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