@samanhappy/mcphub 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -143,6 +143,6 @@ Please change the parent <Route path="${D}"> to <Route path="${D==="/"?"*":`${D}
143
143
  *
144
144
  * This source code is licensed under the ISC license.
145
145
  * See the LICENSE file in the root directory of this source tree.
146
- */const cv=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ds=ut("x",cv);function Fm(l){var s,r,o="";if(typeof l=="string"||typeof l=="number")o+=l;else if(typeof l=="object")if(Array.isArray(l)){var d=l.length;for(s=0;s<d;s++)l[s]&&(r=Fm(l[s]))&&(o&&(o+=" "),o+=r)}else for(r in l)l[r]&&(o&&(o+=" "),o+=r);return o}function dv(){for(var l,s,r=0,o="",d=arguments.length;r<d;r++)(l=arguments[r])&&(s=Fm(l))&&(o&&(o+=" "),o+=s);return o}const Gu="-",fv=l=>{const s=mv(l),{conflictingClassGroups:r,conflictingClassGroupModifiers:o}=l;return{getClassGroupId:m=>{const y=m.split(Gu);return y[0]===""&&y.length!==1&&y.shift(),Wm(y,s)||hv(m)},getConflictingClassGroupIds:(m,y)=>{const h=r[m]||[];return y&&o[m]?[...h,...o[m]]:h}}},Wm=(l,s)=>{var m;if(l.length===0)return s.classGroupId;const r=l[0],o=s.nextPart.get(r),d=o?Wm(l.slice(1),o):void 0;if(d)return d;if(s.validators.length===0)return;const f=l.join(Gu);return(m=s.validators.find(({validator:y})=>y(f)))==null?void 0:m.classGroupId},em=/^\[(.+)\]$/,hv=l=>{if(em.test(l)){const s=em.exec(l)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},mv=l=>{const{theme:s,classGroups:r}=l,o={nextPart:new Map,validators:[]};for(const d in r)Nu(r[d],o,d,s);return o},Nu=(l,s,r,o)=>{l.forEach(d=>{if(typeof d=="string"){const f=d===""?s:tm(s,d);f.classGroupId=r;return}if(typeof d=="function"){if(gv(d)){Nu(d(o),s,r,o);return}s.validators.push({validator:d,classGroupId:r});return}Object.entries(d).forEach(([f,m])=>{Nu(m,tm(s,f),r,o)})})},tm=(l,s)=>{let r=l;return s.split(Gu).forEach(o=>{r.nextPart.has(o)||r.nextPart.set(o,{nextPart:new Map,validators:[]}),r=r.nextPart.get(o)}),r},gv=l=>l.isThemeGetter,pv=l=>{if(l<1)return{get:()=>{},set:()=>{}};let s=0,r=new Map,o=new Map;const d=(f,m)=>{r.set(f,m),s++,s>l&&(s=0,o=r,r=new Map)};return{get(f){let m=r.get(f);if(m!==void 0)return m;if((m=o.get(f))!==void 0)return d(f,m),m},set(f,m){r.has(f)?r.set(f,m):d(f,m)}}},ju="!",Eu=":",yv=Eu.length,xv=l=>{const{prefix:s,experimentalParseClassName:r}=l;let o=d=>{const f=[];let m=0,y=0,h=0,g;for(let N=0;N<d.length;N++){let C=d[N];if(m===0&&y===0){if(C===Eu){f.push(d.slice(h,N)),h=N+yv;continue}if(C==="/"){g=N;continue}}C==="["?m++:C==="]"?m--:C==="("?y++:C===")"&&y--}const v=f.length===0?d:d.substring(h),w=vv(v),b=w!==v,R=g&&g>h?g-h:void 0;return{modifiers:f,hasImportantModifier:b,baseClassName:w,maybePostfixModifierPosition:R}};if(s){const d=s+Eu,f=o;o=m=>m.startsWith(d)?f(m.substring(d.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:m,maybePostfixModifierPosition:void 0}}if(r){const d=o;o=f=>r({className:f,parseClassName:d})}return o},vv=l=>l.endsWith(ju)?l.substring(0,l.length-1):l.startsWith(ju)?l.substring(1):l,bv=l=>{const s=Object.fromEntries(l.orderSensitiveModifiers.map(o=>[o,!0]));return o=>{if(o.length<=1)return o;const d=[];let f=[];return o.forEach(m=>{m[0]==="["||s[m]?(d.push(...f.sort(),m),f=[]):f.push(m)}),d.push(...f.sort()),d}},Sv=l=>({cache:pv(l.cacheSize),parseClassName:xv(l),sortModifiers:bv(l),...fv(l)}),wv=/\s+/,Nv=(l,s)=>{const{parseClassName:r,getClassGroupId:o,getConflictingClassGroupIds:d,sortModifiers:f}=s,m=[],y=l.trim().split(wv);let h="";for(let g=y.length-1;g>=0;g-=1){const v=y[g],{isExternal:w,modifiers:b,hasImportantModifier:R,baseClassName:N,maybePostfixModifierPosition:C}=r(v);if(w){h=v+(h.length>0?" "+h:h);continue}let A=!!C,z=o(A?N.substring(0,C):N);if(!z){if(!A){h=v+(h.length>0?" "+h:h);continue}if(z=o(N),!z){h=v+(h.length>0?" "+h:h);continue}A=!1}const T=f(b).join(":"),D=R?T+ju:T,q=D+z;if(m.includes(q))continue;m.push(q);const Y=d(z,A);for(let W=0;W<Y.length;++W){const H=Y[W];m.push(D+H)}h=v+(h.length>0?" "+h:h)}return h};function jv(){let l=0,s,r,o="";for(;l<arguments.length;)(s=arguments[l++])&&(r=Im(s))&&(o&&(o+=" "),o+=r);return o}const Im=l=>{if(typeof l=="string")return l;let s,r="";for(let o=0;o<l.length;o++)l[o]&&(s=Im(l[o]))&&(r&&(r+=" "),r+=s);return r};function Ev(l,...s){let r,o,d,f=m;function m(h){const g=s.reduce((v,w)=>w(v),l());return r=Sv(g),o=r.cache.get,d=r.cache.set,f=y,y(h)}function y(h){const g=o(h);if(g)return g;const v=Nv(h,r);return d(h,v),v}return function(){return f(jv.apply(null,arguments))}}const Pe=l=>{const s=r=>r[l]||[];return s.isThemeGetter=!0,s},eg=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,tg=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Cv=/^\d+\/\d+$/,kv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Av=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Tv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Rv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ov=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Pn=l=>Cv.test(l),Se=l=>!!l&&!Number.isNaN(Number(l)),Ga=l=>!!l&&Number.isInteger(Number(l)),pu=l=>l.endsWith("%")&&Se(l.slice(0,-1)),ha=l=>kv.test(l),Mv=()=>!0,zv=l=>Av.test(l)&&!Tv.test(l),ag=()=>!1,Dv=l=>Rv.test(l),Uv=l=>Ov.test(l),Lv=l=>!le(l)&&!se(l),_v=l=>nl(l,sg,ag),le=l=>eg.test(l),rn=l=>nl(l,rg,zv),yu=l=>nl(l,Vv,Se),am=l=>nl(l,ng,ag),Hv=l=>nl(l,lg,Uv),zr=l=>nl(l,ig,Dv),se=l=>tg.test(l),is=l=>ll(l,rg),Bv=l=>ll(l,Yv),nm=l=>ll(l,ng),Gv=l=>ll(l,sg),qv=l=>ll(l,lg),Dr=l=>ll(l,ig,!0),nl=(l,s,r)=>{const o=eg.exec(l);return o?o[1]?s(o[1]):r(o[2]):!1},ll=(l,s,r=!1)=>{const o=tg.exec(l);return o?o[1]?s(o[1]):r:!1},ng=l=>l==="position"||l==="percentage",lg=l=>l==="image"||l==="url",sg=l=>l==="length"||l==="size"||l==="bg-size",rg=l=>l==="length",Vv=l=>l==="number",Yv=l=>l==="family-name",ig=l=>l==="shadow",Kv=()=>{const l=Pe("color"),s=Pe("font"),r=Pe("text"),o=Pe("font-weight"),d=Pe("tracking"),f=Pe("leading"),m=Pe("breakpoint"),y=Pe("container"),h=Pe("spacing"),g=Pe("radius"),v=Pe("shadow"),w=Pe("inset-shadow"),b=Pe("text-shadow"),R=Pe("drop-shadow"),N=Pe("blur"),C=Pe("perspective"),A=Pe("aspect"),z=Pe("ease"),T=Pe("animate"),D=()=>["auto","avoid","all","avoid-page","page","left","right","column"],q=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],Y=()=>[...q(),se,le],W=()=>["auto","hidden","clip","visible","scroll"],H=()=>["auto","contain","none"],O=()=>[se,le,h],J=()=>[Pn,"full","auto",...O()],re=()=>[Ga,"none","subgrid",se,le],de=()=>["auto",{span:["full",Ga,se,le]},Ga,se,le],me=()=>[Ga,"auto",se,le],ke=()=>["auto","min","max","fr",se,le],oe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],xe=()=>["start","end","center","stretch","center-safe","end-safe"],G=()=>["auto",...O()],V=()=>[Pn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...O()],$=()=>[l,se,le],ue=()=>[...q(),nm,am,{position:[se,le]}],E=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Q=()=>["auto","cover","contain",Gv,_v,{size:[se,le]}],ee=()=>[pu,is,rn],Z=()=>["","none","full",g,se,le],te=()=>["",Se,is,rn],ve=()=>["solid","dashed","dotted","double"],F=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],I=()=>[Se,pu,nm,am],ae=()=>["","none",N,se,le],ce=()=>["none",Se,se,le],et=()=>["none",Se,se,le],ct=()=>[Se,se,le],pt=()=>[Pn,"full",...O()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ha],breakpoint:[ha],color:[Mv],container:[ha],"drop-shadow":[ha],ease:["in","out","in-out"],font:[Lv],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ha],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ha],shadow:[ha],spacing:["px",Se],text:[ha],"text-shadow":[ha],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Pn,le,se,A]}],container:["container"],columns:[{columns:[Se,le,se,y]}],"break-after":[{"break-after":D()}],"break-before":[{"break-before":D()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:Y()}],overflow:[{overflow:W()}],"overflow-x":[{"overflow-x":W()}],"overflow-y":[{"overflow-y":W()}],overscroll:[{overscroll:H()}],"overscroll-x":[{"overscroll-x":H()}],"overscroll-y":[{"overscroll-y":H()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:J()}],"inset-x":[{"inset-x":J()}],"inset-y":[{"inset-y":J()}],start:[{start:J()}],end:[{end:J()}],top:[{top:J()}],right:[{right:J()}],bottom:[{bottom:J()}],left:[{left:J()}],visibility:["visible","invisible","collapse"],z:[{z:[Ga,"auto",se,le]}],basis:[{basis:[Pn,"full","auto",y,...O()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Se,Pn,"auto","initial","none",le]}],grow:[{grow:["",Se,se,le]}],shrink:[{shrink:["",Se,se,le]}],order:[{order:[Ga,"first","last","none",se,le]}],"grid-cols":[{"grid-cols":re()}],"col-start-end":[{col:de()}],"col-start":[{"col-start":me()}],"col-end":[{"col-end":me()}],"grid-rows":[{"grid-rows":re()}],"row-start-end":[{row:de()}],"row-start":[{"row-start":me()}],"row-end":[{"row-end":me()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ke()}],"auto-rows":[{"auto-rows":ke()}],gap:[{gap:O()}],"gap-x":[{"gap-x":O()}],"gap-y":[{"gap-y":O()}],"justify-content":[{justify:[...oe(),"normal"]}],"justify-items":[{"justify-items":[...xe(),"normal"]}],"justify-self":[{"justify-self":["auto",...xe()]}],"align-content":[{content:["normal",...oe()]}],"align-items":[{items:[...xe(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...xe(),{baseline:["","last"]}]}],"place-content":[{"place-content":oe()}],"place-items":[{"place-items":[...xe(),"baseline"]}],"place-self":[{"place-self":["auto",...xe()]}],p:[{p:O()}],px:[{px:O()}],py:[{py:O()}],ps:[{ps:O()}],pe:[{pe:O()}],pt:[{pt:O()}],pr:[{pr:O()}],pb:[{pb:O()}],pl:[{pl:O()}],m:[{m:G()}],mx:[{mx:G()}],my:[{my:G()}],ms:[{ms:G()}],me:[{me:G()}],mt:[{mt:G()}],mr:[{mr:G()}],mb:[{mb:G()}],ml:[{ml:G()}],"space-x":[{"space-x":O()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":O()}],"space-y-reverse":["space-y-reverse"],size:[{size:V()}],w:[{w:[y,"screen",...V()]}],"min-w":[{"min-w":[y,"screen","none",...V()]}],"max-w":[{"max-w":[y,"screen","none","prose",{screen:[m]},...V()]}],h:[{h:["screen","lh",...V()]}],"min-h":[{"min-h":["screen","lh","none",...V()]}],"max-h":[{"max-h":["screen","lh",...V()]}],"font-size":[{text:["base",r,is,rn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,se,yu]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",pu,le]}],"font-family":[{font:[Bv,le,s]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[d,se,le]}],"line-clamp":[{"line-clamp":[Se,"none",se,yu]}],leading:[{leading:[f,...O()]}],"list-image":[{"list-image":["none",se,le]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",se,le]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:$()}],"text-color":[{text:$()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ve(),"wavy"]}],"text-decoration-thickness":[{decoration:[Se,"from-font","auto",se,rn]}],"text-decoration-color":[{decoration:$()}],"underline-offset":[{"underline-offset":[Se,"auto",se,le]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",se,le]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",se,le]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ue()}],"bg-repeat":[{bg:E()}],"bg-size":[{bg:Q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ga,se,le],radial:["",se,le],conic:[Ga,se,le]},qv,Hv]}],"bg-color":[{bg:$()}],"gradient-from-pos":[{from:ee()}],"gradient-via-pos":[{via:ee()}],"gradient-to-pos":[{to:ee()}],"gradient-from":[{from:$()}],"gradient-via":[{via:$()}],"gradient-to":[{to:$()}],rounded:[{rounded:Z()}],"rounded-s":[{"rounded-s":Z()}],"rounded-e":[{"rounded-e":Z()}],"rounded-t":[{"rounded-t":Z()}],"rounded-r":[{"rounded-r":Z()}],"rounded-b":[{"rounded-b":Z()}],"rounded-l":[{"rounded-l":Z()}],"rounded-ss":[{"rounded-ss":Z()}],"rounded-se":[{"rounded-se":Z()}],"rounded-ee":[{"rounded-ee":Z()}],"rounded-es":[{"rounded-es":Z()}],"rounded-tl":[{"rounded-tl":Z()}],"rounded-tr":[{"rounded-tr":Z()}],"rounded-br":[{"rounded-br":Z()}],"rounded-bl":[{"rounded-bl":Z()}],"border-w":[{border:te()}],"border-w-x":[{"border-x":te()}],"border-w-y":[{"border-y":te()}],"border-w-s":[{"border-s":te()}],"border-w-e":[{"border-e":te()}],"border-w-t":[{"border-t":te()}],"border-w-r":[{"border-r":te()}],"border-w-b":[{"border-b":te()}],"border-w-l":[{"border-l":te()}],"divide-x":[{"divide-x":te()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":te()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ve(),"hidden","none"]}],"divide-style":[{divide:[...ve(),"hidden","none"]}],"border-color":[{border:$()}],"border-color-x":[{"border-x":$()}],"border-color-y":[{"border-y":$()}],"border-color-s":[{"border-s":$()}],"border-color-e":[{"border-e":$()}],"border-color-t":[{"border-t":$()}],"border-color-r":[{"border-r":$()}],"border-color-b":[{"border-b":$()}],"border-color-l":[{"border-l":$()}],"divide-color":[{divide:$()}],"outline-style":[{outline:[...ve(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Se,se,le]}],"outline-w":[{outline:["",Se,is,rn]}],"outline-color":[{outline:$()}],shadow:[{shadow:["","none",v,Dr,zr]}],"shadow-color":[{shadow:$()}],"inset-shadow":[{"inset-shadow":["none",w,Dr,zr]}],"inset-shadow-color":[{"inset-shadow":$()}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:$()}],"ring-offset-w":[{"ring-offset":[Se,rn]}],"ring-offset-color":[{"ring-offset":$()}],"inset-ring-w":[{"inset-ring":te()}],"inset-ring-color":[{"inset-ring":$()}],"text-shadow":[{"text-shadow":["none",b,Dr,zr]}],"text-shadow-color":[{"text-shadow":$()}],opacity:[{opacity:[Se,se,le]}],"mix-blend":[{"mix-blend":[...F(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":F()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Se]}],"mask-image-linear-from-pos":[{"mask-linear-from":I()}],"mask-image-linear-to-pos":[{"mask-linear-to":I()}],"mask-image-linear-from-color":[{"mask-linear-from":$()}],"mask-image-linear-to-color":[{"mask-linear-to":$()}],"mask-image-t-from-pos":[{"mask-t-from":I()}],"mask-image-t-to-pos":[{"mask-t-to":I()}],"mask-image-t-from-color":[{"mask-t-from":$()}],"mask-image-t-to-color":[{"mask-t-to":$()}],"mask-image-r-from-pos":[{"mask-r-from":I()}],"mask-image-r-to-pos":[{"mask-r-to":I()}],"mask-image-r-from-color":[{"mask-r-from":$()}],"mask-image-r-to-color":[{"mask-r-to":$()}],"mask-image-b-from-pos":[{"mask-b-from":I()}],"mask-image-b-to-pos":[{"mask-b-to":I()}],"mask-image-b-from-color":[{"mask-b-from":$()}],"mask-image-b-to-color":[{"mask-b-to":$()}],"mask-image-l-from-pos":[{"mask-l-from":I()}],"mask-image-l-to-pos":[{"mask-l-to":I()}],"mask-image-l-from-color":[{"mask-l-from":$()}],"mask-image-l-to-color":[{"mask-l-to":$()}],"mask-image-x-from-pos":[{"mask-x-from":I()}],"mask-image-x-to-pos":[{"mask-x-to":I()}],"mask-image-x-from-color":[{"mask-x-from":$()}],"mask-image-x-to-color":[{"mask-x-to":$()}],"mask-image-y-from-pos":[{"mask-y-from":I()}],"mask-image-y-to-pos":[{"mask-y-to":I()}],"mask-image-y-from-color":[{"mask-y-from":$()}],"mask-image-y-to-color":[{"mask-y-to":$()}],"mask-image-radial":[{"mask-radial":[se,le]}],"mask-image-radial-from-pos":[{"mask-radial-from":I()}],"mask-image-radial-to-pos":[{"mask-radial-to":I()}],"mask-image-radial-from-color":[{"mask-radial-from":$()}],"mask-image-radial-to-color":[{"mask-radial-to":$()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":q()}],"mask-image-conic-pos":[{"mask-conic":[Se]}],"mask-image-conic-from-pos":[{"mask-conic-from":I()}],"mask-image-conic-to-pos":[{"mask-conic-to":I()}],"mask-image-conic-from-color":[{"mask-conic-from":$()}],"mask-image-conic-to-color":[{"mask-conic-to":$()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ue()}],"mask-repeat":[{mask:E()}],"mask-size":[{mask:Q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",se,le]}],filter:[{filter:["","none",se,le]}],blur:[{blur:ae()}],brightness:[{brightness:[Se,se,le]}],contrast:[{contrast:[Se,se,le]}],"drop-shadow":[{"drop-shadow":["","none",R,Dr,zr]}],"drop-shadow-color":[{"drop-shadow":$()}],grayscale:[{grayscale:["",Se,se,le]}],"hue-rotate":[{"hue-rotate":[Se,se,le]}],invert:[{invert:["",Se,se,le]}],saturate:[{saturate:[Se,se,le]}],sepia:[{sepia:["",Se,se,le]}],"backdrop-filter":[{"backdrop-filter":["","none",se,le]}],"backdrop-blur":[{"backdrop-blur":ae()}],"backdrop-brightness":[{"backdrop-brightness":[Se,se,le]}],"backdrop-contrast":[{"backdrop-contrast":[Se,se,le]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Se,se,le]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Se,se,le]}],"backdrop-invert":[{"backdrop-invert":["",Se,se,le]}],"backdrop-opacity":[{"backdrop-opacity":[Se,se,le]}],"backdrop-saturate":[{"backdrop-saturate":[Se,se,le]}],"backdrop-sepia":[{"backdrop-sepia":["",Se,se,le]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":O()}],"border-spacing-x":[{"border-spacing-x":O()}],"border-spacing-y":[{"border-spacing-y":O()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",se,le]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Se,"initial",se,le]}],ease:[{ease:["linear","initial",z,se,le]}],delay:[{delay:[Se,se,le]}],animate:[{animate:["none",T,se,le]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[C,se,le]}],"perspective-origin":[{"perspective-origin":Y()}],rotate:[{rotate:ce()}],"rotate-x":[{"rotate-x":ce()}],"rotate-y":[{"rotate-y":ce()}],"rotate-z":[{"rotate-z":ce()}],scale:[{scale:et()}],"scale-x":[{"scale-x":et()}],"scale-y":[{"scale-y":et()}],"scale-z":[{"scale-z":et()}],"scale-3d":["scale-3d"],skew:[{skew:ct()}],"skew-x":[{"skew-x":ct()}],"skew-y":[{"skew-y":ct()}],transform:[{transform:[se,le,"","none","gpu","cpu"]}],"transform-origin":[{origin:Y()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:pt()}],"translate-x":[{"translate-x":pt()}],"translate-y":[{"translate-y":pt()}],"translate-z":[{"translate-z":pt()}],"translate-none":["translate-none"],accent:[{accent:$()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:$()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",se,le]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",se,le]}],fill:[{fill:["none",...$()]}],"stroke-w":[{stroke:[Se,is,rn,yu]}],stroke:[{stroke:["none",...$()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},$v=Ev(Kv);function qa(...l){return $v(dv(l))}const Qv=({message:l,type:s="info",duration:r=3e3,onClose:o,visible:d})=>{S.useEffect(()=>{if(d){const h=setTimeout(()=>{o()},r);return()=>clearTimeout(h)}},[d,r,o]);const f={success:c.jsx(Bu,{className:"w-5 h-5 text-green-500"}),error:c.jsx(ds,{className:"w-5 h-5 text-red-500"}),info:c.jsx("svg",{className:"w-5 h-5 text-blue-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),warning:c.jsx("svg",{className:"w-5 h-5 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})},m={success:"bg-green-50 border-green-200",error:"bg-red-50 border-red-200",info:"bg-blue-50 border-blue-200",warning:"bg-yellow-50 border-yellow-200"},y={success:"text-green-800",error:"text-red-800",info:"text-blue-800",warning:"text-yellow-800"};return c.jsx("div",{className:qa("fixed top-4 right-4 z-50 max-w-sm p-4 rounded-md shadow-lg border",m[s],"transform transition-all duration-300 ease-in-out",d?"translate-x-0 opacity-100":"translate-x-full opacity-0"),children:c.jsxs("div",{className:"flex items-start",children:[c.jsx("div",{className:"flex-shrink-0",children:f[s]}),c.jsx("div",{className:"ml-3",children:c.jsx("p",{className:qa("text-sm font-medium",y[s]),children:l})}),c.jsx("div",{className:"ml-auto pl-3",children:c.jsx("div",{className:"-mx-1.5 -my-1.5",children:c.jsxs("button",{onClick:o,className:qa("inline-flex rounded-md p-1.5",`hover:bg-${s}-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-${s}-500`),children:[c.jsx("span",{className:"sr-only",children:"Dismiss"}),c.jsx(ds,{className:"h-5 w-5"})]})})})]})})},og=S.createContext(void 0),ps=()=>{const l=S.useContext(og);if(!l)throw new Error("useToast must be used within a ToastProvider");return l},Xv=({children:l})=>{const[s,r]=S.useState({message:"",type:"info",visible:!1,duration:3e3}),o=S.useCallback((f,m="info",y=3e3)=>{r({message:f,type:m,visible:!0,duration:y})},[]),d=S.useCallback(()=>{r(f=>({...f,visible:!1}))},[]);return c.jsxs(og.Provider,{value:{showToast:o},children:[l,c.jsx(Qv,{message:s.message,type:s.type,duration:s.duration,onClose:d,visible:s.visible})]})},ug=S.createContext(void 0),Zv=()=>{const l=S.useContext(ug);if(!l)throw new Error("useTheme must be used within a ThemeProvider");return l},Pv=({children:l})=>{const[s,r]=S.useState(()=>localStorage.getItem("theme")||"system"),[o,d]=S.useState("light"),f=m=>{r(m),localStorage.setItem("theme",m)};return S.useEffect(()=>{const m=()=>{const h=window.document.documentElement,g=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",v=s==="system"?g:s;d(v),v==="dark"?(console.log("Applying dark mode to HTML root element"),h.classList.add("dark"),document.body.style.backgroundColor="#111827"):(console.log("Removing dark mode from HTML root element"),h.classList.remove("dark"),document.body.style.backgroundColor="")},y=window.matchMedia("(prefers-color-scheme: dark)");return y.addEventListener("change",m),m(),()=>{y.removeEventListener("change",m)}},[s]),c.jsx(ug.Provider,{value:{theme:s,setTheme:f,resolvedTheme:o},children:l})},Jv=(l,s,r,o)=>{var f,m,y,h;const d=[r,{code:s,...o||{}}];if((m=(f=l==null?void 0:l.services)==null?void 0:f.logger)!=null&&m.forward)return l.services.logger.forward(d,"warn","react-i18next::",!0);on(d[0])&&(d[0]=`react-i18next:: ${d[0]}`),(h=(y=l==null?void 0:l.services)==null?void 0:y.logger)!=null&&h.warn?l.services.logger.warn(...d):console!=null&&console.warn&&console.warn(...d)},lm={},Cu=(l,s,r,o)=>{on(r)&&lm[r]||(on(r)&&(lm[r]=new Date),Jv(l,s,r,o))},cg=(l,s)=>()=>{if(l.isInitialized)s();else{const r=()=>{setTimeout(()=>{l.off("initialized",r)},0),s()};l.on("initialized",r)}},ku=(l,s,r)=>{l.loadNamespaces(s,cg(l,r))},sm=(l,s,r,o)=>{if(on(r)&&(r=[r]),l.options.preload&&l.options.preload.indexOf(s)>-1)return ku(l,r,o);r.forEach(d=>{l.options.ns.indexOf(d)<0&&l.options.ns.push(d)}),l.loadLanguages(s,cg(l,o))},Fv=(l,s,r={})=>!s.languages||!s.languages.length?(Cu(s,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:s.languages}),!0):s.hasLoadedNamespace(l,{lng:r.lng,precheck:(o,d)=>{var f;if(((f=r.bindI18n)==null?void 0:f.indexOf("languageChanging"))>-1&&o.services.backendConnector.backend&&o.isLanguageChangingTo&&!d(o.isLanguageChangingTo,l))return!1}}),on=l=>typeof l=="string",Wv=l=>typeof l=="object"&&l!==null,Iv=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,eb={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},tb=l=>eb[l],ab=l=>l.replace(Iv,tb);let Au={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:ab};const nb=(l={})=>{Au={...Au,...l}},lb=()=>Au;let dg;const sb=l=>{dg=l},rb=()=>dg,ib={type:"3rdParty",init(l){nb(l.options.react),sb(l)}},ob=S.createContext();class ub{constructor(){this.usedNamespaces={}}addUsedNamespaces(s){s.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const cb=(l,s)=>{const r=S.useRef();return S.useEffect(()=>{r.current=l},[l,s]),r.current},fg=(l,s,r,o)=>l.getFixedT(s,r,o),db=(l,s,r,o)=>S.useCallback(fg(l,s,r,o),[l,s,r,o]),Te=(l,s={})=>{var q,Y,W,H;const{i18n:r}=s,{i18n:o,defaultNS:d}=S.useContext(ob)||{},f=r||o||rb();if(f&&!f.reportNamespaces&&(f.reportNamespaces=new ub),!f){Cu(f,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const O=(re,de)=>on(de)?de:Wv(de)&&on(de.defaultValue)?de.defaultValue:Array.isArray(re)?re[re.length-1]:re,J=[O,{},!1];return J.t=O,J.i18n={},J.ready=!1,J}(q=f.options.react)!=null&&q.wait&&Cu(f,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const m={...lb(),...f.options.react,...s},{useSuspense:y,keyPrefix:h}=m;let g=d||((Y=f.options)==null?void 0:Y.defaultNS);g=on(g)?[g]:g||["translation"],(H=(W=f.reportNamespaces).addUsedNamespaces)==null||H.call(W,g);const v=(f.isInitialized||f.initializedStoreOnce)&&g.every(O=>Fv(O,f,m)),w=db(f,s.lng||null,m.nsMode==="fallback"?g:g[0],h),b=()=>w,R=()=>fg(f,s.lng||null,m.nsMode==="fallback"?g:g[0],h),[N,C]=S.useState(b);let A=g.join();s.lng&&(A=`${s.lng}${A}`);const z=cb(A),T=S.useRef(!0);S.useEffect(()=>{const{bindI18n:O,bindI18nStore:J}=m;T.current=!0,!v&&!y&&(s.lng?sm(f,s.lng,g,()=>{T.current&&C(R)}):ku(f,g,()=>{T.current&&C(R)})),v&&z&&z!==A&&T.current&&C(R);const re=()=>{T.current&&C(R)};return O&&(f==null||f.on(O,re)),J&&(f==null||f.store.on(J,re)),()=>{T.current=!1,f&&(O==null||O.split(" ").forEach(de=>f.off(de,re))),J&&f&&J.split(" ").forEach(de=>f.store.off(de,re))}},[f,A]),S.useEffect(()=>{T.current&&v&&C(b)},[f,h,v]);const D=[N,f,v];if(D.t=N,D.i18n=f,D.ready=v,v||!v&&!y)return D;throw new Promise(O=>{s.lng?sm(f,s.lng,g,()=>O()):ku(f,g,()=>O())})},hg=()=>{const{t:l}=Te(),{theme:s,setTheme:r}=Zv();return c.jsx("div",{className:"flex items-center space-x-2",children:c.jsxs("div",{className:"flex bg-gray-200 dark:bg-gray-700 rounded-lg p-1",children:[c.jsx("button",{onClick:()=>r("light"),className:`flex items-center justify-center rounded-md p-1.5 ${s==="light"?"bg-white text-yellow-600 shadow":"text-black dark:text-gray-300 hover:text-yellow-600 dark:hover:text-yellow-500"}`,title:l("theme.light"),"aria-label":l("theme.light"),children:c.jsx(sv,{size:18})}),c.jsx("button",{onClick:()=>r("dark"),className:`flex items-center justify-center rounded-md p-1.5 ${s==="dark"?"bg-gray-800 text-blue-400 shadow":"text-gray-600 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400"}`,title:l("theme.dark"),"aria-label":l("theme.dark"),children:c.jsx(Fx,{size:18})})]})})},fb=l=>c.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",...l,children:[c.jsx("title",{children:"GitHub"}),c.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})]}),hb=l=>c.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",...l,children:[c.jsx("title",{children:"Sponsor"}),c.jsx("path",{d:"M17.625 1.499c-2.32 0-4.354 1.203-5.625 3.03-1.271-1.827-3.305-3.03-5.625-3.03C3.129 1.499 0 4.253 0 8.249c0 4.275 3.068 7.847 5.828 10.227a33.14 33.14 0 0 0 5.616 3.876l.028.017.008.003-.001.003c.163.085.342.126.521.125.179.001.358-.041.521-.125l-.001-.003.008-.003.028-.017a33.14 33.14 0 0 0 5.616-3.876C20.932 16.096 24 12.524 24 8.249c0-3.996-3.129-6.75-6.375-6.75zm-.919 15.275a30.766 30.766 0 0 1-4.703 3.316l-.004-.002-.004.002a30.955 30.955 0 0 1-4.703-3.316c-2.677-2.307-5.047-5.298-5.047-8.523 0-2.754 2.121-4.5 4.125-4.5 2.06 0 3.914 1.479 4.544 3.684.143.495.596.797 1.086.796.49.001.943-.302 1.085-.796.63-2.205 2.484-3.684 4.544-3.684 2.004 0 4.125 1.746 4.125 4.5 0 3.225-2.37 6.216-5.048 8.523z"})]}),mb=l=>c.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",...l,children:[c.jsx("title",{children:"WeChat"}),c.jsx("path",{d:"M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 0 0 .167-.054l1.903-1.114a.864.864 0 0 1 .717-.098 10.16 10.16 0 0 0 2.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 3.882-1.98 5.853-1.838-.576-3.583-4.196-6.348-8.596-6.348zM5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178A1.17 1.17 0 0 1 4.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178 1.17 1.17 0 0 1-1.162-1.178c0-.651.52-1.18 1.162-1.18zm5.34 2.867c-1.797-.052-3.746.512-5.28 1.786-1.72 1.428-2.687 3.72-1.78 6.22.942 2.453 3.666 4.229 6.884 4.229.826 0 1.622-.12 2.361-.336a.722.722 0 0 1 .598.082l1.584.926a.272.272 0 0 0 .14.047c.134 0 .24-.111.24-.247 0-.06-.023-.12-.038-.177l-.327-1.233a.582.582 0 0 1-.023-.156.49.49 0 0 1 .201-.398C23.024 18.48 24 16.82 24 14.98c0-3.21-2.931-5.837-6.656-6.088V8.89c-.135-.01-.27-.027-.407-.03zm-2.53 3.274c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.97-.982zm4.844 0c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.969-.982z"})]}),gb=l=>c.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",...l,children:[c.jsx("title",{children:"Discord"}),c.jsx("path",{d:"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"})]}),pb=({open:l,onOpenChange:s})=>{const{i18n:r,t:o}=Te();return l?c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg max-w-md w-full",children:c.jsxs("div",{className:"p-6 relative",children:[c.jsx("button",{onClick:()=>s(!1),className:"absolute top-4 right-4 text-gray-400 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-400","aria-label":o("common.close"),children:c.jsx(ds,{className:"h-5 w-5"})}),c.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-4",children:o("sponsor.title")}),c.jsx("div",{className:"flex flex-col items-center justify-center py-4",children:r.language==="zh"?c.jsx("img",{src:"./assets/reward.png",alt:o("sponsor.rewardAlt"),className:"max-w-full h-auto",style:{maxHeight:"400px"}}):c.jsxs("div",{className:"text-center",children:[c.jsx("p",{className:"mb-4 text-gray-700 dark:text-gray-300",children:o("sponsor.supportMessage")}),c.jsx("a",{href:"https://ko-fi.com/samanhappy",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center bg-[#13C3FF] text-white px-4 py-2 rounded-md hover:bg-[#00A5E5] transition-colors",children:o("sponsor.supportButton")})]})})]})})}):null},yb=({open:l,onOpenChange:s})=>{const{t:r}=Te();return l?c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg max-w-md w-full",children:c.jsxs("div",{className:"p-6 relative",children:[c.jsx("button",{onClick:()=>s(!1),className:"absolute top-4 right-4 text-gray-400 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-400","aria-label":r("common.close"),children:c.jsx(ds,{className:"h-5 w-5"})}),c.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-4",children:r("wechat.title")}),c.jsxs("div",{className:"flex flex-col items-center justify-center py-4",children:[c.jsx("img",{src:"./assets/wexin.png",alt:r("wechat.qrCodeAlt"),className:"max-w-full h-auto",style:{maxHeight:"400px"}}),c.jsx("p",{className:"mt-4 text-center text-gray-700 dark:text-gray-300",children:r("wechat.scanMessage")})]})]})})}):null},xb=({onToggleSidebar:l})=>{const{t:s,i18n:r}=Te(),{auth:o}=Zr(),[d,f]=S.useState(!1),[m,y]=S.useState(!1);return c.jsxs("header",{className:"bg-white dark:bg-gray-800 shadow-sm z-10",children:[c.jsxs("div",{className:"flex justify-between items-center px-4 py-3",children:[c.jsxs("div",{className:"flex items-center",children:[c.jsx("button",{onClick:l,className:"p-2 rounded-md text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none","aria-label":s("app.toggleSidebar"),children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),c.jsx("h1",{className:"ml-4 text-xl font-bold text-gray-900 dark:text-white",children:s("app.title")})]}),c.jsxs("div",{className:"flex items-center space-x-4",children:[c.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"v0.7.0"}),c.jsx("a",{href:"https://github.com/samanhappy/mcphub",target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200","aria-label":"GitHub Repository",children:c.jsx(fb,{className:"h-5 w-5"})}),r.language==="zh"?c.jsx("button",{onClick:()=>y(!0),className:"text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 focus:outline-none","aria-label":s("wechat.label"),children:c.jsx(mb,{className:"h-5 w-5"})}):c.jsx("a",{href:"https://discord.gg/qMKNsn5Q",target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200","aria-label":s("discord.label"),children:c.jsx(gb,{className:"h-5 w-5"})}),c.jsx("button",{onClick:()=>f(!0),className:"text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 focus:outline-none","aria-label":s("sponsor.label"),children:c.jsx(hb,{className:"h-5 w-5"})}),c.jsx(hg,{})]})]}),c.jsx(pb,{open:d,onOpenChange:f}),c.jsx(yb,{open:m,onOpenChange:y})]})},vb="https://registry.npmjs.org",bb="@samanhappy/mcphub",mg=async()=>{try{const l=await fetch(`${vb}/${bb}/latest`);if(!l.ok)throw new Error(`Failed to fetch latest version: ${l.status}`);return(await l.json()).version||null}catch(l){return console.error("Error checking for latest version:",l),null}},gg=(l,s)=>{if(l==="dev")return-1;const r=l.split(".").map(Number),o=s.split(".").map(Number);for(let d=0;d<3;d++){const f=r[d]||0,m=o[d]||0;if(f>m)return-1;if(f<m)return 1}return 0},Sb=({isOpen:l,onClose:s,version:r})=>{const{t:o}=Te(),[d,f]=S.useState(!1),[m,y]=S.useState(""),[h,g]=S.useState(!1),v=async()=>{g(!0);try{const w=await mg();w&&(y(w),f(gg(r,w)>0))}catch(w){console.error("Failed to check for updates:",w)}finally{g(!1)}};return S.useEffect(()=>{l&&v()},[l,r]),l?c.jsx("div",{className:"fixed inset-0 bg-black/50 bg-opacity-30 z-50 flex items-center justify-center p-4",children:c.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg max-w-md w-full",children:c.jsxs("div",{className:"p-6 relative",children:[c.jsx("button",{onClick:s,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-400","aria-label":o("common.close"),children:c.jsx(ds,{className:"h-5 w-5"})}),c.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-4",children:o("about.title")}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("span",{className:"text-gray-700 dark:text-gray-300",children:[o("about.currentVersion"),":"]}),c.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:r})]}),d&&m&&c.jsx("div",{className:"bg-blue-50 dark:bg-blue-900 p-3 rounded",children:c.jsxs("div",{className:"flex items-start",children:[c.jsx("div",{className:"flex-shrink-0",children:c.jsx("svg",{className:"h-5 w-5 text-blue-600 dark:text-blue-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),c.jsxs("div",{className:"ml-3 flex-1 text-sm text-blue-700 dark:text-blue-300",children:[c.jsx("p",{children:o("about.newVersionAvailable",{version:m})}),c.jsx("p",{className:"mt-1",children:c.jsx("a",{href:"https://github.com/samanhappy/mcphub",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline",children:o("about.viewOnGitHub")})})]})]})}),c.jsxs("button",{onClick:v,disabled:h,className:`mt-4 inline-flex items-center px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm text-sm font-medium
147
- ${h?"text-gray-400 dark:text-gray-500 bg-gray-100 dark:bg-gray-800":"text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600"} focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500`,children:[c.jsx(Ix,{className:`h-4 w-4 mr-2 ${h?"animate-spin":""}`}),o(h?"about.checking":"about.checkForUpdates")]})]})]})})}):null},wb=({collapsed:l,version:s})=>{var A;const{t:r}=Te(),o=un(),{auth:d,logout:f}=Zr(),[m,y]=S.useState(!1),[h,g]=S.useState(!1),[v,w]=S.useState(!1),b=S.useRef(null);S.useEffect(()=>{(async()=>{try{const T=await mg();T&&g(gg(s,T)>0)}catch(T){console.error("Error checking for new version:",T)}})()},[s]),S.useEffect(()=>{const z=T=>{b.current&&!b.current.contains(T.target)&&y(!1)};return document.addEventListener("mousedown",z),()=>{document.removeEventListener("mousedown",z)}},[]);const R=()=>{o("/settings"),y(!1)},N=()=>{f(),o("/login")},C=()=>{w(!0),y(!1)};return c.jsxs("div",{ref:b,className:"relative",children:[c.jsxs("button",{onClick:()=>y(!m),className:`flex ${l?"justify-center":"items-center"} w-full p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors rounded-md ${m?"bg-gray-100 dark:bg-gray-700":""}`,children:[c.jsxs("div",{className:"flex-shrink-0 relative",children:[c.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-full border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-700",children:c.jsx(uv,{className:"h-4 w-4 text-gray-700 dark:text-gray-300"})}),h&&c.jsx("span",{className:"absolute -top-1 -right-1 block w-2 h-2 bg-red-500 rounded-full"})]}),!l&&c.jsx("div",{className:"ml-3 flex flex-col items-start",children:c.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:((A=d.user)==null?void 0:A.username)||r("auth.user")})})]}),m&&c.jsxs("div",{className:"absolute top-0 transform -translate-y-full left-0 w-48 bg-white dark:bg-gray-800 shadow-lg rounded-md py-1 z-50",children:[c.jsxs("button",{onClick:R,className:"flex items-center w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:[c.jsx(tv,{className:"h-4 w-4 mr-2"}),r("nav.settings")]}),c.jsxs("button",{onClick:C,className:"flex items-center w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 relative",children:[c.jsx(Xx,{className:"h-4 w-4 mr-2"}),r("about.title"),h&&c.jsx("span",{className:"absolute top-2 right-4 block w-2 h-2 bg-red-500 rounded-full"})]}),c.jsxs("button",{onClick:N,className:"flex items-center w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:[c.jsx(Px,{className:"h-4 w-4 mr-2"}),r("app.logout")]})]}),c.jsx(Sb,{isOpen:v,onClose:()=>w(!1),version:s})]})},Nb=({collapsed:l})=>{const{t:s}=Te();Jt();const r="0.7.0",o=[{path:"/",label:s("nav.dashboard"),icon:c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:[c.jsx("path",{d:"M2 10a8 8 0 018-8v8h8a8 8 0 11-16 0z"}),c.jsx("path",{d:"M12 2.252A8.014 8.014 0 0117.748 8H12V2.252z"})]})},{path:"/servers",label:s("nav.servers"),icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})})},{path:"/groups",label:s("nav.groups"),icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{d:"M13 6a3 3 0 11-6 0 3 3 0 016 0zM18 8a2 2 0 11-4 0 2 2 0 014 0zM14 15a4 4 0 00-8 0v3h8v-3zM6 8a2 2 0 11-4 0 2 2 0 014 0zM16 18v-3a5.972 5.972 0 00-.75-2.906A3.005 3.005 0 0119 15v3h-3zM4.75 12.094A5.973 5.973 0 004 15v3H1v-3a3 3 0 013.75-2.906z"})})},{path:"/market",label:s("nav.market"),icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{d:"M3 1a1 1 0 000 2h1.22l.305 1.222a.997.997 0 00.01.042l1.358 5.43-.893.892C3.74 11.846 4.632 14 6.414 14H15a1 1 0 000-2H6.414l1-1H14a1 1 0 00.894-.553l3-6A1 1 0 0017 3H6.28l-.31-1.243A1 1 0 005 1H3zM16 16.5a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0zM6.5 18a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"})})},{path:"/logs",label:s("nav.logs"),icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z",clipRule:"evenodd"})})}];return c.jsxs("aside",{className:`bg-white dark:bg-gray-800 shadow-sm transition-all duration-300 ease-in-out flex flex-col h-full relative ${l?"w-16":"w-64"}`,children:[c.jsx("div",{className:"overflow-y-auto flex-grow",children:c.jsx("nav",{className:"p-3 space-y-1",children:o.map(d=>c.jsxs(Vm,{to:d.path,className:({isActive:f})=>`flex items-center px-3 py-2 rounded-md transition-colors ${f?"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,end:d.path==="/",children:[c.jsx("span",{className:"flex-shrink-0",children:d.icon}),!l&&c.jsx("span",{className:"ml-3",children:d.label})]},d.path))})}),c.jsx("div",{className:"p-3 bg-white dark:bg-gray-800",children:c.jsx(wb,{collapsed:l,version:r})})]})},jb=({children:l})=>c.jsx("main",{className:"flex-1 overflow-auto p-6 bg-gray-100 dark:bg-gray-900",children:c.jsx("div",{className:"container mx-auto",children:l})}),Eb=()=>{const[l,s]=vu.useState(!1),r=()=>{s(!l)};return c.jsxs("div",{className:"flex flex-col h-screen bg-gray-100 dark:bg-gray-900",children:[c.jsx(xb,{onToggleSidebar:r}),c.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[c.jsx(Nb,{collapsed:l}),c.jsx(jb,{children:c.jsx(Lm,{})})]})]})},Cb=({redirectPath:l="/login"})=>{const{t:s}=Te(),{auth:r}=Zr();return r.loading?c.jsx("div",{className:"flex items-center justify-center h-screen",children:s("app.loading")}):r.isAuthenticated?c.jsx(Lm,{}):c.jsx(Um,{to:l,replace:!0})},kb=()=>{const{t:l}=Te(),[s,r]=S.useState(""),[o,d]=S.useState(""),[f,m]=S.useState(null),[y,h]=S.useState(!1),{login:g}=Zr(),v=un(),w=async b=>{b.preventDefault(),m(null),h(!0);try{if(!s||!o){m(l("auth.emptyFields")),h(!1);return}await g(s,o)?v("/"):m(l("auth.loginFailed"))}catch{m(l("auth.loginError"))}finally{h(!1)}};return c.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 py-12 px-4 sm:px-6 lg:px-8",children:[c.jsx("div",{className:"absolute top-4 right-4",children:c.jsx(hg,{})}),c.jsxs("div",{className:"max-w-md w-full space-y-8",children:[c.jsx("div",{children:c.jsx("h2",{className:"mt-6 text-center text-3xl font-extrabold text-gray-900 dark:text-white",children:l("auth.loginTitle")})}),c.jsxs("form",{className:"mt-8 space-y-6",onSubmit:w,children:[c.jsxs("div",{className:"rounded-md shadow-sm -space-y-px",children:[c.jsxs("div",{children:[c.jsx("label",{htmlFor:"username",className:"sr-only",children:l("auth.username")}),c.jsx("input",{id:"username",name:"username",type:"text",autoComplete:"username",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 dark:border-gray-700 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white dark:bg-gray-800 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",placeholder:l("auth.username"),value:s,onChange:b=>r(b.target.value)})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"password",className:"sr-only",children:l("auth.password")}),c.jsx("input",{id:"password",name:"password",type:"password",autoComplete:"current-password",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 dark:border-gray-700 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white dark:bg-gray-800 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",placeholder:l("auth.password"),value:o,onChange:b=>d(b.target.value)})]})]}),f&&c.jsx("div",{className:"text-red-500 dark:text-red-400 text-sm text-center",children:f}),c.jsx("div",{children:c.jsx("button",{type:"submit",disabled:y,className:"group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",children:l(y?"auth.loggingIn":"auth.login")})})]})]})]})},Ur={startup:{maxAttempts:60,pollingInterval:3e3},normal:{pollingInterval:1e4}},ys=()=>{const{t:l}=Te(),[s,r]=S.useState([]),[o,d]=S.useState(null),[f,m]=S.useState(0),[y,h]=S.useState(!0),[g,v]=S.useState(0),w=S.useRef(null),b=S.useRef(0),R=()=>{w.current&&(clearInterval(w.current),w.current=null)},N=S.useCallback(()=>{R();const q=async()=>{try{const Y=localStorage.getItem("mcphub_token"),H=await(await fetch(Ee("/servers"),{headers:{"x-auth-token":Y||""}})).json();H&&H.success&&Array.isArray(H.data)?r(H.data):H&&Array.isArray(H)?r(H):(console.error("Invalid server data format:",H),r([])),d(null)}catch(Y){console.error("Error fetching servers during normal polling:",Y),navigator.onLine?Y instanceof TypeError&&(Y.message.includes("NetworkError")||Y.message.includes("Failed to fetch"))?d(l("errors.serverConnection")):d(l("errors.serverFetch")):d(l("errors.network"))}};q(),w.current=setInterval(q,Ur.normal.pollingInterval)},[l]);return S.useEffect(()=>{f>0&&(b.current=0,v(0));const q=async()=>{try{const Y=localStorage.getItem("mcphub_token"),H=await(await fetch(Ee("/servers"),{headers:{"x-auth-token":Y||""}})).json();return H&&H.success&&Array.isArray(H.data)?(r(H.data),h(!1),N(),!0):H&&Array.isArray(H)?(r(H),h(!1),N(),!0):(console.error("Invalid server data format:",H),r([]),h(!1),N(),!0)}catch(Y){return b.current+=1,console.error(`Initial loading attempt ${b.current} failed:`,Y),v(b.current),navigator.onLine?d(l("errors.initialStartup")):d(l("errors.network")),b.current>=Ur.startup.maxAttempts&&(console.log("Maximum startup attempts reached, switching to normal polling"),h(!1),R(),N()),!1}};return y?(R(),q(),w.current=setInterval(q,Ur.startup.pollingInterval),console.log(`Started initial polling with interval: ${Ur.startup.pollingInterval}ms`)):N(),()=>{R()}},[f,l,y,N]),{servers:s,error:o,setError:d,isLoading:y,fetchAttempts:g,triggerRefresh:()=>{R(),y&&(h(!0),b.current=0,v(0)),m(q=>q+1)},handleServerAdd:()=>{m(q=>q+1)},handleServerEdit:async q=>{try{const Y=localStorage.getItem("mcphub_token"),H=await(await fetch(Ee("/settings"),{headers:{"x-auth-token":Y||""}})).json();if(H&&H.success&&H.data&&H.data.mcpServers&&H.data.mcpServers[q.name]){const O=H.data.mcpServers[q.name];return{name:q.name,status:q.status,tools:q.tools||[],config:O}}else return console.error("Failed to get server config from settings:",H),d(l("server.invalidConfig",{serverName:q.name})),null}catch(Y){return console.error("Error fetching server settings:",Y),d(Y instanceof Error?Y.message:String(Y)),null}},handleServerRemove:async q=>{try{const Y=localStorage.getItem("mcphub_token"),W=await fetch(Ee(`/servers/${q}`),{method:"DELETE",headers:{"x-auth-token":Y||""}}),H=await W.json();return W.ok?(m(O=>O+1),!0):(d(H.message||l("server.deleteError",{serverName:q})),!1)}catch(Y){return d(l("errors.general")+": "+(Y instanceof Error?Y.message:String(Y))),!1}},handleServerToggle:async(q,Y)=>{try{const W=localStorage.getItem("mcphub_token"),H=await fetch(Ee(`/servers/${q.name}/toggle`),{method:"POST",headers:{"Content-Type":"application/json","x-auth-token":W||""},body:JSON.stringify({enabled:Y})}),O=await H.json();return H.ok?(m(J=>J+1),!0):(console.error("Failed to toggle server:",O),d(l("server.toggleError",{serverName:q.name})),!1)}catch(W){return console.error("Error toggling server:",W),d(W instanceof Error?W.message:String(W)),!1}}}},Ab=()=>{const{t:l}=Te(),{servers:s,error:r,setError:o,isLoading:d}=ys(),f={total:s.length,online:s.filter(h=>h.status==="connected").length,offline:s.filter(h=>h.status==="disconnected").length,connecting:s.filter(h=>h.status==="connecting").length},m={connected:"status.online",disconnected:"status.offline",connecting:"status.connecting"},y=h=>s.length===0?0:Math.round(s.filter(g=>g.status===h).length/s.length*100);return c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-8",children:l("pages.dashboard.title")}),r&&c.jsx("div",{className:"mb-6 bg-red-50 border-l-4 border-red-500 p-4 rounded shadow-sm",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-red-600 text-lg font-medium",children:l("app.error")}),c.jsx("p",{className:"text-gray-600 mt-1",children:r})]}),c.jsx("button",{onClick:()=>o(null),className:"ml-4 text-gray-500 hover:text-gray-700","aria-label":l("app.closeButton"),children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 011.414 0L10 8.586l4.293-4.293a1 1 111.414 1.414L11.414 10l4.293 4.293a1 1 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 01-1.414-1.414L8.586 10 4.293 5.707a1 1 010-1.414z",clipRule:"evenodd"})})})]})}),d?c.jsx("div",{className:"bg-white shadow rounded-lg p-6 flex items-center justify-center",children:c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsxs("svg",{className:"animate-spin h-10 w-10 text-blue-500 mb-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c.jsx("p",{className:"text-gray-600",children:l("app.loading")})]})}):c.jsxs("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-4",children:[c.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:c.jsxs("div",{className:"flex items-center",children:[c.jsx("div",{className:"p-3 rounded-full bg-blue-100 text-blue-800",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"})})}),c.jsxs("div",{className:"ml-4",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-700",children:l("pages.dashboard.totalServers")}),c.jsx("p",{className:"text-3xl font-bold text-gray-900",children:f.total})]})]})}),c.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[c.jsxs("div",{className:"flex items-center",children:[c.jsx("div",{className:"p-3 rounded-full bg-green-100 text-green-800",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),c.jsxs("div",{className:"ml-4",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-700",children:l("pages.dashboard.onlineServers")}),c.jsx("p",{className:"text-3xl font-bold text-gray-900",children:f.online})]})]}),c.jsx("div",{className:"mt-4 h-2 bg-gray-200 rounded-full",children:c.jsx("div",{className:"h-full bg-green-500 rounded-full",style:{width:`${y("connected")}%`}})})]}),c.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[c.jsxs("div",{className:"flex items-center",children:[c.jsx("div",{className:"p-3 rounded-full bg-red-100 text-red-800",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),c.jsxs("div",{className:"ml-4",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-700",children:l("pages.dashboard.offlineServers")}),c.jsx("p",{className:"text-3xl font-bold text-gray-900",children:f.offline})]})]}),c.jsx("div",{className:"mt-4 h-2 bg-gray-200 rounded-full",children:c.jsx("div",{className:"h-full bg-red-500 rounded-full",style:{width:`${y("disconnected")}%`}})})]}),c.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[c.jsxs("div",{className:"flex items-center",children:[c.jsx("div",{className:"p-3 rounded-full bg-yellow-100 text-yellow-800",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),c.jsxs("div",{className:"ml-4",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-700",children:l("pages.dashboard.connectingServers")}),c.jsx("p",{className:"text-3xl font-bold text-gray-900",children:f.connecting})]})]}),c.jsx("div",{className:"mt-4 h-2 bg-gray-200 rounded-full",children:c.jsx("div",{className:"h-full bg-yellow-500 rounded-full",style:{width:`${y("connecting")}%`}})})]})]}),s.length>0&&!d&&c.jsxs("div",{className:"mt-8",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:l("pages.dashboard.recentServers")}),c.jsx("div",{className:"bg-white shadow rounded-lg overflow-hidden",children:c.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[c.jsx("thead",{className:"bg-gray-50",children:c.jsxs("tr",{children:[c.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:l("server.name")}),c.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:l("server.status")}),c.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:l("server.tools")}),c.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:l("server.enabled")})]})}),c.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:s.slice(0,5).map((h,g)=>{var v;return c.jsxs("tr",{children:[c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:h.name}),c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:c.jsx("span",{className:`px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${h.status==="connected"?"bg-green-100 text-green-800":h.status==="disconnected"?"bg-red-100 text-red-800":"bg-yellow-100 text-yellow-800"}`,children:l(m[h.status]||h.status)})}),c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:((v=h.tools)==null?void 0:v.length)||0}),c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:h.enabled!==!1?c.jsx("span",{className:"text-green-600",children:"✓"}):c.jsx("span",{className:"text-red-600",children:"✗"})})]},g)})})]})})]})]})},Tb={default:"bg-blue-500 text-white hover:bg-blue-600",secondary:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600",outline:"bg-transparent border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",destructive:"bg-red-500 text-white hover:bg-red-600"};function Lr({children:l,variant:s="default",className:r,onClick:o}){return c.jsx("span",{className:qa("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors",Tb[s],o?"cursor-pointer":"",r),onClick:o,children:l})}const Rb=({status:l})=>{const{t:s}=Te(),r={connecting:"bg-yellow-100 text-yellow-800",connected:"bg-green-100 text-green-800",disconnected:"bg-red-100 text-red-800"},o={connected:"status.online",disconnected:"status.offline",connecting:"status.connecting"};return c.jsx("span",{className:`px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${r[l]}`,children:s(o[l]||l)})},Ob=({tool:l})=>{const[s,r]=S.useState(!1);return c.jsxs("div",{className:"bg-white shadow rounded-lg p-4 mb-4",children:[c.jsxs("div",{className:"flex justify-between items-center cursor-pointer",onClick:()=>r(!s),children:[c.jsx("h3",{className:"text-lg font-medium text-gray-900",children:l.name}),c.jsx("button",{className:"text-gray-400 hover:text-gray-600",children:s?c.jsx(Zm,{size:18}):c.jsx(Pm,{size:18})})]}),s&&c.jsxs("div",{className:"mt-4",children:[c.jsx("p",{className:"text-gray-600 mb-2",children:l.description||"No description available"}),c.jsxs("div",{className:"bg-gray-50 rounded p-2",children:[c.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:"Input Schema:"}),c.jsx("pre",{className:"text-xs text-gray-600 overflow-auto",children:JSON.stringify(l.inputSchema,null,2)})]})]})]})},pg=({isOpen:l,onClose:s,onConfirm:r,serverName:o,isGroup:d=!1})=>{const{t:f}=Te();return l?c.jsx("div",{className:"fixed inset-0 bg-black/50 bg-opacity-30 z-50 flex items-center justify-center p-4",children:c.jsx("div",{className:"bg-white rounded-lg shadow-lg max-w-md w-full",children:c.jsxs("div",{className:"p-6",children:[c.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-3",children:f(d?"groups.confirmDelete":"server.confirmDelete")}),c.jsx("p",{className:"text-gray-500 mb-6",children:d?f("groups.deleteWarning",{name:o}):f("server.deleteWarning",{name:o})}),c.jsxs("div",{className:"flex justify-end space-x-3",children:[c.jsx("button",{onClick:s,className:"px-4 py-2 text-gray-600 hover:text-gray-800",children:f("common.cancel")}),c.jsx("button",{onClick:r,className:"px-4 py-2 bg-red-500 text-white rounded hover:bg-red-600",children:f("common.delete")})]})]})})}):null},Mb=({server:l,onRemove:s,onEdit:r,onToggle:o})=>{const{t:d}=Te(),{showToast:f}=ps(),[m,y]=S.useState(!1),[h,g]=S.useState(!1),[v,w]=S.useState(!1),[b,R]=S.useState(!1),[N,C]=S.useState(!1),A=S.useRef(null);S.useEffect(()=>{const H=O=>{A.current&&!A.current.contains(O.target)&&R(!1)};return document.addEventListener("mousedown",H),()=>{document.removeEventListener("mousedown",H)}},[]);const z=H=>{H.stopPropagation(),g(!0)},T=H=>{H.stopPropagation(),r(l)},D=async H=>{if(H.stopPropagation(),!(v||!o)){w(!0);try{await o(l,l.enabled===!1)}finally{w(!1)}}},q=H=>{H.stopPropagation(),R(!b)},Y=H=>{if(H.stopPropagation(),!!l.error)if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(l.error).then(()=>{C(!0),f(d("common.copySuccess")||"Copied to clipboard","success"),setTimeout(()=>C(!1),2e3)});else{const O=document.createElement("textarea");O.value=l.error,O.style.position="fixed",O.style.left="-9999px",document.body.appendChild(O),O.focus(),O.select();try{document.execCommand("copy"),C(!0),f(d("common.copySuccess")||"Copied to clipboard","success"),setTimeout(()=>C(!1),2e3)}catch(J){f(d("common.copyFailed")||"Copy failed","error"),console.error("Copy to clipboard failed:",J)}document.body.removeChild(O)}},W=()=>{s(l.name),g(!1)};return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:`bg-white shadow rounded-lg p-6 mb-6 ${l.enabled===!1?"opacity-60":""}`,children:[c.jsxs("div",{className:"flex justify-between items-center cursor-pointer",onClick:()=>y(!m),children:[c.jsxs("div",{className:"flex items-center space-x-3",children:[c.jsx("h2",{className:`text-xl font-semibold ${l.enabled===!1?"text-gray-600":"text-gray-900"}`,children:l.name}),c.jsx(Rb,{status:l.status}),l.error&&c.jsxs("div",{className:"relative",children:[c.jsx("div",{className:"cursor-pointer",onClick:q,"aria-label":d("server.viewErrorDetails"),children:c.jsx(Kx,{className:"text-red-500 hover:text-red-600",size:18})}),b&&c.jsxs("div",{ref:A,className:"absolute z-10 mt-2 bg-white border border-gray-200 rounded-md shadow-lg p-0 w-120",style:{left:"-231px",top:"24px",maxHeight:"300px",overflowY:"auto",width:"480px",transform:"translateX(50%)"},onClick:H=>H.stopPropagation(),children:[c.jsxs("div",{className:"flex justify-between items-center sticky top-0 bg-white py-2 px-4 border-b border-gray-200 z-20 shadow-sm",children:[c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx("h4",{className:"text-sm font-medium text-red-600",children:d("server.errorDetails")}),c.jsx("button",{onClick:Y,className:"p-1 text-gray-400 hover:text-gray-600 transition-colors",title:d("common.copy"),children:N?c.jsx(Bu,{size:14,className:"text-green-500"}):c.jsx(Jm,{size:14})})]}),c.jsx("button",{onClick:H=>{H.stopPropagation(),R(!1)},className:"text-gray-400 hover:text-gray-600",children:"✕"})]}),c.jsx("div",{className:"p-4 pt-2",children:c.jsx("pre",{className:"text-sm text-gray-700 break-words whitespace-pre-wrap",children:l.error})})]})]})]}),c.jsxs("div",{className:"flex space-x-2",children:[c.jsx("button",{onClick:T,className:"px-3 py-1 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 text-sm",children:d("server.edit")}),c.jsx("div",{className:"flex items-center",children:c.jsx("button",{onClick:D,className:`px-3 py-1 text-sm rounded transition-colors ${v?"bg-gray-200 text-gray-500":l.enabled!==!1?"bg-green-100 text-green-800 hover:bg-green-200":"bg-gray-100 text-gray-800 hover:bg-gray-200"}`,disabled:v,children:v?d("common.processing"):l.enabled!==!1?d("server.disable"):d("server.enable")})}),c.jsx("button",{onClick:z,className:"px-3 py-1 bg-red-100 text-red-800 rounded hover:bg-red-200 text-sm",children:d("server.delete")}),c.jsx("button",{className:"text-gray-400 hover:text-gray-600",children:m?c.jsx(Zm,{size:18}):c.jsx(Pm,{size:18})})]})]}),m&&l.tools&&c.jsxs("div",{className:"mt-6",children:[c.jsx("h3",{className:`text-lg font-medium ${l.enabled===!1?"text-gray-600":"text-gray-900"} mb-4`,children:d("server.tools")}),c.jsx("div",{className:"space-y-4",children:l.tools.map((H,O)=>c.jsx(Ob,{tool:H},O))})]})]}),c.jsx(pg,{isOpen:h,onClose:()=>g(!1),onConfirm:W,serverName:l.name})]})},qu=({onSubmit:l,onCancel:s,initialData:r=null,modalTitle:o,formError:d=null})=>{const{t:f}=Te(),m=()=>!r||!r.config?"stdio":r.config.type?r.config.type:r.config.url?"sse":"stdio",[y,h]=S.useState(m()),[g,v]=S.useState({name:r&&r.name||"",url:r&&r.config&&r.config.url||"",command:r&&r.config&&r.config.command||"",arguments:r&&r.config&&r.config.args?Array.isArray(r.config.args)?r.config.args.join(" "):String(r.config.args):"",args:r&&r.config&&r.config.args||[],type:m(),env:[]}),[w,b]=S.useState(r&&r.config&&r.config.env?Object.entries(r.config.env).map(([H,O])=>({key:H,value:O})):[]),[R,N]=S.useState(null),C=!!r,A=H=>{const{name:O,value:J}=H.target;v({...g,[O]:J})},z=H=>{let O=H.split(" ").filter(J=>J.trim()!=="");v({...g,arguments:H,args:O})},T=H=>{h(H),v(O=>({...O,type:H}))},D=(H,O,J)=>{const re=[...w];re[H][O]=J,b(re)},q=()=>{b([...w,{key:"",value:""}])},Y=H=>{const O=[...w];O.splice(H,1),b(O)},W=async H=>{H.preventDefault(),N(null);try{const O={};w.forEach(({key:re,value:de})=>{re.trim()&&(O[re.trim()]=de)});const J={name:g.name,config:{type:y,...y==="sse"||y==="streamable-http"?{url:g.url}:{command:g.command,args:g.args,env:Object.keys(O).length>0?O:void 0}}};l(J)}catch(O){N(`Error: ${O instanceof Error?O.message:String(O)}`)}};return c.jsxs("div",{className:"bg-white shadow rounded-lg p-6 w-full max-w-xl max-h-screen overflow-y-auto",children:[c.jsxs("div",{className:"flex justify-between items-center mb-4",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:o}),c.jsx("button",{onClick:s,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),(R||d)&&c.jsx("div",{className:"bg-red-50 text-red-700 p-3 rounded mb-4",children:d||R}),c.jsxs("form",{onSubmit:W,children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"name",children:f("server.name")}),c.jsx("input",{type:"text",name:"name",id:"name",value:g.name,onChange:A,className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline",placeholder:"e.g.: time-mcp",required:!0,disabled:C})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",children:f("server.type")}),c.jsxs("div",{className:"flex space-x-4",children:[c.jsxs("div",{children:[c.jsx("input",{type:"radio",id:"command",name:"serverType",value:"command",checked:y==="stdio",onChange:()=>T("stdio"),className:"mr-1"}),c.jsx("label",{htmlFor:"command",children:"STDIO"})]}),c.jsxs("div",{children:[c.jsx("input",{type:"radio",id:"url",name:"serverType",value:"url",checked:y==="sse",onChange:()=>T("sse"),className:"mr-1"}),c.jsx("label",{htmlFor:"url",children:"SSE"})]}),c.jsxs("div",{children:[c.jsx("input",{type:"radio",id:"streamable-http",name:"serverType",value:"streamable-http",checked:y==="streamable-http",onChange:()=>T("streamable-http"),className:"mr-1"}),c.jsx("label",{htmlFor:"streamable-http",children:"Streamable HTTP"})]})]})]}),y==="sse"||y==="streamable-http"?c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"url",children:f("server.url")}),c.jsx("input",{type:"url",name:"url",id:"url",value:g.url,onChange:A,className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline",placeholder:y==="streamable-http"?"e.g.: http://localhost:3000/mcp":"e.g.: http://localhost:3000/sse",required:y==="sse"||y==="streamable-http"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"command",children:f("server.command")}),c.jsx("input",{type:"text",name:"command",id:"command",value:g.command,onChange:A,className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline",placeholder:"e.g.: npx",required:y==="stdio"})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"arguments",children:f("server.arguments")}),c.jsx("input",{type:"text",name:"arguments",id:"arguments",value:g.arguments,onChange:H=>z(H.target.value),className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline",placeholder:"e.g.: -y time-mcp",required:y==="stdio"})]}),c.jsxs("div",{className:"mb-4",children:[c.jsxs("div",{className:"flex justify-between items-center mb-2",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold",children:f("server.envVars")}),c.jsxs("button",{type:"button",onClick:q,className:"bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-1 px-2 rounded text-sm flex items-center",children:["+ ",f("server.add")]})]}),w.map((H,O)=>c.jsxs("div",{className:"flex items-center mb-2",children:[c.jsxs("div",{className:"flex items-center space-x-2 flex-grow",children:[c.jsx("input",{type:"text",value:H.key,onChange:J=>D(O,"key",J.target.value),className:"shadow appearance-none border rounded py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline w-1/2",placeholder:f("server.key")}),c.jsx("span",{className:"flex items-center",children:":"}),c.jsx("input",{type:"text",value:H.value,onChange:J=>D(O,"value",J.target.value),className:"shadow appearance-none border rounded py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline w-1/2",placeholder:f("server.value")})]}),c.jsxs("button",{type:"button",onClick:()=>Y(O),className:"bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-1 px-2 rounded text-sm flex items-center justify-center min-w-[56px] ml-2",children:["- ",f("server.remove")]})]},O))]})]}),c.jsxs("div",{className:"flex justify-end mt-6",children:[c.jsx("button",{type:"button",onClick:s,className:"bg-gray-300 hover:bg-gray-400 text-gray-800 font-medium py-2 px-4 rounded mr-2",children:f("server.cancel")}),c.jsx("button",{type:"submit",className:"bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded",children:f(C?"server.save":"server.add")})]})]})]})},zb=({onAdd:l})=>{const{t:s}=Te(),[r,o]=S.useState(!1),[d,f]=S.useState(null),m=()=>{o(!r),f(null)},y=async h=>{try{f(null);const g=localStorage.getItem("mcphub_token"),v=await fetch(Ee("/servers"),{method:"POST",headers:{"Content-Type":"application/json","x-auth-token":g||""},body:JSON.stringify(h)}),w=await v.json();if(!v.ok){w&&w.message?f(w.message):v.status===400?f(s("server.invalidData")):v.status===409?f(s("server.alreadyExists",{serverName:h.name})):f(s("server.addError"));return}o(!1),l()}catch(g){console.error("Error adding server:",g),navigator.onLine?g instanceof TypeError&&(g.message.includes("NetworkError")||g.message.includes("Failed to fetch"))?f(s("errors.serverConnection")):f(s("errors.serverAdd")):f(s("errors.network"))}};return c.jsxs("div",{children:[c.jsx("button",{onClick:m,className:"w-full bg-blue-100 text-blue-800 rounded hover:bg-blue-200 py-2 px-4",children:s("server.addServer")}),r&&c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx(qu,{onSubmit:y,onCancel:m,modalTitle:s("server.addServer"),formError:d})})]})},Db=({server:l,onEdit:s,onCancel:r})=>{const{t:o}=Te(),[d,f]=S.useState(null),m=async y=>{try{f(null);const h=localStorage.getItem("mcphub_token"),g=await fetch(Ee(`/servers/${l.name}`),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":h||""},body:JSON.stringify(y)}),v=await g.json();if(!g.ok){v&&v.message?f(v.message):g.status===404?f(o("server.notFound",{serverName:l.name})):g.status===400?f(o("server.invalidData")):f(o("server.updateError",{serverName:l.name}));return}s()}catch(h){console.error("Error updating server:",h),navigator.onLine?h instanceof TypeError&&(h.message.includes("NetworkError")||h.message.includes("Failed to fetch"))?f(o("errors.serverConnection")):f(o("errors.serverUpdate",{serverName:l.name})):f(o("errors.network"))}};return c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx(qu,{onSubmit:m,onCancel:r,initialData:l,modalTitle:o("server.editTitle",{serverName:l.name}),formError:d})})},Ub=()=>{const{t:l}=Te(),s=un(),{servers:r,error:o,setError:d,isLoading:f,handleServerAdd:m,handleServerEdit:y,handleServerRemove:h,handleServerToggle:g,triggerRefresh:v}=ys(),[w,b]=S.useState(null),[R,N]=S.useState(!1),C=async T=>{const D=await y(T);D&&b(D)},A=()=>{b(null),v()},z=async()=>{N(!0);try{v(),await new Promise(T=>setTimeout(T,500))}finally{N(!1)}};return c.jsxs("div",{children:[c.jsxs("div",{className:"flex justify-between items-center mb-8",children:[c.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:l("pages.servers.title")}),c.jsxs("div",{className:"flex space-x-4",children:[c.jsxs("button",{onClick:()=>s("/market"),className:"px-4 py-2 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 flex items-center",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{d:"M3 1a1 1 0 000 2h1.22l.305 1.222a.997.997 0 00.01.042l1.358 5.43-.893.892C3.74 11.846 4.632 14 6.414 14H15a1 1 0 000-2H6.414l1-1H14a1 1 0 00.894-.553l3-6A1 1 0 0017 3H6.28l-.31-1.243A1 1 0 005 1H3z"})}),l("nav.market")]}),c.jsx(zb,{onAdd:m}),c.jsxs("button",{onClick:z,disabled:R,className:`px-4 py-2 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 flex items-center ${R?"opacity-70 cursor-not-allowed":""}`,children:[R?c.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),l("common.refresh")]})]})]}),o&&c.jsx("div",{className:"mb-6 bg-red-50 border-l-4 border-red-500 p-4 rounded shadow-sm",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-red-600 text-lg font-medium",children:l("app.error")}),c.jsx("p",{className:"text-gray-600 mt-1",children:o})]}),c.jsx("button",{onClick:()=>d(null),className:"ml-4 text-gray-500 hover:text-gray-700","aria-label":l("app.closeButton"),children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 011.414 0L10 8.586l4.293-4.293a1 1 111.414 1.414L11.414 10l4.293 4.293a1 1 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 01-1.414-1.414L8.586 10 4.293 5.707a1 1 010-1.414z",clipRule:"evenodd"})})})]})}),f?c.jsx("div",{className:"bg-white shadow rounded-lg p-6 flex items-center justify-center",children:c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsxs("svg",{className:"animate-spin h-10 w-10 text-blue-500 mb-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c.jsx("p",{className:"text-gray-600",children:l("app.loading")})]})}):r.length===0?c.jsx("div",{className:"bg-white shadow rounded-lg p-6",children:c.jsx("p",{className:"text-gray-600",children:l("app.noServers")})}):c.jsx("div",{className:"space-y-6",children:r.map((T,D)=>c.jsx(Mb,{server:T,onRemove:h,onEdit:C,onToggle:g},D))}),w&&c.jsx(Db,{server:w,onEdit:A,onCancel:()=>b(null)})]})},Vu=()=>{const{t:l}=Te(),[s,r]=S.useState([]),[o,d]=S.useState(!0),[f,m]=S.useState(null),[y,h]=S.useState(0),g=S.useCallback(async()=>{try{d(!0);const z=localStorage.getItem("mcphub_token"),T=await fetch(Ee("/groups"),{headers:{"x-auth-token":z||""}});if(!T.ok)throw new Error(`Status: ${T.status}`);const D=await T.json();D&&D.success&&Array.isArray(D.data)?r(D.data):(console.error("Invalid group data format:",D),r([])),m(null)}catch(z){console.error("Error fetching groups:",z),m(z instanceof Error?z.message:"Failed to fetch groups"),r([])}finally{d(!1)}},[]),v=S.useCallback(()=>{h(z=>z+1)},[]),w=async(z,T,D=[])=>{try{const q=localStorage.getItem("mcphub_token"),Y=await fetch(Ee("/groups"),{method:"POST",headers:{"Content-Type":"application/json","x-auth-token":q||""},body:JSON.stringify({name:z,description:T,servers:D})}),W=await Y.json();return Y.ok?(v(),W.data||null):(m(W.message||l("groups.createError")),null)}catch(q){return m(q instanceof Error?q.message:"Failed to create group"),null}},b=async(z,T)=>{try{const D=localStorage.getItem("mcphub_token"),q=await fetch(Ee(`/groups/${z}`),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":D||""},body:JSON.stringify(T)}),Y=await q.json();return q.ok?(v(),Y.data||null):(m(Y.message||l("groups.updateError")),null)}catch(D){return m(D instanceof Error?D.message:"Failed to update group"),null}},R=async(z,T)=>{try{const D=localStorage.getItem("mcphub_token"),q=await fetch(Ee(`/groups/${z}/servers/batch`),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":D||""},body:JSON.stringify({servers:T})}),Y=await q.json();return q.ok?(v(),Y.data||null):(m(Y.message||l("groups.updateError")),null)}catch(D){return m(D instanceof Error?D.message:"Failed to update group servers"),null}},N=async z=>{try{const T=localStorage.getItem("mcphub_token"),D=await fetch(Ee(`/groups/${z}`),{method:"DELETE",headers:{"x-auth-token":T||""}}),q=await D.json();return D.ok?(v(),!0):(m(q.message||l("groups.deleteError")),!1)}catch(T){return m(T instanceof Error?T.message:"Failed to delete group"),!1}},C=async(z,T)=>{try{const D=localStorage.getItem("mcphub_token"),q=await fetch(Ee(`/groups/${z}/servers`),{method:"POST",headers:{"Content-Type":"application/json","x-auth-token":D||""},body:JSON.stringify({serverName:T})}),Y=await q.json();return q.ok?(v(),Y.data||null):(m(Y.message||l("groups.serverAddError")),null)}catch(D){return m(D instanceof Error?D.message:"Failed to add server to group"),null}},A=async(z,T)=>{try{const D=localStorage.getItem("mcphub_token"),q=await fetch(Ee(`/groups/${z}/servers/${T}`),{method:"DELETE",headers:{"x-auth-token":D||""}}),Y=await q.json();return q.ok?(v(),Y.data||null):(m(Y.message||l("groups.serverRemoveError")),null)}catch(D){return m(D instanceof Error?D.message:"Failed to remove server from group"),null}};return S.useEffect(()=>{g()},[g,y]),{groups:s,loading:o,error:f,setError:m,triggerRefresh:v,createGroup:w,updateGroup:b,updateGroupServers:R,deleteGroup:N,addServerToGroup:C,removeServerFromGroup:A}},Lb=({value:l,isSelected:s,onClick:r,children:o})=>c.jsxs("button",{type:"button",role:"checkbox","aria-checked":s,className:qa("flex w-full items-center justify-between p-2 rounded transition-colors cursor-pointer",s?"bg-blue-50 text-blue-700 hover:bg-blue-100 border-l-4 border-blue-500":"hover:bg-gray-50 text-gray-700"),onClick:r,children:[c.jsx("span",{className:"flex items-center",children:o}),s&&c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"w-5 h-5 text-blue-500",children:c.jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})]}),yg=({label:l,helpText:s,noOptionsText:r="No options available",values:o,options:d,onChange:f,className:m})=>{const y=h=>{const g=o.includes(h);f(g?o.filter(v=>v!==h):[...o,h])};return c.jsxs("div",{className:m,children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",children:l}),c.jsx("div",{className:"border rounded shadow max-h-60 overflow-y-auto",children:d.length===0?c.jsx("p",{className:"text-gray-500 text-sm p-3",children:r}):c.jsx("div",{className:"space-y-1 p-1",children:d.map(h=>c.jsx(Lb,{value:h.value,isSelected:o.includes(h.value),onClick:()=>y(h.value),children:h.label},h.value))})}),s&&c.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s})]})},_r=({checked:l,onCheckedChange:s,disabled:r=!1})=>c.jsx("button",{type:"button",role:"switch","aria-checked":l,disabled:r,className:qa("relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",l?"bg-blue-600":"bg-gray-200",r?"opacity-50 cursor-not-allowed":"cursor-pointer"),onClick:()=>!r&&s(!l),children:c.jsx("span",{className:qa("inline-block h-4 w-4 transform rounded-full bg-white transition-transform",l?"translate-x-6":"translate-x-1")})}),_b=({onAdd:l,onCancel:s})=>{const{t:r}=Te(),{createGroup:o}=Vu(),{servers:d}=ys(),[f,m]=S.useState([]),[y,h]=S.useState(null),[g,v]=S.useState(!1),[w,b]=S.useState({name:"",description:"",servers:[]});S.useEffect(()=>{m(d.filter(C=>C.enabled!==!1))},[d]);const R=C=>{const{name:A,value:z}=C.target;b(T=>({...T,[A]:z}))},N=async C=>{C.preventDefault(),v(!0),h(null);try{if(!w.name.trim()){h(r("groups.nameRequired")),v(!1);return}if(!await o(w.name,w.description,w.servers)){h(r("groups.createError")),v(!1);return}l()}catch(A){h(A instanceof Error?A.message:String(A)),v(!1)}};return c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx("div",{className:"bg-white rounded-lg shadow-lg max-w-md w-full",children:c.jsxs("div",{className:"p-6",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-800 mb-4",children:r("groups.addNew")}),y&&c.jsx("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded",children:y}),c.jsxs("form",{onSubmit:N,children:[c.jsxs("div",{className:"mb-4",children:[c.jsxs("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"name",children:[r("groups.name")," *"]}),c.jsx("input",{type:"text",id:"name",name:"name",value:w.name,onChange:R,className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline",placeholder:r("groups.namePlaceholder"),required:!0})]}),c.jsx(yg,{className:"mb-6",label:r("groups.servers"),noOptionsText:r("groups.noServerOptions"),values:w.servers,options:f.map(C=>({value:C.name,label:C.name})),onChange:C=>b(A=>({...A,servers:C}))}),c.jsxs("div",{className:"flex justify-end space-x-3",children:[c.jsx("button",{type:"button",onClick:s,className:"px-4 py-2 text-gray-600 hover:text-gray-800",disabled:g,children:r("common.cancel")}),c.jsx("button",{type:"submit",className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",disabled:g,children:r(g?"common.submitting":"common.create")})]})]})]})})})},Hb=({group:l,onEdit:s,onCancel:r})=>{const{t:o}=Te(),{updateGroup:d}=Vu(),{servers:f}=ys(),[m,y]=S.useState([]),[h,g]=S.useState(null),[v,w]=S.useState(!1),[b,R]=S.useState({name:l.name,description:l.description||"",servers:l.servers||[]});S.useEffect(()=>{y(f.filter(A=>A.enabled!==!1))},[f]);const N=A=>{const{name:z,value:T}=A.target;R(D=>({...D,[z]:T}))},C=async A=>{A.preventDefault(),w(!0),g(null);try{if(!b.name.trim()){g(o("groups.nameRequired")),w(!1);return}if(!await d(l.id,{name:b.name,description:b.description,servers:b.servers})){g(o("groups.updateError")),w(!1);return}s()}catch(z){g(z instanceof Error?z.message:String(z)),w(!1)}};return c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx("div",{className:"bg-white rounded-lg shadow-lg max-w-md w-full",children:c.jsxs("div",{className:"p-6",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-800 mb-4",children:o("groups.edit")}),h&&c.jsx("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded",children:h}),c.jsxs("form",{onSubmit:C,children:[c.jsxs("div",{className:"mb-4",children:[c.jsxs("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"name",children:[o("groups.name")," *"]}),c.jsx("input",{type:"text",id:"name",name:"name",value:b.name,onChange:N,className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline",placeholder:o("groups.namePlaceholder"),required:!0})]}),c.jsx(yg,{className:"mb-6",label:o("groups.servers"),noOptionsText:o("groups.noServerOptions"),values:b.servers,options:m.map(A=>({value:A.name,label:A.name})),onChange:A=>R(z=>({...z,servers:A}))}),c.jsxs("div",{className:"flex justify-end space-x-3",children:[c.jsx("button",{type:"button",onClick:r,className:"px-4 py-2 text-gray-600 hover:text-gray-800",disabled:v,children:o("common.cancel")}),c.jsx("button",{type:"submit",className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",disabled:v,children:o(v?"common.submitting":"common.save")})]})]})]})})})},Bb=({group:l,servers:s,onEdit:r,onDelete:o})=>{const{t:d}=Te(),{showToast:f}=ps(),[m,y]=S.useState(!1),[h,g]=S.useState(!1),v=()=>{r(l)},w=()=>{y(!0)},b=()=>{o(l.id),y(!1)},R=()=>{if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(l.id).then(()=>{g(!0),setTimeout(()=>g(!1),2e3)});else{const C=document.createElement("textarea");C.value=l.id,C.style.position="fixed",C.style.left="-9999px",document.body.appendChild(C),C.focus(),C.select();try{document.execCommand("copy"),g(!0),setTimeout(()=>g(!1),2e3)}catch(A){f(d("common.copyFailed")||"Copy failed","error"),console.error("Copy to clipboard failed:",A)}document.body.removeChild(C)}},N=s.filter(C=>l.servers.includes(C.name));return c.jsxs("div",{className:"bg-white shadow rounded-lg p-6",children:[c.jsxs("div",{className:"flex justify-between items-center mb-4",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-800",children:l.name}),c.jsxs("div",{className:"flex items-center ml-3",children:[c.jsx("span",{className:"text-xs text-gray-500 mr-1",children:l.id}),c.jsx("button",{onClick:R,className:"p-1 text-gray-400 hover:text-gray-600 transition-colors",title:d("common.copy"),children:h?c.jsx(Bu,{size:14,className:"text-green-500"}):c.jsx(Jm,{size:14})})]})]}),l.description&&c.jsx("p",{className:"text-gray-600 text-sm mt-1",children:l.description})]}),c.jsxs("div",{className:"flex items-center space-x-3",children:[c.jsx("div",{className:"bg-blue-50 text-blue-700 px-3 py-1 rounded-full text-sm",children:d("groups.serverCount",{count:l.servers.length})}),c.jsx("button",{onClick:v,className:"text-gray-500 hover:text-gray-700",title:d("groups.edit"),children:c.jsx(nv,{size:18})}),c.jsx("button",{onClick:w,className:"text-gray-500 hover:text-red-600",title:d("groups.delete"),children:c.jsx(iv,{size:18})})]})]}),c.jsx("div",{className:"mt-4",children:N.length===0?c.jsx("p",{className:"text-gray-500 italic",children:d("groups.noServers")}):c.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:N.map(C=>c.jsxs("div",{className:"inline-flex items-center px-3 py-1 bg-gray-50 rounded",children:[c.jsx("span",{className:"font-medium text-gray-700 text-sm",children:C.name}),c.jsx("span",{className:`ml-2 inline-block h-2 w-2 rounded-full ${C.status==="connected"?"bg-green-500":C.status==="connecting"?"bg-yellow-500":"bg-red-500"}`})]},C.name))})}),c.jsx(pg,{isOpen:m,onClose:()=>y(!1),onConfirm:b,serverName:l.name,isGroup:!0})]})},Gb=()=>{const{t:l}=Te(),{groups:s,loading:r,error:o,setError:d,deleteGroup:f,triggerRefresh:m}=Vu(),{servers:y}=ys(),[h,g]=S.useState(null),[v,w]=S.useState(!1),b=z=>{g(z)},R=()=>{g(null),m()},N=async z=>{await f(z)||d(l("groups.deleteError"))},C=()=>{w(!0)},A=()=>{w(!1),m()};return c.jsxs("div",{children:[c.jsxs("div",{className:"flex justify-between items-center mb-8",children:[c.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:l("pages.groups.title")}),c.jsx("div",{className:"flex space-x-4",children:c.jsxs("button",{onClick:C,className:"px-4 py-2 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 flex items-center",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 00-1 1v5H4a1 1 0 100 2h5v5a1 1 0 102 0v-5h5a1 1 0 100-2h-5V4a1 1 0 00-1-1z",clipRule:"evenodd"})}),l("groups.add")]})})]}),o&&c.jsx("div",{className:"bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-6",children:c.jsx("p",{children:o})}),r?c.jsx("div",{className:"bg-white shadow rounded-lg p-6",children:c.jsxs("div",{className:"flex flex-col items-center justify-center",children:[c.jsxs("svg",{className:"animate-spin h-10 w-10 text-blue-500 mb-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c.jsx("p",{className:"text-gray-600",children:l("app.loading")})]})}):s.length===0?c.jsx("div",{className:"bg-white shadow rounded-lg p-6",children:c.jsx("p",{className:"text-gray-600",children:l("groups.noGroups")})}):c.jsx("div",{className:"space-y-6",children:s.map(z=>c.jsx(Bb,{group:z,servers:y,onEdit:b,onDelete:N},z.id))}),v&&c.jsx(_b,{onAdd:A,onCancel:A}),h&&c.jsx(Hb,{group:h,onEdit:R,onCancel:()=>g(null)})]})},qb=({onSuccess:l,onCancel:s})=>{const{t:r}=Te(),[o,d]=S.useState({currentPassword:"",newPassword:""}),[f,m]=S.useState(""),[y,h]=S.useState(!1),[g,v]=S.useState(null),[w,b]=S.useState(!1),R=C=>{const{name:A,value:z}=C.target;A==="confirmPassword"?m(z):d(T=>({...T,[A]:z}))},N=async C=>{if(C.preventDefault(),v(null),o.newPassword!==f){v(r("auth.passwordsNotMatch"));return}h(!0);try{const A=await zx(o);A.success?(b(!0),l&&l()):v(A.message||r("auth.changePasswordError"))}catch{v(r("auth.changePasswordError"))}finally{h(!1)}};return c.jsxs("div",{className:"p-6 bg-white rounded-lg shadow-md",children:[c.jsx("h2",{className:"text-xl font-bold mb-4",children:r("auth.changePassword")}),w?c.jsx("div",{className:"bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4",children:r("auth.changePasswordSuccess")}):c.jsxs("form",{onSubmit:N,children:[g&&c.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4",children:g}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"currentPassword",children:r("auth.currentPassword")}),c.jsx("input",{type:"password",id:"currentPassword",name:"currentPassword",className:"w-full p-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500",value:o.currentPassword,onChange:R,required:!0})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"newPassword",children:r("auth.newPassword")}),c.jsx("input",{type:"password",id:"newPassword",name:"newPassword",className:"w-full p-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500",value:o.newPassword,onChange:R,required:!0,minLength:6})]}),c.jsxs("div",{className:"mb-6",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"confirmPassword",children:r("auth.confirmPassword")}),c.jsx("input",{type:"password",id:"confirmPassword",name:"confirmPassword",className:"w-full p-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500",value:f,onChange:R,required:!0,minLength:6})]}),c.jsxs("div",{className:"flex justify-end space-x-2",children:[s&&c.jsx("button",{type:"button",onClick:s,disabled:y,className:"py-2 px-4 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",children:r("common.cancel")}),c.jsx("button",{type:"submit",disabled:y,className:"py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",children:y?c.jsxs("span",{className:"flex items-center",children:[c.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),r("common.save")]}):r("common.save")})]})]})]})},Vb=()=>{const{t:l}=Te(),{showToast:s}=ps(),[r,o]=S.useState({enableGlobalRoute:!0,enableGroupNameRoute:!0,enableBearerAuth:!1,bearerAuthKey:""}),[d,f]=S.useState({bearerAuthKey:""}),[m,y]=S.useState({pythonIndexUrl:"",npmRegistry:""}),[h,g]=S.useState({enabled:!1,dbUrl:"",openaiApiBaseUrl:"",openaiApiKey:"",openaiApiEmbeddingModel:""}),[v,w]=S.useState(!1),[b,R]=S.useState(null),[N,C]=S.useState(0),A=S.useCallback(()=>{C(W=>W+1)},[]),z=S.useCallback(async()=>{var W,H,O,J,re,de;w(!0),R(null);try{const me=localStorage.getItem("mcphub_token"),ke=await fetch(Ee("/settings"),{headers:{"x-auth-token":me||""}});if(!ke.ok)throw new Error(`HTTP error! Status: ${ke.status}`);const oe=await ke.json();oe.success&&((H=(W=oe.data)==null?void 0:W.systemConfig)!=null&&H.routing)&&o({enableGlobalRoute:oe.data.systemConfig.routing.enableGlobalRoute??!0,enableGroupNameRoute:oe.data.systemConfig.routing.enableGroupNameRoute??!0,enableBearerAuth:oe.data.systemConfig.routing.enableBearerAuth??!1,bearerAuthKey:oe.data.systemConfig.routing.bearerAuthKey||""}),oe.success&&((J=(O=oe.data)==null?void 0:O.systemConfig)!=null&&J.install)&&y({pythonIndexUrl:oe.data.systemConfig.install.pythonIndexUrl||"",npmRegistry:oe.data.systemConfig.install.npmRegistry||""}),oe.success&&((de=(re=oe.data)==null?void 0:re.systemConfig)!=null&&de.smartRouting)&&g({enabled:oe.data.systemConfig.smartRouting.enabled??!1,dbUrl:oe.data.systemConfig.smartRouting.dbUrl||"",openaiApiBaseUrl:oe.data.systemConfig.smartRouting.openaiApiBaseUrl||"",openaiApiKey:oe.data.systemConfig.smartRouting.openaiApiKey||"",openaiApiEmbeddingModel:oe.data.systemConfig.smartRouting.openaiApiEmbeddingModel||""})}catch(me){console.error("Failed to fetch settings:",me),R(me instanceof Error?me.message:"Failed to fetch settings"),s(l("errors.failedToFetchSettings"))}finally{w(!1)}},[l]),T=async(W,H)=>{w(!0),R(null);try{const O=localStorage.getItem("mcphub_token"),J=await fetch(Ee("/system-config"),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":O||""},body:JSON.stringify({routing:{[W]:H}})});if(!J.ok)throw new Error(`HTTP error! Status: ${J.status}`);return(await J.json()).success?(o({...r,[W]:H}),s(l("settings.systemConfigUpdated")),!0):(s(l("errors.failedToUpdateRouteConfig")),!1)}catch(O){return console.error("Failed to update routing config:",O),R(O instanceof Error?O.message:"Failed to update routing config"),s(l("errors.failedToUpdateRouteConfig")),!1}finally{w(!1)}},D=async(W,H)=>{w(!0),R(null);try{const O=localStorage.getItem("mcphub_token"),J=await fetch(Ee("/system-config"),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":O||""},body:JSON.stringify({install:{[W]:H}})});if(!J.ok)throw new Error(`HTTP error! Status: ${J.status}`);return(await J.json()).success?(y({...m,[W]:H}),s(l("settings.systemConfigUpdated")),!0):(s(l("errors.failedToUpdateSystemConfig")),!1)}catch(O){return console.error("Failed to update system config:",O),R(O instanceof Error?O.message:"Failed to update system config"),s(l("errors.failedToUpdateSystemConfig")),!1}finally{w(!1)}},q=async(W,H)=>{w(!0),R(null);try{const O=localStorage.getItem("mcphub_token"),J=await fetch(Ee("/system-config"),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":O||""},body:JSON.stringify({smartRouting:{[W]:H}})});if(!J.ok){const de=await J.json();throw new Error(de.message||`HTTP error! Status: ${J.status}`)}const re=await J.json();return re.success?(g({...h,[W]:H}),s(l("settings.systemConfigUpdated")),!0):(s(re.message||l("errors.failedToUpdateSmartRoutingConfig")),!1)}catch(O){console.error("Failed to update smart routing config:",O);const J=O instanceof Error?O.message:"Failed to update smart routing config";return R(J),s(J),!1}finally{w(!1)}},Y=async W=>{w(!0),R(null);try{const H=localStorage.getItem("mcphub_token"),O=await fetch(Ee("/system-config"),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":H||""},body:JSON.stringify({smartRouting:W})});if(!O.ok){const re=await O.json();throw new Error(re.message||`HTTP error! Status: ${O.status}`)}const J=await O.json();return J.success?(g({...h,...W}),s(l("settings.systemConfigUpdated")),!0):(s(J.message||l("errors.failedToUpdateSmartRoutingConfig")),!1)}catch(H){console.error("Failed to update smart routing config:",H);const O=H instanceof Error?H.message:"Failed to update smart routing config";return R(O),s(O),!1}finally{w(!1)}};return S.useEffect(()=>{z()},[z,N]),S.useEffect(()=>{r&&f({bearerAuthKey:r.bearerAuthKey})},[r]),{routingConfig:r,tempRoutingConfig:d,setTempRoutingConfig:f,installConfig:m,smartRoutingConfig:h,loading:v,error:b,setError:R,triggerRefresh:A,fetchSettings:z,updateRoutingConfig:T,updateInstallConfig:D,updateSmartRoutingConfig:q,updateSmartRoutingConfigBatch:Y}};function Yb(l=32){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=new Uint8Array(l);return crypto.getRandomValues(r),Array.from(r).map(o=>s.charAt(o%s.length)).join("")}const Kb=()=>{const{t:l,i18n:s}=Te(),r=un(),{showToast:o}=ps(),[d,f]=S.useState(s.language);S.useEffect(()=>{f(s.language)},[s.language]);const[m,y]=S.useState({pythonIndexUrl:"",npmRegistry:""}),[h,g]=S.useState({dbUrl:"",openaiApiBaseUrl:"",openaiApiKey:"",openaiApiEmbeddingModel:""}),{routingConfig:v,tempRoutingConfig:w,setTempRoutingConfig:b,installConfig:R,smartRoutingConfig:N,loading:C,updateRoutingConfig:A,updateInstallConfig:z,updateSmartRoutingConfig:T,updateSmartRoutingConfigBatch:D}=Vb();S.useEffect(()=>{R&&y(R)},[R]),S.useEffect(()=>{N&&g({dbUrl:N.dbUrl||"",openaiApiBaseUrl:N.openaiApiBaseUrl||"",openaiApiKey:N.openaiApiKey||"",openaiApiEmbeddingModel:N.openaiApiEmbeddingModel||""})},[N]);const[q,Y]=S.useState({routingConfig:!1,installConfig:!1,smartRoutingConfig:!1,password:!1}),W=V=>{Y($=>({...$,[V]:!$[V]}))},H=async(V,$)=>{if(await A(V,$),V==="enableBearerAuth"&&$===!0&&!w.bearerAuthKey){const ue=Yb();O(ue),await A("bearerAuthKey",ue)}},O=V=>{b($=>({...$,bearerAuthKey:V}))},J=async()=>{await A("bearerAuthKey",w.bearerAuthKey)},re=(V,$)=>{y({...m,[V]:$})},de=async V=>{await z(V,m[V])},me=(V,$)=>{g({...h,[V]:$})},ke=async V=>{await T(V,h[V])},oe=async V=>{if(V){const $=h.dbUrl||N.dbUrl,ue=h.openaiApiKey||N.openaiApiKey;if(!$||!ue){const Q=[];$||Q.push(l("settings.dbUrl")),ue||Q.push(l("settings.openaiApiKey")),o(l("settings.smartRoutingValidationError",{fields:Q.join(", ")}));return}const E={enabled:V};h.dbUrl!==N.dbUrl&&(E.dbUrl=h.dbUrl),h.openaiApiBaseUrl!==N.openaiApiBaseUrl&&(E.openaiApiBaseUrl=h.openaiApiBaseUrl),h.openaiApiKey!==N.openaiApiKey&&(E.openaiApiKey=h.openaiApiKey),h.openaiApiEmbeddingModel!==N.openaiApiEmbeddingModel&&(E.openaiApiEmbeddingModel=h.openaiApiEmbeddingModel),await D(E)}else await T("enabled",V)},xe=()=>{setTimeout(()=>{r("/")},2e3)},G=V=>{localStorage.setItem("i18nextLng",V),window.location.reload()};return c.jsxs("div",{className:"container mx-auto",children:[c.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-8",children:l("pages.settings.title")}),c.jsx("div",{className:"bg-white shadow rounded-lg py-4 px-6 mb-6",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"font-semibold text-gray-800",children:l("pages.settings.language")}),c.jsxs("div",{className:"flex space-x-3",children:[c.jsx("button",{className:`px-3 py-1.5 rounded-md transition-colors text-sm ${d.startsWith("en")?"bg-blue-500 text-white":"bg-blue-100 text-blue-800 hover:bg-blue-200"}`,onClick:()=>G("en"),children:"English"}),c.jsx("button",{className:`px-3 py-1.5 rounded-md transition-colors text-sm ${d.startsWith("zh")?"bg-blue-500 text-white":"bg-blue-100 text-blue-800 hover:bg-blue-200"}`,onClick:()=>G("zh"),children:"中文"})]})]})}),c.jsxs("div",{className:"bg-white shadow rounded-lg py-4 px-6 mb-6",children:[c.jsxs("div",{className:"flex justify-between items-center cursor-pointer",onClick:()=>W("smartRoutingConfig"),children:[c.jsx("h2",{className:"font-semibold text-gray-800",children:l("pages.settings.smartRouting")}),c.jsx("span",{className:"text-gray-500",children:q.smartRoutingConfig?"▼":"►"})]}),q.smartRoutingConfig&&c.jsxs("div",{className:"space-y-4 mt-4",children:[c.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.enableSmartRouting")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.enableSmartRoutingDescription")})]}),c.jsx(_r,{disabled:C,checked:N.enabled,onCheckedChange:V=>oe(V)})]}),c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsx("div",{className:"mb-2",children:c.jsxs("h3",{className:"font-medium text-gray-700",children:[c.jsx("span",{className:"text-red-500 px-1",children:"*"}),l("settings.dbUrl")]})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"text",value:h.dbUrl,onChange:V=>me("dbUrl",V.target.value),placeholder:l("settings.dbUrlPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm border-gray-300",disabled:C}),c.jsx("button",{onClick:()=>ke("dbUrl"),disabled:C,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]}),c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsx("div",{className:"mb-2",children:c.jsxs("h3",{className:"font-medium text-gray-700",children:[c.jsx("span",{className:"text-red-500 px-1",children:"*"}),l("settings.openaiApiKey")]})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"password",value:h.openaiApiKey,onChange:V=>me("openaiApiKey",V.target.value),placeholder:l("settings.openaiApiKeyPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm border-gray-300",disabled:C}),c.jsx("button",{onClick:()=>ke("openaiApiKey"),disabled:C,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]}),c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsx("div",{className:"mb-2",children:c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.openaiApiBaseUrl")})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"text",value:h.openaiApiBaseUrl,onChange:V=>me("openaiApiBaseUrl",V.target.value),placeholder:l("settings.openaiApiBaseUrlPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm",disabled:C}),c.jsx("button",{onClick:()=>ke("openaiApiBaseUrl"),disabled:C,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]}),c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsx("div",{className:"mb-2",children:c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.openaiApiEmbeddingModel")})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"text",value:h.openaiApiEmbeddingModel,onChange:V=>me("openaiApiEmbeddingModel",V.target.value),placeholder:l("settings.openaiApiEmbeddingModelPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm",disabled:C}),c.jsx("button",{onClick:()=>ke("openaiApiEmbeddingModel"),disabled:C,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]})]})]}),c.jsxs("div",{className:"bg-white shadow rounded-lg py-4 px-6 mb-6",children:[c.jsxs("div",{className:"flex justify-between items-center cursor-pointer",onClick:()=>W("routingConfig"),children:[c.jsx("h2",{className:"font-semibold text-gray-800",children:l("pages.settings.routeConfig")}),c.jsx("span",{className:"text-gray-500",children:q.routingConfig?"▼":"►"})]}),q.routingConfig&&c.jsxs("div",{className:"space-y-4 mt-4",children:[c.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.enableBearerAuth")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.enableBearerAuthDescription")})]}),c.jsx(_r,{disabled:C,checked:v.enableBearerAuth,onCheckedChange:V=>H("enableBearerAuth",V)})]}),v.enableBearerAuth&&c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{className:"mb-2",children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.bearerAuthKey")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.bearerAuthKeyDescription")})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"text",value:w.bearerAuthKey,onChange:V=>O(V.target.value),placeholder:l("settings.bearerAuthKeyPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm",disabled:C||!v.enableBearerAuth}),c.jsx("button",{onClick:J,disabled:C||!v.enableBearerAuth,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]}),c.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.enableGlobalRoute")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.enableGlobalRouteDescription")})]}),c.jsx(_r,{disabled:C,checked:v.enableGlobalRoute,onCheckedChange:V=>H("enableGlobalRoute",V)})]}),c.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.enableGroupNameRoute")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.enableGroupNameRouteDescription")})]}),c.jsx(_r,{disabled:C,checked:v.enableGroupNameRoute,onCheckedChange:V=>H("enableGroupNameRoute",V)})]})]})]}),c.jsxs("div",{className:"bg-white shadow rounded-lg py-4 px-6 mb-6",children:[c.jsxs("div",{className:"flex justify-between items-center cursor-pointer",onClick:()=>W("installConfig"),children:[c.jsx("h2",{className:"font-semibold text-gray-800",children:l("settings.installConfig")}),c.jsx("span",{className:"text-gray-500",children:q.installConfig?"▼":"►"})]}),q.installConfig&&c.jsxs("div",{className:"space-y-4 mt-4",children:[c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{className:"mb-2",children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.pythonIndexUrl")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.pythonIndexUrlDescription")})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"text",value:m.pythonIndexUrl,onChange:V=>re("pythonIndexUrl",V.target.value),placeholder:l("settings.pythonIndexUrlPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm",disabled:C}),c.jsx("button",{onClick:()=>de("pythonIndexUrl"),disabled:C,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]}),c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{className:"mb-2",children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.npmRegistry")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.npmRegistryDescription")})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"text",value:m.npmRegistry,onChange:V=>re("npmRegistry",V.target.value),placeholder:l("settings.npmRegistryPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm",disabled:C}),c.jsx("button",{onClick:()=>de("npmRegistry"),disabled:C,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]})]})]}),c.jsxs("div",{className:"bg-white shadow rounded-lg py-4 px-6 mb-6",children:[c.jsxs("div",{className:"flex justify-between items-center cursor-pointer",onClick:()=>W("password"),children:[c.jsx("h2",{className:"font-semibold text-gray-800",children:l("auth.changePassword")}),c.jsx("span",{className:"text-gray-500",children:q.password?"▼":"►"})]}),q.password&&c.jsx("div",{className:"max-w-lg mt-4",children:c.jsx(qb,{onSuccess:xe})})]})]})},$b=()=>{const{t:l}=Te(),[s,r]=S.useState([]),[o,d]=S.useState([]),[f,m]=S.useState([]),[y,h]=S.useState([]),[g,v]=S.useState(""),[w,b]=S.useState(""),[R,N]=S.useState(""),[C,A]=S.useState(!0),[z,T]=S.useState(null),[D,q]=S.useState(null),[Y,W]=S.useState([]),[H,O]=S.useState(1),[J,re]=S.useState(9),[de,me]=S.useState(1),ke=S.useCallback(async()=>{try{A(!0);const F=localStorage.getItem("mcphub_token"),I=await fetch(Ee("/market/servers"),{headers:{"x-auth-token":F||""}});if(!I.ok)throw new Error(`Status: ${I.status}`);const ae=await I.json();ae&&ae.success&&Array.isArray(ae.data)?(d(ae.data),oe(ae.data,H)):(console.error("Invalid market servers data format:",ae),T(l("market.fetchError")))}catch(F){console.error("Error fetching market servers:",F),T(F instanceof Error?F.message:String(F))}finally{A(!1)}},[l]),oe=S.useCallback((F,I,ae=J)=>{const ce=F.length,et=Math.ceil(ce/ae);me(et);const ct=Math.max(1,Math.min(I,et));ct!==I&&O(ct);const pt=(ct-1)*ae,Ft=F.slice(pt,pt+ae);r(Ft)},[J]),xe=S.useCallback(F=>{O(F),oe(o,F,J)},[o,oe,J]),G=S.useCallback(async()=>{try{const F=localStorage.getItem("mcphub_token"),I=await fetch(Ee("/market/categories"),{headers:{"x-auth-token":F||""}});if(!I.ok)throw new Error(`Status: ${I.status}`);const ae=await I.json();ae&&ae.success&&Array.isArray(ae.data)?m(ae.data):console.error("Invalid categories data format:",ae)}catch(F){console.error("Error fetching categories:",F)}},[]),V=S.useCallback(async()=>{try{const F=localStorage.getItem("mcphub_token"),I=await fetch(Ee("/market/tags"),{headers:{"x-auth-token":F||""}});if(!I.ok)throw new Error(`Status: ${I.status}`);const ae=await I.json();ae&&ae.success&&Array.isArray(ae.data)?h(ae.data):console.error("Invalid tags data format:",ae)}catch(F){console.error("Error fetching tags:",F)}},[]),$=S.useCallback(async F=>{try{A(!0);const I=localStorage.getItem("mcphub_token"),ae=await fetch(Ee(`/market/servers/${F}`),{headers:{"x-auth-token":I||""}});if(!ae.ok)throw new Error(`Status: ${ae.status}`);const ce=await ae.json();return ce&&ce.success&&ce.data?(q(ce.data),ce.data):(console.error("Invalid server data format:",ce),T(l("market.serverNotFound")),null)}catch(I){return console.error(`Error fetching server ${F}:`,I),T(I instanceof Error?I.message:String(I)),null}finally{A(!1)}},[l]),ue=S.useCallback(async F=>{try{if(A(!0),N(F),!F.trim()){ke();return}const I=localStorage.getItem("mcphub_token"),ae=await fetch(Ee(`/market/servers/search?query=${encodeURIComponent(F)}`),{headers:{"x-auth-token":I||""}});if(!ae.ok)throw new Error(`Status: ${ae.status}`);const ce=await ae.json();ce&&ce.success&&Array.isArray(ce.data)?(d(ce.data),O(1),oe(ce.data,1)):(console.error("Invalid search results format:",ce),T(l("market.searchError")))}catch(I){console.error("Error searching servers:",I),T(I instanceof Error?I.message:String(I))}finally{A(!1)}},[l,o,oe,ke]),E=S.useCallback(async F=>{try{if(A(!0),v(F),b(""),!F){ke();return}const I=localStorage.getItem("mcphub_token"),ae=await fetch(Ee(`/market/categories/${encodeURIComponent(F)}`),{headers:{"x-auth-token":I||""}});if(!ae.ok)throw new Error(`Status: ${ae.status}`);const ce=await ae.json();ce&&ce.success&&Array.isArray(ce.data)?(d(ce.data),O(1),oe(ce.data,1)):(console.error("Invalid category filter results format:",ce),T(l("market.filterError")))}catch(I){console.error("Error filtering servers by category:",I),T(I instanceof Error?I.message:String(I))}finally{A(!1)}},[l,ke,oe]),Q=S.useCallback(async F=>{try{if(A(!0),b(F),v(""),!F){ke();return}const I=localStorage.getItem("mcphub_token"),ae=await fetch(Ee(`/market/tags/${encodeURIComponent(F)}`),{headers:{"x-auth-token":I||""}});if(!ae.ok)throw new Error(`Status: ${ae.status}`);const ce=await ae.json();ce&&ce.success&&Array.isArray(ce.data)?(d(ce.data),O(1),oe(ce.data,1)):(console.error("Invalid tag filter results format:",ce),T(l("market.tagFilterError")))}catch(I){console.error("Error filtering servers by tag:",I),T(I instanceof Error?I.message:String(I))}finally{A(!1)}},[l,ke,oe]),ee=S.useCallback(async()=>{try{const F=localStorage.getItem("mcphub_token"),I=await fetch(Ee("/servers"),{headers:{"x-auth-token":F||""}});if(!I.ok)throw new Error(`Status: ${I.status}`);const ae=await I.json();if(ae&&ae.success&&Array.isArray(ae.data)){const ce=ae.data.map(et=>et.name);W(ce)}}catch(F){console.error("Error fetching installed servers:",F)}},[]),Z=S.useCallback(F=>Y.includes(F),[Y]),te=S.useCallback(async F=>{var I,ae;try{const ce=(I=F.installations)!=null&&I.npm?"npm":Object.keys(F.installations||{}).length>0?Object.keys(F.installations)[0]:null;if(!ce||!((ae=F.installations)!=null&&ae[ce]))return T(l("market.noInstallationMethod")),!1;const et=F.installations[ce],ct={name:F.name,config:{command:et.command,args:et.args,env:et.env||{}}},pt=localStorage.getItem("mcphub_token"),Ft=await fetch(Ee("/servers"),{method:"POST",headers:{"Content-Type":"application/json","x-auth-token":pt||""},body:JSON.stringify(ct)});if(!Ft.ok){const sl=await Ft.json();throw new Error(sl.message||`Status: ${Ft.status}`)}return await ee(),!0}catch(ce){return console.error("Error installing server:",ce),T(ce instanceof Error?ce.message:String(ce)),!1}},[l,ee]),ve=S.useCallback(F=>{re(F),O(1),oe(o,1,F)},[o,oe]);return S.useEffect(()=>{ke(),G(),V(),ee()},[ke,G,V,ee]),{servers:s,allServers:o,categories:f,tags:y,selectedCategory:g,selectedTag:w,searchQuery:R,loading:C,error:z,setError:T,currentServer:D,fetchMarketServers:ke,fetchServerByName:$,searchServers:ue,filterByCategory:E,filterByTag:Q,installServer:te,currentPage:H,totalPages:de,serversPerPage:J,changePage:xe,changeServersPerPage:ve,isServerInstalled:Z}},Qb=({server:l,onClick:s})=>{var y,h,g,v;const{t:r}=Te(),o=()=>{if(!l.tags||l.tags.length===0)return{tagsToShow:[],hasMore:!1,moreCount:0};const w=28,b=T=>T.length+3;let R=0,N=0;const C=[...l.tags].sort((T,D)=>T.length-D.length);for(N=0;N<C.length;N++){const T=b(C[N]);if(R+T>w)break;if(R+=T,N===C.length-1)return{tagsToShow:C,hasMore:!1,moreCount:0}}N===0&&C.length>0&&(N=1);const A=C.length-N,z=3+String(A).length+r("market.moreTags").length;return R+z<=w||N<1?{tagsToShow:C.slice(0,N),hasMore:!0,moreCount:A}:{tagsToShow:C.slice(0,Math.max(1,N-1)),hasMore:!0,moreCount:A+1}},{tagsToShow:d,hasMore:f,moreCount:m}=o();return c.jsxs("div",{className:"bg-white rounded-lg shadow-md p-5 hover:shadow-lg transition-shadow cursor-pointer flex flex-col h-full",onClick:()=>s(l),children:[c.jsxs("div",{className:"flex justify-between items-start mb-3",children:[c.jsx("h3",{className:"text-lg font-semibold text-gray-900 line-clamp-1 mr-2",children:l.display_name}),l.is_official&&c.jsx("span",{className:"bg-blue-100 text-blue-800 text-xs font-medium px-2.5 py-0.5 rounded flex-shrink-0",children:r("market.official")})]}),c.jsx("p",{className:"text-gray-600 text-sm mb-4 line-clamp-2 min-h-[40px]",children:l.description}),c.jsx("div",{className:"flex flex-wrap gap-1 mb-2 min-h-[28px]",children:((y=l.categories)==null?void 0:y.length)>0?l.categories.map((w,b)=>c.jsx("span",{className:"bg-gray-100 text-gray-800 text-xs px-2 py-1 rounded whitespace-nowrap",children:w},b)):c.jsx("span",{className:"text-xs text-gray-400 py-1",children:"-"})}),c.jsx("div",{className:"relative mb-3 min-h-[28px] overflow-x-auto",children:((h=l.tags)==null?void 0:h.length)>0?c.jsxs("div",{className:"flex gap-1 items-center whitespace-nowrap",children:[d.map((w,b)=>c.jsxs("span",{className:"bg-green-50 text-green-700 text-xs px-2 py-1 rounded flex-shrink-0",children:["#",w]},b)),f&&c.jsxs("span",{className:"bg-gray-100 text-gray-600 text-xs px-1.5 py-1 rounded flex-shrink-0",children:["+",m," ",r("market.moreTags")]})]}):c.jsx("span",{className:"text-xs text-gray-400 py-1",children:"-"})}),c.jsxs("div",{className:"flex justify-between items-center mt-auto pt-2 text-xs text-gray-500 border-t border-gray-100",children:[c.jsxs("div",{className:"overflow-hidden",children:[c.jsxs("span",{className:"whitespace-nowrap",children:[r("market.by")," "]}),c.jsx("span",{className:"font-medium whitespace-nowrap overflow-hidden text-ellipsis max-w-[120px] inline-block align-bottom",children:((g=l.author)==null?void 0:g.name)||r("market.unknown")})]}),c.jsxs("div",{className:"flex items-center flex-shrink-0",children:[c.jsx("svg",{className:"h-4 w-4 mr-1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M11.3 1.046A1 1 0 0112 2v5h4a1 1 0 01.82 1.573l-7 10A1 1 0 018 18v-5H4a1 1 0 01-.82-1.573l7-10a1 1 0 011.12-.38z",clipRule:"evenodd"})}),c.jsxs("span",{children:[((v=l.tools)==null?void 0:v.length)||0," ",r("market.tools")]})]})]})]})},Xb=({server:l,onBack:s,onInstall:r,installing:o=!1,isInstalled:d=!1})=>{var z,T;const{t:f}=Te(),[m,y]=S.useState(!1),[h,g]=S.useState(null),v=()=>d?{className:"bg-green-600 cursor-default px-4 py-2 rounded text-sm font-medium text-white",disabled:!0,text:f("market.installed")}:o?{className:"bg-gray-400 cursor-not-allowed px-4 py-2 rounded text-sm font-medium text-white",disabled:!0,text:f("market.installing")}:{className:"bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded text-sm font-medium text-white",disabled:!1,text:f("market.install")},w=()=>{y(!m),g(null)},b=()=>{d||w()},R=()=>{if(!l.installations)return;if(l.installations.npm)return l.installations.npm;if(l.installations.uvx)return l.installations.uvx;if(l.installations.default)return l.installations.default;const D=Object.keys(l.installations);if(D.length>0)return l.installations[D[0]]},N=async D=>{try{g(null),r(l),y(!1)}catch(q){console.error("Error installing server:",q),g(f("errors.serverInstall"))}},C=v(),A=R();return c.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6",children:[c.jsx("div",{className:"mb-4",children:c.jsxs("button",{onClick:s,className:"text-gray-600 hover:text-gray-900 flex items-center",children:[c.jsx("svg",{className:"h-5 w-5 mr-1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"})}),f("market.backToList")]})}),c.jsxs("div",{className:"flex justify-between items-start mb-4",children:[c.jsx("div",{children:c.jsxs("h2",{className:"text-2xl font-bold text-gray-900 flex items-center flex-wrap",children:[l.display_name,c.jsxs("span",{className:"text-sm font-normal text-gray-500 ml-2",children:["(",l.name,")"]}),c.jsxs("span",{className:"text-sm font-normal text-gray-600 ml-4",children:[f("market.author"),": ",l.author.name," • ",f("market.license"),": ",l.license," •",c.jsx("a",{href:l.repository.url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline ml-1",children:f("market.repository")})]})]})}),c.jsxs("div",{className:"flex items-center",children:[l.is_official&&c.jsx("span",{className:"bg-blue-100 text-blue-800 text-sm font-medium px-4 py-2 rounded mr-2 flex items-center",children:f("market.official")}),c.jsx("button",{onClick:b,disabled:C.disabled,className:C.className,children:C.text})]})]}),c.jsx("p",{className:"text-gray-700 mb-6",children:l.description}),c.jsxs("div",{className:"mb-6",children:[c.jsxs("h3",{className:"text-lg font-semibold mb-3",children:[f("market.categories")," & ",f("market.tags")]}),c.jsxs("div",{className:"flex flex-wrap gap-2",children:[(z=l.categories)==null?void 0:z.map((D,q)=>c.jsx("span",{className:"bg-gray-100 text-gray-800 px-3 py-1 rounded",children:D},`cat-${q}`)),l.tags&&l.tags.map((D,q)=>c.jsxs("span",{className:"bg-gray-100 text-green-700 px-2 py-1 rounded text-sm",children:["#",D]},`tag-${q}`))]})]}),l.arguments&&Object.keys(l.arguments).length>0&&c.jsxs("div",{className:"mb-6",children:[c.jsx("h3",{className:"text-lg font-semibold mb-3",children:f("market.arguments")}),c.jsx("div",{className:"overflow-x-auto",children:c.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[c.jsx("thead",{className:"bg-gray-50",children:c.jsxs("tr",{children:[c.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:f("market.argumentName")}),c.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:f("market.description")}),c.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:f("market.required")}),c.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:f("market.example")})]})}),c.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:Object.entries(l.arguments).map(([D,q],Y)=>c.jsxs("tr",{children:[c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:D}),c.jsx("td",{className:"px-6 py-4 text-sm text-gray-500",children:q.description}),c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:q.required?c.jsx("span",{className:"text-green-600",children:"✓"}):c.jsx("span",{className:"text-red-600",children:"✗"})}),c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:c.jsx("code",{className:"bg-gray-100 px-2 py-1 rounded",children:q.example})})]},Y))})]})})]}),c.jsxs("div",{className:"mb-6",children:[c.jsx("h3",{className:"text-lg font-semibold mb-3",children:f("market.tools")}),c.jsx("div",{className:"space-y-4",children:(T=l.tools)==null?void 0:T.map((D,q)=>c.jsxs("div",{className:"border border-gray-200 rounded p-4",children:[c.jsxs("h4",{className:"font-medium mb-2",children:[D.name,c.jsx("button",{type:"button",onClick:()=>{const Y=document.getElementById(`schema-${q}`);Y&&Y.classList.toggle("hidden")},className:"text-sm text-blue-600 hover:underline focus:outline-none ml-2",children:f("market.viewSchema")})]}),c.jsx("p",{className:"text-gray-600 mb-2",children:D.description}),c.jsx("div",{className:"mt-2",children:c.jsx("pre",{id:`schema-${q}`,className:"hidden bg-gray-50 p-3 rounded text-sm overflow-auto mt-2",children:JSON.stringify(D.inputSchema,null,2)})})]},q))})]}),l.examples&&l.examples.length>0&&c.jsxs("div",{className:"mb-6",children:[c.jsx("h3",{className:"text-lg font-semibold mb-3",children:f("market.examples")}),c.jsx("div",{className:"space-y-4",children:l.examples.map((D,q)=>c.jsxs("div",{className:"border border-gray-200 rounded p-4",children:[c.jsx("h4",{className:"font-medium mb-2",children:D.title}),c.jsx("p",{className:"text-gray-600 mb-2",children:D.description}),c.jsx("pre",{className:"bg-gray-50 p-3 rounded text-sm overflow-auto",children:D.prompt})]},q))})]}),c.jsx("div",{className:"mt-6 flex justify-end",children:c.jsx("button",{onClick:b,disabled:C.disabled,className:C.className,children:C.text})}),m&&c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx(qu,{onSubmit:N,onCancel:w,modalTitle:f("market.installServer",{name:l.display_name}),formError:h,initialData:{name:l.name,status:"disconnected",config:A?{command:A.command||"",args:A.args||[],env:A.env||{}}:void 0}})})]})},Zb=({currentPage:l,totalPages:s,onPageChange:r})=>{const o=()=>{const d=[];d.push(c.jsx("button",{onClick:()=>r(1),className:`px-3 py-1 mx-1 rounded ${l===1?"bg-blue-500 text-white":"bg-gray-200 hover:bg-gray-300 text-gray-700"}`,children:"1"},"first"));let m=Math.max(2,l-Math.floor(5/2));m>2&&d.push(c.jsx("span",{className:"px-3 py-1",children:"..."},"ellipsis1"));for(let y=m;y<=Math.min(s-1,m+5-3);y++)d.push(c.jsx("button",{onClick:()=>r(y),className:`px-3 py-1 mx-1 rounded ${l===y?"bg-blue-500 text-white":"bg-gray-200 hover:bg-gray-300 text-gray-700"}`,children:y},y));return m+5-3<s-1&&d.push(c.jsx("span",{className:"px-3 py-1",children:"..."},"ellipsis2")),s>1&&d.push(c.jsx("button",{onClick:()=>r(s),className:`px-3 py-1 mx-1 rounded ${l===s?"bg-blue-500 text-white":"bg-gray-200 hover:bg-gray-300 text-gray-700"}`,children:s},"last")),d};return s<=1?null:c.jsxs("div",{className:"flex justify-center items-center my-6",children:[c.jsx("button",{onClick:()=>r(Math.max(1,l-1)),disabled:l===1,className:`px-3 py-1 rounded mr-2 ${l===1?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-200 hover:bg-gray-300 text-gray-700"}`,children:"« Prev"}),c.jsx("div",{className:"flex",children:o()}),c.jsx("button",{onClick:()=>r(Math.min(s,l+1)),disabled:l===s,className:`px-3 py-1 rounded ml-2 ${l===s?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-200 hover:bg-gray-300 text-gray-700"}`,children:"Next »"})]})},rm=()=>{const{t:l}=Te(),s=un();Jt();const{serverName:r}=zy(),{showToast:o}=ps(),{servers:d,allServers:f,categories:m,loading:y,error:h,setError:g,searchServers:v,filterByCategory:w,filterByTag:b,selectedCategory:R,selectedTag:N,installServer:C,fetchServerByName:A,isServerInstalled:z,currentPage:T,totalPages:D,changePage:q,serversPerPage:Y,changeServersPerPage:W}=$b(),[H,O]=S.useState(null),[J,re]=S.useState(""),[de,me]=S.useState(!1),[ke,oe]=S.useState(!1);S.useEffect(()=>{(async()=>{if(r){const te=await A(r);te?O(te):s("/market")}else O(null)})()},[r,A,s]);const xe=Z=>{Z.preventDefault(),v(J)},G=Z=>{w(Z)},V=()=>{re(""),w(""),b("")},$=Z=>{s(`/market/${Z.name}`)},ue=()=>{s("/market")},E=async Z=>{try{me(!0),await C(Z)&&o(l("market.installSuccess",{serverName:Z.display_name}),"success")}finally{me(!1)}},Q=Z=>{q(Z),window.scrollTo({top:0,behavior:"smooth"})},ee=Z=>{const te=parseInt(Z.target.value,10);W(te)};return H?c.jsx(Xb,{server:H,onBack:ue,onInstall:E,installing:de,isInstalled:z(H.name)}):c.jsxs("div",{children:[c.jsx("div",{className:"flex justify-between items-center mb-8",children:c.jsx("div",{children:c.jsxs("h1",{className:"text-2xl font-bold text-gray-900 flex items-center",children:[l("market.title"),c.jsx("span",{className:"text-sm text-gray-500 font-normal ml-2",children:l("pages.market.title").split(" - ")[1]})]})})}),h&&c.jsx("div",{className:"bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-6",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{children:h}),c.jsx("button",{onClick:()=>g(null),className:"text-red-700 hover:text-red-900",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 011.414 0L10 8.586l4.293-4.293a1 1 01.414 1.414L11.414 10l4.293 4.293a1 1 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 01-1.414-1.414L8.586 10 4.293 5.707a1 1 010-1.414z",clipRule:"evenodd"})})})]})}),c.jsx("div",{className:"bg-white shadow rounded-lg p-6 mb-6",children:c.jsxs("form",{onSubmit:xe,className:"flex space-x-4 mb-0",children:[c.jsx("div",{className:"flex-grow",children:c.jsx("input",{type:"text",value:J,onChange:Z=>re(Z.target.value),placeholder:l("market.searchPlaceholder"),className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"})}),c.jsx("button",{type:"submit",className:"bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded",children:l("market.search")}),(J||R||N)&&c.jsx("button",{type:"button",onClick:V,className:"border border-gray-300 text-gray-700 font-medium py-2 px-4 rounded hover:bg-gray-50",children:l("market.clearFilters")})]})}),c.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[c.jsx("div",{className:"md:w-48 flex-shrink-0",children:c.jsx("div",{className:"bg-white shadow rounded-lg p-4 mb-6 sticky top-4",children:m.length>0?c.jsxs("div",{className:"mb-6",children:[c.jsxs("div",{className:"flex justify-between items-center mb-3",children:[c.jsx("h3",{className:"font-medium text-gray-900",children:l("market.categories")}),R&&c.jsx("span",{className:"text-xs text-blue-600 cursor-pointer hover:underline",onClick:()=>w(""),children:l("market.clearCategoryFilter")})]}),c.jsx("div",{className:"flex flex-col gap-2",children:m.map(Z=>c.jsx("button",{onClick:()=>G(Z),className:`px-3 py-2 rounded text-sm text-left ${R===Z?"bg-blue-100 text-blue-800 font-medium":"bg-gray-100 text-gray-800 hover:bg-gray-200"}`,children:Z},Z))})]}):y?c.jsxs("div",{className:"mb-6",children:[c.jsx("div",{className:"mb-3",children:c.jsx("h3",{className:"font-medium text-gray-900",children:l("market.categories")})}),c.jsxs("div",{className:"flex flex-col gap-2 items-center py-4",children:[c.jsxs("svg",{className:"animate-spin h-6 w-6 text-blue-500 mb-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c.jsx("p",{className:"text-sm text-gray-600",children:l("app.loading")})]})]}):c.jsxs("div",{className:"mb-6",children:[c.jsx("div",{className:"mb-3",children:c.jsx("h3",{className:"font-medium text-gray-900",children:l("market.categories")})}),c.jsx("p",{className:"text-sm text-gray-600 py-2",children:l("market.noCategories")})]})})}),c.jsx("div",{className:"flex-grow",children:y?c.jsx("div",{className:"bg-white shadow rounded-lg p-6 flex items-center justify-center",children:c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsxs("svg",{className:"animate-spin h-10 w-10 text-blue-500 mb-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c.jsx("p",{className:"text-gray-600",children:l("app.loading")})]})}):d.length===0?c.jsx("div",{className:"bg-white shadow rounded-lg p-6",children:c.jsx("p",{className:"text-gray-600",children:l("market.noServers")})}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 gap-6",children:d.map((Z,te)=>c.jsx(Qb,{server:Z,onClick:$},te))}),c.jsxs("div",{className:"flex justify-between items-center mb-4",children:[c.jsx("div",{className:"text-sm text-gray-500",children:l("market.showing",{from:(T-1)*Y+1,to:Math.min(T*Y,f.length),total:f.length})}),c.jsx(Zb,{currentPage:T,totalPages:D,onPageChange:Q}),c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsxs("label",{htmlFor:"perPage",className:"text-sm text-gray-600",children:[l("market.perPage"),":"]}),c.jsxs("select",{id:"perPage",value:Y,onChange:ee,className:"border rounded p-1 text-sm",children:[c.jsx("option",{value:"6",children:"6"}),c.jsx("option",{value:"9",children:"9"}),c.jsx("option",{value:"12",children:"12"}),c.jsx("option",{value:"24",children:"24"})]})]})]}),c.jsx("div",{className:"mt-6"})]})})]})]})},Pb={default:"bg-blue-500 text-white hover:bg-blue-600 focus:ring-blue-500",outline:"border border-gray-300 dark:border-gray-700 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300",ghost:"bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300",link:"bg-transparent underline-offset-4 hover:underline text-blue-500 hover:text-blue-600",destructive:"bg-red-500 text-white hover:bg-red-600 focus:ring-red-500"},Jb={default:"h-10 py-2 px-4",sm:"h-8 px-3 text-sm",lg:"h-12 px-6",icon:"h-10 w-10 p-0"};function Fb({variant:l="default",size:s="default",className:r,disabled:o,children:d,...f}){return c.jsx("button",{className:qa("rounded-md inline-flex items-center justify-center font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none",Pb[l],Jb[s],r),disabled:o,...f,children:d})}const Wb=({logs:l,isLoading:s=!1,error:r=null,onClear:o})=>{const{t:d}=Te(),f=S.useRef(null),[m,y]=S.useState(!0),[h,g]=S.useState(""),[v,w]=S.useState(["info","error","warn","debug"]),[b,R]=S.useState(["main","child"]);S.useEffect(()=>{m&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[l,m]);const N=l.filter(T=>{const D=h?T.message.toLowerCase().includes(h.toLowerCase()):!0,q=v.includes(T.type),Y=b.includes(T.source);return D&&q&&Y}),C=T=>new Date(T).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),A=T=>{switch(T){case"error":return"bg-red-400";case"warn":return"bg-yellow-400";case"debug":return"bg-purple-400";default:return"bg-blue-400"}},z=T=>{switch(T){case"main":return"bg-green-400";case"child":return"bg-orange-400";default:return"bg-gray-400"}};return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"bg-card p-3 rounded-t-md border-b flex flex-wrap items-center justify-between gap-2",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsxs("span",{className:"font-semibold text-sm",children:[d("logs.filters"),":"]}),c.jsx("input",{type:"text",placeholder:d("logs.search"),className:"px-2 py-1 text-sm border rounded",value:h,onChange:T=>g(T.target.value)}),c.jsx("div",{className:"flex gap-1 items-center",children:["info","error","warn","debug"].map(T=>c.jsx(Lr,{variant:v.includes(T)?"default":"outline",className:`cursor-pointer ${v.includes(T)?A(T):""}`,onClick:()=>{v.includes(T)?w(D=>D.filter(q=>q!==T)):w(D=>[...D,T])},children:T},T))}),c.jsx("div",{className:"flex gap-1 items-center ml-2",children:["main","child"].map(T=>c.jsx(Lr,{variant:b.includes(T)?"default":"outline",className:`cursor-pointer ${b.includes(T)?z(T):""}`,onClick:()=>{b.includes(T)?R(D=>D.filter(q=>q!==T)):R(D=>[...D,T])},children:d(T==="main"?"logs.mainProcess":"logs.childProcess")},T))})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[c.jsx("input",{type:"checkbox",checked:m,onChange:()=>y(!m),className:"form-checkbox h-4 w-4"}),d("logs.autoScroll")]}),c.jsx(Fb,{variant:"outline",size:"sm",onClick:o,disabled:s||l.length===0,children:d("logs.clearLogs")})]})]}),c.jsx("div",{ref:f,className:"flex-grow p-2 overflow-auto bg-card rounded-b-md font-mono text-sm",style:{maxHeight:"calc(100vh - 300px)"},children:s?c.jsx("div",{className:"flex justify-center items-center h-full",children:c.jsx("span",{children:d("logs.loading")})}):r?c.jsx("div",{className:"text-red-500 p-2",children:r.message}):N.length===0?c.jsx("div",{className:"text-center text-muted-foreground p-8",children:h||v.length<4||b.length<2?d("logs.noMatch"):d("logs.noLogs")}):N.map((T,D)=>c.jsxs("div",{className:`py-1 border-b border-gray-100 dark:border-gray-800 ${T.type==="error"?"text-red-500":T.type==="warn"?"text-yellow-500":""}`,children:[c.jsxs("span",{className:"text-gray-400",children:["[",C(T.timestamp),"]"]}),c.jsx(Lr,{className:`ml-2 mr-1 ${A(T.type)}`,children:T.type}),c.jsxs(Lr,{variant:"default",className:`mr-2 ${z(T.source)}`,children:[T.source==="main"?d("logs.main"):d("logs.child"),T.processId?` (${T.processId})`:""]}),c.jsx("span",{className:"whitespace-pre-wrap",children:T.message})]},`${T.timestamp}-${D}`))})]})},Ib=async()=>{try{const l=gs();if(!l)throw new Error("Authentication token not found. Please log in.");const r=await(await fetch(Ee("/logs"),{method:"DELETE",headers:{"x-auth-token":l}})).json();if(!r.success)throw new Error(r.error||"Failed to clear logs")}catch(l){throw console.error("Error clearing logs:",l),l}},e1=()=>{const[l,s]=S.useState([]),[r,o]=S.useState(!0),[d,f]=S.useState(null);return S.useEffect(()=>{let y=null,h=!0;const g=()=>{try{y&&y.close();const v=gs();if(!v){f(new Error("Authentication token not found. Please log in.")),o(!1);return}y=new EventSource(Ee(`/logs/stream?token=${v}`)),y.onmessage=w=>{if(h)try{const b=JSON.parse(w.data);b.type==="initial"?(s(b.logs),o(!1)):b.type==="log"&&s(R=>[...R,b.log])}catch(b){console.error("Error parsing SSE message:",b)}},y.onerror=()=>{h&&(y&&(y.close(),setTimeout(g,5e3)),f(new Error("Connection to log stream lost, attempting to reconnect...")))}}catch(v){if(!h)return;f(v instanceof Error?v:new Error("Failed to connect to log stream")),o(!1)}};return g(),()=>{h=!1,y&&y.close()}},[]),{logs:l,loading:r,error:d,clearLogs:async()=>{try{await Ib(),s([])}catch(y){f(y instanceof Error?y:new Error("Failed to clear logs"))}}}},t1=()=>{const{t:l}=Te(),{logs:s,loading:r,error:o,clearLogs:d}=e1();return c.jsxs("div",{className:"container mx-auto p-4",children:[c.jsx("div",{className:"flex justify-between items-center mb-4",children:c.jsx("h1",{className:"text-2xl font-bold",children:l("pages.logs.title")})}),c.jsx("div",{className:"bg-card rounded-md shadow-sm",children:c.jsx(Wb,{logs:s,isLoading:r,error:o,onClear:d})})]})};function im(){const l=Km();return c.jsx(Pv,{children:c.jsx(Ux,{children:c.jsx(Xv,{children:c.jsx(xx,{basename:l,children:c.jsxs(Zy,{children:[c.jsx(Ut,{path:"/login",element:c.jsx(kb,{})}),c.jsx(Ut,{element:c.jsx(Cb,{}),children:c.jsxs(Ut,{element:c.jsx(Eb,{}),children:[c.jsx(Ut,{path:"/",element:c.jsx(Ab,{})}),c.jsx(Ut,{path:"/servers",element:c.jsx(Ub,{})}),c.jsx(Ut,{path:"/groups",element:c.jsx(Gb,{})}),c.jsx(Ut,{path:"/market",element:c.jsx(rm,{})}),c.jsx(Ut,{path:"/market/:serverName",element:c.jsx(rm,{})}),c.jsx(Ut,{path:"/logs",element:c.jsx(t1,{})}),c.jsx(Ut,{path:"/settings",element:c.jsx(Kb,{})})]})}),c.jsx(Ut,{path:"*",element:c.jsx(Um,{to:"/"})})]})})})})})}const pe=l=>typeof l=="string",os=()=>{let l,s;const r=new Promise((o,d)=>{l=o,s=d});return r.resolve=l,r.reject=s,r},om=l=>l==null?"":""+l,a1=(l,s,r)=>{l.forEach(o=>{s[o]&&(r[o]=s[o])})},n1=/###/g,um=l=>l&&l.indexOf("###")>-1?l.replace(n1,"."):l,cm=l=>!l||pe(l),us=(l,s,r)=>{const o=pe(s)?s.split("."):s;let d=0;for(;d<o.length-1;){if(cm(l))return{};const f=um(o[d]);!l[f]&&r&&(l[f]=new r),Object.prototype.hasOwnProperty.call(l,f)?l=l[f]:l={},++d}return cm(l)?{}:{obj:l,k:um(o[d])}},dm=(l,s,r)=>{const{obj:o,k:d}=us(l,s,Object);if(o!==void 0||s.length===1){o[d]=r;return}let f=s[s.length-1],m=s.slice(0,s.length-1),y=us(l,m,Object);for(;y.obj===void 0&&m.length;)f=`${m[m.length-1]}.${f}`,m=m.slice(0,m.length-1),y=us(l,m,Object),y!=null&&y.obj&&typeof y.obj[`${y.k}.${f}`]<"u"&&(y.obj=void 0);y.obj[`${y.k}.${f}`]=r},l1=(l,s,r,o)=>{const{obj:d,k:f}=us(l,s,Object);d[f]=d[f]||[],d[f].push(r)},Vr=(l,s)=>{const{obj:r,k:o}=us(l,s);if(r&&Object.prototype.hasOwnProperty.call(r,o))return r[o]},s1=(l,s,r)=>{const o=Vr(l,r);return o!==void 0?o:Vr(s,r)},xg=(l,s,r)=>{for(const o in s)o!=="__proto__"&&o!=="constructor"&&(o in l?pe(l[o])||l[o]instanceof String||pe(s[o])||s[o]instanceof String?r&&(l[o]=s[o]):xg(l[o],s[o],r):l[o]=s[o]);return l},Jn=l=>l.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var r1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const i1=l=>pe(l)?l.replace(/[&<>"'\/]/g,s=>r1[s]):l;class o1{constructor(s){this.capacity=s,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(s){const r=this.regExpMap.get(s);if(r!==void 0)return r;const o=new RegExp(s);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(s,o),this.regExpQueue.push(s),o}}const u1=[" ",",","?","!",";"],c1=new o1(20),d1=(l,s,r)=>{s=s||"",r=r||"";const o=u1.filter(m=>s.indexOf(m)<0&&r.indexOf(m)<0);if(o.length===0)return!0;const d=c1.getRegExp(`(${o.map(m=>m==="?"?"\\?":m).join("|")})`);let f=!d.test(l);if(!f){const m=l.indexOf(r);m>0&&!d.test(l.substring(0,m))&&(f=!0)}return f},Tu=function(l,s){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!l)return;if(l[s])return Object.prototype.hasOwnProperty.call(l,s)?l[s]:void 0;const o=s.split(r);let d=l;for(let f=0;f<o.length;){if(!d||typeof d!="object")return;let m,y="";for(let h=f;h<o.length;++h)if(h!==f&&(y+=r),y+=o[h],m=d[y],m!==void 0){if(["string","number","boolean"].indexOf(typeof m)>-1&&h<o.length-1)continue;f+=h-f+1;break}d=m}return d},Yr=l=>l==null?void 0:l.replace("_","-"),f1={type:"logger",log(l){this.output("log",l)},warn(l){this.output("warn",l)},error(l){this.output("error",l)},output(l,s){var r,o;(o=(r=console==null?void 0:console[l])==null?void 0:r.apply)==null||o.call(r,console,s)}};class Kr{constructor(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(s,r)}init(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=r.prefix||"i18next:",this.logger=s||f1,this.options=r,this.debug=r.debug}log(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return this.forward(r,"log","",!0)}warn(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return this.forward(r,"warn","",!0)}error(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return this.forward(r,"error","")}deprecate(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return this.forward(r,"warn","WARNING DEPRECATED: ",!0)}forward(s,r,o,d){return d&&!this.debug?null:(pe(s[0])&&(s[0]=`${o}${this.prefix} ${s[0]}`),this.logger[r](s))}create(s){return new Kr(this.logger,{prefix:`${this.prefix}:${s}:`,...this.options})}clone(s){return s=s||this.options,s.prefix=s.prefix||this.prefix,new Kr(this.logger,s)}}var Pt=new Kr;class Pr{constructor(){this.observers={}}on(s,r){return s.split(" ").forEach(o=>{this.observers[o]||(this.observers[o]=new Map);const d=this.observers[o].get(r)||0;this.observers[o].set(r,d+1)}),this}off(s,r){if(this.observers[s]){if(!r){delete this.observers[s];return}this.observers[s].delete(r)}}emit(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),d=1;d<r;d++)o[d-1]=arguments[d];this.observers[s]&&Array.from(this.observers[s].entries()).forEach(m=>{let[y,h]=m;for(let g=0;g<h;g++)y(...o)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(m=>{let[y,h]=m;for(let g=0;g<h;g++)y.apply(y,[s,...o])})}}class fm extends Pr{constructor(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=s||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(s){this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}removeNamespaces(s){const r=this.options.ns.indexOf(s);r>-1&&this.options.ns.splice(r,1)}getResource(s,r,o){var g,v;let d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const f=d.keySeparator!==void 0?d.keySeparator:this.options.keySeparator,m=d.ignoreJSONStructure!==void 0?d.ignoreJSONStructure:this.options.ignoreJSONStructure;let y;s.indexOf(".")>-1?y=s.split("."):(y=[s,r],o&&(Array.isArray(o)?y.push(...o):pe(o)&&f?y.push(...o.split(f)):y.push(o)));const h=Vr(this.data,y);return!h&&!r&&!o&&s.indexOf(".")>-1&&(s=y[0],r=y[1],o=y.slice(2).join(".")),h||!m||!pe(o)?h:Tu((v=(g=this.data)==null?void 0:g[s])==null?void 0:v[r],o,f)}addResource(s,r,o,d){let f=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const m=f.keySeparator!==void 0?f.keySeparator:this.options.keySeparator;let y=[s,r];o&&(y=y.concat(m?o.split(m):o)),s.indexOf(".")>-1&&(y=s.split("."),d=r,r=y[1]),this.addNamespaces(r),dm(this.data,y,d),f.silent||this.emit("added",s,r,o,d)}addResources(s,r,o){let d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const f in o)(pe(o[f])||Array.isArray(o[f]))&&this.addResource(s,r,f,o[f],{silent:!0});d.silent||this.emit("added",s,r,o)}addResourceBundle(s,r,o,d,f){let m=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},y=[s,r];s.indexOf(".")>-1&&(y=s.split("."),d=o,o=r,r=y[1]),this.addNamespaces(r);let h=Vr(this.data,y)||{};m.skipCopy||(o=JSON.parse(JSON.stringify(o))),d?xg(h,o,f):h={...h,...o},dm(this.data,y,h),m.silent||this.emit("added",s,r,o)}removeResourceBundle(s,r){this.hasResourceBundle(s,r)&&delete this.data[s][r],this.removeNamespaces(r),this.emit("removed",s,r)}hasResourceBundle(s,r){return this.getResource(s,r)!==void 0}getResourceBundle(s,r){return r||(r=this.options.defaultNS),this.getResource(s,r)}getDataByLanguage(s){return this.data[s]}hasLanguageSomeTranslations(s){const r=this.getDataByLanguage(s);return!!(r&&Object.keys(r)||[]).find(d=>r[d]&&Object.keys(r[d]).length>0)}toJSON(){return this.data}}var vg={processors:{},addPostProcessor(l){this.processors[l.name]=l},handle(l,s,r,o,d){return l.forEach(f=>{var m;s=((m=this.processors[f])==null?void 0:m.process(s,r,o,d))??s}),s}};const hm={},mm=l=>!pe(l)&&typeof l!="boolean"&&typeof l!="number";class $r extends Pr{constructor(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),a1(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],s,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Pt.create("translator")}changeLanguage(s){s&&(this.language=s)}exists(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(s==null)return!1;const o=this.resolve(s,r);return(o==null?void 0:o.res)!==void 0}extractFromKey(s,r){let o=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");const d=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator;let f=r.ns||this.options.defaultNS||[];const m=o&&s.indexOf(o)>-1,y=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!d1(s,o,d);if(m&&!y){const h=s.match(this.interpolator.nestingRegexp);if(h&&h.length>0)return{key:s,namespaces:pe(f)?[f]:f};const g=s.split(o);(o!==d||o===d&&this.options.ns.indexOf(g[0])>-1)&&(f=g.shift()),s=g.join(d)}return{key:s,namespaces:pe(f)?[f]:f}}translate(s,r,o){if(typeof r!="object"&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),typeof r=="object"&&(r={...r}),r||(r={}),s==null)return"";Array.isArray(s)||(s=[String(s)]);const d=r.returnDetails!==void 0?r.returnDetails:this.options.returnDetails,f=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,{key:m,namespaces:y}=this.extractFromKey(s[s.length-1],r),h=y[y.length-1],g=r.lng||this.language,v=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((g==null?void 0:g.toLowerCase())==="cimode"){if(v){const de=r.nsSeparator||this.options.nsSeparator;return d?{res:`${h}${de}${m}`,usedKey:m,exactUsedKey:m,usedLng:g,usedNS:h,usedParams:this.getUsedParamsDetails(r)}:`${h}${de}${m}`}return d?{res:m,usedKey:m,exactUsedKey:m,usedLng:g,usedNS:h,usedParams:this.getUsedParamsDetails(r)}:m}const w=this.resolve(s,r);let b=w==null?void 0:w.res;const R=(w==null?void 0:w.usedKey)||m,N=(w==null?void 0:w.exactUsedKey)||m,C=["[object Number]","[object Function]","[object RegExp]"],A=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,z=!this.i18nFormat||this.i18nFormat.handleAsObject,T=r.count!==void 0&&!pe(r.count),D=$r.hasDefaultValue(r),q=T?this.pluralResolver.getSuffix(g,r.count,r):"",Y=r.ordinal&&T?this.pluralResolver.getSuffix(g,r.count,{ordinal:!1}):"",W=T&&!r.ordinal&&r.count===0,H=W&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${q}`]||r[`defaultValue${Y}`]||r.defaultValue;let O=b;z&&!b&&D&&(O=H);const J=mm(O),re=Object.prototype.toString.apply(O);if(z&&O&&J&&C.indexOf(re)<0&&!(pe(A)&&Array.isArray(O))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const de=this.options.returnedObjectHandler?this.options.returnedObjectHandler(R,O,{...r,ns:y}):`key '${m} (${this.language})' returned an object instead of string.`;return d?(w.res=de,w.usedParams=this.getUsedParamsDetails(r),w):de}if(f){const de=Array.isArray(O),me=de?[]:{},ke=de?N:R;for(const oe in O)if(Object.prototype.hasOwnProperty.call(O,oe)){const xe=`${ke}${f}${oe}`;D&&!b?me[oe]=this.translate(xe,{...r,defaultValue:mm(H)?H[oe]:void 0,joinArrays:!1,ns:y}):me[oe]=this.translate(xe,{...r,joinArrays:!1,ns:y}),me[oe]===xe&&(me[oe]=O[oe])}b=me}}else if(z&&pe(A)&&Array.isArray(b))b=b.join(A),b&&(b=this.extendTranslation(b,s,r,o));else{let de=!1,me=!1;!this.isValidLookup(b)&&D&&(de=!0,b=H),this.isValidLookup(b)||(me=!0,b=m);const oe=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&me?void 0:b,xe=D&&H!==b&&this.options.updateMissing;if(me||de||xe){if(this.logger.log(xe?"updateKey":"missingKey",g,h,m,xe?H:b),f){const ue=this.resolve(m,{...r,keySeparator:!1});ue&&ue.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let G=[];const V=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&V&&V[0])for(let ue=0;ue<V.length;ue++)G.push(V[ue]);else this.options.saveMissingTo==="all"?G=this.languageUtils.toResolveHierarchy(r.lng||this.language):G.push(r.lng||this.language);const $=(ue,E,Q)=>{var Z;const ee=D&&Q!==b?Q:oe;this.options.missingKeyHandler?this.options.missingKeyHandler(ue,h,E,ee,xe,r):(Z=this.backendConnector)!=null&&Z.saveMissing&&this.backendConnector.saveMissing(ue,h,E,ee,xe,r),this.emit("missingKey",ue,h,E,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?G.forEach(ue=>{const E=this.pluralResolver.getSuffixes(ue,r);W&&r[`defaultValue${this.options.pluralSeparator}zero`]&&E.indexOf(`${this.options.pluralSeparator}zero`)<0&&E.push(`${this.options.pluralSeparator}zero`),E.forEach(Q=>{$([ue],m+Q,r[`defaultValue${Q}`]||H)})}):$(G,m,H))}b=this.extendTranslation(b,s,r,w,o),me&&b===m&&this.options.appendNamespaceToMissingKey&&(b=`${h}:${m}`),(me||de)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${h}:${m}`:m,de?b:void 0))}return d?(w.res=b,w.usedParams=this.getUsedParamsDetails(r),w):b}extendTranslation(s,r,o,d,f){var g,v;var m=this;if((g=this.i18nFormat)!=null&&g.parse)s=this.i18nFormat.parse(s,{...this.options.interpolation.defaultVariables,...o},o.lng||this.language||d.usedLng,d.usedNS,d.usedKey,{resolved:d});else if(!o.skipInterpolation){o.interpolation&&this.interpolator.init({...o,interpolation:{...this.options.interpolation,...o.interpolation}});const w=pe(s)&&(((v=o==null?void 0:o.interpolation)==null?void 0:v.skipOnVariables)!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let b;if(w){const N=s.match(this.interpolator.nestingRegexp);b=N&&N.length}let R=o.replace&&!pe(o.replace)?o.replace:o;if(this.options.interpolation.defaultVariables&&(R={...this.options.interpolation.defaultVariables,...R}),s=this.interpolator.interpolate(s,R,o.lng||this.language||d.usedLng,o),w){const N=s.match(this.interpolator.nestingRegexp),C=N&&N.length;b<C&&(o.nest=!1)}!o.lng&&d&&d.res&&(o.lng=this.language||d.usedLng),o.nest!==!1&&(s=this.interpolator.nest(s,function(){for(var N=arguments.length,C=new Array(N),A=0;A<N;A++)C[A]=arguments[A];return(f==null?void 0:f[0])===C[0]&&!o.context?(m.logger.warn(`It seems you are nesting recursively key: ${C[0]} in key: ${r[0]}`),null):m.translate(...C,r)},o)),o.interpolation&&this.interpolator.reset()}const y=o.postProcess||this.options.postProcess,h=pe(y)?[y]:y;return s!=null&&(h!=null&&h.length)&&o.applyPostProcessor!==!1&&(s=vg.handle(h,s,r,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...d,usedParams:this.getUsedParamsDetails(o)},...o}:o,this)),s}resolve(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o,d,f,m,y;return pe(s)&&(s=[s]),s.forEach(h=>{if(this.isValidLookup(o))return;const g=this.extractFromKey(h,r),v=g.key;d=v;let w=g.namespaces;this.options.fallbackNS&&(w=w.concat(this.options.fallbackNS));const b=r.count!==void 0&&!pe(r.count),R=b&&!r.ordinal&&r.count===0,N=r.context!==void 0&&(pe(r.context)||typeof r.context=="number")&&r.context!=="",C=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);w.forEach(A=>{var z,T;this.isValidLookup(o)||(y=A,!hm[`${C[0]}-${A}`]&&((z=this.utils)!=null&&z.hasLoadedNamespace)&&!((T=this.utils)!=null&&T.hasLoadedNamespace(y))&&(hm[`${C[0]}-${A}`]=!0,this.logger.warn(`key "${d}" for languages "${C.join(", ")}" won't get resolved as namespace "${y}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),C.forEach(D=>{var W;if(this.isValidLookup(o))return;m=D;const q=[v];if((W=this.i18nFormat)!=null&&W.addLookupKeys)this.i18nFormat.addLookupKeys(q,v,D,A,r);else{let H;b&&(H=this.pluralResolver.getSuffix(D,r.count,r));const O=`${this.options.pluralSeparator}zero`,J=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(b&&(q.push(v+H),r.ordinal&&H.indexOf(J)===0&&q.push(v+H.replace(J,this.options.pluralSeparator)),R&&q.push(v+O)),N){const re=`${v}${this.options.contextSeparator}${r.context}`;q.push(re),b&&(q.push(re+H),r.ordinal&&H.indexOf(J)===0&&q.push(re+H.replace(J,this.options.pluralSeparator)),R&&q.push(re+O))}}let Y;for(;Y=q.pop();)this.isValidLookup(o)||(f=Y,o=this.getResource(D,A,Y,r))}))})}),{res:o,usedKey:d,exactUsedKey:f,usedLng:m,usedNS:y}}isValidLookup(s){return s!==void 0&&!(!this.options.returnNull&&s===null)&&!(!this.options.returnEmptyString&&s==="")}getResource(s,r,o){var f;let d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return(f=this.i18nFormat)!=null&&f.getResource?this.i18nFormat.getResource(s,r,o,d):this.resourceStore.getResource(s,r,o,d)}getUsedParamsDetails(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],o=s.replace&&!pe(s.replace);let d=o?s.replace:s;if(o&&typeof s.count<"u"&&(d.count=s.count),this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),!o){d={...d};for(const f of r)delete d[f]}return d}static hasDefaultValue(s){const r="defaultValue";for(const o in s)if(Object.prototype.hasOwnProperty.call(s,o)&&r===o.substring(0,r.length)&&s[o]!==void 0)return!0;return!1}}class gm{constructor(s){this.options=s,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Pt.create("languageUtils")}getScriptPartFromCode(s){if(s=Yr(s),!s||s.indexOf("-")<0)return null;const r=s.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(s){if(s=Yr(s),!s||s.indexOf("-")<0)return s;const r=s.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(s){if(pe(s)&&s.indexOf("-")>-1){let r;try{r=Intl.getCanonicalLocales(s)[0]}catch{}return r&&this.options.lowerCaseLng&&(r=r.toLowerCase()),r||(this.options.lowerCaseLng?s.toLowerCase():s)}return this.options.cleanCode||this.options.lowerCaseLng?s.toLowerCase():s}isSupportedCode(s){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(s=this.getLanguagePartFromCode(s)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(s)>-1}getBestMatchFromCodes(s){if(!s)return null;let r;return s.forEach(o=>{if(r)return;const d=this.formatLanguageCode(o);(!this.options.supportedLngs||this.isSupportedCode(d))&&(r=d)}),!r&&this.options.supportedLngs&&s.forEach(o=>{if(r)return;const d=this.getLanguagePartFromCode(o);if(this.isSupportedCode(d))return r=d;r=this.options.supportedLngs.find(f=>{if(f===d)return f;if(!(f.indexOf("-")<0&&d.indexOf("-")<0)&&(f.indexOf("-")>0&&d.indexOf("-")<0&&f.substring(0,f.indexOf("-"))===d||f.indexOf(d)===0&&d.length>1))return f})}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(s,r){if(!s)return[];if(typeof s=="function"&&(s=s(r)),pe(s)&&(s=[s]),Array.isArray(s))return s;if(!r)return s.default||[];let o=s[r];return o||(o=s[this.getScriptPartFromCode(r)]),o||(o=s[this.formatLanguageCode(r)]),o||(o=s[this.getLanguagePartFromCode(r)]),o||(o=s.default),o||[]}toResolveHierarchy(s,r){const o=this.getFallbackCodes(r||this.options.fallbackLng||[],s),d=[],f=m=>{m&&(this.isSupportedCode(m)?d.push(m):this.logger.warn(`rejecting language code not found in supportedLngs: ${m}`))};return pe(s)&&(s.indexOf("-")>-1||s.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&f(this.formatLanguageCode(s)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&f(this.getScriptPartFromCode(s)),this.options.load!=="currentOnly"&&f(this.getLanguagePartFromCode(s))):pe(s)&&f(this.formatLanguageCode(s)),o.forEach(m=>{d.indexOf(m)<0&&f(this.formatLanguageCode(m))}),d}}const pm={zero:0,one:1,two:2,few:3,many:4,other:5},ym={select:l=>l===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class h1{constructor(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=s,this.options=r,this.logger=Pt.create("pluralResolver"),this.pluralRulesCache={}}addRule(s,r){this.rules[s]=r}clearCache(){this.pluralRulesCache={}}getRule(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=Yr(s==="dev"?"en":s),d=r.ordinal?"ordinal":"cardinal",f=JSON.stringify({cleanedCode:o,type:d});if(f in this.pluralRulesCache)return this.pluralRulesCache[f];let m;try{m=new Intl.PluralRules(o,{type:d})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ym;if(!s.match(/-|_/))return ym;const h=this.languageUtils.getLanguagePartFromCode(s);m=this.getRule(h,r)}return this.pluralRulesCache[f]=m,m}needsPlural(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.getRule(s,r);return o||(o=this.getRule("dev",r)),(o==null?void 0:o.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(s,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(s,o).map(d=>`${r}${d}`)}getSuffixes(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.getRule(s,r);return o||(o=this.getRule("dev",r)),o?o.resolvedOptions().pluralCategories.sort((d,f)=>pm[d]-pm[f]).map(d=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${d}`):[]}getSuffix(s,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const d=this.getRule(s,o);return d?`${this.options.prepend}${o.ordinal?`ordinal${this.options.prepend}`:""}${d.select(r)}`:(this.logger.warn(`no plural rule found for: ${s}`),this.getSuffix("dev",r,o))}}const xm=function(l,s,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",d=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,f=s1(l,s,r);return!f&&d&&pe(r)&&(f=Tu(l,r,o),f===void 0&&(f=Tu(s,r,o))),f},xu=l=>l.replace(/\$/g,"$$$$");class m1{constructor(){var r;let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Pt.create("interpolator"),this.options=s,this.format=((r=s==null?void 0:s.interpolation)==null?void 0:r.format)||(o=>o),this.init(s)}init(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};s.interpolation||(s.interpolation={escapeValue:!0});const{escape:r,escapeValue:o,useRawValueToEscape:d,prefix:f,prefixEscaped:m,suffix:y,suffixEscaped:h,formatSeparator:g,unescapeSuffix:v,unescapePrefix:w,nestingPrefix:b,nestingPrefixEscaped:R,nestingSuffix:N,nestingSuffixEscaped:C,nestingOptionsSeparator:A,maxReplaces:z,alwaysFormat:T}=s.interpolation;this.escape=r!==void 0?r:i1,this.escapeValue=o!==void 0?o:!0,this.useRawValueToEscape=d!==void 0?d:!1,this.prefix=f?Jn(f):m||"{{",this.suffix=y?Jn(y):h||"}}",this.formatSeparator=g||",",this.unescapePrefix=v?"":w||"-",this.unescapeSuffix=this.unescapePrefix?"":v||"",this.nestingPrefix=b?Jn(b):R||Jn("$t("),this.nestingSuffix=N?Jn(N):C||Jn(")"),this.nestingOptionsSeparator=A||",",this.maxReplaces=z||1e3,this.alwaysFormat=T!==void 0?T:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const s=(r,o)=>(r==null?void 0:r.source)===o?(r.lastIndex=0,r):new RegExp(o,"g");this.regexp=s(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=s(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=s(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(s,r,o,d){var R;let f,m,y;const h=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},g=N=>{if(N.indexOf(this.formatSeparator)<0){const T=xm(r,h,N,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(T,void 0,o,{...d,...r,interpolationkey:N}):T}const C=N.split(this.formatSeparator),A=C.shift().trim(),z=C.join(this.formatSeparator).trim();return this.format(xm(r,h,A,this.options.keySeparator,this.options.ignoreJSONStructure),z,o,{...d,...r,interpolationkey:A})};this.resetRegExp();const v=(d==null?void 0:d.missingInterpolationHandler)||this.options.missingInterpolationHandler,w=((R=d==null?void 0:d.interpolation)==null?void 0:R.skipOnVariables)!==void 0?d.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:N=>xu(N)},{regex:this.regexp,safeValue:N=>this.escapeValue?xu(this.escape(N)):xu(N)}].forEach(N=>{for(y=0;f=N.regex.exec(s);){const C=f[1].trim();if(m=g(C),m===void 0)if(typeof v=="function"){const z=v(s,f,d);m=pe(z)?z:""}else if(d&&Object.prototype.hasOwnProperty.call(d,C))m="";else if(w){m=f[0];continue}else this.logger.warn(`missed to pass in variable ${C} for interpolating ${s}`),m="";else!pe(m)&&!this.useRawValueToEscape&&(m=om(m));const A=N.safeValue(m);if(s=s.replace(f[0],A),w?(N.regex.lastIndex+=m.length,N.regex.lastIndex-=f[0].length):N.regex.lastIndex=0,y++,y>=this.maxReplaces)break}}),s}nest(s,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},d,f,m;const y=(h,g)=>{const v=this.nestingOptionsSeparator;if(h.indexOf(v)<0)return h;const w=h.split(new RegExp(`${v}[ ]*{`));let b=`{${w[1]}`;h=w[0],b=this.interpolate(b,m);const R=b.match(/'/g),N=b.match(/"/g);(((R==null?void 0:R.length)??0)%2===0&&!N||N.length%2!==0)&&(b=b.replace(/'/g,'"'));try{m=JSON.parse(b),g&&(m={...g,...m})}catch(C){return this.logger.warn(`failed parsing options string in nesting for key ${h}`,C),`${h}${v}${b}`}return m.defaultValue&&m.defaultValue.indexOf(this.prefix)>-1&&delete m.defaultValue,h};for(;d=this.nestingRegexp.exec(s);){let h=[];m={...o},m=m.replace&&!pe(m.replace)?m.replace:m,m.applyPostProcessor=!1,delete m.defaultValue;let g=!1;if(d[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(d[1])){const v=d[1].split(this.formatSeparator).map(w=>w.trim());d[1]=v.shift(),h=v,g=!0}if(f=r(y.call(this,d[1].trim(),m),m),f&&d[0]===s&&!pe(f))return f;pe(f)||(f=om(f)),f||(this.logger.warn(`missed to resolve ${d[1]} for nesting ${s}`),f=""),g&&(f=h.reduce((v,w)=>this.format(v,w,o.lng,{...o,interpolationkey:d[1].trim()}),f.trim())),s=s.replace(d[0],f),this.regexp.lastIndex=0}return s}}const g1=l=>{let s=l.toLowerCase().trim();const r={};if(l.indexOf("(")>-1){const o=l.split("(");s=o[0].toLowerCase().trim();const d=o[1].substring(0,o[1].length-1);s==="currency"&&d.indexOf(":")<0?r.currency||(r.currency=d.trim()):s==="relativetime"&&d.indexOf(":")<0?r.range||(r.range=d.trim()):d.split(";").forEach(m=>{if(m){const[y,...h]=m.split(":"),g=h.join(":").trim().replace(/^'+|'+$/g,""),v=y.trim();r[v]||(r[v]=g),g==="false"&&(r[v]=!1),g==="true"&&(r[v]=!0),isNaN(g)||(r[v]=parseInt(g,10))}})}return{formatName:s,formatOptions:r}},Fn=l=>{const s={};return(r,o,d)=>{let f=d;d&&d.interpolationkey&&d.formatParams&&d.formatParams[d.interpolationkey]&&d[d.interpolationkey]&&(f={...f,[d.interpolationkey]:void 0});const m=o+JSON.stringify(f);let y=s[m];return y||(y=l(Yr(o),d),s[m]=y),y(r)}};class p1{constructor(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Pt.create("formatter"),this.options=s,this.formats={number:Fn((r,o)=>{const d=new Intl.NumberFormat(r,{...o});return f=>d.format(f)}),currency:Fn((r,o)=>{const d=new Intl.NumberFormat(r,{...o,style:"currency"});return f=>d.format(f)}),datetime:Fn((r,o)=>{const d=new Intl.DateTimeFormat(r,{...o});return f=>d.format(f)}),relativetime:Fn((r,o)=>{const d=new Intl.RelativeTimeFormat(r,{...o});return f=>d.format(f,o.range||"day")}),list:Fn((r,o)=>{const d=new Intl.ListFormat(r,{...o});return f=>d.format(f)})},this.init(s)}init(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=r.interpolation.formatSeparator||","}add(s,r){this.formats[s.toLowerCase().trim()]=r}addCached(s,r){this.formats[s.toLowerCase().trim()]=Fn(r)}format(s,r,o){let d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const f=r.split(this.formatSeparator);if(f.length>1&&f[0].indexOf("(")>1&&f[0].indexOf(")")<0&&f.find(y=>y.indexOf(")")>-1)){const y=f.findIndex(h=>h.indexOf(")")>-1);f[0]=[f[0],...f.splice(1,y)].join(this.formatSeparator)}return f.reduce((y,h)=>{var w;const{formatName:g,formatOptions:v}=g1(h);if(this.formats[g]){let b=y;try{const R=((w=d==null?void 0:d.formatParams)==null?void 0:w[d.interpolationkey])||{},N=R.locale||R.lng||d.locale||d.lng||o;b=this.formats[g](y,N,{...v,...d,...R})}catch(R){this.logger.warn(R)}return b}else this.logger.warn(`there was no format function for ${g}`);return y},s)}}const y1=(l,s)=>{l.pending[s]!==void 0&&(delete l.pending[s],l.pendingCount--)};class x1 extends Pr{constructor(s,r,o){var f,m;let d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=s,this.store=r,this.services=o,this.languageUtils=o.languageUtils,this.options=d,this.logger=Pt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=d.maxParallelReads||10,this.readingCalls=0,this.maxRetries=d.maxRetries>=0?d.maxRetries:5,this.retryTimeout=d.retryTimeout>=1?d.retryTimeout:350,this.state={},this.queue=[],(m=(f=this.backend)==null?void 0:f.init)==null||m.call(f,o,d.backend,d)}queueLoad(s,r,o,d){const f={},m={},y={},h={};return s.forEach(g=>{let v=!0;r.forEach(w=>{const b=`${g}|${w}`;!o.reload&&this.store.hasResourceBundle(g,w)?this.state[b]=2:this.state[b]<0||(this.state[b]===1?m[b]===void 0&&(m[b]=!0):(this.state[b]=1,v=!1,m[b]===void 0&&(m[b]=!0),f[b]===void 0&&(f[b]=!0),h[w]===void 0&&(h[w]=!0)))}),v||(y[g]=!0)}),(Object.keys(f).length||Object.keys(m).length)&&this.queue.push({pending:m,pendingCount:Object.keys(m).length,loaded:{},errors:[],callback:d}),{toLoad:Object.keys(f),pending:Object.keys(m),toLoadLanguages:Object.keys(y),toLoadNamespaces:Object.keys(h)}}loaded(s,r,o){const d=s.split("|"),f=d[0],m=d[1];r&&this.emit("failedLoading",f,m,r),!r&&o&&this.store.addResourceBundle(f,m,o,void 0,void 0,{skipCopy:!0}),this.state[s]=r?-1:2,r&&o&&(this.state[s]=0);const y={};this.queue.forEach(h=>{l1(h.loaded,[f],m),y1(h,s),r&&h.errors.push(r),h.pendingCount===0&&!h.done&&(Object.keys(h.loaded).forEach(g=>{y[g]||(y[g]={});const v=h.loaded[g];v.length&&v.forEach(w=>{y[g][w]===void 0&&(y[g][w]=!0)})}),h.done=!0,h.errors.length?h.callback(h.errors):h.callback())}),this.emit("loaded",y),this.queue=this.queue.filter(h=>!h.done)}read(s,r,o){let d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,f=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,m=arguments.length>5?arguments[5]:void 0;if(!s.length)return m(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:s,ns:r,fcName:o,tried:d,wait:f,callback:m});return}this.readingCalls++;const y=(g,v)=>{if(this.readingCalls--,this.waitingReads.length>0){const w=this.waitingReads.shift();this.read(w.lng,w.ns,w.fcName,w.tried,w.wait,w.callback)}if(g&&v&&d<this.maxRetries){setTimeout(()=>{this.read.call(this,s,r,o,d+1,f*2,m)},f);return}m(g,v)},h=this.backend[o].bind(this.backend);if(h.length===2){try{const g=h(s,r);g&&typeof g.then=="function"?g.then(v=>y(null,v)).catch(y):y(null,g)}catch(g){y(g)}return}return h(s,r,y)}prepareLoading(s,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},d=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),d&&d();pe(s)&&(s=this.languageUtils.toResolveHierarchy(s)),pe(r)&&(r=[r]);const f=this.queueLoad(s,r,o,d);if(!f.toLoad.length)return f.pending.length||d(),null;f.toLoad.forEach(m=>{this.loadOne(m)})}load(s,r,o){this.prepareLoading(s,r,{},o)}reload(s,r,o){this.prepareLoading(s,r,{reload:!0},o)}loadOne(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const o=s.split("|"),d=o[0],f=o[1];this.read(d,f,"read",void 0,void 0,(m,y)=>{m&&this.logger.warn(`${r}loading namespace ${f} for language ${d} failed`,m),!m&&y&&this.logger.log(`${r}loaded namespace ${f} for language ${d}`,y),this.loaded(s,m,y)})}saveMissing(s,r,o,d,f){var h,g,v,w,b;let m=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},y=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if((g=(h=this.services)==null?void 0:h.utils)!=null&&g.hasLoadedNamespace&&!((w=(v=this.services)==null?void 0:v.utils)!=null&&w.hasLoadedNamespace(r))){this.logger.warn(`did not save key "${o}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if((b=this.backend)!=null&&b.create){const R={...m,isUpdate:f},N=this.backend.create.bind(this.backend);if(N.length<6)try{let C;N.length===5?C=N(s,r,o,d,R):C=N(s,r,o,d),C&&typeof C.then=="function"?C.then(A=>y(null,A)).catch(y):y(null,C)}catch(C){y(C)}else N(s,r,o,d,y,R)}!s||!s[0]||this.store.addResource(s[0],r,o,d)}}}const vm=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:l=>{let s={};if(typeof l[1]=="object"&&(s=l[1]),pe(l[1])&&(s.defaultValue=l[1]),pe(l[2])&&(s.tDescription=l[2]),typeof l[2]=="object"||typeof l[3]=="object"){const r=l[3]||l[2];Object.keys(r).forEach(o=>{s[o]=r[o]})}return s},interpolation:{escapeValue:!0,format:l=>l,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),bm=l=>{var s,r;return pe(l.ns)&&(l.ns=[l.ns]),pe(l.fallbackLng)&&(l.fallbackLng=[l.fallbackLng]),pe(l.fallbackNS)&&(l.fallbackNS=[l.fallbackNS]),((r=(s=l.supportedLngs)==null?void 0:s.indexOf)==null?void 0:r.call(s,"cimode"))<0&&(l.supportedLngs=l.supportedLngs.concat(["cimode"])),typeof l.initImmediate=="boolean"&&(l.initAsync=l.initImmediate),l},Hr=()=>{},v1=l=>{Object.getOwnPropertyNames(Object.getPrototypeOf(l)).forEach(r=>{typeof l[r]=="function"&&(l[r]=l[r].bind(l))})};class fs extends Pr{constructor(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(super(),this.options=bm(s),this.services={},this.logger=Pt,this.modules={external:[]},v1(this),r&&!this.isInitialized&&!s.isClone){if(!this.options.initAsync)return this.init(s,r),this;setTimeout(()=>{this.init(s,r)},0)}}init(){var s=this;let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof r=="function"&&(o=r,r={}),r.defaultNS==null&&r.ns&&(pe(r.ns)?r.defaultNS=r.ns:r.ns.indexOf("translation")<0&&(r.defaultNS=r.ns[0]));const d=vm();this.options={...d,...this.options,...bm(r)},this.options.interpolation={...d.interpolation,...this.options.interpolation},r.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=r.keySeparator),r.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=r.nsSeparator);const f=v=>v?typeof v=="function"?new v:v:null;if(!this.options.isClone){this.modules.logger?Pt.init(f(this.modules.logger),this.options):Pt.init(null,this.options);let v;this.modules.formatter?v=this.modules.formatter:v=p1;const w=new gm(this.options);this.store=new fm(this.options.resources,this.options);const b=this.services;b.logger=Pt,b.resourceStore=this.store,b.languageUtils=w,b.pluralResolver=new h1(w,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),v&&(!this.options.interpolation.format||this.options.interpolation.format===d.interpolation.format)&&(b.formatter=f(v),b.formatter.init(b,this.options),this.options.interpolation.format=b.formatter.format.bind(b.formatter)),b.interpolator=new m1(this.options),b.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},b.backendConnector=new x1(f(this.modules.backend),b.resourceStore,b,this.options),b.backendConnector.on("*",function(R){for(var N=arguments.length,C=new Array(N>1?N-1:0),A=1;A<N;A++)C[A-1]=arguments[A];s.emit(R,...C)}),this.modules.languageDetector&&(b.languageDetector=f(this.modules.languageDetector),b.languageDetector.init&&b.languageDetector.init(b,this.options.detection,this.options)),this.modules.i18nFormat&&(b.i18nFormat=f(this.modules.i18nFormat),b.i18nFormat.init&&b.i18nFormat.init(this)),this.translator=new $r(this.services,this.options),this.translator.on("*",function(R){for(var N=arguments.length,C=new Array(N>1?N-1:0),A=1;A<N;A++)C[A-1]=arguments[A];s.emit(R,...C)}),this.modules.external.forEach(R=>{R.init&&R.init(this)})}if(this.format=this.options.interpolation.format,o||(o=Hr),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const v=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);v.length>0&&v[0]!=="dev"&&(this.options.lng=v[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(v=>{this[v]=function(){return s.store[v](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(v=>{this[v]=function(){return s.store[v](...arguments),s}});const h=os(),g=()=>{const v=(w,b)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),h.resolve(b),o(w,b)};if(this.languages&&!this.isInitialized)return v(null,this.t.bind(this));this.changeLanguage(this.options.lng,v)};return this.options.resources||!this.options.initAsync?g():setTimeout(g,0),h}loadResources(s){var f,m;let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Hr;const d=pe(s)?s:this.language;if(typeof s=="function"&&(o=s),!this.options.resources||this.options.partialBundledLanguages){if((d==null?void 0:d.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return o();const y=[],h=g=>{if(!g||g==="cimode")return;this.services.languageUtils.toResolveHierarchy(g).forEach(w=>{w!=="cimode"&&y.indexOf(w)<0&&y.push(w)})};d?h(d):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(v=>h(v)),(m=(f=this.options.preload)==null?void 0:f.forEach)==null||m.call(f,g=>h(g)),this.services.backendConnector.load(y,this.options.ns,g=>{!g&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),o(g)})}else o(null)}reloadResources(s,r,o){const d=os();return typeof s=="function"&&(o=s,s=void 0),typeof r=="function"&&(o=r,r=void 0),s||(s=this.languages),r||(r=this.options.ns),o||(o=Hr),this.services.backendConnector.reload(s,r,f=>{d.resolve(),o(f)}),d}use(s){if(!s)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!s.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return s.type==="backend"&&(this.modules.backend=s),(s.type==="logger"||s.log&&s.warn&&s.error)&&(this.modules.logger=s),s.type==="languageDetector"&&(this.modules.languageDetector=s),s.type==="i18nFormat"&&(this.modules.i18nFormat=s),s.type==="postProcessor"&&vg.addPostProcessor(s),s.type==="formatter"&&(this.modules.formatter=s),s.type==="3rdParty"&&this.modules.external.push(s),this}setResolvedLanguage(s){if(!(!s||!this.languages)&&!(["cimode","dev"].indexOf(s)>-1))for(let r=0;r<this.languages.length;r++){const o=this.languages[r];if(!(["cimode","dev"].indexOf(o)>-1)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}}changeLanguage(s,r){var o=this;this.isLanguageChangingTo=s;const d=os();this.emit("languageChanging",s);const f=h=>{this.language=h,this.languages=this.services.languageUtils.toResolveHierarchy(h),this.resolvedLanguage=void 0,this.setResolvedLanguage(h)},m=(h,g)=>{g?(f(g),this.translator.changeLanguage(g),this.isLanguageChangingTo=void 0,this.emit("languageChanged",g),this.logger.log("languageChanged",g)):this.isLanguageChangingTo=void 0,d.resolve(function(){return o.t(...arguments)}),r&&r(h,function(){return o.t(...arguments)})},y=h=>{var v,w;!s&&!h&&this.services.languageDetector&&(h=[]);const g=pe(h)?h:this.services.languageUtils.getBestMatchFromCodes(h);g&&(this.language||f(g),this.translator.language||this.translator.changeLanguage(g),(w=(v=this.services.languageDetector)==null?void 0:v.cacheUserLanguage)==null||w.call(v,g)),this.loadResources(g,b=>{m(b,g)})};return!s&&this.services.languageDetector&&!this.services.languageDetector.async?y(this.services.languageDetector.detect()):!s&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(y):this.services.languageDetector.detect(y):y(s),d}getFixedT(s,r,o){var d=this;const f=function(m,y){let h;if(typeof y!="object"){for(var g=arguments.length,v=new Array(g>2?g-2:0),w=2;w<g;w++)v[w-2]=arguments[w];h=d.options.overloadTranslationOptionHandler([m,y].concat(v))}else h={...y};h.lng=h.lng||f.lng,h.lngs=h.lngs||f.lngs,h.ns=h.ns||f.ns,h.keyPrefix!==""&&(h.keyPrefix=h.keyPrefix||o||f.keyPrefix);const b=d.options.keySeparator||".";let R;return h.keyPrefix&&Array.isArray(m)?R=m.map(N=>`${h.keyPrefix}${b}${N}`):R=h.keyPrefix?`${h.keyPrefix}${b}${m}`:m,d.t(R,h)};return pe(s)?f.lng=s:f.lngs=s,f.ns=r,f.keyPrefix=o,f}t(){var d;for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return(d=this.translator)==null?void 0:d.translate(...r)}exists(){var d;for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return(d=this.translator)==null?void 0:d.exists(...r)}setDefaultNamespace(s){this.options.defaultNS=s}hasLoadedNamespace(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const o=r.lng||this.resolvedLanguage||this.languages[0],d=this.options?this.options.fallbackLng:!1,f=this.languages[this.languages.length-1];if(o.toLowerCase()==="cimode")return!0;const m=(y,h)=>{const g=this.services.backendConnector.state[`${y}|${h}`];return g===-1||g===0||g===2};if(r.precheck){const y=r.precheck(this,m);if(y!==void 0)return y}return!!(this.hasResourceBundle(o,s)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||m(o,s)&&(!d||m(f,s)))}loadNamespaces(s,r){const o=os();return this.options.ns?(pe(s)&&(s=[s]),s.forEach(d=>{this.options.ns.indexOf(d)<0&&this.options.ns.push(d)}),this.loadResources(d=>{o.resolve(),r&&r(d)}),o):(r&&r(),Promise.resolve())}loadLanguages(s,r){const o=os();pe(s)&&(s=[s]);const d=this.options.preload||[],f=s.filter(m=>d.indexOf(m)<0&&this.services.languageUtils.isSupportedCode(m));return f.length?(this.options.preload=d.concat(f),this.loadResources(m=>{o.resolve(),r&&r(m)}),o):(r&&r(),Promise.resolve())}dir(s){var d,f;if(s||(s=this.resolvedLanguage||(((d=this.languages)==null?void 0:d.length)>0?this.languages[0]:this.language)),!s)return"rtl";const r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=((f=this.services)==null?void 0:f.languageUtils)||new gm(vm());return r.indexOf(o.getLanguagePartFromCode(s))>-1||s.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return new fs(s,r)}cloneInstance(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Hr;const o=s.forkResourceStore;o&&delete s.forkResourceStore;const d={...this.options,...s,isClone:!0},f=new fs(d);if((s.debug!==void 0||s.prefix!==void 0)&&(f.logger=f.logger.clone(s)),["store","services","language"].forEach(y=>{f[y]=this[y]}),f.services={...this.services},f.services.utils={hasLoadedNamespace:f.hasLoadedNamespace.bind(f)},o){const y=Object.keys(this.store.data).reduce((h,g)=>(h[g]={...this.store.data[g]},Object.keys(h[g]).reduce((v,w)=>(v[w]={...h[g][w]},v),{})),{});f.store=new fm(y,d),f.services.resourceStore=f.store}return f.translator=new $r(f.services,d),f.translator.on("*",function(y){for(var h=arguments.length,g=new Array(h>1?h-1:0),v=1;v<h;v++)g[v-1]=arguments[v];f.emit(y,...g)}),f.init(d,r),f.translator.options=d,f.translator.backendConnector.services.utils={hasLoadedNamespace:f.hasLoadedNamespace.bind(f)},f}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const it=fs.createInstance();it.createInstance=fs.createInstance;it.createInstance;it.dir;it.init;it.loadResources;it.reloadResources;it.use;it.changeLanguage;it.getFixedT;it.t;it.exists;it.setDefaultNamespace;it.hasLoadedNamespace;it.loadNamespaces;it.loadLanguages;const{slice:b1,forEach:S1}=[];function w1(l){return S1.call(b1.call(arguments,1),s=>{if(s)for(const r in s)l[r]===void 0&&(l[r]=s[r])}),l}function N1(l){return typeof l!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(r=>r.test(l))}const Sm=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,j1=function(l,s){const o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},d=encodeURIComponent(s);let f=`${l}=${d}`;if(o.maxAge>0){const m=o.maxAge-0;if(Number.isNaN(m))throw new Error("maxAge should be a Number");f+=`; Max-Age=${Math.floor(m)}`}if(o.domain){if(!Sm.test(o.domain))throw new TypeError("option domain is invalid");f+=`; Domain=${o.domain}`}if(o.path){if(!Sm.test(o.path))throw new TypeError("option path is invalid");f+=`; Path=${o.path}`}if(o.expires){if(typeof o.expires.toUTCString!="function")throw new TypeError("option expires is invalid");f+=`; Expires=${o.expires.toUTCString()}`}if(o.httpOnly&&(f+="; HttpOnly"),o.secure&&(f+="; Secure"),o.sameSite)switch(typeof o.sameSite=="string"?o.sameSite.toLowerCase():o.sameSite){case!0:f+="; SameSite=Strict";break;case"lax":f+="; SameSite=Lax";break;case"strict":f+="; SameSite=Strict";break;case"none":f+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return o.partitioned&&(f+="; Partitioned"),f},wm={create(l,s,r,o){let d=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(d.expires=new Date,d.expires.setTime(d.expires.getTime()+r*60*1e3)),o&&(d.domain=o),document.cookie=j1(l,encodeURIComponent(s),d)},read(l){const s=`${l}=`,r=document.cookie.split(";");for(let o=0;o<r.length;o++){let d=r[o];for(;d.charAt(0)===" ";)d=d.substring(1,d.length);if(d.indexOf(s)===0)return d.substring(s.length,d.length)}return null},remove(l){this.create(l,"",-1)}};var E1={name:"cookie",lookup(l){let{lookupCookie:s}=l;if(s&&typeof document<"u")return wm.read(s)||void 0},cacheUserLanguage(l,s){let{lookupCookie:r,cookieMinutes:o,cookieDomain:d,cookieOptions:f}=s;r&&typeof document<"u"&&wm.create(r,l,o,d,f)}},C1={name:"querystring",lookup(l){var o;let{lookupQuerystring:s}=l,r;if(typeof window<"u"){let{search:d}=window.location;!window.location.search&&((o=window.location.hash)==null?void 0:o.indexOf("?"))>-1&&(d=window.location.hash.substring(window.location.hash.indexOf("?")));const m=d.substring(1).split("&");for(let y=0;y<m.length;y++){const h=m[y].indexOf("=");h>0&&m[y].substring(0,h)===s&&(r=m[y].substring(h+1))}}return r}};let Wn=null;const Nm=()=>{if(Wn!==null)return Wn;try{if(Wn=typeof window<"u"&&window.localStorage!==null,!Wn)return!1;const l="i18next.translate.boo";window.localStorage.setItem(l,"foo"),window.localStorage.removeItem(l)}catch{Wn=!1}return Wn};var k1={name:"localStorage",lookup(l){let{lookupLocalStorage:s}=l;if(s&&Nm())return window.localStorage.getItem(s)||void 0},cacheUserLanguage(l,s){let{lookupLocalStorage:r}=s;r&&Nm()&&window.localStorage.setItem(r,l)}};let In=null;const jm=()=>{if(In!==null)return In;try{if(In=typeof window<"u"&&window.sessionStorage!==null,!In)return!1;const l="i18next.translate.boo";window.sessionStorage.setItem(l,"foo"),window.sessionStorage.removeItem(l)}catch{In=!1}return In};var A1={name:"sessionStorage",lookup(l){let{lookupSessionStorage:s}=l;if(s&&jm())return window.sessionStorage.getItem(s)||void 0},cacheUserLanguage(l,s){let{lookupSessionStorage:r}=s;r&&jm()&&window.sessionStorage.setItem(r,l)}},T1={name:"navigator",lookup(l){const s=[];if(typeof navigator<"u"){const{languages:r,userLanguage:o,language:d}=navigator;if(r)for(let f=0;f<r.length;f++)s.push(r[f]);o&&s.push(o),d&&s.push(d)}return s.length>0?s:void 0}},R1={name:"htmlTag",lookup(l){let{htmlTag:s}=l,r;const o=s||(typeof document<"u"?document.documentElement:null);return o&&typeof o.getAttribute=="function"&&(r=o.getAttribute("lang")),r}},O1={name:"path",lookup(l){var d;let{lookupFromPathIndex:s}=l;if(typeof window>"u")return;const r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(r)?(d=r[typeof s=="number"?s:0])==null?void 0:d.replace("/",""):void 0}},M1={name:"subdomain",lookup(l){var d,f;let{lookupFromSubdomainIndex:s}=l;const r=typeof s=="number"?s+1:1,o=typeof window<"u"&&((f=(d=window.location)==null?void 0:d.hostname)==null?void 0:f.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i));if(o)return o[r]}};let bg=!1;try{document.cookie,bg=!0}catch{}const Sg=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];bg||Sg.splice(1,1);const z1=()=>({order:Sg,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:l=>l});class wg{constructor(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(s,r)}init(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=s,this.options=w1(r,this.options||{},z1()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=d=>d.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=o,this.addDetector(E1),this.addDetector(C1),this.addDetector(k1),this.addDetector(A1),this.addDetector(T1),this.addDetector(R1),this.addDetector(O1),this.addDetector(M1)}addDetector(s){return this.detectors[s.name]=s,this}detect(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,r=[];return s.forEach(o=>{if(this.detectors[o]){let d=this.detectors[o].lookup(this.options);d&&typeof d=="string"&&(d=[d]),d&&(r=r.concat(d))}}),r=r.filter(o=>o!=null&&!N1(o)).map(o=>this.options.convertDetectedLanguage(o)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?r:r.length>0?r[0]:null}cacheUserLanguage(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(s)>-1||r.forEach(o=>{this.detectors[o]&&this.detectors[o].cacheUserLanguage(s,this.options)}))}}wg.type="languageDetector";const D1={title:"MCP Hub Dashboard",error:"Error",closeButton:"Close",noServers:"No MCP servers available",loading:"Loading...",logout:"Logout",profile:"Profile",changePassword:"Change Password",toggleSidebar:"Toggle Sidebar",welcomeUser:"Welcome, {{username}}",name:"MCP Hub"},U1={title:"About",versionInfo:"MCP Hub Version: {{version}}",newVersion:"New version available!",currentVersion:"Current version",newVersionAvailable:"New version {{version}} is available",viewOnGitHub:"View on GitHub",checkForUpdates:"Check for Updates",checking:"Checking for updates..."},L1={viewProfile:"View profile",userCenter:"User Center"},_1={label:"Sponsor",title:"Support the Project",rewardAlt:"Reward QR Code",supportMessage:"Support the development of MCP Hub by buying me a coffee!",supportButton:"Support on Ko-fi"},H1={label:"WeChat",title:"Connect via WeChat",qrCodeAlt:"WeChat QR Code",scanMessage:"Scan this QR code to connect with us on WeChat"},B1={label:"Discord",title:"Join our Discord server",community:"Join our growing community on Discord for support, discussions, and updates!"},G1={title:"Theme",light:"Light",dark:"Dark",system:"System"},q1={login:"Login",loginTitle:"Login to MCP Hub",username:"Username",password:"Password",loggingIn:"Logging in...",emptyFields:"Username and password cannot be empty",loginFailed:"Login failed, please check your username and password",loginError:"An error occurred during login",currentPassword:"Current Password",newPassword:"New Password",confirmPassword:"Confirm Password",passwordsNotMatch:"New password and confirmation do not match",changePasswordSuccess:"Password changed successfully",changePasswordError:"Failed to change password",changePassword:"Change Password",passwordChanged:"Password changed successfully",passwordChangeError:"Failed to change password"},V1={addServer:"Add Server",add:"Add",edit:"Edit",delete:"Delete",confirmDelete:"Are you sure you want to delete this server?",deleteWarning:"Deleting server '{{name}}' will remove it and all its data. This action cannot be undone.",status:"Status",tools:"Tools",name:"Server Name",url:"Server URL",apiKey:"API Key",save:"Save",cancel:"Cancel",invalidConfig:"Could not find configuration data for {{serverName}}",addError:"Failed to add server",editError:"Failed to edit server {{serverName}}",deleteError:"Failed to delete server {{serverName}}",updateError:"Failed to update server",editTitle:"Edit Server: {{serverName}}",type:"Server Type",command:"Command",arguments:"Arguments",envVars:"Environment Variables",key:"key",value:"value",enabled:"Enabled",enable:"Enable",disable:"Disable",remove:"Remove",toggleError:"Failed to toggle server {{serverName}}",alreadyExists:"Server {{serverName}} already exists",invalidData:"Invalid server data provided",notFound:"Server {{serverName}} not found",namePlaceholder:"Enter server name",urlPlaceholder:"Enter server URL",commandPlaceholder:"Enter command",argumentsPlaceholder:"Enter arguments",errorDetails:"Error Details",viewErrorDetails:"View error details"},Y1={online:"Online",offline:"Offline",connecting:"Connecting"},K1={general:"Something went wrong",network:"Network connection error. Please check your internet connection",serverConnection:"Unable to connect to the server. Please check if the server is running",serverAdd:"Failed to add server. Please check the server status",serverUpdate:"Failed to edit server {{serverName}}. Please check the server status",serverFetch:"Failed to retrieve server data. Please try again later",initialStartup:"The server might be starting up. Please wait a moment as this process can take some time on first launch...",serverInstall:"Failed to install server",failedToFetchSettings:"Failed to fetch settings",failedToUpdateRouteConfig:"Failed to update route configuration",failedToUpdateSmartRoutingConfig:"Failed to update smart routing configuration"},$1={processing:"Processing...",save:"Save",cancel:"Cancel",refresh:"Refresh",create:"Create",submitting:"Submitting...",delete:"Delete",copy:"Copy",copySuccess:"Copied to clipboard",copyFailed:"Copy failed",close:"Close"},Q1={dashboard:"Dashboard",servers:"Servers",groups:"Groups",settings:"Settings",changePassword:"Change Password",market:"Market",logs:"Logs"},X1={dashboard:{title:"Dashboard",totalServers:"Total",onlineServers:"Online",offlineServers:"Offline",connectingServers:"Connecting",recentServers:"Recent Servers"},servers:{title:"Servers Management"},groups:{title:"Group Management"},settings:{title:"Settings",language:"Language",account:"Account Settings",password:"Change Password",appearance:"Appearance",routeConfig:"Security",installConfig:"Installation",smartRouting:"Smart Routing"},market:{title:"Server Market - (Data from mcpm.sh)"},logs:{title:"System Logs"}},Z1={filters:"Filters",search:"Search logs...",autoScroll:"Auto-scroll",clearLogs:"Clear logs",loading:"Loading logs...",noLogs:"No logs available.",noMatch:"No logs match the current filters.",mainProcess:"Main Process",childProcess:"Child Process",main:"Main",child:"Child"},P1={add:"Add",addNew:"Add New Group",edit:"Edit Group",delete:"Delete",confirmDelete:"Are you sure you want to delete this group?",deleteWarning:"Deleting group '{{name}}' will remove it and all its server associations. This action cannot be undone.",name:"Group Name",namePlaceholder:"Enter group name",nameRequired:"Group name is required",description:"Description",descriptionPlaceholder:"Enter group description (optional)",createError:"Failed to create group",updateError:"Failed to update group",deleteError:"Failed to delete group",serverAddError:"Failed to add server to group",serverRemoveError:"Failed to remove server from group",addServer:"Add Server to Group",selectServer:"Select a server to add",servers:"Servers in Group",remove:"Remove",noGroups:"No groups available. Create a new group to get started.",noServers:"No servers in this group.",noServerOptions:"No servers available",serverCount:"{{count}} Servers"},J1={title:"Server Market",official:"Official",by:"By",unknown:"Unknown",tools:"tools",search:"Search",searchPlaceholder:"Search for servers by name, category, or tags",clearFilters:"Clear",clearCategoryFilter:"",clearTagFilter:"",categories:"Categories",tags:"Tags",showTags:"Show tags",hideTags:"Hide tags",moreTags:"",noServers:"No servers found matching your search",backToList:"Back to list",install:"Install",installing:"Installing...",installed:"Installed",installServer:"Install Server: {{name}}",installSuccess:"Server {{serverName}} installed successfully",author:"Author",license:"License",repository:"Repository",examples:"Examples",arguments:"Arguments",argumentName:"Name",description:"Description",required:"Required",example:"Example",viewSchema:"View schema",fetchError:"Error fetching market servers",serverNotFound:"Server not found",searchError:"Error searching servers",filterError:"Error filtering servers by category",tagFilterError:"Error filtering servers by tag",noInstallationMethod:"No installation method available for this server",showing:"Showing {{from}}-{{to}} of {{total}} servers",perPage:"Per page"},F1={enableGlobalRoute:"Enable Global Route",enableGlobalRouteDescription:"Allow connections to /sse endpoint without specifying a group ID",enableGroupNameRoute:"Enable Group Name Route",enableGroupNameRouteDescription:"Allow connections to /sse endpoint using group names instead of just group IDs",enableBearerAuth:"Enable Bearer Authentication",enableBearerAuthDescription:"Require bearer token authentication for MCP requests",bearerAuthKey:"Bearer Authentication Key",bearerAuthKeyDescription:"The authentication key that will be required in the Bearer token",bearerAuthKeyPlaceholder:"Enter bearer authentication key",pythonIndexUrl:"Python Package Repository URL",pythonIndexUrlDescription:"Set UV_DEFAULT_INDEX environment variable for Python package installation",pythonIndexUrlPlaceholder:"e.g. https://pypi.org/simple",npmRegistry:"NPM Registry URL",npmRegistryDescription:"Set npm_config_registry environment variable for NPM package installation",npmRegistryPlaceholder:"e.g. https://registry.npmjs.org/",installConfig:"Installation",systemConfigUpdated:"System configuration updated successfully",enableSmartRouting:"Enable Smart Routing",enableSmartRoutingDescription:"Enable smart routing feature to search the most suitable tool based on input (using $smart group name)",dbUrl:"PostgreSQL URL (with pgvector support)",dbUrlPlaceholder:"e.g. postgresql://user:password@localhost:5432/dbname",openaiApiBaseUrl:"OpenAI API Base URL",openaiApiBaseUrlPlaceholder:"https://api.openai.com/v1",openaiApiKey:"OpenAI API Key",openaiApiKeyPlaceholder:"Enter OpenAI API key",openaiApiEmbeddingModel:"OpenAI Embedding Model",openaiApiEmbeddingModelPlaceholder:"text-embedding-3-small",smartRoutingConfigUpdated:"Smart routing configuration updated successfully",smartRoutingRequiredFields:"Database URL and OpenAI API Key are required to enable smart routing",smartRoutingValidationError:"Please fill in the required fields before enabling Smart Routing: {{fields}}"},W1={app:D1,about:U1,profile:L1,sponsor:_1,wechat:H1,discord:B1,theme:G1,auth:q1,server:V1,status:Y1,errors:K1,common:$1,nav:Q1,pages:X1,logs:Z1,groups:P1,market:J1,settings:F1},I1={title:"MCP Hub 控制面板",error:"错误",closeButton:"关闭",noServers:"没有可用的 MCP 服务器",loading:"加载中...",logout:"退出登录",profile:"个人资料",changePassword:"修改密码",toggleSidebar:"切换侧边栏",welcomeUser:"欢迎, {{username}}",name:"MCP Hub"},e2={title:"关于",versionInfo:"MCP Hub 版本: {{version}}",newVersion:"有新版本可用!",currentVersion:"当前版本",newVersionAvailable:"新版本 {{version}} 已发布",viewOnGitHub:"在 GitHub 上查看",checkForUpdates:"检查更新",checking:"检查更新中..."},t2={viewProfile:"查看个人中心",userCenter:"个人中心"},a2={label:"赞助",title:"支持项目",rewardAlt:"赞赏码",supportMessage:"通过捐赠支持 MCP Hub 的开发!",supportButton:"在 Ko-fi 上支持"},n2={label:"微信",title:"微信联系",qrCodeAlt:"微信二维码",scanMessage:"扫描二维码添加微信"},l2={label:"Discord",title:"加入我们的 Discord 服务器",community:"加入我们不断壮大的 Discord 社区,获取支持、参与讨论并了解最新动态!"},s2={title:"主题",light:"浅色",dark:"深色",system:"系统"},r2={login:"登录",loginTitle:"登录 MCP Hub",username:"用户名",password:"密码",loggingIn:"登录中...",emptyFields:"用户名和密码不能为空",loginFailed:"登录失败,请检查用户名和密码",loginError:"登录过程中出现错误",currentPassword:"当前密码",newPassword:"新密码",confirmPassword:"确认密码",passwordsNotMatch:"新密码与确认密码不一致",changePasswordSuccess:"密码修改成功",changePasswordError:"修改密码失败",changePassword:"修改密码",passwordChanged:"密码修改成功",passwordChangeError:"修改密码失败"},i2={addServer:"添加服务器",add:"添加",edit:"编辑",delete:"删除",confirmDelete:"您确定要删除此服务器吗?",deleteWarning:"删除服务器 '{{name}}' 将会移除该服务器及其所有数据。此操作无法撤销。",status:"状态",tools:"工具",name:"服务器名称",url:"服务器 URL",apiKey:"API 密钥",save:"保存",cancel:"取消",addError:"添加服务器失败",editError:"编辑服务器 {{serverName}} 失败",invalidConfig:"无法找到 {{serverName}} 的配置数据",deleteError:"删除服务器 {{serverName}} 失败",updateError:"更新服务器失败",editTitle:"编辑服务器: {{serverName}}",type:"服务器类型",command:"命令",arguments:"参数",envVars:"环境变量",key:"键",value:"值",enabled:"已启用",enable:"启用",disable:"禁用",remove:"移除",toggleError:"切换服务器 {{serverName}} 状态失败",alreadyExists:"服务器 {{serverName}} 已经存在",invalidData:"提供的服务器数据无效",notFound:"找不到服务器 {{serverName}}",namePlaceholder:"请输入服务器名称",urlPlaceholder:"请输入服务器URL",commandPlaceholder:"请输入命令",argumentsPlaceholder:"请输入参数",errorDetails:"错误详情",viewErrorDetails:"查看错误详情"},o2={online:"在线",offline:"离线",connecting:"连接中"},u2={general:"发生错误",network:"网络连接错误,请检查您的互联网连接",serverConnection:"无法连接到服务器,请检查服务器是否正在运行",serverAdd:"添加服务器失败,请检查服务器状态",serverUpdate:"编辑服务器 {{serverName}} 失败,请检查服务器状态",serverFetch:"获取服务器数据失败,请稍后重试",initialStartup:"服务器可能正在启动中。首次启动可能需要一些时间,请耐心等候...",serverInstall:"安装服务器失败",failedToFetchSettings:"获取设置失败",failedToUpdateSystemConfig:"更新系统配置失败",failedToUpdateRouteConfig:"更新路由配置失败",failedToUpdateSmartRoutingConfig:"更新智能路由配置失败"},c2={processing:"处理中...",save:"保存",cancel:"取消",refresh:"刷新",create:"创建",submitting:"提交中...",delete:"删除",copy:"复制",copySuccess:"已复制到剪贴板",copyFailed:"复制失败",close:"关闭"},d2={dashboard:"仪表盘",servers:"服务器",settings:"设置",changePassword:"修改密码",groups:"分组",market:"市场",logs:"日志"},f2={dashboard:{title:"仪表盘",totalServers:"总数",onlineServers:"在线",offlineServers:"离线",connectingServers:"连接中",recentServers:"最近的服务器"},servers:{title:"服务器管理"},settings:{title:"设置",language:"语言",account:"账户设置",password:"修改密码",appearance:"外观",routeConfig:"安全配置",installConfig:"安装",smartRouting:"智能路由"},groups:{title:"分组管理"},market:{title:"服务器市场 - (数据来源于 mcpm.sh)"},logs:{title:"系统日志"}},h2={filters:"筛选",search:"搜索日志...",autoScroll:"自动滚动",clearLogs:"清除日志",loading:"加载日志中...",noLogs:"暂无日志。",noMatch:"没有匹配当前筛选条件的日志。",mainProcess:"主进程",childProcess:"子进程",main:"主",child:"子"},m2={add:"添加",addNew:"添加新分组",edit:"编辑分组",delete:"删除",confirmDelete:"您确定要删除此分组吗?",deleteWarning:"删除分组 '{{name}}' 将会移除该分组及其所有服务器关联。此操作无法撤销。",name:"分组名称",namePlaceholder:"请输入分组名称",nameRequired:"分组名称不能为空",description:"描述",descriptionPlaceholder:"请输入分组描述(可选)",createError:"创建分组失败",updateError:"更新分组失败",deleteError:"删除分组失败",serverAddError:"向分组添加服务器失败",serverRemoveError:"从分组移除服务器失败",addServer:"添加服务器到分组",selectServer:"选择要添加的服务器",servers:"分组中的服务器",remove:"移除",noGroups:"暂无可用分组。创建一个新分组以开始使用。",noServers:"此分组中没有服务器。",noServerOptions:"没有可用的服务器",serverCount:"{{count}} 台服务器"},g2={title:"服务器市场",official:"官方",by:"作者",unknown:"未知",tools:"工具",search:"搜索",searchPlaceholder:"搜索服务器名称、分类或标签",clearFilters:"清除",clearCategoryFilter:"",clearTagFilter:"",categories:"分类",tags:"标签",showTags:"显示标签",hideTags:"隐藏标签",moreTags:"",noServers:"未找到匹配的服务器",backToList:"返回列表",install:"安装",installing:"安装中...",installed:"已安装",installServer:"安装服务器: {{name}}",installSuccess:"服务器 {{serverName}} 安装成功",author:"作者",license:"许可证",repository:"代码仓库",examples:"示例",arguments:"参数",argumentName:"名称",description:"描述",required:"必填",example:"示例",viewSchema:"查看结构",fetchError:"获取服务器市场数据失败",serverNotFound:"未找到服务器",searchError:"搜索服务器失败",filterError:"按分类筛选服务器失败",tagFilterError:"按标签筛选服务器失败",noInstallationMethod:"该服务器没有可用的安装方法",showing:"显示 {{from}}-{{to}}/{{total}} 个服务器",perPage:"每页显示"},p2={enableGlobalRoute:"启用全局路由",enableGlobalRouteDescription:"允许不指定组 ID 就连接到 /sse 端点",enableGroupNameRoute:"启用组名路由",enableGroupNameRouteDescription:"允许使用组名而不仅仅是组 ID 连接到 /sse 端点",enableBearerAuth:"启用 Bearer 认证",enableBearerAuthDescription:"对 MCP 请求启用 Bearer 令牌认证",bearerAuthKey:"Bearer 认证密钥",bearerAuthKeyDescription:"Bearer 令牌中需要携带的认证密钥",bearerAuthKeyPlaceholder:"请输入 Bearer 认证密钥",pythonIndexUrl:"Python 包仓库地址",pythonIndexUrlDescription:"设置 UV_DEFAULT_INDEX 环境变量,用于 Python 包安装",pythonIndexUrlPlaceholder:"例如: https://mirrors.aliyun.com/pypi/simple",npmRegistry:"NPM 仓库地址",npmRegistryDescription:"设置 npm_config_registry 环境变量,用于 NPM 包安装",npmRegistryPlaceholder:"例如: https://registry.npmmirror.com/",installConfig:"安装配置",systemConfigUpdated:"系统配置更新成功",enableSmartRouting:"启用智能路由",enableSmartRoutingDescription:"开启智能路由功能,根据输入自动搜索最合适的工具(使用 $smart 分组)",dbUrl:"PostgreSQL 连接地址(支持 pgvector)",dbUrlPlaceholder:"例如: postgresql://user:password@localhost:5432/dbname",openaiApiBaseUrl:"OpenAI API 基础地址",openaiApiBaseUrlPlaceholder:"https://api.openai.com/v1",openaiApiKey:"OpenAI API 密钥",openaiApiKeyDescription:"用于访问 OpenAI API 的密钥",openaiApiKeyPlaceholder:"请输入 OpenAI API 密钥",openaiApiEmbeddingModel:"OpenAI 嵌入模型",openaiApiEmbeddingModelPlaceholder:"text-embedding-3-small",smartRoutingConfigUpdated:"智能路由配置更新成功",smartRoutingRequiredFields:"启用智能路由需要填写数据库连接地址和 OpenAI API 密钥",smartRoutingValidationError:"启用智能路由前请先填写必要字段:{{fields}}"},y2={app:I1,about:e2,profile:t2,sponsor:a2,wechat:n2,discord:l2,theme:s2,auth:r2,server:i2,status:o2,errors:u2,common:c2,nav:d2,pages:f2,logs:h2,groups:m2,market:g2,settings:p2};it.use(wg).use(ib).init({resources:{en:{translation:W1},zh:{translation:y2}},fallbackLng:"en",debug:!1,defaultNS:"translation",interpolation:{escapeValue:!1},detection:{order:["localStorage","cookie","htmlTag","navigator"],caches:["localStorage","cookie"]}});async function x2(){try{console.log("Loading runtime configuration...");const l=await Tx();console.log("Runtime configuration loaded:",l),window.__MCPHUB_CONFIG__=l,Qh.createRoot(document.getElementById("root")).render(c.jsx(vu.StrictMode,{children:c.jsx(im,{})}))}catch(l){console.error("Failed to initialize app:",l),console.log("Starting app with default configuration..."),window.__MCPHUB_CONFIG__={basePath:"",version:"dev",name:"mcphub"},Qh.createRoot(document.getElementById("root")).render(c.jsx(vu.StrictMode,{children:c.jsx(im,{})}))}}x2();
148
- //# sourceMappingURL=index-D_eNkDvW.js.map
146
+ */const cv=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ds=ut("x",cv);function Fm(l){var s,r,o="";if(typeof l=="string"||typeof l=="number")o+=l;else if(typeof l=="object")if(Array.isArray(l)){var d=l.length;for(s=0;s<d;s++)l[s]&&(r=Fm(l[s]))&&(o&&(o+=" "),o+=r)}else for(r in l)l[r]&&(o&&(o+=" "),o+=r);return o}function dv(){for(var l,s,r=0,o="",d=arguments.length;r<d;r++)(l=arguments[r])&&(s=Fm(l))&&(o&&(o+=" "),o+=s);return o}const Gu="-",fv=l=>{const s=mv(l),{conflictingClassGroups:r,conflictingClassGroupModifiers:o}=l;return{getClassGroupId:m=>{const y=m.split(Gu);return y[0]===""&&y.length!==1&&y.shift(),Wm(y,s)||hv(m)},getConflictingClassGroupIds:(m,y)=>{const h=r[m]||[];return y&&o[m]?[...h,...o[m]]:h}}},Wm=(l,s)=>{var m;if(l.length===0)return s.classGroupId;const r=l[0],o=s.nextPart.get(r),d=o?Wm(l.slice(1),o):void 0;if(d)return d;if(s.validators.length===0)return;const f=l.join(Gu);return(m=s.validators.find(({validator:y})=>y(f)))==null?void 0:m.classGroupId},em=/^\[(.+)\]$/,hv=l=>{if(em.test(l)){const s=em.exec(l)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},mv=l=>{const{theme:s,classGroups:r}=l,o={nextPart:new Map,validators:[]};for(const d in r)Nu(r[d],o,d,s);return o},Nu=(l,s,r,o)=>{l.forEach(d=>{if(typeof d=="string"){const f=d===""?s:tm(s,d);f.classGroupId=r;return}if(typeof d=="function"){if(gv(d)){Nu(d(o),s,r,o);return}s.validators.push({validator:d,classGroupId:r});return}Object.entries(d).forEach(([f,m])=>{Nu(m,tm(s,f),r,o)})})},tm=(l,s)=>{let r=l;return s.split(Gu).forEach(o=>{r.nextPart.has(o)||r.nextPart.set(o,{nextPart:new Map,validators:[]}),r=r.nextPart.get(o)}),r},gv=l=>l.isThemeGetter,pv=l=>{if(l<1)return{get:()=>{},set:()=>{}};let s=0,r=new Map,o=new Map;const d=(f,m)=>{r.set(f,m),s++,s>l&&(s=0,o=r,r=new Map)};return{get(f){let m=r.get(f);if(m!==void 0)return m;if((m=o.get(f))!==void 0)return d(f,m),m},set(f,m){r.has(f)?r.set(f,m):d(f,m)}}},ju="!",Eu=":",yv=Eu.length,xv=l=>{const{prefix:s,experimentalParseClassName:r}=l;let o=d=>{const f=[];let m=0,y=0,h=0,g;for(let N=0;N<d.length;N++){let C=d[N];if(m===0&&y===0){if(C===Eu){f.push(d.slice(h,N)),h=N+yv;continue}if(C==="/"){g=N;continue}}C==="["?m++:C==="]"?m--:C==="("?y++:C===")"&&y--}const v=f.length===0?d:d.substring(h),w=vv(v),b=w!==v,R=g&&g>h?g-h:void 0;return{modifiers:f,hasImportantModifier:b,baseClassName:w,maybePostfixModifierPosition:R}};if(s){const d=s+Eu,f=o;o=m=>m.startsWith(d)?f(m.substring(d.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:m,maybePostfixModifierPosition:void 0}}if(r){const d=o;o=f=>r({className:f,parseClassName:d})}return o},vv=l=>l.endsWith(ju)?l.substring(0,l.length-1):l.startsWith(ju)?l.substring(1):l,bv=l=>{const s=Object.fromEntries(l.orderSensitiveModifiers.map(o=>[o,!0]));return o=>{if(o.length<=1)return o;const d=[];let f=[];return o.forEach(m=>{m[0]==="["||s[m]?(d.push(...f.sort(),m),f=[]):f.push(m)}),d.push(...f.sort()),d}},Sv=l=>({cache:pv(l.cacheSize),parseClassName:xv(l),sortModifiers:bv(l),...fv(l)}),wv=/\s+/,Nv=(l,s)=>{const{parseClassName:r,getClassGroupId:o,getConflictingClassGroupIds:d,sortModifiers:f}=s,m=[],y=l.trim().split(wv);let h="";for(let g=y.length-1;g>=0;g-=1){const v=y[g],{isExternal:w,modifiers:b,hasImportantModifier:R,baseClassName:N,maybePostfixModifierPosition:C}=r(v);if(w){h=v+(h.length>0?" "+h:h);continue}let A=!!C,z=o(A?N.substring(0,C):N);if(!z){if(!A){h=v+(h.length>0?" "+h:h);continue}if(z=o(N),!z){h=v+(h.length>0?" "+h:h);continue}A=!1}const T=f(b).join(":"),D=R?T+ju:T,q=D+z;if(m.includes(q))continue;m.push(q);const Y=d(z,A);for(let W=0;W<Y.length;++W){const H=Y[W];m.push(D+H)}h=v+(h.length>0?" "+h:h)}return h};function jv(){let l=0,s,r,o="";for(;l<arguments.length;)(s=arguments[l++])&&(r=Im(s))&&(o&&(o+=" "),o+=r);return o}const Im=l=>{if(typeof l=="string")return l;let s,r="";for(let o=0;o<l.length;o++)l[o]&&(s=Im(l[o]))&&(r&&(r+=" "),r+=s);return r};function Ev(l,...s){let r,o,d,f=m;function m(h){const g=s.reduce((v,w)=>w(v),l());return r=Sv(g),o=r.cache.get,d=r.cache.set,f=y,y(h)}function y(h){const g=o(h);if(g)return g;const v=Nv(h,r);return d(h,v),v}return function(){return f(jv.apply(null,arguments))}}const Pe=l=>{const s=r=>r[l]||[];return s.isThemeGetter=!0,s},eg=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,tg=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Cv=/^\d+\/\d+$/,kv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Av=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Tv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Rv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ov=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Pn=l=>Cv.test(l),Se=l=>!!l&&!Number.isNaN(Number(l)),Ga=l=>!!l&&Number.isInteger(Number(l)),pu=l=>l.endsWith("%")&&Se(l.slice(0,-1)),ha=l=>kv.test(l),Mv=()=>!0,zv=l=>Av.test(l)&&!Tv.test(l),ag=()=>!1,Dv=l=>Rv.test(l),Uv=l=>Ov.test(l),Lv=l=>!le(l)&&!se(l),_v=l=>nl(l,sg,ag),le=l=>eg.test(l),rn=l=>nl(l,rg,zv),yu=l=>nl(l,Vv,Se),am=l=>nl(l,ng,ag),Hv=l=>nl(l,lg,Uv),zr=l=>nl(l,ig,Dv),se=l=>tg.test(l),is=l=>ll(l,rg),Bv=l=>ll(l,Yv),nm=l=>ll(l,ng),Gv=l=>ll(l,sg),qv=l=>ll(l,lg),Dr=l=>ll(l,ig,!0),nl=(l,s,r)=>{const o=eg.exec(l);return o?o[1]?s(o[1]):r(o[2]):!1},ll=(l,s,r=!1)=>{const o=tg.exec(l);return o?o[1]?s(o[1]):r:!1},ng=l=>l==="position"||l==="percentage",lg=l=>l==="image"||l==="url",sg=l=>l==="length"||l==="size"||l==="bg-size",rg=l=>l==="length",Vv=l=>l==="number",Yv=l=>l==="family-name",ig=l=>l==="shadow",Kv=()=>{const l=Pe("color"),s=Pe("font"),r=Pe("text"),o=Pe("font-weight"),d=Pe("tracking"),f=Pe("leading"),m=Pe("breakpoint"),y=Pe("container"),h=Pe("spacing"),g=Pe("radius"),v=Pe("shadow"),w=Pe("inset-shadow"),b=Pe("text-shadow"),R=Pe("drop-shadow"),N=Pe("blur"),C=Pe("perspective"),A=Pe("aspect"),z=Pe("ease"),T=Pe("animate"),D=()=>["auto","avoid","all","avoid-page","page","left","right","column"],q=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],Y=()=>[...q(),se,le],W=()=>["auto","hidden","clip","visible","scroll"],H=()=>["auto","contain","none"],O=()=>[se,le,h],J=()=>[Pn,"full","auto",...O()],re=()=>[Ga,"none","subgrid",se,le],de=()=>["auto",{span:["full",Ga,se,le]},Ga,se,le],me=()=>[Ga,"auto",se,le],ke=()=>["auto","min","max","fr",se,le],oe=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],xe=()=>["start","end","center","stretch","center-safe","end-safe"],G=()=>["auto",...O()],V=()=>[Pn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...O()],$=()=>[l,se,le],ue=()=>[...q(),nm,am,{position:[se,le]}],E=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Q=()=>["auto","cover","contain",Gv,_v,{size:[se,le]}],ee=()=>[pu,is,rn],Z=()=>["","none","full",g,se,le],te=()=>["",Se,is,rn],ve=()=>["solid","dashed","dotted","double"],F=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],I=()=>[Se,pu,nm,am],ae=()=>["","none",N,se,le],ce=()=>["none",Se,se,le],et=()=>["none",Se,se,le],ct=()=>[Se,se,le],pt=()=>[Pn,"full",...O()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ha],breakpoint:[ha],color:[Mv],container:[ha],"drop-shadow":[ha],ease:["in","out","in-out"],font:[Lv],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ha],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ha],shadow:[ha],spacing:["px",Se],text:[ha],"text-shadow":[ha],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Pn,le,se,A]}],container:["container"],columns:[{columns:[Se,le,se,y]}],"break-after":[{"break-after":D()}],"break-before":[{"break-before":D()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:Y()}],overflow:[{overflow:W()}],"overflow-x":[{"overflow-x":W()}],"overflow-y":[{"overflow-y":W()}],overscroll:[{overscroll:H()}],"overscroll-x":[{"overscroll-x":H()}],"overscroll-y":[{"overscroll-y":H()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:J()}],"inset-x":[{"inset-x":J()}],"inset-y":[{"inset-y":J()}],start:[{start:J()}],end:[{end:J()}],top:[{top:J()}],right:[{right:J()}],bottom:[{bottom:J()}],left:[{left:J()}],visibility:["visible","invisible","collapse"],z:[{z:[Ga,"auto",se,le]}],basis:[{basis:[Pn,"full","auto",y,...O()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Se,Pn,"auto","initial","none",le]}],grow:[{grow:["",Se,se,le]}],shrink:[{shrink:["",Se,se,le]}],order:[{order:[Ga,"first","last","none",se,le]}],"grid-cols":[{"grid-cols":re()}],"col-start-end":[{col:de()}],"col-start":[{"col-start":me()}],"col-end":[{"col-end":me()}],"grid-rows":[{"grid-rows":re()}],"row-start-end":[{row:de()}],"row-start":[{"row-start":me()}],"row-end":[{"row-end":me()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ke()}],"auto-rows":[{"auto-rows":ke()}],gap:[{gap:O()}],"gap-x":[{"gap-x":O()}],"gap-y":[{"gap-y":O()}],"justify-content":[{justify:[...oe(),"normal"]}],"justify-items":[{"justify-items":[...xe(),"normal"]}],"justify-self":[{"justify-self":["auto",...xe()]}],"align-content":[{content:["normal",...oe()]}],"align-items":[{items:[...xe(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...xe(),{baseline:["","last"]}]}],"place-content":[{"place-content":oe()}],"place-items":[{"place-items":[...xe(),"baseline"]}],"place-self":[{"place-self":["auto",...xe()]}],p:[{p:O()}],px:[{px:O()}],py:[{py:O()}],ps:[{ps:O()}],pe:[{pe:O()}],pt:[{pt:O()}],pr:[{pr:O()}],pb:[{pb:O()}],pl:[{pl:O()}],m:[{m:G()}],mx:[{mx:G()}],my:[{my:G()}],ms:[{ms:G()}],me:[{me:G()}],mt:[{mt:G()}],mr:[{mr:G()}],mb:[{mb:G()}],ml:[{ml:G()}],"space-x":[{"space-x":O()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":O()}],"space-y-reverse":["space-y-reverse"],size:[{size:V()}],w:[{w:[y,"screen",...V()]}],"min-w":[{"min-w":[y,"screen","none",...V()]}],"max-w":[{"max-w":[y,"screen","none","prose",{screen:[m]},...V()]}],h:[{h:["screen","lh",...V()]}],"min-h":[{"min-h":["screen","lh","none",...V()]}],"max-h":[{"max-h":["screen","lh",...V()]}],"font-size":[{text:["base",r,is,rn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,se,yu]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",pu,le]}],"font-family":[{font:[Bv,le,s]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[d,se,le]}],"line-clamp":[{"line-clamp":[Se,"none",se,yu]}],leading:[{leading:[f,...O()]}],"list-image":[{"list-image":["none",se,le]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",se,le]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:$()}],"text-color":[{text:$()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ve(),"wavy"]}],"text-decoration-thickness":[{decoration:[Se,"from-font","auto",se,rn]}],"text-decoration-color":[{decoration:$()}],"underline-offset":[{"underline-offset":[Se,"auto",se,le]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",se,le]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",se,le]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ue()}],"bg-repeat":[{bg:E()}],"bg-size":[{bg:Q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ga,se,le],radial:["",se,le],conic:[Ga,se,le]},qv,Hv]}],"bg-color":[{bg:$()}],"gradient-from-pos":[{from:ee()}],"gradient-via-pos":[{via:ee()}],"gradient-to-pos":[{to:ee()}],"gradient-from":[{from:$()}],"gradient-via":[{via:$()}],"gradient-to":[{to:$()}],rounded:[{rounded:Z()}],"rounded-s":[{"rounded-s":Z()}],"rounded-e":[{"rounded-e":Z()}],"rounded-t":[{"rounded-t":Z()}],"rounded-r":[{"rounded-r":Z()}],"rounded-b":[{"rounded-b":Z()}],"rounded-l":[{"rounded-l":Z()}],"rounded-ss":[{"rounded-ss":Z()}],"rounded-se":[{"rounded-se":Z()}],"rounded-ee":[{"rounded-ee":Z()}],"rounded-es":[{"rounded-es":Z()}],"rounded-tl":[{"rounded-tl":Z()}],"rounded-tr":[{"rounded-tr":Z()}],"rounded-br":[{"rounded-br":Z()}],"rounded-bl":[{"rounded-bl":Z()}],"border-w":[{border:te()}],"border-w-x":[{"border-x":te()}],"border-w-y":[{"border-y":te()}],"border-w-s":[{"border-s":te()}],"border-w-e":[{"border-e":te()}],"border-w-t":[{"border-t":te()}],"border-w-r":[{"border-r":te()}],"border-w-b":[{"border-b":te()}],"border-w-l":[{"border-l":te()}],"divide-x":[{"divide-x":te()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":te()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ve(),"hidden","none"]}],"divide-style":[{divide:[...ve(),"hidden","none"]}],"border-color":[{border:$()}],"border-color-x":[{"border-x":$()}],"border-color-y":[{"border-y":$()}],"border-color-s":[{"border-s":$()}],"border-color-e":[{"border-e":$()}],"border-color-t":[{"border-t":$()}],"border-color-r":[{"border-r":$()}],"border-color-b":[{"border-b":$()}],"border-color-l":[{"border-l":$()}],"divide-color":[{divide:$()}],"outline-style":[{outline:[...ve(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Se,se,le]}],"outline-w":[{outline:["",Se,is,rn]}],"outline-color":[{outline:$()}],shadow:[{shadow:["","none",v,Dr,zr]}],"shadow-color":[{shadow:$()}],"inset-shadow":[{"inset-shadow":["none",w,Dr,zr]}],"inset-shadow-color":[{"inset-shadow":$()}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:$()}],"ring-offset-w":[{"ring-offset":[Se,rn]}],"ring-offset-color":[{"ring-offset":$()}],"inset-ring-w":[{"inset-ring":te()}],"inset-ring-color":[{"inset-ring":$()}],"text-shadow":[{"text-shadow":["none",b,Dr,zr]}],"text-shadow-color":[{"text-shadow":$()}],opacity:[{opacity:[Se,se,le]}],"mix-blend":[{"mix-blend":[...F(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":F()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Se]}],"mask-image-linear-from-pos":[{"mask-linear-from":I()}],"mask-image-linear-to-pos":[{"mask-linear-to":I()}],"mask-image-linear-from-color":[{"mask-linear-from":$()}],"mask-image-linear-to-color":[{"mask-linear-to":$()}],"mask-image-t-from-pos":[{"mask-t-from":I()}],"mask-image-t-to-pos":[{"mask-t-to":I()}],"mask-image-t-from-color":[{"mask-t-from":$()}],"mask-image-t-to-color":[{"mask-t-to":$()}],"mask-image-r-from-pos":[{"mask-r-from":I()}],"mask-image-r-to-pos":[{"mask-r-to":I()}],"mask-image-r-from-color":[{"mask-r-from":$()}],"mask-image-r-to-color":[{"mask-r-to":$()}],"mask-image-b-from-pos":[{"mask-b-from":I()}],"mask-image-b-to-pos":[{"mask-b-to":I()}],"mask-image-b-from-color":[{"mask-b-from":$()}],"mask-image-b-to-color":[{"mask-b-to":$()}],"mask-image-l-from-pos":[{"mask-l-from":I()}],"mask-image-l-to-pos":[{"mask-l-to":I()}],"mask-image-l-from-color":[{"mask-l-from":$()}],"mask-image-l-to-color":[{"mask-l-to":$()}],"mask-image-x-from-pos":[{"mask-x-from":I()}],"mask-image-x-to-pos":[{"mask-x-to":I()}],"mask-image-x-from-color":[{"mask-x-from":$()}],"mask-image-x-to-color":[{"mask-x-to":$()}],"mask-image-y-from-pos":[{"mask-y-from":I()}],"mask-image-y-to-pos":[{"mask-y-to":I()}],"mask-image-y-from-color":[{"mask-y-from":$()}],"mask-image-y-to-color":[{"mask-y-to":$()}],"mask-image-radial":[{"mask-radial":[se,le]}],"mask-image-radial-from-pos":[{"mask-radial-from":I()}],"mask-image-radial-to-pos":[{"mask-radial-to":I()}],"mask-image-radial-from-color":[{"mask-radial-from":$()}],"mask-image-radial-to-color":[{"mask-radial-to":$()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":q()}],"mask-image-conic-pos":[{"mask-conic":[Se]}],"mask-image-conic-from-pos":[{"mask-conic-from":I()}],"mask-image-conic-to-pos":[{"mask-conic-to":I()}],"mask-image-conic-from-color":[{"mask-conic-from":$()}],"mask-image-conic-to-color":[{"mask-conic-to":$()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ue()}],"mask-repeat":[{mask:E()}],"mask-size":[{mask:Q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",se,le]}],filter:[{filter:["","none",se,le]}],blur:[{blur:ae()}],brightness:[{brightness:[Se,se,le]}],contrast:[{contrast:[Se,se,le]}],"drop-shadow":[{"drop-shadow":["","none",R,Dr,zr]}],"drop-shadow-color":[{"drop-shadow":$()}],grayscale:[{grayscale:["",Se,se,le]}],"hue-rotate":[{"hue-rotate":[Se,se,le]}],invert:[{invert:["",Se,se,le]}],saturate:[{saturate:[Se,se,le]}],sepia:[{sepia:["",Se,se,le]}],"backdrop-filter":[{"backdrop-filter":["","none",se,le]}],"backdrop-blur":[{"backdrop-blur":ae()}],"backdrop-brightness":[{"backdrop-brightness":[Se,se,le]}],"backdrop-contrast":[{"backdrop-contrast":[Se,se,le]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Se,se,le]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Se,se,le]}],"backdrop-invert":[{"backdrop-invert":["",Se,se,le]}],"backdrop-opacity":[{"backdrop-opacity":[Se,se,le]}],"backdrop-saturate":[{"backdrop-saturate":[Se,se,le]}],"backdrop-sepia":[{"backdrop-sepia":["",Se,se,le]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":O()}],"border-spacing-x":[{"border-spacing-x":O()}],"border-spacing-y":[{"border-spacing-y":O()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",se,le]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Se,"initial",se,le]}],ease:[{ease:["linear","initial",z,se,le]}],delay:[{delay:[Se,se,le]}],animate:[{animate:["none",T,se,le]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[C,se,le]}],"perspective-origin":[{"perspective-origin":Y()}],rotate:[{rotate:ce()}],"rotate-x":[{"rotate-x":ce()}],"rotate-y":[{"rotate-y":ce()}],"rotate-z":[{"rotate-z":ce()}],scale:[{scale:et()}],"scale-x":[{"scale-x":et()}],"scale-y":[{"scale-y":et()}],"scale-z":[{"scale-z":et()}],"scale-3d":["scale-3d"],skew:[{skew:ct()}],"skew-x":[{"skew-x":ct()}],"skew-y":[{"skew-y":ct()}],transform:[{transform:[se,le,"","none","gpu","cpu"]}],"transform-origin":[{origin:Y()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:pt()}],"translate-x":[{"translate-x":pt()}],"translate-y":[{"translate-y":pt()}],"translate-z":[{"translate-z":pt()}],"translate-none":["translate-none"],accent:[{accent:$()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:$()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",se,le]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",se,le]}],fill:[{fill:["none",...$()]}],"stroke-w":[{stroke:[Se,is,rn,yu]}],stroke:[{stroke:["none",...$()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},$v=Ev(Kv);function qa(...l){return $v(dv(l))}const Qv=({message:l,type:s="info",duration:r=3e3,onClose:o,visible:d})=>{S.useEffect(()=>{if(d){const h=setTimeout(()=>{o()},r);return()=>clearTimeout(h)}},[d,r,o]);const f={success:c.jsx(Bu,{className:"w-5 h-5 text-green-500"}),error:c.jsx(ds,{className:"w-5 h-5 text-red-500"}),info:c.jsx("svg",{className:"w-5 h-5 text-blue-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),warning:c.jsx("svg",{className:"w-5 h-5 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})},m={success:"bg-green-50 border-green-200",error:"bg-red-50 border-red-200",info:"bg-blue-50 border-blue-200",warning:"bg-yellow-50 border-yellow-200"},y={success:"text-green-800",error:"text-red-800",info:"text-blue-800",warning:"text-yellow-800"};return c.jsx("div",{className:qa("fixed top-4 right-4 z-50 max-w-sm p-4 rounded-md shadow-lg border",m[s],"transform transition-all duration-300 ease-in-out",d?"translate-x-0 opacity-100":"translate-x-full opacity-0"),children:c.jsxs("div",{className:"flex items-start",children:[c.jsx("div",{className:"flex-shrink-0",children:f[s]}),c.jsx("div",{className:"ml-3",children:c.jsx("p",{className:qa("text-sm font-medium",y[s]),children:l})}),c.jsx("div",{className:"ml-auto pl-3",children:c.jsx("div",{className:"-mx-1.5 -my-1.5",children:c.jsxs("button",{onClick:o,className:qa("inline-flex rounded-md p-1.5",`hover:bg-${s}-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-${s}-500`),children:[c.jsx("span",{className:"sr-only",children:"Dismiss"}),c.jsx(ds,{className:"h-5 w-5"})]})})})]})})},og=S.createContext(void 0),ps=()=>{const l=S.useContext(og);if(!l)throw new Error("useToast must be used within a ToastProvider");return l},Xv=({children:l})=>{const[s,r]=S.useState({message:"",type:"info",visible:!1,duration:3e3}),o=S.useCallback((f,m="info",y=3e3)=>{r({message:f,type:m,visible:!0,duration:y})},[]),d=S.useCallback(()=>{r(f=>({...f,visible:!1}))},[]);return c.jsxs(og.Provider,{value:{showToast:o},children:[l,c.jsx(Qv,{message:s.message,type:s.type,duration:s.duration,onClose:d,visible:s.visible})]})},ug=S.createContext(void 0),Zv=()=>{const l=S.useContext(ug);if(!l)throw new Error("useTheme must be used within a ThemeProvider");return l},Pv=({children:l})=>{const[s,r]=S.useState(()=>localStorage.getItem("theme")||"system"),[o,d]=S.useState("light"),f=m=>{r(m),localStorage.setItem("theme",m)};return S.useEffect(()=>{const m=()=>{const h=window.document.documentElement,g=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",v=s==="system"?g:s;d(v),v==="dark"?(console.log("Applying dark mode to HTML root element"),h.classList.add("dark"),document.body.style.backgroundColor="#111827"):(console.log("Removing dark mode from HTML root element"),h.classList.remove("dark"),document.body.style.backgroundColor="")},y=window.matchMedia("(prefers-color-scheme: dark)");return y.addEventListener("change",m),m(),()=>{y.removeEventListener("change",m)}},[s]),c.jsx(ug.Provider,{value:{theme:s,setTheme:f,resolvedTheme:o},children:l})},Jv=(l,s,r,o)=>{var f,m,y,h;const d=[r,{code:s,...o||{}}];if((m=(f=l==null?void 0:l.services)==null?void 0:f.logger)!=null&&m.forward)return l.services.logger.forward(d,"warn","react-i18next::",!0);on(d[0])&&(d[0]=`react-i18next:: ${d[0]}`),(h=(y=l==null?void 0:l.services)==null?void 0:y.logger)!=null&&h.warn?l.services.logger.warn(...d):console!=null&&console.warn&&console.warn(...d)},lm={},Cu=(l,s,r,o)=>{on(r)&&lm[r]||(on(r)&&(lm[r]=new Date),Jv(l,s,r,o))},cg=(l,s)=>()=>{if(l.isInitialized)s();else{const r=()=>{setTimeout(()=>{l.off("initialized",r)},0),s()};l.on("initialized",r)}},ku=(l,s,r)=>{l.loadNamespaces(s,cg(l,r))},sm=(l,s,r,o)=>{if(on(r)&&(r=[r]),l.options.preload&&l.options.preload.indexOf(s)>-1)return ku(l,r,o);r.forEach(d=>{l.options.ns.indexOf(d)<0&&l.options.ns.push(d)}),l.loadLanguages(s,cg(l,o))},Fv=(l,s,r={})=>!s.languages||!s.languages.length?(Cu(s,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:s.languages}),!0):s.hasLoadedNamespace(l,{lng:r.lng,precheck:(o,d)=>{var f;if(((f=r.bindI18n)==null?void 0:f.indexOf("languageChanging"))>-1&&o.services.backendConnector.backend&&o.isLanguageChangingTo&&!d(o.isLanguageChangingTo,l))return!1}}),on=l=>typeof l=="string",Wv=l=>typeof l=="object"&&l!==null,Iv=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,eb={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},tb=l=>eb[l],ab=l=>l.replace(Iv,tb);let Au={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:ab};const nb=(l={})=>{Au={...Au,...l}},lb=()=>Au;let dg;const sb=l=>{dg=l},rb=()=>dg,ib={type:"3rdParty",init(l){nb(l.options.react),sb(l)}},ob=S.createContext();class ub{constructor(){this.usedNamespaces={}}addUsedNamespaces(s){s.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const cb=(l,s)=>{const r=S.useRef();return S.useEffect(()=>{r.current=l},[l,s]),r.current},fg=(l,s,r,o)=>l.getFixedT(s,r,o),db=(l,s,r,o)=>S.useCallback(fg(l,s,r,o),[l,s,r,o]),Te=(l,s={})=>{var q,Y,W,H;const{i18n:r}=s,{i18n:o,defaultNS:d}=S.useContext(ob)||{},f=r||o||rb();if(f&&!f.reportNamespaces&&(f.reportNamespaces=new ub),!f){Cu(f,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const O=(re,de)=>on(de)?de:Wv(de)&&on(de.defaultValue)?de.defaultValue:Array.isArray(re)?re[re.length-1]:re,J=[O,{},!1];return J.t=O,J.i18n={},J.ready=!1,J}(q=f.options.react)!=null&&q.wait&&Cu(f,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const m={...lb(),...f.options.react,...s},{useSuspense:y,keyPrefix:h}=m;let g=d||((Y=f.options)==null?void 0:Y.defaultNS);g=on(g)?[g]:g||["translation"],(H=(W=f.reportNamespaces).addUsedNamespaces)==null||H.call(W,g);const v=(f.isInitialized||f.initializedStoreOnce)&&g.every(O=>Fv(O,f,m)),w=db(f,s.lng||null,m.nsMode==="fallback"?g:g[0],h),b=()=>w,R=()=>fg(f,s.lng||null,m.nsMode==="fallback"?g:g[0],h),[N,C]=S.useState(b);let A=g.join();s.lng&&(A=`${s.lng}${A}`);const z=cb(A),T=S.useRef(!0);S.useEffect(()=>{const{bindI18n:O,bindI18nStore:J}=m;T.current=!0,!v&&!y&&(s.lng?sm(f,s.lng,g,()=>{T.current&&C(R)}):ku(f,g,()=>{T.current&&C(R)})),v&&z&&z!==A&&T.current&&C(R);const re=()=>{T.current&&C(R)};return O&&(f==null||f.on(O,re)),J&&(f==null||f.store.on(J,re)),()=>{T.current=!1,f&&(O==null||O.split(" ").forEach(de=>f.off(de,re))),J&&f&&J.split(" ").forEach(de=>f.store.off(de,re))}},[f,A]),S.useEffect(()=>{T.current&&v&&C(b)},[f,h,v]);const D=[N,f,v];if(D.t=N,D.i18n=f,D.ready=v,v||!v&&!y)return D;throw new Promise(O=>{s.lng?sm(f,s.lng,g,()=>O()):ku(f,g,()=>O())})},hg=()=>{const{t:l}=Te(),{theme:s,setTheme:r}=Zv();return c.jsx("div",{className:"flex items-center space-x-2",children:c.jsxs("div",{className:"flex bg-gray-200 dark:bg-gray-700 rounded-lg p-1",children:[c.jsx("button",{onClick:()=>r("light"),className:`flex items-center justify-center rounded-md p-1.5 ${s==="light"?"bg-white text-yellow-600 shadow":"text-black dark:text-gray-300 hover:text-yellow-600 dark:hover:text-yellow-500"}`,title:l("theme.light"),"aria-label":l("theme.light"),children:c.jsx(sv,{size:18})}),c.jsx("button",{onClick:()=>r("dark"),className:`flex items-center justify-center rounded-md p-1.5 ${s==="dark"?"bg-gray-800 text-blue-400 shadow":"text-gray-600 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400"}`,title:l("theme.dark"),"aria-label":l("theme.dark"),children:c.jsx(Fx,{size:18})})]})})},fb=l=>c.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",...l,children:[c.jsx("title",{children:"GitHub"}),c.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})]}),hb=l=>c.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",...l,children:[c.jsx("title",{children:"Sponsor"}),c.jsx("path",{d:"M17.625 1.499c-2.32 0-4.354 1.203-5.625 3.03-1.271-1.827-3.305-3.03-5.625-3.03C3.129 1.499 0 4.253 0 8.249c0 4.275 3.068 7.847 5.828 10.227a33.14 33.14 0 0 0 5.616 3.876l.028.017.008.003-.001.003c.163.085.342.126.521.125.179.001.358-.041.521-.125l-.001-.003.008-.003.028-.017a33.14 33.14 0 0 0 5.616-3.876C20.932 16.096 24 12.524 24 8.249c0-3.996-3.129-6.75-6.375-6.75zm-.919 15.275a30.766 30.766 0 0 1-4.703 3.316l-.004-.002-.004.002a30.955 30.955 0 0 1-4.703-3.316c-2.677-2.307-5.047-5.298-5.047-8.523 0-2.754 2.121-4.5 4.125-4.5 2.06 0 3.914 1.479 4.544 3.684.143.495.596.797 1.086.796.49.001.943-.302 1.085-.796.63-2.205 2.484-3.684 4.544-3.684 2.004 0 4.125 1.746 4.125 4.5 0 3.225-2.37 6.216-5.048 8.523z"})]}),mb=l=>c.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",...l,children:[c.jsx("title",{children:"WeChat"}),c.jsx("path",{d:"M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 0 0 .167-.054l1.903-1.114a.864.864 0 0 1 .717-.098 10.16 10.16 0 0 0 2.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 3.882-1.98 5.853-1.838-.576-3.583-4.196-6.348-8.596-6.348zM5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178A1.17 1.17 0 0 1 4.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178 1.17 1.17 0 0 1-1.162-1.178c0-.651.52-1.18 1.162-1.18zm5.34 2.867c-1.797-.052-3.746.512-5.28 1.786-1.72 1.428-2.687 3.72-1.78 6.22.942 2.453 3.666 4.229 6.884 4.229.826 0 1.622-.12 2.361-.336a.722.722 0 0 1 .598.082l1.584.926a.272.272 0 0 0 .14.047c.134 0 .24-.111.24-.247 0-.06-.023-.12-.038-.177l-.327-1.233a.582.582 0 0 1-.023-.156.49.49 0 0 1 .201-.398C23.024 18.48 24 16.82 24 14.98c0-3.21-2.931-5.837-6.656-6.088V8.89c-.135-.01-.27-.027-.407-.03zm-2.53 3.274c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.97-.982zm4.844 0c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.969-.982z"})]}),gb=l=>c.jsxs("svg",{role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"currentColor",...l,children:[c.jsx("title",{children:"Discord"}),c.jsx("path",{d:"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"})]}),pb=({open:l,onOpenChange:s})=>{const{i18n:r,t:o}=Te();return l?c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg max-w-md w-full",children:c.jsxs("div",{className:"p-6 relative",children:[c.jsx("button",{onClick:()=>s(!1),className:"absolute top-4 right-4 text-gray-400 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-400","aria-label":o("common.close"),children:c.jsx(ds,{className:"h-5 w-5"})}),c.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-4",children:o("sponsor.title")}),c.jsx("div",{className:"flex flex-col items-center justify-center py-4",children:r.language==="zh"?c.jsx("img",{src:"./assets/reward.png",alt:o("sponsor.rewardAlt"),className:"max-w-full h-auto",style:{maxHeight:"400px"}}):c.jsxs("div",{className:"text-center",children:[c.jsx("p",{className:"mb-4 text-gray-700 dark:text-gray-300",children:o("sponsor.supportMessage")}),c.jsx("a",{href:"https://ko-fi.com/samanhappy",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center bg-[#13C3FF] text-white px-4 py-2 rounded-md hover:bg-[#00A5E5] transition-colors",children:o("sponsor.supportButton")})]})})]})})}):null},yb=({open:l,onOpenChange:s})=>{const{t:r}=Te();return l?c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg max-w-md w-full",children:c.jsxs("div",{className:"p-6 relative",children:[c.jsx("button",{onClick:()=>s(!1),className:"absolute top-4 right-4 text-gray-400 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-400","aria-label":r("common.close"),children:c.jsx(ds,{className:"h-5 w-5"})}),c.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-4",children:r("wechat.title")}),c.jsxs("div",{className:"flex flex-col items-center justify-center py-4",children:[c.jsx("img",{src:"./assets/wexin.png",alt:r("wechat.qrCodeAlt"),className:"max-w-full h-auto",style:{maxHeight:"400px"}}),c.jsx("p",{className:"mt-4 text-center text-gray-700 dark:text-gray-300",children:r("wechat.scanMessage")})]})]})})}):null},xb=({onToggleSidebar:l})=>{const{t:s,i18n:r}=Te(),{auth:o}=Zr(),[d,f]=S.useState(!1),[m,y]=S.useState(!1);return c.jsxs("header",{className:"bg-white dark:bg-gray-800 shadow-sm z-10",children:[c.jsxs("div",{className:"flex justify-between items-center px-4 py-3",children:[c.jsxs("div",{className:"flex items-center",children:[c.jsx("button",{onClick:l,className:"p-2 rounded-md text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none","aria-label":s("app.toggleSidebar"),children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),c.jsx("h1",{className:"ml-4 text-xl font-bold text-gray-900 dark:text-white",children:s("app.title")})]}),c.jsxs("div",{className:"flex items-center space-x-4",children:[c.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"v0.7.1"}),c.jsx("a",{href:"https://github.com/samanhappy/mcphub",target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200","aria-label":"GitHub Repository",children:c.jsx(fb,{className:"h-5 w-5"})}),r.language==="zh"?c.jsx("button",{onClick:()=>y(!0),className:"text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 focus:outline-none","aria-label":s("wechat.label"),children:c.jsx(mb,{className:"h-5 w-5"})}):c.jsx("a",{href:"https://discord.gg/qMKNsn5Q",target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200","aria-label":s("discord.label"),children:c.jsx(gb,{className:"h-5 w-5"})}),c.jsx("button",{onClick:()=>f(!0),className:"text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 focus:outline-none","aria-label":s("sponsor.label"),children:c.jsx(hb,{className:"h-5 w-5"})}),c.jsx(hg,{})]})]}),c.jsx(pb,{open:d,onOpenChange:f}),c.jsx(yb,{open:m,onOpenChange:y})]})},vb="https://registry.npmjs.org",bb="@samanhappy/mcphub",mg=async()=>{try{const l=await fetch(`${vb}/${bb}/latest`);if(!l.ok)throw new Error(`Failed to fetch latest version: ${l.status}`);return(await l.json()).version||null}catch(l){return console.error("Error checking for latest version:",l),null}},gg=(l,s)=>{if(l==="dev")return-1;const r=l.split(".").map(Number),o=s.split(".").map(Number);for(let d=0;d<3;d++){const f=r[d]||0,m=o[d]||0;if(f>m)return-1;if(f<m)return 1}return 0},Sb=({isOpen:l,onClose:s,version:r})=>{const{t:o}=Te(),[d,f]=S.useState(!1),[m,y]=S.useState(""),[h,g]=S.useState(!1),v=async()=>{g(!0);try{const w=await mg();w&&(y(w),f(gg(r,w)>0))}catch(w){console.error("Failed to check for updates:",w)}finally{g(!1)}};return S.useEffect(()=>{l&&v()},[l,r]),l?c.jsx("div",{className:"fixed inset-0 bg-black/50 bg-opacity-30 z-50 flex items-center justify-center p-4",children:c.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-lg max-w-md w-full",children:c.jsxs("div",{className:"p-6 relative",children:[c.jsx("button",{onClick:s,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-400","aria-label":o("common.close"),children:c.jsx(ds,{className:"h-5 w-5"})}),c.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-4",children:o("about.title")}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("span",{className:"text-gray-700 dark:text-gray-300",children:[o("about.currentVersion"),":"]}),c.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:r})]}),d&&m&&c.jsx("div",{className:"bg-blue-50 dark:bg-blue-900 p-3 rounded",children:c.jsxs("div",{className:"flex items-start",children:[c.jsx("div",{className:"flex-shrink-0",children:c.jsx("svg",{className:"h-5 w-5 text-blue-600 dark:text-blue-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),c.jsxs("div",{className:"ml-3 flex-1 text-sm text-blue-700 dark:text-blue-300",children:[c.jsx("p",{children:o("about.newVersionAvailable",{version:m})}),c.jsx("p",{className:"mt-1",children:c.jsx("a",{href:"https://github.com/samanhappy/mcphub",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline",children:o("about.viewOnGitHub")})})]})]})}),c.jsxs("button",{onClick:v,disabled:h,className:`mt-4 inline-flex items-center px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm text-sm font-medium
147
+ ${h?"text-gray-400 dark:text-gray-500 bg-gray-100 dark:bg-gray-800":"text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600"} focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500`,children:[c.jsx(Ix,{className:`h-4 w-4 mr-2 ${h?"animate-spin":""}`}),o(h?"about.checking":"about.checkForUpdates")]})]})]})})}):null},wb=({collapsed:l,version:s})=>{var A;const{t:r}=Te(),o=un(),{auth:d,logout:f}=Zr(),[m,y]=S.useState(!1),[h,g]=S.useState(!1),[v,w]=S.useState(!1),b=S.useRef(null);S.useEffect(()=>{(async()=>{try{const T=await mg();T&&g(gg(s,T)>0)}catch(T){console.error("Error checking for new version:",T)}})()},[s]),S.useEffect(()=>{const z=T=>{b.current&&!b.current.contains(T.target)&&y(!1)};return document.addEventListener("mousedown",z),()=>{document.removeEventListener("mousedown",z)}},[]);const R=()=>{o("/settings"),y(!1)},N=()=>{f(),o("/login")},C=()=>{w(!0),y(!1)};return c.jsxs("div",{ref:b,className:"relative",children:[c.jsxs("button",{onClick:()=>y(!m),className:`flex ${l?"justify-center":"items-center"} w-full p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors rounded-md ${m?"bg-gray-100 dark:bg-gray-700":""}`,children:[c.jsxs("div",{className:"flex-shrink-0 relative",children:[c.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-full border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-700",children:c.jsx(uv,{className:"h-4 w-4 text-gray-700 dark:text-gray-300"})}),h&&c.jsx("span",{className:"absolute -top-1 -right-1 block w-2 h-2 bg-red-500 rounded-full"})]}),!l&&c.jsx("div",{className:"ml-3 flex flex-col items-start",children:c.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:((A=d.user)==null?void 0:A.username)||r("auth.user")})})]}),m&&c.jsxs("div",{className:"absolute top-0 transform -translate-y-full left-0 w-48 bg-white dark:bg-gray-800 shadow-lg rounded-md py-1 z-50",children:[c.jsxs("button",{onClick:R,className:"flex items-center w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:[c.jsx(tv,{className:"h-4 w-4 mr-2"}),r("nav.settings")]}),c.jsxs("button",{onClick:C,className:"flex items-center w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 relative",children:[c.jsx(Xx,{className:"h-4 w-4 mr-2"}),r("about.title"),h&&c.jsx("span",{className:"absolute top-2 right-4 block w-2 h-2 bg-red-500 rounded-full"})]}),c.jsxs("button",{onClick:N,className:"flex items-center w-full px-4 py-2 text-left text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:[c.jsx(Px,{className:"h-4 w-4 mr-2"}),r("app.logout")]})]}),c.jsx(Sb,{isOpen:v,onClose:()=>w(!1),version:s})]})},Nb=({collapsed:l})=>{const{t:s}=Te();Jt();const r="0.7.1",o=[{path:"/",label:s("nav.dashboard"),icon:c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:[c.jsx("path",{d:"M2 10a8 8 0 018-8v8h8a8 8 0 11-16 0z"}),c.jsx("path",{d:"M12 2.252A8.014 8.014 0 0117.748 8H12V2.252z"})]})},{path:"/servers",label:s("nav.servers"),icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})})},{path:"/groups",label:s("nav.groups"),icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{d:"M13 6a3 3 0 11-6 0 3 3 0 016 0zM18 8a2 2 0 11-4 0 2 2 0 014 0zM14 15a4 4 0 00-8 0v3h8v-3zM6 8a2 2 0 11-4 0 2 2 0 014 0zM16 18v-3a5.972 5.972 0 00-.75-2.906A3.005 3.005 0 0119 15v3h-3zM4.75 12.094A5.973 5.973 0 004 15v3H1v-3a3 3 0 013.75-2.906z"})})},{path:"/market",label:s("nav.market"),icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{d:"M3 1a1 1 0 000 2h1.22l.305 1.222a.997.997 0 00.01.042l1.358 5.43-.893.892C3.74 11.846 4.632 14 6.414 14H15a1 1 0 000-2H6.414l1-1H14a1 1 0 00.894-.553l3-6A1 1 0 0017 3H6.28l-.31-1.243A1 1 0 005 1H3zM16 16.5a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0zM6.5 18a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"})})},{path:"/logs",label:s("nav.logs"),icon:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z",clipRule:"evenodd"})})}];return c.jsxs("aside",{className:`bg-white dark:bg-gray-800 shadow-sm transition-all duration-300 ease-in-out flex flex-col h-full relative ${l?"w-16":"w-64"}`,children:[c.jsx("div",{className:"overflow-y-auto flex-grow",children:c.jsx("nav",{className:"p-3 space-y-1",children:o.map(d=>c.jsxs(Vm,{to:d.path,className:({isActive:f})=>`flex items-center px-3 py-2 rounded-md transition-colors ${f?"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,end:d.path==="/",children:[c.jsx("span",{className:"flex-shrink-0",children:d.icon}),!l&&c.jsx("span",{className:"ml-3",children:d.label})]},d.path))})}),c.jsx("div",{className:"p-3 bg-white dark:bg-gray-800",children:c.jsx(wb,{collapsed:l,version:r})})]})},jb=({children:l})=>c.jsx("main",{className:"flex-1 overflow-auto p-6 bg-gray-100 dark:bg-gray-900",children:c.jsx("div",{className:"container mx-auto",children:l})}),Eb=()=>{const[l,s]=vu.useState(!1),r=()=>{s(!l)};return c.jsxs("div",{className:"flex flex-col h-screen bg-gray-100 dark:bg-gray-900",children:[c.jsx(xb,{onToggleSidebar:r}),c.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[c.jsx(Nb,{collapsed:l}),c.jsx(jb,{children:c.jsx(Lm,{})})]})]})},Cb=({redirectPath:l="/login"})=>{const{t:s}=Te(),{auth:r}=Zr();return r.loading?c.jsx("div",{className:"flex items-center justify-center h-screen",children:s("app.loading")}):r.isAuthenticated?c.jsx(Lm,{}):c.jsx(Um,{to:l,replace:!0})},kb=()=>{const{t:l}=Te(),[s,r]=S.useState(""),[o,d]=S.useState(""),[f,m]=S.useState(null),[y,h]=S.useState(!1),{login:g}=Zr(),v=un(),w=async b=>{b.preventDefault(),m(null),h(!0);try{if(!s||!o){m(l("auth.emptyFields")),h(!1);return}await g(s,o)?v("/"):m(l("auth.loginFailed"))}catch{m(l("auth.loginError"))}finally{h(!1)}};return c.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 py-12 px-4 sm:px-6 lg:px-8",children:[c.jsx("div",{className:"absolute top-4 right-4",children:c.jsx(hg,{})}),c.jsxs("div",{className:"max-w-md w-full space-y-8",children:[c.jsx("div",{children:c.jsx("h2",{className:"mt-6 text-center text-3xl font-extrabold text-gray-900 dark:text-white",children:l("auth.loginTitle")})}),c.jsxs("form",{className:"mt-8 space-y-6",onSubmit:w,children:[c.jsxs("div",{className:"rounded-md shadow-sm -space-y-px",children:[c.jsxs("div",{children:[c.jsx("label",{htmlFor:"username",className:"sr-only",children:l("auth.username")}),c.jsx("input",{id:"username",name:"username",type:"text",autoComplete:"username",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 dark:border-gray-700 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white dark:bg-gray-800 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",placeholder:l("auth.username"),value:s,onChange:b=>r(b.target.value)})]}),c.jsxs("div",{children:[c.jsx("label",{htmlFor:"password",className:"sr-only",children:l("auth.password")}),c.jsx("input",{id:"password",name:"password",type:"password",autoComplete:"current-password",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 dark:border-gray-700 placeholder-gray-500 dark:placeholder-gray-400 text-gray-900 dark:text-white dark:bg-gray-800 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",placeholder:l("auth.password"),value:o,onChange:b=>d(b.target.value)})]})]}),f&&c.jsx("div",{className:"text-red-500 dark:text-red-400 text-sm text-center",children:f}),c.jsx("div",{children:c.jsx("button",{type:"submit",disabled:y,className:"group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",children:l(y?"auth.loggingIn":"auth.login")})})]})]})]})},Ur={startup:{maxAttempts:60,pollingInterval:3e3},normal:{pollingInterval:1e4}},ys=()=>{const{t:l}=Te(),[s,r]=S.useState([]),[o,d]=S.useState(null),[f,m]=S.useState(0),[y,h]=S.useState(!0),[g,v]=S.useState(0),w=S.useRef(null),b=S.useRef(0),R=()=>{w.current&&(clearInterval(w.current),w.current=null)},N=S.useCallback(()=>{R();const q=async()=>{try{const Y=localStorage.getItem("mcphub_token"),H=await(await fetch(Ee("/servers"),{headers:{"x-auth-token":Y||""}})).json();H&&H.success&&Array.isArray(H.data)?r(H.data):H&&Array.isArray(H)?r(H):(console.error("Invalid server data format:",H),r([])),d(null)}catch(Y){console.error("Error fetching servers during normal polling:",Y),navigator.onLine?Y instanceof TypeError&&(Y.message.includes("NetworkError")||Y.message.includes("Failed to fetch"))?d(l("errors.serverConnection")):d(l("errors.serverFetch")):d(l("errors.network"))}};q(),w.current=setInterval(q,Ur.normal.pollingInterval)},[l]);return S.useEffect(()=>{f>0&&(b.current=0,v(0));const q=async()=>{try{const Y=localStorage.getItem("mcphub_token"),H=await(await fetch(Ee("/servers"),{headers:{"x-auth-token":Y||""}})).json();return H&&H.success&&Array.isArray(H.data)?(r(H.data),h(!1),N(),!0):H&&Array.isArray(H)?(r(H),h(!1),N(),!0):(console.error("Invalid server data format:",H),r([]),h(!1),N(),!0)}catch(Y){return b.current+=1,console.error(`Initial loading attempt ${b.current} failed:`,Y),v(b.current),navigator.onLine?d(l("errors.initialStartup")):d(l("errors.network")),b.current>=Ur.startup.maxAttempts&&(console.log("Maximum startup attempts reached, switching to normal polling"),h(!1),R(),N()),!1}};return y?(R(),q(),w.current=setInterval(q,Ur.startup.pollingInterval),console.log(`Started initial polling with interval: ${Ur.startup.pollingInterval}ms`)):N(),()=>{R()}},[f,l,y,N]),{servers:s,error:o,setError:d,isLoading:y,fetchAttempts:g,triggerRefresh:()=>{R(),y&&(h(!0),b.current=0,v(0)),m(q=>q+1)},handleServerAdd:()=>{m(q=>q+1)},handleServerEdit:async q=>{try{const Y=localStorage.getItem("mcphub_token"),H=await(await fetch(Ee("/settings"),{headers:{"x-auth-token":Y||""}})).json();if(H&&H.success&&H.data&&H.data.mcpServers&&H.data.mcpServers[q.name]){const O=H.data.mcpServers[q.name];return{name:q.name,status:q.status,tools:q.tools||[],config:O}}else return console.error("Failed to get server config from settings:",H),d(l("server.invalidConfig",{serverName:q.name})),null}catch(Y){return console.error("Error fetching server settings:",Y),d(Y instanceof Error?Y.message:String(Y)),null}},handleServerRemove:async q=>{try{const Y=localStorage.getItem("mcphub_token"),W=await fetch(Ee(`/servers/${q}`),{method:"DELETE",headers:{"x-auth-token":Y||""}}),H=await W.json();return W.ok?(m(O=>O+1),!0):(d(H.message||l("server.deleteError",{serverName:q})),!1)}catch(Y){return d(l("errors.general")+": "+(Y instanceof Error?Y.message:String(Y))),!1}},handleServerToggle:async(q,Y)=>{try{const W=localStorage.getItem("mcphub_token"),H=await fetch(Ee(`/servers/${q.name}/toggle`),{method:"POST",headers:{"Content-Type":"application/json","x-auth-token":W||""},body:JSON.stringify({enabled:Y})}),O=await H.json();return H.ok?(m(J=>J+1),!0):(console.error("Failed to toggle server:",O),d(l("server.toggleError",{serverName:q.name})),!1)}catch(W){return console.error("Error toggling server:",W),d(W instanceof Error?W.message:String(W)),!1}}}},Ab=()=>{const{t:l}=Te(),{servers:s,error:r,setError:o,isLoading:d}=ys(),f={total:s.length,online:s.filter(h=>h.status==="connected").length,offline:s.filter(h=>h.status==="disconnected").length,connecting:s.filter(h=>h.status==="connecting").length},m={connected:"status.online",disconnected:"status.offline",connecting:"status.connecting"},y=h=>s.length===0?0:Math.round(s.filter(g=>g.status===h).length/s.length*100);return c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-8",children:l("pages.dashboard.title")}),r&&c.jsx("div",{className:"mb-6 bg-red-50 border-l-4 border-red-500 p-4 rounded shadow-sm",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-red-600 text-lg font-medium",children:l("app.error")}),c.jsx("p",{className:"text-gray-600 mt-1",children:r})]}),c.jsx("button",{onClick:()=>o(null),className:"ml-4 text-gray-500 hover:text-gray-700","aria-label":l("app.closeButton"),children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 011.414 0L10 8.586l4.293-4.293a1 1 111.414 1.414L11.414 10l4.293 4.293a1 1 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 01-1.414-1.414L8.586 10 4.293 5.707a1 1 010-1.414z",clipRule:"evenodd"})})})]})}),d?c.jsx("div",{className:"bg-white shadow rounded-lg p-6 flex items-center justify-center",children:c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsxs("svg",{className:"animate-spin h-10 w-10 text-blue-500 mb-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c.jsx("p",{className:"text-gray-600",children:l("app.loading")})]})}):c.jsxs("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-4",children:[c.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:c.jsxs("div",{className:"flex items-center",children:[c.jsx("div",{className:"p-3 rounded-full bg-blue-100 text-blue-800",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"})})}),c.jsxs("div",{className:"ml-4",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-700",children:l("pages.dashboard.totalServers")}),c.jsx("p",{className:"text-3xl font-bold text-gray-900",children:f.total})]})]})}),c.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[c.jsxs("div",{className:"flex items-center",children:[c.jsx("div",{className:"p-3 rounded-full bg-green-100 text-green-800",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),c.jsxs("div",{className:"ml-4",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-700",children:l("pages.dashboard.onlineServers")}),c.jsx("p",{className:"text-3xl font-bold text-gray-900",children:f.online})]})]}),c.jsx("div",{className:"mt-4 h-2 bg-gray-200 rounded-full",children:c.jsx("div",{className:"h-full bg-green-500 rounded-full",style:{width:`${y("connected")}%`}})})]}),c.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[c.jsxs("div",{className:"flex items-center",children:[c.jsx("div",{className:"p-3 rounded-full bg-red-100 text-red-800",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),c.jsxs("div",{className:"ml-4",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-700",children:l("pages.dashboard.offlineServers")}),c.jsx("p",{className:"text-3xl font-bold text-gray-900",children:f.offline})]})]}),c.jsx("div",{className:"mt-4 h-2 bg-gray-200 rounded-full",children:c.jsx("div",{className:"h-full bg-red-500 rounded-full",style:{width:`${y("disconnected")}%`}})})]}),c.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[c.jsxs("div",{className:"flex items-center",children:[c.jsx("div",{className:"p-3 rounded-full bg-yellow-100 text-yellow-800",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),c.jsxs("div",{className:"ml-4",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-700",children:l("pages.dashboard.connectingServers")}),c.jsx("p",{className:"text-3xl font-bold text-gray-900",children:f.connecting})]})]}),c.jsx("div",{className:"mt-4 h-2 bg-gray-200 rounded-full",children:c.jsx("div",{className:"h-full bg-yellow-500 rounded-full",style:{width:`${y("connecting")}%`}})})]})]}),s.length>0&&!d&&c.jsxs("div",{className:"mt-8",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:l("pages.dashboard.recentServers")}),c.jsx("div",{className:"bg-white shadow rounded-lg overflow-hidden",children:c.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[c.jsx("thead",{className:"bg-gray-50",children:c.jsxs("tr",{children:[c.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:l("server.name")}),c.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:l("server.status")}),c.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:l("server.tools")}),c.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:l("server.enabled")})]})}),c.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:s.slice(0,5).map((h,g)=>{var v;return c.jsxs("tr",{children:[c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:h.name}),c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:c.jsx("span",{className:`px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${h.status==="connected"?"bg-green-100 text-green-800":h.status==="disconnected"?"bg-red-100 text-red-800":"bg-yellow-100 text-yellow-800"}`,children:l(m[h.status]||h.status)})}),c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:((v=h.tools)==null?void 0:v.length)||0}),c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:h.enabled!==!1?c.jsx("span",{className:"text-green-600",children:"✓"}):c.jsx("span",{className:"text-red-600",children:"✗"})})]},g)})})]})})]})]})},Tb={default:"bg-blue-500 text-white hover:bg-blue-600",secondary:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600",outline:"bg-transparent border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800",destructive:"bg-red-500 text-white hover:bg-red-600"};function Lr({children:l,variant:s="default",className:r,onClick:o}){return c.jsx("span",{className:qa("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors",Tb[s],o?"cursor-pointer":"",r),onClick:o,children:l})}const Rb=({status:l})=>{const{t:s}=Te(),r={connecting:"bg-yellow-100 text-yellow-800",connected:"bg-green-100 text-green-800",disconnected:"bg-red-100 text-red-800"},o={connected:"status.online",disconnected:"status.offline",connecting:"status.connecting"};return c.jsx("span",{className:`px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${r[l]}`,children:s(o[l]||l)})},Ob=({tool:l})=>{const[s,r]=S.useState(!1);return c.jsxs("div",{className:"bg-white shadow rounded-lg p-4 mb-4",children:[c.jsxs("div",{className:"flex justify-between items-center cursor-pointer",onClick:()=>r(!s),children:[c.jsx("h3",{className:"text-lg font-medium text-gray-900",children:l.name}),c.jsx("button",{className:"text-gray-400 hover:text-gray-600",children:s?c.jsx(Zm,{size:18}):c.jsx(Pm,{size:18})})]}),s&&c.jsxs("div",{className:"mt-4",children:[c.jsx("p",{className:"text-gray-600 mb-2",children:l.description||"No description available"}),c.jsxs("div",{className:"bg-gray-50 rounded p-2",children:[c.jsx("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:"Input Schema:"}),c.jsx("pre",{className:"text-xs text-gray-600 overflow-auto",children:JSON.stringify(l.inputSchema,null,2)})]})]})]})},pg=({isOpen:l,onClose:s,onConfirm:r,serverName:o,isGroup:d=!1})=>{const{t:f}=Te();return l?c.jsx("div",{className:"fixed inset-0 bg-black/50 bg-opacity-30 z-50 flex items-center justify-center p-4",children:c.jsx("div",{className:"bg-white rounded-lg shadow-lg max-w-md w-full",children:c.jsxs("div",{className:"p-6",children:[c.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-3",children:f(d?"groups.confirmDelete":"server.confirmDelete")}),c.jsx("p",{className:"text-gray-500 mb-6",children:d?f("groups.deleteWarning",{name:o}):f("server.deleteWarning",{name:o})}),c.jsxs("div",{className:"flex justify-end space-x-3",children:[c.jsx("button",{onClick:s,className:"px-4 py-2 text-gray-600 hover:text-gray-800",children:f("common.cancel")}),c.jsx("button",{onClick:r,className:"px-4 py-2 bg-red-500 text-white rounded hover:bg-red-600",children:f("common.delete")})]})]})})}):null},Mb=({server:l,onRemove:s,onEdit:r,onToggle:o})=>{const{t:d}=Te(),{showToast:f}=ps(),[m,y]=S.useState(!1),[h,g]=S.useState(!1),[v,w]=S.useState(!1),[b,R]=S.useState(!1),[N,C]=S.useState(!1),A=S.useRef(null);S.useEffect(()=>{const H=O=>{A.current&&!A.current.contains(O.target)&&R(!1)};return document.addEventListener("mousedown",H),()=>{document.removeEventListener("mousedown",H)}},[]);const z=H=>{H.stopPropagation(),g(!0)},T=H=>{H.stopPropagation(),r(l)},D=async H=>{if(H.stopPropagation(),!(v||!o)){w(!0);try{await o(l,l.enabled===!1)}finally{w(!1)}}},q=H=>{H.stopPropagation(),R(!b)},Y=H=>{if(H.stopPropagation(),!!l.error)if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(l.error).then(()=>{C(!0),f(d("common.copySuccess")||"Copied to clipboard","success"),setTimeout(()=>C(!1),2e3)});else{const O=document.createElement("textarea");O.value=l.error,O.style.position="fixed",O.style.left="-9999px",document.body.appendChild(O),O.focus(),O.select();try{document.execCommand("copy"),C(!0),f(d("common.copySuccess")||"Copied to clipboard","success"),setTimeout(()=>C(!1),2e3)}catch(J){f(d("common.copyFailed")||"Copy failed","error"),console.error("Copy to clipboard failed:",J)}document.body.removeChild(O)}},W=()=>{s(l.name),g(!1)};return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:`bg-white shadow rounded-lg p-6 mb-6 ${l.enabled===!1?"opacity-60":""}`,children:[c.jsxs("div",{className:"flex justify-between items-center cursor-pointer",onClick:()=>y(!m),children:[c.jsxs("div",{className:"flex items-center space-x-3",children:[c.jsx("h2",{className:`text-xl font-semibold ${l.enabled===!1?"text-gray-600":"text-gray-900"}`,children:l.name}),c.jsx(Rb,{status:l.status}),l.error&&c.jsxs("div",{className:"relative",children:[c.jsx("div",{className:"cursor-pointer",onClick:q,"aria-label":d("server.viewErrorDetails"),children:c.jsx(Kx,{className:"text-red-500 hover:text-red-600",size:18})}),b&&c.jsxs("div",{ref:A,className:"absolute z-10 mt-2 bg-white border border-gray-200 rounded-md shadow-lg p-0 w-120",style:{left:"-231px",top:"24px",maxHeight:"300px",overflowY:"auto",width:"480px",transform:"translateX(50%)"},onClick:H=>H.stopPropagation(),children:[c.jsxs("div",{className:"flex justify-between items-center sticky top-0 bg-white py-2 px-4 border-b border-gray-200 z-20 shadow-sm",children:[c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx("h4",{className:"text-sm font-medium text-red-600",children:d("server.errorDetails")}),c.jsx("button",{onClick:Y,className:"p-1 text-gray-400 hover:text-gray-600 transition-colors",title:d("common.copy"),children:N?c.jsx(Bu,{size:14,className:"text-green-500"}):c.jsx(Jm,{size:14})})]}),c.jsx("button",{onClick:H=>{H.stopPropagation(),R(!1)},className:"text-gray-400 hover:text-gray-600",children:"✕"})]}),c.jsx("div",{className:"p-4 pt-2",children:c.jsx("pre",{className:"text-sm text-gray-700 break-words whitespace-pre-wrap",children:l.error})})]})]})]}),c.jsxs("div",{className:"flex space-x-2",children:[c.jsx("button",{onClick:T,className:"px-3 py-1 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 text-sm",children:d("server.edit")}),c.jsx("div",{className:"flex items-center",children:c.jsx("button",{onClick:D,className:`px-3 py-1 text-sm rounded transition-colors ${v?"bg-gray-200 text-gray-500":l.enabled!==!1?"bg-green-100 text-green-800 hover:bg-green-200":"bg-gray-100 text-gray-800 hover:bg-gray-200"}`,disabled:v,children:v?d("common.processing"):l.enabled!==!1?d("server.disable"):d("server.enable")})}),c.jsx("button",{onClick:z,className:"px-3 py-1 bg-red-100 text-red-800 rounded hover:bg-red-200 text-sm",children:d("server.delete")}),c.jsx("button",{className:"text-gray-400 hover:text-gray-600",children:m?c.jsx(Zm,{size:18}):c.jsx(Pm,{size:18})})]})]}),m&&l.tools&&c.jsxs("div",{className:"mt-6",children:[c.jsx("h3",{className:`text-lg font-medium ${l.enabled===!1?"text-gray-600":"text-gray-900"} mb-4`,children:d("server.tools")}),c.jsx("div",{className:"space-y-4",children:l.tools.map((H,O)=>c.jsx(Ob,{tool:H},O))})]})]}),c.jsx(pg,{isOpen:h,onClose:()=>g(!1),onConfirm:W,serverName:l.name})]})},qu=({onSubmit:l,onCancel:s,initialData:r=null,modalTitle:o,formError:d=null})=>{const{t:f}=Te(),m=()=>!r||!r.config?"stdio":r.config.type?r.config.type:r.config.url?"sse":"stdio",[y,h]=S.useState(m()),[g,v]=S.useState({name:r&&r.name||"",url:r&&r.config&&r.config.url||"",command:r&&r.config&&r.config.command||"",arguments:r&&r.config&&r.config.args?Array.isArray(r.config.args)?r.config.args.join(" "):String(r.config.args):"",args:r&&r.config&&r.config.args||[],type:m(),env:[]}),[w,b]=S.useState(r&&r.config&&r.config.env?Object.entries(r.config.env).map(([H,O])=>({key:H,value:O})):[]),[R,N]=S.useState(null),C=!!r,A=H=>{const{name:O,value:J}=H.target;v({...g,[O]:J})},z=H=>{let O=H.split(" ").filter(J=>J.trim()!=="");v({...g,arguments:H,args:O})},T=H=>{h(H),v(O=>({...O,type:H}))},D=(H,O,J)=>{const re=[...w];re[H][O]=J,b(re)},q=()=>{b([...w,{key:"",value:""}])},Y=H=>{const O=[...w];O.splice(H,1),b(O)},W=async H=>{H.preventDefault(),N(null);try{const O={};w.forEach(({key:re,value:de})=>{re.trim()&&(O[re.trim()]=de)});const J={name:g.name,config:{type:y,...y==="sse"||y==="streamable-http"?{url:g.url}:{command:g.command,args:g.args,env:Object.keys(O).length>0?O:void 0}}};l(J)}catch(O){N(`Error: ${O instanceof Error?O.message:String(O)}`)}};return c.jsxs("div",{className:"bg-white shadow rounded-lg p-6 w-full max-w-xl max-h-screen overflow-y-auto",children:[c.jsxs("div",{className:"flex justify-between items-center mb-4",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:o}),c.jsx("button",{onClick:s,className:"text-gray-500 hover:text-gray-700",children:"✕"})]}),(R||d)&&c.jsx("div",{className:"bg-red-50 text-red-700 p-3 rounded mb-4",children:d||R}),c.jsxs("form",{onSubmit:W,children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"name",children:f("server.name")}),c.jsx("input",{type:"text",name:"name",id:"name",value:g.name,onChange:A,className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline",placeholder:"e.g.: time-mcp",required:!0,disabled:C})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",children:f("server.type")}),c.jsxs("div",{className:"flex space-x-4",children:[c.jsxs("div",{children:[c.jsx("input",{type:"radio",id:"command",name:"serverType",value:"command",checked:y==="stdio",onChange:()=>T("stdio"),className:"mr-1"}),c.jsx("label",{htmlFor:"command",children:"STDIO"})]}),c.jsxs("div",{children:[c.jsx("input",{type:"radio",id:"url",name:"serverType",value:"url",checked:y==="sse",onChange:()=>T("sse"),className:"mr-1"}),c.jsx("label",{htmlFor:"url",children:"SSE"})]}),c.jsxs("div",{children:[c.jsx("input",{type:"radio",id:"streamable-http",name:"serverType",value:"streamable-http",checked:y==="streamable-http",onChange:()=>T("streamable-http"),className:"mr-1"}),c.jsx("label",{htmlFor:"streamable-http",children:"Streamable HTTP"})]})]})]}),y==="sse"||y==="streamable-http"?c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"url",children:f("server.url")}),c.jsx("input",{type:"url",name:"url",id:"url",value:g.url,onChange:A,className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline",placeholder:y==="streamable-http"?"e.g.: http://localhost:3000/mcp":"e.g.: http://localhost:3000/sse",required:y==="sse"||y==="streamable-http"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"command",children:f("server.command")}),c.jsx("input",{type:"text",name:"command",id:"command",value:g.command,onChange:A,className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline",placeholder:"e.g.: npx",required:y==="stdio"})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"arguments",children:f("server.arguments")}),c.jsx("input",{type:"text",name:"arguments",id:"arguments",value:g.arguments,onChange:H=>z(H.target.value),className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline",placeholder:"e.g.: -y time-mcp",required:y==="stdio"})]}),c.jsxs("div",{className:"mb-4",children:[c.jsxs("div",{className:"flex justify-between items-center mb-2",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold",children:f("server.envVars")}),c.jsxs("button",{type:"button",onClick:q,className:"bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-1 px-2 rounded text-sm flex items-center",children:["+ ",f("server.add")]})]}),w.map((H,O)=>c.jsxs("div",{className:"flex items-center mb-2",children:[c.jsxs("div",{className:"flex items-center space-x-2 flex-grow",children:[c.jsx("input",{type:"text",value:H.key,onChange:J=>D(O,"key",J.target.value),className:"shadow appearance-none border rounded py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline w-1/2",placeholder:f("server.key")}),c.jsx("span",{className:"flex items-center",children:":"}),c.jsx("input",{type:"text",value:H.value,onChange:J=>D(O,"value",J.target.value),className:"shadow appearance-none border rounded py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline w-1/2",placeholder:f("server.value")})]}),c.jsxs("button",{type:"button",onClick:()=>Y(O),className:"bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-1 px-2 rounded text-sm flex items-center justify-center min-w-[56px] ml-2",children:["- ",f("server.remove")]})]},O))]})]}),c.jsxs("div",{className:"flex justify-end mt-6",children:[c.jsx("button",{type:"button",onClick:s,className:"bg-gray-300 hover:bg-gray-400 text-gray-800 font-medium py-2 px-4 rounded mr-2",children:f("server.cancel")}),c.jsx("button",{type:"submit",className:"bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded",children:f(C?"server.save":"server.add")})]})]})]})},zb=({onAdd:l})=>{const{t:s}=Te(),[r,o]=S.useState(!1),[d,f]=S.useState(null),m=()=>{o(!r),f(null)},y=async h=>{try{f(null);const g=localStorage.getItem("mcphub_token"),v=await fetch(Ee("/servers"),{method:"POST",headers:{"Content-Type":"application/json","x-auth-token":g||""},body:JSON.stringify(h)}),w=await v.json();if(!v.ok){w&&w.message?f(w.message):v.status===400?f(s("server.invalidData")):v.status===409?f(s("server.alreadyExists",{serverName:h.name})):f(s("server.addError"));return}o(!1),l()}catch(g){console.error("Error adding server:",g),navigator.onLine?g instanceof TypeError&&(g.message.includes("NetworkError")||g.message.includes("Failed to fetch"))?f(s("errors.serverConnection")):f(s("errors.serverAdd")):f(s("errors.network"))}};return c.jsxs("div",{children:[c.jsx("button",{onClick:m,className:"w-full bg-blue-100 text-blue-800 rounded hover:bg-blue-200 py-2 px-4",children:s("server.addServer")}),r&&c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx(qu,{onSubmit:y,onCancel:m,modalTitle:s("server.addServer"),formError:d})})]})},Db=({server:l,onEdit:s,onCancel:r})=>{const{t:o}=Te(),[d,f]=S.useState(null),m=async y=>{try{f(null);const h=localStorage.getItem("mcphub_token"),g=await fetch(Ee(`/servers/${l.name}`),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":h||""},body:JSON.stringify(y)}),v=await g.json();if(!g.ok){v&&v.message?f(v.message):g.status===404?f(o("server.notFound",{serverName:l.name})):g.status===400?f(o("server.invalidData")):f(o("server.updateError",{serverName:l.name}));return}s()}catch(h){console.error("Error updating server:",h),navigator.onLine?h instanceof TypeError&&(h.message.includes("NetworkError")||h.message.includes("Failed to fetch"))?f(o("errors.serverConnection")):f(o("errors.serverUpdate",{serverName:l.name})):f(o("errors.network"))}};return c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx(qu,{onSubmit:m,onCancel:r,initialData:l,modalTitle:o("server.editTitle",{serverName:l.name}),formError:d})})},Ub=()=>{const{t:l}=Te(),s=un(),{servers:r,error:o,setError:d,isLoading:f,handleServerAdd:m,handleServerEdit:y,handleServerRemove:h,handleServerToggle:g,triggerRefresh:v}=ys(),[w,b]=S.useState(null),[R,N]=S.useState(!1),C=async T=>{const D=await y(T);D&&b(D)},A=()=>{b(null),v()},z=async()=>{N(!0);try{v(),await new Promise(T=>setTimeout(T,500))}finally{N(!1)}};return c.jsxs("div",{children:[c.jsxs("div",{className:"flex justify-between items-center mb-8",children:[c.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:l("pages.servers.title")}),c.jsxs("div",{className:"flex space-x-4",children:[c.jsxs("button",{onClick:()=>s("/market"),className:"px-4 py-2 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 flex items-center",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{d:"M3 1a1 1 0 000 2h1.22l.305 1.222a.997.997 0 00.01.042l1.358 5.43-.893.892C3.74 11.846 4.632 14 6.414 14H15a1 1 0 000-2H6.414l1-1H14a1 1 0 00.894-.553l3-6A1 1 0 0017 3H6.28l-.31-1.243A1 1 0 005 1H3z"})}),l("nav.market")]}),c.jsx(zb,{onAdd:m}),c.jsxs("button",{onClick:z,disabled:R,className:`px-4 py-2 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 flex items-center ${R?"opacity-70 cursor-not-allowed":""}`,children:[R?c.jsxs("svg",{className:"animate-spin h-4 w-4 mr-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),l("common.refresh")]})]})]}),o&&c.jsx("div",{className:"mb-6 bg-red-50 border-l-4 border-red-500 p-4 rounded shadow-sm",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-red-600 text-lg font-medium",children:l("app.error")}),c.jsx("p",{className:"text-gray-600 mt-1",children:o})]}),c.jsx("button",{onClick:()=>d(null),className:"ml-4 text-gray-500 hover:text-gray-700","aria-label":l("app.closeButton"),children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 011.414 0L10 8.586l4.293-4.293a1 1 111.414 1.414L11.414 10l4.293 4.293a1 1 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 01-1.414-1.414L8.586 10 4.293 5.707a1 1 010-1.414z",clipRule:"evenodd"})})})]})}),f?c.jsx("div",{className:"bg-white shadow rounded-lg p-6 flex items-center justify-center",children:c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsxs("svg",{className:"animate-spin h-10 w-10 text-blue-500 mb-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c.jsx("p",{className:"text-gray-600",children:l("app.loading")})]})}):r.length===0?c.jsx("div",{className:"bg-white shadow rounded-lg p-6",children:c.jsx("p",{className:"text-gray-600",children:l("app.noServers")})}):c.jsx("div",{className:"space-y-6",children:r.map((T,D)=>c.jsx(Mb,{server:T,onRemove:h,onEdit:C,onToggle:g},D))}),w&&c.jsx(Db,{server:w,onEdit:A,onCancel:()=>b(null)})]})},Vu=()=>{const{t:l}=Te(),[s,r]=S.useState([]),[o,d]=S.useState(!0),[f,m]=S.useState(null),[y,h]=S.useState(0),g=S.useCallback(async()=>{try{d(!0);const z=localStorage.getItem("mcphub_token"),T=await fetch(Ee("/groups"),{headers:{"x-auth-token":z||""}});if(!T.ok)throw new Error(`Status: ${T.status}`);const D=await T.json();D&&D.success&&Array.isArray(D.data)?r(D.data):(console.error("Invalid group data format:",D),r([])),m(null)}catch(z){console.error("Error fetching groups:",z),m(z instanceof Error?z.message:"Failed to fetch groups"),r([])}finally{d(!1)}},[]),v=S.useCallback(()=>{h(z=>z+1)},[]),w=async(z,T,D=[])=>{try{const q=localStorage.getItem("mcphub_token"),Y=await fetch(Ee("/groups"),{method:"POST",headers:{"Content-Type":"application/json","x-auth-token":q||""},body:JSON.stringify({name:z,description:T,servers:D})}),W=await Y.json();return Y.ok?(v(),W.data||null):(m(W.message||l("groups.createError")),null)}catch(q){return m(q instanceof Error?q.message:"Failed to create group"),null}},b=async(z,T)=>{try{const D=localStorage.getItem("mcphub_token"),q=await fetch(Ee(`/groups/${z}`),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":D||""},body:JSON.stringify(T)}),Y=await q.json();return q.ok?(v(),Y.data||null):(m(Y.message||l("groups.updateError")),null)}catch(D){return m(D instanceof Error?D.message:"Failed to update group"),null}},R=async(z,T)=>{try{const D=localStorage.getItem("mcphub_token"),q=await fetch(Ee(`/groups/${z}/servers/batch`),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":D||""},body:JSON.stringify({servers:T})}),Y=await q.json();return q.ok?(v(),Y.data||null):(m(Y.message||l("groups.updateError")),null)}catch(D){return m(D instanceof Error?D.message:"Failed to update group servers"),null}},N=async z=>{try{const T=localStorage.getItem("mcphub_token"),D=await fetch(Ee(`/groups/${z}`),{method:"DELETE",headers:{"x-auth-token":T||""}}),q=await D.json();return D.ok?(v(),!0):(m(q.message||l("groups.deleteError")),!1)}catch(T){return m(T instanceof Error?T.message:"Failed to delete group"),!1}},C=async(z,T)=>{try{const D=localStorage.getItem("mcphub_token"),q=await fetch(Ee(`/groups/${z}/servers`),{method:"POST",headers:{"Content-Type":"application/json","x-auth-token":D||""},body:JSON.stringify({serverName:T})}),Y=await q.json();return q.ok?(v(),Y.data||null):(m(Y.message||l("groups.serverAddError")),null)}catch(D){return m(D instanceof Error?D.message:"Failed to add server to group"),null}},A=async(z,T)=>{try{const D=localStorage.getItem("mcphub_token"),q=await fetch(Ee(`/groups/${z}/servers/${T}`),{method:"DELETE",headers:{"x-auth-token":D||""}}),Y=await q.json();return q.ok?(v(),Y.data||null):(m(Y.message||l("groups.serverRemoveError")),null)}catch(D){return m(D instanceof Error?D.message:"Failed to remove server from group"),null}};return S.useEffect(()=>{g()},[g,y]),{groups:s,loading:o,error:f,setError:m,triggerRefresh:v,createGroup:w,updateGroup:b,updateGroupServers:R,deleteGroup:N,addServerToGroup:C,removeServerFromGroup:A}},Lb=({value:l,isSelected:s,onClick:r,children:o})=>c.jsxs("button",{type:"button",role:"checkbox","aria-checked":s,className:qa("flex w-full items-center justify-between p-2 rounded transition-colors cursor-pointer",s?"bg-blue-50 text-blue-700 hover:bg-blue-100 border-l-4 border-blue-500":"hover:bg-gray-50 text-gray-700"),onClick:r,children:[c.jsx("span",{className:"flex items-center",children:o}),s&&c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"w-5 h-5 text-blue-500",children:c.jsx("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",clipRule:"evenodd"})})]}),yg=({label:l,helpText:s,noOptionsText:r="No options available",values:o,options:d,onChange:f,className:m})=>{const y=h=>{const g=o.includes(h);f(g?o.filter(v=>v!==h):[...o,h])};return c.jsxs("div",{className:m,children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",children:l}),c.jsx("div",{className:"border rounded shadow max-h-60 overflow-y-auto",children:d.length===0?c.jsx("p",{className:"text-gray-500 text-sm p-3",children:r}):c.jsx("div",{className:"space-y-1 p-1",children:d.map(h=>c.jsx(Lb,{value:h.value,isSelected:o.includes(h.value),onClick:()=>y(h.value),children:h.label},h.value))})}),s&&c.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s})]})},_r=({checked:l,onCheckedChange:s,disabled:r=!1})=>c.jsx("button",{type:"button",role:"switch","aria-checked":l,disabled:r,className:qa("relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",l?"bg-blue-600":"bg-gray-200",r?"opacity-50 cursor-not-allowed":"cursor-pointer"),onClick:()=>!r&&s(!l),children:c.jsx("span",{className:qa("inline-block h-4 w-4 transform rounded-full bg-white transition-transform",l?"translate-x-6":"translate-x-1")})}),_b=({onAdd:l,onCancel:s})=>{const{t:r}=Te(),{createGroup:o}=Vu(),{servers:d}=ys(),[f,m]=S.useState([]),[y,h]=S.useState(null),[g,v]=S.useState(!1),[w,b]=S.useState({name:"",description:"",servers:[]});S.useEffect(()=>{m(d.filter(C=>C.enabled!==!1))},[d]);const R=C=>{const{name:A,value:z}=C.target;b(T=>({...T,[A]:z}))},N=async C=>{C.preventDefault(),v(!0),h(null);try{if(!w.name.trim()){h(r("groups.nameRequired")),v(!1);return}if(!await o(w.name,w.description,w.servers)){h(r("groups.createError")),v(!1);return}l()}catch(A){h(A instanceof Error?A.message:String(A)),v(!1)}};return c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx("div",{className:"bg-white rounded-lg shadow-lg max-w-md w-full",children:c.jsxs("div",{className:"p-6",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-800 mb-4",children:r("groups.addNew")}),y&&c.jsx("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded",children:y}),c.jsxs("form",{onSubmit:N,children:[c.jsxs("div",{className:"mb-4",children:[c.jsxs("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"name",children:[r("groups.name")," *"]}),c.jsx("input",{type:"text",id:"name",name:"name",value:w.name,onChange:R,className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline",placeholder:r("groups.namePlaceholder"),required:!0})]}),c.jsx(yg,{className:"mb-6",label:r("groups.servers"),noOptionsText:r("groups.noServerOptions"),values:w.servers,options:f.map(C=>({value:C.name,label:C.name})),onChange:C=>b(A=>({...A,servers:C}))}),c.jsxs("div",{className:"flex justify-end space-x-3",children:[c.jsx("button",{type:"button",onClick:s,className:"px-4 py-2 text-gray-600 hover:text-gray-800",disabled:g,children:r("common.cancel")}),c.jsx("button",{type:"submit",className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",disabled:g,children:r(g?"common.submitting":"common.create")})]})]})]})})})},Hb=({group:l,onEdit:s,onCancel:r})=>{const{t:o}=Te(),{updateGroup:d}=Vu(),{servers:f}=ys(),[m,y]=S.useState([]),[h,g]=S.useState(null),[v,w]=S.useState(!1),[b,R]=S.useState({name:l.name,description:l.description||"",servers:l.servers||[]});S.useEffect(()=>{y(f.filter(A=>A.enabled!==!1))},[f]);const N=A=>{const{name:z,value:T}=A.target;R(D=>({...D,[z]:T}))},C=async A=>{A.preventDefault(),w(!0),g(null);try{if(!b.name.trim()){g(o("groups.nameRequired")),w(!1);return}if(!await d(l.id,{name:b.name,description:b.description,servers:b.servers})){g(o("groups.updateError")),w(!1);return}s()}catch(z){g(z instanceof Error?z.message:String(z)),w(!1)}};return c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx("div",{className:"bg-white rounded-lg shadow-lg max-w-md w-full",children:c.jsxs("div",{className:"p-6",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-800 mb-4",children:o("groups.edit")}),h&&c.jsx("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded",children:h}),c.jsxs("form",{onSubmit:C,children:[c.jsxs("div",{className:"mb-4",children:[c.jsxs("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"name",children:[o("groups.name")," *"]}),c.jsx("input",{type:"text",id:"name",name:"name",value:b.name,onChange:N,className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline",placeholder:o("groups.namePlaceholder"),required:!0})]}),c.jsx(yg,{className:"mb-6",label:o("groups.servers"),noOptionsText:o("groups.noServerOptions"),values:b.servers,options:m.map(A=>({value:A.name,label:A.name})),onChange:A=>R(z=>({...z,servers:A}))}),c.jsxs("div",{className:"flex justify-end space-x-3",children:[c.jsx("button",{type:"button",onClick:r,className:"px-4 py-2 text-gray-600 hover:text-gray-800",disabled:v,children:o("common.cancel")}),c.jsx("button",{type:"submit",className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",disabled:v,children:o(v?"common.submitting":"common.save")})]})]})]})})})},Bb=({group:l,servers:s,onEdit:r,onDelete:o})=>{const{t:d}=Te(),{showToast:f}=ps(),[m,y]=S.useState(!1),[h,g]=S.useState(!1),v=()=>{r(l)},w=()=>{y(!0)},b=()=>{o(l.id),y(!1)},R=()=>{if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(l.id).then(()=>{g(!0),setTimeout(()=>g(!1),2e3)});else{const C=document.createElement("textarea");C.value=l.id,C.style.position="fixed",C.style.left="-9999px",document.body.appendChild(C),C.focus(),C.select();try{document.execCommand("copy"),g(!0),setTimeout(()=>g(!1),2e3)}catch(A){f(d("common.copyFailed")||"Copy failed","error"),console.error("Copy to clipboard failed:",A)}document.body.removeChild(C)}},N=s.filter(C=>l.servers.includes(C.name));return c.jsxs("div",{className:"bg-white shadow rounded-lg p-6",children:[c.jsxs("div",{className:"flex justify-between items-center mb-4",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center",children:[c.jsx("h2",{className:"text-xl font-semibold text-gray-800",children:l.name}),c.jsxs("div",{className:"flex items-center ml-3",children:[c.jsx("span",{className:"text-xs text-gray-500 mr-1",children:l.id}),c.jsx("button",{onClick:R,className:"p-1 text-gray-400 hover:text-gray-600 transition-colors",title:d("common.copy"),children:h?c.jsx(Bu,{size:14,className:"text-green-500"}):c.jsx(Jm,{size:14})})]})]}),l.description&&c.jsx("p",{className:"text-gray-600 text-sm mt-1",children:l.description})]}),c.jsxs("div",{className:"flex items-center space-x-3",children:[c.jsx("div",{className:"bg-blue-50 text-blue-700 px-3 py-1 rounded-full text-sm",children:d("groups.serverCount",{count:l.servers.length})}),c.jsx("button",{onClick:v,className:"text-gray-500 hover:text-gray-700",title:d("groups.edit"),children:c.jsx(nv,{size:18})}),c.jsx("button",{onClick:w,className:"text-gray-500 hover:text-red-600",title:d("groups.delete"),children:c.jsx(iv,{size:18})})]})]}),c.jsx("div",{className:"mt-4",children:N.length===0?c.jsx("p",{className:"text-gray-500 italic",children:d("groups.noServers")}):c.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:N.map(C=>c.jsxs("div",{className:"inline-flex items-center px-3 py-1 bg-gray-50 rounded",children:[c.jsx("span",{className:"font-medium text-gray-700 text-sm",children:C.name}),c.jsx("span",{className:`ml-2 inline-block h-2 w-2 rounded-full ${C.status==="connected"?"bg-green-500":C.status==="connecting"?"bg-yellow-500":"bg-red-500"}`})]},C.name))})}),c.jsx(pg,{isOpen:m,onClose:()=>y(!1),onConfirm:b,serverName:l.name,isGroup:!0})]})},Gb=()=>{const{t:l}=Te(),{groups:s,loading:r,error:o,setError:d,deleteGroup:f,triggerRefresh:m}=Vu(),{servers:y}=ys(),[h,g]=S.useState(null),[v,w]=S.useState(!1),b=z=>{g(z)},R=()=>{g(null),m()},N=async z=>{await f(z)||d(l("groups.deleteError"))},C=()=>{w(!0)},A=()=>{w(!1),m()};return c.jsxs("div",{children:[c.jsxs("div",{className:"flex justify-between items-center mb-8",children:[c.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:l("pages.groups.title")}),c.jsx("div",{className:"flex space-x-4",children:c.jsxs("button",{onClick:C,className:"px-4 py-2 bg-blue-100 text-blue-800 rounded hover:bg-blue-200 flex items-center",children:[c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 00-1 1v5H4a1 1 0 100 2h5v5a1 1 0 102 0v-5h5a1 1 0 100-2h-5V4a1 1 0 00-1-1z",clipRule:"evenodd"})}),l("groups.add")]})})]}),o&&c.jsx("div",{className:"bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-6",children:c.jsx("p",{children:o})}),r?c.jsx("div",{className:"bg-white shadow rounded-lg p-6",children:c.jsxs("div",{className:"flex flex-col items-center justify-center",children:[c.jsxs("svg",{className:"animate-spin h-10 w-10 text-blue-500 mb-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c.jsx("p",{className:"text-gray-600",children:l("app.loading")})]})}):s.length===0?c.jsx("div",{className:"bg-white shadow rounded-lg p-6",children:c.jsx("p",{className:"text-gray-600",children:l("groups.noGroups")})}):c.jsx("div",{className:"space-y-6",children:s.map(z=>c.jsx(Bb,{group:z,servers:y,onEdit:b,onDelete:N},z.id))}),v&&c.jsx(_b,{onAdd:A,onCancel:A}),h&&c.jsx(Hb,{group:h,onEdit:R,onCancel:()=>g(null)})]})},qb=({onSuccess:l,onCancel:s})=>{const{t:r}=Te(),[o,d]=S.useState({currentPassword:"",newPassword:""}),[f,m]=S.useState(""),[y,h]=S.useState(!1),[g,v]=S.useState(null),[w,b]=S.useState(!1),R=C=>{const{name:A,value:z}=C.target;A==="confirmPassword"?m(z):d(T=>({...T,[A]:z}))},N=async C=>{if(C.preventDefault(),v(null),o.newPassword!==f){v(r("auth.passwordsNotMatch"));return}h(!0);try{const A=await zx(o);A.success?(b(!0),l&&l()):v(A.message||r("auth.changePasswordError"))}catch{v(r("auth.changePasswordError"))}finally{h(!1)}};return c.jsxs("div",{className:"p-6 bg-white rounded-lg shadow-md",children:[c.jsx("h2",{className:"text-xl font-bold mb-4",children:r("auth.changePassword")}),w?c.jsx("div",{className:"bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4",children:r("auth.changePasswordSuccess")}):c.jsxs("form",{onSubmit:N,children:[g&&c.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4",children:g}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"currentPassword",children:r("auth.currentPassword")}),c.jsx("input",{type:"password",id:"currentPassword",name:"currentPassword",className:"w-full p-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500",value:o.currentPassword,onChange:R,required:!0})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"newPassword",children:r("auth.newPassword")}),c.jsx("input",{type:"password",id:"newPassword",name:"newPassword",className:"w-full p-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500",value:o.newPassword,onChange:R,required:!0,minLength:6})]}),c.jsxs("div",{className:"mb-6",children:[c.jsx("label",{className:"block text-gray-700 text-sm font-bold mb-2",htmlFor:"confirmPassword",children:r("auth.confirmPassword")}),c.jsx("input",{type:"password",id:"confirmPassword",name:"confirmPassword",className:"w-full p-2 border rounded focus:outline-none focus:ring-2 focus:ring-blue-500",value:f,onChange:R,required:!0,minLength:6})]}),c.jsxs("div",{className:"flex justify-end space-x-2",children:[s&&c.jsx("button",{type:"button",onClick:s,disabled:y,className:"py-2 px-4 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",children:r("common.cancel")}),c.jsx("button",{type:"submit",disabled:y,className:"py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",children:y?c.jsxs("span",{className:"flex items-center",children:[c.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),r("common.save")]}):r("common.save")})]})]})]})},Vb=()=>{const{t:l}=Te(),{showToast:s}=ps(),[r,o]=S.useState({enableGlobalRoute:!0,enableGroupNameRoute:!0,enableBearerAuth:!1,bearerAuthKey:""}),[d,f]=S.useState({bearerAuthKey:""}),[m,y]=S.useState({pythonIndexUrl:"",npmRegistry:""}),[h,g]=S.useState({enabled:!1,dbUrl:"",openaiApiBaseUrl:"",openaiApiKey:"",openaiApiEmbeddingModel:""}),[v,w]=S.useState(!1),[b,R]=S.useState(null),[N,C]=S.useState(0),A=S.useCallback(()=>{C(W=>W+1)},[]),z=S.useCallback(async()=>{var W,H,O,J,re,de;w(!0),R(null);try{const me=localStorage.getItem("mcphub_token"),ke=await fetch(Ee("/settings"),{headers:{"x-auth-token":me||""}});if(!ke.ok)throw new Error(`HTTP error! Status: ${ke.status}`);const oe=await ke.json();oe.success&&((H=(W=oe.data)==null?void 0:W.systemConfig)!=null&&H.routing)&&o({enableGlobalRoute:oe.data.systemConfig.routing.enableGlobalRoute??!0,enableGroupNameRoute:oe.data.systemConfig.routing.enableGroupNameRoute??!0,enableBearerAuth:oe.data.systemConfig.routing.enableBearerAuth??!1,bearerAuthKey:oe.data.systemConfig.routing.bearerAuthKey||""}),oe.success&&((J=(O=oe.data)==null?void 0:O.systemConfig)!=null&&J.install)&&y({pythonIndexUrl:oe.data.systemConfig.install.pythonIndexUrl||"",npmRegistry:oe.data.systemConfig.install.npmRegistry||""}),oe.success&&((de=(re=oe.data)==null?void 0:re.systemConfig)!=null&&de.smartRouting)&&g({enabled:oe.data.systemConfig.smartRouting.enabled??!1,dbUrl:oe.data.systemConfig.smartRouting.dbUrl||"",openaiApiBaseUrl:oe.data.systemConfig.smartRouting.openaiApiBaseUrl||"",openaiApiKey:oe.data.systemConfig.smartRouting.openaiApiKey||"",openaiApiEmbeddingModel:oe.data.systemConfig.smartRouting.openaiApiEmbeddingModel||""})}catch(me){console.error("Failed to fetch settings:",me),R(me instanceof Error?me.message:"Failed to fetch settings"),s(l("errors.failedToFetchSettings"))}finally{w(!1)}},[l]),T=async(W,H)=>{w(!0),R(null);try{const O=localStorage.getItem("mcphub_token"),J=await fetch(Ee("/system-config"),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":O||""},body:JSON.stringify({routing:{[W]:H}})});if(!J.ok)throw new Error(`HTTP error! Status: ${J.status}`);return(await J.json()).success?(o({...r,[W]:H}),s(l("settings.systemConfigUpdated")),!0):(s(l("errors.failedToUpdateRouteConfig")),!1)}catch(O){return console.error("Failed to update routing config:",O),R(O instanceof Error?O.message:"Failed to update routing config"),s(l("errors.failedToUpdateRouteConfig")),!1}finally{w(!1)}},D=async(W,H)=>{w(!0),R(null);try{const O=localStorage.getItem("mcphub_token"),J=await fetch(Ee("/system-config"),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":O||""},body:JSON.stringify({install:{[W]:H}})});if(!J.ok)throw new Error(`HTTP error! Status: ${J.status}`);return(await J.json()).success?(y({...m,[W]:H}),s(l("settings.systemConfigUpdated")),!0):(s(l("errors.failedToUpdateSystemConfig")),!1)}catch(O){return console.error("Failed to update system config:",O),R(O instanceof Error?O.message:"Failed to update system config"),s(l("errors.failedToUpdateSystemConfig")),!1}finally{w(!1)}},q=async(W,H)=>{w(!0),R(null);try{const O=localStorage.getItem("mcphub_token"),J=await fetch(Ee("/system-config"),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":O||""},body:JSON.stringify({smartRouting:{[W]:H}})});if(!J.ok){const de=await J.json();throw new Error(de.message||`HTTP error! Status: ${J.status}`)}const re=await J.json();return re.success?(g({...h,[W]:H}),s(l("settings.systemConfigUpdated")),!0):(s(re.message||l("errors.failedToUpdateSmartRoutingConfig")),!1)}catch(O){console.error("Failed to update smart routing config:",O);const J=O instanceof Error?O.message:"Failed to update smart routing config";return R(J),s(J),!1}finally{w(!1)}},Y=async W=>{w(!0),R(null);try{const H=localStorage.getItem("mcphub_token"),O=await fetch(Ee("/system-config"),{method:"PUT",headers:{"Content-Type":"application/json","x-auth-token":H||""},body:JSON.stringify({smartRouting:W})});if(!O.ok){const re=await O.json();throw new Error(re.message||`HTTP error! Status: ${O.status}`)}const J=await O.json();return J.success?(g({...h,...W}),s(l("settings.systemConfigUpdated")),!0):(s(J.message||l("errors.failedToUpdateSmartRoutingConfig")),!1)}catch(H){console.error("Failed to update smart routing config:",H);const O=H instanceof Error?H.message:"Failed to update smart routing config";return R(O),s(O),!1}finally{w(!1)}};return S.useEffect(()=>{z()},[z,N]),S.useEffect(()=>{r&&f({bearerAuthKey:r.bearerAuthKey})},[r]),{routingConfig:r,tempRoutingConfig:d,setTempRoutingConfig:f,installConfig:m,smartRoutingConfig:h,loading:v,error:b,setError:R,triggerRefresh:A,fetchSettings:z,updateRoutingConfig:T,updateInstallConfig:D,updateSmartRoutingConfig:q,updateSmartRoutingConfigBatch:Y}};function Yb(l=32){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=new Uint8Array(l);return crypto.getRandomValues(r),Array.from(r).map(o=>s.charAt(o%s.length)).join("")}const Kb=()=>{const{t:l,i18n:s}=Te(),r=un(),{showToast:o}=ps(),[d,f]=S.useState(s.language);S.useEffect(()=>{f(s.language)},[s.language]);const[m,y]=S.useState({pythonIndexUrl:"",npmRegistry:""}),[h,g]=S.useState({dbUrl:"",openaiApiBaseUrl:"",openaiApiKey:"",openaiApiEmbeddingModel:""}),{routingConfig:v,tempRoutingConfig:w,setTempRoutingConfig:b,installConfig:R,smartRoutingConfig:N,loading:C,updateRoutingConfig:A,updateInstallConfig:z,updateSmartRoutingConfig:T,updateSmartRoutingConfigBatch:D}=Vb();S.useEffect(()=>{R&&y(R)},[R]),S.useEffect(()=>{N&&g({dbUrl:N.dbUrl||"",openaiApiBaseUrl:N.openaiApiBaseUrl||"",openaiApiKey:N.openaiApiKey||"",openaiApiEmbeddingModel:N.openaiApiEmbeddingModel||""})},[N]);const[q,Y]=S.useState({routingConfig:!1,installConfig:!1,smartRoutingConfig:!1,password:!1}),W=V=>{Y($=>({...$,[V]:!$[V]}))},H=async(V,$)=>{if(await A(V,$),V==="enableBearerAuth"&&$===!0&&!w.bearerAuthKey){const ue=Yb();O(ue),await A("bearerAuthKey",ue)}},O=V=>{b($=>({...$,bearerAuthKey:V}))},J=async()=>{await A("bearerAuthKey",w.bearerAuthKey)},re=(V,$)=>{y({...m,[V]:$})},de=async V=>{await z(V,m[V])},me=(V,$)=>{g({...h,[V]:$})},ke=async V=>{await T(V,h[V])},oe=async V=>{if(V){const $=h.dbUrl||N.dbUrl,ue=h.openaiApiKey||N.openaiApiKey;if(!$||!ue){const Q=[];$||Q.push(l("settings.dbUrl")),ue||Q.push(l("settings.openaiApiKey")),o(l("settings.smartRoutingValidationError",{fields:Q.join(", ")}));return}const E={enabled:V};h.dbUrl!==N.dbUrl&&(E.dbUrl=h.dbUrl),h.openaiApiBaseUrl!==N.openaiApiBaseUrl&&(E.openaiApiBaseUrl=h.openaiApiBaseUrl),h.openaiApiKey!==N.openaiApiKey&&(E.openaiApiKey=h.openaiApiKey),h.openaiApiEmbeddingModel!==N.openaiApiEmbeddingModel&&(E.openaiApiEmbeddingModel=h.openaiApiEmbeddingModel),await D(E)}else await T("enabled",V)},xe=()=>{setTimeout(()=>{r("/")},2e3)},G=V=>{localStorage.setItem("i18nextLng",V),window.location.reload()};return c.jsxs("div",{className:"container mx-auto",children:[c.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-8",children:l("pages.settings.title")}),c.jsx("div",{className:"bg-white shadow rounded-lg py-4 px-6 mb-6",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"font-semibold text-gray-800",children:l("pages.settings.language")}),c.jsxs("div",{className:"flex space-x-3",children:[c.jsx("button",{className:`px-3 py-1.5 rounded-md transition-colors text-sm ${d.startsWith("en")?"bg-blue-500 text-white":"bg-blue-100 text-blue-800 hover:bg-blue-200"}`,onClick:()=>G("en"),children:"English"}),c.jsx("button",{className:`px-3 py-1.5 rounded-md transition-colors text-sm ${d.startsWith("zh")?"bg-blue-500 text-white":"bg-blue-100 text-blue-800 hover:bg-blue-200"}`,onClick:()=>G("zh"),children:"中文"})]})]})}),c.jsxs("div",{className:"bg-white shadow rounded-lg py-4 px-6 mb-6",children:[c.jsxs("div",{className:"flex justify-between items-center cursor-pointer",onClick:()=>W("smartRoutingConfig"),children:[c.jsx("h2",{className:"font-semibold text-gray-800",children:l("pages.settings.smartRouting")}),c.jsx("span",{className:"text-gray-500",children:q.smartRoutingConfig?"▼":"►"})]}),q.smartRoutingConfig&&c.jsxs("div",{className:"space-y-4 mt-4",children:[c.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.enableSmartRouting")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.enableSmartRoutingDescription")})]}),c.jsx(_r,{disabled:C,checked:N.enabled,onCheckedChange:V=>oe(V)})]}),c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsx("div",{className:"mb-2",children:c.jsxs("h3",{className:"font-medium text-gray-700",children:[c.jsx("span",{className:"text-red-500 px-1",children:"*"}),l("settings.dbUrl")]})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"text",value:h.dbUrl,onChange:V=>me("dbUrl",V.target.value),placeholder:l("settings.dbUrlPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm border-gray-300",disabled:C}),c.jsx("button",{onClick:()=>ke("dbUrl"),disabled:C,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]}),c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsx("div",{className:"mb-2",children:c.jsxs("h3",{className:"font-medium text-gray-700",children:[c.jsx("span",{className:"text-red-500 px-1",children:"*"}),l("settings.openaiApiKey")]})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"password",value:h.openaiApiKey,onChange:V=>me("openaiApiKey",V.target.value),placeholder:l("settings.openaiApiKeyPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm border-gray-300",disabled:C}),c.jsx("button",{onClick:()=>ke("openaiApiKey"),disabled:C,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]}),c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsx("div",{className:"mb-2",children:c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.openaiApiBaseUrl")})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"text",value:h.openaiApiBaseUrl,onChange:V=>me("openaiApiBaseUrl",V.target.value),placeholder:l("settings.openaiApiBaseUrlPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm",disabled:C}),c.jsx("button",{onClick:()=>ke("openaiApiBaseUrl"),disabled:C,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]}),c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsx("div",{className:"mb-2",children:c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.openaiApiEmbeddingModel")})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"text",value:h.openaiApiEmbeddingModel,onChange:V=>me("openaiApiEmbeddingModel",V.target.value),placeholder:l("settings.openaiApiEmbeddingModelPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm",disabled:C}),c.jsx("button",{onClick:()=>ke("openaiApiEmbeddingModel"),disabled:C,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]})]})]}),c.jsxs("div",{className:"bg-white shadow rounded-lg py-4 px-6 mb-6",children:[c.jsxs("div",{className:"flex justify-between items-center cursor-pointer",onClick:()=>W("routingConfig"),children:[c.jsx("h2",{className:"font-semibold text-gray-800",children:l("pages.settings.routeConfig")}),c.jsx("span",{className:"text-gray-500",children:q.routingConfig?"▼":"►"})]}),q.routingConfig&&c.jsxs("div",{className:"space-y-4 mt-4",children:[c.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.enableBearerAuth")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.enableBearerAuthDescription")})]}),c.jsx(_r,{disabled:C,checked:v.enableBearerAuth,onCheckedChange:V=>H("enableBearerAuth",V)})]}),v.enableBearerAuth&&c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{className:"mb-2",children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.bearerAuthKey")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.bearerAuthKeyDescription")})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"text",value:w.bearerAuthKey,onChange:V=>O(V.target.value),placeholder:l("settings.bearerAuthKeyPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm",disabled:C||!v.enableBearerAuth}),c.jsx("button",{onClick:J,disabled:C||!v.enableBearerAuth,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]}),c.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.enableGlobalRoute")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.enableGlobalRouteDescription")})]}),c.jsx(_r,{disabled:C,checked:v.enableGlobalRoute,onCheckedChange:V=>H("enableGlobalRoute",V)})]}),c.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.enableGroupNameRoute")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.enableGroupNameRouteDescription")})]}),c.jsx(_r,{disabled:C,checked:v.enableGroupNameRoute,onCheckedChange:V=>H("enableGroupNameRoute",V)})]})]})]}),c.jsxs("div",{className:"bg-white shadow rounded-lg py-4 px-6 mb-6",children:[c.jsxs("div",{className:"flex justify-between items-center cursor-pointer",onClick:()=>W("installConfig"),children:[c.jsx("h2",{className:"font-semibold text-gray-800",children:l("settings.installConfig")}),c.jsx("span",{className:"text-gray-500",children:q.installConfig?"▼":"►"})]}),q.installConfig&&c.jsxs("div",{className:"space-y-4 mt-4",children:[c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{className:"mb-2",children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.pythonIndexUrl")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.pythonIndexUrlDescription")})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"text",value:m.pythonIndexUrl,onChange:V=>re("pythonIndexUrl",V.target.value),placeholder:l("settings.pythonIndexUrlPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm",disabled:C}),c.jsx("button",{onClick:()=>de("pythonIndexUrl"),disabled:C,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]}),c.jsxs("div",{className:"p-3 bg-gray-50 rounded-md",children:[c.jsxs("div",{className:"mb-2",children:[c.jsx("h3",{className:"font-medium text-gray-700",children:l("settings.npmRegistry")}),c.jsx("p",{className:"text-sm text-gray-500",children:l("settings.npmRegistryDescription")})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"text",value:m.npmRegistry,onChange:V=>re("npmRegistry",V.target.value),placeholder:l("settings.npmRegistryPlaceholder"),className:"flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm",disabled:C}),c.jsx("button",{onClick:()=>de("npmRegistry"),disabled:C,className:"mt-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium disabled:opacity-50",children:l("common.save")})]})]})]})]}),c.jsxs("div",{className:"bg-white shadow rounded-lg py-4 px-6 mb-6",children:[c.jsxs("div",{className:"flex justify-between items-center cursor-pointer",onClick:()=>W("password"),children:[c.jsx("h2",{className:"font-semibold text-gray-800",children:l("auth.changePassword")}),c.jsx("span",{className:"text-gray-500",children:q.password?"▼":"►"})]}),q.password&&c.jsx("div",{className:"max-w-lg mt-4",children:c.jsx(qb,{onSuccess:xe})})]})]})},$b=()=>{const{t:l}=Te(),[s,r]=S.useState([]),[o,d]=S.useState([]),[f,m]=S.useState([]),[y,h]=S.useState([]),[g,v]=S.useState(""),[w,b]=S.useState(""),[R,N]=S.useState(""),[C,A]=S.useState(!0),[z,T]=S.useState(null),[D,q]=S.useState(null),[Y,W]=S.useState([]),[H,O]=S.useState(1),[J,re]=S.useState(9),[de,me]=S.useState(1),ke=S.useCallback(async()=>{try{A(!0);const F=localStorage.getItem("mcphub_token"),I=await fetch(Ee("/market/servers"),{headers:{"x-auth-token":F||""}});if(!I.ok)throw new Error(`Status: ${I.status}`);const ae=await I.json();ae&&ae.success&&Array.isArray(ae.data)?(d(ae.data),oe(ae.data,H)):(console.error("Invalid market servers data format:",ae),T(l("market.fetchError")))}catch(F){console.error("Error fetching market servers:",F),T(F instanceof Error?F.message:String(F))}finally{A(!1)}},[l]),oe=S.useCallback((F,I,ae=J)=>{const ce=F.length,et=Math.ceil(ce/ae);me(et);const ct=Math.max(1,Math.min(I,et));ct!==I&&O(ct);const pt=(ct-1)*ae,Ft=F.slice(pt,pt+ae);r(Ft)},[J]),xe=S.useCallback(F=>{O(F),oe(o,F,J)},[o,oe,J]),G=S.useCallback(async()=>{try{const F=localStorage.getItem("mcphub_token"),I=await fetch(Ee("/market/categories"),{headers:{"x-auth-token":F||""}});if(!I.ok)throw new Error(`Status: ${I.status}`);const ae=await I.json();ae&&ae.success&&Array.isArray(ae.data)?m(ae.data):console.error("Invalid categories data format:",ae)}catch(F){console.error("Error fetching categories:",F)}},[]),V=S.useCallback(async()=>{try{const F=localStorage.getItem("mcphub_token"),I=await fetch(Ee("/market/tags"),{headers:{"x-auth-token":F||""}});if(!I.ok)throw new Error(`Status: ${I.status}`);const ae=await I.json();ae&&ae.success&&Array.isArray(ae.data)?h(ae.data):console.error("Invalid tags data format:",ae)}catch(F){console.error("Error fetching tags:",F)}},[]),$=S.useCallback(async F=>{try{A(!0);const I=localStorage.getItem("mcphub_token"),ae=await fetch(Ee(`/market/servers/${F}`),{headers:{"x-auth-token":I||""}});if(!ae.ok)throw new Error(`Status: ${ae.status}`);const ce=await ae.json();return ce&&ce.success&&ce.data?(q(ce.data),ce.data):(console.error("Invalid server data format:",ce),T(l("market.serverNotFound")),null)}catch(I){return console.error(`Error fetching server ${F}:`,I),T(I instanceof Error?I.message:String(I)),null}finally{A(!1)}},[l]),ue=S.useCallback(async F=>{try{if(A(!0),N(F),!F.trim()){ke();return}const I=localStorage.getItem("mcphub_token"),ae=await fetch(Ee(`/market/servers/search?query=${encodeURIComponent(F)}`),{headers:{"x-auth-token":I||""}});if(!ae.ok)throw new Error(`Status: ${ae.status}`);const ce=await ae.json();ce&&ce.success&&Array.isArray(ce.data)?(d(ce.data),O(1),oe(ce.data,1)):(console.error("Invalid search results format:",ce),T(l("market.searchError")))}catch(I){console.error("Error searching servers:",I),T(I instanceof Error?I.message:String(I))}finally{A(!1)}},[l,o,oe,ke]),E=S.useCallback(async F=>{try{if(A(!0),v(F),b(""),!F){ke();return}const I=localStorage.getItem("mcphub_token"),ae=await fetch(Ee(`/market/categories/${encodeURIComponent(F)}`),{headers:{"x-auth-token":I||""}});if(!ae.ok)throw new Error(`Status: ${ae.status}`);const ce=await ae.json();ce&&ce.success&&Array.isArray(ce.data)?(d(ce.data),O(1),oe(ce.data,1)):(console.error("Invalid category filter results format:",ce),T(l("market.filterError")))}catch(I){console.error("Error filtering servers by category:",I),T(I instanceof Error?I.message:String(I))}finally{A(!1)}},[l,ke,oe]),Q=S.useCallback(async F=>{try{if(A(!0),b(F),v(""),!F){ke();return}const I=localStorage.getItem("mcphub_token"),ae=await fetch(Ee(`/market/tags/${encodeURIComponent(F)}`),{headers:{"x-auth-token":I||""}});if(!ae.ok)throw new Error(`Status: ${ae.status}`);const ce=await ae.json();ce&&ce.success&&Array.isArray(ce.data)?(d(ce.data),O(1),oe(ce.data,1)):(console.error("Invalid tag filter results format:",ce),T(l("market.tagFilterError")))}catch(I){console.error("Error filtering servers by tag:",I),T(I instanceof Error?I.message:String(I))}finally{A(!1)}},[l,ke,oe]),ee=S.useCallback(async()=>{try{const F=localStorage.getItem("mcphub_token"),I=await fetch(Ee("/servers"),{headers:{"x-auth-token":F||""}});if(!I.ok)throw new Error(`Status: ${I.status}`);const ae=await I.json();if(ae&&ae.success&&Array.isArray(ae.data)){const ce=ae.data.map(et=>et.name);W(ce)}}catch(F){console.error("Error fetching installed servers:",F)}},[]),Z=S.useCallback(F=>Y.includes(F),[Y]),te=S.useCallback(async F=>{var I,ae;try{const ce=(I=F.installations)!=null&&I.npm?"npm":Object.keys(F.installations||{}).length>0?Object.keys(F.installations)[0]:null;if(!ce||!((ae=F.installations)!=null&&ae[ce]))return T(l("market.noInstallationMethod")),!1;const et=F.installations[ce],ct={name:F.name,config:{command:et.command,args:et.args,env:et.env||{}}},pt=localStorage.getItem("mcphub_token"),Ft=await fetch(Ee("/servers"),{method:"POST",headers:{"Content-Type":"application/json","x-auth-token":pt||""},body:JSON.stringify(ct)});if(!Ft.ok){const sl=await Ft.json();throw new Error(sl.message||`Status: ${Ft.status}`)}return await ee(),!0}catch(ce){return console.error("Error installing server:",ce),T(ce instanceof Error?ce.message:String(ce)),!1}},[l,ee]),ve=S.useCallback(F=>{re(F),O(1),oe(o,1,F)},[o,oe]);return S.useEffect(()=>{ke(),G(),V(),ee()},[ke,G,V,ee]),{servers:s,allServers:o,categories:f,tags:y,selectedCategory:g,selectedTag:w,searchQuery:R,loading:C,error:z,setError:T,currentServer:D,fetchMarketServers:ke,fetchServerByName:$,searchServers:ue,filterByCategory:E,filterByTag:Q,installServer:te,currentPage:H,totalPages:de,serversPerPage:J,changePage:xe,changeServersPerPage:ve,isServerInstalled:Z}},Qb=({server:l,onClick:s})=>{var y,h,g,v;const{t:r}=Te(),o=()=>{if(!l.tags||l.tags.length===0)return{tagsToShow:[],hasMore:!1,moreCount:0};const w=28,b=T=>T.length+3;let R=0,N=0;const C=[...l.tags].sort((T,D)=>T.length-D.length);for(N=0;N<C.length;N++){const T=b(C[N]);if(R+T>w)break;if(R+=T,N===C.length-1)return{tagsToShow:C,hasMore:!1,moreCount:0}}N===0&&C.length>0&&(N=1);const A=C.length-N,z=3+String(A).length+r("market.moreTags").length;return R+z<=w||N<1?{tagsToShow:C.slice(0,N),hasMore:!0,moreCount:A}:{tagsToShow:C.slice(0,Math.max(1,N-1)),hasMore:!0,moreCount:A+1}},{tagsToShow:d,hasMore:f,moreCount:m}=o();return c.jsxs("div",{className:"bg-white rounded-lg shadow-md p-5 hover:shadow-lg transition-shadow cursor-pointer flex flex-col h-full",onClick:()=>s(l),children:[c.jsxs("div",{className:"flex justify-between items-start mb-3",children:[c.jsx("h3",{className:"text-lg font-semibold text-gray-900 line-clamp-1 mr-2",children:l.display_name}),l.is_official&&c.jsx("span",{className:"bg-blue-100 text-blue-800 text-xs font-medium px-2.5 py-0.5 rounded flex-shrink-0",children:r("market.official")})]}),c.jsx("p",{className:"text-gray-600 text-sm mb-4 line-clamp-2 min-h-[40px]",children:l.description}),c.jsx("div",{className:"flex flex-wrap gap-1 mb-2 min-h-[28px]",children:((y=l.categories)==null?void 0:y.length)>0?l.categories.map((w,b)=>c.jsx("span",{className:"bg-gray-100 text-gray-800 text-xs px-2 py-1 rounded whitespace-nowrap",children:w},b)):c.jsx("span",{className:"text-xs text-gray-400 py-1",children:"-"})}),c.jsx("div",{className:"relative mb-3 min-h-[28px] overflow-x-auto",children:((h=l.tags)==null?void 0:h.length)>0?c.jsxs("div",{className:"flex gap-1 items-center whitespace-nowrap",children:[d.map((w,b)=>c.jsxs("span",{className:"bg-green-50 text-green-700 text-xs px-2 py-1 rounded flex-shrink-0",children:["#",w]},b)),f&&c.jsxs("span",{className:"bg-gray-100 text-gray-600 text-xs px-1.5 py-1 rounded flex-shrink-0",children:["+",m," ",r("market.moreTags")]})]}):c.jsx("span",{className:"text-xs text-gray-400 py-1",children:"-"})}),c.jsxs("div",{className:"flex justify-between items-center mt-auto pt-2 text-xs text-gray-500 border-t border-gray-100",children:[c.jsxs("div",{className:"overflow-hidden",children:[c.jsxs("span",{className:"whitespace-nowrap",children:[r("market.by")," "]}),c.jsx("span",{className:"font-medium whitespace-nowrap overflow-hidden text-ellipsis max-w-[120px] inline-block align-bottom",children:((g=l.author)==null?void 0:g.name)||r("market.unknown")})]}),c.jsxs("div",{className:"flex items-center flex-shrink-0",children:[c.jsx("svg",{className:"h-4 w-4 mr-1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M11.3 1.046A1 1 0 0112 2v5h4a1 1 0 01.82 1.573l-7 10A1 1 0 018 18v-5H4a1 1 0 01-.82-1.573l7-10a1 1 0 011.12-.38z",clipRule:"evenodd"})}),c.jsxs("span",{children:[((v=l.tools)==null?void 0:v.length)||0," ",r("market.tools")]})]})]})]})},Xb=({server:l,onBack:s,onInstall:r,installing:o=!1,isInstalled:d=!1})=>{var z,T;const{t:f}=Te(),[m,y]=S.useState(!1),[h,g]=S.useState(null),v=()=>d?{className:"bg-green-600 cursor-default px-4 py-2 rounded text-sm font-medium text-white",disabled:!0,text:f("market.installed")}:o?{className:"bg-gray-400 cursor-not-allowed px-4 py-2 rounded text-sm font-medium text-white",disabled:!0,text:f("market.installing")}:{className:"bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded text-sm font-medium text-white",disabled:!1,text:f("market.install")},w=()=>{y(!m),g(null)},b=()=>{d||w()},R=()=>{if(!l.installations)return;if(l.installations.npm)return l.installations.npm;if(l.installations.uvx)return l.installations.uvx;if(l.installations.default)return l.installations.default;const D=Object.keys(l.installations);if(D.length>0)return l.installations[D[0]]},N=async D=>{try{g(null),r(l),y(!1)}catch(q){console.error("Error installing server:",q),g(f("errors.serverInstall"))}},C=v(),A=R();return c.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6",children:[c.jsx("div",{className:"mb-4",children:c.jsxs("button",{onClick:s,className:"text-gray-600 hover:text-gray-900 flex items-center",children:[c.jsx("svg",{className:"h-5 w-5 mr-1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"})}),f("market.backToList")]})}),c.jsxs("div",{className:"flex justify-between items-start mb-4",children:[c.jsx("div",{children:c.jsxs("h2",{className:"text-2xl font-bold text-gray-900 flex items-center flex-wrap",children:[l.display_name,c.jsxs("span",{className:"text-sm font-normal text-gray-500 ml-2",children:["(",l.name,")"]}),c.jsxs("span",{className:"text-sm font-normal text-gray-600 ml-4",children:[f("market.author"),": ",l.author.name," • ",f("market.license"),": ",l.license," •",c.jsx("a",{href:l.repository.url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline ml-1",children:f("market.repository")})]})]})}),c.jsxs("div",{className:"flex items-center",children:[l.is_official&&c.jsx("span",{className:"bg-blue-100 text-blue-800 text-sm font-medium px-4 py-2 rounded mr-2 flex items-center",children:f("market.official")}),c.jsx("button",{onClick:b,disabled:C.disabled,className:C.className,children:C.text})]})]}),c.jsx("p",{className:"text-gray-700 mb-6",children:l.description}),c.jsxs("div",{className:"mb-6",children:[c.jsxs("h3",{className:"text-lg font-semibold mb-3",children:[f("market.categories")," & ",f("market.tags")]}),c.jsxs("div",{className:"flex flex-wrap gap-2",children:[(z=l.categories)==null?void 0:z.map((D,q)=>c.jsx("span",{className:"bg-gray-100 text-gray-800 px-3 py-1 rounded",children:D},`cat-${q}`)),l.tags&&l.tags.map((D,q)=>c.jsxs("span",{className:"bg-gray-100 text-green-700 px-2 py-1 rounded text-sm",children:["#",D]},`tag-${q}`))]})]}),l.arguments&&Object.keys(l.arguments).length>0&&c.jsxs("div",{className:"mb-6",children:[c.jsx("h3",{className:"text-lg font-semibold mb-3",children:f("market.arguments")}),c.jsx("div",{className:"overflow-x-auto",children:c.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[c.jsx("thead",{className:"bg-gray-50",children:c.jsxs("tr",{children:[c.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:f("market.argumentName")}),c.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:f("market.description")}),c.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:f("market.required")}),c.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:f("market.example")})]})}),c.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:Object.entries(l.arguments).map(([D,q],Y)=>c.jsxs("tr",{children:[c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:D}),c.jsx("td",{className:"px-6 py-4 text-sm text-gray-500",children:q.description}),c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:q.required?c.jsx("span",{className:"text-green-600",children:"✓"}):c.jsx("span",{className:"text-red-600",children:"✗"})}),c.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:c.jsx("code",{className:"bg-gray-100 px-2 py-1 rounded",children:q.example})})]},Y))})]})})]}),c.jsxs("div",{className:"mb-6",children:[c.jsx("h3",{className:"text-lg font-semibold mb-3",children:f("market.tools")}),c.jsx("div",{className:"space-y-4",children:(T=l.tools)==null?void 0:T.map((D,q)=>c.jsxs("div",{className:"border border-gray-200 rounded p-4",children:[c.jsxs("h4",{className:"font-medium mb-2",children:[D.name,c.jsx("button",{type:"button",onClick:()=>{const Y=document.getElementById(`schema-${q}`);Y&&Y.classList.toggle("hidden")},className:"text-sm text-blue-600 hover:underline focus:outline-none ml-2",children:f("market.viewSchema")})]}),c.jsx("p",{className:"text-gray-600 mb-2",children:D.description}),c.jsx("div",{className:"mt-2",children:c.jsx("pre",{id:`schema-${q}`,className:"hidden bg-gray-50 p-3 rounded text-sm overflow-auto mt-2",children:JSON.stringify(D.inputSchema,null,2)})})]},q))})]}),l.examples&&l.examples.length>0&&c.jsxs("div",{className:"mb-6",children:[c.jsx("h3",{className:"text-lg font-semibold mb-3",children:f("market.examples")}),c.jsx("div",{className:"space-y-4",children:l.examples.map((D,q)=>c.jsxs("div",{className:"border border-gray-200 rounded p-4",children:[c.jsx("h4",{className:"font-medium mb-2",children:D.title}),c.jsx("p",{className:"text-gray-600 mb-2",children:D.description}),c.jsx("pre",{className:"bg-gray-50 p-3 rounded text-sm overflow-auto",children:D.prompt})]},q))})]}),c.jsx("div",{className:"mt-6 flex justify-end",children:c.jsx("button",{onClick:b,disabled:C.disabled,className:C.className,children:C.text})}),m&&c.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:c.jsx(qu,{onSubmit:N,onCancel:w,modalTitle:f("market.installServer",{name:l.display_name}),formError:h,initialData:{name:l.name,status:"disconnected",config:A?{command:A.command||"",args:A.args||[],env:A.env||{}}:void 0}})})]})},Zb=({currentPage:l,totalPages:s,onPageChange:r})=>{const o=()=>{const d=[];d.push(c.jsx("button",{onClick:()=>r(1),className:`px-3 py-1 mx-1 rounded ${l===1?"bg-blue-500 text-white":"bg-gray-200 hover:bg-gray-300 text-gray-700"}`,children:"1"},"first"));let m=Math.max(2,l-Math.floor(5/2));m>2&&d.push(c.jsx("span",{className:"px-3 py-1",children:"..."},"ellipsis1"));for(let y=m;y<=Math.min(s-1,m+5-3);y++)d.push(c.jsx("button",{onClick:()=>r(y),className:`px-3 py-1 mx-1 rounded ${l===y?"bg-blue-500 text-white":"bg-gray-200 hover:bg-gray-300 text-gray-700"}`,children:y},y));return m+5-3<s-1&&d.push(c.jsx("span",{className:"px-3 py-1",children:"..."},"ellipsis2")),s>1&&d.push(c.jsx("button",{onClick:()=>r(s),className:`px-3 py-1 mx-1 rounded ${l===s?"bg-blue-500 text-white":"bg-gray-200 hover:bg-gray-300 text-gray-700"}`,children:s},"last")),d};return s<=1?null:c.jsxs("div",{className:"flex justify-center items-center my-6",children:[c.jsx("button",{onClick:()=>r(Math.max(1,l-1)),disabled:l===1,className:`px-3 py-1 rounded mr-2 ${l===1?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-200 hover:bg-gray-300 text-gray-700"}`,children:"« Prev"}),c.jsx("div",{className:"flex",children:o()}),c.jsx("button",{onClick:()=>r(Math.min(s,l+1)),disabled:l===s,className:`px-3 py-1 rounded ml-2 ${l===s?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-200 hover:bg-gray-300 text-gray-700"}`,children:"Next »"})]})},rm=()=>{const{t:l}=Te(),s=un();Jt();const{serverName:r}=zy(),{showToast:o}=ps(),{servers:d,allServers:f,categories:m,loading:y,error:h,setError:g,searchServers:v,filterByCategory:w,filterByTag:b,selectedCategory:R,selectedTag:N,installServer:C,fetchServerByName:A,isServerInstalled:z,currentPage:T,totalPages:D,changePage:q,serversPerPage:Y,changeServersPerPage:W}=$b(),[H,O]=S.useState(null),[J,re]=S.useState(""),[de,me]=S.useState(!1),[ke,oe]=S.useState(!1);S.useEffect(()=>{(async()=>{if(r){const te=await A(r);te?O(te):s("/market")}else O(null)})()},[r,A,s]);const xe=Z=>{Z.preventDefault(),v(J)},G=Z=>{w(Z)},V=()=>{re(""),w(""),b("")},$=Z=>{s(`/market/${Z.name}`)},ue=()=>{s("/market")},E=async Z=>{try{me(!0),await C(Z)&&o(l("market.installSuccess",{serverName:Z.display_name}),"success")}finally{me(!1)}},Q=Z=>{q(Z),window.scrollTo({top:0,behavior:"smooth"})},ee=Z=>{const te=parseInt(Z.target.value,10);W(te)};return H?c.jsx(Xb,{server:H,onBack:ue,onInstall:E,installing:de,isInstalled:z(H.name)}):c.jsxs("div",{children:[c.jsx("div",{className:"flex justify-between items-center mb-8",children:c.jsx("div",{children:c.jsxs("h1",{className:"text-2xl font-bold text-gray-900 flex items-center",children:[l("market.title"),c.jsx("span",{className:"text-sm text-gray-500 font-normal ml-2",children:l("pages.market.title").split(" - ")[1]})]})})}),h&&c.jsx("div",{className:"bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-6",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{children:h}),c.jsx("button",{onClick:()=>g(null),className:"text-red-700 hover:text-red-900",children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:c.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 011.414 0L10 8.586l4.293-4.293a1 1 01.414 1.414L11.414 10l4.293 4.293a1 1 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 01-1.414-1.414L8.586 10 4.293 5.707a1 1 010-1.414z",clipRule:"evenodd"})})})]})}),c.jsx("div",{className:"bg-white shadow rounded-lg p-6 mb-6",children:c.jsxs("form",{onSubmit:xe,className:"flex space-x-4 mb-0",children:[c.jsx("div",{className:"flex-grow",children:c.jsx("input",{type:"text",value:J,onChange:Z=>re(Z.target.value),placeholder:l("market.searchPlaceholder"),className:"shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"})}),c.jsx("button",{type:"submit",className:"bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded",children:l("market.search")}),(J||R||N)&&c.jsx("button",{type:"button",onClick:V,className:"border border-gray-300 text-gray-700 font-medium py-2 px-4 rounded hover:bg-gray-50",children:l("market.clearFilters")})]})}),c.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[c.jsx("div",{className:"md:w-48 flex-shrink-0",children:c.jsx("div",{className:"bg-white shadow rounded-lg p-4 mb-6 sticky top-4",children:m.length>0?c.jsxs("div",{className:"mb-6",children:[c.jsxs("div",{className:"flex justify-between items-center mb-3",children:[c.jsx("h3",{className:"font-medium text-gray-900",children:l("market.categories")}),R&&c.jsx("span",{className:"text-xs text-blue-600 cursor-pointer hover:underline",onClick:()=>w(""),children:l("market.clearCategoryFilter")})]}),c.jsx("div",{className:"flex flex-col gap-2",children:m.map(Z=>c.jsx("button",{onClick:()=>G(Z),className:`px-3 py-2 rounded text-sm text-left ${R===Z?"bg-blue-100 text-blue-800 font-medium":"bg-gray-100 text-gray-800 hover:bg-gray-200"}`,children:Z},Z))})]}):y?c.jsxs("div",{className:"mb-6",children:[c.jsx("div",{className:"mb-3",children:c.jsx("h3",{className:"font-medium text-gray-900",children:l("market.categories")})}),c.jsxs("div",{className:"flex flex-col gap-2 items-center py-4",children:[c.jsxs("svg",{className:"animate-spin h-6 w-6 text-blue-500 mb-2",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c.jsx("p",{className:"text-sm text-gray-600",children:l("app.loading")})]})]}):c.jsxs("div",{className:"mb-6",children:[c.jsx("div",{className:"mb-3",children:c.jsx("h3",{className:"font-medium text-gray-900",children:l("market.categories")})}),c.jsx("p",{className:"text-sm text-gray-600 py-2",children:l("market.noCategories")})]})})}),c.jsx("div",{className:"flex-grow",children:y?c.jsx("div",{className:"bg-white shadow rounded-lg p-6 flex items-center justify-center",children:c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsxs("svg",{className:"animate-spin h-10 w-10 text-blue-500 mb-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[c.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),c.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),c.jsx("p",{className:"text-gray-600",children:l("app.loading")})]})}):d.length===0?c.jsx("div",{className:"bg-white shadow rounded-lg p-6",children:c.jsx("p",{className:"text-gray-600",children:l("market.noServers")})}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 gap-6",children:d.map((Z,te)=>c.jsx(Qb,{server:Z,onClick:$},te))}),c.jsxs("div",{className:"flex justify-between items-center mb-4",children:[c.jsx("div",{className:"text-sm text-gray-500",children:l("market.showing",{from:(T-1)*Y+1,to:Math.min(T*Y,f.length),total:f.length})}),c.jsx(Zb,{currentPage:T,totalPages:D,onPageChange:Q}),c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsxs("label",{htmlFor:"perPage",className:"text-sm text-gray-600",children:[l("market.perPage"),":"]}),c.jsxs("select",{id:"perPage",value:Y,onChange:ee,className:"border rounded p-1 text-sm",children:[c.jsx("option",{value:"6",children:"6"}),c.jsx("option",{value:"9",children:"9"}),c.jsx("option",{value:"12",children:"12"}),c.jsx("option",{value:"24",children:"24"})]})]})]}),c.jsx("div",{className:"mt-6"})]})})]})]})},Pb={default:"bg-blue-500 text-white hover:bg-blue-600 focus:ring-blue-500",outline:"border border-gray-300 dark:border-gray-700 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300",ghost:"bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-700 dark:text-gray-300",link:"bg-transparent underline-offset-4 hover:underline text-blue-500 hover:text-blue-600",destructive:"bg-red-500 text-white hover:bg-red-600 focus:ring-red-500"},Jb={default:"h-10 py-2 px-4",sm:"h-8 px-3 text-sm",lg:"h-12 px-6",icon:"h-10 w-10 p-0"};function Fb({variant:l="default",size:s="default",className:r,disabled:o,children:d,...f}){return c.jsx("button",{className:qa("rounded-md inline-flex items-center justify-center font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none",Pb[l],Jb[s],r),disabled:o,...f,children:d})}const Wb=({logs:l,isLoading:s=!1,error:r=null,onClear:o})=>{const{t:d}=Te(),f=S.useRef(null),[m,y]=S.useState(!0),[h,g]=S.useState(""),[v,w]=S.useState(["info","error","warn","debug"]),[b,R]=S.useState(["main","child"]);S.useEffect(()=>{m&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[l,m]);const N=l.filter(T=>{const D=h?T.message.toLowerCase().includes(h.toLowerCase()):!0,q=v.includes(T.type),Y=b.includes(T.source);return D&&q&&Y}),C=T=>new Date(T).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),A=T=>{switch(T){case"error":return"bg-red-400";case"warn":return"bg-yellow-400";case"debug":return"bg-purple-400";default:return"bg-blue-400"}},z=T=>{switch(T){case"main":return"bg-green-400";case"child":return"bg-orange-400";default:return"bg-gray-400"}};return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"bg-card p-3 rounded-t-md border-b flex flex-wrap items-center justify-between gap-2",children:[c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsxs("span",{className:"font-semibold text-sm",children:[d("logs.filters"),":"]}),c.jsx("input",{type:"text",placeholder:d("logs.search"),className:"px-2 py-1 text-sm border rounded",value:h,onChange:T=>g(T.target.value)}),c.jsx("div",{className:"flex gap-1 items-center",children:["info","error","warn","debug"].map(T=>c.jsx(Lr,{variant:v.includes(T)?"default":"outline",className:`cursor-pointer ${v.includes(T)?A(T):""}`,onClick:()=>{v.includes(T)?w(D=>D.filter(q=>q!==T)):w(D=>[...D,T])},children:T},T))}),c.jsx("div",{className:"flex gap-1 items-center ml-2",children:["main","child"].map(T=>c.jsx(Lr,{variant:b.includes(T)?"default":"outline",className:`cursor-pointer ${b.includes(T)?z(T):""}`,onClick:()=>{b.includes(T)?R(D=>D.filter(q=>q!==T)):R(D=>[...D,T])},children:d(T==="main"?"logs.mainProcess":"logs.childProcess")},T))})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[c.jsx("input",{type:"checkbox",checked:m,onChange:()=>y(!m),className:"form-checkbox h-4 w-4"}),d("logs.autoScroll")]}),c.jsx(Fb,{variant:"outline",size:"sm",onClick:o,disabled:s||l.length===0,children:d("logs.clearLogs")})]})]}),c.jsx("div",{ref:f,className:"flex-grow p-2 overflow-auto bg-card rounded-b-md font-mono text-sm",style:{maxHeight:"calc(100vh - 300px)"},children:s?c.jsx("div",{className:"flex justify-center items-center h-full",children:c.jsx("span",{children:d("logs.loading")})}):r?c.jsx("div",{className:"text-red-500 p-2",children:r.message}):N.length===0?c.jsx("div",{className:"text-center text-muted-foreground p-8",children:h||v.length<4||b.length<2?d("logs.noMatch"):d("logs.noLogs")}):N.map((T,D)=>c.jsxs("div",{className:`py-1 border-b border-gray-100 dark:border-gray-800 ${T.type==="error"?"text-red-500":T.type==="warn"?"text-yellow-500":""}`,children:[c.jsxs("span",{className:"text-gray-400",children:["[",C(T.timestamp),"]"]}),c.jsx(Lr,{className:`ml-2 mr-1 ${A(T.type)}`,children:T.type}),c.jsxs(Lr,{variant:"default",className:`mr-2 ${z(T.source)}`,children:[T.source==="main"?d("logs.main"):d("logs.child"),T.processId?` (${T.processId})`:""]}),c.jsx("span",{className:"whitespace-pre-wrap",children:T.message})]},`${T.timestamp}-${D}`))})]})},Ib=async()=>{try{const l=gs();if(!l)throw new Error("Authentication token not found. Please log in.");const r=await(await fetch(Ee("/logs"),{method:"DELETE",headers:{"x-auth-token":l}})).json();if(!r.success)throw new Error(r.error||"Failed to clear logs")}catch(l){throw console.error("Error clearing logs:",l),l}},e1=()=>{const[l,s]=S.useState([]),[r,o]=S.useState(!0),[d,f]=S.useState(null);return S.useEffect(()=>{let y=null,h=!0;const g=()=>{try{y&&y.close();const v=gs();if(!v){f(new Error("Authentication token not found. Please log in.")),o(!1);return}y=new EventSource(Ee(`/logs/stream?token=${v}`)),y.onmessage=w=>{if(h)try{const b=JSON.parse(w.data);b.type==="initial"?(s(b.logs),o(!1)):b.type==="log"&&s(R=>[...R,b.log])}catch(b){console.error("Error parsing SSE message:",b)}},y.onerror=()=>{h&&(y&&(y.close(),setTimeout(g,5e3)),f(new Error("Connection to log stream lost, attempting to reconnect...")))}}catch(v){if(!h)return;f(v instanceof Error?v:new Error("Failed to connect to log stream")),o(!1)}};return g(),()=>{h=!1,y&&y.close()}},[]),{logs:l,loading:r,error:d,clearLogs:async()=>{try{await Ib(),s([])}catch(y){f(y instanceof Error?y:new Error("Failed to clear logs"))}}}},t1=()=>{const{t:l}=Te(),{logs:s,loading:r,error:o,clearLogs:d}=e1();return c.jsxs("div",{className:"container mx-auto p-4",children:[c.jsx("div",{className:"flex justify-between items-center mb-4",children:c.jsx("h1",{className:"text-2xl font-bold",children:l("pages.logs.title")})}),c.jsx("div",{className:"bg-card rounded-md shadow-sm",children:c.jsx(Wb,{logs:s,isLoading:r,error:o,onClear:d})})]})};function im(){const l=Km();return c.jsx(Pv,{children:c.jsx(Ux,{children:c.jsx(Xv,{children:c.jsx(xx,{basename:l,children:c.jsxs(Zy,{children:[c.jsx(Ut,{path:"/login",element:c.jsx(kb,{})}),c.jsx(Ut,{element:c.jsx(Cb,{}),children:c.jsxs(Ut,{element:c.jsx(Eb,{}),children:[c.jsx(Ut,{path:"/",element:c.jsx(Ab,{})}),c.jsx(Ut,{path:"/servers",element:c.jsx(Ub,{})}),c.jsx(Ut,{path:"/groups",element:c.jsx(Gb,{})}),c.jsx(Ut,{path:"/market",element:c.jsx(rm,{})}),c.jsx(Ut,{path:"/market/:serverName",element:c.jsx(rm,{})}),c.jsx(Ut,{path:"/logs",element:c.jsx(t1,{})}),c.jsx(Ut,{path:"/settings",element:c.jsx(Kb,{})})]})}),c.jsx(Ut,{path:"*",element:c.jsx(Um,{to:"/"})})]})})})})})}const pe=l=>typeof l=="string",os=()=>{let l,s;const r=new Promise((o,d)=>{l=o,s=d});return r.resolve=l,r.reject=s,r},om=l=>l==null?"":""+l,a1=(l,s,r)=>{l.forEach(o=>{s[o]&&(r[o]=s[o])})},n1=/###/g,um=l=>l&&l.indexOf("###")>-1?l.replace(n1,"."):l,cm=l=>!l||pe(l),us=(l,s,r)=>{const o=pe(s)?s.split("."):s;let d=0;for(;d<o.length-1;){if(cm(l))return{};const f=um(o[d]);!l[f]&&r&&(l[f]=new r),Object.prototype.hasOwnProperty.call(l,f)?l=l[f]:l={},++d}return cm(l)?{}:{obj:l,k:um(o[d])}},dm=(l,s,r)=>{const{obj:o,k:d}=us(l,s,Object);if(o!==void 0||s.length===1){o[d]=r;return}let f=s[s.length-1],m=s.slice(0,s.length-1),y=us(l,m,Object);for(;y.obj===void 0&&m.length;)f=`${m[m.length-1]}.${f}`,m=m.slice(0,m.length-1),y=us(l,m,Object),y!=null&&y.obj&&typeof y.obj[`${y.k}.${f}`]<"u"&&(y.obj=void 0);y.obj[`${y.k}.${f}`]=r},l1=(l,s,r,o)=>{const{obj:d,k:f}=us(l,s,Object);d[f]=d[f]||[],d[f].push(r)},Vr=(l,s)=>{const{obj:r,k:o}=us(l,s);if(r&&Object.prototype.hasOwnProperty.call(r,o))return r[o]},s1=(l,s,r)=>{const o=Vr(l,r);return o!==void 0?o:Vr(s,r)},xg=(l,s,r)=>{for(const o in s)o!=="__proto__"&&o!=="constructor"&&(o in l?pe(l[o])||l[o]instanceof String||pe(s[o])||s[o]instanceof String?r&&(l[o]=s[o]):xg(l[o],s[o],r):l[o]=s[o]);return l},Jn=l=>l.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var r1={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const i1=l=>pe(l)?l.replace(/[&<>"'\/]/g,s=>r1[s]):l;class o1{constructor(s){this.capacity=s,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(s){const r=this.regExpMap.get(s);if(r!==void 0)return r;const o=new RegExp(s);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(s,o),this.regExpQueue.push(s),o}}const u1=[" ",",","?","!",";"],c1=new o1(20),d1=(l,s,r)=>{s=s||"",r=r||"";const o=u1.filter(m=>s.indexOf(m)<0&&r.indexOf(m)<0);if(o.length===0)return!0;const d=c1.getRegExp(`(${o.map(m=>m==="?"?"\\?":m).join("|")})`);let f=!d.test(l);if(!f){const m=l.indexOf(r);m>0&&!d.test(l.substring(0,m))&&(f=!0)}return f},Tu=function(l,s){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!l)return;if(l[s])return Object.prototype.hasOwnProperty.call(l,s)?l[s]:void 0;const o=s.split(r);let d=l;for(let f=0;f<o.length;){if(!d||typeof d!="object")return;let m,y="";for(let h=f;h<o.length;++h)if(h!==f&&(y+=r),y+=o[h],m=d[y],m!==void 0){if(["string","number","boolean"].indexOf(typeof m)>-1&&h<o.length-1)continue;f+=h-f+1;break}d=m}return d},Yr=l=>l==null?void 0:l.replace("_","-"),f1={type:"logger",log(l){this.output("log",l)},warn(l){this.output("warn",l)},error(l){this.output("error",l)},output(l,s){var r,o;(o=(r=console==null?void 0:console[l])==null?void 0:r.apply)==null||o.call(r,console,s)}};class Kr{constructor(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(s,r)}init(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=r.prefix||"i18next:",this.logger=s||f1,this.options=r,this.debug=r.debug}log(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return this.forward(r,"log","",!0)}warn(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return this.forward(r,"warn","",!0)}error(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return this.forward(r,"error","")}deprecate(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return this.forward(r,"warn","WARNING DEPRECATED: ",!0)}forward(s,r,o,d){return d&&!this.debug?null:(pe(s[0])&&(s[0]=`${o}${this.prefix} ${s[0]}`),this.logger[r](s))}create(s){return new Kr(this.logger,{prefix:`${this.prefix}:${s}:`,...this.options})}clone(s){return s=s||this.options,s.prefix=s.prefix||this.prefix,new Kr(this.logger,s)}}var Pt=new Kr;class Pr{constructor(){this.observers={}}on(s,r){return s.split(" ").forEach(o=>{this.observers[o]||(this.observers[o]=new Map);const d=this.observers[o].get(r)||0;this.observers[o].set(r,d+1)}),this}off(s,r){if(this.observers[s]){if(!r){delete this.observers[s];return}this.observers[s].delete(r)}}emit(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),d=1;d<r;d++)o[d-1]=arguments[d];this.observers[s]&&Array.from(this.observers[s].entries()).forEach(m=>{let[y,h]=m;for(let g=0;g<h;g++)y(...o)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(m=>{let[y,h]=m;for(let g=0;g<h;g++)y.apply(y,[s,...o])})}}class fm extends Pr{constructor(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=s||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(s){this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}removeNamespaces(s){const r=this.options.ns.indexOf(s);r>-1&&this.options.ns.splice(r,1)}getResource(s,r,o){var g,v;let d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const f=d.keySeparator!==void 0?d.keySeparator:this.options.keySeparator,m=d.ignoreJSONStructure!==void 0?d.ignoreJSONStructure:this.options.ignoreJSONStructure;let y;s.indexOf(".")>-1?y=s.split("."):(y=[s,r],o&&(Array.isArray(o)?y.push(...o):pe(o)&&f?y.push(...o.split(f)):y.push(o)));const h=Vr(this.data,y);return!h&&!r&&!o&&s.indexOf(".")>-1&&(s=y[0],r=y[1],o=y.slice(2).join(".")),h||!m||!pe(o)?h:Tu((v=(g=this.data)==null?void 0:g[s])==null?void 0:v[r],o,f)}addResource(s,r,o,d){let f=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const m=f.keySeparator!==void 0?f.keySeparator:this.options.keySeparator;let y=[s,r];o&&(y=y.concat(m?o.split(m):o)),s.indexOf(".")>-1&&(y=s.split("."),d=r,r=y[1]),this.addNamespaces(r),dm(this.data,y,d),f.silent||this.emit("added",s,r,o,d)}addResources(s,r,o){let d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const f in o)(pe(o[f])||Array.isArray(o[f]))&&this.addResource(s,r,f,o[f],{silent:!0});d.silent||this.emit("added",s,r,o)}addResourceBundle(s,r,o,d,f){let m=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},y=[s,r];s.indexOf(".")>-1&&(y=s.split("."),d=o,o=r,r=y[1]),this.addNamespaces(r);let h=Vr(this.data,y)||{};m.skipCopy||(o=JSON.parse(JSON.stringify(o))),d?xg(h,o,f):h={...h,...o},dm(this.data,y,h),m.silent||this.emit("added",s,r,o)}removeResourceBundle(s,r){this.hasResourceBundle(s,r)&&delete this.data[s][r],this.removeNamespaces(r),this.emit("removed",s,r)}hasResourceBundle(s,r){return this.getResource(s,r)!==void 0}getResourceBundle(s,r){return r||(r=this.options.defaultNS),this.getResource(s,r)}getDataByLanguage(s){return this.data[s]}hasLanguageSomeTranslations(s){const r=this.getDataByLanguage(s);return!!(r&&Object.keys(r)||[]).find(d=>r[d]&&Object.keys(r[d]).length>0)}toJSON(){return this.data}}var vg={processors:{},addPostProcessor(l){this.processors[l.name]=l},handle(l,s,r,o,d){return l.forEach(f=>{var m;s=((m=this.processors[f])==null?void 0:m.process(s,r,o,d))??s}),s}};const hm={},mm=l=>!pe(l)&&typeof l!="boolean"&&typeof l!="number";class $r extends Pr{constructor(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),a1(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],s,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Pt.create("translator")}changeLanguage(s){s&&(this.language=s)}exists(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(s==null)return!1;const o=this.resolve(s,r);return(o==null?void 0:o.res)!==void 0}extractFromKey(s,r){let o=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");const d=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator;let f=r.ns||this.options.defaultNS||[];const m=o&&s.indexOf(o)>-1,y=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!d1(s,o,d);if(m&&!y){const h=s.match(this.interpolator.nestingRegexp);if(h&&h.length>0)return{key:s,namespaces:pe(f)?[f]:f};const g=s.split(o);(o!==d||o===d&&this.options.ns.indexOf(g[0])>-1)&&(f=g.shift()),s=g.join(d)}return{key:s,namespaces:pe(f)?[f]:f}}translate(s,r,o){if(typeof r!="object"&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),typeof r=="object"&&(r={...r}),r||(r={}),s==null)return"";Array.isArray(s)||(s=[String(s)]);const d=r.returnDetails!==void 0?r.returnDetails:this.options.returnDetails,f=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,{key:m,namespaces:y}=this.extractFromKey(s[s.length-1],r),h=y[y.length-1],g=r.lng||this.language,v=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((g==null?void 0:g.toLowerCase())==="cimode"){if(v){const de=r.nsSeparator||this.options.nsSeparator;return d?{res:`${h}${de}${m}`,usedKey:m,exactUsedKey:m,usedLng:g,usedNS:h,usedParams:this.getUsedParamsDetails(r)}:`${h}${de}${m}`}return d?{res:m,usedKey:m,exactUsedKey:m,usedLng:g,usedNS:h,usedParams:this.getUsedParamsDetails(r)}:m}const w=this.resolve(s,r);let b=w==null?void 0:w.res;const R=(w==null?void 0:w.usedKey)||m,N=(w==null?void 0:w.exactUsedKey)||m,C=["[object Number]","[object Function]","[object RegExp]"],A=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,z=!this.i18nFormat||this.i18nFormat.handleAsObject,T=r.count!==void 0&&!pe(r.count),D=$r.hasDefaultValue(r),q=T?this.pluralResolver.getSuffix(g,r.count,r):"",Y=r.ordinal&&T?this.pluralResolver.getSuffix(g,r.count,{ordinal:!1}):"",W=T&&!r.ordinal&&r.count===0,H=W&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${q}`]||r[`defaultValue${Y}`]||r.defaultValue;let O=b;z&&!b&&D&&(O=H);const J=mm(O),re=Object.prototype.toString.apply(O);if(z&&O&&J&&C.indexOf(re)<0&&!(pe(A)&&Array.isArray(O))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const de=this.options.returnedObjectHandler?this.options.returnedObjectHandler(R,O,{...r,ns:y}):`key '${m} (${this.language})' returned an object instead of string.`;return d?(w.res=de,w.usedParams=this.getUsedParamsDetails(r),w):de}if(f){const de=Array.isArray(O),me=de?[]:{},ke=de?N:R;for(const oe in O)if(Object.prototype.hasOwnProperty.call(O,oe)){const xe=`${ke}${f}${oe}`;D&&!b?me[oe]=this.translate(xe,{...r,defaultValue:mm(H)?H[oe]:void 0,joinArrays:!1,ns:y}):me[oe]=this.translate(xe,{...r,joinArrays:!1,ns:y}),me[oe]===xe&&(me[oe]=O[oe])}b=me}}else if(z&&pe(A)&&Array.isArray(b))b=b.join(A),b&&(b=this.extendTranslation(b,s,r,o));else{let de=!1,me=!1;!this.isValidLookup(b)&&D&&(de=!0,b=H),this.isValidLookup(b)||(me=!0,b=m);const oe=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&me?void 0:b,xe=D&&H!==b&&this.options.updateMissing;if(me||de||xe){if(this.logger.log(xe?"updateKey":"missingKey",g,h,m,xe?H:b),f){const ue=this.resolve(m,{...r,keySeparator:!1});ue&&ue.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let G=[];const V=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&V&&V[0])for(let ue=0;ue<V.length;ue++)G.push(V[ue]);else this.options.saveMissingTo==="all"?G=this.languageUtils.toResolveHierarchy(r.lng||this.language):G.push(r.lng||this.language);const $=(ue,E,Q)=>{var Z;const ee=D&&Q!==b?Q:oe;this.options.missingKeyHandler?this.options.missingKeyHandler(ue,h,E,ee,xe,r):(Z=this.backendConnector)!=null&&Z.saveMissing&&this.backendConnector.saveMissing(ue,h,E,ee,xe,r),this.emit("missingKey",ue,h,E,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?G.forEach(ue=>{const E=this.pluralResolver.getSuffixes(ue,r);W&&r[`defaultValue${this.options.pluralSeparator}zero`]&&E.indexOf(`${this.options.pluralSeparator}zero`)<0&&E.push(`${this.options.pluralSeparator}zero`),E.forEach(Q=>{$([ue],m+Q,r[`defaultValue${Q}`]||H)})}):$(G,m,H))}b=this.extendTranslation(b,s,r,w,o),me&&b===m&&this.options.appendNamespaceToMissingKey&&(b=`${h}:${m}`),(me||de)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${h}:${m}`:m,de?b:void 0))}return d?(w.res=b,w.usedParams=this.getUsedParamsDetails(r),w):b}extendTranslation(s,r,o,d,f){var g,v;var m=this;if((g=this.i18nFormat)!=null&&g.parse)s=this.i18nFormat.parse(s,{...this.options.interpolation.defaultVariables,...o},o.lng||this.language||d.usedLng,d.usedNS,d.usedKey,{resolved:d});else if(!o.skipInterpolation){o.interpolation&&this.interpolator.init({...o,interpolation:{...this.options.interpolation,...o.interpolation}});const w=pe(s)&&(((v=o==null?void 0:o.interpolation)==null?void 0:v.skipOnVariables)!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let b;if(w){const N=s.match(this.interpolator.nestingRegexp);b=N&&N.length}let R=o.replace&&!pe(o.replace)?o.replace:o;if(this.options.interpolation.defaultVariables&&(R={...this.options.interpolation.defaultVariables,...R}),s=this.interpolator.interpolate(s,R,o.lng||this.language||d.usedLng,o),w){const N=s.match(this.interpolator.nestingRegexp),C=N&&N.length;b<C&&(o.nest=!1)}!o.lng&&d&&d.res&&(o.lng=this.language||d.usedLng),o.nest!==!1&&(s=this.interpolator.nest(s,function(){for(var N=arguments.length,C=new Array(N),A=0;A<N;A++)C[A]=arguments[A];return(f==null?void 0:f[0])===C[0]&&!o.context?(m.logger.warn(`It seems you are nesting recursively key: ${C[0]} in key: ${r[0]}`),null):m.translate(...C,r)},o)),o.interpolation&&this.interpolator.reset()}const y=o.postProcess||this.options.postProcess,h=pe(y)?[y]:y;return s!=null&&(h!=null&&h.length)&&o.applyPostProcessor!==!1&&(s=vg.handle(h,s,r,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...d,usedParams:this.getUsedParamsDetails(o)},...o}:o,this)),s}resolve(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o,d,f,m,y;return pe(s)&&(s=[s]),s.forEach(h=>{if(this.isValidLookup(o))return;const g=this.extractFromKey(h,r),v=g.key;d=v;let w=g.namespaces;this.options.fallbackNS&&(w=w.concat(this.options.fallbackNS));const b=r.count!==void 0&&!pe(r.count),R=b&&!r.ordinal&&r.count===0,N=r.context!==void 0&&(pe(r.context)||typeof r.context=="number")&&r.context!=="",C=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);w.forEach(A=>{var z,T;this.isValidLookup(o)||(y=A,!hm[`${C[0]}-${A}`]&&((z=this.utils)!=null&&z.hasLoadedNamespace)&&!((T=this.utils)!=null&&T.hasLoadedNamespace(y))&&(hm[`${C[0]}-${A}`]=!0,this.logger.warn(`key "${d}" for languages "${C.join(", ")}" won't get resolved as namespace "${y}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),C.forEach(D=>{var W;if(this.isValidLookup(o))return;m=D;const q=[v];if((W=this.i18nFormat)!=null&&W.addLookupKeys)this.i18nFormat.addLookupKeys(q,v,D,A,r);else{let H;b&&(H=this.pluralResolver.getSuffix(D,r.count,r));const O=`${this.options.pluralSeparator}zero`,J=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(b&&(q.push(v+H),r.ordinal&&H.indexOf(J)===0&&q.push(v+H.replace(J,this.options.pluralSeparator)),R&&q.push(v+O)),N){const re=`${v}${this.options.contextSeparator}${r.context}`;q.push(re),b&&(q.push(re+H),r.ordinal&&H.indexOf(J)===0&&q.push(re+H.replace(J,this.options.pluralSeparator)),R&&q.push(re+O))}}let Y;for(;Y=q.pop();)this.isValidLookup(o)||(f=Y,o=this.getResource(D,A,Y,r))}))})}),{res:o,usedKey:d,exactUsedKey:f,usedLng:m,usedNS:y}}isValidLookup(s){return s!==void 0&&!(!this.options.returnNull&&s===null)&&!(!this.options.returnEmptyString&&s==="")}getResource(s,r,o){var f;let d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return(f=this.i18nFormat)!=null&&f.getResource?this.i18nFormat.getResource(s,r,o,d):this.resourceStore.getResource(s,r,o,d)}getUsedParamsDetails(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],o=s.replace&&!pe(s.replace);let d=o?s.replace:s;if(o&&typeof s.count<"u"&&(d.count=s.count),this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),!o){d={...d};for(const f of r)delete d[f]}return d}static hasDefaultValue(s){const r="defaultValue";for(const o in s)if(Object.prototype.hasOwnProperty.call(s,o)&&r===o.substring(0,r.length)&&s[o]!==void 0)return!0;return!1}}class gm{constructor(s){this.options=s,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Pt.create("languageUtils")}getScriptPartFromCode(s){if(s=Yr(s),!s||s.indexOf("-")<0)return null;const r=s.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(s){if(s=Yr(s),!s||s.indexOf("-")<0)return s;const r=s.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(s){if(pe(s)&&s.indexOf("-")>-1){let r;try{r=Intl.getCanonicalLocales(s)[0]}catch{}return r&&this.options.lowerCaseLng&&(r=r.toLowerCase()),r||(this.options.lowerCaseLng?s.toLowerCase():s)}return this.options.cleanCode||this.options.lowerCaseLng?s.toLowerCase():s}isSupportedCode(s){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(s=this.getLanguagePartFromCode(s)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(s)>-1}getBestMatchFromCodes(s){if(!s)return null;let r;return s.forEach(o=>{if(r)return;const d=this.formatLanguageCode(o);(!this.options.supportedLngs||this.isSupportedCode(d))&&(r=d)}),!r&&this.options.supportedLngs&&s.forEach(o=>{if(r)return;const d=this.getLanguagePartFromCode(o);if(this.isSupportedCode(d))return r=d;r=this.options.supportedLngs.find(f=>{if(f===d)return f;if(!(f.indexOf("-")<0&&d.indexOf("-")<0)&&(f.indexOf("-")>0&&d.indexOf("-")<0&&f.substring(0,f.indexOf("-"))===d||f.indexOf(d)===0&&d.length>1))return f})}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(s,r){if(!s)return[];if(typeof s=="function"&&(s=s(r)),pe(s)&&(s=[s]),Array.isArray(s))return s;if(!r)return s.default||[];let o=s[r];return o||(o=s[this.getScriptPartFromCode(r)]),o||(o=s[this.formatLanguageCode(r)]),o||(o=s[this.getLanguagePartFromCode(r)]),o||(o=s.default),o||[]}toResolveHierarchy(s,r){const o=this.getFallbackCodes(r||this.options.fallbackLng||[],s),d=[],f=m=>{m&&(this.isSupportedCode(m)?d.push(m):this.logger.warn(`rejecting language code not found in supportedLngs: ${m}`))};return pe(s)&&(s.indexOf("-")>-1||s.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&f(this.formatLanguageCode(s)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&f(this.getScriptPartFromCode(s)),this.options.load!=="currentOnly"&&f(this.getLanguagePartFromCode(s))):pe(s)&&f(this.formatLanguageCode(s)),o.forEach(m=>{d.indexOf(m)<0&&f(this.formatLanguageCode(m))}),d}}const pm={zero:0,one:1,two:2,few:3,many:4,other:5},ym={select:l=>l===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class h1{constructor(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=s,this.options=r,this.logger=Pt.create("pluralResolver"),this.pluralRulesCache={}}addRule(s,r){this.rules[s]=r}clearCache(){this.pluralRulesCache={}}getRule(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=Yr(s==="dev"?"en":s),d=r.ordinal?"ordinal":"cardinal",f=JSON.stringify({cleanedCode:o,type:d});if(f in this.pluralRulesCache)return this.pluralRulesCache[f];let m;try{m=new Intl.PluralRules(o,{type:d})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ym;if(!s.match(/-|_/))return ym;const h=this.languageUtils.getLanguagePartFromCode(s);m=this.getRule(h,r)}return this.pluralRulesCache[f]=m,m}needsPlural(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.getRule(s,r);return o||(o=this.getRule("dev",r)),(o==null?void 0:o.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(s,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(s,o).map(d=>`${r}${d}`)}getSuffixes(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.getRule(s,r);return o||(o=this.getRule("dev",r)),o?o.resolvedOptions().pluralCategories.sort((d,f)=>pm[d]-pm[f]).map(d=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${d}`):[]}getSuffix(s,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const d=this.getRule(s,o);return d?`${this.options.prepend}${o.ordinal?`ordinal${this.options.prepend}`:""}${d.select(r)}`:(this.logger.warn(`no plural rule found for: ${s}`),this.getSuffix("dev",r,o))}}const xm=function(l,s,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",d=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,f=s1(l,s,r);return!f&&d&&pe(r)&&(f=Tu(l,r,o),f===void 0&&(f=Tu(s,r,o))),f},xu=l=>l.replace(/\$/g,"$$$$");class m1{constructor(){var r;let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Pt.create("interpolator"),this.options=s,this.format=((r=s==null?void 0:s.interpolation)==null?void 0:r.format)||(o=>o),this.init(s)}init(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};s.interpolation||(s.interpolation={escapeValue:!0});const{escape:r,escapeValue:o,useRawValueToEscape:d,prefix:f,prefixEscaped:m,suffix:y,suffixEscaped:h,formatSeparator:g,unescapeSuffix:v,unescapePrefix:w,nestingPrefix:b,nestingPrefixEscaped:R,nestingSuffix:N,nestingSuffixEscaped:C,nestingOptionsSeparator:A,maxReplaces:z,alwaysFormat:T}=s.interpolation;this.escape=r!==void 0?r:i1,this.escapeValue=o!==void 0?o:!0,this.useRawValueToEscape=d!==void 0?d:!1,this.prefix=f?Jn(f):m||"{{",this.suffix=y?Jn(y):h||"}}",this.formatSeparator=g||",",this.unescapePrefix=v?"":w||"-",this.unescapeSuffix=this.unescapePrefix?"":v||"",this.nestingPrefix=b?Jn(b):R||Jn("$t("),this.nestingSuffix=N?Jn(N):C||Jn(")"),this.nestingOptionsSeparator=A||",",this.maxReplaces=z||1e3,this.alwaysFormat=T!==void 0?T:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const s=(r,o)=>(r==null?void 0:r.source)===o?(r.lastIndex=0,r):new RegExp(o,"g");this.regexp=s(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=s(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=s(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(s,r,o,d){var R;let f,m,y;const h=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},g=N=>{if(N.indexOf(this.formatSeparator)<0){const T=xm(r,h,N,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(T,void 0,o,{...d,...r,interpolationkey:N}):T}const C=N.split(this.formatSeparator),A=C.shift().trim(),z=C.join(this.formatSeparator).trim();return this.format(xm(r,h,A,this.options.keySeparator,this.options.ignoreJSONStructure),z,o,{...d,...r,interpolationkey:A})};this.resetRegExp();const v=(d==null?void 0:d.missingInterpolationHandler)||this.options.missingInterpolationHandler,w=((R=d==null?void 0:d.interpolation)==null?void 0:R.skipOnVariables)!==void 0?d.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:N=>xu(N)},{regex:this.regexp,safeValue:N=>this.escapeValue?xu(this.escape(N)):xu(N)}].forEach(N=>{for(y=0;f=N.regex.exec(s);){const C=f[1].trim();if(m=g(C),m===void 0)if(typeof v=="function"){const z=v(s,f,d);m=pe(z)?z:""}else if(d&&Object.prototype.hasOwnProperty.call(d,C))m="";else if(w){m=f[0];continue}else this.logger.warn(`missed to pass in variable ${C} for interpolating ${s}`),m="";else!pe(m)&&!this.useRawValueToEscape&&(m=om(m));const A=N.safeValue(m);if(s=s.replace(f[0],A),w?(N.regex.lastIndex+=m.length,N.regex.lastIndex-=f[0].length):N.regex.lastIndex=0,y++,y>=this.maxReplaces)break}}),s}nest(s,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},d,f,m;const y=(h,g)=>{const v=this.nestingOptionsSeparator;if(h.indexOf(v)<0)return h;const w=h.split(new RegExp(`${v}[ ]*{`));let b=`{${w[1]}`;h=w[0],b=this.interpolate(b,m);const R=b.match(/'/g),N=b.match(/"/g);(((R==null?void 0:R.length)??0)%2===0&&!N||N.length%2!==0)&&(b=b.replace(/'/g,'"'));try{m=JSON.parse(b),g&&(m={...g,...m})}catch(C){return this.logger.warn(`failed parsing options string in nesting for key ${h}`,C),`${h}${v}${b}`}return m.defaultValue&&m.defaultValue.indexOf(this.prefix)>-1&&delete m.defaultValue,h};for(;d=this.nestingRegexp.exec(s);){let h=[];m={...o},m=m.replace&&!pe(m.replace)?m.replace:m,m.applyPostProcessor=!1,delete m.defaultValue;let g=!1;if(d[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(d[1])){const v=d[1].split(this.formatSeparator).map(w=>w.trim());d[1]=v.shift(),h=v,g=!0}if(f=r(y.call(this,d[1].trim(),m),m),f&&d[0]===s&&!pe(f))return f;pe(f)||(f=om(f)),f||(this.logger.warn(`missed to resolve ${d[1]} for nesting ${s}`),f=""),g&&(f=h.reduce((v,w)=>this.format(v,w,o.lng,{...o,interpolationkey:d[1].trim()}),f.trim())),s=s.replace(d[0],f),this.regexp.lastIndex=0}return s}}const g1=l=>{let s=l.toLowerCase().trim();const r={};if(l.indexOf("(")>-1){const o=l.split("(");s=o[0].toLowerCase().trim();const d=o[1].substring(0,o[1].length-1);s==="currency"&&d.indexOf(":")<0?r.currency||(r.currency=d.trim()):s==="relativetime"&&d.indexOf(":")<0?r.range||(r.range=d.trim()):d.split(";").forEach(m=>{if(m){const[y,...h]=m.split(":"),g=h.join(":").trim().replace(/^'+|'+$/g,""),v=y.trim();r[v]||(r[v]=g),g==="false"&&(r[v]=!1),g==="true"&&(r[v]=!0),isNaN(g)||(r[v]=parseInt(g,10))}})}return{formatName:s,formatOptions:r}},Fn=l=>{const s={};return(r,o,d)=>{let f=d;d&&d.interpolationkey&&d.formatParams&&d.formatParams[d.interpolationkey]&&d[d.interpolationkey]&&(f={...f,[d.interpolationkey]:void 0});const m=o+JSON.stringify(f);let y=s[m];return y||(y=l(Yr(o),d),s[m]=y),y(r)}};class p1{constructor(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Pt.create("formatter"),this.options=s,this.formats={number:Fn((r,o)=>{const d=new Intl.NumberFormat(r,{...o});return f=>d.format(f)}),currency:Fn((r,o)=>{const d=new Intl.NumberFormat(r,{...o,style:"currency"});return f=>d.format(f)}),datetime:Fn((r,o)=>{const d=new Intl.DateTimeFormat(r,{...o});return f=>d.format(f)}),relativetime:Fn((r,o)=>{const d=new Intl.RelativeTimeFormat(r,{...o});return f=>d.format(f,o.range||"day")}),list:Fn((r,o)=>{const d=new Intl.ListFormat(r,{...o});return f=>d.format(f)})},this.init(s)}init(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=r.interpolation.formatSeparator||","}add(s,r){this.formats[s.toLowerCase().trim()]=r}addCached(s,r){this.formats[s.toLowerCase().trim()]=Fn(r)}format(s,r,o){let d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const f=r.split(this.formatSeparator);if(f.length>1&&f[0].indexOf("(")>1&&f[0].indexOf(")")<0&&f.find(y=>y.indexOf(")")>-1)){const y=f.findIndex(h=>h.indexOf(")")>-1);f[0]=[f[0],...f.splice(1,y)].join(this.formatSeparator)}return f.reduce((y,h)=>{var w;const{formatName:g,formatOptions:v}=g1(h);if(this.formats[g]){let b=y;try{const R=((w=d==null?void 0:d.formatParams)==null?void 0:w[d.interpolationkey])||{},N=R.locale||R.lng||d.locale||d.lng||o;b=this.formats[g](y,N,{...v,...d,...R})}catch(R){this.logger.warn(R)}return b}else this.logger.warn(`there was no format function for ${g}`);return y},s)}}const y1=(l,s)=>{l.pending[s]!==void 0&&(delete l.pending[s],l.pendingCount--)};class x1 extends Pr{constructor(s,r,o){var f,m;let d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=s,this.store=r,this.services=o,this.languageUtils=o.languageUtils,this.options=d,this.logger=Pt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=d.maxParallelReads||10,this.readingCalls=0,this.maxRetries=d.maxRetries>=0?d.maxRetries:5,this.retryTimeout=d.retryTimeout>=1?d.retryTimeout:350,this.state={},this.queue=[],(m=(f=this.backend)==null?void 0:f.init)==null||m.call(f,o,d.backend,d)}queueLoad(s,r,o,d){const f={},m={},y={},h={};return s.forEach(g=>{let v=!0;r.forEach(w=>{const b=`${g}|${w}`;!o.reload&&this.store.hasResourceBundle(g,w)?this.state[b]=2:this.state[b]<0||(this.state[b]===1?m[b]===void 0&&(m[b]=!0):(this.state[b]=1,v=!1,m[b]===void 0&&(m[b]=!0),f[b]===void 0&&(f[b]=!0),h[w]===void 0&&(h[w]=!0)))}),v||(y[g]=!0)}),(Object.keys(f).length||Object.keys(m).length)&&this.queue.push({pending:m,pendingCount:Object.keys(m).length,loaded:{},errors:[],callback:d}),{toLoad:Object.keys(f),pending:Object.keys(m),toLoadLanguages:Object.keys(y),toLoadNamespaces:Object.keys(h)}}loaded(s,r,o){const d=s.split("|"),f=d[0],m=d[1];r&&this.emit("failedLoading",f,m,r),!r&&o&&this.store.addResourceBundle(f,m,o,void 0,void 0,{skipCopy:!0}),this.state[s]=r?-1:2,r&&o&&(this.state[s]=0);const y={};this.queue.forEach(h=>{l1(h.loaded,[f],m),y1(h,s),r&&h.errors.push(r),h.pendingCount===0&&!h.done&&(Object.keys(h.loaded).forEach(g=>{y[g]||(y[g]={});const v=h.loaded[g];v.length&&v.forEach(w=>{y[g][w]===void 0&&(y[g][w]=!0)})}),h.done=!0,h.errors.length?h.callback(h.errors):h.callback())}),this.emit("loaded",y),this.queue=this.queue.filter(h=>!h.done)}read(s,r,o){let d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,f=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,m=arguments.length>5?arguments[5]:void 0;if(!s.length)return m(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:s,ns:r,fcName:o,tried:d,wait:f,callback:m});return}this.readingCalls++;const y=(g,v)=>{if(this.readingCalls--,this.waitingReads.length>0){const w=this.waitingReads.shift();this.read(w.lng,w.ns,w.fcName,w.tried,w.wait,w.callback)}if(g&&v&&d<this.maxRetries){setTimeout(()=>{this.read.call(this,s,r,o,d+1,f*2,m)},f);return}m(g,v)},h=this.backend[o].bind(this.backend);if(h.length===2){try{const g=h(s,r);g&&typeof g.then=="function"?g.then(v=>y(null,v)).catch(y):y(null,g)}catch(g){y(g)}return}return h(s,r,y)}prepareLoading(s,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},d=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),d&&d();pe(s)&&(s=this.languageUtils.toResolveHierarchy(s)),pe(r)&&(r=[r]);const f=this.queueLoad(s,r,o,d);if(!f.toLoad.length)return f.pending.length||d(),null;f.toLoad.forEach(m=>{this.loadOne(m)})}load(s,r,o){this.prepareLoading(s,r,{},o)}reload(s,r,o){this.prepareLoading(s,r,{reload:!0},o)}loadOne(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const o=s.split("|"),d=o[0],f=o[1];this.read(d,f,"read",void 0,void 0,(m,y)=>{m&&this.logger.warn(`${r}loading namespace ${f} for language ${d} failed`,m),!m&&y&&this.logger.log(`${r}loaded namespace ${f} for language ${d}`,y),this.loaded(s,m,y)})}saveMissing(s,r,o,d,f){var h,g,v,w,b;let m=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},y=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if((g=(h=this.services)==null?void 0:h.utils)!=null&&g.hasLoadedNamespace&&!((w=(v=this.services)==null?void 0:v.utils)!=null&&w.hasLoadedNamespace(r))){this.logger.warn(`did not save key "${o}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if((b=this.backend)!=null&&b.create){const R={...m,isUpdate:f},N=this.backend.create.bind(this.backend);if(N.length<6)try{let C;N.length===5?C=N(s,r,o,d,R):C=N(s,r,o,d),C&&typeof C.then=="function"?C.then(A=>y(null,A)).catch(y):y(null,C)}catch(C){y(C)}else N(s,r,o,d,y,R)}!s||!s[0]||this.store.addResource(s[0],r,o,d)}}}const vm=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:l=>{let s={};if(typeof l[1]=="object"&&(s=l[1]),pe(l[1])&&(s.defaultValue=l[1]),pe(l[2])&&(s.tDescription=l[2]),typeof l[2]=="object"||typeof l[3]=="object"){const r=l[3]||l[2];Object.keys(r).forEach(o=>{s[o]=r[o]})}return s},interpolation:{escapeValue:!0,format:l=>l,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),bm=l=>{var s,r;return pe(l.ns)&&(l.ns=[l.ns]),pe(l.fallbackLng)&&(l.fallbackLng=[l.fallbackLng]),pe(l.fallbackNS)&&(l.fallbackNS=[l.fallbackNS]),((r=(s=l.supportedLngs)==null?void 0:s.indexOf)==null?void 0:r.call(s,"cimode"))<0&&(l.supportedLngs=l.supportedLngs.concat(["cimode"])),typeof l.initImmediate=="boolean"&&(l.initAsync=l.initImmediate),l},Hr=()=>{},v1=l=>{Object.getOwnPropertyNames(Object.getPrototypeOf(l)).forEach(r=>{typeof l[r]=="function"&&(l[r]=l[r].bind(l))})};class fs extends Pr{constructor(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(super(),this.options=bm(s),this.services={},this.logger=Pt,this.modules={external:[]},v1(this),r&&!this.isInitialized&&!s.isClone){if(!this.options.initAsync)return this.init(s,r),this;setTimeout(()=>{this.init(s,r)},0)}}init(){var s=this;let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof r=="function"&&(o=r,r={}),r.defaultNS==null&&r.ns&&(pe(r.ns)?r.defaultNS=r.ns:r.ns.indexOf("translation")<0&&(r.defaultNS=r.ns[0]));const d=vm();this.options={...d,...this.options,...bm(r)},this.options.interpolation={...d.interpolation,...this.options.interpolation},r.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=r.keySeparator),r.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=r.nsSeparator);const f=v=>v?typeof v=="function"?new v:v:null;if(!this.options.isClone){this.modules.logger?Pt.init(f(this.modules.logger),this.options):Pt.init(null,this.options);let v;this.modules.formatter?v=this.modules.formatter:v=p1;const w=new gm(this.options);this.store=new fm(this.options.resources,this.options);const b=this.services;b.logger=Pt,b.resourceStore=this.store,b.languageUtils=w,b.pluralResolver=new h1(w,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),v&&(!this.options.interpolation.format||this.options.interpolation.format===d.interpolation.format)&&(b.formatter=f(v),b.formatter.init(b,this.options),this.options.interpolation.format=b.formatter.format.bind(b.formatter)),b.interpolator=new m1(this.options),b.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},b.backendConnector=new x1(f(this.modules.backend),b.resourceStore,b,this.options),b.backendConnector.on("*",function(R){for(var N=arguments.length,C=new Array(N>1?N-1:0),A=1;A<N;A++)C[A-1]=arguments[A];s.emit(R,...C)}),this.modules.languageDetector&&(b.languageDetector=f(this.modules.languageDetector),b.languageDetector.init&&b.languageDetector.init(b,this.options.detection,this.options)),this.modules.i18nFormat&&(b.i18nFormat=f(this.modules.i18nFormat),b.i18nFormat.init&&b.i18nFormat.init(this)),this.translator=new $r(this.services,this.options),this.translator.on("*",function(R){for(var N=arguments.length,C=new Array(N>1?N-1:0),A=1;A<N;A++)C[A-1]=arguments[A];s.emit(R,...C)}),this.modules.external.forEach(R=>{R.init&&R.init(this)})}if(this.format=this.options.interpolation.format,o||(o=Hr),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const v=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);v.length>0&&v[0]!=="dev"&&(this.options.lng=v[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(v=>{this[v]=function(){return s.store[v](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(v=>{this[v]=function(){return s.store[v](...arguments),s}});const h=os(),g=()=>{const v=(w,b)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),h.resolve(b),o(w,b)};if(this.languages&&!this.isInitialized)return v(null,this.t.bind(this));this.changeLanguage(this.options.lng,v)};return this.options.resources||!this.options.initAsync?g():setTimeout(g,0),h}loadResources(s){var f,m;let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Hr;const d=pe(s)?s:this.language;if(typeof s=="function"&&(o=s),!this.options.resources||this.options.partialBundledLanguages){if((d==null?void 0:d.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return o();const y=[],h=g=>{if(!g||g==="cimode")return;this.services.languageUtils.toResolveHierarchy(g).forEach(w=>{w!=="cimode"&&y.indexOf(w)<0&&y.push(w)})};d?h(d):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(v=>h(v)),(m=(f=this.options.preload)==null?void 0:f.forEach)==null||m.call(f,g=>h(g)),this.services.backendConnector.load(y,this.options.ns,g=>{!g&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),o(g)})}else o(null)}reloadResources(s,r,o){const d=os();return typeof s=="function"&&(o=s,s=void 0),typeof r=="function"&&(o=r,r=void 0),s||(s=this.languages),r||(r=this.options.ns),o||(o=Hr),this.services.backendConnector.reload(s,r,f=>{d.resolve(),o(f)}),d}use(s){if(!s)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!s.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return s.type==="backend"&&(this.modules.backend=s),(s.type==="logger"||s.log&&s.warn&&s.error)&&(this.modules.logger=s),s.type==="languageDetector"&&(this.modules.languageDetector=s),s.type==="i18nFormat"&&(this.modules.i18nFormat=s),s.type==="postProcessor"&&vg.addPostProcessor(s),s.type==="formatter"&&(this.modules.formatter=s),s.type==="3rdParty"&&this.modules.external.push(s),this}setResolvedLanguage(s){if(!(!s||!this.languages)&&!(["cimode","dev"].indexOf(s)>-1))for(let r=0;r<this.languages.length;r++){const o=this.languages[r];if(!(["cimode","dev"].indexOf(o)>-1)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}}changeLanguage(s,r){var o=this;this.isLanguageChangingTo=s;const d=os();this.emit("languageChanging",s);const f=h=>{this.language=h,this.languages=this.services.languageUtils.toResolveHierarchy(h),this.resolvedLanguage=void 0,this.setResolvedLanguage(h)},m=(h,g)=>{g?(f(g),this.translator.changeLanguage(g),this.isLanguageChangingTo=void 0,this.emit("languageChanged",g),this.logger.log("languageChanged",g)):this.isLanguageChangingTo=void 0,d.resolve(function(){return o.t(...arguments)}),r&&r(h,function(){return o.t(...arguments)})},y=h=>{var v,w;!s&&!h&&this.services.languageDetector&&(h=[]);const g=pe(h)?h:this.services.languageUtils.getBestMatchFromCodes(h);g&&(this.language||f(g),this.translator.language||this.translator.changeLanguage(g),(w=(v=this.services.languageDetector)==null?void 0:v.cacheUserLanguage)==null||w.call(v,g)),this.loadResources(g,b=>{m(b,g)})};return!s&&this.services.languageDetector&&!this.services.languageDetector.async?y(this.services.languageDetector.detect()):!s&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(y):this.services.languageDetector.detect(y):y(s),d}getFixedT(s,r,o){var d=this;const f=function(m,y){let h;if(typeof y!="object"){for(var g=arguments.length,v=new Array(g>2?g-2:0),w=2;w<g;w++)v[w-2]=arguments[w];h=d.options.overloadTranslationOptionHandler([m,y].concat(v))}else h={...y};h.lng=h.lng||f.lng,h.lngs=h.lngs||f.lngs,h.ns=h.ns||f.ns,h.keyPrefix!==""&&(h.keyPrefix=h.keyPrefix||o||f.keyPrefix);const b=d.options.keySeparator||".";let R;return h.keyPrefix&&Array.isArray(m)?R=m.map(N=>`${h.keyPrefix}${b}${N}`):R=h.keyPrefix?`${h.keyPrefix}${b}${m}`:m,d.t(R,h)};return pe(s)?f.lng=s:f.lngs=s,f.ns=r,f.keyPrefix=o,f}t(){var d;for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return(d=this.translator)==null?void 0:d.translate(...r)}exists(){var d;for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return(d=this.translator)==null?void 0:d.exists(...r)}setDefaultNamespace(s){this.options.defaultNS=s}hasLoadedNamespace(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const o=r.lng||this.resolvedLanguage||this.languages[0],d=this.options?this.options.fallbackLng:!1,f=this.languages[this.languages.length-1];if(o.toLowerCase()==="cimode")return!0;const m=(y,h)=>{const g=this.services.backendConnector.state[`${y}|${h}`];return g===-1||g===0||g===2};if(r.precheck){const y=r.precheck(this,m);if(y!==void 0)return y}return!!(this.hasResourceBundle(o,s)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||m(o,s)&&(!d||m(f,s)))}loadNamespaces(s,r){const o=os();return this.options.ns?(pe(s)&&(s=[s]),s.forEach(d=>{this.options.ns.indexOf(d)<0&&this.options.ns.push(d)}),this.loadResources(d=>{o.resolve(),r&&r(d)}),o):(r&&r(),Promise.resolve())}loadLanguages(s,r){const o=os();pe(s)&&(s=[s]);const d=this.options.preload||[],f=s.filter(m=>d.indexOf(m)<0&&this.services.languageUtils.isSupportedCode(m));return f.length?(this.options.preload=d.concat(f),this.loadResources(m=>{o.resolve(),r&&r(m)}),o):(r&&r(),Promise.resolve())}dir(s){var d,f;if(s||(s=this.resolvedLanguage||(((d=this.languages)==null?void 0:d.length)>0?this.languages[0]:this.language)),!s)return"rtl";const r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=((f=this.services)==null?void 0:f.languageUtils)||new gm(vm());return r.indexOf(o.getLanguagePartFromCode(s))>-1||s.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return new fs(s,r)}cloneInstance(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Hr;const o=s.forkResourceStore;o&&delete s.forkResourceStore;const d={...this.options,...s,isClone:!0},f=new fs(d);if((s.debug!==void 0||s.prefix!==void 0)&&(f.logger=f.logger.clone(s)),["store","services","language"].forEach(y=>{f[y]=this[y]}),f.services={...this.services},f.services.utils={hasLoadedNamespace:f.hasLoadedNamespace.bind(f)},o){const y=Object.keys(this.store.data).reduce((h,g)=>(h[g]={...this.store.data[g]},Object.keys(h[g]).reduce((v,w)=>(v[w]={...h[g][w]},v),{})),{});f.store=new fm(y,d),f.services.resourceStore=f.store}return f.translator=new $r(f.services,d),f.translator.on("*",function(y){for(var h=arguments.length,g=new Array(h>1?h-1:0),v=1;v<h;v++)g[v-1]=arguments[v];f.emit(y,...g)}),f.init(d,r),f.translator.options=d,f.translator.backendConnector.services.utils={hasLoadedNamespace:f.hasLoadedNamespace.bind(f)},f}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const it=fs.createInstance();it.createInstance=fs.createInstance;it.createInstance;it.dir;it.init;it.loadResources;it.reloadResources;it.use;it.changeLanguage;it.getFixedT;it.t;it.exists;it.setDefaultNamespace;it.hasLoadedNamespace;it.loadNamespaces;it.loadLanguages;const{slice:b1,forEach:S1}=[];function w1(l){return S1.call(b1.call(arguments,1),s=>{if(s)for(const r in s)l[r]===void 0&&(l[r]=s[r])}),l}function N1(l){return typeof l!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(r=>r.test(l))}const Sm=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,j1=function(l,s){const o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},d=encodeURIComponent(s);let f=`${l}=${d}`;if(o.maxAge>0){const m=o.maxAge-0;if(Number.isNaN(m))throw new Error("maxAge should be a Number");f+=`; Max-Age=${Math.floor(m)}`}if(o.domain){if(!Sm.test(o.domain))throw new TypeError("option domain is invalid");f+=`; Domain=${o.domain}`}if(o.path){if(!Sm.test(o.path))throw new TypeError("option path is invalid");f+=`; Path=${o.path}`}if(o.expires){if(typeof o.expires.toUTCString!="function")throw new TypeError("option expires is invalid");f+=`; Expires=${o.expires.toUTCString()}`}if(o.httpOnly&&(f+="; HttpOnly"),o.secure&&(f+="; Secure"),o.sameSite)switch(typeof o.sameSite=="string"?o.sameSite.toLowerCase():o.sameSite){case!0:f+="; SameSite=Strict";break;case"lax":f+="; SameSite=Lax";break;case"strict":f+="; SameSite=Strict";break;case"none":f+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return o.partitioned&&(f+="; Partitioned"),f},wm={create(l,s,r,o){let d=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(d.expires=new Date,d.expires.setTime(d.expires.getTime()+r*60*1e3)),o&&(d.domain=o),document.cookie=j1(l,encodeURIComponent(s),d)},read(l){const s=`${l}=`,r=document.cookie.split(";");for(let o=0;o<r.length;o++){let d=r[o];for(;d.charAt(0)===" ";)d=d.substring(1,d.length);if(d.indexOf(s)===0)return d.substring(s.length,d.length)}return null},remove(l){this.create(l,"",-1)}};var E1={name:"cookie",lookup(l){let{lookupCookie:s}=l;if(s&&typeof document<"u")return wm.read(s)||void 0},cacheUserLanguage(l,s){let{lookupCookie:r,cookieMinutes:o,cookieDomain:d,cookieOptions:f}=s;r&&typeof document<"u"&&wm.create(r,l,o,d,f)}},C1={name:"querystring",lookup(l){var o;let{lookupQuerystring:s}=l,r;if(typeof window<"u"){let{search:d}=window.location;!window.location.search&&((o=window.location.hash)==null?void 0:o.indexOf("?"))>-1&&(d=window.location.hash.substring(window.location.hash.indexOf("?")));const m=d.substring(1).split("&");for(let y=0;y<m.length;y++){const h=m[y].indexOf("=");h>0&&m[y].substring(0,h)===s&&(r=m[y].substring(h+1))}}return r}};let Wn=null;const Nm=()=>{if(Wn!==null)return Wn;try{if(Wn=typeof window<"u"&&window.localStorage!==null,!Wn)return!1;const l="i18next.translate.boo";window.localStorage.setItem(l,"foo"),window.localStorage.removeItem(l)}catch{Wn=!1}return Wn};var k1={name:"localStorage",lookup(l){let{lookupLocalStorage:s}=l;if(s&&Nm())return window.localStorage.getItem(s)||void 0},cacheUserLanguage(l,s){let{lookupLocalStorage:r}=s;r&&Nm()&&window.localStorage.setItem(r,l)}};let In=null;const jm=()=>{if(In!==null)return In;try{if(In=typeof window<"u"&&window.sessionStorage!==null,!In)return!1;const l="i18next.translate.boo";window.sessionStorage.setItem(l,"foo"),window.sessionStorage.removeItem(l)}catch{In=!1}return In};var A1={name:"sessionStorage",lookup(l){let{lookupSessionStorage:s}=l;if(s&&jm())return window.sessionStorage.getItem(s)||void 0},cacheUserLanguage(l,s){let{lookupSessionStorage:r}=s;r&&jm()&&window.sessionStorage.setItem(r,l)}},T1={name:"navigator",lookup(l){const s=[];if(typeof navigator<"u"){const{languages:r,userLanguage:o,language:d}=navigator;if(r)for(let f=0;f<r.length;f++)s.push(r[f]);o&&s.push(o),d&&s.push(d)}return s.length>0?s:void 0}},R1={name:"htmlTag",lookup(l){let{htmlTag:s}=l,r;const o=s||(typeof document<"u"?document.documentElement:null);return o&&typeof o.getAttribute=="function"&&(r=o.getAttribute("lang")),r}},O1={name:"path",lookup(l){var d;let{lookupFromPathIndex:s}=l;if(typeof window>"u")return;const r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(r)?(d=r[typeof s=="number"?s:0])==null?void 0:d.replace("/",""):void 0}},M1={name:"subdomain",lookup(l){var d,f;let{lookupFromSubdomainIndex:s}=l;const r=typeof s=="number"?s+1:1,o=typeof window<"u"&&((f=(d=window.location)==null?void 0:d.hostname)==null?void 0:f.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i));if(o)return o[r]}};let bg=!1;try{document.cookie,bg=!0}catch{}const Sg=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];bg||Sg.splice(1,1);const z1=()=>({order:Sg,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:l=>l});class wg{constructor(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(s,r)}init(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=s,this.options=w1(r,this.options||{},z1()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=d=>d.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=o,this.addDetector(E1),this.addDetector(C1),this.addDetector(k1),this.addDetector(A1),this.addDetector(T1),this.addDetector(R1),this.addDetector(O1),this.addDetector(M1)}addDetector(s){return this.detectors[s.name]=s,this}detect(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,r=[];return s.forEach(o=>{if(this.detectors[o]){let d=this.detectors[o].lookup(this.options);d&&typeof d=="string"&&(d=[d]),d&&(r=r.concat(d))}}),r=r.filter(o=>o!=null&&!N1(o)).map(o=>this.options.convertDetectedLanguage(o)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?r:r.length>0?r[0]:null}cacheUserLanguage(s){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(s)>-1||r.forEach(o=>{this.detectors[o]&&this.detectors[o].cacheUserLanguage(s,this.options)}))}}wg.type="languageDetector";const D1={title:"MCP Hub Dashboard",error:"Error",closeButton:"Close",noServers:"No MCP servers available",loading:"Loading...",logout:"Logout",profile:"Profile",changePassword:"Change Password",toggleSidebar:"Toggle Sidebar",welcomeUser:"Welcome, {{username}}",name:"MCP Hub"},U1={title:"About",versionInfo:"MCP Hub Version: {{version}}",newVersion:"New version available!",currentVersion:"Current version",newVersionAvailable:"New version {{version}} is available",viewOnGitHub:"View on GitHub",checkForUpdates:"Check for Updates",checking:"Checking for updates..."},L1={viewProfile:"View profile",userCenter:"User Center"},_1={label:"Sponsor",title:"Support the Project",rewardAlt:"Reward QR Code",supportMessage:"Support the development of MCP Hub by buying me a coffee!",supportButton:"Support on Ko-fi"},H1={label:"WeChat",title:"Connect via WeChat",qrCodeAlt:"WeChat QR Code",scanMessage:"Scan this QR code to connect with us on WeChat"},B1={label:"Discord",title:"Join our Discord server",community:"Join our growing community on Discord for support, discussions, and updates!"},G1={title:"Theme",light:"Light",dark:"Dark",system:"System"},q1={login:"Login",loginTitle:"Login to MCP Hub",username:"Username",password:"Password",loggingIn:"Logging in...",emptyFields:"Username and password cannot be empty",loginFailed:"Login failed, please check your username and password",loginError:"An error occurred during login",currentPassword:"Current Password",newPassword:"New Password",confirmPassword:"Confirm Password",passwordsNotMatch:"New password and confirmation do not match",changePasswordSuccess:"Password changed successfully",changePasswordError:"Failed to change password",changePassword:"Change Password",passwordChanged:"Password changed successfully",passwordChangeError:"Failed to change password"},V1={addServer:"Add Server",add:"Add",edit:"Edit",delete:"Delete",confirmDelete:"Are you sure you want to delete this server?",deleteWarning:"Deleting server '{{name}}' will remove it and all its data. This action cannot be undone.",status:"Status",tools:"Tools",name:"Server Name",url:"Server URL",apiKey:"API Key",save:"Save",cancel:"Cancel",invalidConfig:"Could not find configuration data for {{serverName}}",addError:"Failed to add server",editError:"Failed to edit server {{serverName}}",deleteError:"Failed to delete server {{serverName}}",updateError:"Failed to update server",editTitle:"Edit Server: {{serverName}}",type:"Server Type",command:"Command",arguments:"Arguments",envVars:"Environment Variables",key:"key",value:"value",enabled:"Enabled",enable:"Enable",disable:"Disable",remove:"Remove",toggleError:"Failed to toggle server {{serverName}}",alreadyExists:"Server {{serverName}} already exists",invalidData:"Invalid server data provided",notFound:"Server {{serverName}} not found",namePlaceholder:"Enter server name",urlPlaceholder:"Enter server URL",commandPlaceholder:"Enter command",argumentsPlaceholder:"Enter arguments",errorDetails:"Error Details",viewErrorDetails:"View error details"},Y1={online:"Online",offline:"Offline",connecting:"Connecting"},K1={general:"Something went wrong",network:"Network connection error. Please check your internet connection",serverConnection:"Unable to connect to the server. Please check if the server is running",serverAdd:"Failed to add server. Please check the server status",serverUpdate:"Failed to edit server {{serverName}}. Please check the server status",serverFetch:"Failed to retrieve server data. Please try again later",initialStartup:"The server might be starting up. Please wait a moment as this process can take some time on first launch...",serverInstall:"Failed to install server",failedToFetchSettings:"Failed to fetch settings",failedToUpdateRouteConfig:"Failed to update route configuration",failedToUpdateSmartRoutingConfig:"Failed to update smart routing configuration"},$1={processing:"Processing...",save:"Save",cancel:"Cancel",refresh:"Refresh",create:"Create",submitting:"Submitting...",delete:"Delete",copy:"Copy",copySuccess:"Copied to clipboard",copyFailed:"Copy failed",close:"Close"},Q1={dashboard:"Dashboard",servers:"Servers",groups:"Groups",settings:"Settings",changePassword:"Change Password",market:"Market",logs:"Logs"},X1={dashboard:{title:"Dashboard",totalServers:"Total",onlineServers:"Online",offlineServers:"Offline",connectingServers:"Connecting",recentServers:"Recent Servers"},servers:{title:"Servers Management"},groups:{title:"Group Management"},settings:{title:"Settings",language:"Language",account:"Account Settings",password:"Change Password",appearance:"Appearance",routeConfig:"Security",installConfig:"Installation",smartRouting:"Smart Routing"},market:{title:"Server Market - (Data from mcpm.sh)"},logs:{title:"System Logs"}},Z1={filters:"Filters",search:"Search logs...",autoScroll:"Auto-scroll",clearLogs:"Clear logs",loading:"Loading logs...",noLogs:"No logs available.",noMatch:"No logs match the current filters.",mainProcess:"Main Process",childProcess:"Child Process",main:"Main",child:"Child"},P1={add:"Add",addNew:"Add New Group",edit:"Edit Group",delete:"Delete",confirmDelete:"Are you sure you want to delete this group?",deleteWarning:"Deleting group '{{name}}' will remove it and all its server associations. This action cannot be undone.",name:"Group Name",namePlaceholder:"Enter group name",nameRequired:"Group name is required",description:"Description",descriptionPlaceholder:"Enter group description (optional)",createError:"Failed to create group",updateError:"Failed to update group",deleteError:"Failed to delete group",serverAddError:"Failed to add server to group",serverRemoveError:"Failed to remove server from group",addServer:"Add Server to Group",selectServer:"Select a server to add",servers:"Servers in Group",remove:"Remove",noGroups:"No groups available. Create a new group to get started.",noServers:"No servers in this group.",noServerOptions:"No servers available",serverCount:"{{count}} Servers"},J1={title:"Server Market",official:"Official",by:"By",unknown:"Unknown",tools:"tools",search:"Search",searchPlaceholder:"Search for servers by name, category, or tags",clearFilters:"Clear",clearCategoryFilter:"",clearTagFilter:"",categories:"Categories",tags:"Tags",showTags:"Show tags",hideTags:"Hide tags",moreTags:"",noServers:"No servers found matching your search",backToList:"Back to list",install:"Install",installing:"Installing...",installed:"Installed",installServer:"Install Server: {{name}}",installSuccess:"Server {{serverName}} installed successfully",author:"Author",license:"License",repository:"Repository",examples:"Examples",arguments:"Arguments",argumentName:"Name",description:"Description",required:"Required",example:"Example",viewSchema:"View schema",fetchError:"Error fetching market servers",serverNotFound:"Server not found",searchError:"Error searching servers",filterError:"Error filtering servers by category",tagFilterError:"Error filtering servers by tag",noInstallationMethod:"No installation method available for this server",showing:"Showing {{from}}-{{to}} of {{total}} servers",perPage:"Per page"},F1={enableGlobalRoute:"Enable Global Route",enableGlobalRouteDescription:"Allow connections to /sse endpoint without specifying a group ID",enableGroupNameRoute:"Enable Group Name Route",enableGroupNameRouteDescription:"Allow connections to /sse endpoint using group names instead of just group IDs",enableBearerAuth:"Enable Bearer Authentication",enableBearerAuthDescription:"Require bearer token authentication for MCP requests",bearerAuthKey:"Bearer Authentication Key",bearerAuthKeyDescription:"The authentication key that will be required in the Bearer token",bearerAuthKeyPlaceholder:"Enter bearer authentication key",pythonIndexUrl:"Python Package Repository URL",pythonIndexUrlDescription:"Set UV_DEFAULT_INDEX environment variable for Python package installation",pythonIndexUrlPlaceholder:"e.g. https://pypi.org/simple",npmRegistry:"NPM Registry URL",npmRegistryDescription:"Set npm_config_registry environment variable for NPM package installation",npmRegistryPlaceholder:"e.g. https://registry.npmjs.org/",installConfig:"Installation",systemConfigUpdated:"System configuration updated successfully",enableSmartRouting:"Enable Smart Routing",enableSmartRoutingDescription:"Enable smart routing feature to search the most suitable tool based on input (using $smart group name)",dbUrl:"PostgreSQL URL (with pgvector support)",dbUrlPlaceholder:"e.g. postgresql://user:password@localhost:5432/dbname",openaiApiBaseUrl:"OpenAI API Base URL",openaiApiBaseUrlPlaceholder:"https://api.openai.com/v1",openaiApiKey:"OpenAI API Key",openaiApiKeyPlaceholder:"Enter OpenAI API key",openaiApiEmbeddingModel:"OpenAI Embedding Model",openaiApiEmbeddingModelPlaceholder:"text-embedding-3-small",smartRoutingConfigUpdated:"Smart routing configuration updated successfully",smartRoutingRequiredFields:"Database URL and OpenAI API Key are required to enable smart routing",smartRoutingValidationError:"Please fill in the required fields before enabling Smart Routing: {{fields}}"},W1={app:D1,about:U1,profile:L1,sponsor:_1,wechat:H1,discord:B1,theme:G1,auth:q1,server:V1,status:Y1,errors:K1,common:$1,nav:Q1,pages:X1,logs:Z1,groups:P1,market:J1,settings:F1},I1={title:"MCP Hub 控制面板",error:"错误",closeButton:"关闭",noServers:"没有可用的 MCP 服务器",loading:"加载中...",logout:"退出登录",profile:"个人资料",changePassword:"修改密码",toggleSidebar:"切换侧边栏",welcomeUser:"欢迎, {{username}}",name:"MCP Hub"},e2={title:"关于",versionInfo:"MCP Hub 版本: {{version}}",newVersion:"有新版本可用!",currentVersion:"当前版本",newVersionAvailable:"新版本 {{version}} 已发布",viewOnGitHub:"在 GitHub 上查看",checkForUpdates:"检查更新",checking:"检查更新中..."},t2={viewProfile:"查看个人中心",userCenter:"个人中心"},a2={label:"赞助",title:"支持项目",rewardAlt:"赞赏码",supportMessage:"通过捐赠支持 MCP Hub 的开发!",supportButton:"在 Ko-fi 上支持"},n2={label:"微信",title:"微信联系",qrCodeAlt:"微信二维码",scanMessage:"扫描二维码添加微信"},l2={label:"Discord",title:"加入我们的 Discord 服务器",community:"加入我们不断壮大的 Discord 社区,获取支持、参与讨论并了解最新动态!"},s2={title:"主题",light:"浅色",dark:"深色",system:"系统"},r2={login:"登录",loginTitle:"登录 MCP Hub",username:"用户名",password:"密码",loggingIn:"登录中...",emptyFields:"用户名和密码不能为空",loginFailed:"登录失败,请检查用户名和密码",loginError:"登录过程中出现错误",currentPassword:"当前密码",newPassword:"新密码",confirmPassword:"确认密码",passwordsNotMatch:"新密码与确认密码不一致",changePasswordSuccess:"密码修改成功",changePasswordError:"修改密码失败",changePassword:"修改密码",passwordChanged:"密码修改成功",passwordChangeError:"修改密码失败"},i2={addServer:"添加服务器",add:"添加",edit:"编辑",delete:"删除",confirmDelete:"您确定要删除此服务器吗?",deleteWarning:"删除服务器 '{{name}}' 将会移除该服务器及其所有数据。此操作无法撤销。",status:"状态",tools:"工具",name:"服务器名称",url:"服务器 URL",apiKey:"API 密钥",save:"保存",cancel:"取消",addError:"添加服务器失败",editError:"编辑服务器 {{serverName}} 失败",invalidConfig:"无法找到 {{serverName}} 的配置数据",deleteError:"删除服务器 {{serverName}} 失败",updateError:"更新服务器失败",editTitle:"编辑服务器: {{serverName}}",type:"服务器类型",command:"命令",arguments:"参数",envVars:"环境变量",key:"键",value:"值",enabled:"已启用",enable:"启用",disable:"禁用",remove:"移除",toggleError:"切换服务器 {{serverName}} 状态失败",alreadyExists:"服务器 {{serverName}} 已经存在",invalidData:"提供的服务器数据无效",notFound:"找不到服务器 {{serverName}}",namePlaceholder:"请输入服务器名称",urlPlaceholder:"请输入服务器URL",commandPlaceholder:"请输入命令",argumentsPlaceholder:"请输入参数",errorDetails:"错误详情",viewErrorDetails:"查看错误详情"},o2={online:"在线",offline:"离线",connecting:"连接中"},u2={general:"发生错误",network:"网络连接错误,请检查您的互联网连接",serverConnection:"无法连接到服务器,请检查服务器是否正在运行",serverAdd:"添加服务器失败,请检查服务器状态",serverUpdate:"编辑服务器 {{serverName}} 失败,请检查服务器状态",serverFetch:"获取服务器数据失败,请稍后重试",initialStartup:"服务器可能正在启动中。首次启动可能需要一些时间,请耐心等候...",serverInstall:"安装服务器失败",failedToFetchSettings:"获取设置失败",failedToUpdateSystemConfig:"更新系统配置失败",failedToUpdateRouteConfig:"更新路由配置失败",failedToUpdateSmartRoutingConfig:"更新智能路由配置失败"},c2={processing:"处理中...",save:"保存",cancel:"取消",refresh:"刷新",create:"创建",submitting:"提交中...",delete:"删除",copy:"复制",copySuccess:"已复制到剪贴板",copyFailed:"复制失败",close:"关闭"},d2={dashboard:"仪表盘",servers:"服务器",settings:"设置",changePassword:"修改密码",groups:"分组",market:"市场",logs:"日志"},f2={dashboard:{title:"仪表盘",totalServers:"总数",onlineServers:"在线",offlineServers:"离线",connectingServers:"连接中",recentServers:"最近的服务器"},servers:{title:"服务器管理"},settings:{title:"设置",language:"语言",account:"账户设置",password:"修改密码",appearance:"外观",routeConfig:"安全配置",installConfig:"安装",smartRouting:"智能路由"},groups:{title:"分组管理"},market:{title:"服务器市场 - (数据来源于 mcpm.sh)"},logs:{title:"系统日志"}},h2={filters:"筛选",search:"搜索日志...",autoScroll:"自动滚动",clearLogs:"清除日志",loading:"加载日志中...",noLogs:"暂无日志。",noMatch:"没有匹配当前筛选条件的日志。",mainProcess:"主进程",childProcess:"子进程",main:"主",child:"子"},m2={add:"添加",addNew:"添加新分组",edit:"编辑分组",delete:"删除",confirmDelete:"您确定要删除此分组吗?",deleteWarning:"删除分组 '{{name}}' 将会移除该分组及其所有服务器关联。此操作无法撤销。",name:"分组名称",namePlaceholder:"请输入分组名称",nameRequired:"分组名称不能为空",description:"描述",descriptionPlaceholder:"请输入分组描述(可选)",createError:"创建分组失败",updateError:"更新分组失败",deleteError:"删除分组失败",serverAddError:"向分组添加服务器失败",serverRemoveError:"从分组移除服务器失败",addServer:"添加服务器到分组",selectServer:"选择要添加的服务器",servers:"分组中的服务器",remove:"移除",noGroups:"暂无可用分组。创建一个新分组以开始使用。",noServers:"此分组中没有服务器。",noServerOptions:"没有可用的服务器",serverCount:"{{count}} 台服务器"},g2={title:"服务器市场",official:"官方",by:"作者",unknown:"未知",tools:"工具",search:"搜索",searchPlaceholder:"搜索服务器名称、分类或标签",clearFilters:"清除",clearCategoryFilter:"",clearTagFilter:"",categories:"分类",tags:"标签",showTags:"显示标签",hideTags:"隐藏标签",moreTags:"",noServers:"未找到匹配的服务器",backToList:"返回列表",install:"安装",installing:"安装中...",installed:"已安装",installServer:"安装服务器: {{name}}",installSuccess:"服务器 {{serverName}} 安装成功",author:"作者",license:"许可证",repository:"代码仓库",examples:"示例",arguments:"参数",argumentName:"名称",description:"描述",required:"必填",example:"示例",viewSchema:"查看结构",fetchError:"获取服务器市场数据失败",serverNotFound:"未找到服务器",searchError:"搜索服务器失败",filterError:"按分类筛选服务器失败",tagFilterError:"按标签筛选服务器失败",noInstallationMethod:"该服务器没有可用的安装方法",showing:"显示 {{from}}-{{to}}/{{total}} 个服务器",perPage:"每页显示"},p2={enableGlobalRoute:"启用全局路由",enableGlobalRouteDescription:"允许不指定组 ID 就连接到 /sse 端点",enableGroupNameRoute:"启用组名路由",enableGroupNameRouteDescription:"允许使用组名而不仅仅是组 ID 连接到 /sse 端点",enableBearerAuth:"启用 Bearer 认证",enableBearerAuthDescription:"对 MCP 请求启用 Bearer 令牌认证",bearerAuthKey:"Bearer 认证密钥",bearerAuthKeyDescription:"Bearer 令牌中需要携带的认证密钥",bearerAuthKeyPlaceholder:"请输入 Bearer 认证密钥",pythonIndexUrl:"Python 包仓库地址",pythonIndexUrlDescription:"设置 UV_DEFAULT_INDEX 环境变量,用于 Python 包安装",pythonIndexUrlPlaceholder:"例如: https://mirrors.aliyun.com/pypi/simple",npmRegistry:"NPM 仓库地址",npmRegistryDescription:"设置 npm_config_registry 环境变量,用于 NPM 包安装",npmRegistryPlaceholder:"例如: https://registry.npmmirror.com/",installConfig:"安装配置",systemConfigUpdated:"系统配置更新成功",enableSmartRouting:"启用智能路由",enableSmartRoutingDescription:"开启智能路由功能,根据输入自动搜索最合适的工具(使用 $smart 分组)",dbUrl:"PostgreSQL 连接地址(支持 pgvector)",dbUrlPlaceholder:"例如: postgresql://user:password@localhost:5432/dbname",openaiApiBaseUrl:"OpenAI API 基础地址",openaiApiBaseUrlPlaceholder:"https://api.openai.com/v1",openaiApiKey:"OpenAI API 密钥",openaiApiKeyDescription:"用于访问 OpenAI API 的密钥",openaiApiKeyPlaceholder:"请输入 OpenAI API 密钥",openaiApiEmbeddingModel:"OpenAI 嵌入模型",openaiApiEmbeddingModelPlaceholder:"text-embedding-3-small",smartRoutingConfigUpdated:"智能路由配置更新成功",smartRoutingRequiredFields:"启用智能路由需要填写数据库连接地址和 OpenAI API 密钥",smartRoutingValidationError:"启用智能路由前请先填写必要字段:{{fields}}"},y2={app:I1,about:e2,profile:t2,sponsor:a2,wechat:n2,discord:l2,theme:s2,auth:r2,server:i2,status:o2,errors:u2,common:c2,nav:d2,pages:f2,logs:h2,groups:m2,market:g2,settings:p2};it.use(wg).use(ib).init({resources:{en:{translation:W1},zh:{translation:y2}},fallbackLng:"en",debug:!1,defaultNS:"translation",interpolation:{escapeValue:!1},detection:{order:["localStorage","cookie","htmlTag","navigator"],caches:["localStorage","cookie"]}});async function x2(){try{console.log("Loading runtime configuration...");const l=await Tx();console.log("Runtime configuration loaded:",l),window.__MCPHUB_CONFIG__=l,Qh.createRoot(document.getElementById("root")).render(c.jsx(vu.StrictMode,{children:c.jsx(im,{})}))}catch(l){console.error("Failed to initialize app:",l),console.log("Starting app with default configuration..."),window.__MCPHUB_CONFIG__={basePath:"",version:"dev",name:"mcphub"},Qh.createRoot(document.getElementById("root")).render(c.jsx(vu.StrictMode,{children:c.jsx(im,{})}))}}x2();
148
+ //# sourceMappingURL=index-CO9hZSAL.js.map