import{e as bt,r as K,f as je,p as J}from"./vendor-react-CTtPmzVP.js";import{D as Ct,j as c,bZ as Et,ak as W,z as jt,M as St,U as gr,I as qe,a6 as ge,by as Pt,aj as kt,F as Bt,cH as Qr,W as q,at as lr,n as At,Q as ur,ar as ce,T as ue,am as me,c_ as It,b4 as be,bI as Xr,c$ as et,cU as Ot,A as mr,cT as Dt,a3 as Tt,d0 as Rt,d1 as zt,cF as Lt,bb as Ft}from"./vendor-mui-core-DnR6WYuU.js";import{q as Nt,g as yr,b as de,t as qt,a as Ce}from"./vendor-hooks-qxhUUbW5.js";import{i as Ht}from"./isURL-4Bkt0jKV.js";import{h as Mt,bj as rt,bk as Ut,bl as Kt,n as $t,bm as Wt,aT as ye,z as He,H as ae}from"./vendor-ux-DTEmWsko.js";import{bU as tt,bD as Vt,bV as Gt,bW as Yt,c as dr,ba as Zt,bb as xr,Z as Jt,Y as Qt,aD as Xt,aB as _r,q as en}from"./index-BZxsCCR_.js";import{S as _e}from"./section-jXB9AxBb.js";import{R as rn}from"./required-BQln5OcV.js";import{F as tn}from"./form-wrapper-PT5ZzMQy.js";import{I as nn,F as Ee}from"./form-text-input-DlypNadC.js";import{u as sn,c as on,w as an}from"./wait-connect-CBmpE7OF.js";import{B as wr,b as nt,C as le,D as st,J as it,n as fr}from"./vendor-utils-CxWN1dT3.js";import{r as Ue}from"./index-_tncRnTu.js";import{f as he}from"./index-DBs9Ljax.js";var cn=null;const ln=Object.freeze(Object.defineProperty({__proto__:null,default:cn},Symbol.toStringTag,{value:"Module"})),Ke=bt(ln),un=Qr`
  0%, 100% {
    transform: scale(1) translateX(0);
  }
  50% {
    transform: scale(1.05) translateX(-3px);
  }
  25%, 75% {
    transform: scale(1.1) translateX(3px);
  }
`;function Se({src:s,alt:h,size:p=20}){return c.jsx("img",{src:s,alt:h,style:{width:p,height:p,display:"block",objectFit:"contain",borderRadius:"2px",flexShrink:0},onError:l=>{l.target.style.display="none"}})}Se.propTypes={src:q.string.isRequired,alt:q.string.isRequired,size:q.number};const dn=48,fn=8,br={PaperProps:{style:{maxHeight:dn*4.5+fn,width:250}}},pn=(s,h,p)=>({fontWeight:h.indexOf(s)===-1?p.typography.fontWeightRegular:p.typography.fontWeightMedium});function ot({label:s="",disabled:h=!1,required:p=!1,initialValue:l="",onChange:C=()=>{},sx:v={},onSubmit:g=()=>{},triggers:d=[],options:a=[],formatterBeforeSubmit:t=j=>j.join(","),helperText:m="",config:w={},directEditing:x=!1,searchable:i=!0,...k}){const j=Ct(),[y,O]=K.useState(x),[n,r]=K.useState(!1),[f,_]=K.useState(""),{multiple:A=!1,labelField:T="name",valueField:L="code"}=w,[N,u]=K.useState(l),[b,B]=K.useState(N),[S,z]=K.useState(!1),[F,U]=K.useState(!1),G=K.useCallback(()=>{U(!0),setTimeout(()=>{U(!1)},500)},[]),Y=async()=>{r(!0);try{await g(typeof t=="function"&&A?t(b):b)===!1?B(N):(B(b),u(b),z(!1))}catch{B(N)}finally{r(!1),O(!1)}},R=K.useCallback(()=>{x&&!h&&!n&&Y(),S&&G(),!S&&!h&&!n&&(O(!1),z(!1))},[x,h,n,S,G]);K.useEffect(()=>{const e=l;e!==N&&(u(e),B(e),z(!1))},[l,N]);const Q=a.filter(e=>{if(!f)return!0;const o=f.toLowerCase();return e[T]?.toLowerCase().includes(o)||e[L]?.toLowerCase().includes(o)}),P=e=>{let{value:o}=e.target;A&&(o=typeof o=="string"?o.split(","):o),z(o!==b),B(o),C(o)},E=y||x?c.jsxs(Et,{value:b,onChange:P,fullWidth:!0,multiple:A,variant:"outlined",margin:"dense",onBlur:R,disabled:h,renderValue:e=>{if(A)return c.jsx(W,{sx:{display:"flex",flexWrap:"wrap"},children:e.filter(D=>a.some(H=>H[L]===D)).map(D=>c.jsx(gr,{label:a.find(H=>H[L]===D)[T],style:{marginRight:8},size:"small"},D))});if(!e)return null;const o=a.find(D=>D[L]===e);return c.jsxs(W,{sx:{display:"flex",alignItems:"center",gap:1},children:[o?.logo&&c.jsx(Se,{src:o.logo,alt:o[T],size:20}),c.jsx("span",{children:o?o[T]:""})]})},MenuProps:{...br,PaperProps:{...br.PaperProps}},error:!!m,...k,children:[i?c.jsx(W,{sx:{p:1,borderBottom:1,borderColor:"divider"},children:c.jsx(jt,{size:"small",placeholder:"Search...",value:f,onChange:e=>_(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),fullWidth:!0,variant:"outlined"})}):null,Q.map(e=>c.jsx(St,{value:e[L],style:pn(e[L],b,j),children:c.jsxs(W,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.logo&&c.jsx(Se,{src:e.logo,alt:e[T],size:20}),c.jsx("span",{children:e[T]})]})},e[L]))]}):c.jsx(W,{"data-cy":"schema-form-item-edit",className:"form-item-input slot",style:{whiteSpace:"pre-wrap"},sx:{px:1},onClick:()=>{h||O(!0)},children:A?b.filter(e=>a.some(o=>o[L]===e)).map(e=>c.jsx(gr,{label:a.find(o=>o[L]===e)[T],style:{marginRight:8},size:"small"},e)):b&&a.some(e=>e[L]===b)&&c.jsxs(W,{sx:{display:"flex",alignItems:"center",gap:1},children:[(()=>{const e=a.find(o=>o[L]===b);return e?.logo?c.jsx(Se,{src:e.logo,alt:e[T],size:20}):null})(),c.jsx("span",{children:a.find(e=>e[L]===b)[T]})]})});return c.jsx(tn,{className:"form",sx:v,children:c.jsxs(W,{className:"form-item",children:[c.jsxs(W,{className:"form-item-label",children:[s,p&&c.jsx(rn,{})]}),c.jsxs(W,{className:"form-item-body",children:[c.jsx(W,{className:"form-item-input",children:E}),c.jsx(W,{className:"form-item-action",style:!y||x?{marginLeft:0}:{},children:y&&!x?c.jsxs(c.Fragment,{children:[S?c.jsx(qe,{"data-cy":"schema-form-item-confirm",onClick:Y,disabled:h||n,sx:{animation:F?`${un} 0.5s linear`:"none"},size:"large",children:n?c.jsx(ge,{size:24}):c.jsx(Pt,{})}):null,c.jsx(qe,{"data-cy":"schema-form-item-cancel",onClick:()=>{B(N),O(!1)},disabled:h||n,size:"large",children:c.jsx(kt,{})})]}):c.jsx(W,{children:d.length?c.jsx(nn,{triggers:d,disabled:h}):null})})]}),y&&m&&c.jsx(Bt,{error:!0,children:m})]})})}ot.propTypes={sx:q.object,onSubmit:q.func,onChange:q.func,label:q.string,initialValue:q.string,required:q.bool,disabled:q.bool,triggers:q.array,options:q.array,helperText:q.string,formatterBeforeSubmit:q.func,config:q.object,directEditing:q.bool,searchable:q.bool};var se={},Pe={exports:{}},ke={exports:{}},hn=ke.exports,Cr;function oe(){return Cr||(Cr=1,function(s,h){(function(p,l){s.exports=l()})(hn,function(){var p=p||function(l,C){var v;if(typeof window<"u"&&window.crypto&&(v=window.crypto),typeof self<"u"&&self.crypto&&(v=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(v=globalThis.crypto),!v&&typeof window<"u"&&window.msCrypto&&(v=window.msCrypto),!v&&typeof je<"u"&&je.crypto&&(v=je.crypto),!v&&typeof Mt=="function")try{v=rt()}catch{}var g=function(){if(v){if(typeof v.getRandomValues=="function")try{return v.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof v.randomBytes=="function")try{return v.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},d=Object.create||function(){function n(){}return function(r){var f;return n.prototype=r,f=new n,n.prototype=null,f}}(),a={},t=a.lib={},m=t.Base=function(){return{extend:function(n){var r=d(this);return n&&r.mixIn(n),(!r.hasOwnProperty("init")||this.init===r.init)&&(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);n.hasOwnProperty("toString")&&(this.toString=n.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),w=t.WordArray=m.extend({init:function(n,r){n=this.words=n||[],r!=C?this.sigBytes=r:this.sigBytes=n.length*4},toString:function(n){return(n||i).stringify(this)},concat:function(n){var r=this.words,f=n.words,_=this.sigBytes,A=n.sigBytes;if(this.clamp(),_%4)for(var T=0;T<A;T++){var L=f[T>>>2]>>>24-T%4*8&255;r[_+T>>>2]|=L<<24-(_+T)%4*8}else for(var N=0;N<A;N+=4)r[_+N>>>2]=f[N>>>2];return this.sigBytes+=A,this},clamp:function(){var n=this.words,r=this.sigBytes;n[r>>>2]&=4294967295<<32-r%4*8,n.length=l.ceil(r/4)},clone:function(){var n=m.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var r=[],f=0;f<n;f+=4)r.push(g());return new w.init(r,n)}}),x=a.enc={},i=x.Hex={stringify:function(n){for(var r=n.words,f=n.sigBytes,_=[],A=0;A<f;A++){var T=r[A>>>2]>>>24-A%4*8&255;_.push((T>>>4).toString(16)),_.push((T&15).toString(16))}return _.join("")},parse:function(n){for(var r=n.length,f=[],_=0;_<r;_+=2)f[_>>>3]|=parseInt(n.substr(_,2),16)<<24-_%8*4;return new w.init(f,r/2)}},k=x.Latin1={stringify:function(n){for(var r=n.words,f=n.sigBytes,_=[],A=0;A<f;A++){var T=r[A>>>2]>>>24-A%4*8&255;_.push(String.fromCharCode(T))}return _.join("")},parse:function(n){for(var r=n.length,f=[],_=0;_<r;_++)f[_>>>2]|=(n.charCodeAt(_)&255)<<24-_%4*8;return new w.init(f,r)}},j=x.Utf8={stringify:function(n){try{return decodeURIComponent(escape(k.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return k.parse(unescape(encodeURIComponent(n)))}},y=t.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new w.init,this._nDataBytes=0},_append:function(n){typeof n=="string"&&(n=j.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes},_process:function(n){var r,f=this._data,_=f.words,A=f.sigBytes,T=this.blockSize,L=T*4,N=A/L;n?N=l.ceil(N):N=l.max((N|0)-this._minBufferSize,0);var u=N*T,b=l.min(u*4,A);if(u){for(var B=0;B<u;B+=T)this._doProcessBlock(_,B);r=_.splice(0,u),f.sigBytes-=b}return new w.init(r,b)},clone:function(){var n=m.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});t.Hasher=y.extend({cfg:m.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset()},reset:function(){y.reset.call(this),this._doReset()},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var r=this._doFinalize();return r},blockSize:16,_createHelper:function(n){return function(r,f){return new n.init(f).finalize(r)}},_createHmacHelper:function(n){return function(r,f){return new O.HMAC.init(n,f).finalize(r)}}});var O=a.algo={};return a}(Math);return p})}(ke)),ke.exports}var Be={exports:{}},vn=Be.exports,Er;function at(){return Er||(Er=1,function(s,h){(function(p,l){s.exports=l(oe())})(vn,function(p){return function(){var l=p,C=l.lib,v=C.WordArray,g=l.enc;g.Base64={stringify:function(a){var t=a.words,m=a.sigBytes,w=this._map;a.clamp();for(var x=[],i=0;i<m;i+=3)for(var k=t[i>>>2]>>>24-i%4*8&255,j=t[i+1>>>2]>>>24-(i+1)%4*8&255,y=t[i+2>>>2]>>>24-(i+2)%4*8&255,O=k<<16|j<<8|y,n=0;n<4&&i+n*.75<m;n++)x.push(w.charAt(O>>>6*(3-n)&63));var r=w.charAt(64);if(r)for(;x.length%4;)x.push(r);return x.join("")},parse:function(a){var t=a.length,m=this._map,w=this._reverseMap;if(!w){w=this._reverseMap=[];for(var x=0;x<m.length;x++)w[m.charCodeAt(x)]=x}var i=m.charAt(64);if(i){var k=a.indexOf(i);k!==-1&&(t=k)}return d(a,t,w)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function d(a,t,m){for(var w=[],x=0,i=0;i<t;i++)if(i%4){var k=m[a.charCodeAt(i-1)]<<i%4*2,j=m[a.charCodeAt(i)]>>>6-i%4*2,y=k|j;w[x>>>2]|=y<<24-x%4*8,x++}return v.create(w,x)}}(),p.enc.Base64})}(Be)),Be.exports}var Ae={exports:{}},gn=Ae.exports,jr;function mn(){return jr||(jr=1,function(s,h){(function(p,l){s.exports=l(oe())})(gn,function(p){return function(l){var C=p,v=C.lib,g=v.WordArray,d=v.Hasher,a=C.algo,t=[];(function(){for(var j=0;j<64;j++)t[j]=l.abs(l.sin(j+1))*4294967296|0})();var m=a.MD5=d.extend({_doReset:function(){this._hash=new g.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(j,y){for(var O=0;O<16;O++){var n=y+O,r=j[n];j[n]=(r<<8|r>>>24)&16711935|(r<<24|r>>>8)&4278255360}var f=this._hash.words,_=j[y+0],A=j[y+1],T=j[y+2],L=j[y+3],N=j[y+4],u=j[y+5],b=j[y+6],B=j[y+7],S=j[y+8],z=j[y+9],F=j[y+10],U=j[y+11],G=j[y+12],Y=j[y+13],R=j[y+14],Q=j[y+15],P=f[0],E=f[1],e=f[2],o=f[3];P=w(P,E,e,o,_,7,t[0]),o=w(o,P,E,e,A,12,t[1]),e=w(e,o,P,E,T,17,t[2]),E=w(E,e,o,P,L,22,t[3]),P=w(P,E,e,o,N,7,t[4]),o=w(o,P,E,e,u,12,t[5]),e=w(e,o,P,E,b,17,t[6]),E=w(E,e,o,P,B,22,t[7]),P=w(P,E,e,o,S,7,t[8]),o=w(o,P,E,e,z,12,t[9]),e=w(e,o,P,E,F,17,t[10]),E=w(E,e,o,P,U,22,t[11]),P=w(P,E,e,o,G,7,t[12]),o=w(o,P,E,e,Y,12,t[13]),e=w(e,o,P,E,R,17,t[14]),E=w(E,e,o,P,Q,22,t[15]),P=x(P,E,e,o,A,5,t[16]),o=x(o,P,E,e,b,9,t[17]),e=x(e,o,P,E,U,14,t[18]),E=x(E,e,o,P,_,20,t[19]),P=x(P,E,e,o,u,5,t[20]),o=x(o,P,E,e,F,9,t[21]),e=x(e,o,P,E,Q,14,t[22]),E=x(E,e,o,P,N,20,t[23]),P=x(P,E,e,o,z,5,t[24]),o=x(o,P,E,e,R,9,t[25]),e=x(e,o,P,E,L,14,t[26]),E=x(E,e,o,P,S,20,t[27]),P=x(P,E,e,o,Y,5,t[28]),o=x(o,P,E,e,T,9,t[29]),e=x(e,o,P,E,B,14,t[30]),E=x(E,e,o,P,G,20,t[31]),P=i(P,E,e,o,u,4,t[32]),o=i(o,P,E,e,S,11,t[33]),e=i(e,o,P,E,U,16,t[34]),E=i(E,e,o,P,R,23,t[35]),P=i(P,E,e,o,A,4,t[36]),o=i(o,P,E,e,N,11,t[37]),e=i(e,o,P,E,B,16,t[38]),E=i(E,e,o,P,F,23,t[39]),P=i(P,E,e,o,Y,4,t[40]),o=i(o,P,E,e,_,11,t[41]),e=i(e,o,P,E,L,16,t[42]),E=i(E,e,o,P,b,23,t[43]),P=i(P,E,e,o,z,4,t[44]),o=i(o,P,E,e,G,11,t[45]),e=i(e,o,P,E,Q,16,t[46]),E=i(E,e,o,P,T,23,t[47]),P=k(P,E,e,o,_,6,t[48]),o=k(o,P,E,e,B,10,t[49]),e=k(e,o,P,E,R,15,t[50]),E=k(E,e,o,P,u,21,t[51]),P=k(P,E,e,o,G,6,t[52]),o=k(o,P,E,e,L,10,t[53]),e=k(e,o,P,E,F,15,t[54]),E=k(E,e,o,P,A,21,t[55]),P=k(P,E,e,o,S,6,t[56]),o=k(o,P,E,e,Q,10,t[57]),e=k(e,o,P,E,b,15,t[58]),E=k(E,e,o,P,Y,21,t[59]),P=k(P,E,e,o,N,6,t[60]),o=k(o,P,E,e,U,10,t[61]),e=k(e,o,P,E,T,15,t[62]),E=k(E,e,o,P,z,21,t[63]),f[0]=f[0]+P|0,f[1]=f[1]+E|0,f[2]=f[2]+e|0,f[3]=f[3]+o|0},_doFinalize:function(){var j=this._data,y=j.words,O=this._nDataBytes*8,n=j.sigBytes*8;y[n>>>5]|=128<<24-n%32;var r=l.floor(O/4294967296),f=O;y[(n+64>>>9<<4)+15]=(r<<8|r>>>24)&16711935|(r<<24|r>>>8)&4278255360,y[(n+64>>>9<<4)+14]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360,j.sigBytes=(y.length+1)*4,this._process();for(var _=this._hash,A=_.words,T=0;T<4;T++){var L=A[T];A[T]=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360}return _},clone:function(){var j=d.clone.call(this);return j._hash=this._hash.clone(),j}});function w(j,y,O,n,r,f,_){var A=j+(y&O|~y&n)+r+_;return(A<<f|A>>>32-f)+y}function x(j,y,O,n,r,f,_){var A=j+(y&n|O&~n)+r+_;return(A<<f|A>>>32-f)+y}function i(j,y,O,n,r,f,_){var A=j+(y^O^n)+r+_;return(A<<f|A>>>32-f)+y}function k(j,y,O,n,r,f,_){var A=j+(O^(y|~n))+r+_;return(A<<f|A>>>32-f)+y}C.MD5=d._createHelper(m),C.HmacMD5=d._createHmacHelper(m)}(Math),p.MD5})}(Ae)),Ae.exports}var Ie={exports:{}},Oe={exports:{}},yn=Oe.exports,Sr;function xn(){return Sr||(Sr=1,function(s,h){(function(p,l){s.exports=l(oe())})(yn,function(p){return function(){var l=p,C=l.lib,v=C.WordArray,g=C.Hasher,d=l.algo,a=[],t=d.SHA1=g.extend({_doReset:function(){this._hash=new v.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(m,w){for(var x=this._hash.words,i=x[0],k=x[1],j=x[2],y=x[3],O=x[4],n=0;n<80;n++){if(n<16)a[n]=m[w+n]|0;else{var r=a[n-3]^a[n-8]^a[n-14]^a[n-16];a[n]=r<<1|r>>>31}var f=(i<<5|i>>>27)+O+a[n];n<20?f+=(k&j|~k&y)+1518500249:n<40?f+=(k^j^y)+1859775393:n<60?f+=(k&j|k&y|j&y)-1894007588:f+=(k^j^y)-899497514,O=y,y=j,j=k<<30|k>>>2,k=i,i=f}x[0]=x[0]+i|0,x[1]=x[1]+k|0,x[2]=x[2]+j|0,x[3]=x[3]+y|0,x[4]=x[4]+O|0},_doFinalize:function(){var m=this._data,w=m.words,x=this._nDataBytes*8,i=m.sigBytes*8;return w[i>>>5]|=128<<24-i%32,w[(i+64>>>9<<4)+14]=Math.floor(x/4294967296),w[(i+64>>>9<<4)+15]=x,m.sigBytes=w.length*4,this._process(),this._hash},clone:function(){var m=g.clone.call(this);return m._hash=this._hash.clone(),m}});l.SHA1=g._createHelper(t),l.HmacSHA1=g._createHmacHelper(t)}(),p.SHA1})}(Oe)),Oe.exports}var De={exports:{}},_n=De.exports,Pr;function wn(){return Pr||(Pr=1,function(s,h){(function(p,l){s.exports=l(oe())})(_n,function(p){(function(){var l=p,C=l.lib,v=C.Base,g=l.enc,d=g.Utf8,a=l.algo;a.HMAC=v.extend({init:function(t,m){t=this._hasher=new t.init,typeof m=="string"&&(m=d.parse(m));var w=t.blockSize,x=w*4;m.sigBytes>x&&(m=t.finalize(m)),m.clamp();for(var i=this._oKey=m.clone(),k=this._iKey=m.clone(),j=i.words,y=k.words,O=0;O<w;O++)j[O]^=1549556828,y[O]^=909522486;i.sigBytes=k.sigBytes=x,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var m=this._hasher,w=m.finalize(t);m.reset();var x=m.finalize(this._oKey.clone().concat(w));return x}})})()})}(De)),De.exports}var bn=Ie.exports,kr;function ct(){return kr||(kr=1,function(s,h){(function(p,l,C){s.exports=l(oe(),xn(),wn())})(bn,function(p){return function(){var l=p,C=l.lib,v=C.Base,g=C.WordArray,d=l.algo,a=d.MD5,t=d.EvpKDF=v.extend({cfg:v.extend({keySize:128/32,hasher:a,iterations:1}),init:function(m){this.cfg=this.cfg.extend(m)},compute:function(m,w){for(var x,i=this.cfg,k=i.hasher.create(),j=g.create(),y=j.words,O=i.keySize,n=i.iterations;y.length<O;){x&&k.update(x),x=k.update(m).finalize(w),k.reset();for(var r=1;r<n;r++)x=k.finalize(x),k.reset();j.concat(x)}return j.sigBytes=O*4,j}});l.EvpKDF=function(m,w,x){return t.create(x).compute(m,w)}}(),p.EvpKDF})}(Ie)),Ie.exports}var Te={exports:{}},Cn=Te.exports,Br;function En(){return Br||(Br=1,function(s,h){(function(p,l,C){s.exports=l(oe(),ct())})(Cn,function(p){p.lib.Cipher||function(l){var C=p,v=C.lib,g=v.Base,d=v.WordArray,a=v.BufferedBlockAlgorithm,t=C.enc;t.Utf8;var m=t.Base64,w=C.algo,x=w.EvpKDF,i=v.Cipher=a.extend({cfg:g.extend(),createEncryptor:function(u,b){return this.create(this._ENC_XFORM_MODE,u,b)},createDecryptor:function(u,b){return this.create(this._DEC_XFORM_MODE,u,b)},init:function(u,b,B){this.cfg=this.cfg.extend(B),this._xformMode=u,this._key=b,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(u){return this._append(u),this._process()},finalize:function(u){u&&this._append(u);var b=this._doFinalize();return b},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function u(b){return typeof b=="string"?N:A}return function(b){return{encrypt:function(B,S,z){return u(S).encrypt(b,B,S,z)},decrypt:function(B,S,z){return u(S).decrypt(b,B,S,z)}}}}()});v.StreamCipher=i.extend({_doFinalize:function(){var u=this._process(!0);return u},blockSize:1});var k=C.mode={},j=v.BlockCipherMode=g.extend({createEncryptor:function(u,b){return this.Encryptor.create(u,b)},createDecryptor:function(u,b){return this.Decryptor.create(u,b)},init:function(u,b){this._cipher=u,this._iv=b}}),y=k.CBC=function(){var u=j.extend();u.Encryptor=u.extend({processBlock:function(B,S){var z=this._cipher,F=z.blockSize;b.call(this,B,S,F),z.encryptBlock(B,S),this._prevBlock=B.slice(S,S+F)}}),u.Decryptor=u.extend({processBlock:function(B,S){var z=this._cipher,F=z.blockSize,U=B.slice(S,S+F);z.decryptBlock(B,S),b.call(this,B,S,F),this._prevBlock=U}});function b(B,S,z){var F,U=this._iv;U?(F=U,this._iv=l):F=this._prevBlock;for(var G=0;G<z;G++)B[S+G]^=F[G]}return u}(),O=C.pad={},n=O.Pkcs7={pad:function(u,b){for(var B=b*4,S=B-u.sigBytes%B,z=S<<24|S<<16|S<<8|S,F=[],U=0;U<S;U+=4)F.push(z);var G=d.create(F,S);u.concat(G)},unpad:function(u){var b=u.words[u.sigBytes-1>>>2]&255;u.sigBytes-=b}};v.BlockCipher=i.extend({cfg:i.cfg.extend({mode:y,padding:n}),reset:function(){var u;i.reset.call(this);var b=this.cfg,B=b.iv,S=b.mode;this._xformMode==this._ENC_XFORM_MODE?u=S.createEncryptor:(u=S.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==u?this._mode.init(this,B&&B.words):(this._mode=u.call(S,this,B&&B.words),this._mode.__creator=u)},_doProcessBlock:function(u,b){this._mode.processBlock(u,b)},_doFinalize:function(){var u,b=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(b.pad(this._data,this.blockSize),u=this._process(!0)):(u=this._process(!0),b.unpad(u)),u},blockSize:128/32});var r=v.CipherParams=g.extend({init:function(u){this.mixIn(u)},toString:function(u){return(u||this.formatter).stringify(this)}}),f=C.format={},_=f.OpenSSL={stringify:function(u){var b,B=u.ciphertext,S=u.salt;return S?b=d.create([1398893684,1701076831]).concat(S).concat(B):b=B,b.toString(m)},parse:function(u){var b,B=m.parse(u),S=B.words;return S[0]==1398893684&&S[1]==1701076831&&(b=d.create(S.slice(2,4)),S.splice(0,4),B.sigBytes-=16),r.create({ciphertext:B,salt:b})}},A=v.SerializableCipher=g.extend({cfg:g.extend({format:_}),encrypt:function(u,b,B,S){S=this.cfg.extend(S);var z=u.createEncryptor(B,S),F=z.finalize(b),U=z.cfg;return r.create({ciphertext:F,key:B,iv:U.iv,algorithm:u,mode:U.mode,padding:U.padding,blockSize:u.blockSize,formatter:S.format})},decrypt:function(u,b,B,S){S=this.cfg.extend(S),b=this._parse(b,S.format);var z=u.createDecryptor(B,S).finalize(b.ciphertext);return z},_parse:function(u,b){return typeof u=="string"?b.parse(u,this):u}}),T=C.kdf={},L=T.OpenSSL={execute:function(u,b,B,S,z){if(S||(S=d.random(64/8)),z)var F=x.create({keySize:b+B,hasher:z}).compute(u,S);else var F=x.create({keySize:b+B}).compute(u,S);var U=d.create(F.words.slice(b),B*4);return F.sigBytes=b*4,r.create({key:F,iv:U,salt:S})}},N=v.PasswordBasedCipher=A.extend({cfg:A.cfg.extend({kdf:L}),encrypt:function(u,b,B,S){S=this.cfg.extend(S);var z=S.kdf.execute(B,u.keySize,u.ivSize,S.salt,S.hasher);S.iv=z.iv;var F=A.encrypt.call(this,u,b,z.key,S);return F.mixIn(z),F},decrypt:function(u,b,B,S){S=this.cfg.extend(S),b=this._parse(b,S.format);var z=S.kdf.execute(B,u.keySize,u.ivSize,b.salt,S.hasher);S.iv=z.iv;var F=A.decrypt.call(this,u,b,z.key,S);return F}})}()})}(Te)),Te.exports}var jn=Pe.exports,Ar;function Sn(){return Ar||(Ar=1,function(s,h){(function(p,l,C){s.exports=l(oe(),at(),mn(),ct(),En())})(jn,function(p){return function(){var l=p,C=l.lib,v=C.BlockCipher,g=l.algo,d=[],a=[],t=[],m=[],w=[],x=[],i=[],k=[],j=[],y=[];(function(){for(var r=[],f=0;f<256;f++)f<128?r[f]=f<<1:r[f]=f<<1^283;for(var _=0,A=0,f=0;f<256;f++){var T=A^A<<1^A<<2^A<<3^A<<4;T=T>>>8^T&255^99,d[_]=T,a[T]=_;var L=r[_],N=r[L],u=r[N],b=r[T]*257^T*16843008;t[_]=b<<24|b>>>8,m[_]=b<<16|b>>>16,w[_]=b<<8|b>>>24,x[_]=b;var b=u*16843009^N*65537^L*257^_*16843008;i[T]=b<<24|b>>>8,k[T]=b<<16|b>>>16,j[T]=b<<8|b>>>24,y[T]=b,_?(_=L^r[r[r[u^L]]],A^=r[r[A]]):_=A=1}})();var O=[0,1,2,4,8,16,32,64,128,27,54],n=g.AES=v.extend({_doReset:function(){var r;if(!(this._nRounds&&this._keyPriorReset===this._key)){for(var f=this._keyPriorReset=this._key,_=f.words,A=f.sigBytes/4,T=this._nRounds=A+6,L=(T+1)*4,N=this._keySchedule=[],u=0;u<L;u++)u<A?N[u]=_[u]:(r=N[u-1],u%A?A>6&&u%A==4&&(r=d[r>>>24]<<24|d[r>>>16&255]<<16|d[r>>>8&255]<<8|d[r&255]):(r=r<<8|r>>>24,r=d[r>>>24]<<24|d[r>>>16&255]<<16|d[r>>>8&255]<<8|d[r&255],r^=O[u/A|0]<<24),N[u]=N[u-A]^r);for(var b=this._invKeySchedule=[],B=0;B<L;B++){var u=L-B;if(B%4)var r=N[u];else var r=N[u-4];B<4||u<=4?b[B]=r:b[B]=i[d[r>>>24]]^k[d[r>>>16&255]]^j[d[r>>>8&255]]^y[d[r&255]]}}},encryptBlock:function(r,f){this._doCryptBlock(r,f,this._keySchedule,t,m,w,x,d)},decryptBlock:function(r,f){var _=r[f+1];r[f+1]=r[f+3],r[f+3]=_,this._doCryptBlock(r,f,this._invKeySchedule,i,k,j,y,a);var _=r[f+1];r[f+1]=r[f+3],r[f+3]=_},_doCryptBlock:function(r,f,_,A,T,L,N,u){for(var b=this._nRounds,B=r[f]^_[0],S=r[f+1]^_[1],z=r[f+2]^_[2],F=r[f+3]^_[3],U=4,G=1;G<b;G++){var Y=A[B>>>24]^T[S>>>16&255]^L[z>>>8&255]^N[F&255]^_[U++],R=A[S>>>24]^T[z>>>16&255]^L[F>>>8&255]^N[B&255]^_[U++],Q=A[z>>>24]^T[F>>>16&255]^L[B>>>8&255]^N[S&255]^_[U++],P=A[F>>>24]^T[B>>>16&255]^L[S>>>8&255]^N[z&255]^_[U++];B=Y,S=R,z=Q,F=P}var Y=(u[B>>>24]<<24|u[S>>>16&255]<<16|u[z>>>8&255]<<8|u[F&255])^_[U++],R=(u[S>>>24]<<24|u[z>>>16&255]<<16|u[F>>>8&255]<<8|u[B&255])^_[U++],Q=(u[z>>>24]<<24|u[F>>>16&255]<<16|u[B>>>8&255]<<8|u[S&255])^_[U++],P=(u[F>>>24]<<24|u[B>>>16&255]<<16|u[S>>>8&255]<<8|u[z&255])^_[U++];r[f]=Y,r[f+1]=R,r[f+2]=Q,r[f+3]=P},keySize:256/32});l.AES=v._createHelper(n)}(),p.AES})}(Pe)),Pe.exports}var Re={exports:{}},Pn=Re.exports,Ir;function kn(){return Ir||(Ir=1,function(s,h){(function(p,l){s.exports=l(oe())})(Pn,function(p){return p.enc.Latin1})}(Re)),Re.exports}var ze={exports:{}},Bn=ze.exports,Or;function An(){return Or||(Or=1,function(s,h){(function(p,l){s.exports=l(oe())})(Bn,function(p){return p.enc.Utf8})}(ze)),ze.exports}var Le={exports:{}},In=Le.exports,Dr;function On(){return Dr||(Dr=1,function(s,h){(function(p,l){s.exports=l(oe())})(In,function(p){return function(){var l=p,C=l.lib,v=C.WordArray,g=l.enc;g.Utf16=g.Utf16BE={stringify:function(a){for(var t=a.words,m=a.sigBytes,w=[],x=0;x<m;x+=2){var i=t[x>>>2]>>>16-x%4*8&65535;w.push(String.fromCharCode(i))}return w.join("")},parse:function(a){for(var t=a.length,m=[],w=0;w<t;w++)m[w>>>1]|=a.charCodeAt(w)<<16-w%2*16;return v.create(m,t*2)}},g.Utf16LE={stringify:function(a){for(var t=a.words,m=a.sigBytes,w=[],x=0;x<m;x+=2){var i=d(t[x>>>2]>>>16-x%4*8&65535);w.push(String.fromCharCode(i))}return w.join("")},parse:function(a){for(var t=a.length,m=[],w=0;w<t;w++)m[w>>>1]|=d(a.charCodeAt(w)<<16-w%2*16);return v.create(m,t*2)}};function d(a){return a<<8&4278255360|a>>>8&16711935}}(),p.enc.Utf16})}(Le)),Le.exports}var Fe={exports:{}},Dn=Fe.exports,Tr;function Tn(){return Tr||(Tr=1,function(s,h){(function(p,l){s.exports=l(oe())})(Dn,function(p){return p.enc.Hex})}(Fe)),Fe.exports}var fe={},Rr;function Rn(){if(Rr)return fe;Rr=1;var s=fe&&fe.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(fe,"__esModule",{value:!0});const h=s(Ut());return fe.default=h.default.create("encrypt","decrypt"),fe}var zr;function zn(){if(zr)return se;zr=1;var s=se&&se.__createBinding||(Object.create?function(i,k,j,y){y===void 0&&(y=j);var O=Object.getOwnPropertyDescriptor(k,j);(!O||("get"in O?!k.__esModule:O.writable||O.configurable))&&(O={enumerable:!0,get:function(){return k[j]}}),Object.defineProperty(i,y,O)}:function(i,k,j,y){y===void 0&&(y=j),i[y]=k[j]}),h=se&&se.__setModuleDefault||(Object.create?function(i,k){Object.defineProperty(i,"default",{enumerable:!0,value:k})}:function(i,k){i.default=k}),p=se&&se.__importStar||function(i){if(i&&i.__esModule)return i;var k={};if(i!=null)for(var j in i)j!=="default"&&Object.prototype.hasOwnProperty.call(i,j)&&s(k,i,j);return h(k,i),k},l=se&&se.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(se,"__esModule",{value:!0}),se.AesCrypter=void 0;const C=p(Sn()),v=l(kn()),g=l(An()),d=l(On()),a=l(at()),t=l(Tn()),m=l(Rn()),w={latin1:v.default,utf8:g.default,hex:t.default,utf16:d.default,base64:a.default};class x extends m.default{encrypt(k,j){const y=typeof k=="string"?k:JSON.stringify(k);return C.encrypt(y,j).toString()}decrypt(k,j,y="utf8"){return C.decrypt(k,j).toString(w[y])}}return se.AesCrypter=x,se.default=new x,se}const Ln=!0,Fn=">= 8",Nn=">= 0.5 && < 0.9.7",qn=!0,Hn=!0,Mn=">= 0.5",Un=!0,Kn=!0,$n=!0,Wn=">= 1 && < 8",Vn="< 8",Gn=!0,Yn=[">= 14.17 && < 15",">= 15.1"],Zn=!0,Jn=">= 0.7.12",Qn=!0,Xn="< 6",es=!0,rs=">= 0.11.1",ts=">= 0.11.1",ns=">= 0.11.1",ss=">= 0.11.1",is=">= 0.11.1",os=">= 0.11.1",as=!0,cs=">= 8.8",ls=!0,us=">= 8",ds="< 8",fs=!0,ps=!0,hs=!0,vs=!0,gs=">= 8.5",ms=">= 1",ys=">= 0.5",xs=!0,_s=!0,ws=!0,bs=">= 0.11.5 && < 3",Cs=">= 0.9.4",Es=">= 0.9.4",js=">= 1.4.1",Ss=">= 0.9.4",Ps=">= 0.9.4",ks=">= 0.9.4",Bs=!0,As=!0,Is=[">= 0.4 && < 0.7",">= 0.8"],Os=!0,Ds=">= 0.11.13",Ts=">= 0.11.3 && < 10",Rs=">= 0.11.3",zs=!0,Ls=">= 10",Fs=!0,Ns=!0,qs=!0,Hs=">= 1",Ms=!0,Us=[">= 13.4 && < 13.5",">= 18.17 && < 19",">= 20"],Ks=">= 11.7",$s=">= 0.5",Ws={assert:Ln,"node:assert":[">= 14.18 && < 15",">= 16"],"assert/strict":">= 15","node:assert/strict":">= 16",async_hooks:Fn,"node:async_hooks":[">= 14.18 && < 15",">= 16"],buffer_ieee754:Nn,buffer:qn,"node:buffer":[">= 14.18 && < 15",">= 16"],child_process:Hn,"node:child_process":[">= 14.18 && < 15",">= 16"],cluster:Mn,"node:cluster":[">= 14.18 && < 15",">= 16"],console:Un,"node:console":[">= 14.18 && < 15",">= 16"],constants:Kn,"node:constants":[">= 14.18 && < 15",">= 16"],crypto:$n,"node:crypto":[">= 14.18 && < 15",">= 16"],_debug_agent:Wn,_debugger:Vn,dgram:Gn,"node:dgram":[">= 14.18 && < 15",">= 16"],diagnostics_channel:Yn,"node:diagnostics_channel":[">= 14.18 && < 15",">= 16"],dns:Zn,"node:dns":[">= 14.18 && < 15",">= 16"],"dns/promises":">= 15","node:dns/promises":">= 16",domain:Jn,"node:domain":[">= 14.18 && < 15",">= 16"],events:Qn,"node:events":[">= 14.18 && < 15",">= 16"],freelist:Xn,fs:es,"node:fs":[">= 14.18 && < 15",">= 16"],"fs/promises":[">= 10 && < 10.1",">= 14"],"node:fs/promises":[">= 14.18 && < 15",">= 16"],_http_agent:rs,"node:_http_agent":[">= 14.18 && < 15",">= 16"],_http_client:ts,"node:_http_client":[">= 14.18 && < 15",">= 16"],_http_common:ns,"node:_http_common":[">= 14.18 && < 15",">= 16"],_http_incoming:ss,"node:_http_incoming":[">= 14.18 && < 15",">= 16"],_http_outgoing:is,"node:_http_outgoing":[">= 14.18 && < 15",">= 16"],_http_server:os,"node:_http_server":[">= 14.18 && < 15",">= 16"],http:as,"node:http":[">= 14.18 && < 15",">= 16"],http2:cs,"node:http2":[">= 14.18 && < 15",">= 16"],https:ls,"node:https":[">= 14.18 && < 15",">= 16"],inspector:us,"node:inspector":[">= 14.18 && < 15",">= 16"],"inspector/promises":[">= 19"],"node:inspector/promises":[">= 19"],_linklist:ds,module:fs,"node:module":[">= 14.18 && < 15",">= 16"],net:ps,"node:net":[">= 14.18 && < 15",">= 16"],"node-inspect/lib/_inspect":">= 7.6 && < 12","node-inspect/lib/internal/inspect_client":">= 7.6 && < 12","node-inspect/lib/internal/inspect_repl":">= 7.6 && < 12",os:hs,"node:os":[">= 14.18 && < 15",">= 16"],path:vs,"node:path":[">= 14.18 && < 15",">= 16"],"path/posix":">= 15.3","node:path/posix":">= 16","path/win32":">= 15.3","node:path/win32":">= 16",perf_hooks:gs,"node:perf_hooks":[">= 14.18 && < 15",">= 16"],process:ms,"node:process":[">= 14.18 && < 15",">= 16"],punycode:ys,"node:punycode":[">= 14.18 && < 15",">= 16"],querystring:xs,"node:querystring":[">= 14.18 && < 15",">= 16"],readline:_s,"node:readline":[">= 14.18 && < 15",">= 16"],"readline/promises":">= 17","node:readline/promises":">= 17",repl:ws,"node:repl":[">= 14.18 && < 15",">= 16"],"node:sea":[">= 20.12 && < 21",">= 21.7"],smalloc:bs,_stream_duplex:Cs,"node:_stream_duplex":[">= 14.18 && < 15",">= 16"],_stream_transform:Es,"node:_stream_transform":[">= 14.18 && < 15",">= 16"],_stream_wrap:js,"node:_stream_wrap":[">= 14.18 && < 15",">= 16"],_stream_passthrough:Ss,"node:_stream_passthrough":[">= 14.18 && < 15",">= 16"],_stream_readable:Ps,"node:_stream_readable":[">= 14.18 && < 15",">= 16"],_stream_writable:ks,"node:_stream_writable":[">= 14.18 && < 15",">= 16"],stream:Bs,"node:stream":[">= 14.18 && < 15",">= 16"],"stream/consumers":">= 16.7","node:stream/consumers":">= 16.7","stream/promises":">= 15","node:stream/promises":">= 16","stream/web":">= 16.5","node:stream/web":">= 16.5",string_decoder:As,"node:string_decoder":[">= 14.18 && < 15",">= 16"],sys:Is,"node:sys":[">= 14.18 && < 15",">= 16"],"test/reporters":">= 19.9 && < 20.2","node:test/reporters":[">= 18.17 && < 19",">= 19.9",">= 20"],"test/mock_loader":">= 22.3 && < 22.7","node:test/mock_loader":">= 22.3 && < 22.7","node:test":[">= 16.17 && < 17",">= 18"],timers:Os,"node:timers":[">= 14.18 && < 15",">= 16"],"timers/promises":">= 15","node:timers/promises":">= 16",_tls_common:Ds,"node:_tls_common":[">= 14.18 && < 15",">= 16"],_tls_legacy:Ts,_tls_wrap:Rs,"node:_tls_wrap":[">= 14.18 && < 15",">= 16"],tls:zs,"node:tls":[">= 14.18 && < 15",">= 16"],trace_events:Ls,"node:trace_events":[">= 14.18 && < 15",">= 16"],tty:Fs,"node:tty":[">= 14.18 && < 15",">= 16"],url:Ns,"node:url":[">= 14.18 && < 15",">= 16"],util:qs,"node:util":[">= 14.18 && < 15",">= 16"],"util/types":">= 15.3","node:util/types":">= 16","v8/tools/arguments":">= 10 && < 12","v8/tools/codemap":[">= 4.4 && < 5",">= 5.2 && < 12"],"v8/tools/consarray":[">= 4.4 && < 5",">= 5.2 && < 12"],"v8/tools/csvparser":[">= 4.4 && < 5",">= 5.2 && < 12"],"v8/tools/logreader":[">= 4.4 && < 5",">= 5.2 && < 12"],"v8/tools/profile_view":[">= 4.4 && < 5",">= 5.2 && < 12"],"v8/tools/splaytree":[">= 4.4 && < 5",">= 5.2 && < 12"],v8:Hs,"node:v8":[">= 14.18 && < 15",">= 16"],vm:Ms,"node:vm":[">= 14.18 && < 15",">= 16"],wasi:Us,"node:wasi":[">= 18.17 && < 19",">= 20"],worker_threads:Ks,"node:worker_threads":[">= 14.18 && < 15",">= 16"],zlib:$s,"node:zlib":[">= 14.18 && < 15",">= 16"]};var We,Lr;function Vs(){if(Lr)return We;Lr=1;var s=Kt();function h(v,g){for(var d=v.split("."),a=g.split(" "),t=a.length>1?a[0]:"=",m=(a.length>1?a[1]:a[0]).split("."),w=0;w<3;++w){var x=parseInt(d[w]||0,10),i=parseInt(m[w]||0,10);if(x!==i)return t==="<"?x<i:t===">="?x>=i:!1}return t===">="}function p(v,g){var d=g.split(/ ?&& ?/);if(d.length===0)return!1;for(var a=0;a<d.length;++a)if(!h(v,d[a]))return!1;return!0}function l(v,g){if(typeof g=="boolean")return g;var d=typeof v>"u"?J.versions&&J.versions.node:v;if(typeof d!="string")throw new TypeError(typeof v>"u"?"Unable to determine current node version":"If provided, a valid node version is required");if(g&&typeof g=="object"){for(var a=0;a<g.length;++a)if(p(d,g[a]))return!0;return!1}return p(d,g)}var C=Ws;return We=function(g,d){return s(C,g)&&l(d,C[g])},We}var Ve,Fr;function Gs(){if(Fr)return Ve;Fr=1;var s={},h=tt();return Ve=h.homedir||function(){var l=s.HOME,C=s.LOGNAME||s.USER||s.LNAME||s.USERNAME;return J.platform==="win32"?s.USERPROFILE||s.HOMEDRIVE+s.HOMEPATH||l||null:J.platform==="darwin"?l||(C?"/Users/"+C:null):J.platform==="linux"?l||(J.getuid()===0?"/root":C?"/home/"+C:null):l||null},Ve}var Ge,Nr;function Ys(){return Nr||(Nr=1,Ge=function(){var s=Error.prepareStackTrace;Error.prepareStackTrace=function(p,l){return l};var h=new Error().stack;return Error.prepareStackTrace=s,h[2].getFileName()}),Ge}var pe={exports:{}},qr;function Zs(){if(qr)return pe.exports;qr=1;var s=J.platform==="win32",h=/^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/,p={};function l(d){return h.exec(d).slice(1)}p.parse=function(d){if(typeof d!="string")throw new TypeError("Parameter 'pathString' must be a string, not "+typeof d);var a=l(d);if(!a||a.length!==5)throw new TypeError("Invalid path '"+d+"'");return{root:a[1],dir:a[0]===a[1]?a[0]:a[0].slice(0,-1),base:a[2],ext:a[4],name:a[3]}};var C=/^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/,v={};function g(d){return C.exec(d).slice(1)}return v.parse=function(d){if(typeof d!="string")throw new TypeError("Parameter 'pathString' must be a string, not "+typeof d);var a=g(d);if(!a||a.length!==5)throw new TypeError("Invalid path '"+d+"'");return{root:a[1],dir:a[0].slice(0,-1),base:a[2],ext:a[4],name:a[3]}},s?pe.exports=p.parse:pe.exports=v.parse,pe.exports.posix=v.parse,pe.exports.win32=p.parse,pe.exports}var Ye,Hr;function Js(){if(Hr)return Ye;Hr=1;var s=Ue(),h=s.parse||Zs(),p=function(C,v){var g="/";/^([A-Za-z]:)/.test(C)?g="":/^\\\\/.test(C)&&(g="\\\\");for(var d=[C],a=h(C);a.dir!==d[d.length-1];)d.push(a.dir),a=h(a.dir);return d.reduce(function(t,m){return t.concat(v.map(function(w){return s.resolve(g,m,w)}))},[])};return Ye=function(C,v,g){var d=v&&v.moduleDirectory?[].concat(v.moduleDirectory):["node_modules"];if(v&&typeof v.paths=="function")return v.paths(g,C,function(){return p(C,d)},v);var a=p(C,d);return v&&v.paths?a.concat(v.paths):a},Ye}var Ze,Mr;function Qs(){return Mr||(Mr=1,Ze=function(s,h){return h||{}}),Ze}var Je,Ur;function Xs(){if(Ur)return Je;Ur=1;var s=Vs(),h=Ke,p=Ue(),l=Gs(),C=Ys(),v=Js(),g=Qs(),d=J.platform!=="win32"&&h.realpathSync&&typeof h.realpathSync.native=="function"?h.realpathSync.native:h.realpathSync,a=l(),t=function(){return[p.join(a,".node_modules"),p.join(a,".node_libraries")]},m=function(O){try{var n=h.statSync(O,{throwIfNoEntry:!1})}catch(r){if(r&&(r.code==="ENOENT"||r.code==="ENOTDIR"))return!1;throw r}return!!n&&(n.isFile()||n.isFIFO())},w=function(O){try{var n=h.statSync(O,{throwIfNoEntry:!1})}catch(r){if(r&&(r.code==="ENOENT"||r.code==="ENOTDIR"))return!1;throw r}return!!n&&n.isDirectory()},x=function(O){try{return d(O)}catch(n){if(n.code!=="ENOENT")throw n}return O},i=function(O,n,r){return r&&r.preserveSymlinks===!1?O(n):n},k=function(O,n){var r=O(n);try{var f=JSON.parse(r);return f}catch{}},j=function(O,n,r){for(var f=v(n,r,O),_=0;_<f.length;_++)f[_]=p.join(f[_],O);return f};return Je=function(O,n){if(typeof O!="string")throw new TypeError("Path must be a string.");var r=g(O,n),f=r.isFile||m,_=r.readFileSync||h.readFileSync,A=r.isDirectory||w,T=r.realpathSync||x,L=r.readPackageSync||k;if(r.readFileSync&&r.readPackageSync)throw new TypeError("`readFileSync` and `readPackageSync` are mutually exclusive.");var N=r.packageIterator,u=r.extensions||[".js"],b=r.includeCoreModules!==!1,B=r.basedir||p.dirname(C()),S=r.filename||B;r.paths=r.paths||t();var z=i(T,p.resolve(B),r);if(/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(O)){var F=p.resolve(z,O);(O==="."||O===".."||O.slice(-1)==="/")&&(F+="/");var U=R(F)||P(F);if(U)return i(T,U,r)}else{if(b&&s(O))return O;var G=E(O,z);if(G)return i(T,G,r)}var Y=new Error("Cannot find module '"+O+"' from '"+S+"'");throw Y.code="MODULE_NOT_FOUND",Y;function R(e){var o=Q(p.dirname(e));if(o&&o.dir&&o.pkg&&r.pathFilter){var D=p.relative(o.dir,e),H=r.pathFilter(o.pkg,e,D);H&&(e=p.resolve(o.dir,H))}if(f(e))return e;for(var V=0;V<u.length;V++){var M=e+u[V];if(f(M))return M}}function Q(e){if(!(e===""||e==="/")&&!(J.platform==="win32"&&/^\w:[/\\]*$/.test(e))&&!/[/\\]node_modules[/\\]*$/.test(e)){var o=p.join(i(T,e,r),"package.json");if(!f(o))return Q(p.dirname(e));var D=L(_,o);return D&&r.packageFilter&&(D=r.packageFilter(D,e)),{pkg:D,dir:e}}}function P(e){var o=p.join(i(T,e,r),"/package.json");if(f(o)){try{var D=L(_,o)}catch{}if(D&&r.packageFilter&&(D=r.packageFilter(D,e)),D&&D.main){if(typeof D.main!="string"){var H=new TypeError("package “"+D.name+"” `main` must be a string");throw H.code="INVALID_PACKAGE_MAIN",H}(D.main==="."||D.main==="./")&&(D.main="index");try{var V=R(p.resolve(e,D.main));if(V)return V;var M=P(p.resolve(e,D.main));if(M)return M}catch{}}}return R(p.join(e,"/index"))}function E(e,o){for(var D=function(){return j(e,o,r)},H=N?N(e,o,D,r):D(),V=0;V<H.length;V++){var M=H[V];if(A(p.dirname(M))){var X=R(M);if(X)return X;var ee=P(M);if(ee)return ee}}}},Je}var Qe,Kr;function ei(){return Kr||(Kr=1,Qe=Xs()),Qe}var Xe,$r;function ri(){if($r)return Xe;$r=1;var s={};Xe=C,C.sync=v;var h=Ke;function p(g,d){var a=d.pathExt!==void 0?d.pathExt:s.PATHEXT;if(!a||(a=a.split(";"),a.indexOf("")!==-1))return!0;for(var t=0;t<a.length;t++){var m=a[t].toLowerCase();if(m&&g.substr(-m.length).toLowerCase()===m)return!0}return!1}function l(g,d,a){return!g.isSymbolicLink()&&!g.isFile()?!1:p(d,a)}function C(g,d,a){h.stat(g,function(t,m){a(t,t?!1:l(m,g,d))})}function v(g,d){return l(h.statSync(g),g,d)}return Xe}var er,Wr;function ti(){if(Wr)return er;Wr=1,er=h,h.sync=p;var s=Ke;function h(v,g,d){s.stat(v,function(a,t){d(a,a?!1:l(t,g))})}function p(v,g){return l(s.statSync(v),g)}function l(v,g){return v.isFile()&&C(v,g)}function C(v,g){var d=v.mode,a=v.uid,t=v.gid,m=g.uid!==void 0?g.uid:J.getuid&&J.getuid(),w=g.gid!==void 0?g.gid:J.getgid&&J.getgid(),x=parseInt("100",8),i=parseInt("010",8),k=parseInt("001",8),j=x|i,y=d&k||d&i&&t===w||d&x&&a===m||d&j&&m===0;return y}return er}var rr,Vr;function ni(){if(Vr)return rr;Vr=1;var s;J.platform==="win32"||je.TESTING_WINDOWS?s=ri():s=ti(),rr=h,h.sync=p;function h(l,C,v){if(typeof C=="function"&&(v=C,C={}),!v){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(g,d){h(l,C||{},function(a,t){a?d(a):g(t)})})}s(l,C||{},function(g,d){g&&(g.code==="EACCES"||C&&C.ignoreErrors)&&(g=null,d=!1),v(g,d)})}function p(l,C){try{return s.sync(l,C||{})}catch(v){if(C&&C.ignoreErrors||v.code==="EACCES")return!1;throw v}}return rr}var tr,Gr;function si(){if(Gr)return tr;Gr=1;var s={};const h=J.platform==="win32"||s.OSTYPE==="cygwin"||s.OSTYPE==="msys",p=Ue(),l=h?";":":",C=ni(),v=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),g=(t,m)=>{const w=m.colon||l,x=t.match(/\//)||h&&t.match(/\\/)?[""]:[...h?[J.cwd()]:[],...(m.path||s.PATH||"").split(w)],i=h?m.pathExt||s.PATHEXT||".EXE;.CMD;.BAT;.COM":"",k=h?i.split(w):[""];return h&&t.indexOf(".")!==-1&&k[0]!==""&&k.unshift(""),{pathEnv:x,pathExt:k,pathExtExe:i}},d=(t,m,w)=>{typeof m=="function"&&(w=m,m={}),m||(m={});const{pathEnv:x,pathExt:i,pathExtExe:k}=g(t,m),j=[],y=n=>new Promise((r,f)=>{if(n===x.length)return m.all&&j.length?r(j):f(v(t));const _=x[n],A=/^".*"$/.test(_)?_.slice(1,-1):_,T=p.join(A,t),L=!A&&/^\.[\\\/]/.test(t)?t.slice(0,2)+T:T;r(O(L,n,0))}),O=(n,r,f)=>new Promise((_,A)=>{if(f===i.length)return _(y(r+1));const T=i[f];C(n+T,{pathExt:k},(L,N)=>{if(!L&&N)if(m.all)j.push(n+T);else return _(n+T);return _(O(n,r,f+1))})});return w?y(0).then(n=>w(null,n),w):y(0)},a=(t,m)=>{m=m||{};const{pathEnv:w,pathExt:x,pathExtExe:i}=g(t,m),k=[];for(let j=0;j<w.length;j++){const y=w[j],O=/^".*"$/.test(y)?y.slice(1,-1):y,n=p.join(O,t),r=!O&&/^\.[\\\/]/.test(t)?t.slice(0,2)+n:n;for(let f=0;f<x.length;f++){const _=r+x[f];try{if(C.sync(_,{pathExt:i}))if(m.all)k.push(_);else return _}catch{}}}if(m.all&&k.length)return k;if(m.nothrow)return null;throw v(t)};return tr=d,d.sync=a,tr}var nr,Yr;function ii(){if(Yr)return nr;Yr=1;function s(h){if(!(typeof h>"u"))try{return structuredClone(h)}catch{return JSON.parse(JSON.stringify(h))}}return nr=s,nr}var sr,Zr;function oi(){if(Zr)return sr;Zr=1;var s={};const{BLOCKLET_MODES:h}=Vt(),p=rt(),l=zn().default,C=$t(),v=Yt,{dirname:g,join:d,sep:a}=Ue(),t=ei(),{tmpdir:m,homedir:w}=tt(),x=si(),{withHttps:i}=Gt(),{exec:k}=Ke,{promisify:j}=Wt(),y=ii(),O="z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o",n="z8iZjMn7Hcyh93rKf8PqcSM94XnS8nRqSrPoP",r=(e,o,D)=>l.encrypt(e,p.pbkdf2Sync(D,o,256,32,"sha512").toString("hex")),f=(e,o,D)=>l.decrypt(e,p.pbkdf2Sync(D,o,256,32,"sha512").toString("hex")),_=(e,o=!0)=>{let D=e;return Array.isArray(D)&&D.every(H=>H.originFileObj&&H.url)&&(D=D.map(H=>H.url),D.length===1&&([D]=D)),o&&D&&typeof D=="object"&&(D=JSON.stringify(D)),D&&typeof D=="string"&&(D=D.replace(/(\r\n|\n|\r)/gm," ")),D},A=e=>e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,""),T=e=>A(wr.from(e).toString("base64")),L=e=>(e+"===".slice((e.length+3)%4)).replace(/-/g,"+").replace(/_/g,"/"),N=e=>new Uint8Array(wr.from(L(e),"base64")),u="v21.6.0",b=()=>C.gte(J.version,u),B=()=>{try{return t("@arcblock/pm2",{basedir:__dirname})}catch{return null}};function S(e){try{return x.sync(e)}catch{return null}}const z=new Map;async function F({optionsKey:e,optionsValues:o}){const D=j(k),H=J.version,V=`${H}.${e}`;if(z.has(V))return z.get(V);try{const{stdout:M}=await D("node -h"),X=o.find(ee=>M.includes(ee));if(!X)throw new Error(`Can not get permission option: ${e} for this Node.js version: ${H}`);return z.set(V,X),X}catch(M){throw console.error(M),M}}const U=async(e,o=!0)=>{const D=s.NODE_OPTIONS??"";if(D.includes("--experimental-permission")||D.includes("--permission")||D.includes("--allow-fs-read")||D.includes("--allow-fs-write")||D.includes("--allow-addons")||D.includes("--allow-child-process")||D.includes("--allow-worker"))throw console.error("getSecurityNodeOptions",{nodeOptions:D}),new Error("process.env.NODE_OPTIONS should not include --experimental-permission or --permission or --allow-fs-read or --allow-fs-write or --allow-addons or --allow-child-process or --allow-worker");if(!e)throw new Error("blocklet is not defined");if(D.includes("ms-vscode.js-debug/src/bootloader.js")&&(e.mode===h.DEVELOPMENT||e.environmentObj.BLOCKLET_MODE===h.DEVELOPMENT))return D;const H=[D].filter(te=>!!te&&te!=="undefined");if(!b()||!o)return H.join(" ").trim();const V=B(),M=S("meilisearch"),X="/data/bin/meilisearch",ee=S("blocklet"),re=[s.XDG_DATA_HOME?d(s.XDG_DATA_HOME,"pnpm/global/"):"",s.PNPM_HOME?d(s.PNPM_HOME,"global/"):""],xe=await F({optionsKey:"--permission",optionsValues:["--permission","--experimental-permission"]});if(H.push(xe,...[e.environmentObj.BLOCKLET_DATA_DIR,e.environmentObj.BLOCKLET_APP_DIR,e.environmentObj.BLOCKLET_LOG_DIR,e.environmentObj.BLOCKLET_CACHE_DIR,e.environmentObj.BLOCKLET_APP_DATA_DIR?d(e.environmentObj.BLOCKLET_APP_DATA_DIR,".projects"):"",m()].filter(Boolean).map(te=>`--allow-fs-write=${d(te,"/*")}`),"--allow-addons","--allow-child-process"),e.mode===h.DEVELOPMENT||e.environmentObj.BLOCKLET_MODE===h.DEVELOPMENT)H.push("--allow-worker","--allow-fs-read=*"),H.push(`--allow-fs-write=${d(w(),".npm","_logs","/*")}`);else if(H.push(...[e.environmentObj.BLOCKLET_LOG_DIR,e.environmentObj.BLOCKLET_CACHE_DIR,e.environmentObj.BLOCKLET_APP_DATA_DIR,g(g(e.environmentObj.BLOCKLET_APP_DIR)),V&&g(g(g(g(V)))),ee,M,X,g(g(J.execPath)),J.cwd(),m(),d(w(),".cursor-server"),"/Applications/Cursor.app",...re].filter(Boolean).filter(te=>te!==a).map(te=>`--allow-fs-read=${d(te,"/*")}`)),[O,n].includes(e?.environmentObj?.BLOCKLET_COMPONENT_DID)){const te=await F({optionsKey:"--allow-worker",optionsValues:["--allow-worker","--experimental-worker"]});H.push(te)}return v(H).join(" ").trim()},G={crossOriginEmbedderPolicy:!1,crossOriginOpenerPolicy:!1,crossOriginResourcePolicy:!1,originAgentCluster:!1,strictTransportSecurity:!0,xContentTypeOptions:!0,xDnsPrefetchControl:!1,xDownloadOptions:!1,xPermittedCrossDomainPolicies:!1,contentSecurityPolicy:!1,referrerPolicy:!1,xFrameOptions:!1,xPoweredBy:!0,xXssProtection:!1};function Y(e,o,D){const H=y(e[o]||[]);return H.push(...D),[...new Set(H)]}async function R(e,{node:o,blocklet:D,trustedDomains:H=[],info:V}){if(!e?.contentSecurityPolicy?.directives)return e;const M=y(e);M.contentSecurityPolicy.directives["default-src"]=Y(M.contentSecurityPolicy.directives,"default-src",["'self'"]);const X=V||await o.getNodeInfo({useCache:!0});let ee=await o.getBlockletDomainAliases({blocklet:D,nodeInfo:X});return ee=(ee||[]).map(re=>re.value),M.contentSecurityPolicy.directives["connect-src"]=Y(M.contentSecurityPolicy.directives,"connect-src",["'self'",...ee.filter(re=>re).map(re=>`https://${re}/.well-known/ping`),"https://api.simplesvg.com","https://api.iconify.design","https://api.unisvg.com"]),M.contentSecurityPolicy.directives["script-src"]=Y(M.contentSecurityPolicy.directives,"script-src",["'self'","https://js.stripe.com"]),M.contentSecurityPolicy.directives["frame-src"]=Y(M.contentSecurityPolicy.directives,"frame-src",["'self'","https://js.stripe.com",...H.filter(Boolean).map(re=>`https://${re}`)]),M.contentSecurityPolicy.directives["frame-ancestors"]=Y(M.contentSecurityPolicy.directives,"frame-ancestors",["'self'",...(D.settings.userSpaceHosts||[]).map(re=>`https://${re}`),...H.filter(Boolean).map(re=>`https://${re}`)]),M}async function Q(e,{node:o,blocklet:D,info:H}){const V=y(e);if(V?.origin?.smart){const M=[];M.push(...V.origin?.value||[]);const X=H||await o.getNodeInfo({useCache:!0});let ee=await o.getBlockletDomainAliases({blocklet:D,nodeInfo:X});ee=(ee||[]).map(ne=>ne.value),M.push(...ee.map(ne=>i(ne)));const xe=((D.settings.federated||{})?.sites||[]).filter(ne=>ne?.isMaster!==!1||ne.status==="approved"),te=[];for(const ne of xe)te.push(new URL(ne.appUrl).hostname),te.push(...ne.aliasDomain||[]);M.push(...te.map(ne=>i(ne))),V.origin.value=[...new Set(M)]}return V}function P(e){const o=y(e);for(const D of Object.keys(o))o[D]=o[D]?.value??o[D];return o}function E(e){const o=y(e);for(const D of Object.keys(o))o[D]=o[D]?.override??!1;return o}return sr={encrypt:r,decrypt:f,formatEnv:_,encodeEncryptionKey:T,decodeEncryptionKey:N,canUseFileSystemIsolateApi:b,getSecurityNodeOptions:U,patchResponseHeader:R,patchCors:Q,cleanConfigOverride:P,keepConfigOverride:E,DEFAULT_HELMET_CONFIG:G,SAFE_NODE_VERSION:u},sr}var lt=oi();const ir=(s,h)=>s&&lt.encrypt(s,h||dr.AIGNE_CONFIG_ENCRYPT_SALT,""),or=(s,h)=>s&&lt.decrypt(s,h||dr.AIGNE_CONFIG_ENCRYPT_SALT,""),we=s=>s==="aigneHub",Ne=s=>s==="bedrock",ai=s=>{const h=["provider","model"];if(nt(s))return[...h,"key"];const{provider:p}=s;let l=h;return we(p)?l=[...h,"key","url"]:Ne(p)?l=[...h,"accessKeyId","secretAccessKey"]:l=[...h,"key"],l.filter(C=>!s[C])},Jr=s=>{if(nt(s)||s==="")return"0";const h=typeof s=="string"?parseFloat(s):s;if(Number.isNaN(h))return"0";if(typeof Intl<"u"&&Intl.NumberFormat)return new Intl.NumberFormat("en-US",{minimumFractionDigits:0,maximumFractionDigits:2}).format(h);const p=h.toFixed(2).split("."),l=p[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),C=parseFloat(p[1])>0?`.${p[1]}`:"";return`${l}${C}`},ci=s=>[{provider:"aigneHub",name:"AIGNE Hub",baseURL:"https://hub.aigne.io",logo:s?.imgPrefix?le(s.imgPrefix,"/aigne-hub.jpg"):"/aigne-hub.jpg",documentation:"https://hub.aigne.io/docs",models:[]}],Me="z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ",li=async s=>{const h=new URL(s);if(typeof window<"u"&&h.origin===window.location.origin)return ut();const p=le(h.origin,"__blocklet__.js?type=json"),l=await st.get(p).then(g=>g.data);if((l?.componentId||"").split("/").pop()===Me)return le(h.origin,l.prefix||"/");const v=(l?.componentMountPoints||[]).find(g=>g?.did===Me);return v?le(h.origin,v.mountPoint):s},ut=()=>{var s,h,p,l;if(typeof window>"u")return"";const C=((s=window.blocklet)===null||s===void 0?void 0:s.prefix)||"/",v=(h=window.location)===null||h===void 0?void 0:h.origin;if((((p=window.blocklet)===null||p===void 0?void 0:p.componentId)||"").split("/").pop()===Me)return le(v,C);const d=(((l=window.blocklet)===null||l===void 0?void 0:l.componentMountPoints)||[]).find(a=>a?.did===Me);return d?le(v,d.mountPoint):le(v,C)};async function ui({baseUrl:s="",accessKey:h=""}){let p=ut();const l=typeof window<"u";try{if(s){const C=new URL(s);(!l||l&&C.origin!==window.location.origin)&&(p=await li(s))}}catch(C){throw console.warn("Failed to parse baseUrl:",C),new Error(`Failed to parse baseUrl: ${he(C)}`)}if(!p||!h)throw new Error("baseUrl or accessKey is not set");return st.get(le(p,"/api/user/info"),{headers:{Authorization:`Bearer ${h}`}}).then(C=>C.data)}const $e=lr.div`
  min-height: ${({minHeight:s})=>s==="none"?"auto":`${s||160}px`};
  height: ${({height:s,minHeight:h})=>s==="none"?"auto":`${s||h||160}px`};
  padding: ${({theme:s})=>s.spacing(2)};
  border-radius: ${({theme:s})=>s.shape.borderRadius}px;
  border: 1px solid;
  border-color: ${({theme:s})=>s.palette.divider};
  background-color: ${({theme:s})=>s.palette.background.paper};
  box-shadow: ${({theme:s})=>s.shadows[1]};
`,di={loading:q.bool,authLoading:q.bool,disconnectLoading:q.bool,connecting:q.bool},cr=lr(ur)`
  color: ${({theme:s})=>s.palette.text.primary};
  font-weight: 500;
  border-color: ${({theme:s})=>s.palette.grey[300]};
  line-height: 1.5;
  &:hover {
    background-color: ${({theme:s})=>At(s.palette.primary.main,.1)};
  }
`;function dt({loading:s=!1,user:h=null,switchUser:p=fr,connecting:l=!1,url:C=""}){const{t:v}=K.useContext(ye);return!h&&!s?null:c.jsx($e,{children:s?c.jsxs(W,{sx:{display:"flex",justifyContent:"center",alignItems:"flex-start",gap:2,height:"100%"},children:[c.jsx(ce,{variant:"circular",width:48,height:48}),c.jsxs(W,{sx:{display:"flex",flexDirection:"column",gap:1,width:"100%"},children:[c.jsx(ce,{variant:"rounded",sx:{width:"80%",height:20}}),c.jsx(ce,{variant:"rounded",sx:{width:"40%",height:20}}),c.jsx(ce,{variant:"rounded",sx:{width:"30%",height:20}}),c.jsx(ce,{variant:"rounded",sx:{width:"60%",height:20}})]})]}):c.jsxs(W,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"flex-start",height:"100%"},children:[c.jsx(Zt,{size:"large",showDid:!0,showHoverCard:!0,user:h,avatarProps:{size:48},infoType:xr.Minimal,popupInfoType:xr.Basic,sx:{border:"none",p:0},onAvatarClick:()=>{C&&window.open(it(le(C,dr.WELLKNOWN_BLOCKLET_USER_PATH),{did:h.did}),"_blank")}}),c.jsx(W,{children:c.jsx(cr,{variant:"outlined",disabled:l,startIcon:l?c.jsx(ge,{size:16,sx:{mr:1}}):c.jsx(He,{style:{fontSize:16},icon:"tabler:switch-horizontal"}),onClick:p,children:v("setting.aigne.switchUser")})})]})})}dt.propTypes={loading:q.bool,user:q.object,switchUser:q.func,url:q.string,...di};function ft({loading:s=!1,credit:h=null,connecting:p=!1,onRefresh:l=()=>{},refreshing:C=!1}){const{t:v}=K.useContext(ye),g=Qr`
    from {
      transform: rotate(0deg);
    }
    to {
      transform: rotate(360deg);
    }
  `,d=K.useMemo(()=>!h?.enableCredit,[h]),a=K.useMemo(()=>Number(h?.creditBalance?.balance)<=0&&Number(h?.creditBalance?.pendingCredit)>0,[h]);if(!h&&!s)return null;const{creditBalance:t,profileLink:m="",paymentLink:w=""}=h||{};return c.jsx($e,{children:s?c.jsxs(W,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"flex-start",gap:2,height:"100%"},children:[c.jsxs(W,{sx:{width:"100%",display:"flex",flexDirection:"column",gap:1},children:[c.jsx(ce,{variant:"rounded",sx:{width:"80%",height:20}}),c.jsx(ce,{variant:"rounded",sx:{width:"50%",height:20}})]}),c.jsxs(W,{sx:{width:"100%",display:"flex",justifyContent:"space-between",gap:1},children:[c.jsx(ce,{variant:"rounded",sx:{width:"100%",height:20}}),c.jsx(ce,{variant:"rounded",sx:{width:"100%",height:20}})]})]}):c.jsxs(W,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"flex-start",height:"100%",width:"100%"},children:[c.jsxs(W,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[c.jsx(ue,{variant:"body1",children:"AIGNE Hub Credits"}),c.jsxs(ue,{variant:"h2",sx:{color:!d&&a?"error.main":"text.primary"},children:[c.jsx("span",{children:d?v("setting.aigne.infinite"):a?`- ${Jr(t?.pendingCredit)}`:Jr(t.balance)}),d?null:c.jsx(me,{title:v("common.refresh"),children:c.jsx(It,{sx:{fontSize:14,ml:1,cursor:"pointer",animation:C?`${g} 1s linear infinite`:"none"},onClick:l})})]})]}),d?null:c.jsxs(W,{sx:{width:"100%",display:"flex",gap:1},children:[c.jsx(cr,{fullWidth:!0,variant:"outlined",disabled:p,onClick:()=>{w&&window.open(w,"_blank")},startIcon:c.jsx(He,{style:{fontSize:16},icon:"tabler:credit-card"}),children:v("setting.aigne.addCredits")}),c.jsx(cr,{fullWidth:!0,disabled:p,onClick:()=>{m&&window.open(it(m,{appDid:window.blocklet.appPid}),"_blank")},variant:"outlined",startIcon:c.jsx(He,{style:{fontSize:16},icon:"hugeicons:transaction"}),children:v("setting.aigne.transaction")})]})]})})}ft.propTypes={loading:q.bool,credit:q.object,connecting:q.bool,onRefresh:q.func,refreshing:q.bool};function pt({url:s,apiKey:h,switchUser:p=fr,connecting:l=!1}){const{t:C}=K.useContext(ye),[v,g]=K.useState(!1),{data:d,loading:a,error:t,refresh:m}=Nt(()=>ui({baseUrl:s,accessKey:h}),{ready:!!(s&&h),refreshDeps:[s,h],onSuccess:()=>{g(!1)},onError:()=>{g(!1)}}),w=K.useCallback(()=>{a||v||(g(!0),m())},[m,a,v]);return t?null:c.jsxs(W,{children:[c.jsx(ue,{variant:"h5",sx:{fontSize:18,mb:2},children:C("setting.aigne.account")}),c.jsxs(be,{container:!0,className:"config-container",spacing:2,sx:{width:"100%"},children:[c.jsx(be,{size:{xs:12,md:6},children:c.jsx(dt,{loading:a&&!v,user:d?.user,switchUser:p,connecting:l,url:s})}),c.jsx(be,{size:{xs:12,md:6},children:c.jsx(ft,{refreshing:v,loading:a&&!v,credit:d,connecting:l,onRefresh:w})})]})]})}pt.propTypes={url:q.string.isRequired,apiKey:q.string.isRequired,connecting:q.bool,switchUser:q.func};function ht({url:s,providerName:h,disconnect:p=fr,disabled:l=!1,loading:C=!1,validationResult:v=""}){const{t:g}=K.useContext(ye),d=K.useMemo(()=>v&&v!=="success",[v]);return c.jsx($e,{minHeight:80,height:"none",children:c.jsxs(W,{sx:{width:"100%",height:"100%",display:"flex",justifyContent:"flex-start",alignItems:"center",gap:2},children:[d?c.jsx(me,{title:v,children:c.jsx(Xr,{sx:{fontSize:24,color:"error.main",cursor:"pointer",flexShrink:0}})}):c.jsx(et,{sx:{fontSize:24,color:"success.main",cursor:"pointer",flexShrink:0}}),c.jsxs(W,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1,flex:1,flexWrap:"wrap"},children:[c.jsxs(W,{children:[c.jsx(ue,{variant:"h5",sx:{fontSize:18},children:d?g("setting.aigne.testFailed"):g("setting.aigne.connected",{provider:h})}),c.jsxs(ue,{variant:"body1",sx:{color:"text.secondary",fontSize:14},children:[g("setting.aigne.baseUrl",{provider:h}),": ",s]})]}),c.jsx(ur,{variant:"outlined",color:"error",startIcon:C?c.jsx(ge,{size:16,sx:{mr:1}}):c.jsx(Ot,{}),onClick:p,disabled:l||C,sx:{lineHeight:1.5},children:g("setting.aigne.disconnect")})]})]})})}ht.propTypes={url:q.string.isRequired,providerName:q.string.isRequired,disabled:q.bool,disconnect:q.func,loading:q.bool,validationResult:q.string};function ve({desc:s,docLink:h=null,provider:p="",orientation:l="vertical"}){const{t:C}=K.useContext(ye);return c.jsxs(ue,{variant:"body2",sx:{lineHeight:1.6,color:"text.secondary",fontSize:12,...l==="vertical"&&{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},title:s,children:[s,h&&c.jsx(me,{title:c.jsxs(c.Fragment,{children:[C("setting.aigne.desc.docLink"),h&&c.jsxs(c.Fragment,{children:[":"," ",c.jsx(Ft,{href:h,target:"_blank",rel:"noopener noreferrer",sx:{ml:.5},children:p||"documentation"})]})]}),arrow:!0,children:c.jsx(Lt,{fontSize:"small",sx:{ml:.25,fontSize:14,cursor:"pointer",verticalAlign:"middle"}})})]})}const ar={provider:"",model:"",url:"",key:"",accessKeyId:"",testConnection:""};ve.propTypes={desc:q.string.isRequired,docLink:q.string,provider:q.string,orientation:q.oneOf(["vertical","horizontal"])};function vt({orientation:s="vertical",hideDivider:h=!1,source:p="dashboard",forceValidate:l=!1},C){const[v,g]=K.useState(!1),[d,a]=K.useState(!1),[t,m]=K.useState(!1),[w,x]=K.useState(!1),{t:i}=K.useContext(ye),k=Jt(),{api:j}=k,{did:y,blocklet:O,actions:n}=Qt(),[r,f]=K.useState(!1),_=yr({...ar}),A=yr({loading:!1,success:!1}),{confirmApi:T,confirmHolder:L}=Xt(),N=K.useMemo(()=>`connect-aigne-${y}`,[y]),u=ci(k),b=sn({messageType:"connect-aigne-message",onOpen:()=>g(!0),onClose:()=>g(!1)}),B=K.useMemo(()=>v||d||t||A.loading,[v,d,t,A.loading]),S=de(I=>u.find($=>$.provider===I)),z=de(I=>S(I)?.models||[]);qt(()=>{N&&on(N)});const F=de(I=>{if(I)return I;const $=u[0]?.provider;return z($)[0]?.name||"auto"}),U=de(()=>{Object.keys(ar).forEach(I=>{_[I]=ar[I]})}),G=Ce(()=>{const{aigne:I={}}=O?.settings||{};return I},[O]),Y=Ce(()=>{const I={...G},$=I?.provider||u[0]?.provider,Z=S($),ie=we($),vr=Ne($);return{...I,url:_r.getOriginUrl(I?.url||ie&&Z?.baseURL||""),provider:$,model:F(I?.model),key:or(I?.key,y),accessKeyId:vr?or(I?.accessKeyId,y):I?.accessKeyId,secretAccessKey:vr?or(I?.secretAccessKey,y):I?.secretAccessKey}},[O,S,F]),[R,Q]=K.useState(Y);K.useEffect(()=>{Q(Y)},[Y]);const P=K.useMemo(()=>R?.url&&R?.key&&R?.provider==="aigneHub",[R]),E=Ce(()=>S(R.provider)?.name||R.provider,[R,S]),e=K.useMemo(()=>ai(R),[R]),o=Ce(()=>S(R.provider)?.documentation||"",[R,S]),D=async()=>{try{g(!0);const I=new Set(["running","error"]),$=O.children.filter(Z=>I.has(Z.status)||I.has(Z.greenStatus)).map(Z=>Z.meta.did);await j.restartBlocklet({input:{did:y,componentDids:$}}),n.refreshBlocklet()}catch(I){console.error("error",I),ae.error(he(I))}finally{g(!1)}},H=(I=!0)=>{if(p!=="setup")return new Promise($=>{T.open({title:i("setting.aigne.restart.title"),content:I?i("setting.aigne.restart.connectedContent",{provider:E}):i("setting.aigne.restart.notConnectedContent",{provider:E}),confirmButtonText:i("setting.aigne.restart.confirm"),cancelButtonText:i("setting.aigne.restart.cancel"),onConfirm(Z){Z(),D(),$(!0)},onCancel(){$(!1)}})})},V=de(()=>new Promise(I=>{T.open({title:i("setting.aigne.revokeUrlAuthTitle",{url:i("setting.aigne.baseUrl",{provider:E})}),content:i("setting.aigne.revokeUrlAuth",{url:i("setting.aigne.baseUrl",{provider:E})}),confirmButtonText:i("common.confirm"),cancelButtonText:i("common.cancel"),onConfirm($){$(),I(!0)},onCancel(){I(!1)}})})),M=async(I,$)=>{const Z={};if(Q({...R,[I]:$}),I==="provider"){const ie=z($);ie.length>0&&(Z.model=ie[0].name),Z.key=""}return P&&I==="url"&&$!==R.url&&(await V()?(Z.key="",Z.validationResult=""):Z.url=R.url),setTimeout(()=>{Q({...R,[I]:$,...Z})},100),f(!0),!0},X=K.useMemo(()=>R.provider,[R.provider]),ee=de(I=>Ht(I)?"":i("setting.aigne.invalidUrl",{provider:E})),re=(I=[])=>{const $=e.filter(ie=>!I.includes(ie));if($.length)return $.forEach(ie=>{_[ie]="required"}),!$.includes("url")&&we(R.provider)&&(_.url=ee(R.url)),!1;const Z=we(R.provider)&&ee(R.url);return Z?(_.url=Z,!1):!0},xe=async()=>{try{m(!0),await j.disconnectToAigne({input:{did:y,url:R.url,key:R.key}}),f(!1),ae.success(i("setting.aigne.disconnectSuccess")),setTimeout(()=>{H(!1)},300)}catch(I){console.error("disconnect error:",I),ae.error(he(I)||i("setting.aigne.disconnectFailed"))}finally{m(!1)}},te=()=>{T.open({title:i("setting.aigne.disconnect"),content:i("setting.aigne.disconnectConfirm"),confirmButtonText:i("setting.aigne.disconnect"),cancelButtonText:i("common.cancel"),onConfirm(I){I(),xe()}})},ne=async()=>{if(!re())return;U();const I={...R,model:"auto",key:ir(R.key,y)};Ne(I.provider)?(I.key="",R.accessKeyId&&(I.accessKeyId=ir(R.accessKeyId,y)),R.secretAccessKey&&(I.secretAccessKey=ir(R.secretAccessKey,y))):(I.accessKeyId="",I.secretAccessKey="");const $=await j.updateBlockletSettings({input:{did:y,aigne:I}});return n.refreshBlocklet(),$},gt=async()=>{try{if(!r&&!l)return;g(!0);const I=await ne();return I?(f(!1),ae.success(i("common.saveSuccess")),I):void 0}catch(I){throw console.error("error",I),ae.error(he(I)||i("setting.aigne.failed")),I}finally{g(!1)}},pr=async(I=!1)=>{_.testConnection="";try{if(A.loading=!0,!I&&(await ne())?.code!=="ok")return;await j.verifyAigneConnection({input:{did:y}}),ae.success(i("setting.aigne.testSuccess",{provider:E})),A.success=!0}catch($){throw console.error("error",$),_.testConnection=$.message,ae.error(i("setting.aigne.testFailed")),$}finally{A.loading=!1,n.refreshBlocklet()}},mt=async()=>{try{await an(j,{did:y,refresh:n.refreshBlocklet,t:i,providerName:E,timerKey:N,values:{...G}}).catch(I=>{throw console.error("waitGetConnectedAigne error",I),ae.error(he(I)),I}).then(()=>pr(!0).catch(I=>{throw console.error("onVerifyConnection error",I),I})),H(!0)}catch(I){console.error("error",I)}finally{f(!1)}},hr=()=>{re(["key"])&&(U(),b(async(I,$)=>{try{a(!0);const Z=await j.connectToAigne({input:{did:y,baseUrl:_r.getOriginUrl(R.url||new URL(window.location.origin).origin),provider:R.provider,model:"auto"}});if(!Z?.url){ae.error("failed to connect to endpoint"),a(!1),g(!1);return}$(Z.url),await mt(),a(!1)}catch(Z){const ie=he(Z);ae.error(ie),a(!1)}}))};K.useImperativeHandle(C,()=>({onSubmit:gt,loading:v||d||t})),z(X);const yt=X==="aigneHub",xt=()=>{x(!w)},_t=I=>{I.preventDefault()},wt=K.useMemo(()=>_.url==="required"?i("common.requiredErrorText",{name:i("setting.aigne.baseUrl",{provider:E})}):_.url?_.url:_.key==="required"?i("setting.aigne.apiKeyNotAuthorized",{provider:E}):"",[_.url,_.key,i,E]);return c.jsxs(fi,{source:p,children:[c.jsx(ue,{variant:"h5",sx:{fontSize:18},children:i("setting.aigne.authorizeAigneHub",{name:E})}),P&&R.validationResult?c.jsx(ht,{url:R.url,providerName:E,disconnect:te,validationResult:R.validationResult,disabled:B,loading:t}):c.jsx($e,{height:"none",minHeight:"none",children:c.jsxs(W,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:2},children:[c.jsx(_e,{orientation:s,title:i("setting.aigne.baseUrl",{provider:E}),required:we(R.provider),desc:c.jsx(ve,{desc:i("setting.aigne.desc.baseUrl",{example:"https://hub.aigne.io"})}),children:c.jsx(Ee,{disabled:B,initialValue:R.url||"",directEditing:!0,onSubmit:I=>{M("url",I)},autoFocus:!1,errorTips:wt,InputProps:P?{endAdornment:c.jsx(mr,{position:"end",children:A.loading||d?c.jsx(ge,{size:16}):c.jsxs(c.Fragment,{children:[R.validationResult==="success"?c.jsx(me,{title:i("setting.aigne.testSuccess",{provider:E}),children:c.jsx(et,{sx:{fontSize:16,color:"success.main",cursor:"pointer"}})}):null,R.validationResult&&R.validationResult!=="success"?c.jsx(me,{title:R.validationResult,children:c.jsx(Xr,{sx:{fontSize:16,color:"error.main",cursor:"pointer"}})}):null,R.validationResult?null:c.jsx(qe,{"aria-label":"test connection",onClick:pr,edge:"end",children:A.loading?c.jsx(ge,{size:16}):c.jsx(me,{title:i("setting.aigne.testConnection",{provider:E}),children:c.jsx(He,{style:{fontSize:16},icon:"tabler:location-check"})})})]})})}:{}})}),c.jsx(ur,{variant:"contained",onClick:hr,startIcon:d?c.jsx(ge,{size:16,sx:{mr:1}}):c.jsx(Dt,{}),disabled:B||!R.url,sx:{flexShrink:0},children:i("setting.aigne.authorizeAigneHub",{name:"AIGNE Hub"})})]})}),c.jsxs(be,{container:!0,className:"config-container",spacing:2,sx:{display:"none"},children:[c.jsx(be,{size:{xs:12,md:4},children:c.jsx(_e,{orientation:s,title:i("setting.aigne.modelAdapter"),required:!0,desc:c.jsx(ve,{desc:i("setting.aigne.desc.modelAdapter")}),children:c.jsx(ot,{disabled:B,options:u,config:{multiple:!1,labelField:"name",valueField:"provider"},initialValue:R.provider,directEditing:!0,searchable:!1,helperText:_.provider==="required"?i("common.requiredErrorText",{name:i("setting.aigne.modelAdapter")}):_.provider,onChange:I=>M("provider",I)})})}),null,yt?null:c.jsx(c.Fragment,{children:Ne(R.provider)?c.jsxs(c.Fragment,{children:[c.jsx(_e,{orientation:s,title:"Access Key ID",required:!0,desc:c.jsx(ve,{desc:i("setting.aigne.desc.accessKeyId"),docLink:o,provider:E}),children:c.jsx(Ee,{disabled:B,initialValue:R.accessKeyId||"",type:w?"text":"password",onChange:I=>M("accessKeyId",I),directEditing:!0,autoFocus:!1})}),!h&&c.jsx(W,{className:"config-form",component:Tt,sx:{my:3}}),c.jsx(_e,{orientation:s,title:"Secret Access Key",required:!0,desc:c.jsx(ve,{desc:i("setting.aigne.desc.secretAccessKey"),docLink:o,provider:E}),children:c.jsx(Ee,{disabled:B,initialValue:R.secretAccessKey||"",type:w?"text":"password",onChange:I=>M("secretAccessKey",I),directEditing:!0,autoFocus:!1})})]}):c.jsx(_e,{orientation:s,title:"API Key",required:!0,desc:c.jsx(ve,{desc:i("setting.aigne.desc.key",{provider:E}),docLink:o,provider:E}),children:c.jsx(Ee,{disabled:B,initialValue:R.key||"",type:w?"text":"password",onChange:I=>M("key",I),directEditing:!0,autoFocus:!1,InputProps:{endAdornment:c.jsx(mr,{position:"end",children:c.jsx(qe,{"aria-label":"toggle password visibility",onClick:xt,onMouseDown:_t,edge:"end",children:w?c.jsx(zt,{}):c.jsx(Rt,{})})})}})})})]}),P&&R.validationResult==="success"?c.jsx(pt,{switchUser:hr,url:R.url||"",apiKey:R.key||"",connecting:d||t}):null,p!=="setup"&&c.jsxs(ue,{sx:{fontSize:12,color:"text.secondary",mt:3,fontStyle:"italic"},children:["* ",i("setting.aigne.description",{name:en.getDisplayName(O,!0)})]}),L]})}vt.propTypes={orientation:q.oneOf(["vertical","horizontal"]),hideDivider:q.bool,source:q.oneOf(["dashboard","setup"]),forceValidate:q.bool};const fi=lr.div`
  max-width: 920px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  .section-title {
    line-height: 1.2 !important;
    font-weight: ${({source:s})=>s==="setup"?"400":"500"};
    color: ${({theme:s,source:h})=>h==="setup"?s.palette.text.secondary:s.palette.text.primary};
    font-size: ${({source:s})=>s==="setup"?"14px":"16px"};
  }
  .section-left {
    width: 100%;
  }
  .form-item {
    margin-bottom: 0 !important;
    margin-top: 0 !important;
  }
`,pi=K.forwardRef(vt),Bi=Object.freeze(Object.defineProperty({__proto__:null,default:pi},Symbol.toStringTag,{value:"Module"}));export{pi as A,Bi as c,Ke as r};
