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