@emailmaker/filemanager 0.10.67 → 0.10.68
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.
- package/components/FileContent/FileContentHeader.d.ts +2 -0
- package/components/FileContent/presentation/FileGridItem.d.ts +1 -0
- package/components/FileContent/renderers/FileGridView.d.ts +2 -0
- package/file-manager.esm.js +2 -2
- package/file-manager.esm.js.map +1 -1
- package/file-manager.js +1 -1
- package/package.json +1 -1
package/file-manager.esm.js
CHANGED
|
@@ -6,7 +6,7 @@ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as r from
|
|
|
6
6
|
* Released under MIT license <https://lodash.com/license>
|
|
7
7
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
8
8
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
9
|
-
*/var go=(ho||(ho=1,function(e,t){(function(){var n,r="Expected a function",i="__lodash_hash_undefined__",o="__lodash_placeholder__",a=32,s=128,l=256,c=1/0,u=9007199254740991,d=NaN,h=4294967295,f=[["ary",s],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",a],["partialRight",64],["rearg",l]],p="[object Arguments]",g="[object Array]",m="[object Boolean]",v="[object Date]",y="[object Error]",b="[object Function]",w="[object GeneratorFunction]",x="[object Map]",C="[object Number]",_="[object Object]",S="[object Promise]",k="[object RegExp]",A="[object Set]",E="[object String]",I="[object Symbol]",T="[object WeakMap]",F="[object ArrayBuffer]",O="[object DataView]",P="[object Float32Array]",M="[object Float64Array]",R="[object Int8Array]",L="[object Int16Array]",N="[object Int32Array]",D="[object Uint8Array]",j="[object Uint8ClampedArray]",z="[object Uint16Array]",B="[object Uint32Array]",U=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,H=/(__e\(.*?\)|\b__t\)) \+\n'';/g,W=/&(?:amp|lt|gt|quot|#39);/g,$=/[&<>"']/g,G=RegExp(W.source),q=RegExp($.source),Y=/<%-([\s\S]+?)%>/g,X=/<%([\s\S]+?)%>/g,K=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,J=/^\w*$/,Q=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ee=/[\\^$.*+?()[\]{}|]/g,te=RegExp(ee.source),ne=/^\s+/,re=/\s/,ie=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,oe=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,se=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,le=/[()=,{}\[\]\/\s]/,ce=/\\(\\)?/g,ue=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,de=/\w*$/,he=/^[-+]0x[0-9a-f]+$/i,fe=/^0b[01]+$/i,pe=/^\[object .+?Constructor\]$/,ge=/^0o[0-7]+$/i,me=/^(?:0|[1-9]\d*)$/,ve=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ye=/($^)/,be=/['\n\r\u2028\u2029\\]/g,we="\\ud800-\\udfff",xe="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ce="\\u2700-\\u27bf",_e="a-z\\xdf-\\xf6\\xf8-\\xff",Se="A-Z\\xc0-\\xd6\\xd8-\\xde",ke="\\ufe0e\\ufe0f",Ae="\\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",Ee="['’]",Ie="["+we+"]",Te="["+Ae+"]",Fe="["+xe+"]",Oe="\\d+",Pe="["+Ce+"]",Me="["+_e+"]",Re="[^"+we+Ae+Oe+Ce+_e+Se+"]",Le="\\ud83c[\\udffb-\\udfff]",Ne="[^"+we+"]",De="(?:\\ud83c[\\udde6-\\uddff]){2}",je="[\\ud800-\\udbff][\\udc00-\\udfff]",ze="["+Se+"]",Be="\\u200d",Ue="(?:"+Me+"|"+Re+")",Ve="(?:"+ze+"|"+Re+")",He="(?:['’](?:d|ll|m|re|s|t|ve))?",We="(?:['’](?:D|LL|M|RE|S|T|VE))?",$e="(?:"+Fe+"|"+Le+")?",Ge="["+ke+"]?",qe=Ge+$e+"(?:"+Be+"(?:"+[Ne,De,je].join("|")+")"+Ge+$e+")*",Ye="(?:"+[Pe,De,je].join("|")+")"+qe,Xe="(?:"+[Ne+Fe+"?",Fe,De,je,Ie].join("|")+")",Ke=RegExp(Ee,"g"),Ze=RegExp(Fe,"g"),Je=RegExp(Le+"(?="+Le+")|"+Xe+qe,"g"),Qe=RegExp([ze+"?"+Me+"+"+He+"(?="+[Te,ze,"$"].join("|")+")",Ve+"+"+We+"(?="+[Te,ze+Ue,"$"].join("|")+")",ze+"?"+Ue+"+"+He,ze+"+"+We,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Oe,Ye].join("|"),"g"),et=RegExp("["+Be+we+xe+ke+"]"),tt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["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"],rt=-1,it={};it[P]=it[M]=it[R]=it[L]=it[N]=it[D]=it[j]=it[z]=it[B]=!0,it[p]=it[g]=it[F]=it[m]=it[O]=it[v]=it[y]=it[b]=it[x]=it[C]=it[_]=it[k]=it[A]=it[E]=it[T]=!1;var ot={};ot[p]=ot[g]=ot[F]=ot[O]=ot[m]=ot[v]=ot[P]=ot[M]=ot[R]=ot[L]=ot[N]=ot[x]=ot[C]=ot[_]=ot[k]=ot[A]=ot[E]=ot[I]=ot[D]=ot[j]=ot[z]=ot[B]=!0,ot[y]=ot[b]=ot[T]=!1;var at={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},st=parseFloat,lt=parseInt,ct="object"==typeof Dn&&Dn&&Dn.Object===Object&&Dn,ut="object"==typeof self&&self&&self.Object===Object&&self,dt=ct||ut||Function("return this")(),ht=t&&!t.nodeType&&t,ft=ht&&e&&!e.nodeType&&e,pt=ft&&ft.exports===ht,gt=pt&&ct.process,mt=function(){try{var e=ft&&ft.require&&ft.require("util").types;return e||gt&>.binding&>.binding("util")}catch(e){}}(),vt=mt&&mt.isArrayBuffer,yt=mt&&mt.isDate,bt=mt&&mt.isMap,wt=mt&&mt.isRegExp,xt=mt&&mt.isSet,Ct=mt&&mt.isTypedArray;function _t(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function St(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i<o;){var a=e[i];t(r,a,n(a),e)}return r}function kt(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}function At(e,t){for(var n=null==e?0:e.length;n--&&!1!==t(e[n],n,e););return e}function Et(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function It(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o}function Tt(e,t){return!(null==e||!e.length)&&zt(e,t,0)>-1}function Ft(e,t,n){for(var r=-1,i=null==e?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function Ot(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}function Pt(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function Mt(e,t,n,r){var i=-1,o=null==e?0:e.length;for(r&&o&&(n=e[++i]);++i<o;)n=t(n,e[i],i,e);return n}function Rt(e,t,n,r){var i=null==e?0:e.length;for(r&&i&&(n=e[--i]);i--;)n=t(n,e[i],i,e);return n}function Lt(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var Nt=Ht("length");function Dt(e,t,n){var r;return n(e,function(e,n,i){if(t(e,n,i))return r=n,!1}),r}function jt(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o<i;)if(t(e[o],o,e))return o;return-1}function zt(e,t,n){return t==t?function(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}(e,t,n):jt(e,Ut,n)}function Bt(e,t,n,r){for(var i=n-1,o=e.length;++i<o;)if(r(e[i],t))return i;return-1}function Ut(e){return e!=e}function Vt(e,t){var n=null==e?0:e.length;return n?Gt(e,t)/n:d}function Ht(e){return function(t){return null==t?n:t[e]}}function Wt(e){return function(t){return null==e?n:e[t]}}function $t(e,t,n,r,i){return i(e,function(e,i,o){n=r?(r=!1,e):t(n,e,i,o)}),n}function Gt(e,t){for(var r,i=-1,o=e.length;++i<o;){var a=t(e[i]);a!==n&&(r=r===n?a:r+a)}return r}function qt(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function Yt(e){return e?e.slice(0,hn(e)+1).replace(ne,""):e}function Xt(e){return function(t){return e(t)}}function Kt(e,t){return Ot(t,function(t){return e[t]})}function Zt(e,t){return e.has(t)}function Jt(e,t){for(var n=-1,r=e.length;++n<r&&zt(t,e[n],0)>-1;);return n}function Qt(e,t){for(var n=e.length;n--&&zt(t,e[n],0)>-1;);return n}var en=Wt({"À":"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"}),tn=Wt({"&":"&","<":"<",">":">",'"':""","'":"'"});function nn(e){return"\\"+at[e]}function rn(e){return et.test(e)}function on(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function an(e,t){return function(n){return e(t(n))}}function sn(e,t){for(var n=-1,r=e.length,i=0,a=[];++n<r;){var s=e[n];s!==t&&s!==o||(e[n]=o,a[i++]=n)}return a}function ln(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}function cn(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=[e,e]}),n}function un(e){return rn(e)?function(e){for(var t=Je.lastIndex=0;Je.test(e);)++t;return t}(e):Nt(e)}function dn(e){return rn(e)?function(e){return e.match(Je)||[]}(e):function(e){return e.split("")}(e)}function hn(e){for(var t=e.length;t--&&re.test(e.charAt(t)););return t}var fn=Wt({"&":"&","<":"<",">":">",""":'"',"'":"'"}),pn=function e(t){var re,we=(t=null==t?dt:pn.defaults(dt.Object(),t,pn.pick(dt,nt))).Array,xe=t.Date,Ce=t.Error,_e=t.Function,Se=t.Math,ke=t.Object,Ae=t.RegExp,Ee=t.String,Ie=t.TypeError,Te=we.prototype,Fe=_e.prototype,Oe=ke.prototype,Pe=t["__core-js_shared__"],Me=Fe.toString,Re=Oe.hasOwnProperty,Le=0,Ne=(re=/[^.]+$/.exec(Pe&&Pe.keys&&Pe.keys.IE_PROTO||""))?"Symbol(src)_1."+re:"",De=Oe.toString,je=Me.call(ke),ze=dt._,Be=Ae("^"+Me.call(Re).replace(ee,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ue=pt?t.Buffer:n,Ve=t.Symbol,He=t.Uint8Array,We=Ue?Ue.allocUnsafe:n,$e=an(ke.getPrototypeOf,ke),Ge=ke.create,qe=Oe.propertyIsEnumerable,Ye=Te.splice,Xe=Ve?Ve.isConcatSpreadable:n,Je=Ve?Ve.iterator:n,et=Ve?Ve.toStringTag:n,at=function(){try{var e=uo(ke,"defineProperty");return e({},"",{}),e}catch(e){}}(),ct=t.clearTimeout!==dt.clearTimeout&&t.clearTimeout,ut=xe&&xe.now!==dt.Date.now&&xe.now,ht=t.setTimeout!==dt.setTimeout&&t.setTimeout,ft=Se.ceil,gt=Se.floor,mt=ke.getOwnPropertySymbols,Nt=Ue?Ue.isBuffer:n,Wt=t.isFinite,gn=Te.join,mn=an(ke.keys,ke),vn=Se.max,yn=Se.min,bn=xe.now,wn=t.parseInt,xn=Se.random,Cn=Te.reverse,_n=uo(t,"DataView"),Sn=uo(t,"Map"),kn=uo(t,"Promise"),An=uo(t,"Set"),En=uo(t,"WeakMap"),In=uo(ke,"create"),Tn=En&&new En,Fn={},On=Do(_n),Pn=Do(Sn),Mn=Do(kn),Rn=Do(An),Ln=Do(En),Nn=Ve?Ve.prototype:n,Dn=Nn?Nn.valueOf:n,jn=Nn?Nn.toString:n;function zn(e){if(es(e)&&!Ha(e)&&!(e instanceof Hn)){if(e instanceof Vn)return e;if(Re.call(e,"__wrapped__"))return jo(e)}return new Vn(e)}var Bn=function(){function e(){}return function(t){if(!Qa(t))return{};if(Ge)return Ge(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function Un(){}function Vn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}function Hn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=h,this.__views__=[]}function Wn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function $n(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Gn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function qn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Gn;++t<n;)this.add(e[t])}function Yn(e){var t=this.__data__=new $n(e);this.size=t.size}function Xn(e,t){var n=Ha(e),r=!n&&Va(e),i=!n&&!r&&qa(e),o=!n&&!r&&!i&&ls(e),a=n||r||i||o,s=a?qt(e.length,Ee):[],l=s.length;for(var c in e)!t&&!Re.call(e,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||yo(c,l))||s.push(c);return s}function Kn(e){var t=e.length;return t?e[qr(0,t-1)]:n}function Zn(e,t){return Ro(Ii(e),ar(t,0,e.length))}function Jn(e){return Ro(Ii(e))}function Qn(e,t,r){(r!==n&&!za(e[t],r)||r===n&&!(t in e))&&ir(e,t,r)}function er(e,t,r){var i=e[t];Re.call(e,t)&&za(i,r)&&(r!==n||t in e)||ir(e,t,r)}function tr(e,t){for(var n=e.length;n--;)if(za(e[n][0],t))return n;return-1}function nr(e,t,n,r){return dr(e,function(e,i,o){t(r,e,n(e),o)}),r}function rr(e,t){return e&&Ti(t,Fs(t),e)}function ir(e,t,n){"__proto__"==t&&at?at(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function or(e,t){for(var r=-1,i=t.length,o=we(i),a=null==e;++r<i;)o[r]=a?n:ks(e,t[r]);return o}function ar(e,t,r){return e==e&&(r!==n&&(e=e<=r?e:r),t!==n&&(e=e>=t?e:t)),e}function sr(e,t,r,i,o,a){var s,l=1&t,c=2&t,u=4&t;if(r&&(s=o?r(e,i,o,a):r(e)),s!==n)return s;if(!Qa(e))return e;var d=Ha(e);if(d){if(s=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Re.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Ii(e,s)}else{var h=po(e),f=h==b||h==w;if(qa(e))return Ci(e,l);if(h==_||h==p||f&&!o){if(s=c||f?{}:mo(e),!l)return c?function(e,t){return Ti(e,fo(e),t)}(e,function(e,t){return e&&Ti(t,Os(t),e)}(s,e)):function(e,t){return Ti(e,ho(e),t)}(e,rr(s,e))}else{if(!ot[h])return o?e:{};s=function(e,t,n){var r,i=e.constructor;switch(t){case F:return _i(e);case m:case v:return new i(+e);case O:return function(e,t){var n=t?_i(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case P:case M:case R:case L:case N:case D:case j:case z:case B:return Si(e,n);case x:return new i;case C:case E:return new i(e);case k:return function(e){var t=new e.constructor(e.source,de.exec(e));return t.lastIndex=e.lastIndex,t}(e);case A:return new i;case I:return r=e,Dn?ke(Dn.call(r)):{}}}(e,h,l)}}a||(a=new Yn);var g=a.get(e);if(g)return g;a.set(e,s),os(e)?e.forEach(function(n){s.add(sr(n,t,r,n,e,a))}):ts(e)&&e.forEach(function(n,i){s.set(i,sr(n,t,r,i,e,a))});var y=d?n:(u?c?ro:no:c?Os:Fs)(e);return kt(y||e,function(n,i){y&&(n=e[i=n]),er(s,i,sr(n,t,r,i,e,a))}),s}function lr(e,t,r){var i=r.length;if(null==e)return!i;for(e=ke(e);i--;){var o=r[i],a=t[o],s=e[o];if(s===n&&!(o in e)||!a(s))return!1}return!0}function cr(e,t,i){if("function"!=typeof e)throw new Ie(r);return Fo(function(){e.apply(n,i)},t)}function ur(e,t,n,r){var i=-1,o=Tt,a=!0,s=e.length,l=[],c=t.length;if(!s)return l;n&&(t=Ot(t,Xt(n))),r?(o=Ft,a=!1):t.length>=200&&(o=Zt,a=!1,t=new qn(t));e:for(;++i<s;){var u=e[i],d=null==n?u:n(u);if(u=r||0!==u?u:0,a&&d==d){for(var h=c;h--;)if(t[h]===d)continue e;l.push(u)}else o(t,d,r)||l.push(u)}return l}zn.templateSettings={escape:Y,evaluate:X,interpolate:K,variable:"",imports:{_:zn}},zn.prototype=Un.prototype,zn.prototype.constructor=zn,Vn.prototype=Bn(Un.prototype),Vn.prototype.constructor=Vn,Hn.prototype=Bn(Un.prototype),Hn.prototype.constructor=Hn,Wn.prototype.clear=function(){this.__data__=In?In(null):{},this.size=0},Wn.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Wn.prototype.get=function(e){var t=this.__data__;if(In){var r=t[e];return r===i?n:r}return Re.call(t,e)?t[e]:n},Wn.prototype.has=function(e){var t=this.__data__;return In?t[e]!==n:Re.call(t,e)},Wn.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=In&&t===n?i:t,this},$n.prototype.clear=function(){this.__data__=[],this.size=0},$n.prototype.delete=function(e){var t=this.__data__,n=tr(t,e);return!(n<0||(n==t.length-1?t.pop():Ye.call(t,n,1),--this.size,0))},$n.prototype.get=function(e){var t=this.__data__,r=tr(t,e);return r<0?n:t[r][1]},$n.prototype.has=function(e){return tr(this.__data__,e)>-1},$n.prototype.set=function(e,t){var n=this.__data__,r=tr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Gn.prototype.clear=function(){this.size=0,this.__data__={hash:new Wn,map:new(Sn||$n),string:new Wn}},Gn.prototype.delete=function(e){var t=lo(this,e).delete(e);return this.size-=t?1:0,t},Gn.prototype.get=function(e){return lo(this,e).get(e)},Gn.prototype.has=function(e){return lo(this,e).has(e)},Gn.prototype.set=function(e,t){var n=lo(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},qn.prototype.add=qn.prototype.push=function(e){return this.__data__.set(e,i),this},qn.prototype.has=function(e){return this.__data__.has(e)},Yn.prototype.clear=function(){this.__data__=new $n,this.size=0},Yn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Yn.prototype.get=function(e){return this.__data__.get(e)},Yn.prototype.has=function(e){return this.__data__.has(e)},Yn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof $n){var r=n.__data__;if(!Sn||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Gn(r)}return n.set(e,t),this.size=n.size,this};var dr=Pi(br),hr=Pi(wr,!0);function fr(e,t){var n=!0;return dr(e,function(e,r,i){return n=!!t(e,r,i)}),n}function pr(e,t,r){for(var i=-1,o=e.length;++i<o;){var a=e[i],s=t(a);if(null!=s&&(l===n?s==s&&!ss(s):r(s,l)))var l=s,c=a}return c}function gr(e,t){var n=[];return dr(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function mr(e,t,n,r,i){var o=-1,a=e.length;for(n||(n=vo),i||(i=[]);++o<a;){var s=e[o];t>0&&n(s)?t>1?mr(s,t-1,n,r,i):Pt(i,s):r||(i[i.length]=s)}return i}var vr=Mi(),yr=Mi(!0);function br(e,t){return e&&vr(e,t,Fs)}function wr(e,t){return e&&yr(e,t,Fs)}function xr(e,t){return It(t,function(t){return Ka(e[t])})}function Cr(e,t){for(var r=0,i=(t=yi(t,e)).length;null!=e&&r<i;)e=e[No(t[r++])];return r&&r==i?e:n}function _r(e,t,n){var r=t(e);return Ha(e)?r:Pt(r,n(e))}function Sr(e){return null==e?e===n?"[object Undefined]":"[object Null]":et&&et in ke(e)?function(e){var t=Re.call(e,et),r=e[et];try{e[et]=n;var i=!0}catch(e){}var o=De.call(e);return i&&(t?e[et]=r:delete e[et]),o}(e):function(e){return De.call(e)}(e)}function kr(e,t){return e>t}function Ar(e,t){return null!=e&&Re.call(e,t)}function Er(e,t){return null!=e&&t in ke(e)}function Ir(e,t,r){for(var i=r?Ft:Tt,o=e[0].length,a=e.length,s=a,l=we(a),c=1/0,u=[];s--;){var d=e[s];s&&t&&(d=Ot(d,Xt(t))),c=yn(d.length,c),l[s]=!r&&(t||o>=120&&d.length>=120)?new qn(s&&d):n}d=e[0];var h=-1,f=l[0];e:for(;++h<o&&u.length<c;){var p=d[h],g=t?t(p):p;if(p=r||0!==p?p:0,!(f?Zt(f,g):i(u,g,r))){for(s=a;--s;){var m=l[s];if(!(m?Zt(m,g):i(e[s],g,r)))continue e}f&&f.push(g),u.push(p)}}return u}function Tr(e,t,r){var i=null==(e=Eo(e,t=yi(t,e)))?e:e[No(Xo(t))];return null==i?n:_t(i,e,r)}function Fr(e){return es(e)&&Sr(e)==p}function Or(e,t,r,i,o){return e===t||(null==e||null==t||!es(e)&&!es(t)?e!=e&&t!=t:function(e,t,r,i,o,a){var s=Ha(e),l=Ha(t),c=s?g:po(e),u=l?g:po(t),d=(c=c==p?_:c)==_,h=(u=u==p?_:u)==_,f=c==u;if(f&&qa(e)){if(!qa(t))return!1;s=!0,d=!1}if(f&&!d)return a||(a=new Yn),s||ls(e)?eo(e,t,r,i,o,a):function(e,t,n,r,i,o,a){switch(n){case O:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case F:return!(e.byteLength!=t.byteLength||!o(new He(e),new He(t)));case m:case v:case C:return za(+e,+t);case y:return e.name==t.name&&e.message==t.message;case k:case E:return e==t+"";case x:var s=on;case A:var l=1&r;if(s||(s=ln),e.size!=t.size&&!l)return!1;var c=a.get(e);if(c)return c==t;r|=2,a.set(e,t);var u=eo(s(e),s(t),r,i,o,a);return a.delete(e),u;case I:if(Dn)return Dn.call(e)==Dn.call(t)}return!1}(e,t,c,r,i,o,a);if(!(1&r)){var b=d&&Re.call(e,"__wrapped__"),w=h&&Re.call(t,"__wrapped__");if(b||w){var S=b?e.value():e,T=w?t.value():t;return a||(a=new Yn),o(S,T,r,i,a)}}return!!f&&(a||(a=new Yn),function(e,t,r,i,o,a){var s=1&r,l=no(e),c=l.length,u=no(t),d=u.length;if(c!=d&&!s)return!1;for(var h=c;h--;){var f=l[h];if(!(s?f in t:Re.call(t,f)))return!1}var p=a.get(e),g=a.get(t);if(p&&g)return p==t&&g==e;var m=!0;a.set(e,t),a.set(t,e);for(var v=s;++h<c;){var y=e[f=l[h]],b=t[f];if(i)var w=s?i(b,y,f,t,e,a):i(y,b,f,e,t,a);if(!(w===n?y===b||o(y,b,r,i,a):w)){m=!1;break}v||(v="constructor"==f)}if(m&&!v){var x=e.constructor,C=t.constructor;x==C||!("constructor"in e)||!("constructor"in t)||"function"==typeof x&&x instanceof x&&"function"==typeof C&&C instanceof C||(m=!1)}return a.delete(e),a.delete(t),m}(e,t,r,i,o,a))}(e,t,r,i,Or,o))}function Pr(e,t,r,i){var o=r.length,a=o,s=!i;if(null==e)return!a;for(e=ke(e);o--;){var l=r[o];if(s&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++o<a;){var c=(l=r[o])[0],u=e[c],d=l[1];if(s&&l[2]){if(u===n&&!(c in e))return!1}else{var h=new Yn;if(i)var f=i(u,d,c,e,t,h);if(!(f===n?Or(d,u,3,i,h):f))return!1}}return!0}function Mr(e){return!(!Qa(e)||(t=e,Ne&&Ne in t))&&(Ka(e)?Be:pe).test(Do(e));var t}function Rr(e){return"function"==typeof e?e:null==e?nl:"object"==typeof e?Ha(e)?Br(e[0],e[1]):zr(e):dl(e)}function Lr(e){if(!_o(e))return mn(e);var t=[];for(var n in ke(e))Re.call(e,n)&&"constructor"!=n&&t.push(n);return t}function Nr(e){if(!Qa(e))return function(e){var t=[];if(null!=e)for(var n in ke(e))t.push(n);return t}(e);var t=_o(e),n=[];for(var r in e)("constructor"!=r||!t&&Re.call(e,r))&&n.push(r);return n}function Dr(e,t){return e<t}function jr(e,t){var n=-1,r=$a(e)?we(e.length):[];return dr(e,function(e,i,o){r[++n]=t(e,i,o)}),r}function zr(e){var t=co(e);return 1==t.length&&t[0][2]?ko(t[0][0],t[0][1]):function(n){return n===e||Pr(n,e,t)}}function Br(e,t){return wo(e)&&So(t)?ko(No(e),t):function(r){var i=ks(r,e);return i===n&&i===t?As(r,e):Or(t,i,3)}}function Ur(e,t,r,i,o){e!==t&&vr(t,function(a,s){if(o||(o=new Yn),Qa(a))!function(e,t,r,i,o,a,s){var l=Io(e,r),c=Io(t,r),u=s.get(c);if(u)Qn(e,r,u);else{var d=a?a(l,c,r+"",e,t,s):n,h=d===n;if(h){var f=Ha(c),p=!f&&qa(c),g=!f&&!p&&ls(c);d=c,f||p||g?Ha(l)?d=l:Ga(l)?d=Ii(l):p?(h=!1,d=Ci(c,!0)):g?(h=!1,d=Si(c,!0)):d=[]:rs(c)||Va(c)?(d=l,Va(l)?d=ms(l):Qa(l)&&!Ka(l)||(d=mo(c))):h=!1}h&&(s.set(c,d),o(d,c,i,a,s),s.delete(c)),Qn(e,r,d)}}(e,t,s,r,Ur,i,o);else{var l=i?i(Io(e,s),a,s+"",e,t,o):n;l===n&&(l=a),Qn(e,s,l)}},Os)}function Vr(e,t){var r=e.length;if(r)return yo(t+=t<0?r:0,r)?e[t]:n}function Hr(e,t,n){t=t.length?Ot(t,function(e){return Ha(e)?function(t){return Cr(t,1===e.length?e[0]:e)}:e}):[nl];var r=-1;t=Ot(t,Xt(so()));var i=jr(e,function(e,n,i){var o=Ot(t,function(t){return t(e)});return{criteria:o,index:++r,value:e}});return function(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}(i,function(e,t){return function(e,t,n){for(var r=-1,i=e.criteria,o=t.criteria,a=i.length,s=n.length;++r<a;){var l=ki(i[r],o[r]);if(l)return r>=s?l:l*("desc"==n[r]?-1:1)}return e.index-t.index}(e,t,n)})}function Wr(e,t,n){for(var r=-1,i=t.length,o={};++r<i;){var a=t[r],s=Cr(e,a);n(s,a)&&Jr(o,yi(a,e),s)}return o}function $r(e,t,n,r){var i=r?Bt:zt,o=-1,a=t.length,s=e;for(e===t&&(t=Ii(t)),n&&(s=Ot(e,Xt(n)));++o<a;)for(var l=0,c=t[o],u=n?n(c):c;(l=i(s,u,l,r))>-1;)s!==e&&Ye.call(s,l,1),Ye.call(e,l,1);return e}function Gr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;yo(i)?Ye.call(e,i,1):ui(e,i)}}return e}function qr(e,t){return e+gt(xn()*(t-e+1))}function Yr(e,t){var n="";if(!e||t<1||t>u)return n;do{t%2&&(n+=e),(t=gt(t/2))&&(e+=e)}while(t);return n}function Xr(e,t){return Oo(Ao(e,t,nl),e+"")}function Kr(e){return Kn(zs(e))}function Zr(e,t){var n=zs(e);return Ro(n,ar(t,0,n.length))}function Jr(e,t,r,i){if(!Qa(e))return e;for(var o=-1,a=(t=yi(t,e)).length,s=a-1,l=e;null!=l&&++o<a;){var c=No(t[o]),u=r;if("__proto__"===c||"constructor"===c||"prototype"===c)return e;if(o!=s){var d=l[c];(u=i?i(d,c,l):n)===n&&(u=Qa(d)?d:yo(t[o+1])?[]:{})}er(l,c,u),l=l[c]}return e}var Qr=Tn?function(e,t){return Tn.set(e,t),e}:nl,ei=at?function(e,t){return at(e,"toString",{configurable:!0,enumerable:!1,value:Qs(t),writable:!0})}:nl;function ti(e){return Ro(zs(e))}function ni(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=we(i);++r<i;)o[r]=e[r+t];return o}function ri(e,t){var n;return dr(e,function(e,r,i){return!(n=t(e,r,i))}),!!n}function ii(e,t,n){var r=0,i=null==e?r:e.length;if("number"==typeof t&&t==t&&i<=2147483647){for(;r<i;){var o=r+i>>>1,a=e[o];null!==a&&!ss(a)&&(n?a<=t:a<t)?r=o+1:i=o}return i}return oi(e,t,nl,n)}function oi(e,t,r,i){var o=0,a=null==e?0:e.length;if(0===a)return 0;for(var s=(t=r(t))!=t,l=null===t,c=ss(t),u=t===n;o<a;){var d=gt((o+a)/2),h=r(e[d]),f=h!==n,p=null===h,g=h==h,m=ss(h);if(s)var v=i||g;else v=u?g&&(i||f):l?g&&f&&(i||!p):c?g&&f&&!p&&(i||!m):!p&&!m&&(i?h<=t:h<t);v?o=d+1:a=d}return yn(a,4294967294)}function ai(e,t){for(var n=-1,r=e.length,i=0,o=[];++n<r;){var a=e[n],s=t?t(a):a;if(!n||!za(s,l)){var l=s;o[i++]=0===a?0:a}}return o}function si(e){return"number"==typeof e?e:ss(e)?d:+e}function li(e){if("string"==typeof e)return e;if(Ha(e))return Ot(e,li)+"";if(ss(e))return jn?jn.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function ci(e,t,n){var r=-1,i=Tt,o=e.length,a=!0,s=[],l=s;if(n)a=!1,i=Ft;else if(o>=200){var c=t?null:Yi(e);if(c)return ln(c);a=!1,i=Zt,l=new qn}else l=t?[]:s;e:for(;++r<o;){var u=e[r],d=t?t(u):u;if(u=n||0!==u?u:0,a&&d==d){for(var h=l.length;h--;)if(l[h]===d)continue e;t&&l.push(d),s.push(u)}else i(l,d,n)||(l!==s&&l.push(d),s.push(u))}return s}function ui(e,t){return null==(e=Eo(e,t=yi(t,e)))||delete e[No(Xo(t))]}function di(e,t,n,r){return Jr(e,t,n(Cr(e,t)),r)}function hi(e,t,n,r){for(var i=e.length,o=r?i:-1;(r?o--:++o<i)&&t(e[o],o,e););return n?ni(e,r?0:o,r?o+1:i):ni(e,r?o+1:0,r?i:o)}function fi(e,t){var n=e;return n instanceof Hn&&(n=n.value()),Mt(t,function(e,t){return t.func.apply(t.thisArg,Pt([e],t.args))},n)}function pi(e,t,n){var r=e.length;if(r<2)return r?ci(e[0]):[];for(var i=-1,o=we(r);++i<r;)for(var a=e[i],s=-1;++s<r;)s!=i&&(o[i]=ur(o[i]||a,e[s],t,n));return ci(mr(o,1),t,n)}function gi(e,t,r){for(var i=-1,o=e.length,a=t.length,s={};++i<o;){var l=i<a?t[i]:n;r(s,e[i],l)}return s}function mi(e){return Ga(e)?e:[]}function vi(e){return"function"==typeof e?e:nl}function yi(e,t){return Ha(e)?e:wo(e,t)?[e]:Lo(vs(e))}var bi=Xr;function wi(e,t,r){var i=e.length;return r=r===n?i:r,!t&&r>=i?e:ni(e,t,r)}var xi=ct||function(e){return dt.clearTimeout(e)};function Ci(e,t){if(t)return e.slice();var n=e.length,r=We?We(n):new e.constructor(n);return e.copy(r),r}function _i(e){var t=new e.constructor(e.byteLength);return new He(t).set(new He(e)),t}function Si(e,t){var n=t?_i(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function ki(e,t){if(e!==t){var r=e!==n,i=null===e,o=e==e,a=ss(e),s=t!==n,l=null===t,c=t==t,u=ss(t);if(!l&&!u&&!a&&e>t||a&&s&&c&&!l&&!u||i&&s&&c||!r&&c||!o)return 1;if(!i&&!a&&!u&&e<t||u&&r&&o&&!i&&!a||l&&r&&o||!s&&o||!c)return-1}return 0}function Ai(e,t,n,r){for(var i=-1,o=e.length,a=n.length,s=-1,l=t.length,c=vn(o-a,0),u=we(l+c),d=!r;++s<l;)u[s]=t[s];for(;++i<a;)(d||i<o)&&(u[n[i]]=e[i]);for(;c--;)u[s++]=e[i++];return u}function Ei(e,t,n,r){for(var i=-1,o=e.length,a=-1,s=n.length,l=-1,c=t.length,u=vn(o-s,0),d=we(u+c),h=!r;++i<u;)d[i]=e[i];for(var f=i;++l<c;)d[f+l]=t[l];for(;++a<s;)(h||i<o)&&(d[f+n[a]]=e[i++]);return d}function Ii(e,t){var n=-1,r=e.length;for(t||(t=we(r));++n<r;)t[n]=e[n];return t}function Ti(e,t,r,i){var o=!r;r||(r={});for(var a=-1,s=t.length;++a<s;){var l=t[a],c=i?i(r[l],e[l],l,r,e):n;c===n&&(c=e[l]),o?ir(r,l,c):er(r,l,c)}return r}function Fi(e,t){return function(n,r){var i=Ha(n)?St:nr,o=t?t():{};return i(n,e,so(r,2),o)}}function Oi(e){return Xr(function(t,r){var i=-1,o=r.length,a=o>1?r[o-1]:n,s=o>2?r[2]:n;for(a=e.length>3&&"function"==typeof a?(o--,a):n,s&&bo(r[0],r[1],s)&&(a=o<3?n:a,o=1),t=ke(t);++i<o;){var l=r[i];l&&e(t,l,i,a)}return t})}function Pi(e,t){return function(n,r){if(null==n)return n;if(!$a(n))return e(n,r);for(var i=n.length,o=t?i:-1,a=ke(n);(t?o--:++o<i)&&!1!==r(a[o],o,a););return n}}function Mi(e){return function(t,n,r){for(var i=-1,o=ke(t),a=r(t),s=a.length;s--;){var l=a[e?s:++i];if(!1===n(o[l],l,o))break}return t}}function Ri(e){return function(t){var r=rn(t=vs(t))?dn(t):n,i=r?r[0]:t.charAt(0),o=r?wi(r,1).join(""):t.slice(1);return i[e]()+o}}function Li(e){return function(t){return Mt(Ks(Vs(t).replace(Ke,"")),e,"")}}function Ni(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 n=Bn(e.prototype),r=e.apply(n,t);return Qa(r)?r:n}}function Di(e){return function(t,r,i){var o=ke(t);if(!$a(t)){var a=so(r,3);t=Fs(t),r=function(e){return a(o[e],e,o)}}var s=e(t,r,i);return s>-1?o[a?t[s]:s]:n}}function ji(e){return to(function(t){var i=t.length,o=i,a=Vn.prototype.thru;for(e&&t.reverse();o--;){var s=t[o];if("function"!=typeof s)throw new Ie(r);if(a&&!l&&"wrapper"==oo(s))var l=new Vn([],!0)}for(o=l?o:i;++o<i;){var c=oo(s=t[o]),u="wrapper"==c?io(s):n;l=u&&xo(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?l[oo(u[0])].apply(l,u[3]):1==s.length&&xo(s)?l[c]():l.thru(s)}return function(){var e=arguments,n=e[0];if(l&&1==e.length&&Ha(n))return l.plant(n).value();for(var r=0,o=i?t[r].apply(this,e):n;++r<i;)o=t[r].call(this,o);return o}})}function zi(e,t,r,i,o,a,l,c,u,d){var h=t&s,f=1&t,p=2&t,g=24&t,m=512&t,v=p?n:Ni(e);return function s(){for(var y=arguments.length,b=we(y),w=y;w--;)b[w]=arguments[w];if(g)var x=ao(s),C=function(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}(b,x);if(i&&(b=Ai(b,i,o,g)),a&&(b=Ei(b,a,l,g)),y-=C,g&&y<d){var _=sn(b,x);return Gi(e,t,zi,s.placeholder,r,b,_,c,u,d-y)}var S=f?r:this,k=p?S[e]:e;return y=b.length,c?b=function(e,t){for(var r=e.length,i=yn(t.length,r),o=Ii(e);i--;){var a=t[i];e[i]=yo(a,r)?o[a]:n}return e}(b,c):m&&y>1&&b.reverse(),h&&u<y&&(b.length=u),this&&this!==dt&&this instanceof s&&(k=v||Ni(k)),k.apply(S,b)}}function Bi(e,t){return function(n,r){return function(e,t,n,r){return br(e,function(e,i,o){t(r,n(e),i,o)}),r}(n,e,t(r),{})}}function Ui(e,t){return function(r,i){var o;if(r===n&&i===n)return t;if(r!==n&&(o=r),i!==n){if(o===n)return i;"string"==typeof r||"string"==typeof i?(r=li(r),i=li(i)):(r=si(r),i=si(i)),o=e(r,i)}return o}}function Vi(e){return to(function(t){return t=Ot(t,Xt(so())),Xr(function(n){var r=this;return e(t,function(e){return _t(e,r,n)})})})}function Hi(e,t){var r=(t=t===n?" ":li(t)).length;if(r<2)return r?Yr(t,e):t;var i=Yr(t,ft(e/un(t)));return rn(t)?wi(dn(i),0,e).join(""):i.slice(0,e)}function Wi(e){return function(t,r,i){return i&&"number"!=typeof i&&bo(t,r,i)&&(r=i=n),t=hs(t),r===n?(r=t,t=0):r=hs(r),function(e,t,n,r){for(var i=-1,o=vn(ft((t-e)/(n||1)),0),a=we(o);o--;)a[r?o:++i]=e,e+=n;return a}(t,r,i=i===n?t<r?1:-1:hs(i),e)}}function $i(e){return function(t,n){return"string"==typeof t&&"string"==typeof n||(t=gs(t),n=gs(n)),e(t,n)}}function Gi(e,t,r,i,o,s,l,c,u,d){var h=8&t;t|=h?a:64,4&(t&=~(h?64:a))||(t&=-4);var f=[e,t,o,h?s:n,h?l:n,h?n:s,h?n:l,c,u,d],p=r.apply(n,f);return xo(e)&&To(p,f),p.placeholder=i,Po(p,e,t)}function qi(e){var t=Se[e];return function(e,n){if(e=gs(e),(n=null==n?0:yn(fs(n),292))&&Wt(e)){var r=(vs(e)+"e").split("e");return+((r=(vs(t(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return t(e)}}var Yi=An&&1/ln(new An([,-0]))[1]==c?function(e){return new An(e)}:sl;function Xi(e){return function(t){var n=po(t);return n==x?on(t):n==A?cn(t):function(e,t){return Ot(t,function(t){return[t,e[t]]})}(t,e(t))}}function Ki(e,t,i,c,u,d,h,f){var p=2&t;if(!p&&"function"!=typeof e)throw new Ie(r);var g=c?c.length:0;if(g||(t&=-97,c=u=n),h=h===n?h:vn(fs(h),0),f=f===n?f:fs(f),g-=u?u.length:0,64&t){var m=c,v=u;c=u=n}var y=p?n:io(e),b=[e,t,i,c,u,m,v,d,h,f];if(y&&function(e,t){var n=e[1],r=t[1],i=n|r,a=i<131,c=r==s&&8==n||r==s&&n==l&&e[7].length<=t[8]||384==r&&t[7].length<=t[8]&&8==n;if(!a&&!c)return e;1&r&&(e[2]=t[2],i|=1&n?0:4);var u=t[3];if(u){var d=e[3];e[3]=d?Ai(d,u,t[4]):u,e[4]=d?sn(e[3],o):t[4]}(u=t[5])&&(d=e[5],e[5]=d?Ei(d,u,t[6]):u,e[6]=d?sn(e[5],o):t[6]),(u=t[7])&&(e[7]=u),r&s&&(e[8]=null==e[8]?t[8]:yn(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=i}(b,y),e=b[0],t=b[1],i=b[2],c=b[3],u=b[4],!(f=b[9]=b[9]===n?p?0:e.length:vn(b[9]-g,0))&&24&t&&(t&=-25),t&&1!=t)w=8==t||16==t?function(e,t,r){var i=Ni(e);return function o(){for(var a=arguments.length,s=we(a),l=a,c=ao(o);l--;)s[l]=arguments[l];var u=a<3&&s[0]!==c&&s[a-1]!==c?[]:sn(s,c);return(a-=u.length)<r?Gi(e,t,zi,o.placeholder,n,s,u,n,n,r-a):_t(this&&this!==dt&&this instanceof o?i:e,this,s)}}(e,t,f):t!=a&&33!=t||u.length?zi.apply(n,b):function(e,t,n,r){var i=1&t,o=Ni(e);return function t(){for(var a=-1,s=arguments.length,l=-1,c=r.length,u=we(c+s),d=this&&this!==dt&&this instanceof t?o:e;++l<c;)u[l]=r[l];for(;s--;)u[l++]=arguments[++a];return _t(d,i?n:this,u)}}(e,t,i,c);else var w=function(e,t,n){var r=1&t,i=Ni(e);return function t(){return(this&&this!==dt&&this instanceof t?i:e).apply(r?n:this,arguments)}}(e,t,i);return Po((y?Qr:To)(w,b),e,t)}function Zi(e,t,r,i){return e===n||za(e,Oe[r])&&!Re.call(i,r)?t:e}function Ji(e,t,r,i,o,a){return Qa(e)&&Qa(t)&&(a.set(t,e),Ur(e,t,n,Ji,a),a.delete(t)),e}function Qi(e){return rs(e)?n:e}function eo(e,t,r,i,o,a){var s=1&r,l=e.length,c=t.length;if(l!=c&&!(s&&c>l))return!1;var u=a.get(e),d=a.get(t);if(u&&d)return u==t&&d==e;var h=-1,f=!0,p=2&r?new qn:n;for(a.set(e,t),a.set(t,e);++h<l;){var g=e[h],m=t[h];if(i)var v=s?i(m,g,h,t,e,a):i(g,m,h,e,t,a);if(v!==n){if(v)continue;f=!1;break}if(p){if(!Lt(t,function(e,t){if(!Zt(p,t)&&(g===e||o(g,e,r,i,a)))return p.push(t)})){f=!1;break}}else if(g!==m&&!o(g,m,r,i,a)){f=!1;break}}return a.delete(e),a.delete(t),f}function to(e){return Oo(Ao(e,n,Wo),e+"")}function no(e){return _r(e,Fs,ho)}function ro(e){return _r(e,Os,fo)}var io=Tn?function(e){return Tn.get(e)}:sl;function oo(e){for(var t=e.name+"",n=Fn[t],r=Re.call(Fn,t)?n.length:0;r--;){var i=n[r],o=i.func;if(null==o||o==e)return i.name}return t}function ao(e){return(Re.call(zn,"placeholder")?zn:e).placeholder}function so(){var e=zn.iteratee||rl;return e=e===rl?Rr:e,arguments.length?e(arguments[0],arguments[1]):e}function lo(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function co(e){for(var t=Fs(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,So(i)]}return t}function uo(e,t){var r=function(e,t){return null==e?n:e[t]}(e,t);return Mr(r)?r:n}var ho=mt?function(e){return null==e?[]:(e=ke(e),It(mt(e),function(t){return qe.call(e,t)}))}:pl,fo=mt?function(e){for(var t=[];e;)Pt(t,ho(e)),e=$e(e);return t}:pl,po=Sr;function go(e,t,n){for(var r=-1,i=(t=yi(t,e)).length,o=!1;++r<i;){var a=No(t[r]);if(!(o=null!=e&&n(e,a)))break;e=e[a]}return o||++r!=i?o:!!(i=null==e?0:e.length)&&Ja(i)&&yo(a,i)&&(Ha(e)||Va(e))}function mo(e){return"function"!=typeof e.constructor||_o(e)?{}:Bn($e(e))}function vo(e){return Ha(e)||Va(e)||!!(Xe&&e&&e[Xe])}function yo(e,t){var n=typeof e;return!!(t=null==t?u:t)&&("number"==n||"symbol"!=n&&me.test(e))&&e>-1&&e%1==0&&e<t}function bo(e,t,n){if(!Qa(n))return!1;var r=typeof t;return!!("number"==r?$a(n)&&yo(t,n.length):"string"==r&&t in n)&&za(n[t],e)}function wo(e,t){if(Ha(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!ss(e))||J.test(e)||!Z.test(e)||null!=t&&e in ke(t)}function xo(e){var t=oo(e),n=zn[t];if("function"!=typeof n||!(t in Hn.prototype))return!1;if(e===n)return!0;var r=io(n);return!!r&&e===r[0]}(_n&&po(new _n(new ArrayBuffer(1)))!=O||Sn&&po(new Sn)!=x||kn&&po(kn.resolve())!=S||An&&po(new An)!=A||En&&po(new En)!=T)&&(po=function(e){var t=Sr(e),r=t==_?e.constructor:n,i=r?Do(r):"";if(i)switch(i){case On:return O;case Pn:return x;case Mn:return S;case Rn:return A;case Ln:return T}return t});var Co=Pe?Ka:gl;function _o(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Oe)}function So(e){return e==e&&!Qa(e)}function ko(e,t){return function(r){return null!=r&&r[e]===t&&(t!==n||e in ke(r))}}function Ao(e,t,r){return t=vn(t===n?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=vn(n.length-t,0),a=we(o);++i<o;)a[i]=n[t+i];i=-1;for(var s=we(t+1);++i<t;)s[i]=n[i];return s[t]=r(a),_t(e,this,s)}}function Eo(e,t){return t.length<2?e:Cr(e,ni(t,0,-1))}function Io(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var To=Mo(Qr),Fo=ht||function(e,t){return dt.setTimeout(e,t)},Oo=Mo(ei);function Po(e,t,n){var r=t+"";return Oo(e,function(e,t){var n=t.length;if(!n)return e;var r=n-1;return t[r]=(n>1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(ie,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return kt(f,function(n){var r="_."+n[0];t&n[1]&&!Tt(e,r)&&e.push(r)}),e.sort()}(function(e){var t=e.match(oe);return t?t[1].split(ae):[]}(r),n)))}function Mo(e){var t=0,r=0;return function(){var i=bn(),o=16-(i-r);if(r=i,o>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(n,arguments)}}function Ro(e,t){var r=-1,i=e.length,o=i-1;for(t=t===n?i:t;++r<t;){var a=qr(r,o),s=e[a];e[a]=e[r],e[r]=s}return e.length=t,e}var Lo=function(e){var t=Ma(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(Q,function(e,n,r,i){t.push(r?i.replace(ce,"$1"):n||e)}),t});function No(e){if("string"==typeof e||ss(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Do(e){if(null!=e){try{return Me.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function jo(e){if(e instanceof Hn)return e.clone();var t=new Vn(e.__wrapped__,e.__chain__);return t.__actions__=Ii(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var zo=Xr(function(e,t){return Ga(e)?ur(e,mr(t,1,Ga,!0)):[]}),Bo=Xr(function(e,t){var r=Xo(t);return Ga(r)&&(r=n),Ga(e)?ur(e,mr(t,1,Ga,!0),so(r,2)):[]}),Uo=Xr(function(e,t){var r=Xo(t);return Ga(r)&&(r=n),Ga(e)?ur(e,mr(t,1,Ga,!0),n,r):[]});function Vo(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:fs(n);return i<0&&(i=vn(r+i,0)),jt(e,so(t,3),i)}function Ho(e,t,r){var i=null==e?0:e.length;if(!i)return-1;var o=i-1;return r!==n&&(o=fs(r),o=r<0?vn(i+o,0):yn(o,i-1)),jt(e,so(t,3),o,!0)}function Wo(e){return null!=e&&e.length?mr(e,1):[]}function $o(e){return e&&e.length?e[0]:n}var Go=Xr(function(e){var t=Ot(e,mi);return t.length&&t[0]===e[0]?Ir(t):[]}),qo=Xr(function(e){var t=Xo(e),r=Ot(e,mi);return t===Xo(r)?t=n:r.pop(),r.length&&r[0]===e[0]?Ir(r,so(t,2)):[]}),Yo=Xr(function(e){var t=Xo(e),r=Ot(e,mi);return(t="function"==typeof t?t:n)&&r.pop(),r.length&&r[0]===e[0]?Ir(r,n,t):[]});function Xo(e){var t=null==e?0:e.length;return t?e[t-1]:n}var Ko=Xr(Zo);function Zo(e,t){return e&&e.length&&t&&t.length?$r(e,t):e}var Jo=to(function(e,t){var n=null==e?0:e.length,r=or(e,t);return Gr(e,Ot(t,function(e){return yo(e,n)?+e:e}).sort(ki)),r});function Qo(e){return null==e?e:Cn.call(e)}var ea=Xr(function(e){return ci(mr(e,1,Ga,!0))}),ta=Xr(function(e){var t=Xo(e);return Ga(t)&&(t=n),ci(mr(e,1,Ga,!0),so(t,2))}),na=Xr(function(e){var t=Xo(e);return t="function"==typeof t?t:n,ci(mr(e,1,Ga,!0),n,t)});function ra(e){if(!e||!e.length)return[];var t=0;return e=It(e,function(e){if(Ga(e))return t=vn(e.length,t),!0}),qt(t,function(t){return Ot(e,Ht(t))})}function ia(e,t){if(!e||!e.length)return[];var r=ra(e);return null==t?r:Ot(r,function(e){return _t(t,n,e)})}var oa=Xr(function(e,t){return Ga(e)?ur(e,t):[]}),aa=Xr(function(e){return pi(It(e,Ga))}),sa=Xr(function(e){var t=Xo(e);return Ga(t)&&(t=n),pi(It(e,Ga),so(t,2))}),la=Xr(function(e){var t=Xo(e);return t="function"==typeof t?t:n,pi(It(e,Ga),n,t)}),ca=Xr(ra),ua=Xr(function(e){var t=e.length,r=t>1?e[t-1]:n;return r="function"==typeof r?(e.pop(),r):n,ia(e,r)});function da(e){var t=zn(e);return t.__chain__=!0,t}function ha(e,t){return t(e)}var fa=to(function(e){var t=e.length,r=t?e[0]:0,i=this.__wrapped__,o=function(t){return or(t,e)};return!(t>1||this.__actions__.length)&&i instanceof Hn&&yo(r)?((i=i.slice(r,+r+(t?1:0))).__actions__.push({func:ha,args:[o],thisArg:n}),new Vn(i,this.__chain__).thru(function(e){return t&&!e.length&&e.push(n),e})):this.thru(o)}),pa=Fi(function(e,t,n){Re.call(e,n)?++e[n]:ir(e,n,1)}),ga=Di(Vo),ma=Di(Ho);function va(e,t){return(Ha(e)?kt:dr)(e,so(t,3))}function ya(e,t){return(Ha(e)?At:hr)(e,so(t,3))}var ba=Fi(function(e,t,n){Re.call(e,n)?e[n].push(t):ir(e,n,[t])}),wa=Xr(function(e,t,n){var r=-1,i="function"==typeof t,o=$a(e)?we(e.length):[];return dr(e,function(e){o[++r]=i?_t(t,e,n):Tr(e,t,n)}),o}),xa=Fi(function(e,t,n){ir(e,n,t)});function Ca(e,t){return(Ha(e)?Ot:jr)(e,so(t,3))}var _a=Fi(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]}),Sa=Xr(function(e,t){if(null==e)return[];var n=t.length;return n>1&&bo(e,t[0],t[1])?t=[]:n>2&&bo(t[0],t[1],t[2])&&(t=[t[0]]),Hr(e,mr(t,1),[])}),ka=ut||function(){return dt.Date.now()};function Aa(e,t,r){return t=r?n:t,t=e&&null==t?e.length:t,Ki(e,s,n,n,n,n,t)}function Ea(e,t){var i;if("function"!=typeof t)throw new Ie(r);return e=fs(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=n),i}}var Ia=Xr(function(e,t,n){var r=1;if(n.length){var i=sn(n,ao(Ia));r|=a}return Ki(e,r,t,n,i)}),Ta=Xr(function(e,t,n){var r=3;if(n.length){var i=sn(n,ao(Ta));r|=a}return Ki(t,r,e,n,i)});function Fa(e,t,i){var o,a,s,l,c,u,d=0,h=!1,f=!1,p=!0;if("function"!=typeof e)throw new Ie(r);function g(t){var r=o,i=a;return o=a=n,d=t,l=e.apply(i,r)}function m(e){var r=e-u;return u===n||r>=t||r<0||f&&e-d>=s}function v(){var e=ka();if(m(e))return y(e);c=Fo(v,function(e){var n=t-(e-u);return f?yn(n,s-(e-d)):n}(e))}function y(e){return c=n,p&&o?g(e):(o=a=n,l)}function b(){var e=ka(),r=m(e);if(o=arguments,a=this,u=e,r){if(c===n)return function(e){return d=e,c=Fo(v,t),h?g(e):l}(u);if(f)return xi(c),c=Fo(v,t),g(u)}return c===n&&(c=Fo(v,t)),l}return t=gs(t)||0,Qa(i)&&(h=!!i.leading,s=(f="maxWait"in i)?vn(gs(i.maxWait)||0,t):s,p="trailing"in i?!!i.trailing:p),b.cancel=function(){c!==n&&xi(c),d=0,o=u=a=c=n},b.flush=function(){return c===n?l:y(ka())},b}var Oa=Xr(function(e,t){return cr(e,1,t)}),Pa=Xr(function(e,t,n){return cr(e,gs(t)||0,n)});function Ma(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ie(r);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(Ma.Cache||Gn),n}function Ra(e){if("function"!=typeof e)throw new Ie(r);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)}}Ma.Cache=Gn;var La=bi(function(e,t){var n=(t=1==t.length&&Ha(t[0])?Ot(t[0],Xt(so())):Ot(mr(t,1),Xt(so()))).length;return Xr(function(r){for(var i=-1,o=yn(r.length,n);++i<o;)r[i]=t[i].call(this,r[i]);return _t(e,this,r)})}),Na=Xr(function(e,t){var r=sn(t,ao(Na));return Ki(e,a,n,t,r)}),Da=Xr(function(e,t){var r=sn(t,ao(Da));return Ki(e,64,n,t,r)}),ja=to(function(e,t){return Ki(e,l,n,n,n,t)});function za(e,t){return e===t||e!=e&&t!=t}var Ba=$i(kr),Ua=$i(function(e,t){return e>=t}),Va=Fr(function(){return arguments}())?Fr:function(e){return es(e)&&Re.call(e,"callee")&&!qe.call(e,"callee")},Ha=we.isArray,Wa=vt?Xt(vt):function(e){return es(e)&&Sr(e)==F};function $a(e){return null!=e&&Ja(e.length)&&!Ka(e)}function Ga(e){return es(e)&&$a(e)}var qa=Nt||gl,Ya=yt?Xt(yt):function(e){return es(e)&&Sr(e)==v};function Xa(e){if(!es(e))return!1;var t=Sr(e);return t==y||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!rs(e)}function Ka(e){if(!Qa(e))return!1;var t=Sr(e);return t==b||t==w||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Za(e){return"number"==typeof e&&e==fs(e)}function Ja(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=u}function Qa(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function es(e){return null!=e&&"object"==typeof e}var ts=bt?Xt(bt):function(e){return es(e)&&po(e)==x};function ns(e){return"number"==typeof e||es(e)&&Sr(e)==C}function rs(e){if(!es(e)||Sr(e)!=_)return!1;var t=$e(e);if(null===t)return!0;var n=Re.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Me.call(n)==je}var is=wt?Xt(wt):function(e){return es(e)&&Sr(e)==k},os=xt?Xt(xt):function(e){return es(e)&&po(e)==A};function as(e){return"string"==typeof e||!Ha(e)&&es(e)&&Sr(e)==E}function ss(e){return"symbol"==typeof e||es(e)&&Sr(e)==I}var ls=Ct?Xt(Ct):function(e){return es(e)&&Ja(e.length)&&!!it[Sr(e)]},cs=$i(Dr),us=$i(function(e,t){return e<=t});function ds(e){if(!e)return[];if($a(e))return as(e)?dn(e):Ii(e);if(Je&&e[Je])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Je]());var t=po(e);return(t==x?on:t==A?ln:zs)(e)}function hs(e){return e?(e=gs(e))===c||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function fs(e){var t=hs(e),n=t%1;return t==t?n?t-n:t:0}function ps(e){return e?ar(fs(e),0,h):0}function gs(e){if("number"==typeof e)return e;if(ss(e))return d;if(Qa(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Qa(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Yt(e);var n=fe.test(e);return n||ge.test(e)?lt(e.slice(2),n?2:8):he.test(e)?d:+e}function ms(e){return Ti(e,Os(e))}function vs(e){return null==e?"":li(e)}var ys=Oi(function(e,t){if(_o(t)||$a(t))Ti(t,Fs(t),e);else for(var n in t)Re.call(t,n)&&er(e,n,t[n])}),bs=Oi(function(e,t){Ti(t,Os(t),e)}),ws=Oi(function(e,t,n,r){Ti(t,Os(t),e,r)}),xs=Oi(function(e,t,n,r){Ti(t,Fs(t),e,r)}),Cs=to(or),_s=Xr(function(e,t){e=ke(e);var r=-1,i=t.length,o=i>2?t[2]:n;for(o&&bo(t[0],t[1],o)&&(i=1);++r<i;)for(var a=t[r],s=Os(a),l=-1,c=s.length;++l<c;){var u=s[l],d=e[u];(d===n||za(d,Oe[u])&&!Re.call(e,u))&&(e[u]=a[u])}return e}),Ss=Xr(function(e){return e.push(n,Ji),_t(Ms,n,e)});function ks(e,t,r){var i=null==e?n:Cr(e,t);return i===n?r:i}function As(e,t){return null!=e&&go(e,t,Er)}var Es=Bi(function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),e[t]=n},Qs(nl)),Is=Bi(function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),Re.call(e,t)?e[t].push(n):e[t]=[n]},so),Ts=Xr(Tr);function Fs(e){return $a(e)?Xn(e):Lr(e)}function Os(e){return $a(e)?Xn(e,!0):Nr(e)}var Ps=Oi(function(e,t,n){Ur(e,t,n)}),Ms=Oi(function(e,t,n,r){Ur(e,t,n,r)}),Rs=to(function(e,t){var n={};if(null==e)return n;var r=!1;t=Ot(t,function(t){return t=yi(t,e),r||(r=t.length>1),t}),Ti(e,ro(e),n),r&&(n=sr(n,7,Qi));for(var i=t.length;i--;)ui(n,t[i]);return n}),Ls=to(function(e,t){return null==e?{}:function(e,t){return Wr(e,t,function(t,n){return As(e,n)})}(e,t)});function Ns(e,t){if(null==e)return{};var n=Ot(ro(e),function(e){return[e]});return t=so(t),Wr(e,n,function(e,n){return t(e,n[0])})}var Ds=Xi(Fs),js=Xi(Os);function zs(e){return null==e?[]:Kt(e,Fs(e))}var Bs=Li(function(e,t,n){return t=t.toLowerCase(),e+(n?Us(t):t)});function Us(e){return Xs(vs(e).toLowerCase())}function Vs(e){return(e=vs(e))&&e.replace(ve,en).replace(Ze,"")}var Hs=Li(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),Ws=Li(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),$s=Ri("toLowerCase"),Gs=Li(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}),qs=Li(function(e,t,n){return e+(n?" ":"")+Xs(t)}),Ys=Li(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Xs=Ri("toUpperCase");function Ks(e,t,r){return e=vs(e),(t=r?n:t)===n?function(e){return tt.test(e)}(e)?function(e){return e.match(Qe)||[]}(e):function(e){return e.match(se)||[]}(e):e.match(t)||[]}var Zs=Xr(function(e,t){try{return _t(e,n,t)}catch(e){return Xa(e)?e:new Ce(e)}}),Js=to(function(e,t){return kt(t,function(t){t=No(t),ir(e,t,Ia(e[t],e))}),e});function Qs(e){return function(){return e}}var el=ji(),tl=ji(!0);function nl(e){return e}function rl(e){return Rr("function"==typeof e?e:sr(e,1))}var il=Xr(function(e,t){return function(n){return Tr(n,e,t)}}),ol=Xr(function(e,t){return function(n){return Tr(e,n,t)}});function al(e,t,n){var r=Fs(t),i=xr(t,r);null!=n||Qa(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=xr(t,Fs(t)));var o=!(Qa(n)&&"chain"in n&&!n.chain),a=Ka(e);return kt(i,function(n){var r=t[n];e[n]=r,a&&(e.prototype[n]=function(){var t=this.__chain__;if(o||t){var n=e(this.__wrapped__);return(n.__actions__=Ii(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,Pt([this.value()],arguments))})}),e}function sl(){}var ll=Vi(Ot),cl=Vi(Et),ul=Vi(Lt);function dl(e){return wo(e)?Ht(No(e)):function(e){return function(t){return Cr(t,e)}}(e)}var hl=Wi(),fl=Wi(!0);function pl(){return[]}function gl(){return!1}var ml,vl=Ui(function(e,t){return e+t},0),yl=qi("ceil"),bl=Ui(function(e,t){return e/t},1),wl=qi("floor"),xl=Ui(function(e,t){return e*t},1),Cl=qi("round"),_l=Ui(function(e,t){return e-t},0);return zn.after=function(e,t){if("function"!=typeof t)throw new Ie(r);return e=fs(e),function(){if(--e<1)return t.apply(this,arguments)}},zn.ary=Aa,zn.assign=ys,zn.assignIn=bs,zn.assignInWith=ws,zn.assignWith=xs,zn.at=Cs,zn.before=Ea,zn.bind=Ia,zn.bindAll=Js,zn.bindKey=Ta,zn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Ha(e)?e:[e]},zn.chain=da,zn.chunk=function(e,t,r){t=(r?bo(e,t,r):t===n)?1:vn(fs(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var o=0,a=0,s=we(ft(i/t));o<i;)s[a++]=ni(e,o,o+=t);return s},zn.compact=function(e){for(var t=-1,n=null==e?0:e.length,r=0,i=[];++t<n;){var o=e[t];o&&(i[r++]=o)}return i},zn.concat=function(){var e=arguments.length;if(!e)return[];for(var t=we(e-1),n=arguments[0],r=e;r--;)t[r-1]=arguments[r];return Pt(Ha(n)?Ii(n):[n],mr(t,1))},zn.cond=function(e){var t=null==e?0:e.length,n=so();return e=t?Ot(e,function(e){if("function"!=typeof e[1])throw new Ie(r);return[n(e[0]),e[1]]}):[],Xr(function(n){for(var r=-1;++r<t;){var i=e[r];if(_t(i[0],this,n))return _t(i[1],this,n)}})},zn.conforms=function(e){return function(e){var t=Fs(e);return function(n){return lr(n,e,t)}}(sr(e,1))},zn.constant=Qs,zn.countBy=pa,zn.create=function(e,t){var n=Bn(e);return null==t?n:rr(n,t)},zn.curry=function e(t,r,i){var o=Ki(t,8,n,n,n,n,n,r=i?n:r);return o.placeholder=e.placeholder,o},zn.curryRight=function e(t,r,i){var o=Ki(t,16,n,n,n,n,n,r=i?n:r);return o.placeholder=e.placeholder,o},zn.debounce=Fa,zn.defaults=_s,zn.defaultsDeep=Ss,zn.defer=Oa,zn.delay=Pa,zn.difference=zo,zn.differenceBy=Bo,zn.differenceWith=Uo,zn.drop=function(e,t,r){var i=null==e?0:e.length;return i?ni(e,(t=r||t===n?1:fs(t))<0?0:t,i):[]},zn.dropRight=function(e,t,r){var i=null==e?0:e.length;return i?ni(e,0,(t=i-(t=r||t===n?1:fs(t)))<0?0:t):[]},zn.dropRightWhile=function(e,t){return e&&e.length?hi(e,so(t,3),!0,!0):[]},zn.dropWhile=function(e,t){return e&&e.length?hi(e,so(t,3),!0):[]},zn.fill=function(e,t,r,i){var o=null==e?0:e.length;return o?(r&&"number"!=typeof r&&bo(e,t,r)&&(r=0,i=o),function(e,t,r,i){var o=e.length;for((r=fs(r))<0&&(r=-r>o?0:o+r),(i=i===n||i>o?o:fs(i))<0&&(i+=o),i=r>i?0:ps(i);r<i;)e[r++]=t;return e}(e,t,r,i)):[]},zn.filter=function(e,t){return(Ha(e)?It:gr)(e,so(t,3))},zn.flatMap=function(e,t){return mr(Ca(e,t),1)},zn.flatMapDeep=function(e,t){return mr(Ca(e,t),c)},zn.flatMapDepth=function(e,t,r){return r=r===n?1:fs(r),mr(Ca(e,t),r)},zn.flatten=Wo,zn.flattenDeep=function(e){return null!=e&&e.length?mr(e,c):[]},zn.flattenDepth=function(e,t){return null!=e&&e.length?mr(e,t=t===n?1:fs(t)):[]},zn.flip=function(e){return Ki(e,512)},zn.flow=el,zn.flowRight=tl,zn.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,r={};++t<n;){var i=e[t];r[i[0]]=i[1]}return r},zn.functions=function(e){return null==e?[]:xr(e,Fs(e))},zn.functionsIn=function(e){return null==e?[]:xr(e,Os(e))},zn.groupBy=ba,zn.initial=function(e){return null!=e&&e.length?ni(e,0,-1):[]},zn.intersection=Go,zn.intersectionBy=qo,zn.intersectionWith=Yo,zn.invert=Es,zn.invertBy=Is,zn.invokeMap=wa,zn.iteratee=rl,zn.keyBy=xa,zn.keys=Fs,zn.keysIn=Os,zn.map=Ca,zn.mapKeys=function(e,t){var n={};return t=so(t,3),br(e,function(e,r,i){ir(n,t(e,r,i),e)}),n},zn.mapValues=function(e,t){var n={};return t=so(t,3),br(e,function(e,r,i){ir(n,r,t(e,r,i))}),n},zn.matches=function(e){return zr(sr(e,1))},zn.matchesProperty=function(e,t){return Br(e,sr(t,1))},zn.memoize=Ma,zn.merge=Ps,zn.mergeWith=Ms,zn.method=il,zn.methodOf=ol,zn.mixin=al,zn.negate=Ra,zn.nthArg=function(e){return e=fs(e),Xr(function(t){return Vr(t,e)})},zn.omit=Rs,zn.omitBy=function(e,t){return Ns(e,Ra(so(t)))},zn.once=function(e){return Ea(2,e)},zn.orderBy=function(e,t,r,i){return null==e?[]:(Ha(t)||(t=null==t?[]:[t]),Ha(r=i?n:r)||(r=null==r?[]:[r]),Hr(e,t,r))},zn.over=ll,zn.overArgs=La,zn.overEvery=cl,zn.overSome=ul,zn.partial=Na,zn.partialRight=Da,zn.partition=_a,zn.pick=Ls,zn.pickBy=Ns,zn.property=dl,zn.propertyOf=function(e){return function(t){return null==e?n:Cr(e,t)}},zn.pull=Ko,zn.pullAll=Zo,zn.pullAllBy=function(e,t,n){return e&&e.length&&t&&t.length?$r(e,t,so(n,2)):e},zn.pullAllWith=function(e,t,r){return e&&e.length&&t&&t.length?$r(e,t,n,r):e},zn.pullAt=Jo,zn.range=hl,zn.rangeRight=fl,zn.rearg=ja,zn.reject=function(e,t){return(Ha(e)?It:gr)(e,Ra(so(t,3)))},zn.remove=function(e,t){var n=[];if(!e||!e.length)return n;var r=-1,i=[],o=e.length;for(t=so(t,3);++r<o;){var a=e[r];t(a,r,e)&&(n.push(a),i.push(r))}return Gr(e,i),n},zn.rest=function(e,t){if("function"!=typeof e)throw new Ie(r);return Xr(e,t=t===n?t:fs(t))},zn.reverse=Qo,zn.sampleSize=function(e,t,r){return t=(r?bo(e,t,r):t===n)?1:fs(t),(Ha(e)?Zn:Zr)(e,t)},zn.set=function(e,t,n){return null==e?e:Jr(e,t,n)},zn.setWith=function(e,t,r,i){return i="function"==typeof i?i:n,null==e?e:Jr(e,t,r,i)},zn.shuffle=function(e){return(Ha(e)?Jn:ti)(e)},zn.slice=function(e,t,r){var i=null==e?0:e.length;return i?(r&&"number"!=typeof r&&bo(e,t,r)?(t=0,r=i):(t=null==t?0:fs(t),r=r===n?i:fs(r)),ni(e,t,r)):[]},zn.sortBy=Sa,zn.sortedUniq=function(e){return e&&e.length?ai(e):[]},zn.sortedUniqBy=function(e,t){return e&&e.length?ai(e,so(t,2)):[]},zn.split=function(e,t,r){return r&&"number"!=typeof r&&bo(e,t,r)&&(t=r=n),(r=r===n?h:r>>>0)?(e=vs(e))&&("string"==typeof t||null!=t&&!is(t))&&!(t=li(t))&&rn(e)?wi(dn(e),0,r):e.split(t,r):[]},zn.spread=function(e,t){if("function"!=typeof e)throw new Ie(r);return t=null==t?0:vn(fs(t),0),Xr(function(n){var r=n[t],i=wi(n,0,t);return r&&Pt(i,r),_t(e,this,i)})},zn.tail=function(e){var t=null==e?0:e.length;return t?ni(e,1,t):[]},zn.take=function(e,t,r){return e&&e.length?ni(e,0,(t=r||t===n?1:fs(t))<0?0:t):[]},zn.takeRight=function(e,t,r){var i=null==e?0:e.length;return i?ni(e,(t=i-(t=r||t===n?1:fs(t)))<0?0:t,i):[]},zn.takeRightWhile=function(e,t){return e&&e.length?hi(e,so(t,3),!1,!0):[]},zn.takeWhile=function(e,t){return e&&e.length?hi(e,so(t,3)):[]},zn.tap=function(e,t){return t(e),e},zn.throttle=function(e,t,n){var i=!0,o=!0;if("function"!=typeof e)throw new Ie(r);return Qa(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),Fa(e,t,{leading:i,maxWait:t,trailing:o})},zn.thru=ha,zn.toArray=ds,zn.toPairs=Ds,zn.toPairsIn=js,zn.toPath=function(e){return Ha(e)?Ot(e,No):ss(e)?[e]:Ii(Lo(vs(e)))},zn.toPlainObject=ms,zn.transform=function(e,t,n){var r=Ha(e),i=r||qa(e)||ls(e);if(t=so(t,4),null==n){var o=e&&e.constructor;n=i?r?new o:[]:Qa(e)&&Ka(o)?Bn($e(e)):{}}return(i?kt:br)(e,function(e,r,i){return t(n,e,r,i)}),n},zn.unary=function(e){return Aa(e,1)},zn.union=ea,zn.unionBy=ta,zn.unionWith=na,zn.uniq=function(e){return e&&e.length?ci(e):[]},zn.uniqBy=function(e,t){return e&&e.length?ci(e,so(t,2)):[]},zn.uniqWith=function(e,t){return t="function"==typeof t?t:n,e&&e.length?ci(e,n,t):[]},zn.unset=function(e,t){return null==e||ui(e,t)},zn.unzip=ra,zn.unzipWith=ia,zn.update=function(e,t,n){return null==e?e:di(e,t,vi(n))},zn.updateWith=function(e,t,r,i){return i="function"==typeof i?i:n,null==e?e:di(e,t,vi(r),i)},zn.values=zs,zn.valuesIn=function(e){return null==e?[]:Kt(e,Os(e))},zn.without=oa,zn.words=Ks,zn.wrap=function(e,t){return Na(vi(t),e)},zn.xor=aa,zn.xorBy=sa,zn.xorWith=la,zn.zip=ca,zn.zipObject=function(e,t){return gi(e||[],t||[],er)},zn.zipObjectDeep=function(e,t){return gi(e||[],t||[],Jr)},zn.zipWith=ua,zn.entries=Ds,zn.entriesIn=js,zn.extend=bs,zn.extendWith=ws,al(zn,zn),zn.add=vl,zn.attempt=Zs,zn.camelCase=Bs,zn.capitalize=Us,zn.ceil=yl,zn.clamp=function(e,t,r){return r===n&&(r=t,t=n),r!==n&&(r=(r=gs(r))==r?r:0),t!==n&&(t=(t=gs(t))==t?t:0),ar(gs(e),t,r)},zn.clone=function(e){return sr(e,4)},zn.cloneDeep=function(e){return sr(e,5)},zn.cloneDeepWith=function(e,t){return sr(e,5,t="function"==typeof t?t:n)},zn.cloneWith=function(e,t){return sr(e,4,t="function"==typeof t?t:n)},zn.conformsTo=function(e,t){return null==t||lr(e,t,Fs(t))},zn.deburr=Vs,zn.defaultTo=function(e,t){return null==e||e!=e?t:e},zn.divide=bl,zn.endsWith=function(e,t,r){e=vs(e),t=li(t);var i=e.length,o=r=r===n?i:ar(fs(r),0,i);return(r-=t.length)>=0&&e.slice(r,o)==t},zn.eq=za,zn.escape=function(e){return(e=vs(e))&&q.test(e)?e.replace($,tn):e},zn.escapeRegExp=function(e){return(e=vs(e))&&te.test(e)?e.replace(ee,"\\$&"):e},zn.every=function(e,t,r){var i=Ha(e)?Et:fr;return r&&bo(e,t,r)&&(t=n),i(e,so(t,3))},zn.find=ga,zn.findIndex=Vo,zn.findKey=function(e,t){return Dt(e,so(t,3),br)},zn.findLast=ma,zn.findLastIndex=Ho,zn.findLastKey=function(e,t){return Dt(e,so(t,3),wr)},zn.floor=wl,zn.forEach=va,zn.forEachRight=ya,zn.forIn=function(e,t){return null==e?e:vr(e,so(t,3),Os)},zn.forInRight=function(e,t){return null==e?e:yr(e,so(t,3),Os)},zn.forOwn=function(e,t){return e&&br(e,so(t,3))},zn.forOwnRight=function(e,t){return e&&wr(e,so(t,3))},zn.get=ks,zn.gt=Ba,zn.gte=Ua,zn.has=function(e,t){return null!=e&&go(e,t,Ar)},zn.hasIn=As,zn.head=$o,zn.identity=nl,zn.includes=function(e,t,n,r){e=$a(e)?e:zs(e),n=n&&!r?fs(n):0;var i=e.length;return n<0&&(n=vn(i+n,0)),as(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&zt(e,t,n)>-1},zn.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:fs(n);return i<0&&(i=vn(r+i,0)),zt(e,t,i)},zn.inRange=function(e,t,r){return t=hs(t),r===n?(r=t,t=0):r=hs(r),function(e,t,n){return e>=yn(t,n)&&e<vn(t,n)}(e=gs(e),t,r)},zn.invoke=Ts,zn.isArguments=Va,zn.isArray=Ha,zn.isArrayBuffer=Wa,zn.isArrayLike=$a,zn.isArrayLikeObject=Ga,zn.isBoolean=function(e){return!0===e||!1===e||es(e)&&Sr(e)==m},zn.isBuffer=qa,zn.isDate=Ya,zn.isElement=function(e){return es(e)&&1===e.nodeType&&!rs(e)},zn.isEmpty=function(e){if(null==e)return!0;if($a(e)&&(Ha(e)||"string"==typeof e||"function"==typeof e.splice||qa(e)||ls(e)||Va(e)))return!e.length;var t=po(e);if(t==x||t==A)return!e.size;if(_o(e))return!Lr(e).length;for(var n in e)if(Re.call(e,n))return!1;return!0},zn.isEqual=function(e,t){return Or(e,t)},zn.isEqualWith=function(e,t,r){var i=(r="function"==typeof r?r:n)?r(e,t):n;return i===n?Or(e,t,n,r):!!i},zn.isError=Xa,zn.isFinite=function(e){return"number"==typeof e&&Wt(e)},zn.isFunction=Ka,zn.isInteger=Za,zn.isLength=Ja,zn.isMap=ts,zn.isMatch=function(e,t){return e===t||Pr(e,t,co(t))},zn.isMatchWith=function(e,t,r){return r="function"==typeof r?r:n,Pr(e,t,co(t),r)},zn.isNaN=function(e){return ns(e)&&e!=+e},zn.isNative=function(e){if(Co(e))throw new Ce("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Mr(e)},zn.isNil=function(e){return null==e},zn.isNull=function(e){return null===e},zn.isNumber=ns,zn.isObject=Qa,zn.isObjectLike=es,zn.isPlainObject=rs,zn.isRegExp=is,zn.isSafeInteger=function(e){return Za(e)&&e>=-9007199254740991&&e<=u},zn.isSet=os,zn.isString=as,zn.isSymbol=ss,zn.isTypedArray=ls,zn.isUndefined=function(e){return e===n},zn.isWeakMap=function(e){return es(e)&&po(e)==T},zn.isWeakSet=function(e){return es(e)&&"[object WeakSet]"==Sr(e)},zn.join=function(e,t){return null==e?"":gn.call(e,t)},zn.kebabCase=Hs,zn.last=Xo,zn.lastIndexOf=function(e,t,r){var i=null==e?0:e.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=fs(r))<0?vn(i+o,0):yn(o,i-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,o):jt(e,Ut,o,!0)},zn.lowerCase=Ws,zn.lowerFirst=$s,zn.lt=cs,zn.lte=us,zn.max=function(e){return e&&e.length?pr(e,nl,kr):n},zn.maxBy=function(e,t){return e&&e.length?pr(e,so(t,2),kr):n},zn.mean=function(e){return Vt(e,nl)},zn.meanBy=function(e,t){return Vt(e,so(t,2))},zn.min=function(e){return e&&e.length?pr(e,nl,Dr):n},zn.minBy=function(e,t){return e&&e.length?pr(e,so(t,2),Dr):n},zn.stubArray=pl,zn.stubFalse=gl,zn.stubObject=function(){return{}},zn.stubString=function(){return""},zn.stubTrue=function(){return!0},zn.multiply=xl,zn.nth=function(e,t){return e&&e.length?Vr(e,fs(t)):n},zn.noConflict=function(){return dt._===this&&(dt._=ze),this},zn.noop=sl,zn.now=ka,zn.pad=function(e,t,n){e=vs(e);var r=(t=fs(t))?un(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return Hi(gt(i),n)+e+Hi(ft(i),n)},zn.padEnd=function(e,t,n){e=vs(e);var r=(t=fs(t))?un(e):0;return t&&r<t?e+Hi(t-r,n):e},zn.padStart=function(e,t,n){e=vs(e);var r=(t=fs(t))?un(e):0;return t&&r<t?Hi(t-r,n)+e:e},zn.parseInt=function(e,t,n){return n||null==t?t=0:t&&(t=+t),wn(vs(e).replace(ne,""),t||0)},zn.random=function(e,t,r){if(r&&"boolean"!=typeof r&&bo(e,t,r)&&(t=r=n),r===n&&("boolean"==typeof t?(r=t,t=n):"boolean"==typeof e&&(r=e,e=n)),e===n&&t===n?(e=0,t=1):(e=hs(e),t===n?(t=e,e=0):t=hs(t)),e>t){var i=e;e=t,t=i}if(r||e%1||t%1){var o=xn();return yn(e+o*(t-e+st("1e-"+((o+"").length-1))),t)}return qr(e,t)},zn.reduce=function(e,t,n){var r=Ha(e)?Mt:$t,i=arguments.length<3;return r(e,so(t,4),n,i,dr)},zn.reduceRight=function(e,t,n){var r=Ha(e)?Rt:$t,i=arguments.length<3;return r(e,so(t,4),n,i,hr)},zn.repeat=function(e,t,r){return t=(r?bo(e,t,r):t===n)?1:fs(t),Yr(vs(e),t)},zn.replace=function(){var e=arguments,t=vs(e[0]);return e.length<3?t:t.replace(e[1],e[2])},zn.result=function(e,t,r){var i=-1,o=(t=yi(t,e)).length;for(o||(o=1,e=n);++i<o;){var a=null==e?n:e[No(t[i])];a===n&&(i=o,a=r),e=Ka(a)?a.call(e):a}return e},zn.round=Cl,zn.runInContext=e,zn.sample=function(e){return(Ha(e)?Kn:Kr)(e)},zn.size=function(e){if(null==e)return 0;if($a(e))return as(e)?un(e):e.length;var t=po(e);return t==x||t==A?e.size:Lr(e).length},zn.snakeCase=Gs,zn.some=function(e,t,r){var i=Ha(e)?Lt:ri;return r&&bo(e,t,r)&&(t=n),i(e,so(t,3))},zn.sortedIndex=function(e,t){return ii(e,t)},zn.sortedIndexBy=function(e,t,n){return oi(e,t,so(n,2))},zn.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var r=ii(e,t);if(r<n&&za(e[r],t))return r}return-1},zn.sortedLastIndex=function(e,t){return ii(e,t,!0)},zn.sortedLastIndexBy=function(e,t,n){return oi(e,t,so(n,2),!0)},zn.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var n=ii(e,t,!0)-1;if(za(e[n],t))return n}return-1},zn.startCase=qs,zn.startsWith=function(e,t,n){return e=vs(e),n=null==n?0:ar(fs(n),0,e.length),t=li(t),e.slice(n,n+t.length)==t},zn.subtract=_l,zn.sum=function(e){return e&&e.length?Gt(e,nl):0},zn.sumBy=function(e,t){return e&&e.length?Gt(e,so(t,2)):0},zn.template=function(e,t,r){var i=zn.templateSettings;r&&bo(e,t,r)&&(t=n),e=vs(e),t=ws({},t,i,Zi);var o,a,s=ws({},t.imports,i.imports,Zi),l=Fs(s),c=Kt(s,l),u=0,d=t.interpolate||ye,h="__p += '",f=Ae((t.escape||ye).source+"|"+d.source+"|"+(d===K?ue:ye).source+"|"+(t.evaluate||ye).source+"|$","g"),p="//# sourceURL="+(Re.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rt+"]")+"\n";e.replace(f,function(t,n,r,i,s,l){return r||(r=i),h+=e.slice(u,l).replace(be,nn),n&&(o=!0,h+="' +\n__e("+n+") +\n'"),s&&(a=!0,h+="';\n"+s+";\n__p += '"),r&&(h+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),u=l+t.length,t}),h+="';\n";var g=Re.call(t,"variable")&&t.variable;if(g){if(le.test(g))throw new Ce("Invalid `variable` option passed into `_.template`")}else h="with (obj) {\n"+h+"\n}\n";h=(a?h.replace(U,""):h).replace(V,"$1").replace(H,"$1;"),h="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var m=Zs(function(){return _e(l,p+"return "+h).apply(n,c)});if(m.source=h,Xa(m))throw m;return m},zn.times=function(e,t){if((e=fs(e))<1||e>u)return[];var n=h,r=yn(e,h);t=so(t),e-=h;for(var i=qt(r,t);++n<e;)t(n);return i},zn.toFinite=hs,zn.toInteger=fs,zn.toLength=ps,zn.toLower=function(e){return vs(e).toLowerCase()},zn.toNumber=gs,zn.toSafeInteger=function(e){return e?ar(fs(e),-9007199254740991,u):0===e?e:0},zn.toString=vs,zn.toUpper=function(e){return vs(e).toUpperCase()},zn.trim=function(e,t,r){if((e=vs(e))&&(r||t===n))return Yt(e);if(!e||!(t=li(t)))return e;var i=dn(e),o=dn(t);return wi(i,Jt(i,o),Qt(i,o)+1).join("")},zn.trimEnd=function(e,t,r){if((e=vs(e))&&(r||t===n))return e.slice(0,hn(e)+1);if(!e||!(t=li(t)))return e;var i=dn(e);return wi(i,0,Qt(i,dn(t))+1).join("")},zn.trimStart=function(e,t,r){if((e=vs(e))&&(r||t===n))return e.replace(ne,"");if(!e||!(t=li(t)))return e;var i=dn(e);return wi(i,Jt(i,dn(t))).join("")},zn.truncate=function(e,t){var r=30,i="...";if(Qa(t)){var o="separator"in t?t.separator:o;r="length"in t?fs(t.length):r,i="omission"in t?li(t.omission):i}var a=(e=vs(e)).length;if(rn(e)){var s=dn(e);a=s.length}if(r>=a)return e;var l=r-un(i);if(l<1)return i;var c=s?wi(s,0,l).join(""):e.slice(0,l);if(o===n)return c+i;if(s&&(l+=c.length-l),is(o)){if(e.slice(l).search(o)){var u,d=c;for(o.global||(o=Ae(o.source,vs(de.exec(o))+"g")),o.lastIndex=0;u=o.exec(d);)var h=u.index;c=c.slice(0,h===n?l:h)}}else if(e.indexOf(li(o),l)!=l){var f=c.lastIndexOf(o);f>-1&&(c=c.slice(0,f))}return c+i},zn.unescape=function(e){return(e=vs(e))&&G.test(e)?e.replace(W,fn):e},zn.uniqueId=function(e){var t=++Le;return vs(e)+t},zn.upperCase=Ys,zn.upperFirst=Xs,zn.each=va,zn.eachRight=ya,zn.first=$o,al(zn,(ml={},br(zn,function(e,t){Re.call(zn.prototype,t)||(ml[t]=e)}),ml),{chain:!1}),zn.VERSION="4.17.21",kt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){zn[e].placeholder=zn}),kt(["drop","take"],function(e,t){Hn.prototype[e]=function(r){r=r===n?1:vn(fs(r),0);var i=this.__filtered__&&!t?new Hn(this):this.clone();return i.__filtered__?i.__takeCount__=yn(r,i.__takeCount__):i.__views__.push({size:yn(r,h),type:e+(i.__dir__<0?"Right":"")}),i},Hn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),kt(["filter","map","takeWhile"],function(e,t){var n=t+1,r=1==n||3==n;Hn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:so(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),kt(["head","last"],function(e,t){var n="take"+(t?"Right":"");Hn.prototype[e]=function(){return this[n](1).value()[0]}}),kt(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");Hn.prototype[e]=function(){return this.__filtered__?new Hn(this):this[n](1)}}),Hn.prototype.compact=function(){return this.filter(nl)},Hn.prototype.find=function(e){return this.filter(e).head()},Hn.prototype.findLast=function(e){return this.reverse().find(e)},Hn.prototype.invokeMap=Xr(function(e,t){return"function"==typeof e?new Hn(this):this.map(function(n){return Tr(n,e,t)})}),Hn.prototype.reject=function(e){return this.filter(Ra(so(e)))},Hn.prototype.slice=function(e,t){e=fs(e);var r=this;return r.__filtered__&&(e>0||t<0)?new Hn(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(r=(t=fs(t))<0?r.dropRight(-t):r.take(t-e)),r)},Hn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hn.prototype.toArray=function(){return this.take(h)},br(Hn.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),o=zn[i?"take"+("last"==t?"Right":""):t],a=i||/^find/.test(t);o&&(zn.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,l=t instanceof Hn,c=s[0],u=l||Ha(t),d=function(e){var t=o.apply(zn,Pt([e],s));return i&&h?t[0]:t};u&&r&&"function"==typeof c&&1!=c.length&&(l=u=!1);var h=this.__chain__,f=!!this.__actions__.length,p=a&&!h,g=l&&!f;if(!a&&u){t=g?t:new Hn(this);var m=e.apply(t,s);return m.__actions__.push({func:ha,args:[d],thisArg:n}),new Vn(m,h)}return p&&g?e.apply(this,s):(m=this.thru(d),p?i?m.value()[0]:m.value():m)})}),kt(["pop","push","shift","sort","splice","unshift"],function(e){var t=Te[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);zn.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(Ha(i)?i:[],e)}return this[n](function(n){return t.apply(Ha(n)?n:[],e)})}}),br(Hn.prototype,function(e,t){var n=zn[t];if(n){var r=n.name+"";Re.call(Fn,r)||(Fn[r]=[]),Fn[r].push({name:t,func:n})}}),Fn[zi(n,2).name]=[{name:"wrapper",func:n}],Hn.prototype.clone=function(){var e=new Hn(this.__wrapped__);return e.__actions__=Ii(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ii(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ii(this.__views__),e},Hn.prototype.reverse=function(){if(this.__filtered__){var e=new Hn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Ha(e),r=t<0,i=n?e.length:0,o=function(e,t,n){for(var r=-1,i=n.length;++r<i;){var o=n[r],a=o.size;switch(o.type){case"drop":e+=a;break;case"dropRight":t-=a;break;case"take":t=yn(t,e+a);break;case"takeRight":e=vn(e,t-a)}}return{start:e,end:t}}(0,i,this.__views__),a=o.start,s=o.end,l=s-a,c=r?s:a-1,u=this.__iteratees__,d=u.length,h=0,f=yn(l,this.__takeCount__);if(!n||!r&&i==l&&f==l)return fi(e,this.__actions__);var p=[];e:for(;l--&&h<f;){for(var g=-1,m=e[c+=t];++g<d;){var v=u[g],y=v.iteratee,b=v.type,w=y(m);if(2==b)m=w;else if(!w){if(1==b)continue e;break e}}p[h++]=m}return p},zn.prototype.at=fa,zn.prototype.chain=function(){return da(this)},zn.prototype.commit=function(){return new Vn(this.value(),this.__chain__)},zn.prototype.next=function(){this.__values__===n&&(this.__values__=ds(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}},zn.prototype.plant=function(e){for(var t,r=this;r instanceof Un;){var i=jo(r);i.__index__=0,i.__values__=n,t?o.__wrapped__=i:t=i;var o=i;r=r.__wrapped__}return o.__wrapped__=e,t},zn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hn){var t=e;return this.__actions__.length&&(t=new Hn(this)),(t=t.reverse()).__actions__.push({func:ha,args:[Qo],thisArg:n}),new Vn(t,this.__chain__)}return this.thru(Qo)},zn.prototype.toJSON=zn.prototype.valueOf=zn.prototype.value=function(){return fi(this.__wrapped__,this.__actions__)},zn.prototype.first=zn.prototype.head,Je&&(zn.prototype[Je]=function(){return this}),zn}();ft?((ft.exports=pn)._=pn,ht._=pn):dt._=pn}).call(po)}(fo,fo.exports)),fo.exports);const mo=e=>null===e.parentId||"null"===e.parentId||!e.parentId,vo=async(e,t,n)=>{var r;if("file"===(null==t?void 0:t.itemType))return e;let i=[];if(!n)return e;{const e=await n({parentId:t.folderId});i=Array.isArray(e)?e:[]}let o=((e,t)=>{const n=Array.isArray(e)?e:[];return(r=t.folderId)&&"root"!==r&&"folders"!==r&&"null"!==r&&null!==r?n.filter(e=>e.parentId===t.folderId):n.filter(mo);var r})(i,t);if(null===(r=null==t?void 0:t.search)||void 0===r?void 0:r.trim()){const e=t.search.trim().toLowerCase();o=o.filter(t=>{var n;return null===(n=t.name)||void 0===n?void 0:n.toLowerCase().includes(e)})}if(0===o.length)return e;const a=o.map(e=>({id:e.id,name:e.name,size:void 0,date:"-",isFolder:!0,folderId:e.parentId||"",type:"",selected:!1,extension:"",childCount:e.childCount}));if("folder"===(null==t?void 0:t.itemType))return a;const s=e.filter(e=>!e.isFolder);return[...a,...s]},yo=e=>{var t,n,r,i;const{state:o,actions:s,options:l}=ro(),{searchTerm:d,sortBy:h,sortOrder:f,selectedFolder:p,pagination:g}=o,{setSearchTerm:m,setSortBy:v,setSortOrder:y,setPagination:b}=s,w=e||s.fetchFiles,x=u(null),C=u(go.debounce(e=>{const t=JSON.stringify(e);x.current!==t&&(x.current=t,null==w||w(e))},150)).current,_=c(()=>{var e;const t=null===(e=null==l?void 0:l.config)||void 0===e?void 0:e.disablePagination;return{folderId:p||"",search:(null==d?void 0:d.trim())||void 0,page:t?void 0:g.current,limit:t?void 0:g.pageSize,sortBy:h,sortOrder:f,itemType:"all"}},[p,d,g.current,g.pageSize,h,f,null===(t=null==l?void 0:l.config)||void 0===t?void 0:t.disablePagination]),S=c(e=>{var t,n;if(m&&m(e),b&&b({current:1,pageSize:g.pageSize,total:0}),w){const r={folderId:p||"",search:(null==e?void 0:e.trim())||void 0,page:(null===(t=null==l?void 0:l.config)||void 0===t?void 0:t.disablePagination)?void 0:1,limit:(null===(n=null==l?void 0:l.config)||void 0===n?void 0:n.disablePagination)?void 0:g.pageSize,sortBy:h,sortOrder:f,itemType:"all"};w(r)}else console.error("🔎 useSortAndFilter: fetchFiles НЕ ОПРЕДЕЛЕНА!")},[m,b,g.pageSize,w,p,h,f,null===(n=null==l?void 0:l.config)||void 0===n?void 0:n.disablePagination]),k=c((e,t)=>{var n,r;null==v||v(e),null==y||y(t),w&&C({folderId:p||"",search:(null==d?void 0:d.trim())||void 0,page:(null===(n=null==l?void 0:l.config)||void 0===n?void 0:n.disablePagination)?void 0:g.current,limit:(null===(r=null==l?void 0:l.config)||void 0===r?void 0:r.disablePagination)?void 0:g.pageSize,sortBy:e,sortOrder:t,itemType:"all"})},[v,y,C,p,d,g.current,g.pageSize,null===(r=null==l?void 0:l.config)||void 0===r?void 0:r.disablePagination]),A=c((e,t)=>{var n;(null===(n=null==l?void 0:l.config)||void 0===n?void 0:n.disablePagination)||(b&&b({current:e,pageSize:t||g.pageSize,total:g.total}),w&&C({folderId:p||"",search:(null==d?void 0:d.trim())||void 0,page:e,limit:t||g.pageSize,sortBy:h,sortOrder:f,itemType:"all"}))},[b,g.pageSize,g.total,C,p,d,h,f,null===(i=null==l?void 0:l.config)||void 0===i?void 0:i.disablePagination]);return a(()=>{if(w){const e=_();C(Object.assign(Object.assign({},e),{page:1}))}},[p]),a(()=>{w&&C(_())},[]),a(()=>()=>{var e;null===(e=C.cancel)||void 0===e||e.call(C)},[C]),{state:{searchTerm:d||"",sortBy:h||"name",sortOrder:f||"asc"},actions:{setSearchTerm:m||(()=>{}),setSortBy:v||(()=>{}),setSortOrder:y||(()=>{}),handleSearch:S,handleSort:k,handlePaginationChange:A,getCurrentQueryParams:_}}},bo=()=>{var e;const{notification:t}=I.useApp(),n=ro(),{options:r}=n,i=c(async e=>{let t;if(r.handleNotify){try{t=await r.handleNotify(e)}catch(e){console.error(e)}if(!1===t)return!1;"object"==typeof t&&t&&(e=t)}if("error"===e.type&&r.handleError){try{t=await r.handleError(e)}catch(e){console.error(e)}if(!1===t)return!1;"object"==typeof t&&t&&(e=t)}if("success"===e.type&&r.handleSuccess){try{t=await r.handleSuccess(e)}catch(e){console.error(e)}if(t)return!1}return t},[r]),o=c(async function(e,n=!1){var o;try{void 0===e.visibility&&(e.visibility=!n);const a=await i(e);"object"==typeof a&&(e=a);if(!(!1!==e.visibility&&!1!==a&&!1!==(null===(o=r.config)||void 0===o?void 0:o.showNotifications)))return e;const s=t[e.type];"function"==typeof s?s(e):console.warn(`Unknown notification type: ${e.type}`,e)}catch(e){console.error(e)}return e},[t,i,null===(e=r.config)||void 0===e?void 0:e.showNotifications]);return d(()=>({error:(e,t=!1)=>o(Object.assign(Object.assign({},e),{type:"error"}),t),success:(e,t=!1)=>o(Object.assign(Object.assign({},e),{type:"success"}),t),warning:(e,t=!1)=>o(Object.assign(Object.assign({},e),{type:"warning"}),t),notify:o}),[o])};Object.values({images:["image/jpeg","image/png","image/gif","image/webp","image/svg+xml","image/bmp","image/tiff"],documents:["application/pdf","text/plain","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],archives:["application/zip","application/x-rar-compressed","application/x-7z-compressed"],videos:["video/mp4","video/avi","video/quicktime","video/x-msvideo"],audio:["audio/mpeg","audio/wav","audio/ogg"]}).flat();const wo=e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]},xo=e=>{if(!e||e<=0)return"";const t=1048576;if(e<t){return`${Math.round(e/1024)} Kb`}return`${(e/t).toFixed(2)} Mb`},Co=e=>{if(null==e)return"";if("number"==typeof e)return xo(e);const t=String(e).trim();if(!t)return"";const n=Number(t);return Number.isNaN(n)?t:xo(n)},_o=(e,t)=>{const n=t.filter(e=>"string"==typeof e),r=new Set(n.map(e=>e.toLowerCase())),i="string"==typeof e?e:String(null!=e?e:"");if(!r.has(i.toLowerCase()))return i;const o=i.lastIndexOf("."),a=o>0?i.slice(0,o):i,s=o>0?i.slice(o):"";let l,c=1;do{l=`${a}_${c}${s}`,c++}while(r.has(l.toLowerCase()));return l},So={FileNotFound:"File not found or no longer available.",FileAlreadyExists:"File with this name already exists.",FileInvalidName:"File name is not valid. Allowed characters: {{allowedChars}}",FileAccessDenied:"You don't have permission to access this file.",FileReadError:"Failed to read the file.",FileWriteError:"Failed to write the file.",FileTooLarge:"File is too large ({{fileSize}}). Maximum allowed size: {{maxSize}}.",FileTypeNotAllowed:"This file type is not allowed.",FileCorrupted:"The file appears to be corrupted.",FileChecksumMismatch:"File integrity check failed.",FileStorageQuotaExceeded:"Storage quota exceeded. Please free up space.",FileLocked:"File is locked by another process or user.",FileVersionConflict:"File version conflict. Please refresh and try again.",FolderNotFound:"Folder not found or no longer available.",FolderAlreadyExists:"Folder with this name already exists.",FolderInvalidName:"Folder name is not valid. Allowed characters: {{allowedChars}}",FolderAccessDenied:"You don't have permission to access this folder.",FolderReadError:"Failed to read the folder contents.",FolderWriteError:"Failed to write to the folder.",FolderQuotaExceeded:"Folder storage quota exceeded.",FolderNotEmpty:"Folder is not empty.",FolderBackendError:"Server error while processing the folder.",FolderTimeout:"Folder operation took too long.",RenameNotAllowed:"Renaming is not allowed for this item.",MoveNotAllowed:"Moving is not allowed for this item.",CopyNotAllowed:"Copying is not allowed for this item.",DeleteNotAllowed:"Deleting is not allowed for this item.",MoveIntoSelf:"Cannot move an item into itself.",MoveIntoDescendant:"Cannot move an item into its descendant folder.",CopyIntoSelf:"Cannot copy an item into itself.",UnsupportedOperation:"This operation is not supported.",ConfigError:"Configuration error occurred.",FileUploadQuotaExceeded:"You have exceeded the upload quota.",FileUploadNetworkError:"Network error while uploading the file.",FileUploadTimeout:"File upload took too long.",FileUploadBackendError:"Server error while uploading the file.",UploadUrlInvalid:"The specified URL is not valid.",UploadUrlNotReachable:"The specified URL is not reachable.",UploadUrlContentTypeNotAllowed:"Content type at the URL is not allowed.",UploadUrlDownloadFailed:"Failed to download file from the URL.",FileLookupFailed:"Failed to find existing file by URL.",FileProxyFailed:"Failed to load file through proxy.",FileProxyNotConfigured:"File proxy is not configured.",FileDownloadNetworkError:"Network error while downloading the file.",FileDownloadTimeout:"File download took too long.",FileDownloadBackendError:"Server error while downloading the file.",BatchPartialFailure:"Some items could not be processed.",BatchAllFailed:"Failed to process all items in the batch.",BatchConflict:"Some items in the batch are in a conflicting state.",BatchValidationFailed:"Some items in the batch did not pass validation.",BatchItemLimitExceeded:"Batch operation exceeds the maximum number of items allowed.",ValidationError:"Some of the provided data is invalid.",PayloadTooLarge:"File is too large ({{fileSize}}). Maximum allowed size: {{maxSize}}.",UnsupportedMediaType:"This media type is not supported.",NetworkError:"Network error. Please check your connection and try again.",BackendError:"Server error. Please try again later.",Timeout:"The operation took too long. Please try again.",AuthenticationFailed:"Authentication failed. Please sign in again.",AuthorizationFailed:"You are not allowed to perform this action.",RateLimitExceeded:"Too many requests. Please try again a bit later.",ServiceUnavailable:"Service is temporarily unavailable. Please try again later.",AIResponseInvalid:"AI service returned an invalid response.",AIImageGenerationFailed:"Failed to generate image using AI.",AIImageGenerationLimitExceeded:"You have reached the AI image generation limit.",IntegrationError:"Error in external integration.",ThirdPartyError:"Error in a third-party service.",UnknownError:"An unknown error occurred."},ko={FileTooLarge:"File is too large to upload.",PayloadTooLarge:"File is too large to upload."},Ao=(e,t,n)=>{var r,i,o;if(!e)return;const a=So[e];if(!a)return;const s=null!==(r=null==n?void 0:n.fileSize)&&void 0!==r?r:"",l=null!==(i=null==n?void 0:n.maxSize)&&void 0!==i?i:"";if(("FileTooLarge"===e||"PayloadTooLarge"===e)&&!(!!s&&!!l)){const n=ko[e];return n?t(n):t(a,{fileSize:"?",maxSize:"?"})}return t(a,{allowedChars:null!==(o=null==n?void 0:n.allowedChars)&&void 0!==o?o:"a-z A-Z 0-9 . _ -",fileSize:s,maxSize:l})},Eo=e=>{if(!e||"string"!=typeof e)return;const t=e.toLowerCase();return(t.includes("maximum number of files")||t.includes("number of files exceeded"))&&(t.includes("allowed")||t.includes("received"))?"BatchItemLimitExceeded":t.includes("exceeds")||t.includes("maximum")||t.includes("too large")||t.includes("size limit")||t.includes("object size")||t.includes("размер")||t.includes("превышен")?"PayloadTooLarge":t.includes("403")||t.includes("forbidden")||t.includes("access denied")||t.includes("доступ запрещён")?"AuthorizationFailed":t.includes("404")||t.includes("not found")||t.includes("не найден")?"UploadUrlNotReachable":t.includes("already exists")||t.includes("уже существует")||t.includes("дубликат")?"FileAlreadyExists":t.includes("invalid")&&(t.includes("name")||t.includes("имя")||t.includes("назва"))?"FileInvalidName":t.includes("type")&&(t.includes("not allowed")||t.includes("не поддерживается"))?"FileTypeNotAllowed":void 0},Io=e=>{var t,n,r,i,o,a,s,l,c,u,d,h,f,p,g,m,v,y;if(!e)return{message:"Unknown error",raw:e};if("string"==typeof e)return{message:e};if(e instanceof Error){const o=e;return{message:null!==(t=o.message)&&void 0!==t?t:e.message,code:o.code,status:null!==(n=o.status)&&void 0!==n?n:o.httpStatus,stack:null!==(r=o.stack)&&void 0!==r?r:e.stack,raw:null!==(i=o.raw)&&void 0!==i?i:e}}if("object"==typeof e){const t=e,n=null!==(o=t.data)&&void 0!==o?o:t,r=null!==(a=null==n?void 0:n.data)&&void 0!==a?a:n,i=null!==(c=null!==(l=null!==(s=t.message)&&void 0!==s?s:null==n?void 0:n.message)&&void 0!==l?l:t.error)&&void 0!==c?c:t.reason,b=null!==(h=null!==(d=null!==(u=t.status)&&void 0!==u?u:t.httpStatus)&&void 0!==d?d:null==r?void 0:r.status)&&void 0!==h?h:null==n?void 0:n.status,w=null!==(f=t.code)&&void 0!==f?f:null==n?void 0:n.code,x=t.stack,C=null!==(p=t.raw)&&void 0!==p?p:e,_=null!==(m=null!==(g=t.fileSize)&&void 0!==g?g:null==r?void 0:r.fileSize)&&void 0!==m?m:null==n?void 0:n.fileSize,S=null!==(y=null!==(v=t.maxSize)&&void 0!==v?v:null==r?void 0:r.maxSize)&&void 0!==y?y:null==n?void 0:n.maxSize;if(i||w||b||x||C)return Object.assign(Object.assign({message:i,code:w,status:b,stack:x,raw:C},null!=_&&{fileSize:_}),null!=S&&{maxSize:S})}return{message:String(e),raw:e}};const To=(e,t,n)=>{const r=Io(e),i=null==r?void 0:r.code;if("FileTooLarge"===i&&null!=(null==n?void 0:n.fileSize)&&null!=(null==n?void 0:n.maxSize))return t("File too large ({{size}}). Maximum allowed size: {{maxSize}}",{size:wo(n.fileSize),maxSize:wo(n.maxSize)});if(("BatchItemLimitExceeded"===i||"exceeded_max_files"===i)&&(null==r?void 0:r.message)){const{allowed:e,received:n}=function(e){const t=e.match(/Allowed:\s*(\d+)/i),n=e.match(/received:\s*(\d+)/i);return{allowed:t?parseInt(t[1],10):void 0,received:n?parseInt(n[1],10):void 0}}(r.message);if(null!=e&&null!=n)return t("Maximum number of files exceeded. Allowed: {{allowed}}, received: {{received}}",{allowed:e,received:n})}if((null==r?void 0:r.message)&&"Unknown error"!==r.message)return r.message;const o=null!=(null==n?void 0:n.fileSize)&&null!=(null==n?void 0:n.maxSize)?{fileSize:wo(n.fileSize),maxSize:wo(n.maxSize)}:void 0,a=Ao(i,t,o);return null!=a?a:t("Error uploading file")},Fo=e=>{const t=Io(e);return"path_folder_not_found"===(null==t?void 0:t.code)},Oo=["file_get_contents","open stream","failed to open stream","http request failed","curl_error"];const Po=(e,t,n)=>{var r;if(!e)return t("Error when downloading a file by URL");const i=null!==(r=(e=>{const t=Eo(e);if("AuthorizationFailed"===t){const t=(e||"").toLowerCase();if(t.includes("download")||t.includes("url")||t.includes("file_get_contents")||t.includes("failed to download"))return"UploadUrlNotReachable"}return t})(null==e?void 0:e.message))&&void 0!==r?r:null==e?void 0:e.code,o=Ao(i,t,n);if(o)return o;const a=(null==e?void 0:e.message)&&"string"==typeof e.message?e.message.trim():null;return a&&function(e){if(!e||e.length>200)return!1;const t=e.toLowerCase();return!Oo.some(e=>t.includes(e))}(a)?a:t("Failed to download file from the URL.")},Mo=e=>Array.isArray(e)?e.filter(e=>(null==e?void 0:e.id)&&"folders"!==e.id).map(e=>e.name).filter(Boolean).join("/"):"",Ro=e=>{const t=e.trim();if(!t)return"";const n=t.toLowerCase(),r=[n.indexOf(" and "),n.indexOf(" or "),t.indexOf(","),t.indexOf(";"),n.indexOf(". ")].filter(e=>e>=0);if(0===r.length)return t;const i=Math.min(...r);return t.slice(0,i).trim()||t},Lo=(e,t)=>{const n=(e=>{var t,n,r,i;if(e&&"object"==typeof e){const o=e,a=null!==(r=null===(n=null===(t=o.data)||void 0===t?void 0:t.data)||void 0===n?void 0:n.path_folder)&&void 0!==r?r:null===(i=o.data)||void 0===i?void 0:i.path_folder;if("string"==typeof a&&a.trim())return Ro(a)||null}const o=Io(e),a=null==o?void 0:o.message;if(!a)return null;const s=a.toLowerCase(),l=["не существует:","not exists:","not exist:","not found:"];for(const e of l){const t=s.indexOf(e);if(t>=0){const n=a.slice(t+e.length).trim();return Ro(n)||null}}const c=["not exists ","not exist ","not found "];for(const e of c){const t=s.indexOf(e);if(t>=0){const n=a.slice(t+e.length).trim();return Ro(n)||null}}return null})(e);return n?(e=>{const t=e.split("/").filter(Boolean);return t.length<=1?"":(t.pop(),t.join("/"))})(n):Mo(t)},No=async e=>{var t;const{options:n,pathFolder:r,dataProviders:i}=e;if(null==i?void 0:i.clearCache)return void await i.clearCache(r||null);const o=null===(t=null==n?void 0:n.apiEndpoints)||void 0===t?void 0:t.clearCache;if(!o)return;const a=o.includes("?");let s=o;r&&r.length>0&&(s=`${o}${a?"&":"?"}path_folder=${encodeURIComponent(r)}`);const l=await fetch(s,{method:"POST"});if(!l.ok)throw new Error(`Cache clear failed: ${l.status}`)},Do={"а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ё":"yo","ж":"zh","з":"z","и":"i","й":"y","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"ts","ч":"ch","ш":"sh","щ":"sch","ъ":"","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ё":"Yo","Ж":"Zh","З":"Z","И":"I","Й":"Y","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"Ts","Ч":"Ch","Ш":"Sh","Щ":"Sch","Ъ":"","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya"},jo=/[<>:"/\\|?*()#\x00-\x1f]/g,zo={transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0};function Bo(e,t){let n=e;return t.transliterate&&(n=n.split("").map(e=>Do[e]||e).join("")),t.removeForbiddenChars&&(n=n.replace(jo,"_")),t.replaceSpaces&&(n=n.replace(/\s+/g,"_")),t.toLowerCase&&(n=n.toLowerCase()),n=n.replace(/_{2,}/g,"_"),n=n.replace(/^_+|_+$/g,""),n.length>255&&(n=n.substring(0,255)),n}function Uo(e,t){const n=Object.assign(Object.assign({},zo),null==t?void 0:t.fileNameProcessing),r=e.lastIndexOf(".");let i,o;r>0?(i=e.substring(0,r),o=e.substring(r).toLowerCase()):(i=e,o="");return(Bo(i,n)||"unnamed_file")+o}function Vo(e,t){return Bo(e,Object.assign(Object.assign({},zo),null==t?void 0:t.folderNameProcessing))||"unnamed_folder"}const Ho=()=>{var e,t;const{state:n,actions:i,options:o}=ro(),{t:a}=Qn(),s=bo(),{folders:l,selectedFolder:u,pathHistory:d,form:h,loading:f,isModalVisible:p}=n,{setFolders:g,setLoading:m,setIsModalVisible:v}=i,{dataProviders:y,config:b}=o,w=c(e=>(Array.isArray(e)?e:[]).filter(e=>e&&e.id&&e.name).map(e=>({id:e.id,name:e.name,parentId:e.folderId?e.folderId:null})),[]),x=c(async(e=!1)=>{null==m||m(!0);try{let e=[];const t="lazy"===(null==b?void 0:b.folderTreeLoading);if(!(null==y?void 0:y.getFolders)){if(null==y?void 0:y.getFiles){const e=async n=>{const{files:r}=await y.getFiles({itemType:"folder",folderId:n||void 0}),i=w(r);if(t)return i;const o=await Promise.all(i.map(t=>e(t.id)));return[...i,...o.flat()]},n=await e(null);return void(g&&g(e=>{const r=Array.isArray(e)?e:[];if(!t){const e=n,t=e.filter(e=>e.id===e.parentId);return t.length>0&&console.warn("Folders with cyclic dependencies detected:",t),e}const i=r.filter(e=>e.parentId),o=[...i,...n],a=o.filter(e=>e.id===e.parentId);return a.length>0&&console.warn("Folders with cyclic dependencies detected:",a),o}))}return void console.error("DataProvider for folders is not defined")}{const n=!t;e=await y.getFolders({parentId:null,deep:n})}const n=Array.isArray(e)?e:[];null==g||g(n);const r=n.filter(e=>e.id===e.parentId);r.length>0&&console.warn("Folders with cyclic dependencies detected:",r)}catch(t){console.error("Error loading folders:",t);const n=Io(t);if(!e&&(404===(null==n?void 0:n.status)||"FileNotFound"===(null==n?void 0:n.code))){const e=Lo(t,d||[]);try{return await No({options:o,pathFolder:e,dataProviders:null==o?void 0:o.dataProviders}),void await x(!0)}catch(e){console.error("Cache clear failed:",e)}}const r=Ao(null==n?void 0:n.code,a);s.error({id:"FOLDERS_FETCH_FAILED",message:null!=r?r:a("Failed to load folders"),placement:"bottomRight",innerException:t,data:{reason:t instanceof Error?t.message:String(t)}})}finally{null==m||m(!1)}},[null==y?void 0:y.getFiles,null==y?void 0:y.getFolders,g,m,null==b?void 0:b.folderTreeLoading,w,s,a,d,o]),C=c(()=>x(),[x]),_=c(async e=>{try{let t,n;if(null==y?void 0:y.getFolders){t=await y.getFolders({parentId:e,deep:!1});const r=Array.isArray(l)?l:[],i=new Set(t.map(e=>e.id)),o=r.filter(t=>t.parentId!==e||i.has(t.id));n=[...o,...t.filter(e=>!o.some(t=>t.id===e.id))]}else{if(!(null==y?void 0:y.getFiles))return[];{const{files:r}=await y.getFiles({itemType:"folder",folderId:e||void 0});t=w(r);const i=Array.isArray(l)?l:[],o=new Set(t.map(e=>e.id)),a=i.filter(t=>t.parentId!==e||o.has(t.id));n=[...a,...t.filter(e=>!a.some(t=>t.id===e.id))]}}let r=n,i=0;for(;i!==r.length;){i=r.length;const e=new Set(r.map(e=>e.id));r=r.filter(t=>!t.parentId||e.has(t.parentId))}return null==g||g(r),t}catch(e){return console.error("Error loading child folders:",e),[]}},[y,l,g,w]),S=c(()=>{var e;const t=null!==(e=null==b?void 0:b.defaultFolderName)&&void 0!==e?e:a("New folder");h.setFieldsValue({folderName:t}),null==v||v(!0)},[h,v,a,null==b?void 0:b.defaultFolderName]),k=c(async(e,t)=>{const n=[...(Array.isArray(l)?l:[]).filter(t=>t.id!==e.id),e];if(null==g||g(n),e.parentId&&(await _(e.parentId),await new Promise(e=>setTimeout(e,50))),!(null==t?void 0:t.preserveSelection)&&i.setSelectedFolder&&i.setSelectedFolder(e.id),!(null==t?void 0:t.preserveSelection)&&i.setPathHistory){const t=Array.isArray(n)?n:[],r=(e,n=new Set)=>{if(n.has(e))return console.warn(`Cycle detected in the path to the folder with id=${e}`),[];const i=t.find(t=>t.id===e);if(!i)return[];const o=new Set(n);return o.add(e),i.parentId?[...r(i.parentId,o),{id:i.id,name:i.name}]:[{id:i.id,name:i.name}]},o=r(e.id),s=[{id:"folders",name:a("Folders")},...o];i.setPathHistory(s)}},[l,g,i,n.pathHistory,_,a]),A=c(async e=>{try{if(null==y?void 0:y.getFolders){const t=await y.getFolders(),n=Array.isArray(t)?t:[];return n.some(t=>t.id===e)}if(null==y?void 0:y.getFiles){const t=new Set,n=async r=>{const{files:i}=await y.getFiles({itemType:"folder",folderId:r||void 0}),o=w(i);for(const r of o){if(t.has(r.id))continue;if(t.add(r.id),r.id===e)return!0;if(await n(r.id))return!0}return!1};return await n(null)}}catch(e){console.warn("⚠️ Error checking the folder:",e)}return!1},[null==y?void 0:y.getFolders,null==y?void 0:y.getFiles,w]),E=c(async e=>{var t;let n,r,i=null;try{const o=await(e?e.validateFields():h.validateFields());if(n=o.folderName.trim(),!n){const e=o.targetFolder||(u&&"folders"!==u?u:null);return void s.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:a("Folder name cannot be empty"),placement:"bottomRight",data:{folderName:n,folderId:null!=e?e:null,reason:"emptyName",is_force_create:!!o.is_force_create}})}r=Vo(n,b);const c=o.targetFolder;if(c)i="folders"!==c?c:null;else if(u&&"folders"!==u)i=u;else if(Array.isArray(d)&&d.length>1){const e=d[d.length-1];i=(null==e?void 0:e.id)&&"folders"!==e.id?e.id:null}if((!1===(null==b?void 0:b.paginationAvailable)||!1===(null==b?void 0:b.hasPagination)||!0===(null==b?void 0:b.disablePagination))&&(null==y?void 0:y.getFolders))try{const e=(await y.getFolders({parentId:i,deep:!1})||[]).map(e=>{var t;return null===(t=e.name)||void 0===t?void 0:t.toLowerCase()}).filter(Boolean);if(e.includes(n.trim().toLowerCase()))return void s.error({id:"FOLDER_ALREADY_EXISTS",message:a("A folder with that name already exists. Please enter a different folder name."),placement:"bottomRight",data:{folderName:n,folderId:i}})}catch(e){}let f;if(!(null==y?void 0:y.createFolder))return void s.error({id:"FOLDER_CREATE_PROVIDER_NOT_CONFIGURED",message:a("Folder creation provider is not configured"),placement:"bottomRight",data:{folderName:r,folderId:null!=i?i:null,is_force_create:!!o.is_force_create}});f=await y.createFolder({name:r,parentId:i,is_force_create:!!o.is_force_create}),(e=>{if(!e||!e.id)throw new Error(a("Invalid server response: folder ID is missing"));if(e.id===e.parentId&&e.parentId)throw console.error("Circular dependency detected: folder cannot be its own parent"),new Error(a("Error: folder cannot be its own parent"))})(f);const p={id:f.id,name:f.name,parentId:null!=i?i:null,childCount:f.childCount},m=[...(Array.isArray(l)?l:[]).filter(e=>e.id!==p.id),p];if(null==g||g(m),s.success({id:"FOLDER_CREATE_SUCCESS",message:a("Folder created"),placement:"bottomRight",data:{itemIds:[p.id],folderId:null!==(t=p.parentId)&&void 0!==t?t:null,folderName:p.name}}),e||null==v||v(!1),(async()=>{try{await k(p,{preserveSelection:Boolean(e)}),await C(),await new Promise(e=>setTimeout(e,200));await A(f.id)||console.warn("⚠️ Could not confirm the creation of the folder on the server, but continuing...")}catch(e){console.error("Error performing background operations after creating the folder:",e)}})(),e)return f}catch(e){console.error("❌ Error creating the folder:",e);const t=Io(e),o=Ao(null==t?void 0:t.code,a);s.error({id:"FOLDER_CREATE_FAILED",message:null!=o?o:a("Failed to create folder"),placement:"bottomRight",innerException:e,data:{folderName:r||n,folderId:null!=i?i:null,reason:e instanceof Error?e.message:String(e)}})}},[h,u,y,k,C,A,v,s,a,l,g,b,d]),I=c(()=>{null==v||v(!1)},[v]),T=c((e,t=new Set)=>{const n=Array.isArray(l)?l:[];return e.map(e=>{if(t.has(e.id))return console.warn(`Cycle detected in the folder structure with id=${e.id}. Skipping child elements processing.`),{key:e.id,label:e.name+" "+a("(error)"),icon:r.createElement(ye,{style:{color:"red"}})};const i=new Set(t);i.add(e.id);const o=n.filter(t=>t.parentId===e.id&&t.id!==e.id);return{key:e.id,label:e.name,children:o.length>0?T(o,i):void 0}})},[l]),F=c(()=>{const e=Array.isArray(l)?l:[],t={key:"folders",label:a("Folders"),children:[]},n=e.filter(e=>null===e.parentId||!e.parentId);return t.children=T(n),[t]},[l,a,T]),O=c(async(e,t)=>{var n,r,c,u;let d;try{const h=t.trim(),f=null==l?void 0:l.find(t=>t.id===e);if(!h)return void s.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:a("Folder name cannot be empty"),placement:"bottomRight",data:{folderId:e,folderName:t,reason:"emptyName"}});d=Vo(h,b);if(!(!1!==(null===(n=null==b?void 0:b.features)||void 0===n?void 0:n.enableRenameFolder)))return void s.error({id:"FOLDER_RENAME_DISABLED_BY_CONFIG",message:a("Folder rename is disabled by config"),placement:"bottomRight",data:{itemId:e,itemName:null!==(r=null==f?void 0:f.name)&&void 0!==r?r:d}});if(!(null===(c=o.dataProviders)||void 0===c?void 0:c.renameFolder))return void s.error({id:"FOLDER_RENAME_FAILED",message:a("Folder rename provider is not configured"),placement:"bottomRight",data:{itemId:e,itemName:d,error:{message:"providerNotConfigured"}}});const p=await o.dataProviders.renameFolder(e,d);if(!(null==p?void 0:p.id))return void s.error({id:"FOLDER_RENAME_FAILED",message:a("Unexpected response when renaming folder"),placement:"bottomRight",data:{itemId:e,itemName:d,error:{message:"invalidResponse"}}});await C(),e!==p.id&&i.setSelectedFolder&&i.setSelectedFolder(p.id),s.success({id:"FOLDER_RENAME_SUCCESS",message:a("Folder renamed"),placement:"bottomRight",data:{itemId:p.id,itemName:p.name,folderId:null!==(u=p.parentId)&&void 0!==u?u:null}})}catch(n){console.error("Error renaming the folder:",n),s.error({id:"FOLDER_RENAME_FAILED",message:a("Failed to rename folder"),placement:"bottomRight",innerException:n,data:{itemId:e,itemName:d||t,error:{message:n instanceof Error?n.message:String(n)}}})}},[C,l,null===(e=o.dataProviders)||void 0===e?void 0:e.renameFolder,null===(t=null==b?void 0:b.features)||void 0===t?void 0:t.enableRenameFolder,b,i.setSelectedFolder,s,a]);return{state:{folders:l,isCreatingFolder:p,loading:f},actions:{fetchFolders:C,fetchChildFolders:_,handleCreateFolder:S,handleModalOk:E,handleModalCancel:I,generateMenuItems:F,renameFolder:O}}},Wo=()=>{const{options:e,actions:t}=ro(),{dataProviders:n,config:r}=e,{setUndoDeletion:i}=t,{t:o}=Qn(),a=bo(),s=c(async({items:e,selectedFolder:t,getItemNameById:s,showNotifications:l=!1})=>{let c=0,u=0;const d=[],h=async t=>{if(null==n?void 0:n.deleteItems)try{const r=await n.deleteItems(e.map(e=>e.id),{permanent:t}),i=r.detailed;if(i){const e=i.filter(e=>e.success),t=i.filter(e=>!e.success),n=t.filter(e=>{var t;const n=null!==(t=e.innerException)&&void 0!==t?t:e.error;return Fo(n)}),r=t.filter(e=>{var t;const n=null!==(t=e.innerException)&&void 0!==t?t:e.error;return!Fo(n)});return c+=e.length+n.length,u+=r.length,void r.forEach(e=>{var t;const n=(e=>{var t;return null!==(t=e.requestId)&&void 0!==t?t:e.id})(e),r=null!==(t=e.innerException)&&void 0!==t?t:e.error,i=Io(r);d.push({itemId:n,itemName:s(n),error:i})})}if(r.success)c+=e.length;else{const t=r.error;if(Fo(t))c+=e.length;else if(t){u+=e.length;const n=Io(t);d.push({error:n})}else u+=e.length}return}catch(n){if(Fo(n))c+=e.length;else{const r=t?"Ошибка при удалении":"Ошибка при перемещении в корзину";console.error(r,n),u+=e.length;const i=Io(n);d.push({error:i})}}const r=t?"DataProvider для удаления файлов не настроен":"DataProvider для перемещения не настроен";console.warn(r)},f=(null==r?void 0:r.enableTrashFolder)&&"Trash"===t;return(null==r?void 0:r.enableTrashFolder)&&!f?await h(!1):await h(!0),c>0&&(null==r?void 0:r.enableTrashFolder)&&!f&&(null==i||i({itemIds:e.map(e=>e.id),sourceFolderId:t||"folders"})),l&&(c>0&&a.success({id:"FILES_DELETE_SUCCESS",message:o("Files deleted"),placement:"bottomRight",data:{successCount:c,totalCount:e.length,itemIds:e.map(e=>e.id),folderId:t||null}}),u>0&&a.error({id:"FILES_DELETE_ERROR",message:o("Error when deleting a file"),placement:"bottomRight",data:{failCount:u,totalCount:e.length,itemIds:e.map(e=>e.id),itemNames:e.map(e=>s(e.id)),folderId:t||null,errors:d}})),{successCount:c,failCount:u,errorDetails:d}},[n,r,i,o,a]);return{deleteItems:s}};class $o extends Error{constructor(e,t,n,r){super(e),this.code=t,this.status=n,this.details=r,this.name="FileManagerApiError",Error.captureStackTrace&&Error.captureStackTrace(this,$o)}}const Go=/^(localhost|127\.0\.0\.1|0\.0\.0\.0|::1)$/i,qo=/^(10\.|172\.(1[6-9]|2[0-9]|3[01])\.|192\.168\.)/;function Yo(e,t){const n=e.trim();if(!n)throw new $o(t("Enter the URL of the image"),"UploadUrlInvalid");if(n.length>8192)throw new $o(t("URL too long"),"UploadUrlInvalid");let r;try{r=new URL(n)}catch(e){throw new $o(t("The specified URL is not valid."),"UploadUrlInvalid")}const i=r.protocol.toLowerCase();if("http:"!==i&&"https:"!==i)throw new $o(t("Only http and https URLs are supported"),"UploadUrlInvalid");const o=r.hostname.toLowerCase();if(Go.test(o))throw new $o(t("Private and local URLs are not allowed"),"UploadUrlInvalid");if(qo.test(o))throw new $o(t("Private and local URLs are not allowed"),"UploadUrlInvalid")}function Xo(e,t){return new Promise(function(n,r){let i;return Ko(e).then(function(e){try{return i=e,n(new Blob([t.slice(0,2),i,t.slice(2)],{type:"image/jpeg"}))}catch(e){return r(e)}},r)})}const Ko=e=>new Promise((t,n)=>{const r=new FileReader;r.addEventListener("load",({target:{result:e}})=>{const r=new DataView(e);let i=0;if(65496!==r.getUint16(i))return n("not a valid JPEG");for(i+=2;;){const o=r.getUint16(i);if(65498===o)break;const a=r.getUint16(i+2);if(65505===o&&1165519206===r.getUint32(i+4)){const o=i+10;let s;switch(r.getUint16(o)){case 18761:s=!0;break;case 19789:s=!1;break;default:return n("TIFF header contains invalid endian")}if(42!==r.getUint16(o+2,s))return n("TIFF header contains invalid version");const l=r.getUint32(o+4,s),c=o+l+2+12*r.getUint16(o+l,s);for(let e=o+l+2;e<c;e+=12)if(274==r.getUint16(e,s)){if(3!==r.getUint16(e+2,s))return n("Orientation data type is invalid");if(1!==r.getUint32(e+4,s))return n("Orientation data count is invalid");r.setUint16(e+8,1,s);break}return t(e.slice(i,i+2+a))}i+=2+a}return t(new Blob)}),r.readAsArrayBuffer(e)});var Zo={},Jo={get exports(){return Zo},set exports(e){Zo=e}};!function(){var e,t,n={};Jo.exports=n,n.parse=function(e,t){for(var r=n.bin.readUshort,i=n.bin.readUint,o=0,a={},s=new Uint8Array(e),l=s.length-4;101010256!=i(s,l);)l--;o=l,o+=4;var c=r(s,o+=4);r(s,o+=2);var u=i(s,o+=2),d=i(s,o+=4);o+=4,o=d;for(var h=0;h<c;h++){i(s,o),o+=4,o+=4,o+=4,i(s,o+=4),u=i(s,o+=4);var f=i(s,o+=4),p=r(s,o+=4),g=r(s,o+2),m=r(s,o+4);o+=6;var v=i(s,o+=8);o+=4,o+=p+g+m,n._readLocal(s,v,a,u,f,t)}return a},n._readLocal=function(e,t,r,i,o,a){var s=n.bin.readUshort,l=n.bin.readUint;l(e,t),s(e,t+=4),s(e,t+=2);var c=s(e,t+=2);l(e,t+=2),l(e,t+=4),t+=4;var u=s(e,t+=8),d=s(e,t+=2);t+=2;var h=n.bin.readUTF8(e,t,u);if(t+=u,t+=d,a)r[h]={size:o,csize:i};else{var f=new Uint8Array(e.buffer,t);if(0==c)r[h]=new Uint8Array(f.buffer.slice(t,t+i));else{if(8!=c)throw"unknown compression method: "+c;var p=new Uint8Array(o);n.inflateRaw(f,p),r[h]=p}}},n.inflateRaw=function(e,t){return n.F.inflate(e,t)},n.inflate=function(e,t){return e[0],e[1],n.inflateRaw(new Uint8Array(e.buffer,e.byteOffset+2,e.length-6),t)},n.deflate=function(e,t){null==t&&(t={level:6});var r=0,i=new Uint8Array(50+Math.floor(1.1*e.length));i[r]=120,i[r+1]=156,r+=2,r=n.F.deflateRaw(e,i,r,t.level);var o=n.adler(e,0,e.length);return i[r+0]=o>>>24&255,i[r+1]=o>>>16&255,i[r+2]=o>>>8&255,i[r+3]=o>>>0&255,new Uint8Array(i.buffer,0,r+4)},n.deflateRaw=function(e,t){null==t&&(t={level:6});var r=new Uint8Array(50+Math.floor(1.1*e.length)),i=n.F.deflateRaw(e,r,i,t.level);return new Uint8Array(r.buffer,0,i)},n.encode=function(e,t){null==t&&(t=!1);var r=0,i=n.bin.writeUint,o=n.bin.writeUshort,a={};for(var s in e){var l=!n._noNeed(s)&&!t,c=e[s],u=n.crc.crc(c,0,c.length);a[s]={cpr:l,usize:c.length,crc:u,file:l?n.deflateRaw(c):c}}for(var s in a)r+=a[s].file.length+30+46+2*n.bin.sizeUTF8(s);r+=22;var d=new Uint8Array(r),h=0,f=[];for(var s in a){var p=a[s];f.push(h),h=n._writeHeader(d,h,s,p,0)}var g=0,m=h;for(var s in a)p=a[s],f.push(h),h=n._writeHeader(d,h,s,p,1,f[g++]);var v=h-m;return i(d,h,101010256),h+=4,o(d,h+=4,g),o(d,h+=2,g),i(d,h+=2,v),i(d,h+=4,m),h+=4,h+=2,d.buffer},n._noNeed=function(e){var t=e.split(".").pop().toLowerCase();return-1!="png,jpg,jpeg,zip".indexOf(t)},n._writeHeader=function(e,t,r,i,o,a){var s=n.bin.writeUint,l=n.bin.writeUshort,c=i.file;return s(e,t,0==o?67324752:33639248),t+=4,1==o&&(t+=2),l(e,t,20),l(e,t+=2,0),l(e,t+=2,i.cpr?8:0),s(e,t+=2,0),s(e,t+=4,i.crc),s(e,t+=4,c.length),s(e,t+=4,i.usize),l(e,t+=4,n.bin.sizeUTF8(r)),l(e,t+=2,0),t+=2,1==o&&(t+=2,t+=2,s(e,t+=6,a),t+=4),t+=n.bin.writeUTF8(e,t,r),0==o&&(e.set(c,t),t+=c.length),t},n.crc={table:function(){for(var e=new Uint32Array(256),t=0;t<256;t++){for(var n=t,r=0;r<8;r++)1&n?n=3988292384^n>>>1:n>>>=1;e[t]=n}return e}(),update:function(e,t,r,i){for(var o=0;o<i;o++)e=n.crc.table[255&(e^t[r+o])]^e>>>8;return e},crc:function(e,t,r){return 4294967295^n.crc.update(4294967295,e,t,r)}},n.adler=function(e,t,n){for(var r=1,i=0,o=t,a=t+n;o<a;){for(var s=Math.min(o+5552,a);o<s;)i+=r+=e[o++];r%=65521,i%=65521}return i<<16|r},n.bin={readUshort:function(e,t){return e[t]|e[t+1]<<8},writeUshort:function(e,t,n){e[t]=255&n,e[t+1]=n>>8&255},readUint:function(e,t){return 16777216*e[t+3]+(e[t+2]<<16|e[t+1]<<8|e[t])},writeUint:function(e,t,n){e[t]=255&n,e[t+1]=n>>8&255,e[t+2]=n>>16&255,e[t+3]=n>>24&255},readASCII:function(e,t,n){for(var r="",i=0;i<n;i++)r+=String.fromCharCode(e[t+i]);return r},writeASCII:function(e,t,n){for(var r=0;r<n.length;r++)e[t+r]=n.charCodeAt(r)},pad:function(e){return e.length<2?"0"+e:e},readUTF8:function(e,t,r){for(var i,o="",a=0;a<r;a++)o+="%"+n.bin.pad(e[t+a].toString(16));try{i=decodeURIComponent(o)}catch(i){return n.bin.readASCII(e,t,r)}return i},writeUTF8:function(e,t,n){for(var r=n.length,i=0,o=0;o<r;o++){var a=n.charCodeAt(o);if(4294967168&a)if(4294965248&a)if(4294901760&a){if(4292870144&a)throw"e";e[t+i]=240|a>>18,e[t+i+1]=128|a>>12&63,e[t+i+2]=128|a>>6&63,e[t+i+3]=128|63&a,i+=4}else e[t+i]=224|a>>12,e[t+i+1]=128|a>>6&63,e[t+i+2]=128|63&a,i+=3;else e[t+i]=192|a>>6,e[t+i+1]=128|63&a,i+=2;else e[t+i]=a,i++}return i},sizeUTF8:function(e){for(var t=e.length,n=0,r=0;r<t;r++){var i=e.charCodeAt(r);if(4294967168&i)if(4294965248&i)if(4294901760&i){if(4292870144&i)throw"e";n+=4}else n+=3;else n+=2;else n++}return n}},n.F={},n.F.deflateRaw=function(e,t,r,i){var o=[[0,0,0,0,0],[4,4,8,4,0],[4,5,16,8,0],[4,6,16,16,0],[4,10,16,32,0],[8,16,32,32,0],[8,16,128,128,0],[8,32,128,256,0],[32,128,258,1024,1],[32,258,258,4096,1]][i],a=n.F.U,s=n.F._goodIndex;n.F._hash;var l=n.F._putsE,c=0,u=r<<3,d=0,h=e.length;if(0==i){for(;c<h;)l(t,u,c+(S=Math.min(65535,h-c))==h?1:0),u=n.F._copyExact(e,c,S,t,u+8),c+=S;return u>>>3}var f=a.lits,p=a.strt,g=a.prev,m=0,v=0,y=0,b=0,w=0,x=0;for(h>2&&(p[x=n.F._hash(e,0)]=0),c=0;c<h;c++){if(w=x,c+1<h-2){x=n.F._hash(e,c+1);var C=c+1&32767;g[C]=p[x],p[x]=C}if(d<=c){(m>14e3||v>26697)&&h-c>100&&(d<c&&(f[m]=c-d,m+=2,d=c),u=n.F._writeBlock(c==h-1||d==h?1:0,f,m,b,e,y,c-y,t,u),m=v=b=0,y=c);var _=0;c<h-2&&(_=n.F._bestMatch(e,c,g,w,Math.min(o[2],h-c),o[3]));var S=_>>>16,k=65535&_;if(0!=_){k=65535&_;var A=s(S=_>>>16,a.of0);a.lhst[257+A]++;var E=s(k,a.df0);a.dhst[E]++,b+=a.exb[A]+a.dxb[E],f[m]=S<<23|c-d,f[m+1]=k<<16|A<<8|E,m+=2,d=c+S}else a.lhst[e[c]]++;v++}}for(y==c&&0!=e.length||(d<c&&(f[m]=c-d,m+=2,d=c),u=n.F._writeBlock(1,f,m,b,e,y,c-y,t,u),m=0,v=0,m=v=b=0,y=c);7&u;)u++;return u>>>3},n.F._bestMatch=function(e,t,r,i,o,a){var s=32767&t,l=r[s],c=s-l+32768&32767;if(l==s||i!=n.F._hash(e,t-c))return 0;for(var u=0,d=0,h=Math.min(32767,t);c<=h&&0!=--a&&l!=s;){if(0==u||e[t+u]==e[t+u-c]){var f=n.F._howLong(e,t,c);if(f>u){if(d=c,(u=f)>=o)break;c+2<f&&(f=c+2);for(var p=0,g=0;g<f-2;g++){var m=t-c+g+32768&32767,v=m-r[m]+32768&32767;v>p&&(p=v,l=m)}}}c+=(s=l)-(l=r[s])+32768&32767}return u<<16|d},n.F._howLong=function(e,t,n){if(e[t]!=e[t-n]||e[t+1]!=e[t+1-n]||e[t+2]!=e[t+2-n])return 0;var r=t,i=Math.min(e.length,t+258);for(t+=3;t<i&&e[t]==e[t-n];)t++;return t-r},n.F._hash=function(e,t){return(e[t]<<8|e[t+1])+(e[t+2]<<4)&65535},n.saved=0,n.F._writeBlock=function(e,t,r,i,o,a,s,l,c){var u,d,h,f,p,g,m,v,y,b=n.F.U,w=n.F._putsF,x=n.F._putsE;b.lhst[256]++,d=(u=n.F.getTrees())[0],h=u[1],f=u[2],p=u[3],g=u[4],m=u[5],v=u[6],y=u[7];var C=32+(c+3&7?8-(c+3&7):0)+(s<<3),_=i+n.F.contSize(b.fltree,b.lhst)+n.F.contSize(b.fdtree,b.dhst),S=i+n.F.contSize(b.ltree,b.lhst)+n.F.contSize(b.dtree,b.dhst);S+=14+3*m+n.F.contSize(b.itree,b.ihst)+(2*b.ihst[16]+3*b.ihst[17]+7*b.ihst[18]);for(var k=0;k<286;k++)b.lhst[k]=0;for(k=0;k<30;k++)b.dhst[k]=0;for(k=0;k<19;k++)b.ihst[k]=0;var A=C<_&&C<S?0:_<S?1:2;if(w(l,c,e),w(l,c+1,A),c+=3,0==A){for(;7&c;)c++;c=n.F._copyExact(o,a,s,l,c)}else{var E,I;if(1==A&&(E=b.fltree,I=b.fdtree),2==A){n.F.makeCodes(b.ltree,d),n.F.revCodes(b.ltree,d),n.F.makeCodes(b.dtree,h),n.F.revCodes(b.dtree,h),n.F.makeCodes(b.itree,f),n.F.revCodes(b.itree,f),E=b.ltree,I=b.dtree,x(l,c,p-257),x(l,c+=5,g-1),x(l,c+=5,m-4),c+=4;for(var T=0;T<m;T++)x(l,c+3*T,b.itree[1+(b.ordr[T]<<1)]);c+=3*m,c=n.F._codeTiny(v,b.itree,l,c),c=n.F._codeTiny(y,b.itree,l,c)}for(var F=a,O=0;O<r;O+=2){for(var P=t[O],M=P>>>23,R=F+(8388607&P);F<R;)c=n.F._writeLit(o[F++],E,l,c);if(0!=M){var L=t[O+1],N=L>>16,D=L>>8&255,j=255&L;x(l,c=n.F._writeLit(257+D,E,l,c),M-b.of0[D]),c+=b.exb[D],w(l,c=n.F._writeLit(j,I,l,c),N-b.df0[j]),c+=b.dxb[j],F+=M}}c=n.F._writeLit(256,E,l,c)}return c},n.F._copyExact=function(e,t,n,r,i){var o=i>>>3;return r[o]=n,r[o+1]=n>>>8,r[o+2]=255-r[o],r[o+3]=255-r[o+1],o+=4,r.set(new Uint8Array(e.buffer,t,n),o),i+(n+4<<3)},n.F.getTrees=function(){for(var e=n.F.U,t=n.F._hufTree(e.lhst,e.ltree,15),r=n.F._hufTree(e.dhst,e.dtree,15),i=[],o=n.F._lenCodes(e.ltree,i),a=[],s=n.F._lenCodes(e.dtree,a),l=0;l<i.length;l+=2)e.ihst[i[l]]++;for(l=0;l<a.length;l+=2)e.ihst[a[l]]++;for(var c=n.F._hufTree(e.ihst,e.itree,7),u=19;u>4&&0==e.itree[1+(e.ordr[u-1]<<1)];)u--;return[t,r,c,o,s,u,i,a]},n.F.getSecond=function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(e[n+1]);return t},n.F.nonZero=function(e){for(var t="",n=0;n<e.length;n+=2)0!=e[n+1]&&(t+=(n>>1)+",");return t},n.F.contSize=function(e,t){for(var n=0,r=0;r<t.length;r++)n+=t[r]*e[1+(r<<1)];return n},n.F._codeTiny=function(e,t,r,i){for(var o=0;o<e.length;o+=2){var a=e[o],s=e[o+1];i=n.F._writeLit(a,t,r,i);var l=16==a?2:17==a?3:7;a>15&&(n.F._putsE(r,i,s,l),i+=l)}return i},n.F._lenCodes=function(e,t){for(var n=e.length;2!=n&&0==e[n-1];)n-=2;for(var r=0;r<n;r+=2){var i=e[r+1],o=r+3<n?e[r+3]:-1,a=r+5<n?e[r+5]:-1,s=0==r?-1:e[r-1];if(0==i&&o==i&&a==i){for(var l=r+5;l+2<n&&e[l+2]==i;)l+=2;(c=Math.min(l+1-r>>>1,138))<11?t.push(17,c-3):t.push(18,c-11),r+=2*c-2}else if(i==s&&o==i&&a==i){for(l=r+5;l+2<n&&e[l+2]==i;)l+=2;var c=Math.min(l+1-r>>>1,6);t.push(16,c-3),r+=2*c-2}else t.push(i,0)}return n>>>1},n.F._hufTree=function(e,t,r){var i=[],o=e.length,a=t.length,s=0;for(s=0;s<a;s+=2)t[s]=0,t[s+1]=0;for(s=0;s<o;s++)0!=e[s]&&i.push({lit:s,f:e[s]});var l=i.length,c=i.slice(0);if(0==l)return 0;if(1==l){var u=i[0].lit;return c=0==u?1:0,t[1+(u<<1)]=1,t[1+(c<<1)]=1,1}i.sort(function(e,t){return e.f-t.f});var d=i[0],h=i[1],f=0,p=1,g=2;for(i[0]={lit:-1,f:d.f+h.f,l:d,r:h,d:0};p!=l-1;)d=f!=p&&(g==l||i[f].f<i[g].f)?i[f++]:i[g++],h=f!=p&&(g==l||i[f].f<i[g].f)?i[f++]:i[g++],i[p++]={lit:-1,f:d.f+h.f,l:d,r:h};var m=n.F.setDepth(i[p-1],0);for(m>r&&(n.F.restrictDepth(c,r,m),m=r),s=0;s<l;s++)t[1+(c[s].lit<<1)]=c[s].d;return m},n.F.setDepth=function(e,t){return-1!=e.lit?(e.d=t,t):Math.max(n.F.setDepth(e.l,t+1),n.F.setDepth(e.r,t+1))},n.F.restrictDepth=function(e,t,n){var r=0,i=1<<n-t,o=0;for(e.sort(function(e,t){return t.d==e.d?e.f-t.f:t.d-e.d}),r=0;r<e.length&&e[r].d>t;r++){var a=e[r].d;e[r].d=t,o+=i-(1<<n-a)}for(o>>>=n-t;o>0;)(a=e[r].d)<t?(e[r].d++,o-=1<<t-a-1):r++;for(;r>=0;r--)e[r].d==t&&o<0&&(e[r].d--,o++);0!=o&&console.log("debt left")},n.F._goodIndex=function(e,t){var n=0;return t[16|n]<=e&&(n|=16),t[8|n]<=e&&(n|=8),t[4|n]<=e&&(n|=4),t[2|n]<=e&&(n|=2),t[1|n]<=e&&(n|=1),n},n.F._writeLit=function(e,t,r,i){return n.F._putsF(r,i,t[e<<1]),i+t[1+(e<<1)]},n.F.inflate=function(e,t){var r=Uint8Array;if(3==e[0]&&0==e[1])return t||new r(0);var i=n.F,o=i._bitsF,a=i._bitsE,s=i._decodeTiny,l=i.makeCodes,c=i.codes2map,u=i._get17,d=i.U,h=null==t;h&&(t=new r(e.length>>>2<<3));for(var f,p,g=0,m=0,v=0,y=0,b=0,w=0,x=0,C=0,_=0;0==g;)if(g=o(e,_,1),m=o(e,_+1,2),_+=3,0!=m){if(h&&(t=n.F._check(t,C+(1<<17))),1==m&&(f=d.flmap,p=d.fdmap,w=511,x=31),2==m){v=a(e,_,5)+257,y=a(e,_+5,5)+1,b=a(e,_+10,4)+4,_+=14;for(var S=0;S<38;S+=2)d.itree[S]=0,d.itree[S+1]=0;var k=1;for(S=0;S<b;S++){var A=a(e,_+3*S,3);d.itree[1+(d.ordr[S]<<1)]=A,A>k&&(k=A)}_+=3*b,l(d.itree,k),c(d.itree,k,d.imap),f=d.lmap,p=d.dmap,_=s(d.imap,(1<<k)-1,v+y,e,_,d.ttree);var E=i._copyOut(d.ttree,0,v,d.ltree);w=(1<<E)-1;var I=i._copyOut(d.ttree,v,y,d.dtree);x=(1<<I)-1,l(d.ltree,E),c(d.ltree,E,f),l(d.dtree,I),c(d.dtree,I,p)}for(;;){var T=f[u(e,_)&w];_+=15&T;var F=T>>>4;if(F>>>8==0)t[C++]=F;else{if(256==F)break;var O=C+F-254;if(F>264){var P=d.ldef[F-257];O=C+(P>>>3)+a(e,_,7&P),_+=7&P}var M=p[u(e,_)&x];_+=15&M;var R=M>>>4,L=d.ddef[R],N=(L>>>4)+o(e,_,15&L);for(_+=15&L,h&&(t=n.F._check(t,C+(1<<17)));C<O;)t[C]=t[C++-N],t[C]=t[C++-N],t[C]=t[C++-N],t[C]=t[C++-N];C=O}}}else{7&_&&(_+=8-(7&_));var D=4+(_>>>3),j=e[D-4]|e[D-3]<<8;h&&(t=n.F._check(t,C+j)),t.set(new r(e.buffer,e.byteOffset+D,j),C),_=D+j<<3,C+=j}return t.length==C?t:t.slice(0,C)},n.F._check=function(e,t){var n=e.length;if(t<=n)return e;var r=new Uint8Array(Math.max(n<<1,t));return r.set(e,0),r},n.F._decodeTiny=function(e,t,r,i,o,a){for(var s=n.F._bitsE,l=n.F._get17,c=0;c<r;){var u=e[l(i,o)&t];o+=15&u;var d=u>>>4;if(d<=15)a[c]=d,c++;else{var h=0,f=0;16==d?(f=3+s(i,o,2),o+=2,h=a[c-1]):17==d?(f=3+s(i,o,3),o+=3):18==d&&(f=11+s(i,o,7),o+=7);for(var p=c+f;c<p;)a[c]=h,c++}}return o},n.F._copyOut=function(e,t,n,r){for(var i=0,o=0,a=r.length>>>1;o<n;){var s=e[o+t];r[o<<1]=0,r[1+(o<<1)]=s,s>i&&(i=s),o++}for(;o<a;)r[o<<1]=0,r[1+(o<<1)]=0,o++;return i},n.F.makeCodes=function(e,t){for(var r,i,o,a,s=n.F.U,l=e.length,c=s.bl_count,u=0;u<=t;u++)c[u]=0;for(u=1;u<l;u+=2)c[e[u]]++;var d=s.next_code;for(r=0,c[0]=0,i=1;i<=t;i++)r=r+c[i-1]<<1,d[i]=r;for(o=0;o<l;o+=2)0!=(a=e[o+1])&&(e[o]=d[a],d[a]++)},n.F.codes2map=function(e,t,r){for(var i=e.length,o=n.F.U.rev15,a=0;a<i;a+=2)if(0!=e[a+1])for(var s=a>>1,l=e[a+1],c=s<<4|l,u=t-l,d=e[a]<<u,h=d+(1<<u);d!=h;)r[o[d]>>>15-t]=c,d++},n.F.revCodes=function(e,t){for(var r=n.F.U.rev15,i=15-t,o=0;o<e.length;o+=2){var a=e[o]<<t-e[o+1];e[o]=r[a]>>>i}},n.F._putsE=function(e,t,n){n<<=7&t;var r=t>>>3;e[r]|=n,e[r+1]|=n>>>8},n.F._putsF=function(e,t,n){n<<=7&t;var r=t>>>3;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},n.F._bitsE=function(e,t,n){return(e[t>>>3]|e[1+(t>>>3)]<<8)>>>(7&t)&(1<<n)-1},n.F._bitsF=function(e,t,n){return(e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)&(1<<n)-1},n.F._get17=function(e,t){return(e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)},n.F._get25=function(e,t){return(e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16|e[3+(t>>>3)]<<24)>>>(7&t)},n.F.U=(e=Uint16Array,t=Uint32Array,{next_code:new e(16),bl_count:new e(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[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,999,999,999],exb:[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,0,0,0],ldef:new e(32),df0:[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,65535,65535],dxb:[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,0,0],ddef:new t(32),flmap:new e(512),fltree:[],fdmap:new e(32),fdtree:[],lmap:new e(32768),ltree:[],ttree:[],dmap:new e(32768),dtree:[],imap:new e(512),itree:[],rev15:new e(32768),lhst:new t(286),dhst:new t(30),ihst:new t(19),lits:new t(15e3),strt:new e(65536),prev:new e(32768)}),function(){for(var e=n.F.U,t=0;t<32768;t++){var r=t;r=(4278255360&(r=(4042322160&(r=(3435973836&(r=(2863311530&r)>>>1|(1431655765&r)<<1))>>>2|(858993459&r)<<2))>>>4|(252645135&r)<<4))>>>8|(16711935&r)<<8,e.rev15[t]=(r>>>16|r<<16)>>>17}function i(e,t,n){for(;0!=t--;)e.push(0,n)}for(t=0;t<32;t++)e.ldef[t]=e.of0[t]<<3|e.exb[t],e.ddef[t]=e.df0[t]<<4|e.dxb[t];i(e.fltree,144,8),i(e.fltree,112,9),i(e.fltree,24,7),i(e.fltree,8,8),n.F.makeCodes(e.fltree,9),n.F.codes2map(e.fltree,9,e.flmap),n.F.revCodes(e.fltree,9),i(e.fdtree,32,5),n.F.makeCodes(e.fdtree,5),n.F.codes2map(e.fdtree,5,e.fdmap),n.F.revCodes(e.fdtree,5),i(e.itree,19,0),i(e.ltree,286,0),i(e.dtree,30,0),i(e.ttree,320,0)}()}();var Qo=function(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(e)}({__proto__:null,default:Zo},[Zo]);const ea=function(){var e={nextZero(e,t){for(;0!=e[t];)t++;return t},readUshort:(e,t)=>e[t]<<8|e[t+1],writeUshort(e,t,n){e[t]=n>>8&255,e[t+1]=255&n},readUint:(e,t)=>16777216*e[t]+(e[t+1]<<16|e[t+2]<<8|e[t+3]),writeUint(e,t,n){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n},readASCII(e,t,n){let r="";for(let i=0;i<n;i++)r+=String.fromCharCode(e[t+i]);return r},writeASCII(e,t,n){for(let r=0;r<n.length;r++)e[t+r]=n.charCodeAt(r)},readBytes(e,t,n){const r=[];for(let i=0;i<n;i++)r.push(e[t+i]);return r},pad:e=>e.length<2?`0${e}`:e,readUTF8(t,n,r){let i,o="";for(let i=0;i<r;i++)o+=`%${e.pad(t[n+i].toString(16))}`;try{i=decodeURIComponent(o)}catch(i){return e.readASCII(t,n,r)}return i}};function t(t,n,r,i){const a=n*r,s=o(i),l=Math.ceil(n*s/8),c=new Uint8Array(4*a),u=new Uint32Array(c.buffer),{ctype:d}=i,{depth:h}=i,f=e.readUshort;if(6==d){const e=a<<2;if(8==h)for(var p=0;p<e;p+=4)c[p]=t[p],c[p+1]=t[p+1],c[p+2]=t[p+2],c[p+3]=t[p+3];if(16==h)for(p=0;p<e;p++)c[p]=t[p<<1]}else if(2==d){const e=i.tabs.tRNS;if(null==e){if(8==h)for(p=0;p<a;p++){var g=3*p;u[p]=255<<24|t[g+2]<<16|t[g+1]<<8|t[g]}if(16==h)for(p=0;p<a;p++)g=6*p,u[p]=255<<24|t[g+4]<<16|t[g+2]<<8|t[g]}else{var m=e[0];const n=e[1],r=e[2];if(8==h)for(p=0;p<a;p++){var v=p<<2;g=3*p,u[p]=255<<24|t[g+2]<<16|t[g+1]<<8|t[g],t[g]==m&&t[g+1]==n&&t[g+2]==r&&(c[v+3]=0)}if(16==h)for(p=0;p<a;p++)v=p<<2,g=6*p,u[p]=255<<24|t[g+4]<<16|t[g+2]<<8|t[g],f(t,g)==m&&f(t,g+2)==n&&f(t,g+4)==r&&(c[v+3]=0)}}else if(3==d){const e=i.tabs.PLTE,o=i.tabs.tRNS,s=o?o.length:0;if(1==h)for(var y=0;y<r;y++){var b=y*l,w=y*n;for(p=0;p<n;p++){v=w+p<<2;var x=3*(C=t[b+(p>>3)]>>7-(7&p)&1);c[v]=e[x],c[v+1]=e[x+1],c[v+2]=e[x+2],c[v+3]=C<s?o[C]:255}}if(2==h)for(y=0;y<r;y++)for(b=y*l,w=y*n,p=0;p<n;p++)v=w+p<<2,x=3*(C=t[b+(p>>2)]>>6-((3&p)<<1)&3),c[v]=e[x],c[v+1]=e[x+1],c[v+2]=e[x+2],c[v+3]=C<s?o[C]:255;if(4==h)for(y=0;y<r;y++)for(b=y*l,w=y*n,p=0;p<n;p++)v=w+p<<2,x=3*(C=t[b+(p>>1)]>>4-((1&p)<<2)&15),c[v]=e[x],c[v+1]=e[x+1],c[v+2]=e[x+2],c[v+3]=C<s?o[C]:255;if(8==h)for(p=0;p<a;p++){var C;v=p<<2,x=3*(C=t[p]),c[v]=e[x],c[v+1]=e[x+1],c[v+2]=e[x+2],c[v+3]=C<s?o[C]:255}}else if(4==d){if(8==h)for(p=0;p<a;p++){v=p<<2;var _=t[S=p<<1];c[v]=_,c[v+1]=_,c[v+2]=_,c[v+3]=t[S+1]}if(16==h)for(p=0;p<a;p++){var S;v=p<<2,_=t[S=p<<2],c[v]=_,c[v+1]=_,c[v+2]=_,c[v+3]=t[S+2]}}else if(0==d)for(m=i.tabs.tRNS?i.tabs.tRNS:-1,y=0;y<r;y++){const e=y*l,r=y*n;if(1==h)for(var k=0;k<n;k++){var A=(_=255*(t[e+(k>>>3)]>>>7-(7&k)&1))==255*m?0:255;u[r+k]=A<<24|_<<16|_<<8|_}else if(2==h)for(k=0;k<n;k++)A=(_=85*(t[e+(k>>>2)]>>>6-((3&k)<<1)&3))==85*m?0:255,u[r+k]=A<<24|_<<16|_<<8|_;else if(4==h)for(k=0;k<n;k++)A=(_=17*(t[e+(k>>>1)]>>>4-((1&k)<<2)&15))==17*m?0:255,u[r+k]=A<<24|_<<16|_<<8|_;else if(8==h)for(k=0;k<n;k++)A=(_=t[e+k])==m?0:255,u[r+k]=A<<24|_<<16|_<<8|_;else if(16==h)for(k=0;k<n;k++)_=t[e+(k<<1)],A=f(t,e+(k<<1))==m?0:255,u[r+k]=A<<24|_<<16|_<<8|_}return c}function n(e,t,n,s){const l=o(e),c=Math.ceil(n*l/8),u=new Uint8Array((c+1+e.interlace)*s);return t=e.tabs.CgBI?i(t,u):r(t,u),0==e.interlace?t=a(t,e,0,n,s):1==e.interlace&&(t=function(e,t){const n=t.width,r=t.height,i=o(t),s=i>>3,l=Math.ceil(n*i/8),c=new Uint8Array(r*l);let u=0;const d=[0,0,4,0,2,0,1],h=[0,4,0,2,0,1,0],f=[8,8,8,4,4,2,2],p=[8,8,4,4,2,2,1];let g=0;for(;g<7;){const o=f[g],v=p[g];let y=0,b=0,w=d[g];for(;w<r;)w+=o,b++;let x=h[g];for(;x<n;)x+=v,y++;const C=Math.ceil(y*i/8);a(e,t,u,y,b);let _=0,S=d[g];for(;S<r;){let t=h[g],r=u+_*C<<3;for(;t<n;){var m;if(1==i&&(m=(m=e[r>>3])>>7-(7&r)&1,c[S*l+(t>>3)]|=m<<7-(7&t)),2==i&&(m=(m=e[r>>3])>>6-(7&r)&3,c[S*l+(t>>2)]|=m<<6-((3&t)<<1)),4==i&&(m=(m=e[r>>3])>>4-(7&r)&15,c[S*l+(t>>1)]|=m<<4-((1&t)<<2)),i>=8){const n=S*l+t*s;for(let t=0;t<s;t++)c[n+t]=e[(r>>3)+t]}r+=i,t+=v}_++,S+=o}y*b!=0&&(u+=b*(1+C)),g+=1}return c}(t,e)),t}function r(e,t){return i(new Uint8Array(e.buffer,2,e.length-6),t)}var i=function(){const e={H:{}};return e.H.N=function(t,n){const r=Uint8Array;let i,o,a=0,s=0,l=0,c=0,u=0,d=0,h=0,f=0,p=0;if(3==t[0]&&0==t[1])return n||new r(0);const g=e.H,m=g.b,v=g.e,y=g.R,b=g.n,w=g.A,x=g.Z,C=g.m,_=null==n;for(_&&(n=new r(t.length>>>2<<5));0==a;)if(a=m(t,p,1),s=m(t,p+1,2),p+=3,0!=s){if(_&&(n=e.H.W(n,f+(1<<17))),1==s&&(i=C.J,o=C.h,d=511,h=31),2==s){l=v(t,p,5)+257,c=v(t,p+5,5)+1,u=v(t,p+10,4)+4,p+=14;let e=1;for(var S=0;S<38;S+=2)C.Q[S]=0,C.Q[S+1]=0;for(S=0;S<u;S++){const n=v(t,p+3*S,3);C.Q[1+(C.X[S]<<1)]=n,n>e&&(e=n)}p+=3*u,b(C.Q,e),w(C.Q,e,C.u),i=C.w,o=C.d,p=y(C.u,(1<<e)-1,l+c,t,p,C.v);const n=g.V(C.v,0,l,C.C);d=(1<<n)-1;const r=g.V(C.v,l,c,C.D);h=(1<<r)-1,b(C.C,n),w(C.C,n,i),b(C.D,r),w(C.D,r,o)}for(;;){const e=i[x(t,p)&d];p+=15&e;const r=e>>>4;if(r>>>8==0)n[f++]=r;else{if(256==r)break;{let e=f+r-254;if(r>264){const n=C.q[r-257];e=f+(n>>>3)+v(t,p,7&n),p+=7&n}const i=o[x(t,p)&h];p+=15&i;const a=i>>>4,s=C.c[a],l=(s>>>4)+m(t,p,15&s);for(p+=15&s;f<e;)n[f]=n[f++-l],n[f]=n[f++-l],n[f]=n[f++-l],n[f]=n[f++-l];f=e}}}}else{7&p&&(p+=8-(7&p));const i=4+(p>>>3),o=t[i-4]|t[i-3]<<8;_&&(n=e.H.W(n,f+o)),n.set(new r(t.buffer,t.byteOffset+i,o),f),p=i+o<<3,f+=o}return n.length==f?n:n.slice(0,f)},e.H.W=function(e,t){const n=e.length;if(t<=n)return e;const r=new Uint8Array(n<<1);return r.set(e,0),r},e.H.R=function(t,n,r,i,o,a){const s=e.H.e,l=e.H.Z;let c=0;for(;c<r;){const e=t[l(i,o)&n];o+=15&e;const r=e>>>4;if(r<=15)a[c]=r,c++;else{let e=0,t=0;16==r?(t=3+s(i,o,2),o+=2,e=a[c-1]):17==r?(t=3+s(i,o,3),o+=3):18==r&&(t=11+s(i,o,7),o+=7);const n=c+t;for(;c<n;)a[c]=e,c++}}return o},e.H.V=function(e,t,n,r){let i=0,o=0;const a=r.length>>>1;for(;o<n;){const n=e[o+t];r[o<<1]=0,r[1+(o<<1)]=n,n>i&&(i=n),o++}for(;o<a;)r[o<<1]=0,r[1+(o<<1)]=0,o++;return i},e.H.n=function(t,n){const r=e.H.m,i=t.length;let o,a,s,l;const c=r.j;for(var u=0;u<=n;u++)c[u]=0;for(u=1;u<i;u+=2)c[t[u]]++;const d=r.K;for(o=0,c[0]=0,a=1;a<=n;a++)o=o+c[a-1]<<1,d[a]=o;for(s=0;s<i;s+=2)l=t[s+1],0!=l&&(t[s]=d[l],d[l]++)},e.H.A=function(t,n,r){const i=t.length,o=e.H.m.r;for(let e=0;e<i;e+=2)if(0!=t[e+1]){const i=e>>1,a=t[e+1],s=i<<4|a,l=n-a;let c=t[e]<<l;const u=c+(1<<l);for(;c!=u;)r[o[c]>>>15-n]=s,c++}},e.H.l=function(t,n){const r=e.H.m.r,i=15-n;for(let e=0;e<t.length;e+=2){const o=t[e]<<n-t[e+1];t[e]=r[o]>>>i}},e.H.M=function(e,t,n){n<<=7&t;const r=t>>>3;e[r]|=n,e[r+1]|=n>>>8},e.H.I=function(e,t,n){n<<=7&t;const r=t>>>3;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},e.H.e=function(e,t,n){return(e[t>>>3]|e[1+(t>>>3)]<<8)>>>(7&t)&(1<<n)-1},e.H.b=function(e,t,n){return(e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)&(1<<n)-1},e.H.Z=function(e,t){return(e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)},e.H.i=function(e,t){return(e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16|e[3+(t>>>3)]<<24)>>>(7&t)},e.H.m=function(){const e=Uint16Array,t=Uint32Array;return{K:new e(16),j:new e(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[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,999,999,999],T:[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,0,0,0],q:new e(32),p:[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,65535,65535],z:[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,0,0],c:new t(32),J:new e(512),_:[],h:new e(32),$:[],w:new e(32768),C:[],v:[],d:new e(32768),D:[],u:new e(512),Q:[],r:new e(32768),s:new t(286),Y:new t(30),a:new t(19),t:new t(15e3),k:new e(65536),g:new e(32768)}}(),function(){const t=e.H.m;for(var n=0;n<32768;n++){let e=n;e=(2863311530&e)>>>1|(1431655765&e)<<1,e=(3435973836&e)>>>2|(858993459&e)<<2,e=(4042322160&e)>>>4|(252645135&e)<<4,e=(4278255360&e)>>>8|(16711935&e)<<8,t.r[n]=(e>>>16|e<<16)>>>17}function r(e,t,n){for(;0!=t--;)e.push(0,n)}for(n=0;n<32;n++)t.q[n]=t.S[n]<<3|t.T[n],t.c[n]=t.p[n]<<4|t.z[n];r(t._,144,8),r(t._,112,9),r(t._,24,7),r(t._,8,8),e.H.n(t._,9),e.H.A(t._,9,t.J),e.H.l(t._,9),r(t.$,32,5),e.H.n(t.$,5),e.H.A(t.$,5,t.h),e.H.l(t.$,5),r(t.Q,19,0),r(t.C,286,0),r(t.D,30,0),r(t.v,320,0)}(),e.H.N}();function o(e){return[1,null,3,1,2,null,4][e.ctype]*e.depth}function a(e,t,n,r,i){let a=o(t);const l=Math.ceil(r*a/8);let c,u;a=Math.ceil(a/8);let d=e[n],h=0;if(d>1&&(e[n]=[0,0,1][d-2]),3==d)for(h=a;h<l;h++)e[h+1]=e[h+1]+(e[h+1-a]>>>1)&255;for(let t=0;t<i;t++)if(c=n+t*l,u=c+t+1,d=e[u-1],h=0,0==d)for(;h<l;h++)e[c+h]=e[u+h];else if(1==d){for(;h<a;h++)e[c+h]=e[u+h];for(;h<l;h++)e[c+h]=e[u+h]+e[c+h-a]}else if(2==d)for(;h<l;h++)e[c+h]=e[u+h]+e[c+h-l];else if(3==d){for(;h<a;h++)e[c+h]=e[u+h]+(e[c+h-l]>>>1);for(;h<l;h++)e[c+h]=e[u+h]+(e[c+h-l]+e[c+h-a]>>>1)}else{for(;h<a;h++)e[c+h]=e[u+h]+s(0,e[c+h-l],0);for(;h<l;h++)e[c+h]=e[u+h]+s(e[c+h-a],e[c+h-l],e[c+h-a-l])}return e}function s(e,t,n){const r=e+t-n,i=r-e,o=r-t,a=r-n;return i*i<=o*o&&i*i<=a*a?e:o*o<=a*a?t:n}function l(t,n,r){r.width=e.readUint(t,n),n+=4,r.height=e.readUint(t,n),n+=4,r.depth=t[n],n++,r.ctype=t[n],n++,r.compress=t[n],n++,r.filter=t[n],n++,r.interlace=t[n],n++}function c(e,t,n,r,i,o,a,s,l){const c=Math.min(t,i),u=Math.min(n,o);let d=0,h=0;for(let n=0;n<u;n++)for(let o=0;o<c;o++)if(a>=0&&s>=0?(d=n*t+o<<2,h=(s+n)*i+a+o<<2):(d=(-s+n)*t-a+o<<2,h=n*i+o<<2),0==l)r[h]=e[d],r[h+1]=e[d+1],r[h+2]=e[d+2],r[h+3]=e[d+3];else if(1==l){var f=e[d+3]*(1/255),p=e[d]*f,g=e[d+1]*f,m=e[d+2]*f,v=r[h+3]*(1/255),y=r[h]*v,b=r[h+1]*v,w=r[h+2]*v;const t=1-f,n=f+v*t,i=0==n?0:1/n;r[h+3]=255*n,r[h+0]=(p+y*t)*i,r[h+1]=(g+b*t)*i,r[h+2]=(m+w*t)*i}else if(2==l)f=e[d+3],p=e[d],g=e[d+1],m=e[d+2],v=r[h+3],y=r[h],b=r[h+1],w=r[h+2],f==v&&p==y&&g==b&&m==w?(r[h]=0,r[h+1]=0,r[h+2]=0,r[h+3]=0):(r[h]=p,r[h+1]=g,r[h+2]=m,r[h+3]=f);else if(3==l){if(f=e[d+3],p=e[d],g=e[d+1],m=e[d+2],v=r[h+3],y=r[h],b=r[h+1],w=r[h+2],f==v&&p==y&&g==b&&m==w)continue;if(f<220&&v>20)return!1}return!0}return{decode:function(t){const o=new Uint8Array(t);let a=8;const s=e,c=s.readUshort,u=s.readUint,d={tabs:{},frames:[]},h=new Uint8Array(o.length);let f,p=0,g=0;const m=[137,80,78,71,13,10,26,10];for(var v=0;v<8;v++)if(o[v]!=m[v])throw"The input is not a PNG file!";for(;a<o.length;){const e=s.readUint(o,a);a+=4;const t=s.readASCII(o,a,4);if(a+=4,"IHDR"==t)l(o,a,d);else if("iCCP"==t){for(var y=a;0!=o[y];)y++;s.readASCII(o,a,y-a),o[y+1];const n=o.slice(y+2,a+e);let l=null;try{l=r(n)}catch(e){l=i(n)}d.tabs[t]=l}else if("CgBI"==t)d.tabs[t]=o.slice(a,a+4);else if("IDAT"==t){for(v=0;v<e;v++)h[p+v]=o[a+v];p+=e}else if("acTL"==t)d.tabs[t]={num_frames:u(o,a),num_plays:u(o,a+4)},f=new Uint8Array(o.length);else if("fcTL"==t){0!=g&&((S=d.frames[d.frames.length-1]).data=n(d,f.slice(0,g),S.rect.width,S.rect.height),g=0);const e={x:u(o,a+12),y:u(o,a+16),width:u(o,a+4),height:u(o,a+8)};let t=c(o,a+22);t=c(o,a+20)/(0==t?100:t);const r={rect:e,delay:Math.round(1e3*t),dispose:o[a+24],blend:o[a+25]};d.frames.push(r)}else if("fdAT"==t){for(v=0;v<e-4;v++)f[g+v]=o[a+v+4];g+=e-4}else if("pHYs"==t)d.tabs[t]=[s.readUint(o,a),s.readUint(o,a+4),o[a+8]];else if("cHRM"==t)for(d.tabs[t]=[],v=0;v<8;v++)d.tabs[t].push(s.readUint(o,a+4*v));else if("tEXt"==t||"zTXt"==t){null==d.tabs[t]&&(d.tabs[t]={});var b=s.nextZero(o,a),w=s.readASCII(o,a,b-a),x=a+e-b-1;if("tEXt"==t)_=s.readASCII(o,b+1,x);else{var C=r(o.slice(b+2,b+2+x));_=s.readUTF8(C,0,C.length)}d.tabs[t][w]=_}else if("iTXt"==t){null==d.tabs[t]&&(d.tabs[t]={}),b=0,y=a,b=s.nextZero(o,y),w=s.readASCII(o,y,b-y);const n=o[y=b+1];var _;o[y+1],y+=2,b=s.nextZero(o,y),s.readASCII(o,y,b-y),y=b+1,b=s.nextZero(o,y),s.readUTF8(o,y,b-y),x=e-((y=b+1)-a),0==n?_=s.readUTF8(o,y,x):(C=r(o.slice(y,y+x)),_=s.readUTF8(C,0,C.length)),d.tabs[t][w]=_}else if("PLTE"==t)d.tabs[t]=s.readBytes(o,a,e);else if("hIST"==t){const e=d.tabs.PLTE.length/3;for(d.tabs[t]=[],v=0;v<e;v++)d.tabs[t].push(c(o,a+2*v))}else if("tRNS"==t)3==d.ctype?d.tabs[t]=s.readBytes(o,a,e):0==d.ctype?d.tabs[t]=c(o,a):2==d.ctype&&(d.tabs[t]=[c(o,a),c(o,a+2),c(o,a+4)]);else if("gAMA"==t)d.tabs[t]=s.readUint(o,a)/1e5;else if("sRGB"==t)d.tabs[t]=o[a];else if("bKGD"==t)0==d.ctype||4==d.ctype?d.tabs[t]=[c(o,a)]:2==d.ctype||6==d.ctype?d.tabs[t]=[c(o,a),c(o,a+2),c(o,a+4)]:3==d.ctype&&(d.tabs[t]=o[a]);else if("IEND"==t)break;a+=e,s.readUint(o,a),a+=4}var S;return 0!=g&&((S=d.frames[d.frames.length-1]).data=n(d,f.slice(0,g),S.rect.width,S.rect.height)),d.data=n(d,h,d.width,d.height),delete d.compress,delete d.interlace,delete d.filter,d},toRGBA8:function(e){const n=e.width,r=e.height;if(null==e.tabs.acTL)return[t(e.data,n,r,e).buffer];const i=[];null==e.frames[0].data&&(e.frames[0].data=e.data);const o=n*r*4,a=new Uint8Array(o),s=new Uint8Array(o),l=new Uint8Array(o);for(let d=0;d<e.frames.length;d++){const h=e.frames[d],f=h.rect.x,p=h.rect.y,g=h.rect.width,m=h.rect.height,v=t(h.data,g,m,e);if(0!=d)for(var u=0;u<o;u++)l[u]=a[u];if(0==h.blend?c(v,g,m,a,n,r,f,p,0):1==h.blend&&c(v,g,m,a,n,r,f,p,1),i.push(a.buffer.slice(0)),0==h.dispose);else if(1==h.dispose)c(s,g,m,a,n,r,f,p,0);else if(2==h.dispose)for(u=0;u<o;u++)a[u]=l[u]}return i},_paeth:s,_copyTile:c,_bin:e}}();!function(){const{_copyTile:e}=ea,{_bin:t}=ea,n=ea._paeth;var r={table:function(){const e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)1&n?n=3988292384^n>>>1:n>>>=1;e[t]=n}return e}(),update(e,t,n,i){for(let o=0;o<i;o++)e=r.table[255&(e^t[n+o])]^e>>>8;return e},crc:(e,t,n)=>4294967295^r.update(4294967295,e,t,n)};function i(e,t,n,r){t[n]+=e[0]*r>>4,t[n+1]+=e[1]*r>>4,t[n+2]+=e[2]*r>>4,t[n+3]+=e[3]*r>>4}function o(e){return Math.max(0,Math.min(255,e))}function a(e,t){const n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2],o=e[3]-t[3];return n*n+r*r+i*i+o*o}function s(e,t,n,r,s,l,c){null==c&&(c=1);const u=r.length,d=[];for(var h=0;h<u;h++){const e=r[h];d.push([e>>>0&255,e>>>8&255,e>>>16&255,e>>>24&255])}for(h=0;h<u;h++){let e=4294967295;for(var f=0,p=0;p<u;p++){var g=a(d[h],d[p]);p!=h&&g<e&&(e=g,f=p)}}const m=new Uint32Array(s.buffer),v=new Int16Array(t*n*4),y=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];for(h=0;h<y.length;h++)y[h]=255*((y[h]+.5)/16-.5);for(let s=0;s<n;s++)for(let w=0;w<t;w++){var b;h=4*(s*t+w),2!=c?b=[o(e[h]+v[h]),o(e[h+1]+v[h+1]),o(e[h+2]+v[h+2]),o(e[h+3]+v[h+3])]:(g=y[4*(3&s)+(3&w)],b=[o(e[h]+g),o(e[h+1]+g),o(e[h+2]+g),o(e[h+3]+g)]),f=0;let x=16777215;for(p=0;p<u;p++){const e=a(b,d[p]);e<x&&(x=e,f=p)}const C=d[f],_=[b[0]-C[0],b[1]-C[1],b[2]-C[2],b[3]-C[3]];1==c&&(w!=t-1&&i(_,v,h+4,7),s!=n-1&&(0!=w&&i(_,v,h+4*t-4,3),i(_,v,h+4*t,5),w!=t-1&&i(_,v,h+4*t+4,1))),l[h>>2]=f,m[h>>2]=r[f]}}function l(e,n,i,o,a){null==a&&(a={});const{crc:s}=r,l=t.writeUint,c=t.writeUshort,u=t.writeASCII;let d=8;const h=e.frames.length>1;let f,p=!1,g=33+(h?20:0);if(null!=a.sRGB&&(g+=13),null!=a.pHYs&&(g+=21),null!=a.iCCP&&(f=pako.deflate(a.iCCP),g+=21+f.length+4),3==e.ctype){for(var m=e.plte.length,v=0;v<m;v++)e.plte[v]>>>24!=255&&(p=!0);g+=8+3*m+4+(p?8+1*m+4:0)}for(var y=0;y<e.frames.length;y++)h&&(g+=38),g+=(C=e.frames[y]).cimg.length+12,0!=y&&(g+=4);g+=12;const b=new Uint8Array(g),w=[137,80,78,71,13,10,26,10];for(v=0;v<8;v++)b[v]=w[v];if(l(b,d,13),d+=4,u(b,d,"IHDR"),d+=4,l(b,d,n),d+=4,l(b,d,i),d+=4,b[d]=e.depth,d++,b[d]=e.ctype,d++,b[d]=0,d++,b[d]=0,d++,b[d]=0,d++,l(b,d,s(b,d-17,17)),d+=4,null!=a.sRGB&&(l(b,d,1),d+=4,u(b,d,"sRGB"),d+=4,b[d]=a.sRGB,d++,l(b,d,s(b,d-5,5)),d+=4),null!=a.iCCP){const e=13+f.length;l(b,d,e),d+=4,u(b,d,"iCCP"),d+=4,u(b,d,"ICC profile"),d+=11,d+=2,b.set(f,d),d+=f.length,l(b,d,s(b,d-(e+4),e+4)),d+=4}if(null!=a.pHYs&&(l(b,d,9),d+=4,u(b,d,"pHYs"),d+=4,l(b,d,a.pHYs[0]),d+=4,l(b,d,a.pHYs[1]),d+=4,b[d]=a.pHYs[2],d++,l(b,d,s(b,d-13,13)),d+=4),h&&(l(b,d,8),d+=4,u(b,d,"acTL"),d+=4,l(b,d,e.frames.length),d+=4,l(b,d,null!=a.loop?a.loop:0),d+=4,l(b,d,s(b,d-12,12)),d+=4),3==e.ctype){for(l(b,d,3*(m=e.plte.length)),d+=4,u(b,d,"PLTE"),d+=4,v=0;v<m;v++){const t=3*v,n=e.plte[v],r=255&n,i=n>>>8&255,o=n>>>16&255;b[d+t+0]=r,b[d+t+1]=i,b[d+t+2]=o}if(d+=3*m,l(b,d,s(b,d-3*m-4,3*m+4)),d+=4,p){for(l(b,d,m),d+=4,u(b,d,"tRNS"),d+=4,v=0;v<m;v++)b[d+v]=e.plte[v]>>>24&255;d+=m,l(b,d,s(b,d-m-4,m+4)),d+=4}}let x=0;for(y=0;y<e.frames.length;y++){var C=e.frames[y];h&&(l(b,d,26),d+=4,u(b,d,"fcTL"),d+=4,l(b,d,x++),d+=4,l(b,d,C.rect.width),d+=4,l(b,d,C.rect.height),d+=4,l(b,d,C.rect.x),d+=4,l(b,d,C.rect.y),d+=4,c(b,d,o[y]),d+=2,c(b,d,1e3),d+=2,b[d]=C.dispose,d++,b[d]=C.blend,d++,l(b,d,s(b,d-30,30)),d+=4);const t=C.cimg;l(b,d,(m=t.length)+(0==y?0:4)),d+=4;const n=d;u(b,d,0==y?"IDAT":"fdAT"),d+=4,0!=y&&(l(b,d,x++),d+=4),b.set(t,d),d+=m,l(b,d,s(b,n,d-n)),d+=4}return l(b,d,0),d+=4,u(b,d,"IEND"),d+=4,l(b,d,s(b,d-4,4)),d+=4,b.buffer}function c(e,t,n){for(let r=0;r<e.frames.length;r++){const i=e.frames[r];i.rect.width;const o=i.rect.height,a=new Uint8Array(o*i.bpl+o);i.cimg=f(i.img,o,i.bpp,i.bpl,a,t,n)}}function u(t,n,r,i,o){const a=o[0],l=o[1],c=o[2],u=o[3],f=o[4],p=o[5];let m=6,v=8,y=255;for(var b=0;b<t.length;b++){const e=new Uint8Array(t[b]);for(var w=e.length,x=0;x<w;x+=4)y&=e[x+3]}const C=255!=y,_=function(t,n,r,i,o,a){const s=[];for(var l=0;l<t.length;l++){const d=new Uint8Array(t[l]),f=new Uint32Array(d.buffer);var c;let g=0,m=0,v=n,y=r,b=i?1:0;if(0!=l){const w=a||i||1==l||0!=s[l-2].dispose?1:2;let x=0,C=1e9;for(let e=0;e<w;e++){var u=new Uint8Array(t[l-1-e]);const i=new Uint32Array(t[l-1-e]);let a=n,s=r,c=-1,d=-1;for(let e=0;e<r;e++)for(let t=0;t<n;t++)f[p=e*n+t]!=i[p]&&(t<a&&(a=t),t>c&&(c=t),e<s&&(s=e),e>d&&(d=e));-1==c&&(a=s=c=d=0),o&&(!(1&~a)&&a--,!(1&~s)&&s--);const h=(c-a+1)*(d-s+1);h<C&&(C=h,x=e,g=a,m=s,v=c-a+1,y=d-s+1)}u=new Uint8Array(t[l-1-x]),1==x&&(s[l-1].dispose=2),c=new Uint8Array(v*y*4),e(u,n,r,c,v,y,-g,-m,0),b=e(d,n,r,c,v,y,-g,-m,3)?1:0,1==b?h(d,n,r,c,{x:g,y:m,width:v,height:y}):e(d,n,r,c,v,y,-g,-m,0)}else c=d.slice(0);s.push({rect:{x:g,y:m,width:v,height:y},img:c,blend:b,dispose:0})}if(i)for(l=0;l<s.length;l++){if(1==(g=s[l]).blend)continue;const e=g.rect,i=s[l-1].rect,a=Math.min(e.x,i.x),c=Math.min(e.y,i.y),u={x:a,y:c,width:Math.max(e.x+e.width,i.x+i.width)-a,height:Math.max(e.y+e.height,i.y+i.height)-c};s[l-1].dispose=1,l-1!=0&&d(t,n,r,s,l-1,u,o),d(t,n,r,s,l,u,o)}let f=0;if(1!=t.length)for(var p=0;p<s.length;p++){var g;f+=(g=s[p]).rect.width*g.rect.height}return s}(t,n,r,a,l,c),S={},k=[],A=[];if(0!=i){const e=[];for(x=0;x<_.length;x++)e.push(_[x].img.buffer);const t=function(e){let t=0;for(var n=0;n<e.length;n++)t+=e[n].byteLength;const r=new Uint8Array(t);let i=0;for(n=0;n<e.length;n++){const t=new Uint8Array(e[n]),o=t.length;for(let e=0;e<o;e+=4){let n=t[e],o=t[e+1],a=t[e+2];const s=t[e+3];0==s&&(n=o=a=0),r[i+e]=n,r[i+e+1]=o,r[i+e+2]=a,r[i+e+3]=s}i+=o}return r.buffer}(e),n=g(t,i);for(x=0;x<n.plte.length;x++)k.push(n.plte[x].est.rgba);let r=0;for(x=0;x<_.length;x++){const e=(I=_[x]).img.length;var E=new Uint8Array(n.inds.buffer,r>>2,e>>2);A.push(E);const t=new Uint8Array(n.abuf,r,e);p&&s(I.img,I.rect.width,I.rect.height,k,t,E),I.img.set(t),r+=e}}else for(b=0;b<_.length;b++){var I=_[b];const e=new Uint32Array(I.img.buffer);var T=I.rect.width;for(w=e.length,E=new Uint8Array(w),A.push(E),x=0;x<w;x++){const t=e[x];if(0!=x&&t==e[x-1])E[x]=E[x-1];else if(x>T&&t==e[x-T])E[x]=E[x-T];else{let e=S[t];if(null==e&&(S[t]=e=k.length,k.push(t),k.length>=300))break;E[x]=e}}}const F=k.length;for(F<=256&&0==f&&(v=F<=2?1:F<=4?2:F<=16?4:8,v=Math.max(v,u)),b=0;b<_.length;b++){(I=_[b]).rect.x,I.rect.y,T=I.rect.width;const e=I.rect.height;let t=I.img;new Uint32Array(t.buffer);let n=4*T,r=4;if(F<=256&&0==f){n=Math.ceil(v*T/8);var O=new Uint8Array(n*e);const i=A[b];for(let t=0;t<e;t++){x=t*n;const e=t*T;if(8==v)for(var P=0;P<T;P++)O[x+P]=i[e+P];else if(4==v)for(P=0;P<T;P++)O[x+(P>>1)]|=i[e+P]<<4-4*(1&P);else if(2==v)for(P=0;P<T;P++)O[x+(P>>2)]|=i[e+P]<<6-2*(3&P);else if(1==v)for(P=0;P<T;P++)O[x+(P>>3)]|=i[e+P]<<7-1*(7&P)}t=O,m=3,r=1}else if(0==C&&1==_.length){O=new Uint8Array(T*e*3);const i=T*e;for(x=0;x<i;x++){const e=3*x,n=4*x;O[e]=t[n],O[e+1]=t[n+1],O[e+2]=t[n+2]}t=O,m=2,r=3,n=3*T}I.img=t,I.bpl=n,I.bpp=r}return{ctype:m,depth:v,plte:k,frames:_}}function d(t,n,r,i,o,a,s){const l=Uint8Array,c=Uint32Array,u=new l(t[o-1]),d=new c(t[o-1]),f=o+1<t.length?new l(t[o+1]):null,p=new l(t[o]),g=new c(p.buffer);let m=n,v=r,y=-1,b=-1;for(let e=0;e<a.height;e++)for(let t=0;t<a.width;t++){const r=a.x+t,s=a.y+e,l=s*n+r,c=g[l];0==c||0==i[o-1].dispose&&d[l]==c&&(null==f||0!=f[4*l+3])||(r<m&&(m=r),r>y&&(y=r),s<v&&(v=s),s>b&&(b=s))}-1==y&&(m=v=y=b=0),s&&(!(1&~m)&&m--,!(1&~v)&&v--),a={x:m,y:v,width:y-m+1,height:b-v+1};const w=i[o];w.rect=a,w.blend=1,w.img=new Uint8Array(a.width*a.height*4),0==i[o-1].dispose?(e(u,n,r,w.img,a.width,a.height,-a.x,-a.y,0),h(p,n,r,w.img,a)):e(p,n,r,w.img,a.width,a.height,-a.x,-a.y,0)}function h(t,n,r,i,o){e(t,n,r,i,o.width,o.height,-o.x,-o.y,2)}function f(e,t,n,r,i,o,a){const s=[];let l,c=[0,1,2,3,4];-1!=o?c=[o]:(t*r>5e5||1==n)&&(c=[0]),a&&(l={level:0});const u=Qo;for(var d=0;d<c.length;d++){for(let o=0;o<t;o++)p(i,e,o,r,n,c[d]);s.push(u.deflate(i,l))}let h,f=1e9;for(d=0;d<s.length;d++)s[d].length<f&&(h=d,f=s[d].length);return s[h]}function p(e,t,r,i,o,a){const s=r*i;let l=s+r;if(e[l]=a,l++,0==a)if(i<500)for(var c=0;c<i;c++)e[l+c]=t[s+c];else e.set(new Uint8Array(t.buffer,s,i),l);else if(1==a){for(c=0;c<o;c++)e[l+c]=t[s+c];for(c=o;c<i;c++)e[l+c]=t[s+c]-t[s+c-o]+256&255}else if(0==r){for(c=0;c<o;c++)e[l+c]=t[s+c];if(2==a)for(c=o;c<i;c++)e[l+c]=t[s+c];if(3==a)for(c=o;c<i;c++)e[l+c]=t[s+c]-(t[s+c-o]>>1)+256&255;if(4==a)for(c=o;c<i;c++)e[l+c]=t[s+c]-n(t[s+c-o],0,0)+256&255}else{if(2==a)for(c=0;c<i;c++)e[l+c]=t[s+c]+256-t[s+c-i]&255;if(3==a){for(c=0;c<o;c++)e[l+c]=t[s+c]+256-(t[s+c-i]>>1)&255;for(c=o;c<i;c++)e[l+c]=t[s+c]+256-(t[s+c-i]+t[s+c-o]>>1)&255}if(4==a){for(c=0;c<o;c++)e[l+c]=t[s+c]+256-n(0,t[s+c-i],0)&255;for(c=o;c<i;c++)e[l+c]=t[s+c]+256-n(t[s+c-o],t[s+c-i],t[s+c-o-i])&255}}}function g(e,t){const n=new Uint8Array(e),r=n.slice(0),i=new Uint32Array(r.buffer),o=m(r,t),a=o[0],s=o[1],l=n.length,c=new Uint8Array(l>>2);let u;if(n.length<2e7)for(var d=0;d<l;d+=4)u=v(a,h=n[d]*(1/255),f=n[d+1]*(1/255),p=n[d+2]*(1/255),g=n[d+3]*(1/255)),c[d>>2]=u.ind,i[d>>2]=u.est.rgba;else for(d=0;d<l;d+=4){var h=n[d]*(1/255),f=n[d+1]*(1/255),p=n[d+2]*(1/255),g=n[d+3]*(1/255);for(u=a;u.left;)u=y(u.est,h,f,p,g)<=0?u.left:u.right;c[d>>2]=u.ind,i[d>>2]=u.est.rgba}return{abuf:r.buffer,inds:c,plte:s}}function m(e,t,n){null==n&&(n=1e-4);const r=new Uint32Array(e.buffer),i={i0:0,i1:e.length,bst:null,est:null,tdst:0,left:null,right:null};i.bst=x(e,i.i0,i.i1),i.est=C(i.bst);const o=[i];for(;o.length<t;){let t=0,i=0;for(var a=0;a<o.length;a++)o[a].est.L>t&&(t=o[a].est.L,i=a);if(t<n)break;const s=o[i],l=b(e,r,s.i0,s.i1,s.est.e,s.est.eMq255);if(s.i0>=l||s.i1<=l){s.est.L=0;continue}const c={i0:s.i0,i1:l,bst:null,est:null,tdst:0,left:null,right:null};c.bst=x(e,c.i0,c.i1),c.est=C(c.bst);const u={i0:l,i1:s.i1,bst:null,est:null,tdst:0,left:null,right:null};for(u.bst={R:[],m:[],N:s.bst.N-c.bst.N},a=0;a<16;a++)u.bst.R[a]=s.bst.R[a]-c.bst.R[a];for(a=0;a<4;a++)u.bst.m[a]=s.bst.m[a]-c.bst.m[a];u.est=C(u.bst),s.left=c,s.right=u,o[i]=c,o.push(u)}for(o.sort((e,t)=>t.bst.N-e.bst.N),a=0;a<o.length;a++)o[a].ind=a;return[i,o]}function v(e,t,n,r,i){if(null==e.left)return e.tdst=function(e,t,n,r,i){const o=t-e[0],a=n-e[1],s=r-e[2],l=i-e[3];return o*o+a*a+s*s+l*l}(e.est.q,t,n,r,i),e;const o=y(e.est,t,n,r,i);let a=e.left,s=e.right;o>0&&(a=e.right,s=e.left);const l=v(a,t,n,r,i);if(l.tdst<=o*o)return l;const c=v(s,t,n,r,i);return c.tdst<l.tdst?c:l}function y(e,t,n,r,i){const{e:o}=e;return o[0]*t+o[1]*n+o[2]*r+o[3]*i-e.eMq}function b(e,t,n,r,i,o){for(r-=4;n<r;){for(;w(e,n,i)<=o;)n+=4;for(;w(e,r,i)>o;)r-=4;if(n>=r)break;const a=t[n>>2];t[n>>2]=t[r>>2],t[r>>2]=a,n+=4,r-=4}for(;w(e,n,i)>o;)n-=4;return n+4}function w(e,t,n){return e[t]*n[0]+e[t+1]*n[1]+e[t+2]*n[2]+e[t+3]*n[3]}function x(e,t,n){const r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i=[0,0,0,0],o=n-t>>2;for(let o=t;o<n;o+=4){const t=e[o]*(1/255),n=e[o+1]*(1/255),a=e[o+2]*(1/255),s=e[o+3]*(1/255);i[0]+=t,i[1]+=n,i[2]+=a,i[3]+=s,r[0]+=t*t,r[1]+=t*n,r[2]+=t*a,r[3]+=t*s,r[5]+=n*n,r[6]+=n*a,r[7]+=n*s,r[10]+=a*a,r[11]+=a*s,r[15]+=s*s}return r[4]=r[1],r[8]=r[2],r[9]=r[6],r[12]=r[3],r[13]=r[7],r[14]=r[11],{R:r,m:i,N:o}}function C(e){const{R:t}=e,{m:n}=e,{N:r}=e,i=n[0],o=n[1],a=n[2],s=n[3],l=0==r?0:1/r,c=[t[0]-i*i*l,t[1]-i*o*l,t[2]-i*a*l,t[3]-i*s*l,t[4]-o*i*l,t[5]-o*o*l,t[6]-o*a*l,t[7]-o*s*l,t[8]-a*i*l,t[9]-a*o*l,t[10]-a*a*l,t[11]-a*s*l,t[12]-s*i*l,t[13]-s*o*l,t[14]-s*a*l,t[15]-s*s*l],u=c,d=_;let h=[Math.random(),Math.random(),Math.random(),Math.random()],f=0,p=0;if(0!=r)for(let e=0;e<16&&(h=d.multVec(u,h),p=Math.sqrt(d.dot(h,h)),h=d.sml(1/p,h),!(0!=e&&Math.abs(p-f)<1e-9));e++)f=p;const g=[i*l,o*l,a*l,s*l];return{Cov:c,q:g,e:h,L:f,eMq255:d.dot(d.sml(255,g),h),eMq:d.dot(h,g),rgba:(Math.round(255*g[3])<<24|Math.round(255*g[2])<<16|Math.round(255*g[1])<<8|Math.round(255*g[0]))>>>0}}var _={multVec:(e,t)=>[e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],e[4]*t[0]+e[5]*t[1]+e[6]*t[2]+e[7]*t[3],e[8]*t[0]+e[9]*t[1]+e[10]*t[2]+e[11]*t[3],e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]*t[3]],dot:(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],sml:(e,t)=>[e*t[0],e*t[1],e*t[2],e*t[3]]};ea.encode=function(e,t,n,r,i,o,a){null==r&&(r=0),null==a&&(a=!1);const s=u(e,t,n,r,[!1,!1,!1,0,a,!1]);return c(s,-1),l(s,t,n,i,o)},ea.encodeLL=function(e,t,n,r,i,o,a,s){const u={ctype:0+(1==r?0:2)+(0==i?0:4),depth:o,frames:[]},d=(r+i)*o,h=d*t;for(let r=0;r<e.length;r++)u.frames.push({rect:{x:0,y:0,width:t,height:n},img:new Uint8Array(e[r]),blend:0,dispose:1,bpp:Math.ceil(d/8),bpl:Math.ceil(h/8)});return c(u,0,!0),l(u,t,n,a,s)},ea.encode.compress=u,ea.encode.dither=s,ea.quantize=g,ea.quantize.getKDtree=m,ea.quantize.getNearest=v}();const ta={toArrayBuffer(e,t){const n=e.width,r=e.height,i=n<<2,o=e.getContext("2d").getImageData(0,0,n,r),a=new Uint32Array(o.data.buffer),s=(32*n+31)/32<<2,l=s*r,c=122+l,u=new ArrayBuffer(c),d=new DataView(u),h=1<<20;let f,p,g,m,v=h,y=0,b=0,w=0;function x(e){d.setUint16(b,e,!0),b+=2}function C(e){d.setUint32(b,e,!0),b+=4}function _(e){b+=e}x(19778),C(c),_(4),C(122),C(108),C(n),C(-r>>>0),x(1),x(32),C(3),C(l),C(2835),C(2835),_(8),C(16711680),C(65280),C(255),C(4278190080),C(1466527264),function e(){for(;y<r&&v>0;){for(m=122+y*s,f=0;f<i;)v--,p=a[w++],g=p>>>24,d.setUint32(m+f,p<<8|g),f+=4;y++}w<a.length?(v=h,setTimeout(e,ta._dly)):t(u)}()},toBlob(e,t){this.toArrayBuffer(e,e=>{t(new Blob([e],{type:"image/bmp"}))})},_dly:9};var na={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},ra={[na.CHROME]:16384,[na.FIREFOX]:11180,[na.DESKTOP_SAFARI]:16384,[na.IE]:8192,[na.IOS]:4096,[na.ETC]:8192};const ia="undefined"!=typeof window,oa="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,aa=ia&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),sa=(ia||oa)&&(aa&&aa.getOriginalSymbol(window,"File")||"undefined"!=typeof File&&File),la=(ia||oa)&&(aa&&aa.getOriginalSymbol(window,"FileReader")||"undefined"!=typeof FileReader&&FileReader);function ca(e,t,n=Date.now()){return new Promise(r=>{const i=e.split(","),o=i[0].match(/:(.*?);/)[1],a=globalThis.atob(i[1]);let s=a.length;const l=new Uint8Array(s);for(;s--;)l[s]=a.charCodeAt(s);const c=new Blob([l],{type:o});c.name=t,c.lastModified=n,r(c)})}function ua(e){return new Promise((t,n)=>{const r=new la;r.onload=()=>t(r.result),r.onerror=e=>n(e),r.readAsDataURL(e)})}function da(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=e=>n(e),r.src=e})}function ha(){if(void 0!==ha.cachedResult)return ha.cachedResult;let e=na.ETC;const{userAgent:t}=navigator;return/Chrom(e|ium)/i.test(t)?e=na.CHROME:/iP(ad|od|hone)/i.test(t)&&/WebKit/i.test(t)?e=na.IOS:/Safari/i.test(t)?e=na.DESKTOP_SAFARI:/Firefox/i.test(t)?e=na.FIREFOX:(/MSIE/i.test(t)||1==!!document.documentMode)&&(e=na.IE),ha.cachedResult=e,ha.cachedResult}function fa(e,t){const n=ha(),r=ra[n];let i=e,o=t,a=i*o;const s=i>o?o/i:i/o;for(;a>r*r;){const e=(r+i)/2,t=(r+o)/2;e<t?(o=t,i=t*s):(o=e*s,i=e),a=i*o}return{width:i,height:o}}function pa(e,t){let n,r;try{if(n=new OffscreenCanvas(e,t),r=n.getContext("2d"),null===r)throw new Error("getContext of OffscreenCanvas returns null")}catch(e){n=document.createElement("canvas"),r=n.getContext("2d")}return n.width=e,n.height=t,[n,r]}function ga(e,t){const{width:n,height:r}=fa(e.width,e.height),[i,o]=pa(n,r);return t&&/jpe?g/.test(t)&&(o.fillStyle="white",o.fillRect(0,0,i.width,i.height)),o.drawImage(e,0,0,i.width,i.height),i}function ma(){return void 0!==ma.cachedResult||(ma.cachedResult=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"undefined"!=typeof document&&"ontouchend"in document),ma.cachedResult}function va(e,t={}){return new Promise(function(n,r){let i,o;var a=function(){try{return o=ga(i,t.fileType||e.type),n([i,o])}catch(e){return r(e)}},s=function(t){try{var n=function(e){try{throw e}catch(e){return r(e)}};try{let t;return ua(e).then(function(e){try{return t=e,da(t).then(function(e){try{return i=e,function(){try{return a()}catch(e){return r(e)}}()}catch(e){return n(e)}},n)}catch(e){return n(e)}},n)}catch(e){n(e)}}catch(e){return r(e)}};try{if(ma()||[na.DESKTOP_SAFARI,na.MOBILE_SAFARI].includes(ha()))throw new Error("Skip createImageBitmap on IOS and Safari");return createImageBitmap(e).then(function(e){try{return i=e,a()}catch(e){return s()}},s)}catch(e){s()}})}function ya(e,t,n,r,i=1){return new Promise(function(o,a){let s;if("image/png"===t){let c,u,d;return c=e.getContext("2d"),({data:u}=c.getImageData(0,0,e.width,e.height)),d=ea.encode([u.buffer],e.width,e.height,4096*i),s=new Blob([d],{type:t}),s.name=n,s.lastModified=r,l.call(this)}{if("image/bmp"===t)return new Promise(t=>ta.toBlob(e,t)).then(function(e){try{return s=e,s.name=n,s.lastModified=r,h.call(this)}catch(e){return a(e)}}.bind(this),a);{if("function"==typeof OffscreenCanvas&&e instanceof OffscreenCanvas)return e.convertToBlob({type:t,quality:i}).then(function(e){try{return s=e,s.name=n,s.lastModified=r,f.call(this)}catch(e){return a(e)}}.bind(this),a);{let p;return p=e.toDataURL(t,i),ca(p,n,r).then(function(e){try{return s=e,f.call(this)}catch(e){return a(e)}}.bind(this),a)}function f(){return h.call(this)}}function h(){return l.call(this)}}function l(){return o(s)}})}function ba(e){e.width=0,e.height=0}function wa(){return new Promise(function(e,t){let n,r,i,o;return void 0!==wa.cachedResult?e(wa.cachedResult):ca("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then(function(a){try{return n=a,va(n).then(function(a){try{return r=a[1],ya(r,n.type,n.name,n.lastModified).then(function(n){try{return i=n,ba(r),va(i).then(function(n){try{return o=n[0],wa.cachedResult=1===o.width&&2===o.height,e(wa.cachedResult)}catch(e){return t(e)}},t)}catch(e){return t(e)}},t)}catch(e){return t(e)}},t)}catch(e){return t(e)}},t)})}function xa(e){return new Promise((t,n)=>{const r=new la;r.onload=e=>{const n=new DataView(e.target.result);if(65496!=n.getUint16(0,!1))return t(-2);const r=n.byteLength;let i=2;for(;i<r;){if(n.getUint16(i+2,!1)<=8)return t(-1);const e=n.getUint16(i,!1);if(i+=2,65505==e){if(1165519206!=n.getUint32(i+=2,!1))return t(-1);const e=18761==n.getUint16(i+=6,!1);i+=n.getUint32(i+4,e);const r=n.getUint16(i,e);i+=2;for(let o=0;o<r;o++)if(274==n.getUint16(i+12*o,e))return t(n.getUint16(i+12*o+8,e))}else{if(65280&~e)break;i+=n.getUint16(i,!1)}}return t(-1)},r.onerror=e=>n(e),r.readAsArrayBuffer(e)})}function Ca(e,t){const{width:n}=e,{height:r}=e,{maxWidthOrHeight:i}=t;let o,a=e;return isFinite(i)&&(n>i||r>i)&&([a,o]=pa(n,r),n>r?(a.width=i,a.height=r/n*i):(a.width=n/r*i,a.height=i),o.drawImage(e,0,0,a.width,a.height),ba(e)),a}function _a(e,t){const{width:n}=e,{height:r}=e,[i,o]=pa(n,r);switch(t>4&&t<9?(i.width=r,i.height=n):(i.width=n,i.height=r),t){case 2:o.transform(-1,0,0,1,n,0);break;case 3:o.transform(-1,0,0,-1,n,r);break;case 4:o.transform(1,0,0,-1,0,r);break;case 5:o.transform(0,1,1,0,0,0);break;case 6:o.transform(0,1,-1,0,r,0);break;case 7:o.transform(0,-1,-1,0,r,n);break;case 8:o.transform(0,-1,1,0,0,n)}return o.drawImage(e,0,0,n,r),ba(e),i}function Sa(e,t,n=0){return new Promise(function(r,i){let o,a,s,l,c,u,d,h,f,p,g,m,v,y,b,w,x,C,_,S;function k(e=5){if(t.signal&&t.signal.aborted)throw t.signal.reason;o+=e,t.onProgress(Math.min(o,100))}function A(e){if(t.signal&&t.signal.aborted)throw t.signal.reason;o=Math.min(Math.max(e,o),100),t.onProgress(o)}return o=n,a=t.maxIteration||10,s=1024*t.maxSizeMB*1024,k(),va(e,t).then(function(n){try{return[,l]=n,k(),c=Ca(l,t),k(),new Promise(function(n,r){var i;if(!(i=t.exifOrientation))return xa(e).then(function(e){try{return i=e,o.call(this)}catch(e){return r(e)}}.bind(this),r);function o(){return n(i)}return o.call(this)}).then(function(n){try{return u=n,k(),wa().then(function(n){try{return d=n?c:_a(c,u),k(),h=t.initialQuality||1,f=t.fileType||e.type,ya(d,f,e.name,e.lastModified,h).then(function(n){try{{if(p=n,k(),g=p.size>s,m=p.size>e.size,!g&&!m)return A(100),r(p);var o;function u(){if(a--&&(b>s||b>v)){let t,n;return t=S?.95*_.width:_.width,n=S?.95*_.height:_.height,[x,C]=pa(t,n),C.drawImage(_,0,0,t,n),h*="image/png"===f?.85:.95,ya(x,f,e.name,e.lastModified,h).then(function(e){try{return w=e,ba(_),_=x,b=w.size,A(Math.min(99,Math.floor((y-b)/(y-s)*100))),u}catch(e){return i(e)}},i)}return[1]}return v=e.size,y=p.size,b=y,_=d,S=!t.alwaysKeepResolution&&g,(o=function(e){for(;e;){if(e.then)return void e.then(o,i);try{if(e.pop){if(e.length)return e.pop()?E.call(this):e;e=u}else e=e.call(this)}catch(e){return i(e)}}}.bind(this))(u);function E(){return ba(_),ba(x),ba(c),ba(d),ba(l),A(100),r(w)}}}catch(I){return i(I)}}.bind(this),i)}catch(e){return i(e)}}.bind(this),i)}catch(e){return i(e)}}.bind(this),i)}catch(e){return i(e)}}.bind(this),i)})}let ka;function Aa(e,t){return new Promise((n,r)=>{ka||(ka=function(e){const t=[];return t.push(e),URL.createObjectURL(new Blob(t))}("\nlet scriptImported = false\nself.addEventListener('message', async (e) => {\n const { file, id, imageCompressionLibUrl, options } = e.data\n options.onProgress = (progress) => self.postMessage({ progress, id })\n try {\n if (!scriptImported) {\n // console.log('[worker] importScripts', imageCompressionLibUrl)\n self.importScripts(imageCompressionLibUrl)\n scriptImported = true\n }\n // console.log('[worker] self', self)\n const compressedFile = await imageCompression(file, options)\n self.postMessage({ file: compressedFile, id })\n } catch (e) {\n // console.error('[worker] error', e)\n self.postMessage({ error: e.message + '\\n' + e.stack, id })\n }\n})\n"));const i=new Worker(ka);i.addEventListener("message",function(e){if(t.signal&&t.signal.aborted)i.terminate();else if(void 0===e.data.progress){if(e.data.error)return r(new Error(e.data.error)),void i.terminate();n(e.data.file),i.terminate()}else t.onProgress(e.data.progress)}),i.addEventListener("error",r),t.signal&&t.signal.addEventListener("abort",()=>{r(t.signal.reason),i.terminate()}),i.postMessage({file:e,imageCompressionLibUrl:t.libURL,options:{...t,onProgress:void 0,signal:void 0}})})}function Ea(e,t){return new Promise(function(n,r){let i,o,a,s,l,c;if(i={...t},a=0,({onProgress:s}=i),i.maxSizeMB=i.maxSizeMB||Number.POSITIVE_INFINITY,l="boolean"!=typeof i.useWebWorker||i.useWebWorker,delete i.useWebWorker,i.onProgress=e=>{a=e,"function"==typeof s&&s(a)},!(e instanceof Blob||e instanceof sa))return r(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(e.type))return r(new Error("The file given is not an image"));if(c="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,!l||"function"!=typeof Worker||c)return Sa(e,i).then(function(e){try{return o=e,h.call(this)}catch(e){return r(e)}}.bind(this),r);var u=function(){try{return h.call(this)}catch(e){return r(e)}}.bind(this),d=function(t){try{return Sa(e,i).then(function(e){try{return o=e,u()}catch(e){return r(e)}},r)}catch(e){return r(e)}};try{return i.libURL=i.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",Aa(e,i).then(function(e){try{return o=e,u()}catch(e){return d()}},d)}catch(e){d()}function h(){try{o.name=e.name,o.lastModified=e.lastModified}catch(e){}try{i.preserveExif&&"image/jpeg"===e.type&&(!i.fileType||i.fileType&&i.fileType===e.type)&&(o=Xo(e,o))}catch(e){}return n(o)}})}function Ia(e,t){var n;if(null==e?void 0:e.extension){const t=e.extension.toLowerCase(),n={jpg:{extension:"jpeg",mimeType:"image/jpeg",format:"jpeg",pixieFormat:"jpeg"},jpeg:{extension:"jpeg",mimeType:"image/jpeg",format:"jpeg",pixieFormat:"jpeg"},png:{extension:"png",mimeType:"image/png",format:"png",pixieFormat:"png"},gif:{extension:"gif",mimeType:"image/gif",format:"gif",pixieFormat:"png"},webp:{extension:"webp",mimeType:"image/webp",format:"webp",pixieFormat:"png"},svg:{extension:"svg",mimeType:"image/svg+xml",format:"svg",pixieFormat:"svg"}};if(n[t])return n[t]}if(null==e?void 0:e.type){const t=Tn(e.type),n={"image/jpeg":{extension:"jpeg",mimeType:"image/jpeg",format:"jpeg",pixieFormat:"jpeg"},"image/png":{extension:"png",mimeType:"image/png",format:"png",pixieFormat:"png"},"image/gif":{extension:"gif",mimeType:"image/gif",format:"gif",pixieFormat:"png"},"image/webp":{extension:"webp",mimeType:"image/webp",format:"webp",pixieFormat:"png"},"image/svg+xml":{extension:"svg",mimeType:"image/svg+xml",format:"svg",pixieFormat:"svg"}};if(n[t])return n[t]}if(null==e?void 0:e.name){const t=null===(n=e.name.split(".").pop())||void 0===n?void 0:n.toLowerCase();if(t){const e={jpg:{extension:"jpeg",mimeType:"image/jpeg",format:"jpeg",pixieFormat:"jpeg"},jpeg:{extension:"jpeg",mimeType:"image/jpeg",format:"jpeg",pixieFormat:"jpeg"},png:{extension:"png",mimeType:"image/png",format:"png",pixieFormat:"png"},gif:{extension:"gif",mimeType:"image/gif",format:"gif",pixieFormat:"png"},webp:{extension:"webp",mimeType:"image/webp",format:"webp",pixieFormat:"png"},svg:{extension:"svg",mimeType:"image/svg+xml",format:"svg",pixieFormat:"svg"}};if(e[t])return e[t]}}if(t){const e=Tn(t),n=Pn(e);let r="jpeg";return"png"===n?r="png":"svg"===n?r="svg":"jpeg"===n&&(r="jpeg"),{extension:n,mimeType:e,format:n,pixieFormat:r}}return{extension:"jpeg",mimeType:"image/jpeg",format:"jpeg",pixieFormat:"jpeg"}}Ea.getDataUrlFromFile=ua,Ea.getFilefromDataUrl=ca,Ea.loadImage=da,Ea.drawImageInCanvas=ga,Ea.drawFileInCanvas=va,Ea.canvasToFile=ya,Ea.getExifOrientation=xa,Ea.handleMaxWidthOrHeight=Ca,Ea.followExifOrientation=_a,Ea.cleanupCanvasMemory=ba,Ea.isAutoOrientationInBrowser=wa,Ea.approximateBelowMaximumCanvasSizeOfBrowser=fa,Ea.copyExifWithoutOrientation=Xo,Ea.getBrowserName=ha,Ea.version="2.0.2";const Ta={MAX_SIZE_MB:.48,MAX_WIDTH_OR_HEIGHT:2e3,QUALITY:.8},Fa=["gif","svg"];function Oa(e,t,n,r){return new File([e],t,{type:n,lastModified:r})}function Pa(e,t){return t&&t!==e.name?Oa(e,t,e.type,e.lastModified):e}async function Ma(e,t={}){const{maxSizeMB:n=Ta.MAX_SIZE_MB,maxWidthOrHeight:r=Ta.MAX_WIDTH_OR_HEIGHT,mimeType:i,fileName:o,libURL:a,enableCompression:s=!0}=t;if(!(e&&e instanceof File))return e;const l=Tn(e.type||i||"image/jpeg");if(!l.startsWith("image/"))return Pa(e,o);const c="image/webp"===(u=l)?"image/jpeg":u;var u;const d=Pn(l),h=Pn(c),f=c!==l?function(e,t){const n=t.startsWith(".")?t.slice(1):t,r=e.lastIndexOf(".");return r>0?`${e.substring(0,r)}.${n}`:`${e}.${n}`}(null!=o?o:e.name,h):null!=o?o:e.name,p=s&&(g=d,!Fa.includes(g));var g;if(!p&&!(c!==l))return Pa(e,f);try{const t={libURL:a,useWebWorker:!0,fileType:c};p?(t.maxSizeMB=n,t.maxWidthOrHeight=r):(t.maxSizeMB=Math.max(e.size/1048576+1,1),t.initialQuality=1,t.alwaysKeepResolution=!0);const i=await Ea(e,t);return function(e,t,n,r){const i=null!=r?r:t.name;return e instanceof File?e.type!==n||e.lastModified!==t.lastModified||e.name!==i?Oa(e,i,n,t.lastModified):e:Oa(e,i,n,t.lastModified)}(i,e,Tn(i.type||c),f)}catch(t){console.error("prepareImageForUpload failed",t);try{return Pa(e,f)}catch(t){return console.error("Failed to create File with normalized name after image preparation error",t),e}}}const Ra=/^(utm_[a-z0-9_]+|fbclid|gclid|igshid|mc_cid|mc_eid)$/i;function La(e){const t=new URL(e.trim());t.hash="",t.hostname=t.hostname.toLowerCase(),("https:"===t.protocol&&"443"===t.port||"http:"===t.protocol&&"80"===t.port)&&(t.port="");const n=Array.from(t.searchParams.entries()).filter(([e])=>!Ra.test(e)).sort(([e,t],[n,r])=>{const i=e.localeCompare(n);return 0!==i?i:t.localeCompare(r)});return t.search="",n.forEach(([e,n])=>t.searchParams.append(e,n)),t.toString()}function Na(e){return!!(null==e?void 0:e.startsWith("image/"))&&"image/gif"!==e}function Da(e,t){if(t===e.name)return e;try{return new File([e],t,{type:e.type,lastModified:e.lastModified})}catch(t){return console.warn("Failed to create normalized File:",t),e}}async function ja(e){const t=await fetch(e,{mode:"cors"});if(!t.ok)throw new $o(`HTTP ${t.status}`,"UploadUrlDownloadFailed",t.status);return t.blob()}const za=()=>{var e,t,n,r,o,a,s;const{state:l,actions:u,options:d}=ro(),h=yo(),{sortBy:f,sortOrder:p}=h.state,{actions:{fetchFolders:g}}=Ho(),{t:m}=Qn(),v=bo(),{deleteItems:y}=Wo(),{selectedFolder:b,urlForm:w,pagination:x,files:C,pathHistory:_}=l,S=i.useRef(null),k=i.useRef([]);S.current=x,k.current=Array.isArray(C)?C:[];const{setFiles:A,setLoading:E,setIsUrlModalVisible:I,setActiveLibraryItem:T,setPagination:F,setSelectedFolder:O,setPathHistory:P}=u,{dataProviders:M}=d,R=c(async e=>{var t,n,r;if(!(null==M?void 0:M.getFiles))return[];const i=null===(t=null==d?void 0:d.config)||void 0===t?void 0:t.disablePagination,{files:o,pagination:a}=await M.getFiles({folderId:"folders"!==(null==e?void 0:e.folderId)?null==e?void 0:e.folderId:void 0,noFolder:null==e?void 0:e.noFolder,search:(null===(n=null==e?void 0:e.search)||void 0===n?void 0:n.trim())||void 0,sortBy:null==e?void 0:e.sortBy,sortOrder:null==e?void 0:e.sortOrder,page:i||null==e?void 0:e.page,limit:i||null==e?void 0:e.limit,itemType:(null==e?void 0:e.itemType)||"all"});return F&&((null===(r=null==d?void 0:d.config)||void 0===r?void 0:r.disablePagination)?F({current:1,pageSize:o.length||1,total:o.length||0}):a&&F({current:a.page,pageSize:a.limit,total:a.total})),o},[M,null===(e=null==d?void 0:d.config)||void 0===e?void 0:e.disablePagination,F]),L=c(async(e,t,n)=>{var r,i,o;if(!(!1===(null===(r=null==d?void 0:d.config)||void 0===r?void 0:r.paginationAvailable)||!1===(null===(i=null==d?void 0:d.config)||void 0===i?void 0:i.hasPagination)||!0===(null===(o=null==d?void 0:d.config)||void 0===o?void 0:o.disablePagination))||!(null==M?void 0:M.getFiles))return e;try{let r=[];const{files:i}=await M.getFiles({folderId:n?void 0:t||void 0,noFolder:n,itemType:"all",page:1,limit:1e4});if(r=(i||[]).map(e=>e.name).filter(e=>!!e),!n&&(null==M?void 0:M.getFolders)){const e=(await M.getFolders({parentId:null!=t?t:null,deep:!1})||[]).map(e=>e.name).filter(e=>!!e);r=[...r,...e]}return _o(e,r)}catch(t){return console.warn("Could not fetch files for duplicate check:",t),e}},[M,null===(t=null==d?void 0:d.config)||void 0===t?void 0:t.disablePagination,null===(n=null==d?void 0:d.config)||void 0===n?void 0:n.hasPagination,null===(r=null==d?void 0:d.config)||void 0===r?void 0:r.paginationAvailable]),N=c(async(e,t=!1)=>{var n;try{null==E||E(!0);let t=[];if(!(null==M?void 0:M.getFiles))return void console.error("DataProvider for getting files is not defined");t=await R(e);const n=null!=e?e:{folderId:b||"",itemType:"all"};"file"!==n.itemType&&(t=await vo(t,n,null==M?void 0:M.getFolders)),"Trash"!==(b||"")&&(t=t.filter(e=>!(e.isFolder&&"Trash"===e.id))),null==A||A(t)}catch(r){if("StaleLoad"===(null==r?void 0:r.name))return;const i=Io(r),o=404===(null==i?void 0:i.status)||"FileNotFound"===(null==i?void 0:i.code)||"path_folder_not_found"===(null==i?void 0:i.code);if(o||console.error("Error loading files:",r),!t&&o){const t=Lo(r,_||[]);try{return await No({options:d,pathFolder:t,dataProviders:null==d?void 0:d.dataProviders}),void await N(e,!0)}catch(e){console.error("Cache clear failed:",e)}}if(o&&O&&P){const t=Array.isArray(_)?_:[];if(t.length>1){const r=t.slice(0,-1),i=r[r.length-1],o=null!==(n=null==i?void 0:i.id)&&void 0!==n?n:"folders";return P(r),O(o),await g(),v.success({id:"FOLDER_NOT_FOUND_NAVIGATE",message:m("Folder not found"),description:m("Navigated to parent folder"),placement:"bottomRight"}),void await N(Object.assign(Object.assign({},e),{folderId:o}),!1)}return P([{id:"folders",name:m("Folders")}]),O("folders"),await g(),v.success({id:"FOLDER_NOT_FOUND_NAVIGATE",message:m("Folder not found"),description:m("Navigated to root folder"),placement:"bottomRight"}),void await N(Object.assign(Object.assign({},e),{folderId:"folders"}),!1)}const a=Ao(null==i?void 0:i.code,m);v.error({id:"FILES_FETCH_FAILED",message:null!=a?a:m("Failed to load files"),placement:"bottomRight",innerException:r,data:{params:e}})}finally{null==E||E(!1)}},[M,A,E,O,P,R,g,b,v,m,_,d]),D=c(e=>N(e),[N]),j=c(async(e,t)=>{var n;if(!(null==M?void 0:M.findFileByUrl))return null;const r=La(e);try{return null!==(n=await M.findFileByUrl(r))&&void 0!==n?n:null}catch(e){return console.warn("findFileByUrl failed, falling back to direct loading",e),null}},[M]),z=c(async(e,t)=>{var n,r,i,o;Yo(e,m);const a=La(e),s=await j(a,t);if(s)return{kind:"existing",file:s,normalizedUrl:a};let l,c;const u=null===(n=null==d?void 0:d.config)||void 0===n?void 0:n.handleFileProxy,h=null===(r=null==d?void 0:d.config)||void 0===r?void 0:r.handleProxyUrl;if(u)try{l=await Promise.resolve(u(a))}catch(e){c=e,console.warn("handleFileProxy failed, falling back to fetch",e)}if(!l&&h)try{const e=await Promise.resolve(h(a));l=await ja(e)}catch(e){c=e,console.warn("handleProxyUrl fetch failed, falling back to direct fetch",e)}if(!l)try{l=await ja(a)}catch(e){c=e}if(!(l instanceof Blob)||0===l.size)throw c instanceof Error?c:new $o(m("Failed to load file through proxy."),"FileProxyFailed");const f=(null===(o=null===(i=l.type)||void 0===i?void 0:i.split(";")[0])||void 0===o?void 0:o.trim())||"image/png";if(!f.startsWith("image/"))throw new $o(m("Content type at the URL is not allowed."),"UploadUrlContentTypeNotAllowed");const p=Pn(f),g=function(e){try{const t=new URL(e).pathname.split("/").pop();return t?decodeURIComponent(t):void 0}catch(e){return}}(a)||"uploaded-file",v=g.replace(/\.[^.]+$/,"")||"uploaded-file";return{kind:"blob",blob:l,normalizedUrl:a,mimeType:f,extension:p,fileName:Uo(g.includes(".")?g:`${v}.${p}`,null==d?void 0:d.config)}},[j,null==d?void 0:d.config,m]),B=c(async(e,t)=>{var n,r;Yo(e,m);const i=La(e);try{const e=await z(i,t);if("existing"===e.kind)return e.file;const n=await(s=e.blob,new Promise((e,t)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>{var e;return t(null!==(e=n.error)&&void 0!==e?e:new Error("Failed to read proxied file"))},n.readAsDataURL(s)}));return{thumbnail:n,name:e.fileName,type:e.mimeType,extension:e.extension,size:e.blob.size,sourceUrl:e.normalizedUrl,saveWithoutFolder:!0}}catch(e){const s=Io(e),l=(o=null==s?void 0:s.code,a="UploadUrlDownloadFailed","string"==typeof o?o:a),c=e instanceof $o?e:new $o(null!==(r=null!==(n=Ao(l,m))&&void 0!==n?n:null==s?void 0:s.message)&&void 0!==r?r:m("Failed to load file through proxy."),l,null==s?void 0:s.status);throw c.notificationShown=!0,await v.error({id:"EDITOR_PROXY_FILE_FAILED",message:c.message,placement:"bottomRight",data:{url:i,folderId:b||null,error:s,eventSource:"pixie"},innerException:e},t),c}var o,a,s},[j,v,null==d?void 0:d.config,b,m]),U=c(async e=>{const t=S.current;try{const n=k.current.find(t=>t.id===e),r=e=>{if(!e)return;const t=C.find(t=>t.id===e);return null==t?void 0:t.name};await y({items:[{id:e,isFolder:null==n?void 0:n.isFolder}],selectedFolder:b,getItemNameById:r,showNotifications:!0});const i=Object.assign({},t);let o=t.current;1===C.length&&(o=i.current>1?i.current-1:1),await D({folderId:b||"",page:o,limit:t.pageSize,sortBy:f,sortOrder:p})}catch(t){console.error("ОError when deleting a file:",t);const n=t;(null==n?void 0:n.notificationShown)||v.error({id:"FILES_DELETE_ERROR",message:m("Error when deleting a file"),placement:"bottomRight",innerException:t,data:{failCount:1,totalCount:1,itemIds:[e],folderId:b||null,errors:[{itemId:e,error:Io(t)}]}})}},[y,D,b,m,v,C,f,p]),V=c(async e=>{try{const t=S.current;if(!(null==M?void 0:M.deleteFolder))return void v.error({id:"FOLDER_DELETE_ERROR",message:m("DataProvider for folder deletion is not configured"),placement:"bottomRight",data:{totalCount:1,failCount:1,itemIds:[e],folderId:e}});if(!await M.deleteFolder(e)){const e=new Error("Не удалось удалить папку");throw e.notificationShown=!1,e}v.success({id:"FOLDER_DELETE_SUCCESS",message:m("Folder deleted"),placement:"bottomRight",data:{successCount:1,totalCount:1,itemIds:[e],folderId:e}});b===e?await D({page:t.current,limit:t.pageSize,sortBy:f,sortOrder:p}):await D({folderId:b||"",sortBy:f,sortOrder:p,page:t.current,limit:t.pageSize})}catch(t){console.error("Error when deleting a folder:",t);const n=t;(null==n?void 0:n.notificationShown)||v.error({id:"FOLDER_DELETE_ERROR",message:m("Error when deleting a folder"),innerException:t,placement:"bottomRight",data:{totalCount:1,failCount:1,itemIds:[e],folderId:e,errors:[{itemId:e,error:Io(t)}]}})}},[M,b,v,m,D,f,p]),H=c(async(e,t)=>{var n,r;try{if(null==M?void 0:M.getFileData){const t=await M.getFileData(e);if(t)return t;throw new Error(m("Failed to download file"))}{const t=await fetch(`/api/files/${e}/content`);if(!t.ok)throw new Error(m("Error loading image"));return await t.blob()}}catch(i){console.error("Error when loading a file:",i);const o=k.current.find(t=>t.id===e);t||v.error({id:"FILE_DOWNLOAD_FAILED",message:m("Failed to download file"),placement:"bottomRight",description:(null==o?void 0:o.name)||e,innerException:i,data:{itemId:e,itemName:(null==o?void 0:o.name)||e,folderId:null!==(n=null==o?void 0:o.folderId)&&void 0!==n?n:null,thumbnail:null!==(r=null==o?void 0:o.thumbnail)&&void 0!==r?r:null}},t)}},[M,v,m]),W=c(async(e,t,n,r)=>{var i,o,a,s,c,u,h,f,p,g,y,w,x,C,_,S,k;if("Trash"===(r?"":null!=t?t:b||""))throw new Error(m("Upload to Trash is forbidden"));const A=Uo(e.name,null==d?void 0:d.config),E=A.split(".").pop()||"",I=r?"":null!=t?t:b||"";let F=e;try{if(null===(o=null===(i=e.type)||void 0===i?void 0:i.startsWith)||void 0===o?void 0:o.call(i,"image/")){const t=null!==(s=null===(a=null==d?void 0:d.config)||void 0===a?void 0:a.compressMaxSize)&&void 0!==s?s:Ta.MAX_SIZE_MB,n=null!==(u=null===(c=null==d?void 0:d.config)||void 0===c?void 0:c.compressMaxWidthOrHeight)&&void 0!==u?u:2e3,r=null!==(f=null===(h=null==d?void 0:d.config)||void 0===h?void 0:h.compessorUrl)&&void 0!==f?f:null===(p=null==d?void 0:d.config)||void 0===p?void 0:p.compressorUrl;F=await Ma(e,{maxSizeMB:t,maxWidthOrHeight:n,mimeType:e.type,fileName:A,libURL:r,enableCompression:Na(e.type)})}else F=Da(e,A)}catch(t){console.warn("Image preparation failed, uploading original file",t),F=Da(e,A)}let O=F.name;const P=!1===(null===(g=null==d?void 0:d.config)||void 0===g?void 0:g.hasPagination)||!0===(null===(y=null==d?void 0:d.config)||void 0===y?void 0:y.disablePagination);P&&(O=await L(O,I,r)),P&&(F=Da(F,O));try{if(null==M?void 0:M.uploadFiles)try{const t=await M.uploadFiles({items:[{name:O,size:F.size,type:F.type||e.type,folderId:I,data:F,extension:E,noFolder:r}],folderId:I});if(t.success&&t.detailed&&t.detailed.length>0){const i=t.detailed[0];if(!i.success||!i.data){if(!n){const e=(null==i?void 0:i.error)?String(i.error):m("Failed to upload file");v.error({id:"FILE_UPLOAD_ITEM_FAILED",message:e,placement:"bottomRight",description:A,innerException:null==i?void 0:i.error,data:{itemName:A,folderId:I||null,eventSource:"upload"}})}return void(T&&T(rn))}{const t=i.data;if(t.id){const n=(null!==(w=t.folderId)&&void 0!==w?w:I)||void 0;await D({folderId:n,noFolder:r});let i=l.files.find(e=>e.id===t.id);if(!i)try{i=(await R({folderId:n,noFolder:r,itemType:"file"})).find(e=>e.id===t.id)}catch(e){console.warn("uploadFileWithProvider: не удалось получить свежий список файлов",e)}return T&&T(rn),i||Object.assign(Object.assign({},t),{id:t.id,name:t.name||A,folderId:null!==(C=null!==(x=t.folderId)&&void 0!==x?x:I)&&void 0!==C?C:null,type:F.type||e.type,size:F.size,extension:E||A.split(".").pop()||"",thumbnail:null!==(_=t.thumbnail)&&void 0!==_?_:void 0,url:null!==(S=t.url)&&void 0!==S?S:void 0,thumbnailUrl:null!==(k=t.thumbnailUrl)&&void 0!==k?k:void 0,isFolder:!1,selected:!1})}}}else if(!t.success){if(!n){const e=t.error?String(t.error):m("Failed to upload file");v.error({id:"FILE_UPLOAD_ITEM_FAILED",message:e,placement:"bottomRight",description:A,innerException:t.error,data:{itemName:A,folderId:I||null,eventSource:"upload"}})}return void(T&&T(rn))}return void(T&&T(rn))}catch(e){throw e}if(null==M?void 0:M.uploadFile){const t=await M.uploadFile({name:O,size:F.size,type:F.type||e.type,folderId:I,noFolder:r,data:F,extension:E});return T&&T(rn),t}return void(n||v.error({id:"FILES_UPLOAD_PROVIDER_NOT_CONFIGURED",message:m("DataProvider for file upload is not configured"),placement:"bottomRight"}))}catch(e){const t=Io(e),r=Ao(null==t?void 0:t.code,m);return n?void 0:void v.error({id:"FILE_UPLOAD_ITEM_FAILED",message:null!=r?r:m("Failed to upload file"),placement:"bottomRight",description:A,innerException:e,data:{itemName:A,folderId:I||null,error:Io(e),eventSource:"upload"}})}},[M,b,T,l.files,D,R,v,m,null==d?void 0:d.config]),$=c(async(e,t)=>{var n;if(!(null==M?void 0:M.getFolders)||!(null==M?void 0:M.createFolder))return e||"";try{const r=await M.getFolders(),i=Array.isArray(r)?r:[],o=(e,t)=>i.find(n=>{var r;return(null!==(r=n.parentId)&&void 0!==r?r:null)===(null!=e?e:null)&&n.name===t});let a=null!=e?e:"";for(const e of t){if(!e)continue;let t=o(a,e);if(!t){const n=await M.createFolder({name:e,parentId:null!=a?a:null});i.push(n),t=n}a=t.id}return null!==(n=a)&&void 0!==n?n:e||""}catch(t){return console.warn("ensureFolderPath: unable to guarantee the path",t),e||""}},[M]),G=c(async(e,t)=>{var n,r,i,o;if(!(null===(r=null===(n=e.type)||void 0===n?void 0:n.startsWith)||void 0===r?void 0:r.call(n,"image/")))return null!=t?t:null;const a=null==e?void 0:e.webkitRelativePath;let s=t||"";if(a&&a.includes("/")){const e=a.split("/");e.pop();const n=e.filter(Boolean);n.length&&(s=await $(t||"",n)||t||"")}return null!==(o=null!==(i=s)&&void 0!==i?i:t)&&void 0!==o?o:null},[$]);c(async e=>{var t,n,r,i,o,a,s,l,c,u,d,h;const{file:f,selectedFolderId:p,uploadFn:g,progressCallbacks:m}=e;if(!(null===(n=null===(t=f.type)||void 0===t?void 0:t.startsWith)||void 0===n?void 0:n.call(t,"image/")))return{success:!0,fileName:f.name,folderId:null!=p?p:null};const v=null!==(i=null!==(r=await G(f,p))&&void 0!==r?r:p)&&void 0!==i?i:null,y=null!==(o=null!=v?v:p)&&void 0!==o?o:null;let b;null===(a=null==m?void 0:m.onStart)||void 0===a||a.call(m,f);try{if(null==m?void 0:m.onProgress){let e=0;b=window.setInterval(()=>{var t;e=Math.min(e+10+Math.floor(Date.now()%10),90),null===(t=null==m?void 0:m.onProgress)||void 0===t||t.call(m,f.name,e)},200)}const e=await g(f,null!=y?y:void 0);return(null==m?void 0:m.onProgress)&&(null===(s=null==m?void 0:m.onProgress)||void 0===s||s.call(m,f.name,100)),null===(l=null==m?void 0:m.onComplete)||void 0===l||l.call(m,f.name),{success:!0,fileName:f.name,fileId:null==e?void 0:e.id,folderId:null!==(u=null!==(c=null==e?void 0:e.folderId)&&void 0!==c?c:y)&&void 0!==u?u:null}}catch(e){const t=e instanceof Error?e.message:String(e);return null===(d=null==m?void 0:m.onError)||void 0===d||d.call(m,f.name,t),{success:!1,fileName:f.name,folderId:null!==(h=null!=y?y:p)&&void 0!==h?h:null,error:t}}finally{void 0!==b&&clearInterval(b)}},[G]);const q=c(async(e,t)=>{var n,r,i,o,a,s,l,c,u,h,f,p,g,y,w,x,C,_,S,k,A,E,I,F,O,P,R,L,N,D,j,z,B,U,V,H,W,$,q,Y;if(0===e.length)return{successCount:0,failCount:0,successes:[],errors:[],totalCount:0};null===(n=null==t?void 0:t.onStartBatch)||void 0===n||n.call(t,e);const X=e=>{const t=e.filter(Boolean);return t.length>0&&t.length<=5?t.join(", "):null},K=[];for(let n=0;n<e.length;n++){const w=e[n];if(!(null===(i=null===(r=w.type)||void 0===r?void 0:r.startsWith)||void 0===i?void 0:i.call(r,"image/"))){const e=await v.warning({id:"FILES_UPLOAD_UNSUPPORTED_TYPE",message:m("Unsupported file type"),placement:"bottomRight",data:{itemName:w.name,fileType:w.type,folderId:b||null}});null===(o=null==t?void 0:t.onError)||void 0===o||o.call(t,w.name,e.message);continue}const x=Uo(w.name,null==d?void 0:d.config);let C=w;try{if(null===(s=null===(a=w.type)||void 0===a?void 0:a.startsWith)||void 0===s?void 0:s.call(a,"image/")){const e=null!==(c=null===(l=null==d?void 0:d.config)||void 0===l?void 0:l.compressMaxSize)&&void 0!==c?c:Ta.MAX_SIZE_MB,t=null!==(h=null===(u=null==d?void 0:d.config)||void 0===u?void 0:u.compressMaxWidthOrHeight)&&void 0!==h?h:2e3,n=null!==(p=null===(f=null==d?void 0:d.config)||void 0===f?void 0:f.compessorUrl)&&void 0!==p?p:null===(g=null==d?void 0:d.config)||void 0===g?void 0:g.compressorUrl;C=await Ma(w,{maxSizeMB:e,maxWidthOrHeight:t,mimeType:w.type,fileName:x,libURL:n,enableCompression:Na(w.type)})}else C=Da(w,x)}catch(e){console.warn("Image preparation failed, uploading original file",e),C=Da(w,x)}const _=`${Date.now()}-${n}-${Math.random().toString(36).slice(2,8)}`,S=await G(C,b);null===(y=null==t?void 0:t.onStart)||void 0===y||y.call(t,C),K.push({file:C,targetFolderId:S,requestId:_,originalFileName:w.name,originalIndex:n})}const Z=K.length;if(0===Z)return{successCount:0,failCount:0,successes:[],errors:[],totalCount:0};const J=!1===(null===(w=null==d?void 0:d.config)||void 0===w?void 0:w.hasPagination)||!0===(null===(x=null==d?void 0:d.config)||void 0===x?void 0:x.disablePagination),Q=new Map;if(J&&(null==M?void 0:M.getFiles)){const e=[...new Set(K.map(e=>{var t,n;return null!==(n=null!==(t=e.targetFolderId)&&void 0!==t?t:b)&&void 0!==n?n:""}).filter(Boolean))];for(const t of e)try{const{files:e}=await M.getFiles({folderId:t||void 0,itemType:"file",page:1,limit:1e4});Q.set(t,(e||[]).map(e=>e.name))}catch(e){console.warn("Could not fetch files for duplicate check:",e)}}const ee=new Map,te=!t,ne=1===Z&&te,re=[],ie=[],oe=[],ae=[],se=new Map;let le=0,ce=0;const ue=null!==(_=null===(C=null==d?void 0:d.config)||void 0===C?void 0:C.maxFileSize)&&void 0!==_?_:52428800,de=async(e,n,r,i)=>{var o,a;const{emitProgress:s=!0,emitNotification:l=!0}=null!=i?i:{};le++,re.push(e),ie.push(null!=r?r:e),await((e,t,n,r)=>{var i;return v.success({id:"FILE_UPLOAD_ITEM_SUCCESS",message:`${m("File")} ${e} ${m("has been successfully uploaded")}`,placement:"bottomRight",data:{itemId:n,itemName:e,folderId:null!==(i=null!=t?t:b)&&void 0!==i?i:null,eventSource:"upload"}},r||!te)})(e,n,r,!l),s&&(null===(o=null==t?void 0:t.onProgress)||void 0===o||o.call(t,e,100),null===(a=null==t?void 0:t.onComplete)||void 0===a||a.call(t,e))},he=async(e,n,r,i)=>{var o;const{emitProgress:a=!0,emitNotification:s=!0,fileSize:l,progressCallbackName:c,progressCallbackIndex:u}=null!=i?i:{};ce++;const d=null!=l?{fileSize:l,maxSize:ue}:void 0,h=await((e,t,n,r,i)=>{var o,a,s,l,c,u,d;const h=Io(n),f=null!==(o=null==i?void 0:i.fileSize)&&void 0!==o?o:null==h?void 0:h.fileSize,p=null!==(s=null!==(a=null==i?void 0:i.maxSize)&&void 0!==a?a:null==h?void 0:h.maxSize)&&void 0!==s?s:ue,g={allowedChars:"a-z A-Z 0-9 . _ -",fileSize:null!=f?wo(Number(f)):void 0,maxSize:null!=p?wo(Number(p)):void 0},y=null==h?void 0:h.code,w="BatchItemLimitExceeded"===y||"exceeded_max_files"===y?y:null!==(l=Eo(null==h?void 0:h.message))&&void 0!==l?l:y,x="BatchItemLimitExceeded"===w||"exceeded_max_files"===w?To(n,m):Ao(w,m,g),C=(null==h?void 0:h.message)&&"string"==typeof h.message&&h.message.length>0?h.message:null,_=n instanceof Error?n.message:"string"==typeof n?n:null,S=_&&"[object Object]"!==_?_:null;return v.error({id:"FILE_UPLOAD_ITEM_FAILED",message:null!==(u=null!==(c=null!=C?C:x)&&void 0!==c?c:S)&&void 0!==u?u:m("Error uploading file {{fileName}}",{fileName:e}),placement:"bottomRight",data:{itemName:e,folderId:null!==(d=null!=t?t:b)&&void 0!==d?d:null,error:Io(n),eventSource:"upload"},innerException:n},r||!te)})(e,n,r,!s,d);a&&(null===(o=null==t?void 0:t.onError)||void 0===o||o.call(t,null!=c?c:e,h.message,u)),ae.push({itemId:void 0,itemName:e,error:Io(r)}),oe.push({fileName:e,error:h.message})};if(!(null==M?void 0:M.uploadFiles))return v.error({id:"FILES_UPLOAD_PROVIDER_NOT_CONFIGURED",message:m("DataProvider for file upload is not configured"),placement:"bottomRight"}),{successCount:0,failCount:Z,successes:[],errors:[],totalCount:Z};{const e=[];try{(null==t?void 0:t.onProgress)&&K.forEach(n=>{let r=0;const i=window.setInterval(()=>{var e;r=Math.min(r+10+Math.floor(Date.now()%10),90),null===(e=null==t?void 0:t.onProgress)||void 0===e||e.call(t,n.file.name,r)},200);e.push(i)});let n=await M.uploadFiles({items:K.map(e=>{var t,n;const r=J?((e,t)=>{const n=null!=e?e:"";let r=Q.get(n)||[],i=ee.get(n);i||(i=new Set(r.map(e=>e.toLowerCase())),ee.set(n,i));const o=_o(t,Array.from(i));return i.add(o.toLowerCase()),o})(e.targetFolderId,e.file.name):e.file.name,i=J?Da(e.file,r):e.file;return{requestId:e.requestId,name:r,size:i.size,type:i.type,folderId:null!==(n=null!==(t=e.targetFolderId)&&void 0!==t?t:b)&&void 0!==n?n:null,data:i,extension:i.name.split(".").pop()||""}}),folderId:null!=b?b:null});e.forEach(e=>window.clearInterval(e)),e.length=0;const r=null!==(S=n.detailed)&&void 0!==S?S:[],i=new Map(r.filter(e=>e.requestId).map(e=>[e.requestId,e]));if(r.length>0)for(let e=0;e<K.length;e++){const t=K[e],n=null!==(k=t.requestId?i.get(t.requestId):void 0)&&void 0!==k?k:r[e];if(n&&n.success){const e=n.data,r=null!==(A=null==e?void 0:e.name)&&void 0!==A?A:Uo(t.file.name,null==d?void 0:d.config),i=null!==(F=null!==(I=null!==(E=null==e?void 0:e.folderId)&&void 0!==E?E:t.targetFolderId)&&void 0!==I?I:b)&&void 0!==F?F:null,o=null==e?void 0:e.id;se.set(r,{id:o,name:r,folderId:i,size:null==e?void 0:e.size,originalFileName:t.originalFileName,originalIndex:t.originalIndex}),await de(r,i,o,{emitNotification:ne})}else{const e=null==n?void 0:n.data,r=null!==(O=null==e?void 0:e.name)&&void 0!==O?O:Uo(t.file.name,null==d?void 0:d.config),i=null!==(L=null!==(R=null!==(P=null==e?void 0:e.folderId)&&void 0!==P?P:t.targetFolderId)&&void 0!==R?R:b)&&void 0!==L?L:null;await he(r,i,null!==(N=null==n?void 0:n.error)&&void 0!==N?N:new Error(m("Error uploading file")),{emitNotification:ne,fileSize:t.file.size,progressCallbackName:t.originalFileName,progressCallbackIndex:t.originalIndex})}}else if(n.success)for(const e of K){const t=Uo(e.file.name,null==d?void 0:d.config),n=null!==(j=null!==(D=e.targetFolderId)&&void 0!==D?D:b)&&void 0!==j?j:null;await de(t,n,void 0,{emitNotification:ne})}else{const e=null!==(z=n.error)&&void 0!==z?z:new Error(m("Error uploading file"));for(const t of K){const n=Uo(t.file.name,null==d?void 0:d.config),r=null!==(U=null!==(B=t.targetFolderId)&&void 0!==B?B:b)&&void 0!==U?U:null;await he(n,r,e,{emitNotification:ne,fileSize:t.file.size,progressCallbackName:t.originalFileName,progressCallbackIndex:t.originalIndex})}}}catch(e){for(const t of K){const n=Uo(t.file.name,null==d?void 0:d.config),r=null!==(H=null!==(V=t.targetFolderId)&&void 0!==V?V:b)&&void 0!==H?H:null;await he(n,r,null!=e?e:new Error(m("Error uploading file")),{emitNotification:ne,fileSize:t.file.size,progressCallbackName:t.originalFileName,progressCallbackIndex:t.originalIndex})}}finally{e.forEach(e=>window.clearInterval(e))}}if(le>0&&(T&&T(rn),Z>1&&te)){const e=X(re),t=e?m("Uploaded",{names:e}):m("uploads_success_summary",{successCount:le,totalCount:Z});v.success({id:"FILES_UPLOAD_BATCH_SUCCESS",message:t,placement:"bottomRight",data:{successCount:le,totalCount:Z,itemIds:ie,itemNames:re,folderId:null!=b?b:null,eventSource:"upload"}})}if(ce>0&&te&&!ne)if(Z>1){const e=oe.map(e=>e.fileName),t=X(e),n=t?m("Failed",{names:t}):m("uploads_fail_summary",{failCount:ce,totalCount:Z});v.error({id:"FILES_UPLOAD_BATCH_FAILED",message:n,placement:"bottomRight",data:{failCount:ce,totalCount:Z,itemNames:e,folderId:null!=b?b:null,errors:ae,eventSource:"upload"}})}else if(1===Z&&ae.length>0&&(null===(W=ae[0].error)||void 0===W?void 0:W.code)){const e=Ao(null===($=ae[0].error)||void 0===$?void 0:$.code,m),t=null!==(Y=null===(q=oe[0])||void 0===q?void 0:q.fileName)&&void 0!==Y?Y:"",n=null!=e?e:t?`${m("Failed to upload files")}: ${t}`:m("Failed to upload files");v.error({id:"FILES_UPLOAD_BATCH_FAILED",message:n,placement:"bottomRight",data:{failCount:ce,totalCount:Z,itemNames:[t],folderId:null!=b?b:null,errors:ae,eventSource:"upload"}})}return{successCount:le,failCount:ce,successes:re,errors:oe,totalCount:Z,uploadedFiles:se.size>0?se:void 0}},[M,null===(o=null==d?void 0:d.config)||void 0===o?void 0:o.hasPagination,null===(a=null==d?void 0:d.config)||void 0===a?void 0:a.disablePagination,v,G,b,T,m,null==d?void 0:d.config]),Y=c(async e=>{var t;if(!(null==M?void 0:M.uploadFiles))return void v.error({id:"FILES_UPLOAD_PROVIDER_NOT_CONFIGURED",message:m("DataProvider for file upload is not configured"),placement:"bottomRight"});if("Trash"===b)return void v.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:m("Cannot upload files to Trash"),placement:"bottomRight",data:{folderId:b||null,reason:"Upload to Trash is not allowed"}});const n=S.current,r=document.createElement("input");r.type="file",r.accept="image/*",r.multiple=!0;try{!(!(null===(t=null==d?void 0:d.config)||void 0===t?void 0:t.features)||!d.config.features.enableDirectoryUpload)&&(r.webkitdirectory=!0)}catch(e){}r.onchange=async t=>{var r;const i=t.target.files;if(!i||0===i.length)return;const o=Array.from(i);try{null==E||E(!0);const{successes:t,errors:i,uploadedFiles:a}=await q(o,e);null===(r=null==e?void 0:e.onBatchComplete)||void 0===r||r.call(e,{files:o,successes:t,errors:i,uploadedFiles:a}),await g(),await D({folderId:b||"",sortBy:f,sortOrder:p,page:n.current,limit:n.pageSize})}catch(e){console.error("Error when loading files:",e)}finally{null==E||E(!1)}},r.click()},[null==M?void 0:M.uploadFiles,b,v,m,E,D,g,f,p,q,null===(s=null==d?void 0:d.config)||void 0===s?void 0:s.features]),X=c(async(e,t,n,r="uploadByUrl")=>{const i=S.current;let o,a=null!=e?e:null;try{if(!t&&"Trash"===b)throw n||v.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:m("Cannot upload files to Trash"),placement:"bottomRight",data:{folderId:b||null,reason:"Upload to Trash is not allowed"}}),new $o(m("Cannot upload files to Trash"),"UploadUrlDownloadFailed");let e,s;if(!a&&w&&(e=await w.validateFields(),a=null==e?void 0:e.fileUrl),!a)throw n||v.error({id:"FILES_UPLOAD_URL_VALIDATION_FAILED",message:m("Please fill in all fields"),placement:"bottomRight",data:{url:null!=a?a:null,folderId:b||null,eventSource:r}}),new $o(m("Please fill in all fields"),"UploadUrlInvalid");if(Yo(a,m),a=La(a),null==E||E(!0),a){const e=a.split("?")[0].split("#")[0].split("/");s=e[e.length-1]||"uploaded-file",s=Uo(s,null==d?void 0:d.config)}const l=t?"":b||"",c=Boolean((null==M?void 0:M.uploadFiles)||(null==M?void 0:M.uploadFile)),u=Boolean(null==M?void 0:M.uploadFileByUrl);let h=s;h&&u&&(h=await L(h,l,t));try{const e=await z(a,n);if("existing"===e.kind)o=e.file;else if(c){const n=new File([e.blob],e.fileName,{type:e.mimeType,lastModified:Date.now()});try{o=await W(n,l,!0,t)}catch(e){throw e.uploadUrlStage="binaryUpload",e}if(!o){const e=new $o(m("Failed to upload file"),"FileUploadBackendError");throw e.uploadUrlStage="binaryUpload",e}}else{if(!u)throw n||v.error({id:"FILES_UPLOAD_URL_NOT_SUPPORTED",message:m("Upload by URL is not supported"),placement:"bottomRight",data:{url:a,folderId:b||null,eventSource:r}}),new $o(m("Upload by URL is not supported"),"UploadUrlDownloadFailed");o=await M.uploadFileByUrl({url:a,folderId:b||"",noFolder:t,name:h,eventSource:r})}}catch(e){const n=e;if("binaryUpload"===(null==n?void 0:n.uploadUrlStage)||!u)throw e;console.warn("Failed to fetch file by URL locally, falling back to uploadByUrl",e),o=await M.uploadFileByUrl({url:a,folderId:b||"",noFolder:t,name:h,eventSource:r})}const g=(null==e?void 0:e.name)||(null==o?void 0:o.name)||"unnamed file";return o&&v.success({id:"FILE_UPLOAD_ITEM_SUCCESS",message:`${m("File")} ${g} ${m("successfully uploaded")}`,placement:"bottomRight",data:{itemName:g,itemId:null==o?void 0:o.id,folderId:b||null,eventSource:r}},n),e&&(null==I||I(!1),null==w||w.resetFields()),T&&T(rn),await D({folderId:b||"",noFolder:t,sortBy:f,sortOrder:p,page:i.current,limit:i.pageSize}),o}catch(e){if(console.error("Error when loading a file by URL:",e),!n){const t=Io(e),n=t,i=e,o=Number(null==n?void 0:n.fileSize),s=Number(null==n?void 0:n.maxSize),l=Number.isFinite(o)&&Number.isFinite(s)?{fileSize:o,maxSize:s}:void 0,c="binaryUpload"===(null==i?void 0:i.uploadUrlStage)?To(t,m,l):Po(t,m);v.error({id:"FILES_UPLOAD_BY_URL_FAILED",message:c,placement:"bottomRight",data:{url:null!=a?a:null,folderId:b||null,error:t,eventSource:r},innerException:e})}throw e}finally{null==E||E(!1)}},[w,E,M,v,m,I,T,D,b,f,p,L,z,W,null==d?void 0:d.config]),K=c(async e=>{if(!e.length)return;const t=S.current;"Trash"!==b?(await q(e),await D({folderId:b||"",sortBy:f,sortOrder:p,page:t.current,limit:t.pageSize})):v.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:m("Cannot upload files to Trash"),placement:"bottomRight",data:{folderId:b||null,reason:"Upload to Trash is not allowed"}})},[D,b,f,p,q,v,m]);return{fetchFiles:D,handleDeleteFile:U,handleDeleteFolder:V,handleAddFile:Y,handleAddFileByUrl:X,handleDroppedFiles:K,getFileData:H,findFileByUrl:j,resolveFileForEditByUrl:B,uploadFileWithProvider:W}},Ba=e=>{let t;const n=new Set,r=(e,r)=>{const i="function"==typeof e?e(t):e;if(!Object.is(i,t)){const e=t;t=(null!=r?r:"object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>a,subscribe:e=>(n.add(e),()=>n.delete(e))},a=t=e(r,i,o);return o},Ua=e=>e;const Va=e=>{const t=(e=>e?Ba(e):Ba)(e),n=e=>function(e,t=Ua){const n=i.useSyncExternalStore(e.subscribe,i.useCallback(()=>t(e.getState()),[e,t]),i.useCallback(()=>t(e.getInitialState()),[e,t]));return i.useDebugValue(n),n}(t,e);return Object.assign(n,t),n};function Ha(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const Wa=($a=e=>({selectedFiles:new Set,visibleFileIds:[],anchorId:null,multiSelect:!0,setMultiSelect:t=>{e(e=>{var n;if(e.multiSelect===t)return e;if(t)return{multiSelect:!0};const r=null!==(n=Array.from(e.selectedFiles)[0])&&void 0!==n?n:null;return{multiSelect:!1,selectedFiles:r?new Set([r]):new Set,anchorId:r}})},syncVisibleFiles:t=>{const n=Array.isArray(t)?t.map(e=>e.id):[];e(e=>{const t=new Set(n),r=new Set(Array.from(e.selectedFiles).filter(e=>t.has(e))),i=e.anchorId&&t.has(e.anchorId)?e.anchorId:null,o=function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}(e.visibleFileIds,n),a=Ha(e.selectedFiles,r),s=e.anchorId===i;return o&&a&&s?e:{visibleFileIds:n,selectedFiles:r,anchorId:i}})},setSelectedFiles:t=>{e(e=>{var n;const r=new Set(e.visibleFileIds),i=new Set(Array.from(t).filter(e=>r.has(e)));return Ha(e.selectedFiles,i)?e:{selectedFiles:i,anchorId:null!==(n=Array.from(i)[0])&&void 0!==n?n:null}})},clearSelection:()=>{e(e=>0===e.selectedFiles.size&&null===e.anchorId?e:{selectedFiles:new Set,anchorId:null})},selectAllVisible:()=>{e(e=>{var t;const n=new Set(e.visibleFileIds),r=null!==(t=e.visibleFileIds[0])&&void 0!==t?t:null;return Ha(e.selectedFiles,n)&&e.anchorId===r?e:{selectedFiles:n,anchorId:r}})},toggleFileSelection:(t,n)=>{e(e=>{const r=!1!==e.multiSelect,i=Boolean(null==n?void 0:n.shiftKey)&&r,o=Boolean(null==n?void 0:n.metaKey)||Boolean(null==n?void 0:n.ctrlKey)||Boolean(null==n?void 0:n.forceToggle),a=e.visibleFileIds,s=new Set(a);if(a.length>0&&!s.has(t))return e;if(!r){const n=new Set([t]);return Ha(e.selectedFiles,n)&&e.anchorId===t?e:{selectedFiles:n,anchorId:t}}if(i&&e.anchorId&&s.has(e.anchorId)){const n=a.indexOf(e.anchorId),r=a.indexOf(t);if(-1===n||-1===r)return e;const[i,s]=n<r?[n,r]:[r,n],l=a.slice(i,s+1),c=o?new Set(e.selectedFiles):new Set;return l.forEach(e=>{c.add(e)}),Ha(e.selectedFiles,c)?e:{selectedFiles:c}}if(i&&!e.anchorId){const n=new Set([t]);return Ha(e.selectedFiles,n)&&e.anchorId===t?e:{selectedFiles:n,anchorId:t}}if(o){const n=new Set(e.selectedFiles);return n.has(t)?n.delete(t):n.add(t),Ha(e.selectedFiles,n)&&e.anchorId===t?e:{selectedFiles:n,anchorId:t}}const l=new Set([t]);return Ha(e.selectedFiles,l)&&e.anchorId===t?e:{selectedFiles:l,anchorId:t}})}}),$a?Va($a):Va);var $a;const Ga=e=>{var t,n,r,i;const{state:o,actions:a,options:s}=ro(),{t:l}=Qn(),u=Ho(),d=bo(),{fetchFolders:h}=u.actions,{renameItem:f}=(()=>{const{options:e}=ro(),{dataProviders:t}=e,{t:n}=Qn(),r=c(async({itemId:r,newName:i,isFolder:o})=>{var a,s,l,c,u,d,h,f;try{if(o){if(!(null==t?void 0:t.renameFolder))throw new Error(n("renameFolder is not implemented in dataProviders"));const o=Vo(i.trim(),e.config),c=await t.renameFolder(r,o);return{success:!0,renamedItem:{id:c.id,name:null!==(a=c.name)&&void 0!==a?a:o,parentId:null!==(s=c.parentId)&&void 0!==s?s:null,folderId:null!==(l=c.parentId)&&void 0!==l?l:null}}}if(!(null==t?void 0:t.renameFile))throw new Error(n("renameFile is not implemented in dataProviders"));const p=Uo(i,e.config),g=await t.renameFile(r,p);return{success:!0,renamedItem:{id:null!==(c=null==g?void 0:g.id)&&void 0!==c?c:r,name:null!==(u=null==g?void 0:g.name)&&void 0!==u?u:p,folderId:null!==(d=null==g?void 0:g.folderId)&&void 0!==d?d:null,parentId:null!==(f=null!==(h=null==g?void 0:g.parentId)&&void 0!==h?h:null==g?void 0:g.folderId)&&void 0!==f?f:null}}}catch(e){return{success:!1,error:Io(e)}}},[t,n,e.config]);return{renameItem:r}})(),{files:p,selectedFolder:g,fileToRename:m,renameForm:v,isRenameModalVisible:y,pagination:b}=o,{setFileToRename:w,setIsRenameModalVisible:x}=a,{dataProviders:C,config:_}=s,S=e=>{var t,n;if(!e)return null;const r=e;return null!==(n=null!==(t=r.folderId)&&void 0!==t?t:r.parentId)&&void 0!==n?n:null},k=(e,t)=>{var n;return{itemId:null!==(n=null==e?void 0:e.id)&&void 0!==n?n:t,itemName:null==e?void 0:e.name,folderId:S(e)}},A=c(e=>{var t,n;const r=null==p?void 0:p.find(t=>t.id===e);if((null==r?void 0:r.isFolder)||e.startsWith("folder_")){if(!(!1!==(null===(t=null==_?void 0:_.features)||void 0===t?void 0:t.enableRenameFolder)))return void d.error({id:"FOLDER_RENAME_DISABLED_BY_CONFIG",message:l("Folder rename is disabled by config"),placement:"bottomRight",data:k(r,e)});if(!(null==C?void 0:C.renameFolder))throw new Error(l("renameFolder is not implemented in dataProviders"))}else{if(!(!1!==(null===(n=null==_?void 0:_.features)||void 0===n?void 0:n.enableRenameFile)))return void d.error({id:"FILE_RENAME_DISABLED_BY_CONFIG",message:l("File rename is disabled by config"),placement:"bottomRight",data:k(r,e)});if(!(null==C?void 0:C.renameFile))throw new Error(l("renameFile is not implemented in dataProviders"))}null==w||w(e),null==x||x(!0),r&&v&&v.setFieldsValue({newFileName:r.name})},[p,w,x,v,null===(t=null==_?void 0:_.features)||void 0===t?void 0:t.enableRenameFolder,null===(n=null==_?void 0:_.features)||void 0===n?void 0:n.enableRenameFile,null==C?void 0:C.renameFolder,null==C?void 0:C.renameFile,d,l]),E=c(()=>{null==x||x(!1),null==w||w(null),null==v||v.resetFields()},[x,w,v]),I=c(async()=>{var t,n,r,i,o,s,c,u,y,w,x,C;if(!m||!v)return;const S=null==p?void 0:p.find(e=>e.id===m);try{const p=await v.validateFields();if(!(null==p?void 0:p.newFileName))return;const A=(null==S?void 0:S.isFolder)||m.startsWith("folder_");if(A){if(!(!1!==(null===(t=null==_?void 0:_.features)||void 0===t?void 0:t.enableRenameFolder)))return void d.error({id:"FOLDER_RENAME_DISABLED_BY_CONFIG",message:l("Folder rename is disabled by config"),placement:"bottomRight",data:k(S,m)})}else{if(!(!1!==(null===(n=null==_?void 0:_.features)||void 0===n?void 0:n.enableRenameFile)))return void d.error({id:"FILE_RENAME_DISABLED_BY_CONFIG",message:l("File rename is disabled by config"),placement:"bottomRight",data:k(S,m)})}const I=await f({itemId:m,newName:p.newFileName,isFolder:A});if(!I.success){const e=Ao(null===(r=I.error)||void 0===r?void 0:r.code,l);return void d.error({id:"ITEM_RENAME_FAILED",message:null!==(o=null!=e?e:null===(i=I.error)||void 0===i?void 0:i.message)&&void 0!==o?o:l("Error renaming"),placement:"bottomRight",data:Object.assign(Object.assign({},k(S,m)),{error:I.error}),innerException:I.error})}const T=I.renamedItem;A?(d.success({id:"FOLDER_RENAME_SUCCESS",message:l(`${l("Folder renamed to")} ${null!==(s=null==T?void 0:T.name)&&void 0!==s?s:p.newFileName}`),placement:"bottomRight",data:{itemId:null!==(c=null==T?void 0:T.id)&&void 0!==c?c:m,itemName:null!==(u=null==T?void 0:T.name)&&void 0!==u?u:p.newFileName,folderId:null!==(w=null!==(y=null==T?void 0:T.parentId)&&void 0!==y?y:null==T?void 0:T.folderId)&&void 0!==w?w:null}}),await h(),(null==T?void 0:T.id)&&T.id!==m&&a.setSelectedFolder&&a.setSelectedFolder(T.id)):d.success({id:"FILE_RENAME_SUCCESS",message:`${l("File renamed to")} ${null!==(x=null==T?void 0:T.name)&&void 0!==x?x:p.newFileName}`,placement:"bottomRight",data:Object.assign(Object.assign({},k(S,m)),{itemName:null!==(C=null==T?void 0:T.name)&&void 0!==C?C:p.newFileName})}),E(),await e({folderId:g||"",page:b.current,limit:b.pageSize})}catch(e){console.error("Error when renaming:",e);const t=Io(e),n=Ao(null==t?void 0:t.code,l);d.error({id:"ITEM_RENAME_FAILED",message:null!=n?n:e instanceof Error?e.message:l("Error renaming"),placement:"bottomRight",data:Object.assign(Object.assign({},k(S,m)),{error:t}),innerException:e})}},[m,v,p,a,E,e,g,l,b,null===(r=null==_?void 0:_.features)||void 0===r?void 0:r.enableRenameFolder,null===(i=null==_?void 0:_.features)||void 0===i?void 0:i.enableRenameFile,d,h,f]);return{state:{isRenamingFile:y||!1,fileToRename:m},actions:{showRenameModal:A,handleRenameCancel:E,handleRenameOk:I}}},qa=e=>{const t=t=>{if(!t)return;const n=e.find(e=>e.id===t);return null==n?void 0:n.name};return{getItemNameById:t,getItemNamesByIds:e=>e.map(t).filter(e=>Boolean(e)),getNamesPreview:e=>e.length>0&&e.length<=5?e.join(", "):null}},Ya=(e,t,n,r,i)=>({itemIds:e,itemNames:i&&i.length?i:void 0,successCount:t,totalCount:n,folderId:null!=r?r:null}),Xa=(e,t,n,r,i,o)=>({itemIds:e,itemNames:o&&o.length?o:void 0,failCount:t,totalCount:n,folderId:null!=r?r:null,errors:i}),Ka=()=>{const e=bo(),{t:t}=Qn(),{actions:{fetchFolders:n,fetchChildFolders:r}}=Ho();return{refreshFolders:c(async({parentIds:i,selectedFolder:o})=>{try{if(await n(),i&&r)for(const e of i)e&&await r(e)}catch(n){console.error("Error when updating the folder tree:",n),e.error({id:"FILES_FETCH_FAILED",message:t("Failed to refresh folder tree"),placement:"bottomRight",innerException:n,data:{params:{folderId:o||void 0}}})}},[e,t]),refreshFiles:c(async({fetchFiles:n,selectedFolder:r,page:i,limit:o})=>{try{await n({folderId:r||"",page:i,limit:o})}catch(n){console.error("Ошибка при обновлении списка файлов:",n),e.error({id:"FILES_FETCH_FAILED",message:t("Failed to refresh file list"),placement:"bottomRight",innerException:n,data:{params:{folderId:r||void 0,page:i,limit:o}}})}},[e,t])}},Za=e=>{var t,n;const{state:r,actions:i,options:o}=ro(),{t:a}=Qn(),s=bo(),l=Wa(e=>e.selectedFiles),u=Wa(e=>e.clearSelection),{files:d,selectedFolder:h,moveForm:f,pagination:p,currentMenuFile:g}=r,{setIsMoveModalVisible:m,setPagination:v}=i,{dataProviders:y}=o,{moveItems:b}=(()=>{const{options:e}=ro(),{dataProviders:t}=e,{t:n}=Qn(),r=bo(),i=c(async({items:e,targetFolderId:i,getItemNameById:o,showNotifications:a=!1})=>{let s=0,l=0;const c=[];if(null==t?void 0:t.moveItems)try{const n=await t.moveItems("folders"===i?"":i,e.map(e=>e.id)),r=n.detailed;if(r){const e=r.filter(e=>e.success),t=r.filter(e=>!e.success);s+=e.length,l+=t.length,t.forEach(e=>{const t=(e=>{var t;return null!==(t=e.requestId)&&void 0!==t?t:e.id})(e),n=e.error,r=Io(n);c.push({itemId:t,itemName:o(t),error:r})})}else if(n.success)s+=e.length;else{const t=n.error;if(t){l+=e.length;const n=Io(t);c.push({error:n})}else l+=e.length}}catch(t){l+=e.length;const n=Io(t);c.push({error:n})}else l+=e.length,c.push({error:{message:"Move provider is not configured"}});return a&&(s>0&&r.success({id:"FILES_MOVE_SUCCESS",message:n("Files moved"),placement:"bottomRight",data:{successCount:s,totalCount:e.length,itemIds:e.map(e=>e.id),folderId:"folders"===i?null:i}}),l>0&&r.error({id:"FILES_MOVE_ERROR",message:n("Errors occurred while moving"),placement:"bottomRight",innerException:c.length?c:void 0,data:{failCount:l,totalCount:e.length,itemIds:e.map(e=>e.id),errors:c.length?c:void 0}})),{successCount:s,failCount:l,errorDetails:c}},[t,r,n]);return{moveItems:i}})(),{refreshFolders:w,refreshFiles:x}=Ka(),{getItemNameById:C,getItemNamesByIds:_,getNamesPreview:S}=qa(d),k=c(()=>{null==m||m(!0)},[m]),A=c(()=>{null==m||m(!1),null==f||f.resetFields()},[m,f]),E=c(async t=>{var n,r,i,c,m,k,E,I,T,F;if(!((null==g?void 0:g.length)||l&&0!==l.size))return;const O=d.length,P=Object.assign({},p),M=Array.from((null==g?void 0:g.length)?[g]:l),R=M.length;let L=0,N=0;const D=[],j=M.map(e=>d.find(t=>t.id===e)).filter(e=>Boolean(e)),z=j.some(e=>(null==e?void 0:e.isFolder)||e.id.startsWith("folder_"));try{let l=t;if(!t){const e=await f.validateFields();l=null==e?void 0:e.targetFolder}if(!l)return void s.error({id:"FILES_MOVE_DIRECTORY_NOT_SELECTED",message:a("Select destination folder"),placement:"bottomRight"});const d="folders"===l?null:l,p=null!=d?d:h,g=!1===(null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.paginationAvailable)||!1===(null===(r=null==o?void 0:o.config)||void 0===r?void 0:r.hasPagination)||!0===(null===(i=null==o?void 0:o.config)||void 0===i?void 0:i.disablePagination);if(g&&(null==y?void 0:y.getFolders))try{const e=await y.getFolders({parentId:d,deep:!1}),t=new Set((e||[]).map(e=>{var t;return null===(t=e.name)||void 0===t?void 0:t.toLowerCase()}).filter(Boolean));for(const e of j){if(!e.isFolder&&!(null===(m=(c=e.id).startsWith)||void 0===m?void 0:m.call(c,"folder_")))continue;const n=e.name||C(e.id)||"";if(n&&t.has(n.toLowerCase()))return void s.error({id:"FOLDER_ALREADY_EXISTS_MOVE",message:a("A folder with that name already exists. Please enter a different folder name."),placement:"bottomRight",data:{folderName:n,targetFolderId:l}})}}catch(e){console.warn("Could not check folder duplicates for move:",e)}if(g&&(null==y?void 0:y.getFiles)&&(null==y?void 0:y.renameFile))try{let e=[];if(null==y?void 0:y.getFiles){const{files:t}=await y.getFiles({folderId:d||void 0,itemType:"all",page:1,limit:1e4});e=(t||[]).map(e=>e.name).filter(e=>!!e)}if(null==y?void 0:y.getFolders){const t=(await y.getFolders({parentId:d,deep:!1})||[]).map(e=>e.name).filter(e=>!!e);e=[...e,...t]}const t=new Set(e.map(e=>null==e?void 0:e.toLowerCase()).filter(Boolean));for(const e of j){if(e.isFolder||(null===(E=(k=e.id).startsWith)||void 0===E?void 0:E.call(k,"folder_")))continue;const n=e.name||C(e.id)||"";if(!n||!t.has(n.toLowerCase())){t.add(n.toLowerCase());continue}const r=_o(n,Array.from(t));await y.renameFile(e.id,r),t.add(r.toLowerCase())}}catch(e){console.warn("Could not check duplicates for move:",e)}const B=await b({items:j,targetFolderId:l,getItemNameById:C,showNotifications:!1});if(L=B.successCount,N=B.failCount,D.push(...B.errorDetails),L>0){const e=_(M),t=S(e),n=t?a("Moved",{names:t}):a("move_success_summary",{successCount:L,totalCount:R});s.success({id:"FILES_MOVE_SUCCESS",message:n,placement:"bottomRight",data:Ya(M,L,R,d,e)})}if(N>0){const e=_(M),t=S(e);let n;if(1===R&&D.length>0&&(null===(I=D[0].error)||void 0===I?void 0:I.code)){const e=Ao(null===(T=D[0].error)||void 0===T?void 0:T.code,a);n=null!=e?e:t?a("Failed",{names:t}):a("move_fail_summary",{failCount:N,totalCount:R})}else n=t?a("Failed",{names:t}):a("move_fail_summary",{failCount:N,totalCount:R});s.error({id:"FILES_MOVE_ERROR",message:n,placement:"bottomRight",innerException:D.length?D:void 0,data:Xa(M,N,R,d,D.length?D:void 0,e)})}A(),u();let U=P.current;if(L>0&&O>0&&L>=O&&P.current>1&&(U=P.current-1),L>0&&P.total>=L){const e=Math.max(0,(null!==(F=P.total)&&void 0!==F?F:0)-L);null==v||v({current:U,pageSize:P.pageSize,total:e})}z&&await w({parentIds:void 0,selectedFolder:p}),await x({fetchFiles:e,selectedFolder:h,page:U,limit:P.pageSize})}catch(e){console.error("Error when moving:",e);const t=Ao(Io(e).code,a);s.error({id:"FILES_MOVE_ERROR",innerException:e,message:null!=t?t:a("Error moving"),placement:"bottomRight",data:Xa(M,R,R,h||null,[{error:Io(e)}],_(M))})}},[g,l,f,e,h,p,d,s,v,a,b,u,m,null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.hasPagination,null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.disablePagination,null==y?void 0:y.getFiles,null==y?void 0:y.renameFile,C]);return{actions:{showMoveModal:k,handleMoveCancel:A,handleMoveOk:E}}},Ja=e=>{var t,n;const{state:r,actions:i,options:o}=ro(),{t:a}=Qn(),s=bo(),l=Wa(e=>e.selectedFiles),u=Wa(e=>e.clearSelection),{files:d,selectedFolder:h,copyForm:f,pagination:p,currentMenuFile:g}=r,{setIsCopyModalVisible:m}=i,{dataProviders:v}=o,{copyItems:y}=(()=>{const{options:e}=ro(),{dataProviders:t}=e,{t:n}=Qn(),r=bo(),i=c(async({items:e,targetFolderId:i,getItemNameById:o,showNotifications:a=!1})=>{let s=0,l=0;const c=[],u="folders"===i?"":i;if(null==t?void 0:t.copyItems)try{const n=await t.copyItems(u,e.map(e=>({id:e.id,newName:e.newName}))),r=n.detailed;if(r){const e=r.filter(e=>e.success),t=r.filter(e=>!e.success);s+=e.length,l+=t.length,t.forEach(e=>{const t=(e=>{var t;return null!==(t=e.requestId)&&void 0!==t?t:e.id})(e),n=e.error,r=Io(n);c.push({itemId:t,itemName:o(t),error:r})})}else if(n.success)s+=e.length;else{const t=n.error;if(t){l+=e.length;const n=Io(t);c.push({error:n})}else l+=e.length}}catch(t){l+=e.length;const n=Io(t);c.push({error:n})}else if(null==t?void 0:t.copyItem)for(const n of e)try{const e=(null==n?void 0:n.isFolder)||n.id.startsWith("folder_");await t.copyItem({itemId:n.id,targetFolderId:u,isFolder:e,newName:n.newName})?s++:l++}catch(e){l++;const t=Io(e);c.push({itemId:n.id,itemName:o(n.id),error:t})}else l+=e.length,c.push({error:{message:"Copy provider is not configured"}});return a&&(s>0&&r.success({id:"FILES_COPY_SUCCESS",message:n("Files copied"),placement:"bottomRight",data:{successCount:s,totalCount:e.length,itemIds:e.map(e=>e.id),folderId:"folders"===i?null:i}}),l>0&&r.error({id:"FILES_COPY_ERROR",message:n("Errors occurred while copying"),placement:"bottomRight",innerException:c.length?c:void 0,data:{failCount:l,totalCount:e.length,itemIds:e.map(e=>e.id),errors:c.length?c:void 0}})),{successCount:s,failCount:l,errorDetails:c}},[t,r,n]);return{copyItems:i}})(),{refreshFolders:b,refreshFiles:w}=Ka(),{getItemNameById:x,getItemNamesByIds:C,getNamesPreview:_}=qa(d),S=c(()=>{null==m||m(!0)},[m]),k=c(()=>{null==m||m(!1),null==f||f.resetFields()},[m,f]),A=c(async t=>{var n,r,i,c,m,S,A;if(!((null==g?void 0:g.length)||l&&0!==l.size))return;const E=Array.from((null==g?void 0:g.length)?[g]:l),I=E.length;let T=0,F=0;const O=[],P=E.map(e=>d.find(t=>t.id===e)).filter(e=>Boolean(e)),M=P.some(e=>(null==e?void 0:e.isFolder)||e.id.startsWith("folder_"));try{let l=t;if(!t){const e=await f.validateFields();l=null==e?void 0:e.targetFolder}if(!l)return void s.error({id:"FILES_COPY_DIRECTORY_NOT_SELECTED",message:a("Select destination folder"),placement:"bottomRight"});const d="folders"===l?null:l,g=null!=d?d:h;let R=P.map(e=>({id:e.id,isFolder:(null==e?void 0:e.isFolder)||e.id.startsWith("folder_")}));const L=!1===(null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.paginationAvailable)||!1===(null===(r=null==o?void 0:o.config)||void 0===r?void 0:r.hasPagination)||!0===(null===(i=null==o?void 0:o.config)||void 0===i?void 0:i.disablePagination);if(L&&(null==v?void 0:v.getFolders))try{const e=await v.getFolders({parentId:d,deep:!1}),t=new Set((e||[]).map(e=>{var t;return null===(t=e.name)||void 0===t?void 0:t.toLowerCase()}).filter(Boolean));for(const e of P){if(!e.isFolder&&!(null===(m=(c=e.id).startsWith)||void 0===m?void 0:m.call(c,"folder_")))continue;const n=e.name||x(e.id)||"";if(n&&t.has(n.toLowerCase()))return void s.error({id:"FOLDER_ALREADY_EXISTS_COPY",message:a("A folder with that name already exists. Please enter a different folder name."),placement:"bottomRight",data:{folderName:n,targetFolderId:l}})}}catch(e){console.warn("Could not check folder duplicates for copy:",e)}if(L&&(null==v?void 0:v.getFiles))try{let e=[];const{files:t}=await v.getFiles({folderId:d||void 0,itemType:"all",page:1,limit:1e4});if(e=(t||[]).map(e=>e.name).filter(e=>!!e),null==v?void 0:v.getFolders){const t=(await v.getFolders({parentId:d,deep:!1})||[]).map(e=>e.name).filter(e=>!!e);e=[...e,...t]}const n=[...e];R=P.map(e=>{var t,r;if(e.isFolder||(null===(r=(t=e.id).startsWith)||void 0===r?void 0:r.call(t,"folder_")))return{id:e.id,isFolder:!0};const i=P.find(t=>t.id===e.id),o=(null==i?void 0:i.name)||x(e.id)||"",a=_o(o,n);return n.push(a),{id:e.id,isFolder:!1,newName:a!==o?a:void 0}})}catch(e){console.warn("Could not check duplicates for copy:",e)}else R=P.map(e=>({id:e.id,isFolder:(null==e?void 0:e.isFolder)||e.id.startsWith("folder_")}));const N=await y({items:R,targetFolderId:l,getItemNameById:x,showNotifications:!1});if(T=N.successCount,F=N.failCount,O.push(...N.errorDetails),T>0){const e=C(E),t=_(e),n=t?a("Copied",{names:t}):a("copy_success_summary",{successCount:T,totalCount:I});s.success({id:"FILES_COPY_SUCCESS",message:n,placement:"bottomRight",data:Ya(E,T,I,d,e)})}if(F>0){const e=C(E),t=_(e);let n;if(1===I&&O.length>0&&(null===(S=O[0].error)||void 0===S?void 0:S.code)){const e=Ao(null===(A=O[0].error)||void 0===A?void 0:A.code,a);n=null!=e?e:t?a("Failed",{names:t}):a("copy_fail_summary",{failCount:F,totalCount:I})}else n=t?a("Failed",{names:t}):a("copy_fail_summary",{failCount:F,totalCount:I});s.error({id:"FILES_COPY_ERROR",message:n,placement:"bottomRight",innerException:O.length?O:void 0,data:Xa(E,F,I,d,O.length?O:void 0,e)})}k(),u(),M&&await b({parentIds:void 0,selectedFolder:g}),await w({fetchFiles:e,selectedFolder:h,page:p.current,limit:p.pageSize})}catch(e){console.error("Error when copying:",e);const t=Ao(Io(e).code,a);s.error({id:"FILES_COPY_ERROR",message:null!=t?t:a("Error copying"),innerException:e,placement:"bottomRight",data:Xa(E,I,I,h||null,[{error:Io(e)}],C(E))})}},[g,l,f,e,h,p,d,s,a,y,u,m,null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.hasPagination,null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.disablePagination,null==v?void 0:v.getFiles,x]);return{actions:{showCopyModal:S,handleCopyCancel:k,handleCopyOk:A}}},Qa=e=>{const t=Ga(e),n=Za(e),r=Ja(e),i=(e=>{const{state:t,actions:n,options:r}=ro(),{t:i}=Qn(),o=bo(),a=Wa(e=>e.selectedFiles),s=Wa(e=>e.clearSelection),{files:l,selectedFolder:u,pagination:d,currentMenuFile:h}=t,{setIsDeleteConfirmVisible:f,setUndoDeletion:p,setPagination:g}=n,{config:m}=r,{deleteItems:v}=Wo(),{refreshFolders:y,refreshFiles:b}=Ka(),{getItemNameById:w,getItemNamesByIds:x,getNamesPreview:C}=qa(l),_=c(()=>{null==f||f(!0)},[f]),S=c(()=>{null==f||f(!1)},[f]),k=c(async()=>{var t,n,r;if(!((null==h?void 0:h.length)||a&&0!==a.size))return void(null==f||f(!1));const c=l.length,_=Object.assign({},d),S=Array.from(h?[h]:a),k=S.map(e=>l.find(t=>t.id===e)).filter(e=>Boolean(e)),A=new Set;k.forEach(e=>{(null==e?void 0:e.isFolder)&&A.add((e=>{var t,n;if(!e)return null;const r=e;return null!==(n=null!==(t=r.folderId)&&void 0!==t?t:r.parentId)&&void 0!==n?n:null})(e))});let E=0,I=0;const T=[];try{const a=await v({items:k,selectedFolder:u,getItemNameById:w,showNotifications:!1});E=a.successCount,I=a.failCount,T.push(...a.errorDetails);const l=(null==m?void 0:m.enableTrashFolder)&&"Trash"===u;if(E>0&&(null==m?void 0:m.enableTrashFolder)&&!l&&(null==p||p({itemIds:S,sourceFolderId:u||"folders"})),E>0){const e=S.length;(null==m?void 0:m.enableTrashFolder)&&!l?await o.success({id:"FILES_DELETE_SUCCESS",message:i("moved_to_trash",{count:E}),placement:"bottomRight",data:{successCount:E,totalCount:e,itemIds:S,folderId:u||null}}):await o.success({id:"FILES_DELETE_SUCCESS",message:i("Files deleted"),placement:"bottomRight",data:{successCount:E,totalCount:e,itemIds:S,folderId:u||null}})}if(I>0){const e=x(S),r=C(e),a=S.length,s=1===a&&T.length>0&&(null===(t=T[0].error)||void 0===t?void 0:t.code),c=(null==m?void 0:m.enableTrashFolder)&&!l,u=i(c?"При перемещении в корзину произошли ошибки":"При удалении произошли ошибки"),d=s?Ao(null===(n=T[0].error)||void 0===n?void 0:n.code,i):void 0,h=null!=d?d:r?i("Failed",{names:r}):u;o.error({id:"FILES_DELETE_ERROR",message:h,placement:"bottomRight",innerException:T.length?T:void 0,data:{failCount:I,isTrashMove:c,totalCount:a,itemNames:e,errors:T.length?T:void 0}})}s(),null==f||f(!1),await y({parentIds:Array.from(A),selectedFolder:u});let d=_.current;if(E>0&&c>0&&E>=c&&_.current>1&&(d=_.current-1),E>0&&_.total>=E){const e=Math.max(0,(null!==(r=_.total)&&void 0!==r?r:0)-E);null==g||g({current:d,pageSize:_.pageSize,total:e})}await b({fetchFiles:e,selectedFolder:u,page:d,limit:_.pageSize})}catch(e){console.error("Error when deleting:",e),o.error({id:"FILES_DELETE_ERROR",message:i("Error deleting"),placement:"bottomRight",innerException:e,data:{failCount:I,totalCount:k.length}})}},[h,a,f,e,u,d,p,g,l,i,o,v,s,null==m?void 0:m.enableTrashFolder]);return{actions:{showDeleteConfirm:_,handleDeleteConfirmCancel:S,handleDeleteConfirmOk:k}}})(e);return{state:t.state,actions:Object.assign(Object.assign(Object.assign(Object.assign({},t.actions),n.actions),r.actions),i.actions)}},es=()=>{const{state:e}=ro(),{files:t,loading:n,isUrlModalVisible:r}=e,i=za(),o=(()=>{const{state:e}=ro(),t=e.multiSelect,n=Wa(e=>e.selectedFiles),r=Wa(e=>e.toggleFileSelection),i=Wa(e=>e.setMultiSelect);return a(()=>{i(!1!==t)},[t,i]),{state:{selectedFiles:n},actions:{toggleFileSelection:r}}})(),s=Qa(i.fetchFiles);return{state:{files:t||[],selectedFiles:o.state.selectedFiles,loading:n||!1,isAddingFileByUrl:r||!1,isRenamingFile:s.state.isRenamingFile,fileToRename:s.state.fileToRename},actions:{fetchFiles:i.fetchFiles,handleDeleteFile:i.handleDeleteFile,handleDeleteFolder:i.handleDeleteFolder,handleAddFile:i.handleAddFile,handleAddFileByUrl:i.handleAddFileByUrl,handleDroppedFiles:i.handleDroppedFiles,uploadFileWithProvider:i.uploadFileWithProvider,toggleFileSelection:o.actions.toggleFileSelection,showRenameModal:s.actions.showRenameModal,handleRenameCancel:s.actions.handleRenameCancel,handleRenameOk:s.actions.handleRenameOk,showMoveModal:s.actions.showMoveModal,handleMoveCancel:s.actions.handleMoveCancel,handleMoveOk:s.actions.handleMoveOk,showCopyModal:s.actions.showCopyModal,handleCopyCancel:s.actions.handleCopyCancel,handleCopyOk:s.actions.handleCopyOk,showDeleteConfirm:s.actions.showDeleteConfirm,handleDeleteConfirmCancel:s.actions.handleDeleteConfirmCancel,handleDeleteConfirmOk:s.actions.handleDeleteConfirmOk}}},ts="filemanager_sidebar_width",ns=({onSearch:t,placeholder:n,className:r})=>{const{t:i}=Qn(),[s,l]=o(""),c=u(null),{options:d}=ro(),{config:h}=d,f=n||i("Search files...");a(()=>(c.current=go.debounce(e=>{t(e)},500),()=>{var e;null===(e=c.current)||void 0===e||e.cancel()}),[t]);return e(F,{value:s,onChange:e=>{var t;const n=e.target.value;l(n),null===(t=c.current)||void 0===t||t.call(c,n)},placeholder:f,prefix:e(wi,{size:16,strokeWidth:null==h?void 0:h.iconStrokeWidth}),className:r,allowClear:!0,onClear:()=>{l(""),t("")}})};var rs={contentLayout:"contentLayout",headerContainer:"headerContainer",actionsContainer:"actionsContainer",filesContainer:"filesContainer",emptyStateWrapper:"emptyStateWrapper",paginationContainer:"paginationContainer",uploadIcon:"uploadIcon",tableContainer:"tableContainer",tableLoadingWrapper:"tableLoadingWrapper",imagePreview:"imagePreview",fileManagerTableFolder:"fileManagerTableFolder",fileManagerTableFolderInner:"fileManagerTableFolderInner",sortSelect:"sortSelect",fileNameCol:"fileNameCol",fileItemCount:"fileItemCount",fileSize:"fileSize",fileDate:"fileDate",tableMenu:"tableMenu",tableImagePreview:"tableImagePreview",tableFolderIcon:"tableFolderIcon",buttonDeselected:"buttonDeselected",buttonSelectAll:"buttonSelectAll",gridRow:"gridRow",gridCard:"gridCard",selectedRow:"selectedRow",gridCardSelected:"gridCardSelected",gridCheckbox:"gridCheckbox",gridCardContent:"gridCardContent",gridPreviewContainer:"gridPreviewContainer",gridPreviewContainerFolder:"gridPreviewContainerFolder",gridFolderIcon:"gridFolderIcon",gridFolderIconImage:"gridFolderIconImage",gridFileName:"gridFileName",gridFileInfo:"gridFileInfo",gridFileMenu:"gridFileMenu",gridFileMenuButton:"gridFileMenuButton",actionsBox:"actionsBox",uploadContainer:"uploadContainer",uploadArea:"uploadArea",blockText:"blockText",textTitle:"textTitle",textDescription:"textDescription",buttons:"buttons",btnAi:"btnAi",btnPhoto:"btnPhoto",dragOverlay:"dragOverlay",dragOverlayInner:"dragOverlayInner",dragCaptureLayer:"dragCaptureLayer",dragOverlayGlobal:"dragOverlayGlobal",noFiles:"noFiles",noFilesIcon:"noFilesIcon",textTitle_trash:"textTitle_trash",textDescription_trash:"textDescription_trash"};const{Text:is}=O,{Option:os}=P;const as=i.memo(({files:n,filesById:r,currentSortOption:i,isSmallScreen:o,iconStrokeWidth:a,features:s,viewMode:l,setViewMode:c,handleSearch:u,handleSortOptionChange:h,onClearSelection:f,onRename:p,onDelete:g,onCopy:m,onMove:v,onEdit:y,t:b})=>{const w=Wa(e=>e.selectedFiles),x=Wa(e=>e.selectedFiles.size),C=Wa(e=>e.selectAllVisible),_=n.length>0&&x===n.length,S=d(()=>Array.from(w)[0],[w]),k=d(()=>S?r.get(S):void 0,[r,S]),A=(null==k?void 0:k.isFolder)?!1!==(null==s?void 0:s.enableRenameFolder):!1!==(null==s?void 0:s.enableRenameFile),E=d(()=>Array.from(w).every(e=>{const t=r.get(e);return!!t&&(t.isFolder?!1!==(null==s?void 0:s.enableMoveFolder):!1!==(null==s?void 0:s.enableMoveItem))}),[s,r,w]),I=d(()=>Array.from(w).every(e=>{const t=r.get(e);return!!t&&(t.isFolder?!1!==(null==s?void 0:s.enableCopyFolder):!1!==(null==s?void 0:s.enableCopyItem))}),[s,r,w]),T=d(()=>1===x&&function(e){var t,n,r;if(!e||e.isFolder)return!1;const i=e.extension||(e.name&&e.name.includes(".")?e.name.split(".").pop():void 0)||((null===(t=e.type)||void 0===t?void 0:t.startsWith("image/"))?null===(r=null===(n=e.type.split("/")[1])||void 0===n?void 0:n.split(";")[0])||void 0===r?void 0:r.trim():void 0);return Boolean(i&&vn.includes(i.toLowerCase()))}(k),[x,k]);return t("div",x>0?{className:`header-container ${rs.headerContainer}`,children:[t(is,{type:"secondary",className:"selected-text",children:[t("div",{children:[x," ",b("selected")]}),e(M,{title:o?b("Select all"):null,children:e(R,{className:rs.buttonSelectAll,onClick:C,disabled:_||0===n.length,children:b("Select all")})}),e(M,{title:o?b("Deselected"):null,children:e(R,{className:rs.buttonDeselected,icon:e(bi,{size:16,strokeWidth:a}),onClick:f,children:b("Deselected")})})]}),t(L,{children:[T&&!1!==(null==s?void 0:s.enableEdit)&&e(M,{title:o?b("Edit"):null,children:e(R,{icon:e(ai,{size:16,strokeWidth:a}),onClick:()=>y(k),disabled:!T,children:b("Edit")})}),E&&e(M,{title:o?b("Move to"):null,children:e(R,{icon:e(li,{size:16,strokeWidth:a}),onClick:v,children:b("Move to")})}),I&&e(M,{title:o?b("Copy"):null,children:e(R,{icon:e(oi,{size:16,strokeWidth:a}),onClick:m,children:b("Copy")})}),1===x&&A&&e(M,{title:o?b("Rename"):null,children:e(R,{icon:e(Ci,{size:16,strokeWidth:a}),onClick:()=>p(),disabled:1!==x||!A,children:b("Rename")})}),!1!==(null==s?void 0:s.enableDelete)&&e(M,{title:o?b("Delete"):null,children:e(R,{danger:!0,icon:e(Si,{size:16,strokeWidth:a}),onClick:e=>{e.stopPropagation(),e.preventDefault(),g()},children:b("Delete")})})]})]}:{className:rs.headerContainer,children:[e("div",{className:"search-container",children:e(ns,{placeholder:b("Search file or folder"),onSearch:u,className:rs.searchInput})}),t("div",{className:rs.actionsBox,children:[e("div",{className:"sort-container",children:t(P,{value:i,onChange:h,className:rs.sortSelect,popupMatchSelectWidth:!1,suffixIcon:e(ri,{size:16,strokeWidth:a}),children:[e(os,{value:"date-desc",children:b("Newest first")}),e(os,{value:"date-asc",children:b("Oldest first")}),e(os,{value:"size-desc",children:b("Largest first")}),e(os,{value:"size-asc",children:b("Smallest first")}),e(os,{value:"name-asc",children:b("A-Z")}),e(os,{value:"name-desc",children:b("Z-A")}),e(os,{value:"type-asc",children:b("By type")})]})}),e("div",{className:rs.actionsContainer,children:e(N,{options:[{value:"grid",icon:e(hi,{size:16,strokeWidth:a})},{value:"table",icon:e(gi,{size:20,strokeWidth:a})}],value:l,onChange:e=>c(e)})})]})]})});as.displayName="FileContentHeader";const ss=i.memo(({fileId:t,style:n})=>{const r=Wa(e=>e.selectedFiles.has(t)),i=Wa(e=>e.toggleFileSelection);return e(D,{checked:r,style:n,onClick:e=>{e.stopPropagation()},onChange:e=>{const n=e.nativeEvent;i(t,{metaKey:n.metaKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,forceToggle:!0})}})});function ls(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}ss.displayName="FileSelectionCheckbox","function"==typeof SuppressedError&&SuppressedError;const cs=i.memo(t=>{var{className:n}=t,r=ls(t,["className"]);const i=r["data-row-key"],o=null==i?"":String(i),a=[n,Wa(e=>!!o&&e.selectedFiles.has(o))?rs.selectedRow:""].filter(Boolean).join(" ");return e("tr",Object.assign({},r,{className:a}))});cs.displayName="SelectableTableRow";const us=i.memo(({item:t,variant:n="table",t:r,iconStrokeWidth:i,setCurrentMenuFile:a,showMoveModal:s,showCopyModal:l,showRenameModal:u,showDeleteConfirm:h,onEdit:f})=>{const[p,g]=o(!1),m=d(()=>{if(!p)return[];const n=[];return t.canEdit&&n.push({key:"edit",label:r("Edit"),icon:e(ai,{size:16,strokeWidth:i})}),t.canMove&&n.push({key:"move",label:r("Move to"),icon:e(li,{size:16,strokeWidth:i})}),t.canCopy&&n.push({key:"copy",label:r("Copy"),icon:e(oi,{size:16,strokeWidth:i})}),t.canRename&&n.push({key:"rename",label:r("Rename"),icon:e(Ci,{size:16,strokeWidth:i})}),t.canDelete&&n.push({key:"delete",label:r("Delete"),icon:e(Si,{size:16,strokeWidth:i}),style:{color:"#ff4d4f"}}),n},[i,p,t.canCopy,t.canDelete,t.canEdit,t.canMove,t.canRename,r]),v=c(({key:e})=>{switch(t.id&&(null==a||a(t.id)),e){case"edit":f(t.file);break;case"move":s();break;case"copy":l();break;case"rename":u(t.id);break;case"delete":null==h||h();break;default:null==a||a("")}},[t,f,a,l,h,s,u]),y=d(()=>({items:m,onClick:v}),[v,m]);return e(j,{arrow:!0,placement:"bottom",menu:y,trigger:["hover"],onOpenChange:g,children:"grid"===n?e(R,{type:"default",className:`${rs.gridFileMenuButton} gridFileMenuButton`,onClick:e=>{e.stopPropagation(),e.preventDefault()},children:e(si,{size:16,strokeWidth:i})}):e("span",{className:`${rs.tableMenu} tableMenuButton`,onClick:e=>{e.stopPropagation(),e.preventDefault()},children:e(si,{size:16,strokeWidth:i})})})});us.displayName="FileItemActionsDropdown";const ds=({thumbnailSrc:t,previewSrc:n,alt:r,className:s,width:l,height:u,preview:d=!1})=>{const h=r,[f,p]=o(t),[g,m]=o(n),v=i.useRef(!1),y=i.useRef(!1),b=c(e=>{const t=e.split(",")[1];return!!(t&&t.length>20)},[]),w=c(e=>{var t;if(e&&e!==bn)return e.startsWith("data:image/")?b(e)?e:void 0:e.startsWith("blob:")?e:e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?null!==(t=(e=>{if(e&&"string"==typeof e){if(e.startsWith("data:")||e.startsWith("blob:"))return e;try{if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")){const t=new URL(e.startsWith("/")?`https://x${e}`:e),n=e.startsWith("/")?"":`${t.protocol}//${t.host}`,r=t.pathname.split("/").map(e=>{if(!e)return"";try{return encodeURIComponent(decodeURIComponent(e))}catch(t){return encodeURIComponent(e)}}).join("/");return e.startsWith("/")?r+(t.search||"")+(t.hash||""):`${n}${r}${t.search}${t.hash}`}}catch(e){}return e}})(e))&&void 0!==t?t:e:void 0},[b]);a(()=>{v.current=!1,y.current=!1;const e=w(t),r=w(n),i=null!=r?r:e;p(null!=e?e:r),m(i)},[t,n,w]);const x=c((e,t)=>e&&e.toLowerCase().endsWith(".svg")||t&&(t.includes(".svg")||t.includes("image/svg+xml")),[]),C=c(()=>{f!==bn&&(v.current||(v.current=!0,x(h,f)),p(bn))},[f,h,x]),_=c(()=>{if(g&&g!==bn&&!y.current)return g;const e=w(t);return e&&!v.current?e:void 0},[g,t,w]),S=f===bn?mn:f,k=_();return S?e(z,{className:s,src:S,alt:r,width:l,height:u,preview:!(!d||!k)&&{src:k,toolbarRender:()=>null,destroyOnHidden:!0,mask:e(be,{style:{fontSize:"20px"}})},onError:C,fallback:mn}):null},hs=i.memo(({item:t,variant:n="table",FolderIcon:r,getFileData:i,className:o,width:a,height:s})=>t.isFolder?e("div","grid"===n?{className:rs.gridFolderIcon,children:e(r,{className:rs.gridFolderIconImage})}:{className:rs.fileManagerTableFolder,children:e("div",{className:rs.fileManagerTableFolderInner,children:e(r,{className:rs.tableFolderIcon,style:{width:null!=a?a:40,height:null!=s?s:40}})})}):t.thumbnailSrc||t.previewSrc?e(ds,{className:o,thumbnailSrc:t.thumbnailSrc,previewSrc:t.previewSrc,alt:t.file.name,width:a,height:s,preview:!0,file:t.file,getFileData:i}):null);hs.displayName="FileItemPreview";const fs=i.memo(({item:n,t:r,iconStrokeWidth:i,FolderIcon:o,handleSingleClick:a,handleDoubleClick:s,handleItemClick:l,setCurrentMenuFile:c,showMoveModal:u,showCopyModal:d,showRenameModal:h,showDeleteConfirm:f,onEdit:p,onEditorOk:g,getFileData:m})=>{const v=Wa(e=>e.selectedFiles.has(n.id)),y=Wa(e=>e.toggleFileSelection);return e(B,{className:rs.gridCard_col,style:{padding:0},children:t(U,{hoverable:!0,cover:e("div",{className:n.isFolder?rs.gridPreviewContainerFolder:rs.gridPreviewContainer,onClick:e=>{e.stopPropagation(),n.isFolder&&a(()=>{y(n.id,{metaKey:e.metaKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey})})},onDoubleClick:e=>{e.stopPropagation(),s(()=>{n.isFolder&&l(n.file)})},children:e(hs,{item:n,variant:"grid",FolderIcon:o,getFileData:m,className:rs.gridImagePreview})}),className:`${rs.gridCard} ${v?rs.gridCardSelected:""}`,onClick:e=>{e.stopPropagation(),e.preventDefault();const t=e.target;t.closest(".gridFileMenuButton")||t.closest(".ant-dropdown-menu")||a(()=>y(n.id,{metaKey:e.metaKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey}))},onDoubleClick:e=>{e.stopPropagation(),s(()=>{n.isFolder&&l(n.file)})},children:[t("div",{className:rs.gridCardContent,onDoubleClick:e=>{e.stopPropagation(),e.preventDefault(),s(()=>{n.isFolder?l(n.file):g&&g(n.file)})},onClick:e=>{e.stopPropagation(),e.preventDefault();const t=e.target;t.closest(".gridFileMenuButton")||t.closest(".ant-dropdown-menu")||a(()=>y(n.id,{metaKey:e.metaKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey}))},children:[e("div",{className:rs.gridFileName,children:n.nameText||r("Untitled")}),e("div",{className:rs.gridFileInfo,children:n.gridInfoText})]}),e("div",{className:rs.gridFileMenu,children:e(us,{item:n,variant:"grid",t:r,iconStrokeWidth:i,setCurrentMenuFile:c,showMoveModal:u,showCopyModal:d,showRenameModal:h,showDeleteConfirm:f,onEdit:p})}),e("div",{onClick:e=>{e.stopPropagation()},className:rs.gridCheckbox,children:e(ss,{fileId:n.id,style:{height:20}})})]})})});fs.displayName="FileGridItem";const ps=i.memo(({rows:t,topOffset:r=0,bottomOffset:i=0,t:o,iconStrokeWidth:a,FolderIcon:s,handleSingleClick:l,handleDoubleClick:c,handleItemClick:u,setCurrentMenuFile:d,showMoveModal:h,showCopyModal:f,showRenameModal:p,showDeleteConfirm:g,onEdit:m,onEditorOk:v,getFileData:y})=>e(n,{children:e("div",{style:{paddingTop:r,paddingBottom:i},children:e(V,{gutter:[16,16],className:rs.gridRow,style:{gap:20,padding:"0 24px 24px",margin:0},children:t.map(t=>e(fs,{item:t,handleSingleClick:l,handleDoubleClick:c,handleItemClick:u,iconStrokeWidth:a,t:o,FolderIcon:s,setCurrentMenuFile:d,showMoveModal:h,showCopyModal:f,showRenameModal:p,showDeleteConfirm:g,onEdit:m,onEditorOk:v,getFileData:y},t.id))})})}));ps.displayName="FileGridView";const gs=i.memo(({rows:t,columns:r,loading:i,topOffset:o=0,bottomOffset:a=0,onRow:s,components:l})=>{const c=d(()=>e("div",{style:{paddingTop:o,paddingBottom:a},children:e(E,{renderEmpty:()=>e(W,{image:e(n,{}),description:""}),children:e(H,{dataSource:t,columns:r,rowKey:"id",pagination:!1,tableLayout:"fixed",onRow:s,components:l,showHeader:!1})})}),[a,r,l,s,t,o]);return e(k,{spinning:i,className:rs.tableLoadingWrapper,children:c})});gs.displayName="FileTableView";const ms=i.memo(({item:t})=>t.dateText?e(M,{title:t.dateText,placement:"bottom",className:rs.fileDate,children:t.dateText}):null);ms.displayName="FileItemDate";const vs=i.memo(({item:n})=>t("div",{className:rs.fileName,children:[n.nameText,n.isFolder&&e("div",{className:rs.fileItemCount,children:n.folderItemsText})]}));vs.displayName="FileItemName";const ys="filemanager_view_mode";class bs{constructor(){this.rowsById=new Map}reconcile(e,t,n){const r=new Map,i=[];for(const o of e){const e=t.getId(o),a=t.buildSignature(o,n),s=this.rowsById.get(e);if(s&&s.signature===a){r.set(e,s),i.push(s);continue}const l=t.buildRowModel(o,n,{id:e,signature:a});r.set(e,l),i.push(l)}return this.rowsById=r,i}}class ws{createRenderWindow(e,t){var n,r,i,o,a,s,l,c,u,d,h;if("windowed"!==(null!==(n=null==t?void 0:t.renderStrategy)&&void 0!==n?n:"full"))return{rows:e,startIndex:0,endIndex:e.length>0?e.length-1:-1,topOffset:0,bottomOffset:0,totalCount:e.length};const f=Math.max(0,null!==(i=null===(r=null==t?void 0:t.windowed)||void 0===r?void 0:r.startIndex)&&void 0!==i?i:0),p=null!==(a=null===(o=null==t?void 0:t.windowed)||void 0===o?void 0:o.endIndex)&&void 0!==a?a:e.length-1,g=Math.max(0,null!==(l=null===(s=null==t?void 0:t.windowed)||void 0===s?void 0:s.overscan)&&void 0!==l?l:0),m=Math.max(1,null!==(u=null===(c=null==t?void 0:t.windowed)||void 0===c?void 0:c.estimatedItemSize)&&void 0!==u?u:1),v=Math.max(1,null!==(h=null===(d=null==t?void 0:t.windowed)||void 0===d?void 0:d.itemsPerLane)&&void 0!==h?h:1),y=Math.ceil(e.length/v),b=Math.min(e.length-1,p),w=Math.floor(f/v),x=Math.floor(Math.max(f,b)/v),C=Math.max(0,w-g),_=Math.min(y-1,x+g),S=C*v,k=Math.min(e.length-1,(_+1)*v-1),A=Math.max(0,y-_-1);return{rows:e.slice(S,k+1),startIndex:S,endIndex:k,topOffset:C*m,bottomOffset:A*m,totalCount:e.length}}}function xs({totalCount:e,plan:t}){const[n,r]=o(null),i=d(()=>{var r,i;if(!t.enabled)return{renderStrategy:"full"};const o=function(e,t){var n;return Math.max(1,null!==(n=null==e?void 0:e.viewportHeight)&&void 0!==n?n:t)}(n,null!==(r=t.fallbackViewportHeight)&&void 0!==r?r:800),a=Math.max(1,Math.ceil(o/t.estimatedItemSize)),s=Math.max(1,Math.ceil(e/t.itemsPerLane)),l=Math.min(s-1,Math.max(0,Math.floor((null!==(i=null==n?void 0:n.scrollTop)&&void 0!==i?i:0)/t.estimatedItemSize))),c=l+a-1;return{renderStrategy:"windowed",windowed:{startIndex:l*t.itemsPerLane,endIndex:Math.min(e-1,(c+1)*t.itemsPerLane-1),overscan:t.overscan,estimatedItemSize:t.estimatedItemSize,itemsPerLane:t.itemsPerLane}}},[t.enabled,t.estimatedItemSize,t.fallbackViewportHeight,t.itemsPerLane,t.overscan,e,n]);return{engineOptions:i,handleViewportChange:c(e=>{r(t=>(null==t?void 0:t.viewportHeight)===e.viewportHeight&&(null==t?void 0:t.viewportWidth)===e.viewportWidth&&(null==t?void 0:t.scrollHeight)===e.scrollHeight&&(null==t?void 0:t.scrollTop)===e.scrollTop?t:e)},[])}}function Cs(e){var t,n,r;const i=e.extension||(e.name&&e.name.includes(".")?e.name.split(".").pop():void 0)||((null===(t=e.type)||void 0===t?void 0:t.startsWith("image/"))?null===(r=null===(n=e.type.split("/")[1])||void 0===n?void 0:n.split(";")[0])||void 0===r?void 0:r.trim():void 0);return Boolean(i&&vn.includes(i.toLowerCase()))}function _s(e,t){if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return"";const r=[t("months.january"),t("months.february"),t("months.march"),t("months.april"),t("months.may"),t("months.june"),t("months.july"),t("months.august"),t("months.september"),t("months.october"),t("months.november"),t("months.december")];return t("Added",{date:`${n.getDate()} ${r[n.getMonth()]} ${n.getFullYear()}`})}const Ss={getId:e=>e.id,buildSignature:(e,t)=>function(e,t){var n,r,i,o,a,s,l,c,u,d;const h=Boolean(e.isFolder),f=h&&null!==(r=null!==(n=e.childCount)&&void 0!==n?n:t.folderFileCounts[e.id])&&void 0!==r?r:0,p=_s(e.date,t.t),g=!h&&e.size?String(e.size):"",m=[!1!==(null===(i=t.features)||void 0===i?void 0:i.enableEdit),!1!==(null===(o=t.features)||void 0===o?void 0:o.enableMoveFolder),!1!==(null===(a=t.features)||void 0===a?void 0:a.enableMoveItem),!1!==(null===(s=t.features)||void 0===s?void 0:s.enableCopyFolder),!1!==(null===(l=t.features)||void 0===l?void 0:l.enableCopyItem),!1!==(null===(c=t.features)||void 0===c?void 0:c.enableRenameFolder),!1!==(null===(u=t.features)||void 0===u?void 0:u.enableRenameFile),!1!==(null===(d=t.features)||void 0===d?void 0:d.enableDelete)].join("|");return[e.id,e.name,e.folderId,e.type||"",e.extension||"",e.thumbnailUrl||e.thumbnail||"",e.thumbnailUrl||e.thumbnail||"",e.dimensions||"",g,p,h?"1":"0",String(f),m].join("::")}(e,t),buildRowModel:(e,t,n)=>{var r,i,o,a,s,l,c,u,d,h;const f=Boolean(e.isFolder),p=f&&null!==(i=null!==(r=e.childCount)&&void 0!==r?r:t.folderFileCounts[e.id])&&void 0!==i?i:0,g=1===p?t.t("item"):t.t("items"),m=f?`${p} ${g}`:"",v=e.dimensions||"",y=!f&&e.size?Co(e.size):"",b=f?t.t("Folder"):function(e){var t,n,r;return e.extension||(null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase())||(e.url?null===(r=null===(n=e.url.split("?")[0].split("/").pop())||void 0===n?void 0:n.split(".").pop())||void 0===r?void 0:r.toLowerCase():"")||""}(e),w=_s(e.date,t.t),x=f?m:[v,y,b].filter(Boolean).join(" • ");return{id:n.id,signature:n.signature,item:e,file:e,isFolder:f,nameText:e.name||t.t("No name"),folderItemsText:m,dimensionsText:v,sizeText:y,typeText:b,dateText:w,gridInfoText:x,thumbnailSrc:e.thumbnailUrl||e.thumbnail,previewSrc:e.thumbnailUrl||e.thumbnail,canEdit:!f&&!1!==(null===(o=t.features)||void 0===o?void 0:o.enableEdit)&&Cs(e),canMove:f?!1!==(null===(a=t.features)||void 0===a?void 0:a.enableMoveFolder):!1!==(null===(s=t.features)||void 0===s?void 0:s.enableMoveItem),canCopy:f?!1!==(null===(l=t.features)||void 0===l?void 0:l.enableCopyFolder):!1!==(null===(c=t.features)||void 0===c?void 0:c.enableCopyItem),canRename:f?!1!==(null===(u=t.features)||void 0===u?void 0:u.enableRenameFolder):!1!==(null===(d=t.features)||void 0===d?void 0:d.enableRenameFile),canDelete:!1!==(null===(h=t.features)||void 0===h?void 0:h.enableDelete)}}};function ks({files:e,folderFileCounts:t,features:n,t:r,viewMode:i}){const a=d(()=>({folderFileCounts:t,features:n,t:r}),[n,t,r]),[s,l]=o(()=>Math.max(1,Math.floor(5))),h=d(()=>{const t=e.length>150;return"table"===i?{enabled:t,estimatedItemSize:56,overscan:10,itemsPerLane:1,fallbackViewportHeight:800}:{enabled:t,estimatedItemSize:320,overscan:2,itemsPerLane:s,fallbackViewportHeight:800}},[e.length,s,i]),{engineOptions:f,handleViewportChange:p}=xs({totalCount:e.length,plan:h}),{rowModels:g,renderWindow:m}=function({items:e,context:t,adapter:n,options:r}){const i=u(null),o=u(null);i.current||(i.current=new bs),o.current||(o.current=new ws);const a=d(()=>i.current.reconcile(e,n,t),[n,t,e]),s=d(()=>o.current.createRenderWindow(a,r),[r,a]);return{rowModels:a,renderWindow:s}}({items:e,context:a,adapter:Ss,options:f}),v=d(()=>g.some(e=>Boolean(e.dateText)),[g]),y=c(e=>{if("grid"===i){const t=Math.max(1,Math.floor(e.viewportWidth/240));l(e=>e===t?e:t)}p(e)},[p,i]);return{rowModels:g,renderRows:m.rows,renderWindow:m,hasAnyValidDate:v,handleViewportChange:y}}const As=/(auto|scroll|overlay)/;function Es(e){if("undefined"==typeof window)return!1;const t=window.getComputedStyle(e);return As.test(t.overflowY)||As.test(t.overflow)||As.test(t.overflowX)}function Is(e){if("undefined"==typeof window)return e;let t=e;for(;t;){if(Es(t))return t;t=t.parentElement}return null}function Ts(e,t,n){Math.max(0,e.clientHeight),Math.max(0,Math.round(e.getBoundingClientRect().height));return Math.max(1,t)}function Fs(e,t){if(e===t){const n=function(e){var t;if("undefined"==typeof window)return Math.max(1,e.clientHeight);const n=e.getBoundingClientRect(),r=window.innerHeight||(null===(t=document.documentElement)||void 0===t?void 0:t.clientHeight)||0,i=Math.max(0,n.top),o=Math.min(r,n.bottom);return Math.max(0,Math.round(o-i))}(t);return{scrollTop:t.scrollTop,viewportHeight:Ts(e,Math.min(t.clientHeight,n||t.clientHeight)),viewportWidth:Math.max(1,t.clientWidth),scrollHeight:e.scrollHeight}}const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=Math.max(n.top,r.top),o=Math.min(n.bottom,r.bottom),a=Math.max(n.left,r.left),s=Math.min(n.right,r.right),l=Math.max(0,Math.round(o-i)),c=Math.max(0,Math.round(s-a));return{scrollTop:Math.max(0,Math.round(i-r.top)),viewportHeight:Ts(e,l),viewportWidth:Math.max(1,c||t.clientWidth||e.clientWidth),scrollHeight:e.scrollHeight}}function Os(e){if("undefined"==typeof window)return{scrollTop:e.scrollTop,viewportHeight:Math.max(1,e.clientHeight),viewportWidth:e.clientWidth,scrollHeight:e.scrollHeight};const t=Is(e);return t&&function(e){return e.scrollHeight-e.clientHeight>1}(t)?Fs(e,t):function(e){var t,n;const r=e.getBoundingClientRect(),i=window.innerHeight||(null===(t=document.documentElement)||void 0===t?void 0:t.clientHeight)||0,o=window.innerWidth||(null===(n=document.documentElement)||void 0===n?void 0:n.clientWidth)||r.width,a=Math.max(0,r.top),s=Math.min(i,r.bottom),l=Math.max(0,Math.round(s-a));return{scrollTop:Math.max(0,Math.round(-r.top)),viewportHeight:Ts(e,l),viewportWidth:Math.max(1,Math.min(Math.round(r.width),o)),scrollHeight:e.scrollHeight}}(e)}const Ps=i.memo(({files:n,searchTerm:r,handleSearch:i,sortBy:s,sortOrder:l,handleSortOptionChange:h,pagination:f,setPagination:p,loading:g,handleItemClick:m,onClearSelection:v,onRename:y,onDelete:b,onCopy:w,onMove:x,showRenameModal:C,showDeleteConfirm:_,showCopyModal:S,showMoveModal:k,onEdit:A,getFileData:E,handleAddFile:I})=>{var T;const{t:F}=Qn(),{DropZoneFileIcon:O,BigStockIcon:P,BigAIIcon:M,FolderIcon:R}=oo(),{options:L,actions:N,state:D}=ro(),{dataProviders:j,config:z}=L,B=null==z?void 0:z.disablePagination,{setCurrentMenuFile:U,setActiveLibraryItem:V}=N,H="Trash"===(null==D?void 0:D.selectedFolder),W=Wa(e=>e.toggleFileSelection),{viewMode:G,setViewMode:q}=(()=>{const[e,t]=o(()=>{try{return localStorage.getItem(ys)||"table"}catch(e){return"table"}}),n=c(e=>{t(e);try{localStorage.setItem(ys,e)}catch(e){console.warn("Не удалось сохранить режим отображения:",e)}},[]),r=c(()=>{n("table"===e?"grid":"table")},[e,n]);return{viewMode:e,setViewMode:n,toggleViewMode:r}})(),[Y,X]=o({}),[K,Z]=o(!1),J=u(null),Q=u(0),ee=u(null);a(()=>{const e=window.matchMedia("(max-width: 1199px)"),t=e=>{Z(e.matches)};t(e);const n=e=>t(e);return"function"==typeof e.addEventListener?(e.addEventListener("change",n),()=>e.removeEventListener("change",n)):(e.addListener(n),()=>e.removeListener(n))},[]);const te=d(()=>(null==z?void 0:z.features)||{},[null==z?void 0:z.features]),ne=null==z?void 0:z.iconStrokeWidth,re=`${s}-${l}`,ie=d(()=>new Map(n.map(e=>[e.id,e])),[n]),{renderRows:oe,renderWindow:ae,hasAnyValidDate:se,handleViewportChange:le}=ks({files:n,folderFileCounts:Y,features:te,t:F,viewMode:G}),ce=c(async e=>{var t;try{if(null==j?void 0:j.getChildrenCount)return await j.getChildrenCount("folders"===e?void 0:e);if(null==j?void 0:j.getFiles){const{files:n,pagination:r}=await j.getFiles({folderId:"folders"===e?void 0:e,itemType:"all",page:B?void 0:1,limit:B?void 0:1});return B?Array.isArray(n)?n.length:0:null!==(t=null==r?void 0:r.total)&&void 0!==t?t:Array.isArray(n)?n.length:0}return 0}catch(t){return"StaleLoad"===(null==t?void 0:t.name)||console.error(`Error getting the number of files for the folder ${e}:`,t),0}},[j,B]),ue=c(async()=>{const e=Q.current+1;Q.current=e;const t=n.filter(e=>e.isFolder);if(0===t.length)return void X(e=>0===Object.keys(e).length?e:{});const r={},i=t.map(async e=>{"number"!=typeof e.childCount?r[e.id]=await ce(e.id):r[e.id]=e.childCount});await Promise.all(i),Q.current===e&&X(e=>{const t=Object.keys(e),n=Object.keys(r);return t.length===n.length&&t.every(t=>e[t]===r[t])?e:r})},[n,ce]);a(()=>{ue()},[ue]),a(()=>{ee.current&&le(Os(ee.current))},[n.length,le,G]),a(()=>{if(!ee.current||"undefined"==typeof ResizeObserver)return;const e=ee.current,t=new ResizeObserver(()=>{le(Os(e))});return t.observe(e),()=>{t.disconnect()}},[le]);const de=c((e=()=>{})=>{if(J.current)return;const t=setTimeout(()=>{e(),J.current=null},300);J.current=t},[]),he=c(e=>{J.current&&(clearTimeout(J.current),J.current=null),e()},[]),fe=c(e=>{const t=Os(e);le(t)},[le]);a(()=>{const e=ee.current;if(!e)return;const t=()=>{fe(e)},n=function(e){if("undefined"==typeof window)return[e];const t=Is(e);return t?t===e?[window,e]:[window,t]:[window]}(e);return n.forEach(e=>{e.addEventListener("scroll",t,{passive:!0})}),()=>{n.forEach(e=>{e.removeEventListener("scroll",t)})}},[n.length,fe,G]);const pe=c((e,t)=>e!==t,[]),ge=d(()=>[{key:"selection",width:46,shouldCellUpdate:pe,render:(t,n)=>e(ss,{fileId:n.id})},{key:"preview",width:60,shouldCellUpdate:pe,render:(t,n)=>e(hs,{item:n,variant:"table",FolderIcon:R,getFileData:E,className:`${rs.imagePreview} ${rs.tableImagePreview}`,width:40,height:40})},{title:F("Name"),width:"calc(100% - 430px)",dataIndex:"nameText",key:"name",className:rs.fileNameCol,shouldCellUpdate:pe,render:(t,n)=>e(vs,{item:n})},{title:F("Dimensions"),key:"dimensions",width:100,shouldCellUpdate:pe,render:(t,n)=>n.dimensionsText&&e("div",{className:rs.fileSize,children:n.dimensionsText})},{title:F("Size"),key:"size",width:90,shouldCellUpdate:pe,render:(t,n)=>n.sizeText?e("div",{className:rs.fileSize,children:n.sizeText}):null},{title:F("Type"),key:"type",width:90,shouldCellUpdate:pe,render:(t,n)=>e("div",{className:rs.fileSize,children:n.typeText})},...se?[{title:F("Date"),dataIndex:"dateText",key:"date",width:200,shouldCellUpdate:pe,render:(t,n)=>e(ms,{item:n})}]:[],{width:40,title:"",dataIndex:"",key:"x",onCell:()=>({style:{padding:0}}),shouldCellUpdate:pe,render:(t,n)=>e(us,{item:n,variant:"table",t:F,iconStrokeWidth:ne,setCurrentMenuFile:U,showMoveModal:k,showCopyModal:S,showRenameModal:C,showDeleteConfirm:_,onEdit:A})}],[R,E,se,ne,A,U,pe,S,_,k,C,F]);a(()=>()=>{J.current&&clearTimeout(J.current)},[]);const me=d(()=>({body:{row:cs}}),[]),ve=c(e=>({onClick:t=>{const n=t.target;de(()=>{t.stopPropagation(),t.preventDefault();const r=Boolean(n.closest(".ant-image"))||Boolean(n.closest(".ant-image-preview-wrap")),i=Boolean(n.closest(".tableMenuButton")),o=Boolean(n.closest(".ant-dropdown-menu"));r||i||o||W(e.id,{metaKey:t.metaKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey})})},onDoubleClick:t=>{he(()=>{t.stopPropagation(),t.preventDefault();const n=t.target;n.closest(".ant-checkbox-wrapper")||n.closest(".tableMenu")||(e.isFolder?m(e.file):n.closest(".ant-image")||n.closest(".ant-image-preview-wrap")||!L.onEditorOk||L.onEditorOk(e.file))})}}),[he,m,de,L,W]);let ye="table"===G?e(gs,{rows:oe,columns:ge,loading:g,topOffset:ae.topOffset,bottomOffset:ae.bottomOffset,onRow:ve,components:me}):e(ps,{rows:oe,topOffset:ae.topOffset,bottomOffset:ae.bottomOffset,t:F,iconStrokeWidth:ne,FolderIcon:R,handleSingleClick:de,handleDoubleClick:he,handleItemClick:m,setCurrentMenuFile:U,showMoveModal:k,showCopyModal:S,showRenameModal:C,showDeleteConfirm:_,onEdit:A,onEditorOk:L.onEditorOk,getFileData:E});r&&!n.length&&(ye=e(uo,{}));const be=null===(T=null==z?void 0:z.availableImageExtensions)||void 0===T?void 0:T.map(e=>"."+e).join(", "),we=t("div",H?{className:`${rs.noFiles} ant-layout-sider-light`,children:[e(ki,{size:48,className:rs.noFilesIcon}),e("div",{className:`${rs.textTitle_trash} ant-menu-submenu-title`,children:F("Trash is empty")}),e("div",{className:`${rs.textDescription_trash} ant-menu-submenu-title`,children:F("Deleted files will be displayed here")})]}:{className:rs.uploadContainer,children:[t("div",{className:`${rs.uploadArea} `,onClick:I,children:[e("div",{className:rs.uploadIcon,children:e(O,{})}),e("div",{className:rs.textTitle,children:F("Click here to select a file")}),e("div",{className:rs.textDescription,children:F("Supported files:")+" "+(be||"jpeg, .svg, .png")})]}),t("div",{className:rs.buttons,children:[t("button",{className:rs.btnPhoto,onClick:()=>{V&&V(an)},children:[e("div",{className:rs.icon,children:e(P,{})}),t("div",{className:rs.blockText,children:[e("div",{className:rs.textTitle,children:F("Stock")}),e("div",{className:rs.textDescription,children:F("Select an image from our library")})]})]}),t("button",{className:rs.btnAi,onClick:()=>{V&&V(ln)},children:[e("div",{className:rs.icon,children:e(M,{})}),t("div",{className:rs.blockText,children:[e("div",{className:rs.textTitle,children:F("AI generation")}),e("div",{className:rs.textDescription,children:F("Creating an image on demand")})]})]})]})]});return e("div",{className:`content-layout ${rs.contentLayout}`,children:g||0!==(null==n?void 0:n.length)||r?t("div",{className:rs.tableContainer,children:[e(as,{files:n,filesById:ie,currentSortOption:re,isSmallScreen:K,iconStrokeWidth:ne,features:te,viewMode:G,setViewMode:q,handleSearch:i,handleSortOptionChange:h,onClearSelection:v,onRename:y,onDelete:b,onCopy:w,onMove:x,onEdit:A,t:F}),e("div",{ref:ee,className:rs.filesContainer,children:ye}),!B&&f.total>f.pageSize&&e("div",{className:rs.paginationContainer,children:e($,{current:f.current,pageSize:f.pageSize,total:f.total,onChange:(e,t)=>p({current:e,pageSize:t,total:f.total}),showSizeChanger:!0,showTotal:e=>F("total pages",{total:e})})})]}):e("div",{className:rs.emptyStateWrapper,children:we})})});Ps.displayName="FileContent";var Ms="folderTree",Rs="emptyFolderContainer",Ls="folderItemContainer",Ns="folderLabel",Ds="folderLabelItem",js="fileCount",zs="foldersTitle",Bs="foldersTitleItem",Us="folderMenu";const Vs=({selectedFolder:n,onSelect:r,onExpand:i,generateMenuItems:s,fetchChildFolders:l,disabledFolders:u=[],showFileCounts:h=!1,folderFileCounts:f={},className:p="",expandedKeys:g,setExpandedKeys:m,showTrashFolder:v=!1,mode:y="navigation",defaultExpandAll:b=!1})=>{const{t:w}=Qn(),{options:x}=ro(),{config:C}=x,{ExpandArrowIcon:_,CollapseArrowIcon:S,CollapseFolderIcon:k,ExpandFolderIcon:A,EmptyFolderIcon:E}=oo(),I=c(e=>{const t=[],n=e=>{e.forEach(e=>{t.push(e.key),e.children&&n(e.children)})};return n(e),t},[]),[T,F]=o(()=>{if(b||"selection"===y&&b){const e=s();return I(e)}return[]}),O=void 0!==g?g:T,P=void 0!==m?m:F;a(()=>{if(b||"selection"===y&&b){const e=s(),t=I(e);void 0===g&&F(t)}},[b,y,s,I,g]);const M=c(async e=>{const t=e[0];t&&"empty"!==t&&!t.endsWith("_input")&&(null==r||r(e),await(null==l?void 0:l("folders"===t?null:t)))},[r,l]),R=c(async(e,t)=>{var n;P(e),null==i||i(e,t);if(!("lazy"===(null==C?void 0:C.folderTreeLoading)))return;const r=(null===(n=null==t?void 0:t.node)||void 0===n?void 0:n.key)||void 0;if(r&&"folders"!==r)try{await(null==l?void 0:l(r))}catch(e){console.warn("Failed to load child folders for",r,e)}},[null==C?void 0:C.folderTreeLoading,l,i,P]),L=c(()=>{var r,i;const o=s(),a=e=>e.filter(e=>"Trash"!==e.key).map(e=>Object.assign(Object.assign({},e),{children:e.children?a(e.children):void 0})),l=v?a(o):o,c=e=>{"selection"!==y?(O.includes(e)&&n===e?P(O.filter(t=>t!==e)):O.includes(e)||P([...O,e]),M([e])):M([e])},d=0===l.length||1===l.length&&(!l[0].children||0===l[0].children.length),p=n=>{var r;const i=h&&f[n.key]||0,o=O.includes(n.key),a=u.includes(n.key),s=(()=>{var t;return(null===(t=n.children)||void 0===t?void 0:t.length)?e(o?k:A,{size:20,strokeWidth:null==C?void 0:C.iconStrokeWidth}):e(E,{size:20,strokeWidth:null==C?void 0:C.iconStrokeWidth})})(),l=t("div",{className:`${Ls} folder-item-container`,onClick:()=>!a&&c(n.key),style:{opacity:a?.5:1,cursor:a?"not-allowed":"pointer"},children:[t("div",{className:Ns,children:[void 0!==n.icon?n.icon:s,e("span",{className:Ds,children:n.label})]}),h&&e("div",{className:js,title:`${i} ${1===i?"file":"files"}`,children:i})]});return{key:n.key,title:l,children:null===(r=n.children)||void 0===r?void 0:r.map(p),disabled:a}},g=O.includes("folders"),m=e("div",{className:zs,onClick:()=>c("folders"),children:t("div",{className:Bs,children:[e(g?k:A,{size:20,strokeWidth:null==C?void 0:C.iconStrokeWidth}),e("span",{className:`${Ds} folder-label-item`,children:"folders"===(null===(r=l[0])||void 0===r?void 0:r.key)?l[0].label:w("Folders")})]})}),b=()=>({key:"Trash",title:e("div",{className:zs,onClick:()=>c("Trash"),children:t("div",{className:Bs,children:[e(Si,{size:20,strokeWidth:null==C?void 0:C.iconStrokeWidth}),e("span",{className:Ds,children:w("Trash")})]})}),children:void 0});if(d){if(!v)return[{key:"empty",title:e("div",{className:Rs,children:w("No folders yet")}),disabled:!0}];const t=[];return l.length>0&&"folders"===l[0].key&&t.push({key:"folders",title:m,children:[]}),t.push(b()),t}if(l.length>0&&"folders"===l[0].key){const e=[{key:"folders",title:m,children:null===(i=l[0].children)||void 0===i?void 0:i.map(p)}];return v&&e.push(b()),e}return l.map(p)},[s,O,k,null==C?void 0:C.iconStrokeWidth,A,w,n,M,h,f,E,u,v,y,P]),N=d(()=>L(),[L]);return e(G,{className:`${Ms} ${Us} ${p}`,selectedKeys:n?[n]:[],expandedKeys:O,onSelect:M,onExpand:R,treeData:N,switcherIcon:({expanded:t})=>e(t?S:_,{}),showLine:!1})},Hs=({style:t={},wrap:n=!1})=>{const r=Object.assign({width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},t);return e(L,{size:"large",style:r,wrap:n,children:e(k,{})})};var Ws={formFooter:"formFooter",folderButton:"folderButton",foldersWrapper:"foldersWrapper",formItem:"formItem",folderToolsField:"folderToolsField",inputButtonOk:"inputButtonOk",permanentDeleteWarning:"permanentDeleteWarning",clearTrashProgress:"clearTrashProgress",progressText:"progressText",closeIcon:"closeIcon",modalContentWithLoader:"modalContentWithLoader",modalLoaderOverlay:"modalLoaderOverlay"};const $s=({folderId:r,activeFormField:i,EmptyFolderIcon:o,targetForm:a,handleModalOk:s,onComplete:l,setIsLoading:c,t:u})=>e(T.Item,{className:"form-item form-item-moveto "+(i===r?"form-item_active":""),name:"folderName",initialValue:u("New folder"),rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(u("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{className:"form-input",autoFocus:!0,prefix:e(o,{style:{marginRight:6}}),suffix:t(n,{children:[e(M,{placement:"top",title:"Clean",children:e(R,{icon:e(we,{style:{fontSize:10}}),className:Ws.inputButtonClose,type:"text",onClick:()=>{a.setFieldsValue({folderName:""})}})}),e(R,{className:Ws.inputButtonOk,type:"text",onClick:()=>{c(!0),s(a).then(e=>{const t=null==e?void 0:e.id;l(t)}).finally(()=>c(!1))},children:u("Create")})]})})});function Gs({folders:r,selectedFolder:o,EmptyFolderIcon:a,handleCreateFolderModalOk:s,setIsLoading:l,t:c}){const[u,d]=i.useState(""),h=i.useCallback((t,n)=>r=>e($s,{folderId:r,activeFormField:u,EmptyFolderIcon:a,targetForm:t,handleModalOk:s,onComplete:n,setIsLoading:l,t:c},r),[a,u,s,l,c]),f=i.useCallback(e=>{const{folderId:t,targetForm:n,onTreeSelect:r,onComplete:i}=e;return{handleAddFolder:e=>{e.preventDefault(),e.stopPropagation(),d(t),n.setFieldsValue({folderName:c("New folder"),targetFolder:t})},handleSelectFolder:e=>{e.preventDefault(),e.stopPropagation(),r([t]).then(()=>i(t))}}},[c]),p=i.useCallback(i=>{const{targetForm:a,onTreeSelect:s,onComplete:l,actionButtonText:d}=i,p=h(a,l),g=Array.isArray(r)?r:[],m=(r=null,i=new Set)=>g.filter(e=>{const t=null===r&&!e.parentId,n=e.parentId===r;return t||n}).map(r=>{if(i.has(r.id))return{key:r.id,label:`${r.name} (циклическая ссылка)`};const c=new Set(i);c.add(r.id);const h=m(r.id,c),{handleAddFolder:g,handleSelectFolder:v}=f({folderId:r.id,targetForm:a,onTreeSelect:s,onComplete:l}),y=u===r.id?[{key:`${r.id}_input`,label:p(r.id),icon:null},...h]:h;return{key:r.id,label:t(n,{children:[r.name,o!==r.id&&t("div",{className:`${Ws.folderToolsField} folder-tools-field`,children:[e(R,{onClick:g,children:"+"}),e(R,{onClick:v,children:d})]})]}),children:y}}),v=m(),{handleAddFolder:y,handleSelectFolder:b}=f({folderId:"folders",targetForm:a,onTreeSelect:s,onComplete:l}),w="folders"===u?[{key:"folders_input",label:p("folders"),icon:null},...v]:v;return[{key:"folders",label:t(n,{children:[c("Folders"),"folders"!==o&&null!==o&&t("div",{className:`${Ws.folderToolsField} folder-tools-field`,children:[e(R,{onClick:y,children:"+"}),e(R,{onClick:b,children:d})]})]}),children:w}]},[u,h,f,r,o,c]);return{activeFormField:u,setActiveFormField:d,generateMenuItemsFromFolders:p}}const qs=f(({folderId:t,activeFormField:n,EmptyFolderIcon:r,targetForm:i,handleModalOk:o,onComplete:a,t:s,setIsLoading:l,defaultFolderName:u})=>{const d=c(()=>{l(!0),o(i).then(e=>a(null==e?void 0:e.id)).finally(()=>l(!1))},[o,i,a,l]);return e(T.Item,{className:"form-item form-item-moveto "+(n===t?"form-item_active":""),name:"folderName",initialValue:u,rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(s("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{className:"form-input",autoFocus:!0,prefix:e(r,{style:{marginRight:6}}),suffix:e(R,{className:Ws.inputButtonOk,type:"text",onClick:()=>{l(!0),d()},children:s("Create")})})})});qs.displayName="CustomFolderInput";const Ys=({isModalVisible:r,handleModalOk:i,handleModalCancel:s,form:l,selectedFolder:u,folders:h,isUrlModalVisible:f,setIsUrlModalVisible:p,handleAddFileByUrl:g,urlForm:m,isRenameModalVisible:v,handleRenameOk:y,handleRenameCancel:b,renameForm:w,fileToRename:x,files:C,isMoveModalVisible:_,handleMoveOk:S,handleMoveCancel:k,moveForm:A,selectedFiles:E,isRenameFolderModalVisible:I,handleRenameFolderOk:O,handleRenameFolderCancel:P,renameFolderForm:M,folderToRename:L,isCopyModalVisible:N,handleCopyOk:D,handleCopyCancel:j,copyForm:z,isDeleteConfirmVisible:B,handleDeleteConfirmOk:U,handleDeleteConfirmCancel:V,isClearTrashConfirmVisible:H,handleClearTrashConfirm:W,handleClearTrashCancel:$,fetchChildFolders:G})=>{var X,K,Z;const{t:J}=Qn(),{state:Q,actions:ee,options:te}=ro(),{setCurrentMenuFile:ne}=ee,{config:re}=te,{currentMenuFile:ie}=Q,oe=T.useWatch("folderName",l),{EmptyFolderIcon:ae}=oo(),[se,le]=o(!1),ce=d(()=>{var e;return(null===(e=null==re?void 0:re.defaultFolderName)||void 0===e?void 0:e.trim())||J("New folder")},[null==re?void 0:re.defaultFolderName,J]),ue=!oe||0===String(oe).trim().length,de=d(()=>Array.isArray(C)?C:[],[C]),he=x?null===(X=de.find(e=>e.id===x))||void 0===X?void 0:X.name:"",fe=Array.isArray(h)?h:[],pe=L?null===(K=fe.find(e=>e.id===L))||void 0===K?void 0:K.name:"",{activeFormField:ge,setActiveFormField:me,generateMenuItemsFromFolders:ve}=Gs({folders:fe,selectedFolder:u,EmptyFolderIcon:ae,handleCreateFolderModalOk:i,setIsLoading:e=>le(Boolean(e)),t:J});a(()=>{if(B){const e=setTimeout(()=>{const e=document.querySelector(".deleteModal");if(e){const t=e.querySelector(".ant-modal-footer");if(t){const e=t.querySelector(".ant-btn-primary");e&&e.focus()}}},100);return()=>clearTimeout(e)}},[B]);const ye=x?de.find(e=>e.id===x):null,be=(null==ye?void 0:ye.isFolder)||(null==x?void 0:x.startsWith("folder_")),xe=c(async e=>{e.length>0&&(A.setFieldsValue({targetFolder:e[0]}),ge!==e[0].toString()&&me(""))},[A,ge,me]),Ce=c(async e=>{e.length>0&&(z.setFieldsValue({targetFolder:e[0]}),ge!==e[0].toString()&&me(""))},[ge,z,me]),_e=c(async e=>{le(!0);try{await S(e)}finally{le(!1)}},[S]),Se=c(async e=>{le(!0);try{await D(e)}finally{le(!1)}},[D]),ke=d(()=>{const e=Array.from(E).filter(e=>{const t=de.find(t=>t.id===e);return(null==t?void 0:t.isFolder)||h.some(t=>t.id===e)});return u&&"folders"!==u?e.push(u):u&&"folders"!==u||e.push("folders"),e},[E,de,h,u]);return t(n,{children:[e(q,{title:e("div",{className:"modal-title",children:J("Creating a new folder")}),open:r,onOk:()=>i(),onCancel:s,okText:J("Create"),cancelText:J("Cancel"),okButtonProps:{disabled:ue,loading:se},cancelButtonProps:{disabled:se},afterClose:()=>le(!1),children:t(T,{form:l,layout:"vertical",children:[e(T.Item,{name:"folderName",label:e("div",{className:"form-label",children:J("Folder name")}),rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(J("Enter the name of the folder"))):Promise.resolve()}],initialValue:ce,className:"form-item",style:{marginBottom:5},children:e(F,{autoFocus:!0,className:"form-input",disabled:se,placeholder:J("Enter the name"),onPressEnter:async()=>{le(!0);try{await l.validateFields(),ue||await i()}catch(e){le(!1)}}})}),e("div",{children:u&&"folders"!==u?t("p",{className:"fm-note",children:[J("A folder will be created inside:")," ",(null===(Z=fe.find(e=>e.id===u))||void 0===Z?void 0:Z.name)||J("selected folder"),"."]}):e("p",{className:"fm-note",children:J("The folder will be created in the root directory.")})})]})}),e(q,{title:e("div",{className:"modal-title",children:J("Upload file by URL")}),open:f,onOk:async()=>{le(!0);try{await m.validateFields();await g(null,void 0,void 0,"uploadByUrl")||le(!1)}catch(e){le(!1)}},onCancel:()=>p(!1),okText:J("Download"),okButtonProps:{loading:se},cancelText:J("Cancel"),cancelButtonProps:{disabled:se},afterClose:()=>le(!1),children:e(T,{form:m,layout:"vertical",children:e(T.Item,{name:"fileUrl",label:e("div",{className:"form-label",children:J("File URL")}),rules:[{required:!0,message:J("Enter the URL of the image")},{validator:(e,t)=>{if(!t||!String(t).trim())return Promise.resolve();try{return Yo(String(t),J),Promise.resolve()}catch(e){return Promise.reject(new Error(e instanceof Error?e.message:J("The specified URL is not valid.")))}}}],validateTrigger:"onBlur",className:"form-item",children:e(F,{className:"form-input",placeholder:"https://example.com/image.jpg",autoFocus:!0,disabled:se,onPressEnter:async()=>{le(!0);try{await m.validateFields();await g(null,void 0,void 0,"uploadByUrl")||le(!1)}catch(e){le(!1)}}})})})}),e(q,{title:e("div",{className:"modal-title",children:be?`${J("Rename folder")} ${he}`:J("Rename file",{currentFileName:he})}),open:v,onOk:y,okText:J("Rename"),okButtonProps:{loading:se},onCancel:b,cancelText:J("Cancel"),cancelButtonProps:{disabled:se},afterClose:()=>{le(!1),ne&&ne("")},children:e(T,{form:w,layout:"vertical",children:e(T.Item,{name:"newFileName",label:e("div",{className:"form-label",children:J(be?"New folder name":"New file name")}),rules:[{required:!0,message:J(be?"Enter a new folder name":"Enter a new file name")}],className:"form-item",children:e(F,{autoFocus:!0,className:"form-input",disabled:se,onPressEnter:async()=>{le(!0);try{await w.validateFields(),y()}catch(e){le(!1)}}})})})}),e(q,{title:e("div",{className:"modal-title",children:J("Move to")}),open:_,onCancel:k,footer:t("div",{className:Ws.formFooter,children:[t(R,{className:Ws.folderButton,onClick:()=>{const e=null!=u?u:"folders";me(e),A.setFieldsValue({folderName:ce,targetFolder:e})},loading:se,children:[e(ui,{size:18,strokeWidth:null==re?void 0:re.iconStrokeWidth}),J("Create folder")]}),e(R,{type:"primary",className:Ws.folderButton,onClick:k,loading:se,children:J("Done")})]}),afterClose:()=>{ne&&ne(""),me(""),le(!1)},loading:se,children:t("div",{className:Ws.modalContentWithLoader,children:[se&&e("div",{className:Ws.modalLoaderOverlay,children:e(Hs,{})}),e(T,{form:A,layout:"vertical",initialValues:{targetFolder:"folders",folderName:ce,is_force_create:!1},children:t("div",{className:Ws.foldersWrapper,children:[e(T.Item,{name:"targetFolder",rules:[{required:!0,message:J("Select the destination folder")}],className:Ws.formItem,children:e(Vs,{onSelect:xe,generateMenuItems:()=>ve({targetForm:A,onTreeSelect:xe,onComplete:_e,actionButtonText:J("Move here")}),fetchChildFolders:G,disabledFolders:ke,mode:"selection",className:"folderSelectionTree",defaultExpandAll:!0})}),e(T.Item,{name:"folderName",style:{display:"none"},rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(J("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{})}),e(T.Item,{name:"is_force_create",style:{display:"none"},children:e(F,{})})]})})]})}),e(q,{title:e("div",{className:"modal-title",children:J("Copy to folder")}),open:N,onCancel:j,footer:t("div",{className:Ws.formFooter,children:[t(R,{className:Ws.folderButton,onClick:()=>{const e=null!=u?u:"folders";me(e),z.setFieldsValue({folderName:ce,targetFolder:e})},loading:se,children:[e(ui,{size:18,strokeWidth:null==re?void 0:re.iconStrokeWidth}),J("Create folder")]}),e(R,{type:"primary",className:Ws.folderButton,onClick:j,loading:se,children:J("Done")})]}),afterClose:()=>{ne&&ne(""),me(""),le(!1)},loading:se,children:t("div",{className:Ws.modalContentWithLoader,children:[se&&e("div",{className:Ws.modalLoaderOverlay,children:e(Hs,{})}),e(T,{form:z,layout:"vertical",initialValues:{targetFolder:"folders",folderName:ce,is_force_create:!1},children:t("div",{className:Ws.foldersWrapper,children:[e(T.Item,{name:"targetFolder",rules:[{required:!0,message:J("Select the destination folder")}],className:Ws.formItem,children:e(Vs,{onSelect:Ce,generateMenuItems:()=>ve({targetForm:z,onTreeSelect:Ce,onComplete:Se,actionButtonText:J("Copy here")}),fetchChildFolders:G,disabledFolders:ke,mode:"selection",className:"folderSelectionTree",defaultExpandAll:!0})}),e(T.Item,{name:"folderName",style:{display:"none"},rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(J("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{})}),e(T.Item,{name:"is_force_create",style:{display:"none"},children:e(F,{})})]})})]})}),e(q,{title:t("div",{className:"modal-title",children:[J("Rename folder")," ",pe]}),open:I,onOk:O,onCancel:P,okText:J("Rename"),cancelText:J("Cancel"),okButtonProps:{loading:se},cancelButtonProps:{disabled:se},afterClose:()=>{le(!1),ne&&ne("")},children:e(T,{form:M,layout:"vertical",children:e(T.Item,{name:"newFolderName",label:e("div",{className:"form-label",children:J("New folder name")}),rules:[{required:!0,message:J("Enter a new folder name")}],className:"form-item",children:e(F,{autoFocus:!0,className:"form-input",disabled:se,onPressEnter:async()=>{le(!0);try{await M.validateFields(),O()}catch(e){le(!1)}}})})})}),e(q,{className:`${Ws.deleteModal} deleteModal`,title:(()=>{const t=!!(null==re?void 0:re.enableTrashFolder)&&"Trash"===u||!(null==re?void 0:re.enableTrashFolder),n=J(t?"Permanently delete":"Move to Trash");return e("div",{className:"modal-title",children:n})})(),open:!!B,onOk:()=>{le(!0);try{U&&U()}catch(e){console.error(e),le(!1)}},onCancel:()=>V&&V(),okText:(null==re?void 0:re.enableTrashFolder)&&"Trash"===u?J("Delete permanently"):(null==re?void 0:re.enableTrashFolder)?J("Move to Trash"):J("Delete"),cancelText:J("Cancel"),okButtonProps:{danger:!(null==re?void 0:re.enableTrashFolder)||"Trash"===u,loading:se},cancelButtonProps:{disabled:se},afterClose:()=>{le(!1),ne&&ne("")},closeIcon:e(we,{className:Ws.closeIcon}),children:(()=>{var n,r;const i=(ie?[ie]:Array.from(E||[])).map(e=>de.find(t=>t.id===e)).filter(e=>!!e),o=i.filter(e=>e.isFolder||e.id.startsWith("folder_")),a=i.filter(e=>!(e.isFolder||e.id.startsWith("folder_"))),s=i.length,l=o.length,c=a.length,d=!!(null==re?void 0:re.enableTrashFolder);if(!d||d&&"Trash"===u){let r;if(1===s&&1===l){const e=o[0],t=(null==e?void 0:e.name)||"",i=null!==(n=null==e?void 0:e.childCount)&&void 0!==n?n:0;r=J("delete_folder_permanent",{name:t,count:i})}else r=0===l&&c>0?J("delete_files_permanent",{count:c}):J("delete_mixed_permanent",{total:s,folders:l,images:c});return t("div",{children:[e("div",{children:r}),e("p",{className:Ws.permanentDeleteWarning,children:J("permanent_delete_warning")})]})}if(1===s&&1===l){const t=o[0],n=(null==t?void 0:t.name)||"",i=null!==(r=null==t?void 0:t.childCount)&&void 0!==r?r:0;return e("div",{children:J("move_folder_to_trash",{name:n,count:i})})}return e("div",0===l&&c>0?{children:J("move_files_to_trash",{count:c})}:{children:J("move_mixed_to_trash",{total:s,folders:l,images:c})})})()}),t(q,{className:`${Ws.deleteModal} deleteModal`,title:e("div",{className:"modal-title",children:J("Clear Trash")}),open:!!H,onOk:async()=>{le(!0),W&&await W(),le(!1)},onCancel:()=>$&&$(),okText:J("Delete permanently"),cancelText:J("Cancel"),okButtonProps:{danger:!0,loading:se},cancelButtonProps:{disabled:se},afterClose:()=>{le(!1)},closeIcon:e(we,{className:Ws.closeIcon}),children:[e("div",{children:J("Are you sure you want to permanently delete all items from Trash?")}),se&&t("div",{className:Ws.clearTrashProgress,children:[e(Y,{percent:99,status:"active",showInfo:!1}),e("div",{className:Ws.progressText,children:J("Deleting items...")})]})]})]})};var Xs={button:"button",folderActions:"folderActions",uploadButton:"uploadButton",foldersContainer:"foldersContainer",buttonWrapper:"buttonWrapper",uploadButtonTitle:"uploadButtonTitle"};const Ks=f(p(({selectedFolder:n,generateMenuItems:r,onFolderSelect:i,folders:s,fetchChildFolders:l,handleAddFile:h,setIsUrlModalVisible:f,handleCreateFolder:p,activeLibraryItem:m,setActiveLibraryItem:v},y)=>{var b,w,x;const C=d(()=>Array.isArray(s)?s:[],[s]),{t:_}=Qn(),S=bo(),[k,A]=o({}),{options:E}=ro(),{dataProviders:I,config:T}=E,F=!1!==(null===(b=null==T?void 0:T.features)||void 0===b?void 0:b.enableGif)&&(!(null==T?void 0:T.enabledTabs)||T.enabledTabs.includes("gif")),O=!1!==(null===(w=null==T?void 0:T.features)||void 0===w?void 0:w.enableStockImages)&&(!(null==T?void 0:T.enabledTabs)||T.enabledTabs.includes("stock")),P=!1!==(null===(x=null==T?void 0:T.features)||void 0===x?void 0:x.enableIconStock)&&(!(null==T?void 0:T.enabledTabs)||T.enabledTabs.includes("icons")),M=c(e=>{const t=[],n=e=>{e.forEach(e=>{t.push(e.key),e.children&&n(e.children)})};return n(e),t},[]),[L,N]=o(()=>{if(!0===(null==T?void 0:T.expandAllFoldersOnInit)&&"lazy"!==(null==T?void 0:T.folderTreeLoading)){const e=r();return M(e)}return!0===(null==T?void 0:T.expandRootFolderOnInit)?["folders"]:[]}),D=u(!1),j=u(!1);a(()=>{if(D.current)return;"lazy"===(null==T?void 0:T.folderTreeLoading)&&!0===(null==T?void 0:T.expandRootFolderOnInit)&&(D.current=!0,(async()=>{try{await(null==l?void 0:l(null))}catch(e){console.warn("Could not load the root child folders during initialization",e)}})())},[null==T?void 0:T.folderTreeLoading,null==T?void 0:T.expandRootFolderOnInit,l]),a(()=>{!0===(null==T?void 0:T.expandRootFolderOnInit)&&Array.isArray(C)&&C.length>0&&(j.current||L&&0!==L.length||(j.current=!0,N(["folders"])))},[null==T?void 0:T.expandRootFolderOnInit,C,L]),a(()=>{if(!0===(null==T?void 0:T.expandAllFoldersOnInit)&&"lazy"!==(null==T?void 0:T.folderTreeLoading)){const e=r(),t=M(e);return void N(t)}!0===(null==T?void 0:T.expandRootFolderOnInit)&&N(e=>e&&e.length>0?[...e]:["folders"])},[C,r,M,null==T?void 0:T.expandAllFoldersOnInit,null==T?void 0:T.folderTreeLoading,null==T?void 0:T.expandRootFolderOnInit]);const z=null==T?void 0:T.disablePagination,B=c(async e=>{var t,n,r,i;try{if(null==I?void 0:I.getChildrenCount)return await I.getChildrenCount("folders"===e?void 0:e);if(null==I?void 0:I.getFiles){const{files:n,pagination:r}=await I.getFiles({folderId:"folders"===e?void 0:e,itemType:"all",page:z?void 0:1,limit:z?void 0:1});return z?Array.isArray(n)?n.length:0:null!==(t=null==r?void 0:r.total)&&void 0!==t?t:Array.isArray(n)?n.length:0}return 0}catch(t){if("StaleLoad"===(null==t?void 0:t.name))return 0;const o=t;return 404===(null==o?void 0:o.status)||"FileNotFound"===(null==o?void 0:o.code)||"path_folder_not_found"===(null==o?void 0:o.code)||"path_folder_not_found"===(null===(n=null==o?void 0:o.data)||void 0===n?void 0:n.code)||404===(null===(i=null===(r=null==o?void 0:o.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.status)||(console.error(`Error getting the number of files for the folder ${e}:`,t),S.error({id:"FOLDER_CHILDREN_COUNT_FAILED",message:_("Failed to load folder items count"),placement:"bottomRight",innerException:t,data:{folderId:"folders"===e?null:e,reason:t instanceof Error?t.message:String(t)}})),0}},[I,S,_,z]),U=c(async()=>{if(0===C.length)return;const e={};e.folders=await B("folders");const t=C.map(async t=>{"number"!=typeof t.childCount?e[t.id]=await B(t.id):e[t.id]=t.childCount});await Promise.all(t),A(e)},[C,B]),V=c(async e=>{const t=await B(e);A(n=>Object.assign(Object.assign({},n),{[e]:t}))},[B]);g(y,()=>({refreshFileCounts:U}),[U]),a(()=>{U()},[U]),a(()=>{if(!n||"folders"===n)return;const e=(t,n=new Set)=>{if(n.has(t))return console.warn(`Cycle detected in the path to the folder with id=${t}`),[];const r=C.find(e=>e.id===t);if(!r)return[];if(!r.parentId)return[];const i=new Set(n);i.add(t);return[...e(r.parentId,i),r.parentId]},t=e(n);t.length>0?N(e=>{const n=new Set(e);return t.forEach(e=>n.add(e)),n.add("folders"),Array.from(n)}):N(e=>e.includes("folders")?e:[...e,"folders"])},[n,C]);const H=c(async()=>{await h(),n?await V(n):await V("folders")},[h,n,V]),W=[{key:rn,label:_("My files"),icon:e(fi,{size:20,strokeWidth:null==T?void 0:T.iconStrokeWidth})},{key:on,label:_("GIF"),icon:e(mi,{size:20,strokeWidth:null==T?void 0:T.iconStrokeWidth}),disabled:!F},{key:an,label:_("Stock images"),icon:e(ii,{size:20,strokeWidth:null==T?void 0:T.iconStrokeWidth}),disabled:!O},{key:sn,label:_("Icons"),icon:e(xe,{size:20}),disabled:!P},{key:ln,label:_("AI"),icon:e(xi,{size:20,strokeWidth:null==T?void 0:T.iconStrokeWidth}),disabled:!(null==T?void 0:T.sseQuery)}].filter(e=>!e.disabled),$=c(async e=>{const t=e[0];t&&"empty"!==t&&(m!==rn&&v(rn),null==i||i(t),await(null==l?void 0:l(t)))},[i,m,v,l]),G=c(({key:e})=>{v(e)},[v]),q=c(async(e,t)=>{var n;N(e);if(!("lazy"===(null==T?void 0:T.folderTreeLoading)))return;const r=(null===(n=null==t?void 0:t.node)||void 0===n?void 0:n.key)||void 0;if(r&&"folders"!==r)try{await(null==l?void 0:l(r))}catch(e){console.warn("Could not load the child folders for",r,e),S.error({id:"FOLDER_CHILDREN_FETCH_FAILED",message:_("Failed to load subfolders"),placement:"bottomRight",innerException:e,data:{folderId:r,reason:e instanceof Error?e.message:String(e)}})}},[null==T?void 0:T.folderTreeLoading,l,S,_]);return t("div",{className:"sidebar-container",children:[t("div",{className:Xs.buttonWrapper,children:[e(R,{type:"primary",size:"large",icon:e(vi,{size:24,strokeWidth:null==T?void 0:T.iconStrokeWidth}),onClick:H,className:Xs.uploadButton,style:{whiteSpace:"nowrap"},disabled:"Trash"===n,children:e("span",{className:Xs.uploadButtonTitle,children:_("Upload file")})}),e(R,{type:"primary",size:"large",icon:e(pi,{size:24,strokeWidth:null==T?void 0:T.iconStrokeWidth}),onClick:()=>null==f?void 0:f(!0),className:Xs.uploadByURLButton,style:{whiteSpace:"nowrap"},disabled:"Trash"===n})]}),e(X,{className:"folder-menu",items:W,defaultSelectedKeys:[rn],onSelect:({key:e})=>G({key:e}),selectedKeys:[m]}),e(K,{className:Xs.divider}),t("div",{className:Xs.foldersContainer,children:[e(Vs,{selectedFolder:n,onSelect:$,onExpand:q,generateMenuItems:r,fetchChildFolders:l,showFileCounts:!0,folderFileCounts:k,expandedKeys:L,setExpandedKeys:N,showTrashFolder:null==T?void 0:T.enableTrashFolder}),e("div",{className:Xs.folderActions,children:e(R,{onClick:e=>{e.stopPropagation(),p()},className:Xs.button,icon:e(ui,{size:18,strokeWidth:null==T?void 0:T.iconStrokeWidth}),size:"middle"})})]})]})}));Ks.displayName="FolderSidebar";var Zs=Object.defineProperty,Js=(e,t,n)=>(((e,t,n)=>{t in e?Zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);function Qs(e,t){return void 0===t&&(t=15),+parseFloat(Number(e).toPrecision(t))}function el(e){var t=e.toString().split(/[eE]/),n=(t[0].split(".")[1]||"").length-+(t[1]||0);return n>0?n:0}function tl(e){if(-1===e.toString().indexOf("e"))return Number(e.toString().replace(".",""));var t=el(e);return t>0?Qs(Number(e)*Math.pow(10,t)):Number(e)}function nl(e){ll&&(e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER)&&console.warn(e+" is beyond boundary when transfer to integer, the results may not be accurate")}function rl(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t[0];return t.slice(1).reduce(function(t,n){return e(t,n)},r)}}var il=rl(function(e,t){var n=tl(e),r=tl(t),i=el(e)+el(t),o=n*r;return nl(o),o/Math.pow(10,i)}),ol=rl(function(e,t){var n=Math.pow(10,Math.max(el(e),el(t)));return(il(e,n)+il(t,n))/n}),al=rl(function(e,t){var n=Math.pow(10,Math.max(el(e),el(t)));return(il(e,n)-il(t,n))/n}),sl=rl(function(e,t){var n=tl(e),r=tl(t);return nl(n),nl(r),il(n/r,Qs(Math.pow(10,el(t)-el(e))))});var ll=!0;var cl={strip:Qs,plus:ol,minus:al,times:il,divide:sl,round:function(e,t){var n=Math.pow(10,t),r=sl(Math.round(Math.abs(il(e,n))),n);return e<0&&0!==r&&(r=il(r,-1)),r},digitLength:el,float2Fixed:tl,enableBoundaryChecking:function(e){void 0===e&&(e=!0),ll=e}};const ul=Object.prototype.toString;function dl(e){switch(ul.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return xl(e,Error)}}function hl(e,t){return ul.call(e)===`[object ${t}]`}function fl(e){return hl(e,"ErrorEvent")}function pl(e){return hl(e,"DOMError")}function gl(e){return hl(e,"String")}function ml(e){return"object"==typeof e&&null!==e&&"__sentry_template_string__"in e&&"__sentry_template_values__"in e}function vl(e){return null===e||ml(e)||"object"!=typeof e&&"function"!=typeof e}function yl(e){return hl(e,"Object")}function bl(e){return typeof Event<"u"&&xl(e,Event)}function wl(e){return!(!e||!e.then||"function"!=typeof e.then)}function xl(e,t){try{return e instanceof t}catch{return!1}}function Cl(e){return!("object"!=typeof e||null===e||!e.__isVue&&!e._isVue)}function _l(e,t=0){return"string"!=typeof e||0===t||e.length<=t?e:`${e.slice(0,t)}...`}function Sl(e,t){if(!Array.isArray(e))return"";const n=[];for(let t=0;t<e.length;t++){const r=e[t];try{Cl(r)?n.push("[VueViewModel]"):n.push(String(r))}catch{n.push("[value cannot be serialized]")}}return n.join(t)}function kl(e,t,n=!1){return!!gl(e)&&(function(e){return hl(e,"RegExp")}(t)?t.test(e):!!gl(t)&&(n?e===t:e.includes(t)))}function Al(e,t=[],n=!1){return t.some(t=>kl(e,t,n))}function El(e,t,n=250,r,i,o,a){if(!(o.exception&&o.exception.values&&a&&xl(a.originalException,Error)))return;const s=o.exception.values.length>0?o.exception.values[o.exception.values.length-1]:void 0;s&&(o.exception.values=function(e,t){return e.map(e=>(e.value&&(e.value=_l(e.value,t)),e))}(Il(e,t,i,a.originalException,r,o.exception.values,s,0),n))}function Il(e,t,n,r,i,o,a,s){if(o.length>=n+1)return o;let l=[...o];if(xl(r[i],Error)){Tl(a,s);const o=e(t,r[i]),c=l.length;Fl(o,i,c,s),l=Il(e,t,n,r[i],i,[o,...l],o,c)}return Array.isArray(r.errors)&&r.errors.forEach((r,o)=>{if(xl(r,Error)){Tl(a,s);const c=e(t,r),u=l.length;Fl(c,`errors[${o}]`,u,s),l=Il(e,t,n,r,i,[c,...l],c,u)}}),l}function Tl(e,t){e.mechanism=e.mechanism||{type:"generic",handled:!0},e.mechanism={...e.mechanism,..."AggregateError"===e.type&&{is_exception_group:!0},exception_id:t}}function Fl(e,t,n,r){e.mechanism=e.mechanism||{type:"generic",handled:!0},e.mechanism={...e.mechanism,type:"chained",source:t,exception_id:n,parent_id:r}}function Ol(e){return e&&e.Math==Math?e:void 0}const Pl="object"==typeof globalThis&&Ol(globalThis)||"object"==typeof window&&Ol(window)||"object"==typeof self&&Ol(self)||"object"==typeof global&&Ol(global)||function(){return this}()||{};function Ml(){return Pl}function Rl(e,t,n){const r=n||Pl,i=r.__SENTRY__=r.__SENTRY__||{};return i[e]||(i[e]=t())}const Ll=Ml();function Nl(e,t={}){if(!e)return"<unknown>";try{let n=e;const r=5,i=[];let o=0,a=0;const s=" > ",l=s.length;let c;const u=Array.isArray(t)?t:t.keyAttrs,d=!Array.isArray(t)&&t.maxStringLength||80;for(;n&&o++<r&&(c=Dl(n,u),!("html"===c||o>1&&a+i.length*l+c.length>=d));)i.push(c),a+=c.length,n=n.parentNode;return i.reverse().join(s)}catch{return"<unknown>"}}function Dl(e,t){const n=e,r=[];let i,o,a,s,l;if(!n||!n.tagName)return"";if(Ll.HTMLElement&&n instanceof HTMLElement&&n.dataset&&n.dataset.sentryComponent)return n.dataset.sentryComponent;r.push(n.tagName.toLowerCase());const c=t&&t.length?t.filter(e=>n.getAttribute(e)).map(e=>[e,n.getAttribute(e)]):null;if(c&&c.length)c.forEach(e=>{r.push(`[${e[0]}="${e[1]}"]`)});else if(n.id&&r.push(`#${n.id}`),i=n.className,i&&gl(i))for(o=i.split(/\s+/),l=0;l<o.length;l++)r.push(`.${o[l]}`);const u=["aria-label","type","name","title","alt"];for(l=0;l<u.length;l++)a=u[l],s=n.getAttribute(a),s&&r.push(`[${a}="${s}"]`);return r.join("")}const jl=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,zl=["debug","info","warn","error","log","assert","trace"],Bl={};function Ul(e){if(!("console"in Pl))return e();const t=Pl.console,n={},r=Object.keys(Bl);r.forEach(e=>{const r=Bl[e];n[e]=t[e],t[e]=r});try{return e()}finally{r.forEach(e=>{t[e]=n[e]})}}const Vl=function(){let e=!1;const t={enable:()=>{e=!0},disable:()=>{e=!1},isEnabled:()=>e};return jl?zl.forEach(n=>{t[n]=(...t)=>{e&&Ul(()=>{Pl.console[n](`Sentry Logger [${n}]:`,...t)})}}):zl.forEach(e=>{t[e]=()=>{}}),t}(),Hl=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;function Wl(e,t=!1){const{host:n,path:r,pass:i,port:o,projectId:a,protocol:s,publicKey:l}=e;return`${s}://${l}${t&&i?`:${i}`:""}@${n}${o?`:${o}`:""}/${r&&`${r}/`}${a}`}function $l(e){return{protocol:e.protocol,publicKey:e.publicKey||"",pass:e.pass||"",host:e.host,port:e.port||"",path:e.path||"",projectId:e.projectId}}function Gl(e){const t="string"==typeof e?function(e){const t=Hl.exec(e);if(!t)return void Ul(()=>{console.error(`Invalid Sentry Dsn: ${e}`)});const[n,r,i="",o,a="",s]=t.slice(1);let l="",c=s;const u=c.split("/");if(u.length>1&&(l=u.slice(0,-1).join("/"),c=u.pop()),c){const e=c.match(/^\d+/);e&&(c=e[0])}return $l({host:o,pass:i,path:l,projectId:c,port:a,protocol:n,publicKey:r})}(e):$l(e);if(t&&function(e){if(!jl)return!0;const{port:t,projectId:n,protocol:r}=e;return!(["protocol","publicKey","host","projectId"].find(t=>!e[t]&&(Vl.error(`Invalid Sentry Dsn: ${t} missing`),!0))||(n.match(/^\d+$/)?function(e){return"http"===e||"https"===e}(r)?t&&isNaN(parseInt(t,10))&&(Vl.error(`Invalid Sentry Dsn: Invalid port ${t}`),1):(Vl.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),1):(Vl.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),1)))}(t))return t}class ql extends Error{constructor(e,t="warn"){super(e),this.message=e,this.name=new.target.prototype.constructor.name,Object.setPrototypeOf(this,new.target.prototype),this.logLevel=t}}function Yl(e,t,n){if(!(t in e))return;const r=e[t],i=n(r);"function"==typeof i&&Kl(i,r),e[t]=i}function Xl(e,t,n){try{Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0})}catch{jl&&Vl.log(`Failed to add non-enumerable property "${t}" to object`,e)}}function Kl(e,t){try{const n=t.prototype||{};e.prototype=t.prototype=n,Xl(e,"__sentry_original__",t)}catch{}}function Zl(e){return e.__sentry_original__}function Jl(e){if(dl(e))return{message:e.message,name:e.name,stack:e.stack,...ec(e)};if(bl(e)){const t={type:e.type,target:Ql(e.target),currentTarget:Ql(e.currentTarget),...ec(e)};return typeof CustomEvent<"u"&&xl(e,CustomEvent)&&(t.detail=e.detail),t}return e}function Ql(e){try{return function(e){return typeof Element<"u"&&xl(e,Element)}(e)?Nl(e):Object.prototype.toString.call(e)}catch{return"<unknown>"}}function ec(e){if("object"==typeof e&&null!==e){const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}return{}}function tc(e){return nc(e,new Map)}function nc(e,t){if(function(e){if(!yl(e))return!1;try{const t=Object.getPrototypeOf(e).constructor.name;return!t||"Object"===t}catch{return!0}}(e)){const n=t.get(e);if(void 0!==n)return n;const r={};t.set(e,r);for(const n of Object.keys(e))typeof e[n]<"u"&&(r[n]=nc(e[n],t));return r}if(Array.isArray(e)){const n=t.get(e);if(void 0!==n)return n;const r=[];return t.set(e,r),e.forEach(e=>{r.push(nc(e,t))}),r}return e}const rc=/\(error: (.*)\)/,ic=/captureMessage|captureException/;function oc(...e){const t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,n=0)=>{const r=[],i=e.split("\n");for(let e=n;e<i.length;e++){const n=i[e];if(n.length>1024)continue;const o=rc.test(n)?n.replace(rc,"$1"):n;if(!o.match(/\S*Error: /)){for(const e of t){const t=e(o);if(t){r.push(t);break}}if(r.length>=50)break}}return function(e){if(!e.length)return[];const t=Array.from(e);return/sentryWrapped/.test(t[t.length-1].function||"")&&t.pop(),t.reverse(),ic.test(t[t.length-1].function||"")&&(t.pop(),ic.test(t[t.length-1].function||"")&&t.pop()),t.slice(0,50).map(e=>({...e,filename:e.filename||t[t.length-1].filename,function:e.function||"?"}))}(r)}}function ac(e){return Array.isArray(e)?oc(...e):e}const sc="<anonymous>";function lc(e){try{return e&&"function"==typeof e&&e.name||sc}catch{return sc}}const cc={},uc={};function dc(e,t){cc[e]=cc[e]||[],cc[e].push(t)}function hc(e,t){uc[e]||(t(),uc[e]=!0)}function fc(e,t){const n=e&&cc[e];if(n)for(const r of n)try{r(t)}catch(t){jl&&Vl.error(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${lc(r)}\nError:`,t)}}function pc(){"console"in Pl&&zl.forEach(function(e){e in Pl.console&&Yl(Pl.console,e,function(t){return Bl[e]=t,function(...t){fc("console",{args:t,level:e});const n=Bl[e];n&&n.apply(Pl.console,t)}})})}function gc(){const e=Pl,t=e.crypto||e.msCrypto;let n=()=>16*Math.random();try{if(t&&t.randomUUID)return t.randomUUID().replace(/-/g,"");t&&t.getRandomValues&&(n=()=>{const e=new Uint8Array(1);return t.getRandomValues(e),e[0]})}catch{}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,e=>(e^(15&n())>>e/4).toString(16))}function mc(e){return e.exception&&e.exception.values?e.exception.values[0]:void 0}function vc(e){const{message:t,event_id:n}=e;if(t)return t;const r=mc(e);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||"<unknown>":n||"<unknown>"}function yc(e,t,n){const r=e.exception=e.exception||{},i=r.values=r.values||[],o=i[0]=i[0]||{};o.value||(o.value=t||""),o.type||(o.type="Error")}function bc(e,t){const n=mc(e);if(!n)return;const r=n.mechanism;if(n.mechanism={type:"generic",handled:!0,...r,...t},t&&"data"in t){const e={...r&&r.data,...t.data};n.mechanism.data=e}}function wc(e){if(e&&e.__sentry_captured__)return!0;try{Xl(e,"__sentry_captured__",!0)}catch{}return!1}function xc(e){return Array.isArray(e)?e:[e]}const Cc=Pl;let _c,Sc,kc;function Ac(){if(!Cc.document)return;const e=fc.bind(null,"dom"),t=Ec(e,!0);Cc.document.addEventListener("click",t,!1),Cc.document.addEventListener("keypress",t,!1),["EventTarget","Node"].forEach(t=>{const n=Cc[t]&&Cc[t].prototype;!n||!n.hasOwnProperty||!n.hasOwnProperty("addEventListener")||(Yl(n,"addEventListener",function(t){return function(n,r,i){if("click"===n||"keypress"==n)try{const r=this,o=r.__sentry_instrumentation_handlers__=r.__sentry_instrumentation_handlers__||{},a=o[n]=o[n]||{refCount:0};if(!a.handler){const r=Ec(e);a.handler=r,t.call(this,n,r,i)}a.refCount++}catch{}return t.call(this,n,r,i)}}),Yl(n,"removeEventListener",function(e){return function(t,n,r){if("click"===t||"keypress"==t)try{const n=this,i=n.__sentry_instrumentation_handlers__||{},o=i[t];o&&(o.refCount--,o.refCount<=0&&(e.call(this,t,o.handler,r),o.handler=void 0,delete i[t]),0===Object.keys(i).length&&delete n.__sentry_instrumentation_handlers__)}catch{}return e.call(this,t,n,r)}}))})}function Ec(e,t=!1){return n=>{if(!n||n._sentryCaptured)return;const r=function(e){try{return e.target}catch{return null}}(n);if(function(e,t){return!("keypress"!==e||t&&t.tagName&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))}(n.type,r))return;Xl(n,"_sentryCaptured",!0),r&&!r._sentryId&&Xl(r,"_sentryId",gc());const i="keypress"===n.type?"input":n.type;(function(e){if(e.type!==Sc)return!1;try{if(!e.target||e.target._sentryId!==kc)return!1}catch{}return!0})(n)||(e({event:n,name:i,global:t}),Sc=n.type,kc=r?r._sentryId:void 0),clearTimeout(_c),_c=Cc.setTimeout(()=>{kc=void 0,Sc=void 0},1e3)}}const Ic=Ml();function Tc(){if(!("fetch"in Ic))return!1;try{return new Headers,new Request("http://www.example.com"),new Response,!0}catch{return!1}}function Fc(e){return e&&/^function fetch\(\)\s+\{\s+\[native code\]\s+\}$/.test(e.toString())}function Oc(){(function(){if("string"==typeof EdgeRuntime)return!0;if(!Tc())return!1;if(Fc(Ic.fetch))return!0;let e=!1;const t=Ic.document;if(t&&"function"==typeof t.createElement)try{const n=t.createElement("iframe");n.hidden=!0,t.head.appendChild(n),n.contentWindow&&n.contentWindow.fetch&&(e=Fc(n.contentWindow.fetch)),t.head.removeChild(n)}catch(e){jl&&Vl.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",e)}return e})()&&Yl(Pl,"fetch",function(e){return function(...t){const{method:n,url:r}=function(e){if(0===e.length)return{method:"GET",url:""};if(2===e.length){const[t,n]=e;return{url:Mc(t),method:Pc(n,"method")?String(n.method).toUpperCase():"GET"}}const t=e[0];return{url:Mc(t),method:Pc(t,"method")?String(t.method).toUpperCase():"GET"}}(t),i={args:t,fetchData:{method:n,url:r},startTimestamp:Date.now()};return fc("fetch",{...i}),e.apply(Pl,t).then(e=>(fc("fetch",{...i,endTimestamp:Date.now(),response:e}),e),e=>{throw fc("fetch",{...i,endTimestamp:Date.now(),error:e}),e})}})}function Pc(e,t){return!!e&&"object"==typeof e&&!!e[t]}function Mc(e){return"string"==typeof e?e:e?Pc(e,"url")?e.url:e.toString?e.toString():"":""}let Rc=null;function Lc(){Rc=Pl.onerror,Pl.onerror=function(e,t,n,r,i){return fc("error",{column:r,error:i,line:n,msg:e,url:t}),!(!Rc||Rc.__SENTRY_LOADER__)&&Rc.apply(this,arguments)},Pl.onerror.__SENTRY_INSTRUMENTED__=!0}let Nc=null;function Dc(){Nc=Pl.onunhandledrejection,Pl.onunhandledrejection=function(e){return fc("unhandledrejection",e),!(Nc&&!Nc.__SENTRY_LOADER__)||Nc.apply(this,arguments)},Pl.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}const jc=Ml();const zc=Pl;let Bc;function Uc(e){const t="history";dc(t,e),hc(t,Vc)}function Vc(){if(!function(){const e=jc.chrome,t=e&&e.app&&e.app.runtime,n="history"in jc&&!!jc.history.pushState&&!!jc.history.replaceState;return!t&&n}())return;const e=zc.onpopstate;function t(e){return function(...t){const n=t.length>2?t[2]:void 0;if(n){const e=Bc,t=String(n);Bc=t,fc("history",{from:e,to:t})}return e.apply(this,t)}}zc.onpopstate=function(...t){const n=zc.location.href,r=Bc;if(Bc=n,fc("history",{from:r,to:n}),e)try{return e.apply(this,t)}catch{}},Yl(zc.history,"pushState",t),Yl(zc.history,"replaceState",t)}const Hc=Pl,Wc="__sentry_xhr_v3__";function $c(){if(!Hc.XMLHttpRequest)return;const e=XMLHttpRequest.prototype;Yl(e,"open",function(e){return function(...t){const n=Date.now(),r=gl(t[0])?t[0].toUpperCase():void 0,i=function(e){if(gl(e))return e;try{return e.toString()}catch{}}(t[1]);if(!r||!i)return e.apply(this,t);this[Wc]={method:r,url:i,request_headers:{}},"POST"===r&&i.match(/sentry_key/)&&(this.__sentry_own_request__=!0);const o=()=>{const e=this[Wc];if(e&&4===this.readyState){try{e.status_code=this.status}catch{}fc("xhr",{args:[r,i],endTimestamp:Date.now(),startTimestamp:n,xhr:this})}};return"onreadystatechange"in this&&"function"==typeof this.onreadystatechange?Yl(this,"onreadystatechange",function(e){return function(...t){return o(),e.apply(this,t)}}):this.addEventListener("readystatechange",o),Yl(this,"setRequestHeader",function(e){return function(...t){const[n,r]=t,i=this[Wc];return i&&gl(n)&&gl(r)&&(i.request_headers[n.toLowerCase()]=r),e.apply(this,t)}}),e.apply(this,t)}}),Yl(e,"send",function(e){return function(...t){const n=this[Wc];if(!n)return e.apply(this,t);void 0!==t[0]&&(n.body=t[0]);return fc("xhr",{args:[n.method,n.url],startTimestamp:Date.now(),xhr:this}),e.apply(this,t)}})}function Gc(e,t=100,n=1/0){try{return Yc("",e,t,n)}catch(e){return{ERROR:`**non-serializable** (${e})`}}}function qc(e,t=3,n=102400){const r=Gc(e,t);return function(e){return function(e){return~-encodeURI(e).split(/%..|./).length}(JSON.stringify(e))}(r)>n?qc(e,t-1,n):r}function Yc(e,t,n=1/0,r=1/0,i=function(){const e="function"==typeof WeakSet,t=e?new WeakSet:[];return[function(n){if(e)return!!t.has(n)||(t.add(n),!1);for(let e=0;e<t.length;e++)if(t[e]===n)return!0;return t.push(n),!1},function(n){if(e)t.delete(n);else for(let e=0;e<t.length;e++)if(t[e]===n){t.splice(e,1);break}}]}()){const[o,a]=i;if(null==t||["number","boolean","string"].includes(typeof t)&&!function(e){return"number"==typeof e&&e!=e}(t))return t;const s=function(e,t){try{if("domain"===e&&t&&"object"==typeof t&&t._events)return"[Domain]";if("domainEmitter"===e)return"[DomainEmitter]";if(typeof global<"u"&&t===global)return"[Global]";if(typeof window<"u"&&t===window)return"[Window]";if(typeof document<"u"&&t===document)return"[Document]";if(Cl(t))return"[VueViewModel]";if(function(e){return yl(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e}(t))return"[SyntheticEvent]";if("number"==typeof t&&t!=t)return"[NaN]";if("function"==typeof t)return`[Function: ${lc(t)}]`;if("symbol"==typeof t)return`[${String(t)}]`;if("bigint"==typeof t)return`[BigInt: ${String(t)}]`;const n=function(e){const t=Object.getPrototypeOf(e);return t?t.constructor.name:"null prototype"}(t);return/^HTML(\w*)Element$/.test(n)?`[HTMLElement: ${n}]`:`[object ${n}]`}catch(e){return`**non-serializable** (${e})`}}(e,t);if(!s.startsWith("[object "))return s;if(t.__sentry_skip_normalization__)return t;const l="number"==typeof t.__sentry_override_normalization_depth__?t.__sentry_override_normalization_depth__:n;if(0===l)return s.replace("object ","");if(o(t))return"[Circular ~]";const c=t;if(c&&"function"==typeof c.toJSON)try{return Yc("",c.toJSON(),l-1,r,i)}catch{}const u=Array.isArray(t)?[]:{};let d=0;const h=Jl(t);for(const e in h){if(!Object.prototype.hasOwnProperty.call(h,e))continue;if(d>=r){u[e]="[MaxProperties ~]";break}const t=h[e];u[e]=Yc(e,t,l-1,r,i),d++}return a(t),u}var Xc;function Kc(e){return new Jc(t=>{t(e)})}function Zc(e){return new Jc((t,n)=>{n(e)})}!function(e){e[e.PENDING=0]="PENDING";e[e.RESOLVED=1]="RESOLVED";e[e.REJECTED=2]="REJECTED"}(Xc||(Xc={}));class Jc{constructor(e){Jc.prototype.__init.call(this),Jc.prototype.__init2.call(this),Jc.prototype.__init3.call(this),Jc.prototype.__init4.call(this),this._state=Xc.PENDING,this._handlers=[];try{e(this._resolve,this._reject)}catch(e){this._reject(e)}}then(e,t){return new Jc((n,r)=>{this._handlers.push([!1,t=>{if(e)try{n(e(t))}catch(e){r(e)}else n(t)},e=>{if(t)try{n(t(e))}catch(e){r(e)}else r(e)}]),this._executeHandlers()})}catch(e){return this.then(e=>e,e)}finally(e){return new Jc((t,n)=>{let r,i;return this.then(t=>{i=!1,r=t,e&&e()},t=>{i=!0,r=t,e&&e()}).then(()=>{i?n(r):t(r)})})}__init(){this._resolve=e=>{this._setResult(Xc.RESOLVED,e)}}__init2(){this._reject=e=>{this._setResult(Xc.REJECTED,e)}}__init3(){this._setResult=(e,t)=>{if(this._state===Xc.PENDING){if(wl(t))return void t.then(this._resolve,this._reject);this._state=e,this._value=t,this._executeHandlers()}}}__init4(){this._executeHandlers=()=>{if(this._state===Xc.PENDING)return;const e=this._handlers.slice();this._handlers=[],e.forEach(e=>{e[0]||(this._state===Xc.RESOLVED&&e[1](this._value),this._state===Xc.REJECTED&&e[2](this._value),e[0]=!0)})}}}function Qc(e){const t=[];function n(e){return t.splice(t.indexOf(e),1)[0]}return{$:t,add:function(r){if(!(void 0===e||t.length<e))return Zc(new ql("Not adding Promise because buffer limit was reached."));const i=r();return-1===t.indexOf(i)&&t.push(i),i.then(()=>n(i)).then(null,()=>n(i).then(null,()=>{})),i},drain:function(e){return new Jc((n,r)=>{let i=t.length;if(!i)return n(!0);const o=setTimeout(()=>{e&&e>0&&n(!1)},e);t.forEach(e=>{Kc(e).then(()=>{--i||(clearTimeout(o),n(!0))},r)})})}}}function eu(e){if(!e)return{};const t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};const n=t[6]||"",r=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],search:n,hash:r,relative:t[5]+n+r}}const tu=["fatal","error","warning","log","info","debug"];function nu(e){return"warn"===e?"warning":tu.includes(e)?e:"log"}function ru(){return Date.now()/1e3}const iu=function(){const{performance:e}=Pl;if(!e||!e.now)return ru;const t=Date.now()-e.now(),n=null==e.timeOrigin?t:e.timeOrigin;return()=>(n+e.now())/1e3}();function ou(e,t=[]){return[e,t]}function au(e,t){const[n,r]=e;return[n,[...r,t]]}function su(e,t){const n=e[1];for(const e of n){if(t(e,e[0].type))return!0}return!1}function lu(e,t){return(t||new TextEncoder).encode(e)}function cu(e,t){const[n,r]=e;let i=JSON.stringify(n);function o(e){"string"==typeof i?i="string"==typeof e?i+e:[lu(i,t),e]:i.push("string"==typeof e?lu(e,t):e)}for(const e of r){const[t,n]=e;if(o(`\n${JSON.stringify(t)}\n`),"string"==typeof n||n instanceof Uint8Array)o(n);else{let e;try{e=JSON.stringify(n)}catch{e=JSON.stringify(Gc(n))}o(e)}}return"string"==typeof i?i:function(e){const t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t);let r=0;for(const t of e)n.set(t,r),r+=t.length;return n}(i)}function uu(e,t){const n="string"==typeof e.data?lu(e.data,t):e.data;return[tc({type:"attachment",length:n.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType}),n]}(()=>{const{performance:e}=Pl;if(!e||!e.now)return;const t=36e5,n=e.now(),r=Date.now(),i=e.timeOrigin?Math.abs(e.timeOrigin+n-r):t,o=i<t,a=e.timing&&e.timing.navigationStart,s="number"==typeof a?Math.abs(a+n-r):t;(o||s<t)&&(i<=s&&e.timeOrigin)})();const du={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",feedback:"feedback",span:"span",statsd:"metric_bucket"};function hu(e){return du[e]}function fu(e){if(!e||!e.sdk)return;const{name:t,version:n}=e.sdk;return{name:t,version:n}}function pu(e,{statusCode:t,headers:n},r=Date.now()){const i={...e},o=n&&n["x-sentry-rate-limits"],a=n&&n["retry-after"];if(o)for(const e of o.trim().split(",")){const[t,n,,,o]=e.split(":",5),a=parseInt(t,10),s=1e3*(isNaN(a)?60:a);if(n)for(const e of n.split(";"))"metric_bucket"===e?(!o||o.split(";").includes("custom"))&&(i[e]=r+s):i[e]=r+s;else i.all=r+s}else a?i.all=r+function(e,t=Date.now()){const n=parseInt(`${e}`,10);if(!isNaN(n))return 1e3*n;const r=Date.parse(`${e}`);return isNaN(r)?6e4:r-t}(a,r):429===t&&(i.all=r+6e4);return i}const gu=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,mu="production";function vu(){return Rl("globalEventProcessors",()=>[])}function yu(e){vu().push(e)}function bu(e,t,n,r=0){return new Jc((i,o)=>{const a=e[r];if(null===t||"function"!=typeof a)i(t);else{const s=a({...t},n);gu&&a.id&&null===s&&Vl.log(`Event processor "${a.id}" dropped event`),wl(s)?s.then(t=>bu(e,t,n,r+1).then(i)).then(null,o):bu(e,s,n,r+1).then(i).then(null,o)}})}function wu(e){const t=iu(),n={sid:gc(),init:!0,timestamp:t,started:t,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(e){return tc({sid:`${e.sid}`,init:e.init,started:new Date(1e3*e.started).toISOString(),timestamp:new Date(1e3*e.timestamp).toISOString(),status:e.status,errors:e.errors,did:"number"==typeof e.did||"string"==typeof e.did?`${e.did}`:void 0,duration:e.duration,abnormal_mechanism:e.abnormal_mechanism,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}})}(n)};return e&&xu(n,e),n}function xu(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),!e.did&&!t.did&&(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||iu(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=32===t.sid.length?t.sid:gc()),void 0!==t.init&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),"number"==typeof t.started&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if("number"==typeof t.duration)e.duration=t.duration;else{const t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),"number"==typeof t.errors&&(e.errors=t.errors),t.status&&(e.status=t.status)}function Cu(e,t){let n={};"ok"===e.status&&(n={status:"exited"}),xu(e,n)}function _u(e){const{spanId:t,traceId:n}=e.spanContext(),{data:r,op:i,parent_span_id:o,status:a,tags:s,origin:l}=Su(e);return tc({data:r,op:i,parent_span_id:o,span_id:t,status:a,tags:s,trace_id:n,origin:l})}function Su(e){return function(e){return"function"==typeof e.getSpanJSON}(e)?e.getSpanJSON():"function"==typeof e.toJSON?e.toJSON():{}}function ku(e,t,n,r,i,o){const{normalizeDepth:a=3,normalizeMaxBreadth:s=1e3}=e,l={...t,event_id:t.event_id||n.event_id||gc(),timestamp:t.timestamp||ru()},c=n.integrations||e.integrations.map(e=>e.name);(function(e,t){const{environment:n,release:r,dist:i,maxValueLength:o=250}=t;"environment"in e||(e.environment="environment"in t?n:mu),void 0===e.release&&void 0!==r&&(e.release=r),void 0===e.dist&&void 0!==i&&(e.dist=i),e.message&&(e.message=_l(e.message,o));const a=e.exception&&e.exception.values&&e.exception.values[0];a&&a.value&&(a.value=_l(a.value,o));const s=e.request;s&&s.url&&(s.url=_l(s.url,o))})(l,e),function(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}(l,c),void 0===t.type&&function(e,t){const n=Pl._sentryDebugIds;if(!n)return;let r;const i=Au.get(t);i?r=i:(r=new Map,Au.set(t,r));const o=Object.keys(n).reduce((e,i)=>{let o;const a=r.get(i);a?o=a:(o=t(i),r.set(i,o));for(let t=o.length-1;t>=0;t--){const r=o[t];if(r.filename){e[r.filename]=n[i];break}}return e},{});try{e.exception.values.forEach(e=>{e.stacktrace.frames.forEach(e=>{e.filename&&(e.debug_id=o[e.filename])})})}catch{}}(l,e.stackParser);const u=function(e,t){if(!t)return e;const n=e?e.clone():new Vu;return n.update(t),n}(r,n.captureContext);n.mechanism&&bc(l,n.mechanism);const d=i&&i.getEventProcessors?i.getEventProcessors():[],h=(Uu||(Uu=new Vu),Uu).getScopeData();if(o){zu(h,o.getScopeData())}if(u){zu(h,u.getScopeData())}const f=[...n.attachments||[],...h.attachments];f.length&&(n.attachments=f),ju(l,h);return bu([...d,...vu(),...h.eventProcessors],l,n).then(e=>(e&&function(e){const t={};try{e.exception.values.forEach(e=>{e.stacktrace.frames.forEach(e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)})})}catch{}if(0===Object.keys(t).length)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];const n=e.debug_meta.images;Object.keys(t).forEach(e=>{n.push({type:"sourcemap",code_file:e,debug_id:t[e]})})}(e),"number"==typeof a&&a>0?function(e,t,n){if(!e)return null;const r={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map(e=>({...e,...e.data&&{data:Gc(e.data,t,n)}}))},...e.user&&{user:Gc(e.user,t,n)},...e.contexts&&{contexts:Gc(e.contexts,t,n)},...e.extra&&{extra:Gc(e.extra,t,n)}};return e.contexts&&e.contexts.trace&&r.contexts&&(r.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(r.contexts.trace.data=Gc(e.contexts.trace.data,t,n))),e.spans&&(r.spans=e.spans.map(e=>{const r=Su(e).data;return r&&(e.data=Gc(r,t,n)),e})),r}(e,a,s):e))}const Au=new WeakMap;function Eu(e,t){return Ku().captureEvent(e,t)}function Iu(e,t){Ku().addBreadcrumb(e,t)}function Tu(){return Ku().getClient()}function Fu(){return Ku().getScope()}function Ou(e){const t=Tu(),n=Zu(),r=Fu(),{release:i,environment:o=mu}=t&&t.getOptions()||{},{userAgent:a}=Pl.navigator||{},s=wu({release:i,environment:o,user:r.getUser()||n.getUser(),...a&&{userAgent:a},...e}),l=n.getSession();return l&&"ok"===l.status&&xu(l,{status:"exited"}),Pu(),n.setSession(s),r.setSession(s),s}function Pu(){const e=Zu(),t=Fu(),n=t.getSession()||e.getSession();n&&Cu(n),Mu(),e.setSession(),t.setSession()}function Mu(){const e=Zu(),t=Fu(),n=Tu(),r=t.getSession()||e.getSession();r&&n&&n.captureSession&&n.captureSession(r)}function Ru(e=!1){e?Pu():Mu()}function Lu(e){return e.transaction}function Nu(e,t,n){const r=t.getOptions(),{publicKey:i}=t.getDsn()||{},{segment:o}=n&&n.getUser()||{},a=tc({environment:r.environment||mu,release:r.release,user_segment:o,public_key:i,trace_id:e});return t.emit&&t.emit("createDsc",a),a}function Du(e){const t=Tu();if(!t)return{};const n=Nu(Su(e).trace_id||"",t,Fu()),r=Lu(e);if(!r)return n;const i=r&&r._frozenDynamicSamplingContext;if(i)return i;const{sampleRate:o,source:a}=r.metadata;null!=o&&(n.sample_rate=`${o}`);const s=Su(r);return a&&"url"!==a&&(n.transaction=s.description),n.sampled=String(function(e){const{traceFlags:t}=e.spanContext();return!!(1&t)}(r)),t.emit&&t.emit("createDsc",n),n}function ju(e,t){const{fingerprint:n,span:r,breadcrumbs:i,sdkProcessingMetadata:o}=t;(function(e,t){const{extra:n,tags:r,user:i,contexts:o,level:a,transactionName:s}=t,l=tc(n);l&&Object.keys(l).length&&(e.extra={...l,...e.extra});const c=tc(r);c&&Object.keys(c).length&&(e.tags={...c,...e.tags});const u=tc(i);u&&Object.keys(u).length&&(e.user={...u,...e.user});const d=tc(o);d&&Object.keys(d).length&&(e.contexts={...d,...e.contexts}),a&&(e.level=a),s&&(e.transaction=s)})(e,t),r&&function(e,t){e.contexts={trace:_u(t),...e.contexts};const n=Lu(t);if(n){e.sdkProcessingMetadata={dynamicSamplingContext:Du(t),...e.sdkProcessingMetadata};const r=Su(n).description;r&&(e.tags={transaction:r,...e.tags})}}(e,r),function(e,t){e.fingerprint=e.fingerprint?xc(e.fingerprint):[],t&&(e.fingerprint=e.fingerprint.concat(t)),e.fingerprint&&!e.fingerprint.length&&delete e.fingerprint}(e,n),function(e,t){const n=[...e.breadcrumbs||[],...t];e.breadcrumbs=n.length?n:void 0}(e,i),function(e,t){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t}}(e,o)}function zu(e,t){const{extra:n,tags:r,user:i,contexts:o,level:a,sdkProcessingMetadata:s,breadcrumbs:l,fingerprint:c,eventProcessors:u,attachments:d,propagationContext:h,transactionName:f,span:p}=t;Bu(e,"extra",n),Bu(e,"tags",r),Bu(e,"user",i),Bu(e,"contexts",o),Bu(e,"sdkProcessingMetadata",s),a&&(e.level=a),f&&(e.transactionName=f),p&&(e.span=p),l.length&&(e.breadcrumbs=[...e.breadcrumbs,...l]),c.length&&(e.fingerprint=[...e.fingerprint,...c]),u.length&&(e.eventProcessors=[...e.eventProcessors,...u]),d.length&&(e.attachments=[...e.attachments,...d]),e.propagationContext={...e.propagationContext,...h}}function Bu(e,t,n){if(n&&Object.keys(n).length){e[t]={...e[t]};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[t][r]=n[r])}}let Uu;class Vu{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext=Hu()}static clone(e){return e?e.clone():new Vu}clone(){const e=new Vu;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._extra={...this._extra},e._contexts={...this._contexts},e._user=this._user,e._level=this._level,e._span=this._span,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._requestSession=this._requestSession,e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e}setClient(e){this._client=e}getClient(){return this._client}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,segment:void 0,username:void 0},this._session&&xu(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(e){return this._requestSession=e,this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this._tags={...this._tags,[e]:t},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return null===t?delete this._contexts[e]:this._contexts[e]=t,this._notifyScopeListeners(),this}setSpan(e){return this._span=e,this._notifyScopeListeners(),this}getSpan(){return this._span}getTransaction(){const e=this._span;return e&&e.transaction}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;const t="function"==typeof e?e(this):e;if(t instanceof Vu){const e=t.getScopeData();this._tags={...this._tags,...e.tags},this._extra={...this._extra,...e.extra},this._contexts={...this._contexts,...e.contexts},e.user&&Object.keys(e.user).length&&(this._user=e.user),e.level&&(this._level=e.level),e.fingerprint.length&&(this._fingerprint=e.fingerprint),t.getRequestSession()&&(this._requestSession=t.getRequestSession()),e.propagationContext&&(this._propagationContext=e.propagationContext)}else if(yl(t)){const t=e;this._tags={...this._tags,...t.tags},this._extra={...this._extra,...t.extra},this._contexts={...this._contexts,...t.contexts},t.user&&(this._user=t.user),t.level&&(this._level=t.level),t.fingerprint&&(this._fingerprint=t.fingerprint),t.requestSession&&(this._requestSession=t.requestSession),t.propagationContext&&(this._propagationContext=t.propagationContext)}return this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this._attachments=[],this._propagationContext=Hu(),this}addBreadcrumb(e,t){const n="number"==typeof t?t:100;if(n<=0)return this;const r={timestamp:ru(),...e},i=this._breadcrumbs;return i.push(r),this._breadcrumbs=i.length>n?i.slice(-n):i,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}getAttachments(){return this.getScopeData().attachments}clearAttachments(){return this._attachments=[],this}getScopeData(){const{_breadcrumbs:e,_attachments:t,_contexts:n,_tags:r,_extra:i,_user:o,_level:a,_fingerprint:s,_eventProcessors:l,_propagationContext:c,_sdkProcessingMetadata:u,_transactionName:d,_span:h}=this;return{breadcrumbs:e,attachments:t,contexts:n,tags:r,extra:i,user:o,level:a,fingerprint:s||[],eventProcessors:l,propagationContext:c,sdkProcessingMetadata:u,transactionName:d,span:h}}applyToEvent(e,t={},n=[]){ju(e,this.getScopeData());return bu([...n,...vu(),...this._eventProcessors],e,t)}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata={...this._sdkProcessingMetadata,...e},this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,t){const n=t&&t.event_id?t.event_id:gc();if(!this._client)return Vl.warn("No client configured on scope - will not capture exception!"),n;const r=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:r,...t,event_id:n},this),n}captureMessage(e,t,n){const r=n&&n.event_id?n.event_id:gc();if(!this._client)return Vl.warn("No client configured on scope - will not capture message!"),r;const i=new Error(e);return this._client.captureMessage(e,t,{originalException:e,syntheticException:i,...n,event_id:r},this),r}captureEvent(e,t){const n=t&&t.event_id?t.event_id:gc();return this._client?(this._client.captureEvent(e,{...t,event_id:n},this),n):(Vl.warn("No client configured on scope - will not capture event!"),n)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}}function Hu(){return{traceId:gc(),spanId:gc().substring(16)}}const Wu="7.116.0",$u=parseFloat(Wu),Gu=100;class qu{constructor(e,t,n,r=$u){let i,o;this._version=r,t?i=t:(i=new Vu,i.setClient(e)),n?o=n:(o=new Vu,o.setClient(e)),this._stack=[{scope:i}],e&&this.bindClient(e),this._isolationScope=o}isOlderThan(e){return this._version<e}bindClient(e){const t=this.getStackTop();t.client=e,t.scope.setClient(e),e&&e.setupIntegrations&&e.setupIntegrations()}pushScope(){const e=this.getScope().clone();return this.getStack().push({client:this.getClient(),scope:e}),e}popScope(){return!(this.getStack().length<=1)&&!!this.getStack().pop()}withScope(e){const t=this.pushScope();let n;try{n=e(t)}catch(e){throw this.popScope(),e}return wl(n)?n.then(e=>(this.popScope(),e),e=>{throw this.popScope(),e}):(this.popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStack(){return this._stack}getStackTop(){return this._stack[this._stack.length-1]}captureException(e,t){const n=this._lastEventId=t&&t.event_id?t.event_id:gc(),r=new Error("Sentry syntheticException");return this.getScope().captureException(e,{originalException:e,syntheticException:r,...t,event_id:n}),n}captureMessage(e,t,n){const r=this._lastEventId=n&&n.event_id?n.event_id:gc(),i=new Error(e);return this.getScope().captureMessage(e,t,{originalException:e,syntheticException:i,...n,event_id:r}),r}captureEvent(e,t){const n=t&&t.event_id?t.event_id:gc();return e.type||(this._lastEventId=n),this.getScope().captureEvent(e,{...t,event_id:n}),n}lastEventId(){return this._lastEventId}addBreadcrumb(e,t){const{scope:n,client:r}=this.getStackTop();if(!r)return;const{beforeBreadcrumb:i=null,maxBreadcrumbs:o=Gu}=r.getOptions&&r.getOptions()||{};if(o<=0)return;const a={timestamp:ru(),...e},s=i?Ul(()=>i(a,t)):a;null!==s&&(r.emit&&r.emit("beforeAddBreadcrumb",s,t),n.addBreadcrumb(s,o))}setUser(e){this.getScope().setUser(e),this.getIsolationScope().setUser(e)}setTags(e){this.getScope().setTags(e),this.getIsolationScope().setTags(e)}setExtras(e){this.getScope().setExtras(e),this.getIsolationScope().setExtras(e)}setTag(e,t){this.getScope().setTag(e,t),this.getIsolationScope().setTag(e,t)}setExtra(e,t){this.getScope().setExtra(e,t),this.getIsolationScope().setExtra(e,t)}setContext(e,t){this.getScope().setContext(e,t),this.getIsolationScope().setContext(e,t)}configureScope(e){const{scope:t,client:n}=this.getStackTop();n&&e(t)}run(e){const t=Xu(this);try{e(this)}finally{Xu(t)}}getIntegration(e){const t=this.getClient();if(!t)return null;try{return t.getIntegration(e)}catch{return gu&&Vl.warn(`Cannot retrieve integration ${e.id} from the current Hub`),null}}startTransaction(e,t){const n=this._callExtensionMethod("startTransaction",e,t);return gu&&!n&&(this.getClient()?Vl.warn("Tracing extension 'startTransaction' has not been added. Call 'addTracingExtensions' before calling 'init':\nSentry.addTracingExtensions();\nSentry.init({...});\n"):Vl.warn("Tracing extension 'startTransaction' is missing. You should 'init' the SDK before calling 'startTransaction'")),n}traceHeaders(){return this._callExtensionMethod("traceHeaders")}captureSession(e=!1){if(e)return this.endSession();this._sendSessionUpdate()}endSession(){const e=this.getStackTop().scope,t=e.getSession();t&&Cu(t),this._sendSessionUpdate(),e.setSession()}startSession(e){const{scope:t,client:n}=this.getStackTop(),{release:r,environment:i=mu}=n&&n.getOptions()||{},{userAgent:o}=Pl.navigator||{},a=wu({release:r,environment:i,user:t.getUser(),...o&&{userAgent:o},...e}),s=t.getSession&&t.getSession();return s&&"ok"===s.status&&xu(s,{status:"exited"}),this.endSession(),t.setSession(a),a}shouldSendDefaultPii(){const e=this.getClient(),t=e&&e.getOptions();return!(!t||!t.sendDefaultPii)}_sendSessionUpdate(){const{scope:e,client:t}=this.getStackTop(),n=e.getSession();n&&t&&t.captureSession&&t.captureSession(n)}_callExtensionMethod(e,...t){const n=Yu().__SENTRY__;if(n&&n.extensions&&"function"==typeof n.extensions[e])return n.extensions[e].apply(this,t);gu&&Vl.warn(`Extension method ${e} couldn't be found, doing nothing.`)}}function Yu(){return Pl.__SENTRY__=Pl.__SENTRY__||{extensions:{},hub:void 0},Pl}function Xu(e){const t=Yu(),n=Ju(t);return Qu(t,e),n}function Ku(){const e=Yu();if(e.__SENTRY__&&e.__SENTRY__.acs){const t=e.__SENTRY__.acs.getCurrentHub();if(t)return t}return function(e=Yu()){return(!function(e){return!!(e&&e.__SENTRY__&&e.__SENTRY__.hub)}(e)||Ju(e).isOlderThan($u))&&Qu(e,new qu),Ju(e)}(e)}function Zu(){return Ku().getIsolationScope()}function Ju(e){return Rl("hub",()=>new qu,e)}function Qu(e,t){if(!e)return!1;return(e.__SENTRY__=e.__SENTRY__||{}).hub=t,!0}function ed(e,t,n,r){const i=fu(n),o=e.type&&"replay_event"!==e.type?e.type:"event";!function(e,t){t&&(e.sdk=e.sdk||{},e.sdk.name=e.sdk.name||t.name,e.sdk.version=e.sdk.version||t.version,e.sdk.integrations=[...e.sdk.integrations||[],...t.integrations||[]],e.sdk.packages=[...e.sdk.packages||[],...t.packages||[]])}(e,n&&n.sdk);const a=function(e,t,n,r){const i=e.sdkProcessingMetadata&&e.sdkProcessingMetadata.dynamicSamplingContext;return{event_id:e.event_id,sent_at:(new Date).toISOString(),...t&&{sdk:t},...!!n&&r&&{dsn:Wl(r)},...i&&{trace:tc({...i})}}}(e,i,r,t);return delete e.sdkProcessingMetadata,ou(a,[[{type:o},e]])}function td(e,t){return function(e){return Object.keys(e).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join("&")}({sentry_key:e.publicKey,sentry_version:"7",...t&&{sentry_client:`${t.name}/${t.version}`}})}const nd=[];function rd(e){const t=e.defaultIntegrations||[],n=e.integrations;let r;t.forEach(e=>{e.isDefaultInstance=!0}),r=Array.isArray(n)?[...t,...n]:"function"==typeof n?xc(n(t)):t;const i=function(e){const t={};return e.forEach(e=>{const{name:n}=e,r=t[n];r&&!r.isDefaultInstance&&e.isDefaultInstance||(t[n]=e)}),Object.keys(t).map(e=>t[e])}(r),o=function(e,t){for(let n=0;n<e.length;n++)if(!0===t(e[n]))return n;return-1}(i,e=>"Debug"===e.name);if(-1!==o){const[e]=i.splice(o,1);i.push(e)}return i}function id(e,t){for(const n of t)n&&n.afterAllSetup&&n.afterAllSetup(e)}function od(e,t,n){if(n[t.name])gu&&Vl.log(`Integration skipped because it was already installed: ${t.name}`);else{if(n[t.name]=t,-1===nd.indexOf(t.name)&&(t.setupOnce(yu,Ku),nd.push(t.name)),t.setup&&"function"==typeof t.setup&&t.setup(e),e.on&&"function"==typeof t.preprocessEvent){const n=t.preprocessEvent.bind(t);e.on("preprocessEvent",(t,r)=>n(t,r,e))}if(e.addEventProcessor&&"function"==typeof t.processEvent){const n=t.processEvent.bind(t),r=Object.assign((t,r)=>n(t,r,e),{id:t.name});e.addEventProcessor(r)}gu&&Vl.log(`Integration installed: ${t.name}`)}}function ad(e,t){return Object.assign(function(...e){return t(...e)},{id:e})}function sd(e,t,n,r){const i={sent_at:(new Date).toISOString()};n&&n.sdk&&(i.sdk={name:n.sdk.name,version:n.sdk.version}),r&&t&&(i.dsn=Wl(t));const o=function(e){const t=function(e){let t="";for(const n of e){const e=Object.entries(n.tags),r=e.length>0?`|#${e.map(([e,t])=>`${e}:${t}`).join(",")}`:"";t+=`${n.name}@${n.unit}:${n.metric}|${n.metricType}${r}|T${n.timestamp}\n`}return t}(e);return[{type:"statsd",length:t.length},t]}(e);return ou(i,[o])}const ld="Not capturing exception because it's already been captured.";class cd{constructor(e){if(this._options=e,this._integrations={},this._integrationsInitialized=!1,this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],e.dsn?this._dsn=Gl(e.dsn):gu&&Vl.warn("No DSN provided, client will not send events."),this._dsn){const t=function(e,t={}){const n="string"==typeof t?t:t.tunnel,r="string"!=typeof t&&t._metadata?t._metadata.sdk:void 0;return n||`${function(e){return`${function(e){const t=e.protocol?`${e.protocol}:`:"",n=e.port?`:${e.port}`:"";return`${t}//${e.host}${n}${e.path?`/${e.path}`:""}/api/`}(e)}${e.projectId}/envelope/`}(e)}?${td(e,r)}`}(this._dsn,e);this._transport=e.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:t})}}captureException(e,t,n){if(wc(e))return void(gu&&Vl.log(ld));let r=t&&t.event_id;return this._process(this.eventFromException(e,t).then(e=>this._captureEvent(e,t,n)).then(e=>{r=e})),r}captureMessage(e,t,n,r){let i=n&&n.event_id;const o=ml(e)?e:String(e),a=vl(e)?this.eventFromMessage(o,t,n):this.eventFromException(e,n);return this._process(a.then(e=>this._captureEvent(e,n,r)).then(e=>{i=e})),i}captureEvent(e,t,n){if(t&&t.originalException&&wc(t.originalException))return void(gu&&Vl.log(ld));let r=t&&t.event_id;const i=(e.sdkProcessingMetadata||{}).capturedSpanScope;return this._process(this._captureEvent(e,t,i||n).then(e=>{r=e})),r}captureSession(e){"string"!=typeof e.release?gu&&Vl.warn("Discarded session because of missing or non-string release"):(this.sendSession(e),xu(e,{init:!1}))}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(e){const t=this._transport;return t?(this.metricsAggregator&&this.metricsAggregator.flush(),this._isClientDoneProcessing(e).then(n=>t.flush(e).then(e=>n&&e))):Kc(!0)}close(e){return this.flush(e).then(e=>(this.getOptions().enabled=!1,this.metricsAggregator&&this.metricsAggregator.close(),e))}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}setupIntegrations(e){(e&&!this._integrationsInitialized||this._isEnabled()&&!this._integrationsInitialized)&&this._setupIntegrations()}init(){this._isEnabled()&&this._setupIntegrations()}getIntegrationById(e){return this.getIntegrationByName(e)}getIntegrationByName(e){return this._integrations[e]}getIntegration(e){try{return this._integrations[e.id]||null}catch{return gu&&Vl.warn(`Cannot retrieve integration ${e.id} from the current Client`),null}}addIntegration(e){const t=this._integrations[e.name];od(this,e,this._integrations),t||id(this,[e])}sendEvent(e,t={}){this.emit("beforeSendEvent",e,t);let n=ed(e,this._dsn,this._options._metadata,this._options.tunnel);for(const e of t.attachments||[])n=au(n,uu(e,this._options.transportOptions&&this._options.transportOptions.textEncoder));const r=this._sendEnvelope(n);r&&r.then(t=>this.emit("afterSendEvent",e,t),null)}sendSession(e){const t=function(e,t,n,r){const i=fu(n);return ou({sent_at:(new Date).toISOString(),...i&&{sdk:i},...!!r&&t&&{dsn:Wl(t)}},["aggregates"in e?[{type:"sessions"},e]:[{type:"session"},e.toJSON()]])}(e,this._dsn,this._options._metadata,this._options.tunnel);this._sendEnvelope(t)}recordDroppedEvent(e,t,n){if(this._options.sendClientReports){const n=`${e}:${t}`;gu&&Vl.log(`Adding outcome: "${n}"`),this._outcomes[n]=this._outcomes[n]+1||1}}captureAggregateMetrics(e){gu&&Vl.log(`Flushing aggregated metrics, number of metrics: ${e.length}`);const t=sd(e,this._dsn,this._options._metadata,this._options.tunnel);this._sendEnvelope(t)}on(e,t){this._hooks[e]||(this._hooks[e]=[]),this._hooks[e].push(t)}emit(e,...t){this._hooks[e]&&this._hooks[e].forEach(e=>e(...t))}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=function(e,t){const n={};return t.forEach(t=>{t&&od(e,t,n)}),n}(this,e),id(this,e),this._integrationsInitialized=!0}_updateSessionFromEvent(e,t){let n=!1,r=!1;const i=t.exception&&t.exception.values;if(i){r=!0;for(const e of i){const t=e.mechanism;if(t&&!1===t.handled){n=!0;break}}}const o="ok"===e.status;(o&&0===e.errors||o&&n)&&(xu(e,{...n&&{status:"crashed"},errors:e.errors||Number(r||n)}),this.captureSession(e))}_isClientDoneProcessing(e){return new Jc(t=>{let n=0;const r=setInterval(()=>{0==this._numProcessing?(clearInterval(r),t(!0)):(n+=1,e&&n>=e&&(clearInterval(r),t(!1)))},1)})}_isEnabled(){return!1!==this.getOptions().enabled&&void 0!==this._transport}_prepareEvent(e,t,n,r=Zu()){const i=this.getOptions(),o=Object.keys(this._integrations);return!t.integrations&&o.length>0&&(t.integrations=o),this.emit("preprocessEvent",e,t),ku(i,e,t,n,this,r).then(e=>{if(null===e)return e;const t={...r.getPropagationContext(),...n?n.getPropagationContext():void 0};if((!e.contexts||!e.contexts.trace)&&t){const{traceId:r,spanId:i,parentSpanId:o,dsc:a}=t;e.contexts={trace:{trace_id:r,span_id:i,parent_span_id:o},...e.contexts};const s=a||Nu(r,this,n);e.sdkProcessingMetadata={dynamicSamplingContext:s,...e.sdkProcessingMetadata}}return e})}_captureEvent(e,t={},n){return this._processEvent(e,t,n).then(e=>e.event_id,e=>{if(gu){const t=e;"log"===t.logLevel?Vl.log(t.message):Vl.warn(t)}})}_processEvent(e,t,n){const r=this.getOptions(),{sampleRate:i}=r,o=dd(e),a=ud(e),s=e.type||"error",l=`before send for type \`${s}\``;if(a&&"number"==typeof i&&Math.random()>i)return this.recordDroppedEvent("sample_rate","error",e),Zc(new ql(`Discarding event because it's not included in the random sample (sampling rate = ${i})`,"log"));const c="replay_event"===s?"replay":s,u=(e.sdkProcessingMetadata||{}).capturedSpanIsolationScope;return this._prepareEvent(e,t,n,u).then(n=>{if(null===n)throw this.recordDroppedEvent("event_processor",c,e),new ql("An event processor returned `null`, will not send event.","log");if(t.data&&!0===t.data.__sentry__)return n;const i=function(e,t,n){const{beforeSend:r,beforeSendTransaction:i}=e;return ud(t)&&r?r(t,n):dd(t)&&i?i(t,n):t}(r,n,t);return function(e,t){const n=`${t} must return \`null\` or a valid event.`;if(wl(e))return e.then(e=>{if(!yl(e)&&null!==e)throw new ql(n);return e},e=>{throw new ql(`${t} rejected with ${e}`)});if(!yl(e)&&null!==e)throw new ql(n);return e}(i,l)}).then(r=>{if(null===r)throw this.recordDroppedEvent("before_send",c,e),new ql(`${l} returned \`null\`, will not send event.`,"log");const i=n&&n.getSession();!o&&i&&this._updateSessionFromEvent(i,r);const a=r.transaction_info;if(o&&a&&r.transaction!==e.transaction){const e="custom";r.transaction_info={...a,source:e}}return this.sendEvent(r,t),r}).then(null,e=>{throw e instanceof ql?e:(this.captureException(e,{data:{__sentry__:!0},originalException:e}),new ql(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${e}`))})}_process(e){this._numProcessing++,e.then(e=>(this._numProcessing--,e),e=>(this._numProcessing--,e))}_sendEnvelope(e){if(this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport)return this._transport.send(e).then(null,e=>{gu&&Vl.error("Error while sending event:",e)});gu&&Vl.error("Transport disabled")}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.keys(e).map(t=>{const[n,r]=t.split(":");return{reason:n,category:r,quantity:e[t]}})}}function ud(e){return void 0===e.type}function dd(e){return"transaction"===e.type}function hd(e,t){!0===t.debug&&(gu?Vl.enable():Ul(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),Fu().update(t.initialScope);const n=new e(t);(function(e){const t=Ku().getStackTop();t.client=e,t.scope.setClient(e)})(n),function(e){e.init?e.init():e.setupIntegrations&&e.setupIntegrations()}(n)}function fd(e,t,n=Qc(e.bufferSize||30)){let r={};function i(i){const o=[];if(su(i,(t,n)=>{const i=hu(n);if(function(e,t,n=Date.now()){return function(e,t){return e[t]||e.all||0}(e,t)>n}(r,i)){const r=pd(t,n);e.recordDroppedEvent("ratelimit_backoff",i,r)}else o.push(t)}),0===o.length)return Kc();const a=ou(i[0],o),s=t=>{su(a,(n,r)=>{const i=pd(n,r);e.recordDroppedEvent(t,hu(r),i)})};return n.add(()=>t({body:cu(a,e.textEncoder)}).then(e=>(void 0!==e.statusCode&&(e.statusCode<200||e.statusCode>=300)&&gu&&Vl.warn(`Sentry responded with status code ${e.statusCode} to sent event.`),r=pu(r,e),e),e=>{throw s("network_error"),e})).then(e=>e,e=>{if(e instanceof ql)return gu&&Vl.error("Skipped sending event because buffer is full."),s("queue_overflow"),Kc();throw e})}return i.__sentry__baseTransport__=!0,{send:i,flush:e=>n.drain(e)}}function pd(e,t){if("event"===t||"transaction"===t)return Array.isArray(e)?e[1]:void 0}function gd(e,t,n=[t],r="npm"){const i=e._metadata||{};i.sdk||(i.sdk={name:`sentry.javascript.${t}`,packages:n.map(e=>({name:`${r}:@sentry/${e}`,version:Wu})),version:Wu}),e._metadata=i}const md=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/],vd=[/^.*\/healthcheck$/,/^.*\/healthy$/,/^.*\/live$/,/^.*\/ready$/,/^.*\/heartbeat$/,/^.*\/health$/,/^.*\/healthz$/],yd="InboundFilters",bd=(e={})=>({name:yd,setupOnce(){},processEvent(t,n,r){const i=r.getOptions(),o=function(e={},t={}){return{allowUrls:[...e.allowUrls||[],...t.allowUrls||[]],denyUrls:[...e.denyUrls||[],...t.denyUrls||[]],ignoreErrors:[...e.ignoreErrors||[],...t.ignoreErrors||[],...e.disableErrorDefaults?[]:md],ignoreTransactions:[...e.ignoreTransactions||[],...t.ignoreTransactions||[],...e.disableTransactionDefaults?[]:vd],ignoreInternal:void 0===e.ignoreInternal||e.ignoreInternal}}(e,i);return function(e,t){return t.ignoreInternal&&function(e){try{return"SentryError"===e.exception.values[0].type}catch{}return!1}(e)?(gu&&Vl.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${vc(e)}`),!0):function(e,t){return!(e.type||!t||!t.length)&&function(e){const t=[];let n;e.message&&t.push(e.message);try{n=e.exception.values[e.exception.values.length-1]}catch{}return n&&n.value&&(t.push(n.value),n.type&&t.push(`${n.type}: ${n.value}`)),gu&&0===t.length&&Vl.error(`Could not extract message for event ${vc(e)}`),t}(e).some(e=>Al(e,t))}(e,t.ignoreErrors)?(gu&&Vl.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${vc(e)}`),!0):function(e,t){if("transaction"!==e.type||!t||!t.length)return!1;const n=e.transaction;return!!n&&Al(n,t)}(e,t.ignoreTransactions)?(gu&&Vl.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.\nEvent: ${vc(e)}`),!0):function(e,t){if(!t||!t.length)return!1;const n=wd(e);return!!n&&Al(n,t)}(e,t.denyUrls)?(gu&&Vl.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${vc(e)}.\nUrl: ${wd(e)}`),!0):!function(e,t){if(!t||!t.length)return!0;const n=wd(e);return!n||Al(n,t)}(e,t.allowUrls)&&(gu&&Vl.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${vc(e)}.\nUrl: ${wd(e)}`),!0)}(t,o)?null:t}});function wd(e){try{let t;try{t=e.exception.values[0].stacktrace.frames}catch{}return t?function(e=[]){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n&&"<anonymous>"!==n.filename&&"[native code]"!==n.filename)return n.filename||null}return null}(t):null}catch{return gu&&Vl.error(`Cannot extract url for event ${vc(e)}`),null}}let xd;ad(yd,bd);const Cd="FunctionToString",_d=new WeakMap,Sd=()=>({name:Cd,setupOnce(){xd=Function.prototype.toString;try{Function.prototype.toString=function(...e){const t=Zl(this),n=_d.has(Tu())&&void 0!==t?t:this;return xd.apply(n,e)}}catch{}},setup(e){_d.set(e,!0)}});ad(Cd,Sd);const kd=Pl;let Ad=0;function Ed(){return Ad>0}function Id(e,t={},n){if("function"!=typeof e)return e;try{const t=e.__sentry_wrapped__;if(t)return t;if(Zl(e))return e}catch{return e}const r=function(){const r=Array.prototype.slice.call(arguments);try{n&&"function"==typeof n&&n.apply(this,arguments);const i=r.map(e=>Id(e,t));return e.apply(this,i)}catch(e){throw Ad++,setTimeout(()=>{Ad--}),function(...e){const t=Ku();if(2===e.length){const[n,r]=e;return n?t.withScope(()=>(t.getStackTop().scope=n,r(n))):t.withScope(r)}t.withScope(e[0])}(n=>{n.addEventProcessor(e=>(t.mechanism&&(yc(e,void 0),bc(e,t.mechanism)),e.extra={...e.extra,arguments:r},e)),function(e){Ku().captureException(e,void 0)}(e)}),e}};try{for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])}catch{}Kl(r,e),Xl(e,"__sentry_wrapped__",r);try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get:()=>e.name})}catch{}return r}const Td=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;function Fd(e,t){const n=Pd(e,t),r={type:t&&t.name,value:Rd(t)};return n.length&&(r.stacktrace={frames:n}),void 0===r.type&&""===r.value&&(r.value="Unrecoverable error caught"),r}function Od(e,t){return{exception:{values:[Fd(e,t)]}}}function Pd(e,t){const n=t.stacktrace||t.stack||"",r=function(e){if(e){if("number"==typeof e.framesToPop)return e.framesToPop;if(Md.test(e.message))return 1}return 0}(t);try{return e(n,r)}catch{}return[]}const Md=/Minified React error #\d+;/i;function Rd(e){const t=e&&e.message;return t?t.error&&"string"==typeof t.error.message?t.error.message:t:"No error message"}function Ld(e,t,n,r,i){let o;if(fl(t)&&t.error)return Od(e,t.error);if(pl(t)||function(e){return hl(e,"DOMException")}(t)){const i=t;if("stack"in t)o=Od(e,t);else{const t=i.name||(pl(i)?"DOMError":"DOMException"),a=i.message?`${t}: ${i.message}`:t;o=Nd(e,a,n,r),yc(o,a)}return"code"in i&&(o.tags={...o.tags,"DOMException.code":`${i.code}`}),o}return dl(t)?Od(e,t):yl(t)||bl(t)?(o=function(e,t,n,r){const i=Tu(),o=i&&i.getOptions().normalizeDepth,a={exception:{values:[{type:bl(t)?t.constructor.name:r?"UnhandledRejection":"Error",value:Dd(t,{isUnhandledRejection:r})}]},extra:{__serialized__:qc(t,o)}};if(n){const t=Pd(e,n);t.length&&(a.exception.values[0].stacktrace={frames:t})}return a}(e,t,n,i),bc(o,{synthetic:!0}),o):(o=Nd(e,t,n,r),yc(o,`${t}`),bc(o,{synthetic:!0}),o)}function Nd(e,t,n,r){const i={};if(r&&n){const r=Pd(e,n);r.length&&(i.exception={values:[{value:t,stacktrace:{frames:r}}]})}if(ml(t)){const{__sentry_template_string__:e,__sentry_template_values__:n}=t;return i.logentry={message:e,params:n},i}return i.message=t,i}function Dd(e,{isUnhandledRejection:t}){const n=function(e,t=40){const n=Object.keys(Jl(e));if(n.sort(),!n.length)return"[object has no keys]";if(n[0].length>=t)return _l(n[0],t);for(let e=n.length;e>0;e--){const r=n.slice(0,e).join(", ");if(!(r.length>t))return e===n.length?r:_l(r,t)}return""}(e),r=t?"promise rejection":"exception";return fl(e)?`Event \`ErrorEvent\` captured as ${r} with message \`${e.message}\``:bl(e)?`Event \`${function(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}(e)}\` (type=${e.type}) captured as ${r}`:`Object captured as ${r} with keys: ${n}`}class jd extends cd{constructor(e){gd(e,"browser",["browser"],kd.SENTRY_SDK_SOURCE||"npm"),super(e),e.sendClientReports&&kd.document&&kd.document.addEventListener("visibilitychange",()=>{"hidden"===kd.document.visibilityState&&this._flushOutcomes()})}eventFromException(e,t){return function(e,t,n,r){const i=Ld(e,t,n&&n.syntheticException||void 0,r);return bc(i),i.level="error",n&&n.event_id&&(i.event_id=n.event_id),Kc(i)}(this._options.stackParser,e,t,this._options.attachStacktrace)}eventFromMessage(e,t="info",n){return function(e,t,n="info",r,i){const o=Nd(e,t,r&&r.syntheticException||void 0,i);return o.level=n,r&&r.event_id&&(o.event_id=r.event_id),Kc(o)}(this._options.stackParser,e,t,n,this._options.attachStacktrace)}captureUserFeedback(e){if(!this._isEnabled())return void(Td&&Vl.warn("SDK not enabled, will not capture user feedback."));const t=function(e,{metadata:t,tunnel:n,dsn:r}){const i={event_id:e.event_id,sent_at:(new Date).toISOString(),...t&&t.sdk&&{sdk:{name:t.sdk.name,version:t.sdk.version}},...!!n&&!!r&&{dsn:Wl(r)}},o=function(e){return[{type:"user_report"},e]}(e);return ou(i,[o])}(e,{metadata:this.getSdkMetadata(),dsn:this.getDsn(),tunnel:this.getOptions().tunnel});this._sendEnvelope(t)}_prepareEvent(e,t,n){return e.platform=e.platform||"javascript",super._prepareEvent(e,t,n)}_flushOutcomes(){const e=this._clearOutcomes();if(0===e.length)return void(Td&&Vl.log("No outcomes to send"));if(!this._dsn)return void(Td&&Vl.log("No dsn provided, will not send outcomes"));Td&&Vl.log("Sending outcomes:",e);const t=function(e,t){return ou(t?{dsn:t}:{},[[{type:"client_report"},{timestamp:ru(),discarded_events:e}]])}(e,this._options.tunnel&&Wl(this._dsn));this._sendEnvelope(t)}}let zd;function Bd(e,t=function(){if(zd)return zd;if(Fc(kd.fetch))return zd=kd.fetch.bind(kd);const e=kd.document;let t=kd.fetch;if(e&&"function"==typeof e.createElement)try{const n=e.createElement("iframe");n.hidden=!0,e.head.appendChild(n);const r=n.contentWindow;r&&r.fetch&&(t=r.fetch),e.head.removeChild(n)}catch(e){Td&&Vl.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",e)}return zd=t.bind(kd)}()){let n=0,r=0;return fd(e,function(i){const o=i.body.length;n+=o,r++;const a={body:i.body,method:"POST",referrerPolicy:"origin",headers:e.headers,keepalive:n<=6e4&&r<15,...e.fetchOptions};try{return t(e.url,a).then(e=>(n-=o,r--,{statusCode:e.status,headers:{"x-sentry-rate-limits":e.headers.get("X-Sentry-Rate-Limits"),"retry-after":e.headers.get("Retry-After")}}))}catch(e){return zd=void 0,n-=o,r--,Zc(e)}})}function Ud(e){return fd(e,function(t){return new Jc((n,r)=>{const i=new XMLHttpRequest;i.onerror=r,i.onreadystatechange=()=>{4===i.readyState&&n({statusCode:i.status,headers:{"x-sentry-rate-limits":i.getResponseHeader("X-Sentry-Rate-Limits"),"retry-after":i.getResponseHeader("Retry-After")}})},i.open("POST",e.url);for(const t in e.headers)Object.prototype.hasOwnProperty.call(e.headers,t)&&i.setRequestHeader(t,e.headers[t]);i.send(t.body)})})}const Vd="?";function Hd(e,t,n,r){const i={filename:e,function:t,in_app:!0};return void 0!==n&&(i.lineno=n),void 0!==r&&(i.colno=r),i}const Wd=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,$d=/\((\S*)(?::(\d+))(?::(\d+))\)/,Gd=[30,e=>{const t=Wd.exec(e);if(t){if(t[2]&&0===t[2].indexOf("eval")){const e=$d.exec(t[2]);e&&(t[2]=e[1],t[3]=e[2],t[4]=e[3])}const[e,n]=Qd(t[1]||Vd,t[2]);return Hd(n,e,t[3]?+t[3]:void 0,t[4]?+t[4]:void 0)}}],qd=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Yd=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Xd=[50,e=>{const t=qd.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){const e=Yd.exec(t[3]);e&&(t[1]=t[1]||"eval",t[3]=e[1],t[4]=e[2],t[5]="")}let e=t[3],n=t[1]||Vd;return[n,e]=Qd(n,e),Hd(e,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}],Kd=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i,Zd=[40,e=>{const t=Kd.exec(e);return t?Hd(t[2],t[1]||Vd,+t[3],t[4]?+t[4]:void 0):void 0}],Jd=oc(...[Gd,Xd,Zd]),Qd=(e,t)=>{const n=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return n||r?[-1!==e.indexOf("@")?e.split("@")[0]:Vd,n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},eh=1024,th="Breadcrumbs",nh=(e={})=>{const t={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...e};return{name:th,setupOnce(){},setup(e){t.console&&function(e){const t="console";dc(t,e),hc(t,pc)}(function(e){return function(t){if(Tu()!==e)return;const n={category:"console",data:{arguments:t.args,logger:"console"},level:nu(t.level),message:Sl(t.args," ")};if("assert"===t.level){if(!1!==t.args[0])return;n.message=`Assertion failed: ${Sl(t.args.slice(1)," ")||"console.assert"}`,n.data.arguments=t.args.slice(1)}Iu(n,{input:t.args,level:t.level})}}(e)),t.dom&&function(e){dc("dom",e),hc("dom",Ac)}(function(e,t){return function(n){if(Tu()!==e)return;let r,i,o="object"==typeof t?t.serializeAttribute:void 0,a="object"==typeof t&&"number"==typeof t.maxStringLength?t.maxStringLength:void 0;a&&a>eh&&(Td&&Vl.warn(`\`dom.maxStringLength\` cannot exceed 1024, but a value of ${a} was configured. Sentry will use 1024 instead.`),a=eh),"string"==typeof o&&(o=[o]);try{const e=n.event,t=function(e){return!!e&&!!e.target}(e)?e.target:e;r=Nl(t,{keyAttrs:o,maxStringLength:a}),i=function(e){if(!Ll.HTMLElement)return null;let t=e;for(let e=0;e<5;e++){if(!t)return null;if(t instanceof HTMLElement&&t.dataset.sentryComponent)return t.dataset.sentryComponent;t=t.parentNode}return null}(t)}catch{r="<unknown>"}if(0===r.length)return;const s={category:`ui.${n.name}`,message:r};i&&(s.data={"ui.component_name":i}),Iu(s,{event:n.event,name:n.name,global:n.global})}}(e,t.dom)),t.xhr&&function(e){dc("xhr",e),hc("xhr",$c)}(function(e){return function(t){if(Tu()!==e)return;const{startTimestamp:n,endTimestamp:r}=t,i=t.xhr[Wc];if(!n||!r||!i)return;const{method:o,url:a,status_code:s,body:l}=i;Iu({category:"xhr",data:{method:o,url:a,status_code:s},type:"http"},{xhr:t.xhr,input:l,startTimestamp:n,endTimestamp:r})}}(e)),t.fetch&&function(e){const t="fetch";dc(t,e),hc(t,Oc)}(function(e){return function(t){if(Tu()!==e)return;const{startTimestamp:n,endTimestamp:r}=t;if(r&&(!t.fetchData.url.match(/sentry_key/)||"POST"!==t.fetchData.method))if(t.error){Iu({category:"fetch",data:t.fetchData,level:"error",type:"http"},{data:t.error,input:t.args,startTimestamp:n,endTimestamp:r})}else{const e=t.response;Iu({category:"fetch",data:{...t.fetchData,status_code:e&&e.status},type:"http"},{input:t.args,response:e,startTimestamp:n,endTimestamp:r})}}}(e)),t.history&&Uc(function(e){return function(t){if(Tu()!==e)return;let n=t.from,r=t.to;const i=eu(kd.location.href);let o=n?eu(n):void 0;const a=eu(r);(!o||!o.path)&&(o=i),i.protocol===a.protocol&&i.host===a.host&&(r=a.relative),i.protocol===o.protocol&&i.host===o.host&&(n=o.relative),Iu({category:"navigation",data:{from:n,to:r}})}}(e)),t.sentry&&e.on&&e.on("beforeSendEvent",function(e){return function(t){Tu()===e&&Iu({category:"sentry."+("transaction"===t.type?"transaction":"event"),event_id:t.event_id,level:t.level,message:vc(t)},{event:t})}}(e))}}};ad(th,nh);const rh="Dedupe",ih=()=>{let e;return{name:rh,setupOnce(){},processEvent(t){if(t.type)return t;try{if(function(e,t){return!!t&&!(!function(e,t){const n=e.message,r=t.message;return!(!n&&!r||n&&!r||!n&&r||n!==r||!ah(e,t)||!oh(e,t))}(e,t)&&!function(e,t){const n=sh(t),r=sh(e);return!!(n&&r&&n.type===r.type&&n.value===r.value&&ah(e,t)&&oh(e,t))}(e,t))}(t,e))return Td&&Vl.warn("Event dropped due to being a duplicate of previously captured event."),null}catch{}return e=t}}};function oh(e,t){let n=lh(e),r=lh(t);if(!n&&!r)return!0;if(n&&!r||!n&&r||r.length!==n.length)return!1;for(let e=0;e<r.length;e++){const t=r[e],i=n[e];if(t.filename!==i.filename||t.lineno!==i.lineno||t.colno!==i.colno||t.function!==i.function)return!1}return!0}function ah(e,t){let n=e.fingerprint,r=t.fingerprint;if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;try{return n.join("")===r.join("")}catch{return!1}}function sh(e){return e.exception&&e.exception.values&&e.exception.values[0]}function lh(e){const t=e.exception;if(t)try{return t.values[0].stacktrace.frames}catch{return}}ad(rh,ih);const ch="GlobalHandlers",uh=(e={})=>{const t={onerror:!0,onunhandledrejection:!0,...e};return{name:ch,setupOnce(){Error.stackTraceLimit=50},setup(e){t.onerror&&(function(e){!function(e){const t="error";dc(t,e),hc(t,Lc)}(t=>{const{stackParser:n,attachStacktrace:r}=fh();if(Tu()!==e||Ed())return;const{msg:i,url:o,line:a,column:s,error:l}=t,c=void 0===l&&gl(i)?function(e,t,n,r){const i=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;let o=fl(e)?e.message:e,a="Error";const s=o.match(i);return s&&(a=s[1],o=s[2]),dh({exception:{values:[{type:a,value:o}]}},t,n,r)}(i,o,a,s):dh(Ld(n,l||i,void 0,r,!1),o,a,s);c.level="error",Eu(c,{originalException:l,mechanism:{handled:!1,type:"onerror"}})})}(e),hh("onerror")),t.onunhandledrejection&&(function(e){!function(e){const t="unhandledrejection";dc(t,e),hc(t,Dc)}(t=>{const{stackParser:n,attachStacktrace:r}=fh();if(Tu()!==e||Ed())return;const i=function(e){if(vl(e))return e;const t=e;try{if("reason"in t)return t.reason;if("detail"in t&&"reason"in t.detail)return t.detail.reason}catch{}return e}(t),o=vl(i)?function(e){return{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(e)}`}]}}}(i):Ld(n,i,void 0,r,!0);o.level="error",Eu(o,{originalException:i,mechanism:{handled:!1,type:"onunhandledrejection"}})})}(e),hh("onunhandledrejection"))}}};function dh(e,t,n,r){const i=e.exception=e.exception||{},o=i.values=i.values||[],a=o[0]=o[0]||{},s=a.stacktrace=a.stacktrace||{},l=s.frames=s.frames||[],c=isNaN(parseInt(r,10))?void 0:r,u=isNaN(parseInt(n,10))?void 0:n,d=gl(t)&&t.length>0?t:function(){try{return Ll.document.location.href}catch{return""}}();return 0===l.length&&l.push({colno:c,filename:d,function:"?",in_app:!0,lineno:u}),e}function hh(e){Td&&Vl.log(`Global Handler attached: ${e}`)}function fh(){const e=Tu();return e&&e.getOptions()||{stackParser:()=>[],attachStacktrace:!1}}ad(ch,uh);const ph="HttpContext",gh=()=>({name:ph,setupOnce(){},preprocessEvent(e){if(!kd.navigator&&!kd.location&&!kd.document)return;const t=e.request&&e.request.url||kd.location&&kd.location.href,{referrer:n}=kd.document||{},{userAgent:r}=kd.navigator||{},i={...e.request&&e.request.headers,...n&&{Referer:n},...r&&{"User-Agent":r}},o={...e.request,...t&&{url:t},headers:i};e.request=o}});ad(ph,gh);const mh="LinkedErrors",vh=(e={})=>{const t=e.limit||5,n=e.key||"cause";return{name:mh,setupOnce(){},preprocessEvent(e,r,i){const o=i.getOptions();El(Fd,o.stackParser,o.maxValueLength,n,t,e,r)}}};ad(mh,vh);const yh=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","BroadcastChannel","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","SharedWorker","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],bh="TryCatch",wh=(e={})=>{const t={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,...e};return{name:bh,setupOnce(){t.setTimeout&&Yl(kd,"setTimeout",xh),t.setInterval&&Yl(kd,"setInterval",xh),t.requestAnimationFrame&&Yl(kd,"requestAnimationFrame",Ch),t.XMLHttpRequest&&"XMLHttpRequest"in kd&&Yl(XMLHttpRequest.prototype,"send",_h);const e=t.eventTarget;e&&(Array.isArray(e)?e:yh).forEach(Sh)}}};function xh(e){return function(...t){const n=t[0];return t[0]=Id(n,{mechanism:{data:{function:lc(e)},handled:!1,type:"instrument"}}),e.apply(this,t)}}function Ch(e){return function(t){return e.apply(this,[Id(t,{mechanism:{data:{function:"requestAnimationFrame",handler:lc(e)},handled:!1,type:"instrument"}})])}}function _h(e){return function(...t){const n=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(e=>{e in n&&"function"==typeof n[e]&&Yl(n,e,function(t){const n={mechanism:{data:{function:e,handler:lc(t)},handled:!1,type:"instrument"}},r=Zl(t);return r&&(n.mechanism.data.handler=lc(r)),Id(t,n)})}),e.apply(this,t)}}function Sh(e){const t=kd,n=t[e]&&t[e].prototype;!n||!n.hasOwnProperty||!n.hasOwnProperty("addEventListener")||(Yl(n,"addEventListener",function(t){return function(n,r,i){try{"function"==typeof r.handleEvent&&(r.handleEvent=Id(r.handleEvent,{mechanism:{data:{function:"handleEvent",handler:lc(r),target:e},handled:!1,type:"instrument"}}))}catch{}return t.apply(this,[n,Id(r,{mechanism:{data:{function:"addEventListener",handler:lc(r),target:e},handled:!1,type:"instrument"}}),i])}}),Yl(n,"removeEventListener",function(e){return function(t,n,r){const i=n;try{const n=i&&i.__sentry_wrapped__;n&&e.call(this,t,n,r)}catch{}return e.call(this,t,i,r)}}))}ad(bh,wh);const kh=[bd(),Sd(),wh(),nh(),uh(),vh(),ih(),gh()];function Ah(e={}){void 0===e.defaultIntegrations&&(e.defaultIntegrations=[...kh]),void 0===e.release&&("string"==typeof __SENTRY_RELEASE__&&(e.release=__SENTRY_RELEASE__),kd.SENTRY_RELEASE&&kd.SENTRY_RELEASE.id&&(e.release=kd.SENTRY_RELEASE.id)),void 0===e.autoSessionTracking&&(e.autoSessionTracking=!0),void 0===e.sendClientReports&&(e.sendClientReports=!0);const t={...e,stackParser:ac(e.stackParser||Jd),integrations:rd(e),transport:e.transport||(Tc()?Bd:Ud)};hd(jd,t),e.autoSessionTracking&&function(){if(typeof kd.document>"u")return void(Td&&Vl.warn("Session tracking in non-browser environment with @sentry/browser is not supported."));Ou({ignoreDuration:!0}),Ru(),Uc(({from:e,to:t})=>{void 0!==e&&e!==t&&(Ou({ignoreDuration:!0}),Ru())})}()}var Eh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ih(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Th(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}var Fh=(e=>(e.INLINE="inline",e.OVERLAY="overlay",e))(Fh||{}),Oh=(e=>(e.TOP="top",e.BOTTOM="bottom",e.HIDDEN="",e))(Oh||{});function Ph(e,t){return{...t,message:e}}const Mh=[{name:"emoticons",list:["afro-1","afro","agent","alien-1","alien","angel","angry-1","angry-2","angry-3","angry-4","angry-5","angry","arguing","arrogant","asian-1","asian","avatar","baby-1","baby-2","baby","bully","burglar","businessman","cheeky-1","cheeky","clown","confused-1","confused-2","confused-3","confused","creepy","crying-1","crying-2","crying-3","crying","dazed-1","dazed-2","dazed-3","dazed","dead-1","dead-2","dead-3","dead-4","dead-5","dead-6","dead","desperate-1","desperate","detective","dissapointment","doctor","drunk","dumb","emo-1","emo-2","emo","emoticon","evil","faint-1","faint","flirt-1","flirt-2","flirt","flirty","gangster","geek-1","geek","gentleman-1","gentleman-2","gentleman-3","gentleman-4","gentleman","ginger","girl-1","girl","goofy-1","goofy-2","goofy-3","goofy-4","goofy","grubby-1","grubby","happy-1","happy-10","happy-11","happy-12","happy-13","happy-14","happy-15","happy-16","happy-2","happy-3","happy-4","happy-5","happy-6","happy-7","happy-8","happy-9","happy","harry-potter","heisenberg","hipster-1","hipster-2","hipster","in-love-1","in-love-2","in-love-3","in-love-4","in-love-5","in-love-6","in-love","japan","jew","joyful-1","joyful-2","joyful","kiss-1","kiss-2","kiss-3","kiss-4","kiss","laughing-1","laughing-2","laughing-3","laughing","listening","love","manly","miserly-1","miserly","nerd-1","nerd-2","nerd-3","nerd-4","nerd","ninja","pirate-1","pirate-2","pirate","punk-1","punk-2","punk","rapper","relieved","rich-1","rich-2","rich","rockstar","sad-1","sad-2","sad-3","sad-4","sad-5","sad-6","sad","scared-1","scared-2","scared-3","scared","sceptic-1","sceptic-2","sceptic-3","sceptic-4","sceptic-5","sceptic-6","sceptic-7","sceptic","secret","shocked-1","shocked-2","shocked-3","shocked","sick-1","sick-2","sick-3","sick-4","sick","silent","skeleton","smile","smiling-1","smiling","smoked","smug-1","smug-2","smug-3","smug-4","smug-5","smug-6","smug","sporty","stunned","superhero-1","superhero-2","superhero-3","superhero-4","superhero","surprised-1","surprised","thinking","tired-1","tired-2","tired-3","tired","tough-1","tough","trendy","vampire-1","vampire","wink-1","wink-2","wink","winking-1","winking","yawning-1","yawning-2","yawning-3","yawning","yelling","zombie"],type:"svg",thumbnailUrl:"images/stickers/categories/emoticon.svg"},{name:"doodles",items:100,type:"svg",thumbnailUrl:"images/stickers/categories/doodles.svg"},{name:"landmarks",items:100,type:"svg",thumbnailUrl:"images/stickers/categories/landmark.svg",invertPreview:!0},{name:"bubbles",items:104,type:"png",thumbnailUrl:"images/stickers/categories/speech-bubble.svg"},{name:"transportation",items:22,type:"svg",thumbnailUrl:"images/stickers/categories/transportation.svg",invertPreview:!0},{name:"beach",items:22,type:"svg",thumbnailUrl:"images/stickers/categories/beach.svg",invertPreview:!0}],Rh={emoticons:Ph("Emoticons"),doodles:Ph("Doodles"),landmarks:Ph("Landmarks"),bubbles:Ph("Bubbles"),transportation:Ph("Transportation"),beach:Ph("Beach")},Lh={fill:"#1565C0",opacity:1,backgroundColor:null,strokeWidth:.05,stroke:"#000"},Nh=[1,8,15,20,25];var Dh=(e=>(e.DARK="dark",e.LIGHT="light",e))(Dh||{});const jh=[{name:Dh.LIGHT,colors:{"--be-foreground-base":"0 0 0","--be-primary-light":"191 219 254","--be-primary":"59 130 246","--be-primary-dark":"37 99 235","--be-on-primary":"255 255 255","--be-danger":"179 38 30","--be-on-danger":"255 255 255","--be-background":"255 255 255","--be-background-alt":"250 250 250","--be-paper":"255 255 255","--be-disabled-bg-opacity":"12%","--be-disabled-fg-opacity":"26%","--be-hover-opacity":"4%","--be-focus-opacity":"12%","--be-selected-opacity":"8%","--be-text-main-opacity":"87%","--be-text-muted-opacity":"60%","--be-divider-opacity":"12%"}},{name:Dh.DARK,isDark:!0,colors:{"--be-foreground-base":"255 255 255","--be-primary-light":"239 246 255","--be-primary":"191 219 254","--be-primary-dark":"147 197 253","--be-on-primary":"56 30 114","--be-danger":"242 184 181","--be-on-danger":"96 20 16","--be-background":"20 21 23","--be-background-alt":"26 27 30","--be-paper":"44 46 51","--be-disabled-bg-opacity":"12%","--be-disabled-fg-opacity":"30%","--be-hover-opacity":"8%","--be-focus-opacity":"12%","--be-selected-opacity":"16%","--be-text-main-opacity":"100%","--be-text-muted-opacity":"70%","--be-divider-opacity":"12%"}}];var zh=(e=>(e.FILTER="filter",e.RESIZE="resize",e.CROP="crop",e.DRAW="draw",e.TEXT="text",e.SHAPES="shapes",e.STICKERS="stickers",e.FRAME="frame",e.CORNERS="corners",e.MERGE="merge",e))(zh||{});function Bh(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Bh(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Uh(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Bh(e))&&(r&&(r+=" "),r+=t);return r}const Vh=p((n,r)=>{const{attr:i,size:o,title:a,className:s,color:l,style:c,children:u,viewBox:d,width:h,height:f,...p}=n;return t("svg",{"aria-hidden":!a,focusable:!1,xmlns:"http://www.w3.org/2000/svg",viewBox:d||"0 0 24 24",...i,...p,className:Uh("svg-icon",s,Hh(o)),style:{color:l,...c},ref:r,height:f||"1em",width:h||"1em",children:[a&&e("title",{children:a}),u]})});function Hh(e){switch(e){case"2xs":return"icon-2xs";case"xs":return"icon-xs";case"sm":return"icon-sm";case"md":return"icon-md";case"lg":return"icon-lg";case"xl":return"icon-xl";default:return e}}function Wh(t,n="",r){return i.memo(i.forwardRef((i,o)=>e(Vh,{"data-testid":`${n}Icon`,ref:o,viewBox:r,...i,size:i.size||"md",children:t})))}function $h(e,t=""){return Wh(Gh(e),t)}function Gh(e){return(null==e?void 0:e.map)&&e.map((e,t)=>i.createElement(e.tag,{key:t,...e.attr},Gh(e.child)))}const qh=Wh(e("path",{d:"M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z"}),"TuneOutlined"),Yh=Wh(e("path",{d:"M21 15h2v2h-2v-2zm0-4h2v2h-2v-2zm2 8h-2v2c1 0 2-1 2-2zM13 3h2v2h-2V3zm8 4h2v2h-2V7zm0-4v2h2c0-1-1-2-2-2zM1 7h2v2H1V7zm16-4h2v2h-2V3zm0 16h2v2h-2v-2zM3 3C2 3 1 4 1 5h2V3zm6 0h2v2H9V3zM5 3h2v2H5V3zm-4 8v8c0 1.1.9 2 2 2h12V11H1zm2 8 2.5-3.21 1.79 2.15 2.5-3.22L13 19H3z"}),"PhotoSizeSelectLargeOutlined"),Xh=Wh(e("path",{d:"M17 15h2V7c0-1.1-.9-2-2-2H9v2h8v8zM7 17V1H5v4H1v2h4v10c0 1.1.9 2 2 2h10v4h2v-4h4v-2H7z"}),"CropOutlined"),Kh=Wh(e("path",{d:"M2.5 4v3h5v12h3V7h5V4h-13zm19 5h-9v3h3v7h3v-7h3V9z"}),"TextFieldsOutlined"),Zh=Wh(e("path",{d:"M10.5 4.5c.28 0 .5.22.5.5v2h6v6h2c.28 0 .5.22.5.5s-.22.5-.5.5h-2v6h-2.12c-.68-1.75-2.39-3-4.38-3s-3.7 1.25-4.38 3H4v-2.12c1.75-.68 3-2.39 3-4.38 0-1.99-1.24-3.7-2.99-4.38L4 7h6V5c0-.28.22-.5.5-.5m0-2C9.12 2.5 8 3.62 8 5H4c-1.1 0-1.99.9-1.99 2v3.8h.29c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-.3c0-1.49 1.21-2.7 2.7-2.7s2.7 1.21 2.7 2.7v.3H17c1.1 0 2-.9 2-2v-4c1.38 0 2.5-1.12 2.5-2.5S20.38 11 19 11V7c0-1.1-.9-2-2-2h-4c0-1.38-1.12-2.5-2.5-2.5z"}),"ExtensionOutlined"),Jh=Wh(e("path",{d:"M10.25 13c0 .69-.56 1.25-1.25 1.25S7.75 13.69 7.75 13s.56-1.25 1.25-1.25 1.25.56 1.25 1.25zM15 11.75c-.69 0-1.25.56-1.25 1.25s.56 1.25 1.25 1.25 1.25-.56 1.25-1.25-.56-1.25-1.25-1.25zm7 .25c0 5.52-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2s10 4.48 10 10zM10.66 4.12C12.06 6.44 14.6 8 17.5 8c.46 0 .91-.05 1.34-.12C17.44 5.56 14.9 4 12 4c-.46 0-.91.05-1.34.12zM4.42 9.47c1.71-.97 3.03-2.55 3.66-4.44C6.37 6 5.05 7.58 4.42 9.47zM20 12c0-.78-.12-1.53-.33-2.24-.7.15-1.42.24-2.17.24-3.13 0-5.92-1.44-7.76-3.69C8.69 8.87 6.6 10.88 4 11.86c.01.04 0 .09 0 .14 0 4.41 3.59 8 8 8s8-3.59 8-8z"}),"FaceOutlined"),Qh=Wh(e("path",{d:"M20 4h-4l-4-4-4 4H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H4V6h4.52l3.52-3.5L15.52 6H20v14zM6 18h12V8H6v10zm2-8h8v6H8v-6z"}),"FilterFramesOutlined"),ef=Wh(e("path",{d:"M6.41 21 5 19.59l4.83-4.83c.75-.75 1.17-1.77 1.17-2.83v-5.1L9.41 8.41 8 7l4-4 4 4-1.41 1.41L13 6.83v5.1c0 1.06.42 2.08 1.17 2.83L19 19.59 17.59 21 12 15.41 6.41 21z"}),"MergeOutlined"),tf=Wh(e("path",{d:"M19 19h2v2h-2v-2zm0-2h2v-2h-2v2zM3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm0-4h2V3H3v2zm4 0h2V3H7v2zm8 16h2v-2h-2v2zm-4 0h2v-2h-2v2zm4 0h2v-2h-2v2zm-8 0h2v-2H7v2zm-4 0h2v-2H3v2zM21 8c0-2.76-2.24-5-5-5h-5v2h5c1.65 0 3 1.35 3 3v5h2V8z"}),"RoundedCornerOutlined"),nf=Wh(e("path",{d:"M20 4v12H8V4h12m0-2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-8.5 9.67 1.69 2.26 2.48-3.1L19 15H9zM2 6v14c0 1.1.9 2 2 2h14v-2H4V6H2z"}),"PhotoLibraryOutlined"),rf=Wh(e("path",{d:"M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.25 2.52.77-1.28-3.52-2.09V8z"}),"HistoryOutlined"),of=Wh([e("path",{d:"m2.53 19.65 1.34.56v-9.03l-2.43 5.86c-.41 1.02.08 2.19 1.09 2.61zm19.5-3.7L17.07 3.98c-.31-.75-1.04-1.21-1.81-1.23-.26 0-.53.04-.79.15L7.1 5.95c-.75.31-1.21 1.03-1.23 1.8-.01.27.04.54.15.8l4.96 11.97c.31.76 1.05 1.22 1.83 1.23.26 0 .52-.05.77-.15l7.36-3.05c1.02-.42 1.51-1.59 1.09-2.6zm-9.2 3.8L7.87 7.79l7.35-3.04h.01l4.95 11.95-7.35 3.05z"},"0"),e("circle",{cx:"11",cy:"9",r:"1"},"1"),e("path",{d:"M5.88 19.75c0 1.1.9 2 2 2h1.45l-3.45-8.34v6.34z"},"2")],"StyleOutlined"),af=Wh(e("path",{d:"M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"}),"DeleteOutlined"),sf=Wh(e("path",{d:"M18.85,10.39l1.06-1.06c0.78-0.78,0.78-2.05,0-2.83L18.5,5.09c-0.78-0.78-2.05-0.78-2.83,0l-1.06,1.06L18.85,10.39z M14.61,11.81L7.41,19H6v-1.41l7.19-7.19L14.61,11.81z M13.19,7.56L4,16.76V21h4.24l9.19-9.19L13.19,7.56L13.19,7.56z M19,17.5 c0,2.19-2.54,3.5-5,3.5c-0.55,0-1-0.45-1-1s0.45-1,1-1c1.54,0,3-0.73,3-1.5c0-0.47-0.48-0.87-1.23-1.2l1.48-1.48 C18.32,15.45,19,16.29,19,17.5z M4.58,13.35C3.61,12.79,3,12.06,3,11c0-1.8,1.89-2.63,3.56-3.36C7.59,7.18,9,6.56,9,6 c0-0.41-0.78-1-2-1C5.74,5,5.2,5.61,5.17,5.64C4.82,6.05,4.19,6.1,3.77,5.76C3.36,5.42,3.28,4.81,3.62,4.38C3.73,4.24,4.76,3,7,3 c2.24,0,4,1.32,4,3c0,1.87-1.93,2.72-3.64,3.47C6.42,9.88,5,10.5,5,11c0,0.31,0.43,0.6,1.07,0.86L4.58,13.35z"}),"Draw"),lf=Wh(e("path",{d:"m12 5.69 5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3 2 12h3v8h6v-6h2v6h6v-8h3L12 3z"}),"HomeOutlined"),cf={[zh.FILTER]:{name:Ph("Applied Filters"),icon:qh},[zh.RESIZE]:{name:Ph("Resized Image"),icon:Yh},[zh.CROP]:{name:Ph("Cropped Image"),icon:Xh},[zh.DRAW]:{name:Ph("Added Drawing"),icon:sf},[zh.TEXT]:{name:Ph("Added Text"),icon:Kh},[zh.SHAPES]:{name:Ph("Added Shape"),icon:Zh},[zh.STICKERS]:{name:Ph("Added Sticker"),icon:Jh},[zh.FRAME]:{name:Ph("Added Frame"),icon:Qh},[zh.MERGE]:{name:Ph("Merged Objects"),icon:ef},[zh.CORNERS]:{name:Ph("Rounded Corner"),icon:tf},bgImage:{name:Ph("Replaced Background Image"),icon:nf},overlayImage:{name:Ph("Added Image"),icon:nf},initial:{name:Ph("Initial"),icon:lf},loadedState:{name:Ph("Loaded State"),icon:rf},objectStyle:{name:Ph("Changed Style"),icon:of},deletedObject:{name:Ph("Deleted object"),icon:af}},uf=Object.values(zh).map(e=>({name:e,icon:cf[e].icon,action:e===zh.MERGE?e=>{e.tools.merge.apply()}:e})),df={filter:Ph("filter"),resize:Ph("resize"),crop:Ph("crop"),draw:Ph("draw"),text:Ph("text"),shapes:Ph("shapes"),stickers:Ph("stickers"),frame:Ph("frame"),corners:Ph("corners"),merge:Ph("merge")},hf=Wh(e("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5 5-5z"}),"FileDownloadOutlined"),ff="3.0.5",pf={selector:"pixie-editor",textureSize:4096,activeLanguage:"en",ui:{visible:!0,mode:Fh.INLINE,forceOverlayModeOnMobile:!0,activeTheme:Dh.LIGHT,themes:jh,allowEditorClose:!0,menubar:{items:[{type:"undoWidget",align:"left"},{type:"zoomWidget",align:"center",desktopOnly:!0},{type:"button",icon:rf,align:"right",desktopOnly:!0,action:e=>{e.togglePanel("history")}},{type:"button",icon:hf,label:Ph("Done"),align:"right",action:e=>{var t;null!=(t=e.state.config.ui)&&t.showExportPanel?e.state.togglePanel("export",!0):e.tools.export.save()}}]},nav:{position:Oh.BOTTOM,items:[...uf]},openImageDialog:{show:!0,sampleImages:[{url:"images/samples/sample1.jpg",thumbnail:"images/samples/sample1_thumbnail.jpg"},{url:"images/samples/sample2.jpg",thumbnail:"images/samples/sample2_thumbnail.jpg"},{url:"images/samples/sample3.jpg",thumbnail:"images/samples/sample3_thumbnail.jpg"}]},colorPresets:{items:["rgb(0,0,0)","rgb(255, 255, 255)","rgb(242, 38, 19)","rgb(249, 105, 14)","rgb(253, 227, 167)","rgb(4, 147, 114)","rgb(30, 139, 195)","rgb(142, 68, 173)"]}},objectDefaults:{global:{...Lh},sticker:{fill:void 0},text:{textAlign:"initial",underline:!1,linethrough:!1,fontStyle:"normal",fontFamily:"Times New Roman",fontWeight:"normal",stroke:void 0,fontSize:40}},tools:{filter:{items:["grayscale","blackWhite","sharpen","invert","vintage","polaroid","kodachrome","technicolor","brownie","sepia","removeColor","brightness","gamma","noise","pixelate","blur","emboss","blendColor"]},zoom:{allowUserZoom:!0,fitImageToScreen:!0},crop:{allowCustomRatio:!0,defaultRatio:"1:1",presets:[{ratio:null,name:"Custom"},{ratio:"1:1",name:"Square"},{ratio:"4:3"},{ratio:"16:9"},{ratio:"5:3"},{ratio:"5:4"},{ratio:"6:4"},{ratio:"7:5"},{ratio:"10:8"}]},text:{defaultText:"Double click to edit",controlsPadding:6,items:[{family:"Roboto",src:"fonts/open-sans-v27-latin-ext_latin-regular.woff2"},{family:"Fuzzy Bubbles",src:"fonts/fuzzy-bubbles-v3-latin-700.woff2",descriptors:{weight:"700"}},{family:"Aleo Bold",src:"fonts/aleo-v4-latin-ext_latin-700.woff2",descriptors:{weight:"700"}},{family:"Amatic SC",src:"fonts/amatic-sc-v16-latin-ext_latin-regular.woff2"},{family:"Corinthia Bold",src:"fonts/corinthia-v7-latin-ext_latin-700.woff2"},{family:"Bungee Inline",src:"fonts/bungee-inline-v6-latin-ext_latin-regular.woff2"},{family:"Robot Slab Bold",src:"fonts/roboto-slab-v16-latin-ext_latin-500.woff2"},{family:"Carter One",src:"fonts/carter-one-v12-latin-regular.woff2"},{family:"Cody Star",src:"fonts/codystar-v10-latin-ext_latin-regular.woff2"},{family:"Fira Sans",src:"fonts/fira-sans-v11-latin-ext_latin_cyrillic-regular.woff2"},{family:"Krona One",src:"fonts/krona-one-v9-latin-ext_latin-regular.woff2"},{family:"Kumar One Outline",src:"fonts/kumar-one-outline-v8-latin-ext_latin-regular.woff2"},{family:"Lobster Two",src:"fonts/lobster-two-v13-latin-regular.woff2"},{family:"Molle Italic",src:"fonts/molle-v11-latin-ext_latin-italic.woff2"},{family:"Monoton",src:"fonts/monoton-v10-latin-regular.woff2"},{family:"Nixie One",src:"fonts/nixie-one-v11-latin-regular.woff2"},{family:"Permanent Marker",src:"fonts/permanent-marker-v10-latin-regular.woff2"},{family:"Sancreek",src:"fonts/sancreek-v13-latin-ext_latin-regular.woff2"},{family:"Stint Ultra Expanded",src:"fonts/stint-ultra-expanded-v10-latin-regular.woff2"},{family:"VT323",src:"fonts/vt323-v12-latin-ext_latin-regular.woff2"},{family:"Trash Hand",src:"fonts/TrashHand.ttf"}]},draw:{brushSizes:Nh,brushTypes:["PencilBrush","EraserBrush","SprayBrush","CircleBrush","DiamondBrush","VLineBrush","HLineBrush","SquareBrush"]},shapes:{items:[{name:"circle",type:"Circle"},{name:"square",type:"Rect",options:{lockUniScaling:!1}},{name:"triangle",type:"Triangle"},{name:"ellipse",type:"Ellipse",options:{lockUniScaling:!1}},{name:"Arrow #1",type:"Path",options:{path:"M 294.9 16.4 l 15.7 42.2 c -171.4 70.3 -294 242.3 -289.1 437.4 l 14.7 -1 c 9.1 -0.6 18.1 -1.2 27.1 -1.9 l 14.7 -1 c -4.3 -170.1 102.5 -320 252 -381.3 l 15.7 42.2 c 34.7 -40.5 83.1 -76.6 144.8 -99.8 c -58.1 -26.2 -124.9 -39.6 -195.6 -36.8 z"}},{name:"Arrow #2",type:"Path",options:{path:"M 16 248.4 v 14.9 h 447.5 l -93.2 82.5 l 11.9 10.5 l 113.8 -100.2 l -113.6 -100.4 l -11.8 10.5 l 92.9 82.2 z"}},{name:"Arrow #3",type:"Path",options:{path:"M 496 256 l -118.6 -66 v 40.8 h -361.4 v 50.4 h 361.4 v 40.8 l 118.6 -66 z"}},{name:"Line",type:"Path",options:{path:"M 16 256 h 480",strokeWidth:10,stroke:"#000",padding:10}},{name:"Star",type:"Path",options:{path:"M 256 406.3 l 148.3 78 l -28.3 -165.2 l 120 -117 l -165.8 -24.1 l -74.2 -150.3 l -74.2 150.3 l -165.8 24.1 l 120 117 l -28.3 165.2 z"}},{name:"Polygon",type:"Path",options:{path:"M 256 19.6 l 156.6 57.1 l 83.4 144.3 l -28.9 164.2 l -127.7 107.2 h -166.8 l -127.7 -107.2 l -28.9 -164.2 l 83.4 -144.3 z"}},{name:"Badge",type:"Path",options:{path:"M 257.3 16.2 s -148 58.2 -204.4 81.4 c 0 75.7 -16.8 303.5 204.4 398.2 c 218.7 -94.6 201.9 -322.4 201.9 -398.2 c -62.1 -23.6 -201.9 -81.4 -201.9 -81.4 z"}}].slice()},stickers:{items:Mh},import:{validImgExtensions:["png","jpg","jpeg","svg","gif"],fitOverlayToScreen:!0,openDroppedImageAsBackground:!1},export:{defaultFormat:"png",defaultQuality:.8,defaultName:"image"},frame:{items:[{name:"basic",mode:"basic",size:{min:1,max:35,default:10}},{name:"pine",mode:"stretch",size:{min:1,max:35,default:15}},{name:"oak",mode:"stretch",size:{min:1,max:35,default:15}},{name:"rainbow",mode:"stretch",size:{min:1,max:35,default:15}},{name:"grunge1",display_name:"grunge #1",mode:"stretch",size:{min:1,max:35,default:15}},{name:"grunge2",display_name:"grunge #2",mode:"stretch",size:{min:1,max:35,default:20}},{name:"ebony",mode:"stretch",size:{min:1,max:35,default:15}},{name:"art1",display_name:"Art #1",mode:"repeat",size:{min:10,max:70,default:55}},{name:"art2",display_name:"Art #2",mode:"repeat",size:{min:10,max:70,default:55}}]}}},gf=e=>{let t;const n=new Set,r=(e,r)=>{const i="function"==typeof e?e(t):e;if(!Object.is(i,t)){const e=t;t=r??("object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>a,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},a=t=e(r,i,o);return o};var mf={exports:{}},vf={},yf={exports:{}},bf={},wf=i;
|
|
9
|
+
*/var go=(ho||(ho=1,function(e,t){(function(){var n,r="Expected a function",i="__lodash_hash_undefined__",o="__lodash_placeholder__",a=32,s=128,l=256,c=1/0,u=9007199254740991,d=NaN,h=4294967295,f=[["ary",s],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",a],["partialRight",64],["rearg",l]],p="[object Arguments]",g="[object Array]",m="[object Boolean]",v="[object Date]",y="[object Error]",b="[object Function]",w="[object GeneratorFunction]",x="[object Map]",C="[object Number]",_="[object Object]",S="[object Promise]",k="[object RegExp]",A="[object Set]",E="[object String]",I="[object Symbol]",T="[object WeakMap]",F="[object ArrayBuffer]",O="[object DataView]",P="[object Float32Array]",M="[object Float64Array]",R="[object Int8Array]",L="[object Int16Array]",N="[object Int32Array]",D="[object Uint8Array]",j="[object Uint8ClampedArray]",z="[object Uint16Array]",B="[object Uint32Array]",U=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,H=/(__e\(.*?\)|\b__t\)) \+\n'';/g,W=/&(?:amp|lt|gt|quot|#39);/g,$=/[&<>"']/g,G=RegExp(W.source),q=RegExp($.source),Y=/<%-([\s\S]+?)%>/g,X=/<%([\s\S]+?)%>/g,K=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,J=/^\w*$/,Q=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ee=/[\\^$.*+?()[\]{}|]/g,te=RegExp(ee.source),ne=/^\s+/,re=/\s/,ie=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,oe=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,se=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,le=/[()=,{}\[\]\/\s]/,ce=/\\(\\)?/g,ue=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,de=/\w*$/,he=/^[-+]0x[0-9a-f]+$/i,fe=/^0b[01]+$/i,pe=/^\[object .+?Constructor\]$/,ge=/^0o[0-7]+$/i,me=/^(?:0|[1-9]\d*)$/,ve=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ye=/($^)/,be=/['\n\r\u2028\u2029\\]/g,we="\\ud800-\\udfff",xe="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ce="\\u2700-\\u27bf",_e="a-z\\xdf-\\xf6\\xf8-\\xff",Se="A-Z\\xc0-\\xd6\\xd8-\\xde",ke="\\ufe0e\\ufe0f",Ae="\\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",Ee="['’]",Ie="["+we+"]",Te="["+Ae+"]",Fe="["+xe+"]",Oe="\\d+",Pe="["+Ce+"]",Me="["+_e+"]",Re="[^"+we+Ae+Oe+Ce+_e+Se+"]",Le="\\ud83c[\\udffb-\\udfff]",Ne="[^"+we+"]",De="(?:\\ud83c[\\udde6-\\uddff]){2}",je="[\\ud800-\\udbff][\\udc00-\\udfff]",ze="["+Se+"]",Be="\\u200d",Ue="(?:"+Me+"|"+Re+")",Ve="(?:"+ze+"|"+Re+")",He="(?:['’](?:d|ll|m|re|s|t|ve))?",We="(?:['’](?:D|LL|M|RE|S|T|VE))?",$e="(?:"+Fe+"|"+Le+")?",Ge="["+ke+"]?",qe=Ge+$e+"(?:"+Be+"(?:"+[Ne,De,je].join("|")+")"+Ge+$e+")*",Ye="(?:"+[Pe,De,je].join("|")+")"+qe,Xe="(?:"+[Ne+Fe+"?",Fe,De,je,Ie].join("|")+")",Ke=RegExp(Ee,"g"),Ze=RegExp(Fe,"g"),Je=RegExp(Le+"(?="+Le+")|"+Xe+qe,"g"),Qe=RegExp([ze+"?"+Me+"+"+He+"(?="+[Te,ze,"$"].join("|")+")",Ve+"+"+We+"(?="+[Te,ze+Ue,"$"].join("|")+")",ze+"?"+Ue+"+"+He,ze+"+"+We,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Oe,Ye].join("|"),"g"),et=RegExp("["+Be+we+xe+ke+"]"),tt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["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"],rt=-1,it={};it[P]=it[M]=it[R]=it[L]=it[N]=it[D]=it[j]=it[z]=it[B]=!0,it[p]=it[g]=it[F]=it[m]=it[O]=it[v]=it[y]=it[b]=it[x]=it[C]=it[_]=it[k]=it[A]=it[E]=it[T]=!1;var ot={};ot[p]=ot[g]=ot[F]=ot[O]=ot[m]=ot[v]=ot[P]=ot[M]=ot[R]=ot[L]=ot[N]=ot[x]=ot[C]=ot[_]=ot[k]=ot[A]=ot[E]=ot[I]=ot[D]=ot[j]=ot[z]=ot[B]=!0,ot[y]=ot[b]=ot[T]=!1;var at={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},st=parseFloat,lt=parseInt,ct="object"==typeof Dn&&Dn&&Dn.Object===Object&&Dn,ut="object"==typeof self&&self&&self.Object===Object&&self,dt=ct||ut||Function("return this")(),ht=t&&!t.nodeType&&t,ft=ht&&e&&!e.nodeType&&e,pt=ft&&ft.exports===ht,gt=pt&&ct.process,mt=function(){try{var e=ft&&ft.require&&ft.require("util").types;return e||gt&>.binding&>.binding("util")}catch(e){}}(),vt=mt&&mt.isArrayBuffer,yt=mt&&mt.isDate,bt=mt&&mt.isMap,wt=mt&&mt.isRegExp,xt=mt&&mt.isSet,Ct=mt&&mt.isTypedArray;function _t(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function St(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i<o;){var a=e[i];t(r,a,n(a),e)}return r}function kt(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}function At(e,t){for(var n=null==e?0:e.length;n--&&!1!==t(e[n],n,e););return e}function Et(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function It(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o}function Tt(e,t){return!(null==e||!e.length)&&zt(e,t,0)>-1}function Ft(e,t,n){for(var r=-1,i=null==e?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function Ot(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}function Pt(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function Mt(e,t,n,r){var i=-1,o=null==e?0:e.length;for(r&&o&&(n=e[++i]);++i<o;)n=t(n,e[i],i,e);return n}function Rt(e,t,n,r){var i=null==e?0:e.length;for(r&&i&&(n=e[--i]);i--;)n=t(n,e[i],i,e);return n}function Lt(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var Nt=Ht("length");function Dt(e,t,n){var r;return n(e,function(e,n,i){if(t(e,n,i))return r=n,!1}),r}function jt(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o<i;)if(t(e[o],o,e))return o;return-1}function zt(e,t,n){return t==t?function(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}(e,t,n):jt(e,Ut,n)}function Bt(e,t,n,r){for(var i=n-1,o=e.length;++i<o;)if(r(e[i],t))return i;return-1}function Ut(e){return e!=e}function Vt(e,t){var n=null==e?0:e.length;return n?Gt(e,t)/n:d}function Ht(e){return function(t){return null==t?n:t[e]}}function Wt(e){return function(t){return null==e?n:e[t]}}function $t(e,t,n,r,i){return i(e,function(e,i,o){n=r?(r=!1,e):t(n,e,i,o)}),n}function Gt(e,t){for(var r,i=-1,o=e.length;++i<o;){var a=t(e[i]);a!==n&&(r=r===n?a:r+a)}return r}function qt(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function Yt(e){return e?e.slice(0,hn(e)+1).replace(ne,""):e}function Xt(e){return function(t){return e(t)}}function Kt(e,t){return Ot(t,function(t){return e[t]})}function Zt(e,t){return e.has(t)}function Jt(e,t){for(var n=-1,r=e.length;++n<r&&zt(t,e[n],0)>-1;);return n}function Qt(e,t){for(var n=e.length;n--&&zt(t,e[n],0)>-1;);return n}var en=Wt({"À":"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"}),tn=Wt({"&":"&","<":"<",">":">",'"':""","'":"'"});function nn(e){return"\\"+at[e]}function rn(e){return et.test(e)}function on(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function an(e,t){return function(n){return e(t(n))}}function sn(e,t){for(var n=-1,r=e.length,i=0,a=[];++n<r;){var s=e[n];s!==t&&s!==o||(e[n]=o,a[i++]=n)}return a}function ln(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}function cn(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=[e,e]}),n}function un(e){return rn(e)?function(e){for(var t=Je.lastIndex=0;Je.test(e);)++t;return t}(e):Nt(e)}function dn(e){return rn(e)?function(e){return e.match(Je)||[]}(e):function(e){return e.split("")}(e)}function hn(e){for(var t=e.length;t--&&re.test(e.charAt(t)););return t}var fn=Wt({"&":"&","<":"<",">":">",""":'"',"'":"'"}),pn=function e(t){var re,we=(t=null==t?dt:pn.defaults(dt.Object(),t,pn.pick(dt,nt))).Array,xe=t.Date,Ce=t.Error,_e=t.Function,Se=t.Math,ke=t.Object,Ae=t.RegExp,Ee=t.String,Ie=t.TypeError,Te=we.prototype,Fe=_e.prototype,Oe=ke.prototype,Pe=t["__core-js_shared__"],Me=Fe.toString,Re=Oe.hasOwnProperty,Le=0,Ne=(re=/[^.]+$/.exec(Pe&&Pe.keys&&Pe.keys.IE_PROTO||""))?"Symbol(src)_1."+re:"",De=Oe.toString,je=Me.call(ke),ze=dt._,Be=Ae("^"+Me.call(Re).replace(ee,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ue=pt?t.Buffer:n,Ve=t.Symbol,He=t.Uint8Array,We=Ue?Ue.allocUnsafe:n,$e=an(ke.getPrototypeOf,ke),Ge=ke.create,qe=Oe.propertyIsEnumerable,Ye=Te.splice,Xe=Ve?Ve.isConcatSpreadable:n,Je=Ve?Ve.iterator:n,et=Ve?Ve.toStringTag:n,at=function(){try{var e=uo(ke,"defineProperty");return e({},"",{}),e}catch(e){}}(),ct=t.clearTimeout!==dt.clearTimeout&&t.clearTimeout,ut=xe&&xe.now!==dt.Date.now&&xe.now,ht=t.setTimeout!==dt.setTimeout&&t.setTimeout,ft=Se.ceil,gt=Se.floor,mt=ke.getOwnPropertySymbols,Nt=Ue?Ue.isBuffer:n,Wt=t.isFinite,gn=Te.join,mn=an(ke.keys,ke),vn=Se.max,yn=Se.min,bn=xe.now,wn=t.parseInt,xn=Se.random,Cn=Te.reverse,_n=uo(t,"DataView"),Sn=uo(t,"Map"),kn=uo(t,"Promise"),An=uo(t,"Set"),En=uo(t,"WeakMap"),In=uo(ke,"create"),Tn=En&&new En,Fn={},On=Do(_n),Pn=Do(Sn),Mn=Do(kn),Rn=Do(An),Ln=Do(En),Nn=Ve?Ve.prototype:n,Dn=Nn?Nn.valueOf:n,jn=Nn?Nn.toString:n;function zn(e){if(es(e)&&!Ha(e)&&!(e instanceof Hn)){if(e instanceof Vn)return e;if(Re.call(e,"__wrapped__"))return jo(e)}return new Vn(e)}var Bn=function(){function e(){}return function(t){if(!Qa(t))return{};if(Ge)return Ge(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function Un(){}function Vn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}function Hn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=h,this.__views__=[]}function Wn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function $n(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Gn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function qn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Gn;++t<n;)this.add(e[t])}function Yn(e){var t=this.__data__=new $n(e);this.size=t.size}function Xn(e,t){var n=Ha(e),r=!n&&Va(e),i=!n&&!r&&qa(e),o=!n&&!r&&!i&&ls(e),a=n||r||i||o,s=a?qt(e.length,Ee):[],l=s.length;for(var c in e)!t&&!Re.call(e,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||yo(c,l))||s.push(c);return s}function Kn(e){var t=e.length;return t?e[qr(0,t-1)]:n}function Zn(e,t){return Ro(Ii(e),ar(t,0,e.length))}function Jn(e){return Ro(Ii(e))}function Qn(e,t,r){(r!==n&&!za(e[t],r)||r===n&&!(t in e))&&ir(e,t,r)}function er(e,t,r){var i=e[t];Re.call(e,t)&&za(i,r)&&(r!==n||t in e)||ir(e,t,r)}function tr(e,t){for(var n=e.length;n--;)if(za(e[n][0],t))return n;return-1}function nr(e,t,n,r){return dr(e,function(e,i,o){t(r,e,n(e),o)}),r}function rr(e,t){return e&&Ti(t,Fs(t),e)}function ir(e,t,n){"__proto__"==t&&at?at(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function or(e,t){for(var r=-1,i=t.length,o=we(i),a=null==e;++r<i;)o[r]=a?n:ks(e,t[r]);return o}function ar(e,t,r){return e==e&&(r!==n&&(e=e<=r?e:r),t!==n&&(e=e>=t?e:t)),e}function sr(e,t,r,i,o,a){var s,l=1&t,c=2&t,u=4&t;if(r&&(s=o?r(e,i,o,a):r(e)),s!==n)return s;if(!Qa(e))return e;var d=Ha(e);if(d){if(s=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Re.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Ii(e,s)}else{var h=po(e),f=h==b||h==w;if(qa(e))return Ci(e,l);if(h==_||h==p||f&&!o){if(s=c||f?{}:mo(e),!l)return c?function(e,t){return Ti(e,fo(e),t)}(e,function(e,t){return e&&Ti(t,Os(t),e)}(s,e)):function(e,t){return Ti(e,ho(e),t)}(e,rr(s,e))}else{if(!ot[h])return o?e:{};s=function(e,t,n){var r,i=e.constructor;switch(t){case F:return _i(e);case m:case v:return new i(+e);case O:return function(e,t){var n=t?_i(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case P:case M:case R:case L:case N:case D:case j:case z:case B:return Si(e,n);case x:return new i;case C:case E:return new i(e);case k:return function(e){var t=new e.constructor(e.source,de.exec(e));return t.lastIndex=e.lastIndex,t}(e);case A:return new i;case I:return r=e,Dn?ke(Dn.call(r)):{}}}(e,h,l)}}a||(a=new Yn);var g=a.get(e);if(g)return g;a.set(e,s),os(e)?e.forEach(function(n){s.add(sr(n,t,r,n,e,a))}):ts(e)&&e.forEach(function(n,i){s.set(i,sr(n,t,r,i,e,a))});var y=d?n:(u?c?ro:no:c?Os:Fs)(e);return kt(y||e,function(n,i){y&&(n=e[i=n]),er(s,i,sr(n,t,r,i,e,a))}),s}function lr(e,t,r){var i=r.length;if(null==e)return!i;for(e=ke(e);i--;){var o=r[i],a=t[o],s=e[o];if(s===n&&!(o in e)||!a(s))return!1}return!0}function cr(e,t,i){if("function"!=typeof e)throw new Ie(r);return Fo(function(){e.apply(n,i)},t)}function ur(e,t,n,r){var i=-1,o=Tt,a=!0,s=e.length,l=[],c=t.length;if(!s)return l;n&&(t=Ot(t,Xt(n))),r?(o=Ft,a=!1):t.length>=200&&(o=Zt,a=!1,t=new qn(t));e:for(;++i<s;){var u=e[i],d=null==n?u:n(u);if(u=r||0!==u?u:0,a&&d==d){for(var h=c;h--;)if(t[h]===d)continue e;l.push(u)}else o(t,d,r)||l.push(u)}return l}zn.templateSettings={escape:Y,evaluate:X,interpolate:K,variable:"",imports:{_:zn}},zn.prototype=Un.prototype,zn.prototype.constructor=zn,Vn.prototype=Bn(Un.prototype),Vn.prototype.constructor=Vn,Hn.prototype=Bn(Un.prototype),Hn.prototype.constructor=Hn,Wn.prototype.clear=function(){this.__data__=In?In(null):{},this.size=0},Wn.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Wn.prototype.get=function(e){var t=this.__data__;if(In){var r=t[e];return r===i?n:r}return Re.call(t,e)?t[e]:n},Wn.prototype.has=function(e){var t=this.__data__;return In?t[e]!==n:Re.call(t,e)},Wn.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=In&&t===n?i:t,this},$n.prototype.clear=function(){this.__data__=[],this.size=0},$n.prototype.delete=function(e){var t=this.__data__,n=tr(t,e);return!(n<0||(n==t.length-1?t.pop():Ye.call(t,n,1),--this.size,0))},$n.prototype.get=function(e){var t=this.__data__,r=tr(t,e);return r<0?n:t[r][1]},$n.prototype.has=function(e){return tr(this.__data__,e)>-1},$n.prototype.set=function(e,t){var n=this.__data__,r=tr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Gn.prototype.clear=function(){this.size=0,this.__data__={hash:new Wn,map:new(Sn||$n),string:new Wn}},Gn.prototype.delete=function(e){var t=lo(this,e).delete(e);return this.size-=t?1:0,t},Gn.prototype.get=function(e){return lo(this,e).get(e)},Gn.prototype.has=function(e){return lo(this,e).has(e)},Gn.prototype.set=function(e,t){var n=lo(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},qn.prototype.add=qn.prototype.push=function(e){return this.__data__.set(e,i),this},qn.prototype.has=function(e){return this.__data__.has(e)},Yn.prototype.clear=function(){this.__data__=new $n,this.size=0},Yn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Yn.prototype.get=function(e){return this.__data__.get(e)},Yn.prototype.has=function(e){return this.__data__.has(e)},Yn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof $n){var r=n.__data__;if(!Sn||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Gn(r)}return n.set(e,t),this.size=n.size,this};var dr=Pi(br),hr=Pi(wr,!0);function fr(e,t){var n=!0;return dr(e,function(e,r,i){return n=!!t(e,r,i)}),n}function pr(e,t,r){for(var i=-1,o=e.length;++i<o;){var a=e[i],s=t(a);if(null!=s&&(l===n?s==s&&!ss(s):r(s,l)))var l=s,c=a}return c}function gr(e,t){var n=[];return dr(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function mr(e,t,n,r,i){var o=-1,a=e.length;for(n||(n=vo),i||(i=[]);++o<a;){var s=e[o];t>0&&n(s)?t>1?mr(s,t-1,n,r,i):Pt(i,s):r||(i[i.length]=s)}return i}var vr=Mi(),yr=Mi(!0);function br(e,t){return e&&vr(e,t,Fs)}function wr(e,t){return e&&yr(e,t,Fs)}function xr(e,t){return It(t,function(t){return Ka(e[t])})}function Cr(e,t){for(var r=0,i=(t=yi(t,e)).length;null!=e&&r<i;)e=e[No(t[r++])];return r&&r==i?e:n}function _r(e,t,n){var r=t(e);return Ha(e)?r:Pt(r,n(e))}function Sr(e){return null==e?e===n?"[object Undefined]":"[object Null]":et&&et in ke(e)?function(e){var t=Re.call(e,et),r=e[et];try{e[et]=n;var i=!0}catch(e){}var o=De.call(e);return i&&(t?e[et]=r:delete e[et]),o}(e):function(e){return De.call(e)}(e)}function kr(e,t){return e>t}function Ar(e,t){return null!=e&&Re.call(e,t)}function Er(e,t){return null!=e&&t in ke(e)}function Ir(e,t,r){for(var i=r?Ft:Tt,o=e[0].length,a=e.length,s=a,l=we(a),c=1/0,u=[];s--;){var d=e[s];s&&t&&(d=Ot(d,Xt(t))),c=yn(d.length,c),l[s]=!r&&(t||o>=120&&d.length>=120)?new qn(s&&d):n}d=e[0];var h=-1,f=l[0];e:for(;++h<o&&u.length<c;){var p=d[h],g=t?t(p):p;if(p=r||0!==p?p:0,!(f?Zt(f,g):i(u,g,r))){for(s=a;--s;){var m=l[s];if(!(m?Zt(m,g):i(e[s],g,r)))continue e}f&&f.push(g),u.push(p)}}return u}function Tr(e,t,r){var i=null==(e=Eo(e,t=yi(t,e)))?e:e[No(Xo(t))];return null==i?n:_t(i,e,r)}function Fr(e){return es(e)&&Sr(e)==p}function Or(e,t,r,i,o){return e===t||(null==e||null==t||!es(e)&&!es(t)?e!=e&&t!=t:function(e,t,r,i,o,a){var s=Ha(e),l=Ha(t),c=s?g:po(e),u=l?g:po(t),d=(c=c==p?_:c)==_,h=(u=u==p?_:u)==_,f=c==u;if(f&&qa(e)){if(!qa(t))return!1;s=!0,d=!1}if(f&&!d)return a||(a=new Yn),s||ls(e)?eo(e,t,r,i,o,a):function(e,t,n,r,i,o,a){switch(n){case O:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case F:return!(e.byteLength!=t.byteLength||!o(new He(e),new He(t)));case m:case v:case C:return za(+e,+t);case y:return e.name==t.name&&e.message==t.message;case k:case E:return e==t+"";case x:var s=on;case A:var l=1&r;if(s||(s=ln),e.size!=t.size&&!l)return!1;var c=a.get(e);if(c)return c==t;r|=2,a.set(e,t);var u=eo(s(e),s(t),r,i,o,a);return a.delete(e),u;case I:if(Dn)return Dn.call(e)==Dn.call(t)}return!1}(e,t,c,r,i,o,a);if(!(1&r)){var b=d&&Re.call(e,"__wrapped__"),w=h&&Re.call(t,"__wrapped__");if(b||w){var S=b?e.value():e,T=w?t.value():t;return a||(a=new Yn),o(S,T,r,i,a)}}return!!f&&(a||(a=new Yn),function(e,t,r,i,o,a){var s=1&r,l=no(e),c=l.length,u=no(t),d=u.length;if(c!=d&&!s)return!1;for(var h=c;h--;){var f=l[h];if(!(s?f in t:Re.call(t,f)))return!1}var p=a.get(e),g=a.get(t);if(p&&g)return p==t&&g==e;var m=!0;a.set(e,t),a.set(t,e);for(var v=s;++h<c;){var y=e[f=l[h]],b=t[f];if(i)var w=s?i(b,y,f,t,e,a):i(y,b,f,e,t,a);if(!(w===n?y===b||o(y,b,r,i,a):w)){m=!1;break}v||(v="constructor"==f)}if(m&&!v){var x=e.constructor,C=t.constructor;x==C||!("constructor"in e)||!("constructor"in t)||"function"==typeof x&&x instanceof x&&"function"==typeof C&&C instanceof C||(m=!1)}return a.delete(e),a.delete(t),m}(e,t,r,i,o,a))}(e,t,r,i,Or,o))}function Pr(e,t,r,i){var o=r.length,a=o,s=!i;if(null==e)return!a;for(e=ke(e);o--;){var l=r[o];if(s&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++o<a;){var c=(l=r[o])[0],u=e[c],d=l[1];if(s&&l[2]){if(u===n&&!(c in e))return!1}else{var h=new Yn;if(i)var f=i(u,d,c,e,t,h);if(!(f===n?Or(d,u,3,i,h):f))return!1}}return!0}function Mr(e){return!(!Qa(e)||(t=e,Ne&&Ne in t))&&(Ka(e)?Be:pe).test(Do(e));var t}function Rr(e){return"function"==typeof e?e:null==e?nl:"object"==typeof e?Ha(e)?Br(e[0],e[1]):zr(e):dl(e)}function Lr(e){if(!_o(e))return mn(e);var t=[];for(var n in ke(e))Re.call(e,n)&&"constructor"!=n&&t.push(n);return t}function Nr(e){if(!Qa(e))return function(e){var t=[];if(null!=e)for(var n in ke(e))t.push(n);return t}(e);var t=_o(e),n=[];for(var r in e)("constructor"!=r||!t&&Re.call(e,r))&&n.push(r);return n}function Dr(e,t){return e<t}function jr(e,t){var n=-1,r=$a(e)?we(e.length):[];return dr(e,function(e,i,o){r[++n]=t(e,i,o)}),r}function zr(e){var t=co(e);return 1==t.length&&t[0][2]?ko(t[0][0],t[0][1]):function(n){return n===e||Pr(n,e,t)}}function Br(e,t){return wo(e)&&So(t)?ko(No(e),t):function(r){var i=ks(r,e);return i===n&&i===t?As(r,e):Or(t,i,3)}}function Ur(e,t,r,i,o){e!==t&&vr(t,function(a,s){if(o||(o=new Yn),Qa(a))!function(e,t,r,i,o,a,s){var l=Io(e,r),c=Io(t,r),u=s.get(c);if(u)Qn(e,r,u);else{var d=a?a(l,c,r+"",e,t,s):n,h=d===n;if(h){var f=Ha(c),p=!f&&qa(c),g=!f&&!p&&ls(c);d=c,f||p||g?Ha(l)?d=l:Ga(l)?d=Ii(l):p?(h=!1,d=Ci(c,!0)):g?(h=!1,d=Si(c,!0)):d=[]:rs(c)||Va(c)?(d=l,Va(l)?d=ms(l):Qa(l)&&!Ka(l)||(d=mo(c))):h=!1}h&&(s.set(c,d),o(d,c,i,a,s),s.delete(c)),Qn(e,r,d)}}(e,t,s,r,Ur,i,o);else{var l=i?i(Io(e,s),a,s+"",e,t,o):n;l===n&&(l=a),Qn(e,s,l)}},Os)}function Vr(e,t){var r=e.length;if(r)return yo(t+=t<0?r:0,r)?e[t]:n}function Hr(e,t,n){t=t.length?Ot(t,function(e){return Ha(e)?function(t){return Cr(t,1===e.length?e[0]:e)}:e}):[nl];var r=-1;t=Ot(t,Xt(so()));var i=jr(e,function(e,n,i){var o=Ot(t,function(t){return t(e)});return{criteria:o,index:++r,value:e}});return function(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}(i,function(e,t){return function(e,t,n){for(var r=-1,i=e.criteria,o=t.criteria,a=i.length,s=n.length;++r<a;){var l=ki(i[r],o[r]);if(l)return r>=s?l:l*("desc"==n[r]?-1:1)}return e.index-t.index}(e,t,n)})}function Wr(e,t,n){for(var r=-1,i=t.length,o={};++r<i;){var a=t[r],s=Cr(e,a);n(s,a)&&Jr(o,yi(a,e),s)}return o}function $r(e,t,n,r){var i=r?Bt:zt,o=-1,a=t.length,s=e;for(e===t&&(t=Ii(t)),n&&(s=Ot(e,Xt(n)));++o<a;)for(var l=0,c=t[o],u=n?n(c):c;(l=i(s,u,l,r))>-1;)s!==e&&Ye.call(s,l,1),Ye.call(e,l,1);return e}function Gr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;yo(i)?Ye.call(e,i,1):ui(e,i)}}return e}function qr(e,t){return e+gt(xn()*(t-e+1))}function Yr(e,t){var n="";if(!e||t<1||t>u)return n;do{t%2&&(n+=e),(t=gt(t/2))&&(e+=e)}while(t);return n}function Xr(e,t){return Oo(Ao(e,t,nl),e+"")}function Kr(e){return Kn(zs(e))}function Zr(e,t){var n=zs(e);return Ro(n,ar(t,0,n.length))}function Jr(e,t,r,i){if(!Qa(e))return e;for(var o=-1,a=(t=yi(t,e)).length,s=a-1,l=e;null!=l&&++o<a;){var c=No(t[o]),u=r;if("__proto__"===c||"constructor"===c||"prototype"===c)return e;if(o!=s){var d=l[c];(u=i?i(d,c,l):n)===n&&(u=Qa(d)?d:yo(t[o+1])?[]:{})}er(l,c,u),l=l[c]}return e}var Qr=Tn?function(e,t){return Tn.set(e,t),e}:nl,ei=at?function(e,t){return at(e,"toString",{configurable:!0,enumerable:!1,value:Qs(t),writable:!0})}:nl;function ti(e){return Ro(zs(e))}function ni(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=we(i);++r<i;)o[r]=e[r+t];return o}function ri(e,t){var n;return dr(e,function(e,r,i){return!(n=t(e,r,i))}),!!n}function ii(e,t,n){var r=0,i=null==e?r:e.length;if("number"==typeof t&&t==t&&i<=2147483647){for(;r<i;){var o=r+i>>>1,a=e[o];null!==a&&!ss(a)&&(n?a<=t:a<t)?r=o+1:i=o}return i}return oi(e,t,nl,n)}function oi(e,t,r,i){var o=0,a=null==e?0:e.length;if(0===a)return 0;for(var s=(t=r(t))!=t,l=null===t,c=ss(t),u=t===n;o<a;){var d=gt((o+a)/2),h=r(e[d]),f=h!==n,p=null===h,g=h==h,m=ss(h);if(s)var v=i||g;else v=u?g&&(i||f):l?g&&f&&(i||!p):c?g&&f&&!p&&(i||!m):!p&&!m&&(i?h<=t:h<t);v?o=d+1:a=d}return yn(a,4294967294)}function ai(e,t){for(var n=-1,r=e.length,i=0,o=[];++n<r;){var a=e[n],s=t?t(a):a;if(!n||!za(s,l)){var l=s;o[i++]=0===a?0:a}}return o}function si(e){return"number"==typeof e?e:ss(e)?d:+e}function li(e){if("string"==typeof e)return e;if(Ha(e))return Ot(e,li)+"";if(ss(e))return jn?jn.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function ci(e,t,n){var r=-1,i=Tt,o=e.length,a=!0,s=[],l=s;if(n)a=!1,i=Ft;else if(o>=200){var c=t?null:Yi(e);if(c)return ln(c);a=!1,i=Zt,l=new qn}else l=t?[]:s;e:for(;++r<o;){var u=e[r],d=t?t(u):u;if(u=n||0!==u?u:0,a&&d==d){for(var h=l.length;h--;)if(l[h]===d)continue e;t&&l.push(d),s.push(u)}else i(l,d,n)||(l!==s&&l.push(d),s.push(u))}return s}function ui(e,t){return null==(e=Eo(e,t=yi(t,e)))||delete e[No(Xo(t))]}function di(e,t,n,r){return Jr(e,t,n(Cr(e,t)),r)}function hi(e,t,n,r){for(var i=e.length,o=r?i:-1;(r?o--:++o<i)&&t(e[o],o,e););return n?ni(e,r?0:o,r?o+1:i):ni(e,r?o+1:0,r?i:o)}function fi(e,t){var n=e;return n instanceof Hn&&(n=n.value()),Mt(t,function(e,t){return t.func.apply(t.thisArg,Pt([e],t.args))},n)}function pi(e,t,n){var r=e.length;if(r<2)return r?ci(e[0]):[];for(var i=-1,o=we(r);++i<r;)for(var a=e[i],s=-1;++s<r;)s!=i&&(o[i]=ur(o[i]||a,e[s],t,n));return ci(mr(o,1),t,n)}function gi(e,t,r){for(var i=-1,o=e.length,a=t.length,s={};++i<o;){var l=i<a?t[i]:n;r(s,e[i],l)}return s}function mi(e){return Ga(e)?e:[]}function vi(e){return"function"==typeof e?e:nl}function yi(e,t){return Ha(e)?e:wo(e,t)?[e]:Lo(vs(e))}var bi=Xr;function wi(e,t,r){var i=e.length;return r=r===n?i:r,!t&&r>=i?e:ni(e,t,r)}var xi=ct||function(e){return dt.clearTimeout(e)};function Ci(e,t){if(t)return e.slice();var n=e.length,r=We?We(n):new e.constructor(n);return e.copy(r),r}function _i(e){var t=new e.constructor(e.byteLength);return new He(t).set(new He(e)),t}function Si(e,t){var n=t?_i(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function ki(e,t){if(e!==t){var r=e!==n,i=null===e,o=e==e,a=ss(e),s=t!==n,l=null===t,c=t==t,u=ss(t);if(!l&&!u&&!a&&e>t||a&&s&&c&&!l&&!u||i&&s&&c||!r&&c||!o)return 1;if(!i&&!a&&!u&&e<t||u&&r&&o&&!i&&!a||l&&r&&o||!s&&o||!c)return-1}return 0}function Ai(e,t,n,r){for(var i=-1,o=e.length,a=n.length,s=-1,l=t.length,c=vn(o-a,0),u=we(l+c),d=!r;++s<l;)u[s]=t[s];for(;++i<a;)(d||i<o)&&(u[n[i]]=e[i]);for(;c--;)u[s++]=e[i++];return u}function Ei(e,t,n,r){for(var i=-1,o=e.length,a=-1,s=n.length,l=-1,c=t.length,u=vn(o-s,0),d=we(u+c),h=!r;++i<u;)d[i]=e[i];for(var f=i;++l<c;)d[f+l]=t[l];for(;++a<s;)(h||i<o)&&(d[f+n[a]]=e[i++]);return d}function Ii(e,t){var n=-1,r=e.length;for(t||(t=we(r));++n<r;)t[n]=e[n];return t}function Ti(e,t,r,i){var o=!r;r||(r={});for(var a=-1,s=t.length;++a<s;){var l=t[a],c=i?i(r[l],e[l],l,r,e):n;c===n&&(c=e[l]),o?ir(r,l,c):er(r,l,c)}return r}function Fi(e,t){return function(n,r){var i=Ha(n)?St:nr,o=t?t():{};return i(n,e,so(r,2),o)}}function Oi(e){return Xr(function(t,r){var i=-1,o=r.length,a=o>1?r[o-1]:n,s=o>2?r[2]:n;for(a=e.length>3&&"function"==typeof a?(o--,a):n,s&&bo(r[0],r[1],s)&&(a=o<3?n:a,o=1),t=ke(t);++i<o;){var l=r[i];l&&e(t,l,i,a)}return t})}function Pi(e,t){return function(n,r){if(null==n)return n;if(!$a(n))return e(n,r);for(var i=n.length,o=t?i:-1,a=ke(n);(t?o--:++o<i)&&!1!==r(a[o],o,a););return n}}function Mi(e){return function(t,n,r){for(var i=-1,o=ke(t),a=r(t),s=a.length;s--;){var l=a[e?s:++i];if(!1===n(o[l],l,o))break}return t}}function Ri(e){return function(t){var r=rn(t=vs(t))?dn(t):n,i=r?r[0]:t.charAt(0),o=r?wi(r,1).join(""):t.slice(1);return i[e]()+o}}function Li(e){return function(t){return Mt(Ks(Vs(t).replace(Ke,"")),e,"")}}function Ni(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 n=Bn(e.prototype),r=e.apply(n,t);return Qa(r)?r:n}}function Di(e){return function(t,r,i){var o=ke(t);if(!$a(t)){var a=so(r,3);t=Fs(t),r=function(e){return a(o[e],e,o)}}var s=e(t,r,i);return s>-1?o[a?t[s]:s]:n}}function ji(e){return to(function(t){var i=t.length,o=i,a=Vn.prototype.thru;for(e&&t.reverse();o--;){var s=t[o];if("function"!=typeof s)throw new Ie(r);if(a&&!l&&"wrapper"==oo(s))var l=new Vn([],!0)}for(o=l?o:i;++o<i;){var c=oo(s=t[o]),u="wrapper"==c?io(s):n;l=u&&xo(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?l[oo(u[0])].apply(l,u[3]):1==s.length&&xo(s)?l[c]():l.thru(s)}return function(){var e=arguments,n=e[0];if(l&&1==e.length&&Ha(n))return l.plant(n).value();for(var r=0,o=i?t[r].apply(this,e):n;++r<i;)o=t[r].call(this,o);return o}})}function zi(e,t,r,i,o,a,l,c,u,d){var h=t&s,f=1&t,p=2&t,g=24&t,m=512&t,v=p?n:Ni(e);return function s(){for(var y=arguments.length,b=we(y),w=y;w--;)b[w]=arguments[w];if(g)var x=ao(s),C=function(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}(b,x);if(i&&(b=Ai(b,i,o,g)),a&&(b=Ei(b,a,l,g)),y-=C,g&&y<d){var _=sn(b,x);return Gi(e,t,zi,s.placeholder,r,b,_,c,u,d-y)}var S=f?r:this,k=p?S[e]:e;return y=b.length,c?b=function(e,t){for(var r=e.length,i=yn(t.length,r),o=Ii(e);i--;){var a=t[i];e[i]=yo(a,r)?o[a]:n}return e}(b,c):m&&y>1&&b.reverse(),h&&u<y&&(b.length=u),this&&this!==dt&&this instanceof s&&(k=v||Ni(k)),k.apply(S,b)}}function Bi(e,t){return function(n,r){return function(e,t,n,r){return br(e,function(e,i,o){t(r,n(e),i,o)}),r}(n,e,t(r),{})}}function Ui(e,t){return function(r,i){var o;if(r===n&&i===n)return t;if(r!==n&&(o=r),i!==n){if(o===n)return i;"string"==typeof r||"string"==typeof i?(r=li(r),i=li(i)):(r=si(r),i=si(i)),o=e(r,i)}return o}}function Vi(e){return to(function(t){return t=Ot(t,Xt(so())),Xr(function(n){var r=this;return e(t,function(e){return _t(e,r,n)})})})}function Hi(e,t){var r=(t=t===n?" ":li(t)).length;if(r<2)return r?Yr(t,e):t;var i=Yr(t,ft(e/un(t)));return rn(t)?wi(dn(i),0,e).join(""):i.slice(0,e)}function Wi(e){return function(t,r,i){return i&&"number"!=typeof i&&bo(t,r,i)&&(r=i=n),t=hs(t),r===n?(r=t,t=0):r=hs(r),function(e,t,n,r){for(var i=-1,o=vn(ft((t-e)/(n||1)),0),a=we(o);o--;)a[r?o:++i]=e,e+=n;return a}(t,r,i=i===n?t<r?1:-1:hs(i),e)}}function $i(e){return function(t,n){return"string"==typeof t&&"string"==typeof n||(t=gs(t),n=gs(n)),e(t,n)}}function Gi(e,t,r,i,o,s,l,c,u,d){var h=8&t;t|=h?a:64,4&(t&=~(h?64:a))||(t&=-4);var f=[e,t,o,h?s:n,h?l:n,h?n:s,h?n:l,c,u,d],p=r.apply(n,f);return xo(e)&&To(p,f),p.placeholder=i,Po(p,e,t)}function qi(e){var t=Se[e];return function(e,n){if(e=gs(e),(n=null==n?0:yn(fs(n),292))&&Wt(e)){var r=(vs(e)+"e").split("e");return+((r=(vs(t(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return t(e)}}var Yi=An&&1/ln(new An([,-0]))[1]==c?function(e){return new An(e)}:sl;function Xi(e){return function(t){var n=po(t);return n==x?on(t):n==A?cn(t):function(e,t){return Ot(t,function(t){return[t,e[t]]})}(t,e(t))}}function Ki(e,t,i,c,u,d,h,f){var p=2&t;if(!p&&"function"!=typeof e)throw new Ie(r);var g=c?c.length:0;if(g||(t&=-97,c=u=n),h=h===n?h:vn(fs(h),0),f=f===n?f:fs(f),g-=u?u.length:0,64&t){var m=c,v=u;c=u=n}var y=p?n:io(e),b=[e,t,i,c,u,m,v,d,h,f];if(y&&function(e,t){var n=e[1],r=t[1],i=n|r,a=i<131,c=r==s&&8==n||r==s&&n==l&&e[7].length<=t[8]||384==r&&t[7].length<=t[8]&&8==n;if(!a&&!c)return e;1&r&&(e[2]=t[2],i|=1&n?0:4);var u=t[3];if(u){var d=e[3];e[3]=d?Ai(d,u,t[4]):u,e[4]=d?sn(e[3],o):t[4]}(u=t[5])&&(d=e[5],e[5]=d?Ei(d,u,t[6]):u,e[6]=d?sn(e[5],o):t[6]),(u=t[7])&&(e[7]=u),r&s&&(e[8]=null==e[8]?t[8]:yn(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=i}(b,y),e=b[0],t=b[1],i=b[2],c=b[3],u=b[4],!(f=b[9]=b[9]===n?p?0:e.length:vn(b[9]-g,0))&&24&t&&(t&=-25),t&&1!=t)w=8==t||16==t?function(e,t,r){var i=Ni(e);return function o(){for(var a=arguments.length,s=we(a),l=a,c=ao(o);l--;)s[l]=arguments[l];var u=a<3&&s[0]!==c&&s[a-1]!==c?[]:sn(s,c);return(a-=u.length)<r?Gi(e,t,zi,o.placeholder,n,s,u,n,n,r-a):_t(this&&this!==dt&&this instanceof o?i:e,this,s)}}(e,t,f):t!=a&&33!=t||u.length?zi.apply(n,b):function(e,t,n,r){var i=1&t,o=Ni(e);return function t(){for(var a=-1,s=arguments.length,l=-1,c=r.length,u=we(c+s),d=this&&this!==dt&&this instanceof t?o:e;++l<c;)u[l]=r[l];for(;s--;)u[l++]=arguments[++a];return _t(d,i?n:this,u)}}(e,t,i,c);else var w=function(e,t,n){var r=1&t,i=Ni(e);return function t(){return(this&&this!==dt&&this instanceof t?i:e).apply(r?n:this,arguments)}}(e,t,i);return Po((y?Qr:To)(w,b),e,t)}function Zi(e,t,r,i){return e===n||za(e,Oe[r])&&!Re.call(i,r)?t:e}function Ji(e,t,r,i,o,a){return Qa(e)&&Qa(t)&&(a.set(t,e),Ur(e,t,n,Ji,a),a.delete(t)),e}function Qi(e){return rs(e)?n:e}function eo(e,t,r,i,o,a){var s=1&r,l=e.length,c=t.length;if(l!=c&&!(s&&c>l))return!1;var u=a.get(e),d=a.get(t);if(u&&d)return u==t&&d==e;var h=-1,f=!0,p=2&r?new qn:n;for(a.set(e,t),a.set(t,e);++h<l;){var g=e[h],m=t[h];if(i)var v=s?i(m,g,h,t,e,a):i(g,m,h,e,t,a);if(v!==n){if(v)continue;f=!1;break}if(p){if(!Lt(t,function(e,t){if(!Zt(p,t)&&(g===e||o(g,e,r,i,a)))return p.push(t)})){f=!1;break}}else if(g!==m&&!o(g,m,r,i,a)){f=!1;break}}return a.delete(e),a.delete(t),f}function to(e){return Oo(Ao(e,n,Wo),e+"")}function no(e){return _r(e,Fs,ho)}function ro(e){return _r(e,Os,fo)}var io=Tn?function(e){return Tn.get(e)}:sl;function oo(e){for(var t=e.name+"",n=Fn[t],r=Re.call(Fn,t)?n.length:0;r--;){var i=n[r],o=i.func;if(null==o||o==e)return i.name}return t}function ao(e){return(Re.call(zn,"placeholder")?zn:e).placeholder}function so(){var e=zn.iteratee||rl;return e=e===rl?Rr:e,arguments.length?e(arguments[0],arguments[1]):e}function lo(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function co(e){for(var t=Fs(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,So(i)]}return t}function uo(e,t){var r=function(e,t){return null==e?n:e[t]}(e,t);return Mr(r)?r:n}var ho=mt?function(e){return null==e?[]:(e=ke(e),It(mt(e),function(t){return qe.call(e,t)}))}:pl,fo=mt?function(e){for(var t=[];e;)Pt(t,ho(e)),e=$e(e);return t}:pl,po=Sr;function go(e,t,n){for(var r=-1,i=(t=yi(t,e)).length,o=!1;++r<i;){var a=No(t[r]);if(!(o=null!=e&&n(e,a)))break;e=e[a]}return o||++r!=i?o:!!(i=null==e?0:e.length)&&Ja(i)&&yo(a,i)&&(Ha(e)||Va(e))}function mo(e){return"function"!=typeof e.constructor||_o(e)?{}:Bn($e(e))}function vo(e){return Ha(e)||Va(e)||!!(Xe&&e&&e[Xe])}function yo(e,t){var n=typeof e;return!!(t=null==t?u:t)&&("number"==n||"symbol"!=n&&me.test(e))&&e>-1&&e%1==0&&e<t}function bo(e,t,n){if(!Qa(n))return!1;var r=typeof t;return!!("number"==r?$a(n)&&yo(t,n.length):"string"==r&&t in n)&&za(n[t],e)}function wo(e,t){if(Ha(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!ss(e))||J.test(e)||!Z.test(e)||null!=t&&e in ke(t)}function xo(e){var t=oo(e),n=zn[t];if("function"!=typeof n||!(t in Hn.prototype))return!1;if(e===n)return!0;var r=io(n);return!!r&&e===r[0]}(_n&&po(new _n(new ArrayBuffer(1)))!=O||Sn&&po(new Sn)!=x||kn&&po(kn.resolve())!=S||An&&po(new An)!=A||En&&po(new En)!=T)&&(po=function(e){var t=Sr(e),r=t==_?e.constructor:n,i=r?Do(r):"";if(i)switch(i){case On:return O;case Pn:return x;case Mn:return S;case Rn:return A;case Ln:return T}return t});var Co=Pe?Ka:gl;function _o(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Oe)}function So(e){return e==e&&!Qa(e)}function ko(e,t){return function(r){return null!=r&&r[e]===t&&(t!==n||e in ke(r))}}function Ao(e,t,r){return t=vn(t===n?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=vn(n.length-t,0),a=we(o);++i<o;)a[i]=n[t+i];i=-1;for(var s=we(t+1);++i<t;)s[i]=n[i];return s[t]=r(a),_t(e,this,s)}}function Eo(e,t){return t.length<2?e:Cr(e,ni(t,0,-1))}function Io(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var To=Mo(Qr),Fo=ht||function(e,t){return dt.setTimeout(e,t)},Oo=Mo(ei);function Po(e,t,n){var r=t+"";return Oo(e,function(e,t){var n=t.length;if(!n)return e;var r=n-1;return t[r]=(n>1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(ie,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return kt(f,function(n){var r="_."+n[0];t&n[1]&&!Tt(e,r)&&e.push(r)}),e.sort()}(function(e){var t=e.match(oe);return t?t[1].split(ae):[]}(r),n)))}function Mo(e){var t=0,r=0;return function(){var i=bn(),o=16-(i-r);if(r=i,o>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(n,arguments)}}function Ro(e,t){var r=-1,i=e.length,o=i-1;for(t=t===n?i:t;++r<t;){var a=qr(r,o),s=e[a];e[a]=e[r],e[r]=s}return e.length=t,e}var Lo=function(e){var t=Ma(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(Q,function(e,n,r,i){t.push(r?i.replace(ce,"$1"):n||e)}),t});function No(e){if("string"==typeof e||ss(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Do(e){if(null!=e){try{return Me.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function jo(e){if(e instanceof Hn)return e.clone();var t=new Vn(e.__wrapped__,e.__chain__);return t.__actions__=Ii(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var zo=Xr(function(e,t){return Ga(e)?ur(e,mr(t,1,Ga,!0)):[]}),Bo=Xr(function(e,t){var r=Xo(t);return Ga(r)&&(r=n),Ga(e)?ur(e,mr(t,1,Ga,!0),so(r,2)):[]}),Uo=Xr(function(e,t){var r=Xo(t);return Ga(r)&&(r=n),Ga(e)?ur(e,mr(t,1,Ga,!0),n,r):[]});function Vo(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:fs(n);return i<0&&(i=vn(r+i,0)),jt(e,so(t,3),i)}function Ho(e,t,r){var i=null==e?0:e.length;if(!i)return-1;var o=i-1;return r!==n&&(o=fs(r),o=r<0?vn(i+o,0):yn(o,i-1)),jt(e,so(t,3),o,!0)}function Wo(e){return null!=e&&e.length?mr(e,1):[]}function $o(e){return e&&e.length?e[0]:n}var Go=Xr(function(e){var t=Ot(e,mi);return t.length&&t[0]===e[0]?Ir(t):[]}),qo=Xr(function(e){var t=Xo(e),r=Ot(e,mi);return t===Xo(r)?t=n:r.pop(),r.length&&r[0]===e[0]?Ir(r,so(t,2)):[]}),Yo=Xr(function(e){var t=Xo(e),r=Ot(e,mi);return(t="function"==typeof t?t:n)&&r.pop(),r.length&&r[0]===e[0]?Ir(r,n,t):[]});function Xo(e){var t=null==e?0:e.length;return t?e[t-1]:n}var Ko=Xr(Zo);function Zo(e,t){return e&&e.length&&t&&t.length?$r(e,t):e}var Jo=to(function(e,t){var n=null==e?0:e.length,r=or(e,t);return Gr(e,Ot(t,function(e){return yo(e,n)?+e:e}).sort(ki)),r});function Qo(e){return null==e?e:Cn.call(e)}var ea=Xr(function(e){return ci(mr(e,1,Ga,!0))}),ta=Xr(function(e){var t=Xo(e);return Ga(t)&&(t=n),ci(mr(e,1,Ga,!0),so(t,2))}),na=Xr(function(e){var t=Xo(e);return t="function"==typeof t?t:n,ci(mr(e,1,Ga,!0),n,t)});function ra(e){if(!e||!e.length)return[];var t=0;return e=It(e,function(e){if(Ga(e))return t=vn(e.length,t),!0}),qt(t,function(t){return Ot(e,Ht(t))})}function ia(e,t){if(!e||!e.length)return[];var r=ra(e);return null==t?r:Ot(r,function(e){return _t(t,n,e)})}var oa=Xr(function(e,t){return Ga(e)?ur(e,t):[]}),aa=Xr(function(e){return pi(It(e,Ga))}),sa=Xr(function(e){var t=Xo(e);return Ga(t)&&(t=n),pi(It(e,Ga),so(t,2))}),la=Xr(function(e){var t=Xo(e);return t="function"==typeof t?t:n,pi(It(e,Ga),n,t)}),ca=Xr(ra),ua=Xr(function(e){var t=e.length,r=t>1?e[t-1]:n;return r="function"==typeof r?(e.pop(),r):n,ia(e,r)});function da(e){var t=zn(e);return t.__chain__=!0,t}function ha(e,t){return t(e)}var fa=to(function(e){var t=e.length,r=t?e[0]:0,i=this.__wrapped__,o=function(t){return or(t,e)};return!(t>1||this.__actions__.length)&&i instanceof Hn&&yo(r)?((i=i.slice(r,+r+(t?1:0))).__actions__.push({func:ha,args:[o],thisArg:n}),new Vn(i,this.__chain__).thru(function(e){return t&&!e.length&&e.push(n),e})):this.thru(o)}),pa=Fi(function(e,t,n){Re.call(e,n)?++e[n]:ir(e,n,1)}),ga=Di(Vo),ma=Di(Ho);function va(e,t){return(Ha(e)?kt:dr)(e,so(t,3))}function ya(e,t){return(Ha(e)?At:hr)(e,so(t,3))}var ba=Fi(function(e,t,n){Re.call(e,n)?e[n].push(t):ir(e,n,[t])}),wa=Xr(function(e,t,n){var r=-1,i="function"==typeof t,o=$a(e)?we(e.length):[];return dr(e,function(e){o[++r]=i?_t(t,e,n):Tr(e,t,n)}),o}),xa=Fi(function(e,t,n){ir(e,n,t)});function Ca(e,t){return(Ha(e)?Ot:jr)(e,so(t,3))}var _a=Fi(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]}),Sa=Xr(function(e,t){if(null==e)return[];var n=t.length;return n>1&&bo(e,t[0],t[1])?t=[]:n>2&&bo(t[0],t[1],t[2])&&(t=[t[0]]),Hr(e,mr(t,1),[])}),ka=ut||function(){return dt.Date.now()};function Aa(e,t,r){return t=r?n:t,t=e&&null==t?e.length:t,Ki(e,s,n,n,n,n,t)}function Ea(e,t){var i;if("function"!=typeof t)throw new Ie(r);return e=fs(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=n),i}}var Ia=Xr(function(e,t,n){var r=1;if(n.length){var i=sn(n,ao(Ia));r|=a}return Ki(e,r,t,n,i)}),Ta=Xr(function(e,t,n){var r=3;if(n.length){var i=sn(n,ao(Ta));r|=a}return Ki(t,r,e,n,i)});function Fa(e,t,i){var o,a,s,l,c,u,d=0,h=!1,f=!1,p=!0;if("function"!=typeof e)throw new Ie(r);function g(t){var r=o,i=a;return o=a=n,d=t,l=e.apply(i,r)}function m(e){var r=e-u;return u===n||r>=t||r<0||f&&e-d>=s}function v(){var e=ka();if(m(e))return y(e);c=Fo(v,function(e){var n=t-(e-u);return f?yn(n,s-(e-d)):n}(e))}function y(e){return c=n,p&&o?g(e):(o=a=n,l)}function b(){var e=ka(),r=m(e);if(o=arguments,a=this,u=e,r){if(c===n)return function(e){return d=e,c=Fo(v,t),h?g(e):l}(u);if(f)return xi(c),c=Fo(v,t),g(u)}return c===n&&(c=Fo(v,t)),l}return t=gs(t)||0,Qa(i)&&(h=!!i.leading,s=(f="maxWait"in i)?vn(gs(i.maxWait)||0,t):s,p="trailing"in i?!!i.trailing:p),b.cancel=function(){c!==n&&xi(c),d=0,o=u=a=c=n},b.flush=function(){return c===n?l:y(ka())},b}var Oa=Xr(function(e,t){return cr(e,1,t)}),Pa=Xr(function(e,t,n){return cr(e,gs(t)||0,n)});function Ma(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ie(r);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(Ma.Cache||Gn),n}function Ra(e){if("function"!=typeof e)throw new Ie(r);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)}}Ma.Cache=Gn;var La=bi(function(e,t){var n=(t=1==t.length&&Ha(t[0])?Ot(t[0],Xt(so())):Ot(mr(t,1),Xt(so()))).length;return Xr(function(r){for(var i=-1,o=yn(r.length,n);++i<o;)r[i]=t[i].call(this,r[i]);return _t(e,this,r)})}),Na=Xr(function(e,t){var r=sn(t,ao(Na));return Ki(e,a,n,t,r)}),Da=Xr(function(e,t){var r=sn(t,ao(Da));return Ki(e,64,n,t,r)}),ja=to(function(e,t){return Ki(e,l,n,n,n,t)});function za(e,t){return e===t||e!=e&&t!=t}var Ba=$i(kr),Ua=$i(function(e,t){return e>=t}),Va=Fr(function(){return arguments}())?Fr:function(e){return es(e)&&Re.call(e,"callee")&&!qe.call(e,"callee")},Ha=we.isArray,Wa=vt?Xt(vt):function(e){return es(e)&&Sr(e)==F};function $a(e){return null!=e&&Ja(e.length)&&!Ka(e)}function Ga(e){return es(e)&&$a(e)}var qa=Nt||gl,Ya=yt?Xt(yt):function(e){return es(e)&&Sr(e)==v};function Xa(e){if(!es(e))return!1;var t=Sr(e);return t==y||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!rs(e)}function Ka(e){if(!Qa(e))return!1;var t=Sr(e);return t==b||t==w||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Za(e){return"number"==typeof e&&e==fs(e)}function Ja(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=u}function Qa(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function es(e){return null!=e&&"object"==typeof e}var ts=bt?Xt(bt):function(e){return es(e)&&po(e)==x};function ns(e){return"number"==typeof e||es(e)&&Sr(e)==C}function rs(e){if(!es(e)||Sr(e)!=_)return!1;var t=$e(e);if(null===t)return!0;var n=Re.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Me.call(n)==je}var is=wt?Xt(wt):function(e){return es(e)&&Sr(e)==k},os=xt?Xt(xt):function(e){return es(e)&&po(e)==A};function as(e){return"string"==typeof e||!Ha(e)&&es(e)&&Sr(e)==E}function ss(e){return"symbol"==typeof e||es(e)&&Sr(e)==I}var ls=Ct?Xt(Ct):function(e){return es(e)&&Ja(e.length)&&!!it[Sr(e)]},cs=$i(Dr),us=$i(function(e,t){return e<=t});function ds(e){if(!e)return[];if($a(e))return as(e)?dn(e):Ii(e);if(Je&&e[Je])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Je]());var t=po(e);return(t==x?on:t==A?ln:zs)(e)}function hs(e){return e?(e=gs(e))===c||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function fs(e){var t=hs(e),n=t%1;return t==t?n?t-n:t:0}function ps(e){return e?ar(fs(e),0,h):0}function gs(e){if("number"==typeof e)return e;if(ss(e))return d;if(Qa(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Qa(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Yt(e);var n=fe.test(e);return n||ge.test(e)?lt(e.slice(2),n?2:8):he.test(e)?d:+e}function ms(e){return Ti(e,Os(e))}function vs(e){return null==e?"":li(e)}var ys=Oi(function(e,t){if(_o(t)||$a(t))Ti(t,Fs(t),e);else for(var n in t)Re.call(t,n)&&er(e,n,t[n])}),bs=Oi(function(e,t){Ti(t,Os(t),e)}),ws=Oi(function(e,t,n,r){Ti(t,Os(t),e,r)}),xs=Oi(function(e,t,n,r){Ti(t,Fs(t),e,r)}),Cs=to(or),_s=Xr(function(e,t){e=ke(e);var r=-1,i=t.length,o=i>2?t[2]:n;for(o&&bo(t[0],t[1],o)&&(i=1);++r<i;)for(var a=t[r],s=Os(a),l=-1,c=s.length;++l<c;){var u=s[l],d=e[u];(d===n||za(d,Oe[u])&&!Re.call(e,u))&&(e[u]=a[u])}return e}),Ss=Xr(function(e){return e.push(n,Ji),_t(Ms,n,e)});function ks(e,t,r){var i=null==e?n:Cr(e,t);return i===n?r:i}function As(e,t){return null!=e&&go(e,t,Er)}var Es=Bi(function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),e[t]=n},Qs(nl)),Is=Bi(function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),Re.call(e,t)?e[t].push(n):e[t]=[n]},so),Ts=Xr(Tr);function Fs(e){return $a(e)?Xn(e):Lr(e)}function Os(e){return $a(e)?Xn(e,!0):Nr(e)}var Ps=Oi(function(e,t,n){Ur(e,t,n)}),Ms=Oi(function(e,t,n,r){Ur(e,t,n,r)}),Rs=to(function(e,t){var n={};if(null==e)return n;var r=!1;t=Ot(t,function(t){return t=yi(t,e),r||(r=t.length>1),t}),Ti(e,ro(e),n),r&&(n=sr(n,7,Qi));for(var i=t.length;i--;)ui(n,t[i]);return n}),Ls=to(function(e,t){return null==e?{}:function(e,t){return Wr(e,t,function(t,n){return As(e,n)})}(e,t)});function Ns(e,t){if(null==e)return{};var n=Ot(ro(e),function(e){return[e]});return t=so(t),Wr(e,n,function(e,n){return t(e,n[0])})}var Ds=Xi(Fs),js=Xi(Os);function zs(e){return null==e?[]:Kt(e,Fs(e))}var Bs=Li(function(e,t,n){return t=t.toLowerCase(),e+(n?Us(t):t)});function Us(e){return Xs(vs(e).toLowerCase())}function Vs(e){return(e=vs(e))&&e.replace(ve,en).replace(Ze,"")}var Hs=Li(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),Ws=Li(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),$s=Ri("toLowerCase"),Gs=Li(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}),qs=Li(function(e,t,n){return e+(n?" ":"")+Xs(t)}),Ys=Li(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Xs=Ri("toUpperCase");function Ks(e,t,r){return e=vs(e),(t=r?n:t)===n?function(e){return tt.test(e)}(e)?function(e){return e.match(Qe)||[]}(e):function(e){return e.match(se)||[]}(e):e.match(t)||[]}var Zs=Xr(function(e,t){try{return _t(e,n,t)}catch(e){return Xa(e)?e:new Ce(e)}}),Js=to(function(e,t){return kt(t,function(t){t=No(t),ir(e,t,Ia(e[t],e))}),e});function Qs(e){return function(){return e}}var el=ji(),tl=ji(!0);function nl(e){return e}function rl(e){return Rr("function"==typeof e?e:sr(e,1))}var il=Xr(function(e,t){return function(n){return Tr(n,e,t)}}),ol=Xr(function(e,t){return function(n){return Tr(e,n,t)}});function al(e,t,n){var r=Fs(t),i=xr(t,r);null!=n||Qa(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=xr(t,Fs(t)));var o=!(Qa(n)&&"chain"in n&&!n.chain),a=Ka(e);return kt(i,function(n){var r=t[n];e[n]=r,a&&(e.prototype[n]=function(){var t=this.__chain__;if(o||t){var n=e(this.__wrapped__);return(n.__actions__=Ii(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,Pt([this.value()],arguments))})}),e}function sl(){}var ll=Vi(Ot),cl=Vi(Et),ul=Vi(Lt);function dl(e){return wo(e)?Ht(No(e)):function(e){return function(t){return Cr(t,e)}}(e)}var hl=Wi(),fl=Wi(!0);function pl(){return[]}function gl(){return!1}var ml,vl=Ui(function(e,t){return e+t},0),yl=qi("ceil"),bl=Ui(function(e,t){return e/t},1),wl=qi("floor"),xl=Ui(function(e,t){return e*t},1),Cl=qi("round"),_l=Ui(function(e,t){return e-t},0);return zn.after=function(e,t){if("function"!=typeof t)throw new Ie(r);return e=fs(e),function(){if(--e<1)return t.apply(this,arguments)}},zn.ary=Aa,zn.assign=ys,zn.assignIn=bs,zn.assignInWith=ws,zn.assignWith=xs,zn.at=Cs,zn.before=Ea,zn.bind=Ia,zn.bindAll=Js,zn.bindKey=Ta,zn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Ha(e)?e:[e]},zn.chain=da,zn.chunk=function(e,t,r){t=(r?bo(e,t,r):t===n)?1:vn(fs(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var o=0,a=0,s=we(ft(i/t));o<i;)s[a++]=ni(e,o,o+=t);return s},zn.compact=function(e){for(var t=-1,n=null==e?0:e.length,r=0,i=[];++t<n;){var o=e[t];o&&(i[r++]=o)}return i},zn.concat=function(){var e=arguments.length;if(!e)return[];for(var t=we(e-1),n=arguments[0],r=e;r--;)t[r-1]=arguments[r];return Pt(Ha(n)?Ii(n):[n],mr(t,1))},zn.cond=function(e){var t=null==e?0:e.length,n=so();return e=t?Ot(e,function(e){if("function"!=typeof e[1])throw new Ie(r);return[n(e[0]),e[1]]}):[],Xr(function(n){for(var r=-1;++r<t;){var i=e[r];if(_t(i[0],this,n))return _t(i[1],this,n)}})},zn.conforms=function(e){return function(e){var t=Fs(e);return function(n){return lr(n,e,t)}}(sr(e,1))},zn.constant=Qs,zn.countBy=pa,zn.create=function(e,t){var n=Bn(e);return null==t?n:rr(n,t)},zn.curry=function e(t,r,i){var o=Ki(t,8,n,n,n,n,n,r=i?n:r);return o.placeholder=e.placeholder,o},zn.curryRight=function e(t,r,i){var o=Ki(t,16,n,n,n,n,n,r=i?n:r);return o.placeholder=e.placeholder,o},zn.debounce=Fa,zn.defaults=_s,zn.defaultsDeep=Ss,zn.defer=Oa,zn.delay=Pa,zn.difference=zo,zn.differenceBy=Bo,zn.differenceWith=Uo,zn.drop=function(e,t,r){var i=null==e?0:e.length;return i?ni(e,(t=r||t===n?1:fs(t))<0?0:t,i):[]},zn.dropRight=function(e,t,r){var i=null==e?0:e.length;return i?ni(e,0,(t=i-(t=r||t===n?1:fs(t)))<0?0:t):[]},zn.dropRightWhile=function(e,t){return e&&e.length?hi(e,so(t,3),!0,!0):[]},zn.dropWhile=function(e,t){return e&&e.length?hi(e,so(t,3),!0):[]},zn.fill=function(e,t,r,i){var o=null==e?0:e.length;return o?(r&&"number"!=typeof r&&bo(e,t,r)&&(r=0,i=o),function(e,t,r,i){var o=e.length;for((r=fs(r))<0&&(r=-r>o?0:o+r),(i=i===n||i>o?o:fs(i))<0&&(i+=o),i=r>i?0:ps(i);r<i;)e[r++]=t;return e}(e,t,r,i)):[]},zn.filter=function(e,t){return(Ha(e)?It:gr)(e,so(t,3))},zn.flatMap=function(e,t){return mr(Ca(e,t),1)},zn.flatMapDeep=function(e,t){return mr(Ca(e,t),c)},zn.flatMapDepth=function(e,t,r){return r=r===n?1:fs(r),mr(Ca(e,t),r)},zn.flatten=Wo,zn.flattenDeep=function(e){return null!=e&&e.length?mr(e,c):[]},zn.flattenDepth=function(e,t){return null!=e&&e.length?mr(e,t=t===n?1:fs(t)):[]},zn.flip=function(e){return Ki(e,512)},zn.flow=el,zn.flowRight=tl,zn.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,r={};++t<n;){var i=e[t];r[i[0]]=i[1]}return r},zn.functions=function(e){return null==e?[]:xr(e,Fs(e))},zn.functionsIn=function(e){return null==e?[]:xr(e,Os(e))},zn.groupBy=ba,zn.initial=function(e){return null!=e&&e.length?ni(e,0,-1):[]},zn.intersection=Go,zn.intersectionBy=qo,zn.intersectionWith=Yo,zn.invert=Es,zn.invertBy=Is,zn.invokeMap=wa,zn.iteratee=rl,zn.keyBy=xa,zn.keys=Fs,zn.keysIn=Os,zn.map=Ca,zn.mapKeys=function(e,t){var n={};return t=so(t,3),br(e,function(e,r,i){ir(n,t(e,r,i),e)}),n},zn.mapValues=function(e,t){var n={};return t=so(t,3),br(e,function(e,r,i){ir(n,r,t(e,r,i))}),n},zn.matches=function(e){return zr(sr(e,1))},zn.matchesProperty=function(e,t){return Br(e,sr(t,1))},zn.memoize=Ma,zn.merge=Ps,zn.mergeWith=Ms,zn.method=il,zn.methodOf=ol,zn.mixin=al,zn.negate=Ra,zn.nthArg=function(e){return e=fs(e),Xr(function(t){return Vr(t,e)})},zn.omit=Rs,zn.omitBy=function(e,t){return Ns(e,Ra(so(t)))},zn.once=function(e){return Ea(2,e)},zn.orderBy=function(e,t,r,i){return null==e?[]:(Ha(t)||(t=null==t?[]:[t]),Ha(r=i?n:r)||(r=null==r?[]:[r]),Hr(e,t,r))},zn.over=ll,zn.overArgs=La,zn.overEvery=cl,zn.overSome=ul,zn.partial=Na,zn.partialRight=Da,zn.partition=_a,zn.pick=Ls,zn.pickBy=Ns,zn.property=dl,zn.propertyOf=function(e){return function(t){return null==e?n:Cr(e,t)}},zn.pull=Ko,zn.pullAll=Zo,zn.pullAllBy=function(e,t,n){return e&&e.length&&t&&t.length?$r(e,t,so(n,2)):e},zn.pullAllWith=function(e,t,r){return e&&e.length&&t&&t.length?$r(e,t,n,r):e},zn.pullAt=Jo,zn.range=hl,zn.rangeRight=fl,zn.rearg=ja,zn.reject=function(e,t){return(Ha(e)?It:gr)(e,Ra(so(t,3)))},zn.remove=function(e,t){var n=[];if(!e||!e.length)return n;var r=-1,i=[],o=e.length;for(t=so(t,3);++r<o;){var a=e[r];t(a,r,e)&&(n.push(a),i.push(r))}return Gr(e,i),n},zn.rest=function(e,t){if("function"!=typeof e)throw new Ie(r);return Xr(e,t=t===n?t:fs(t))},zn.reverse=Qo,zn.sampleSize=function(e,t,r){return t=(r?bo(e,t,r):t===n)?1:fs(t),(Ha(e)?Zn:Zr)(e,t)},zn.set=function(e,t,n){return null==e?e:Jr(e,t,n)},zn.setWith=function(e,t,r,i){return i="function"==typeof i?i:n,null==e?e:Jr(e,t,r,i)},zn.shuffle=function(e){return(Ha(e)?Jn:ti)(e)},zn.slice=function(e,t,r){var i=null==e?0:e.length;return i?(r&&"number"!=typeof r&&bo(e,t,r)?(t=0,r=i):(t=null==t?0:fs(t),r=r===n?i:fs(r)),ni(e,t,r)):[]},zn.sortBy=Sa,zn.sortedUniq=function(e){return e&&e.length?ai(e):[]},zn.sortedUniqBy=function(e,t){return e&&e.length?ai(e,so(t,2)):[]},zn.split=function(e,t,r){return r&&"number"!=typeof r&&bo(e,t,r)&&(t=r=n),(r=r===n?h:r>>>0)?(e=vs(e))&&("string"==typeof t||null!=t&&!is(t))&&!(t=li(t))&&rn(e)?wi(dn(e),0,r):e.split(t,r):[]},zn.spread=function(e,t){if("function"!=typeof e)throw new Ie(r);return t=null==t?0:vn(fs(t),0),Xr(function(n){var r=n[t],i=wi(n,0,t);return r&&Pt(i,r),_t(e,this,i)})},zn.tail=function(e){var t=null==e?0:e.length;return t?ni(e,1,t):[]},zn.take=function(e,t,r){return e&&e.length?ni(e,0,(t=r||t===n?1:fs(t))<0?0:t):[]},zn.takeRight=function(e,t,r){var i=null==e?0:e.length;return i?ni(e,(t=i-(t=r||t===n?1:fs(t)))<0?0:t,i):[]},zn.takeRightWhile=function(e,t){return e&&e.length?hi(e,so(t,3),!1,!0):[]},zn.takeWhile=function(e,t){return e&&e.length?hi(e,so(t,3)):[]},zn.tap=function(e,t){return t(e),e},zn.throttle=function(e,t,n){var i=!0,o=!0;if("function"!=typeof e)throw new Ie(r);return Qa(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),Fa(e,t,{leading:i,maxWait:t,trailing:o})},zn.thru=ha,zn.toArray=ds,zn.toPairs=Ds,zn.toPairsIn=js,zn.toPath=function(e){return Ha(e)?Ot(e,No):ss(e)?[e]:Ii(Lo(vs(e)))},zn.toPlainObject=ms,zn.transform=function(e,t,n){var r=Ha(e),i=r||qa(e)||ls(e);if(t=so(t,4),null==n){var o=e&&e.constructor;n=i?r?new o:[]:Qa(e)&&Ka(o)?Bn($e(e)):{}}return(i?kt:br)(e,function(e,r,i){return t(n,e,r,i)}),n},zn.unary=function(e){return Aa(e,1)},zn.union=ea,zn.unionBy=ta,zn.unionWith=na,zn.uniq=function(e){return e&&e.length?ci(e):[]},zn.uniqBy=function(e,t){return e&&e.length?ci(e,so(t,2)):[]},zn.uniqWith=function(e,t){return t="function"==typeof t?t:n,e&&e.length?ci(e,n,t):[]},zn.unset=function(e,t){return null==e||ui(e,t)},zn.unzip=ra,zn.unzipWith=ia,zn.update=function(e,t,n){return null==e?e:di(e,t,vi(n))},zn.updateWith=function(e,t,r,i){return i="function"==typeof i?i:n,null==e?e:di(e,t,vi(r),i)},zn.values=zs,zn.valuesIn=function(e){return null==e?[]:Kt(e,Os(e))},zn.without=oa,zn.words=Ks,zn.wrap=function(e,t){return Na(vi(t),e)},zn.xor=aa,zn.xorBy=sa,zn.xorWith=la,zn.zip=ca,zn.zipObject=function(e,t){return gi(e||[],t||[],er)},zn.zipObjectDeep=function(e,t){return gi(e||[],t||[],Jr)},zn.zipWith=ua,zn.entries=Ds,zn.entriesIn=js,zn.extend=bs,zn.extendWith=ws,al(zn,zn),zn.add=vl,zn.attempt=Zs,zn.camelCase=Bs,zn.capitalize=Us,zn.ceil=yl,zn.clamp=function(e,t,r){return r===n&&(r=t,t=n),r!==n&&(r=(r=gs(r))==r?r:0),t!==n&&(t=(t=gs(t))==t?t:0),ar(gs(e),t,r)},zn.clone=function(e){return sr(e,4)},zn.cloneDeep=function(e){return sr(e,5)},zn.cloneDeepWith=function(e,t){return sr(e,5,t="function"==typeof t?t:n)},zn.cloneWith=function(e,t){return sr(e,4,t="function"==typeof t?t:n)},zn.conformsTo=function(e,t){return null==t||lr(e,t,Fs(t))},zn.deburr=Vs,zn.defaultTo=function(e,t){return null==e||e!=e?t:e},zn.divide=bl,zn.endsWith=function(e,t,r){e=vs(e),t=li(t);var i=e.length,o=r=r===n?i:ar(fs(r),0,i);return(r-=t.length)>=0&&e.slice(r,o)==t},zn.eq=za,zn.escape=function(e){return(e=vs(e))&&q.test(e)?e.replace($,tn):e},zn.escapeRegExp=function(e){return(e=vs(e))&&te.test(e)?e.replace(ee,"\\$&"):e},zn.every=function(e,t,r){var i=Ha(e)?Et:fr;return r&&bo(e,t,r)&&(t=n),i(e,so(t,3))},zn.find=ga,zn.findIndex=Vo,zn.findKey=function(e,t){return Dt(e,so(t,3),br)},zn.findLast=ma,zn.findLastIndex=Ho,zn.findLastKey=function(e,t){return Dt(e,so(t,3),wr)},zn.floor=wl,zn.forEach=va,zn.forEachRight=ya,zn.forIn=function(e,t){return null==e?e:vr(e,so(t,3),Os)},zn.forInRight=function(e,t){return null==e?e:yr(e,so(t,3),Os)},zn.forOwn=function(e,t){return e&&br(e,so(t,3))},zn.forOwnRight=function(e,t){return e&&wr(e,so(t,3))},zn.get=ks,zn.gt=Ba,zn.gte=Ua,zn.has=function(e,t){return null!=e&&go(e,t,Ar)},zn.hasIn=As,zn.head=$o,zn.identity=nl,zn.includes=function(e,t,n,r){e=$a(e)?e:zs(e),n=n&&!r?fs(n):0;var i=e.length;return n<0&&(n=vn(i+n,0)),as(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&zt(e,t,n)>-1},zn.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:fs(n);return i<0&&(i=vn(r+i,0)),zt(e,t,i)},zn.inRange=function(e,t,r){return t=hs(t),r===n?(r=t,t=0):r=hs(r),function(e,t,n){return e>=yn(t,n)&&e<vn(t,n)}(e=gs(e),t,r)},zn.invoke=Ts,zn.isArguments=Va,zn.isArray=Ha,zn.isArrayBuffer=Wa,zn.isArrayLike=$a,zn.isArrayLikeObject=Ga,zn.isBoolean=function(e){return!0===e||!1===e||es(e)&&Sr(e)==m},zn.isBuffer=qa,zn.isDate=Ya,zn.isElement=function(e){return es(e)&&1===e.nodeType&&!rs(e)},zn.isEmpty=function(e){if(null==e)return!0;if($a(e)&&(Ha(e)||"string"==typeof e||"function"==typeof e.splice||qa(e)||ls(e)||Va(e)))return!e.length;var t=po(e);if(t==x||t==A)return!e.size;if(_o(e))return!Lr(e).length;for(var n in e)if(Re.call(e,n))return!1;return!0},zn.isEqual=function(e,t){return Or(e,t)},zn.isEqualWith=function(e,t,r){var i=(r="function"==typeof r?r:n)?r(e,t):n;return i===n?Or(e,t,n,r):!!i},zn.isError=Xa,zn.isFinite=function(e){return"number"==typeof e&&Wt(e)},zn.isFunction=Ka,zn.isInteger=Za,zn.isLength=Ja,zn.isMap=ts,zn.isMatch=function(e,t){return e===t||Pr(e,t,co(t))},zn.isMatchWith=function(e,t,r){return r="function"==typeof r?r:n,Pr(e,t,co(t),r)},zn.isNaN=function(e){return ns(e)&&e!=+e},zn.isNative=function(e){if(Co(e))throw new Ce("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Mr(e)},zn.isNil=function(e){return null==e},zn.isNull=function(e){return null===e},zn.isNumber=ns,zn.isObject=Qa,zn.isObjectLike=es,zn.isPlainObject=rs,zn.isRegExp=is,zn.isSafeInteger=function(e){return Za(e)&&e>=-9007199254740991&&e<=u},zn.isSet=os,zn.isString=as,zn.isSymbol=ss,zn.isTypedArray=ls,zn.isUndefined=function(e){return e===n},zn.isWeakMap=function(e){return es(e)&&po(e)==T},zn.isWeakSet=function(e){return es(e)&&"[object WeakSet]"==Sr(e)},zn.join=function(e,t){return null==e?"":gn.call(e,t)},zn.kebabCase=Hs,zn.last=Xo,zn.lastIndexOf=function(e,t,r){var i=null==e?0:e.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=fs(r))<0?vn(i+o,0):yn(o,i-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,o):jt(e,Ut,o,!0)},zn.lowerCase=Ws,zn.lowerFirst=$s,zn.lt=cs,zn.lte=us,zn.max=function(e){return e&&e.length?pr(e,nl,kr):n},zn.maxBy=function(e,t){return e&&e.length?pr(e,so(t,2),kr):n},zn.mean=function(e){return Vt(e,nl)},zn.meanBy=function(e,t){return Vt(e,so(t,2))},zn.min=function(e){return e&&e.length?pr(e,nl,Dr):n},zn.minBy=function(e,t){return e&&e.length?pr(e,so(t,2),Dr):n},zn.stubArray=pl,zn.stubFalse=gl,zn.stubObject=function(){return{}},zn.stubString=function(){return""},zn.stubTrue=function(){return!0},zn.multiply=xl,zn.nth=function(e,t){return e&&e.length?Vr(e,fs(t)):n},zn.noConflict=function(){return dt._===this&&(dt._=ze),this},zn.noop=sl,zn.now=ka,zn.pad=function(e,t,n){e=vs(e);var r=(t=fs(t))?un(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return Hi(gt(i),n)+e+Hi(ft(i),n)},zn.padEnd=function(e,t,n){e=vs(e);var r=(t=fs(t))?un(e):0;return t&&r<t?e+Hi(t-r,n):e},zn.padStart=function(e,t,n){e=vs(e);var r=(t=fs(t))?un(e):0;return t&&r<t?Hi(t-r,n)+e:e},zn.parseInt=function(e,t,n){return n||null==t?t=0:t&&(t=+t),wn(vs(e).replace(ne,""),t||0)},zn.random=function(e,t,r){if(r&&"boolean"!=typeof r&&bo(e,t,r)&&(t=r=n),r===n&&("boolean"==typeof t?(r=t,t=n):"boolean"==typeof e&&(r=e,e=n)),e===n&&t===n?(e=0,t=1):(e=hs(e),t===n?(t=e,e=0):t=hs(t)),e>t){var i=e;e=t,t=i}if(r||e%1||t%1){var o=xn();return yn(e+o*(t-e+st("1e-"+((o+"").length-1))),t)}return qr(e,t)},zn.reduce=function(e,t,n){var r=Ha(e)?Mt:$t,i=arguments.length<3;return r(e,so(t,4),n,i,dr)},zn.reduceRight=function(e,t,n){var r=Ha(e)?Rt:$t,i=arguments.length<3;return r(e,so(t,4),n,i,hr)},zn.repeat=function(e,t,r){return t=(r?bo(e,t,r):t===n)?1:fs(t),Yr(vs(e),t)},zn.replace=function(){var e=arguments,t=vs(e[0]);return e.length<3?t:t.replace(e[1],e[2])},zn.result=function(e,t,r){var i=-1,o=(t=yi(t,e)).length;for(o||(o=1,e=n);++i<o;){var a=null==e?n:e[No(t[i])];a===n&&(i=o,a=r),e=Ka(a)?a.call(e):a}return e},zn.round=Cl,zn.runInContext=e,zn.sample=function(e){return(Ha(e)?Kn:Kr)(e)},zn.size=function(e){if(null==e)return 0;if($a(e))return as(e)?un(e):e.length;var t=po(e);return t==x||t==A?e.size:Lr(e).length},zn.snakeCase=Gs,zn.some=function(e,t,r){var i=Ha(e)?Lt:ri;return r&&bo(e,t,r)&&(t=n),i(e,so(t,3))},zn.sortedIndex=function(e,t){return ii(e,t)},zn.sortedIndexBy=function(e,t,n){return oi(e,t,so(n,2))},zn.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var r=ii(e,t);if(r<n&&za(e[r],t))return r}return-1},zn.sortedLastIndex=function(e,t){return ii(e,t,!0)},zn.sortedLastIndexBy=function(e,t,n){return oi(e,t,so(n,2),!0)},zn.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var n=ii(e,t,!0)-1;if(za(e[n],t))return n}return-1},zn.startCase=qs,zn.startsWith=function(e,t,n){return e=vs(e),n=null==n?0:ar(fs(n),0,e.length),t=li(t),e.slice(n,n+t.length)==t},zn.subtract=_l,zn.sum=function(e){return e&&e.length?Gt(e,nl):0},zn.sumBy=function(e,t){return e&&e.length?Gt(e,so(t,2)):0},zn.template=function(e,t,r){var i=zn.templateSettings;r&&bo(e,t,r)&&(t=n),e=vs(e),t=ws({},t,i,Zi);var o,a,s=ws({},t.imports,i.imports,Zi),l=Fs(s),c=Kt(s,l),u=0,d=t.interpolate||ye,h="__p += '",f=Ae((t.escape||ye).source+"|"+d.source+"|"+(d===K?ue:ye).source+"|"+(t.evaluate||ye).source+"|$","g"),p="//# sourceURL="+(Re.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rt+"]")+"\n";e.replace(f,function(t,n,r,i,s,l){return r||(r=i),h+=e.slice(u,l).replace(be,nn),n&&(o=!0,h+="' +\n__e("+n+") +\n'"),s&&(a=!0,h+="';\n"+s+";\n__p += '"),r&&(h+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),u=l+t.length,t}),h+="';\n";var g=Re.call(t,"variable")&&t.variable;if(g){if(le.test(g))throw new Ce("Invalid `variable` option passed into `_.template`")}else h="with (obj) {\n"+h+"\n}\n";h=(a?h.replace(U,""):h).replace(V,"$1").replace(H,"$1;"),h="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var m=Zs(function(){return _e(l,p+"return "+h).apply(n,c)});if(m.source=h,Xa(m))throw m;return m},zn.times=function(e,t){if((e=fs(e))<1||e>u)return[];var n=h,r=yn(e,h);t=so(t),e-=h;for(var i=qt(r,t);++n<e;)t(n);return i},zn.toFinite=hs,zn.toInteger=fs,zn.toLength=ps,zn.toLower=function(e){return vs(e).toLowerCase()},zn.toNumber=gs,zn.toSafeInteger=function(e){return e?ar(fs(e),-9007199254740991,u):0===e?e:0},zn.toString=vs,zn.toUpper=function(e){return vs(e).toUpperCase()},zn.trim=function(e,t,r){if((e=vs(e))&&(r||t===n))return Yt(e);if(!e||!(t=li(t)))return e;var i=dn(e),o=dn(t);return wi(i,Jt(i,o),Qt(i,o)+1).join("")},zn.trimEnd=function(e,t,r){if((e=vs(e))&&(r||t===n))return e.slice(0,hn(e)+1);if(!e||!(t=li(t)))return e;var i=dn(e);return wi(i,0,Qt(i,dn(t))+1).join("")},zn.trimStart=function(e,t,r){if((e=vs(e))&&(r||t===n))return e.replace(ne,"");if(!e||!(t=li(t)))return e;var i=dn(e);return wi(i,Jt(i,dn(t))).join("")},zn.truncate=function(e,t){var r=30,i="...";if(Qa(t)){var o="separator"in t?t.separator:o;r="length"in t?fs(t.length):r,i="omission"in t?li(t.omission):i}var a=(e=vs(e)).length;if(rn(e)){var s=dn(e);a=s.length}if(r>=a)return e;var l=r-un(i);if(l<1)return i;var c=s?wi(s,0,l).join(""):e.slice(0,l);if(o===n)return c+i;if(s&&(l+=c.length-l),is(o)){if(e.slice(l).search(o)){var u,d=c;for(o.global||(o=Ae(o.source,vs(de.exec(o))+"g")),o.lastIndex=0;u=o.exec(d);)var h=u.index;c=c.slice(0,h===n?l:h)}}else if(e.indexOf(li(o),l)!=l){var f=c.lastIndexOf(o);f>-1&&(c=c.slice(0,f))}return c+i},zn.unescape=function(e){return(e=vs(e))&&G.test(e)?e.replace(W,fn):e},zn.uniqueId=function(e){var t=++Le;return vs(e)+t},zn.upperCase=Ys,zn.upperFirst=Xs,zn.each=va,zn.eachRight=ya,zn.first=$o,al(zn,(ml={},br(zn,function(e,t){Re.call(zn.prototype,t)||(ml[t]=e)}),ml),{chain:!1}),zn.VERSION="4.17.21",kt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){zn[e].placeholder=zn}),kt(["drop","take"],function(e,t){Hn.prototype[e]=function(r){r=r===n?1:vn(fs(r),0);var i=this.__filtered__&&!t?new Hn(this):this.clone();return i.__filtered__?i.__takeCount__=yn(r,i.__takeCount__):i.__views__.push({size:yn(r,h),type:e+(i.__dir__<0?"Right":"")}),i},Hn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),kt(["filter","map","takeWhile"],function(e,t){var n=t+1,r=1==n||3==n;Hn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:so(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}}),kt(["head","last"],function(e,t){var n="take"+(t?"Right":"");Hn.prototype[e]=function(){return this[n](1).value()[0]}}),kt(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");Hn.prototype[e]=function(){return this.__filtered__?new Hn(this):this[n](1)}}),Hn.prototype.compact=function(){return this.filter(nl)},Hn.prototype.find=function(e){return this.filter(e).head()},Hn.prototype.findLast=function(e){return this.reverse().find(e)},Hn.prototype.invokeMap=Xr(function(e,t){return"function"==typeof e?new Hn(this):this.map(function(n){return Tr(n,e,t)})}),Hn.prototype.reject=function(e){return this.filter(Ra(so(e)))},Hn.prototype.slice=function(e,t){e=fs(e);var r=this;return r.__filtered__&&(e>0||t<0)?new Hn(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(r=(t=fs(t))<0?r.dropRight(-t):r.take(t-e)),r)},Hn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hn.prototype.toArray=function(){return this.take(h)},br(Hn.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),o=zn[i?"take"+("last"==t?"Right":""):t],a=i||/^find/.test(t);o&&(zn.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,l=t instanceof Hn,c=s[0],u=l||Ha(t),d=function(e){var t=o.apply(zn,Pt([e],s));return i&&h?t[0]:t};u&&r&&"function"==typeof c&&1!=c.length&&(l=u=!1);var h=this.__chain__,f=!!this.__actions__.length,p=a&&!h,g=l&&!f;if(!a&&u){t=g?t:new Hn(this);var m=e.apply(t,s);return m.__actions__.push({func:ha,args:[d],thisArg:n}),new Vn(m,h)}return p&&g?e.apply(this,s):(m=this.thru(d),p?i?m.value()[0]:m.value():m)})}),kt(["pop","push","shift","sort","splice","unshift"],function(e){var t=Te[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);zn.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(Ha(i)?i:[],e)}return this[n](function(n){return t.apply(Ha(n)?n:[],e)})}}),br(Hn.prototype,function(e,t){var n=zn[t];if(n){var r=n.name+"";Re.call(Fn,r)||(Fn[r]=[]),Fn[r].push({name:t,func:n})}}),Fn[zi(n,2).name]=[{name:"wrapper",func:n}],Hn.prototype.clone=function(){var e=new Hn(this.__wrapped__);return e.__actions__=Ii(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ii(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ii(this.__views__),e},Hn.prototype.reverse=function(){if(this.__filtered__){var e=new Hn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Ha(e),r=t<0,i=n?e.length:0,o=function(e,t,n){for(var r=-1,i=n.length;++r<i;){var o=n[r],a=o.size;switch(o.type){case"drop":e+=a;break;case"dropRight":t-=a;break;case"take":t=yn(t,e+a);break;case"takeRight":e=vn(e,t-a)}}return{start:e,end:t}}(0,i,this.__views__),a=o.start,s=o.end,l=s-a,c=r?s:a-1,u=this.__iteratees__,d=u.length,h=0,f=yn(l,this.__takeCount__);if(!n||!r&&i==l&&f==l)return fi(e,this.__actions__);var p=[];e:for(;l--&&h<f;){for(var g=-1,m=e[c+=t];++g<d;){var v=u[g],y=v.iteratee,b=v.type,w=y(m);if(2==b)m=w;else if(!w){if(1==b)continue e;break e}}p[h++]=m}return p},zn.prototype.at=fa,zn.prototype.chain=function(){return da(this)},zn.prototype.commit=function(){return new Vn(this.value(),this.__chain__)},zn.prototype.next=function(){this.__values__===n&&(this.__values__=ds(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}},zn.prototype.plant=function(e){for(var t,r=this;r instanceof Un;){var i=jo(r);i.__index__=0,i.__values__=n,t?o.__wrapped__=i:t=i;var o=i;r=r.__wrapped__}return o.__wrapped__=e,t},zn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hn){var t=e;return this.__actions__.length&&(t=new Hn(this)),(t=t.reverse()).__actions__.push({func:ha,args:[Qo],thisArg:n}),new Vn(t,this.__chain__)}return this.thru(Qo)},zn.prototype.toJSON=zn.prototype.valueOf=zn.prototype.value=function(){return fi(this.__wrapped__,this.__actions__)},zn.prototype.first=zn.prototype.head,Je&&(zn.prototype[Je]=function(){return this}),zn}();ft?((ft.exports=pn)._=pn,ht._=pn):dt._=pn}).call(po)}(fo,fo.exports)),fo.exports);const mo=e=>null===e.parentId||"null"===e.parentId||!e.parentId,vo=async(e,t,n)=>{var r;if("file"===(null==t?void 0:t.itemType))return e;let i=[];if(!n)return e;{const e=await n({parentId:t.folderId});i=Array.isArray(e)?e:[]}let o=((e,t)=>{const n=Array.isArray(e)?e:[];return(r=t.folderId)&&"root"!==r&&"folders"!==r&&"null"!==r&&null!==r?n.filter(e=>e.parentId===t.folderId):n.filter(mo);var r})(i,t);if(null===(r=null==t?void 0:t.search)||void 0===r?void 0:r.trim()){const e=t.search.trim().toLowerCase();o=o.filter(t=>{var n;return null===(n=t.name)||void 0===n?void 0:n.toLowerCase().includes(e)})}if(0===o.length)return e;const a=o.map(e=>({id:e.id,name:e.name,size:void 0,date:"-",isFolder:!0,folderId:e.parentId||"",type:"",selected:!1,extension:"",childCount:e.childCount}));if("folder"===(null==t?void 0:t.itemType))return a;const s=e.filter(e=>!e.isFolder);return[...a,...s]},yo=e=>{var t,n,r,i;const{state:o,actions:s,options:l}=ro(),{searchTerm:d,sortBy:h,sortOrder:f,selectedFolder:p,pagination:g}=o,{setSearchTerm:m,setSortBy:v,setSortOrder:y,setPagination:b}=s,w=e||s.fetchFiles,x=u(null),C=u(go.debounce(e=>{const t=JSON.stringify(e);x.current!==t&&(x.current=t,null==w||w(e))},150)).current,_=c(()=>{var e;const t=null===(e=null==l?void 0:l.config)||void 0===e?void 0:e.disablePagination;return{folderId:p||"",search:(null==d?void 0:d.trim())||void 0,page:t?void 0:g.current,limit:t?void 0:g.pageSize,sortBy:h,sortOrder:f,itemType:"all"}},[p,d,g.current,g.pageSize,h,f,null===(t=null==l?void 0:l.config)||void 0===t?void 0:t.disablePagination]),S=c(e=>{var t,n;if(m&&m(e),b&&b({current:1,pageSize:g.pageSize,total:0}),w){const r={folderId:p||"",search:(null==e?void 0:e.trim())||void 0,page:(null===(t=null==l?void 0:l.config)||void 0===t?void 0:t.disablePagination)?void 0:1,limit:(null===(n=null==l?void 0:l.config)||void 0===n?void 0:n.disablePagination)?void 0:g.pageSize,sortBy:h,sortOrder:f,itemType:"all"};w(r)}else console.error("🔎 useSortAndFilter: fetchFiles НЕ ОПРЕДЕЛЕНА!")},[m,b,g.pageSize,w,p,h,f,null===(n=null==l?void 0:l.config)||void 0===n?void 0:n.disablePagination]),k=c((e,t)=>{var n,r;null==v||v(e),null==y||y(t),w&&C({folderId:p||"",search:(null==d?void 0:d.trim())||void 0,page:(null===(n=null==l?void 0:l.config)||void 0===n?void 0:n.disablePagination)?void 0:g.current,limit:(null===(r=null==l?void 0:l.config)||void 0===r?void 0:r.disablePagination)?void 0:g.pageSize,sortBy:e,sortOrder:t,itemType:"all"})},[v,y,C,p,d,g.current,g.pageSize,null===(r=null==l?void 0:l.config)||void 0===r?void 0:r.disablePagination]),A=c((e,t)=>{var n;(null===(n=null==l?void 0:l.config)||void 0===n?void 0:n.disablePagination)||(b&&b({current:e,pageSize:t||g.pageSize,total:g.total}),w&&C({folderId:p||"",search:(null==d?void 0:d.trim())||void 0,page:e,limit:t||g.pageSize,sortBy:h,sortOrder:f,itemType:"all"}))},[b,g.pageSize,g.total,C,p,d,h,f,null===(i=null==l?void 0:l.config)||void 0===i?void 0:i.disablePagination]);return a(()=>{if(w){const e=_();C(Object.assign(Object.assign({},e),{page:1}))}},[p]),a(()=>{w&&C(_())},[]),a(()=>()=>{var e;null===(e=C.cancel)||void 0===e||e.call(C)},[C]),{state:{searchTerm:d||"",sortBy:h||"name",sortOrder:f||"asc"},actions:{setSearchTerm:m||(()=>{}),setSortBy:v||(()=>{}),setSortOrder:y||(()=>{}),handleSearch:S,handleSort:k,handlePaginationChange:A,getCurrentQueryParams:_}}},bo=()=>{var e;const{notification:t}=I.useApp(),n=ro(),{options:r}=n,i=c(async e=>{let t;if(r.handleNotify){try{t=await r.handleNotify(e)}catch(e){console.error(e)}if(!1===t)return!1;"object"==typeof t&&t&&(e=t)}if("error"===e.type&&r.handleError){try{t=await r.handleError(e)}catch(e){console.error(e)}if(!1===t)return!1;"object"==typeof t&&t&&(e=t)}if("success"===e.type&&r.handleSuccess){try{t=await r.handleSuccess(e)}catch(e){console.error(e)}if(t)return!1}return t},[r]),o=c(async function(e,n=!1){var o;try{void 0===e.visibility&&(e.visibility=!n);const a=await i(e);"object"==typeof a&&(e=a);if(!(!1!==e.visibility&&!1!==a&&!1!==(null===(o=r.config)||void 0===o?void 0:o.showNotifications)))return e;const s=t[e.type];"function"==typeof s?s(e):console.warn(`Unknown notification type: ${e.type}`,e)}catch(e){console.error(e)}return e},[t,i,null===(e=r.config)||void 0===e?void 0:e.showNotifications]);return d(()=>({error:(e,t=!1)=>o(Object.assign(Object.assign({},e),{type:"error"}),t),success:(e,t=!1)=>o(Object.assign(Object.assign({},e),{type:"success"}),t),warning:(e,t=!1)=>o(Object.assign(Object.assign({},e),{type:"warning"}),t),notify:o}),[o])};Object.values({images:["image/jpeg","image/png","image/gif","image/webp","image/svg+xml","image/bmp","image/tiff"],documents:["application/pdf","text/plain","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],archives:["application/zip","application/x-rar-compressed","application/x-7z-compressed"],videos:["video/mp4","video/avi","video/quicktime","video/x-msvideo"],audio:["audio/mpeg","audio/wav","audio/ogg"]}).flat();const wo=e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]},xo=e=>{if(!e||e<=0)return"";const t=1048576;if(e<t){return`${Math.round(e/1024)} Kb`}return`${(e/t).toFixed(2)} Mb`},Co=e=>{if(null==e)return"";if("number"==typeof e)return xo(e);const t=String(e).trim();if(!t)return"";const n=Number(t);return Number.isNaN(n)?t:xo(n)},_o=(e,t)=>{const n=t.filter(e=>"string"==typeof e),r=new Set(n.map(e=>e.toLowerCase())),i="string"==typeof e?e:String(null!=e?e:"");if(!r.has(i.toLowerCase()))return i;const o=i.lastIndexOf("."),a=o>0?i.slice(0,o):i,s=o>0?i.slice(o):"";let l,c=1;do{l=`${a}_${c}${s}`,c++}while(r.has(l.toLowerCase()));return l},So={FileNotFound:"File not found or no longer available.",FileAlreadyExists:"File with this name already exists.",FileInvalidName:"File name is not valid. Allowed characters: {{allowedChars}}",FileAccessDenied:"You don't have permission to access this file.",FileReadError:"Failed to read the file.",FileWriteError:"Failed to write the file.",FileTooLarge:"File is too large ({{fileSize}}). Maximum allowed size: {{maxSize}}.",FileTypeNotAllowed:"This file type is not allowed.",FileCorrupted:"The file appears to be corrupted.",FileChecksumMismatch:"File integrity check failed.",FileStorageQuotaExceeded:"Storage quota exceeded. Please free up space.",FileLocked:"File is locked by another process or user.",FileVersionConflict:"File version conflict. Please refresh and try again.",FolderNotFound:"Folder not found or no longer available.",FolderAlreadyExists:"Folder with this name already exists.",FolderInvalidName:"Folder name is not valid. Allowed characters: {{allowedChars}}",FolderAccessDenied:"You don't have permission to access this folder.",FolderReadError:"Failed to read the folder contents.",FolderWriteError:"Failed to write to the folder.",FolderQuotaExceeded:"Folder storage quota exceeded.",FolderNotEmpty:"Folder is not empty.",FolderBackendError:"Server error while processing the folder.",FolderTimeout:"Folder operation took too long.",RenameNotAllowed:"Renaming is not allowed for this item.",MoveNotAllowed:"Moving is not allowed for this item.",CopyNotAllowed:"Copying is not allowed for this item.",DeleteNotAllowed:"Deleting is not allowed for this item.",MoveIntoSelf:"Cannot move an item into itself.",MoveIntoDescendant:"Cannot move an item into its descendant folder.",CopyIntoSelf:"Cannot copy an item into itself.",UnsupportedOperation:"This operation is not supported.",ConfigError:"Configuration error occurred.",FileUploadQuotaExceeded:"You have exceeded the upload quota.",FileUploadNetworkError:"Network error while uploading the file.",FileUploadTimeout:"File upload took too long.",FileUploadBackendError:"Server error while uploading the file.",UploadUrlInvalid:"The specified URL is not valid.",UploadUrlNotReachable:"The specified URL is not reachable.",UploadUrlContentTypeNotAllowed:"Content type at the URL is not allowed.",UploadUrlDownloadFailed:"Failed to download file from the URL.",FileLookupFailed:"Failed to find existing file by URL.",FileProxyFailed:"Failed to load file through proxy.",FileProxyNotConfigured:"File proxy is not configured.",FileDownloadNetworkError:"Network error while downloading the file.",FileDownloadTimeout:"File download took too long.",FileDownloadBackendError:"Server error while downloading the file.",BatchPartialFailure:"Some items could not be processed.",BatchAllFailed:"Failed to process all items in the batch.",BatchConflict:"Some items in the batch are in a conflicting state.",BatchValidationFailed:"Some items in the batch did not pass validation.",BatchItemLimitExceeded:"Batch operation exceeds the maximum number of items allowed.",ValidationError:"Some of the provided data is invalid.",PayloadTooLarge:"File is too large ({{fileSize}}). Maximum allowed size: {{maxSize}}.",UnsupportedMediaType:"This media type is not supported.",NetworkError:"Network error. Please check your connection and try again.",BackendError:"Server error. Please try again later.",Timeout:"The operation took too long. Please try again.",AuthenticationFailed:"Authentication failed. Please sign in again.",AuthorizationFailed:"You are not allowed to perform this action.",RateLimitExceeded:"Too many requests. Please try again a bit later.",ServiceUnavailable:"Service is temporarily unavailable. Please try again later.",AIResponseInvalid:"AI service returned an invalid response.",AIImageGenerationFailed:"Failed to generate image using AI.",AIImageGenerationLimitExceeded:"You have reached the AI image generation limit.",IntegrationError:"Error in external integration.",ThirdPartyError:"Error in a third-party service.",UnknownError:"An unknown error occurred."},ko={FileTooLarge:"File is too large to upload.",PayloadTooLarge:"File is too large to upload."},Ao=(e,t,n)=>{var r,i,o;if(!e)return;const a=So[e];if(!a)return;const s=null!==(r=null==n?void 0:n.fileSize)&&void 0!==r?r:"",l=null!==(i=null==n?void 0:n.maxSize)&&void 0!==i?i:"";if(("FileTooLarge"===e||"PayloadTooLarge"===e)&&!(!!s&&!!l)){const n=ko[e];return n?t(n):t(a,{fileSize:"?",maxSize:"?"})}return t(a,{allowedChars:null!==(o=null==n?void 0:n.allowedChars)&&void 0!==o?o:"a-z A-Z 0-9 . _ -",fileSize:s,maxSize:l})},Eo=e=>{if(!e||"string"!=typeof e)return;const t=e.toLowerCase();return(t.includes("maximum number of files")||t.includes("number of files exceeded"))&&(t.includes("allowed")||t.includes("received"))?"BatchItemLimitExceeded":t.includes("exceeds")||t.includes("maximum")||t.includes("too large")||t.includes("size limit")||t.includes("object size")||t.includes("размер")||t.includes("превышен")?"PayloadTooLarge":t.includes("403")||t.includes("forbidden")||t.includes("access denied")||t.includes("доступ запрещён")?"AuthorizationFailed":t.includes("404")||t.includes("not found")||t.includes("не найден")?"UploadUrlNotReachable":t.includes("already exists")||t.includes("уже существует")||t.includes("дубликат")?"FileAlreadyExists":t.includes("invalid")&&(t.includes("name")||t.includes("имя")||t.includes("назва"))?"FileInvalidName":t.includes("type")&&(t.includes("not allowed")||t.includes("не поддерживается"))?"FileTypeNotAllowed":void 0},Io=e=>{var t,n,r,i,o,a,s,l,c,u,d,h,f,p,g,m,v,y;if(!e)return{message:"Unknown error",raw:e};if("string"==typeof e)return{message:e};if(e instanceof Error){const o=e;return{message:null!==(t=o.message)&&void 0!==t?t:e.message,code:o.code,status:null!==(n=o.status)&&void 0!==n?n:o.httpStatus,stack:null!==(r=o.stack)&&void 0!==r?r:e.stack,raw:null!==(i=o.raw)&&void 0!==i?i:e}}if("object"==typeof e){const t=e,n=null!==(o=t.data)&&void 0!==o?o:t,r=null!==(a=null==n?void 0:n.data)&&void 0!==a?a:n,i=null!==(c=null!==(l=null!==(s=t.message)&&void 0!==s?s:null==n?void 0:n.message)&&void 0!==l?l:t.error)&&void 0!==c?c:t.reason,b=null!==(h=null!==(d=null!==(u=t.status)&&void 0!==u?u:t.httpStatus)&&void 0!==d?d:null==r?void 0:r.status)&&void 0!==h?h:null==n?void 0:n.status,w=null!==(f=t.code)&&void 0!==f?f:null==n?void 0:n.code,x=t.stack,C=null!==(p=t.raw)&&void 0!==p?p:e,_=null!==(m=null!==(g=t.fileSize)&&void 0!==g?g:null==r?void 0:r.fileSize)&&void 0!==m?m:null==n?void 0:n.fileSize,S=null!==(y=null!==(v=t.maxSize)&&void 0!==v?v:null==r?void 0:r.maxSize)&&void 0!==y?y:null==n?void 0:n.maxSize;if(i||w||b||x||C)return Object.assign(Object.assign({message:i,code:w,status:b,stack:x,raw:C},null!=_&&{fileSize:_}),null!=S&&{maxSize:S})}return{message:String(e),raw:e}};const To=(e,t,n)=>{const r=Io(e),i=null==r?void 0:r.code;if("FileTooLarge"===i&&null!=(null==n?void 0:n.fileSize)&&null!=(null==n?void 0:n.maxSize))return t("File too large ({{size}}). Maximum allowed size: {{maxSize}}",{size:wo(n.fileSize),maxSize:wo(n.maxSize)});if(("BatchItemLimitExceeded"===i||"exceeded_max_files"===i)&&(null==r?void 0:r.message)){const{allowed:e,received:n}=function(e){const t=e.match(/Allowed:\s*(\d+)/i),n=e.match(/received:\s*(\d+)/i);return{allowed:t?parseInt(t[1],10):void 0,received:n?parseInt(n[1],10):void 0}}(r.message);if(null!=e&&null!=n)return t("Maximum number of files exceeded. Allowed: {{allowed}}, received: {{received}}",{allowed:e,received:n})}if((null==r?void 0:r.message)&&"Unknown error"!==r.message)return r.message;const o=null!=(null==n?void 0:n.fileSize)&&null!=(null==n?void 0:n.maxSize)?{fileSize:wo(n.fileSize),maxSize:wo(n.maxSize)}:void 0,a=Ao(i,t,o);return null!=a?a:t("Error uploading file")},Fo=e=>{const t=Io(e);return"path_folder_not_found"===(null==t?void 0:t.code)},Oo=["file_get_contents","open stream","failed to open stream","http request failed","curl_error"];const Po=(e,t,n)=>{var r;if(!e)return t("Error when downloading a file by URL");const i=null!==(r=(e=>{const t=Eo(e);if("AuthorizationFailed"===t){const t=(e||"").toLowerCase();if(t.includes("download")||t.includes("url")||t.includes("file_get_contents")||t.includes("failed to download"))return"UploadUrlNotReachable"}return t})(null==e?void 0:e.message))&&void 0!==r?r:null==e?void 0:e.code,o=Ao(i,t,n);if(o)return o;const a=(null==e?void 0:e.message)&&"string"==typeof e.message?e.message.trim():null;return a&&function(e){if(!e||e.length>200)return!1;const t=e.toLowerCase();return!Oo.some(e=>t.includes(e))}(a)?a:t("Failed to download file from the URL.")},Mo=e=>Array.isArray(e)?e.filter(e=>(null==e?void 0:e.id)&&"folders"!==e.id).map(e=>e.name).filter(Boolean).join("/"):"",Ro=e=>{const t=e.trim();if(!t)return"";const n=t.toLowerCase(),r=[n.indexOf(" and "),n.indexOf(" or "),t.indexOf(","),t.indexOf(";"),n.indexOf(". ")].filter(e=>e>=0);if(0===r.length)return t;const i=Math.min(...r);return t.slice(0,i).trim()||t},Lo=(e,t)=>{const n=(e=>{var t,n,r,i;if(e&&"object"==typeof e){const o=e,a=null!==(r=null===(n=null===(t=o.data)||void 0===t?void 0:t.data)||void 0===n?void 0:n.path_folder)&&void 0!==r?r:null===(i=o.data)||void 0===i?void 0:i.path_folder;if("string"==typeof a&&a.trim())return Ro(a)||null}const o=Io(e),a=null==o?void 0:o.message;if(!a)return null;const s=a.toLowerCase(),l=["не существует:","not exists:","not exist:","not found:"];for(const e of l){const t=s.indexOf(e);if(t>=0){const n=a.slice(t+e.length).trim();return Ro(n)||null}}const c=["not exists ","not exist ","not found "];for(const e of c){const t=s.indexOf(e);if(t>=0){const n=a.slice(t+e.length).trim();return Ro(n)||null}}return null})(e);return n?(e=>{const t=e.split("/").filter(Boolean);return t.length<=1?"":(t.pop(),t.join("/"))})(n):Mo(t)},No=async e=>{var t;const{options:n,pathFolder:r,dataProviders:i}=e;if(null==i?void 0:i.clearCache)return void await i.clearCache(r||null);const o=null===(t=null==n?void 0:n.apiEndpoints)||void 0===t?void 0:t.clearCache;if(!o)return;const a=o.includes("?");let s=o;r&&r.length>0&&(s=`${o}${a?"&":"?"}path_folder=${encodeURIComponent(r)}`);const l=await fetch(s,{method:"POST"});if(!l.ok)throw new Error(`Cache clear failed: ${l.status}`)},Do={"а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ё":"yo","ж":"zh","з":"z","и":"i","й":"y","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"ts","ч":"ch","ш":"sh","щ":"sch","ъ":"","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ё":"Yo","Ж":"Zh","З":"Z","И":"I","Й":"Y","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"Ts","Ч":"Ch","Ш":"Sh","Щ":"Sch","Ъ":"","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya"},jo=/[<>:"/\\|?*()#\x00-\x1f]/g,zo={transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0};function Bo(e,t){let n=e;return t.transliterate&&(n=n.split("").map(e=>Do[e]||e).join("")),t.removeForbiddenChars&&(n=n.replace(jo,"_")),t.replaceSpaces&&(n=n.replace(/\s+/g,"_")),t.toLowerCase&&(n=n.toLowerCase()),n=n.replace(/_{2,}/g,"_"),n=n.replace(/^_+|_+$/g,""),n.length>255&&(n=n.substring(0,255)),n}function Uo(e,t){const n=Object.assign(Object.assign({},zo),null==t?void 0:t.fileNameProcessing),r=e.lastIndexOf(".");let i,o;r>0?(i=e.substring(0,r),o=e.substring(r).toLowerCase()):(i=e,o="");return(Bo(i,n)||"unnamed_file")+o}function Vo(e,t){return Bo(e,Object.assign(Object.assign({},zo),null==t?void 0:t.folderNameProcessing))||"unnamed_folder"}const Ho=()=>{var e,t;const{state:n,actions:i,options:o}=ro(),{t:a}=Qn(),s=bo(),{folders:l,selectedFolder:u,pathHistory:d,form:h,loading:f,isModalVisible:p}=n,{setFolders:g,setLoading:m,setIsModalVisible:v}=i,{dataProviders:y,config:b}=o,w=c(e=>(Array.isArray(e)?e:[]).filter(e=>e&&e.id&&e.name).map(e=>({id:e.id,name:e.name,parentId:e.folderId?e.folderId:null})),[]),x=c(async(e=!1)=>{null==m||m(!0);try{let e=[];const t="lazy"===(null==b?void 0:b.folderTreeLoading);if(!(null==y?void 0:y.getFolders)){if(null==y?void 0:y.getFiles){const e=async n=>{const{files:r}=await y.getFiles({itemType:"folder",folderId:n||void 0}),i=w(r);if(t)return i;const o=await Promise.all(i.map(t=>e(t.id)));return[...i,...o.flat()]},n=await e(null);return void(g&&g(e=>{const r=Array.isArray(e)?e:[];if(!t){const e=n,t=e.filter(e=>e.id===e.parentId);return t.length>0&&console.warn("Folders with cyclic dependencies detected:",t),e}const i=r.filter(e=>e.parentId),o=[...i,...n],a=o.filter(e=>e.id===e.parentId);return a.length>0&&console.warn("Folders with cyclic dependencies detected:",a),o}))}return void console.error("DataProvider for folders is not defined")}{const n=!t;e=await y.getFolders({parentId:null,deep:n})}const n=Array.isArray(e)?e:[];null==g||g(n);const r=n.filter(e=>e.id===e.parentId);r.length>0&&console.warn("Folders with cyclic dependencies detected:",r)}catch(t){console.error("Error loading folders:",t);const n=Io(t);if(!e&&(404===(null==n?void 0:n.status)||"FileNotFound"===(null==n?void 0:n.code))){const e=Lo(t,d||[]);try{return await No({options:o,pathFolder:e,dataProviders:null==o?void 0:o.dataProviders}),void await x(!0)}catch(e){console.error("Cache clear failed:",e)}}const r=Ao(null==n?void 0:n.code,a);s.error({id:"FOLDERS_FETCH_FAILED",message:null!=r?r:a("Failed to load folders"),placement:"bottomRight",innerException:t,data:{reason:t instanceof Error?t.message:String(t)}})}finally{null==m||m(!1)}},[null==y?void 0:y.getFiles,null==y?void 0:y.getFolders,g,m,null==b?void 0:b.folderTreeLoading,w,s,a,d,o]),C=c(()=>x(),[x]),_=c(async e=>{try{let t,n;if(null==y?void 0:y.getFolders){t=await y.getFolders({parentId:e,deep:!1});const r=Array.isArray(l)?l:[],i=new Set(t.map(e=>e.id)),o=r.filter(t=>t.parentId!==e||i.has(t.id));n=[...o,...t.filter(e=>!o.some(t=>t.id===e.id))]}else{if(!(null==y?void 0:y.getFiles))return[];{const{files:r}=await y.getFiles({itemType:"folder",folderId:e||void 0});t=w(r);const i=Array.isArray(l)?l:[],o=new Set(t.map(e=>e.id)),a=i.filter(t=>t.parentId!==e||o.has(t.id));n=[...a,...t.filter(e=>!a.some(t=>t.id===e.id))]}}let r=n,i=0;for(;i!==r.length;){i=r.length;const e=new Set(r.map(e=>e.id));r=r.filter(t=>!t.parentId||e.has(t.parentId))}return null==g||g(r),t}catch(e){return console.error("Error loading child folders:",e),[]}},[y,l,g,w]),S=c(()=>{var e;const t=null!==(e=null==b?void 0:b.defaultFolderName)&&void 0!==e?e:a("New folder");h.setFieldsValue({folderName:t}),null==v||v(!0)},[h,v,a,null==b?void 0:b.defaultFolderName]),k=c(async(e,t)=>{const n=[...(Array.isArray(l)?l:[]).filter(t=>t.id!==e.id),e];if(null==g||g(n),e.parentId&&(await _(e.parentId),await new Promise(e=>setTimeout(e,50))),!(null==t?void 0:t.preserveSelection)&&i.setSelectedFolder&&i.setSelectedFolder(e.id),!(null==t?void 0:t.preserveSelection)&&i.setPathHistory){const t=Array.isArray(n)?n:[],r=(e,n=new Set)=>{if(n.has(e))return console.warn(`Cycle detected in the path to the folder with id=${e}`),[];const i=t.find(t=>t.id===e);if(!i)return[];const o=new Set(n);return o.add(e),i.parentId?[...r(i.parentId,o),{id:i.id,name:i.name}]:[{id:i.id,name:i.name}]},o=r(e.id),s=[{id:"folders",name:a("Folders")},...o];i.setPathHistory(s)}},[l,g,i,n.pathHistory,_,a]),A=c(async e=>{try{if(null==y?void 0:y.getFolders){const t=await y.getFolders(),n=Array.isArray(t)?t:[];return n.some(t=>t.id===e)}if(null==y?void 0:y.getFiles){const t=new Set,n=async r=>{const{files:i}=await y.getFiles({itemType:"folder",folderId:r||void 0}),o=w(i);for(const r of o){if(t.has(r.id))continue;if(t.add(r.id),r.id===e)return!0;if(await n(r.id))return!0}return!1};return await n(null)}}catch(e){console.warn("⚠️ Error checking the folder:",e)}return!1},[null==y?void 0:y.getFolders,null==y?void 0:y.getFiles,w]),E=c(async e=>{var t;let n,r,i=null;try{const o=await(e?e.validateFields():h.validateFields());if(n=o.folderName.trim(),!n){const e=o.targetFolder||(u&&"folders"!==u?u:null);return void s.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:a("Folder name cannot be empty"),placement:"bottomRight",data:{folderName:n,folderId:null!=e?e:null,reason:"emptyName",is_force_create:!!o.is_force_create}})}r=Vo(n,b);const c=o.targetFolder;if(c)i="folders"!==c?c:null;else if(u&&"folders"!==u)i=u;else if(Array.isArray(d)&&d.length>1){const e=d[d.length-1];i=(null==e?void 0:e.id)&&"folders"!==e.id?e.id:null}if((!1===(null==b?void 0:b.paginationAvailable)||!1===(null==b?void 0:b.hasPagination)||!0===(null==b?void 0:b.disablePagination))&&(null==y?void 0:y.getFolders))try{const e=(await y.getFolders({parentId:i,deep:!1})||[]).map(e=>{var t;return null===(t=e.name)||void 0===t?void 0:t.toLowerCase()}).filter(Boolean);if(e.includes(n.trim().toLowerCase()))return void s.error({id:"FOLDER_ALREADY_EXISTS",message:a("A folder with that name already exists. Please enter a different folder name."),placement:"bottomRight",data:{folderName:n,folderId:i}})}catch(e){}let f;if(!(null==y?void 0:y.createFolder))return void s.error({id:"FOLDER_CREATE_PROVIDER_NOT_CONFIGURED",message:a("Folder creation provider is not configured"),placement:"bottomRight",data:{folderName:r,folderId:null!=i?i:null,is_force_create:!!o.is_force_create}});f=await y.createFolder({name:r,parentId:i,is_force_create:!!o.is_force_create}),(e=>{if(!e||!e.id)throw new Error(a("Invalid server response: folder ID is missing"));if(e.id===e.parentId&&e.parentId)throw console.error("Circular dependency detected: folder cannot be its own parent"),new Error(a("Error: folder cannot be its own parent"))})(f);const p={id:f.id,name:f.name,parentId:null!=i?i:null,childCount:f.childCount},m=[...(Array.isArray(l)?l:[]).filter(e=>e.id!==p.id),p];if(null==g||g(m),s.success({id:"FOLDER_CREATE_SUCCESS",message:a("Folder created"),placement:"bottomRight",data:{itemIds:[p.id],folderId:null!==(t=p.parentId)&&void 0!==t?t:null,folderName:p.name}}),e||null==v||v(!1),(async()=>{try{await k(p,{preserveSelection:Boolean(e)}),await C(),await new Promise(e=>setTimeout(e,200));await A(f.id)||console.warn("⚠️ Could not confirm the creation of the folder on the server, but continuing...")}catch(e){console.error("Error performing background operations after creating the folder:",e)}})(),e)return f}catch(e){console.error("❌ Error creating the folder:",e);const t=Io(e),o=Ao(null==t?void 0:t.code,a);s.error({id:"FOLDER_CREATE_FAILED",message:null!=o?o:a("Failed to create folder"),placement:"bottomRight",innerException:e,data:{folderName:r||n,folderId:null!=i?i:null,reason:e instanceof Error?e.message:String(e)}})}},[h,u,y,k,C,A,v,s,a,l,g,b,d]),I=c(()=>{null==v||v(!1)},[v]),T=c((e,t=new Set)=>{const n=Array.isArray(l)?l:[];return e.map(e=>{if(t.has(e.id))return console.warn(`Cycle detected in the folder structure with id=${e.id}. Skipping child elements processing.`),{key:e.id,label:e.name+" "+a("(error)"),icon:r.createElement(ye,{style:{color:"red"}})};const i=new Set(t);i.add(e.id);const o=n.filter(t=>t.parentId===e.id&&t.id!==e.id);return{key:e.id,label:e.name,children:o.length>0?T(o,i):void 0}})},[l]),F=c(()=>{const e=Array.isArray(l)?l:[],t={key:"folders",label:a("Folders"),children:[]},n=e.filter(e=>null===e.parentId||!e.parentId);return t.children=T(n),[t]},[l,a,T]),O=c(async(e,t)=>{var n,r,c,u;let d;try{const h=t.trim(),f=null==l?void 0:l.find(t=>t.id===e);if(!h)return void s.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:a("Folder name cannot be empty"),placement:"bottomRight",data:{folderId:e,folderName:t,reason:"emptyName"}});d=Vo(h,b);if(!(!1!==(null===(n=null==b?void 0:b.features)||void 0===n?void 0:n.enableRenameFolder)))return void s.error({id:"FOLDER_RENAME_DISABLED_BY_CONFIG",message:a("Folder rename is disabled by config"),placement:"bottomRight",data:{itemId:e,itemName:null!==(r=null==f?void 0:f.name)&&void 0!==r?r:d}});if(!(null===(c=o.dataProviders)||void 0===c?void 0:c.renameFolder))return void s.error({id:"FOLDER_RENAME_FAILED",message:a("Folder rename provider is not configured"),placement:"bottomRight",data:{itemId:e,itemName:d,error:{message:"providerNotConfigured"}}});const p=await o.dataProviders.renameFolder(e,d);if(!(null==p?void 0:p.id))return void s.error({id:"FOLDER_RENAME_FAILED",message:a("Unexpected response when renaming folder"),placement:"bottomRight",data:{itemId:e,itemName:d,error:{message:"invalidResponse"}}});await C(),e!==p.id&&i.setSelectedFolder&&i.setSelectedFolder(p.id),s.success({id:"FOLDER_RENAME_SUCCESS",message:a("Folder renamed"),placement:"bottomRight",data:{itemId:p.id,itemName:p.name,folderId:null!==(u=p.parentId)&&void 0!==u?u:null}})}catch(n){console.error("Error renaming the folder:",n),s.error({id:"FOLDER_RENAME_FAILED",message:a("Failed to rename folder"),placement:"bottomRight",innerException:n,data:{itemId:e,itemName:d||t,error:{message:n instanceof Error?n.message:String(n)}}})}},[C,l,null===(e=o.dataProviders)||void 0===e?void 0:e.renameFolder,null===(t=null==b?void 0:b.features)||void 0===t?void 0:t.enableRenameFolder,b,i.setSelectedFolder,s,a]);return{state:{folders:l,isCreatingFolder:p,loading:f},actions:{fetchFolders:C,fetchChildFolders:_,handleCreateFolder:S,handleModalOk:E,handleModalCancel:I,generateMenuItems:F,renameFolder:O}}},Wo=()=>{const{options:e,actions:t}=ro(),{dataProviders:n,config:r}=e,{setUndoDeletion:i}=t,{t:o}=Qn(),a=bo(),s=c(async({items:e,selectedFolder:t,getItemNameById:s,showNotifications:l=!1})=>{let c=0,u=0;const d=[],h=async t=>{if(null==n?void 0:n.deleteItems)try{const r=await n.deleteItems(e.map(e=>e.id),{permanent:t}),i=r.detailed;if(i){const e=i.filter(e=>e.success),t=i.filter(e=>!e.success),n=t.filter(e=>{var t;const n=null!==(t=e.innerException)&&void 0!==t?t:e.error;return Fo(n)}),r=t.filter(e=>{var t;const n=null!==(t=e.innerException)&&void 0!==t?t:e.error;return!Fo(n)});return c+=e.length+n.length,u+=r.length,void r.forEach(e=>{var t;const n=(e=>{var t;return null!==(t=e.requestId)&&void 0!==t?t:e.id})(e),r=null!==(t=e.innerException)&&void 0!==t?t:e.error,i=Io(r);d.push({itemId:n,itemName:s(n),error:i})})}if(r.success)c+=e.length;else{const t=r.error;if(Fo(t))c+=e.length;else if(t){u+=e.length;const n=Io(t);d.push({error:n})}else u+=e.length}return}catch(n){if(Fo(n))c+=e.length;else{const r=t?"Ошибка при удалении":"Ошибка при перемещении в корзину";console.error(r,n),u+=e.length;const i=Io(n);d.push({error:i})}}const r=t?"DataProvider для удаления файлов не настроен":"DataProvider для перемещения не настроен";console.warn(r)},f=(null==r?void 0:r.enableTrashFolder)&&"Trash"===t;return(null==r?void 0:r.enableTrashFolder)&&!f?await h(!1):await h(!0),c>0&&(null==r?void 0:r.enableTrashFolder)&&!f&&(null==i||i({itemIds:e.map(e=>e.id),sourceFolderId:t||"folders"})),l&&(c>0&&a.success({id:"FILES_DELETE_SUCCESS",message:o("Files deleted"),placement:"bottomRight",data:{successCount:c,totalCount:e.length,itemIds:e.map(e=>e.id),folderId:t||null}}),u>0&&a.error({id:"FILES_DELETE_ERROR",message:o("Error when deleting a file"),placement:"bottomRight",data:{failCount:u,totalCount:e.length,itemIds:e.map(e=>e.id),itemNames:e.map(e=>s(e.id)),folderId:t||null,errors:d}})),{successCount:c,failCount:u,errorDetails:d}},[n,r,i,o,a]);return{deleteItems:s}};class $o extends Error{constructor(e,t,n,r){super(e),this.code=t,this.status=n,this.details=r,this.name="FileManagerApiError",Error.captureStackTrace&&Error.captureStackTrace(this,$o)}}const Go=/^(localhost|127\.0\.0\.1|0\.0\.0\.0|::1)$/i,qo=/^(10\.|172\.(1[6-9]|2[0-9]|3[01])\.|192\.168\.)/;function Yo(e,t){const n=e.trim();if(!n)throw new $o(t("Enter the URL of the image"),"UploadUrlInvalid");if(n.length>8192)throw new $o(t("URL too long"),"UploadUrlInvalid");let r;try{r=new URL(n)}catch(e){throw new $o(t("The specified URL is not valid."),"UploadUrlInvalid")}const i=r.protocol.toLowerCase();if("http:"!==i&&"https:"!==i)throw new $o(t("Only http and https URLs are supported"),"UploadUrlInvalid");const o=r.hostname.toLowerCase();if(Go.test(o))throw new $o(t("Private and local URLs are not allowed"),"UploadUrlInvalid");if(qo.test(o))throw new $o(t("Private and local URLs are not allowed"),"UploadUrlInvalid")}function Xo(e,t){return new Promise(function(n,r){let i;return Ko(e).then(function(e){try{return i=e,n(new Blob([t.slice(0,2),i,t.slice(2)],{type:"image/jpeg"}))}catch(e){return r(e)}},r)})}const Ko=e=>new Promise((t,n)=>{const r=new FileReader;r.addEventListener("load",({target:{result:e}})=>{const r=new DataView(e);let i=0;if(65496!==r.getUint16(i))return n("not a valid JPEG");for(i+=2;;){const o=r.getUint16(i);if(65498===o)break;const a=r.getUint16(i+2);if(65505===o&&1165519206===r.getUint32(i+4)){const o=i+10;let s;switch(r.getUint16(o)){case 18761:s=!0;break;case 19789:s=!1;break;default:return n("TIFF header contains invalid endian")}if(42!==r.getUint16(o+2,s))return n("TIFF header contains invalid version");const l=r.getUint32(o+4,s),c=o+l+2+12*r.getUint16(o+l,s);for(let e=o+l+2;e<c;e+=12)if(274==r.getUint16(e,s)){if(3!==r.getUint16(e+2,s))return n("Orientation data type is invalid");if(1!==r.getUint32(e+4,s))return n("Orientation data count is invalid");r.setUint16(e+8,1,s);break}return t(e.slice(i,i+2+a))}i+=2+a}return t(new Blob)}),r.readAsArrayBuffer(e)});var Zo={},Jo={get exports(){return Zo},set exports(e){Zo=e}};!function(){var e,t,n={};Jo.exports=n,n.parse=function(e,t){for(var r=n.bin.readUshort,i=n.bin.readUint,o=0,a={},s=new Uint8Array(e),l=s.length-4;101010256!=i(s,l);)l--;o=l,o+=4;var c=r(s,o+=4);r(s,o+=2);var u=i(s,o+=2),d=i(s,o+=4);o+=4,o=d;for(var h=0;h<c;h++){i(s,o),o+=4,o+=4,o+=4,i(s,o+=4),u=i(s,o+=4);var f=i(s,o+=4),p=r(s,o+=4),g=r(s,o+2),m=r(s,o+4);o+=6;var v=i(s,o+=8);o+=4,o+=p+g+m,n._readLocal(s,v,a,u,f,t)}return a},n._readLocal=function(e,t,r,i,o,a){var s=n.bin.readUshort,l=n.bin.readUint;l(e,t),s(e,t+=4),s(e,t+=2);var c=s(e,t+=2);l(e,t+=2),l(e,t+=4),t+=4;var u=s(e,t+=8),d=s(e,t+=2);t+=2;var h=n.bin.readUTF8(e,t,u);if(t+=u,t+=d,a)r[h]={size:o,csize:i};else{var f=new Uint8Array(e.buffer,t);if(0==c)r[h]=new Uint8Array(f.buffer.slice(t,t+i));else{if(8!=c)throw"unknown compression method: "+c;var p=new Uint8Array(o);n.inflateRaw(f,p),r[h]=p}}},n.inflateRaw=function(e,t){return n.F.inflate(e,t)},n.inflate=function(e,t){return e[0],e[1],n.inflateRaw(new Uint8Array(e.buffer,e.byteOffset+2,e.length-6),t)},n.deflate=function(e,t){null==t&&(t={level:6});var r=0,i=new Uint8Array(50+Math.floor(1.1*e.length));i[r]=120,i[r+1]=156,r+=2,r=n.F.deflateRaw(e,i,r,t.level);var o=n.adler(e,0,e.length);return i[r+0]=o>>>24&255,i[r+1]=o>>>16&255,i[r+2]=o>>>8&255,i[r+3]=o>>>0&255,new Uint8Array(i.buffer,0,r+4)},n.deflateRaw=function(e,t){null==t&&(t={level:6});var r=new Uint8Array(50+Math.floor(1.1*e.length)),i=n.F.deflateRaw(e,r,i,t.level);return new Uint8Array(r.buffer,0,i)},n.encode=function(e,t){null==t&&(t=!1);var r=0,i=n.bin.writeUint,o=n.bin.writeUshort,a={};for(var s in e){var l=!n._noNeed(s)&&!t,c=e[s],u=n.crc.crc(c,0,c.length);a[s]={cpr:l,usize:c.length,crc:u,file:l?n.deflateRaw(c):c}}for(var s in a)r+=a[s].file.length+30+46+2*n.bin.sizeUTF8(s);r+=22;var d=new Uint8Array(r),h=0,f=[];for(var s in a){var p=a[s];f.push(h),h=n._writeHeader(d,h,s,p,0)}var g=0,m=h;for(var s in a)p=a[s],f.push(h),h=n._writeHeader(d,h,s,p,1,f[g++]);var v=h-m;return i(d,h,101010256),h+=4,o(d,h+=4,g),o(d,h+=2,g),i(d,h+=2,v),i(d,h+=4,m),h+=4,h+=2,d.buffer},n._noNeed=function(e){var t=e.split(".").pop().toLowerCase();return-1!="png,jpg,jpeg,zip".indexOf(t)},n._writeHeader=function(e,t,r,i,o,a){var s=n.bin.writeUint,l=n.bin.writeUshort,c=i.file;return s(e,t,0==o?67324752:33639248),t+=4,1==o&&(t+=2),l(e,t,20),l(e,t+=2,0),l(e,t+=2,i.cpr?8:0),s(e,t+=2,0),s(e,t+=4,i.crc),s(e,t+=4,c.length),s(e,t+=4,i.usize),l(e,t+=4,n.bin.sizeUTF8(r)),l(e,t+=2,0),t+=2,1==o&&(t+=2,t+=2,s(e,t+=6,a),t+=4),t+=n.bin.writeUTF8(e,t,r),0==o&&(e.set(c,t),t+=c.length),t},n.crc={table:function(){for(var e=new Uint32Array(256),t=0;t<256;t++){for(var n=t,r=0;r<8;r++)1&n?n=3988292384^n>>>1:n>>>=1;e[t]=n}return e}(),update:function(e,t,r,i){for(var o=0;o<i;o++)e=n.crc.table[255&(e^t[r+o])]^e>>>8;return e},crc:function(e,t,r){return 4294967295^n.crc.update(4294967295,e,t,r)}},n.adler=function(e,t,n){for(var r=1,i=0,o=t,a=t+n;o<a;){for(var s=Math.min(o+5552,a);o<s;)i+=r+=e[o++];r%=65521,i%=65521}return i<<16|r},n.bin={readUshort:function(e,t){return e[t]|e[t+1]<<8},writeUshort:function(e,t,n){e[t]=255&n,e[t+1]=n>>8&255},readUint:function(e,t){return 16777216*e[t+3]+(e[t+2]<<16|e[t+1]<<8|e[t])},writeUint:function(e,t,n){e[t]=255&n,e[t+1]=n>>8&255,e[t+2]=n>>16&255,e[t+3]=n>>24&255},readASCII:function(e,t,n){for(var r="",i=0;i<n;i++)r+=String.fromCharCode(e[t+i]);return r},writeASCII:function(e,t,n){for(var r=0;r<n.length;r++)e[t+r]=n.charCodeAt(r)},pad:function(e){return e.length<2?"0"+e:e},readUTF8:function(e,t,r){for(var i,o="",a=0;a<r;a++)o+="%"+n.bin.pad(e[t+a].toString(16));try{i=decodeURIComponent(o)}catch(i){return n.bin.readASCII(e,t,r)}return i},writeUTF8:function(e,t,n){for(var r=n.length,i=0,o=0;o<r;o++){var a=n.charCodeAt(o);if(4294967168&a)if(4294965248&a)if(4294901760&a){if(4292870144&a)throw"e";e[t+i]=240|a>>18,e[t+i+1]=128|a>>12&63,e[t+i+2]=128|a>>6&63,e[t+i+3]=128|63&a,i+=4}else e[t+i]=224|a>>12,e[t+i+1]=128|a>>6&63,e[t+i+2]=128|63&a,i+=3;else e[t+i]=192|a>>6,e[t+i+1]=128|63&a,i+=2;else e[t+i]=a,i++}return i},sizeUTF8:function(e){for(var t=e.length,n=0,r=0;r<t;r++){var i=e.charCodeAt(r);if(4294967168&i)if(4294965248&i)if(4294901760&i){if(4292870144&i)throw"e";n+=4}else n+=3;else n+=2;else n++}return n}},n.F={},n.F.deflateRaw=function(e,t,r,i){var o=[[0,0,0,0,0],[4,4,8,4,0],[4,5,16,8,0],[4,6,16,16,0],[4,10,16,32,0],[8,16,32,32,0],[8,16,128,128,0],[8,32,128,256,0],[32,128,258,1024,1],[32,258,258,4096,1]][i],a=n.F.U,s=n.F._goodIndex;n.F._hash;var l=n.F._putsE,c=0,u=r<<3,d=0,h=e.length;if(0==i){for(;c<h;)l(t,u,c+(S=Math.min(65535,h-c))==h?1:0),u=n.F._copyExact(e,c,S,t,u+8),c+=S;return u>>>3}var f=a.lits,p=a.strt,g=a.prev,m=0,v=0,y=0,b=0,w=0,x=0;for(h>2&&(p[x=n.F._hash(e,0)]=0),c=0;c<h;c++){if(w=x,c+1<h-2){x=n.F._hash(e,c+1);var C=c+1&32767;g[C]=p[x],p[x]=C}if(d<=c){(m>14e3||v>26697)&&h-c>100&&(d<c&&(f[m]=c-d,m+=2,d=c),u=n.F._writeBlock(c==h-1||d==h?1:0,f,m,b,e,y,c-y,t,u),m=v=b=0,y=c);var _=0;c<h-2&&(_=n.F._bestMatch(e,c,g,w,Math.min(o[2],h-c),o[3]));var S=_>>>16,k=65535&_;if(0!=_){k=65535&_;var A=s(S=_>>>16,a.of0);a.lhst[257+A]++;var E=s(k,a.df0);a.dhst[E]++,b+=a.exb[A]+a.dxb[E],f[m]=S<<23|c-d,f[m+1]=k<<16|A<<8|E,m+=2,d=c+S}else a.lhst[e[c]]++;v++}}for(y==c&&0!=e.length||(d<c&&(f[m]=c-d,m+=2,d=c),u=n.F._writeBlock(1,f,m,b,e,y,c-y,t,u),m=0,v=0,m=v=b=0,y=c);7&u;)u++;return u>>>3},n.F._bestMatch=function(e,t,r,i,o,a){var s=32767&t,l=r[s],c=s-l+32768&32767;if(l==s||i!=n.F._hash(e,t-c))return 0;for(var u=0,d=0,h=Math.min(32767,t);c<=h&&0!=--a&&l!=s;){if(0==u||e[t+u]==e[t+u-c]){var f=n.F._howLong(e,t,c);if(f>u){if(d=c,(u=f)>=o)break;c+2<f&&(f=c+2);for(var p=0,g=0;g<f-2;g++){var m=t-c+g+32768&32767,v=m-r[m]+32768&32767;v>p&&(p=v,l=m)}}}c+=(s=l)-(l=r[s])+32768&32767}return u<<16|d},n.F._howLong=function(e,t,n){if(e[t]!=e[t-n]||e[t+1]!=e[t+1-n]||e[t+2]!=e[t+2-n])return 0;var r=t,i=Math.min(e.length,t+258);for(t+=3;t<i&&e[t]==e[t-n];)t++;return t-r},n.F._hash=function(e,t){return(e[t]<<8|e[t+1])+(e[t+2]<<4)&65535},n.saved=0,n.F._writeBlock=function(e,t,r,i,o,a,s,l,c){var u,d,h,f,p,g,m,v,y,b=n.F.U,w=n.F._putsF,x=n.F._putsE;b.lhst[256]++,d=(u=n.F.getTrees())[0],h=u[1],f=u[2],p=u[3],g=u[4],m=u[5],v=u[6],y=u[7];var C=32+(c+3&7?8-(c+3&7):0)+(s<<3),_=i+n.F.contSize(b.fltree,b.lhst)+n.F.contSize(b.fdtree,b.dhst),S=i+n.F.contSize(b.ltree,b.lhst)+n.F.contSize(b.dtree,b.dhst);S+=14+3*m+n.F.contSize(b.itree,b.ihst)+(2*b.ihst[16]+3*b.ihst[17]+7*b.ihst[18]);for(var k=0;k<286;k++)b.lhst[k]=0;for(k=0;k<30;k++)b.dhst[k]=0;for(k=0;k<19;k++)b.ihst[k]=0;var A=C<_&&C<S?0:_<S?1:2;if(w(l,c,e),w(l,c+1,A),c+=3,0==A){for(;7&c;)c++;c=n.F._copyExact(o,a,s,l,c)}else{var E,I;if(1==A&&(E=b.fltree,I=b.fdtree),2==A){n.F.makeCodes(b.ltree,d),n.F.revCodes(b.ltree,d),n.F.makeCodes(b.dtree,h),n.F.revCodes(b.dtree,h),n.F.makeCodes(b.itree,f),n.F.revCodes(b.itree,f),E=b.ltree,I=b.dtree,x(l,c,p-257),x(l,c+=5,g-1),x(l,c+=5,m-4),c+=4;for(var T=0;T<m;T++)x(l,c+3*T,b.itree[1+(b.ordr[T]<<1)]);c+=3*m,c=n.F._codeTiny(v,b.itree,l,c),c=n.F._codeTiny(y,b.itree,l,c)}for(var F=a,O=0;O<r;O+=2){for(var P=t[O],M=P>>>23,R=F+(8388607&P);F<R;)c=n.F._writeLit(o[F++],E,l,c);if(0!=M){var L=t[O+1],N=L>>16,D=L>>8&255,j=255&L;x(l,c=n.F._writeLit(257+D,E,l,c),M-b.of0[D]),c+=b.exb[D],w(l,c=n.F._writeLit(j,I,l,c),N-b.df0[j]),c+=b.dxb[j],F+=M}}c=n.F._writeLit(256,E,l,c)}return c},n.F._copyExact=function(e,t,n,r,i){var o=i>>>3;return r[o]=n,r[o+1]=n>>>8,r[o+2]=255-r[o],r[o+3]=255-r[o+1],o+=4,r.set(new Uint8Array(e.buffer,t,n),o),i+(n+4<<3)},n.F.getTrees=function(){for(var e=n.F.U,t=n.F._hufTree(e.lhst,e.ltree,15),r=n.F._hufTree(e.dhst,e.dtree,15),i=[],o=n.F._lenCodes(e.ltree,i),a=[],s=n.F._lenCodes(e.dtree,a),l=0;l<i.length;l+=2)e.ihst[i[l]]++;for(l=0;l<a.length;l+=2)e.ihst[a[l]]++;for(var c=n.F._hufTree(e.ihst,e.itree,7),u=19;u>4&&0==e.itree[1+(e.ordr[u-1]<<1)];)u--;return[t,r,c,o,s,u,i,a]},n.F.getSecond=function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(e[n+1]);return t},n.F.nonZero=function(e){for(var t="",n=0;n<e.length;n+=2)0!=e[n+1]&&(t+=(n>>1)+",");return t},n.F.contSize=function(e,t){for(var n=0,r=0;r<t.length;r++)n+=t[r]*e[1+(r<<1)];return n},n.F._codeTiny=function(e,t,r,i){for(var o=0;o<e.length;o+=2){var a=e[o],s=e[o+1];i=n.F._writeLit(a,t,r,i);var l=16==a?2:17==a?3:7;a>15&&(n.F._putsE(r,i,s,l),i+=l)}return i},n.F._lenCodes=function(e,t){for(var n=e.length;2!=n&&0==e[n-1];)n-=2;for(var r=0;r<n;r+=2){var i=e[r+1],o=r+3<n?e[r+3]:-1,a=r+5<n?e[r+5]:-1,s=0==r?-1:e[r-1];if(0==i&&o==i&&a==i){for(var l=r+5;l+2<n&&e[l+2]==i;)l+=2;(c=Math.min(l+1-r>>>1,138))<11?t.push(17,c-3):t.push(18,c-11),r+=2*c-2}else if(i==s&&o==i&&a==i){for(l=r+5;l+2<n&&e[l+2]==i;)l+=2;var c=Math.min(l+1-r>>>1,6);t.push(16,c-3),r+=2*c-2}else t.push(i,0)}return n>>>1},n.F._hufTree=function(e,t,r){var i=[],o=e.length,a=t.length,s=0;for(s=0;s<a;s+=2)t[s]=0,t[s+1]=0;for(s=0;s<o;s++)0!=e[s]&&i.push({lit:s,f:e[s]});var l=i.length,c=i.slice(0);if(0==l)return 0;if(1==l){var u=i[0].lit;return c=0==u?1:0,t[1+(u<<1)]=1,t[1+(c<<1)]=1,1}i.sort(function(e,t){return e.f-t.f});var d=i[0],h=i[1],f=0,p=1,g=2;for(i[0]={lit:-1,f:d.f+h.f,l:d,r:h,d:0};p!=l-1;)d=f!=p&&(g==l||i[f].f<i[g].f)?i[f++]:i[g++],h=f!=p&&(g==l||i[f].f<i[g].f)?i[f++]:i[g++],i[p++]={lit:-1,f:d.f+h.f,l:d,r:h};var m=n.F.setDepth(i[p-1],0);for(m>r&&(n.F.restrictDepth(c,r,m),m=r),s=0;s<l;s++)t[1+(c[s].lit<<1)]=c[s].d;return m},n.F.setDepth=function(e,t){return-1!=e.lit?(e.d=t,t):Math.max(n.F.setDepth(e.l,t+1),n.F.setDepth(e.r,t+1))},n.F.restrictDepth=function(e,t,n){var r=0,i=1<<n-t,o=0;for(e.sort(function(e,t){return t.d==e.d?e.f-t.f:t.d-e.d}),r=0;r<e.length&&e[r].d>t;r++){var a=e[r].d;e[r].d=t,o+=i-(1<<n-a)}for(o>>>=n-t;o>0;)(a=e[r].d)<t?(e[r].d++,o-=1<<t-a-1):r++;for(;r>=0;r--)e[r].d==t&&o<0&&(e[r].d--,o++);0!=o&&console.log("debt left")},n.F._goodIndex=function(e,t){var n=0;return t[16|n]<=e&&(n|=16),t[8|n]<=e&&(n|=8),t[4|n]<=e&&(n|=4),t[2|n]<=e&&(n|=2),t[1|n]<=e&&(n|=1),n},n.F._writeLit=function(e,t,r,i){return n.F._putsF(r,i,t[e<<1]),i+t[1+(e<<1)]},n.F.inflate=function(e,t){var r=Uint8Array;if(3==e[0]&&0==e[1])return t||new r(0);var i=n.F,o=i._bitsF,a=i._bitsE,s=i._decodeTiny,l=i.makeCodes,c=i.codes2map,u=i._get17,d=i.U,h=null==t;h&&(t=new r(e.length>>>2<<3));for(var f,p,g=0,m=0,v=0,y=0,b=0,w=0,x=0,C=0,_=0;0==g;)if(g=o(e,_,1),m=o(e,_+1,2),_+=3,0!=m){if(h&&(t=n.F._check(t,C+(1<<17))),1==m&&(f=d.flmap,p=d.fdmap,w=511,x=31),2==m){v=a(e,_,5)+257,y=a(e,_+5,5)+1,b=a(e,_+10,4)+4,_+=14;for(var S=0;S<38;S+=2)d.itree[S]=0,d.itree[S+1]=0;var k=1;for(S=0;S<b;S++){var A=a(e,_+3*S,3);d.itree[1+(d.ordr[S]<<1)]=A,A>k&&(k=A)}_+=3*b,l(d.itree,k),c(d.itree,k,d.imap),f=d.lmap,p=d.dmap,_=s(d.imap,(1<<k)-1,v+y,e,_,d.ttree);var E=i._copyOut(d.ttree,0,v,d.ltree);w=(1<<E)-1;var I=i._copyOut(d.ttree,v,y,d.dtree);x=(1<<I)-1,l(d.ltree,E),c(d.ltree,E,f),l(d.dtree,I),c(d.dtree,I,p)}for(;;){var T=f[u(e,_)&w];_+=15&T;var F=T>>>4;if(F>>>8==0)t[C++]=F;else{if(256==F)break;var O=C+F-254;if(F>264){var P=d.ldef[F-257];O=C+(P>>>3)+a(e,_,7&P),_+=7&P}var M=p[u(e,_)&x];_+=15&M;var R=M>>>4,L=d.ddef[R],N=(L>>>4)+o(e,_,15&L);for(_+=15&L,h&&(t=n.F._check(t,C+(1<<17)));C<O;)t[C]=t[C++-N],t[C]=t[C++-N],t[C]=t[C++-N],t[C]=t[C++-N];C=O}}}else{7&_&&(_+=8-(7&_));var D=4+(_>>>3),j=e[D-4]|e[D-3]<<8;h&&(t=n.F._check(t,C+j)),t.set(new r(e.buffer,e.byteOffset+D,j),C),_=D+j<<3,C+=j}return t.length==C?t:t.slice(0,C)},n.F._check=function(e,t){var n=e.length;if(t<=n)return e;var r=new Uint8Array(Math.max(n<<1,t));return r.set(e,0),r},n.F._decodeTiny=function(e,t,r,i,o,a){for(var s=n.F._bitsE,l=n.F._get17,c=0;c<r;){var u=e[l(i,o)&t];o+=15&u;var d=u>>>4;if(d<=15)a[c]=d,c++;else{var h=0,f=0;16==d?(f=3+s(i,o,2),o+=2,h=a[c-1]):17==d?(f=3+s(i,o,3),o+=3):18==d&&(f=11+s(i,o,7),o+=7);for(var p=c+f;c<p;)a[c]=h,c++}}return o},n.F._copyOut=function(e,t,n,r){for(var i=0,o=0,a=r.length>>>1;o<n;){var s=e[o+t];r[o<<1]=0,r[1+(o<<1)]=s,s>i&&(i=s),o++}for(;o<a;)r[o<<1]=0,r[1+(o<<1)]=0,o++;return i},n.F.makeCodes=function(e,t){for(var r,i,o,a,s=n.F.U,l=e.length,c=s.bl_count,u=0;u<=t;u++)c[u]=0;for(u=1;u<l;u+=2)c[e[u]]++;var d=s.next_code;for(r=0,c[0]=0,i=1;i<=t;i++)r=r+c[i-1]<<1,d[i]=r;for(o=0;o<l;o+=2)0!=(a=e[o+1])&&(e[o]=d[a],d[a]++)},n.F.codes2map=function(e,t,r){for(var i=e.length,o=n.F.U.rev15,a=0;a<i;a+=2)if(0!=e[a+1])for(var s=a>>1,l=e[a+1],c=s<<4|l,u=t-l,d=e[a]<<u,h=d+(1<<u);d!=h;)r[o[d]>>>15-t]=c,d++},n.F.revCodes=function(e,t){for(var r=n.F.U.rev15,i=15-t,o=0;o<e.length;o+=2){var a=e[o]<<t-e[o+1];e[o]=r[a]>>>i}},n.F._putsE=function(e,t,n){n<<=7&t;var r=t>>>3;e[r]|=n,e[r+1]|=n>>>8},n.F._putsF=function(e,t,n){n<<=7&t;var r=t>>>3;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},n.F._bitsE=function(e,t,n){return(e[t>>>3]|e[1+(t>>>3)]<<8)>>>(7&t)&(1<<n)-1},n.F._bitsF=function(e,t,n){return(e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)&(1<<n)-1},n.F._get17=function(e,t){return(e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)},n.F._get25=function(e,t){return(e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16|e[3+(t>>>3)]<<24)>>>(7&t)},n.F.U=(e=Uint16Array,t=Uint32Array,{next_code:new e(16),bl_count:new e(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[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,999,999,999],exb:[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,0,0,0],ldef:new e(32),df0:[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,65535,65535],dxb:[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,0,0],ddef:new t(32),flmap:new e(512),fltree:[],fdmap:new e(32),fdtree:[],lmap:new e(32768),ltree:[],ttree:[],dmap:new e(32768),dtree:[],imap:new e(512),itree:[],rev15:new e(32768),lhst:new t(286),dhst:new t(30),ihst:new t(19),lits:new t(15e3),strt:new e(65536),prev:new e(32768)}),function(){for(var e=n.F.U,t=0;t<32768;t++){var r=t;r=(4278255360&(r=(4042322160&(r=(3435973836&(r=(2863311530&r)>>>1|(1431655765&r)<<1))>>>2|(858993459&r)<<2))>>>4|(252645135&r)<<4))>>>8|(16711935&r)<<8,e.rev15[t]=(r>>>16|r<<16)>>>17}function i(e,t,n){for(;0!=t--;)e.push(0,n)}for(t=0;t<32;t++)e.ldef[t]=e.of0[t]<<3|e.exb[t],e.ddef[t]=e.df0[t]<<4|e.dxb[t];i(e.fltree,144,8),i(e.fltree,112,9),i(e.fltree,24,7),i(e.fltree,8,8),n.F.makeCodes(e.fltree,9),n.F.codes2map(e.fltree,9,e.flmap),n.F.revCodes(e.fltree,9),i(e.fdtree,32,5),n.F.makeCodes(e.fdtree,5),n.F.codes2map(e.fdtree,5,e.fdmap),n.F.revCodes(e.fdtree,5),i(e.itree,19,0),i(e.ltree,286,0),i(e.dtree,30,0),i(e.ttree,320,0)}()}();var Qo=function(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(e)}({__proto__:null,default:Zo},[Zo]);const ea=function(){var e={nextZero(e,t){for(;0!=e[t];)t++;return t},readUshort:(e,t)=>e[t]<<8|e[t+1],writeUshort(e,t,n){e[t]=n>>8&255,e[t+1]=255&n},readUint:(e,t)=>16777216*e[t]+(e[t+1]<<16|e[t+2]<<8|e[t+3]),writeUint(e,t,n){e[t]=n>>24&255,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n},readASCII(e,t,n){let r="";for(let i=0;i<n;i++)r+=String.fromCharCode(e[t+i]);return r},writeASCII(e,t,n){for(let r=0;r<n.length;r++)e[t+r]=n.charCodeAt(r)},readBytes(e,t,n){const r=[];for(let i=0;i<n;i++)r.push(e[t+i]);return r},pad:e=>e.length<2?`0${e}`:e,readUTF8(t,n,r){let i,o="";for(let i=0;i<r;i++)o+=`%${e.pad(t[n+i].toString(16))}`;try{i=decodeURIComponent(o)}catch(i){return e.readASCII(t,n,r)}return i}};function t(t,n,r,i){const a=n*r,s=o(i),l=Math.ceil(n*s/8),c=new Uint8Array(4*a),u=new Uint32Array(c.buffer),{ctype:d}=i,{depth:h}=i,f=e.readUshort;if(6==d){const e=a<<2;if(8==h)for(var p=0;p<e;p+=4)c[p]=t[p],c[p+1]=t[p+1],c[p+2]=t[p+2],c[p+3]=t[p+3];if(16==h)for(p=0;p<e;p++)c[p]=t[p<<1]}else if(2==d){const e=i.tabs.tRNS;if(null==e){if(8==h)for(p=0;p<a;p++){var g=3*p;u[p]=255<<24|t[g+2]<<16|t[g+1]<<8|t[g]}if(16==h)for(p=0;p<a;p++)g=6*p,u[p]=255<<24|t[g+4]<<16|t[g+2]<<8|t[g]}else{var m=e[0];const n=e[1],r=e[2];if(8==h)for(p=0;p<a;p++){var v=p<<2;g=3*p,u[p]=255<<24|t[g+2]<<16|t[g+1]<<8|t[g],t[g]==m&&t[g+1]==n&&t[g+2]==r&&(c[v+3]=0)}if(16==h)for(p=0;p<a;p++)v=p<<2,g=6*p,u[p]=255<<24|t[g+4]<<16|t[g+2]<<8|t[g],f(t,g)==m&&f(t,g+2)==n&&f(t,g+4)==r&&(c[v+3]=0)}}else if(3==d){const e=i.tabs.PLTE,o=i.tabs.tRNS,s=o?o.length:0;if(1==h)for(var y=0;y<r;y++){var b=y*l,w=y*n;for(p=0;p<n;p++){v=w+p<<2;var x=3*(C=t[b+(p>>3)]>>7-(7&p)&1);c[v]=e[x],c[v+1]=e[x+1],c[v+2]=e[x+2],c[v+3]=C<s?o[C]:255}}if(2==h)for(y=0;y<r;y++)for(b=y*l,w=y*n,p=0;p<n;p++)v=w+p<<2,x=3*(C=t[b+(p>>2)]>>6-((3&p)<<1)&3),c[v]=e[x],c[v+1]=e[x+1],c[v+2]=e[x+2],c[v+3]=C<s?o[C]:255;if(4==h)for(y=0;y<r;y++)for(b=y*l,w=y*n,p=0;p<n;p++)v=w+p<<2,x=3*(C=t[b+(p>>1)]>>4-((1&p)<<2)&15),c[v]=e[x],c[v+1]=e[x+1],c[v+2]=e[x+2],c[v+3]=C<s?o[C]:255;if(8==h)for(p=0;p<a;p++){var C;v=p<<2,x=3*(C=t[p]),c[v]=e[x],c[v+1]=e[x+1],c[v+2]=e[x+2],c[v+3]=C<s?o[C]:255}}else if(4==d){if(8==h)for(p=0;p<a;p++){v=p<<2;var _=t[S=p<<1];c[v]=_,c[v+1]=_,c[v+2]=_,c[v+3]=t[S+1]}if(16==h)for(p=0;p<a;p++){var S;v=p<<2,_=t[S=p<<2],c[v]=_,c[v+1]=_,c[v+2]=_,c[v+3]=t[S+2]}}else if(0==d)for(m=i.tabs.tRNS?i.tabs.tRNS:-1,y=0;y<r;y++){const e=y*l,r=y*n;if(1==h)for(var k=0;k<n;k++){var A=(_=255*(t[e+(k>>>3)]>>>7-(7&k)&1))==255*m?0:255;u[r+k]=A<<24|_<<16|_<<8|_}else if(2==h)for(k=0;k<n;k++)A=(_=85*(t[e+(k>>>2)]>>>6-((3&k)<<1)&3))==85*m?0:255,u[r+k]=A<<24|_<<16|_<<8|_;else if(4==h)for(k=0;k<n;k++)A=(_=17*(t[e+(k>>>1)]>>>4-((1&k)<<2)&15))==17*m?0:255,u[r+k]=A<<24|_<<16|_<<8|_;else if(8==h)for(k=0;k<n;k++)A=(_=t[e+k])==m?0:255,u[r+k]=A<<24|_<<16|_<<8|_;else if(16==h)for(k=0;k<n;k++)_=t[e+(k<<1)],A=f(t,e+(k<<1))==m?0:255,u[r+k]=A<<24|_<<16|_<<8|_}return c}function n(e,t,n,s){const l=o(e),c=Math.ceil(n*l/8),u=new Uint8Array((c+1+e.interlace)*s);return t=e.tabs.CgBI?i(t,u):r(t,u),0==e.interlace?t=a(t,e,0,n,s):1==e.interlace&&(t=function(e,t){const n=t.width,r=t.height,i=o(t),s=i>>3,l=Math.ceil(n*i/8),c=new Uint8Array(r*l);let u=0;const d=[0,0,4,0,2,0,1],h=[0,4,0,2,0,1,0],f=[8,8,8,4,4,2,2],p=[8,8,4,4,2,2,1];let g=0;for(;g<7;){const o=f[g],v=p[g];let y=0,b=0,w=d[g];for(;w<r;)w+=o,b++;let x=h[g];for(;x<n;)x+=v,y++;const C=Math.ceil(y*i/8);a(e,t,u,y,b);let _=0,S=d[g];for(;S<r;){let t=h[g],r=u+_*C<<3;for(;t<n;){var m;if(1==i&&(m=(m=e[r>>3])>>7-(7&r)&1,c[S*l+(t>>3)]|=m<<7-(7&t)),2==i&&(m=(m=e[r>>3])>>6-(7&r)&3,c[S*l+(t>>2)]|=m<<6-((3&t)<<1)),4==i&&(m=(m=e[r>>3])>>4-(7&r)&15,c[S*l+(t>>1)]|=m<<4-((1&t)<<2)),i>=8){const n=S*l+t*s;for(let t=0;t<s;t++)c[n+t]=e[(r>>3)+t]}r+=i,t+=v}_++,S+=o}y*b!=0&&(u+=b*(1+C)),g+=1}return c}(t,e)),t}function r(e,t){return i(new Uint8Array(e.buffer,2,e.length-6),t)}var i=function(){const e={H:{}};return e.H.N=function(t,n){const r=Uint8Array;let i,o,a=0,s=0,l=0,c=0,u=0,d=0,h=0,f=0,p=0;if(3==t[0]&&0==t[1])return n||new r(0);const g=e.H,m=g.b,v=g.e,y=g.R,b=g.n,w=g.A,x=g.Z,C=g.m,_=null==n;for(_&&(n=new r(t.length>>>2<<5));0==a;)if(a=m(t,p,1),s=m(t,p+1,2),p+=3,0!=s){if(_&&(n=e.H.W(n,f+(1<<17))),1==s&&(i=C.J,o=C.h,d=511,h=31),2==s){l=v(t,p,5)+257,c=v(t,p+5,5)+1,u=v(t,p+10,4)+4,p+=14;let e=1;for(var S=0;S<38;S+=2)C.Q[S]=0,C.Q[S+1]=0;for(S=0;S<u;S++){const n=v(t,p+3*S,3);C.Q[1+(C.X[S]<<1)]=n,n>e&&(e=n)}p+=3*u,b(C.Q,e),w(C.Q,e,C.u),i=C.w,o=C.d,p=y(C.u,(1<<e)-1,l+c,t,p,C.v);const n=g.V(C.v,0,l,C.C);d=(1<<n)-1;const r=g.V(C.v,l,c,C.D);h=(1<<r)-1,b(C.C,n),w(C.C,n,i),b(C.D,r),w(C.D,r,o)}for(;;){const e=i[x(t,p)&d];p+=15&e;const r=e>>>4;if(r>>>8==0)n[f++]=r;else{if(256==r)break;{let e=f+r-254;if(r>264){const n=C.q[r-257];e=f+(n>>>3)+v(t,p,7&n),p+=7&n}const i=o[x(t,p)&h];p+=15&i;const a=i>>>4,s=C.c[a],l=(s>>>4)+m(t,p,15&s);for(p+=15&s;f<e;)n[f]=n[f++-l],n[f]=n[f++-l],n[f]=n[f++-l],n[f]=n[f++-l];f=e}}}}else{7&p&&(p+=8-(7&p));const i=4+(p>>>3),o=t[i-4]|t[i-3]<<8;_&&(n=e.H.W(n,f+o)),n.set(new r(t.buffer,t.byteOffset+i,o),f),p=i+o<<3,f+=o}return n.length==f?n:n.slice(0,f)},e.H.W=function(e,t){const n=e.length;if(t<=n)return e;const r=new Uint8Array(n<<1);return r.set(e,0),r},e.H.R=function(t,n,r,i,o,a){const s=e.H.e,l=e.H.Z;let c=0;for(;c<r;){const e=t[l(i,o)&n];o+=15&e;const r=e>>>4;if(r<=15)a[c]=r,c++;else{let e=0,t=0;16==r?(t=3+s(i,o,2),o+=2,e=a[c-1]):17==r?(t=3+s(i,o,3),o+=3):18==r&&(t=11+s(i,o,7),o+=7);const n=c+t;for(;c<n;)a[c]=e,c++}}return o},e.H.V=function(e,t,n,r){let i=0,o=0;const a=r.length>>>1;for(;o<n;){const n=e[o+t];r[o<<1]=0,r[1+(o<<1)]=n,n>i&&(i=n),o++}for(;o<a;)r[o<<1]=0,r[1+(o<<1)]=0,o++;return i},e.H.n=function(t,n){const r=e.H.m,i=t.length;let o,a,s,l;const c=r.j;for(var u=0;u<=n;u++)c[u]=0;for(u=1;u<i;u+=2)c[t[u]]++;const d=r.K;for(o=0,c[0]=0,a=1;a<=n;a++)o=o+c[a-1]<<1,d[a]=o;for(s=0;s<i;s+=2)l=t[s+1],0!=l&&(t[s]=d[l],d[l]++)},e.H.A=function(t,n,r){const i=t.length,o=e.H.m.r;for(let e=0;e<i;e+=2)if(0!=t[e+1]){const i=e>>1,a=t[e+1],s=i<<4|a,l=n-a;let c=t[e]<<l;const u=c+(1<<l);for(;c!=u;)r[o[c]>>>15-n]=s,c++}},e.H.l=function(t,n){const r=e.H.m.r,i=15-n;for(let e=0;e<t.length;e+=2){const o=t[e]<<n-t[e+1];t[e]=r[o]>>>i}},e.H.M=function(e,t,n){n<<=7&t;const r=t>>>3;e[r]|=n,e[r+1]|=n>>>8},e.H.I=function(e,t,n){n<<=7&t;const r=t>>>3;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},e.H.e=function(e,t,n){return(e[t>>>3]|e[1+(t>>>3)]<<8)>>>(7&t)&(1<<n)-1},e.H.b=function(e,t,n){return(e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)&(1<<n)-1},e.H.Z=function(e,t){return(e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16)>>>(7&t)},e.H.i=function(e,t){return(e[t>>>3]|e[1+(t>>>3)]<<8|e[2+(t>>>3)]<<16|e[3+(t>>>3)]<<24)>>>(7&t)},e.H.m=function(){const e=Uint16Array,t=Uint32Array;return{K:new e(16),j:new e(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[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,999,999,999],T:[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,0,0,0],q:new e(32),p:[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,65535,65535],z:[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,0,0],c:new t(32),J:new e(512),_:[],h:new e(32),$:[],w:new e(32768),C:[],v:[],d:new e(32768),D:[],u:new e(512),Q:[],r:new e(32768),s:new t(286),Y:new t(30),a:new t(19),t:new t(15e3),k:new e(65536),g:new e(32768)}}(),function(){const t=e.H.m;for(var n=0;n<32768;n++){let e=n;e=(2863311530&e)>>>1|(1431655765&e)<<1,e=(3435973836&e)>>>2|(858993459&e)<<2,e=(4042322160&e)>>>4|(252645135&e)<<4,e=(4278255360&e)>>>8|(16711935&e)<<8,t.r[n]=(e>>>16|e<<16)>>>17}function r(e,t,n){for(;0!=t--;)e.push(0,n)}for(n=0;n<32;n++)t.q[n]=t.S[n]<<3|t.T[n],t.c[n]=t.p[n]<<4|t.z[n];r(t._,144,8),r(t._,112,9),r(t._,24,7),r(t._,8,8),e.H.n(t._,9),e.H.A(t._,9,t.J),e.H.l(t._,9),r(t.$,32,5),e.H.n(t.$,5),e.H.A(t.$,5,t.h),e.H.l(t.$,5),r(t.Q,19,0),r(t.C,286,0),r(t.D,30,0),r(t.v,320,0)}(),e.H.N}();function o(e){return[1,null,3,1,2,null,4][e.ctype]*e.depth}function a(e,t,n,r,i){let a=o(t);const l=Math.ceil(r*a/8);let c,u;a=Math.ceil(a/8);let d=e[n],h=0;if(d>1&&(e[n]=[0,0,1][d-2]),3==d)for(h=a;h<l;h++)e[h+1]=e[h+1]+(e[h+1-a]>>>1)&255;for(let t=0;t<i;t++)if(c=n+t*l,u=c+t+1,d=e[u-1],h=0,0==d)for(;h<l;h++)e[c+h]=e[u+h];else if(1==d){for(;h<a;h++)e[c+h]=e[u+h];for(;h<l;h++)e[c+h]=e[u+h]+e[c+h-a]}else if(2==d)for(;h<l;h++)e[c+h]=e[u+h]+e[c+h-l];else if(3==d){for(;h<a;h++)e[c+h]=e[u+h]+(e[c+h-l]>>>1);for(;h<l;h++)e[c+h]=e[u+h]+(e[c+h-l]+e[c+h-a]>>>1)}else{for(;h<a;h++)e[c+h]=e[u+h]+s(0,e[c+h-l],0);for(;h<l;h++)e[c+h]=e[u+h]+s(e[c+h-a],e[c+h-l],e[c+h-a-l])}return e}function s(e,t,n){const r=e+t-n,i=r-e,o=r-t,a=r-n;return i*i<=o*o&&i*i<=a*a?e:o*o<=a*a?t:n}function l(t,n,r){r.width=e.readUint(t,n),n+=4,r.height=e.readUint(t,n),n+=4,r.depth=t[n],n++,r.ctype=t[n],n++,r.compress=t[n],n++,r.filter=t[n],n++,r.interlace=t[n],n++}function c(e,t,n,r,i,o,a,s,l){const c=Math.min(t,i),u=Math.min(n,o);let d=0,h=0;for(let n=0;n<u;n++)for(let o=0;o<c;o++)if(a>=0&&s>=0?(d=n*t+o<<2,h=(s+n)*i+a+o<<2):(d=(-s+n)*t-a+o<<2,h=n*i+o<<2),0==l)r[h]=e[d],r[h+1]=e[d+1],r[h+2]=e[d+2],r[h+3]=e[d+3];else if(1==l){var f=e[d+3]*(1/255),p=e[d]*f,g=e[d+1]*f,m=e[d+2]*f,v=r[h+3]*(1/255),y=r[h]*v,b=r[h+1]*v,w=r[h+2]*v;const t=1-f,n=f+v*t,i=0==n?0:1/n;r[h+3]=255*n,r[h+0]=(p+y*t)*i,r[h+1]=(g+b*t)*i,r[h+2]=(m+w*t)*i}else if(2==l)f=e[d+3],p=e[d],g=e[d+1],m=e[d+2],v=r[h+3],y=r[h],b=r[h+1],w=r[h+2],f==v&&p==y&&g==b&&m==w?(r[h]=0,r[h+1]=0,r[h+2]=0,r[h+3]=0):(r[h]=p,r[h+1]=g,r[h+2]=m,r[h+3]=f);else if(3==l){if(f=e[d+3],p=e[d],g=e[d+1],m=e[d+2],v=r[h+3],y=r[h],b=r[h+1],w=r[h+2],f==v&&p==y&&g==b&&m==w)continue;if(f<220&&v>20)return!1}return!0}return{decode:function(t){const o=new Uint8Array(t);let a=8;const s=e,c=s.readUshort,u=s.readUint,d={tabs:{},frames:[]},h=new Uint8Array(o.length);let f,p=0,g=0;const m=[137,80,78,71,13,10,26,10];for(var v=0;v<8;v++)if(o[v]!=m[v])throw"The input is not a PNG file!";for(;a<o.length;){const e=s.readUint(o,a);a+=4;const t=s.readASCII(o,a,4);if(a+=4,"IHDR"==t)l(o,a,d);else if("iCCP"==t){for(var y=a;0!=o[y];)y++;s.readASCII(o,a,y-a),o[y+1];const n=o.slice(y+2,a+e);let l=null;try{l=r(n)}catch(e){l=i(n)}d.tabs[t]=l}else if("CgBI"==t)d.tabs[t]=o.slice(a,a+4);else if("IDAT"==t){for(v=0;v<e;v++)h[p+v]=o[a+v];p+=e}else if("acTL"==t)d.tabs[t]={num_frames:u(o,a),num_plays:u(o,a+4)},f=new Uint8Array(o.length);else if("fcTL"==t){0!=g&&((S=d.frames[d.frames.length-1]).data=n(d,f.slice(0,g),S.rect.width,S.rect.height),g=0);const e={x:u(o,a+12),y:u(o,a+16),width:u(o,a+4),height:u(o,a+8)};let t=c(o,a+22);t=c(o,a+20)/(0==t?100:t);const r={rect:e,delay:Math.round(1e3*t),dispose:o[a+24],blend:o[a+25]};d.frames.push(r)}else if("fdAT"==t){for(v=0;v<e-4;v++)f[g+v]=o[a+v+4];g+=e-4}else if("pHYs"==t)d.tabs[t]=[s.readUint(o,a),s.readUint(o,a+4),o[a+8]];else if("cHRM"==t)for(d.tabs[t]=[],v=0;v<8;v++)d.tabs[t].push(s.readUint(o,a+4*v));else if("tEXt"==t||"zTXt"==t){null==d.tabs[t]&&(d.tabs[t]={});var b=s.nextZero(o,a),w=s.readASCII(o,a,b-a),x=a+e-b-1;if("tEXt"==t)_=s.readASCII(o,b+1,x);else{var C=r(o.slice(b+2,b+2+x));_=s.readUTF8(C,0,C.length)}d.tabs[t][w]=_}else if("iTXt"==t){null==d.tabs[t]&&(d.tabs[t]={}),b=0,y=a,b=s.nextZero(o,y),w=s.readASCII(o,y,b-y);const n=o[y=b+1];var _;o[y+1],y+=2,b=s.nextZero(o,y),s.readASCII(o,y,b-y),y=b+1,b=s.nextZero(o,y),s.readUTF8(o,y,b-y),x=e-((y=b+1)-a),0==n?_=s.readUTF8(o,y,x):(C=r(o.slice(y,y+x)),_=s.readUTF8(C,0,C.length)),d.tabs[t][w]=_}else if("PLTE"==t)d.tabs[t]=s.readBytes(o,a,e);else if("hIST"==t){const e=d.tabs.PLTE.length/3;for(d.tabs[t]=[],v=0;v<e;v++)d.tabs[t].push(c(o,a+2*v))}else if("tRNS"==t)3==d.ctype?d.tabs[t]=s.readBytes(o,a,e):0==d.ctype?d.tabs[t]=c(o,a):2==d.ctype&&(d.tabs[t]=[c(o,a),c(o,a+2),c(o,a+4)]);else if("gAMA"==t)d.tabs[t]=s.readUint(o,a)/1e5;else if("sRGB"==t)d.tabs[t]=o[a];else if("bKGD"==t)0==d.ctype||4==d.ctype?d.tabs[t]=[c(o,a)]:2==d.ctype||6==d.ctype?d.tabs[t]=[c(o,a),c(o,a+2),c(o,a+4)]:3==d.ctype&&(d.tabs[t]=o[a]);else if("IEND"==t)break;a+=e,s.readUint(o,a),a+=4}var S;return 0!=g&&((S=d.frames[d.frames.length-1]).data=n(d,f.slice(0,g),S.rect.width,S.rect.height)),d.data=n(d,h,d.width,d.height),delete d.compress,delete d.interlace,delete d.filter,d},toRGBA8:function(e){const n=e.width,r=e.height;if(null==e.tabs.acTL)return[t(e.data,n,r,e).buffer];const i=[];null==e.frames[0].data&&(e.frames[0].data=e.data);const o=n*r*4,a=new Uint8Array(o),s=new Uint8Array(o),l=new Uint8Array(o);for(let d=0;d<e.frames.length;d++){const h=e.frames[d],f=h.rect.x,p=h.rect.y,g=h.rect.width,m=h.rect.height,v=t(h.data,g,m,e);if(0!=d)for(var u=0;u<o;u++)l[u]=a[u];if(0==h.blend?c(v,g,m,a,n,r,f,p,0):1==h.blend&&c(v,g,m,a,n,r,f,p,1),i.push(a.buffer.slice(0)),0==h.dispose);else if(1==h.dispose)c(s,g,m,a,n,r,f,p,0);else if(2==h.dispose)for(u=0;u<o;u++)a[u]=l[u]}return i},_paeth:s,_copyTile:c,_bin:e}}();!function(){const{_copyTile:e}=ea,{_bin:t}=ea,n=ea._paeth;var r={table:function(){const e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)1&n?n=3988292384^n>>>1:n>>>=1;e[t]=n}return e}(),update(e,t,n,i){for(let o=0;o<i;o++)e=r.table[255&(e^t[n+o])]^e>>>8;return e},crc:(e,t,n)=>4294967295^r.update(4294967295,e,t,n)};function i(e,t,n,r){t[n]+=e[0]*r>>4,t[n+1]+=e[1]*r>>4,t[n+2]+=e[2]*r>>4,t[n+3]+=e[3]*r>>4}function o(e){return Math.max(0,Math.min(255,e))}function a(e,t){const n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2],o=e[3]-t[3];return n*n+r*r+i*i+o*o}function s(e,t,n,r,s,l,c){null==c&&(c=1);const u=r.length,d=[];for(var h=0;h<u;h++){const e=r[h];d.push([e>>>0&255,e>>>8&255,e>>>16&255,e>>>24&255])}for(h=0;h<u;h++){let e=4294967295;for(var f=0,p=0;p<u;p++){var g=a(d[h],d[p]);p!=h&&g<e&&(e=g,f=p)}}const m=new Uint32Array(s.buffer),v=new Int16Array(t*n*4),y=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];for(h=0;h<y.length;h++)y[h]=255*((y[h]+.5)/16-.5);for(let s=0;s<n;s++)for(let w=0;w<t;w++){var b;h=4*(s*t+w),2!=c?b=[o(e[h]+v[h]),o(e[h+1]+v[h+1]),o(e[h+2]+v[h+2]),o(e[h+3]+v[h+3])]:(g=y[4*(3&s)+(3&w)],b=[o(e[h]+g),o(e[h+1]+g),o(e[h+2]+g),o(e[h+3]+g)]),f=0;let x=16777215;for(p=0;p<u;p++){const e=a(b,d[p]);e<x&&(x=e,f=p)}const C=d[f],_=[b[0]-C[0],b[1]-C[1],b[2]-C[2],b[3]-C[3]];1==c&&(w!=t-1&&i(_,v,h+4,7),s!=n-1&&(0!=w&&i(_,v,h+4*t-4,3),i(_,v,h+4*t,5),w!=t-1&&i(_,v,h+4*t+4,1))),l[h>>2]=f,m[h>>2]=r[f]}}function l(e,n,i,o,a){null==a&&(a={});const{crc:s}=r,l=t.writeUint,c=t.writeUshort,u=t.writeASCII;let d=8;const h=e.frames.length>1;let f,p=!1,g=33+(h?20:0);if(null!=a.sRGB&&(g+=13),null!=a.pHYs&&(g+=21),null!=a.iCCP&&(f=pako.deflate(a.iCCP),g+=21+f.length+4),3==e.ctype){for(var m=e.plte.length,v=0;v<m;v++)e.plte[v]>>>24!=255&&(p=!0);g+=8+3*m+4+(p?8+1*m+4:0)}for(var y=0;y<e.frames.length;y++)h&&(g+=38),g+=(C=e.frames[y]).cimg.length+12,0!=y&&(g+=4);g+=12;const b=new Uint8Array(g),w=[137,80,78,71,13,10,26,10];for(v=0;v<8;v++)b[v]=w[v];if(l(b,d,13),d+=4,u(b,d,"IHDR"),d+=4,l(b,d,n),d+=4,l(b,d,i),d+=4,b[d]=e.depth,d++,b[d]=e.ctype,d++,b[d]=0,d++,b[d]=0,d++,b[d]=0,d++,l(b,d,s(b,d-17,17)),d+=4,null!=a.sRGB&&(l(b,d,1),d+=4,u(b,d,"sRGB"),d+=4,b[d]=a.sRGB,d++,l(b,d,s(b,d-5,5)),d+=4),null!=a.iCCP){const e=13+f.length;l(b,d,e),d+=4,u(b,d,"iCCP"),d+=4,u(b,d,"ICC profile"),d+=11,d+=2,b.set(f,d),d+=f.length,l(b,d,s(b,d-(e+4),e+4)),d+=4}if(null!=a.pHYs&&(l(b,d,9),d+=4,u(b,d,"pHYs"),d+=4,l(b,d,a.pHYs[0]),d+=4,l(b,d,a.pHYs[1]),d+=4,b[d]=a.pHYs[2],d++,l(b,d,s(b,d-13,13)),d+=4),h&&(l(b,d,8),d+=4,u(b,d,"acTL"),d+=4,l(b,d,e.frames.length),d+=4,l(b,d,null!=a.loop?a.loop:0),d+=4,l(b,d,s(b,d-12,12)),d+=4),3==e.ctype){for(l(b,d,3*(m=e.plte.length)),d+=4,u(b,d,"PLTE"),d+=4,v=0;v<m;v++){const t=3*v,n=e.plte[v],r=255&n,i=n>>>8&255,o=n>>>16&255;b[d+t+0]=r,b[d+t+1]=i,b[d+t+2]=o}if(d+=3*m,l(b,d,s(b,d-3*m-4,3*m+4)),d+=4,p){for(l(b,d,m),d+=4,u(b,d,"tRNS"),d+=4,v=0;v<m;v++)b[d+v]=e.plte[v]>>>24&255;d+=m,l(b,d,s(b,d-m-4,m+4)),d+=4}}let x=0;for(y=0;y<e.frames.length;y++){var C=e.frames[y];h&&(l(b,d,26),d+=4,u(b,d,"fcTL"),d+=4,l(b,d,x++),d+=4,l(b,d,C.rect.width),d+=4,l(b,d,C.rect.height),d+=4,l(b,d,C.rect.x),d+=4,l(b,d,C.rect.y),d+=4,c(b,d,o[y]),d+=2,c(b,d,1e3),d+=2,b[d]=C.dispose,d++,b[d]=C.blend,d++,l(b,d,s(b,d-30,30)),d+=4);const t=C.cimg;l(b,d,(m=t.length)+(0==y?0:4)),d+=4;const n=d;u(b,d,0==y?"IDAT":"fdAT"),d+=4,0!=y&&(l(b,d,x++),d+=4),b.set(t,d),d+=m,l(b,d,s(b,n,d-n)),d+=4}return l(b,d,0),d+=4,u(b,d,"IEND"),d+=4,l(b,d,s(b,d-4,4)),d+=4,b.buffer}function c(e,t,n){for(let r=0;r<e.frames.length;r++){const i=e.frames[r];i.rect.width;const o=i.rect.height,a=new Uint8Array(o*i.bpl+o);i.cimg=f(i.img,o,i.bpp,i.bpl,a,t,n)}}function u(t,n,r,i,o){const a=o[0],l=o[1],c=o[2],u=o[3],f=o[4],p=o[5];let m=6,v=8,y=255;for(var b=0;b<t.length;b++){const e=new Uint8Array(t[b]);for(var w=e.length,x=0;x<w;x+=4)y&=e[x+3]}const C=255!=y,_=function(t,n,r,i,o,a){const s=[];for(var l=0;l<t.length;l++){const d=new Uint8Array(t[l]),f=new Uint32Array(d.buffer);var c;let g=0,m=0,v=n,y=r,b=i?1:0;if(0!=l){const w=a||i||1==l||0!=s[l-2].dispose?1:2;let x=0,C=1e9;for(let e=0;e<w;e++){var u=new Uint8Array(t[l-1-e]);const i=new Uint32Array(t[l-1-e]);let a=n,s=r,c=-1,d=-1;for(let e=0;e<r;e++)for(let t=0;t<n;t++)f[p=e*n+t]!=i[p]&&(t<a&&(a=t),t>c&&(c=t),e<s&&(s=e),e>d&&(d=e));-1==c&&(a=s=c=d=0),o&&(!(1&~a)&&a--,!(1&~s)&&s--);const h=(c-a+1)*(d-s+1);h<C&&(C=h,x=e,g=a,m=s,v=c-a+1,y=d-s+1)}u=new Uint8Array(t[l-1-x]),1==x&&(s[l-1].dispose=2),c=new Uint8Array(v*y*4),e(u,n,r,c,v,y,-g,-m,0),b=e(d,n,r,c,v,y,-g,-m,3)?1:0,1==b?h(d,n,r,c,{x:g,y:m,width:v,height:y}):e(d,n,r,c,v,y,-g,-m,0)}else c=d.slice(0);s.push({rect:{x:g,y:m,width:v,height:y},img:c,blend:b,dispose:0})}if(i)for(l=0;l<s.length;l++){if(1==(g=s[l]).blend)continue;const e=g.rect,i=s[l-1].rect,a=Math.min(e.x,i.x),c=Math.min(e.y,i.y),u={x:a,y:c,width:Math.max(e.x+e.width,i.x+i.width)-a,height:Math.max(e.y+e.height,i.y+i.height)-c};s[l-1].dispose=1,l-1!=0&&d(t,n,r,s,l-1,u,o),d(t,n,r,s,l,u,o)}let f=0;if(1!=t.length)for(var p=0;p<s.length;p++){var g;f+=(g=s[p]).rect.width*g.rect.height}return s}(t,n,r,a,l,c),S={},k=[],A=[];if(0!=i){const e=[];for(x=0;x<_.length;x++)e.push(_[x].img.buffer);const t=function(e){let t=0;for(var n=0;n<e.length;n++)t+=e[n].byteLength;const r=new Uint8Array(t);let i=0;for(n=0;n<e.length;n++){const t=new Uint8Array(e[n]),o=t.length;for(let e=0;e<o;e+=4){let n=t[e],o=t[e+1],a=t[e+2];const s=t[e+3];0==s&&(n=o=a=0),r[i+e]=n,r[i+e+1]=o,r[i+e+2]=a,r[i+e+3]=s}i+=o}return r.buffer}(e),n=g(t,i);for(x=0;x<n.plte.length;x++)k.push(n.plte[x].est.rgba);let r=0;for(x=0;x<_.length;x++){const e=(I=_[x]).img.length;var E=new Uint8Array(n.inds.buffer,r>>2,e>>2);A.push(E);const t=new Uint8Array(n.abuf,r,e);p&&s(I.img,I.rect.width,I.rect.height,k,t,E),I.img.set(t),r+=e}}else for(b=0;b<_.length;b++){var I=_[b];const e=new Uint32Array(I.img.buffer);var T=I.rect.width;for(w=e.length,E=new Uint8Array(w),A.push(E),x=0;x<w;x++){const t=e[x];if(0!=x&&t==e[x-1])E[x]=E[x-1];else if(x>T&&t==e[x-T])E[x]=E[x-T];else{let e=S[t];if(null==e&&(S[t]=e=k.length,k.push(t),k.length>=300))break;E[x]=e}}}const F=k.length;for(F<=256&&0==f&&(v=F<=2?1:F<=4?2:F<=16?4:8,v=Math.max(v,u)),b=0;b<_.length;b++){(I=_[b]).rect.x,I.rect.y,T=I.rect.width;const e=I.rect.height;let t=I.img;new Uint32Array(t.buffer);let n=4*T,r=4;if(F<=256&&0==f){n=Math.ceil(v*T/8);var O=new Uint8Array(n*e);const i=A[b];for(let t=0;t<e;t++){x=t*n;const e=t*T;if(8==v)for(var P=0;P<T;P++)O[x+P]=i[e+P];else if(4==v)for(P=0;P<T;P++)O[x+(P>>1)]|=i[e+P]<<4-4*(1&P);else if(2==v)for(P=0;P<T;P++)O[x+(P>>2)]|=i[e+P]<<6-2*(3&P);else if(1==v)for(P=0;P<T;P++)O[x+(P>>3)]|=i[e+P]<<7-1*(7&P)}t=O,m=3,r=1}else if(0==C&&1==_.length){O=new Uint8Array(T*e*3);const i=T*e;for(x=0;x<i;x++){const e=3*x,n=4*x;O[e]=t[n],O[e+1]=t[n+1],O[e+2]=t[n+2]}t=O,m=2,r=3,n=3*T}I.img=t,I.bpl=n,I.bpp=r}return{ctype:m,depth:v,plte:k,frames:_}}function d(t,n,r,i,o,a,s){const l=Uint8Array,c=Uint32Array,u=new l(t[o-1]),d=new c(t[o-1]),f=o+1<t.length?new l(t[o+1]):null,p=new l(t[o]),g=new c(p.buffer);let m=n,v=r,y=-1,b=-1;for(let e=0;e<a.height;e++)for(let t=0;t<a.width;t++){const r=a.x+t,s=a.y+e,l=s*n+r,c=g[l];0==c||0==i[o-1].dispose&&d[l]==c&&(null==f||0!=f[4*l+3])||(r<m&&(m=r),r>y&&(y=r),s<v&&(v=s),s>b&&(b=s))}-1==y&&(m=v=y=b=0),s&&(!(1&~m)&&m--,!(1&~v)&&v--),a={x:m,y:v,width:y-m+1,height:b-v+1};const w=i[o];w.rect=a,w.blend=1,w.img=new Uint8Array(a.width*a.height*4),0==i[o-1].dispose?(e(u,n,r,w.img,a.width,a.height,-a.x,-a.y,0),h(p,n,r,w.img,a)):e(p,n,r,w.img,a.width,a.height,-a.x,-a.y,0)}function h(t,n,r,i,o){e(t,n,r,i,o.width,o.height,-o.x,-o.y,2)}function f(e,t,n,r,i,o,a){const s=[];let l,c=[0,1,2,3,4];-1!=o?c=[o]:(t*r>5e5||1==n)&&(c=[0]),a&&(l={level:0});const u=Qo;for(var d=0;d<c.length;d++){for(let o=0;o<t;o++)p(i,e,o,r,n,c[d]);s.push(u.deflate(i,l))}let h,f=1e9;for(d=0;d<s.length;d++)s[d].length<f&&(h=d,f=s[d].length);return s[h]}function p(e,t,r,i,o,a){const s=r*i;let l=s+r;if(e[l]=a,l++,0==a)if(i<500)for(var c=0;c<i;c++)e[l+c]=t[s+c];else e.set(new Uint8Array(t.buffer,s,i),l);else if(1==a){for(c=0;c<o;c++)e[l+c]=t[s+c];for(c=o;c<i;c++)e[l+c]=t[s+c]-t[s+c-o]+256&255}else if(0==r){for(c=0;c<o;c++)e[l+c]=t[s+c];if(2==a)for(c=o;c<i;c++)e[l+c]=t[s+c];if(3==a)for(c=o;c<i;c++)e[l+c]=t[s+c]-(t[s+c-o]>>1)+256&255;if(4==a)for(c=o;c<i;c++)e[l+c]=t[s+c]-n(t[s+c-o],0,0)+256&255}else{if(2==a)for(c=0;c<i;c++)e[l+c]=t[s+c]+256-t[s+c-i]&255;if(3==a){for(c=0;c<o;c++)e[l+c]=t[s+c]+256-(t[s+c-i]>>1)&255;for(c=o;c<i;c++)e[l+c]=t[s+c]+256-(t[s+c-i]+t[s+c-o]>>1)&255}if(4==a){for(c=0;c<o;c++)e[l+c]=t[s+c]+256-n(0,t[s+c-i],0)&255;for(c=o;c<i;c++)e[l+c]=t[s+c]+256-n(t[s+c-o],t[s+c-i],t[s+c-o-i])&255}}}function g(e,t){const n=new Uint8Array(e),r=n.slice(0),i=new Uint32Array(r.buffer),o=m(r,t),a=o[0],s=o[1],l=n.length,c=new Uint8Array(l>>2);let u;if(n.length<2e7)for(var d=0;d<l;d+=4)u=v(a,h=n[d]*(1/255),f=n[d+1]*(1/255),p=n[d+2]*(1/255),g=n[d+3]*(1/255)),c[d>>2]=u.ind,i[d>>2]=u.est.rgba;else for(d=0;d<l;d+=4){var h=n[d]*(1/255),f=n[d+1]*(1/255),p=n[d+2]*(1/255),g=n[d+3]*(1/255);for(u=a;u.left;)u=y(u.est,h,f,p,g)<=0?u.left:u.right;c[d>>2]=u.ind,i[d>>2]=u.est.rgba}return{abuf:r.buffer,inds:c,plte:s}}function m(e,t,n){null==n&&(n=1e-4);const r=new Uint32Array(e.buffer),i={i0:0,i1:e.length,bst:null,est:null,tdst:0,left:null,right:null};i.bst=x(e,i.i0,i.i1),i.est=C(i.bst);const o=[i];for(;o.length<t;){let t=0,i=0;for(var a=0;a<o.length;a++)o[a].est.L>t&&(t=o[a].est.L,i=a);if(t<n)break;const s=o[i],l=b(e,r,s.i0,s.i1,s.est.e,s.est.eMq255);if(s.i0>=l||s.i1<=l){s.est.L=0;continue}const c={i0:s.i0,i1:l,bst:null,est:null,tdst:0,left:null,right:null};c.bst=x(e,c.i0,c.i1),c.est=C(c.bst);const u={i0:l,i1:s.i1,bst:null,est:null,tdst:0,left:null,right:null};for(u.bst={R:[],m:[],N:s.bst.N-c.bst.N},a=0;a<16;a++)u.bst.R[a]=s.bst.R[a]-c.bst.R[a];for(a=0;a<4;a++)u.bst.m[a]=s.bst.m[a]-c.bst.m[a];u.est=C(u.bst),s.left=c,s.right=u,o[i]=c,o.push(u)}for(o.sort((e,t)=>t.bst.N-e.bst.N),a=0;a<o.length;a++)o[a].ind=a;return[i,o]}function v(e,t,n,r,i){if(null==e.left)return e.tdst=function(e,t,n,r,i){const o=t-e[0],a=n-e[1],s=r-e[2],l=i-e[3];return o*o+a*a+s*s+l*l}(e.est.q,t,n,r,i),e;const o=y(e.est,t,n,r,i);let a=e.left,s=e.right;o>0&&(a=e.right,s=e.left);const l=v(a,t,n,r,i);if(l.tdst<=o*o)return l;const c=v(s,t,n,r,i);return c.tdst<l.tdst?c:l}function y(e,t,n,r,i){const{e:o}=e;return o[0]*t+o[1]*n+o[2]*r+o[3]*i-e.eMq}function b(e,t,n,r,i,o){for(r-=4;n<r;){for(;w(e,n,i)<=o;)n+=4;for(;w(e,r,i)>o;)r-=4;if(n>=r)break;const a=t[n>>2];t[n>>2]=t[r>>2],t[r>>2]=a,n+=4,r-=4}for(;w(e,n,i)>o;)n-=4;return n+4}function w(e,t,n){return e[t]*n[0]+e[t+1]*n[1]+e[t+2]*n[2]+e[t+3]*n[3]}function x(e,t,n){const r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i=[0,0,0,0],o=n-t>>2;for(let o=t;o<n;o+=4){const t=e[o]*(1/255),n=e[o+1]*(1/255),a=e[o+2]*(1/255),s=e[o+3]*(1/255);i[0]+=t,i[1]+=n,i[2]+=a,i[3]+=s,r[0]+=t*t,r[1]+=t*n,r[2]+=t*a,r[3]+=t*s,r[5]+=n*n,r[6]+=n*a,r[7]+=n*s,r[10]+=a*a,r[11]+=a*s,r[15]+=s*s}return r[4]=r[1],r[8]=r[2],r[9]=r[6],r[12]=r[3],r[13]=r[7],r[14]=r[11],{R:r,m:i,N:o}}function C(e){const{R:t}=e,{m:n}=e,{N:r}=e,i=n[0],o=n[1],a=n[2],s=n[3],l=0==r?0:1/r,c=[t[0]-i*i*l,t[1]-i*o*l,t[2]-i*a*l,t[3]-i*s*l,t[4]-o*i*l,t[5]-o*o*l,t[6]-o*a*l,t[7]-o*s*l,t[8]-a*i*l,t[9]-a*o*l,t[10]-a*a*l,t[11]-a*s*l,t[12]-s*i*l,t[13]-s*o*l,t[14]-s*a*l,t[15]-s*s*l],u=c,d=_;let h=[Math.random(),Math.random(),Math.random(),Math.random()],f=0,p=0;if(0!=r)for(let e=0;e<16&&(h=d.multVec(u,h),p=Math.sqrt(d.dot(h,h)),h=d.sml(1/p,h),!(0!=e&&Math.abs(p-f)<1e-9));e++)f=p;const g=[i*l,o*l,a*l,s*l];return{Cov:c,q:g,e:h,L:f,eMq255:d.dot(d.sml(255,g),h),eMq:d.dot(h,g),rgba:(Math.round(255*g[3])<<24|Math.round(255*g[2])<<16|Math.round(255*g[1])<<8|Math.round(255*g[0]))>>>0}}var _={multVec:(e,t)=>[e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],e[4]*t[0]+e[5]*t[1]+e[6]*t[2]+e[7]*t[3],e[8]*t[0]+e[9]*t[1]+e[10]*t[2]+e[11]*t[3],e[12]*t[0]+e[13]*t[1]+e[14]*t[2]+e[15]*t[3]],dot:(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],sml:(e,t)=>[e*t[0],e*t[1],e*t[2],e*t[3]]};ea.encode=function(e,t,n,r,i,o,a){null==r&&(r=0),null==a&&(a=!1);const s=u(e,t,n,r,[!1,!1,!1,0,a,!1]);return c(s,-1),l(s,t,n,i,o)},ea.encodeLL=function(e,t,n,r,i,o,a,s){const u={ctype:0+(1==r?0:2)+(0==i?0:4),depth:o,frames:[]},d=(r+i)*o,h=d*t;for(let r=0;r<e.length;r++)u.frames.push({rect:{x:0,y:0,width:t,height:n},img:new Uint8Array(e[r]),blend:0,dispose:1,bpp:Math.ceil(d/8),bpl:Math.ceil(h/8)});return c(u,0,!0),l(u,t,n,a,s)},ea.encode.compress=u,ea.encode.dither=s,ea.quantize=g,ea.quantize.getKDtree=m,ea.quantize.getNearest=v}();const ta={toArrayBuffer(e,t){const n=e.width,r=e.height,i=n<<2,o=e.getContext("2d").getImageData(0,0,n,r),a=new Uint32Array(o.data.buffer),s=(32*n+31)/32<<2,l=s*r,c=122+l,u=new ArrayBuffer(c),d=new DataView(u),h=1<<20;let f,p,g,m,v=h,y=0,b=0,w=0;function x(e){d.setUint16(b,e,!0),b+=2}function C(e){d.setUint32(b,e,!0),b+=4}function _(e){b+=e}x(19778),C(c),_(4),C(122),C(108),C(n),C(-r>>>0),x(1),x(32),C(3),C(l),C(2835),C(2835),_(8),C(16711680),C(65280),C(255),C(4278190080),C(1466527264),function e(){for(;y<r&&v>0;){for(m=122+y*s,f=0;f<i;)v--,p=a[w++],g=p>>>24,d.setUint32(m+f,p<<8|g),f+=4;y++}w<a.length?(v=h,setTimeout(e,ta._dly)):t(u)}()},toBlob(e,t){this.toArrayBuffer(e,e=>{t(new Blob([e],{type:"image/bmp"}))})},_dly:9};var na={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},ra={[na.CHROME]:16384,[na.FIREFOX]:11180,[na.DESKTOP_SAFARI]:16384,[na.IE]:8192,[na.IOS]:4096,[na.ETC]:8192};const ia="undefined"!=typeof window,oa="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,aa=ia&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),sa=(ia||oa)&&(aa&&aa.getOriginalSymbol(window,"File")||"undefined"!=typeof File&&File),la=(ia||oa)&&(aa&&aa.getOriginalSymbol(window,"FileReader")||"undefined"!=typeof FileReader&&FileReader);function ca(e,t,n=Date.now()){return new Promise(r=>{const i=e.split(","),o=i[0].match(/:(.*?);/)[1],a=globalThis.atob(i[1]);let s=a.length;const l=new Uint8Array(s);for(;s--;)l[s]=a.charCodeAt(s);const c=new Blob([l],{type:o});c.name=t,c.lastModified=n,r(c)})}function ua(e){return new Promise((t,n)=>{const r=new la;r.onload=()=>t(r.result),r.onerror=e=>n(e),r.readAsDataURL(e)})}function da(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=e=>n(e),r.src=e})}function ha(){if(void 0!==ha.cachedResult)return ha.cachedResult;let e=na.ETC;const{userAgent:t}=navigator;return/Chrom(e|ium)/i.test(t)?e=na.CHROME:/iP(ad|od|hone)/i.test(t)&&/WebKit/i.test(t)?e=na.IOS:/Safari/i.test(t)?e=na.DESKTOP_SAFARI:/Firefox/i.test(t)?e=na.FIREFOX:(/MSIE/i.test(t)||1==!!document.documentMode)&&(e=na.IE),ha.cachedResult=e,ha.cachedResult}function fa(e,t){const n=ha(),r=ra[n];let i=e,o=t,a=i*o;const s=i>o?o/i:i/o;for(;a>r*r;){const e=(r+i)/2,t=(r+o)/2;e<t?(o=t,i=t*s):(o=e*s,i=e),a=i*o}return{width:i,height:o}}function pa(e,t){let n,r;try{if(n=new OffscreenCanvas(e,t),r=n.getContext("2d"),null===r)throw new Error("getContext of OffscreenCanvas returns null")}catch(e){n=document.createElement("canvas"),r=n.getContext("2d")}return n.width=e,n.height=t,[n,r]}function ga(e,t){const{width:n,height:r}=fa(e.width,e.height),[i,o]=pa(n,r);return t&&/jpe?g/.test(t)&&(o.fillStyle="white",o.fillRect(0,0,i.width,i.height)),o.drawImage(e,0,0,i.width,i.height),i}function ma(){return void 0!==ma.cachedResult||(ma.cachedResult=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"undefined"!=typeof document&&"ontouchend"in document),ma.cachedResult}function va(e,t={}){return new Promise(function(n,r){let i,o;var a=function(){try{return o=ga(i,t.fileType||e.type),n([i,o])}catch(e){return r(e)}},s=function(t){try{var n=function(e){try{throw e}catch(e){return r(e)}};try{let t;return ua(e).then(function(e){try{return t=e,da(t).then(function(e){try{return i=e,function(){try{return a()}catch(e){return r(e)}}()}catch(e){return n(e)}},n)}catch(e){return n(e)}},n)}catch(e){n(e)}}catch(e){return r(e)}};try{if(ma()||[na.DESKTOP_SAFARI,na.MOBILE_SAFARI].includes(ha()))throw new Error("Skip createImageBitmap on IOS and Safari");return createImageBitmap(e).then(function(e){try{return i=e,a()}catch(e){return s()}},s)}catch(e){s()}})}function ya(e,t,n,r,i=1){return new Promise(function(o,a){let s;if("image/png"===t){let c,u,d;return c=e.getContext("2d"),({data:u}=c.getImageData(0,0,e.width,e.height)),d=ea.encode([u.buffer],e.width,e.height,4096*i),s=new Blob([d],{type:t}),s.name=n,s.lastModified=r,l.call(this)}{if("image/bmp"===t)return new Promise(t=>ta.toBlob(e,t)).then(function(e){try{return s=e,s.name=n,s.lastModified=r,h.call(this)}catch(e){return a(e)}}.bind(this),a);{if("function"==typeof OffscreenCanvas&&e instanceof OffscreenCanvas)return e.convertToBlob({type:t,quality:i}).then(function(e){try{return s=e,s.name=n,s.lastModified=r,f.call(this)}catch(e){return a(e)}}.bind(this),a);{let p;return p=e.toDataURL(t,i),ca(p,n,r).then(function(e){try{return s=e,f.call(this)}catch(e){return a(e)}}.bind(this),a)}function f(){return h.call(this)}}function h(){return l.call(this)}}function l(){return o(s)}})}function ba(e){e.width=0,e.height=0}function wa(){return new Promise(function(e,t){let n,r,i,o;return void 0!==wa.cachedResult?e(wa.cachedResult):ca("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then(function(a){try{return n=a,va(n).then(function(a){try{return r=a[1],ya(r,n.type,n.name,n.lastModified).then(function(n){try{return i=n,ba(r),va(i).then(function(n){try{return o=n[0],wa.cachedResult=1===o.width&&2===o.height,e(wa.cachedResult)}catch(e){return t(e)}},t)}catch(e){return t(e)}},t)}catch(e){return t(e)}},t)}catch(e){return t(e)}},t)})}function xa(e){return new Promise((t,n)=>{const r=new la;r.onload=e=>{const n=new DataView(e.target.result);if(65496!=n.getUint16(0,!1))return t(-2);const r=n.byteLength;let i=2;for(;i<r;){if(n.getUint16(i+2,!1)<=8)return t(-1);const e=n.getUint16(i,!1);if(i+=2,65505==e){if(1165519206!=n.getUint32(i+=2,!1))return t(-1);const e=18761==n.getUint16(i+=6,!1);i+=n.getUint32(i+4,e);const r=n.getUint16(i,e);i+=2;for(let o=0;o<r;o++)if(274==n.getUint16(i+12*o,e))return t(n.getUint16(i+12*o+8,e))}else{if(65280&~e)break;i+=n.getUint16(i,!1)}}return t(-1)},r.onerror=e=>n(e),r.readAsArrayBuffer(e)})}function Ca(e,t){const{width:n}=e,{height:r}=e,{maxWidthOrHeight:i}=t;let o,a=e;return isFinite(i)&&(n>i||r>i)&&([a,o]=pa(n,r),n>r?(a.width=i,a.height=r/n*i):(a.width=n/r*i,a.height=i),o.drawImage(e,0,0,a.width,a.height),ba(e)),a}function _a(e,t){const{width:n}=e,{height:r}=e,[i,o]=pa(n,r);switch(t>4&&t<9?(i.width=r,i.height=n):(i.width=n,i.height=r),t){case 2:o.transform(-1,0,0,1,n,0);break;case 3:o.transform(-1,0,0,-1,n,r);break;case 4:o.transform(1,0,0,-1,0,r);break;case 5:o.transform(0,1,1,0,0,0);break;case 6:o.transform(0,1,-1,0,r,0);break;case 7:o.transform(0,-1,-1,0,r,n);break;case 8:o.transform(0,-1,1,0,0,n)}return o.drawImage(e,0,0,n,r),ba(e),i}function Sa(e,t,n=0){return new Promise(function(r,i){let o,a,s,l,c,u,d,h,f,p,g,m,v,y,b,w,x,C,_,S;function k(e=5){if(t.signal&&t.signal.aborted)throw t.signal.reason;o+=e,t.onProgress(Math.min(o,100))}function A(e){if(t.signal&&t.signal.aborted)throw t.signal.reason;o=Math.min(Math.max(e,o),100),t.onProgress(o)}return o=n,a=t.maxIteration||10,s=1024*t.maxSizeMB*1024,k(),va(e,t).then(function(n){try{return[,l]=n,k(),c=Ca(l,t),k(),new Promise(function(n,r){var i;if(!(i=t.exifOrientation))return xa(e).then(function(e){try{return i=e,o.call(this)}catch(e){return r(e)}}.bind(this),r);function o(){return n(i)}return o.call(this)}).then(function(n){try{return u=n,k(),wa().then(function(n){try{return d=n?c:_a(c,u),k(),h=t.initialQuality||1,f=t.fileType||e.type,ya(d,f,e.name,e.lastModified,h).then(function(n){try{{if(p=n,k(),g=p.size>s,m=p.size>e.size,!g&&!m)return A(100),r(p);var o;function u(){if(a--&&(b>s||b>v)){let t,n;return t=S?.95*_.width:_.width,n=S?.95*_.height:_.height,[x,C]=pa(t,n),C.drawImage(_,0,0,t,n),h*="image/png"===f?.85:.95,ya(x,f,e.name,e.lastModified,h).then(function(e){try{return w=e,ba(_),_=x,b=w.size,A(Math.min(99,Math.floor((y-b)/(y-s)*100))),u}catch(e){return i(e)}},i)}return[1]}return v=e.size,y=p.size,b=y,_=d,S=!t.alwaysKeepResolution&&g,(o=function(e){for(;e;){if(e.then)return void e.then(o,i);try{if(e.pop){if(e.length)return e.pop()?E.call(this):e;e=u}else e=e.call(this)}catch(e){return i(e)}}}.bind(this))(u);function E(){return ba(_),ba(x),ba(c),ba(d),ba(l),A(100),r(w)}}}catch(I){return i(I)}}.bind(this),i)}catch(e){return i(e)}}.bind(this),i)}catch(e){return i(e)}}.bind(this),i)}catch(e){return i(e)}}.bind(this),i)})}let ka;function Aa(e,t){return new Promise((n,r)=>{ka||(ka=function(e){const t=[];return t.push(e),URL.createObjectURL(new Blob(t))}("\nlet scriptImported = false\nself.addEventListener('message', async (e) => {\n const { file, id, imageCompressionLibUrl, options } = e.data\n options.onProgress = (progress) => self.postMessage({ progress, id })\n try {\n if (!scriptImported) {\n // console.log('[worker] importScripts', imageCompressionLibUrl)\n self.importScripts(imageCompressionLibUrl)\n scriptImported = true\n }\n // console.log('[worker] self', self)\n const compressedFile = await imageCompression(file, options)\n self.postMessage({ file: compressedFile, id })\n } catch (e) {\n // console.error('[worker] error', e)\n self.postMessage({ error: e.message + '\\n' + e.stack, id })\n }\n})\n"));const i=new Worker(ka);i.addEventListener("message",function(e){if(t.signal&&t.signal.aborted)i.terminate();else if(void 0===e.data.progress){if(e.data.error)return r(new Error(e.data.error)),void i.terminate();n(e.data.file),i.terminate()}else t.onProgress(e.data.progress)}),i.addEventListener("error",r),t.signal&&t.signal.addEventListener("abort",()=>{r(t.signal.reason),i.terminate()}),i.postMessage({file:e,imageCompressionLibUrl:t.libURL,options:{...t,onProgress:void 0,signal:void 0}})})}function Ea(e,t){return new Promise(function(n,r){let i,o,a,s,l,c;if(i={...t},a=0,({onProgress:s}=i),i.maxSizeMB=i.maxSizeMB||Number.POSITIVE_INFINITY,l="boolean"!=typeof i.useWebWorker||i.useWebWorker,delete i.useWebWorker,i.onProgress=e=>{a=e,"function"==typeof s&&s(a)},!(e instanceof Blob||e instanceof sa))return r(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(e.type))return r(new Error("The file given is not an image"));if(c="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,!l||"function"!=typeof Worker||c)return Sa(e,i).then(function(e){try{return o=e,h.call(this)}catch(e){return r(e)}}.bind(this),r);var u=function(){try{return h.call(this)}catch(e){return r(e)}}.bind(this),d=function(t){try{return Sa(e,i).then(function(e){try{return o=e,u()}catch(e){return r(e)}},r)}catch(e){return r(e)}};try{return i.libURL=i.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",Aa(e,i).then(function(e){try{return o=e,u()}catch(e){return d()}},d)}catch(e){d()}function h(){try{o.name=e.name,o.lastModified=e.lastModified}catch(e){}try{i.preserveExif&&"image/jpeg"===e.type&&(!i.fileType||i.fileType&&i.fileType===e.type)&&(o=Xo(e,o))}catch(e){}return n(o)}})}function Ia(e,t){var n;if(null==e?void 0:e.extension){const t=e.extension.toLowerCase(),n={jpg:{extension:"jpeg",mimeType:"image/jpeg",format:"jpeg",pixieFormat:"jpeg"},jpeg:{extension:"jpeg",mimeType:"image/jpeg",format:"jpeg",pixieFormat:"jpeg"},png:{extension:"png",mimeType:"image/png",format:"png",pixieFormat:"png"},gif:{extension:"gif",mimeType:"image/gif",format:"gif",pixieFormat:"png"},webp:{extension:"webp",mimeType:"image/webp",format:"webp",pixieFormat:"png"},svg:{extension:"svg",mimeType:"image/svg+xml",format:"svg",pixieFormat:"svg"}};if(n[t])return n[t]}if(null==e?void 0:e.type){const t=Tn(e.type),n={"image/jpeg":{extension:"jpeg",mimeType:"image/jpeg",format:"jpeg",pixieFormat:"jpeg"},"image/png":{extension:"png",mimeType:"image/png",format:"png",pixieFormat:"png"},"image/gif":{extension:"gif",mimeType:"image/gif",format:"gif",pixieFormat:"png"},"image/webp":{extension:"webp",mimeType:"image/webp",format:"webp",pixieFormat:"png"},"image/svg+xml":{extension:"svg",mimeType:"image/svg+xml",format:"svg",pixieFormat:"svg"}};if(n[t])return n[t]}if(null==e?void 0:e.name){const t=null===(n=e.name.split(".").pop())||void 0===n?void 0:n.toLowerCase();if(t){const e={jpg:{extension:"jpeg",mimeType:"image/jpeg",format:"jpeg",pixieFormat:"jpeg"},jpeg:{extension:"jpeg",mimeType:"image/jpeg",format:"jpeg",pixieFormat:"jpeg"},png:{extension:"png",mimeType:"image/png",format:"png",pixieFormat:"png"},gif:{extension:"gif",mimeType:"image/gif",format:"gif",pixieFormat:"png"},webp:{extension:"webp",mimeType:"image/webp",format:"webp",pixieFormat:"png"},svg:{extension:"svg",mimeType:"image/svg+xml",format:"svg",pixieFormat:"svg"}};if(e[t])return e[t]}}if(t){const e=Tn(t),n=Pn(e);let r="jpeg";return"png"===n?r="png":"svg"===n?r="svg":"jpeg"===n&&(r="jpeg"),{extension:n,mimeType:e,format:n,pixieFormat:r}}return{extension:"jpeg",mimeType:"image/jpeg",format:"jpeg",pixieFormat:"jpeg"}}Ea.getDataUrlFromFile=ua,Ea.getFilefromDataUrl=ca,Ea.loadImage=da,Ea.drawImageInCanvas=ga,Ea.drawFileInCanvas=va,Ea.canvasToFile=ya,Ea.getExifOrientation=xa,Ea.handleMaxWidthOrHeight=Ca,Ea.followExifOrientation=_a,Ea.cleanupCanvasMemory=ba,Ea.isAutoOrientationInBrowser=wa,Ea.approximateBelowMaximumCanvasSizeOfBrowser=fa,Ea.copyExifWithoutOrientation=Xo,Ea.getBrowserName=ha,Ea.version="2.0.2";const Ta={MAX_SIZE_MB:.48,MAX_WIDTH_OR_HEIGHT:2e3,QUALITY:.8},Fa=["gif","svg"];function Oa(e,t,n,r){return new File([e],t,{type:n,lastModified:r})}function Pa(e,t){return t&&t!==e.name?Oa(e,t,e.type,e.lastModified):e}async function Ma(e,t={}){const{maxSizeMB:n=Ta.MAX_SIZE_MB,maxWidthOrHeight:r=Ta.MAX_WIDTH_OR_HEIGHT,mimeType:i,fileName:o,libURL:a,enableCompression:s=!0}=t;if(!(e&&e instanceof File))return e;const l=Tn(e.type||i||"image/jpeg");if(!l.startsWith("image/"))return Pa(e,o);const c="image/webp"===(u=l)?"image/jpeg":u;var u;const d=Pn(l),h=Pn(c),f=c!==l?function(e,t){const n=t.startsWith(".")?t.slice(1):t,r=e.lastIndexOf(".");return r>0?`${e.substring(0,r)}.${n}`:`${e}.${n}`}(null!=o?o:e.name,h):null!=o?o:e.name,p=s&&(g=d,!Fa.includes(g));var g;if(!p&&!(c!==l))return Pa(e,f);try{const t={libURL:a,useWebWorker:!0,fileType:c};p?(t.maxSizeMB=n,t.maxWidthOrHeight=r):(t.maxSizeMB=Math.max(e.size/1048576+1,1),t.initialQuality=1,t.alwaysKeepResolution=!0);const i=await Ea(e,t);return function(e,t,n,r){const i=null!=r?r:t.name;return e instanceof File?e.type!==n||e.lastModified!==t.lastModified||e.name!==i?Oa(e,i,n,t.lastModified):e:Oa(e,i,n,t.lastModified)}(i,e,Tn(i.type||c),f)}catch(t){console.error("prepareImageForUpload failed",t);try{return Pa(e,f)}catch(t){return console.error("Failed to create File with normalized name after image preparation error",t),e}}}const Ra=/^(utm_[a-z0-9_]+|fbclid|gclid|igshid|mc_cid|mc_eid)$/i;function La(e){const t=new URL(e.trim());t.hash="",t.hostname=t.hostname.toLowerCase(),("https:"===t.protocol&&"443"===t.port||"http:"===t.protocol&&"80"===t.port)&&(t.port="");const n=Array.from(t.searchParams.entries()).filter(([e])=>!Ra.test(e)).sort(([e,t],[n,r])=>{const i=e.localeCompare(n);return 0!==i?i:t.localeCompare(r)});return t.search="",n.forEach(([e,n])=>t.searchParams.append(e,n)),t.toString()}function Na(e){return!!(null==e?void 0:e.startsWith("image/"))&&"image/gif"!==e}function Da(e,t){if(t===e.name)return e;try{return new File([e],t,{type:e.type,lastModified:e.lastModified})}catch(t){return console.warn("Failed to create normalized File:",t),e}}async function ja(e){const t=await fetch(e,{mode:"cors"});if(!t.ok)throw new $o(`HTTP ${t.status}`,"UploadUrlDownloadFailed",t.status);return t.blob()}const za=()=>{var e,t,n,r,o,a,s;const{state:l,actions:u,options:d}=ro(),h=yo(),{sortBy:f,sortOrder:p}=h.state,{actions:{fetchFolders:g}}=Ho(),{t:m}=Qn(),v=bo(),{deleteItems:y}=Wo(),{selectedFolder:b,urlForm:w,pagination:x,files:C,pathHistory:_}=l,S=i.useRef(null),k=i.useRef([]);S.current=x,k.current=Array.isArray(C)?C:[];const{setFiles:A,setLoading:E,setIsUrlModalVisible:I,setActiveLibraryItem:T,setPagination:F,setSelectedFolder:O,setPathHistory:P}=u,{dataProviders:M}=d,R=c(async e=>{var t,n,r;if(!(null==M?void 0:M.getFiles))return[];const i=null===(t=null==d?void 0:d.config)||void 0===t?void 0:t.disablePagination,{files:o,pagination:a}=await M.getFiles({folderId:"folders"!==(null==e?void 0:e.folderId)?null==e?void 0:e.folderId:void 0,noFolder:null==e?void 0:e.noFolder,search:(null===(n=null==e?void 0:e.search)||void 0===n?void 0:n.trim())||void 0,sortBy:null==e?void 0:e.sortBy,sortOrder:null==e?void 0:e.sortOrder,page:i||null==e?void 0:e.page,limit:i||null==e?void 0:e.limit,itemType:(null==e?void 0:e.itemType)||"all"});return F&&((null===(r=null==d?void 0:d.config)||void 0===r?void 0:r.disablePagination)?F({current:1,pageSize:o.length||1,total:o.length||0}):a&&F({current:a.page,pageSize:a.limit,total:a.total})),o},[M,null===(e=null==d?void 0:d.config)||void 0===e?void 0:e.disablePagination,F]),L=c(async(e,t,n)=>{var r,i,o;if(!(!1===(null===(r=null==d?void 0:d.config)||void 0===r?void 0:r.paginationAvailable)||!1===(null===(i=null==d?void 0:d.config)||void 0===i?void 0:i.hasPagination)||!0===(null===(o=null==d?void 0:d.config)||void 0===o?void 0:o.disablePagination))||!(null==M?void 0:M.getFiles))return e;try{let r=[];const{files:i}=await M.getFiles({folderId:n?void 0:t||void 0,noFolder:n,itemType:"all",page:1,limit:1e4});if(r=(i||[]).map(e=>e.name).filter(e=>!!e),!n&&(null==M?void 0:M.getFolders)){const e=(await M.getFolders({parentId:null!=t?t:null,deep:!1})||[]).map(e=>e.name).filter(e=>!!e);r=[...r,...e]}return _o(e,r)}catch(t){return console.warn("Could not fetch files for duplicate check:",t),e}},[M,null===(t=null==d?void 0:d.config)||void 0===t?void 0:t.disablePagination,null===(n=null==d?void 0:d.config)||void 0===n?void 0:n.hasPagination,null===(r=null==d?void 0:d.config)||void 0===r?void 0:r.paginationAvailable]),N=c(async(e,t=!1)=>{var n;try{null==E||E(!0);let t=[];if(!(null==M?void 0:M.getFiles))return void console.error("DataProvider for getting files is not defined");t=await R(e);const n=null!=e?e:{folderId:b||"",itemType:"all"};"file"!==n.itemType&&(t=await vo(t,n,null==M?void 0:M.getFolders)),"Trash"!==(b||"")&&(t=t.filter(e=>!(e.isFolder&&"Trash"===e.id))),null==A||A(t)}catch(r){if("StaleLoad"===(null==r?void 0:r.name))return;const i=Io(r),o=404===(null==i?void 0:i.status)||"FileNotFound"===(null==i?void 0:i.code)||"path_folder_not_found"===(null==i?void 0:i.code);if(o||console.error("Error loading files:",r),!t&&o){const t=Lo(r,_||[]);try{return await No({options:d,pathFolder:t,dataProviders:null==d?void 0:d.dataProviders}),void await N(e,!0)}catch(e){console.error("Cache clear failed:",e)}}if(o&&O&&P){const t=Array.isArray(_)?_:[];if(t.length>1){const r=t.slice(0,-1),i=r[r.length-1],o=null!==(n=null==i?void 0:i.id)&&void 0!==n?n:"folders";return P(r),O(o),await g(),v.success({id:"FOLDER_NOT_FOUND_NAVIGATE",message:m("Folder not found"),description:m("Navigated to parent folder"),placement:"bottomRight"}),void await N(Object.assign(Object.assign({},e),{folderId:o}),!1)}return P([{id:"folders",name:m("Folders")}]),O("folders"),await g(),v.success({id:"FOLDER_NOT_FOUND_NAVIGATE",message:m("Folder not found"),description:m("Navigated to root folder"),placement:"bottomRight"}),void await N(Object.assign(Object.assign({},e),{folderId:"folders"}),!1)}const a=Ao(null==i?void 0:i.code,m);v.error({id:"FILES_FETCH_FAILED",message:null!=a?a:m("Failed to load files"),placement:"bottomRight",innerException:r,data:{params:e}})}finally{null==E||E(!1)}},[M,A,E,O,P,R,g,b,v,m,_,d]),D=c(e=>N(e),[N]),j=c(async(e,t)=>{var n;if(!(null==M?void 0:M.findFileByUrl))return null;const r=La(e);try{return null!==(n=await M.findFileByUrl(r))&&void 0!==n?n:null}catch(e){return console.warn("findFileByUrl failed, falling back to direct loading",e),null}},[M]),z=c(async(e,t)=>{var n,r,i,o;Yo(e,m);const a=La(e),s=await j(a,t);if(s)return{kind:"existing",file:s,normalizedUrl:a};let l,c;const u=null===(n=null==d?void 0:d.config)||void 0===n?void 0:n.handleFileProxy,h=null===(r=null==d?void 0:d.config)||void 0===r?void 0:r.handleProxyUrl;if(u)try{l=await Promise.resolve(u(a))}catch(e){c=e,console.warn("handleFileProxy failed, falling back to fetch",e)}if(!l&&h)try{const e=await Promise.resolve(h(a));l=await ja(e)}catch(e){c=e,console.warn("handleProxyUrl fetch failed, falling back to direct fetch",e)}if(!l)try{l=await ja(a)}catch(e){c=e}if(!(l instanceof Blob)||0===l.size)throw c instanceof Error?c:new $o(m("Failed to load file through proxy."),"FileProxyFailed");const f=(null===(o=null===(i=l.type)||void 0===i?void 0:i.split(";")[0])||void 0===o?void 0:o.trim())||"image/png";if(!f.startsWith("image/"))throw new $o(m("Content type at the URL is not allowed."),"UploadUrlContentTypeNotAllowed");const p=Pn(f),g=function(e){try{const t=new URL(e).pathname.split("/").pop();return t?decodeURIComponent(t):void 0}catch(e){return}}(a)||"uploaded-file",v=g.replace(/\.[^.]+$/,"")||"uploaded-file";return{kind:"blob",blob:l,normalizedUrl:a,mimeType:f,extension:p,fileName:Uo(g.includes(".")?g:`${v}.${p}`,null==d?void 0:d.config)}},[j,null==d?void 0:d.config,m]),B=c(async(e,t)=>{var n,r;Yo(e,m);const i=La(e);try{const e=await z(i,t);if("existing"===e.kind)return e.file;const n=await(s=e.blob,new Promise((e,t)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>{var e;return t(null!==(e=n.error)&&void 0!==e?e:new Error("Failed to read proxied file"))},n.readAsDataURL(s)}));return{thumbnail:n,name:e.fileName,type:e.mimeType,extension:e.extension,size:e.blob.size,sourceUrl:e.normalizedUrl,saveWithoutFolder:!0}}catch(e){const s=Io(e),l=(o=null==s?void 0:s.code,a="UploadUrlDownloadFailed","string"==typeof o?o:a),c=e instanceof $o?e:new $o(null!==(r=null!==(n=Ao(l,m))&&void 0!==n?n:null==s?void 0:s.message)&&void 0!==r?r:m("Failed to load file through proxy."),l,null==s?void 0:s.status);throw c.notificationShown=!0,await v.error({id:"EDITOR_PROXY_FILE_FAILED",message:c.message,placement:"bottomRight",data:{url:i,folderId:b||null,error:s,eventSource:"pixie"},innerException:e},t),c}var o,a,s},[j,v,null==d?void 0:d.config,b,m]),U=c(async e=>{const t=S.current;try{const n=k.current.find(t=>t.id===e),r=e=>{if(!e)return;const t=C.find(t=>t.id===e);return null==t?void 0:t.name};await y({items:[{id:e,isFolder:null==n?void 0:n.isFolder}],selectedFolder:b,getItemNameById:r,showNotifications:!0});const i=Object.assign({},t);let o=t.current;1===C.length&&(o=i.current>1?i.current-1:1),await D({folderId:b||"",page:o,limit:t.pageSize,sortBy:f,sortOrder:p})}catch(t){console.error("ОError when deleting a file:",t);const n=t;(null==n?void 0:n.notificationShown)||v.error({id:"FILES_DELETE_ERROR",message:m("Error when deleting a file"),placement:"bottomRight",innerException:t,data:{failCount:1,totalCount:1,itemIds:[e],folderId:b||null,errors:[{itemId:e,error:Io(t)}]}})}},[y,D,b,m,v,C,f,p]),V=c(async e=>{try{const t=S.current;if(!(null==M?void 0:M.deleteFolder))return void v.error({id:"FOLDER_DELETE_ERROR",message:m("DataProvider for folder deletion is not configured"),placement:"bottomRight",data:{totalCount:1,failCount:1,itemIds:[e],folderId:e}});if(!await M.deleteFolder(e)){const e=new Error("Не удалось удалить папку");throw e.notificationShown=!1,e}v.success({id:"FOLDER_DELETE_SUCCESS",message:m("Folder deleted"),placement:"bottomRight",data:{successCount:1,totalCount:1,itemIds:[e],folderId:e}});b===e?await D({page:t.current,limit:t.pageSize,sortBy:f,sortOrder:p}):await D({folderId:b||"",sortBy:f,sortOrder:p,page:t.current,limit:t.pageSize})}catch(t){console.error("Error when deleting a folder:",t);const n=t;(null==n?void 0:n.notificationShown)||v.error({id:"FOLDER_DELETE_ERROR",message:m("Error when deleting a folder"),innerException:t,placement:"bottomRight",data:{totalCount:1,failCount:1,itemIds:[e],folderId:e,errors:[{itemId:e,error:Io(t)}]}})}},[M,b,v,m,D,f,p]),H=c(async(e,t)=>{var n,r;try{if(null==M?void 0:M.getFileData){const t=await M.getFileData(e);if(t)return t;throw new Error(m("Failed to download file"))}{const t=await fetch(`/api/files/${e}/content`);if(!t.ok)throw new Error(m("Error loading image"));return await t.blob()}}catch(i){console.error("Error when loading a file:",i);const o=k.current.find(t=>t.id===e);t||v.error({id:"FILE_DOWNLOAD_FAILED",message:m("Failed to download file"),placement:"bottomRight",description:(null==o?void 0:o.name)||e,innerException:i,data:{itemId:e,itemName:(null==o?void 0:o.name)||e,folderId:null!==(n=null==o?void 0:o.folderId)&&void 0!==n?n:null,thumbnail:null!==(r=null==o?void 0:o.thumbnail)&&void 0!==r?r:null}},t)}},[M,v,m]),W=c(async(e,t,n,r)=>{var i,o,a,s,c,u,h,f,p,g,y,w,x,C,_,S,k;if("Trash"===(r?"":null!=t?t:b||""))throw new Error(m("Upload to Trash is forbidden"));const A=Uo(e.name,null==d?void 0:d.config),E=A.split(".").pop()||"",I=r?"":null!=t?t:b||"";let F=e;try{if(null===(o=null===(i=e.type)||void 0===i?void 0:i.startsWith)||void 0===o?void 0:o.call(i,"image/")){const t=null!==(s=null===(a=null==d?void 0:d.config)||void 0===a?void 0:a.compressMaxSize)&&void 0!==s?s:Ta.MAX_SIZE_MB,n=null!==(u=null===(c=null==d?void 0:d.config)||void 0===c?void 0:c.compressMaxWidthOrHeight)&&void 0!==u?u:2e3,r=null!==(f=null===(h=null==d?void 0:d.config)||void 0===h?void 0:h.compessorUrl)&&void 0!==f?f:null===(p=null==d?void 0:d.config)||void 0===p?void 0:p.compressorUrl;F=await Ma(e,{maxSizeMB:t,maxWidthOrHeight:n,mimeType:e.type,fileName:A,libURL:r,enableCompression:Na(e.type)})}else F=Da(e,A)}catch(t){console.warn("Image preparation failed, uploading original file",t),F=Da(e,A)}let O=F.name;const P=!1===(null===(g=null==d?void 0:d.config)||void 0===g?void 0:g.hasPagination)||!0===(null===(y=null==d?void 0:d.config)||void 0===y?void 0:y.disablePagination);P&&(O=await L(O,I,r)),P&&(F=Da(F,O));try{if(null==M?void 0:M.uploadFiles)try{const t=await M.uploadFiles({items:[{name:O,size:F.size,type:F.type||e.type,folderId:I,data:F,extension:E,noFolder:r}],folderId:I});if(t.success&&t.detailed&&t.detailed.length>0){const i=t.detailed[0];if(!i.success||!i.data){if(!n){const e=(null==i?void 0:i.error)?String(i.error):m("Failed to upload file");v.error({id:"FILE_UPLOAD_ITEM_FAILED",message:e,placement:"bottomRight",description:A,innerException:null==i?void 0:i.error,data:{itemName:A,folderId:I||null,eventSource:"upload"}})}return void(T&&T(rn))}{const t=i.data;if(t.id){const n=(null!==(w=t.folderId)&&void 0!==w?w:I)||void 0;await D({folderId:n,noFolder:r});let i=l.files.find(e=>e.id===t.id);if(!i)try{i=(await R({folderId:n,noFolder:r,itemType:"file"})).find(e=>e.id===t.id)}catch(e){console.warn("uploadFileWithProvider: не удалось получить свежий список файлов",e)}return T&&T(rn),i||Object.assign(Object.assign({},t),{id:t.id,name:t.name||A,folderId:null!==(C=null!==(x=t.folderId)&&void 0!==x?x:I)&&void 0!==C?C:null,type:F.type||e.type,size:F.size,extension:E||A.split(".").pop()||"",thumbnail:null!==(_=t.thumbnail)&&void 0!==_?_:void 0,url:null!==(S=t.url)&&void 0!==S?S:void 0,thumbnailUrl:null!==(k=t.thumbnailUrl)&&void 0!==k?k:void 0,isFolder:!1,selected:!1})}}}else if(!t.success){if(!n){const e=t.error?String(t.error):m("Failed to upload file");v.error({id:"FILE_UPLOAD_ITEM_FAILED",message:e,placement:"bottomRight",description:A,innerException:t.error,data:{itemName:A,folderId:I||null,eventSource:"upload"}})}return void(T&&T(rn))}return void(T&&T(rn))}catch(e){throw e}if(null==M?void 0:M.uploadFile){const t=await M.uploadFile({name:O,size:F.size,type:F.type||e.type,folderId:I,noFolder:r,data:F,extension:E});return T&&T(rn),t}return void(n||v.error({id:"FILES_UPLOAD_PROVIDER_NOT_CONFIGURED",message:m("DataProvider for file upload is not configured"),placement:"bottomRight"}))}catch(e){const t=Io(e),r=Ao(null==t?void 0:t.code,m);return n?void 0:void v.error({id:"FILE_UPLOAD_ITEM_FAILED",message:null!=r?r:m("Failed to upload file"),placement:"bottomRight",description:A,innerException:e,data:{itemName:A,folderId:I||null,error:Io(e),eventSource:"upload"}})}},[M,b,T,l.files,D,R,v,m,null==d?void 0:d.config]),$=c(async(e,t)=>{var n;if(!(null==M?void 0:M.getFolders)||!(null==M?void 0:M.createFolder))return e||"";try{const r=await M.getFolders(),i=Array.isArray(r)?r:[],o=(e,t)=>i.find(n=>{var r;return(null!==(r=n.parentId)&&void 0!==r?r:null)===(null!=e?e:null)&&n.name===t});let a=null!=e?e:"";for(const e of t){if(!e)continue;let t=o(a,e);if(!t){const n=await M.createFolder({name:e,parentId:null!=a?a:null});i.push(n),t=n}a=t.id}return null!==(n=a)&&void 0!==n?n:e||""}catch(t){return console.warn("ensureFolderPath: unable to guarantee the path",t),e||""}},[M]),G=c(async(e,t)=>{var n,r,i,o;if(!(null===(r=null===(n=e.type)||void 0===n?void 0:n.startsWith)||void 0===r?void 0:r.call(n,"image/")))return null!=t?t:null;const a=null==e?void 0:e.webkitRelativePath;let s=t||"";if(a&&a.includes("/")){const e=a.split("/");e.pop();const n=e.filter(Boolean);n.length&&(s=await $(t||"",n)||t||"")}return null!==(o=null!==(i=s)&&void 0!==i?i:t)&&void 0!==o?o:null},[$]);c(async e=>{var t,n,r,i,o,a,s,l,c,u,d,h;const{file:f,selectedFolderId:p,uploadFn:g,progressCallbacks:m}=e;if(!(null===(n=null===(t=f.type)||void 0===t?void 0:t.startsWith)||void 0===n?void 0:n.call(t,"image/")))return{success:!0,fileName:f.name,folderId:null!=p?p:null};const v=null!==(i=null!==(r=await G(f,p))&&void 0!==r?r:p)&&void 0!==i?i:null,y=null!==(o=null!=v?v:p)&&void 0!==o?o:null;let b;null===(a=null==m?void 0:m.onStart)||void 0===a||a.call(m,f);try{if(null==m?void 0:m.onProgress){let e=0;b=window.setInterval(()=>{var t;e=Math.min(e+10+Math.floor(Date.now()%10),90),null===(t=null==m?void 0:m.onProgress)||void 0===t||t.call(m,f.name,e)},200)}const e=await g(f,null!=y?y:void 0);return(null==m?void 0:m.onProgress)&&(null===(s=null==m?void 0:m.onProgress)||void 0===s||s.call(m,f.name,100)),null===(l=null==m?void 0:m.onComplete)||void 0===l||l.call(m,f.name),{success:!0,fileName:f.name,fileId:null==e?void 0:e.id,folderId:null!==(u=null!==(c=null==e?void 0:e.folderId)&&void 0!==c?c:y)&&void 0!==u?u:null}}catch(e){const t=e instanceof Error?e.message:String(e);return null===(d=null==m?void 0:m.onError)||void 0===d||d.call(m,f.name,t),{success:!1,fileName:f.name,folderId:null!==(h=null!=y?y:p)&&void 0!==h?h:null,error:t}}finally{void 0!==b&&clearInterval(b)}},[G]);const q=c(async(e,t)=>{var n,r,i,o,a,s,l,c,u,h,f,p,g,y,w,x,C,_,S,k,A,E,I,F,O,P,R,L,N,D,j,z,B,U,V,H,W,$,q,Y;if(0===e.length)return{successCount:0,failCount:0,successes:[],errors:[],totalCount:0};null===(n=null==t?void 0:t.onStartBatch)||void 0===n||n.call(t,e);const X=e=>{const t=e.filter(Boolean);return t.length>0&&t.length<=5?t.join(", "):null},K=[];for(let n=0;n<e.length;n++){const w=e[n];if(!(null===(i=null===(r=w.type)||void 0===r?void 0:r.startsWith)||void 0===i?void 0:i.call(r,"image/"))){const e=await v.warning({id:"FILES_UPLOAD_UNSUPPORTED_TYPE",message:m("Unsupported file type"),placement:"bottomRight",data:{itemName:w.name,fileType:w.type,folderId:b||null}});null===(o=null==t?void 0:t.onError)||void 0===o||o.call(t,w.name,e.message);continue}const x=Uo(w.name,null==d?void 0:d.config);let C=w;try{if(null===(s=null===(a=w.type)||void 0===a?void 0:a.startsWith)||void 0===s?void 0:s.call(a,"image/")){const e=null!==(c=null===(l=null==d?void 0:d.config)||void 0===l?void 0:l.compressMaxSize)&&void 0!==c?c:Ta.MAX_SIZE_MB,t=null!==(h=null===(u=null==d?void 0:d.config)||void 0===u?void 0:u.compressMaxWidthOrHeight)&&void 0!==h?h:2e3,n=null!==(p=null===(f=null==d?void 0:d.config)||void 0===f?void 0:f.compessorUrl)&&void 0!==p?p:null===(g=null==d?void 0:d.config)||void 0===g?void 0:g.compressorUrl;C=await Ma(w,{maxSizeMB:e,maxWidthOrHeight:t,mimeType:w.type,fileName:x,libURL:n,enableCompression:Na(w.type)})}else C=Da(w,x)}catch(e){console.warn("Image preparation failed, uploading original file",e),C=Da(w,x)}const _=`${Date.now()}-${n}-${Math.random().toString(36).slice(2,8)}`,S=await G(C,b);null===(y=null==t?void 0:t.onStart)||void 0===y||y.call(t,C),K.push({file:C,targetFolderId:S,requestId:_,originalFileName:w.name,originalIndex:n})}const Z=K.length;if(0===Z)return{successCount:0,failCount:0,successes:[],errors:[],totalCount:0};const J=!1===(null===(w=null==d?void 0:d.config)||void 0===w?void 0:w.hasPagination)||!0===(null===(x=null==d?void 0:d.config)||void 0===x?void 0:x.disablePagination),Q=new Map;if(J&&(null==M?void 0:M.getFiles)){const e=[...new Set(K.map(e=>{var t,n;return null!==(n=null!==(t=e.targetFolderId)&&void 0!==t?t:b)&&void 0!==n?n:""}).filter(Boolean))];for(const t of e)try{const{files:e}=await M.getFiles({folderId:t||void 0,itemType:"file",page:1,limit:1e4});Q.set(t,(e||[]).map(e=>e.name))}catch(e){console.warn("Could not fetch files for duplicate check:",e)}}const ee=new Map,te=!t,ne=1===Z&&te,re=[],ie=[],oe=[],ae=[],se=new Map;let le=0,ce=0;const ue=null!==(_=null===(C=null==d?void 0:d.config)||void 0===C?void 0:C.maxFileSize)&&void 0!==_?_:52428800,de=async(e,n,r,i)=>{var o,a;const{emitProgress:s=!0,emitNotification:l=!0}=null!=i?i:{};le++,re.push(e),ie.push(null!=r?r:e),await((e,t,n,r)=>{var i;return v.success({id:"FILE_UPLOAD_ITEM_SUCCESS",message:`${m("File")} ${e} ${m("has been successfully uploaded")}`,placement:"bottomRight",data:{itemId:n,itemName:e,folderId:null!==(i=null!=t?t:b)&&void 0!==i?i:null,eventSource:"upload"}},r||!te)})(e,n,r,!l),s&&(null===(o=null==t?void 0:t.onProgress)||void 0===o||o.call(t,e,100),null===(a=null==t?void 0:t.onComplete)||void 0===a||a.call(t,e))},he=async(e,n,r,i)=>{var o;const{emitProgress:a=!0,emitNotification:s=!0,fileSize:l,progressCallbackName:c,progressCallbackIndex:u}=null!=i?i:{};ce++;const d=null!=l?{fileSize:l,maxSize:ue}:void 0,h=await((e,t,n,r,i)=>{var o,a,s,l,c,u,d;const h=Io(n),f=null!==(o=null==i?void 0:i.fileSize)&&void 0!==o?o:null==h?void 0:h.fileSize,p=null!==(s=null!==(a=null==i?void 0:i.maxSize)&&void 0!==a?a:null==h?void 0:h.maxSize)&&void 0!==s?s:ue,g={allowedChars:"a-z A-Z 0-9 . _ -",fileSize:null!=f?wo(Number(f)):void 0,maxSize:null!=p?wo(Number(p)):void 0},y=null==h?void 0:h.code,w="BatchItemLimitExceeded"===y||"exceeded_max_files"===y?y:null!==(l=Eo(null==h?void 0:h.message))&&void 0!==l?l:y,x="BatchItemLimitExceeded"===w||"exceeded_max_files"===w?To(n,m):Ao(w,m,g),C=(null==h?void 0:h.message)&&"string"==typeof h.message&&h.message.length>0?h.message:null,_=n instanceof Error?n.message:"string"==typeof n?n:null,S=_&&"[object Object]"!==_?_:null;return v.error({id:"FILE_UPLOAD_ITEM_FAILED",message:null!==(u=null!==(c=null!=C?C:x)&&void 0!==c?c:S)&&void 0!==u?u:m("Error uploading file {{fileName}}",{fileName:e}),placement:"bottomRight",data:{itemName:e,folderId:null!==(d=null!=t?t:b)&&void 0!==d?d:null,error:Io(n),eventSource:"upload"},innerException:n},r||!te)})(e,n,r,!s,d);a&&(null===(o=null==t?void 0:t.onError)||void 0===o||o.call(t,null!=c?c:e,h.message,u)),ae.push({itemId:void 0,itemName:e,error:Io(r)}),oe.push({fileName:e,error:h.message})};if(!(null==M?void 0:M.uploadFiles))return v.error({id:"FILES_UPLOAD_PROVIDER_NOT_CONFIGURED",message:m("DataProvider for file upload is not configured"),placement:"bottomRight"}),{successCount:0,failCount:Z,successes:[],errors:[],totalCount:Z};{const e=[];try{(null==t?void 0:t.onProgress)&&K.forEach(n=>{let r=0;const i=window.setInterval(()=>{var e;r=Math.min(r+10+Math.floor(Date.now()%10),90),null===(e=null==t?void 0:t.onProgress)||void 0===e||e.call(t,n.file.name,r)},200);e.push(i)});let n=await M.uploadFiles({items:K.map(e=>{var t,n;const r=J?((e,t)=>{const n=null!=e?e:"";let r=Q.get(n)||[],i=ee.get(n);i||(i=new Set(r.map(e=>e.toLowerCase())),ee.set(n,i));const o=_o(t,Array.from(i));return i.add(o.toLowerCase()),o})(e.targetFolderId,e.file.name):e.file.name,i=J?Da(e.file,r):e.file;return{requestId:e.requestId,name:r,size:i.size,type:i.type,folderId:null!==(n=null!==(t=e.targetFolderId)&&void 0!==t?t:b)&&void 0!==n?n:null,data:i,extension:i.name.split(".").pop()||""}}),folderId:null!=b?b:null});e.forEach(e=>window.clearInterval(e)),e.length=0;const r=null!==(S=n.detailed)&&void 0!==S?S:[],i=new Map(r.filter(e=>e.requestId).map(e=>[e.requestId,e]));if(r.length>0)for(let e=0;e<K.length;e++){const t=K[e],n=null!==(k=t.requestId?i.get(t.requestId):void 0)&&void 0!==k?k:r[e];if(n&&n.success){const e=n.data,r=null!==(A=null==e?void 0:e.name)&&void 0!==A?A:Uo(t.file.name,null==d?void 0:d.config),i=null!==(F=null!==(I=null!==(E=null==e?void 0:e.folderId)&&void 0!==E?E:t.targetFolderId)&&void 0!==I?I:b)&&void 0!==F?F:null,o=null==e?void 0:e.id;se.set(r,{id:o,name:r,folderId:i,size:null==e?void 0:e.size,originalFileName:t.originalFileName,originalIndex:t.originalIndex}),await de(r,i,o,{emitNotification:ne})}else{const e=null==n?void 0:n.data,r=null!==(O=null==e?void 0:e.name)&&void 0!==O?O:Uo(t.file.name,null==d?void 0:d.config),i=null!==(L=null!==(R=null!==(P=null==e?void 0:e.folderId)&&void 0!==P?P:t.targetFolderId)&&void 0!==R?R:b)&&void 0!==L?L:null;await he(r,i,null!==(N=null==n?void 0:n.error)&&void 0!==N?N:new Error(m("Error uploading file")),{emitNotification:ne,fileSize:t.file.size,progressCallbackName:t.originalFileName,progressCallbackIndex:t.originalIndex})}}else if(n.success)for(const e of K){const t=Uo(e.file.name,null==d?void 0:d.config),n=null!==(j=null!==(D=e.targetFolderId)&&void 0!==D?D:b)&&void 0!==j?j:null;await de(t,n,void 0,{emitNotification:ne})}else{const e=null!==(z=n.error)&&void 0!==z?z:new Error(m("Error uploading file"));for(const t of K){const n=Uo(t.file.name,null==d?void 0:d.config),r=null!==(U=null!==(B=t.targetFolderId)&&void 0!==B?B:b)&&void 0!==U?U:null;await he(n,r,e,{emitNotification:ne,fileSize:t.file.size,progressCallbackName:t.originalFileName,progressCallbackIndex:t.originalIndex})}}}catch(e){for(const t of K){const n=Uo(t.file.name,null==d?void 0:d.config),r=null!==(H=null!==(V=t.targetFolderId)&&void 0!==V?V:b)&&void 0!==H?H:null;await he(n,r,null!=e?e:new Error(m("Error uploading file")),{emitNotification:ne,fileSize:t.file.size,progressCallbackName:t.originalFileName,progressCallbackIndex:t.originalIndex})}}finally{e.forEach(e=>window.clearInterval(e))}}if(le>0&&(T&&T(rn),Z>1&&te)){const e=X(re),t=e?m("Uploaded",{names:e}):m("uploads_success_summary",{successCount:le,totalCount:Z});v.success({id:"FILES_UPLOAD_BATCH_SUCCESS",message:t,placement:"bottomRight",data:{successCount:le,totalCount:Z,itemIds:ie,itemNames:re,folderId:null!=b?b:null,eventSource:"upload"}})}if(ce>0&&te&&!ne)if(Z>1){const e=oe.map(e=>e.fileName),t=X(e),n=t?m("Failed",{names:t}):m("uploads_fail_summary",{failCount:ce,totalCount:Z});v.error({id:"FILES_UPLOAD_BATCH_FAILED",message:n,placement:"bottomRight",data:{failCount:ce,totalCount:Z,itemNames:e,folderId:null!=b?b:null,errors:ae,eventSource:"upload"}})}else if(1===Z&&ae.length>0&&(null===(W=ae[0].error)||void 0===W?void 0:W.code)){const e=Ao(null===($=ae[0].error)||void 0===$?void 0:$.code,m),t=null!==(Y=null===(q=oe[0])||void 0===q?void 0:q.fileName)&&void 0!==Y?Y:"",n=null!=e?e:t?`${m("Failed to upload files")}: ${t}`:m("Failed to upload files");v.error({id:"FILES_UPLOAD_BATCH_FAILED",message:n,placement:"bottomRight",data:{failCount:ce,totalCount:Z,itemNames:[t],folderId:null!=b?b:null,errors:ae,eventSource:"upload"}})}return{successCount:le,failCount:ce,successes:re,errors:oe,totalCount:Z,uploadedFiles:se.size>0?se:void 0}},[M,null===(o=null==d?void 0:d.config)||void 0===o?void 0:o.hasPagination,null===(a=null==d?void 0:d.config)||void 0===a?void 0:a.disablePagination,v,G,b,T,m,null==d?void 0:d.config]),Y=c(async e=>{var t;if(!(null==M?void 0:M.uploadFiles))return void v.error({id:"FILES_UPLOAD_PROVIDER_NOT_CONFIGURED",message:m("DataProvider for file upload is not configured"),placement:"bottomRight"});if("Trash"===b)return void v.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:m("Cannot upload files to Trash"),placement:"bottomRight",data:{folderId:b||null,reason:"Upload to Trash is not allowed"}});const n=S.current,r=document.createElement("input");r.type="file",r.accept="image/*",r.multiple=!0;try{!(!(null===(t=null==d?void 0:d.config)||void 0===t?void 0:t.features)||!d.config.features.enableDirectoryUpload)&&(r.webkitdirectory=!0)}catch(e){}r.onchange=async t=>{var r;const i=t.target.files;if(!i||0===i.length)return;const o=Array.from(i);try{null==E||E(!0);const{successes:t,errors:i,uploadedFiles:a}=await q(o,e);null===(r=null==e?void 0:e.onBatchComplete)||void 0===r||r.call(e,{files:o,successes:t,errors:i,uploadedFiles:a}),await g(),await D({folderId:b||"",sortBy:f,sortOrder:p,page:n.current,limit:n.pageSize})}catch(e){console.error("Error when loading files:",e)}finally{null==E||E(!1)}},r.click()},[null==M?void 0:M.uploadFiles,b,v,m,E,D,g,f,p,q,null===(s=null==d?void 0:d.config)||void 0===s?void 0:s.features]),X=c(async(e,t,n,r="uploadByUrl")=>{const i=S.current,o=Boolean(e&&String(e).trim());let a,s=null!=e?e:null;try{if(!t&&"Trash"===b)throw n||v.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:m("Cannot upload files to Trash"),placement:"bottomRight",data:{folderId:b||null,reason:"Upload to Trash is not allowed"}}),new $o(m("Cannot upload files to Trash"),"UploadUrlDownloadFailed");let e,l;if(!s&&w&&(e=await w.validateFields(),s=null==e?void 0:e.fileUrl),!s)throw n||v.error({id:"FILES_UPLOAD_URL_VALIDATION_FAILED",message:m("Please fill in all fields"),placement:"bottomRight",data:{url:null!=s?s:null,folderId:b||null,eventSource:r}}),new $o(m("Please fill in all fields"),"UploadUrlInvalid");if(Yo(s,m),s=La(s),null==E||E(!0),s){const e=s.split("?")[0].split("#")[0].split("/");l=e[e.length-1]||"uploaded-file",l=Uo(l,null==d?void 0:d.config)}const c=t?"":b||"",u=Boolean((null==M?void 0:M.uploadFiles)||(null==M?void 0:M.uploadFile)),h=Boolean(null==M?void 0:M.uploadFileByUrl);let g=l;g&&h&&(g=await L(g,c,t));try{const e=await z(s,n);if("existing"===e.kind)a=e.file;else if(u){const n=new File([e.blob],e.fileName,{type:e.mimeType,lastModified:Date.now()});try{a=await W(n,c,!0,t)}catch(e){throw e.uploadUrlStage="binaryUpload",e}if(!a){const e=new $o(m("Failed to upload file"),"FileUploadBackendError");throw e.uploadUrlStage="binaryUpload",e}}else{if(!h)throw n||v.error({id:"FILES_UPLOAD_URL_NOT_SUPPORTED",message:m("Upload by URL is not supported"),placement:"bottomRight",data:{url:s,folderId:b||null,eventSource:r}}),new $o(m("Upload by URL is not supported"),"UploadUrlDownloadFailed");a=await M.uploadFileByUrl({url:s,folderId:b||"",noFolder:t,name:g,eventSource:r})}}catch(e){const n=e;if("binaryUpload"===(null==n?void 0:n.uploadUrlStage)||!h)throw e;console.warn("Failed to fetch file by URL locally, falling back to uploadByUrl",e),a=await M.uploadFileByUrl({url:s,folderId:b||"",noFolder:t,name:g,eventSource:r})}const y=(null==e?void 0:e.name)||(null==a?void 0:a.name)||"unnamed file";return a&&v.success({id:"FILE_UPLOAD_ITEM_SUCCESS",message:`${m("File")} ${y} ${m("successfully uploaded")}`,placement:"bottomRight",data:{itemName:y,itemId:null==a?void 0:a.id,folderId:b||null,eventSource:r}},n),(e||o)&&(null==I||I(!1),null==w||w.resetFields()),T&&T(rn),await D({folderId:b||"",noFolder:t,sortBy:f,sortOrder:p,page:i.current,limit:i.pageSize}),a}catch(e){if(console.error("Error when loading a file by URL:",e),!n){const t=Io(e),n=t,i=e,o=Number(null==n?void 0:n.fileSize),a=Number(null==n?void 0:n.maxSize),l=Number.isFinite(o)&&Number.isFinite(a)?{fileSize:o,maxSize:a}:void 0,c="binaryUpload"===(null==i?void 0:i.uploadUrlStage)?To(t,m,l):Po(t,m);v.error({id:"FILES_UPLOAD_BY_URL_FAILED",message:c,placement:"bottomRight",data:{url:null!=s?s:null,folderId:b||null,error:t,eventSource:r},innerException:e})}throw e}finally{null==E||E(!1)}},[w,E,M,v,m,I,T,D,b,f,p,L,z,W,null==d?void 0:d.config]),K=c(async e=>{if(!e.length)return;const t=S.current;"Trash"!==b?(await q(e),await D({folderId:b||"",sortBy:f,sortOrder:p,page:t.current,limit:t.pageSize})):v.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:m("Cannot upload files to Trash"),placement:"bottomRight",data:{folderId:b||null,reason:"Upload to Trash is not allowed"}})},[D,b,f,p,q,v,m]);return{fetchFiles:D,handleDeleteFile:U,handleDeleteFolder:V,handleAddFile:Y,handleAddFileByUrl:X,handleDroppedFiles:K,getFileData:H,findFileByUrl:j,resolveFileForEditByUrl:B,uploadFileWithProvider:W}},Ba=e=>{let t;const n=new Set,r=(e,r)=>{const i="function"==typeof e?e(t):e;if(!Object.is(i,t)){const e=t;t=(null!=r?r:"object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>a,subscribe:e=>(n.add(e),()=>n.delete(e))},a=t=e(r,i,o);return o},Ua=e=>e;const Va=e=>{const t=(e=>e?Ba(e):Ba)(e),n=e=>function(e,t=Ua){const n=i.useSyncExternalStore(e.subscribe,i.useCallback(()=>t(e.getState()),[e,t]),i.useCallback(()=>t(e.getInitialState()),[e,t]));return i.useDebugValue(n),n}(t,e);return Object.assign(n,t),n};function Ha(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const Wa=($a=e=>({selectedFiles:new Set,visibleFileIds:[],anchorId:null,multiSelect:!0,setMultiSelect:t=>{e(e=>{var n;if(e.multiSelect===t)return e;if(t)return{multiSelect:!0};const r=null!==(n=Array.from(e.selectedFiles)[0])&&void 0!==n?n:null;return{multiSelect:!1,selectedFiles:r?new Set([r]):new Set,anchorId:r}})},syncVisibleFiles:t=>{const n=Array.isArray(t)?t.map(e=>e.id):[];e(e=>{const t=new Set(n),r=new Set(Array.from(e.selectedFiles).filter(e=>t.has(e))),i=e.anchorId&&t.has(e.anchorId)?e.anchorId:null,o=function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}(e.visibleFileIds,n),a=Ha(e.selectedFiles,r),s=e.anchorId===i;return o&&a&&s?e:{visibleFileIds:n,selectedFiles:r,anchorId:i}})},setSelectedFiles:t=>{e(e=>{var n;const r=new Set(e.visibleFileIds),i=new Set(Array.from(t).filter(e=>r.has(e)));return Ha(e.selectedFiles,i)?e:{selectedFiles:i,anchorId:null!==(n=Array.from(i)[0])&&void 0!==n?n:null}})},clearSelection:()=>{e(e=>0===e.selectedFiles.size&&null===e.anchorId?e:{selectedFiles:new Set,anchorId:null})},selectAllVisible:()=>{e(e=>{var t;const n=new Set(e.visibleFileIds),r=null!==(t=e.visibleFileIds[0])&&void 0!==t?t:null;return Ha(e.selectedFiles,n)&&e.anchorId===r?e:{selectedFiles:n,anchorId:r}})},toggleFileSelection:(t,n)=>{e(e=>{const r=!1!==e.multiSelect,i=Boolean(null==n?void 0:n.shiftKey)&&r,o=Boolean(null==n?void 0:n.metaKey)||Boolean(null==n?void 0:n.ctrlKey)||Boolean(null==n?void 0:n.forceToggle),a=e.visibleFileIds,s=new Set(a);if(a.length>0&&!s.has(t))return e;if(!r){const n=new Set([t]);return Ha(e.selectedFiles,n)&&e.anchorId===t?e:{selectedFiles:n,anchorId:t}}if(i&&e.anchorId&&s.has(e.anchorId)){const n=a.indexOf(e.anchorId),r=a.indexOf(t);if(-1===n||-1===r)return e;const[i,s]=n<r?[n,r]:[r,n],l=a.slice(i,s+1),c=o?new Set(e.selectedFiles):new Set;return l.forEach(e=>{c.add(e)}),Ha(e.selectedFiles,c)?e:{selectedFiles:c}}if(i&&!e.anchorId){const n=new Set([t]);return Ha(e.selectedFiles,n)&&e.anchorId===t?e:{selectedFiles:n,anchorId:t}}if(o){const n=new Set(e.selectedFiles);return n.has(t)?n.delete(t):n.add(t),Ha(e.selectedFiles,n)&&e.anchorId===t?e:{selectedFiles:n,anchorId:t}}const l=new Set([t]);return Ha(e.selectedFiles,l)&&e.anchorId===t?e:{selectedFiles:l,anchorId:t}})}}),$a?Va($a):Va);var $a;const Ga=e=>{var t,n,r,i;const{state:o,actions:a,options:s}=ro(),{t:l}=Qn(),u=Ho(),d=bo(),{fetchFolders:h}=u.actions,{renameItem:f}=(()=>{const{options:e}=ro(),{dataProviders:t}=e,{t:n}=Qn(),r=c(async({itemId:r,newName:i,isFolder:o})=>{var a,s,l,c,u,d,h,f;try{if(o){if(!(null==t?void 0:t.renameFolder))throw new Error(n("renameFolder is not implemented in dataProviders"));const o=Vo(i.trim(),e.config),c=await t.renameFolder(r,o);return{success:!0,renamedItem:{id:c.id,name:null!==(a=c.name)&&void 0!==a?a:o,parentId:null!==(s=c.parentId)&&void 0!==s?s:null,folderId:null!==(l=c.parentId)&&void 0!==l?l:null}}}if(!(null==t?void 0:t.renameFile))throw new Error(n("renameFile is not implemented in dataProviders"));const p=Uo(i,e.config),g=await t.renameFile(r,p);return{success:!0,renamedItem:{id:null!==(c=null==g?void 0:g.id)&&void 0!==c?c:r,name:null!==(u=null==g?void 0:g.name)&&void 0!==u?u:p,folderId:null!==(d=null==g?void 0:g.folderId)&&void 0!==d?d:null,parentId:null!==(f=null!==(h=null==g?void 0:g.parentId)&&void 0!==h?h:null==g?void 0:g.folderId)&&void 0!==f?f:null}}}catch(e){return{success:!1,error:Io(e)}}},[t,n,e.config]);return{renameItem:r}})(),{files:p,selectedFolder:g,fileToRename:m,renameForm:v,isRenameModalVisible:y,pagination:b}=o,{setFileToRename:w,setIsRenameModalVisible:x}=a,{dataProviders:C,config:_}=s,S=e=>{var t,n;if(!e)return null;const r=e;return null!==(n=null!==(t=r.folderId)&&void 0!==t?t:r.parentId)&&void 0!==n?n:null},k=(e,t)=>{var n;return{itemId:null!==(n=null==e?void 0:e.id)&&void 0!==n?n:t,itemName:null==e?void 0:e.name,folderId:S(e)}},A=c(e=>{var t,n;const r=null==p?void 0:p.find(t=>t.id===e);if((null==r?void 0:r.isFolder)||e.startsWith("folder_")){if(!(!1!==(null===(t=null==_?void 0:_.features)||void 0===t?void 0:t.enableRenameFolder)))return void d.error({id:"FOLDER_RENAME_DISABLED_BY_CONFIG",message:l("Folder rename is disabled by config"),placement:"bottomRight",data:k(r,e)});if(!(null==C?void 0:C.renameFolder))throw new Error(l("renameFolder is not implemented in dataProviders"))}else{if(!(!1!==(null===(n=null==_?void 0:_.features)||void 0===n?void 0:n.enableRenameFile)))return void d.error({id:"FILE_RENAME_DISABLED_BY_CONFIG",message:l("File rename is disabled by config"),placement:"bottomRight",data:k(r,e)});if(!(null==C?void 0:C.renameFile))throw new Error(l("renameFile is not implemented in dataProviders"))}null==w||w(e),null==x||x(!0),r&&v&&v.setFieldsValue({newFileName:r.name})},[p,w,x,v,null===(t=null==_?void 0:_.features)||void 0===t?void 0:t.enableRenameFolder,null===(n=null==_?void 0:_.features)||void 0===n?void 0:n.enableRenameFile,null==C?void 0:C.renameFolder,null==C?void 0:C.renameFile,d,l]),E=c(()=>{null==x||x(!1),null==w||w(null),null==v||v.resetFields()},[x,w,v]),I=c(async()=>{var t,n,r,i,o,s,c,u,y,w,x,C;if(!m||!v)return;const S=null==p?void 0:p.find(e=>e.id===m);try{const p=await v.validateFields();if(!(null==p?void 0:p.newFileName))return;const A=(null==S?void 0:S.isFolder)||m.startsWith("folder_");if(A){if(!(!1!==(null===(t=null==_?void 0:_.features)||void 0===t?void 0:t.enableRenameFolder)))return void d.error({id:"FOLDER_RENAME_DISABLED_BY_CONFIG",message:l("Folder rename is disabled by config"),placement:"bottomRight",data:k(S,m)})}else{if(!(!1!==(null===(n=null==_?void 0:_.features)||void 0===n?void 0:n.enableRenameFile)))return void d.error({id:"FILE_RENAME_DISABLED_BY_CONFIG",message:l("File rename is disabled by config"),placement:"bottomRight",data:k(S,m)})}const I=await f({itemId:m,newName:p.newFileName,isFolder:A});if(!I.success){const e=Ao(null===(r=I.error)||void 0===r?void 0:r.code,l);return void d.error({id:"ITEM_RENAME_FAILED",message:null!==(o=null!=e?e:null===(i=I.error)||void 0===i?void 0:i.message)&&void 0!==o?o:l("Error renaming"),placement:"bottomRight",data:Object.assign(Object.assign({},k(S,m)),{error:I.error}),innerException:I.error})}const T=I.renamedItem;A?(d.success({id:"FOLDER_RENAME_SUCCESS",message:l(`${l("Folder renamed to")} ${null!==(s=null==T?void 0:T.name)&&void 0!==s?s:p.newFileName}`),placement:"bottomRight",data:{itemId:null!==(c=null==T?void 0:T.id)&&void 0!==c?c:m,itemName:null!==(u=null==T?void 0:T.name)&&void 0!==u?u:p.newFileName,folderId:null!==(w=null!==(y=null==T?void 0:T.parentId)&&void 0!==y?y:null==T?void 0:T.folderId)&&void 0!==w?w:null}}),await h(),(null==T?void 0:T.id)&&T.id!==m&&a.setSelectedFolder&&a.setSelectedFolder(T.id)):d.success({id:"FILE_RENAME_SUCCESS",message:`${l("File renamed to")} ${null!==(x=null==T?void 0:T.name)&&void 0!==x?x:p.newFileName}`,placement:"bottomRight",data:Object.assign(Object.assign({},k(S,m)),{itemName:null!==(C=null==T?void 0:T.name)&&void 0!==C?C:p.newFileName})}),E(),await e({folderId:g||"",page:b.current,limit:b.pageSize})}catch(e){console.error("Error when renaming:",e);const t=Io(e),n=Ao(null==t?void 0:t.code,l);d.error({id:"ITEM_RENAME_FAILED",message:null!=n?n:e instanceof Error?e.message:l("Error renaming"),placement:"bottomRight",data:Object.assign(Object.assign({},k(S,m)),{error:t}),innerException:e})}},[m,v,p,a,E,e,g,l,b,null===(r=null==_?void 0:_.features)||void 0===r?void 0:r.enableRenameFolder,null===(i=null==_?void 0:_.features)||void 0===i?void 0:i.enableRenameFile,d,h,f]);return{state:{isRenamingFile:y||!1,fileToRename:m},actions:{showRenameModal:A,handleRenameCancel:E,handleRenameOk:I}}},qa=e=>{const t=t=>{if(!t)return;const n=e.find(e=>e.id===t);return null==n?void 0:n.name};return{getItemNameById:t,getItemNamesByIds:e=>e.map(t).filter(e=>Boolean(e)),getNamesPreview:e=>e.length>0&&e.length<=5?e.join(", "):null}},Ya=(e,t,n,r,i)=>({itemIds:e,itemNames:i&&i.length?i:void 0,successCount:t,totalCount:n,folderId:null!=r?r:null}),Xa=(e,t,n,r,i,o)=>({itemIds:e,itemNames:o&&o.length?o:void 0,failCount:t,totalCount:n,folderId:null!=r?r:null,errors:i}),Ka=()=>{const e=bo(),{t:t}=Qn(),{actions:{fetchFolders:n,fetchChildFolders:r}}=Ho();return{refreshFolders:c(async({parentIds:i,selectedFolder:o})=>{try{if(await n(),i&&r)for(const e of i)e&&await r(e)}catch(n){console.error("Error when updating the folder tree:",n),e.error({id:"FILES_FETCH_FAILED",message:t("Failed to refresh folder tree"),placement:"bottomRight",innerException:n,data:{params:{folderId:o||void 0}}})}},[e,t]),refreshFiles:c(async({fetchFiles:n,selectedFolder:r,page:i,limit:o})=>{try{await n({folderId:r||"",page:i,limit:o})}catch(n){console.error("Ошибка при обновлении списка файлов:",n),e.error({id:"FILES_FETCH_FAILED",message:t("Failed to refresh file list"),placement:"bottomRight",innerException:n,data:{params:{folderId:r||void 0,page:i,limit:o}}})}},[e,t])}},Za=e=>{var t,n;const{state:r,actions:i,options:o}=ro(),{t:a}=Qn(),s=bo(),l=Wa(e=>e.selectedFiles),u=Wa(e=>e.clearSelection),{files:d,selectedFolder:h,moveForm:f,pagination:p,currentMenuFile:g}=r,{setIsMoveModalVisible:m,setPagination:v}=i,{dataProviders:y}=o,{moveItems:b}=(()=>{const{options:e}=ro(),{dataProviders:t}=e,{t:n}=Qn(),r=bo(),i=c(async({items:e,targetFolderId:i,getItemNameById:o,showNotifications:a=!1})=>{let s=0,l=0;const c=[];if(null==t?void 0:t.moveItems)try{const n=await t.moveItems("folders"===i?"":i,e.map(e=>e.id)),r=n.detailed;if(r){const e=r.filter(e=>e.success),t=r.filter(e=>!e.success);s+=e.length,l+=t.length,t.forEach(e=>{const t=(e=>{var t;return null!==(t=e.requestId)&&void 0!==t?t:e.id})(e),n=e.error,r=Io(n);c.push({itemId:t,itemName:o(t),error:r})})}else if(n.success)s+=e.length;else{const t=n.error;if(t){l+=e.length;const n=Io(t);c.push({error:n})}else l+=e.length}}catch(t){l+=e.length;const n=Io(t);c.push({error:n})}else l+=e.length,c.push({error:{message:"Move provider is not configured"}});return a&&(s>0&&r.success({id:"FILES_MOVE_SUCCESS",message:n("Files moved"),placement:"bottomRight",data:{successCount:s,totalCount:e.length,itemIds:e.map(e=>e.id),folderId:"folders"===i?null:i}}),l>0&&r.error({id:"FILES_MOVE_ERROR",message:n("Errors occurred while moving"),placement:"bottomRight",innerException:c.length?c:void 0,data:{failCount:l,totalCount:e.length,itemIds:e.map(e=>e.id),errors:c.length?c:void 0}})),{successCount:s,failCount:l,errorDetails:c}},[t,r,n]);return{moveItems:i}})(),{refreshFolders:w,refreshFiles:x}=Ka(),{getItemNameById:C,getItemNamesByIds:_,getNamesPreview:S}=qa(d),k=c(()=>{null==m||m(!0)},[m]),A=c(()=>{null==m||m(!1),null==f||f.resetFields()},[m,f]),E=c(async t=>{var n,r,i,c,m,k,E,I,T,F;if(!((null==g?void 0:g.length)||l&&0!==l.size))return;const O=d.length,P=Object.assign({},p),M=Array.from((null==g?void 0:g.length)?[g]:l),R=M.length;let L=0,N=0;const D=[],j=M.map(e=>d.find(t=>t.id===e)).filter(e=>Boolean(e)),z=j.some(e=>(null==e?void 0:e.isFolder)||e.id.startsWith("folder_"));try{let l=t;if(!t){const e=await f.validateFields();l=null==e?void 0:e.targetFolder}if(!l)return void s.error({id:"FILES_MOVE_DIRECTORY_NOT_SELECTED",message:a("Select destination folder"),placement:"bottomRight"});const d="folders"===l?null:l,p=null!=d?d:h,g=!1===(null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.paginationAvailable)||!1===(null===(r=null==o?void 0:o.config)||void 0===r?void 0:r.hasPagination)||!0===(null===(i=null==o?void 0:o.config)||void 0===i?void 0:i.disablePagination);if(g&&(null==y?void 0:y.getFolders))try{const e=await y.getFolders({parentId:d,deep:!1}),t=new Set((e||[]).map(e=>{var t;return null===(t=e.name)||void 0===t?void 0:t.toLowerCase()}).filter(Boolean));for(const e of j){if(!e.isFolder&&!(null===(m=(c=e.id).startsWith)||void 0===m?void 0:m.call(c,"folder_")))continue;const n=e.name||C(e.id)||"";if(n&&t.has(n.toLowerCase()))return void s.error({id:"FOLDER_ALREADY_EXISTS_MOVE",message:a("A folder with that name already exists. Please enter a different folder name."),placement:"bottomRight",data:{folderName:n,targetFolderId:l}})}}catch(e){console.warn("Could not check folder duplicates for move:",e)}if(g&&(null==y?void 0:y.getFiles)&&(null==y?void 0:y.renameFile))try{let e=[];if(null==y?void 0:y.getFiles){const{files:t}=await y.getFiles({folderId:d||void 0,itemType:"all",page:1,limit:1e4});e=(t||[]).map(e=>e.name).filter(e=>!!e)}if(null==y?void 0:y.getFolders){const t=(await y.getFolders({parentId:d,deep:!1})||[]).map(e=>e.name).filter(e=>!!e);e=[...e,...t]}const t=new Set(e.map(e=>null==e?void 0:e.toLowerCase()).filter(Boolean));for(const e of j){if(e.isFolder||(null===(E=(k=e.id).startsWith)||void 0===E?void 0:E.call(k,"folder_")))continue;const n=e.name||C(e.id)||"";if(!n||!t.has(n.toLowerCase())){t.add(n.toLowerCase());continue}const r=_o(n,Array.from(t));await y.renameFile(e.id,r),t.add(r.toLowerCase())}}catch(e){console.warn("Could not check duplicates for move:",e)}const B=await b({items:j,targetFolderId:l,getItemNameById:C,showNotifications:!1});if(L=B.successCount,N=B.failCount,D.push(...B.errorDetails),L>0){const e=_(M),t=S(e),n=t?a("Moved",{names:t}):a("move_success_summary",{successCount:L,totalCount:R});s.success({id:"FILES_MOVE_SUCCESS",message:n,placement:"bottomRight",data:Ya(M,L,R,d,e)})}if(N>0){const e=_(M),t=S(e);let n;if(1===R&&D.length>0&&(null===(I=D[0].error)||void 0===I?void 0:I.code)){const e=Ao(null===(T=D[0].error)||void 0===T?void 0:T.code,a);n=null!=e?e:t?a("Failed",{names:t}):a("move_fail_summary",{failCount:N,totalCount:R})}else n=t?a("Failed",{names:t}):a("move_fail_summary",{failCount:N,totalCount:R});s.error({id:"FILES_MOVE_ERROR",message:n,placement:"bottomRight",innerException:D.length?D:void 0,data:Xa(M,N,R,d,D.length?D:void 0,e)})}A(),u();let U=P.current;if(L>0&&O>0&&L>=O&&P.current>1&&(U=P.current-1),L>0&&P.total>=L){const e=Math.max(0,(null!==(F=P.total)&&void 0!==F?F:0)-L);null==v||v({current:U,pageSize:P.pageSize,total:e})}z&&await w({parentIds:void 0,selectedFolder:p}),await x({fetchFiles:e,selectedFolder:h,page:U,limit:P.pageSize})}catch(e){console.error("Error when moving:",e);const t=Ao(Io(e).code,a);s.error({id:"FILES_MOVE_ERROR",innerException:e,message:null!=t?t:a("Error moving"),placement:"bottomRight",data:Xa(M,R,R,h||null,[{error:Io(e)}],_(M))})}},[g,l,f,e,h,p,d,s,v,a,b,u,m,null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.hasPagination,null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.disablePagination,null==y?void 0:y.getFiles,null==y?void 0:y.renameFile,C]);return{actions:{showMoveModal:k,handleMoveCancel:A,handleMoveOk:E}}},Ja=e=>{var t,n;const{state:r,actions:i,options:o}=ro(),{t:a}=Qn(),s=bo(),l=Wa(e=>e.selectedFiles),u=Wa(e=>e.clearSelection),{files:d,selectedFolder:h,copyForm:f,pagination:p,currentMenuFile:g}=r,{setIsCopyModalVisible:m}=i,{dataProviders:v}=o,{copyItems:y}=(()=>{const{options:e}=ro(),{dataProviders:t}=e,{t:n}=Qn(),r=bo(),i=c(async({items:e,targetFolderId:i,getItemNameById:o,showNotifications:a=!1})=>{let s=0,l=0;const c=[],u="folders"===i?"":i;if(null==t?void 0:t.copyItems)try{const n=await t.copyItems(u,e.map(e=>({id:e.id,newName:e.newName}))),r=n.detailed;if(r){const e=r.filter(e=>e.success),t=r.filter(e=>!e.success);s+=e.length,l+=t.length,t.forEach(e=>{const t=(e=>{var t;return null!==(t=e.requestId)&&void 0!==t?t:e.id})(e),n=e.error,r=Io(n);c.push({itemId:t,itemName:o(t),error:r})})}else if(n.success)s+=e.length;else{const t=n.error;if(t){l+=e.length;const n=Io(t);c.push({error:n})}else l+=e.length}}catch(t){l+=e.length;const n=Io(t);c.push({error:n})}else if(null==t?void 0:t.copyItem)for(const n of e)try{const e=(null==n?void 0:n.isFolder)||n.id.startsWith("folder_");await t.copyItem({itemId:n.id,targetFolderId:u,isFolder:e,newName:n.newName})?s++:l++}catch(e){l++;const t=Io(e);c.push({itemId:n.id,itemName:o(n.id),error:t})}else l+=e.length,c.push({error:{message:"Copy provider is not configured"}});return a&&(s>0&&r.success({id:"FILES_COPY_SUCCESS",message:n("Files copied"),placement:"bottomRight",data:{successCount:s,totalCount:e.length,itemIds:e.map(e=>e.id),folderId:"folders"===i?null:i}}),l>0&&r.error({id:"FILES_COPY_ERROR",message:n("Errors occurred while copying"),placement:"bottomRight",innerException:c.length?c:void 0,data:{failCount:l,totalCount:e.length,itemIds:e.map(e=>e.id),errors:c.length?c:void 0}})),{successCount:s,failCount:l,errorDetails:c}},[t,r,n]);return{copyItems:i}})(),{refreshFolders:b,refreshFiles:w}=Ka(),{getItemNameById:x,getItemNamesByIds:C,getNamesPreview:_}=qa(d),S=c(()=>{null==m||m(!0)},[m]),k=c(()=>{null==m||m(!1),null==f||f.resetFields()},[m,f]),A=c(async t=>{var n,r,i,c,m,S,A;if(!((null==g?void 0:g.length)||l&&0!==l.size))return;const E=Array.from((null==g?void 0:g.length)?[g]:l),I=E.length;let T=0,F=0;const O=[],P=E.map(e=>d.find(t=>t.id===e)).filter(e=>Boolean(e)),M=P.some(e=>(null==e?void 0:e.isFolder)||e.id.startsWith("folder_"));try{let l=t;if(!t){const e=await f.validateFields();l=null==e?void 0:e.targetFolder}if(!l)return void s.error({id:"FILES_COPY_DIRECTORY_NOT_SELECTED",message:a("Select destination folder"),placement:"bottomRight"});const d="folders"===l?null:l,g=null!=d?d:h;let R=P.map(e=>({id:e.id,isFolder:(null==e?void 0:e.isFolder)||e.id.startsWith("folder_")}));const L=!1===(null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.paginationAvailable)||!1===(null===(r=null==o?void 0:o.config)||void 0===r?void 0:r.hasPagination)||!0===(null===(i=null==o?void 0:o.config)||void 0===i?void 0:i.disablePagination);if(L&&(null==v?void 0:v.getFolders))try{const e=await v.getFolders({parentId:d,deep:!1}),t=new Set((e||[]).map(e=>{var t;return null===(t=e.name)||void 0===t?void 0:t.toLowerCase()}).filter(Boolean));for(const e of P){if(!e.isFolder&&!(null===(m=(c=e.id).startsWith)||void 0===m?void 0:m.call(c,"folder_")))continue;const n=e.name||x(e.id)||"";if(n&&t.has(n.toLowerCase()))return void s.error({id:"FOLDER_ALREADY_EXISTS_COPY",message:a("A folder with that name already exists. Please enter a different folder name."),placement:"bottomRight",data:{folderName:n,targetFolderId:l}})}}catch(e){console.warn("Could not check folder duplicates for copy:",e)}if(L&&(null==v?void 0:v.getFiles))try{let e=[];const{files:t}=await v.getFiles({folderId:d||void 0,itemType:"all",page:1,limit:1e4});if(e=(t||[]).map(e=>e.name).filter(e=>!!e),null==v?void 0:v.getFolders){const t=(await v.getFolders({parentId:d,deep:!1})||[]).map(e=>e.name).filter(e=>!!e);e=[...e,...t]}const n=[...e];R=P.map(e=>{var t,r;if(e.isFolder||(null===(r=(t=e.id).startsWith)||void 0===r?void 0:r.call(t,"folder_")))return{id:e.id,isFolder:!0};const i=P.find(t=>t.id===e.id),o=(null==i?void 0:i.name)||x(e.id)||"",a=_o(o,n);return n.push(a),{id:e.id,isFolder:!1,newName:a!==o?a:void 0}})}catch(e){console.warn("Could not check duplicates for copy:",e)}else R=P.map(e=>({id:e.id,isFolder:(null==e?void 0:e.isFolder)||e.id.startsWith("folder_")}));const N=await y({items:R,targetFolderId:l,getItemNameById:x,showNotifications:!1});if(T=N.successCount,F=N.failCount,O.push(...N.errorDetails),T>0){const e=C(E),t=_(e),n=t?a("Copied",{names:t}):a("copy_success_summary",{successCount:T,totalCount:I});s.success({id:"FILES_COPY_SUCCESS",message:n,placement:"bottomRight",data:Ya(E,T,I,d,e)})}if(F>0){const e=C(E),t=_(e);let n;if(1===I&&O.length>0&&(null===(S=O[0].error)||void 0===S?void 0:S.code)){const e=Ao(null===(A=O[0].error)||void 0===A?void 0:A.code,a);n=null!=e?e:t?a("Failed",{names:t}):a("copy_fail_summary",{failCount:F,totalCount:I})}else n=t?a("Failed",{names:t}):a("copy_fail_summary",{failCount:F,totalCount:I});s.error({id:"FILES_COPY_ERROR",message:n,placement:"bottomRight",innerException:O.length?O:void 0,data:Xa(E,F,I,d,O.length?O:void 0,e)})}k(),u(),M&&await b({parentIds:void 0,selectedFolder:g}),await w({fetchFiles:e,selectedFolder:h,page:p.current,limit:p.pageSize})}catch(e){console.error("Error when copying:",e);const t=Ao(Io(e).code,a);s.error({id:"FILES_COPY_ERROR",message:null!=t?t:a("Error copying"),innerException:e,placement:"bottomRight",data:Xa(E,I,I,h||null,[{error:Io(e)}],C(E))})}},[g,l,f,e,h,p,d,s,a,y,u,m,null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.hasPagination,null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.disablePagination,null==v?void 0:v.getFiles,x]);return{actions:{showCopyModal:S,handleCopyCancel:k,handleCopyOk:A}}},Qa=e=>{const t=Ga(e),n=Za(e),r=Ja(e),i=(e=>{const{state:t,actions:n,options:r}=ro(),{t:i}=Qn(),o=bo(),a=Wa(e=>e.selectedFiles),s=Wa(e=>e.clearSelection),{files:l,selectedFolder:u,pagination:d,currentMenuFile:h}=t,{setIsDeleteConfirmVisible:f,setUndoDeletion:p,setPagination:g}=n,{config:m}=r,{deleteItems:v}=Wo(),{refreshFolders:y,refreshFiles:b}=Ka(),{getItemNameById:w,getItemNamesByIds:x,getNamesPreview:C}=qa(l),_=c(()=>{null==f||f(!0)},[f]),S=c(()=>{null==f||f(!1)},[f]),k=c(async()=>{var t,n,r;if(!((null==h?void 0:h.length)||a&&0!==a.size))return void(null==f||f(!1));const c=l.length,_=Object.assign({},d),S=Array.from(h?[h]:a),k=S.map(e=>l.find(t=>t.id===e)).filter(e=>Boolean(e)),A=new Set;k.forEach(e=>{(null==e?void 0:e.isFolder)&&A.add((e=>{var t,n;if(!e)return null;const r=e;return null!==(n=null!==(t=r.folderId)&&void 0!==t?t:r.parentId)&&void 0!==n?n:null})(e))});let E=0,I=0;const T=[];try{const a=await v({items:k,selectedFolder:u,getItemNameById:w,showNotifications:!1});E=a.successCount,I=a.failCount,T.push(...a.errorDetails);const l=(null==m?void 0:m.enableTrashFolder)&&"Trash"===u;if(E>0&&(null==m?void 0:m.enableTrashFolder)&&!l&&(null==p||p({itemIds:S,sourceFolderId:u||"folders"})),E>0){const e=S.length;(null==m?void 0:m.enableTrashFolder)&&!l?await o.success({id:"FILES_DELETE_SUCCESS",message:i("moved_to_trash",{count:E}),placement:"bottomRight",data:{successCount:E,totalCount:e,itemIds:S,folderId:u||null}}):await o.success({id:"FILES_DELETE_SUCCESS",message:i("Files deleted"),placement:"bottomRight",data:{successCount:E,totalCount:e,itemIds:S,folderId:u||null}})}if(I>0){const e=x(S),r=C(e),a=S.length,s=1===a&&T.length>0&&(null===(t=T[0].error)||void 0===t?void 0:t.code),c=(null==m?void 0:m.enableTrashFolder)&&!l,u=i(c?"При перемещении в корзину произошли ошибки":"При удалении произошли ошибки"),d=s?Ao(null===(n=T[0].error)||void 0===n?void 0:n.code,i):void 0,h=null!=d?d:r?i("Failed",{names:r}):u;o.error({id:"FILES_DELETE_ERROR",message:h,placement:"bottomRight",innerException:T.length?T:void 0,data:{failCount:I,isTrashMove:c,totalCount:a,itemNames:e,errors:T.length?T:void 0}})}s(),null==f||f(!1),await y({parentIds:Array.from(A),selectedFolder:u});let d=_.current;if(E>0&&c>0&&E>=c&&_.current>1&&(d=_.current-1),E>0&&_.total>=E){const e=Math.max(0,(null!==(r=_.total)&&void 0!==r?r:0)-E);null==g||g({current:d,pageSize:_.pageSize,total:e})}await b({fetchFiles:e,selectedFolder:u,page:d,limit:_.pageSize})}catch(e){console.error("Error when deleting:",e),o.error({id:"FILES_DELETE_ERROR",message:i("Error deleting"),placement:"bottomRight",innerException:e,data:{failCount:I,totalCount:k.length}})}},[h,a,f,e,u,d,p,g,l,i,o,v,s,null==m?void 0:m.enableTrashFolder]);return{actions:{showDeleteConfirm:_,handleDeleteConfirmCancel:S,handleDeleteConfirmOk:k}}})(e);return{state:t.state,actions:Object.assign(Object.assign(Object.assign(Object.assign({},t.actions),n.actions),r.actions),i.actions)}},es=()=>{const{state:e}=ro(),{files:t,loading:n,isUrlModalVisible:r}=e,i=za(),o=(()=>{const{state:e}=ro(),t=e.multiSelect,n=Wa(e=>e.selectedFiles),r=Wa(e=>e.toggleFileSelection),i=Wa(e=>e.setMultiSelect);return a(()=>{i(!1!==t)},[t,i]),{state:{selectedFiles:n},actions:{toggleFileSelection:r}}})(),s=Qa(i.fetchFiles);return{state:{files:t||[],selectedFiles:o.state.selectedFiles,loading:n||!1,isAddingFileByUrl:r||!1,isRenamingFile:s.state.isRenamingFile,fileToRename:s.state.fileToRename},actions:{fetchFiles:i.fetchFiles,handleDeleteFile:i.handleDeleteFile,handleDeleteFolder:i.handleDeleteFolder,handleAddFile:i.handleAddFile,handleAddFileByUrl:i.handleAddFileByUrl,handleDroppedFiles:i.handleDroppedFiles,uploadFileWithProvider:i.uploadFileWithProvider,toggleFileSelection:o.actions.toggleFileSelection,showRenameModal:s.actions.showRenameModal,handleRenameCancel:s.actions.handleRenameCancel,handleRenameOk:s.actions.handleRenameOk,showMoveModal:s.actions.showMoveModal,handleMoveCancel:s.actions.handleMoveCancel,handleMoveOk:s.actions.handleMoveOk,showCopyModal:s.actions.showCopyModal,handleCopyCancel:s.actions.handleCopyCancel,handleCopyOk:s.actions.handleCopyOk,showDeleteConfirm:s.actions.showDeleteConfirm,handleDeleteConfirmCancel:s.actions.handleDeleteConfirmCancel,handleDeleteConfirmOk:s.actions.handleDeleteConfirmOk}}},ts="filemanager_sidebar_width",ns=({onSearch:t,placeholder:n,className:r})=>{const{t:i}=Qn(),[s,l]=o(""),c=u(null),{options:d}=ro(),{config:h}=d,f=n||i("Search files...");a(()=>(c.current=go.debounce(e=>{t(e)},500),()=>{var e;null===(e=c.current)||void 0===e||e.cancel()}),[t]);return e(F,{value:s,onChange:e=>{var t;const n=e.target.value;l(n),null===(t=c.current)||void 0===t||t.call(c,n)},placeholder:f,prefix:e(wi,{size:16,strokeWidth:null==h?void 0:h.iconStrokeWidth}),className:r,allowClear:!0,onClear:()=>{l(""),t("")}})};var rs={contentLayout:"contentLayout",headerContainer:"headerContainer",actionsContainer:"actionsContainer",filesContainer:"filesContainer",emptyStateWrapper:"emptyStateWrapper",paginationContainer:"paginationContainer",uploadIcon:"uploadIcon",tableContainer:"tableContainer",tableLoadingWrapper:"tableLoadingWrapper",imagePreview:"imagePreview",fileManagerTableFolder:"fileManagerTableFolder",fileManagerTableFolderInner:"fileManagerTableFolderInner",sortSelect:"sortSelect",fileNameCol:"fileNameCol",fileItemCount:"fileItemCount",fileSize:"fileSize",fileDate:"fileDate",tableMenu:"tableMenu",tableImagePreview:"tableImagePreview",tableFolderIcon:"tableFolderIcon",buttonDeselected:"buttonDeselected",buttonSelectAll:"buttonSelectAll",gridRow:"gridRow",gridCard:"gridCard",selectedRow:"selectedRow",gridCardSelected:"gridCardSelected",gridCheckbox:"gridCheckbox",gridCardContent:"gridCardContent",gridPreviewContainer:"gridPreviewContainer",gridPreviewContainerFolder:"gridPreviewContainerFolder",gridFolderIcon:"gridFolderIcon",gridFolderIconImage:"gridFolderIconImage",gridFileName:"gridFileName",gridFileInfo:"gridFileInfo",gridFileMenu:"gridFileMenu",gridFileMenuButton:"gridFileMenuButton",actionsBox:"actionsBox",uploadContainer:"uploadContainer",uploadArea:"uploadArea",blockText:"blockText",textTitle:"textTitle",textDescription:"textDescription",buttons:"buttons",btnAi:"btnAi",btnPhoto:"btnPhoto",dragOverlay:"dragOverlay",dragOverlayInner:"dragOverlayInner",dragCaptureLayer:"dragCaptureLayer",dragOverlayGlobal:"dragOverlayGlobal",noFiles:"noFiles",noFilesIcon:"noFilesIcon",textTitle_trash:"textTitle_trash",textDescription_trash:"textDescription_trash"};const{Text:is}=O,{Option:os}=P;const as=i.memo(({files:n,filesById:r,currentSortOption:i,isSmallScreen:o,iconStrokeWidth:a,multiSelectEnabled:s=!0,features:l,viewMode:c,setViewMode:u,handleSearch:h,handleSortOptionChange:f,onClearSelection:p,onRename:g,onDelete:m,onCopy:v,onMove:y,onEdit:b,t:w})=>{const x=Wa(e=>e.selectedFiles),C=Wa(e=>e.selectedFiles.size),_=Wa(e=>e.selectAllVisible),S=n.length>0&&C===n.length,k=d(()=>Array.from(x)[0],[x]),A=d(()=>k?r.get(k):void 0,[r,k]),E=(null==A?void 0:A.isFolder)?!1!==(null==l?void 0:l.enableRenameFolder):!1!==(null==l?void 0:l.enableRenameFile),I=d(()=>Array.from(x).every(e=>{const t=r.get(e);return!!t&&(t.isFolder?!1!==(null==l?void 0:l.enableMoveFolder):!1!==(null==l?void 0:l.enableMoveItem))}),[l,r,x]),T=d(()=>Array.from(x).every(e=>{const t=r.get(e);return!!t&&(t.isFolder?!1!==(null==l?void 0:l.enableCopyFolder):!1!==(null==l?void 0:l.enableCopyItem))}),[l,r,x]),F=d(()=>1===C&&function(e){var t,n,r;if(!e||e.isFolder)return!1;const i=e.extension||(e.name&&e.name.includes(".")?e.name.split(".").pop():void 0)||((null===(t=e.type)||void 0===t?void 0:t.startsWith("image/"))?null===(r=null===(n=e.type.split("/")[1])||void 0===n?void 0:n.split(";")[0])||void 0===r?void 0:r.trim():void 0);return Boolean(i&&vn.includes(i.toLowerCase()))}(A),[C,A]);return t("div",C>0?{className:`header-container ${rs.headerContainer}`,children:[t(is,{type:"secondary",className:"selected-text",children:[t("div",{children:[C," ",w("selected")]}),s&&e(M,{title:o?w("Select all"):null,children:e(R,{className:rs.buttonSelectAll,onClick:_,disabled:S||0===n.length,children:w("Select all")})}),e(M,{title:o?w("Deselected"):null,children:e(R,{className:rs.buttonDeselected,icon:e(bi,{size:16,strokeWidth:a}),onClick:p,children:w("Deselected")})})]}),t(L,{children:[F&&!1!==(null==l?void 0:l.enableEdit)&&e(M,{title:o?w("Edit"):null,children:e(R,{icon:e(ai,{size:16,strokeWidth:a}),onClick:()=>b(A),disabled:!F,children:w("Edit")})}),I&&e(M,{title:o?w("Move to"):null,children:e(R,{icon:e(li,{size:16,strokeWidth:a}),onClick:y,children:w("Move to")})}),T&&e(M,{title:o?w("Copy"):null,children:e(R,{icon:e(oi,{size:16,strokeWidth:a}),onClick:v,children:w("Copy")})}),1===C&&E&&e(M,{title:o?w("Rename"):null,children:e(R,{icon:e(Ci,{size:16,strokeWidth:a}),onClick:()=>g(),disabled:1!==C||!E,children:w("Rename")})}),!1!==(null==l?void 0:l.enableDelete)&&e(M,{title:o?w("Delete"):null,children:e(R,{danger:!0,icon:e(Si,{size:16,strokeWidth:a}),onClick:e=>{e.stopPropagation(),e.preventDefault(),m()},children:w("Delete")})})]})]}:{className:rs.headerContainer,children:[e("div",{className:"search-container",children:e(ns,{placeholder:w("Search file or folder"),onSearch:h,className:rs.searchInput})}),t("div",{className:rs.actionsBox,children:[e("div",{className:"sort-container",children:t(P,{value:i,onChange:f,className:rs.sortSelect,popupMatchSelectWidth:!1,suffixIcon:e(ri,{size:16,strokeWidth:a}),children:[e(os,{value:"date-desc",children:w("Newest first")}),e(os,{value:"date-asc",children:w("Oldest first")}),e(os,{value:"size-desc",children:w("Largest first")}),e(os,{value:"size-asc",children:w("Smallest first")}),e(os,{value:"name-asc",children:w("A-Z")}),e(os,{value:"name-desc",children:w("Z-A")}),e(os,{value:"type-asc",children:w("By type")})]})}),e("div",{className:rs.actionsContainer,children:e(N,{options:[{value:"grid",icon:e(hi,{size:16,strokeWidth:a})},{value:"table",icon:e(gi,{size:20,strokeWidth:a})}],value:c,onChange:e=>u(e)})})]})]})});as.displayName="FileContentHeader";const ss=i.memo(({fileId:t,style:n})=>{const r=Wa(e=>e.selectedFiles.has(t)),i=Wa(e=>e.toggleFileSelection);return e(D,{checked:r,style:n,onClick:e=>{e.stopPropagation()},onChange:e=>{const n=e.nativeEvent;i(t,{metaKey:n.metaKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,forceToggle:!0})}})});function ls(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}ss.displayName="FileSelectionCheckbox","function"==typeof SuppressedError&&SuppressedError;const cs=i.memo(t=>{var{className:n}=t,r=ls(t,["className"]);const i=r["data-row-key"],o=null==i?"":String(i),a=[n,Wa(e=>!!o&&e.selectedFiles.has(o))?rs.selectedRow:""].filter(Boolean).join(" ");return e("tr",Object.assign({},r,{className:a}))});cs.displayName="SelectableTableRow";const us=i.memo(({item:t,variant:n="table",t:r,iconStrokeWidth:i,setCurrentMenuFile:a,showMoveModal:s,showCopyModal:l,showRenameModal:u,showDeleteConfirm:h,onEdit:f})=>{const[p,g]=o(!1),m=d(()=>{if(!p)return[];const n=[];return t.canEdit&&n.push({key:"edit",label:r("Edit"),icon:e(ai,{size:16,strokeWidth:i})}),t.canMove&&n.push({key:"move",label:r("Move to"),icon:e(li,{size:16,strokeWidth:i})}),t.canCopy&&n.push({key:"copy",label:r("Copy"),icon:e(oi,{size:16,strokeWidth:i})}),t.canRename&&n.push({key:"rename",label:r("Rename"),icon:e(Ci,{size:16,strokeWidth:i})}),t.canDelete&&n.push({key:"delete",label:r("Delete"),icon:e(Si,{size:16,strokeWidth:i}),style:{color:"#ff4d4f"}}),n},[i,p,t.canCopy,t.canDelete,t.canEdit,t.canMove,t.canRename,r]),v=c(({key:e})=>{switch(t.id&&(null==a||a(t.id)),e){case"edit":f(t.file);break;case"move":s();break;case"copy":l();break;case"rename":u(t.id);break;case"delete":null==h||h();break;default:null==a||a("")}},[t,f,a,l,h,s,u]),y=d(()=>({items:m,onClick:v}),[v,m]);return e(j,{arrow:!0,placement:"bottom",menu:y,trigger:["hover"],onOpenChange:g,children:"grid"===n?e(R,{type:"default",className:`${rs.gridFileMenuButton} gridFileMenuButton`,onClick:e=>{e.stopPropagation(),e.preventDefault()},children:e(si,{size:16,strokeWidth:i})}):e("span",{className:`${rs.tableMenu} tableMenuButton`,onClick:e=>{e.stopPropagation(),e.preventDefault()},children:e(si,{size:16,strokeWidth:i})})})});us.displayName="FileItemActionsDropdown";const ds=({thumbnailSrc:t,previewSrc:n,alt:r,className:s,width:l,height:u,preview:d=!1})=>{const h=r,[f,p]=o(t),[g,m]=o(n),v=i.useRef(!1),y=i.useRef(!1),b=c(e=>{const t=e.split(",")[1];return!!(t&&t.length>20)},[]),w=c(e=>{var t;if(e&&e!==bn)return e.startsWith("data:image/")?b(e)?e:void 0:e.startsWith("blob:")?e:e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?null!==(t=(e=>{if(e&&"string"==typeof e){if(e.startsWith("data:")||e.startsWith("blob:"))return e;try{if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")){const t=new URL(e.startsWith("/")?`https://x${e}`:e),n=e.startsWith("/")?"":`${t.protocol}//${t.host}`,r=t.pathname.split("/").map(e=>{if(!e)return"";try{return encodeURIComponent(decodeURIComponent(e))}catch(t){return encodeURIComponent(e)}}).join("/");return e.startsWith("/")?r+(t.search||"")+(t.hash||""):`${n}${r}${t.search}${t.hash}`}}catch(e){}return e}})(e))&&void 0!==t?t:e:void 0},[b]);a(()=>{v.current=!1,y.current=!1;const e=w(t),r=w(n),i=null!=r?r:e;p(null!=e?e:r),m(i)},[t,n,w]);const x=c((e,t)=>e&&e.toLowerCase().endsWith(".svg")||t&&(t.includes(".svg")||t.includes("image/svg+xml")),[]),C=c(()=>{f!==bn&&(v.current||(v.current=!0,x(h,f)),p(bn))},[f,h,x]),_=c(()=>{if(g&&g!==bn&&!y.current)return g;const e=w(t);return e&&!v.current?e:void 0},[g,t,w]),S=f===bn?mn:f,k=_();return S?e(z,{className:s,src:S,alt:r,width:l,height:u,preview:!(!d||!k)&&{src:k,toolbarRender:()=>null,destroyOnHidden:!0,mask:e(be,{style:{fontSize:"20px"}})},onError:C,fallback:mn}):null},hs=i.memo(({item:t,variant:n="table",FolderIcon:r,getFileData:i,className:o,width:a,height:s})=>t.isFolder?e("div","grid"===n?{className:rs.gridFolderIcon,children:e(r,{className:rs.gridFolderIconImage})}:{className:rs.fileManagerTableFolder,children:e("div",{className:rs.fileManagerTableFolderInner,children:e(r,{className:rs.tableFolderIcon,style:{width:null!=a?a:40,height:null!=s?s:40}})})}):t.thumbnailSrc||t.previewSrc?e(ds,{className:o,thumbnailSrc:t.thumbnailSrc,previewSrc:t.previewSrc,alt:t.file.name,width:a,height:s,preview:!0,file:t.file,getFileData:i}):null);hs.displayName="FileItemPreview";const fs=i.memo(({item:n,t:r,iconStrokeWidth:i,FolderIcon:o,handleSingleClick:a,handleDoubleClick:s,handleItemClick:l,setCurrentMenuFile:c,showMoveModal:u,showCopyModal:d,showRenameModal:h,showDeleteConfirm:f,onEdit:p,onEditorOk:g,getFileData:m,showSelectionCheckbox:v=!0})=>{const y=Wa(e=>e.selectedFiles.has(n.id)),b=Wa(e=>e.toggleFileSelection);return e(B,{className:rs.gridCard_col,style:{padding:0},children:t(U,{hoverable:!0,cover:e("div",{className:n.isFolder?rs.gridPreviewContainerFolder:rs.gridPreviewContainer,onClick:e=>{e.stopPropagation(),n.isFolder&&a(()=>{b(n.id,{metaKey:e.metaKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey})})},onDoubleClick:e=>{e.stopPropagation(),s(()=>{n.isFolder&&l(n.file)})},children:e(hs,{item:n,variant:"grid",FolderIcon:o,getFileData:m,className:rs.gridImagePreview})}),className:`${rs.gridCard} ${y?rs.gridCardSelected:""}`,onClick:e=>{e.stopPropagation(),e.preventDefault();const t=e.target;t.closest(".gridFileMenuButton")||t.closest(".ant-dropdown-menu")||a(()=>b(n.id,{metaKey:e.metaKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey}))},onDoubleClick:e=>{e.stopPropagation(),s(()=>{n.isFolder&&l(n.file)})},children:[t("div",{className:rs.gridCardContent,onDoubleClick:e=>{e.stopPropagation(),e.preventDefault(),s(()=>{n.isFolder?l(n.file):g&&g(n.file)})},onClick:e=>{e.stopPropagation(),e.preventDefault();const t=e.target;t.closest(".gridFileMenuButton")||t.closest(".ant-dropdown-menu")||a(()=>b(n.id,{metaKey:e.metaKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey}))},children:[e("div",{className:rs.gridFileName,children:n.nameText||r("Untitled")}),e("div",{className:rs.gridFileInfo,children:n.gridInfoText})]}),e("div",{className:rs.gridFileMenu,children:e(us,{item:n,variant:"grid",t:r,iconStrokeWidth:i,setCurrentMenuFile:c,showMoveModal:u,showCopyModal:d,showRenameModal:h,showDeleteConfirm:f,onEdit:p})}),v?e("div",{onClick:e=>{e.stopPropagation()},className:rs.gridCheckbox,children:e(ss,{fileId:n.id,style:{height:20}})}):null]})})});fs.displayName="FileGridItem";const ps=i.memo(({rows:t,topOffset:r=0,bottomOffset:i=0,t:o,iconStrokeWidth:a,FolderIcon:s,handleSingleClick:l,handleDoubleClick:c,handleItemClick:u,setCurrentMenuFile:d,showMoveModal:h,showCopyModal:f,showRenameModal:p,showDeleteConfirm:g,onEdit:m,onEditorOk:v,getFileData:y,showSelectionCheckbox:b=!0})=>e(n,{children:e("div",{style:{paddingTop:r,paddingBottom:i},children:e(V,{gutter:[16,16],className:rs.gridRow,style:{gap:20,padding:"0 24px 24px",margin:0},children:t.map(t=>e(fs,{item:t,handleSingleClick:l,handleDoubleClick:c,handleItemClick:u,iconStrokeWidth:a,t:o,FolderIcon:s,setCurrentMenuFile:d,showMoveModal:h,showCopyModal:f,showRenameModal:p,showDeleteConfirm:g,onEdit:m,onEditorOk:v,getFileData:y,showSelectionCheckbox:b},t.id))})})}));ps.displayName="FileGridView";const gs=i.memo(({rows:t,columns:r,loading:i,topOffset:o=0,bottomOffset:a=0,onRow:s,components:l})=>{const c=d(()=>e("div",{style:{paddingTop:o,paddingBottom:a},children:e(E,{renderEmpty:()=>e(W,{image:e(n,{}),description:""}),children:e(H,{dataSource:t,columns:r,rowKey:"id",pagination:!1,tableLayout:"fixed",onRow:s,components:l,showHeader:!1})})}),[a,r,l,s,t,o]);return e(k,{spinning:i,className:rs.tableLoadingWrapper,children:c})});gs.displayName="FileTableView";const ms=i.memo(({item:t})=>t.dateText?e(M,{title:t.dateText,placement:"bottom",className:rs.fileDate,children:t.dateText}):null);ms.displayName="FileItemDate";const vs=i.memo(({item:n})=>t("div",{className:rs.fileName,children:[n.nameText,n.isFolder&&e("div",{className:rs.fileItemCount,children:n.folderItemsText})]}));vs.displayName="FileItemName";const ys="filemanager_view_mode";class bs{constructor(){this.rowsById=new Map}reconcile(e,t,n){const r=new Map,i=[];for(const o of e){const e=t.getId(o),a=t.buildSignature(o,n),s=this.rowsById.get(e);if(s&&s.signature===a){r.set(e,s),i.push(s);continue}const l=t.buildRowModel(o,n,{id:e,signature:a});r.set(e,l),i.push(l)}return this.rowsById=r,i}}class ws{createRenderWindow(e,t){var n,r,i,o,a,s,l,c,u,d,h;if("windowed"!==(null!==(n=null==t?void 0:t.renderStrategy)&&void 0!==n?n:"full"))return{rows:e,startIndex:0,endIndex:e.length>0?e.length-1:-1,topOffset:0,bottomOffset:0,totalCount:e.length};const f=Math.max(0,null!==(i=null===(r=null==t?void 0:t.windowed)||void 0===r?void 0:r.startIndex)&&void 0!==i?i:0),p=null!==(a=null===(o=null==t?void 0:t.windowed)||void 0===o?void 0:o.endIndex)&&void 0!==a?a:e.length-1,g=Math.max(0,null!==(l=null===(s=null==t?void 0:t.windowed)||void 0===s?void 0:s.overscan)&&void 0!==l?l:0),m=Math.max(1,null!==(u=null===(c=null==t?void 0:t.windowed)||void 0===c?void 0:c.estimatedItemSize)&&void 0!==u?u:1),v=Math.max(1,null!==(h=null===(d=null==t?void 0:t.windowed)||void 0===d?void 0:d.itemsPerLane)&&void 0!==h?h:1),y=Math.ceil(e.length/v),b=Math.min(e.length-1,p),w=Math.floor(f/v),x=Math.floor(Math.max(f,b)/v),C=Math.max(0,w-g),_=Math.min(y-1,x+g),S=C*v,k=Math.min(e.length-1,(_+1)*v-1),A=Math.max(0,y-_-1);return{rows:e.slice(S,k+1),startIndex:S,endIndex:k,topOffset:C*m,bottomOffset:A*m,totalCount:e.length}}}function xs({totalCount:e,plan:t}){const[n,r]=o(null),i=d(()=>{var r,i;if(!t.enabled)return{renderStrategy:"full"};const o=function(e,t){var n;return Math.max(1,null!==(n=null==e?void 0:e.viewportHeight)&&void 0!==n?n:t)}(n,null!==(r=t.fallbackViewportHeight)&&void 0!==r?r:800),a=Math.max(1,Math.ceil(o/t.estimatedItemSize)),s=Math.max(1,Math.ceil(e/t.itemsPerLane)),l=Math.min(s-1,Math.max(0,Math.floor((null!==(i=null==n?void 0:n.scrollTop)&&void 0!==i?i:0)/t.estimatedItemSize))),c=l+a-1;return{renderStrategy:"windowed",windowed:{startIndex:l*t.itemsPerLane,endIndex:Math.min(e-1,(c+1)*t.itemsPerLane-1),overscan:t.overscan,estimatedItemSize:t.estimatedItemSize,itemsPerLane:t.itemsPerLane}}},[t.enabled,t.estimatedItemSize,t.fallbackViewportHeight,t.itemsPerLane,t.overscan,e,n]);return{engineOptions:i,handleViewportChange:c(e=>{r(t=>(null==t?void 0:t.viewportHeight)===e.viewportHeight&&(null==t?void 0:t.viewportWidth)===e.viewportWidth&&(null==t?void 0:t.scrollHeight)===e.scrollHeight&&(null==t?void 0:t.scrollTop)===e.scrollTop?t:e)},[])}}function Cs(e){var t,n,r;const i=e.extension||(e.name&&e.name.includes(".")?e.name.split(".").pop():void 0)||((null===(t=e.type)||void 0===t?void 0:t.startsWith("image/"))?null===(r=null===(n=e.type.split("/")[1])||void 0===n?void 0:n.split(";")[0])||void 0===r?void 0:r.trim():void 0);return Boolean(i&&vn.includes(i.toLowerCase()))}function _s(e,t){if(!e)return"";const n=new Date(e);if(Number.isNaN(n.getTime()))return"";const r=[t("months.january"),t("months.february"),t("months.march"),t("months.april"),t("months.may"),t("months.june"),t("months.july"),t("months.august"),t("months.september"),t("months.october"),t("months.november"),t("months.december")];return t("Added",{date:`${n.getDate()} ${r[n.getMonth()]} ${n.getFullYear()}`})}const Ss={getId:e=>e.id,buildSignature:(e,t)=>function(e,t){var n,r,i,o,a,s,l,c,u,d;const h=Boolean(e.isFolder),f=h&&null!==(r=null!==(n=e.childCount)&&void 0!==n?n:t.folderFileCounts[e.id])&&void 0!==r?r:0,p=_s(e.date,t.t),g=!h&&e.size?String(e.size):"",m=[!1!==(null===(i=t.features)||void 0===i?void 0:i.enableEdit),!1!==(null===(o=t.features)||void 0===o?void 0:o.enableMoveFolder),!1!==(null===(a=t.features)||void 0===a?void 0:a.enableMoveItem),!1!==(null===(s=t.features)||void 0===s?void 0:s.enableCopyFolder),!1!==(null===(l=t.features)||void 0===l?void 0:l.enableCopyItem),!1!==(null===(c=t.features)||void 0===c?void 0:c.enableRenameFolder),!1!==(null===(u=t.features)||void 0===u?void 0:u.enableRenameFile),!1!==(null===(d=t.features)||void 0===d?void 0:d.enableDelete)].join("|");return[e.id,e.name,e.folderId,e.type||"",e.extension||"",e.thumbnailUrl||e.thumbnail||"",e.thumbnailUrl||e.thumbnail||"",e.dimensions||"",g,p,h?"1":"0",String(f),m].join("::")}(e,t),buildRowModel:(e,t,n)=>{var r,i,o,a,s,l,c,u,d,h;const f=Boolean(e.isFolder),p=f&&null!==(i=null!==(r=e.childCount)&&void 0!==r?r:t.folderFileCounts[e.id])&&void 0!==i?i:0,g=1===p?t.t("item"):t.t("items"),m=f?`${p} ${g}`:"",v=e.dimensions||"",y=!f&&e.size?Co(e.size):"",b=f?t.t("Folder"):function(e){var t,n,r;return e.extension||(null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase())||(e.url?null===(r=null===(n=e.url.split("?")[0].split("/").pop())||void 0===n?void 0:n.split(".").pop())||void 0===r?void 0:r.toLowerCase():"")||""}(e),w=_s(e.date,t.t),x=f?m:[v,y,b].filter(Boolean).join(" • ");return{id:n.id,signature:n.signature,item:e,file:e,isFolder:f,nameText:e.name||t.t("No name"),folderItemsText:m,dimensionsText:v,sizeText:y,typeText:b,dateText:w,gridInfoText:x,thumbnailSrc:e.thumbnailUrl||e.thumbnail,previewSrc:e.thumbnailUrl||e.thumbnail,canEdit:!f&&!1!==(null===(o=t.features)||void 0===o?void 0:o.enableEdit)&&Cs(e),canMove:f?!1!==(null===(a=t.features)||void 0===a?void 0:a.enableMoveFolder):!1!==(null===(s=t.features)||void 0===s?void 0:s.enableMoveItem),canCopy:f?!1!==(null===(l=t.features)||void 0===l?void 0:l.enableCopyFolder):!1!==(null===(c=t.features)||void 0===c?void 0:c.enableCopyItem),canRename:f?!1!==(null===(u=t.features)||void 0===u?void 0:u.enableRenameFolder):!1!==(null===(d=t.features)||void 0===d?void 0:d.enableRenameFile),canDelete:!1!==(null===(h=t.features)||void 0===h?void 0:h.enableDelete)}}};function ks({files:e,folderFileCounts:t,features:n,t:r,viewMode:i}){const a=d(()=>({folderFileCounts:t,features:n,t:r}),[n,t,r]),[s,l]=o(()=>Math.max(1,Math.floor(5))),h=d(()=>{const t=e.length>150;return"table"===i?{enabled:t,estimatedItemSize:56,overscan:10,itemsPerLane:1,fallbackViewportHeight:800}:{enabled:t,estimatedItemSize:320,overscan:2,itemsPerLane:s,fallbackViewportHeight:800}},[e.length,s,i]),{engineOptions:f,handleViewportChange:p}=xs({totalCount:e.length,plan:h}),{rowModels:g,renderWindow:m}=function({items:e,context:t,adapter:n,options:r}){const i=u(null),o=u(null);i.current||(i.current=new bs),o.current||(o.current=new ws);const a=d(()=>i.current.reconcile(e,n,t),[n,t,e]),s=d(()=>o.current.createRenderWindow(a,r),[r,a]);return{rowModels:a,renderWindow:s}}({items:e,context:a,adapter:Ss,options:f}),v=d(()=>g.some(e=>Boolean(e.dateText)),[g]),y=c(e=>{if("grid"===i){const t=Math.max(1,Math.floor(e.viewportWidth/240));l(e=>e===t?e:t)}p(e)},[p,i]);return{rowModels:g,renderRows:m.rows,renderWindow:m,hasAnyValidDate:v,handleViewportChange:y}}const As=/(auto|scroll|overlay)/;function Es(e){if("undefined"==typeof window)return!1;const t=window.getComputedStyle(e);return As.test(t.overflowY)||As.test(t.overflow)||As.test(t.overflowX)}function Is(e){if("undefined"==typeof window)return e;let t=e;for(;t;){if(Es(t))return t;t=t.parentElement}return null}function Ts(e,t,n){Math.max(0,e.clientHeight),Math.max(0,Math.round(e.getBoundingClientRect().height));return Math.max(1,t)}function Fs(e,t){if(e===t){const n=function(e){var t;if("undefined"==typeof window)return Math.max(1,e.clientHeight);const n=e.getBoundingClientRect(),r=window.innerHeight||(null===(t=document.documentElement)||void 0===t?void 0:t.clientHeight)||0,i=Math.max(0,n.top),o=Math.min(r,n.bottom);return Math.max(0,Math.round(o-i))}(t);return{scrollTop:t.scrollTop,viewportHeight:Ts(e,Math.min(t.clientHeight,n||t.clientHeight)),viewportWidth:Math.max(1,t.clientWidth),scrollHeight:e.scrollHeight}}const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=Math.max(n.top,r.top),o=Math.min(n.bottom,r.bottom),a=Math.max(n.left,r.left),s=Math.min(n.right,r.right),l=Math.max(0,Math.round(o-i)),c=Math.max(0,Math.round(s-a));return{scrollTop:Math.max(0,Math.round(i-r.top)),viewportHeight:Ts(e,l),viewportWidth:Math.max(1,c||t.clientWidth||e.clientWidth),scrollHeight:e.scrollHeight}}function Os(e){if("undefined"==typeof window)return{scrollTop:e.scrollTop,viewportHeight:Math.max(1,e.clientHeight),viewportWidth:e.clientWidth,scrollHeight:e.scrollHeight};const t=Is(e);return t&&function(e){return e.scrollHeight-e.clientHeight>1}(t)?Fs(e,t):function(e){var t,n;const r=e.getBoundingClientRect(),i=window.innerHeight||(null===(t=document.documentElement)||void 0===t?void 0:t.clientHeight)||0,o=window.innerWidth||(null===(n=document.documentElement)||void 0===n?void 0:n.clientWidth)||r.width,a=Math.max(0,r.top),s=Math.min(i,r.bottom),l=Math.max(0,Math.round(s-a));return{scrollTop:Math.max(0,Math.round(-r.top)),viewportHeight:Ts(e,l),viewportWidth:Math.max(1,Math.min(Math.round(r.width),o)),scrollHeight:e.scrollHeight}}(e)}const Ps=i.memo(({files:n,searchTerm:r,handleSearch:i,sortBy:s,sortOrder:l,handleSortOptionChange:h,pagination:f,setPagination:p,loading:g,handleItemClick:m,onClearSelection:v,onRename:y,onDelete:b,onCopy:w,onMove:x,showRenameModal:C,showDeleteConfirm:_,showCopyModal:S,showMoveModal:k,onEdit:A,getFileData:E,handleAddFile:I})=>{var T;const{t:F}=Qn(),{DropZoneFileIcon:O,BigStockIcon:P,BigAIIcon:M,FolderIcon:R}=oo(),{options:L,actions:N,state:D}=ro(),{dataProviders:j,config:z}=L,B=null==z?void 0:z.disablePagination,{setCurrentMenuFile:U,setActiveLibraryItem:V}=N,H="Trash"===(null==D?void 0:D.selectedFolder),W=!1!==(null==D?void 0:D.multiSelect),G=Wa(e=>e.toggleFileSelection),{viewMode:q,setViewMode:Y}=(()=>{const[e,t]=o(()=>{try{return localStorage.getItem(ys)||"table"}catch(e){return"table"}}),n=c(e=>{t(e);try{localStorage.setItem(ys,e)}catch(e){console.warn("Не удалось сохранить режим отображения:",e)}},[]),r=c(()=>{n("table"===e?"grid":"table")},[e,n]);return{viewMode:e,setViewMode:n,toggleViewMode:r}})(),[X,K]=o({}),[Z,J]=o(!1),Q=u(null),ee=u(0),te=u(null);a(()=>{const e=window.matchMedia("(max-width: 1199px)"),t=e=>{J(e.matches)};t(e);const n=e=>t(e);return"function"==typeof e.addEventListener?(e.addEventListener("change",n),()=>e.removeEventListener("change",n)):(e.addListener(n),()=>e.removeListener(n))},[]);const ne=d(()=>(null==z?void 0:z.features)||{},[null==z?void 0:z.features]),re=null==z?void 0:z.iconStrokeWidth,ie=`${s}-${l}`,oe=d(()=>new Map(n.map(e=>[e.id,e])),[n]),{renderRows:ae,renderWindow:se,hasAnyValidDate:le,handleViewportChange:ce}=ks({files:n,folderFileCounts:X,features:ne,t:F,viewMode:q}),ue=c(async e=>{var t;try{if(null==j?void 0:j.getChildrenCount)return await j.getChildrenCount("folders"===e?void 0:e);if(null==j?void 0:j.getFiles){const{files:n,pagination:r}=await j.getFiles({folderId:"folders"===e?void 0:e,itemType:"all",page:B?void 0:1,limit:B?void 0:1});return B?Array.isArray(n)?n.length:0:null!==(t=null==r?void 0:r.total)&&void 0!==t?t:Array.isArray(n)?n.length:0}return 0}catch(t){return"StaleLoad"===(null==t?void 0:t.name)||console.error(`Error getting the number of files for the folder ${e}:`,t),0}},[j,B]),de=c(async()=>{const e=ee.current+1;ee.current=e;const t=n.filter(e=>e.isFolder);if(0===t.length)return void K(e=>0===Object.keys(e).length?e:{});const r={},i=t.map(async e=>{"number"!=typeof e.childCount?r[e.id]=await ue(e.id):r[e.id]=e.childCount});await Promise.all(i),ee.current===e&&K(e=>{const t=Object.keys(e),n=Object.keys(r);return t.length===n.length&&t.every(t=>e[t]===r[t])?e:r})},[n,ue]);a(()=>{de()},[de]),a(()=>{te.current&&ce(Os(te.current))},[n.length,ce,q]),a(()=>{if(!te.current||"undefined"==typeof ResizeObserver)return;const e=te.current,t=new ResizeObserver(()=>{ce(Os(e))});return t.observe(e),()=>{t.disconnect()}},[ce]);const he=c((e=()=>{})=>{if(Q.current)return;const t=setTimeout(()=>{e(),Q.current=null},300);Q.current=t},[]),fe=c(e=>{Q.current&&(clearTimeout(Q.current),Q.current=null),e()},[]),pe=c(e=>{const t=Os(e);ce(t)},[ce]);a(()=>{const e=te.current;if(!e)return;const t=()=>{pe(e)},n=function(e){if("undefined"==typeof window)return[e];const t=Is(e);return t?t===e?[window,e]:[window,t]:[window]}(e);return n.forEach(e=>{e.addEventListener("scroll",t,{passive:!0})}),()=>{n.forEach(e=>{e.removeEventListener("scroll",t)})}},[n.length,pe,q]);const ge=c((e,t)=>e!==t,[]),me=d(()=>[...W?[{key:"selection",width:46,shouldCellUpdate:ge,render:(t,n)=>e(ss,{fileId:n.id})}]:[],{key:"preview",width:60,shouldCellUpdate:ge,render:(t,n)=>e(hs,{item:n,variant:"table",FolderIcon:R,getFileData:E,className:`${rs.imagePreview} ${rs.tableImagePreview}`,width:40,height:40})},{title:F("Name"),width:"calc(100% - 430px)",dataIndex:"nameText",key:"name",className:rs.fileNameCol,shouldCellUpdate:ge,render:(t,n)=>e(vs,{item:n})},{title:F("Dimensions"),key:"dimensions",width:100,shouldCellUpdate:ge,render:(t,n)=>n.dimensionsText&&e("div",{className:rs.fileSize,children:n.dimensionsText})},{title:F("Size"),key:"size",width:90,shouldCellUpdate:ge,render:(t,n)=>n.sizeText?e("div",{className:rs.fileSize,children:n.sizeText}):null},{title:F("Type"),key:"type",width:90,shouldCellUpdate:ge,render:(t,n)=>e("div",{className:rs.fileSize,children:n.typeText})},...le?[{title:F("Date"),dataIndex:"dateText",key:"date",width:200,shouldCellUpdate:ge,render:(t,n)=>e(ms,{item:n})}]:[],{width:40,title:"",dataIndex:"",key:"x",onCell:()=>({style:{padding:0}}),shouldCellUpdate:ge,render:(t,n)=>e(us,{item:n,variant:"table",t:F,iconStrokeWidth:re,setCurrentMenuFile:U,showMoveModal:k,showCopyModal:S,showRenameModal:C,showDeleteConfirm:_,onEdit:A})}],[R,E,le,re,W,A,U,ge,S,_,k,C,F]);a(()=>()=>{Q.current&&clearTimeout(Q.current)},[]);const ve=d(()=>({body:{row:cs}}),[]),ye=c(e=>({onClick:t=>{const n=t.target;he(()=>{t.stopPropagation(),t.preventDefault();const r=Boolean(n.closest(".ant-image"))||Boolean(n.closest(".ant-image-preview-wrap")),i=Boolean(n.closest(".tableMenuButton")),o=Boolean(n.closest(".ant-dropdown-menu"));r||i||o||G(e.id,{metaKey:t.metaKey,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey})})},onDoubleClick:t=>{fe(()=>{t.stopPropagation(),t.preventDefault();const n=t.target;n.closest(".ant-checkbox-wrapper")||n.closest(".tableMenu")||(e.isFolder?m(e.file):n.closest(".ant-image")||n.closest(".ant-image-preview-wrap")||!L.onEditorOk||L.onEditorOk(e.file))})}}),[fe,m,he,L,G]);let be="table"===q?e(gs,{rows:ae,columns:me,loading:g,topOffset:se.topOffset,bottomOffset:se.bottomOffset,onRow:ye,components:ve}):e(ps,{rows:ae,topOffset:se.topOffset,bottomOffset:se.bottomOffset,t:F,iconStrokeWidth:re,FolderIcon:R,handleSingleClick:he,handleDoubleClick:fe,handleItemClick:m,setCurrentMenuFile:U,showMoveModal:k,showCopyModal:S,showRenameModal:C,showDeleteConfirm:_,onEdit:A,onEditorOk:L.onEditorOk,getFileData:E,showSelectionCheckbox:W});r&&!n.length&&(be=e(uo,{}));const we=null===(T=null==z?void 0:z.availableImageExtensions)||void 0===T?void 0:T.map(e=>"."+e).join(", "),xe=t("div",H?{className:`${rs.noFiles} ant-layout-sider-light`,children:[e(ki,{size:48,className:rs.noFilesIcon}),e("div",{className:`${rs.textTitle_trash} ant-menu-submenu-title`,children:F("Trash is empty")}),e("div",{className:`${rs.textDescription_trash} ant-menu-submenu-title`,children:F("Deleted files will be displayed here")})]}:{className:rs.uploadContainer,children:[t("div",{className:`${rs.uploadArea} `,onClick:I,children:[e("div",{className:rs.uploadIcon,children:e(O,{})}),e("div",{className:rs.textTitle,children:F("Click here to select a file")}),e("div",{className:rs.textDescription,children:F("Supported files:")+" "+(we||"jpeg, .svg, .png")})]}),t("div",{className:rs.buttons,children:[t("button",{className:rs.btnPhoto,onClick:()=>{V&&V(an)},children:[e("div",{className:rs.icon,children:e(P,{})}),t("div",{className:rs.blockText,children:[e("div",{className:rs.textTitle,children:F("Stock")}),e("div",{className:rs.textDescription,children:F("Select an image from our library")})]})]}),t("button",{className:rs.btnAi,onClick:()=>{V&&V(ln)},children:[e("div",{className:rs.icon,children:e(M,{})}),t("div",{className:rs.blockText,children:[e("div",{className:rs.textTitle,children:F("AI generation")}),e("div",{className:rs.textDescription,children:F("Creating an image on demand")})]})]})]})]});return e("div",{className:`content-layout ${rs.contentLayout}`,children:g||0!==(null==n?void 0:n.length)||r?t("div",{className:rs.tableContainer,children:[e(as,{files:n,filesById:oe,currentSortOption:ie,isSmallScreen:Z,iconStrokeWidth:re,multiSelectEnabled:W,features:ne,viewMode:q,setViewMode:Y,handleSearch:i,handleSortOptionChange:h,onClearSelection:v,onRename:y,onDelete:b,onCopy:w,onMove:x,onEdit:A,t:F}),e("div",{ref:te,className:rs.filesContainer,children:be}),!B&&f.total>f.pageSize&&e("div",{className:rs.paginationContainer,children:e($,{current:f.current,pageSize:f.pageSize,total:f.total,onChange:(e,t)=>p({current:e,pageSize:t,total:f.total}),showSizeChanger:!0,showTotal:e=>F("total pages",{total:e})})})]}):e("div",{className:rs.emptyStateWrapper,children:xe})})});Ps.displayName="FileContent";var Ms="folderTree",Rs="emptyFolderContainer",Ls="folderItemContainer",Ns="folderLabel",Ds="folderLabelItem",js="fileCount",zs="foldersTitle",Bs="foldersTitleItem",Us="folderMenu";const Vs=({selectedFolder:n,onSelect:r,onExpand:i,generateMenuItems:s,fetchChildFolders:l,disabledFolders:u=[],showFileCounts:h=!1,folderFileCounts:f={},className:p="",expandedKeys:g,setExpandedKeys:m,showTrashFolder:v=!1,mode:y="navigation",defaultExpandAll:b=!1})=>{const{t:w}=Qn(),{options:x}=ro(),{config:C}=x,{ExpandArrowIcon:_,CollapseArrowIcon:S,CollapseFolderIcon:k,ExpandFolderIcon:A,EmptyFolderIcon:E}=oo(),I=c(e=>{const t=[],n=e=>{e.forEach(e=>{t.push(e.key),e.children&&n(e.children)})};return n(e),t},[]),[T,F]=o(()=>{if(b||"selection"===y&&b){const e=s();return I(e)}return[]}),O=void 0!==g?g:T,P=void 0!==m?m:F;a(()=>{if(b||"selection"===y&&b){const e=s(),t=I(e);void 0===g&&F(t)}},[b,y,s,I,g]);const M=c(async e=>{const t=e[0];t&&"empty"!==t&&!t.endsWith("_input")&&(null==r||r(e),await(null==l?void 0:l("folders"===t?null:t)))},[r,l]),R=c(async(e,t)=>{var n;P(e),null==i||i(e,t);if(!("lazy"===(null==C?void 0:C.folderTreeLoading)))return;const r=(null===(n=null==t?void 0:t.node)||void 0===n?void 0:n.key)||void 0;if(r&&"folders"!==r)try{await(null==l?void 0:l(r))}catch(e){console.warn("Failed to load child folders for",r,e)}},[null==C?void 0:C.folderTreeLoading,l,i,P]),L=c(()=>{var r,i;const o=s(),a=e=>e.filter(e=>"Trash"!==e.key).map(e=>Object.assign(Object.assign({},e),{children:e.children?a(e.children):void 0})),l=v?a(o):o,c=e=>{"selection"!==y?(O.includes(e)&&n===e?P(O.filter(t=>t!==e)):O.includes(e)||P([...O,e]),M([e])):M([e])},d=0===l.length||1===l.length&&(!l[0].children||0===l[0].children.length),p=n=>{var r;const i=h&&f[n.key]||0,o=O.includes(n.key),a=u.includes(n.key),s=(()=>{var t;return(null===(t=n.children)||void 0===t?void 0:t.length)?e(o?k:A,{size:20,strokeWidth:null==C?void 0:C.iconStrokeWidth}):e(E,{size:20,strokeWidth:null==C?void 0:C.iconStrokeWidth})})(),l=t("div",{className:`${Ls} folder-item-container`,onClick:()=>!a&&c(n.key),style:{opacity:a?.5:1,cursor:a?"not-allowed":"pointer"},children:[t("div",{className:Ns,children:[void 0!==n.icon?n.icon:s,e("span",{className:Ds,children:n.label})]}),h&&e("div",{className:js,title:`${i} ${1===i?"file":"files"}`,children:i})]});return{key:n.key,title:l,children:null===(r=n.children)||void 0===r?void 0:r.map(p),disabled:a}},g=O.includes("folders"),m=e("div",{className:zs,onClick:()=>c("folders"),children:t("div",{className:Bs,children:[e(g?k:A,{size:20,strokeWidth:null==C?void 0:C.iconStrokeWidth}),e("span",{className:`${Ds} folder-label-item`,children:"folders"===(null===(r=l[0])||void 0===r?void 0:r.key)?l[0].label:w("Folders")})]})}),b=()=>({key:"Trash",title:e("div",{className:zs,onClick:()=>c("Trash"),children:t("div",{className:Bs,children:[e(Si,{size:20,strokeWidth:null==C?void 0:C.iconStrokeWidth}),e("span",{className:Ds,children:w("Trash")})]})}),children:void 0});if(d){if(!v)return[{key:"empty",title:e("div",{className:Rs,children:w("No folders yet")}),disabled:!0}];const t=[];return l.length>0&&"folders"===l[0].key&&t.push({key:"folders",title:m,children:[]}),t.push(b()),t}if(l.length>0&&"folders"===l[0].key){const e=[{key:"folders",title:m,children:null===(i=l[0].children)||void 0===i?void 0:i.map(p)}];return v&&e.push(b()),e}return l.map(p)},[s,O,k,null==C?void 0:C.iconStrokeWidth,A,w,n,M,h,f,E,u,v,y,P]),N=d(()=>L(),[L]);return e(G,{className:`${Ms} ${Us} ${p}`,selectedKeys:n?[n]:[],expandedKeys:O,onSelect:M,onExpand:R,treeData:N,switcherIcon:({expanded:t})=>e(t?S:_,{}),showLine:!1})},Hs=({style:t={},wrap:n=!1})=>{const r=Object.assign({width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},t);return e(L,{size:"large",style:r,wrap:n,children:e(k,{})})};var Ws={formFooter:"formFooter",folderButton:"folderButton",foldersWrapper:"foldersWrapper",formItem:"formItem",folderToolsField:"folderToolsField",inputButtonOk:"inputButtonOk",permanentDeleteWarning:"permanentDeleteWarning",clearTrashProgress:"clearTrashProgress",progressText:"progressText",closeIcon:"closeIcon",modalContentWithLoader:"modalContentWithLoader",modalLoaderOverlay:"modalLoaderOverlay"};const $s=({folderId:r,activeFormField:i,EmptyFolderIcon:o,targetForm:a,handleModalOk:s,onComplete:l,setIsLoading:c,t:u})=>e(T.Item,{className:"form-item form-item-moveto "+(i===r?"form-item_active":""),name:"folderName",initialValue:u("New folder"),rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(u("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{className:"form-input",autoFocus:!0,prefix:e(o,{style:{marginRight:6}}),suffix:t(n,{children:[e(M,{placement:"top",title:"Clean",children:e(R,{icon:e(we,{style:{fontSize:10}}),className:Ws.inputButtonClose,type:"text",onClick:()=>{a.setFieldsValue({folderName:""})}})}),e(R,{className:Ws.inputButtonOk,type:"text",onClick:()=>{c(!0),s(a).then(e=>{const t=null==e?void 0:e.id;l(t)}).finally(()=>c(!1))},children:u("Create")})]})})});function Gs({folders:r,selectedFolder:o,EmptyFolderIcon:a,handleCreateFolderModalOk:s,setIsLoading:l,t:c}){const[u,d]=i.useState(""),h=i.useCallback((t,n)=>r=>e($s,{folderId:r,activeFormField:u,EmptyFolderIcon:a,targetForm:t,handleModalOk:s,onComplete:n,setIsLoading:l,t:c},r),[a,u,s,l,c]),f=i.useCallback(e=>{const{folderId:t,targetForm:n,onTreeSelect:r,onComplete:i}=e;return{handleAddFolder:e=>{e.preventDefault(),e.stopPropagation(),d(t),n.setFieldsValue({folderName:c("New folder"),targetFolder:t})},handleSelectFolder:e=>{e.preventDefault(),e.stopPropagation(),r([t]).then(()=>i(t))}}},[c]),p=i.useCallback(i=>{const{targetForm:a,onTreeSelect:s,onComplete:l,actionButtonText:d}=i,p=h(a,l),g=Array.isArray(r)?r:[],m=(r=null,i=new Set)=>g.filter(e=>{const t=null===r&&!e.parentId,n=e.parentId===r;return t||n}).map(r=>{if(i.has(r.id))return{key:r.id,label:`${r.name} (циклическая ссылка)`};const c=new Set(i);c.add(r.id);const h=m(r.id,c),{handleAddFolder:g,handleSelectFolder:v}=f({folderId:r.id,targetForm:a,onTreeSelect:s,onComplete:l}),y=u===r.id?[{key:`${r.id}_input`,label:p(r.id),icon:null},...h]:h;return{key:r.id,label:t(n,{children:[r.name,o!==r.id&&t("div",{className:`${Ws.folderToolsField} folder-tools-field`,children:[e(R,{onClick:g,children:"+"}),e(R,{onClick:v,children:d})]})]}),children:y}}),v=m(),{handleAddFolder:y,handleSelectFolder:b}=f({folderId:"folders",targetForm:a,onTreeSelect:s,onComplete:l}),w="folders"===u?[{key:"folders_input",label:p("folders"),icon:null},...v]:v;return[{key:"folders",label:t(n,{children:[c("Folders"),"folders"!==o&&null!==o&&t("div",{className:`${Ws.folderToolsField} folder-tools-field`,children:[e(R,{onClick:y,children:"+"}),e(R,{onClick:b,children:d})]})]}),children:w}]},[u,h,f,r,o,c]);return{activeFormField:u,setActiveFormField:d,generateMenuItemsFromFolders:p}}const qs=f(({folderId:t,activeFormField:n,EmptyFolderIcon:r,targetForm:i,handleModalOk:o,onComplete:a,t:s,setIsLoading:l,defaultFolderName:u})=>{const d=c(()=>{l(!0),o(i).then(e=>a(null==e?void 0:e.id)).finally(()=>l(!1))},[o,i,a,l]);return e(T.Item,{className:"form-item form-item-moveto "+(n===t?"form-item_active":""),name:"folderName",initialValue:u,rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(s("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{className:"form-input",autoFocus:!0,prefix:e(r,{style:{marginRight:6}}),suffix:e(R,{className:Ws.inputButtonOk,type:"text",onClick:()=>{l(!0),d()},children:s("Create")})})})});qs.displayName="CustomFolderInput";const Ys=({isModalVisible:r,handleModalOk:i,handleModalCancel:s,form:l,selectedFolder:u,folders:h,isUrlModalVisible:f,setIsUrlModalVisible:p,handleAddFileByUrl:g,urlForm:m,isRenameModalVisible:v,handleRenameOk:y,handleRenameCancel:b,renameForm:w,fileToRename:x,files:C,isMoveModalVisible:_,handleMoveOk:S,handleMoveCancel:k,moveForm:A,selectedFiles:E,isRenameFolderModalVisible:I,handleRenameFolderOk:O,handleRenameFolderCancel:P,renameFolderForm:M,folderToRename:L,isCopyModalVisible:N,handleCopyOk:D,handleCopyCancel:j,copyForm:z,isDeleteConfirmVisible:B,handleDeleteConfirmOk:U,handleDeleteConfirmCancel:V,isClearTrashConfirmVisible:H,handleClearTrashConfirm:W,handleClearTrashCancel:$,fetchChildFolders:G})=>{var X,K,Z;const{t:J}=Qn(),{state:Q,actions:ee,options:te}=ro(),{setCurrentMenuFile:ne}=ee,{config:re}=te,{currentMenuFile:ie}=Q,oe=T.useWatch("folderName",l),{EmptyFolderIcon:ae}=oo(),[se,le]=o(!1),ce=d(()=>{var e;return(null===(e=null==re?void 0:re.defaultFolderName)||void 0===e?void 0:e.trim())||J("New folder")},[null==re?void 0:re.defaultFolderName,J]),ue=!oe||0===String(oe).trim().length,de=d(()=>Array.isArray(C)?C:[],[C]),he=x?null===(X=de.find(e=>e.id===x))||void 0===X?void 0:X.name:"",fe=Array.isArray(h)?h:[],pe=L?null===(K=fe.find(e=>e.id===L))||void 0===K?void 0:K.name:"",{activeFormField:ge,setActiveFormField:me,generateMenuItemsFromFolders:ve}=Gs({folders:fe,selectedFolder:u,EmptyFolderIcon:ae,handleCreateFolderModalOk:i,setIsLoading:e=>le(Boolean(e)),t:J});a(()=>{if(B){const e=setTimeout(()=>{const e=document.querySelector(".deleteModal");if(e){const t=e.querySelector(".ant-modal-footer");if(t){const e=t.querySelector(".ant-btn-primary");e&&e.focus()}}},100);return()=>clearTimeout(e)}},[B]);const ye=x?de.find(e=>e.id===x):null,be=(null==ye?void 0:ye.isFolder)||(null==x?void 0:x.startsWith("folder_")),xe=c(async e=>{e.length>0&&(A.setFieldsValue({targetFolder:e[0]}),ge!==e[0].toString()&&me(""))},[A,ge,me]),Ce=c(async e=>{e.length>0&&(z.setFieldsValue({targetFolder:e[0]}),ge!==e[0].toString()&&me(""))},[ge,z,me]),_e=c(async e=>{le(!0);try{await S(e)}finally{le(!1)}},[S]),Se=c(async e=>{le(!0);try{await D(e)}finally{le(!1)}},[D]),ke=d(()=>{const e=Array.from(E).filter(e=>{const t=de.find(t=>t.id===e);return(null==t?void 0:t.isFolder)||h.some(t=>t.id===e)});return u&&"folders"!==u?e.push(u):u&&"folders"!==u||e.push("folders"),e},[E,de,h,u]);return t(n,{children:[e(q,{title:e("div",{className:"modal-title",children:J("Creating a new folder")}),open:r,onOk:()=>i(),onCancel:s,okText:J("Create"),cancelText:J("Cancel"),okButtonProps:{disabled:ue,loading:se},cancelButtonProps:{disabled:se},afterClose:()=>le(!1),children:t(T,{form:l,layout:"vertical",children:[e(T.Item,{name:"folderName",label:e("div",{className:"form-label",children:J("Folder name")}),rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(J("Enter the name of the folder"))):Promise.resolve()}],initialValue:ce,className:"form-item",style:{marginBottom:5},children:e(F,{autoFocus:!0,className:"form-input",disabled:se,placeholder:J("Enter the name"),onPressEnter:async()=>{le(!0);try{await l.validateFields(),ue||await i()}catch(e){le(!1)}}})}),e("div",{children:u&&"folders"!==u?t("p",{className:"fm-note",children:[J("A folder will be created inside:")," ",(null===(Z=fe.find(e=>e.id===u))||void 0===Z?void 0:Z.name)||J("selected folder"),"."]}):e("p",{className:"fm-note",children:J("The folder will be created in the root directory.")})})]})}),e(q,{title:e("div",{className:"modal-title",children:J("Upload file by URL")}),open:f,onOk:async()=>{var e;le(!0);try{const t=await m.validateFields(),n=String(null!==(e=t.fileUrl)&&void 0!==e?e:"").trim();await g(n,void 0,void 0,"uploadByUrl")}catch(e){}finally{le(!1)}},onCancel:()=>p(!1),okText:J("Download"),okButtonProps:{loading:se},cancelText:J("Cancel"),cancelButtonProps:{disabled:se},afterClose:()=>le(!1),children:e(T,{form:m,layout:"vertical",children:e(T.Item,{name:"fileUrl",label:e("div",{className:"form-label",children:J("File URL")}),rules:[{required:!0,message:J("Enter the URL of the image")},{validator:(e,t)=>{if(!t||!String(t).trim())return Promise.resolve();try{return Yo(String(t),J),Promise.resolve()}catch(e){return Promise.reject(new Error(e instanceof Error?e.message:J("The specified URL is not valid.")))}}}],validateTrigger:"onBlur",className:"form-item",children:e(F,{className:"form-input",placeholder:"https://example.com/image.jpg",autoFocus:!0,disabled:se,onPressEnter:async()=>{var e;le(!0);try{const t=await m.validateFields(),n=String(null!==(e=t.fileUrl)&&void 0!==e?e:"").trim();await g(n,void 0,void 0,"uploadByUrl")}catch(e){}finally{le(!1)}}})})})}),e(q,{title:e("div",{className:"modal-title",children:be?`${J("Rename folder")} ${he}`:J("Rename file",{currentFileName:he})}),open:v,onOk:y,okText:J("Rename"),okButtonProps:{loading:se},onCancel:b,cancelText:J("Cancel"),cancelButtonProps:{disabled:se},afterClose:()=>{le(!1),ne&&ne("")},children:e(T,{form:w,layout:"vertical",children:e(T.Item,{name:"newFileName",label:e("div",{className:"form-label",children:J(be?"New folder name":"New file name")}),rules:[{required:!0,message:J(be?"Enter a new folder name":"Enter a new file name")}],className:"form-item",children:e(F,{autoFocus:!0,className:"form-input",disabled:se,onPressEnter:async()=>{le(!0);try{await w.validateFields(),y()}catch(e){le(!1)}}})})})}),e(q,{title:e("div",{className:"modal-title",children:J("Move to")}),open:_,onCancel:k,footer:t("div",{className:Ws.formFooter,children:[t(R,{className:Ws.folderButton,onClick:()=>{const e=null!=u?u:"folders";me(e),A.setFieldsValue({folderName:ce,targetFolder:e})},loading:se,children:[e(ui,{size:18,strokeWidth:null==re?void 0:re.iconStrokeWidth}),J("Create folder")]}),e(R,{type:"primary",className:Ws.folderButton,onClick:k,loading:se,children:J("Done")})]}),afterClose:()=>{ne&&ne(""),me(""),le(!1)},loading:se,children:t("div",{className:Ws.modalContentWithLoader,children:[se&&e("div",{className:Ws.modalLoaderOverlay,children:e(Hs,{})}),e(T,{form:A,layout:"vertical",initialValues:{targetFolder:"folders",folderName:ce,is_force_create:!1},children:t("div",{className:Ws.foldersWrapper,children:[e(T.Item,{name:"targetFolder",rules:[{required:!0,message:J("Select the destination folder")}],className:Ws.formItem,children:e(Vs,{onSelect:xe,generateMenuItems:()=>ve({targetForm:A,onTreeSelect:xe,onComplete:_e,actionButtonText:J("Move here")}),fetchChildFolders:G,disabledFolders:ke,mode:"selection",className:"folderSelectionTree",defaultExpandAll:!0})}),e(T.Item,{name:"folderName",style:{display:"none"},rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(J("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{})}),e(T.Item,{name:"is_force_create",style:{display:"none"},children:e(F,{})})]})})]})}),e(q,{title:e("div",{className:"modal-title",children:J("Copy to folder")}),open:N,onCancel:j,footer:t("div",{className:Ws.formFooter,children:[t(R,{className:Ws.folderButton,onClick:()=>{const e=null!=u?u:"folders";me(e),z.setFieldsValue({folderName:ce,targetFolder:e})},loading:se,children:[e(ui,{size:18,strokeWidth:null==re?void 0:re.iconStrokeWidth}),J("Create folder")]}),e(R,{type:"primary",className:Ws.folderButton,onClick:j,loading:se,children:J("Done")})]}),afterClose:()=>{ne&&ne(""),me(""),le(!1)},loading:se,children:t("div",{className:Ws.modalContentWithLoader,children:[se&&e("div",{className:Ws.modalLoaderOverlay,children:e(Hs,{})}),e(T,{form:z,layout:"vertical",initialValues:{targetFolder:"folders",folderName:ce,is_force_create:!1},children:t("div",{className:Ws.foldersWrapper,children:[e(T.Item,{name:"targetFolder",rules:[{required:!0,message:J("Select the destination folder")}],className:Ws.formItem,children:e(Vs,{onSelect:Ce,generateMenuItems:()=>ve({targetForm:z,onTreeSelect:Ce,onComplete:Se,actionButtonText:J("Copy here")}),fetchChildFolders:G,disabledFolders:ke,mode:"selection",className:"folderSelectionTree",defaultExpandAll:!0})}),e(T.Item,{name:"folderName",style:{display:"none"},rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(J("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{})}),e(T.Item,{name:"is_force_create",style:{display:"none"},children:e(F,{})})]})})]})}),e(q,{title:t("div",{className:"modal-title",children:[J("Rename folder")," ",pe]}),open:I,onOk:O,onCancel:P,okText:J("Rename"),cancelText:J("Cancel"),okButtonProps:{loading:se},cancelButtonProps:{disabled:se},afterClose:()=>{le(!1),ne&&ne("")},children:e(T,{form:M,layout:"vertical",children:e(T.Item,{name:"newFolderName",label:e("div",{className:"form-label",children:J("New folder name")}),rules:[{required:!0,message:J("Enter a new folder name")}],className:"form-item",children:e(F,{autoFocus:!0,className:"form-input",disabled:se,onPressEnter:async()=>{le(!0);try{await M.validateFields(),O()}catch(e){le(!1)}}})})})}),e(q,{className:`${Ws.deleteModal} deleteModal`,title:(()=>{const t=!!(null==re?void 0:re.enableTrashFolder)&&"Trash"===u||!(null==re?void 0:re.enableTrashFolder),n=J(t?"Permanently delete":"Move to Trash");return e("div",{className:"modal-title",children:n})})(),open:!!B,onOk:()=>{le(!0);try{U&&U()}catch(e){console.error(e),le(!1)}},onCancel:()=>V&&V(),okText:(null==re?void 0:re.enableTrashFolder)&&"Trash"===u?J("Delete permanently"):(null==re?void 0:re.enableTrashFolder)?J("Move to Trash"):J("Delete"),cancelText:J("Cancel"),okButtonProps:{danger:!(null==re?void 0:re.enableTrashFolder)||"Trash"===u,loading:se},cancelButtonProps:{disabled:se},afterClose:()=>{le(!1),ne&&ne("")},closeIcon:e(we,{className:Ws.closeIcon}),children:(()=>{var n,r;const i=(ie?[ie]:Array.from(E||[])).map(e=>de.find(t=>t.id===e)).filter(e=>!!e),o=i.filter(e=>e.isFolder||e.id.startsWith("folder_")),a=i.filter(e=>!(e.isFolder||e.id.startsWith("folder_"))),s=i.length,l=o.length,c=a.length,d=!!(null==re?void 0:re.enableTrashFolder);if(!d||d&&"Trash"===u){let r;if(1===s&&1===l){const e=o[0],t=(null==e?void 0:e.name)||"",i=null!==(n=null==e?void 0:e.childCount)&&void 0!==n?n:0;r=J("delete_folder_permanent",{name:t,count:i})}else r=0===l&&c>0?J("delete_files_permanent",{count:c}):J("delete_mixed_permanent",{total:s,folders:l,images:c});return t("div",{children:[e("div",{children:r}),e("p",{className:Ws.permanentDeleteWarning,children:J("permanent_delete_warning")})]})}if(1===s&&1===l){const t=o[0],n=(null==t?void 0:t.name)||"",i=null!==(r=null==t?void 0:t.childCount)&&void 0!==r?r:0;return e("div",{children:J("move_folder_to_trash",{name:n,count:i})})}return e("div",0===l&&c>0?{children:J("move_files_to_trash",{count:c})}:{children:J("move_mixed_to_trash",{total:s,folders:l,images:c})})})()}),t(q,{className:`${Ws.deleteModal} deleteModal`,title:e("div",{className:"modal-title",children:J("Clear Trash")}),open:!!H,onOk:async()=>{le(!0),W&&await W(),le(!1)},onCancel:()=>$&&$(),okText:J("Delete permanently"),cancelText:J("Cancel"),okButtonProps:{danger:!0,loading:se},cancelButtonProps:{disabled:se},afterClose:()=>{le(!1)},closeIcon:e(we,{className:Ws.closeIcon}),children:[e("div",{children:J("Are you sure you want to permanently delete all items from Trash?")}),se&&t("div",{className:Ws.clearTrashProgress,children:[e(Y,{percent:99,status:"active",showInfo:!1}),e("div",{className:Ws.progressText,children:J("Deleting items...")})]})]})]})};var Xs={button:"button",folderActions:"folderActions",uploadButton:"uploadButton",foldersContainer:"foldersContainer",buttonWrapper:"buttonWrapper",uploadButtonTitle:"uploadButtonTitle"};const Ks=f(p(({selectedFolder:n,generateMenuItems:r,onFolderSelect:i,folders:s,fetchChildFolders:l,handleAddFile:h,setIsUrlModalVisible:f,handleCreateFolder:p,activeLibraryItem:m,setActiveLibraryItem:v},y)=>{var b,w,x;const C=d(()=>Array.isArray(s)?s:[],[s]),{t:_}=Qn(),S=bo(),[k,A]=o({}),{options:E}=ro(),{dataProviders:I,config:T}=E,F=!1!==(null===(b=null==T?void 0:T.features)||void 0===b?void 0:b.enableGif)&&(!(null==T?void 0:T.enabledTabs)||T.enabledTabs.includes("gif")),O=!1!==(null===(w=null==T?void 0:T.features)||void 0===w?void 0:w.enableStockImages)&&(!(null==T?void 0:T.enabledTabs)||T.enabledTabs.includes("stock")),P=!1!==(null===(x=null==T?void 0:T.features)||void 0===x?void 0:x.enableIconStock)&&(!(null==T?void 0:T.enabledTabs)||T.enabledTabs.includes("icons")),M=c(e=>{const t=[],n=e=>{e.forEach(e=>{t.push(e.key),e.children&&n(e.children)})};return n(e),t},[]),[L,N]=o(()=>{if(!0===(null==T?void 0:T.expandAllFoldersOnInit)&&"lazy"!==(null==T?void 0:T.folderTreeLoading)){const e=r();return M(e)}return!0===(null==T?void 0:T.expandRootFolderOnInit)?["folders"]:[]}),D=u(!1),j=u(!1);a(()=>{if(D.current)return;"lazy"===(null==T?void 0:T.folderTreeLoading)&&!0===(null==T?void 0:T.expandRootFolderOnInit)&&(D.current=!0,(async()=>{try{await(null==l?void 0:l(null))}catch(e){console.warn("Could not load the root child folders during initialization",e)}})())},[null==T?void 0:T.folderTreeLoading,null==T?void 0:T.expandRootFolderOnInit,l]),a(()=>{!0===(null==T?void 0:T.expandRootFolderOnInit)&&Array.isArray(C)&&C.length>0&&(j.current||L&&0!==L.length||(j.current=!0,N(["folders"])))},[null==T?void 0:T.expandRootFolderOnInit,C,L]),a(()=>{if(!0===(null==T?void 0:T.expandAllFoldersOnInit)&&"lazy"!==(null==T?void 0:T.folderTreeLoading)){const e=r(),t=M(e);return void N(t)}!0===(null==T?void 0:T.expandRootFolderOnInit)&&N(e=>e&&e.length>0?[...e]:["folders"])},[C,r,M,null==T?void 0:T.expandAllFoldersOnInit,null==T?void 0:T.folderTreeLoading,null==T?void 0:T.expandRootFolderOnInit]);const z=null==T?void 0:T.disablePagination,B=c(async e=>{var t,n,r,i;try{if(null==I?void 0:I.getChildrenCount)return await I.getChildrenCount("folders"===e?void 0:e);if(null==I?void 0:I.getFiles){const{files:n,pagination:r}=await I.getFiles({folderId:"folders"===e?void 0:e,itemType:"all",page:z?void 0:1,limit:z?void 0:1});return z?Array.isArray(n)?n.length:0:null!==(t=null==r?void 0:r.total)&&void 0!==t?t:Array.isArray(n)?n.length:0}return 0}catch(t){if("StaleLoad"===(null==t?void 0:t.name))return 0;const o=t;return 404===(null==o?void 0:o.status)||"FileNotFound"===(null==o?void 0:o.code)||"path_folder_not_found"===(null==o?void 0:o.code)||"path_folder_not_found"===(null===(n=null==o?void 0:o.data)||void 0===n?void 0:n.code)||404===(null===(i=null===(r=null==o?void 0:o.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.status)||(console.error(`Error getting the number of files for the folder ${e}:`,t),S.error({id:"FOLDER_CHILDREN_COUNT_FAILED",message:_("Failed to load folder items count"),placement:"bottomRight",innerException:t,data:{folderId:"folders"===e?null:e,reason:t instanceof Error?t.message:String(t)}})),0}},[I,S,_,z]),U=c(async()=>{if(0===C.length)return;const e={};e.folders=await B("folders");const t=C.map(async t=>{"number"!=typeof t.childCount?e[t.id]=await B(t.id):e[t.id]=t.childCount});await Promise.all(t),A(e)},[C,B]),V=c(async e=>{const t=await B(e);A(n=>Object.assign(Object.assign({},n),{[e]:t}))},[B]);g(y,()=>({refreshFileCounts:U}),[U]),a(()=>{U()},[U]),a(()=>{if(!n||"folders"===n)return;const e=(t,n=new Set)=>{if(n.has(t))return console.warn(`Cycle detected in the path to the folder with id=${t}`),[];const r=C.find(e=>e.id===t);if(!r)return[];if(!r.parentId)return[];const i=new Set(n);i.add(t);return[...e(r.parentId,i),r.parentId]},t=e(n);t.length>0?N(e=>{const n=new Set(e);return t.forEach(e=>n.add(e)),n.add("folders"),Array.from(n)}):N(e=>e.includes("folders")?e:[...e,"folders"])},[n,C]);const H=c(async()=>{await h(),n?await V(n):await V("folders")},[h,n,V]),W=[{key:rn,label:_("My files"),icon:e(fi,{size:20,strokeWidth:null==T?void 0:T.iconStrokeWidth})},{key:on,label:_("GIF"),icon:e(mi,{size:20,strokeWidth:null==T?void 0:T.iconStrokeWidth}),disabled:!F},{key:an,label:_("Stock images"),icon:e(ii,{size:20,strokeWidth:null==T?void 0:T.iconStrokeWidth}),disabled:!O},{key:sn,label:_("Icons"),icon:e(xe,{size:20}),disabled:!P},{key:ln,label:_("AI"),icon:e(xi,{size:20,strokeWidth:null==T?void 0:T.iconStrokeWidth}),disabled:!(null==T?void 0:T.sseQuery)}].filter(e=>!e.disabled),$=c(async e=>{const t=e[0];t&&"empty"!==t&&(m!==rn&&v(rn),null==i||i(t),await(null==l?void 0:l(t)))},[i,m,v,l]),G=c(({key:e})=>{v(e)},[v]),q=c(async(e,t)=>{var n;N(e);if(!("lazy"===(null==T?void 0:T.folderTreeLoading)))return;const r=(null===(n=null==t?void 0:t.node)||void 0===n?void 0:n.key)||void 0;if(r&&"folders"!==r)try{await(null==l?void 0:l(r))}catch(e){console.warn("Could not load the child folders for",r,e),S.error({id:"FOLDER_CHILDREN_FETCH_FAILED",message:_("Failed to load subfolders"),placement:"bottomRight",innerException:e,data:{folderId:r,reason:e instanceof Error?e.message:String(e)}})}},[null==T?void 0:T.folderTreeLoading,l,S,_]);return t("div",{className:"sidebar-container",children:[t("div",{className:Xs.buttonWrapper,children:[e(R,{type:"primary",size:"large",icon:e(vi,{size:24,strokeWidth:null==T?void 0:T.iconStrokeWidth}),onClick:H,className:Xs.uploadButton,style:{whiteSpace:"nowrap"},disabled:"Trash"===n,children:e("span",{className:Xs.uploadButtonTitle,children:_("Upload file")})}),e(R,{type:"primary",size:"large",icon:e(pi,{size:24,strokeWidth:null==T?void 0:T.iconStrokeWidth}),onClick:()=>null==f?void 0:f(!0),className:Xs.uploadByURLButton,style:{whiteSpace:"nowrap"},disabled:"Trash"===n})]}),e(X,{className:"folder-menu",items:W,defaultSelectedKeys:[rn],onSelect:({key:e})=>G({key:e}),selectedKeys:[m]}),e(K,{className:Xs.divider}),t("div",{className:Xs.foldersContainer,children:[e(Vs,{selectedFolder:n,onSelect:$,onExpand:q,generateMenuItems:r,fetchChildFolders:l,showFileCounts:!0,folderFileCounts:k,expandedKeys:L,setExpandedKeys:N,showTrashFolder:null==T?void 0:T.enableTrashFolder}),e("div",{className:Xs.folderActions,children:e(R,{onClick:e=>{e.stopPropagation(),p()},className:Xs.button,icon:e(ui,{size:18,strokeWidth:null==T?void 0:T.iconStrokeWidth}),size:"middle"})})]})]})}));Ks.displayName="FolderSidebar";var Zs=Object.defineProperty,Js=(e,t,n)=>(((e,t,n)=>{t in e?Zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);function Qs(e,t){return void 0===t&&(t=15),+parseFloat(Number(e).toPrecision(t))}function el(e){var t=e.toString().split(/[eE]/),n=(t[0].split(".")[1]||"").length-+(t[1]||0);return n>0?n:0}function tl(e){if(-1===e.toString().indexOf("e"))return Number(e.toString().replace(".",""));var t=el(e);return t>0?Qs(Number(e)*Math.pow(10,t)):Number(e)}function nl(e){ll&&(e>Number.MAX_SAFE_INTEGER||e<Number.MIN_SAFE_INTEGER)&&console.warn(e+" is beyond boundary when transfer to integer, the results may not be accurate")}function rl(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t[0];return t.slice(1).reduce(function(t,n){return e(t,n)},r)}}var il=rl(function(e,t){var n=tl(e),r=tl(t),i=el(e)+el(t),o=n*r;return nl(o),o/Math.pow(10,i)}),ol=rl(function(e,t){var n=Math.pow(10,Math.max(el(e),el(t)));return(il(e,n)+il(t,n))/n}),al=rl(function(e,t){var n=Math.pow(10,Math.max(el(e),el(t)));return(il(e,n)-il(t,n))/n}),sl=rl(function(e,t){var n=tl(e),r=tl(t);return nl(n),nl(r),il(n/r,Qs(Math.pow(10,el(t)-el(e))))});var ll=!0;var cl={strip:Qs,plus:ol,minus:al,times:il,divide:sl,round:function(e,t){var n=Math.pow(10,t),r=sl(Math.round(Math.abs(il(e,n))),n);return e<0&&0!==r&&(r=il(r,-1)),r},digitLength:el,float2Fixed:tl,enableBoundaryChecking:function(e){void 0===e&&(e=!0),ll=e}};const ul=Object.prototype.toString;function dl(e){switch(ul.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return xl(e,Error)}}function hl(e,t){return ul.call(e)===`[object ${t}]`}function fl(e){return hl(e,"ErrorEvent")}function pl(e){return hl(e,"DOMError")}function gl(e){return hl(e,"String")}function ml(e){return"object"==typeof e&&null!==e&&"__sentry_template_string__"in e&&"__sentry_template_values__"in e}function vl(e){return null===e||ml(e)||"object"!=typeof e&&"function"!=typeof e}function yl(e){return hl(e,"Object")}function bl(e){return typeof Event<"u"&&xl(e,Event)}function wl(e){return!(!e||!e.then||"function"!=typeof e.then)}function xl(e,t){try{return e instanceof t}catch{return!1}}function Cl(e){return!("object"!=typeof e||null===e||!e.__isVue&&!e._isVue)}function _l(e,t=0){return"string"!=typeof e||0===t||e.length<=t?e:`${e.slice(0,t)}...`}function Sl(e,t){if(!Array.isArray(e))return"";const n=[];for(let t=0;t<e.length;t++){const r=e[t];try{Cl(r)?n.push("[VueViewModel]"):n.push(String(r))}catch{n.push("[value cannot be serialized]")}}return n.join(t)}function kl(e,t,n=!1){return!!gl(e)&&(function(e){return hl(e,"RegExp")}(t)?t.test(e):!!gl(t)&&(n?e===t:e.includes(t)))}function Al(e,t=[],n=!1){return t.some(t=>kl(e,t,n))}function El(e,t,n=250,r,i,o,a){if(!(o.exception&&o.exception.values&&a&&xl(a.originalException,Error)))return;const s=o.exception.values.length>0?o.exception.values[o.exception.values.length-1]:void 0;s&&(o.exception.values=function(e,t){return e.map(e=>(e.value&&(e.value=_l(e.value,t)),e))}(Il(e,t,i,a.originalException,r,o.exception.values,s,0),n))}function Il(e,t,n,r,i,o,a,s){if(o.length>=n+1)return o;let l=[...o];if(xl(r[i],Error)){Tl(a,s);const o=e(t,r[i]),c=l.length;Fl(o,i,c,s),l=Il(e,t,n,r[i],i,[o,...l],o,c)}return Array.isArray(r.errors)&&r.errors.forEach((r,o)=>{if(xl(r,Error)){Tl(a,s);const c=e(t,r),u=l.length;Fl(c,`errors[${o}]`,u,s),l=Il(e,t,n,r,i,[c,...l],c,u)}}),l}function Tl(e,t){e.mechanism=e.mechanism||{type:"generic",handled:!0},e.mechanism={...e.mechanism,..."AggregateError"===e.type&&{is_exception_group:!0},exception_id:t}}function Fl(e,t,n,r){e.mechanism=e.mechanism||{type:"generic",handled:!0},e.mechanism={...e.mechanism,type:"chained",source:t,exception_id:n,parent_id:r}}function Ol(e){return e&&e.Math==Math?e:void 0}const Pl="object"==typeof globalThis&&Ol(globalThis)||"object"==typeof window&&Ol(window)||"object"==typeof self&&Ol(self)||"object"==typeof global&&Ol(global)||function(){return this}()||{};function Ml(){return Pl}function Rl(e,t,n){const r=n||Pl,i=r.__SENTRY__=r.__SENTRY__||{};return i[e]||(i[e]=t())}const Ll=Ml();function Nl(e,t={}){if(!e)return"<unknown>";try{let n=e;const r=5,i=[];let o=0,a=0;const s=" > ",l=s.length;let c;const u=Array.isArray(t)?t:t.keyAttrs,d=!Array.isArray(t)&&t.maxStringLength||80;for(;n&&o++<r&&(c=Dl(n,u),!("html"===c||o>1&&a+i.length*l+c.length>=d));)i.push(c),a+=c.length,n=n.parentNode;return i.reverse().join(s)}catch{return"<unknown>"}}function Dl(e,t){const n=e,r=[];let i,o,a,s,l;if(!n||!n.tagName)return"";if(Ll.HTMLElement&&n instanceof HTMLElement&&n.dataset&&n.dataset.sentryComponent)return n.dataset.sentryComponent;r.push(n.tagName.toLowerCase());const c=t&&t.length?t.filter(e=>n.getAttribute(e)).map(e=>[e,n.getAttribute(e)]):null;if(c&&c.length)c.forEach(e=>{r.push(`[${e[0]}="${e[1]}"]`)});else if(n.id&&r.push(`#${n.id}`),i=n.className,i&&gl(i))for(o=i.split(/\s+/),l=0;l<o.length;l++)r.push(`.${o[l]}`);const u=["aria-label","type","name","title","alt"];for(l=0;l<u.length;l++)a=u[l],s=n.getAttribute(a),s&&r.push(`[${a}="${s}"]`);return r.join("")}const jl=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,zl=["debug","info","warn","error","log","assert","trace"],Bl={};function Ul(e){if(!("console"in Pl))return e();const t=Pl.console,n={},r=Object.keys(Bl);r.forEach(e=>{const r=Bl[e];n[e]=t[e],t[e]=r});try{return e()}finally{r.forEach(e=>{t[e]=n[e]})}}const Vl=function(){let e=!1;const t={enable:()=>{e=!0},disable:()=>{e=!1},isEnabled:()=>e};return jl?zl.forEach(n=>{t[n]=(...t)=>{e&&Ul(()=>{Pl.console[n](`Sentry Logger [${n}]:`,...t)})}}):zl.forEach(e=>{t[e]=()=>{}}),t}(),Hl=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;function Wl(e,t=!1){const{host:n,path:r,pass:i,port:o,projectId:a,protocol:s,publicKey:l}=e;return`${s}://${l}${t&&i?`:${i}`:""}@${n}${o?`:${o}`:""}/${r&&`${r}/`}${a}`}function $l(e){return{protocol:e.protocol,publicKey:e.publicKey||"",pass:e.pass||"",host:e.host,port:e.port||"",path:e.path||"",projectId:e.projectId}}function Gl(e){const t="string"==typeof e?function(e){const t=Hl.exec(e);if(!t)return void Ul(()=>{console.error(`Invalid Sentry Dsn: ${e}`)});const[n,r,i="",o,a="",s]=t.slice(1);let l="",c=s;const u=c.split("/");if(u.length>1&&(l=u.slice(0,-1).join("/"),c=u.pop()),c){const e=c.match(/^\d+/);e&&(c=e[0])}return $l({host:o,pass:i,path:l,projectId:c,port:a,protocol:n,publicKey:r})}(e):$l(e);if(t&&function(e){if(!jl)return!0;const{port:t,projectId:n,protocol:r}=e;return!(["protocol","publicKey","host","projectId"].find(t=>!e[t]&&(Vl.error(`Invalid Sentry Dsn: ${t} missing`),!0))||(n.match(/^\d+$/)?function(e){return"http"===e||"https"===e}(r)?t&&isNaN(parseInt(t,10))&&(Vl.error(`Invalid Sentry Dsn: Invalid port ${t}`),1):(Vl.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),1):(Vl.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),1)))}(t))return t}class ql extends Error{constructor(e,t="warn"){super(e),this.message=e,this.name=new.target.prototype.constructor.name,Object.setPrototypeOf(this,new.target.prototype),this.logLevel=t}}function Yl(e,t,n){if(!(t in e))return;const r=e[t],i=n(r);"function"==typeof i&&Kl(i,r),e[t]=i}function Xl(e,t,n){try{Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0})}catch{jl&&Vl.log(`Failed to add non-enumerable property "${t}" to object`,e)}}function Kl(e,t){try{const n=t.prototype||{};e.prototype=t.prototype=n,Xl(e,"__sentry_original__",t)}catch{}}function Zl(e){return e.__sentry_original__}function Jl(e){if(dl(e))return{message:e.message,name:e.name,stack:e.stack,...ec(e)};if(bl(e)){const t={type:e.type,target:Ql(e.target),currentTarget:Ql(e.currentTarget),...ec(e)};return typeof CustomEvent<"u"&&xl(e,CustomEvent)&&(t.detail=e.detail),t}return e}function Ql(e){try{return function(e){return typeof Element<"u"&&xl(e,Element)}(e)?Nl(e):Object.prototype.toString.call(e)}catch{return"<unknown>"}}function ec(e){if("object"==typeof e&&null!==e){const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}return{}}function tc(e){return nc(e,new Map)}function nc(e,t){if(function(e){if(!yl(e))return!1;try{const t=Object.getPrototypeOf(e).constructor.name;return!t||"Object"===t}catch{return!0}}(e)){const n=t.get(e);if(void 0!==n)return n;const r={};t.set(e,r);for(const n of Object.keys(e))typeof e[n]<"u"&&(r[n]=nc(e[n],t));return r}if(Array.isArray(e)){const n=t.get(e);if(void 0!==n)return n;const r=[];return t.set(e,r),e.forEach(e=>{r.push(nc(e,t))}),r}return e}const rc=/\(error: (.*)\)/,ic=/captureMessage|captureException/;function oc(...e){const t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,n=0)=>{const r=[],i=e.split("\n");for(let e=n;e<i.length;e++){const n=i[e];if(n.length>1024)continue;const o=rc.test(n)?n.replace(rc,"$1"):n;if(!o.match(/\S*Error: /)){for(const e of t){const t=e(o);if(t){r.push(t);break}}if(r.length>=50)break}}return function(e){if(!e.length)return[];const t=Array.from(e);return/sentryWrapped/.test(t[t.length-1].function||"")&&t.pop(),t.reverse(),ic.test(t[t.length-1].function||"")&&(t.pop(),ic.test(t[t.length-1].function||"")&&t.pop()),t.slice(0,50).map(e=>({...e,filename:e.filename||t[t.length-1].filename,function:e.function||"?"}))}(r)}}function ac(e){return Array.isArray(e)?oc(...e):e}const sc="<anonymous>";function lc(e){try{return e&&"function"==typeof e&&e.name||sc}catch{return sc}}const cc={},uc={};function dc(e,t){cc[e]=cc[e]||[],cc[e].push(t)}function hc(e,t){uc[e]||(t(),uc[e]=!0)}function fc(e,t){const n=e&&cc[e];if(n)for(const r of n)try{r(t)}catch(t){jl&&Vl.error(`Error while triggering instrumentation handler.\nType: ${e}\nName: ${lc(r)}\nError:`,t)}}function pc(){"console"in Pl&&zl.forEach(function(e){e in Pl.console&&Yl(Pl.console,e,function(t){return Bl[e]=t,function(...t){fc("console",{args:t,level:e});const n=Bl[e];n&&n.apply(Pl.console,t)}})})}function gc(){const e=Pl,t=e.crypto||e.msCrypto;let n=()=>16*Math.random();try{if(t&&t.randomUUID)return t.randomUUID().replace(/-/g,"");t&&t.getRandomValues&&(n=()=>{const e=new Uint8Array(1);return t.getRandomValues(e),e[0]})}catch{}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,e=>(e^(15&n())>>e/4).toString(16))}function mc(e){return e.exception&&e.exception.values?e.exception.values[0]:void 0}function vc(e){const{message:t,event_id:n}=e;if(t)return t;const r=mc(e);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||"<unknown>":n||"<unknown>"}function yc(e,t,n){const r=e.exception=e.exception||{},i=r.values=r.values||[],o=i[0]=i[0]||{};o.value||(o.value=t||""),o.type||(o.type="Error")}function bc(e,t){const n=mc(e);if(!n)return;const r=n.mechanism;if(n.mechanism={type:"generic",handled:!0,...r,...t},t&&"data"in t){const e={...r&&r.data,...t.data};n.mechanism.data=e}}function wc(e){if(e&&e.__sentry_captured__)return!0;try{Xl(e,"__sentry_captured__",!0)}catch{}return!1}function xc(e){return Array.isArray(e)?e:[e]}const Cc=Pl;let _c,Sc,kc;function Ac(){if(!Cc.document)return;const e=fc.bind(null,"dom"),t=Ec(e,!0);Cc.document.addEventListener("click",t,!1),Cc.document.addEventListener("keypress",t,!1),["EventTarget","Node"].forEach(t=>{const n=Cc[t]&&Cc[t].prototype;!n||!n.hasOwnProperty||!n.hasOwnProperty("addEventListener")||(Yl(n,"addEventListener",function(t){return function(n,r,i){if("click"===n||"keypress"==n)try{const r=this,o=r.__sentry_instrumentation_handlers__=r.__sentry_instrumentation_handlers__||{},a=o[n]=o[n]||{refCount:0};if(!a.handler){const r=Ec(e);a.handler=r,t.call(this,n,r,i)}a.refCount++}catch{}return t.call(this,n,r,i)}}),Yl(n,"removeEventListener",function(e){return function(t,n,r){if("click"===t||"keypress"==t)try{const n=this,i=n.__sentry_instrumentation_handlers__||{},o=i[t];o&&(o.refCount--,o.refCount<=0&&(e.call(this,t,o.handler,r),o.handler=void 0,delete i[t]),0===Object.keys(i).length&&delete n.__sentry_instrumentation_handlers__)}catch{}return e.call(this,t,n,r)}}))})}function Ec(e,t=!1){return n=>{if(!n||n._sentryCaptured)return;const r=function(e){try{return e.target}catch{return null}}(n);if(function(e,t){return!("keypress"!==e||t&&t.tagName&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))}(n.type,r))return;Xl(n,"_sentryCaptured",!0),r&&!r._sentryId&&Xl(r,"_sentryId",gc());const i="keypress"===n.type?"input":n.type;(function(e){if(e.type!==Sc)return!1;try{if(!e.target||e.target._sentryId!==kc)return!1}catch{}return!0})(n)||(e({event:n,name:i,global:t}),Sc=n.type,kc=r?r._sentryId:void 0),clearTimeout(_c),_c=Cc.setTimeout(()=>{kc=void 0,Sc=void 0},1e3)}}const Ic=Ml();function Tc(){if(!("fetch"in Ic))return!1;try{return new Headers,new Request("http://www.example.com"),new Response,!0}catch{return!1}}function Fc(e){return e&&/^function fetch\(\)\s+\{\s+\[native code\]\s+\}$/.test(e.toString())}function Oc(){(function(){if("string"==typeof EdgeRuntime)return!0;if(!Tc())return!1;if(Fc(Ic.fetch))return!0;let e=!1;const t=Ic.document;if(t&&"function"==typeof t.createElement)try{const n=t.createElement("iframe");n.hidden=!0,t.head.appendChild(n),n.contentWindow&&n.contentWindow.fetch&&(e=Fc(n.contentWindow.fetch)),t.head.removeChild(n)}catch(e){jl&&Vl.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",e)}return e})()&&Yl(Pl,"fetch",function(e){return function(...t){const{method:n,url:r}=function(e){if(0===e.length)return{method:"GET",url:""};if(2===e.length){const[t,n]=e;return{url:Mc(t),method:Pc(n,"method")?String(n.method).toUpperCase():"GET"}}const t=e[0];return{url:Mc(t),method:Pc(t,"method")?String(t.method).toUpperCase():"GET"}}(t),i={args:t,fetchData:{method:n,url:r},startTimestamp:Date.now()};return fc("fetch",{...i}),e.apply(Pl,t).then(e=>(fc("fetch",{...i,endTimestamp:Date.now(),response:e}),e),e=>{throw fc("fetch",{...i,endTimestamp:Date.now(),error:e}),e})}})}function Pc(e,t){return!!e&&"object"==typeof e&&!!e[t]}function Mc(e){return"string"==typeof e?e:e?Pc(e,"url")?e.url:e.toString?e.toString():"":""}let Rc=null;function Lc(){Rc=Pl.onerror,Pl.onerror=function(e,t,n,r,i){return fc("error",{column:r,error:i,line:n,msg:e,url:t}),!(!Rc||Rc.__SENTRY_LOADER__)&&Rc.apply(this,arguments)},Pl.onerror.__SENTRY_INSTRUMENTED__=!0}let Nc=null;function Dc(){Nc=Pl.onunhandledrejection,Pl.onunhandledrejection=function(e){return fc("unhandledrejection",e),!(Nc&&!Nc.__SENTRY_LOADER__)||Nc.apply(this,arguments)},Pl.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}const jc=Ml();const zc=Pl;let Bc;function Uc(e){const t="history";dc(t,e),hc(t,Vc)}function Vc(){if(!function(){const e=jc.chrome,t=e&&e.app&&e.app.runtime,n="history"in jc&&!!jc.history.pushState&&!!jc.history.replaceState;return!t&&n}())return;const e=zc.onpopstate;function t(e){return function(...t){const n=t.length>2?t[2]:void 0;if(n){const e=Bc,t=String(n);Bc=t,fc("history",{from:e,to:t})}return e.apply(this,t)}}zc.onpopstate=function(...t){const n=zc.location.href,r=Bc;if(Bc=n,fc("history",{from:r,to:n}),e)try{return e.apply(this,t)}catch{}},Yl(zc.history,"pushState",t),Yl(zc.history,"replaceState",t)}const Hc=Pl,Wc="__sentry_xhr_v3__";function $c(){if(!Hc.XMLHttpRequest)return;const e=XMLHttpRequest.prototype;Yl(e,"open",function(e){return function(...t){const n=Date.now(),r=gl(t[0])?t[0].toUpperCase():void 0,i=function(e){if(gl(e))return e;try{return e.toString()}catch{}}(t[1]);if(!r||!i)return e.apply(this,t);this[Wc]={method:r,url:i,request_headers:{}},"POST"===r&&i.match(/sentry_key/)&&(this.__sentry_own_request__=!0);const o=()=>{const e=this[Wc];if(e&&4===this.readyState){try{e.status_code=this.status}catch{}fc("xhr",{args:[r,i],endTimestamp:Date.now(),startTimestamp:n,xhr:this})}};return"onreadystatechange"in this&&"function"==typeof this.onreadystatechange?Yl(this,"onreadystatechange",function(e){return function(...t){return o(),e.apply(this,t)}}):this.addEventListener("readystatechange",o),Yl(this,"setRequestHeader",function(e){return function(...t){const[n,r]=t,i=this[Wc];return i&&gl(n)&&gl(r)&&(i.request_headers[n.toLowerCase()]=r),e.apply(this,t)}}),e.apply(this,t)}}),Yl(e,"send",function(e){return function(...t){const n=this[Wc];if(!n)return e.apply(this,t);void 0!==t[0]&&(n.body=t[0]);return fc("xhr",{args:[n.method,n.url],startTimestamp:Date.now(),xhr:this}),e.apply(this,t)}})}function Gc(e,t=100,n=1/0){try{return Yc("",e,t,n)}catch(e){return{ERROR:`**non-serializable** (${e})`}}}function qc(e,t=3,n=102400){const r=Gc(e,t);return function(e){return function(e){return~-encodeURI(e).split(/%..|./).length}(JSON.stringify(e))}(r)>n?qc(e,t-1,n):r}function Yc(e,t,n=1/0,r=1/0,i=function(){const e="function"==typeof WeakSet,t=e?new WeakSet:[];return[function(n){if(e)return!!t.has(n)||(t.add(n),!1);for(let e=0;e<t.length;e++)if(t[e]===n)return!0;return t.push(n),!1},function(n){if(e)t.delete(n);else for(let e=0;e<t.length;e++)if(t[e]===n){t.splice(e,1);break}}]}()){const[o,a]=i;if(null==t||["number","boolean","string"].includes(typeof t)&&!function(e){return"number"==typeof e&&e!=e}(t))return t;const s=function(e,t){try{if("domain"===e&&t&&"object"==typeof t&&t._events)return"[Domain]";if("domainEmitter"===e)return"[DomainEmitter]";if(typeof global<"u"&&t===global)return"[Global]";if(typeof window<"u"&&t===window)return"[Window]";if(typeof document<"u"&&t===document)return"[Document]";if(Cl(t))return"[VueViewModel]";if(function(e){return yl(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e}(t))return"[SyntheticEvent]";if("number"==typeof t&&t!=t)return"[NaN]";if("function"==typeof t)return`[Function: ${lc(t)}]`;if("symbol"==typeof t)return`[${String(t)}]`;if("bigint"==typeof t)return`[BigInt: ${String(t)}]`;const n=function(e){const t=Object.getPrototypeOf(e);return t?t.constructor.name:"null prototype"}(t);return/^HTML(\w*)Element$/.test(n)?`[HTMLElement: ${n}]`:`[object ${n}]`}catch(e){return`**non-serializable** (${e})`}}(e,t);if(!s.startsWith("[object "))return s;if(t.__sentry_skip_normalization__)return t;const l="number"==typeof t.__sentry_override_normalization_depth__?t.__sentry_override_normalization_depth__:n;if(0===l)return s.replace("object ","");if(o(t))return"[Circular ~]";const c=t;if(c&&"function"==typeof c.toJSON)try{return Yc("",c.toJSON(),l-1,r,i)}catch{}const u=Array.isArray(t)?[]:{};let d=0;const h=Jl(t);for(const e in h){if(!Object.prototype.hasOwnProperty.call(h,e))continue;if(d>=r){u[e]="[MaxProperties ~]";break}const t=h[e];u[e]=Yc(e,t,l-1,r,i),d++}return a(t),u}var Xc;function Kc(e){return new Jc(t=>{t(e)})}function Zc(e){return new Jc((t,n)=>{n(e)})}!function(e){e[e.PENDING=0]="PENDING";e[e.RESOLVED=1]="RESOLVED";e[e.REJECTED=2]="REJECTED"}(Xc||(Xc={}));class Jc{constructor(e){Jc.prototype.__init.call(this),Jc.prototype.__init2.call(this),Jc.prototype.__init3.call(this),Jc.prototype.__init4.call(this),this._state=Xc.PENDING,this._handlers=[];try{e(this._resolve,this._reject)}catch(e){this._reject(e)}}then(e,t){return new Jc((n,r)=>{this._handlers.push([!1,t=>{if(e)try{n(e(t))}catch(e){r(e)}else n(t)},e=>{if(t)try{n(t(e))}catch(e){r(e)}else r(e)}]),this._executeHandlers()})}catch(e){return this.then(e=>e,e)}finally(e){return new Jc((t,n)=>{let r,i;return this.then(t=>{i=!1,r=t,e&&e()},t=>{i=!0,r=t,e&&e()}).then(()=>{i?n(r):t(r)})})}__init(){this._resolve=e=>{this._setResult(Xc.RESOLVED,e)}}__init2(){this._reject=e=>{this._setResult(Xc.REJECTED,e)}}__init3(){this._setResult=(e,t)=>{if(this._state===Xc.PENDING){if(wl(t))return void t.then(this._resolve,this._reject);this._state=e,this._value=t,this._executeHandlers()}}}__init4(){this._executeHandlers=()=>{if(this._state===Xc.PENDING)return;const e=this._handlers.slice();this._handlers=[],e.forEach(e=>{e[0]||(this._state===Xc.RESOLVED&&e[1](this._value),this._state===Xc.REJECTED&&e[2](this._value),e[0]=!0)})}}}function Qc(e){const t=[];function n(e){return t.splice(t.indexOf(e),1)[0]}return{$:t,add:function(r){if(!(void 0===e||t.length<e))return Zc(new ql("Not adding Promise because buffer limit was reached."));const i=r();return-1===t.indexOf(i)&&t.push(i),i.then(()=>n(i)).then(null,()=>n(i).then(null,()=>{})),i},drain:function(e){return new Jc((n,r)=>{let i=t.length;if(!i)return n(!0);const o=setTimeout(()=>{e&&e>0&&n(!1)},e);t.forEach(e=>{Kc(e).then(()=>{--i||(clearTimeout(o),n(!0))},r)})})}}}function eu(e){if(!e)return{};const t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};const n=t[6]||"",r=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],search:n,hash:r,relative:t[5]+n+r}}const tu=["fatal","error","warning","log","info","debug"];function nu(e){return"warn"===e?"warning":tu.includes(e)?e:"log"}function ru(){return Date.now()/1e3}const iu=function(){const{performance:e}=Pl;if(!e||!e.now)return ru;const t=Date.now()-e.now(),n=null==e.timeOrigin?t:e.timeOrigin;return()=>(n+e.now())/1e3}();function ou(e,t=[]){return[e,t]}function au(e,t){const[n,r]=e;return[n,[...r,t]]}function su(e,t){const n=e[1];for(const e of n){if(t(e,e[0].type))return!0}return!1}function lu(e,t){return(t||new TextEncoder).encode(e)}function cu(e,t){const[n,r]=e;let i=JSON.stringify(n);function o(e){"string"==typeof i?i="string"==typeof e?i+e:[lu(i,t),e]:i.push("string"==typeof e?lu(e,t):e)}for(const e of r){const[t,n]=e;if(o(`\n${JSON.stringify(t)}\n`),"string"==typeof n||n instanceof Uint8Array)o(n);else{let e;try{e=JSON.stringify(n)}catch{e=JSON.stringify(Gc(n))}o(e)}}return"string"==typeof i?i:function(e){const t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t);let r=0;for(const t of e)n.set(t,r),r+=t.length;return n}(i)}function uu(e,t){const n="string"==typeof e.data?lu(e.data,t):e.data;return[tc({type:"attachment",length:n.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType}),n]}(()=>{const{performance:e}=Pl;if(!e||!e.now)return;const t=36e5,n=e.now(),r=Date.now(),i=e.timeOrigin?Math.abs(e.timeOrigin+n-r):t,o=i<t,a=e.timing&&e.timing.navigationStart,s="number"==typeof a?Math.abs(a+n-r):t;(o||s<t)&&(i<=s&&e.timeOrigin)})();const du={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",feedback:"feedback",span:"span",statsd:"metric_bucket"};function hu(e){return du[e]}function fu(e){if(!e||!e.sdk)return;const{name:t,version:n}=e.sdk;return{name:t,version:n}}function pu(e,{statusCode:t,headers:n},r=Date.now()){const i={...e},o=n&&n["x-sentry-rate-limits"],a=n&&n["retry-after"];if(o)for(const e of o.trim().split(",")){const[t,n,,,o]=e.split(":",5),a=parseInt(t,10),s=1e3*(isNaN(a)?60:a);if(n)for(const e of n.split(";"))"metric_bucket"===e?(!o||o.split(";").includes("custom"))&&(i[e]=r+s):i[e]=r+s;else i.all=r+s}else a?i.all=r+function(e,t=Date.now()){const n=parseInt(`${e}`,10);if(!isNaN(n))return 1e3*n;const r=Date.parse(`${e}`);return isNaN(r)?6e4:r-t}(a,r):429===t&&(i.all=r+6e4);return i}const gu=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,mu="production";function vu(){return Rl("globalEventProcessors",()=>[])}function yu(e){vu().push(e)}function bu(e,t,n,r=0){return new Jc((i,o)=>{const a=e[r];if(null===t||"function"!=typeof a)i(t);else{const s=a({...t},n);gu&&a.id&&null===s&&Vl.log(`Event processor "${a.id}" dropped event`),wl(s)?s.then(t=>bu(e,t,n,r+1).then(i)).then(null,o):bu(e,s,n,r+1).then(i).then(null,o)}})}function wu(e){const t=iu(),n={sid:gc(),init:!0,timestamp:t,started:t,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(e){return tc({sid:`${e.sid}`,init:e.init,started:new Date(1e3*e.started).toISOString(),timestamp:new Date(1e3*e.timestamp).toISOString(),status:e.status,errors:e.errors,did:"number"==typeof e.did||"string"==typeof e.did?`${e.did}`:void 0,duration:e.duration,abnormal_mechanism:e.abnormal_mechanism,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}})}(n)};return e&&xu(n,e),n}function xu(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),!e.did&&!t.did&&(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||iu(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=32===t.sid.length?t.sid:gc()),void 0!==t.init&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),"number"==typeof t.started&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if("number"==typeof t.duration)e.duration=t.duration;else{const t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),"number"==typeof t.errors&&(e.errors=t.errors),t.status&&(e.status=t.status)}function Cu(e,t){let n={};"ok"===e.status&&(n={status:"exited"}),xu(e,n)}function _u(e){const{spanId:t,traceId:n}=e.spanContext(),{data:r,op:i,parent_span_id:o,status:a,tags:s,origin:l}=Su(e);return tc({data:r,op:i,parent_span_id:o,span_id:t,status:a,tags:s,trace_id:n,origin:l})}function Su(e){return function(e){return"function"==typeof e.getSpanJSON}(e)?e.getSpanJSON():"function"==typeof e.toJSON?e.toJSON():{}}function ku(e,t,n,r,i,o){const{normalizeDepth:a=3,normalizeMaxBreadth:s=1e3}=e,l={...t,event_id:t.event_id||n.event_id||gc(),timestamp:t.timestamp||ru()},c=n.integrations||e.integrations.map(e=>e.name);(function(e,t){const{environment:n,release:r,dist:i,maxValueLength:o=250}=t;"environment"in e||(e.environment="environment"in t?n:mu),void 0===e.release&&void 0!==r&&(e.release=r),void 0===e.dist&&void 0!==i&&(e.dist=i),e.message&&(e.message=_l(e.message,o));const a=e.exception&&e.exception.values&&e.exception.values[0];a&&a.value&&(a.value=_l(a.value,o));const s=e.request;s&&s.url&&(s.url=_l(s.url,o))})(l,e),function(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}(l,c),void 0===t.type&&function(e,t){const n=Pl._sentryDebugIds;if(!n)return;let r;const i=Au.get(t);i?r=i:(r=new Map,Au.set(t,r));const o=Object.keys(n).reduce((e,i)=>{let o;const a=r.get(i);a?o=a:(o=t(i),r.set(i,o));for(let t=o.length-1;t>=0;t--){const r=o[t];if(r.filename){e[r.filename]=n[i];break}}return e},{});try{e.exception.values.forEach(e=>{e.stacktrace.frames.forEach(e=>{e.filename&&(e.debug_id=o[e.filename])})})}catch{}}(l,e.stackParser);const u=function(e,t){if(!t)return e;const n=e?e.clone():new Vu;return n.update(t),n}(r,n.captureContext);n.mechanism&&bc(l,n.mechanism);const d=i&&i.getEventProcessors?i.getEventProcessors():[],h=(Uu||(Uu=new Vu),Uu).getScopeData();if(o){zu(h,o.getScopeData())}if(u){zu(h,u.getScopeData())}const f=[...n.attachments||[],...h.attachments];f.length&&(n.attachments=f),ju(l,h);return bu([...d,...vu(),...h.eventProcessors],l,n).then(e=>(e&&function(e){const t={};try{e.exception.values.forEach(e=>{e.stacktrace.frames.forEach(e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)})})}catch{}if(0===Object.keys(t).length)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];const n=e.debug_meta.images;Object.keys(t).forEach(e=>{n.push({type:"sourcemap",code_file:e,debug_id:t[e]})})}(e),"number"==typeof a&&a>0?function(e,t,n){if(!e)return null;const r={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map(e=>({...e,...e.data&&{data:Gc(e.data,t,n)}}))},...e.user&&{user:Gc(e.user,t,n)},...e.contexts&&{contexts:Gc(e.contexts,t,n)},...e.extra&&{extra:Gc(e.extra,t,n)}};return e.contexts&&e.contexts.trace&&r.contexts&&(r.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(r.contexts.trace.data=Gc(e.contexts.trace.data,t,n))),e.spans&&(r.spans=e.spans.map(e=>{const r=Su(e).data;return r&&(e.data=Gc(r,t,n)),e})),r}(e,a,s):e))}const Au=new WeakMap;function Eu(e,t){return Ku().captureEvent(e,t)}function Iu(e,t){Ku().addBreadcrumb(e,t)}function Tu(){return Ku().getClient()}function Fu(){return Ku().getScope()}function Ou(e){const t=Tu(),n=Zu(),r=Fu(),{release:i,environment:o=mu}=t&&t.getOptions()||{},{userAgent:a}=Pl.navigator||{},s=wu({release:i,environment:o,user:r.getUser()||n.getUser(),...a&&{userAgent:a},...e}),l=n.getSession();return l&&"ok"===l.status&&xu(l,{status:"exited"}),Pu(),n.setSession(s),r.setSession(s),s}function Pu(){const e=Zu(),t=Fu(),n=t.getSession()||e.getSession();n&&Cu(n),Mu(),e.setSession(),t.setSession()}function Mu(){const e=Zu(),t=Fu(),n=Tu(),r=t.getSession()||e.getSession();r&&n&&n.captureSession&&n.captureSession(r)}function Ru(e=!1){e?Pu():Mu()}function Lu(e){return e.transaction}function Nu(e,t,n){const r=t.getOptions(),{publicKey:i}=t.getDsn()||{},{segment:o}=n&&n.getUser()||{},a=tc({environment:r.environment||mu,release:r.release,user_segment:o,public_key:i,trace_id:e});return t.emit&&t.emit("createDsc",a),a}function Du(e){const t=Tu();if(!t)return{};const n=Nu(Su(e).trace_id||"",t,Fu()),r=Lu(e);if(!r)return n;const i=r&&r._frozenDynamicSamplingContext;if(i)return i;const{sampleRate:o,source:a}=r.metadata;null!=o&&(n.sample_rate=`${o}`);const s=Su(r);return a&&"url"!==a&&(n.transaction=s.description),n.sampled=String(function(e){const{traceFlags:t}=e.spanContext();return!!(1&t)}(r)),t.emit&&t.emit("createDsc",n),n}function ju(e,t){const{fingerprint:n,span:r,breadcrumbs:i,sdkProcessingMetadata:o}=t;(function(e,t){const{extra:n,tags:r,user:i,contexts:o,level:a,transactionName:s}=t,l=tc(n);l&&Object.keys(l).length&&(e.extra={...l,...e.extra});const c=tc(r);c&&Object.keys(c).length&&(e.tags={...c,...e.tags});const u=tc(i);u&&Object.keys(u).length&&(e.user={...u,...e.user});const d=tc(o);d&&Object.keys(d).length&&(e.contexts={...d,...e.contexts}),a&&(e.level=a),s&&(e.transaction=s)})(e,t),r&&function(e,t){e.contexts={trace:_u(t),...e.contexts};const n=Lu(t);if(n){e.sdkProcessingMetadata={dynamicSamplingContext:Du(t),...e.sdkProcessingMetadata};const r=Su(n).description;r&&(e.tags={transaction:r,...e.tags})}}(e,r),function(e,t){e.fingerprint=e.fingerprint?xc(e.fingerprint):[],t&&(e.fingerprint=e.fingerprint.concat(t)),e.fingerprint&&!e.fingerprint.length&&delete e.fingerprint}(e,n),function(e,t){const n=[...e.breadcrumbs||[],...t];e.breadcrumbs=n.length?n:void 0}(e,i),function(e,t){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t}}(e,o)}function zu(e,t){const{extra:n,tags:r,user:i,contexts:o,level:a,sdkProcessingMetadata:s,breadcrumbs:l,fingerprint:c,eventProcessors:u,attachments:d,propagationContext:h,transactionName:f,span:p}=t;Bu(e,"extra",n),Bu(e,"tags",r),Bu(e,"user",i),Bu(e,"contexts",o),Bu(e,"sdkProcessingMetadata",s),a&&(e.level=a),f&&(e.transactionName=f),p&&(e.span=p),l.length&&(e.breadcrumbs=[...e.breadcrumbs,...l]),c.length&&(e.fingerprint=[...e.fingerprint,...c]),u.length&&(e.eventProcessors=[...e.eventProcessors,...u]),d.length&&(e.attachments=[...e.attachments,...d]),e.propagationContext={...e.propagationContext,...h}}function Bu(e,t,n){if(n&&Object.keys(n).length){e[t]={...e[t]};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[t][r]=n[r])}}let Uu;class Vu{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext=Hu()}static clone(e){return e?e.clone():new Vu}clone(){const e=new Vu;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._extra={...this._extra},e._contexts={...this._contexts},e._user=this._user,e._level=this._level,e._span=this._span,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._requestSession=this._requestSession,e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e}setClient(e){this._client=e}getClient(){return this._client}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,segment:void 0,username:void 0},this._session&&xu(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(e){return this._requestSession=e,this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this._tags={...this._tags,[e]:t},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return null===t?delete this._contexts[e]:this._contexts[e]=t,this._notifyScopeListeners(),this}setSpan(e){return this._span=e,this._notifyScopeListeners(),this}getSpan(){return this._span}getTransaction(){const e=this._span;return e&&e.transaction}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;const t="function"==typeof e?e(this):e;if(t instanceof Vu){const e=t.getScopeData();this._tags={...this._tags,...e.tags},this._extra={...this._extra,...e.extra},this._contexts={...this._contexts,...e.contexts},e.user&&Object.keys(e.user).length&&(this._user=e.user),e.level&&(this._level=e.level),e.fingerprint.length&&(this._fingerprint=e.fingerprint),t.getRequestSession()&&(this._requestSession=t.getRequestSession()),e.propagationContext&&(this._propagationContext=e.propagationContext)}else if(yl(t)){const t=e;this._tags={...this._tags,...t.tags},this._extra={...this._extra,...t.extra},this._contexts={...this._contexts,...t.contexts},t.user&&(this._user=t.user),t.level&&(this._level=t.level),t.fingerprint&&(this._fingerprint=t.fingerprint),t.requestSession&&(this._requestSession=t.requestSession),t.propagationContext&&(this._propagationContext=t.propagationContext)}return this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this._attachments=[],this._propagationContext=Hu(),this}addBreadcrumb(e,t){const n="number"==typeof t?t:100;if(n<=0)return this;const r={timestamp:ru(),...e},i=this._breadcrumbs;return i.push(r),this._breadcrumbs=i.length>n?i.slice(-n):i,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}getAttachments(){return this.getScopeData().attachments}clearAttachments(){return this._attachments=[],this}getScopeData(){const{_breadcrumbs:e,_attachments:t,_contexts:n,_tags:r,_extra:i,_user:o,_level:a,_fingerprint:s,_eventProcessors:l,_propagationContext:c,_sdkProcessingMetadata:u,_transactionName:d,_span:h}=this;return{breadcrumbs:e,attachments:t,contexts:n,tags:r,extra:i,user:o,level:a,fingerprint:s||[],eventProcessors:l,propagationContext:c,sdkProcessingMetadata:u,transactionName:d,span:h}}applyToEvent(e,t={},n=[]){ju(e,this.getScopeData());return bu([...n,...vu(),...this._eventProcessors],e,t)}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata={...this._sdkProcessingMetadata,...e},this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,t){const n=t&&t.event_id?t.event_id:gc();if(!this._client)return Vl.warn("No client configured on scope - will not capture exception!"),n;const r=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:r,...t,event_id:n},this),n}captureMessage(e,t,n){const r=n&&n.event_id?n.event_id:gc();if(!this._client)return Vl.warn("No client configured on scope - will not capture message!"),r;const i=new Error(e);return this._client.captureMessage(e,t,{originalException:e,syntheticException:i,...n,event_id:r},this),r}captureEvent(e,t){const n=t&&t.event_id?t.event_id:gc();return this._client?(this._client.captureEvent(e,{...t,event_id:n},this),n):(Vl.warn("No client configured on scope - will not capture event!"),n)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}}function Hu(){return{traceId:gc(),spanId:gc().substring(16)}}const Wu="7.116.0",$u=parseFloat(Wu),Gu=100;class qu{constructor(e,t,n,r=$u){let i,o;this._version=r,t?i=t:(i=new Vu,i.setClient(e)),n?o=n:(o=new Vu,o.setClient(e)),this._stack=[{scope:i}],e&&this.bindClient(e),this._isolationScope=o}isOlderThan(e){return this._version<e}bindClient(e){const t=this.getStackTop();t.client=e,t.scope.setClient(e),e&&e.setupIntegrations&&e.setupIntegrations()}pushScope(){const e=this.getScope().clone();return this.getStack().push({client:this.getClient(),scope:e}),e}popScope(){return!(this.getStack().length<=1)&&!!this.getStack().pop()}withScope(e){const t=this.pushScope();let n;try{n=e(t)}catch(e){throw this.popScope(),e}return wl(n)?n.then(e=>(this.popScope(),e),e=>{throw this.popScope(),e}):(this.popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStack(){return this._stack}getStackTop(){return this._stack[this._stack.length-1]}captureException(e,t){const n=this._lastEventId=t&&t.event_id?t.event_id:gc(),r=new Error("Sentry syntheticException");return this.getScope().captureException(e,{originalException:e,syntheticException:r,...t,event_id:n}),n}captureMessage(e,t,n){const r=this._lastEventId=n&&n.event_id?n.event_id:gc(),i=new Error(e);return this.getScope().captureMessage(e,t,{originalException:e,syntheticException:i,...n,event_id:r}),r}captureEvent(e,t){const n=t&&t.event_id?t.event_id:gc();return e.type||(this._lastEventId=n),this.getScope().captureEvent(e,{...t,event_id:n}),n}lastEventId(){return this._lastEventId}addBreadcrumb(e,t){const{scope:n,client:r}=this.getStackTop();if(!r)return;const{beforeBreadcrumb:i=null,maxBreadcrumbs:o=Gu}=r.getOptions&&r.getOptions()||{};if(o<=0)return;const a={timestamp:ru(),...e},s=i?Ul(()=>i(a,t)):a;null!==s&&(r.emit&&r.emit("beforeAddBreadcrumb",s,t),n.addBreadcrumb(s,o))}setUser(e){this.getScope().setUser(e),this.getIsolationScope().setUser(e)}setTags(e){this.getScope().setTags(e),this.getIsolationScope().setTags(e)}setExtras(e){this.getScope().setExtras(e),this.getIsolationScope().setExtras(e)}setTag(e,t){this.getScope().setTag(e,t),this.getIsolationScope().setTag(e,t)}setExtra(e,t){this.getScope().setExtra(e,t),this.getIsolationScope().setExtra(e,t)}setContext(e,t){this.getScope().setContext(e,t),this.getIsolationScope().setContext(e,t)}configureScope(e){const{scope:t,client:n}=this.getStackTop();n&&e(t)}run(e){const t=Xu(this);try{e(this)}finally{Xu(t)}}getIntegration(e){const t=this.getClient();if(!t)return null;try{return t.getIntegration(e)}catch{return gu&&Vl.warn(`Cannot retrieve integration ${e.id} from the current Hub`),null}}startTransaction(e,t){const n=this._callExtensionMethod("startTransaction",e,t);return gu&&!n&&(this.getClient()?Vl.warn("Tracing extension 'startTransaction' has not been added. Call 'addTracingExtensions' before calling 'init':\nSentry.addTracingExtensions();\nSentry.init({...});\n"):Vl.warn("Tracing extension 'startTransaction' is missing. You should 'init' the SDK before calling 'startTransaction'")),n}traceHeaders(){return this._callExtensionMethod("traceHeaders")}captureSession(e=!1){if(e)return this.endSession();this._sendSessionUpdate()}endSession(){const e=this.getStackTop().scope,t=e.getSession();t&&Cu(t),this._sendSessionUpdate(),e.setSession()}startSession(e){const{scope:t,client:n}=this.getStackTop(),{release:r,environment:i=mu}=n&&n.getOptions()||{},{userAgent:o}=Pl.navigator||{},a=wu({release:r,environment:i,user:t.getUser(),...o&&{userAgent:o},...e}),s=t.getSession&&t.getSession();return s&&"ok"===s.status&&xu(s,{status:"exited"}),this.endSession(),t.setSession(a),a}shouldSendDefaultPii(){const e=this.getClient(),t=e&&e.getOptions();return!(!t||!t.sendDefaultPii)}_sendSessionUpdate(){const{scope:e,client:t}=this.getStackTop(),n=e.getSession();n&&t&&t.captureSession&&t.captureSession(n)}_callExtensionMethod(e,...t){const n=Yu().__SENTRY__;if(n&&n.extensions&&"function"==typeof n.extensions[e])return n.extensions[e].apply(this,t);gu&&Vl.warn(`Extension method ${e} couldn't be found, doing nothing.`)}}function Yu(){return Pl.__SENTRY__=Pl.__SENTRY__||{extensions:{},hub:void 0},Pl}function Xu(e){const t=Yu(),n=Ju(t);return Qu(t,e),n}function Ku(){const e=Yu();if(e.__SENTRY__&&e.__SENTRY__.acs){const t=e.__SENTRY__.acs.getCurrentHub();if(t)return t}return function(e=Yu()){return(!function(e){return!!(e&&e.__SENTRY__&&e.__SENTRY__.hub)}(e)||Ju(e).isOlderThan($u))&&Qu(e,new qu),Ju(e)}(e)}function Zu(){return Ku().getIsolationScope()}function Ju(e){return Rl("hub",()=>new qu,e)}function Qu(e,t){if(!e)return!1;return(e.__SENTRY__=e.__SENTRY__||{}).hub=t,!0}function ed(e,t,n,r){const i=fu(n),o=e.type&&"replay_event"!==e.type?e.type:"event";!function(e,t){t&&(e.sdk=e.sdk||{},e.sdk.name=e.sdk.name||t.name,e.sdk.version=e.sdk.version||t.version,e.sdk.integrations=[...e.sdk.integrations||[],...t.integrations||[]],e.sdk.packages=[...e.sdk.packages||[],...t.packages||[]])}(e,n&&n.sdk);const a=function(e,t,n,r){const i=e.sdkProcessingMetadata&&e.sdkProcessingMetadata.dynamicSamplingContext;return{event_id:e.event_id,sent_at:(new Date).toISOString(),...t&&{sdk:t},...!!n&&r&&{dsn:Wl(r)},...i&&{trace:tc({...i})}}}(e,i,r,t);return delete e.sdkProcessingMetadata,ou(a,[[{type:o},e]])}function td(e,t){return function(e){return Object.keys(e).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join("&")}({sentry_key:e.publicKey,sentry_version:"7",...t&&{sentry_client:`${t.name}/${t.version}`}})}const nd=[];function rd(e){const t=e.defaultIntegrations||[],n=e.integrations;let r;t.forEach(e=>{e.isDefaultInstance=!0}),r=Array.isArray(n)?[...t,...n]:"function"==typeof n?xc(n(t)):t;const i=function(e){const t={};return e.forEach(e=>{const{name:n}=e,r=t[n];r&&!r.isDefaultInstance&&e.isDefaultInstance||(t[n]=e)}),Object.keys(t).map(e=>t[e])}(r),o=function(e,t){for(let n=0;n<e.length;n++)if(!0===t(e[n]))return n;return-1}(i,e=>"Debug"===e.name);if(-1!==o){const[e]=i.splice(o,1);i.push(e)}return i}function id(e,t){for(const n of t)n&&n.afterAllSetup&&n.afterAllSetup(e)}function od(e,t,n){if(n[t.name])gu&&Vl.log(`Integration skipped because it was already installed: ${t.name}`);else{if(n[t.name]=t,-1===nd.indexOf(t.name)&&(t.setupOnce(yu,Ku),nd.push(t.name)),t.setup&&"function"==typeof t.setup&&t.setup(e),e.on&&"function"==typeof t.preprocessEvent){const n=t.preprocessEvent.bind(t);e.on("preprocessEvent",(t,r)=>n(t,r,e))}if(e.addEventProcessor&&"function"==typeof t.processEvent){const n=t.processEvent.bind(t),r=Object.assign((t,r)=>n(t,r,e),{id:t.name});e.addEventProcessor(r)}gu&&Vl.log(`Integration installed: ${t.name}`)}}function ad(e,t){return Object.assign(function(...e){return t(...e)},{id:e})}function sd(e,t,n,r){const i={sent_at:(new Date).toISOString()};n&&n.sdk&&(i.sdk={name:n.sdk.name,version:n.sdk.version}),r&&t&&(i.dsn=Wl(t));const o=function(e){const t=function(e){let t="";for(const n of e){const e=Object.entries(n.tags),r=e.length>0?`|#${e.map(([e,t])=>`${e}:${t}`).join(",")}`:"";t+=`${n.name}@${n.unit}:${n.metric}|${n.metricType}${r}|T${n.timestamp}\n`}return t}(e);return[{type:"statsd",length:t.length},t]}(e);return ou(i,[o])}const ld="Not capturing exception because it's already been captured.";class cd{constructor(e){if(this._options=e,this._integrations={},this._integrationsInitialized=!1,this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],e.dsn?this._dsn=Gl(e.dsn):gu&&Vl.warn("No DSN provided, client will not send events."),this._dsn){const t=function(e,t={}){const n="string"==typeof t?t:t.tunnel,r="string"!=typeof t&&t._metadata?t._metadata.sdk:void 0;return n||`${function(e){return`${function(e){const t=e.protocol?`${e.protocol}:`:"",n=e.port?`:${e.port}`:"";return`${t}//${e.host}${n}${e.path?`/${e.path}`:""}/api/`}(e)}${e.projectId}/envelope/`}(e)}?${td(e,r)}`}(this._dsn,e);this._transport=e.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:t})}}captureException(e,t,n){if(wc(e))return void(gu&&Vl.log(ld));let r=t&&t.event_id;return this._process(this.eventFromException(e,t).then(e=>this._captureEvent(e,t,n)).then(e=>{r=e})),r}captureMessage(e,t,n,r){let i=n&&n.event_id;const o=ml(e)?e:String(e),a=vl(e)?this.eventFromMessage(o,t,n):this.eventFromException(e,n);return this._process(a.then(e=>this._captureEvent(e,n,r)).then(e=>{i=e})),i}captureEvent(e,t,n){if(t&&t.originalException&&wc(t.originalException))return void(gu&&Vl.log(ld));let r=t&&t.event_id;const i=(e.sdkProcessingMetadata||{}).capturedSpanScope;return this._process(this._captureEvent(e,t,i||n).then(e=>{r=e})),r}captureSession(e){"string"!=typeof e.release?gu&&Vl.warn("Discarded session because of missing or non-string release"):(this.sendSession(e),xu(e,{init:!1}))}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(e){const t=this._transport;return t?(this.metricsAggregator&&this.metricsAggregator.flush(),this._isClientDoneProcessing(e).then(n=>t.flush(e).then(e=>n&&e))):Kc(!0)}close(e){return this.flush(e).then(e=>(this.getOptions().enabled=!1,this.metricsAggregator&&this.metricsAggregator.close(),e))}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}setupIntegrations(e){(e&&!this._integrationsInitialized||this._isEnabled()&&!this._integrationsInitialized)&&this._setupIntegrations()}init(){this._isEnabled()&&this._setupIntegrations()}getIntegrationById(e){return this.getIntegrationByName(e)}getIntegrationByName(e){return this._integrations[e]}getIntegration(e){try{return this._integrations[e.id]||null}catch{return gu&&Vl.warn(`Cannot retrieve integration ${e.id} from the current Client`),null}}addIntegration(e){const t=this._integrations[e.name];od(this,e,this._integrations),t||id(this,[e])}sendEvent(e,t={}){this.emit("beforeSendEvent",e,t);let n=ed(e,this._dsn,this._options._metadata,this._options.tunnel);for(const e of t.attachments||[])n=au(n,uu(e,this._options.transportOptions&&this._options.transportOptions.textEncoder));const r=this._sendEnvelope(n);r&&r.then(t=>this.emit("afterSendEvent",e,t),null)}sendSession(e){const t=function(e,t,n,r){const i=fu(n);return ou({sent_at:(new Date).toISOString(),...i&&{sdk:i},...!!r&&t&&{dsn:Wl(t)}},["aggregates"in e?[{type:"sessions"},e]:[{type:"session"},e.toJSON()]])}(e,this._dsn,this._options._metadata,this._options.tunnel);this._sendEnvelope(t)}recordDroppedEvent(e,t,n){if(this._options.sendClientReports){const n=`${e}:${t}`;gu&&Vl.log(`Adding outcome: "${n}"`),this._outcomes[n]=this._outcomes[n]+1||1}}captureAggregateMetrics(e){gu&&Vl.log(`Flushing aggregated metrics, number of metrics: ${e.length}`);const t=sd(e,this._dsn,this._options._metadata,this._options.tunnel);this._sendEnvelope(t)}on(e,t){this._hooks[e]||(this._hooks[e]=[]),this._hooks[e].push(t)}emit(e,...t){this._hooks[e]&&this._hooks[e].forEach(e=>e(...t))}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=function(e,t){const n={};return t.forEach(t=>{t&&od(e,t,n)}),n}(this,e),id(this,e),this._integrationsInitialized=!0}_updateSessionFromEvent(e,t){let n=!1,r=!1;const i=t.exception&&t.exception.values;if(i){r=!0;for(const e of i){const t=e.mechanism;if(t&&!1===t.handled){n=!0;break}}}const o="ok"===e.status;(o&&0===e.errors||o&&n)&&(xu(e,{...n&&{status:"crashed"},errors:e.errors||Number(r||n)}),this.captureSession(e))}_isClientDoneProcessing(e){return new Jc(t=>{let n=0;const r=setInterval(()=>{0==this._numProcessing?(clearInterval(r),t(!0)):(n+=1,e&&n>=e&&(clearInterval(r),t(!1)))},1)})}_isEnabled(){return!1!==this.getOptions().enabled&&void 0!==this._transport}_prepareEvent(e,t,n,r=Zu()){const i=this.getOptions(),o=Object.keys(this._integrations);return!t.integrations&&o.length>0&&(t.integrations=o),this.emit("preprocessEvent",e,t),ku(i,e,t,n,this,r).then(e=>{if(null===e)return e;const t={...r.getPropagationContext(),...n?n.getPropagationContext():void 0};if((!e.contexts||!e.contexts.trace)&&t){const{traceId:r,spanId:i,parentSpanId:o,dsc:a}=t;e.contexts={trace:{trace_id:r,span_id:i,parent_span_id:o},...e.contexts};const s=a||Nu(r,this,n);e.sdkProcessingMetadata={dynamicSamplingContext:s,...e.sdkProcessingMetadata}}return e})}_captureEvent(e,t={},n){return this._processEvent(e,t,n).then(e=>e.event_id,e=>{if(gu){const t=e;"log"===t.logLevel?Vl.log(t.message):Vl.warn(t)}})}_processEvent(e,t,n){const r=this.getOptions(),{sampleRate:i}=r,o=dd(e),a=ud(e),s=e.type||"error",l=`before send for type \`${s}\``;if(a&&"number"==typeof i&&Math.random()>i)return this.recordDroppedEvent("sample_rate","error",e),Zc(new ql(`Discarding event because it's not included in the random sample (sampling rate = ${i})`,"log"));const c="replay_event"===s?"replay":s,u=(e.sdkProcessingMetadata||{}).capturedSpanIsolationScope;return this._prepareEvent(e,t,n,u).then(n=>{if(null===n)throw this.recordDroppedEvent("event_processor",c,e),new ql("An event processor returned `null`, will not send event.","log");if(t.data&&!0===t.data.__sentry__)return n;const i=function(e,t,n){const{beforeSend:r,beforeSendTransaction:i}=e;return ud(t)&&r?r(t,n):dd(t)&&i?i(t,n):t}(r,n,t);return function(e,t){const n=`${t} must return \`null\` or a valid event.`;if(wl(e))return e.then(e=>{if(!yl(e)&&null!==e)throw new ql(n);return e},e=>{throw new ql(`${t} rejected with ${e}`)});if(!yl(e)&&null!==e)throw new ql(n);return e}(i,l)}).then(r=>{if(null===r)throw this.recordDroppedEvent("before_send",c,e),new ql(`${l} returned \`null\`, will not send event.`,"log");const i=n&&n.getSession();!o&&i&&this._updateSessionFromEvent(i,r);const a=r.transaction_info;if(o&&a&&r.transaction!==e.transaction){const e="custom";r.transaction_info={...a,source:e}}return this.sendEvent(r,t),r}).then(null,e=>{throw e instanceof ql?e:(this.captureException(e,{data:{__sentry__:!0},originalException:e}),new ql(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${e}`))})}_process(e){this._numProcessing++,e.then(e=>(this._numProcessing--,e),e=>(this._numProcessing--,e))}_sendEnvelope(e){if(this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport)return this._transport.send(e).then(null,e=>{gu&&Vl.error("Error while sending event:",e)});gu&&Vl.error("Transport disabled")}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.keys(e).map(t=>{const[n,r]=t.split(":");return{reason:n,category:r,quantity:e[t]}})}}function ud(e){return void 0===e.type}function dd(e){return"transaction"===e.type}function hd(e,t){!0===t.debug&&(gu?Vl.enable():Ul(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),Fu().update(t.initialScope);const n=new e(t);(function(e){const t=Ku().getStackTop();t.client=e,t.scope.setClient(e)})(n),function(e){e.init?e.init():e.setupIntegrations&&e.setupIntegrations()}(n)}function fd(e,t,n=Qc(e.bufferSize||30)){let r={};function i(i){const o=[];if(su(i,(t,n)=>{const i=hu(n);if(function(e,t,n=Date.now()){return function(e,t){return e[t]||e.all||0}(e,t)>n}(r,i)){const r=pd(t,n);e.recordDroppedEvent("ratelimit_backoff",i,r)}else o.push(t)}),0===o.length)return Kc();const a=ou(i[0],o),s=t=>{su(a,(n,r)=>{const i=pd(n,r);e.recordDroppedEvent(t,hu(r),i)})};return n.add(()=>t({body:cu(a,e.textEncoder)}).then(e=>(void 0!==e.statusCode&&(e.statusCode<200||e.statusCode>=300)&&gu&&Vl.warn(`Sentry responded with status code ${e.statusCode} to sent event.`),r=pu(r,e),e),e=>{throw s("network_error"),e})).then(e=>e,e=>{if(e instanceof ql)return gu&&Vl.error("Skipped sending event because buffer is full."),s("queue_overflow"),Kc();throw e})}return i.__sentry__baseTransport__=!0,{send:i,flush:e=>n.drain(e)}}function pd(e,t){if("event"===t||"transaction"===t)return Array.isArray(e)?e[1]:void 0}function gd(e,t,n=[t],r="npm"){const i=e._metadata||{};i.sdk||(i.sdk={name:`sentry.javascript.${t}`,packages:n.map(e=>({name:`${r}:@sentry/${e}`,version:Wu})),version:Wu}),e._metadata=i}const md=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/],vd=[/^.*\/healthcheck$/,/^.*\/healthy$/,/^.*\/live$/,/^.*\/ready$/,/^.*\/heartbeat$/,/^.*\/health$/,/^.*\/healthz$/],yd="InboundFilters",bd=(e={})=>({name:yd,setupOnce(){},processEvent(t,n,r){const i=r.getOptions(),o=function(e={},t={}){return{allowUrls:[...e.allowUrls||[],...t.allowUrls||[]],denyUrls:[...e.denyUrls||[],...t.denyUrls||[]],ignoreErrors:[...e.ignoreErrors||[],...t.ignoreErrors||[],...e.disableErrorDefaults?[]:md],ignoreTransactions:[...e.ignoreTransactions||[],...t.ignoreTransactions||[],...e.disableTransactionDefaults?[]:vd],ignoreInternal:void 0===e.ignoreInternal||e.ignoreInternal}}(e,i);return function(e,t){return t.ignoreInternal&&function(e){try{return"SentryError"===e.exception.values[0].type}catch{}return!1}(e)?(gu&&Vl.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${vc(e)}`),!0):function(e,t){return!(e.type||!t||!t.length)&&function(e){const t=[];let n;e.message&&t.push(e.message);try{n=e.exception.values[e.exception.values.length-1]}catch{}return n&&n.value&&(t.push(n.value),n.type&&t.push(`${n.type}: ${n.value}`)),gu&&0===t.length&&Vl.error(`Could not extract message for event ${vc(e)}`),t}(e).some(e=>Al(e,t))}(e,t.ignoreErrors)?(gu&&Vl.warn(`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${vc(e)}`),!0):function(e,t){if("transaction"!==e.type||!t||!t.length)return!1;const n=e.transaction;return!!n&&Al(n,t)}(e,t.ignoreTransactions)?(gu&&Vl.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.\nEvent: ${vc(e)}`),!0):function(e,t){if(!t||!t.length)return!1;const n=wd(e);return!!n&&Al(n,t)}(e,t.denyUrls)?(gu&&Vl.warn(`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${vc(e)}.\nUrl: ${wd(e)}`),!0):!function(e,t){if(!t||!t.length)return!0;const n=wd(e);return!n||Al(n,t)}(e,t.allowUrls)&&(gu&&Vl.warn(`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${vc(e)}.\nUrl: ${wd(e)}`),!0)}(t,o)?null:t}});function wd(e){try{let t;try{t=e.exception.values[0].stacktrace.frames}catch{}return t?function(e=[]){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n&&"<anonymous>"!==n.filename&&"[native code]"!==n.filename)return n.filename||null}return null}(t):null}catch{return gu&&Vl.error(`Cannot extract url for event ${vc(e)}`),null}}let xd;ad(yd,bd);const Cd="FunctionToString",_d=new WeakMap,Sd=()=>({name:Cd,setupOnce(){xd=Function.prototype.toString;try{Function.prototype.toString=function(...e){const t=Zl(this),n=_d.has(Tu())&&void 0!==t?t:this;return xd.apply(n,e)}}catch{}},setup(e){_d.set(e,!0)}});ad(Cd,Sd);const kd=Pl;let Ad=0;function Ed(){return Ad>0}function Id(e,t={},n){if("function"!=typeof e)return e;try{const t=e.__sentry_wrapped__;if(t)return t;if(Zl(e))return e}catch{return e}const r=function(){const r=Array.prototype.slice.call(arguments);try{n&&"function"==typeof n&&n.apply(this,arguments);const i=r.map(e=>Id(e,t));return e.apply(this,i)}catch(e){throw Ad++,setTimeout(()=>{Ad--}),function(...e){const t=Ku();if(2===e.length){const[n,r]=e;return n?t.withScope(()=>(t.getStackTop().scope=n,r(n))):t.withScope(r)}t.withScope(e[0])}(n=>{n.addEventProcessor(e=>(t.mechanism&&(yc(e,void 0),bc(e,t.mechanism)),e.extra={...e.extra,arguments:r},e)),function(e){Ku().captureException(e,void 0)}(e)}),e}};try{for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t])}catch{}Kl(r,e),Xl(e,"__sentry_wrapped__",r);try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get:()=>e.name})}catch{}return r}const Td=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;function Fd(e,t){const n=Pd(e,t),r={type:t&&t.name,value:Rd(t)};return n.length&&(r.stacktrace={frames:n}),void 0===r.type&&""===r.value&&(r.value="Unrecoverable error caught"),r}function Od(e,t){return{exception:{values:[Fd(e,t)]}}}function Pd(e,t){const n=t.stacktrace||t.stack||"",r=function(e){if(e){if("number"==typeof e.framesToPop)return e.framesToPop;if(Md.test(e.message))return 1}return 0}(t);try{return e(n,r)}catch{}return[]}const Md=/Minified React error #\d+;/i;function Rd(e){const t=e&&e.message;return t?t.error&&"string"==typeof t.error.message?t.error.message:t:"No error message"}function Ld(e,t,n,r,i){let o;if(fl(t)&&t.error)return Od(e,t.error);if(pl(t)||function(e){return hl(e,"DOMException")}(t)){const i=t;if("stack"in t)o=Od(e,t);else{const t=i.name||(pl(i)?"DOMError":"DOMException"),a=i.message?`${t}: ${i.message}`:t;o=Nd(e,a,n,r),yc(o,a)}return"code"in i&&(o.tags={...o.tags,"DOMException.code":`${i.code}`}),o}return dl(t)?Od(e,t):yl(t)||bl(t)?(o=function(e,t,n,r){const i=Tu(),o=i&&i.getOptions().normalizeDepth,a={exception:{values:[{type:bl(t)?t.constructor.name:r?"UnhandledRejection":"Error",value:Dd(t,{isUnhandledRejection:r})}]},extra:{__serialized__:qc(t,o)}};if(n){const t=Pd(e,n);t.length&&(a.exception.values[0].stacktrace={frames:t})}return a}(e,t,n,i),bc(o,{synthetic:!0}),o):(o=Nd(e,t,n,r),yc(o,`${t}`),bc(o,{synthetic:!0}),o)}function Nd(e,t,n,r){const i={};if(r&&n){const r=Pd(e,n);r.length&&(i.exception={values:[{value:t,stacktrace:{frames:r}}]})}if(ml(t)){const{__sentry_template_string__:e,__sentry_template_values__:n}=t;return i.logentry={message:e,params:n},i}return i.message=t,i}function Dd(e,{isUnhandledRejection:t}){const n=function(e,t=40){const n=Object.keys(Jl(e));if(n.sort(),!n.length)return"[object has no keys]";if(n[0].length>=t)return _l(n[0],t);for(let e=n.length;e>0;e--){const r=n.slice(0,e).join(", ");if(!(r.length>t))return e===n.length?r:_l(r,t)}return""}(e),r=t?"promise rejection":"exception";return fl(e)?`Event \`ErrorEvent\` captured as ${r} with message \`${e.message}\``:bl(e)?`Event \`${function(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}(e)}\` (type=${e.type}) captured as ${r}`:`Object captured as ${r} with keys: ${n}`}class jd extends cd{constructor(e){gd(e,"browser",["browser"],kd.SENTRY_SDK_SOURCE||"npm"),super(e),e.sendClientReports&&kd.document&&kd.document.addEventListener("visibilitychange",()=>{"hidden"===kd.document.visibilityState&&this._flushOutcomes()})}eventFromException(e,t){return function(e,t,n,r){const i=Ld(e,t,n&&n.syntheticException||void 0,r);return bc(i),i.level="error",n&&n.event_id&&(i.event_id=n.event_id),Kc(i)}(this._options.stackParser,e,t,this._options.attachStacktrace)}eventFromMessage(e,t="info",n){return function(e,t,n="info",r,i){const o=Nd(e,t,r&&r.syntheticException||void 0,i);return o.level=n,r&&r.event_id&&(o.event_id=r.event_id),Kc(o)}(this._options.stackParser,e,t,n,this._options.attachStacktrace)}captureUserFeedback(e){if(!this._isEnabled())return void(Td&&Vl.warn("SDK not enabled, will not capture user feedback."));const t=function(e,{metadata:t,tunnel:n,dsn:r}){const i={event_id:e.event_id,sent_at:(new Date).toISOString(),...t&&t.sdk&&{sdk:{name:t.sdk.name,version:t.sdk.version}},...!!n&&!!r&&{dsn:Wl(r)}},o=function(e){return[{type:"user_report"},e]}(e);return ou(i,[o])}(e,{metadata:this.getSdkMetadata(),dsn:this.getDsn(),tunnel:this.getOptions().tunnel});this._sendEnvelope(t)}_prepareEvent(e,t,n){return e.platform=e.platform||"javascript",super._prepareEvent(e,t,n)}_flushOutcomes(){const e=this._clearOutcomes();if(0===e.length)return void(Td&&Vl.log("No outcomes to send"));if(!this._dsn)return void(Td&&Vl.log("No dsn provided, will not send outcomes"));Td&&Vl.log("Sending outcomes:",e);const t=function(e,t){return ou(t?{dsn:t}:{},[[{type:"client_report"},{timestamp:ru(),discarded_events:e}]])}(e,this._options.tunnel&&Wl(this._dsn));this._sendEnvelope(t)}}let zd;function Bd(e,t=function(){if(zd)return zd;if(Fc(kd.fetch))return zd=kd.fetch.bind(kd);const e=kd.document;let t=kd.fetch;if(e&&"function"==typeof e.createElement)try{const n=e.createElement("iframe");n.hidden=!0,e.head.appendChild(n);const r=n.contentWindow;r&&r.fetch&&(t=r.fetch),e.head.removeChild(n)}catch(e){Td&&Vl.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",e)}return zd=t.bind(kd)}()){let n=0,r=0;return fd(e,function(i){const o=i.body.length;n+=o,r++;const a={body:i.body,method:"POST",referrerPolicy:"origin",headers:e.headers,keepalive:n<=6e4&&r<15,...e.fetchOptions};try{return t(e.url,a).then(e=>(n-=o,r--,{statusCode:e.status,headers:{"x-sentry-rate-limits":e.headers.get("X-Sentry-Rate-Limits"),"retry-after":e.headers.get("Retry-After")}}))}catch(e){return zd=void 0,n-=o,r--,Zc(e)}})}function Ud(e){return fd(e,function(t){return new Jc((n,r)=>{const i=new XMLHttpRequest;i.onerror=r,i.onreadystatechange=()=>{4===i.readyState&&n({statusCode:i.status,headers:{"x-sentry-rate-limits":i.getResponseHeader("X-Sentry-Rate-Limits"),"retry-after":i.getResponseHeader("Retry-After")}})},i.open("POST",e.url);for(const t in e.headers)Object.prototype.hasOwnProperty.call(e.headers,t)&&i.setRequestHeader(t,e.headers[t]);i.send(t.body)})})}const Vd="?";function Hd(e,t,n,r){const i={filename:e,function:t,in_app:!0};return void 0!==n&&(i.lineno=n),void 0!==r&&(i.colno=r),i}const Wd=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,$d=/\((\S*)(?::(\d+))(?::(\d+))\)/,Gd=[30,e=>{const t=Wd.exec(e);if(t){if(t[2]&&0===t[2].indexOf("eval")){const e=$d.exec(t[2]);e&&(t[2]=e[1],t[3]=e[2],t[4]=e[3])}const[e,n]=Qd(t[1]||Vd,t[2]);return Hd(n,e,t[3]?+t[3]:void 0,t[4]?+t[4]:void 0)}}],qd=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Yd=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Xd=[50,e=>{const t=qd.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){const e=Yd.exec(t[3]);e&&(t[1]=t[1]||"eval",t[3]=e[1],t[4]=e[2],t[5]="")}let e=t[3],n=t[1]||Vd;return[n,e]=Qd(n,e),Hd(e,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}],Kd=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i,Zd=[40,e=>{const t=Kd.exec(e);return t?Hd(t[2],t[1]||Vd,+t[3],t[4]?+t[4]:void 0):void 0}],Jd=oc(...[Gd,Xd,Zd]),Qd=(e,t)=>{const n=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return n||r?[-1!==e.indexOf("@")?e.split("@")[0]:Vd,n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},eh=1024,th="Breadcrumbs",nh=(e={})=>{const t={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...e};return{name:th,setupOnce(){},setup(e){t.console&&function(e){const t="console";dc(t,e),hc(t,pc)}(function(e){return function(t){if(Tu()!==e)return;const n={category:"console",data:{arguments:t.args,logger:"console"},level:nu(t.level),message:Sl(t.args," ")};if("assert"===t.level){if(!1!==t.args[0])return;n.message=`Assertion failed: ${Sl(t.args.slice(1)," ")||"console.assert"}`,n.data.arguments=t.args.slice(1)}Iu(n,{input:t.args,level:t.level})}}(e)),t.dom&&function(e){dc("dom",e),hc("dom",Ac)}(function(e,t){return function(n){if(Tu()!==e)return;let r,i,o="object"==typeof t?t.serializeAttribute:void 0,a="object"==typeof t&&"number"==typeof t.maxStringLength?t.maxStringLength:void 0;a&&a>eh&&(Td&&Vl.warn(`\`dom.maxStringLength\` cannot exceed 1024, but a value of ${a} was configured. Sentry will use 1024 instead.`),a=eh),"string"==typeof o&&(o=[o]);try{const e=n.event,t=function(e){return!!e&&!!e.target}(e)?e.target:e;r=Nl(t,{keyAttrs:o,maxStringLength:a}),i=function(e){if(!Ll.HTMLElement)return null;let t=e;for(let e=0;e<5;e++){if(!t)return null;if(t instanceof HTMLElement&&t.dataset.sentryComponent)return t.dataset.sentryComponent;t=t.parentNode}return null}(t)}catch{r="<unknown>"}if(0===r.length)return;const s={category:`ui.${n.name}`,message:r};i&&(s.data={"ui.component_name":i}),Iu(s,{event:n.event,name:n.name,global:n.global})}}(e,t.dom)),t.xhr&&function(e){dc("xhr",e),hc("xhr",$c)}(function(e){return function(t){if(Tu()!==e)return;const{startTimestamp:n,endTimestamp:r}=t,i=t.xhr[Wc];if(!n||!r||!i)return;const{method:o,url:a,status_code:s,body:l}=i;Iu({category:"xhr",data:{method:o,url:a,status_code:s},type:"http"},{xhr:t.xhr,input:l,startTimestamp:n,endTimestamp:r})}}(e)),t.fetch&&function(e){const t="fetch";dc(t,e),hc(t,Oc)}(function(e){return function(t){if(Tu()!==e)return;const{startTimestamp:n,endTimestamp:r}=t;if(r&&(!t.fetchData.url.match(/sentry_key/)||"POST"!==t.fetchData.method))if(t.error){Iu({category:"fetch",data:t.fetchData,level:"error",type:"http"},{data:t.error,input:t.args,startTimestamp:n,endTimestamp:r})}else{const e=t.response;Iu({category:"fetch",data:{...t.fetchData,status_code:e&&e.status},type:"http"},{input:t.args,response:e,startTimestamp:n,endTimestamp:r})}}}(e)),t.history&&Uc(function(e){return function(t){if(Tu()!==e)return;let n=t.from,r=t.to;const i=eu(kd.location.href);let o=n?eu(n):void 0;const a=eu(r);(!o||!o.path)&&(o=i),i.protocol===a.protocol&&i.host===a.host&&(r=a.relative),i.protocol===o.protocol&&i.host===o.host&&(n=o.relative),Iu({category:"navigation",data:{from:n,to:r}})}}(e)),t.sentry&&e.on&&e.on("beforeSendEvent",function(e){return function(t){Tu()===e&&Iu({category:"sentry."+("transaction"===t.type?"transaction":"event"),event_id:t.event_id,level:t.level,message:vc(t)},{event:t})}}(e))}}};ad(th,nh);const rh="Dedupe",ih=()=>{let e;return{name:rh,setupOnce(){},processEvent(t){if(t.type)return t;try{if(function(e,t){return!!t&&!(!function(e,t){const n=e.message,r=t.message;return!(!n&&!r||n&&!r||!n&&r||n!==r||!ah(e,t)||!oh(e,t))}(e,t)&&!function(e,t){const n=sh(t),r=sh(e);return!!(n&&r&&n.type===r.type&&n.value===r.value&&ah(e,t)&&oh(e,t))}(e,t))}(t,e))return Td&&Vl.warn("Event dropped due to being a duplicate of previously captured event."),null}catch{}return e=t}}};function oh(e,t){let n=lh(e),r=lh(t);if(!n&&!r)return!0;if(n&&!r||!n&&r||r.length!==n.length)return!1;for(let e=0;e<r.length;e++){const t=r[e],i=n[e];if(t.filename!==i.filename||t.lineno!==i.lineno||t.colno!==i.colno||t.function!==i.function)return!1}return!0}function ah(e,t){let n=e.fingerprint,r=t.fingerprint;if(!n&&!r)return!0;if(n&&!r||!n&&r)return!1;try{return n.join("")===r.join("")}catch{return!1}}function sh(e){return e.exception&&e.exception.values&&e.exception.values[0]}function lh(e){const t=e.exception;if(t)try{return t.values[0].stacktrace.frames}catch{return}}ad(rh,ih);const ch="GlobalHandlers",uh=(e={})=>{const t={onerror:!0,onunhandledrejection:!0,...e};return{name:ch,setupOnce(){Error.stackTraceLimit=50},setup(e){t.onerror&&(function(e){!function(e){const t="error";dc(t,e),hc(t,Lc)}(t=>{const{stackParser:n,attachStacktrace:r}=fh();if(Tu()!==e||Ed())return;const{msg:i,url:o,line:a,column:s,error:l}=t,c=void 0===l&&gl(i)?function(e,t,n,r){const i=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;let o=fl(e)?e.message:e,a="Error";const s=o.match(i);return s&&(a=s[1],o=s[2]),dh({exception:{values:[{type:a,value:o}]}},t,n,r)}(i,o,a,s):dh(Ld(n,l||i,void 0,r,!1),o,a,s);c.level="error",Eu(c,{originalException:l,mechanism:{handled:!1,type:"onerror"}})})}(e),hh("onerror")),t.onunhandledrejection&&(function(e){!function(e){const t="unhandledrejection";dc(t,e),hc(t,Dc)}(t=>{const{stackParser:n,attachStacktrace:r}=fh();if(Tu()!==e||Ed())return;const i=function(e){if(vl(e))return e;const t=e;try{if("reason"in t)return t.reason;if("detail"in t&&"reason"in t.detail)return t.detail.reason}catch{}return e}(t),o=vl(i)?function(e){return{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(e)}`}]}}}(i):Ld(n,i,void 0,r,!0);o.level="error",Eu(o,{originalException:i,mechanism:{handled:!1,type:"onunhandledrejection"}})})}(e),hh("onunhandledrejection"))}}};function dh(e,t,n,r){const i=e.exception=e.exception||{},o=i.values=i.values||[],a=o[0]=o[0]||{},s=a.stacktrace=a.stacktrace||{},l=s.frames=s.frames||[],c=isNaN(parseInt(r,10))?void 0:r,u=isNaN(parseInt(n,10))?void 0:n,d=gl(t)&&t.length>0?t:function(){try{return Ll.document.location.href}catch{return""}}();return 0===l.length&&l.push({colno:c,filename:d,function:"?",in_app:!0,lineno:u}),e}function hh(e){Td&&Vl.log(`Global Handler attached: ${e}`)}function fh(){const e=Tu();return e&&e.getOptions()||{stackParser:()=>[],attachStacktrace:!1}}ad(ch,uh);const ph="HttpContext",gh=()=>({name:ph,setupOnce(){},preprocessEvent(e){if(!kd.navigator&&!kd.location&&!kd.document)return;const t=e.request&&e.request.url||kd.location&&kd.location.href,{referrer:n}=kd.document||{},{userAgent:r}=kd.navigator||{},i={...e.request&&e.request.headers,...n&&{Referer:n},...r&&{"User-Agent":r}},o={...e.request,...t&&{url:t},headers:i};e.request=o}});ad(ph,gh);const mh="LinkedErrors",vh=(e={})=>{const t=e.limit||5,n=e.key||"cause";return{name:mh,setupOnce(){},preprocessEvent(e,r,i){const o=i.getOptions();El(Fd,o.stackParser,o.maxValueLength,n,t,e,r)}}};ad(mh,vh);const yh=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","BroadcastChannel","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","SharedWorker","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],bh="TryCatch",wh=(e={})=>{const t={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,...e};return{name:bh,setupOnce(){t.setTimeout&&Yl(kd,"setTimeout",xh),t.setInterval&&Yl(kd,"setInterval",xh),t.requestAnimationFrame&&Yl(kd,"requestAnimationFrame",Ch),t.XMLHttpRequest&&"XMLHttpRequest"in kd&&Yl(XMLHttpRequest.prototype,"send",_h);const e=t.eventTarget;e&&(Array.isArray(e)?e:yh).forEach(Sh)}}};function xh(e){return function(...t){const n=t[0];return t[0]=Id(n,{mechanism:{data:{function:lc(e)},handled:!1,type:"instrument"}}),e.apply(this,t)}}function Ch(e){return function(t){return e.apply(this,[Id(t,{mechanism:{data:{function:"requestAnimationFrame",handler:lc(e)},handled:!1,type:"instrument"}})])}}function _h(e){return function(...t){const n=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(e=>{e in n&&"function"==typeof n[e]&&Yl(n,e,function(t){const n={mechanism:{data:{function:e,handler:lc(t)},handled:!1,type:"instrument"}},r=Zl(t);return r&&(n.mechanism.data.handler=lc(r)),Id(t,n)})}),e.apply(this,t)}}function Sh(e){const t=kd,n=t[e]&&t[e].prototype;!n||!n.hasOwnProperty||!n.hasOwnProperty("addEventListener")||(Yl(n,"addEventListener",function(t){return function(n,r,i){try{"function"==typeof r.handleEvent&&(r.handleEvent=Id(r.handleEvent,{mechanism:{data:{function:"handleEvent",handler:lc(r),target:e},handled:!1,type:"instrument"}}))}catch{}return t.apply(this,[n,Id(r,{mechanism:{data:{function:"addEventListener",handler:lc(r),target:e},handled:!1,type:"instrument"}}),i])}}),Yl(n,"removeEventListener",function(e){return function(t,n,r){const i=n;try{const n=i&&i.__sentry_wrapped__;n&&e.call(this,t,n,r)}catch{}return e.call(this,t,i,r)}}))}ad(bh,wh);const kh=[bd(),Sd(),wh(),nh(),uh(),vh(),ih(),gh()];function Ah(e={}){void 0===e.defaultIntegrations&&(e.defaultIntegrations=[...kh]),void 0===e.release&&("string"==typeof __SENTRY_RELEASE__&&(e.release=__SENTRY_RELEASE__),kd.SENTRY_RELEASE&&kd.SENTRY_RELEASE.id&&(e.release=kd.SENTRY_RELEASE.id)),void 0===e.autoSessionTracking&&(e.autoSessionTracking=!0),void 0===e.sendClientReports&&(e.sendClientReports=!0);const t={...e,stackParser:ac(e.stackParser||Jd),integrations:rd(e),transport:e.transport||(Tc()?Bd:Ud)};hd(jd,t),e.autoSessionTracking&&function(){if(typeof kd.document>"u")return void(Td&&Vl.warn("Session tracking in non-browser environment with @sentry/browser is not supported."));Ou({ignoreDuration:!0}),Ru(),Uc(({from:e,to:t})=>{void 0!==e&&e!==t&&(Ou({ignoreDuration:!0}),Ru())})}()}var Eh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ih(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Th(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),n}var Fh=(e=>(e.INLINE="inline",e.OVERLAY="overlay",e))(Fh||{}),Oh=(e=>(e.TOP="top",e.BOTTOM="bottom",e.HIDDEN="",e))(Oh||{});function Ph(e,t){return{...t,message:e}}const Mh=[{name:"emoticons",list:["afro-1","afro","agent","alien-1","alien","angel","angry-1","angry-2","angry-3","angry-4","angry-5","angry","arguing","arrogant","asian-1","asian","avatar","baby-1","baby-2","baby","bully","burglar","businessman","cheeky-1","cheeky","clown","confused-1","confused-2","confused-3","confused","creepy","crying-1","crying-2","crying-3","crying","dazed-1","dazed-2","dazed-3","dazed","dead-1","dead-2","dead-3","dead-4","dead-5","dead-6","dead","desperate-1","desperate","detective","dissapointment","doctor","drunk","dumb","emo-1","emo-2","emo","emoticon","evil","faint-1","faint","flirt-1","flirt-2","flirt","flirty","gangster","geek-1","geek","gentleman-1","gentleman-2","gentleman-3","gentleman-4","gentleman","ginger","girl-1","girl","goofy-1","goofy-2","goofy-3","goofy-4","goofy","grubby-1","grubby","happy-1","happy-10","happy-11","happy-12","happy-13","happy-14","happy-15","happy-16","happy-2","happy-3","happy-4","happy-5","happy-6","happy-7","happy-8","happy-9","happy","harry-potter","heisenberg","hipster-1","hipster-2","hipster","in-love-1","in-love-2","in-love-3","in-love-4","in-love-5","in-love-6","in-love","japan","jew","joyful-1","joyful-2","joyful","kiss-1","kiss-2","kiss-3","kiss-4","kiss","laughing-1","laughing-2","laughing-3","laughing","listening","love","manly","miserly-1","miserly","nerd-1","nerd-2","nerd-3","nerd-4","nerd","ninja","pirate-1","pirate-2","pirate","punk-1","punk-2","punk","rapper","relieved","rich-1","rich-2","rich","rockstar","sad-1","sad-2","sad-3","sad-4","sad-5","sad-6","sad","scared-1","scared-2","scared-3","scared","sceptic-1","sceptic-2","sceptic-3","sceptic-4","sceptic-5","sceptic-6","sceptic-7","sceptic","secret","shocked-1","shocked-2","shocked-3","shocked","sick-1","sick-2","sick-3","sick-4","sick","silent","skeleton","smile","smiling-1","smiling","smoked","smug-1","smug-2","smug-3","smug-4","smug-5","smug-6","smug","sporty","stunned","superhero-1","superhero-2","superhero-3","superhero-4","superhero","surprised-1","surprised","thinking","tired-1","tired-2","tired-3","tired","tough-1","tough","trendy","vampire-1","vampire","wink-1","wink-2","wink","winking-1","winking","yawning-1","yawning-2","yawning-3","yawning","yelling","zombie"],type:"svg",thumbnailUrl:"images/stickers/categories/emoticon.svg"},{name:"doodles",items:100,type:"svg",thumbnailUrl:"images/stickers/categories/doodles.svg"},{name:"landmarks",items:100,type:"svg",thumbnailUrl:"images/stickers/categories/landmark.svg",invertPreview:!0},{name:"bubbles",items:104,type:"png",thumbnailUrl:"images/stickers/categories/speech-bubble.svg"},{name:"transportation",items:22,type:"svg",thumbnailUrl:"images/stickers/categories/transportation.svg",invertPreview:!0},{name:"beach",items:22,type:"svg",thumbnailUrl:"images/stickers/categories/beach.svg",invertPreview:!0}],Rh={emoticons:Ph("Emoticons"),doodles:Ph("Doodles"),landmarks:Ph("Landmarks"),bubbles:Ph("Bubbles"),transportation:Ph("Transportation"),beach:Ph("Beach")},Lh={fill:"#1565C0",opacity:1,backgroundColor:null,strokeWidth:.05,stroke:"#000"},Nh=[1,8,15,20,25];var Dh=(e=>(e.DARK="dark",e.LIGHT="light",e))(Dh||{});const jh=[{name:Dh.LIGHT,colors:{"--be-foreground-base":"0 0 0","--be-primary-light":"191 219 254","--be-primary":"59 130 246","--be-primary-dark":"37 99 235","--be-on-primary":"255 255 255","--be-danger":"179 38 30","--be-on-danger":"255 255 255","--be-background":"255 255 255","--be-background-alt":"250 250 250","--be-paper":"255 255 255","--be-disabled-bg-opacity":"12%","--be-disabled-fg-opacity":"26%","--be-hover-opacity":"4%","--be-focus-opacity":"12%","--be-selected-opacity":"8%","--be-text-main-opacity":"87%","--be-text-muted-opacity":"60%","--be-divider-opacity":"12%"}},{name:Dh.DARK,isDark:!0,colors:{"--be-foreground-base":"255 255 255","--be-primary-light":"239 246 255","--be-primary":"191 219 254","--be-primary-dark":"147 197 253","--be-on-primary":"56 30 114","--be-danger":"242 184 181","--be-on-danger":"96 20 16","--be-background":"20 21 23","--be-background-alt":"26 27 30","--be-paper":"44 46 51","--be-disabled-bg-opacity":"12%","--be-disabled-fg-opacity":"30%","--be-hover-opacity":"8%","--be-focus-opacity":"12%","--be-selected-opacity":"16%","--be-text-main-opacity":"100%","--be-text-muted-opacity":"70%","--be-divider-opacity":"12%"}}];var zh=(e=>(e.FILTER="filter",e.RESIZE="resize",e.CROP="crop",e.DRAW="draw",e.TEXT="text",e.SHAPES="shapes",e.STICKERS="stickers",e.FRAME="frame",e.CORNERS="corners",e.MERGE="merge",e))(zh||{});function Bh(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Bh(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Uh(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Bh(e))&&(r&&(r+=" "),r+=t);return r}const Vh=p((n,r)=>{const{attr:i,size:o,title:a,className:s,color:l,style:c,children:u,viewBox:d,width:h,height:f,...p}=n;return t("svg",{"aria-hidden":!a,focusable:!1,xmlns:"http://www.w3.org/2000/svg",viewBox:d||"0 0 24 24",...i,...p,className:Uh("svg-icon",s,Hh(o)),style:{color:l,...c},ref:r,height:f||"1em",width:h||"1em",children:[a&&e("title",{children:a}),u]})});function Hh(e){switch(e){case"2xs":return"icon-2xs";case"xs":return"icon-xs";case"sm":return"icon-sm";case"md":return"icon-md";case"lg":return"icon-lg";case"xl":return"icon-xl";default:return e}}function Wh(t,n="",r){return i.memo(i.forwardRef((i,o)=>e(Vh,{"data-testid":`${n}Icon`,ref:o,viewBox:r,...i,size:i.size||"md",children:t})))}function $h(e,t=""){return Wh(Gh(e),t)}function Gh(e){return(null==e?void 0:e.map)&&e.map((e,t)=>i.createElement(e.tag,{key:t,...e.attr},Gh(e.child)))}const qh=Wh(e("path",{d:"M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z"}),"TuneOutlined"),Yh=Wh(e("path",{d:"M21 15h2v2h-2v-2zm0-4h2v2h-2v-2zm2 8h-2v2c1 0 2-1 2-2zM13 3h2v2h-2V3zm8 4h2v2h-2V7zm0-4v2h2c0-1-1-2-2-2zM1 7h2v2H1V7zm16-4h2v2h-2V3zm0 16h2v2h-2v-2zM3 3C2 3 1 4 1 5h2V3zm6 0h2v2H9V3zM5 3h2v2H5V3zm-4 8v8c0 1.1.9 2 2 2h12V11H1zm2 8 2.5-3.21 1.79 2.15 2.5-3.22L13 19H3z"}),"PhotoSizeSelectLargeOutlined"),Xh=Wh(e("path",{d:"M17 15h2V7c0-1.1-.9-2-2-2H9v2h8v8zM7 17V1H5v4H1v2h4v10c0 1.1.9 2 2 2h10v4h2v-4h4v-2H7z"}),"CropOutlined"),Kh=Wh(e("path",{d:"M2.5 4v3h5v12h3V7h5V4h-13zm19 5h-9v3h3v7h3v-7h3V9z"}),"TextFieldsOutlined"),Zh=Wh(e("path",{d:"M10.5 4.5c.28 0 .5.22.5.5v2h6v6h2c.28 0 .5.22.5.5s-.22.5-.5.5h-2v6h-2.12c-.68-1.75-2.39-3-4.38-3s-3.7 1.25-4.38 3H4v-2.12c1.75-.68 3-2.39 3-4.38 0-1.99-1.24-3.7-2.99-4.38L4 7h6V5c0-.28.22-.5.5-.5m0-2C9.12 2.5 8 3.62 8 5H4c-1.1 0-1.99.9-1.99 2v3.8h.29c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-.3c0-1.49 1.21-2.7 2.7-2.7s2.7 1.21 2.7 2.7v.3H17c1.1 0 2-.9 2-2v-4c1.38 0 2.5-1.12 2.5-2.5S20.38 11 19 11V7c0-1.1-.9-2-2-2h-4c0-1.38-1.12-2.5-2.5-2.5z"}),"ExtensionOutlined"),Jh=Wh(e("path",{d:"M10.25 13c0 .69-.56 1.25-1.25 1.25S7.75 13.69 7.75 13s.56-1.25 1.25-1.25 1.25.56 1.25 1.25zM15 11.75c-.69 0-1.25.56-1.25 1.25s.56 1.25 1.25 1.25 1.25-.56 1.25-1.25-.56-1.25-1.25-1.25zm7 .25c0 5.52-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2s10 4.48 10 10zM10.66 4.12C12.06 6.44 14.6 8 17.5 8c.46 0 .91-.05 1.34-.12C17.44 5.56 14.9 4 12 4c-.46 0-.91.05-1.34.12zM4.42 9.47c1.71-.97 3.03-2.55 3.66-4.44C6.37 6 5.05 7.58 4.42 9.47zM20 12c0-.78-.12-1.53-.33-2.24-.7.15-1.42.24-2.17.24-3.13 0-5.92-1.44-7.76-3.69C8.69 8.87 6.6 10.88 4 11.86c.01.04 0 .09 0 .14 0 4.41 3.59 8 8 8s8-3.59 8-8z"}),"FaceOutlined"),Qh=Wh(e("path",{d:"M20 4h-4l-4-4-4 4H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H4V6h4.52l3.52-3.5L15.52 6H20v14zM6 18h12V8H6v10zm2-8h8v6H8v-6z"}),"FilterFramesOutlined"),ef=Wh(e("path",{d:"M6.41 21 5 19.59l4.83-4.83c.75-.75 1.17-1.77 1.17-2.83v-5.1L9.41 8.41 8 7l4-4 4 4-1.41 1.41L13 6.83v5.1c0 1.06.42 2.08 1.17 2.83L19 19.59 17.59 21 12 15.41 6.41 21z"}),"MergeOutlined"),tf=Wh(e("path",{d:"M19 19h2v2h-2v-2zm0-2h2v-2h-2v2zM3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm0-4h2V3H3v2zm4 0h2V3H7v2zm8 16h2v-2h-2v2zm-4 0h2v-2h-2v2zm4 0h2v-2h-2v2zm-8 0h2v-2H7v2zm-4 0h2v-2H3v2zM21 8c0-2.76-2.24-5-5-5h-5v2h5c1.65 0 3 1.35 3 3v5h2V8z"}),"RoundedCornerOutlined"),nf=Wh(e("path",{d:"M20 4v12H8V4h12m0-2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-8.5 9.67 1.69 2.26 2.48-3.1L19 15H9zM2 6v14c0 1.1.9 2 2 2h14v-2H4V6H2z"}),"PhotoLibraryOutlined"),rf=Wh(e("path",{d:"M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.25 2.52.77-1.28-3.52-2.09V8z"}),"HistoryOutlined"),of=Wh([e("path",{d:"m2.53 19.65 1.34.56v-9.03l-2.43 5.86c-.41 1.02.08 2.19 1.09 2.61zm19.5-3.7L17.07 3.98c-.31-.75-1.04-1.21-1.81-1.23-.26 0-.53.04-.79.15L7.1 5.95c-.75.31-1.21 1.03-1.23 1.8-.01.27.04.54.15.8l4.96 11.97c.31.76 1.05 1.22 1.83 1.23.26 0 .52-.05.77-.15l7.36-3.05c1.02-.42 1.51-1.59 1.09-2.6zm-9.2 3.8L7.87 7.79l7.35-3.04h.01l4.95 11.95-7.35 3.05z"},"0"),e("circle",{cx:"11",cy:"9",r:"1"},"1"),e("path",{d:"M5.88 19.75c0 1.1.9 2 2 2h1.45l-3.45-8.34v6.34z"},"2")],"StyleOutlined"),af=Wh(e("path",{d:"M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"}),"DeleteOutlined"),sf=Wh(e("path",{d:"M18.85,10.39l1.06-1.06c0.78-0.78,0.78-2.05,0-2.83L18.5,5.09c-0.78-0.78-2.05-0.78-2.83,0l-1.06,1.06L18.85,10.39z M14.61,11.81L7.41,19H6v-1.41l7.19-7.19L14.61,11.81z M13.19,7.56L4,16.76V21h4.24l9.19-9.19L13.19,7.56L13.19,7.56z M19,17.5 c0,2.19-2.54,3.5-5,3.5c-0.55,0-1-0.45-1-1s0.45-1,1-1c1.54,0,3-0.73,3-1.5c0-0.47-0.48-0.87-1.23-1.2l1.48-1.48 C18.32,15.45,19,16.29,19,17.5z M4.58,13.35C3.61,12.79,3,12.06,3,11c0-1.8,1.89-2.63,3.56-3.36C7.59,7.18,9,6.56,9,6 c0-0.41-0.78-1-2-1C5.74,5,5.2,5.61,5.17,5.64C4.82,6.05,4.19,6.1,3.77,5.76C3.36,5.42,3.28,4.81,3.62,4.38C3.73,4.24,4.76,3,7,3 c2.24,0,4,1.32,4,3c0,1.87-1.93,2.72-3.64,3.47C6.42,9.88,5,10.5,5,11c0,0.31,0.43,0.6,1.07,0.86L4.58,13.35z"}),"Draw"),lf=Wh(e("path",{d:"m12 5.69 5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3 2 12h3v8h6v-6h2v6h6v-8h3L12 3z"}),"HomeOutlined"),cf={[zh.FILTER]:{name:Ph("Applied Filters"),icon:qh},[zh.RESIZE]:{name:Ph("Resized Image"),icon:Yh},[zh.CROP]:{name:Ph("Cropped Image"),icon:Xh},[zh.DRAW]:{name:Ph("Added Drawing"),icon:sf},[zh.TEXT]:{name:Ph("Added Text"),icon:Kh},[zh.SHAPES]:{name:Ph("Added Shape"),icon:Zh},[zh.STICKERS]:{name:Ph("Added Sticker"),icon:Jh},[zh.FRAME]:{name:Ph("Added Frame"),icon:Qh},[zh.MERGE]:{name:Ph("Merged Objects"),icon:ef},[zh.CORNERS]:{name:Ph("Rounded Corner"),icon:tf},bgImage:{name:Ph("Replaced Background Image"),icon:nf},overlayImage:{name:Ph("Added Image"),icon:nf},initial:{name:Ph("Initial"),icon:lf},loadedState:{name:Ph("Loaded State"),icon:rf},objectStyle:{name:Ph("Changed Style"),icon:of},deletedObject:{name:Ph("Deleted object"),icon:af}},uf=Object.values(zh).map(e=>({name:e,icon:cf[e].icon,action:e===zh.MERGE?e=>{e.tools.merge.apply()}:e})),df={filter:Ph("filter"),resize:Ph("resize"),crop:Ph("crop"),draw:Ph("draw"),text:Ph("text"),shapes:Ph("shapes"),stickers:Ph("stickers"),frame:Ph("frame"),corners:Ph("corners"),merge:Ph("merge")},hf=Wh(e("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5 5-5z"}),"FileDownloadOutlined"),ff="3.0.5",pf={selector:"pixie-editor",textureSize:4096,activeLanguage:"en",ui:{visible:!0,mode:Fh.INLINE,forceOverlayModeOnMobile:!0,activeTheme:Dh.LIGHT,themes:jh,allowEditorClose:!0,menubar:{items:[{type:"undoWidget",align:"left"},{type:"zoomWidget",align:"center",desktopOnly:!0},{type:"button",icon:rf,align:"right",desktopOnly:!0,action:e=>{e.togglePanel("history")}},{type:"button",icon:hf,label:Ph("Done"),align:"right",action:e=>{var t;null!=(t=e.state.config.ui)&&t.showExportPanel?e.state.togglePanel("export",!0):e.tools.export.save()}}]},nav:{position:Oh.BOTTOM,items:[...uf]},openImageDialog:{show:!0,sampleImages:[{url:"images/samples/sample1.jpg",thumbnail:"images/samples/sample1_thumbnail.jpg"},{url:"images/samples/sample2.jpg",thumbnail:"images/samples/sample2_thumbnail.jpg"},{url:"images/samples/sample3.jpg",thumbnail:"images/samples/sample3_thumbnail.jpg"}]},colorPresets:{items:["rgb(0,0,0)","rgb(255, 255, 255)","rgb(242, 38, 19)","rgb(249, 105, 14)","rgb(253, 227, 167)","rgb(4, 147, 114)","rgb(30, 139, 195)","rgb(142, 68, 173)"]}},objectDefaults:{global:{...Lh},sticker:{fill:void 0},text:{textAlign:"initial",underline:!1,linethrough:!1,fontStyle:"normal",fontFamily:"Times New Roman",fontWeight:"normal",stroke:void 0,fontSize:40}},tools:{filter:{items:["grayscale","blackWhite","sharpen","invert","vintage","polaroid","kodachrome","technicolor","brownie","sepia","removeColor","brightness","gamma","noise","pixelate","blur","emboss","blendColor"]},zoom:{allowUserZoom:!0,fitImageToScreen:!0},crop:{allowCustomRatio:!0,defaultRatio:"1:1",presets:[{ratio:null,name:"Custom"},{ratio:"1:1",name:"Square"},{ratio:"4:3"},{ratio:"16:9"},{ratio:"5:3"},{ratio:"5:4"},{ratio:"6:4"},{ratio:"7:5"},{ratio:"10:8"}]},text:{defaultText:"Double click to edit",controlsPadding:6,items:[{family:"Roboto",src:"fonts/open-sans-v27-latin-ext_latin-regular.woff2"},{family:"Fuzzy Bubbles",src:"fonts/fuzzy-bubbles-v3-latin-700.woff2",descriptors:{weight:"700"}},{family:"Aleo Bold",src:"fonts/aleo-v4-latin-ext_latin-700.woff2",descriptors:{weight:"700"}},{family:"Amatic SC",src:"fonts/amatic-sc-v16-latin-ext_latin-regular.woff2"},{family:"Corinthia Bold",src:"fonts/corinthia-v7-latin-ext_latin-700.woff2"},{family:"Bungee Inline",src:"fonts/bungee-inline-v6-latin-ext_latin-regular.woff2"},{family:"Robot Slab Bold",src:"fonts/roboto-slab-v16-latin-ext_latin-500.woff2"},{family:"Carter One",src:"fonts/carter-one-v12-latin-regular.woff2"},{family:"Cody Star",src:"fonts/codystar-v10-latin-ext_latin-regular.woff2"},{family:"Fira Sans",src:"fonts/fira-sans-v11-latin-ext_latin_cyrillic-regular.woff2"},{family:"Krona One",src:"fonts/krona-one-v9-latin-ext_latin-regular.woff2"},{family:"Kumar One Outline",src:"fonts/kumar-one-outline-v8-latin-ext_latin-regular.woff2"},{family:"Lobster Two",src:"fonts/lobster-two-v13-latin-regular.woff2"},{family:"Molle Italic",src:"fonts/molle-v11-latin-ext_latin-italic.woff2"},{family:"Monoton",src:"fonts/monoton-v10-latin-regular.woff2"},{family:"Nixie One",src:"fonts/nixie-one-v11-latin-regular.woff2"},{family:"Permanent Marker",src:"fonts/permanent-marker-v10-latin-regular.woff2"},{family:"Sancreek",src:"fonts/sancreek-v13-latin-ext_latin-regular.woff2"},{family:"Stint Ultra Expanded",src:"fonts/stint-ultra-expanded-v10-latin-regular.woff2"},{family:"VT323",src:"fonts/vt323-v12-latin-ext_latin-regular.woff2"},{family:"Trash Hand",src:"fonts/TrashHand.ttf"}]},draw:{brushSizes:Nh,brushTypes:["PencilBrush","EraserBrush","SprayBrush","CircleBrush","DiamondBrush","VLineBrush","HLineBrush","SquareBrush"]},shapes:{items:[{name:"circle",type:"Circle"},{name:"square",type:"Rect",options:{lockUniScaling:!1}},{name:"triangle",type:"Triangle"},{name:"ellipse",type:"Ellipse",options:{lockUniScaling:!1}},{name:"Arrow #1",type:"Path",options:{path:"M 294.9 16.4 l 15.7 42.2 c -171.4 70.3 -294 242.3 -289.1 437.4 l 14.7 -1 c 9.1 -0.6 18.1 -1.2 27.1 -1.9 l 14.7 -1 c -4.3 -170.1 102.5 -320 252 -381.3 l 15.7 42.2 c 34.7 -40.5 83.1 -76.6 144.8 -99.8 c -58.1 -26.2 -124.9 -39.6 -195.6 -36.8 z"}},{name:"Arrow #2",type:"Path",options:{path:"M 16 248.4 v 14.9 h 447.5 l -93.2 82.5 l 11.9 10.5 l 113.8 -100.2 l -113.6 -100.4 l -11.8 10.5 l 92.9 82.2 z"}},{name:"Arrow #3",type:"Path",options:{path:"M 496 256 l -118.6 -66 v 40.8 h -361.4 v 50.4 h 361.4 v 40.8 l 118.6 -66 z"}},{name:"Line",type:"Path",options:{path:"M 16 256 h 480",strokeWidth:10,stroke:"#000",padding:10}},{name:"Star",type:"Path",options:{path:"M 256 406.3 l 148.3 78 l -28.3 -165.2 l 120 -117 l -165.8 -24.1 l -74.2 -150.3 l -74.2 150.3 l -165.8 24.1 l 120 117 l -28.3 165.2 z"}},{name:"Polygon",type:"Path",options:{path:"M 256 19.6 l 156.6 57.1 l 83.4 144.3 l -28.9 164.2 l -127.7 107.2 h -166.8 l -127.7 -107.2 l -28.9 -164.2 l 83.4 -144.3 z"}},{name:"Badge",type:"Path",options:{path:"M 257.3 16.2 s -148 58.2 -204.4 81.4 c 0 75.7 -16.8 303.5 204.4 398.2 c 218.7 -94.6 201.9 -322.4 201.9 -398.2 c -62.1 -23.6 -201.9 -81.4 -201.9 -81.4 z"}}].slice()},stickers:{items:Mh},import:{validImgExtensions:["png","jpg","jpeg","svg","gif"],fitOverlayToScreen:!0,openDroppedImageAsBackground:!1},export:{defaultFormat:"png",defaultQuality:.8,defaultName:"image"},frame:{items:[{name:"basic",mode:"basic",size:{min:1,max:35,default:10}},{name:"pine",mode:"stretch",size:{min:1,max:35,default:15}},{name:"oak",mode:"stretch",size:{min:1,max:35,default:15}},{name:"rainbow",mode:"stretch",size:{min:1,max:35,default:15}},{name:"grunge1",display_name:"grunge #1",mode:"stretch",size:{min:1,max:35,default:15}},{name:"grunge2",display_name:"grunge #2",mode:"stretch",size:{min:1,max:35,default:20}},{name:"ebony",mode:"stretch",size:{min:1,max:35,default:15}},{name:"art1",display_name:"Art #1",mode:"repeat",size:{min:10,max:70,default:55}},{name:"art2",display_name:"Art #2",mode:"repeat",size:{min:10,max:70,default:55}}]}}},gf=e=>{let t;const n=new Set,r=(e,r)=>{const i="function"==typeof e?e(t):e;if(!Object.is(i,t)){const e=t;t=r??("object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>a,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},a=t=e(r,i,o);return o};var mf={exports:{}},vf={},yf={exports:{}},bf={},wf=i;
|
|
10
10
|
/**
|
|
11
11
|
* @license React
|
|
12
12
|
* use-sync-external-store-shim.production.min.js
|
|
@@ -73,5 +73,5 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
73
73
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
74
74
|
and limitations under the License.
|
|
75
75
|
***************************************************************************** */
|
|
76
|
-
var nL=function(e,t){return nL=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},nL(e,t)};var rL=function(){return rL=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},rL.apply(this,arguments)};var iL="Pixel",oL="Percent",aL={unit:oL,value:.8};function sL(e){return"number"==typeof e?{unit:oL,value:100*e}:"string"==typeof e?e.match(/^(\d*(\.\d+)?)px$/)?{unit:iL,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:oL,value:parseFloat(e)}:(console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'),aL):(console.warn("scrollThreshold should be string or number"),aL)}var lL=function(e){function t(t){var n=e.call(this,t)||this;return n.lastScrollTop=0,n.actionTriggered=!1,n.startY=0,n.currentY=0,n.dragging=!1,n.maxPullDownDistance=0,n.getScrollableTarget=function(){return n.props.scrollableTarget instanceof HTMLElement?n.props.scrollableTarget:"string"==typeof n.props.scrollableTarget?document.getElementById(n.props.scrollableTarget):(null===n.props.scrollableTarget&&console.warn("You are trying to pass scrollableTarget but it is null. This might\n happen because the element may not have been added to DOM yet.\n See https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59 for more info.\n "),null)},n.onStart=function(e){n.lastScrollTop||(n.dragging=!0,e instanceof MouseEvent?n.startY=e.pageY:e instanceof TouchEvent&&(n.startY=e.touches[0].pageY),n.currentY=n.startY,n._infScroll&&(n._infScroll.style.willChange="transform",n._infScroll.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)"))},n.onMove=function(e){n.dragging&&(e instanceof MouseEvent?n.currentY=e.pageY:e instanceof TouchEvent&&(n.currentY=e.touches[0].pageY),n.currentY<n.startY||(n.currentY-n.startY>=Number(n.props.pullDownToRefreshThreshold)&&n.setState({pullToRefreshThresholdBreached:!0}),n.currentY-n.startY>1.5*n.maxPullDownDistance||n._infScroll&&(n._infScroll.style.overflow="visible",n._infScroll.style.transform="translate3d(0px, "+(n.currentY-n.startY)+"px, 0px)")))},n.onEnd=function(){n.startY=0,n.currentY=0,n.dragging=!1,n.state.pullToRefreshThresholdBreached&&(n.props.refreshFunction&&n.props.refreshFunction(),n.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame(function(){n._infScroll&&(n._infScroll.style.overflow="auto",n._infScroll.style.transform="none",n._infScroll.style.willChange="unset")})},n.onScrollListener=function(e){"function"==typeof n.props.onScroll&&setTimeout(function(){return n.props.onScroll&&n.props.onScroll(e)},0);var t=n.props.height||n._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;n.actionTriggered||((n.props.inverse?n.isElementAtTop(t,n.props.scrollThreshold):n.isElementAtBottom(t,n.props.scrollThreshold))&&n.props.hasMore&&(n.actionTriggered=!0,n.setState({showLoader:!0}),n.props.next&&n.props.next()),n.lastScrollTop=t.scrollTop)},n.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},n.throttledOnScrollListener=function(e,t,n,r){var i,o=!1,a=0;function s(){i&&clearTimeout(i)}function l(){var l=this,c=Date.now()-a,u=arguments;function d(){a=Date.now(),n.apply(l,u)}o||(r&&!i&&d(),s(),void 0===r&&c>e?d():!0!==t&&(i=setTimeout(r?function(){i=void 0}:d,void 0===r?e-c:e)))}return"boolean"!=typeof t&&(r=n,n=t,t=void 0),l.cancel=function(){s(),o=!0},l}(150,n.onScrollListener).bind(n),n.onStart=n.onStart.bind(n),n.onMove=n.onMove.bind(n),n.onEnd=n.onEnd.bind(n),n}return function(e,t){function n(){this.constructor=e}nL(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype.componentDidMount=function(){if(void 0===this.props.dataLength)throw new Error('mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage');if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener("scroll",this.throttledOnScrollListener),"number"==typeof this.props.initialScrollY&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener("touchstart",this.onStart),this.el.addEventListener("touchmove",this.onMove),this.el.addEventListener("touchend",this.onEnd),this.el.addEventListener("mousedown",this.onStart),this.el.addEventListener("mousemove",this.onMove),this.el.addEventListener("mouseup",this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),"function"!=typeof this.props.refreshFunction))throw new Error('Mandatory prop "refreshFunction" missing.\n Pull Down To Refresh functionality will not work\n as expected. Check README.md for usage\'')},t.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener("scroll",this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener("touchstart",this.onStart),this.el.removeEventListener("touchmove",this.onMove),this.el.removeEventListener("touchend",this.onEnd),this.el.removeEventListener("mousedown",this.onStart),this.el.removeEventListener("mousemove",this.onMove),this.el.removeEventListener("mouseup",this.onEnd)))},t.prototype.componentDidUpdate=function(e){this.props.dataLength!==e.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},t.getDerivedStateFromProps=function(e,t){return e.dataLength!==t.prevDataLength?rL(rL({},t),{prevDataLength:e.dataLength}):null},t.prototype.isElementAtTop=function(e,t){void 0===t&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=sL(t);return r.unit===iL?e.scrollTop<=r.value+n-e.scrollHeight+1:e.scrollTop<=r.value/100+n-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){void 0===t&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=sL(t);return r.unit===iL?e.scrollTop+n>=e.scrollHeight-r.value:e.scrollTop+n>=r.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=rL({height:this.props.height||"auto",overflow:"auto",WebkitOverflowScrolling:"touch"},this.props.style),n=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),r=this.props.pullDownToRefresh&&this.props.height?{overflow:"auto"}:{};return i.createElement("div",{style:r,className:"infinite-scroll-component__outerdiv"},i.createElement("div",{className:"infinite-scroll-component "+(this.props.className||""),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&i.createElement("div",{style:{position:"relative"},ref:function(t){return e._pullDown=t}},i.createElement("div",{style:{position:"absolute",left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!n&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(_);function cL(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function uL(){return uL=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},uL.apply(this,arguments)}function dL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function hL(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?dL(Object(n),!0).forEach(function(t){fL(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function fL(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const pL={breakpointCols:void 0,className:void 0,columnClassName:void 0,children:void 0,columnAttrs:void 0,column:void 0};class gL extends i.Component{constructor(e){let t;super(e),this.reCalculateColumnCount=this.reCalculateColumnCount.bind(this),this.reCalculateColumnCountDebounce=this.reCalculateColumnCountDebounce.bind(this),t=this.props.breakpointCols&&this.props.breakpointCols.default?this.props.breakpointCols.default:parseInt(this.props.breakpointCols)||2,this.state={columnCount:t}}componentDidMount(){this.reCalculateColumnCount(),window&&window.addEventListener("resize",this.reCalculateColumnCountDebounce)}componentDidUpdate(){this.reCalculateColumnCount()}componentWillUnmount(){window&&window.removeEventListener("resize",this.reCalculateColumnCountDebounce)}reCalculateColumnCountDebounce(){window&&window.requestAnimationFrame?(window.cancelAnimationFrame&&window.cancelAnimationFrame(this._lastRecalculateAnimationFrame),this._lastRecalculateAnimationFrame=window.requestAnimationFrame(()=>{this.reCalculateColumnCount()})):this.reCalculateColumnCount()}reCalculateColumnCount(){const e=window&&window.innerWidth||1/0;let t=this.props.breakpointCols;"object"!=typeof t&&(t={default:parseInt(t)||2});let n=1/0,r=t.default||2;for(let i in t){const o=parseInt(i);o>0&&e<=o&&o<n&&(n=o,r=t[i])}r=Math.max(1,parseInt(r)||1),this.state.columnCount!==r&&this.setState({columnCount:r})}itemsInColumns(){const e=this.state.columnCount,t=new Array(e),n=i.Children.toArray(this.props.children);for(let r=0;r<n.length;r++){const i=r%e;t[i]||(t[i]=[]),t[i].push(n[r])}return t}renderColumns(){const{column:e,columnAttrs:t={},columnClassName:n}=this.props,r=this.itemsInColumns(),o=100/r.length+"%";let a=n;a&&"string"!=typeof a&&(this.logDeprecated('The property "columnClassName" requires a string'),void 0===a&&(a="my-masonry-grid_column"));const s=hL(hL(hL({},e),t),{},{style:hL(hL({},t.style),{},{width:o}),className:a});return r.map((e,t)=>i.createElement("div",uL({},s,{key:t}),e))}logDeprecated(e){console.error("[Masonry]",e)}render(){const e=this.props,{children:t,breakpointCols:n,columnClassName:r,columnAttrs:o,column:a,className:s}=e,l=cL(e,["children","breakpointCols","columnClassName","columnAttrs","column","className"]);let c=s;return"string"!=typeof s&&(this.logDeprecated('The property "className" requires a string'),void 0===s&&(c="my-masonry-grid")),i.createElement("div",uL({},l,{className:c}),this.renderColumns())}}gL.defaultProps=pL;var mL={gifTab:"gifTab",scrollableDiv:"scrollableDiv",gifSearchInput:"gifSearchInput",search:"search",searchResults:"searchResults",myMasonryGrid:"myMasonryGrid",myMasonryGridColumn:"myMasonryGridColumn",listItem:"listItem",loaded:"loaded",loadedImage:"loadedImage",searchOutputWrapper:"searchOutputWrapper",divider:"divider",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle"};const vL={default:4,1600:3,1100:2,700:1},yL=({setImageGifList:r,imageGifList:i=[],currentReqGif:s,setCurrentReqGif:l,inputRef:c,customRequest:d})=>{const{t:h}=Qn(),{GifPlayIcon:f}=oo(),{options:p}=ro(),{config:g}=p,[m,v]=o(null),[y,b]=o(!1),[w,x]=o(25),[C,_]=o(null),[S]=T.useForm(),A=u(s);a(()=>{S.setFieldsValue({keywords:s.keywords})},[]);const E=null==g?void 0:g.handleProxyUrl,I=async e=>E?Promise.resolve(E(e)):e,O=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{images:Object.assign(Object.assign({},e.images),{downsized:Object.assign(Object.assign({},e.images.downsized),{url:await I(e.images.downsized.url)})})}))),P=async function({query:e,page:t}){var n;const r=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{const e=`https://api.giphy.com/v1/gifs/search?api_key=${null!==(n=null==g?void 0:g.REACT_APP_GIPHY_KEY)&&void 0!==n?n:"Nh77eBlPeMn1ed9MBAvL542NUGeNO26F"}&q=${encodeURIComponent(r)}&limit=25&offset=${t}&lang=en`,i=await fetch(await I(e));return{data:await i.json()}}catch(e){console.warn(e)}},M=async()=>{var e,t;const n=await P({query:A.current,page:0});(null===(t=null===(e=null==n?void 0:n.data)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)&&n.data.data.length>0&&r(await O(n.data.data))};return a(()=>()=>{C&&clearTimeout(C)},[C]),e("div",{className:mL.gifTab,children:e("div",{className:mL.searchOutputWrapper,children:t("div",{id:"scrollableDiv",className:mL.scrollableDiv,children:[t(T,{form:S,onValuesChange:e=>{if(void 0!==e.keywords){const t=Object.assign(Object.assign({},A.current),{keywords:e.keywords});l(t),A.current=t,C&&clearTimeout(C);const n=setTimeout(M,800);_(n)}},className:i.length>0?mL.searchResults:mL.search,children:[e(T.Item,{name:"keywords",className:mL.gifSearchInput,children:e(F,{onKeyDown:e=>"Space"===e.code&&M(),onPressEnter:e=>M(),allowClear:!0,placeholder:h("Search GIFs"),ref:c,spellCheck:"false",prefix:e(wi,{size:16,strokeWidth:null==g?void 0:g.iconStrokeWidth,onClick:M})})}),i.length>0&&!y&&e("div",{className:`ant-divider ${mL.divider}`,role:"separator"})]}),!i.length&&!y&&e(n,{children:s.keywords?e(uo,{}):t("div",{className:mL.resultsContainer,children:[e("div",{className:mL.videoIcon,children:e(f,{className:mL.playButton})}),e("h1",{className:mL.title,children:h("Over 350,000 live images")}),e("p",{className:mL.subtitle,children:h("Enter a search query and we'll find the perfect image for you")})]})}),!i.length&&y&&e(Hs,{}),i.length>0&&e(lL,{dataLength:i&&i.length,next:async()=>{y||(b(!0),P({query:A.current,page:w}).then(async e=>{if(e&&e.data&&e.data.data){const t=await O(e.data.data);r(e=>[...e,...t])}b(!1),x(e=>e+25)}).catch(()=>{b(!1)}))},hasMore:!!i,endMessage:t(K,{plain:!0,children:[h("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:e(Hs,{}),children:e(gL,{breakpointCols:vL,className:mL.myMasonryGrid,columnClassName:mL.myMasonryGridColumn,children:i.map((n,r)=>t("div",{className:mL.listItem,onClick:()=>(async(e,t)=>{var n;v(t),setTimeout(()=>{v(null)},2e3);let r=e.split("?")[0].split("#")[0].split("/"),i=r[r.length-1]||"uploaded-file";i.includes(".")&&(null===(n=i.split(".").pop())||void 0===n?void 0:n.length)&&i.split(".").pop().length<=5||(i+=".gif"),d(e,i)})(n.images.downsized.url,n.id,n.title),children:[e("img",{className:m===n.id?mL.loadedImage:"",width:"100%",src:n.images.downsized.url,alt:n.title,onLoad:e=>{const t=e.target.parentNode;t&&t instanceof HTMLElement&&t.classList.add(mL.loaded)}}),e("a",{rel:"noreferrer",href:"https://giphy.com/",target:"_blank",onClick:e=>e.stopPropagation()}),m===n.id&&e(k,{className:mL.antSpin})]},n.id+r))})})]})})})};var bL={stockTab:"stockTab",stockSearchInput:"stockSearchInput",searchOutputWrapper:"searchOutputWrapper",divider:"divider",search:"search",searchResults:"searchResults",scrollableDiv:"scrollableDiv",myMasonryGrid:"myMasonryGrid",myMasonryGridColumn:"myMasonryGridColumn",listItem:"listItem",loaded:"loaded",loadedImage:"loadedImage",creatorInfo:"creatorInfo",stockColorFilter:"stockColorFilter",allColors:"allColors",blackColor:"blackColor",bwColor:"bwColor",whiteColor:"whiteColor",orangeColor:"orangeColor",redColor:"redColor",purpleColor:"purpleColor",magentaColor:"magentaColor",greenColor:"greenColor",tealColor:"tealColor",blueColor:"blueColor",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle"};const wL={default:4,1600:3,1100:2,700:1},xL=(e,t)=>{const n=new URL(e);return n.searchParams.set("w",t.toString()),n.toString()},CL=({imageStockList:r,setImageStockList:i,currentReq:s,setCurrentReq:l,inputRef:c,customRequest:d})=>{var h,f,p;const{t:g}=Qn(),{StockBigIcon:m,MixedViewIcon:v,LandscapeViewIcon:y,PortraitViewIcon:b,SquareViewIcon:w}=oo(),{options:x}=ro(),{config:C}=x,[_,S]=o(!1),[A,E]=o(2),[I,O]=o(null),[P,R]=o(null),[L,N]=o(!0),[D]=T.useForm(),j=null==C?void 0:C.handleProxyUrl,z=null!==(h=null==C?void 0:C.UNSPLASH_KEY)&&void 0!==h?h:"HX2_qqq3F3ljmtYtfmb9P6h0dn2u9mnnOl36IdV8el0",U=(null===(f=null==C?void 0:C.locale)||void 0===f?void 0:f.slice(0,2))||"ru",H=u(s),W=async e=>j?Promise.resolve(j(e)):e,$=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{urls:{raw:await W(xL(e.urls.raw,1200)),small:await W(xL(e.urls.raw,540))}})));a(()=>{H.current=s},[s]),a(()=>{0===r.length&&D.setFieldsValue({color:"",orientation:""})},[r,D]),a(()=>{D.setFieldsValue({keywords:s.keywords,color:s.color,orientation:s.orientation})},[]);const G=async function({query:e,page:t}){const n=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{let r=`https://api.unsplash.com/search/photos?client_id=${z}&lang=${U}&per_page=18&query=${encodeURIComponent(n)}&page=${t}`;""!==e.color&&(r+=`&color=${e.color}`),""!==e.orientation&&(r+=`&orientation=${e.orientation}`);const i=await fetch(await W(r));return{data:await i.json()}}catch(e){console.warn(e)}finally{S(!1)}},q=async()=>{var e,t,n;S(!0);const r=await G({query:H.current,page:1});(null===(e=null==r?void 0:r.data)||void 0===e?void 0:e.results)&&(i(await $(r.data.results)),N(18===r.data.results.length),(null===(n=null===(t=null==r?void 0:r.data)||void 0===t?void 0:t.results)||void 0===n?void 0:n.length)&&r.data.results.length>0&&E(2))};a(()=>()=>{P&&clearTimeout(P)},[P]);const Y=async(e,t,n,r)=>{var i;!async function(e){try{const t=`${e}${e.includes("?")?"&":"?"}client_id=${z}`,n=await W(t),r=await fetch(n);return{data:await r.json()}}catch(e){console.warn(e)}}(t.download_location),O(n),setTimeout(()=>O(null),2e3);const o=e.raw,a=o.split("?")[0].split("#")[0].split("/");let s=a[a.length-1]||"uploaded-file";s.includes(".")&&(null===(i=s.split(".").pop())||void 0===i?void 0:i.length)&&s.split(".").pop().length<=5||(s+=".jpg"),d(o,s)};return e("div",{className:bL.stockTab,children:e("div",{className:bL.searchOutputWrapper,children:t("div",{className:bL.scrollableDiv,id:"scrollableDiv",children:[t(T,{form:D,initialValues:wn,onValuesChange:(e,t)=>{const n=Object.assign(Object.assign({},wn),t);if(l(n),H.current=n,P&&clearTimeout(P),""!==t.keywords){const e=setTimeout(q,800);R(e)}else r.length||(l(Object.assign({},wn)),H.current=wn,D.resetFields())},className:r.length>0?bL.searchResults:bL.search,children:[t(V,{gutter:24,children:[e(B,{span:r.length>0?void 0:24,children:e(T.Item,{name:"keywords",className:bL.stockSearchInput,children:e(F,{allowClear:!0,placeholder:g("Search image"),ref:c,spellCheck:"false",prefix:e(wi,{size:16,strokeWidth:null==C?void 0:C.iconStrokeWidth})})})}),!!r.length&&t(n,{children:[e(B,{children:e(T.Item,{name:"orientation",children:t(ee.Group,{onChange:e=>l(t=>Object.assign(Object.assign({},t),{orientation:e.target.value})),children:[e(M,{title:g("All"),placement:"top",children:e(ee.Button,{value:"",children:e(v,{})})}),e(M,{title:g("Landscape"),placement:"top",children:e(ee.Button,{value:"landscape",children:e(y,{})})}),e(M,{title:g("Portrait"),placement:"top",children:e(ee.Button,{value:"portrait",children:e(b,{})})}),e(M,{title:g("Squarish"),placement:"top",children:e(ee.Button,{value:"squarish",children:e(w,{})})})]})})}),e(B,{children:e(T.Item,{name:"color",children:t(ee.Group,{className:bL.stockColorFilter,onChange:e=>l(t=>Object.assign(Object.assign({},t),{color:e.target.value})),children:[e(M,{title:g("All"),placement:"top",children:e(ee.Button,{className:bL.allColors,value:"",children:"All"})}),e(M,{title:g("Black"),placement:"top",children:e(ee.Button,{className:bL.blackColor,value:"black",children:"B"})}),e(M,{title:g("Black and White"),placement:"top",children:e(ee.Button,{className:bL.bwColor,value:"black_and_white",children:"B&W"})}),e(M,{title:g("White"),placement:"top",children:e(ee.Button,{className:bL.whiteColor,value:"white",children:"W"})}),e(M,{title:g("Orange"),placement:"top",children:e(ee.Button,{className:bL.orangeColor,value:"orange",children:"O"})}),e(M,{title:g("Red"),placement:"top",children:e(ee.Button,{className:bL.redColor,value:"red",children:"R"})}),e(M,{title:g("Purple"),placement:"top",children:e(ee.Button,{className:bL.purpleColor,value:"purple",children:"P"})}),e(M,{title:g("Magenta"),placement:"top",children:e(ee.Button,{className:bL.magentaColor,value:"magenta",children:"M"})}),e(M,{title:g("Green"),placement:"top",children:e(ee.Button,{className:bL.greenColor,value:"green",children:"G"})}),e(M,{title:g("Teal"),placement:"top",children:e(ee.Button,{className:bL.tealColor,value:"teal",children:"T"})}),e(M,{title:g("Blue"),placement:"top",children:e(ee.Button,{className:bL.blueColor,value:"blue",children:"B"})})]})})})]})]}),r.length>0&&!_&&e("div",{className:`ant-divider ${bL.divider}`,role:"separator"})]}),!r.length&&!_&&e(n,{children:s.keywords?e(uo,{}):t("div",{className:bL.resultsContainer,children:[e("div",{className:bL.videoIcon,children:e(m,{className:bL.playButton})}),e("h1",{className:bL.title,children:g("Millions of free stock images")}),e("p",{className:bL.subtitle,children:g("Enter a search query and we'll find the perfect image for you")})]})}),!r.length&&_&&e(Hs,{}),r.length>0&&e(lL,{dataLength:r&&r.length,next:async()=>{if(_||""===H.current.keywords)return S(!1),void(""===H.current.keywords&&N(!1));S(!0),G({query:H.current,page:A}).then(async e=>{if(e&&e.data&&e.data.results){const t=await $(e.data.results);i(e=>[...e,...t]),N(18===e.data.results.length)}E(e=>e+1)}).catch(e=>{console.warn("catch",e)}).finally(()=>{S(!1)})},hasMore:L&&""!==(null===(p=H.current)||void 0===p?void 0:p.keywords),endMessage:t(K,{plain:!0,children:[g("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:e(Hs,{}),children:e(gL,{breakpointCols:wL,className:bL.myMasonryGrid,columnClassName:bL.myMasonryGridColumn,children:r.map((n,r)=>t("div",{className:bL.listItem,onClick:()=>Y(n.urls,n.links,n.id,n.description),children:[e("img",{className:I===n.id?bL.loadedImage:"",width:"100%",src:n.urls.small,alt:n.description,onLoad:e=>{const t=e.target.parentNode;t&&t instanceof HTMLElement&&t.classList.add(bL.loaded)}}),t("p",{className:bL.creatorInfo,onClick:e=>e.stopPropagation(),children:[g("Photo by")," ",e("a",{target:"_blank",href:`${n.user.links.html}?utm_source=${null==C?void 0:C.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:n.user.name})," ",g("on")," ",e("a",{target:"_blank",href:`https://unsplash.com/?utm_source=${null==C?void 0:C.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:"Unsplash"})]}),I===n.id&&e(k,{className:bL.antSpin})]},n.id+r))})})]})})})},_L=()=>{const{options:e}=ro(),t=e.config;return c((e,n)=>{!1!==(null==t?void 0:t.pushToGTM)&&((e,t)=>{const n=()=>{try{const t=Object.assign(Object.assign({},e),{appLabel:"blocks_app"});window.dataLayer&&"function"==typeof window.dataLayer.push&&window.dataLayer.push(t)}catch(e){console.error("Ошибка при вызове GTM:",e)}};t?setTimeout(n,t):n()})(e,n)},[null==t?void 0:t.pushToGTM])};var SL="slideshowContainer",kL="slideshowImage";const AL=({images:t,transitionDuration:n=1e3,frameHeight:r})=>{const[i,s]=o([]),[l,c]=o(r);a(()=>{const e=()=>{if("undefined"==typeof window)return void c(r);const e=window.innerHeight,t=Math.max(e-260,130);if("number"==typeof r){const e=Math.min(r,t);c(e)}else c(t)};if(e(),"undefined"!=typeof window)return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[r]);const u=()=>{s(e=>e.map((t,n)=>n===e.length-1?Object.assign(Object.assign({},t),{opacity:1}):t))};return a(()=>{if(t.length>0){const e=t[t.length-1];s(t=>[...t,{src:e,opacity:0}]),setTimeout(u,1e3)}else s([])},[t]),e("div",{className:SL,style:{height:l,minHeight:130},children:i.map((t,r)=>e("img",{src:`data:image/jpeg;base64, ${t.src}`,alt:`Slide ${r+1}`,className:kL,style:{opacity:t.opacity,transition:`opacity ${n}ms linear`,display:"block"}},r))})},EL=t=>{var{className:n,style:r,color:i,text:o,bordered:a}=t,s=ls(t,["className","style","color","text","bordered"]);const l=o||"";return e(te,Object.assign({style:r,color:i,bordered:a,className:n},s,{children:l}))},IL=({text:n,counter:r,limits:i,wrapperStyles:o})=>{const{t:a}=Qn(),{options:s}=ro(),l=s.config,{token:c}=A.useToken(),u=+i>0,d=!u||r<+i,h=(null==l?void 0:l.billingPageUrl)||"/billing",f=r+" "+a("of")+" "+(u?i:"∞")+" "+(n||a("tests",{count:i}))+" "+a("was used",{count:r});return t("div",{className:"limits-couter-wrapper",style:o,children:[e(EL,{bordered:!1,text:f,className:"limit-counter",style:{color:d?c.colorText:"white"},color:d?c.colorFillSecondary:"rgb(255, 77, 79)"}),u&&e("div",{style:{fontSize:14,textDecoration:"underline",cursor:"pointer"},onClick:()=>window.location.assign(h),children:a("Need more?")})]})};var TL={imageAi:"imageAi",imageAiExample:"imageAiExample",imageItem:"imageItem",textAreaInputHybrid:"textAreaInputHybrid",loading:"loading",carousel:"carousel",arrow:"arrow",arrowNext:"arrowNext",arrowPrev:"arrowPrev",arrowBtn:"arrowBtn",arrowBtnNext:"arrowBtnNext",arrowBtnPrev:"arrowBtnPrev",row:"row",inputAffixWrapper:"inputAffixWrapper",textarea:"textarea",inputIcon:"inputIcon"};const FL=f(({className:t,onClick:n})=>e("div",{className:`${TL.arrow} ${TL.arrowNext} ${t||""}`,onClick:n,children:e(R,{className:`${TL.arrowBtn} ${TL.arrowBtnNext}`,size:"large",icon:e(Ae,{})})}));FL.displayName="SampleNextArrow";const OL=f(({className:t,onClick:n})=>e("div",{className:`${TL.arrow} ${TL.arrowPrev} ${t||""}`,onClick:n,children:e(R,{className:`${TL.arrowBtn} ${TL.arrowBtnPrev}`,size:"large",icon:e(Ee,{})})}));OL.displayName="SamplePrevArrow";const PL=({customRequest:n,inputAiRef:r,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:h,setAiImageRequest:f,imageAiList:p,setImageAiList:g,isLoadingAi:m,setIsLoadingAi:v})=>{const{t:y}=Qn(),{AiIcon_2:b}=oo(),w=i.useRef(null),[x,C]=o("auto"),{aiImageCounter:_,currentAiImgLimits:S,loadingDuringGeneration:k,requestStatus:A,handleGenerate:E,convertBase64ToFile:I,isShiftPressed:O,setIsShiftPressed:P,limitsInPlugin:M}=function({setFrameHeight:e,customRequest:t,aiTabRef:n,isImageUploaded:r,setIsImageUploaded:i,aiImageRequest:s,imageAiList:l,setImageAiList:h,isLoadingAi:f,setIsLoadingAi:p}){const{t:g}=Qn(),{options:m}=ro(),v=m.config,y=bo(),b=_L(),{messages:w}=m.config,[x,C]=o([]),[_,S]=o(0),[k,A]=o(null),[E,I]=o(!1),[T,F]=o(g("Evaluating the task")),[O,P]=o(!1),M=u(new Set),R=u(new Set),L=u(new Set);a(()=>{C(w)},[w]),a(()=>{l.length||k||(C([]),M.current.clear(),R.current.clear(),L.current.clear(),j.current=-1)},[l,k]);const N=d(()=>v&&"function"==typeof(null==v?void 0:v.sendAIImageRequest)?null==v?void 0:v.sendAIImageRequest:()=>Promise.resolve({}),[v]),D=c(e=>{const t=`${k}-${e.progress}-${JSON.stringify(e.images||e.data)}`;if(!L.current.has(t))if(L.current.add(t),"error"!==e.status&&"Canceled"!==e.status){if(e.images){if(F(String(e.status)),100===e.progress){p(!1),h(e.images);const t=k,n=Array.isArray(e.images)?e.images:[];n.length>0&&t&&!M.current.has(t)&&(M.current.add(t),y.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:g("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:n}})),A(null),P(!1)}}else if(e.data&&(h([String(e.data)]),100===e.progress)){p(!1);const t=k,n=e.data?[String(e.data)]:[];n.length>0&&t&&!M.current.has(t)&&(M.current.add(t),y.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:g("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:n}})),A(null),P(!1)}}else p(!1),P(!1),k&&!R.current.has(k)&&(R.current.add(k),y.error({id:"AI_RESPONSE_INVALID",message:g("Something went wrong, please try again"),placement:"bottomRight",description:String(k)||void 0,data:{requestId:k,request:s,response:e},innerException:e}))},[s,h,F,g,p,k,y,P]),j=u(-1);a(()=>{if(x.length>0){const e=x.length-1;e>j.current&&(j.current=e,D(x[e]))}},[D,x]);const z=d(()=>{if(v&&"function"==typeof(null==v?void 0:v.sseQuery)){const e=null==v?void 0:v.sseQuery;return t=>e(t)}return e=>{}},[v]),B=d(()=>v&&"object"==typeof(null==v?void 0:v.handleLimitUsageEmitter)?null==v?void 0:v.handleLimitUsageEmitter:{fire:()=>{}},[v]),U=null==v?void 0:v.elementId,{projectId:V}=v,{limits:H}=(null==v?void 0:v.limits)?v:{limits:{ai_img_limit:0}},{ai_img_limit:W}=H,$=W>0&&_>=W,G=!(!(null==v?void 0:v.limits)||!v.counters)&&gn,q=c(()=>{B.fire({name:"AiImgCount",count:_+1})},[B,_]),Y=d(()=>!$&&!G,[$,G,_,W]),X=c(async()=>{F(g("Evaluating the task")),""===s||f||(p(!0),P(!0),h([]),C([]),b({event:"submit_form",action:"ai_image_generation",entity_id:U,project_id:V}),N({body:{project_id:V,request:"create-image",connection:"midjourney",message:s}}).then(e=>{var t,n,r,i,o;const{data:a,error:l}=e||{};if(l)throw l;const c=a;if(401===(null==c?void 0:c.status)||401===(null===(t=null==c?void 0:c.data)||void 0===t?void 0:t.status))throw new Error("ERROR");const u=(null==c?void 0:c.task)||(null===(n=null==c?void 0:c.data)||void 0===n?void 0:n.task),d=null!==(i=null!==(r=null==u?void 0:u.id)&&void 0!==r?r:k)&&void 0!==i?i:void 0;200===(null==c?void 0:c.status)||200===(null===(o=null==c?void 0:c.data)||void 0===o?void 0:o.status)?((null==u?void 0:u.id)&&(F(u.message),A(u.id)),(null==c?void 0:c.message)&&y.success({id:"AI_IMAGE_GENERATION_STARTED",message:c.message,placement:"bottomRight",data:{request:s,taskId:d,response:null==c?void 0:c.data}}),z({task_id:null==u?void 0:u.id,entity_id:U})):(p(!1),P(!1),d&&!R.current.has(d)&&(R.current.add(d),y.error({id:"AI_IMAGE_GENERATION_FAILED",message:(null==c?void 0:c.message)||g("Something went wrong, please try again"),placement:"bottomRight",description:s,data:{request:s,taskId:d,response:c},innerException:c})))}).catch(e=>{p(!1),P(!1);const t=e;return((null==t?void 0:t.error)||(null==t?void 0:t.data))&&k&&!R.current.has(k)&&(R.current.add(k),null==y||y.error({id:"AI_IMAGE_GENERATION_FAILED",message:g("Something went wrong, please try again"),placement:"bottomRight",description:s,innerException:e,data:{request:s,taskId:k,response:null==t?void 0:t.data,error:Io(null==t?void 0:t.error)}})),t}))},[s,f,p,P,h,b,U,V,N,y,z,g,k]),K=c(()=>{Y&&X()},[Y,G,S,q,X,y,g]);a(()=>{},[v,G]);const Z=c(e=>{if(r)return;const n=e.match(/^data:image\/([A-Za-z-+/]+);base64,(.+)$/);if(!n)return;const o=n[1],a=n[2],s=atob(a),l=new Array(s.length);for(let e=0;e<s.length;e++)l[e]=s.charCodeAt(e);const c=new Uint8Array(l),u=new Blob([c],{type:`image/${o}`}),d=new File([u],"image.jpeg",{type:u.type,lastModified:Date.now()});i(!0),(async()=>{try{"function"==typeof t&&await Promise.resolve(t({file:d}))}catch(e){console.error("FM AI: customRequest error",e)}finally{i(!1)}})()},[r,i,t]);return a(()=>{(f||l.length>0)&&setTimeout(()=>{var t,r;let i=350;if(n.current){const e=null===(t=n.current)||void 0===t?void 0:t.firstChild;e&&e instanceof HTMLElement&&(i=(null===(r=n.current.getBoundingClientRect())||void 0===r?void 0:r.height)-48-e.clientHeight)}e(i)},0)},[n,l.length,f,e]),{aiImageCounter:_,setAiImageCounter:S,currentAiImgLimits:W,isFieldsDisabled:$,canGenerateImage:Y,aiImageRequest:s,imageAiList:l,setImageAiList:h,isLoadingAi:f,setIsLoadingAi:p,loadingDuringGeneration:O,setLoadingDuringGeneration:P,requestStatus:T,setRequestStatus:F,handleGenerate:K,handleLimitAiImgCount:q,convertBase64ToFile:Z,isShiftPressed:E,setIsShiftPressed:I,currentReqId:k,setCurrentReqId:A,limitsInPlugin:G}}({setFrameHeight:C,customRequest:n,aiTabRef:w,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:h,imageAiList:p,setImageAiList:g,isLoadingAi:m,setIsLoadingAi:v});a(()=>{},[s]);const[L,N]=o(!1),D=c(()=>N(!0),[]),j=c(()=>N(!1),[]),z=c(e=>f(e.target.value),[f]),U=c(e=>{"Shift"===e.key?P(!0):"Enter"!==e.key||O||(e.preventDefault(),E())},[O,E,P]),H=c(e=>{"Shift"===e.key&&P(!1)},[P]);return t("div",{className:TL.imageAi,ref:w,children:[M&&e(IL,{text:"images",counter:_,limits:S,wrapperStyles:{marginTop:-25}}),e(V,{gutter:24,className:TL.row,children:t(B,{span:24,children:[e(T.Item,{children:t("span",{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg ${TL.inputAffixWrapper}${L?" ant-input-affix-wrapper-focused":""}`,children:[e(F.TextArea,{ref:r,onKeyDown:U,onKeyUp:H,onFocus:D,onBlur:j,autoSize:!0,allowClear:!0,className:`${TL.textAreaInputHybrid} ${TL.textarea}`,placeholder:y("Generate image"),value:h,onChange:z,spellCheck:"false"}),e("span",{className:`ant-input-suffix ${TL.inputSuffix}`,children:m||k?e(le,{className:`${TL.inputIcon} input-icon`,spin:!0}):e(b,{className:`${TL.inputIcon} input-icon`,onClick:E})})]})}),t("div",{className:TL.imageAiExample,children:[e("span",{children:y("For example:")})," ",y("A beautiful image of a sunset over a calm ocean.")]})]})}),(m||p.length>0)&&t(ne,{dotPosition:"top",arrows:!0,nextArrow:e(FL,{}),prevArrow:e(OL,{}),className:TL.carousel,infinite:!1,children:[m&&!p.length&&e("div",{className:TL.loading,children:t("div",{className:"spin",children:[e(le,{style:{fontSize:48},spin:!0}),e("p",{className:"status",children:A})]})}),p.length>0&&p.map((n,r)=>t("div",{className:TL.imageItem,children:[e(AL,{images:p,frameHeight:x}),e("div",{className:"buttons",children:p.length>0&&!m&&e(R,{onClick:()=>I(`data:image/jpeg;base64, ${n}`),loading:s,icon:e(Ie,{}),children:y("Use this variant")})})]},r))]})]})};var ML={iconsTab:"iconsTab",hasSearch:"hasSearch",iconsSearchFormCenteredContainer:"iconsSearchFormCenteredContainer",iconsSearchFormCentered:"iconsSearchFormCentered",iconsSearchFormInput:"iconsSearchFormInput",iconsSearchFormInputInput:"iconsSearchFormInputInput",iconsSearchResults:"iconsSearchResults",iconsControlsControls:"iconsControlsControls",iconsControls:"iconsControls",iconsControlElement:"iconsControlElement",iconsControlsStrokeWidth:"iconsControlsStrokeWidth",iconsControlsHeader:"iconsControlsHeader",iconsSearchFormSelect:"iconsSearchFormSelect",iconsSearchFormStyleItem:"iconsSearchFormStyleItem",iconsSearchDivider:"iconsSearchDivider",iconsGrid:"iconsGrid",iconsBottomBar:"iconsBottomBar",iconsBottomBarContent:"iconsBottomBarContent",iconsGridEmptyState:"iconsGridEmptyState",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle",iconsGridInfiniteScroll:"iconsGridInfiniteScroll",iconsGridGrid:"iconsGridGrid",iconsGridItem:"iconsGridItem",iconsGridItemThumbnail:"iconsGridItemThumbnail",iconsGridItemSvg:"iconsGridItemSvg",iconsGridItemImg:"iconsGridItemImg",iconsGridItemName:"iconsGridItemName",iconsGridLoading:"iconsGridLoading",iconsControlsBackButton:"iconsControlsBackButton",iconsGridCheckbox:"iconsGridCheckbox",iconsGridShowCheckboxes:"iconsGridShowCheckboxes",iconsHeaderContainer:"iconsHeaderContainer",iconsHeaderContainerLeft:"iconsHeaderContainerLeft",copyToFolderModalBody:"copyToFolderModalBody",copyToFolderModalLoadingOverlay:"copyToFolderModalLoadingOverlay"};const RL=[{label:"Line",value:"line"},{label:"Solid",value:"solid"},{label:"Flat",value:"flat"},{label:"Duo",value:"duo"},{label:"Handrawn",value:"handrawn"},{label:"Creative",value:"creative"},{label:"Gradient",value:"gradient"},{label:"Remix",value:"remix"},{label:"Neon",value:"neon"},{label:"Pop",value:"pop"},{label:"Light",value:"light"},{label:"Glyph",value:"glyph"},{label:"Minimal",value:"minimal"},{label:"Outlined",value:"outlined"},{label:"Geometric",value:"geometric"},{label:"Bold",value:"bold"},{label:"Stroke",value:"stroke"},{label:"Wireframe",value:"wireframe"},{label:"Filled",value:"filled"}],LL=({query:n,onQueryChange:r,onSubmit:i,styleFilter:o,onStyleChange:a,hasResults:s=!1,inputRef:l})=>{const{t:c}=Qn(),{options:u}=ro(),{config:d}=u,h=n.length>0&&s;return t("div",{className:ML.iconsSearchFormCenteredContainer,children:[t(T,{layout:"inline",onFinish:i,className:h?ML.iconsSearchResults:ML.iconsSearchFormCentered,children:[e(T.Item,{className:ML.iconsSearchFormInput,children:e(F,{ref:l,className:ML.iconsSearchFormInputInput,allowClear:!0,prefix:e(wi,{size:16,strokeWidth:null==d?void 0:d.iconStrokeWidth,onClick:i}),placeholder:c("Search icons"),value:n,onChange:e=>r(e.target.value),onKeyDown:e=>"Space"===e.code&&i(),onPressEnter:i,spellCheck:"false"})}),h&&e(T.Item,{className:ML.iconsSearchFormStyleItem,children:e(P,{allowClear:!0,placeholder:c("Style"),value:null!=o?o:void 0,onChange:e=>a(null!=e?e:null),className:ML.iconsSearchFormSelect,options:RL.map(e=>({label:c(e.label),value:e.value}))})})]}),h&&e("div",{className:`ant-divider ${ML.iconsSearchDivider}`,role:"separator"})]})},NL=r=>{const{t:i}=Qn(),{mode:o,colorHex:a,setColorHex:s,colorHex2:l,setColorHex2:c,colorHex3:u,setColorHex3:d,sizePx:h,setSizePx:f,strokeWidth:p,setStrokeWidth:g,showSecondColor:m,showThirdColor:v,onBack:y,styleFilter:b}=r;return t("div",{className:ML.iconsControls,children:[e("div",{className:ML.iconsControlsControls,children:"family"===o&&t(n,{children:[t("div",{className:ML.iconsControlsStrokeWidth,children:[e("span",{children:i("Size")}),e(re,{min:20,max:200,value:h,formatter:e=>`${e}px`,parser:e=>e?e.replace("px",""):"",onChange:e=>f("number"==typeof e?e:50)})]}),t("div",{className:ML.iconsControlsStrokeWidth,children:[e("span",{children:i("Stroke width")}),e(re,{min:.3,max:3,step:.1,value:"number"==typeof p?p:1,formatter:e=>`${e}px`,parser:e=>e?e.replace("px",""):"",onChange:e=>g("number"==typeof e?e:1)})]}),"gradient"===b?e(L,{size:8,children:e(ie,{defaultValue:[{color:a||"#108ee9",percent:0},{color:l||"#87d068",percent:100}],showText:!0,mode:"gradient",onChangeComplete:e=>{try{const t=e.toCssString().match(/(rgba?\([^)]+\)|#[0-9a-fA-F]{3,8})/g)||[];t[0]&&s(t[0]),t[1]&&c(t[1])}catch(e){console.warn("ColorPicker gradient parsing error",e)}},size:"small"})}):t(n,{children:[t("div",{className:ML.iconsControlElement,children:[e("span",{children:i("Color1")}),e(ie,{value:a,format:"hex",disabledAlpha:!0,onChange:(e,t)=>s(t),size:"middle"})]}),m&&t("div",{className:ML.iconsControlElement,children:[e("span",{children:i("Color2")}),e(ie,{value:l,format:"hex",disabledAlpha:!0,onChange:(e,t)=>c(t),size:"middle"})]}),v&&t("div",{className:ML.iconsControlElement,children:[e("span",{children:i("Color3")}),e(ie,{value:u,format:"hex",disabledAlpha:!0,onChange:(e,t)=>d(t),size:"middle"})]})]})]})}),e("div",{className:ML.iconsControlsHeader,children:e("div",{children:"family"===o?e(R,{className:ML.iconsControlsBackButton,type:"default",onClick:y,title:i("Back"),children:i("Back")}):null})})]})},DL=e(le,{style:{fontSize:20},spin:!0}),jL=({items:n,hasMore:r,loading:i,hasQuery:o,mode:a,selectedHash:s,onLoadMore:l,onItemClick:c,onInsert:u,scrollContainerRef:d,colorVars:h,svgTextMap:f,previewSize:p,selectedHashes:g,onToggleSelect:m})=>{const{t:v}=Qn(),{ThumbsUpIcon:y}=oo(),b=Boolean(g&&g.size>0),w=e("div",o?{className:ML.iconsGridEmptyState,children:e(uo,{})}:{className:ML.iconsGridEmptyState,children:t("div",{className:ML.resultsContainer,children:[e("span",{className:ML.videoIcon,children:e(y,{className:ML.playButton,style:{width:48,height:49,marginBottom:10}})}),e("h1",{className:ML.title,children:v("Millions of icons")}),e("p",{className:ML.subtitle,children:v("Enter a search query and we'll find the perfect icon for you")})]})});return t("div",{id:"iconsScrollableDiv",ref:d,className:ML.iconsGrid,children:[0!==n.length||i?e(lL,{dataLength:n.length,next:l,hasMore:r,scrollableTarget:"iconsScrollableDiv",className:ML.iconsGridInfiniteScroll,loader:e(k,{indicator:DL}),children:e("div",{className:`${ML.iconsGridGrid} ${b?ML.iconsGridShowCheckboxes:""}`,style:{"--icons-grid-min-col":`${Math.max(100,(null!=p?p:50)+48)}px`},children:n.map(n=>{var r,i,o,l,u,d,v,y,b,w,x;return t("div",{style:{border:g&&g.has(n.hash)||s===n.hash?"1px solid #1890ff":"1px solid #f0f0f0",boxShadow:g&&g.has(n.hash)||s===n.hash?"0 0 0 2px rgba(24,144,255,0.2)":"none"},className:ML.iconsGridItem,onClick:()=>{c(n),m&&"family"===a&&m(n.hash)},children:[e("div",{style:{height:null!=p?p:50},className:ML.iconsGridItemThumbnail,children:"family"===a&&f[n.hash]?e("div",{style:{color:null==h?void 0:h.colorHex,"--icon-grad-1":null!==(r=null==h?void 0:h.colorHex)&&void 0!==r?r:"#000","--icon-grad-2":null!==(i=null==h?void 0:h.colorHex2)&&void 0!==i?i:"#ff007a","--icon-color-1":null!==(o=null==h?void 0:h.colorHex)&&void 0!==o?o:"#000","--icon-color-2":null!==(l=null==h?void 0:h.colorHex2)&&void 0!==l?l:"#ff007a","--icon-color-3":null!==(u=null==h?void 0:h.colorHex3)&&void 0!==u?u:"#00C2FF","--icon-stroke-1":null!==(d=null==h?void 0:h.colorHex)&&void 0!==d?d:"#000","--icon-stroke-2":null!==(v=null==h?void 0:h.colorHex2)&&void 0!==v?v:"#ff007a","--icon-stroke-3":null!==(y=null==h?void 0:h.colorHex3)&&void 0!==y?y:"#00C2FF","--icon-fill-1":null!==(b=null==h?void 0:h.colorHex)&&void 0!==b?b:"#000","--icon-fill-2":null!==(w=null==h?void 0:h.colorHex2)&&void 0!==w?w:"#ff007a","--icon-fill-3":null!==(x=null==h?void 0:h.colorHex3)&&void 0!==x?x:"#00C2FF"},dangerouslySetInnerHTML:{__html:f[n.hash]},className:ML.iconsGridItemSvg}):e("img",{src:n.imagePreviewUrl,alt:n.name,style:{maxHeight:null!=p?p:96},className:ML.iconsGridItemImg})}),e("div",{className:ML.iconsGridItemName,title:n.name,children:n.name}),m?e("div",{onClick:e=>{e.stopPropagation()},className:ML.iconsGridCheckbox,children:e(D,{checked:Boolean(g&&g.has(n.hash)),onChange:()=>m(n.hash)})}):null]},n.hash)})})}):w,!i&&r&&n.length>0&&e("div",{style:{height:1},ref:e=>{if(!e||!d.current)return;const t=d.current;t.scrollHeight<=t.clientHeight&&l()}}),i&&0===n.length&&e("div",{className:ML.iconsGridLoading,children:e(k,{indicator:DL})})]})},zL="path|rect|circle|ellipse|polygon|line|polyline|g";function BL(e){const t=e.trim();if(!t||"none"===t||"transparent"===t)return null;if(/^url\(#/.test(t))return null;if(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(t)){const e=t.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/);return e?"#"+(3===e[1].length?e[1].replace(/(.)/g,"$1$1"):e[1]).toLowerCase():null}if(/^rgb\(/.test(t)){const e=t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(e)return"#"+[1,2,3].map(t=>parseInt(e[t],10).toString(16).padStart(2,"0")).join("")}if(/^rgba\(/.test(t)){const e=t.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*[\d.]+\s*\)/);if(e)return"#"+[1,2,3].map(t=>parseInt(e[t],10).toString(16).padStart(2,"0")).join("")}const n={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff"},r=t.toLowerCase();return n[r]?n[r]:("currentcolor"===r||"inherit"===r||/^[a-zA-Z]+$/.test(t),null)}function UL(e,t){const n=new RegExp(`${t}\\s*:\\s*([^;]+)`,"i"),r=e.match(n);return r?r[1].trim():null}function VL(e){let t=0;const n=new RegExp(`<(?:${zL})([^>]*)>`,"gi");let r;for(;null!==(r=n.exec(e));){const e=r[1],n=e.match(/fill\s*=\s*["']([^"']*)["']/i),i=e.match(/style\s*=\s*["']([^"']*)["']/i),o=n&&n[1]&&!/^none$/i.test(n[1])&&!/^url\(#/i.test(n[1]),a=i&&UL(i[1],"fill")&&!/^none$/i.test(UL(i[1],"fill"));(o||a)&&(t+=1)}return t}function HL(e){let t=0;const n=new RegExp(`<(?:${zL})([^>]*)>`,"gi");let r;for(;null!==(r=n.exec(e));){const e=r[1],n=e.match(/stroke\s*=\s*["']([^"']*)["']/i),i=e.match(/style\s*=\s*["']([^"']*)["']/i),o=n&&n[1]&&!/^none$/i.test(n[1])&&!/^url\(#/i.test(n[1]),a=i&&UL(i[1],"stroke")&&!/^none$/i.test(UL(i[1],"stroke"));(o||a)&&(t+=1)}return t}function WL(e){return/<linearGradient/i.test(e)||/<radialGradient/i.test(e)||/fill="url\(#|stroke="url\(#/i.test(e)}function $L(e){const t=e.trim().replace(/(?:px|em|ex|%)\s*$/i,""),n=parseFloat(t);return Number.isNaN(n)||n<=0||n>10?null:Math.round(10*n)/10}function GL(e){const t=[],n=e.indexOf("</defs>"),r=n>=0?e.slice(n):e,i=new RegExp(`<(?:${zL})[^>]*stroke-width\\s*=\\s*["']([^"']+)["']`,"gi");let o;for(;null!==(o=i.exec(r));){const e=$L(o[1]);null!=e&&t.push(e)}const a=new RegExp(`<(?:${zL})[^>]*style\\s*=\\s*["'][^"']*stroke-width\\s*:\\s*([^;"]+)[^"']*["']`,"gi");for(;null!==(o=a.exec(r));){const e=$L(o[1]);null!=e&&t.push(e)}if(0===t.length)return;t.sort((e,t)=>e-t);const s=Math.floor(t.length/2);return t.length%2==1?t[s]:(t[s-1]+t[s])/2}function qL(e){const t=function(e){const t=[],n=new Set;Array.from(e.matchAll(/<stop[^>]*?stop-color\s*=\s*["']([^"']+)["']/gi)).map(e=>e[1]).forEach(e=>{const r=BL(e);r&&!n.has(r)&&(n.add(r),t.push(e))});const r=new RegExp(`<(?:${zL})([^>]*)>`,"gi");let i;for(;null!==(i=r.exec(e));){const e=i[1],r=e.match(/fill\s*=\s*["']([^"']*)["']/i);if(r&&r[1]){const e=BL(r[1]);e&&!n.has(e)&&(n.add(e),t.push(r[1]))}const o=e.match(/stroke\s*=\s*["']([^"']*)["']/i);if(o&&o[1]){const e=BL(o[1]);e&&!n.has(e)&&(n.add(e),t.push(o[1]))}const a=e.match(/style\s*=\s*["']([^"']*)["']/i);if(a&&a[1]){const e=UL(a[1],"fill");if(e){const r=BL(e);r&&!n.has(r)&&(n.add(r),t.push(e))}const r=UL(a[1],"stroke");if(r){const e=BL(r);e&&!n.has(e)&&(n.add(e),t.push(r))}}}const o=e.match(/<svg([^>]*)>/i);if(o&&o[1]){const e=o[1];for(const[r,i]of[["fill",/fill\s*=\s*["']([^"']*)["']/i],["stroke",/stroke\s*=\s*["']([^"']*)["']/i]]){const r=e.match(i);if(r&&r[1]){const e=BL(r[1]);e&&!n.has(e)&&(n.add(e),t.push(r[1]))}}const r=e.match(/style\s*=\s*["']([^"']*)["']/i);if(r&&r[1])for(const e of["fill","stroke"]){const i=UL(r[1],e);if(i){const e=BL(i);e&&!n.has(e)&&(n.add(e),t.push(i))}}}return t}(e);return{colors:t,fillsCount:VL(e),strokesCount:HL(e),hasGradient:WL(e),strokeWidth:GL(e)}}const YL=new Map,XL="https://public-api.streamlinehq.com/v1";function KL(e,t,n,r){const o=i.useMemo(()=>t&&"string"==typeof t?t.replace(/\/$/,""):"/streamline",[t]),a=async e=>n?Promise.resolve(n(e)):e,s=null==r?void 0:r.trim(),l=i.useCallback(async e=>n?a(function(e){const{mode:t,q:n,offset:r,limit:i,familySlug:o,style:a}=e,s=new URLSearchParams;"global"===t&&(s.set("productType","icons"),s.set("productTier","free")),s.set("query",n),s.set("offset",String(r)),s.set("limit",String(i)),a&&s.set("style",a);const l="global"===t?"search/global":`search/family/${encodeURIComponent(o||"")}`;return`${XL}/${l}?${s.toString()}`}(e)):function(e,t){const{mode:n,q:r,offset:i,limit:o,familySlug:a,style:s}=t,l="global"===n?"search/global":`search/family/${encodeURIComponent(a||"")}`,c=new URL(`${e}/${l}`,window.location.origin);return"global"===n&&(c.searchParams.set("productType","icons"),c.searchParams.set("productTier","free")),c.searchParams.set("query",r),c.searchParams.set("offset",String(i)),c.searchParams.set("limit",String(o)),s&&c.searchParams.set("style",s),c.toString().replace(window.location.origin,"")}(o,e),[o,n]),c=i.useCallback(async e=>{var t;const n=await l({mode:e.mode,q:e.query.trim(),offset:e.offset,limit:e.limit,familySlug:e.familySlug,style:null!==(t=e.style)&&void 0!==t?t:null}),r={Accept:"application/json"};s&&(r["x-api-key"]=s);const i=await fetch(n,{method:"GET",headers:r,signal:e.signal});if(!i.ok){const e=await i.text();throw new Error(`Request failed: ${i.status} ${e}`)}return await i.json()},[l,s]),u=i.useCallback((e,t)=>{let n=e;const r=/<linearGradient[\s\S]*?<\/linearGradient>/i.test(n)||/<radialGradient[\s\S]*?<\/radialGradient>/i.test(n);if(!(/fill="url\(#/i.test(n)||/stroke="url\(#/i.test(n))){const e=function(e){var t,n,r,i,o,a,s,l;const c=new Map,u={v:1},d=e=>{const t=BL(e);t&&!c.has(t)&&(c.set(t,u.v),u.v=Math.min(u.v+1,3))},h=e.match(/<svg([^>]*)>/i);if(null==h?void 0:h[1]){const e=h[1],t=e.match(/fill\s*=\s*["']([^"']*)["']/i),n=e.match(/stroke\s*=\s*["']([^"']*)["']/i);!(null==t?void 0:t[1])||/^none$/i.test(t[1])||/^url\(#/i.test(t[1])||d(t[1]),!(null==n?void 0:n[1])||/^none$/i.test(n[1])||/^url\(#/i.test(n[1])||d(n[1])}const f=new RegExp(`<(?:${zL})([^>]*)>`,"gi");let p;for(;null!==(p=f.exec(e));){const e=p[1],c=e.match(/fill\s*=\s*["']([^"']*)["']/i),u=e.match(/style\s*=\s*["']([^"']*)["']/i),h=null===(t=null==u?void 0:u[1])||void 0===t?void 0:t.match(/fill\s*:\s*([^;]+)/i),f=null===(i=null!==(n=null==c?void 0:c[1])&&void 0!==n?n:null===(r=null==h?void 0:h[1])||void 0===r?void 0:r.trim())||void 0===i?void 0:i.trim();!f||/^none$/i.test(f)||/^url\(#/i.test(f)||d(f);const g=e.match(/stroke\s*=\s*["']([^"']*)["']/i),m=e.match(/style\s*=\s*["']([^"']*)["']/i),v=null===(o=null==m?void 0:m[1])||void 0===o?void 0:o.match(/stroke\s*:\s*([^;]+)/i),y=null===(l=null!==(a=null==g?void 0:g[1])&&void 0!==a?a:null===(s=null==v?void 0:v[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();!y||/^none$/i.test(y)||/^url\(#/i.test(y)||d(y)}return c}(n),t=t=>{const n=BL(t),r=n?e.get(n):void 0;return 1===r?"var(--icon-color-1)":2===r?"var(--icon-color-2)":3===r?"var(--icon-color-3)":"currentColor"};n=n.replace(/<svg([^>]*)>/i,(e,n)=>{let r=n;const i=n.match(/fill\s*=\s*["']([^"']*)["']/i);!(null==i?void 0:i[1])||/^none$/i.test(i[1])||/^url\(#/i.test(i[1])||(r=r.replace(/fill\s*=\s*["'][^"']*["']/i,`fill="${t(i[1])}"`));const o=n.match(/stroke\s*=\s*["']([^"']*)["']/i);return!(null==o?void 0:o[1])||/^none$/i.test(o[1])||/^url\(#/i.test(o[1])||(r=r.replace(/stroke\s*=\s*["'][^"']*["']/i,`stroke="${t(o[1])}"`)),`<svg${r}>`}),n=n.replace(/<(path|rect|circle|ellipse|polygon|line|polyline)([^>]*?)(\/>|>)/gi,(e,n,r,i)=>{var o,a,s,l,c,u,d,h;let f=r;const p=r.match(/fill\s*=\s*["']([^"']*)["']/i),g=r.match(/style\s*=\s*["']([^"']*)["']/i),m=null===(o=null==g?void 0:g[1])||void 0===o?void 0:o.match(/fill\s*:\s*([^;]+)/i),v=null===(l=null!==(a=null==p?void 0:p[1])&&void 0!==a?a:null===(s=null==m?void 0:m[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();if(v&&!/^none$/i.test(v)&&!/^url\(#/i.test(v)){const e=t(v);p?f=f.replace(/fill\s*=\s*["'][^"']*["']/i,`fill="${e}"`):(null==g?void 0:g[1])&&(f=f.replace(/style\s*=\s*["']([^"']*)["']/i,(t,n)=>`style="${n.replace(/fill\s*:\s*[^;]+/gi,`fill: ${e}`)}"`))}const y=r.match(/stroke\s*=\s*["']([^"']*)["']/i),b=r.match(/style\s*=\s*["']([^"']*)["']/i),w=null===(c=null==b?void 0:b[1])||void 0===c?void 0:c.match(/stroke\s*:\s*([^;]+)/i),x=null===(h=null!==(u=null==y?void 0:y[1])&&void 0!==u?u:null===(d=null==w?void 0:w[1])||void 0===d?void 0:d.trim())||void 0===h?void 0:h.trim();if(x&&!/^none$/i.test(x)&&!/^url\(#/i.test(x)){const e=t(x);y?f=f.replace(/stroke\s*=\s*["'][^"']*["']/i,`stroke="${e}"`):(null==b?void 0:b[1])&&(f=f.replace(/style\s*=\s*["']([^"']*)["']/i,(t,n)=>`style="${n.replace(/stroke\s*:\s*[^;]+/gi,`stroke: ${e}`)}"`))}return`<${n}${f}${i}`})}return r&&(n=n.replace(/<linearGradient([^>]*?)>([\s\S]*?)<\/linearGradient>/gi,(e,t,n)=>{let r=0;return`<linearGradient${t}>${n.replace(/<stop([^>]*?)>/gi,(e,t)=>{const n=0===r?"var(--icon-grad-1)":"var(--icon-grad-2)";if(r+=1,/stop-color\s*=/.test(t)){return"<stop"+t.replace(/stop-color="[^"]*"/i,'stop-color="'+n+'"')+">"}return"<stop"+t+' stop-color="'+n+'">'})}</linearGradient>`}),n=n.replace(/<radialGradient([^>]*?)>([\s\S]*?)<\/radialGradient>/gi,(e,t,n)=>{let r=0;return`<radialGradient${t}>${n.replace(/<stop([^>]*?)>/gi,(e,t)=>{const n=0===r?"var(--icon-grad-1)":"var(--icon-grad-2)";if(r+=1,/stop-color\s*=/.test(t)){return"<stop"+t.replace(/stop-color="[^"]*"/i,'stop-color="'+n+'"')+">"}return"<stop"+t+' stop-color="'+n+'">'})}</radialGradient>`})),"number"!=typeof(null==t?void 0:t.strokeWidth)||Number.isNaN(t.strokeWidth)||(/stroke-width\s*=\s*["'][^"']*["']/i.test(n)&&(n=n.replace(/stroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${t.strokeWidth}"`)),/stroke-width\s*:/.test(n)&&(n=n.replace(/stroke-width\s*:\s*[^;]+/gi,`stroke-width: ${t.strokeWidth}`)),/stroke-width/i.test(n)||(n=n.replace(/<svg/,`<svg stroke-width="${t.strokeWidth}"`))),n=n.replace(/<svg([^>]*)>/i,(e,t)=>`<svg${t.replace(/\swidth="[^"]*"/i,"").replace(/\sheight="[^"]*"/i,"")} width="100%" height="100%">`),n},[]),d=i.useCallback(async(t,r)=>{const i=[t,e?"css=1":"css=0",(null==r?void 0:r.colors)?`c=${r.colors}`:"",(null==r?void 0:r.backgroundColor)?`bg=${r.backgroundColor}`:"",null!=(null==r?void 0:r.strokeWidth)?`sw=${r.strokeWidth}`:"",null!=(null==r?void 0:r.size)?`s=${r.size}`:"",null!=(null==r?void 0:r.responsive)?`r=${r.responsive}`:"",null!=(null==r?void 0:r.strokeToFill)?`sf=${r.strokeToFill}`:""].filter(Boolean).join("|"),l=YL.get(i);if(l)return l;const c=await(async(e,t)=>{var r,i;const s=new URLSearchParams;(null==t?void 0:t.colors)&&s.set("colors",t.colors),(null==t?void 0:t.backgroundColor)&&s.set("backgroundColor",t.backgroundColor),null!=(null==t?void 0:t.strokeWidth)&&s.set("strokeWidth",String(t.strokeWidth)),s.set("size",String(null!==(r=null==t?void 0:t.size)&&void 0!==r?r:96)),s.set("responsive",String(null===(i=null==t?void 0:t.responsive)||void 0===i||i)),null!=(null==t?void 0:t.strokeToFill)&&s.set("strokeToFill",String(t.strokeToFill));const l=`${XL}/icons/${encodeURIComponent(e)}/download/svg?${s.toString()}`;if(n)return a(l);const c=new URL(`${o}/icons/${encodeURIComponent(e)}/download/svg`,window.location.origin);return s.forEach((e,t)=>c.searchParams.set(t,e)),c.toString().replace(window.location.origin,"")})(t,r),d={Accept:"image/svg+xml"};s&&(d["x-api-key"]=s);const h=await fetch(c,{method:"GET",headers:d,signal:null==r?void 0:r.signal});if(!h.ok){const e=await h.text();throw new Error(`SVG request failed: ${h.status} ${e}`)}let f=await h.text();const p=f;e&&!(null==r?void 0:r.colors)&&(f=u(f,{strokeWidth:null==r?void 0:r.strokeWidth}));const g={text:f,url:`data:image/svg+xml;utf8,${encodeURIComponent(f)}`,original:p};return YL.set(i,g),g},[o,u,e,n,a,s]),h=i.useCallback(async(e,t)=>{const r=await(async(e,t)=>{var r;const i=new URLSearchParams;i.set("size",String(null!==(r=null==t?void 0:t.size)&&void 0!==r?r:96)),(null==t?void 0:t.colors)&&i.set("colors",t.colors),(null==t?void 0:t.backgroundColor)&&i.set("backgroundColor",t.backgroundColor),null!=(null==t?void 0:t.strokeWidth)&&i.set("strokeWidth",String(t.strokeWidth));const s=`${XL}/icons/${encodeURIComponent(e)}/download/png?${i.toString()}`;if(n)return a(s);const l=new URL(`${o}/icons/${encodeURIComponent(e)}/download/png`,window.location.origin);return i.forEach((e,t)=>l.searchParams.set(t,e)),l.toString().replace(window.location.origin,"")})(e,t),i={Accept:"image/png"};s&&(i["x-api-key"]=s);const l=await fetch(r,{method:"GET",headers:i,signal:null==t?void 0:t.signal});if(!l.ok){const e=await l.text();throw new Error(`PNG request failed: ${l.status} ${e}`)}const c=await l.blob();return await new Promise((e,t)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>t(new Error("Failed to read PNG blob")),n.readAsDataURL(c)})},[o,n,a,s]);return{buildUrl:l,performSearch:c,fetchSvgDataUrl:d,fetchPngDataUrl:h,normalizeSvgForCss:u}}const ZL=({apiKey:r,customRequest:o,query:a,setQuery:s,inputRef:l})=>{var c,u,d,h,f,p,g,m,v;const{t:y}=Qn(),[b,w]=i.useState(""),x=void 0!==a?a:b,C=void 0!==s?s:w,[_,S]=i.useState(""),[A,E]=i.useState("global"),[I,P]=i.useState(null),[M,N]=i.useState(null),[D,j]=i.useState(null),[z,B]=i.useState(null),[U,V]=i.useState([]),[H,W]=i.useState(0),[$,G]=i.useState(!1),[Y,X]=i.useState(!1),[Z,J]=i.useState(null),[Q,ee]=i.useState({}),[te,ne]=i.useState({}),[re,ie]=i.useState({}),[ae,se]=i.useState("#000000"),[le,ce]=i.useState("#ff007a"),[ue,de]=i.useState("#00C2FF"),[he,fe]=i.useState(1),[pe,ge]=i.useState(50),[me,ve]=i.useState(!0),[ye,be]=i.useState(!0),[we,xe]=i.useState(!1),Ce=ro(),{options:_e}=Ce,Se=i.useRef(null),ke=i.useRef(!1),Ae=i.useRef(null),Ee=i.useRef(0),Ie=i.useRef(!1),Te=i.useRef(null),Fe=i.useRef(null===(c=null==_e?void 0:_e.config)||void 0===c?void 0:c.handleTranslate),Oe=i.useRef(null===(u=null==_e?void 0:_e.config)||void 0===u?void 0:u.locale);i.useEffect(()=>{var e,t;Fe.current=null===(e=null==_e?void 0:_e.config)||void 0===e?void 0:e.handleTranslate,Oe.current=null===(t=null==_e?void 0:_e.config)||void 0===t?void 0:t.locale},[null===(d=null==_e?void 0:_e.config)||void 0===d?void 0:d.handleTranslate,null===(h=null==_e?void 0:_e.config)||void 0===h?void 0:h.locale]);const Pe=i.useRef(null),Me=i.useRef(null),Re=i.useRef(null),[Le,Ne]=i.useState(new Set),De=null!==(p=null===(f=null==_e?void 0:_e.config)||void 0===f?void 0:f.STREAMLINE_API_KEY)&&void 0!==p?p:"3pAQQzwUNMmcgSr2.f4eb08cd5886d44b1fc6a701a3ba797c",je=null===(g=null==_e?void 0:_e.config)||void 0===g?void 0:g.handleProxyUrl,ze=async e=>je?Promise.resolve(je(e)):e,Be=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{imagePreviewUrl:await ze(e.imagePreviewUrl)}))),{performSearch:Ue,fetchSvgDataUrl:Ve,fetchPngDataUrl:He,normalizeSvgForCss:We}=KL(ye,null===(m=null==_e?void 0:_e.config)||void 0===m?void 0:m.STREAMLINE_BASE_URL,je,De),$e=i.useMemo(()=>{if("family"!==A||0===U.length)return null;const e=new Set(U.map(e=>e.hash)),t=Object.keys(re).some(t=>e.has(t))?re:te,n=U.map(e=>t[e.hash]).filter(e=>Boolean(e));if(0===n.length)return null;return function(e){const t=[],n=new Set;let r,i=0,o=0,a=!1;for(const s of e){i+=s.fillsCount,o+=s.strokesCount,s.hasGradient&&(a=!0);for(const e of s.colors){const r=BL(e);r&&!n.has(r)&&(n.add(r),t.push(e))}null==r&&null!=s.strokeWidth&&(r=s.strokeWidth)}return{colors:t,fillsCount:i,strokesCount:o,hasGradient:a,strokeWidth:r}}(n.map(e=>qL(e)))},[U,A,re,te]);i.useMemo(()=>"family"===A&&(!!(null==$e?void 0:$e.hasGradient)||!!(I||"").toLowerCase().includes("gradient")),[$e,I,A]);const Ge=i.useMemo(()=>"family"===A&&U.some(e=>{const t=te[e.hash];return t&&/var\(--icon-color-2\)/i.test(t)}),[U,A,te]),qe=i.useMemo(()=>"family"===A&&U.some(e=>{const t=te[e.hash];return t&&/var\(--icon-color-3\)/i.test(t)}),[U,A,te]),Ye=i.useMemo(()=>!!ye&&(!!$e&&($e.hasGradient||$e.colors.length>=2&&Ge)),[$e,ye,Ge]),Xe=i.useMemo(()=>!!ye&&(!!$e&&($e.colors.length>=3&&qe)),[$e,ye,qe]);i.useEffect(()=>(ke.current=!0,()=>{var e,t,n;ke.current=!1;try{null===(e=Pe.current)||void 0===e||e.abort(),null===(t=Me.current)||void 0===t||t.abort(),null===(n=Re.current)||void 0===n||n.abort()}catch(e){}}),[]);const Ke=i.useRef(x),Ze=i.useCallback(async e=>{var t,n,r,i,o,a,s,l;const c=null!==(n=null===(t=e.override)||void 0===t?void 0:t.query)&&void 0!==n?n:_;if(!c||0===c.trim().length)return;if(Y)return;if(!ke.current)return;null===(r=Pe.current)||void 0===r||r.abort();const u=new AbortController;Pe.current=u,X(!0);const d=e.initial?0:H,h=e.initial?30:20,f=null!==(o=null===(i=e.override)||void 0===i?void 0:i.mode)&&void 0!==o?o:A,p=null!==(s=null===(a=e.override)||void 0===a?void 0:a.familySlug)&&void 0!==s?s:I,g=c.trim();try{const t=await Ue({mode:f,familySlug:p||null,query:g,offset:d,limit:h,style:D,signal:u.signal});if(!ke.current)return;if(e.initial)V(await Be(t.results));else{const e=await Be(t.results);V(t=>[...t,...e])}G(Boolean(null===(l=t.pagination)||void 0===l?void 0:l.hasMore)),W(d+h)}catch(e){if("AbortError"===(null==e?void 0:e.name))return;console.error(e),oe.error(y("Request error"))}finally{ke.current&&X(!1)}},[_,I,je,U,Y,A,H,Ue,D,y]);i.useEffect(()=>{Te.current=Ze},[Ze]),i.useEffect(()=>{if("family"===A){const e=window.setTimeout(()=>{Ie.current=!1},100);return()=>window.clearTimeout(e)}Ie.current=!1},[A]);const Je=i.useCallback(async e=>{var t;if(!e||0===e.trim().length)return;const n=++Ee.current;let r=e.trim();if(Fe.current)try{r=await Fe.current(e,{locale:Oe.current})}catch(t){console.error("IconsTab: translation error",t),r=e}n===Ee.current&&(E("global"),P(null),B(null),V([]),G(!1),W(0),J(null),Ne(new Set),S(r),await(null===(t=Te.current)||void 0===t?void 0:t.call(Te,{initial:!0,override:{query:r}})))},[]),Qe=i.useCallback(async()=>{x&&0!==x.trim().length&&await Je(x)},[x,Je]),et=i.useCallback(()=>{Ee.current+=1,E("global"),P(null),N(null),B(null),j(null),S(""),V([]),G(!1),W(0),J(null),Ne(new Set),se("#000000"),ce("#ff007a"),de("#00C2FF")},[]);i.useEffect(()=>{const e=Ke.current;e&&e.trim().length>=3&&Je(e)},[]),i.useEffect(()=>{const e=x.trim();Ae.current&&(window.clearTimeout(Ae.current),Ae.current=null),e.length<3?et():Ae.current=window.setTimeout(()=>{Je(e)},700)},[x,D,et,Je]);const tt=i.useCallback(()=>{Ie.current||$&&!Y&&Ze({initial:!1})},[Ze,$,Y]),nt=i.useCallback(e=>{if("global"===A){if(!e.familySlug||!_)return;return Ae.current&&(window.clearTimeout(Ae.current),Ae.current=null),Ie.current=!0,E("family"),P(e.familySlug),N(e.hash),B(e.categoryName||null),V([]),G(!1),W(0),J(null),Ne(new Set),se("#000000"),ce("#ff007a"),de("#00C2FF"),void Ze({initial:!0,override:{mode:"family",familySlug:e.familySlug,query:_}})}J(e.hash)},[_,Ze,A]),rt=i.useCallback(()=>{const e=_.trim();E("global"),P(null),N(null),B(null),V([]),G(!1),W(0),J(null),Ne(new Set),se("#000000"),ce("#ff007a"),de("#00C2FF"),e&&Ze({initial:!0,override:{mode:"global",familySlug:null,query:e}})},[_,Ze]);i.useEffect(()=>{var e;if("family"!==A||0===U.length)return;const t=new Set(U.map(e=>e.hash));let n=U.map(e=>e.hash).filter(e=>!Q[e]||!te[e]);if(!M||t.has(M)||re[M]||(n=[M,...n]),0===n.length)return;let r=!1;null===(e=Me.current)||void 0===e||e.abort();const i=new AbortController;return Me.current=i,Promise.all(n.map(e=>Ve(e,{colors:ye?void 0:ae,strokeWidth:he,size:pe,responsive:me,signal:i.signal}).then(t=>({h:e,r:t})).catch(()=>null))).then(e=>{if(r||!ke.current)return;const t={},n={},i={};e.forEach(e=>{e&&e.h&&e.r&&(t[e.h]=e.r.url,n[e.h]=e.r.text,e.r.original&&(i[e.h]=e.r.original))}),Object.keys(t).length>0&&ee(e=>Object.assign(Object.assign({},e),t)),Object.keys(n).length>0&&ne(e=>Object.assign(Object.assign({},e),n)),Object.keys(i).length>0&&ie(e=>Object.assign(Object.assign({},e),i))}),()=>{r=!0,i.abort()}},[ae,M,Ve,U,A,re,me,pe,he,te,Q,ye]),i.useEffect(()=>{if("family"!==A)return;if(0===U.length)return;const e=U.map(e=>e.hash),t={},n={};let r=!1;e.forEach(e=>{const i=re[e]||te[e];if(!i)return;const o=We(i,{strokeWidth:"number"==typeof he?he:void 0});o&&o!==te[e]&&(t[e]=o,n[e]=`data:image/svg+xml;utf8,${encodeURIComponent(o)}`,r=!0)}),r&&(Object.keys(t).length>0&&ne(e=>Object.assign(Object.assign({},e),t)),Object.keys(n).length>0&&ee(e=>Object.assign(Object.assign({},e),n)))},[U,A,We,re,he,te]);const it=i.useRef(null);i.useEffect(()=>{var e;if("family"!==A||0===U.length)return;const t=M&&re[M]?M:null===(e=U[0])||void 0===e?void 0:e.hash;if(!t||!re[t])return;if(it.current===I)return;const n=re[t];if(!n)return;it.current=I;const r=function(e){var t,n,r,i,o,a,s,l;const c=[],u=new Set,d=e=>{const t=BL(e);t&&!u.has(t)&&(u.add(t),c.push(e))},h=Array.from(e.matchAll(/<stop[^>]*?stop-color\s*=\s*["']([^"']+)["']/gi)).map(e=>e[1]);if(h.length>=2)return h.slice(0,3).forEach(e=>d(e)),c;const f=e.match(/<svg([^>]*)>/i);if(null==f?void 0:f[1]){const e=f[1],t=e.match(/fill\s*=\s*["']([^"']*)["']/i),n=e.match(/stroke\s*=\s*["']([^"']*)["']/i);!(null==t?void 0:t[1])||/^none$/i.test(t[1])||/^url\(#/i.test(t[1])||d(t[1]),!(null==n?void 0:n[1])||/^none$/i.test(n[1])||/^url\(#/i.test(n[1])||d(n[1])}const p=new RegExp(`<(?:${zL})([^>]*)>`,"gi");let g;for(;null!==(g=p.exec(e));){const e=g[1],c=e.match(/fill\s*=\s*["']([^"']*)["']/i),u=e.match(/style\s*=\s*["']([^"']*)["']/i),h=null===(t=null==u?void 0:u[1])||void 0===t?void 0:t.match(/fill\s*:\s*([^;]+)/i),f=null===(i=null!==(n=null==c?void 0:c[1])&&void 0!==n?n:null===(r=null==h?void 0:h[1])||void 0===r?void 0:r.trim())||void 0===i?void 0:i.trim();!f||/^none$/i.test(f)||/^url\(#/i.test(f)||d(f);const p=e.match(/stroke\s*=\s*["']([^"']*)["']/i),m=e.match(/style\s*=\s*["']([^"']*)["']/i),v=null===(o=null==m?void 0:m[1])||void 0===o?void 0:o.match(/stroke\s*:\s*([^;]+)/i),y=null===(l=null!==(a=null==p?void 0:p[1])&&void 0!==a?a:null===(s=null==v?void 0:v[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();!y||/^none$/i.test(y)||/^url\(#/i.test(y)||d(y)}return c.slice(0,3)}(n),i=e=>{const t=(e||"").trim().match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);if(t){return"#"+(3===t[1].length?t[1].replace(/(.)/g,"$1$1"):t[1]).toLowerCase()}return function(e){var t;const n=e.trim();if(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(n)){const e=n.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/);if(e)return"#"+(3===e[1].length?e[1].replace(/(.)/g,"$1$1"):e[1]).toLowerCase()}const r=n.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(r)return"#"+[1,2,3].map(e=>parseInt(r[e],10).toString(16).padStart(2,"0")).join("");const i=n.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*[\d.]+\s*\)/);return i?"#"+[1,2,3].map(e=>parseInt(i[e],10).toString(16).padStart(2,"0")).join(""):null!==(t={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff"}[n.toLowerCase()])&&void 0!==t?t:BL(n)||"#000000"}(e)};r[0]&&se(i(r[0])),r[1]&&ce(i(r[1])),r[2]&&de(i(r[2]))},[U,A,re,I,M]),i.useEffect(()=>{"family"!==A&&(it.current=null)},[A]);const ot=i.useRef(null);i.useEffect(()=>{if("family"!==A||!I||0===U.length)return;const e=U[0];if(!e||!re[e.hash])return;if(ot.current===I)return;const t=re[e.hash];if(!t)return;const n=qL(t);"number"==typeof n.strokeWidth&&n.strokeWidth>0&&(ot.current=I,fe(n.strokeWidth))},[U,A,re,I]),i.useEffect(()=>{"family"!==A&&(ot.current=null)},[A]);const at=i.useCallback(e=>function(e,t){const{colorHex:n,colorHex2:r,colorHex3:i}=t,o=[`--icon-grad-1: ${n}`,`--icon-grad-2: ${r}`,`--icon-stroke-1: ${n}`,`--icon-stroke-2: ${r}`,`--icon-stroke-3: ${i}`,`--icon-fill-1: ${n}`,`--icon-fill-2: ${r}`,`--icon-fill-3: ${i}`,`color: ${n}`].join(";");let a=e.replace(/<svg([^>]*)>/i,(e,t)=>{let n=t;return/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};${o}"`):n+=` style="${o}"`,`<svg${n}>`});return a=a.replace(/var\(--icon-color-1\)/g,n).replace(/var\(--icon-color-2\)/g,r).replace(/var\(--icon-color-3\)/g,i).replace(/var\(--icon-fill-1\)/g,n).replace(/var\(--icon-fill-2\)/g,r).replace(/var\(--icon-fill-3\)/g,i).replace(/var\(--icon-stroke-1\)/g,n).replace(/var\(--icon-stroke-2\)/g,r).replace(/var\(--icon-stroke-3\)/g,i).replace(/var\(--icon-grad-1\)/g,n).replace(/var\(--icon-grad-2\)/g,r).replace(/currentColor/g,n),a}(e,{colorHex:ae,colorHex2:le,colorHex3:ue}),[ae,le,ue]),st=i.useCallback(e=>{Ne(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),lt=i.useCallback(()=>{Ne(new Set)},[]),ct=i.useMemo(()=>{if(1===Le.size){const[e]=Array.from(Le);return U.find(t=>t.hash===e)||null}return 0===Le.size&&Z&&U.find(e=>e.hash===Z)||null},[U,Z,Le]),ut=i.useCallback((e,t="image/png")=>{try{const n=e.split(",");if(n.length<2)return new Blob([],{type:t});const r=n[1]||"",i=atob(r),o=new Array(i.length);for(let e=0;e<i.length;e+=1)o[e]=i.charCodeAt(e);const a=new Uint8Array(o);return new Blob([a],{type:t})}catch(e){return new Blob([],{type:t})}},[]),dt=i.useCallback(async(e,t)=>{try{const n=async e=>{const t="family"===A?at(e):e,n=function(e,t){const n=e.match(/\swidth="([0-9.]+)(px)?"/i),r=e.match(/\sheight="([0-9.]+)(px)?"/i);if(n&&r){const e=parseFloat(n[1]),i=parseFloat(r[1]);if(Number.isFinite(e)&&Number.isFinite(i)&&e>0&&i>0){const n=e/i;return n>=1?{width:t,height:Math.max(1,Math.round(t/n))}:{width:Math.max(1,Math.round(t*n)),height:t}}}const i=e.match(/viewBox="([^"]+)"/i);if(i){const e=i[1].trim().split(/\s+/);if(4===e.length){const n=parseFloat(e[2]),r=parseFloat(e[3]);if(Number.isFinite(n)&&Number.isFinite(r)&&n>0&&r>0){const e=n/r;return e>=1?{width:t,height:Math.max(1,Math.round(t/e))}:{width:Math.max(1,Math.round(t*e)),height:t}}}}return{width:t,height:t}}(t,pe);return async function(e,t,n){const r=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(r);try{const e=new Image;return await new Promise((r,o)=>{e.onload=()=>{const i=document.createElement("canvas"),a=Math.max(1,Math.round(2*t)),s=Math.max(1,Math.round(2*n));i.width=a,i.height=s;const l=i.getContext("2d");l?(l.clearRect(0,0,a,s),l.drawImage(e,0,0,a,s),r(i.toDataURL("image/png"))):o(new Error("Canvas 2D context is not available"))},e.onerror=()=>o(new Error("Failed to load SVG image")),e.src=i})}finally{URL.revokeObjectURL(i)}}(t,n.width,n.height)},r=async e=>{const r=await Ve(e,{colors:ye?void 0:ae,strokeWidth:"number"==typeof he?he:void 0,size:pe,responsive:me,signal:t}),i=r.original||r.text;return n(i)};if("family"!==A)try{return await He(e.hash,{size:pe,colors:ye?void 0:ae,strokeWidth:"number"==typeof he?he:void 0,signal:t})}catch(t){return e.hash?await r(e.hash):null}const i=te[e.hash]||re[e.hash];return i?n(i):e.hash?await r(e.hash):null}catch(e){return null}},[at,ae,Ve,He,A,re,me,pe,he,te,ye]),ht=i.useCallback(async e=>{var t;try{if(!ke.current)return;xe(!0),null===(t=Re.current)||void 0===t||t.abort();const n=new AbortController;Re.current=n;const r=await dt(e,n.signal);if(!ke.current||!r)return;await Promise.resolve(o(r))}catch(e){console.error("IconsTab: insert error",e),oe.error(y("Request error"))}finally{ke.current&&xe(!1)}},[o,dt,y]);i.useCallback(()=>{var e;J(null),lt();const t=null===(e=null==_e?void 0:_e.config)||void 0===e?void 0:e.onClose;"function"==typeof t&&t()},[lt,_e]);const{isCopyIconsModalVisible:ft,isCopyLoading:pt,copyForm:gt,openCopyModal:mt,closeCopyModal:vt,resetAfterClose:yt,handleCopyTreeSelect:bt,handleIconsCopyOk:wt,fetchChildFolders:xt,generateMenuItemsFromFolders:Ct,handleCreateFolderAndCopy:_t}=(({items:e,selectedHashes:t,getPngDataUrlForItem:n,dataUrlToBlob:r,clearSelection:o})=>{const{t:a}=Qn(),{options:s,state:l}=ro(),c=bo(),[u,d]=i.useState(!1),[h]=T.useForm(),[f,p]=i.useState(!1),g=i.useRef(!1),{state:m,actions:{fetchFolders:v,fetchChildFolders:y,handleModalOk:b}}=Ho(),{EmptyFolderIcon:w}=oo(),{activeFormField:x,setActiveFormField:C,generateMenuItemsFromFolders:_}=Gs({folders:Array.isArray(m.folders)?m.folders:[],selectedFolder:l.selectedFolder,EmptyFolderIcon:w,handleCreateFolderModalOk:b,setIsLoading:p,t:a}),S=i.useCallback(async()=>{await v(),d(!0)},[v]),k=i.useCallback(async e=>{e.length>0&&(h.setFieldsValue({targetFolder:e[0]}),x!==e[0].toString()&&C(""))},[x,h,C]),A=i.useCallback(async i=>{var u,d;try{const{dataProviders:d}=s;if(!d||!d.uploadFile&&!d.uploadFiles)return void c.error({id:"FILES_UPLOAD_PROVIDER_NOT_CONFIGURED",message:a("API-endpoint for file upload is not configured"),placement:"bottomRight"});const h=i||(null==l?void 0:l.selectedFolder)||void 0,f=Array.from(t);if(0===f.length)return;const p=null!==(u=d.uploadFile)&&void 0!==u?u:async e=>{var t,n,r;if(!d.uploadFiles)throw new Error("Upload is not supported by data provider");const i=await d.uploadFiles({folderId:e.folderId,items:[{name:e.name,size:e.size,type:e.type,folderId:e.folderId,data:e.data,extension:e.extension}]}),o=null===(t=null==i?void 0:i.detailed)||void 0===t?void 0:t[0];if(!i||!i.success||!o||!1===o.success){const e=(null===(n=null==o?void 0:o.error)||void 0===n?void 0:n.message)||(null===(r=null==i?void 0:i.error)||void 0===r?void 0:r.message)||"Upload failed";throw new Error(e)}return o.data},{successCount:g,failCount:m}=await async function(e){var t;const{hashes:n,items:r,folderId:i,dataProviders:o,getPngDataUrlForItem:a,dataUrlToBlob:s}=e;let l=0,c=0;for(const e of n){const n=r.find(t=>t.hash===e);if(!n){c+=1;continue}const u=await a(n);if(!u){c+=1;continue}const d=`${(null===(t=n.name)||void 0===t?void 0:t.trim())||`icon-${e}`}.png`,h=s(u,"image/png");try{await o.uploadFile({name:d,size:h.size,type:"image/png",folderId:i,data:h,extension:"png"}),l+=1}catch(e){c+=1}}return{successCount:l,failCount:c}}({hashes:f,items:e,folderId:h,dataProviders:{uploadFile:p},getPngDataUrlForItem:n,dataUrlToBlob:r});g>0&&c.success({id:"FILES_COPY_SUCCESS",message:a("Files copied"),placement:"bottomRight",data:{successCount:g,totalCount:f.length,itemIds:f,folderId:null!=h?h:null}}),m>0&&c.error({id:"FILES_COPY_ERROR",message:a("При копировании произошли ошибки"),placement:"bottomRight",data:{failCount:m,totalCount:f.length,itemIds:f,folderId:null!=h?h:null}}),o()}catch(e){console.error(e),c.error({id:"FILES_COPY_ERROR",message:a("При копировании произошли ошибки"),placement:"bottomRight",innerException:e,data:{failCount:Array.from(t).length||0,totalCount:Array.from(t).length||0,itemIds:Array.from(t),folderId:null!==(d=null==l?void 0:l.selectedFolder)&&void 0!==d?d:null}})}},[o,r,n,e,c,s,t,null==l?void 0:l.selectedFolder,a]),E=i.useCallback(()=>{f||g.current||(d(!1),C(""),p(!1))},[f,C]),I=i.useCallback(()=>{C(""),p(!1)},[C]),F=i.useCallback(async e=>{if(!g.current){g.current=!0,p(!0);try{await A(null!=e?e:null),d(!1),C("")}finally{g.current=!1,p(!1)}}},[A,C]),O=i.useCallback(()=>{var e;const t=null!==(e=l.selectedFolder)&&void 0!==e?e:"folders";C(t),h.setFieldsValue({folderName:a("New folder"),targetFolder:t})},[h,l.selectedFolder,C,a]);return{isCopyIconsModalVisible:u,isCopyLoading:f,copyForm:h,openCopyModal:S,closeCopyModal:E,resetAfterClose:I,handleCopyTreeSelect:k,handleIconsCopyOk:F,handleCreateFolderAndCopy:O,fetchChildFolders:y,generateMenuItemsFromFolders:_}})({items:U,selectedHashes:Le,getPngDataUrlForItem:dt,dataUrlToBlob:ut,clearSelection:lt});return t(n,{children:[t("div",{className:`${ML.iconsTab} ${_.trim()?ML.hasSearch:""}`,children:[_.trim()&&(U.length>0||Y)&&Le.size>0?e(n,{children:t("div",{className:ML.iconsHeaderContainer,children:[t("div",{className:ML.iconsHeaderContainerLeft,children:[t(O.Text,{type:"secondary",children:[Le.size," ",y("selected")]}),e(R,{icon:e(bi,{size:16}),onClick:lt,children:y("Deselected")})]}),e(L,{children:e(R,{icon:e(oi,{size:16}),onClick:mt,children:y("Copy to folder")})})]})}):e(LL,{query:x,onQueryChange:C,onSubmit:Qe,styleFilter:D,onStyleChange:j,hasResults:U.length>0||Y,inputRef:l}),"family"===A?e(NL,{mode:A,familySlug:I,categoryName:z,colorHex:ae,setColorHex:se,colorHex2:le,setColorHex2:ce,colorHex3:ue,setColorHex3:de,sizePx:pe,setSizePx:ge,strokeWidth:he,setStrokeWidth:fe,responsiveSvg:me,setResponsiveSvg:ve,useCssColor:ye,setUseCssColor:be,showSecondColor:Ye,showThirdColor:Xe,styleFilter:D,onBack:rt}):null,e(jL,{items:U,hasMore:$,loading:Y,hasQuery:Boolean(_.trim()),mode:A,selectedHash:Z,onLoadMore:tt,onItemClick:nt,onInsert:ht,scrollContainerRef:Se,colorVars:{colorHex:ae,colorHex2:le,colorHex3:ue},svgTextMap:te,previewSize:pe,selectedHashes:Le,onToggleSelect:st}),ct?t("div",{className:ML.iconsBottomBar,children:[e(K,{className:"zero-divider"}),e("div",{className:ML.iconsBottomBarContent,children:e(L,{children:e(R,{size:"large",type:"primary",style:{height:40},loading:we,onClick:()=>ht(ct),children:y("Choose")})})})]}):null]}),e(q,{title:e("div",{className:"modal-title",children:y("Copy to folder")}),open:ft,onCancel:()=>{pt||vt()},maskClosable:!pt,closable:!pt,keyboard:!pt,footer:t("div",{className:Ws.formFooter,children:[t(R,{className:Ws.folderButton,onClick:_t,loading:pt,children:[e(ui,{size:18,strokeWidth:null===(v=_e.config)||void 0===v?void 0:v.iconStrokeWidth}),y("Create folder")]}),e(R,{type:"primary",className:Ws.folderButton,onClick:()=>{vt()},loading:pt,children:y("Done")})]}),afterClose:()=>yt(),children:t("div",{className:ML.copyToFolderModalBody,children:[pt?e("div",{className:ML.copyToFolderModalLoadingOverlay,children:e(k,{size:"large"})}):null,e(T,{form:gt,layout:"vertical",initialValues:{targetFolder:"folders",folderName:y("New folder"),is_force_create:!1},children:t("div",{className:Ws.foldersWrapper,children:[e(T.Item,{name:"targetFolder",rules:[{required:!0,message:y("Select the destination folder")}],className:Ws.formItem,children:e(Vs,{onSelect:bt,generateMenuItems:()=>Ct({targetForm:gt,onTreeSelect:bt,onComplete:wt,actionButtonText:y("Copy here")}),fetchChildFolders:xt,disabledFolders:[],mode:"selection",className:"folderSelectionTree",defaultExpandAll:!0})}),e(T.Item,{name:"folderName",style:{display:"none"},rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(y("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{})}),e(T.Item,{name:"is_force_create",style:{display:"none"},children:e(F,{})})]})})]})})]})},JL=e=>{(null==e?void 0:e.customTheme)&&((e={})=>{const t=document.querySelector("head");if(!t)return;const n=document.createElement("style");if(n.type="text/css",n.dataset.themeVariablesFm="true",n.setAttribute("data-file-manager","true"),Object.entries(e).length){let r="";Object.entries(e).forEach(([e,t])=>{"object"!=typeof t&&(r+=`\t--${e}: ${t};\n`)}),r=`.em-filemanager {\n${r}}`,n.appendChild(document.createTextNode(r));const i=t.querySelector('[data-theme-variables-fm="true"]');i?t.replaceChild(n,i):t.insertBefore(n,t.firstChild)}})(null==e?void 0:e.customTheme)},{Sider:QL,Content:eN}=Q,tN={keywords:""},nN=()=>{var s,l,d;const h=Ho(),f=es(),p=(()=>{var e,t;const{state:n,actions:r,options:i}=ro(),{selectedFolder:o,pathHistory:a,folders:s}=n,{t:l}=Qn(),{setSelectedFolder:u,setPathHistory:d}=r,h=c(()=>{var e;return`em_fm:lastFolder:${(null===(e=null==i?void 0:i.config)||void 0===e?void 0:e.projectId)||"default"}`},[null===(e=null==i?void 0:i.config)||void 0===e?void 0:e.projectId]),f=c((e,t=new Set)=>{if(t.has(e))return console.warn(`Cycle detected in the path to the folder with id=${e}`),[];const n=(Array.isArray(s)?s:[]).find(t=>t.id===e);if(!n)return[];const r=new Set(t);return r.add(e),n.parentId?n.parentId===n.id?(console.warn(`Cycle detected: folder ${n.id} is a parent of itself`),[{id:n.id,name:n.name+" (ошибка)"}]):[...f(n.parentId,r),{id:n.id,name:n.name}]:[{id:n.id,name:n.name}]},[s]),p=c(e=>{var t;if("undefined"==typeof window)return;const n=!0===(null===(t=null==i?void 0:i.config)||void 0===t?void 0:t.rememberLastFolder),r=h();try{if(!n)return void localStorage.removeItem(r);e?localStorage.setItem(r,e):localStorage.removeItem(r)}catch(e){}},[h,null===(t=null==i?void 0:i.config)||void 0===t?void 0:t.rememberLastFolder]),g=c(e=>{if("folders"===e){const e=[{id:"folders",name:l("Folders")}];return null==d||d(e),void(i.onPathChange&&i.onPathChange([]))}const t=(Array.isArray(s)?s:[]).find(t=>t.id===e);if(!t)return void console.warn("⚠️ Folder not found:",e);const n=f(e),r=[{id:"folders",name:l("Folders")},...n];null==d||d(r),i.onPathChange&&i.onPathChange(r.map(e=>e.name))},[s,f,d,i,l]),m=c(e=>{const t="folders"===e?null:e;t!==o&&(null==u||u(t),p(t),g(e))},[p,o,u,g]),v=c(e=>{if(-1===e)null==u||u(null),null==d||d([{id:"folders",name:l("Folders")}]),i.onPathChange&&i.onPathChange([]);else{const t=a.slice(0,e+1),n=t[t.length-1],r="folders"===n.id?void 0:n.id;null==u||u(r||null),null==d||d(t),i.onPathChange&&i.onPathChange(t.map(e=>e.name))}},[i,a,d,u,l]),y=c(e=>{if(!e.isFolder)return;null==u||u(e.id);const t={id:e.id,name:e.name};if(d){const e=[...a,t];d(e)}if(i.onPathChange){const t=[...a.map(e=>e.name),e.name];i.onPathChange(t)}},[i,a,d,u]);return{state:{selectedFolder:o,pathHistory:a},actions:{handleFolderSelect:m,handleBreadcrumbClick:v,handleItemClick:y},selectedFolder:o,pathHistory:a,handleFolderSelect:m,handleBreadcrumbClick:v,handleItemClick:y}})(),g=(()=>{const{state:e,actions:t}=ro(),{pagination:n}=e,{setPagination:r}=t,i=c((e,t)=>{const i=t||n.pageSize;null==r||r({current:e,pageSize:i,total:n.total})},[n.pageSize,n.total,r]);return{state:{pagination:n},actions:{handlePaginationChange:i}}})(),m=(()=>{const[e,t]=r.useState(()=>{const e=localStorage.getItem(ts);return e?Math.max(290,parseInt(e,10)):298}),[n,i]=r.useState(!1),[o,a]=r.useState(!1),[s,l]=r.useState(0),c=r.useCallback(()=>{t(298),localStorage.setItem(ts,298..toString())},[]),u=r.useCallback(n=>{n.preventDefault(),n.stopPropagation(),i(!0),document.body.classList.add("resizing");const r=n.clientX,o=e;let s=o;const c=e=>{e.preventDefault();const n=Math.max(Math.min(o+e.clientX-r,600),290);s=n,t(n),l(e.clientX),a(!0)},u=()=>{i(!1),document.body.classList.remove("resizing"),a(!1),localStorage.setItem(ts,s.toString()),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)},[e]);return r.useEffect(()=>()=>{document.body.classList.remove("resizing")},[]),{sidebarWidth:e,isResizing:n,showResizeGuide:o,resizeGuidePosition:s,handleResizeStart:u,handleDoubleClick:c}})(),v=(()=>{const[e,t]=o([]),[n,r]=o(!1),[i,a]=o(!1),s=u(0),l=u(new Map),d=c(()=>(s.current+=1,`upload_${s.current}_${Date.now()}`),[]),h=c(e=>Co(e.size),[]),f=c((e,n)=>{const i=n.map(t=>({id:d(),folderId:e,name:t.name,size:h(t),status:"uploading",progress:0}));return t(i),r(!0),a(!1),i.map(e=>e.id)},[d,h]),p=c((e,n)=>{const i={id:d(),folderId:e,name:n,size:void 0,status:"uploading",progress:0};return t(e=>[...e,i]),r(!0),a(!1),i.id},[d]),g=c((e,n)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{progress:Math.min(100,Math.max(0,n))}):t))},[]),m=c((e,n)=>{n&&l.current.set(e,n),t(t=>t.map(t=>{if(t.id===e){const e=Object.assign(Object.assign({},t),{status:"success",progress:100});return(null==n?void 0:n.size)&&void 0===t.size&&(e.size=Co(n.size)),e}return t}))},[]),v=c((e,n)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{status:"error",error:n}):t))},[]),y=c(()=>{r(!1),a(!1),setTimeout(()=>{t([]),l.current.clear()},300)},[]),b=c(()=>{a(e=>!e)},[]),w=c(e=>l.current.get(e),[]),x=e.length,C=e.filter(e=>"success"===e.status||"error"===e.status).length;return{uploadFiles:e,isUploadVisible:n,isUploadMinimized:i,totalFiles:x,completedFiles:C,startUpload:f,startUploadByUrl:p,updateProgress:g,markAsSuccess:m,markAsError:v,getUploadedFile:w,closeUpload:y,minimizeUpload:b}})(),y=za(),{deleteItems:b}=Wo(),w=bo(),{t:C}=Qn(),{options:_,state:S,actions:A}=ro(),E=_,I=null==E?void 0:E.onChangeSelection,T=S,F=null==E?void 0:E.config,{dataProviders:O}=E,{form:P,urlForm:M,renameForm:L,moveForm:N,renameFolderForm:D,copyForm:j,isModalVisible:z,isUrlModalVisible:B,isMoveModalVisible:U,isRenameFolderModalVisible:V,isCopyModalVisible:H,isDeleteConfirmVisible:W,folderToRename:$,activeLibraryItem:G}=S,{setIsUrlModalVisible:q,setActiveLibraryItem:Y}=A,{config:X}=_,{DropZoneFileIcon:Z}=oo(),[J,ee]=o(!1),[te,ne]=o(!1),[re,ie]=o(!1),oe=u(0),ae=u(!1);ae.current=te;const se=i.useRef(null),le=i.useRef([]),[ce,ue]=o(!1),[de,he]=o(!1),fe=Wa(e=>e.selectedFiles),pe=Wa(e=>e.clearSelection),ge=Wa(e=>e.syncVisibleFiles),{folders:me,loading:ve}=h.state,{fetchFolders:ye,fetchChildFolders:be,handleCreateFolder:we,handleModalOk:xe,handleModalCancel:Ce,generateMenuItems:_e}=h.actions,Se=(e=>{var t;const{state:n,actions:r,options:i}=ro(),{t:o}=Qn(),a=bo(),{folders:s,folderToRename:l,renameFolderForm:u,isRenameFolderModalVisible:d}=n,{setFolderToRename:h,setIsRenameFolderModalVisible:f}=r,{apiEndpoints:p,dataProviders:g,config:m}=i,v=c(e=>{null==h||h(e),null==f||f(!0);const t=null==s?void 0:s.find(t=>t.id===e);t&&u&&u.setFieldsValue({newFolderName:t.name})},[h,f,s,u]),y=c(()=>{null==f||f(!1),null==h||h(null),null==u||u.resetFields()},[f,h,u]),b=c(async()=>{var t,n;if(l&&u)try{const i=await u.validateFields();if(!(null==i?void 0:i.newFolderName))return void a.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:o("Folder name cannot be empty"),placement:"bottomRight",data:{folderId:l,folderName:null==i?void 0:i.newFolderName,reason:"emptyName"}});if(!1===(null===(t=null==m?void 0:m.features)||void 0===t?void 0:t.enableRenameFolder))return void a.error({id:"FOLDER_RENAME_DISABLED_BY_CONFIG",message:o("Folder rename is disabled by config"),placement:"bottomRight",data:{itemId:null!=l?l:void 0,itemName:null==i?void 0:i.newFolderName}});if(!(null==g?void 0:g.renameFolder))throw new Error(o("renameFolder is not implemented in dataProviders"));const s=await g.renameFolder(l,i.newFolderName.trim());if(!(null==s?void 0:s.id))return void a.error({id:"FOLDER_RENAME_FAILED",message:o("Unexpected response when renaming folder"),placement:"bottomRight",data:{itemId:null!=l?l:void 0,itemName:i.newFolderName,error:{message:"invalidResponse"}}});a.success({id:"FOLDER_RENAME_SUCCESS",message:o("Folder renamed"),placement:"bottomRight",data:{itemId:s.id,itemName:s.name,folderId:null!==(n=s.parentId)&&void 0!==n?n:null}}),y(),await e(),l!==s.id&&r.setSelectedFolder&&r.setSelectedFolder(s.id)}catch(e){console.error("Ошибка при переименовании папки:",e),a.error({id:"FOLDER_RENAME_FAILED",message:o("Failed to rename folder"),placement:"bottomRight",innerException:e,data:{itemId:null!=l?l:void 0,itemName:null==u?void 0:u.getFieldValue("newFolderName"),error:{message:e instanceof Error?e.message:String(e)}}})}},[l,u,p,y,e,o,null===(t=null==m?void 0:m.features)||void 0===t?void 0:t.enableRenameFolder,a]);return{state:{isRenamingFolder:d||!1,folderToRename:l},actions:{showRenameFolderModal:v,handleRenameFolderCancel:y,handleRenameFolderOk:b}}})(ye),{files:ke,loading:Ae,isRenamingFile:Ee,fileToRename:Ie}=f.state,{fetchFiles:Te,handleDeleteFile:Oe,handleDeleteFolder:Pe,handleAddFile:Me,handleAddFileByUrl:Re,showRenameModal:Le,handleRenameCancel:Ne,handleRenameOk:De,handleDroppedFiles:je,showMoveModal:ze,handleMoveCancel:Be,handleMoveOk:Ue,handleCopyOk:Ve,handleCopyCancel:He,showDeleteConfirm:We,handleDeleteConfirmCancel:$e,handleDeleteConfirmOk:Ge}=f.actions,{selectedFolder:qe,pathHistory:Ye}=p.state,{handleFolderSelect:Xe,handleItemClick:Ke}=p.actions,{pagination:Ze}=g.state,Je=yo(Te),{searchTerm:Qe,sortBy:et,sortOrder:tt}=Je.state,{handleSearch:nt,handleSort:rt,handlePaginationChange:it}=Je.actions,ot=c(async()=>{const e=(e=>Mo(e))(Ye||[]);try{await No({options:E,pathFolder:e,dataProviders:null==E?void 0:E.dataProviders})}catch(e){console.error("Cache clear failed:",e)}await ye(),await Te({folderId:qe||"",page:Ze.current,limit:Ze.pageSize,search:Qe,sortBy:et,sortOrder:tt,itemType:"all"})},[Te,ye,E,Ze,Ye,Qe,qe,et,tt]),at=(({files:e,fetchFiles:t,selectedFolder:n})=>{const{t:i}=Qn(),o=bo(),{options:a,actions:s,state:l}=r.useContext(no),{setActiveLibraryItem:c}=s,{activeLibraryItem:u}=l,d=za(),[h,f]=r.useState(!1),[p,g]=r.useState(null),m=r.useCallback(e=>{var t;if(e.type&&e.type.startsWith("image/"))return!0;if(e.extension){const t=e.extension.toLowerCase();return vn.includes(t)}const n=null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase();return!!n&&vn.includes(n)},[]),v=r.useCallback(async(e,t)=>{var n,r;const{dataProviders:o}=a;if(!1===(null===(r=null===(n=a.config)||void 0===n?void 0:n.features)||void 0===r?void 0:r.enableUpdateFile))throw new $o(i("Updating files is disabled by configuration"),"UnsupportedOperation");if(!e.id||!e.thumbnail||!(null==o?void 0:o.updateFile))throw new $o(i("Failed to save changes"),"UnsupportedOperation");const s=(null==t?void 0:t.mimeType)||On(e.thumbnail,e.type),l=Pn(s),c=e.name.lastIndexOf("."),u=`${c>0?e.name.substring(0,c):e.name}.${l}`,d=(null==t?void 0:t.blob)||Nn(e.thumbnail,s);return o.updateFile(e.id,{name:u,type:s,data:d})},[a,i]),y=r.useCallback(async(e,t)=>{var n;if(!e.thumbnail)throw new $o(i("Failed to save changes"),"ValidationError");const r=null!==(n=e.saveWithoutFolder)&&void 0!==n?n:!e.id,o=(null==t?void 0:t.mimeType)||On(e.thumbnail,e.type),a=(null==t?void 0:t.blob)||Nn(e.thumbnail,o),s=new File([a],e.name,{type:o,lastModified:Date.now()}),l=await d.uploadFileWithProvider(s,e.folderId||void 0,void 0,r);if(!l)throw new $o(i("Failed to save image copy"),"FileWriteError");return l},[d,i]),b=r.useCallback(t=>{let n;if(t)n=t;else{const t=Wa.getState().selectedFiles;if(1!==t.size)return;const r=Array.from(t)[0];if(n=e.find(e=>e.id===r),!n||n.isFolder||!m(n))return}c&&c(cn),g(n),f(!0)},[e,m,f,c]),w=r.useCallback(()=>{c&&u===cn&&c(rn),f(!1),g(null)},[u,c]),x=r.useCallback(async(e,r)=>{var s,l,c,u,d,h;try{const c=await v(e,r);return o.success({id:"IMAGE_UPDATE_SUCCESS",message:i("Success"),description:i("Image updated successfully"),placement:"bottomRight",data:{itemId:null!==(s=null==c?void 0:c.id)&&void 0!==s?s:void 0,itemName:null==c?void 0:c.name,folderId:null!==(l=null==c?void 0:c.folderId)&&void 0!==l?l:null,thumbnail:null==c?void 0:c.thumbnail}}),c&&a.onEditorOk&&a.onEditorOk(c),await t({folderId:n||""}),w(),null!=c?c:void 0}catch(t){const n=Io(t),r=null!==(u=null!==(c=Ao(null==n?void 0:n.code,i))&&void 0!==c?c:null==n?void 0:n.message)&&void 0!==u?u:i("Failed to save changes");throw o.error({id:"IMAGE_SAVE_FAILED",message:r,innerException:t,placement:"bottomRight",data:{itemId:null!==(d=e.id)&&void 0!==d?d:void 0,itemName:e.name,folderId:null!==(h=e.folderId)&&void 0!==h?h:null,thumbnail:e.thumbnail}}),t.notificationShown=!0,t}},[v,a,t,n,o,w,i]),C=r.useCallback(async(e,r)=>{var s,l,c,u,d,h;try{const c=await y(e,r);return o.success({id:"IMAGE_SAVE_COPY_SUCCESS",message:i("Success"),description:i("Image copy saved successfully"),placement:"bottomRight",data:{itemId:null!==(s=null==c?void 0:c.id)&&void 0!==s?s:void 0,itemName:null==c?void 0:c.name,folderId:null!==(l=null==c?void 0:c.folderId)&&void 0!==l?l:null,thumbnail:null==c?void 0:c.thumbnail}}),c&&a.onEditorOk&&a.onEditorOk(c),await t({folderId:n||""}),w(),null!=c?c:void 0}catch(t){const n=Io(t),r=null!==(u=null!==(c=Ao(null==n?void 0:n.code,i))&&void 0!==c?c:null==n?void 0:n.message)&&void 0!==u?u:i("Failed to save image copy");throw o.error({id:"IMAGE_SAVE_COPY_FAILED",message:r,innerException:t,placement:"bottomRight",data:{itemId:null!==(d=e.id)&&void 0!==d?d:void 0,itemName:e.name,folderId:null!==(h=e.folderId)&&void 0!==h?h:null,thumbnail:e.thumbnail}}),t.notificationShown=!0,t}},[y,a,t,n,o,w,i]);return{isPixieEditorVisible:h,editingFile:p,handleEdit:b,handlePixieEditorSave:x,handlePixieEditorSaveCopy:C,handlePixieEditorClose:w}})({files:ke||[],fetchFiles:Te,selectedFolder:qe||null}),[st,lt]=o(!1),ct=c(e=>{if(e.preventDefault(),e.stopPropagation(),!e.dataTransfer||!e.dataTransfer.types||!e.dataTransfer.types.includes("Files"))return;e.dataTransfer.dropEffect="copy";const t=e.relatedTarget,n=e.currentTarget;t&&n.contains(t)||(oe.current+=1,oe.current>0&&ee(!0))},[]),ut=c(e=>{e.preventDefault(),e.stopPropagation();const t=e.relatedTarget,n=e.currentTarget;if(t&&!n.contains(t))oe.current=Math.max(0,oe.current-1),oe.current<=0&&ee(!1);else if(t){const e=t.closest('[class*="dragOverlay"]');if(e&&n.contains(e))return}},[]),dt=c(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},[]),ht=c(e=>{e.preventDefault(),e.stopPropagation(),ee(!1),oe.current=0;const t=(()=>{var t;const n=e.dataTransfer;if(!n)return[];if(null===(t=n.files)||void 0===t?void 0:t.length)return Array.from(n.files);const r=[];if(n.items)for(let e=0;e<n.items.length;e++){const t=n.items[e].getAsFile();t&&r.push(t)}return r})();t.length&&(lt(!0),je(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error("Ошибка при загрузке файлов:",e)}).finally(()=>{lt(!1)}))},[je]),ft=c(()=>{ee(!1),oe.current=0,document.body.removeAttribute("data-fm-dragging"),ie(!1),ne(!1)},[]);i.useEffect(()=>{le.current=ke||[]},[ke]);const pt=null==T?void 0:T.activeLibraryItem;a(()=>{const e=e=>{e?document.body.setAttribute("data-fm-dragging","true"):document.body.removeAttribute("data-fm-dragging")};let t=!1;const n=n=>{var r,i;!t&&(null===(i=null===(r=n.dataTransfer)||void 0===r?void 0:r.types)||void 0===i?void 0:i.includes("Files"))&&(t=!0,ie(!0),e(!0),pt===rn&&ne(!0))},r=n=>{const r=n.relatedTarget;(!r||!document.documentElement.contains(r))&&t&&(t=!1,ie(!1),ne(!1),e(!1))};return window.addEventListener("dragenter",n,!0),window.addEventListener("dragleave",r,!0),()=>{window.removeEventListener("dragenter",n,!0),window.removeEventListener("dragleave",r,!0),document.body.removeAttribute("data-fm-dragging")}},[pt]),a(()=>{const e=e=>{var t,n;if(document.body.removeAttribute("data-fm-dragging"),ie(!1),!(null===(n=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===n?void 0:n.includes("Files")))return;e.preventDefault();const r=(e=>{var t;if(!e)return[];if(null===(t=e.files)||void 0===t?void 0:t.length)return Array.from(e.files);const n=[];if(e.items)for(let t=0;t<e.items.length;t++){const r=e.items[t].getAsFile();r&&n.push(r)}return n})(e.dataTransfer);if(!r.length)return;const i=e.target,o=i.closest(`.${rs.filesContainer.replace(/\s+/g,".")}`)||i.closest("[data-files-container]"),a=i.closest(".em-filemanager")||i.closest(".file-manager__layout")||i.closest("[data-drop-overlay]")||i.closest("[data-drag-capture]");(ae.current||J||o||a)&&(e.preventDefault(),e.stopPropagation(),ne(!1),ee(!1),oe.current=0,lt(!0),je(r).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error("Ошибка при загрузке файлов:",e)}).finally(()=>lt(!1)))},t=e=>{var t,n;(null===(n=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===n?void 0:n.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",document.body.hasAttribute("data-fm-dragging")||(document.body.setAttribute("data-fm-dragging","true"),ie(!0)),pt!==rn||ae.current||ne(!0))},n=e=>{var t,n;(null===(n=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===n?void 0:n.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",document.body.setAttribute("data-fm-dragging","true"),ie(!0))},r={capture:!0,passive:!1};return window.addEventListener("drop",e,r),window.addEventListener("dragover",t,r),window.addEventListener("dragenter",n,r),()=>{window.removeEventListener("drop",e,r),window.removeEventListener("dragover",t,r),window.removeEventListener("dragenter",n,r)}},[J,je,pt]),a(()=>{const e=e=>{J&&ft(),ne(!1),ie(!1),document.body.removeAttribute("data-fm-dragging")};return window.addEventListener("dragend",e,!0),()=>window.removeEventListener("dragend",e,!0)},[J,ft]),a(()=>{let e=null;const t=t=>{J&&(e=setTimeout(()=>{J&&ft()},200))};return document.addEventListener("mouseup",t,!0),()=>{document.removeEventListener("mouseup",t,!0),e&&clearTimeout(e)}},[J,ft]),a(()=>{const e=e=>{"Escape"===e.key&&J&&ft()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[J,ft]),a(()=>{const e=e=>{J&&setTimeout(()=>{J&&ft()},100)};return document.addEventListener("click",e,!0),()=>{document.removeEventListener("click",e,!0)}},[J,ft]);const gt=i.useCallback(async()=>{await Ge(),await ye(),qe===un&&be&&await be(un),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var e,t;return null===(t=null===(e=se.current)||void 0===e?void 0:e.refreshFileCounts)||void 0===t?void 0:t.call(e)})})},[ye,be,Ge,qe]),mt=i.useCallback(()=>{he(!0)},[]),vt=i.useCallback(async()=>{var e,t;if(qe!==un)return console.error("Clear trash called outside of trash folder"),void he(!1);try{if(null==O?void 0:O.cleanTrash){const t=await O.cleanTrash();await Te({folderId:un}),await(null===(e=se.current)||void 0===e?void 0:e.refreshFileCounts()),t.success?w.success({id:"TRASH_CLEARED_SUCCESS",message:C("Trash cleared successfully"),description:C("{{count}} items permanently deleted",{count:t.deletedCount||0}),placement:"bottomRight"}):w.error({id:"TRASH_CLEAR_FAILED",message:C("Failed to clear trash"),placement:"bottomRight"})}else{const e=le.current||[];if(0===e.length)return void he(!1);const n=e.map(e=>({id:e.id,isFolder:e.isFolder})),r=await b({items:n,selectedFolder:un,getItemNameById:t=>{var n;return(null===(n=e.find(e=>e.id===t))||void 0===n?void 0:n.name)||t||""},showNotifications:!1});await Te({folderId:un}),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts());const{successCount:i,failCount:o}=r;0===o?w.success({id:"TRASH_CLEARED_SUCCESS",message:C("Trash cleared successfully"),description:C("{{count}} items permanently deleted",{count:i}),placement:"bottomRight"}):i>0?w.warning({id:"TRASH_CLEARED_PARTIAL",message:C("Trash partially cleared"),description:C("{{succeeded}} items deleted, {{failed}} items failed",{succeeded:i,failed:o}),placement:"bottomRight"}):w.error({id:"TRASH_CLEAR_FAILED",message:C("Failed to clear trash"),placement:"bottomRight"})}he(!1)}catch(e){console.error("Error clearing trash:",e),w.error({id:"TRASH_CLEAR_ERROR",message:C("Error clearing trash"),placement:"bottomRight"}),he(!1)}},[qe,O,Te,w,C,b]),yt=i.useCallback(()=>{he(!1)},[]),bt=i.useCallback(async e=>{var t;await Ue(e),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())},[Ue]),wt=i.useCallback(async e=>{var t;await Ve(e),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())},[Ve]),xt=i.useCallback(async()=>{let e=[],t=new Map;const n=null==E?void 0:E.config;await Me({onStartBatch:r=>{e=v.startUpload(qe||void 0,r),t=new Map,r.forEach((r,i)=>{const o=e[i];o&&(t.set(r.name,o),t.set(Uo(r.name,n),o))})},onStart:r=>{if(0===e.length){e=v.startUpload(qe||void 0,[r]);const i=e[0];i&&(t.set(r.name,i),t.set(Uo(r.name,n),i))}},onProgress:(e,n)=>{const r=t.get(e);r&&v.updateProgress(r,n)},onComplete:async e=>{var n;const r=t.get(e);if(r){await new Promise(e=>setTimeout(e,100));const t=null==ke?void 0:ke.find(t=>t.name===e&&!t.isFolder);v.markAsSuccess(r,t)}await(null===(n=se.current)||void 0===n?void 0:n.refreshFileCounts())},onError:(n,r,i)=>{var o;const a=null!==(o=t.get(n))&&void 0!==o?o:null!=i&&i<e.length?e[i]:void 0;a&&v.markAsError(a,r)},onBatchComplete:async n=>{var r,i,o,a,s,l,c,u;for(let u=0;u<n.successes.length;u++){const d=n.successes[u],h=null===(r=n.uploadedFiles)||void 0===r?void 0:r.get(d),f=null!==(a=null!==(o=null!==(i=t.get(d))&&void 0!==i?i:(null==h?void 0:h.originalFileName)?t.get(h.originalFileName):void 0)&&void 0!==o?o:null!=(null==h?void 0:h.originalIndex)&&h.originalIndex<e.length?e[h.originalIndex]:void 0)&&void 0!==a?a:u<e.length?e[u]:void 0;if(f){let e;if(null==h?void 0:h.id){const t=h;e={id:t.id,name:null!==(s=t.name)&&void 0!==s?s:d,folderId:null!==(c=null!==(l=t.folderId)&&void 0!==l?l:qe)&&void 0!==c?c:null,isFolder:!1,size:t.size}}else await new Promise(e=>setTimeout(e,100)),e=null==ke?void 0:ke.find(e=>e.name===d&&!e.isFolder);v.updateProgress(f,100),v.markAsSuccess(f,e)}}n.errors.forEach(({fileName:e,error:n})=>{const r=t.get(e);r&&v.markAsError(r,n)}),await(null===(u=se.current)||void 0===u?void 0:u.refreshFileCounts())}})},[Me,v,ke,qe,null==E?void 0:E.config]),Ct=i.useCallback(async(e,t,n,r)=>{var i,o;try{ue(!0);let a=n||"uploaded-file";if(!n&&e){const t=e.split("?")[0].split("#")[0].split("/");a=t[t.length-1]||"uploaded-file";a.includes(".")&&(null===(i=a.split(".").pop())||void 0===i?void 0:i.length)&&a.split(".").pop().length<=5||(a+=".jpg")}const s=v.startUploadByUrl(qe||void 0,a);try{const n=await Re(e,t,!0,null!=r?r:"uploadByUrl");if(v.updateProgress(s,100),n){await new Promise(e=>setTimeout(e,100));const e=(null==ke?void 0:ke.find(e=>e.id===n.id&&!e.isFolder))||n;v.markAsSuccess(s,e)}else v.markAsSuccess(s);await(null===(o=se.current)||void 0===o?void 0:o.refreshFileCounts())}catch(e){const t=Io(e),n=Po(t,C);v.markAsError(s,n)}}finally{ue(!1)}},[Re,v,qe,ke,C]),_t=i.useCallback(async({file:e})=>{var t;const n=v.startUpload(qe||void 0,[e])[0];let r=0;const i=setInterval(()=>{r=Math.min(r+10+Math.floor(Date.now()%10),90),v.updateProgress(n,r)},200);try{const r=await y.uploadFileWithProvider(e,void 0,!0);if(clearInterval(i),v.updateProgress(n,100),r){await new Promise(e=>setTimeout(e,100));const e=(null==ke?void 0:ke.find(e=>e.id===r.id&&!e.isFolder))||r;v.markAsSuccess(n,e)}else v.markAsSuccess(n);const o=r&&r.folderId||qe||null;return Xe&&Xe(o&&"folders"!==o?o:"folders"),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts()),r}catch(e){clearInterval(i);const t=e instanceof Error?e.message:String(e);throw v.markAsError(n,t),e}},[y,v,qe,ke,Xe]),St=i.useCallback(async e=>{var t;if(je){const n=v.startUpload(qe||void 0,e);e.forEach(async(e,t)=>{const r=n[t];if(!r)return;let i=0;const o=setInterval(()=>{i=Math.min(i+10+Math.floor(Date.now()%10),85),v.updateProgress(r,i)},200);setTimeout(()=>{clearInterval(o)},2e3)}),await je(e),n.forEach(e=>{v.updateProgress(e,100),v.markAsSuccess(e)}),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())}},[je,v,qe]),kt=i.useCallback(async e=>{var t;await Pe(e),await ye(),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())},[Pe,ye]),At=(({files:e,clearSelection:t,showRenameModal:n,showMoveModal:i,showCopyModal:o,handleDeleteFile:a,handleDeleteFolder:s,showDeleteConfirm:l,onEdit:c})=>{const u=r.useCallback(()=>{t()},[t]),d=r.useCallback(e=>{const t=Wa.getState().selectedFiles;if(t&&1===t.size||e){const r=e||Array.from(t)[0];n(r)}},[n]),h=r.useCallback(t=>{const n=Wa.getState().selectedFiles;if(n&&n.size>0||(null==t?void 0:t.id)){if(l)return void l();(t?[t.id]:n).forEach(t=>{const n=e.find(e=>e.id===t);n?n.isFolder?s(t):a(t):console.warn(`Объект с ID ${t} не найден в списке файлов`)})}},[e,a,s,l]);return{handleClearSelection:u,handleRename:d,handleDeleteSelected:h,handleCopy:r.useCallback(()=>{o()},[o]),handleMove:r.useCallback(()=>{i()},[i]),handleEdit:r.useCallback(()=>{c()},[c])}})({files:ke||[],clearSelection:pe,showRenameModal:Le,showMoveModal:ze,showCopyModal:f.actions.showCopyModal||(()=>{}),handleDeleteFile:Oe,handleDeleteFolder:kt,showDeleteConfirm:We,onEdit:at.handleEdit}),Et=ve||Ae||st;a(()=>{En()},[]),x(()=>{G!==rn?pe():ge(ke||[])},[G,ke,ge,pe]),a(()=>{if(!I||G!==rn)return;if(!dn.current)return void(dn.current=!0);const e=(Array.isArray(ke)?ke:[]).filter(e=>fe.has(e.id));I(e)},[G,ke,fe,I]),i.useEffect(()=>{if(!Xe||0===me.length)return;const e=!1!==(null==F?void 0:F.rememberLastFolder),t=`em_fm:lastFolder:${(null==F?void 0:F.projectId)||"default"}`;if(e&&"undefined"!=typeof window)try{const e=localStorage.getItem(t),n=e&&me.some(t=>t.id===e);if(n)return void Xe(e)}catch(e){}qe||Xe("folders")},[qe,Xe,me,null==F?void 0:F.rememberLastFolder,null==F?void 0:F.projectId]);const{handleRenameFolderCancel:It,handleRenameFolderOk:Tt}=Se.actions;a(()=>{const e=async e=>{if(G!==rn)return;const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||"true"===(null==t?void 0:t.getAttribute("contenteditable")))return;const n=e.clipboardData;if(!n)return;const r=Array.from(n.items),i=r.filter(e=>e.type.startsWith("image/"));if(i.length>0){const t=i.map(e=>e.getAsFile()).filter(e=>null!==e);return void(t.length>0&&(e.preventDefault(),await St(t)))}const o=r.find(e=>"text/plain"===e.type);o&&o.getAsString(async t=>{const n=t.trim();if(n.startsWith("http://")||n.startsWith("https://"))e.preventDefault(),await Ct(n);else if(n.includes("<meta")||n.includes("http")){const t=n.match(/https?:\/\/[^\s"']+/);t&&(e.preventDefault(),await Ct(t[0]))}})};return document.addEventListener("paste",e),()=>{document.removeEventListener("paste",e)}},[G,Ct,St]);const Ft=u(Ze);a(()=>{Ft.current=Ze},[Ze]);const Ot=c(e=>{it(e.current||Ft.current.current,e.pageSize||Ft.current.pageSize)},[it]),Pt=c(e=>{null==Ke||Ke(e)},[Ke]),Mt=i.useCallback(e=>{const{sortBy:t,sortOrder:n}=(e=>{const[t,n]=e.split("-");return{sortBy:t,sortOrder:n}})(e);rt(t,n)},[rt]),[Rt,Lt]=o(tN),[Nt,Dt]=o([]),jt=u(null),[zt,Bt]=o(wn),[Ut,Vt]=o([]),Ht=u(null),[Wt,$t]=o(""),Gt=u(null),[qt,Yt]=o(""),[Xt,Kt]=o([]),Zt=i.useRef(void 0),[Jt,Qt]=o(!1),[en,tn]=o(!1),nn=i.useRef(null),dn=i.useRef(!1),hn=i.useRef(G),fn=i.useCallback(e=>{const t=e.indexOf(",");if(-1===t)return null;const n=e.substring(0,t),r=n.match(/^data:([^;]+)/),i=r&&r[1]||"image/svg+xml";let o,a="svg";if(i.includes("png")?a="png":(i.includes("jpeg")||i.includes("jpg"))&&(a="jpg"),/;base64/i.test(n)){const n=e.substring(t+1),r=atob(n),a=new Uint8Array(r.length);for(let e=0;e<r.length;e+=1)a[e]=r.charCodeAt(e);o=new Blob([a],{type:i})}else{const n=decodeURIComponent(e.substring(t+1));o=new Blob([n],{type:i})}return new File([o],`icon_${Date.now()}.${a}`,{type:i})},[]),pn=i.useCallback(async e=>{var t;const n=v.startUpload(qe||void 0,[e])[0];let r=0;const i=setInterval(()=>{r=Math.min(r+10+Math.floor(Date.now()%10),90),v.updateProgress(n,r)},200);try{const r=await y.uploadFileWithProvider(e,void 0,!0);if(clearInterval(i),v.updateProgress(n,100),r){await new Promise(e=>setTimeout(e,100));const e=(null==ke?void 0:ke.find(e=>e.id===r.id&&!e.isFolder))||r;v.markAsSuccess(n,e)}else v.markAsSuccess(n);await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())}catch(e){clearInterval(i);const t=e instanceof Error?e.message:String(e);throw v.markAsError(n,t),e}},[v,ke,y,qe]),gn=c(async e=>{if(Boolean(e&&e.startsWith("data:"))){const t=fn(e);if(!t)return;return void await pn(t)}e&&await Ct(e,void 0,void 0,"iconStock")},[fn,Ct,pn]),mn=c(async()=>{const e=null==X?void 0:X.fileForEdit;if(Zt.current===e)return;if(G===cn&&e&&!at.editingFile){Zt.current=e;try{if("string"==typeof e){if(e.startsWith("data:"))return void(null==at||at.handleEdit({thumbnail:e,saveWithoutFolder:!0}));const t=await y.resolveFileForEditByUrl(e);Zt.current===e&&(null==at||at.handleEdit(t))}}catch(t){Zt.current===e&&(Zt.current=null),console.error("Failed to open file in editor:",t),null==at||at.handlePixieEditorClose()}}},[null==X?void 0:X.fileForEdit,G,at,y]);a(()=>{mn()},[mn]),a(()=>{var e,t,n,r;const i=hn.current;hn.current=G,G===rn?(Dt([]),Lt(tN),Vt([]),Bt(wn),Kt([]),Yt(""),tn(!1),Qt(!1),i===rn||i!==an&&i!==on&&i!==ln||nt("")):G===ln?null===(e=nn.current)||void 0===e||e.focus():G===on?null===(t=jt.current)||void 0===t||t.focus():G===an?null===(n=Ht.current)||void 0===n||n.focus():G===sn&&(null===(r=Gt.current)||void 0===r||r.focus())},[G,nt]);const bn=i.useCallback(async()=>{var e;await Tt(),await(null===(e=se.current)||void 0===e?void 0:e.refreshFileCounts())},[Tt]),xn=fe.size,Cn=i.useMemo(()=>{var e,t,n;if(1!==xn)return!1;const[r]=Array.from(fe),i=ke.find(e=>e.id===r);if(!i||i.isFolder)return!1;const o="string"==typeof i.name?i.name:"",a=o?null===(e=o.split(".").pop())||void 0===e?void 0:e.toLowerCase():void 0,s=null!==(n=null===(t=i.extension)||void 0===t?void 0:t.toLowerCase())&&void 0!==n?n:a;return"string"==typeof i.type&&i.type.startsWith("image/")||"string"==typeof s&&yn.includes(s)},[xn,fe,ke]),_n=c(e=>{var t;return e?(null===(t=e.files)||void 0===t?void 0:t.length)?Array.from(e.files):e.items?Array.from(e.items).map(e=>e.getAsFile()).filter(e=>Boolean(e)):[]:[]},[]);return t(n,{children:[re&&pt===rn&&Fe(e("div",{className:rs.dragCaptureLayer,"data-drag-capture":"true",onDragOver:e=>{var t,n;e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),(null===(n=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===n?void 0:n.includes("Files"))&&!ae.current&&ne(!0)},onDragEnter:e=>{var t,n;e.preventDefault(),e.stopPropagation(),(null===(n=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===n?void 0:n.includes("Files"))&&ne(!0)},onDragLeave:e=>{const t=e.relatedTarget;t&&document.documentElement.contains(t)||(ne(!1),ie(!1),document.body.removeAttribute("data-fm-dragging"))},onDrop:e=>{e.preventDefault(),e.stopPropagation(),ie(!1),ne(!1),document.body.removeAttribute("data-fm-dragging");const t=_n(e.dataTransfer);t.length&&(lt(!0),je(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error(e)}).finally(()=>lt(!1)))},"aria-hidden":"true"}),document.body),te&&Fe(e("div",{className:rs.dragOverlayGlobal,"data-drop-overlay":"true",onDragOver:e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},onDragEnter:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),e.stopPropagation(),ne(!1),ie(!1),document.body.removeAttribute("data-fm-dragging");const t=_n(e.dataTransfer);t.length&&(lt(!0),je(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error(e)}).finally(()=>lt(!1)))},"aria-hidden":"true",children:t("div",{className:rs.dragOverlayInner,children:[e("div",{className:rs.uploadIcon,children:e(Z,{})}),e("div",{className:rs.textTitle,children:C("Drop files here to upload")}),e("div",{className:rs.textDescription,children:C("Supported files:")+" .jpg, .jpeg, .svg, .png"})]})}),document.body),e(Q,{className:"file-manager__layout",children:t("div",{className:rs.filesContainer,"data-files-container":"true",onDragOver:dt,onDragLeave:ut,onDragEnter:ct,onDrop:ht,children:[J&&e("div",{className:rs.dragOverlay,children:t("div",{className:rs.dragOverlayInner,children:[e("div",{className:rs.uploadIcon,children:e(Z,{})}),e("div",{className:rs.textTitle,children:C("Drop files here to upload")}),e("div",{className:rs.textDescription,children:C("Supported files:")+" .jpg, .jpeg, .svg, .png"})]})}),m.showResizeGuide&&e("div",{className:"resize-guide",style:{left:`${m.resizeGuidePosition}px`}}),t(Q,{className:"file-manager__content",children:[t(QL,{width:320,theme:"light",className:"file-manager-sider",children:[e(Ks,{ref:se,selectedFolder:qe||"folders",generateMenuItems:_e,onFolderSelect:e=>null==Xe?void 0:Xe(e),folders:me||[],fetchFolders:ye,fetchChildFolders:be,handleAddFile:xt,setIsUrlModalVisible:e=>null==q?void 0:q(e),handleDeleteFolder:kt,handleCreateFolder:we,activeLibraryItem:G,setActiveLibraryItem:e=>null==Y?void 0:Y(e)}),e("div",{className:"sidebar-resizer "+(m.isResizing?"resizing":""),onMouseDown:m.handleResizeStart,onDoubleClick:m.handleDoubleClick,children:e("div",{className:"sidebar-resizer-indicator"})})]}),t(Q,{className:"file-manager__main-content",children:[st&&e(Hs,{style:{position:"absolute",width:"100%",height:"100%",top:0,left:0,zIndex:100,background:"var(--colorBgLayout)"}}),t(eN,{className:"main-content",children:[e(tL,{activeLibraryItem:G,selectedFolder:(null===(s=null==me?void 0:me.find(e=>(null==e?void 0:e.id)===qe))||void 0===s?void 0:s.name)||C("Folders"),isTrashFolder:"Trash"===qe,onClearTrash:mt,files:ke||[],loading:Et,onRefresh:ot,refreshDisabled:Ae||ve,showRefresh:!(!(null===(l=null==E?void 0:E.apiEndpoints)||void 0===l?void 0:l.clearCache)&&!(null===(d=null==E?void 0:E.dataProviders)||void 0===d?void 0:d.clearCache))}),e(K,{className:"zero-divider"}),G===rn&&e(Ps,{searchTerm:Qe,handleAddFile:xt,files:ke||[],handleSearch:nt,sortBy:et,sortOrder:tt,handleSortOptionChange:Mt,pagination:Ze,setPagination:Ot,loading:Et,handleItemClick:Pt,onClearSelection:At.handleClearSelection,onRename:At.handleRename,onCopy:At.handleCopy,onMove:At.handleMove,onDelete:At.handleDeleteSelected,showRenameModal:Le,showDeleteConfirm:We,showCopyModal:f.actions.showCopyModal||(()=>{}),showMoveModal:ze,onEdit:at.handleEdit,getFileData:y.getFileData}),G===on&&e(yL,{imageGifList:Nt,setImageGifList:Dt,currentReqGif:Rt,setCurrentReqGif:Lt,inputRef:jt,customRequest:(e,t)=>Ct(e,void 0,t,"gif")}),G===an&&e(CL,{imageStockList:Ut,setImageStockList:Vt,currentReq:zt,setCurrentReq:Bt,inputRef:Ht,customRequest:(e,t)=>Ct(e,void 0,t,"imageStock")}),G===sn&&e(ZL,{apiKey:null==X?void 0:X.STREAMLINE_API_KEY,customRequest:gn,query:Wt,setQuery:$t,inputRef:Gt}),G===ln&&!!(null==X?void 0:X.sseQuery)&&e(PL,{imageAiList:Xt,setImageAiList:Kt,aiImageRequest:qt,setAiImageRequest:Yt,inputAiRef:nn,customRequest:_t,isLoadingAi:Jt,setIsLoadingAi:Qt,isImageUploaded:en,setIsImageUploaded:tn}),G===cn&&e(n,{}),e(n,{children:Cn&&t(n,{children:[e(K,{className:"zero-divider"}),e("div",{style:{display:"flex",justifyContent:"right",padding:"17px 24px",alignItems:"center"},children:e(R,{size:"large",type:"primary",style:{height:40},onClick:()=>{if(_.onEditorOk){const e=Array.from(fe)[0],t=ke.find(t=>t.id===e);t&&_.onEditorOk(t)}},children:C("Choose")})})]})})]})]})]}),ce&&e("div",{style:{position:"fixed",inset:0,zIndex:1500,backgroundColor:"rgba(255, 255, 255, 0.5)",pointerEvents:"all",display:"flex",alignItems:"center",justifyContent:"center"},children:e(k,{size:"large"})}),e(Ys,{isModalVisible:z,handleModalOk:xe,handleModalCancel:Ce,form:P,selectedFolder:qe||null,folders:me||[],isUrlModalVisible:B,setIsUrlModalVisible:e=>null==q?void 0:q(e),handleAddFileByUrl:Ct,urlForm:M,isRenameModalVisible:Ee,handleRenameOk:()=>null==De?void 0:De(),handleRenameCancel:()=>null==Ne?void 0:Ne(),renameForm:L,fileToRename:Ie,files:ke||[],isMoveModalVisible:U,handleMoveOk:bt,handleMoveCancel:Be,moveForm:N,selectedFiles:fe||new Set,isRenameFolderModalVisible:V,handleRenameFolderOk:bn,handleRenameFolderCancel:It,renameFolderForm:D,folderToRename:$,isCopyModalVisible:H,handleCopyOk:wt,handleCopyCancel:He,copyForm:j,isDeleteConfirmVisible:W,handleDeleteConfirmOk:gt,handleDeleteConfirmCancel:()=>null==$e?void 0:$e(),isClearTrashConfirmVisible:de,handleClearTrashConfirm:vt,handleClearTrashCancel:yt,fetchChildFolders:be}),e(_R,{visible:at.isPixieEditorVisible,onClose:at.handlePixieEditorClose,file:at.editingFile,onSave:at.handlePixieEditorSave,onSaveCopy:at.handlePixieEditorSaveCopy}),e(JR,{files:v.uploadFiles,visible:v.isUploadVisible,minimized:v.isUploadMinimized,totalFiles:v.totalFiles,completedFiles:v.completedFiles,onClose:v.closeUpload,onMinimize:v.minimizeUpload,onInsert:e=>{var t;const n=v.getUploadedFile(e.id)||e;null===(t=_.onEditorOk)||void 0===t||t.call(_,n)}})]})})]})},rN=f(({config:r={},onPathChange:o,onChangeSelection:s,onEditorOk:l,searchQuery:c="",sortBySize:d="name",apiEndpoints:h={},customIcons:f,dragDropIcon:p,dataProviders:g,handleNotify:m,handleError:v,handleSuccess:y})=>{const b=i.useMemo(()=>Object.assign({folderTreeLoading:"lazy",expandAllFoldersOnInit:!1,expandRootFolderOnInit:!1,iconStrokeWidth:1.4,availableImageExtensions:["jpg","jpeg","png","gif"],fileNameProcessing:Object.assign(Object.assign({},{transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0}),r.fileNameProcessing),folderNameProcessing:Object.assign(Object.assign({},{transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0}),r.folderNameProcessing)},r),[r]);i.useEffect(()=>{b.theme&&(e=>{if("system"===e){const t=matchMedia(pn).matches?hn:dn;e=e===fn?t:e}document.documentElement.setAttribute("data-theme",e)})(b.theme),JL(b)},[b]),a(()=>{b.locale&&b.locale!==Wr.language&&Wr.changeLanguage(b.locale),b.customLocale&&b.locale&&Wr.addResourceBundle(b.locale,"translation",b.customLocale,!0,!0)},[b.locale,b.customLocale]);const w=u(null),x=i.useMemo(()=>({apiEndpoints:h,searchQuery:c,sortBySize:d,onPathChange:o,onChangeSelection:s,onEditorOk:l,config:b,customIcons:f,dragDropIcon:p,dataProviders:g,handleNotify:m,handleError:v,handleSuccess:y}),[h,c,d,o,s,l,b,f,p,g,m,v,y]);return e(I,{className:"em-filemanager",children:t(n,{children:[e(E,{getPopupContainer:()=>w.current||document.body,children:e(io,{options:x,children:e(nN,{})})}),e("div",{ref:w,className:"file-manager-modal-root"})]})})});rN.displayName="FileManagerApp";const iN=t=>{var n,r,i;return e(er,{i18n:Wr,children:e(_n,{externalTheme:null!==(r=null===(n=t.config)||void 0===n?void 0:n.theme)&&void 0!==r?r:"light",customThemeToken:null===(i=t.config)||void 0===i?void 0:i.customTheme,children:e(ae,{children:e(rN,Object.assign({},t))})})})},oN=new Map,aN=(t,n)=>{var r;let i;En();let o={};const a=e=>{const t=!e||"fileManager"!==e.mode&&"imageCenter"!==e.mode&&"plugin"!==e.mode?void 0:e.mode;return"imageCenter"===t?kn("imageCenter",e):kn(t)};if(t instanceof HTMLElement){i=t;o={config:a(n),apiEndpoints:null==n?void 0:n.apiEndpoints}}else{i=t.element;const e=a(t.config),n=Object.assign(Object.assign({},null===(r=t.config)||void 0===r?void 0:r.apiEndpoints),t.apiEndpoints);o={config:e,currentPath:t.currentPath,onPathChange:t.onPathChange,onChangeSelection:t.onChangeSelection,searchQuery:t.searchQuery,sortBySize:t.sortBySize,apiEndpoints:n,dataProviders:t.dataProviders,customIcons:t.customIcons,dragDropIcon:t.dragDropIcon,handleNotify:t.handleNotify,handleError:t.handleError,handleSuccess:t.handleSuccess}}const s=S(i);s.render(e(iN,Object.assign({},o))),oN.set(i.id||`container_${Date.now()}`,s)},sN=e=>{const t=e.id||Object.keys(oN).find(e=>e.startsWith("container_"));if(t&&oN.has(t)){const e=oN.get(t);null==e||e.unmount(),oN.delete(t)}else{console.warn("Couldn t find the root to unmount");try{S(e).unmount()}catch(e){console.error("Error unmounting the component:",e)}}},lN=new Map,cN=r=>{var o,s;const{onClose:l,onSave:c,dataProviders:d,theme:h,locale:f}=r,p=i.useCallback(async(e,t,n,r)=>{if(!e&&!t||!(null==d?void 0:d.getFiles))return null;try{const i=await d.getFiles({folderId:r?void 0:n||void 0,noFolder:r,search:t||void 0,itemType:"file",page:1,limit:1}),[o]=i.files;return o?e&&o.id!==e?null:o:null}catch(e){return console.warn("Standalone Pixie: failed to resolve uploaded file from provider",e),null}},[d]),g=i.useMemo(()=>{if(r.file)return r.file;const e=r.name||"edited-image",t=r.extension||(r.type?r.type.split("/")[1]:"png"),n=r.type||`image/${t}`;return{thumbnail:r.imageDataUrl||"",name:e,id:void 0,type:n,extension:t,saveWithoutFolder:!0}},[r.file,r.imageDataUrl,r.name,r.extension,r.type]),m=i.useCallback(async(e,t)=>{if((null==d?void 0:d.updateFile)&&e.thumbnail)try{const n=(null==t?void 0:t.mimeType)||On(e.thumbnail,e.type),r=Pn(n),i=e.name.substring(0,e.name.lastIndexOf("."))+"."+r,o=(null==t?void 0:t.blob)||Nn(e.thumbnail,n);return await d.updateFile(e.id,{name:i,type:n,data:o})}catch(e){return console.error("Error updating the file through updateFile:",e),null}return console.warn("DataProvider for updating files is not configured"),null},[d]),v=i.useCallback(async(e,t)=>{var n,r,i,o,a,s;if(!e.thumbnail)return null;try{const l=null!==(n=e.saveWithoutFolder)&&void 0!==n?n:!e.id,c=l?"":e.folderId||"",u=(null==t?void 0:t.mimeType)||On(e.thumbnail,e.type),h=(null==t?void 0:t.blob)||Nn(e.thumbnail,u),f=new File([h],e.name,{type:u,lastModified:Date.now()});if(null==d?void 0:d.uploadFiles){const t=await d.uploadFiles({items:[{name:f.name,size:f.size,type:f.type,folderId:c,noFolder:l,data:f,extension:Pn(u)}],folderId:c}),n=null===(r=t.detailed)||void 0===r?void 0:r[0];if(t.success&&(null==n?void 0:n.success)&&n.data){const t=n.data;if(t.url||t.thumbnailUrl||t.thumbnail)return{id:t.id||e.id||"",name:t.name||e.name,folderId:null!==(i=t.folderId)&&void 0!==i?i:c,type:t.type||f.type,size:null!==(o=t.size)&&void 0!==o?o:f.size,extension:t.extension||Pn(u),url:t.url,thumbnailUrl:t.thumbnailUrl,thumbnail:t.thumbnail,date:t.date,dimensions:t.dimensions,aspectRatio:t.aspectRatio,sourceUrl:t.sourceUrl,isFolder:!1,selected:!1};const r=await p(n.data.id,n.data.name||f.name,null!==(a=n.data.folderId)&&void 0!==a?a:c,l);return r||{id:n.data.id||e.id||"",name:n.data.name||e.name,folderId:null!==(s=n.data.folderId)&&void 0!==s?s:c,type:f.type,size:f.size,extension:Pn(u),url:n.data.url,thumbnailUrl:n.data.thumbnailUrl,thumbnail:n.data.thumbnail,isFolder:!1,selected:!1}}}return(null==d?void 0:d.uploadFile)?await d.uploadFile({name:f.name,size:f.size,type:f.type,folderId:c,noFolder:l,data:f,extension:Pn(u)}):null}catch(e){return console.error("Error saving file copy:",e),null}},[d,p]),y=i.useCallback(async(e,t)=>{if((null==d?void 0:d.updateFile)&&e.id&&e.thumbnail)try{const n=await m(e,t);n&&(e=n)}catch(e){console.error("Standalone Pixie: saveFileToServer error",e)}return c&&await c(e,t),l&&l(),e},[d,c,l,m]),b=i.useCallback(async(e,t)=>{let n=e;if(e.thumbnail)try{const r=await v(e,t);r&&(n=r)}catch(e){console.error("Standalone Pixie: saveFileCopyToServer error",e)}return c&&await c(n,t),l&&l(),n},[l,c,v]),w=u(null);return a(()=>{f&&f!==Wr.language&&Wr.changeLanguage(f)},[f]),e(I,{className:"em-filemanager",children:t(n,{children:[e(E,{getPopupContainer:()=>w.current||document.body,children:e(er,{i18n:Wr,children:e(_n,{externalTheme:null!=h?h:"light",children:e(ae,{children:e(io,{options:{dataProviders:d,handleNotify:r.handleNotify,handleError:r.handleError,handleSuccess:r.handleSuccess,config:{theme:null!=h?h:"light",locale:f,baseUrl:r.baseUrl,assetsUrl:r.assetsUrl,compressMaxSize:r.compressMaxSize,compressMaxWidthOrHeight:r.compressMaxWidthOrHeight,compessorUrl:null!==(o=r.compessorUrl)&&void 0!==o?o:r.compressorUrl,compressorUrl:null!==(s=r.compressorUrl)&&void 0!==s?s:r.compessorUrl,showNotifications:r.showNotifications,handleFileProxy:r.handleFileProxy}},children:e(_R,{visible:!0,onClose:l,file:g,onSave:y,onSaveCopy:b})})})})})}),e("div",{ref:w,className:"file-manager-modal-root"})]})})},uN=t=>{En();const n=t.element,r=S(n);r.render(e(cN,Object.assign({},t))),lN.set(n.id||`pixie_container_${Date.now()}`,r)},dN=e=>{const t=Array.from(lN.keys()).find(e=>e.startsWith("pixie_container_")),n=e.id||t;if(n&&lN.has(n)){const e=lN.get(n);null==e||e.unmount(),lN.delete(n)}else{console.warn("Couldn t find the root to unmount Pixie");try{S(e).unmount()}catch(e){console.error("Error unmounting Pixie:",e)}}},hN=e=>{var t,n;const{mode:r,element:i,fileManager:o,pixieEditor:a,theme:s,dataProviders:l}=e;let c,u;const d={unmount:()=>{c&&sN(c),u&&dN(u)},unmountFileManager:void 0,unmountPixieEditor:void 0};switch(r){case"fileManager":c=i,aN(i,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),d.unmountFileManager=()=>sN(c);break;case"pixieEditor":u=i,uN(Object.assign({element:i,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountPixieEditor=()=>dN(u);break;case"both":{const e=document.createElement("div");e.id="file-manager-container",e.style.cssText="height: 50%; border-bottom: 1px solid #d9d9d9;";const t=document.createElement("div");t.id="pixie-editor-container",t.style.cssText="height: 50%;",i.appendChild(e),i.appendChild(t),c=e,u=t,aN(c,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),uN(Object.assign({element:u,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountFileManager=()=>sN(c),d.unmountPixieEditor=()=>dN(u);break}}return d};function fN(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}var pN={init:aN,unmount:sN,initPixieEditor:uN,unmountPixieEditor:dN,initFileManager:hN};export{Ps as FileContent,$o as FileManagerApiError,rN as FileManagerApp,iN as FileManagerAppWithContext,Ys as FileModals,Ks as FolderSidebar,cN as PixieOnlyApp,pN as default,aN as init,hN as initFileManager,uN as initPixieEditor,En as installResizeObserverErrorHandler,fN as mapHttpStatusToErrorCode,In as uninstallResizeObserverErrorHandler,sN as unmount,dN as unmountPixieEditor};
|
|
76
|
+
var nL=function(e,t){return nL=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},nL(e,t)};var rL=function(){return rL=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},rL.apply(this,arguments)};var iL="Pixel",oL="Percent",aL={unit:oL,value:.8};function sL(e){return"number"==typeof e?{unit:oL,value:100*e}:"string"==typeof e?e.match(/^(\d*(\.\d+)?)px$/)?{unit:iL,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:oL,value:parseFloat(e)}:(console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'),aL):(console.warn("scrollThreshold should be string or number"),aL)}var lL=function(e){function t(t){var n=e.call(this,t)||this;return n.lastScrollTop=0,n.actionTriggered=!1,n.startY=0,n.currentY=0,n.dragging=!1,n.maxPullDownDistance=0,n.getScrollableTarget=function(){return n.props.scrollableTarget instanceof HTMLElement?n.props.scrollableTarget:"string"==typeof n.props.scrollableTarget?document.getElementById(n.props.scrollableTarget):(null===n.props.scrollableTarget&&console.warn("You are trying to pass scrollableTarget but it is null. This might\n happen because the element may not have been added to DOM yet.\n See https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59 for more info.\n "),null)},n.onStart=function(e){n.lastScrollTop||(n.dragging=!0,e instanceof MouseEvent?n.startY=e.pageY:e instanceof TouchEvent&&(n.startY=e.touches[0].pageY),n.currentY=n.startY,n._infScroll&&(n._infScroll.style.willChange="transform",n._infScroll.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)"))},n.onMove=function(e){n.dragging&&(e instanceof MouseEvent?n.currentY=e.pageY:e instanceof TouchEvent&&(n.currentY=e.touches[0].pageY),n.currentY<n.startY||(n.currentY-n.startY>=Number(n.props.pullDownToRefreshThreshold)&&n.setState({pullToRefreshThresholdBreached:!0}),n.currentY-n.startY>1.5*n.maxPullDownDistance||n._infScroll&&(n._infScroll.style.overflow="visible",n._infScroll.style.transform="translate3d(0px, "+(n.currentY-n.startY)+"px, 0px)")))},n.onEnd=function(){n.startY=0,n.currentY=0,n.dragging=!1,n.state.pullToRefreshThresholdBreached&&(n.props.refreshFunction&&n.props.refreshFunction(),n.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame(function(){n._infScroll&&(n._infScroll.style.overflow="auto",n._infScroll.style.transform="none",n._infScroll.style.willChange="unset")})},n.onScrollListener=function(e){"function"==typeof n.props.onScroll&&setTimeout(function(){return n.props.onScroll&&n.props.onScroll(e)},0);var t=n.props.height||n._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;n.actionTriggered||((n.props.inverse?n.isElementAtTop(t,n.props.scrollThreshold):n.isElementAtBottom(t,n.props.scrollThreshold))&&n.props.hasMore&&(n.actionTriggered=!0,n.setState({showLoader:!0}),n.props.next&&n.props.next()),n.lastScrollTop=t.scrollTop)},n.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},n.throttledOnScrollListener=function(e,t,n,r){var i,o=!1,a=0;function s(){i&&clearTimeout(i)}function l(){var l=this,c=Date.now()-a,u=arguments;function d(){a=Date.now(),n.apply(l,u)}o||(r&&!i&&d(),s(),void 0===r&&c>e?d():!0!==t&&(i=setTimeout(r?function(){i=void 0}:d,void 0===r?e-c:e)))}return"boolean"!=typeof t&&(r=n,n=t,t=void 0),l.cancel=function(){s(),o=!0},l}(150,n.onScrollListener).bind(n),n.onStart=n.onStart.bind(n),n.onMove=n.onMove.bind(n),n.onEnd=n.onEnd.bind(n),n}return function(e,t){function n(){this.constructor=e}nL(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype.componentDidMount=function(){if(void 0===this.props.dataLength)throw new Error('mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage');if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener("scroll",this.throttledOnScrollListener),"number"==typeof this.props.initialScrollY&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener("touchstart",this.onStart),this.el.addEventListener("touchmove",this.onMove),this.el.addEventListener("touchend",this.onEnd),this.el.addEventListener("mousedown",this.onStart),this.el.addEventListener("mousemove",this.onMove),this.el.addEventListener("mouseup",this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),"function"!=typeof this.props.refreshFunction))throw new Error('Mandatory prop "refreshFunction" missing.\n Pull Down To Refresh functionality will not work\n as expected. Check README.md for usage\'')},t.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener("scroll",this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener("touchstart",this.onStart),this.el.removeEventListener("touchmove",this.onMove),this.el.removeEventListener("touchend",this.onEnd),this.el.removeEventListener("mousedown",this.onStart),this.el.removeEventListener("mousemove",this.onMove),this.el.removeEventListener("mouseup",this.onEnd)))},t.prototype.componentDidUpdate=function(e){this.props.dataLength!==e.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},t.getDerivedStateFromProps=function(e,t){return e.dataLength!==t.prevDataLength?rL(rL({},t),{prevDataLength:e.dataLength}):null},t.prototype.isElementAtTop=function(e,t){void 0===t&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=sL(t);return r.unit===iL?e.scrollTop<=r.value+n-e.scrollHeight+1:e.scrollTop<=r.value/100+n-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){void 0===t&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=sL(t);return r.unit===iL?e.scrollTop+n>=e.scrollHeight-r.value:e.scrollTop+n>=r.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=rL({height:this.props.height||"auto",overflow:"auto",WebkitOverflowScrolling:"touch"},this.props.style),n=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),r=this.props.pullDownToRefresh&&this.props.height?{overflow:"auto"}:{};return i.createElement("div",{style:r,className:"infinite-scroll-component__outerdiv"},i.createElement("div",{className:"infinite-scroll-component "+(this.props.className||""),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&i.createElement("div",{style:{position:"relative"},ref:function(t){return e._pullDown=t}},i.createElement("div",{style:{position:"absolute",left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!n&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(_);function cL(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function uL(){return uL=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},uL.apply(this,arguments)}function dL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function hL(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?dL(Object(n),!0).forEach(function(t){fL(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function fL(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const pL={breakpointCols:void 0,className:void 0,columnClassName:void 0,children:void 0,columnAttrs:void 0,column:void 0};class gL extends i.Component{constructor(e){let t;super(e),this.reCalculateColumnCount=this.reCalculateColumnCount.bind(this),this.reCalculateColumnCountDebounce=this.reCalculateColumnCountDebounce.bind(this),t=this.props.breakpointCols&&this.props.breakpointCols.default?this.props.breakpointCols.default:parseInt(this.props.breakpointCols)||2,this.state={columnCount:t}}componentDidMount(){this.reCalculateColumnCount(),window&&window.addEventListener("resize",this.reCalculateColumnCountDebounce)}componentDidUpdate(){this.reCalculateColumnCount()}componentWillUnmount(){window&&window.removeEventListener("resize",this.reCalculateColumnCountDebounce)}reCalculateColumnCountDebounce(){window&&window.requestAnimationFrame?(window.cancelAnimationFrame&&window.cancelAnimationFrame(this._lastRecalculateAnimationFrame),this._lastRecalculateAnimationFrame=window.requestAnimationFrame(()=>{this.reCalculateColumnCount()})):this.reCalculateColumnCount()}reCalculateColumnCount(){const e=window&&window.innerWidth||1/0;let t=this.props.breakpointCols;"object"!=typeof t&&(t={default:parseInt(t)||2});let n=1/0,r=t.default||2;for(let i in t){const o=parseInt(i);o>0&&e<=o&&o<n&&(n=o,r=t[i])}r=Math.max(1,parseInt(r)||1),this.state.columnCount!==r&&this.setState({columnCount:r})}itemsInColumns(){const e=this.state.columnCount,t=new Array(e),n=i.Children.toArray(this.props.children);for(let r=0;r<n.length;r++){const i=r%e;t[i]||(t[i]=[]),t[i].push(n[r])}return t}renderColumns(){const{column:e,columnAttrs:t={},columnClassName:n}=this.props,r=this.itemsInColumns(),o=100/r.length+"%";let a=n;a&&"string"!=typeof a&&(this.logDeprecated('The property "columnClassName" requires a string'),void 0===a&&(a="my-masonry-grid_column"));const s=hL(hL(hL({},e),t),{},{style:hL(hL({},t.style),{},{width:o}),className:a});return r.map((e,t)=>i.createElement("div",uL({},s,{key:t}),e))}logDeprecated(e){console.error("[Masonry]",e)}render(){const e=this.props,{children:t,breakpointCols:n,columnClassName:r,columnAttrs:o,column:a,className:s}=e,l=cL(e,["children","breakpointCols","columnClassName","columnAttrs","column","className"]);let c=s;return"string"!=typeof s&&(this.logDeprecated('The property "className" requires a string'),void 0===s&&(c="my-masonry-grid")),i.createElement("div",uL({},l,{className:c}),this.renderColumns())}}gL.defaultProps=pL;var mL={gifTab:"gifTab",scrollableDiv:"scrollableDiv",gifSearchInput:"gifSearchInput",search:"search",searchResults:"searchResults",myMasonryGrid:"myMasonryGrid",myMasonryGridColumn:"myMasonryGridColumn",listItem:"listItem",loaded:"loaded",loadedImage:"loadedImage",searchOutputWrapper:"searchOutputWrapper",divider:"divider",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle"};const vL={default:4,1600:3,1100:2,700:1},yL=({setImageGifList:r,imageGifList:i=[],currentReqGif:s,setCurrentReqGif:l,inputRef:c,customRequest:d})=>{const{t:h}=Qn(),{GifPlayIcon:f}=oo(),{options:p}=ro(),{config:g}=p,[m,v]=o(null),[y,b]=o(!1),[w,x]=o(25),[C,_]=o(null),[S]=T.useForm(),A=u(s);a(()=>{S.setFieldsValue({keywords:s.keywords})},[]);const E=null==g?void 0:g.handleProxyUrl,I=async e=>E?Promise.resolve(E(e)):e,O=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{images:Object.assign(Object.assign({},e.images),{downsized:Object.assign(Object.assign({},e.images.downsized),{url:await I(e.images.downsized.url)})})}))),P=async function({query:e,page:t}){var n;const r=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{const e=`https://api.giphy.com/v1/gifs/search?api_key=${null!==(n=null==g?void 0:g.REACT_APP_GIPHY_KEY)&&void 0!==n?n:"Nh77eBlPeMn1ed9MBAvL542NUGeNO26F"}&q=${encodeURIComponent(r)}&limit=25&offset=${t}&lang=en`,i=await fetch(await I(e));return{data:await i.json()}}catch(e){console.warn(e)}},M=async()=>{var e,t;const n=await P({query:A.current,page:0});(null===(t=null===(e=null==n?void 0:n.data)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)&&n.data.data.length>0&&r(await O(n.data.data))};return a(()=>()=>{C&&clearTimeout(C)},[C]),e("div",{className:mL.gifTab,children:e("div",{className:mL.searchOutputWrapper,children:t("div",{id:"scrollableDiv",className:mL.scrollableDiv,children:[t(T,{form:S,onValuesChange:e=>{if(void 0!==e.keywords){const t=Object.assign(Object.assign({},A.current),{keywords:e.keywords});l(t),A.current=t,C&&clearTimeout(C);const n=setTimeout(M,800);_(n)}},className:i.length>0?mL.searchResults:mL.search,children:[e(T.Item,{name:"keywords",className:mL.gifSearchInput,children:e(F,{onKeyDown:e=>"Space"===e.code&&M(),onPressEnter:e=>M(),allowClear:!0,placeholder:h("Search GIFs"),ref:c,spellCheck:"false",prefix:e(wi,{size:16,strokeWidth:null==g?void 0:g.iconStrokeWidth,onClick:M})})}),i.length>0&&!y&&e("div",{className:`ant-divider ${mL.divider}`,role:"separator"})]}),!i.length&&!y&&e(n,{children:s.keywords?e(uo,{}):t("div",{className:mL.resultsContainer,children:[e("div",{className:mL.videoIcon,children:e(f,{className:mL.playButton})}),e("h1",{className:mL.title,children:h("Over 350,000 live images")}),e("p",{className:mL.subtitle,children:h("Enter a search query and we'll find the perfect image for you")})]})}),!i.length&&y&&e(Hs,{}),i.length>0&&e(lL,{dataLength:i&&i.length,next:async()=>{y||(b(!0),P({query:A.current,page:w}).then(async e=>{if(e&&e.data&&e.data.data){const t=await O(e.data.data);r(e=>[...e,...t])}b(!1),x(e=>e+25)}).catch(()=>{b(!1)}))},hasMore:!!i,endMessage:t(K,{plain:!0,children:[h("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:e(Hs,{}),children:e(gL,{breakpointCols:vL,className:mL.myMasonryGrid,columnClassName:mL.myMasonryGridColumn,children:i.map((n,r)=>t("div",{className:mL.listItem,onClick:()=>(async(e,t)=>{var n;v(t),setTimeout(()=>{v(null)},2e3);let r=e.split("?")[0].split("#")[0].split("/"),i=r[r.length-1]||"uploaded-file";i.includes(".")&&(null===(n=i.split(".").pop())||void 0===n?void 0:n.length)&&i.split(".").pop().length<=5||(i+=".gif"),d(e,i)})(n.images.downsized.url,n.id,n.title),children:[e("img",{className:m===n.id?mL.loadedImage:"",width:"100%",src:n.images.downsized.url,alt:n.title,onLoad:e=>{const t=e.target.parentNode;t&&t instanceof HTMLElement&&t.classList.add(mL.loaded)}}),e("a",{rel:"noreferrer",href:"https://giphy.com/",target:"_blank",onClick:e=>e.stopPropagation()}),m===n.id&&e(k,{className:mL.antSpin})]},n.id+r))})})]})})})};var bL={stockTab:"stockTab",stockSearchInput:"stockSearchInput",searchOutputWrapper:"searchOutputWrapper",divider:"divider",search:"search",searchResults:"searchResults",scrollableDiv:"scrollableDiv",myMasonryGrid:"myMasonryGrid",myMasonryGridColumn:"myMasonryGridColumn",listItem:"listItem",loaded:"loaded",loadedImage:"loadedImage",creatorInfo:"creatorInfo",stockColorFilter:"stockColorFilter",allColors:"allColors",blackColor:"blackColor",bwColor:"bwColor",whiteColor:"whiteColor",orangeColor:"orangeColor",redColor:"redColor",purpleColor:"purpleColor",magentaColor:"magentaColor",greenColor:"greenColor",tealColor:"tealColor",blueColor:"blueColor",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle"};const wL={default:4,1600:3,1100:2,700:1},xL=(e,t)=>{const n=new URL(e);return n.searchParams.set("w",t.toString()),n.toString()},CL=({imageStockList:r,setImageStockList:i,currentReq:s,setCurrentReq:l,inputRef:c,customRequest:d})=>{var h,f,p;const{t:g}=Qn(),{StockBigIcon:m,MixedViewIcon:v,LandscapeViewIcon:y,PortraitViewIcon:b,SquareViewIcon:w}=oo(),{options:x}=ro(),{config:C}=x,[_,S]=o(!1),[A,E]=o(2),[I,O]=o(null),[P,R]=o(null),[L,N]=o(!0),[D]=T.useForm(),j=null==C?void 0:C.handleProxyUrl,z=null!==(h=null==C?void 0:C.UNSPLASH_KEY)&&void 0!==h?h:"HX2_qqq3F3ljmtYtfmb9P6h0dn2u9mnnOl36IdV8el0",U=(null===(f=null==C?void 0:C.locale)||void 0===f?void 0:f.slice(0,2))||"ru",H=u(s),W=async e=>j?Promise.resolve(j(e)):e,$=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{urls:{raw:await W(xL(e.urls.raw,1200)),small:await W(xL(e.urls.raw,540))}})));a(()=>{H.current=s},[s]),a(()=>{0===r.length&&D.setFieldsValue({color:"",orientation:""})},[r,D]),a(()=>{D.setFieldsValue({keywords:s.keywords,color:s.color,orientation:s.orientation})},[]);const G=async function({query:e,page:t}){const n=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{let r=`https://api.unsplash.com/search/photos?client_id=${z}&lang=${U}&per_page=18&query=${encodeURIComponent(n)}&page=${t}`;""!==e.color&&(r+=`&color=${e.color}`),""!==e.orientation&&(r+=`&orientation=${e.orientation}`);const i=await fetch(await W(r));return{data:await i.json()}}catch(e){console.warn(e)}finally{S(!1)}},q=async()=>{var e,t,n;S(!0);const r=await G({query:H.current,page:1});(null===(e=null==r?void 0:r.data)||void 0===e?void 0:e.results)&&(i(await $(r.data.results)),N(18===r.data.results.length),(null===(n=null===(t=null==r?void 0:r.data)||void 0===t?void 0:t.results)||void 0===n?void 0:n.length)&&r.data.results.length>0&&E(2))};a(()=>()=>{P&&clearTimeout(P)},[P]);const Y=async(e,t,n,r)=>{var i;!async function(e){try{const t=`${e}${e.includes("?")?"&":"?"}client_id=${z}`,n=await W(t),r=await fetch(n);return{data:await r.json()}}catch(e){console.warn(e)}}(t.download_location),O(n),setTimeout(()=>O(null),2e3);const o=e.raw,a=o.split("?")[0].split("#")[0].split("/");let s=a[a.length-1]||"uploaded-file";s.includes(".")&&(null===(i=s.split(".").pop())||void 0===i?void 0:i.length)&&s.split(".").pop().length<=5||(s+=".jpg"),d(o,s)};return e("div",{className:bL.stockTab,children:e("div",{className:bL.searchOutputWrapper,children:t("div",{className:bL.scrollableDiv,id:"scrollableDiv",children:[t(T,{form:D,initialValues:wn,onValuesChange:(e,t)=>{const n=Object.assign(Object.assign({},wn),t);if(l(n),H.current=n,P&&clearTimeout(P),""!==t.keywords){const e=setTimeout(q,800);R(e)}else r.length||(l(Object.assign({},wn)),H.current=wn,D.resetFields())},className:r.length>0?bL.searchResults:bL.search,children:[t(V,{gutter:24,children:[e(B,{span:r.length>0?void 0:24,children:e(T.Item,{name:"keywords",className:bL.stockSearchInput,children:e(F,{allowClear:!0,placeholder:g("Search image"),ref:c,spellCheck:"false",prefix:e(wi,{size:16,strokeWidth:null==C?void 0:C.iconStrokeWidth})})})}),!!r.length&&t(n,{children:[e(B,{children:e(T.Item,{name:"orientation",children:t(ee.Group,{onChange:e=>l(t=>Object.assign(Object.assign({},t),{orientation:e.target.value})),children:[e(M,{title:g("All"),placement:"top",children:e(ee.Button,{value:"",children:e(v,{})})}),e(M,{title:g("Landscape"),placement:"top",children:e(ee.Button,{value:"landscape",children:e(y,{})})}),e(M,{title:g("Portrait"),placement:"top",children:e(ee.Button,{value:"portrait",children:e(b,{})})}),e(M,{title:g("Squarish"),placement:"top",children:e(ee.Button,{value:"squarish",children:e(w,{})})})]})})}),e(B,{children:e(T.Item,{name:"color",children:t(ee.Group,{className:bL.stockColorFilter,onChange:e=>l(t=>Object.assign(Object.assign({},t),{color:e.target.value})),children:[e(M,{title:g("All"),placement:"top",children:e(ee.Button,{className:bL.allColors,value:"",children:"All"})}),e(M,{title:g("Black"),placement:"top",children:e(ee.Button,{className:bL.blackColor,value:"black",children:"B"})}),e(M,{title:g("Black and White"),placement:"top",children:e(ee.Button,{className:bL.bwColor,value:"black_and_white",children:"B&W"})}),e(M,{title:g("White"),placement:"top",children:e(ee.Button,{className:bL.whiteColor,value:"white",children:"W"})}),e(M,{title:g("Orange"),placement:"top",children:e(ee.Button,{className:bL.orangeColor,value:"orange",children:"O"})}),e(M,{title:g("Red"),placement:"top",children:e(ee.Button,{className:bL.redColor,value:"red",children:"R"})}),e(M,{title:g("Purple"),placement:"top",children:e(ee.Button,{className:bL.purpleColor,value:"purple",children:"P"})}),e(M,{title:g("Magenta"),placement:"top",children:e(ee.Button,{className:bL.magentaColor,value:"magenta",children:"M"})}),e(M,{title:g("Green"),placement:"top",children:e(ee.Button,{className:bL.greenColor,value:"green",children:"G"})}),e(M,{title:g("Teal"),placement:"top",children:e(ee.Button,{className:bL.tealColor,value:"teal",children:"T"})}),e(M,{title:g("Blue"),placement:"top",children:e(ee.Button,{className:bL.blueColor,value:"blue",children:"B"})})]})})})]})]}),r.length>0&&!_&&e("div",{className:`ant-divider ${bL.divider}`,role:"separator"})]}),!r.length&&!_&&e(n,{children:s.keywords?e(uo,{}):t("div",{className:bL.resultsContainer,children:[e("div",{className:bL.videoIcon,children:e(m,{className:bL.playButton})}),e("h1",{className:bL.title,children:g("Millions of free stock images")}),e("p",{className:bL.subtitle,children:g("Enter a search query and we'll find the perfect image for you")})]})}),!r.length&&_&&e(Hs,{}),r.length>0&&e(lL,{dataLength:r&&r.length,next:async()=>{if(_||""===H.current.keywords)return S(!1),void(""===H.current.keywords&&N(!1));S(!0),G({query:H.current,page:A}).then(async e=>{if(e&&e.data&&e.data.results){const t=await $(e.data.results);i(e=>[...e,...t]),N(18===e.data.results.length)}E(e=>e+1)}).catch(e=>{console.warn("catch",e)}).finally(()=>{S(!1)})},hasMore:L&&""!==(null===(p=H.current)||void 0===p?void 0:p.keywords),endMessage:t(K,{plain:!0,children:[g("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:e(Hs,{}),children:e(gL,{breakpointCols:wL,className:bL.myMasonryGrid,columnClassName:bL.myMasonryGridColumn,children:r.map((n,r)=>t("div",{className:bL.listItem,onClick:()=>Y(n.urls,n.links,n.id,n.description),children:[e("img",{className:I===n.id?bL.loadedImage:"",width:"100%",src:n.urls.small,alt:n.description,onLoad:e=>{const t=e.target.parentNode;t&&t instanceof HTMLElement&&t.classList.add(bL.loaded)}}),t("p",{className:bL.creatorInfo,onClick:e=>e.stopPropagation(),children:[g("Photo by")," ",e("a",{target:"_blank",href:`${n.user.links.html}?utm_source=${null==C?void 0:C.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:n.user.name})," ",g("on")," ",e("a",{target:"_blank",href:`https://unsplash.com/?utm_source=${null==C?void 0:C.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:"Unsplash"})]}),I===n.id&&e(k,{className:bL.antSpin})]},n.id+r))})})]})})})},_L=()=>{const{options:e}=ro(),t=e.config;return c((e,n)=>{!1!==(null==t?void 0:t.pushToGTM)&&((e,t)=>{const n=()=>{try{const t=Object.assign(Object.assign({},e),{appLabel:"blocks_app"});window.dataLayer&&"function"==typeof window.dataLayer.push&&window.dataLayer.push(t)}catch(e){console.error("Ошибка при вызове GTM:",e)}};t?setTimeout(n,t):n()})(e,n)},[null==t?void 0:t.pushToGTM])};var SL="slideshowContainer",kL="slideshowImage";const AL=({images:t,transitionDuration:n=1e3,frameHeight:r})=>{const[i,s]=o([]),[l,c]=o(r);a(()=>{const e=()=>{if("undefined"==typeof window)return void c(r);const e=window.innerHeight,t=Math.max(e-260,130);if("number"==typeof r){const e=Math.min(r,t);c(e)}else c(t)};if(e(),"undefined"!=typeof window)return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[r]);const u=()=>{s(e=>e.map((t,n)=>n===e.length-1?Object.assign(Object.assign({},t),{opacity:1}):t))};return a(()=>{if(t.length>0){const e=t[t.length-1];s(t=>[...t,{src:e,opacity:0}]),setTimeout(u,1e3)}else s([])},[t]),e("div",{className:SL,style:{height:l,minHeight:130},children:i.map((t,r)=>e("img",{src:`data:image/jpeg;base64, ${t.src}`,alt:`Slide ${r+1}`,className:kL,style:{opacity:t.opacity,transition:`opacity ${n}ms linear`,display:"block"}},r))})},EL=t=>{var{className:n,style:r,color:i,text:o,bordered:a}=t,s=ls(t,["className","style","color","text","bordered"]);const l=o||"";return e(te,Object.assign({style:r,color:i,bordered:a,className:n},s,{children:l}))},IL=({text:n,counter:r,limits:i,wrapperStyles:o})=>{const{t:a}=Qn(),{options:s}=ro(),l=s.config,{token:c}=A.useToken(),u=+i>0,d=!u||r<+i,h=(null==l?void 0:l.billingPageUrl)||"/billing",f=r+" "+a("of")+" "+(u?i:"∞")+" "+(n||a("tests",{count:i}))+" "+a("was used",{count:r});return t("div",{className:"limits-couter-wrapper",style:o,children:[e(EL,{bordered:!1,text:f,className:"limit-counter",style:{color:d?c.colorText:"white"},color:d?c.colorFillSecondary:"rgb(255, 77, 79)"}),u&&e("div",{style:{fontSize:14,textDecoration:"underline",cursor:"pointer"},onClick:()=>window.location.assign(h),children:a("Need more?")})]})};var TL={imageAi:"imageAi",imageAiExample:"imageAiExample",imageItem:"imageItem",textAreaInputHybrid:"textAreaInputHybrid",loading:"loading",carousel:"carousel",arrow:"arrow",arrowNext:"arrowNext",arrowPrev:"arrowPrev",arrowBtn:"arrowBtn",arrowBtnNext:"arrowBtnNext",arrowBtnPrev:"arrowBtnPrev",row:"row",inputAffixWrapper:"inputAffixWrapper",textarea:"textarea",inputIcon:"inputIcon"};const FL=f(({className:t,onClick:n})=>e("div",{className:`${TL.arrow} ${TL.arrowNext} ${t||""}`,onClick:n,children:e(R,{className:`${TL.arrowBtn} ${TL.arrowBtnNext}`,size:"large",icon:e(Ae,{})})}));FL.displayName="SampleNextArrow";const OL=f(({className:t,onClick:n})=>e("div",{className:`${TL.arrow} ${TL.arrowPrev} ${t||""}`,onClick:n,children:e(R,{className:`${TL.arrowBtn} ${TL.arrowBtnPrev}`,size:"large",icon:e(Ee,{})})}));OL.displayName="SamplePrevArrow";const PL=({customRequest:n,inputAiRef:r,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:h,setAiImageRequest:f,imageAiList:p,setImageAiList:g,isLoadingAi:m,setIsLoadingAi:v})=>{const{t:y}=Qn(),{AiIcon_2:b}=oo(),w=i.useRef(null),[x,C]=o("auto"),{aiImageCounter:_,currentAiImgLimits:S,loadingDuringGeneration:k,requestStatus:A,handleGenerate:E,convertBase64ToFile:I,isShiftPressed:O,setIsShiftPressed:P,limitsInPlugin:M}=function({setFrameHeight:e,customRequest:t,aiTabRef:n,isImageUploaded:r,setIsImageUploaded:i,aiImageRequest:s,imageAiList:l,setImageAiList:h,isLoadingAi:f,setIsLoadingAi:p}){const{t:g}=Qn(),{options:m}=ro(),v=m.config,y=bo(),b=_L(),{messages:w}=m.config,[x,C]=o([]),[_,S]=o(0),[k,A]=o(null),[E,I]=o(!1),[T,F]=o(g("Evaluating the task")),[O,P]=o(!1),M=u(new Set),R=u(new Set),L=u(new Set);a(()=>{C(w)},[w]),a(()=>{l.length||k||(C([]),M.current.clear(),R.current.clear(),L.current.clear(),j.current=-1)},[l,k]);const N=d(()=>v&&"function"==typeof(null==v?void 0:v.sendAIImageRequest)?null==v?void 0:v.sendAIImageRequest:()=>Promise.resolve({}),[v]),D=c(e=>{const t=`${k}-${e.progress}-${JSON.stringify(e.images||e.data)}`;if(!L.current.has(t))if(L.current.add(t),"error"!==e.status&&"Canceled"!==e.status){if(e.images){if(F(String(e.status)),100===e.progress){p(!1),h(e.images);const t=k,n=Array.isArray(e.images)?e.images:[];n.length>0&&t&&!M.current.has(t)&&(M.current.add(t),y.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:g("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:n}})),A(null),P(!1)}}else if(e.data&&(h([String(e.data)]),100===e.progress)){p(!1);const t=k,n=e.data?[String(e.data)]:[];n.length>0&&t&&!M.current.has(t)&&(M.current.add(t),y.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:g("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:n}})),A(null),P(!1)}}else p(!1),P(!1),k&&!R.current.has(k)&&(R.current.add(k),y.error({id:"AI_RESPONSE_INVALID",message:g("Something went wrong, please try again"),placement:"bottomRight",description:String(k)||void 0,data:{requestId:k,request:s,response:e},innerException:e}))},[s,h,F,g,p,k,y,P]),j=u(-1);a(()=>{if(x.length>0){const e=x.length-1;e>j.current&&(j.current=e,D(x[e]))}},[D,x]);const z=d(()=>{if(v&&"function"==typeof(null==v?void 0:v.sseQuery)){const e=null==v?void 0:v.sseQuery;return t=>e(t)}return e=>{}},[v]),B=d(()=>v&&"object"==typeof(null==v?void 0:v.handleLimitUsageEmitter)?null==v?void 0:v.handleLimitUsageEmitter:{fire:()=>{}},[v]),U=null==v?void 0:v.elementId,{projectId:V}=v,{limits:H}=(null==v?void 0:v.limits)?v:{limits:{ai_img_limit:0}},{ai_img_limit:W}=H,$=W>0&&_>=W,G=!(!(null==v?void 0:v.limits)||!v.counters)&&gn,q=c(()=>{B.fire({name:"AiImgCount",count:_+1})},[B,_]),Y=d(()=>!$&&!G,[$,G,_,W]),X=c(async()=>{F(g("Evaluating the task")),""===s||f||(p(!0),P(!0),h([]),C([]),b({event:"submit_form",action:"ai_image_generation",entity_id:U,project_id:V}),N({body:{project_id:V,request:"create-image",connection:"midjourney",message:s}}).then(e=>{var t,n,r,i,o;const{data:a,error:l}=e||{};if(l)throw l;const c=a;if(401===(null==c?void 0:c.status)||401===(null===(t=null==c?void 0:c.data)||void 0===t?void 0:t.status))throw new Error("ERROR");const u=(null==c?void 0:c.task)||(null===(n=null==c?void 0:c.data)||void 0===n?void 0:n.task),d=null!==(i=null!==(r=null==u?void 0:u.id)&&void 0!==r?r:k)&&void 0!==i?i:void 0;200===(null==c?void 0:c.status)||200===(null===(o=null==c?void 0:c.data)||void 0===o?void 0:o.status)?((null==u?void 0:u.id)&&(F(u.message),A(u.id)),(null==c?void 0:c.message)&&y.success({id:"AI_IMAGE_GENERATION_STARTED",message:c.message,placement:"bottomRight",data:{request:s,taskId:d,response:null==c?void 0:c.data}}),z({task_id:null==u?void 0:u.id,entity_id:U})):(p(!1),P(!1),d&&!R.current.has(d)&&(R.current.add(d),y.error({id:"AI_IMAGE_GENERATION_FAILED",message:(null==c?void 0:c.message)||g("Something went wrong, please try again"),placement:"bottomRight",description:s,data:{request:s,taskId:d,response:c},innerException:c})))}).catch(e=>{p(!1),P(!1);const t=e;return((null==t?void 0:t.error)||(null==t?void 0:t.data))&&k&&!R.current.has(k)&&(R.current.add(k),null==y||y.error({id:"AI_IMAGE_GENERATION_FAILED",message:g("Something went wrong, please try again"),placement:"bottomRight",description:s,innerException:e,data:{request:s,taskId:k,response:null==t?void 0:t.data,error:Io(null==t?void 0:t.error)}})),t}))},[s,f,p,P,h,b,U,V,N,y,z,g,k]),K=c(()=>{Y&&X()},[Y,G,S,q,X,y,g]);a(()=>{},[v,G]);const Z=c(e=>{if(r)return;const n=e.match(/^data:image\/([A-Za-z-+/]+);base64,(.+)$/);if(!n)return;const o=n[1],a=n[2],s=atob(a),l=new Array(s.length);for(let e=0;e<s.length;e++)l[e]=s.charCodeAt(e);const c=new Uint8Array(l),u=new Blob([c],{type:`image/${o}`}),d=new File([u],"image.jpeg",{type:u.type,lastModified:Date.now()});i(!0),(async()=>{try{"function"==typeof t&&await Promise.resolve(t({file:d}))}catch(e){console.error("FM AI: customRequest error",e)}finally{i(!1)}})()},[r,i,t]);return a(()=>{(f||l.length>0)&&setTimeout(()=>{var t,r;let i=350;if(n.current){const e=null===(t=n.current)||void 0===t?void 0:t.firstChild;e&&e instanceof HTMLElement&&(i=(null===(r=n.current.getBoundingClientRect())||void 0===r?void 0:r.height)-48-e.clientHeight)}e(i)},0)},[n,l.length,f,e]),{aiImageCounter:_,setAiImageCounter:S,currentAiImgLimits:W,isFieldsDisabled:$,canGenerateImage:Y,aiImageRequest:s,imageAiList:l,setImageAiList:h,isLoadingAi:f,setIsLoadingAi:p,loadingDuringGeneration:O,setLoadingDuringGeneration:P,requestStatus:T,setRequestStatus:F,handleGenerate:K,handleLimitAiImgCount:q,convertBase64ToFile:Z,isShiftPressed:E,setIsShiftPressed:I,currentReqId:k,setCurrentReqId:A,limitsInPlugin:G}}({setFrameHeight:C,customRequest:n,aiTabRef:w,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:h,imageAiList:p,setImageAiList:g,isLoadingAi:m,setIsLoadingAi:v});a(()=>{},[s]);const[L,N]=o(!1),D=c(()=>N(!0),[]),j=c(()=>N(!1),[]),z=c(e=>f(e.target.value),[f]),U=c(e=>{"Shift"===e.key?P(!0):"Enter"!==e.key||O||(e.preventDefault(),E())},[O,E,P]),H=c(e=>{"Shift"===e.key&&P(!1)},[P]);return t("div",{className:TL.imageAi,ref:w,children:[M&&e(IL,{text:"images",counter:_,limits:S,wrapperStyles:{marginTop:-25}}),e(V,{gutter:24,className:TL.row,children:t(B,{span:24,children:[e(T.Item,{children:t("span",{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg ${TL.inputAffixWrapper}${L?" ant-input-affix-wrapper-focused":""}`,children:[e(F.TextArea,{ref:r,onKeyDown:U,onKeyUp:H,onFocus:D,onBlur:j,autoSize:!0,allowClear:!0,className:`${TL.textAreaInputHybrid} ${TL.textarea}`,placeholder:y("Generate image"),value:h,onChange:z,spellCheck:"false"}),e("span",{className:`ant-input-suffix ${TL.inputSuffix}`,children:m||k?e(le,{className:`${TL.inputIcon} input-icon`,spin:!0}):e(b,{className:`${TL.inputIcon} input-icon`,onClick:E})})]})}),t("div",{className:TL.imageAiExample,children:[e("span",{children:y("For example:")})," ",y("A beautiful image of a sunset over a calm ocean.")]})]})}),(m||p.length>0)&&t(ne,{dotPosition:"top",arrows:!0,nextArrow:e(FL,{}),prevArrow:e(OL,{}),className:TL.carousel,infinite:!1,children:[m&&!p.length&&e("div",{className:TL.loading,children:t("div",{className:"spin",children:[e(le,{style:{fontSize:48},spin:!0}),e("p",{className:"status",children:A})]})}),p.length>0&&p.map((n,r)=>t("div",{className:TL.imageItem,children:[e(AL,{images:p,frameHeight:x}),e("div",{className:"buttons",children:p.length>0&&!m&&e(R,{onClick:()=>I(`data:image/jpeg;base64, ${n}`),loading:s,icon:e(Ie,{}),children:y("Use this variant")})})]},r))]})]})};var ML={iconsTab:"iconsTab",hasSearch:"hasSearch",iconsSearchFormCenteredContainer:"iconsSearchFormCenteredContainer",iconsSearchFormCentered:"iconsSearchFormCentered",iconsSearchFormInput:"iconsSearchFormInput",iconsSearchFormInputInput:"iconsSearchFormInputInput",iconsSearchResults:"iconsSearchResults",iconsControlsControls:"iconsControlsControls",iconsControls:"iconsControls",iconsControlElement:"iconsControlElement",iconsControlsStrokeWidth:"iconsControlsStrokeWidth",iconsControlsHeader:"iconsControlsHeader",iconsSearchFormSelect:"iconsSearchFormSelect",iconsSearchFormStyleItem:"iconsSearchFormStyleItem",iconsSearchDivider:"iconsSearchDivider",iconsGrid:"iconsGrid",iconsBottomBar:"iconsBottomBar",iconsBottomBarContent:"iconsBottomBarContent",iconsGridEmptyState:"iconsGridEmptyState",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle",iconsGridInfiniteScroll:"iconsGridInfiniteScroll",iconsGridGrid:"iconsGridGrid",iconsGridItem:"iconsGridItem",iconsGridItemThumbnail:"iconsGridItemThumbnail",iconsGridItemSvg:"iconsGridItemSvg",iconsGridItemImg:"iconsGridItemImg",iconsGridItemName:"iconsGridItemName",iconsGridLoading:"iconsGridLoading",iconsControlsBackButton:"iconsControlsBackButton",iconsGridCheckbox:"iconsGridCheckbox",iconsGridShowCheckboxes:"iconsGridShowCheckboxes",iconsHeaderContainer:"iconsHeaderContainer",iconsHeaderContainerLeft:"iconsHeaderContainerLeft",copyToFolderModalBody:"copyToFolderModalBody",copyToFolderModalLoadingOverlay:"copyToFolderModalLoadingOverlay"};const RL=[{label:"Line",value:"line"},{label:"Solid",value:"solid"},{label:"Flat",value:"flat"},{label:"Duo",value:"duo"},{label:"Handrawn",value:"handrawn"},{label:"Creative",value:"creative"},{label:"Gradient",value:"gradient"},{label:"Remix",value:"remix"},{label:"Neon",value:"neon"},{label:"Pop",value:"pop"},{label:"Light",value:"light"},{label:"Glyph",value:"glyph"},{label:"Minimal",value:"minimal"},{label:"Outlined",value:"outlined"},{label:"Geometric",value:"geometric"},{label:"Bold",value:"bold"},{label:"Stroke",value:"stroke"},{label:"Wireframe",value:"wireframe"},{label:"Filled",value:"filled"}],LL=({query:n,onQueryChange:r,onSubmit:i,styleFilter:o,onStyleChange:a,hasResults:s=!1,inputRef:l})=>{const{t:c}=Qn(),{options:u}=ro(),{config:d}=u,h=n.length>0&&s;return t("div",{className:ML.iconsSearchFormCenteredContainer,children:[t(T,{layout:"inline",onFinish:i,className:h?ML.iconsSearchResults:ML.iconsSearchFormCentered,children:[e(T.Item,{className:ML.iconsSearchFormInput,children:e(F,{ref:l,className:ML.iconsSearchFormInputInput,allowClear:!0,prefix:e(wi,{size:16,strokeWidth:null==d?void 0:d.iconStrokeWidth,onClick:i}),placeholder:c("Search icons"),value:n,onChange:e=>r(e.target.value),onKeyDown:e=>"Space"===e.code&&i(),onPressEnter:i,spellCheck:"false"})}),h&&e(T.Item,{className:ML.iconsSearchFormStyleItem,children:e(P,{allowClear:!0,placeholder:c("Style"),value:null!=o?o:void 0,onChange:e=>a(null!=e?e:null),className:ML.iconsSearchFormSelect,options:RL.map(e=>({label:c(e.label),value:e.value}))})})]}),h&&e("div",{className:`ant-divider ${ML.iconsSearchDivider}`,role:"separator"})]})},NL=r=>{const{t:i}=Qn(),{mode:o,colorHex:a,setColorHex:s,colorHex2:l,setColorHex2:c,colorHex3:u,setColorHex3:d,sizePx:h,setSizePx:f,strokeWidth:p,setStrokeWidth:g,showSecondColor:m,showThirdColor:v,onBack:y,styleFilter:b}=r;return t("div",{className:ML.iconsControls,children:[e("div",{className:ML.iconsControlsControls,children:"family"===o&&t(n,{children:[t("div",{className:ML.iconsControlsStrokeWidth,children:[e("span",{children:i("Size")}),e(re,{min:20,max:200,value:h,formatter:e=>`${e}px`,parser:e=>e?e.replace("px",""):"",onChange:e=>f("number"==typeof e?e:50)})]}),t("div",{className:ML.iconsControlsStrokeWidth,children:[e("span",{children:i("Stroke width")}),e(re,{min:.3,max:3,step:.1,value:"number"==typeof p?p:1,formatter:e=>`${e}px`,parser:e=>e?e.replace("px",""):"",onChange:e=>g("number"==typeof e?e:1)})]}),"gradient"===b?e(L,{size:8,children:e(ie,{defaultValue:[{color:a||"#108ee9",percent:0},{color:l||"#87d068",percent:100}],showText:!0,mode:"gradient",onChangeComplete:e=>{try{const t=e.toCssString().match(/(rgba?\([^)]+\)|#[0-9a-fA-F]{3,8})/g)||[];t[0]&&s(t[0]),t[1]&&c(t[1])}catch(e){console.warn("ColorPicker gradient parsing error",e)}},size:"small"})}):t(n,{children:[t("div",{className:ML.iconsControlElement,children:[e("span",{children:i("Color1")}),e(ie,{value:a,format:"hex",disabledAlpha:!0,onChange:(e,t)=>s(t),size:"middle"})]}),m&&t("div",{className:ML.iconsControlElement,children:[e("span",{children:i("Color2")}),e(ie,{value:l,format:"hex",disabledAlpha:!0,onChange:(e,t)=>c(t),size:"middle"})]}),v&&t("div",{className:ML.iconsControlElement,children:[e("span",{children:i("Color3")}),e(ie,{value:u,format:"hex",disabledAlpha:!0,onChange:(e,t)=>d(t),size:"middle"})]})]})]})}),e("div",{className:ML.iconsControlsHeader,children:e("div",{children:"family"===o?e(R,{className:ML.iconsControlsBackButton,type:"default",onClick:y,title:i("Back"),children:i("Back")}):null})})]})},DL=e(le,{style:{fontSize:20},spin:!0}),jL=({items:n,hasMore:r,loading:i,hasQuery:o,mode:a,selectedHash:s,onLoadMore:l,onItemClick:c,onInsert:u,scrollContainerRef:d,colorVars:h,svgTextMap:f,previewSize:p,selectedHashes:g,onToggleSelect:m})=>{const{t:v}=Qn(),{ThumbsUpIcon:y}=oo(),b=Boolean(g&&g.size>0),w=e("div",o?{className:ML.iconsGridEmptyState,children:e(uo,{})}:{className:ML.iconsGridEmptyState,children:t("div",{className:ML.resultsContainer,children:[e("span",{className:ML.videoIcon,children:e(y,{className:ML.playButton,style:{width:48,height:49,marginBottom:10}})}),e("h1",{className:ML.title,children:v("Millions of icons")}),e("p",{className:ML.subtitle,children:v("Enter a search query and we'll find the perfect icon for you")})]})});return t("div",{id:"iconsScrollableDiv",ref:d,className:ML.iconsGrid,children:[0!==n.length||i?e(lL,{dataLength:n.length,next:l,hasMore:r,scrollableTarget:"iconsScrollableDiv",className:ML.iconsGridInfiniteScroll,loader:e(k,{indicator:DL}),children:e("div",{className:`${ML.iconsGridGrid} ${b?ML.iconsGridShowCheckboxes:""}`,style:{"--icons-grid-min-col":`${Math.max(100,(null!=p?p:50)+48)}px`},children:n.map(n=>{var r,i,o,l,u,d,v,y,b,w,x;return t("div",{style:{border:g&&g.has(n.hash)||s===n.hash?"1px solid #1890ff":"1px solid #f0f0f0",boxShadow:g&&g.has(n.hash)||s===n.hash?"0 0 0 2px rgba(24,144,255,0.2)":"none"},className:ML.iconsGridItem,onClick:()=>{c(n),m&&"family"===a&&m(n.hash)},children:[e("div",{style:{height:null!=p?p:50},className:ML.iconsGridItemThumbnail,children:"family"===a&&f[n.hash]?e("div",{style:{color:null==h?void 0:h.colorHex,"--icon-grad-1":null!==(r=null==h?void 0:h.colorHex)&&void 0!==r?r:"#000","--icon-grad-2":null!==(i=null==h?void 0:h.colorHex2)&&void 0!==i?i:"#ff007a","--icon-color-1":null!==(o=null==h?void 0:h.colorHex)&&void 0!==o?o:"#000","--icon-color-2":null!==(l=null==h?void 0:h.colorHex2)&&void 0!==l?l:"#ff007a","--icon-color-3":null!==(u=null==h?void 0:h.colorHex3)&&void 0!==u?u:"#00C2FF","--icon-stroke-1":null!==(d=null==h?void 0:h.colorHex)&&void 0!==d?d:"#000","--icon-stroke-2":null!==(v=null==h?void 0:h.colorHex2)&&void 0!==v?v:"#ff007a","--icon-stroke-3":null!==(y=null==h?void 0:h.colorHex3)&&void 0!==y?y:"#00C2FF","--icon-fill-1":null!==(b=null==h?void 0:h.colorHex)&&void 0!==b?b:"#000","--icon-fill-2":null!==(w=null==h?void 0:h.colorHex2)&&void 0!==w?w:"#ff007a","--icon-fill-3":null!==(x=null==h?void 0:h.colorHex3)&&void 0!==x?x:"#00C2FF"},dangerouslySetInnerHTML:{__html:f[n.hash]},className:ML.iconsGridItemSvg}):e("img",{src:n.imagePreviewUrl,alt:n.name,style:{maxHeight:null!=p?p:96},className:ML.iconsGridItemImg})}),e("div",{className:ML.iconsGridItemName,title:n.name,children:n.name}),m?e("div",{onClick:e=>{e.stopPropagation()},className:ML.iconsGridCheckbox,children:e(D,{checked:Boolean(g&&g.has(n.hash)),onChange:()=>m(n.hash)})}):null]},n.hash)})})}):w,!i&&r&&n.length>0&&e("div",{style:{height:1},ref:e=>{if(!e||!d.current)return;const t=d.current;t.scrollHeight<=t.clientHeight&&l()}}),i&&0===n.length&&e("div",{className:ML.iconsGridLoading,children:e(k,{indicator:DL})})]})},zL="path|rect|circle|ellipse|polygon|line|polyline|g";function BL(e){const t=e.trim();if(!t||"none"===t||"transparent"===t)return null;if(/^url\(#/.test(t))return null;if(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(t)){const e=t.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/);return e?"#"+(3===e[1].length?e[1].replace(/(.)/g,"$1$1"):e[1]).toLowerCase():null}if(/^rgb\(/.test(t)){const e=t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(e)return"#"+[1,2,3].map(t=>parseInt(e[t],10).toString(16).padStart(2,"0")).join("")}if(/^rgba\(/.test(t)){const e=t.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*[\d.]+\s*\)/);if(e)return"#"+[1,2,3].map(t=>parseInt(e[t],10).toString(16).padStart(2,"0")).join("")}const n={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff"},r=t.toLowerCase();return n[r]?n[r]:("currentcolor"===r||"inherit"===r||/^[a-zA-Z]+$/.test(t),null)}function UL(e,t){const n=new RegExp(`${t}\\s*:\\s*([^;]+)`,"i"),r=e.match(n);return r?r[1].trim():null}function VL(e){let t=0;const n=new RegExp(`<(?:${zL})([^>]*)>`,"gi");let r;for(;null!==(r=n.exec(e));){const e=r[1],n=e.match(/fill\s*=\s*["']([^"']*)["']/i),i=e.match(/style\s*=\s*["']([^"']*)["']/i),o=n&&n[1]&&!/^none$/i.test(n[1])&&!/^url\(#/i.test(n[1]),a=i&&UL(i[1],"fill")&&!/^none$/i.test(UL(i[1],"fill"));(o||a)&&(t+=1)}return t}function HL(e){let t=0;const n=new RegExp(`<(?:${zL})([^>]*)>`,"gi");let r;for(;null!==(r=n.exec(e));){const e=r[1],n=e.match(/stroke\s*=\s*["']([^"']*)["']/i),i=e.match(/style\s*=\s*["']([^"']*)["']/i),o=n&&n[1]&&!/^none$/i.test(n[1])&&!/^url\(#/i.test(n[1]),a=i&&UL(i[1],"stroke")&&!/^none$/i.test(UL(i[1],"stroke"));(o||a)&&(t+=1)}return t}function WL(e){return/<linearGradient/i.test(e)||/<radialGradient/i.test(e)||/fill="url\(#|stroke="url\(#/i.test(e)}function $L(e){const t=e.trim().replace(/(?:px|em|ex|%)\s*$/i,""),n=parseFloat(t);return Number.isNaN(n)||n<=0||n>10?null:Math.round(10*n)/10}function GL(e){const t=[],n=e.indexOf("</defs>"),r=n>=0?e.slice(n):e,i=new RegExp(`<(?:${zL})[^>]*stroke-width\\s*=\\s*["']([^"']+)["']`,"gi");let o;for(;null!==(o=i.exec(r));){const e=$L(o[1]);null!=e&&t.push(e)}const a=new RegExp(`<(?:${zL})[^>]*style\\s*=\\s*["'][^"']*stroke-width\\s*:\\s*([^;"]+)[^"']*["']`,"gi");for(;null!==(o=a.exec(r));){const e=$L(o[1]);null!=e&&t.push(e)}if(0===t.length)return;t.sort((e,t)=>e-t);const s=Math.floor(t.length/2);return t.length%2==1?t[s]:(t[s-1]+t[s])/2}function qL(e){const t=function(e){const t=[],n=new Set;Array.from(e.matchAll(/<stop[^>]*?stop-color\s*=\s*["']([^"']+)["']/gi)).map(e=>e[1]).forEach(e=>{const r=BL(e);r&&!n.has(r)&&(n.add(r),t.push(e))});const r=new RegExp(`<(?:${zL})([^>]*)>`,"gi");let i;for(;null!==(i=r.exec(e));){const e=i[1],r=e.match(/fill\s*=\s*["']([^"']*)["']/i);if(r&&r[1]){const e=BL(r[1]);e&&!n.has(e)&&(n.add(e),t.push(r[1]))}const o=e.match(/stroke\s*=\s*["']([^"']*)["']/i);if(o&&o[1]){const e=BL(o[1]);e&&!n.has(e)&&(n.add(e),t.push(o[1]))}const a=e.match(/style\s*=\s*["']([^"']*)["']/i);if(a&&a[1]){const e=UL(a[1],"fill");if(e){const r=BL(e);r&&!n.has(r)&&(n.add(r),t.push(e))}const r=UL(a[1],"stroke");if(r){const e=BL(r);e&&!n.has(e)&&(n.add(e),t.push(r))}}}const o=e.match(/<svg([^>]*)>/i);if(o&&o[1]){const e=o[1];for(const[r,i]of[["fill",/fill\s*=\s*["']([^"']*)["']/i],["stroke",/stroke\s*=\s*["']([^"']*)["']/i]]){const r=e.match(i);if(r&&r[1]){const e=BL(r[1]);e&&!n.has(e)&&(n.add(e),t.push(r[1]))}}const r=e.match(/style\s*=\s*["']([^"']*)["']/i);if(r&&r[1])for(const e of["fill","stroke"]){const i=UL(r[1],e);if(i){const e=BL(i);e&&!n.has(e)&&(n.add(e),t.push(i))}}}return t}(e);return{colors:t,fillsCount:VL(e),strokesCount:HL(e),hasGradient:WL(e),strokeWidth:GL(e)}}const YL=new Map,XL="https://public-api.streamlinehq.com/v1";function KL(e,t,n,r){const o=i.useMemo(()=>t&&"string"==typeof t?t.replace(/\/$/,""):"/streamline",[t]),a=async e=>n?Promise.resolve(n(e)):e,s=null==r?void 0:r.trim(),l=i.useCallback(async e=>n?a(function(e){const{mode:t,q:n,offset:r,limit:i,familySlug:o,style:a}=e,s=new URLSearchParams;"global"===t&&(s.set("productType","icons"),s.set("productTier","free")),s.set("query",n),s.set("offset",String(r)),s.set("limit",String(i)),a&&s.set("style",a);const l="global"===t?"search/global":`search/family/${encodeURIComponent(o||"")}`;return`${XL}/${l}?${s.toString()}`}(e)):function(e,t){const{mode:n,q:r,offset:i,limit:o,familySlug:a,style:s}=t,l="global"===n?"search/global":`search/family/${encodeURIComponent(a||"")}`,c=new URL(`${e}/${l}`,window.location.origin);return"global"===n&&(c.searchParams.set("productType","icons"),c.searchParams.set("productTier","free")),c.searchParams.set("query",r),c.searchParams.set("offset",String(i)),c.searchParams.set("limit",String(o)),s&&c.searchParams.set("style",s),c.toString().replace(window.location.origin,"")}(o,e),[o,n]),c=i.useCallback(async e=>{var t;const n=await l({mode:e.mode,q:e.query.trim(),offset:e.offset,limit:e.limit,familySlug:e.familySlug,style:null!==(t=e.style)&&void 0!==t?t:null}),r={Accept:"application/json"};s&&(r["x-api-key"]=s);const i=await fetch(n,{method:"GET",headers:r,signal:e.signal});if(!i.ok){const e=await i.text();throw new Error(`Request failed: ${i.status} ${e}`)}return await i.json()},[l,s]),u=i.useCallback((e,t)=>{let n=e;const r=/<linearGradient[\s\S]*?<\/linearGradient>/i.test(n)||/<radialGradient[\s\S]*?<\/radialGradient>/i.test(n);if(!(/fill="url\(#/i.test(n)||/stroke="url\(#/i.test(n))){const e=function(e){var t,n,r,i,o,a,s,l;const c=new Map,u={v:1},d=e=>{const t=BL(e);t&&!c.has(t)&&(c.set(t,u.v),u.v=Math.min(u.v+1,3))},h=e.match(/<svg([^>]*)>/i);if(null==h?void 0:h[1]){const e=h[1],t=e.match(/fill\s*=\s*["']([^"']*)["']/i),n=e.match(/stroke\s*=\s*["']([^"']*)["']/i);!(null==t?void 0:t[1])||/^none$/i.test(t[1])||/^url\(#/i.test(t[1])||d(t[1]),!(null==n?void 0:n[1])||/^none$/i.test(n[1])||/^url\(#/i.test(n[1])||d(n[1])}const f=new RegExp(`<(?:${zL})([^>]*)>`,"gi");let p;for(;null!==(p=f.exec(e));){const e=p[1],c=e.match(/fill\s*=\s*["']([^"']*)["']/i),u=e.match(/style\s*=\s*["']([^"']*)["']/i),h=null===(t=null==u?void 0:u[1])||void 0===t?void 0:t.match(/fill\s*:\s*([^;]+)/i),f=null===(i=null!==(n=null==c?void 0:c[1])&&void 0!==n?n:null===(r=null==h?void 0:h[1])||void 0===r?void 0:r.trim())||void 0===i?void 0:i.trim();!f||/^none$/i.test(f)||/^url\(#/i.test(f)||d(f);const g=e.match(/stroke\s*=\s*["']([^"']*)["']/i),m=e.match(/style\s*=\s*["']([^"']*)["']/i),v=null===(o=null==m?void 0:m[1])||void 0===o?void 0:o.match(/stroke\s*:\s*([^;]+)/i),y=null===(l=null!==(a=null==g?void 0:g[1])&&void 0!==a?a:null===(s=null==v?void 0:v[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();!y||/^none$/i.test(y)||/^url\(#/i.test(y)||d(y)}return c}(n),t=t=>{const n=BL(t),r=n?e.get(n):void 0;return 1===r?"var(--icon-color-1)":2===r?"var(--icon-color-2)":3===r?"var(--icon-color-3)":"currentColor"};n=n.replace(/<svg([^>]*)>/i,(e,n)=>{let r=n;const i=n.match(/fill\s*=\s*["']([^"']*)["']/i);!(null==i?void 0:i[1])||/^none$/i.test(i[1])||/^url\(#/i.test(i[1])||(r=r.replace(/fill\s*=\s*["'][^"']*["']/i,`fill="${t(i[1])}"`));const o=n.match(/stroke\s*=\s*["']([^"']*)["']/i);return!(null==o?void 0:o[1])||/^none$/i.test(o[1])||/^url\(#/i.test(o[1])||(r=r.replace(/stroke\s*=\s*["'][^"']*["']/i,`stroke="${t(o[1])}"`)),`<svg${r}>`}),n=n.replace(/<(path|rect|circle|ellipse|polygon|line|polyline)([^>]*?)(\/>|>)/gi,(e,n,r,i)=>{var o,a,s,l,c,u,d,h;let f=r;const p=r.match(/fill\s*=\s*["']([^"']*)["']/i),g=r.match(/style\s*=\s*["']([^"']*)["']/i),m=null===(o=null==g?void 0:g[1])||void 0===o?void 0:o.match(/fill\s*:\s*([^;]+)/i),v=null===(l=null!==(a=null==p?void 0:p[1])&&void 0!==a?a:null===(s=null==m?void 0:m[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();if(v&&!/^none$/i.test(v)&&!/^url\(#/i.test(v)){const e=t(v);p?f=f.replace(/fill\s*=\s*["'][^"']*["']/i,`fill="${e}"`):(null==g?void 0:g[1])&&(f=f.replace(/style\s*=\s*["']([^"']*)["']/i,(t,n)=>`style="${n.replace(/fill\s*:\s*[^;]+/gi,`fill: ${e}`)}"`))}const y=r.match(/stroke\s*=\s*["']([^"']*)["']/i),b=r.match(/style\s*=\s*["']([^"']*)["']/i),w=null===(c=null==b?void 0:b[1])||void 0===c?void 0:c.match(/stroke\s*:\s*([^;]+)/i),x=null===(h=null!==(u=null==y?void 0:y[1])&&void 0!==u?u:null===(d=null==w?void 0:w[1])||void 0===d?void 0:d.trim())||void 0===h?void 0:h.trim();if(x&&!/^none$/i.test(x)&&!/^url\(#/i.test(x)){const e=t(x);y?f=f.replace(/stroke\s*=\s*["'][^"']*["']/i,`stroke="${e}"`):(null==b?void 0:b[1])&&(f=f.replace(/style\s*=\s*["']([^"']*)["']/i,(t,n)=>`style="${n.replace(/stroke\s*:\s*[^;]+/gi,`stroke: ${e}`)}"`))}return`<${n}${f}${i}`})}return r&&(n=n.replace(/<linearGradient([^>]*?)>([\s\S]*?)<\/linearGradient>/gi,(e,t,n)=>{let r=0;return`<linearGradient${t}>${n.replace(/<stop([^>]*?)>/gi,(e,t)=>{const n=0===r?"var(--icon-grad-1)":"var(--icon-grad-2)";if(r+=1,/stop-color\s*=/.test(t)){return"<stop"+t.replace(/stop-color="[^"]*"/i,'stop-color="'+n+'"')+">"}return"<stop"+t+' stop-color="'+n+'">'})}</linearGradient>`}),n=n.replace(/<radialGradient([^>]*?)>([\s\S]*?)<\/radialGradient>/gi,(e,t,n)=>{let r=0;return`<radialGradient${t}>${n.replace(/<stop([^>]*?)>/gi,(e,t)=>{const n=0===r?"var(--icon-grad-1)":"var(--icon-grad-2)";if(r+=1,/stop-color\s*=/.test(t)){return"<stop"+t.replace(/stop-color="[^"]*"/i,'stop-color="'+n+'"')+">"}return"<stop"+t+' stop-color="'+n+'">'})}</radialGradient>`})),"number"!=typeof(null==t?void 0:t.strokeWidth)||Number.isNaN(t.strokeWidth)||(/stroke-width\s*=\s*["'][^"']*["']/i.test(n)&&(n=n.replace(/stroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${t.strokeWidth}"`)),/stroke-width\s*:/.test(n)&&(n=n.replace(/stroke-width\s*:\s*[^;]+/gi,`stroke-width: ${t.strokeWidth}`)),/stroke-width/i.test(n)||(n=n.replace(/<svg/,`<svg stroke-width="${t.strokeWidth}"`))),n=n.replace(/<svg([^>]*)>/i,(e,t)=>`<svg${t.replace(/\swidth="[^"]*"/i,"").replace(/\sheight="[^"]*"/i,"")} width="100%" height="100%">`),n},[]),d=i.useCallback(async(t,r)=>{const i=[t,e?"css=1":"css=0",(null==r?void 0:r.colors)?`c=${r.colors}`:"",(null==r?void 0:r.backgroundColor)?`bg=${r.backgroundColor}`:"",null!=(null==r?void 0:r.strokeWidth)?`sw=${r.strokeWidth}`:"",null!=(null==r?void 0:r.size)?`s=${r.size}`:"",null!=(null==r?void 0:r.responsive)?`r=${r.responsive}`:"",null!=(null==r?void 0:r.strokeToFill)?`sf=${r.strokeToFill}`:""].filter(Boolean).join("|"),l=YL.get(i);if(l)return l;const c=await(async(e,t)=>{var r,i;const s=new URLSearchParams;(null==t?void 0:t.colors)&&s.set("colors",t.colors),(null==t?void 0:t.backgroundColor)&&s.set("backgroundColor",t.backgroundColor),null!=(null==t?void 0:t.strokeWidth)&&s.set("strokeWidth",String(t.strokeWidth)),s.set("size",String(null!==(r=null==t?void 0:t.size)&&void 0!==r?r:96)),s.set("responsive",String(null===(i=null==t?void 0:t.responsive)||void 0===i||i)),null!=(null==t?void 0:t.strokeToFill)&&s.set("strokeToFill",String(t.strokeToFill));const l=`${XL}/icons/${encodeURIComponent(e)}/download/svg?${s.toString()}`;if(n)return a(l);const c=new URL(`${o}/icons/${encodeURIComponent(e)}/download/svg`,window.location.origin);return s.forEach((e,t)=>c.searchParams.set(t,e)),c.toString().replace(window.location.origin,"")})(t,r),d={Accept:"image/svg+xml"};s&&(d["x-api-key"]=s);const h=await fetch(c,{method:"GET",headers:d,signal:null==r?void 0:r.signal});if(!h.ok){const e=await h.text();throw new Error(`SVG request failed: ${h.status} ${e}`)}let f=await h.text();const p=f;e&&!(null==r?void 0:r.colors)&&(f=u(f,{strokeWidth:null==r?void 0:r.strokeWidth}));const g={text:f,url:`data:image/svg+xml;utf8,${encodeURIComponent(f)}`,original:p};return YL.set(i,g),g},[o,u,e,n,a,s]),h=i.useCallback(async(e,t)=>{const r=await(async(e,t)=>{var r;const i=new URLSearchParams;i.set("size",String(null!==(r=null==t?void 0:t.size)&&void 0!==r?r:96)),(null==t?void 0:t.colors)&&i.set("colors",t.colors),(null==t?void 0:t.backgroundColor)&&i.set("backgroundColor",t.backgroundColor),null!=(null==t?void 0:t.strokeWidth)&&i.set("strokeWidth",String(t.strokeWidth));const s=`${XL}/icons/${encodeURIComponent(e)}/download/png?${i.toString()}`;if(n)return a(s);const l=new URL(`${o}/icons/${encodeURIComponent(e)}/download/png`,window.location.origin);return i.forEach((e,t)=>l.searchParams.set(t,e)),l.toString().replace(window.location.origin,"")})(e,t),i={Accept:"image/png"};s&&(i["x-api-key"]=s);const l=await fetch(r,{method:"GET",headers:i,signal:null==t?void 0:t.signal});if(!l.ok){const e=await l.text();throw new Error(`PNG request failed: ${l.status} ${e}`)}const c=await l.blob();return await new Promise((e,t)=>{const n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>t(new Error("Failed to read PNG blob")),n.readAsDataURL(c)})},[o,n,a,s]);return{buildUrl:l,performSearch:c,fetchSvgDataUrl:d,fetchPngDataUrl:h,normalizeSvgForCss:u}}const ZL=({apiKey:r,customRequest:o,query:a,setQuery:s,inputRef:l})=>{var c,u,d,h,f,p,g,m,v;const{t:y}=Qn(),[b,w]=i.useState(""),x=void 0!==a?a:b,C=void 0!==s?s:w,[_,S]=i.useState(""),[A,E]=i.useState("global"),[I,P]=i.useState(null),[M,N]=i.useState(null),[D,j]=i.useState(null),[z,B]=i.useState(null),[U,V]=i.useState([]),[H,W]=i.useState(0),[$,G]=i.useState(!1),[Y,X]=i.useState(!1),[Z,J]=i.useState(null),[Q,ee]=i.useState({}),[te,ne]=i.useState({}),[re,ie]=i.useState({}),[ae,se]=i.useState("#000000"),[le,ce]=i.useState("#ff007a"),[ue,de]=i.useState("#00C2FF"),[he,fe]=i.useState(1),[pe,ge]=i.useState(50),[me,ve]=i.useState(!0),[ye,be]=i.useState(!0),[we,xe]=i.useState(!1),Ce=ro(),{options:_e}=Ce,Se=i.useRef(null),ke=i.useRef(!1),Ae=i.useRef(null),Ee=i.useRef(0),Ie=i.useRef(!1),Te=i.useRef(null),Fe=i.useRef(null===(c=null==_e?void 0:_e.config)||void 0===c?void 0:c.handleTranslate),Oe=i.useRef(null===(u=null==_e?void 0:_e.config)||void 0===u?void 0:u.locale);i.useEffect(()=>{var e,t;Fe.current=null===(e=null==_e?void 0:_e.config)||void 0===e?void 0:e.handleTranslate,Oe.current=null===(t=null==_e?void 0:_e.config)||void 0===t?void 0:t.locale},[null===(d=null==_e?void 0:_e.config)||void 0===d?void 0:d.handleTranslate,null===(h=null==_e?void 0:_e.config)||void 0===h?void 0:h.locale]);const Pe=i.useRef(null),Me=i.useRef(null),Re=i.useRef(null),[Le,Ne]=i.useState(new Set),De=null!==(p=null===(f=null==_e?void 0:_e.config)||void 0===f?void 0:f.STREAMLINE_API_KEY)&&void 0!==p?p:"3pAQQzwUNMmcgSr2.f4eb08cd5886d44b1fc6a701a3ba797c",je=null===(g=null==_e?void 0:_e.config)||void 0===g?void 0:g.handleProxyUrl,ze=async e=>je?Promise.resolve(je(e)):e,Be=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{imagePreviewUrl:await ze(e.imagePreviewUrl)}))),{performSearch:Ue,fetchSvgDataUrl:Ve,fetchPngDataUrl:He,normalizeSvgForCss:We}=KL(ye,null===(m=null==_e?void 0:_e.config)||void 0===m?void 0:m.STREAMLINE_BASE_URL,je,De),$e=i.useMemo(()=>{if("family"!==A||0===U.length)return null;const e=new Set(U.map(e=>e.hash)),t=Object.keys(re).some(t=>e.has(t))?re:te,n=U.map(e=>t[e.hash]).filter(e=>Boolean(e));if(0===n.length)return null;return function(e){const t=[],n=new Set;let r,i=0,o=0,a=!1;for(const s of e){i+=s.fillsCount,o+=s.strokesCount,s.hasGradient&&(a=!0);for(const e of s.colors){const r=BL(e);r&&!n.has(r)&&(n.add(r),t.push(e))}null==r&&null!=s.strokeWidth&&(r=s.strokeWidth)}return{colors:t,fillsCount:i,strokesCount:o,hasGradient:a,strokeWidth:r}}(n.map(e=>qL(e)))},[U,A,re,te]);i.useMemo(()=>"family"===A&&(!!(null==$e?void 0:$e.hasGradient)||!!(I||"").toLowerCase().includes("gradient")),[$e,I,A]);const Ge=i.useMemo(()=>"family"===A&&U.some(e=>{const t=te[e.hash];return t&&/var\(--icon-color-2\)/i.test(t)}),[U,A,te]),qe=i.useMemo(()=>"family"===A&&U.some(e=>{const t=te[e.hash];return t&&/var\(--icon-color-3\)/i.test(t)}),[U,A,te]),Ye=i.useMemo(()=>!!ye&&(!!$e&&($e.hasGradient||$e.colors.length>=2&&Ge)),[$e,ye,Ge]),Xe=i.useMemo(()=>!!ye&&(!!$e&&($e.colors.length>=3&&qe)),[$e,ye,qe]);i.useEffect(()=>(ke.current=!0,()=>{var e,t,n;ke.current=!1;try{null===(e=Pe.current)||void 0===e||e.abort(),null===(t=Me.current)||void 0===t||t.abort(),null===(n=Re.current)||void 0===n||n.abort()}catch(e){}}),[]);const Ke=i.useRef(x),Ze=i.useCallback(async e=>{var t,n,r,i,o,a,s,l;const c=null!==(n=null===(t=e.override)||void 0===t?void 0:t.query)&&void 0!==n?n:_;if(!c||0===c.trim().length)return;if(Y)return;if(!ke.current)return;null===(r=Pe.current)||void 0===r||r.abort();const u=new AbortController;Pe.current=u,X(!0);const d=e.initial?0:H,h=e.initial?30:20,f=null!==(o=null===(i=e.override)||void 0===i?void 0:i.mode)&&void 0!==o?o:A,p=null!==(s=null===(a=e.override)||void 0===a?void 0:a.familySlug)&&void 0!==s?s:I,g=c.trim();try{const t=await Ue({mode:f,familySlug:p||null,query:g,offset:d,limit:h,style:D,signal:u.signal});if(!ke.current)return;if(e.initial)V(await Be(t.results));else{const e=await Be(t.results);V(t=>[...t,...e])}G(Boolean(null===(l=t.pagination)||void 0===l?void 0:l.hasMore)),W(d+h)}catch(e){if("AbortError"===(null==e?void 0:e.name))return;console.error(e),oe.error(y("Request error"))}finally{ke.current&&X(!1)}},[_,I,je,U,Y,A,H,Ue,D,y]);i.useEffect(()=>{Te.current=Ze},[Ze]),i.useEffect(()=>{if("family"===A){const e=window.setTimeout(()=>{Ie.current=!1},100);return()=>window.clearTimeout(e)}Ie.current=!1},[A]);const Je=i.useCallback(async e=>{var t;if(!e||0===e.trim().length)return;const n=++Ee.current;let r=e.trim();if(Fe.current)try{r=await Fe.current(e,{locale:Oe.current})}catch(t){console.error("IconsTab: translation error",t),r=e}n===Ee.current&&(E("global"),P(null),B(null),V([]),G(!1),W(0),J(null),Ne(new Set),S(r),await(null===(t=Te.current)||void 0===t?void 0:t.call(Te,{initial:!0,override:{query:r}})))},[]),Qe=i.useCallback(async()=>{x&&0!==x.trim().length&&await Je(x)},[x,Je]),et=i.useCallback(()=>{Ee.current+=1,E("global"),P(null),N(null),B(null),j(null),S(""),V([]),G(!1),W(0),J(null),Ne(new Set),se("#000000"),ce("#ff007a"),de("#00C2FF")},[]);i.useEffect(()=>{const e=Ke.current;e&&e.trim().length>=3&&Je(e)},[]),i.useEffect(()=>{const e=x.trim();Ae.current&&(window.clearTimeout(Ae.current),Ae.current=null),e.length<3?et():Ae.current=window.setTimeout(()=>{Je(e)},700)},[x,D,et,Je]);const tt=i.useCallback(()=>{Ie.current||$&&!Y&&Ze({initial:!1})},[Ze,$,Y]),nt=i.useCallback(e=>{if("global"===A){if(!e.familySlug||!_)return;return Ae.current&&(window.clearTimeout(Ae.current),Ae.current=null),Ie.current=!0,E("family"),P(e.familySlug),N(e.hash),B(e.categoryName||null),V([]),G(!1),W(0),J(null),Ne(new Set),se("#000000"),ce("#ff007a"),de("#00C2FF"),void Ze({initial:!0,override:{mode:"family",familySlug:e.familySlug,query:_}})}J(e.hash)},[_,Ze,A]),rt=i.useCallback(()=>{const e=_.trim();E("global"),P(null),N(null),B(null),V([]),G(!1),W(0),J(null),Ne(new Set),se("#000000"),ce("#ff007a"),de("#00C2FF"),e&&Ze({initial:!0,override:{mode:"global",familySlug:null,query:e}})},[_,Ze]);i.useEffect(()=>{var e;if("family"!==A||0===U.length)return;const t=new Set(U.map(e=>e.hash));let n=U.map(e=>e.hash).filter(e=>!Q[e]||!te[e]);if(!M||t.has(M)||re[M]||(n=[M,...n]),0===n.length)return;let r=!1;null===(e=Me.current)||void 0===e||e.abort();const i=new AbortController;return Me.current=i,Promise.all(n.map(e=>Ve(e,{colors:ye?void 0:ae,strokeWidth:he,size:pe,responsive:me,signal:i.signal}).then(t=>({h:e,r:t})).catch(()=>null))).then(e=>{if(r||!ke.current)return;const t={},n={},i={};e.forEach(e=>{e&&e.h&&e.r&&(t[e.h]=e.r.url,n[e.h]=e.r.text,e.r.original&&(i[e.h]=e.r.original))}),Object.keys(t).length>0&&ee(e=>Object.assign(Object.assign({},e),t)),Object.keys(n).length>0&&ne(e=>Object.assign(Object.assign({},e),n)),Object.keys(i).length>0&&ie(e=>Object.assign(Object.assign({},e),i))}),()=>{r=!0,i.abort()}},[ae,M,Ve,U,A,re,me,pe,he,te,Q,ye]),i.useEffect(()=>{if("family"!==A)return;if(0===U.length)return;const e=U.map(e=>e.hash),t={},n={};let r=!1;e.forEach(e=>{const i=re[e]||te[e];if(!i)return;const o=We(i,{strokeWidth:"number"==typeof he?he:void 0});o&&o!==te[e]&&(t[e]=o,n[e]=`data:image/svg+xml;utf8,${encodeURIComponent(o)}`,r=!0)}),r&&(Object.keys(t).length>0&&ne(e=>Object.assign(Object.assign({},e),t)),Object.keys(n).length>0&&ee(e=>Object.assign(Object.assign({},e),n)))},[U,A,We,re,he,te]);const it=i.useRef(null);i.useEffect(()=>{var e;if("family"!==A||0===U.length)return;const t=M&&re[M]?M:null===(e=U[0])||void 0===e?void 0:e.hash;if(!t||!re[t])return;if(it.current===I)return;const n=re[t];if(!n)return;it.current=I;const r=function(e){var t,n,r,i,o,a,s,l;const c=[],u=new Set,d=e=>{const t=BL(e);t&&!u.has(t)&&(u.add(t),c.push(e))},h=Array.from(e.matchAll(/<stop[^>]*?stop-color\s*=\s*["']([^"']+)["']/gi)).map(e=>e[1]);if(h.length>=2)return h.slice(0,3).forEach(e=>d(e)),c;const f=e.match(/<svg([^>]*)>/i);if(null==f?void 0:f[1]){const e=f[1],t=e.match(/fill\s*=\s*["']([^"']*)["']/i),n=e.match(/stroke\s*=\s*["']([^"']*)["']/i);!(null==t?void 0:t[1])||/^none$/i.test(t[1])||/^url\(#/i.test(t[1])||d(t[1]),!(null==n?void 0:n[1])||/^none$/i.test(n[1])||/^url\(#/i.test(n[1])||d(n[1])}const p=new RegExp(`<(?:${zL})([^>]*)>`,"gi");let g;for(;null!==(g=p.exec(e));){const e=g[1],c=e.match(/fill\s*=\s*["']([^"']*)["']/i),u=e.match(/style\s*=\s*["']([^"']*)["']/i),h=null===(t=null==u?void 0:u[1])||void 0===t?void 0:t.match(/fill\s*:\s*([^;]+)/i),f=null===(i=null!==(n=null==c?void 0:c[1])&&void 0!==n?n:null===(r=null==h?void 0:h[1])||void 0===r?void 0:r.trim())||void 0===i?void 0:i.trim();!f||/^none$/i.test(f)||/^url\(#/i.test(f)||d(f);const p=e.match(/stroke\s*=\s*["']([^"']*)["']/i),m=e.match(/style\s*=\s*["']([^"']*)["']/i),v=null===(o=null==m?void 0:m[1])||void 0===o?void 0:o.match(/stroke\s*:\s*([^;]+)/i),y=null===(l=null!==(a=null==p?void 0:p[1])&&void 0!==a?a:null===(s=null==v?void 0:v[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();!y||/^none$/i.test(y)||/^url\(#/i.test(y)||d(y)}return c.slice(0,3)}(n),i=e=>{const t=(e||"").trim().match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);if(t){return"#"+(3===t[1].length?t[1].replace(/(.)/g,"$1$1"):t[1]).toLowerCase()}return function(e){var t;const n=e.trim();if(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(n)){const e=n.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/);if(e)return"#"+(3===e[1].length?e[1].replace(/(.)/g,"$1$1"):e[1]).toLowerCase()}const r=n.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(r)return"#"+[1,2,3].map(e=>parseInt(r[e],10).toString(16).padStart(2,"0")).join("");const i=n.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*[\d.]+\s*\)/);return i?"#"+[1,2,3].map(e=>parseInt(i[e],10).toString(16).padStart(2,"0")).join(""):null!==(t={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff"}[n.toLowerCase()])&&void 0!==t?t:BL(n)||"#000000"}(e)};r[0]&&se(i(r[0])),r[1]&&ce(i(r[1])),r[2]&&de(i(r[2]))},[U,A,re,I,M]),i.useEffect(()=>{"family"!==A&&(it.current=null)},[A]);const ot=i.useRef(null);i.useEffect(()=>{if("family"!==A||!I||0===U.length)return;const e=U[0];if(!e||!re[e.hash])return;if(ot.current===I)return;const t=re[e.hash];if(!t)return;const n=qL(t);"number"==typeof n.strokeWidth&&n.strokeWidth>0&&(ot.current=I,fe(n.strokeWidth))},[U,A,re,I]),i.useEffect(()=>{"family"!==A&&(ot.current=null)},[A]);const at=i.useCallback(e=>function(e,t){const{colorHex:n,colorHex2:r,colorHex3:i}=t,o=[`--icon-grad-1: ${n}`,`--icon-grad-2: ${r}`,`--icon-stroke-1: ${n}`,`--icon-stroke-2: ${r}`,`--icon-stroke-3: ${i}`,`--icon-fill-1: ${n}`,`--icon-fill-2: ${r}`,`--icon-fill-3: ${i}`,`color: ${n}`].join(";");let a=e.replace(/<svg([^>]*)>/i,(e,t)=>{let n=t;return/style="/i.test(n)?n=n.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};${o}"`):n+=` style="${o}"`,`<svg${n}>`});return a=a.replace(/var\(--icon-color-1\)/g,n).replace(/var\(--icon-color-2\)/g,r).replace(/var\(--icon-color-3\)/g,i).replace(/var\(--icon-fill-1\)/g,n).replace(/var\(--icon-fill-2\)/g,r).replace(/var\(--icon-fill-3\)/g,i).replace(/var\(--icon-stroke-1\)/g,n).replace(/var\(--icon-stroke-2\)/g,r).replace(/var\(--icon-stroke-3\)/g,i).replace(/var\(--icon-grad-1\)/g,n).replace(/var\(--icon-grad-2\)/g,r).replace(/currentColor/g,n),a}(e,{colorHex:ae,colorHex2:le,colorHex3:ue}),[ae,le,ue]),st=i.useCallback(e=>{Ne(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),lt=i.useCallback(()=>{Ne(new Set)},[]),ct=i.useMemo(()=>{if(1===Le.size){const[e]=Array.from(Le);return U.find(t=>t.hash===e)||null}return 0===Le.size&&Z&&U.find(e=>e.hash===Z)||null},[U,Z,Le]),ut=i.useCallback((e,t="image/png")=>{try{const n=e.split(",");if(n.length<2)return new Blob([],{type:t});const r=n[1]||"",i=atob(r),o=new Array(i.length);for(let e=0;e<i.length;e+=1)o[e]=i.charCodeAt(e);const a=new Uint8Array(o);return new Blob([a],{type:t})}catch(e){return new Blob([],{type:t})}},[]),dt=i.useCallback(async(e,t)=>{try{const n=async e=>{const t="family"===A?at(e):e,n=function(e,t){const n=e.match(/\swidth="([0-9.]+)(px)?"/i),r=e.match(/\sheight="([0-9.]+)(px)?"/i);if(n&&r){const e=parseFloat(n[1]),i=parseFloat(r[1]);if(Number.isFinite(e)&&Number.isFinite(i)&&e>0&&i>0){const n=e/i;return n>=1?{width:t,height:Math.max(1,Math.round(t/n))}:{width:Math.max(1,Math.round(t*n)),height:t}}}const i=e.match(/viewBox="([^"]+)"/i);if(i){const e=i[1].trim().split(/\s+/);if(4===e.length){const n=parseFloat(e[2]),r=parseFloat(e[3]);if(Number.isFinite(n)&&Number.isFinite(r)&&n>0&&r>0){const e=n/r;return e>=1?{width:t,height:Math.max(1,Math.round(t/e))}:{width:Math.max(1,Math.round(t*e)),height:t}}}}return{width:t,height:t}}(t,pe);return async function(e,t,n){const r=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(r);try{const e=new Image;return await new Promise((r,o)=>{e.onload=()=>{const i=document.createElement("canvas"),a=Math.max(1,Math.round(2*t)),s=Math.max(1,Math.round(2*n));i.width=a,i.height=s;const l=i.getContext("2d");l?(l.clearRect(0,0,a,s),l.drawImage(e,0,0,a,s),r(i.toDataURL("image/png"))):o(new Error("Canvas 2D context is not available"))},e.onerror=()=>o(new Error("Failed to load SVG image")),e.src=i})}finally{URL.revokeObjectURL(i)}}(t,n.width,n.height)},r=async e=>{const r=await Ve(e,{colors:ye?void 0:ae,strokeWidth:"number"==typeof he?he:void 0,size:pe,responsive:me,signal:t}),i=r.original||r.text;return n(i)};if("family"!==A)try{return await He(e.hash,{size:pe,colors:ye?void 0:ae,strokeWidth:"number"==typeof he?he:void 0,signal:t})}catch(t){return e.hash?await r(e.hash):null}const i=te[e.hash]||re[e.hash];return i?n(i):e.hash?await r(e.hash):null}catch(e){return null}},[at,ae,Ve,He,A,re,me,pe,he,te,ye]),ht=i.useCallback(async e=>{var t;try{if(!ke.current)return;xe(!0),null===(t=Re.current)||void 0===t||t.abort();const n=new AbortController;Re.current=n;const r=await dt(e,n.signal);if(!ke.current||!r)return;await Promise.resolve(o(r))}catch(e){console.error("IconsTab: insert error",e),oe.error(y("Request error"))}finally{ke.current&&xe(!1)}},[o,dt,y]);i.useCallback(()=>{var e;J(null),lt();const t=null===(e=null==_e?void 0:_e.config)||void 0===e?void 0:e.onClose;"function"==typeof t&&t()},[lt,_e]);const{isCopyIconsModalVisible:ft,isCopyLoading:pt,copyForm:gt,openCopyModal:mt,closeCopyModal:vt,resetAfterClose:yt,handleCopyTreeSelect:bt,handleIconsCopyOk:wt,fetchChildFolders:xt,generateMenuItemsFromFolders:Ct,handleCreateFolderAndCopy:_t}=(({items:e,selectedHashes:t,getPngDataUrlForItem:n,dataUrlToBlob:r,clearSelection:o})=>{const{t:a}=Qn(),{options:s,state:l}=ro(),c=bo(),[u,d]=i.useState(!1),[h]=T.useForm(),[f,p]=i.useState(!1),g=i.useRef(!1),{state:m,actions:{fetchFolders:v,fetchChildFolders:y,handleModalOk:b}}=Ho(),{EmptyFolderIcon:w}=oo(),{activeFormField:x,setActiveFormField:C,generateMenuItemsFromFolders:_}=Gs({folders:Array.isArray(m.folders)?m.folders:[],selectedFolder:l.selectedFolder,EmptyFolderIcon:w,handleCreateFolderModalOk:b,setIsLoading:p,t:a}),S=i.useCallback(async()=>{await v(),d(!0)},[v]),k=i.useCallback(async e=>{e.length>0&&(h.setFieldsValue({targetFolder:e[0]}),x!==e[0].toString()&&C(""))},[x,h,C]),A=i.useCallback(async i=>{var u,d;try{const{dataProviders:d}=s;if(!d||!d.uploadFile&&!d.uploadFiles)return void c.error({id:"FILES_UPLOAD_PROVIDER_NOT_CONFIGURED",message:a("API-endpoint for file upload is not configured"),placement:"bottomRight"});const h=i||(null==l?void 0:l.selectedFolder)||void 0,f=Array.from(t);if(0===f.length)return;const p=null!==(u=d.uploadFile)&&void 0!==u?u:async e=>{var t,n,r;if(!d.uploadFiles)throw new Error("Upload is not supported by data provider");const i=await d.uploadFiles({folderId:e.folderId,items:[{name:e.name,size:e.size,type:e.type,folderId:e.folderId,data:e.data,extension:e.extension}]}),o=null===(t=null==i?void 0:i.detailed)||void 0===t?void 0:t[0];if(!i||!i.success||!o||!1===o.success){const e=(null===(n=null==o?void 0:o.error)||void 0===n?void 0:n.message)||(null===(r=null==i?void 0:i.error)||void 0===r?void 0:r.message)||"Upload failed";throw new Error(e)}return o.data},{successCount:g,failCount:m}=await async function(e){var t;const{hashes:n,items:r,folderId:i,dataProviders:o,getPngDataUrlForItem:a,dataUrlToBlob:s}=e;let l=0,c=0;for(const e of n){const n=r.find(t=>t.hash===e);if(!n){c+=1;continue}const u=await a(n);if(!u){c+=1;continue}const d=`${(null===(t=n.name)||void 0===t?void 0:t.trim())||`icon-${e}`}.png`,h=s(u,"image/png");try{await o.uploadFile({name:d,size:h.size,type:"image/png",folderId:i,data:h,extension:"png"}),l+=1}catch(e){c+=1}}return{successCount:l,failCount:c}}({hashes:f,items:e,folderId:h,dataProviders:{uploadFile:p},getPngDataUrlForItem:n,dataUrlToBlob:r});g>0&&c.success({id:"FILES_COPY_SUCCESS",message:a("Files copied"),placement:"bottomRight",data:{successCount:g,totalCount:f.length,itemIds:f,folderId:null!=h?h:null}}),m>0&&c.error({id:"FILES_COPY_ERROR",message:a("При копировании произошли ошибки"),placement:"bottomRight",data:{failCount:m,totalCount:f.length,itemIds:f,folderId:null!=h?h:null}}),o()}catch(e){console.error(e),c.error({id:"FILES_COPY_ERROR",message:a("При копировании произошли ошибки"),placement:"bottomRight",innerException:e,data:{failCount:Array.from(t).length||0,totalCount:Array.from(t).length||0,itemIds:Array.from(t),folderId:null!==(d=null==l?void 0:l.selectedFolder)&&void 0!==d?d:null}})}},[o,r,n,e,c,s,t,null==l?void 0:l.selectedFolder,a]),E=i.useCallback(()=>{f||g.current||(d(!1),C(""),p(!1))},[f,C]),I=i.useCallback(()=>{C(""),p(!1)},[C]),F=i.useCallback(async e=>{if(!g.current){g.current=!0,p(!0);try{await A(null!=e?e:null),d(!1),C("")}finally{g.current=!1,p(!1)}}},[A,C]),O=i.useCallback(()=>{var e;const t=null!==(e=l.selectedFolder)&&void 0!==e?e:"folders";C(t),h.setFieldsValue({folderName:a("New folder"),targetFolder:t})},[h,l.selectedFolder,C,a]);return{isCopyIconsModalVisible:u,isCopyLoading:f,copyForm:h,openCopyModal:S,closeCopyModal:E,resetAfterClose:I,handleCopyTreeSelect:k,handleIconsCopyOk:F,handleCreateFolderAndCopy:O,fetchChildFolders:y,generateMenuItemsFromFolders:_}})({items:U,selectedHashes:Le,getPngDataUrlForItem:dt,dataUrlToBlob:ut,clearSelection:lt});return t(n,{children:[t("div",{className:`${ML.iconsTab} ${_.trim()?ML.hasSearch:""}`,children:[_.trim()&&(U.length>0||Y)&&Le.size>0?e(n,{children:t("div",{className:ML.iconsHeaderContainer,children:[t("div",{className:ML.iconsHeaderContainerLeft,children:[t(O.Text,{type:"secondary",children:[Le.size," ",y("selected")]}),e(R,{icon:e(bi,{size:16}),onClick:lt,children:y("Deselected")})]}),e(L,{children:e(R,{icon:e(oi,{size:16}),onClick:mt,children:y("Copy to folder")})})]})}):e(LL,{query:x,onQueryChange:C,onSubmit:Qe,styleFilter:D,onStyleChange:j,hasResults:U.length>0||Y,inputRef:l}),"family"===A?e(NL,{mode:A,familySlug:I,categoryName:z,colorHex:ae,setColorHex:se,colorHex2:le,setColorHex2:ce,colorHex3:ue,setColorHex3:de,sizePx:pe,setSizePx:ge,strokeWidth:he,setStrokeWidth:fe,responsiveSvg:me,setResponsiveSvg:ve,useCssColor:ye,setUseCssColor:be,showSecondColor:Ye,showThirdColor:Xe,styleFilter:D,onBack:rt}):null,e(jL,{items:U,hasMore:$,loading:Y,hasQuery:Boolean(_.trim()),mode:A,selectedHash:Z,onLoadMore:tt,onItemClick:nt,onInsert:ht,scrollContainerRef:Se,colorVars:{colorHex:ae,colorHex2:le,colorHex3:ue},svgTextMap:te,previewSize:pe,selectedHashes:Le,onToggleSelect:st}),ct?t("div",{className:ML.iconsBottomBar,children:[e(K,{className:"zero-divider"}),e("div",{className:ML.iconsBottomBarContent,children:e(L,{children:e(R,{size:"large",type:"primary",style:{height:40},loading:we,onClick:()=>ht(ct),children:y("Choose")})})})]}):null]}),e(q,{title:e("div",{className:"modal-title",children:y("Copy to folder")}),open:ft,onCancel:()=>{pt||vt()},maskClosable:!pt,closable:!pt,keyboard:!pt,footer:t("div",{className:Ws.formFooter,children:[t(R,{className:Ws.folderButton,onClick:_t,loading:pt,children:[e(ui,{size:18,strokeWidth:null===(v=_e.config)||void 0===v?void 0:v.iconStrokeWidth}),y("Create folder")]}),e(R,{type:"primary",className:Ws.folderButton,onClick:()=>{vt()},loading:pt,children:y("Done")})]}),afterClose:()=>yt(),children:t("div",{className:ML.copyToFolderModalBody,children:[pt?e("div",{className:ML.copyToFolderModalLoadingOverlay,children:e(k,{size:"large"})}):null,e(T,{form:gt,layout:"vertical",initialValues:{targetFolder:"folders",folderName:y("New folder"),is_force_create:!1},children:t("div",{className:Ws.foldersWrapper,children:[e(T.Item,{name:"targetFolder",rules:[{required:!0,message:y("Select the destination folder")}],className:Ws.formItem,children:e(Vs,{onSelect:bt,generateMenuItems:()=>Ct({targetForm:gt,onTreeSelect:bt,onComplete:wt,actionButtonText:y("Copy here")}),fetchChildFolders:xt,disabledFolders:[],mode:"selection",className:"folderSelectionTree",defaultExpandAll:!0})}),e(T.Item,{name:"folderName",style:{display:"none"},rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(y("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{})}),e(T.Item,{name:"is_force_create",style:{display:"none"},children:e(F,{})})]})})]})})]})},JL=e=>{(null==e?void 0:e.customTheme)&&((e={})=>{const t=document.querySelector("head");if(!t)return;const n=document.createElement("style");if(n.type="text/css",n.dataset.themeVariablesFm="true",n.setAttribute("data-file-manager","true"),Object.entries(e).length){let r="";Object.entries(e).forEach(([e,t])=>{"object"!=typeof t&&(r+=`\t--${e}: ${t};\n`)}),r=`.em-filemanager {\n${r}}`,n.appendChild(document.createTextNode(r));const i=t.querySelector('[data-theme-variables-fm="true"]');i?t.replaceChild(n,i):t.insertBefore(n,t.firstChild)}})(null==e?void 0:e.customTheme)},{Sider:QL,Content:eN}=Q,tN={keywords:""},nN=()=>{var s,l,d;const h=Ho(),f=es(),p=(()=>{var e,t;const{state:n,actions:r,options:i}=ro(),{selectedFolder:o,pathHistory:a,folders:s}=n,{t:l}=Qn(),{setSelectedFolder:u,setPathHistory:d}=r,h=c(()=>{var e;return`em_fm:lastFolder:${(null===(e=null==i?void 0:i.config)||void 0===e?void 0:e.projectId)||"default"}`},[null===(e=null==i?void 0:i.config)||void 0===e?void 0:e.projectId]),f=c((e,t=new Set)=>{if(t.has(e))return console.warn(`Cycle detected in the path to the folder with id=${e}`),[];const n=(Array.isArray(s)?s:[]).find(t=>t.id===e);if(!n)return[];const r=new Set(t);return r.add(e),n.parentId?n.parentId===n.id?(console.warn(`Cycle detected: folder ${n.id} is a parent of itself`),[{id:n.id,name:n.name+" (ошибка)"}]):[...f(n.parentId,r),{id:n.id,name:n.name}]:[{id:n.id,name:n.name}]},[s]),p=c(e=>{var t;if("undefined"==typeof window)return;const n=!0===(null===(t=null==i?void 0:i.config)||void 0===t?void 0:t.rememberLastFolder),r=h();try{if(!n)return void localStorage.removeItem(r);e?localStorage.setItem(r,e):localStorage.removeItem(r)}catch(e){}},[h,null===(t=null==i?void 0:i.config)||void 0===t?void 0:t.rememberLastFolder]),g=c(e=>{if("folders"===e){const e=[{id:"folders",name:l("Folders")}];return null==d||d(e),void(i.onPathChange&&i.onPathChange([]))}const t=(Array.isArray(s)?s:[]).find(t=>t.id===e);if(!t)return void console.warn("⚠️ Folder not found:",e);const n=f(e),r=[{id:"folders",name:l("Folders")},...n];null==d||d(r),i.onPathChange&&i.onPathChange(r.map(e=>e.name))},[s,f,d,i,l]),m=c(e=>{const t="folders"===e?null:e;t!==o&&(null==u||u(t),p(t),g(e))},[p,o,u,g]),v=c(e=>{if(-1===e)null==u||u(null),null==d||d([{id:"folders",name:l("Folders")}]),i.onPathChange&&i.onPathChange([]);else{const t=a.slice(0,e+1),n=t[t.length-1],r="folders"===n.id?void 0:n.id;null==u||u(r||null),null==d||d(t),i.onPathChange&&i.onPathChange(t.map(e=>e.name))}},[i,a,d,u,l]),y=c(e=>{if(!e.isFolder)return;null==u||u(e.id);const t={id:e.id,name:e.name};if(d){const e=[...a,t];d(e)}if(i.onPathChange){const t=[...a.map(e=>e.name),e.name];i.onPathChange(t)}},[i,a,d,u]);return{state:{selectedFolder:o,pathHistory:a},actions:{handleFolderSelect:m,handleBreadcrumbClick:v,handleItemClick:y},selectedFolder:o,pathHistory:a,handleFolderSelect:m,handleBreadcrumbClick:v,handleItemClick:y}})(),g=(()=>{const{state:e,actions:t}=ro(),{pagination:n}=e,{setPagination:r}=t,i=c((e,t)=>{const i=t||n.pageSize;null==r||r({current:e,pageSize:i,total:n.total})},[n.pageSize,n.total,r]);return{state:{pagination:n},actions:{handlePaginationChange:i}}})(),m=(()=>{const[e,t]=r.useState(()=>{const e=localStorage.getItem(ts);return e?Math.max(290,parseInt(e,10)):298}),[n,i]=r.useState(!1),[o,a]=r.useState(!1),[s,l]=r.useState(0),c=r.useCallback(()=>{t(298),localStorage.setItem(ts,298..toString())},[]),u=r.useCallback(n=>{n.preventDefault(),n.stopPropagation(),i(!0),document.body.classList.add("resizing");const r=n.clientX,o=e;let s=o;const c=e=>{e.preventDefault();const n=Math.max(Math.min(o+e.clientX-r,600),290);s=n,t(n),l(e.clientX),a(!0)},u=()=>{i(!1),document.body.classList.remove("resizing"),a(!1),localStorage.setItem(ts,s.toString()),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)},[e]);return r.useEffect(()=>()=>{document.body.classList.remove("resizing")},[]),{sidebarWidth:e,isResizing:n,showResizeGuide:o,resizeGuidePosition:s,handleResizeStart:u,handleDoubleClick:c}})(),v=(()=>{const[e,t]=o([]),[n,r]=o(!1),[i,a]=o(!1),s=u(0),l=u(new Map),d=c(()=>(s.current+=1,`upload_${s.current}_${Date.now()}`),[]),h=c(e=>Co(e.size),[]),f=c((e,n)=>{const i=n.map(t=>({id:d(),folderId:e,name:t.name,size:h(t),status:"uploading",progress:0}));return t(i),r(!0),a(!1),i.map(e=>e.id)},[d,h]),p=c((e,n)=>{const i={id:d(),folderId:e,name:n,size:void 0,status:"uploading",progress:0};return t(e=>[...e,i]),r(!0),a(!1),i.id},[d]),g=c((e,n)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{progress:Math.min(100,Math.max(0,n))}):t))},[]),m=c((e,n)=>{n&&l.current.set(e,n),t(t=>t.map(t=>{if(t.id===e){const e=Object.assign(Object.assign({},t),{status:"success",progress:100});return(null==n?void 0:n.name)&&(e.name=n.name),(null==n?void 0:n.size)&&void 0===t.size&&(e.size=Co(n.size)),e}return t}))},[]),v=c((e,n)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{status:"error",error:n}):t))},[]),y=c(()=>{r(!1),a(!1),setTimeout(()=>{t([]),l.current.clear()},300)},[]),b=c(()=>{a(e=>!e)},[]),w=c(e=>l.current.get(e),[]),x=e.length,C=e.filter(e=>"success"===e.status||"error"===e.status).length;return{uploadFiles:e,isUploadVisible:n,isUploadMinimized:i,totalFiles:x,completedFiles:C,startUpload:f,startUploadByUrl:p,updateProgress:g,markAsSuccess:m,markAsError:v,getUploadedFile:w,closeUpload:y,minimizeUpload:b}})(),y=za(),{deleteItems:b}=Wo(),w=bo(),{t:C}=Qn(),{options:_,state:S,actions:A}=ro(),E=_,I=null==E?void 0:E.onChangeSelection,T=S,F=null==E?void 0:E.config,{dataProviders:O}=E,{form:P,urlForm:M,renameForm:L,moveForm:N,renameFolderForm:D,copyForm:j,isModalVisible:z,isUrlModalVisible:B,isMoveModalVisible:U,isRenameFolderModalVisible:V,isCopyModalVisible:H,isDeleteConfirmVisible:W,folderToRename:$,activeLibraryItem:G}=S,{setIsUrlModalVisible:q,setActiveLibraryItem:Y}=A,{config:X}=_,{DropZoneFileIcon:Z}=oo(),[J,ee]=o(!1),[te,ne]=o(!1),[re,ie]=o(!1),oe=u(0),ae=u(!1);ae.current=te;const se=i.useRef(null),le=i.useRef([]),[ce,ue]=o(!1),[de,he]=o(!1),fe=Wa(e=>e.selectedFiles),pe=Wa(e=>e.clearSelection),ge=Wa(e=>e.syncVisibleFiles),{folders:me,loading:ve}=h.state,{fetchFolders:ye,fetchChildFolders:be,handleCreateFolder:we,handleModalOk:xe,handleModalCancel:Ce,generateMenuItems:_e}=h.actions,Se=(e=>{var t;const{state:n,actions:r,options:i}=ro(),{t:o}=Qn(),a=bo(),{folders:s,folderToRename:l,renameFolderForm:u,isRenameFolderModalVisible:d}=n,{setFolderToRename:h,setIsRenameFolderModalVisible:f}=r,{apiEndpoints:p,dataProviders:g,config:m}=i,v=c(e=>{null==h||h(e),null==f||f(!0);const t=null==s?void 0:s.find(t=>t.id===e);t&&u&&u.setFieldsValue({newFolderName:t.name})},[h,f,s,u]),y=c(()=>{null==f||f(!1),null==h||h(null),null==u||u.resetFields()},[f,h,u]),b=c(async()=>{var t,n;if(l&&u)try{const i=await u.validateFields();if(!(null==i?void 0:i.newFolderName))return void a.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:o("Folder name cannot be empty"),placement:"bottomRight",data:{folderId:l,folderName:null==i?void 0:i.newFolderName,reason:"emptyName"}});if(!1===(null===(t=null==m?void 0:m.features)||void 0===t?void 0:t.enableRenameFolder))return void a.error({id:"FOLDER_RENAME_DISABLED_BY_CONFIG",message:o("Folder rename is disabled by config"),placement:"bottomRight",data:{itemId:null!=l?l:void 0,itemName:null==i?void 0:i.newFolderName}});if(!(null==g?void 0:g.renameFolder))throw new Error(o("renameFolder is not implemented in dataProviders"));const s=await g.renameFolder(l,i.newFolderName.trim());if(!(null==s?void 0:s.id))return void a.error({id:"FOLDER_RENAME_FAILED",message:o("Unexpected response when renaming folder"),placement:"bottomRight",data:{itemId:null!=l?l:void 0,itemName:i.newFolderName,error:{message:"invalidResponse"}}});a.success({id:"FOLDER_RENAME_SUCCESS",message:o("Folder renamed"),placement:"bottomRight",data:{itemId:s.id,itemName:s.name,folderId:null!==(n=s.parentId)&&void 0!==n?n:null}}),y(),await e(),l!==s.id&&r.setSelectedFolder&&r.setSelectedFolder(s.id)}catch(e){console.error("Ошибка при переименовании папки:",e),a.error({id:"FOLDER_RENAME_FAILED",message:o("Failed to rename folder"),placement:"bottomRight",innerException:e,data:{itemId:null!=l?l:void 0,itemName:null==u?void 0:u.getFieldValue("newFolderName"),error:{message:e instanceof Error?e.message:String(e)}}})}},[l,u,p,y,e,o,null===(t=null==m?void 0:m.features)||void 0===t?void 0:t.enableRenameFolder,a]);return{state:{isRenamingFolder:d||!1,folderToRename:l},actions:{showRenameFolderModal:v,handleRenameFolderCancel:y,handleRenameFolderOk:b}}})(ye),{files:ke,loading:Ae,isRenamingFile:Ee,fileToRename:Ie}=f.state,{fetchFiles:Te,handleDeleteFile:Oe,handleDeleteFolder:Pe,handleAddFile:Me,handleAddFileByUrl:Re,showRenameModal:Le,handleRenameCancel:Ne,handleRenameOk:De,handleDroppedFiles:je,showMoveModal:ze,handleMoveCancel:Be,handleMoveOk:Ue,handleCopyOk:Ve,handleCopyCancel:He,showDeleteConfirm:We,handleDeleteConfirmCancel:$e,handleDeleteConfirmOk:Ge}=f.actions,{selectedFolder:qe,pathHistory:Ye}=p.state,{handleFolderSelect:Xe,handleItemClick:Ke}=p.actions,{pagination:Ze}=g.state,Je=yo(Te),{searchTerm:Qe,sortBy:et,sortOrder:tt}=Je.state,{handleSearch:nt,handleSort:rt,handlePaginationChange:it}=Je.actions,ot=c(async()=>{const e=(e=>Mo(e))(Ye||[]);try{await No({options:E,pathFolder:e,dataProviders:null==E?void 0:E.dataProviders})}catch(e){console.error("Cache clear failed:",e)}await ye(),await Te({folderId:qe||"",page:Ze.current,limit:Ze.pageSize,search:Qe,sortBy:et,sortOrder:tt,itemType:"all"})},[Te,ye,E,Ze,Ye,Qe,qe,et,tt]),at=(({files:e,fetchFiles:t,selectedFolder:n})=>{const{t:i}=Qn(),o=bo(),{options:a,actions:s,state:l}=r.useContext(no),{setActiveLibraryItem:c}=s,{activeLibraryItem:u}=l,d=za(),[h,f]=r.useState(!1),[p,g]=r.useState(null),m=r.useCallback(e=>{var t;if(e.type&&e.type.startsWith("image/"))return!0;if(e.extension){const t=e.extension.toLowerCase();return vn.includes(t)}const n=null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase();return!!n&&vn.includes(n)},[]),v=r.useCallback(async(e,t)=>{var n,r;const{dataProviders:o}=a;if(!1===(null===(r=null===(n=a.config)||void 0===n?void 0:n.features)||void 0===r?void 0:r.enableUpdateFile))throw new $o(i("Updating files is disabled by configuration"),"UnsupportedOperation");if(!e.id||!e.thumbnail||!(null==o?void 0:o.updateFile))throw new $o(i("Failed to save changes"),"UnsupportedOperation");const s=(null==t?void 0:t.mimeType)||On(e.thumbnail,e.type),l=Pn(s),c=e.name.lastIndexOf("."),u=`${c>0?e.name.substring(0,c):e.name}.${l}`,d=(null==t?void 0:t.blob)||Nn(e.thumbnail,s);return o.updateFile(e.id,{name:u,type:s,data:d})},[a,i]),y=r.useCallback(async(e,t)=>{var n;if(!e.thumbnail)throw new $o(i("Failed to save changes"),"ValidationError");const r=null!==(n=e.saveWithoutFolder)&&void 0!==n?n:!e.id,o=(null==t?void 0:t.mimeType)||On(e.thumbnail,e.type),a=(null==t?void 0:t.blob)||Nn(e.thumbnail,o),s=new File([a],e.name,{type:o,lastModified:Date.now()}),l=await d.uploadFileWithProvider(s,e.folderId||void 0,void 0,r);if(!l)throw new $o(i("Failed to save image copy"),"FileWriteError");return l},[d,i]),b=r.useCallback(t=>{let n;if(t)n=t;else{const t=Wa.getState().selectedFiles;if(1!==t.size)return;const r=Array.from(t)[0];if(n=e.find(e=>e.id===r),!n||n.isFolder||!m(n))return}c&&c(cn),g(n),f(!0)},[e,m,f,c]),w=r.useCallback(()=>{c&&u===cn&&c(rn),f(!1),g(null)},[u,c]),x=r.useCallback(async(e,r)=>{var s,l,c,u,d,h;try{const c=await v(e,r);return o.success({id:"IMAGE_UPDATE_SUCCESS",message:i("Success"),description:i("Image updated successfully"),placement:"bottomRight",data:{itemId:null!==(s=null==c?void 0:c.id)&&void 0!==s?s:void 0,itemName:null==c?void 0:c.name,folderId:null!==(l=null==c?void 0:c.folderId)&&void 0!==l?l:null,thumbnail:null==c?void 0:c.thumbnail}}),c&&a.onEditorOk&&a.onEditorOk(c),await t({folderId:n||""}),w(),null!=c?c:void 0}catch(t){const n=Io(t),r=null!==(u=null!==(c=Ao(null==n?void 0:n.code,i))&&void 0!==c?c:null==n?void 0:n.message)&&void 0!==u?u:i("Failed to save changes");throw o.error({id:"IMAGE_SAVE_FAILED",message:r,innerException:t,placement:"bottomRight",data:{itemId:null!==(d=e.id)&&void 0!==d?d:void 0,itemName:e.name,folderId:null!==(h=e.folderId)&&void 0!==h?h:null,thumbnail:e.thumbnail}}),t.notificationShown=!0,t}},[v,a,t,n,o,w,i]),C=r.useCallback(async(e,r)=>{var s,l,c,u,d,h;try{const c=await y(e,r);return o.success({id:"IMAGE_SAVE_COPY_SUCCESS",message:i("Success"),description:i("Image copy saved successfully"),placement:"bottomRight",data:{itemId:null!==(s=null==c?void 0:c.id)&&void 0!==s?s:void 0,itemName:null==c?void 0:c.name,folderId:null!==(l=null==c?void 0:c.folderId)&&void 0!==l?l:null,thumbnail:null==c?void 0:c.thumbnail}}),c&&a.onEditorOk&&a.onEditorOk(c),await t({folderId:n||""}),w(),null!=c?c:void 0}catch(t){const n=Io(t),r=null!==(u=null!==(c=Ao(null==n?void 0:n.code,i))&&void 0!==c?c:null==n?void 0:n.message)&&void 0!==u?u:i("Failed to save image copy");throw o.error({id:"IMAGE_SAVE_COPY_FAILED",message:r,innerException:t,placement:"bottomRight",data:{itemId:null!==(d=e.id)&&void 0!==d?d:void 0,itemName:e.name,folderId:null!==(h=e.folderId)&&void 0!==h?h:null,thumbnail:e.thumbnail}}),t.notificationShown=!0,t}},[y,a,t,n,o,w,i]);return{isPixieEditorVisible:h,editingFile:p,handleEdit:b,handlePixieEditorSave:x,handlePixieEditorSaveCopy:C,handlePixieEditorClose:w}})({files:ke||[],fetchFiles:Te,selectedFolder:qe||null}),[st,lt]=o(!1),ct=c(e=>{if(e.preventDefault(),e.stopPropagation(),!e.dataTransfer||!e.dataTransfer.types||!e.dataTransfer.types.includes("Files"))return;e.dataTransfer.dropEffect="copy";const t=e.relatedTarget,n=e.currentTarget;t&&n.contains(t)||(oe.current+=1,oe.current>0&&ee(!0))},[]),ut=c(e=>{e.preventDefault(),e.stopPropagation();const t=e.relatedTarget,n=e.currentTarget;if(t&&!n.contains(t))oe.current=Math.max(0,oe.current-1),oe.current<=0&&ee(!1);else if(t){const e=t.closest('[class*="dragOverlay"]');if(e&&n.contains(e))return}},[]),dt=c(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},[]),ht=c(e=>{e.preventDefault(),e.stopPropagation(),ee(!1),oe.current=0;const t=(()=>{var t;const n=e.dataTransfer;if(!n)return[];if(null===(t=n.files)||void 0===t?void 0:t.length)return Array.from(n.files);const r=[];if(n.items)for(let e=0;e<n.items.length;e++){const t=n.items[e].getAsFile();t&&r.push(t)}return r})();t.length&&(lt(!0),je(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error("Ошибка при загрузке файлов:",e)}).finally(()=>{lt(!1)}))},[je]),ft=c(()=>{ee(!1),oe.current=0,document.body.removeAttribute("data-fm-dragging"),ie(!1),ne(!1)},[]);i.useEffect(()=>{le.current=ke||[]},[ke]);const pt=null==T?void 0:T.activeLibraryItem;a(()=>{const e=e=>{e?document.body.setAttribute("data-fm-dragging","true"):document.body.removeAttribute("data-fm-dragging")};let t=!1;const n=n=>{var r,i;!t&&(null===(i=null===(r=n.dataTransfer)||void 0===r?void 0:r.types)||void 0===i?void 0:i.includes("Files"))&&(t=!0,ie(!0),e(!0),pt===rn&&ne(!0))},r=n=>{const r=n.relatedTarget;(!r||!document.documentElement.contains(r))&&t&&(t=!1,ie(!1),ne(!1),e(!1))};return window.addEventListener("dragenter",n,!0),window.addEventListener("dragleave",r,!0),()=>{window.removeEventListener("dragenter",n,!0),window.removeEventListener("dragleave",r,!0),document.body.removeAttribute("data-fm-dragging")}},[pt]),a(()=>{const e=e=>{var t,n;if(document.body.removeAttribute("data-fm-dragging"),ie(!1),!(null===(n=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===n?void 0:n.includes("Files")))return;e.preventDefault();const r=(e=>{var t;if(!e)return[];if(null===(t=e.files)||void 0===t?void 0:t.length)return Array.from(e.files);const n=[];if(e.items)for(let t=0;t<e.items.length;t++){const r=e.items[t].getAsFile();r&&n.push(r)}return n})(e.dataTransfer);if(!r.length)return;const i=e.target,o=i.closest(`.${rs.filesContainer.replace(/\s+/g,".")}`)||i.closest("[data-files-container]"),a=i.closest(".em-filemanager")||i.closest(".file-manager__layout")||i.closest("[data-drop-overlay]")||i.closest("[data-drag-capture]");(ae.current||J||o||a)&&(e.preventDefault(),e.stopPropagation(),ne(!1),ee(!1),oe.current=0,lt(!0),je(r).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error("Ошибка при загрузке файлов:",e)}).finally(()=>lt(!1)))},t=e=>{var t,n;(null===(n=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===n?void 0:n.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",document.body.hasAttribute("data-fm-dragging")||(document.body.setAttribute("data-fm-dragging","true"),ie(!0)),pt!==rn||ae.current||ne(!0))},n=e=>{var t,n;(null===(n=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===n?void 0:n.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",document.body.setAttribute("data-fm-dragging","true"),ie(!0))},r={capture:!0,passive:!1};return window.addEventListener("drop",e,r),window.addEventListener("dragover",t,r),window.addEventListener("dragenter",n,r),()=>{window.removeEventListener("drop",e,r),window.removeEventListener("dragover",t,r),window.removeEventListener("dragenter",n,r)}},[J,je,pt]),a(()=>{const e=e=>{J&&ft(),ne(!1),ie(!1),document.body.removeAttribute("data-fm-dragging")};return window.addEventListener("dragend",e,!0),()=>window.removeEventListener("dragend",e,!0)},[J,ft]),a(()=>{let e=null;const t=t=>{J&&(e=setTimeout(()=>{J&&ft()},200))};return document.addEventListener("mouseup",t,!0),()=>{document.removeEventListener("mouseup",t,!0),e&&clearTimeout(e)}},[J,ft]),a(()=>{const e=e=>{"Escape"===e.key&&J&&ft()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[J,ft]),a(()=>{const e=e=>{J&&setTimeout(()=>{J&&ft()},100)};return document.addEventListener("click",e,!0),()=>{document.removeEventListener("click",e,!0)}},[J,ft]);const gt=i.useCallback(async()=>{await Ge(),await ye(),qe===un&&be&&await be(un),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var e,t;return null===(t=null===(e=se.current)||void 0===e?void 0:e.refreshFileCounts)||void 0===t?void 0:t.call(e)})})},[ye,be,Ge,qe]),mt=i.useCallback(()=>{he(!0)},[]),vt=i.useCallback(async()=>{var e,t;if(qe!==un)return console.error("Clear trash called outside of trash folder"),void he(!1);try{if(null==O?void 0:O.cleanTrash){const t=await O.cleanTrash();await Te({folderId:un}),await(null===(e=se.current)||void 0===e?void 0:e.refreshFileCounts()),t.success?w.success({id:"TRASH_CLEARED_SUCCESS",message:C("Trash cleared successfully"),description:C("{{count}} items permanently deleted",{count:t.deletedCount||0}),placement:"bottomRight"}):w.error({id:"TRASH_CLEAR_FAILED",message:C("Failed to clear trash"),placement:"bottomRight"})}else{const e=le.current||[];if(0===e.length)return void he(!1);const n=e.map(e=>({id:e.id,isFolder:e.isFolder})),r=await b({items:n,selectedFolder:un,getItemNameById:t=>{var n;return(null===(n=e.find(e=>e.id===t))||void 0===n?void 0:n.name)||t||""},showNotifications:!1});await Te({folderId:un}),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts());const{successCount:i,failCount:o}=r;0===o?w.success({id:"TRASH_CLEARED_SUCCESS",message:C("Trash cleared successfully"),description:C("{{count}} items permanently deleted",{count:i}),placement:"bottomRight"}):i>0?w.warning({id:"TRASH_CLEARED_PARTIAL",message:C("Trash partially cleared"),description:C("{{succeeded}} items deleted, {{failed}} items failed",{succeeded:i,failed:o}),placement:"bottomRight"}):w.error({id:"TRASH_CLEAR_FAILED",message:C("Failed to clear trash"),placement:"bottomRight"})}he(!1)}catch(e){console.error("Error clearing trash:",e),w.error({id:"TRASH_CLEAR_ERROR",message:C("Error clearing trash"),placement:"bottomRight"}),he(!1)}},[qe,O,Te,w,C,b]),yt=i.useCallback(()=>{he(!1)},[]),bt=i.useCallback(async e=>{var t;await Ue(e),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())},[Ue]),wt=i.useCallback(async e=>{var t;await Ve(e),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())},[Ve]),xt=i.useCallback(async()=>{let e=[],t=new Map;const n=null==E?void 0:E.config;await Me({onStartBatch:r=>{e=v.startUpload(qe||void 0,r),t=new Map,r.forEach((r,i)=>{const o=e[i];o&&(t.set(r.name,o),t.set(Uo(r.name,n),o))})},onStart:r=>{if(0===e.length){e=v.startUpload(qe||void 0,[r]);const i=e[0];i&&(t.set(r.name,i),t.set(Uo(r.name,n),i))}},onProgress:(e,n)=>{const r=t.get(e);r&&v.updateProgress(r,n)},onComplete:async e=>{var n;const r=t.get(e);if(r){await new Promise(e=>setTimeout(e,100));const t=null==ke?void 0:ke.find(t=>t.name===e&&!t.isFolder);v.markAsSuccess(r,t)}await(null===(n=se.current)||void 0===n?void 0:n.refreshFileCounts())},onError:(n,r,i)=>{var o;const a=null!==(o=t.get(n))&&void 0!==o?o:null!=i&&i<e.length?e[i]:void 0;a&&v.markAsError(a,r)},onBatchComplete:async n=>{var r,i,o,a,s,l,c,u;for(let u=0;u<n.successes.length;u++){const d=n.successes[u],h=null===(r=n.uploadedFiles)||void 0===r?void 0:r.get(d),f=null!==(a=null!==(o=null!==(i=t.get(d))&&void 0!==i?i:(null==h?void 0:h.originalFileName)?t.get(h.originalFileName):void 0)&&void 0!==o?o:null!=(null==h?void 0:h.originalIndex)&&h.originalIndex<e.length?e[h.originalIndex]:void 0)&&void 0!==a?a:u<e.length?e[u]:void 0;if(f){let e;if(null==h?void 0:h.id){const t=h;e={id:t.id,name:null!==(s=t.name)&&void 0!==s?s:d,folderId:null!==(c=null!==(l=t.folderId)&&void 0!==l?l:qe)&&void 0!==c?c:null,isFolder:!1,size:t.size}}else await new Promise(e=>setTimeout(e,100)),e=null==ke?void 0:ke.find(e=>e.name===d&&!e.isFolder);v.updateProgress(f,100),v.markAsSuccess(f,e)}}n.errors.forEach(({fileName:e,error:n})=>{const r=t.get(e);r&&v.markAsError(r,n)}),await(null===(u=se.current)||void 0===u?void 0:u.refreshFileCounts())}})},[Me,v,ke,qe,null==E?void 0:E.config]),Ct=i.useCallback(async(e,t,n,r)=>{var i,o;try{ue(!0);let a=n||"uploaded-file";if(!n&&e){const t=e.split("?")[0].split("#")[0].split("/");a=t[t.length-1]||"uploaded-file";a.includes(".")&&(null===(i=a.split(".").pop())||void 0===i?void 0:i.length)&&a.split(".").pop().length<=5||(a+=".jpg")}const s=v.startUploadByUrl(qe||void 0,a);try{const n=await Re(e,t,!0,null!=r?r:"uploadByUrl");if(v.updateProgress(s,100),n){await new Promise(e=>setTimeout(e,100));const e=(null==ke?void 0:ke.find(e=>e.id===n.id&&!e.isFolder))||n;v.markAsSuccess(s,e)}else v.markAsSuccess(s);await(null===(o=se.current)||void 0===o?void 0:o.refreshFileCounts())}catch(e){const t=Io(e),n=Po(t,C);v.markAsError(s,n)}}finally{ue(!1)}},[Re,v,qe,ke,C]),_t=i.useCallback(async({file:e})=>{var t;const n=v.startUpload(qe||void 0,[e])[0];let r=0;const i=setInterval(()=>{r=Math.min(r+10+Math.floor(Date.now()%10),90),v.updateProgress(n,r)},200);try{const r=await y.uploadFileWithProvider(e,void 0,!0);if(clearInterval(i),v.updateProgress(n,100),r){await new Promise(e=>setTimeout(e,100));const e=(null==ke?void 0:ke.find(e=>e.id===r.id&&!e.isFolder))||r;v.markAsSuccess(n,e)}else v.markAsSuccess(n);const o=r&&r.folderId||qe||null;return Xe&&Xe(o&&"folders"!==o?o:"folders"),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts()),r}catch(e){clearInterval(i);const t=e instanceof Error?e.message:String(e);throw v.markAsError(n,t),e}},[y,v,qe,ke,Xe]),St=i.useCallback(async e=>{var t;if(je){const n=v.startUpload(qe||void 0,e);e.forEach(async(e,t)=>{const r=n[t];if(!r)return;let i=0;const o=setInterval(()=>{i=Math.min(i+10+Math.floor(Date.now()%10),85),v.updateProgress(r,i)},200);setTimeout(()=>{clearInterval(o)},2e3)}),await je(e),n.forEach(e=>{v.updateProgress(e,100),v.markAsSuccess(e)}),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())}},[je,v,qe]),kt=i.useCallback(async e=>{var t;await Pe(e),await ye(),await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())},[Pe,ye]),At=(({files:e,clearSelection:t,showRenameModal:n,showMoveModal:i,showCopyModal:o,handleDeleteFile:a,handleDeleteFolder:s,showDeleteConfirm:l,onEdit:c})=>{const u=r.useCallback(()=>{t()},[t]),d=r.useCallback(e=>{const t=Wa.getState().selectedFiles;if(t&&1===t.size||e){const r=e||Array.from(t)[0];n(r)}},[n]),h=r.useCallback(t=>{const n=Wa.getState().selectedFiles;if(n&&n.size>0||(null==t?void 0:t.id)){if(l)return void l();(t?[t.id]:n).forEach(t=>{const n=e.find(e=>e.id===t);n?n.isFolder?s(t):a(t):console.warn(`Объект с ID ${t} не найден в списке файлов`)})}},[e,a,s,l]);return{handleClearSelection:u,handleRename:d,handleDeleteSelected:h,handleCopy:r.useCallback(()=>{o()},[o]),handleMove:r.useCallback(()=>{i()},[i]),handleEdit:r.useCallback(()=>{c()},[c])}})({files:ke||[],clearSelection:pe,showRenameModal:Le,showMoveModal:ze,showCopyModal:f.actions.showCopyModal||(()=>{}),handleDeleteFile:Oe,handleDeleteFolder:kt,showDeleteConfirm:We,onEdit:at.handleEdit}),Et=ve||Ae||st;a(()=>{En()},[]),x(()=>{G!==rn?pe():ge(ke||[])},[G,ke,ge,pe]),a(()=>{if(!I||G!==rn)return;if(!dn.current)return void(dn.current=!0);const e=(Array.isArray(ke)?ke:[]).filter(e=>fe.has(e.id));I(e)},[G,ke,fe,I]),i.useEffect(()=>{if(!Xe||0===me.length)return;const e=!1!==(null==F?void 0:F.rememberLastFolder),t=`em_fm:lastFolder:${(null==F?void 0:F.projectId)||"default"}`;if(e&&"undefined"!=typeof window)try{const e=localStorage.getItem(t),n=e&&me.some(t=>t.id===e);if(n)return void Xe(e)}catch(e){}qe||Xe("folders")},[qe,Xe,me,null==F?void 0:F.rememberLastFolder,null==F?void 0:F.projectId]);const{handleRenameFolderCancel:It,handleRenameFolderOk:Tt}=Se.actions;a(()=>{const e=async e=>{if(G!==rn)return;const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||"true"===(null==t?void 0:t.getAttribute("contenteditable")))return;const n=e.clipboardData;if(!n)return;const r=Array.from(n.items),i=r.filter(e=>e.type.startsWith("image/"));if(i.length>0){const t=i.map(e=>e.getAsFile()).filter(e=>null!==e);return void(t.length>0&&(e.preventDefault(),await St(t)))}const o=r.find(e=>"text/plain"===e.type);o&&o.getAsString(async t=>{const n=t.trim();if(n.startsWith("http://")||n.startsWith("https://"))e.preventDefault(),await Ct(n);else if(n.includes("<meta")||n.includes("http")){const t=n.match(/https?:\/\/[^\s"']+/);t&&(e.preventDefault(),await Ct(t[0]))}})};return document.addEventListener("paste",e),()=>{document.removeEventListener("paste",e)}},[G,Ct,St]);const Ft=u(Ze);a(()=>{Ft.current=Ze},[Ze]);const Ot=c(e=>{it(e.current||Ft.current.current,e.pageSize||Ft.current.pageSize)},[it]),Pt=c(e=>{null==Ke||Ke(e)},[Ke]),Mt=i.useCallback(e=>{const{sortBy:t,sortOrder:n}=(e=>{const[t,n]=e.split("-");return{sortBy:t,sortOrder:n}})(e);rt(t,n)},[rt]),[Rt,Lt]=o(tN),[Nt,Dt]=o([]),jt=u(null),[zt,Bt]=o(wn),[Ut,Vt]=o([]),Ht=u(null),[Wt,$t]=o(""),Gt=u(null),[qt,Yt]=o(""),[Xt,Kt]=o([]),Zt=i.useRef(void 0),[Jt,Qt]=o(!1),[en,tn]=o(!1),nn=i.useRef(null),dn=i.useRef(!1),hn=i.useRef(G),fn=i.useCallback(e=>{const t=e.indexOf(",");if(-1===t)return null;const n=e.substring(0,t),r=n.match(/^data:([^;]+)/),i=r&&r[1]||"image/svg+xml";let o,a="svg";if(i.includes("png")?a="png":(i.includes("jpeg")||i.includes("jpg"))&&(a="jpg"),/;base64/i.test(n)){const n=e.substring(t+1),r=atob(n),a=new Uint8Array(r.length);for(let e=0;e<r.length;e+=1)a[e]=r.charCodeAt(e);o=new Blob([a],{type:i})}else{const n=decodeURIComponent(e.substring(t+1));o=new Blob([n],{type:i})}return new File([o],`icon_${Date.now()}.${a}`,{type:i})},[]),pn=i.useCallback(async e=>{var t;const n=v.startUpload(qe||void 0,[e])[0];let r=0;const i=setInterval(()=>{r=Math.min(r+10+Math.floor(Date.now()%10),90),v.updateProgress(n,r)},200);try{const r=await y.uploadFileWithProvider(e,void 0,!0);if(clearInterval(i),v.updateProgress(n,100),r){await new Promise(e=>setTimeout(e,100));const e=(null==ke?void 0:ke.find(e=>e.id===r.id&&!e.isFolder))||r;v.markAsSuccess(n,e)}else v.markAsSuccess(n);await(null===(t=se.current)||void 0===t?void 0:t.refreshFileCounts())}catch(e){clearInterval(i);const t=e instanceof Error?e.message:String(e);throw v.markAsError(n,t),e}},[v,ke,y,qe]),gn=c(async e=>{if(Boolean(e&&e.startsWith("data:"))){const t=fn(e);if(!t)return;return void await pn(t)}e&&await Ct(e,void 0,void 0,"iconStock")},[fn,Ct,pn]),mn=c(async()=>{const e=null==X?void 0:X.fileForEdit;if(Zt.current===e)return;if(G===cn&&e&&!at.editingFile){Zt.current=e;try{if("string"==typeof e){if(e.startsWith("data:"))return void(null==at||at.handleEdit({thumbnail:e,saveWithoutFolder:!0}));const t=await y.resolveFileForEditByUrl(e);Zt.current===e&&(null==at||at.handleEdit(t))}}catch(t){Zt.current===e&&(Zt.current=null),console.error("Failed to open file in editor:",t),null==at||at.handlePixieEditorClose()}}},[null==X?void 0:X.fileForEdit,G,at,y]);a(()=>{mn()},[mn]),a(()=>{var e,t,n,r;const i=hn.current;hn.current=G,G===rn?(Dt([]),Lt(tN),Vt([]),Bt(wn),Kt([]),Yt(""),tn(!1),Qt(!1),i===rn||i!==an&&i!==on&&i!==ln||nt("")):G===ln?null===(e=nn.current)||void 0===e||e.focus():G===on?null===(t=jt.current)||void 0===t||t.focus():G===an?null===(n=Ht.current)||void 0===n||n.focus():G===sn&&(null===(r=Gt.current)||void 0===r||r.focus())},[G,nt]);const bn=i.useCallback(async()=>{var e;await Tt(),await(null===(e=se.current)||void 0===e?void 0:e.refreshFileCounts())},[Tt]),xn=fe.size,Cn=i.useMemo(()=>{var e,t,n;if(1!==xn)return!1;const[r]=Array.from(fe),i=ke.find(e=>e.id===r);if(!i||i.isFolder)return!1;const o="string"==typeof i.name?i.name:"",a=o?null===(e=o.split(".").pop())||void 0===e?void 0:e.toLowerCase():void 0,s=null!==(n=null===(t=i.extension)||void 0===t?void 0:t.toLowerCase())&&void 0!==n?n:a;return"string"==typeof i.type&&i.type.startsWith("image/")||"string"==typeof s&&yn.includes(s)},[xn,fe,ke]),_n=c(e=>{var t;return e?(null===(t=e.files)||void 0===t?void 0:t.length)?Array.from(e.files):e.items?Array.from(e.items).map(e=>e.getAsFile()).filter(e=>Boolean(e)):[]:[]},[]);return t(n,{children:[re&&pt===rn&&Fe(e("div",{className:rs.dragCaptureLayer,"data-drag-capture":"true",onDragOver:e=>{var t,n;e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),(null===(n=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===n?void 0:n.includes("Files"))&&!ae.current&&ne(!0)},onDragEnter:e=>{var t,n;e.preventDefault(),e.stopPropagation(),(null===(n=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===n?void 0:n.includes("Files"))&&ne(!0)},onDragLeave:e=>{const t=e.relatedTarget;t&&document.documentElement.contains(t)||(ne(!1),ie(!1),document.body.removeAttribute("data-fm-dragging"))},onDrop:e=>{e.preventDefault(),e.stopPropagation(),ie(!1),ne(!1),document.body.removeAttribute("data-fm-dragging");const t=_n(e.dataTransfer);t.length&&(lt(!0),je(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error(e)}).finally(()=>lt(!1)))},"aria-hidden":"true"}),document.body),te&&Fe(e("div",{className:rs.dragOverlayGlobal,"data-drop-overlay":"true",onDragOver:e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},onDragEnter:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),e.stopPropagation(),ne(!1),ie(!1),document.body.removeAttribute("data-fm-dragging");const t=_n(e.dataTransfer);t.length&&(lt(!0),je(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error(e)}).finally(()=>lt(!1)))},"aria-hidden":"true",children:t("div",{className:rs.dragOverlayInner,children:[e("div",{className:rs.uploadIcon,children:e(Z,{})}),e("div",{className:rs.textTitle,children:C("Drop files here to upload")}),e("div",{className:rs.textDescription,children:C("Supported files:")+" .jpg, .jpeg, .svg, .png"})]})}),document.body),e(Q,{className:"file-manager__layout",children:t("div",{className:rs.filesContainer,"data-files-container":"true",onDragOver:dt,onDragLeave:ut,onDragEnter:ct,onDrop:ht,children:[J&&e("div",{className:rs.dragOverlay,children:t("div",{className:rs.dragOverlayInner,children:[e("div",{className:rs.uploadIcon,children:e(Z,{})}),e("div",{className:rs.textTitle,children:C("Drop files here to upload")}),e("div",{className:rs.textDescription,children:C("Supported files:")+" .jpg, .jpeg, .svg, .png"})]})}),m.showResizeGuide&&e("div",{className:"resize-guide",style:{left:`${m.resizeGuidePosition}px`}}),t(Q,{className:"file-manager__content",children:[t(QL,{width:320,theme:"light",className:"file-manager-sider",children:[e(Ks,{ref:se,selectedFolder:qe||"folders",generateMenuItems:_e,onFolderSelect:e=>null==Xe?void 0:Xe(e),folders:me||[],fetchFolders:ye,fetchChildFolders:be,handleAddFile:xt,setIsUrlModalVisible:e=>null==q?void 0:q(e),handleDeleteFolder:kt,handleCreateFolder:we,activeLibraryItem:G,setActiveLibraryItem:e=>null==Y?void 0:Y(e)}),e("div",{className:"sidebar-resizer "+(m.isResizing?"resizing":""),onMouseDown:m.handleResizeStart,onDoubleClick:m.handleDoubleClick,children:e("div",{className:"sidebar-resizer-indicator"})})]}),t(Q,{className:"file-manager__main-content",children:[st&&e(Hs,{style:{position:"absolute",width:"100%",height:"100%",top:0,left:0,zIndex:100,background:"var(--colorBgLayout)"}}),t(eN,{className:"main-content",children:[e(tL,{activeLibraryItem:G,selectedFolder:(null===(s=null==me?void 0:me.find(e=>(null==e?void 0:e.id)===qe))||void 0===s?void 0:s.name)||C("Folders"),isTrashFolder:"Trash"===qe,onClearTrash:mt,files:ke||[],loading:Et,onRefresh:ot,refreshDisabled:Ae||ve,showRefresh:!(!(null===(l=null==E?void 0:E.apiEndpoints)||void 0===l?void 0:l.clearCache)&&!(null===(d=null==E?void 0:E.dataProviders)||void 0===d?void 0:d.clearCache))}),e(K,{className:"zero-divider"}),G===rn&&e(Ps,{searchTerm:Qe,handleAddFile:xt,files:ke||[],handleSearch:nt,sortBy:et,sortOrder:tt,handleSortOptionChange:Mt,pagination:Ze,setPagination:Ot,loading:Et,handleItemClick:Pt,onClearSelection:At.handleClearSelection,onRename:At.handleRename,onCopy:At.handleCopy,onMove:At.handleMove,onDelete:At.handleDeleteSelected,showRenameModal:Le,showDeleteConfirm:We,showCopyModal:f.actions.showCopyModal||(()=>{}),showMoveModal:ze,onEdit:at.handleEdit,getFileData:y.getFileData}),G===on&&e(yL,{imageGifList:Nt,setImageGifList:Dt,currentReqGif:Rt,setCurrentReqGif:Lt,inputRef:jt,customRequest:(e,t)=>Ct(e,void 0,t,"gif")}),G===an&&e(CL,{imageStockList:Ut,setImageStockList:Vt,currentReq:zt,setCurrentReq:Bt,inputRef:Ht,customRequest:(e,t)=>Ct(e,void 0,t,"imageStock")}),G===sn&&e(ZL,{apiKey:null==X?void 0:X.STREAMLINE_API_KEY,customRequest:gn,query:Wt,setQuery:$t,inputRef:Gt}),G===ln&&!!(null==X?void 0:X.sseQuery)&&e(PL,{imageAiList:Xt,setImageAiList:Kt,aiImageRequest:qt,setAiImageRequest:Yt,inputAiRef:nn,customRequest:_t,isLoadingAi:Jt,setIsLoadingAi:Qt,isImageUploaded:en,setIsImageUploaded:tn}),G===cn&&e(n,{}),e(n,{children:Cn&&t(n,{children:[e(K,{className:"zero-divider"}),e("div",{style:{display:"flex",justifyContent:"right",padding:"17px 24px",alignItems:"center"},children:e(R,{size:"large",type:"primary",style:{height:40},onClick:()=>{if(_.onEditorOk){const e=Array.from(fe)[0],t=ke.find(t=>t.id===e);t&&_.onEditorOk(t)}},children:C("Choose")})})]})})]})]})]}),ce&&!v.isUploadVisible&&e("div",{style:{position:"fixed",inset:0,zIndex:1500,backgroundColor:"rgba(255, 255, 255, 0.5)",pointerEvents:"all",display:"flex",alignItems:"center",justifyContent:"center"},children:e(k,{size:"large"})}),e(Ys,{isModalVisible:z,handleModalOk:xe,handleModalCancel:Ce,form:P,selectedFolder:qe||null,folders:me||[],isUrlModalVisible:B,setIsUrlModalVisible:e=>null==q?void 0:q(e),handleAddFileByUrl:Ct,urlForm:M,isRenameModalVisible:Ee,handleRenameOk:()=>null==De?void 0:De(),handleRenameCancel:()=>null==Ne?void 0:Ne(),renameForm:L,fileToRename:Ie,files:ke||[],isMoveModalVisible:U,handleMoveOk:bt,handleMoveCancel:Be,moveForm:N,selectedFiles:fe||new Set,isRenameFolderModalVisible:V,handleRenameFolderOk:bn,handleRenameFolderCancel:It,renameFolderForm:D,folderToRename:$,isCopyModalVisible:H,handleCopyOk:wt,handleCopyCancel:He,copyForm:j,isDeleteConfirmVisible:W,handleDeleteConfirmOk:gt,handleDeleteConfirmCancel:()=>null==$e?void 0:$e(),isClearTrashConfirmVisible:de,handleClearTrashConfirm:vt,handleClearTrashCancel:yt,fetchChildFolders:be}),e(_R,{visible:at.isPixieEditorVisible,onClose:at.handlePixieEditorClose,file:at.editingFile,onSave:at.handlePixieEditorSave,onSaveCopy:at.handlePixieEditorSaveCopy}),e(JR,{files:v.uploadFiles,visible:v.isUploadVisible,minimized:v.isUploadMinimized,totalFiles:v.totalFiles,completedFiles:v.completedFiles,onClose:v.closeUpload,onMinimize:v.minimizeUpload,onInsert:e=>{var t;const n=v.getUploadedFile(e.id)||e;null===(t=_.onEditorOk)||void 0===t||t.call(_,n)}})]})})]})},rN=f(({config:r={},onPathChange:o,onChangeSelection:s,onEditorOk:l,searchQuery:c="",sortBySize:d="name",apiEndpoints:h={},customIcons:f,dragDropIcon:p,dataProviders:g,handleNotify:m,handleError:v,handleSuccess:y})=>{const b=i.useMemo(()=>Object.assign({folderTreeLoading:"lazy",expandAllFoldersOnInit:!1,expandRootFolderOnInit:!1,iconStrokeWidth:1.4,availableImageExtensions:["jpg","jpeg","png","gif"],fileNameProcessing:Object.assign(Object.assign({},{transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0}),r.fileNameProcessing),folderNameProcessing:Object.assign(Object.assign({},{transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0}),r.folderNameProcessing)},r),[r]);i.useEffect(()=>{b.theme&&(e=>{if("system"===e){const t=matchMedia(pn).matches?hn:dn;e=e===fn?t:e}document.documentElement.setAttribute("data-theme",e)})(b.theme),JL(b)},[b]),a(()=>{b.locale&&b.locale!==Wr.language&&Wr.changeLanguage(b.locale),b.customLocale&&b.locale&&Wr.addResourceBundle(b.locale,"translation",b.customLocale,!0,!0)},[b.locale,b.customLocale]);const w=u(null),x=i.useMemo(()=>({apiEndpoints:h,searchQuery:c,sortBySize:d,onPathChange:o,onChangeSelection:s,onEditorOk:l,config:b,customIcons:f,dragDropIcon:p,dataProviders:g,handleNotify:m,handleError:v,handleSuccess:y}),[h,c,d,o,s,l,b,f,p,g,m,v,y]);return e(I,{className:"em-filemanager",children:t(n,{children:[e(E,{getPopupContainer:()=>w.current||document.body,children:e(io,{options:x,children:e(nN,{})})}),e("div",{ref:w,className:"file-manager-modal-root"})]})})});rN.displayName="FileManagerApp";const iN=t=>{var n,r,i;return e(er,{i18n:Wr,children:e(_n,{externalTheme:null!==(r=null===(n=t.config)||void 0===n?void 0:n.theme)&&void 0!==r?r:"light",customThemeToken:null===(i=t.config)||void 0===i?void 0:i.customTheme,children:e(ae,{children:e(rN,Object.assign({},t))})})})},oN=new Map,aN=(t,n)=>{var r;let i;En();let o={};const a=e=>{const t=!e||"fileManager"!==e.mode&&"imageCenter"!==e.mode&&"plugin"!==e.mode?void 0:e.mode;return"imageCenter"===t?kn("imageCenter",e):kn(t)};if(t instanceof HTMLElement){i=t;o={config:a(n),apiEndpoints:null==n?void 0:n.apiEndpoints}}else{i=t.element;const e=a(t.config),n=Object.assign(Object.assign({},null===(r=t.config)||void 0===r?void 0:r.apiEndpoints),t.apiEndpoints);o={config:e,currentPath:t.currentPath,onPathChange:t.onPathChange,onChangeSelection:t.onChangeSelection,searchQuery:t.searchQuery,sortBySize:t.sortBySize,apiEndpoints:n,dataProviders:t.dataProviders,customIcons:t.customIcons,dragDropIcon:t.dragDropIcon,handleNotify:t.handleNotify,handleError:t.handleError,handleSuccess:t.handleSuccess}}const s=S(i);s.render(e(iN,Object.assign({},o))),oN.set(i.id||`container_${Date.now()}`,s)},sN=e=>{const t=e.id||Object.keys(oN).find(e=>e.startsWith("container_"));if(t&&oN.has(t)){const e=oN.get(t);null==e||e.unmount(),oN.delete(t)}else{console.warn("Couldn t find the root to unmount");try{S(e).unmount()}catch(e){console.error("Error unmounting the component:",e)}}},lN=new Map,cN=r=>{var o,s;const{onClose:l,onSave:c,dataProviders:d,theme:h,locale:f}=r,p=i.useCallback(async(e,t,n,r)=>{if(!e&&!t||!(null==d?void 0:d.getFiles))return null;try{const i=await d.getFiles({folderId:r?void 0:n||void 0,noFolder:r,search:t||void 0,itemType:"file",page:1,limit:1}),[o]=i.files;return o?e&&o.id!==e?null:o:null}catch(e){return console.warn("Standalone Pixie: failed to resolve uploaded file from provider",e),null}},[d]),g=i.useMemo(()=>{if(r.file)return r.file;const e=r.name||"edited-image",t=r.extension||(r.type?r.type.split("/")[1]:"png"),n=r.type||`image/${t}`;return{thumbnail:r.imageDataUrl||"",name:e,id:void 0,type:n,extension:t,saveWithoutFolder:!0}},[r.file,r.imageDataUrl,r.name,r.extension,r.type]),m=i.useCallback(async(e,t)=>{if((null==d?void 0:d.updateFile)&&e.thumbnail)try{const n=(null==t?void 0:t.mimeType)||On(e.thumbnail,e.type),r=Pn(n),i=e.name.substring(0,e.name.lastIndexOf("."))+"."+r,o=(null==t?void 0:t.blob)||Nn(e.thumbnail,n);return await d.updateFile(e.id,{name:i,type:n,data:o})}catch(e){return console.error("Error updating the file through updateFile:",e),null}return console.warn("DataProvider for updating files is not configured"),null},[d]),v=i.useCallback(async(e,t)=>{var n,r,i,o,a,s;if(!e.thumbnail)return null;try{const l=null!==(n=e.saveWithoutFolder)&&void 0!==n?n:!e.id,c=l?"":e.folderId||"",u=(null==t?void 0:t.mimeType)||On(e.thumbnail,e.type),h=(null==t?void 0:t.blob)||Nn(e.thumbnail,u),f=new File([h],e.name,{type:u,lastModified:Date.now()});if(null==d?void 0:d.uploadFiles){const t=await d.uploadFiles({items:[{name:f.name,size:f.size,type:f.type,folderId:c,noFolder:l,data:f,extension:Pn(u)}],folderId:c}),n=null===(r=t.detailed)||void 0===r?void 0:r[0];if(t.success&&(null==n?void 0:n.success)&&n.data){const t=n.data;if(t.url||t.thumbnailUrl||t.thumbnail)return{id:t.id||e.id||"",name:t.name||e.name,folderId:null!==(i=t.folderId)&&void 0!==i?i:c,type:t.type||f.type,size:null!==(o=t.size)&&void 0!==o?o:f.size,extension:t.extension||Pn(u),url:t.url,thumbnailUrl:t.thumbnailUrl,thumbnail:t.thumbnail,date:t.date,dimensions:t.dimensions,aspectRatio:t.aspectRatio,sourceUrl:t.sourceUrl,isFolder:!1,selected:!1};const r=await p(n.data.id,n.data.name||f.name,null!==(a=n.data.folderId)&&void 0!==a?a:c,l);return r||{id:n.data.id||e.id||"",name:n.data.name||e.name,folderId:null!==(s=n.data.folderId)&&void 0!==s?s:c,type:f.type,size:f.size,extension:Pn(u),url:n.data.url,thumbnailUrl:n.data.thumbnailUrl,thumbnail:n.data.thumbnail,isFolder:!1,selected:!1}}}return(null==d?void 0:d.uploadFile)?await d.uploadFile({name:f.name,size:f.size,type:f.type,folderId:c,noFolder:l,data:f,extension:Pn(u)}):null}catch(e){return console.error("Error saving file copy:",e),null}},[d,p]),y=i.useCallback(async(e,t)=>{if((null==d?void 0:d.updateFile)&&e.id&&e.thumbnail)try{const n=await m(e,t);n&&(e=n)}catch(e){console.error("Standalone Pixie: saveFileToServer error",e)}return c&&await c(e,t),l&&l(),e},[d,c,l,m]),b=i.useCallback(async(e,t)=>{let n=e;if(e.thumbnail)try{const r=await v(e,t);r&&(n=r)}catch(e){console.error("Standalone Pixie: saveFileCopyToServer error",e)}return c&&await c(n,t),l&&l(),n},[l,c,v]),w=u(null);return a(()=>{f&&f!==Wr.language&&Wr.changeLanguage(f)},[f]),e(I,{className:"em-filemanager",children:t(n,{children:[e(E,{getPopupContainer:()=>w.current||document.body,children:e(er,{i18n:Wr,children:e(_n,{externalTheme:null!=h?h:"light",children:e(ae,{children:e(io,{options:{dataProviders:d,handleNotify:r.handleNotify,handleError:r.handleError,handleSuccess:r.handleSuccess,config:{theme:null!=h?h:"light",locale:f,baseUrl:r.baseUrl,assetsUrl:r.assetsUrl,compressMaxSize:r.compressMaxSize,compressMaxWidthOrHeight:r.compressMaxWidthOrHeight,compessorUrl:null!==(o=r.compessorUrl)&&void 0!==o?o:r.compressorUrl,compressorUrl:null!==(s=r.compressorUrl)&&void 0!==s?s:r.compessorUrl,showNotifications:r.showNotifications,handleFileProxy:r.handleFileProxy}},children:e(_R,{visible:!0,onClose:l,file:g,onSave:y,onSaveCopy:b})})})})})}),e("div",{ref:w,className:"file-manager-modal-root"})]})})},uN=t=>{En();const n=t.element,r=S(n);r.render(e(cN,Object.assign({},t))),lN.set(n.id||`pixie_container_${Date.now()}`,r)},dN=e=>{const t=Array.from(lN.keys()).find(e=>e.startsWith("pixie_container_")),n=e.id||t;if(n&&lN.has(n)){const e=lN.get(n);null==e||e.unmount(),lN.delete(n)}else{console.warn("Couldn t find the root to unmount Pixie");try{S(e).unmount()}catch(e){console.error("Error unmounting Pixie:",e)}}},hN=e=>{var t,n;const{mode:r,element:i,fileManager:o,pixieEditor:a,theme:s,dataProviders:l}=e;let c,u;const d={unmount:()=>{c&&sN(c),u&&dN(u)},unmountFileManager:void 0,unmountPixieEditor:void 0};switch(r){case"fileManager":c=i,aN(i,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),d.unmountFileManager=()=>sN(c);break;case"pixieEditor":u=i,uN(Object.assign({element:i,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountPixieEditor=()=>dN(u);break;case"both":{const e=document.createElement("div");e.id="file-manager-container",e.style.cssText="height: 50%; border-bottom: 1px solid #d9d9d9;";const t=document.createElement("div");t.id="pixie-editor-container",t.style.cssText="height: 50%;",i.appendChild(e),i.appendChild(t),c=e,u=t,aN(c,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),uN(Object.assign({element:u,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountFileManager=()=>sN(c),d.unmountPixieEditor=()=>dN(u);break}}return d};function fN(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}var pN={init:aN,unmount:sN,initPixieEditor:uN,unmountPixieEditor:dN,initFileManager:hN};export{Ps as FileContent,$o as FileManagerApiError,rN as FileManagerApp,iN as FileManagerAppWithContext,Ys as FileModals,Ks as FolderSidebar,cN as PixieOnlyApp,pN as default,aN as init,hN as initFileManager,uN as initPixieEditor,En as installResizeObserverErrorHandler,fN as mapHttpStatusToErrorCode,In as uninstallResizeObserverErrorHandler,sN as unmount,dN as unmountPixieEditor};
|
|
77
77
|
//# sourceMappingURL=file-manager.esm.js.map
|