upfynai-code 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MermaidBlock-BuBc_G-F.js","assets/vendor-syntax-DuHI9Ok6.js","assets/vendor-react-96lCPsRK.js","assets/vendor-markdown-CimbIo6Y.js","assets/vendor-diff-DNQpbhrT.js","assets/MarkdownPreview-DHmk3qzu.js","assets/FileTree-CbJF7m5P.js","assets/index-DtIQCXd6.js","assets/vendor-icons-BaD0x9SL.js","assets/vendor-i18n-DCFGyhQR.js","assets/index-BFuqS0tY.css","assets/LoginModal-Bk9mxZsi.js","assets/vendor-xterm-CZq1hqo1.js","assets/vendor-xterm-qxJ8_QYu.css","assets/vendor-canvas-D39yWul6.js","assets/vendor-mermaid-CH7SGc99.js","assets/vendor-canvas-BZV40eAE.css","assets/vendor-codemirror-CbtmxxaB.js","assets/GitPanel-avzqm9Zj.js","assets/WorkflowsPanel-BOaVEpdu.js","assets/DashboardPanel-DmHbSyTP.js","assets/CanvasWorkspace-DksIgrfl.js","assets/PreviewPanel-CqCa92Tf.js"])))=>i.map(i=>d[i]);
2
- import{r as l,j as e,R as it,i as Cr,g as Jn,h as Yn,u as hi}from"./vendor-react-96lCPsRK.js";import{a as hr,b as Be,c as ps,d as Me,e as Lr,l as Pa,f as pa,g as fr,u as Qn}from"./index-DtIQCXd6.js";import{S as Dt,b as Ut,c as $a,R as Vs,P as at,d as fi,e as Ar,X as Ve,F as Zr,f as xs,g as Pr,h as Ir,i as yt,j as Lt,k as bi,l as Pt,m as er,n as mr,o as _a,p as Mr,q as rr,W as Xn,G as br,K as xa,L as Sr,r as ga,E as sr,s as Zn,T as $t,t as vt,u as ha,v as Fa,w as yi,x as vi,y as fa,z as $r,A as qs,Z as tr,B as eo,D as Ks,H as Js,J as Ys,N as za,O as ki,Q as wi,U as ba,V as gs,Y as to,_ as es,$ as gt,a0 as ur,a as ji,a1 as ts,a2 as Ni,a3 as ro,a4 as ya,a5 as so,a6 as Qs,a7 as ao,a8 as Ci,a9 as Si,aa as Ei,ab as Ti,M as va,ac as Ai,ad as no,ae as Ii,af as oo,ag as io,ah as Mi,ai as Di,aj as Li,ak as Pi,al as $i,am as _i,an as Fi,ao as zi,ap as Ri,aq as Oi,ar as Bi,as as Wi}from"./vendor-icons-BaD0x9SL.js";import{C as Ui,a as Hi,b as Gi,u as We,L as Vi,S as lo}from"./LoginModal-Bk9mxZsi.js";import{h as co,p as uo,b as kt}from"./vendor-syntax-DuHI9Ok6.js";import{a as qi,b as Ki,c as Ji,M as Yi}from"./vendor-markdown-CimbIo6Y.js";import{F as mo,E as Wt,S as Qi,V as ka,c as pr,a as Xi,f as Zi,u as el,b as tl,T as Ra,l as rl,h as Oa,s as sl,d as al,e as nl,g as ol,i as Ds,j as il,R as po,o as xo,k as ll,m as go,n as cl,p as dl,q as ul,r as ml,t as pl,v as xl}from"./vendor-codemirror-CbtmxxaB.js";const Ba=t=>typeof window>"u"?!1:window.innerWidth<t,Wa=()=>{if(typeof window>"u")return!1;const t=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!t.standalone||document.referrer.includes("android-app://")};function wa(t={}){const{mobileBreakpoint:r=768,trackMobile:s=!0,trackPWA:a=!0}=t,[n,o]=l.useState(()=>s?Ba(r):!1),[i,c]=l.useState(()=>a?Wa():!1);return l.useEffect(()=>{if(!s||typeof window>"u")return;const u=()=>{o(Ba(r))};return u(),window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}},[r,s]),l.useEffect(()=>{if(!a||typeof window>"u")return;const u=window.matchMedia("(display-mode: standalone)"),d=()=>{c(Wa())};return d(),typeof u.addEventListener=="function"?(u.addEventListener("change",d),()=>{u.removeEventListener("change",d)}):(u.addListener(d),()=>{u.removeListener(d)})},[a]),{isMobile:n,isPWA:i}}const Ua="2.9.9",Ha="upfyn-version-dismissed",gl=(t,r)=>{const s=t.split(".").map(Number),a=r.split(".").map(Number);for(let n=0;n<Math.max(s.length,a.length);n++){const o=s[n]||0,i=a[n]||0;if(o!==i)return o-i}return 0},ho=(t,r)=>{const[s,a]=l.useState(!1),[n,o]=l.useState(null),[i,c]=l.useState(null);l.useEffect(()=>{const d=async()=>{try{const h=await fetch("https://registry.npmjs.org/upfynai-code/latest");if(!h.ok)return;const p=await h.json();if(p.version){const g=p.version;if(o(g),localStorage.getItem(Ha)===g){a(!1);return}a(gl(g,Ua)>0),c({title:`v${g}`,body:"",htmlUrl:"https://www.npmjs.com/package/upfynai-code",publishedAt:null})}}catch{}};d();const m=setInterval(d,1800*1e3);return()=>clearInterval(m)},[t,r]);const u=l.useCallback(()=>{n&&localStorage.setItem(Ha,n),a(!1)},[n]);return{updateAvailable:s,latestVersion:n,currentVersion:Ua,releaseInfo:i,dismissUpdate:u}},Yt={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0},rs=Object.keys(Yt),hl=new Set(rs),Ls="ui-preferences:sync",ss=(t,r)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(t==="true")return!0;if(t==="false")return!1}return r},fl=(t,r)=>{try{const s=localStorage.getItem(t);if(s===null)return r;const a=JSON.parse(s);return ss(a,r)}catch{return r}},bl=t=>{if(typeof window>"u")return Yt;try{const r=localStorage.getItem(t);if(r){const s=JSON.parse(r);if(s&&typeof s=="object"&&!Array.isArray(s)){const a=s;return rs.reduce((n,o)=>(n[o]=ss(a[o],Yt[o]),n),{...Yt})}}}catch{}return rs.reduce((r,s)=>(r[s]=fl(s,Yt[s]),r),{...Yt})};function yl(t,r){switch(r.type){case"set":{const{key:s,value:a}=r;if(!hl.has(s))return t;const n=ss(a,t[s]);return t[s]===n?t:{...t,[s]:n}}case"set_many":{const s=r.value||{};let a=!1;const n={...t};for(const o of rs){if(!(o in s))continue;const i=s[o],c=ss(i,t[o]);n[o]!==c&&(n[o]=c,a=!0)}return a?n:t}case"reset":return{...Yt,...r.value||{}};default:return t}}function ja(t="uiPreferences"){const r=l.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[s,a]=l.useReducer(yl,t,bl);return l.useEffect(()=>{typeof window>"u"||(localStorage.setItem(t,JSON.stringify(s)),window.dispatchEvent(new CustomEvent(Ls,{detail:{storageKey:t,sourceId:r.current,value:s}})))},[s,t]),l.useEffect(()=>{if(typeof window>"u")return;const c=m=>{!m||typeof m!="object"||Array.isArray(m)||a({type:"set_many",value:m})},u=m=>{if(!(m.key!==t||m.newValue===null))try{const h=JSON.parse(m.newValue);c(h)}catch{}},d=m=>{const p=m.detail;!p||p.storageKey!==t||p.sourceId===r.current||c(p.value)};return window.addEventListener("storage",u),window.addEventListener(Ls,d),()=>{window.removeEventListener("storage",u),window.removeEventListener(Ls,d)}},[t]),{preferences:s,setPreference:(c,u)=>{a({type:"set",key:c,value:u})},setPreferences:c=>{a({type:"set_many",value:c})},resetPreferences:c=>{a({type:"reset",value:c})},dispatch:a}}const vl=()=>{try{const t=localStorage.getItem("claude-settings");return t&&JSON.parse(t).projectSortOrder==="date"?"date":"name"}catch{return"name"}},kl=()=>{try{const t=localStorage.getItem("starredProjects");return t?new Set(JSON.parse(t)):new Set}catch{return new Set}},wl=t=>{try{localStorage.setItem("starredProjects",JSON.stringify([...t]))}catch{}},as=t=>t.__provider==="cursor"?new Date(t.createdAt||0):t.__provider==="codex"?new Date(t.createdAt||t.lastActivity||0):new Date(t.lastActivity||0),jl=(t,r)=>t.__provider==="cursor"?t.name||r("projects.untitledSession"):t.__provider==="codex"?t.summary||t.name||r("projects.codexSession"):t.summary||r("projects.newSession"),Nl=t=>t.__provider==="cursor"?String(t.createdAt||""):t.__provider==="codex"?String(t.createdAt||t.lastActivity||""):String(t.lastActivity||""),Cl=(t,r,s)=>{const a=as(t),n=Math.floor((r.getTime()-a.getTime())/(1e3*60));return{isCursorSession:t.__provider==="cursor",isCodexSession:t.__provider==="codex",isActive:n<10,sessionName:jl(t,s),sessionTime:Nl(t),messageCount:Number(t.messageCount||0)}},fo=(t,r)=>{const s=[...t.sessions||[],...r[t.name]||[]].map(o=>({...o,__provider:"claude"})),a=(t.cursorSessions||[]).map(o=>({...o,__provider:"cursor"})),n=(t.codexSessions||[]).map(o=>({...o,__provider:"codex"}));return[...s,...a,...n].sort((o,i)=>as(i).getTime()-as(o).getTime())},Ga=(t,r)=>{const s=fo(t,r);return s.length===0?new Date(0):s.reduce((a,n)=>{const o=as(n);return o>a?o:a},new Date(0))},Sl=(t,r,s,a)=>{const n=[...t];return n.sort((o,i)=>{const c=s.has(o.name),u=s.has(i.name);return c&&!u?-1:!c&&u?1:r==="date"?Ga(i,a).getTime()-Ga(o,a).getTime():(o.displayName||o.name).localeCompare(i.displayName||i.name)}),n},El=(t,r)=>{const s=r.trim().toLowerCase();return s?t.filter(a=>{const n=(a.displayName||a.name).toLowerCase(),o=a.name.toLowerCase();return n.includes(s)||o.includes(s)}):t},Tl=(t,r)=>{var n;const s=!!((n=t.taskmaster)!=null&&n.hasTaskmaster),a=!!(r!=null&&r.hasMCPServer&&(r!=null&&r.isConfigured));return s&&a?"fully-configured":s?"taskmaster-only":a?"mcp-only":"not-configured"},Al=t=>{const r=typeof t.fullPath=="string"&&t.fullPath.length>0?t.fullPath:typeof t.path=="string"?t.path:"";return{name:t.name,displayName:typeof t.displayName=="string"&&t.displayName.trim().length>0?t.displayName:t.name,fullPath:r,path:typeof t.path=="string"&&t.path.length>0?t.path:r}};function Il({projects:t,selectedProject:r,selectedSession:s,isLoading:a,isMobile:n,t:o,onRefresh:i,onProjectSelect:c,onSessionSelect:u,onSessionDelete:d,onProjectDelete:m,setCurrentProject:h,setSidebarVisible:p,sidebarVisible:g}){const{addToast:f}=hr(),[x,b]=l.useState(new Set),[N,j]=l.useState(null),[y,k]=l.useState(!1),[I,D]=l.useState(""),[C,v]=l.useState({}),[E,T]=l.useState({}),[W,S]=l.useState(new Set),[O,H]=l.useState(new Date),[R,A]=l.useState("name"),[z,J]=l.useState(!1),[re,G]=l.useState({}),[ie,$]=l.useState(null),[Z,te]=l.useState(""),[Q,_]=l.useState(""),[F,q]=l.useState(new Set),[U,B]=l.useState(null),[ee,V]=l.useState(null),[w,M]=l.useState(!1),[Y,se]=l.useState(()=>kl()),de=!n&&!g;l.useEffect(()=>{const ae=setInterval(()=>{H(new Date)},6e4);return()=>clearInterval(ae)},[]),l.useEffect(()=>{T({}),S(new Set),G({})},[t]),l.useEffect(()=>{r&&b(ae=>{if(ae.has(r.name))return ae;const be=new Set(ae);return be.add(r.name),be})},[s,r]),l.useEffect(()=>{if(t.length>0&&!a){const ae=new Set;t.forEach(be=>{be.sessions&&be.sessions.length>=0&&ae.add(be.name)}),S(ae)}},[t,a]),l.useEffect(()=>{const ae=()=>{A(vl())};ae();const be=Ce=>{Ce.key==="claude-settings"&&ae()};window.addEventListener("storage",be);const ze=setInterval(()=>{document.hasFocus()&&ae()},1e3);return()=>{window.removeEventListener("storage",be),clearInterval(ze)}},[]);const je=l.useCallback(ae=>be=>{const ze=be.target;ze.closest(".overflow-y-auto")||ze.closest("[data-scroll-container]")||(be.preventDefault(),be.stopPropagation(),ae())},[]),ge=l.useCallback(ae=>{b(be=>{const ze=new Set;return be.has(ae)||ze.add(ae),ze})},[]),Re=l.useCallback((ae,be)=>{u({...ae,__projectName:be})},[u]),Ne=l.useCallback(ae=>{se(be=>{const ze=new Set(be);return ze.has(ae)?ze.delete(ae):ze.add(ae),wl(ze),ze})},[]),De=l.useCallback(ae=>Y.has(ae),[Y]),Ue=l.useCallback(ae=>fo(ae,E),[E]),_e=l.useMemo(()=>t.map(ae=>{const be=re[ae.name];return be===void 0?ae:{...ae,sessionMeta:{...ae.sessionMeta,hasMore:be}}}),[re,t]),L=l.useMemo(()=>Sl(_e,R,Y,E),[E,R,_e,Y]),K=l.useMemo(()=>El(L,Q),[Q,L]),pe=l.useCallback(ae=>{j(ae.name),D(ae.displayName)},[]),ye=l.useCallback(()=>{j(null),D("")},[]),Ie=l.useCallback(async ae=>{try{(await Be.renameProject(ae,I)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(be){console.error("Error renaming project:",be)}finally{j(null),D("")}},[I]),Fe=l.useCallback((ae,be,ze,Ce="claude")=>{V({projectName:ae,sessionId:be,sessionTitle:ze,provider:Ce})},[]),Se=l.useCallback(async()=>{if(!ee)return;const{projectName:ae,sessionId:be,provider:ze}=ee;V(null),d==null||d(be);try{const Ce=ze==="codex"?await Be.deleteCodexSession(be):await Be.deleteSession(ae,be);Ce.ok||console.error("[Sidebar] Failed to delete session:",Ce.status)}catch(Ce){console.error("[Sidebar] Error deleting session:",Ce)}},[d,ee,o]),Oe=l.useCallback(ae=>{B({project:ae,sessionCount:Ue(ae).length})},[Ue]),ne=l.useCallback(async()=>{if(!U)return;const{project:ae,sessionCount:be}=U,ze=be===0;B(null),q(Ce=>new Set([...Ce,ae.name]));try{const Ce=await Be.deleteProject(ae.name,!ze);if(Ce.ok)m==null||m(ae.name);else{const Ye=await Ce.json();f(Ye.error||o("messages.deleteProjectFailed"),"error")}}catch(Ce){console.error("Error deleting project:",Ce),f(o("messages.deleteProjectError"),"error")}finally{q(Ce=>{const Ye=new Set(Ce);return Ye.delete(ae.name),Ye})}},[U,m,o]),fe=l.useCallback(async ae=>{var Ce,Ye,lt;const be=re[ae.name];if(!(!(be!==void 0?be:((Ce=ae.sessionMeta)==null?void 0:Ce.hasMore)===!0)||C[ae.name])){v(dt=>({...dt,[ae.name]:!0}));try{const dt=(((Ye=ae.sessions)==null?void 0:Ye.length)||0)+(((lt=E[ae.name])==null?void 0:lt.length)||0),Tt=await Be.sessions(ae.name,5,dt);if(!Tt.ok)return;const At=await Tt.json();T(wt=>({...wt,[ae.name]:[...wt[ae.name]||[],...At.sessions||[]]})),At.hasMore===!1&&G(wt=>({...wt,[ae.name]:!1}))}catch(dt){console.error("Error loading more sessions:",dt)}finally{v(dt=>({...dt,[ae.name]:!1}))}}},[E,C,re]),Ee=l.useCallback(ae=>{c(ae),h(ae)},[c,h]),Le=l.useCallback(async()=>{J(!0);try{await i()}finally{J(!1)}},[i]),Pe=l.useCallback(async(ae,be,ze)=>{$(null),te("")},[]),Ae=l.useCallback(()=>{p(!1)},[p]),Ge=l.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:de,expandedProjects:x,editingProject:N,showNewProject:y,editingName:I,loadingSessions:C,additionalSessions:E,initialSessionsLoaded:W,currentTime:O,projectSortOrder:R,isRefreshing:z,editingSession:ie,editingSessionName:Z,searchFilter:Q,deletingProjects:F,deleteConfirmation:U,sessionDeleteConfirmation:ee,showVersionModal:w,starredProjects:Y,filteredProjects:K,handleTouchClick:je,toggleProject:ge,handleSessionClick:Re,toggleStarProject:Ne,isProjectStarred:De,getProjectSessions:Ue,startEditing:pe,cancelEditing:ye,saveProjectName:Ie,showDeleteSessionConfirmation:Fe,confirmDeleteSession:Se,requestProjectDelete:Oe,confirmDeleteProject:ne,loadMoreSessions:fe,handleProjectSelect:Ee,refreshProjects:Le,updateSessionSummary:Pe,collapseSidebar:Ae,expandSidebar:Ge,setShowNewProject:k,setEditingName:D,setEditingSession:$,setEditingSessionName:te,setSearchFilter:_,setDeleteConfirmation:B,setSessionDeleteConfirmation:V,setShowVersionModal:M}}function Ml({onExpand:t,onShowSettings:r,updateAvailable:s,onShowVersionModal:a,t:n}){return e.jsxs("div",{className:"h-full flex flex-col items-center py-3 gap-1 bg-background/80 backdrop-blur-sm w-12",children:[e.jsx("button",{onClick:t,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("common:versionUpdate.ariaLabels.showSidebar"),title:n("common:versionUpdate.ariaLabels.showSidebar"),children:e.jsx("img",{src:"/favicon.svg",alt:"",className:"w-6 h-6 rounded"})}),e.jsx("div",{className:"nav-divider w-6 my-1"}),e.jsx("button",{onClick:r,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("actions.settings"),title:n("actions.settings"),children:e.jsx(Dt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),s&&e.jsxs("button",{onClick:a,className:"relative w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors","aria-label":n("common:versionUpdate.ariaLabels.updateAvailable"),title:n("common:versionUpdate.ariaLabels.updateAvailable"),children:[e.jsx(Ut,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]})]})}function bo(t){var r,s,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(r=0;r<n;r++)t[r]&&(s=bo(t[r]))&&(a&&(a+=" "),a+=s)}else for(s in t)t[s]&&(a&&(a+=" "),a+=s);return a}function yo(){for(var t,r,s=0,a="",n=arguments.length;s<n;s++)(t=arguments[s])&&(r=bo(t))&&(a&&(a+=" "),a+=r);return a}const Dl=(t,r)=>{const s=new Array(t.length+r.length);for(let a=0;a<t.length;a++)s[a]=t[a];for(let a=0;a<r.length;a++)s[t.length+a]=r[a];return s},Ll=(t,r)=>({classGroupId:t,validator:r}),vo=(t=new Map,r=null,s)=>({nextPart:t,validators:r,classGroupId:s}),ns="-",Va=[],Pl="arbitrary..",$l=t=>{const r=Fl(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return _l(i);const c=i.split(ns),u=c[0]===""&&c.length>1?1:0;return ko(c,u,r)},getConflictingClassGroupIds:(i,c)=>{if(c){const u=a[i],d=s[i];return u?d?Dl(d,u):u:d||Va}return s[i]||Va}}},ko=(t,r,s)=>{if(t.length-r===0)return s.classGroupId;const n=t[r],o=s.nextPart.get(n);if(o){const d=ko(t,r+1,o);if(d)return d}const i=s.validators;if(i===null)return;const c=r===0?t.join(ns):t.slice(r).join(ns),u=i.length;for(let d=0;d<u;d++){const m=i[d];if(m.validator(c))return m.classGroupId}},_l=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=t.slice(1,-1),s=r.indexOf(":"),a=r.slice(0,s);return a?Pl+a:void 0})(),Fl=t=>{const{theme:r,classGroups:s}=t;return zl(s,r)},zl=(t,r)=>{const s=vo();for(const a in t){const n=t[a];Na(n,s,a,r)}return s},Na=(t,r,s,a)=>{const n=t.length;for(let o=0;o<n;o++){const i=t[o];Rl(i,r,s,a)}},Rl=(t,r,s,a)=>{if(typeof t=="string"){Ol(t,r,s);return}if(typeof t=="function"){Bl(t,r,s,a);return}Wl(t,r,s,a)},Ol=(t,r,s)=>{const a=t===""?r:wo(r,t);a.classGroupId=s},Bl=(t,r,s,a)=>{if(Ul(t)){Na(t(a),r,s,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Ll(s,t))},Wl=(t,r,s,a)=>{const n=Object.entries(t),o=n.length;for(let i=0;i<o;i++){const[c,u]=n[i];Na(u,wo(r,c),s,a)}},wo=(t,r)=>{let s=t;const a=r.split(ns),n=a.length;for(let o=0;o<n;o++){const i=a[o];let c=s.nextPart.get(i);c||(c=vo(),s.nextPart.set(i,c)),s=c}return s},Ul=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,Hl=t=>{if(t<1)return{get:()=>{},set:()=>{}};let r=0,s=Object.create(null),a=Object.create(null);const n=(o,i)=>{s[o]=i,r++,r>t&&(r=0,a=s,s=Object.create(null))};return{get(o){let i=s[o];if(i!==void 0)return i;if((i=a[o])!==void 0)return n(o,i),i},set(o,i){o in s?s[o]=i:n(o,i)}}},Xs="!",qa=":",Gl=[],Ka=(t,r,s,a,n)=>({modifiers:t,hasImportantModifier:r,baseClassName:s,maybePostfixModifierPosition:a,isExternal:n}),Vl=t=>{const{prefix:r,experimentalParseClassName:s}=t;let a=n=>{const o=[];let i=0,c=0,u=0,d;const m=n.length;for(let x=0;x<m;x++){const b=n[x];if(i===0&&c===0){if(b===qa){o.push(n.slice(u,x)),u=x+1;continue}if(b==="/"){d=x;continue}}b==="["?i++:b==="]"?i--:b==="("?c++:b===")"&&c--}const h=o.length===0?n:n.slice(u);let p=h,g=!1;h.endsWith(Xs)?(p=h.slice(0,-1),g=!0):h.startsWith(Xs)&&(p=h.slice(1),g=!0);const f=d&&d>u?d-u:void 0;return Ka(o,g,p,f)};if(r){const n=r+qa,o=a;a=i=>i.startsWith(n)?o(i.slice(n.length)):Ka(Gl,!1,i,void 0,!0)}if(s){const n=a;a=o=>s({className:o,parseClassName:n})}return a},ql=t=>{const r=new Map;return t.orderSensitiveModifiers.forEach((s,a)=>{r.set(s,1e6+a)}),s=>{const a=[];let n=[];for(let o=0;o<s.length;o++){const i=s[o],c=i[0]==="[",u=r.has(i);c||u?(n.length>0&&(n.sort(),a.push(...n),n=[]),a.push(i)):n.push(i)}return n.length>0&&(n.sort(),a.push(...n)),a}},Kl=t=>({cache:Hl(t.cacheSize),parseClassName:Vl(t),sortModifiers:ql(t),...$l(t)}),Jl=/\s+/,Yl=(t,r)=>{const{parseClassName:s,getClassGroupId:a,getConflictingClassGroupIds:n,sortModifiers:o}=r,i=[],c=t.trim().split(Jl);let u="";for(let d=c.length-1;d>=0;d-=1){const m=c[d],{isExternal:h,modifiers:p,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:x}=s(m);if(h){u=m+(u.length>0?" "+u:u);continue}let b=!!x,N=a(b?f.substring(0,x):f);if(!N){if(!b){u=m+(u.length>0?" "+u:u);continue}if(N=a(f),!N){u=m+(u.length>0?" "+u:u);continue}b=!1}const j=p.length===0?"":p.length===1?p[0]:o(p).join(":"),y=g?j+Xs:j,k=y+N;if(i.indexOf(k)>-1)continue;i.push(k);const I=n(N,b);for(let D=0;D<I.length;++D){const C=I[D];i.push(y+C)}u=m+(u.length>0?" "+u:u)}return u},Ql=(...t)=>{let r=0,s,a,n="";for(;r<t.length;)(s=t[r++])&&(a=jo(s))&&(n&&(n+=" "),n+=a);return n},jo=t=>{if(typeof t=="string")return t;let r,s="";for(let a=0;a<t.length;a++)t[a]&&(r=jo(t[a]))&&(s&&(s+=" "),s+=r);return s},Xl=(t,...r)=>{let s,a,n,o;const i=u=>{const d=r.reduce((m,h)=>h(m),t());return s=Kl(d),a=s.cache.get,n=s.cache.set,o=c,c(u)},c=u=>{const d=a(u);if(d)return d;const m=Yl(u,s);return n(u,m),m};return o=i,(...u)=>o(Ql(...u))},Zl=[],rt=t=>{const r=s=>s[t]||Zl;return r.isThemeGetter=!0,r},No=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Co=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ec=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,tc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,rc=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,sc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ac=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,nc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Rt=t=>ec.test(t),$e=t=>!!t&&!Number.isNaN(Number(t)),Ot=t=>!!t&&Number.isInteger(Number(t)),Ps=t=>t.endsWith("%")&&$e(t.slice(0,-1)),Mt=t=>tc.test(t),So=()=>!0,oc=t=>rc.test(t)&&!sc.test(t),Ca=()=>!1,ic=t=>ac.test(t),lc=t=>nc.test(t),cc=t=>!me(t)&&!xe(t),dc=t=>Ht(t,Ao,Ca),me=t=>No.test(t),Jt=t=>Ht(t,Io,oc),Ja=t=>Ht(t,bc,$e),uc=t=>Ht(t,Do,So),mc=t=>Ht(t,Mo,Ca),Ya=t=>Ht(t,Eo,Ca),pc=t=>Ht(t,To,lc),Hr=t=>Ht(t,Lo,ic),xe=t=>Co.test(t),kr=t=>ar(t,Io),xc=t=>ar(t,Mo),Qa=t=>ar(t,Eo),gc=t=>ar(t,Ao),hc=t=>ar(t,To),Gr=t=>ar(t,Lo,!0),fc=t=>ar(t,Do,!0),Ht=(t,r,s)=>{const a=No.exec(t);return a?a[1]?r(a[1]):s(a[2]):!1},ar=(t,r,s=!1)=>{const a=Co.exec(t);return a?a[1]?r(a[1]):s:!1},Eo=t=>t==="position"||t==="percentage",To=t=>t==="image"||t==="url",Ao=t=>t==="length"||t==="size"||t==="bg-size",Io=t=>t==="length",bc=t=>t==="number",Mo=t=>t==="family-name",Do=t=>t==="number"||t==="weight",Lo=t=>t==="shadow",yc=()=>{const t=rt("color"),r=rt("font"),s=rt("text"),a=rt("font-weight"),n=rt("tracking"),o=rt("leading"),i=rt("breakpoint"),c=rt("container"),u=rt("spacing"),d=rt("radius"),m=rt("shadow"),h=rt("inset-shadow"),p=rt("text-shadow"),g=rt("drop-shadow"),f=rt("blur"),x=rt("perspective"),b=rt("aspect"),N=rt("ease"),j=rt("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],I=()=>[...k(),xe,me],D=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],v=()=>[xe,me,u],E=()=>[Rt,"full","auto",...v()],T=()=>[Ot,"none","subgrid",xe,me],W=()=>["auto",{span:["full",Ot,xe,me]},Ot,xe,me],S=()=>[Ot,"auto",xe,me],O=()=>["auto","min","max","fr",xe,me],H=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],R=()=>["start","end","center","stretch","center-safe","end-safe"],A=()=>["auto",...v()],z=()=>[Rt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],J=()=>[Rt,"screen","full","dvw","lvw","svw","min","max","fit",...v()],re=()=>[Rt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],G=()=>[t,xe,me],ie=()=>[...k(),Qa,Ya,{position:[xe,me]}],$=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Z=()=>["auto","cover","contain",gc,dc,{size:[xe,me]}],te=()=>[Ps,kr,Jt],Q=()=>["","none","full",d,xe,me],_=()=>["",$e,kr,Jt],F=()=>["solid","dashed","dotted","double"],q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>[$e,Ps,Qa,Ya],B=()=>["","none",f,xe,me],ee=()=>["none",$e,xe,me],V=()=>["none",$e,xe,me],w=()=>[$e,xe,me],M=()=>[Rt,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Mt],breakpoint:[Mt],color:[So],container:[Mt],"drop-shadow":[Mt],ease:["in","out","in-out"],font:[cc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Mt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Mt],shadow:[Mt],spacing:["px",$e],text:[Mt],"text-shadow":[Mt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Rt,me,xe,b]}],container:["container"],columns:[{columns:[$e,me,xe,c]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:I()}],overflow:[{overflow:D()}],"overflow-x":[{"overflow-x":D()}],"overflow-y":[{"overflow-y":D()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{"inset-s":E(),start:E()}],end:[{"inset-e":E(),end:E()}],"inset-bs":[{"inset-bs":E()}],"inset-be":[{"inset-be":E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[Ot,"auto",xe,me]}],basis:[{basis:[Rt,"full","auto",c,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[$e,Rt,"auto","initial","none",me]}],grow:[{grow:["",$e,xe,me]}],shrink:[{shrink:["",$e,xe,me]}],order:[{order:[Ot,"first","last","none",xe,me]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:W()}],"col-start":[{"col-start":S()}],"col-end":[{"col-end":S()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:W()}],"row-start":[{"row-start":S()}],"row-end":[{"row-end":S()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":O()}],"auto-rows":[{"auto-rows":O()}],gap:[{gap:v()}],"gap-x":[{"gap-x":v()}],"gap-y":[{"gap-y":v()}],"justify-content":[{justify:[...H(),"normal"]}],"justify-items":[{"justify-items":[...R(),"normal"]}],"justify-self":[{"justify-self":["auto",...R()]}],"align-content":[{content:["normal",...H()]}],"align-items":[{items:[...R(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...R(),{baseline:["","last"]}]}],"place-content":[{"place-content":H()}],"place-items":[{"place-items":[...R(),"baseline"]}],"place-self":[{"place-self":["auto",...R()]}],p:[{p:v()}],px:[{px:v()}],py:[{py:v()}],ps:[{ps:v()}],pe:[{pe:v()}],pbs:[{pbs:v()}],pbe:[{pbe:v()}],pt:[{pt:v()}],pr:[{pr:v()}],pb:[{pb:v()}],pl:[{pl:v()}],m:[{m:A()}],mx:[{mx:A()}],my:[{my:A()}],ms:[{ms:A()}],me:[{me:A()}],mbs:[{mbs:A()}],mbe:[{mbe:A()}],mt:[{mt:A()}],mr:[{mr:A()}],mb:[{mb:A()}],ml:[{ml:A()}],"space-x":[{"space-x":v()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":v()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],"inline-size":[{inline:["auto",...J()]}],"min-inline-size":[{"min-inline":["auto",...J()]}],"max-inline-size":[{"max-inline":["none",...J()]}],"block-size":[{block:["auto",...re()]}],"min-block-size":[{"min-block":["auto",...re()]}],"max-block-size":[{"max-block":["none",...re()]}],w:[{w:[c,"screen",...z()]}],"min-w":[{"min-w":[c,"screen","none",...z()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",s,kr,Jt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,fc,uc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ps,me]}],"font-family":[{font:[xc,mc,r]}],"font-features":[{"font-features":[me]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[n,xe,me]}],"line-clamp":[{"line-clamp":[$e,"none",xe,Ja]}],leading:[{leading:[o,...v()]}],"list-image":[{"list-image":["none",xe,me]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",xe,me]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:G()}],"text-color":[{text:G()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...F(),"wavy"]}],"text-decoration-thickness":[{decoration:[$e,"from-font","auto",xe,Jt]}],"text-decoration-color":[{decoration:G()}],"underline-offset":[{"underline-offset":[$e,"auto",xe,me]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:v()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",xe,me]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",xe,me]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:$()}],"bg-size":[{bg:Z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ot,xe,me],radial:["",xe,me],conic:[Ot,xe,me]},hc,pc]}],"bg-color":[{bg:G()}],"gradient-from-pos":[{from:te()}],"gradient-via-pos":[{via:te()}],"gradient-to-pos":[{to:te()}],"gradient-from":[{from:G()}],"gradient-via":[{via:G()}],"gradient-to":[{to:G()}],rounded:[{rounded:Q()}],"rounded-s":[{"rounded-s":Q()}],"rounded-e":[{"rounded-e":Q()}],"rounded-t":[{"rounded-t":Q()}],"rounded-r":[{"rounded-r":Q()}],"rounded-b":[{"rounded-b":Q()}],"rounded-l":[{"rounded-l":Q()}],"rounded-ss":[{"rounded-ss":Q()}],"rounded-se":[{"rounded-se":Q()}],"rounded-ee":[{"rounded-ee":Q()}],"rounded-es":[{"rounded-es":Q()}],"rounded-tl":[{"rounded-tl":Q()}],"rounded-tr":[{"rounded-tr":Q()}],"rounded-br":[{"rounded-br":Q()}],"rounded-bl":[{"rounded-bl":Q()}],"border-w":[{border:_()}],"border-w-x":[{"border-x":_()}],"border-w-y":[{"border-y":_()}],"border-w-s":[{"border-s":_()}],"border-w-e":[{"border-e":_()}],"border-w-bs":[{"border-bs":_()}],"border-w-be":[{"border-be":_()}],"border-w-t":[{"border-t":_()}],"border-w-r":[{"border-r":_()}],"border-w-b":[{"border-b":_()}],"border-w-l":[{"border-l":_()}],"divide-x":[{"divide-x":_()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":_()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...F(),"hidden","none"]}],"divide-style":[{divide:[...F(),"hidden","none"]}],"border-color":[{border:G()}],"border-color-x":[{"border-x":G()}],"border-color-y":[{"border-y":G()}],"border-color-s":[{"border-s":G()}],"border-color-e":[{"border-e":G()}],"border-color-bs":[{"border-bs":G()}],"border-color-be":[{"border-be":G()}],"border-color-t":[{"border-t":G()}],"border-color-r":[{"border-r":G()}],"border-color-b":[{"border-b":G()}],"border-color-l":[{"border-l":G()}],"divide-color":[{divide:G()}],"outline-style":[{outline:[...F(),"none","hidden"]}],"outline-offset":[{"outline-offset":[$e,xe,me]}],"outline-w":[{outline:["",$e,kr,Jt]}],"outline-color":[{outline:G()}],shadow:[{shadow:["","none",m,Gr,Hr]}],"shadow-color":[{shadow:G()}],"inset-shadow":[{"inset-shadow":["none",h,Gr,Hr]}],"inset-shadow-color":[{"inset-shadow":G()}],"ring-w":[{ring:_()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:G()}],"ring-offset-w":[{"ring-offset":[$e,Jt]}],"ring-offset-color":[{"ring-offset":G()}],"inset-ring-w":[{"inset-ring":_()}],"inset-ring-color":[{"inset-ring":G()}],"text-shadow":[{"text-shadow":["none",p,Gr,Hr]}],"text-shadow-color":[{"text-shadow":G()}],opacity:[{opacity:[$e,xe,me]}],"mix-blend":[{"mix-blend":[...q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":q()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[$e]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":G()}],"mask-image-linear-to-color":[{"mask-linear-to":G()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":G()}],"mask-image-t-to-color":[{"mask-t-to":G()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":G()}],"mask-image-r-to-color":[{"mask-r-to":G()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":G()}],"mask-image-b-to-color":[{"mask-b-to":G()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":G()}],"mask-image-l-to-color":[{"mask-l-to":G()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":G()}],"mask-image-x-to-color":[{"mask-x-to":G()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":G()}],"mask-image-y-to-color":[{"mask-y-to":G()}],"mask-image-radial":[{"mask-radial":[xe,me]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":G()}],"mask-image-radial-to-color":[{"mask-radial-to":G()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":k()}],"mask-image-conic-pos":[{"mask-conic":[$e]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":G()}],"mask-image-conic-to-color":[{"mask-conic-to":G()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:$()}],"mask-size":[{mask:Z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",xe,me]}],filter:[{filter:["","none",xe,me]}],blur:[{blur:B()}],brightness:[{brightness:[$e,xe,me]}],contrast:[{contrast:[$e,xe,me]}],"drop-shadow":[{"drop-shadow":["","none",g,Gr,Hr]}],"drop-shadow-color":[{"drop-shadow":G()}],grayscale:[{grayscale:["",$e,xe,me]}],"hue-rotate":[{"hue-rotate":[$e,xe,me]}],invert:[{invert:["",$e,xe,me]}],saturate:[{saturate:[$e,xe,me]}],sepia:[{sepia:["",$e,xe,me]}],"backdrop-filter":[{"backdrop-filter":["","none",xe,me]}],"backdrop-blur":[{"backdrop-blur":B()}],"backdrop-brightness":[{"backdrop-brightness":[$e,xe,me]}],"backdrop-contrast":[{"backdrop-contrast":[$e,xe,me]}],"backdrop-grayscale":[{"backdrop-grayscale":["",$e,xe,me]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[$e,xe,me]}],"backdrop-invert":[{"backdrop-invert":["",$e,xe,me]}],"backdrop-opacity":[{"backdrop-opacity":[$e,xe,me]}],"backdrop-saturate":[{"backdrop-saturate":[$e,xe,me]}],"backdrop-sepia":[{"backdrop-sepia":["",$e,xe,me]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":v()}],"border-spacing-x":[{"border-spacing-x":v()}],"border-spacing-y":[{"border-spacing-y":v()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",xe,me]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[$e,"initial",xe,me]}],ease:[{ease:["linear","initial",N,xe,me]}],delay:[{delay:[$e,xe,me]}],animate:[{animate:["none",j,xe,me]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,xe,me]}],"perspective-origin":[{"perspective-origin":I()}],rotate:[{rotate:ee()}],"rotate-x":[{"rotate-x":ee()}],"rotate-y":[{"rotate-y":ee()}],"rotate-z":[{"rotate-z":ee()}],scale:[{scale:V()}],"scale-x":[{"scale-x":V()}],"scale-y":[{"scale-y":V()}],"scale-z":[{"scale-z":V()}],"scale-3d":["scale-3d"],skew:[{skew:w()}],"skew-x":[{"skew-x":w()}],"skew-y":[{"skew-y":w()}],transform:[{transform:[xe,me,"","none","gpu","cpu"]}],"transform-origin":[{origin:I()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:M()}],"translate-x":[{"translate-x":M()}],"translate-y":[{"translate-y":M()}],"translate-z":[{"translate-z":M()}],"translate-none":["translate-none"],accent:[{accent:G()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:G()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",xe,me]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":v()}],"scroll-mx":[{"scroll-mx":v()}],"scroll-my":[{"scroll-my":v()}],"scroll-ms":[{"scroll-ms":v()}],"scroll-me":[{"scroll-me":v()}],"scroll-mbs":[{"scroll-mbs":v()}],"scroll-mbe":[{"scroll-mbe":v()}],"scroll-mt":[{"scroll-mt":v()}],"scroll-mr":[{"scroll-mr":v()}],"scroll-mb":[{"scroll-mb":v()}],"scroll-ml":[{"scroll-ml":v()}],"scroll-p":[{"scroll-p":v()}],"scroll-px":[{"scroll-px":v()}],"scroll-py":[{"scroll-py":v()}],"scroll-ps":[{"scroll-ps":v()}],"scroll-pe":[{"scroll-pe":v()}],"scroll-pbs":[{"scroll-pbs":v()}],"scroll-pbe":[{"scroll-pbe":v()}],"scroll-pt":[{"scroll-pt":v()}],"scroll-pr":[{"scroll-pr":v()}],"scroll-pb":[{"scroll-pb":v()}],"scroll-pl":[{"scroll-pl":v()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",xe,me]}],fill:[{fill:["none",...G()]}],"stroke-w":[{stroke:[$e,kr,Jt,Ja]}],stroke:[{stroke:["none",...G()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},vc=Xl(yc);function ke(...t){return vc(yo(t))}function kc(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const Po=l.forwardRef(({className:t,children:r,...s},a)=>e.jsx("div",{className:ke(t,"relative overflow-hidden"),...s,children:e.jsx("div",{ref:a,className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));Po.displayName="ScrollArea";function wc({updateAvailable:t,releaseInfo:r,latestVersion:s,onShowVersionModal:a,onShowSettings:n,t:o}){return e.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-left hover:bg-blue-50/80 dark:hover:bg-blue-900/15 transition-colors group",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx($a,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:(r==null?void 0:r.title)||`v${s}`}),e.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})}),e.jsx("div",{className:"md:hidden px-3 py-2",children:e.jsxs("button",{className:"w-full h-11 bg-blue-50/80 dark:bg-blue-900/15 border border-blue-200/60 dark:border-blue-700/40 rounded-xl flex items-center gap-3 px-3.5 active:scale-[0.98] transition-all",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx($a,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:(r==null?void 0:r.title)||`v${s}`}),e.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})})]}),e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors",onClick:n,children:[e.jsx(Dt,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),e.jsx("div",{className:"md:hidden p-3 pb-20",children:e.jsxs("button",{className:"w-full h-12 bg-muted/40 hover:bg-muted/60 rounded-xl flex items-center gap-3.5 px-4 active:scale-[0.98] transition-all",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-background/80 flex items-center justify-center",children:e.jsx(Dt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),e.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const Xa=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Za=yo,$o=(t,r)=>s=>{var a;if((r==null?void 0:r.variants)==null)return Za(t,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:n,defaultVariants:o}=r,i=Object.keys(n).map(d=>{const m=s==null?void 0:s[d],h=o==null?void 0:o[d];if(m===null)return null;const p=Xa(m)||Xa(h);return n[d][p]}),c=s&&Object.entries(s).reduce((d,m)=>{let[h,p]=m;return p===void 0||(d[h]=p),d},{}),u=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((d,m)=>{let{class:h,className:p,...g}=m;return Object.entries(g).every(f=>{let[x,b]=f;return Array.isArray(b)?b.includes({...o,...c}[x]):{...o,...c}[x]===b})?[...d,h,p]:d},[]);return Za(t,i,u,s==null?void 0:s.class,s==null?void 0:s.className)},jc=$o("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),he=l.forwardRef(({className:t,variant:r,size:s,...a},n)=>e.jsx("button",{className:ke(jc({variant:r,size:s,className:t})),ref:n,...a}));he.displayName="Button";const Ze=l.forwardRef(({className:t,type:r,...s},a)=>e.jsx("input",{type:r,className:ke("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),ref:a,...s}));Ze.displayName="Input";function Nc({isPWA:t,isMobile:r,isLoading:s,projectsCount:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,t:h}){const p=()=>e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("img",{src:"/favicon.svg",alt:"",className:"w-7 h-7 rounded-lg flex-shrink-0"}),e.jsx("h1",{className:"text-sm font-semibold text-foreground tracking-tight truncate",children:h("app.title")})]});return e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"hidden md:block px-3 pt-3 pb-2",style:{},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(p,{}),e.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(he,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:c,disabled:u,title:h("tooltips.refresh"),children:e.jsx(Vs,{className:`w-3.5 h-3.5 ${u?"animate-spin":""}`})}),e.jsx(he,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:d,title:h("tooltips.createProject"),children:e.jsx(at,{className:"w-3.5 h-3.5"})}),e.jsx(he,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:m,title:h("tooltips.hideSidebar"),children:e.jsx(fi,{className:"w-3.5 h-3.5"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(Ar,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground/50 pointer-events-none"}),e.jsx(Ze,{type:"text",placeholder:h("projects.searchPlaceholder"),value:n,onChange:g=>o(g.target.value),className:"nav-search-input pl-9 pr-8 h-9 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-accent rounded-md",children:e.jsx(Ve,{className:"w-3 h-3 text-muted-foreground"})})]})]}),e.jsx("div",{className:"hidden md:block nav-divider"}),e.jsxs("div",{className:"md:hidden p-3 pb-2",style:t&&r?{paddingTop:"16px"}:{},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{}),e.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-muted/50 flex items-center justify-center active:scale-95 transition-all",onClick:c,disabled:u,children:e.jsx(Vs,{className:`w-4 h-4 text-muted-foreground ${u?"animate-spin":""}`})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/90 text-primary-foreground flex items-center justify-center active:scale-95 transition-all",onClick:d,children:e.jsx(Zr,{className:"w-4 h-4"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(Ar,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 pointer-events-none"}),e.jsx(Ze,{type:"text",placeholder:h("projects.searchPlaceholder"),value:n,onChange:g=>o(g.target.value),className:"nav-search-input pl-10 pr-9 h-10 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 hover:bg-accent rounded-md",children:e.jsx(Ve,{className:"w-3.5 h-3.5 text-muted-foreground"})})]})]}),e.jsx("div",{className:"md:hidden nav-divider"})]})}const Cc=({status:t="not-configured",size:r="sm",className:s="",showLabel:a=!1})=>{const o=(()=>{switch(t){case"fully-configured":return{icon:Pr,color:"text-green-500 dark:text-green-400",bgColor:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"};case"taskmaster-only":return{icon:Dt,color:"text-blue-500 dark:text-blue-400",bgColor:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"};case"mcp-only":return{icon:xs,color:"text-amber-500 dark:text-amber-400",bgColor:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"};case"not-configured":case"error":default:return{icon:Ve,color:"text-gray-400 dark:text-gray-500",bgColor:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"}}})(),i=o.icon,c={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},u={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"};return a?e.jsxs("div",{className:ke("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",o.bgColor,o.color,s),title:o.title,children:[e.jsx(i,{className:c[r]}),e.jsx("span",{className:"font-medium",children:o.label})]}):e.jsx("div",{className:ke("inline-flex items-center justify-center rounded-full transition-colors",o.bgColor,u[r],s),title:o.title,children:e.jsx(i,{className:ke(c[r],o.color)})})},Sc=$o("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function bt({className:t,variant:r,...s}){return e.jsx("div",{className:ke(Sc({variant:r}),t),...s})}const en=(t,r,s)=>{const a=new Date(t),n=r;if(isNaN(a.getTime()))return s?s("status.unknown"):"Unknown";const o=n.getTime()-a.getTime(),i=Math.floor(o/1e3),c=Math.floor(o/(1e3*60)),u=Math.floor(o/(1e3*60*60)),d=Math.floor(o/(1e3*60*60*24));return i<60?s?s("time.justNow"):"Just now":c===1?s?s("time.oneMinuteAgo"):"1 min ago":c<60?s?s("time.minutesAgo",{count:c}):`${c} mins ago`:u===1?s?s("time.oneHourAgo"):"1 hour ago":u<24?s?s("time.hoursAgo",{count:u}):`${u} hours ago`:d===1?s?s("time.oneDayAgo"):"1 day ago":d<7?s?s("time.daysAgo",{count:d}):`${d} days ago`:a.toLocaleDateString()};function ft({provider:t="claude",className:r="w-5 h-5"}){return t==="cursor"?e.jsx(Ui,{className:r}):t==="codex"?e.jsx(Hi,{className:r}):e.jsx(Gi,{className:r})}function Ec({project:t,session:r,selectedSession:s,currentTime:a,editingSession:n,editingSessionName:o,onEditingSessionNameChange:i,onStartEditingSession:c,onCancelEditingSession:u,onSaveEditingSession:d,onProjectSelect:m,onSessionSelect:h,onDeleteSession:p,touchHandlerFactory:g,t:f}){const x=Cl(r,a,f),b=(s==null?void 0:s.id)===r.id,N=()=>{m(t),h(r,t.name)},j=()=>{d(t.name,r.id,o)},y=()=>{p(t.name,r.id,x.sessionName,r.__provider)};return e.jsxs("div",{className:"group relative",children:[x.isActive&&e.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-y-1/2 -translate-x-1",children:e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})}),e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:ke("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",b?"bg-primary/5 border-primary/20":"",!b&&x.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:N,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:ke("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",b?"bg-primary/10":"bg-muted/50"),children:e.jsx(ft,{provider:r.__provider,className:"w-3 h-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:x.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Ir,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:en(x.sessionTime,a,f)}),x.messageCount>0&&e.jsx(bt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:x.messageCount}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(ft,{provider:r.__provider,className:"w-3 h-3"})})]})]}),!x.isCursorSession&&e.jsx("button",{className:"w-5 h-5 rounded-md bg-red-50 dark:bg-red-900/20 flex items-center justify-center active:scale-95 transition-transform opacity-70 ml-1",onClick:k=>{k.stopPropagation(),y()},children:e.jsx(yt,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(he,{variant:"ghost",className:ke("w-full justify-start px-2 py-2.5 h-auto min-h-[48px] font-normal text-left hover:bg-accent/50 transition-colors duration-200",b&&"bg-accent text-accent-foreground"),onClick:()=>h(r,t.name),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full pr-14",children:[e.jsx(ft,{provider:r.__provider,className:"w-3 h-3 mt-1 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground leading-5",children:x.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Ir,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:en(x.sessionTime,a,f)}),x.messageCount>0&&e.jsx(bt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto group-hover:opacity-0 transition-opacity",children:x.messageCount}),e.jsx("span",{className:"ml-1 opacity-70 group-hover:opacity-0 transition-opacity",children:e.jsx(ft,{provider:r.__provider,className:"w-3 h-3"})})]})]})]})}),!x.isCursorSession&&e.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-all duration-200 bg-accent/80 backdrop-blur-sm rounded-md px-1 py-0.5",children:n===r.id&&!x.isCodexSession?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:o,onChange:k=>i(k.target.value),onKeyDown:k=>{k.stopPropagation(),k.key==="Enter"?j():k.key==="Escape"&&u()},onClick:k=>k.stopPropagation(),className:"w-32 px-2 py-1 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"w-6 h-6 bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),j()},title:f("tooltips.save"),children:e.jsx(Lt,{className:"w-3 h-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),u()},title:f("tooltips.cancel"),children:e.jsx(Ve,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})})]}):e.jsxs(e.Fragment,{children:[!x.isCodexSession&&e.jsx("button",{className:"w-7 h-7 bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),c(r.id,r.summary||f("projects.newSession"))},title:f("tooltips.editSessionName"),children:e.jsx(bi,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-7 h-7 bg-red-50 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),y()},title:f("tooltips.deleteSession"),children:e.jsx(yt,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]})}function Tc(){return e.jsx(e.Fragment,{children:Array.from({length:3}).map((t,r)=>e.jsx("div",{className:"p-2 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-3 h-3 bg-muted rounded-full animate-pulse mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 bg-muted rounded animate-pulse",style:{width:`${60+r*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},r))})}function Ac({project:t,isExpanded:r,sessions:s,selectedSession:a,initialSessionsLoaded:n,isLoadingSessions:o,currentTime:i,editingSession:c,editingSessionName:u,onEditingSessionNameChange:d,onStartEditingSession:m,onCancelEditingSession:h,onSaveEditingSession:p,onProjectSelect:g,onSessionSelect:f,onDeleteSession:x,onLoadMoreSessions:b,onNewSession:N,touchHandlerFactory:j,t:y}){var D;if(!r)return null;const k=s.length>0,I=((D=t.sessionMeta)==null?void 0:D.hasMore)===!0;return e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[n?!k&&!o?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:y("sessions.noSessions")})}):s.map(C=>e.jsx(Ec,{project:t,session:C,selectedSession:a,currentTime:i,editingSession:c,editingSessionName:u,onEditingSessionNameChange:d,onStartEditingSession:m,onCancelEditingSession:h,onSaveEditingSession:p,onProjectSelect:g,onSessionSelect:f,onDeleteSession:x,touchHandlerFactory:j,t:y},C.id)):e.jsx(Tc,{}),k&&I&&e.jsx(he,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>b(t),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),y("sessions.loading")]}):e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"w-3 h-3"}),y("sessions.showMore")]})}),e.jsx("div",{className:"md:hidden px-3 pb-2",children:e.jsxs("button",{className:"w-full h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-md flex items-center justify-center gap-2 font-medium text-xs active:scale-[0.98] transition-all duration-150",onClick:()=>{g(t),N(t)},children:[e.jsx(at,{className:"w-3 h-3"}),y("sessions.newSession")]})}),e.jsxs(he,{variant:"default",size:"sm",className:"hidden md:flex w-full justify-start gap-2 mt-1 h-8 text-xs font-medium bg-primary hover:bg-primary/90 text-primary-foreground transition-colors",onClick:()=>N(t),children:[e.jsx(at,{className:"w-3 h-3"}),y("sessions.newSession")]})]})}const Ic=(t,r)=>{const s=t.length;return r&&s>=5?`${s}+`:`${s}`};function Mc({project:t,selectedProject:r,selectedSession:s,isExpanded:a,isDeleting:n,isStarred:o,editingProject:i,editingName:c,sessions:u,initialSessionsLoaded:d,isLoadingSessions:m,currentTime:h,editingSession:p,editingSessionName:g,tasksEnabled:f,mcpServerStatus:x,onEditingNameChange:b,onToggleProject:N,onProjectSelect:j,onToggleStarProject:y,onStartEditingProject:k,onCancelEditingProject:I,onSaveProjectName:D,onDeleteProject:C,onSessionSelect:v,onDeleteSession:E,onLoadMoreSessions:T,onNewSession:W,onEditingSessionNameChange:S,onStartEditingSession:O,onCancelEditingSession:H,onSaveEditingSession:R,onOpenProjectSettings:A,touchHandlerFactory:z,t:J}){var U;const re=(r==null?void 0:r.name)===t.name,G=i===t.name,ie=((U=t.sessionMeta)==null?void 0:U.hasMore)===!0,$=Ic(u,ie),Z=`${$} session${u.length===1?"":"s"}`,te=Tl(t,x),Q=()=>N(t.name),_=()=>y(t.name),F=()=>{D(t.name)},q=()=>{(r==null?void 0:r.name)!==t.name&&j(t),Q()};return e.jsxs("div",{className:ke("md:space-y-1",n&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"group md:group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:ke("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",re&&"bg-primary/5 border-primary/20",o&&!re&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:Q,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:ke("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",a?"bg-primary/10":"bg-muted"),children:a?e.jsx(er,{className:"w-4 h-4 text-primary"}):e.jsx(mr,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:G?e.jsx("input",{type:"text",value:c,onChange:B=>b(B.target.value),className:"w-full px-3 py-2 text-sm border-2 border-primary/40 focus:border-primary rounded-lg bg-background text-foreground shadow-sm focus:shadow-md transition-all duration-200 focus:outline-none",placeholder:J("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:B=>B.stopPropagation(),onKeyDown:B=>{B.key==="Enter"&&F(),B.key==="Escape"&&I()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between min-w-0 flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:t.displayName}),f&&e.jsx(Cc,{status:te,size:"xs",className:"hidden md:inline-flex flex-shrink-0 ml-2"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Z})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:G?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-green-500 dark:bg-green-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:B=>{B.stopPropagation(),F()},children:e.jsx(Lt,{className:"w-4 h-4 text-white"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500 dark:bg-gray-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:B=>{B.stopPropagation(),I()},children:e.jsx(Ve,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:ke("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",o?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:B=>{B.stopPropagation(),_()},title:J(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(_a,{className:ke("w-4 h-4 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500/10 dark:bg-gray-900/30 flex items-center justify-center active:scale-90 border border-gray-200 dark:border-gray-800",onClick:B=>{B.stopPropagation(),A(t)},title:J("tooltips.projectSettings",{defaultValue:"Project settings"}),children:e.jsx(Dt,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-red-500/10 dark:bg-red-900/30 flex items-center justify-center active:scale-90 border border-red-200 dark:border-red-800",onClick:B=>{B.stopPropagation(),C(t)},children:e.jsx(yt,{className:"w-4 h-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center active:scale-90 border border-primary/20 dark:border-primary/30",onClick:B=>{B.stopPropagation(),k(t)},children:e.jsx(Mr,{className:"w-4 h-4 text-primary"})}),e.jsx("div",{className:"w-6 h-6 rounded-md bg-muted/30 flex items-center justify-center",children:a?e.jsx(Pt,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(rr,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(he,{variant:"ghost",className:ke("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",re&&"bg-accent text-accent-foreground",o&&!re&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:q,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a?e.jsx(er,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(mr,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:G?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:c,onChange:B=>b(B.target.value),className:"w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:ring-2 focus:ring-primary/20",placeholder:J("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:B=>{B.key==="Enter"&&F(),B.key==="Escape"&&I()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:t.fullPath,children:t.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:t.displayName,children:t.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[$,t.fullPath!==t.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:t.fullPath,children:[" - ",t.fullPath.length>25?`...${t.fullPath.slice(-22)}`:t.fullPath]})]})]})})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:G?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-900/20 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:B=>{B.stopPropagation(),F()},children:e.jsx(Lt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:B=>{B.stopPropagation(),I()},children:e.jsx(Ve,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ke("w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100",o?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:B=>{B.stopPropagation(),_()},title:J(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(_a,{className:ke("w-3 h-3 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:B=>{B.stopPropagation(),A(t)},title:J("tooltips.projectSettings",{defaultValue:"Project settings"}),children:e.jsx(Dt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:B=>{B.stopPropagation(),k(t)},title:J("tooltips.renameProject"),children:e.jsx(Mr,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:B=>{B.stopPropagation(),C(t)},title:J("tooltips.deleteProject"),children:e.jsx(yt,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),a?e.jsx(Pt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(rr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),e.jsx(Ac,{project:t,isExpanded:a,sessions:u,selectedSession:s,initialSessionsLoaded:d,isLoadingSessions:m,currentTime:h,editingSession:p,editingSessionName:g,onEditingSessionNameChange:S,onStartEditingSession:O,onCancelEditingSession:H,onSaveEditingSession:R,onProjectSelect:j,onSessionSelect:v,onDeleteSession:E,onLoadMoreSessions:T,onNewSession:W,touchHandlerFactory:z,t:J})]})}function Dc({isLoading:t,loadingProgress:r,projectsCount:s,filteredProjectsCount:a,t:n}){const{isRelayConnected:o}=ps();return t?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.loadingProjects")}),r&&r.total>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full transition-all duration-300 ease-out",style:{width:`${r.current/r.total*100}%`}})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.current,"/",r.total," ",n("projects.projects")]}),r.currentProject&&e.jsx("p",{className:"text-xs text-muted-foreground/70 truncate max-w-[200px] mx-auto",title:r.currentProject,children:r.currentProject.split("-").slice(-2).join("/")})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.fetchingProjects")})]}):s===0?o?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(mr,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.runClaudeCli")})]}):e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(Xn,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"No machine connected"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your machine to see projects"})]}):a===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(Ar,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noMatchingProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.tryDifferentSearch")})]}):null}function Lc({projects:t,filteredProjects:r,selectedProject:s,selectedSession:a,isLoading:n,loadingProgress:o,expandedProjects:i,editingProject:c,editingName:u,loadingSessions:d,initialSessionsLoaded:m,currentTime:h,editingSession:p,editingSessionName:g,deletingProjects:f,tasksEnabled:x,mcpServerStatus:b,getProjectSessions:N,isProjectStarred:j,onEditingNameChange:y,onToggleProject:k,onProjectSelect:I,onToggleStarProject:D,onStartEditingProject:C,onCancelEditingProject:v,onSaveProjectName:E,onDeleteProject:T,onSessionSelect:W,onDeleteSession:S,onLoadMoreSessions:O,onNewSession:H,onEditingSessionNameChange:R,onStartEditingSession:A,onCancelEditingSession:z,onSaveEditingSession:J,onOpenProjectSettings:re,touchHandlerFactory:G,t:ie}){const $=e.jsx(Dc,{isLoading:n,loadingProgress:o,projectsCount:t.length,filteredProjectsCount:r.length,t:ie}),Z=!n&&t.length>0&&r.length>0;return e.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:Z?r.map(te=>e.jsx(Mc,{project:te,selectedProject:s,selectedSession:a,isExpanded:i.has(te.name),isDeleting:f.has(te.name),isStarred:j(te.name),editingProject:c,editingName:u,sessions:N(te),initialSessionsLoaded:m.has(te.name),isLoadingSessions:!!d[te.name],currentTime:h,editingSession:p,editingSessionName:g,tasksEnabled:x,mcpServerStatus:b,onEditingNameChange:y,onToggleProject:k,onProjectSelect:I,onToggleStarProject:D,onStartEditingProject:C,onCancelEditingProject:v,onSaveProjectName:E,onDeleteProject:T,onSessionSelect:W,onDeleteSession:S,onLoadMoreSessions:O,onNewSession:H,onEditingSessionNameChange:R,onStartEditingSession:A,onCancelEditingSession:z,onSaveEditingSession:J,onOpenProjectSettings:re,touchHandlerFactory:G,t:ie},te.name)):$})}function Pc({isPWA:t,isMobile:r,isLoading:s,projects:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,updateAvailable:h,releaseInfo:p,latestVersion:g,onShowVersionModal:f,onShowSettings:x,projectListProps:b,t:N}){return e.jsxs("div",{className:"h-full flex flex-col bg-background/80 backdrop-blur-sm md:select-none md:w-72",style:{},children:[e.jsx(Nc,{isPWA:t,isMobile:r,isLoading:s,projectsCount:a.length,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,t:N}),e.jsx(Po,{className:"flex-1 px-1.5 py-1.5 md:py-2 overflow-y-auto overscroll-contain",children:e.jsx(Lc,{...b})}),e.jsx(wc,{updateAvailable:h,releaseInfo:p,latestVersion:g,onShowVersionModal:f,onShowSettings:x,t:N})]})}const $c=({onClose:t,onProjectCreated:r})=>{var _e;const{t:s}=We(),[a,n]=l.useState(1),[o,i]=l.useState("existing"),[c,u]=l.useState(""),[d,m]=l.useState(""),[h,p]=l.useState(""),[g,f]=l.useState("stored"),[x,b]=l.useState(""),[N,j]=l.useState(!1),[y,k]=l.useState(null),[I,D]=l.useState([]),[C,v]=l.useState(!1),[E,T]=l.useState([]),[W,S]=l.useState(!1),[O,H]=l.useState(!1),[R,A]=l.useState("~"),[z,J]=l.useState([]),[re,G]=l.useState(!1),[ie,$]=l.useState(!1),[Z,te]=l.useState(!1),[Q,_]=l.useState(""),[F,q]=l.useState(!1),[U,B]=l.useState(""),[ee,V]=l.useState([]);l.useEffect(()=>{a===2&&o==="new"&&d&&w()},[a,o,d]),l.useEffect(()=>{c.length>2?M(c):(T([]),S(!1))},[c]);const w=async()=>{try{v(!0);const pe=((await(await Be.get("/settings/credentials?type=github_token")).json()).credentials||[]).filter(ye=>ye.is_active);D(pe),pe.length>0&&!h&&p(pe[0].id.toString())}catch(L){console.error("Error loading GitHub tokens:",L)}finally{v(!1)}},M=async L=>{try{const K=L.lastIndexOf("/"),pe=K>0?L.substring(0,K):"~",Ie=await(await Be.browseFilesystem(pe)).json();if(Ie.suggestions){const Fe=Ie.suggestions.filter(Se=>Se.path.toLowerCase().startsWith(L.toLowerCase())&&Se.path.toLowerCase()!==L.toLowerCase());T(Fe.slice(0,5)),S(Fe.length>0)}}catch(K){console.error("Error loading path suggestions:",K)}},Y=()=>{if(k(null),a===1){if(!o){k(s("projectWizard.errors.selectType"));return}n(2)}else if(a===2){if(!c.trim()){k(s("projectWizard.errors.providePath"));return}n(3)}},se=()=>{k(null),n(a-1)},de=async()=>{j(!0),k(null),B("");try{if(o==="new"&&d){const ye=new URLSearchParams({path:c.trim(),githubUrl:d.trim()});g==="stored"&&h?ye.append("githubTokenId",h):g==="new"&&x&&ye.append("newGithubToken",x.trim());const Ie=`/api/projects/clone-progress?${ye}`;await new Promise((Fe,Se)=>{const Oe=new EventSource(Ie);Oe.onmessage=ne=>{try{const fe=JSON.parse(ne.data);fe.type==="progress"?B(fe.message):fe.type==="complete"?(Oe.close(),r&&r(fe.project),t(),Fe()):fe.type==="error"&&(Oe.close(),Se(new Error(fe.message)))}catch(fe){console.error("Error parsing SSE event:",fe)}},Oe.onerror=()=>{Oe.close(),Se(new Error("Connection lost during clone"))}});return}const L={workspaceType:o,path:c.trim()},K=await Be.createWorkspace(L),pe=await K.json();if(!K.ok)throw new Error(pe.details||pe.error||s("projectWizard.errors.failedToCreate"));r&&r(pe.project),t()}catch(L){console.error("Error creating workspace:",L),k(L.message||s("projectWizard.errors.failedToCreate"))}finally{j(!1)}},je=L=>{u(L.path),S(!1)},ge=async()=>{H(!0),await Re("~")},Re=async L=>{try{G(!0);const pe=await(await Be.browseFilesystem(L)).json();A(pe.path||L),J(pe.suggestions||[]),pe.drives&&Array.isArray(pe.drives)&&V(pe.drives)}catch(K){console.error("Error loading folders:",K)}finally{G(!1)}},Ne=(L,K=!1)=>{u(L),H(!1),K&&n(3)},De=async L=>{await Re(L)},Ue=async()=>{if(Q.trim()){q(!0),k(null);try{const L=R.includes("\\")?"\\":"/",K=`${R}${L}${Q.trim()}`,pe=await Be.createFolder(K),ye=await pe.json();if(!pe.ok)throw new Error(ye.error||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"));_(""),te(!1),await Re(ye.path||K)}catch(L){console.error("Error creating folder:",L),k(L.message||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{q(!1)}}};return e.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-2xl border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Zr,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:s("projectWizard.title")})]}),e.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:N,children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"px-6 pt-4 pb-2",children:e.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(L=>e.jsxs(it.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${L<a?"bg-green-500 text-white":L===a?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:L<a?e.jsx(Lt,{className:"w-4 h-4"}):L}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:s(L===1?"projectWizard.steps.type":L===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),L<3&&e.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${L<a?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},L))})}),e.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[y&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(xs,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:y})})]}),a===1&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:s("projectWizard.step1.question")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("button",{onClick:()=>i("existing"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="existing"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(Zr,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.existing.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.existing.description")})]})]})}),e.jsx("button",{onClick:()=>i("new"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="new"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(br,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.new.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.new.description")})]})]})})]})]})}),a===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s(o==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),e.jsxs("div",{className:"relative flex gap-2",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ze,{type:"text",value:c,onChange:L=>u(L.target.value),placeholder:o==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),W&&E.length>0&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:E.map((L,K)=>e.jsxs("button",{onClick:()=>je(L),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:L.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:L.path})]},K))})]}),e.jsx(he,{type:"button",variant:"outline",onClick:ge,className:"px-3",title:"Browse folders",children:e.jsx(er,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s(o==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]}),o==="new"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.githubUrl")}),e.jsx(Ze,{type:"text",value:d,onChange:L=>m(L.target.value),placeholder:"https://github.com/username/repository",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.githubHelp")})]}),d&&!d.startsWith("git@")&&!d.startsWith("ssh://")&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(xa,{className:"w-5 h-5 text-gray-600 dark:text-gray-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-medium text-gray-900 dark:text-white mb-1",children:s("projectWizard.step2.githubAuth")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step2.githubAuthHelp")})]})]}),C?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(Sr,{className:"w-4 h-4 animate-spin"}),s("projectWizard.step2.loadingTokens")]}):I.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[e.jsx("button",{onClick:()=>f("stored"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="stored"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.storedToken")}),e.jsx("button",{onClick:()=>f("new"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="new"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.newToken")}),e.jsx("button",{onClick:()=>{f("none"),p(""),b("")},className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="none"?"bg-green-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.nonePublic")})]}),g==="stored"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.selectToken")}),e.jsxs("select",{value:h,onChange:L=>p(L.target.value),className:"w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:s("projectWizard.step2.selectTokenPlaceholder")}),I.map(L=>e.jsx("option",{value:L.id,children:L.credential_name},L.id))]})]}):g==="new"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.newToken")}),e.jsx(Ze,{type:"password",value:x,onChange:L=>b(L.target.value),placeholder:"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.tokenHelp")})]}):null]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 border border-blue-200 dark:border-blue-800",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s("projectWizard.step2.publicRepoInfo")})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.optionalTokenPublic")}),e.jsx(Ze,{type:"password",value:x,onChange:L=>b(L.target.value),placeholder:s("projectWizard.step2.tokenPublicPlaceholder"),className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.noTokensHelp")})]})]})]})]})]}),a===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:s("projectWizard.step3.reviewConfig")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.workspaceType")}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:s(o==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.path")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]}),o==="new"&&d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.cloneFrom")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:d})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.authentication")}),e.jsx("span",{className:"text-xs text-gray-900 dark:text-white",children:g==="stored"&&h?`${s("projectWizard.step3.usingStoredToken")} ${((_e=I.find(L=>L.id.toString()===h))==null?void 0:_e.credential_name)||"Unknown"}`:g==="new"&&x?s("projectWizard.step3.usingProvidedToken"):d.startsWith("git@")||d.startsWith("ssh://")?s("projectWizard.step3.sshKey","SSH Key"):s("projectWizard.step3.noAuthentication")})]})]})]})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:N&&U?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:s("projectWizard.step3.cloningRepository","Cloning repository...")}),e.jsx("code",{className:"block text-xs font-mono text-blue-700 dark:text-blue-300 whitespace-pre-wrap break-all",children:U})]}):e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s(o==="existing"?"projectWizard.step3.existingInfo":d?"projectWizard.step3.newWithClone":"projectWizard.step3.newEmpty")})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(he,{variant:"outline",onClick:a===1?t:se,disabled:N,children:a===1?s("projectWizard.buttons.cancel"):e.jsxs(e.Fragment,{children:[e.jsx(ga,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.back")]})}),e.jsx(he,{onClick:a===3?de:Y,disabled:N||a===1&&!o,children:N?e.jsxs(e.Fragment,{children:[e.jsx(Sr,{className:"w-4 h-4 mr-2 animate-spin"}),d?s("projectWizard.buttons.cloning","Cloning..."):s("projectWizard.buttons.creating")]}):a===3?e.jsxs(e.Fragment,{children:[e.jsx(Lt,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.createProject")]}):e.jsxs(e.Fragment,{children:[s("projectWizard.buttons.next"),e.jsx(rr,{className:"w-4 h-4 ml-1"})]})})]})]}),O&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] border border-gray-200 dark:border-gray-700 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(er,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>$(!ie),className:`p-2 rounded-md transition-colors ${ie?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:ie?"Hide hidden folders":"Show hidden folders",children:ie?e.jsx(sr,{className:"w-5 h-5"}):e.jsx(Zn,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>te(!Z),className:`p-2 rounded-md transition-colors ${Z?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:"Create new folder",children:e.jsx(at,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>H(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Ve,{className:"w-5 h-5"})})]})]}),Z&&e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-blue-50 dark:bg-blue-900/20",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{type:"text",value:Q,onChange:L=>_(L.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:L=>{L.key==="Enter"&&Ue(),L.key==="Escape"&&(te(!1),_(""))},autoFocus:!0}),e.jsx(he,{size:"sm",onClick:Ue,disabled:!Q.trim()||F,children:F?e.jsx(Sr,{className:"w-4 h-4 animate-spin"}):"Create"}),e.jsx(he,{size:"sm",variant:"ghost",onClick:()=>{te(!1),_("")},children:"Cancel"})]})}),ee.length>0&&e.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 mr-1",children:"Drives:"}),ee.map(L=>{const K=typeof L=="string"?L:L.name||L.path,pe=typeof L=="string"?`${L}\\`:L.path||`${L.name}\\`;return e.jsx("button",{onClick:()=>De(pe),className:`px-3 py-1.5 text-sm font-mono font-medium rounded-md border transition-colors ${R.startsWith(K)?"bg-blue-100 dark:bg-blue-900/50 border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300":"bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:K},K)})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:re?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Sr,{className:"w-6 h-6 animate-spin text-gray-400"})}):e.jsxs("div",{className:"space-y-1",children:[R!=="~"&&R!=="/"&&!/^[A-Za-z]:\\?$/.test(R)&&e.jsxs("button",{onClick:()=>{const L=Math.max(R.lastIndexOf("/"),R.lastIndexOf("\\"));let K;L<=0?K="/":L===2&&/^[A-Za-z]:/.test(R)?K=R.substring(0,3):K=R.substring(0,L),De(K)},className:"w-full px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(er,{className:"w-5 h-5 text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),z.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):z.filter(L=>ie||!L.name.startsWith(".")).sort((L,K)=>L.name.toLowerCase().localeCompare(K.name.toLowerCase())).map((L,K)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>De(L.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(Zr,{className:"w-5 h-5 text-blue-500"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:L.name})]}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>Ne(L.path,o==="existing"),className:"text-xs px-3",children:"Select"})]},K))]})}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),e.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:R})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[e.jsx(he,{variant:"outline",onClick:()=>{H(!1),te(!1),_("")},children:"Cancel"}),e.jsx(he,{variant:"outline",onClick:()=>Ne(R,o==="existing"),children:"Use this folder"})]})]})]})})]})};function _c({isOpen:t,onConfirm:r,onCancel:s,title:a,message:n,detail:o,variant:i="danger",confirmLabel:c="Confirm",cancelLabel:u="Cancel"}){const d=l.useRef(null);l.useEffect(()=>{var p;t&&((p=d.current)==null||p.focus())},[t]);const m=l.useCallback(p=>{p.key==="Escape"&&s()},[s]);if(!t)return null;const h=i==="danger";return Cr.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onKeyDown:m,children:e.jsxs("div",{className:"bg-card border border-border/40 rounded-2xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`w-11 h-11 rounded-xl flex items-center justify-center flex-shrink-0 ${h?"bg-red-500/10":"bg-amber-500/10"}`,children:h?e.jsx($t,{className:"w-5 h-5 text-red-500"}):e.jsx(vt,{className:"w-5 h-5 text-amber-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground mb-1.5",children:a}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:n}),o&&e.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-2 leading-relaxed",children:o})]})]})}),e.jsxs("div",{className:"flex gap-2 px-5 py-4 border-t border-border/20",children:[e.jsx("button",{ref:d,onClick:s,className:"flex-1 px-4 py-2.5 text-xs font-medium text-muted-foreground bg-muted/30 hover:bg-muted/50 rounded-xl transition-colors",children:u}),e.jsx("button",{onClick:r,className:`flex-1 px-4 py-2.5 text-xs font-medium rounded-xl transition-opacity ${h?"bg-red-600 hover:bg-red-700 text-white":"bg-foreground hover:opacity-90 text-background"}`,children:c})]})]})}),document.body)}function Sa(){const[t,r]=l.useState(null),s=l.useCallback(i=>new Promise(c=>{r({...i,resolve:c})}),[]),a=l.useCallback(()=>{t==null||t.resolve(!0),r(null)},[t]),n=l.useCallback(()=>{t==null||t.resolve(!1),r(null)},[t]),o=t?{isOpen:!0,onConfirm:a,onCancel:n,title:t.title,message:t.message,detail:t.detail,variant:t.variant,confirmLabel:t.confirmLabel,cancelLabel:t.cancelLabel}:{isOpen:!1,onConfirm:()=>{},onCancel:()=>{},title:"",message:""};return{confirm:s,dialogProps:o,ConfirmDialog:_c}}const Fc="2.9.9";function zc(){const{t}=We("settings"),{confirm:r,dialogProps:s,ConfirmDialog:a}=Sa(),[n,o]=l.useState([]),[i,c]=l.useState([]),[u,d]=l.useState(!0),[m,h]=l.useState(!1),[p,g]=l.useState(!1),[f,x]=l.useState(""),[b,N]=l.useState(""),[j,y]=l.useState(""),[k,I]=l.useState(""),[D,C]=l.useState({}),[v,E]=l.useState(null),[T,W]=l.useState(null),{updateAvailable:S,latestVersion:O,releaseInfo:H}=ho("AnitChaudhry","UpfynAI-Code");l.useEffect(()=>{R()},[]);const R=async()=>{try{d(!0);const te=await(await Me("/api/settings/api-keys")).json();o(te.apiKeys||[]);const _=await(await Me("/api/settings/credentials?type=github_token")).json();c(_.credentials||[])}catch(Z){console.error("Error fetching settings:",Z)}finally{d(!1)}},A=async()=>{if(f.trim())try{const te=await(await Me("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:f})})).json();te.success&&(W(te.apiKey),x(""),h(!1),R())}catch(Z){console.error("Error creating API key:",Z)}},z=async Z=>{if(await r({title:t("apiKeys.deleteTitle","Delete API Key"),message:t("apiKeys.confirmDelete"),confirmLabel:t("apiKeys.deleteButton","Delete"),cancelLabel:t("common:cancel","Cancel")}))try{await Me(`/api/settings/api-keys/${Z}`,{method:"DELETE"}),R()}catch(Q){console.error("Error deleting API key:",Q)}},J=async(Z,te)=>{try{await Me(`/api/settings/api-keys/${Z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!te})}),R()}catch(Q){console.error("Error toggling API key:",Q)}},re=async()=>{if(!(!b.trim()||!j.trim()))try{(await(await Me("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:b,credentialType:"github_token",credentialValue:j,description:k})})).json()).success&&(N(""),y(""),I(""),g(!1),R())}catch(Z){console.error("Error creating GitHub credential:",Z)}},G=async Z=>{if(await r({title:t("apiKeys.github.deleteTitle","Delete GitHub Credential"),message:t("apiKeys.github.confirmDelete"),confirmLabel:t("apiKeys.deleteButton","Delete"),cancelLabel:t("common:cancel","Cancel")}))try{await Me(`/api/settings/credentials/${Z}`,{method:"DELETE"}),R()}catch(Q){console.error("Error deleting GitHub credential:",Q)}},ie=async(Z,te)=>{try{await Me(`/api/settings/credentials/${Z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!te})}),R()}catch(Q){console.error("Error toggling GitHub credential:",Q)}},$=(Z,te)=>{navigator.clipboard.writeText(Z),E(te),setTimeout(()=>E(null),2e3)};return u?e.jsx("div",{className:"text-muted-foreground",children:t("apiKeys.loading")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-8",children:[T&&e.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[e.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:t("apiKeys.newKey.alertTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:t("apiKeys.newKey.alertMessage")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:T.apiKey}),e.jsx(he,{size:"sm",variant:"outline",onClick:()=>$(T.apiKey,"new"),children:v==="new"?e.jsx(Lt,{className:"h-4 w-4"}):e.jsx(ha,{className:"h-4 w-4"})})]}),e.jsx(he,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>W(null),children:t("apiKeys.newKey.iveSavedIt")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xa,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.title")})]}),e.jsxs(he,{size:"sm",onClick:()=>h(!m),children:[e.jsx(at,{className:"h-4 w-4 mr-1"}),t("apiKeys.newButton")]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:t("apiKeys.description")}),e.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[t("apiKeys.apiDocsLink"),e.jsx(Fa,{className:"h-3 w-3"})]})]}),m&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[e.jsx(Ze,{placeholder:t("apiKeys.form.placeholder"),value:f,onChange:Z=>x(Z.target.value),className:"mb-2"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(he,{onClick:A,children:t("apiKeys.form.createButton")}),e.jsx(he,{variant:"outline",onClick:()=>h(!1),children:t("apiKeys.form.cancelButton")})]})]}),e.jsx("div",{className:"space-y-2",children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.empty")}):n.map(Z=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:Z.key_name}),e.jsx("code",{className:"text-xs text-muted-foreground",children:Z.api_key}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.list.created")," ",new Date(Z.created_at).toLocaleDateString(),Z.last_used&&` • ${t("apiKeys.list.lastUsed")} ${new Date(Z.last_used).toLocaleDateString()}`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{size:"sm",variant:Z.is_active?"outline":"secondary",onClick:()=>J(Z.id,Z.is_active),children:Z.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(he,{size:"sm",variant:"ghost",onClick:()=>z(Z.id),children:e.jsx(yt,{className:"h-4 w-4"})})]})]},Z.id))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yi,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.github.title")})]}),e.jsxs(he,{size:"sm",onClick:()=>g(!p),children:[e.jsx(at,{className:"h-4 w-4 mr-1"}),t("apiKeys.github.addButton")]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("apiKeys.github.descriptionAlt")}),p&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[e.jsx(Ze,{placeholder:t("apiKeys.github.form.namePlaceholder"),value:b,onChange:Z=>N(Z.target.value)}),e.jsxs("div",{className:"relative",children:[e.jsx(Ze,{type:D.new?"text":"password",placeholder:t("apiKeys.github.form.tokenPlaceholder"),value:j,onChange:Z=>y(Z.target.value),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>C({...D,new:!D.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:D.new?e.jsx(Zn,{className:"h-4 w-4"}):e.jsx(sr,{className:"h-4 w-4"})})]}),e.jsx(Ze,{placeholder:t("apiKeys.github.form.descriptionPlaceholder"),value:k,onChange:Z=>I(Z.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(he,{onClick:re,children:t("apiKeys.github.form.addButton")}),e.jsx(he,{variant:"outline",onClick:()=>{g(!1),N(""),y(""),I("")},children:t("apiKeys.github.form.cancelButton")})]}),e.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:t("apiKeys.github.form.howToCreate")})]}),e.jsx("div",{className:"space-y-2",children:i.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.github.empty")}):i.map(Z=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:Z.credential_name}),Z.description&&e.jsx("div",{className:"text-xs text-muted-foreground",children:Z.description}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.github.added")," ",new Date(Z.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{size:"sm",variant:Z.is_active?"outline":"secondary",onClick:()=>ie(Z.id,Z.is_active),children:Z.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(he,{size:"sm",variant:"ghost",onClick:()=>G(Z.id),children:e.jsx(yt,{className:"h-4 w-4"})})]})]},Z.id))})]}),e.jsx("div",{className:"pt-6 border-t border-border/50",children:e.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[e.jsxs("a",{href:(H==null?void 0:H.htmlUrl)||"https://github.com/AnitChaudhry/UpfynAI-Code/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Fc]}),S&&O&&e.jsxs("a",{href:(H==null?void 0:H.htmlUrl)||"https://github.com/AnitChaudhry/UpfynAI-Code/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[e.jsx("span",{className:"text-[10px]",children:t("apiKeys.version.updateAvailable",{version:O})}),e.jsx(Fa,{className:"h-2.5 w-2.5"})]})]})})]}),e.jsx(a,{...s})]})}function Rc(){const{t}=We("settings"),[r,s]=l.useState(""),[a,n]=l.useState(""),[o,i]=l.useState(!1),[c,u]=l.useState(!1),[d,m]=l.useState(null);l.useEffect(()=>{h()},[]);const h=async()=>{try{i(!0);const g=await Me("/api/user/git-config");if(g.ok){const f=await g.json();s(f.gitName||""),n(f.gitEmail||"")}}catch(g){console.error("Error loading git config:",g)}finally{i(!1)}},p=async()=>{try{u(!0);const g=await Me("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:a})});if(g.ok)m("success"),setTimeout(()=>m(null),3e3);else{const f=await g.json();m("error"),console.error("Failed to save git config:",f.error)}}catch(g){console.error("Error saving git config:",g),m("error")}finally{u(!1)}};return e.jsx("div",{className:"space-y-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(br,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("git.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("git.description")}),e.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:t("git.name.label")}),e.jsx(Ze,{id:"settings-git-name",type:"text",value:r,onChange:g=>s(g.target.value),placeholder:"John Doe",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.name.help")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:t("git.email.label")}),e.jsx(Ze,{id:"settings-git-email",type:"email",value:a,onChange:g=>n(g.target.value),placeholder:"john@example.com",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.email.help")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{onClick:p,disabled:c||!r||!a,children:t(c?"git.actions.saving":"git.actions.save")}),d==="success"&&e.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[e.jsx(Lt,{className:"w-4 h-4"}),t("git.status.success")]})]})]})]})})}function Oc(){const{t}=We("settings"),{tasksEnabled:r,setTasksEnabled:s,isTaskMasterInstalled:a,isCheckingInstallation:n}=Lr();return e.jsx("div",{className:"space-y-8",children:n?e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("tasks.checking")})]})}):e.jsxs(e.Fragment,{children:[!a&&e.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-orange-100 dark:bg-orange-900 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:t("tasks.notInstalled.title")}),e.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[e.jsx("p",{children:t("tasks.notInstalled.description")}),e.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:e.jsx("code",{children:t("tasks.notInstalled.installCommand")})}),e.jsx("div",{children:e.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),t("tasks.notInstalled.viewOnGitHub"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:t("tasks.notInstalled.afterInstallation")}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[e.jsx("li",{children:t("tasks.notInstalled.steps.restart")}),e.jsx("li",{children:t("tasks.notInstalled.steps.autoAvailable")}),e.jsx("li",{children:t("tasks.notInstalled.steps.initCommand")})]})]})]})]})]})}),a&&e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:t("tasks.settings.enableLabel")}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:t("tasks.settings.enableDescription")})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:o=>s(o.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]})})})]})})}const Bc={claude:{name:"Claude",color:"blue"},cursor:{name:"Cursor",color:"purple"},codex:{name:"Codex",color:"gray"}},Wc={blue:{border:"border-l-blue-500 md:border-l-blue-500",borderBottom:"border-b-blue-500",bg:"bg-blue-50 dark:bg-blue-900/20",dot:"bg-blue-500"},purple:{border:"border-l-purple-500 md:border-l-purple-500",borderBottom:"border-b-purple-500",bg:"bg-purple-50 dark:bg-purple-900/20",dot:"bg-purple-500"},gray:{border:"border-l-gray-700 dark:border-l-gray-300",borderBottom:"border-b-gray-700 dark:border-b-gray-300",bg:"bg-gray-100 dark:bg-gray-800/50",dot:"bg-gray-700 dark:bg-gray-300"}};function dr({agentId:t,authStatus:r,isSelected:s,onClick:a,isMobile:n=!1}){const{t:o}=We("settings"),i=Bc[t],c=Wc[i.color];return n?e.jsx("button",{onClick:a,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${s?`${c.borderBottom} ${c.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx(ft,{provider:t,className:"w-5 h-5"}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:i.name}),(r==null?void 0:r.authenticated)&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`})]})}):e.jsxs("button",{onClick:a,className:`w-full text-left p-3 border-l-4 transition-colors ${s?`${c.border} ${c.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ft,{provider:t,className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:i.name})]}),e.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:r!=null&&r.loading?e.jsx("span",{className:"text-gray-400",children:o("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`}),e.jsx("span",{className:"truncate max-w-[120px]",title:r.email,children:r.email||o("agents.authStatus.connected")})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),e.jsx("span",{children:o("agents.authStatus.notConnected")})]})})]})}const Uc={claude:{name:"Claude",description:"Anthropic Claude AI assistant",bgClass:"bg-blue-50 dark:bg-blue-900/20",borderClass:"border-blue-200 dark:border-blue-800",textClass:"text-blue-900 dark:text-blue-100",subtextClass:"text-blue-700 dark:text-blue-300",buttonClass:"bg-blue-600 hover:bg-blue-700"},cursor:{name:"Cursor",description:"Cursor AI-powered code editor",bgClass:"bg-purple-50 dark:bg-purple-900/20",borderClass:"border-purple-200 dark:border-purple-800",textClass:"text-purple-900 dark:text-purple-100",subtextClass:"text-purple-700 dark:text-purple-300",buttonClass:"bg-purple-600 hover:bg-purple-700"},codex:{name:"Codex",description:"OpenAI Codex AI assistant",bgClass:"bg-gray-100 dark:bg-gray-800/50",borderClass:"border-gray-300 dark:border-gray-600",textClass:"text-gray-900 dark:text-gray-100",subtextClass:"text-gray-700 dark:text-gray-300",buttonClass:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"}};function Hc({agent:t,authStatus:r,onLogin:s}){const{t:a}=We("settings"),n=Uc[t];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(ft,{provider:t,className:"w-6 h-6"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a(`agents.account.${t}.description`)})]})]}),e.jsx("div",{className:`${n.bgClass} border ${n.borderClass} rounded-lg p-4`,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:a("agents.connectionStatus")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&r.loading?a("agents.authStatus.checkingAuth"):r!=null&&r.authenticated?a("agents.authStatus.loggedInAs",{email:r.email||a("agents.authStatus.authenticatedUser")}):a("agents.authStatus.notConnected")})]}),e.jsx("div",{children:r!=null&&r.loading?e.jsx(bt,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:a("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsx(bt,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:a("agents.authStatus.connected")}):e.jsx(bt,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:a("agents.authStatus.disconnected")})})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:r!=null&&r.authenticated?a("agents.login.reAuthenticate"):a("agents.login.title")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&r.authenticated?a("agents.login.reAuthDescription"):a("agents.login.description",{agent:n.name})})]}),e.jsxs(he,{onClick:s,className:`${n.buttonClass} text-white`,size:"sm",children:[e.jsx(vi,{className:"w-4 h-4 mr-2"}),r!=null&&r.authenticated?a("agents.login.reLoginButton"):a("agents.login.button")]})]})}),(r==null?void 0:r.error)&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:a("agents.error",{error:r.error})})})]})})]})}const Gc=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],Vc=["Shell(ls)","Shell(mkdir)","Shell(cd)","Shell(cat)","Shell(echo)","Shell(git status)","Shell(git diff)","Shell(git log)","Shell(npm install)","Shell(npm run)","Shell(python)","Shell(node)"];function qc({skipPermissions:t,setSkipPermissions:r,allowedTools:s,setAllowedTools:a,disallowedTools:n,setDisallowedTools:o,newAllowedTool:i,setNewAllowedTool:c,newDisallowedTool:u,setNewDisallowedTool:d}){const{t:m}=We("settings"),h=x=>{x&&!s.includes(x)&&(a([...s,x]),c(""))},p=x=>{a(s.filter(b=>b!==x))},g=x=>{x&&!n.includes(x)&&(o([...n,x]),d(""))},f=x=>{o(n.filter(b=>b!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:m("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:m("permissions.skipPermissions.claudeDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.allowedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.allowedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:i,onChange:x=>c(x.target.value),placeholder:m("permissions.allowedTools.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),h(i))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>h(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:m("permissions.allowedTools.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Gc.map(x=>e.jsx(he,{variant:"outline",size:"sm",onClick:()=>h(x),disabled:s.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>p(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.allowedTools.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.blockedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.blockedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:u,onChange:x=>d(x.target.value),placeholder:m("permissions.blockedTools.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(u))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>g(u),disabled:!u,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>f(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.blockedTools.empty")})]})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:m("permissions.toolExamples.title")}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," ",m("permissions.toolExamples.bashGitLog")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," ",m("permissions.toolExamples.bashGitDiff")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," ",m("permissions.toolExamples.write")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," ",m("permissions.toolExamples.bashRm")]})]})]})]})}function Kc({skipPermissions:t,setSkipPermissions:r,allowedCommands:s,setAllowedCommands:a,disallowedCommands:n,setDisallowedCommands:o,newAllowedCommand:i,setNewAllowedCommand:c,newDisallowedCommand:u,setNewDisallowedCommand:d}){const{t:m}=We("settings"),h=x=>{x&&!s.includes(x)&&(a([...s,x]),c(""))},p=x=>{a(s.filter(b=>b!==x))},g=x=>{x&&!n.includes(x)&&(o([...n,x]),d(""))},f=x=>{o(n.filter(b=>b!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 text-purple-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-purple-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:m("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:m("permissions.skipPermissions.cursorDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.allowedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.allowedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:i,onChange:x=>c(x.target.value),placeholder:m("permissions.allowedCommands.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),h(i))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>h(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:m("permissions.allowedCommands.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Vc.map(x=>e.jsx(he,{variant:"outline",size:"sm",onClick:()=>h(x),disabled:s.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>p(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.allowedCommands.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.blockedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.blockedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:u,onChange:x=>d(x.target.value),placeholder:m("permissions.blockedCommands.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(u))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>g(u),disabled:!u,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>f(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.blockedCommands.empty")})]})]}),e.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:m("permissions.shellExamples.title")}),e.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," ",m("permissions.shellExamples.ls")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," ",m("permissions.shellExamples.gitStatus")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," ",m("permissions.shellExamples.npmInstall")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," ",m("permissions.shellExamples.rmRf")]})]})]})]})}function Jc({permissionMode:t,setPermissionMode:r}){const{t:s}=We("settings");return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:s("permissions.codex.permissionMode")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("permissions.codex.description")}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="default"?"bg-gray-100 dark:bg-gray-800 border-gray-400 dark:border-gray-500":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("default"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="default",onChange:()=>r("default"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:s("permissions.codex.modes.default.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("permissions.codex.modes.default.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 border-green-400 dark:border-green-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("acceptEdits"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="acceptEdits",onChange:()=>r("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:s("permissions.codex.modes.acceptEdits.title")}),e.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:s("permissions.codex.modes.acceptEdits.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 border-orange-400 dark:border-orange-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("bypassPermissions"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="bypassPermissions",onChange:()=>r("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:[s("permissions.codex.modes.bypassPermissions.title"),e.jsx($t,{className:"w-4 h-4"})]}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:s("permissions.codex.modes.bypassPermissions.description")})]})]})}),e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:s("permissions.codex.technicalDetails")}),e.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg text-xs text-muted-foreground space-y-2",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.default.title"),":"]})," ",s("permissions.codex.technicalInfo.default")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.acceptEdits.title"),":"]})," ",s("permissions.codex.technicalInfo.acceptEdits")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.bypassPermissions.title"),":"]})," ",s("permissions.codex.technicalInfo.bypassPermissions")]}),e.jsx("p",{className:"text-xs opacity-75",children:s("permissions.codex.technicalInfo.overrideNote")})]})]})]})})}function $s({agent:t,...r}){return t==="claude"?e.jsx(qc,{...r}):t==="cursor"?e.jsx(Kc,{...r}):t==="codex"?e.jsx(Jc,{...r}):null}const Yc=t=>{switch(t){case"stdio":return e.jsx(vt,{className:"w-4 h-4"});case"sse":return e.jsx(tr,{className:"w-4 h-4"});case"http":return e.jsx(qs,{className:"w-4 h-4"});default:return e.jsx($r,{className:"w-4 h-4"})}};function Qc({servers:t,onAdd:r,onEdit:s,onDelete:a,onTest:n,onDiscoverTools:o,testResults:i,serverTools:c,toolsLoading:u}){const{t:d}=We("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($r,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d("mcpServers.description.claude")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(he,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),d("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(m=>{var h,p,g,f;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[Yc(m.type),e.jsx("span",{className:"font-medium text-foreground",children:m.name}),e.jsx(bt,{variant:"outline",className:"text-xs",children:m.type}),e.jsx(bt,{variant:"outline",className:"text-xs",children:m.scope==="local"?d("mcpServers.scope.local"):m.scope==="user"?d("mcpServers.scope.user"):m.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[m.type==="stdio"&&((h=m.config)==null?void 0:h.command)&&e.jsxs("div",{children:[d("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.command})]}),(m.type==="sse"||m.type==="http")&&((p=m.config)==null?void 0:p.url)&&e.jsxs("div",{children:[d("mcpServers.config.url"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.url})]}),((g=m.config)==null?void 0:g.args)&&m.config.args.length>0&&e.jsxs("div",{children:[d("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.args.join(" ")})]})]}),(i==null?void 0:i[m.id])&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${i[m.id].success?"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200":"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200"}`,children:e.jsx("div",{className:"font-medium",children:i[m.id].message})}),(c==null?void 0:c[m.id])&&((f=c[m.id].tools)==null?void 0:f.length)>0&&e.jsxs("div",{className:"mt-2 p-2 rounded text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200",children:[e.jsxs("div",{className:"font-medium",children:[d("mcpServers.tools.title")," ",d("mcpServers.tools.count",{count:c[m.id].tools.length})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[c[m.id].tools.slice(0,5).map((x,b)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:x.name},b)),c[m.id].tools.length>5&&e.jsx("span",{className:"text-xs opacity-75",children:d("mcpServers.tools.more",{count:c[m.id].tools.length-5})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(he,{onClick:()=>s(m),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:d("mcpServers.actions.edit"),children:e.jsx(Mr,{className:"w-4 h-4"})}),e.jsx(he,{onClick:()=>a(m.id,m.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:d("mcpServers.actions.delete"),children:e.jsx(yt,{className:"w-4 h-4"})})]})]})},m.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:d("mcpServers.empty")})]})]})}function Xc({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=We("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($r,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.cursor")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(he,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(vt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(bt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:((i=o.config)==null?void 0:i.command)&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(he,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(Mr,{className:"w-4 h-4"})}),e.jsx(he,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(yt,{className:"w-4 h-4"})})]})]})},o.name||o.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]})]})}function Zc({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=We("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($r,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.codex")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(he,{onClick:r,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i,c,u;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(vt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(bt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[((i=o.config)==null?void 0:i.command)&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]}),((c=o.config)==null?void 0:c.args)&&o.config.args.length>0&&e.jsxs("div",{children:[n("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.args.join(" ")})]}),((u=o.config)==null?void 0:u.env)&&Object.keys(o.config.env).length>0&&e.jsxs("div",{children:[n("mcpServers.config.environment"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(o.config.env).map(([d,m])=>`${d}=${m}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(he,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(Mr,{className:"w-4 h-4"})}),e.jsx(he,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(yt,{className:"w-4 h-4"})})]})]})},o.name)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]}),e.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:n("mcpServers.help.title")}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:n("mcpServers.help.description")})]})]})}function _s({agent:t,...r}){return t==="claude"?e.jsx(Qc,{...r}):t==="cursor"?e.jsx(Xc,{...r}):t==="codex"?e.jsx(Zc,{...r}):null}const ed=[{name:"filesystem",description:"Read/write local files and directories",category:"Files & Code",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-filesystem","/path"]}},{name:"github",description:"GitHub repos, issues, and PRs",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-github"]}},{name:"postgres",description:"Query PostgreSQL databases",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-postgres"]}},{name:"brave-search",description:"Web search via Brave Search API",category:"AI & Search",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-brave-search"]}},{name:"memory",description:"Persistent memory store for AI agents",category:"AI & Search",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-memory"]}},{name:"puppeteer",description:"Browser automation and scraping",category:"DevOps",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-puppeteer"]}},{name:"sqlite",description:"Query SQLite databases",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-sqlite"]}},{name:"fetch",description:"HTTP fetch and web content retrieval",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-fetch"]}}],td={"Files & Code":"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300","Data & APIs":"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300","AI & Search":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300",DevOps:"bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-300"};function rd(){const[t,r]=l.useState([]),[s,a]=l.useState(!0),[n,o]=l.useState(null),[i,c]=l.useState(""),u=l.useCallback(async()=>{a(!0);try{const g=await(await Me("/api/mcp/config/read")).json();g.success&&g.servers&&r(g.servers)}catch{}a(!1)},[]);l.useEffect(()=>{u();const p=window.location.origin;c(`${p}/mcp`)},[u]);const d=async p=>{o(p.name);try{(await Me("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:p.name,config:{command:p.installConfig.command,args:p.installConfig.args}})})).ok&&await u()}catch{}o(null)},m=p=>t.some(g=>g.name===p),h=p=>{navigator.clipboard.writeText(p)};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Installed Servers"}),e.jsx("button",{onClick:()=>void u(),className:"ml-auto text-sm text-muted-foreground hover:text-foreground transition-colors",title:"Refresh",children:e.jsx("svg",{className:`w-4 h-4 ${s?"animate-spin":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-6",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading servers..."]}):t.length===0?e.jsx("div",{className:"text-sm text-muted-foreground bg-muted/30 rounded-lg px-4 py-4 border border-border/30",children:"No MCP servers installed. Browse the directory below to get started."}):e.jsx("div",{className:"grid gap-2",children:t.map(p=>{var g,f;return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-card border border-border/50 rounded-lg",children:[e.jsx("svg",{className:"w-4 h-4 text-primary flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:p.name}),p.type==="stdio"&&((g=p.config)==null?void 0:g.command)&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:[p.config.command," ",p.config.args?p.config.args.join(" "):""]}),(p.type==="http"||p.type==="sse")&&((f=p.config)==null?void 0:f.url)&&e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:p.config.url})]}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${p.type==="stdio"?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":p.type==="sse"?"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300"}`,children:p.type}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${p.scope==="user"?"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400":"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300"}`,children:p.scope})]},p.id)})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-amber-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Server Directory"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Popular MCP servers"})]}),e.jsx("div",{className:"grid gap-2",children:ed.map(p=>{const g=m(p.name);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/20 border border-border/30 rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:p.name}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${td[p.category]||"bg-gray-100 text-gray-600"}`,children:p.category})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:p.description})]}),g?e.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 font-medium flex items-center gap-1 flex-shrink-0",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Installed"]}):e.jsx("button",{onClick:()=>void d(p),disabled:n===p.name,className:"text-xs px-3 py-1.5 rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 font-medium transition-colors flex-shrink-0 min-h-[36px]",children:n===p.name?"Installing...":"Install"})]},p.name)})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-blue-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Your Upfyn MCP Server"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Connect external AI clients (Claude Desktop, Cursor, etc.) to your Upfyn instance using MCP."}),e.jsxs("div",{className:"bg-muted/30 border border-border/30 rounded-lg p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"MCP Endpoint"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{className:"flex-1 text-sm bg-card border border-border rounded px-3 py-1.5 font-mono text-foreground truncate",children:i}),e.jsx("button",{onClick:()=>h(i),className:"px-2.5 py-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",title:"Copy",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Claude Desktop Config"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{className:"flex-1 text-xs bg-card border border-border rounded px-3 py-1.5 font-mono text-foreground overflow-x-auto",children:`{ "mcpServers": { "upfyn": { "url": "${i}" } } }`}),e.jsx("button",{onClick:()=>h(`{ "mcpServers": { "upfyn": { "url": "${i}" } } }`),className:"px-2.5 py-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground transition-colors flex-shrink-0 min-w-[44px] min-h-[44px] flex items-center justify-center",title:"Copy config",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})]})]})]})}function _o({compact:t=!1}){const{i18n:r,t:s}=We("settings"),a=n=>{const o=n.target.value;r.changeLanguage(o)};return t?e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(eo,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),s("account.language")]}),e.jsx("select",{value:r.language,onChange:a,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400",children:Pa.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]}):e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:s("account.languageLabel")}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("account.languageDescription")})]}),e.jsx("select",{value:r.language,onChange:a,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-36",children:Pa.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]})})}function sd(){const[t,r]=l.useState([]),[s,a]=l.useState(!0),[n,o]=l.useState(null),[i,c]=l.useState(!1),u=async()=>{try{const f=await Me("/api/sessions");if(f.ok){const x=await f.json();r(x.sessions||[])}}catch{}a(!1)};l.useEffect(()=>{u();const f=setInterval(u,1e4);return()=>clearInterval(f)},[]);const d=async(f,x)=>{o(f);try{await Me(`/api/sessions/${f}/abort`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:x})}),await u()}catch{}o(null)},m=async()=>{c(!0);try{await Me("/api/sessions/abort-all",{method:"POST"}),await u()}catch{}c(!1)},h=f=>{if(!f)return"";const x=Date.now()-new Date(f).getTime(),b=Math.floor(x/1e3);if(b<60)return`${b}s`;const N=Math.floor(b/60);return N<60?`${N}m`:`${Math.floor(N/60)}h ${N%60}m`},p=f=>({claude:"Claude",cursor:"Cursor",codex:"Codex"})[f]||f,g=f=>({claude:"text-orange-500",cursor:"text-blue-500",codex:"text-green-500"})[f]||"text-gray-500";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Ks,{className:"w-5 h-5"})," Active Sessions"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:u,className:"text-sm text-muted-foreground hover:text-foreground flex items-center gap-1",children:[e.jsx(Vs,{className:"w-3.5 h-3.5"})," Refresh"]}),t.length>0&&e.jsxs("button",{onClick:m,disabled:i,className:"text-sm text-red-500 hover:text-red-400 flex items-center gap-1 disabled:opacity-50",children:[e.jsx(za,{className:"w-3.5 h-3.5"})," ",i?"Aborting...":"Abort All"]})]})]}),s?e.jsx("div",{className:"text-center text-muted-foreground text-sm py-8",children:"Loading sessions..."}):t.length===0?e.jsxs("div",{className:"bg-muted/30 border border-border rounded-lg p-8 text-center",children:[e.jsx(Ks,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"No active sessions"}),e.jsx("p",{className:"text-muted-foreground/60 text-xs mt-1",children:"Sessions appear here when you run Claude, Cursor, or Codex commands"})]}):e.jsx("div",{className:"border border-border rounded-lg overflow-hidden divide-y divide-border",children:t.map(f=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-mono text-foreground truncate",children:f.sessionId}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:`text-xs font-medium ${g(f.provider)}`,children:p(f.provider)}),e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium ${f.status==="active"?"bg-green-500/10 text-green-500 dark:text-green-400":"bg-gray-500/10 text-gray-500"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${f.status==="active"?"bg-green-500":"bg-gray-400"}`}),f.status]}),f.startedAt&&e.jsx("span",{className:"text-xs text-muted-foreground",children:h(f.startedAt)})]})]}),e.jsx("button",{onClick:()=>d(f.sessionId,f.provider),disabled:n===f.sessionId,className:"p-1.5 rounded hover:bg-red-500/10 text-red-500 hover:text-red-400 transition-colors disabled:opacity-50",title:"Abort session",children:e.jsx(za,{className:"w-4 h-4"})})]},f.sessionId))})]})}function ad({isOpen:t,onClose:r,projects:s=[],initialTab:a="agents"}){var Wr,et,It,Ms;const{isDarkMode:n,toggleDarkMode:o}=pa(),{t:i}=We("settings"),{addToast:c}=hr(),{confirm:u,dialogProps:d,ConfirmDialog:m}=Sa(),[h,p]=l.useState([]),[g,f]=l.useState([]),[x,b]=l.useState(""),[N,j]=l.useState(""),[y,k]=l.useState(!1),[I,D]=l.useState(!1),[C,v]=l.useState(null),[E,T]=l.useState("name"),[W,S]=l.useState([]),[O,H]=l.useState(!1),[R,A]=l.useState(null),[z,J]=l.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[re,G]=l.useState(!1),[ie,$]=l.useState({}),[Z,te]=l.useState({}),[Q,_]=l.useState({}),[F,q]=l.useState(a),[U,B]=l.useState(""),[ee,V]=l.useState("claude"),[w,M]=l.useState("account"),[Y,se]=l.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[de,je]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[ge,Re]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[Ne,De]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Ue,_e]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[L,K]=l.useState([]),[pe,ye]=l.useState([]),[Ie,Fe]=l.useState(!1),[Se,Oe]=l.useState(""),[ne,fe]=l.useState(""),[Ee,Le]=l.useState([]),[Pe,Ae]=l.useState([]),[Ge,ae]=l.useState("default"),[be,ze]=l.useState(!1),[Ce,Ye]=l.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[lt,dt]=l.useState(null),[Tt,At]=l.useState(!1),[wt,Ft]=l.useState(!1),[le,ue]=l.useState(""),[ce,we]=l.useState(null),[He,Qe]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Xe,ut]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Vt,ht]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),jt=async()=>{try{const P=await Me("/api/cursor/mcp");if(P.ok){const X=await P.json();Le(X.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(P){console.error("Error fetching Cursor MCP servers:",P)}},st=async()=>{try{const P=await Me("/api/codex/mcp/config/read");if(P.ok){const oe=await P.json();if(oe.success&&oe.servers){Ae(oe.servers);return}}const X=await Me("/api/codex/mcp/cli/list");if(X.ok){const oe=await X.json();if(oe.success&&oe.servers){const ve=oe.servers.map(Ke=>({id:Ke.name,name:Ke.name,type:Ke.type||"stdio",scope:"user",config:{command:Ke.command||"",args:Ke.args||[],env:Ke.env||{}}}));Ae(ve)}}}catch(P){console.error("Error fetching Codex MCP servers:",P)}},tt=async()=>{try{const P=await Me("/api/mcp/config/read");if(P.ok){const ve=await P.json();if(ve.success&&ve.servers){S(ve.servers);return}}const X=await Me("/api/mcp/cli/list");if(X.ok){const ve=await X.json();if(ve.success&&ve.servers){const Ke=ve.servers.map(nt=>({id:nt.name,name:nt.name,type:nt.type,scope:"user",config:{command:nt.command||"",args:nt.args||[],env:nt.env||{},url:nt.url||"",headers:nt.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));S(Ke);return}}const oe=await Me("/api/mcp/servers?scope=user");if(oe.ok){const ve=await oe.json();S(ve.servers||[])}else console.error("Failed to fetch MCP servers")}catch(P){console.error("Error fetching MCP servers:",P)}},zt=async P=>{var X,oe,ve,Ke,nt;try{R&&await or(R.id,"user");const cr=await Me("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:P.name,type:P.type,scope:P.scope,projectPath:P.projectPath,command:(X=P.config)==null?void 0:X.command,args:((oe=P.config)==null?void 0:oe.args)||[],url:(ve=P.config)==null?void 0:ve.url,headers:((Ke=P.config)==null?void 0:Ke.headers)||{},env:((nt=P.config)==null?void 0:nt.env)||{}})});if(cr.ok){const Ur=await cr.json();if(Ur.success)return await tt(),!0;throw new Error(Ur.error||"Failed to save server via Claude CLI")}else{const Ur=await cr.json();throw new Error(Ur.error||"Failed to save server")}}catch(cr){throw console.error("Error saving MCP server:",cr),cr}},or=async(P,X="user")=>{try{const oe=await Me(`/api/mcp/cli/remove/${P}?scope=${X}`,{method:"DELETE"});if(oe.ok){const ve=await oe.json();if(ve.success)return await tt(),!0;throw new Error(ve.error||"Failed to delete server via Claude CLI")}else{const ve=await oe.json();throw new Error(ve.error||"Failed to delete server")}}catch(oe){throw console.error("Error deleting MCP server:",oe),oe}},bs=async(P,X="user")=>{try{const oe=await Me(`/api/mcp/servers/${P}/test?scope=${X}`,{method:"POST"});if(oe.ok)return(await oe.json()).testResult;{const ve=await oe.json();throw new Error(ve.error||"Failed to test server")}}catch(oe){throw console.error("Error testing MCP server:",oe),oe}},ys=async(P,X="user")=>{try{const oe=await Me(`/api/mcp/servers/${P}/tools?scope=${X}`,{method:"POST"});if(oe.ok)return(await oe.json()).toolsResult;{const ve=await oe.json();throw new Error(ve.error||"Failed to discover tools")}}catch(oe){throw console.error("Error discovering MCP tools:",oe),oe}},vs=async P=>{var X,oe,ve;try{lt&&await vr(lt.id);const Ke=await Me("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:P.name,command:(X=P.config)==null?void 0:X.command,args:((oe=P.config)==null?void 0:oe.args)||[],env:((ve=P.config)==null?void 0:ve.env)||{}})});if(Ke.ok){const nt=await Ke.json();if(nt.success)return await st(),!0;throw new Error(nt.error||"Failed to save Codex MCP server")}else{const nt=await Ke.json();throw new Error(nt.error||"Failed to save server")}}catch(Ke){throw console.error("Error saving Codex MCP server:",Ke),Ke}},vr=async P=>{try{const X=await Me(`/api/codex/mcp/cli/remove/${P}`,{method:"DELETE"});if(X.ok){const oe=await X.json();if(oe.success)return await st(),!0;throw new Error(oe.error||"Failed to delete Codex MCP server")}else{const oe=await X.json();throw new Error(oe.error||"Failed to delete server")}}catch(X){throw console.error("Error deleting Codex MCP server:",X),X}},ir=()=>{Ye({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),dt(null),ze(!1)},_r=(P=null)=>{var X,oe,ve;P?(dt(P),Ye({name:P.name,type:P.type||"stdio",config:{command:((X=P.config)==null?void 0:X.command)||"",args:((oe=P.config)==null?void 0:oe.args)||[],env:((ve=P.config)==null?void 0:ve.env)||{}}})):ir(),ze(!0)},ks=async P=>{P.preventDefault(),At(!0);try{lt&&await vr(lt.name),await vs(Ce),ir(),v("success")}catch(X){c(`Error: ${X.message}`,"error"),v("error")}finally{At(!1)}},ws=async P=>{if(await u({title:i("mcp.deleteTitle","Delete MCP Server"),message:i("mcp.confirmDelete","Are you sure you want to delete this MCP server?"),confirmLabel:i("mcp.deleteButton","Delete"),cancelLabel:i("common:cancel","Cancel")}))try{await vr(P),v("success")}catch(oe){c(`Error: ${oe.message}`,"error"),v("error")}};l.useEffect(()=>{t&&(js(),Fr(),zr(),Rr(),q(a))},[t,a]),l.useEffect(()=>{localStorage.setItem("codeEditorTheme",Y),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Y]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",de.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[de]),l.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",ge.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ge]),l.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",Ne.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ne]),l.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Ue),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ue]);const js=async()=>{try{const P=localStorage.getItem("claude-settings");if(P){const ve=JSON.parse(P);p(ve.allowedTools||[]),f(ve.disallowedTools||[]),k(ve.skipPermissions||!1),T(ve.projectSortOrder||"name")}else p([]),f([]),k(!1),T("name");const X=localStorage.getItem("cursor-tools-settings");if(X){const ve=JSON.parse(X);K(ve.allowedCommands||[]),ye(ve.disallowedCommands||[]),Fe(ve.skipPermissions||!1)}else K([]),ye([]),Fe(!1);const oe=localStorage.getItem("codex-settings");if(oe){const ve=JSON.parse(oe);ae(ve.permissionMode||"default")}else ae("default");await tt(),await jt(),await st()}catch(P){console.error("Error loading tool settings:",P),p([]),f([]),k(!1),T("name")}},Fr=async()=>{try{const P=await Me("/api/cli/claude/status");if(P.ok){const X=await P.json();Qe({authenticated:X.authenticated,email:X.email,loading:!1,error:X.error||null})}else Qe({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Claude auth status:",P),Qe({authenticated:!1,email:null,loading:!1,error:P.message})}},zr=async()=>{try{const P=await Me("/api/cli/cursor/status");if(P.ok){const X=await P.json();ut({authenticated:X.authenticated,email:X.email,loading:!1,error:X.error||null})}else ut({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Cursor auth status:",P),ut({authenticated:!1,email:null,loading:!1,error:P.message})}},Rr=async()=>{try{const P=await Me("/api/cli/codex/status");if(P.ok){const X=await P.json();ht({authenticated:X.authenticated,email:X.email,loading:!1,error:X.error||null})}else ht({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Codex auth status:",P),ht({authenticated:!1,email:null,loading:!1,error:P.message})}},Ns=()=>{ue("claude"),we((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},lr=()=>{ue("cursor"),we((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},Cs=()=>{ue("codex"),we((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},Ss=P=>{P===0&&(v("success"),le==="claude"?Fr():le==="cursor"?zr():le==="codex"&&Rr())},Or=()=>{D(!0),v(null);try{const P={allowedTools:h,disallowedTools:g,skipPermissions:y,projectSortOrder:E,lastUpdated:new Date().toISOString()},X={allowedCommands:L,disallowedCommands:pe,skipPermissions:Ie,lastUpdated:new Date().toISOString()},oe={permissionMode:Ge,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(P)),localStorage.setItem("cursor-tools-settings",JSON.stringify(X)),localStorage.setItem("codex-settings",JSON.stringify(oe)),v("success"),setTimeout(()=>{r()},1e3)}catch(P){console.error("Error saving tool settings:",P),v("error")}finally{D(!1)}},qt=()=>{J({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),A(null),H(!1),B("")},Br=(P=null)=>{P?(A(P),J({name:P.name,type:P.type,scope:P.scope,projectPath:P.projectPath||"",config:{...P.config},raw:P.raw,importMode:"form",jsonInput:""})):qt(),H(!0)},Es=async P=>{P.preventDefault(),G(!0);try{if(z.importMode==="json"){const X=await Me("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:z.name,jsonConfig:z.jsonInput,scope:z.scope,projectPath:z.projectPath})});if(X.ok){const oe=await X.json();if(oe.success)await tt(),qt(),v("success");else throw new Error(oe.error||"Failed to add server via JSON")}else{const oe=await X.json();throw new Error(oe.error||"Failed to add server")}}else await zt(z),qt(),v("success")}catch(X){c(`Error: ${X.message}`,"error"),v("error")}finally{G(!1)}},Ts=async(P,X)=>{if(await u({title:i("mcp.deleteTitle","Delete MCP Server"),message:i("mcp.confirmDelete","Are you sure you want to delete this MCP server?"),confirmLabel:i("mcp.deleteButton","Delete"),cancelLabel:i("common:cancel","Cancel")}))try{await or(P,X),v("success")}catch(ve){c(`Error: ${ve.message}`,"error"),v("error")}},As=async(P,X)=>{try{$({...ie,[P]:{loading:!0}});const oe=await bs(P,X);$({...ie,[P]:oe})}catch(oe){$({...ie,[P]:{success:!1,message:oe.message,details:[]}})}},Is=async(P,X)=>{try{_({...Q,[P]:!0});const oe=await ys(P,X);te({...Z,[P]:oe})}catch{te({...Z,[P]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{_({...Q,[P]:!1})}},Kt=(P,X)=>{J(oe=>({...oe,config:{...oe.config,[P]:X}}))};return t?e.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[e.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Dt,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),e.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:i("title")})]}),e.jsx(he,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"border-b border-border",children:e.jsxs("div",{className:"flex overflow-x-auto scrollbar-none px-4 md:px-6",children:[e.jsx("button",{onClick:()=>q("agents"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.agents")}),e.jsx("button",{onClick:()=>q("appearance"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.appearance")}),e.jsxs("button",{onClick:()=>q("git"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(br,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.git")]}),e.jsxs("button",{onClick:()=>q("api"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(xa,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]}),e.jsx("button",{onClick:()=>q("tasks"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.tasks")}),e.jsxs("button",{onClick:()=>q("mcp"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx($r,{className:"w-4 h-4 inline mr-2"}),"MCP Hub"]}),e.jsxs("button",{onClick:()=>q("sessions"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="sessions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Ks,{className:"w-4 h-4 inline mr-2"}),"Sessions"]})]})}),e.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[F==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:F==="appearance"&&e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.darkMode.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.darkMode.description")})]}),e.jsxs("button",{onClick:o,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":n,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${n?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:n?e.jsx(Js,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Ys,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),e.jsx("div",{className:"space-y-4",children:e.jsx(_o,{})}),e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.projectSorting.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.projectSorting.description")})]}),e.jsxs("select",{value:E,onChange:P=>T(P.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-32",children:[e.jsx("option",{value:"name",children:i("appearanceSettings.projectSorting.alphabetical")}),e.jsx("option",{value:"date",children:i("appearanceSettings.projectSorting.recentActivity")})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:i("appearanceSettings.codeEditor.title")}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.theme.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.theme.description")})]}),e.jsxs("button",{onClick:()=>se(Y==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Y==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${Y==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:Y==="dark"?e.jsx(Js,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Ys,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.wordWrap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.wordWrap.description")})]}),e.jsxs("button",{onClick:()=>je(!de),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":de,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${de?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.showMinimap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.showMinimap.description")})]}),e.jsxs("button",{onClick:()=>Re(!ge),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":ge,"aria-label":"Toggle minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),e.jsx("span",{className:`${ge?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.description")})]}),e.jsxs("button",{onClick:()=>De(!Ne),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ne,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${Ne?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.fontSize.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.fontSize.description")})]}),e.jsxs("select",{value:Ue,onChange:P=>_e(P.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-24",children:[e.jsx("option",{value:"10",children:"10px"}),e.jsx("option",{value:"11",children:"11px"}),e.jsx("option",{value:"12",children:"12px"}),e.jsx("option",{value:"13",children:"13px"}),e.jsx("option",{value:"14",children:"14px"}),e.jsx("option",{value:"15",children:"15px"}),e.jsx("option",{value:"16",children:"16px"}),e.jsx("option",{value:"18",children:"18px"}),e.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),F==="git"&&e.jsx(Rc,{}),F==="agents"&&e.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[e.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex",children:[e.jsx(dr,{agentId:"claude",authStatus:He,isSelected:ee==="claude",onClick:()=>V("claude"),isMobile:!0}),e.jsx(dr,{agentId:"cursor",authStatus:Xe,isSelected:ee==="cursor",onClick:()=>V("cursor"),isMobile:!0}),e.jsx(dr,{agentId:"codex",authStatus:Vt,isSelected:ee==="codex",onClick:()=>V("codex"),isMobile:!0})]})}),e.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"p-2",children:[e.jsx(dr,{agentId:"claude",authStatus:He,isSelected:ee==="claude",onClick:()=>V("claude")}),e.jsx(dr,{agentId:"cursor",authStatus:Xe,isSelected:ee==="cursor",onClick:()=>V("cursor")}),e.jsx(dr,{agentId:"codex",authStatus:Vt,isSelected:ee==="codex",onClick:()=>V("codex")})]})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[e.jsx("button",{onClick:()=>M("account"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.account")}),e.jsx("button",{onClick:()=>M("permissions"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.permissions")}),e.jsx("button",{onClick:()=>M("mcp"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.mcpServers")})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[w==="account"&&e.jsx(Hc,{agent:ee,authStatus:ee==="claude"?He:ee==="cursor"?Xe:Vt,onLogin:ee==="claude"?Ns:ee==="cursor"?lr:Cs}),w==="permissions"&&ee==="claude"&&e.jsx($s,{agent:"claude",skipPermissions:y,setSkipPermissions:k,allowedTools:h,setAllowedTools:p,disallowedTools:g,setDisallowedTools:f,newAllowedTool:x,setNewAllowedTool:b,newDisallowedTool:N,setNewDisallowedTool:j}),w==="permissions"&&ee==="cursor"&&e.jsx($s,{agent:"cursor",skipPermissions:Ie,setSkipPermissions:Fe,allowedCommands:L,setAllowedCommands:K,disallowedCommands:pe,setDisallowedCommands:ye,newAllowedCommand:Se,setNewAllowedCommand:Oe,newDisallowedCommand:ne,setNewDisallowedCommand:fe}),w==="permissions"&&ee==="codex"&&e.jsx($s,{agent:"codex",permissionMode:Ge,setPermissionMode:ae}),w==="mcp"&&ee==="claude"&&e.jsx(_s,{agent:"claude",servers:W,onAdd:()=>Br(),onEdit:P=>Br(P),onDelete:(P,X)=>Ts(P,X),onTest:(P,X)=>As(P,X),onDiscoverTools:(P,X)=>Is(P,X),testResults:ie,serverTools:Z,toolsLoading:Q}),w==="mcp"&&ee==="cursor"&&e.jsx(_s,{agent:"cursor",servers:Ee,onAdd:()=>{},onEdit:P=>{},onDelete:P=>{}}),w==="mcp"&&ee==="codex"&&e.jsx(_s,{agent:"codex",servers:Pe,onAdd:()=>_r(),onEdit:P=>_r(P),onDelete:P=>ws(P)})]})]})]}),O&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(R?"mcpForm.title.edit":"mcpForm.title.add")}),e.jsx(he,{variant:"ghost",size:"sm",onClick:qt,children:e.jsx(Ve,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:Es,className:"p-4 space-y-4",children:[!R&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${z.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.form")}),e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${z.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.json")})]}),z.importMode==="form"&&R&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.scope.label")}),e.jsxs("div",{className:"flex items-center gap-2",children:[z.scope==="user"?e.jsx(qs,{className:"w-4 h-4"}):e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:z.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),z.scope==="local"&&z.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",z.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),z.importMode==="form"&&!R&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.scope.label")," *"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${z.scope==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(qs,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${z.scope==="local"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.projectLocal")})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:z.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),z.scope==="local"&&!R&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.selectProject")," *"]}),e.jsxs("select",{value:z.projectPath,onChange:P=>J(X=>({...X,projectPath:P.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",required:z.scope==="local",children:[e.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),s.map(P=>e.jsx("option",{value:P.path||P.fullPath,children:P.displayName||P.name},P.name))]}),z.projectPath&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:z.projectPath})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:z.importMode==="json"?"md:col-span-2":"",children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),e.jsx(Ze,{value:z.name,onChange:P=>{J(X=>({...X,name:P.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),z.importMode==="form"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.transportType")," *"]}),e.jsxs("select",{value:z.type,onChange:P=>{J(X=>({...X,type:P.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",children:[e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"sse",children:"SSE"}),e.jsx("option",{value:"http",children:"HTTP"})]})]})]}),R&&z.raw&&z.importMode==="form"&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:i("mcpForm.configDetails",{configFile:R.scope==="global"?"~/.claude.json":"project config"})}),e.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(z.raw,null,2)})]}),z.importMode==="json"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.jsonConfig")," *"]}),e.jsx("textarea",{value:z.jsonInput,onChange:P=>{J(X=>({...X,jsonInput:P.target.value}));try{if(P.target.value.trim()){const X=JSON.parse(P.target.value);X.type?X.type==="stdio"&&!X.command?B(i("mcpForm.validation.stdioRequiresCommand")):(X.type==="http"||X.type==="sse")&&!X.url?B(i("mcpForm.validation.httpRequiresUrl",{type:X.type})):B(""):B(i("mcpForm.validation.missingType"))}}catch{P.target.value.trim()?B(i("mcpForm.validation.invalidJson")):B("")}},className:`w-full px-3 py-2 border ${U?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 font-mono text-sm`,rows:"8",placeholder:`{
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MermaidBlock-BuBc_G-F.js","assets/vendor-syntax-DuHI9Ok6.js","assets/vendor-react-96lCPsRK.js","assets/vendor-markdown-CimbIo6Y.js","assets/vendor-diff-DNQpbhrT.js","assets/MarkdownPreview-DHmk3qzu.js","assets/FileTree-BDUnBheV.js","assets/index-C5ptjuTl.js","assets/vendor-icons-BaD0x9SL.js","assets/vendor-i18n-DCFGyhQR.js","assets/index-BFuqS0tY.css","assets/LoginModal-BWep8a6g.js","assets/vendor-xterm-CZq1hqo1.js","assets/vendor-xterm-qxJ8_QYu.css","assets/vendor-canvas-D39yWul6.js","assets/vendor-mermaid-CH7SGc99.js","assets/vendor-canvas-BZV40eAE.css","assets/vendor-codemirror-CbtmxxaB.js","assets/GitPanel-RtyZUIWS.js","assets/WorkflowsPanel-B2mIXDvD.js","assets/DashboardPanel-CblJfTGi.js","assets/CanvasWorkspace-Bk9R9_e0.js","assets/PreviewPanel-CqCa92Tf.js"])))=>i.map(i=>d[i]);
2
+ import{r as l,j as e,R as it,i as Cr,g as Yn,h as Qn,u as fi}from"./vendor-react-96lCPsRK.js";import{I as Vs,a as hr,b as Be,c as ps,d as Me,e as Lr,l as $a,f as xa,g as fr,u as Xn}from"./index-C5ptjuTl.js";import{S as Dt,b as Ut,c as _a,R as qs,P as at,d as bi,e as Ar,X as Ve,F as Zr,f as xs,g as Pr,h as Ir,i as yt,j as Lt,k as yi,l as Pt,m as er,n as mr,o as Fa,p as Mr,q as rr,W as Zn,G as br,K as ga,L as Sr,r as ha,E as sr,s as eo,T as $t,t as vt,u as fa,v as za,w as vi,x as ki,y as ba,z as $r,A as Ks,Z as tr,B as to,D as Js,H as Ys,J as Qs,N as Ra,O as wi,Q as ji,U as ya,V as gs,Y as ro,_ as es,$ as gt,a0 as ur,a as Ni,a1 as ts,a2 as Ci,a3 as so,a4 as va,a5 as ao,a6 as Xs,a7 as no,a8 as Si,a9 as Ei,aa as Ti,ab as Ai,M as ka,ac as Ii,ad as oo,ae as Mi,af as io,ag as lo,ah as Di,ai as Li,aj as Pi,ak as $i,al as _i,am as Fi,an as zi,ao as Ri,ap as Oi,aq as Bi,ar as Wi,as as Ui}from"./vendor-icons-BaD0x9SL.js";import{C as Hi,a as Gi,b as Vi,u as We,L as qi,S as co}from"./LoginModal-BWep8a6g.js";import{h as uo,p as mo,b as kt}from"./vendor-syntax-DuHI9Ok6.js";import{a as Ki,b as Ji,c as Yi,M as Qi}from"./vendor-markdown-CimbIo6Y.js";import{F as po,E as Wt,S as Xi,V as wa,c as pr,a as Zi,f as el,u as tl,b as rl,T as Oa,l as sl,h as Ba,s as al,d as nl,e as ol,g as il,i as Ds,j as ll,R as xo,o as go,k as cl,m as ho,n as dl,p as ul,q as ml,r as pl,t as xl,v as gl}from"./vendor-codemirror-CbtmxxaB.js";const Wa=t=>typeof window>"u"?!1:window.innerWidth<t,Ua=()=>{if(typeof window>"u")return!1;const t=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!t.standalone||document.referrer.includes("android-app://")};function ja(t={}){const{mobileBreakpoint:r=768,trackMobile:s=!0,trackPWA:a=!0}=t,[n,o]=l.useState(()=>s?Wa(r):!1),[i,c]=l.useState(()=>a?Ua():!1);return l.useEffect(()=>{if(!s||typeof window>"u")return;const u=()=>{o(Wa(r))};return u(),window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}},[r,s]),l.useEffect(()=>{if(!a||typeof window>"u")return;const u=window.matchMedia("(display-mode: standalone)"),d=()=>{c(Ua())};return d(),typeof u.addEventListener=="function"?(u.addEventListener("change",d),()=>{u.removeEventListener("change",d)}):(u.addListener(d),()=>{u.removeListener(d)})},[a]),{isMobile:n,isPWA:i}}const Ha="3.0.2",Ga="upfyn-version-dismissed",hl=(t,r)=>{const s=t.split(".").map(Number),a=r.split(".").map(Number);for(let n=0;n<Math.max(s.length,a.length);n++){const o=s[n]||0,i=a[n]||0;if(o!==i)return o-i}return 0},fo=(t,r)=>{const[s,a]=l.useState(!1),[n,o]=l.useState(null),[i,c]=l.useState(null);l.useEffect(()=>{if(Vs)return;const d=async()=>{try{const h=await fetch("https://registry.npmjs.org/upfynai-code/latest");if(!h.ok)return;const p=await h.json();if(p.version){const g=p.version;if(o(g),localStorage.getItem(Ga)===g){a(!1);return}a(hl(g,Ha)>0),c({title:`v${g}`,body:"",htmlUrl:"https://www.npmjs.com/package/upfynai-code",publishedAt:null})}}catch{}};d();const m=setInterval(d,1800*1e3);return()=>clearInterval(m)},[t,r]);const u=l.useCallback(()=>{n&&localStorage.setItem(Ga,n),a(!1)},[n]);return{updateAvailable:s,latestVersion:n,currentVersion:Ha,releaseInfo:i,dismissUpdate:u}},Yt={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0},rs=Object.keys(Yt),fl=new Set(rs),Ls="ui-preferences:sync",ss=(t,r)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(t==="true")return!0;if(t==="false")return!1}return r},bl=(t,r)=>{try{const s=localStorage.getItem(t);if(s===null)return r;const a=JSON.parse(s);return ss(a,r)}catch{return r}},yl=t=>{if(typeof window>"u")return Yt;try{const r=localStorage.getItem(t);if(r){const s=JSON.parse(r);if(s&&typeof s=="object"&&!Array.isArray(s)){const a=s;return rs.reduce((n,o)=>(n[o]=ss(a[o],Yt[o]),n),{...Yt})}}}catch{}return rs.reduce((r,s)=>(r[s]=bl(s,Yt[s]),r),{...Yt})};function vl(t,r){switch(r.type){case"set":{const{key:s,value:a}=r;if(!fl.has(s))return t;const n=ss(a,t[s]);return t[s]===n?t:{...t,[s]:n}}case"set_many":{const s=r.value||{};let a=!1;const n={...t};for(const o of rs){if(!(o in s))continue;const i=s[o],c=ss(i,t[o]);n[o]!==c&&(n[o]=c,a=!0)}return a?n:t}case"reset":return{...Yt,...r.value||{}};default:return t}}function Na(t="uiPreferences"){const r=l.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[s,a]=l.useReducer(vl,t,yl);return l.useEffect(()=>{typeof window>"u"||(localStorage.setItem(t,JSON.stringify(s)),window.dispatchEvent(new CustomEvent(Ls,{detail:{storageKey:t,sourceId:r.current,value:s}})))},[s,t]),l.useEffect(()=>{if(typeof window>"u")return;const c=m=>{!m||typeof m!="object"||Array.isArray(m)||a({type:"set_many",value:m})},u=m=>{if(!(m.key!==t||m.newValue===null))try{const h=JSON.parse(m.newValue);c(h)}catch{}},d=m=>{const p=m.detail;!p||p.storageKey!==t||p.sourceId===r.current||c(p.value)};return window.addEventListener("storage",u),window.addEventListener(Ls,d),()=>{window.removeEventListener("storage",u),window.removeEventListener(Ls,d)}},[t]),{preferences:s,setPreference:(c,u)=>{a({type:"set",key:c,value:u})},setPreferences:c=>{a({type:"set_many",value:c})},resetPreferences:c=>{a({type:"reset",value:c})},dispatch:a}}const kl=()=>{try{const t=localStorage.getItem("claude-settings");return t&&JSON.parse(t).projectSortOrder==="date"?"date":"name"}catch{return"name"}},wl=()=>{try{const t=localStorage.getItem("starredProjects");return t?new Set(JSON.parse(t)):new Set}catch{return new Set}},jl=t=>{try{localStorage.setItem("starredProjects",JSON.stringify([...t]))}catch{}},as=t=>t.__provider==="cursor"?new Date(t.createdAt||0):t.__provider==="codex"?new Date(t.createdAt||t.lastActivity||0):new Date(t.lastActivity||0),Nl=(t,r)=>t.__provider==="cursor"?t.name||r("projects.untitledSession"):t.__provider==="codex"?t.summary||t.name||r("projects.codexSession"):t.summary||r("projects.newSession"),Cl=t=>t.__provider==="cursor"?String(t.createdAt||""):t.__provider==="codex"?String(t.createdAt||t.lastActivity||""):String(t.lastActivity||""),Sl=(t,r,s)=>{const a=as(t),n=Math.floor((r.getTime()-a.getTime())/(1e3*60));return{isCursorSession:t.__provider==="cursor",isCodexSession:t.__provider==="codex",isActive:n<10,sessionName:Nl(t,s),sessionTime:Cl(t),messageCount:Number(t.messageCount||0)}},bo=(t,r)=>{const s=[...t.sessions||[],...r[t.name]||[]].map(o=>({...o,__provider:"claude"})),a=(t.cursorSessions||[]).map(o=>({...o,__provider:"cursor"})),n=(t.codexSessions||[]).map(o=>({...o,__provider:"codex"}));return[...s,...a,...n].sort((o,i)=>as(i).getTime()-as(o).getTime())},Va=(t,r)=>{const s=bo(t,r);return s.length===0?new Date(0):s.reduce((a,n)=>{const o=as(n);return o>a?o:a},new Date(0))},El=(t,r,s,a)=>{const n=[...t];return n.sort((o,i)=>{const c=s.has(o.name),u=s.has(i.name);return c&&!u?-1:!c&&u?1:r==="date"?Va(i,a).getTime()-Va(o,a).getTime():(o.displayName||o.name).localeCompare(i.displayName||i.name)}),n},Tl=(t,r)=>{const s=r.trim().toLowerCase();return s?t.filter(a=>{const n=(a.displayName||a.name).toLowerCase(),o=a.name.toLowerCase();return n.includes(s)||o.includes(s)}):t},Al=(t,r)=>{var n;const s=!!((n=t.taskmaster)!=null&&n.hasTaskmaster),a=!!(r!=null&&r.hasMCPServer&&(r!=null&&r.isConfigured));return s&&a?"fully-configured":s?"taskmaster-only":a?"mcp-only":"not-configured"},Il=t=>{const r=typeof t.fullPath=="string"&&t.fullPath.length>0?t.fullPath:typeof t.path=="string"?t.path:"";return{name:t.name,displayName:typeof t.displayName=="string"&&t.displayName.trim().length>0?t.displayName:t.name,fullPath:r,path:typeof t.path=="string"&&t.path.length>0?t.path:r}};function Ml({projects:t,selectedProject:r,selectedSession:s,isLoading:a,isMobile:n,t:o,onRefresh:i,onProjectSelect:c,onSessionSelect:u,onSessionDelete:d,onProjectDelete:m,setCurrentProject:h,setSidebarVisible:p,sidebarVisible:g}){const{addToast:f}=hr(),[x,b]=l.useState(new Set),[N,j]=l.useState(null),[y,k]=l.useState(!1),[I,D]=l.useState(""),[C,v]=l.useState({}),[E,T]=l.useState({}),[W,S]=l.useState(new Set),[O,H]=l.useState(new Date),[R,A]=l.useState("name"),[z,J]=l.useState(!1),[re,G]=l.useState({}),[ie,$]=l.useState(null),[Z,te]=l.useState(""),[Q,_]=l.useState(""),[F,q]=l.useState(new Set),[U,B]=l.useState(null),[ee,V]=l.useState(null),[w,M]=l.useState(!1),[Y,se]=l.useState(()=>wl()),de=!n&&!g;l.useEffect(()=>{const ae=setInterval(()=>{H(new Date)},6e4);return()=>clearInterval(ae)},[]),l.useEffect(()=>{T({}),S(new Set),G({})},[t]),l.useEffect(()=>{r&&b(ae=>{if(ae.has(r.name))return ae;const be=new Set(ae);return be.add(r.name),be})},[s,r]),l.useEffect(()=>{if(t.length>0&&!a){const ae=new Set;t.forEach(be=>{be.sessions&&be.sessions.length>=0&&ae.add(be.name)}),S(ae)}},[t,a]),l.useEffect(()=>{const ae=()=>{A(kl())};ae();const be=Ce=>{Ce.key==="claude-settings"&&ae()};window.addEventListener("storage",be);const ze=setInterval(()=>{document.hasFocus()&&ae()},1e3);return()=>{window.removeEventListener("storage",be),clearInterval(ze)}},[]);const je=l.useCallback(ae=>be=>{const ze=be.target;ze.closest(".overflow-y-auto")||ze.closest("[data-scroll-container]")||(be.preventDefault(),be.stopPropagation(),ae())},[]),ge=l.useCallback(ae=>{b(be=>{const ze=new Set;return be.has(ae)||ze.add(ae),ze})},[]),Re=l.useCallback((ae,be)=>{u({...ae,__projectName:be})},[u]),Ne=l.useCallback(ae=>{se(be=>{const ze=new Set(be);return ze.has(ae)?ze.delete(ae):ze.add(ae),jl(ze),ze})},[]),De=l.useCallback(ae=>Y.has(ae),[Y]),Ue=l.useCallback(ae=>bo(ae,E),[E]),_e=l.useMemo(()=>t.map(ae=>{const be=re[ae.name];return be===void 0?ae:{...ae,sessionMeta:{...ae.sessionMeta,hasMore:be}}}),[re,t]),L=l.useMemo(()=>El(_e,R,Y,E),[E,R,_e,Y]),K=l.useMemo(()=>Tl(L,Q),[Q,L]),pe=l.useCallback(ae=>{j(ae.name),D(ae.displayName)},[]),ye=l.useCallback(()=>{j(null),D("")},[]),Ie=l.useCallback(async ae=>{try{(await Be.renameProject(ae,I)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(be){console.error("Error renaming project:",be)}finally{j(null),D("")}},[I]),Fe=l.useCallback((ae,be,ze,Ce="claude")=>{V({projectName:ae,sessionId:be,sessionTitle:ze,provider:Ce})},[]),Se=l.useCallback(async()=>{if(!ee)return;const{projectName:ae,sessionId:be,provider:ze}=ee;V(null),d==null||d(be);try{const Ce=ze==="codex"?await Be.deleteCodexSession(be):await Be.deleteSession(ae,be);Ce.ok||console.error("[Sidebar] Failed to delete session:",Ce.status)}catch(Ce){console.error("[Sidebar] Error deleting session:",Ce)}},[d,ee,o]),Oe=l.useCallback(ae=>{B({project:ae,sessionCount:Ue(ae).length})},[Ue]),ne=l.useCallback(async()=>{if(!U)return;const{project:ae,sessionCount:be}=U,ze=be===0;B(null),q(Ce=>new Set([...Ce,ae.name]));try{const Ce=await Be.deleteProject(ae.name,!ze);if(Ce.ok)m==null||m(ae.name);else{const Ye=await Ce.json();f(Ye.error||o("messages.deleteProjectFailed"),"error")}}catch(Ce){console.error("Error deleting project:",Ce),f(o("messages.deleteProjectError"),"error")}finally{q(Ce=>{const Ye=new Set(Ce);return Ye.delete(ae.name),Ye})}},[U,m,o]),fe=l.useCallback(async ae=>{var Ce,Ye,lt;const be=re[ae.name];if(!(!(be!==void 0?be:((Ce=ae.sessionMeta)==null?void 0:Ce.hasMore)===!0)||C[ae.name])){v(dt=>({...dt,[ae.name]:!0}));try{const dt=(((Ye=ae.sessions)==null?void 0:Ye.length)||0)+(((lt=E[ae.name])==null?void 0:lt.length)||0),Tt=await Be.sessions(ae.name,5,dt);if(!Tt.ok)return;const At=await Tt.json();T(wt=>({...wt,[ae.name]:[...wt[ae.name]||[],...At.sessions||[]]})),At.hasMore===!1&&G(wt=>({...wt,[ae.name]:!1}))}catch(dt){console.error("Error loading more sessions:",dt)}finally{v(dt=>({...dt,[ae.name]:!1}))}}},[E,C,re]),Ee=l.useCallback(ae=>{c(ae),h(ae)},[c,h]),Le=l.useCallback(async()=>{J(!0);try{await i()}finally{J(!1)}},[i]),Pe=l.useCallback(async(ae,be,ze)=>{$(null),te("")},[]),Ae=l.useCallback(()=>{p(!1)},[p]),Ge=l.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:de,expandedProjects:x,editingProject:N,showNewProject:y,editingName:I,loadingSessions:C,additionalSessions:E,initialSessionsLoaded:W,currentTime:O,projectSortOrder:R,isRefreshing:z,editingSession:ie,editingSessionName:Z,searchFilter:Q,deletingProjects:F,deleteConfirmation:U,sessionDeleteConfirmation:ee,showVersionModal:w,starredProjects:Y,filteredProjects:K,handleTouchClick:je,toggleProject:ge,handleSessionClick:Re,toggleStarProject:Ne,isProjectStarred:De,getProjectSessions:Ue,startEditing:pe,cancelEditing:ye,saveProjectName:Ie,showDeleteSessionConfirmation:Fe,confirmDeleteSession:Se,requestProjectDelete:Oe,confirmDeleteProject:ne,loadMoreSessions:fe,handleProjectSelect:Ee,refreshProjects:Le,updateSessionSummary:Pe,collapseSidebar:Ae,expandSidebar:Ge,setShowNewProject:k,setEditingName:D,setEditingSession:$,setEditingSessionName:te,setSearchFilter:_,setDeleteConfirmation:B,setSessionDeleteConfirmation:V,setShowVersionModal:M}}function Dl({onExpand:t,onShowSettings:r,updateAvailable:s,onShowVersionModal:a,t:n}){return e.jsxs("div",{className:"h-full flex flex-col items-center py-3 gap-1 bg-background/80 backdrop-blur-sm w-12",children:[e.jsx("button",{onClick:t,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("common:versionUpdate.ariaLabels.showSidebar"),title:n("common:versionUpdate.ariaLabels.showSidebar"),children:e.jsx("img",{src:"/favicon.svg",alt:"",className:"w-6 h-6 rounded"})}),e.jsx("div",{className:"nav-divider w-6 my-1"}),e.jsx("button",{onClick:r,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("actions.settings"),title:n("actions.settings"),children:e.jsx(Dt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),s&&e.jsxs("button",{onClick:a,className:"relative w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors","aria-label":n("common:versionUpdate.ariaLabels.updateAvailable"),title:n("common:versionUpdate.ariaLabels.updateAvailable"),children:[e.jsx(Ut,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]})]})}function yo(t){var r,s,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(r=0;r<n;r++)t[r]&&(s=yo(t[r]))&&(a&&(a+=" "),a+=s)}else for(s in t)t[s]&&(a&&(a+=" "),a+=s);return a}function vo(){for(var t,r,s=0,a="",n=arguments.length;s<n;s++)(t=arguments[s])&&(r=yo(t))&&(a&&(a+=" "),a+=r);return a}const Ll=(t,r)=>{const s=new Array(t.length+r.length);for(let a=0;a<t.length;a++)s[a]=t[a];for(let a=0;a<r.length;a++)s[t.length+a]=r[a];return s},Pl=(t,r)=>({classGroupId:t,validator:r}),ko=(t=new Map,r=null,s)=>({nextPart:t,validators:r,classGroupId:s}),ns="-",qa=[],$l="arbitrary..",_l=t=>{const r=zl(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Fl(i);const c=i.split(ns),u=c[0]===""&&c.length>1?1:0;return wo(c,u,r)},getConflictingClassGroupIds:(i,c)=>{if(c){const u=a[i],d=s[i];return u?d?Ll(d,u):u:d||qa}return s[i]||qa}}},wo=(t,r,s)=>{if(t.length-r===0)return s.classGroupId;const n=t[r],o=s.nextPart.get(n);if(o){const d=wo(t,r+1,o);if(d)return d}const i=s.validators;if(i===null)return;const c=r===0?t.join(ns):t.slice(r).join(ns),u=i.length;for(let d=0;d<u;d++){const m=i[d];if(m.validator(c))return m.classGroupId}},Fl=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=t.slice(1,-1),s=r.indexOf(":"),a=r.slice(0,s);return a?$l+a:void 0})(),zl=t=>{const{theme:r,classGroups:s}=t;return Rl(s,r)},Rl=(t,r)=>{const s=ko();for(const a in t){const n=t[a];Ca(n,s,a,r)}return s},Ca=(t,r,s,a)=>{const n=t.length;for(let o=0;o<n;o++){const i=t[o];Ol(i,r,s,a)}},Ol=(t,r,s,a)=>{if(typeof t=="string"){Bl(t,r,s);return}if(typeof t=="function"){Wl(t,r,s,a);return}Ul(t,r,s,a)},Bl=(t,r,s)=>{const a=t===""?r:jo(r,t);a.classGroupId=s},Wl=(t,r,s,a)=>{if(Hl(t)){Ca(t(a),r,s,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Pl(s,t))},Ul=(t,r,s,a)=>{const n=Object.entries(t),o=n.length;for(let i=0;i<o;i++){const[c,u]=n[i];Ca(u,jo(r,c),s,a)}},jo=(t,r)=>{let s=t;const a=r.split(ns),n=a.length;for(let o=0;o<n;o++){const i=a[o];let c=s.nextPart.get(i);c||(c=ko(),s.nextPart.set(i,c)),s=c}return s},Hl=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,Gl=t=>{if(t<1)return{get:()=>{},set:()=>{}};let r=0,s=Object.create(null),a=Object.create(null);const n=(o,i)=>{s[o]=i,r++,r>t&&(r=0,a=s,s=Object.create(null))};return{get(o){let i=s[o];if(i!==void 0)return i;if((i=a[o])!==void 0)return n(o,i),i},set(o,i){o in s?s[o]=i:n(o,i)}}},Zs="!",Ka=":",Vl=[],Ja=(t,r,s,a,n)=>({modifiers:t,hasImportantModifier:r,baseClassName:s,maybePostfixModifierPosition:a,isExternal:n}),ql=t=>{const{prefix:r,experimentalParseClassName:s}=t;let a=n=>{const o=[];let i=0,c=0,u=0,d;const m=n.length;for(let x=0;x<m;x++){const b=n[x];if(i===0&&c===0){if(b===Ka){o.push(n.slice(u,x)),u=x+1;continue}if(b==="/"){d=x;continue}}b==="["?i++:b==="]"?i--:b==="("?c++:b===")"&&c--}const h=o.length===0?n:n.slice(u);let p=h,g=!1;h.endsWith(Zs)?(p=h.slice(0,-1),g=!0):h.startsWith(Zs)&&(p=h.slice(1),g=!0);const f=d&&d>u?d-u:void 0;return Ja(o,g,p,f)};if(r){const n=r+Ka,o=a;a=i=>i.startsWith(n)?o(i.slice(n.length)):Ja(Vl,!1,i,void 0,!0)}if(s){const n=a;a=o=>s({className:o,parseClassName:n})}return a},Kl=t=>{const r=new Map;return t.orderSensitiveModifiers.forEach((s,a)=>{r.set(s,1e6+a)}),s=>{const a=[];let n=[];for(let o=0;o<s.length;o++){const i=s[o],c=i[0]==="[",u=r.has(i);c||u?(n.length>0&&(n.sort(),a.push(...n),n=[]),a.push(i)):n.push(i)}return n.length>0&&(n.sort(),a.push(...n)),a}},Jl=t=>({cache:Gl(t.cacheSize),parseClassName:ql(t),sortModifiers:Kl(t),..._l(t)}),Yl=/\s+/,Ql=(t,r)=>{const{parseClassName:s,getClassGroupId:a,getConflictingClassGroupIds:n,sortModifiers:o}=r,i=[],c=t.trim().split(Yl);let u="";for(let d=c.length-1;d>=0;d-=1){const m=c[d],{isExternal:h,modifiers:p,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:x}=s(m);if(h){u=m+(u.length>0?" "+u:u);continue}let b=!!x,N=a(b?f.substring(0,x):f);if(!N){if(!b){u=m+(u.length>0?" "+u:u);continue}if(N=a(f),!N){u=m+(u.length>0?" "+u:u);continue}b=!1}const j=p.length===0?"":p.length===1?p[0]:o(p).join(":"),y=g?j+Zs:j,k=y+N;if(i.indexOf(k)>-1)continue;i.push(k);const I=n(N,b);for(let D=0;D<I.length;++D){const C=I[D];i.push(y+C)}u=m+(u.length>0?" "+u:u)}return u},Xl=(...t)=>{let r=0,s,a,n="";for(;r<t.length;)(s=t[r++])&&(a=No(s))&&(n&&(n+=" "),n+=a);return n},No=t=>{if(typeof t=="string")return t;let r,s="";for(let a=0;a<t.length;a++)t[a]&&(r=No(t[a]))&&(s&&(s+=" "),s+=r);return s},Zl=(t,...r)=>{let s,a,n,o;const i=u=>{const d=r.reduce((m,h)=>h(m),t());return s=Jl(d),a=s.cache.get,n=s.cache.set,o=c,c(u)},c=u=>{const d=a(u);if(d)return d;const m=Ql(u,s);return n(u,m),m};return o=i,(...u)=>o(Xl(...u))},ec=[],rt=t=>{const r=s=>s[t]||ec;return r.isThemeGetter=!0,r},Co=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,So=/^\((?:(\w[\w-]*):)?(.+)\)$/i,tc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,rc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sc=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ac=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,nc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,oc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Rt=t=>tc.test(t),$e=t=>!!t&&!Number.isNaN(Number(t)),Ot=t=>!!t&&Number.isInteger(Number(t)),Ps=t=>t.endsWith("%")&&$e(t.slice(0,-1)),Mt=t=>rc.test(t),Eo=()=>!0,ic=t=>sc.test(t)&&!ac.test(t),Sa=()=>!1,lc=t=>nc.test(t),cc=t=>oc.test(t),dc=t=>!me(t)&&!xe(t),uc=t=>Ht(t,Io,Sa),me=t=>Co.test(t),Jt=t=>Ht(t,Mo,ic),Ya=t=>Ht(t,yc,$e),mc=t=>Ht(t,Lo,Eo),pc=t=>Ht(t,Do,Sa),Qa=t=>Ht(t,To,Sa),xc=t=>Ht(t,Ao,cc),Hr=t=>Ht(t,Po,lc),xe=t=>So.test(t),kr=t=>ar(t,Mo),gc=t=>ar(t,Do),Xa=t=>ar(t,To),hc=t=>ar(t,Io),fc=t=>ar(t,Ao),Gr=t=>ar(t,Po,!0),bc=t=>ar(t,Lo,!0),Ht=(t,r,s)=>{const a=Co.exec(t);return a?a[1]?r(a[1]):s(a[2]):!1},ar=(t,r,s=!1)=>{const a=So.exec(t);return a?a[1]?r(a[1]):s:!1},To=t=>t==="position"||t==="percentage",Ao=t=>t==="image"||t==="url",Io=t=>t==="length"||t==="size"||t==="bg-size",Mo=t=>t==="length",yc=t=>t==="number",Do=t=>t==="family-name",Lo=t=>t==="number"||t==="weight",Po=t=>t==="shadow",vc=()=>{const t=rt("color"),r=rt("font"),s=rt("text"),a=rt("font-weight"),n=rt("tracking"),o=rt("leading"),i=rt("breakpoint"),c=rt("container"),u=rt("spacing"),d=rt("radius"),m=rt("shadow"),h=rt("inset-shadow"),p=rt("text-shadow"),g=rt("drop-shadow"),f=rt("blur"),x=rt("perspective"),b=rt("aspect"),N=rt("ease"),j=rt("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],I=()=>[...k(),xe,me],D=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],v=()=>[xe,me,u],E=()=>[Rt,"full","auto",...v()],T=()=>[Ot,"none","subgrid",xe,me],W=()=>["auto",{span:["full",Ot,xe,me]},Ot,xe,me],S=()=>[Ot,"auto",xe,me],O=()=>["auto","min","max","fr",xe,me],H=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],R=()=>["start","end","center","stretch","center-safe","end-safe"],A=()=>["auto",...v()],z=()=>[Rt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],J=()=>[Rt,"screen","full","dvw","lvw","svw","min","max","fit",...v()],re=()=>[Rt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],G=()=>[t,xe,me],ie=()=>[...k(),Xa,Qa,{position:[xe,me]}],$=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Z=()=>["auto","cover","contain",hc,uc,{size:[xe,me]}],te=()=>[Ps,kr,Jt],Q=()=>["","none","full",d,xe,me],_=()=>["",$e,kr,Jt],F=()=>["solid","dashed","dotted","double"],q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>[$e,Ps,Xa,Qa],B=()=>["","none",f,xe,me],ee=()=>["none",$e,xe,me],V=()=>["none",$e,xe,me],w=()=>[$e,xe,me],M=()=>[Rt,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Mt],breakpoint:[Mt],color:[Eo],container:[Mt],"drop-shadow":[Mt],ease:["in","out","in-out"],font:[dc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Mt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Mt],shadow:[Mt],spacing:["px",$e],text:[Mt],"text-shadow":[Mt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Rt,me,xe,b]}],container:["container"],columns:[{columns:[$e,me,xe,c]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:I()}],overflow:[{overflow:D()}],"overflow-x":[{"overflow-x":D()}],"overflow-y":[{"overflow-y":D()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{"inset-s":E(),start:E()}],end:[{"inset-e":E(),end:E()}],"inset-bs":[{"inset-bs":E()}],"inset-be":[{"inset-be":E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[Ot,"auto",xe,me]}],basis:[{basis:[Rt,"full","auto",c,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[$e,Rt,"auto","initial","none",me]}],grow:[{grow:["",$e,xe,me]}],shrink:[{shrink:["",$e,xe,me]}],order:[{order:[Ot,"first","last","none",xe,me]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:W()}],"col-start":[{"col-start":S()}],"col-end":[{"col-end":S()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:W()}],"row-start":[{"row-start":S()}],"row-end":[{"row-end":S()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":O()}],"auto-rows":[{"auto-rows":O()}],gap:[{gap:v()}],"gap-x":[{"gap-x":v()}],"gap-y":[{"gap-y":v()}],"justify-content":[{justify:[...H(),"normal"]}],"justify-items":[{"justify-items":[...R(),"normal"]}],"justify-self":[{"justify-self":["auto",...R()]}],"align-content":[{content:["normal",...H()]}],"align-items":[{items:[...R(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...R(),{baseline:["","last"]}]}],"place-content":[{"place-content":H()}],"place-items":[{"place-items":[...R(),"baseline"]}],"place-self":[{"place-self":["auto",...R()]}],p:[{p:v()}],px:[{px:v()}],py:[{py:v()}],ps:[{ps:v()}],pe:[{pe:v()}],pbs:[{pbs:v()}],pbe:[{pbe:v()}],pt:[{pt:v()}],pr:[{pr:v()}],pb:[{pb:v()}],pl:[{pl:v()}],m:[{m:A()}],mx:[{mx:A()}],my:[{my:A()}],ms:[{ms:A()}],me:[{me:A()}],mbs:[{mbs:A()}],mbe:[{mbe:A()}],mt:[{mt:A()}],mr:[{mr:A()}],mb:[{mb:A()}],ml:[{ml:A()}],"space-x":[{"space-x":v()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":v()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],"inline-size":[{inline:["auto",...J()]}],"min-inline-size":[{"min-inline":["auto",...J()]}],"max-inline-size":[{"max-inline":["none",...J()]}],"block-size":[{block:["auto",...re()]}],"min-block-size":[{"min-block":["auto",...re()]}],"max-block-size":[{"max-block":["none",...re()]}],w:[{w:[c,"screen",...z()]}],"min-w":[{"min-w":[c,"screen","none",...z()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",s,kr,Jt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,bc,mc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ps,me]}],"font-family":[{font:[gc,pc,r]}],"font-features":[{"font-features":[me]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[n,xe,me]}],"line-clamp":[{"line-clamp":[$e,"none",xe,Ya]}],leading:[{leading:[o,...v()]}],"list-image":[{"list-image":["none",xe,me]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",xe,me]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:G()}],"text-color":[{text:G()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...F(),"wavy"]}],"text-decoration-thickness":[{decoration:[$e,"from-font","auto",xe,Jt]}],"text-decoration-color":[{decoration:G()}],"underline-offset":[{"underline-offset":[$e,"auto",xe,me]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:v()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",xe,me]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",xe,me]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:$()}],"bg-size":[{bg:Z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ot,xe,me],radial:["",xe,me],conic:[Ot,xe,me]},fc,xc]}],"bg-color":[{bg:G()}],"gradient-from-pos":[{from:te()}],"gradient-via-pos":[{via:te()}],"gradient-to-pos":[{to:te()}],"gradient-from":[{from:G()}],"gradient-via":[{via:G()}],"gradient-to":[{to:G()}],rounded:[{rounded:Q()}],"rounded-s":[{"rounded-s":Q()}],"rounded-e":[{"rounded-e":Q()}],"rounded-t":[{"rounded-t":Q()}],"rounded-r":[{"rounded-r":Q()}],"rounded-b":[{"rounded-b":Q()}],"rounded-l":[{"rounded-l":Q()}],"rounded-ss":[{"rounded-ss":Q()}],"rounded-se":[{"rounded-se":Q()}],"rounded-ee":[{"rounded-ee":Q()}],"rounded-es":[{"rounded-es":Q()}],"rounded-tl":[{"rounded-tl":Q()}],"rounded-tr":[{"rounded-tr":Q()}],"rounded-br":[{"rounded-br":Q()}],"rounded-bl":[{"rounded-bl":Q()}],"border-w":[{border:_()}],"border-w-x":[{"border-x":_()}],"border-w-y":[{"border-y":_()}],"border-w-s":[{"border-s":_()}],"border-w-e":[{"border-e":_()}],"border-w-bs":[{"border-bs":_()}],"border-w-be":[{"border-be":_()}],"border-w-t":[{"border-t":_()}],"border-w-r":[{"border-r":_()}],"border-w-b":[{"border-b":_()}],"border-w-l":[{"border-l":_()}],"divide-x":[{"divide-x":_()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":_()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...F(),"hidden","none"]}],"divide-style":[{divide:[...F(),"hidden","none"]}],"border-color":[{border:G()}],"border-color-x":[{"border-x":G()}],"border-color-y":[{"border-y":G()}],"border-color-s":[{"border-s":G()}],"border-color-e":[{"border-e":G()}],"border-color-bs":[{"border-bs":G()}],"border-color-be":[{"border-be":G()}],"border-color-t":[{"border-t":G()}],"border-color-r":[{"border-r":G()}],"border-color-b":[{"border-b":G()}],"border-color-l":[{"border-l":G()}],"divide-color":[{divide:G()}],"outline-style":[{outline:[...F(),"none","hidden"]}],"outline-offset":[{"outline-offset":[$e,xe,me]}],"outline-w":[{outline:["",$e,kr,Jt]}],"outline-color":[{outline:G()}],shadow:[{shadow:["","none",m,Gr,Hr]}],"shadow-color":[{shadow:G()}],"inset-shadow":[{"inset-shadow":["none",h,Gr,Hr]}],"inset-shadow-color":[{"inset-shadow":G()}],"ring-w":[{ring:_()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:G()}],"ring-offset-w":[{"ring-offset":[$e,Jt]}],"ring-offset-color":[{"ring-offset":G()}],"inset-ring-w":[{"inset-ring":_()}],"inset-ring-color":[{"inset-ring":G()}],"text-shadow":[{"text-shadow":["none",p,Gr,Hr]}],"text-shadow-color":[{"text-shadow":G()}],opacity:[{opacity:[$e,xe,me]}],"mix-blend":[{"mix-blend":[...q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":q()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[$e]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":G()}],"mask-image-linear-to-color":[{"mask-linear-to":G()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":G()}],"mask-image-t-to-color":[{"mask-t-to":G()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":G()}],"mask-image-r-to-color":[{"mask-r-to":G()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":G()}],"mask-image-b-to-color":[{"mask-b-to":G()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":G()}],"mask-image-l-to-color":[{"mask-l-to":G()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":G()}],"mask-image-x-to-color":[{"mask-x-to":G()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":G()}],"mask-image-y-to-color":[{"mask-y-to":G()}],"mask-image-radial":[{"mask-radial":[xe,me]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":G()}],"mask-image-radial-to-color":[{"mask-radial-to":G()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":k()}],"mask-image-conic-pos":[{"mask-conic":[$e]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":G()}],"mask-image-conic-to-color":[{"mask-conic-to":G()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:$()}],"mask-size":[{mask:Z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",xe,me]}],filter:[{filter:["","none",xe,me]}],blur:[{blur:B()}],brightness:[{brightness:[$e,xe,me]}],contrast:[{contrast:[$e,xe,me]}],"drop-shadow":[{"drop-shadow":["","none",g,Gr,Hr]}],"drop-shadow-color":[{"drop-shadow":G()}],grayscale:[{grayscale:["",$e,xe,me]}],"hue-rotate":[{"hue-rotate":[$e,xe,me]}],invert:[{invert:["",$e,xe,me]}],saturate:[{saturate:[$e,xe,me]}],sepia:[{sepia:["",$e,xe,me]}],"backdrop-filter":[{"backdrop-filter":["","none",xe,me]}],"backdrop-blur":[{"backdrop-blur":B()}],"backdrop-brightness":[{"backdrop-brightness":[$e,xe,me]}],"backdrop-contrast":[{"backdrop-contrast":[$e,xe,me]}],"backdrop-grayscale":[{"backdrop-grayscale":["",$e,xe,me]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[$e,xe,me]}],"backdrop-invert":[{"backdrop-invert":["",$e,xe,me]}],"backdrop-opacity":[{"backdrop-opacity":[$e,xe,me]}],"backdrop-saturate":[{"backdrop-saturate":[$e,xe,me]}],"backdrop-sepia":[{"backdrop-sepia":["",$e,xe,me]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":v()}],"border-spacing-x":[{"border-spacing-x":v()}],"border-spacing-y":[{"border-spacing-y":v()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",xe,me]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[$e,"initial",xe,me]}],ease:[{ease:["linear","initial",N,xe,me]}],delay:[{delay:[$e,xe,me]}],animate:[{animate:["none",j,xe,me]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,xe,me]}],"perspective-origin":[{"perspective-origin":I()}],rotate:[{rotate:ee()}],"rotate-x":[{"rotate-x":ee()}],"rotate-y":[{"rotate-y":ee()}],"rotate-z":[{"rotate-z":ee()}],scale:[{scale:V()}],"scale-x":[{"scale-x":V()}],"scale-y":[{"scale-y":V()}],"scale-z":[{"scale-z":V()}],"scale-3d":["scale-3d"],skew:[{skew:w()}],"skew-x":[{"skew-x":w()}],"skew-y":[{"skew-y":w()}],transform:[{transform:[xe,me,"","none","gpu","cpu"]}],"transform-origin":[{origin:I()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:M()}],"translate-x":[{"translate-x":M()}],"translate-y":[{"translate-y":M()}],"translate-z":[{"translate-z":M()}],"translate-none":["translate-none"],accent:[{accent:G()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:G()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",xe,me]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":v()}],"scroll-mx":[{"scroll-mx":v()}],"scroll-my":[{"scroll-my":v()}],"scroll-ms":[{"scroll-ms":v()}],"scroll-me":[{"scroll-me":v()}],"scroll-mbs":[{"scroll-mbs":v()}],"scroll-mbe":[{"scroll-mbe":v()}],"scroll-mt":[{"scroll-mt":v()}],"scroll-mr":[{"scroll-mr":v()}],"scroll-mb":[{"scroll-mb":v()}],"scroll-ml":[{"scroll-ml":v()}],"scroll-p":[{"scroll-p":v()}],"scroll-px":[{"scroll-px":v()}],"scroll-py":[{"scroll-py":v()}],"scroll-ps":[{"scroll-ps":v()}],"scroll-pe":[{"scroll-pe":v()}],"scroll-pbs":[{"scroll-pbs":v()}],"scroll-pbe":[{"scroll-pbe":v()}],"scroll-pt":[{"scroll-pt":v()}],"scroll-pr":[{"scroll-pr":v()}],"scroll-pb":[{"scroll-pb":v()}],"scroll-pl":[{"scroll-pl":v()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",xe,me]}],fill:[{fill:["none",...G()]}],"stroke-w":[{stroke:[$e,kr,Jt,Ya]}],stroke:[{stroke:["none",...G()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},kc=Zl(vc);function ke(...t){return kc(vo(t))}function wc(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const $o=l.forwardRef(({className:t,children:r,...s},a)=>e.jsx("div",{className:ke(t,"relative overflow-hidden"),...s,children:e.jsx("div",{ref:a,className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));$o.displayName="ScrollArea";function jc({updateAvailable:t,releaseInfo:r,latestVersion:s,onShowVersionModal:a,onShowSettings:n,t:o}){return e.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-left hover:bg-blue-50/80 dark:hover:bg-blue-900/15 transition-colors group",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(_a,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:(r==null?void 0:r.title)||`v${s}`}),e.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})}),e.jsx("div",{className:"md:hidden px-3 py-2",children:e.jsxs("button",{className:"w-full h-11 bg-blue-50/80 dark:bg-blue-900/15 border border-blue-200/60 dark:border-blue-700/40 rounded-xl flex items-center gap-3 px-3.5 active:scale-[0.98] transition-all",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(_a,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:(r==null?void 0:r.title)||`v${s}`}),e.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})})]}),e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors",onClick:n,children:[e.jsx(Dt,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),e.jsx("div",{className:"md:hidden p-3 pb-20",children:e.jsxs("button",{className:"w-full h-12 bg-muted/40 hover:bg-muted/60 rounded-xl flex items-center gap-3.5 px-4 active:scale-[0.98] transition-all",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-background/80 flex items-center justify-center",children:e.jsx(Dt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),e.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const Za=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,en=vo,_o=(t,r)=>s=>{var a;if((r==null?void 0:r.variants)==null)return en(t,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:n,defaultVariants:o}=r,i=Object.keys(n).map(d=>{const m=s==null?void 0:s[d],h=o==null?void 0:o[d];if(m===null)return null;const p=Za(m)||Za(h);return n[d][p]}),c=s&&Object.entries(s).reduce((d,m)=>{let[h,p]=m;return p===void 0||(d[h]=p),d},{}),u=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((d,m)=>{let{class:h,className:p,...g}=m;return Object.entries(g).every(f=>{let[x,b]=f;return Array.isArray(b)?b.includes({...o,...c}[x]):{...o,...c}[x]===b})?[...d,h,p]:d},[]);return en(t,i,u,s==null?void 0:s.class,s==null?void 0:s.className)},Nc=_o("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),he=l.forwardRef(({className:t,variant:r,size:s,...a},n)=>e.jsx("button",{className:ke(Nc({variant:r,size:s,className:t})),ref:n,...a}));he.displayName="Button";const Ze=l.forwardRef(({className:t,type:r,...s},a)=>e.jsx("input",{type:r,className:ke("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),ref:a,...s}));Ze.displayName="Input";function Cc({isPWA:t,isMobile:r,isLoading:s,projectsCount:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,t:h}){const p=()=>e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("img",{src:"/favicon.svg",alt:"",className:"w-7 h-7 rounded-lg flex-shrink-0"}),e.jsx("h1",{className:"text-sm font-semibold text-foreground tracking-tight truncate",children:h("app.title")})]});return e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"hidden md:block px-3 pt-3 pb-2",style:{},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Vs?e.jsx("a",{href:"https://cli.upfyn.com",className:"flex items-center gap-2.5 min-w-0 hover:opacity-80 transition-opacity",title:h("tooltips.viewEnvironments"),children:e.jsx(p,{})}):e.jsx(p,{}),e.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(he,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:c,disabled:u,title:h("tooltips.refresh"),children:e.jsx(qs,{className:`w-3.5 h-3.5 ${u?"animate-spin":""}`})}),e.jsx(he,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:d,title:h("tooltips.createProject"),children:e.jsx(at,{className:"w-3.5 h-3.5"})}),e.jsx(he,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:m,title:h("tooltips.hideSidebar"),children:e.jsx(bi,{className:"w-3.5 h-3.5"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(Ar,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground/50 pointer-events-none"}),e.jsx(Ze,{type:"text",placeholder:h("projects.searchPlaceholder"),value:n,onChange:g=>o(g.target.value),className:"nav-search-input pl-9 pr-8 h-9 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-accent rounded-md",children:e.jsx(Ve,{className:"w-3 h-3 text-muted-foreground"})})]})]}),e.jsx("div",{className:"hidden md:block nav-divider"}),e.jsxs("div",{className:"md:hidden p-3 pb-2",style:t&&r?{paddingTop:"16px"}:{},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[Vs?e.jsx("a",{href:"https://cli.upfyn.com",className:"flex items-center gap-2.5 active:opacity-70 transition-opacity min-w-0",title:h("tooltips.viewEnvironments"),children:e.jsx(p,{})}):e.jsx(p,{}),e.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-muted/50 flex items-center justify-center active:scale-95 transition-all",onClick:c,disabled:u,children:e.jsx(qs,{className:`w-4 h-4 text-muted-foreground ${u?"animate-spin":""}`})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/90 text-primary-foreground flex items-center justify-center active:scale-95 transition-all",onClick:d,children:e.jsx(Zr,{className:"w-4 h-4"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(Ar,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 pointer-events-none"}),e.jsx(Ze,{type:"text",placeholder:h("projects.searchPlaceholder"),value:n,onChange:g=>o(g.target.value),className:"nav-search-input pl-10 pr-9 h-10 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 hover:bg-accent rounded-md",children:e.jsx(Ve,{className:"w-3.5 h-3.5 text-muted-foreground"})})]})]}),e.jsx("div",{className:"md:hidden nav-divider"})]})}const Sc=({status:t="not-configured",size:r="sm",className:s="",showLabel:a=!1})=>{const o=(()=>{switch(t){case"fully-configured":return{icon:Pr,color:"text-green-500 dark:text-green-400",bgColor:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"};case"taskmaster-only":return{icon:Dt,color:"text-blue-500 dark:text-blue-400",bgColor:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"};case"mcp-only":return{icon:xs,color:"text-amber-500 dark:text-amber-400",bgColor:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"};case"not-configured":case"error":default:return{icon:Ve,color:"text-gray-400 dark:text-gray-500",bgColor:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"}}})(),i=o.icon,c={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},u={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"};return a?e.jsxs("div",{className:ke("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",o.bgColor,o.color,s),title:o.title,children:[e.jsx(i,{className:c[r]}),e.jsx("span",{className:"font-medium",children:o.label})]}):e.jsx("div",{className:ke("inline-flex items-center justify-center rounded-full transition-colors",o.bgColor,u[r],s),title:o.title,children:e.jsx(i,{className:ke(c[r],o.color)})})},Ec=_o("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function bt({className:t,variant:r,...s}){return e.jsx("div",{className:ke(Ec({variant:r}),t),...s})}const tn=(t,r,s)=>{const a=new Date(t),n=r;if(isNaN(a.getTime()))return s?s("status.unknown"):"Unknown";const o=n.getTime()-a.getTime(),i=Math.floor(o/1e3),c=Math.floor(o/(1e3*60)),u=Math.floor(o/(1e3*60*60)),d=Math.floor(o/(1e3*60*60*24));return i<60?s?s("time.justNow"):"Just now":c===1?s?s("time.oneMinuteAgo"):"1 min ago":c<60?s?s("time.minutesAgo",{count:c}):`${c} mins ago`:u===1?s?s("time.oneHourAgo"):"1 hour ago":u<24?s?s("time.hoursAgo",{count:u}):`${u} hours ago`:d===1?s?s("time.oneDayAgo"):"1 day ago":d<7?s?s("time.daysAgo",{count:d}):`${d} days ago`:a.toLocaleDateString()};function ft({provider:t="claude",className:r="w-5 h-5"}){return t==="cursor"?e.jsx(Hi,{className:r}):t==="codex"?e.jsx(Gi,{className:r}):e.jsx(Vi,{className:r})}function Tc({project:t,session:r,selectedSession:s,currentTime:a,editingSession:n,editingSessionName:o,onEditingSessionNameChange:i,onStartEditingSession:c,onCancelEditingSession:u,onSaveEditingSession:d,onProjectSelect:m,onSessionSelect:h,onDeleteSession:p,touchHandlerFactory:g,t:f}){const x=Sl(r,a,f),b=(s==null?void 0:s.id)===r.id,N=()=>{m(t),h(r,t.name)},j=()=>{d(t.name,r.id,o)},y=()=>{p(t.name,r.id,x.sessionName,r.__provider)};return e.jsxs("div",{className:"group relative",children:[x.isActive&&e.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-y-1/2 -translate-x-1",children:e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})}),e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:ke("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",b?"bg-primary/5 border-primary/20":"",!b&&x.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:N,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:ke("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",b?"bg-primary/10":"bg-muted/50"),children:e.jsx(ft,{provider:r.__provider,className:"w-3 h-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:x.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Ir,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:tn(x.sessionTime,a,f)}),x.messageCount>0&&e.jsx(bt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:x.messageCount}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(ft,{provider:r.__provider,className:"w-3 h-3"})})]})]}),!x.isCursorSession&&e.jsx("button",{className:"w-5 h-5 rounded-md bg-red-50 dark:bg-red-900/20 flex items-center justify-center active:scale-95 transition-transform opacity-70 ml-1",onClick:k=>{k.stopPropagation(),y()},children:e.jsx(yt,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(he,{variant:"ghost",className:ke("w-full justify-start px-2 py-2.5 h-auto min-h-[48px] font-normal text-left hover:bg-accent/50 transition-colors duration-200",b&&"bg-accent text-accent-foreground"),onClick:()=>h(r,t.name),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full pr-14",children:[e.jsx(ft,{provider:r.__provider,className:"w-3 h-3 mt-1 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground leading-5",children:x.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Ir,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:tn(x.sessionTime,a,f)}),x.messageCount>0&&e.jsx(bt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto group-hover:opacity-0 transition-opacity",children:x.messageCount}),e.jsx("span",{className:"ml-1 opacity-70 group-hover:opacity-0 transition-opacity",children:e.jsx(ft,{provider:r.__provider,className:"w-3 h-3"})})]})]})]})}),!x.isCursorSession&&e.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-all duration-200 bg-accent/80 backdrop-blur-sm rounded-md px-1 py-0.5",children:n===r.id&&!x.isCodexSession?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:o,onChange:k=>i(k.target.value),onKeyDown:k=>{k.stopPropagation(),k.key==="Enter"?j():k.key==="Escape"&&u()},onClick:k=>k.stopPropagation(),className:"w-32 px-2 py-1 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"w-6 h-6 bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),j()},title:f("tooltips.save"),children:e.jsx(Lt,{className:"w-3 h-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),u()},title:f("tooltips.cancel"),children:e.jsx(Ve,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})})]}):e.jsxs(e.Fragment,{children:[!x.isCodexSession&&e.jsx("button",{className:"w-7 h-7 bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),c(r.id,r.summary||f("projects.newSession"))},title:f("tooltips.editSessionName"),children:e.jsx(yi,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-7 h-7 bg-red-50 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),y()},title:f("tooltips.deleteSession"),children:e.jsx(yt,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]})}function Ac(){return e.jsx(e.Fragment,{children:Array.from({length:3}).map((t,r)=>e.jsx("div",{className:"p-2 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-3 h-3 bg-muted rounded-full animate-pulse mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 bg-muted rounded animate-pulse",style:{width:`${60+r*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},r))})}function Ic({project:t,isExpanded:r,sessions:s,selectedSession:a,initialSessionsLoaded:n,isLoadingSessions:o,currentTime:i,editingSession:c,editingSessionName:u,onEditingSessionNameChange:d,onStartEditingSession:m,onCancelEditingSession:h,onSaveEditingSession:p,onProjectSelect:g,onSessionSelect:f,onDeleteSession:x,onLoadMoreSessions:b,onNewSession:N,touchHandlerFactory:j,t:y}){var D;if(!r)return null;const k=s.length>0,I=((D=t.sessionMeta)==null?void 0:D.hasMore)===!0;return e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[n?!k&&!o?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:y("sessions.noSessions")})}):s.map(C=>e.jsx(Tc,{project:t,session:C,selectedSession:a,currentTime:i,editingSession:c,editingSessionName:u,onEditingSessionNameChange:d,onStartEditingSession:m,onCancelEditingSession:h,onSaveEditingSession:p,onProjectSelect:g,onSessionSelect:f,onDeleteSession:x,touchHandlerFactory:j,t:y},C.id)):e.jsx(Ac,{}),k&&I&&e.jsx(he,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>b(t),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),y("sessions.loading")]}):e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"w-3 h-3"}),y("sessions.showMore")]})}),e.jsx("div",{className:"md:hidden px-3 pb-2",children:e.jsxs("button",{className:"w-full h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-md flex items-center justify-center gap-2 font-medium text-xs active:scale-[0.98] transition-all duration-150",onClick:()=>{g(t),N(t)},children:[e.jsx(at,{className:"w-3 h-3"}),y("sessions.newSession")]})}),e.jsxs(he,{variant:"default",size:"sm",className:"hidden md:flex w-full justify-start gap-2 mt-1 h-8 text-xs font-medium bg-primary hover:bg-primary/90 text-primary-foreground transition-colors",onClick:()=>N(t),children:[e.jsx(at,{className:"w-3 h-3"}),y("sessions.newSession")]})]})}const Mc=(t,r)=>{const s=t.length;return r&&s>=5?`${s}+`:`${s}`};function Dc({project:t,selectedProject:r,selectedSession:s,isExpanded:a,isDeleting:n,isStarred:o,editingProject:i,editingName:c,sessions:u,initialSessionsLoaded:d,isLoadingSessions:m,currentTime:h,editingSession:p,editingSessionName:g,tasksEnabled:f,mcpServerStatus:x,onEditingNameChange:b,onToggleProject:N,onProjectSelect:j,onToggleStarProject:y,onStartEditingProject:k,onCancelEditingProject:I,onSaveProjectName:D,onDeleteProject:C,onSessionSelect:v,onDeleteSession:E,onLoadMoreSessions:T,onNewSession:W,onEditingSessionNameChange:S,onStartEditingSession:O,onCancelEditingSession:H,onSaveEditingSession:R,onOpenProjectSettings:A,touchHandlerFactory:z,t:J}){var U;const re=(r==null?void 0:r.name)===t.name,G=i===t.name,ie=((U=t.sessionMeta)==null?void 0:U.hasMore)===!0,$=Mc(u,ie),Z=`${$} session${u.length===1?"":"s"}`,te=Al(t,x),Q=()=>N(t.name),_=()=>y(t.name),F=()=>{D(t.name)},q=()=>{(r==null?void 0:r.name)!==t.name&&j(t),Q()};return e.jsxs("div",{className:ke("md:space-y-1",n&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"group md:group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:ke("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",re&&"bg-primary/5 border-primary/20",o&&!re&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:Q,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:ke("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",a?"bg-primary/10":"bg-muted"),children:a?e.jsx(er,{className:"w-4 h-4 text-primary"}):e.jsx(mr,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:G?e.jsx("input",{type:"text",value:c,onChange:B=>b(B.target.value),className:"w-full px-3 py-2 text-sm border-2 border-primary/40 focus:border-primary rounded-lg bg-background text-foreground shadow-sm focus:shadow-md transition-all duration-200 focus:outline-none",placeholder:J("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:B=>B.stopPropagation(),onKeyDown:B=>{B.key==="Enter"&&F(),B.key==="Escape"&&I()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between min-w-0 flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:t.displayName}),f&&e.jsx(Sc,{status:te,size:"xs",className:"hidden md:inline-flex flex-shrink-0 ml-2"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Z})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:G?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-green-500 dark:bg-green-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:B=>{B.stopPropagation(),F()},children:e.jsx(Lt,{className:"w-4 h-4 text-white"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500 dark:bg-gray-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:B=>{B.stopPropagation(),I()},children:e.jsx(Ve,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:ke("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",o?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:B=>{B.stopPropagation(),_()},title:J(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(Fa,{className:ke("w-4 h-4 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500/10 dark:bg-gray-900/30 flex items-center justify-center active:scale-90 border border-gray-200 dark:border-gray-800",onClick:B=>{B.stopPropagation(),A(t)},title:J("tooltips.projectSettings",{defaultValue:"Project settings"}),children:e.jsx(Dt,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-red-500/10 dark:bg-red-900/30 flex items-center justify-center active:scale-90 border border-red-200 dark:border-red-800",onClick:B=>{B.stopPropagation(),C(t)},children:e.jsx(yt,{className:"w-4 h-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center active:scale-90 border border-primary/20 dark:border-primary/30",onClick:B=>{B.stopPropagation(),k(t)},children:e.jsx(Mr,{className:"w-4 h-4 text-primary"})}),e.jsx("div",{className:"w-6 h-6 rounded-md bg-muted/30 flex items-center justify-center",children:a?e.jsx(Pt,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(rr,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(he,{variant:"ghost",className:ke("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",re&&"bg-accent text-accent-foreground",o&&!re&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:q,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a?e.jsx(er,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(mr,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:G?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:c,onChange:B=>b(B.target.value),className:"w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:ring-2 focus:ring-primary/20",placeholder:J("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:B=>{B.key==="Enter"&&F(),B.key==="Escape"&&I()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:t.fullPath,children:t.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:t.displayName,children:t.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[$,t.fullPath!==t.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:t.fullPath,children:[" - ",t.fullPath.length>25?`...${t.fullPath.slice(-22)}`:t.fullPath]})]})]})})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:G?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-900/20 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:B=>{B.stopPropagation(),F()},children:e.jsx(Lt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:B=>{B.stopPropagation(),I()},children:e.jsx(Ve,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ke("w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100",o?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:B=>{B.stopPropagation(),_()},title:J(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(Fa,{className:ke("w-3 h-3 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:B=>{B.stopPropagation(),A(t)},title:J("tooltips.projectSettings",{defaultValue:"Project settings"}),children:e.jsx(Dt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:B=>{B.stopPropagation(),k(t)},title:J("tooltips.renameProject"),children:e.jsx(Mr,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:B=>{B.stopPropagation(),C(t)},title:J("tooltips.deleteProject"),children:e.jsx(yt,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),a?e.jsx(Pt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(rr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),e.jsx(Ic,{project:t,isExpanded:a,sessions:u,selectedSession:s,initialSessionsLoaded:d,isLoadingSessions:m,currentTime:h,editingSession:p,editingSessionName:g,onEditingSessionNameChange:S,onStartEditingSession:O,onCancelEditingSession:H,onSaveEditingSession:R,onProjectSelect:j,onSessionSelect:v,onDeleteSession:E,onLoadMoreSessions:T,onNewSession:W,touchHandlerFactory:z,t:J})]})}function Lc({isLoading:t,loadingProgress:r,projectsCount:s,filteredProjectsCount:a,t:n}){const{isRelayConnected:o}=ps();return t?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.loadingProjects")}),r&&r.total>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full transition-all duration-300 ease-out",style:{width:`${r.current/r.total*100}%`}})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.current,"/",r.total," ",n("projects.projects")]}),r.currentProject&&e.jsx("p",{className:"text-xs text-muted-foreground/70 truncate max-w-[200px] mx-auto",title:r.currentProject,children:r.currentProject.split("-").slice(-2).join("/")})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.fetchingProjects")})]}):s===0?o?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(mr,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.runClaudeCli")})]}):e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(Zn,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"No machine connected"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your machine to see projects"})]}):a===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(Ar,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noMatchingProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.tryDifferentSearch")})]}):null}function Pc({projects:t,filteredProjects:r,selectedProject:s,selectedSession:a,isLoading:n,loadingProgress:o,expandedProjects:i,editingProject:c,editingName:u,loadingSessions:d,initialSessionsLoaded:m,currentTime:h,editingSession:p,editingSessionName:g,deletingProjects:f,tasksEnabled:x,mcpServerStatus:b,getProjectSessions:N,isProjectStarred:j,onEditingNameChange:y,onToggleProject:k,onProjectSelect:I,onToggleStarProject:D,onStartEditingProject:C,onCancelEditingProject:v,onSaveProjectName:E,onDeleteProject:T,onSessionSelect:W,onDeleteSession:S,onLoadMoreSessions:O,onNewSession:H,onEditingSessionNameChange:R,onStartEditingSession:A,onCancelEditingSession:z,onSaveEditingSession:J,onOpenProjectSettings:re,touchHandlerFactory:G,t:ie}){const $=e.jsx(Lc,{isLoading:n,loadingProgress:o,projectsCount:t.length,filteredProjectsCount:r.length,t:ie}),Z=!n&&t.length>0&&r.length>0;return e.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:Z?r.map(te=>e.jsx(Dc,{project:te,selectedProject:s,selectedSession:a,isExpanded:i.has(te.name),isDeleting:f.has(te.name),isStarred:j(te.name),editingProject:c,editingName:u,sessions:N(te),initialSessionsLoaded:m.has(te.name),isLoadingSessions:!!d[te.name],currentTime:h,editingSession:p,editingSessionName:g,tasksEnabled:x,mcpServerStatus:b,onEditingNameChange:y,onToggleProject:k,onProjectSelect:I,onToggleStarProject:D,onStartEditingProject:C,onCancelEditingProject:v,onSaveProjectName:E,onDeleteProject:T,onSessionSelect:W,onDeleteSession:S,onLoadMoreSessions:O,onNewSession:H,onEditingSessionNameChange:R,onStartEditingSession:A,onCancelEditingSession:z,onSaveEditingSession:J,onOpenProjectSettings:re,touchHandlerFactory:G,t:ie},te.name)):$})}function $c({isPWA:t,isMobile:r,isLoading:s,projects:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,updateAvailable:h,releaseInfo:p,latestVersion:g,onShowVersionModal:f,onShowSettings:x,projectListProps:b,t:N}){return e.jsxs("div",{className:"h-full flex flex-col bg-background/80 backdrop-blur-sm md:select-none md:w-72",style:{},children:[e.jsx(Cc,{isPWA:t,isMobile:r,isLoading:s,projectsCount:a.length,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:u,onCreateProject:d,onCollapseSidebar:m,t:N}),e.jsx($o,{className:"flex-1 px-1.5 py-1.5 md:py-2 overflow-y-auto overscroll-contain",children:e.jsx(Pc,{...b})}),e.jsx(jc,{updateAvailable:h,releaseInfo:p,latestVersion:g,onShowVersionModal:f,onShowSettings:x,t:N})]})}const _c=({onClose:t,onProjectCreated:r})=>{var _e;const{t:s}=We(),[a,n]=l.useState(1),[o,i]=l.useState("existing"),[c,u]=l.useState(""),[d,m]=l.useState(""),[h,p]=l.useState(""),[g,f]=l.useState("stored"),[x,b]=l.useState(""),[N,j]=l.useState(!1),[y,k]=l.useState(null),[I,D]=l.useState([]),[C,v]=l.useState(!1),[E,T]=l.useState([]),[W,S]=l.useState(!1),[O,H]=l.useState(!1),[R,A]=l.useState("~"),[z,J]=l.useState([]),[re,G]=l.useState(!1),[ie,$]=l.useState(!1),[Z,te]=l.useState(!1),[Q,_]=l.useState(""),[F,q]=l.useState(!1),[U,B]=l.useState(""),[ee,V]=l.useState([]);l.useEffect(()=>{a===2&&o==="new"&&d&&w()},[a,o,d]),l.useEffect(()=>{c.length>2?M(c):(T([]),S(!1))},[c]);const w=async()=>{try{v(!0);const pe=((await(await Be.get("/settings/credentials?type=github_token")).json()).credentials||[]).filter(ye=>ye.is_active);D(pe),pe.length>0&&!h&&p(pe[0].id.toString())}catch(L){console.error("Error loading GitHub tokens:",L)}finally{v(!1)}},M=async L=>{try{const K=L.lastIndexOf("/"),pe=K>0?L.substring(0,K):"~",Ie=await(await Be.browseFilesystem(pe)).json();if(Ie.suggestions){const Fe=Ie.suggestions.filter(Se=>Se.path.toLowerCase().startsWith(L.toLowerCase())&&Se.path.toLowerCase()!==L.toLowerCase());T(Fe.slice(0,5)),S(Fe.length>0)}}catch(K){console.error("Error loading path suggestions:",K)}},Y=()=>{if(k(null),a===1){if(!o){k(s("projectWizard.errors.selectType"));return}n(2)}else if(a===2){if(!c.trim()){k(s("projectWizard.errors.providePath"));return}n(3)}},se=()=>{k(null),n(a-1)},de=async()=>{j(!0),k(null),B("");try{if(o==="new"&&d){const ye=new URLSearchParams({path:c.trim(),githubUrl:d.trim()});g==="stored"&&h?ye.append("githubTokenId",h):g==="new"&&x&&ye.append("newGithubToken",x.trim());const Ie=`/api/projects/clone-progress?${ye}`;await new Promise((Fe,Se)=>{const Oe=new EventSource(Ie);Oe.onmessage=ne=>{try{const fe=JSON.parse(ne.data);fe.type==="progress"?B(fe.message):fe.type==="complete"?(Oe.close(),r&&r(fe.project),t(),Fe()):fe.type==="error"&&(Oe.close(),Se(new Error(fe.message)))}catch(fe){console.error("Error parsing SSE event:",fe)}},Oe.onerror=()=>{Oe.close(),Se(new Error("Connection lost during clone"))}});return}const L={workspaceType:o,path:c.trim()},K=await Be.createWorkspace(L),pe=await K.json();if(!K.ok)throw new Error(pe.details||pe.error||s("projectWizard.errors.failedToCreate"));r&&r(pe.project),t()}catch(L){console.error("Error creating workspace:",L),k(L.message||s("projectWizard.errors.failedToCreate"))}finally{j(!1)}},je=L=>{u(L.path),S(!1)},ge=async()=>{H(!0),await Re("~")},Re=async L=>{try{G(!0);const pe=await(await Be.browseFilesystem(L)).json();A(pe.path||L),J(pe.suggestions||[]),pe.drives&&Array.isArray(pe.drives)&&V(pe.drives)}catch(K){console.error("Error loading folders:",K)}finally{G(!1)}},Ne=(L,K=!1)=>{u(L),H(!1),K&&n(3)},De=async L=>{await Re(L)},Ue=async()=>{if(Q.trim()){q(!0),k(null);try{const L=R.includes("\\")?"\\":"/",K=`${R}${L}${Q.trim()}`,pe=await Be.createFolder(K),ye=await pe.json();if(!pe.ok)throw new Error(ye.error||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"));_(""),te(!1),await Re(ye.path||K)}catch(L){console.error("Error creating folder:",L),k(L.message||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{q(!1)}}};return e.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-2xl border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Zr,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:s("projectWizard.title")})]}),e.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:N,children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"px-6 pt-4 pb-2",children:e.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(L=>e.jsxs(it.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${L<a?"bg-green-500 text-white":L===a?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:L<a?e.jsx(Lt,{className:"w-4 h-4"}):L}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:s(L===1?"projectWizard.steps.type":L===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),L<3&&e.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${L<a?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},L))})}),e.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[y&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(xs,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:y})})]}),a===1&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:s("projectWizard.step1.question")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("button",{onClick:()=>i("existing"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="existing"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(Zr,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.existing.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.existing.description")})]})]})}),e.jsx("button",{onClick:()=>i("new"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="new"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(br,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.new.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.new.description")})]})]})})]})]})}),a===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s(o==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),e.jsxs("div",{className:"relative flex gap-2",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ze,{type:"text",value:c,onChange:L=>u(L.target.value),placeholder:o==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),W&&E.length>0&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:E.map((L,K)=>e.jsxs("button",{onClick:()=>je(L),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:L.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:L.path})]},K))})]}),e.jsx(he,{type:"button",variant:"outline",onClick:ge,className:"px-3",title:"Browse folders",children:e.jsx(er,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s(o==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]}),o==="new"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.githubUrl")}),e.jsx(Ze,{type:"text",value:d,onChange:L=>m(L.target.value),placeholder:"https://github.com/username/repository",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.githubHelp")})]}),d&&!d.startsWith("git@")&&!d.startsWith("ssh://")&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(ga,{className:"w-5 h-5 text-gray-600 dark:text-gray-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-medium text-gray-900 dark:text-white mb-1",children:s("projectWizard.step2.githubAuth")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step2.githubAuthHelp")})]})]}),C?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(Sr,{className:"w-4 h-4 animate-spin"}),s("projectWizard.step2.loadingTokens")]}):I.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[e.jsx("button",{onClick:()=>f("stored"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="stored"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.storedToken")}),e.jsx("button",{onClick:()=>f("new"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="new"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.newToken")}),e.jsx("button",{onClick:()=>{f("none"),p(""),b("")},className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="none"?"bg-green-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.nonePublic")})]}),g==="stored"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.selectToken")}),e.jsxs("select",{value:h,onChange:L=>p(L.target.value),className:"w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:s("projectWizard.step2.selectTokenPlaceholder")}),I.map(L=>e.jsx("option",{value:L.id,children:L.credential_name},L.id))]})]}):g==="new"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.newToken")}),e.jsx(Ze,{type:"password",value:x,onChange:L=>b(L.target.value),placeholder:"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.tokenHelp")})]}):null]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 border border-blue-200 dark:border-blue-800",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s("projectWizard.step2.publicRepoInfo")})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.optionalTokenPublic")}),e.jsx(Ze,{type:"password",value:x,onChange:L=>b(L.target.value),placeholder:s("projectWizard.step2.tokenPublicPlaceholder"),className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.noTokensHelp")})]})]})]})]})]}),a===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:s("projectWizard.step3.reviewConfig")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.workspaceType")}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:s(o==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.path")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]}),o==="new"&&d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.cloneFrom")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:d})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.authentication")}),e.jsx("span",{className:"text-xs text-gray-900 dark:text-white",children:g==="stored"&&h?`${s("projectWizard.step3.usingStoredToken")} ${((_e=I.find(L=>L.id.toString()===h))==null?void 0:_e.credential_name)||"Unknown"}`:g==="new"&&x?s("projectWizard.step3.usingProvidedToken"):d.startsWith("git@")||d.startsWith("ssh://")?s("projectWizard.step3.sshKey","SSH Key"):s("projectWizard.step3.noAuthentication")})]})]})]})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:N&&U?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:s("projectWizard.step3.cloningRepository","Cloning repository...")}),e.jsx("code",{className:"block text-xs font-mono text-blue-700 dark:text-blue-300 whitespace-pre-wrap break-all",children:U})]}):e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s(o==="existing"?"projectWizard.step3.existingInfo":d?"projectWizard.step3.newWithClone":"projectWizard.step3.newEmpty")})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(he,{variant:"outline",onClick:a===1?t:se,disabled:N,children:a===1?s("projectWizard.buttons.cancel"):e.jsxs(e.Fragment,{children:[e.jsx(ha,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.back")]})}),e.jsx(he,{onClick:a===3?de:Y,disabled:N||a===1&&!o,children:N?e.jsxs(e.Fragment,{children:[e.jsx(Sr,{className:"w-4 h-4 mr-2 animate-spin"}),d?s("projectWizard.buttons.cloning","Cloning..."):s("projectWizard.buttons.creating")]}):a===3?e.jsxs(e.Fragment,{children:[e.jsx(Lt,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.createProject")]}):e.jsxs(e.Fragment,{children:[s("projectWizard.buttons.next"),e.jsx(rr,{className:"w-4 h-4 ml-1"})]})})]})]}),O&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] border border-gray-200 dark:border-gray-700 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(er,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>$(!ie),className:`p-2 rounded-md transition-colors ${ie?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:ie?"Hide hidden folders":"Show hidden folders",children:ie?e.jsx(sr,{className:"w-5 h-5"}):e.jsx(eo,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>te(!Z),className:`p-2 rounded-md transition-colors ${Z?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:"Create new folder",children:e.jsx(at,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>H(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Ve,{className:"w-5 h-5"})})]})]}),Z&&e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-blue-50 dark:bg-blue-900/20",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{type:"text",value:Q,onChange:L=>_(L.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:L=>{L.key==="Enter"&&Ue(),L.key==="Escape"&&(te(!1),_(""))},autoFocus:!0}),e.jsx(he,{size:"sm",onClick:Ue,disabled:!Q.trim()||F,children:F?e.jsx(Sr,{className:"w-4 h-4 animate-spin"}):"Create"}),e.jsx(he,{size:"sm",variant:"ghost",onClick:()=>{te(!1),_("")},children:"Cancel"})]})}),ee.length>0&&e.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 mr-1",children:"Drives:"}),ee.map(L=>{const K=typeof L=="string"?L:L.name||L.path,pe=typeof L=="string"?`${L}\\`:L.path||`${L.name}\\`;return e.jsx("button",{onClick:()=>De(pe),className:`px-3 py-1.5 text-sm font-mono font-medium rounded-md border transition-colors ${R.startsWith(K)?"bg-blue-100 dark:bg-blue-900/50 border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300":"bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:K},K)})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:re?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Sr,{className:"w-6 h-6 animate-spin text-gray-400"})}):e.jsxs("div",{className:"space-y-1",children:[R!=="~"&&R!=="/"&&!/^[A-Za-z]:\\?$/.test(R)&&e.jsxs("button",{onClick:()=>{const L=Math.max(R.lastIndexOf("/"),R.lastIndexOf("\\"));let K;L<=0?K="/":L===2&&/^[A-Za-z]:/.test(R)?K=R.substring(0,3):K=R.substring(0,L),De(K)},className:"w-full px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(er,{className:"w-5 h-5 text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),z.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):z.filter(L=>ie||!L.name.startsWith(".")).sort((L,K)=>L.name.toLowerCase().localeCompare(K.name.toLowerCase())).map((L,K)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>De(L.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(Zr,{className:"w-5 h-5 text-blue-500"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:L.name})]}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>Ne(L.path,o==="existing"),className:"text-xs px-3",children:"Select"})]},K))]})}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),e.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:R})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[e.jsx(he,{variant:"outline",onClick:()=>{H(!1),te(!1),_("")},children:"Cancel"}),e.jsx(he,{variant:"outline",onClick:()=>Ne(R,o==="existing"),children:"Use this folder"})]})]})]})})]})};function Fc({isOpen:t,onConfirm:r,onCancel:s,title:a,message:n,detail:o,variant:i="danger",confirmLabel:c="Confirm",cancelLabel:u="Cancel"}){const d=l.useRef(null);l.useEffect(()=>{var p;t&&((p=d.current)==null||p.focus())},[t]);const m=l.useCallback(p=>{p.key==="Escape"&&s()},[s]);if(!t)return null;const h=i==="danger";return Cr.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onKeyDown:m,children:e.jsxs("div",{className:"bg-card border border-border/40 rounded-2xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`w-11 h-11 rounded-xl flex items-center justify-center flex-shrink-0 ${h?"bg-red-500/10":"bg-amber-500/10"}`,children:h?e.jsx($t,{className:"w-5 h-5 text-red-500"}):e.jsx(vt,{className:"w-5 h-5 text-amber-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground mb-1.5",children:a}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:n}),o&&e.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-2 leading-relaxed",children:o})]})]})}),e.jsxs("div",{className:"flex gap-2 px-5 py-4 border-t border-border/20",children:[e.jsx("button",{ref:d,onClick:s,className:"flex-1 px-4 py-2.5 text-xs font-medium text-muted-foreground bg-muted/30 hover:bg-muted/50 rounded-xl transition-colors",children:u}),e.jsx("button",{onClick:r,className:`flex-1 px-4 py-2.5 text-xs font-medium rounded-xl transition-opacity ${h?"bg-red-600 hover:bg-red-700 text-white":"bg-foreground hover:opacity-90 text-background"}`,children:c})]})]})}),document.body)}function Ea(){const[t,r]=l.useState(null),s=l.useCallback(i=>new Promise(c=>{r({...i,resolve:c})}),[]),a=l.useCallback(()=>{t==null||t.resolve(!0),r(null)},[t]),n=l.useCallback(()=>{t==null||t.resolve(!1),r(null)},[t]),o=t?{isOpen:!0,onConfirm:a,onCancel:n,title:t.title,message:t.message,detail:t.detail,variant:t.variant,confirmLabel:t.confirmLabel,cancelLabel:t.cancelLabel}:{isOpen:!1,onConfirm:()=>{},onCancel:()=>{},title:"",message:""};return{confirm:s,dialogProps:o,ConfirmDialog:Fc}}const zc="3.0.2";function Rc(){const{t}=We("settings"),{confirm:r,dialogProps:s,ConfirmDialog:a}=Ea(),[n,o]=l.useState([]),[i,c]=l.useState([]),[u,d]=l.useState(!0),[m,h]=l.useState(!1),[p,g]=l.useState(!1),[f,x]=l.useState(""),[b,N]=l.useState(""),[j,y]=l.useState(""),[k,I]=l.useState(""),[D,C]=l.useState({}),[v,E]=l.useState(null),[T,W]=l.useState(null),{updateAvailable:S,latestVersion:O,releaseInfo:H}=fo("AnitChaudhry","UpfynAI-Code");l.useEffect(()=>{R()},[]);const R=async()=>{try{d(!0);const te=await(await Me("/api/settings/api-keys")).json();o(te.apiKeys||[]);const _=await(await Me("/api/settings/credentials?type=github_token")).json();c(_.credentials||[])}catch(Z){console.error("Error fetching settings:",Z)}finally{d(!1)}},A=async()=>{if(f.trim())try{const te=await(await Me("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:f})})).json();te.success&&(W(te.apiKey),x(""),h(!1),R())}catch(Z){console.error("Error creating API key:",Z)}},z=async Z=>{if(await r({title:t("apiKeys.deleteTitle","Delete API Key"),message:t("apiKeys.confirmDelete"),confirmLabel:t("apiKeys.deleteButton","Delete"),cancelLabel:t("common:cancel","Cancel")}))try{await Me(`/api/settings/api-keys/${Z}`,{method:"DELETE"}),R()}catch(Q){console.error("Error deleting API key:",Q)}},J=async(Z,te)=>{try{await Me(`/api/settings/api-keys/${Z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!te})}),R()}catch(Q){console.error("Error toggling API key:",Q)}},re=async()=>{if(!(!b.trim()||!j.trim()))try{(await(await Me("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:b,credentialType:"github_token",credentialValue:j,description:k})})).json()).success&&(N(""),y(""),I(""),g(!1),R())}catch(Z){console.error("Error creating GitHub credential:",Z)}},G=async Z=>{if(await r({title:t("apiKeys.github.deleteTitle","Delete GitHub Credential"),message:t("apiKeys.github.confirmDelete"),confirmLabel:t("apiKeys.deleteButton","Delete"),cancelLabel:t("common:cancel","Cancel")}))try{await Me(`/api/settings/credentials/${Z}`,{method:"DELETE"}),R()}catch(Q){console.error("Error deleting GitHub credential:",Q)}},ie=async(Z,te)=>{try{await Me(`/api/settings/credentials/${Z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!te})}),R()}catch(Q){console.error("Error toggling GitHub credential:",Q)}},$=(Z,te)=>{navigator.clipboard.writeText(Z),E(te),setTimeout(()=>E(null),2e3)};return u?e.jsx("div",{className:"text-muted-foreground",children:t("apiKeys.loading")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-8",children:[T&&e.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[e.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:t("apiKeys.newKey.alertTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:t("apiKeys.newKey.alertMessage")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:T.apiKey}),e.jsx(he,{size:"sm",variant:"outline",onClick:()=>$(T.apiKey,"new"),children:v==="new"?e.jsx(Lt,{className:"h-4 w-4"}):e.jsx(fa,{className:"h-4 w-4"})})]}),e.jsx(he,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>W(null),children:t("apiKeys.newKey.iveSavedIt")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ga,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.title")})]}),e.jsxs(he,{size:"sm",onClick:()=>h(!m),children:[e.jsx(at,{className:"h-4 w-4 mr-1"}),t("apiKeys.newButton")]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:t("apiKeys.description")}),e.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[t("apiKeys.apiDocsLink"),e.jsx(za,{className:"h-3 w-3"})]})]}),m&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[e.jsx(Ze,{placeholder:t("apiKeys.form.placeholder"),value:f,onChange:Z=>x(Z.target.value),className:"mb-2"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(he,{onClick:A,children:t("apiKeys.form.createButton")}),e.jsx(he,{variant:"outline",onClick:()=>h(!1),children:t("apiKeys.form.cancelButton")})]})]}),e.jsx("div",{className:"space-y-2",children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.empty")}):n.map(Z=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:Z.key_name}),e.jsx("code",{className:"text-xs text-muted-foreground",children:Z.api_key}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.list.created")," ",new Date(Z.created_at).toLocaleDateString(),Z.last_used&&` • ${t("apiKeys.list.lastUsed")} ${new Date(Z.last_used).toLocaleDateString()}`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{size:"sm",variant:Z.is_active?"outline":"secondary",onClick:()=>J(Z.id,Z.is_active),children:Z.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(he,{size:"sm",variant:"ghost",onClick:()=>z(Z.id),children:e.jsx(yt,{className:"h-4 w-4"})})]})]},Z.id))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vi,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.github.title")})]}),e.jsxs(he,{size:"sm",onClick:()=>g(!p),children:[e.jsx(at,{className:"h-4 w-4 mr-1"}),t("apiKeys.github.addButton")]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("apiKeys.github.descriptionAlt")}),p&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[e.jsx(Ze,{placeholder:t("apiKeys.github.form.namePlaceholder"),value:b,onChange:Z=>N(Z.target.value)}),e.jsxs("div",{className:"relative",children:[e.jsx(Ze,{type:D.new?"text":"password",placeholder:t("apiKeys.github.form.tokenPlaceholder"),value:j,onChange:Z=>y(Z.target.value),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>C({...D,new:!D.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:D.new?e.jsx(eo,{className:"h-4 w-4"}):e.jsx(sr,{className:"h-4 w-4"})})]}),e.jsx(Ze,{placeholder:t("apiKeys.github.form.descriptionPlaceholder"),value:k,onChange:Z=>I(Z.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(he,{onClick:re,children:t("apiKeys.github.form.addButton")}),e.jsx(he,{variant:"outline",onClick:()=>{g(!1),N(""),y(""),I("")},children:t("apiKeys.github.form.cancelButton")})]}),e.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:t("apiKeys.github.form.howToCreate")})]}),e.jsx("div",{className:"space-y-2",children:i.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.github.empty")}):i.map(Z=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:Z.credential_name}),Z.description&&e.jsx("div",{className:"text-xs text-muted-foreground",children:Z.description}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.github.added")," ",new Date(Z.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{size:"sm",variant:Z.is_active?"outline":"secondary",onClick:()=>ie(Z.id,Z.is_active),children:Z.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(he,{size:"sm",variant:"ghost",onClick:()=>G(Z.id),children:e.jsx(yt,{className:"h-4 w-4"})})]})]},Z.id))})]}),e.jsx("div",{className:"pt-6 border-t border-border/50",children:e.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[e.jsxs("a",{href:(H==null?void 0:H.htmlUrl)||"https://github.com/AnitChaudhry/UpfynAI-Code/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",zc]}),S&&O&&e.jsxs("a",{href:(H==null?void 0:H.htmlUrl)||"https://github.com/AnitChaudhry/UpfynAI-Code/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[e.jsx("span",{className:"text-[10px]",children:t("apiKeys.version.updateAvailable",{version:O})}),e.jsx(za,{className:"h-2.5 w-2.5"})]})]})})]}),e.jsx(a,{...s})]})}function Oc(){const{t}=We("settings"),[r,s]=l.useState(""),[a,n]=l.useState(""),[o,i]=l.useState(!1),[c,u]=l.useState(!1),[d,m]=l.useState(null);l.useEffect(()=>{h()},[]);const h=async()=>{try{i(!0);const g=await Me("/api/user/git-config");if(g.ok){const f=await g.json();s(f.gitName||""),n(f.gitEmail||"")}}catch(g){console.error("Error loading git config:",g)}finally{i(!1)}},p=async()=>{try{u(!0);const g=await Me("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:a})});if(g.ok)m("success"),setTimeout(()=>m(null),3e3);else{const f=await g.json();m("error"),console.error("Failed to save git config:",f.error)}}catch(g){console.error("Error saving git config:",g),m("error")}finally{u(!1)}};return e.jsx("div",{className:"space-y-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(br,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("git.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("git.description")}),e.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:t("git.name.label")}),e.jsx(Ze,{id:"settings-git-name",type:"text",value:r,onChange:g=>s(g.target.value),placeholder:"John Doe",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.name.help")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:t("git.email.label")}),e.jsx(Ze,{id:"settings-git-email",type:"email",value:a,onChange:g=>n(g.target.value),placeholder:"john@example.com",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.email.help")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{onClick:p,disabled:c||!r||!a,children:t(c?"git.actions.saving":"git.actions.save")}),d==="success"&&e.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[e.jsx(Lt,{className:"w-4 h-4"}),t("git.status.success")]})]})]})]})})}function Bc(){const{t}=We("settings"),{tasksEnabled:r,setTasksEnabled:s,isTaskMasterInstalled:a,isCheckingInstallation:n}=Lr();return e.jsx("div",{className:"space-y-8",children:n?e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("tasks.checking")})]})}):e.jsxs(e.Fragment,{children:[!a&&e.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-orange-100 dark:bg-orange-900 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:t("tasks.notInstalled.title")}),e.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[e.jsx("p",{children:t("tasks.notInstalled.description")}),e.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:e.jsx("code",{children:t("tasks.notInstalled.installCommand")})}),e.jsx("div",{children:e.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),t("tasks.notInstalled.viewOnGitHub"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:t("tasks.notInstalled.afterInstallation")}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[e.jsx("li",{children:t("tasks.notInstalled.steps.restart")}),e.jsx("li",{children:t("tasks.notInstalled.steps.autoAvailable")}),e.jsx("li",{children:t("tasks.notInstalled.steps.initCommand")})]})]})]})]})]})}),a&&e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:t("tasks.settings.enableLabel")}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:t("tasks.settings.enableDescription")})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:o=>s(o.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]})})})]})})}const Wc={claude:{name:"Claude",color:"blue"},cursor:{name:"Cursor",color:"purple"},codex:{name:"Codex",color:"gray"}},Uc={blue:{border:"border-l-blue-500 md:border-l-blue-500",borderBottom:"border-b-blue-500",bg:"bg-blue-50 dark:bg-blue-900/20",dot:"bg-blue-500"},purple:{border:"border-l-purple-500 md:border-l-purple-500",borderBottom:"border-b-purple-500",bg:"bg-purple-50 dark:bg-purple-900/20",dot:"bg-purple-500"},gray:{border:"border-l-gray-700 dark:border-l-gray-300",borderBottom:"border-b-gray-700 dark:border-b-gray-300",bg:"bg-gray-100 dark:bg-gray-800/50",dot:"bg-gray-700 dark:bg-gray-300"}};function dr({agentId:t,authStatus:r,isSelected:s,onClick:a,isMobile:n=!1}){const{t:o}=We("settings"),i=Wc[t],c=Uc[i.color];return n?e.jsx("button",{onClick:a,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${s?`${c.borderBottom} ${c.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx(ft,{provider:t,className:"w-5 h-5"}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:i.name}),(r==null?void 0:r.authenticated)&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`})]})}):e.jsxs("button",{onClick:a,className:`w-full text-left p-3 border-l-4 transition-colors ${s?`${c.border} ${c.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ft,{provider:t,className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:i.name})]}),e.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:r!=null&&r.loading?e.jsx("span",{className:"text-gray-400",children:o("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`}),e.jsx("span",{className:"truncate max-w-[120px]",title:r.email,children:r.email||o("agents.authStatus.connected")})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),e.jsx("span",{children:o("agents.authStatus.notConnected")})]})})]})}const Hc={claude:{name:"Claude",description:"Anthropic Claude AI assistant",bgClass:"bg-blue-50 dark:bg-blue-900/20",borderClass:"border-blue-200 dark:border-blue-800",textClass:"text-blue-900 dark:text-blue-100",subtextClass:"text-blue-700 dark:text-blue-300",buttonClass:"bg-blue-600 hover:bg-blue-700"},cursor:{name:"Cursor",description:"Cursor AI-powered code editor",bgClass:"bg-purple-50 dark:bg-purple-900/20",borderClass:"border-purple-200 dark:border-purple-800",textClass:"text-purple-900 dark:text-purple-100",subtextClass:"text-purple-700 dark:text-purple-300",buttonClass:"bg-purple-600 hover:bg-purple-700"},codex:{name:"Codex",description:"OpenAI Codex AI assistant",bgClass:"bg-gray-100 dark:bg-gray-800/50",borderClass:"border-gray-300 dark:border-gray-600",textClass:"text-gray-900 dark:text-gray-100",subtextClass:"text-gray-700 dark:text-gray-300",buttonClass:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"}};function Gc({agent:t,authStatus:r,onLogin:s}){const{t:a}=We("settings"),n=Hc[t];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(ft,{provider:t,className:"w-6 h-6"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a(`agents.account.${t}.description`)})]})]}),e.jsx("div",{className:`${n.bgClass} border ${n.borderClass} rounded-lg p-4`,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:a("agents.connectionStatus")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&r.loading?a("agents.authStatus.checkingAuth"):r!=null&&r.authenticated?a("agents.authStatus.loggedInAs",{email:r.email||a("agents.authStatus.authenticatedUser")}):a("agents.authStatus.notConnected")})]}),e.jsx("div",{children:r!=null&&r.loading?e.jsx(bt,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:a("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsx(bt,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:a("agents.authStatus.connected")}):e.jsx(bt,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:a("agents.authStatus.disconnected")})})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:r!=null&&r.authenticated?a("agents.login.reAuthenticate"):a("agents.login.title")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&r.authenticated?a("agents.login.reAuthDescription"):a("agents.login.description",{agent:n.name})})]}),e.jsxs(he,{onClick:s,className:`${n.buttonClass} text-white`,size:"sm",children:[e.jsx(ki,{className:"w-4 h-4 mr-2"}),r!=null&&r.authenticated?a("agents.login.reLoginButton"):a("agents.login.button")]})]})}),(r==null?void 0:r.error)&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:a("agents.error",{error:r.error})})})]})})]})}const Vc=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],qc=["Shell(ls)","Shell(mkdir)","Shell(cd)","Shell(cat)","Shell(echo)","Shell(git status)","Shell(git diff)","Shell(git log)","Shell(npm install)","Shell(npm run)","Shell(python)","Shell(node)"];function Kc({skipPermissions:t,setSkipPermissions:r,allowedTools:s,setAllowedTools:a,disallowedTools:n,setDisallowedTools:o,newAllowedTool:i,setNewAllowedTool:c,newDisallowedTool:u,setNewDisallowedTool:d}){const{t:m}=We("settings"),h=x=>{x&&!s.includes(x)&&(a([...s,x]),c(""))},p=x=>{a(s.filter(b=>b!==x))},g=x=>{x&&!n.includes(x)&&(o([...n,x]),d(""))},f=x=>{o(n.filter(b=>b!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:m("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:m("permissions.skipPermissions.claudeDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ba,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.allowedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.allowedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:i,onChange:x=>c(x.target.value),placeholder:m("permissions.allowedTools.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),h(i))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>h(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:m("permissions.allowedTools.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Vc.map(x=>e.jsx(he,{variant:"outline",size:"sm",onClick:()=>h(x),disabled:s.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>p(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.allowedTools.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.blockedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.blockedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:u,onChange:x=>d(x.target.value),placeholder:m("permissions.blockedTools.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(u))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>g(u),disabled:!u,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>f(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.blockedTools.empty")})]})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:m("permissions.toolExamples.title")}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," ",m("permissions.toolExamples.bashGitLog")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," ",m("permissions.toolExamples.bashGitDiff")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," ",m("permissions.toolExamples.write")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," ",m("permissions.toolExamples.bashRm")]})]})]})]})}function Jc({skipPermissions:t,setSkipPermissions:r,allowedCommands:s,setAllowedCommands:a,disallowedCommands:n,setDisallowedCommands:o,newAllowedCommand:i,setNewAllowedCommand:c,newDisallowedCommand:u,setNewDisallowedCommand:d}){const{t:m}=We("settings"),h=x=>{x&&!s.includes(x)&&(a([...s,x]),c(""))},p=x=>{a(s.filter(b=>b!==x))},g=x=>{x&&!n.includes(x)&&(o([...n,x]),d(""))},f=x=>{o(n.filter(b=>b!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 text-purple-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-purple-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:m("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:m("permissions.skipPermissions.cursorDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ba,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.allowedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.allowedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:i,onChange:x=>c(x.target.value),placeholder:m("permissions.allowedCommands.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),h(i))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>h(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:m("permissions.allowedCommands.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:qc.map(x=>e.jsx(he,{variant:"outline",size:"sm",onClick:()=>h(x),disabled:s.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>p(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.allowedCommands.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.blockedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.blockedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:u,onChange:x=>d(x.target.value),placeholder:m("permissions.blockedCommands.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(u))},className:"flex-1 h-10"}),e.jsxs(he,{onClick:()=>g(u),disabled:!u,size:"sm",className:"h-10 px-4",children:[e.jsx(at,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(he,{variant:"ghost",size:"sm",onClick:()=>f(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Ve,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.blockedCommands.empty")})]})]}),e.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:m("permissions.shellExamples.title")}),e.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," ",m("permissions.shellExamples.ls")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," ",m("permissions.shellExamples.gitStatus")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," ",m("permissions.shellExamples.npmInstall")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," ",m("permissions.shellExamples.rmRf")]})]})]})]})}function Yc({permissionMode:t,setPermissionMode:r}){const{t:s}=We("settings");return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ba,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:s("permissions.codex.permissionMode")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("permissions.codex.description")}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="default"?"bg-gray-100 dark:bg-gray-800 border-gray-400 dark:border-gray-500":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("default"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="default",onChange:()=>r("default"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:s("permissions.codex.modes.default.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("permissions.codex.modes.default.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 border-green-400 dark:border-green-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("acceptEdits"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="acceptEdits",onChange:()=>r("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:s("permissions.codex.modes.acceptEdits.title")}),e.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:s("permissions.codex.modes.acceptEdits.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 border-orange-400 dark:border-orange-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("bypassPermissions"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="bypassPermissions",onChange:()=>r("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:[s("permissions.codex.modes.bypassPermissions.title"),e.jsx($t,{className:"w-4 h-4"})]}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:s("permissions.codex.modes.bypassPermissions.description")})]})]})}),e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:s("permissions.codex.technicalDetails")}),e.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg text-xs text-muted-foreground space-y-2",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.default.title"),":"]})," ",s("permissions.codex.technicalInfo.default")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.acceptEdits.title"),":"]})," ",s("permissions.codex.technicalInfo.acceptEdits")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.bypassPermissions.title"),":"]})," ",s("permissions.codex.technicalInfo.bypassPermissions")]}),e.jsx("p",{className:"text-xs opacity-75",children:s("permissions.codex.technicalInfo.overrideNote")})]})]})]})})}function $s({agent:t,...r}){return t==="claude"?e.jsx(Kc,{...r}):t==="cursor"?e.jsx(Jc,{...r}):t==="codex"?e.jsx(Yc,{...r}):null}const Qc=t=>{switch(t){case"stdio":return e.jsx(vt,{className:"w-4 h-4"});case"sse":return e.jsx(tr,{className:"w-4 h-4"});case"http":return e.jsx(Ks,{className:"w-4 h-4"});default:return e.jsx($r,{className:"w-4 h-4"})}};function Xc({servers:t,onAdd:r,onEdit:s,onDelete:a,onTest:n,onDiscoverTools:o,testResults:i,serverTools:c,toolsLoading:u}){const{t:d}=We("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($r,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d("mcpServers.description.claude")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(he,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),d("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(m=>{var h,p,g,f;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[Qc(m.type),e.jsx("span",{className:"font-medium text-foreground",children:m.name}),e.jsx(bt,{variant:"outline",className:"text-xs",children:m.type}),e.jsx(bt,{variant:"outline",className:"text-xs",children:m.scope==="local"?d("mcpServers.scope.local"):m.scope==="user"?d("mcpServers.scope.user"):m.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[m.type==="stdio"&&((h=m.config)==null?void 0:h.command)&&e.jsxs("div",{children:[d("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.command})]}),(m.type==="sse"||m.type==="http")&&((p=m.config)==null?void 0:p.url)&&e.jsxs("div",{children:[d("mcpServers.config.url"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.url})]}),((g=m.config)==null?void 0:g.args)&&m.config.args.length>0&&e.jsxs("div",{children:[d("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.args.join(" ")})]})]}),(i==null?void 0:i[m.id])&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${i[m.id].success?"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200":"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200"}`,children:e.jsx("div",{className:"font-medium",children:i[m.id].message})}),(c==null?void 0:c[m.id])&&((f=c[m.id].tools)==null?void 0:f.length)>0&&e.jsxs("div",{className:"mt-2 p-2 rounded text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200",children:[e.jsxs("div",{className:"font-medium",children:[d("mcpServers.tools.title")," ",d("mcpServers.tools.count",{count:c[m.id].tools.length})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[c[m.id].tools.slice(0,5).map((x,b)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:x.name},b)),c[m.id].tools.length>5&&e.jsx("span",{className:"text-xs opacity-75",children:d("mcpServers.tools.more",{count:c[m.id].tools.length-5})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(he,{onClick:()=>s(m),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:d("mcpServers.actions.edit"),children:e.jsx(Mr,{className:"w-4 h-4"})}),e.jsx(he,{onClick:()=>a(m.id,m.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:d("mcpServers.actions.delete"),children:e.jsx(yt,{className:"w-4 h-4"})})]})]})},m.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:d("mcpServers.empty")})]})]})}function Zc({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=We("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($r,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.cursor")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(he,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(vt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(bt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:((i=o.config)==null?void 0:i.command)&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(he,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(Mr,{className:"w-4 h-4"})}),e.jsx(he,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(yt,{className:"w-4 h-4"})})]})]})},o.name||o.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]})]})}function ed({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=We("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($r,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.codex")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(he,{onClick:r,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[e.jsx(at,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i,c,u;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(vt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(bt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[((i=o.config)==null?void 0:i.command)&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]}),((c=o.config)==null?void 0:c.args)&&o.config.args.length>0&&e.jsxs("div",{children:[n("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.args.join(" ")})]}),((u=o.config)==null?void 0:u.env)&&Object.keys(o.config.env).length>0&&e.jsxs("div",{children:[n("mcpServers.config.environment"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(o.config.env).map(([d,m])=>`${d}=${m}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(he,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(Mr,{className:"w-4 h-4"})}),e.jsx(he,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(yt,{className:"w-4 h-4"})})]})]})},o.name)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]}),e.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:n("mcpServers.help.title")}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:n("mcpServers.help.description")})]})]})}function _s({agent:t,...r}){return t==="claude"?e.jsx(Xc,{...r}):t==="cursor"?e.jsx(Zc,{...r}):t==="codex"?e.jsx(ed,{...r}):null}const td=[{name:"filesystem",description:"Read/write local files and directories",category:"Files & Code",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-filesystem","/path"]}},{name:"github",description:"GitHub repos, issues, and PRs",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-github"]}},{name:"postgres",description:"Query PostgreSQL databases",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-postgres"]}},{name:"brave-search",description:"Web search via Brave Search API",category:"AI & Search",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-brave-search"]}},{name:"memory",description:"Persistent memory store for AI agents",category:"AI & Search",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-memory"]}},{name:"puppeteer",description:"Browser automation and scraping",category:"DevOps",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-puppeteer"]}},{name:"sqlite",description:"Query SQLite databases",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-sqlite"]}},{name:"fetch",description:"HTTP fetch and web content retrieval",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-fetch"]}}],rd={"Files & Code":"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300","Data & APIs":"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300","AI & Search":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300",DevOps:"bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-300"};function sd(){const[t,r]=l.useState([]),[s,a]=l.useState(!0),[n,o]=l.useState(null),[i,c]=l.useState(""),u=l.useCallback(async()=>{a(!0);try{const g=await(await Me("/api/mcp/config/read")).json();g.success&&g.servers&&r(g.servers)}catch{}a(!1)},[]);l.useEffect(()=>{u();const p=window.location.origin;c(`${p}/mcp`)},[u]);const d=async p=>{o(p.name);try{(await Me("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:p.name,config:{command:p.installConfig.command,args:p.installConfig.args}})})).ok&&await u()}catch{}o(null)},m=p=>t.some(g=>g.name===p),h=p=>{navigator.clipboard.writeText(p)};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Installed Servers"}),e.jsx("button",{onClick:()=>void u(),className:"ml-auto text-sm text-muted-foreground hover:text-foreground transition-colors",title:"Refresh",children:e.jsx("svg",{className:`w-4 h-4 ${s?"animate-spin":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-6",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading servers..."]}):t.length===0?e.jsx("div",{className:"text-sm text-muted-foreground bg-muted/30 rounded-lg px-4 py-4 border border-border/30",children:"No MCP servers installed. Browse the directory below to get started."}):e.jsx("div",{className:"grid gap-2",children:t.map(p=>{var g,f;return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-card border border-border/50 rounded-lg",children:[e.jsx("svg",{className:"w-4 h-4 text-primary flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:p.name}),p.type==="stdio"&&((g=p.config)==null?void 0:g.command)&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:[p.config.command," ",p.config.args?p.config.args.join(" "):""]}),(p.type==="http"||p.type==="sse")&&((f=p.config)==null?void 0:f.url)&&e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:p.config.url})]}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${p.type==="stdio"?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":p.type==="sse"?"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300"}`,children:p.type}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${p.scope==="user"?"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400":"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300"}`,children:p.scope})]},p.id)})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-amber-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Server Directory"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Popular MCP servers"})]}),e.jsx("div",{className:"grid gap-2",children:td.map(p=>{const g=m(p.name);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/20 border border-border/30 rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:p.name}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${rd[p.category]||"bg-gray-100 text-gray-600"}`,children:p.category})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:p.description})]}),g?e.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 font-medium flex items-center gap-1 flex-shrink-0",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Installed"]}):e.jsx("button",{onClick:()=>void d(p),disabled:n===p.name,className:"text-xs px-3 py-1.5 rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 font-medium transition-colors flex-shrink-0 min-h-[36px]",children:n===p.name?"Installing...":"Install"})]},p.name)})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-blue-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Your Upfyn MCP Server"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Connect external AI clients (Claude Desktop, Cursor, etc.) to your Upfyn instance using MCP."}),e.jsxs("div",{className:"bg-muted/30 border border-border/30 rounded-lg p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"MCP Endpoint"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{className:"flex-1 text-sm bg-card border border-border rounded px-3 py-1.5 font-mono text-foreground truncate",children:i}),e.jsx("button",{onClick:()=>h(i),className:"px-2.5 py-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",title:"Copy",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Claude Desktop Config"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{className:"flex-1 text-xs bg-card border border-border rounded px-3 py-1.5 font-mono text-foreground overflow-x-auto",children:`{ "mcpServers": { "upfyn": { "url": "${i}" } } }`}),e.jsx("button",{onClick:()=>h(`{ "mcpServers": { "upfyn": { "url": "${i}" } } }`),className:"px-2.5 py-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground transition-colors flex-shrink-0 min-w-[44px] min-h-[44px] flex items-center justify-center",title:"Copy config",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})]})]})]})}function Fo({compact:t=!1}){const{i18n:r,t:s}=We("settings"),a=n=>{const o=n.target.value;r.changeLanguage(o)};return t?e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(to,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),s("account.language")]}),e.jsx("select",{value:r.language,onChange:a,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400",children:$a.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]}):e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:s("account.languageLabel")}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("account.languageDescription")})]}),e.jsx("select",{value:r.language,onChange:a,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-36",children:$a.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]})})}function ad(){const[t,r]=l.useState([]),[s,a]=l.useState(!0),[n,o]=l.useState(null),[i,c]=l.useState(!1),u=async()=>{try{const f=await Me("/api/sessions");if(f.ok){const x=await f.json();r(x.sessions||[])}}catch{}a(!1)};l.useEffect(()=>{u();const f=setInterval(u,1e4);return()=>clearInterval(f)},[]);const d=async(f,x)=>{o(f);try{await Me(`/api/sessions/${f}/abort`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:x})}),await u()}catch{}o(null)},m=async()=>{c(!0);try{await Me("/api/sessions/abort-all",{method:"POST"}),await u()}catch{}c(!1)},h=f=>{if(!f)return"";const x=Date.now()-new Date(f).getTime(),b=Math.floor(x/1e3);if(b<60)return`${b}s`;const N=Math.floor(b/60);return N<60?`${N}m`:`${Math.floor(N/60)}h ${N%60}m`},p=f=>({claude:"Claude",cursor:"Cursor",codex:"Codex"})[f]||f,g=f=>({claude:"text-orange-500",cursor:"text-blue-500",codex:"text-green-500"})[f]||"text-gray-500";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Js,{className:"w-5 h-5"})," Active Sessions"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:u,className:"text-sm text-muted-foreground hover:text-foreground flex items-center gap-1",children:[e.jsx(qs,{className:"w-3.5 h-3.5"})," Refresh"]}),t.length>0&&e.jsxs("button",{onClick:m,disabled:i,className:"text-sm text-red-500 hover:text-red-400 flex items-center gap-1 disabled:opacity-50",children:[e.jsx(Ra,{className:"w-3.5 h-3.5"})," ",i?"Aborting...":"Abort All"]})]})]}),s?e.jsx("div",{className:"text-center text-muted-foreground text-sm py-8",children:"Loading sessions..."}):t.length===0?e.jsxs("div",{className:"bg-muted/30 border border-border rounded-lg p-8 text-center",children:[e.jsx(Js,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"No active sessions"}),e.jsx("p",{className:"text-muted-foreground/60 text-xs mt-1",children:"Sessions appear here when you run Claude, Cursor, or Codex commands"})]}):e.jsx("div",{className:"border border-border rounded-lg overflow-hidden divide-y divide-border",children:t.map(f=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-mono text-foreground truncate",children:f.sessionId}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:`text-xs font-medium ${g(f.provider)}`,children:p(f.provider)}),e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium ${f.status==="active"?"bg-green-500/10 text-green-500 dark:text-green-400":"bg-gray-500/10 text-gray-500"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${f.status==="active"?"bg-green-500":"bg-gray-400"}`}),f.status]}),f.startedAt&&e.jsx("span",{className:"text-xs text-muted-foreground",children:h(f.startedAt)})]})]}),e.jsx("button",{onClick:()=>d(f.sessionId,f.provider),disabled:n===f.sessionId,className:"p-1.5 rounded hover:bg-red-500/10 text-red-500 hover:text-red-400 transition-colors disabled:opacity-50",title:"Abort session",children:e.jsx(Ra,{className:"w-4 h-4"})})]},f.sessionId))})]})}function nd({isOpen:t,onClose:r,projects:s=[],initialTab:a="agents"}){var Wr,et,It,Ms;const{isDarkMode:n,toggleDarkMode:o}=xa(),{t:i}=We("settings"),{addToast:c}=hr(),{confirm:u,dialogProps:d,ConfirmDialog:m}=Ea(),[h,p]=l.useState([]),[g,f]=l.useState([]),[x,b]=l.useState(""),[N,j]=l.useState(""),[y,k]=l.useState(!1),[I,D]=l.useState(!1),[C,v]=l.useState(null),[E,T]=l.useState("name"),[W,S]=l.useState([]),[O,H]=l.useState(!1),[R,A]=l.useState(null),[z,J]=l.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[re,G]=l.useState(!1),[ie,$]=l.useState({}),[Z,te]=l.useState({}),[Q,_]=l.useState({}),[F,q]=l.useState(a),[U,B]=l.useState(""),[ee,V]=l.useState("claude"),[w,M]=l.useState("account"),[Y,se]=l.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[de,je]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[ge,Re]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[Ne,De]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Ue,_e]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[L,K]=l.useState([]),[pe,ye]=l.useState([]),[Ie,Fe]=l.useState(!1),[Se,Oe]=l.useState(""),[ne,fe]=l.useState(""),[Ee,Le]=l.useState([]),[Pe,Ae]=l.useState([]),[Ge,ae]=l.useState("default"),[be,ze]=l.useState(!1),[Ce,Ye]=l.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[lt,dt]=l.useState(null),[Tt,At]=l.useState(!1),[wt,Ft]=l.useState(!1),[le,ue]=l.useState(""),[ce,we]=l.useState(null),[He,Qe]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Xe,ut]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Vt,ht]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),jt=async()=>{try{const P=await Me("/api/cursor/mcp");if(P.ok){const X=await P.json();Le(X.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(P){console.error("Error fetching Cursor MCP servers:",P)}},st=async()=>{try{const P=await Me("/api/codex/mcp/config/read");if(P.ok){const oe=await P.json();if(oe.success&&oe.servers){Ae(oe.servers);return}}const X=await Me("/api/codex/mcp/cli/list");if(X.ok){const oe=await X.json();if(oe.success&&oe.servers){const ve=oe.servers.map(Ke=>({id:Ke.name,name:Ke.name,type:Ke.type||"stdio",scope:"user",config:{command:Ke.command||"",args:Ke.args||[],env:Ke.env||{}}}));Ae(ve)}}}catch(P){console.error("Error fetching Codex MCP servers:",P)}},tt=async()=>{try{const P=await Me("/api/mcp/config/read");if(P.ok){const ve=await P.json();if(ve.success&&ve.servers){S(ve.servers);return}}const X=await Me("/api/mcp/cli/list");if(X.ok){const ve=await X.json();if(ve.success&&ve.servers){const Ke=ve.servers.map(nt=>({id:nt.name,name:nt.name,type:nt.type,scope:"user",config:{command:nt.command||"",args:nt.args||[],env:nt.env||{},url:nt.url||"",headers:nt.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));S(Ke);return}}const oe=await Me("/api/mcp/servers?scope=user");if(oe.ok){const ve=await oe.json();S(ve.servers||[])}else console.error("Failed to fetch MCP servers")}catch(P){console.error("Error fetching MCP servers:",P)}},zt=async P=>{var X,oe,ve,Ke,nt;try{R&&await or(R.id,"user");const cr=await Me("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:P.name,type:P.type,scope:P.scope,projectPath:P.projectPath,command:(X=P.config)==null?void 0:X.command,args:((oe=P.config)==null?void 0:oe.args)||[],url:(ve=P.config)==null?void 0:ve.url,headers:((Ke=P.config)==null?void 0:Ke.headers)||{},env:((nt=P.config)==null?void 0:nt.env)||{}})});if(cr.ok){const Ur=await cr.json();if(Ur.success)return await tt(),!0;throw new Error(Ur.error||"Failed to save server via Claude CLI")}else{const Ur=await cr.json();throw new Error(Ur.error||"Failed to save server")}}catch(cr){throw console.error("Error saving MCP server:",cr),cr}},or=async(P,X="user")=>{try{const oe=await Me(`/api/mcp/cli/remove/${P}?scope=${X}`,{method:"DELETE"});if(oe.ok){const ve=await oe.json();if(ve.success)return await tt(),!0;throw new Error(ve.error||"Failed to delete server via Claude CLI")}else{const ve=await oe.json();throw new Error(ve.error||"Failed to delete server")}}catch(oe){throw console.error("Error deleting MCP server:",oe),oe}},bs=async(P,X="user")=>{try{const oe=await Me(`/api/mcp/servers/${P}/test?scope=${X}`,{method:"POST"});if(oe.ok)return(await oe.json()).testResult;{const ve=await oe.json();throw new Error(ve.error||"Failed to test server")}}catch(oe){throw console.error("Error testing MCP server:",oe),oe}},ys=async(P,X="user")=>{try{const oe=await Me(`/api/mcp/servers/${P}/tools?scope=${X}`,{method:"POST"});if(oe.ok)return(await oe.json()).toolsResult;{const ve=await oe.json();throw new Error(ve.error||"Failed to discover tools")}}catch(oe){throw console.error("Error discovering MCP tools:",oe),oe}},vs=async P=>{var X,oe,ve;try{lt&&await vr(lt.id);const Ke=await Me("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:P.name,command:(X=P.config)==null?void 0:X.command,args:((oe=P.config)==null?void 0:oe.args)||[],env:((ve=P.config)==null?void 0:ve.env)||{}})});if(Ke.ok){const nt=await Ke.json();if(nt.success)return await st(),!0;throw new Error(nt.error||"Failed to save Codex MCP server")}else{const nt=await Ke.json();throw new Error(nt.error||"Failed to save server")}}catch(Ke){throw console.error("Error saving Codex MCP server:",Ke),Ke}},vr=async P=>{try{const X=await Me(`/api/codex/mcp/cli/remove/${P}`,{method:"DELETE"});if(X.ok){const oe=await X.json();if(oe.success)return await st(),!0;throw new Error(oe.error||"Failed to delete Codex MCP server")}else{const oe=await X.json();throw new Error(oe.error||"Failed to delete server")}}catch(X){throw console.error("Error deleting Codex MCP server:",X),X}},ir=()=>{Ye({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),dt(null),ze(!1)},_r=(P=null)=>{var X,oe,ve;P?(dt(P),Ye({name:P.name,type:P.type||"stdio",config:{command:((X=P.config)==null?void 0:X.command)||"",args:((oe=P.config)==null?void 0:oe.args)||[],env:((ve=P.config)==null?void 0:ve.env)||{}}})):ir(),ze(!0)},ks=async P=>{P.preventDefault(),At(!0);try{lt&&await vr(lt.name),await vs(Ce),ir(),v("success")}catch(X){c(`Error: ${X.message}`,"error"),v("error")}finally{At(!1)}},ws=async P=>{if(await u({title:i("mcp.deleteTitle","Delete MCP Server"),message:i("mcp.confirmDelete","Are you sure you want to delete this MCP server?"),confirmLabel:i("mcp.deleteButton","Delete"),cancelLabel:i("common:cancel","Cancel")}))try{await vr(P),v("success")}catch(oe){c(`Error: ${oe.message}`,"error"),v("error")}};l.useEffect(()=>{t&&(js(),Fr(),zr(),Rr(),q(a))},[t,a]),l.useEffect(()=>{localStorage.setItem("codeEditorTheme",Y),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Y]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",de.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[de]),l.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",ge.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ge]),l.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",Ne.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ne]),l.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Ue),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ue]);const js=async()=>{try{const P=localStorage.getItem("claude-settings");if(P){const ve=JSON.parse(P);p(ve.allowedTools||[]),f(ve.disallowedTools||[]),k(ve.skipPermissions||!1),T(ve.projectSortOrder||"name")}else p([]),f([]),k(!1),T("name");const X=localStorage.getItem("cursor-tools-settings");if(X){const ve=JSON.parse(X);K(ve.allowedCommands||[]),ye(ve.disallowedCommands||[]),Fe(ve.skipPermissions||!1)}else K([]),ye([]),Fe(!1);const oe=localStorage.getItem("codex-settings");if(oe){const ve=JSON.parse(oe);ae(ve.permissionMode||"default")}else ae("default");await tt(),await jt(),await st()}catch(P){console.error("Error loading tool settings:",P),p([]),f([]),k(!1),T("name")}},Fr=async()=>{try{const P=await Me("/api/cli/claude/status");if(P.ok){const X=await P.json();Qe({authenticated:X.authenticated,email:X.email,loading:!1,error:X.error||null})}else Qe({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Claude auth status:",P),Qe({authenticated:!1,email:null,loading:!1,error:P.message})}},zr=async()=>{try{const P=await Me("/api/cli/cursor/status");if(P.ok){const X=await P.json();ut({authenticated:X.authenticated,email:X.email,loading:!1,error:X.error||null})}else ut({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Cursor auth status:",P),ut({authenticated:!1,email:null,loading:!1,error:P.message})}},Rr=async()=>{try{const P=await Me("/api/cli/codex/status");if(P.ok){const X=await P.json();ht({authenticated:X.authenticated,email:X.email,loading:!1,error:X.error||null})}else ht({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(P){console.error("Error checking Codex auth status:",P),ht({authenticated:!1,email:null,loading:!1,error:P.message})}},Ns=()=>{ue("claude"),we((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},lr=()=>{ue("cursor"),we((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},Cs=()=>{ue("codex"),we((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},Ss=P=>{P===0&&(v("success"),le==="claude"?Fr():le==="cursor"?zr():le==="codex"&&Rr())},Or=()=>{D(!0),v(null);try{const P={allowedTools:h,disallowedTools:g,skipPermissions:y,projectSortOrder:E,lastUpdated:new Date().toISOString()},X={allowedCommands:L,disallowedCommands:pe,skipPermissions:Ie,lastUpdated:new Date().toISOString()},oe={permissionMode:Ge,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(P)),localStorage.setItem("cursor-tools-settings",JSON.stringify(X)),localStorage.setItem("codex-settings",JSON.stringify(oe)),v("success"),setTimeout(()=>{r()},1e3)}catch(P){console.error("Error saving tool settings:",P),v("error")}finally{D(!1)}},qt=()=>{J({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),A(null),H(!1),B("")},Br=(P=null)=>{P?(A(P),J({name:P.name,type:P.type,scope:P.scope,projectPath:P.projectPath||"",config:{...P.config},raw:P.raw,importMode:"form",jsonInput:""})):qt(),H(!0)},Es=async P=>{P.preventDefault(),G(!0);try{if(z.importMode==="json"){const X=await Me("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:z.name,jsonConfig:z.jsonInput,scope:z.scope,projectPath:z.projectPath})});if(X.ok){const oe=await X.json();if(oe.success)await tt(),qt(),v("success");else throw new Error(oe.error||"Failed to add server via JSON")}else{const oe=await X.json();throw new Error(oe.error||"Failed to add server")}}else await zt(z),qt(),v("success")}catch(X){c(`Error: ${X.message}`,"error"),v("error")}finally{G(!1)}},Ts=async(P,X)=>{if(await u({title:i("mcp.deleteTitle","Delete MCP Server"),message:i("mcp.confirmDelete","Are you sure you want to delete this MCP server?"),confirmLabel:i("mcp.deleteButton","Delete"),cancelLabel:i("common:cancel","Cancel")}))try{await or(P,X),v("success")}catch(ve){c(`Error: ${ve.message}`,"error"),v("error")}},As=async(P,X)=>{try{$({...ie,[P]:{loading:!0}});const oe=await bs(P,X);$({...ie,[P]:oe})}catch(oe){$({...ie,[P]:{success:!1,message:oe.message,details:[]}})}},Is=async(P,X)=>{try{_({...Q,[P]:!0});const oe=await ys(P,X);te({...Z,[P]:oe})}catch{te({...Z,[P]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{_({...Q,[P]:!1})}},Kt=(P,X)=>{J(oe=>({...oe,config:{...oe.config,[P]:X}}))};return t?e.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[e.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Dt,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),e.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:i("title")})]}),e.jsx(he,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"border-b border-border",children:e.jsxs("div",{className:"flex overflow-x-auto scrollbar-none px-4 md:px-6",children:[e.jsx("button",{onClick:()=>q("agents"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.agents")}),e.jsx("button",{onClick:()=>q("appearance"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.appearance")}),e.jsxs("button",{onClick:()=>q("git"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(br,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.git")]}),e.jsxs("button",{onClick:()=>q("api"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ga,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]}),e.jsx("button",{onClick:()=>q("tasks"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.tasks")}),e.jsxs("button",{onClick:()=>q("mcp"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx($r,{className:"w-4 h-4 inline mr-2"}),"MCP Hub"]}),e.jsxs("button",{onClick:()=>q("sessions"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${F==="sessions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Js,{className:"w-4 h-4 inline mr-2"}),"Sessions"]})]})}),e.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[F==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:F==="appearance"&&e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.darkMode.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.darkMode.description")})]}),e.jsxs("button",{onClick:o,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":n,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${n?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:n?e.jsx(Ys,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Qs,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),e.jsx("div",{className:"space-y-4",children:e.jsx(Fo,{})}),e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.projectSorting.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.projectSorting.description")})]}),e.jsxs("select",{value:E,onChange:P=>T(P.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-32",children:[e.jsx("option",{value:"name",children:i("appearanceSettings.projectSorting.alphabetical")}),e.jsx("option",{value:"date",children:i("appearanceSettings.projectSorting.recentActivity")})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:i("appearanceSettings.codeEditor.title")}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.theme.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.theme.description")})]}),e.jsxs("button",{onClick:()=>se(Y==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Y==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${Y==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:Y==="dark"?e.jsx(Ys,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Qs,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.wordWrap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.wordWrap.description")})]}),e.jsxs("button",{onClick:()=>je(!de),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":de,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${de?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.showMinimap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.showMinimap.description")})]}),e.jsxs("button",{onClick:()=>Re(!ge),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":ge,"aria-label":"Toggle minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),e.jsx("span",{className:`${ge?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.description")})]}),e.jsxs("button",{onClick:()=>De(!Ne),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ne,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${Ne?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.fontSize.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.fontSize.description")})]}),e.jsxs("select",{value:Ue,onChange:P=>_e(P.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-24",children:[e.jsx("option",{value:"10",children:"10px"}),e.jsx("option",{value:"11",children:"11px"}),e.jsx("option",{value:"12",children:"12px"}),e.jsx("option",{value:"13",children:"13px"}),e.jsx("option",{value:"14",children:"14px"}),e.jsx("option",{value:"15",children:"15px"}),e.jsx("option",{value:"16",children:"16px"}),e.jsx("option",{value:"18",children:"18px"}),e.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),F==="git"&&e.jsx(Oc,{}),F==="agents"&&e.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[e.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex",children:[e.jsx(dr,{agentId:"claude",authStatus:He,isSelected:ee==="claude",onClick:()=>V("claude"),isMobile:!0}),e.jsx(dr,{agentId:"cursor",authStatus:Xe,isSelected:ee==="cursor",onClick:()=>V("cursor"),isMobile:!0}),e.jsx(dr,{agentId:"codex",authStatus:Vt,isSelected:ee==="codex",onClick:()=>V("codex"),isMobile:!0})]})}),e.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"p-2",children:[e.jsx(dr,{agentId:"claude",authStatus:He,isSelected:ee==="claude",onClick:()=>V("claude")}),e.jsx(dr,{agentId:"cursor",authStatus:Xe,isSelected:ee==="cursor",onClick:()=>V("cursor")}),e.jsx(dr,{agentId:"codex",authStatus:Vt,isSelected:ee==="codex",onClick:()=>V("codex")})]})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[e.jsx("button",{onClick:()=>M("account"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.account")}),e.jsx("button",{onClick:()=>M("permissions"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.permissions")}),e.jsx("button",{onClick:()=>M("mcp"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.mcpServers")})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[w==="account"&&e.jsx(Gc,{agent:ee,authStatus:ee==="claude"?He:ee==="cursor"?Xe:Vt,onLogin:ee==="claude"?Ns:ee==="cursor"?lr:Cs}),w==="permissions"&&ee==="claude"&&e.jsx($s,{agent:"claude",skipPermissions:y,setSkipPermissions:k,allowedTools:h,setAllowedTools:p,disallowedTools:g,setDisallowedTools:f,newAllowedTool:x,setNewAllowedTool:b,newDisallowedTool:N,setNewDisallowedTool:j}),w==="permissions"&&ee==="cursor"&&e.jsx($s,{agent:"cursor",skipPermissions:Ie,setSkipPermissions:Fe,allowedCommands:L,setAllowedCommands:K,disallowedCommands:pe,setDisallowedCommands:ye,newAllowedCommand:Se,setNewAllowedCommand:Oe,newDisallowedCommand:ne,setNewDisallowedCommand:fe}),w==="permissions"&&ee==="codex"&&e.jsx($s,{agent:"codex",permissionMode:Ge,setPermissionMode:ae}),w==="mcp"&&ee==="claude"&&e.jsx(_s,{agent:"claude",servers:W,onAdd:()=>Br(),onEdit:P=>Br(P),onDelete:(P,X)=>Ts(P,X),onTest:(P,X)=>As(P,X),onDiscoverTools:(P,X)=>Is(P,X),testResults:ie,serverTools:Z,toolsLoading:Q}),w==="mcp"&&ee==="cursor"&&e.jsx(_s,{agent:"cursor",servers:Ee,onAdd:()=>{},onEdit:P=>{},onDelete:P=>{}}),w==="mcp"&&ee==="codex"&&e.jsx(_s,{agent:"codex",servers:Pe,onAdd:()=>_r(),onEdit:P=>_r(P),onDelete:P=>ws(P)})]})]})]}),O&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(R?"mcpForm.title.edit":"mcpForm.title.add")}),e.jsx(he,{variant:"ghost",size:"sm",onClick:qt,children:e.jsx(Ve,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:Es,className:"p-4 space-y-4",children:[!R&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${z.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.form")}),e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${z.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.json")})]}),z.importMode==="form"&&R&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.scope.label")}),e.jsxs("div",{className:"flex items-center gap-2",children:[z.scope==="user"?e.jsx(Ks,{className:"w-4 h-4"}):e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:z.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),z.scope==="local"&&z.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",z.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),z.importMode==="form"&&!R&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.scope.label")," *"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${z.scope==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(Ks,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),e.jsx("button",{type:"button",onClick:()=>J(P=>({...P,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${z.scope==="local"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.projectLocal")})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:z.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),z.scope==="local"&&!R&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.selectProject")," *"]}),e.jsxs("select",{value:z.projectPath,onChange:P=>J(X=>({...X,projectPath:P.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",required:z.scope==="local",children:[e.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),s.map(P=>e.jsx("option",{value:P.path||P.fullPath,children:P.displayName||P.name},P.name))]}),z.projectPath&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:z.projectPath})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:z.importMode==="json"?"md:col-span-2":"",children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),e.jsx(Ze,{value:z.name,onChange:P=>{J(X=>({...X,name:P.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),z.importMode==="form"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.transportType")," *"]}),e.jsxs("select",{value:z.type,onChange:P=>{J(X=>({...X,type:P.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",children:[e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"sse",children:"SSE"}),e.jsx("option",{value:"http",children:"HTTP"})]})]})]}),R&&z.raw&&z.importMode==="form"&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:i("mcpForm.configDetails",{configFile:R.scope==="global"?"~/.claude.json":"project config"})}),e.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(z.raw,null,2)})]}),z.importMode==="json"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.jsonConfig")," *"]}),e.jsx("textarea",{value:z.jsonInput,onChange:P=>{J(X=>({...X,jsonInput:P.target.value}));try{if(P.target.value.trim()){const X=JSON.parse(P.target.value);X.type?X.type==="stdio"&&!X.command?B(i("mcpForm.validation.stdioRequiresCommand")):(X.type==="http"||X.type==="sse")&&!X.url?B(i("mcpForm.validation.httpRequiresUrl",{type:X.type})):B(""):B(i("mcpForm.validation.missingType"))}}catch{P.target.value.trim()?B(i("mcpForm.validation.invalidJson")):B("")}},className:`w-full px-3 py-2 border ${U?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 font-mono text-sm`,rows:"8",placeholder:`{
3
3
  "type": "stdio",
4
4
  "command": "/path/to/server",
5
5
  "args": ["--api-key", "abc123"],
@@ -21,7 +21,7 @@ X-API-Key=your-key`})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",c
21
21
  3000`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),e.jsx("textarea",{value:Object.entries(((It=Ce.config)==null?void 0:It.env)||{}).map(([P,X])=>`${P}=${X}`).join(`
22
22
  `),onChange:P=>{const X={};P.target.value.split(`
23
23
  `).forEach(oe=>{const[ve,...Ke]=oe.split("=");ve&&Ke.length>0&&(X[ve.trim()]=Ke.join("=").trim())}),Ye(oe=>({...oe,config:{...oe.config,env:X}}))},placeholder:`API_KEY=xxx
24
- DEBUG=true`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[e.jsx(he,{type:"button",variant:"outline",onClick:ir,children:i("mcpForm.actions.cancel")}),e.jsx(he,{type:"submit",disabled:Tt||!Ce.name||!((Ms=Ce.config)!=null&&Ms.command),className:"bg-green-600 hover:bg-green-700 text-white",children:i(Tt?"mcpForm.actions.saving":lt?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),F==="tasks"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsx(Oc,{})}),F==="api"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsx(zc,{})}),F==="mcp"&&e.jsx(rd,{}),F==="sessions"&&e.jsx(sd,{})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 md:p-6 border-t border-border flex-shrink-0 gap-3 pb-safe-area-inset-bottom",children:[e.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[C==="success"&&e.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),i("saveStatus.success")]}),C==="error"&&e.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),i("saveStatus.error")]})]}),e.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[e.jsx(he,{variant:"outline",onClick:r,disabled:I,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:i("footerActions.cancel")}),e.jsx(he,{onClick:Or,disabled:I,className:"flex-1 sm:flex-none h-10 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 touch-manipulation",children:I?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),i("saveStatus.saving")]}):i("footerActions.save")})]})]})]}),e.jsx(Vi,{isOpen:wt,onClose:()=>Ft(!1),provider:le,project:ce,onComplete:Ss,isAuthenticated:le==="claude"?He.authenticated:le==="cursor"?Xe.authenticated:le==="codex"?Vt.authenticated:!1},le),e.jsx(m,{...d})]}):null}function nd({isOpen:t,onClose:r,releaseInfo:s,currentVersion:a,latestVersion:n}){const{t:o}=We("common"),[i,c]=l.useState(!1),[u,d]=l.useState(""),[m,h]=l.useState(""),[p,g]=l.useState(!1),[f,x]=l.useState(!1),b=l.useCallback(async()=>{c(!0),d(`Starting update...
24
+ DEBUG=true`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[e.jsx(he,{type:"button",variant:"outline",onClick:ir,children:i("mcpForm.actions.cancel")}),e.jsx(he,{type:"submit",disabled:Tt||!Ce.name||!((Ms=Ce.config)!=null&&Ms.command),className:"bg-green-600 hover:bg-green-700 text-white",children:i(Tt?"mcpForm.actions.saving":lt?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),F==="tasks"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsx(Bc,{})}),F==="api"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsx(Rc,{})}),F==="mcp"&&e.jsx(sd,{}),F==="sessions"&&e.jsx(ad,{})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 md:p-6 border-t border-border flex-shrink-0 gap-3 pb-safe-area-inset-bottom",children:[e.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[C==="success"&&e.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),i("saveStatus.success")]}),C==="error"&&e.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),i("saveStatus.error")]})]}),e.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[e.jsx(he,{variant:"outline",onClick:r,disabled:I,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:i("footerActions.cancel")}),e.jsx(he,{onClick:Or,disabled:I,className:"flex-1 sm:flex-none h-10 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 touch-manipulation",children:I?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),i("saveStatus.saving")]}):i("footerActions.save")})]})]})]}),e.jsx(qi,{isOpen:wt,onClose:()=>Ft(!1),provider:le,project:ce,onComplete:Ss,isAuthenticated:le==="claude"?He.authenticated:le==="cursor"?Xe.authenticated:le==="codex"?Vt.authenticated:!1},le),e.jsx(m,{...d})]}):null}function od({isOpen:t,onClose:r,releaseInfo:s,currentVersion:a,latestVersion:n}){const{t:o}=We("common"),[i,c]=l.useState(!1),[u,d]=l.useState(""),[m,h]=l.useState(""),[p,g]=l.useState(!1),[f,x]=l.useState(!1),b=l.useCallback(async()=>{c(!0),d(`Starting update...
25
25
  `),h(""),g(!1);try{const j=await Me("/api/system/update",{method:"POST"}),y=await j.json();j.ok?(d(k=>k+(y.output||"")+`
26
26
  `),d(k=>k+`
27
27
  Update completed successfully!
@@ -30,10 +30,10 @@ Update completed successfully!
30
30
  Update failed: `+(y.error||"Unknown error")+`
31
31
  `))}catch{h("Network error — could not reach the server."),d(j=>j+`
32
32
  Update failed: Network error
33
- `)}finally{c(!1)}},[]),N=l.useCallback(()=>{navigator.clipboard.writeText("npm install -g upfynai-code@latest"),x(!0),setTimeout(()=>x(!1),2e3)},[]);return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("button",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:r,"aria-label":o("versionUpdate.ariaLabels.closeModal")}),e.jsxs("div",{className:"relative bg-card border border-border/40 rounded-2xl shadow-2xl w-full max-w-lg mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-primary/10 rounded-xl flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:o("versionUpdate.title")}),e.jsx("p",{className:"text-xs text-muted-foreground/50",children:(s==null?void 0:s.title)||o("versionUpdate.newVersionReady")})]})]}),e.jsx("button",{onClick:r,className:"p-2 text-muted-foreground/40 hover:text-foreground hover:bg-muted/30 rounded-lg transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-muted/20 rounded-xl",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:o("versionUpdate.currentVersion")}),e.jsx("span",{className:"text-xs text-foreground font-mono",children:a})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-primary/5 rounded-xl border border-primary/15",children:[e.jsx("span",{className:"text-xs font-medium text-primary",children:o("versionUpdate.latestVersion")}),e.jsx("span",{className:"text-xs text-primary font-mono font-semibold",children:n})]})]}),(s==null?void 0:s.body)&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:o("versionUpdate.whatsNew")}),(s==null?void 0:s.htmlUrl)&&e.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-primary hover:underline flex items-center gap-1",children:[o("versionUpdate.viewFullRelease"),e.jsx("svg",{className:"w-2.5 h-2.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]}),e.jsx("div",{className:"bg-muted/20 rounded-xl p-3 max-h-48 overflow-y-auto",children:e.jsx("div",{className:"text-xs text-muted-foreground whitespace-pre-wrap leading-relaxed",children:od(s.body)})})]}),u&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:o("versionUpdate.updateProgress")}),e.jsx("div",{className:"bg-background rounded-xl p-3 border border-border/30 max-h-40 overflow-y-auto",children:e.jsx("pre",{className:"text-[10px] text-green-400 font-mono whitespace-pre-wrap",children:u})}),m&&e.jsx("div",{className:"px-3 py-2 text-xs text-red-400 bg-red-500/[0.03] border border-red-500/15 rounded-xl",children:m})]}),!i&&!u&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:o("versionUpdate.manualUpgrade")}),e.jsxs("div",{className:"flex items-center justify-between bg-background rounded-xl p-3 border border-border/30 cursor-pointer hover:border-border/50 transition-colors group",onClick:N,children:[e.jsx("code",{className:"text-xs text-foreground font-mono",children:"npm install -g upfynai-code@latest"}),e.jsx("span",{className:"text-[10px] text-muted-foreground/40 group-hover:text-primary transition-colors",children:f?"Copied!":"Click to copy"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/40 leading-relaxed",children:o("versionUpdate.manualUpgradeHint")})]})]}),e.jsxs("div",{className:"flex gap-2 px-5 py-4 border-t border-border/20",children:[e.jsx("button",{onClick:r,className:"flex-1 px-4 py-2.5 text-xs font-medium text-muted-foreground bg-muted/30 hover:bg-muted/50 rounded-xl transition-colors",children:o(p?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!u&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:N,className:"flex-1 px-4 py-2.5 text-xs font-medium text-muted-foreground bg-muted/30 hover:bg-muted/50 rounded-xl transition-colors",children:f?"Copied!":o("versionUpdate.buttons.copyCommand")}),e.jsx("button",{onClick:b,disabled:i,className:"flex-1 px-4 py-2.5 text-xs font-medium text-background bg-foreground hover:opacity-90 disabled:opacity-40 rounded-xl transition-opacity flex items-center justify-center gap-2",children:i?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3.5 h-3.5 border-2 border-background/30 border-t-background rounded-full animate-spin"}),o("versionUpdate.buttons.updating")]}):o("versionUpdate.buttons.updateNow")})]})]})]})]}):null}const od=t=>t?t.replace(/\b[0-9a-f]{40}\b/gi,"").replace(/(?:^|\s|-)([0-9a-f]{7,10})\b/gi,"").replace(/\*\*Full Changelog\*\*:.*$/gim,"").replace(/https?:\/\/github\.com\/[^\/]+\/[^\/]+\/compare\/[^\s)]+/gi,"").replace(/\n\s*\n\s*\n/g,`
33
+ `)}finally{c(!1)}},[]),N=l.useCallback(()=>{navigator.clipboard.writeText("npm install -g upfynai-code@latest"),x(!0),setTimeout(()=>x(!1),2e3)},[]);return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("button",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:r,"aria-label":o("versionUpdate.ariaLabels.closeModal")}),e.jsxs("div",{className:"relative bg-card border border-border/40 rounded-2xl shadow-2xl w-full max-w-lg mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-primary/10 rounded-xl flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:o("versionUpdate.title")}),e.jsx("p",{className:"text-xs text-muted-foreground/50",children:(s==null?void 0:s.title)||o("versionUpdate.newVersionReady")})]})]}),e.jsx("button",{onClick:r,className:"p-2 text-muted-foreground/40 hover:text-foreground hover:bg-muted/30 rounded-lg transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-muted/20 rounded-xl",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:o("versionUpdate.currentVersion")}),e.jsx("span",{className:"text-xs text-foreground font-mono",children:a})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-primary/5 rounded-xl border border-primary/15",children:[e.jsx("span",{className:"text-xs font-medium text-primary",children:o("versionUpdate.latestVersion")}),e.jsx("span",{className:"text-xs text-primary font-mono font-semibold",children:n})]})]}),(s==null?void 0:s.body)&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:o("versionUpdate.whatsNew")}),(s==null?void 0:s.htmlUrl)&&e.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-primary hover:underline flex items-center gap-1",children:[o("versionUpdate.viewFullRelease"),e.jsx("svg",{className:"w-2.5 h-2.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]}),e.jsx("div",{className:"bg-muted/20 rounded-xl p-3 max-h-48 overflow-y-auto",children:e.jsx("div",{className:"text-xs text-muted-foreground whitespace-pre-wrap leading-relaxed",children:id(s.body)})})]}),u&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:o("versionUpdate.updateProgress")}),e.jsx("div",{className:"bg-background rounded-xl p-3 border border-border/30 max-h-40 overflow-y-auto",children:e.jsx("pre",{className:"text-[10px] text-green-400 font-mono whitespace-pre-wrap",children:u})}),m&&e.jsx("div",{className:"px-3 py-2 text-xs text-red-400 bg-red-500/[0.03] border border-red-500/15 rounded-xl",children:m})]}),!i&&!u&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:o("versionUpdate.manualUpgrade")}),e.jsxs("div",{className:"flex items-center justify-between bg-background rounded-xl p-3 border border-border/30 cursor-pointer hover:border-border/50 transition-colors group",onClick:N,children:[e.jsx("code",{className:"text-xs text-foreground font-mono",children:"npm install -g upfynai-code@latest"}),e.jsx("span",{className:"text-[10px] text-muted-foreground/40 group-hover:text-primary transition-colors",children:f?"Copied!":"Click to copy"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/40 leading-relaxed",children:o("versionUpdate.manualUpgradeHint")})]})]}),e.jsxs("div",{className:"flex gap-2 px-5 py-4 border-t border-border/20",children:[e.jsx("button",{onClick:r,className:"flex-1 px-4 py-2.5 text-xs font-medium text-muted-foreground bg-muted/30 hover:bg-muted/50 rounded-xl transition-colors",children:o(p?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!u&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:N,className:"flex-1 px-4 py-2.5 text-xs font-medium text-muted-foreground bg-muted/30 hover:bg-muted/50 rounded-xl transition-colors",children:f?"Copied!":o("versionUpdate.buttons.copyCommand")}),e.jsx("button",{onClick:b,disabled:i,className:"flex-1 px-4 py-2.5 text-xs font-medium text-background bg-foreground hover:opacity-90 disabled:opacity-40 rounded-xl transition-opacity flex items-center justify-center gap-2",children:i?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3.5 h-3.5 border-2 border-background/30 border-t-background rounded-full animate-spin"}),o("versionUpdate.buttons.updating")]}):o("versionUpdate.buttons.updateNow")})]})]})]})]}):null}const id=t=>t?t.replace(/\b[0-9a-f]{40}\b/gi,"").replace(/(?:^|\s|-)([0-9a-f]{7,10})\b/gi,"").replace(/\*\*Full Changelog\*\*:.*$/gim,"").replace(/https?:\/\/github\.com\/[^\/]+\/[^\/]+\/compare\/[^\s)]+/gi,"").replace(/\n\s*\n\s*\n/g,`
34
34
 
35
- `).trim():"",id=ad;function ld(t){return e.jsx(id,{...t})}function cd({projects:t,showSettings:r,settingsInitialTab:s,onCloseSettings:a,showNewProject:n,onCloseNewProject:o,onProjectCreated:i,deleteConfirmation:c,onCancelDeleteProject:u,onConfirmDeleteProject:d,sessionDeleteConfirmation:m,onCancelDeleteSession:h,onConfirmDeleteSession:p,showVersionModal:g,onCloseVersionModal:f,releaseInfo:x,currentVersion:b,latestVersion:N,t:j}){const y=l.useMemo(()=>t.map(Al),[t]);return e.jsxs(e.Fragment,{children:[n&&Cr.createPortal(e.jsx($c,{onClose:o,onProjectCreated:i}),document.body),r&&Cr.createPortal(e.jsx(ld,{isOpen:r,onClose:a,projects:y,initialTab:s}),document.body),c&&Cr.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:e.jsx($t,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:j("deleteConfirmation.deleteProject")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[j("deleteConfirmation.confirmDelete")," ",e.jsx("span",{className:"font-medium text-foreground",children:c.project.displayName||c.project.name}),"?"]}),c.sessionCount>0&&e.jsxs("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 font-medium",children:j("deleteConfirmation.sessionCount",{count:c.sessionCount})}),e.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:j("deleteConfirmation.allConversationsDeleted")})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:j("deleteConfirmation.cannotUndo")})]})]})}),e.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[e.jsx(he,{variant:"outline",className:"flex-1",onClick:u,children:j("actions.cancel")}),e.jsxs(he,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:d,children:[e.jsx(yt,{className:"w-4 h-4 mr-2"}),j("actions.delete")]})]})]})}),document.body),m&&Cr.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:e.jsx($t,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:j("deleteConfirmation.deleteSession")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[j("deleteConfirmation.confirmDelete")," ",e.jsx("span",{className:"font-medium text-foreground",children:m.sessionTitle||j("sessions.unnamed")}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:j("deleteConfirmation.cannotUndo")})]})]})}),e.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[e.jsx(he,{variant:"outline",className:"flex-1",onClick:h,children:j("actions.cancel")}),e.jsxs(he,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:p,children:[e.jsx(yt,{className:"w-4 h-4 mr-2"}),j("actions.delete")]})]})]})}),document.body),e.jsx(nd,{isOpen:g,onClose:f,releaseInfo:x,currentVersion:b,latestVersion:N})]})}function dd({project:t,isOpen:r,onClose:s}){var j;const{t:a}=We("sidebar"),[n,o]=l.useState(null),[i,c]=l.useState(null),[u,d]=l.useState(!1),[m,h]=l.useState(null),[p,g]=l.useState([]),[f,x]=l.useState(!1),b=l.useCallback(async()=>{d(!0),h(null);try{const k=await(await Me(`/api/projects/${encodeURIComponent(t.name)}/claude-md`)).json();o(k.content),c(k.path||null),k.error&&h(k.error)}catch{h("Failed to fetch CLAUDE.md")}finally{d(!1)}},[t.name]),N=l.useCallback(async()=>{x(!0);try{const y=t.fullPath||t.path||"",I=await(await Me(`/api/mcp/config/read?projectPath=${encodeURIComponent(y)}`)).json();I.success&&I.servers?g(I.servers.filter(D=>D.scope==="project"||D.scope==="local")):g([])}catch{g([])}finally{x(!1)}},[t.fullPath,t.path]);return l.useEffect(()=>{r&&(b(),N())},[r,b,N]),l.useEffect(()=>{if(!r)return;const y=k=>{k.key==="Escape"&&s()};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[r,s]),r?e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:s}),e.jsxs("div",{className:"relative ml-auto w-full sm:max-w-md bg-card border-l border-border shadow-2xl flex flex-col h-full animate-in slide-in-from-right duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/30",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground truncate",children:t.displayName}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",title:t.fullPath,children:t.fullPath})]}),e.jsx("button",{onClick:s,className:"ml-3 w-10 h-10 sm:w-7 sm:h-7 rounded-md hover:bg-accent flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-5 pb-[max(1rem,env(safe-area-inset-bottom))]",children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:a("projectSettings.quickInfo",{defaultValue:"Quick Info"})}),e.jsxs("div",{className:"space-y-1.5 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),e.jsx("span",{className:"truncate",children:t.fullPath})]}),((j=t.taskmaster)==null?void 0:j.hasTaskmaster)&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),e.jsxs("span",{children:["TaskMaster: ",e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"Active"})]})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:"CLAUDE.md"}),u?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-3",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading..."]}):m?e.jsx("div",{className:"text-sm text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 rounded-lg px-3 py-2",children:m}):n?e.jsxs("div",{className:"bg-muted/50 rounded-lg border border-border/50 overflow-hidden",children:[e.jsx("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 bg-muted/30",children:e.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate",children:i})}),e.jsx("pre",{className:"px-3 py-2 text-xs text-foreground overflow-x-auto max-h-[300px] overflow-y-auto whitespace-pre-wrap font-mono leading-relaxed",children:n})]}):e.jsx("div",{className:"text-sm text-muted-foreground bg-muted/30 rounded-lg px-3 py-3 border border-border/30",children:a("projectSettings.noClaudeMd",{defaultValue:"No CLAUDE.md found in this project."})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:a("projectSettings.mcpServers",{defaultValue:"Project MCP Servers"})}),f?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-3",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading..."]}):p.length>0?e.jsx("div",{className:"space-y-2",children:p.map(y=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-muted/30 rounded-lg border border-border/30",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-primary flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"text-sm font-medium text-foreground",children:y.name})}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${y.type==="stdio"?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300"}`,children:y.type})]},y.id))}):e.jsx("div",{className:"text-sm text-muted-foreground bg-muted/30 rounded-lg px-3 py-3 border border-border/30",children:a("projectSettings.noMcpServers",{defaultValue:"No project-scoped MCP servers configured."})})]})]})]})]}):null}function tn({projects:t,selectedProject:r,selectedSession:s,onProjectSelect:a,onSessionSelect:n,onNewSession:o,onSessionDelete:i,onProjectDelete:c,isLoading:u,loadingProgress:d,onRefresh:m,onShowSettings:h,showSettings:p,settingsInitialTab:g,onCloseSettings:f,isMobile:x}){const{t:b}=We(["sidebar","common"]),{isPWA:N}=wa({trackMobile:!1}),{updateAvailable:j,latestVersion:y,currentVersion:k,releaseInfo:I,dismissUpdate:D}=ho("AnitChaudhry","UpfynAI-Code"),{preferences:C,setPreference:v}=ja(),{sidebarVisible:E}=C,{setCurrentProject:T,mcpServerStatus:W}=fr(),{tasksEnabled:S}=Lr(),[O,H]=l.useState(null),R=l.useCallback(Ce=>H(Ce),[]),A=l.useCallback(()=>H(null),[]),{isSidebarCollapsed:z,expandedProjects:J,editingProject:re,showNewProject:G,editingName:ie,loadingSessions:$,initialSessionsLoaded:Z,currentTime:te,isRefreshing:Q,editingSession:_,editingSessionName:F,searchFilter:q,deletingProjects:U,deleteConfirmation:B,sessionDeleteConfirmation:ee,showVersionModal:V,filteredProjects:w,handleTouchClick:M,toggleProject:Y,handleSessionClick:se,toggleStarProject:de,isProjectStarred:je,getProjectSessions:ge,startEditing:Re,cancelEditing:Ne,saveProjectName:De,showDeleteSessionConfirmation:Ue,confirmDeleteSession:_e,requestProjectDelete:L,confirmDeleteProject:K,loadMoreSessions:pe,handleProjectSelect:ye,refreshProjects:Ie,updateSessionSummary:Fe,collapseSidebar:Se,expandSidebar:Oe,setShowNewProject:ne,setEditingName:fe,setEditingSession:Ee,setEditingSessionName:Le,setSearchFilter:Pe,setDeleteConfirmation:Ae,setSessionDeleteConfirmation:Ge,setShowVersionModal:ae}=Il({projects:t,selectedProject:r,selectedSession:s,isLoading:u,isMobile:x,t:b,onRefresh:m,onProjectSelect:a,onSessionSelect:n,onSessionDelete:i,onProjectDelete:c,setCurrentProject:T,setSidebarVisible:Ce=>v("sidebarVisible",Ce),sidebarVisible:E});l.useEffect(()=>{typeof document>"u"||(document.documentElement.classList.toggle("pwa-mode",N),document.body.classList.toggle("pwa-mode",N))},[N]);const be=()=>{if(window.refreshProjects){window.refreshProjects();return}window.location.reload()},ze={projects:t,filteredProjects:w,selectedProject:r,selectedSession:s,isLoading:u,loadingProgress:d,expandedProjects:J,editingProject:re,editingName:ie,loadingSessions:$,initialSessionsLoaded:Z,currentTime:te,editingSession:_,editingSessionName:F,deletingProjects:U,tasksEnabled:S,mcpServerStatus:W,getProjectSessions:ge,isProjectStarred:je,onEditingNameChange:fe,onToggleProject:Y,onProjectSelect:ye,onToggleStarProject:de,onStartEditingProject:Re,onCancelEditingProject:Ne,onSaveProjectName:Ce=>{De(Ce)},onDeleteProject:L,onSessionSelect:se,onDeleteSession:Ue,onLoadMoreSessions:Ce=>{pe(Ce)},onNewSession:o,onEditingSessionNameChange:Le,onStartEditingSession:(Ce,Ye)=>{Ee(Ce),Le(Ye)},onCancelEditingSession:()=>{Ee(null),Le("")},onSaveEditingSession:(Ce,Ye,lt)=>{Fe(Ce,Ye,lt)},onOpenProjectSettings:R,touchHandlerFactory:M,t:b};return e.jsxs(e.Fragment,{children:[O&&e.jsx(dd,{project:O,isOpen:!0,onClose:A}),e.jsx(cd,{projects:t,showSettings:p,settingsInitialTab:g,onCloseSettings:f,showNewProject:G,onCloseNewProject:()=>ne(!1),onProjectCreated:be,deleteConfirmation:B,onCancelDeleteProject:()=>Ae(null),onConfirmDeleteProject:K,sessionDeleteConfirmation:ee,onCancelDeleteSession:()=>Ge(null),onConfirmDeleteSession:_e,showVersionModal:V,onCloseVersionModal:()=>{ae(!1),D()},releaseInfo:I,currentVersion:k,latestVersion:y,t:b}),z?e.jsx(Ml,{onExpand:Oe,onShowSettings:h,updateAvailable:j,onShowVersionModal:()=>ae(!0),t:b}):e.jsx(e.Fragment,{children:e.jsx(Pc,{isPWA:N,isMobile:x,isLoading:u,projects:t,searchFilter:q,onSearchFilterChange:Pe,onClearSearchFilter:()=>Pe(""),onRefresh:()=>{Ie()},isRefreshing:Q,onCreateProject:()=>ne(!0),onCollapseSidebar:Se,updateAvailable:j,releaseInfo:I,latestVersion:y,onShowVersionModal:()=>ae(!0),onShowSettings:h,projectListProps:ze,t:b})})]})}function ud(){const{isDarkMode:t,toggleDarkMode:r}=pa();return e.jsxs("button",{onClick:r,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":t,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${t?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:t?e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})}):e.jsx("svg",{className:"w-3.5 h-3.5 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})})]})}const md=()=>{const{t}=We("settings"),[r,s]=l.useState(!1),[a,n]=l.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:o}=pa(),{isMobile:i}=wa({trackPWA:!1}),{preferences:c,setPreference:u}=ja(),{autoExpandTools:d,showRawParameters:m,showThinking:h,autoScrollToBottom:p,sendByCtrlEnter:g}=c,[f,x]=l.useState(()=>{const A=localStorage.getItem("quickSettingsHandlePosition");if(A)try{return JSON.parse(A).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[b,N]=l.useState(!1),[j,y]=l.useState(0),[k,I]=l.useState(0),[D,C]=l.useState(!1),v=l.useRef(null),E=l.useRef({min:10,max:90}),T=5;l.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:f}))},[f]);const W=l.useCallback(()=>i?{bottom:`${window.innerHeight*f/100}px`}:{top:`${f}%`,transform:"translateY(-50%)"},[f,i]),S=l.useCallback(A=>{A.stopPropagation();const z=A.type.includes("touch")?A.touches[0].clientY:A.clientY;y(z),I(f),C(!1),N(!1)},[f]),O=l.useCallback(A=>{if(j===0)return;const z=A.type.includes("touch")?A.touches[0].clientY:A.clientY,J=Math.abs(z-j);if(!b&&J>T&&(N(!0),C(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",A.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!b)return;A.type.includes("touch")&&A.preventDefault();const re=z-j;let G;i?G=-(re/window.innerHeight)*100:G=re/window.innerHeight*100;let ie=k+G;ie=Math.max(E.current.min,Math.min(E.current.max,ie)),x(ie)},[b,j,k,i,T]),H=l.useCallback(()=>{N(!1),y(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);l.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),l.useEffect(()=>{if(j!==0){const A=G=>O(G),z=()=>H(),J=G=>O(G),re=()=>H();return document.addEventListener("mousemove",A),document.addEventListener("mouseup",z),document.addEventListener("touchmove",J,{passive:!1}),document.addEventListener("touchend",re),()=>{document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",J),document.removeEventListener("touchend",re)}}},[j,O,H]);const R=A=>{if(D){A.preventDefault(),C(!1);return}s(z=>!z)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:v,onClick:R,onMouseDown:A=>{S(A)},onTouchStart:A=>{S(A)},className:`fixed ${r?"right-64":"right-0"} z-50 ${b?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${b?"border-blue-500 dark:border-blue-400":"border-gray-200 dark:border-gray-700"} rounded-l-md p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors shadow-lg ${b?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...W(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":t(b?"quickSettings.dragHandle.dragging":r?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:t(b?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:b?e.jsx(ki,{className:"h-5 w-5 text-blue-500 dark:text-blue-400"}):r?e.jsx(rr,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(ga,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsx("div",{className:`fixed top-0 right-0 h-full w-64 bg-background border-l border-border shadow-xl transform transition-transform duration-150 ease-out z-40 ${r?"translate-x-0":"translate-x-full"} ${i?"h-screen":""}`,children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(wi,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),t("quickSettings.title")]})}),e.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${i?"pb-mobile-nav":""}`,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.appearance")}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[o?e.jsx(Js,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):e.jsx(Ys,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.darkMode")]}),e.jsx(ud,{})]}),e.jsx("div",{children:e.jsx(_o,{compact:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.toolDisplay")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(ba,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.autoExpandTools")]}),e.jsx("input",{type:"checkbox",checked:d,onChange:A=>u("autoExpandTools",A.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(sr,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.showRawParameters")]}),e.jsx("input",{type:"checkbox",checked:m,onChange:A=>u("showRawParameters",A.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(gs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.showThinking")]}),e.jsx("input",{type:"checkbox",checked:h,onChange:A=>u("showThinking",A.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.viewOptions")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(to,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.autoScrollToBottom")]}),e.jsx("input",{type:"checkbox",checked:p,onChange:A=>u("autoScrollToBottom",A.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.inputSettings")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(eo,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.sendByCtrlEnter")]}),e.jsx("input",{type:"checkbox",checked:g,onChange:A=>u("sendByCtrlEnter",A.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:t("quickSettings.sendByCtrlEnterDescription")})]}),e.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.whisperDictation")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:a==="default",onChange:()=>{n("default"),localStorage.setItem("whisperMode","default"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(es,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.default")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.defaultDescription")})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:a==="prompt",onChange:()=>{n("prompt"),localStorage.setItem("whisperMode","prompt"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(Ut,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.prompt")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.promptDescription")})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:a==="vibe"||a==="instructions"||a==="architect",onChange:()=>{n("vibe"),localStorage.setItem("whisperMode","vibe"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(gt,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.vibe")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.vibeDescription")})]})]})]})]})]})]})}),r&&e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:R})]})};function St(t){return t&&t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function pd(t){if(!t||typeof t!="string")return t;try{return t.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return t}}function Vr(t){if(!t||typeof t!="string")return t;const r=[],s="__MATH_BLOCK_",a="__";let n=t.replace(/\$\$([\s\S]*?)\$\$|\$([^\$\n]+?)\$/g,o=>{const i=r.length;return r.push(o),`${s}${i}${a}`});return n=n.replace(/\\n/g,`
36
- `).replace(/\\t/g," ").replace(/\\r/g,"\r"),n=n.replace(new RegExp(`${s}(\\d+)${a}`,"g"),(o,i)=>r[parseInt(i,10)]),n}function Fo(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zs(t){try{return typeof t!="string"?t:t.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(r,s)=>{let a=parseInt(s,10);if(!Number.isFinite(a))return r;a<1e12&&(a*=1e3);const n=new Date(a),o=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(n),i=-n.getTimezoneOffset(),c=i>=0?"+":"-",u=Math.abs(i),d=Math.floor(u/60),m=u%60,h=`GMT${c}${d}${m?":"+String(m).padStart(2,"0"):""}`,f=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,j=>j.toUpperCase()),x=f?`${h} (${f})`:h,b=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],N=`${n.getDate()} ${b[n.getMonth()]} ${n.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${o} ${x}** - ${N}`})}catch{return t}}const zo=l.createContext(null),xd=zo.Provider;function gd(){return l.useContext(zo)}const hd=l.lazy(()=>kt(()=>import("./MermaidBlock-BuBc_G-F.js"),__vite__mapDeps([0,1,2,3])));function fd(t){return`<!DOCTYPE html>
35
+ `).trim():"",ld=nd;function cd(t){return e.jsx(ld,{...t})}function dd({projects:t,showSettings:r,settingsInitialTab:s,onCloseSettings:a,showNewProject:n,onCloseNewProject:o,onProjectCreated:i,deleteConfirmation:c,onCancelDeleteProject:u,onConfirmDeleteProject:d,sessionDeleteConfirmation:m,onCancelDeleteSession:h,onConfirmDeleteSession:p,showVersionModal:g,onCloseVersionModal:f,releaseInfo:x,currentVersion:b,latestVersion:N,t:j}){const y=l.useMemo(()=>t.map(Il),[t]);return e.jsxs(e.Fragment,{children:[n&&Cr.createPortal(e.jsx(_c,{onClose:o,onProjectCreated:i}),document.body),r&&Cr.createPortal(e.jsx(cd,{isOpen:r,onClose:a,projects:y,initialTab:s}),document.body),c&&Cr.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:e.jsx($t,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:j("deleteConfirmation.deleteProject")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[j("deleteConfirmation.confirmDelete")," ",e.jsx("span",{className:"font-medium text-foreground",children:c.project.displayName||c.project.name}),"?"]}),c.sessionCount>0&&e.jsxs("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 font-medium",children:j("deleteConfirmation.sessionCount",{count:c.sessionCount})}),e.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:j("deleteConfirmation.allConversationsDeleted")})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:j("deleteConfirmation.cannotUndo")})]})]})}),e.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[e.jsx(he,{variant:"outline",className:"flex-1",onClick:u,children:j("actions.cancel")}),e.jsxs(he,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:d,children:[e.jsx(yt,{className:"w-4 h-4 mr-2"}),j("actions.delete")]})]})]})}),document.body),m&&Cr.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:e.jsx($t,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:j("deleteConfirmation.deleteSession")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[j("deleteConfirmation.confirmDelete")," ",e.jsx("span",{className:"font-medium text-foreground",children:m.sessionTitle||j("sessions.unnamed")}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:j("deleteConfirmation.cannotUndo")})]})]})}),e.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[e.jsx(he,{variant:"outline",className:"flex-1",onClick:h,children:j("actions.cancel")}),e.jsxs(he,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:p,children:[e.jsx(yt,{className:"w-4 h-4 mr-2"}),j("actions.delete")]})]})]})}),document.body),e.jsx(od,{isOpen:g,onClose:f,releaseInfo:x,currentVersion:b,latestVersion:N})]})}function ud({project:t,isOpen:r,onClose:s}){var j;const{t:a}=We("sidebar"),[n,o]=l.useState(null),[i,c]=l.useState(null),[u,d]=l.useState(!1),[m,h]=l.useState(null),[p,g]=l.useState([]),[f,x]=l.useState(!1),b=l.useCallback(async()=>{d(!0),h(null);try{const k=await(await Me(`/api/projects/${encodeURIComponent(t.name)}/claude-md`)).json();o(k.content),c(k.path||null),k.error&&h(k.error)}catch{h("Failed to fetch CLAUDE.md")}finally{d(!1)}},[t.name]),N=l.useCallback(async()=>{x(!0);try{const y=t.fullPath||t.path||"",I=await(await Me(`/api/mcp/config/read?projectPath=${encodeURIComponent(y)}`)).json();I.success&&I.servers?g(I.servers.filter(D=>D.scope==="project"||D.scope==="local")):g([])}catch{g([])}finally{x(!1)}},[t.fullPath,t.path]);return l.useEffect(()=>{r&&(b(),N())},[r,b,N]),l.useEffect(()=>{if(!r)return;const y=k=>{k.key==="Escape"&&s()};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[r,s]),r?e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:s}),e.jsxs("div",{className:"relative ml-auto w-full sm:max-w-md bg-card border-l border-border shadow-2xl flex flex-col h-full animate-in slide-in-from-right duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/30",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground truncate",children:t.displayName}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",title:t.fullPath,children:t.fullPath})]}),e.jsx("button",{onClick:s,className:"ml-3 w-10 h-10 sm:w-7 sm:h-7 rounded-md hover:bg-accent flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-5 pb-[max(1rem,env(safe-area-inset-bottom))]",children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:a("projectSettings.quickInfo",{defaultValue:"Quick Info"})}),e.jsxs("div",{className:"space-y-1.5 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),e.jsx("span",{className:"truncate",children:t.fullPath})]}),((j=t.taskmaster)==null?void 0:j.hasTaskmaster)&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),e.jsxs("span",{children:["TaskMaster: ",e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"Active"})]})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:"CLAUDE.md"}),u?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-3",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading..."]}):m?e.jsx("div",{className:"text-sm text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 rounded-lg px-3 py-2",children:m}):n?e.jsxs("div",{className:"bg-muted/50 rounded-lg border border-border/50 overflow-hidden",children:[e.jsx("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 bg-muted/30",children:e.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate",children:i})}),e.jsx("pre",{className:"px-3 py-2 text-xs text-foreground overflow-x-auto max-h-[300px] overflow-y-auto whitespace-pre-wrap font-mono leading-relaxed",children:n})]}):e.jsx("div",{className:"text-sm text-muted-foreground bg-muted/30 rounded-lg px-3 py-3 border border-border/30",children:a("projectSettings.noClaudeMd",{defaultValue:"No CLAUDE.md found in this project."})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:a("projectSettings.mcpServers",{defaultValue:"Project MCP Servers"})}),f?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-3",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading..."]}):p.length>0?e.jsx("div",{className:"space-y-2",children:p.map(y=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-muted/30 rounded-lg border border-border/30",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-primary flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"text-sm font-medium text-foreground",children:y.name})}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${y.type==="stdio"?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300"}`,children:y.type})]},y.id))}):e.jsx("div",{className:"text-sm text-muted-foreground bg-muted/30 rounded-lg px-3 py-3 border border-border/30",children:a("projectSettings.noMcpServers",{defaultValue:"No project-scoped MCP servers configured."})})]})]})]})]}):null}function rn({projects:t,selectedProject:r,selectedSession:s,onProjectSelect:a,onSessionSelect:n,onNewSession:o,onSessionDelete:i,onProjectDelete:c,isLoading:u,loadingProgress:d,onRefresh:m,onShowSettings:h,showSettings:p,settingsInitialTab:g,onCloseSettings:f,isMobile:x}){const{t:b}=We(["sidebar","common"]),{isPWA:N}=ja({trackMobile:!1}),{updateAvailable:j,latestVersion:y,currentVersion:k,releaseInfo:I,dismissUpdate:D}=fo("AnitChaudhry","UpfynAI-Code"),{preferences:C,setPreference:v}=Na(),{sidebarVisible:E}=C,{setCurrentProject:T,mcpServerStatus:W}=fr(),{tasksEnabled:S}=Lr(),[O,H]=l.useState(null),R=l.useCallback(Ce=>H(Ce),[]),A=l.useCallback(()=>H(null),[]),{isSidebarCollapsed:z,expandedProjects:J,editingProject:re,showNewProject:G,editingName:ie,loadingSessions:$,initialSessionsLoaded:Z,currentTime:te,isRefreshing:Q,editingSession:_,editingSessionName:F,searchFilter:q,deletingProjects:U,deleteConfirmation:B,sessionDeleteConfirmation:ee,showVersionModal:V,filteredProjects:w,handleTouchClick:M,toggleProject:Y,handleSessionClick:se,toggleStarProject:de,isProjectStarred:je,getProjectSessions:ge,startEditing:Re,cancelEditing:Ne,saveProjectName:De,showDeleteSessionConfirmation:Ue,confirmDeleteSession:_e,requestProjectDelete:L,confirmDeleteProject:K,loadMoreSessions:pe,handleProjectSelect:ye,refreshProjects:Ie,updateSessionSummary:Fe,collapseSidebar:Se,expandSidebar:Oe,setShowNewProject:ne,setEditingName:fe,setEditingSession:Ee,setEditingSessionName:Le,setSearchFilter:Pe,setDeleteConfirmation:Ae,setSessionDeleteConfirmation:Ge,setShowVersionModal:ae}=Ml({projects:t,selectedProject:r,selectedSession:s,isLoading:u,isMobile:x,t:b,onRefresh:m,onProjectSelect:a,onSessionSelect:n,onSessionDelete:i,onProjectDelete:c,setCurrentProject:T,setSidebarVisible:Ce=>v("sidebarVisible",Ce),sidebarVisible:E});l.useEffect(()=>{typeof document>"u"||(document.documentElement.classList.toggle("pwa-mode",N),document.body.classList.toggle("pwa-mode",N))},[N]);const be=()=>{if(window.refreshProjects){window.refreshProjects();return}window.location.reload()},ze={projects:t,filteredProjects:w,selectedProject:r,selectedSession:s,isLoading:u,loadingProgress:d,expandedProjects:J,editingProject:re,editingName:ie,loadingSessions:$,initialSessionsLoaded:Z,currentTime:te,editingSession:_,editingSessionName:F,deletingProjects:U,tasksEnabled:S,mcpServerStatus:W,getProjectSessions:ge,isProjectStarred:je,onEditingNameChange:fe,onToggleProject:Y,onProjectSelect:ye,onToggleStarProject:de,onStartEditingProject:Re,onCancelEditingProject:Ne,onSaveProjectName:Ce=>{De(Ce)},onDeleteProject:L,onSessionSelect:se,onDeleteSession:Ue,onLoadMoreSessions:Ce=>{pe(Ce)},onNewSession:o,onEditingSessionNameChange:Le,onStartEditingSession:(Ce,Ye)=>{Ee(Ce),Le(Ye)},onCancelEditingSession:()=>{Ee(null),Le("")},onSaveEditingSession:(Ce,Ye,lt)=>{Fe(Ce,Ye,lt)},onOpenProjectSettings:R,touchHandlerFactory:M,t:b};return e.jsxs(e.Fragment,{children:[O&&e.jsx(ud,{project:O,isOpen:!0,onClose:A}),e.jsx(dd,{projects:t,showSettings:p,settingsInitialTab:g,onCloseSettings:f,showNewProject:G,onCloseNewProject:()=>ne(!1),onProjectCreated:be,deleteConfirmation:B,onCancelDeleteProject:()=>Ae(null),onConfirmDeleteProject:K,sessionDeleteConfirmation:ee,onCancelDeleteSession:()=>Ge(null),onConfirmDeleteSession:_e,showVersionModal:V,onCloseVersionModal:()=>{ae(!1),D()},releaseInfo:I,currentVersion:k,latestVersion:y,t:b}),z?e.jsx(Dl,{onExpand:Oe,onShowSettings:h,updateAvailable:j,onShowVersionModal:()=>ae(!0),t:b}):e.jsx(e.Fragment,{children:e.jsx($c,{isPWA:N,isMobile:x,isLoading:u,projects:t,searchFilter:q,onSearchFilterChange:Pe,onClearSearchFilter:()=>Pe(""),onRefresh:()=>{Ie()},isRefreshing:Q,onCreateProject:()=>ne(!0),onCollapseSidebar:Se,updateAvailable:j,releaseInfo:I,latestVersion:y,onShowVersionModal:()=>ae(!0),onShowSettings:h,projectListProps:ze,t:b})})]})}function md(){const{isDarkMode:t,toggleDarkMode:r}=xa();return e.jsxs("button",{onClick:r,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":t,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${t?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:t?e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})}):e.jsx("svg",{className:"w-3.5 h-3.5 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})})]})}const pd=()=>{const{t}=We("settings"),[r,s]=l.useState(!1),[a,n]=l.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:o}=xa(),{isMobile:i}=ja({trackPWA:!1}),{preferences:c,setPreference:u}=Na(),{autoExpandTools:d,showRawParameters:m,showThinking:h,autoScrollToBottom:p,sendByCtrlEnter:g}=c,[f,x]=l.useState(()=>{const A=localStorage.getItem("quickSettingsHandlePosition");if(A)try{return JSON.parse(A).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[b,N]=l.useState(!1),[j,y]=l.useState(0),[k,I]=l.useState(0),[D,C]=l.useState(!1),v=l.useRef(null),E=l.useRef({min:10,max:90}),T=5;l.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:f}))},[f]);const W=l.useCallback(()=>i?{bottom:`${window.innerHeight*f/100}px`}:{top:`${f}%`,transform:"translateY(-50%)"},[f,i]),S=l.useCallback(A=>{A.stopPropagation();const z=A.type.includes("touch")?A.touches[0].clientY:A.clientY;y(z),I(f),C(!1),N(!1)},[f]),O=l.useCallback(A=>{if(j===0)return;const z=A.type.includes("touch")?A.touches[0].clientY:A.clientY,J=Math.abs(z-j);if(!b&&J>T&&(N(!0),C(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",A.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!b)return;A.type.includes("touch")&&A.preventDefault();const re=z-j;let G;i?G=-(re/window.innerHeight)*100:G=re/window.innerHeight*100;let ie=k+G;ie=Math.max(E.current.min,Math.min(E.current.max,ie)),x(ie)},[b,j,k,i,T]),H=l.useCallback(()=>{N(!1),y(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);l.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),l.useEffect(()=>{if(j!==0){const A=G=>O(G),z=()=>H(),J=G=>O(G),re=()=>H();return document.addEventListener("mousemove",A),document.addEventListener("mouseup",z),document.addEventListener("touchmove",J,{passive:!1}),document.addEventListener("touchend",re),()=>{document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",J),document.removeEventListener("touchend",re)}}},[j,O,H]);const R=A=>{if(D){A.preventDefault(),C(!1);return}s(z=>!z)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:v,onClick:R,onMouseDown:A=>{S(A)},onTouchStart:A=>{S(A)},className:`fixed ${r?"right-64":"right-0"} z-50 ${b?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${b?"border-blue-500 dark:border-blue-400":"border-gray-200 dark:border-gray-700"} rounded-l-md p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors shadow-lg ${b?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...W(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":t(b?"quickSettings.dragHandle.dragging":r?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:t(b?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:b?e.jsx(wi,{className:"h-5 w-5 text-blue-500 dark:text-blue-400"}):r?e.jsx(rr,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(ha,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsx("div",{className:`fixed top-0 right-0 h-full w-64 bg-background border-l border-border shadow-xl transform transition-transform duration-150 ease-out z-40 ${r?"translate-x-0":"translate-x-full"} ${i?"h-screen":""}`,children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(ji,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),t("quickSettings.title")]})}),e.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${i?"pb-mobile-nav":""}`,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.appearance")}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[o?e.jsx(Ys,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):e.jsx(Qs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.darkMode")]}),e.jsx(md,{})]}),e.jsx("div",{children:e.jsx(Fo,{compact:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.toolDisplay")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(ya,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.autoExpandTools")]}),e.jsx("input",{type:"checkbox",checked:d,onChange:A=>u("autoExpandTools",A.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(sr,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.showRawParameters")]}),e.jsx("input",{type:"checkbox",checked:m,onChange:A=>u("showRawParameters",A.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(gs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.showThinking")]}),e.jsx("input",{type:"checkbox",checked:h,onChange:A=>u("showThinking",A.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.viewOptions")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(ro,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.autoScrollToBottom")]}),e.jsx("input",{type:"checkbox",checked:p,onChange:A=>u("autoScrollToBottom",A.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.inputSettings")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(to,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.sendByCtrlEnter")]}),e.jsx("input",{type:"checkbox",checked:g,onChange:A=>u("sendByCtrlEnter",A.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:t("quickSettings.sendByCtrlEnterDescription")})]}),e.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.whisperDictation")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:a==="default",onChange:()=>{n("default"),localStorage.setItem("whisperMode","default"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(es,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.default")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.defaultDescription")})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:a==="prompt",onChange:()=>{n("prompt"),localStorage.setItem("whisperMode","prompt"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(Ut,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.prompt")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.promptDescription")})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:a==="vibe"||a==="instructions"||a==="architect",onChange:()=>{n("vibe"),localStorage.setItem("whisperMode","vibe"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(gt,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.vibe")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.vibeDescription")})]})]})]})]})]})]})}),r&&e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:R})]})};function St(t){return t&&t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function xd(t){if(!t||typeof t!="string")return t;try{return t.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return t}}function Vr(t){if(!t||typeof t!="string")return t;const r=[],s="__MATH_BLOCK_",a="__";let n=t.replace(/\$\$([\s\S]*?)\$\$|\$([^\$\n]+?)\$/g,o=>{const i=r.length;return r.push(o),`${s}${i}${a}`});return n=n.replace(/\\n/g,`
36
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r"),n=n.replace(new RegExp(`${s}(\\d+)${a}`,"g"),(o,i)=>r[parseInt(i,10)]),n}function zo(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ea(t){try{return typeof t!="string"?t:t.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(r,s)=>{let a=parseInt(s,10);if(!Number.isFinite(a))return r;a<1e12&&(a*=1e3);const n=new Date(a),o=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(n),i=-n.getTimezoneOffset(),c=i>=0?"+":"-",u=Math.abs(i),d=Math.floor(u/60),m=u%60,h=`GMT${c}${d}${m?":"+String(m).padStart(2,"0"):""}`,f=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,j=>j.toUpperCase()),x=f?`${h} (${f})`:h,b=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],N=`${n.getDate()} ${b[n.getMonth()]} ${n.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${o} ${x}** - ${N}`})}catch{return t}}const Ro=l.createContext(null),gd=Ro.Provider;function hd(){return l.useContext(Ro)}const fd=l.lazy(()=>kt(()=>import("./MermaidBlock-BuBc_G-F.js"),__vite__mapDeps([0,1,2,3])));function bd(t){return`<!DOCTYPE html>
37
37
  <html><head>
38
38
  <meta charset="utf-8" />
39
39
  <meta name="viewport" content="width=device-width, initial-scale=1" />
@@ -58,10 +58,10 @@ if (_App) {
58
58
  } else {
59
59
  document.getElementById('root').innerHTML = '<p style="color:#666">No component found to render</p>';
60
60
  }
61
- <\/script></body></html>`}const bd=new Set(["html","jsx","tsx","react"]);function yd(t,r){return!!(bd.has(t)||t==="text"&&r.trim().startsWith("<!DOCTYPE")||r.trim().startsWith("<html"))}function rn(t,r){return t==="jsx"||t==="tsx"||t==="react"?fd(r):r.trim().toLowerCase().startsWith("<!doctype")||r.trim().toLowerCase().startsWith("<html")?r:`<!DOCTYPE html><html><head>
61
+ <\/script></body></html>`}const yd=new Set(["html","jsx","tsx","react"]);function vd(t,r){return!!(yd.has(t)||t==="text"&&r.trim().startsWith("<!DOCTYPE")||r.trim().startsWith("<html"))}function sn(t,r){return t==="jsx"||t==="tsx"||t==="react"?bd(r):r.trim().toLowerCase().startsWith("<!doctype")||r.trim().toLowerCase().startsWith("<html")?r:`<!DOCTYPE html><html><head>
62
62
  <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
63
63
  <style>body{margin:0;padding:16px;font-family:system-ui,sans-serif}</style>
64
- </head><body>${r}</body></html>`}const vd=({node:t,inline:r,className:s,children:a,...n})=>{const{t:o}=We("chat"),[i,c]=l.useState(!1),[u,d]=l.useState("code"),m=gd(),h=Array.isArray(a)?a.join(""):String(a??""),p=/[\r\n]/.test(h);if(r||t&&t.type==="inlineCode"||!p)return e.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${s||""}`,...n,children:a});const x=/language-(\w+)/.exec(s||""),b=x?x[1]:"text",N=yd(b,h);if(b==="mermaid")return e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"my-2 p-4 rounded-lg bg-slate-900/50 border border-slate-700 text-sm text-slate-500",children:"Loading diagram..."}),children:e.jsx(hd,{code:h})});const j=h,y=()=>{const I=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(j).then(I).catch(()=>{const D=document.createElement("textarea");D.value=j,D.style.position="fixed",D.style.opacity="0",document.body.appendChild(D),D.select();try{document.execCommand("copy")}catch{}document.body.removeChild(D),I()});else{const D=document.createElement("textarea");D.value=j,D.style.position="fixed",D.style.opacity="0",document.body.appendChild(D),D.select();try{document.execCommand("copy")}catch{}document.body.removeChild(D),I()}}catch{}},k=()=>{m&&m({id:`html-preview-${Date.now()}`,type:"html",title:b==="html"?"HTML Preview":"React Preview",data:{html:rn(b,h)}})};return e.jsxs("div",{className:"relative group my-2",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800 rounded-t-lg border-b border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[b&&b!=="text"&&e.jsx("span",{className:"text-xs text-gray-400 font-medium uppercase",children:b}),N&&e.jsxs("div",{className:"flex items-center rounded-md bg-gray-700/50 p-0.5",children:[e.jsx("button",{type:"button",onClick:()=>d("code"),className:`text-[10px] px-2 py-0.5 rounded transition-colors ${u==="code"?"bg-gray-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:"Code"}),e.jsx("button",{type:"button",onClick:()=>d("preview"),className:`text-[10px] px-2 py-0.5 rounded transition-colors ${u==="preview"?"bg-blue-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:"Preview"})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[N&&m&&e.jsx("button",{type:"button",onClick:k,className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs px-1.5 py-0.5 rounded-md bg-gray-700/80 hover:bg-gray-700 text-gray-300 border border-gray-600",title:"Open in side panel",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),e.jsx("button",{type:"button",onClick:y,className:"opacity-0 group-hover:opacity-100 focus:opacity-100 active:opacity-100 transition-opacity text-xs px-2 py-0.5 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",title:o(i?"codeBlock.copied":"codeBlock.copyCode"),"aria-label":o(i?"codeBlock.copied":"codeBlock.copyCode"),children:i?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),o("codeBlock.copied")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),o("codeBlock.copy")]})})]})]}),u==="code"&&e.jsx(co,{language:b,style:uo,customStyle:{margin:0,borderRadius:"0 0 0.5rem 0.5rem",fontSize:"0.875rem",padding:"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:h}),u==="preview"&&N&&e.jsx("div",{className:"bg-white rounded-b-lg overflow-hidden border border-gray-700 border-t-0",children:e.jsx("iframe",{srcDoc:rn(b,h),sandbox:"allow-scripts allow-same-origin",className:"w-full border-0",style:{minHeight:"200px",height:"400px"},title:"Code preview"})})]})},kd={code:vd,blockquote:({children:t})=>e.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:t}),a:({href:t,children:r})=>e.jsx("a",{href:t,className:"text-blue-600 dark:text-blue-400 hover:underline",target:"_blank",rel:"noopener noreferrer",children:r}),p:({children:t})=>e.jsx("div",{className:"mb-2 last:mb-0",children:t}),table:({children:t})=>e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:t})}),thead:({children:t})=>e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:t}),th:({children:t})=>e.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:t}),td:({children:t})=>e.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:t})};function Qt({children:t,className:r}){const s=pd(String(t??"")),a=l.useMemo(()=>[qi,Ki],[]),n=l.useMemo(()=>[Ji],[]);return e.jsx("div",{className:r,children:e.jsx(Yi,{remarkPlugins:a,rehypePlugins:n,components:kd,children:s})})}const Ro="claude-settings",ot={setItem:(t,r)=>{try{if(t.startsWith("chat_messages_")&&typeof r=="string")try{const s=JSON.parse(r);if(Array.isArray(s)&&s.length>50){const a=s.slice(-50);r=JSON.stringify(a)}}catch(s){console.warn("Could not parse chat messages for truncation:",s)}localStorage.setItem(t,r)}catch(s){if((s==null?void 0:s.name)==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const a=Object.keys(localStorage),n=a.filter(i=>i.startsWith("chat_messages_")).sort();n.length>3&&n.slice(0,n.length-3).forEach(i=>{localStorage.removeItem(i)}),a.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(t,r)}catch(i){if(console.error("Failed to save to localStorage even after cleanup:",i),t.startsWith("chat_messages_")&&typeof r=="string")try{const c=JSON.parse(r);if(Array.isArray(c)&&c.length>10){const u=c.slice(-10);localStorage.setItem(t,JSON.stringify(u))}}catch(c){console.error("Final save attempt failed:",c)}}}else console.error("localStorage error:",s)}},getItem:t=>{try{return localStorage.getItem(t)}catch(r){return console.error("localStorage getItem error:",r),null}},removeItem:t=>{try{localStorage.removeItem(t)}catch(r){console.error("localStorage removeItem error:",r)}}};function Ea(){const t=ot.getItem(Ro);if(!t)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const r=JSON.parse(t);return{...r,allowedTools:Array.isArray(r.allowedTools)?r.allowedTools:[],disallowedTools:Array.isArray(r.disallowedTools)?r.disallowedTools:[],skipPermissions:!!r.skipPermissions,projectSortOrder:r.projectSortOrder||"name"}}catch{return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"}}}function ea(t,r){if(!t)return null;if(t!=="Bash")return t;const s=kc(r),a=typeof(s==null?void 0:s.command)=="string"?s.command.trim():"";if(!a)return t;const n=a.split(/\s+/);return n.length===0?t:n[0]==="git"&&n[1]?`Bash(${n[0]} ${n[1]}:*)`:`Bash(${n[0]}:*)`}function sn(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function wd(t,r){var i;if(r!=="claude"||!((i=t==null?void 0:t.toolResult)!=null&&i.isError))return null;const s=t==null?void 0:t.toolName,a=ea(s,t.toolInput);if(!a)return null;const o=Ea().allowedTools.includes(a);return{toolName:s||"UnknownTool",entry:a,isAllowed:o}}function jd(t){if(!t)return{success:!1};const r=Ea(),s=r.allowedTools.includes(t),a=s?r.allowedTools:[...r.allowedTools,t],n=r.disallowedTools.filter(i=>i!==t),o={...r,allowedTools:a,disallowedTools:n,lastUpdated:new Date().toISOString()};return ot.setItem(Ro,JSON.stringify(o)),{success:!0,alreadyAllowed:s,updatedSettings:o}}const an={Bash:{input:{type:"one-line",icon:"terminal",getValue:t=>t.command,getSecondary:t=>t.description,action:"copy",style:"terminal",wrapText:!0,colorScheme:{primary:"text-green-400 font-mono",secondary:"text-gray-400",background:"",border:"border-green-500 dark:border-green-400",icon:"text-green-500 dark:text-green-400"}},result:{hideOnSuccess:!0,type:"special"}},Read:{input:{type:"one-line",label:"Read",getValue:t=>t.file_path||"",action:"open-file",colorScheme:{primary:"text-gray-700 dark:text-gray-300",background:"",border:"border-gray-300 dark:border-gray-600",icon:"text-gray-500 dark:text-gray-400"}},result:{hidden:!0}},Edit:{input:{type:"collapsible",title:t=>{var s;return`${((s=t.file_path)==null?void 0:s.split("/").pop())||t.file_path||"file"}`},defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:t.old_string,newContent:t.new_string,filePath:t.file_path,badge:"Edit",badgeColor:"gray"})},result:{hideOnSuccess:!0}},Write:{input:{type:"collapsible",title:t=>{var s;return`${((s=t.file_path)==null?void 0:s.split("/").pop())||t.file_path||"file"}`},defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:"",newContent:t.content,filePath:t.file_path,badge:"New",badgeColor:"green"})},result:{hideOnSuccess:!0}},ApplyPatch:{input:{type:"collapsible",title:t=>{var s;return`${((s=t.file_path)==null?void 0:s.split("/").pop())||t.file_path||"file"}`},defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:t.old_string,newContent:t.new_string,filePath:t.file_path,badge:"Patch",badgeColor:"gray"})},result:{hideOnSuccess:!0}},Grep:{input:{type:"one-line",label:"Grep",getValue:t=>t.pattern,getSecondary:t=>t.path?`in ${t.path}`:void 0,action:"jump-to-results",colorScheme:{primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-400 dark:border-gray-500",icon:"text-gray-500 dark:text-gray-400"}},result:{type:"collapsible",defaultOpen:!1,title:t=>{var a;const r=t.toolUseResult||{},s=r.numFiles||((a=r.filenames)==null?void 0:a.length)||0;return`Found ${s} ${s===1?"file":"files"}`},contentType:"file-list",getContentProps:t=>({files:(t.toolUseResult||{}).filenames||[]})}},Glob:{input:{type:"one-line",label:"Glob",getValue:t=>t.pattern,getSecondary:t=>t.path?`in ${t.path}`:void 0,action:"jump-to-results",colorScheme:{primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-400 dark:border-gray-500",icon:"text-gray-500 dark:text-gray-400"}},result:{type:"collapsible",defaultOpen:!1,title:t=>{var a;const r=t.toolUseResult||{},s=r.numFiles||((a=r.filenames)==null?void 0:a.length)||0;return`Found ${s} ${s===1?"file":"files"}`},contentType:"file-list",getContentProps:t=>({files:(t.toolUseResult||{}).filenames||[]})}},TodoWrite:{input:{type:"collapsible",title:"Updating todo list",defaultOpen:!1,contentType:"todo-list",getContentProps:t=>({todos:t.todos})},result:{type:"collapsible",contentType:"success-message",getMessage:()=>"Todo list updated"}},TodoRead:{input:{type:"one-line",label:"TodoRead",getValue:()=>"reading list",action:"none",colorScheme:{primary:"text-gray-500 dark:text-gray-400",border:"border-violet-400 dark:border-violet-500"}},result:{type:"collapsible",contentType:"todo-list",getContentProps:t=>{try{const r=String(t.content||"");let s=null;return r.startsWith("[")&&(s=JSON.parse(r)),{todos:s,isResult:!0}}catch{return{todos:[],isResult:!0}}}}},TaskCreate:{input:{type:"one-line",label:"Task",getValue:t=>t.subject||"Creating task",getSecondary:t=>t.status||void 0,action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{hideOnSuccess:!0}},TaskUpdate:{input:{type:"one-line",label:"Task",getValue:t=>{const r=[];return t.taskId&&r.push(`#${t.taskId}`),t.status&&r.push(t.status),t.subject&&r.push(`"${t.subject}"`),r.join(" → ")||"updating"},action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{hideOnSuccess:!0}},TaskList:{input:{type:"one-line",label:"Tasks",getValue:()=>"listing tasks",action:"none",colorScheme:{primary:"text-gray-500 dark:text-gray-400",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{type:"collapsible",defaultOpen:!0,title:"Task list",contentType:"task",getContentProps:t=>({content:String((t==null?void 0:t.content)||"")})}},TaskGet:{input:{type:"one-line",label:"Task",getValue:t=>t.taskId?`#${t.taskId}`:"fetching",action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{type:"collapsible",defaultOpen:!0,title:"Task details",contentType:"task",getContentProps:t=>({content:String((t==null?void 0:t.content)||"")})}},Task:{input:{type:"collapsible",title:t=>{const r=t.subagent_type||"Agent",s=t.description||"Running task";return`Subagent / ${r}: ${s}`},defaultOpen:!1,contentType:"markdown",getContentProps:t=>{if(t.prompt&&!t.model&&!t.resume)return{content:t.prompt||""};const s=[];return t.model&&s.push(`**Model:** ${t.model}`),t.prompt&&s.push(`**Prompt:**
64
+ </head><body>${r}</body></html>`}const kd=({node:t,inline:r,className:s,children:a,...n})=>{const{t:o}=We("chat"),[i,c]=l.useState(!1),[u,d]=l.useState("code"),m=hd(),h=Array.isArray(a)?a.join(""):String(a??""),p=/[\r\n]/.test(h);if(r||t&&t.type==="inlineCode"||!p)return e.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${s||""}`,...n,children:a});const x=/language-(\w+)/.exec(s||""),b=x?x[1]:"text",N=vd(b,h);if(b==="mermaid")return e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"my-2 p-4 rounded-lg bg-slate-900/50 border border-slate-700 text-sm text-slate-500",children:"Loading diagram..."}),children:e.jsx(fd,{code:h})});const j=h,y=()=>{const I=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(j).then(I).catch(()=>{const D=document.createElement("textarea");D.value=j,D.style.position="fixed",D.style.opacity="0",document.body.appendChild(D),D.select();try{document.execCommand("copy")}catch{}document.body.removeChild(D),I()});else{const D=document.createElement("textarea");D.value=j,D.style.position="fixed",D.style.opacity="0",document.body.appendChild(D),D.select();try{document.execCommand("copy")}catch{}document.body.removeChild(D),I()}}catch{}},k=()=>{m&&m({id:`html-preview-${Date.now()}`,type:"html",title:b==="html"?"HTML Preview":"React Preview",data:{html:sn(b,h)}})};return e.jsxs("div",{className:"relative group my-2",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800 rounded-t-lg border-b border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[b&&b!=="text"&&e.jsx("span",{className:"text-xs text-gray-400 font-medium uppercase",children:b}),N&&e.jsxs("div",{className:"flex items-center rounded-md bg-gray-700/50 p-0.5",children:[e.jsx("button",{type:"button",onClick:()=>d("code"),className:`text-[10px] px-2 py-0.5 rounded transition-colors ${u==="code"?"bg-gray-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:"Code"}),e.jsx("button",{type:"button",onClick:()=>d("preview"),className:`text-[10px] px-2 py-0.5 rounded transition-colors ${u==="preview"?"bg-blue-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:"Preview"})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[N&&m&&e.jsx("button",{type:"button",onClick:k,className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs px-1.5 py-0.5 rounded-md bg-gray-700/80 hover:bg-gray-700 text-gray-300 border border-gray-600",title:"Open in side panel",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),e.jsx("button",{type:"button",onClick:y,className:"opacity-0 group-hover:opacity-100 focus:opacity-100 active:opacity-100 transition-opacity text-xs px-2 py-0.5 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",title:o(i?"codeBlock.copied":"codeBlock.copyCode"),"aria-label":o(i?"codeBlock.copied":"codeBlock.copyCode"),children:i?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),o("codeBlock.copied")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),o("codeBlock.copy")]})})]})]}),u==="code"&&e.jsx(uo,{language:b,style:mo,customStyle:{margin:0,borderRadius:"0 0 0.5rem 0.5rem",fontSize:"0.875rem",padding:"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:h}),u==="preview"&&N&&e.jsx("div",{className:"bg-white rounded-b-lg overflow-hidden border border-gray-700 border-t-0",children:e.jsx("iframe",{srcDoc:sn(b,h),sandbox:"allow-scripts allow-same-origin",className:"w-full border-0",style:{minHeight:"200px",height:"400px"},title:"Code preview"})})]})},wd={code:kd,blockquote:({children:t})=>e.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:t}),a:({href:t,children:r})=>e.jsx("a",{href:t,className:"text-blue-600 dark:text-blue-400 hover:underline",target:"_blank",rel:"noopener noreferrer",children:r}),p:({children:t})=>e.jsx("div",{className:"mb-2 last:mb-0",children:t}),table:({children:t})=>e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:t})}),thead:({children:t})=>e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:t}),th:({children:t})=>e.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:t}),td:({children:t})=>e.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:t})};function Qt({children:t,className:r}){const s=xd(String(t??"")),a=l.useMemo(()=>[Ki,Ji],[]),n=l.useMemo(()=>[Yi],[]);return e.jsx("div",{className:r,children:e.jsx(Qi,{remarkPlugins:a,rehypePlugins:n,components:wd,children:s})})}const Oo="claude-settings",ot={setItem:(t,r)=>{try{if(t.startsWith("chat_messages_")&&typeof r=="string")try{const s=JSON.parse(r);if(Array.isArray(s)&&s.length>50){const a=s.slice(-50);r=JSON.stringify(a)}}catch(s){console.warn("Could not parse chat messages for truncation:",s)}localStorage.setItem(t,r)}catch(s){if((s==null?void 0:s.name)==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const a=Object.keys(localStorage),n=a.filter(i=>i.startsWith("chat_messages_")).sort();n.length>3&&n.slice(0,n.length-3).forEach(i=>{localStorage.removeItem(i)}),a.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(t,r)}catch(i){if(console.error("Failed to save to localStorage even after cleanup:",i),t.startsWith("chat_messages_")&&typeof r=="string")try{const c=JSON.parse(r);if(Array.isArray(c)&&c.length>10){const u=c.slice(-10);localStorage.setItem(t,JSON.stringify(u))}}catch(c){console.error("Final save attempt failed:",c)}}}else console.error("localStorage error:",s)}},getItem:t=>{try{return localStorage.getItem(t)}catch(r){return console.error("localStorage getItem error:",r),null}},removeItem:t=>{try{localStorage.removeItem(t)}catch(r){console.error("localStorage removeItem error:",r)}}};function Ta(){const t=ot.getItem(Oo);if(!t)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const r=JSON.parse(t);return{...r,allowedTools:Array.isArray(r.allowedTools)?r.allowedTools:[],disallowedTools:Array.isArray(r.disallowedTools)?r.disallowedTools:[],skipPermissions:!!r.skipPermissions,projectSortOrder:r.projectSortOrder||"name"}}catch{return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"}}}function ta(t,r){if(!t)return null;if(t!=="Bash")return t;const s=wc(r),a=typeof(s==null?void 0:s.command)=="string"?s.command.trim():"";if(!a)return t;const n=a.split(/\s+/);return n.length===0?t:n[0]==="git"&&n[1]?`Bash(${n[0]} ${n[1]}:*)`:`Bash(${n[0]}:*)`}function an(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function jd(t,r){var i;if(r!=="claude"||!((i=t==null?void 0:t.toolResult)!=null&&i.isError))return null;const s=t==null?void 0:t.toolName,a=ta(s,t.toolInput);if(!a)return null;const o=Ta().allowedTools.includes(a);return{toolName:s||"UnknownTool",entry:a,isAllowed:o}}function Nd(t){if(!t)return{success:!1};const r=Ta(),s=r.allowedTools.includes(t),a=s?r.allowedTools:[...r.allowedTools,t],n=r.disallowedTools.filter(i=>i!==t),o={...r,allowedTools:a,disallowedTools:n,lastUpdated:new Date().toISOString()};return ot.setItem(Oo,JSON.stringify(o)),{success:!0,alreadyAllowed:s,updatedSettings:o}}const nn={Bash:{input:{type:"one-line",icon:"terminal",getValue:t=>t.command,getSecondary:t=>t.description,action:"copy",style:"terminal",wrapText:!0,colorScheme:{primary:"text-green-400 font-mono",secondary:"text-gray-400",background:"",border:"border-green-500 dark:border-green-400",icon:"text-green-500 dark:text-green-400"}},result:{hideOnSuccess:!0,type:"special"}},Read:{input:{type:"one-line",label:"Read",getValue:t=>t.file_path||"",action:"open-file",colorScheme:{primary:"text-gray-700 dark:text-gray-300",background:"",border:"border-gray-300 dark:border-gray-600",icon:"text-gray-500 dark:text-gray-400"}},result:{hidden:!0}},Edit:{input:{type:"collapsible",title:t=>{var s;return`${((s=t.file_path)==null?void 0:s.split("/").pop())||t.file_path||"file"}`},defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:t.old_string,newContent:t.new_string,filePath:t.file_path,badge:"Edit",badgeColor:"gray"})},result:{hideOnSuccess:!0}},Write:{input:{type:"collapsible",title:t=>{var s;return`${((s=t.file_path)==null?void 0:s.split("/").pop())||t.file_path||"file"}`},defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:"",newContent:t.content,filePath:t.file_path,badge:"New",badgeColor:"green"})},result:{hideOnSuccess:!0}},ApplyPatch:{input:{type:"collapsible",title:t=>{var s;return`${((s=t.file_path)==null?void 0:s.split("/").pop())||t.file_path||"file"}`},defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:t.old_string,newContent:t.new_string,filePath:t.file_path,badge:"Patch",badgeColor:"gray"})},result:{hideOnSuccess:!0}},Grep:{input:{type:"one-line",label:"Grep",getValue:t=>t.pattern,getSecondary:t=>t.path?`in ${t.path}`:void 0,action:"jump-to-results",colorScheme:{primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-400 dark:border-gray-500",icon:"text-gray-500 dark:text-gray-400"}},result:{type:"collapsible",defaultOpen:!1,title:t=>{var a;const r=t.toolUseResult||{},s=r.numFiles||((a=r.filenames)==null?void 0:a.length)||0;return`Found ${s} ${s===1?"file":"files"}`},contentType:"file-list",getContentProps:t=>({files:(t.toolUseResult||{}).filenames||[]})}},Glob:{input:{type:"one-line",label:"Glob",getValue:t=>t.pattern,getSecondary:t=>t.path?`in ${t.path}`:void 0,action:"jump-to-results",colorScheme:{primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-400 dark:border-gray-500",icon:"text-gray-500 dark:text-gray-400"}},result:{type:"collapsible",defaultOpen:!1,title:t=>{var a;const r=t.toolUseResult||{},s=r.numFiles||((a=r.filenames)==null?void 0:a.length)||0;return`Found ${s} ${s===1?"file":"files"}`},contentType:"file-list",getContentProps:t=>({files:(t.toolUseResult||{}).filenames||[]})}},TodoWrite:{input:{type:"collapsible",title:"Updating todo list",defaultOpen:!1,contentType:"todo-list",getContentProps:t=>({todos:t.todos})},result:{type:"collapsible",contentType:"success-message",getMessage:()=>"Todo list updated"}},TodoRead:{input:{type:"one-line",label:"TodoRead",getValue:()=>"reading list",action:"none",colorScheme:{primary:"text-gray-500 dark:text-gray-400",border:"border-violet-400 dark:border-violet-500"}},result:{type:"collapsible",contentType:"todo-list",getContentProps:t=>{try{const r=String(t.content||"");let s=null;return r.startsWith("[")&&(s=JSON.parse(r)),{todos:s,isResult:!0}}catch{return{todos:[],isResult:!0}}}}},TaskCreate:{input:{type:"one-line",label:"Task",getValue:t=>t.subject||"Creating task",getSecondary:t=>t.status||void 0,action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{hideOnSuccess:!0}},TaskUpdate:{input:{type:"one-line",label:"Task",getValue:t=>{const r=[];return t.taskId&&r.push(`#${t.taskId}`),t.status&&r.push(t.status),t.subject&&r.push(`"${t.subject}"`),r.join(" → ")||"updating"},action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{hideOnSuccess:!0}},TaskList:{input:{type:"one-line",label:"Tasks",getValue:()=>"listing tasks",action:"none",colorScheme:{primary:"text-gray-500 dark:text-gray-400",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{type:"collapsible",defaultOpen:!0,title:"Task list",contentType:"task",getContentProps:t=>({content:String((t==null?void 0:t.content)||"")})}},TaskGet:{input:{type:"one-line",label:"Task",getValue:t=>t.taskId?`#${t.taskId}`:"fetching",action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{type:"collapsible",defaultOpen:!0,title:"Task details",contentType:"task",getContentProps:t=>({content:String((t==null?void 0:t.content)||"")})}},Task:{input:{type:"collapsible",title:t=>{const r=t.subagent_type||"Agent",s=t.description||"Running task";return`Subagent / ${r}: ${s}`},defaultOpen:!1,contentType:"markdown",getContentProps:t=>{if(t.prompt&&!t.model&&!t.resume)return{content:t.prompt||""};const s=[];return t.model&&s.push(`**Model:** ${t.model}`),t.prompt&&s.push(`**Prompt:**
65
65
  ${t.prompt}`),t.resume&&s.push(`**Resuming from:** ${t.resume}`),{content:s.join(`
66
66
 
67
67
  `)}},colorScheme:{border:"border-purple-500 dark:border-purple-400",icon:"text-purple-500 dark:text-purple-400"}},result:{type:"collapsible",title:"Subagent result",defaultOpen:!1,contentType:"markdown",getContentProps:t=>{if(t&&t.content){let r=t.content;if(typeof r=="string")try{const s=JSON.parse(r);Array.isArray(s)&&(r=s)}catch{return{content:r}}return Array.isArray(r)?{content:r.filter(a=>a.type==="text").map(a=>a.text).join(`
@@ -70,16 +70,16 @@ ${t.prompt}`),t.resume&&s.push(`**Resuming from:** ${t.resume}`),{content:s.join
70
70
  `))||t.plan}}},result:{type:"collapsible",contentType:"markdown",getContentProps:t=>{var r;try{let s=t.content;return typeof s=="string"&&(s=JSON.parse(s)),{content:((r=s.plan)==null?void 0:r.replace(/\\n/g,`
71
71
  `))||s.plan}}catch{return{content:""}}}}},ExitPlanMode:{input:{type:"collapsible",title:"Implementation plan",defaultOpen:!0,contentType:"markdown",getContentProps:t=>{var r;return{content:((r=t.plan)==null?void 0:r.replace(/\\n/g,`
72
72
  `))||t.plan}}},result:{type:"collapsible",contentType:"markdown",getContentProps:t=>{var r;try{let s=t.content;return typeof s=="string"&&(s=JSON.parse(s)),{content:((r=s.plan)==null?void 0:r.replace(/\\n/g,`
73
- `))||s.plan}}catch{return{content:""}}}}},Default:{input:{type:"collapsible",title:"Parameters",defaultOpen:!1,contentType:"text",getContentProps:t=>({content:typeof t=="string"?t:JSON.stringify(t,null,2),format:"code"})},result:{type:"collapsible",contentType:"text",getContentProps:t=>({content:String((t==null?void 0:t.content)||""),format:"plain"})}}};function Oo(t){return an[t]||an.Default}function Nd(t,r){const s=Oo(t);return s.result?!!(s.result.hidden||s.result.hideOnSuccess&&r&&!r.isError):!1}const Bo=({title:t,toolName:r,open:s=!1,action:a,onTitleClick:n,children:o,className:i=""})=>e.jsxs("details",{className:`relative group/details ${i}`,open:s,children:[e.jsxs("summary",{className:"flex items-center gap-1.5 text-xs cursor-pointer py-0.5 select-none group-open/details:sticky group-open/details:top-0 group-open/details:z-10 group-open/details:bg-background group-open/details:-mx-1 group-open/details:px-1",children:[e.jsx("svg",{className:"w-3 h-3 text-gray-400 dark:text-gray-500 transition-transform duration-150 group-open/details:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r&&e.jsx("span",{className:"font-medium text-gray-500 dark:text-gray-400 flex-shrink-0",children:r}),r&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px] flex-shrink-0",children:"/"}),n?e.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),n()},className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono hover:underline truncate flex-1 text-left transition-colors",children:t}):e.jsx("span",{className:"text-gray-600 dark:text-gray-400 truncate flex-1",children:t}),a&&e.jsx("span",{className:"flex-shrink-0 ml-1",children:a})]}),e.jsx("div",{className:"mt-1.5 pl-[18px]",children:o})]}),Cd=l.lazy(()=>kt(()=>import("./vendor-diff-DNQpbhrT.js"),__vite__mapDeps([4,2]))),Sd={variables:{dark:{diffViewerBackground:"#0f172a",diffViewerColor:"#e2e8f0",addedBackground:"#064e3b20",addedColor:"#6ee7b7",removedBackground:"#7f1d1d20",removedColor:"#fca5a5",wordAddedBackground:"#065f4630",wordRemovedBackground:"#991b1b30",addedGutterBackground:"#064e3b30",removedGutterBackground:"#7f1d1d30",gutterBackground:"#0f172a",gutterBackgroundDark:"#0f172a",highlightBackground:"#1e293b",highlightGutterBackground:"#1e293b",codeFoldGutterBackground:"#1e293b",codeFoldBackground:"#1e293b",emptyLineBackground:"#0f172a",gutterColor:"#475569",addedGutterColor:"#6ee7b7",removedGutterColor:"#fca5a5",codeFoldContentColor:"#94a3b8",diffViewerTitleBackground:"#1e293b",diffViewerTitleColor:"#e2e8f0",diffViewerTitleBorderColor:"#334155"}},line:{padding:"2px 8px",fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},gutter:{padding:"2px 8px",fontSize:"11px",minWidth:"36px"},contentText:{fontSize:"12px",lineHeight:"20px"}},Ed=({oldContent:t,newContent:r,filePath:s,createDiff:a,onFileClick:n,badge:o="Diff",badgeColor:i="gray"})=>{const[c,u]=l.useState(!1),[d,m]=l.useState(!1),h=i==="green"?"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400":"bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400",p=l.useMemo(()=>{const f=a(t,r),x=f.filter(N=>N.type==="added").length,b=f.filter(N=>N.type==="removed").length;return{added:x,removed:b}},[a,t,r]),g=()=>{navigator.clipboard.writeText(r).then(()=>{m(!0),setTimeout(()=>m(!1),1500)}).catch(()=>{})};return e.jsxs("div",{className:"border border-gray-200/60 dark:border-gray-700/50 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-gray-50/80 dark:bg-gray-800/40 border-b border-gray-200/60 dark:border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n?e.jsx("button",{onClick:n,className:"text-[11px] font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 truncate cursor-pointer transition-colors",children:s}):e.jsx("span",{className:"text-[11px] font-mono text-gray-600 dark:text-gray-400 truncate",children:s}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-px rounded ${h} flex-shrink-0`,children:o}),p.added>0&&e.jsxs("span",{className:"text-[10px] text-green-600 dark:text-green-400 font-mono flex-shrink-0",children:["+",p.added]}),p.removed>0&&e.jsxs("span",{className:"text-[10px] text-red-600 dark:text-red-400 font-mono flex-shrink-0",children:["-",p.removed]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 ml-2",children:[e.jsx("button",{onClick:()=>u(!c),className:"text-[10px] px-1.5 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",title:c?"Unified view":"Split view",children:c?"Unified":"Split"}),e.jsx("button",{onClick:g,className:"text-[10px] px-1.5 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",title:"Copy new content",children:d?"Copied":"Copy"})]})]}),e.jsx("div",{className:"max-h-[500px] overflow-auto",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"p-4 text-xs text-gray-500 dark:text-gray-400",children:"Loading diff viewer..."}),children:e.jsx(Cd,{oldValue:t,newValue:r,splitView:c,useDarkTheme:!0,styles:Sd,hideLineNumbers:!1,showDiffOnly:!0,extraLinesSurroundingDiff:3})})})]})},Td=t=>{if(typeof document>"u"||!document.body)return!1;const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.left="-9999px",document.body.appendChild(r),r.select(),r.setSelectionRange(0,t.length);let s=!1;try{s=document.execCommand("copy")}catch{s=!1}finally{document.body.removeChild(r)}return s},Ad=async t=>{var r;if(typeof navigator<"u"&&typeof window<"u"&&window.isSecureContext&&((r=navigator.clipboard)!=null&&r.writeText))try{return await navigator.clipboard.writeText(t),!0}catch{}return Td(t)},Id=({toolName:t,icon:r,label:s,value:a,secondary:n,action:o="none",onAction:i,style:c,wrapText:u=!1,colorScheme:d={primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-300 dark:border-gray-600",icon:"text-gray-500 dark:text-gray-400"},resultId:m,toolResult:h,toolId:p})=>{const[g,f]=l.useState(!1),x=c==="terminal",b=async()=>{if(o==="copy"&&a){if(!await Ad(a))return;f(!0),setTimeout(()=>f(!1),2e3)}else i&&i()},N=()=>e.jsx("button",{onClick:b,className:"opacity-0 group-hover:opacity-100 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 transition-all ml-1 flex-shrink-0",title:"Copy to clipboard","aria-label":"Copy to clipboard",children:g?e.jsx("svg",{className:"w-3 h-3 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})});if(x)return e.jsxs("div",{className:"group my-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"flex items-center gap-1.5 flex-shrink-0 pt-0.5",children:e.jsx("svg",{className:"w-3 h-3 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-start gap-2",children:[e.jsx("div",{className:"bg-gray-900 dark:bg-black rounded px-2.5 py-1 flex-1 min-w-0",children:e.jsxs("code",{className:`text-xs text-green-400 font-mono ${u?"whitespace-pre-wrap break-all":"block truncate"}`,children:[e.jsx("span",{className:"text-green-600 dark:text-green-500 select-none",children:"$ "}),a]})}),o==="copy"&&N()]})]}),n&&e.jsx("div",{className:"ml-7 mt-1",children:e.jsx("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic",children:n})})]});if(o==="open-file"){const j=a.split("/").pop()||a;return e.jsxs("div",{className:`group flex items-center gap-1.5 border-l-2 ${d.border} pl-3 py-0.5 my-0.5`,children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("button",{onClick:b,className:"text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono hover:underline transition-colors truncate",title:a,children:j})]})}return o==="jump-to-results"?e.jsxs("div",{className:`group flex items-center gap-1.5 border-l-2 ${d.border} pl-3 py-0.5 my-0.5`,children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("span",{className:`text-xs font-mono truncate flex-1 min-w-0 ${d.primary}`,children:a}),n&&e.jsx("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic flex-shrink-0",children:n}),h&&e.jsx("a",{href:`#tool-result-${p}`,className:"flex-shrink-0 text-[11px] text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors flex items-center gap-0.5",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}):e.jsxs("div",{className:`group flex items-center gap-1.5 ${d.background||""} border-l-2 ${d.border} pl-3 py-0.5 my-0.5`,children:[r&&r!=="terminal"&&e.jsx("span",{className:`${d.icon} flex-shrink-0 text-xs`,children:r}),!r&&(s||t)&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),(r||s||t)&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("span",{className:`text-xs font-mono ${u?"whitespace-pre-wrap break-all":"truncate"} flex-1 min-w-0 ${d.primary}`,children:a}),n&&e.jsx("span",{className:`text-[11px] ${d.secondary} italic flex-shrink-0`,children:n}),o==="copy"&&N()]})},nn={edit:"border-l-amber-500 dark:border-l-amber-400",search:"border-l-gray-400 dark:border-l-gray-500",bash:"border-l-green-500 dark:border-l-green-400",todo:"border-l-violet-500 dark:border-l-violet-400",task:"border-l-violet-500 dark:border-l-violet-400",agent:"border-l-purple-500 dark:border-l-purple-400",plan:"border-l-indigo-500 dark:border-l-indigo-400",question:"border-l-blue-500 dark:border-l-blue-400",default:"border-l-gray-300 dark:border-l-gray-600"},Md=({toolName:t,title:r,defaultOpen:s=!1,action:a,onTitleClick:n,children:o,showRawParameters:i=!1,rawContent:c,className:u="",toolCategory:d})=>{const m=nn[d||"default"]||nn.default;return e.jsx("div",{className:`border-l-2 ${m} pl-3 py-0.5 my-1 ${u}`,children:e.jsxs(Bo,{title:r,toolName:t,open:s,action:a,onTitleClick:n,children:[o,i&&c&&e.jsxs("details",{className:"relative mt-2 group/raw",children:[e.jsxs("summary",{className:"flex items-center gap-1.5 text-[11px] text-gray-400 dark:text-gray-500 cursor-pointer hover:text-gray-600 dark:hover:text-gray-300 py-0.5",children:[e.jsx("svg",{className:"w-2.5 h-2.5 transition-transform duration-150 group-open/raw:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"raw params"]}),e.jsx("pre",{className:"mt-1 text-[11px] bg-gray-50 dark:bg-gray-900/50 border border-gray-200/40 dark:border-gray-700/40 p-2 rounded whitespace-pre-wrap break-words overflow-hidden text-gray-600 dark:text-gray-400 font-mono",children:c})]})]})})},qr=(t,r)=>{var a;const s=typeof r=="string"?(()=>{try{return JSON.parse(r)}catch{return{}}})():r||{};switch(t){case"Read":case"Write":case"Edit":case"ApplyPatch":return((a=s.file_path)==null?void 0:a.split("/").pop())||s.file_path||"";case"Grep":case"Glob":return s.pattern||"";case"Bash":const n=s.command||"";return n.length>40?`${n.slice(0,40)}...`:n;case"Task":return s.description||s.subagent_type||"";case"WebFetch":case"WebSearch":return s.url||s.query||"";default:return""}},Dd=({toolInput:t,toolResult:r,subagentState:s})=>{const a=typeof t=="string"?(()=>{try{return JSON.parse(t)}catch{return{}}})():t||{},n=(a==null?void 0:a.subagent_type)||"Agent",o=(a==null?void 0:a.description)||"Running task",i=(a==null?void 0:a.prompt)||"",{childTools:c,currentToolIndex:u,isComplete:d}=s,m=u>=0?c[u]:null,h=`Subagent / ${n}: ${o}`;return e.jsx("div",{className:"border-l-2 border-l-purple-500 dark:border-l-purple-400 pl-3 py-0.5 my-1",children:e.jsxs(Bo,{title:h,toolName:"Task",open:!1,children:[i&&e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mb-2 whitespace-pre-wrap break-words line-clamp-4",children:i}),m&&!d&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 mt-1",children:[e.jsx("span",{className:"animate-pulse w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 flex-shrink-0"}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Currently:"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:m.toolName}),qr(m.toolName,m.toolInput)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"/"}),e.jsx("span",{className:"font-mono truncate text-gray-500 dark:text-gray-400",children:qr(m.toolName,m.toolInput)})]})]}),d&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400 mt-1",children:[e.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsxs("span",{children:["Completed (",c.length," ",c.length===1?"tool":"tools",")"]})]}),c.length>0&&e.jsxs("details",{className:"mt-2 group/history",children:[e.jsxs("summary",{className:"cursor-pointer text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 flex items-center gap-1",children:[e.jsx("svg",{className:"w-2.5 h-2.5 transition-transform duration-150 group-open/history:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsxs("span",{children:["View tool history (",c.length,")"]})]}),e.jsx("div",{className:"mt-1 pl-3 border-l border-gray-200 dark:border-gray-700 space-y-0.5",children:c.map((p,g)=>{var f;return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{className:"text-gray-400 dark:text-gray-500 w-4 text-right flex-shrink-0",children:[g+1,"."]}),e.jsx("span",{className:"font-medium",children:p.toolName}),qr(p.toolName,p.toolInput)&&e.jsx("span",{className:"font-mono truncate text-gray-400 dark:text-gray-500",children:qr(p.toolName,p.toolInput)}),((f=p.toolResult)==null?void 0:f.isError)&&e.jsx("span",{className:"text-red-500 flex-shrink-0",children:"(error)"})]},p.toolId)})})]}),d&&r&&e.jsx("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400",children:(()=>{let p=r.content;if(typeof p=="string")try{const g=JSON.parse(p);if(Array.isArray(g)){const f=g.filter(x=>x.type==="text"&&x.text).map(x=>x.text);f.length>0&&(p=f.join(`
73
+ `))||s.plan}}catch{return{content:""}}}}},Default:{input:{type:"collapsible",title:"Parameters",defaultOpen:!1,contentType:"text",getContentProps:t=>({content:typeof t=="string"?t:JSON.stringify(t,null,2),format:"code"})},result:{type:"collapsible",contentType:"text",getContentProps:t=>({content:String((t==null?void 0:t.content)||""),format:"plain"})}}};function Bo(t){return nn[t]||nn.Default}function Cd(t,r){const s=Bo(t);return s.result?!!(s.result.hidden||s.result.hideOnSuccess&&r&&!r.isError):!1}const Wo=({title:t,toolName:r,open:s=!1,action:a,onTitleClick:n,children:o,className:i=""})=>e.jsxs("details",{className:`relative group/details ${i}`,open:s,children:[e.jsxs("summary",{className:"flex items-center gap-1.5 text-xs cursor-pointer py-0.5 select-none group-open/details:sticky group-open/details:top-0 group-open/details:z-10 group-open/details:bg-background group-open/details:-mx-1 group-open/details:px-1",children:[e.jsx("svg",{className:"w-3 h-3 text-gray-400 dark:text-gray-500 transition-transform duration-150 group-open/details:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r&&e.jsx("span",{className:"font-medium text-gray-500 dark:text-gray-400 flex-shrink-0",children:r}),r&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px] flex-shrink-0",children:"/"}),n?e.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),n()},className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono hover:underline truncate flex-1 text-left transition-colors",children:t}):e.jsx("span",{className:"text-gray-600 dark:text-gray-400 truncate flex-1",children:t}),a&&e.jsx("span",{className:"flex-shrink-0 ml-1",children:a})]}),e.jsx("div",{className:"mt-1.5 pl-[18px]",children:o})]}),Sd=l.lazy(()=>kt(()=>import("./vendor-diff-DNQpbhrT.js"),__vite__mapDeps([4,2]))),Ed={variables:{dark:{diffViewerBackground:"#0f172a",diffViewerColor:"#e2e8f0",addedBackground:"#064e3b20",addedColor:"#6ee7b7",removedBackground:"#7f1d1d20",removedColor:"#fca5a5",wordAddedBackground:"#065f4630",wordRemovedBackground:"#991b1b30",addedGutterBackground:"#064e3b30",removedGutterBackground:"#7f1d1d30",gutterBackground:"#0f172a",gutterBackgroundDark:"#0f172a",highlightBackground:"#1e293b",highlightGutterBackground:"#1e293b",codeFoldGutterBackground:"#1e293b",codeFoldBackground:"#1e293b",emptyLineBackground:"#0f172a",gutterColor:"#475569",addedGutterColor:"#6ee7b7",removedGutterColor:"#fca5a5",codeFoldContentColor:"#94a3b8",diffViewerTitleBackground:"#1e293b",diffViewerTitleColor:"#e2e8f0",diffViewerTitleBorderColor:"#334155"}},line:{padding:"2px 8px",fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},gutter:{padding:"2px 8px",fontSize:"11px",minWidth:"36px"},contentText:{fontSize:"12px",lineHeight:"20px"}},Td=({oldContent:t,newContent:r,filePath:s,createDiff:a,onFileClick:n,badge:o="Diff",badgeColor:i="gray"})=>{const[c,u]=l.useState(!1),[d,m]=l.useState(!1),h=i==="green"?"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400":"bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400",p=l.useMemo(()=>{const f=a(t,r),x=f.filter(N=>N.type==="added").length,b=f.filter(N=>N.type==="removed").length;return{added:x,removed:b}},[a,t,r]),g=()=>{navigator.clipboard.writeText(r).then(()=>{m(!0),setTimeout(()=>m(!1),1500)}).catch(()=>{})};return e.jsxs("div",{className:"border border-gray-200/60 dark:border-gray-700/50 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-gray-50/80 dark:bg-gray-800/40 border-b border-gray-200/60 dark:border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n?e.jsx("button",{onClick:n,className:"text-[11px] font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 truncate cursor-pointer transition-colors",children:s}):e.jsx("span",{className:"text-[11px] font-mono text-gray-600 dark:text-gray-400 truncate",children:s}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-px rounded ${h} flex-shrink-0`,children:o}),p.added>0&&e.jsxs("span",{className:"text-[10px] text-green-600 dark:text-green-400 font-mono flex-shrink-0",children:["+",p.added]}),p.removed>0&&e.jsxs("span",{className:"text-[10px] text-red-600 dark:text-red-400 font-mono flex-shrink-0",children:["-",p.removed]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 ml-2",children:[e.jsx("button",{onClick:()=>u(!c),className:"text-[10px] px-1.5 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",title:c?"Unified view":"Split view",children:c?"Unified":"Split"}),e.jsx("button",{onClick:g,className:"text-[10px] px-1.5 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",title:"Copy new content",children:d?"Copied":"Copy"})]})]}),e.jsx("div",{className:"max-h-[500px] overflow-auto",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"p-4 text-xs text-gray-500 dark:text-gray-400",children:"Loading diff viewer..."}),children:e.jsx(Sd,{oldValue:t,newValue:r,splitView:c,useDarkTheme:!0,styles:Ed,hideLineNumbers:!1,showDiffOnly:!0,extraLinesSurroundingDiff:3})})})]})},Ad=t=>{if(typeof document>"u"||!document.body)return!1;const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.left="-9999px",document.body.appendChild(r),r.select(),r.setSelectionRange(0,t.length);let s=!1;try{s=document.execCommand("copy")}catch{s=!1}finally{document.body.removeChild(r)}return s},Id=async t=>{var r;if(typeof navigator<"u"&&typeof window<"u"&&window.isSecureContext&&((r=navigator.clipboard)!=null&&r.writeText))try{return await navigator.clipboard.writeText(t),!0}catch{}return Ad(t)},Md=({toolName:t,icon:r,label:s,value:a,secondary:n,action:o="none",onAction:i,style:c,wrapText:u=!1,colorScheme:d={primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-300 dark:border-gray-600",icon:"text-gray-500 dark:text-gray-400"},resultId:m,toolResult:h,toolId:p})=>{const[g,f]=l.useState(!1),x=c==="terminal",b=async()=>{if(o==="copy"&&a){if(!await Id(a))return;f(!0),setTimeout(()=>f(!1),2e3)}else i&&i()},N=()=>e.jsx("button",{onClick:b,className:"opacity-0 group-hover:opacity-100 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 transition-all ml-1 flex-shrink-0",title:"Copy to clipboard","aria-label":"Copy to clipboard",children:g?e.jsx("svg",{className:"w-3 h-3 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})});if(x)return e.jsxs("div",{className:"group my-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"flex items-center gap-1.5 flex-shrink-0 pt-0.5",children:e.jsx("svg",{className:"w-3 h-3 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-start gap-2",children:[e.jsx("div",{className:"bg-gray-900 dark:bg-black rounded px-2.5 py-1 flex-1 min-w-0",children:e.jsxs("code",{className:`text-xs text-green-400 font-mono ${u?"whitespace-pre-wrap break-all":"block truncate"}`,children:[e.jsx("span",{className:"text-green-600 dark:text-green-500 select-none",children:"$ "}),a]})}),o==="copy"&&N()]})]}),n&&e.jsx("div",{className:"ml-7 mt-1",children:e.jsx("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic",children:n})})]});if(o==="open-file"){const j=a.split("/").pop()||a;return e.jsxs("div",{className:`group flex items-center gap-1.5 border-l-2 ${d.border} pl-3 py-0.5 my-0.5`,children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("button",{onClick:b,className:"text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono hover:underline transition-colors truncate",title:a,children:j})]})}return o==="jump-to-results"?e.jsxs("div",{className:`group flex items-center gap-1.5 border-l-2 ${d.border} pl-3 py-0.5 my-0.5`,children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("span",{className:`text-xs font-mono truncate flex-1 min-w-0 ${d.primary}`,children:a}),n&&e.jsx("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic flex-shrink-0",children:n}),h&&e.jsx("a",{href:`#tool-result-${p}`,className:"flex-shrink-0 text-[11px] text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors flex items-center gap-0.5",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}):e.jsxs("div",{className:`group flex items-center gap-1.5 ${d.background||""} border-l-2 ${d.border} pl-3 py-0.5 my-0.5`,children:[r&&r!=="terminal"&&e.jsx("span",{className:`${d.icon} flex-shrink-0 text-xs`,children:r}),!r&&(s||t)&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),(r||s||t)&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("span",{className:`text-xs font-mono ${u?"whitespace-pre-wrap break-all":"truncate"} flex-1 min-w-0 ${d.primary}`,children:a}),n&&e.jsx("span",{className:`text-[11px] ${d.secondary} italic flex-shrink-0`,children:n}),o==="copy"&&N()]})},on={edit:"border-l-amber-500 dark:border-l-amber-400",search:"border-l-gray-400 dark:border-l-gray-500",bash:"border-l-green-500 dark:border-l-green-400",todo:"border-l-violet-500 dark:border-l-violet-400",task:"border-l-violet-500 dark:border-l-violet-400",agent:"border-l-purple-500 dark:border-l-purple-400",plan:"border-l-indigo-500 dark:border-l-indigo-400",question:"border-l-blue-500 dark:border-l-blue-400",default:"border-l-gray-300 dark:border-l-gray-600"},Dd=({toolName:t,title:r,defaultOpen:s=!1,action:a,onTitleClick:n,children:o,showRawParameters:i=!1,rawContent:c,className:u="",toolCategory:d})=>{const m=on[d||"default"]||on.default;return e.jsx("div",{className:`border-l-2 ${m} pl-3 py-0.5 my-1 ${u}`,children:e.jsxs(Wo,{title:r,toolName:t,open:s,action:a,onTitleClick:n,children:[o,i&&c&&e.jsxs("details",{className:"relative mt-2 group/raw",children:[e.jsxs("summary",{className:"flex items-center gap-1.5 text-[11px] text-gray-400 dark:text-gray-500 cursor-pointer hover:text-gray-600 dark:hover:text-gray-300 py-0.5",children:[e.jsx("svg",{className:"w-2.5 h-2.5 transition-transform duration-150 group-open/raw:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"raw params"]}),e.jsx("pre",{className:"mt-1 text-[11px] bg-gray-50 dark:bg-gray-900/50 border border-gray-200/40 dark:border-gray-700/40 p-2 rounded whitespace-pre-wrap break-words overflow-hidden text-gray-600 dark:text-gray-400 font-mono",children:c})]})]})})},qr=(t,r)=>{var a;const s=typeof r=="string"?(()=>{try{return JSON.parse(r)}catch{return{}}})():r||{};switch(t){case"Read":case"Write":case"Edit":case"ApplyPatch":return((a=s.file_path)==null?void 0:a.split("/").pop())||s.file_path||"";case"Grep":case"Glob":return s.pattern||"";case"Bash":const n=s.command||"";return n.length>40?`${n.slice(0,40)}...`:n;case"Task":return s.description||s.subagent_type||"";case"WebFetch":case"WebSearch":return s.url||s.query||"";default:return""}},Ld=({toolInput:t,toolResult:r,subagentState:s})=>{const a=typeof t=="string"?(()=>{try{return JSON.parse(t)}catch{return{}}})():t||{},n=(a==null?void 0:a.subagent_type)||"Agent",o=(a==null?void 0:a.description)||"Running task",i=(a==null?void 0:a.prompt)||"",{childTools:c,currentToolIndex:u,isComplete:d}=s,m=u>=0?c[u]:null,h=`Subagent / ${n}: ${o}`;return e.jsx("div",{className:"border-l-2 border-l-purple-500 dark:border-l-purple-400 pl-3 py-0.5 my-1",children:e.jsxs(Wo,{title:h,toolName:"Task",open:!1,children:[i&&e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mb-2 whitespace-pre-wrap break-words line-clamp-4",children:i}),m&&!d&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 mt-1",children:[e.jsx("span",{className:"animate-pulse w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 flex-shrink-0"}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Currently:"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:m.toolName}),qr(m.toolName,m.toolInput)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"/"}),e.jsx("span",{className:"font-mono truncate text-gray-500 dark:text-gray-400",children:qr(m.toolName,m.toolInput)})]})]}),d&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400 mt-1",children:[e.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsxs("span",{children:["Completed (",c.length," ",c.length===1?"tool":"tools",")"]})]}),c.length>0&&e.jsxs("details",{className:"mt-2 group/history",children:[e.jsxs("summary",{className:"cursor-pointer text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 flex items-center gap-1",children:[e.jsx("svg",{className:"w-2.5 h-2.5 transition-transform duration-150 group-open/history:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsxs("span",{children:["View tool history (",c.length,")"]})]}),e.jsx("div",{className:"mt-1 pl-3 border-l border-gray-200 dark:border-gray-700 space-y-0.5",children:c.map((p,g)=>{var f;return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{className:"text-gray-400 dark:text-gray-500 w-4 text-right flex-shrink-0",children:[g+1,"."]}),e.jsx("span",{className:"font-medium",children:p.toolName}),qr(p.toolName,p.toolInput)&&e.jsx("span",{className:"font-mono truncate text-gray-400 dark:text-gray-500",children:qr(p.toolName,p.toolInput)}),((f=p.toolResult)==null?void 0:f.isError)&&e.jsx("span",{className:"text-red-500 flex-shrink-0",children:"(error)"})]},p.toolId)})})]}),d&&r&&e.jsx("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400",children:(()=>{let p=r.content;if(typeof p=="string")try{const g=JSON.parse(p);if(Array.isArray(g)){const f=g.filter(x=>x.type==="text"&&x.text).map(x=>x.text);f.length>0&&(p=f.join(`
74
74
  `))}}catch{}else if(Array.isArray(p)){const g=p.filter(f=>f.type==="text"&&f.text).map(f=>f.text);g.length>0&&(p=g.join(`
75
- `))}return typeof p=="string"?e.jsx("div",{className:"whitespace-pre-wrap break-words line-clamp-6",children:p}):p?e.jsx("pre",{className:"whitespace-pre-wrap break-words line-clamp-6 font-mono text-[11px]",children:JSON.stringify(p,null,2)}):null})()})]})})},Ld=({content:t,className:r="mt-1 prose prose-sm max-w-none dark:prose-invert"})=>e.jsx(Qt,{className:r,children:t}),Pd=({files:t,onFileClick:r,title:s})=>e.jsxs("div",{children:[s&&e.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400 mb-1",children:s}),e.jsx("div",{className:"flex flex-wrap gap-x-1 gap-y-0.5 max-h-48 overflow-y-auto",children:t.map((a,n)=>{const o=typeof a=="string"?a:a.path,i=o.split("/").pop()||o,c=typeof a=="string"?()=>r==null?void 0:r(a):a.onClick;return e.jsxs("span",{className:"inline-flex items-center",children:[e.jsx("button",{onClick:c,className:"text-[11px] font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline transition-colors",title:o,children:i}),n<t.length-1&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px] ml-1",children:","})]},n)})})]}),$d=({todos:t,isResult:r=!1})=>{if(!t||!Array.isArray(t))return null;const s=o=>{switch(o){case"completed":return e.jsx(ji,{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(Ir,{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400"});case"pending":default:return e.jsx(ur,{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500"})}},a=o=>{switch(o){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 border-green-200 dark:border-green-800";case"in_progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-200 border-blue-200 dark:border-blue-800";case"pending":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},n=o=>{switch(o){case"high":return"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 border-red-200 dark:border-red-800";case"medium":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800";case"low":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}};return e.jsxs("div",{className:"space-y-1.5",children:[r&&e.jsxs("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1.5",children:["Todo List (",t.length," ",t.length===1?"item":"items",")"]}),t.map((o,i)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:s(o.status)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-0.5",children:[e.jsx("p",{className:`text-xs font-medium ${o.status==="completed"?"line-through text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100"}`,children:o.content}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(bt,{variant:"outline",className:`text-[10px] px-1.5 py-px ${n(o.priority)}`,children:o.priority}),e.jsx(bt,{variant:"outline",className:`text-[10px] px-1.5 py-px ${a(o.status)}`,children:o.status.replace("_"," ")})]})]})})]},o.id||`todo-${i}`))]})},_d=({todos:t,isResult:r=!1})=>e.jsx($d,{todos:t,isResult:r});function Fd(t){const r=[],s=t.split(`
76
- `);for(const a of s){const n=a.match(/#(\d+)\.?\s*(?:\[(\w+)\]\s*)?(.+?)(?:\s*\((?:owner:\s*\w+)?\))?$/);if(n){const[,o,i,c]=n,u=a.match(/blockedBy:\s*\[([^\]]*)\]/);r.push({id:o,subject:c.trim(),status:i||"pending",blockedBy:u?u[1].split(",").map(d=>d.trim()).filter(Boolean):void 0})}}return r}const on={completed:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),textClass:"line-through text-gray-400 dark:text-gray-500",badgeClass:"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300 border-green-200 dark:border-green-800"},in_progress:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),textClass:"text-gray-900 dark:text-gray-100",badgeClass:"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-800"},pending:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})}),textClass:"text-gray-700 dark:text-gray-300",badgeClass:"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},zd=({content:t})=>{const r=Fd(t);if(r.length===0)return e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-gray-400 whitespace-pre-wrap",children:t});const s=r.filter(n=>n.status==="completed").length,a=r.length;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[s,"/",a," completed"]}),e.jsx("div",{className:"flex-1 h-1 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-green-500 dark:bg-green-400 rounded-full transition-all",style:{width:`${a>0?s/a*100:0}%`}})})]}),e.jsx("div",{className:"space-y-px",children:r.map(n=>{const o=on[n.status]||on.pending;return e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 group",children:[e.jsx("span",{className:"flex-shrink-0",children:o.icon}),e.jsxs("span",{className:"text-[11px] font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:["#",n.id]}),e.jsx("span",{className:`text-xs truncate flex-1 ${o.textClass}`,children:n.subject}),e.jsx("span",{className:`text-[10px] px-1 py-px rounded border flex-shrink-0 ${o.badgeClass}`,children:n.status.replace("_"," ")})]},n.id)})})]})},Rd=({content:t,format:r="plain",className:s=""})=>{if(r==="json"){let a=t;try{const n=JSON.parse(t);a=JSON.stringify(n,null,2)}catch{}return e.jsx("pre",{className:`mt-1 text-xs bg-gray-900 dark:bg-gray-950 text-gray-100 p-2.5 rounded overflow-x-auto font-mono ${s}`,children:a})}return r==="code"?e.jsx("pre",{className:`mt-1 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/50 dark:border-gray-700/50 p-2 rounded whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono ${s}`,children:t}):e.jsx("div",{className:`mt-1 text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap ${s}`,children:t})},Od=({questions:t,answers:r,className:s=""})=>{const[a,n]=l.useState(null);if(!t||t.length===0)return null;const o=Object.keys(r||{}).length>0,i=t.length;return e.jsxs("div",{className:`space-y-2 ${s}`,children:[t.map((c,u)=>{const d=r==null?void 0:r[c.question],m=d?d.split(", "):[],h=!d,p=a===u;return e.jsxs("div",{className:"rounded-lg border border-gray-150 dark:border-gray-700/50 bg-gray-50/50 dark:bg-gray-800/30 overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>n(p?null:u),className:"w-full text-left px-3 py-2 flex items-start gap-2.5 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-4 h-4 rounded-full flex items-center justify-center ${m.length>0?"bg-blue-100 dark:bg-blue-900/40":"bg-gray-100 dark:bg-gray-800"}`,children:m.length>0?e.jsx("svg",{className:"w-2.5 h-2.5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-300 dark:bg-gray-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.header&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase tracking-wider bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 border border-blue-100/80 dark:border-blue-800/40",children:c.header}),i>1&&e.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500",children:[u+1,"/",i]})]}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5 leading-snug",children:c.question}),!p&&m.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:m.map(g=>{const f=!c.options.some(x=>x.label===g);return e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded-md bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium",children:[g,f&&e.jsx("span",{className:"text-[9px] text-blue-400 dark:text-blue-500 font-normal",children:"(custom)"})]},g)})}),!p&&h&&o&&e.jsx("span",{className:"inline-block mt-1 text-[10px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]}),e.jsx("svg",{className:`w-3.5 h-3.5 mt-0.5 text-gray-400 dark:text-gray-500 flex-shrink-0 transition-transform duration-200 ${p?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),p&&e.jsx("div",{className:"px-3 pb-2.5 pt-0.5 border-t border-gray-100 dark:border-gray-700/40",children:e.jsxs("div",{className:"space-y-1 ml-6.5",children:[c.options.map(g=>{const f=m.includes(g.label);return e.jsxs("div",{className:`flex items-start gap-2 px-2.5 py-1.5 rounded-lg text-[12px] ${f?"bg-blue-50/80 dark:bg-blue-900/20 border border-blue-200/60 dark:border-blue-800/40":"text-gray-400 dark:text-gray-500"}`,children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-3.5 h-3.5 ${c.multiSelect?"rounded-[3px]":"rounded-full"} border-[1.5px] flex items-center justify-center ${f?"border-blue-500 dark:border-blue-400 bg-blue-500 dark:bg-blue-500":"border-gray-300 dark:border-gray-600"}`,children:f&&e.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:f?"text-gray-900 dark:text-gray-100 font-medium":"",children:g.label}),g.description&&e.jsx("span",{className:`block text-[11px] mt-0.5 ${f?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-600"}`,children:g.description})]})]},g.label)}),m.filter(g=>!c.options.some(f=>f.label===g)).map(g=>e.jsxs("div",{className:"flex items-start gap-2 px-2.5 py-1.5 rounded-lg text-[12px] bg-blue-50/80 dark:bg-blue-900/20 border border-blue-200/60 dark:border-blue-800/40",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-3.5 h-3.5 ${c.multiSelect?"rounded-[3px]":"rounded-full"} border-[1.5px] border-blue-500 dark:border-blue-400 bg-blue-500 dark:bg-blue-500 flex items-center justify-center`,children:e.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium",children:g}),e.jsx("span",{className:"text-[10px] text-blue-500 dark:text-blue-400 ml-1",children:"(custom)"})]})]},g)),h&&o&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic px-2.5 py-1",children:"No answer provided"})]})})]},u)}),!o&&i===1&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]})},Bd=({request:t,onDecision:r})=>{const s=t.input,a=(s==null?void 0:s.questions)||[],[n,o]=l.useState(0),[i,c]=l.useState(()=>new Map),[u,d]=l.useState(()=>new Map),[m,h]=l.useState(()=>new Map),[p,g]=l.useState(!1),f=l.useRef(null),x=l.useRef(null);l.useEffect(()=>{requestAnimationFrame(()=>g(!0))},[]),l.useEffect(()=>{var A;m.get(n)||(A=f.current)==null||A.focus()},[n,m]),l.useEffect(()=>{var A;m.get(n)&&((A=x.current)==null||A.focus())},[m,n]);const b=l.useCallback((A,z,J)=>{c(re=>{const G=new Map(re),ie=new Set(G.get(A)||[]);return J?ie.has(z)?ie.delete(z):ie.add(z):(ie.clear(),ie.add(z),h($=>{const Z=new Map($);return Z.set(A,!1),Z})),G.set(A,ie),G})},[]),N=l.useCallback((A,z)=>{h(J=>{const re=new Map(J),G=re.get(A)||!1;return re.set(A,!G),!z&&!G&&c(ie=>{const $=new Map(ie);return $.set(A,new Set),$}),re})},[]),j=l.useCallback((A,z)=>{d(J=>{const re=new Map(J);return re.set(A,z),re})},[]),y=l.useCallback(()=>{const A={};return a.forEach((z,J)=>{const re=Array.from(i.get(J)||[]),G=m.get(J)||!1,ie=(u.get(J)||"").trim();G&&ie&&re.push(ie),re.length>0&&(A[z.question]=re.join(", "))}),A},[a,i,m,u]),k=l.useCallback(()=>{r(t.requestId,{allow:!0,updatedInput:{...s,answers:y()}})},[r,t.requestId,s,y]),I=l.useCallback(()=>{r(t.requestId,{allow:!0,updatedInput:{...s,answers:{}}})},[r,t.requestId,s]),D=l.useCallback(A=>{if(A.target instanceof HTMLInputElement)return;const z=a[n];if(!z)return;const J=z.multiSelect||!1,re=z.options.length,G=parseInt(A.key);if(!isNaN(G)&&G>=1&&G<=re){A.preventDefault(),b(n,z.options[G-1].label,J);return}if(A.key==="0"){A.preventDefault(),N(n,J);return}if(A.key==="Enter"){A.preventDefault(),n===a.length-1?k():o($=>$+1);return}if(A.key==="Escape"){A.preventDefault(),I();return}},[n,a,b,N,k,I]);if(a.length===0)return null;const C=a.length,v=C===1,E=a[n],T=E.multiSelect||!1,W=i.get(n)||new Set,S=m.get(n)||!1,O=n===C-1,H=n===0,R=W.size>0||S&&(u.get(n)||"").trim().length>0;return e.jsx("div",{ref:f,tabIndex:-1,onKeyDown:D,className:`w-full outline-none transition-all duration-500 ease-out ${p?"opacity-100 translate-y-0":"opacity-0 translate-y-3"}`,children:e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-gray-200/80 dark:border-gray-700/50 bg-white dark:bg-gray-800/90 shadow-lg dark:shadow-2xl",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-blue-500 via-cyan-400 to-teal-400"}),e.jsxs("div",{className:"px-4 pt-3.5 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:"w-6 h-6 rounded-lg bg-gradient-to-br from-blue-500/10 to-cyan-500/10 dark:from-blue-400/15 dark:to-cyan-400/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-600 dark:text-blue-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.75,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827m0 3h.01"})})}),e.jsx("div",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-cyan-400 dark:bg-cyan-500 animate-pulse"})]}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"text-[10px] font-medium tracking-wide uppercase text-gray-400 dark:text-gray-500",children:"Claude needs your input"}),E.header&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-px rounded text-[9px] font-semibold uppercase tracking-wider bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 border border-blue-100 dark:border-blue-800/50",children:E.header})]}),!v&&e.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500 flex-shrink-0",children:[n+1,"/",C]})]}),!v&&e.jsx("div",{className:"flex items-center gap-1 mb-2",children:a.map((A,z)=>e.jsx("button",{type:"button",onClick:()=>o(z),className:`h-[3px] rounded-full transition-all duration-300 ${z===n?"w-5 bg-blue-500 dark:bg-blue-400":z<n?"w-2.5 bg-blue-300 dark:bg-blue-600":"w-2.5 bg-gray-200 dark:bg-gray-700"}`},z))}),e.jsx("p",{className:"text-[14px] leading-snug font-medium text-gray-900 dark:text-gray-100",children:E.question}),T&&e.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500",children:"Select all that apply"})]}),e.jsx("div",{className:"px-4 pb-2 max-h-48 overflow-y-auto scrollbar-thin",role:T?"group":"radiogroup","aria-label":E.question,children:e.jsxs("div",{className:"space-y-1",children:[E.options.map((A,z)=>{const J=W.has(A.label);return e.jsxs("button",{type:"button",onClick:()=>b(n,A.label,T),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${J?"border-blue-300 dark:border-blue-600 bg-blue-50/80 dark:bg-blue-900/25 ring-1 ring-blue-200/50 dark:ring-blue-700/30":"border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50/60 dark:hover:bg-gray-750/50"}`,children:[e.jsx("kbd",{className:`flex-shrink-0 w-5 h-5 rounded text-[10px] font-mono flex items-center justify-center transition-all duration-150 ${J?"bg-blue-500 dark:bg-blue-500 text-white font-semibold":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"}`,children:z+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-[13px] leading-tight transition-colors duration-150 ${J?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-700 dark:text-gray-300"}`,children:A.label}),A.description&&e.jsx("div",{className:`text-[11px] leading-snug transition-colors duration-150 ${J?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-500"}`,children:A.description})]}),J&&e.jsx("svg",{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]},A.label)}),e.jsxs("button",{type:"button",onClick:()=>N(n,T),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${S?"border-blue-300 dark:border-blue-600 bg-blue-50/80 dark:bg-blue-900/25 ring-1 ring-blue-200/50 dark:ring-blue-700/30":"border-dashed border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50/60 dark:hover:bg-gray-750/50"}`,children:[e.jsx("kbd",{className:`flex-shrink-0 w-5 h-5 rounded text-[10px] font-mono flex items-center justify-center transition-all duration-150 ${S?"bg-blue-500 dark:bg-blue-500 text-white font-semibold":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"}`,children:"0"}),e.jsx("span",{className:`text-[13px] leading-tight transition-colors ${S?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-500 dark:text-gray-400"}`,children:"Other..."}),S&&e.jsx("svg",{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]}),S&&e.jsx("div",{className:"pl-[30px] pr-0.5",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:x,type:"text",value:u.get(n)||"",onChange:A=>j(n,A.target.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),O?k():o(z=>z+1)),A.stopPropagation()},placeholder:"Type your answer...",className:"w-full text-[13px] rounded-lg border-0 bg-gray-50 dark:bg-gray-900/60 text-gray-900 dark:text-gray-100 px-3 py-1.5 outline-none ring-1 ring-gray-200 dark:ring-gray-700 focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 placeholder:text-gray-400 dark:placeholder:text-gray-600 transition-shadow duration-200"}),e.jsx("kbd",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[9px] font-mono text-gray-300 dark:text-gray-600 bg-gray-100 dark:bg-gray-800 px-1 py-0.5 rounded border border-gray-200 dark:border-gray-700",children:"Enter"})]})})]})}),e.jsxs("div",{className:"px-4 py-2 border-t border-gray-100 dark:border-gray-700/50 bg-gray-50/50 dark:bg-gray-800/50 flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:I,className:"text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:[v?"Skip":"Skip all",e.jsx("span",{className:"ml-1 text-[9px] text-gray-300 dark:text-gray-600",children:"Esc"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[!v&&!H&&e.jsxs("button",{type:"button",onClick:()=>o(A=>A-1),className:"inline-flex items-center gap-0.5 text-[11px] font-medium px-2.5 py-1.5 rounded-lg text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700/60 transition-all duration-150",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),"Back"]}),O?e.jsxs("button",{type:"button",onClick:k,disabled:!R&&!Object.keys(y()).length,className:"inline-flex items-center gap-1 text-[11px] font-semibold px-3.5 py-1.5 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 dark:from-blue-500 dark:to-blue-600 text-white shadow-sm hover:shadow-md disabled:opacity-30 disabled:cursor-not-allowed disabled:shadow-none transition-all duration-200",children:["Submit",e.jsx("span",{className:"text-[9px] opacity-70 font-mono ml-0.5",children:"Enter"})]}):e.jsxs("button",{type:"button",onClick:()=>o(A=>A+1),className:"inline-flex items-center gap-1 text-[11px] font-semibold px-3.5 py-1.5 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 dark:from-blue-500 dark:to-blue-600 text-white shadow-sm hover:shadow-md transition-all duration-200",children:["Next",e.jsx("span",{className:"text-[9px] opacity-70 font-mono ml-0.5",children:"Enter"})]})]})]})]})})};function Fs(t,r,s,a,n){const o=`${t}-${r||Date.now()}`;if(t==="Edit"||t==="Write"||t==="ApplyPatch"){const i=typeof s=="string"?(()=>{try{return JSON.parse(s)}catch{return s}})():s,c=(i==null?void 0:i.file_path)||"file",u=c.split("/").pop()||c;return{id:`diff-${o}`,type:"diff",title:u,data:{filePath:c,oldContent:(i==null?void 0:i.old_string)||"",newContent:t==="Write"?(i==null?void 0:i.content)||"":(i==null?void 0:i.new_string)||"",badge:t==="Write"?"New":t==="ApplyPatch"?"Patch":"Edit"}}}if(t==="Bash"&&a&&!a.isError){const i=typeof s=="string"?(()=>{try{return JSON.parse(s)}catch{return s}})():s;return{id:`terminal-${o}`,type:"terminal",title:((i==null?void 0:i.command)||"terminal").substring(0,40),data:{command:(i==null?void 0:i.command)||"",output:String((a==null?void 0:a.content)||"")}}}if((t==="Grep"||t==="Glob")&&a){const i=typeof s=="string"?(()=>{try{return JSON.parse(s)}catch{return s}})():s,c=typeof a=="string"?(()=>{try{return JSON.parse(a)}catch{return a}})():a,d=((c==null?void 0:c.toolUseResult)||{}).filenames||[];return{id:`search-${o}`,type:"search",title:`${t}: ${(i==null?void 0:i.pattern)||"search"}`,data:{pattern:(i==null?void 0:i.pattern)||"",files:d}}}if(t==="Read"&&a&&!a.isError){const i=typeof s=="string"?(()=>{try{return JSON.parse(s)}catch{return s}})():s,c=(i==null?void 0:i.file_path)||"file",u=c.split("/").pop()||c;return{id:`code-${o}`,type:"code",title:u,data:{filePath:c,content:String((a==null?void 0:a.content)||"")}}}return null}function Wd(t){return["Edit","Write","ApplyPatch"].includes(t)?"edit":["Grep","Glob"].includes(t)?"search":t==="Bash"?"bash":["TodoWrite","TodoRead"].includes(t)?"todo":["TaskCreate","TaskUpdate","TaskList","TaskGet"].includes(t)?"task":t==="Task"?"agent":t==="exit_plan_mode"||t==="ExitPlanMode"?"plan":t==="AskUserQuestion"?"question":"default"}const ta=l.memo(({toolName:t,toolInput:r,toolResult:s,toolId:a,mode:n,onFileOpen:o,createDiff:i,selectedProject:c,autoExpandTools:u=!1,showRawParameters:d=!1,rawToolInput:m,isSubagentContainer:h,subagentState:p,onArtifactOpen:g})=>{var y,k,I,D,C;if(h&&p)return n==="result"?null:e.jsx(Dd,{toolInput:r,toolResult:s,subagentState:p});const f=Oo(t),x=n==="input"?f.input:f.result,b=l.useMemo(()=>{try{const v=n==="input"?r:s;return typeof v=="string"?JSON.parse(v):v}catch{return n==="input"?r:s}},[n,r,s]),N=l.useCallback(()=>{var v;if((x==null?void 0:x.action)==="open-file"&&o){const E=((v=x.getValue)==null?void 0:v.call(x,b))||"";o(E)}},[x,b,o]),j=l.useCallback(()=>{if(!g)return;const v=Fs(t,a,r,s);v&&g(v)},[g,t,a,r,s,n]);if(!x)return null;if(x.type==="one-line"){const v=((y=x.getValue)==null?void 0:y.call(x,b))||"",E=(k=x.getSecondary)==null?void 0:k.call(x,b),T=g&&Fs(t,a,r,s)!==null;return e.jsxs("div",{className:"group/oneline relative",children:[e.jsx(Id,{toolName:t,toolResult:s,toolId:a,icon:x.icon,label:x.label,value:v,secondary:E,action:x.action,onAction:N,style:x.style,wrapText:x.wrapText,colorScheme:x.colorScheme,resultId:n==="input"?`tool-result-${a}`:void 0}),T&&e.jsx("button",{onClick:j,className:"absolute top-0.5 right-0 opacity-0 group-hover/oneline:opacity-100 transition-opacity text-[10px] px-1 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 bg-white dark:bg-gray-900 z-10",title:"Open in side panel",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]})}if(x.type==="collapsible"){const v=typeof x.title=="function"?x.title(b):x.title||"Details",E=x.defaultOpen!==void 0?x.defaultOpen:u,T=((I=x.getContentProps)==null?void 0:I.call(x,b,{selectedProject:c,createDiff:i,onFileOpen:o}))||{};let W=null;switch(x.contentType){case"diff":i&&(W=e.jsx(Ed,{...T,createDiff:i,onFileClick:()=>o==null?void 0:o(T.filePath)}));break;case"markdown":W=e.jsx(Ld,{content:T.content||""});break;case"file-list":W=e.jsx(Pd,{files:T.files||[],onFileClick:o,title:T.title});break;case"todo-list":((D=T.todos)==null?void 0:D.length)>0&&(W=e.jsx(_d,{todos:T.todos,isResult:T.isResult}));break;case"task":W=e.jsx(zd,{content:T.content||""});break;case"question-answer":W=e.jsx(Od,{questions:T.questions||[],answers:T.answers||{}});break;case"text":W=e.jsx(Rd,{content:T.content||"",format:T.format||"plain"});break;case"success-message":{const R=((C=x.getMessage)==null?void 0:C.call(x,b))||"Success";W=e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),R]});break}}const S=(t==="Edit"||t==="Write"||t==="ApplyPatch")&&T.filePath&&o?()=>o(T.filePath,{old_string:T.oldContent,new_string:T.newContent}):void 0,H=g&&Fs(t,a,r,s)!==null?e.jsx("button",{onClick:R=>{R.preventDefault(),R.stopPropagation(),j()},className:"opacity-0 group-hover/details:opacity-100 transition-opacity text-[10px] px-1.5 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",title:"Open in side panel",children:e.jsx("svg",{className:"w-3 h-3 inline-block",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}):void 0;return e.jsx(Md,{toolName:t,toolId:a,title:v,defaultOpen:E,action:H,onTitleClick:S,showRawParameters:n==="input"&&d,rawContent:m,toolCategory:Wd(t),children:W})}return null});ta.displayName="ToolRenderer";const Ud=l.memo(({message:t,index:r,prevMessage:s,createDiff:a,onFileOpen:n,onShowSettings:o,onGrantToolPermission:i,autoExpandTools:c,showRawParameters:u,showThinking:d,selectedProject:m,provider:h,onArtifactOpen:p})=>{const{t:g}=We("chat"),f=s&&s.type===t.type&&(s.type==="assistant"||s.type==="user"||s.type==="tool"||s.type==="error"),x=it.useRef(null),[b,N]=it.useState(!1),j=wd(t,h),[y,k]=it.useState("idle");it.useEffect(()=>{k("idle")},[j==null?void 0:j.entry,t.toolId]),it.useEffect(()=>{const C=x.current;if(!c||!C||!t.isToolUse)return;const v=new IntersectionObserver(E=>{E.forEach(T=>{T.isIntersecting&&!b&&(N(!0),C.querySelectorAll("details").forEach(S=>{S.open=!0}))})},{threshold:.1});return v.observe(C),()=>{v.unobserve(C)}},[c,b,t.isToolUse]);const I=l.useMemo(()=>new Date(t.timestamp).toLocaleTimeString(),[t.timestamp]);return t.isThinking&&!d?null:e.jsx(xd,{value:p||null,children:e.jsx("div",{ref:x,className:`chat-message ${t.type} ${f?"grouped":""} ${t.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:t.type==="user"?e.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[e.jsxs("div",{className:"bg-blue-600 text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[e.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:t.content}),t.images&&t.images.length>0&&e.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:t.images.map((C,v)=>e.jsx("img",{src:C.data,alt:C.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(C.data,"_blank")},C.name||v))}),e.jsx("div",{className:"text-xs text-blue-100 mt-1 text-right",children:I})]}),!f&&e.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-blue-600 rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):t.isTaskNotification?e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${t.taskStatus==="completed"?"bg-green-400 dark:bg-green-500":"bg-amber-400 dark:bg-amber-500"}`}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:t.content})]})}):e.jsxs("div",{className:"w-full",children:[!f&&e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[t.type==="error"?e.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):t.type==="tool"?e.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:e.jsx(ft,{provider:h,className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t.type==="error"?g("messageTypes.error"):t.type==="tool"?g("messageTypes.tool"):g(h==="cursor"?"messageTypes.cursor":h==="codex"?"messageTypes.codex":"messageTypes.claude")})]}),e.jsxs("div",{className:"w-full",children:[t.isToolUse?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert",children:String(t.displayText||"")})})}),t.toolInput&&e.jsx(ta,{toolName:t.toolName||"UnknownTool",toolInput:t.toolInput,toolResult:t.toolResult,toolId:t.toolId,mode:"input",onFileOpen:n,createDiff:a,selectedProject:m,autoExpandTools:c,showRawParameters:u,rawToolInput:typeof t.toolInput=="string"?t.toolInput:void 0,isSubagentContainer:t.isSubagentContainer,subagentState:t.subagentState,onArtifactOpen:p}),t.toolResult&&!Nd(t.toolName||"UnknownTool",t.toolResult)&&(t.toolResult.isError?e.jsxs("div",{id:`tool-result-${t.toolId}`,className:"relative mt-2 p-3 rounded border scroll-mt-4 bg-red-50/50 dark:bg-red-950/10 border-red-200/60 dark:border-red-800/40",children:[e.jsxs("div",{className:"relative flex items-center gap-1.5 mb-2",children:[e.jsx("svg",{className:"w-4 h-4 text-red-500 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"text-xs font-medium text-red-700 dark:text-red-300",children:g("messageTypes.error")})]}),e.jsxs("div",{className:"relative text-sm text-red-900 dark:text-red-100",children:[e.jsx(Qt,{className:"prose prose-sm max-w-none prose-red dark:prose-invert",children:String(t.toolResult.content||"")}),j&&e.jsxs("div",{className:"mt-4 border-t border-red-200/60 dark:border-red-800/60 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{if(!i)return;const C=i(j);C!=null&&C.success?k("granted"):k("error")},disabled:j.isAllowed||y==="granted",className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${j.isAllowed||y==="granted"?"bg-green-100 dark:bg-green-900/30 border-green-300/70 dark:border-green-800/60 text-green-800 dark:text-green-200 cursor-default":"bg-white/80 dark:bg-gray-900/40 border-red-300/70 dark:border-red-800/60 text-red-700 dark:text-red-200 hover:bg-white dark:hover:bg-gray-900/70"}`,children:j.isAllowed||y==="granted"?g("permissions.added"):g("permissions.grant",{tool:j.toolName})}),o&&e.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),o()},className:"text-xs text-red-700 dark:text-red-200 underline hover:text-red-800 dark:hover:text-red-100",children:g("permissions.openSettings")})]}),e.jsx("div",{className:"mt-2 text-xs text-red-700/90 dark:text-red-200/80",children:g("permissions.addTo",{entry:j.entry})}),y==="error"&&e.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:g("permissions.error")}),(j.isAllowed||y==="granted")&&e.jsx("div",{className:"mt-2 text-xs text-green-700 dark:text-green-200",children:g("permissions.retry")})]})]})]}):e.jsx("div",{id:`tool-result-${t.toolId}`,className:"scroll-mt-4",children:e.jsx(ta,{toolName:t.toolName||"UnknownTool",toolInput:t.toolInput,toolResult:t.toolResult,toolId:t.toolId,mode:"result",onFileOpen:n,createDiff:a,selectedProject:m,autoExpandTools:c,onArtifactOpen:p})}))]}):t.isInteractivePrompt?e.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-amber-500 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-amber-900 dark:text-amber-100 text-base mb-3",children:g("interactive.title")}),(()=>{const C=(t.content||"").split(`
77
- `).filter(T=>T.trim()),v=C.find(T=>T.includes("?"))||C[0]||"",E=[];return C.forEach(T=>{const W=T.match(/[❯\s]*(\d+)\.\s+(.+)/);if(W){const S=T.includes("❯");E.push({number:W[1],text:W[2].trim(),isSelected:S})}}),e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:v}),e.jsx("div",{className:"space-y-2 mb-4",children:E.map(T=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${T.isSelected?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700"} cursor-not-allowed opacity-75`,disabled:!0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${T.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:T.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:T.text}),T.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},T.number))}),e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[e.jsx("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:g("interactive.waiting")}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:g("interactive.instruction")})]})]})})()]})]})}):t.isThinking?e.jsx("div",{className:"text-sm",children:e.jsxs("details",{className:"group rounded-lg border border-purple-500/20 dark:border-purple-400/15 bg-purple-50/30 dark:bg-purple-950/10 overflow-hidden",children:[e.jsxs("summary",{className:"cursor-pointer px-3 py-2 flex items-center gap-2.5 hover:bg-purple-50/50 dark:hover:bg-purple-950/20 transition-colors select-none",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-purple-500 dark:text-purple-400 transition-transform group-open:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("svg",{className:"w-4 h-4 text-purple-500 dark:text-purple-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),e.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:"Thinking"})]}),e.jsx("div",{className:"px-3 pb-3 pt-1 border-t border-purple-500/10 dark:border-purple-400/10",children:e.jsx("div",{className:"pl-3 border-l-2 border-purple-400/30 dark:border-purple-500/20 text-gray-600 dark:text-gray-400 text-sm",children:e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:t.content})})})]})}):e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[d&&t.reasoning&&e.jsxs("details",{className:"mb-3 group/reasoning rounded-lg border border-purple-500/20 dark:border-purple-400/15 bg-purple-50/30 dark:bg-purple-950/10 overflow-hidden",children:[e.jsxs("summary",{className:"cursor-pointer px-3 py-2 flex items-center gap-2.5 hover:bg-purple-50/50 dark:hover:bg-purple-950/20 transition-colors select-none",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-purple-500 dark:text-purple-400 transition-transform group-open/reasoning:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("svg",{className:"w-4 h-4 text-purple-500 dark:text-purple-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),e.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:"Extended thinking"})]}),e.jsx("div",{className:"px-3 pb-3 pt-1 border-t border-purple-500/10 dark:border-purple-400/10",children:e.jsx("div",{className:"pl-3 border-l-2 border-purple-400/30 dark:border-purple-500/20 text-gray-600 dark:text-gray-400 text-sm",children:e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:t.reasoning})})})]}),(()=>{const C=Zs(String(t.content||"")),v=C.trim();if((v.startsWith("{")||v.startsWith("["))&&(v.endsWith("}")||v.endsWith("]")))try{const E=JSON.parse(v),T=JSON.stringify(E,null,2);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),e.jsx("span",{className:"font-medium",children:g("json.response")})]}),e.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("pre",{className:"p-4 overflow-x-auto",children:e.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:T})})})]})}catch{}return t.type==="assistant"?e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:C}):e.jsx("div",{className:"whitespace-pre-wrap",children:C})})()]}),!f&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 mt-1",children:I})]})]})})})}),Wo=({task:t,onClose:r,onEdit:s,onStatusChange:a,onTaskClick:n,isOpen:o=!0,className:i=""})=>{var W;const{addToast:c}=hr(),[u,d]=l.useState(!1),[m,h]=l.useState(t||{}),[p,g]=l.useState(!1),[f,x]=l.useState(!1),[b,N]=l.useState(!1),{currentProject:j,refreshTasks:y}=fr();if(!o||!t)return null;const k=async()=>{if(j){g(!0);try{const S={};if(m.title!==t.title&&(S.title=m.title),m.description!==t.description&&(S.description=m.description),m.details!==t.details&&(S.details=m.details),Object.keys(S).length>0){const O=await Be.taskmaster.updateTask(j.name,t.id,S);if(O.ok)y==null||y(),s==null||s(m),d(!1);else{const H=await O.json();console.error("Failed to update task:",H),c(`Failed to update task: ${H.message}`,"error")}}else d(!1)}catch(S){console.error("Error updating task:",S),c("Error updating task. Please try again.","error")}finally{g(!1)}}},I=()=>{navigator.clipboard.writeText(t.id.toString())},D=S=>{switch(S){case"done":return{icon:Pr,color:"text-green-600 dark:text-green-400",bg:"bg-green-50 dark:bg-green-950"};case"in-progress":return{icon:Ir,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-50 dark:bg-blue-950"};case"review":return{icon:xs,color:"text-amber-600 dark:text-amber-400",bg:"bg-amber-50 dark:bg-amber-950"};case"deferred":return{icon:so,color:"text-gray-500 dark:text-gray-400",bg:"bg-gray-50 dark:bg-gray-800"};case"cancelled":return{icon:Ve,color:"text-red-600 dark:text-red-400",bg:"bg-red-50 dark:bg-red-950"};default:return{icon:ur,color:"text-slate-500 dark:text-slate-400",bg:"bg-slate-50 dark:bg-slate-800"}}},C=D(t.status),v=C.icon,E=S=>{switch(S){case"high":return"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950";case"medium":return"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-950";case"low":return"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-950";default:return"text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-800"}},T=[{value:"pending",label:"Pending"},{value:"in-progress",label:"In Progress"},{value:"review",label:"Review"},{value:"done",label:"Done"},{value:"deferred",label:"Deferred"},{value:"cancelled",label:"Cancelled"}];return e.jsx("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[100] md:p-4 bg-black/50",children:e.jsxs("div",{className:ke("bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 md:rounded-lg shadow-xl","w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",i),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx(v,{className:ke("w-6 h-6",C.color)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("button",{onClick:I,className:"flex items-center gap-1 px-2 py-1 text-xs bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",title:"Click to copy task ID",children:[e.jsxs("span",{children:["Task ",t.id]}),e.jsx(ha,{className:"w-3 h-3"})]}),t.parentId&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Subtask of Task ",t.parentId]})]}),u?e.jsx("input",{type:"text",value:m.title||"",onChange:S=>h({...m,title:S.target.value}),className:"w-full text-lg font-semibold bg-transparent border-b-2 border-blue-500 focus:outline-none text-gray-900 dark:text-white",placeholder:"Task title"}):e.jsx("h1",{className:"text-lg md:text-xl font-semibold text-gray-900 dark:text-white line-clamp-2",children:t.title})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:k,disabled:p,className:"p-2 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:p?"Saving...":"Save changes",children:e.jsx(ts,{className:ke("w-5 h-5",p&&"animate-spin")})}),e.jsx("button",{onClick:()=>{d(!1),h(t)},disabled:p,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Cancel editing",children:e.jsx(Ve,{className:"w-5 h-5"})})]}):e.jsx("button",{onClick:()=>d(!0),className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Edit task",children:e.jsx(Ni,{className:"w-5 h-5"})}),e.jsx("button",{onClick:r,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Close",children:e.jsx(Ve,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 md:p-6 space-y-6 min-h-0",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Status"}),e.jsx("div",{className:ke("w-full px-3 py-2 rounded-md border border-gray-300 dark:border-gray-600",C.bg,C.color),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium capitalize",children:((W=T.find(S=>S.value===t.status))==null?void 0:W.label)||t.status})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Priority"}),e.jsxs("div",{className:ke("px-3 py-2 rounded-md text-sm font-medium capitalize",E(t.priority)),children:[e.jsx(ro,{className:"w-4 h-4 inline mr-2"}),t.priority||"Not set"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Dependencies"}),t.dependencies&&t.dependencies.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:t.dependencies.map(S=>e.jsxs("button",{onClick:()=>n&&n({id:S}),className:"px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 rounded text-sm hover:bg-blue-200 dark:hover:bg-blue-800 transition-colors cursor-pointer disabled:cursor-default disabled:opacity-50",disabled:!n,title:n?`Click to view Task ${S}`:`Task ${S}`,children:[e.jsx(ya,{className:"w-3 h-3 inline mr-1"}),S]},S))}):e.jsx("span",{className:"text-gray-500 dark:text-gray-400 text-sm",children:"No dependencies"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Description"}),u?e.jsx("textarea",{value:m.description||"",onChange:S=>h({...m,description:S.target.value}),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Task description"}):e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.description||"No description provided"})]}),t.details&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("button",{onClick:()=>x(!f),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Implementation Details"}),f?e.jsx(Pt,{className:"w-4 h-4 text-gray-500"}):e.jsx(rr,{className:"w-4 h-4 text-gray-500"})]}),f&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:u?e.jsx("textarea",{value:m.details||"",onChange:S=>h({...m,details:S.target.value}),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Implementation details"}):e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-4",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.details})})})]}),t.testStrategy&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("button",{onClick:()=>N(!b),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Test Strategy"}),b?e.jsx(Pt,{className:"w-4 h-4 text-gray-500"}):e.jsx(rr,{className:"w-4 h-4 text-gray-500"})]}),b&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:e.jsx("div",{className:"bg-blue-50 dark:bg-blue-950 rounded-md p-4",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.testStrategy})})})]}),t.subtasks&&t.subtasks.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Subtasks (",t.subtasks.length,")"]}),e.jsx("div",{className:"space-y-2",children:t.subtasks.map(S=>{const O=D(S.status),H=O.icon;return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx(H,{className:ke("w-4 h-4",O.color)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white truncate",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 truncate",children:S.description})]}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:S.id})]},S.id)})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Task ID: ",t.id]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{onClick:r,className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Close"})})]})]})})},ln=({onShowAllTasks:t,onStartTask:r,className:s=""})=>{const{nextTask:a,tasks:n,currentProject:o,isLoadingTasks:i,projectTaskMaster:c,refreshTasks:u,refreshProjects:d}=fr(),{addToast:m}=hr(),[h,p]=l.useState(!1),[g,f]=l.useState(!1),[x,b]=l.useState(!1),[N,j]=l.useState(!1),[y,k]=l.useState(!1),[I,D]=l.useState(!1),[C,v]=l.useState(!1),E=async()=>{if(o){v(!0);try{const O=await Be.taskmaster.init(o.name);if(O.ok)await d(),f(!1);else{const H=await O.json();console.error("Failed to initialize TaskMaster:",H),m(`Failed to initialize TaskMaster: ${H.message}`,"error")}}catch(O){console.error("Error initializing TaskMaster:",O),m("Error initializing TaskMaster. Please try again.","error")}finally{v(!1)}}},T=()=>{b(!0),f(!1)},W=()=>{j(!0),f(!1)};if(!o||i)return null;let S;if((!n||n.length===0)&&!(c!=null&&c.hasTaskmaster))S=e.jsxs("div",{className:ke("bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-lg p-3 mb-4",s),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qs,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"TaskMaster AI is not configured"}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5"})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:E,disabled:C,className:"text-xs px-2 py-1 bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors flex items-center gap-1 disabled:opacity-50",children:[e.jsx(tr,{className:"w-3 h-3"}),C?"Initializing...":"Initialize TaskMaster AI"]}),e.jsx("button",{onClick:()=>f(!g),className:"text-xs px-1.5 py-1 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-600 dark:text-slate-400 rounded transition-colors",title:"More options",children:g?e.jsx(ao,{className:"w-3 h-3"}):e.jsx(Pt,{className:"w-3 h-3"})})]})]}),g&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-blue-200 dark:border-blue-800",children:[!(c!=null&&c.hasTaskmaster)&&e.jsxs("div",{className:"mb-3 p-3 bg-blue-50 dark:bg-blue-900/50 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-blue-900 dark:text-blue-100 mb-2",children:"🎯 What is TaskMaster?"}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("p",{children:["• ",e.jsx("strong",{children:"AI-Powered Task Management:"})," Break complex projects into manageable subtasks"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"PRD Templates:"})," Generate tasks from Product Requirements Documents"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Dependency Tracking:"})," Understand task relationships and execution order"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Progress Visualization:"})," Kanban boards and detailed task analytics"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"CLI Integration:"})," Use taskmaster commands for advanced workflows"]})]})]}),e.jsx("div",{className:"flex flex-col gap-2",children:c!=null&&c.hasTaskmaster?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 p-2 bg-green-50 dark:bg-green-900/30 rounded text-xs text-green-800 dark:text-green-200",children:[e.jsx("strong",{children:"Add more tasks:"})," Create additional tasks manually or generate them from a PRD template"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-green-100 dark:bg-green-900 hover:bg-green-200 dark:hover:bg-green-800 text-green-800 dark:text-green-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:T,disabled:C,children:[e.jsx(at,{className:"w-3 h-3"}),"Create a new task manually"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-purple-100 dark:bg-purple-900 hover:bg-purple-200 dark:hover:bg-purple-800 text-purple-800 dark:text-purple-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:W,disabled:C,children:[e.jsx(gt,{className:"w-3 h-3"}),C?"Parsing...":"Generate tasks from PRD template"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"text-xs px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:E,disabled:C,children:[e.jsx(tr,{className:"w-3 h-3"}),C?"Initializing...":"Initialize TaskMaster (Auto)"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-800 dark:text-slate-200 rounded transition-colors text-left flex items-center gap-2",onClick:()=>k(!0),children:[e.jsx(vt,{className:"w-3 h-3"}),"Initialize via Terminal (Advanced)"]})]})})]})]});else if(a)S=e.jsx("div",{className:ke("bg-slate-50 dark:bg-slate-900/30 border border-slate-200 dark:border-slate-700 rounded-lg p-3 mb-4",s),children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-5 h-5 bg-blue-100 dark:bg-blue-900/50 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx(Ci,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})}),e.jsxs("span",{className:"text-xs text-slate-600 dark:text-slate-400 font-medium",children:["Task ",a.id]}),a.priority==="high"&&e.jsx("div",{className:"w-4 h-4 rounded bg-red-100 dark:bg-red-900/50 flex items-center justify-center",title:"High Priority",children:e.jsx(tr,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})}),a.priority==="medium"&&e.jsx("div",{className:"w-4 h-4 rounded bg-amber-100 dark:bg-amber-900/50 flex items-center justify-center",title:"Medium Priority",children:e.jsx(ro,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})}),a.priority==="low"&&e.jsx("div",{className:"w-4 h-4 rounded bg-gray-100 dark:bg-gray-800 flex items-center justify-center",title:"Low Priority",children:e.jsx(ur,{className:"w-2.5 h-2.5 text-gray-400 dark:text-gray-500"})})]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-1",children:a.title})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>r==null?void 0:r(),className:"text-xs px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-md font-medium transition-colors shadow-sm flex items-center gap-1",children:[e.jsx(Si,{className:"w-3 h-3"}),"Start Task"]}),e.jsx("button",{onClick:()=>D(!0),className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View task details",children:e.jsx(sr,{className:"w-3 h-3"})}),t&&e.jsx("button",{onClick:t,className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View all tasks",children:e.jsx(Qs,{className:"w-3 h-3"})})]})]})});else if(n&&n.length>0){const O=n.filter(R=>R.status==="done").length,H=n.length;S=e.jsx("div",{className:ke("bg-purple-50 dark:bg-purple-950 border border-purple-200 dark:border-purple-800 rounded-lg p-3 mb-4",s),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pr,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:O===H?"All done! 🎉":"No pending tasks"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[O,"/",H]}),e.jsx("button",{onClick:t,className:"text-xs px-2 py-1 bg-purple-600 hover:bg-purple-700 text-white rounded transition-colors",children:"Review"})]})]})})}else S=null;return e.jsxs(e.Fragment,{children:[S,x&&e.jsx(Hd,{currentProject:o,onClose:()=>b(!1),onTaskCreated:()=>{u(),b(!1)}}),N&&e.jsx(Gd,{currentProject:o,onClose:()=>j(!1),onTemplateApplied:()=>{u(),j(!1)}}),y&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl h-[600px] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(vt,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"TaskMaster Setup"}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Interactive CLI for ",o==null?void 0:o.displayName]})]})]}),e.jsx("button",{onClick:()=>k(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"h-full bg-black rounded-lg overflow-hidden",children:e.jsx(lo,{selectedProject:o,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0})})}),e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"TaskMaster initialization will start automatically"}),e.jsx("button",{onClick:()=>k(!1),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Close"})]})})]})}),I&&a&&e.jsx(Wo,{task:a,isOpen:I,onClose:()=>D(!1),onStatusChange:()=>u==null?void 0:u(),onTaskClick:null})]})},Hd=({currentProject:t,onClose:r,onTaskCreated:s})=>{const[a,n]=l.useState({title:"",description:"",priority:"medium",useAI:!1,prompt:""}),[o,i]=l.useState(!1),c=async u=>{if(u.preventDefault(),!!t){i(!0);try{const d=a.useAI?{prompt:a.prompt,priority:a.priority}:{title:a.title,description:a.description,priority:a.priority},m=await Be.taskmaster.addTask(t.name,d);if(m.ok)s();else{const h=await m.json();console.error("Failed to create task:",h),addToast(`Failed to create task: ${h.message}`,"error")}}catch(d){console.error("Error creating task:",d),addToast("Error creating task. Please try again.","error")}finally{i(!1)}}};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Create New Task"}),e.jsx("button",{onClick:r,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:e.jsx(Ve,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:c,className:"space-y-4",children:[e.jsx("div",{children:e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[e.jsx("input",{type:"checkbox",checked:a.useAI,onChange:u=>n(d=>({...d,useAI:u.target.checked}))}),"Use AI to generate task details"]})}),a.useAI?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Description (AI will generate details)"}),e.jsx("textarea",{value:a.prompt,onChange:u=>n(d=>({...d,prompt:u.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe what you want to accomplish...",required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Title"}),e.jsx("input",{type:"text",value:a.title,onChange:u=>n(d=>({...d,title:u.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Enter task title...",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Description"}),e.jsx("textarea",{value:a.description,onChange:u=>n(d=>({...d,description:u.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe the task...",required:!0})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Priority"}),e.jsxs("select",{value:a.priority,onChange:u=>n(d=>({...d,priority:u.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx("button",{type:"button",onClick:r,className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",disabled:o,children:"Cancel"}),e.jsx("button",{type:"submit",className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded disabled:opacity-50",disabled:o||a.useAI&&!a.prompt.trim()||!a.useAI&&(!a.title.trim()||!a.description.trim()),children:o?"Creating...":"Create Task"})]})]})]})})},Gd=({currentProject:t,onClose:r,onTemplateApplied:s})=>{const[a,n]=l.useState([]),[o,i]=l.useState(null),[c,u]=l.useState({}),[d,m]=l.useState("prd.txt"),[h,p]=l.useState(!0),[g,f]=l.useState(!1),[x,b]=l.useState("select");useEffect(()=>{(async()=>{try{const k=await Be.taskmaster.getTemplates();if(k.ok){const I=await k.json();n(I.templates)}}catch(k){console.error("Error loading templates:",k)}finally{p(!1)}})()},[]);const N=y=>{i(y);const k=y.content.match(/\[([^\]]+)\]/g)||[],I=[...new Set(k.map(C=>C.slice(1,-1)))],D={};I.forEach(C=>{D[C]=""}),u(D),b("customize")},j=async()=>{if(!(!o||!t)){f(!0);try{const y=await Be.taskmaster.applyTemplate(t.name,{templateId:o.id,fileName:d,customizations:c});if(!y.ok){const I=await y.json();throw new Error(I.message||"Failed to apply template")}const k=await Be.taskmaster.parsePRD(t.name,{fileName:d,numTasks:10});if(!k.ok){const I=await k.json();throw new Error(I.message||"Failed to generate tasks")}b("generate"),setTimeout(()=>{s()},2e3)}catch(y){console.error("Error applying template:",y),addToast(`Error: ${y.message}`,"error"),f(!1)}}};return h?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading templates..."})]})})}):e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:x==="select"?"Select PRD Template":x==="customize"?"Customize Template":"Generating Tasks"}),e.jsx("button",{onClick:r,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:e.jsx(Ve,{className:"w-4 h-4"})})]}),x==="select"&&e.jsx("div",{className:"space-y-3",children:a.map(y=>e.jsx("div",{className:"p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer transition-colors",onClick:()=>N(y),children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white",children:y.name}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:y.description}),e.jsx("span",{className:"inline-block text-xs bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 px-2 py-1 rounded mt-2",children:y.category})]}),e.jsx(ya,{className:"w-4 h-4 text-gray-400 mt-1"})]})},y.id))}),x==="customize"&&o&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"File Name"}),e.jsx("input",{type:"text",value:d,onChange:y=>m(y.target.value),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"prd.txt"})]}),Object.keys(c).length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Customize Template"}),e.jsx("div",{className:"space-y-3",children:Object.entries(c).map(([y,k])=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:y.replace(/([A-Z])/g," $1").replace(/^./,I=>I.toUpperCase())}),e.jsx("input",{type:"text",value:k,onChange:I=>u(D=>({...D,[y]:I.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:`Enter ${y.toLowerCase()}`})]},y))})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx("button",{onClick:()=>b("select"),className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",children:"Back"}),e.jsx("button",{onClick:j,className:"flex-1 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded disabled:opacity-50",disabled:g,children:g?"Applying...":"Apply & Generate Tasks"})]})]}),x==="generate"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Pr,{className:"w-8 h-8 text-green-600 dark:text-green-400"})}),e.jsx("h4",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"Template Applied Successfully!"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Your PRD has been created and tasks are being generated..."})]})]})})},Ta={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"},{value:"opusplan",label:"Opus Plan"},{value:"sonnet[1m]",label:"Sonnet [1M]"}],DEFAULT:"sonnet"},Aa={OPTIONS:[{value:"gpt-5.2-high",label:"GPT-5.2 High"},{value:"gemini-3-pro",label:"Gemini 3 Pro"},{value:"opus-4.5-thinking",label:"Claude 4.5 Opus (Thinking)"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1",label:"GPT-5.1"},{value:"gpt-5.1-high",label:"GPT-5.1 High"},{value:"composer-1",label:"Composer 1"},{value:"auto",label:"Auto"},{value:"sonnet-4.5",label:"Claude 4.5 Sonnet"},{value:"sonnet-4.5-thinking",label:"Claude 4.5 Sonnet (Thinking)"},{value:"opus-4.5",label:"Claude 4.5 Opus"},{value:"gpt-5.1-codex",label:"GPT-5.1 Codex"},{value:"gpt-5.1-codex-high",label:"GPT-5.1 Codex High"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-max-high",label:"GPT-5.1 Codex Max High"},{value:"opus-4.1",label:"Claude 4.1 Opus"},{value:"grok",label:"Grok"}],DEFAULT:"gpt-5"},Ia={OPTIONS:[{value:"gpt-5.3-codex",label:"GPT-5.3 Codex"},{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"o3",label:"O3"},{value:"o4-mini",label:"O4-mini"}],DEFAULT:"gpt-5.2"},Vd=[{id:"claude",name:"Claude Code",infoKey:"providerSelection.providerInfo.anthropic",accent:"border-primary",ring:"ring-primary/15",check:"bg-primary text-primary-foreground"},{id:"cursor",name:"Cursor",infoKey:"providerSelection.providerInfo.cursorEditor",accent:"border-violet-500 dark:border-violet-400",ring:"ring-violet-500/15",check:"bg-violet-500 text-white"},{id:"codex",name:"Codex",infoKey:"providerSelection.providerInfo.openai",accent:"border-emerald-600 dark:border-emerald-400",ring:"ring-emerald-600/15",check:"bg-emerald-600 dark:bg-emerald-500 text-white"}];function qd(t){return t==="claude"?Ta:t==="codex"?Ia:Aa}function Kd(t,r,s,a){return t==="claude"?r:t==="codex"?a:s}function Jd({selectedSession:t,currentSessionId:r,provider:s,setProvider:a,textareaRef:n,claudeModel:o,setClaudeModel:i,cursorModel:c,setCursorModel:u,codexModel:d,setCodexModel:m,tasksEnabled:h,isTaskMasterInstalled:p,onShowAllTasks:g,setInput:f}){const{t:x}=We("chat"),b=x("tasks.nextTaskPrompt",{defaultValue:"Start the next task"}),N=I=>{a(I),localStorage.setItem("selected-provider",I),setTimeout(()=>{var D;return(D=n.current)==null?void 0:D.focus()},100)},j=I=>{s==="claude"?(i(I),localStorage.setItem("claude-model",I)):s==="codex"?(m(I),localStorage.setItem("codex-model",I)):(u(I),localStorage.setItem("cursor-model",I))},y=qd(s),k=Kd(s,o,c,d);return!t&&!r?e.jsx("div",{className:"flex items-center justify-center h-full px-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h2",{className:"text-lg sm:text-xl font-semibold text-foreground tracking-tight",children:x("providerSelection.title")}),e.jsx("p",{className:"text-[13px] text-muted-foreground mt-1",children:x("providerSelection.description")})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:gap-2.5 mb-6",children:Vd.map(I=>{const D=s===I.id;return e.jsxs("button",{onClick:()=>N(I.id),className:`
75
+ `))}return typeof p=="string"?e.jsx("div",{className:"whitespace-pre-wrap break-words line-clamp-6",children:p}):p?e.jsx("pre",{className:"whitespace-pre-wrap break-words line-clamp-6 font-mono text-[11px]",children:JSON.stringify(p,null,2)}):null})()})]})})},Pd=({content:t,className:r="mt-1 prose prose-sm max-w-none dark:prose-invert"})=>e.jsx(Qt,{className:r,children:t}),$d=({files:t,onFileClick:r,title:s})=>e.jsxs("div",{children:[s&&e.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400 mb-1",children:s}),e.jsx("div",{className:"flex flex-wrap gap-x-1 gap-y-0.5 max-h-48 overflow-y-auto",children:t.map((a,n)=>{const o=typeof a=="string"?a:a.path,i=o.split("/").pop()||o,c=typeof a=="string"?()=>r==null?void 0:r(a):a.onClick;return e.jsxs("span",{className:"inline-flex items-center",children:[e.jsx("button",{onClick:c,className:"text-[11px] font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline transition-colors",title:o,children:i}),n<t.length-1&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px] ml-1",children:","})]},n)})})]}),_d=({todos:t,isResult:r=!1})=>{if(!t||!Array.isArray(t))return null;const s=o=>{switch(o){case"completed":return e.jsx(Ni,{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(Ir,{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400"});case"pending":default:return e.jsx(ur,{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500"})}},a=o=>{switch(o){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 border-green-200 dark:border-green-800";case"in_progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-200 border-blue-200 dark:border-blue-800";case"pending":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},n=o=>{switch(o){case"high":return"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 border-red-200 dark:border-red-800";case"medium":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800";case"low":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}};return e.jsxs("div",{className:"space-y-1.5",children:[r&&e.jsxs("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1.5",children:["Todo List (",t.length," ",t.length===1?"item":"items",")"]}),t.map((o,i)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:s(o.status)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-0.5",children:[e.jsx("p",{className:`text-xs font-medium ${o.status==="completed"?"line-through text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100"}`,children:o.content}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(bt,{variant:"outline",className:`text-[10px] px-1.5 py-px ${n(o.priority)}`,children:o.priority}),e.jsx(bt,{variant:"outline",className:`text-[10px] px-1.5 py-px ${a(o.status)}`,children:o.status.replace("_"," ")})]})]})})]},o.id||`todo-${i}`))]})},Fd=({todos:t,isResult:r=!1})=>e.jsx(_d,{todos:t,isResult:r});function zd(t){const r=[],s=t.split(`
76
+ `);for(const a of s){const n=a.match(/#(\d+)\.?\s*(?:\[(\w+)\]\s*)?(.+?)(?:\s*\((?:owner:\s*\w+)?\))?$/);if(n){const[,o,i,c]=n,u=a.match(/blockedBy:\s*\[([^\]]*)\]/);r.push({id:o,subject:c.trim(),status:i||"pending",blockedBy:u?u[1].split(",").map(d=>d.trim()).filter(Boolean):void 0})}}return r}const ln={completed:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),textClass:"line-through text-gray-400 dark:text-gray-500",badgeClass:"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300 border-green-200 dark:border-green-800"},in_progress:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),textClass:"text-gray-900 dark:text-gray-100",badgeClass:"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-800"},pending:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})}),textClass:"text-gray-700 dark:text-gray-300",badgeClass:"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},Rd=({content:t})=>{const r=zd(t);if(r.length===0)return e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-gray-400 whitespace-pre-wrap",children:t});const s=r.filter(n=>n.status==="completed").length,a=r.length;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[s,"/",a," completed"]}),e.jsx("div",{className:"flex-1 h-1 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-green-500 dark:bg-green-400 rounded-full transition-all",style:{width:`${a>0?s/a*100:0}%`}})})]}),e.jsx("div",{className:"space-y-px",children:r.map(n=>{const o=ln[n.status]||ln.pending;return e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 group",children:[e.jsx("span",{className:"flex-shrink-0",children:o.icon}),e.jsxs("span",{className:"text-[11px] font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:["#",n.id]}),e.jsx("span",{className:`text-xs truncate flex-1 ${o.textClass}`,children:n.subject}),e.jsx("span",{className:`text-[10px] px-1 py-px rounded border flex-shrink-0 ${o.badgeClass}`,children:n.status.replace("_"," ")})]},n.id)})})]})},Od=({content:t,format:r="plain",className:s=""})=>{if(r==="json"){let a=t;try{const n=JSON.parse(t);a=JSON.stringify(n,null,2)}catch{}return e.jsx("pre",{className:`mt-1 text-xs bg-gray-900 dark:bg-gray-950 text-gray-100 p-2.5 rounded overflow-x-auto font-mono ${s}`,children:a})}return r==="code"?e.jsx("pre",{className:`mt-1 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/50 dark:border-gray-700/50 p-2 rounded whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono ${s}`,children:t}):e.jsx("div",{className:`mt-1 text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap ${s}`,children:t})},Bd=({questions:t,answers:r,className:s=""})=>{const[a,n]=l.useState(null);if(!t||t.length===0)return null;const o=Object.keys(r||{}).length>0,i=t.length;return e.jsxs("div",{className:`space-y-2 ${s}`,children:[t.map((c,u)=>{const d=r==null?void 0:r[c.question],m=d?d.split(", "):[],h=!d,p=a===u;return e.jsxs("div",{className:"rounded-lg border border-gray-150 dark:border-gray-700/50 bg-gray-50/50 dark:bg-gray-800/30 overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>n(p?null:u),className:"w-full text-left px-3 py-2 flex items-start gap-2.5 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-4 h-4 rounded-full flex items-center justify-center ${m.length>0?"bg-blue-100 dark:bg-blue-900/40":"bg-gray-100 dark:bg-gray-800"}`,children:m.length>0?e.jsx("svg",{className:"w-2.5 h-2.5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-300 dark:bg-gray-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.header&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase tracking-wider bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 border border-blue-100/80 dark:border-blue-800/40",children:c.header}),i>1&&e.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500",children:[u+1,"/",i]})]}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5 leading-snug",children:c.question}),!p&&m.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:m.map(g=>{const f=!c.options.some(x=>x.label===g);return e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded-md bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium",children:[g,f&&e.jsx("span",{className:"text-[9px] text-blue-400 dark:text-blue-500 font-normal",children:"(custom)"})]},g)})}),!p&&h&&o&&e.jsx("span",{className:"inline-block mt-1 text-[10px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]}),e.jsx("svg",{className:`w-3.5 h-3.5 mt-0.5 text-gray-400 dark:text-gray-500 flex-shrink-0 transition-transform duration-200 ${p?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),p&&e.jsx("div",{className:"px-3 pb-2.5 pt-0.5 border-t border-gray-100 dark:border-gray-700/40",children:e.jsxs("div",{className:"space-y-1 ml-6.5",children:[c.options.map(g=>{const f=m.includes(g.label);return e.jsxs("div",{className:`flex items-start gap-2 px-2.5 py-1.5 rounded-lg text-[12px] ${f?"bg-blue-50/80 dark:bg-blue-900/20 border border-blue-200/60 dark:border-blue-800/40":"text-gray-400 dark:text-gray-500"}`,children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-3.5 h-3.5 ${c.multiSelect?"rounded-[3px]":"rounded-full"} border-[1.5px] flex items-center justify-center ${f?"border-blue-500 dark:border-blue-400 bg-blue-500 dark:bg-blue-500":"border-gray-300 dark:border-gray-600"}`,children:f&&e.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:f?"text-gray-900 dark:text-gray-100 font-medium":"",children:g.label}),g.description&&e.jsx("span",{className:`block text-[11px] mt-0.5 ${f?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-600"}`,children:g.description})]})]},g.label)}),m.filter(g=>!c.options.some(f=>f.label===g)).map(g=>e.jsxs("div",{className:"flex items-start gap-2 px-2.5 py-1.5 rounded-lg text-[12px] bg-blue-50/80 dark:bg-blue-900/20 border border-blue-200/60 dark:border-blue-800/40",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-3.5 h-3.5 ${c.multiSelect?"rounded-[3px]":"rounded-full"} border-[1.5px] border-blue-500 dark:border-blue-400 bg-blue-500 dark:bg-blue-500 flex items-center justify-center`,children:e.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium",children:g}),e.jsx("span",{className:"text-[10px] text-blue-500 dark:text-blue-400 ml-1",children:"(custom)"})]})]},g)),h&&o&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic px-2.5 py-1",children:"No answer provided"})]})})]},u)}),!o&&i===1&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]})},Wd=({request:t,onDecision:r})=>{const s=t.input,a=(s==null?void 0:s.questions)||[],[n,o]=l.useState(0),[i,c]=l.useState(()=>new Map),[u,d]=l.useState(()=>new Map),[m,h]=l.useState(()=>new Map),[p,g]=l.useState(!1),f=l.useRef(null),x=l.useRef(null);l.useEffect(()=>{requestAnimationFrame(()=>g(!0))},[]),l.useEffect(()=>{var A;m.get(n)||(A=f.current)==null||A.focus()},[n,m]),l.useEffect(()=>{var A;m.get(n)&&((A=x.current)==null||A.focus())},[m,n]);const b=l.useCallback((A,z,J)=>{c(re=>{const G=new Map(re),ie=new Set(G.get(A)||[]);return J?ie.has(z)?ie.delete(z):ie.add(z):(ie.clear(),ie.add(z),h($=>{const Z=new Map($);return Z.set(A,!1),Z})),G.set(A,ie),G})},[]),N=l.useCallback((A,z)=>{h(J=>{const re=new Map(J),G=re.get(A)||!1;return re.set(A,!G),!z&&!G&&c(ie=>{const $=new Map(ie);return $.set(A,new Set),$}),re})},[]),j=l.useCallback((A,z)=>{d(J=>{const re=new Map(J);return re.set(A,z),re})},[]),y=l.useCallback(()=>{const A={};return a.forEach((z,J)=>{const re=Array.from(i.get(J)||[]),G=m.get(J)||!1,ie=(u.get(J)||"").trim();G&&ie&&re.push(ie),re.length>0&&(A[z.question]=re.join(", "))}),A},[a,i,m,u]),k=l.useCallback(()=>{r(t.requestId,{allow:!0,updatedInput:{...s,answers:y()}})},[r,t.requestId,s,y]),I=l.useCallback(()=>{r(t.requestId,{allow:!0,updatedInput:{...s,answers:{}}})},[r,t.requestId,s]),D=l.useCallback(A=>{if(A.target instanceof HTMLInputElement)return;const z=a[n];if(!z)return;const J=z.multiSelect||!1,re=z.options.length,G=parseInt(A.key);if(!isNaN(G)&&G>=1&&G<=re){A.preventDefault(),b(n,z.options[G-1].label,J);return}if(A.key==="0"){A.preventDefault(),N(n,J);return}if(A.key==="Enter"){A.preventDefault(),n===a.length-1?k():o($=>$+1);return}if(A.key==="Escape"){A.preventDefault(),I();return}},[n,a,b,N,k,I]);if(a.length===0)return null;const C=a.length,v=C===1,E=a[n],T=E.multiSelect||!1,W=i.get(n)||new Set,S=m.get(n)||!1,O=n===C-1,H=n===0,R=W.size>0||S&&(u.get(n)||"").trim().length>0;return e.jsx("div",{ref:f,tabIndex:-1,onKeyDown:D,className:`w-full outline-none transition-all duration-500 ease-out ${p?"opacity-100 translate-y-0":"opacity-0 translate-y-3"}`,children:e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-gray-200/80 dark:border-gray-700/50 bg-white dark:bg-gray-800/90 shadow-lg dark:shadow-2xl",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-blue-500 via-cyan-400 to-teal-400"}),e.jsxs("div",{className:"px-4 pt-3.5 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:"w-6 h-6 rounded-lg bg-gradient-to-br from-blue-500/10 to-cyan-500/10 dark:from-blue-400/15 dark:to-cyan-400/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-600 dark:text-blue-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.75,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827m0 3h.01"})})}),e.jsx("div",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-cyan-400 dark:bg-cyan-500 animate-pulse"})]}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"text-[10px] font-medium tracking-wide uppercase text-gray-400 dark:text-gray-500",children:"Claude needs your input"}),E.header&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-px rounded text-[9px] font-semibold uppercase tracking-wider bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 border border-blue-100 dark:border-blue-800/50",children:E.header})]}),!v&&e.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500 flex-shrink-0",children:[n+1,"/",C]})]}),!v&&e.jsx("div",{className:"flex items-center gap-1 mb-2",children:a.map((A,z)=>e.jsx("button",{type:"button",onClick:()=>o(z),className:`h-[3px] rounded-full transition-all duration-300 ${z===n?"w-5 bg-blue-500 dark:bg-blue-400":z<n?"w-2.5 bg-blue-300 dark:bg-blue-600":"w-2.5 bg-gray-200 dark:bg-gray-700"}`},z))}),e.jsx("p",{className:"text-[14px] leading-snug font-medium text-gray-900 dark:text-gray-100",children:E.question}),T&&e.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500",children:"Select all that apply"})]}),e.jsx("div",{className:"px-4 pb-2 max-h-48 overflow-y-auto scrollbar-thin",role:T?"group":"radiogroup","aria-label":E.question,children:e.jsxs("div",{className:"space-y-1",children:[E.options.map((A,z)=>{const J=W.has(A.label);return e.jsxs("button",{type:"button",onClick:()=>b(n,A.label,T),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${J?"border-blue-300 dark:border-blue-600 bg-blue-50/80 dark:bg-blue-900/25 ring-1 ring-blue-200/50 dark:ring-blue-700/30":"border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50/60 dark:hover:bg-gray-750/50"}`,children:[e.jsx("kbd",{className:`flex-shrink-0 w-5 h-5 rounded text-[10px] font-mono flex items-center justify-center transition-all duration-150 ${J?"bg-blue-500 dark:bg-blue-500 text-white font-semibold":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"}`,children:z+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-[13px] leading-tight transition-colors duration-150 ${J?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-700 dark:text-gray-300"}`,children:A.label}),A.description&&e.jsx("div",{className:`text-[11px] leading-snug transition-colors duration-150 ${J?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-500"}`,children:A.description})]}),J&&e.jsx("svg",{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]},A.label)}),e.jsxs("button",{type:"button",onClick:()=>N(n,T),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${S?"border-blue-300 dark:border-blue-600 bg-blue-50/80 dark:bg-blue-900/25 ring-1 ring-blue-200/50 dark:ring-blue-700/30":"border-dashed border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50/60 dark:hover:bg-gray-750/50"}`,children:[e.jsx("kbd",{className:`flex-shrink-0 w-5 h-5 rounded text-[10px] font-mono flex items-center justify-center transition-all duration-150 ${S?"bg-blue-500 dark:bg-blue-500 text-white font-semibold":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"}`,children:"0"}),e.jsx("span",{className:`text-[13px] leading-tight transition-colors ${S?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-500 dark:text-gray-400"}`,children:"Other..."}),S&&e.jsx("svg",{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]}),S&&e.jsx("div",{className:"pl-[30px] pr-0.5",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:x,type:"text",value:u.get(n)||"",onChange:A=>j(n,A.target.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),O?k():o(z=>z+1)),A.stopPropagation()},placeholder:"Type your answer...",className:"w-full text-[13px] rounded-lg border-0 bg-gray-50 dark:bg-gray-900/60 text-gray-900 dark:text-gray-100 px-3 py-1.5 outline-none ring-1 ring-gray-200 dark:ring-gray-700 focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 placeholder:text-gray-400 dark:placeholder:text-gray-600 transition-shadow duration-200"}),e.jsx("kbd",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[9px] font-mono text-gray-300 dark:text-gray-600 bg-gray-100 dark:bg-gray-800 px-1 py-0.5 rounded border border-gray-200 dark:border-gray-700",children:"Enter"})]})})]})}),e.jsxs("div",{className:"px-4 py-2 border-t border-gray-100 dark:border-gray-700/50 bg-gray-50/50 dark:bg-gray-800/50 flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:I,className:"text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:[v?"Skip":"Skip all",e.jsx("span",{className:"ml-1 text-[9px] text-gray-300 dark:text-gray-600",children:"Esc"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[!v&&!H&&e.jsxs("button",{type:"button",onClick:()=>o(A=>A-1),className:"inline-flex items-center gap-0.5 text-[11px] font-medium px-2.5 py-1.5 rounded-lg text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700/60 transition-all duration-150",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),"Back"]}),O?e.jsxs("button",{type:"button",onClick:k,disabled:!R&&!Object.keys(y()).length,className:"inline-flex items-center gap-1 text-[11px] font-semibold px-3.5 py-1.5 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 dark:from-blue-500 dark:to-blue-600 text-white shadow-sm hover:shadow-md disabled:opacity-30 disabled:cursor-not-allowed disabled:shadow-none transition-all duration-200",children:["Submit",e.jsx("span",{className:"text-[9px] opacity-70 font-mono ml-0.5",children:"Enter"})]}):e.jsxs("button",{type:"button",onClick:()=>o(A=>A+1),className:"inline-flex items-center gap-1 text-[11px] font-semibold px-3.5 py-1.5 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 dark:from-blue-500 dark:to-blue-600 text-white shadow-sm hover:shadow-md transition-all duration-200",children:["Next",e.jsx("span",{className:"text-[9px] opacity-70 font-mono ml-0.5",children:"Enter"})]})]})]})]})})};function Fs(t,r,s,a,n){const o=`${t}-${r||Date.now()}`;if(t==="Edit"||t==="Write"||t==="ApplyPatch"){const i=typeof s=="string"?(()=>{try{return JSON.parse(s)}catch{return s}})():s,c=(i==null?void 0:i.file_path)||"file",u=c.split("/").pop()||c;return{id:`diff-${o}`,type:"diff",title:u,data:{filePath:c,oldContent:(i==null?void 0:i.old_string)||"",newContent:t==="Write"?(i==null?void 0:i.content)||"":(i==null?void 0:i.new_string)||"",badge:t==="Write"?"New":t==="ApplyPatch"?"Patch":"Edit"}}}if(t==="Bash"&&a&&!a.isError){const i=typeof s=="string"?(()=>{try{return JSON.parse(s)}catch{return s}})():s;return{id:`terminal-${o}`,type:"terminal",title:((i==null?void 0:i.command)||"terminal").substring(0,40),data:{command:(i==null?void 0:i.command)||"",output:String((a==null?void 0:a.content)||"")}}}if((t==="Grep"||t==="Glob")&&a){const i=typeof s=="string"?(()=>{try{return JSON.parse(s)}catch{return s}})():s,c=typeof a=="string"?(()=>{try{return JSON.parse(a)}catch{return a}})():a,d=((c==null?void 0:c.toolUseResult)||{}).filenames||[];return{id:`search-${o}`,type:"search",title:`${t}: ${(i==null?void 0:i.pattern)||"search"}`,data:{pattern:(i==null?void 0:i.pattern)||"",files:d}}}if(t==="Read"&&a&&!a.isError){const i=typeof s=="string"?(()=>{try{return JSON.parse(s)}catch{return s}})():s,c=(i==null?void 0:i.file_path)||"file",u=c.split("/").pop()||c;return{id:`code-${o}`,type:"code",title:u,data:{filePath:c,content:String((a==null?void 0:a.content)||"")}}}return null}function Ud(t){return["Edit","Write","ApplyPatch"].includes(t)?"edit":["Grep","Glob"].includes(t)?"search":t==="Bash"?"bash":["TodoWrite","TodoRead"].includes(t)?"todo":["TaskCreate","TaskUpdate","TaskList","TaskGet"].includes(t)?"task":t==="Task"?"agent":t==="exit_plan_mode"||t==="ExitPlanMode"?"plan":t==="AskUserQuestion"?"question":"default"}const ra=l.memo(({toolName:t,toolInput:r,toolResult:s,toolId:a,mode:n,onFileOpen:o,createDiff:i,selectedProject:c,autoExpandTools:u=!1,showRawParameters:d=!1,rawToolInput:m,isSubagentContainer:h,subagentState:p,onArtifactOpen:g})=>{var y,k,I,D,C;if(h&&p)return n==="result"?null:e.jsx(Ld,{toolInput:r,toolResult:s,subagentState:p});const f=Bo(t),x=n==="input"?f.input:f.result,b=l.useMemo(()=>{try{const v=n==="input"?r:s;return typeof v=="string"?JSON.parse(v):v}catch{return n==="input"?r:s}},[n,r,s]),N=l.useCallback(()=>{var v;if((x==null?void 0:x.action)==="open-file"&&o){const E=((v=x.getValue)==null?void 0:v.call(x,b))||"";o(E)}},[x,b,o]),j=l.useCallback(()=>{if(!g)return;const v=Fs(t,a,r,s);v&&g(v)},[g,t,a,r,s,n]);if(!x)return null;if(x.type==="one-line"){const v=((y=x.getValue)==null?void 0:y.call(x,b))||"",E=(k=x.getSecondary)==null?void 0:k.call(x,b),T=g&&Fs(t,a,r,s)!==null;return e.jsxs("div",{className:"group/oneline relative",children:[e.jsx(Md,{toolName:t,toolResult:s,toolId:a,icon:x.icon,label:x.label,value:v,secondary:E,action:x.action,onAction:N,style:x.style,wrapText:x.wrapText,colorScheme:x.colorScheme,resultId:n==="input"?`tool-result-${a}`:void 0}),T&&e.jsx("button",{onClick:j,className:"absolute top-0.5 right-0 opacity-0 group-hover/oneline:opacity-100 transition-opacity text-[10px] px-1 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 bg-white dark:bg-gray-900 z-10",title:"Open in side panel",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]})}if(x.type==="collapsible"){const v=typeof x.title=="function"?x.title(b):x.title||"Details",E=x.defaultOpen!==void 0?x.defaultOpen:u,T=((I=x.getContentProps)==null?void 0:I.call(x,b,{selectedProject:c,createDiff:i,onFileOpen:o}))||{};let W=null;switch(x.contentType){case"diff":i&&(W=e.jsx(Td,{...T,createDiff:i,onFileClick:()=>o==null?void 0:o(T.filePath)}));break;case"markdown":W=e.jsx(Pd,{content:T.content||""});break;case"file-list":W=e.jsx($d,{files:T.files||[],onFileClick:o,title:T.title});break;case"todo-list":((D=T.todos)==null?void 0:D.length)>0&&(W=e.jsx(Fd,{todos:T.todos,isResult:T.isResult}));break;case"task":W=e.jsx(Rd,{content:T.content||""});break;case"question-answer":W=e.jsx(Bd,{questions:T.questions||[],answers:T.answers||{}});break;case"text":W=e.jsx(Od,{content:T.content||"",format:T.format||"plain"});break;case"success-message":{const R=((C=x.getMessage)==null?void 0:C.call(x,b))||"Success";W=e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),R]});break}}const S=(t==="Edit"||t==="Write"||t==="ApplyPatch")&&T.filePath&&o?()=>o(T.filePath,{old_string:T.oldContent,new_string:T.newContent}):void 0,H=g&&Fs(t,a,r,s)!==null?e.jsx("button",{onClick:R=>{R.preventDefault(),R.stopPropagation(),j()},className:"opacity-0 group-hover/details:opacity-100 transition-opacity text-[10px] px-1.5 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",title:"Open in side panel",children:e.jsx("svg",{className:"w-3 h-3 inline-block",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}):void 0;return e.jsx(Dd,{toolName:t,toolId:a,title:v,defaultOpen:E,action:H,onTitleClick:S,showRawParameters:n==="input"&&d,rawContent:m,toolCategory:Ud(t),children:W})}return null});ra.displayName="ToolRenderer";const Hd=l.memo(({message:t,index:r,prevMessage:s,createDiff:a,onFileOpen:n,onShowSettings:o,onGrantToolPermission:i,autoExpandTools:c,showRawParameters:u,showThinking:d,selectedProject:m,provider:h,onArtifactOpen:p})=>{const{t:g}=We("chat"),f=s&&s.type===t.type&&(s.type==="assistant"||s.type==="user"||s.type==="tool"||s.type==="error"),x=it.useRef(null),[b,N]=it.useState(!1),j=jd(t,h),[y,k]=it.useState("idle");it.useEffect(()=>{k("idle")},[j==null?void 0:j.entry,t.toolId]),it.useEffect(()=>{const C=x.current;if(!c||!C||!t.isToolUse)return;const v=new IntersectionObserver(E=>{E.forEach(T=>{T.isIntersecting&&!b&&(N(!0),C.querySelectorAll("details").forEach(S=>{S.open=!0}))})},{threshold:.1});return v.observe(C),()=>{v.unobserve(C)}},[c,b,t.isToolUse]);const I=l.useMemo(()=>new Date(t.timestamp).toLocaleTimeString(),[t.timestamp]);return t.isThinking&&!d?null:e.jsx(gd,{value:p||null,children:e.jsx("div",{ref:x,className:`chat-message ${t.type} ${f?"grouped":""} ${t.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:t.type==="user"?e.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[e.jsxs("div",{className:"bg-blue-600 text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[e.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:t.content}),t.images&&t.images.length>0&&e.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:t.images.map((C,v)=>e.jsx("img",{src:C.data,alt:C.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(C.data,"_blank")},C.name||v))}),e.jsx("div",{className:"text-xs text-blue-100 mt-1 text-right",children:I})]}),!f&&e.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-blue-600 rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):t.isTaskNotification?e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${t.taskStatus==="completed"?"bg-green-400 dark:bg-green-500":"bg-amber-400 dark:bg-amber-500"}`}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:t.content})]})}):e.jsxs("div",{className:"w-full",children:[!f&&e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[t.type==="error"?e.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):t.type==="tool"?e.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:e.jsx(ft,{provider:h,className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t.type==="error"?g("messageTypes.error"):t.type==="tool"?g("messageTypes.tool"):g(h==="cursor"?"messageTypes.cursor":h==="codex"?"messageTypes.codex":"messageTypes.claude")})]}),e.jsxs("div",{className:"w-full",children:[t.isToolUse?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert",children:String(t.displayText||"")})})}),t.toolInput&&e.jsx(ra,{toolName:t.toolName||"UnknownTool",toolInput:t.toolInput,toolResult:t.toolResult,toolId:t.toolId,mode:"input",onFileOpen:n,createDiff:a,selectedProject:m,autoExpandTools:c,showRawParameters:u,rawToolInput:typeof t.toolInput=="string"?t.toolInput:void 0,isSubagentContainer:t.isSubagentContainer,subagentState:t.subagentState,onArtifactOpen:p}),t.toolResult&&!Cd(t.toolName||"UnknownTool",t.toolResult)&&(t.toolResult.isError?e.jsxs("div",{id:`tool-result-${t.toolId}`,className:"relative mt-2 p-3 rounded border scroll-mt-4 bg-red-50/50 dark:bg-red-950/10 border-red-200/60 dark:border-red-800/40",children:[e.jsxs("div",{className:"relative flex items-center gap-1.5 mb-2",children:[e.jsx("svg",{className:"w-4 h-4 text-red-500 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"text-xs font-medium text-red-700 dark:text-red-300",children:g("messageTypes.error")})]}),e.jsxs("div",{className:"relative text-sm text-red-900 dark:text-red-100",children:[e.jsx(Qt,{className:"prose prose-sm max-w-none prose-red dark:prose-invert",children:String(t.toolResult.content||"")}),j&&e.jsxs("div",{className:"mt-4 border-t border-red-200/60 dark:border-red-800/60 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{if(!i)return;const C=i(j);C!=null&&C.success?k("granted"):k("error")},disabled:j.isAllowed||y==="granted",className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${j.isAllowed||y==="granted"?"bg-green-100 dark:bg-green-900/30 border-green-300/70 dark:border-green-800/60 text-green-800 dark:text-green-200 cursor-default":"bg-white/80 dark:bg-gray-900/40 border-red-300/70 dark:border-red-800/60 text-red-700 dark:text-red-200 hover:bg-white dark:hover:bg-gray-900/70"}`,children:j.isAllowed||y==="granted"?g("permissions.added"):g("permissions.grant",{tool:j.toolName})}),o&&e.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),o()},className:"text-xs text-red-700 dark:text-red-200 underline hover:text-red-800 dark:hover:text-red-100",children:g("permissions.openSettings")})]}),e.jsx("div",{className:"mt-2 text-xs text-red-700/90 dark:text-red-200/80",children:g("permissions.addTo",{entry:j.entry})}),y==="error"&&e.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:g("permissions.error")}),(j.isAllowed||y==="granted")&&e.jsx("div",{className:"mt-2 text-xs text-green-700 dark:text-green-200",children:g("permissions.retry")})]})]})]}):e.jsx("div",{id:`tool-result-${t.toolId}`,className:"scroll-mt-4",children:e.jsx(ra,{toolName:t.toolName||"UnknownTool",toolInput:t.toolInput,toolResult:t.toolResult,toolId:t.toolId,mode:"result",onFileOpen:n,createDiff:a,selectedProject:m,autoExpandTools:c,onArtifactOpen:p})}))]}):t.isInteractivePrompt?e.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-amber-500 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-amber-900 dark:text-amber-100 text-base mb-3",children:g("interactive.title")}),(()=>{const C=(t.content||"").split(`
77
+ `).filter(T=>T.trim()),v=C.find(T=>T.includes("?"))||C[0]||"",E=[];return C.forEach(T=>{const W=T.match(/[❯\s]*(\d+)\.\s+(.+)/);if(W){const S=T.includes("❯");E.push({number:W[1],text:W[2].trim(),isSelected:S})}}),e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:v}),e.jsx("div",{className:"space-y-2 mb-4",children:E.map(T=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${T.isSelected?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700"} cursor-not-allowed opacity-75`,disabled:!0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${T.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:T.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:T.text}),T.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},T.number))}),e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[e.jsx("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:g("interactive.waiting")}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:g("interactive.instruction")})]})]})})()]})]})}):t.isThinking?e.jsx("div",{className:"text-sm",children:e.jsxs("details",{className:"group rounded-lg border border-purple-500/20 dark:border-purple-400/15 bg-purple-50/30 dark:bg-purple-950/10 overflow-hidden",children:[e.jsxs("summary",{className:"cursor-pointer px-3 py-2 flex items-center gap-2.5 hover:bg-purple-50/50 dark:hover:bg-purple-950/20 transition-colors select-none",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-purple-500 dark:text-purple-400 transition-transform group-open:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("svg",{className:"w-4 h-4 text-purple-500 dark:text-purple-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),e.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:"Thinking"})]}),e.jsx("div",{className:"px-3 pb-3 pt-1 border-t border-purple-500/10 dark:border-purple-400/10",children:e.jsx("div",{className:"pl-3 border-l-2 border-purple-400/30 dark:border-purple-500/20 text-gray-600 dark:text-gray-400 text-sm",children:e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:t.content})})})]})}):e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[d&&t.reasoning&&e.jsxs("details",{className:"mb-3 group/reasoning rounded-lg border border-purple-500/20 dark:border-purple-400/15 bg-purple-50/30 dark:bg-purple-950/10 overflow-hidden",children:[e.jsxs("summary",{className:"cursor-pointer px-3 py-2 flex items-center gap-2.5 hover:bg-purple-50/50 dark:hover:bg-purple-950/20 transition-colors select-none",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-purple-500 dark:text-purple-400 transition-transform group-open/reasoning:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("svg",{className:"w-4 h-4 text-purple-500 dark:text-purple-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),e.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:"Extended thinking"})]}),e.jsx("div",{className:"px-3 pb-3 pt-1 border-t border-purple-500/10 dark:border-purple-400/10",children:e.jsx("div",{className:"pl-3 border-l-2 border-purple-400/30 dark:border-purple-500/20 text-gray-600 dark:text-gray-400 text-sm",children:e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:t.reasoning})})})]}),(()=>{const C=ea(String(t.content||"")),v=C.trim();if((v.startsWith("{")||v.startsWith("["))&&(v.endsWith("}")||v.endsWith("]")))try{const E=JSON.parse(v),T=JSON.stringify(E,null,2);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),e.jsx("span",{className:"font-medium",children:g("json.response")})]}),e.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("pre",{className:"p-4 overflow-x-auto",children:e.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:T})})})]})}catch{}return t.type==="assistant"?e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:C}):e.jsx("div",{className:"whitespace-pre-wrap",children:C})})()]}),!f&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 mt-1",children:I})]})]})})})}),Uo=({task:t,onClose:r,onEdit:s,onStatusChange:a,onTaskClick:n,isOpen:o=!0,className:i=""})=>{var W;const{addToast:c}=hr(),[u,d]=l.useState(!1),[m,h]=l.useState(t||{}),[p,g]=l.useState(!1),[f,x]=l.useState(!1),[b,N]=l.useState(!1),{currentProject:j,refreshTasks:y}=fr();if(!o||!t)return null;const k=async()=>{if(j){g(!0);try{const S={};if(m.title!==t.title&&(S.title=m.title),m.description!==t.description&&(S.description=m.description),m.details!==t.details&&(S.details=m.details),Object.keys(S).length>0){const O=await Be.taskmaster.updateTask(j.name,t.id,S);if(O.ok)y==null||y(),s==null||s(m),d(!1);else{const H=await O.json();console.error("Failed to update task:",H),c(`Failed to update task: ${H.message}`,"error")}}else d(!1)}catch(S){console.error("Error updating task:",S),c("Error updating task. Please try again.","error")}finally{g(!1)}}},I=()=>{navigator.clipboard.writeText(t.id.toString())},D=S=>{switch(S){case"done":return{icon:Pr,color:"text-green-600 dark:text-green-400",bg:"bg-green-50 dark:bg-green-950"};case"in-progress":return{icon:Ir,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-50 dark:bg-blue-950"};case"review":return{icon:xs,color:"text-amber-600 dark:text-amber-400",bg:"bg-amber-50 dark:bg-amber-950"};case"deferred":return{icon:ao,color:"text-gray-500 dark:text-gray-400",bg:"bg-gray-50 dark:bg-gray-800"};case"cancelled":return{icon:Ve,color:"text-red-600 dark:text-red-400",bg:"bg-red-50 dark:bg-red-950"};default:return{icon:ur,color:"text-slate-500 dark:text-slate-400",bg:"bg-slate-50 dark:bg-slate-800"}}},C=D(t.status),v=C.icon,E=S=>{switch(S){case"high":return"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950";case"medium":return"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-950";case"low":return"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-950";default:return"text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-800"}},T=[{value:"pending",label:"Pending"},{value:"in-progress",label:"In Progress"},{value:"review",label:"Review"},{value:"done",label:"Done"},{value:"deferred",label:"Deferred"},{value:"cancelled",label:"Cancelled"}];return e.jsx("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[100] md:p-4 bg-black/50",children:e.jsxs("div",{className:ke("bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 md:rounded-lg shadow-xl","w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",i),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx(v,{className:ke("w-6 h-6",C.color)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("button",{onClick:I,className:"flex items-center gap-1 px-2 py-1 text-xs bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",title:"Click to copy task ID",children:[e.jsxs("span",{children:["Task ",t.id]}),e.jsx(fa,{className:"w-3 h-3"})]}),t.parentId&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Subtask of Task ",t.parentId]})]}),u?e.jsx("input",{type:"text",value:m.title||"",onChange:S=>h({...m,title:S.target.value}),className:"w-full text-lg font-semibold bg-transparent border-b-2 border-blue-500 focus:outline-none text-gray-900 dark:text-white",placeholder:"Task title"}):e.jsx("h1",{className:"text-lg md:text-xl font-semibold text-gray-900 dark:text-white line-clamp-2",children:t.title})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[u?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:k,disabled:p,className:"p-2 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:p?"Saving...":"Save changes",children:e.jsx(ts,{className:ke("w-5 h-5",p&&"animate-spin")})}),e.jsx("button",{onClick:()=>{d(!1),h(t)},disabled:p,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Cancel editing",children:e.jsx(Ve,{className:"w-5 h-5"})})]}):e.jsx("button",{onClick:()=>d(!0),className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Edit task",children:e.jsx(Ci,{className:"w-5 h-5"})}),e.jsx("button",{onClick:r,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Close",children:e.jsx(Ve,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 md:p-6 space-y-6 min-h-0",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Status"}),e.jsx("div",{className:ke("w-full px-3 py-2 rounded-md border border-gray-300 dark:border-gray-600",C.bg,C.color),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium capitalize",children:((W=T.find(S=>S.value===t.status))==null?void 0:W.label)||t.status})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Priority"}),e.jsxs("div",{className:ke("px-3 py-2 rounded-md text-sm font-medium capitalize",E(t.priority)),children:[e.jsx(so,{className:"w-4 h-4 inline mr-2"}),t.priority||"Not set"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Dependencies"}),t.dependencies&&t.dependencies.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:t.dependencies.map(S=>e.jsxs("button",{onClick:()=>n&&n({id:S}),className:"px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 rounded text-sm hover:bg-blue-200 dark:hover:bg-blue-800 transition-colors cursor-pointer disabled:cursor-default disabled:opacity-50",disabled:!n,title:n?`Click to view Task ${S}`:`Task ${S}`,children:[e.jsx(va,{className:"w-3 h-3 inline mr-1"}),S]},S))}):e.jsx("span",{className:"text-gray-500 dark:text-gray-400 text-sm",children:"No dependencies"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Description"}),u?e.jsx("textarea",{value:m.description||"",onChange:S=>h({...m,description:S.target.value}),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Task description"}):e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.description||"No description provided"})]}),t.details&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("button",{onClick:()=>x(!f),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Implementation Details"}),f?e.jsx(Pt,{className:"w-4 h-4 text-gray-500"}):e.jsx(rr,{className:"w-4 h-4 text-gray-500"})]}),f&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:u?e.jsx("textarea",{value:m.details||"",onChange:S=>h({...m,details:S.target.value}),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Implementation details"}):e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-4",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.details})})})]}),t.testStrategy&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("button",{onClick:()=>N(!b),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Test Strategy"}),b?e.jsx(Pt,{className:"w-4 h-4 text-gray-500"}):e.jsx(rr,{className:"w-4 h-4 text-gray-500"})]}),b&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:e.jsx("div",{className:"bg-blue-50 dark:bg-blue-950 rounded-md p-4",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.testStrategy})})})]}),t.subtasks&&t.subtasks.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Subtasks (",t.subtasks.length,")"]}),e.jsx("div",{className:"space-y-2",children:t.subtasks.map(S=>{const O=D(S.status),H=O.icon;return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx(H,{className:ke("w-4 h-4",O.color)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white truncate",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 truncate",children:S.description})]}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:S.id})]},S.id)})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Task ID: ",t.id]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{onClick:r,className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Close"})})]})]})})},cn=({onShowAllTasks:t,onStartTask:r,className:s=""})=>{const{nextTask:a,tasks:n,currentProject:o,isLoadingTasks:i,projectTaskMaster:c,refreshTasks:u,refreshProjects:d}=fr(),{addToast:m}=hr(),[h,p]=l.useState(!1),[g,f]=l.useState(!1),[x,b]=l.useState(!1),[N,j]=l.useState(!1),[y,k]=l.useState(!1),[I,D]=l.useState(!1),[C,v]=l.useState(!1),E=async()=>{if(o){v(!0);try{const O=await Be.taskmaster.init(o.name);if(O.ok)await d(),f(!1);else{const H=await O.json();console.error("Failed to initialize TaskMaster:",H),m(`Failed to initialize TaskMaster: ${H.message}`,"error")}}catch(O){console.error("Error initializing TaskMaster:",O),m("Error initializing TaskMaster. Please try again.","error")}finally{v(!1)}}},T=()=>{b(!0),f(!1)},W=()=>{j(!0),f(!1)};if(!o||i)return null;let S;if((!n||n.length===0)&&!(c!=null&&c.hasTaskmaster))S=e.jsxs("div",{className:ke("bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-lg p-3 mb-4",s),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xs,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"TaskMaster AI is not configured"}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5"})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:E,disabled:C,className:"text-xs px-2 py-1 bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors flex items-center gap-1 disabled:opacity-50",children:[e.jsx(tr,{className:"w-3 h-3"}),C?"Initializing...":"Initialize TaskMaster AI"]}),e.jsx("button",{onClick:()=>f(!g),className:"text-xs px-1.5 py-1 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-600 dark:text-slate-400 rounded transition-colors",title:"More options",children:g?e.jsx(no,{className:"w-3 h-3"}):e.jsx(Pt,{className:"w-3 h-3"})})]})]}),g&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-blue-200 dark:border-blue-800",children:[!(c!=null&&c.hasTaskmaster)&&e.jsxs("div",{className:"mb-3 p-3 bg-blue-50 dark:bg-blue-900/50 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-blue-900 dark:text-blue-100 mb-2",children:"🎯 What is TaskMaster?"}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("p",{children:["• ",e.jsx("strong",{children:"AI-Powered Task Management:"})," Break complex projects into manageable subtasks"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"PRD Templates:"})," Generate tasks from Product Requirements Documents"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Dependency Tracking:"})," Understand task relationships and execution order"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Progress Visualization:"})," Kanban boards and detailed task analytics"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"CLI Integration:"})," Use taskmaster commands for advanced workflows"]})]})]}),e.jsx("div",{className:"flex flex-col gap-2",children:c!=null&&c.hasTaskmaster?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 p-2 bg-green-50 dark:bg-green-900/30 rounded text-xs text-green-800 dark:text-green-200",children:[e.jsx("strong",{children:"Add more tasks:"})," Create additional tasks manually or generate them from a PRD template"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-green-100 dark:bg-green-900 hover:bg-green-200 dark:hover:bg-green-800 text-green-800 dark:text-green-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:T,disabled:C,children:[e.jsx(at,{className:"w-3 h-3"}),"Create a new task manually"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-purple-100 dark:bg-purple-900 hover:bg-purple-200 dark:hover:bg-purple-800 text-purple-800 dark:text-purple-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:W,disabled:C,children:[e.jsx(gt,{className:"w-3 h-3"}),C?"Parsing...":"Generate tasks from PRD template"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"text-xs px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:E,disabled:C,children:[e.jsx(tr,{className:"w-3 h-3"}),C?"Initializing...":"Initialize TaskMaster (Auto)"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-800 dark:text-slate-200 rounded transition-colors text-left flex items-center gap-2",onClick:()=>k(!0),children:[e.jsx(vt,{className:"w-3 h-3"}),"Initialize via Terminal (Advanced)"]})]})})]})]});else if(a)S=e.jsx("div",{className:ke("bg-slate-50 dark:bg-slate-900/30 border border-slate-200 dark:border-slate-700 rounded-lg p-3 mb-4",s),children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-5 h-5 bg-blue-100 dark:bg-blue-900/50 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx(Si,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})}),e.jsxs("span",{className:"text-xs text-slate-600 dark:text-slate-400 font-medium",children:["Task ",a.id]}),a.priority==="high"&&e.jsx("div",{className:"w-4 h-4 rounded bg-red-100 dark:bg-red-900/50 flex items-center justify-center",title:"High Priority",children:e.jsx(tr,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})}),a.priority==="medium"&&e.jsx("div",{className:"w-4 h-4 rounded bg-amber-100 dark:bg-amber-900/50 flex items-center justify-center",title:"Medium Priority",children:e.jsx(so,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})}),a.priority==="low"&&e.jsx("div",{className:"w-4 h-4 rounded bg-gray-100 dark:bg-gray-800 flex items-center justify-center",title:"Low Priority",children:e.jsx(ur,{className:"w-2.5 h-2.5 text-gray-400 dark:text-gray-500"})})]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-1",children:a.title})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>r==null?void 0:r(),className:"text-xs px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-md font-medium transition-colors shadow-sm flex items-center gap-1",children:[e.jsx(Ei,{className:"w-3 h-3"}),"Start Task"]}),e.jsx("button",{onClick:()=>D(!0),className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View task details",children:e.jsx(sr,{className:"w-3 h-3"})}),t&&e.jsx("button",{onClick:t,className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View all tasks",children:e.jsx(Xs,{className:"w-3 h-3"})})]})]})});else if(n&&n.length>0){const O=n.filter(R=>R.status==="done").length,H=n.length;S=e.jsx("div",{className:ke("bg-purple-50 dark:bg-purple-950 border border-purple-200 dark:border-purple-800 rounded-lg p-3 mb-4",s),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pr,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:O===H?"All done! 🎉":"No pending tasks"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[O,"/",H]}),e.jsx("button",{onClick:t,className:"text-xs px-2 py-1 bg-purple-600 hover:bg-purple-700 text-white rounded transition-colors",children:"Review"})]})]})})}else S=null;return e.jsxs(e.Fragment,{children:[S,x&&e.jsx(Gd,{currentProject:o,onClose:()=>b(!1),onTaskCreated:()=>{u(),b(!1)}}),N&&e.jsx(Vd,{currentProject:o,onClose:()=>j(!1),onTemplateApplied:()=>{u(),j(!1)}}),y&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl h-[600px] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(vt,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"TaskMaster Setup"}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Interactive CLI for ",o==null?void 0:o.displayName]})]})]}),e.jsx("button",{onClick:()=>k(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"h-full bg-black rounded-lg overflow-hidden",children:e.jsx(co,{selectedProject:o,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0})})}),e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"TaskMaster initialization will start automatically"}),e.jsx("button",{onClick:()=>k(!1),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Close"})]})})]})}),I&&a&&e.jsx(Uo,{task:a,isOpen:I,onClose:()=>D(!1),onStatusChange:()=>u==null?void 0:u(),onTaskClick:null})]})},Gd=({currentProject:t,onClose:r,onTaskCreated:s})=>{const[a,n]=l.useState({title:"",description:"",priority:"medium",useAI:!1,prompt:""}),[o,i]=l.useState(!1),c=async u=>{if(u.preventDefault(),!!t){i(!0);try{const d=a.useAI?{prompt:a.prompt,priority:a.priority}:{title:a.title,description:a.description,priority:a.priority},m=await Be.taskmaster.addTask(t.name,d);if(m.ok)s();else{const h=await m.json();console.error("Failed to create task:",h),addToast(`Failed to create task: ${h.message}`,"error")}}catch(d){console.error("Error creating task:",d),addToast("Error creating task. Please try again.","error")}finally{i(!1)}}};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Create New Task"}),e.jsx("button",{onClick:r,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:e.jsx(Ve,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:c,className:"space-y-4",children:[e.jsx("div",{children:e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[e.jsx("input",{type:"checkbox",checked:a.useAI,onChange:u=>n(d=>({...d,useAI:u.target.checked}))}),"Use AI to generate task details"]})}),a.useAI?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Description (AI will generate details)"}),e.jsx("textarea",{value:a.prompt,onChange:u=>n(d=>({...d,prompt:u.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe what you want to accomplish...",required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Title"}),e.jsx("input",{type:"text",value:a.title,onChange:u=>n(d=>({...d,title:u.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Enter task title...",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Description"}),e.jsx("textarea",{value:a.description,onChange:u=>n(d=>({...d,description:u.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe the task...",required:!0})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Priority"}),e.jsxs("select",{value:a.priority,onChange:u=>n(d=>({...d,priority:u.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx("button",{type:"button",onClick:r,className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",disabled:o,children:"Cancel"}),e.jsx("button",{type:"submit",className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded disabled:opacity-50",disabled:o||a.useAI&&!a.prompt.trim()||!a.useAI&&(!a.title.trim()||!a.description.trim()),children:o?"Creating...":"Create Task"})]})]})]})})},Vd=({currentProject:t,onClose:r,onTemplateApplied:s})=>{const[a,n]=l.useState([]),[o,i]=l.useState(null),[c,u]=l.useState({}),[d,m]=l.useState("prd.txt"),[h,p]=l.useState(!0),[g,f]=l.useState(!1),[x,b]=l.useState("select");useEffect(()=>{(async()=>{try{const k=await Be.taskmaster.getTemplates();if(k.ok){const I=await k.json();n(I.templates)}}catch(k){console.error("Error loading templates:",k)}finally{p(!1)}})()},[]);const N=y=>{i(y);const k=y.content.match(/\[([^\]]+)\]/g)||[],I=[...new Set(k.map(C=>C.slice(1,-1)))],D={};I.forEach(C=>{D[C]=""}),u(D),b("customize")},j=async()=>{if(!(!o||!t)){f(!0);try{const y=await Be.taskmaster.applyTemplate(t.name,{templateId:o.id,fileName:d,customizations:c});if(!y.ok){const I=await y.json();throw new Error(I.message||"Failed to apply template")}const k=await Be.taskmaster.parsePRD(t.name,{fileName:d,numTasks:10});if(!k.ok){const I=await k.json();throw new Error(I.message||"Failed to generate tasks")}b("generate"),setTimeout(()=>{s()},2e3)}catch(y){console.error("Error applying template:",y),addToast(`Error: ${y.message}`,"error"),f(!1)}}};return h?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading templates..."})]})})}):e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:x==="select"?"Select PRD Template":x==="customize"?"Customize Template":"Generating Tasks"}),e.jsx("button",{onClick:r,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:e.jsx(Ve,{className:"w-4 h-4"})})]}),x==="select"&&e.jsx("div",{className:"space-y-3",children:a.map(y=>e.jsx("div",{className:"p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer transition-colors",onClick:()=>N(y),children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white",children:y.name}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:y.description}),e.jsx("span",{className:"inline-block text-xs bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 px-2 py-1 rounded mt-2",children:y.category})]}),e.jsx(va,{className:"w-4 h-4 text-gray-400 mt-1"})]})},y.id))}),x==="customize"&&o&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"File Name"}),e.jsx("input",{type:"text",value:d,onChange:y=>m(y.target.value),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"prd.txt"})]}),Object.keys(c).length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Customize Template"}),e.jsx("div",{className:"space-y-3",children:Object.entries(c).map(([y,k])=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:y.replace(/([A-Z])/g," $1").replace(/^./,I=>I.toUpperCase())}),e.jsx("input",{type:"text",value:k,onChange:I=>u(D=>({...D,[y]:I.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:`Enter ${y.toLowerCase()}`})]},y))})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx("button",{onClick:()=>b("select"),className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",children:"Back"}),e.jsx("button",{onClick:j,className:"flex-1 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded disabled:opacity-50",disabled:g,children:g?"Applying...":"Apply & Generate Tasks"})]})]}),x==="generate"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Pr,{className:"w-8 h-8 text-green-600 dark:text-green-400"})}),e.jsx("h4",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"Template Applied Successfully!"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Your PRD has been created and tasks are being generated..."})]})]})})},Aa={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"},{value:"opusplan",label:"Opus Plan"},{value:"sonnet[1m]",label:"Sonnet [1M]"}],DEFAULT:"sonnet"},Ia={OPTIONS:[{value:"gpt-5.2-high",label:"GPT-5.2 High"},{value:"gemini-3-pro",label:"Gemini 3 Pro"},{value:"opus-4.5-thinking",label:"Claude 4.5 Opus (Thinking)"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1",label:"GPT-5.1"},{value:"gpt-5.1-high",label:"GPT-5.1 High"},{value:"composer-1",label:"Composer 1"},{value:"auto",label:"Auto"},{value:"sonnet-4.5",label:"Claude 4.5 Sonnet"},{value:"sonnet-4.5-thinking",label:"Claude 4.5 Sonnet (Thinking)"},{value:"opus-4.5",label:"Claude 4.5 Opus"},{value:"gpt-5.1-codex",label:"GPT-5.1 Codex"},{value:"gpt-5.1-codex-high",label:"GPT-5.1 Codex High"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-max-high",label:"GPT-5.1 Codex Max High"},{value:"opus-4.1",label:"Claude 4.1 Opus"},{value:"grok",label:"Grok"}],DEFAULT:"gpt-5"},Ma={OPTIONS:[{value:"gpt-5.3-codex",label:"GPT-5.3 Codex"},{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"o3",label:"O3"},{value:"o4-mini",label:"O4-mini"}],DEFAULT:"gpt-5.2"},qd=[{id:"claude",name:"Claude Code",infoKey:"providerSelection.providerInfo.anthropic",accent:"border-primary",ring:"ring-primary/15",check:"bg-primary text-primary-foreground"},{id:"cursor",name:"Cursor",infoKey:"providerSelection.providerInfo.cursorEditor",accent:"border-violet-500 dark:border-violet-400",ring:"ring-violet-500/15",check:"bg-violet-500 text-white"},{id:"codex",name:"Codex",infoKey:"providerSelection.providerInfo.openai",accent:"border-emerald-600 dark:border-emerald-400",ring:"ring-emerald-600/15",check:"bg-emerald-600 dark:bg-emerald-500 text-white"}];function Kd(t){return t==="claude"?Aa:t==="codex"?Ma:Ia}function Jd(t,r,s,a){return t==="claude"?r:t==="codex"?a:s}function Yd({selectedSession:t,currentSessionId:r,provider:s,setProvider:a,textareaRef:n,claudeModel:o,setClaudeModel:i,cursorModel:c,setCursorModel:u,codexModel:d,setCodexModel:m,tasksEnabled:h,isTaskMasterInstalled:p,onShowAllTasks:g,setInput:f}){const{t:x}=We("chat"),b=x("tasks.nextTaskPrompt",{defaultValue:"Start the next task"}),N=I=>{a(I),localStorage.setItem("selected-provider",I),setTimeout(()=>{var D;return(D=n.current)==null?void 0:D.focus()},100)},j=I=>{s==="claude"?(i(I),localStorage.setItem("claude-model",I)):s==="codex"?(m(I),localStorage.setItem("codex-model",I)):(u(I),localStorage.setItem("cursor-model",I))},y=Kd(s),k=Jd(s,o,c,d);return!t&&!r?e.jsx("div",{className:"flex items-center justify-center h-full px-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h2",{className:"text-lg sm:text-xl font-semibold text-foreground tracking-tight",children:x("providerSelection.title")}),e.jsx("p",{className:"text-[13px] text-muted-foreground mt-1",children:x("providerSelection.description")})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:gap-2.5 mb-6",children:qd.map(I=>{const D=s===I.id;return e.jsxs("button",{onClick:()=>N(I.id),className:`
78
78
  relative flex flex-col items-center gap-2.5 pt-5 pb-4 px-2
79
79
  rounded-xl border-[1.5px] transition-all duration-150
80
80
  active:scale-[0.97]
81
81
  ${D?`${I.accent} ${I.ring} ring-2 bg-card shadow-sm`:"border-border bg-card/60 hover:bg-card hover:border-border/80"}
82
- `,children:[e.jsx(ft,{provider:I.id,className:`w-9 h-9 transition-transform duration-150 ${D?"scale-110":""}`}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[13px] font-semibold text-foreground leading-none",children:I.name}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 leading-tight",children:x(I.infoKey)})]}),D&&e.jsx("div",{className:`absolute -top-1 -right-1 w-[18px] h-[18px] rounded-full ${I.check} flex items-center justify-center shadow-sm`,children:e.jsx(Lt,{className:"w-2.5 h-2.5",strokeWidth:3})})]},I.id)})}),e.jsxs("div",{className:`transition-all duration-200 ${s?"opacity-100 translate-y-0":"opacity-0 translate-y-1 pointer-events-none"}`,children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-5",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:x("providerSelection.selectModel")}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:k,onChange:I=>j(I.target.value),tabIndex:-1,className:"appearance-none pl-3 pr-7 py-1.5 text-sm font-medium bg-muted/50 border border-border/60 rounded-lg text-foreground cursor-pointer hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary/20",children:y.OPTIONS.map(({value:I,label:D})=>e.jsx("option",{value:I,children:D},I))}),e.jsx(Pt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground pointer-events-none"})]})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground/70",children:s==="claude"?x("providerSelection.readyPrompt.claude",{model:o}):s==="cursor"?x("providerSelection.readyPrompt.cursor",{model:c}):s==="codex"?x("providerSelection.readyPrompt.codex",{model:d}):x("providerSelection.readyPrompt.default")})]}),s&&h&&p&&e.jsx("div",{className:"mt-5",children:e.jsx(ln,{onStartTask:()=>f(b),onShowAllTasks:g})})]})}):t?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center px-6 max-w-md",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground mb-1.5",children:x("session.continue.title")}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:x("session.continue.description")}),h&&p&&e.jsx("div",{className:"mt-5",children:e.jsx(ln,{onStartTask:()=>f(b),onShowAllTasks:g})})]})}):null}function Yd({selectedProvider:t}){return e.jsx("div",{className:"chat-message assistant",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1 bg-transparent",children:e.jsx(ft,{provider:t,className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t==="cursor"?"Cursor":t==="codex"?"Codex":"Claude"})]}),e.jsx("div",{className:"w-full pl-3 sm:pl-0",children:e.jsxs("div",{className:"inline-flex items-center gap-2.5 px-3 py-2 rounded-lg border border-purple-500/20 dark:border-purple-400/15 bg-purple-50/30 dark:bg-purple-950/10",children:[e.jsx("svg",{className:"w-4 h-4 text-purple-500 dark:text-purple-400 animate-pulse flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),e.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:"Thinking"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 animate-bounce",style:{animationDelay:"300ms"}})]})]})})]})})}const Qd=t=>{if(typeof t!="string"&&typeof t!="number")return null;const r=String(t).trim();return r.length>0?r:null},Xd=t=>{const r=[t.id,t.messageId,t.toolId,t.toolCallId,t.blobId,t.rowid,t.sequence];for(const o of r){const i=Qd(o);if(i)return`message-${t.type}-${i}`}const s=new Date(t.timestamp).getTime();if(!Number.isFinite(s))return null;const a=typeof t.content=="string"?t.content.slice(0,48):"",n=typeof t.toolName=="string"?t.toolName:"";return`message-${t.type}-${s}-${n}-${a}`};function Zd({scrollContainerRef:t,onWheel:r,onTouchMove:s,isLoadingSessionMessages:a,chatMessages:n,selectedSession:o,currentSessionId:i,provider:c,setProvider:u,textareaRef:d,claudeModel:m,setClaudeModel:h,cursorModel:p,setCursorModel:g,codexModel:f,setCodexModel:x,tasksEnabled:b,isTaskMasterInstalled:N,onShowAllTasks:j,setInput:y,isLoadingMoreMessages:k,hasMoreMessages:I,totalMessages:D,sessionMessagesCount:C,visibleMessageCount:v,visibleMessages:E,loadEarlierMessages:T,loadAllMessages:W,allMessagesLoaded:S,isLoadingAllMessages:O,loadAllJustFinished:H,showLoadAllOverlay:R,createDiff:A,onFileOpen:z,onShowSettings:J,onGrantToolPermission:re,autoExpandTools:G,showRawParameters:ie,showThinking:$,selectedProject:Z,isLoading:te,onArtifactOpen:Q}){const{t:_}=We("chat"),F=l.useRef(new WeakMap),q=l.useRef(new Set),U=l.useRef(0),B=l.useCallback(ee=>{const V=F.current.get(ee);if(V)return V;const w=Xd(ee);let M=w;if(!M||q.current.has(M))do U.current+=1,M=w?`${w}-${U.current}`:`message-generated-${U.current}`;while(q.current.has(M));return q.current.add(M),F.current.set(ee,M),M},[]);return e.jsxs("div",{ref:t,onWheel:r,onTouchMove:s,className:"flex-1 overflow-y-auto overflow-x-hidden px-0 py-3 sm:p-4 pb-24 space-y-3 sm:space-y-4 relative",children:[a&&n.length===0?e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 mt-8",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{children:_("session.loading.sessionMessages")})]})}):n.length===0?e.jsx(Jd,{selectedSession:o,currentSessionId:i,provider:c,setProvider:u,textareaRef:d,claudeModel:m,setClaudeModel:h,cursorModel:p,setCursorModel:g,codexModel:f,setCodexModel:x,tasksEnabled:b,isTaskMasterInstalled:N,onShowAllTasks:j,setInput:y}):e.jsxs(e.Fragment,{children:[k&&!O&&!S&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 py-3",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{className:"text-sm",children:_("session.loading.olderMessages")})]})}),I&&!k&&!S&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:D>0&&e.jsxs("span",{children:[_("session.messages.showingOf",{shown:C,total:D})," ",e.jsx("span",{className:"text-xs",children:_("session.messages.scrollToLoad")})]})}),(R||O||H)&&e.jsx("div",{className:"sticky top-2 z-20 flex justify-center pointer-events-none",children:H?e.jsxs("div",{className:"px-4 py-1.5 text-xs font-medium text-white bg-green-600 dark:bg-green-500 rounded-full shadow-lg flex items-center space-x-2",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})}),e.jsx("span",{children:_("session.messages.allLoaded")})]}):e.jsxs("button",{className:"pointer-events-auto px-4 py-1.5 text-xs font-medium text-white bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 rounded-full shadow-lg transition-all duration-200 hover:scale-105 disabled:opacity-75 disabled:cursor-wait flex items-center space-x-2",onClick:W,disabled:O,children:[O&&e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-2 border-white/30 border-t-white"}),e.jsx("span",{children:O?_("session.messages.loadingAll"):e.jsxs(e.Fragment,{children:[_("session.messages.loadAll")," ",D>0&&`(${D})`]})})]})}),S&&e.jsx("div",{className:"text-center text-amber-600 dark:text-amber-400 text-xs py-1.5 bg-amber-50 dark:bg-amber-900/20 border-b border-amber-200 dark:border-amber-800",children:_("session.messages.perfWarning")}),!I&&n.length>v&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:[_("session.messages.showingLast",{count:v,total:n.length})," |",e.jsx("button",{className:"ml-1 text-blue-600 hover:text-blue-700 underline",onClick:T,children:_("session.messages.loadEarlier")})," | ",e.jsx("button",{className:"text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 underline",onClick:W,children:_("session.messages.loadAll")})]}),E.map((ee,V)=>{const w=V>0?E[V-1]:null;return e.jsx(Ud,{message:ee,index:V,prevMessage:w,createDiff:A,onFileOpen:z,onShowSettings:J,onGrantToolPermission:re,autoExpandTools:G,showRawParameters:ie,showThinking:$,selectedProject:Z,provider:c,onArtifactOpen:Q},B(ee))})]}),te&&e.jsx(Yd,{selectedProvider:c})]})}const eu=({commands:t=[],selectedIndex:r=-1,onSelect:s,onClose:a,position:n={top:0,left:0},isOpen:o=!1,frequentCommands:i=[]})=>{const c=l.useRef(null),u=l.useRef(null),m=(()=>{const y=window.innerWidth<640,k=window.innerHeight;return y?{position:"fixed",bottom:`${n.bottom||90}px`,left:"16px",right:"16px",width:"auto",maxWidth:"calc(100vw - 32px)",maxHeight:"min(50vh, 300px)"}:{position:"fixed",top:`${Math.max(16,Math.min(n.top,k-316))}px`,left:`${n.left}px`,width:"min(400px, calc(100vw - 32px))",maxWidth:"calc(100vw - 32px)",maxHeight:"300px"}})();if(l.useEffect(()=>{const y=k=>{c.current&&!c.current.contains(k.target)&&o&&a()};if(o)return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[o,a]),l.useEffect(()=>{if(u.current&&c.current){const y=c.current.getBoundingClientRect(),k=u.current.getBoundingClientRect();k.bottom>y.bottom?u.current.scrollIntoView({block:"nearest",behavior:"smooth"}):k.top<y.top&&u.current.scrollIntoView({block:"nearest",behavior:"smooth"})}},[r]),!o)return null;if(t.length===0)return e.jsx("div",{ref:c,className:"command-menu command-menu-empty",style:{...m,maxHeight:"300px",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"20px",opacity:1,transform:"translateY(0)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out",textAlign:"center"},children:"No commands available"});const h=i.length>0,p=y=>`${y.name}::${y.namespace||y.type||"other"}::${y.path||""}`,g=new Set(i.map(p)),f=t.reduce((y,k)=>{if(h&&g.has(p(k)))return y;const I=k.namespace||k.type||"other";return y[I]||(y[I]=[]),y[I].push(k),y},{});h&&(f.frequent=i);for(const y of Object.keys(f))y!=="builtin"&&y!=="project"&&y!=="frequent"&&(f.project=[...f.project||[],...f[y]],delete f[y]);const b=(h?["frequent","builtin","project"]:["builtin","project"]).filter(y=>f[y]),N={frequent:"⭐ Frequently Used",builtin:"Upfynai",project:"Project"},j=new Map;return t.forEach((y,k)=>{const I=p(y);j.has(I)||j.set(I,k)}),e.jsxs("div",{ref:c,role:"listbox","aria-label":"Available commands",className:"command-menu",style:{...m,maxHeight:"300px",overflowY:"auto",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"8px",opacity:o?1:0,transform:o?"translateY(0)":"translateY(-10px)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out"},children:[b.map(y=>e.jsxs("div",{className:"command-group",children:[b.length>1&&e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"#6b7280",padding:"8px 12px 4px",letterSpacing:"0.05em"},children:N[y]||y}),f[y].map(k=>{const I=p(k),D=j.get(I)??-1,C=D===r;return e.jsxs("div",{ref:C?u:null,role:"option","aria-selected":C,className:"command-item",onMouseEnter:()=>{s&&D>=0&&s(k,D,!0)},onClick:()=>{s&&s(k,D,!1)},style:{display:"flex",alignItems:"flex-start",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",backgroundColor:C?"#eff6ff":"transparent",transition:"background-color 100ms ease-in-out",marginBottom:"2px"},onMouseDown:v=>v.preventDefault(),children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:k.description?"4px":0},children:[e.jsxs("span",{style:{fontSize:"16px",flexShrink:0},children:[y==="builtin"&&"⚡",y==="project"&&"📁",y==="frequent"&&"⭐"]}),e.jsx("span",{style:{fontWeight:600,fontSize:"14px",color:"#111827",fontFamily:"monospace"},children:k.name}),e.jsx("span",{className:"command-metadata-badge",style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",backgroundColor:y==="builtin"?"#dbeafe":"#f3f4f6",color:y==="builtin"?"#2563eb":"#6b7280",fontWeight:500},children:y==="builtin"?"Upfynai":"Project"})]}),k.description&&e.jsx("div",{style:{fontSize:"13px",color:"#6b7280",marginLeft:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:k.description})]}),C&&e.jsx("span",{style:{marginLeft:"8px",color:"#3b82f6",fontSize:"12px",fontWeight:600},children:"↵"})]},`${y}-${k.name}-${k.path||""}`)})]},y)),e.jsx("style",{children:`
82
+ `,children:[e.jsx(ft,{provider:I.id,className:`w-9 h-9 transition-transform duration-150 ${D?"scale-110":""}`}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[13px] font-semibold text-foreground leading-none",children:I.name}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 leading-tight",children:x(I.infoKey)})]}),D&&e.jsx("div",{className:`absolute -top-1 -right-1 w-[18px] h-[18px] rounded-full ${I.check} flex items-center justify-center shadow-sm`,children:e.jsx(Lt,{className:"w-2.5 h-2.5",strokeWidth:3})})]},I.id)})}),e.jsxs("div",{className:`transition-all duration-200 ${s?"opacity-100 translate-y-0":"opacity-0 translate-y-1 pointer-events-none"}`,children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-5",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:x("providerSelection.selectModel")}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:k,onChange:I=>j(I.target.value),tabIndex:-1,className:"appearance-none pl-3 pr-7 py-1.5 text-sm font-medium bg-muted/50 border border-border/60 rounded-lg text-foreground cursor-pointer hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary/20",children:y.OPTIONS.map(({value:I,label:D})=>e.jsx("option",{value:I,children:D},I))}),e.jsx(Pt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground pointer-events-none"})]})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground/70",children:s==="claude"?x("providerSelection.readyPrompt.claude",{model:o}):s==="cursor"?x("providerSelection.readyPrompt.cursor",{model:c}):s==="codex"?x("providerSelection.readyPrompt.codex",{model:d}):x("providerSelection.readyPrompt.default")})]}),s&&h&&p&&e.jsx("div",{className:"mt-5",children:e.jsx(cn,{onStartTask:()=>f(b),onShowAllTasks:g})})]})}):t?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center px-6 max-w-md",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground mb-1.5",children:x("session.continue.title")}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:x("session.continue.description")}),h&&p&&e.jsx("div",{className:"mt-5",children:e.jsx(cn,{onStartTask:()=>f(b),onShowAllTasks:g})})]})}):null}function Qd({selectedProvider:t}){return e.jsx("div",{className:"chat-message assistant",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1 bg-transparent",children:e.jsx(ft,{provider:t,className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t==="cursor"?"Cursor":t==="codex"?"Codex":"Claude"})]}),e.jsx("div",{className:"w-full pl-3 sm:pl-0",children:e.jsxs("div",{className:"inline-flex items-center gap-2.5 px-3 py-2 rounded-lg border border-purple-500/20 dark:border-purple-400/15 bg-purple-50/30 dark:bg-purple-950/10",children:[e.jsx("svg",{className:"w-4 h-4 text-purple-500 dark:text-purple-400 animate-pulse flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),e.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:"Thinking"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 animate-bounce",style:{animationDelay:"300ms"}})]})]})})]})})}const Xd=t=>{if(typeof t!="string"&&typeof t!="number")return null;const r=String(t).trim();return r.length>0?r:null},Zd=t=>{const r=[t.id,t.messageId,t.toolId,t.toolCallId,t.blobId,t.rowid,t.sequence];for(const o of r){const i=Xd(o);if(i)return`message-${t.type}-${i}`}const s=new Date(t.timestamp).getTime();if(!Number.isFinite(s))return null;const a=typeof t.content=="string"?t.content.slice(0,48):"",n=typeof t.toolName=="string"?t.toolName:"";return`message-${t.type}-${s}-${n}-${a}`};function eu({scrollContainerRef:t,onWheel:r,onTouchMove:s,isLoadingSessionMessages:a,chatMessages:n,selectedSession:o,currentSessionId:i,provider:c,setProvider:u,textareaRef:d,claudeModel:m,setClaudeModel:h,cursorModel:p,setCursorModel:g,codexModel:f,setCodexModel:x,tasksEnabled:b,isTaskMasterInstalled:N,onShowAllTasks:j,setInput:y,isLoadingMoreMessages:k,hasMoreMessages:I,totalMessages:D,sessionMessagesCount:C,visibleMessageCount:v,visibleMessages:E,loadEarlierMessages:T,loadAllMessages:W,allMessagesLoaded:S,isLoadingAllMessages:O,loadAllJustFinished:H,showLoadAllOverlay:R,createDiff:A,onFileOpen:z,onShowSettings:J,onGrantToolPermission:re,autoExpandTools:G,showRawParameters:ie,showThinking:$,selectedProject:Z,isLoading:te,onArtifactOpen:Q}){const{t:_}=We("chat"),F=l.useRef(new WeakMap),q=l.useRef(new Set),U=l.useRef(0),B=l.useCallback(ee=>{const V=F.current.get(ee);if(V)return V;const w=Zd(ee);let M=w;if(!M||q.current.has(M))do U.current+=1,M=w?`${w}-${U.current}`:`message-generated-${U.current}`;while(q.current.has(M));return q.current.add(M),F.current.set(ee,M),M},[]);return e.jsxs("div",{ref:t,onWheel:r,onTouchMove:s,className:"flex-1 overflow-y-auto overflow-x-hidden px-0 py-3 sm:p-4 pb-24 space-y-3 sm:space-y-4 relative",children:[a&&n.length===0?e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 mt-8",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{children:_("session.loading.sessionMessages")})]})}):n.length===0?e.jsx(Yd,{selectedSession:o,currentSessionId:i,provider:c,setProvider:u,textareaRef:d,claudeModel:m,setClaudeModel:h,cursorModel:p,setCursorModel:g,codexModel:f,setCodexModel:x,tasksEnabled:b,isTaskMasterInstalled:N,onShowAllTasks:j,setInput:y}):e.jsxs(e.Fragment,{children:[k&&!O&&!S&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 py-3",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{className:"text-sm",children:_("session.loading.olderMessages")})]})}),I&&!k&&!S&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:D>0&&e.jsxs("span",{children:[_("session.messages.showingOf",{shown:C,total:D})," ",e.jsx("span",{className:"text-xs",children:_("session.messages.scrollToLoad")})]})}),(R||O||H)&&e.jsx("div",{className:"sticky top-2 z-20 flex justify-center pointer-events-none",children:H?e.jsxs("div",{className:"px-4 py-1.5 text-xs font-medium text-white bg-green-600 dark:bg-green-500 rounded-full shadow-lg flex items-center space-x-2",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})}),e.jsx("span",{children:_("session.messages.allLoaded")})]}):e.jsxs("button",{className:"pointer-events-auto px-4 py-1.5 text-xs font-medium text-white bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 rounded-full shadow-lg transition-all duration-200 hover:scale-105 disabled:opacity-75 disabled:cursor-wait flex items-center space-x-2",onClick:W,disabled:O,children:[O&&e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-2 border-white/30 border-t-white"}),e.jsx("span",{children:O?_("session.messages.loadingAll"):e.jsxs(e.Fragment,{children:[_("session.messages.loadAll")," ",D>0&&`(${D})`]})})]})}),S&&e.jsx("div",{className:"text-center text-amber-600 dark:text-amber-400 text-xs py-1.5 bg-amber-50 dark:bg-amber-900/20 border-b border-amber-200 dark:border-amber-800",children:_("session.messages.perfWarning")}),!I&&n.length>v&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:[_("session.messages.showingLast",{count:v,total:n.length})," |",e.jsx("button",{className:"ml-1 text-blue-600 hover:text-blue-700 underline",onClick:T,children:_("session.messages.loadEarlier")})," | ",e.jsx("button",{className:"text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 underline",onClick:W,children:_("session.messages.loadAll")})]}),E.map((ee,V)=>{const w=V>0?E[V-1]:null;return e.jsx(Hd,{message:ee,index:V,prevMessage:w,createDiff:A,onFileOpen:z,onShowSettings:J,onGrantToolPermission:re,autoExpandTools:G,showRawParameters:ie,showThinking:$,selectedProject:Z,provider:c,onArtifactOpen:Q},B(ee))})]}),te&&e.jsx(Qd,{selectedProvider:c})]})}const tu=({commands:t=[],selectedIndex:r=-1,onSelect:s,onClose:a,position:n={top:0,left:0},isOpen:o=!1,frequentCommands:i=[]})=>{const c=l.useRef(null),u=l.useRef(null),m=(()=>{const y=window.innerWidth<640,k=window.innerHeight;return y?{position:"fixed",bottom:`${n.bottom||90}px`,left:"16px",right:"16px",width:"auto",maxWidth:"calc(100vw - 32px)",maxHeight:"min(50vh, 300px)"}:{position:"fixed",top:`${Math.max(16,Math.min(n.top,k-316))}px`,left:`${n.left}px`,width:"min(400px, calc(100vw - 32px))",maxWidth:"calc(100vw - 32px)",maxHeight:"300px"}})();if(l.useEffect(()=>{const y=k=>{c.current&&!c.current.contains(k.target)&&o&&a()};if(o)return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[o,a]),l.useEffect(()=>{if(u.current&&c.current){const y=c.current.getBoundingClientRect(),k=u.current.getBoundingClientRect();k.bottom>y.bottom?u.current.scrollIntoView({block:"nearest",behavior:"smooth"}):k.top<y.top&&u.current.scrollIntoView({block:"nearest",behavior:"smooth"})}},[r]),!o)return null;if(t.length===0)return e.jsx("div",{ref:c,className:"command-menu command-menu-empty",style:{...m,maxHeight:"300px",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"20px",opacity:1,transform:"translateY(0)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out",textAlign:"center"},children:"No commands available"});const h=i.length>0,p=y=>`${y.name}::${y.namespace||y.type||"other"}::${y.path||""}`,g=new Set(i.map(p)),f=t.reduce((y,k)=>{if(h&&g.has(p(k)))return y;const I=k.namespace||k.type||"other";return y[I]||(y[I]=[]),y[I].push(k),y},{});h&&(f.frequent=i);for(const y of Object.keys(f))y!=="builtin"&&y!=="project"&&y!=="frequent"&&(f.project=[...f.project||[],...f[y]],delete f[y]);const b=(h?["frequent","builtin","project"]:["builtin","project"]).filter(y=>f[y]),N={frequent:"⭐ Frequently Used",builtin:"Upfynai",project:"Project"},j=new Map;return t.forEach((y,k)=>{const I=p(y);j.has(I)||j.set(I,k)}),e.jsxs("div",{ref:c,role:"listbox","aria-label":"Available commands",className:"command-menu",style:{...m,maxHeight:"300px",overflowY:"auto",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"8px",opacity:o?1:0,transform:o?"translateY(0)":"translateY(-10px)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out"},children:[b.map(y=>e.jsxs("div",{className:"command-group",children:[b.length>1&&e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"#6b7280",padding:"8px 12px 4px",letterSpacing:"0.05em"},children:N[y]||y}),f[y].map(k=>{const I=p(k),D=j.get(I)??-1,C=D===r;return e.jsxs("div",{ref:C?u:null,role:"option","aria-selected":C,className:"command-item",onMouseEnter:()=>{s&&D>=0&&s(k,D,!0)},onClick:()=>{s&&s(k,D,!1)},style:{display:"flex",alignItems:"flex-start",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",backgroundColor:C?"#eff6ff":"transparent",transition:"background-color 100ms ease-in-out",marginBottom:"2px"},onMouseDown:v=>v.preventDefault(),children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:k.description?"4px":0},children:[e.jsxs("span",{style:{fontSize:"16px",flexShrink:0},children:[y==="builtin"&&"⚡",y==="project"&&"📁",y==="frequent"&&"⭐"]}),e.jsx("span",{style:{fontWeight:600,fontSize:"14px",color:"#111827",fontFamily:"monospace"},children:k.name}),e.jsx("span",{className:"command-metadata-badge",style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",backgroundColor:y==="builtin"?"#dbeafe":"#f3f4f6",color:y==="builtin"?"#2563eb":"#6b7280",fontWeight:500},children:y==="builtin"?"Upfynai":"Project"})]}),k.description&&e.jsx("div",{style:{fontSize:"13px",color:"#6b7280",marginLeft:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:k.description})]}),C&&e.jsx("span",{style:{marginLeft:"8px",color:"#3b82f6",fontSize:"12px",fontWeight:600},children:"↵"})]},`${y}-${k.name}-${k.path||""}`)})]},y)),e.jsx("style",{children:`
83
83
  .command-menu {
84
84
  background-color: white;
85
85
  border: 1px solid #e5e7eb;
@@ -113,7 +113,7 @@ ${t.prompt}`),t.resume&&s.push(`**Resuming from:** ${t.resume}`),{content:s.join
113
113
  color: #9ca3af !important;
114
114
  }
115
115
  }
116
- `})]})};function tu({status:t,onAbort:r,isLoading:s,provider:a="claude"}){const[n,o]=l.useState(0),[i,c]=l.useState(0),[u,d]=l.useState(0);if(l.useEffect(()=>{if(!s){o(0),d(0);return}const N=Date.now(),j=30+Math.random()*20,y=setInterval(()=>{const k=Math.floor((Date.now()-N)/1e3);o(k),d(Math.floor(k*j))},1e3);return()=>clearInterval(y)},[s]),l.useEffect(()=>{if(!s)return;const N=setInterval(()=>{c(j=>(j+1)%4)},500);return()=>clearInterval(N)},[s]),!s)return null;const m=["Thinking","Processing","Analyzing","Working","Computing","Reasoning"],h=Math.floor(n/3)%m.length,p=(t==null?void 0:t.text)||m[h],g=(t==null?void 0:t.tokens)||u,f=(t==null?void 0:t.can_interrupt)!==!1,b=["✻","✹","✸","✶"][i];return e.jsx("div",{className:"w-full mb-3 sm:mb-6 animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between max-w-4xl mx-auto bg-gray-800 dark:bg-gray-900 text-white rounded-lg shadow-lg px-2.5 py-2 sm:px-4 sm:py-3 border border-gray-700 dark:border-gray-800",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("span",{className:ke("text-base sm:text-xl transition-all duration-500 flex-shrink-0",i%2===0?"text-blue-400 scale-110":"text-blue-300"),children:b}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("span",{className:"font-medium text-xs sm:text-sm truncate",children:[p,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",n,"s)"]}),g>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsxs("span",{className:"text-gray-300 text-xs sm:text-sm hidden sm:inline flex-shrink-0",children:["⚒ ",g.toLocaleString()]})]}),e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsx("span",{className:"text-gray-400 text-xs sm:text-sm hidden sm:inline",children:"esc to stop"})]})})]})}),f&&r&&e.jsxs("button",{onClick:r,className:"ml-2 sm:ml-3 text-xs bg-red-600 hover:bg-red-700 active:bg-red-800 text-white px-2 py-1 sm:px-3 sm:py-1.5 rounded-md transition-colors flex items-center gap-1 sm:gap-1.5 flex-shrink-0 font-medium",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"hidden sm:inline",children:"Stop"})]})]})})}async function ru(t,r){const s=new FormData,a=`recording_${Date.now()}.webm`,n=new File([t],a,{type:t.type});s.append("audio",n);const o=window.localStorage.getItem("whisperMode")||"default";s.append("mode",o);try{const i=await Be.transcribe(s);if(!i.ok){const u=await i.json().catch(()=>({}));throw new Error(u.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function su({onTranscript:t,className:r=""}){const[s,a]=l.useState("idle"),[n,o]=l.useState(null),[i,c]=l.useState(!0),u=l.useRef(null),d=l.useRef(null),m=l.useRef([]),h=l.useRef(0);l.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){c(!1),o("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){c(!1),o("Microphone requires HTTPS. Please use a secure connection.");return}c(!0),o(null)})()},[]);const p=async()=>{try{if(console.log("Starting recording..."),o(null),m.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const y=await navigator.mediaDevices.getUserMedia({audio:!0});d.current=y;const k=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",I=new MediaRecorder(y,{mimeType:k});u.current=I,I.ondataavailable=D=>{D.data.size>0&&m.current.push(D.data)},I.onstop=async()=>{console.log("Recording stopped, creating blob...");const D=new Blob(m.current,{type:k});d.current&&(d.current.getTracks().forEach(T=>T.stop()),d.current=null),a("transcribing");const C=window.localStorage.getItem("whisperMode")||"default",v=C==="prompt"||C==="vibe"||C==="instructions"||C==="architect";let E;v&&(E=setTimeout(()=>{a("processing")},2e3));try{const T=await ru(D);T&&t&&t(T)}catch(T){console.error("Transcription error:",T),o(T.message)}finally{E&&clearTimeout(E),a("idle")}},I.start(),a("recording"),console.log("Recording started successfully")}catch(y){console.error("Failed to start recording:",y);let k="Microphone access failed";y.name==="NotAllowedError"?k="Microphone access denied. Please allow microphone permissions.":y.name==="NotFoundError"?k="No microphone found. Please check your audio devices.":y.name==="NotSupportedError"?k="Microphone not supported by this browser.":y.name==="NotReadableError"?k="Microphone is being used by another application.":y.message.includes("HTTPS")&&(k=y.message),o(k),a("idle")}},g=()=>{console.log("Stopping recording..."),u.current&&u.current.state==="recording"?u.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),d.current&&(d.current.getTracks().forEach(y=>y.stop()),d.current=null),a("idle"))},f=y=>{if(y&&(y.preventDefault(),y.stopPropagation()),!i)return;const k=Date.now();if(k-h.current<300){console.log("Ignoring rapid tap");return}h.current=k,console.log("Button clicked, current state:",s),s==="idle"?p():s==="recording"&&g()};l.useEffect(()=>()=>{d.current&&d.current.getTracks().forEach(y=>y.stop())},[]);const x=()=>{if(!i)return{icon:e.jsx(es,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(s){case"recording":return{icon:e.jsx(es,{className:"w-5 h-5 text-white"}),className:"bg-red-500 hover:bg-red-600 animate-pulse",disabled:!1};case"transcribing":return{icon:e.jsx(Sr,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx(gs,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(es,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:b,className:N,disabled:j}=x();return e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",style:{backgroundColor:s==="recording"?"#ef4444":s==="transcribing"?"#3b82f6":s==="processing"?"#a855f7":"#374151"},className:`
116
+ `})]})};function ru({status:t,onAbort:r,isLoading:s,provider:a="claude"}){const[n,o]=l.useState(0),[i,c]=l.useState(0),[u,d]=l.useState(0);if(l.useEffect(()=>{if(!s){o(0),d(0);return}const N=Date.now(),j=30+Math.random()*20,y=setInterval(()=>{const k=Math.floor((Date.now()-N)/1e3);o(k),d(Math.floor(k*j))},1e3);return()=>clearInterval(y)},[s]),l.useEffect(()=>{if(!s)return;const N=setInterval(()=>{c(j=>(j+1)%4)},500);return()=>clearInterval(N)},[s]),!s)return null;const m=["Thinking","Processing","Analyzing","Working","Computing","Reasoning"],h=Math.floor(n/3)%m.length,p=(t==null?void 0:t.text)||m[h],g=(t==null?void 0:t.tokens)||u,f=(t==null?void 0:t.can_interrupt)!==!1,b=["✻","✹","✸","✶"][i];return e.jsx("div",{className:"w-full mb-3 sm:mb-6 animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between max-w-4xl mx-auto bg-gray-800 dark:bg-gray-900 text-white rounded-lg shadow-lg px-2.5 py-2 sm:px-4 sm:py-3 border border-gray-700 dark:border-gray-800",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("span",{className:ke("text-base sm:text-xl transition-all duration-500 flex-shrink-0",i%2===0?"text-blue-400 scale-110":"text-blue-300"),children:b}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("span",{className:"font-medium text-xs sm:text-sm truncate",children:[p,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",n,"s)"]}),g>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsxs("span",{className:"text-gray-300 text-xs sm:text-sm hidden sm:inline flex-shrink-0",children:["⚒ ",g.toLocaleString()]})]}),e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsx("span",{className:"text-gray-400 text-xs sm:text-sm hidden sm:inline",children:"esc to stop"})]})})]})}),f&&r&&e.jsxs("button",{onClick:r,className:"ml-2 sm:ml-3 text-xs bg-red-600 hover:bg-red-700 active:bg-red-800 text-white px-2 py-1 sm:px-3 sm:py-1.5 rounded-md transition-colors flex items-center gap-1 sm:gap-1.5 flex-shrink-0 font-medium",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"hidden sm:inline",children:"Stop"})]})]})})}async function su(t,r){const s=new FormData,a=`recording_${Date.now()}.webm`,n=new File([t],a,{type:t.type});s.append("audio",n);const o=window.localStorage.getItem("whisperMode")||"default";s.append("mode",o);try{const i=await Be.transcribe(s);if(!i.ok){const u=await i.json().catch(()=>({}));throw new Error(u.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function au({onTranscript:t,className:r=""}){const[s,a]=l.useState("idle"),[n,o]=l.useState(null),[i,c]=l.useState(!0),u=l.useRef(null),d=l.useRef(null),m=l.useRef([]),h=l.useRef(0);l.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){c(!1),o("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){c(!1),o("Microphone requires HTTPS. Please use a secure connection.");return}c(!0),o(null)})()},[]);const p=async()=>{try{if(console.log("Starting recording..."),o(null),m.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const y=await navigator.mediaDevices.getUserMedia({audio:!0});d.current=y;const k=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",I=new MediaRecorder(y,{mimeType:k});u.current=I,I.ondataavailable=D=>{D.data.size>0&&m.current.push(D.data)},I.onstop=async()=>{console.log("Recording stopped, creating blob...");const D=new Blob(m.current,{type:k});d.current&&(d.current.getTracks().forEach(T=>T.stop()),d.current=null),a("transcribing");const C=window.localStorage.getItem("whisperMode")||"default",v=C==="prompt"||C==="vibe"||C==="instructions"||C==="architect";let E;v&&(E=setTimeout(()=>{a("processing")},2e3));try{const T=await su(D);T&&t&&t(T)}catch(T){console.error("Transcription error:",T),o(T.message)}finally{E&&clearTimeout(E),a("idle")}},I.start(),a("recording"),console.log("Recording started successfully")}catch(y){console.error("Failed to start recording:",y);let k="Microphone access failed";y.name==="NotAllowedError"?k="Microphone access denied. Please allow microphone permissions.":y.name==="NotFoundError"?k="No microphone found. Please check your audio devices.":y.name==="NotSupportedError"?k="Microphone not supported by this browser.":y.name==="NotReadableError"?k="Microphone is being used by another application.":y.message.includes("HTTPS")&&(k=y.message),o(k),a("idle")}},g=()=>{console.log("Stopping recording..."),u.current&&u.current.state==="recording"?u.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),d.current&&(d.current.getTracks().forEach(y=>y.stop()),d.current=null),a("idle"))},f=y=>{if(y&&(y.preventDefault(),y.stopPropagation()),!i)return;const k=Date.now();if(k-h.current<300){console.log("Ignoring rapid tap");return}h.current=k,console.log("Button clicked, current state:",s),s==="idle"?p():s==="recording"&&g()};l.useEffect(()=>()=>{d.current&&d.current.getTracks().forEach(y=>y.stop())},[]);const x=()=>{if(!i)return{icon:e.jsx(es,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(s){case"recording":return{icon:e.jsx(es,{className:"w-5 h-5 text-white"}),className:"bg-red-500 hover:bg-red-600 animate-pulse",disabled:!1};case"transcribing":return{icon:e.jsx(Sr,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx(gs,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(es,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:b,className:N,disabled:j}=x();return e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",style:{backgroundColor:s==="recording"?"#ef4444":s==="transcribing"?"#3b82f6":s==="processing"?"#a855f7":"#374151"},className:`
117
117
  flex items-center justify-center
118
118
  w-9 h-9 rounded-full
119
119
  text-white transition-all duration-200
@@ -126,26 +126,26 @@ ${t.prompt}`),t.resume&&s.push(`**Resuming from:** ${t.resume}`),{content:s.join
126
126
  ${r}
127
127
  `,onClick:f,disabled:j,children:b}),n&&e.jsx("div",{className:`absolute bottom-full mb-2 right-0\r
128
128
  bg-destructive/90 text-destructive-foreground text-[11px] px-2.5 py-1.5 rounded-lg whitespace-nowrap z-50\r
129
- animate-fade-in shadow-lg max-w-[220px] text-center`,style:{whiteSpace:"normal"},children:n}),s==="recording"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),s==="processing"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}const au=({file:t,onRemove:r,uploadProgress:s,error:a})=>{const[n,o]=l.useState(void 0);return l.useEffect(()=>{const i=URL.createObjectURL(t);return o(i),()=>URL.revokeObjectURL(i)},[t]),e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:n,alt:t.name,className:"w-20 h-20 object-cover rounded"}),s!==void 0&&s<100&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("div",{className:"text-white text-xs",children:[s,"%"]})}),a&&e.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("button",{type:"button",onClick:r,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 focus:opacity-100 transition-opacity","aria-label":"Remove image",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},Uo={};function nu(t,r){Uo[t]=r}function ou(t){return Uo[t]||null}nu("AskUserQuestion",Bd);function iu({pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s}){return t.length?e.jsx("div",{className:"mb-3 space-y-2",children:t.map(a=>{const n=ou(a.toolName);if(n)return e.jsx(n,{request:a,onDecision:r},a.requestId);const o=sn(a.input),i=ea(a.toolName,o),c=Ea(),u=i?c.allowedTools.includes(i):!1,d=u?"Allow (saved)":"Allow & remember",m=i?t.filter(h=>ea(h.toolName,sn(h.input))===i).map(h=>h.requestId):[a.requestId];return e.jsxs("div",{className:"rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/20 p-3 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-amber-900 dark:text-amber-100",children:"Permission required"}),e.jsxs("div",{className:"text-xs text-amber-800 dark:text-amber-200",children:["Tool: ",e.jsx("span",{className:"font-mono",children:a.toolName})]})]}),i&&e.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:["Allow rule: ",e.jsx("span",{className:"font-mono",children:i})]})]}),o&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-amber-800 dark:text-amber-200 hover:text-amber-900 dark:hover:text-amber-100",children:"View tool input"}),e.jsx("pre",{className:"mt-2 max-h-40 overflow-auto rounded-md bg-white/80 dark:bg-gray-900/60 border border-amber-200/60 dark:border-amber-800/60 p-2 text-xs text-amber-900 dark:text-amber-100 whitespace-pre-wrap",children:o})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(a.requestId,{allow:!0}),className:"inline-flex items-center gap-2 rounded-md bg-amber-600 text-white text-xs font-medium px-3 py-1.5 hover:bg-amber-700 transition-colors",children:"Allow once"}),e.jsx("button",{type:"button",onClick:()=>{i&&!u&&s({entry:i,toolName:a.toolName}),r(m,{allow:!0,rememberEntry:i})},className:`inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border transition-colors ${i?"border-amber-300 text-amber-800 hover:bg-amber-100 dark:border-amber-700 dark:text-amber-100 dark:hover:bg-amber-900/30":"border-gray-300 text-gray-400 cursor-not-allowed"}`,disabled:!i,children:d}),e.jsx("button",{type:"button",onClick:()=>r(a.requestId,{allow:!1,message:"User denied tool use"}),className:"inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border border-red-300 text-red-700 hover:bg-red-50 dark:border-red-800 dark:text-red-200 dark:hover:bg-red-900/30 transition-colors",children:"Deny"})]})]},a.requestId)})}):null}const Ho=[{id:"none",name:"Standard",description:"Regular Claude response",icon:null,prefix:"",color:"text-gray-600"},{id:"think",name:"Think",description:"Basic extended thinking",icon:gs,prefix:"think",color:"text-blue-600"},{id:"think-hard",name:"Think Hard",description:"More thorough evaluation",icon:tr,prefix:"think hard",color:"text-purple-600"},{id:"think-harder",name:"Think Harder",description:"Deep analysis with alternatives",icon:Ut,prefix:"think harder",color:"text-indigo-600"},{id:"ultrathink",name:"Ultrathink",description:"Maximum thinking budget",icon:Ei,prefix:"ultrathink",color:"text-red-600"}];function lu({selectedMode:t,onModeChange:r,onClose:s,className:a=""}){const{t:n}=We("chat"),o={"think-hard":"thinkHard","think-harder":"thinkHarder"},i=Ho.map(p=>{const g=o[p.id]||p.id;return{...p,name:n(`thinkingMode.modes.${g}.name`),description:n(`thinkingMode.modes.${g}.description`),prefix:n(`thinkingMode.modes.${g}.prefix`)}}),[c,u]=l.useState(!1),d=l.useRef(null);l.useEffect(()=>{const p=g=>{d.current&&!d.current.contains(g.target)&&(u(!1),s&&s())};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]);const m=i.find(p=>p.id===t)||i[0],h=m.icon||gs;return e.jsxs("div",{className:`relative ${a}`,ref:d,children:[e.jsx("button",{type:"button",onClick:()=>u(!c),className:`w-10 h-10 sm:w-10 sm:h-10 rounded-full flex items-center justify-center transition-all duration-200 ${t==="none"?"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600":"bg-blue-100 hover:bg-blue-200 dark:bg-blue-900 dark:hover:bg-blue-800"}`,title:n("thinkingMode.buttonTitle",{mode:m.name}),children:e.jsx(h,{className:`w-5 h-5 ${m.color}`})}),c&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:"p-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:n("thinkingMode.selector.title")}),e.jsx("button",{onClick:()=>{u(!1),s&&s()},className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:e.jsx(Ve,{className:"w-4 h-4 text-gray-500"})})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:n("thinkingMode.selector.description")})]}),e.jsx("div",{className:"py-1",children:i.map(p=>{const g=p.icon,f=p.id===t;return e.jsx("button",{onClick:()=>{r(p.id),u(!1),s&&s()},className:`w-full px-4 py-3 text-left hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${f?"bg-gray-50 dark:bg-gray-700":""}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 ${p.icon?p.color:"text-gray-400"}`,children:g?e.jsx(g,{className:"w-5 h-5"}):e.jsx("div",{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium text-sm ${f?"text-gray-900 dark:text-white":"text-gray-700 dark:text-gray-300"}`,children:p.name}),f&&e.jsx("span",{className:"text-xs bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 px-2 py-0.5 rounded",children:n("thinkingMode.selector.active")})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:p.description}),p.prefix&&e.jsx("code",{className:"text-xs bg-gray-100 dark:bg-gray-700 px-1.5 py-0.5 rounded mt-1 inline-block",children:p.prefix})]})]})},p.id)})}),e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("strong",{children:"Tip:"})," ",n("thinkingMode.selector.tip")]})})]})]})}function cu({used:t,total:r}){if(t==null||r==null||r<=0)return null;const s=Math.min(100,t/r*100),a=10,n=2*Math.PI*a,o=n-s/100*n,i=()=>s<50?"#3b82f6":s<75?"#f59e0b":"#ef4444";return e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"transform -rotate-90",children:[e.jsx("circle",{cx:"12",cy:"12",r:a,fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-gray-300 dark:text-gray-600"}),e.jsx("circle",{cx:"12",cy:"12",r:a,fill:"none",stroke:i(),strokeWidth:"2",strokeDasharray:n,strokeDashoffset:o,strokeLinecap:"round"})]}),e.jsxs("span",{title:`${t.toLocaleString()} / ${r.toLocaleString()} tokens`,children:[s.toFixed(1),"%"]})]})}function du({permissionMode:t,onModeSwitch:r,provider:s,thinkingMode:a,setThinkingMode:n,tokenBudget:o,currentModel:i,onModelChange:c,modelOptions:u,slashCommandsCount:d,onToggleCommandMenu:m,hasInput:h,onClearInput:p,isUserScrolledUp:g,hasMessages:f,onScrollToBottom:x}){var I;const{t:b}=We("chat"),[N,j]=l.useState(!1),y=l.useRef(null);l.useEffect(()=>{if(!N)return;const D=C=>{y.current&&!y.current.contains(C.target)&&j(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[N]);const k=((I=u.find(D=>D.value===i))==null?void 0:I.label)||i;return e.jsxs("div",{className:"flex items-center justify-center gap-2 sm:gap-3 flex-wrap",children:[e.jsx("button",{type:"button",onClick:r,className:`px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 ${t==="default"?"bg-muted/50 text-muted-foreground border-border/60 hover:bg-muted":t==="acceptEdits"?"bg-green-50 dark:bg-green-900/15 text-green-700 dark:text-green-300 border-green-300/60 dark:border-green-600/40 hover:bg-green-100 dark:hover:bg-green-900/25":t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/15 text-orange-700 dark:text-orange-300 border-orange-300/60 dark:border-orange-600/40 hover:bg-orange-100 dark:hover:bg-orange-900/25":"bg-primary/5 text-primary border-primary/20 hover:bg-primary/10"}`,title:b("input.clickToChangeMode"),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${t==="default"?"bg-muted-foreground":t==="acceptEdits"?"bg-green-500":t==="bypassPermissions"?"bg-orange-500":"bg-primary"}`}),e.jsxs("span",{children:[t==="default"&&b("codex.modes.default"),t==="acceptEdits"&&b("codex.modes.acceptEdits"),t==="bypassPermissions"&&b("codex.modes.bypassPermissions"),t==="plan"&&b("codex.modes.plan")]})]})}),s==="claude"&&e.jsx(lu,{selectedMode:a,onModeChange:n,onClose:()=>{},className:""}),e.jsxs("div",{className:"relative",ref:y,children:[e.jsx("button",{type:"button",onClick:()=>j(D=>!D),className:"px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 bg-muted/50 text-muted-foreground border-border/60 hover:bg-muted hover:text-foreground",title:b("input.selectModel",{defaultValue:"Select model"}),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),e.jsx("span",{children:k}),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})}),N&&e.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 bg-card border border-border/60 rounded-xl shadow-lg min-w-[160px] max-h-[240px] overflow-y-auto z-50",children:u.map(D=>e.jsx("button",{type:"button",onClick:()=>{c(D.value),j(!1)},className:`w-full text-left px-3 py-2 text-sm transition-colors first:rounded-t-xl last:rounded-b-xl ${D.value===i?"bg-primary/10 text-primary font-medium":"text-foreground hover:bg-accent/50"}`,children:D.label},D.value))})]}),e.jsx(cu,{used:(o==null?void 0:o.used)||0,total:(o==null?void 0:o.total)||parseInt(void 0)||16e4}),e.jsxs("button",{type:"button",onClick:m,className:"relative w-8 h-8 sm:w-8 sm:h-8 text-muted-foreground hover:text-foreground rounded-lg flex items-center justify-center transition-colors hover:bg-accent/60",title:b("input.showAllCommands"),children:[e.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),d>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-primary text-primary-foreground text-[10px] font-bold rounded-full w-4 h-4 sm:w-5 sm:h-5 flex items-center justify-center",children:d})]}),h&&e.jsx("button",{type:"button",onClick:p,className:"w-8 h-8 sm:w-8 sm:h-8 bg-card hover:bg-accent/60 border border-border/50 rounded-lg flex items-center justify-center transition-all duration-200 group shadow-sm",title:b("input.clearInput",{defaultValue:"Clear input"}),children:e.jsx("svg",{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 text-muted-foreground group-hover:text-foreground transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),g&&f&&e.jsx("button",{onClick:x,className:"w-8 h-8 sm:w-8 sm:h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-lg shadow-sm flex items-center justify-center transition-all duration-200 hover:scale-105",title:b("input.scrollToBottom",{defaultValue:"Scroll to bottom"}),children:e.jsx("svg",{className:"w-3.5 h-3.5 sm:w-4 sm:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})})]})}const cn="upfynai-voice-output-enabled",dn="upfynai-voice-id",uu=2e3;function Go(){const[t,r]=l.useState(!1),[s,a]=l.useState(()=>localStorage.getItem(cn)==="true"),[n,o]=l.useState(()=>localStorage.getItem(dn)||"en-US-AriaNeural"),i=l.useRef(null),c=l.useRef(null),u=l.useCallback(async p=>{if(!(!s||!p)&&!(p.length>uu))try{r(!0);const g=await Me("/api/voice/tts",{method:"POST",body:JSON.stringify({text:p,voice:n})});if(!g.ok)throw new Error("TTS failed");const f=await g.blob(),x=URL.createObjectURL(f);i.current&&(i.current.pause(),i.current=null),c.current&&URL.revokeObjectURL(c.current),c.current=x;const b=new Audio(x);i.current=b,b.onended=()=>{r(!1),URL.revokeObjectURL(x),c.current=null,i.current=null},b.onerror=()=>{r(!1),URL.revokeObjectURL(x),c.current=null,i.current=null},await b.play()}catch{r(!1)}},[s,n]),d=l.useCallback(()=>{i.current&&(i.current.pause(),i.current=null),c.current&&(URL.revokeObjectURL(c.current),c.current=null),r(!1)},[]),m=l.useCallback(()=>{const p=!s;a(p),localStorage.setItem(cn,String(p)),p||d()},[s,d]),h=l.useCallback(p=>{o(p),localStorage.setItem(dn,p)},[]);return{speak:u,stop:d,isPlaying:t,voiceEnabled:s,toggleVoice:m,selectedVoice:n,changeVoice:h}}function mu({pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s,claudeStatus:a,isLoading:n,onAbortSession:o,provider:i,permissionMode:c,onModeSwitch:u,thinkingMode:d,setThinkingMode:m,tokenBudget:h,currentModel:p,onModelChange:g,modelOptions:f,slashCommandsCount:x,onToggleCommandMenu:b,hasInput:N,onClearInput:j,isUserScrolledUp:y,hasMessages:k,onScrollToBottom:I,onSubmit:D,isDragActive:C,attachedImages:v,onRemoveImage:E,uploadingImages:T,imageErrors:W,showFileDropdown:S,filteredFiles:O,selectedFileIndex:H,onSelectFile:R,filteredCommands:A,selectedCommandIndex:z,onCommandSelect:J,onCloseCommandMenu:re,isCommandMenuOpen:G,frequentCommands:ie,getRootProps:$,getInputProps:Z,openImagePicker:te,inputHighlightRef:Q,renderInputWithMentions:_,textareaRef:F,input:q,onInputChange:U,onTextareaClick:B,onTextareaKeyDown:ee,onTextareaPaste:V,onTextareaScrollSync:w,onTextareaInput:M,onInputFocusChange:Y,isInputFocused:se,placeholder:de,isTextareaExpanded:je,sendByCtrlEnter:ge,onTranscript:Re}){var Fe;const{t:Ne}=We("chat"),{voiceEnabled:De,toggleVoice:Ue,isPlaying:_e}=Go(),L=eu,K=(Fe=F.current)==null?void 0:Fe.getBoundingClientRect(),pe={top:K?Math.max(16,K.top-316):0,left:K?K.left:16,bottom:K?window.innerHeight-K.top+8:90},ye=t.some(Se=>Se.toolName==="AskUserQuestion"),Ie=se?"max-sm:fixed max-sm:bottom-0 max-sm:left-0 max-sm:right-0 max-sm:z-50 max-sm:bg-background max-sm:shadow-[0_-4px_20px_rgba(0,0,0,0.12)] max-sm:border-t max-sm:border-border/30 max-sm:rounded-b-none":"";return e.jsxs("div",{className:`sticky bottom-0 z-30 bg-background p-2 sm:p-3 flex-shrink-0 pb-2 ${Ie}`,children:[!ye&&e.jsx("div",{className:"flex-1",children:e.jsx(tu,{status:a,isLoading:n,onAbort:o,provider:i})}),e.jsxs("div",{className:"max-w-4xl mx-auto mb-3",children:[e.jsx(iu,{pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s}),!ye&&e.jsx(du,{permissionMode:c,onModeSwitch:u,provider:i,thinkingMode:d,setThinkingMode:m,tokenBudget:h,currentModel:p,onModelChange:g,modelOptions:f,slashCommandsCount:x,onToggleCommandMenu:b,hasInput:N,onClearInput:j,isUserScrolledUp:y,hasMessages:k,onScrollToBottom:I})]}),!ye&&e.jsxs("form",{onSubmit:D,className:"relative max-w-4xl mx-auto",children:[C&&e.jsx("div",{className:"absolute inset-0 bg-primary/15 border-2 border-dashed border-primary/50 rounded-2xl flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card rounded-xl p-4 shadow-lg border border-border/30",children:[e.jsx("svg",{className:"w-8 h-8 text-primary mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),e.jsx("p",{className:"text-sm font-medium",children:"Drop images here"})]})}),v.length>0&&e.jsx("div",{className:"mb-2 p-2 bg-muted/40 rounded-xl",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:v.map((Se,Oe)=>e.jsx(au,{file:Se,onRemove:()=>E(Oe),uploadProgress:T.get(Se.name),error:W.get(Se.name)},Oe))})}),S&&O.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-card/95 backdrop-blur-md border border-border/50 rounded-xl shadow-lg max-h-48 overflow-y-auto z-50",children:O.map((Se,Oe)=>e.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-border/30 last:border-b-0 touch-manipulation ${Oe===H?"bg-primary/8 text-primary":"hover:bg-accent/50 text-foreground"}`,onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),R(Se)},children:[e.jsx("div",{className:"font-medium text-sm",children:Se.name}),e.jsx("div",{className:"text-xs text-muted-foreground font-mono",children:Se.path})]},Se.path))}),e.jsx(L,{commands:A,selectedIndex:z,onSelect:J,onClose:re,position:pe,isOpen:G,frequentCommands:ie}),e.jsxs("div",{...$(),className:`relative bg-card/80 backdrop-blur-sm rounded-2xl shadow-sm border border-border/40 focus-within:shadow-md focus-within:border-primary/25 focus-within:ring-1 focus-within:ring-primary/10 transition-all duration-200 overflow-hidden ${je?"chat-input-expanded":""}`,children:[e.jsx("input",{...Z()}),e.jsx("div",{ref:Q,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden rounded-2xl",children:e.jsx("div",{className:"chat-input-placeholder block w-full pl-12 pr-20 sm:pr-40 py-1.5 sm:py-4 text-transparent text-base leading-6 whitespace-pre-wrap break-words",children:_(q)})}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("textarea",{ref:F,value:q,onChange:U,onClick:B,onKeyDown:ee,onPaste:V,onScroll:Se=>w(Se.target),onFocus:()=>Y==null?void 0:Y(!0),onBlur:()=>Y==null?void 0:Y(!1),onInput:M,placeholder:de,disabled:n,className:"chat-input-placeholder block w-full pl-12 pr-20 sm:pr-40 py-1.5 sm:py-4 bg-transparent rounded-2xl focus:outline-none text-foreground placeholder-muted-foreground/50 disabled:opacity-50 resize-none min-h-[50px] sm:min-h-[80px] max-h-[40vh] sm:max-h-[300px] overflow-y-auto text-base leading-6 transition-all duration-200",style:{height:"50px"}}),e.jsx("button",{type:"button",onClick:te,className:"absolute left-1.5 top-1/2 transform -translate-y-1/2 w-9 h-9 flex items-center justify-center hover:bg-accent/60 rounded-xl transition-colors",title:Ne("input.attachImages"),children:e.jsx("svg",{className:"w-5 h-5 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsxs("div",{className:"absolute right-[88px] sm:right-[88px] top-1/2 transform -translate-y-1/2 flex items-center gap-0.5",children:[e.jsx(su,{onTranscript:Re}),e.jsx("button",{type:"button",onClick:Ue,className:`w-9 h-9 flex items-center justify-center rounded-lg transition-colors ${De?"text-primary hover:bg-primary/10":"text-muted-foreground/40 hover:text-muted-foreground hover:bg-accent/50"} ${_e?"animate-pulse":""}`,title:De?"Disable voice output":"Enable voice output",children:De?e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.536 8.464a5 5 0 010 7.072M18.364 5.636a9 9 0 010 12.728M11 5L6 9H2v6h4l5 4V5z"})}):e.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707A1 1 0 0112 5v14a1 1 0 01-1.707.707L5.586 15z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]})})]}),e.jsx("button",{type:"submit",disabled:!q.trim()||n,onMouseDown:Se=>{Se.preventDefault(),D(Se)},onTouchStart:Se=>{Se.preventDefault(),D(Se)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-10 h-10 sm:w-11 sm:h-11 bg-primary hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground disabled:cursor-not-allowed rounded-xl flex items-center justify-center transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:ring-offset-1 focus:ring-offset-background",children:e.jsx("svg",{className:"w-4 h-4 sm:w-[18px] sm:h-[18px] text-primary-foreground transform rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})}),e.jsx("div",{className:`absolute bottom-1 left-12 right-14 sm:right-40 text-xs text-muted-foreground/50 pointer-events-none hidden sm:block transition-opacity duration-200 ${q.trim()?"opacity-0":"opacity-100"}`,children:Ne(ge?"input.hintText.ctrlEnter":"input.hintText.enter")})]})]})]})]})}function pu({selectedSession:t}){const[r,s]=l.useState("default"),[a,n]=l.useState([]),[o,i]=l.useState(()=>localStorage.getItem("selected-provider")||"claude"),[c,u]=l.useState(()=>localStorage.getItem("cursor-model")||Aa.DEFAULT),[d,m]=l.useState(()=>localStorage.getItem("claude-model")||Ta.DEFAULT),[h,p]=l.useState(()=>localStorage.getItem("codex-model")||Ia.DEFAULT),g=l.useRef(o);l.useEffect(()=>{if(!(t!=null&&t.id))return;const x=localStorage.getItem(`permissionMode-${t.id}`);s(x||"default")},[t==null?void 0:t.id]),l.useEffect(()=>{!(t!=null&&t.__provider)||t.__provider===o||(i(t.__provider),localStorage.setItem("selected-provider",t.__provider))},[o,t]),l.useEffect(()=>{g.current!==o&&(n([]),g.current=o)},[o]),l.useEffect(()=>{n(x=>x.filter(b=>!b.sessionId||b.sessionId===(t==null?void 0:t.id)))},[t==null?void 0:t.id]),l.useEffect(()=>{o==="cursor"&&Me("/api/cursor/config").then(x=>x.json()).then(x=>{var N,j;if(!x.success||!((j=(N=x.config)==null?void 0:N.model)!=null&&j.modelId))return;const b=x.config.model.modelId;localStorage.getItem("cursor-model")||u(b)}).catch(x=>{console.error("Error loading Cursor config:",x)})},[o]);const f=l.useCallback(()=>{const x=o==="codex"?["default","acceptEdits","bypassPermissions"]:["default","acceptEdits","bypassPermissions","plan"],N=(x.indexOf(r)+1)%x.length,j=x[N];s(j),t!=null&&t.id&&localStorage.setItem(`permissionMode-${t.id}`,j)},[r,o,t==null?void 0:t.id]);return{provider:o,setProvider:i,cursorModel:c,setCursorModel:u,claudeModel:d,setClaudeModel:m,codexModel:h,setCodexModel:p,permissionMode:r,setPermissionMode:s,pendingPermissionRequests:a,setPendingPermissionRequests:n,cyclePermissionMode:f}}const xu=t=>Array.isArray(t)?t:[],Tr=t=>{if(!t)return!0;const r=t.trim();return r.startsWith("<command-name>")||r.startsWith("<command-message>")||r.startsWith("<command-args>")||r.startsWith("<local-command-stdout>")||r.startsWith("<system-reminder>")||r.startsWith("<INSTRUCTIONS>")||r.startsWith("<instructions>")||r.startsWith("Caveat:")||r.startsWith("This session is being continued from a previous")||r.startsWith("[Request interrupted")||/^#\s+AGENTS\.md instructions for/i.test(r)||r.startsWith("# AGENTS.md")||r.includes("## Skills")&&r.includes("### Available skills")||r.includes("### How to use skills")&&r.includes("Trigger rules:")||r.startsWith("A skill is a set of local instructions")||/^<system[_-]?prompt>/i.test(r)||r.startsWith("## System Information")&&r.includes("Operating System:")},os=t=>{if(t==null||t==="")return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}},zs=(t,r)=>r&&(r.startsWith("/")?r:`${t}/${r}`),gu=(t,r)=>{const s=t.split(`
129
+ animate-fade-in shadow-lg max-w-[220px] text-center`,style:{whiteSpace:"normal"},children:n}),s==="recording"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),s==="processing"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}const nu=({file:t,onRemove:r,uploadProgress:s,error:a})=>{const[n,o]=l.useState(void 0);return l.useEffect(()=>{const i=URL.createObjectURL(t);return o(i),()=>URL.revokeObjectURL(i)},[t]),e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:n,alt:t.name,className:"w-20 h-20 object-cover rounded"}),s!==void 0&&s<100&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("div",{className:"text-white text-xs",children:[s,"%"]})}),a&&e.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("button",{type:"button",onClick:r,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 focus:opacity-100 transition-opacity","aria-label":"Remove image",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},Ho={};function ou(t,r){Ho[t]=r}function iu(t){return Ho[t]||null}ou("AskUserQuestion",Wd);function lu({pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s}){return t.length?e.jsx("div",{className:"mb-3 space-y-2",children:t.map(a=>{const n=iu(a.toolName);if(n)return e.jsx(n,{request:a,onDecision:r},a.requestId);const o=an(a.input),i=ta(a.toolName,o),c=Ta(),u=i?c.allowedTools.includes(i):!1,d=u?"Allow (saved)":"Allow & remember",m=i?t.filter(h=>ta(h.toolName,an(h.input))===i).map(h=>h.requestId):[a.requestId];return e.jsxs("div",{className:"rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/20 p-3 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-amber-900 dark:text-amber-100",children:"Permission required"}),e.jsxs("div",{className:"text-xs text-amber-800 dark:text-amber-200",children:["Tool: ",e.jsx("span",{className:"font-mono",children:a.toolName})]})]}),i&&e.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:["Allow rule: ",e.jsx("span",{className:"font-mono",children:i})]})]}),o&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-amber-800 dark:text-amber-200 hover:text-amber-900 dark:hover:text-amber-100",children:"View tool input"}),e.jsx("pre",{className:"mt-2 max-h-40 overflow-auto rounded-md bg-white/80 dark:bg-gray-900/60 border border-amber-200/60 dark:border-amber-800/60 p-2 text-xs text-amber-900 dark:text-amber-100 whitespace-pre-wrap",children:o})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(a.requestId,{allow:!0}),className:"inline-flex items-center gap-2 rounded-md bg-amber-600 text-white text-xs font-medium px-3 py-1.5 hover:bg-amber-700 transition-colors",children:"Allow once"}),e.jsx("button",{type:"button",onClick:()=>{i&&!u&&s({entry:i,toolName:a.toolName}),r(m,{allow:!0,rememberEntry:i})},className:`inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border transition-colors ${i?"border-amber-300 text-amber-800 hover:bg-amber-100 dark:border-amber-700 dark:text-amber-100 dark:hover:bg-amber-900/30":"border-gray-300 text-gray-400 cursor-not-allowed"}`,disabled:!i,children:d}),e.jsx("button",{type:"button",onClick:()=>r(a.requestId,{allow:!1,message:"User denied tool use"}),className:"inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border border-red-300 text-red-700 hover:bg-red-50 dark:border-red-800 dark:text-red-200 dark:hover:bg-red-900/30 transition-colors",children:"Deny"})]})]},a.requestId)})}):null}const Go=[{id:"none",name:"Standard",description:"Regular Claude response",icon:null,prefix:"",color:"text-gray-600"},{id:"think",name:"Think",description:"Basic extended thinking",icon:gs,prefix:"think",color:"text-blue-600"},{id:"think-hard",name:"Think Hard",description:"More thorough evaluation",icon:tr,prefix:"think hard",color:"text-purple-600"},{id:"think-harder",name:"Think Harder",description:"Deep analysis with alternatives",icon:Ut,prefix:"think harder",color:"text-indigo-600"},{id:"ultrathink",name:"Ultrathink",description:"Maximum thinking budget",icon:Ti,prefix:"ultrathink",color:"text-red-600"}];function cu({selectedMode:t,onModeChange:r,onClose:s,className:a=""}){const{t:n}=We("chat"),o={"think-hard":"thinkHard","think-harder":"thinkHarder"},i=Go.map(p=>{const g=o[p.id]||p.id;return{...p,name:n(`thinkingMode.modes.${g}.name`),description:n(`thinkingMode.modes.${g}.description`),prefix:n(`thinkingMode.modes.${g}.prefix`)}}),[c,u]=l.useState(!1),d=l.useRef(null);l.useEffect(()=>{const p=g=>{d.current&&!d.current.contains(g.target)&&(u(!1),s&&s())};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]);const m=i.find(p=>p.id===t)||i[0],h=m.icon||gs;return e.jsxs("div",{className:`relative ${a}`,ref:d,children:[e.jsx("button",{type:"button",onClick:()=>u(!c),className:`w-10 h-10 sm:w-10 sm:h-10 rounded-full flex items-center justify-center transition-all duration-200 ${t==="none"?"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600":"bg-blue-100 hover:bg-blue-200 dark:bg-blue-900 dark:hover:bg-blue-800"}`,title:n("thinkingMode.buttonTitle",{mode:m.name}),children:e.jsx(h,{className:`w-5 h-5 ${m.color}`})}),c&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:"p-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:n("thinkingMode.selector.title")}),e.jsx("button",{onClick:()=>{u(!1),s&&s()},className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:e.jsx(Ve,{className:"w-4 h-4 text-gray-500"})})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:n("thinkingMode.selector.description")})]}),e.jsx("div",{className:"py-1",children:i.map(p=>{const g=p.icon,f=p.id===t;return e.jsx("button",{onClick:()=>{r(p.id),u(!1),s&&s()},className:`w-full px-4 py-3 text-left hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${f?"bg-gray-50 dark:bg-gray-700":""}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 ${p.icon?p.color:"text-gray-400"}`,children:g?e.jsx(g,{className:"w-5 h-5"}):e.jsx("div",{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium text-sm ${f?"text-gray-900 dark:text-white":"text-gray-700 dark:text-gray-300"}`,children:p.name}),f&&e.jsx("span",{className:"text-xs bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 px-2 py-0.5 rounded",children:n("thinkingMode.selector.active")})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:p.description}),p.prefix&&e.jsx("code",{className:"text-xs bg-gray-100 dark:bg-gray-700 px-1.5 py-0.5 rounded mt-1 inline-block",children:p.prefix})]})]})},p.id)})}),e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("strong",{children:"Tip:"})," ",n("thinkingMode.selector.tip")]})})]})]})}function du({used:t,total:r}){if(t==null||r==null||r<=0)return null;const s=Math.min(100,t/r*100),a=10,n=2*Math.PI*a,o=n-s/100*n,i=()=>s<50?"#3b82f6":s<75?"#f59e0b":"#ef4444";return e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"transform -rotate-90",children:[e.jsx("circle",{cx:"12",cy:"12",r:a,fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-gray-300 dark:text-gray-600"}),e.jsx("circle",{cx:"12",cy:"12",r:a,fill:"none",stroke:i(),strokeWidth:"2",strokeDasharray:n,strokeDashoffset:o,strokeLinecap:"round"})]}),e.jsxs("span",{title:`${t.toLocaleString()} / ${r.toLocaleString()} tokens`,children:[s.toFixed(1),"%"]})]})}function uu({permissionMode:t,onModeSwitch:r,provider:s,thinkingMode:a,setThinkingMode:n,tokenBudget:o,currentModel:i,onModelChange:c,modelOptions:u,slashCommandsCount:d,onToggleCommandMenu:m,hasInput:h,onClearInput:p,isUserScrolledUp:g,hasMessages:f,onScrollToBottom:x}){var I;const{t:b}=We("chat"),[N,j]=l.useState(!1),y=l.useRef(null);l.useEffect(()=>{if(!N)return;const D=C=>{y.current&&!y.current.contains(C.target)&&j(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[N]);const k=((I=u.find(D=>D.value===i))==null?void 0:I.label)||i;return e.jsxs("div",{className:"flex items-center justify-center gap-2 sm:gap-3 flex-wrap",children:[e.jsx("button",{type:"button",onClick:r,className:`px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 ${t==="default"?"bg-muted/50 text-muted-foreground border-border/60 hover:bg-muted":t==="acceptEdits"?"bg-green-50 dark:bg-green-900/15 text-green-700 dark:text-green-300 border-green-300/60 dark:border-green-600/40 hover:bg-green-100 dark:hover:bg-green-900/25":t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/15 text-orange-700 dark:text-orange-300 border-orange-300/60 dark:border-orange-600/40 hover:bg-orange-100 dark:hover:bg-orange-900/25":"bg-primary/5 text-primary border-primary/20 hover:bg-primary/10"}`,title:b("input.clickToChangeMode"),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${t==="default"?"bg-muted-foreground":t==="acceptEdits"?"bg-green-500":t==="bypassPermissions"?"bg-orange-500":"bg-primary"}`}),e.jsxs("span",{children:[t==="default"&&b("codex.modes.default"),t==="acceptEdits"&&b("codex.modes.acceptEdits"),t==="bypassPermissions"&&b("codex.modes.bypassPermissions"),t==="plan"&&b("codex.modes.plan")]})]})}),s==="claude"&&e.jsx(cu,{selectedMode:a,onModeChange:n,onClose:()=>{},className:""}),e.jsxs("div",{className:"relative",ref:y,children:[e.jsx("button",{type:"button",onClick:()=>j(D=>!D),className:"px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 bg-muted/50 text-muted-foreground border-border/60 hover:bg-muted hover:text-foreground",title:b("input.selectModel",{defaultValue:"Select model"}),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),e.jsx("span",{children:k}),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})}),N&&e.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 bg-card border border-border/60 rounded-xl shadow-lg min-w-[160px] max-h-[240px] overflow-y-auto z-50",children:u.map(D=>e.jsx("button",{type:"button",onClick:()=>{c(D.value),j(!1)},className:`w-full text-left px-3 py-2 text-sm transition-colors first:rounded-t-xl last:rounded-b-xl ${D.value===i?"bg-primary/10 text-primary font-medium":"text-foreground hover:bg-accent/50"}`,children:D.label},D.value))})]}),e.jsx(du,{used:(o==null?void 0:o.used)||0,total:(o==null?void 0:o.total)||parseInt(void 0)||16e4}),e.jsxs("button",{type:"button",onClick:m,className:"relative w-8 h-8 sm:w-8 sm:h-8 text-muted-foreground hover:text-foreground rounded-lg flex items-center justify-center transition-colors hover:bg-accent/60",title:b("input.showAllCommands"),children:[e.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),d>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-primary text-primary-foreground text-[10px] font-bold rounded-full w-4 h-4 sm:w-5 sm:h-5 flex items-center justify-center",children:d})]}),h&&e.jsx("button",{type:"button",onClick:p,className:"w-8 h-8 sm:w-8 sm:h-8 bg-card hover:bg-accent/60 border border-border/50 rounded-lg flex items-center justify-center transition-all duration-200 group shadow-sm",title:b("input.clearInput",{defaultValue:"Clear input"}),children:e.jsx("svg",{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 text-muted-foreground group-hover:text-foreground transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),g&&f&&e.jsx("button",{onClick:x,className:"w-8 h-8 sm:w-8 sm:h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-lg shadow-sm flex items-center justify-center transition-all duration-200 hover:scale-105",title:b("input.scrollToBottom",{defaultValue:"Scroll to bottom"}),children:e.jsx("svg",{className:"w-3.5 h-3.5 sm:w-4 sm:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})})]})}const dn="upfynai-voice-output-enabled",un="upfynai-voice-id",mu=2e3;function Vo(){const[t,r]=l.useState(!1),[s,a]=l.useState(()=>localStorage.getItem(dn)==="true"),[n,o]=l.useState(()=>localStorage.getItem(un)||"en-US-AriaNeural"),i=l.useRef(null),c=l.useRef(null),u=l.useCallback(async p=>{if(!(!s||!p)&&!(p.length>mu))try{r(!0);const g=await Me("/api/voice/tts",{method:"POST",body:JSON.stringify({text:p,voice:n})});if(!g.ok)throw new Error("TTS failed");const f=await g.blob(),x=URL.createObjectURL(f);i.current&&(i.current.pause(),i.current=null),c.current&&URL.revokeObjectURL(c.current),c.current=x;const b=new Audio(x);i.current=b,b.onended=()=>{r(!1),URL.revokeObjectURL(x),c.current=null,i.current=null},b.onerror=()=>{r(!1),URL.revokeObjectURL(x),c.current=null,i.current=null},await b.play()}catch{r(!1)}},[s,n]),d=l.useCallback(()=>{i.current&&(i.current.pause(),i.current=null),c.current&&(URL.revokeObjectURL(c.current),c.current=null),r(!1)},[]),m=l.useCallback(()=>{const p=!s;a(p),localStorage.setItem(dn,String(p)),p||d()},[s,d]),h=l.useCallback(p=>{o(p),localStorage.setItem(un,p)},[]);return{speak:u,stop:d,isPlaying:t,voiceEnabled:s,toggleVoice:m,selectedVoice:n,changeVoice:h}}function pu({pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s,claudeStatus:a,isLoading:n,onAbortSession:o,provider:i,permissionMode:c,onModeSwitch:u,thinkingMode:d,setThinkingMode:m,tokenBudget:h,currentModel:p,onModelChange:g,modelOptions:f,slashCommandsCount:x,onToggleCommandMenu:b,hasInput:N,onClearInput:j,isUserScrolledUp:y,hasMessages:k,onScrollToBottom:I,onSubmit:D,isDragActive:C,attachedImages:v,onRemoveImage:E,uploadingImages:T,imageErrors:W,showFileDropdown:S,filteredFiles:O,selectedFileIndex:H,onSelectFile:R,filteredCommands:A,selectedCommandIndex:z,onCommandSelect:J,onCloseCommandMenu:re,isCommandMenuOpen:G,frequentCommands:ie,getRootProps:$,getInputProps:Z,openImagePicker:te,inputHighlightRef:Q,renderInputWithMentions:_,textareaRef:F,input:q,onInputChange:U,onTextareaClick:B,onTextareaKeyDown:ee,onTextareaPaste:V,onTextareaScrollSync:w,onTextareaInput:M,onInputFocusChange:Y,isInputFocused:se,placeholder:de,isTextareaExpanded:je,sendByCtrlEnter:ge,onTranscript:Re}){var Fe;const{t:Ne}=We("chat"),{voiceEnabled:De,toggleVoice:Ue,isPlaying:_e}=Vo(),L=tu,K=(Fe=F.current)==null?void 0:Fe.getBoundingClientRect(),pe={top:K?Math.max(16,K.top-316):0,left:K?K.left:16,bottom:K?window.innerHeight-K.top+8:90},ye=t.some(Se=>Se.toolName==="AskUserQuestion"),Ie=se?"max-sm:fixed max-sm:bottom-0 max-sm:left-0 max-sm:right-0 max-sm:z-50 max-sm:bg-background max-sm:shadow-[0_-4px_20px_rgba(0,0,0,0.12)] max-sm:border-t max-sm:border-border/30 max-sm:rounded-b-none":"";return e.jsxs("div",{className:`sticky bottom-0 z-30 bg-background p-2 sm:p-3 flex-shrink-0 pb-2 ${Ie}`,children:[!ye&&e.jsx("div",{className:"flex-1",children:e.jsx(ru,{status:a,isLoading:n,onAbort:o,provider:i})}),e.jsxs("div",{className:"max-w-4xl mx-auto mb-3",children:[e.jsx(lu,{pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s}),!ye&&e.jsx(uu,{permissionMode:c,onModeSwitch:u,provider:i,thinkingMode:d,setThinkingMode:m,tokenBudget:h,currentModel:p,onModelChange:g,modelOptions:f,slashCommandsCount:x,onToggleCommandMenu:b,hasInput:N,onClearInput:j,isUserScrolledUp:y,hasMessages:k,onScrollToBottom:I})]}),!ye&&e.jsxs("form",{onSubmit:D,className:"relative max-w-4xl mx-auto",children:[C&&e.jsx("div",{className:"absolute inset-0 bg-primary/15 border-2 border-dashed border-primary/50 rounded-2xl flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card rounded-xl p-4 shadow-lg border border-border/30",children:[e.jsx("svg",{className:"w-8 h-8 text-primary mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),e.jsx("p",{className:"text-sm font-medium",children:"Drop images here"})]})}),v.length>0&&e.jsx("div",{className:"mb-2 p-2 bg-muted/40 rounded-xl",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:v.map((Se,Oe)=>e.jsx(nu,{file:Se,onRemove:()=>E(Oe),uploadProgress:T.get(Se.name),error:W.get(Se.name)},Oe))})}),S&&O.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-card/95 backdrop-blur-md border border-border/50 rounded-xl shadow-lg max-h-48 overflow-y-auto z-50",children:O.map((Se,Oe)=>e.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-border/30 last:border-b-0 touch-manipulation ${Oe===H?"bg-primary/8 text-primary":"hover:bg-accent/50 text-foreground"}`,onMouseDown:ne=>{ne.preventDefault(),ne.stopPropagation()},onClick:ne=>{ne.preventDefault(),ne.stopPropagation(),R(Se)},children:[e.jsx("div",{className:"font-medium text-sm",children:Se.name}),e.jsx("div",{className:"text-xs text-muted-foreground font-mono",children:Se.path})]},Se.path))}),e.jsx(L,{commands:A,selectedIndex:z,onSelect:J,onClose:re,position:pe,isOpen:G,frequentCommands:ie}),e.jsxs("div",{...$(),className:`relative bg-card/80 backdrop-blur-sm rounded-2xl shadow-sm border border-border/40 focus-within:shadow-md focus-within:border-primary/25 focus-within:ring-1 focus-within:ring-primary/10 transition-all duration-200 overflow-hidden ${je?"chat-input-expanded":""}`,children:[e.jsx("input",{...Z()}),e.jsx("div",{ref:Q,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden rounded-2xl",children:e.jsx("div",{className:"chat-input-placeholder block w-full pl-12 pr-20 sm:pr-40 py-1.5 sm:py-4 text-transparent text-base leading-6 whitespace-pre-wrap break-words",children:_(q)})}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("textarea",{ref:F,value:q,onChange:U,onClick:B,onKeyDown:ee,onPaste:V,onScroll:Se=>w(Se.target),onFocus:()=>Y==null?void 0:Y(!0),onBlur:()=>Y==null?void 0:Y(!1),onInput:M,placeholder:de,disabled:n,className:"chat-input-placeholder block w-full pl-12 pr-20 sm:pr-40 py-1.5 sm:py-4 bg-transparent rounded-2xl focus:outline-none text-foreground placeholder-muted-foreground/50 disabled:opacity-50 resize-none min-h-[50px] sm:min-h-[80px] max-h-[40vh] sm:max-h-[300px] overflow-y-auto text-base leading-6 transition-all duration-200",style:{height:"50px"}}),e.jsx("button",{type:"button",onClick:te,className:"absolute left-1.5 top-1/2 transform -translate-y-1/2 w-9 h-9 flex items-center justify-center hover:bg-accent/60 rounded-xl transition-colors",title:Ne("input.attachImages"),children:e.jsx("svg",{className:"w-5 h-5 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsxs("div",{className:"absolute right-[88px] sm:right-[88px] top-1/2 transform -translate-y-1/2 flex items-center gap-0.5",children:[e.jsx(au,{onTranscript:Re}),e.jsx("button",{type:"button",onClick:Ue,className:`w-9 h-9 flex items-center justify-center rounded-lg transition-colors ${De?"text-primary hover:bg-primary/10":"text-muted-foreground/40 hover:text-muted-foreground hover:bg-accent/50"} ${_e?"animate-pulse":""}`,title:De?"Disable voice output":"Enable voice output",children:De?e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.536 8.464a5 5 0 010 7.072M18.364 5.636a9 9 0 010 12.728M11 5L6 9H2v6h4l5 4V5z"})}):e.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707A1 1 0 0112 5v14a1 1 0 01-1.707.707L5.586 15z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]})})]}),e.jsx("button",{type:"submit",disabled:!q.trim()||n,onMouseDown:Se=>{Se.preventDefault(),D(Se)},onTouchStart:Se=>{Se.preventDefault(),D(Se)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-10 h-10 sm:w-11 sm:h-11 bg-primary hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground disabled:cursor-not-allowed rounded-xl flex items-center justify-center transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:ring-offset-1 focus:ring-offset-background",children:e.jsx("svg",{className:"w-4 h-4 sm:w-[18px] sm:h-[18px] text-primary-foreground transform rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})}),e.jsx("div",{className:`absolute bottom-1 left-12 right-14 sm:right-40 text-xs text-muted-foreground/50 pointer-events-none hidden sm:block transition-opacity duration-200 ${q.trim()?"opacity-0":"opacity-100"}`,children:Ne(ge?"input.hintText.ctrlEnter":"input.hintText.enter")})]})]})]})]})}function xu({selectedSession:t}){const[r,s]=l.useState("default"),[a,n]=l.useState([]),[o,i]=l.useState(()=>localStorage.getItem("selected-provider")||"claude"),[c,u]=l.useState(()=>localStorage.getItem("cursor-model")||Ia.DEFAULT),[d,m]=l.useState(()=>localStorage.getItem("claude-model")||Aa.DEFAULT),[h,p]=l.useState(()=>localStorage.getItem("codex-model")||Ma.DEFAULT),g=l.useRef(o);l.useEffect(()=>{if(!(t!=null&&t.id))return;const x=localStorage.getItem(`permissionMode-${t.id}`);s(x||"default")},[t==null?void 0:t.id]),l.useEffect(()=>{!(t!=null&&t.__provider)||t.__provider===o||(i(t.__provider),localStorage.setItem("selected-provider",t.__provider))},[o,t]),l.useEffect(()=>{g.current!==o&&(n([]),g.current=o)},[o]),l.useEffect(()=>{n(x=>x.filter(b=>!b.sessionId||b.sessionId===(t==null?void 0:t.id)))},[t==null?void 0:t.id]),l.useEffect(()=>{o==="cursor"&&Me("/api/cursor/config").then(x=>x.json()).then(x=>{var N,j;if(!x.success||!((j=(N=x.config)==null?void 0:N.model)!=null&&j.modelId))return;const b=x.config.model.modelId;localStorage.getItem("cursor-model")||u(b)}).catch(x=>{console.error("Error loading Cursor config:",x)})},[o]);const f=l.useCallback(()=>{const x=o==="codex"?["default","acceptEdits","bypassPermissions"]:["default","acceptEdits","bypassPermissions","plan"],N=(x.indexOf(r)+1)%x.length,j=x[N];s(j),t!=null&&t.id&&localStorage.setItem(`permissionMode-${t.id}`,j)},[r,o,t==null?void 0:t.id]);return{provider:o,setProvider:i,cursorModel:c,setCursorModel:u,claudeModel:d,setClaudeModel:m,codexModel:h,setCodexModel:p,permissionMode:r,setPermissionMode:s,pendingPermissionRequests:a,setPendingPermissionRequests:n,cyclePermissionMode:f}}const gu=t=>Array.isArray(t)?t:[],Tr=t=>{if(!t)return!0;const r=t.trim();return r.startsWith("<command-name>")||r.startsWith("<command-message>")||r.startsWith("<command-args>")||r.startsWith("<local-command-stdout>")||r.startsWith("<system-reminder>")||r.startsWith("<INSTRUCTIONS>")||r.startsWith("<instructions>")||r.startsWith("Caveat:")||r.startsWith("This session is being continued from a previous")||r.startsWith("[Request interrupted")||/^#\s+AGENTS\.md instructions for/i.test(r)||r.startsWith("# AGENTS.md")||r.includes("## Skills")&&r.includes("### Available skills")||r.includes("### How to use skills")&&r.includes("Trigger rules:")||r.startsWith("A skill is a set of local instructions")||/^<system[_-]?prompt>/i.test(r)||r.startsWith("## System Information")&&r.includes("Operating System:")},os=t=>{if(t==null||t==="")return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}},zs=(t,r)=>r&&(r.startsWith("/")?r:`${t}/${r}`),hu=(t,r)=>{const s=t.split(`
130
130
  `),a=r.split(`
131
- `),n=Array.from({length:s.length+1},()=>new Array(a.length+1).fill(0));for(let u=s.length-1;u>=0;u-=1)for(let d=a.length-1;d>=0;d-=1)s[u]===a[d]?n[u][d]=n[u+1][d+1]+1:n[u][d]=Math.max(n[u+1][d],n[u][d+1]);const o=[];let i=0,c=0;for(;i<s.length&&c<a.length;){const u=s[i],d=a[c];if(u===d){i+=1,c+=1;continue}if(n[i+1][c]>=n[i][c+1]){o.push({type:"removed",content:u,lineNum:i+1}),i+=1;continue}o.push({type:"added",content:d,lineNum:c+1}),c+=1}for(;i<s.length;)o.push({type:"removed",content:s[i],lineNum:i+1}),i+=1;for(;c<a.length;)o.push({type:"added",content:a[c],lineNum:c+1}),c+=1;return o},hu=()=>{const t=new Map;return(r,s)=>{const a=JSON.stringify([r,s]),n=t.get(a);if(n)return n;const o=gu(r,s);if(t.set(a,o),t.size>100){const i=t.keys().next().value;i&&t.delete(i)}return o}},fu=(t,r)=>{var n,o;const s=[],a={};for(let i=0;i<t.length;i+=1){const c=t[i],u=c.content;let d="",m="assistant",h=null;try{if(u!=null&&u.role&&(u!=null&&u.content)){if(u.role==="system")continue;if(u.role==="tool"){const p=xu(u.content);for(const g of p){if((g==null?void 0:g.type)!=="tool-result")continue;const f=g.toolName==="ApplyPatch"?"Edit":g.toolName||"Unknown Tool",x=g.toolCallId||u.id,b=g.result||"";x&&a[x]?a[x].toolResult={content:b,isError:!1}:s.push({type:"assistant",content:"",timestamp:new Date(Date.now()+i*1e3),blobId:c.id,sequence:c.sequence,rowid:c.rowid,isToolUse:!0,toolName:f,toolId:x,toolInput:os(null),toolResult:{content:b,isError:!1}})}continue}if(m=u.role==="user"?"user":"assistant",Array.isArray(u.content)){const p=[];for(const g of u.content){if((g==null?void 0:g.type)==="text"&&(g!=null&&g.text)){p.push(St(g.text));continue}if((g==null?void 0:g.type)==="reasoning"&&(g!=null&&g.text)){h=St(g.text);continue}if((g==null?void 0:g.type)==="tool-call"||(g==null?void 0:g.type)==="tool_use"){(p.length>0||h)&&(s.push({type:m,content:p.join(`
131
+ `),n=Array.from({length:s.length+1},()=>new Array(a.length+1).fill(0));for(let u=s.length-1;u>=0;u-=1)for(let d=a.length-1;d>=0;d-=1)s[u]===a[d]?n[u][d]=n[u+1][d+1]+1:n[u][d]=Math.max(n[u+1][d],n[u][d+1]);const o=[];let i=0,c=0;for(;i<s.length&&c<a.length;){const u=s[i],d=a[c];if(u===d){i+=1,c+=1;continue}if(n[i+1][c]>=n[i][c+1]){o.push({type:"removed",content:u,lineNum:i+1}),i+=1;continue}o.push({type:"added",content:d,lineNum:c+1}),c+=1}for(;i<s.length;)o.push({type:"removed",content:s[i],lineNum:i+1}),i+=1;for(;c<a.length;)o.push({type:"added",content:a[c],lineNum:c+1}),c+=1;return o},fu=()=>{const t=new Map;return(r,s)=>{const a=JSON.stringify([r,s]),n=t.get(a);if(n)return n;const o=hu(r,s);if(t.set(a,o),t.size>100){const i=t.keys().next().value;i&&t.delete(i)}return o}},bu=(t,r)=>{var n,o;const s=[],a={};for(let i=0;i<t.length;i+=1){const c=t[i],u=c.content;let d="",m="assistant",h=null;try{if(u!=null&&u.role&&(u!=null&&u.content)){if(u.role==="system")continue;if(u.role==="tool"){const p=gu(u.content);for(const g of p){if((g==null?void 0:g.type)!=="tool-result")continue;const f=g.toolName==="ApplyPatch"?"Edit":g.toolName||"Unknown Tool",x=g.toolCallId||u.id,b=g.result||"";x&&a[x]?a[x].toolResult={content:b,isError:!1}:s.push({type:"assistant",content:"",timestamp:new Date(Date.now()+i*1e3),blobId:c.id,sequence:c.sequence,rowid:c.rowid,isToolUse:!0,toolName:f,toolId:x,toolInput:os(null),toolResult:{content:b,isError:!1}})}continue}if(m=u.role==="user"?"user":"assistant",Array.isArray(u.content)){const p=[];for(const g of u.content){if((g==null?void 0:g.type)==="text"&&(g!=null&&g.text)){p.push(St(g.text));continue}if((g==null?void 0:g.type)==="reasoning"&&(g!=null&&g.text)){h=St(g.text);continue}if((g==null?void 0:g.type)==="tool-call"||(g==null?void 0:g.type)==="tool_use"){(p.length>0||h)&&(s.push({type:m,content:p.join(`
132
132
  `),reasoning:h??void 0,timestamp:new Date(Date.now()+i*1e3),blobId:c.id,sequence:c.sequence,rowid:c.rowid}),p.length=0,h=null);const f=g.toolName||g.name||"Unknown Tool",x=f==="ApplyPatch"?"Edit":f,b=g.toolCallId||g.id||`tool_${i}`;let N=g.args||g.input;if(x==="Edit"&&g.args)if(g.args.patch){const y=String(g.args.patch).split(`
133
133
  `),k=[],I=[];let D=!1;y.forEach(C=>{if(C.startsWith("@@")){D=!0;return}D&&(C.startsWith("-")?k.push(C.slice(1)):C.startsWith("+")?I.push(C.slice(1)):C.startsWith(" ")&&(k.push(C.slice(1)),I.push(C.slice(1))))}),N={file_path:zs(r,g.args.file_path),old_string:k.join(`
134
134
  `)||g.args.patch,new_string:I.join(`
135
135
  `)||g.args.patch}}else N=g.args;else if(x==="Read"&&g.args){const y=g.args.path||g.args.file_path;N={file_path:zs(r,y)}}else if(x==="Write"&&g.args){const y=g.args.path||g.args.file_path;N={file_path:zs(r,y),content:g.args.contents||g.args.content}}const j={type:"assistant",content:"",timestamp:new Date(Date.now()+i*1e3),blobId:c.id,sequence:c.sequence,rowid:c.rowid,isToolUse:!0,toolName:x,toolId:b,toolInput:os(N),toolResult:null};s.push(j),a[b]=j;continue}typeof g=="string"&&p.push(g)}p.length>0?(d=p.join(`
136
136
  `),h&&!d&&(s.push({type:m,content:"",reasoning:h,timestamp:new Date(Date.now()+i*1e3),blobId:c.id,sequence:c.sequence,rowid:c.rowid}),d="")):d=""}else typeof u.content=="string"&&(d=u.content)}else if((n=u==null?void 0:u.message)!=null&&n.role&&((o=u==null?void 0:u.message)!=null&&o.content)){if(u.message.role==="system")continue;m=u.message.role==="user"?"user":"assistant",Array.isArray(u.message.content)?d=u.message.content.map(p=>typeof p=="string"?p:(p==null?void 0:p.text)||"").filter(Boolean).join(`
137
- `):typeof u.message.content=="string"&&(d=u.message.content)}}catch(p){console.log("Error parsing blob content:",p)}if(d&&d.trim()&&!Tr(d)){const p={type:m,content:d,timestamp:new Date(Date.now()+i*1e3),blobId:c.id,sequence:c.sequence,rowid:c.rowid};h&&(p.reasoning=h),s.push(p)}}return s.sort((i,c)=>i.sequence!==void 0&&c.sequence!==void 0?Number(i.sequence)-Number(c.sequence):i.rowid!==void 0&&c.rowid!==void 0?Number(i.rowid)-Number(c.rowid):new Date(i.timestamp).getTime()-new Date(c.timestamp).getTime()),s},bu=t=>{const r=[],s=new Map;return t.forEach(a=>{var n,o;((n=a.message)==null?void 0:n.role)==="user"&&Array.isArray((o=a.message)==null?void 0:o.content)&&a.message.content.forEach(i=>{i.type==="tool_result"&&s.set(i.tool_use_id,{content:i.content,isError:!!i.is_error,timestamp:new Date(a.timestamp||Date.now()),toolUseResult:a.toolUseResult||null,subagentTools:a.subagentTools})})}),t.forEach(a=>{var n,o,i,c,u,d,m;if(((n=a.message)==null?void 0:n.role)==="user"&&((o=a.message)!=null&&o.content)){let h="";if(Array.isArray(a.message.content)){const g=[];a.message.content.forEach(f=>{f.type==="text"&&g.push(St(f.text))}),h=g.join(`
138
- `)}else typeof a.message.content=="string"?h=St(a.message.content):h=St(String(a.message.content));if(!(!h||Tr(h))){const f=/<task-notification>\s*<task-id>[^<]*<\/task-id>\s*<output-file>[^<]*<\/output-file>\s*<status>([^<]*)<\/status>\s*<summary>([^<]*)<\/summary>\s*<\/task-notification>/g.exec(h);if(f){const x=((i=f[1])==null?void 0:i.trim())||"completed",b=((c=f[2])==null?void 0:c.trim())||"Background task finished";r.push({type:"assistant",content:b,timestamp:a.timestamp||new Date().toISOString(),isTaskNotification:!0,taskStatus:x})}else r.push({type:"user",content:Vr(h),timestamp:a.timestamp||new Date().toISOString()})}return}if(a.type==="thinking"&&((u=a.message)!=null&&u.content)){r.push({type:"assistant",content:Vr(a.message.content),timestamp:a.timestamp||new Date().toISOString(),isThinking:!0});return}if(a.type==="tool_use"&&a.toolName){r.push({type:"assistant",content:"",timestamp:a.timestamp||new Date().toISOString(),isToolUse:!0,toolName:a.toolName,toolInput:os(a.toolInput),toolCallId:a.toolCallId});return}if(a.type==="tool_result"){for(let h=r.length-1;h>=0;h-=1){const p=r[h];if(!(!p.isToolUse||p.toolResult)&&(!a.toolCallId||p.toolCallId===a.toolCallId)){p.toolResult={content:a.output||"",isError:!1};break}}return}if(((d=a.message)==null?void 0:d.role)==="assistant"&&((m=a.message)!=null&&m.content)){if(Array.isArray(a.message.content)){a.message.content.forEach(h=>{if(h.type==="text"){let p=h.text;if(typeof p=="string"){if(Tr(p))return;p=Vr(p)}r.push({type:"assistant",content:p,timestamp:a.timestamp||new Date().toISOString()});return}if(h.type==="tool_use"){const p=s.get(h.id),g=h.name==="Task",f=[];if(g&&(p!=null&&p.subagentTools)&&Array.isArray(p.subagentTools))for(const x of p.subagentTools)f.push({toolId:x.toolId,toolName:x.toolName,toolInput:x.toolInput,toolResult:x.toolResult||null,timestamp:new Date(x.timestamp||Date.now())});r.push({type:"assistant",content:"",timestamp:a.timestamp||new Date().toISOString(),isToolUse:!0,toolName:h.name,toolInput:os(h.input),toolId:h.id,toolResult:p?{content:typeof p.content=="string"?p.content:JSON.stringify(p.content),isError:p.isError,toolUseResult:p.toolUseResult}:null,toolError:(p==null?void 0:p.isError)||!1,toolResultTimestamp:(p==null?void 0:p.timestamp)||new Date,isSubagentContainer:g,subagentState:g?{childTools:f,currentToolIndex:f.length>0?f.length-1:-1,isComplete:!!p}:void 0})}});return}typeof a.message.content=="string"&&!Tr(a.message.content)&&r.push({type:"assistant",content:Vr(a.message.content),timestamp:a.timestamp||new Date().toISOString()})}}),r},yu=20,Kr=100;function vu({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,autoScrollToBottom:n,externalMessageUpdate:o,processingSessions:i,resetStreamingState:c,pendingViewSessionRef:u}){const[d,m]=l.useState(()=>{if(typeof window<"u"&&t){const ne=ot.getItem(`chat_messages_${t.name}`);if(ne)try{return JSON.parse(ne)}catch{return console.error("Failed to parse saved chat messages, resetting"),ot.removeItem(`chat_messages_${t.name}`),[]}return[]}return[]}),[h,p]=l.useState(!1),[g,f]=l.useState((r==null?void 0:r.id)||null),[x,b]=l.useState([]),[N,j]=l.useState(!1),[y,k]=l.useState(!1),[I,D]=l.useState(!1),[C,v]=l.useState(0),[E,T]=l.useState(!1),[W,S]=l.useState(!1),[O,H]=l.useState(!1),[R,A]=l.useState(null),[z,J]=l.useState(Kr),[re,G]=l.useState(null),[ie,$]=l.useState(!1),[Z,te]=l.useState(!1),[Q,_]=l.useState(!1),[F,q]=l.useState(!1),U=l.useRef(null),B=l.useRef(!1),ee=l.useRef(!1),V=l.useRef(!1),w=l.useRef(!1),M=l.useRef(null),Y=l.useRef(!0),se=l.useRef(0),de=l.useRef({height:0,top:0}),je=l.useRef(null),ge=l.useRef(null),Re=l.useMemo(()=>hu(),[]),Ne=l.useCallback(async(ne,fe,Ee=!1,Le="claude")=>{var Ae;if(!ne||!fe)return[];const Pe=!Ee;Pe?j(!0):k(!0);try{const Ge=Ee?se.current:0,ae=await Be.sessionMessages(ne,fe,yu,Ge,Le);if(!ae.ok)throw new Error("Failed to load session messages");const be=await ae.json();if(Pe&&be.tokenUsage&&A(be.tokenUsage),be.hasMore!==void 0){const Ce=((Ae=be.messages)==null?void 0:Ae.length)||0;return D(!!be.hasMore),v(Number(be.total||0)),se.current=Ge+Ce,be.messages||[]}const ze=be.messages||[];return D(!1),v(ze.length),se.current=ze.length,ze}catch(Ge){return console.error("Error loading session messages:",Ge),[]}finally{Pe?j(!1):k(!1)}},[]),De=l.useCallback(async(ne,fe)=>{var Ee;if(!ne||!fe)return[];j(!0);try{const Le=`/api/cursor/sessions/${encodeURIComponent(fe)}?projectPath=${encodeURIComponent(ne)}`,Pe=await Me(Le);if(!Pe.ok)return[];const Ae=await Pe.json(),Ge=((Ee=Ae==null?void 0:Ae.session)==null?void 0:Ee.messages)||[];return fu(Ge,ne)}catch(Le){return console.error("Error loading Cursor session messages:",Le),[]}finally{j(!1)}},[]),Ue=l.useMemo(()=>bu(x),[x]),_e=l.useCallback(()=>{const ne=U.current;ne&&(ne.scrollTop=ne.scrollHeight)},[]),L=l.useCallback(()=>{_e(),ie&&(J(Kr),$(!1),V.current=!1)},[ie,_e]),K=l.useCallback(()=>{const ne=U.current;if(!ne)return!1;const{scrollTop:fe,scrollHeight:Ee,clientHeight:Le}=ne;return Ee-fe-Le<50},[]),pe=l.useCallback(async ne=>{if(!ne||ee.current||y||V.current||!I||!r||!t)return!1;const fe=r.__provider||"claude";if(fe==="cursor")return!1;ee.current=!0;const Ee=ne.scrollHeight,Le=ne.scrollTop;try{const Pe=await Ne(t.name,r.id,!0,fe);return Pe.length===0?!1:(M.current={height:Ee,top:Le},b(Ae=>[...Pe,...Ae]),J(Ae=>Ae+Pe.length),!0)}finally{ee.current=!1}},[I,y,Ne,t,r]),ye=l.useCallback(async()=>{const ne=U.current;if(!ne)return;const fe=K();if(H(!fe),!V.current){if(!(ne.scrollTop<100)){w.current=!1;return}if(w.current){ne.scrollTop>20&&(w.current=!1);return}await pe(ne)&&(w.current=!0)}},[K,pe]);l.useLayoutEffect(()=>{if(!M.current||!U.current)return;const{height:ne,top:fe}=M.current,Ee=U.current,Pe=Ee.scrollHeight-ne;Ee.scrollTop=fe+Math.max(Pe,0),M.current=null},[d.length]),l.useEffect(()=>{Y.current=!0,w.current=!1,M.current=null,J(Kr),H(!1)},[t==null?void 0:t.name,r==null?void 0:r.id]),l.useEffect(()=>{if(!(!Y.current||!U.current||N)){if(d.length===0){Y.current=!1;return}Y.current=!1,setTimeout(()=>{_e()},200)}},[d.length,N,_e]),l.useEffect(()=>{(async()=>{if(r&&t){const fe=localStorage.getItem("selected-provider")||"claude";if(B.current=!0,g!==null&&g!==r.id?(E||(c(),u.current=null,m([]),b([]),G(null),S(!1)),se.current=0,D(!1),v(0),J(Kr),$(!1),V.current=!1,te(!1),_(!1),q(!1),ge.current&&clearTimeout(ge.current),je.current&&clearTimeout(je.current),A(null),p(!1),s&&a({type:"check-session-status",sessionId:r.id,provider:fe})):g===null&&(se.current=0,D(!1),v(0),s&&a({type:"check-session-status",sessionId:r.id,provider:fe})),fe==="cursor")if(f(r.id),sessionStorage.setItem("cursorSessionId",r.id),E)T(!1);else{const Le=t.fullPath||t.path||"",Pe=await De(Le,r.id);b([]),m(Pe)}else if(f(r.id),E)T(!1);else{const Le=await Ne(t.name,r.id,!1,r.__provider||"claude");b(Le)}}else E||(c(),u.current=null,m([]),b([]),G(null),S(!1),p(!1)),f(null),sessionStorage.removeItem("cursorSessionId"),se.current=0,D(!1),v(0),A(null);setTimeout(()=>{B.current=!1},250)})()},[E,De,Ne,u,c,t,r,a,s]),l.useEffect(()=>{if(!o||!r||!t)return;(async()=>{try{if((localStorage.getItem("selected-provider")||"claude")==="cursor"){const Pe=t.fullPath||t.path||"",Ae=await De(Pe,r.id);b([]),m(Ae);return}const Ee=await Ne(t.name,r.id,!1,r.__provider||"claude");b(Ee),!!n&&K()&&setTimeout(()=>_e(),200)}catch(fe){console.error("Error reloading messages from external update:",fe)}})()},[n,o,K,De,Ne,_e,t,r]),l.useEffect(()=>{r!=null&&r.id&&(u.current=null)},[u,r==null?void 0:r.id]),l.useEffect(()=>{x.length>0&&m(Ue)},[Ue,x.length]),l.useEffect(()=>{t&&d.length>0&&ot.setItem(`chat_messages_${t.name}`,JSON.stringify(d))},[d,t]),l.useEffect(()=>{if(!t||!(r!=null&&r.id)||r.id.startsWith("new-session-")){A(null);return}if((r.__provider||"claude")!=="claude")return;(async()=>{try{const Ee=`/api/projects/${t.name}/sessions/${r.id}/token-usage`,Le=await Me(Ee);if(Le.ok){const Pe=await Le.json();A(Pe)}else A(null)}catch(Ee){console.error("Failed to fetch initial token usage:",Ee)}})()},[t,r==null?void 0:r.id,r==null?void 0:r.__provider]);const Ie=l.useMemo(()=>d.length<=z?d:d.slice(-z),[d,z]);l.useEffect(()=>{if(!n&&U.current){const ne=U.current;de.current={height:ne.scrollHeight,top:ne.scrollTop}}}),l.useEffect(()=>{if(!U.current||d.length===0||ee.current||y||M.current)return;if(n){O||setTimeout(()=>_e(),50);return}const ne=U.current,fe=de.current.height,Ee=de.current.top,Pe=ne.scrollHeight-fe;Pe>0&&Ee>0&&(ne.scrollTop=Ee+Pe)},[n,d.length,y,O,_e]),l.useEffect(()=>{const ne=U.current;if(ne)return ne.addEventListener("scroll",ye),()=>ne.removeEventListener("scroll",ye)},[ye]),l.useEffect(()=>{const ne=(r==null?void 0:r.id)||g;if(!ne||!i)return;i.has(ne)&&!h&&(p(!0),S(!0))},[g,h,i,r==null?void 0:r.id]);const Fe=l.useRef(!1);l.useEffect(()=>{const ne=Fe.current;return Fe.current=y,ne&&!y&&I&&(ge.current&&clearTimeout(ge.current),q(!0),ge.current=setTimeout(()=>{q(!1)},2e3)),!I&&!y&&(ge.current&&clearTimeout(ge.current),q(!1)),()=>{ge.current&&clearTimeout(ge.current)}},[y,I]);const Se=l.useCallback(async()=>{if(!r||!t||Z)return;const ne=r.__provider||"claude";if(ne==="cursor"){J(1/0),$(!0),V.current=!0,_(!0),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>{_(!1),q(!1)},1e3);return}const fe=r.id;V.current=!0,ee.current=!0,te(!0),q(!0);const Ee=U.current,Le=Ee?Ee.scrollHeight:0,Pe=Ee?Ee.scrollTop:0;try{const Ae=await Be.sessionMessages(t.name,fe,null,0,ne);if(g!==fe)return;if(Ae.ok){const Ge=await Ae.json(),ae=Ge.messages||Ge;Ee&&(M.current={height:Le,top:Pe}),b(Array.isArray(ae)?ae:[]),D(!1),v(Array.isArray(ae)?ae.length:0),se.current=Array.isArray(ae)?ae.length:0,J(1/0),$(!0),_(!0),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>{_(!1),q(!1)},1e3)}else V.current=!1,q(!1)}catch(Ae){console.error("Error loading all messages:",Ae),V.current=!1,q(!1)}finally{ee.current=!1,te(!1)}},[r,t,Z,g]),Oe=l.useCallback(()=>{J(ne=>ne+100)},[]);return{chatMessages:d,setChatMessages:m,isLoading:h,setIsLoading:p,currentSessionId:g,setCurrentSessionId:f,sessionMessages:x,setSessionMessages:b,isLoadingSessionMessages:N,isLoadingMoreMessages:y,hasMoreMessages:I,totalMessages:C,isSystemSessionChange:E,setIsSystemSessionChange:T,canAbortSession:W,setCanAbortSession:S,isUserScrolledUp:O,setIsUserScrolledUp:H,tokenBudget:R,setTokenBudget:A,visibleMessageCount:z,visibleMessages:Ie,loadEarlierMessages:Oe,loadAllMessages:Se,allMessagesLoaded:ie,isLoadingAllMessages:Z,loadAllJustFinished:Q,showLoadAllOverlay:F,claudeStatus:re,setClaudeStatus:G,createDiff:Re,scrollContainerRef:U,scrollToBottom:_e,scrollToBottomAndReset:L,isNearBottom:K,handleScroll:ye,loadSessionMessages:Ne,loadCursorSessionMessages:De}}const Jr=(t,r,s=!1)=>{r&&t(a=>{const n=[...a],o=n.length-1,i=n[o];if(i&&i.type==="assistant"&&!i.isToolUse&&i.isStreaming){const c=s?i.content?`${i.content}
139
- ${r}`:r:`${i.content||""}${r}`;n[o]={...i,content:c}}else n.push({type:"assistant",content:r,timestamp:new Date,isStreaming:!0});return n})},ku=t=>{t(r=>{const s=[...r],a=s.length-1,n=s[a];return n&&n.type==="assistant"&&n.isStreaming&&(s[a]={...n,isStreaming:!1}),s})};function wu({latestMessage:t,provider:r,selectedProject:s,selectedSession:a,currentSessionId:n,setCurrentSessionId:o,setChatMessages:i,setIsLoading:c,setCanAbortSession:u,setClaudeStatus:d,setTokenBudget:m,setIsSystemSessionChange:h,setPendingPermissionRequests:p,pendingViewSessionRef:g,streamBufferRef:f,streamTimerRef:x,onSessionInactive:b,onSessionProcessing:N,onSessionNotProcessing:j,onReplaceTemporarySession:y,onNavigateToSession:k,onResponseComplete:I}){const D=l.useRef(null);l.useEffect(()=>{var te,Q,_,F,q,U,B,ee,V;if(!t||D.current===t)return;D.current=t;const C=((te=t.data)==null?void 0:te.message)||t.data,v=C&&typeof C=="object"?C:null,E=t.data&&typeof t.data=="object"?t.data:null,W=["projects_updated","taskmaster-project-updated","session-created"].includes(String(t.type)),S=new Set(["claude-complete","codex-complete","cursor-result","session-aborted","claude-error","cursor-error","codex-error"]),O=t.type==="claude-response"&&v&&v.type==="system"&&v.subtype==="init",H=t.type==="cursor-system"&&E&&E.type==="system"&&E.subtype==="init",R=O?v==null?void 0:v.session_id:H?E==null?void 0:E.session_id:null,A=(a==null?void 0:a.id)||n||((Q=g.current)==null?void 0:Q.sessionId)||null,z=R&&(!A||R===A),J=W||!!z,re=!t.sessionId&&g.current&&!g.current.sessionId&&(t.type==="claude-error"||t.type==="cursor-error"||t.type==="codex-error"),G=w=>{w&&(b==null||b(w),j==null||j(w))},ie=(...w)=>Array.from(new Set(w.filter(M=>typeof M=="string"&&M.length>0))),$=()=>{c(!1),u(!1),d(null)},Z=(...w)=>{ie(...w).forEach(Y=>{b==null||b(Y),j==null||j(Y)})};if(!J){if(!A&&(t.sessionId&&S.has(String(t.type))&&G(t.sessionId),!re)||!t.sessionId&&!re)return;if(t.sessionId!==A){t.sessionId&&S.has(String(t.type))&&G(t.sessionId);return}}switch(t.type){case"session-created":t.sessionId&&!n&&(sessionStorage.setItem("pendingSessionId",t.sessionId),g.current&&!g.current.sessionId&&(g.current.sessionId=t.sessionId),h(!0),y==null||y(t.sessionId),p(w=>w.map(M=>M.sessionId?M:{...M,sessionId:t.sessionId})));break;case"relay-session-id":{const w=t.cliSessionId;w&&(o(w),sessionStorage.setItem("pendingSessionId",w));break}case"session-busy":case"session-lock-denied":{$();const w=t.error||"Session is busy. Wait for the current request to finish.";i(M=>[...M,{type:"system",content:w,timestamp:new Date().toISOString()}]);break}case"token-budget":t.data&&m(t.data);break;case"claude-response":{if(C&&typeof C=="object"&&C.type){if(C.type==="content_block_delta"&&((_=C.delta)!=null&&_.text)){const w=St(C.delta.text);f.current+=w,x.current||(x.current=window.setTimeout(()=>{const M=f.current;f.current="",x.current=null,Jr(i,M,!1)},100));return}if(C.type==="content_block_stop"){x.current&&(clearTimeout(x.current),x.current=null);const w=f.current;f.current="",Jr(i,w,!1),ku(i);return}}if((v==null?void 0:v.type)==="system"&&v.subtype==="init"&&v.session_id&&n&&v.session_id!==n&&z){h(!0),k==null||k(v.session_id);return}if((v==null?void 0:v.type)==="system"&&v.subtype==="init"&&v.session_id&&!n&&z){h(!0),k==null||k(v.session_id);return}if((v==null?void 0:v.type)==="system"&&v.subtype==="init"&&v.session_id&&n&&v.session_id===n&&z)return;if(v&&Array.isArray(v.content)){const w=E==null?void 0:E.parentToolUseId;v.content.forEach(M=>{var Y;if(M.type==="tool_use"){const se=M.input?JSON.stringify(M.input,null,2):"";if(w){i(je=>je.map(ge=>{var Re;if(ge.toolId===w&&ge.isSubagentContainer){const Ne={toolId:M.id,toolName:M.name,toolInput:M.input,toolResult:null,timestamp:new Date},De=((Re=ge.subagentState)==null?void 0:Re.childTools)||[];return{...ge,subagentState:{childTools:[...De,Ne],currentToolIndex:De.length,isComplete:!1}}}return ge}));return}const de=M.name==="Task";i(je=>[...je,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:M.name,toolInput:se,toolId:M.id,toolResult:null,isSubagentContainer:de,subagentState:de?{childTools:[],currentToolIndex:-1,isComplete:!1}:void 0}]);return}if(M.type==="text"&&((Y=M.text)!=null&&Y.trim())){let se=St(M.text);se=Zs(se),i(de=>[...de,{type:"assistant",content:se,timestamp:new Date}])}})}else if(v&&typeof v.content=="string"&&v.content.trim()){let w=St(v.content);w=Zs(w),i(M=>[...M,{type:"assistant",content:w,timestamp:new Date}])}if((v==null?void 0:v.role)==="user"&&Array.isArray(v.content)){const w=E==null?void 0:E.parentToolUseId;v.content.forEach(M=>{M.type==="tool_result"&&i(Y=>Y.map(se=>{if(w&&se.toolId===w&&se.isSubagentContainer)return{...se,subagentState:{...se.subagentState,childTools:se.subagentState.childTools.map(de=>de.toolId===M.tool_use_id?{...de,toolResult:{content:M.content,isError:M.is_error,timestamp:new Date}}:de)}};if(se.isToolUse&&se.toolId===M.tool_use_id){const de={...se,toolResult:{content:M.content,isError:M.is_error,timestamp:new Date}};return se.isSubagentContainer&&se.subagentState&&(de.subagentState={...se.subagentState,isComplete:!0}),de}return se}))})}break}case"claude-output":{const w=String(t.data||"");w.trim()&&(f.current+=f.current?`
137
+ `):typeof u.message.content=="string"&&(d=u.message.content)}}catch(p){console.log("Error parsing blob content:",p)}if(d&&d.trim()&&!Tr(d)){const p={type:m,content:d,timestamp:new Date(Date.now()+i*1e3),blobId:c.id,sequence:c.sequence,rowid:c.rowid};h&&(p.reasoning=h),s.push(p)}}return s.sort((i,c)=>i.sequence!==void 0&&c.sequence!==void 0?Number(i.sequence)-Number(c.sequence):i.rowid!==void 0&&c.rowid!==void 0?Number(i.rowid)-Number(c.rowid):new Date(i.timestamp).getTime()-new Date(c.timestamp).getTime()),s},yu=t=>{const r=[],s=new Map;return t.forEach(a=>{var n,o;((n=a.message)==null?void 0:n.role)==="user"&&Array.isArray((o=a.message)==null?void 0:o.content)&&a.message.content.forEach(i=>{i.type==="tool_result"&&s.set(i.tool_use_id,{content:i.content,isError:!!i.is_error,timestamp:new Date(a.timestamp||Date.now()),toolUseResult:a.toolUseResult||null,subagentTools:a.subagentTools})})}),t.forEach(a=>{var n,o,i,c,u,d,m;if(((n=a.message)==null?void 0:n.role)==="user"&&((o=a.message)!=null&&o.content)){let h="";if(Array.isArray(a.message.content)){const g=[];a.message.content.forEach(f=>{f.type==="text"&&g.push(St(f.text))}),h=g.join(`
138
+ `)}else typeof a.message.content=="string"?h=St(a.message.content):h=St(String(a.message.content));if(!(!h||Tr(h))){const f=/<task-notification>\s*<task-id>[^<]*<\/task-id>\s*<output-file>[^<]*<\/output-file>\s*<status>([^<]*)<\/status>\s*<summary>([^<]*)<\/summary>\s*<\/task-notification>/g.exec(h);if(f){const x=((i=f[1])==null?void 0:i.trim())||"completed",b=((c=f[2])==null?void 0:c.trim())||"Background task finished";r.push({type:"assistant",content:b,timestamp:a.timestamp||new Date().toISOString(),isTaskNotification:!0,taskStatus:x})}else r.push({type:"user",content:Vr(h),timestamp:a.timestamp||new Date().toISOString()})}return}if(a.type==="thinking"&&((u=a.message)!=null&&u.content)){r.push({type:"assistant",content:Vr(a.message.content),timestamp:a.timestamp||new Date().toISOString(),isThinking:!0});return}if(a.type==="tool_use"&&a.toolName){r.push({type:"assistant",content:"",timestamp:a.timestamp||new Date().toISOString(),isToolUse:!0,toolName:a.toolName,toolInput:os(a.toolInput),toolCallId:a.toolCallId});return}if(a.type==="tool_result"){for(let h=r.length-1;h>=0;h-=1){const p=r[h];if(!(!p.isToolUse||p.toolResult)&&(!a.toolCallId||p.toolCallId===a.toolCallId)){p.toolResult={content:a.output||"",isError:!1};break}}return}if(((d=a.message)==null?void 0:d.role)==="assistant"&&((m=a.message)!=null&&m.content)){if(Array.isArray(a.message.content)){a.message.content.forEach(h=>{if(h.type==="text"){let p=h.text;if(typeof p=="string"){if(Tr(p))return;p=Vr(p)}r.push({type:"assistant",content:p,timestamp:a.timestamp||new Date().toISOString()});return}if(h.type==="tool_use"){const p=s.get(h.id),g=h.name==="Task",f=[];if(g&&(p!=null&&p.subagentTools)&&Array.isArray(p.subagentTools))for(const x of p.subagentTools)f.push({toolId:x.toolId,toolName:x.toolName,toolInput:x.toolInput,toolResult:x.toolResult||null,timestamp:new Date(x.timestamp||Date.now())});r.push({type:"assistant",content:"",timestamp:a.timestamp||new Date().toISOString(),isToolUse:!0,toolName:h.name,toolInput:os(h.input),toolId:h.id,toolResult:p?{content:typeof p.content=="string"?p.content:JSON.stringify(p.content),isError:p.isError,toolUseResult:p.toolUseResult}:null,toolError:(p==null?void 0:p.isError)||!1,toolResultTimestamp:(p==null?void 0:p.timestamp)||new Date,isSubagentContainer:g,subagentState:g?{childTools:f,currentToolIndex:f.length>0?f.length-1:-1,isComplete:!!p}:void 0})}});return}typeof a.message.content=="string"&&!Tr(a.message.content)&&r.push({type:"assistant",content:Vr(a.message.content),timestamp:a.timestamp||new Date().toISOString()})}}),r},vu=20,Kr=100;function ku({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,autoScrollToBottom:n,externalMessageUpdate:o,processingSessions:i,resetStreamingState:c,pendingViewSessionRef:u}){const[d,m]=l.useState(()=>{if(typeof window<"u"&&t){const ne=ot.getItem(`chat_messages_${t.name}`);if(ne)try{return JSON.parse(ne)}catch{return console.error("Failed to parse saved chat messages, resetting"),ot.removeItem(`chat_messages_${t.name}`),[]}return[]}return[]}),[h,p]=l.useState(!1),[g,f]=l.useState((r==null?void 0:r.id)||null),[x,b]=l.useState([]),[N,j]=l.useState(!1),[y,k]=l.useState(!1),[I,D]=l.useState(!1),[C,v]=l.useState(0),[E,T]=l.useState(!1),[W,S]=l.useState(!1),[O,H]=l.useState(!1),[R,A]=l.useState(null),[z,J]=l.useState(Kr),[re,G]=l.useState(null),[ie,$]=l.useState(!1),[Z,te]=l.useState(!1),[Q,_]=l.useState(!1),[F,q]=l.useState(!1),U=l.useRef(null),B=l.useRef(!1),ee=l.useRef(!1),V=l.useRef(!1),w=l.useRef(!1),M=l.useRef(null),Y=l.useRef(!0),se=l.useRef(0),de=l.useRef({height:0,top:0}),je=l.useRef(null),ge=l.useRef(null),Re=l.useMemo(()=>fu(),[]),Ne=l.useCallback(async(ne,fe,Ee=!1,Le="claude")=>{var Ae;if(!ne||!fe)return[];const Pe=!Ee;Pe?j(!0):k(!0);try{const Ge=Ee?se.current:0,ae=await Be.sessionMessages(ne,fe,vu,Ge,Le);if(!ae.ok)throw new Error("Failed to load session messages");const be=await ae.json();if(Pe&&be.tokenUsage&&A(be.tokenUsage),be.hasMore!==void 0){const Ce=((Ae=be.messages)==null?void 0:Ae.length)||0;return D(!!be.hasMore),v(Number(be.total||0)),se.current=Ge+Ce,be.messages||[]}const ze=be.messages||[];return D(!1),v(ze.length),se.current=ze.length,ze}catch(Ge){return console.error("Error loading session messages:",Ge),[]}finally{Pe?j(!1):k(!1)}},[]),De=l.useCallback(async(ne,fe)=>{var Ee;if(!ne||!fe)return[];j(!0);try{const Le=`/api/cursor/sessions/${encodeURIComponent(fe)}?projectPath=${encodeURIComponent(ne)}`,Pe=await Me(Le);if(!Pe.ok)return[];const Ae=await Pe.json(),Ge=((Ee=Ae==null?void 0:Ae.session)==null?void 0:Ee.messages)||[];return bu(Ge,ne)}catch(Le){return console.error("Error loading Cursor session messages:",Le),[]}finally{j(!1)}},[]),Ue=l.useMemo(()=>yu(x),[x]),_e=l.useCallback(()=>{const ne=U.current;ne&&(ne.scrollTop=ne.scrollHeight)},[]),L=l.useCallback(()=>{_e(),ie&&(J(Kr),$(!1),V.current=!1)},[ie,_e]),K=l.useCallback(()=>{const ne=U.current;if(!ne)return!1;const{scrollTop:fe,scrollHeight:Ee,clientHeight:Le}=ne;return Ee-fe-Le<50},[]),pe=l.useCallback(async ne=>{if(!ne||ee.current||y||V.current||!I||!r||!t)return!1;const fe=r.__provider||"claude";if(fe==="cursor")return!1;ee.current=!0;const Ee=ne.scrollHeight,Le=ne.scrollTop;try{const Pe=await Ne(t.name,r.id,!0,fe);return Pe.length===0?!1:(M.current={height:Ee,top:Le},b(Ae=>[...Pe,...Ae]),J(Ae=>Ae+Pe.length),!0)}finally{ee.current=!1}},[I,y,Ne,t,r]),ye=l.useCallback(async()=>{const ne=U.current;if(!ne)return;const fe=K();if(H(!fe),!V.current){if(!(ne.scrollTop<100)){w.current=!1;return}if(w.current){ne.scrollTop>20&&(w.current=!1);return}await pe(ne)&&(w.current=!0)}},[K,pe]);l.useLayoutEffect(()=>{if(!M.current||!U.current)return;const{height:ne,top:fe}=M.current,Ee=U.current,Pe=Ee.scrollHeight-ne;Ee.scrollTop=fe+Math.max(Pe,0),M.current=null},[d.length]),l.useEffect(()=>{Y.current=!0,w.current=!1,M.current=null,J(Kr),H(!1)},[t==null?void 0:t.name,r==null?void 0:r.id]),l.useEffect(()=>{if(!(!Y.current||!U.current||N)){if(d.length===0){Y.current=!1;return}Y.current=!1,setTimeout(()=>{_e()},200)}},[d.length,N,_e]),l.useEffect(()=>{(async()=>{if(r&&t){const fe=localStorage.getItem("selected-provider")||"claude";if(B.current=!0,g!==null&&g!==r.id?(E||(c(),u.current=null,m([]),b([]),G(null),S(!1)),se.current=0,D(!1),v(0),J(Kr),$(!1),V.current=!1,te(!1),_(!1),q(!1),ge.current&&clearTimeout(ge.current),je.current&&clearTimeout(je.current),A(null),p(!1),s&&a({type:"check-session-status",sessionId:r.id,provider:fe})):g===null&&(se.current=0,D(!1),v(0),s&&a({type:"check-session-status",sessionId:r.id,provider:fe})),fe==="cursor")if(f(r.id),sessionStorage.setItem("cursorSessionId",r.id),E)T(!1);else{const Le=t.fullPath||t.path||"",Pe=await De(Le,r.id);b([]),m(Pe)}else if(f(r.id),E)T(!1);else{const Le=await Ne(t.name,r.id,!1,r.__provider||"claude");b(Le)}}else E||(c(),u.current=null,m([]),b([]),G(null),S(!1),p(!1)),f(null),sessionStorage.removeItem("cursorSessionId"),se.current=0,D(!1),v(0),A(null);setTimeout(()=>{B.current=!1},250)})()},[E,De,Ne,u,c,t,r,a,s]),l.useEffect(()=>{if(!o||!r||!t)return;(async()=>{try{if((localStorage.getItem("selected-provider")||"claude")==="cursor"){const Pe=t.fullPath||t.path||"",Ae=await De(Pe,r.id);b([]),m(Ae);return}const Ee=await Ne(t.name,r.id,!1,r.__provider||"claude");b(Ee),!!n&&K()&&setTimeout(()=>_e(),200)}catch(fe){console.error("Error reloading messages from external update:",fe)}})()},[n,o,K,De,Ne,_e,t,r]),l.useEffect(()=>{r!=null&&r.id&&(u.current=null)},[u,r==null?void 0:r.id]),l.useEffect(()=>{x.length>0&&m(Ue)},[Ue,x.length]),l.useEffect(()=>{t&&d.length>0&&ot.setItem(`chat_messages_${t.name}`,JSON.stringify(d))},[d,t]),l.useEffect(()=>{if(!t||!(r!=null&&r.id)||r.id.startsWith("new-session-")){A(null);return}if((r.__provider||"claude")!=="claude")return;(async()=>{try{const Ee=`/api/projects/${t.name}/sessions/${r.id}/token-usage`,Le=await Me(Ee);if(Le.ok){const Pe=await Le.json();A(Pe)}else A(null)}catch(Ee){console.error("Failed to fetch initial token usage:",Ee)}})()},[t,r==null?void 0:r.id,r==null?void 0:r.__provider]);const Ie=l.useMemo(()=>d.length<=z?d:d.slice(-z),[d,z]);l.useEffect(()=>{if(!n&&U.current){const ne=U.current;de.current={height:ne.scrollHeight,top:ne.scrollTop}}}),l.useEffect(()=>{if(!U.current||d.length===0||ee.current||y||M.current)return;if(n){O||setTimeout(()=>_e(),50);return}const ne=U.current,fe=de.current.height,Ee=de.current.top,Pe=ne.scrollHeight-fe;Pe>0&&Ee>0&&(ne.scrollTop=Ee+Pe)},[n,d.length,y,O,_e]),l.useEffect(()=>{const ne=U.current;if(ne)return ne.addEventListener("scroll",ye),()=>ne.removeEventListener("scroll",ye)},[ye]),l.useEffect(()=>{const ne=(r==null?void 0:r.id)||g;if(!ne||!i)return;i.has(ne)&&!h&&(p(!0),S(!0))},[g,h,i,r==null?void 0:r.id]);const Fe=l.useRef(!1);l.useEffect(()=>{const ne=Fe.current;return Fe.current=y,ne&&!y&&I&&(ge.current&&clearTimeout(ge.current),q(!0),ge.current=setTimeout(()=>{q(!1)},2e3)),!I&&!y&&(ge.current&&clearTimeout(ge.current),q(!1)),()=>{ge.current&&clearTimeout(ge.current)}},[y,I]);const Se=l.useCallback(async()=>{if(!r||!t||Z)return;const ne=r.__provider||"claude";if(ne==="cursor"){J(1/0),$(!0),V.current=!0,_(!0),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>{_(!1),q(!1)},1e3);return}const fe=r.id;V.current=!0,ee.current=!0,te(!0),q(!0);const Ee=U.current,Le=Ee?Ee.scrollHeight:0,Pe=Ee?Ee.scrollTop:0;try{const Ae=await Be.sessionMessages(t.name,fe,null,0,ne);if(g!==fe)return;if(Ae.ok){const Ge=await Ae.json(),ae=Ge.messages||Ge;Ee&&(M.current={height:Le,top:Pe}),b(Array.isArray(ae)?ae:[]),D(!1),v(Array.isArray(ae)?ae.length:0),se.current=Array.isArray(ae)?ae.length:0,J(1/0),$(!0),_(!0),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>{_(!1),q(!1)},1e3)}else V.current=!1,q(!1)}catch(Ae){console.error("Error loading all messages:",Ae),V.current=!1,q(!1)}finally{ee.current=!1,te(!1)}},[r,t,Z,g]),Oe=l.useCallback(()=>{J(ne=>ne+100)},[]);return{chatMessages:d,setChatMessages:m,isLoading:h,setIsLoading:p,currentSessionId:g,setCurrentSessionId:f,sessionMessages:x,setSessionMessages:b,isLoadingSessionMessages:N,isLoadingMoreMessages:y,hasMoreMessages:I,totalMessages:C,isSystemSessionChange:E,setIsSystemSessionChange:T,canAbortSession:W,setCanAbortSession:S,isUserScrolledUp:O,setIsUserScrolledUp:H,tokenBudget:R,setTokenBudget:A,visibleMessageCount:z,visibleMessages:Ie,loadEarlierMessages:Oe,loadAllMessages:Se,allMessagesLoaded:ie,isLoadingAllMessages:Z,loadAllJustFinished:Q,showLoadAllOverlay:F,claudeStatus:re,setClaudeStatus:G,createDiff:Re,scrollContainerRef:U,scrollToBottom:_e,scrollToBottomAndReset:L,isNearBottom:K,handleScroll:ye,loadSessionMessages:Ne,loadCursorSessionMessages:De}}const Jr=(t,r,s=!1)=>{r&&t(a=>{const n=[...a],o=n.length-1,i=n[o];if(i&&i.type==="assistant"&&!i.isToolUse&&i.isStreaming){const c=s?i.content?`${i.content}
139
+ ${r}`:r:`${i.content||""}${r}`;n[o]={...i,content:c}}else n.push({type:"assistant",content:r,timestamp:new Date,isStreaming:!0});return n})},wu=t=>{t(r=>{const s=[...r],a=s.length-1,n=s[a];return n&&n.type==="assistant"&&n.isStreaming&&(s[a]={...n,isStreaming:!1}),s})};function ju({latestMessage:t,provider:r,selectedProject:s,selectedSession:a,currentSessionId:n,setCurrentSessionId:o,setChatMessages:i,setIsLoading:c,setCanAbortSession:u,setClaudeStatus:d,setTokenBudget:m,setIsSystemSessionChange:h,setPendingPermissionRequests:p,pendingViewSessionRef:g,streamBufferRef:f,streamTimerRef:x,onSessionInactive:b,onSessionProcessing:N,onSessionNotProcessing:j,onReplaceTemporarySession:y,onNavigateToSession:k,onResponseComplete:I}){const D=l.useRef(null);l.useEffect(()=>{var te,Q,_,F,q,U,B,ee,V;if(!t||D.current===t)return;D.current=t;const C=((te=t.data)==null?void 0:te.message)||t.data,v=C&&typeof C=="object"?C:null,E=t.data&&typeof t.data=="object"?t.data:null,W=["projects_updated","taskmaster-project-updated","session-created"].includes(String(t.type)),S=new Set(["claude-complete","codex-complete","cursor-result","session-aborted","claude-error","cursor-error","codex-error"]),O=t.type==="claude-response"&&v&&v.type==="system"&&v.subtype==="init",H=t.type==="cursor-system"&&E&&E.type==="system"&&E.subtype==="init",R=O?v==null?void 0:v.session_id:H?E==null?void 0:E.session_id:null,A=(a==null?void 0:a.id)||n||((Q=g.current)==null?void 0:Q.sessionId)||null,z=R&&(!A||R===A),J=W||!!z,re=!t.sessionId&&g.current&&!g.current.sessionId&&(t.type==="claude-error"||t.type==="cursor-error"||t.type==="codex-error"),G=w=>{w&&(b==null||b(w),j==null||j(w))},ie=(...w)=>Array.from(new Set(w.filter(M=>typeof M=="string"&&M.length>0))),$=()=>{c(!1),u(!1),d(null)},Z=(...w)=>{ie(...w).forEach(Y=>{b==null||b(Y),j==null||j(Y)})};if(!J){if(!A&&(t.sessionId&&S.has(String(t.type))&&G(t.sessionId),!re)||!t.sessionId&&!re)return;if(t.sessionId!==A){t.sessionId&&S.has(String(t.type))&&G(t.sessionId);return}}switch(t.type){case"session-created":t.sessionId&&!n&&(sessionStorage.setItem("pendingSessionId",t.sessionId),g.current&&!g.current.sessionId&&(g.current.sessionId=t.sessionId),h(!0),y==null||y(t.sessionId),p(w=>w.map(M=>M.sessionId?M:{...M,sessionId:t.sessionId})));break;case"relay-session-id":{const w=t.cliSessionId;w&&(o(w),sessionStorage.setItem("pendingSessionId",w));break}case"session-busy":case"session-lock-denied":{$();const w=t.error||"Session is busy. Wait for the current request to finish.";i(M=>[...M,{type:"system",content:w,timestamp:new Date().toISOString()}]);break}case"token-budget":t.data&&m(t.data);break;case"claude-response":{if(C&&typeof C=="object"&&C.type){if(C.type==="content_block_delta"&&((_=C.delta)!=null&&_.text)){const w=St(C.delta.text);f.current+=w,x.current||(x.current=window.setTimeout(()=>{const M=f.current;f.current="",x.current=null,Jr(i,M,!1)},100));return}if(C.type==="content_block_stop"){x.current&&(clearTimeout(x.current),x.current=null);const w=f.current;f.current="",Jr(i,w,!1),wu(i);return}}if((v==null?void 0:v.type)==="system"&&v.subtype==="init"&&v.session_id&&n&&v.session_id!==n&&z){h(!0),k==null||k(v.session_id);return}if((v==null?void 0:v.type)==="system"&&v.subtype==="init"&&v.session_id&&!n&&z){h(!0),k==null||k(v.session_id);return}if((v==null?void 0:v.type)==="system"&&v.subtype==="init"&&v.session_id&&n&&v.session_id===n&&z)return;if(v&&Array.isArray(v.content)){const w=E==null?void 0:E.parentToolUseId;v.content.forEach(M=>{var Y;if(M.type==="tool_use"){const se=M.input?JSON.stringify(M.input,null,2):"";if(w){i(je=>je.map(ge=>{var Re;if(ge.toolId===w&&ge.isSubagentContainer){const Ne={toolId:M.id,toolName:M.name,toolInput:M.input,toolResult:null,timestamp:new Date},De=((Re=ge.subagentState)==null?void 0:Re.childTools)||[];return{...ge,subagentState:{childTools:[...De,Ne],currentToolIndex:De.length,isComplete:!1}}}return ge}));return}const de=M.name==="Task";i(je=>[...je,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:M.name,toolInput:se,toolId:M.id,toolResult:null,isSubagentContainer:de,subagentState:de?{childTools:[],currentToolIndex:-1,isComplete:!1}:void 0}]);return}if(M.type==="text"&&((Y=M.text)!=null&&Y.trim())){let se=St(M.text);se=ea(se),i(de=>[...de,{type:"assistant",content:se,timestamp:new Date}])}})}else if(v&&typeof v.content=="string"&&v.content.trim()){let w=St(v.content);w=ea(w),i(M=>[...M,{type:"assistant",content:w,timestamp:new Date}])}if((v==null?void 0:v.role)==="user"&&Array.isArray(v.content)){const w=E==null?void 0:E.parentToolUseId;v.content.forEach(M=>{M.type==="tool_result"&&i(Y=>Y.map(se=>{if(w&&se.toolId===w&&se.isSubagentContainer)return{...se,subagentState:{...se.subagentState,childTools:se.subagentState.childTools.map(de=>de.toolId===M.tool_use_id?{...de,toolResult:{content:M.content,isError:M.is_error,timestamp:new Date}}:de)}};if(se.isToolUse&&se.toolId===M.tool_use_id){const de={...se,toolResult:{content:M.content,isError:M.is_error,timestamp:new Date}};return se.isSubagentContainer&&se.subagentState&&(de.subagentState={...se.subagentState,isComplete:!0}),de}return se}))})}break}case"claude-output":{const w=String(t.data||"");w.trim()&&(f.current+=f.current?`
140
140
  ${w}`:w,x.current||(x.current=window.setTimeout(()=>{const M=f.current;f.current="",x.current=null,Jr(i,M,!0)},100)));break}case"claude-interactive-prompt":{const w=typeof t.data=="string"?t.data:JSON.stringify(t.data??"",null,2);i(M=>[...M,{type:"assistant",content:w,timestamp:new Date,isInteractivePrompt:!0}])}break;case"claude-permission-request":if(r!=="claude"||!t.requestId)break;{const w=t.requestId;p(M=>M.some(Y=>Y.requestId===w)?M:[...M,{requestId:w,toolName:t.toolName||"UnknownTool",input:t.input,context:t.context,sessionId:t.sessionId||null,receivedAt:new Date}])}c(!0),u(!0),d({text:"Waiting for permission",tokens:0,can_interrupt:!0});break;case"claude-permission-cancelled":if(!t.requestId)break;p(w=>w.filter(M=>M.requestId!==t.requestId));break;case"claude-error":i(w=>[...w,{type:"error",content:`Error: ${t.error}`,timestamp:new Date}]);break;case"cursor-system":try{const w=t.data;if(w&&w.type==="system"&&w.subtype==="init"&&w.session_id){if(!z)return;if(n&&w.session_id!==n){h(!0),k==null||k(w.session_id);return}if(!n){h(!0),k==null||k(w.session_id);return}}}catch{}break;case"cursor-user":break;case"cursor-tool-use":i(w=>[...w,{type:"assistant",content:`Using tool: ${t.tool} ${t.input?`with ${t.input}`:""}`,timestamp:new Date,isToolUse:!0,toolName:t.tool,toolInput:t.input}]);break;case"cursor-error":i(w=>[...w,{type:"error",content:`Cursor error: ${t.error||"Unknown error"}`,timestamp:new Date}]);break;case"cursor-result":{const w=t.sessionId||n,M=sessionStorage.getItem("pendingSessionId");$(),Z(w,n,a==null?void 0:a.id,M);try{const Y=t.data||{},se=typeof Y.result=="string"?Y.result:"";x.current&&(clearTimeout(x.current),x.current=null);const de=f.current;f.current="",i(je=>{const ge=[...je],Re=ge.length-1,Ne=ge[Re];if(Ne&&Ne.type==="assistant"&&!Ne.isToolUse&&Ne.isStreaming){const De=se&&se.trim()?se:`${Ne.content||""}${de||""}`;ge[Re]={...Ne,content:De,isStreaming:!1}}else se&&se.trim()&&ge.push({type:Y.is_error?"error":"assistant",content:se,timestamp:new Date,isStreaming:!1});return ge})}catch{}w&&!n&&w===M&&(o(w),sessionStorage.removeItem("pendingSessionId"),window.refreshProjects&&setTimeout(()=>{var Y;return(Y=window.refreshProjects)==null?void 0:Y.call(window)},500));break}case"cursor-output":try{const M=String(t.data??"").replace(/\x1b\[[0-9;?]*[A-Za-z]/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"").trim();M&&(f.current+=f.current?`
141
141
  ${M}`:M,x.current||(x.current=window.setTimeout(()=>{const Y=f.current;f.current="",x.current=null,Jr(i,Y,!0)},100)))}catch{}break;case"claude-complete":{const w=sessionStorage.getItem("pendingSessionId"),M=t.sessionId||n||w;$(),Z(M,n,a==null?void 0:a.id,w),w&&!n&&t.exitCode===0&&(o(w),sessionStorage.removeItem("pendingSessionId")),s&&t.exitCode===0&&ot.removeItem(`chat_messages_${s.name}`),p([]),I&&i(Y=>{for(let se=Y.length-1;se>=0;se--)if(Y[se].type==="assistant"&&Y[se].content&&!Y[se].isToolUse){I(Y[se].content||"");break}return Y});break}case"codex-response":{const w=t.data;if(!w)break;if(w.type==="item")switch(w.itemType){case"agent_message":if((q=(F=w.message)==null?void 0:F.content)!=null&&q.trim()){const M=St(w.message.content);Tr(M)||i(Y=>[...Y,{type:"assistant",content:M,timestamp:new Date}])}break;case"reasoning":if((B=(U=w.message)==null?void 0:U.content)!=null&&B.trim()){const M=St(w.message.content);i(Y=>[...Y,{type:"assistant",content:M,timestamp:new Date,isThinking:!0}])}break;case"command_execution":w.command&&i(M=>[...M,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:w.command,toolResult:w.output||null,exitCode:w.exitCode}]);break;case"file_change":if(((ee=w.changes)==null?void 0:ee.length)>0){const M=w.changes.map(Y=>`${Y.kind}: ${Y.path}`).join(`
142
142
  `);i(Y=>[...Y,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:M,toolResult:{content:`Status: ${w.status}`,isError:!1}}])}break;case"mcp_tool_call":i(M=>{var Y;return[...M,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${w.server}:${w.tool}`,toolInput:JSON.stringify(w.arguments,null,2),toolResult:w.result?JSON.stringify(w.result,null,2):((Y=w.error)==null?void 0:Y.message)||null}]});break;case"error":(V=w.message)!=null&&V.content&&i(M=>[...M,{type:"error",content:w.message.content,timestamp:new Date}]);break}w.type==="turn_complete"&&($(),Z(t.sessionId,n,a==null?void 0:a.id)),w.type==="turn_failed"&&($(),Z(t.sessionId,n,a==null?void 0:a.id),i(M=>{var Y;return[...M,{type:"error",content:((Y=w.error)==null?void 0:Y.message)||"Turn failed",timestamp:new Date}]}));break}case"codex-complete":{const w=sessionStorage.getItem("pendingSessionId"),M=t.actualSessionId||w,Y=t.sessionId||n||w;$(),Z(Y,M,n,a==null?void 0:a.id,w),w&&!n&&(o(M),h(!0),M&&(k==null||k(M)),sessionStorage.removeItem("pendingSessionId")),s&&ot.removeItem(`chat_messages_${s.name}`);break}case"codex-error":c(!1),u(!1),i(w=>[...w,{type:"error",content:t.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{const w=typeof window<"u"?sessionStorage.getItem("pendingSessionId"):null,M=t.sessionId||n;t.success!==!1?($(),Z(M,n,a==null?void 0:a.id,w),w&&(!M||w===M)&&sessionStorage.removeItem("pendingSessionId"),p([]),i(se=>[...se,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}])):i(se=>[...se,{type:"error",content:"Stop request failed. The session is still running.",timestamp:new Date}]);break}case"session-status":{const w=t.sessionId;(w===n||a&&w===a.id)&&t.isProcessing&&(c(!0),u(!0),N==null||N(w));break}case"claude-status":{const w=t.data;if(!w)break;const M={text:"Working...",tokens:0,can_interrupt:!0};w.message?M.text=w.message:w.status?M.text=w.status:typeof w=="string"&&(M.text=w),w.tokens?M.tokens=w.tokens:w.token_count&&(M.tokens=w.token_count),w.can_interrupt!==void 0&&(M.can_interrupt=w.can_interrupt),d(M),c(!0),u(M.can_interrupt);break}case"shell-exec-output":{c(!1),u(!1),d(null);const w=t.output||"(no output)",M=t.exitCode,se=t.status==="error"||M&&M!==0;i(de=>[...de,{type:se?"error":"assistant",content:"```\n"+w+"\n```"+(M?`
143
143
 
144
- Exit code: ${M}`:""),timestamp:new Date}]);break}}},[t,r,s,a,n,o,i,c,u,d,m,h,p,b,N,j,y,k])}var Rs={exports:{}},Os,un;function ju(){if(un)return Os;un=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Os=t,Os}var Bs,mn;function Nu(){if(mn)return Bs;mn=1;var t=ju();function r(){}function s(){}return s.resetWarningCache=r,Bs=function(){function a(i,c,u,d,m,h){if(h!==t){var p=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw p.name="Invariant Violation",p}}a.isRequired=a;function n(){return a}var o={array:a,bigint:a,bool:a,func:a,number:a,object:a,string:a,symbol:a,any:a,arrayOf:n,element:a,elementType:a,instanceOf:n,node:a,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:s,resetWarningCache:r};return o.PropTypes=o,o},Bs}var pn;function Cu(){return pn||(pn=1,Rs.exports=Nu()()),Rs.exports}var Su=Cu();const qe=Jn(Su);function nr(t,r,s,a){function n(o){return o instanceof s?o:new s(function(i){i(o)})}return new(s||(s=Promise))(function(o,i){function c(m){try{d(a.next(m))}catch(h){i(h)}}function u(m){try{d(a.throw(m))}catch(h){i(h)}}function d(m){m.done?o(m.value):n(m.value).then(c,u)}d((a=a.apply(t,r||[])).next())})}const Eu=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function xr(t,r,s){const a=Tu(t),{webkitRelativePath:n}=t,o=typeof r=="string"?r:typeof n=="string"&&n.length>0?n:`./${t.name}`;return typeof a.path!="string"&&xn(a,"path",o),xn(a,"relativePath",o),a}function Tu(t){const{name:r}=t;if(r&&r.lastIndexOf(".")!==-1&&!t.type){const a=r.split(".").pop().toLowerCase(),n=Eu.get(a);n&&Object.defineProperty(t,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return t}function xn(t,r,s){Object.defineProperty(t,r,{value:s,writable:!1,configurable:!1,enumerable:!0})}const Au=[".DS_Store","Thumbs.db"];function Iu(t){return nr(this,void 0,void 0,function*(){return is(t)&&Mu(t.dataTransfer)?$u(t.dataTransfer,t.type):Du(t)?Lu(t):Array.isArray(t)&&t.every(r=>"getFile"in r&&typeof r.getFile=="function")?Pu(t):[]})}function Mu(t){return is(t)}function Du(t){return is(t)&&is(t.target)}function is(t){return typeof t=="object"&&t!==null}function Lu(t){return ra(t.target.files).map(r=>xr(r))}function Pu(t){return nr(this,void 0,void 0,function*(){return(yield Promise.all(t.map(s=>s.getFile()))).map(s=>xr(s))})}function $u(t,r){return nr(this,void 0,void 0,function*(){if(t.items){const s=ra(t.items).filter(n=>n.kind==="file");if(r!=="drop")return s;const a=yield Promise.all(s.map(_u));return gn(Vo(a))}return gn(ra(t.files).map(s=>xr(s)))})}function gn(t){return t.filter(r=>Au.indexOf(r.name)===-1)}function ra(t){if(t===null)return[];const r=[];for(let s=0;s<t.length;s++){const a=t[s];r.push(a)}return r}function _u(t){if(typeof t.webkitGetAsEntry!="function")return hn(t);const r=t.webkitGetAsEntry();return r&&r.isDirectory?qo(r):hn(t,r)}function Vo(t){return t.reduce((r,s)=>[...r,...Array.isArray(s)?Vo(s):[s]],[])}function hn(t,r){return nr(this,void 0,void 0,function*(){var s;if(globalThis.isSecureContext&&typeof t.getAsFileSystemHandle=="function"){const o=yield t.getAsFileSystemHandle();if(o===null)throw new Error(`${t} is not a File`);if(o!==void 0){const i=yield o.getFile();return i.handle=o,xr(i)}}const a=t.getAsFile();if(!a)throw new Error(`${t} is not a File`);return xr(a,(s=r==null?void 0:r.fullPath)!==null&&s!==void 0?s:void 0)})}function Fu(t){return nr(this,void 0,void 0,function*(){return t.isDirectory?qo(t):zu(t)})}function qo(t){const r=t.createReader();return new Promise((s,a)=>{const n=[];function o(){r.readEntries(i=>nr(this,void 0,void 0,function*(){if(i.length){const c=Promise.all(i.map(Fu));n.push(c),o()}else try{const c=yield Promise.all(n);s(c)}catch(c){a(c)}}),i=>{a(i)})}o()})}function zu(t){return nr(this,void 0,void 0,function*(){return new Promise((r,s)=>{t.file(a=>{const n=xr(a,t.fullPath);r(n)},a=>{s(a)})})})}var Yr={},fn;function Ru(){return fn||(fn=1,Yr.__esModule=!0,Yr.default=function(t,r){if(t&&r){var s=Array.isArray(r)?r:r.split(",");if(s.length===0)return!0;var a=t.name||"",n=(t.type||"").toLowerCase(),o=n.replace(/\/.*$/,"");return s.some(function(i){var c=i.trim().toLowerCase();return c.charAt(0)==="."?a.toLowerCase().endsWith(c):c.endsWith("/*")?o===c.replace(/\/.*$/,""):n===c})}return!0}),Yr}var Ou=Ru();const Ws=Jn(Ou);function bn(t){return Uu(t)||Wu(t)||Jo(t)||Bu()}function Bu(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
145
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Wu(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Uu(t){if(Array.isArray(t))return sa(t)}function yn(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,a)}return s}function vn(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?yn(Object(s),!0).forEach(function(a){Ko(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):yn(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function Ko(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function Dr(t,r){return Vu(t)||Gu(t,r)||Jo(t,r)||Hu()}function Hu(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
146
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jo(t,r){if(t){if(typeof t=="string")return sa(t,r);var s=Object.prototype.toString.call(t).slice(8,-1);if(s==="Object"&&t.constructor&&(s=t.constructor.name),s==="Map"||s==="Set")return Array.from(t);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return sa(t,r)}}function sa(t,r){(r==null||r>t.length)&&(r=t.length);for(var s=0,a=new Array(r);s<r;s++)a[s]=t[s];return a}function Gu(t,r){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var a=[],n=!0,o=!1,i,c;try{for(s=s.call(t);!(n=(i=s.next()).done)&&(a.push(i.value),!(r&&a.length===r));n=!0);}catch(u){o=!0,c=u}finally{try{!n&&s.return!=null&&s.return()}finally{if(o)throw c}}return a}}function Vu(t){if(Array.isArray(t))return t}var qu=typeof Ws=="function"?Ws:Ws.default,Ku="file-invalid-type",Ju="file-too-large",Yu="file-too-small",Qu="too-many-files",Xu=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",s=r.split(","),a=s.length>1?"one of ".concat(s.join(", ")):s[0];return{code:Ku,message:"File type must be ".concat(a)}},kn=function(r){return{code:Ju,message:"File is larger than ".concat(r," ").concat(r===1?"byte":"bytes")}},wn=function(r){return{code:Yu,message:"File is smaller than ".concat(r," ").concat(r===1?"byte":"bytes")}},Zu={code:Qu,message:"Too many files"};function em(t){return t.type===""&&typeof t.getAsFile=="function"}function Yo(t,r){var s=t.type==="application/x-moz-file"||qu(t,r)||em(t);return[s,s?null:Xu(r)]}function Qo(t,r,s){if(Xt(t.size))if(Xt(r)&&Xt(s)){if(t.size>s)return[!1,kn(s)];if(t.size<r)return[!1,wn(r)]}else{if(Xt(r)&&t.size<r)return[!1,wn(r)];if(Xt(s)&&t.size>s)return[!1,kn(s)]}return[!0,null]}function Xt(t){return t!=null}function tm(t){var r=t.files,s=t.accept,a=t.minSize,n=t.maxSize,o=t.multiple,i=t.maxFiles,c=t.validator;return!o&&r.length>1||o&&i>=1&&r.length>i?!1:r.every(function(u){var d=Yo(u,s),m=Dr(d,1),h=m[0],p=Qo(u,a,n),g=Dr(p,1),f=g[0],x=c?c(u):null;return h&&f&&!x})}function ls(t){return typeof t.isPropagationStopped=="function"?t.isPropagationStopped():typeof t.cancelBubble<"u"?t.cancelBubble:!1}function wr(t){return t.dataTransfer?Array.prototype.some.call(t.dataTransfer.types,function(r){return r==="Files"||r==="application/x-moz-file"}):!!t.target&&!!t.target.files}function jn(t){t.preventDefault()}function rm(t){return t.indexOf("MSIE")!==-1||t.indexOf("Trident/")!==-1}function sm(t){return t.indexOf("Edge/")!==-1}function am(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return rm(t)||sm(t)}function Nt(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return function(a){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return r.some(function(c){return!ls(a)&&c&&c.apply(void 0,[a].concat(o)),ls(a)})}}function nm(){return"showOpenFilePicker"in window}function om(t){if(Xt(t)){var r=Object.entries(t).filter(function(s){var a=Dr(s,2),n=a[0],o=a[1],i=!0;return Xo(n)||(console.warn('Skipped "'.concat(n,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),(!Array.isArray(o)||!o.every(Zo))&&(console.warn('Skipped "'.concat(n,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(s,a){var n=Dr(a,2),o=n[0],i=n[1];return vn(vn({},s),{},Ko({},o,i))},{});return[{description:"Files",accept:r}]}return t}function im(t){if(Xt(t))return Object.entries(t).reduce(function(r,s){var a=Dr(s,2),n=a[0],o=a[1];return[].concat(bn(r),[n],bn(o))},[]).filter(function(r){return Xo(r)||Zo(r)}).join(",")}function lm(t){return t instanceof DOMException&&(t.name==="AbortError"||t.code===t.ABORT_ERR)}function cm(t){return t instanceof DOMException&&(t.name==="SecurityError"||t.code===t.SECURITY_ERR)}function Xo(t){return t==="audio/*"||t==="video/*"||t==="image/*"||t==="text/*"||t==="application/*"||/\w+\/[-+.\w]+/g.test(t)}function Zo(t){return/^.*\.[\w]+$/.test(t)}var dm=["children"],um=["open"],mm=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],pm=["refKey","onChange","onClick"];function Nn(t){return hm(t)||gm(t)||ei(t)||xm()}function xm(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
147
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gm(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function hm(t){if(Array.isArray(t))return aa(t)}function Us(t,r){return ym(t)||bm(t,r)||ei(t,r)||fm()}function fm(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
148
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ei(t,r){if(t){if(typeof t=="string")return aa(t,r);var s=Object.prototype.toString.call(t).slice(8,-1);if(s==="Object"&&t.constructor&&(s=t.constructor.name),s==="Map"||s==="Set")return Array.from(t);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return aa(t,r)}}function aa(t,r){(r==null||r>t.length)&&(r=t.length);for(var s=0,a=new Array(r);s<r;s++)a[s]=t[s];return a}function bm(t,r){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var a=[],n=!0,o=!1,i,c;try{for(s=s.call(t);!(n=(i=s.next()).done)&&(a.push(i.value),!(r&&a.length===r));n=!0);}catch(u){o=!0,c=u}finally{try{!n&&s.return!=null&&s.return()}finally{if(o)throw c}}return a}}function ym(t){if(Array.isArray(t))return t}function Cn(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,a)}return s}function Je(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?Cn(Object(s),!0).forEach(function(a){na(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Cn(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function na(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function cs(t,r){if(t==null)return{};var s=vm(t,r),a,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)a=o[n],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(s[a]=t[a])}return s}function vm(t,r){if(t==null)return{};var s={},a=Object.keys(t),n,o;for(o=0;o<a.length;o++)n=a[o],!(r.indexOf(n)>=0)&&(s[n]=t[n]);return s}var Ma=l.forwardRef(function(t,r){var s=t.children,a=cs(t,dm),n=ri(a),o=n.open,i=cs(n,um);return l.useImperativeHandle(r,function(){return{open:o}},[o]),it.createElement(l.Fragment,null,s(Je(Je({},i),{},{open:o})))});Ma.displayName="Dropzone";var ti={disabled:!1,getFilesFromEvent:Iu,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};Ma.defaultProps=ti;Ma.propTypes={children:qe.func,accept:qe.objectOf(qe.arrayOf(qe.string)),multiple:qe.bool,preventDropOnDocument:qe.bool,noClick:qe.bool,noKeyboard:qe.bool,noDrag:qe.bool,noDragEventsBubbling:qe.bool,minSize:qe.number,maxSize:qe.number,maxFiles:qe.number,disabled:qe.bool,getFilesFromEvent:qe.func,onFileDialogCancel:qe.func,onFileDialogOpen:qe.func,useFsAccessApi:qe.bool,autoFocus:qe.bool,onDragEnter:qe.func,onDragLeave:qe.func,onDragOver:qe.func,onDrop:qe.func,onDropAccepted:qe.func,onDropRejected:qe.func,onError:qe.func,validator:qe.func};var oa={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function ri(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=Je(Je({},ti),t),s=r.accept,a=r.disabled,n=r.getFilesFromEvent,o=r.maxSize,i=r.minSize,c=r.multiple,u=r.maxFiles,d=r.onDragEnter,m=r.onDragLeave,h=r.onDragOver,p=r.onDrop,g=r.onDropAccepted,f=r.onDropRejected,x=r.onFileDialogCancel,b=r.onFileDialogOpen,N=r.useFsAccessApi,j=r.autoFocus,y=r.preventDropOnDocument,k=r.noClick,I=r.noKeyboard,D=r.noDrag,C=r.noDragEventsBubbling,v=r.onError,E=r.validator,T=l.useMemo(function(){return im(s)},[s]),W=l.useMemo(function(){return om(s)},[s]),S=l.useMemo(function(){return typeof b=="function"?b:Sn},[b]),O=l.useMemo(function(){return typeof x=="function"?x:Sn},[x]),H=l.useRef(null),R=l.useRef(null),A=l.useReducer(km,oa),z=Us(A,2),J=z[0],re=z[1],G=J.isFocused,ie=J.isFileDialogActive,$=l.useRef(typeof window<"u"&&window.isSecureContext&&N&&nm()),Z=function(){!$.current&&ie&&setTimeout(function(){if(R.current){var K=R.current.files;K.length||(re({type:"closeDialog"}),O())}},300)};l.useEffect(function(){return window.addEventListener("focus",Z,!1),function(){window.removeEventListener("focus",Z,!1)}},[R,ie,O,$]);var te=l.useRef([]),Q=l.useRef([]),_=function(K){H.current&&H.current.contains(K.target)||(K.preventDefault(),te.current=[])};l.useEffect(function(){return y&&(document.addEventListener("dragover",jn,!1),document.addEventListener("drop",_,!1)),function(){y&&(document.removeEventListener("dragover",jn),document.removeEventListener("drop",_))}},[H,y]),l.useEffect(function(){var L=function(Fe){Q.current=[].concat(Nn(Q.current),[Fe.target]),wr(Fe)&&re({isDragGlobal:!0,type:"setDragGlobal"})},K=function(Fe){Q.current=Q.current.filter(function(Se){return Se!==Fe.target&&Se!==null}),!(Q.current.length>0)&&re({isDragGlobal:!1,type:"setDragGlobal"})},pe=function(){Q.current=[],re({isDragGlobal:!1,type:"setDragGlobal"})},ye=function(){Q.current=[],re({isDragGlobal:!1,type:"setDragGlobal"})};return document.addEventListener("dragenter",L,!1),document.addEventListener("dragleave",K,!1),document.addEventListener("dragend",pe,!1),document.addEventListener("drop",ye,!1),function(){document.removeEventListener("dragenter",L),document.removeEventListener("dragleave",K),document.removeEventListener("dragend",pe),document.removeEventListener("drop",ye)}},[H]),l.useEffect(function(){return!a&&j&&H.current&&H.current.focus(),function(){}},[H,j,a]);var F=l.useCallback(function(L){v?v(L):console.error(L)},[v]),q=l.useCallback(function(L){L.preventDefault(),L.persist(),Ne(L),te.current=[].concat(Nn(te.current),[L.target]),wr(L)&&Promise.resolve(n(L)).then(function(K){if(!(ls(L)&&!C)){var pe=K.length,ye=pe>0&&tm({files:K,accept:T,minSize:i,maxSize:o,multiple:c,maxFiles:u,validator:E}),Ie=pe>0&&!ye;re({isDragAccept:ye,isDragReject:Ie,isDragActive:!0,type:"setDraggedFiles"}),d&&d(L)}}).catch(function(K){return F(K)})},[n,d,F,C,T,i,o,c,u,E]),U=l.useCallback(function(L){L.preventDefault(),L.persist(),Ne(L);var K=wr(L);if(K&&L.dataTransfer)try{L.dataTransfer.dropEffect="copy"}catch{}return K&&h&&h(L),!1},[h,C]),B=l.useCallback(function(L){L.preventDefault(),L.persist(),Ne(L);var K=te.current.filter(function(ye){return H.current&&H.current.contains(ye)}),pe=K.indexOf(L.target);pe!==-1&&K.splice(pe,1),te.current=K,!(K.length>0)&&(re({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),wr(L)&&m&&m(L))},[H,m,C]),ee=l.useCallback(function(L,K){var pe=[],ye=[];L.forEach(function(Ie){var Fe=Yo(Ie,T),Se=Us(Fe,2),Oe=Se[0],ne=Se[1],fe=Qo(Ie,i,o),Ee=Us(fe,2),Le=Ee[0],Pe=Ee[1],Ae=E?E(Ie):null;if(Oe&&Le&&!Ae)pe.push(Ie);else{var Ge=[ne,Pe];Ae&&(Ge=Ge.concat(Ae)),ye.push({file:Ie,errors:Ge.filter(function(ae){return ae})})}}),(!c&&pe.length>1||c&&u>=1&&pe.length>u)&&(pe.forEach(function(Ie){ye.push({file:Ie,errors:[Zu]})}),pe.splice(0)),re({acceptedFiles:pe,fileRejections:ye,isDragReject:ye.length>0,type:"setFiles"}),p&&p(pe,ye,K),ye.length>0&&f&&f(ye,K),pe.length>0&&g&&g(pe,K)},[re,c,T,i,o,u,p,g,f,E]),V=l.useCallback(function(L){L.preventDefault(),L.persist(),Ne(L),te.current=[],wr(L)&&Promise.resolve(n(L)).then(function(K){ls(L)&&!C||ee(K,L)}).catch(function(K){return F(K)}),re({type:"reset"})},[n,ee,F,C]),w=l.useCallback(function(){if($.current){re({type:"openDialog"}),S();var L={multiple:c,types:W};window.showOpenFilePicker(L).then(function(K){return n(K)}).then(function(K){ee(K,null),re({type:"closeDialog"})}).catch(function(K){lm(K)?(O(K),re({type:"closeDialog"})):cm(K)?($.current=!1,R.current?(R.current.value=null,R.current.click()):F(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):F(K)});return}R.current&&(re({type:"openDialog"}),S(),R.current.value=null,R.current.click())},[re,S,O,N,ee,F,W,c]),M=l.useCallback(function(L){!H.current||!H.current.isEqualNode(L.target)||(L.key===" "||L.key==="Enter"||L.keyCode===32||L.keyCode===13)&&(L.preventDefault(),w())},[H,w]),Y=l.useCallback(function(){re({type:"focus"})},[]),se=l.useCallback(function(){re({type:"blur"})},[]),de=l.useCallback(function(){k||(am()?setTimeout(w,0):w())},[k,w]),je=function(K){return a?null:K},ge=function(K){return I?null:je(K)},Re=function(K){return D?null:je(K)},Ne=function(K){C&&K.stopPropagation()},De=l.useMemo(function(){return function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},K=L.refKey,pe=K===void 0?"ref":K,ye=L.role,Ie=L.onKeyDown,Fe=L.onFocus,Se=L.onBlur,Oe=L.onClick,ne=L.onDragEnter,fe=L.onDragOver,Ee=L.onDragLeave,Le=L.onDrop,Pe=cs(L,mm);return Je(Je(na({onKeyDown:ge(Nt(Ie,M)),onFocus:ge(Nt(Fe,Y)),onBlur:ge(Nt(Se,se)),onClick:je(Nt(Oe,de)),onDragEnter:Re(Nt(ne,q)),onDragOver:Re(Nt(fe,U)),onDragLeave:Re(Nt(Ee,B)),onDrop:Re(Nt(Le,V)),role:typeof ye=="string"&&ye!==""?ye:"presentation"},pe,H),!a&&!I?{tabIndex:0}:{}),Pe)}},[H,M,Y,se,de,q,U,B,V,I,D,a]),Ue=l.useCallback(function(L){L.stopPropagation()},[]),_e=l.useMemo(function(){return function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},K=L.refKey,pe=K===void 0?"ref":K,ye=L.onChange,Ie=L.onClick,Fe=cs(L,pm),Se=na({accept:T,multiple:c,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:je(Nt(ye,V)),onClick:je(Nt(Ie,Ue)),tabIndex:-1},pe,R);return Je(Je({},Se),Fe)}},[R,s,c,V,a]);return Je(Je({},J),{},{isFocused:G&&!a,getRootProps:De,getInputProps:_e,rootRef:H,inputRef:R,open:je(w)})}function km(t,r){switch(r.type){case"focus":return Je(Je({},t),{},{isFocused:!0});case"blur":return Je(Je({},t),{},{isFocused:!1});case"openDialog":return Je(Je({},oa),{},{isFileDialogActive:!0});case"closeDialog":return Je(Je({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return Je(Je({},t),{},{isDragActive:r.isDragActive,isDragAccept:r.isDragAccept,isDragReject:r.isDragReject});case"setFiles":return Je(Je({},t),{},{acceptedFiles:r.acceptedFiles,fileRejections:r.fileRejections,isDragReject:r.isDragReject});case"setDragGlobal":return Je(Je({},t),{},{isDragGlobal:r.isDragGlobal});case"reset":return Je({},oa);default:return t}}function Sn(){}const si=(t,r="")=>{let s=[];return t.forEach(a=>{const n=r?`${r}/${a.name}`:a.name;if(a.type==="directory"&&a.children){s=s.concat(si(a.children,n));return}a.type==="file"&&s.push({name:a.name,path:n,relativePath:a.path})}),s};function wm({selectedProject:t,input:r,setInput:s,textareaRef:a}){const[n,o]=l.useState([]),[i,c]=l.useState([]),[u,d]=l.useState([]),[m,h]=l.useState(!1),[p,g]=l.useState(-1),[f,x]=l.useState(0),[b,N]=l.useState(-1);l.useEffect(()=>{const E=new AbortController;return(async()=>{const W=t==null?void 0:t.name;if(o([]),d([]),!!W)try{const S=await Be.getFiles(W,{signal:E.signal});if(!S.ok)return;const O=await S.json();o(si(O))}catch(S){if((S==null?void 0:S.name)==="AbortError")return;console.error("Error fetching files:",S)}})(),()=>{E.abort()}},[t==null?void 0:t.name]),l.useEffect(()=>{const E=r.slice(0,f),T=E.lastIndexOf("@");if(T===-1){h(!1),N(-1);return}const W=E.slice(T+1);if(W.includes(" ")){h(!1),N(-1);return}N(T),h(!0),g(-1);const S=n.filter(O=>O.name.toLowerCase().includes(W.toLowerCase())||O.path.toLowerCase().includes(W.toLowerCase())).slice(0,10);d(S)},[r,f,n]);const j=l.useMemo(()=>!r||i.length===0?[]:i.filter(E=>r.includes(E)),[i,r]),y=l.useMemo(()=>j.length===0?[]:Array.from(new Set(j)).sort((T,W)=>W.length-T.length),[j]),k=l.useMemo(()=>{if(y.length===0)return null;const E=y.map(Fo).join("|");return new RegExp(`(${E})`,"g")},[y]),I=l.useMemo(()=>new Set(y),[y]),D=l.useCallback(E=>E?k?E.split(k).map((W,S)=>I.has(W)?e.jsx("span",{className:"bg-blue-200/70 -ml-0.5 dark:bg-blue-300/40 px-0.5 rounded-md box-decoration-clone text-transparent",children:W},`mention-${S}`):e.jsx("span",{children:W},`text-${S}`)):E:"",[k,I]),C=l.useCallback(E=>{const T=r.slice(0,b),W=r.slice(b),S=W.indexOf(" "),O=S!==-1?W.slice(S):"",H=`${T}${E.path} ${O}`,R=T.length+E.path.length+1;a.current&&!a.current.matches(":focus")&&a.current.focus(),s(H),x(R),c(A=>A.includes(E.path)?A:[...A,E.path]),h(!1),N(-1),a.current&&requestAnimationFrame(()=>{a.current&&(a.current.setSelectionRange(R,R),a.current.matches(":focus")||a.current.focus())})},[r,b,a,s]),v=l.useCallback(E=>!m||u.length===0?!1:E.key==="ArrowDown"?(E.preventDefault(),g(T=>T<u.length-1?T+1:0),!0):E.key==="ArrowUp"?(E.preventDefault(),g(T=>T>0?T-1:u.length-1),!0):E.key==="Tab"||E.key==="Enter"?(E.preventDefault(),p>=0?C(u[p]):u.length>0&&C(u[0]),!0):E.key==="Escape"?(E.preventDefault(),h(!1),!0):!1,[m,u,p,C]);return{showFileDropdown:m,filteredFiles:u,selectedFileIndex:p,renderInputWithMentions:D,selectFile:C,setCursorPosition:x,handleFileMentionsKeyDown:v}}function _t(t){return Array.isArray?Array.isArray(t):oi(t)==="[object Array]"}function jm(t){if(typeof t=="string")return t;let r=t+"";return r=="0"&&1/t==-1/0?"-0":r}function Nm(t){return t==null?"":jm(t)}function Et(t){return typeof t=="string"}function ai(t){return typeof t=="number"}function Cm(t){return t===!0||t===!1||Sm(t)&&oi(t)=="[object Boolean]"}function ni(t){return typeof t=="object"}function Sm(t){return ni(t)&&t!==null}function xt(t){return t!=null}function Hs(t){return!t.trim().length}function oi(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Em="Incorrect 'index' type",Tm=t=>`Invalid value for key ${t}`,Am=t=>`Pattern length exceeds max of ${t}.`,Im=t=>`Missing ${t} property in key`,Mm=t=>`Property 'weight' in key '${t}' must be a positive integer`,En=Object.prototype.hasOwnProperty;class Dm{constructor(r){this._keys=[],this._keyMap={};let s=0;r.forEach(a=>{let n=ii(a);this._keys.push(n),this._keyMap[n.id]=n,s+=n.weight}),this._keys.forEach(a=>{a.weight/=s})}get(r){return this._keyMap[r]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function ii(t){let r=null,s=null,a=null,n=1,o=null;if(Et(t)||_t(t))a=t,r=Tn(t),s=ia(t);else{if(!En.call(t,"name"))throw new Error(Im("name"));const i=t.name;if(a=i,En.call(t,"weight")&&(n=t.weight,n<=0))throw new Error(Mm(i));r=Tn(i),s=ia(i),o=t.getFn}return{path:r,id:s,weight:n,src:a,getFn:o}}function Tn(t){return _t(t)?t:t.split(".")}function ia(t){return _t(t)?t.join("."):t}function Lm(t,r){let s=[],a=!1;const n=(o,i,c)=>{if(xt(o))if(!i[c])s.push(o);else{let u=i[c];const d=o[u];if(!xt(d))return;if(c===i.length-1&&(Et(d)||ai(d)||Cm(d)))s.push(Nm(d));else if(_t(d)){a=!0;for(let m=0,h=d.length;m<h;m+=1)n(d[m],i,c+1)}else i.length&&n(d,i,c+1)}};return n(t,Et(r)?r.split("."):r,0),a?s:s[0]}const Pm={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},$m={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,r)=>t.score===r.score?t.idx<r.idx?-1:1:t.score<r.score?-1:1},_m={location:0,threshold:.6,distance:100},Fm={useExtendedSearch:!1,getFn:Lm,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Te={...$m,...Pm,..._m,...Fm};const zm=/[^ ]+/g;function Rm(t=1,r=3){const s=new Map,a=Math.pow(10,r);return{get(n){const o=n.match(zm).length;if(s.has(o))return s.get(o);const i=1/Math.pow(o,.5*t),c=parseFloat(Math.round(i*a)/a);return s.set(o,c),c},clear(){s.clear()}}}class Da{constructor({getFn:r=Te.getFn,fieldNormWeight:s=Te.fieldNormWeight}={}){this.norm=Rm(s,3),this.getFn=r,this.isCreated=!1,this.setIndexRecords()}setSources(r=[]){this.docs=r}setIndexRecords(r=[]){this.records=r}setKeys(r=[]){this.keys=r,this._keysMap={},r.forEach((s,a)=>{this._keysMap[s.id]=a})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Et(this.docs[0])?this.docs.forEach((r,s)=>{this._addString(r,s)}):this.docs.forEach((r,s)=>{this._addObject(r,s)}),this.norm.clear())}add(r){const s=this.size();Et(r)?this._addString(r,s):this._addObject(r,s)}removeAt(r){this.records.splice(r,1);for(let s=r,a=this.size();s<a;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(r,s){return r[this._keysMap[s]]}size(){return this.records.length}_addString(r,s){if(!xt(r)||Hs(r))return;let a={v:r,i:s,n:this.norm.get(r)};this.records.push(a)}_addObject(r,s){let a={i:s,$:{}};this.keys.forEach((n,o)=>{let i=n.getFn?n.getFn(r):this.getFn(r,n.path);if(xt(i)){if(_t(i)){let c=[];const u=[{nestedArrIndex:-1,value:i}];for(;u.length;){const{nestedArrIndex:d,value:m}=u.pop();if(xt(m))if(Et(m)&&!Hs(m)){let h={v:m,i:d,n:this.norm.get(m)};c.push(h)}else _t(m)&&m.forEach((h,p)=>{u.push({nestedArrIndex:p,value:h})})}a.$[o]=c}else if(Et(i)&&!Hs(i)){let c={v:i,n:this.norm.get(i)};a.$[o]=c}}}),this.records.push(a)}toJSON(){return{keys:this.keys,records:this.records}}}function li(t,r,{getFn:s=Te.getFn,fieldNormWeight:a=Te.fieldNormWeight}={}){const n=new Da({getFn:s,fieldNormWeight:a});return n.setKeys(t.map(ii)),n.setSources(r),n.create(),n}function Om(t,{getFn:r=Te.getFn,fieldNormWeight:s=Te.fieldNormWeight}={}){const{keys:a,records:n}=t,o=new Da({getFn:r,fieldNormWeight:s});return o.setKeys(a),o.setIndexRecords(n),o}function Qr(t,{errors:r=0,currentLocation:s=0,expectedLocation:a=0,distance:n=Te.distance,ignoreLocation:o=Te.ignoreLocation}={}){const i=r/t.length;if(o)return i;const c=Math.abs(a-s);return n?i+c/n:c?1:i}function Bm(t=[],r=Te.minMatchCharLength){let s=[],a=-1,n=-1,o=0;for(let i=t.length;o<i;o+=1){let c=t[o];c&&a===-1?a=o:!c&&a!==-1&&(n=o-1,n-a+1>=r&&s.push([a,n]),a=-1)}return t[o-1]&&o-a>=r&&s.push([a,o-1]),s}const Zt=32;function Wm(t,r,s,{location:a=Te.location,distance:n=Te.distance,threshold:o=Te.threshold,findAllMatches:i=Te.findAllMatches,minMatchCharLength:c=Te.minMatchCharLength,includeMatches:u=Te.includeMatches,ignoreLocation:d=Te.ignoreLocation}={}){if(r.length>Zt)throw new Error(Am(Zt));const m=r.length,h=t.length,p=Math.max(0,Math.min(a,h));let g=o,f=p;const x=c>1||u,b=x?Array(h):[];let N;for(;(N=t.indexOf(r,f))>-1;){let C=Qr(r,{currentLocation:N,expectedLocation:p,distance:n,ignoreLocation:d});if(g=Math.min(C,g),f=N+m,x){let v=0;for(;v<m;)b[N+v]=1,v+=1}}f=-1;let j=[],y=1,k=m+h;const I=1<<m-1;for(let C=0;C<m;C+=1){let v=0,E=k;for(;v<E;)Qr(r,{errors:C,currentLocation:p+E,expectedLocation:p,distance:n,ignoreLocation:d})<=g?v=E:k=E,E=Math.floor((k-v)/2+v);k=E;let T=Math.max(1,p-E+1),W=i?h:Math.min(p+E,h)+m,S=Array(W+2);S[W+1]=(1<<C)-1;for(let H=W;H>=T;H-=1){let R=H-1,A=s[t.charAt(R)];if(x&&(b[R]=+!!A),S[H]=(S[H+1]<<1|1)&A,C&&(S[H]|=(j[H+1]|j[H])<<1|1|j[H+1]),S[H]&I&&(y=Qr(r,{errors:C,currentLocation:R,expectedLocation:p,distance:n,ignoreLocation:d}),y<=g)){if(g=y,f=R,f<=p)break;T=Math.max(1,2*p-f)}}if(Qr(r,{errors:C+1,currentLocation:p,expectedLocation:p,distance:n,ignoreLocation:d})>g)break;j=S}const D={isMatch:f>=0,score:Math.max(.001,y)};if(x){const C=Bm(b,c);C.length?u&&(D.indices=C):D.isMatch=!1}return D}function Um(t){let r={};for(let s=0,a=t.length;s<a;s+=1){const n=t.charAt(s);r[n]=(r[n]||0)|1<<a-s-1}return r}const ds=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class ci{constructor(r,{location:s=Te.location,threshold:a=Te.threshold,distance:n=Te.distance,includeMatches:o=Te.includeMatches,findAllMatches:i=Te.findAllMatches,minMatchCharLength:c=Te.minMatchCharLength,isCaseSensitive:u=Te.isCaseSensitive,ignoreDiacritics:d=Te.ignoreDiacritics,ignoreLocation:m=Te.ignoreLocation}={}){if(this.options={location:s,threshold:a,distance:n,includeMatches:o,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:u,ignoreDiacritics:d,ignoreLocation:m},r=u?r:r.toLowerCase(),r=d?ds(r):r,this.pattern=r,this.chunks=[],!this.pattern.length)return;const h=(g,f)=>{this.chunks.push({pattern:g,alphabet:Um(g),startIndex:f})},p=this.pattern.length;if(p>Zt){let g=0;const f=p%Zt,x=p-f;for(;g<x;)h(this.pattern.substr(g,Zt),g),g+=Zt;if(f){const b=p-Zt;h(this.pattern.substr(b),b)}}else h(this.pattern,0)}searchIn(r){const{isCaseSensitive:s,ignoreDiacritics:a,includeMatches:n}=this.options;if(r=s?r:r.toLowerCase(),r=a?ds(r):r,this.pattern===r){let x={isMatch:!0,score:0};return n&&(x.indices=[[0,r.length-1]]),x}const{location:o,distance:i,threshold:c,findAllMatches:u,minMatchCharLength:d,ignoreLocation:m}=this.options;let h=[],p=0,g=!1;this.chunks.forEach(({pattern:x,alphabet:b,startIndex:N})=>{const{isMatch:j,score:y,indices:k}=Wm(r,x,b,{location:o+N,distance:i,threshold:c,findAllMatches:u,minMatchCharLength:d,includeMatches:n,ignoreLocation:m});j&&(g=!0),p+=y,j&&k&&(h=[...h,...k])});let f={isMatch:g,score:g?p/this.chunks.length:1};return g&&n&&(f.indices=h),f}}class Gt{constructor(r){this.pattern=r}static isMultiMatch(r){return An(r,this.multiRegex)}static isSingleMatch(r){return An(r,this.singleRegex)}search(){}}function An(t,r){const s=t.match(r);return s?s[1]:null}class Hm extends Gt{constructor(r){super(r)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(r){const s=r===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Gm extends Gt{constructor(r){super(r)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(r){const a=r.indexOf(this.pattern)===-1;return{isMatch:a,score:a?0:1,indices:[0,r.length-1]}}}class Vm extends Gt{constructor(r){super(r)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(r){const s=r.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class qm extends Gt{constructor(r){super(r)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(r){const s=!r.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,r.length-1]}}}class Km extends Gt{constructor(r){super(r)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(r){const s=r.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[r.length-this.pattern.length,r.length-1]}}}class Jm extends Gt{constructor(r){super(r)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(r){const s=!r.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,r.length-1]}}}class di extends Gt{constructor(r,{location:s=Te.location,threshold:a=Te.threshold,distance:n=Te.distance,includeMatches:o=Te.includeMatches,findAllMatches:i=Te.findAllMatches,minMatchCharLength:c=Te.minMatchCharLength,isCaseSensitive:u=Te.isCaseSensitive,ignoreDiacritics:d=Te.ignoreDiacritics,ignoreLocation:m=Te.ignoreLocation}={}){super(r),this._bitapSearch=new ci(r,{location:s,threshold:a,distance:n,includeMatches:o,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:u,ignoreDiacritics:d,ignoreLocation:m})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(r){return this._bitapSearch.searchIn(r)}}class ui extends Gt{constructor(r){super(r)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(r){let s=0,a;const n=[],o=this.pattern.length;for(;(a=r.indexOf(this.pattern,s))>-1;)s=a+o,n.push([a,s-1]);const i=!!n.length;return{isMatch:i,score:i?0:1,indices:n}}}const la=[Hm,ui,Vm,qm,Jm,Km,Gm,di],In=la.length,Ym=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Qm="|";function Xm(t,r={}){return t.split(Qm).map(s=>{let a=s.trim().split(Ym).filter(o=>o&&!!o.trim()),n=[];for(let o=0,i=a.length;o<i;o+=1){const c=a[o];let u=!1,d=-1;for(;!u&&++d<In;){const m=la[d];let h=m.isMultiMatch(c);h&&(n.push(new m(h,r)),u=!0)}if(!u)for(d=-1;++d<In;){const m=la[d];let h=m.isSingleMatch(c);if(h){n.push(new m(h,r));break}}}return n})}const Zm=new Set([di.type,ui.type]);class ep{constructor(r,{isCaseSensitive:s=Te.isCaseSensitive,ignoreDiacritics:a=Te.ignoreDiacritics,includeMatches:n=Te.includeMatches,minMatchCharLength:o=Te.minMatchCharLength,ignoreLocation:i=Te.ignoreLocation,findAllMatches:c=Te.findAllMatches,location:u=Te.location,threshold:d=Te.threshold,distance:m=Te.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:a,includeMatches:n,minMatchCharLength:o,findAllMatches:c,ignoreLocation:i,location:u,threshold:d,distance:m},r=s?r:r.toLowerCase(),r=a?ds(r):r,this.pattern=r,this.query=Xm(this.pattern,this.options)}static condition(r,s){return s.useExtendedSearch}searchIn(r){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:a,isCaseSensitive:n,ignoreDiacritics:o}=this.options;r=n?r:r.toLowerCase(),r=o?ds(r):r;let i=0,c=[],u=0;for(let d=0,m=s.length;d<m;d+=1){const h=s[d];c.length=0,i=0;for(let p=0,g=h.length;p<g;p+=1){const f=h[p],{isMatch:x,indices:b,score:N}=f.search(r);if(x){if(i+=1,u+=N,a){const j=f.constructor.type;Zm.has(j)?c=[...c,...b]:c.push(b)}}else{u=0,i=0,c.length=0;break}}if(i){let p={isMatch:!0,score:u/i};return a&&(p.indices=c),p}}return{isMatch:!1,score:1}}}const ca=[];function tp(...t){ca.push(...t)}function da(t,r){for(let s=0,a=ca.length;s<a;s+=1){let n=ca[s];if(n.condition(t,r))return new n(t,r)}return new ci(t,r)}const us={AND:"$and",OR:"$or"},ua={PATH:"$path",PATTERN:"$val"},ma=t=>!!(t[us.AND]||t[us.OR]),rp=t=>!!t[ua.PATH],sp=t=>!_t(t)&&ni(t)&&!ma(t),Mn=t=>({[us.AND]:Object.keys(t).map(r=>({[r]:t[r]}))});function mi(t,r,{auto:s=!0}={}){const a=n=>{let o=Object.keys(n);const i=rp(n);if(!i&&o.length>1&&!ma(n))return a(Mn(n));if(sp(n)){const u=i?n[ua.PATH]:o[0],d=i?n[ua.PATTERN]:n[u];if(!Et(d))throw new Error(Tm(u));const m={keyId:ia(u),pattern:d};return s&&(m.searcher=da(d,r)),m}let c={children:[],operator:o[0]};return o.forEach(u=>{const d=n[u];_t(d)&&d.forEach(m=>{c.children.push(a(m))})}),c};return ma(t)||(t=Mn(t)),a(t)}function ap(t,{ignoreFieldNorm:r=Te.ignoreFieldNorm}){t.forEach(s=>{let a=1;s.matches.forEach(({key:n,norm:o,score:i})=>{const c=n?n.weight:null;a*=Math.pow(i===0&&c?Number.EPSILON:i,(c||1)*(r?1:o))}),s.score=a})}function np(t,r){const s=t.matches;r.matches=[],xt(s)&&s.forEach(a=>{if(!xt(a.indices)||!a.indices.length)return;const{indices:n,value:o}=a;let i={indices:n,value:o};a.key&&(i.key=a.key.src),a.idx>-1&&(i.refIndex=a.idx),r.matches.push(i)})}function op(t,r){r.score=t.score}function ip(t,r,{includeMatches:s=Te.includeMatches,includeScore:a=Te.includeScore}={}){const n=[];return s&&n.push(np),a&&n.push(op),t.map(o=>{const{idx:i}=o,c={item:r[i],refIndex:i};return n.length&&n.forEach(u=>{u(o,c)}),c})}class yr{constructor(r,s={},a){this.options={...Te,...s},this.options.useExtendedSearch,this._keyStore=new Dm(this.options.keys),this.setCollection(r,a)}setCollection(r,s){if(this._docs=r,s&&!(s instanceof Da))throw new Error(Em);this._myIndex=s||li(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(r){xt(r)&&(this._docs.push(r),this._myIndex.add(r))}remove(r=()=>!1){const s=[];for(let a=0,n=this._docs.length;a<n;a+=1){const o=this._docs[a];r(o,a)&&(this.removeAt(a),a-=1,n-=1,s.push(o))}return s}removeAt(r){this._docs.splice(r,1),this._myIndex.removeAt(r)}getIndex(){return this._myIndex}search(r,{limit:s=-1}={}){const{includeMatches:a,includeScore:n,shouldSort:o,sortFn:i,ignoreFieldNorm:c}=this.options;let u=Et(r)?Et(this._docs[0])?this._searchStringList(r):this._searchObjectList(r):this._searchLogical(r);return ap(u,{ignoreFieldNorm:c}),o&&u.sort(i),ai(s)&&s>-1&&(u=u.slice(0,s)),ip(u,this._docs,{includeMatches:a,includeScore:n})}_searchStringList(r){const s=da(r,this.options),{records:a}=this._myIndex,n=[];return a.forEach(({v:o,i,n:c})=>{if(!xt(o))return;const{isMatch:u,score:d,indices:m}=s.searchIn(o);u&&n.push({item:o,idx:i,matches:[{score:d,value:o,norm:c,indices:m}]})}),n}_searchLogical(r){const s=mi(r,this.options),a=(c,u,d)=>{if(!c.children){const{keyId:h,searcher:p}=c,g=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(u,h),searcher:p});return g&&g.length?[{idx:d,item:u,matches:g}]:[]}const m=[];for(let h=0,p=c.children.length;h<p;h+=1){const g=c.children[h],f=a(g,u,d);if(f.length)m.push(...f);else if(c.operator===us.AND)return[]}return m},n=this._myIndex.records,o={},i=[];return n.forEach(({$:c,i:u})=>{if(xt(c)){let d=a(s,c,u);d.length&&(o[u]||(o[u]={idx:u,item:c,matches:[]},i.push(o[u])),d.forEach(({matches:m})=>{o[u].matches.push(...m)}))}}),i}_searchObjectList(r){const s=da(r,this.options),{keys:a,records:n}=this._myIndex,o=[];return n.forEach(({$:i,i:c})=>{if(!xt(i))return;let u=[];a.forEach((d,m)=>{u.push(...this._findMatches({key:d,value:i[m],searcher:s}))}),u.length&&o.push({idx:c,item:i,matches:u})}),o}_findMatches({key:r,value:s,searcher:a}){if(!xt(s))return[];let n=[];if(_t(s))s.forEach(({v:o,i,n:c})=>{if(!xt(o))return;const{isMatch:u,score:d,indices:m}=a.searchIn(o);u&&n.push({score:d,key:r,value:o,idx:i,norm:c,indices:m})});else{const{v:o,n:i}=s,{isMatch:c,score:u,indices:d}=a.searchIn(o);c&&n.push({score:u,key:r,value:o,norm:i,indices:d})}return n}}yr.version="7.1.0";yr.createIndex=li;yr.parseIndex=Om;yr.config=Te;yr.parseQuery=mi;tp(ep);const lp=150,pi=t=>`command_history_${t}`,Gs=t=>{const r=ot.getItem(pi(t));if(!r)return{};try{return JSON.parse(r)}catch(s){return console.error("Error parsing command history:",s),{}}},cp=(t,r)=>{ot.setItem(pi(t),JSON.stringify(r))},Dn=t=>!!t&&typeof t.then=="function";function dp({selectedProject:t,input:r,setInput:s,textareaRef:a,onExecuteCommand:n}){const[o,i]=l.useState([]),[c,u]=l.useState([]),[d,m]=l.useState(!1),[h,p]=l.useState(""),[g,f]=l.useState(-1),[x,b]=l.useState(-1),N=l.useRef(null),j=l.useCallback(()=>{N.current!==null&&(window.clearTimeout(N.current),N.current=null)},[]),y=l.useCallback(()=>{m(!1),b(-1),p(""),f(-1),j()},[j]);l.useEffect(()=>{(async()=>{if(!t){i([]),u([]);return}try{const O=await Me("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:t.fullPath||t.path})});if(!O.ok)throw new Error("Failed to fetch commands");const H=await O.json(),R=[...(H.builtIn||[]).map(J=>({...J,type:"built-in"})),...(H.custom||[]).map(J=>({...J,type:"custom"}))],A=Gs(t.name),z=[...R].sort((J,re)=>{const G=A[J.name]||0;return(A[re.name]||0)-G});i(z)}catch(O){console.error("Error fetching slash commands:",O),i([])}})()},[t]),l.useEffect(()=>{d||f(-1)},[d]);const k=l.useMemo(()=>o.length?new yr(o,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[o]);l.useEffect(()=>{if(!h){u(o);return}if(!k){u([]);return}const S=k.search(h);u(S.map(O=>O.item))},[h,o,k]);const I=l.useMemo(()=>{if(!t||o.length===0)return[];const S=Gs(t.name);return o.map(O=>({...O,usageCount:S[O.name]||0})).filter(O=>O.usageCount>0).sort((O,H)=>H.usageCount-O.usageCount).slice(0,5)},[t,o]),D=l.useCallback(S=>{if(!t)return;const O=Gs(t.name);O[S.name]=(O[S.name]||0)+1,cp(t.name,O)},[t]),C=l.useCallback(S=>{const O=r.slice(0,x),H=r.slice(x),R=H.indexOf(" "),A=R!==-1?H.slice(R):"",z=`${O}${S.name} ${A}`;s(z),y();const J=n(S);Dn(J)&&J.catch(()=>{})},[r,x,s,y,n]),v=l.useCallback((S,O,H)=>{if(!S||!t)return;if(H){f(O);return}D(S);const R=n(S);Dn(R)?(R.then(()=>{y()}),R.catch(()=>{})):y()},[t,D,n,y]),E=l.useCallback(()=>{var O;const S=!d;m(S),p(""),f(-1),S&&u(o),(O=a.current)==null||O.focus()},[d,o,a]),T=l.useCallback((S,O)=>{if(!S.trim()){y();return}const H=S.slice(0,O);if((H.match(/```/g)||[]).length%2===1){y();return}const z=/(^|\s)\/(\S*)$/,J=H.match(z);if(!J){y();return}const re=(J.index||0)+J[1].length,G=J[2];b(re),m(!0),f(-1),j(),N.current=window.setTimeout(()=>{p(G)},lp)},[y,j]),W=l.useCallback(S=>d?c.length?S.key==="ArrowDown"?(S.preventDefault(),f(O=>O<c.length-1?O+1:0),!0):S.key==="ArrowUp"?(S.preventDefault(),f(O=>O>0?O-1:c.length-1),!0):S.key==="Tab"||S.key==="Enter"?(S.preventDefault(),g>=0?C(c[g]):c.length>0&&C(c[0]),!0):S.key==="Escape"?(S.preventDefault(),y(),!0):!1:S.key==="Escape"?(S.preventDefault(),y(),!0):!1:!1,[d,c,y,C,g]);return l.useEffect(()=>()=>{j()},[j]),{slashCommands:o,slashCommandsCount:o.length,filteredCommands:c,frequentCommands:I,commandQuery:h,showCommandMenu:d,selectedCommandIndex:g,resetCommandMenuState:y,handleCommandSelect:v,handleToggleCommandMenu:E,handleCommandInputChange:T,handleCommandMenuKeyDown:W}}const up=()=>({preventDefault:()=>{}}),mp=t=>!!(t&&t.startsWith("new-session-"));function pp({selectedProject:t,selectedSession:r,currentSessionId:s,provider:a,permissionMode:n,cyclePermissionMode:o,cursorModel:i,claudeModel:c,codexModel:u,isLoading:d,canAbortSession:m,tokenBudget:h,sendMessage:p,sendByCtrlEnter:g,onSessionActive:f,onInputFocusChange:x,onFileOpen:b,onShowSettings:N,pendingViewSessionRef:j,scrollToBottom:y,setChatMessages:k,setSessionMessages:I,setIsLoading:D,setCanAbortSession:C,setClaudeStatus:v,setIsUserScrolledUp:E,setPendingPermissionRequests:T}){const[W,S]=l.useState(()=>typeof window<"u"&&t&&ot.getItem(`draft_input_${t.name}`)||""),[O,H]=l.useState([]),[R,A]=l.useState(new Map),[z,J]=l.useState(new Map),[re,G]=l.useState(!1),[ie,$]=l.useState("none"),{confirm:Z,dialogProps:te,ConfirmDialog:Q}=Sa(),_=l.useRef(null),F=l.useRef(null),q=l.useRef(null),U=l.useRef(W),B=l.useCallback(le=>{const{action:ue,data:ce}=le;switch(ue){case"clear":k([]),I==null||I([]);break;case"help":k(we=>[...we,{type:"assistant",content:ce.content,timestamp:Date.now()}]);break;case"model":k(we=>[...we,{type:"assistant",content:`**Current Model**: ${ce.current.model}
144
+ Exit code: ${M}`:""),timestamp:new Date}]);break}}},[t,r,s,a,n,o,i,c,u,d,m,h,p,b,N,j,y,k])}var Rs={exports:{}},Os,mn;function Nu(){if(mn)return Os;mn=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Os=t,Os}var Bs,pn;function Cu(){if(pn)return Bs;pn=1;var t=Nu();function r(){}function s(){}return s.resetWarningCache=r,Bs=function(){function a(i,c,u,d,m,h){if(h!==t){var p=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw p.name="Invariant Violation",p}}a.isRequired=a;function n(){return a}var o={array:a,bigint:a,bool:a,func:a,number:a,object:a,string:a,symbol:a,any:a,arrayOf:n,element:a,elementType:a,instanceOf:n,node:a,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:s,resetWarningCache:r};return o.PropTypes=o,o},Bs}var xn;function Su(){return xn||(xn=1,Rs.exports=Cu()()),Rs.exports}var Eu=Su();const qe=Yn(Eu);function nr(t,r,s,a){function n(o){return o instanceof s?o:new s(function(i){i(o)})}return new(s||(s=Promise))(function(o,i){function c(m){try{d(a.next(m))}catch(h){i(h)}}function u(m){try{d(a.throw(m))}catch(h){i(h)}}function d(m){m.done?o(m.value):n(m.value).then(c,u)}d((a=a.apply(t,r||[])).next())})}const Tu=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function xr(t,r,s){const a=Au(t),{webkitRelativePath:n}=t,o=typeof r=="string"?r:typeof n=="string"&&n.length>0?n:`./${t.name}`;return typeof a.path!="string"&&gn(a,"path",o),gn(a,"relativePath",o),a}function Au(t){const{name:r}=t;if(r&&r.lastIndexOf(".")!==-1&&!t.type){const a=r.split(".").pop().toLowerCase(),n=Tu.get(a);n&&Object.defineProperty(t,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return t}function gn(t,r,s){Object.defineProperty(t,r,{value:s,writable:!1,configurable:!1,enumerable:!0})}const Iu=[".DS_Store","Thumbs.db"];function Mu(t){return nr(this,void 0,void 0,function*(){return is(t)&&Du(t.dataTransfer)?_u(t.dataTransfer,t.type):Lu(t)?Pu(t):Array.isArray(t)&&t.every(r=>"getFile"in r&&typeof r.getFile=="function")?$u(t):[]})}function Du(t){return is(t)}function Lu(t){return is(t)&&is(t.target)}function is(t){return typeof t=="object"&&t!==null}function Pu(t){return sa(t.target.files).map(r=>xr(r))}function $u(t){return nr(this,void 0,void 0,function*(){return(yield Promise.all(t.map(s=>s.getFile()))).map(s=>xr(s))})}function _u(t,r){return nr(this,void 0,void 0,function*(){if(t.items){const s=sa(t.items).filter(n=>n.kind==="file");if(r!=="drop")return s;const a=yield Promise.all(s.map(Fu));return hn(qo(a))}return hn(sa(t.files).map(s=>xr(s)))})}function hn(t){return t.filter(r=>Iu.indexOf(r.name)===-1)}function sa(t){if(t===null)return[];const r=[];for(let s=0;s<t.length;s++){const a=t[s];r.push(a)}return r}function Fu(t){if(typeof t.webkitGetAsEntry!="function")return fn(t);const r=t.webkitGetAsEntry();return r&&r.isDirectory?Ko(r):fn(t,r)}function qo(t){return t.reduce((r,s)=>[...r,...Array.isArray(s)?qo(s):[s]],[])}function fn(t,r){return nr(this,void 0,void 0,function*(){var s;if(globalThis.isSecureContext&&typeof t.getAsFileSystemHandle=="function"){const o=yield t.getAsFileSystemHandle();if(o===null)throw new Error(`${t} is not a File`);if(o!==void 0){const i=yield o.getFile();return i.handle=o,xr(i)}}const a=t.getAsFile();if(!a)throw new Error(`${t} is not a File`);return xr(a,(s=r==null?void 0:r.fullPath)!==null&&s!==void 0?s:void 0)})}function zu(t){return nr(this,void 0,void 0,function*(){return t.isDirectory?Ko(t):Ru(t)})}function Ko(t){const r=t.createReader();return new Promise((s,a)=>{const n=[];function o(){r.readEntries(i=>nr(this,void 0,void 0,function*(){if(i.length){const c=Promise.all(i.map(zu));n.push(c),o()}else try{const c=yield Promise.all(n);s(c)}catch(c){a(c)}}),i=>{a(i)})}o()})}function Ru(t){return nr(this,void 0,void 0,function*(){return new Promise((r,s)=>{t.file(a=>{const n=xr(a,t.fullPath);r(n)},a=>{s(a)})})})}var Yr={},bn;function Ou(){return bn||(bn=1,Yr.__esModule=!0,Yr.default=function(t,r){if(t&&r){var s=Array.isArray(r)?r:r.split(",");if(s.length===0)return!0;var a=t.name||"",n=(t.type||"").toLowerCase(),o=n.replace(/\/.*$/,"");return s.some(function(i){var c=i.trim().toLowerCase();return c.charAt(0)==="."?a.toLowerCase().endsWith(c):c.endsWith("/*")?o===c.replace(/\/.*$/,""):n===c})}return!0}),Yr}var Bu=Ou();const Ws=Yn(Bu);function yn(t){return Hu(t)||Uu(t)||Yo(t)||Wu()}function Wu(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
145
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Uu(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Hu(t){if(Array.isArray(t))return aa(t)}function vn(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,a)}return s}function kn(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?vn(Object(s),!0).forEach(function(a){Jo(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):vn(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function Jo(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function Dr(t,r){return qu(t)||Vu(t,r)||Yo(t,r)||Gu()}function Gu(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
146
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yo(t,r){if(t){if(typeof t=="string")return aa(t,r);var s=Object.prototype.toString.call(t).slice(8,-1);if(s==="Object"&&t.constructor&&(s=t.constructor.name),s==="Map"||s==="Set")return Array.from(t);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return aa(t,r)}}function aa(t,r){(r==null||r>t.length)&&(r=t.length);for(var s=0,a=new Array(r);s<r;s++)a[s]=t[s];return a}function Vu(t,r){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var a=[],n=!0,o=!1,i,c;try{for(s=s.call(t);!(n=(i=s.next()).done)&&(a.push(i.value),!(r&&a.length===r));n=!0);}catch(u){o=!0,c=u}finally{try{!n&&s.return!=null&&s.return()}finally{if(o)throw c}}return a}}function qu(t){if(Array.isArray(t))return t}var Ku=typeof Ws=="function"?Ws:Ws.default,Ju="file-invalid-type",Yu="file-too-large",Qu="file-too-small",Xu="too-many-files",Zu=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",s=r.split(","),a=s.length>1?"one of ".concat(s.join(", ")):s[0];return{code:Ju,message:"File type must be ".concat(a)}},wn=function(r){return{code:Yu,message:"File is larger than ".concat(r," ").concat(r===1?"byte":"bytes")}},jn=function(r){return{code:Qu,message:"File is smaller than ".concat(r," ").concat(r===1?"byte":"bytes")}},em={code:Xu,message:"Too many files"};function tm(t){return t.type===""&&typeof t.getAsFile=="function"}function Qo(t,r){var s=t.type==="application/x-moz-file"||Ku(t,r)||tm(t);return[s,s?null:Zu(r)]}function Xo(t,r,s){if(Xt(t.size))if(Xt(r)&&Xt(s)){if(t.size>s)return[!1,wn(s)];if(t.size<r)return[!1,jn(r)]}else{if(Xt(r)&&t.size<r)return[!1,jn(r)];if(Xt(s)&&t.size>s)return[!1,wn(s)]}return[!0,null]}function Xt(t){return t!=null}function rm(t){var r=t.files,s=t.accept,a=t.minSize,n=t.maxSize,o=t.multiple,i=t.maxFiles,c=t.validator;return!o&&r.length>1||o&&i>=1&&r.length>i?!1:r.every(function(u){var d=Qo(u,s),m=Dr(d,1),h=m[0],p=Xo(u,a,n),g=Dr(p,1),f=g[0],x=c?c(u):null;return h&&f&&!x})}function ls(t){return typeof t.isPropagationStopped=="function"?t.isPropagationStopped():typeof t.cancelBubble<"u"?t.cancelBubble:!1}function wr(t){return t.dataTransfer?Array.prototype.some.call(t.dataTransfer.types,function(r){return r==="Files"||r==="application/x-moz-file"}):!!t.target&&!!t.target.files}function Nn(t){t.preventDefault()}function sm(t){return t.indexOf("MSIE")!==-1||t.indexOf("Trident/")!==-1}function am(t){return t.indexOf("Edge/")!==-1}function nm(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return sm(t)||am(t)}function Nt(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return function(a){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return r.some(function(c){return!ls(a)&&c&&c.apply(void 0,[a].concat(o)),ls(a)})}}function om(){return"showOpenFilePicker"in window}function im(t){if(Xt(t)){var r=Object.entries(t).filter(function(s){var a=Dr(s,2),n=a[0],o=a[1],i=!0;return Zo(n)||(console.warn('Skipped "'.concat(n,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),(!Array.isArray(o)||!o.every(ei))&&(console.warn('Skipped "'.concat(n,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(s,a){var n=Dr(a,2),o=n[0],i=n[1];return kn(kn({},s),{},Jo({},o,i))},{});return[{description:"Files",accept:r}]}return t}function lm(t){if(Xt(t))return Object.entries(t).reduce(function(r,s){var a=Dr(s,2),n=a[0],o=a[1];return[].concat(yn(r),[n],yn(o))},[]).filter(function(r){return Zo(r)||ei(r)}).join(",")}function cm(t){return t instanceof DOMException&&(t.name==="AbortError"||t.code===t.ABORT_ERR)}function dm(t){return t instanceof DOMException&&(t.name==="SecurityError"||t.code===t.SECURITY_ERR)}function Zo(t){return t==="audio/*"||t==="video/*"||t==="image/*"||t==="text/*"||t==="application/*"||/\w+\/[-+.\w]+/g.test(t)}function ei(t){return/^.*\.[\w]+$/.test(t)}var um=["children"],mm=["open"],pm=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],xm=["refKey","onChange","onClick"];function Cn(t){return fm(t)||hm(t)||ti(t)||gm()}function gm(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
147
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hm(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function fm(t){if(Array.isArray(t))return na(t)}function Us(t,r){return vm(t)||ym(t,r)||ti(t,r)||bm()}function bm(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
148
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ti(t,r){if(t){if(typeof t=="string")return na(t,r);var s=Object.prototype.toString.call(t).slice(8,-1);if(s==="Object"&&t.constructor&&(s=t.constructor.name),s==="Map"||s==="Set")return Array.from(t);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return na(t,r)}}function na(t,r){(r==null||r>t.length)&&(r=t.length);for(var s=0,a=new Array(r);s<r;s++)a[s]=t[s];return a}function ym(t,r){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var a=[],n=!0,o=!1,i,c;try{for(s=s.call(t);!(n=(i=s.next()).done)&&(a.push(i.value),!(r&&a.length===r));n=!0);}catch(u){o=!0,c=u}finally{try{!n&&s.return!=null&&s.return()}finally{if(o)throw c}}return a}}function vm(t){if(Array.isArray(t))return t}function Sn(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,a)}return s}function Je(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?Sn(Object(s),!0).forEach(function(a){oa(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Sn(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function oa(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function cs(t,r){if(t==null)return{};var s=km(t,r),a,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)a=o[n],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(s[a]=t[a])}return s}function km(t,r){if(t==null)return{};var s={},a=Object.keys(t),n,o;for(o=0;o<a.length;o++)n=a[o],!(r.indexOf(n)>=0)&&(s[n]=t[n]);return s}var Da=l.forwardRef(function(t,r){var s=t.children,a=cs(t,um),n=si(a),o=n.open,i=cs(n,mm);return l.useImperativeHandle(r,function(){return{open:o}},[o]),it.createElement(l.Fragment,null,s(Je(Je({},i),{},{open:o})))});Da.displayName="Dropzone";var ri={disabled:!1,getFilesFromEvent:Mu,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};Da.defaultProps=ri;Da.propTypes={children:qe.func,accept:qe.objectOf(qe.arrayOf(qe.string)),multiple:qe.bool,preventDropOnDocument:qe.bool,noClick:qe.bool,noKeyboard:qe.bool,noDrag:qe.bool,noDragEventsBubbling:qe.bool,minSize:qe.number,maxSize:qe.number,maxFiles:qe.number,disabled:qe.bool,getFilesFromEvent:qe.func,onFileDialogCancel:qe.func,onFileDialogOpen:qe.func,useFsAccessApi:qe.bool,autoFocus:qe.bool,onDragEnter:qe.func,onDragLeave:qe.func,onDragOver:qe.func,onDrop:qe.func,onDropAccepted:qe.func,onDropRejected:qe.func,onError:qe.func,validator:qe.func};var ia={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function si(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=Je(Je({},ri),t),s=r.accept,a=r.disabled,n=r.getFilesFromEvent,o=r.maxSize,i=r.minSize,c=r.multiple,u=r.maxFiles,d=r.onDragEnter,m=r.onDragLeave,h=r.onDragOver,p=r.onDrop,g=r.onDropAccepted,f=r.onDropRejected,x=r.onFileDialogCancel,b=r.onFileDialogOpen,N=r.useFsAccessApi,j=r.autoFocus,y=r.preventDropOnDocument,k=r.noClick,I=r.noKeyboard,D=r.noDrag,C=r.noDragEventsBubbling,v=r.onError,E=r.validator,T=l.useMemo(function(){return lm(s)},[s]),W=l.useMemo(function(){return im(s)},[s]),S=l.useMemo(function(){return typeof b=="function"?b:En},[b]),O=l.useMemo(function(){return typeof x=="function"?x:En},[x]),H=l.useRef(null),R=l.useRef(null),A=l.useReducer(wm,ia),z=Us(A,2),J=z[0],re=z[1],G=J.isFocused,ie=J.isFileDialogActive,$=l.useRef(typeof window<"u"&&window.isSecureContext&&N&&om()),Z=function(){!$.current&&ie&&setTimeout(function(){if(R.current){var K=R.current.files;K.length||(re({type:"closeDialog"}),O())}},300)};l.useEffect(function(){return window.addEventListener("focus",Z,!1),function(){window.removeEventListener("focus",Z,!1)}},[R,ie,O,$]);var te=l.useRef([]),Q=l.useRef([]),_=function(K){H.current&&H.current.contains(K.target)||(K.preventDefault(),te.current=[])};l.useEffect(function(){return y&&(document.addEventListener("dragover",Nn,!1),document.addEventListener("drop",_,!1)),function(){y&&(document.removeEventListener("dragover",Nn),document.removeEventListener("drop",_))}},[H,y]),l.useEffect(function(){var L=function(Fe){Q.current=[].concat(Cn(Q.current),[Fe.target]),wr(Fe)&&re({isDragGlobal:!0,type:"setDragGlobal"})},K=function(Fe){Q.current=Q.current.filter(function(Se){return Se!==Fe.target&&Se!==null}),!(Q.current.length>0)&&re({isDragGlobal:!1,type:"setDragGlobal"})},pe=function(){Q.current=[],re({isDragGlobal:!1,type:"setDragGlobal"})},ye=function(){Q.current=[],re({isDragGlobal:!1,type:"setDragGlobal"})};return document.addEventListener("dragenter",L,!1),document.addEventListener("dragleave",K,!1),document.addEventListener("dragend",pe,!1),document.addEventListener("drop",ye,!1),function(){document.removeEventListener("dragenter",L),document.removeEventListener("dragleave",K),document.removeEventListener("dragend",pe),document.removeEventListener("drop",ye)}},[H]),l.useEffect(function(){return!a&&j&&H.current&&H.current.focus(),function(){}},[H,j,a]);var F=l.useCallback(function(L){v?v(L):console.error(L)},[v]),q=l.useCallback(function(L){L.preventDefault(),L.persist(),Ne(L),te.current=[].concat(Cn(te.current),[L.target]),wr(L)&&Promise.resolve(n(L)).then(function(K){if(!(ls(L)&&!C)){var pe=K.length,ye=pe>0&&rm({files:K,accept:T,minSize:i,maxSize:o,multiple:c,maxFiles:u,validator:E}),Ie=pe>0&&!ye;re({isDragAccept:ye,isDragReject:Ie,isDragActive:!0,type:"setDraggedFiles"}),d&&d(L)}}).catch(function(K){return F(K)})},[n,d,F,C,T,i,o,c,u,E]),U=l.useCallback(function(L){L.preventDefault(),L.persist(),Ne(L);var K=wr(L);if(K&&L.dataTransfer)try{L.dataTransfer.dropEffect="copy"}catch{}return K&&h&&h(L),!1},[h,C]),B=l.useCallback(function(L){L.preventDefault(),L.persist(),Ne(L);var K=te.current.filter(function(ye){return H.current&&H.current.contains(ye)}),pe=K.indexOf(L.target);pe!==-1&&K.splice(pe,1),te.current=K,!(K.length>0)&&(re({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),wr(L)&&m&&m(L))},[H,m,C]),ee=l.useCallback(function(L,K){var pe=[],ye=[];L.forEach(function(Ie){var Fe=Qo(Ie,T),Se=Us(Fe,2),Oe=Se[0],ne=Se[1],fe=Xo(Ie,i,o),Ee=Us(fe,2),Le=Ee[0],Pe=Ee[1],Ae=E?E(Ie):null;if(Oe&&Le&&!Ae)pe.push(Ie);else{var Ge=[ne,Pe];Ae&&(Ge=Ge.concat(Ae)),ye.push({file:Ie,errors:Ge.filter(function(ae){return ae})})}}),(!c&&pe.length>1||c&&u>=1&&pe.length>u)&&(pe.forEach(function(Ie){ye.push({file:Ie,errors:[em]})}),pe.splice(0)),re({acceptedFiles:pe,fileRejections:ye,isDragReject:ye.length>0,type:"setFiles"}),p&&p(pe,ye,K),ye.length>0&&f&&f(ye,K),pe.length>0&&g&&g(pe,K)},[re,c,T,i,o,u,p,g,f,E]),V=l.useCallback(function(L){L.preventDefault(),L.persist(),Ne(L),te.current=[],wr(L)&&Promise.resolve(n(L)).then(function(K){ls(L)&&!C||ee(K,L)}).catch(function(K){return F(K)}),re({type:"reset"})},[n,ee,F,C]),w=l.useCallback(function(){if($.current){re({type:"openDialog"}),S();var L={multiple:c,types:W};window.showOpenFilePicker(L).then(function(K){return n(K)}).then(function(K){ee(K,null),re({type:"closeDialog"})}).catch(function(K){cm(K)?(O(K),re({type:"closeDialog"})):dm(K)?($.current=!1,R.current?(R.current.value=null,R.current.click()):F(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):F(K)});return}R.current&&(re({type:"openDialog"}),S(),R.current.value=null,R.current.click())},[re,S,O,N,ee,F,W,c]),M=l.useCallback(function(L){!H.current||!H.current.isEqualNode(L.target)||(L.key===" "||L.key==="Enter"||L.keyCode===32||L.keyCode===13)&&(L.preventDefault(),w())},[H,w]),Y=l.useCallback(function(){re({type:"focus"})},[]),se=l.useCallback(function(){re({type:"blur"})},[]),de=l.useCallback(function(){k||(nm()?setTimeout(w,0):w())},[k,w]),je=function(K){return a?null:K},ge=function(K){return I?null:je(K)},Re=function(K){return D?null:je(K)},Ne=function(K){C&&K.stopPropagation()},De=l.useMemo(function(){return function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},K=L.refKey,pe=K===void 0?"ref":K,ye=L.role,Ie=L.onKeyDown,Fe=L.onFocus,Se=L.onBlur,Oe=L.onClick,ne=L.onDragEnter,fe=L.onDragOver,Ee=L.onDragLeave,Le=L.onDrop,Pe=cs(L,pm);return Je(Je(oa({onKeyDown:ge(Nt(Ie,M)),onFocus:ge(Nt(Fe,Y)),onBlur:ge(Nt(Se,se)),onClick:je(Nt(Oe,de)),onDragEnter:Re(Nt(ne,q)),onDragOver:Re(Nt(fe,U)),onDragLeave:Re(Nt(Ee,B)),onDrop:Re(Nt(Le,V)),role:typeof ye=="string"&&ye!==""?ye:"presentation"},pe,H),!a&&!I?{tabIndex:0}:{}),Pe)}},[H,M,Y,se,de,q,U,B,V,I,D,a]),Ue=l.useCallback(function(L){L.stopPropagation()},[]),_e=l.useMemo(function(){return function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},K=L.refKey,pe=K===void 0?"ref":K,ye=L.onChange,Ie=L.onClick,Fe=cs(L,xm),Se=oa({accept:T,multiple:c,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:je(Nt(ye,V)),onClick:je(Nt(Ie,Ue)),tabIndex:-1},pe,R);return Je(Je({},Se),Fe)}},[R,s,c,V,a]);return Je(Je({},J),{},{isFocused:G&&!a,getRootProps:De,getInputProps:_e,rootRef:H,inputRef:R,open:je(w)})}function wm(t,r){switch(r.type){case"focus":return Je(Je({},t),{},{isFocused:!0});case"blur":return Je(Je({},t),{},{isFocused:!1});case"openDialog":return Je(Je({},ia),{},{isFileDialogActive:!0});case"closeDialog":return Je(Je({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return Je(Je({},t),{},{isDragActive:r.isDragActive,isDragAccept:r.isDragAccept,isDragReject:r.isDragReject});case"setFiles":return Je(Je({},t),{},{acceptedFiles:r.acceptedFiles,fileRejections:r.fileRejections,isDragReject:r.isDragReject});case"setDragGlobal":return Je(Je({},t),{},{isDragGlobal:r.isDragGlobal});case"reset":return Je({},ia);default:return t}}function En(){}const ai=(t,r="")=>{let s=[];return t.forEach(a=>{const n=r?`${r}/${a.name}`:a.name;if(a.type==="directory"&&a.children){s=s.concat(ai(a.children,n));return}a.type==="file"&&s.push({name:a.name,path:n,relativePath:a.path})}),s};function jm({selectedProject:t,input:r,setInput:s,textareaRef:a}){const[n,o]=l.useState([]),[i,c]=l.useState([]),[u,d]=l.useState([]),[m,h]=l.useState(!1),[p,g]=l.useState(-1),[f,x]=l.useState(0),[b,N]=l.useState(-1);l.useEffect(()=>{const E=new AbortController;return(async()=>{const W=t==null?void 0:t.name;if(o([]),d([]),!!W)try{const S=await Be.getFiles(W,{signal:E.signal});if(!S.ok)return;const O=await S.json();o(ai(O))}catch(S){if((S==null?void 0:S.name)==="AbortError")return;console.error("Error fetching files:",S)}})(),()=>{E.abort()}},[t==null?void 0:t.name]),l.useEffect(()=>{const E=r.slice(0,f),T=E.lastIndexOf("@");if(T===-1){h(!1),N(-1);return}const W=E.slice(T+1);if(W.includes(" ")){h(!1),N(-1);return}N(T),h(!0),g(-1);const S=n.filter(O=>O.name.toLowerCase().includes(W.toLowerCase())||O.path.toLowerCase().includes(W.toLowerCase())).slice(0,10);d(S)},[r,f,n]);const j=l.useMemo(()=>!r||i.length===0?[]:i.filter(E=>r.includes(E)),[i,r]),y=l.useMemo(()=>j.length===0?[]:Array.from(new Set(j)).sort((T,W)=>W.length-T.length),[j]),k=l.useMemo(()=>{if(y.length===0)return null;const E=y.map(zo).join("|");return new RegExp(`(${E})`,"g")},[y]),I=l.useMemo(()=>new Set(y),[y]),D=l.useCallback(E=>E?k?E.split(k).map((W,S)=>I.has(W)?e.jsx("span",{className:"bg-blue-200/70 -ml-0.5 dark:bg-blue-300/40 px-0.5 rounded-md box-decoration-clone text-transparent",children:W},`mention-${S}`):e.jsx("span",{children:W},`text-${S}`)):E:"",[k,I]),C=l.useCallback(E=>{const T=r.slice(0,b),W=r.slice(b),S=W.indexOf(" "),O=S!==-1?W.slice(S):"",H=`${T}${E.path} ${O}`,R=T.length+E.path.length+1;a.current&&!a.current.matches(":focus")&&a.current.focus(),s(H),x(R),c(A=>A.includes(E.path)?A:[...A,E.path]),h(!1),N(-1),a.current&&requestAnimationFrame(()=>{a.current&&(a.current.setSelectionRange(R,R),a.current.matches(":focus")||a.current.focus())})},[r,b,a,s]),v=l.useCallback(E=>!m||u.length===0?!1:E.key==="ArrowDown"?(E.preventDefault(),g(T=>T<u.length-1?T+1:0),!0):E.key==="ArrowUp"?(E.preventDefault(),g(T=>T>0?T-1:u.length-1),!0):E.key==="Tab"||E.key==="Enter"?(E.preventDefault(),p>=0?C(u[p]):u.length>0&&C(u[0]),!0):E.key==="Escape"?(E.preventDefault(),h(!1),!0):!1,[m,u,p,C]);return{showFileDropdown:m,filteredFiles:u,selectedFileIndex:p,renderInputWithMentions:D,selectFile:C,setCursorPosition:x,handleFileMentionsKeyDown:v}}function _t(t){return Array.isArray?Array.isArray(t):ii(t)==="[object Array]"}function Nm(t){if(typeof t=="string")return t;let r=t+"";return r=="0"&&1/t==-1/0?"-0":r}function Cm(t){return t==null?"":Nm(t)}function Et(t){return typeof t=="string"}function ni(t){return typeof t=="number"}function Sm(t){return t===!0||t===!1||Em(t)&&ii(t)=="[object Boolean]"}function oi(t){return typeof t=="object"}function Em(t){return oi(t)&&t!==null}function xt(t){return t!=null}function Hs(t){return!t.trim().length}function ii(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Tm="Incorrect 'index' type",Am=t=>`Invalid value for key ${t}`,Im=t=>`Pattern length exceeds max of ${t}.`,Mm=t=>`Missing ${t} property in key`,Dm=t=>`Property 'weight' in key '${t}' must be a positive integer`,Tn=Object.prototype.hasOwnProperty;class Lm{constructor(r){this._keys=[],this._keyMap={};let s=0;r.forEach(a=>{let n=li(a);this._keys.push(n),this._keyMap[n.id]=n,s+=n.weight}),this._keys.forEach(a=>{a.weight/=s})}get(r){return this._keyMap[r]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function li(t){let r=null,s=null,a=null,n=1,o=null;if(Et(t)||_t(t))a=t,r=An(t),s=la(t);else{if(!Tn.call(t,"name"))throw new Error(Mm("name"));const i=t.name;if(a=i,Tn.call(t,"weight")&&(n=t.weight,n<=0))throw new Error(Dm(i));r=An(i),s=la(i),o=t.getFn}return{path:r,id:s,weight:n,src:a,getFn:o}}function An(t){return _t(t)?t:t.split(".")}function la(t){return _t(t)?t.join("."):t}function Pm(t,r){let s=[],a=!1;const n=(o,i,c)=>{if(xt(o))if(!i[c])s.push(o);else{let u=i[c];const d=o[u];if(!xt(d))return;if(c===i.length-1&&(Et(d)||ni(d)||Sm(d)))s.push(Cm(d));else if(_t(d)){a=!0;for(let m=0,h=d.length;m<h;m+=1)n(d[m],i,c+1)}else i.length&&n(d,i,c+1)}};return n(t,Et(r)?r.split("."):r,0),a?s:s[0]}const $m={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},_m={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,r)=>t.score===r.score?t.idx<r.idx?-1:1:t.score<r.score?-1:1},Fm={location:0,threshold:.6,distance:100},zm={useExtendedSearch:!1,getFn:Pm,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Te={..._m,...$m,...Fm,...zm};const Rm=/[^ ]+/g;function Om(t=1,r=3){const s=new Map,a=Math.pow(10,r);return{get(n){const o=n.match(Rm).length;if(s.has(o))return s.get(o);const i=1/Math.pow(o,.5*t),c=parseFloat(Math.round(i*a)/a);return s.set(o,c),c},clear(){s.clear()}}}class La{constructor({getFn:r=Te.getFn,fieldNormWeight:s=Te.fieldNormWeight}={}){this.norm=Om(s,3),this.getFn=r,this.isCreated=!1,this.setIndexRecords()}setSources(r=[]){this.docs=r}setIndexRecords(r=[]){this.records=r}setKeys(r=[]){this.keys=r,this._keysMap={},r.forEach((s,a)=>{this._keysMap[s.id]=a})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Et(this.docs[0])?this.docs.forEach((r,s)=>{this._addString(r,s)}):this.docs.forEach((r,s)=>{this._addObject(r,s)}),this.norm.clear())}add(r){const s=this.size();Et(r)?this._addString(r,s):this._addObject(r,s)}removeAt(r){this.records.splice(r,1);for(let s=r,a=this.size();s<a;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(r,s){return r[this._keysMap[s]]}size(){return this.records.length}_addString(r,s){if(!xt(r)||Hs(r))return;let a={v:r,i:s,n:this.norm.get(r)};this.records.push(a)}_addObject(r,s){let a={i:s,$:{}};this.keys.forEach((n,o)=>{let i=n.getFn?n.getFn(r):this.getFn(r,n.path);if(xt(i)){if(_t(i)){let c=[];const u=[{nestedArrIndex:-1,value:i}];for(;u.length;){const{nestedArrIndex:d,value:m}=u.pop();if(xt(m))if(Et(m)&&!Hs(m)){let h={v:m,i:d,n:this.norm.get(m)};c.push(h)}else _t(m)&&m.forEach((h,p)=>{u.push({nestedArrIndex:p,value:h})})}a.$[o]=c}else if(Et(i)&&!Hs(i)){let c={v:i,n:this.norm.get(i)};a.$[o]=c}}}),this.records.push(a)}toJSON(){return{keys:this.keys,records:this.records}}}function ci(t,r,{getFn:s=Te.getFn,fieldNormWeight:a=Te.fieldNormWeight}={}){const n=new La({getFn:s,fieldNormWeight:a});return n.setKeys(t.map(li)),n.setSources(r),n.create(),n}function Bm(t,{getFn:r=Te.getFn,fieldNormWeight:s=Te.fieldNormWeight}={}){const{keys:a,records:n}=t,o=new La({getFn:r,fieldNormWeight:s});return o.setKeys(a),o.setIndexRecords(n),o}function Qr(t,{errors:r=0,currentLocation:s=0,expectedLocation:a=0,distance:n=Te.distance,ignoreLocation:o=Te.ignoreLocation}={}){const i=r/t.length;if(o)return i;const c=Math.abs(a-s);return n?i+c/n:c?1:i}function Wm(t=[],r=Te.minMatchCharLength){let s=[],a=-1,n=-1,o=0;for(let i=t.length;o<i;o+=1){let c=t[o];c&&a===-1?a=o:!c&&a!==-1&&(n=o-1,n-a+1>=r&&s.push([a,n]),a=-1)}return t[o-1]&&o-a>=r&&s.push([a,o-1]),s}const Zt=32;function Um(t,r,s,{location:a=Te.location,distance:n=Te.distance,threshold:o=Te.threshold,findAllMatches:i=Te.findAllMatches,minMatchCharLength:c=Te.minMatchCharLength,includeMatches:u=Te.includeMatches,ignoreLocation:d=Te.ignoreLocation}={}){if(r.length>Zt)throw new Error(Im(Zt));const m=r.length,h=t.length,p=Math.max(0,Math.min(a,h));let g=o,f=p;const x=c>1||u,b=x?Array(h):[];let N;for(;(N=t.indexOf(r,f))>-1;){let C=Qr(r,{currentLocation:N,expectedLocation:p,distance:n,ignoreLocation:d});if(g=Math.min(C,g),f=N+m,x){let v=0;for(;v<m;)b[N+v]=1,v+=1}}f=-1;let j=[],y=1,k=m+h;const I=1<<m-1;for(let C=0;C<m;C+=1){let v=0,E=k;for(;v<E;)Qr(r,{errors:C,currentLocation:p+E,expectedLocation:p,distance:n,ignoreLocation:d})<=g?v=E:k=E,E=Math.floor((k-v)/2+v);k=E;let T=Math.max(1,p-E+1),W=i?h:Math.min(p+E,h)+m,S=Array(W+2);S[W+1]=(1<<C)-1;for(let H=W;H>=T;H-=1){let R=H-1,A=s[t.charAt(R)];if(x&&(b[R]=+!!A),S[H]=(S[H+1]<<1|1)&A,C&&(S[H]|=(j[H+1]|j[H])<<1|1|j[H+1]),S[H]&I&&(y=Qr(r,{errors:C,currentLocation:R,expectedLocation:p,distance:n,ignoreLocation:d}),y<=g)){if(g=y,f=R,f<=p)break;T=Math.max(1,2*p-f)}}if(Qr(r,{errors:C+1,currentLocation:p,expectedLocation:p,distance:n,ignoreLocation:d})>g)break;j=S}const D={isMatch:f>=0,score:Math.max(.001,y)};if(x){const C=Wm(b,c);C.length?u&&(D.indices=C):D.isMatch=!1}return D}function Hm(t){let r={};for(let s=0,a=t.length;s<a;s+=1){const n=t.charAt(s);r[n]=(r[n]||0)|1<<a-s-1}return r}const ds=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class di{constructor(r,{location:s=Te.location,threshold:a=Te.threshold,distance:n=Te.distance,includeMatches:o=Te.includeMatches,findAllMatches:i=Te.findAllMatches,minMatchCharLength:c=Te.minMatchCharLength,isCaseSensitive:u=Te.isCaseSensitive,ignoreDiacritics:d=Te.ignoreDiacritics,ignoreLocation:m=Te.ignoreLocation}={}){if(this.options={location:s,threshold:a,distance:n,includeMatches:o,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:u,ignoreDiacritics:d,ignoreLocation:m},r=u?r:r.toLowerCase(),r=d?ds(r):r,this.pattern=r,this.chunks=[],!this.pattern.length)return;const h=(g,f)=>{this.chunks.push({pattern:g,alphabet:Hm(g),startIndex:f})},p=this.pattern.length;if(p>Zt){let g=0;const f=p%Zt,x=p-f;for(;g<x;)h(this.pattern.substr(g,Zt),g),g+=Zt;if(f){const b=p-Zt;h(this.pattern.substr(b),b)}}else h(this.pattern,0)}searchIn(r){const{isCaseSensitive:s,ignoreDiacritics:a,includeMatches:n}=this.options;if(r=s?r:r.toLowerCase(),r=a?ds(r):r,this.pattern===r){let x={isMatch:!0,score:0};return n&&(x.indices=[[0,r.length-1]]),x}const{location:o,distance:i,threshold:c,findAllMatches:u,minMatchCharLength:d,ignoreLocation:m}=this.options;let h=[],p=0,g=!1;this.chunks.forEach(({pattern:x,alphabet:b,startIndex:N})=>{const{isMatch:j,score:y,indices:k}=Um(r,x,b,{location:o+N,distance:i,threshold:c,findAllMatches:u,minMatchCharLength:d,includeMatches:n,ignoreLocation:m});j&&(g=!0),p+=y,j&&k&&(h=[...h,...k])});let f={isMatch:g,score:g?p/this.chunks.length:1};return g&&n&&(f.indices=h),f}}class Gt{constructor(r){this.pattern=r}static isMultiMatch(r){return In(r,this.multiRegex)}static isSingleMatch(r){return In(r,this.singleRegex)}search(){}}function In(t,r){const s=t.match(r);return s?s[1]:null}class Gm extends Gt{constructor(r){super(r)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(r){const s=r===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Vm extends Gt{constructor(r){super(r)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(r){const a=r.indexOf(this.pattern)===-1;return{isMatch:a,score:a?0:1,indices:[0,r.length-1]}}}class qm extends Gt{constructor(r){super(r)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(r){const s=r.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Km extends Gt{constructor(r){super(r)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(r){const s=!r.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,r.length-1]}}}class Jm extends Gt{constructor(r){super(r)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(r){const s=r.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[r.length-this.pattern.length,r.length-1]}}}class Ym extends Gt{constructor(r){super(r)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(r){const s=!r.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,r.length-1]}}}class ui extends Gt{constructor(r,{location:s=Te.location,threshold:a=Te.threshold,distance:n=Te.distance,includeMatches:o=Te.includeMatches,findAllMatches:i=Te.findAllMatches,minMatchCharLength:c=Te.minMatchCharLength,isCaseSensitive:u=Te.isCaseSensitive,ignoreDiacritics:d=Te.ignoreDiacritics,ignoreLocation:m=Te.ignoreLocation}={}){super(r),this._bitapSearch=new di(r,{location:s,threshold:a,distance:n,includeMatches:o,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:u,ignoreDiacritics:d,ignoreLocation:m})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(r){return this._bitapSearch.searchIn(r)}}class mi extends Gt{constructor(r){super(r)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(r){let s=0,a;const n=[],o=this.pattern.length;for(;(a=r.indexOf(this.pattern,s))>-1;)s=a+o,n.push([a,s-1]);const i=!!n.length;return{isMatch:i,score:i?0:1,indices:n}}}const ca=[Gm,mi,qm,Km,Ym,Jm,Vm,ui],Mn=ca.length,Qm=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Xm="|";function Zm(t,r={}){return t.split(Xm).map(s=>{let a=s.trim().split(Qm).filter(o=>o&&!!o.trim()),n=[];for(let o=0,i=a.length;o<i;o+=1){const c=a[o];let u=!1,d=-1;for(;!u&&++d<Mn;){const m=ca[d];let h=m.isMultiMatch(c);h&&(n.push(new m(h,r)),u=!0)}if(!u)for(d=-1;++d<Mn;){const m=ca[d];let h=m.isSingleMatch(c);if(h){n.push(new m(h,r));break}}}return n})}const ep=new Set([ui.type,mi.type]);class tp{constructor(r,{isCaseSensitive:s=Te.isCaseSensitive,ignoreDiacritics:a=Te.ignoreDiacritics,includeMatches:n=Te.includeMatches,minMatchCharLength:o=Te.minMatchCharLength,ignoreLocation:i=Te.ignoreLocation,findAllMatches:c=Te.findAllMatches,location:u=Te.location,threshold:d=Te.threshold,distance:m=Te.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:a,includeMatches:n,minMatchCharLength:o,findAllMatches:c,ignoreLocation:i,location:u,threshold:d,distance:m},r=s?r:r.toLowerCase(),r=a?ds(r):r,this.pattern=r,this.query=Zm(this.pattern,this.options)}static condition(r,s){return s.useExtendedSearch}searchIn(r){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:a,isCaseSensitive:n,ignoreDiacritics:o}=this.options;r=n?r:r.toLowerCase(),r=o?ds(r):r;let i=0,c=[],u=0;for(let d=0,m=s.length;d<m;d+=1){const h=s[d];c.length=0,i=0;for(let p=0,g=h.length;p<g;p+=1){const f=h[p],{isMatch:x,indices:b,score:N}=f.search(r);if(x){if(i+=1,u+=N,a){const j=f.constructor.type;ep.has(j)?c=[...c,...b]:c.push(b)}}else{u=0,i=0,c.length=0;break}}if(i){let p={isMatch:!0,score:u/i};return a&&(p.indices=c),p}}return{isMatch:!1,score:1}}}const da=[];function rp(...t){da.push(...t)}function ua(t,r){for(let s=0,a=da.length;s<a;s+=1){let n=da[s];if(n.condition(t,r))return new n(t,r)}return new di(t,r)}const us={AND:"$and",OR:"$or"},ma={PATH:"$path",PATTERN:"$val"},pa=t=>!!(t[us.AND]||t[us.OR]),sp=t=>!!t[ma.PATH],ap=t=>!_t(t)&&oi(t)&&!pa(t),Dn=t=>({[us.AND]:Object.keys(t).map(r=>({[r]:t[r]}))});function pi(t,r,{auto:s=!0}={}){const a=n=>{let o=Object.keys(n);const i=sp(n);if(!i&&o.length>1&&!pa(n))return a(Dn(n));if(ap(n)){const u=i?n[ma.PATH]:o[0],d=i?n[ma.PATTERN]:n[u];if(!Et(d))throw new Error(Am(u));const m={keyId:la(u),pattern:d};return s&&(m.searcher=ua(d,r)),m}let c={children:[],operator:o[0]};return o.forEach(u=>{const d=n[u];_t(d)&&d.forEach(m=>{c.children.push(a(m))})}),c};return pa(t)||(t=Dn(t)),a(t)}function np(t,{ignoreFieldNorm:r=Te.ignoreFieldNorm}){t.forEach(s=>{let a=1;s.matches.forEach(({key:n,norm:o,score:i})=>{const c=n?n.weight:null;a*=Math.pow(i===0&&c?Number.EPSILON:i,(c||1)*(r?1:o))}),s.score=a})}function op(t,r){const s=t.matches;r.matches=[],xt(s)&&s.forEach(a=>{if(!xt(a.indices)||!a.indices.length)return;const{indices:n,value:o}=a;let i={indices:n,value:o};a.key&&(i.key=a.key.src),a.idx>-1&&(i.refIndex=a.idx),r.matches.push(i)})}function ip(t,r){r.score=t.score}function lp(t,r,{includeMatches:s=Te.includeMatches,includeScore:a=Te.includeScore}={}){const n=[];return s&&n.push(op),a&&n.push(ip),t.map(o=>{const{idx:i}=o,c={item:r[i],refIndex:i};return n.length&&n.forEach(u=>{u(o,c)}),c})}class yr{constructor(r,s={},a){this.options={...Te,...s},this.options.useExtendedSearch,this._keyStore=new Lm(this.options.keys),this.setCollection(r,a)}setCollection(r,s){if(this._docs=r,s&&!(s instanceof La))throw new Error(Tm);this._myIndex=s||ci(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(r){xt(r)&&(this._docs.push(r),this._myIndex.add(r))}remove(r=()=>!1){const s=[];for(let a=0,n=this._docs.length;a<n;a+=1){const o=this._docs[a];r(o,a)&&(this.removeAt(a),a-=1,n-=1,s.push(o))}return s}removeAt(r){this._docs.splice(r,1),this._myIndex.removeAt(r)}getIndex(){return this._myIndex}search(r,{limit:s=-1}={}){const{includeMatches:a,includeScore:n,shouldSort:o,sortFn:i,ignoreFieldNorm:c}=this.options;let u=Et(r)?Et(this._docs[0])?this._searchStringList(r):this._searchObjectList(r):this._searchLogical(r);return np(u,{ignoreFieldNorm:c}),o&&u.sort(i),ni(s)&&s>-1&&(u=u.slice(0,s)),lp(u,this._docs,{includeMatches:a,includeScore:n})}_searchStringList(r){const s=ua(r,this.options),{records:a}=this._myIndex,n=[];return a.forEach(({v:o,i,n:c})=>{if(!xt(o))return;const{isMatch:u,score:d,indices:m}=s.searchIn(o);u&&n.push({item:o,idx:i,matches:[{score:d,value:o,norm:c,indices:m}]})}),n}_searchLogical(r){const s=pi(r,this.options),a=(c,u,d)=>{if(!c.children){const{keyId:h,searcher:p}=c,g=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(u,h),searcher:p});return g&&g.length?[{idx:d,item:u,matches:g}]:[]}const m=[];for(let h=0,p=c.children.length;h<p;h+=1){const g=c.children[h],f=a(g,u,d);if(f.length)m.push(...f);else if(c.operator===us.AND)return[]}return m},n=this._myIndex.records,o={},i=[];return n.forEach(({$:c,i:u})=>{if(xt(c)){let d=a(s,c,u);d.length&&(o[u]||(o[u]={idx:u,item:c,matches:[]},i.push(o[u])),d.forEach(({matches:m})=>{o[u].matches.push(...m)}))}}),i}_searchObjectList(r){const s=ua(r,this.options),{keys:a,records:n}=this._myIndex,o=[];return n.forEach(({$:i,i:c})=>{if(!xt(i))return;let u=[];a.forEach((d,m)=>{u.push(...this._findMatches({key:d,value:i[m],searcher:s}))}),u.length&&o.push({idx:c,item:i,matches:u})}),o}_findMatches({key:r,value:s,searcher:a}){if(!xt(s))return[];let n=[];if(_t(s))s.forEach(({v:o,i,n:c})=>{if(!xt(o))return;const{isMatch:u,score:d,indices:m}=a.searchIn(o);u&&n.push({score:d,key:r,value:o,idx:i,norm:c,indices:m})});else{const{v:o,n:i}=s,{isMatch:c,score:u,indices:d}=a.searchIn(o);c&&n.push({score:u,key:r,value:o,norm:i,indices:d})}return n}}yr.version="7.1.0";yr.createIndex=ci;yr.parseIndex=Bm;yr.config=Te;yr.parseQuery=pi;rp(tp);const cp=150,xi=t=>`command_history_${t}`,Gs=t=>{const r=ot.getItem(xi(t));if(!r)return{};try{return JSON.parse(r)}catch(s){return console.error("Error parsing command history:",s),{}}},dp=(t,r)=>{ot.setItem(xi(t),JSON.stringify(r))},Ln=t=>!!t&&typeof t.then=="function";function up({selectedProject:t,input:r,setInput:s,textareaRef:a,onExecuteCommand:n}){const[o,i]=l.useState([]),[c,u]=l.useState([]),[d,m]=l.useState(!1),[h,p]=l.useState(""),[g,f]=l.useState(-1),[x,b]=l.useState(-1),N=l.useRef(null),j=l.useCallback(()=>{N.current!==null&&(window.clearTimeout(N.current),N.current=null)},[]),y=l.useCallback(()=>{m(!1),b(-1),p(""),f(-1),j()},[j]);l.useEffect(()=>{(async()=>{if(!t){i([]),u([]);return}try{const O=await Me("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:t.fullPath||t.path})});if(!O.ok)throw new Error("Failed to fetch commands");const H=await O.json(),R=[...(H.builtIn||[]).map(J=>({...J,type:"built-in"})),...(H.custom||[]).map(J=>({...J,type:"custom"}))],A=Gs(t.name),z=[...R].sort((J,re)=>{const G=A[J.name]||0;return(A[re.name]||0)-G});i(z)}catch(O){console.error("Error fetching slash commands:",O),i([])}})()},[t]),l.useEffect(()=>{d||f(-1)},[d]);const k=l.useMemo(()=>o.length?new yr(o,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[o]);l.useEffect(()=>{if(!h){u(o);return}if(!k){u([]);return}const S=k.search(h);u(S.map(O=>O.item))},[h,o,k]);const I=l.useMemo(()=>{if(!t||o.length===0)return[];const S=Gs(t.name);return o.map(O=>({...O,usageCount:S[O.name]||0})).filter(O=>O.usageCount>0).sort((O,H)=>H.usageCount-O.usageCount).slice(0,5)},[t,o]),D=l.useCallback(S=>{if(!t)return;const O=Gs(t.name);O[S.name]=(O[S.name]||0)+1,dp(t.name,O)},[t]),C=l.useCallback(S=>{const O=r.slice(0,x),H=r.slice(x),R=H.indexOf(" "),A=R!==-1?H.slice(R):"",z=`${O}${S.name} ${A}`;s(z),y();const J=n(S);Ln(J)&&J.catch(()=>{})},[r,x,s,y,n]),v=l.useCallback((S,O,H)=>{if(!S||!t)return;if(H){f(O);return}D(S);const R=n(S);Ln(R)?(R.then(()=>{y()}),R.catch(()=>{})):y()},[t,D,n,y]),E=l.useCallback(()=>{var O;const S=!d;m(S),p(""),f(-1),S&&u(o),(O=a.current)==null||O.focus()},[d,o,a]),T=l.useCallback((S,O)=>{if(!S.trim()){y();return}const H=S.slice(0,O);if((H.match(/```/g)||[]).length%2===1){y();return}const z=/(^|\s)\/(\S*)$/,J=H.match(z);if(!J){y();return}const re=(J.index||0)+J[1].length,G=J[2];b(re),m(!0),f(-1),j(),N.current=window.setTimeout(()=>{p(G)},cp)},[y,j]),W=l.useCallback(S=>d?c.length?S.key==="ArrowDown"?(S.preventDefault(),f(O=>O<c.length-1?O+1:0),!0):S.key==="ArrowUp"?(S.preventDefault(),f(O=>O>0?O-1:c.length-1),!0):S.key==="Tab"||S.key==="Enter"?(S.preventDefault(),g>=0?C(c[g]):c.length>0&&C(c[0]),!0):S.key==="Escape"?(S.preventDefault(),y(),!0):!1:S.key==="Escape"?(S.preventDefault(),y(),!0):!1:!1,[d,c,y,C,g]);return l.useEffect(()=>()=>{j()},[j]),{slashCommands:o,slashCommandsCount:o.length,filteredCommands:c,frequentCommands:I,commandQuery:h,showCommandMenu:d,selectedCommandIndex:g,resetCommandMenuState:y,handleCommandSelect:v,handleToggleCommandMenu:E,handleCommandInputChange:T,handleCommandMenuKeyDown:W}}const mp=()=>({preventDefault:()=>{}}),pp=t=>!!(t&&t.startsWith("new-session-"));function xp({selectedProject:t,selectedSession:r,currentSessionId:s,provider:a,permissionMode:n,cyclePermissionMode:o,cursorModel:i,claudeModel:c,codexModel:u,isLoading:d,canAbortSession:m,tokenBudget:h,sendMessage:p,sendByCtrlEnter:g,onSessionActive:f,onInputFocusChange:x,onFileOpen:b,onShowSettings:N,pendingViewSessionRef:j,scrollToBottom:y,setChatMessages:k,setSessionMessages:I,setIsLoading:D,setCanAbortSession:C,setClaudeStatus:v,setIsUserScrolledUp:E,setPendingPermissionRequests:T}){const[W,S]=l.useState(()=>typeof window<"u"&&t&&ot.getItem(`draft_input_${t.name}`)||""),[O,H]=l.useState([]),[R,A]=l.useState(new Map),[z,J]=l.useState(new Map),[re,G]=l.useState(!1),[ie,$]=l.useState("none"),{confirm:Z,dialogProps:te,ConfirmDialog:Q}=Ea(),_=l.useRef(null),F=l.useRef(null),q=l.useRef(null),U=l.useRef(W),B=l.useCallback(le=>{const{action:ue,data:ce}=le;switch(ue){case"clear":k([]),I==null||I([]);break;case"help":k(we=>[...we,{type:"assistant",content:ce.content,timestamp:Date.now()}]);break;case"model":k(we=>[...we,{type:"assistant",content:`**Current Model**: ${ce.current.model}
149
149
 
150
150
  **Available Models**:
151
151
 
@@ -167,7 +167,7 @@ Cursor: ${ce.available.cursor.join(", ")}`,timestamp:Date.now()}]);break;case"co
167
167
  - Node.js: ${ce.nodeVersion}
168
168
  - Platform: ${ce.platform}`;k(He=>[...He,{type:"assistant",content:we,timestamp:Date.now()}]);break}case"memory":ce.error?k(we=>[...we,{type:"assistant",content:`⚠️ ${ce.message}`,timestamp:Date.now()}]):(k(we=>[...we,{type:"assistant",content:`📝 ${ce.message}
169
169
 
170
- Path: \`${ce.path}\``,timestamp:Date.now()}]),ce.exists&&b&&b(ce.path));break;case"config":N==null||N();break;case"rewind":ce.error?k(we=>[...we,{type:"assistant",content:`⚠️ ${ce.message}`,timestamp:Date.now()}]):(k(we=>we.slice(0,-ce.steps*2)),k(we=>[...we,{type:"assistant",content:`⏪ ${ce.message}`,timestamp:Date.now()}]));break}},[b,N,k,I]),ee=l.useCallback(async le=>{const{content:ue,hasBashCommands:ce}=le;if(ce&&!await Z({title:"Execute Bash Commands",message:"This command contains bash commands that will be executed. Do you want to proceed?",variant:"warning",confirmLabel:"Execute",cancelLabel:"Cancel"})){k(Qe=>[...Qe,{type:"assistant",content:"❌ Command execution cancelled",timestamp:Date.now()}]);return}const we=ue||"";S(we),U.current=we,setTimeout(()=>{q.current&&q.current(up())},0)},[Z,k]),V=l.useCallback(async le=>{if(!(!le||!t))try{const ue=W.match(new RegExp(`${Fo(le.name)}\\s*(.*)`)),ce=ue&&ue[1]?ue[1].trim().split(/\s+/):[],we={projectPath:t.fullPath||t.path,projectName:t.name,sessionId:s,provider:a,model:a==="cursor"?i:a==="codex"?u:c,tokenUsage:h},He=await Me("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:le.name,commandPath:le.path,args:ce,context:we})});if(!He.ok){let Xe=`Failed to execute command (${He.status})`;try{const ut=await He.json();Xe=(ut==null?void 0:ut.message)||(ut==null?void 0:ut.error)||Xe}catch{}throw new Error(Xe)}const Qe=await He.json();Qe.type==="builtin"?(B(Qe),S(""),U.current=""):Qe.type==="custom"&&await ee(Qe)}catch(ue){const ce=ue instanceof Error?ue.message:"Unknown error";k(we=>[...we,{type:"assistant",content:`Error executing command: ${ce}`,timestamp:Date.now()}])}},[c,u,s,i,B,ee,W,a,t,k,h]),{slashCommandsCount:w,filteredCommands:M,frequentCommands:Y,commandQuery:se,showCommandMenu:de,selectedCommandIndex:je,resetCommandMenuState:ge,handleCommandSelect:Re,handleToggleCommandMenu:Ne,handleCommandInputChange:De,handleCommandMenuKeyDown:Ue}=dp({selectedProject:t,input:W,setInput:S,textareaRef:_,onExecuteCommand:V}),{showFileDropdown:_e,filteredFiles:L,selectedFileIndex:K,renderInputWithMentions:pe,selectFile:ye,setCursorPosition:Ie,handleFileMentionsKeyDown:Fe}=wm({selectedProject:t,input:W,setInput:S,textareaRef:_}),Se=l.useCallback(le=>{!F.current||!le||(F.current.scrollTop=le.scrollTop,F.current.scrollLeft=le.scrollLeft)},[]),Oe=l.useCallback(le=>{const ue=le.filter(ce=>{try{if(!ce||typeof ce!="object"||!ce.type||!ce.type.startsWith("image/"))return!1;if(!ce.size||ce.size>5242880){const we=ce.name||"Unknown file";return J(He=>{const Qe=new Map(He);return Qe.set(we,"File too large (max 5MB)"),Qe}),!1}return!0}catch{return!1}});ue.length>0&&H(ce=>[...ce,...ue].slice(0,5))},[]),ne=l.useCallback(le=>{const ue=Array.from(le.clipboardData.items);if(ue.forEach(ce=>{if(!ce.type.startsWith("image/"))return;const we=ce.getAsFile();we&&Oe([we])}),ue.length===0&&le.clipboardData.files.length>0){const we=Array.from(le.clipboardData.files).filter(He=>He.type.startsWith("image/"));we.length>0&&Oe(we)}},[Oe]),{getRootProps:fe,getInputProps:Ee,isDragActive:Le,open:Pe}=ri({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:Oe,noClick:!0,noKeyboard:!0}),Ae=l.useCallback(async le=>{le.preventDefault();const ue=U.current;if(!ue.trim()||d||!t)return;if(ue.trimStart().startsWith("!")){const st=ue.trimStart().slice(1).trim();if(!st)return;const tt=t.fullPath||t.path||"";k(zt=>[...zt,{type:"user",content:ue,timestamp:new Date}]),D(!0),p({type:"shell-exec",command:st,cwd:tt}),S(""),U.current="",ge(),H([]),G(!1),_.current&&(_.current.style.height="auto"),ot.removeItem(`draft_input_${t.name}`);return}let ce=ue;const we=Ho.find(st=>st.id===ie);we&&we.prefix&&(ce=`${we.prefix}: ${ue}`);let He=[];if(O.length>0){const st=new FormData;O.forEach(tt=>{st.append("images",tt)});try{const tt=await Me(`/api/projects/${t.name}/upload-images`,{method:"POST",headers:{},body:st});if(!tt.ok)throw new Error("Failed to upload images");He=(await tt.json()).images}catch(tt){const zt=tt instanceof Error?tt.message:"Unknown error";k(or=>[...or,{type:"error",content:`Failed to upload images: ${zt}`,timestamp:new Date}]);return}}const Qe={type:"user",content:ue,images:He,timestamp:new Date};k(st=>[...st,Qe]),D(!0),C(!0),v({text:"Processing",tokens:0,can_interrupt:!0}),E(!1),setTimeout(()=>y(),100);const Xe=s||(r==null?void 0:r.id)||sessionStorage.getItem("cursorSessionId"),ut=Xe||`new-session-${Date.now()}`;!Xe&&!(r!=null&&r.id)&&(typeof window<"u"&&sessionStorage.removeItem("pendingSessionId"),j.current={sessionId:null,startedAt:Date.now()}),f==null||f(ut);const ht=(()=>{try{const st=a==="cursor"?"cursor-tools-settings":a==="codex"?"codex-settings":"claude-settings",tt=ot.getItem(st);if(tt)return JSON.parse(tt)}catch{}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})(),jt=t.fullPath||t.path||"";p(a==="cursor"?{type:"cursor-command",command:ce,sessionId:Xe,options:{cwd:jt,projectPath:jt,sessionId:Xe,resume:!!Xe,model:i,skipPermissions:(ht==null?void 0:ht.skipPermissions)||!1,toolsSettings:ht}}:a==="codex"?{type:"codex-command",command:ce,sessionId:Xe,options:{cwd:jt,projectPath:jt,sessionId:Xe,resume:!!Xe,model:u,permissionMode:n==="plan"?"default":n}}:{type:"claude-command",command:ce,options:{projectPath:jt,cwd:jt,sessionId:Xe,resume:!!Xe,toolsSettings:ht,permissionMode:n,model:c,images:He}}),S(""),U.current="",ge(),H([]),A(new Map),J(new Map),G(!1),$("none"),_.current&&(_.current.style.height="auto"),ot.removeItem(`draft_input_${t.name}`)},[O,c,u,s,i,d,f,j,n,a,ge,y,t,r==null?void 0:r.id,p,C,k,v,D,E,ie]);l.useEffect(()=>{q.current=Ae},[Ae]),l.useEffect(()=>{U.current=W},[W]),l.useEffect(()=>{if(!t)return;const le=ot.getItem(`draft_input_${t.name}`)||"";S(ue=>{const ce=ue===le?ue:le;return U.current=ce,ce})},[t==null?void 0:t.name]),l.useEffect(()=>{t&&(W!==""?ot.setItem(`draft_input_${t.name}`,W):ot.removeItem(`draft_input_${t.name}`))},[W,t]),l.useEffect(()=>{if(!_.current)return;_.current.style.height="auto",_.current.style.height=`${_.current.scrollHeight}px`;const le=parseInt(window.getComputedStyle(_.current).lineHeight),ue=_.current.scrollHeight>le*2;G(ue)},[W]),l.useEffect(()=>{!_.current||W.trim()||(_.current.style.height="auto",G(!1))},[W]);const Ge=l.useCallback(le=>{const ue=le.target.value,ce=le.target.selectionStart;if(S(ue),U.current=ue,Ie(ce),!ue.trim()){le.target.style.height="auto",G(!1),ge();return}De(ue,ce)},[De,ge,Ie]),ae=l.useCallback(le=>{if(!Ue(le)&&!Fe(le)){if(le.key==="Tab"&&!_e&&!de){le.preventDefault(),o();return}if(le.key==="Enter"){if(le.nativeEvent.isComposing)return;((le.ctrlKey||le.metaKey)&&!le.shiftKey||!le.shiftKey&&!le.ctrlKey&&!le.metaKey&&!g)&&(le.preventDefault(),Ae(le))}}},[o,Ue,Fe,Ae,g,de,_e]),be=l.useCallback(le=>{Ie(le.currentTarget.selectionStart)},[Ie]),ze=l.useCallback(le=>{const ue=le.currentTarget;ue.style.height="auto",ue.style.height=`${ue.scrollHeight}px`,Ie(ue.selectionStart),Se(ue);const ce=parseInt(window.getComputedStyle(ue).lineHeight);G(ue.scrollHeight>ce*2)},[Ie,Se]),Ce=l.useCallback(()=>{S(""),U.current="",ge(),_.current&&(_.current.style.height="auto",_.current.focus()),G(!1)},[ge]),Ye=l.useCallback(()=>{var He;if(!m)return;const le=typeof window<"u"?sessionStorage.getItem("pendingSessionId"):null,ue=typeof window<"u"?sessionStorage.getItem("cursorSessionId"):null,we=[s,((He=j.current)==null?void 0:He.sessionId)||null,le,a==="cursor"?ue:null,(r==null?void 0:r.id)||null].find(Qe=>!!Qe&&!mp(Qe))||null;we&&p({type:"abort-session",sessionId:we,provider:a})},[m,s,j,a,r==null?void 0:r.id,p]),lt=l.useCallback(le=>{le.trim()&&S(ue=>{const ce=ue.trim()?`${ue} ${le}`:le;return U.current=ce,setTimeout(()=>{if(!_.current)return;_.current.style.height="auto",_.current.style.height=`${_.current.scrollHeight}px`;const we=parseInt(window.getComputedStyle(_.current).lineHeight);G(_.current.scrollHeight>we*2)},0),ce})},[]),dt=l.useCallback(le=>!le||a!=="claude"?{success:!1}:jd(le.entry),[a]),Tt=l.useCallback((le,ue)=>{const we=(Array.isArray(le)?le:[le]).filter(Boolean);we.length!==0&&(we.forEach(He=>{p({type:"claude-permission-response",requestId:He,allow:!!(ue!=null&&ue.allow),updatedInput:ue==null?void 0:ue.updatedInput,message:ue==null?void 0:ue.message,rememberEntry:ue==null?void 0:ue.rememberEntry})}),T(He=>{const Qe=He.filter(Xe=>!we.includes(Xe.requestId));return Qe.length===0&&v(null),Qe}))},[p,v,T]),[At,wt]=l.useState(!1),Ft=l.useCallback(le=>{wt(le),x==null||x(le)},[x]);return{input:W,setInput:S,textareaRef:_,inputHighlightRef:F,isTextareaExpanded:re,thinkingMode:ie,setThinkingMode:$,slashCommandsCount:w,filteredCommands:M,frequentCommands:Y,commandQuery:se,showCommandMenu:de,selectedCommandIndex:je,resetCommandMenuState:ge,handleCommandSelect:Re,handleToggleCommandMenu:Ne,showFileDropdown:_e,filteredFiles:L,selectedFileIndex:K,renderInputWithMentions:pe,selectFile:ye,attachedImages:O,setAttachedImages:H,uploadingImages:R,imageErrors:z,getRootProps:fe,getInputProps:Ee,isDragActive:Le,openImagePicker:Pe,handleSubmit:Ae,handleInputChange:Ge,handleKeyDown:ae,handlePaste:ne,handleTextareaClick:be,handleTextareaInput:ze,syncInputOverlayScroll:Se,handleClearInput:Ce,handleAbortSession:Ye,handleTranscript:lt,handlePermissionDecision:Tt,handleGrantToolPermission:dt,handleInputFocusChange:Ft,isInputFocused:At,commandConfirmDialogProps:te,CommandConfirmDialog:Q}}const xp=[{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:chat|conversation)\b/i,tab:"chat"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:terminal|shell|console|command line)\b/i,tab:"shell"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:files?|file\s*(?:tree|explorer|browser|manager))\b/i,tab:"files"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:git|version control|source control)\b/i,tab:"git"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:canvas|whiteboard|board|draw)\b/i,tab:"canvas"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:workflows?|automations?|cron)\b/i,tab:"workflows"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:tasks?|task\s*master)\b/i,tab:"tasks"}],gp=[{pattern:/\b(?:run|execute)\s+git\s+status\b/i,action:"git-status"},{pattern:/\b(?:run|execute)\s+git\s+(.+)/i,action:"git-command",extractArgs:t=>t[1]},{pattern:/\b(?:create|start|new)\s+(?:a\s+)?(?:new\s+)?session\b/i,action:"new-session"},{pattern:/\b(?:clear|reset)\s+(?:the\s+)?(?:chat|conversation)\b/i,action:"clear-chat"},{pattern:/\bscroll\s+(?:to\s+)?(?:the\s+)?(?:bottom|down)\b/i,action:"scroll-bottom"},{pattern:/\b(?:stop|cancel|abort)\s+(?:the\s+)?(?:session|response|generation)\b/i,action:"abort"}];function Ln(t){const r=t.trim();if(!r)return null;for(const{pattern:s,tab:a}of xp)if(s.test(r))return{type:"navigate",tab:a};for(const{pattern:s,action:a,extractArgs:n}of gp){const o=r.match(s);if(o)return{type:"action",action:a,args:n?n(o):void 0}}return null}function hp({setActiveTab:t,onChatInput:r,onAbortSession:s,onScrollToBottom:a}){return{routeTranscript:l.useCallback(o=>{const i=Ln(o);if(!i){r(o);return}if(i.type==="navigate"){t(i.tab);return}if(i.type==="action")switch(i.action){case"abort":s==null||s();return;case"scroll-bottom":a==null||a();return;case"new-session":t("chat");return;case"git-status":case"git-command":t("git");return;case"clear-chat":t("chat");return;default:r(o)}},[t,r,s,a]),parseIntent:Ln}}function fp({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,latestMessage:n,onFileOpen:o,onInputFocusChange:i,onSessionActive:c,onSessionInactive:u,onSessionProcessing:d,onSessionNotProcessing:m,processingSessions:h,onReplaceTemporarySession:p,onNavigateToSession:g,onShowSettings:f,autoExpandTools:x,showRawParameters:b,showThinking:N,autoScrollToBottom:j,sendByCtrlEnter:y,externalMessageUpdate:k,onShowAllTasks:I,setActiveTab:D,onArtifactOpen:C}){const{tasksEnabled:v,isTaskMasterInstalled:E}=Lr(),{t:T}=We("chat"),{speak:W}=Go(),S=l.useRef(""),O=l.useRef(null),H=l.useRef(null),R=l.useCallback(()=>{O.current&&(clearTimeout(O.current),O.current=null),S.current=""},[]),{provider:A,setProvider:z,cursorModel:J,setCursorModel:re,claudeModel:G,setClaudeModel:ie,codexModel:$,setCodexModel:Z,permissionMode:te,pendingPermissionRequests:Q,setPendingPermissionRequests:_,cyclePermissionMode:F}=pu({selectedSession:r}),{chatMessages:q,setChatMessages:U,isLoading:B,setIsLoading:ee,currentSessionId:V,setCurrentSessionId:w,sessionMessages:M,setSessionMessages:Y,isLoadingSessionMessages:se,isLoadingMoreMessages:de,hasMoreMessages:je,totalMessages:ge,setIsSystemSessionChange:Re,canAbortSession:Ne,setCanAbortSession:De,isUserScrolledUp:Ue,setIsUserScrolledUp:_e,tokenBudget:L,setTokenBudget:K,visibleMessageCount:pe,visibleMessages:ye,loadEarlierMessages:Ie,loadAllMessages:Fe,allMessagesLoaded:Se,isLoadingAllMessages:Oe,loadAllJustFinished:ne,showLoadAllOverlay:fe,claudeStatus:Ee,setClaudeStatus:Le,createDiff:Pe,scrollContainerRef:Ae,scrollToBottom:Ge,scrollToBottomAndReset:ae,handleScroll:be}=vu({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,autoScrollToBottom:j,externalMessageUpdate:k,processingSessions:h,resetStreamingState:R,pendingViewSessionRef:H}),{input:ze,setInput:Ce,textareaRef:Ye,inputHighlightRef:lt,isTextareaExpanded:dt,thinkingMode:Tt,setThinkingMode:At,slashCommandsCount:wt,filteredCommands:Ft,frequentCommands:le,commandQuery:ue,showCommandMenu:ce,selectedCommandIndex:we,resetCommandMenuState:He,handleCommandSelect:Qe,handleToggleCommandMenu:Xe,showFileDropdown:ut,filteredFiles:Vt,selectedFileIndex:ht,renderInputWithMentions:jt,selectFile:st,attachedImages:tt,setAttachedImages:zt,uploadingImages:or,imageErrors:bs,getRootProps:ys,getInputProps:vs,isDragActive:vr,openImagePicker:ir,handleSubmit:_r,handleInputChange:ks,handleKeyDown:ws,handlePaste:js,handleTextareaClick:Fr,handleTextareaInput:zr,syncInputOverlayScroll:Rr,handleClearInput:Ns,handleAbortSession:lr,handleTranscript:Cs,handlePermissionDecision:Ss,handleGrantToolPermission:Or,handleInputFocusChange:qt,isInputFocused:Br,commandConfirmDialogProps:Es,CommandConfirmDialog:Ts}=pp({selectedProject:t,selectedSession:r,currentSessionId:V,provider:A,permissionMode:te,cyclePermissionMode:F,cursorModel:J,claudeModel:G,codexModel:$,isLoading:B,canAbortSession:Ne,tokenBudget:L,sendMessage:a,sendByCtrlEnter:y,onSessionActive:c,onInputFocusChange:i,onFileOpen:o,onShowSettings:f,pendingViewSessionRef:H,scrollToBottom:Ge,setChatMessages:U,setSessionMessages:Y,setIsLoading:ee,setCanAbortSession:De,setClaudeStatus:Le,setIsUserScrolledUp:_e,setPendingPermissionRequests:_});wu({latestMessage:n,provider:A,selectedProject:t,selectedSession:r,currentSessionId:V,setCurrentSessionId:w,setChatMessages:U,setIsLoading:ee,setCanAbortSession:De,setClaudeStatus:Le,setTokenBudget:K,setIsSystemSessionChange:Re,setPendingPermissionRequests:_,pendingViewSessionRef:H,streamBufferRef:S,streamTimerRef:O,onSessionInactive:u,onSessionProcessing:d,onSessionNotProcessing:m,onReplaceTemporarySession:p,onNavigateToSession:g,onResponseComplete:W});const As=l.useMemo(()=>A==="claude"?Ta.OPTIONS:A==="codex"?Ia.OPTIONS:Aa.OPTIONS,[A]),Is=A==="claude"?G:A==="codex"?$:J,Kt=l.useCallback(et=>{A==="claude"?(ie(et),localStorage.setItem("claude-model",et)):A==="codex"?(Z(et),localStorage.setItem("codex-model",et)):(re(et),localStorage.setItem("cursor-model",et))},[A,ie,Z,re]),{routeTranscript:Wr}=hp({setActiveTab:D||(()=>{}),onChatInput:Cs,onAbortSession:lr,onScrollToBottom:ae});if(l.useEffect(()=>{if(!B||!Ne)return;const et=It=>{It.key!=="Escape"||It.repeat||It.defaultPrevented||(It.preventDefault(),lr())};return document.addEventListener("keydown",et,{capture:!0}),()=>{document.removeEventListener("keydown",et,{capture:!0})}},[Ne,lr,B]),l.useEffect(()=>{const et=(r==null?void 0:r.id)||V;et&&B&&d&&d(et)},[V,B,d,r==null?void 0:r.id]),l.useEffect(()=>()=>{R()},[R]),!t){const et=T(A==="cursor"?"messageTypes.cursor":A==="codex"?"messageTypes.codex":"messageTypes.claude");return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-center text-muted-foreground",children:e.jsx("p",{className:"text-sm",children:T("projectSelection.startChatWithProvider",{provider:et,defaultValue:"Select a project to start chatting with {{provider}}"})})})})}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(Zd,{scrollContainerRef:Ae,onWheel:be,onTouchMove:be,isLoadingSessionMessages:se,chatMessages:q,selectedSession:r,currentSessionId:V,provider:A,setProvider:et=>z(et),textareaRef:Ye,claudeModel:G,setClaudeModel:ie,cursorModel:J,setCursorModel:re,codexModel:$,setCodexModel:Z,tasksEnabled:v,isTaskMasterInstalled:E,onShowAllTasks:I,setInput:Ce,isLoadingMoreMessages:de,hasMoreMessages:je,totalMessages:ge,sessionMessagesCount:M.length,visibleMessageCount:pe,visibleMessages:ye,loadEarlierMessages:Ie,loadAllMessages:Fe,allMessagesLoaded:Se,isLoadingAllMessages:Oe,loadAllJustFinished:ne,showLoadAllOverlay:fe,createDiff:Pe,onFileOpen:o,onShowSettings:f,onGrantToolPermission:Or,autoExpandTools:x,showRawParameters:b,showThinking:N,selectedProject:t,isLoading:B,onArtifactOpen:C}),e.jsx(mu,{pendingPermissionRequests:Q,handlePermissionDecision:Ss,handleGrantToolPermission:Or,claudeStatus:Ee,isLoading:B,onAbortSession:lr,provider:A,permissionMode:te,onModeSwitch:F,thinkingMode:Tt,setThinkingMode:At,tokenBudget:L,currentModel:Is,onModelChange:Kt,modelOptions:As,slashCommandsCount:wt,onToggleCommandMenu:Xe,hasInput:!!ze.trim(),onClearInput:Ns,isUserScrolledUp:Ue,hasMessages:q.length>0,onScrollToBottom:ae,onSubmit:_r,isDragActive:vr,attachedImages:tt,onRemoveImage:et=>zt(It=>It.filter((Ms,P)=>P!==et)),uploadingImages:or,imageErrors:bs,showFileDropdown:ut,filteredFiles:Vt,selectedFileIndex:ht,onSelectFile:st,filteredCommands:Ft,selectedCommandIndex:we,onCommandSelect:Qe,onCloseCommandMenu:He,isCommandMenuOpen:ce,frequentCommands:ue?[]:le,getRootProps:ys,getInputProps:vs,openImagePicker:ir,inputHighlightRef:lt,renderInputWithMentions:jt,textareaRef:Ye,input:ze,onInputChange:ks,onTextareaClick:Fr,onTextareaKeyDown:ws,onTextareaPaste:js,onTextareaScrollSync:Rr,onTextareaInput:zr,onInputFocusChange:qt,isInputFocused:Br,placeholder:T("input.placeholder",{provider:T(A==="cursor"?"messageTypes.cursor":A==="codex"?"messageTypes.codex":"messageTypes.claude")}),isTextareaExpanded:dt,sendByCtrlEnter:y,onTranscript:Wr})]}),e.jsx(md,{}),e.jsx(Ts,{...Es})]})}const bp=it.memo(fp);class jr extends it.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,s){this.setState({error:r,errorInfo:s})}render(){return this.state.hasError?e.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:e.jsxs("div",{className:"bg-destructive/5 border border-destructive/20 rounded-xl p-6 max-w-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-destructive/10 flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"h-4.5 w-4.5 text-destructive",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"text-left",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Something went wrong"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"This section encountered an error"})]})]}),this.props.showDetails&&this.state.error&&e.jsxs("details",{className:"mt-3 text-left",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-mono text-muted-foreground hover:text-foreground transition-colors",children:"Error Details"}),e.jsxs("pre",{className:"mt-2 text-xs bg-muted/50 text-muted-foreground p-3 rounded-lg overflow-auto max-h-40 border border-border/50",children:[this.state.error.toString(),this.state.errorInfo&&this.state.errorInfo.componentStack]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onRetry&&this.props.onRetry()},className:"bg-primary text-primary-foreground px-4 py-2 rounded-lg text-sm font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary/50",children:"Try Again"}),e.jsx("button",{onClick:()=>window.location.reload(),className:"bg-muted text-muted-foreground px-4 py-2 rounded-lg text-sm font-medium hover:bg-muted/80 hover:text-foreground transition-colors",children:"Reload Page"})]})]})}):this.props.children}}function yp(t){const r=l.useRef(!1),s=l.useCallback(o=>{o&&(o.preventDefault(),o.stopPropagation()),t()},[t]),a=l.useCallback(o=>{r.current=!0,s(o),window.setTimeout(()=>{r.current=!1},350)},[s]);return{handleMobileMenuClick:l.useCallback(o=>{if(r.current){o.preventDefault(),o.stopPropagation();return}s(o)},[s]),handleMobileMenuTouchEnd:a}}function xi({onMenuClick:t,compact:r=!1}){const{handleMobileMenuClick:s,handleMobileMenuTouchEnd:a}=yp(t),n=r?"p-1.5 text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent/60 pwa-menu-button":"p-1.5 text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent/60 touch-manipulation active:scale-95 pwa-menu-button flex-shrink-0";return e.jsx("button",{onClick:s,onTouchEnd:a,className:n,"aria-label":"Open menu",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}const Ct=({children:t,content:r,position:s="top",className:a="",delay:n=500})=>{const[o,i]=l.useState(!1),[c,u]=l.useState(null),d=()=>{const g=setTimeout(()=>{i(!0)},n);u(g)},m=()=>{c&&(clearTimeout(c),u(null)),i(!1)},h=()=>{switch(s){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},p=()=>{switch(s){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return r?e.jsxs("div",{className:"relative inline-block",onMouseEnter:d,onMouseLeave:m,children:[t,o&&e.jsxs("div",{className:ke("absolute z-50 px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",h(),a),children:[r,e.jsx("div",{className:ke("absolute w-0 h-0 border-4 border-transparent",p())})]})]}):t},Pn=[{id:"dashboard",labelKey:"Dashboard",icon:Ti},{id:"chat",labelKey:"tabs.chat",icon:va},{id:"canvas",labelKey:"Canvas",icon:Ai},{id:"shell",labelKey:"tabs.shell",icon:vt},{id:"files",labelKey:"tabs.files",icon:mr},{id:"git",labelKey:"tabs.git",icon:br},{id:"workflows",labelKey:"Workflows",icon:tr}],vp={id:"tasks",labelKey:"tabs.tasks",icon:no};function kp({activeTab:t,setActiveTab:r,shouldShowTasksTab:s}){const{t:a}=We(),n=s?[...Pn,vp]:Pn;return e.jsx("div",{className:"inline-flex items-center bg-muted/60 rounded-lg p-[3px] gap-[2px]",children:n.map(o=>{const i=o.icon,c=o.id===t;return e.jsx(Ct,{content:a(o.labelKey),position:"bottom",children:e.jsxs("button",{"data-tour":o.id,onClick:()=>r(o.id),className:`relative flex items-center gap-1.5 px-2.5 py-[5px] text-sm font-medium rounded-md transition-all duration-150 ${c?"bg-background text-foreground shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:text-foreground hover:bg-muted/40"}`,children:[e.jsx(i,{className:"w-3.5 h-3.5",strokeWidth:c?2.2:1.8}),e.jsx("span",{className:"hidden lg:inline",children:a(o.labelKey)})]})},o.id)})})}function wp(t,r,s){return t==="files"?s("mainContent.projectFiles"):t==="git"?s("tabs.git"):t==="tasks"&&r?"TaskMaster":"Project"}function jp(t){return t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session"}function Np({activeTab:t,selectedProject:r,selectedSession:s,shouldShowTasksTab:a}){const{t:n}=We(),o=t==="chat"&&!!s,i=t==="chat"&&!s;return e.jsxs("div",{className:"min-w-0 flex items-center gap-2 flex-1 overflow-x-auto scrollbar-hide",children:[o&&e.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:e.jsx(ft,{provider:s==null?void 0:s.__provider,className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0 flex-1",children:t==="chat"&&s?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground whitespace-nowrap overflow-x-auto scrollbar-hide leading-tight",children:jp(s)}),e.jsx("div",{className:"text-[11px] text-muted-foreground truncate leading-tight",children:r.displayName})]}):i?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground leading-tight",children:n("mainContent.newSession")}),e.jsx("div",{className:"text-xs text-muted-foreground truncate leading-tight",children:r.displayName})]}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground leading-tight",children:wp(t,a,n)}),e.jsx("div",{className:"text-[11px] text-muted-foreground truncate leading-tight",children:r.displayName})]})})]})}function Cp({activeTab:t,setActiveTab:r,selectedProject:s,selectedSession:a,shouldShowTasksTab:n,isMobile:o,onMenuClick:i}){return e.jsx("div",{className:"bg-background border-b border-border/60 px-3 py-1.5 sm:px-4 sm:py-2 pwa-header-safe flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o&&e.jsx(xi,{onMenuClick:i}),e.jsx(Np,{activeTab:t,selectedProject:s,selectedSession:a,shouldShowTasksTab:n})]}),e.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:e.jsx(kp,{activeTab:t,setActiveTab:r,shouldShowTasksTab:n})})]})})}function $n({mode:t,isMobile:r,onMenuClick:s}){const{t:a}=We(),n=t==="loading";return e.jsxs("div",{className:"h-full flex flex-col",children:[r&&e.jsx("div",{className:"bg-background/80 backdrop-blur-sm border-b border-border/50 p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsx(xi,{onMenuClick:s,compact:!0})}),n?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx("div",{className:"w-10 h-10 mx-auto mb-4",children:e.jsx("div",{className:"w-full h-full rounded-full border-[3px] border-muted border-t-primary",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:a("mainContent.loading")}),e.jsx("p",{className:"text-sm",children:a("mainContent.settingUpWorkspace")})]})}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto px-6",children:[e.jsx("div",{className:"w-14 h-14 mx-auto mb-5 bg-muted/50 rounded-2xl flex items-center justify-center",children:e.jsx(mr,{className:"w-7 h-7 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2 text-foreground",children:a("mainContent.chooseProject")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-5 leading-relaxed",children:a("mainContent.selectProjectDescription")}),e.jsx("div",{className:"bg-primary/5 rounded-xl p-3.5 border border-primary/10",children:e.jsxs("p",{className:"text-sm text-primary",children:[e.jsxs("strong",{children:[a("mainContent.tip"),":"]})," ",a(r?"mainContent.createProjectMobile":"mainContent.createProjectDesktop")]})})]})})]})}var Sp=function(t,r){var s={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&r.indexOf(a)<0&&(s[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,a=Object.getOwnPropertySymbols(t);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(t,a[n])&&(s[a[n]]=t[a[n]]);return s};const ct=mo.define({combine:t=>{const r=[];for(let s of t){if(!s)continue;const{create:a,gutters:n}=s,o=Sp(s,["create","gutters"]);r.push(Object.assign(Object.assign({},o),{enabled:!0,gutters:n?n.filter(i=>Object.keys(i).length>0):void 0}))}return Xi(r,{enabled:r.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),pt={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},Ep=Wt.theme({".cm-minimap-overlay-container":{position:"absolute",top:0,height:"100%",width:"100%","&.cm-minimap-overlay-mouse-over":{opacity:0,transition:"visibility 0s linear 300ms, opacity 300ms"},"&.cm-minimap-overlay-mouse-over:hover":{opacity:1,transition:"visibility 0s linear 0ms, opacity 300ms"},"&.cm-minimap-overlay-off":{display:"none"},"& .cm-minimap-overlay":{background:"rgb(121, 121, 121)",opacity:"0.2",position:"absolute",right:0,top:0,width:"100%",transition:"top 0s ease-in 0ms","&:hover":{opacity:"0.3"}},"&.cm-minimap-overlay-active":{opacity:1,visibility:"visible",transition:"visibility 0s linear 0ms, opacity 300ms","& .cm-minimap-overlay":{opacity:"0.4"}}}}),Bt=pt.PixelMultiplier*pt.SizeRatio,Tp=ka.fromClass(class{constructor(t){this.view=t,this._isDragging=!1,t.state.facet(ct).enabled&&this.create(t)}create(t){this.container=pr("div",{class:"cm-minimap-overlay-container"}),this.dom=pr("div",{class:"cm-minimap-overlay"}),this.container.appendChild(this.dom),this.container.addEventListener("mousedown",this.onMouseDown.bind(this)),window.addEventListener("mouseup",this.onMouseUp.bind(this)),window.addEventListener("mousemove",this.onMouseMove.bind(this));const r=t.dom.querySelector(".cm-minimap-inner");r&&r.appendChild(this.container),this.computeShowOverlay(),this.computeHeight(),this.computeTop()}remove(){this.container&&(this.container.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),this.container.remove())}update(t){const r=t.startState.facet(ct).enabled,s=t.state.facet(ct).enabled;if(r&&!s){this.remove();return}!r&&s&&this.create(t.view),s&&(this.computeShowOverlay(),t.geometryChanged&&(this.computeHeight(),this.computeTop()))}computeHeight(){if(!this.dom)return;const t=this.view.dom.clientHeight/Bt;this.dom.style.height=t+"px"}computeTop(){if(!this._isDragging&&this.dom){const{clientHeight:t,scrollHeight:r,scrollTop:s}=this.view.scrollDOM,a=r-t,n=s/Bt,o=t/Bt,i=t-o;let c=s/a;isNaN(c)&&(c=0);const u=i*c,d=Math.min(u,n);this.dom.style.top=d+"px"}}computeShowOverlay(){if(!this.container)return;const{showOverlay:t}=this.view.state.facet(ct);t==="mouse-over"?this.container.classList.add("cm-minimap-overlay-mouse-over"):this.container.classList.remove("cm-minimap-overlay-mouse-over");const{clientHeight:r,scrollHeight:s}=this.view.scrollDOM;r===s?this.container.classList.add("cm-minimap-overlay-off"):this.container.classList.remove("cm-minimap-overlay-off")}onMouseDown(t){if(!this.container||t.button===2)return;const{clientY:r,target:s}=t;if(s===this.dom){this._dragStartY=t.clientY,this._isDragging=!0,this.container.classList.add("cm-minimap-overlay-active");return}const{clientHeight:a,scrollHeight:n,scrollTop:o}=this.view.scrollDOM,i=s.getBoundingClientRect().top,c=(r-i)*Bt,u=o/(n-a),m=(a*Bt-a)*u,h=Math.max(0,o-m);this.view.scrollDOM.scrollTop=h+c-a/2}onMouseUp(t){this._isDragging&&this.container&&(this._dragStartY=void 0,this._isDragging=!1,this.container.classList.remove("cm-minimap-overlay-active"))}onMouseMove(t){if(!this._isDragging||!this.dom)return;if(t.preventDefault(),t.stopPropagation(),!this._dragStartY){this._dragStartY=t.clientY;return}const r=t.clientY-this._dragStartY,s=r<0,a=r>0;this._dragStartY=t.clientY;const n=this.dom.getBoundingClientRect().height,o=this.dom.getBoundingClientRect().y,i=o+n,c=parseFloat(this.dom.style.top),u=this.view.scrollDOM.scrollTop,d=this.view.scrollDOM.clientHeight,m=this.view.scrollDOM.scrollHeight,h=u===0,p=Math.round(u)>=Math.round(m-d);if(h&&s||h&&t.clientY<o||p&&a||p&&t.clientY>i)return;const g=this.view.scrollDOM.scrollHeight,f=this.view.scrollDOM.clientHeight,x=(g-f)/Bt,b=f-f/Bt,N=c+r,j=N/b,y=(g-f)*j,k=N*Bt;this.view.scrollDOM.scrollTop=Math.max(y,k);const I=Math.min(Math.max(0,N),Math.min(b,x));this.dom.style.top=I+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),Ap=[Ep,Tp];class La{constructor(r){this.map=new Map,this.view=r}get(r){return this.map.get(r)}set(r,s){this.map.set(r,s)}}function _n(t){var r;if(!t.facet(ct).enabled)return[];const s=[],a=t.doc.iterLines(),n=tl(t).iter();let o=0;for(a.next();!a.done;){const i=a.value;let c=o,u=c+i.length;for(;n.value&&n.to<c;)n.next();const{from:d,to:m}=n,h=c>=d&&c<m,p=u>d&&u<=m;if(h){let g=(r=s.pop())!==null&&r!==void 0?r:[],f=g.pop();f&&f.folded&&(f.to=m),f&&g.push(f),(!f||!f.folded)&&g.push({from:d,to:m,folded:!0}),p||g.push({from:m,to:u,folded:!1}),s.push(g)}else p?s.push([{from:c,to:d,folded:!1},{from:d,to:m,folded:!0}]):s.push([{from:c,to:u,folded:!1}]);o=u+1,a.next()}return s}const gr=Qi.define({create:t=>_n(t),update:(t,r)=>hs([r])||r.docChanged?_n(r.state):t});function hs(t){return t.find(r=>r.effects.find(s=>s.is(Zi)||s.is(el)))}class Ip extends La{constructor(r){super(r),this.count=void 0}shouldUpdate(r){if(!r.state.facet(ct).enabled)return!1;if(r.docChanged)return!0;for(const s of r.transactions)for(const a of s.effects)if(a.is(sl))return!0;return!!(hs(r.transactions)||this.count===void 0)}update(r){if(!this.shouldUpdate(r))return;this.map.clear();const s=r.state.field(gr);this.count=al(r.state),nl(r.state,(a,n,o)=>{const i=this.findLine(n,s),c=this.findLine(o,s);let u=a.severity;for(let d=i;d<=c;d++){const m=this.get(d);m&&(u=[u,m].sort(this.sort.bind(this)).slice(0,1)[0]),this.set(d,u)}})}drawLine(r,s){const{context:a,lineHeight:n,offsetX:o,offsetY:i}=r,c=this.get(s);c&&(a.globalAlpha=.65,a.beginPath(),a.rect(o,i,a.canvas.width-o,n),a.fillStyle=this.color(c),a.fill())}findLine(r,s){return s.findIndex(n=>{const o=n.slice(0,1)[0],i=n.slice(-1)[0];return!o||!i?!1:o.from<=r&&r<=i.to})+1}color(r){return r==="error"?"#d11":r==="warning"?"orange":"#999"}sort(r,s){return this.score(s)-this.score(r)}score(r){switch(r){case"error":return 3;case"warning":return 2;default:return 1}}}function Mp(t){return new Ip(t)}class Dp extends La{constructor(r){super(r),this.getDrawInfo(),this._themeClasses=r.dom.classList.value}shouldUpdate(r){return r.state.facet(ct).enabled?!!(r.docChanged||r.selectionSet||this._themeClasses!==this.view.dom.classList.value||hs(r.transactions)):!1}update(r){if(!this.shouldUpdate(r))return;this.map.clear(),this._themeClasses!==this.view.dom.classList.value&&(this._drawInfo=void 0,this._themeClasses=this.view.dom.classList.value);const{ranges:s}=r.state.selection;let a=0;for(const[n,o]of r.state.field(gr).entries()){const i=[];let c=0;for(const d of o){do{if(a>=s.length||d.to<s[a].from)continue;if(s[a].from===s[a].to){a++;continue}const m=s[a],h={from:c+Math.max(d.from,m.from)-d.from,to:c+Math.min(d.to,m.to)-d.from,extends:m.to>d.to},p=i.slice(-1)[0];if(p&&p.to===h.from){let{to:g}=h;d.folded&&h.extends?g=h.from+1:d.folded&&!h.extends&&(g=p.to),i[i.length-1]=Object.assign(Object.assign({},p),{to:g,extends:h.extends})}else d.folded||i.push(h);if(h.extends)break;a++}while(a<s.length&&d.to>=s[a].from);c+=d.folded?1:d.to-d.from}if(i.length===0)continue;const u=n+1;this.map.set(u,i)}}drawLine(r,s){let{context:a,lineHeight:n,charWidth:o,offsetX:i,offsetY:c}=r;const u=this.get(s);if(u)for(const d of u){const m=i+d.from*o,h=(d.to-d.from)*o,p=a.canvas.width-m;d.extends&&(a.globalAlpha=.65,a.beginPath(),a.rect(m,c,p,n),a.fillStyle=this.getDrawInfo().backgroundColor,a.fill()),a.globalAlpha=1,a.beginPath(),a.rect(m,c,h,n),a.fillStyle=this.getDrawInfo().backgroundColor,a.fill()}}getDrawInfo(){if(this._drawInfo)return this._drawInfo;const r=document.createElement("span");r.setAttribute("class","cm-selectionBackground"),this.view.dom.appendChild(r);const a={backgroundColor:window.getComputedStyle(r).backgroundColor};return this._drawInfo=a,this.view.dom.removeChild(r),a}}function Lp(t){return new Dp(t)}class Pp extends La{constructor(r){super(r),this._fontInfoMap=new Map,this._themeClasses=new Set(r.dom.classList.values()),r.state.facet(ct).enabled&&this.updateImpl(r.state)}shouldUpdate(r){return!!(r.docChanged||r.state.facet(ct)!==r.startState.facet(ct)||this.themeChanged()||hs(r.transactions))}update(r){this.shouldUpdate(r)&&(this._highlightingCallbackId&&(typeof window.requestIdleCallback<"u"?cancelIdleCallback(this._highlightingCallbackId):clearTimeout(this._highlightingCallbackId)),this.updateImpl(r.state,r.changes))}updateImpl(r,s){var a;this.map.clear(),this._displayText=r.facet(ct).displayText,this.themeChanged()&&this._fontInfoMap.clear();let n;if(this._previousTree&&s){const h=Ra.addTree(this._previousTree),p=[];s.iterChangedRanges((g,f,x,b)=>p.push({fromA:g,toA:f,fromB:x,toB:b})),n=Ra.applyChanges(h,p)}const o=r.doc.toString(),i=(a=r.facet(rl))===null||a===void 0?void 0:a.parser,c=i?i.parse(o,n):void 0;this._previousTree=c;const u={style:h=>ol(r,h)};let d=[];if(c){const h=r.doc.lineAt(this.view.viewport.from).number,p=r.doc.lineAt(this.view.viewport.to).number,g=p-h,f=h/(r.doc.lines-g),{SizeRatio:x,PixelMultiplier:b}=pt,N=g*x*b,j=f*N,y=Math.max(1,Math.floor(h-j)),k=Math.min(p+Math.floor(N-j),r.doc.lines);Oa(c,u,(I,D,C)=>{d.push({from:I,to:D,tags:C})},r.doc.line(y).from,r.doc.line(k).to)}this.updateMapImpl(r,d),d=[];const m=()=>{c&&(Oa(c,u,(h,p,g)=>{d.push({from:h,to:p,tags:g})}),this.updateMapImpl(r,d),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(m):setTimeout(m)}updateMapImpl(r,s){this.map.clear();const a=r.doc.toString(),n=s.values();let o=n.next();for(const[i,c]of r.field(gr).entries()){const u=[];for(const m of c){if(m.from===m.to)continue;if(m.folded){u.push({text:"…",tags:""});continue}let h=m.from;for(;!o.done&&o.value.from<m.to;){const{from:p,to:g,tags:f}=o.value;if(g<h){o=n.next();continue}p>h&&u.push({text:a.slice(h,p),tags:""});const x=Math.max(p,m.from),b=Math.min(g,m.to);if(u.push({text:a.slice(x,b),tags:f}),h=b,g>b)break;o=n.next()}h!==m.to&&u.push({text:a.slice(h,m.to),tags:""})}const d=i+1;this.map.set(d,u)}}measure(r){const{color:s,font:a,lineHeight:n}=this.getFontInfo("");return r.textBaseline="ideographic",r.fillStyle=s,r.font=a,{charWidth:r.measureText("_").width,lineHeight:n}}beforeDraw(){this._fontInfoMap.clear()}drawLine(r,s){const a=this.get(s);if(!a)return;let{context:n,charWidth:o,lineHeight:i,offsetX:c,offsetY:u}=r,d;n.textBaseline="ideographic";for(const m of a){const h=this.getFontInfo(m.tags);switch((!d||d.color!==h.color)&&(n.fillStyle=h.color),(!d||d.font!==h.font)&&(n.font=h.font),d=h,i=Math.max(i,h.lineHeight),this._displayText){case"characters":{n.fillText(m.text,c,u+i),c+=m.text.length*o;break}case"blocks":{const p=/\S+/g;let g;for(;(g=p.exec(m.text))!==null;){const f=c+g.index*o;let x=(p.lastIndex-g.index)*o;if(f>n.canvas.width)break;f+x>n.canvas.width&&(x=n.canvas.width-f);const b=2/pt.SizeRatio,N=i-b;n.fillStyle=h.color,n.globalAlpha=.65,n.beginPath(),n.rect(f,u,x,N),n.fill()}c+=m.text.length*o;break}}}}getFontInfo(r){const s=this._fontInfoMap.get(r);if(s)return s;const a=pr("span",{class:r}),n=pr("div",{class:"cm-line",style:"display: none"},a);this.view.contentDOM.appendChild(n);const o=window.getComputedStyle(a),i=parseFloat(o.lineHeight)/pt.SizeRatio,c={color:o.color,font:`${o.fontStyle} ${o.fontWeight} ${i}px ${o.fontFamily}`,lineHeight:i};return this._fontInfoMap.set(r,c),this.view.contentDOM.removeChild(n),c}themeChanged(){const r=this._themeClasses,s=new Set(this.view.dom.classList.values());if(this._themeClasses=s,!r||(r.delete("cm-focused"),s.delete("cm-focused"),r.size!==s.size))return!0;let a=!0;return r.forEach(n=>{s.has(n)||(a=!1)}),!a}}function $p(t){return new Pp(t)}const gi=4;function _p(t,r,s){const a=t[s];a&&(r.context.fillStyle=a,r.context.globalAlpha=1,r.context.beginPath(),r.context.rect(r.offsetX,r.offsetY,gi,r.lineHeight),r.context.fill())}const Fp=Wt.theme({"&":{height:"100%",overflowY:"auto"},"& .cm-minimap-gutter":{borderRight:0,flexShrink:0,left:"unset",position:"sticky",right:0,top:0},"& .cm-minimap-inner":{height:"100%",position:"absolute",right:0,top:0,overflowY:"hidden","& canvas":{display:"block"}},"& .cm-minimap-box-shadow":{boxShadow:"12px 0px 20px 5px #6c6c6c"}}),Fn=6,zp=ka.fromClass(class{constructor(t){this.view=t,this.text=$p(t),this.selection=Lp(t),this.diagnostic=Mp(t),t.state.facet(Er)&&this.create(t)}create(t){const r=t.state.facet(Er);if(!r)throw Error("Expected nonnull");this.inner=pr("div",{class:"cm-minimap-inner"}),this.canvas=pr("canvas"),this.dom=r.create(t).dom,this.dom.classList.add("cm-gutters"),this.dom.classList.add("cm-minimap-gutter"),this.inner.appendChild(this.canvas),this.dom.appendChild(this.inner),this.view.scrollDOM.insertBefore(this.dom,this.view.contentDOM.nextSibling);for(const s in this.view.state.facet(ct).eventHandlers){const a=this.view.state.facet(ct).eventHandlers[s];a&&this.dom.addEventListener(s,n=>a(n,this.view))}}remove(){this.dom&&this.dom.remove()}update(t){const r=t.startState.facet(Er),s=t.state.facet(Er);if(r&&!s){this.remove();return}!r&&s&&this.create(t.view),s&&(this.text.update(t),this.selection.update(t),this.diagnostic.update(t),this.render())}getWidth(){const t=this.view.dom.clientWidth;if(t<=pt.MaxWidth*Fn){const r=t/(pt.MaxWidth*Fn);return pt.MaxWidth*r}return pt.MaxWidth}render(){if(!this.dom||!this.canvas||!this.inner)return;this.text.beforeDraw(),this.updateBoxShadow(),this.dom.style.width=this.getWidth()+"px",this.canvas.style.maxWidth=this.getWidth()+"px",this.canvas.width=this.getWidth()*pt.PixelMultiplier;const t=this.view.dom.getBoundingClientRect().height;this.inner.style.minHeight=t+"px",this.canvas.height=t*pt.PixelMultiplier,this.canvas.style.height=t+"px";const r=this.canvas.getContext("2d");if(!r)return;r.clearRect(0,0,this.canvas.width,this.canvas.height);const{charWidth:s,lineHeight:a}=this.text.measure(r);let{startIndex:n,endIndex:o,offsetY:i}=this.canvasStartAndEndIndex(r,a);const c=this.view.state.facet(ct).gutters;for(let u=n;u<o;u++){const d=this.view.state.field(gr);if(u>=d.length)break;const m={offsetX:0,offsetY:i,context:r,lineHeight:a,charWidth:s};if(c.length){m.offsetX+=2;for(let h of c)_p(h,m,u+1),m.offsetX+=gi;m.offsetX+=2}this.text.drawLine(m,u+1),this.selection.drawLine(m,u+1),this.diagnostic.drawLine(m,u+1),i+=a}r.restore()}canvasStartAndEndIndex(t,r){let{top:s,bottom:a}=this.view.documentPadding;s/=pt.SizeRatio,a/=pt.SizeRatio;const n=t.canvas.height,{clientHeight:o,scrollHeight:i,scrollTop:c}=this.view.scrollDOM;let u=c/(i-o);isNaN(u)&&(u=0);const d=this.view.state.field(gr).length,m=s+a+d*r,h=Math.max(0,u*(m-n)),p=Math.max(0,s-h),g=Math.round(Math.max(0,h-s)/r),f=Math.round((n-p)/r);return{startIndex:g,endIndex:g+f,offsetY:p}}updateBoxShadow(){if(!this.canvas)return;const{clientWidth:t,scrollWidth:r,scrollLeft:s}=this.view.scrollDOM;t+s<r?this.canvas.classList.add("cm-minimap-box-shadow"):this.canvas.classList.remove("cm-minimap-box-shadow")}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.render())}},provide:t=>Wt.scrollMargins.of(r=>{var s;const a=(s=r.plugin(t))===null||s===void 0?void 0:s.getWidth();return a?{right:a}:null})}),Er=mo.define({combine:t=>{var r;return(r=t.find(s=>s!==null))!==null&&r!==void 0?r:null},enables:t=>[[ct.compute([t],r=>r.facet(t)),Fp,gr,zp,Ap]]}),Rp=l.lazy(()=>kt(()=>import("./MarkdownPreview-DHmk3qzu.js"),__vite__mapDeps([5,2,3,1]))),zn=xl.define({token(t){return t.match(/^#.*/)?"comment":t.sol()&&t.match(/^[A-Za-z_][A-Za-z0-9_.]*(?==)/)?"variableName.definition":t.match(/^=/)?"operator":t.match(/^"(?:[^"\\]|\\.)*"?/)||t.match(/^'(?:[^'\\]|\\.)*'?/)?"string":t.match(/^\$\{[^}]*\}?/)||t.match(/^\$[A-Za-z_][A-Za-z0-9_]*/)?"variableName.special":t.match(/^\d+/)?"number":(t.next(),null)}});function Op({file:t,onClose:r,projectPath:s,isSidebar:a=!1,isExpanded:n=!1,onToggleExpand:o=null,onPopOut:i=null}){const{t:c}=We("codeEditor"),{addToast:u}=hr(),[d,m]=l.useState(""),[h,p]=l.useState(!0),[g,f]=l.useState(!1),[x,b]=l.useState(!1),[N,j]=l.useState(()=>{const F=localStorage.getItem("codeEditorTheme");return F?F==="dark":!0}),[y,k]=l.useState(!1),[I,D]=l.useState(!!t.diffInfo),[C,v]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[E,T]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[W,S]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[O,H]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"12"),[R,A]=l.useState(!1),z=l.useRef(null),J=l.useMemo(()=>{var q;const F=(q=t.name.split(".").pop())==null?void 0:q.toLowerCase();return F==="md"||F==="markdown"},[t.name]),re=l.useMemo(()=>{if(!t.diffInfo||!I||!E)return[];const F={};return[Er.compute(["doc"],q=>{const U=Ds(q),B=(U==null?void 0:U.chunks)||[];return Object.keys(F).forEach(ee=>delete F[ee]),B.forEach(ee=>{const V=q.doc.lineAt(ee.fromB).number,w=q.doc.lineAt(Math.min(ee.toB,q.doc.length)).number;for(let M=V;M<=w;M++)F[M]=N?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[F]}})]},[t.diffInfo,I,E,N]),G=l.useMemo(()=>!t.diffInfo||!I?[]:[ka.fromClass(class{constructor(F){setTimeout(()=>{const q=Ds(F.state),U=(q==null?void 0:q.chunks)||[];if(U.length>0){const B=U[0];F.dispatch({effects:Wt.scrollIntoView(B.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[t.diffInfo,I]),ie=!!(t.diffInfo||a&&i||a&&o),$=l.useMemo(()=>{if(!ie)return[];const F=q=>{const U=document.createElement("div");U.className="cm-editor-toolbar-panel";let B=0;const ee=()=>{const V=t.diffInfo&&I,w=V?Ds(q.state):null,M=(w==null?void 0:w.chunks)||[],Y=M.length;let se='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(se+='<div style="display: flex; align-items: center; gap: 8px;">',V&&(se+=`
170
+ Path: \`${ce.path}\``,timestamp:Date.now()}]),ce.exists&&b&&b(ce.path));break;case"config":N==null||N();break;case"rewind":ce.error?k(we=>[...we,{type:"assistant",content:`⚠️ ${ce.message}`,timestamp:Date.now()}]):(k(we=>we.slice(0,-ce.steps*2)),k(we=>[...we,{type:"assistant",content:`⏪ ${ce.message}`,timestamp:Date.now()}]));break}},[b,N,k,I]),ee=l.useCallback(async le=>{const{content:ue,hasBashCommands:ce}=le;if(ce&&!await Z({title:"Execute Bash Commands",message:"This command contains bash commands that will be executed. Do you want to proceed?",variant:"warning",confirmLabel:"Execute",cancelLabel:"Cancel"})){k(Qe=>[...Qe,{type:"assistant",content:"❌ Command execution cancelled",timestamp:Date.now()}]);return}const we=ue||"";S(we),U.current=we,setTimeout(()=>{q.current&&q.current(mp())},0)},[Z,k]),V=l.useCallback(async le=>{if(!(!le||!t))try{const ue=W.match(new RegExp(`${zo(le.name)}\\s*(.*)`)),ce=ue&&ue[1]?ue[1].trim().split(/\s+/):[],we={projectPath:t.fullPath||t.path,projectName:t.name,sessionId:s,provider:a,model:a==="cursor"?i:a==="codex"?u:c,tokenUsage:h},He=await Me("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:le.name,commandPath:le.path,args:ce,context:we})});if(!He.ok){let Xe=`Failed to execute command (${He.status})`;try{const ut=await He.json();Xe=(ut==null?void 0:ut.message)||(ut==null?void 0:ut.error)||Xe}catch{}throw new Error(Xe)}const Qe=await He.json();Qe.type==="builtin"?(B(Qe),S(""),U.current=""):Qe.type==="custom"&&await ee(Qe)}catch(ue){const ce=ue instanceof Error?ue.message:"Unknown error";k(we=>[...we,{type:"assistant",content:`Error executing command: ${ce}`,timestamp:Date.now()}])}},[c,u,s,i,B,ee,W,a,t,k,h]),{slashCommandsCount:w,filteredCommands:M,frequentCommands:Y,commandQuery:se,showCommandMenu:de,selectedCommandIndex:je,resetCommandMenuState:ge,handleCommandSelect:Re,handleToggleCommandMenu:Ne,handleCommandInputChange:De,handleCommandMenuKeyDown:Ue}=up({selectedProject:t,input:W,setInput:S,textareaRef:_,onExecuteCommand:V}),{showFileDropdown:_e,filteredFiles:L,selectedFileIndex:K,renderInputWithMentions:pe,selectFile:ye,setCursorPosition:Ie,handleFileMentionsKeyDown:Fe}=jm({selectedProject:t,input:W,setInput:S,textareaRef:_}),Se=l.useCallback(le=>{!F.current||!le||(F.current.scrollTop=le.scrollTop,F.current.scrollLeft=le.scrollLeft)},[]),Oe=l.useCallback(le=>{const ue=le.filter(ce=>{try{if(!ce||typeof ce!="object"||!ce.type||!ce.type.startsWith("image/"))return!1;if(!ce.size||ce.size>5242880){const we=ce.name||"Unknown file";return J(He=>{const Qe=new Map(He);return Qe.set(we,"File too large (max 5MB)"),Qe}),!1}return!0}catch{return!1}});ue.length>0&&H(ce=>[...ce,...ue].slice(0,5))},[]),ne=l.useCallback(le=>{const ue=Array.from(le.clipboardData.items);if(ue.forEach(ce=>{if(!ce.type.startsWith("image/"))return;const we=ce.getAsFile();we&&Oe([we])}),ue.length===0&&le.clipboardData.files.length>0){const we=Array.from(le.clipboardData.files).filter(He=>He.type.startsWith("image/"));we.length>0&&Oe(we)}},[Oe]),{getRootProps:fe,getInputProps:Ee,isDragActive:Le,open:Pe}=si({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:Oe,noClick:!0,noKeyboard:!0}),Ae=l.useCallback(async le=>{le.preventDefault();const ue=U.current;if(!ue.trim()||d||!t)return;if(ue.trimStart().startsWith("!")){const st=ue.trimStart().slice(1).trim();if(!st)return;const tt=t.fullPath||t.path||"";k(zt=>[...zt,{type:"user",content:ue,timestamp:new Date}]),D(!0),p({type:"shell-exec",command:st,cwd:tt}),S(""),U.current="",ge(),H([]),G(!1),_.current&&(_.current.style.height="auto"),ot.removeItem(`draft_input_${t.name}`);return}let ce=ue;const we=Go.find(st=>st.id===ie);we&&we.prefix&&(ce=`${we.prefix}: ${ue}`);let He=[];if(O.length>0){const st=new FormData;O.forEach(tt=>{st.append("images",tt)});try{const tt=await Me(`/api/projects/${t.name}/upload-images`,{method:"POST",headers:{},body:st});if(!tt.ok)throw new Error("Failed to upload images");He=(await tt.json()).images}catch(tt){const zt=tt instanceof Error?tt.message:"Unknown error";k(or=>[...or,{type:"error",content:`Failed to upload images: ${zt}`,timestamp:new Date}]);return}}const Qe={type:"user",content:ue,images:He,timestamp:new Date};k(st=>[...st,Qe]),D(!0),C(!0),v({text:"Processing",tokens:0,can_interrupt:!0}),E(!1),setTimeout(()=>y(),100);const Xe=s||(r==null?void 0:r.id)||sessionStorage.getItem("cursorSessionId"),ut=Xe||`new-session-${Date.now()}`;!Xe&&!(r!=null&&r.id)&&(typeof window<"u"&&sessionStorage.removeItem("pendingSessionId"),j.current={sessionId:null,startedAt:Date.now()}),f==null||f(ut);const ht=(()=>{try{const st=a==="cursor"?"cursor-tools-settings":a==="codex"?"codex-settings":"claude-settings",tt=ot.getItem(st);if(tt)return JSON.parse(tt)}catch{}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})(),jt=t.fullPath||t.path||"";p(a==="cursor"?{type:"cursor-command",command:ce,sessionId:Xe,options:{cwd:jt,projectPath:jt,sessionId:Xe,resume:!!Xe,model:i,skipPermissions:(ht==null?void 0:ht.skipPermissions)||!1,toolsSettings:ht}}:a==="codex"?{type:"codex-command",command:ce,sessionId:Xe,options:{cwd:jt,projectPath:jt,sessionId:Xe,resume:!!Xe,model:u,permissionMode:n==="plan"?"default":n}}:{type:"claude-command",command:ce,options:{projectPath:jt,cwd:jt,sessionId:Xe,resume:!!Xe,toolsSettings:ht,permissionMode:n,model:c,images:He}}),S(""),U.current="",ge(),H([]),A(new Map),J(new Map),G(!1),$("none"),_.current&&(_.current.style.height="auto"),ot.removeItem(`draft_input_${t.name}`)},[O,c,u,s,i,d,f,j,n,a,ge,y,t,r==null?void 0:r.id,p,C,k,v,D,E,ie]);l.useEffect(()=>{q.current=Ae},[Ae]),l.useEffect(()=>{U.current=W},[W]),l.useEffect(()=>{if(!t)return;const le=ot.getItem(`draft_input_${t.name}`)||"";S(ue=>{const ce=ue===le?ue:le;return U.current=ce,ce})},[t==null?void 0:t.name]),l.useEffect(()=>{t&&(W!==""?ot.setItem(`draft_input_${t.name}`,W):ot.removeItem(`draft_input_${t.name}`))},[W,t]),l.useEffect(()=>{if(!_.current)return;_.current.style.height="auto",_.current.style.height=`${_.current.scrollHeight}px`;const le=parseInt(window.getComputedStyle(_.current).lineHeight),ue=_.current.scrollHeight>le*2;G(ue)},[W]),l.useEffect(()=>{!_.current||W.trim()||(_.current.style.height="auto",G(!1))},[W]);const Ge=l.useCallback(le=>{const ue=le.target.value,ce=le.target.selectionStart;if(S(ue),U.current=ue,Ie(ce),!ue.trim()){le.target.style.height="auto",G(!1),ge();return}De(ue,ce)},[De,ge,Ie]),ae=l.useCallback(le=>{if(!Ue(le)&&!Fe(le)){if(le.key==="Tab"&&!_e&&!de){le.preventDefault(),o();return}if(le.key==="Enter"){if(le.nativeEvent.isComposing)return;((le.ctrlKey||le.metaKey)&&!le.shiftKey||!le.shiftKey&&!le.ctrlKey&&!le.metaKey&&!g)&&(le.preventDefault(),Ae(le))}}},[o,Ue,Fe,Ae,g,de,_e]),be=l.useCallback(le=>{Ie(le.currentTarget.selectionStart)},[Ie]),ze=l.useCallback(le=>{const ue=le.currentTarget;ue.style.height="auto",ue.style.height=`${ue.scrollHeight}px`,Ie(ue.selectionStart),Se(ue);const ce=parseInt(window.getComputedStyle(ue).lineHeight);G(ue.scrollHeight>ce*2)},[Ie,Se]),Ce=l.useCallback(()=>{S(""),U.current="",ge(),_.current&&(_.current.style.height="auto",_.current.focus()),G(!1)},[ge]),Ye=l.useCallback(()=>{var He;if(!m)return;const le=typeof window<"u"?sessionStorage.getItem("pendingSessionId"):null,ue=typeof window<"u"?sessionStorage.getItem("cursorSessionId"):null,we=[s,((He=j.current)==null?void 0:He.sessionId)||null,le,a==="cursor"?ue:null,(r==null?void 0:r.id)||null].find(Qe=>!!Qe&&!pp(Qe))||null;we&&p({type:"abort-session",sessionId:we,provider:a})},[m,s,j,a,r==null?void 0:r.id,p]),lt=l.useCallback(le=>{le.trim()&&S(ue=>{const ce=ue.trim()?`${ue} ${le}`:le;return U.current=ce,setTimeout(()=>{if(!_.current)return;_.current.style.height="auto",_.current.style.height=`${_.current.scrollHeight}px`;const we=parseInt(window.getComputedStyle(_.current).lineHeight);G(_.current.scrollHeight>we*2)},0),ce})},[]),dt=l.useCallback(le=>!le||a!=="claude"?{success:!1}:Nd(le.entry),[a]),Tt=l.useCallback((le,ue)=>{const we=(Array.isArray(le)?le:[le]).filter(Boolean);we.length!==0&&(we.forEach(He=>{p({type:"claude-permission-response",requestId:He,allow:!!(ue!=null&&ue.allow),updatedInput:ue==null?void 0:ue.updatedInput,message:ue==null?void 0:ue.message,rememberEntry:ue==null?void 0:ue.rememberEntry})}),T(He=>{const Qe=He.filter(Xe=>!we.includes(Xe.requestId));return Qe.length===0&&v(null),Qe}))},[p,v,T]),[At,wt]=l.useState(!1),Ft=l.useCallback(le=>{wt(le),x==null||x(le)},[x]);return{input:W,setInput:S,textareaRef:_,inputHighlightRef:F,isTextareaExpanded:re,thinkingMode:ie,setThinkingMode:$,slashCommandsCount:w,filteredCommands:M,frequentCommands:Y,commandQuery:se,showCommandMenu:de,selectedCommandIndex:je,resetCommandMenuState:ge,handleCommandSelect:Re,handleToggleCommandMenu:Ne,showFileDropdown:_e,filteredFiles:L,selectedFileIndex:K,renderInputWithMentions:pe,selectFile:ye,attachedImages:O,setAttachedImages:H,uploadingImages:R,imageErrors:z,getRootProps:fe,getInputProps:Ee,isDragActive:Le,openImagePicker:Pe,handleSubmit:Ae,handleInputChange:Ge,handleKeyDown:ae,handlePaste:ne,handleTextareaClick:be,handleTextareaInput:ze,syncInputOverlayScroll:Se,handleClearInput:Ce,handleAbortSession:Ye,handleTranscript:lt,handlePermissionDecision:Tt,handleGrantToolPermission:dt,handleInputFocusChange:Ft,isInputFocused:At,commandConfirmDialogProps:te,CommandConfirmDialog:Q}}const gp=[{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:chat|conversation)\b/i,tab:"chat"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:terminal|shell|console|command line)\b/i,tab:"shell"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:files?|file\s*(?:tree|explorer|browser|manager))\b/i,tab:"files"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:git|version control|source control)\b/i,tab:"git"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:canvas|whiteboard|board|draw)\b/i,tab:"canvas"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:workflows?|automations?|cron)\b/i,tab:"workflows"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:tasks?|task\s*master)\b/i,tab:"tasks"}],hp=[{pattern:/\b(?:run|execute)\s+git\s+status\b/i,action:"git-status"},{pattern:/\b(?:run|execute)\s+git\s+(.+)/i,action:"git-command",extractArgs:t=>t[1]},{pattern:/\b(?:create|start|new)\s+(?:a\s+)?(?:new\s+)?session\b/i,action:"new-session"},{pattern:/\b(?:clear|reset)\s+(?:the\s+)?(?:chat|conversation)\b/i,action:"clear-chat"},{pattern:/\bscroll\s+(?:to\s+)?(?:the\s+)?(?:bottom|down)\b/i,action:"scroll-bottom"},{pattern:/\b(?:stop|cancel|abort)\s+(?:the\s+)?(?:session|response|generation)\b/i,action:"abort"}];function Pn(t){const r=t.trim();if(!r)return null;for(const{pattern:s,tab:a}of gp)if(s.test(r))return{type:"navigate",tab:a};for(const{pattern:s,action:a,extractArgs:n}of hp){const o=r.match(s);if(o)return{type:"action",action:a,args:n?n(o):void 0}}return null}function fp({setActiveTab:t,onChatInput:r,onAbortSession:s,onScrollToBottom:a}){return{routeTranscript:l.useCallback(o=>{const i=Pn(o);if(!i){r(o);return}if(i.type==="navigate"){t(i.tab);return}if(i.type==="action")switch(i.action){case"abort":s==null||s();return;case"scroll-bottom":a==null||a();return;case"new-session":t("chat");return;case"git-status":case"git-command":t("git");return;case"clear-chat":t("chat");return;default:r(o)}},[t,r,s,a]),parseIntent:Pn}}function bp({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,latestMessage:n,onFileOpen:o,onInputFocusChange:i,onSessionActive:c,onSessionInactive:u,onSessionProcessing:d,onSessionNotProcessing:m,processingSessions:h,onReplaceTemporarySession:p,onNavigateToSession:g,onShowSettings:f,autoExpandTools:x,showRawParameters:b,showThinking:N,autoScrollToBottom:j,sendByCtrlEnter:y,externalMessageUpdate:k,onShowAllTasks:I,setActiveTab:D,onArtifactOpen:C}){const{tasksEnabled:v,isTaskMasterInstalled:E}=Lr(),{t:T}=We("chat"),{speak:W}=Vo(),S=l.useRef(""),O=l.useRef(null),H=l.useRef(null),R=l.useCallback(()=>{O.current&&(clearTimeout(O.current),O.current=null),S.current=""},[]),{provider:A,setProvider:z,cursorModel:J,setCursorModel:re,claudeModel:G,setClaudeModel:ie,codexModel:$,setCodexModel:Z,permissionMode:te,pendingPermissionRequests:Q,setPendingPermissionRequests:_,cyclePermissionMode:F}=xu({selectedSession:r}),{chatMessages:q,setChatMessages:U,isLoading:B,setIsLoading:ee,currentSessionId:V,setCurrentSessionId:w,sessionMessages:M,setSessionMessages:Y,isLoadingSessionMessages:se,isLoadingMoreMessages:de,hasMoreMessages:je,totalMessages:ge,setIsSystemSessionChange:Re,canAbortSession:Ne,setCanAbortSession:De,isUserScrolledUp:Ue,setIsUserScrolledUp:_e,tokenBudget:L,setTokenBudget:K,visibleMessageCount:pe,visibleMessages:ye,loadEarlierMessages:Ie,loadAllMessages:Fe,allMessagesLoaded:Se,isLoadingAllMessages:Oe,loadAllJustFinished:ne,showLoadAllOverlay:fe,claudeStatus:Ee,setClaudeStatus:Le,createDiff:Pe,scrollContainerRef:Ae,scrollToBottom:Ge,scrollToBottomAndReset:ae,handleScroll:be}=ku({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,autoScrollToBottom:j,externalMessageUpdate:k,processingSessions:h,resetStreamingState:R,pendingViewSessionRef:H}),{input:ze,setInput:Ce,textareaRef:Ye,inputHighlightRef:lt,isTextareaExpanded:dt,thinkingMode:Tt,setThinkingMode:At,slashCommandsCount:wt,filteredCommands:Ft,frequentCommands:le,commandQuery:ue,showCommandMenu:ce,selectedCommandIndex:we,resetCommandMenuState:He,handleCommandSelect:Qe,handleToggleCommandMenu:Xe,showFileDropdown:ut,filteredFiles:Vt,selectedFileIndex:ht,renderInputWithMentions:jt,selectFile:st,attachedImages:tt,setAttachedImages:zt,uploadingImages:or,imageErrors:bs,getRootProps:ys,getInputProps:vs,isDragActive:vr,openImagePicker:ir,handleSubmit:_r,handleInputChange:ks,handleKeyDown:ws,handlePaste:js,handleTextareaClick:Fr,handleTextareaInput:zr,syncInputOverlayScroll:Rr,handleClearInput:Ns,handleAbortSession:lr,handleTranscript:Cs,handlePermissionDecision:Ss,handleGrantToolPermission:Or,handleInputFocusChange:qt,isInputFocused:Br,commandConfirmDialogProps:Es,CommandConfirmDialog:Ts}=xp({selectedProject:t,selectedSession:r,currentSessionId:V,provider:A,permissionMode:te,cyclePermissionMode:F,cursorModel:J,claudeModel:G,codexModel:$,isLoading:B,canAbortSession:Ne,tokenBudget:L,sendMessage:a,sendByCtrlEnter:y,onSessionActive:c,onInputFocusChange:i,onFileOpen:o,onShowSettings:f,pendingViewSessionRef:H,scrollToBottom:Ge,setChatMessages:U,setSessionMessages:Y,setIsLoading:ee,setCanAbortSession:De,setClaudeStatus:Le,setIsUserScrolledUp:_e,setPendingPermissionRequests:_});ju({latestMessage:n,provider:A,selectedProject:t,selectedSession:r,currentSessionId:V,setCurrentSessionId:w,setChatMessages:U,setIsLoading:ee,setCanAbortSession:De,setClaudeStatus:Le,setTokenBudget:K,setIsSystemSessionChange:Re,setPendingPermissionRequests:_,pendingViewSessionRef:H,streamBufferRef:S,streamTimerRef:O,onSessionInactive:u,onSessionProcessing:d,onSessionNotProcessing:m,onReplaceTemporarySession:p,onNavigateToSession:g,onResponseComplete:W});const As=l.useMemo(()=>A==="claude"?Aa.OPTIONS:A==="codex"?Ma.OPTIONS:Ia.OPTIONS,[A]),Is=A==="claude"?G:A==="codex"?$:J,Kt=l.useCallback(et=>{A==="claude"?(ie(et),localStorage.setItem("claude-model",et)):A==="codex"?(Z(et),localStorage.setItem("codex-model",et)):(re(et),localStorage.setItem("cursor-model",et))},[A,ie,Z,re]),{routeTranscript:Wr}=fp({setActiveTab:D||(()=>{}),onChatInput:Cs,onAbortSession:lr,onScrollToBottom:ae});if(l.useEffect(()=>{if(!B||!Ne)return;const et=It=>{It.key!=="Escape"||It.repeat||It.defaultPrevented||(It.preventDefault(),lr())};return document.addEventListener("keydown",et,{capture:!0}),()=>{document.removeEventListener("keydown",et,{capture:!0})}},[Ne,lr,B]),l.useEffect(()=>{const et=(r==null?void 0:r.id)||V;et&&B&&d&&d(et)},[V,B,d,r==null?void 0:r.id]),l.useEffect(()=>()=>{R()},[R]),!t){const et=T(A==="cursor"?"messageTypes.cursor":A==="codex"?"messageTypes.codex":"messageTypes.claude");return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-center text-muted-foreground",children:e.jsx("p",{className:"text-sm",children:T("projectSelection.startChatWithProvider",{provider:et,defaultValue:"Select a project to start chatting with {{provider}}"})})})})}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(eu,{scrollContainerRef:Ae,onWheel:be,onTouchMove:be,isLoadingSessionMessages:se,chatMessages:q,selectedSession:r,currentSessionId:V,provider:A,setProvider:et=>z(et),textareaRef:Ye,claudeModel:G,setClaudeModel:ie,cursorModel:J,setCursorModel:re,codexModel:$,setCodexModel:Z,tasksEnabled:v,isTaskMasterInstalled:E,onShowAllTasks:I,setInput:Ce,isLoadingMoreMessages:de,hasMoreMessages:je,totalMessages:ge,sessionMessagesCount:M.length,visibleMessageCount:pe,visibleMessages:ye,loadEarlierMessages:Ie,loadAllMessages:Fe,allMessagesLoaded:Se,isLoadingAllMessages:Oe,loadAllJustFinished:ne,showLoadAllOverlay:fe,createDiff:Pe,onFileOpen:o,onShowSettings:f,onGrantToolPermission:Or,autoExpandTools:x,showRawParameters:b,showThinking:N,selectedProject:t,isLoading:B,onArtifactOpen:C}),e.jsx(pu,{pendingPermissionRequests:Q,handlePermissionDecision:Ss,handleGrantToolPermission:Or,claudeStatus:Ee,isLoading:B,onAbortSession:lr,provider:A,permissionMode:te,onModeSwitch:F,thinkingMode:Tt,setThinkingMode:At,tokenBudget:L,currentModel:Is,onModelChange:Kt,modelOptions:As,slashCommandsCount:wt,onToggleCommandMenu:Xe,hasInput:!!ze.trim(),onClearInput:Ns,isUserScrolledUp:Ue,hasMessages:q.length>0,onScrollToBottom:ae,onSubmit:_r,isDragActive:vr,attachedImages:tt,onRemoveImage:et=>zt(It=>It.filter((Ms,P)=>P!==et)),uploadingImages:or,imageErrors:bs,showFileDropdown:ut,filteredFiles:Vt,selectedFileIndex:ht,onSelectFile:st,filteredCommands:Ft,selectedCommandIndex:we,onCommandSelect:Qe,onCloseCommandMenu:He,isCommandMenuOpen:ce,frequentCommands:ue?[]:le,getRootProps:ys,getInputProps:vs,openImagePicker:ir,inputHighlightRef:lt,renderInputWithMentions:jt,textareaRef:Ye,input:ze,onInputChange:ks,onTextareaClick:Fr,onTextareaKeyDown:ws,onTextareaPaste:js,onTextareaScrollSync:Rr,onTextareaInput:zr,onInputFocusChange:qt,isInputFocused:Br,placeholder:T("input.placeholder",{provider:T(A==="cursor"?"messageTypes.cursor":A==="codex"?"messageTypes.codex":"messageTypes.claude")}),isTextareaExpanded:dt,sendByCtrlEnter:y,onTranscript:Wr})]}),e.jsx(pd,{}),e.jsx(Ts,{...Es})]})}const yp=it.memo(bp);class jr extends it.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,s){this.setState({error:r,errorInfo:s})}render(){return this.state.hasError?e.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:e.jsxs("div",{className:"bg-destructive/5 border border-destructive/20 rounded-xl p-6 max-w-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-destructive/10 flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"h-4.5 w-4.5 text-destructive",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"text-left",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Something went wrong"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"This section encountered an error"})]})]}),this.props.showDetails&&this.state.error&&e.jsxs("details",{className:"mt-3 text-left",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-mono text-muted-foreground hover:text-foreground transition-colors",children:"Error Details"}),e.jsxs("pre",{className:"mt-2 text-xs bg-muted/50 text-muted-foreground p-3 rounded-lg overflow-auto max-h-40 border border-border/50",children:[this.state.error.toString(),this.state.errorInfo&&this.state.errorInfo.componentStack]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onRetry&&this.props.onRetry()},className:"bg-primary text-primary-foreground px-4 py-2 rounded-lg text-sm font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary/50",children:"Try Again"}),e.jsx("button",{onClick:()=>window.location.reload(),className:"bg-muted text-muted-foreground px-4 py-2 rounded-lg text-sm font-medium hover:bg-muted/80 hover:text-foreground transition-colors",children:"Reload Page"})]})]})}):this.props.children}}function vp(t){const r=l.useRef(!1),s=l.useCallback(o=>{o&&(o.preventDefault(),o.stopPropagation()),t()},[t]),a=l.useCallback(o=>{r.current=!0,s(o),window.setTimeout(()=>{r.current=!1},350)},[s]);return{handleMobileMenuClick:l.useCallback(o=>{if(r.current){o.preventDefault(),o.stopPropagation();return}s(o)},[s]),handleMobileMenuTouchEnd:a}}function gi({onMenuClick:t,compact:r=!1}){const{handleMobileMenuClick:s,handleMobileMenuTouchEnd:a}=vp(t),n=r?"p-1.5 text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent/60 pwa-menu-button":"p-1.5 text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent/60 touch-manipulation active:scale-95 pwa-menu-button flex-shrink-0";return e.jsx("button",{onClick:s,onTouchEnd:a,className:n,"aria-label":"Open menu",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}const Ct=({children:t,content:r,position:s="top",className:a="",delay:n=500})=>{const[o,i]=l.useState(!1),[c,u]=l.useState(null),d=()=>{const g=setTimeout(()=>{i(!0)},n);u(g)},m=()=>{c&&(clearTimeout(c),u(null)),i(!1)},h=()=>{switch(s){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},p=()=>{switch(s){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return r?e.jsxs("div",{className:"relative inline-block",onMouseEnter:d,onMouseLeave:m,children:[t,o&&e.jsxs("div",{className:ke("absolute z-50 px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",h(),a),children:[r,e.jsx("div",{className:ke("absolute w-0 h-0 border-4 border-transparent",p())})]})]}):t},$n=[{id:"dashboard",labelKey:"Dashboard",icon:Ai},{id:"chat",labelKey:"tabs.chat",icon:ka},{id:"canvas",labelKey:"Canvas",icon:Ii},{id:"shell",labelKey:"tabs.shell",icon:vt},{id:"files",labelKey:"tabs.files",icon:mr},{id:"git",labelKey:"tabs.git",icon:br},{id:"workflows",labelKey:"Workflows",icon:tr}],kp={id:"tasks",labelKey:"tabs.tasks",icon:oo};function wp({activeTab:t,setActiveTab:r,shouldShowTasksTab:s}){const{t:a}=We(),n=s?[...$n,kp]:$n;return e.jsx("div",{className:"inline-flex items-center bg-muted/60 rounded-lg p-[3px] gap-[2px]",children:n.map(o=>{const i=o.icon,c=o.id===t;return e.jsx(Ct,{content:a(o.labelKey),position:"bottom",children:e.jsxs("button",{"data-tour":o.id,onClick:()=>r(o.id),className:`relative flex items-center gap-1.5 px-2.5 py-[5px] text-sm font-medium rounded-md transition-all duration-150 ${c?"bg-background text-foreground shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:text-foreground hover:bg-muted/40"}`,children:[e.jsx(i,{className:"w-3.5 h-3.5",strokeWidth:c?2.2:1.8}),e.jsx("span",{className:"hidden lg:inline",children:a(o.labelKey)})]})},o.id)})})}function jp(t,r,s){return t==="files"?s("mainContent.projectFiles"):t==="git"?s("tabs.git"):t==="tasks"&&r?"TaskMaster":"Project"}function Np(t){return t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session"}function Cp({activeTab:t,selectedProject:r,selectedSession:s,shouldShowTasksTab:a}){const{t:n}=We(),o=t==="chat"&&!!s,i=t==="chat"&&!s;return e.jsxs("div",{className:"min-w-0 flex items-center gap-2 flex-1 overflow-x-auto scrollbar-hide",children:[o&&e.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:e.jsx(ft,{provider:s==null?void 0:s.__provider,className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0 flex-1",children:t==="chat"&&s?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground whitespace-nowrap overflow-x-auto scrollbar-hide leading-tight",children:Np(s)}),e.jsx("div",{className:"text-[11px] text-muted-foreground truncate leading-tight",children:r.displayName})]}):i?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground leading-tight",children:n("mainContent.newSession")}),e.jsx("div",{className:"text-xs text-muted-foreground truncate leading-tight",children:r.displayName})]}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground leading-tight",children:jp(t,a,n)}),e.jsx("div",{className:"text-[11px] text-muted-foreground truncate leading-tight",children:r.displayName})]})})]})}function Sp({activeTab:t,setActiveTab:r,selectedProject:s,selectedSession:a,shouldShowTasksTab:n,isMobile:o,onMenuClick:i}){return e.jsx("div",{className:"bg-background border-b border-border/60 px-3 py-1.5 sm:px-4 sm:py-2 pwa-header-safe flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o&&e.jsx(gi,{onMenuClick:i}),e.jsx(Cp,{activeTab:t,selectedProject:s,selectedSession:a,shouldShowTasksTab:n})]}),e.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:e.jsx(wp,{activeTab:t,setActiveTab:r,shouldShowTasksTab:n})})]})})}function _n({mode:t,isMobile:r,onMenuClick:s}){const{t:a}=We(),n=t==="loading";return e.jsxs("div",{className:"h-full flex flex-col",children:[r&&e.jsx("div",{className:"bg-background/80 backdrop-blur-sm border-b border-border/50 p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsx(gi,{onMenuClick:s,compact:!0})}),n?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx("div",{className:"w-10 h-10 mx-auto mb-4",children:e.jsx("div",{className:"w-full h-full rounded-full border-[3px] border-muted border-t-primary",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:a("mainContent.loading")}),e.jsx("p",{className:"text-sm",children:a("mainContent.settingUpWorkspace")})]})}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto px-6",children:[e.jsx("div",{className:"w-14 h-14 mx-auto mb-5 bg-muted/50 rounded-2xl flex items-center justify-center",children:e.jsx(mr,{className:"w-7 h-7 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2 text-foreground",children:a("mainContent.chooseProject")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-5 leading-relaxed",children:a("mainContent.selectProjectDescription")}),e.jsx("div",{className:"bg-primary/5 rounded-xl p-3.5 border border-primary/10",children:e.jsxs("p",{className:"text-sm text-primary",children:[e.jsxs("strong",{children:[a("mainContent.tip"),":"]})," ",a(r?"mainContent.createProjectMobile":"mainContent.createProjectDesktop")]})})]})})]})}var Ep=function(t,r){var s={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&r.indexOf(a)<0&&(s[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,a=Object.getOwnPropertySymbols(t);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(t,a[n])&&(s[a[n]]=t[a[n]]);return s};const ct=po.define({combine:t=>{const r=[];for(let s of t){if(!s)continue;const{create:a,gutters:n}=s,o=Ep(s,["create","gutters"]);r.push(Object.assign(Object.assign({},o),{enabled:!0,gutters:n?n.filter(i=>Object.keys(i).length>0):void 0}))}return Zi(r,{enabled:r.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),pt={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},Tp=Wt.theme({".cm-minimap-overlay-container":{position:"absolute",top:0,height:"100%",width:"100%","&.cm-minimap-overlay-mouse-over":{opacity:0,transition:"visibility 0s linear 300ms, opacity 300ms"},"&.cm-minimap-overlay-mouse-over:hover":{opacity:1,transition:"visibility 0s linear 0ms, opacity 300ms"},"&.cm-minimap-overlay-off":{display:"none"},"& .cm-minimap-overlay":{background:"rgb(121, 121, 121)",opacity:"0.2",position:"absolute",right:0,top:0,width:"100%",transition:"top 0s ease-in 0ms","&:hover":{opacity:"0.3"}},"&.cm-minimap-overlay-active":{opacity:1,visibility:"visible",transition:"visibility 0s linear 0ms, opacity 300ms","& .cm-minimap-overlay":{opacity:"0.4"}}}}),Bt=pt.PixelMultiplier*pt.SizeRatio,Ap=wa.fromClass(class{constructor(t){this.view=t,this._isDragging=!1,t.state.facet(ct).enabled&&this.create(t)}create(t){this.container=pr("div",{class:"cm-minimap-overlay-container"}),this.dom=pr("div",{class:"cm-minimap-overlay"}),this.container.appendChild(this.dom),this.container.addEventListener("mousedown",this.onMouseDown.bind(this)),window.addEventListener("mouseup",this.onMouseUp.bind(this)),window.addEventListener("mousemove",this.onMouseMove.bind(this));const r=t.dom.querySelector(".cm-minimap-inner");r&&r.appendChild(this.container),this.computeShowOverlay(),this.computeHeight(),this.computeTop()}remove(){this.container&&(this.container.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),this.container.remove())}update(t){const r=t.startState.facet(ct).enabled,s=t.state.facet(ct).enabled;if(r&&!s){this.remove();return}!r&&s&&this.create(t.view),s&&(this.computeShowOverlay(),t.geometryChanged&&(this.computeHeight(),this.computeTop()))}computeHeight(){if(!this.dom)return;const t=this.view.dom.clientHeight/Bt;this.dom.style.height=t+"px"}computeTop(){if(!this._isDragging&&this.dom){const{clientHeight:t,scrollHeight:r,scrollTop:s}=this.view.scrollDOM,a=r-t,n=s/Bt,o=t/Bt,i=t-o;let c=s/a;isNaN(c)&&(c=0);const u=i*c,d=Math.min(u,n);this.dom.style.top=d+"px"}}computeShowOverlay(){if(!this.container)return;const{showOverlay:t}=this.view.state.facet(ct);t==="mouse-over"?this.container.classList.add("cm-minimap-overlay-mouse-over"):this.container.classList.remove("cm-minimap-overlay-mouse-over");const{clientHeight:r,scrollHeight:s}=this.view.scrollDOM;r===s?this.container.classList.add("cm-minimap-overlay-off"):this.container.classList.remove("cm-minimap-overlay-off")}onMouseDown(t){if(!this.container||t.button===2)return;const{clientY:r,target:s}=t;if(s===this.dom){this._dragStartY=t.clientY,this._isDragging=!0,this.container.classList.add("cm-minimap-overlay-active");return}const{clientHeight:a,scrollHeight:n,scrollTop:o}=this.view.scrollDOM,i=s.getBoundingClientRect().top,c=(r-i)*Bt,u=o/(n-a),m=(a*Bt-a)*u,h=Math.max(0,o-m);this.view.scrollDOM.scrollTop=h+c-a/2}onMouseUp(t){this._isDragging&&this.container&&(this._dragStartY=void 0,this._isDragging=!1,this.container.classList.remove("cm-minimap-overlay-active"))}onMouseMove(t){if(!this._isDragging||!this.dom)return;if(t.preventDefault(),t.stopPropagation(),!this._dragStartY){this._dragStartY=t.clientY;return}const r=t.clientY-this._dragStartY,s=r<0,a=r>0;this._dragStartY=t.clientY;const n=this.dom.getBoundingClientRect().height,o=this.dom.getBoundingClientRect().y,i=o+n,c=parseFloat(this.dom.style.top),u=this.view.scrollDOM.scrollTop,d=this.view.scrollDOM.clientHeight,m=this.view.scrollDOM.scrollHeight,h=u===0,p=Math.round(u)>=Math.round(m-d);if(h&&s||h&&t.clientY<o||p&&a||p&&t.clientY>i)return;const g=this.view.scrollDOM.scrollHeight,f=this.view.scrollDOM.clientHeight,x=(g-f)/Bt,b=f-f/Bt,N=c+r,j=N/b,y=(g-f)*j,k=N*Bt;this.view.scrollDOM.scrollTop=Math.max(y,k);const I=Math.min(Math.max(0,N),Math.min(b,x));this.dom.style.top=I+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),Ip=[Tp,Ap];class Pa{constructor(r){this.map=new Map,this.view=r}get(r){return this.map.get(r)}set(r,s){this.map.set(r,s)}}function Fn(t){var r;if(!t.facet(ct).enabled)return[];const s=[],a=t.doc.iterLines(),n=rl(t).iter();let o=0;for(a.next();!a.done;){const i=a.value;let c=o,u=c+i.length;for(;n.value&&n.to<c;)n.next();const{from:d,to:m}=n,h=c>=d&&c<m,p=u>d&&u<=m;if(h){let g=(r=s.pop())!==null&&r!==void 0?r:[],f=g.pop();f&&f.folded&&(f.to=m),f&&g.push(f),(!f||!f.folded)&&g.push({from:d,to:m,folded:!0}),p||g.push({from:m,to:u,folded:!1}),s.push(g)}else p?s.push([{from:c,to:d,folded:!1},{from:d,to:m,folded:!0}]):s.push([{from:c,to:u,folded:!1}]);o=u+1,a.next()}return s}const gr=Xi.define({create:t=>Fn(t),update:(t,r)=>hs([r])||r.docChanged?Fn(r.state):t});function hs(t){return t.find(r=>r.effects.find(s=>s.is(el)||s.is(tl)))}class Mp extends Pa{constructor(r){super(r),this.count=void 0}shouldUpdate(r){if(!r.state.facet(ct).enabled)return!1;if(r.docChanged)return!0;for(const s of r.transactions)for(const a of s.effects)if(a.is(al))return!0;return!!(hs(r.transactions)||this.count===void 0)}update(r){if(!this.shouldUpdate(r))return;this.map.clear();const s=r.state.field(gr);this.count=nl(r.state),ol(r.state,(a,n,o)=>{const i=this.findLine(n,s),c=this.findLine(o,s);let u=a.severity;for(let d=i;d<=c;d++){const m=this.get(d);m&&(u=[u,m].sort(this.sort.bind(this)).slice(0,1)[0]),this.set(d,u)}})}drawLine(r,s){const{context:a,lineHeight:n,offsetX:o,offsetY:i}=r,c=this.get(s);c&&(a.globalAlpha=.65,a.beginPath(),a.rect(o,i,a.canvas.width-o,n),a.fillStyle=this.color(c),a.fill())}findLine(r,s){return s.findIndex(n=>{const o=n.slice(0,1)[0],i=n.slice(-1)[0];return!o||!i?!1:o.from<=r&&r<=i.to})+1}color(r){return r==="error"?"#d11":r==="warning"?"orange":"#999"}sort(r,s){return this.score(s)-this.score(r)}score(r){switch(r){case"error":return 3;case"warning":return 2;default:return 1}}}function Dp(t){return new Mp(t)}class Lp extends Pa{constructor(r){super(r),this.getDrawInfo(),this._themeClasses=r.dom.classList.value}shouldUpdate(r){return r.state.facet(ct).enabled?!!(r.docChanged||r.selectionSet||this._themeClasses!==this.view.dom.classList.value||hs(r.transactions)):!1}update(r){if(!this.shouldUpdate(r))return;this.map.clear(),this._themeClasses!==this.view.dom.classList.value&&(this._drawInfo=void 0,this._themeClasses=this.view.dom.classList.value);const{ranges:s}=r.state.selection;let a=0;for(const[n,o]of r.state.field(gr).entries()){const i=[];let c=0;for(const d of o){do{if(a>=s.length||d.to<s[a].from)continue;if(s[a].from===s[a].to){a++;continue}const m=s[a],h={from:c+Math.max(d.from,m.from)-d.from,to:c+Math.min(d.to,m.to)-d.from,extends:m.to>d.to},p=i.slice(-1)[0];if(p&&p.to===h.from){let{to:g}=h;d.folded&&h.extends?g=h.from+1:d.folded&&!h.extends&&(g=p.to),i[i.length-1]=Object.assign(Object.assign({},p),{to:g,extends:h.extends})}else d.folded||i.push(h);if(h.extends)break;a++}while(a<s.length&&d.to>=s[a].from);c+=d.folded?1:d.to-d.from}if(i.length===0)continue;const u=n+1;this.map.set(u,i)}}drawLine(r,s){let{context:a,lineHeight:n,charWidth:o,offsetX:i,offsetY:c}=r;const u=this.get(s);if(u)for(const d of u){const m=i+d.from*o,h=(d.to-d.from)*o,p=a.canvas.width-m;d.extends&&(a.globalAlpha=.65,a.beginPath(),a.rect(m,c,p,n),a.fillStyle=this.getDrawInfo().backgroundColor,a.fill()),a.globalAlpha=1,a.beginPath(),a.rect(m,c,h,n),a.fillStyle=this.getDrawInfo().backgroundColor,a.fill()}}getDrawInfo(){if(this._drawInfo)return this._drawInfo;const r=document.createElement("span");r.setAttribute("class","cm-selectionBackground"),this.view.dom.appendChild(r);const a={backgroundColor:window.getComputedStyle(r).backgroundColor};return this._drawInfo=a,this.view.dom.removeChild(r),a}}function Pp(t){return new Lp(t)}class $p extends Pa{constructor(r){super(r),this._fontInfoMap=new Map,this._themeClasses=new Set(r.dom.classList.values()),r.state.facet(ct).enabled&&this.updateImpl(r.state)}shouldUpdate(r){return!!(r.docChanged||r.state.facet(ct)!==r.startState.facet(ct)||this.themeChanged()||hs(r.transactions))}update(r){this.shouldUpdate(r)&&(this._highlightingCallbackId&&(typeof window.requestIdleCallback<"u"?cancelIdleCallback(this._highlightingCallbackId):clearTimeout(this._highlightingCallbackId)),this.updateImpl(r.state,r.changes))}updateImpl(r,s){var a;this.map.clear(),this._displayText=r.facet(ct).displayText,this.themeChanged()&&this._fontInfoMap.clear();let n;if(this._previousTree&&s){const h=Oa.addTree(this._previousTree),p=[];s.iterChangedRanges((g,f,x,b)=>p.push({fromA:g,toA:f,fromB:x,toB:b})),n=Oa.applyChanges(h,p)}const o=r.doc.toString(),i=(a=r.facet(sl))===null||a===void 0?void 0:a.parser,c=i?i.parse(o,n):void 0;this._previousTree=c;const u={style:h=>il(r,h)};let d=[];if(c){const h=r.doc.lineAt(this.view.viewport.from).number,p=r.doc.lineAt(this.view.viewport.to).number,g=p-h,f=h/(r.doc.lines-g),{SizeRatio:x,PixelMultiplier:b}=pt,N=g*x*b,j=f*N,y=Math.max(1,Math.floor(h-j)),k=Math.min(p+Math.floor(N-j),r.doc.lines);Ba(c,u,(I,D,C)=>{d.push({from:I,to:D,tags:C})},r.doc.line(y).from,r.doc.line(k).to)}this.updateMapImpl(r,d),d=[];const m=()=>{c&&(Ba(c,u,(h,p,g)=>{d.push({from:h,to:p,tags:g})}),this.updateMapImpl(r,d),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(m):setTimeout(m)}updateMapImpl(r,s){this.map.clear();const a=r.doc.toString(),n=s.values();let o=n.next();for(const[i,c]of r.field(gr).entries()){const u=[];for(const m of c){if(m.from===m.to)continue;if(m.folded){u.push({text:"…",tags:""});continue}let h=m.from;for(;!o.done&&o.value.from<m.to;){const{from:p,to:g,tags:f}=o.value;if(g<h){o=n.next();continue}p>h&&u.push({text:a.slice(h,p),tags:""});const x=Math.max(p,m.from),b=Math.min(g,m.to);if(u.push({text:a.slice(x,b),tags:f}),h=b,g>b)break;o=n.next()}h!==m.to&&u.push({text:a.slice(h,m.to),tags:""})}const d=i+1;this.map.set(d,u)}}measure(r){const{color:s,font:a,lineHeight:n}=this.getFontInfo("");return r.textBaseline="ideographic",r.fillStyle=s,r.font=a,{charWidth:r.measureText("_").width,lineHeight:n}}beforeDraw(){this._fontInfoMap.clear()}drawLine(r,s){const a=this.get(s);if(!a)return;let{context:n,charWidth:o,lineHeight:i,offsetX:c,offsetY:u}=r,d;n.textBaseline="ideographic";for(const m of a){const h=this.getFontInfo(m.tags);switch((!d||d.color!==h.color)&&(n.fillStyle=h.color),(!d||d.font!==h.font)&&(n.font=h.font),d=h,i=Math.max(i,h.lineHeight),this._displayText){case"characters":{n.fillText(m.text,c,u+i),c+=m.text.length*o;break}case"blocks":{const p=/\S+/g;let g;for(;(g=p.exec(m.text))!==null;){const f=c+g.index*o;let x=(p.lastIndex-g.index)*o;if(f>n.canvas.width)break;f+x>n.canvas.width&&(x=n.canvas.width-f);const b=2/pt.SizeRatio,N=i-b;n.fillStyle=h.color,n.globalAlpha=.65,n.beginPath(),n.rect(f,u,x,N),n.fill()}c+=m.text.length*o;break}}}}getFontInfo(r){const s=this._fontInfoMap.get(r);if(s)return s;const a=pr("span",{class:r}),n=pr("div",{class:"cm-line",style:"display: none"},a);this.view.contentDOM.appendChild(n);const o=window.getComputedStyle(a),i=parseFloat(o.lineHeight)/pt.SizeRatio,c={color:o.color,font:`${o.fontStyle} ${o.fontWeight} ${i}px ${o.fontFamily}`,lineHeight:i};return this._fontInfoMap.set(r,c),this.view.contentDOM.removeChild(n),c}themeChanged(){const r=this._themeClasses,s=new Set(this.view.dom.classList.values());if(this._themeClasses=s,!r||(r.delete("cm-focused"),s.delete("cm-focused"),r.size!==s.size))return!0;let a=!0;return r.forEach(n=>{s.has(n)||(a=!1)}),!a}}function _p(t){return new $p(t)}const hi=4;function Fp(t,r,s){const a=t[s];a&&(r.context.fillStyle=a,r.context.globalAlpha=1,r.context.beginPath(),r.context.rect(r.offsetX,r.offsetY,hi,r.lineHeight),r.context.fill())}const zp=Wt.theme({"&":{height:"100%",overflowY:"auto"},"& .cm-minimap-gutter":{borderRight:0,flexShrink:0,left:"unset",position:"sticky",right:0,top:0},"& .cm-minimap-inner":{height:"100%",position:"absolute",right:0,top:0,overflowY:"hidden","& canvas":{display:"block"}},"& .cm-minimap-box-shadow":{boxShadow:"12px 0px 20px 5px #6c6c6c"}}),zn=6,Rp=wa.fromClass(class{constructor(t){this.view=t,this.text=_p(t),this.selection=Pp(t),this.diagnostic=Dp(t),t.state.facet(Er)&&this.create(t)}create(t){const r=t.state.facet(Er);if(!r)throw Error("Expected nonnull");this.inner=pr("div",{class:"cm-minimap-inner"}),this.canvas=pr("canvas"),this.dom=r.create(t).dom,this.dom.classList.add("cm-gutters"),this.dom.classList.add("cm-minimap-gutter"),this.inner.appendChild(this.canvas),this.dom.appendChild(this.inner),this.view.scrollDOM.insertBefore(this.dom,this.view.contentDOM.nextSibling);for(const s in this.view.state.facet(ct).eventHandlers){const a=this.view.state.facet(ct).eventHandlers[s];a&&this.dom.addEventListener(s,n=>a(n,this.view))}}remove(){this.dom&&this.dom.remove()}update(t){const r=t.startState.facet(Er),s=t.state.facet(Er);if(r&&!s){this.remove();return}!r&&s&&this.create(t.view),s&&(this.text.update(t),this.selection.update(t),this.diagnostic.update(t),this.render())}getWidth(){const t=this.view.dom.clientWidth;if(t<=pt.MaxWidth*zn){const r=t/(pt.MaxWidth*zn);return pt.MaxWidth*r}return pt.MaxWidth}render(){if(!this.dom||!this.canvas||!this.inner)return;this.text.beforeDraw(),this.updateBoxShadow(),this.dom.style.width=this.getWidth()+"px",this.canvas.style.maxWidth=this.getWidth()+"px",this.canvas.width=this.getWidth()*pt.PixelMultiplier;const t=this.view.dom.getBoundingClientRect().height;this.inner.style.minHeight=t+"px",this.canvas.height=t*pt.PixelMultiplier,this.canvas.style.height=t+"px";const r=this.canvas.getContext("2d");if(!r)return;r.clearRect(0,0,this.canvas.width,this.canvas.height);const{charWidth:s,lineHeight:a}=this.text.measure(r);let{startIndex:n,endIndex:o,offsetY:i}=this.canvasStartAndEndIndex(r,a);const c=this.view.state.facet(ct).gutters;for(let u=n;u<o;u++){const d=this.view.state.field(gr);if(u>=d.length)break;const m={offsetX:0,offsetY:i,context:r,lineHeight:a,charWidth:s};if(c.length){m.offsetX+=2;for(let h of c)Fp(h,m,u+1),m.offsetX+=hi;m.offsetX+=2}this.text.drawLine(m,u+1),this.selection.drawLine(m,u+1),this.diagnostic.drawLine(m,u+1),i+=a}r.restore()}canvasStartAndEndIndex(t,r){let{top:s,bottom:a}=this.view.documentPadding;s/=pt.SizeRatio,a/=pt.SizeRatio;const n=t.canvas.height,{clientHeight:o,scrollHeight:i,scrollTop:c}=this.view.scrollDOM;let u=c/(i-o);isNaN(u)&&(u=0);const d=this.view.state.field(gr).length,m=s+a+d*r,h=Math.max(0,u*(m-n)),p=Math.max(0,s-h),g=Math.round(Math.max(0,h-s)/r),f=Math.round((n-p)/r);return{startIndex:g,endIndex:g+f,offsetY:p}}updateBoxShadow(){if(!this.canvas)return;const{clientWidth:t,scrollWidth:r,scrollLeft:s}=this.view.scrollDOM;t+s<r?this.canvas.classList.add("cm-minimap-box-shadow"):this.canvas.classList.remove("cm-minimap-box-shadow")}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.render())}},provide:t=>Wt.scrollMargins.of(r=>{var s;const a=(s=r.plugin(t))===null||s===void 0?void 0:s.getWidth();return a?{right:a}:null})}),Er=po.define({combine:t=>{var r;return(r=t.find(s=>s!==null))!==null&&r!==void 0?r:null},enables:t=>[[ct.compute([t],r=>r.facet(t)),zp,gr,Rp,Ip]]}),Op=l.lazy(()=>kt(()=>import("./MarkdownPreview-DHmk3qzu.js"),__vite__mapDeps([5,2,3,1]))),Rn=gl.define({token(t){return t.match(/^#.*/)?"comment":t.sol()&&t.match(/^[A-Za-z_][A-Za-z0-9_.]*(?==)/)?"variableName.definition":t.match(/^=/)?"operator":t.match(/^"(?:[^"\\]|\\.)*"?/)||t.match(/^'(?:[^'\\]|\\.)*'?/)?"string":t.match(/^\$\{[^}]*\}?/)||t.match(/^\$[A-Za-z_][A-Za-z0-9_]*/)?"variableName.special":t.match(/^\d+/)?"number":(t.next(),null)}});function Bp({file:t,onClose:r,projectPath:s,isSidebar:a=!1,isExpanded:n=!1,onToggleExpand:o=null,onPopOut:i=null}){const{t:c}=We("codeEditor"),{addToast:u}=hr(),[d,m]=l.useState(""),[h,p]=l.useState(!0),[g,f]=l.useState(!1),[x,b]=l.useState(!1),[N,j]=l.useState(()=>{const F=localStorage.getItem("codeEditorTheme");return F?F==="dark":!0}),[y,k]=l.useState(!1),[I,D]=l.useState(!!t.diffInfo),[C,v]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[E,T]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[W,S]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[O,H]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"12"),[R,A]=l.useState(!1),z=l.useRef(null),J=l.useMemo(()=>{var q;const F=(q=t.name.split(".").pop())==null?void 0:q.toLowerCase();return F==="md"||F==="markdown"},[t.name]),re=l.useMemo(()=>{if(!t.diffInfo||!I||!E)return[];const F={};return[Er.compute(["doc"],q=>{const U=Ds(q),B=(U==null?void 0:U.chunks)||[];return Object.keys(F).forEach(ee=>delete F[ee]),B.forEach(ee=>{const V=q.doc.lineAt(ee.fromB).number,w=q.doc.lineAt(Math.min(ee.toB,q.doc.length)).number;for(let M=V;M<=w;M++)F[M]=N?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[F]}})]},[t.diffInfo,I,E,N]),G=l.useMemo(()=>!t.diffInfo||!I?[]:[wa.fromClass(class{constructor(F){setTimeout(()=>{const q=Ds(F.state),U=(q==null?void 0:q.chunks)||[];if(U.length>0){const B=U[0];F.dispatch({effects:Wt.scrollIntoView(B.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[t.diffInfo,I]),ie=!!(t.diffInfo||a&&i||a&&o),$=l.useMemo(()=>{if(!ie)return[];const F=q=>{const U=document.createElement("div");U.className="cm-editor-toolbar-panel";let B=0;const ee=()=>{const V=t.diffInfo&&I,w=V?Ds(q.state):null,M=(w==null?void 0:w.chunks)||[],Y=M.length;let se='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(se+='<div style="display: flex; align-items: center; gap: 8px;">',V&&(se+=`
171
171
  <span style="font-weight: 500;">${Y>0?`${B+1}/${Y}`:"0"} ${c("toolbar.changes")}</span>
172
172
  <button class="cm-diff-nav-btn cm-diff-nav-prev" title="${c("toolbar.previousChange")}" ${Y===0?"disabled":""}>
173
173
  <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -197,7 +197,7 @@ Path: \`${ce.path}\``,timestamp:Date.now()}]),ce.exists&&b&&b(ce.path));break;ca
197
197
  ${n?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />'}
198
198
  </svg>
199
199
  </button>
200
- `),se+="</div>",se+="</div>",U.innerHTML=se,V){const de=U.querySelector(".cm-diff-nav-prev"),je=U.querySelector(".cm-diff-nav-next");de==null||de.addEventListener("click",()=>{if(M.length===0)return;B=B>0?B-1:M.length-1;const ge=M[B];ge&&q.dispatch({effects:Wt.scrollIntoView(ge.fromB,{y:"center"})}),ee()}),je==null||je.addEventListener("click",()=>{if(M.length===0)return;B=B<M.length-1?B+1:0;const ge=M[B];ge&&q.dispatch({effects:Wt.scrollIntoView(ge.fromB,{y:"center"})}),ee()})}if(t.diffInfo){const de=U.querySelector(".cm-toggle-diff-btn");de==null||de.addEventListener("click",()=>{D(!I)})}if(a&&i){const de=U.querySelector(".cm-popout-btn");de==null||de.addEventListener("click",()=>{i()})}if(a&&o){const de=U.querySelector(".cm-expand-btn");de==null||de.addEventListener("click",()=>{o()})}};return ee(),{top:!0,dom:U,update:ee}};return[il.of(F)]},[t.diffInfo,I,a,n,o,i]),Z=F=>{var B;const q=F.toLowerCase();if(q===".env"||q.startsWith(".env."))return[zn];const U=(B=F.split(".").pop())==null?void 0:B.toLowerCase();switch(U){case"js":case"jsx":case"ts":case"tsx":return[pl({jsx:!0,typescript:U.includes("ts")})];case"py":return[ml()];case"html":case"htm":return[ul()];case"css":case"scss":case"less":return[dl()];case"json":return[cl()];case"md":case"markdown":return[go()];case"env":return[zn];default:return[]}};l.useEffect(()=>{(async()=>{try{if(p(!0),t.diffInfo&&t.diffInfo.new_string!==void 0&&t.diffInfo.old_string!==void 0){m(t.diffInfo.new_string),p(!1);return}const q=await Be.readFile(t.projectName,t.path);if(!q.ok)throw new Error(`Failed to load file: ${q.status} ${q.statusText}`);const U=await q.json();m(U.content)}catch(q){console.error("Error loading file:",q),m(`// Error loading file: ${q.message}
200
+ `),se+="</div>",se+="</div>",U.innerHTML=se,V){const de=U.querySelector(".cm-diff-nav-prev"),je=U.querySelector(".cm-diff-nav-next");de==null||de.addEventListener("click",()=>{if(M.length===0)return;B=B>0?B-1:M.length-1;const ge=M[B];ge&&q.dispatch({effects:Wt.scrollIntoView(ge.fromB,{y:"center"})}),ee()}),je==null||je.addEventListener("click",()=>{if(M.length===0)return;B=B<M.length-1?B+1:0;const ge=M[B];ge&&q.dispatch({effects:Wt.scrollIntoView(ge.fromB,{y:"center"})}),ee()})}if(t.diffInfo){const de=U.querySelector(".cm-toggle-diff-btn");de==null||de.addEventListener("click",()=>{D(!I)})}if(a&&i){const de=U.querySelector(".cm-popout-btn");de==null||de.addEventListener("click",()=>{i()})}if(a&&o){const de=U.querySelector(".cm-expand-btn");de==null||de.addEventListener("click",()=>{o()})}};return ee(),{top:!0,dom:U,update:ee}};return[ll.of(F)]},[t.diffInfo,I,a,n,o,i]),Z=F=>{var B;const q=F.toLowerCase();if(q===".env"||q.startsWith(".env."))return[Rn];const U=(B=F.split(".").pop())==null?void 0:B.toLowerCase();switch(U){case"js":case"jsx":case"ts":case"tsx":return[xl({jsx:!0,typescript:U.includes("ts")})];case"py":return[pl()];case"html":case"htm":return[ml()];case"css":case"scss":case"less":return[ul()];case"json":return[dl()];case"md":case"markdown":return[ho()];case"env":return[Rn];default:return[]}};l.useEffect(()=>{(async()=>{try{if(p(!0),t.diffInfo&&t.diffInfo.new_string!==void 0&&t.diffInfo.old_string!==void 0){m(t.diffInfo.new_string),p(!1);return}const q=await Be.readFile(t.projectName,t.path);if(!q.ok)throw new Error(`Failed to load file: ${q.status} ${q.statusText}`);const U=await q.json();m(U.content)}catch(q){console.error("Error loading file:",q),m(`// Error loading file: ${q.message}
201
201
  // File: ${t.name}
202
202
  // Path: ${t.path}`)}finally{p(!1)}})()},[t,s]);const te=async()=>{f(!0);try{console.log("Saving file:",{projectName:t.projectName,path:t.path,contentLength:d==null?void 0:d.length});const F=await Be.saveFile(t.projectName,t.path,d);if(console.log("Save response:",{status:F.status,ok:F.ok,contentType:F.headers.get("content-type")}),!F.ok){const U=F.headers.get("content-type");if(U&&U.includes("application/json")){const B=await F.json();throw new Error(B.error||`Save failed: ${F.status}`)}else{const B=await F.text();throw console.error("Non-JSON error response:",B),new Error(`Save failed: ${F.status} ${F.statusText}`)}}const q=await F.json();console.log("Save successful:",q),k(!0),setTimeout(()=>k(!1),2e3)}catch(F){console.error("Error saving file:",F),u(`Error saving file: ${F.message}`,"error")}finally{f(!1)}},Q=()=>{const F=new Blob([d],{type:"text/plain"}),q=URL.createObjectURL(F),U=document.createElement("a");U.href=q,U.download=t.name,document.body.appendChild(U),U.click(),document.body.removeChild(U),URL.revokeObjectURL(q)},_=()=>{b(!x)};return l.useEffect(()=>{localStorage.setItem("codeEditorTheme",N?"dark":"light")},[N]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",C.toString())},[C]),l.useEffect(()=>{const F=()=>{const q=localStorage.getItem("codeEditorTheme");q&&j(q==="dark");const U=localStorage.getItem("codeEditorWordWrap");U!==null&&v(U==="true");const B=localStorage.getItem("codeEditorShowMinimap");B!==null&&T(B!=="false");const ee=localStorage.getItem("codeEditorLineNumbers");ee!==null&&S(ee!=="false");const V=localStorage.getItem("codeEditorFontSize");V&&H(V)};return window.addEventListener("storage",F),window.addEventListener("codeEditorSettingsChanged",F),()=>{window.removeEventListener("storage",F),window.removeEventListener("codeEditorSettingsChanged",F)}},[]),l.useEffect(()=>{const F=q=>{(q.ctrlKey||q.metaKey)&&(q.key==="s"?(q.preventDefault(),te()):q.key==="Escape"&&(q.preventDefault(),r()))};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[d]),h?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
203
203
  .code-editor-loading {
@@ -274,8 +274,8 @@ Path: \`${ce.path}\``,timestamp:Date.now()}]),ce.exists&&b&&b(ce.path));break;ca
274
274
  opacity: 0.5;
275
275
  cursor: not-allowed;
276
276
  }
277
- `}),e.jsx("div",{className:a?"w-full h-full flex flex-col":`fixed inset-0 z-[9999] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${x?"md:p-0":""}`,children:e.jsxs("div",{className:a?"bg-background flex flex-col w-full h-full":`bg-background shadow-2xl flex flex-col ${"w-full h-full md:rounded-lg md:shadow-2xl"+(x?" md:w-full md:h-full md:rounded-none":" md:w-full md:max-w-6xl md:h-[80vh] md:max-h-[80vh]")}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border flex-shrink-0 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:t.name}),t.diffInfo&&e.jsx("span",{className:"text-[10px] bg-blue-100 dark:bg-blue-900 text-blue-600 dark:text-blue-300 px-1.5 py-0.5 rounded whitespace-nowrap",children:c("header.showingChanges")})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.path})]})}),e.jsxs("div",{className:"flex items-center gap-0.5 md:gap-1 flex-shrink-0",children:[J&&e.jsx("button",{onClick:()=>A(!R),className:`p-1.5 rounded-md min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center transition-colors ${R?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:c(R?"actions.editMarkdown":"actions.previewMarkdown"),children:R?e.jsx(Ii,{className:"w-4 h-4"}):e.jsx(sr,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>{var F;return(F=window.openSettings)==null?void 0:F.call(window,"appearance")},className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:c("toolbar.settings"),children:e.jsx(Dt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:Q,className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:c("actions.download"),children:e.jsx(oo,{className:"w-4 h-4"})}),e.jsx("button",{onClick:te,disabled:g,className:`p-1.5 rounded-md disabled:opacity-50 flex items-center justify-center transition-colors min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 ${y?"text-green-600 dark:text-green-400 bg-green-50 dark:bg-green-900/30":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:c(y?"actions.saved":g?"actions.saving":"actions.save"),children:y?e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):e.jsx(ts,{className:"w-4 h-4"})}),!a&&e.jsx("button",{onClick:_,className:"hidden md:flex p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:c(x?"actions.exitFullscreen":"actions.fullscreen"),children:x?e.jsx(io,{className:"w-4 h-4"}):e.jsx(ba,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:c("actions.close"),children:e.jsx(Ve,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:R&&J?e.jsx("div",{className:"h-full overflow-y-auto bg-white dark:bg-gray-900",children:e.jsx("div",{className:"max-w-4xl mx-auto px-8 py-6 prose prose-sm dark:prose-invert prose-headings:font-semibold prose-a:text-blue-600 dark:prose-a:text-blue-400 prose-code:text-sm prose-pre:bg-gray-900 prose-img:rounded-lg max-w-none",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"text-muted-foreground text-sm p-4",children:"Loading preview..."}),children:e.jsx(Rp,{content:d})})})}):e.jsx(po,{ref:z,value:d,onChange:m,extensions:[...Z(t.name),...$,...t.diffInfo&&I&&t.diffInfo.old_string!==void 0?[ll({original:t.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...re,...G]:[],...C?[Wt.lineWrapping]:[]],theme:N?xo:void 0,height:"100%",style:{fontSize:`${O}px`,height:"100%"},basicSetup:{lineNumbers:W,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-border bg-muted flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:[c("footer.lines")," ",d.split(`
278
- `).length]}),e.jsxs("span",{children:[c("footer.characters")," ",d.length]})]}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("footer.shortcuts")})]})]})})]})}const Rn=Op;function Bp({editingFile:t,isMobile:r,editorExpanded:s,editorWidth:a,resizeHandleRef:n,onResizeStart:o,onCloseEditor:i,onToggleEditorExpand:c,projectPath:u,fillSpace:d}){const[m,h]=l.useState(!1);if(!t)return null;if(r||m)return e.jsx(Rn,{file:t,onClose:()=>{h(!1),i()},projectPath:u,isSidebar:!1});const p=s||d;return e.jsxs(e.Fragment,{children:[!s&&e.jsx("div",{ref:n,onMouseDown:o,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:e.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),e.jsx("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${p?"flex-1":""}`,style:p?void 0:{width:`${a}px`},children:e.jsx(Rn,{file:t,onClose:i,projectPath:u,isSidebar:!0,isExpanded:s,onToggleExpand:c,onPopOut:()=>h(!0)})})]})}const Wp=l.lazy(()=>kt(()=>import("./vendor-diff-DNQpbhrT.js"),__vite__mapDeps([4,2]))),Up={variables:{dark:{diffViewerBackground:"#0f172a",diffViewerColor:"#e2e8f0",addedBackground:"#064e3b20",addedColor:"#6ee7b7",removedBackground:"#7f1d1d20",removedColor:"#fca5a5",wordAddedBackground:"#065f4630",wordRemovedBackground:"#991b1b30",addedGutterBackground:"#064e3b30",removedGutterBackground:"#7f1d1d30",gutterBackground:"#0f172a",gutterBackgroundDark:"#0f172a",highlightBackground:"#1e293b",highlightGutterBackground:"#1e293b",codeFoldGutterBackground:"#1e293b",codeFoldBackground:"#1e293b",emptyLineBackground:"#0f172a",gutterColor:"#475569",addedGutterColor:"#6ee7b7",removedGutterColor:"#fca5a5",codeFoldContentColor:"#94a3b8",diffViewerTitleBackground:"#1e293b",diffViewerTitleColor:"#e2e8f0",diffViewerTitleBorderColor:"#334155"}},line:{padding:"2px 8px",fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},gutter:{padding:"2px 8px",fontSize:"11px",minWidth:"36px"},contentText:{fontSize:"12px",lineHeight:"20px"}};function Hp(t){var a;const r=((a=t.split(".").pop())==null?void 0:a.toLowerCase())||"";return{ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",html:"html",css:"css",scss:"scss",less:"less",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",xml:"xml",sql:"sql",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",graphql:"graphql",dockerfile:"docker",tf:"hcl",lua:"lua",r:"r",vue:"html",svelte:"html"}[r]||"text"}function Gp({data:t}){const[r,s]=it.useState(!1),a=t.language||Hp(t.filePath||""),n=t.content||"",o=()=>{navigator.clipboard.writeText(n).then(()=>{s(!0),setTimeout(()=>s(!1),1500)}).catch(()=>{})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:[e.jsx("span",{className:"text-xs text-gray-400 font-mono truncate",children:t.filePath||"code"}),e.jsx("button",{onClick:o,className:"text-[10px] px-2 py-0.5 rounded border border-gray-600 text-gray-400 hover:text-gray-200 hover:bg-gray-700 transition-colors",children:r?"Copied":"Copy"})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx(co,{language:a,style:uo,customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",padding:"1rem",minHeight:"100%"},showLineNumbers:!0,lineNumberStyle:{minWidth:"2.5em",paddingRight:"1em",color:"#475569"},children:n})})]})}function Vp({data:t}){const[r,s]=it.useState(!1);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs text-gray-400 font-mono truncate",children:t.filePath||"diff"}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-px rounded flex-shrink-0 ${t.badge==="New"?"bg-green-900/30 text-green-400":"bg-gray-800 text-gray-400"}`,children:t.badge||"Diff"})]}),e.jsx("button",{onClick:()=>s(!r),className:"text-[10px] px-2 py-0.5 rounded border border-gray-600 text-gray-400 hover:text-gray-200 hover:bg-gray-700 transition-colors",children:r?"Unified":"Split"})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"p-4 text-xs text-gray-500",children:"Loading diff viewer..."}),children:e.jsx(Wp,{oldValue:t.oldContent||"",newValue:t.newContent||"",splitView:r,useDarkTheme:!0,styles:Up,hideLineNumbers:!1,showDiffOnly:!0,extraLinesSurroundingDiff:3})})})]})}function qp({data:t}){const[r,s]=it.useState(!1),a=t.output||"",n=()=>{navigator.clipboard.writeText(a).then(()=>{s(!0),setTimeout(()=>s(!1),1500)}).catch(()=>{})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs text-green-400 font-mono",children:"$"}),e.jsx("span",{className:"text-xs text-gray-300 font-mono truncate",children:t.command||"terminal"})]}),e.jsx("button",{onClick:n,className:"text-[10px] px-2 py-0.5 rounded border border-gray-600 text-gray-400 hover:text-gray-200 hover:bg-gray-700 transition-colors",children:r?"Copied":"Copy"})]}),e.jsx("div",{className:"flex-1 overflow-auto bg-gray-950 p-3",children:e.jsx("pre",{className:"text-xs text-gray-300 font-mono whitespace-pre-wrap break-words",children:a})})]})}function Kp({data:t,onFileOpen:r}){const s=t.files||[],a=t.pattern||"";return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs text-gray-400",children:"Search:"}),e.jsx("span",{className:"text-xs text-gray-300 font-mono truncate",children:a})]}),e.jsxs("span",{className:"text-[10px] text-gray-500 flex-shrink-0",children:[s.length," files"]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:s.length===0?e.jsx("div",{className:"p-4 text-xs text-gray-500 text-center",children:"No files found"}):e.jsx("div",{className:"divide-y divide-gray-800/50",children:s.map((n,o)=>e.jsx("button",{onClick:()=>r==null?void 0:r(n),className:"w-full text-left px-3 py-1.5 text-xs font-mono text-blue-400 hover:text-blue-300 hover:bg-gray-800/50 transition-colors truncate",children:n},o))})})]})}function Jp({data:t}){const r=t.html||"";return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:e.jsx("span",{className:"text-xs text-gray-400",children:"Preview"})}),e.jsx("div",{className:"flex-1 overflow-hidden bg-white",children:e.jsx("iframe",{srcDoc:r,sandbox:"allow-scripts",className:"w-full h-full border-0",title:"HTML Preview"})})]})}function Yp({data:t}){const r=t.content||"";return e.jsx("div",{className:"h-full flex flex-col overflow-auto p-4",children:e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert text-sm text-gray-300",children:r})})}function Qp({artifact:t,onFileOpen:r}){switch(t.type){case"code":return e.jsx(Gp,{data:t.data});case"diff":return e.jsx(Vp,{data:t.data});case"terminal":return e.jsx(qp,{data:t.data});case"search":return e.jsx(Kp,{data:t.data,onFileOpen:r});case"html":return e.jsx(Jp,{data:t.data});case"markdown":return e.jsx(Yp,{data:t.data});default:return e.jsx("div",{className:"p-4 text-xs text-gray-500",children:"Unknown artifact type"})}}const On={code:"📄",diff:"±",terminal:"$",search:"🔍",html:"🌐",markdown:"📝"};function Bn({artifacts:t,recentArtifacts:r,activeArtifactId:s,panelWidth:a,panelExpanded:n,resizeHandleRef:o,onResizeStart:i,onSetActive:c,onClose:u,onReopenArtifact:d,onClearHistory:m,onCloseAll:h,onToggleExpand:p,onPinToCanvas:g,onFileOpen:f}){const[x,b]=it.useState(!1);if(t.length===0&&r.length===0)return null;const N=t.find(j=>j.id===s)||t[0];return e.jsxs(e.Fragment,{children:[!n&&e.jsx("div",{ref:o,onMouseDown:i,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:e.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),e.jsxs("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden flex flex-col bg-gray-900 ${n?"flex-1":""}`,style:n?void 0:{width:`${a}px`},children:[e.jsxs("div",{className:"flex items-center bg-gray-800/80 border-b border-gray-700/50 min-h-[36px]",children:[e.jsx("div",{className:"flex-1 flex items-center overflow-x-auto scrollbar-none",children:t.map(j=>e.jsxs("button",{onClick:()=>c(j.id),className:`group/tab flex items-center gap-1.5 px-3 py-2 sm:py-1.5 text-xs border-r border-gray-700/30 whitespace-nowrap transition-colors ${j.id===(N==null?void 0:N.id)?"bg-gray-900 text-gray-200":"text-gray-500 hover:text-gray-300 hover:bg-gray-800/50"}`,children:[e.jsx("span",{className:"text-[10px] opacity-60",children:On[j.type]||"•"}),e.jsx("span",{className:"max-w-[120px] truncate",children:j.title}),e.jsx("button",{onClick:y=>{y.stopPropagation(),u(j.id)},className:"ml-1 opacity-0 group-hover/tab:opacity-100 text-gray-500 hover:text-gray-300 transition-opacity","aria-label":"Close tab",children:"×"})]},j.id))}),e.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 flex-shrink-0",children:[g&&N&&e.jsx("button",{onClick:()=>g(N),className:"p-1 text-gray-500 hover:text-gray-300 transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center",title:"Pin to canvas",children:e.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]})}),r.length>0&&e.jsx("button",{onClick:()=>b(!x),className:`p-1 transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center ${x?"text-gray-200":"text-gray-500 hover:text-gray-300"}`,title:`Recent (${r.length})`,children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("button",{onClick:p,className:"p-1 text-gray-500 hover:text-gray-300 transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center",title:n?"Restore size":"Expand",children:n?e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"})}):e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),e.jsx("button",{onClick:h,className:"p-1 text-gray-500 hover:text-gray-300 transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center",title:"Close all",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:N?e.jsx(Qp,{artifact:N,onFileOpen:f}):t.length===0&&r.length>0?e.jsx("div",{className:"flex items-center justify-center h-full text-xs text-gray-500",children:"No open artifacts. Check recent history below."}):null}),x&&r.length>0&&e.jsxs("div",{className:"border-t border-gray-700/50 max-h-[200px] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 sticky top-0",children:[e.jsxs("span",{className:"text-[10px] font-medium text-gray-400 uppercase tracking-wider",children:["Recent (",r.length,")"]}),e.jsx("button",{onClick:m,className:"text-[10px] text-gray-500 hover:text-gray-300 transition-colors",children:"Clear"})]}),e.jsx("div",{className:"divide-y divide-gray-800/30",children:r.map(j=>e.jsxs("button",{onClick:()=>d(j.id),className:"w-full text-left px-3 py-2.5 sm:py-1.5 text-xs hover:bg-gray-800/50 transition-colors flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] opacity-60 flex-shrink-0",children:On[j.type]||"•"}),e.jsx("span",{className:"text-gray-400 truncate",children:j.title}),e.jsx("span",{className:"ml-auto text-[10px] text-gray-600 flex-shrink-0",children:j.type})]},j.id))})]})]})]})}const Wn=({task:t,onClick:r,showParent:s=!1,className:a=""})=>{const o=(c=>{switch(c){case"done":return{icon:Pr,bgColor:"bg-green-50 dark:bg-green-950",borderColor:"border-green-200 dark:border-green-800",iconColor:"text-green-600 dark:text-green-400",textColor:"text-green-900 dark:text-green-100",statusText:"Done"};case"in-progress":return{icon:Ir,bgColor:"bg-blue-50 dark:bg-blue-950",borderColor:"border-blue-200 dark:border-blue-800",iconColor:"text-blue-600 dark:text-blue-400",textColor:"text-blue-900 dark:text-blue-100",statusText:"In Progress"};case"review":return{icon:xs,bgColor:"bg-amber-50 dark:bg-amber-950",borderColor:"border-amber-200 dark:border-amber-800",iconColor:"text-amber-600 dark:text-amber-400",textColor:"text-amber-900 dark:text-amber-100",statusText:"Review"};case"deferred":return{icon:so,bgColor:"bg-gray-50 dark:bg-gray-800",borderColor:"border-gray-200 dark:border-gray-700",iconColor:"text-gray-500 dark:text-gray-400",textColor:"text-gray-700 dark:text-gray-300",statusText:"Deferred"};case"cancelled":return{icon:Ve,bgColor:"bg-red-50 dark:bg-red-950",borderColor:"border-red-200 dark:border-red-800",iconColor:"text-red-600 dark:text-red-400",textColor:"text-red-900 dark:text-red-100",statusText:"Cancelled"};case"pending":default:return{icon:ur,bgColor:"bg-slate-50 dark:bg-slate-800",borderColor:"border-slate-200 dark:border-slate-700",iconColor:"text-slate-500 dark:text-slate-400",textColor:"text-slate-900 dark:text-slate-100",statusText:"Pending"}}})(t.status);o.icon;const i=c=>{switch(c){case"high":return e.jsx(Ct,{content:"High Priority",children:e.jsx("div",{className:"w-4 h-4 bg-red-100 dark:bg-red-900/30 rounded flex items-center justify-center",children:e.jsx(ao,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})});case"medium":return e.jsx(Ct,{content:"Medium Priority",children:e.jsx("div",{className:"w-4 h-4 bg-amber-100 dark:bg-amber-900/30 rounded flex items-center justify-center",children:e.jsx(Mi,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})})});case"low":return e.jsx(Ct,{content:"Low Priority",children:e.jsx("div",{className:"w-4 h-4 bg-blue-100 dark:bg-blue-900/30 rounded flex items-center justify-center",children:e.jsx(ur,{className:"w-1.5 h-1.5 text-blue-600 dark:text-blue-400 fill-current"})})});default:return e.jsx(Ct,{content:"No Priority Set",children:e.jsx("div",{className:"w-4 h-4 bg-gray-100 dark:bg-gray-800 rounded flex items-center justify-center",children:e.jsx(ur,{className:"w-1.5 h-1.5 text-gray-400 dark:text-gray-500"})})})}};return e.jsxs("div",{className:ke("bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700","hover:shadow-md hover:border-blue-300 dark:hover:border-blue-600 transition-all duration-200 cursor-pointer","p-3 space-y-3",r&&"hover:-translate-y-0.5",a),onClick:r,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx(Ct,{content:`Task ID: ${t.id}`,children:e.jsx("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 px-2 py-0.5 rounded",children:t.id})})}),e.jsx("h3",{className:"font-medium text-sm text-gray-900 dark:text-white line-clamp-2 leading-tight",children:t.title}),s&&t.parentId&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium",children:["Task ",t.parentId]})]}),e.jsx("div",{className:"flex-shrink-0",children:i(t.priority)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:t.dependencies&&Array.isArray(t.dependencies)&&t.dependencies.length>0&&e.jsx(Ct,{content:`Depends on: ${t.dependencies.map(c=>`Task ${c}`).join(", ")}`,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[e.jsx(ya,{className:"w-3 h-3"}),e.jsxs("span",{children:["Depends on: ",t.dependencies.join(", ")]})]})})}),e.jsx(Ct,{content:`Status: ${o.statusText}`,children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:ke("w-2 h-2 rounded-full",o.iconColor.replace("text-","bg-"))}),e.jsx("span",{className:ke("text-xs font-medium",o.textColor),children:o.statusText})]})})]}),t.subtasks&&t.subtasks.length>0&&e.jsx("div",{className:"ml-3",children:e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Progress:"}),e.jsx(Ct,{content:`${t.subtasks.filter(c=>c.status==="done").length} of ${t.subtasks.length} subtasks completed`,children:e.jsx("div",{className:"flex-1 bg-gray-200 dark:bg-gray-700 rounded-full h-1.5",children:e.jsx("div",{className:ke("h-full rounded-full transition-all duration-300",t.status==="done"?"bg-green-500":"bg-blue-500"),style:{width:`${Math.round(t.subtasks.filter(c=>c.status==="done").length/t.subtasks.length*100)}%`}})})}),e.jsx(Ct,{content:`${t.subtasks.filter(c=>c.status==="done").length} completed, ${t.subtasks.filter(c=>c.status==="pending").length} pending, ${t.subtasks.filter(c=>c.status==="in-progress").length} in progress`,children:e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t.subtasks.filter(c=>c.status==="done").length,"/",t.subtasks.length]})})]})})]})},Xp=({currentProject:t,onClose:r,onTaskCreated:s})=>e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Ut,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Create AI-Generated Task"})]}),e.jsx("button",{onClick:r,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ut,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"💡 Pro Tip: Ask Your AI Assistant Directly!"}),e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-3",children:"You can simply ask your AI assistant in the chat to create tasks for you. The AI assistant will automatically generate detailed tasks with research-backed insights."}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-blue-200 dark:border-blue-700 p-3 mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Example:"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white font-mono",children:'"Please add a new task to implement user profile image uploads using Cloudinary, research the best approach."'})]}),e.jsxs("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:[e.jsx("strong",{children:"This runs:"})," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900/50 px-1 rounded text-xs",children:'task-master add-task --prompt="Implement user profile image uploads using Cloudinary" --research'})]})]})]})}),e.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),e.jsx("div",{className:"pt-4",children:e.jsx("button",{onClick:r,className:"w-full px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask my AI assistant directly"})})]})]})}),Zp=({tasks:t=[],onTaskClick:r,className:s="",showParentTasks:a=!1,defaultView:n="kanban",currentProject:o,onTaskCreated:i,onShowPRDEditor:c,existingPRDs:u=[],onRefreshPRDs:d})=>{var B,ee;const[m,h]=l.useState(""),[p,g]=l.useState("all"),[f,x]=l.useState("all"),[b,N]=l.useState("id"),[j,y]=l.useState("asc"),[k,I]=l.useState(n),[D,C]=l.useState(!1),[v,E]=l.useState(!1),[T,W]=l.useState(!1),[S,O]=l.useState(!1),[H,R]=l.useState(!1),[A,z]=l.useState(!1),{projectTaskMaster:J,refreshProjects:re,refreshTasks:G,setCurrentProject:ie}=fr(),{t:$}=We("tasks");l.useEffect(()=>{const V=w=>{A&&!w.target.closest(".relative")&&z(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[A]);const Z=l.useMemo(()=>{const V=new Set(t.map(w=>w.status).filter(Boolean));return Array.from(V).sort()},[t]),te=l.useMemo(()=>{const V=new Set(t.map(w=>w.priority).filter(Boolean));return Array.from(V).sort()},[t]),Q=l.useMemo(()=>{let V=t.filter(w=>{var je;const M=m.toLowerCase(),Y=!m||w.title.toLowerCase().includes(M)||((je=w.description)==null?void 0:je.toLowerCase().includes(M))||w.id.toString().includes(M),se=p==="all"||w.status===p,de=f==="all"||w.priority===f;return Y&&se&&de});return V.sort((w,M)=>{let Y,se;switch(b){case"title":Y=w.title.toLowerCase(),se=M.title.toLowerCase();break;case"status":const de={pending:1,"in-progress":2,done:3,blocked:4,deferred:5,cancelled:6};Y=de[w.status]||99,se=de[M.status]||99;break;case"priority":const je={high:3,medium:2,low:1};Y=je[w.priority]||0,se=je[M.priority]||0;break;case"updated":Y=new Date(w.updatedAt||w.createdAt||0),se=new Date(M.updatedAt||M.createdAt||0);break;case"id":default:const ge=De=>De.toString().split(".").map(_e=>parseInt(_e,10)),Re=ge(w.id),Ne=ge(M.id);for(let De=0;De<Math.max(Re.length,Ne.length);De++){const Ue=Re[De]||0,_e=Ne[De]||0;if(Ue!==_e){Y=Ue,se=_e;break}}break}return b==="updated"?j==="asc"?Y-se:se-Y:typeof Y=="string"?j==="asc"?Y.localeCompare(se):se.localeCompare(Y):j==="asc"?Y-se:se-Y}),V},[t,m,p,f,b,j]),_=l.useMemo(()=>{const V=[{id:"pending",title:$("kanban.pending"),status:"pending",color:"bg-slate-50 dark:bg-slate-900/50 border-slate-200 dark:border-slate-700",headerColor:"bg-slate-100 dark:bg-slate-800 text-slate-800 dark:text-slate-200"},{id:"in-progress",title:$("kanban.inProgress"),status:"in-progress",color:"bg-blue-50 dark:bg-blue-900/50 border-blue-200 dark:border-blue-700",headerColor:"bg-blue-100 dark:bg-blue-800 text-blue-800 dark:text-blue-200"},{id:"done",title:$("kanban.done"),status:"done",color:"bg-emerald-50 dark:bg-emerald-900/50 border-emerald-200 dark:border-emerald-700",headerColor:"bg-emerald-100 dark:bg-emerald-800 text-emerald-800 dark:text-emerald-200"},{id:"blocked",title:$("kanban.blocked"),status:"blocked",color:"bg-red-50 dark:bg-red-900/50 border-red-200 dark:border-red-700",headerColor:"bg-red-100 dark:bg-red-800 text-red-800 dark:text-red-200"},{id:"deferred",title:$("kanban.deferred"),status:"deferred",color:"bg-amber-50 dark:bg-amber-900/50 border-amber-200 dark:border-amber-700",headerColor:"bg-amber-100 dark:bg-amber-800 text-amber-800 dark:text-amber-200"},{id:"cancelled",title:$("kanban.cancelled"),status:"cancelled",color:"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700",headerColor:"bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-200"}],w=["pending","in-progress","done"];return V.filter(Y=>{const se=Q.some(je=>je.status===Y.status),de=w.includes(Y.status);return se||de}).map(Y=>({...Y,tasks:Q.filter(se=>se.status===Y.status)}))},[Q,$]),F=V=>{b===V?y(j==="asc"?"desc":"asc"):(N(V),y("asc"))},q=()=>{h(""),g("all"),x("all")},U=V=>b!==V?e.jsx(_i,{className:"w-4 h-4"}):j==="asc"?e.jsx(Fi,{className:"w-4 h-4"}):e.jsx(to,{className:"w-4 h-4"});if(t.length===0){const V=(o==null?void 0:o.taskMasterConfigured)||((B=o==null?void 0:o.taskmaster)==null?void 0:B.hasTaskmaster)||(J==null?void 0:J.hasTaskmaster);return e.jsxs("div",{className:ke("text-center py-12",s),children:[V?e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-950/50 dark:to-indigo-950/50 rounded-xl border border-blue-200 dark:border-blue-800 p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(gt,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:$("gettingStarted.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("gettingStarted.subtitle")})]})]}),e.jsxs("div",{className:"space-y-4 text-left",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:$("gettingStarted.steps.createPRD.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:$("gettingStarted.steps.createPRD.description")}),e.jsxs("button",{onClick:()=>{c==null||c()},className:"inline-flex items-center gap-1 text-xs bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 px-2 py-1 rounded hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors",children:[e.jsx(gt,{className:"w-3 h-3"}),$("gettingStarted.steps.createPRD.addButton")]}),u.length>0&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:$("gettingStarted.steps.createPRD.existingPRDs")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(w=>e.jsxs("button",{onClick:async()=>{try{const M=await Be.get(`/taskmaster/prd/${encodeURIComponent(o.name)}/${encodeURIComponent(w.name)}`);if(M.ok){const Y=await M.json();c==null||c({name:w.name,content:Y.content,isExisting:!0})}else console.error("Failed to load PRD:",M.statusText)}catch(M){console.error("Error loading PRD:",M)}},className:"inline-flex items-center gap-1 text-xs bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 px-2 py-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(gt,{className:"w-3 h-3"}),w.name]},w.name))})]})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:$("gettingStarted.steps.generateTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("gettingStarted.steps.generateTasks.description")})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:$("gettingStarted.steps.analyzeTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("gettingStarted.steps.analyzeTasks.description")})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"4"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:$("gettingStarted.steps.startBuilding.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("gettingStarted.steps.startBuilding.description")})]})]})]}),e.jsx("div",{className:"flex gap-3 pt-4 border-t border-blue-200 dark:border-blue-700",children:e.jsxs("button",{onClick:w=>{w.preventDefault(),w.stopPropagation(),c==null||c()},className:"flex items-center gap-2 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg font-medium transition-colors cursor-pointer",style:{zIndex:10},children:[e.jsx(gt,{className:"w-4 h-4"}),$("buttons.addPRD")]})})]})]}),e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mb-2",children:$("gettingStarted.tip")})})]}):e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsx("div",{className:"text-blue-600 dark:text-blue-400 mb-4",children:e.jsx(Dt,{className:"w-12 h-12 mx-auto mb-4"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:$("notConfigured.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:$("notConfigured.description")}),e.jsxs("div",{className:"mb-6 p-4 bg-blue-50 dark:bg-blue-950 rounded-lg text-left",children:[e.jsx("h4",{className:"text-sm font-medium text-blue-900 dark:text-blue-100 mb-3",children:$("notConfigured.whatIsTitle")}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("p",{children:["• ",$("notConfigured.features.aiPowered")]}),e.jsxs("p",{children:["• ",$("notConfigured.features.prdTemplates")]}),e.jsxs("p",{children:["• ",$("notConfigured.features.dependencyTracking")]}),e.jsxs("p",{children:["• ",$("notConfigured.features.progressVisualization")]}),e.jsxs("p",{children:["• ",$("notConfigured.features.cliIntegration")]})]})]}),e.jsxs("button",{onClick:()=>{R(!1),W(!0)},className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium transition-colors flex items-center gap-2 mx-auto",children:[e.jsx(vt,{className:"w-4 h-4"}),$("notConfigured.initializeButton")]})]}),T&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center p-4 pt-16 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl h-[600px] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(vt,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:$("setupModal.title")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:$("setupModal.subtitle",{projectName:o==null?void 0:o.displayName})})]})]}),e.jsx("button",{onClick:()=>{W(!1),setTimeout(()=>{re(),o&&ie(o)},1e3)},className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800",children:e.jsx(at,{className:"w-5 h-5 rotate-45"})})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"h-full bg-black rounded-lg overflow-hidden",onClick:w=>{const M=w.currentTarget.querySelector(".xterm-screen");M&&M.focus()},children:e.jsx(lo,{selectedProject:o,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0,onProcessComplete:w=>{R(!0),w===0&&setTimeout(()=>{re(),o&&ie(o)},1e3)}})})}),e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:H?e.jsxs("span",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),$("setupModal.completed")]}):$("setupModal.willStart")}),e.jsx("button",{onClick:()=>{W(!1),R(!1),setTimeout(()=>{re(),o&&ie(o)},1e3)},className:ke("px-4 py-2 text-sm font-medium rounded-md transition-colors",H?"bg-green-600 hover:bg-green-700 text-white":"text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600"),children:$(H?"setupModal.closeContinueButton":"setupModal.closeButton")})]})})]})})]})}return e.jsxs("div",{className:ke("space-y-4",s),children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-3 lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(Ar,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),e.jsx("input",{type:"text",placeholder:$("search.placeholder"),value:m,onChange:V=>h(V.target.value),className:"pl-10 pr-4 py-2 w-full border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"flex bg-gray-100 dark:bg-gray-800 rounded-lg p-1",children:[e.jsx("button",{onClick:()=>I("kanban"),className:ke("p-2 rounded-md transition-colors",k==="kanban"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:$("views.kanban"),children:e.jsx(Di,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>I("list"),className:ke("p-2 rounded-md transition-colors",k==="list"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:$("views.list"),children:e.jsx(Qs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>I("grid"),className:ke("p-2 rounded-md transition-colors",k==="grid"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:$("views.grid"),children:e.jsx(Li,{className:"w-4 h-4"})})]}),e.jsxs("button",{onClick:()=>C(!D),className:ke("flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors",D?"bg-blue-50 dark:bg-blue-900 border-blue-200 dark:border-blue-700 text-blue-700 dark:text-blue-300":"bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"),children:[e.jsx(Pi,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:$("filters.button")}),e.jsx(Pt,{className:ke("w-4 h-4 transition-transform",D&&"rotate-180")})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>O(!0),className:"p-2 text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors border border-gray-300 dark:border-gray-600",title:$("buttons.help"),children:e.jsx($i,{className:"w-4 h-4"})}),e.jsx("div",{className:"relative",children:u.length>0?e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>z(!A),className:"flex items-center gap-2 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors font-medium",title:$("buttons.prdsAvailable",{count:u.length}),children:[e.jsx(gt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:$("buttons.prds")}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs bg-purple-500 rounded-full min-w-[1.25rem] text-center",children:u.length}),e.jsx(Pt,{className:ke("w-3 h-3 transition-transform hidden sm:block",A&&"rotate-180")})]}),A&&e.jsx("div",{className:"absolute right-0 top-full mt-2 w-56 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-xl z-30",children:e.jsxs("div",{className:"p-2",children:[e.jsxs("button",{onClick:()=>{c==null||c(),z(!1)},className:"w-full text-left px-3 py-2 text-sm font-medium text-purple-700 dark:text-purple-300 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded flex items-center gap-2",children:[e.jsx(at,{className:"w-4 h-4"}),$("buttons.createNewPRD")]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 my-1"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 px-3 py-1 font-medium",children:$("gettingStarted.steps.createPRD.existingPRDs")}),u.map(V=>e.jsxs("button",{onClick:async()=>{try{const w=await Be.get(`/taskmaster/prd/${encodeURIComponent(o.name)}/${encodeURIComponent(V.name)}`);if(w.ok){const M=await w.json();c==null||c({name:V.name,content:M.content,isExisting:!0}),z(!1)}}catch(w){console.error("Error loading PRD:",w)}},className:"w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded flex items-center gap-2",title:$("prd.modified",{date:new Date(V.modified).toLocaleDateString()}),children:[e.jsx(gt,{className:"w-4 h-4"}),e.jsx("span",{className:"truncate",children:V.name})]},V.name))]})})]}):e.jsxs("button",{onClick:()=>{c==null||c()},className:"flex items-center gap-2 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors font-medium",title:$("buttons.addPRD"),children:[e.jsx(gt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:$("buttons.addPRD")})]})}),((o==null?void 0:o.taskMasterConfigured)||((ee=o==null?void 0:o.taskmaster)==null?void 0:ee.hasTaskmaster)||(J==null?void 0:J.hasTaskmaster)||t.length>0)&&e.jsxs("button",{onClick:()=>E(!0),className:"flex items-center gap-2 px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium",title:$("buttons.addTask"),children:[e.jsx(at,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:$("buttons.addTask")})]})]})]})]}),D&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:$("filters.status")}),e.jsxs("select",{value:p,onChange:V=>g(V.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:$("filters.allStatuses")}),Z.map(V=>e.jsx("option",{value:V,children:$(`statuses.${V}`,V.charAt(0).toUpperCase()+V.slice(1).replace("-"," "))},V))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:$("filters.priority")}),e.jsxs("select",{value:f,onChange:V=>x(V.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:$("filters.allPriorities")}),te.map(V=>e.jsx("option",{value:V,children:$(`priorities.${V}`,V.charAt(0).toUpperCase()+V.slice(1))},V))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:$("filters.sortBy")}),e.jsxs("select",{value:`${b}-${j}`,onChange:V=>{const[w,M]=V.target.value.split("-");N(w),y(M)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"id-asc",children:$("sort.idAsc")}),e.jsx("option",{value:"id-desc",children:$("sort.idDesc")}),e.jsx("option",{value:"title-asc",children:$("sort.titleAsc")}),e.jsx("option",{value:"title-desc",children:$("sort.titleDesc")}),e.jsx("option",{value:"status-asc",children:$("sort.statusAsc")}),e.jsx("option",{value:"status-desc",children:$("sort.statusDesc")}),e.jsx("option",{value:"priority-asc",children:$("sort.priorityAsc")}),e.jsx("option",{value:"priority-desc",children:$("sort.priorityDesc")})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("filters.showing",{filtered:Q.length,total:t.length})}),e.jsx("button",{onClick:q,className:"text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium",children:$("filters.clearFilters")})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>F("id"),className:ke("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",b==="id"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[$("sort.id")," ",U("id")]}),e.jsxs("button",{onClick:()=>F("status"),className:ke("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",b==="status"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[$("sort.status")," ",U("status")]}),e.jsxs("button",{onClick:()=>F("priority"),className:ke("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",b==="priority"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[$("sort.priority")," ",U("priority")]})]}),Q.length===0?e.jsx("div",{className:"text-center py-12",children:e.jsxs("div",{className:"text-gray-500 dark:text-gray-400",children:[e.jsx(Ar,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:$("noMatchingTasks.title")}),e.jsx("p",{className:"text-sm",children:$("noMatchingTasks.description")})]})}):k==="kanban"?e.jsx("div",{className:ke("grid gap-6",_.length===1&&"grid-cols-1 max-w-md mx-auto",_.length===2&&"grid-cols-1 md:grid-cols-2",_.length===3&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",_.length===4&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-4",_.length===5&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5",_.length>=6&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6"),children:_.map(V=>e.jsxs("div",{className:ke("rounded-xl border shadow-sm transition-shadow hover:shadow-md",V.color),children:[e.jsx("div",{className:ke("px-4 py-3 rounded-t-xl border-b",V.headerColor),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold text-sm",children:V.title}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-xs font-medium px-2 py-1 bg-white/60 dark:bg-black/20 rounded-full",children:V.tasks.length})})]})}),e.jsx("div",{className:"p-3 space-y-3 min-h-[200px] max-h-[calc(100vh-300px)] overflow-y-auto",children:V.tasks.length===0?e.jsxs("div",{className:"text-center py-8 text-gray-400 dark:text-gray-500",children:[e.jsx("div",{className:"w-8 h-8 mx-auto mb-2 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center",children:e.jsx("div",{className:"w-3 h-3 rounded-full bg-gray-300 dark:bg-gray-600"})}),e.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:$("kanban.noTasksYet")}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:V.status==="pending"?$("kanban.tasksWillAppear"):V.status==="in-progress"?$("kanban.moveTasksHere"):V.status==="done"?$("kanban.completedTasksHere"):$("kanban.statusTasksHere")})]}):V.tasks.map(w=>e.jsx("div",{className:"transform transition-transform hover:scale-[1.02]",children:e.jsx(Wn,{task:w,onClick:()=>r==null?void 0:r(w),showParent:a,className:"w-full shadow-sm hover:shadow-md transition-shadow cursor-pointer"})},w.id))})]},V.id))}):e.jsx("div",{className:ke("gap-4",k==="grid"?"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3":"space-y-4"),children:Q.map(V=>e.jsx(Wn,{task:V,onClick:()=>r==null?void 0:r(V),showParent:a,className:k==="grid"?"h-full":""},V.id))}),v&&e.jsx(Xp,{currentProject:o,onClose:()=>E(!1),onTaskCreated:()=>{E(!1),i&&i()}}),S&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl max-h-[90vh] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(gt,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:$("helpGuide.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("helpGuide.subtitle")})]})]}),e.jsx("button",{onClick:()=>O(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-120px)]",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-950/50 dark:to-indigo-950/50 rounded-lg border border-blue-200 dark:border-blue-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-blue-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:$("gettingStarted.steps.createPRD.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:$("gettingStarted.steps.createPRD.description")}),e.jsxs("button",{onClick:()=>{c==null||c(),O(!1)},className:"inline-flex items-center gap-2 text-sm bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 px-3 py-1.5 rounded-lg hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors",children:[e.jsx(gt,{className:"w-4 h-4"}),$("buttons.addPRD")]})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-green-50 to-emerald-50 dark:from-green-950/50 dark:to-emerald-950/50 rounded-lg border border-green-200 dark:border-green-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-green-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:$("gettingStarted.steps.generateTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:$("gettingStarted.steps.generateTasks.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-green-200 dark:border-green-700/50 p-3 mb-2",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:$("helpGuide.examples.parsePRD")})})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-amber-50 to-orange-50 dark:from-amber-950/50 dark:to-orange-950/50 rounded-lg border border-amber-200 dark:border-amber-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-amber-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:$("gettingStarted.steps.analyzeTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:$("gettingStarted.steps.analyzeTasks.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-amber-200 dark:border-amber-700/50 p-3 mb-2",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:$("helpGuide.examples.expandTask")})})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-purple-50 to-pink-50 dark:from-purple-950/50 dark:to-pink-950/50 rounded-lg border border-purple-200 dark:border-purple-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-purple-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"4"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:$("gettingStarted.steps.startBuilding.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:$("gettingStarted.steps.startBuilding.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-purple-200 dark:border-purple-700/50 p-3 mb-3",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:$("helpGuide.examples.addTask")})}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:$("helpGuide.moreExamples")})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-3",children:$("helpGuide.proTips.title")}),e.jsxs("ul",{className:"space-y-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full mt-2 flex-shrink-0"}),$("helpGuide.proTips.search")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-green-500 rounded-full mt-2 flex-shrink-0"}),$("helpGuide.proTips.views")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-purple-500 rounded-full mt-2 flex-shrink-0"}),$("helpGuide.proTips.filters")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-orange-500 rounded-full mt-2 flex-shrink-0"}),$("helpGuide.proTips.details")]})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-blue-50 dark:bg-blue-950/50 rounded-lg border border-blue-200 dark:border-blue-800",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-3",children:$("helpGuide.learnMore.title")}),e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-3",children:$("helpGuide.learnMore.description")}),e.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm bg-blue-600 hover:bg-blue-700 text-white px-3 py-2 rounded-lg font-medium transition-colors",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),$("helpGuide.learnMore.githubButton"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]})})]})})]})},e0=({file:t,onClose:r,projectPath:s,project:a,initialContent:n="",isNewFile:o=!1,onSave:i})=>{const{addToast:c}=hr(),[u,d]=l.useState(n),[m,h]=l.useState(!o),[p,g]=l.useState(!1),[f,x]=l.useState(!1),[b,N]=l.useState(!0),[j,y]=l.useState(!1),[k,I]=l.useState(!1),[D,C]=l.useState(!0),[v,E]=l.useState(""),[T,W]=l.useState(!1),[S,O]=l.useState(!1),[H,R]=l.useState([]),A=l.useRef(null),z=`# Product Requirements Document - Example Project
277
+ `}),e.jsx("div",{className:a?"w-full h-full flex flex-col":`fixed inset-0 z-[9999] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${x?"md:p-0":""}`,children:e.jsxs("div",{className:a?"bg-background flex flex-col w-full h-full":`bg-background shadow-2xl flex flex-col ${"w-full h-full md:rounded-lg md:shadow-2xl"+(x?" md:w-full md:h-full md:rounded-none":" md:w-full md:max-w-6xl md:h-[80vh] md:max-h-[80vh]")}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border flex-shrink-0 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:t.name}),t.diffInfo&&e.jsx("span",{className:"text-[10px] bg-blue-100 dark:bg-blue-900 text-blue-600 dark:text-blue-300 px-1.5 py-0.5 rounded whitespace-nowrap",children:c("header.showingChanges")})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.path})]})}),e.jsxs("div",{className:"flex items-center gap-0.5 md:gap-1 flex-shrink-0",children:[J&&e.jsx("button",{onClick:()=>A(!R),className:`p-1.5 rounded-md min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center transition-colors ${R?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:c(R?"actions.editMarkdown":"actions.previewMarkdown"),children:R?e.jsx(Mi,{className:"w-4 h-4"}):e.jsx(sr,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>{var F;return(F=window.openSettings)==null?void 0:F.call(window,"appearance")},className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:c("toolbar.settings"),children:e.jsx(Dt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:Q,className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:c("actions.download"),children:e.jsx(io,{className:"w-4 h-4"})}),e.jsx("button",{onClick:te,disabled:g,className:`p-1.5 rounded-md disabled:opacity-50 flex items-center justify-center transition-colors min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 ${y?"text-green-600 dark:text-green-400 bg-green-50 dark:bg-green-900/30":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:c(y?"actions.saved":g?"actions.saving":"actions.save"),children:y?e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):e.jsx(ts,{className:"w-4 h-4"})}),!a&&e.jsx("button",{onClick:_,className:"hidden md:flex p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:c(x?"actions.exitFullscreen":"actions.fullscreen"),children:x?e.jsx(lo,{className:"w-4 h-4"}):e.jsx(ya,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:c("actions.close"),children:e.jsx(Ve,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:R&&J?e.jsx("div",{className:"h-full overflow-y-auto bg-white dark:bg-gray-900",children:e.jsx("div",{className:"max-w-4xl mx-auto px-8 py-6 prose prose-sm dark:prose-invert prose-headings:font-semibold prose-a:text-blue-600 dark:prose-a:text-blue-400 prose-code:text-sm prose-pre:bg-gray-900 prose-img:rounded-lg max-w-none",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"text-muted-foreground text-sm p-4",children:"Loading preview..."}),children:e.jsx(Op,{content:d})})})}):e.jsx(xo,{ref:z,value:d,onChange:m,extensions:[...Z(t.name),...$,...t.diffInfo&&I&&t.diffInfo.old_string!==void 0?[cl({original:t.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...re,...G]:[],...C?[Wt.lineWrapping]:[]],theme:N?go:void 0,height:"100%",style:{fontSize:`${O}px`,height:"100%"},basicSetup:{lineNumbers:W,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-border bg-muted flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:[c("footer.lines")," ",d.split(`
278
+ `).length]}),e.jsxs("span",{children:[c("footer.characters")," ",d.length]})]}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("footer.shortcuts")})]})]})})]})}const On=Bp;function Wp({editingFile:t,isMobile:r,editorExpanded:s,editorWidth:a,resizeHandleRef:n,onResizeStart:o,onCloseEditor:i,onToggleEditorExpand:c,projectPath:u,fillSpace:d}){const[m,h]=l.useState(!1);if(!t)return null;if(r||m)return e.jsx(On,{file:t,onClose:()=>{h(!1),i()},projectPath:u,isSidebar:!1});const p=s||d;return e.jsxs(e.Fragment,{children:[!s&&e.jsx("div",{ref:n,onMouseDown:o,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:e.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),e.jsx("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${p?"flex-1":""}`,style:p?void 0:{width:`${a}px`},children:e.jsx(On,{file:t,onClose:i,projectPath:u,isSidebar:!0,isExpanded:s,onToggleExpand:c,onPopOut:()=>h(!0)})})]})}const Up=l.lazy(()=>kt(()=>import("./vendor-diff-DNQpbhrT.js"),__vite__mapDeps([4,2]))),Hp={variables:{dark:{diffViewerBackground:"#0f172a",diffViewerColor:"#e2e8f0",addedBackground:"#064e3b20",addedColor:"#6ee7b7",removedBackground:"#7f1d1d20",removedColor:"#fca5a5",wordAddedBackground:"#065f4630",wordRemovedBackground:"#991b1b30",addedGutterBackground:"#064e3b30",removedGutterBackground:"#7f1d1d30",gutterBackground:"#0f172a",gutterBackgroundDark:"#0f172a",highlightBackground:"#1e293b",highlightGutterBackground:"#1e293b",codeFoldGutterBackground:"#1e293b",codeFoldBackground:"#1e293b",emptyLineBackground:"#0f172a",gutterColor:"#475569",addedGutterColor:"#6ee7b7",removedGutterColor:"#fca5a5",codeFoldContentColor:"#94a3b8",diffViewerTitleBackground:"#1e293b",diffViewerTitleColor:"#e2e8f0",diffViewerTitleBorderColor:"#334155"}},line:{padding:"2px 8px",fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},gutter:{padding:"2px 8px",fontSize:"11px",minWidth:"36px"},contentText:{fontSize:"12px",lineHeight:"20px"}};function Gp(t){var a;const r=((a=t.split(".").pop())==null?void 0:a.toLowerCase())||"";return{ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",html:"html",css:"css",scss:"scss",less:"less",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",xml:"xml",sql:"sql",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",graphql:"graphql",dockerfile:"docker",tf:"hcl",lua:"lua",r:"r",vue:"html",svelte:"html"}[r]||"text"}function Vp({data:t}){const[r,s]=it.useState(!1),a=t.language||Gp(t.filePath||""),n=t.content||"",o=()=>{navigator.clipboard.writeText(n).then(()=>{s(!0),setTimeout(()=>s(!1),1500)}).catch(()=>{})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:[e.jsx("span",{className:"text-xs text-gray-400 font-mono truncate",children:t.filePath||"code"}),e.jsx("button",{onClick:o,className:"text-[10px] px-2 py-0.5 rounded border border-gray-600 text-gray-400 hover:text-gray-200 hover:bg-gray-700 transition-colors",children:r?"Copied":"Copy"})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx(uo,{language:a,style:mo,customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",padding:"1rem",minHeight:"100%"},showLineNumbers:!0,lineNumberStyle:{minWidth:"2.5em",paddingRight:"1em",color:"#475569"},children:n})})]})}function qp({data:t}){const[r,s]=it.useState(!1);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs text-gray-400 font-mono truncate",children:t.filePath||"diff"}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-px rounded flex-shrink-0 ${t.badge==="New"?"bg-green-900/30 text-green-400":"bg-gray-800 text-gray-400"}`,children:t.badge||"Diff"})]}),e.jsx("button",{onClick:()=>s(!r),className:"text-[10px] px-2 py-0.5 rounded border border-gray-600 text-gray-400 hover:text-gray-200 hover:bg-gray-700 transition-colors",children:r?"Unified":"Split"})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"p-4 text-xs text-gray-500",children:"Loading diff viewer..."}),children:e.jsx(Up,{oldValue:t.oldContent||"",newValue:t.newContent||"",splitView:r,useDarkTheme:!0,styles:Hp,hideLineNumbers:!1,showDiffOnly:!0,extraLinesSurroundingDiff:3})})})]})}function Kp({data:t}){const[r,s]=it.useState(!1),a=t.output||"",n=()=>{navigator.clipboard.writeText(a).then(()=>{s(!0),setTimeout(()=>s(!1),1500)}).catch(()=>{})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs text-green-400 font-mono",children:"$"}),e.jsx("span",{className:"text-xs text-gray-300 font-mono truncate",children:t.command||"terminal"})]}),e.jsx("button",{onClick:n,className:"text-[10px] px-2 py-0.5 rounded border border-gray-600 text-gray-400 hover:text-gray-200 hover:bg-gray-700 transition-colors",children:r?"Copied":"Copy"})]}),e.jsx("div",{className:"flex-1 overflow-auto bg-gray-950 p-3",children:e.jsx("pre",{className:"text-xs text-gray-300 font-mono whitespace-pre-wrap break-words",children:a})})]})}function Jp({data:t,onFileOpen:r}){const s=t.files||[],a=t.pattern||"";return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs text-gray-400",children:"Search:"}),e.jsx("span",{className:"text-xs text-gray-300 font-mono truncate",children:a})]}),e.jsxs("span",{className:"text-[10px] text-gray-500 flex-shrink-0",children:[s.length," files"]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:s.length===0?e.jsx("div",{className:"p-4 text-xs text-gray-500 text-center",children:"No files found"}):e.jsx("div",{className:"divide-y divide-gray-800/50",children:s.map((n,o)=>e.jsx("button",{onClick:()=>r==null?void 0:r(n),className:"w-full text-left px-3 py-1.5 text-xs font-mono text-blue-400 hover:text-blue-300 hover:bg-gray-800/50 transition-colors truncate",children:n},o))})})]})}function Yp({data:t}){const r=t.html||"";return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:e.jsx("span",{className:"text-xs text-gray-400",children:"Preview"})}),e.jsx("div",{className:"flex-1 overflow-hidden bg-white",children:e.jsx("iframe",{srcDoc:r,sandbox:"allow-scripts",className:"w-full h-full border-0",title:"HTML Preview"})})]})}function Qp({data:t}){const r=t.content||"";return e.jsx("div",{className:"h-full flex flex-col overflow-auto p-4",children:e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert text-sm text-gray-300",children:r})})}function Xp({artifact:t,onFileOpen:r}){switch(t.type){case"code":return e.jsx(Vp,{data:t.data});case"diff":return e.jsx(qp,{data:t.data});case"terminal":return e.jsx(Kp,{data:t.data});case"search":return e.jsx(Jp,{data:t.data,onFileOpen:r});case"html":return e.jsx(Yp,{data:t.data});case"markdown":return e.jsx(Qp,{data:t.data});default:return e.jsx("div",{className:"p-4 text-xs text-gray-500",children:"Unknown artifact type"})}}const Bn={code:"📄",diff:"±",terminal:"$",search:"🔍",html:"🌐",markdown:"📝"};function Wn({artifacts:t,recentArtifacts:r,activeArtifactId:s,panelWidth:a,panelExpanded:n,resizeHandleRef:o,onResizeStart:i,onSetActive:c,onClose:u,onReopenArtifact:d,onClearHistory:m,onCloseAll:h,onToggleExpand:p,onPinToCanvas:g,onFileOpen:f}){const[x,b]=it.useState(!1);if(t.length===0&&r.length===0)return null;const N=t.find(j=>j.id===s)||t[0];return e.jsxs(e.Fragment,{children:[!n&&e.jsx("div",{ref:o,onMouseDown:i,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:e.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),e.jsxs("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden flex flex-col bg-gray-900 ${n?"flex-1":""}`,style:n?void 0:{width:`${a}px`},children:[e.jsxs("div",{className:"flex items-center bg-gray-800/80 border-b border-gray-700/50 min-h-[36px]",children:[e.jsx("div",{className:"flex-1 flex items-center overflow-x-auto scrollbar-none",children:t.map(j=>e.jsxs("button",{onClick:()=>c(j.id),className:`group/tab flex items-center gap-1.5 px-3 py-2 sm:py-1.5 text-xs border-r border-gray-700/30 whitespace-nowrap transition-colors ${j.id===(N==null?void 0:N.id)?"bg-gray-900 text-gray-200":"text-gray-500 hover:text-gray-300 hover:bg-gray-800/50"}`,children:[e.jsx("span",{className:"text-[10px] opacity-60",children:Bn[j.type]||"•"}),e.jsx("span",{className:"max-w-[120px] truncate",children:j.title}),e.jsx("button",{onClick:y=>{y.stopPropagation(),u(j.id)},className:"ml-1 opacity-0 group-hover/tab:opacity-100 text-gray-500 hover:text-gray-300 transition-opacity","aria-label":"Close tab",children:"×"})]},j.id))}),e.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 flex-shrink-0",children:[g&&N&&e.jsx("button",{onClick:()=>g(N),className:"p-1 text-gray-500 hover:text-gray-300 transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center",title:"Pin to canvas",children:e.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]})}),r.length>0&&e.jsx("button",{onClick:()=>b(!x),className:`p-1 transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center ${x?"text-gray-200":"text-gray-500 hover:text-gray-300"}`,title:`Recent (${r.length})`,children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("button",{onClick:p,className:"p-1 text-gray-500 hover:text-gray-300 transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center",title:n?"Restore size":"Expand",children:n?e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"})}):e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),e.jsx("button",{onClick:h,className:"p-1 text-gray-500 hover:text-gray-300 transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center",title:"Close all",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:N?e.jsx(Xp,{artifact:N,onFileOpen:f}):t.length===0&&r.length>0?e.jsx("div",{className:"flex items-center justify-center h-full text-xs text-gray-500",children:"No open artifacts. Check recent history below."}):null}),x&&r.length>0&&e.jsxs("div",{className:"border-t border-gray-700/50 max-h-[200px] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 sticky top-0",children:[e.jsxs("span",{className:"text-[10px] font-medium text-gray-400 uppercase tracking-wider",children:["Recent (",r.length,")"]}),e.jsx("button",{onClick:m,className:"text-[10px] text-gray-500 hover:text-gray-300 transition-colors",children:"Clear"})]}),e.jsx("div",{className:"divide-y divide-gray-800/30",children:r.map(j=>e.jsxs("button",{onClick:()=>d(j.id),className:"w-full text-left px-3 py-2.5 sm:py-1.5 text-xs hover:bg-gray-800/50 transition-colors flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] opacity-60 flex-shrink-0",children:Bn[j.type]||"•"}),e.jsx("span",{className:"text-gray-400 truncate",children:j.title}),e.jsx("span",{className:"ml-auto text-[10px] text-gray-600 flex-shrink-0",children:j.type})]},j.id))})]})]})]})}const Un=({task:t,onClick:r,showParent:s=!1,className:a=""})=>{const o=(c=>{switch(c){case"done":return{icon:Pr,bgColor:"bg-green-50 dark:bg-green-950",borderColor:"border-green-200 dark:border-green-800",iconColor:"text-green-600 dark:text-green-400",textColor:"text-green-900 dark:text-green-100",statusText:"Done"};case"in-progress":return{icon:Ir,bgColor:"bg-blue-50 dark:bg-blue-950",borderColor:"border-blue-200 dark:border-blue-800",iconColor:"text-blue-600 dark:text-blue-400",textColor:"text-blue-900 dark:text-blue-100",statusText:"In Progress"};case"review":return{icon:xs,bgColor:"bg-amber-50 dark:bg-amber-950",borderColor:"border-amber-200 dark:border-amber-800",iconColor:"text-amber-600 dark:text-amber-400",textColor:"text-amber-900 dark:text-amber-100",statusText:"Review"};case"deferred":return{icon:ao,bgColor:"bg-gray-50 dark:bg-gray-800",borderColor:"border-gray-200 dark:border-gray-700",iconColor:"text-gray-500 dark:text-gray-400",textColor:"text-gray-700 dark:text-gray-300",statusText:"Deferred"};case"cancelled":return{icon:Ve,bgColor:"bg-red-50 dark:bg-red-950",borderColor:"border-red-200 dark:border-red-800",iconColor:"text-red-600 dark:text-red-400",textColor:"text-red-900 dark:text-red-100",statusText:"Cancelled"};case"pending":default:return{icon:ur,bgColor:"bg-slate-50 dark:bg-slate-800",borderColor:"border-slate-200 dark:border-slate-700",iconColor:"text-slate-500 dark:text-slate-400",textColor:"text-slate-900 dark:text-slate-100",statusText:"Pending"}}})(t.status);o.icon;const i=c=>{switch(c){case"high":return e.jsx(Ct,{content:"High Priority",children:e.jsx("div",{className:"w-4 h-4 bg-red-100 dark:bg-red-900/30 rounded flex items-center justify-center",children:e.jsx(no,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})});case"medium":return e.jsx(Ct,{content:"Medium Priority",children:e.jsx("div",{className:"w-4 h-4 bg-amber-100 dark:bg-amber-900/30 rounded flex items-center justify-center",children:e.jsx(Di,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})})});case"low":return e.jsx(Ct,{content:"Low Priority",children:e.jsx("div",{className:"w-4 h-4 bg-blue-100 dark:bg-blue-900/30 rounded flex items-center justify-center",children:e.jsx(ur,{className:"w-1.5 h-1.5 text-blue-600 dark:text-blue-400 fill-current"})})});default:return e.jsx(Ct,{content:"No Priority Set",children:e.jsx("div",{className:"w-4 h-4 bg-gray-100 dark:bg-gray-800 rounded flex items-center justify-center",children:e.jsx(ur,{className:"w-1.5 h-1.5 text-gray-400 dark:text-gray-500"})})})}};return e.jsxs("div",{className:ke("bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700","hover:shadow-md hover:border-blue-300 dark:hover:border-blue-600 transition-all duration-200 cursor-pointer","p-3 space-y-3",r&&"hover:-translate-y-0.5",a),onClick:r,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx(Ct,{content:`Task ID: ${t.id}`,children:e.jsx("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 px-2 py-0.5 rounded",children:t.id})})}),e.jsx("h3",{className:"font-medium text-sm text-gray-900 dark:text-white line-clamp-2 leading-tight",children:t.title}),s&&t.parentId&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium",children:["Task ",t.parentId]})]}),e.jsx("div",{className:"flex-shrink-0",children:i(t.priority)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:t.dependencies&&Array.isArray(t.dependencies)&&t.dependencies.length>0&&e.jsx(Ct,{content:`Depends on: ${t.dependencies.map(c=>`Task ${c}`).join(", ")}`,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[e.jsx(va,{className:"w-3 h-3"}),e.jsxs("span",{children:["Depends on: ",t.dependencies.join(", ")]})]})})}),e.jsx(Ct,{content:`Status: ${o.statusText}`,children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:ke("w-2 h-2 rounded-full",o.iconColor.replace("text-","bg-"))}),e.jsx("span",{className:ke("text-xs font-medium",o.textColor),children:o.statusText})]})})]}),t.subtasks&&t.subtasks.length>0&&e.jsx("div",{className:"ml-3",children:e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Progress:"}),e.jsx(Ct,{content:`${t.subtasks.filter(c=>c.status==="done").length} of ${t.subtasks.length} subtasks completed`,children:e.jsx("div",{className:"flex-1 bg-gray-200 dark:bg-gray-700 rounded-full h-1.5",children:e.jsx("div",{className:ke("h-full rounded-full transition-all duration-300",t.status==="done"?"bg-green-500":"bg-blue-500"),style:{width:`${Math.round(t.subtasks.filter(c=>c.status==="done").length/t.subtasks.length*100)}%`}})})}),e.jsx(Ct,{content:`${t.subtasks.filter(c=>c.status==="done").length} completed, ${t.subtasks.filter(c=>c.status==="pending").length} pending, ${t.subtasks.filter(c=>c.status==="in-progress").length} in progress`,children:e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t.subtasks.filter(c=>c.status==="done").length,"/",t.subtasks.length]})})]})})]})},Zp=({currentProject:t,onClose:r,onTaskCreated:s})=>e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Ut,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Create AI-Generated Task"})]}),e.jsx("button",{onClick:r,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ut,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"💡 Pro Tip: Ask Your AI Assistant Directly!"}),e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-3",children:"You can simply ask your AI assistant in the chat to create tasks for you. The AI assistant will automatically generate detailed tasks with research-backed insights."}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-blue-200 dark:border-blue-700 p-3 mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Example:"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white font-mono",children:'"Please add a new task to implement user profile image uploads using Cloudinary, research the best approach."'})]}),e.jsxs("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:[e.jsx("strong",{children:"This runs:"})," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900/50 px-1 rounded text-xs",children:'task-master add-task --prompt="Implement user profile image uploads using Cloudinary" --research'})]})]})]})}),e.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),e.jsx("div",{className:"pt-4",children:e.jsx("button",{onClick:r,className:"w-full px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask my AI assistant directly"})})]})]})}),e0=({tasks:t=[],onTaskClick:r,className:s="",showParentTasks:a=!1,defaultView:n="kanban",currentProject:o,onTaskCreated:i,onShowPRDEditor:c,existingPRDs:u=[],onRefreshPRDs:d})=>{var B,ee;const[m,h]=l.useState(""),[p,g]=l.useState("all"),[f,x]=l.useState("all"),[b,N]=l.useState("id"),[j,y]=l.useState("asc"),[k,I]=l.useState(n),[D,C]=l.useState(!1),[v,E]=l.useState(!1),[T,W]=l.useState(!1),[S,O]=l.useState(!1),[H,R]=l.useState(!1),[A,z]=l.useState(!1),{projectTaskMaster:J,refreshProjects:re,refreshTasks:G,setCurrentProject:ie}=fr(),{t:$}=We("tasks");l.useEffect(()=>{const V=w=>{A&&!w.target.closest(".relative")&&z(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[A]);const Z=l.useMemo(()=>{const V=new Set(t.map(w=>w.status).filter(Boolean));return Array.from(V).sort()},[t]),te=l.useMemo(()=>{const V=new Set(t.map(w=>w.priority).filter(Boolean));return Array.from(V).sort()},[t]),Q=l.useMemo(()=>{let V=t.filter(w=>{var je;const M=m.toLowerCase(),Y=!m||w.title.toLowerCase().includes(M)||((je=w.description)==null?void 0:je.toLowerCase().includes(M))||w.id.toString().includes(M),se=p==="all"||w.status===p,de=f==="all"||w.priority===f;return Y&&se&&de});return V.sort((w,M)=>{let Y,se;switch(b){case"title":Y=w.title.toLowerCase(),se=M.title.toLowerCase();break;case"status":const de={pending:1,"in-progress":2,done:3,blocked:4,deferred:5,cancelled:6};Y=de[w.status]||99,se=de[M.status]||99;break;case"priority":const je={high:3,medium:2,low:1};Y=je[w.priority]||0,se=je[M.priority]||0;break;case"updated":Y=new Date(w.updatedAt||w.createdAt||0),se=new Date(M.updatedAt||M.createdAt||0);break;case"id":default:const ge=De=>De.toString().split(".").map(_e=>parseInt(_e,10)),Re=ge(w.id),Ne=ge(M.id);for(let De=0;De<Math.max(Re.length,Ne.length);De++){const Ue=Re[De]||0,_e=Ne[De]||0;if(Ue!==_e){Y=Ue,se=_e;break}}break}return b==="updated"?j==="asc"?Y-se:se-Y:typeof Y=="string"?j==="asc"?Y.localeCompare(se):se.localeCompare(Y):j==="asc"?Y-se:se-Y}),V},[t,m,p,f,b,j]),_=l.useMemo(()=>{const V=[{id:"pending",title:$("kanban.pending"),status:"pending",color:"bg-slate-50 dark:bg-slate-900/50 border-slate-200 dark:border-slate-700",headerColor:"bg-slate-100 dark:bg-slate-800 text-slate-800 dark:text-slate-200"},{id:"in-progress",title:$("kanban.inProgress"),status:"in-progress",color:"bg-blue-50 dark:bg-blue-900/50 border-blue-200 dark:border-blue-700",headerColor:"bg-blue-100 dark:bg-blue-800 text-blue-800 dark:text-blue-200"},{id:"done",title:$("kanban.done"),status:"done",color:"bg-emerald-50 dark:bg-emerald-900/50 border-emerald-200 dark:border-emerald-700",headerColor:"bg-emerald-100 dark:bg-emerald-800 text-emerald-800 dark:text-emerald-200"},{id:"blocked",title:$("kanban.blocked"),status:"blocked",color:"bg-red-50 dark:bg-red-900/50 border-red-200 dark:border-red-700",headerColor:"bg-red-100 dark:bg-red-800 text-red-800 dark:text-red-200"},{id:"deferred",title:$("kanban.deferred"),status:"deferred",color:"bg-amber-50 dark:bg-amber-900/50 border-amber-200 dark:border-amber-700",headerColor:"bg-amber-100 dark:bg-amber-800 text-amber-800 dark:text-amber-200"},{id:"cancelled",title:$("kanban.cancelled"),status:"cancelled",color:"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700",headerColor:"bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-200"}],w=["pending","in-progress","done"];return V.filter(Y=>{const se=Q.some(je=>je.status===Y.status),de=w.includes(Y.status);return se||de}).map(Y=>({...Y,tasks:Q.filter(se=>se.status===Y.status)}))},[Q,$]),F=V=>{b===V?y(j==="asc"?"desc":"asc"):(N(V),y("asc"))},q=()=>{h(""),g("all"),x("all")},U=V=>b!==V?e.jsx(Fi,{className:"w-4 h-4"}):j==="asc"?e.jsx(zi,{className:"w-4 h-4"}):e.jsx(ro,{className:"w-4 h-4"});if(t.length===0){const V=(o==null?void 0:o.taskMasterConfigured)||((B=o==null?void 0:o.taskmaster)==null?void 0:B.hasTaskmaster)||(J==null?void 0:J.hasTaskmaster);return e.jsxs("div",{className:ke("text-center py-12",s),children:[V?e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-950/50 dark:to-indigo-950/50 rounded-xl border border-blue-200 dark:border-blue-800 p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(gt,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:$("gettingStarted.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("gettingStarted.subtitle")})]})]}),e.jsxs("div",{className:"space-y-4 text-left",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:$("gettingStarted.steps.createPRD.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:$("gettingStarted.steps.createPRD.description")}),e.jsxs("button",{onClick:()=>{c==null||c()},className:"inline-flex items-center gap-1 text-xs bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 px-2 py-1 rounded hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors",children:[e.jsx(gt,{className:"w-3 h-3"}),$("gettingStarted.steps.createPRD.addButton")]}),u.length>0&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:$("gettingStarted.steps.createPRD.existingPRDs")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(w=>e.jsxs("button",{onClick:async()=>{try{const M=await Be.get(`/taskmaster/prd/${encodeURIComponent(o.name)}/${encodeURIComponent(w.name)}`);if(M.ok){const Y=await M.json();c==null||c({name:w.name,content:Y.content,isExisting:!0})}else console.error("Failed to load PRD:",M.statusText)}catch(M){console.error("Error loading PRD:",M)}},className:"inline-flex items-center gap-1 text-xs bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 px-2 py-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(gt,{className:"w-3 h-3"}),w.name]},w.name))})]})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:$("gettingStarted.steps.generateTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("gettingStarted.steps.generateTasks.description")})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:$("gettingStarted.steps.analyzeTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("gettingStarted.steps.analyzeTasks.description")})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"4"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:$("gettingStarted.steps.startBuilding.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("gettingStarted.steps.startBuilding.description")})]})]})]}),e.jsx("div",{className:"flex gap-3 pt-4 border-t border-blue-200 dark:border-blue-700",children:e.jsxs("button",{onClick:w=>{w.preventDefault(),w.stopPropagation(),c==null||c()},className:"flex items-center gap-2 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg font-medium transition-colors cursor-pointer",style:{zIndex:10},children:[e.jsx(gt,{className:"w-4 h-4"}),$("buttons.addPRD")]})})]})]}),e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mb-2",children:$("gettingStarted.tip")})})]}):e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsx("div",{className:"text-blue-600 dark:text-blue-400 mb-4",children:e.jsx(Dt,{className:"w-12 h-12 mx-auto mb-4"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:$("notConfigured.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:$("notConfigured.description")}),e.jsxs("div",{className:"mb-6 p-4 bg-blue-50 dark:bg-blue-950 rounded-lg text-left",children:[e.jsx("h4",{className:"text-sm font-medium text-blue-900 dark:text-blue-100 mb-3",children:$("notConfigured.whatIsTitle")}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("p",{children:["• ",$("notConfigured.features.aiPowered")]}),e.jsxs("p",{children:["• ",$("notConfigured.features.prdTemplates")]}),e.jsxs("p",{children:["• ",$("notConfigured.features.dependencyTracking")]}),e.jsxs("p",{children:["• ",$("notConfigured.features.progressVisualization")]}),e.jsxs("p",{children:["• ",$("notConfigured.features.cliIntegration")]})]})]}),e.jsxs("button",{onClick:()=>{R(!1),W(!0)},className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium transition-colors flex items-center gap-2 mx-auto",children:[e.jsx(vt,{className:"w-4 h-4"}),$("notConfigured.initializeButton")]})]}),T&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center p-4 pt-16 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl h-[600px] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(vt,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:$("setupModal.title")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:$("setupModal.subtitle",{projectName:o==null?void 0:o.displayName})})]})]}),e.jsx("button",{onClick:()=>{W(!1),setTimeout(()=>{re(),o&&ie(o)},1e3)},className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800",children:e.jsx(at,{className:"w-5 h-5 rotate-45"})})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"h-full bg-black rounded-lg overflow-hidden",onClick:w=>{const M=w.currentTarget.querySelector(".xterm-screen");M&&M.focus()},children:e.jsx(co,{selectedProject:o,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0,onProcessComplete:w=>{R(!0),w===0&&setTimeout(()=>{re(),o&&ie(o)},1e3)}})})}),e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:H?e.jsxs("span",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),$("setupModal.completed")]}):$("setupModal.willStart")}),e.jsx("button",{onClick:()=>{W(!1),R(!1),setTimeout(()=>{re(),o&&ie(o)},1e3)},className:ke("px-4 py-2 text-sm font-medium rounded-md transition-colors",H?"bg-green-600 hover:bg-green-700 text-white":"text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600"),children:$(H?"setupModal.closeContinueButton":"setupModal.closeButton")})]})})]})})]})}return e.jsxs("div",{className:ke("space-y-4",s),children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-3 lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(Ar,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),e.jsx("input",{type:"text",placeholder:$("search.placeholder"),value:m,onChange:V=>h(V.target.value),className:"pl-10 pr-4 py-2 w-full border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"flex bg-gray-100 dark:bg-gray-800 rounded-lg p-1",children:[e.jsx("button",{onClick:()=>I("kanban"),className:ke("p-2 rounded-md transition-colors",k==="kanban"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:$("views.kanban"),children:e.jsx(Li,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>I("list"),className:ke("p-2 rounded-md transition-colors",k==="list"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:$("views.list"),children:e.jsx(Xs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>I("grid"),className:ke("p-2 rounded-md transition-colors",k==="grid"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:$("views.grid"),children:e.jsx(Pi,{className:"w-4 h-4"})})]}),e.jsxs("button",{onClick:()=>C(!D),className:ke("flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors",D?"bg-blue-50 dark:bg-blue-900 border-blue-200 dark:border-blue-700 text-blue-700 dark:text-blue-300":"bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"),children:[e.jsx($i,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:$("filters.button")}),e.jsx(Pt,{className:ke("w-4 h-4 transition-transform",D&&"rotate-180")})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>O(!0),className:"p-2 text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors border border-gray-300 dark:border-gray-600",title:$("buttons.help"),children:e.jsx(_i,{className:"w-4 h-4"})}),e.jsx("div",{className:"relative",children:u.length>0?e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>z(!A),className:"flex items-center gap-2 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors font-medium",title:$("buttons.prdsAvailable",{count:u.length}),children:[e.jsx(gt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:$("buttons.prds")}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs bg-purple-500 rounded-full min-w-[1.25rem] text-center",children:u.length}),e.jsx(Pt,{className:ke("w-3 h-3 transition-transform hidden sm:block",A&&"rotate-180")})]}),A&&e.jsx("div",{className:"absolute right-0 top-full mt-2 w-56 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-xl z-30",children:e.jsxs("div",{className:"p-2",children:[e.jsxs("button",{onClick:()=>{c==null||c(),z(!1)},className:"w-full text-left px-3 py-2 text-sm font-medium text-purple-700 dark:text-purple-300 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded flex items-center gap-2",children:[e.jsx(at,{className:"w-4 h-4"}),$("buttons.createNewPRD")]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 my-1"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 px-3 py-1 font-medium",children:$("gettingStarted.steps.createPRD.existingPRDs")}),u.map(V=>e.jsxs("button",{onClick:async()=>{try{const w=await Be.get(`/taskmaster/prd/${encodeURIComponent(o.name)}/${encodeURIComponent(V.name)}`);if(w.ok){const M=await w.json();c==null||c({name:V.name,content:M.content,isExisting:!0}),z(!1)}}catch(w){console.error("Error loading PRD:",w)}},className:"w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded flex items-center gap-2",title:$("prd.modified",{date:new Date(V.modified).toLocaleDateString()}),children:[e.jsx(gt,{className:"w-4 h-4"}),e.jsx("span",{className:"truncate",children:V.name})]},V.name))]})})]}):e.jsxs("button",{onClick:()=>{c==null||c()},className:"flex items-center gap-2 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors font-medium",title:$("buttons.addPRD"),children:[e.jsx(gt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:$("buttons.addPRD")})]})}),((o==null?void 0:o.taskMasterConfigured)||((ee=o==null?void 0:o.taskmaster)==null?void 0:ee.hasTaskmaster)||(J==null?void 0:J.hasTaskmaster)||t.length>0)&&e.jsxs("button",{onClick:()=>E(!0),className:"flex items-center gap-2 px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium",title:$("buttons.addTask"),children:[e.jsx(at,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:$("buttons.addTask")})]})]})]})]}),D&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:$("filters.status")}),e.jsxs("select",{value:p,onChange:V=>g(V.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:$("filters.allStatuses")}),Z.map(V=>e.jsx("option",{value:V,children:$(`statuses.${V}`,V.charAt(0).toUpperCase()+V.slice(1).replace("-"," "))},V))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:$("filters.priority")}),e.jsxs("select",{value:f,onChange:V=>x(V.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:$("filters.allPriorities")}),te.map(V=>e.jsx("option",{value:V,children:$(`priorities.${V}`,V.charAt(0).toUpperCase()+V.slice(1))},V))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:$("filters.sortBy")}),e.jsxs("select",{value:`${b}-${j}`,onChange:V=>{const[w,M]=V.target.value.split("-");N(w),y(M)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"id-asc",children:$("sort.idAsc")}),e.jsx("option",{value:"id-desc",children:$("sort.idDesc")}),e.jsx("option",{value:"title-asc",children:$("sort.titleAsc")}),e.jsx("option",{value:"title-desc",children:$("sort.titleDesc")}),e.jsx("option",{value:"status-asc",children:$("sort.statusAsc")}),e.jsx("option",{value:"status-desc",children:$("sort.statusDesc")}),e.jsx("option",{value:"priority-asc",children:$("sort.priorityAsc")}),e.jsx("option",{value:"priority-desc",children:$("sort.priorityDesc")})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("filters.showing",{filtered:Q.length,total:t.length})}),e.jsx("button",{onClick:q,className:"text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium",children:$("filters.clearFilters")})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>F("id"),className:ke("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",b==="id"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[$("sort.id")," ",U("id")]}),e.jsxs("button",{onClick:()=>F("status"),className:ke("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",b==="status"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[$("sort.status")," ",U("status")]}),e.jsxs("button",{onClick:()=>F("priority"),className:ke("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",b==="priority"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[$("sort.priority")," ",U("priority")]})]}),Q.length===0?e.jsx("div",{className:"text-center py-12",children:e.jsxs("div",{className:"text-gray-500 dark:text-gray-400",children:[e.jsx(Ar,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:$("noMatchingTasks.title")}),e.jsx("p",{className:"text-sm",children:$("noMatchingTasks.description")})]})}):k==="kanban"?e.jsx("div",{className:ke("grid gap-6",_.length===1&&"grid-cols-1 max-w-md mx-auto",_.length===2&&"grid-cols-1 md:grid-cols-2",_.length===3&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",_.length===4&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-4",_.length===5&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5",_.length>=6&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6"),children:_.map(V=>e.jsxs("div",{className:ke("rounded-xl border shadow-sm transition-shadow hover:shadow-md",V.color),children:[e.jsx("div",{className:ke("px-4 py-3 rounded-t-xl border-b",V.headerColor),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold text-sm",children:V.title}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-xs font-medium px-2 py-1 bg-white/60 dark:bg-black/20 rounded-full",children:V.tasks.length})})]})}),e.jsx("div",{className:"p-3 space-y-3 min-h-[200px] max-h-[calc(100vh-300px)] overflow-y-auto",children:V.tasks.length===0?e.jsxs("div",{className:"text-center py-8 text-gray-400 dark:text-gray-500",children:[e.jsx("div",{className:"w-8 h-8 mx-auto mb-2 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center",children:e.jsx("div",{className:"w-3 h-3 rounded-full bg-gray-300 dark:bg-gray-600"})}),e.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:$("kanban.noTasksYet")}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:V.status==="pending"?$("kanban.tasksWillAppear"):V.status==="in-progress"?$("kanban.moveTasksHere"):V.status==="done"?$("kanban.completedTasksHere"):$("kanban.statusTasksHere")})]}):V.tasks.map(w=>e.jsx("div",{className:"transform transition-transform hover:scale-[1.02]",children:e.jsx(Un,{task:w,onClick:()=>r==null?void 0:r(w),showParent:a,className:"w-full shadow-sm hover:shadow-md transition-shadow cursor-pointer"})},w.id))})]},V.id))}):e.jsx("div",{className:ke("gap-4",k==="grid"?"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3":"space-y-4"),children:Q.map(V=>e.jsx(Un,{task:V,onClick:()=>r==null?void 0:r(V),showParent:a,className:k==="grid"?"h-full":""},V.id))}),v&&e.jsx(Zp,{currentProject:o,onClose:()=>E(!1),onTaskCreated:()=>{E(!1),i&&i()}}),S&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl max-h-[90vh] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(gt,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:$("helpGuide.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("helpGuide.subtitle")})]})]}),e.jsx("button",{onClick:()=>O(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-120px)]",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-950/50 dark:to-indigo-950/50 rounded-lg border border-blue-200 dark:border-blue-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-blue-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:$("gettingStarted.steps.createPRD.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:$("gettingStarted.steps.createPRD.description")}),e.jsxs("button",{onClick:()=>{c==null||c(),O(!1)},className:"inline-flex items-center gap-2 text-sm bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 px-3 py-1.5 rounded-lg hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors",children:[e.jsx(gt,{className:"w-4 h-4"}),$("buttons.addPRD")]})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-green-50 to-emerald-50 dark:from-green-950/50 dark:to-emerald-950/50 rounded-lg border border-green-200 dark:border-green-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-green-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:$("gettingStarted.steps.generateTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:$("gettingStarted.steps.generateTasks.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-green-200 dark:border-green-700/50 p-3 mb-2",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:$("helpGuide.examples.parsePRD")})})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-amber-50 to-orange-50 dark:from-amber-950/50 dark:to-orange-950/50 rounded-lg border border-amber-200 dark:border-amber-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-amber-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:$("gettingStarted.steps.analyzeTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:$("gettingStarted.steps.analyzeTasks.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-amber-200 dark:border-amber-700/50 p-3 mb-2",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:$("helpGuide.examples.expandTask")})})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-purple-50 to-pink-50 dark:from-purple-950/50 dark:to-pink-950/50 rounded-lg border border-purple-200 dark:border-purple-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-purple-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"4"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:$("gettingStarted.steps.startBuilding.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:$("gettingStarted.steps.startBuilding.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-purple-200 dark:border-purple-700/50 p-3 mb-3",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:$("helpGuide.examples.addTask")})}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:$("helpGuide.moreExamples")})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-3",children:$("helpGuide.proTips.title")}),e.jsxs("ul",{className:"space-y-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full mt-2 flex-shrink-0"}),$("helpGuide.proTips.search")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-green-500 rounded-full mt-2 flex-shrink-0"}),$("helpGuide.proTips.views")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-purple-500 rounded-full mt-2 flex-shrink-0"}),$("helpGuide.proTips.filters")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-orange-500 rounded-full mt-2 flex-shrink-0"}),$("helpGuide.proTips.details")]})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-blue-50 dark:bg-blue-950/50 rounded-lg border border-blue-200 dark:border-blue-800",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-3",children:$("helpGuide.learnMore.title")}),e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-3",children:$("helpGuide.learnMore.description")}),e.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm bg-blue-600 hover:bg-blue-700 text-white px-3 py-2 rounded-lg font-medium transition-colors",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),$("helpGuide.learnMore.githubButton"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]})})]})})]})},t0=({file:t,onClose:r,projectPath:s,project:a,initialContent:n="",isNewFile:o=!1,onSave:i})=>{const{addToast:c}=hr(),[u,d]=l.useState(n),[m,h]=l.useState(!o),[p,g]=l.useState(!1),[f,x]=l.useState(!1),[b,N]=l.useState(!0),[j,y]=l.useState(!1),[k,I]=l.useState(!1),[D,C]=l.useState(!0),[v,E]=l.useState(""),[T,W]=l.useState(!1),[S,O]=l.useState(!1),[H,R]=l.useState([]),A=l.useRef(null),z=`# Product Requirements Document - Example Project
279
279
 
280
280
  ## 1. Overview
281
281
  **Product Name:** AI-Powered Task Manager
@@ -538,8 +538,8 @@ Error: ${Q.message}
538
538
  File: ${(t==null?void 0:t.name)||"New PRD"}
539
539
  Path: ${(t==null?void 0:t.path)||"Not saved yet"}
540
540
 
541
- ${z}`)}finally{h(!1)}})()},[t,s,o]),l.useEffect(()=>{(async()=>{if(!(a!=null&&a.name)){console.log("No project name available:",a);return}try{console.log("Fetching PRDs for project:",a.name);const Q=await Be.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(Q.ok){const _=await Q.json();console.log("Fetched existing PRDs:",_.prds),R(_.prds||[])}else console.log("Failed to fetch PRDs:",Q.status,Q.statusText)}catch(Q){console.error("Error fetching existing PRDs:",Q)}})()},[a==null?void 0:a.name]);const J=async()=>{if(!u.trim()){c("Please add content before saving.","warning");return}if(!v.trim()){c("Please provide a filename for the PRD.","warning");return}const te=v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,Q=H.find(_=>_.name===te);if(console.log("Save check:",{fullFileName:te,existingPRDs:H,existingFile:Q,isExisting:t==null?void 0:t.isExisting,fileObject:t,shouldShowModal:Q&&!(t!=null&&t.isExisting)}),Q&&!(t!=null&&t.isExisting)){console.log("Showing overwrite confirmation modal"),O(!0);return}await re()},re=async()=>{g(!0);try{const te=v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,Q=await Me(`/api/taskmaster/prd/${encodeURIComponent(a==null?void 0:a.name)}`,{method:"POST",body:JSON.stringify({fileName:te,content:u})});if(!Q.ok){const F=await Q.json();throw new Error(F.message||`Save failed: ${Q.status}`)}y(!0),setTimeout(()=>y(!1),2e3);const _=await Be.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(_.ok){const F=await _.json();R(F.prds||[])}i&&await i()}catch(te){console.error("Error saving PRD:",te),c(`Error saving PRD: ${te.message}`,"error")}finally{g(!1)}},G=()=>{const te=new Blob([u],{type:"text/markdown"}),Q=URL.createObjectURL(te),_=document.createElement("a");_.href=Q;const F=v?`${v}.txt`:"prd.txt";_.download=F,document.body.appendChild(_),_.click(),document.body.removeChild(_),URL.revokeObjectURL(Q)},ie=async()=>{if(!u.trim()){c("Please add content to the PRD before generating tasks.","warning");return}W(!0)},$=()=>{x(!f)};l.useEffect(()=>{const te=Q=>{(Q.ctrlKey||Q.metaKey)&&(Q.key==="s"?(Q.preventDefault(),J()):Q.key==="Escape"&&(Q.preventDefault(),r()))};return document.addEventListener("keydown",te),()=>document.removeEventListener("keydown",te)},[u]);const Z=te=>te.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/^\- (.*$)/gim,"<li>$1</li>").replace(/(<li>.*<\/li>)/gims,"<ul>$1</ul>").replace(/\n\n/gim,"</p><p>").replace(/^(?!<[h|u|l])(.*$)/gim,"<p>$1</p>").replace(/<\/ul>\s*<ul>/gim,"");return m?e.jsx("div",{className:"fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center",children:e.jsx("div",{className:"w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center bg-white dark:bg-gray-900",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading PRD..."})]})})}):e.jsxs("div",{className:`fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${f?"md:p-0":""}`,children:[e.jsxs("div",{className:ke("bg-white dark:bg-gray-900 shadow-2xl flex flex-col","w-full h-full md:rounded-lg md:shadow-2xl",f?"md:w-full md:h-full md:rounded-none":"md:w-full md:max-w-6xl md:h-[85vh] md:max-h-[85vh]"),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-600 rounded flex items-center justify-center flex-shrink-0",children:e.jsx(gt,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center min-w-0 flex-1 bg-gray-50 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md px-3 py-2 focus-within:ring-2 focus-within:ring-purple-500 focus-within:border-purple-500 dark:focus-within:ring-purple-400 dark:focus-within:border-purple-400",children:[e.jsx("input",{type:"text",value:v,onChange:te=>{const Q=te.target.value.replace(/[<>:"/\\|?*]/g,"");E(Q)},className:"font-medium text-gray-900 dark:text-white bg-transparent border-none outline-none min-w-0 flex-1 text-base sm:text-sm placeholder-gray-400 dark:placeholder-gray-500",placeholder:"Enter PRD filename",maxLength:100}),e.jsx("span",{className:"text-sm sm:text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap ml-1",children:".txt"})]}),e.jsx("button",{onClick:()=>{var te;return(te=document.querySelector('input[placeholder="Enter PRD filename"]'))==null?void 0:te.focus()},className:"p-1 text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 transition-colors",title:"Click to edit filename",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:"text-xs bg-purple-100 dark:bg-purple-900 text-purple-600 dark:text-purple-300 px-2 py-1 rounded whitespace-nowrap",children:"📋 PRD"}),o&&e.jsx("span",{className:"text-xs bg-green-100 dark:bg-green-900 text-green-600 dark:text-green-300 px-2 py-1 rounded whitespace-nowrap",children:"✨ New"})]})]}),e.jsx("p",{className:"text-xs sm:text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:"Product Requirements Document"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>I(!k),className:ke("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",k?"text-purple-600 dark:text-purple-400 bg-purple-50 dark:bg-purple-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:k?"Switch to edit mode":"Preview markdown",children:e.jsx(sr,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsx("button",{onClick:()=>C(!D),className:ke("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",D?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:D?"Disable word wrap":"Enable word wrap",children:e.jsx("span",{className:"text-sm md:text-xs font-mono font-bold",children:"↵"})}),e.jsx("button",{onClick:()=>N(!b),className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Toggle theme",children:e.jsx("span",{className:"text-lg md:text-base",children:b?"☀️":"🌙"})}),e.jsx("button",{onClick:G,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Download PRD",children:e.jsx(oo,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsxs("button",{onClick:ie,disabled:!u.trim(),className:ke("px-3 py-2 rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors text-sm font-medium","bg-purple-600 hover:bg-purple-700 text-white","min-h-[44px] md:min-h-0"),title:"Generate tasks from PRD content",children:[e.jsx(Ut,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:"Generate Tasks"})]}),e.jsx("button",{onClick:J,disabled:p,className:ke("px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors","min-h-[44px] md:min-h-0",j?"bg-green-600 hover:bg-green-700":"bg-purple-600 hover:bg-purple-700"),children:j?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"hidden sm:inline",children:"Saved!"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ts,{className:"w-5 h-5 md:w-4 md:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Saving...":"Save PRD"})]})}),e.jsx("button",{onClick:$,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:f?"Exit fullscreen":"Fullscreen",children:f?e.jsx(io,{className:"w-4 h-4"}):e.jsx(ba,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Close",children:e.jsx(Ve,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:k?e.jsx("div",{className:"h-full overflow-y-auto p-6 prose prose-gray dark:prose-invert max-w-none",children:e.jsx("div",{className:"markdown-preview",dangerouslySetInnerHTML:{__html:Z(u)}})}):e.jsx(po,{ref:A,value:u,onChange:d,extensions:[go(),...D?[Wt.lineWrapping]:[]],theme:b?xo:void 0,height:"100%",style:{fontSize:"14px",height:"100%"},basicSetup:{lineNumbers:!0,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:["Lines: ",u.split(`
542
- `).length]}),e.jsxs("span",{children:["Characters: ",u.length]}),e.jsxs("span",{children:["Words: ",u.split(/\s+/).filter(te=>te.length>0).length]}),e.jsx("span",{children:"Format: Markdown"})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]}),T&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Ut,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Generate Tasks from PRD"})]}),e.jsx("button",{onClick:()=>W(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ut,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-purple-900 dark:text-purple-100 mb-2",children:"💡 Pro Tip: Ask Your AI Assistant Directly!"}),e.jsx("p",{className:"text-sm text-purple-800 dark:text-purple-200 mb-3",children:"You can simply ask your AI assistant in the chat to parse your PRD and generate tasks. The AI assistant will automatically save your PRD and create detailed tasks with implementation details."}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-purple-200 dark:border-purple-700 p-3 mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"💬 Example:"}),e.jsxs("p",{className:"text-xs text-gray-900 dark:text-white font-mono",children:[`"I've just initialized a new project with Claude Task Master. I have a PRD at .taskmaster/docs/`,v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,'. Can you help me parse it and set up the initial tasks?"']})]}),e.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:[e.jsx("strong",{children:"This will:"})," Save your PRD, analyze its content, and generate structured tasks with subtasks, dependencies, and implementation details."]})]})]})}),e.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-purple-600 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),e.jsx("div",{className:"pt-4",children:e.jsx("button",{onClick:()=>W(!1),className:"w-full px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask my AI assistant directly"})})]})]})}),S&&e.jsxs("div",{className:"fixed inset-0 z-[300] flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>O(!1)}),e.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"p-2 rounded-full mr-3 bg-yellow-100 dark:bg-yellow-900",children:e.jsx($t,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"File Already Exists"})]}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:['A PRD file named "',v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,'" already exists. Do you want to overwrite it with the current content?']}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>O(!1),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:async()=>{O(!1),await re()},className:"px-4 py-2 text-sm text-white bg-yellow-600 hover:bg-yellow-700 rounded-md flex items-center space-x-2 transition-colors",children:[e.jsx(ts,{className:"w-4 h-4"}),e.jsx("span",{children:"Overwrite"})]})]})]})})]})]})},t0=Zp,r0=Wo,s0=e0,a0="PRD saved successfully!";function n0(t){return t.prdFiles||t.prds||[]}function o0({isVisible:t}){const{tasks:r=[],currentProject:s,refreshTasks:a}=fr(),[n,o]=l.useState(null),[i,c]=l.useState(!1),[u,d]=l.useState(!1),[m,h]=l.useState(null),[p,g]=l.useState([]),[f,x]=l.useState(null),b=l.useRef(null),N=l.useCallback(T=>{b.current&&clearTimeout(b.current),x(T),b.current=setTimeout(()=>{x(null),b.current=null},3e3)},[]),j=l.useCallback(async()=>{if(!(s!=null&&s.name)){g([]);return}try{const T=await Be.get(`/taskmaster/prd/${encodeURIComponent(s.name)}`);if(!T.ok){g([]);return}const W=await T.json();g(n0(W))}catch(T){console.error("Failed to load existing PRDs:",T),g([])}},[s==null?void 0:s.name]),y=l.useCallback(async(T=!1)=>{await j(),T&&N(a0)},[j,N]);l.useEffect(()=>{j()},[j]),l.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const k=l.useCallback(T=>{if(!(!T||typeof T!="object"||!("id"in T))){if(!("title"in T)||!T.title){const W=r.find(S=>String(S.id)===String(T.id));W&&(o(W),c(!0));return}o(T),c(!0)}},[r]),I=l.useCallback(()=>{c(!1),o(null)},[]),D=l.useCallback((T,W)=>{console.log("Update task status:",T,W),a==null||a()},[a]),C=l.useCallback((T=null)=>{h(T),d(!0)},[]),v=l.useCallback(()=>{d(!1),h(null)},[]),E=l.useCallback(async()=>{v(),await y(!0),a==null||a()},[v,y,a]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`h-full ${t?"block":"hidden"}`,children:e.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:e.jsx(t0,{tasks:r,onTaskClick:k,showParentTasks:!0,className:"flex-1 overflow-y-auto p-4",currentProject:s,onTaskCreated:a||void 0,onShowPRDEditor:C,existingPRDs:p,onRefreshPRDs:(T=!1)=>{y(T)}})})}),i&&n&&e.jsx(r0,{task:n,isOpen:i,onClose:I,onStatusChange:D,onTaskClick:k}),u&&e.jsx(s0,{project:s,projectPath:(s==null?void 0:s.fullPath)||(s==null?void 0:s.path),onClose:v,isNewFile:!(m!=null&&m.isExisting),file:{name:(m==null?void 0:m.name)||"prd.txt",content:(m==null?void 0:m.content)||""},onSave:E}),f&&e.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-in slide-in-from-bottom-2 duration-300",children:e.jsxs("div",{className:"bg-green-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"font-medium",children:f})]})})]})}function i0(){const{isRelayConnected:t,isChecking:r,sandboxActive:s,isDisconnecting:a,disconnect:n,relayCwd:o,relayMachine:i}=ps(),[c,u]=l.useState(!1),[d,m]=l.useState(!1),h="uc connect",p=l.useCallback(()=>{navigator.clipboard.writeText(h),u(!0),setTimeout(()=>u(!1),2e3)},[]),g=l.useCallback(async()=>{await n()&&m(!1)},[n]);return r?null:t?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-green-500/5 border-b border-green-500/15 text-sm",children:[e.jsx(zi,{className:"w-3.5 h-3.5 text-green-500 flex-shrink-0"}),e.jsx("span",{className:"text-green-400 text-xs font-medium",children:"Connected"}),i&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-[150px]",children:i}),o&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-[200px] hidden sm:inline",children:o.split(/[\\/]/).slice(-2).join("/")}),s&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/20 text-emerald-400 border border-emerald-500/30",children:"Isolated"}),e.jsx("div",{className:"ml-auto flex items-center gap-1",children:d?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-amber-400",children:"Disconnect?"}),e.jsx("button",{onClick:g,disabled:a,className:"text-[10px] px-2 py-0.5 rounded bg-red-500/20 text-red-400 hover:bg-red-500/30 border border-red-500/30 transition-colors disabled:opacity-40",children:a?"Disconnecting...":"Yes"}),e.jsx("button",{onClick:()=>m(!1),className:"text-[10px] px-2 py-0.5 rounded bg-muted text-muted-foreground hover:bg-muted/80 transition-colors",children:"No"})]}):e.jsx("button",{onClick:()=>m(!0),className:"p-1 rounded hover:bg-red-500/10 text-muted-foreground hover:text-red-400 transition-colors",title:"Disconnect relay",children:e.jsx(Ri,{className:"w-3.5 h-3.5"})})})]}):e.jsxs("div",{className:"border-b border-amber-500/20 bg-amber-500/10",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(Xn,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-amber-300",children:"Connect your machine to get started"})]}),e.jsxs("div",{className:"px-4 pb-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1.5",children:"Run these commands in your terminal:"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:"npm install -g upfynai-code"})}),e.jsx("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:"uc login"})}),e.jsxs("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:[e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:h}),e.jsx("button",{onClick:p,className:"flex-shrink-0 p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",title:"Copy command",children:c?e.jsx(Lt,{className:"w-3.5 h-3.5 text-green-400"}):e.jsx(ha,{className:"w-3.5 h-3.5"})})]})]})]})]})}function l0(){const{connectionState:t,reconnectAttempts:r}=Qn();return t==="connected"||t==="disconnected"?null:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-500/10 border-b border-amber-500/20 text-amber-400 text-xs animate-in fade-in duration-300",children:[e.jsx("div",{className:"w-2 h-2 bg-amber-400 rounded-full animate-pulse shrink-0"}),e.jsx("span",{children:t==="connecting"?"Connecting...":e.jsxs(e.Fragment,{children:["Reconnecting to server",r>1&&e.jsxs("span",{className:"text-amber-400/60 ml-1",children:["(attempt ",r,")"]}),e.jsx("span",{className:"ml-1.5",children:"— your session is preserved"})]})})]})}function Xr({children:t,fallback:r,bypass:s}){const{isRelayConnected:a}=ps();return s||a?e.jsx(e.Fragment,{children:t}):e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 backdrop-blur-sm",children:r}),e.jsx("div",{className:"h-full w-full opacity-30 pointer-events-none select-none","aria-hidden":!0,children:t})]})}function fs({icon:t,label:r}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",role:"status","aria-label":`${r} loading`,children:[e.jsx(t,{className:"w-10 h-10 opacity-40"}),e.jsxs("p",{className:"text-sm font-medium",children:[r," requires a connected machine"]}),e.jsx("p",{className:"text-xs opacity-60",children:"Connect your machine to get started"})]})}function c0(){return e.jsx(fs,{icon:va,label:"Chat"})}function Un(){return e.jsx(fs,{icon:vt,label:"Shell"})}function Hn(){return e.jsx(fs,{icon:Oi,label:"Files"})}function Gn(){return e.jsx(fs,{icon:br,label:"Git"})}function d0({selectedProject:t,isMobile:r,initialWidth:s=600}){const[a,n]=l.useState(null),[o,i]=l.useState(s),[c,u]=l.useState(!1),[d,m]=l.useState(!1),h=l.useRef(null),[p,g]=l.useState(280),[f,x]=l.useState(!1),b=l.useRef(null),N=l.useCallback((D,C=null)=>{const E=D.replace(/\\/g,"/").split("/").pop()||D;n({name:E,path:D,projectName:t==null?void 0:t.name,diffInfo:C})},[t==null?void 0:t.name]),j=l.useCallback(()=>{n(null),u(!1)},[]),y=l.useCallback(()=>{u(D=>!D)},[]),k=l.useCallback(D=>{r||(x(!0),D.preventDefault())},[r]);l.useEffect(()=>{const D=v=>{var H;if(!f)return;const E=(H=b.current)==null?void 0:H.parentElement;if(!E)return;const T=E.getBoundingClientRect(),W=v.clientX-T.left,S=180,O=Math.min(500,T.width*.5);W>=S&&W<=O&&g(W)},C=()=>{x(!1)};return f&&(document.addEventListener("mousemove",D),document.addEventListener("mouseup",C),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",C),f&&(document.body.style.cursor="",document.body.style.userSelect="")}},[f]);const I=l.useCallback(D=>{r||(m(!0),D.preventDefault())},[r]);return l.useEffect(()=>{const D=v=>{var H;if(!d)return;const E=(H=h.current)==null?void 0:H.parentElement;if(!E)return;const T=E.getBoundingClientRect(),W=T.right-v.clientX,S=300,O=T.width*.8;W>=S&&W<=O&&i(W)},C=()=>{m(!1)};return d&&(document.addEventListener("mousemove",D),document.addEventListener("mouseup",C),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",C),document.body.style.cursor="",document.body.style.userSelect=""}},[d]),{editingFile:a,editorWidth:o,editorExpanded:c,resizeHandleRef:h,handleFileOpen:N,handleCloseEditor:j,handleToggleEditorExpand:y,handleResizeStart:I,fileTreeWidth:p,fileTreeResizeRef:b,handleFileTreeResizeStart:k}}function u0({isMobile:t,initialWidth:r=520}){const[s,a]=l.useState([]),[n,o]=l.useState([]),[i,c]=l.useState(null),[u,d]=l.useState(r),[m,h]=l.useState(!1),[p,g]=l.useState(!1),f=l.useRef(null),x=s.length>0||n.length>0,b=l.useCallback(C=>{a(v=>v.find(T=>T.id===C.id)?v.map(T=>T.id===C.id?C:T):[...v,C]),c(C.id)},[]),N=l.useCallback(C=>{a(v=>{const E=v.find(T=>T.id===C);return E&&o(T=>{const W=T.filter(S=>S.id!==C);return[E,...W].slice(0,20)}),v.filter(T=>T.id!==C)}),c(v=>{if(v!==C)return v;const E=s.filter(T=>T.id!==C);return E.length>0?E[E.length-1].id:null})},[s]),j=l.useCallback(C=>{const v=n.find(E=>E.id===C);v&&(o(E=>E.filter(T=>T.id!==C)),a(E=>[...E,v]),c(v.id))},[n]),y=l.useCallback(()=>{o([])},[]),k=l.useCallback(()=>{a(C=>(C.length>0&&o(v=>{const E=new Set(v.map(W=>W.id));return[...C.filter(W=>!E.has(W.id)),...v].slice(0,20)}),[])),c(null),h(!1)},[]),I=l.useCallback(()=>{h(C=>!C)},[]),D=l.useCallback(C=>{t||(g(!0),C.preventDefault())},[t]);return l.useEffect(()=>{const C=E=>{var R;if(!p)return;const T=(R=f.current)==null?void 0:R.parentElement;if(!T)return;const W=T.getBoundingClientRect(),S=W.right-E.clientX,O=320,H=W.width*.75;S>=O&&S<=H&&d(S)},v=()=>{g(!1)};return p&&(document.addEventListener("mousemove",C),document.addEventListener("mouseup",v),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",v),p&&(document.body.style.cursor="",document.body.style.userSelect="")}},[p]),{artifacts:s,recentArtifacts:n,activeArtifactId:i,setActiveArtifactId:c,panelWidth:u,panelExpanded:m,isOpen:x,resizeHandleRef:f,openArtifact:b,closeArtifact:N,reopenArtifact:j,clearHistory:y,closeAll:k,toggleExpand:I,handleResizeStart:D}}const m0=l.lazy(()=>kt(()=>import("./FileTree-CbJF7m5P.js"),__vite__mapDeps([6,2,7,1,3,8,9,10,11,12,13,14,15,16,17]))),p0=l.lazy(()=>kt(()=>import("./LoginModal-Bk9mxZsi.js").then(t=>t.c),__vite__mapDeps([11,2,7,1,3,8,9,10,12,13,14,15,16]))),x0=l.lazy(()=>kt(()=>import("./GitPanel-avzqm9Zj.js"),__vite__mapDeps([18,2,7,1,3,8,9,10,11,12,13,14,15,16,17]))),g0=l.lazy(()=>kt(()=>import("./WorkflowsPanel-BOaVEpdu.js"),__vite__mapDeps([19,2,7,1,3,8,9,10]))),h0=l.lazy(()=>kt(()=>import("./DashboardPanel-DmHbSyTP.js"),__vite__mapDeps([20,2,7,1,3,8,9,10,11,12,13,14,15,16,17]))),f0=l.lazy(()=>kt(()=>import("./CanvasWorkspace-DksIgrfl.js"),__vite__mapDeps([21,1,2,3,14,15,16,7,8,9,10]))),b0=l.lazy(()=>kt(()=>import("./PreviewPanel-CqCa92Tf.js"),__vite__mapDeps([22,2])));function y0({selectedProject:t,selectedSession:r,activeTab:s,setActiveTab:a,ws:n,sendMessage:o,latestMessage:i,isMobile:c,onMenuClick:u,isLoading:d,onInputFocusChange:m,onSessionActive:h,onSessionInactive:p,onSessionProcessing:g,onSessionNotProcessing:f,processingSessions:x,onReplaceTemporarySession:b,onNavigateToSession:N,onShowSettings:j,externalMessageUpdate:y}){var _e,L;const k=Yn(),{preferences:I}=ja(),{autoExpandTools:D,showRawParameters:C,showThinking:v,autoScrollToBottom:E,sendByCtrlEnter:T}=I,{currentProject:W,setCurrentProject:S}=fr(),{tasksEnabled:O,isTaskMasterInstalled:H}=Lr(),R=O!==!1,{editingFile:A,editorWidth:z,editorExpanded:J,resizeHandleRef:re,handleFileOpen:G,handleCloseEditor:ie,handleToggleEditorExpand:$,handleResizeStart:Z,fileTreeWidth:te,fileTreeResizeRef:Q,handleFileTreeResizeStart:_}=d0({selectedProject:t,isMobile:c}),{artifacts:F,recentArtifacts:q,activeArtifactId:U,setActiveArtifactId:B,panelWidth:ee,panelExpanded:V,isOpen:w,resizeHandleRef:M,openArtifact:Y,closeArtifact:se,reopenArtifact:de,clearHistory:je,closeAll:ge,toggleExpand:Re,handleResizeStart:Ne}=u0({isMobile:c}),De=it.useCallback(K=>{Y(K)},[Y]),Ue=it.useCallback(async K=>{var pe,ye,Ie,Fe;if(t!=null&&t.name)try{const Oe=await(await Be.canvas.load(t.name)).json(),ne=Oe.elements||[];let fe=[],Ee=[];ne.length===1&&((pe=ne[0])!=null&&pe.nodes)?(fe=ne[0].nodes,Ee=ne[0].edges||[]):ne.length>0&&((ye=ne[0])!=null&&ye.position)&&(fe=ne.filter(Ce=>!Ce.source),Ee=ne.filter(Ce=>Ce.source));const Pe={code:"response",diff:"response",terminal:"response",search:"response",html:"webpage",markdown:"note"}[K.type]||"note";let Ae="";K.type==="code"?Ae=String(K.data.content||""):K.type==="diff"?Ae=`Diff: ${K.data.filePath||"file"}
541
+ ${z}`)}finally{h(!1)}})()},[t,s,o]),l.useEffect(()=>{(async()=>{if(!(a!=null&&a.name)){console.log("No project name available:",a);return}try{console.log("Fetching PRDs for project:",a.name);const Q=await Be.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(Q.ok){const _=await Q.json();console.log("Fetched existing PRDs:",_.prds),R(_.prds||[])}else console.log("Failed to fetch PRDs:",Q.status,Q.statusText)}catch(Q){console.error("Error fetching existing PRDs:",Q)}})()},[a==null?void 0:a.name]);const J=async()=>{if(!u.trim()){c("Please add content before saving.","warning");return}if(!v.trim()){c("Please provide a filename for the PRD.","warning");return}const te=v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,Q=H.find(_=>_.name===te);if(console.log("Save check:",{fullFileName:te,existingPRDs:H,existingFile:Q,isExisting:t==null?void 0:t.isExisting,fileObject:t,shouldShowModal:Q&&!(t!=null&&t.isExisting)}),Q&&!(t!=null&&t.isExisting)){console.log("Showing overwrite confirmation modal"),O(!0);return}await re()},re=async()=>{g(!0);try{const te=v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,Q=await Me(`/api/taskmaster/prd/${encodeURIComponent(a==null?void 0:a.name)}`,{method:"POST",body:JSON.stringify({fileName:te,content:u})});if(!Q.ok){const F=await Q.json();throw new Error(F.message||`Save failed: ${Q.status}`)}y(!0),setTimeout(()=>y(!1),2e3);const _=await Be.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(_.ok){const F=await _.json();R(F.prds||[])}i&&await i()}catch(te){console.error("Error saving PRD:",te),c(`Error saving PRD: ${te.message}`,"error")}finally{g(!1)}},G=()=>{const te=new Blob([u],{type:"text/markdown"}),Q=URL.createObjectURL(te),_=document.createElement("a");_.href=Q;const F=v?`${v}.txt`:"prd.txt";_.download=F,document.body.appendChild(_),_.click(),document.body.removeChild(_),URL.revokeObjectURL(Q)},ie=async()=>{if(!u.trim()){c("Please add content to the PRD before generating tasks.","warning");return}W(!0)},$=()=>{x(!f)};l.useEffect(()=>{const te=Q=>{(Q.ctrlKey||Q.metaKey)&&(Q.key==="s"?(Q.preventDefault(),J()):Q.key==="Escape"&&(Q.preventDefault(),r()))};return document.addEventListener("keydown",te),()=>document.removeEventListener("keydown",te)},[u]);const Z=te=>te.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/^\- (.*$)/gim,"<li>$1</li>").replace(/(<li>.*<\/li>)/gims,"<ul>$1</ul>").replace(/\n\n/gim,"</p><p>").replace(/^(?!<[h|u|l])(.*$)/gim,"<p>$1</p>").replace(/<\/ul>\s*<ul>/gim,"");return m?e.jsx("div",{className:"fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center",children:e.jsx("div",{className:"w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center bg-white dark:bg-gray-900",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading PRD..."})]})})}):e.jsxs("div",{className:`fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${f?"md:p-0":""}`,children:[e.jsxs("div",{className:ke("bg-white dark:bg-gray-900 shadow-2xl flex flex-col","w-full h-full md:rounded-lg md:shadow-2xl",f?"md:w-full md:h-full md:rounded-none":"md:w-full md:max-w-6xl md:h-[85vh] md:max-h-[85vh]"),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-600 rounded flex items-center justify-center flex-shrink-0",children:e.jsx(gt,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center min-w-0 flex-1 bg-gray-50 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md px-3 py-2 focus-within:ring-2 focus-within:ring-purple-500 focus-within:border-purple-500 dark:focus-within:ring-purple-400 dark:focus-within:border-purple-400",children:[e.jsx("input",{type:"text",value:v,onChange:te=>{const Q=te.target.value.replace(/[<>:"/\\|?*]/g,"");E(Q)},className:"font-medium text-gray-900 dark:text-white bg-transparent border-none outline-none min-w-0 flex-1 text-base sm:text-sm placeholder-gray-400 dark:placeholder-gray-500",placeholder:"Enter PRD filename",maxLength:100}),e.jsx("span",{className:"text-sm sm:text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap ml-1",children:".txt"})]}),e.jsx("button",{onClick:()=>{var te;return(te=document.querySelector('input[placeholder="Enter PRD filename"]'))==null?void 0:te.focus()},className:"p-1 text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 transition-colors",title:"Click to edit filename",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:"text-xs bg-purple-100 dark:bg-purple-900 text-purple-600 dark:text-purple-300 px-2 py-1 rounded whitespace-nowrap",children:"📋 PRD"}),o&&e.jsx("span",{className:"text-xs bg-green-100 dark:bg-green-900 text-green-600 dark:text-green-300 px-2 py-1 rounded whitespace-nowrap",children:"✨ New"})]})]}),e.jsx("p",{className:"text-xs sm:text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:"Product Requirements Document"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>I(!k),className:ke("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",k?"text-purple-600 dark:text-purple-400 bg-purple-50 dark:bg-purple-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:k?"Switch to edit mode":"Preview markdown",children:e.jsx(sr,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsx("button",{onClick:()=>C(!D),className:ke("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",D?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:D?"Disable word wrap":"Enable word wrap",children:e.jsx("span",{className:"text-sm md:text-xs font-mono font-bold",children:"↵"})}),e.jsx("button",{onClick:()=>N(!b),className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Toggle theme",children:e.jsx("span",{className:"text-lg md:text-base",children:b?"☀️":"🌙"})}),e.jsx("button",{onClick:G,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Download PRD",children:e.jsx(io,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsxs("button",{onClick:ie,disabled:!u.trim(),className:ke("px-3 py-2 rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors text-sm font-medium","bg-purple-600 hover:bg-purple-700 text-white","min-h-[44px] md:min-h-0"),title:"Generate tasks from PRD content",children:[e.jsx(Ut,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:"Generate Tasks"})]}),e.jsx("button",{onClick:J,disabled:p,className:ke("px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors","min-h-[44px] md:min-h-0",j?"bg-green-600 hover:bg-green-700":"bg-purple-600 hover:bg-purple-700"),children:j?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"hidden sm:inline",children:"Saved!"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ts,{className:"w-5 h-5 md:w-4 md:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Saving...":"Save PRD"})]})}),e.jsx("button",{onClick:$,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:f?"Exit fullscreen":"Fullscreen",children:f?e.jsx(lo,{className:"w-4 h-4"}):e.jsx(ya,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Close",children:e.jsx(Ve,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:k?e.jsx("div",{className:"h-full overflow-y-auto p-6 prose prose-gray dark:prose-invert max-w-none",children:e.jsx("div",{className:"markdown-preview",dangerouslySetInnerHTML:{__html:Z(u)}})}):e.jsx(xo,{ref:A,value:u,onChange:d,extensions:[ho(),...D?[Wt.lineWrapping]:[]],theme:b?go:void 0,height:"100%",style:{fontSize:"14px",height:"100%"},basicSetup:{lineNumbers:!0,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:["Lines: ",u.split(`
542
+ `).length]}),e.jsxs("span",{children:["Characters: ",u.length]}),e.jsxs("span",{children:["Words: ",u.split(/\s+/).filter(te=>te.length>0).length]}),e.jsx("span",{children:"Format: Markdown"})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]}),T&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Ut,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Generate Tasks from PRD"})]}),e.jsx("button",{onClick:()=>W(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(Ve,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ut,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-purple-900 dark:text-purple-100 mb-2",children:"💡 Pro Tip: Ask Your AI Assistant Directly!"}),e.jsx("p",{className:"text-sm text-purple-800 dark:text-purple-200 mb-3",children:"You can simply ask your AI assistant in the chat to parse your PRD and generate tasks. The AI assistant will automatically save your PRD and create detailed tasks with implementation details."}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-purple-200 dark:border-purple-700 p-3 mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"💬 Example:"}),e.jsxs("p",{className:"text-xs text-gray-900 dark:text-white font-mono",children:[`"I've just initialized a new project with Claude Task Master. I have a PRD at .taskmaster/docs/`,v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,'. Can you help me parse it and set up the initial tasks?"']})]}),e.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:[e.jsx("strong",{children:"This will:"})," Save your PRD, analyze its content, and generate structured tasks with subtasks, dependencies, and implementation details."]})]})]})}),e.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-purple-600 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),e.jsx("div",{className:"pt-4",children:e.jsx("button",{onClick:()=>W(!1),className:"w-full px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask my AI assistant directly"})})]})]})}),S&&e.jsxs("div",{className:"fixed inset-0 z-[300] flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>O(!1)}),e.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"p-2 rounded-full mr-3 bg-yellow-100 dark:bg-yellow-900",children:e.jsx($t,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"File Already Exists"})]}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:['A PRD file named "',v.endsWith(".txt")||v.endsWith(".md")?v:`${v}.txt`,'" already exists. Do you want to overwrite it with the current content?']}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>O(!1),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:async()=>{O(!1),await re()},className:"px-4 py-2 text-sm text-white bg-yellow-600 hover:bg-yellow-700 rounded-md flex items-center space-x-2 transition-colors",children:[e.jsx(ts,{className:"w-4 h-4"}),e.jsx("span",{children:"Overwrite"})]})]})]})})]})]})},r0=e0,s0=Uo,a0=t0,n0="PRD saved successfully!";function o0(t){return t.prdFiles||t.prds||[]}function i0({isVisible:t}){const{tasks:r=[],currentProject:s,refreshTasks:a}=fr(),[n,o]=l.useState(null),[i,c]=l.useState(!1),[u,d]=l.useState(!1),[m,h]=l.useState(null),[p,g]=l.useState([]),[f,x]=l.useState(null),b=l.useRef(null),N=l.useCallback(T=>{b.current&&clearTimeout(b.current),x(T),b.current=setTimeout(()=>{x(null),b.current=null},3e3)},[]),j=l.useCallback(async()=>{if(!(s!=null&&s.name)){g([]);return}try{const T=await Be.get(`/taskmaster/prd/${encodeURIComponent(s.name)}`);if(!T.ok){g([]);return}const W=await T.json();g(o0(W))}catch(T){console.error("Failed to load existing PRDs:",T),g([])}},[s==null?void 0:s.name]),y=l.useCallback(async(T=!1)=>{await j(),T&&N(n0)},[j,N]);l.useEffect(()=>{j()},[j]),l.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const k=l.useCallback(T=>{if(!(!T||typeof T!="object"||!("id"in T))){if(!("title"in T)||!T.title){const W=r.find(S=>String(S.id)===String(T.id));W&&(o(W),c(!0));return}o(T),c(!0)}},[r]),I=l.useCallback(()=>{c(!1),o(null)},[]),D=l.useCallback((T,W)=>{console.log("Update task status:",T,W),a==null||a()},[a]),C=l.useCallback((T=null)=>{h(T),d(!0)},[]),v=l.useCallback(()=>{d(!1),h(null)},[]),E=l.useCallback(async()=>{v(),await y(!0),a==null||a()},[v,y,a]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`h-full ${t?"block":"hidden"}`,children:e.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:e.jsx(r0,{tasks:r,onTaskClick:k,showParentTasks:!0,className:"flex-1 overflow-y-auto p-4",currentProject:s,onTaskCreated:a||void 0,onShowPRDEditor:C,existingPRDs:p,onRefreshPRDs:(T=!1)=>{y(T)}})})}),i&&n&&e.jsx(s0,{task:n,isOpen:i,onClose:I,onStatusChange:D,onTaskClick:k}),u&&e.jsx(a0,{project:s,projectPath:(s==null?void 0:s.fullPath)||(s==null?void 0:s.path),onClose:v,isNewFile:!(m!=null&&m.isExisting),file:{name:(m==null?void 0:m.name)||"prd.txt",content:(m==null?void 0:m.content)||""},onSave:E}),f&&e.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-in slide-in-from-bottom-2 duration-300",children:e.jsxs("div",{className:"bg-green-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"font-medium",children:f})]})})]})}function l0(){const{isRelayConnected:t,isChecking:r,sandboxActive:s,isDisconnecting:a,disconnect:n,relayCwd:o,relayMachine:i}=ps(),[c,u]=l.useState(!1),[d,m]=l.useState(!1),h="uc connect",p=l.useCallback(()=>{navigator.clipboard.writeText(h),u(!0),setTimeout(()=>u(!1),2e3)},[]),g=l.useCallback(async()=>{await n()&&m(!1)},[n]);return r?null:t?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-green-500/5 border-b border-green-500/15 text-sm",children:[e.jsx(Ri,{className:"w-3.5 h-3.5 text-green-500 flex-shrink-0"}),e.jsx("span",{className:"text-green-400 text-xs font-medium",children:"Connected"}),i&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-[150px]",children:i}),o&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-[200px] hidden sm:inline",children:o.split(/[\\/]/).slice(-2).join("/")}),s&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/20 text-emerald-400 border border-emerald-500/30",children:"Isolated"}),e.jsx("div",{className:"ml-auto flex items-center gap-1",children:d?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-amber-400",children:"Disconnect?"}),e.jsx("button",{onClick:g,disabled:a,className:"text-[10px] px-2 py-0.5 rounded bg-red-500/20 text-red-400 hover:bg-red-500/30 border border-red-500/30 transition-colors disabled:opacity-40",children:a?"Disconnecting...":"Yes"}),e.jsx("button",{onClick:()=>m(!1),className:"text-[10px] px-2 py-0.5 rounded bg-muted text-muted-foreground hover:bg-muted/80 transition-colors",children:"No"})]}):e.jsx("button",{onClick:()=>m(!0),className:"p-1 rounded hover:bg-red-500/10 text-muted-foreground hover:text-red-400 transition-colors",title:"Disconnect relay",children:e.jsx(Oi,{className:"w-3.5 h-3.5"})})})]}):e.jsxs("div",{className:"border-b border-amber-500/20 bg-amber-500/10",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(Zn,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-amber-300",children:"Connect your machine to get started"})]}),e.jsxs("div",{className:"px-4 pb-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1.5",children:"Run these commands in your terminal:"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:"npm install -g upfynai-code"})}),e.jsx("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:"uc login"})}),e.jsxs("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:[e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:h}),e.jsx("button",{onClick:p,className:"flex-shrink-0 p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",title:"Copy command",children:c?e.jsx(Lt,{className:"w-3.5 h-3.5 text-green-400"}):e.jsx(fa,{className:"w-3.5 h-3.5"})})]})]})]})]})}function c0(){const{connectionState:t,reconnectAttempts:r}=Xn();return t==="connected"||t==="disconnected"?null:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-500/10 border-b border-amber-500/20 text-amber-400 text-xs animate-in fade-in duration-300",children:[e.jsx("div",{className:"w-2 h-2 bg-amber-400 rounded-full animate-pulse shrink-0"}),e.jsx("span",{children:t==="connecting"?"Connecting...":e.jsxs(e.Fragment,{children:["Reconnecting to server",r>1&&e.jsxs("span",{className:"text-amber-400/60 ml-1",children:["(attempt ",r,")"]}),e.jsx("span",{className:"ml-1.5",children:"— your session is preserved"})]})})]})}function Xr({children:t,fallback:r,bypass:s}){const{isRelayConnected:a}=ps();return s||a?e.jsx(e.Fragment,{children:t}):e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 backdrop-blur-sm",children:r}),e.jsx("div",{className:"h-full w-full opacity-30 pointer-events-none select-none","aria-hidden":!0,children:t})]})}function fs({icon:t,label:r}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",role:"status","aria-label":`${r} loading`,children:[e.jsx(t,{className:"w-10 h-10 opacity-40"}),e.jsxs("p",{className:"text-sm font-medium",children:[r," requires a connected machine"]}),e.jsx("p",{className:"text-xs opacity-60",children:"Connect your machine to get started"})]})}function d0(){return e.jsx(fs,{icon:ka,label:"Chat"})}function Hn(){return e.jsx(fs,{icon:vt,label:"Shell"})}function Gn(){return e.jsx(fs,{icon:Bi,label:"Files"})}function Vn(){return e.jsx(fs,{icon:br,label:"Git"})}function u0({selectedProject:t,isMobile:r,initialWidth:s=600}){const[a,n]=l.useState(null),[o,i]=l.useState(s),[c,u]=l.useState(!1),[d,m]=l.useState(!1),h=l.useRef(null),[p,g]=l.useState(280),[f,x]=l.useState(!1),b=l.useRef(null),N=l.useCallback((D,C=null)=>{const E=D.replace(/\\/g,"/").split("/").pop()||D;n({name:E,path:D,projectName:t==null?void 0:t.name,diffInfo:C})},[t==null?void 0:t.name]),j=l.useCallback(()=>{n(null),u(!1)},[]),y=l.useCallback(()=>{u(D=>!D)},[]),k=l.useCallback(D=>{r||(x(!0),D.preventDefault())},[r]);l.useEffect(()=>{const D=v=>{var H;if(!f)return;const E=(H=b.current)==null?void 0:H.parentElement;if(!E)return;const T=E.getBoundingClientRect(),W=v.clientX-T.left,S=180,O=Math.min(500,T.width*.5);W>=S&&W<=O&&g(W)},C=()=>{x(!1)};return f&&(document.addEventListener("mousemove",D),document.addEventListener("mouseup",C),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",C),f&&(document.body.style.cursor="",document.body.style.userSelect="")}},[f]);const I=l.useCallback(D=>{r||(m(!0),D.preventDefault())},[r]);return l.useEffect(()=>{const D=v=>{var H;if(!d)return;const E=(H=h.current)==null?void 0:H.parentElement;if(!E)return;const T=E.getBoundingClientRect(),W=T.right-v.clientX,S=300,O=T.width*.8;W>=S&&W<=O&&i(W)},C=()=>{m(!1)};return d&&(document.addEventListener("mousemove",D),document.addEventListener("mouseup",C),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",C),document.body.style.cursor="",document.body.style.userSelect=""}},[d]),{editingFile:a,editorWidth:o,editorExpanded:c,resizeHandleRef:h,handleFileOpen:N,handleCloseEditor:j,handleToggleEditorExpand:y,handleResizeStart:I,fileTreeWidth:p,fileTreeResizeRef:b,handleFileTreeResizeStart:k}}function m0({isMobile:t,initialWidth:r=520}){const[s,a]=l.useState([]),[n,o]=l.useState([]),[i,c]=l.useState(null),[u,d]=l.useState(r),[m,h]=l.useState(!1),[p,g]=l.useState(!1),f=l.useRef(null),x=s.length>0||n.length>0,b=l.useCallback(C=>{a(v=>v.find(T=>T.id===C.id)?v.map(T=>T.id===C.id?C:T):[...v,C]),c(C.id)},[]),N=l.useCallback(C=>{a(v=>{const E=v.find(T=>T.id===C);return E&&o(T=>{const W=T.filter(S=>S.id!==C);return[E,...W].slice(0,20)}),v.filter(T=>T.id!==C)}),c(v=>{if(v!==C)return v;const E=s.filter(T=>T.id!==C);return E.length>0?E[E.length-1].id:null})},[s]),j=l.useCallback(C=>{const v=n.find(E=>E.id===C);v&&(o(E=>E.filter(T=>T.id!==C)),a(E=>[...E,v]),c(v.id))},[n]),y=l.useCallback(()=>{o([])},[]),k=l.useCallback(()=>{a(C=>(C.length>0&&o(v=>{const E=new Set(v.map(W=>W.id));return[...C.filter(W=>!E.has(W.id)),...v].slice(0,20)}),[])),c(null),h(!1)},[]),I=l.useCallback(()=>{h(C=>!C)},[]),D=l.useCallback(C=>{t||(g(!0),C.preventDefault())},[t]);return l.useEffect(()=>{const C=E=>{var R;if(!p)return;const T=(R=f.current)==null?void 0:R.parentElement;if(!T)return;const W=T.getBoundingClientRect(),S=W.right-E.clientX,O=320,H=W.width*.75;S>=O&&S<=H&&d(S)},v=()=>{g(!1)};return p&&(document.addEventListener("mousemove",C),document.addEventListener("mouseup",v),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",v),p&&(document.body.style.cursor="",document.body.style.userSelect="")}},[p]),{artifacts:s,recentArtifacts:n,activeArtifactId:i,setActiveArtifactId:c,panelWidth:u,panelExpanded:m,isOpen:x,resizeHandleRef:f,openArtifact:b,closeArtifact:N,reopenArtifact:j,clearHistory:y,closeAll:k,toggleExpand:I,handleResizeStart:D}}const p0=l.lazy(()=>kt(()=>import("./FileTree-BDUnBheV.js"),__vite__mapDeps([6,2,7,1,3,8,9,10,11,12,13,14,15,16,17]))),x0=l.lazy(()=>kt(()=>import("./LoginModal-BWep8a6g.js").then(t=>t.c),__vite__mapDeps([11,2,7,1,3,8,9,10,12,13,14,15,16]))),g0=l.lazy(()=>kt(()=>import("./GitPanel-RtyZUIWS.js"),__vite__mapDeps([18,2,7,1,3,8,9,10,11,12,13,14,15,16,17]))),h0=l.lazy(()=>kt(()=>import("./WorkflowsPanel-B2mIXDvD.js"),__vite__mapDeps([19,2,7,1,3,8,9,10]))),f0=l.lazy(()=>kt(()=>import("./DashboardPanel-CblJfTGi.js"),__vite__mapDeps([20,2,7,1,3,8,9,10,11,12,13,14,15,16,17]))),b0=l.lazy(()=>kt(()=>import("./CanvasWorkspace-Bk9R9_e0.js"),__vite__mapDeps([21,1,2,3,14,15,16,7,8,9,10]))),y0=l.lazy(()=>kt(()=>import("./PreviewPanel-CqCa92Tf.js"),__vite__mapDeps([22,2])));function v0({selectedProject:t,selectedSession:r,activeTab:s,setActiveTab:a,ws:n,sendMessage:o,latestMessage:i,isMobile:c,onMenuClick:u,isLoading:d,onInputFocusChange:m,onSessionActive:h,onSessionInactive:p,onSessionProcessing:g,onSessionNotProcessing:f,processingSessions:x,onReplaceTemporarySession:b,onNavigateToSession:N,onShowSettings:j,externalMessageUpdate:y}){var _e,L;const k=Qn(),{preferences:I}=Na(),{autoExpandTools:D,showRawParameters:C,showThinking:v,autoScrollToBottom:E,sendByCtrlEnter:T}=I,{currentProject:W,setCurrentProject:S}=fr(),{tasksEnabled:O,isTaskMasterInstalled:H}=Lr(),R=O!==!1,{editingFile:A,editorWidth:z,editorExpanded:J,resizeHandleRef:re,handleFileOpen:G,handleCloseEditor:ie,handleToggleEditorExpand:$,handleResizeStart:Z,fileTreeWidth:te,fileTreeResizeRef:Q,handleFileTreeResizeStart:_}=u0({selectedProject:t,isMobile:c}),{artifacts:F,recentArtifacts:q,activeArtifactId:U,setActiveArtifactId:B,panelWidth:ee,panelExpanded:V,isOpen:w,resizeHandleRef:M,openArtifact:Y,closeArtifact:se,reopenArtifact:de,clearHistory:je,closeAll:ge,toggleExpand:Re,handleResizeStart:Ne}=m0({isMobile:c}),De=it.useCallback(K=>{Y(K)},[Y]),Ue=it.useCallback(async K=>{var pe,ye,Ie,Fe;if(t!=null&&t.name)try{const Oe=await(await Be.canvas.load(t.name)).json(),ne=Oe.elements||[];let fe=[],Ee=[];ne.length===1&&((pe=ne[0])!=null&&pe.nodes)?(fe=ne[0].nodes,Ee=ne[0].edges||[]):ne.length>0&&((ye=ne[0])!=null&&ye.position)&&(fe=ne.filter(Ce=>!Ce.source),Ee=ne.filter(Ce=>Ce.source));const Pe={code:"response",diff:"response",terminal:"response",search:"response",html:"webpage",markdown:"note"}[K.type]||"note";let Ae="";K.type==="code"?Ae=String(K.data.content||""):K.type==="diff"?Ae=`Diff: ${K.data.filePath||"file"}
543
543
  +${String(K.data.newContent||"").split(`
544
544
  `).length} lines`:K.type==="terminal"?Ae=String(K.data.output||""):K.type==="search"?Ae=(K.data.files||[]).join(`
545
- `):K.type==="html"?Ae=String(K.data.html||""):Ae=String(K.data.content||"");const Ge=fe[fe.length-1],ae=Ge?(((Ie=Ge.position)==null?void 0:Ie.x)||0)+300:100,be=Ge?((Fe=Ge.position)==null?void 0:Fe.y)||0:100,ze={id:`pinned_${Date.now()}`,type:Pe,position:{x:ae,y:be},data:{label:K.title,content:Ae.slice(0,2e3),...K.type==="html"&&{html:Ae,pageName:K.title}}};fe.push(ze),await Be.canvas.save(t.name,[{nodes:fe,edges:Ee}],Oe.appState||{})}catch{}},[t==null?void 0:t.name]);return l.useEffect(()=>{t&&t!==W&&(S==null||S(t))},[t,W,S]),l.useEffect(()=>{!R&&s==="tasks"&&a("chat")},[R,s,a]),d?e.jsx($n,{mode:"loading",isMobile:c,onMenuClick:u}):t?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(Cp,{activeTab:s,setActiveTab:a,selectedProject:t,selectedSession:r,shouldShowTasksTab:R,isMobile:c,onMenuClick:u}),e.jsx(l0,{}),e.jsx(i0,{}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:`flex flex-col min-h-0 overflow-hidden ${J?"hidden":""} ${s==="files"&&A?"flex-shrink-0":"flex-1"}`,style:s==="files"&&A?{width:`${te}px`}:void 0,children:[s==="dashboard"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading dashboard..."}),children:e.jsx(h0,{selectedProject:t})})}),e.jsx("div",{className:`h-full ${s==="chat"?"block":"hidden"}`,children:e.jsx(Xr,{fallback:e.jsx(c0,{}),children:e.jsx(jr,{showDetails:!0,children:e.jsx(bp,{selectedProject:t,selectedSession:r,ws:n,sendMessage:o,latestMessage:i,onFileOpen:G,onInputFocusChange:m,onSessionActive:h,onSessionInactive:p,onSessionProcessing:g,onSessionNotProcessing:f,processingSessions:x,onReplaceTemporarySession:b,onNavigateToSession:N,onShowSettings:j,autoExpandTools:D,showRawParameters:C,showThinking:v,autoScrollToBottom:E,sendByCtrlEnter:T,externalMessageUpdate:y,onShowAllTasks:O?()=>a("tasks"):null,setActiveTab:a,onArtifactOpen:De})})})}),s==="canvas"&&e.jsxs("div",{className:"h-full overflow-hidden relative",children:[e.jsx(jr,{children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-muted-foreground/30 border-t-muted-foreground rounded-full animate-spin"}),"Loading canvas..."]})}),children:(t==null?void 0:t.name)&&e.jsx(f0,{projectName:t.name,sendMessage:o,latestMessage:i,isFullScreen:!1})})}),(t==null?void 0:t.name)&&e.jsxs("button",{onClick:()=>k(`/canvas/${encodeURIComponent(t.name)}`),className:"absolute top-3 right-32 z-20 flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-card/90 border border-border/50 text-xs text-muted-foreground hover:text-foreground hover:bg-card transition-colors backdrop-blur-sm shadow-sm",title:"Open in fullscreen",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})}),"Fullscreen"]})]}),e.jsx("div",{className:`h-full overflow-hidden ${s==="files"?"block":"hidden"}`,children:e.jsx(Xr,{fallback:e.jsx(Hn,{}),children:e.jsx(l.Suspense,{fallback:e.jsx(Hn,{}),children:e.jsx(m0,{selectedProject:t,onFileOpen:G,activeFilePath:(A==null?void 0:A.path)||null})})})}),e.jsx("div",{className:`h-full w-full overflow-hidden ${s==="shell"?"block":"hidden"}`,children:e.jsx(Xr,{fallback:e.jsx(Un,{}),children:e.jsx(jr,{children:e.jsx(l.Suspense,{fallback:e.jsx(Un,{}),children:e.jsx(p0,{project:t,session:r,showHeader:!1,multiTab:!0})})})})}),e.jsx("div",{className:`h-full overflow-hidden ${s==="git"?"block":"hidden"}`,children:e.jsx(Xr,{fallback:e.jsx(Gn,{}),children:e.jsx(jr,{children:e.jsx(l.Suspense,{fallback:e.jsx(Gn,{}),children:e.jsx(x0,{selectedProject:t,isMobile:c,onFileOpen:G})})})})}),s==="workflows"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(jr,{children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading workflows..."}),children:e.jsx(g0,{selectedProject:t})})})}),R&&e.jsx(o0,{isVisible:s==="tasks"}),s==="preview"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading preview..."}),children:e.jsx(b0,{initialHtml:(L=(_e=F.find(K=>K.type==="html"))==null?void 0:_e.data)==null?void 0:L.html})})})]}),s==="files"&&A&&!J&&e.jsx("div",{ref:Q,onMouseDown:_,className:"w-1 flex-shrink-0 cursor-col-resize hover:bg-primary/30 active:bg-primary/50 transition-colors relative group",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1"})}),e.jsx(Bp,{editingFile:A,isMobile:c,editorExpanded:J,editorWidth:z,resizeHandleRef:re,onResizeStart:Z,onCloseEditor:ie,onToggleEditorExpand:$,projectPath:t.path,fillSpace:s==="files"}),w&&!A&&(c?e.jsx("div",{className:"fixed inset-0 z-40 bg-gray-900 flex flex-col",children:e.jsx(Bn,{artifacts:F,recentArtifacts:q,activeArtifactId:U,panelWidth:ee,panelExpanded:V,resizeHandleRef:M,onResizeStart:Ne,onSetActive:B,onClose:se,onReopenArtifact:de,onClearHistory:je,onCloseAll:ge,onToggleExpand:Re,onPinToCanvas:Ue,onFileOpen:G})}):e.jsx(Bn,{artifacts:F,recentArtifacts:q,activeArtifactId:U,panelWidth:ee,panelExpanded:V,resizeHandleRef:M,onResizeStart:Ne,onSetActive:B,onClose:se,onReopenArtifact:de,onClearHistory:je,onCloseAll:ge,onToggleExpand:Re,onPinToCanvas:Ue,onFileOpen:G}))]})]}):e.jsx($n,{mode:"empty",isMobile:c,onMenuClick:u})}const v0=it.memo(y0);function k0({activeTab:t,setActiveTab:r,isInputFocused:s}){const{tasksEnabled:a,isTaskMasterInstalled:n}=Lr(),i=[{id:"dashboard",icon:Bi,label:"Home"},{id:"chat",icon:va,label:"Chat"},{id:"shell",icon:vt,label:"Shell"},{id:"files",icon:mr,label:"Files"},{id:"canvas",icon:Wi,label:"Canvas"},{id:"preview",icon:sr,label:"Preview"},{id:"git",icon:br,label:"Git"},{id:"workflows",icon:tr,label:"Auto"},...!!(a&&n)?[{id:"tasks",icon:no,label:"Tasks"}]:[]];return e.jsx("div",{className:`fixed bottom-0 left-0 right-0 z-50 px-2 pb-[max(6px,env(safe-area-inset-bottom))] transform transition-transform duration-300 ease-in-out ${s?"translate-y-full":"translate-y-0"}`,children:e.jsx("div",{className:"nav-glass mobile-nav-float rounded-2xl border border-border/30",children:e.jsx("div",{className:"flex items-center justify-around px-0.5 py-1 gap-0 overflow-x-auto scrollbar-hide",children:i.map(c=>{const u=c.icon,d=t===c.id;return e.jsxs("button",{onClick:()=>r(c.id),onTouchStart:m=>{m.preventDefault(),r(c.id)},className:`flex flex-col items-center justify-center gap-0.5 px-1.5 py-1.5 rounded-xl flex-shrink-0 min-w-[42px] relative touch-manipulation transition-all duration-200 active:scale-95 ${d?"text-primary":"text-muted-foreground hover:text-foreground"}`,"aria-label":c.label,"aria-current":d?"page":void 0,children:[d&&e.jsx("div",{className:"absolute inset-0 bg-primary/8 dark:bg-primary/12 rounded-xl"}),e.jsx(u,{className:`relative z-10 transition-all duration-200 ${d?"w-[18px] h-[18px]":"w-4 h-4"}`,strokeWidth:d?2.4:1.8}),e.jsx("span",{className:`relative z-10 text-[9px] leading-tight font-medium truncate w-full text-center transition-all duration-200 ${d?"opacity-100":"opacity-60"}`,children:c.label})]},c.id)})})})})}const Vn="upfyn-tour-complete",Nr=[{target:"chat",title:"Chat",description:"Talk to AI agents — Claude, Cursor, or Codex. Stream responses, run tools, and see every action live."},{target:"canvas",title:"Canvas",description:"A visual whiteboard for code blocks, diagrams, notes, and web previews. Drag, connect, and organize."},{target:"files",title:"Files",description:"Browse your project tree, open files in the built-in editor, and make quick edits."},{target:"shell",title:"Shell",description:"A full terminal — run commands, install packages, or manage processes. Supports multiple tabs."},{target:"git",title:"Git",description:"Stage, commit, push, and view diffs — all from the browser. No terminal needed."}];function w0(){const[t,r]=l.useState(!1),[s,a]=l.useState(0),[n,o]=l.useState(null);l.useEffect(()=>{if(localStorage.getItem(Vn))return;const x=setTimeout(()=>r(!0),800);return()=>clearTimeout(x)},[]);const i=l.useCallback(()=>{if(!t)return;const x=document.querySelector(`[data-tour="${Nr[s].target}"]`);o(x?x.getBoundingClientRect():null)},[t,s]);l.useEffect(()=>(i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)),[i]);const c=l.useCallback(()=>{r(!1),localStorage.setItem(Vn,"1")},[]),u=l.useCallback(()=>{s<Nr.length-1?a(s+1):c()},[s,c]),d=l.useCallback(()=>{s>0&&a(s-1)},[s]);if(l.useEffect(()=>{if(!t)return;const x=b=>{b.key==="Escape"?c():b.key==="ArrowRight"||b.key==="Enter"?u():b.key==="ArrowLeft"&&d()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t,u,d,c]),!t||!n)return null;const m=6,h={top:n.top-m,left:n.left-m,width:n.width+m*2,height:n.height+m*2},p=h.top+h.height+12,g=Math.max(12,Math.min(h.left+h.width/2-160,window.innerWidth-332)),f=Nr[s];return e.jsxs("div",{className:"fixed inset-0 z-[9999]",role:"dialog","aria-label":"Feature tour",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:c}),e.jsx("div",{className:"absolute rounded-lg ring-2 ring-primary/60 bg-transparent pointer-events-none",style:{...h,boxShadow:"0 0 0 9999px rgba(0,0,0,0.5)"}}),e.jsxs("div",{className:"absolute w-[320px] bg-card border border-border/60 rounded-xl shadow-2xl overflow-hidden",style:{top:p,left:g},children:[e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-sm font-bold text-foreground",children:f.title}),e.jsx("button",{onClick:c,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors","aria-label":"Skip tour",children:e.jsx(Ve,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:f.description})]}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-border/40 bg-muted/20",children:[e.jsxs("span",{className:"text-xs text-muted-foreground/60",children:[s+1," / ",Nr.length]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&e.jsxs("button",{onClick:d,className:"flex items-center gap-1 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors rounded-lg",children:[e.jsx(ga,{className:"w-3.5 h-3.5"}),"Back"]}),e.jsx("button",{onClick:u,className:"flex items-center gap-1 px-4 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:s<Nr.length-1?e.jsxs(e.Fragment,{children:["Next",e.jsx(rr,{className:"w-3.5 h-3.5"})]}):"Done"})]})]})]})]})}function j0(){const[t,r]=l.useState(new Set),[s,a]=l.useState(new Set),n=l.useCallback(d=>{d&&r(m=>new Set([...m,d]))},[]),o=l.useCallback(d=>{d&&r(m=>{const h=new Set(m);return h.delete(d),h})},[]),i=l.useCallback(d=>{d&&a(m=>new Set([...m,d]))},[]),c=l.useCallback(d=>{d&&a(m=>{const h=new Set(m);return h.delete(d),h})},[]),u=l.useCallback(d=>{d&&r(m=>{const h=new Set;for(const p of m)p.startsWith("new-session-")||h.add(p);return h.add(d),h})},[]);return{activeSessions:t,processingSessions:s,markSessionAsActive:n,markSessionAsInactive:o,markSessionAsProcessing:i,markSessionAsNotProcessing:c,replaceTemporarySession:u}}const mt=t=>JSON.stringify(t??null),qn=(t,r,s)=>t.length!==r.length?!0:r.some((a,n)=>{const o=t[n];return!o||a.name!==o.name||a.displayName!==o.displayName||a.fullPath!==o.fullPath||mt(a.sessionMeta)!==mt(o.sessionMeta)||mt(a.sessions)!==mt(o.sessions)?!0:mt(a.cursorSessions)!==mt(o.cursorSessions)||mt(a.codexSessions)!==mt(o.codexSessions)}),ms=t=>[...t.sessions??[],...t.codexSessions??[],...t.cursorSessions??[]],N0=(t,r,s,a)=>{if(!s||!a)return!0;const n=t.find(u=>u.name===s.name),o=r.find(u=>u.name===s.name);if(!n||!o)return!1;const i=ms(n).find(u=>u.id===a.id),c=ms(o).find(u=>u.id===a.id);return!i||!c?!1:i.id===c.id&&i.title===c.title&&i.created_at===c.created_at&&i.updated_at===c.updated_at};function C0({sessionId:t,navigate:r,latestMessage:s,isMobile:a,activeSessions:n}){const[o,i]=l.useState([]),[c,u]=l.useState(null),[d,m]=l.useState(null),[h,p]=l.useState("chat"),[g,f]=l.useState(!1),[x,b]=l.useState(!0),[N,j]=l.useState(null),[y,k]=l.useState(!1),[I,D]=l.useState(!1),[C,v]=l.useState("agents"),[E,T]=l.useState(0),{relayCwd:W,isRelayConnected:S}=ps(),O=l.useRef(null),H=l.useRef(new Set),R=l.useRef(null),A=l.useCallback(async()=>{try{b(!0);const _=await Be.projects();if(!_.ok)return;const F=await _.json();if(!Array.isArray(F))return;i(q=>q.length===0||qn(q,F,!0)?F:q)}catch(_){console.error("Error fetching projects:",_)}finally{b(!1)}},[]),z=l.useCallback((_="tools")=>{v(_),D(!0)},[]);l.useEffect(()=>{A()},[A]);const J=l.useRef(0);l.useEffect(()=>{if(x||o.length>0||!S||!W){J.current=0;return}if(J.current>=3)return;const _=setTimeout(()=>{J.current++,A()},1500);return()=>clearTimeout(_)},[x,o.length,S,W,A]),l.useEffect(()=>{if(!(x||c||t||o.length===0)){if(S&&W){const _=B=>B.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase(),F=_(W),q=F.split("/").pop()||"",U=o.find(B=>_(B.fullPath||"")===F||_(B.name||"")===q);if(U){u(U);return}}o.length===1&&u(o[0])}},[x,o,c,t,S,W]),l.useEffect(()=>{if(!R.current||o.length===0)return;const _=R.current,F=ee=>ee.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase(),q=F(_),U=q.split("/").pop()||"",B=o.find(ee=>F(ee.fullPath||"")===q||F(ee.name||"")===U);B&&(R.current=null,u(B),m(null),p("chat"),r("/"))},[o,r]),l.useEffect(()=>{if(!s)return;if((s.type==="relay-init"||s.type==="relay-status")&&s.cwd&&s.connected!==!1){R.current=s.cwd,A();return}if(s.type==="shell-project-selected"&&s.projectPath){R.current=s.projectPath,A();return}if(s.type==="loading_progress"){O.current&&(clearTimeout(O.current),O.current=null),j(s),s.phase==="complete"&&(O.current=setTimeout(()=>{j(null),O.current=null},500));return}if(s.type!=="projects_updated")return;const _=s;if(_.changedFile&&d&&c){const V=_.changedFile.replace(/\\/g,"/").split("/");V.length>=2&&V[V.length-1].replace(".jsonl","")===d.id&&(n.has(d.id)||T(se=>se+1))}const F=d&&n.has(d.id)||n.size>0&&Array.from(n).some(ee=>ee.startsWith("new-session-")),q=_.projects;if(!Array.isArray(q)||F&&!N0(o,q,c,d)||(i(q),!c))return;const U=q.find(ee=>ee.name===c.name);if(!U||(mt(U)!==mt(c)&&u(U),!d))return;ms(U).find(ee=>ee.id===d.id)||m(null)},[s,c,d,n,o]),l.useEffect(()=>()=>{O.current&&(clearTimeout(O.current),O.current=null)},[]),l.useEffect(()=>{var F,q,U;if(!t||o.length===0)return;const _=!d||d.id!==t;for(const B of o){const ee=(F=B.sessions)==null?void 0:F.find(M=>M.id===t);if(ee){const M=(c==null?void 0:c.name)!==B.name,Y=(d==null?void 0:d.id)!==t||d.__provider!=="claude";M&&u(B),Y&&m({...ee,__provider:"claude"}),_&&p("chat");return}const V=(q=B.cursorSessions)==null?void 0:q.find(M=>M.id===t);if(V){const M=(c==null?void 0:c.name)!==B.name,Y=(d==null?void 0:d.id)!==t||d.__provider!=="cursor";M&&u(B),Y&&m({...V,__provider:"cursor"}),_&&p("chat");return}const w=(U=B.codexSessions)==null?void 0:U.find(M=>M.id===t);if(w){const M=(c==null?void 0:c.name)!==B.name,Y=(d==null?void 0:d.id)!==t||d.__provider!=="codex";M&&u(B),Y&&m({...w,__provider:"codex"}),_&&p("chat");return}}},[t,o,c==null?void 0:c.name,d==null?void 0:d.id,d==null?void 0:d.__provider]);const re=l.useCallback(_=>{u(_),m(null),r("/"),a&&f(!1)},[a,r]),G=l.useCallback(_=>{if(m(_),h!=="git"&&h!=="preview"&&p("chat"),(localStorage.getItem("selected-provider")||"claude")==="cursor"&&sessionStorage.setItem("cursorSessionId",_.id),a){const q=_.__projectName,U=c==null?void 0:c.name;q!==U&&f(!1)}r(`/session/${_.id}`)},[h,a,r,c==null?void 0:c.name]),ie=l.useCallback(_=>{u(_),m(null),p("chat"),r("/"),a&&f(!1)},[a,r]),$=l.useCallback(_=>{H.current.add(_),setTimeout(()=>H.current.delete(_),3e4),(d==null?void 0:d.id)===_&&(m(null),r("/")),i(F=>F.map(q=>{var U,B;return{...q,sessions:((U=q.sessions)==null?void 0:U.filter(ee=>ee.id!==_))??[],sessionMeta:{...q.sessionMeta,total:Math.max(0,(((B=q.sessionMeta)==null?void 0:B.total)??0)-1)}}}))},[r,d==null?void 0:d.id]),Z=l.useCallback(async()=>{try{const _=await Be.projects();if(!_.ok)return;let F=await _.json();if(!Array.isArray(F)||(H.current.size>0&&(F=F.map(B=>{var ee;return{...B,sessions:((ee=B.sessions)==null?void 0:ee.filter(V=>!H.current.has(V.id)))??[]}})),i(B=>qn(B,F,!0)?F:B),!c))return;const q=F.find(B=>B.name===c.name);if(!q||(mt(q)!==mt(c)&&u(q),!d))return;const U=ms(q).find(B=>B.id===d.id);if(U){const B=U.__provider||!d.__provider?U:{...U,__provider:d.__provider};mt(B)!==mt(d)&&m(B)}}catch(_){console.error("Error refreshing sidebar:",_)}},[c,d]),te=l.useCallback(_=>{(c==null?void 0:c.name)===_&&(u(null),m(null),r("/")),i(F=>F.filter(q=>q.name!==_))},[r,c==null?void 0:c.name]),Q=l.useMemo(()=>({projects:o,selectedProject:c,selectedSession:d,onProjectSelect:re,onSessionSelect:G,onNewSession:ie,onSessionDelete:$,onProjectDelete:te,isLoading:x,loadingProgress:N,onRefresh:Z,onShowSettings:()=>D(!0),showSettings:I,settingsInitialTab:C,onCloseSettings:()=>D(!1),isMobile:a}),[ie,te,re,$,G,Z,x,a,N,o,C,c,d,I]);return{projects:o,selectedProject:c,selectedSession:d,activeTab:h,sidebarOpen:g,isLoadingProjects:x,loadingProgress:N,isInputFocused:y,showSettings:I,settingsInitialTab:C,externalMessageUpdate:E,setActiveTab:p,setSidebarOpen:f,setIsInputFocused:k,setShowSettings:D,openSettings:z,fetchProjects:A,sidebarSharedProps:Q,handleProjectSelect:re,handleSessionSelect:G,handleNewSession:ie,handleSessionDelete:$,handleProjectDelete:te,handleSidebarRefresh:Z}}const Kn="upfyn-pwa-install-dismissed",S0=10080*60*1e3;function E0(){const[t,r]=l.useState(null),[s,a]=l.useState(!1),[n,o]=l.useState(()=>{const d=localStorage.getItem(Kn);if(!d)return!1;const m=parseInt(d,10);return Date.now()-m<S0});l.useEffect(()=>{if(window.matchMedia("(display-mode: standalone)").matches||navigator.standalone===!0){a(!0);return}const m=p=>{p.preventDefault(),r(p)};window.addEventListener("beforeinstallprompt",m);const h=()=>a(!0);return window.addEventListener("appinstalled",h),()=>{window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",h)}},[]);const i=l.useCallback(async()=>{if(!t)return;await t.prompt();const{outcome:d}=await t.userChoice;d==="accepted"&&a(!0),r(null)},[t]),c=l.useCallback(()=>{localStorage.setItem(Kn,String(Date.now())),o(!0)},[]);return{canPrompt:!!t&&!s&&!n,isInstalled:s,promptInstall:i,dismiss:c}}function T0(){const t=Yn(),{sessionId:r}=hi(),{t:s}=We("common"),{isMobile:a}=wa({trackPWA:!1}),{ws:n,sendMessage:o,latestMessage:i}=Qn(),{canPrompt:c,promptInstall:u,dismiss:d}=E0(),{activeSessions:m,processingSessions:h,markSessionAsActive:p,markSessionAsInactive:g,markSessionAsProcessing:f,markSessionAsNotProcessing:x,replaceTemporarySession:b}=j0(),{selectedProject:N,selectedSession:j,activeTab:y,sidebarOpen:k,isLoadingProjects:I,isInputFocused:D,externalMessageUpdate:C,setActiveTab:v,setSidebarOpen:E,setIsInputFocused:T,setShowSettings:W,openSettings:S,fetchProjects:O,sidebarSharedProps:H}=C0({sessionId:r,navigate:t,latestMessage:i,isMobile:a,activeSessions:m});return l.useEffect(()=>(window.refreshProjects=O,()=>{window.refreshProjects===O&&delete window.refreshProjects}),[O]),l.useEffect(()=>(window.openSettings=S,()=>{window.openSettings===S&&delete window.openSettings}),[S]),e.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[a?e.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${k?"opacity-100 visible":"opacity-0 invisible"}`,children:[e.jsx("button",{className:"fixed inset-0 bg-background/60 backdrop-blur-sm transition-opacity duration-150 ease-out",onClick:R=>{R.stopPropagation(),E(!1)},onTouchStart:R=>{R.preventDefault(),R.stopPropagation(),E(!1)},"aria-label":s("versionUpdate.ariaLabels.closeSidebar")}),e.jsx("div",{className:`relative w-[85vw] max-w-sm sm:w-80 h-full bg-card border-r border-border/40 transform transition-transform duration-150 ease-out ${k?"translate-x-0":"-translate-x-full"}`,onClick:R=>R.stopPropagation(),onTouchStart:R=>R.stopPropagation(),children:e.jsx(tn,{...H})})]}):e.jsx("div",{className:"h-full flex-shrink-0 border-r border-border/50",children:e.jsx(tn,{...H})}),e.jsxs("div",{className:`flex-1 flex flex-col min-w-0 ${a?"pb-mobile-nav":""}`,children:[a&&c&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-primary/10 border-b border-primary/20 flex-shrink-0",children:[e.jsx("span",{className:"text-xs text-foreground flex-1",children:"Install Upfyn for a better experience"}),e.jsx("button",{onClick:u,className:"text-xs px-3 py-1 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors",children:"Install"}),e.jsx("button",{onClick:d,className:"p-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":"Dismiss",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx(v0,{selectedProject:N,selectedSession:j,activeTab:y,setActiveTab:v,ws:n,sendMessage:o,latestMessage:i,isMobile:a,onMenuClick:()=>E(!0),isLoading:I,onInputFocusChange:T,onSessionActive:p,onSessionInactive:g,onSessionProcessing:f,onSessionNotProcessing:x,processingSessions:h,onReplaceTemporarySession:b,onNavigateToSession:R=>t(`/session/${R}`),onShowSettings:()=>W(!0),externalMessageUpdate:C})]}),a&&e.jsx(k0,{activeTab:y,setActiveTab:v,isInputFocused:D}),!a&&e.jsx(w0,{})]})}const _0=Object.freeze(Object.defineProperty({__proto__:null,default:T0},Symbol.toStringTag,{value:"Module"}));export{_0 as A,he as B,Ze as I,su as M,Po as S,wa as a,ke as c,E0 as u};
545
+ `):K.type==="html"?Ae=String(K.data.html||""):Ae=String(K.data.content||"");const Ge=fe[fe.length-1],ae=Ge?(((Ie=Ge.position)==null?void 0:Ie.x)||0)+300:100,be=Ge?((Fe=Ge.position)==null?void 0:Fe.y)||0:100,ze={id:`pinned_${Date.now()}`,type:Pe,position:{x:ae,y:be},data:{label:K.title,content:Ae.slice(0,2e3),...K.type==="html"&&{html:Ae,pageName:K.title}}};fe.push(ze),await Be.canvas.save(t.name,[{nodes:fe,edges:Ee}],Oe.appState||{})}catch{}},[t==null?void 0:t.name]);return l.useEffect(()=>{t&&t!==W&&(S==null||S(t))},[t,W,S]),l.useEffect(()=>{!R&&s==="tasks"&&a("chat")},[R,s,a]),d?e.jsx(_n,{mode:"loading",isMobile:c,onMenuClick:u}):t?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(Sp,{activeTab:s,setActiveTab:a,selectedProject:t,selectedSession:r,shouldShowTasksTab:R,isMobile:c,onMenuClick:u}),e.jsx(c0,{}),e.jsx(l0,{}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:`flex flex-col min-h-0 overflow-hidden ${J?"hidden":""} ${s==="files"&&A?"flex-shrink-0":"flex-1"}`,style:s==="files"&&A?{width:`${te}px`}:void 0,children:[s==="dashboard"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading dashboard..."}),children:e.jsx(f0,{selectedProject:t})})}),e.jsx("div",{className:`h-full ${s==="chat"?"block":"hidden"}`,children:e.jsx(Xr,{fallback:e.jsx(d0,{}),children:e.jsx(jr,{showDetails:!0,children:e.jsx(yp,{selectedProject:t,selectedSession:r,ws:n,sendMessage:o,latestMessage:i,onFileOpen:G,onInputFocusChange:m,onSessionActive:h,onSessionInactive:p,onSessionProcessing:g,onSessionNotProcessing:f,processingSessions:x,onReplaceTemporarySession:b,onNavigateToSession:N,onShowSettings:j,autoExpandTools:D,showRawParameters:C,showThinking:v,autoScrollToBottom:E,sendByCtrlEnter:T,externalMessageUpdate:y,onShowAllTasks:O?()=>a("tasks"):null,setActiveTab:a,onArtifactOpen:De})})})}),s==="canvas"&&e.jsxs("div",{className:"h-full overflow-hidden relative",children:[e.jsx(jr,{children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-muted-foreground/30 border-t-muted-foreground rounded-full animate-spin"}),"Loading canvas..."]})}),children:(t==null?void 0:t.name)&&e.jsx(b0,{projectName:t.name,sendMessage:o,latestMessage:i,isFullScreen:!1})})}),(t==null?void 0:t.name)&&e.jsxs("button",{onClick:()=>k(`/canvas/${encodeURIComponent(t.name)}`),className:"absolute top-3 right-32 z-20 flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-card/90 border border-border/50 text-xs text-muted-foreground hover:text-foreground hover:bg-card transition-colors backdrop-blur-sm shadow-sm",title:"Open in fullscreen",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})}),"Fullscreen"]})]}),e.jsx("div",{className:`h-full overflow-hidden ${s==="files"?"block":"hidden"}`,children:e.jsx(Xr,{fallback:e.jsx(Gn,{}),children:e.jsx(l.Suspense,{fallback:e.jsx(Gn,{}),children:e.jsx(p0,{selectedProject:t,onFileOpen:G,activeFilePath:(A==null?void 0:A.path)||null})})})}),e.jsx("div",{className:`h-full w-full overflow-hidden ${s==="shell"?"block":"hidden"}`,children:e.jsx(Xr,{fallback:e.jsx(Hn,{}),children:e.jsx(jr,{children:e.jsx(l.Suspense,{fallback:e.jsx(Hn,{}),children:e.jsx(x0,{project:t,session:r,showHeader:!1,multiTab:!0})})})})}),e.jsx("div",{className:`h-full overflow-hidden ${s==="git"?"block":"hidden"}`,children:e.jsx(Xr,{fallback:e.jsx(Vn,{}),children:e.jsx(jr,{children:e.jsx(l.Suspense,{fallback:e.jsx(Vn,{}),children:e.jsx(g0,{selectedProject:t,isMobile:c,onFileOpen:G})})})})}),s==="workflows"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(jr,{children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading workflows..."}),children:e.jsx(h0,{selectedProject:t})})})}),R&&e.jsx(i0,{isVisible:s==="tasks"}),s==="preview"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading preview..."}),children:e.jsx(y0,{initialHtml:(L=(_e=F.find(K=>K.type==="html"))==null?void 0:_e.data)==null?void 0:L.html})})})]}),s==="files"&&A&&!J&&e.jsx("div",{ref:Q,onMouseDown:_,className:"w-1 flex-shrink-0 cursor-col-resize hover:bg-primary/30 active:bg-primary/50 transition-colors relative group",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1"})}),e.jsx(Wp,{editingFile:A,isMobile:c,editorExpanded:J,editorWidth:z,resizeHandleRef:re,onResizeStart:Z,onCloseEditor:ie,onToggleEditorExpand:$,projectPath:t.path,fillSpace:s==="files"}),w&&!A&&(c?e.jsx("div",{className:"fixed inset-0 z-40 bg-gray-900 flex flex-col",children:e.jsx(Wn,{artifacts:F,recentArtifacts:q,activeArtifactId:U,panelWidth:ee,panelExpanded:V,resizeHandleRef:M,onResizeStart:Ne,onSetActive:B,onClose:se,onReopenArtifact:de,onClearHistory:je,onCloseAll:ge,onToggleExpand:Re,onPinToCanvas:Ue,onFileOpen:G})}):e.jsx(Wn,{artifacts:F,recentArtifacts:q,activeArtifactId:U,panelWidth:ee,panelExpanded:V,resizeHandleRef:M,onResizeStart:Ne,onSetActive:B,onClose:se,onReopenArtifact:de,onClearHistory:je,onCloseAll:ge,onToggleExpand:Re,onPinToCanvas:Ue,onFileOpen:G}))]})]}):e.jsx(_n,{mode:"empty",isMobile:c,onMenuClick:u})}const k0=it.memo(v0);function w0({activeTab:t,setActiveTab:r,isInputFocused:s}){const{tasksEnabled:a,isTaskMasterInstalled:n}=Lr(),i=[{id:"dashboard",icon:Wi,label:"Home"},{id:"chat",icon:ka,label:"Chat"},{id:"shell",icon:vt,label:"Shell"},{id:"files",icon:mr,label:"Files"},{id:"canvas",icon:Ui,label:"Canvas"},{id:"preview",icon:sr,label:"Preview"},{id:"git",icon:br,label:"Git"},{id:"workflows",icon:tr,label:"Auto"},...!!(a&&n)?[{id:"tasks",icon:oo,label:"Tasks"}]:[]];return e.jsx("div",{className:`fixed bottom-0 left-0 right-0 z-50 px-2 pb-[max(6px,env(safe-area-inset-bottom))] transform transition-transform duration-300 ease-in-out ${s?"translate-y-full":"translate-y-0"}`,children:e.jsx("div",{className:"nav-glass mobile-nav-float rounded-2xl border border-border/30",children:e.jsx("div",{className:"flex items-center justify-around px-0.5 py-1 gap-0 overflow-x-auto scrollbar-hide",children:i.map(c=>{const u=c.icon,d=t===c.id;return e.jsxs("button",{onClick:()=>r(c.id),onTouchStart:m=>{m.preventDefault(),r(c.id)},className:`flex flex-col items-center justify-center gap-0.5 px-1.5 py-1.5 rounded-xl flex-shrink-0 min-w-[42px] relative touch-manipulation transition-all duration-200 active:scale-95 ${d?"text-primary":"text-muted-foreground hover:text-foreground"}`,"aria-label":c.label,"aria-current":d?"page":void 0,children:[d&&e.jsx("div",{className:"absolute inset-0 bg-primary/8 dark:bg-primary/12 rounded-xl"}),e.jsx(u,{className:`relative z-10 transition-all duration-200 ${d?"w-[18px] h-[18px]":"w-4 h-4"}`,strokeWidth:d?2.4:1.8}),e.jsx("span",{className:`relative z-10 text-[9px] leading-tight font-medium truncate w-full text-center transition-all duration-200 ${d?"opacity-100":"opacity-60"}`,children:c.label})]},c.id)})})})})}const qn="upfyn-tour-complete",Nr=[{target:"chat",title:"Chat",description:"Talk to AI agents — Claude, Cursor, or Codex. Stream responses, run tools, and see every action live."},{target:"canvas",title:"Canvas",description:"A visual whiteboard for code blocks, diagrams, notes, and web previews. Drag, connect, and organize."},{target:"files",title:"Files",description:"Browse your project tree, open files in the built-in editor, and make quick edits."},{target:"shell",title:"Shell",description:"A full terminal — run commands, install packages, or manage processes. Supports multiple tabs."},{target:"git",title:"Git",description:"Stage, commit, push, and view diffs — all from the browser. No terminal needed."}];function j0(){const[t,r]=l.useState(!1),[s,a]=l.useState(0),[n,o]=l.useState(null);l.useEffect(()=>{if(localStorage.getItem(qn))return;const x=setTimeout(()=>r(!0),800);return()=>clearTimeout(x)},[]);const i=l.useCallback(()=>{if(!t)return;const x=document.querySelector(`[data-tour="${Nr[s].target}"]`);o(x?x.getBoundingClientRect():null)},[t,s]);l.useEffect(()=>(i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)),[i]);const c=l.useCallback(()=>{r(!1),localStorage.setItem(qn,"1")},[]),u=l.useCallback(()=>{s<Nr.length-1?a(s+1):c()},[s,c]),d=l.useCallback(()=>{s>0&&a(s-1)},[s]);if(l.useEffect(()=>{if(!t)return;const x=b=>{b.key==="Escape"?c():b.key==="ArrowRight"||b.key==="Enter"?u():b.key==="ArrowLeft"&&d()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t,u,d,c]),!t||!n)return null;const m=6,h={top:n.top-m,left:n.left-m,width:n.width+m*2,height:n.height+m*2},p=h.top+h.height+12,g=Math.max(12,Math.min(h.left+h.width/2-160,window.innerWidth-332)),f=Nr[s];return e.jsxs("div",{className:"fixed inset-0 z-[9999]",role:"dialog","aria-label":"Feature tour",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:c}),e.jsx("div",{className:"absolute rounded-lg ring-2 ring-primary/60 bg-transparent pointer-events-none",style:{...h,boxShadow:"0 0 0 9999px rgba(0,0,0,0.5)"}}),e.jsxs("div",{className:"absolute w-[320px] bg-card border border-border/60 rounded-xl shadow-2xl overflow-hidden",style:{top:p,left:g},children:[e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-sm font-bold text-foreground",children:f.title}),e.jsx("button",{onClick:c,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors","aria-label":"Skip tour",children:e.jsx(Ve,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:f.description})]}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-border/40 bg-muted/20",children:[e.jsxs("span",{className:"text-xs text-muted-foreground/60",children:[s+1," / ",Nr.length]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&e.jsxs("button",{onClick:d,className:"flex items-center gap-1 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors rounded-lg",children:[e.jsx(ha,{className:"w-3.5 h-3.5"}),"Back"]}),e.jsx("button",{onClick:u,className:"flex items-center gap-1 px-4 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:s<Nr.length-1?e.jsxs(e.Fragment,{children:["Next",e.jsx(rr,{className:"w-3.5 h-3.5"})]}):"Done"})]})]})]})]})}function N0(){const[t,r]=l.useState(new Set),[s,a]=l.useState(new Set),n=l.useCallback(d=>{d&&r(m=>new Set([...m,d]))},[]),o=l.useCallback(d=>{d&&r(m=>{const h=new Set(m);return h.delete(d),h})},[]),i=l.useCallback(d=>{d&&a(m=>new Set([...m,d]))},[]),c=l.useCallback(d=>{d&&a(m=>{const h=new Set(m);return h.delete(d),h})},[]),u=l.useCallback(d=>{d&&r(m=>{const h=new Set;for(const p of m)p.startsWith("new-session-")||h.add(p);return h.add(d),h})},[]);return{activeSessions:t,processingSessions:s,markSessionAsActive:n,markSessionAsInactive:o,markSessionAsProcessing:i,markSessionAsNotProcessing:c,replaceTemporarySession:u}}const mt=t=>JSON.stringify(t??null),Kn=(t,r,s)=>t.length!==r.length?!0:r.some((a,n)=>{const o=t[n];return!o||a.name!==o.name||a.displayName!==o.displayName||a.fullPath!==o.fullPath||mt(a.sessionMeta)!==mt(o.sessionMeta)||mt(a.sessions)!==mt(o.sessions)?!0:mt(a.cursorSessions)!==mt(o.cursorSessions)||mt(a.codexSessions)!==mt(o.codexSessions)}),ms=t=>[...t.sessions??[],...t.codexSessions??[],...t.cursorSessions??[]],C0=(t,r,s,a)=>{if(!s||!a)return!0;const n=t.find(u=>u.name===s.name),o=r.find(u=>u.name===s.name);if(!n||!o)return!1;const i=ms(n).find(u=>u.id===a.id),c=ms(o).find(u=>u.id===a.id);return!i||!c?!1:i.id===c.id&&i.title===c.title&&i.created_at===c.created_at&&i.updated_at===c.updated_at};function S0({sessionId:t,navigate:r,latestMessage:s,isMobile:a,activeSessions:n}){const[o,i]=l.useState([]),[c,u]=l.useState(null),[d,m]=l.useState(null),[h,p]=l.useState("chat"),[g,f]=l.useState(!1),[x,b]=l.useState(!0),[N,j]=l.useState(null),[y,k]=l.useState(!1),[I,D]=l.useState(!1),[C,v]=l.useState("agents"),[E,T]=l.useState(0),{relayCwd:W,isRelayConnected:S}=ps(),O=l.useRef(null),H=l.useRef(new Set),R=l.useRef(null),A=l.useCallback(async()=>{try{b(!0);const _=await Be.projects();if(!_.ok)return;const F=await _.json();if(!Array.isArray(F))return;i(q=>q.length===0||Kn(q,F,!0)?F:q)}catch(_){console.error("Error fetching projects:",_)}finally{b(!1)}},[]),z=l.useCallback((_="tools")=>{v(_),D(!0)},[]);l.useEffect(()=>{A()},[A]);const J=l.useRef(0);l.useEffect(()=>{if(x||o.length>0||!S||!W){J.current=0;return}if(J.current>=3)return;const _=setTimeout(()=>{J.current++,A()},1500);return()=>clearTimeout(_)},[x,o.length,S,W,A]),l.useEffect(()=>{if(!(x||c||t||o.length===0)){if(S&&W){const _=B=>B.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase(),F=_(W),q=F.split("/").pop()||"",U=o.find(B=>_(B.fullPath||"")===F||_(B.name||"")===q);if(U){u(U);return}}o.length===1&&u(o[0])}},[x,o,c,t,S,W]),l.useEffect(()=>{if(!R.current||o.length===0)return;const _=R.current,F=ee=>ee.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase(),q=F(_),U=q.split("/").pop()||"",B=o.find(ee=>F(ee.fullPath||"")===q||F(ee.name||"")===U);B&&(R.current=null,u(B),m(null),p("chat"),r("/"))},[o,r]),l.useEffect(()=>{if(!s)return;if((s.type==="relay-init"||s.type==="relay-status")&&s.cwd&&s.connected!==!1){R.current=s.cwd,A();return}if(s.type==="shell-project-selected"&&s.projectPath){R.current=s.projectPath,A();return}if(s.type==="loading_progress"){O.current&&(clearTimeout(O.current),O.current=null),j(s),s.phase==="complete"&&(O.current=setTimeout(()=>{j(null),O.current=null},500));return}if(s.type!=="projects_updated")return;const _=s;if(_.changedFile&&d&&c){const V=_.changedFile.replace(/\\/g,"/").split("/");V.length>=2&&V[V.length-1].replace(".jsonl","")===d.id&&(n.has(d.id)||T(se=>se+1))}const F=d&&n.has(d.id)||n.size>0&&Array.from(n).some(ee=>ee.startsWith("new-session-")),q=_.projects;if(!Array.isArray(q)||F&&!C0(o,q,c,d)||(i(q),!c))return;const U=q.find(ee=>ee.name===c.name);if(!U||(mt(U)!==mt(c)&&u(U),!d))return;ms(U).find(ee=>ee.id===d.id)||m(null)},[s,c,d,n,o]),l.useEffect(()=>()=>{O.current&&(clearTimeout(O.current),O.current=null)},[]),l.useEffect(()=>{var F,q,U;if(!t||o.length===0)return;const _=!d||d.id!==t;for(const B of o){const ee=(F=B.sessions)==null?void 0:F.find(M=>M.id===t);if(ee){const M=(c==null?void 0:c.name)!==B.name,Y=(d==null?void 0:d.id)!==t||d.__provider!=="claude";M&&u(B),Y&&m({...ee,__provider:"claude"}),_&&p("chat");return}const V=(q=B.cursorSessions)==null?void 0:q.find(M=>M.id===t);if(V){const M=(c==null?void 0:c.name)!==B.name,Y=(d==null?void 0:d.id)!==t||d.__provider!=="cursor";M&&u(B),Y&&m({...V,__provider:"cursor"}),_&&p("chat");return}const w=(U=B.codexSessions)==null?void 0:U.find(M=>M.id===t);if(w){const M=(c==null?void 0:c.name)!==B.name,Y=(d==null?void 0:d.id)!==t||d.__provider!=="codex";M&&u(B),Y&&m({...w,__provider:"codex"}),_&&p("chat");return}}},[t,o,c==null?void 0:c.name,d==null?void 0:d.id,d==null?void 0:d.__provider]);const re=l.useCallback(_=>{u(_),m(null),r("/"),a&&f(!1)},[a,r]),G=l.useCallback(_=>{if(m(_),h!=="git"&&h!=="preview"&&p("chat"),(localStorage.getItem("selected-provider")||"claude")==="cursor"&&sessionStorage.setItem("cursorSessionId",_.id),a){const q=_.__projectName,U=c==null?void 0:c.name;q!==U&&f(!1)}r(`/session/${_.id}`)},[h,a,r,c==null?void 0:c.name]),ie=l.useCallback(_=>{u(_),m(null),p("chat"),r("/"),a&&f(!1)},[a,r]),$=l.useCallback(_=>{H.current.add(_),setTimeout(()=>H.current.delete(_),3e4),(d==null?void 0:d.id)===_&&(m(null),r("/")),i(F=>F.map(q=>{var U,B;return{...q,sessions:((U=q.sessions)==null?void 0:U.filter(ee=>ee.id!==_))??[],sessionMeta:{...q.sessionMeta,total:Math.max(0,(((B=q.sessionMeta)==null?void 0:B.total)??0)-1)}}}))},[r,d==null?void 0:d.id]),Z=l.useCallback(async()=>{try{const _=await Be.projects();if(!_.ok)return;let F=await _.json();if(!Array.isArray(F)||(H.current.size>0&&(F=F.map(B=>{var ee;return{...B,sessions:((ee=B.sessions)==null?void 0:ee.filter(V=>!H.current.has(V.id)))??[]}})),i(B=>Kn(B,F,!0)?F:B),!c))return;const q=F.find(B=>B.name===c.name);if(!q||(mt(q)!==mt(c)&&u(q),!d))return;const U=ms(q).find(B=>B.id===d.id);if(U){const B=U.__provider||!d.__provider?U:{...U,__provider:d.__provider};mt(B)!==mt(d)&&m(B)}}catch(_){console.error("Error refreshing sidebar:",_)}},[c,d]),te=l.useCallback(_=>{(c==null?void 0:c.name)===_&&(u(null),m(null),r("/")),i(F=>F.filter(q=>q.name!==_))},[r,c==null?void 0:c.name]),Q=l.useMemo(()=>({projects:o,selectedProject:c,selectedSession:d,onProjectSelect:re,onSessionSelect:G,onNewSession:ie,onSessionDelete:$,onProjectDelete:te,isLoading:x,loadingProgress:N,onRefresh:Z,onShowSettings:()=>D(!0),showSettings:I,settingsInitialTab:C,onCloseSettings:()=>D(!1),isMobile:a}),[ie,te,re,$,G,Z,x,a,N,o,C,c,d,I]);return{projects:o,selectedProject:c,selectedSession:d,activeTab:h,sidebarOpen:g,isLoadingProjects:x,loadingProgress:N,isInputFocused:y,showSettings:I,settingsInitialTab:C,externalMessageUpdate:E,setActiveTab:p,setSidebarOpen:f,setIsInputFocused:k,setShowSettings:D,openSettings:z,fetchProjects:A,sidebarSharedProps:Q,handleProjectSelect:re,handleSessionSelect:G,handleNewSession:ie,handleSessionDelete:$,handleProjectDelete:te,handleSidebarRefresh:Z}}const Jn="upfyn-pwa-install-dismissed",E0=10080*60*1e3;function T0(){const[t,r]=l.useState(null),[s,a]=l.useState(!1),[n,o]=l.useState(()=>{const d=localStorage.getItem(Jn);if(!d)return!1;const m=parseInt(d,10);return Date.now()-m<E0});l.useEffect(()=>{if(window.matchMedia("(display-mode: standalone)").matches||navigator.standalone===!0){a(!0);return}const m=p=>{p.preventDefault(),r(p)};window.addEventListener("beforeinstallprompt",m);const h=()=>a(!0);return window.addEventListener("appinstalled",h),()=>{window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",h)}},[]);const i=l.useCallback(async()=>{if(!t)return;await t.prompt();const{outcome:d}=await t.userChoice;d==="accepted"&&a(!0),r(null)},[t]),c=l.useCallback(()=>{localStorage.setItem(Jn,String(Date.now())),o(!0)},[]);return{canPrompt:!!t&&!s&&!n,isInstalled:s,promptInstall:i,dismiss:c}}function A0(){const t=Qn(),{sessionId:r}=fi(),{t:s}=We("common"),{isMobile:a}=ja({trackPWA:!1}),{ws:n,sendMessage:o,latestMessage:i}=Xn(),{canPrompt:c,promptInstall:u,dismiss:d}=T0(),{activeSessions:m,processingSessions:h,markSessionAsActive:p,markSessionAsInactive:g,markSessionAsProcessing:f,markSessionAsNotProcessing:x,replaceTemporarySession:b}=N0(),{selectedProject:N,selectedSession:j,activeTab:y,sidebarOpen:k,isLoadingProjects:I,isInputFocused:D,externalMessageUpdate:C,setActiveTab:v,setSidebarOpen:E,setIsInputFocused:T,setShowSettings:W,openSettings:S,fetchProjects:O,sidebarSharedProps:H}=S0({sessionId:r,navigate:t,latestMessage:i,isMobile:a,activeSessions:m});return l.useEffect(()=>(window.refreshProjects=O,()=>{window.refreshProjects===O&&delete window.refreshProjects}),[O]),l.useEffect(()=>(window.openSettings=S,()=>{window.openSettings===S&&delete window.openSettings}),[S]),e.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[a?e.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${k?"opacity-100 visible":"opacity-0 invisible"}`,children:[e.jsx("button",{className:"fixed inset-0 bg-background/60 backdrop-blur-sm transition-opacity duration-150 ease-out",onClick:R=>{R.stopPropagation(),E(!1)},onTouchStart:R=>{R.preventDefault(),R.stopPropagation(),E(!1)},"aria-label":s("versionUpdate.ariaLabels.closeSidebar")}),e.jsx("div",{className:`relative w-[85vw] max-w-sm sm:w-80 h-full bg-card border-r border-border/40 transform transition-transform duration-150 ease-out ${k?"translate-x-0":"-translate-x-full"}`,onClick:R=>R.stopPropagation(),onTouchStart:R=>R.stopPropagation(),children:e.jsx(rn,{...H})})]}):e.jsx("div",{className:"h-full flex-shrink-0 border-r border-border/50",children:e.jsx(rn,{...H})}),e.jsxs("div",{className:`flex-1 flex flex-col min-w-0 ${a?"pb-mobile-nav":""}`,children:[a&&c&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-primary/10 border-b border-primary/20 flex-shrink-0",children:[e.jsx("span",{className:"text-xs text-foreground flex-1",children:"Install Upfyn for a better experience"}),e.jsx("button",{onClick:u,className:"text-xs px-3 py-1 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors",children:"Install"}),e.jsx("button",{onClick:d,className:"p-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":"Dismiss",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx(k0,{selectedProject:N,selectedSession:j,activeTab:y,setActiveTab:v,ws:n,sendMessage:o,latestMessage:i,isMobile:a,onMenuClick:()=>E(!0),isLoading:I,onInputFocusChange:T,onSessionActive:p,onSessionInactive:g,onSessionProcessing:f,onSessionNotProcessing:x,processingSessions:h,onReplaceTemporarySession:b,onNavigateToSession:R=>t(`/session/${R}`),onShowSettings:()=>W(!0),externalMessageUpdate:C})]}),a&&e.jsx(w0,{activeTab:y,setActiveTab:v,isInputFocused:D}),!a&&e.jsx(j0,{})]})}const F0=Object.freeze(Object.defineProperty({__proto__:null,default:A0},Symbol.toStringTag,{value:"Module"}));export{F0 as A,he as B,Ze as I,au as M,$o as S,ja as a,ke as c,T0 as u};