import{q as D,x as e,H as A,I as x,m as J,l as P,f as O,b as S,T as W,M as de,G as Ye,e as Je,E as Xe,k as Te,X as re,z as Me,j as xe,S as R,C as Qe,s as Ze,y as et,h as Ee,v as tt,w as st,J as nt,Q as at,p as it,n as me,L as rt,B as G,u as Q,i as F,D as lt,o as ot,U as ct,F as dt,a as xt,K as Pe,c as mt,d as pt,R as ut,N as Z,t as ht,r as bt}from"./display-OFjwfD4F.js";import{g as ze,M as be,l as ft}from"./context-windows-C2Qe_OYn.js";import{_ as _t}from"./preload-helper-2LWRYvkK.js";import{p as L,A as gt,F as s,d as X,o as kt,E as jt,c as fe,D as vt,l as le,u as yt,j as Nt,y as I,H as wt,i as Ct,g as St,h as Tt,s as Mt,m as Et,b as Pt,w as _e,M as zt}from"./capabilities-CQ-mRPPK.js";import{m as Le,s as Lt,D as ee,l as ge,d as Wt,u as Dt,c as At,a as te}from"./user-memory-DFldwEtp.js";import{g as We,s as Ft,l as Rt,a as It,r as Ot,n as Y}from"./local-folders-Bgzoz3Cn.js";/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ut=D("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const De=D("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const $t=D("Gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const pe=D("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Bt=D("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
 * @license lucide-react v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Kt=D("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]),oe="yank-backup",Ae=1;function se(t){return typeof t=="object"&&t!==null}function $(t){return Array.isArray(t)?t:[]}function Ht(t){var a;const n={...t,llm:{...t.llm,providers:t.llm.providers.map(i=>i.apiKey?{...i,apiKey:""}:i)}};return t.mcp&&(n.mcp={...t.mcp,servers:t.mcp.servers.map(i=>i.authHeader?{...i,authHeader:""}:i)}),(a=t.license)!=null&&a.token&&(n.license={...t.license,token:void 0}),n}function qt(t,n,a){var o;if(a)return n;const i=new Map(t.llm.providers.map(c=>[c.id,c])),r=n.llm.providers.map(c=>{var h;return c.apiKey?c:{...c,apiKey:((h=i.get(c.id))==null?void 0:h.apiKey)??""}}),m={...n,llm:{...n.llm,providers:r}};if(n.mcp&&t.mcp){const c=new Map(t.mcp.servers.map(h=>[h.id,h]));m.mcp={...n.mcp,servers:n.mcp.servers.map(h=>{var j;return h.authHeader===""?{...h,authHeader:(j=c.get(h.id))==null?void 0:j.authHeader}:h})}}return n.license&&!n.license.token&&((o=t.license)!=null&&o.token)&&t.license.accountId===n.license.accountId&&(m.license={...n.license,token:t.license.token}),m}function Vt(t){let n;try{n=JSON.parse(t)}catch(r){return{ok:!1,kind:"json",message:r.message}}if(!se(n)||n.format!==oe)return{ok:!1,kind:"format",message:"not a yank backup file"};if(typeof n.version!="number"||n.version>Ae)return{ok:!1,kind:"version",message:String(n.version)};const a=se(n.data)?n.data:{};return{ok:!0,backup:{format:oe,version:n.version,exportedAt:typeof n.exportedAt=="string"?n.exportedAt:"",appVersion:typeof n.appVersion=="string"?n.appVersion:"",includesSecrets:n.includesSecrets===!0,data:{settings:se(a.settings)?a.settings:void 0,macros:$(a.macros),sessions:$(a.sessions),userMemory:$(a.userMemory),elementCache:$(a.elementCache)}}}}async function Gt(t){const n=await We(),[a,i,r,m,o]=await Promise.all([L(),n.getAll("macros"),n.getAll("sessions"),n.getAll("user_memory"),n.getAll("element_cache")]);return{format:oe,version:Ae,exportedAt:new Date().toISOString(),appVersion:t.appVersion,includesSecrets:t.includeSecrets,data:{settings:t.includeSecrets?a:Ht(a),macros:i,sessions:r,userMemory:m,elementCache:o}}}async function Yt(t){const n=await We(),{data:a}=t;if(a.settings){const i=await L();await gt(qt(i,a.settings,t.includesSecrets))}for(const i of a.macros)await n.put("macros",i);for(const i of a.sessions)await n.put("sessions",i);for(const i of a.userMemory)await n.put("user_memory",i);for(const i of a.elementCache)await n.put("element_cache",i);return{settings:!!a.settings,macros:a.macros.length,sessions:a.sessions.length,userMemory:a.userMemory.length,elementCache:a.elementCache.length}}const Jt=[{title:"guide_mode_a_title",desc:"guide_mode_a_desc",tone:"text-modeA"},{title:"guide_mode_b_title",desc:"guide_mode_b_desc",tone:"text-modeB"},{title:"guide_mode_c_title",desc:"guide_mode_c_desc",tone:"text-modeC"}],Xt=[{title:"guide_step1_title",desc:"guide_step1_desc"},{title:"guide_step2_title",desc:"guide_step2_desc"},{title:"guide_step3_title",desc:"guide_step3_desc"}],Qt=["guide_free_byok","guide_free_modes","guide_free_instructions","guide_free_replay"],Zt=[{title:"guide_pro_sessions_title",desc:"guide_pro_sessions_desc"},{title:"guide_pro_scheduled_title",desc:"guide_pro_scheduled_desc"},{title:"guide_pro_mcp_title",desc:"guide_pro_mcp_desc"},{title:"guide_pro_import_title",desc:"guide_pro_import_desc"},{title:"guide_pro_translate_title",desc:"guide_pro_translate_desc"},{title:"guide_pro_scenarios_title",desc:"guide_pro_scenarios_desc"},{title:"guide_pro_memory_title",desc:"guide_pro_memory_desc"},{title:"guide_pro_pierce_title",desc:"guide_pro_pierce_desc"},{title:"guide_pro_xpath_title",desc:"guide_pro_xpath_desc"},{title:"guide_pro_bookmarks_title",desc:"guide_pro_bookmarks_desc"},{title:"guide_pro_selfheal_title",desc:"guide_pro_selfheal_desc"}];function es(){return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:s("guide_title")}),e.jsx("p",{className:"mt-1 text-sm text-ink-3 leading-relaxed max-w-2xl",children:s("guide_intro")}),e.jsx("div",{className:"mt-3 max-w-2xl rounded-lg border border-brand-2 bg-brand-bg px-3 py-2 text-sm text-brand-ink font-medium",children:s("guide_hero_cheap_model")})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-sm font-medium text-ink-2 mb-3",children:s("guide_modes_title")}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:Jt.map(t=>e.jsxs("div",{className:"rounded-xl border border-line-soft bg-bg-soft p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-mono text-sm font-medium ${t.tone}`,children:s(t.title)}),e.jsx("span",{className:"ml-auto text-[10px] px-1.5 py-0.5 rounded bg-bg-app text-ink-4",children:s("guide_tag_free")})]}),e.jsx("p",{className:"mt-1.5 text-xs text-ink-3 leading-relaxed",children:s(t.desc)})]},t.title))})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-sm font-medium text-ink-2 mb-3",children:s("guide_start_title")}),e.jsx("ol",{className:"space-y-2.5",children:Xt.map((t,n)=>e.jsxs("li",{className:"flex gap-3",children:[e.jsx("span",{className:"w-5 h-5 shrink-0 mt-0.5 rounded-full bg-brand text-brand-ink text-xs font-mono font-bold flex items-center justify-center",children:n+1}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-ink-1",children:s(t.title)}),e.jsx("div",{className:"text-xs text-ink-3 leading-relaxed",children:s(t.desc)})]})]},t.title))}),e.jsx("button",{type:"button",className:"yk-btn is-sm mt-3",onClick:()=>{location.hash="models"},children:s("guide_start_cta")})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-sm font-medium text-ink-2 mb-2",children:s("guide_free_title")}),e.jsx("ul",{className:"space-y-1.5",children:Qt.map(t=>e.jsxs("li",{className:"text-sm text-ink-2 flex gap-2",children:[e.jsx("span",{className:"text-modeC",children:"✓"}),e.jsx("span",{children:s(t)})]},t))})]}),e.jsxs("section",{className:"rounded-xl border border-line-soft bg-bg-soft p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink-1",children:s("guide_pro_title")}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-brand text-brand-ink font-bold tracking-wide",children:"PRO"})]}),e.jsx("p",{className:"mt-1 text-xs text-ink-3 leading-relaxed",children:s("guide_pro_lead")}),e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-x-5 gap-y-3",children:Zt.map(t=>e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-ink-1",children:s(t.title)}),e.jsx("div",{className:"text-xs text-ink-3 leading-relaxed",children:s(t.desc)})]},t.title))}),e.jsx("button",{type:"button",className:"yk-btn yk-btn-primary is-sm mt-4",onClick:()=>void A(),children:s("guide_upgrade_btn")})]})]})}async function ts(t){try{return await t.queryPermission({mode:"read"})}catch{return"granted"}}async function B(){const t=await Rt();return Promise.all(t.map(async n=>({...n,perm:await ts(n.handle)})))}function ss(){const[t,n]=x.useState(null),[a,i]=x.useState(null);if(x.useEffect(()=>{X("local_files").then(c=>n(!c)),B().then(i)},[]),!Ft())return e.jsx(rs,{});if(t===null||!a)return null;if(t)return e.jsx(ls,{});async function r(){let c;try{c=await showDirectoryPicker({mode:"read",startIn:"downloads"})}catch{return}try{await c.requestPermission({mode:"read"})}catch{}await It(c),i(await B())}async function m(c){try{await c.handle.requestPermission({mode:"read"})}catch{}i(await B())}async function o(c){await Ot(c),i(await B())}return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-line bg-bg-soft px-3.5 py-3",children:[e.jsx("span",{className:"flex h-[34px] w-[34px] shrink-0 items-center justify-center rounded-lg border border-line bg-bg-app text-ink-2",children:e.jsx(pe,{size:17,strokeWidth:1.5})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-md font-semibold text-ink-1",children:s("opts_sec_localfiles")}),e.jsx("div",{className:"mt-0.5 text-xs text-ink-3",children:s("opts_lf_banner_sub")})]}),e.jsx("span",{className:"rounded bg-bg-inset px-1.5 py-px font-mono text-xs font-bold uppercase tracking-wide text-ink-2",children:"Pro"})]}),e.jsx(J,{}),a.length===0?e.jsx(is,{onAdd:()=>void r()}):e.jsxs(e.Fragment,{children:[e.jsx(ns,{children:`${s("opts_lf_configured")} · ${a.length}`}),a.map(c=>e.jsx(as,{folder:c,onRegrant:()=>void m(c),onRemove:()=>void o(c.id)},c.id)),e.jsxs("div",{className:"px-3.5 pb-4 pt-3",children:[e.jsxs("button",{type:"button",onClick:()=>void r(),className:"flex w-full items-center justify-center gap-2 rounded-lg border border-dashed border-line py-2 text-sm font-medium text-ink-2 hover:bg-bg-soft",children:[e.jsx(P,{size:14,strokeWidth:2}),s("opts_lf_add")]}),e.jsx("div",{className:"mt-2 text-sm leading-relaxed text-ink-4",children:s("opts_lf_add_hint")})]})]})]})}function ns({children:t}){return e.jsxs("div",{className:"flex items-center gap-2 px-3.5 pb-1.5 pt-3.5 font-mono text-xs uppercase tracking-wider text-ink-3",children:[e.jsx("span",{children:t}),e.jsx("span",{className:"h-px flex-1 bg-line-soft"})]})}function as(t){const{folder:n}=t,a=n.perm!=="granted";return e.jsxs("div",{className:`grid grid-cols-[30px_1fr_auto] items-center gap-[11px] border-b border-line-soft px-3.5 py-[11px] ${a?"bg-[#fdf6f4]":""}`,children:[e.jsx("span",{className:"flex h-[30px] w-[30px] items-center justify-center rounded-lg border border-line bg-bg-app text-ink-3",children:e.jsx(De,{size:16,strokeWidth:1.5})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-[7px]",children:[e.jsx("span",{className:"truncate text-base font-semibold text-ink-1",children:n.name}),e.jsx("span",{className:"shrink-0 rounded bg-bg-inset px-1.5 py-px font-mono text-xs text-ink-3",children:s("opts_lf_readonly_badge")})]}),e.jsx("div",{className:`mt-0.5 truncate text-xs ${a?"text-err":"text-ink-4"}`,children:a?s("opts_lf_perm_lapsed"):s("opts_lf_perm_ok")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[a&&e.jsxs("button",{type:"button",onClick:t.onRegrant,className:"flex items-center gap-1.5 rounded-md border border-brand-2 bg-brand px-2.5 py-1.5 text-sm font-medium text-brand-ink hover:bg-brand-2",children:[e.jsx(Bt,{size:13,strokeWidth:1.5}),s("opts_lf_regrant")]}),e.jsx("button",{type:"button",onClick:t.onRemove,"aria-label":s("opts_lf_remove_aria"),className:"flex h-[26px] w-[26px] items-center justify-center rounded-md border border-line bg-bg-app text-ink-3 hover:border-[#eccbc4] hover:bg-[#fff8f6] hover:text-err",children:e.jsx(W,{size:14,strokeWidth:1.5})})]})]})}function is(t){return e.jsxs("div",{className:"px-[18px] pb-[18px] pt-[18px]",children:[e.jsx("div",{className:"mb-3 flex h-[46px] w-[46px] items-center justify-center rounded-xl border border-line bg-bg-soft text-ink-2",children:e.jsx(De,{size:22,strokeWidth:1.5})}),e.jsx("div",{className:"text-xl font-semibold leading-snug text-ink-1",children:s("opts_lf_empty_title")}),e.jsx("div",{className:"mt-1.5 text-base leading-relaxed text-ink-3",children:s("opts_lf_empty_desc")}),e.jsxs("button",{type:"button",onClick:t.onAdd,className:"mt-3.5 flex w-full items-center justify-center gap-2 rounded-lg border border-brand-2 bg-brand py-2 text-base font-medium text-brand-ink hover:bg-brand-2",children:[e.jsx(P,{size:14,strokeWidth:2}),s("opts_lf_empty_cta")]})]})}function rs(){return e.jsx("section",{children:e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-line bg-bg-soft px-3.5 py-3",children:[e.jsx("span",{className:"flex h-[34px] w-[34px] shrink-0 items-center justify-center rounded-lg border border-line bg-bg-app text-ink-3",children:e.jsx(pe,{size:17,strokeWidth:1.5})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-md font-semibold text-ink-1",children:s("opts_sec_localfiles")}),e.jsx("div",{className:"mt-0.5 text-sm leading-relaxed text-ink-3",children:s("opts_lf_unsupported")})]})]})})}function ls(){return e.jsx("section",{children:e.jsxs("div",{className:"rounded-xl border border-line bg-bg-soft p-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-line bg-bg-app text-ink-2",children:e.jsx(O,{size:17,strokeWidth:1.5})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-lg font-semibold text-ink-1",children:s("opts_lf_locked_title")}),e.jsx("div",{className:"mt-0.5 text-sm text-ink-3",children:s("opts_lf_locked_sub")})]})]}),e.jsx("div",{className:"mt-3 flex flex-col gap-1.5",children:[s("opts_lf_locked_b1"),s("opts_lf_locked_b2"),s("opts_lf_locked_b3")].map(t=>e.jsxs("div",{className:"flex items-center gap-2 text-base text-ink-2",children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-brand-2 text-white",children:e.jsx(S,{size:10,strokeWidth:2.5})}),t]},t))}),e.jsx("button",{type:"button",onClick:()=>void A(),className:"mt-3.5 flex w-full items-center justify-center gap-2 rounded-lg border border-brand-2 bg-brand py-2 text-base font-medium text-brand-ink hover:bg-brand-2",children:s("opts_lf_locked_cta")}),e.jsx("div",{className:"mt-2 text-center font-mono text-xs text-ink-4",children:s("opts_lf_locked_note")})]})})}const V="http://127.0.0.1:8765/mcp",os=["read_file","list_directory"],ke=5e3;async function je(t,n){const a=Date.now(),i=await Le({url:V},t).listTools(n).catch(()=>null),r=Date.now()-a>=t*.8;if(i!=null&&i.ok){const m=new Set(i.value.map(c=>c.name));return{probe:os.every(c=>m.has(c))?{status:"found"}:{status:"absent"},timedOut:r}}return i&&i.error.kind==="auth"?{probe:{status:"needs_auth"},timedOut:r}:{probe:{status:"absent"},timedOut:r}}async function cs(t){const n=await je(ke,t);return n.probe.status!=="absent"||!n.timedOut?n.probe:(await je(ke*2,t)).probe}function ds(){var T;const[t,n]=x.useState(null),[a,i]=x.useState(null),[r,m]=x.useState(null),[o,c]=x.useState(null),[h,j]=x.useState(!1),[v,f]=x.useState(null);if(x.useEffect(()=>{kt().then(n),X("mcp").then(_=>m(!_))},[]),x.useEffect(()=>{if(r!==!1||!t||t.some(u=>u.url===V))return;let _=!1;const p=new AbortController;return cs(p.signal).then(u=>{_||c(u)}),()=>{_=!0,p.abort()}},[r,t]),r===null||!t)return null;if(r)return e.jsx(ks,{});async function d(){const _=t??[],p=fe("Local files",_.map(u=>u.slug).filter(u=>!!u));await w([..._,{id:Y(),label:"Local files",slug:p,url:V,enabled:!0,createdAt:Date.now(),description:s("opts_mcp_detected_desc_added")}]),c(null),f(s("opts_mcp_added_notice"))}function b(){c(null),i({editing:{id:"",label:"Local files",url:V,enabled:!0,createdAt:0}})}const y=!h&&((o==null?void 0:o.status)==="found"||(o==null?void 0:o.status)==="needs_auth");async function w(_){n(_),await jt(_)}async function g(_,p){const u=t??[],k=_?u.map(M=>M.id===_?{...M,...p}:M):[...u,{...p,id:Y(),slug:fe(p.label,u.map(M=>M.slug).filter(M=>!!M)),createdAt:Date.now()}];await w(k),i(null)}return a?e.jsx("section",{children:e.jsx(_s,{initial:a.editing,onCancel:()=>i(null),onSubmit:_=>{var p;return g((p=a.editing)==null?void 0:p.id,_)},onDelete:(T=a.editing)!=null&&T.id?async()=>{await w((t??[]).filter(_=>{var p;return _.id!==((p=a.editing)==null?void 0:p.id)})),i(null)}:void 0})}):e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-mcp-line bg-gradient-to-b from-mcp-bg to-[#f6f4fc] px-3.5 py-3",children:[e.jsx("span",{className:"flex h-[34px] w-[34px] shrink-0 items-center justify-center rounded-lg border border-mcp-line bg-bg-app text-mcp",children:e.jsx(Kt,{size:17,strokeWidth:1.5})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-md font-semibold text-mcp-ink",children:s("opts_sec_mcp")}),e.jsx("div",{className:"mt-0.5 text-xs text-mcp-ink/70",children:s("opts_mcp_banner_sub")})]}),e.jsx("span",{className:"rounded bg-mcp-bg px-1.5 py-px font-mono text-xs font-bold uppercase tracking-wide text-mcp-ink",children:"Pro"})]}),e.jsx(J,{}),v&&e.jsx(ms,{text:v,onClose:()=>f(null)}),y&&o&&e.jsx(xs,{needsAuth:o.status==="needs_auth",onAdd:()=>o.status==="needs_auth"?b():void d(),onDismiss:()=>j(!0)}),t.length===0?e.jsx(fs,{onAdd:()=>i({}),onTemplate:_=>i(bs(_))}):e.jsxs(e.Fragment,{children:[e.jsx(Fe,{right:s("opts_mcp_auth_local"),children:`${s("opts_mcp_configured")} · ${t.length}`}),t.map(_=>e.jsx(us,{server:_,onToggle:p=>w(t.map(u=>u.id===_.id?{...u,enabled:p}:u)),onEdit:()=>i({editing:_}),onDelete:()=>w(t.filter(p=>p.id!==_.id))},_.id)),e.jsxs("div",{className:"px-3.5 pb-4 pt-3",children:[e.jsxs("button",{type:"button",onClick:()=>i({}),className:"flex w-full items-center justify-center gap-2 rounded-lg border border-dashed border-mcp-line py-2 text-sm font-medium text-mcp-ink hover:bg-mcp-bg/40",children:[e.jsx(P,{size:14,strokeWidth:2}),s("opts_mcp_add")]}),e.jsx("div",{className:"mt-2 text-sm leading-relaxed text-ink-4",children:s("opts_mcp_add_hint")})]})]})]})}function Fe({children:t,right:n}){return e.jsxs("div",{className:"flex items-center gap-2 px-3.5 pb-1.5 pt-3.5 font-mono text-xs uppercase tracking-wider text-ink-3",children:[e.jsx("span",{children:t}),e.jsx("span",{className:"h-px flex-1 bg-line-soft"}),n&&e.jsx("span",{className:"normal-case tracking-normal text-ink-4",children:n})]})}function xs(t){return e.jsxs("div",{className:"mt-2 flex items-center gap-3 rounded-xl border border-mcp-line bg-mcp-bg/50 px-3.5 py-3",children:[e.jsx("span",{className:"flex h-[34px] w-[34px] shrink-0 items-center justify-center rounded-lg border border-mcp-line bg-bg-app text-mcp",children:e.jsx(pe,{size:17,strokeWidth:1.5})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-md font-semibold text-mcp-ink",children:s("opts_mcp_detected_title")}),e.jsx("div",{className:"mt-0.5 text-xs text-mcp-ink/70",children:t.needsAuth?s("opts_mcp_detected_sub_auth"):s("opts_mcp_detected_sub")})]}),e.jsx("button",{type:"button",onClick:t.onDismiss,className:"rounded-lg px-2.5 py-1.5 text-sm text-ink-3 hover:bg-bg-app",children:s("opts_mcp_detected_dismiss")}),e.jsxs("button",{type:"button",onClick:t.onAdd,className:"flex items-center gap-1.5 rounded-lg border border-brand-2 bg-brand px-3 py-1.5 text-sm font-medium text-brand-ink hover:bg-brand-2",children:[e.jsx(P,{size:14,strokeWidth:2}),s("opts_mcp_detected_add")]})]})}function ms({text:t,onClose:n}){return e.jsxs("div",{className:"mt-2 flex items-center gap-2 rounded-lg border border-[#c9dcbe] bg-ok-bg px-3 py-2.5 text-sm text-ok",children:[e.jsx(S,{size:14,strokeWidth:2}),e.jsx("span",{className:"flex-1 font-medium",children:t}),e.jsx("button",{type:"button",onClick:n,"aria-label":s("opts_mcp_cancel"),className:"text-ok/70 hover:text-ok",children:e.jsx(re,{size:14,strokeWidth:2})})]})}function ps({server:t}){var r;const n=((r=t.lastTest)==null?void 0:r.status)??"idle",i={ok:{cls:"bg-ok-bg text-ok border-[#c9dcbe]",label:s("opts_mcp_status_ok")},fail:{cls:"bg-err-bg text-err border-[#ebc9c2]",label:s("opts_mcp_status_fail")},idle:{cls:"bg-bg-soft text-ink-3 border-line",label:s("opts_mcp_status_idle")}}[n];return e.jsx("span",{className:`rounded border px-1.5 py-px font-mono text-xs ${i.cls}`,children:i.label})}function Re({on:t,onClick:n}){return e.jsx("button",{type:"button",onClick:n,"aria-pressed":t,"aria-label":s("opts_mcp_enabled"),className:`relative h-[18px] w-[30px] shrink-0 rounded-full transition-colors duration-fast ${t?"bg-brand-2":"bg-ink-4"}`,children:e.jsx("span",{className:`absolute top-0.5 h-3.5 w-3.5 rounded-full bg-white transition-all duration-fast ${t?"left-3.5":"left-0.5"}`})})}function us(t){var r,m,o;const{server:n}=t,a=((r=n.lastTest)==null?void 0:r.status)==="fail",i=a?Me((m=n.lastTest)==null?void 0:m.errKind).settings:((o=n.lastTest)==null?void 0:o.status)==="ok"?`${s("opts_mcp_tools_n",String(n.lastTest.tools??0))}${n.description?` · ${n.description}`:""}`:n.description??n.url;return e.jsxs("div",{className:`grid grid-cols-[30px_1fr_auto_auto] items-center gap-[11px] border-b border-line-soft px-3.5 py-[11px] ${a?"bg-[#fdf6f4]":""}`,children:[e.jsx(de,{label:n.label,size:30}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-[7px]",children:[e.jsx("span",{className:"text-base font-semibold text-ink-1",children:n.label}),e.jsxs("span",{className:"rounded bg-mcp-bg px-1.5 py-px font-mono text-xs text-mcp-ink",title:s("opts_mcp_slug_hint"),children:["mcp:",vt(n)]}),e.jsx(ps,{server:n})]}),e.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-ink-3",children:n.url}),e.jsx("div",{className:`mt-0.5 truncate text-xs ${a?"font-mono text-err":"text-ink-4"}`,children:i})]}),e.jsx(Re,{on:n.enabled,onClick:()=>t.onToggle(!n.enabled)}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:t.onEdit,"aria-label":s("opts_mcp_edit_aria"),className:"flex h-[26px] w-[26px] items-center justify-center rounded-md border border-line bg-bg-app text-ink-3 hover:bg-bg-soft hover:text-ink-1",children:e.jsx(xe,{size:14,strokeWidth:1.5})}),e.jsx("button",{type:"button",onClick:t.onDelete,"aria-label":s("opts_mcp_remove_aria"),className:"flex h-[26px] w-[26px] items-center justify-center rounded-md border border-line bg-bg-app text-ink-3 hover:border-[#eccbc4] hover:bg-[#fff8f6] hover:text-err",children:e.jsx(W,{size:14,strokeWidth:1.5})})]})]})}const hs=[{label:"Notion",url:"https://mcp.notion.com/mcp"},{label:"Linear",url:"https://mcp.linear.app/mcp"},{label:"Sentry",url:"https://mcp.sentry.dev/mcp"}];function bs(t){return{editing:{id:"",label:t.label,url:t.url,enabled:!0,createdAt:0}}}function fs(t){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-[18px] pb-1.5 pt-[18px]",children:[e.jsx("div",{className:"mb-3 flex h-[46px] w-[46px] items-center justify-center rounded-xl border border-mcp-line bg-mcp-bg text-mcp",children:e.jsx(Te,{size:22,strokeWidth:1.5})}),e.jsx("div",{className:"text-xl font-semibold leading-snug text-ink-1",children:s("opts_mcp_empty_title")}),e.jsx("div",{className:"mt-1.5 text-base leading-relaxed text-ink-3",children:s("opts_mcp_empty_desc")}),e.jsxs("button",{type:"button",onClick:t.onAdd,className:"mt-3.5 flex w-full items-center justify-center gap-2 rounded-lg border border-brand-2 bg-brand py-2 text-base font-medium text-brand-ink hover:bg-brand-2",children:[e.jsx(P,{size:14,strokeWidth:2}),s("opts_mcp_empty_cta")]})]}),e.jsx(Fe,{right:s("opts_mcp_templates_hint"),children:s("opts_mcp_templates")}),e.jsx("div",{className:"flex flex-col gap-2 px-3.5 pb-[18px] pt-0.5",children:hs.map(n=>e.jsxs("button",{type:"button",onClick:()=>t.onTemplate(n),className:"grid grid-cols-[28px_1fr_auto] items-center gap-[11px] rounded-lg border border-line bg-bg-app px-3 py-2.5 text-left hover:bg-bg-soft",children:[e.jsx(de,{label:n.label,size:28}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-base font-semibold text-ink-1",children:n.label}),e.jsx("div",{className:"truncate font-mono text-xs text-ink-3",children:n.url})]}),e.jsx("span",{className:"text-mcp",children:e.jsx(P,{size:14,strokeWidth:2})})]},n.label))})]})}function _s(t){const n=t.initial,[a,i]=x.useState((n==null?void 0:n.label)??""),[r,m]=x.useState((n==null?void 0:n.url)??""),[o,c]=x.useState((n==null?void 0:n.authHeader)??""),[h,j]=x.useState((n==null?void 0:n.enabled)??!0),[v,f]=x.useState(!1),[d,b]=x.useState({status:"idle"});function y(){const g=d.status==="ok"?{status:"ok",tools:d.tools,at:Date.now()}:d.status==="fail"?{status:"fail",errKind:d.error.kind,at:Date.now()}:n==null?void 0:n.lastTest;return{label:a.trim()||r.trim(),url:r.trim(),authHeader:o.trim()||void 0,enabled:h,description:n==null?void 0:n.description,lastTest:g}}async function w(){if(!r.trim())return;b({status:"testing"});const g=Date.now(),T=await Le({url:r.trim(),authHeader:o.trim()||void 0}).listTools().catch(_=>({ok:!1,error:{kind:"protocol",message:String(_)}}));T.ok?b({status:"ok",tools:T.value.length,latencyMs:Date.now()-g}):b({status:"fail",error:T.error})}return e.jsxs("div",{className:"rounded-xl border border-line",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-line-soft px-3.5 py-2.5",children:[e.jsx("span",{className:"text-md font-semibold",children:n!=null&&n.id?s("opts_mcp_edit_title"):s("opts_mcp_add_title")}),e.jsx("span",{className:"ml-auto rounded bg-mcp-bg px-1.5 py-px font-mono text-xs font-bold uppercase tracking-wide text-mcp-ink",children:"MCP"})]}),e.jsxs("div",{className:"space-y-3 p-3.5",children:[e.jsx(ne,{label:s("opts_mcp_form_label"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[a.trim()&&e.jsx(de,{label:a,size:18}),e.jsx("input",{value:a,onChange:g=>i(g.target.value),placeholder:"Notion",className:"w-full bg-transparent text-base text-ink-1 placeholder:text-ink-4 outline-none"})]})}),e.jsx(ne,{label:s("opts_mcp_form_url"),required:!0,hint:s("opts_mcp_url_hint"),mono:!0,icon:e.jsx(Ye,{size:14,strokeWidth:1.5}),children:e.jsx("input",{value:r,onChange:g=>{m(g.target.value),b({status:"idle"})},placeholder:"https://mcp.example.com/sse",className:"w-full bg-transparent font-mono text-sm text-ink-1 placeholder:text-ink-4 outline-none"})}),e.jsxs(ne,{label:s("opts_mcp_form_auth"),hint:s("opts_mcp_form_auth_hint"),mono:!0,icon:e.jsx(O,{size:13,strokeWidth:1.5}),children:[e.jsx("input",{type:v?"text":"password",value:o,onChange:g=>c(g.target.value),placeholder:"Bearer sk-...",className:"w-full bg-transparent font-mono text-sm text-ink-1 placeholder:text-ink-4 outline-none"}),e.jsx("button",{type:"button",onClick:()=>f(g=>!g),className:"text-ink-3 hover:text-ink-1","aria-label":v?"hide":"show",children:v?e.jsx(Je,{size:14,strokeWidth:1.5}):e.jsx(Xe,{size:14,strokeWidth:1.5})})]}),e.jsxs("div",{className:"flex items-center gap-2.5 py-1",children:[e.jsx(Re,{on:h,onClick:()=>j(g=>!g)}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-base font-medium text-ink-1",children:s("opts_mcp_enabled")}),e.jsx("div",{className:"text-sm text-ink-3",children:s("opts_mcp_enabled_sub")})]})]}),e.jsx("div",{className:"h-px bg-line-soft"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:w,disabled:!r.trim()||d.status==="testing",className:"flex items-center gap-1.5 rounded-lg border border-mcp-line bg-bg-app px-3 py-1.5 text-sm font-medium text-mcp-ink hover:bg-mcp-bg/40 disabled:cursor-not-allowed disabled:opacity-40",children:[e.jsx(Te,{size:13,strokeWidth:1.5}),d.status==="testing"?s("opts_mcp_testing"):s("opts_mcp_test")]}),e.jsx("span",{className:"text-sm text-ink-4",children:s("opts_mcp_test_hint")})]}),e.jsx(gs,{test:d})]}),e.jsxs("div",{className:"flex items-center gap-2 rounded-b-xl border-t border-line-soft bg-bg-soft px-3.5 py-3",children:[t.onDelete&&e.jsxs("button",{type:"button",onClick:t.onDelete,className:"mr-auto flex items-center gap-1.5 rounded-lg border border-[#eccbc4] bg-[#fff8f6] px-3 py-1.5 text-sm font-medium text-err",children:[e.jsx(W,{size:13,strokeWidth:1.5}),s("opts_mcp_delete")]}),e.jsx("button",{type:"button",onClick:t.onCancel,className:`rounded-lg px-3 py-1.5 text-sm text-ink-2 hover:bg-bg-app ${t.onDelete?"":"ml-auto"}`,children:s("opts_mcp_cancel")}),e.jsxs("button",{type:"button",onClick:()=>t.onSubmit(y()),disabled:!r.trim(),className:"flex items-center gap-1.5 rounded-lg border border-brand-2 bg-brand px-4 py-1.5 text-sm font-medium text-brand-ink hover:bg-brand-2 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(S,{size:14,strokeWidth:2}),s("opts_mcp_save")]})]})]})}function ne(t){return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 font-mono text-xs uppercase tracking-wider text-ink-3",children:[e.jsx("span",{children:t.label}),t.required&&e.jsx("span",{className:"text-mcp",children:s("opts_mcp_url_required")})]}),e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-line bg-bg-app px-2.5 py-2 focus-within:border-mcp-2 focus-within:shadow-ring-mcp",children:[t.icon&&e.jsx("span",{className:"text-ink-3",children:t.icon}),t.children]}),t.hint&&e.jsx("div",{className:"mt-1.5 text-xs text-ink-4",children:t.hint})]})}function gs({test:t}){if(t.status==="idle")return null;if(t.status==="testing")return e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-mcp-line bg-mcp-bg px-3 py-2.5 text-sm text-mcp-ink",children:[e.jsx("span",{className:"h-3.5 w-3.5 animate-yk-spin rounded-full border-[1.6px] border-bg-inset border-t-mcp-2"}),s("opts_mcp_testing_long")]});if(t.status==="ok")return e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-[#c9dcbe] bg-ok-bg px-3 py-2.5",children:[e.jsx("span",{className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full bg-ok text-white",children:e.jsx(S,{size:11,strokeWidth:2.5})}),e.jsx("span",{className:"text-base font-semibold text-ok",children:s("opts_mcp_test_ok",String(t.tools))}),e.jsx("span",{className:"flex-1"}),e.jsxs("span",{className:"font-mono text-xs text-ink-4",children:[t.latencyMs,"ms"]})]});const n=Me(t.error.kind),a=n.warn;return e.jsxs("div",{className:`rounded-lg border px-3 py-2.5 ${a?"border-[#e7d2ab] bg-warn-bg":"border-[#ebc9c2] bg-err-bg"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full text-xs font-bold text-white ${a?"bg-warn":"bg-err"}`,children:"!"}),e.jsx("span",{className:`font-mono text-sm font-semibold ${a?"text-warn":"text-err"}`,children:n.settings})]}),e.jsxs("div",{className:`mt-1.5 pl-[26px] text-xs leading-relaxed ${a?"text-[#7d4d18]":"text-[#7a2c1e]"}`,children:["↳ ",n.fix]})]})}function ks(){return e.jsx("section",{children:e.jsxs("div",{className:"rounded-xl border border-mcp-line bg-gradient-to-b from-mcp-bg to-[#f6f4fc] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-mcp-line bg-bg-app text-mcp",children:e.jsx(O,{size:17,strokeWidth:1.5})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-lg font-semibold text-mcp-ink",children:s("opts_mcp_locked_title")}),e.jsx("div",{className:"mt-0.5 text-sm text-mcp-ink/70",children:s("opts_mcp_locked_sub")})]})]}),e.jsx("div",{className:"mt-3 flex flex-col gap-1.5",children:[s("opts_mcp_locked_b1"),s("opts_mcp_locked_b2"),s("opts_mcp_locked_b3")].map(t=>e.jsxs("div",{className:"flex items-center gap-2 text-base text-ink-2",children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-mcp text-white",children:e.jsx(S,{size:10,strokeWidth:2.5})}),t]},t))}),e.jsx("button",{type:"button",onClick:()=>void A(),className:"mt-3.5 flex w-full items-center justify-center gap-2 rounded-lg border border-mcp-2 bg-mcp py-2 text-base font-medium text-white hover:bg-mcp-2",children:s("opts_mcp_locked_cta")}),e.jsx("div",{className:"mt-2 text-center font-mono text-xs text-ink-4",children:s("opts_mcp_locked_note")})]})})}const js=[{key:"plans_free_f1"},{key:"plans_free_f2"},{key:"plans_free_f3"},{key:"plans_free_f4"},{key:"plans_free_f5"},{key:"plans_free_f6"},{key:"plans_free_f7"},{key:"plans_free_f8"},{key:"plans_free_f10"},{key:"plans_free_f9"}],vs=[{key:"plans_pro_f1"},{key:"plans_pro_f11"},{key:"plans_pro_f2"},{key:"plans_pro_f3"},{key:"plans_pro_f4"},{key:"plans_pro_f6"},{key:"plans_pro_f7"},{key:"plans_pro_f8"},{key:"plans_pro_f10"},{key:"plans_pro_f9"}];function ys(){const[t,n]=x.useState("yearly");return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h2",{className:"text-lg font-medium",children:s("plans_sec_title")})}),e.jsx(Ns,{value:t,onChange:n})]}),e.jsx("div",{className:"text-sm text-ink-3 mb-4",children:s("plans_sec_desc")}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2 items-start",children:[e.jsx(Ss,{name:s("plans_free_name"),tag:"BYOK · OSS",price:"$0",features:js,cta:e.jsx("button",{type:"button",className:"yk-btn w-full justify-center",disabled:!0,children:s("plans_free_cta")})}),e.jsx(Cs,{billing:t})]})]})}function Ns(t){return e.jsx("div",{className:"inline-flex items-center rounded-lg border border-line bg-bg-soft p-0.5 text-sm",children:["yearly","monthly"].map(n=>{const a=t.value===n;return e.jsx("button",{type:"button",onClick:()=>t.onChange(n),className:`px-2.5 py-1 rounded-md transition-colors duration-fast ${a?"bg-bg-app text-ink-1 font-medium shadow-sm":"text-ink-3"}`,children:s(n==="yearly"?"plans_billing_yearly":"plans_billing_monthly")},n)})})}function ws(){return Nt()==="zh_CN"?"alipay":"google"}function Cs(t){const n=t.billing==="yearly",[a,i]=x.useState(null),[r,m]=x.useState(!1),[o,c]=x.useState(!1),h=x.useCallback(async()=>{const b=await le();i((b==null?void 0:b.accountId)??null),m(await yt())},[]);x.useEffect(()=>{h();const b=()=>void h();return window.addEventListener("focus",b),()=>window.removeEventListener("focus",b)},[h]);async function j(){c(!0);const b=await et(ws());c(!1),b.status==="ok"&&await h()}const v=b=>a&&Qe&&r?Ze({accountId:a,billing:b}):null,f=v(t.billing),d=v("onetime");return e.jsxs("div",{className:"relative rounded-2xl border-2 border-brand-2 bg-bg-app p-5 flex flex-col shadow-glow-brand",children:[e.jsxs("div",{className:"absolute -top-2.5 left-4 yk-chip yk-chip-brand",children:[e.jsx(R,{size:11,strokeWidth:2}),s("plans_recommended")]}),e.jsx("div",{className:"font-mono text-xs uppercase tracking-wider text-brand-ink",children:s("plans_pro_name")}),e.jsxs("div",{className:"flex items-baseline gap-1.5 mt-1",children:[e.jsx("span",{className:"text-3xl font-bold font-mono text-ink-1 tracking-tight",children:n?"$59":"$9"}),e.jsx("span",{className:"text-md text-ink-3",children:n?s("plans_per_yr"):s("plans_per_mo")}),n&&e.jsx("span",{className:"yk-chip yk-chip-brand ml-1",children:s("plans_save_pct")})]}),e.jsx("div",{className:"text-xs text-ink-3 mt-0.5 h-4",children:n?s("plans_pro_yearly_sub"):""}),e.jsxs("div",{className:"mt-3 inline-flex items-center gap-1.5 self-start yk-chip yk-chip-C",children:[e.jsx("span",{className:"font-mono font-bold",children:"0¢"}),s("plans_zero_badge")]}),e.jsx("div",{className:"mt-4 text-xs font-medium text-ink-3",children:s("plans_pro_inherits")}),e.jsx(Ie,{features:vs,className:"mt-1.5"}),f?e.jsx("a",{href:f,target:"_blank",rel:"noreferrer",className:"yk-btn yk-btn-primary w-full justify-center mt-4",children:s("plans_pro_checkout_cta")}):a?e.jsx("div",{className:"yk-btn w-full justify-center mt-4 cursor-default text-ink-3",children:s("plans_pro_beta_unlocked")}):e.jsx("button",{type:"button",onClick:()=>void j(),disabled:o,className:"yk-btn yk-btn-primary w-full justify-center mt-4 disabled:opacity-50",children:o?s("plans_pro_login_loading"):s("plans_pro_login_cta")}),d&&e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",className:"yk-btn w-full justify-center mt-2",children:s("plans_pro_onetime_cta")}),e.jsx("div",{className:"text-xs text-ink-3 mt-3 leading-relaxed",children:s("plans_pro_framing")})]})}function Ss(t){return e.jsxs("div",{className:"rounded-2xl border border-line bg-bg-app p-5 flex flex-col",children:[e.jsx("div",{className:"font-mono text-xs uppercase tracking-wider text-ink-3",children:t.name}),e.jsxs("div",{className:"flex items-baseline gap-1.5 mt-1",children:[e.jsx("span",{className:"text-3xl font-bold font-mono text-ink-1 tracking-tight",children:t.price}),t.unit&&e.jsx("span",{className:"text-md text-ink-3",children:t.unit})]}),e.jsx("div",{className:"text-xs text-ink-3 mt-0.5 h-4",children:t.tag}),e.jsx(Ie,{features:t.features}),e.jsx("div",{className:"mt-4",children:t.cta})]})}function Ie(t){return e.jsx("ul",{className:`${t.className??"mt-4"} space-y-1.5 text-sm text-ink-2 flex-1`,children:t.features.map(n=>e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(S,{size:14,strokeWidth:2,className:"text-modeC mt-0.5 shrink-0"}),e.jsxs("span",{children:[s(n.key),n.badge?e.jsx("span",{className:"yk-chip ml-1.5 align-middle text-[10px] font-mono uppercase tracking-wider text-ink-3",children:n.badge}):null]})]},n.key))})}function Ts(){const[t,n]=x.useState(void 0);x.useEffect(()=>{le().then(i=>n(i??null))},[]);const a=t==null?void 0:t.token;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{children:[e.jsxs("h2",{className:"text-lg font-medium mb-1 flex items-center gap-2",children:[e.jsx($t,{size:18,strokeWidth:1.6,className:"text-brand-ink"}),s("ref_title")]}),e.jsx("p",{className:"text-sm text-ink-3 leading-relaxed",children:s("ref_reward_note")})]}),t===void 0?e.jsx("div",{className:"text-sm text-ink-3",children:s("ref_loading")}):a?e.jsx(Ms,{token:a}):e.jsxs("section",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-ink-3",children:s("ref_login_prompt")}),e.jsx(Ee,{onLoggedIn:()=>void le().then(i=>n(i??null))})]}),e.jsx(Es,{token:a??null})]})}function Ms({token:t}){const[n,a]=x.useState({kind:"loading"});if(x.useEffect(()=>{let r=!0;return(async()=>{const[m,o]=await Promise.all([tt(t),st(t)]);if(r){if(m.status==="error"||o.status==="error"){const c=m.status==="error"?m.kind:"server";a({kind:"error",reason:ce(c)});return}a({kind:"ready",code:m.code,stats:o.stats})}})(),()=>{r=!1}},[t]),n.kind==="loading")return e.jsx("div",{className:"text-sm text-ink-3",children:s("ref_loading")});if(n.kind==="error")return e.jsx("div",{className:"rounded-xl border border-err/30 bg-err/5 px-4 py-3 text-sm text-ink-2",children:n.reason});const i=nt(n.code);return e.jsxs("section",{className:"rounded-xl border border-line bg-bg-app p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wider text-ink-3 mb-1",children:s("ref_your_code")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-2xl font-mono font-bold tracking-widest text-brand-ink",children:n.code}),e.jsx(ye,{value:n.code,label:s("ref_copy")})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wider text-ink-3 mb-1",children:s("ref_share_link")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{readOnly:!0,value:i,className:"flex-1 min-w-0 bg-bg-soft border border-line rounded-md px-3 py-1.5 text-xs font-mono text-ink-2 outline-none"}),e.jsx(ye,{value:i,label:s("ref_copy_link")})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 border-t border-line-soft pt-3",children:[e.jsx(ve,{value:n.stats.invites,label:s("ref_stats_invites"),unit:s("ref_unit_people")}),e.jsx(ve,{value:n.stats.earnedDays,label:s("ref_stats_earned"),unit:s("ref_unit_days")})]})]})}function Es({token:t}){const[n,a]=x.useState(""),[i,r]=x.useState({kind:"idle"});x.useEffect(()=>{L().then(o=>{var h;const c=(h=o.referral)==null?void 0:h.pendingCode;c&&(a(c),r({kind:"done",ok:!0,msg:s("ref_enter_pending")}))})},[]);async function m(){const o=n.trim().toUpperCase();if(!o)return;r({kind:"checking"});const c=await at(o);if(c.status==="error"){r({kind:"done",ok:!1,msg:ce(c.kind)});return}if(!c.valid){r({kind:"done",ok:!1,msg:s("ref_enter_invalid")});return}if(!t){await I({referral:{pendingCode:o}}),r({kind:"done",ok:!0,msg:s("ref_enter_pending")});return}const h=await it(t,o);if(h.status==="error"){r({kind:"done",ok:!1,msg:ce(h.kind)});return}if(h.bound){await I({referral:{pendingCode:void 0}}),r({kind:"done",ok:!0,msg:s("ref_enter_bound")});return}r({kind:"done",ok:!1,msg:Ps(h.reason)})}return e.jsxs("section",{className:"rounded-xl border border-line p-4 space-y-2",children:[e.jsx("div",{className:"text-base font-medium",children:s("ref_enter_title")}),e.jsx("div",{className:"text-sm text-ink-3",children:s("ref_enter_desc")}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{value:n,onChange:o=>{a(o.target.value),i.kind==="done"&&r({kind:"idle"})},placeholder:s("ref_enter_placeholder"),maxLength:12,className:"flex-1 min-w-0 bg-bg-app border border-line rounded-md px-3 py-2 text-sm font-mono tracking-widest uppercase text-ink-1 placeholder:text-ink-4 placeholder:tracking-normal placeholder:normal-case outline-none focus:border-brand-2"}),e.jsx("button",{type:"button",onClick:()=>void m(),disabled:i.kind==="checking"||!n.trim(),className:"yk-btn yk-btn-primary disabled:opacity-50",children:i.kind==="checking"?s("ref_loading"):s("ref_apply")})]}),i.kind==="done"&&e.jsx("div",{className:`text-sm mt-1 ${i.ok?"text-modeC":"text-err"}`,children:i.msg})]})}function ve({value:t,label:n,unit:a}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wider text-ink-3",children:n}),e.jsxs("div",{className:"mt-0.5",children:[e.jsx("span",{className:"text-2xl font-bold font-mono text-ink-1",children:t}),e.jsx("span",{className:"text-sm text-ink-3 ml-1",children:a})]})]})}function ye({value:t,label:n}){const[a,i]=x.useState(!1);return e.jsxs("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(t),i(!0),setTimeout(()=>i(!1),1500)}catch{}},className:"yk-btn is-sm shrink-0",children:[a?e.jsx(S,{size:13,strokeWidth:1.8,className:"text-modeC"}):e.jsx(Ut,{size:13,strokeWidth:1.6}),a?s("ref_copied"):n]})}function ce(t){return t==="network"?s("ref_err_network"):s("ref_err_generic")}function Ps(t){switch(t){case"self_referral":return s("ref_enter_self");case"already_bound":return s("ref_enter_already");case"unknown_code":return s("ref_enter_invalid");default:return s("ref_err_generic")}}function zs(){const[t,n]=x.useState(null),[a,i]=x.useState([]),[r,m]=x.useState(null);x.useEffect(()=>{X("scenarios").then(d=>n(!d)),L().then(d=>{var b;return i(((b=d.prompts)==null?void 0:b.scenarios)??[])})},[]);async function o(d){i(d),await I({prompts:{scenarios:d}})}function c(d){const b={...d,id:Y()};o([...a,b]),m(b.id)}function h(d,b){o(a.map(y=>y.id===d?{...y,...b}:y))}function j(d){o(a.filter(b=>b.id!==d)),r===d&&m(null)}if(t===null)return null;if(t)return e.jsx(Ds,{});const v=wt().toLowerCase().startsWith("zh")?"zh":"en",f=a.filter(d=>d.enabled).length;return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(R,{size:16,strokeWidth:1.7,className:"text-brand-ink"}),e.jsx("h2",{className:"text-lg font-medium",children:s("opts_scen_title")}),e.jsx(me,{}),a.length>0&&e.jsx("span",{className:"yk-chip text-[10px]",children:s("opts_scen_count",[String(f),String(a.length)])})]}),e.jsx("div",{className:"text-sm text-ink-3 mb-1",children:s("opts_scen_desc")}),e.jsx(J,{}),e.jsx("div",{className:"flex flex-col gap-2",children:a.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-line bg-bg-soft px-4 py-6 text-center",children:[e.jsx(rt,{size:20,strokeWidth:1.4,className:"mx-auto mb-2 text-ink-4"}),e.jsx("div",{className:"text-sm text-ink-3",children:s("opts_scen_empty")})]}):a.map(d=>r===d.id?e.jsx(Ws,{scenario:d,onChange:b=>h(d.id,b),onClose:()=>m(null),onDelete:()=>j(d.id)},d.id):e.jsx(Ls,{scenario:d,onToggle:()=>h(d.id,{enabled:!d.enabled}),onEdit:()=>m(d.id),onDelete:()=>j(d.id)},d.id))}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",className:"yk-btn is-sm",onClick:()=>c({title:"",body:"",enabled:!0}),children:[e.jsx(P,{size:13,strokeWidth:1.8}),s("opts_scen_add")]}),e.jsx("span",{className:"text-xs text-ink-4",children:s("opts_scen_templates")}),Lt(v).map(d=>e.jsxs("button",{type:"button",className:"yk-btn is-sm",onClick:()=>c({...d,enabled:!0}),children:[e.jsx(R,{size:12,strokeWidth:1.8}),d.title]},d.title))]})]})}function Ls(t){const{scenario:n}=t,a=n.body.trim().split(`
`)[0]??"";return e.jsxs("div",{className:`group flex items-center gap-3 rounded-xl border border-line bg-bg-app px-3 py-2.5 transition-colors hover:border-brand-2/50 ${n.enabled?"":"opacity-55"}`,children:[e.jsx(Oe,{on:n.enabled,onClick:t.onToggle,label:s("opts_scen_enabled")}),e.jsxs("button",{type:"button",onClick:t.onEdit,className:"min-w-0 flex-1 text-left",children:[e.jsx("div",{className:"text-sm font-medium text-ink-1 truncate",children:n.title.trim()||e.jsx("span",{className:"text-ink-4 italic font-normal",children:s("opts_scen_untitled")})}),a&&e.jsx("div",{className:"mt-0.5 text-xs text-ink-3 truncate",children:a})]}),e.jsxs("div",{className:"flex items-center gap-0.5 opacity-60 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{type:"button",onClick:t.onEdit,"aria-label":s("opts_scen_edit"),title:s("opts_scen_edit"),className:"shrink-0 w-7 h-7 inline-flex items-center justify-center rounded-md text-ink-3 hover:bg-bg-soft hover:text-ink-1",children:e.jsx(xe,{size:13,strokeWidth:1.6})}),e.jsx("button",{type:"button",onClick:t.onDelete,"aria-label":s("opts_scen_delete"),title:s("opts_scen_delete"),className:"shrink-0 w-7 h-7 inline-flex items-center justify-center rounded-md text-ink-4 hover:bg-[#fff8f6] hover:text-err",children:e.jsx(W,{size:13,strokeWidth:1.5})})]})]})}function Oe(t){return e.jsx("button",{type:"button",onClick:t.onClick,"aria-label":t.label,title:t.label,className:`shrink-0 w-9 h-5 rounded-full relative transition-colors ${t.on?"bg-brand":"bg-line"}`,children:e.jsx("span",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-bg-app shadow-sm transition-all ${t.on?"left-[18px]":"left-0.5"}`})})}function Ws(t){const{scenario:n}=t;return e.jsxs("div",{className:"rounded-xl border border-brand-2 bg-bg-app p-3 flex flex-col gap-2.5 shadow-glow-brand",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oe,{on:n.enabled,onClick:()=>t.onChange({enabled:!n.enabled}),label:s("opts_scen_enabled")}),e.jsx("input",{type:"text",value:n.title,onChange:a=>t.onChange({title:a.target.value}),placeholder:s("opts_scen_field_title"),className:"flex-1 rounded-lg border border-line bg-bg-app px-2.5 py-1.5 text-sm font-medium focus:border-brand-2 outline-none"})]}),e.jsx("textarea",{value:n.body,onChange:a=>t.onChange({body:a.target.value}),placeholder:s("opts_scen_body_ph"),rows:6,className:"w-full rounded-lg border border-line bg-bg-app px-2.5 py-2 text-sm leading-relaxed font-mono focus:border-brand-2 outline-none resize-y"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:t.onDelete,className:"yk-btn is-sm text-err",children:[e.jsx(W,{size:12,strokeWidth:1.6}),s("opts_scen_delete")]}),e.jsx("span",{className:"flex-1"}),e.jsxs("button",{type:"button",onClick:t.onClose,className:"yk-btn yk-btn-primary is-sm",children:[e.jsx(S,{size:13,strokeWidth:2}),s("opts_scen_done")]})]})]})}function Ds(){const t=["opts_scen_lock_b1","opts_scen_lock_b2","opts_scen_lock_b3"];return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(R,{size:16,strokeWidth:1.7,className:"text-brand-ink"}),e.jsx("h2",{className:"text-lg font-medium",children:s("opts_scen_title")})]}),e.jsxs("div",{className:"rounded-xl border border-brand-2 bg-gradient-to-b from-brand-bg to-bg-app p-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-brand-2 bg-bg-app text-brand-ink",children:e.jsx(O,{size:17,strokeWidth:1.5})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-lg font-semibold text-brand-ink",children:s("opts_scen_lock_title")}),e.jsx("div",{className:"mt-0.5 text-sm text-ink-3",children:s("opts_scen_lock_sub")})]})]}),e.jsx("div",{className:"mt-3 flex flex-col gap-1.5",children:t.map(n=>e.jsxs("div",{className:"flex items-center gap-2 text-sm text-ink-2",children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-brand-2 text-brand-ink",children:e.jsx(S,{size:10,strokeWidth:2.5})}),s(n)]},n))}),e.jsxs("button",{type:"button",onClick:()=>void A(),className:"yk-btn yk-btn-primary mt-3.5 w-full justify-center",children:[e.jsx(R,{size:13,strokeWidth:2}),s("opts_scen_lock_cta")]})]})]})}function As(t){return new Date(t).toISOString().slice(0,10)}function Fs(){const[t,n]=x.useState(null),[a,i]=x.useState([]),[r,m]=x.useState(ee);x.useEffect(()=>{X("user_memory").then(f=>n(!f)),ge().then(i),L().then(f=>{var d;return m(((d=f.userMemory)==null?void 0:d.maxEntries)??ee)})},[]);async function o(){i(await ge())}async function c(){await At("",3),await o()}async function h(f,d){i(b=>b.map(y=>y.id===f?{...y,...d}:y)),await Dt(f,d)}async function j(f){i(d=>d.filter(b=>b.id!==f)),await Wt(f)}async function v(f){const d=Math.max(1,Math.min(2e3,f||ee));m(d),await I({userMemory:{maxEntries:d}})}return t===null?null:t?e.jsx(Is,{}):e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(G,{size:16,strokeWidth:1.7,className:"text-brand-ink"}),e.jsx("h2",{className:"text-lg font-medium",children:s("opts_mem_title")}),e.jsx(me,{}),a.length>0&&e.jsx("span",{className:"yk-chip text-[10px]",children:s("opts_mem_count",[String(a.length),String(r)])})]}),e.jsx("div",{className:"text-sm text-ink-3 mb-1",children:s("opts_mem_desc")}),e.jsx(J,{}),e.jsxs("label",{className:"block mb-4 text-sm",children:[e.jsx("span",{className:"block mb-1 text-ink-2",children:s("opts_mem_max_label")}),e.jsx("input",{type:"number",min:1,max:2e3,step:50,value:r,onChange:f=>void v(Number.parseInt(f.target.value,10)),className:"w-28 bg-bg-app border border-line rounded-md px-2.5 py-1.5 text-sm outline-none focus:border-brand-2"}),e.jsx("span",{className:"block text-xs text-ink-4 mt-1",children:s("opts_mem_max_desc")})]}),e.jsx("div",{className:"flex flex-col gap-2",children:a.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-line bg-bg-soft px-4 py-6 text-center",children:[e.jsx(G,{size:20,strokeWidth:1.4,className:"mx-auto mb-2 text-ink-4"}),e.jsx("div",{className:"text-sm text-ink-3",children:s("opts_mem_empty")})]}):a.map(f=>e.jsx(Rs,{entry:f,onText:d=>void h(f.id,{text:d}),onLevel:d=>void h(f.id,{level:d}),onDelete:()=>void j(f.id)},f.id))}),e.jsx("div",{className:"mt-3",children:e.jsxs("button",{type:"button",className:"yk-btn is-sm",onClick:()=>void c(),children:[e.jsx(P,{size:13,strokeWidth:1.8}),s("opts_mem_add")]})})]})}function Rs(t){const{entry:n}=t;return e.jsxs("div",{className:"group flex items-start gap-2.5 rounded-xl border border-line bg-bg-app px-3 py-2.5 transition-colors hover:border-brand-2/50",children:[e.jsx("select",{value:n.level,onChange:a=>t.onLevel(Number.parseInt(a.target.value,10)),"aria-label":s("opts_mem_level"),title:s("opts_mem_level"),className:"shrink-0 mt-0.5 w-16 bg-bg-soft border border-line rounded-md px-1.5 py-1 text-xs font-mono text-brand-ink outline-none focus:border-brand-2",children:[1,2,3,4,5].map(a=>e.jsx("option",{value:a,children:"!".repeat(a)},a))}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("textarea",{value:n.text,onChange:a=>t.onText(a.target.value),rows:1,placeholder:s("opts_mem_text_ph"),className:"w-full resize-y bg-transparent text-sm text-ink-1 placeholder:text-ink-4 outline-none"}),e.jsx("div",{className:"mt-0.5 text-[11px] text-ink-4",children:s("opts_mem_updated",[As(n.updatedAt)])})]}),e.jsx("button",{type:"button",onClick:t.onDelete,"aria-label":s("opts_mem_delete"),title:s("opts_mem_delete"),className:"shrink-0 w-7 h-7 inline-flex items-center justify-center rounded-md text-ink-4 opacity-60 group-hover:opacity-100 hover:bg-[#fff8f6] hover:text-err transition-all",children:e.jsx(W,{size:13,strokeWidth:1.5})})]})}function Is(){const t=["opts_mem_lock_b1","opts_mem_lock_b2","opts_mem_lock_b3"];return e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(G,{size:16,strokeWidth:1.7,className:"text-brand-ink"}),e.jsx("h2",{className:"text-lg font-medium",children:s("opts_mem_title")})]}),e.jsxs("div",{className:"rounded-xl border border-brand-2 bg-gradient-to-b from-brand-bg to-bg-app p-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-brand-2 bg-bg-app text-brand-ink",children:e.jsx(O,{size:17,strokeWidth:1.5})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-lg font-semibold text-brand-ink",children:s("opts_mem_lock_title")}),e.jsx("div",{className:"mt-0.5 text-sm text-ink-3",children:s("opts_mem_lock_sub")})]})]}),e.jsx("div",{className:"mt-3 flex flex-col gap-1.5",children:t.map(n=>e.jsxs("div",{className:"flex items-center gap-2 text-sm text-ink-2",children:[e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-brand-2 text-brand-ink",children:e.jsx(S,{size:10,strokeWidth:2.5})}),s(n)]},n))}),e.jsxs("button",{type:"button",onClick:()=>void A(),className:"yk-btn yk-btn-primary mt-3.5 w-full justify-center",children:[e.jsx(G,{size:13,strokeWidth:2}),s("opts_mem_lock_cta")]})]})]})}const ae={openai:"gpt-4o-mini",anthropic:"claude-3-5-sonnet-latest",kimi:"kimi-k2-thinking",qwen:"qwen-plus",deepseek:"deepseek-v4",minimax:"MiniMax-M2",custom:"","custom-anthropic":"",managed:""},Os={openai:"https://api.openai.com/v1",anthropic:"https://api.anthropic.com/v1",kimi:"https://api.moonshot.cn/anthropic",qwen:"https://dashscope.aliyuncs.com/compatible-mode/v1",deepseek:"https://api.deepseek.com",minimax:"https://api.minimaxi.com/v1",custom:"https://api.example.com/v1","custom-anthropic":"https://your-claude-gateway.com/v1",managed:""};function Ne(t){return Os[t]??""}const Ue={modeA:"opts_prompt_mode_a_title",traceToMacro:"opts_prompt_trace_title",failureToPatch:"opts_prompt_heal_title"},Us={modeA:"opts_prompt_mode_a_desc",traceToMacro:"opts_prompt_trace_desc",failureToPatch:"opts_prompt_heal_desc"},$s={totalUsd:0,cacheSavedUsd:0,inputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,outputTokens:0},$e=[{key:"guide",label:"opts_cat_guide"},{key:"account",label:"opts_cat_account"},{key:"referral",label:"opts_cat_referral"},{key:"models",label:"opts_cat_models"},{key:"mcp",label:"opts_cat_mcp",pro:!0},{key:"localfiles",label:"opts_cat_localfiles",pro:!0},{key:"scenarios",label:"opts_cat_scenarios",pro:!0},{key:"memory",label:"opts_cat_user_memory",pro:!0},{key:"advanced",label:"opts_cat_advanced"},{key:"appearance",label:"opts_cat_appearance"},{key:"data",label:"opts_cat_data"}];function we(){if(typeof location>"u")return;const t=location.hash.replace(/^#/,"");return $e.some(n=>n.key===t)?t:void 0}function Bs(){var ue,he;const[t,n]=x.useState(null),[a,i]=x.useState(0),[r,m]=x.useState(0),[o,c]=x.useState($s),[h,j]=x.useState(0),[v,f]=x.useState(Number.POSITIVE_INFINITY),[d,b]=x.useState(!1),[y,w]=x.useState(null),[g,T]=x.useState(()=>we()??"guide"),[_,p]=x.useState(!1);if(x.useEffect(()=>{const l=()=>{const N=we();N&&T(N)};return window.addEventListener("hashchange",l),()=>window.removeEventListener("hashchange",l)},[]),x.useEffect(()=>{Promise.all([L().then(n),Ct().then(i),St().then(m),Tt().then(c),Mt().then(j),Et().then(l=>f(l.selfHealPerMonth))])},[]),!t)return e.jsx("div",{className:"p-8",children:s("opts_loading")});const u=t;async function k(l){await I(l),n(l)}async function M(l){const N={...l,id:Y(),createdAt:Date.now()},C={...u,llm:{...u.llm,providers:[...u.llm.providers,N],defaultProviderId:u.llm.defaultProviderId||N.id}};await k(C),b(!1)}async function Be(l,N){const C={...u,llm:{...u.llm,providers:u.llm.providers.map(E=>E.id===l?{...E,...N}:E)}};await k(C),w(null)}async function Ke(l){var C;const N={...u,llm:{...u.llm,providers:u.llm.providers.filter(E=>E.id!==l),defaultProviderId:u.llm.defaultProviderId===l?((C=u.llm.providers.find(E=>E.id!==l))==null?void 0:C.id)??"":u.llm.defaultProviderId}};await k(N)}async function He(l){await k({...u,llm:{...u.llm,defaultProviderId:l}})}const qe=Q(a,u.llm.displayCurrency??"USD"),Ve=Q(o.cacheSavedUsd,u.llm.displayCurrency??"USD"),U=Js(a,o.cacheSavedUsd);return e.jsxs("div",{className:"max-w-5xl mx-auto p-8",children:[e.jsxs("header",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-md bg-brand text-brand-ink font-mono font-bold flex items-center justify-center",children:"Y"}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-xl font-semibold tracking-tight",children:["yank · ",s("opts_title_suffix")]}),e.jsx("p",{className:"text-sm text-ink-3 mt-0.5",children:s("opts_intro")})]}),e.jsx("div",{className:"flex-1"}),e.jsx(en,{value:u.language??"auto",onChange:async l=>{Pt(l),await k({...u,language:l})}}),e.jsx(tn,{value:u.llm.displayCurrency??"USD",onChange:async l=>{await k({...u,llm:{...u.llm,displayCurrency:l}})}})]}),e.jsxs("div",{className:"flex gap-8 items-start mt-8",children:[e.jsx("nav",{className:"w-44 shrink-0 sticky top-8 flex flex-col gap-0.5",children:$e.map(l=>e.jsx("button",{type:"button",onClick:()=>T(l.key),className:`text-left px-3 py-2 rounded-lg text-sm transition-colors ${g===l.key?"bg-bg-soft text-ink-1 font-medium":"text-ink-3 hover:text-ink-1 hover:bg-bg-soft/60"}`,children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s(l.label),l.pro&&e.jsx(me,{})]})},l.key))}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-8",children:[g==="guide"&&e.jsx(es,{}),g==="account"&&e.jsxs(e.Fragment,{children:[e.jsx(Ee,{}),e.jsxs("section",{className:"rounded-2xl border p-5 bg-gradient-to-b from-brand-bg to-[#f7faea]",style:{borderColor:"#d8e8a8"},children:[e.jsx("div",{className:"font-mono text-xs uppercase tracking-wider text-brand-ink/80",children:s("opts_cost_this_month")}),e.jsxs("div",{className:"flex items-baseline gap-3 mt-1",children:[e.jsx("span",{className:"text-3xl font-bold font-mono text-brand-ink tracking-tight",children:qe}),e.jsx("span",{className:"text-md text-brand-ink/70",children:s("opts_spent_on_llm")}),e.jsx("span",{className:"flex-1"}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-mono text-xs uppercase tracking-wider text-modeC",children:s("opts_saved_label")}),e.jsx("div",{className:"text-2xl font-bold font-mono text-modeC tracking-tight",children:Ve})]})]}),e.jsxs("div",{className:"mt-2 h-1.5 bg-black/5 rounded-full overflow-hidden flex","aria-hidden":"true",children:[e.jsx("div",{className:"bg-brand-3",style:{width:`${U.spent}%`}}),e.jsx("div",{className:"bg-modeC",style:{width:`${U.saved}%`}})]}),e.jsxs("div",{className:"mt-1.5 text-xs font-mono text-brand-ink/80 flex justify-between",children:[e.jsxs("span",{children:[s("opts_paid_vs_reuse")," = ",U.spent.toFixed(1),"% /"," ",U.saved.toFixed(1),"%"]}),e.jsxs("span",{children:[s("opts_total_label")," ",Q(r,u.llm.displayCurrency??"USD")]})]}),(o.inputTokens>0||o.outputTokens>0||o.cacheReadTokens>0)&&e.jsxs("div",{className:"grid grid-cols-4 gap-3 text-xs text-ink-3 border-t border-line-soft pt-3 mt-3",children:[e.jsx(K,{label:s("opts_cost_tok_input"),value:o.inputTokens}),e.jsx(K,{label:s("opts_cost_tok_cache_read"),value:o.cacheReadTokens}),e.jsx(K,{label:s("opts_cost_tok_cache_create"),value:o.cacheCreationTokens}),e.jsx(K,{label:s("opts_cost_tok_output"),value:o.outputTokens})]})]}),e.jsxs("section",{className:"rounded-xl border border-line-soft bg-bg-soft p-3",children:[Number.isFinite(v)?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-md",children:[e.jsxs("strong",{className:`font-mono ${h>=v?"text-err":""}`,children:[h," / ",v]}),e.jsx("span",{className:"text-ink-3",children:s("opts_selfheal_usage_free")}),e.jsx("span",{className:"flex-1"}),e.jsx("button",{type:"button",className:"yk-btn is-sm",onClick:()=>void A(),children:s("opts_upgrade_selfheal")})]}),e.jsx("div",{className:"mt-2 h-1.5 bg-bg-app rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-warn",style:{width:`${Math.min(100,h/v*100)}%`}})})]}):e.jsxs("div",{className:"flex items-center gap-2 text-md",children:[e.jsxs("strong",{className:"font-mono text-modeC",children:[h," · ∞"]}),e.jsx("span",{className:"text-ink-3",children:s("opts_selfheal_usage_pro")})]}),e.jsx("div",{className:"mt-1.5 text-xs text-ink-3",children:s("opts_selfheal_note")})]})]}),g==="models"&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-medium mb-2",children:s("opts_sec_providers")}),e.jsx("div",{className:"text-sm text-ink-3 mb-4",children:s("opts_providers_desc")}),t.llm.providers.length===0&&!d&&e.jsx("div",{className:"rounded-xl border border-dashed border-line p-6 text-center text-ink-3",children:s("opts_no_provider")}),e.jsx("ul",{className:"space-y-2",children:t.llm.providers.map(l=>y===l.id?e.jsx("li",{children:e.jsx(Se,{initial:l,onCancel:()=>w(null),onSubmit:N=>Be(l.id,N)})},l.id):e.jsxs("li",{className:"flex items-center gap-3 rounded-xl border border-line px-4 py-3",children:[e.jsx("button",{type:"button",onClick:()=>He(l.id),className:`flex h-5 w-5 items-center justify-center rounded-full border transition-colors duration-fast ${t.llm.defaultProviderId===l.id?"border-brand-2 bg-brand":"border-line hover:border-brand-2"}`,"aria-label":s("opts_use_default_aria"),children:t.llm.defaultProviderId===l.id&&e.jsx(S,{size:12,strokeWidth:3,className:"text-brand-ink"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-md font-medium",children:l.label}),e.jsxs("div",{className:"text-xs text-ink-3 font-mono truncate",children:[F[l.kind]," · ",l.model," · sk-•••",l.apiKey.slice(-4)," · ctx"," ",z(l.contextWindowTokens??ze(l.model))]})]}),e.jsx("button",{type:"button",onClick:()=>{b(!1),w(l.id)},className:"text-ink-3 hover:text-ink-1 transition-colors duration-fast","aria-label":s("opts_edit_aria"),children:e.jsx(xe,{size:16,strokeWidth:1.5})}),e.jsx("button",{type:"button",onClick:()=>Ke(l.id),className:"text-ink-3 hover:text-err transition-colors duration-fast","aria-label":s("opts_remove_aria"),children:e.jsx(W,{size:16,strokeWidth:1.5})})]},l.id))}),d?e.jsx(Se,{onCancel:()=>b(!1),onSubmit:M}):e.jsxs("button",{type:"button",onClick:()=>{w(null),b(!0)},className:"mt-3 flex items-center gap-2 text-sm text-brand-ink hover:text-brand-ink-hover",children:[e.jsx(P,{size:14,strokeWidth:2}),s("opts_add_provider")]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-medium mb-2",children:s("opts_sec_pricing")}),e.jsx("div",{className:"text-sm text-ink-3 mb-4",children:s("opts_pricing_desc")}),e.jsx(Qs,{models:Xs(u.llm.providers),overrides:u.llm.pricingOverrides??{},currency:u.llm.displayCurrency??"USD",onChange:async l=>{await k({...u,llm:{...u.llm,pricingOverrides:l}})}})]})]}),g==="account"&&e.jsx(ys,{}),g==="referral"&&e.jsx(Ts,{}),g==="mcp"&&e.jsx(ds,{}),g==="localfiles"&&e.jsx(ss,{}),g==="scenarios"&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-medium mb-2",children:s("opts_sec_user_instructions")}),e.jsx("div",{className:"text-sm text-ink-3 mb-3",children:s("opts_user_instructions_desc")}),e.jsx("textarea",{value:((ue=t.prompts)==null?void 0:ue.userInstructions)??"",onChange:l=>n({...t,prompts:{...t.prompts,userInstructions:l.target.value}}),onBlur:async()=>{await k(t)},placeholder:s("opts_user_instructions_placeholder"),rows:6,className:"w-full bg-bg-app border border-line rounded-md px-3 py-2 text-sm leading-relaxed text-ink-1 placeholder:text-ink-4 caret-accent outline-none focus:border-brand-2 resize-y font-mono"})]}),e.jsx(zs,{})]}),g==="memory"&&e.jsx(Fs,{}),g==="appearance"&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-medium mb-2",children:s("opts_sec_appearance")}),e.jsxs("div",{className:"grid grid-cols-[max-content_1fr] gap-x-6 gap-y-3 items-center",children:[e.jsx("label",{htmlFor:"lang-select",className:"text-sm text-ink-3",children:s("opts_language")}),e.jsxs("select",{id:"lang-select",value:t.language,onChange:async l=>{const N=l.target.value;await k({...t,language:N});const{applyLocale:C}=await _t(async()=>{const{applyLocale:E}=await import("./capabilities-CQ-mRPPK.js").then(Ge=>Ge.t);return{applyLocale:E}},[]);C(N),window.location.reload()},className:"bg-bg-app border border-line rounded-md px-3 py-2 text-base text-ink-1 outline-none focus:border-brand-2 w-fit min-w-[180px]",children:[e.jsx("option",{value:"auto",children:s("opts_language_auto")}),e.jsx("option",{value:"en",children:"English"}),e.jsx("option",{value:"zh_CN",children:"简体中文"})]}),e.jsx("label",{htmlFor:"tr-lang-select",className:"text-sm text-ink-3",children:s("opts_translate_target")}),e.jsxs("select",{id:"tr-lang-select",value:((he=t.translation)==null?void 0:he.targetLanguage)??"auto",onChange:l=>k({...t,translation:{targetLanguage:l.target.value}}),className:"bg-bg-app border border-line rounded-md px-3 py-2 text-base text-ink-1 outline-none focus:border-brand-2 w-fit min-w-[180px]",children:[e.jsx("option",{value:"auto",children:s("opts_translate_target_auto")}),e.jsx("option",{value:"English",children:"English"}),e.jsx("option",{value:"Chinese (Simplified)",children:"简体中文"}),e.jsx("option",{value:"Chinese (Traditional)",children:"繁體中文"}),e.jsx("option",{value:"Japanese",children:"日本語"}),e.jsx("option",{value:"Korean",children:"한국어"}),e.jsx("option",{value:"French",children:"Français"}),e.jsx("option",{value:"German",children:"Deutsch"}),e.jsx("option",{value:"Spanish",children:"Español"})]}),e.jsx("div",{className:"text-sm text-ink-3",children:s("opts_welcome_card")}),e.jsx("button",{type:"button",onClick:()=>k({...t,onboarding:{dismissed:!1}}),disabled:!t.onboarding.dismissed,className:"px-3 py-2 text-sm bg-bg-app border border-line hover:border-line rounded-md disabled:opacity-30 disabled:cursor-not-allowed w-fit",children:s("opts_welcome_show_again")})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-medium mb-2",children:s("opts_sec_privacy")}),e.jsx("p",{className:"text-sm text-ink-3",children:s("opts_privacy_no_telemetry")})]})]}),g==="advanced"&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-medium mb-2",children:s("opts_sec_tools")}),e.jsx("div",{className:"text-sm text-ink-3 mb-3",children:s("opts_sec_tools_desc")}),e.jsxs("label",{className:"flex items-start gap-3 text-sm mb-3",children:[e.jsx("input",{type:"checkbox",checked:t.tools.typeDefaultPerKey,onChange:l=>k({...t,tools:{...t.tools,typeDefaultPerKey:l.target.checked}}),className:"accent-brand mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"block",children:s("opts_tools_typewriter_label")}),e.jsx("span",{className:"block text-xs text-ink-3 mt-0.5",children:s("opts_tools_typewriter_desc")})]})]}),e.jsxs("label",{className:"block mb-3 text-sm",children:[e.jsx("span",{className:"block mb-1",children:s("opts_tools_element_timeout_label")}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:1e3,max:6e4,step:500,value:t.tools.defaultElementTimeoutMs,onChange:l=>k({...t,tools:{...t.tools,defaultElementTimeoutMs:Math.max(1e3,Math.min(6e4,Number.parseInt(l.target.value,10)||5e3))}}),className:"w-24 bg-bg-app border border-line rounded px-2 py-1 text-sm"}),e.jsx("span",{className:"text-xs text-ink-4",children:"ms"})]}),e.jsx("span",{className:"block text-xs text-ink-3 mt-1",children:s("opts_tools_element_timeout_desc")})]}),e.jsxs("label",{className:"block mb-3 text-sm",children:[e.jsx("span",{className:"block mb-1",children:s("opts_tools_max_steps_label")}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:10,max:500,step:10,value:t.modeA.maxToolCallsPerTask,onChange:l=>k({...t,modeA:{...t.modeA,maxToolCallsPerTask:Math.max(10,Math.min(500,Number.parseInt(l.target.value,10)||200))}}),className:"w-24 bg-bg-app border border-line rounded px-2 py-1 text-sm"}),e.jsx("span",{className:"text-xs text-ink-4",children:s("opts_tools_max_steps_unit")})]}),e.jsx("span",{className:"block text-xs text-ink-3 mt-1",children:s("opts_tools_max_steps_desc")})]}),e.jsxs("label",{className:"block mb-3 text-sm",children:[e.jsx("span",{className:"block mb-1",children:s("opts_tools_max_tokens_label")}),e.jsxs("select",{value:String(t.modeA.maxTokens),onChange:l=>k({...t,modeA:{...t.modeA,maxTokens:Number.parseInt(l.target.value,10)}}),className:"bg-bg-app border border-line rounded px-2 py-1 text-sm",children:[e.jsx("option",{value:"16384",children:s("opts_tools_max_tokens_tier_16")}),e.jsx("option",{value:"32768",children:s("opts_tools_max_tokens_tier_32")}),e.jsx("option",{value:"65536",children:s("opts_tools_max_tokens_tier_64")}),e.jsx("option",{value:"131072",children:s("opts_tools_max_tokens_tier_128")})]}),e.jsx("span",{className:"block text-xs text-ink-3 mt-1",children:s("opts_tools_max_tokens_desc")})]}),e.jsxs("label",{className:"block text-sm",children:[e.jsx("span",{className:"block mb-1",children:s("opts_tools_screenshot_detail_label")}),e.jsxs("select",{value:t.tools.screenshotDetailDefault,onChange:l=>k({...t,tools:{...t.tools,screenshotDetailDefault:l.target.value}}),className:"bg-bg-app border border-line rounded px-2 py-1 text-sm",children:[e.jsx("option",{value:"low",children:s("opts_tools_screenshot_detail_low")}),e.jsx("option",{value:"high",children:s("opts_tools_screenshot_detail_high")})]}),e.jsx("span",{className:"block text-xs text-ink-3 mt-1",children:s("opts_tools_screenshot_detail_desc")})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-medium mb-2",children:s("opts_sec_context_window")}),e.jsx("div",{className:"text-sm text-ink-3 mb-3",children:s("opts_context_window_desc")}),e.jsx(Ce,{title:s("opts_async_precompress"),subtitle:s("opts_async_precompress_desc"),pct:t.compression.precompressThresholdPct,pctMin:20,pctMax:t.compression.blockingThresholdPct-5,maxTokens:t.compression.precompressMaxTokens,settings:t,onPctChange:async l=>{await k({...t,compression:{...t.compression,precompressThresholdPct:l}})},onMaxTokensChange:async l=>{await k({...t,compression:{...t.compression,precompressMaxTokens:l}})}}),e.jsx("div",{className:"h-3"}),e.jsx(Ce,{title:s("opts_hard_cap"),subtitle:s("opts_hard_cap_desc"),pct:t.compression.blockingThresholdPct,pctMin:t.compression.precompressThresholdPct+5,pctMax:99,maxTokens:t.compression.blockingMaxTokens,settings:t,onPctChange:async l=>{await k({...t,compression:{...t.compression,blockingThresholdPct:l}})},onMaxTokensChange:async l=>{await k({...t,compression:{...t.compression,blockingMaxTokens:l}})}}),e.jsx("div",{className:"text-xs text-ink-4 mt-3",children:s("opts_compression_defaults_hint")})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-medium mb-2",children:s("opts_sec_prompts")}),e.jsx("div",{className:"text-sm text-ink-3 mb-3",children:s("opts_prompts_desc")}),e.jsx("div",{className:"space-y-3",children:Object.keys(Ue).map(l=>{var N;return e.jsx(Ks,{name:l,value:((N=t.prompts)==null?void 0:N[l])??"",onSave:async C=>{await k({...t,prompts:{...t.prompts,[l]:C}})},onReset:async()=>{const C={...t.prompts};delete C[l],await k({...t,prompts:C})}},l)})})]})]}),g==="data"&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-medium mb-2",children:s("opts_sec_backup")}),e.jsx("div",{className:"text-sm text-ink-3 mb-3",children:s("opts_backup_desc")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Vs(_),className:"px-3 py-2 text-sm bg-bg-app border border-line hover:border-line rounded-md flex items-center gap-2 transition-colors",children:[e.jsx(lt,{size:14,strokeWidth:1.5}),s("opts_export")]}),e.jsxs("button",{type:"button",onClick:()=>void Gs().then(async l=>{l&&(n(await L()),alert(s("opts_restore_done",[String(l.macros),String(l.sessions),String(l.userMemory)])))}),className:"px-3 py-2 text-sm bg-bg-app border border-line hover:border-line rounded-md flex items-center gap-2 transition-colors",children:[e.jsx(ot,{size:14,strokeWidth:1.5}),s("opts_import")]})]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs text-ink-3 mt-2.5 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:l=>p(l.target.checked),className:"w-3.5 h-3.5 accent-brand"}),s("opts_backup_include_secrets")]}),e.jsx("div",{className:"text-xs text-ink-4 mt-2",children:s("opts_backup_warning")})]}),e.jsxs("footer",{className:"pt-6 mt-2 border-t border-line text-xs text-ink-3 space-y-3",children:[e.jsx("h3",{className:"text-xs uppercase tracking-wider text-ink-4",children:s("legal_section_title")}),e.jsxs("p",{className:"leading-relaxed",children:["🔒 ",s("legal_privacy_body")]}),e.jsxs("p",{className:"leading-relaxed",children:["⚖️ ",s("legal_liability_body")]}),e.jsx("p",{className:"leading-relaxed",children:s("legal_lawful_use_body")}),e.jsxs("p",{className:"leading-relaxed",children:["💬 ",s("feedback_contact")," ",e.jsx("a",{href:dt,className:"text-brand-ink hover:underline",children:ct})]})]})]})]})]})]})}function z(t){return t>=1e6?`${(t/1e6).toFixed(t%1e6===0?0:1)}M`:t>=1e3?`${Math.round(t/1e3)}K`:String(t)}function Ce(t){const n=t.settings.llm.providers.find(r=>r.id===t.settings.llm.defaultProviderId),a=n?ze(n.model,n.contextWindowTokens):0,i=a?Math.min(Math.floor(a*(t.pct/100)),t.maxTokens):0;return e.jsxs("div",{className:"rounded-xl border border-line p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-medium",children:t.title}),e.jsx("div",{className:"text-xs text-ink-3 mt-0.5",children:t.subtitle})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs text-ink-3",children:s("opts_pct_label")}),e.jsxs("span",{className:"text-sm font-mono text-brand-ink",children:[t.pct,"%"]})]}),e.jsx("input",{type:"range",min:t.pctMin,max:t.pctMax,value:t.pct,onChange:r=>t.onPctChange(Number(r.target.value)),className:"w-full accent-brand"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-ink-3",htmlFor:`max-${t.title}`,children:s("opts_abs_cap_label")}),e.jsx("input",{id:`max-${t.title}`,type:"number",min:5e3,step:1e4,value:t.maxTokens,onChange:r=>t.onMaxTokensChange(Math.max(5e3,Number(r.target.value))),className:"mt-1 w-full bg-bg-app border border-line rounded-md px-3 py-2 text-base font-mono text-ink-1 caret-accent outline-none focus:border-brand-2"})]}),n&&e.jsx("div",{className:"text-xs text-ink-3",children:s("opts_for_default_model",[n.model,z(a),z(i),String(t.pct),z(Math.floor(a*(t.pct/100))),z(t.maxTokens)])})]})}function Ks(t){const[n,a]=x.useState(!1),i=t.value.trim().length>0,r=i?t.value:te[t.name],[m,o]=x.useState(r),c=m!==r;return e.jsxs("div",{className:"rounded-xl border border-line",children:[e.jsxs("button",{type:"button",onClick:()=>{n||o(r),a(!n)},className:"w-full flex items-center gap-2 px-4 py-3 text-left hover:bg-bg-app transition-colors rounded-xl",children:[n?e.jsx(mt,{size:16,strokeWidth:1.5,className:"shrink-0"}):e.jsx(pt,{size:16,strokeWidth:1.5,className:"shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-base font-medium flex items-center gap-2",children:[s(Ue[t.name]),i&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-brand/20 text-brand-ink",children:s("opts_customized_chip")})]}),e.jsx("div",{className:"text-xs text-ink-3 truncate",children:s(Us[t.name])})]})]}),n&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.jsx("textarea",{value:m,onChange:h=>o(h.target.value),rows:16,spellCheck:!1,className:"w-full bg-bg-app border border-line rounded-md px-3 py-2 text-sm font-mono leading-relaxed text-ink-1 placeholder:text-ink-4 caret-accent outline-none focus:border-brand-2 resize-y"}),e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:async()=>{confirm(s("opts_prompt_reset_confirm"))&&(await t.onReset(),o(te[t.name]))},disabled:!i,className:"px-3 py-2 text-sm text-ink-3 hover:text-err disabled:opacity-30 disabled:cursor-not-allowed flex items-center gap-1 transition-colors",children:[e.jsx(ut,{size:14,strokeWidth:1.5}),s("opts_reset_default")]}),e.jsx("button",{type:"button",disabled:!c,onClick:async()=>{m.trim()===te[t.name].trim()?await t.onReset():await t.onSave(m)},className:"px-4 py-2 text-sm bg-brand hover:bg-brand-2 text-brand-ink rounded-md font-medium disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:s("opts_save")})]}),e.jsx("div",{className:"text-xs text-ink-4",children:s("opts_prompts_warning")})]})]})}function Hs(t,n){const a=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),i=URL.createObjectURL(a),r=document.createElement("a");r.href=i,r.download=n,document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(i),r.remove()},100)}function qs(t){return new Promise(n=>{const a=document.createElement("input");a.type="file",a.accept=t,a.onchange=async()=>{var r;const i=(r=a.files)==null?void 0:r[0];if(!i){n(null);return}try{n(await i.text())}catch{n(null)}},a.click()})}async function Vs(t){const n=await Gt({includeSecrets:t,appVersion:chrome.runtime.getManifest().version}),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");Hs(n,`yank-backup-${a}.json`)}async function Gs(){const t=await qs("application/json");if(t===null)return null;const n=Vt(t);if(!n.ok)return alert(n.kind==="version"?s("opts_restore_version"):n.kind==="json"?s("opts_restore_failed",n.message):s("opts_restore_invalid")),null;const{data:a}=n.backup;return confirm(s("opts_restore_confirm",[String(a.macros.length),String(a.sessions.length),String(a.userMemory.length)]))?Yt(n.backup):null}const Ys=[{label:"32K",value:32768},{label:"64K",value:65536},{label:"128K",value:128e3},{label:"200K",value:2e5},{label:"256K",value:256e3},{label:"1M",value:1e6}];function Se(t){const n=t.initial,a=n!==void 0,[i,r]=x.useState((n==null?void 0:n.kind)??"openai"),[m,o]=x.useState((n==null?void 0:n.label)??""),[c,h]=x.useState((n==null?void 0:n.apiKey)??""),[j,v]=x.useState((n==null?void 0:n.model)??ae.openai),[f,d]=x.useState((n==null?void 0:n.baseUrl)??""),[b,y]=x.useState((n==null?void 0:n.contextWindowTokens)??0),[w,g]=x.useState((n==null?void 0:n.thinking)??!0);function T(p){r(p),a||v(ae[p])}function _(){c.trim()&&t.onSubmit({kind:i,label:m.trim()||F[i],apiKey:c.trim(),model:j.trim()||ae[i],baseUrl:f.trim()||void 0,timeoutMs:(n==null?void 0:n.timeoutMs)??6e4,contextWindowTokens:b>0?b:void 0,thinking:_e(j.trim(),i)&&!w?!1:void 0})}return e.jsxs("div",{className:"mt-3 rounded-xl border border-line p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs uppercase tracking-wider text-ink-3",htmlFor:"provider-kind",children:s("opts_form_provider")}),e.jsx("select",{id:"provider-kind",value:i,onChange:p=>T(p.target.value),className:"mt-1 w-full bg-bg-app border border-line rounded-md px-3 py-2 text-base text-ink-1 placeholder:text-ink-4 caret-accent focus:border-brand-2 outline-none",children:Object.keys(F).filter(p=>p!=="managed").map(p=>e.jsx("option",{value:p,children:F[p]},p))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs uppercase tracking-wider text-ink-3",htmlFor:"provider-label",children:s("opts_form_label")}),e.jsx("input",{id:"provider-label",type:"text",value:m,onChange:p=>o(p.target.value),placeholder:F[i],className:"mt-1 w-full bg-bg-app border border-line rounded-md px-3 py-2 text-base text-ink-1 placeholder:text-ink-4 caret-accent focus:border-brand-2 outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs uppercase tracking-wider text-ink-3",htmlFor:"api-key",children:s("opts_form_api_key")}),e.jsx("input",{id:"api-key",type:"password",value:c,onChange:p=>h(p.target.value),placeholder:"sk-...",className:"mt-1 w-full bg-bg-app border border-line rounded-md px-3 py-2 text-base font-mono text-ink-1 placeholder:text-ink-4 caret-accent focus:border-brand-2 outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs uppercase tracking-wider text-ink-3",htmlFor:"model",children:s("opts_form_model")}),e.jsx("input",{id:"model",type:"text",value:j,onChange:p=>v(p.target.value),className:"mt-1 w-full bg-bg-app border border-line rounded-md px-3 py-2 text-base font-mono text-ink-1 placeholder:text-ink-4 caret-accent focus:border-brand-2 outline-none"})]}),_e(j.trim(),i)&&e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:p=>g(p.target.checked),className:"accent-brand"}),e.jsx("span",{className:"text-sm text-ink-1",children:s("opts_form_thinking")}),e.jsx("span",{className:"text-xs text-ink-3",children:s("opts_form_thinking_hint")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs uppercase tracking-wider text-ink-3",htmlFor:"base-url",children:[s("opts_form_base_url"),i!=="custom"&&i!=="custom-anthropic"&&e.jsxs("span",{className:"ml-1 normal-case tracking-normal text-ink-4",children:["· ",s("opts_form_optional")]})]}),e.jsx("input",{id:"base-url",type:"text",value:f,onChange:p=>d(p.target.value),placeholder:Ne(i),className:"mt-1 w-full bg-bg-app border border-line rounded-md px-3 py-2 text-base font-mono text-ink-1 placeholder:text-ink-4 caret-accent focus:border-brand-2 outline-none"}),i!=="custom"&&i!=="custom-anthropic"&&e.jsx("div",{className:"text-xs text-ink-4 mt-1",children:s("opts_form_base_url_hint",Ne(i))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs uppercase tracking-wider text-ink-3",htmlFor:"ctx-window",children:s("opts_form_ctx_window_label")}),e.jsx("input",{id:"ctx-window",type:"number",min:0,step:1e3,value:b,onChange:p=>y(Number(p.target.value)),placeholder:String(be[j]??32768),className:"mt-1 w-full bg-bg-app border border-line rounded-md px-3 py-2 text-base font-mono text-ink-1 placeholder:text-ink-4 caret-accent focus:border-brand-2 outline-none"}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-ink-3 font-medium mr-1",children:s("opts_form_ctx_window_presets")}),Ys.map(p=>{const u=b===p.value;return e.jsx("button",{type:"button",onClick:()=>y(p.value),className:`px-2 py-0.5 rounded-md text-[11px] font-mono border transition-colors duration-fast ${u?"border-brand-2 bg-brand/10 text-brand-ink":"border-line text-ink-3 hover:bg-bg-soft hover:border-line hover:text-ink-1"}`,children:p.label},p.value)}),b>0&&e.jsx("button",{type:"button",onClick:()=>y(0),className:"px-2 py-0.5 rounded-md text-[11px] text-ink-3 hover:text-ink-1 transition-colors",title:"Clear override",children:e.jsx(re,{size:11,strokeWidth:1.75,className:"inline"})})]}),e.jsx("div",{className:"text-xs text-ink-4 mt-1",children:s("opts_form_ctx_window_hint",[j||"—",z(be[j]??32768)])})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsxs("button",{type:"button",onClick:t.onCancel,className:"px-3 py-2 text-sm text-ink-3 hover:text-ink-1 transition-colors duration-fast flex items-center gap-1",children:[e.jsx(re,{size:14,strokeWidth:1.5}),s("opts_form_cancel")]}),e.jsxs("button",{type:"button",onClick:_,disabled:!c.trim(),className:"px-4 py-2 text-sm bg-brand hover:bg-brand-2 text-brand-ink font-medium rounded-md transition-colors duration-fast disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-1",children:[e.jsx(S,{size:14,strokeWidth:2}),a?s("opts_form_save"):s("opts_form_add")]})]})]})}function Js(t,n){const a=t+n;if(a<=0)return{spent:0,saved:0};const i=t/a*100,r=n/a*100;return{spent:Math.max(1,i),saved:Math.max(1,r)}}function K({label:t,value:n}){return e.jsxs("div",{children:[e.jsx("div",{className:"uppercase tracking-wider text-ink-3 text-[10px]",children:t}),e.jsx("div",{className:"font-mono text-sm text-ink-2 mt-0.5",children:z(n)})]})}function Xs(t){const n=new Set,a=[];for(const i of t)i.model&&!n.has(i.model)&&(n.add(i.model),a.push(i.model));return a}function Qs(t){if(t.models.length===0)return e.jsx("div",{className:"rounded-xl border border-dashed border-line p-4 text-sm text-ink-3",children:s("opts_pricing_no_models")});const n=Pe(t.currency);return e.jsxs("div",{className:"rounded-xl border border-line overflow-hidden",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-bg-soft text-ink-1 text-xs uppercase tracking-wider font-medium",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-3 py-2.5",children:s("opts_pricing_col_model")}),e.jsxs("th",{className:"text-right px-2 py-2.5",children:[s("opts_pricing_col_input")," ",e.jsxs("span",{className:"text-ink-3 normal-case",children:["(",n,"/1M)"]})]}),e.jsxs("th",{className:"text-right px-2 py-2.5",children:[s("opts_pricing_col_cache_read")," ",e.jsxs("span",{className:"text-ink-3 normal-case",children:["(",n,"/1M)"]})]}),e.jsxs("th",{className:"text-right px-2 py-2.5",children:[s("opts_pricing_col_cache_create")," ",e.jsxs("span",{className:"text-ink-3 normal-case",children:["(",n,"/1M)"]})]}),e.jsxs("th",{className:"text-right px-3 py-2.5",children:[s("opts_pricing_col_output")," ",e.jsxs("span",{className:"text-ink-3 normal-case",children:["(",n,"/1M)"]})]})]})}),e.jsx("tbody",{children:t.models.map(a=>e.jsx(Zs,{model:a,override:t.overrides[a],builtin:zt[a],currency:t.currency,onChange:i=>{const r={...t.overrides};return i?r[a]=i:delete r[a],t.onChange(r)}},a))})]}),e.jsx("div",{className:"px-3 py-2 text-xs text-ink-3 border-t border-line bg-bg-app/30",children:s("opts_pricing_footer")})]})}function Zs(t){var i,r,m,o;const n=t.override??t.builtin,a=!t.builtin&&!t.override;return e.jsxs("tr",{className:"border-t border-line",children:[e.jsxs("td",{className:"px-3 py-2 font-mono text-xs",children:[t.model,a&&e.jsx("span",{className:"ml-2 text-[10px] uppercase tracking-wider text-modeB",children:s("opts_pricing_unset_badge")}),t.override&&e.jsx("button",{type:"button",onClick:()=>void t.onChange(void 0),className:"ml-2 text-[10px] uppercase tracking-wider text-ink-3 hover:text-ink-2",children:s("opts_pricing_reset")})]}),e.jsx(q,{value:n==null?void 0:n.input,builtin:(i=t.builtin)==null?void 0:i.input,currency:t.currency,onChange:c=>H(t,"input",c)}),e.jsx(q,{value:n==null?void 0:n.cacheRead,builtin:((r=t.builtin)==null?void 0:r.cacheRead)??(t.builtin?t.builtin.input*.1:void 0),currency:t.currency,placeholderHint:!0,onChange:c=>H(t,"cacheRead",c)}),e.jsx(q,{value:n==null?void 0:n.cacheCreation,builtin:((m=t.builtin)==null?void 0:m.cacheCreation)??(t.builtin?t.builtin.input*1.25:void 0),currency:t.currency,placeholderHint:!0,onChange:c=>H(t,"cacheCreation",c)}),e.jsx(q,{value:n==null?void 0:n.output,builtin:(o=t.builtin)==null?void 0:o.output,currency:t.currency,onChange:c=>H(t,"output",c)})]})}async function H(t,n,a){const r={...t.override??t.builtin??{input:0,output:0}};if(a===void 0?delete r[n]:r[n]=a,t.builtin&&r.input===t.builtin.input&&r.output===t.builtin.output&&r.cacheRead===t.builtin.cacheRead&&r.cacheCreation===t.builtin.cacheCreation){await t.onChange(void 0);return}await t.onChange(r)}function q(t){const n=o=>o===void 0?"":ie(Z(o,t.currency)),[a,i]=x.useState(n(t.value));x.useEffect(()=>{i(t.value===void 0?"":ie(Z(t.value,t.currency)))},[t.value,t.currency]);const r=t.builtin!==void 0?ie(Z(t.builtin,t.currency)):"—",m=t.currency==="JPY"||t.currency==="CNY"?"w-24":"w-20";return e.jsx("td",{className:"px-2 py-1 text-right",children:e.jsx("input",{type:"number",step:"0.01",min:"0",value:a,placeholder:r,onChange:o=>i(o.target.value),onBlur:()=>{const o=a.trim();if(o===""){t.onChange(void 0);return}const c=Number.parseFloat(o);if(Number.isNaN(c)||c<0){i(n(t.value));return}const h=ht(c,t.currency);t.onChange(h)},className:`${m} bg-bg-app border rounded px-2 py-1 text-right text-xs font-mono caret-accent outline-none focus:border-brand-2 ${t.placeholderHint&&a===""?"border-line text-ink-3":"border-line text-ink-1"}`})})}function ie(t){return t.toFixed(4).replace(/\.?0+$/,"")||"0"}function en(t){return e.jsxs("label",{className:"flex items-center gap-2 text-xs text-ink-3",children:[e.jsx("span",{className:"uppercase tracking-wider",children:s("opts_language_label")}),e.jsxs("select",{value:t.value,onChange:n=>void t.onChange(n.target.value),className:"bg-bg-app border border-line rounded px-2 py-1 text-xs font-mono text-ink-1 outline-none focus:border-brand-2",children:[e.jsx("option",{value:"auto",children:s("opts_language_auto")}),e.jsx("option",{value:"en",children:"English"}),e.jsx("option",{value:"zh_CN",children:"中文"})]})]})}function tn(t){return e.jsxs("label",{className:"flex items-center gap-2 text-xs text-ink-3",children:[e.jsx("span",{className:"uppercase tracking-wider",children:s("opts_currency_label")}),e.jsx("select",{value:t.value,onChange:n=>void t.onChange(n.target.value),className:"bg-bg-app border border-line rounded px-2 py-1 text-xs font-mono text-ink-1 outline-none focus:border-brand-2",children:xt.map(n=>e.jsxs("option",{value:n,children:[Pe(n)," ",n]},n))})]})}async function sn(){await ft();const t=document.getElementById("root");if(!t)throw new Error("Root element not found");bt(t).render(e.jsx(Bs,{}))}sn();
