(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,324216,e=>{"use strict";var t=e.i(738776),s=e.i(465458),a=e.i(799773),r=e.i(951841),l=e.i(523592);let o={sm:"size-8 [&>svg]:size-3",md:"size-10 [&>svg]:size-4",lg:"size-12 [&>svg]:size-5"};e.s(["UserIcon",0,function({size:e="lg",className:c}){let n=(0,r.useUserAvatar)(),i=(0,l.resolveServerAssetUrl)(n);return(0,t.jsx)("div",{className:(0,s.cn)("rounded-full overflow-hidden border border-input flex items-center justify-center shrink-0",o[e],i?"":"bg-muted",c),children:i?(0,t.jsx)("img",{src:i,alt:"User",className:"size-full object-cover"}):(0,t.jsx)(a.User,{className:"text-muted-foreground"})})}])},974915,e=>{"use strict";var t=e.i(816709);let s="keyboard-shortcuts",a=[{id:"commandPalette",defaultKeys:"ctrl+shift+p",labelKey:"openCommandPalette"},{id:"toggleSidebar",defaultKeys:"shift+tab",labelKey:"toggleSidebar"}],r=(0,t.create)((e,t)=>({shortcuts:function(){try{return JSON.parse(localStorage.getItem(s)||"{}")}catch{return{}}}(),getShortcut:e=>{let s=a.find(t=>t.id===e);return t().shortcuts[e]??s?.defaultKeys??""},setShortcut:(t,a)=>{e(e=>{let r={...e.shortcuts,[t]:a};return localStorage.setItem(s,JSON.stringify(r)),{shortcuts:r}})},resetShortcut:t=>{e(e=>{let a={...e.shortcuts};return delete a[t],localStorage.setItem(s,JSON.stringify(a)),{shortcuts:a}})},matchesEvent:(e,s)=>{let a=t().getShortcut(e);if(!a)return!1;let r=a.toLowerCase().split("+").map(e=>e.trim()),l=r.includes("ctrl"),o=r.includes("shift"),c=r.includes("alt"),n=r.includes("meta")||r.includes("cmd"),i=r[r.length-1];return s.ctrlKey===l&&s.shiftKey===o&&s.altKey===c&&s.metaKey===n&&s.key.toLowerCase()===i}}));e.s(["SHORTCUT_DEFS",0,a,"useKeyboardShortcuts",0,r])},890687,e=>{"use strict";let t="theme-style",s="theme-style-custom-css",a="theme-style-override",r="theme-style-google-fonts",l="theme-style-google-fonts-preconnect",o="theme-style-google-fonts-static-preconnect",c=["sans","serif","mono","app","heading","mid"],n=["sans","serif","mono","heading","mid"],i=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","emoji","math","fangsong"]),d=new Set(["-apple-system","arial","blinkmacsystemfont","cambria","consolas","courier new","georgia","helvetica","helvetica neue","menlo","segoe ui","sf mono","sfmono-regular","times","times new roman"]),u={mira:`:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --chart-1: oklch(0.87 0 0);
  --chart-2: oklch(0.556 0 0);
  --chart-3: oklch(0.439 0 0);
  --chart-4: oklch(0.371 0 0);
  --chart-5: oklch(0.269 0 0);
  --radius: 0.625rem;
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary: oklch(0.205 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.97 0 0);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-ring: oklch(0.708 0 0);
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --chart-1: oklch(0.87 0 0);
  --chart-2: oklch(0.556 0 0);
  --chart-3: oklch(0.439 0 0);
  --chart-4: oklch(0.371 0 0);
  --chart-5: oklch(0.269 0 0);
  --sidebar: oklch(0.205 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.488 0.243 264.376);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.269 0 0);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-ring: oklch(0.556 0 0);
}`,lyra:`:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --chart-1: oklch(0.87 0 0);
  --chart-2: oklch(0.556 0 0);
  --chart-3: oklch(0.439 0 0);
  --chart-4: oklch(0.371 0 0);
  --chart-5: oklch(0.269 0 0);
  --radius: 0;
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary: oklch(0.205 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.97 0 0);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-ring: oklch(0.708 0 0);
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --chart-1: oklch(0.87 0 0);
  --chart-2: oklch(0.556 0 0);
  --chart-3: oklch(0.439 0 0);
  --chart-4: oklch(0.371 0 0);
  --chart-5: oklch(0.269 0 0);
  --sidebar: oklch(0.205 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.488 0.243 264.376);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.269 0 0);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-ring: oklch(0.556 0 0);
}`,luma:`:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.147 0.004 49.3);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.147 0.004 49.3);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.147 0.004 49.3);
  --primary: oklch(0.505 0.213 27.518);
  --primary-foreground: oklch(0.971 0.013 17.38);
  --secondary: oklch(0.967 0.001 286.375);
  --secondary-foreground: oklch(0.21 0.006 285.885);
  --muted: oklch(0.96 0.002 17.2);
  --muted-foreground: oklch(0.547 0.021 43.1);
  --accent: oklch(0.96 0.002 17.2);
  --accent-foreground: oklch(0.214 0.009 43.1);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0.005 34.3);
  --input: oklch(0.922 0.005 34.3);
  --ring: oklch(0.714 0.014 41.2);
  --chart-1: oklch(0.868 0.007 39.5);
  --chart-2: oklch(0.547 0.021 43.1);
  --chart-3: oklch(0.438 0.017 39.3);
  --chart-4: oklch(0.367 0.016 35.7);
  --chart-5: oklch(0.268 0.011 36.5);
  --radius: 0.875rem;
  --sidebar: oklch(0.986 0.002 67.8);
  --sidebar-foreground: oklch(0.147 0.004 49.3);
  --sidebar-primary: oklch(0.577 0.245 27.325);
  --sidebar-primary-foreground: oklch(0.971 0.013 17.38);
  --sidebar-accent: oklch(0.96 0.002 17.2);
  --sidebar-accent-foreground: oklch(0.214 0.009 43.1);
  --sidebar-border: oklch(0.922 0.005 34.3);
  --sidebar-ring: oklch(0.714 0.014 41.2);
}

.dark {
  --background: oklch(0.147 0.004 49.3);
  --foreground: oklch(0.986 0.002 67.8);
  --card: oklch(0.214 0.009 43.1);
  --card-foreground: oklch(0.986 0.002 67.8);
  --popover: oklch(0.214 0.009 43.1);
  --popover-foreground: oklch(0.986 0.002 67.8);
  --primary: oklch(0.444 0.177 26.899);
  --primary-foreground: oklch(0.971 0.013 17.38);
  --secondary: oklch(0.274 0.006 286.033);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.268 0.011 36.5);
  --muted-foreground: oklch(0.714 0.014 41.2);
  --accent: oklch(0.268 0.011 36.5);
  --accent-foreground: oklch(0.986 0.002 67.8);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.547 0.021 43.1);
  --chart-1: oklch(0.868 0.007 39.5);
  --chart-2: oklch(0.547 0.021 43.1);
  --chart-3: oklch(0.438 0.017 39.3);
  --chart-4: oklch(0.367 0.016 35.7);
  --chart-5: oklch(0.268 0.011 36.5);
  --sidebar: oklch(0.214 0.009 43.1);
  --sidebar-foreground: oklch(0.986 0.002 67.8);
  --sidebar-primary: oklch(0.637 0.237 25.331);
  --sidebar-primary-foreground: oklch(0.971 0.013 17.38);
  --sidebar-accent: oklch(0.268 0.011 36.5);
  --sidebar-accent-foreground: oklch(0.986 0.002 67.8);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-ring: oklch(0.547 0.021 43.1);
}`,rhea:`:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --chart-1: oklch(0.87 0 0);
  --chart-2: oklch(0.556 0 0);
  --chart-3: oklch(0.439 0 0);
  --chart-4: oklch(0.371 0 0);
  --chart-5: oklch(0.269 0 0);
  --radius: 0.625rem;
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary: oklch(0.205 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.97 0 0);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-ring: oklch(0.708 0 0);
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --chart-1: oklch(0.87 0 0);
  --chart-2: oklch(0.556 0 0);
  --chart-3: oklch(0.439 0 0);
  --chart-4: oklch(0.371 0 0);
  --chart-5: oklch(0.269 0 0);
  --sidebar: oklch(0.205 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.488 0.243 264.376);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.269 0 0);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-ring: oklch(0.556 0 0);
}`};function m(e){let t=e.trim().replace(/^["']|["']$/g,"");if(!t||t.startsWith("var("))return"";let s=t.toLowerCase();return i.has(s)||d.has(s)?"":t}function h(){document.getElementById(r)?.remove(),document.getElementById(l)?.remove(),document.getElementById(o)?.remove()}function x(e){!function(e){let t=function(e){if(0===e.length)return"";let t=e.sort((e,t)=>e.localeCompare(t)).map(e=>`family=${encodeURIComponent(e).replace(/%20/g,"+")}`).join("&");return`https://fonts.googleapis.com/css2?${t}&display=swap`}(function(e){let t=new Set,s=RegExp(`--font-(${c.join("|")})\\s*:\\s*([^;]+);`,"g");for(let a of e.matchAll(s)){let e=(function(e){let t=[],s="",a=null,r=0;for(let l of e){if(a){l===a&&(a=null),s+=l;continue}if('"'===l||"'"===l){a=l,s+=l;continue}if("("===l&&(r+=1),")"===l&&(r=Math.max(0,r-1)),","===l&&0===r){t.push(s.trim()),s="";continue}s+=l}return s.trim()&&t.push(s.trim()),t})(a[2]).map(m).find(Boolean);e&&t.add(e)}return[...t]}(e)),s=document.getElementById(r);if(!t)return h();if(!document.getElementById(l)){let e=document.createElement("link");e.id=l,e.rel="preconnect",e.href="https://fonts.googleapis.com",document.head.appendChild(e)}if(!document.getElementById(o)){let e=document.createElement("link");e.id=o,e.rel="preconnect",e.href="https://fonts.gstatic.com",e.crossOrigin="anonymous",document.head.appendChild(e)}if(s){s.href!==t&&(s.href=t);return}let a=document.createElement("link");a.id=r,a.rel="stylesheet",a.href=t,document.head.appendChild(a)}(e);let t=function(e){let t=new Map,s=RegExp(`--font-(${n.join("|")})\\s*:\\s*([^;]+);`,"g");for(let a of e.matchAll(s)){let e=a[2].trim();e.startsWith("var(")||t.has(a[1])||t.set(a[1],e)}return t}(e),s=document.documentElement;for(let e of n){let a=t.get(e);a?s.style.setProperty(`--app-font-${e}`,a):s.style.removeProperty(`--app-font-${e}`)}let i=document.getElementById(a);i||((i=document.createElement("style")).id=a,document.head.appendChild(i)),i.textContent=e}let p="theme-primary-color",g="theme-primary-override";function f(e){let t=e.replace("#","").match(/.{2}/g);return t?{r:parseInt(t[0],16),g:parseInt(t[1],16),b:parseInt(t[2],16)}:null}function k(e){let t,s=(t=f(e))&&(.299*t.r+.587*t.g+.114*t.b)/255>.55?"#000000":"#ffffff",a=function(e){let t=f(e);if(!t)return e;let s=Math.max(0,Math.round(.85*t.r)),a=Math.max(0,Math.round(.85*t.g)),r=Math.max(0,Math.round(.85*t.b));return`#${s.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}(e),r=`:root {
  --primary: ${e};
  --primary-foreground: ${s};
  --ring: ${e};
  --sidebar-primary: ${e};
  --sidebar-primary-foreground: ${s};
  --sidebar-ring: ${e};
  --chart-1: ${e};
}
.dark {
  --primary: ${e};
  --primary-foreground: ${s};
  --ring: ${e};
  --sidebar-primary: ${e};
  --sidebar-primary-foreground: ${s};
  --sidebar-ring: ${e};
  --chart-1: ${e};
}
/* primary button hover */
button.btn-primary-hover:hover, [data-primary-hover]:hover {
  background: ${a} !important;
}`,l=document.getElementById(g);l||((l=document.createElement("style")).id=g,document.head.appendChild(l)),l.textContent=r}e.s(["DEFAULT_PRIMARY_COLORS",0,["#1456f0","#6366f1","#8b5cf6","#ec4899","#ef4444","#f97316","#eab308","#22c55e","#06b6d4"],"PRIMARY_COLOR_KEY",0,p,"THEME_STYLES",0,u,"THEME_STYLE_CUSTOM_CSS_KEY",0,s,"THEME_STYLE_STORAGE_KEY",0,t,"applyPrimaryColor",0,k,"applySavedPrimaryColor",0,function(){let e=localStorage.getItem(p);e&&k(e)},"applySavedThemeStyle",0,function(){let e=localStorage.getItem(t);if(e)if("custom"===e){let e=localStorage.getItem(s);e&&x(e)}else{let t=u[e];t&&x(t)}},"applyThemeStyle",0,x,"getDefaultPrimaryColor",0,function(){return"#1456f0"},"removePrimaryColor",0,function(){document.getElementById(g)?.remove()},"removeThemeStyle",0,function(){document.getElementById(a)?.remove(),h();let e=document.documentElement;for(let t of n)e.style.removeProperty(`--app-font-${t}`)}])},758960,767848,710858,e=>{"use strict";var t=e.i(310361);e.s(["Shield",()=>t.default],758960);var s=e.i(738776),a=e.i(482560),r=e.i(106486),l=e.i(194157),o=e.i(465458),c=e.i(953700),n=e.i(260218),i=e.i(788010),d=e.i(188815),u=e.i(566531),m=e.i(890687),h=e.i(939133),x=e.i(209988),p=e.i(681622),g=e.i(812057),f=e.i(460578),k=e.i(62669),b=e.i(882469),j=e.i(129981),y=e.i(360112);function v({open:e,onOpenChange:t,onFontAdded:l}){let o=(0,r.useTranslations)("settings"),[c,i]=(0,a.useState)(!1),[d,m]=(0,a.useState)(""),[h,N]=(0,a.useState)([]),w=(0,a.useCallback)(()=>{m(""),N([]),i(!1)},[]),S=(0,a.useCallback)(e=>{e||w(),t(e)},[t,w]),C=async()=>{if(0!==h.length){i(!0);try{let e=h[0].file,t=await new Promise((t,s)=>{let a=new FileReader;a.onload=()=>{let e=a.result;t(e.split(",")[1]||e)},a.onerror=s,a.readAsDataURL(e)}),s=await u.sdk.font.uploadByName(e.name,t);y.toast.success(o("fontAdded")),l(s.url,s.name),S(!1)}catch{y.toast.error(o("fontAddFailed"))}finally{i(!1)}}},I=async()=>{if(d.trim()){i(!0);try{let e=d.trim(),t=e.split("/").pop()||"custom-font";y.toast.success(o("fontAdded")),l(e,t),S(!1)}catch{y.toast.error(o("fontAddFailed"))}finally{i(!1)}}};return(0,s.jsx)(x.Dialog,{open:e,onOpenChange:S,children:(0,s.jsxs)(x.DialogContent,{className:"sm:max-w-[480px]",children:[(0,s.jsxs)(x.DialogHeader,{children:[(0,s.jsx)(x.DialogTitle,{children:o("addCustomFont")}),(0,s.jsx)(x.DialogDescription,{children:o("addCustomFontDesc")})]}),(0,s.jsxs)(g.Tabs,{defaultValue:"upload",className:"w-full flex flex-col gap-3",children:[(0,s.jsxs)(g.TabsList,{className:"w-full grid grid-cols-2",children:[(0,s.jsxs)(g.TabsTrigger,{value:"upload",className:"gap-1 text-xs",children:[(0,s.jsx)(j.Upload,{className:"size-3"}),o("fontUpload")]}),(0,s.jsxs)(g.TabsTrigger,{value:"url",className:"gap-1 text-xs",children:[(0,s.jsx)(b.Globe,{className:"size-3"}),o("fontOnlineUrl")]})]}),(0,s.jsxs)(g.TabsContent,{value:"upload",className:"space-y-3 pt-2",children:[(0,s.jsx)(f.FileUpload,{value:h,onChange:N,accept:{"font/*":[".ttf",".otf",".woff",".woff2"]},maxFiles:1,placeholder:o("fontUploadPlaceholder")}),(0,s.jsx)(n.Button,{className:"w-full",onClick:C,disabled:0===h.length||c,children:c?(0,s.jsx)(k.Loader2,{className:"size-4 animate-spin"}):o("fontUpload")})]}),(0,s.jsxs)(g.TabsContent,{value:"url",className:"space-y-3 pt-2",children:[(0,s.jsx)(p.Input,{placeholder:"https://fonts.gstatic.com/s/...",value:d,onChange:e=>m(e.target.value),onKeyDown:e=>"Enter"===e.key&&I()}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:o("fontUrlHint")}),(0,s.jsx)(n.Button,{className:"w-full",onClick:I,disabled:!d.trim()||c,children:c?(0,s.jsx)(k.Loader2,{className:"size-4 animate-spin"}):o("fontOnlineUrl")})]})]})]})})}let N=[{value:"",label:"Default"},{value:"DM Sans",label:"DM Sans"},{value:"Inter",label:"Inter"},{value:"Roboto",label:"Roboto"},{value:"system-ui",label:"System UI"},{value:"Arial",label:"Arial"},{value:"Helvetica",label:"Helvetica"},{value:"Georgia",label:"Georgia"},{value:"Times New Roman",label:"Times New Roman"},{value:"Courier New",label:"Courier New"},{value:"Menlo",label:"Menlo"},{value:"monospace",label:"Monospace"}],w="customFont",S="customFonts",C=["--font-app","--font-sans","--font-heading","--font-mid","--font-mono","--app-font-sans","--app-font-serif","--app-font-heading","--app-font-mid","--app-font-mono"];function I(e,t){let s=document.documentElement;if(s.dataset.customFont=e?"true":"false",!e){for(let e of C)s.style.removeProperty(e);return}let a=N.find(t=>t.value===e)?e:t.find(t=>t.name===e)?`"${E(e)}"`:e;for(let e of C)s.style.setProperty(e,a)}function E(e){return e.replace(/\.\w+$/,"")}function T(e,t){let s=`font-${e.replace(/[^a-zA-Z0-9]/g,"-")}`;if(document.getElementById(s))return;let a=E(e),r=document.createElement("style");r.id=s,r.textContent=`@font-face { font-family: "${a}"; src: url("${t}"); }`,document.head.appendChild(r)}let z={light:(0,s.jsxs)("svg",{"aria-hidden":!0,className:"size-full",fill:"none",viewBox:"0 0 88 70",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("path",{className:"fill-neutral-200",d:"M0 0h88v70H0z"}),(0,s.jsx)("path",{className:"fill-white shadow-sm",d:"M10 12a4 4 0 0 1 4-4h74v62H10V12Z"}),(0,s.jsx)("circle",{className:"fill-neutral-300",cx:"28",cy:"26",r:"8"}),(0,s.jsx)("rect",{className:"fill-neutral-200",height:"4",rx:"2",width:"58",x:"20",y:"42"}),(0,s.jsx)("rect",{className:"fill-neutral-200",height:"4",rx:"2",width:"58",x:"20",y:"49"}),(0,s.jsx)("rect",{className:"fill-neutral-200",height:"4",rx:"2",width:"29",x:"20",y:"56"})]}),dark:(0,s.jsxs)("svg",{"aria-hidden":!0,className:"size-full",fill:"none",viewBox:"0 0 88 70",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("path",{className:"fill-neutral-900",d:"M0 0h88v70H0z"}),(0,s.jsx)("path",{className:"fill-neutral-800 shadow-sm",d:"M10 12a4 4 0 0 1 4-4h74v62H10V12Z"}),(0,s.jsx)("circle",{className:"fill-neutral-600",cx:"28",cy:"26",r:"8"}),(0,s.jsx)("rect",{className:"fill-neutral-700",height:"4",rx:"2",width:"58",x:"20",y:"42"}),(0,s.jsx)("rect",{className:"fill-neutral-700",height:"4",rx:"2",width:"58",x:"20",y:"49"}),(0,s.jsx)("rect",{className:"fill-neutral-700",height:"4",rx:"2",width:"29",x:"20",y:"56"})]}),system:(0,s.jsxs)("svg",{"aria-hidden":!0,className:"size-full",fill:"none",viewBox:"0 0 88 70",xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)("path",{className:"fill-neutral-200",d:"M0 0h44v70H0z"}),(0,s.jsx)("path",{className:"fill-neutral-900",d:"M44 0h44v70H44z"}),(0,s.jsx)("path",{className:"fill-white shadow-sm",d:"M10 12a4 4 0 0 1 4-4h30v62H10V12Z"}),(0,s.jsx)("circle",{className:"fill-neutral-300",cx:"28",cy:"26",r:"8"}),(0,s.jsx)("path",{className:"fill-neutral-200",d:"M20 44a2 2 0 0 1 2-2h22v4H22a2 2 0 0 1-2-2ZM20 51a2 2 0 0 1 2-2h22v4H22a2 2 0 0 1-2-2ZM20 58a2 2 0 0 1 2-2h22v4H22a2 2 0 0 1-2-2Z"}),(0,s.jsx)("path",{className:"fill-neutral-800 shadow-sm",d:"M54 12a4 4 0 0 1 4-4h30v62H54V12Z"}),(0,s.jsx)("circle",{className:"fill-neutral-600",cx:"72",cy:"26",r:"8"}),(0,s.jsx)("path",{className:"fill-neutral-700",d:"M64 44a2 2 0 0 1 2-2h22v4H66a2 2 0 0 1-2-2ZM64 51a2 2 0 0 1 2-2h22v4H66a2 2 0 0 1-2-2ZM64 58a2 2 0 0 1 2-2h22v4H66a2 2 0 0 1-2-2Z"})]})};e.s(["AppearanceTab",0,function(){let{theme:e,setTheme:t}=(0,l.useTheme)(),x=(0,r.useTranslations)("settings"),[p,g]=(0,a.useState)(()=>localStorage.getItem(w)||""),[f,k]=(0,a.useState)(()=>{try{return JSON.parse(localStorage.getItem(S)||"[]")}catch{return[]}}),[b,j]=(0,a.useState)(!1),[y,C]=(0,a.useState)(()=>localStorage.getItem(m.THEME_STYLE_STORAGE_KEY)||""),[E,D]=(0,a.useState)(()=>localStorage.getItem(m.PRIMARY_COLOR_KEY)||(0,m.getDefaultPrimaryColor)()),[A,B]=(0,a.useState)(()=>localStorage.getItem(m.THEME_STYLE_CUSTOM_CSS_KEY)||""),L=[{value:"light",label:x("themeLight")},{value:"dark",label:x("themeDark")},{value:"system",label:x("themeSystem")}];(0,a.useEffect)(()=>{for(let e of f)T(e.name,e.url);I(p,f)},[f,p]),(0,a.useEffect)(()=>{if(y)if("custom"===y)A&&(0,m.applyThemeStyle)(A);else{let e=m.THEME_STYLES[y];e&&(0,m.applyThemeStyle)(e)}},[]);let M=(0,a.useCallback)(e=>{if(C(e),localStorage.setItem(m.THEME_STYLE_STORAGE_KEY,e),"custom"===e)A&&(0,m.applyThemeStyle)(A);else if(""===e)(0,m.removeThemeStyle)();else{let t=m.THEME_STYLES[e];t&&(0,m.applyThemeStyle)(t)}},[A]),R=(0,a.useCallback)(e=>{B(e),localStorage.setItem(m.THEME_STYLE_CUSTOM_CSS_KEY,e),(0,m.applyThemeStyle)(e)},[]),U=(0,a.useCallback)(e=>{D(e),e?(localStorage.setItem(m.PRIMARY_COLOR_KEY,e),(0,m.applyPrimaryColor)(e)):(localStorage.removeItem(m.PRIMARY_COLOR_KEY),(0,m.removePrimaryColor)())},[]),P=(0,a.useCallback)(e=>{g(e),localStorage.setItem(w,e),I(e,f)},[f]),_=(0,a.useCallback)(async(e,t)=>{let s=[...f,{name:t,url:e}];k(s),localStorage.setItem(S,JSON.stringify(s)),T(t,e),g(t),localStorage.setItem(w,t),setTimeout(()=>I(t,s),100)},[f]);(0,a.useEffect)(()=>{u.sdk.font.list().then(e=>{if(0!==e.length)for(let t of(k(t=>{let s=new Set(t.map(e=>e.name)),a=[...t];for(let t of e)s.has(t.name)||a.push(t);return localStorage.setItem(S,JSON.stringify(a)),a}),e))T(t.name,t.url)}).catch(()=>{})},[]);let $=[...N,...f.map(e=>({value:e.name,label:e.name.replace(/\.\w+$/,"")}))];return(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:x("theme")}),(0,s.jsx)("div",{className:"flex gap-3",children:L.map(({value:a,label:r})=>(0,s.jsxs)("button",{type:"button",onClick:()=>t(a),className:"flex flex-col items-center gap-1.5 cursor-pointer group",children:[(0,s.jsx)("span",{className:(0,o.cn)("relative block h-[70px] w-[88px] overflow-hidden rounded-lg shadow-xs transition-shadow","ring-2 ring-offset-1 ring-offset-background",e===a?"ring-primary/48 opacity-100":"ring-transparent opacity-80 hover:opacity-100"),children:z[a]}),(0,s.jsx)("span",{className:(0,o.cn)("text-xs font-medium transition-colors",e===a?"text-foreground":"text-muted-foreground/70 group-hover:text-muted-foreground"),children:r})]},a))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:x("primaryColor")||"Primary Color"}),(0,s.jsx)(h.ColorPicker,{colors:m.DEFAULT_PRIMARY_COLORS,value:E,onChange:U})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:"Style"}),(0,s.jsx)(d.SearchSelect,{value:y,onChange:M,options:[{value:"",label:"Default"},{value:"mira",label:"Mira"},{value:"lyra",label:"Lyra"},{value:"luma",label:"Luma"},{value:"rhea",label:"Rhea"},{value:"custom",label:"Custom"}],placeholder:"Select style...",allowCustom:!1}),"custom"===y&&(0,s.jsx)(i.Textarea,{className:"mt-2 font-mono text-xs min-h-40",placeholder:"Paste CSS variables here...",value:A,onChange:e=>R(e.target.value)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:x("font")}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(d.SearchSelect,{value:p,onChange:P,options:$,placeholder:x("fontPlaceholder"),searchPlaceholder:x("fontSearch"),allowCustom:!1,className:"flex-1"}),(0,s.jsx)(n.Button,{variant:"outline",size:"icon",className:"size-8 shrink-0",onClick:()=>j(!0),title:x("addCustomFont"),children:(0,s.jsx)(c.Plus,{className:"size-4"})})]})]}),(0,s.jsx)(v,{open:b,onOpenChange:j,onFontAdded:_})]})}],767848);var D=e.i(694913),D=D,A=e.i(5618);e.s(["LanguageTab",0,function(){let e=(0,r.useTranslations)("settings"),{locale:t,setLocale:a}=(0,A.useLocale)(),l=[{value:"zh",label:e("languageZh")},{value:"en",label:e("languageEn")}];return(0,s.jsx)("div",{className:"space-y-5",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:e("language")}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2",children:l.map(({value:e,label:r})=>(0,s.jsxs)("button",{type:"button",onClick:()=>a(e),className:(0,o.cn)("flex items-center justify-center gap-1.5 rounded-lg border p-3 text-sm transition-colors hover:bg-muted/50",t===e&&"border-primary bg-primary/5 text-primary"),children:[(0,s.jsx)(D.default,{className:"size-4"}),(0,s.jsx)("span",{className:"text-xs font-medium",children:r})]},e))})]})})}],710858)},238300,e=>{"use strict";var t=e.i(738776),s=e.i(482560),a=e.i(106486),r=e.i(209988),l=e.i(465458),o=e.i(799773),c=e.i(348085),n=e.i(882469),i=e.i(758960),d=e.i(797161),u=e.i(327962),m=e.i(513501),h=e.i(325443),x=e.i(583705),p=e.i(346038),g=e.i(977694),f=e.i(943997),k=e.i(473616),b=e.i(964970),j=e.i(767848),y=e.i(710858),v=e.i(324216),N=e.i(951841),w=e.i(566531),S=e.i(494396);function C(){let e=(0,a.useTranslations)("settings"),r=(0,a.useTranslations)("common"),[l,o]=(0,s.useState)(null),[c,n]=(0,s.useState)(!1),[i,d]=(0,s.useState)(null);return(0,s.useEffect)(()=>{w.sdk.http.get("/api/user/settings").then(e=>{e.avatarUrl&&o(e.avatarUrl)}).catch(()=>{})},[]),(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:e("userAvatar")}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(v.UserIcon,{size:"lg"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("label",{className:"text-xs text-primary cursor-pointer hover:underline",children:[r("upload"),(0,t.jsx)("input",{type:"file",accept:"image/*",className:"hidden",onChange:e=>{let t=e.target.files?.[0];t&&(d(URL.createObjectURL(t)),n(!0),e.target.value="")}})]}),l&&(0,t.jsx)("button",{type:"button",className:"text-xs text-destructive hover:underline cursor-pointer",onClick:()=>{o(null),(0,N.setCachedUserAvatarUrl)(null),w.sdk.http.putVoid("/api/user/settings",{avatarUrl:null}).catch(()=>{})},children:r("remove")})]})]})]}),i&&(0,t.jsx)(S.AvatarPicker,{src:i,open:c,onOpenChange:e=>{e||(n(!1),d(null))},onUploaded:e=>o(e)})]})}var I=e.i(749943),E=e.i(233297),T=e.i(437122),z=e.i(681622),D=e.i(260218);function A(){let e=(0,a.useTranslations)("settings"),r=(0,a.useTranslations)("common"),l=(0,I.useRouter)(),[o,c]=(0,s.useState)(""),[n,i]=(0,s.useState)(!1),d=async()=>{try{await w.sdk.auth.changeSecret(o),i(!0),(0,T.removeToken)(),setTimeout(()=>(0,E.tauriNavigate)(l,"/login"),800)}catch{}};return(0,t.jsx)("div",{className:"space-y-5",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:e("security")}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(z.Input,{type:"password",autoComplete:"new-password",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,className:"h-8 text-sm flex-1",placeholder:e("newSecretPlaceholder"),value:o,onChange:e=>{c(e.target.value),i(!1)},onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,t.jsx)(D.Button,{size:"sm",onClick:d,disabled:n,children:r(n?"saved":"save")})]}),n&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:e("redirecting")})]})})}var B=e.i(817854),L=e.i(226624);function M(){let e=(0,a.useTranslations)("settings"),r=(0,a.useTranslations)("common"),[l,o]=(0,s.useState)([]),[c,n]=(0,s.useState)(!0),i=async()=>{try{let e=await w.sdk.http.get("/api/speech-recognition");o(e)}catch{}n(!1)};(0,s.useEffect)(()=>{i()},[]);let d=async(e,t)=>{await w.sdk.http.putVoid(`/api/speech-recognition/${e}`,{credentials:t})},u=async(e,t)=>{await w.sdk.http.putVoid(`/api/speech-recognition/${e}`,{enabled:t}),o(s=>s.map(s=>s.id===e?{...s,enabled:t}:s))},m=async e=>{let t=await w.sdk.http.post("/api/speech-recognition",{provider:e,credentials:{}});o(e=>[...e,t])};if(c)return(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:r("loading")});let h=l.find(e=>"tencent"===e.provider);return(0,t.jsx)("div",{className:"space-y-5",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:e("speechDescription")}),(0,t.jsxs)("div",{className:"space-y-3 p-3 border rounded-lg",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e("speechTencent")}),h&&(0,t.jsx)(L.Switch,{checked:!1!==h.enabled,onCheckedChange:e=>u(h.id,e)})]}),h?(0,t.jsx)(R,{configId:h.id,credentials:h.credentials,onSave:d}):(0,t.jsx)(D.Button,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>m("tencent"),children:e("speechAddConfig")})]})]})})}function R({configId:e,credentials:r,onSave:l}){let o=(0,a.useTranslations)("settings"),c=(0,a.useTranslations)("common"),[n,i]=(0,s.useState)(r.appId??""),[d,u]=(0,s.useState)(r.secretId??""),[m,h]=(0,s.useState)(r.secretKey??""),[x,p]=(0,s.useState)(!1),g=async()=>{await l(e,{appId:n,secretId:d,secretKey:m}),p(!0),setTimeout(()=>p(!1),2e3)};return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(B.Label,{className:"text-xs text-muted-foreground",children:o("speechAppId")}),(0,t.jsx)(z.Input,{className:"h-7 text-xs",value:n,onChange:e=>i(e.target.value),placeholder:"125922****"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(B.Label,{className:"text-xs text-muted-foreground",children:o("speechSecretId")}),(0,t.jsx)(z.Input,{className:"h-7 text-xs",value:d,onChange:e=>u(e.target.value),placeholder:"SecretId"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(B.Label,{className:"text-xs text-muted-foreground",children:o("speechSecretKey")}),(0,t.jsx)(z.Input,{type:"password",className:"h-7 text-xs",value:m,onChange:e=>h(e.target.value),placeholder:"SecretKey"})]}),(0,t.jsx)(D.Button,{size:"sm",className:"text-xs",onClick:g,children:c(x?"saved":"save")})]})}var U=e.i(953700),P=e.i(137340),_=e.i(962562),$=e.i(244996),O=e.i(62669),F=e.i(905437),F=F,H=e.i(360112);function K(){var e;let l=(0,a.useTranslations)("robotAccounts"),o=(0,a.useTranslations)("common"),[c,n]=(0,s.useState)([]),[i,d]=(0,s.useState)(!0),[u,m]=(0,s.useState)(!1),[x,p]=(0,s.useState)(null),[g,f]=(0,s.useState)(null),[k,b]=(0,s.useState)(""),[j,y]=(0,s.useState)(""),[v,N]=(0,s.useState)(""),[S,C]=(0,s.useState)(!1),[I,E]=(0,s.useState)({status:"idle"}),[T,A]=(0,s.useState)(!1),L=(0,s.useRef)(!1),M=()=>{w.sdk.robotAccounts.list().then(e=>{n(e),d(!1)}).catch(()=>d(!1))};(0,s.useEffect)(()=>{M()},[]);let R=e=>{p(e),b(e.name),y(e.lark?.appId??""),N(e.lark?.appSecret??""),m(!0)},P=async()=>{if(!S){C(!0);try{let e={name:k,type:"lark",lark:{appId:j,appSecret:v}};x?await w.sdk.robotAccounts.update(x.id,e):await w.sdk.robotAccounts.create(e),H.toast.success(x?l("updateSuccess"):l("createSuccess")),m(!1),M()}catch(e){H.toast.error(x?l("updateFailed"):l("createFailed"),{description:e instanceof Error?e.message:void 0})}finally{C(!1)}}},_=async()=>{if("loading"!==I.status){E({status:"loading"});try{let e=await w.sdk.robotAccounts.wechatQR();E({status:"wait",qrcodeImgContent:e.qrcodeImgContent,sessionId:e.sessionId})}catch(e){H.toast.error(l("createFailed"),{description:e instanceof Error?e.message:void 0}),E({status:"idle"})}}};(0,s.useEffect)(()=>{if(!T||!["wait","scaned"].includes(I.status)||!I.sessionId)return;let e=window.setInterval(()=>{L.current||(L.current=!0,w.sdk.robotAccounts.wechatQRPoll(I.sessionId).then(e=>{E(t=>({...t,status:e.status})),"confirmed"===e.status&&e.account&&(H.toast.success(l("createSuccess")),A(!1),E({status:"idle"}),M()),"expired"===e.status&&H.toast.error(l("wechatExpired"))}).catch(()=>{}).finally(()=>{L.current=!1}))},2e3);return()=>window.clearInterval(e)},[T,I.status,I.sessionId,l]);let K=async e=>{try{await w.sdk.robotAccounts.delete_(e),H.toast.success(l("deleteSuccess")),f(null),M()}catch{H.toast.error(l("deleteFailed"))}},Z=c.filter(e=>"lark"===e.type),G=c.filter(e=>"wechat"===e.type),V=k.trim()&&j.trim()&&v.trim();return(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:l("title")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:l("description")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)(D.Button,{type:"button",size:"sm",onClick:()=>{p(null),b(""),y(""),N(""),m(!0)},children:[(0,t.jsx)(U.Plus,{className:"mr-1.5 h-3.5 w-3.5"}),l("addLark")]}),(0,t.jsxs)(D.Button,{type:"button",size:"sm",variant:"outline",onClick:()=>{A(!0),E({status:"idle"})},children:[(0,t.jsx)(U.Plus,{className:"mr-1.5 h-3.5 w-3.5"}),l("addWechat")]})]}),i?null:0===c.length?(0,t.jsxs)("div",{className:"rounded-md border border-dashed px-4 py-8 text-center",children:[(0,t.jsx)(h.Bot,{className:"mx-auto h-8 w-8 text-muted-foreground/50"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:l("noAccounts")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:l("noAccountsDesc")})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[Z.length>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h5",{className:"text-xs font-medium text-muted-foreground",children:l("lark")}),Z.map(e=>(0,t.jsx)(Y,{account:e,onEdit:R,onDelete:f},e.id))]}),G.length>0&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h5",{className:"text-xs font-medium text-muted-foreground",children:l("wechat")}),G.map(e=>(0,t.jsx)(Y,{account:e,onEdit:()=>{},onDelete:f},e.id))]})]}),(0,t.jsx)(r.Dialog,{open:u,onOpenChange:m,children:(0,t.jsxs)(r.DialogContent,{className:"sm:max-w-md",children:[(0,t.jsxs)(r.DialogHeader,{children:[(0,t.jsx)(r.DialogTitle,{children:x?l("editAccount"):l("addLark")}),(0,t.jsx)(r.DialogDescription,{children:l("lark")})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(B.Label,{className:"text-xs text-muted-foreground",children:l("name")}),(0,t.jsx)(z.Input,{value:k,onChange:e=>b(e.target.value),placeholder:l("namePlaceholder")})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(B.Label,{className:"text-xs text-muted-foreground",children:l("larkFields.appId")}),(0,t.jsx)(z.Input,{value:j,onChange:e=>y(e.target.value),placeholder:"cli_xxx"})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(B.Label,{className:"text-xs text-muted-foreground",children:l("larkFields.appSecret")}),(0,t.jsx)(z.Input,{type:"password",value:v,onChange:e=>N(e.target.value),placeholder:"app secret"})]})]}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,t.jsx)(D.Button,{type:"button",size:"sm",variant:"outline",onClick:()=>m(!1),children:o("cancel")}),(0,t.jsx)(D.Button,{type:"button",size:"sm",onClick:P,disabled:!V||S,children:l("save")})]})]})}),(0,t.jsx)(r.Dialog,{open:T,onOpenChange:A,children:(0,t.jsxs)(r.DialogContent,{className:"sm:max-w-md",children:[(0,t.jsxs)(r.DialogHeader,{children:[(0,t.jsx)(r.DialogTitle,{children:l("addWechat")}),(0,t.jsx)(r.DialogDescription,{children:l("wechatQrDescription")})]}),(0,t.jsxs)("div",{className:"space-y-4",children:["idle"===I.status&&(0,t.jsx)("div",{className:"flex justify-center py-4",children:(0,t.jsxs)(D.Button,{type:"button",onClick:_,children:[(0,t.jsx)(F.default,{className:"mr-1.5 h-4 w-4"}),l("getQr")]})}),"loading"===I.status&&(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(O.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}),["wait","scaned","expired"].includes(I.status)&&I.qrcodeImgContent&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-md border border-dashed px-3 py-3",children:[(0,t.jsx)("img",{src:(e=I.qrcodeImgContent,`https://api.qrserver.com/v1/create-qr-code/?size=180x180&margin=8&data=${encodeURIComponent(e)}`),alt:"WeChat QR code",className:"h-36 w-36 shrink-0 rounded border bg-white p-2"}),(0,t.jsx)("div",{className:"min-w-0 space-y-1 text-xs text-muted-foreground",children:(0,t.jsxs)("p",{className:"flex items-center gap-1.5",children:["wait"===I.status&&l("wechatWaitScan"),"scaned"===I.status&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)($.CheckCircle2,{className:"h-3.5 w-3.5 text-emerald-600"})," ",l("wechatScanned")]}),"expired"===I.status&&l("wechatExpired")]})})]}),(0,t.jsx)("div",{className:"flex justify-center",children:(0,t.jsxs)(D.Button,{type:"button",size:"sm",variant:"outline",onClick:_,children:[(0,t.jsx)(O.Loader2,{className:"loading"===I.status?"mr-1.5 h-3.5 w-3.5 animate-spin":"hidden"}),l("refreshQr")]})})]})]})]})}),(0,t.jsx)(r.Dialog,{open:!!g,onOpenChange:()=>f(null),children:(0,t.jsxs)(r.DialogContent,{className:"sm:max-w-sm",children:[(0,t.jsxs)(r.DialogHeader,{children:[(0,t.jsx)(r.DialogTitle,{children:l("deleteAccount")}),(0,t.jsx)(r.DialogDescription,{children:l("deleteConfirm")})]}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,t.jsx)(D.Button,{type:"button",size:"sm",variant:"outline",onClick:()=>f(null),children:o("cancel")}),(0,t.jsx)(D.Button,{type:"button",size:"sm",variant:"destructive",onClick:()=>g&&K(g),children:l("deleteAccount")})]})]})})]})}function Y({account:e,onEdit:s,onDelete:r}){let l=(0,a.useTranslations)("robotAccounts");return(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-md border px-3 py-2.5",children:[(0,t.jsx)(h.Bot,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"text-sm font-medium truncate",children:e.name}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:"lark"===e.type?`${l("lark")} \xb7 ${e.lark?.appId??"-"}`:`${l("wechat")} \xb7 ${e.wechat?.accountId??"-"}`})]}),(0,t.jsxs)("div",{className:"flex gap-1 shrink-0",children:["lark"===e.type&&(0,t.jsx)(D.Button,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>s(e),children:(0,t.jsx)(_.Pencil,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(D.Button,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive hover:text-destructive",onClick:()=>r(e.id),children:(0,t.jsx)(P.Trash2,{className:"h-3.5 w-3.5"})})]})]})}var Z=e.i(601039),G=e.i(307858),V=e.i(734649);let W="agent-spaces-auto-check-update";function q(){let e=(0,a.useTranslations)("settings"),r=(0,a.useTranslations)("common"),[o,c]=(0,s.useState)(null),[n,i]=(0,s.useState)(""),[d,u]=(0,s.useState)(!1),[m,h]=(0,s.useState)(()=>"false"!==localStorage.getItem(W)),[x,p]=(0,s.useState)(!1),g=(0,s.useCallback)(async()=>{try{let e=await w.sdk.version.current();c(e)}catch{}},[]);(0,s.useEffect)(()=>{w.sdk.http.get("/api/health",{noAuth:!0}).then(e=>i(e.platform??"")).catch(()=>{}),g()},[g]),(0,s.useEffect)(()=>{m&&w.sdk.version.check().then(e=>{e.updateAvailable&&c(e)}).catch(()=>{})},[]);let f=(0,s.useCallback)(async()=>{u(!0);try{let t=await w.sdk.version.check();c(t),t.updateAvailable||H.toast.success(e("aboutUpToDate"))}catch{H.toast.error(e("aboutCheckFailed"))}finally{u(!1)}},[e]),k=(0,s.useCallback)(async()=>{p(!1),H.toast.info(e("aboutUpdating"));try{await w.sdk.version.triggerUpdate()}catch{}},[e]),b=o?.local??"-",j=o?.latest,y=o?.dev===!0,v=!y&&(o?.updateAvailable??!1);return(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 pb-4 border-b",children:[(0,t.jsx)("img",{src:"/favicon.ico",alt:"Logo",className:"size-10 shrink-0"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:"Agent Spaces"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["v",b]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:e("aboutInfo")}),(0,t.jsxs)("div",{className:"text-sm space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:e("aboutVersion")}),(0,t.jsx)("span",{className:"font-mono",children:b})]}),j&&(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:e("aboutLatestVersion")}),(0,t.jsx)("span",{className:"font-mono",children:j})]}),n&&(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:e("aboutPlatform")}),(0,t.jsx)("span",{children:n})]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:e("aboutLinks")}),(0,t.jsxs)("a",{href:"https://github.com/hunmer/agent_spaces",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline flex items-center gap-1.5",children:[(0,t.jsx)("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})}),"GitHub",(0,t.jsx)(G.ExternalLink,{className:"size-3"})]})]}),!y&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:e("aboutUpdates")}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-sm",children:e("aboutAutoCheck")}),(0,t.jsx)(L.Switch,{size:"sm",checked:m,onCheckedChange:e=>{h(e),localStorage.setItem(W,String(e))}})]}),(0,t.jsxs)(D.Button,{variant:"outline",size:"sm",onClick:f,disabled:d,children:[(0,t.jsx)(Z.RefreshCw,{className:(0,l.cn)("size-3.5 mr-1.5",d&&"animate-spin")}),d?e("aboutChecking"):e("aboutCheckNow")]}),v&&j&&(0,t.jsxs)("div",{className:"rounded-lg border p-3 text-sm space-y-2",children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:e("aboutNewVersion",{version:j})}),(0,t.jsx)(D.Button,{size:"sm",onClick:()=>p(!0),children:e("aboutUpdateNow")})]})]})]}),y&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e("aboutDevMode")}),(0,t.jsx)(V.AlertDialog,{open:x,onOpenChange:p,children:(0,t.jsxs)(V.AlertDialogContent,{children:[(0,t.jsxs)(V.AlertDialogHeader,{children:[(0,t.jsx)(V.AlertDialogTitle,{children:e("aboutUpdateConfirmTitle")}),(0,t.jsx)(V.AlertDialogDescription,{children:e("aboutUpdateConfirmDesc")})]}),(0,t.jsxs)(V.AlertDialogFooter,{children:[(0,t.jsx)(V.AlertDialogCancel,{children:r("cancel")}),(0,t.jsx)(V.AlertDialogAction,{onClick:k,children:e("aboutUpdateNow")})]})]})})]})}var J=e.i(974915),Q=e.i(357301);function X(){let e=(0,a.useTranslations)("settings"),{getShortcut:r,setShortcut:l,resetShortcut:o}=(0,J.useKeyboardShortcuts)(),[c,n]=(0,s.useState)(null),i=(0,s.useCallback)(e=>{if(!c)return;if(e.preventDefault(),e.stopPropagation(),"Escape"===e.key)return void n(null);if(["Control","Shift","Alt","Meta"].includes(e.key))return;let t=[];e.ctrlKey&&t.push("ctrl"),e.shiftKey&&t.push("shift"),e.altKey&&t.push("alt"),e.metaKey&&t.push("meta"),t.push(e.key.toLowerCase()),l(c,t.join("+")),n(null)},[c,l]);return(0,s.useEffect)(()=>{if(c)return document.addEventListener("keydown",i,!0),()=>document.removeEventListener("keydown",i,!0)},[c,i]),(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:e("shortcuts")}),(0,t.jsx)("div",{className:"space-y-2",children:J.SHORTCUT_DEFS.map(s=>{let a,l=r(s.id),i=c===s.id;return(0,t.jsxs)("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg border",children:[(0,t.jsx)("span",{className:"text-sm",children:e(s.labelKey)}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[i?(0,t.jsx)("span",{className:"text-xs text-primary animate-pulse",children:e("recordingShortcut")}):(0,t.jsx)("div",{className:"flex items-center gap-0.5",children:(a={ctrl:"Ctrl",shift:"Shift",alt:"Alt",meta:"Meta",cmd:"Cmd"},l.split("+").map(e=>a[e]??e.toUpperCase())).map((e,s)=>(0,t.jsx)("kbd",{className:"inline-flex items-center rounded border bg-muted px-1.5 py-0.5 text-[11px] font-mono",children:e},s))}),(0,t.jsx)(D.Button,{variant:"ghost",size:"sm",className:"size-7 p-0",onClick:()=>n(i?null:s.id),title:e("recordShortcut"),children:(0,t.jsx)(p.Keyboard,{className:"size-3.5"})}),(0,t.jsx)(D.Button,{variant:"ghost",size:"sm",className:"size-7 p-0",onClick:()=>o(s.id),title:e("resetShortcut"),children:(0,t.jsx)(Q.RotateCcw,{className:"size-3.5"})})]})]},s.id)})})]})})}var ee=e.i(607452),et=e.i(515104);function es(){let e=(0,a.useTranslations)("settings"),[r,l]=(0,s.useState)(()=>{let e=localStorage.getItem("pageZoom"),t=e?Number(e):100;return t>=50&&t<=200?t:100}),[o,c]=(0,s.useState)(!1),[n,i]=(0,s.useState)(()=>{let e=localStorage.getItem("showWorkspaceTabs");return null===e||"false"!==e}),[d,u]=(0,s.useState)(()=>"true"===localStorage.getItem("autoActivateWorkspace")),m=(0,s.useCallback)(e=>{localStorage.setItem("pageZoom",String(e)),l(e),window.dispatchEvent(new CustomEvent("zoom-change",{detail:e}))},[]);return(0,s.useEffect)(()=>{let e=requestAnimationFrame(()=>{c((0,et.isNativeEnvironment)())});return()=>cancelAnimationFrame(e)},[]),(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:e("showWorkspaceTabs")}),(0,t.jsx)(L.Switch,{size:"sm",checked:n,onCheckedChange:e=>{i(e),localStorage.setItem("showWorkspaceTabs",String(e)),window.dispatchEvent(new CustomEvent("workspace-tabs-visibility",{detail:e}))}})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:e("autoActivateWorkspace")}),(0,t.jsx)(L.Switch,{size:"sm",checked:d,onCheckedChange:e=>{u(e),localStorage.setItem("autoActivateWorkspace",String(e))}})]}),o&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:e("zoom")}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(ee.Slider,{min:50,max:200,step:10,value:r,onValueChange:e=>m(Array.isArray(e)?e[0]:e),className:"flex-1"}),(0,t.jsxs)("span",{className:"text-xs font-mono tabular-nums w-10 text-right",children:[r,"%"]}),(0,t.jsx)("button",{type:"button",onClick:()=>m(100),className:"text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:e("zoomReset"),children:(0,t.jsx)(Q.RotateCcw,{className:"size-3.5"})})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:e("layout")}),(0,t.jsxs)(D.Button,{variant:"outline",size:"sm",className:"gap-1.5 text-xs",onClick:()=>window.dispatchEvent(new CustomEvent("reset-layout")),children:[(0,t.jsx)(Q.RotateCcw,{className:"size-3.5"}),e("resetLayout")]})]})]})}var ea=e.i(916950);let er=[{label:"GitHub (Proxy)",url:"https://gh-proxy.org/https://github.com/hunmer/agent-spaces/raw/refs/heads/main/packages/templates/"},{label:"GitHub (Direct)",url:"https://github.com/hunmer/agent-spaces/raw/refs/heads/main/packages/templates/"},{label:"Local (8080)",url:"http://localhost:3101/"}];function el(){let[e,r]=(0,s.useState)(()=>(0,ea.getStoreApiBase)()),[l,o]=(0,s.useState)(!1),c=(0,a.useTranslations)("settings"),i=t=>{let s=t??e;r(s),(0,ea.setStoreApiBase)(s),o(!0),setTimeout(()=>o(!1),1500)};return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:c("storeApiBase")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(z.Input,{value:e,onChange:e=>r(e.target.value),placeholder:er[0].url,className:"text-sm"}),(0,t.jsx)(D.Button,{size:"sm",onClick:()=>i(),children:l?"✓":c("save")})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1.5",children:c("storeApiBaseDesc")})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2 block",children:c("storeApiPresets")}),(0,t.jsx)("div",{className:"space-y-1.5",children:er.map(s=>(0,t.jsxs)("button",{onClick:()=>i(s.url),className:`w-full flex items-center gap-2.5 rounded-md px-3 py-2 text-sm text-left transition-colors ${e===s.url?"bg-primary/10 text-primary border border-primary/20":"hover:bg-muted text-foreground"}`,children:[(0,t.jsx)(n.Globe,{className:"h-3.5 w-3.5 shrink-0 opacity-60"}),(0,t.jsx)("span",{className:"font-medium",children:s.label}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate ml-auto max-w-[200px]",children:s.url})]},s.url))})]})]})}var eo=e.i(18179),ec=e.i(193251),en=e.i(129981),ei=e.i(368942);let ed=["config","ai","content","customization","billing"];function eu(){let e=(0,a.useTranslations)("settings"),[l,o]=(0,s.useState)(!1),[c,n]=(0,s.useState)(!1),[i,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)([]),[h,x]=(0,s.useState)([]),[p,g]=(0,s.useState)([]),[f,k]=(0,s.useState)(""),[b,j]=(0,s.useState)(new Set),[y,v]=(0,s.useState)(new Set),[N,S]=(0,s.useState)(new Set),[C,I]=(0,s.useState)(!1),[E,T]=(0,s.useState)(!1),[z,A]=(0,s.useState)(!1),[B,L]=(0,s.useState)(!1),[M,R]=(0,s.useState)(""),[U,P]=(0,s.useState)([]),[_,$]=(0,s.useState)(new Set),[F,K]=(0,s.useState)(""),[Y,Z]=(0,s.useState)(null),G=(0,s.useRef)(null),V=(0,s.useCallback)(async()=>{n(!0),k("");try{let e=await w.sdk.data.ccSwitchPreview();if(!e.error||e.providers?.length||e.skills?.length||e.mcps?.length){let t=e.providers||[],s=e.skills||[],a=e.mcps||[];m(t),x(s),g(a),j(new Set(t.map(e=>e.sourceId))),v(new Set(s.map(e=>e.name))),S(new Set(a.map(e=>e.name)))}else k(e.error),m([]),x([]),g([]);o(!0)}catch{k("Failed to load cc-switch data"),o(!0)}finally{n(!1)}},[]),W=(0,s.useCallback)(async()=>{d(!0);try{let t={providers:u.filter(e=>b.has(e.sourceId)),skills:h.filter(e=>y.has(e.name)),mcps:p.filter(e=>N.has(e.name))},s=await w.sdk.data.ccSwitchExecute(t);if(s.providers?.length||s.models?.length){let[e,t]=await Promise.all([w.sdk.llm.listProviders(),w.sdk.llm.listModels()]),s={};s.providers=e,s.models=t,ei.useLLMStore.setState(s)}let a=(s.providers?.filter(e=>!e.includes("skipped")).length||0)+(s.models?.length||0)+(s.skills?.length||0)+(s.mcps?.length||0);H.toast.success(e("dataImportSuccess",{count:a})),o(!1)}catch{H.toast.error(e("dataImportFailed"))}finally{d(!1)}},[u,h,p,b,y,N,e]),q=(e,t)=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s},J=(e,t,s)=>{let a=new Set(e.map(e=>e.sourceId||e.name));s(t().size===e.length?new Set:a)},Q=b.size+y.size+N.size,X=(0,s.useCallback)(async()=>{I(!0);try{let t=await w.sdk.data.exportZip();if(!t.ok)throw Error("Export failed");let s=await t.blob(),a=URL.createObjectURL(s),r=document.createElement("a");r.href=a,r.download=`agent-spaces-backup-${new Date().toISOString().slice(0,10)}.zip`,r.click(),URL.revokeObjectURL(a),H.toast.success(e("dataExportSuccess"))}catch{H.toast.error(e("dataExportFailed"))}finally{I(!1)}},[e]),ee=(0,s.useCallback)(async e=>{let t=e.target.files?.[0];if(t){e.target.value="",A(!0),K(""),Z(null);try{let e=new FormData;e.append("file",t);let s=await w.sdk.data.importPreview(e);s.error?(K(s.error),P([]),R("")):(R(s.sessionId??""),P(s.categories??[]),$(new Set((s.categories??[]).map(e=>e.key)))),T(!0)}catch{K("Failed to upload file"),P([]),T(!0)}finally{A(!1)}}},[]),et=(0,s.useCallback)(async()=>{L(!0);try{let t=await w.sdk.data.importExecute(M,[..._]);t.error?H.toast.error(t.error):(Z(t.results??null),H.toast.success(e("dataImportComplete")))}catch{H.toast.error(e("dataImportFailed"))}finally{L(!1)}},[M,_,e]),es=ed.map(t=>({group:t,label:(t=>{switch(t){case"config":return e("dataCategoryConfig");case"ai":return e("dataCategoryAI");case"content":return e("dataCategoryContent");case"customization":return e("dataCategoryCustomization");case"billing":return e("dataCategoryBilling");default:return t}})(t),items:U.filter(e=>e.group===t)})).filter(e=>e.items.length>0);return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:e("dataExportTitle")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mb-3",children:e("dataExportDesc")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)(D.Button,{variant:"outline",size:"sm",onClick:X,disabled:C,children:[C?(0,t.jsx)(O.Loader2,{className:"size-3.5 mr-1.5 animate-spin"}):(0,t.jsx)(ec.Download,{className:"size-3.5 mr-1.5"}),C?e("dataExporting"):e("dataExport")]}),(0,t.jsxs)(D.Button,{variant:"outline",size:"sm",onClick:()=>G.current?.click(),disabled:z,children:[z?(0,t.jsx)(O.Loader2,{className:"size-3.5 mr-1.5 animate-spin"}):(0,t.jsx)(en.Upload,{className:"size-3.5 mr-1.5"}),z?e("dataUploading"):e("dataImportBackup")]}),(0,t.jsx)("input",{ref:G,type:"file",accept:".zip",className:"hidden",onChange:ee})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:e("dataTitle")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mb-3",children:e("dataDescription")}),(0,t.jsxs)(D.Button,{variant:"outline",size:"sm",onClick:V,disabled:c,children:[c?(0,t.jsx)(O.Loader2,{className:"size-3.5 mr-1.5 animate-spin"}):(0,t.jsx)(eo.Import,{className:"size-3.5 mr-1.5"}),c?e("dataLoading"):e("dataImportFromCcSwitch")]})]}),(0,t.jsx)(r.Dialog,{open:E,onOpenChange:T,children:(0,t.jsxs)(r.DialogContent,{className:"sm:max-w-lg max-h-[75vh] flex flex-col",children:[(0,t.jsxs)(r.DialogHeader,{children:[(0,t.jsx)(r.DialogTitle,{className:"text-base",children:e("dataImportBackupTitle")}),(0,t.jsx)(r.DialogDescription,{className:"text-xs",children:e("dataImportBackupDialogDesc")})]}),F&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:F}),Y?(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-1.5 py-2",children:U.map(s=>{let a=Y[s.key];return a?(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-md border px-3 py-2",children:[(0,t.jsx)("span",{className:"text-sm",children:s.label}),(0,t.jsx)("span",{className:`text-xs px-2 py-0.5 rounded ${{ok:"text-green-600 bg-green-50",skipped:"text-muted-foreground bg-muted",error:"text-destructive bg-destructive/10"}[a]}`,children:"ok"===a?e("dataImportResultOk"):"skipped"===a?e("dataImportResultSkipped"):e("dataImportResultError")})]},s.key):null})}):(0,t.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-4 py-2",children:[0===es.length&&!F&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:e("dataNoCategories")}),es.map(({group:s,label:a,items:r})=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:a}),(0,t.jsx)(D.Button,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{let e,t;return t=(e=U.filter(e=>e.group===s).map(e=>e.key)).every(e=>_.has(e)),void $(s=>{let a=new Set(s);return e.forEach(e=>t?a.delete(e):a.add(e)),a})},children:r.every(e=>_.has(e.key))?e("dataDeselectAll"):e("dataSelectAll")})]}),(0,t.jsx)("div",{className:"space-y-1.5",children:r.map(e=>{var s;return(0,t.jsxs)("label",{className:"flex items-center gap-2.5 rounded-md border px-3 py-2 cursor-pointer hover:bg-muted/50",children:[(0,t.jsx)("input",{type:"checkbox",checked:_.has(e.key),onChange:()=>{var t;return t=e.key,void $(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"size-4 rounded border-border accent-primary"}),(0,t.jsx)("span",{className:"text-sm flex-1",children:e.label}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:"directory"===e.type?e.details:(s=e.size)<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KB`:`${(s/1048576).toFixed(1)} MB`})]},e.key)})})]},s))]}),(0,t.jsxs)(r.DialogFooter,{children:[(0,t.jsx)(D.Button,{variant:"outline",size:"sm",onClick:()=>T(!1),children:e("dataCancel")}),!Y&&(0,t.jsxs)(D.Button,{size:"sm",onClick:et,disabled:B||0===_.size,children:[B&&(0,t.jsx)(O.Loader2,{className:"size-3.5 mr-1.5 animate-spin"}),e("dataImport")," (",_.size,")"]})]})]})}),(0,t.jsx)(r.Dialog,{open:l,onOpenChange:o,children:(0,t.jsxs)(r.DialogContent,{className:"sm:max-w-lg max-h-[75vh] flex flex-col",children:[(0,t.jsxs)(r.DialogHeader,{children:[(0,t.jsx)(r.DialogTitle,{className:"text-base",children:e("dataImportTitle")}),(0,t.jsx)(r.DialogDescription,{className:"text-xs",children:e("dataImportDesc")})]}),f&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:f}),(0,t.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-4 py-2",children:[u.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsxs)("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[e("dataProviders")," (",u.length,")"]}),(0,t.jsx)(D.Button,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>J(u,()=>b,j),children:b.size===u.length?e("dataDeselectAll"):e("dataSelectAll")})]}),(0,t.jsx)("div",{className:"space-y-1.5",children:u.map(e=>{var s;return(0,t.jsxs)("label",{className:"flex items-start gap-2.5 rounded-md border px-3 py-2 cursor-pointer hover:bg-muted/50",children:[(0,t.jsx)("input",{type:"checkbox",id:`prov-${e.sourceId}`,checked:b.has(e.sourceId),onChange:()=>j(t=>q(t,e.sourceId)),className:"mt-0.5 size-4 rounded border-border accent-primary"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:e.source})]}),e.apiBase&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.apiBase}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground font-mono",children:(s=e.apiKey)&&!(s.length<12)?s.slice(0,6)+"..."+s.slice(-4):s?"***":""}),e.models.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:e.models.map(e=>(0,t.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-primary/10 text-primary",children:e},e))})]})]},e.sourceId)})})]}),p.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsxs)("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[e("dataMcps")," (",p.length,")"]}),(0,t.jsx)(D.Button,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>J(p,()=>N,S),children:N.size===p.length?e("dataDeselectAll"):e("dataSelectAll")})]}),(0,t.jsx)("div",{className:"space-y-1.5",children:p.map(e=>(0,t.jsxs)("label",{className:"flex items-start gap-2.5 rounded-md border px-3 py-2 cursor-pointer hover:bg-muted/50",children:[(0,t.jsx)("input",{type:"checkbox",id:`mcp-${e.name}`,checked:N.has(e.name),onChange:()=>S(t=>q(t,e.name)),className:"mt-0.5 size-4 rounded border-border accent-primary"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:[e.command," ",e.args.join(" ")]})]})]},e.name))})]}),h.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsxs)("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[e("dataSkills")," (",h.length,")"]}),(0,t.jsx)(D.Button,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>J(h,()=>y,v),children:y.size===h.length?e("dataDeselectAll"):e("dataSelectAll")})]}),(0,t.jsx)("div",{className:"space-y-1.5",children:h.map(e=>(0,t.jsxs)("label",{className:"flex items-start gap-2.5 rounded-md border px-3 py-2 cursor-pointer hover:bg-muted/50",children:[(0,t.jsx)("input",{type:"checkbox",id:`skill-${e.name}`,checked:y.has(e.name),onChange:()=>v(t=>q(t,e.name)),className:"mt-0.5 size-4 rounded border-border accent-primary"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),e.description&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.description})]})]},e.name))})]}),!f&&0===u.length&&0===h.length&&0===p.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:e("dataNoData")})]}),(0,t.jsxs)(r.DialogFooter,{children:[(0,t.jsx)(D.Button,{variant:"outline",size:"sm",onClick:()=>o(!1),children:e("dataCancel")}),(0,t.jsxs)(D.Button,{size:"sm",onClick:W,disabled:i||0===Q,children:[i&&(0,t.jsx)(O.Loader2,{className:"size-3.5 mr-1.5 animate-spin"}),e("dataImport")," (",Q,")"]})]})]})})]})}var em=e.i(346131);let eh=[{label:"淘宝源",value:"https://registry.npmmirror.com"},{label:"npm 官方",value:"https://registry.npmjs.org"},{label:"腾讯云",value:"https://mirrors.cloud.tencent.com/npm/"},{label:"华为云",value:"https://repo.huaweicloud.com/repository/npm/"}],ex="__custom__";function ep(){let[e,a]=(0,s.useState)(eh[0].value),[r,l]=(0,s.useState)(""),[o,c]=(0,s.useState)(!0),[n,i]=(0,s.useState)(!1),[d,u]=(0,s.useState)(!1),m=(0,s.useMemo)(()=>eh.some(t=>t.value===e)?e:ex,[e]);(0,s.useEffect)(()=>{let e=!1;return w.sdk.npmSettings.get().then(t=>{e||(a(t.registry||eh[0].value),l(t.proxy||""))}).finally(()=>{e||c(!1)}),()=>{e=!0}},[]);let h=async()=>{i(!0),u(!1);try{let t=await w.sdk.npmSettings.update({registry:e,proxy:r});a(t.registry),l(t.proxy||""),u(!0),setTimeout(()=>u(!1),1500)}finally{i(!1)}};return(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mb-2.5 block text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"NPM 源"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)(em.Select,{value:m,onValueChange:e=>{e&&e!==ex&&a(e)},disabled:o,children:[(0,t.jsx)(em.SelectTrigger,{className:"h-8 w-[140px] text-sm",children:(0,t.jsx)(em.SelectValue,{})}),(0,t.jsxs)(em.SelectContent,{children:[eh.map(e=>(0,t.jsx)(em.SelectItem,{value:e.value,children:e.label},e.value)),(0,t.jsx)(em.SelectItem,{value:ex,children:"自定义"})]})]}),(0,t.jsx)(z.Input,{value:e,onChange:e=>{a(e.target.value),u(!1)},placeholder:eh[0].value,className:"h-8 flex-1 text-sm",disabled:o})]}),(0,t.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:"用于安装插件 package.json 里的 npm 依赖，默认使用淘宝源。"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mb-2.5 block text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Proxy"}),(0,t.jsx)(z.Input,{value:r,onChange:e=>{l(e.target.value),u(!1)},placeholder:"http://127.0.0.1:7890",className:"h-8 text-sm",disabled:o}),(0,t.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:"可选。保存后会同时写入 npm 的 proxy 和 https-proxy。"})]}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(D.Button,{size:"sm",onClick:h,disabled:o||n||!e.trim(),children:d?"已保存":n?"保存中...":"保存"})})]})}let eg=[{key:"appearance",icon:c.Palette},{key:"startup",icon:g.Rocket},{key:"language",icon:n.Globe},{key:"account",icon:o.User},{key:"security",icon:i.Shield},{key:"robots",icon:h.Bot},{key:"agent_store",icon:m.Store},{key:"npm",icon:k.Package},{key:"data",icon:f.Database},{key:"git",icon:u.GitBranch},{key:"speech",icon:d.Mic},{key:"shortcuts",icon:p.Keyboard},{key:"about",icon:x.Info}];function ef(){return(0,t.jsx)("div",{className:"space-y-5",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2.5 block",children:"Git"}),(0,t.jsx)(b.GitSettingsForm,{scope:"global"})]})})}e.s(["SettingsDialog",0,function({open:e,onOpenChange:o,standalone:c}){let n=(0,a.useTranslations)("settings"),[i,d]=(0,s.useState)("appearance"),u={appearance:n("theme"),startup:n("startup"),language:n("language"),account:n("userAvatar"),security:n("security"),robots:n("robots"),agent_store:n("agentStore"),npm:n("npm"),data:n("data"),git:n("git"),speech:n("speech"),shortcuts:n("shortcuts"),about:n("about")},m=(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col sm:flex-row",children:[(0,t.jsx)("div",{className:"flex sm:flex-col sm:w-48 sm:border-r sm:py-3 sm:px-2 shrink-0 overflow-x-auto overflow-y-auto border-b sm:border-b-0 gap-1 px-2 py-2",children:eg.map(({key:e,icon:s})=>(0,t.jsxs)("button",{type:"button",onClick:()=>d(e),className:(0,l.cn)("flex items-center gap-2 rounded-md px-2.5 py-2 text-xs font-medium transition-colors whitespace-nowrap",i===e?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[(0,t.jsx)(s,{className:"size-4"}),u[e]]},e))}),(0,t.jsx)("form",{autoComplete:"off",onSubmit:e=>e.preventDefault(),className:"flex-1 p-5 min-w-0 overflow-y-auto",children:(()=>{switch(i){case"appearance":return(0,t.jsx)(j.AppearanceTab,{});case"startup":return(0,t.jsx)(es,{});case"language":return(0,t.jsx)(y.LanguageTab,{});case"account":return(0,t.jsx)(C,{});case"security":return(0,t.jsx)(A,{});case"robots":return(0,t.jsx)(K,{});case"agent_store":return(0,t.jsx)(el,{});case"npm":return(0,t.jsx)(ep,{});case"data":return(0,t.jsx)(eu,{});case"git":return(0,t.jsx)(ef,{});case"speech":return(0,t.jsx)(M,{});case"shortcuts":return(0,t.jsx)(X,{});case"about":return(0,t.jsx)(q,{})}})()})]});return c?m:(0,t.jsx)(r.Dialog,{open:e,onOpenChange:o,children:(0,t.jsxs)(r.DialogContent,{className:"sm:max-w-2xl max-h-[85vh] p-0 gap-0 flex flex-col overflow-hidden",children:[(0,t.jsxs)(r.DialogHeader,{className:"px-5 py-4 border-b shrink-0",children:[(0,t.jsx)(r.DialogTitle,{className:"text-base",children:n("title")}),(0,t.jsx)(r.DialogDescription,{className:"text-xs",children:n("description")})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:m})]})})}],238300)}]);