PageSourceSearch

https://happycapy.ai/_next/static/chunks/7563-02a078de86cafd2a.js

js happycapy.ai collected 2026-10-04 20:19:38 UTC 65,918 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7563],{39732:(e,t,n)=>{n.d(t,{q:()=>x});var l=n(95155),s=n(12115),a=n(30285),r=n(62523),i=n(53904),o=n(33786),c=n(51154),d=n(59434),u=n(55630),h=n(94222),m=n(43405),f=n(9486),p=n(93307);function x(e){let{url:t}=e,[n,x]=(0,s.useState)(t),[g,v]=(0,s.useState)(t),[b,w]=(0,s.useState)(!0),y=(0,s.useRef)(null),{modifiedFiles:j,clearFileRefresh:N}=(0,m.C)(),k=(0,f.useAppSelector)(p.selectUserSandboxId),C=()=>{if(!g.trim())return;let e=g;e.startsWith("http://")||e.startsWith("https://")||(e="https://".concat(e)),(0,h.AY)(e)&&(x(e),w(!0))},S=()=>{y.current&&n&&(w(!0),y.current.src=y.current.src)};return(0,s.useEffect)(()=>{if(!n||0===Object.keys(j).length)return;let e=Object.keys(j).filter(e=>!e.includes(":skipReload")&&function(e,t,n){if(!e||!t)return!1;let l=e.replace(/\/+$/,"").toLowerCase(),s=t.replace(/^\/+/,"").replace(/\/+$/,"").toLowerCase();if(!(l.includes("localhost")||l.includes("127.0.0.1")||l.startsWith("file://")||n&&l.includes(n)))return!1;if(l.includes(s))return!0;if(t.endsWith(".html")){let e=s.replace(/\.html$/,"");if(l.includes(e))return!0}let a=s.includes("/")?s.substring(0,s.lastIndexOf("/")):"",r=l.replace(/^https?:\/\/[^\/]+/,"").replace(/\?.*$/,"").replace(/#.*$/,"");return!!(t.endsWith(".css")||t.endsWith(".js")||t.endsWith("index.html")&&a)&&r.includes(a)}(n,e,null!=k?k:null));e.length>0&&(e.some(e=>!!j["".concat(e,":skipReload")])?console.log("[UrlPreviewFloat] Files were saved recently, skipping unnecessary preview refresh"):(console.log("[UrlPreviewFloat] Detected relevant external file modification, refreshing preview"),S()),e.forEach(e=>{N(e),N("".concat(e,":skipReload"))}))},[j,n,k,N]),(0,l.jsxs)("div",{className:"h-full flex flex-col bg-background",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 p-2 border-b border-border bg-muted/30",children:[(0,l.jsxs)("div",{className:"flex-1 relative",children:[(0,l.jsx)(r.p,{type:"text",placeholder:"Enter URL...",value:g,onChange:e=>v(e.target.value),onKeyPress:e=>{"Enter"===e.key&&C()},className:"pr-12 text-xs font-mono h-7"}),(0,l.jsx)(a.$,{onClick:C,size:"sm",className:"absolute right-1 top-1/2 -translate-y-1/2 h-5 px-2 text-[10px]",children:"Go"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,l.jsx)(u.C,{label:"Refresh",wrapTrigger:!0,children:(0,l.jsx)(a.$,{variant:"ghost",size:"sm",onClick:S,disabled:!n,className:"h-7 w-7 p-0",children:(0,l.jsx)(i.A,{className:"h-3.5 w-3.5"})})}),(0,l.jsx)(u.C,{label:"Open in new tab",wrapTrigger:!0,children:(0,l.jsx)(a.$,{variant:"ghost",size:"sm",onClick:()=>{n&&window.open(n,"_blank","noopener,noreferrer")},disabled:!n,className:"h-7 w-7 p-0",children:(0,l.jsx)(o.A,{className:"h-3.5 w-3.5"})})})]})]}),(0,l.jsxs)("div",{className:"flex-1 relative bg-white",children:[b&&(0,l.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 backdrop-blur-xs z-10",children:(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(c.A,{className:"h-4 w-4 animate-spin"}),(0,l.jsx)("span",{className:"text-xs text-muted-foreground",children:"Loading..."})]})}),n?(0,l.jsx)("iframe",{ref:y,src:n,className:(0,d.cn)("w-full h-full border-0",b&&"blur-xs"),onLoad:()=>{w(!1)},onError:()=>{w(!1)},sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads",allow:"autoplay; fullscreen; encrypted-media; picture-in-picture",title:"URL Preview"}):(0,l.jsx)("div",{className:"h-full flex items-center justify-center text-center",children:(0,l.jsxs)("div",{className:"max-w-sm",children:[(0,l.jsx)("div",{className:"text-muted-foreground mb-2",children:(0,l.jsx)(o.A,{className:"h-8 w-8 mx-auto mb-2 opacity-50"})}),(0,l.jsx)("h3",{className:"text-sm font-medium mb-1",children:"No URL"}),(0,l.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enter a URL in the address bar above"})]})})]})]})}},44605:(e,t,n)=>{n.d(t,{j:()=>s});var l=n(58361);let s={async createFileShare(e){let t=await (0,l.bE)("/file-shares",e);return{fileShare:t.fileShare,url:t.url}},async listFileShares(e){let t=new URLSearchParams;
1(null==e?void 0:e.sessionId)!==void 0&&t.set("sessionId",e.sessionId),(null==e?void 0:e.teamId)!==void 0&&t.set("teamId",e.teamId),(null==e?void 0:e.limit)!==void 0&&t.set("limit",String(e.limit)),(null==e?void 0:e.offset)!==void 0&&t.set("offset",String(e.offset));let n="/file-shares".concat(t.toString()?"?".concat(t):"");return(await (0,l.get)(n)).fileShares},getFileShare:async e=>(await (0,l.get)("/file-shares/".concat(e))).fileShare,async deleteFileShare(e){await (0,l.yH)("/file-shares/".concat(e))},async remixFileShare(e,t){let n=await (0,l.bE)("/file-shares/".concat(e,"/remix"),t||{});return{session:n.session,filePath:n.filePath}}}},45768:(e,t,n)=>{n.d(t,{U:()=>c});var l=n(95155),s=n(12115),a=n(51154),r=n(42355),i=n(13052),o=n(59434);function c(e){let{vncUrl:t,steps:n,mode:c,onModeChange:d,requestedStepIndex:u}=e,[h,m]=(0,s.useState)(n.length-1),[f,p]=(0,s.useState)(!0),x=(0,s.useRef)(null),g=(0,s.useRef)(!1);(0,s.useEffect)(()=>{void 0!==u&&u>=0&&u<n.length&&(m(u),g.current=!0)},[u,n.length]),(0,s.useEffect)(()=>{n.length>0&&!g.current&&m(n.length-1)},[n.length]);let v=(0,s.useCallback)(()=>{g.current=!0,m(e=>Math.max(0,e-1))},[]),b=(0,s.useCallback)(()=>{m(e=>{let t=Math.min(n.length-1,e+1);return t===n.length-1&&(g.current=!1),t})},[n.length]),w=(0,s.useCallback)(()=>p(!1),[]),y=(0,s.useCallback)(()=>p(!1),[]),j=n[h],N=h<n.length-1,k="screenshot"===c&&n.length>0&&j;return(0,l.jsxs)("div",{className:"h-full flex flex-col bg-background relative",children:[!1,(0,l.jsx)("div",{className:"flex-1 relative bg-muted overflow-hidden min-h-0 flex items-center justify-center",children:"screenshot"===c?n.length>0&&j?(0,l.jsxs)("div",{className:"w-full h-full flex flex-col",children:[(0,l.jsx)("div",{className:"flex-1 min-h-0 w-full flex items-center justify-center bg-muted/10",children:j.screenshotUrl?(0,l.jsx)("img",{src:j.screenshotUrl,alt:"Browser step ".concat(h+1),className:"w-full h-full object-contain"}):(0,l.jsx)("div",{className:"flex items-center justify-center",children:(0,l.jsx)("span",{className:"text-xs text-muted-foreground",children:"No screenshot available"})})}),(0,l.jsx)("div",{className:"shrink-0 w-full h-12 px-4 flex items-center",children:j.message&&(0,l.jsx)("p",{className:"text-xs text-foreground/80 leading-tight line-clamp-2",children:j.message})})]}):(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(a.A,{className:"h-4 w-4 animate-spin"}),(0,l.jsx)("span",{className:"text-xs text-muted-foreground",children:"Waiting for browser activity..."})]}):(0,l.jsxs)("div",{className:"w-full h-full relative flex items-center justify-center",children:[f&&(0,l.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 backdrop-blur-xs z-10",children:(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(a.A,{className:"h-4 w-4 animate-spin"}),(0,l.jsx)("span",{className:"text-xs text-muted-foreground",children:"Connecting to live session..."})]})}),(0,l.jsx)("iframe",{ref:x,src:t,className:(0,o.cn)("w-full h-full border-0",f&&"opacity-0"),onLoad:w,onError:y,allow:"clipboard-read; clipboard-write",title:"VNC Preview"})]})}),k&&n.length>1&&(0,l.jsxs)("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 flex items-center gap-1 px-2 py-1 rounded-full bg-background/95 backdrop-blur-md border border-border/50 shadow-md z-20",children:[(0,l.jsx)("button",{onClick:v,disabled:!(h>0),className:"p-0.5 rounded-sm transition-colors disabled:opacity-30 text-muted-foreground hover:text-foreground",children:(0,l.jsx)(r.A,{className:"w-3.5 h-3.5"})}),(0,l.jsxs)("span",{className:"text-[10px] text-muted-foreground tabular-nums min-w-8 text-center",children:[h+1," / ",n.length]}),(0,l.jsx)("button",{onClick:b,disabled:!N,className:"p-0.5 rounded-sm transition-colors disabled:opacity-30 text-muted-foreground hover:text-foreground",children:(0,l.jsx)(i.A,{className:"w-3.5 h-3.5"})})]})]})}n(55630)},70476:(e,t,n)=>{n.d(t,{B:()=>P});var l=n(95155),s=n(12115),a=n(66474),r=n(89917),i=n(8804),o=n(38564),c=n(18860),d=n(71366),u=n(5196),h=n(84616),m=n(54416),f=n(14636),p=n(13485),x=n(14769),g=n(62102),v=n(16684),b=n(54437),w=n(46244),y=n(44409),j=n(9486),N=n(93307),k=n(38651),C=n(55837),S=n(25731),F=n(56671),R=n(27336),A=n(61464);function P(e){var t;let{sessionId:n,rootSessionId:m,isChildSession:P,rootTitle:I,historyEvents:E,wsEvents:M,isLoadingHistory:D,agentStatus:T,questions:z,currentToolCallId:L,onChatSubmit:_,onInterrupt:O,onQuestionAnswer:U,onSessionCreated:W,onWindowRefresh:G,onAgentFileProduced:B,isSharePage:$,shareMode:q,isFreePlan:H,onUpgradeClick:X,installedSkills:Q,isNewUser:V,isSubscriptionSuccess:K,showLoadingCarousel:Y,showMacintoshEasterEgg:J,showCEOLetter:Z,historyPagination:ee,onLoadMoreHistory:et,isLoadingMoreHistory:en,hasTeam:el,teamData:es,onNavigateToMain:ea,onNavigateToChild:er,onRename:ei,onFavoriteToggle:eo,onFork:ec,onForkFromMessage:ed,isFavorited:eu=!1,headerRight:eh,headerControlsDisabled:em=!1,bodyRightSlot:ef,onSidePanelOpenChange:ep,sidePanelDisplacesChat:ex=!1,inputBottomPaddingClass:eg,chatContentClassName:ev,inputHorizontalPaddingClass:eb,inputMa
1xWidthClass:ew,shareCtaHref:ey,onShareCtaClick:ej,isSnapshotPage:eN=!1}=e,ek=(0,j.useAppDispatch)(),eC=(0,j.useAppSelector)(N.selectActiveContext),eS=(0,j.useAppSelector)(N.selectPendingSession),{sendMessage:eF}=(0,R.h)(),[eR,eA]=(0,s.useState)([]),eP=!!eS&&"created"!==eS.status&&(eS.sessionId===m||eS.sessionId===n);(0,s.useEffect)(()=>{if(eP)return void eA([]);let e=!1;return(async()=>{try{let t=$?await C.M.getPublicChildSessions(m):await C.M.getChildSessions(m);e||eA(t)}catch(t){e||eA([])}})(),()=>{e=!0}},[m,$,eP]),(0,s.useEffect)(()=>{if($||eP)return;let e=e=>{let t=e.detail;(null==t?void 0:t.parentSessionId)===m&&eA(t.sessions)};return window.addEventListener(C.O,e),()=>window.removeEventListener(C.O,e)},[eP,$,m]),(0,s.useEffect)(()=>{let e=e=>{let{sessionId:t,title:n}=e.detail;eA(e=>{let l=e.findIndex(e=>e.id===t);if(-1===l)return e;let s=[...e];return s[l]={...s[l],title:n},s})};return window.addEventListener("happycapy:session-title-updated",e),()=>window.removeEventListener("happycapy:session-title-updated",e)},[]);let eI=P?n:m,[eE,eM]=(0,s.useState)(!1),[eD,eT]=(0,s.useState)(!1),[ez,eL]=(0,s.useState)(!1),[e_,eO]=(0,s.useState)(!1),eU=(0,s.useCallback)(()=>{eL(!1),eT(!1),eM(!0)},[]),eW=(0,s.useCallback)(()=>{eM(!1)},[]),eG=(0,s.useCallback)(()=>{eM(!1),eL(!0)},[]),eB=(0,s.useCallback)(()=>{eO(!1),eM(!1),eT(!0)},[]),e$=(0,s.useCallback)(()=>{eT(!1)},[]),eq=(0,s.useCallback)(()=>{eT(!1),eO(!0)},[]),eH=(0,s.useMemo)(()=>{var e;return null!=(e=null==es?void 0:es.config.members.map(e=>e.name))?e:[]},[es]),eX="submitted"===T.state||"inited"===T.state||"using_tool"===T.state||"replying"===T.state,{hasAny:eQ,groups:eV,agentCount:eK,runningCount:eY}=(0,w.D)(n,M,eH,$,eX),eJ=eQ&&!e_,eZ=el&&!ez,e0=(0,s.useRef)(el);(0,s.useEffect)(()=>{el&&!e0.current&&(eT(!1),eL(!1),eM(!0)),e0.current=el},[el]),(0,s.useEffect)(()=>{eM(!1),eT(!1),eL(!1),eO(!1)},[n]);let e1=eE&&eZ&&!!es||eD&&eJ;(0,s.useEffect)(()=>{null==ep||ep(e1)},[e1,ep]);let e5=e1&&ex,e3=e5?"flex-1 min-w-0 h-full overflow-hidden":"shrink-0 w-[40%] min-w-[min(380px,55%)] max-w-[600px] h-full border-l border-border overflow-hidden",e2=(0,s.useRef)(eQ);(0,s.useEffect)(()=>{eQ&&!e2.current&&eO(!1),e2.current=eQ},[eQ]);let e4=(0,s.useMemo)(()=>{if(P)return eR.find(e=>e.id===n)},[P,n,eR]),e6=(0,s.useCallback)(e=>{P&&eA(t=>t.map(t=>t.id===n?{...t,model:e}:t))},[P,n]),e8=(0,s.useCallback)(e=>{P&&eA(t=>t.map(t=>t.id===n?{...t,connectorIds:e}:t))},[P,n]),e7=(0,s.useCallback)(e=>{P&&eA(t=>t.map(t=>t.id===n?{...t,bridgeIds:e}:t))},[P,n]),[e9,te]=(0,s.useState)(!1),tt=(0,s.useCallback)(async e=>{try{let t,n=await C.M.createChildSession(m,e.title,e.model,eC||void 0,e.effort,e.adaptiveThinking,e.account,e.connectorIds,e.bridgeIds);if(e.files.length>0&&(t=(await S.FH.uploadFiles(m,e.files)).files.map(e=>({path:e.path||"uploads/".concat(e.filename),name:e.filename}))),eA(e=>e.some(e=>e.id===n.id)?e:[...e,n]),er(n.id),e.message||e.imageUrls.length>0||t){let l=e.skill?[{id:e.skill.id,name:e.skill.name}]:void 0;eF(n.id,e.message,e.imageUrls.length>0?e.imageUrls:void 0,void 0,l,t,e.model)}return!0}catch(e){return e instanceof Error&&"SESSION_LIMIT_REACHED"===e.message?ek((0,k.openSessionLimitDialog)()):(console.error("[ChatPane] Failed to create child session:",e),F.oR.error("Failed to create new session")),!1}},[eC,ek,er,m,eF]),[tn,tl]=(0,s.useState)({type:null,sessionId:"",sessionTitle:""}
1),[ts,ta]=(0,s.useState)(!1),tr=(0,s.useCallback)(async e=>{if(tn.sessionId){ta(!0);try{await C.M.updateSessionTitle(tn.sessionId,e),eA(t=>t.map(t=>t.id===tn.sessionId?{...t,title:e}:t)),tl({type:null,sessionId:"",sessionTitle:""})}catch(e){console.error("[ChatPane] Failed to rename child session:",e),F.oR.error("Failed to rename session")}finally{ta(!1)}}},[tn.sessionId]),ti=(0,s.useCallback)(async()=>{if(!tn.sessionId)return;let e=tn.sessionId;ta(!0);try{await C.M.deleteSession(e),eA(t=>{let l=t.filter(t=>t.id!==e);return n===e&&(l.length>0?er(l[0].id):ea()),l}),tl({type:null,sessionId:"",sessionTitle:""})}catch(e){console.error("[ChatPane] Failed to delete child session:",e),F.oR.error("Failed to delete session")}finally{ta(!1)}},[tn.sessionId,n,er,ea]),to=I||"Main",[tc,td]=(0,s.useState)(!1),tu=$&&0===eR.length||em,th=P?(null==(t=eR.find(e=>e.id===n))?void 0:t.title)||"Untitled":null,tm=th?"".concat(to," \xb7 ").concat(th):"".concat(to," \xb7 Main");return(0,l.jsxs)("div",{className:"flex flex-col h-full w-full overflow-hidden",children:[(0,l.jsx)("div",{className:"relative z-20 shrink-0 h-[52px] box-border border-b border-border px-2 bg-background",children:(0,l.jsxs)("div",{className:"flex items-center gap-1 h-full",children:[(0,l.jsxs)(f.AM,{open:tc,onOpenChange:tu?void 0:td,children:[(0,l.jsx)(f.Wv,{asChild:!0,children:(0,l.jsxs)("button",{disabled:tu,className:"flex items-center gap-1.5 min-w-0 px-2 h-8 rounded-md text-sm font-medium text-foreground disabled:cursor-default enabled:hover:bg-sidebar-item-hover transition-colors",children:[(0,l.jsx)("span",{className:"truncate max-w-[200px]",children:tm}),!tu&&(0,l.jsx)(a.A,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"})]})}),(0,l.jsxs)(f.hl,{align:"start",sideOffset:4,className:"w-60 p-1.5 rounded-xl max-h-[70vh] overflow-y-auto",children:[!$&&(ei||eo||ec)&&(0,l.jsxs)(l.Fragment,{children:[ei&&(0,l.jsxs)("button",{onClick:()=>{td(!1),ei()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-muted transition-colors",children:[(0,l.jsx)(r.A,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),(0,l.jsx)("span",{className:"flex-1 text-left",children:"Rename"})]}),eo&&(0,l.jsxs)("button",{onClick:()=>{td(!1),eo()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-muted transition-colors",children:[eu?(0,l.jsx)(i.A,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}):(0,l.jsx)(o.A,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),(0,l.jsx)("span",{className:"flex-1 text-left",children:eu?"Remove from Favorites":"Add to Favorites"})]}),ec&&(0,l.jsxs)("button",{onClick:()=>{td(!1),ec()},className:"w-full flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-muted transition-colors",children:[(0,l.jsx)(c.A,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground rotate-90"}),(0,l.jsx)("span",{className:"flex-1 text-left",children:"Fork Session"})]}),(0,l.jsx)("div",{className:"h-px bg-border my-1"})]}),(0,l.jsxs)("button",{onClick:()=>{ea(),td(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-muted transition-colors",children:[(0,l.jsx)(d.A,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),(0,l.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:"Main"}),eI===m&&(0,l.jsx)(u.A,{className:"w-3.5 h-3.5 shrink-0 text-primary"})]}),eR.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-1 group",children:[(0,l.jsxs)("button",{onClick:()=>{er(e.id),td(!1)},className:"flex-1 min-w-0 flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-muted transition-colors",children:[(0,l.jsx)(d.A,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),(0,l.jsx)("span",{className:"flex-1 min-w-0 truncate text-left",children:e.title||"Untitled"}),eI===e.id&&(0,l.jsx)(u.A,{className:"w-3.5 h-3.5 shrink-0 text-primary"})]}),!$&&(0,l.jsx)(y.s,{sessionId:e.id,sessionTitle:e.title||"Untitled",onRenameClick:()=>{td(!1),tl({type:"rename",sessionId:e.id,sessionTitle:e.title||"Untitled"})},onDeleteClick:()=>{td(!1),tl({type:"delete",sessionId:e.id,sessionTitle:e.title||"Untitled"})}})]},e.id)),!$&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"h-px bg-border my-1"}),(0,l.jsxs)("button",{onClick:()=>{td(!1),te(!0)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-muted transition-colors text-muted-foreground",children:[(0,l.jsx)(h.A,{className:"w-3.5 h-3.5"}),(0,l.jsx)("span",{children:"New session"})]})]})]})]}),(0,l.jsx)("div",{className:"flex-1"}),eh]})}),(0,l.jsxs)("div",{className:"flex-1 min-h-0 flex overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex-1 min-w-0 flex overflow-hidden",children:[!e5&&(0,l.jsx)("div",{className:"flex-1 min-w-0 relative",children:(0,l.jsx)(g.x,{sessionId:n,windowSessionId:m,historyEvents:E,wsEvents:M,isLoadingHistory:D,agentStatus:T,questions:z,currentToolCallId:L,onSubmit:_,onInterrupt:O,onQuestionAnswer:U,onSessionCreated:W,onWindowRefresh:G,onAgentFileProduced:B,isSharePage:$,shareMode:q,isFreePlan:H,onUpgradeClick:X,installedSkills:Q,isNewUser:V,isSubscriptionSuccess:K,showLoadingCarousel:Y,showMacintoshEasterEgg:J,showCEOLetter:Z,historyPagination:ee,onLoadMoreHistory:et,isLoadingMoreHistory:en,hasTeam:eZ,teamData:es,isTeamExpanded:eE,onTeamExpand:eU,onTeamClose:eG,hasSubtasks:eJ,subtaskAgentCount:eK,subtaskRunningCount:eY,isSubtasksExpanded:eD,onSubtasksExpand:eB,onSubtasksClose:eq,sessionModel:null==e4?void 0:e4.model,sessionAccount:null==e4?void 0:e4.byoAccount,onSessionModelChange:P?e6:void 0,sessionConnectorIds:null==e4?void 0:e4.connectorIds,sessionBridgeIds:null==e4?void 0:e4.bridgeIds,onSessionConnectorsChange:P?e8:void 0,onSessionBridgesChange:P?e7:void 0,inputBottomPaddingClass:eg,chatContentClassName:ev,inputHorizontalPaddingClass:eb,inputMa
1xWidthClass:ew,shareCtaHref:ey,onShareCtaClick:ej,isSnapshotPage:eN,onForkFromMessage:ed})}),eE&&eZ&&es&&(0,l.jsx)("div",{className:e3,children:(0,l.jsx)(b.Q,{sessionId:n,teamData:es,wsEvents:M,onClose:eG,onCollapse:eW,onSessionCreated:W,onWindowRefresh:G,isShareMode:$})}),eD&&eJ&&(0,l.jsx)("div",{className:e3,children:(0,l.jsx)(v.l,{sessionId:n,groups:eV,wsEvents:M,onClose:eq,onCollapse:e$,onSessionCreated:W,onWindowRefresh:G,isShareMode:$})})]}),ef]}),(0,l.jsx)(x.X,{open:"rename"===tn.type,onOpenChange:e=>{e||tl({type:null,sessionId:"",sessionTitle:""})},title:"Rename Session",description:"Enter a new name for this session.",initialValue:tn.sessionTitle,placeholder:"Enter session name",loading:ts,onSubmit:tr}),(0,l.jsx)(p.T,{open:"delete"===tn.type,onOpenChange:e=>{e||tl({type:null,sessionId:"",sessionTitle:""})},title:"Delete Session",description:'Are you sure you want to delete "'.concat(tn.sessionTitle,'"? This will permanently delete the session and all its messages. This action cannot be undone.'),confirmLabel:"Delete",variant:"danger",icon:"trash",loading:ts,onConfirm:ti}),(0,l.jsx)(A.e,{open:e9,onOpenChange:te,fallbackTitle:"Session ".concat(eR.length+1),onSubmit:tt,isFreePlan:H,onUpgradeClick:X,installedSkills:Q,parentSessionId:m})]})}m.A},92556:(e,t,n)=>{let l,s;n.d(t,{Yy:()=>eW,xz:()=>eE,qn:()=>eT});var a=n(95155),r=n(12115),i=n(75143),o=n(50402),c=n(78266),d=n(5623),u=n(91788),h=n(66516),m=n(89917),f=n(62525),p=n(34869),x=n(42118),g=n(41066),v=n(5456),b=n(41684),w=n(5534),y=n(57434),j=n(84616),N=n(14395),k=n(53904),C=n(5459),S=n(12767),F=n(54416),R=n(74311),A=n(91981),P=n(4113),I=n(59434),E=n(9486),M=n(38651),D=n(41932),T=n(19739),z=n(93307),L=n(51154),_=n(66474),O=n(13052),U=n(21675),W=n(29869),G=n(55630),B=n(89728),$=n(6422),q=n(44605);function H(e){return e.startsWith("/")?e:"/".concat(e)}var X=n(56671),Q=n(44838),V=n(27716);function K(e,t,n){let l=0,s=e;for(;l<s;){let e=Math.ceil((l+s)/2);n(e)<=t?l=e:s=e-1}return l}function Y(e){let{name:t,trailing:n,className:s}=e,i=(0,r.useRef)(null),o=(0,r.useRef)(null),c=(0,r.useRef)(null),[d,u]=(0,r.useState)(t),[h,m]=(0,r.useState)();return(0,r.useLayoutEffect)(()=>{var e;let n=i.current,s=o.current;if(!n||!s)return;let a=!1,r=()=>{if(a)return;let e=function(e){void 0===l&&(l=document.createElement("canvas").getContext("2d"));let t=l;if(!t)return null;let n=getComputedStyle(e);return t.font="".concat(n.fontStyle," ").concat(n.fontWeight," ").concat(n.fontSize," ").concat(n.fontFamily),"letterSpacing"in t&&(t.letterSpacing=n.letterSpacing),e=>t.measureText(e).width}(s);if(!e)return;let r=e(t),i=c.current,o=i?i.offsetWidth+(parseFloat(getComputedStyle(n).columnGap)||0):0;m(r+1+o);let d=n.offsetWidth-o;u(r<=d?t:function(e,t,n){let l=Array.from(t),s=n-e("…");if(s<=0)return"…";let{ext:a}=(0,$.se)(t),r=Math.min(s/2,Math.max(0,s-e(a))),i=K(l.length,r,t=>e(l.slice(0,t).join(""))),o=l.slice(0,i).join(""),c=K(l.length-i,s-e(o),t=>e(l.slice(l.length-t).join(""))),d=l.slice(l.length-c).join("");return o||d?"".concat(o).concat("…").concat(d):"…"}(e,t,d))};if(r(),null==(e=document.fonts)||e.ready.then(r),"undefined"==typeof ResizeObserver)return()=>{a=!0};let d=new ResizeObserver(r);return d.observe(n),c.current&&d.observe(c.current),()=>{a=!0,d.disconnect()}},[t,!!n]),(0,a.jsxs)("span",{ref:i,className:(0,I.cn)("flex min-w-0 shrink items-center gap-1",s),style:void 0===h?void 0:{flexBasis:"".concat(h,"px")},title:d===t?void 0:t,children:[(0,a.jsx)("span",{ref:o,className:"min-w-0 truncate",children:d}),n?(0,a.jsx)("span",{ref:c,className:"flex shrink-0 items-center",children:n}):null]})}var J=n(14769),Z=n(13485);function ee(e){return"folder"===e?"Renaming this folder will break links to its files in earlier chat messages.":"Renaming this file will break links to it in earlier chat messages."}function et(e){return"folder"===e?"Any links to files in this folder in earlier chat messages will no longer work.":"Any links to this file in earlier chat messages will no longer work."}let en=(0,r.createContext)(null),el=(0,r.createContext)(null),es=(0,r.createContext)(null);function ea(e){var t,n,l,s,i;let{node:o,depth:c,onFileClick:x,onFileOpenInTab:g,activeFilePath:v,expandedPaths:b,onToggle:w,onRenameFile:y,onDeleteFile:k,onDeleteFolder:C,onDownloadFile:S,onDownloadFolder:F,onUploadFiles:R,onUploadFolder:A,onShareFile:P,readOnly:E,sharedFiles:M,onCreateShare:D,onDeleteShare:T,loadedPaths:z,loadingPaths:$}=e,q=(0,r.useContext)(en),X=(0,r.useContext)(el),K=(0,r.useContext)(es),J=b.has(o.path),Z=$.has(o.path),ee="file"===o.type&&v===(null!=(l=null==(t=o.file)?void 0:t.path)?l:"/".concat(o.path)),[et,er]=(0,r.useState)(null),ei=(0,r.useRef)(null);(0,r.useEffect)(()=>{var e;ee&&(null==(e=ei.current)||e.scrollIntoView({block:"nearest"}))},[ee]);let eo="directory"===o.type,ec=(eo?!!F:!!S)||!eo&&!!M&&!!D&&!!T,ed=!E&&!!y,eu=H(null!=(s=null==(n=o.file)?void 0:n.path)?s:o.path),eh=!eo&&(null==M?void 0:M.get(eu))||null,em=eh?(0,a.jsx)(p.A,{role:"img","aria-label":"Shared to web",className:"w-3 h-3 shrink-0 text-blue-500 dark:text-blue-400"}):null,ef=null!=(i=o.file)?i:{name:o.name,path:o.path,type:o.type,size:0,mimetype:""},ep=Array.from({length:c},(e,t)=>8+12*t+7);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{ref:ei,className:(0,I.cn)("group relative flex items-center gap-1 py-[3px] pr-1 text-xs leading-4 rounded-sm transition-colors cursor-pointer select-none [&_svg]:[stroke-width:1.5]",ee?"bg-sidebar-item-active hover:bg-sidebar-item-active-hover text-foreground":"text-muted-foreground hover:text-foreground hover:bg-sidebar-item-hover"),style:{paddingLeft:"".concat(8+12*c,"px")},onClick:()=>{"directory"===o.type?w(o.path):x(ef)},children:[ep.map(e=>(0,a.jsx)("span",{className:"absolute top-0.5 bottom-0.5 w-px bg-foreground
1/10 dark:bg-foreground/15 pointer-events-none",style:{left:"".concat(e,"px")}},e)),"directory"===o.type?(0,a.jsx)("span",{className:"shrink-0 w-3.5 h-3.5 flex items-center justify-center text-muted-foreground",children:Z?(0,a.jsx)(L.A,{className:"w-3.5 h-3.5 animate-spin"}):J?(0,a.jsx)(_.A,{className:"w-3.5 h-3.5"}):(0,a.jsx)(O.A,{className:"w-3.5 h-3.5"})}):(0,a.jsx)("span",{className:"shrink-0 w-3.5 h-3.5 flex items-center justify-center",children:(0,B.I3)(ef,"w-3.5 h-3.5")}),(0,a.jsx)("span",{className:"flex min-w-0 flex-1 items-center gap-1",children:eo?(0,a.jsx)("span",{className:"truncate min-w-0",children:o.name}):(0,a.jsx)(Y,{name:o.name,trailing:em})}),(0,a.jsxs)("div",{className:et?"contents":"hidden group-hover:contents",onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:["file"===o.type&&(0,a.jsx)(G.C,{label:"Open in new tab",children:(0,a.jsx)("button",{className:"shrink-0 p-0.5 rounded hover:bg-sidebar-item-active-hover transition-colors",onClick:e=>{e.stopPropagation(),g(ef)},children:(0,a.jsx)(U.A,{className:"w-3 h-3"})})}),"directory"===o.type&&!E&&(R||A)&&(0,a.jsxs)(Q.rI,{open:"upload"===et,onOpenChange:e=>er(e?"upload":null),children:[(0,a.jsx)(G.C,{label:"Upload here",children:(0,a.jsx)(Q.ty,{asChild:!0,children:(0,a.jsx)("button",{className:"shrink-0 p-0.5 rounded hover:bg-sidebar-item-active-hover transition-colors",onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,a.jsx)(j.A,{className:"w-3 h-3"})})})}),(0,a.jsxs)(Q.SQ,{align:"start",className:"w-40 rounded-xl",container:q,children:[R&&(0,a.jsxs)(Q._2,{onClick:()=>R("/".concat(o.path)),children:[(0,a.jsx)(W.A,{className:"w-3.5 h-3.5"}),"Upload files"]}),A&&(0,a.jsxs)(Q._2,{onClick:()=>A("/".concat(o.path)),children:[(0,a.jsx)(N.A,{className:"w-3.5 h-3.5"}),"Upload folder"]})]})]}),(0,a.jsxs)(Q.rI,{open:"more"===et,onOpenChange:e=>er(e?"more":null),children:[(0,a.jsx)(G.C,{label:"More",children:(0,a.jsx)(Q.ty,{asChild:!0,children:(0,a.jsx)("button",{className:"shrink-0 p-0.5 rounded hover:bg-sidebar-item-active-hover transition-colors",onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,a.jsx)(d.A,{className:"w-3 h-3"})})})}),(0,a.jsxs)(Q.SQ,{align:"start",className:"w-36 rounded-xl",container:q,children:["file"===o.type&&S&&(0,a.jsxs)(Q._2,{onClick:()=>{var e,t;return S(null!=(t=null==(e=o.file)?void 0:e.path)?t:"/".concat(o.path),o.name)},children:[(0,a.jsx)(u.A,{className:"w-3.5 h-3.5"}),"Download"]}),"directory"===o.type&&F&&(0,a.jsxs)(Q._2,{onClick:()=>F("/".concat(o.path),o.name),children:[(0,a.jsx)(u.A,{className:"w-3.5 h-3.5"}),"Download"]}),"file"===o.type&&M&&D&&T&&(0,a.jsxs)(Q.lv,{children:[(0,a.jsxs)(Q.nV,{className:"[&>
1svg:last-child]:hidden",children:[(0,a.jsx)(h.A,{className:"w-3.5 h-3.5"}),"Share"]}),(0,a.jsx)(Q.M5,{className:"p-3 w-72 rounded-xl",children:(0,a.jsx)(V.q,{filePath:eu,share:eh,onCreateShare:D,onDeleteShare:T})})]}),ed&&(0,a.jsxs)(Q._2,{onClick:()=>{var e,t;return null==X?void 0:X({path:null!=(t=null==(e=o.file)?void 0:e.path)?t:o.path,name:o.name,type:o.type})},children:[(0,a.jsx)(m.A,{className:"w-3.5 h-3.5"}),"Rename"]}),(ec||ed)&&!E&&(eo?!!C:!!k)&&(0,a.jsx)(Q.mB,{}),!E&&"file"===o.type&&k&&(0,a.jsxs)(Q._2,{className:"text-destructive focus:text-destructive",onClick:()=>{var e,t;return null==K?void 0:K({path:null!=(t=null==(e=o.file)?void 0:e.path)?t:"/".concat(o.path),name:o.name,type:"file"})},children:[(0,a.jsx)(f.A,{className:"w-3.5 h-3.5"}),"Delete"]}),!E&&"directory"===o.type&&C&&(0,a.jsxs)(Q._2,{className:"text-destructive focus:text-destructive",onClick:()=>null==K?void 0:K({path:"/".concat(o.path),name:o.name,type:"directory"}),children:[(0,a.jsx)(f.A,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]})]}),"directory"===o.type&&J&&o.children.map(e=>(0,a.jsx)(ea,{node:e,depth:c+1,onFileClick:x,onFileOpenInTab:g,activeFilePath:v,expandedPaths:b,onToggle:w,onRenameFile:y,onDeleteFile:k,onDeleteFolder:C,onDownloadFile:S,onDownloadFolder:F,onUploadFiles:R,onUploadFolder:A,onShareFile:P,readOnly:E,sharedFiles:M,onCreateShare:D,onDeleteShare:T,loadedPaths:z,loadingPaths:$},e.path))]})}function er(e){let{sessionFiles:t,onFileClick:n,onFileOpenInTab:l,activeFilePath:s,isLoading:i,onRenameFile:o,onDeleteFile:c,onDeleteFolder:d,onDownloadFile:u,onDownloadFolder:h,onUploadFiles:m,onUploadFolder:f,onShareFile:p,readOnly:x,externalExpandedPaths:g,onExpandedPathsChange:v,sharedFiles:b,onCreateShare:w,onDeleteShare:y,loadedPaths:j=[],onLoadDirectory:N,portalContainer:k=null}=e,C=(0,r.useMemo)(()=>(function(e){let t={name:"",path:"",type:"directory",children:[]};for(let n of e){let e=n.path.replace(/^\//,"").split("/").filter(Boolean),l=t;for(let t=0;t<e.length;t++){let s=e[t],a=t===e.length-1,r=l.children.find(e=>e.name===s);r?a&&(r.file=n,r.type="directory"!==n.type?"file":"directory",r.isLazy=n.isLazy):(r={name:s,path:e.slice(0,t+1).join("/"),type:a&&"directory"!==n.type?"file":"directory",file:a?n:void 0,children:[],isLazy:a?n.isLazy:void 0},l.children.push(r)),l=r}}return function e(t){return t.sort((e,t)=>"directory"===e.type&&"directory"!==t.type?-1:"directory"!==e.type&&"directory"===t.type?1:e.name.localeCompare(t.name)).map(t=>({...t,children:e(t.children)}))}(t.children)})(t),[t]),[S,F]=(0,r.useState)(new Set),[R,A]=(0,r.useState)(new Set),P=(0,r.useRef)(!1),I=void 0!==g,E=I?g:S,M=(0,r.useMemo)(()=>new Set(j),[j]);(0,r.useEffect)(()=>{!I&&(P.current||0===C.length||(P.current=!0,F(new Set(C.filter(e=>"directory"===e.type&&!e.isLazy).map(e=>e.path)))))},[C,I]);let D=(0,r.useRef)(new Set),[T,z]=(0,r.useState)(null),L=(null==T?void 0:T.type)==="directory",{stem:_,ext:O}=T?L?{stem:T.name,ext:""}:(0,$.se)(T.name):{stem:"",ext:""},[U,W]=(0,r.useState)(null),G=(null==U?void 0:U.type)==="directory",B=async e=>{if(!N)return!0;A(t=>new Set(t).add(e));try{return await N(e),D.current.delete(e),!0}catch(t){return D.current.add(e),X.oR.error(t instanceof Error?t.message:"Failed to load directory"),!1}finally{A(t=>{let n=new Set(t);return n.delete(e),n})}},q=e=>{let t=function e(t,n){for(let l of t){if(l.path===n)return l;let t=e(l.children,n);if(t)return t}}(C,e);return(null==t?void 0:t.type)==="directory"&&!!t.isLazy&&!M.has(e)&&!R.has(e)},H=e=>{I?null==v||v(e):F(e)},Q=async e=>{if(q(e)&&(D.current.delete(e),!await B(e)))return;let t=new Set(E);t.has(e)?t.delete(e):t.add(e),H(t)},V=(0,r.useRef)(s);return((0,r.useEffect)(()=>{if(!s||V.current===s)return;V.current=s;let e=(function(e){let t=e.replace(/^\//,"").split("/").filter(Boolean);return t.pop(),t.map((e,n)=>t.slice(0,n+1).join("/"))})(s).filter(e=>!E.has(e));if(0===e.length)return;let t=new Set(E);for(let n of e)t.add(n);H(t)},[s]),(0,r.useEffect)(()=>{if(N)for(let e of E)!D.current.has(e)&&q(e)&&B(e)},[E,C,M,R,N]),i)?(0,a.jsx)("div",{className:"p-2 space-y-1",children:[1,2,3,4,5].map(e=>(0,a.jsx)("div",{className:"h-5 rounded bg-muted/50 animate-pulse",style:{width:"".concat(60+8*e,"%")}},e))}):0===C.length?(0,a.jsx)("div",{className:"p-3 text-xs text-muted-foreground",children:"No files"}):(0,a.jsx)(en.Provider,{value:k,children:(0,a.jsx)(el.Provider,{value:z,children:(0,a.jsxs)(es.Provider,{value:W,children:[(0,a.jsx)(J.X,{open:!!T,onOpenChange:e=>{e||z(null)},container:k,title:L?"Rename folder":"Rename file",warning:ee(L?"folder":"file"),initialValue:_,placeholder:L?"Folder name":"File name",confirmLabel:"Rename",onSubmit:e=>{if(z(null),!T)return;let t="".concat(e).concat(O);t!==T.name&&(null==o||o(T.path,t,T.type))}}),(0,a.jsx)(Z.T,{open:!!U,onOpenChange:e=>{e||W(null)},container:k,variant:"danger",title:G?"Delete folder":"Delete file",description:(0,a.jsxs)(a.Fragment,{children:["Delete ",(0,a.jsx)("span",{className:"font-medium text-foreground",children:null==U?void 0:U.name}
1),"? This can't be undone. ",et(G?"folder":"file")]}),confirmLabel:"Delete",onConfirm:()=>{W(null),U&&("directory"===U.type?null==d||d(U.path,U.name):null==c||c(U.path,U.name))}}),(0,a.jsx)("div",{className:"p-1 space-y-0.5 select-none",children:C.map(e=>(0,a.jsx)(ea,{node:e,depth:0,onFileClick:n,onFileOpenInTab:l,activeFilePath:s,expandedPaths:E,onToggle:Q,onRenameFile:o,onDeleteFile:c,onDeleteFolder:d,onDownloadFile:u,onDownloadFolder:h,onUploadFiles:m,onUploadFolder:f,onShareFile:p,readOnly:x,sharedFiles:b,onCreateShare:w,onDeleteShare:y,loadedPaths:M,loadingPaths:R},e.path))})]})})})}var ei=n(88170),eo=n(49619),ec=n(35235),ed=n(40590);function eu(e){let{sessionId:t,file:n,readOnly:l=!1,snapshotId:s,isGlobalFile:i=!1,globalFilePath:o,watermarkGeneratedMedia:c=!1}=e,d=(0,r.useMemo)(()=>(function(e){let t=e.name||e.path,n=e.mimetype;return(0,$.u)(t,n)?"image":(0,$.AE)(t,n)?"video":!function(e){let t=e.toLowerCase().split(".").pop();return"html"===t||"htm"===t||"csv"===t||"tsv"===t}(t)?(0,$.oD)(t,n)?"text-editor":"preview":"preview"})(n),[n]),u=o||(n.path.startsWith("/")?n.path:"/".concat(n.path));return"text-editor"===d?(0,a.jsx)(ei.v,{sessionId:t,filePath:u,fileName:n.name,readOnly:l,snapshotId:s,isGlobalFile:i}):"image"===d?(0,a.jsx)(ec.e,{sessionId:t,filePath:u,fileName:n.name,readOnly:l,snapshotId:s,isGlobalFile:i,watermarkGeneratedMedia:c}):"video"===d?(0,a.jsx)(ed.o,{sessionId:t,filePath:u,fileName:n.name,readOnly:l,snapshotId:s,isGlobalFile:i,watermarkGeneratedMedia:c}):(0,a.jsx)(eo.r,{sessionId:t,filePath:u,fileName:n.name,readOnly:l,snapshotId:s,isGlobalFile:i})}var eh=n(43405),em=n(10521),ef=n(15064),ep=n(26511),ex=n(43228);let eg="__ui2_files__",ev="__ui2_inline_preview__",eb="memory/";function ew(e){let t=e.startsWith("/")?e.slice(1):e;return"memory"===t||t.startsWith(eb)}function ey(e,t){let n="/home/node/.claude/projects/-home-node-a0-workspace-".concat(e,"-workspace/memory"),l=t.startsWith("/")?t.slice(1):t;if("memory"===l)return n;let s=l.startsWith(eb)?l.slice(eb.length):l;return"".concat(n,"/").concat(s)}function ej(e,t){let n=ey(e,"memory");return t===n?"memory":t.startsWith("".concat(n,"/"))?"".concat(eb).concat(t.slice(n.length+1)):null}function eN(e,t){var n;return H(null!=(n=ej(e,t))?n:t)}let ek="filespane_tree_width";function eC(e){let{fileName:t,sharePath:n,share:l,onCreateShare:s,onDeleteShare:i,onRename:o,onDownload:c,onDelete:p,container:x}=e,[g,v]=(0,r.useState)(!1),[b,w]=(0,r.useState)(!1),[y,j]=(0,r.useState)(!1),N=(0,r.useCallback)(()=>v(!1),[]);(0,ef.Z)(g,N);let k=!!(s&&i),{stem:C,ext:S}=(0,$.se)(t);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(Q.rI,{open:g,onOpenChange:v,children:[(0,a.jsx)(G.C,{label:"More options",container:x,children:(0,a.jsx)(Q.ty,{asChild:!0,children:(0,a.jsx)("button",{className:"w-7 h-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-sidebar-item-hover transition-colors",children:(0,a.jsx)(d.A,{className:"w-3.5 h-3.5"})})})}),(0,a.jsxs)(Q.SQ,{align:"end",className:"w-44",container:null!=x?x:void 0,children:[(0,a.jsxs)(Q._2,{onClick:c,children:[(0,a.jsx)(u.A,{className:"w-3.5 h-3.5"}),"Download"]}),k&&(0,a.jsxs)(Q.lv,{children:[(0,a.jsxs)(Q.nV,{className:"[&>
1svg:last-child]:hidden",children:[(0,a.jsx)(h.A,{className:"w-3.5 h-3.5"}),"Share"]}),(0,a.jsx)(Q.M5,{className:"p-3 w-72 rounded-xl",children:(0,a.jsx)(V.q,{filePath:n,share:l,onCreateShare:s,onDeleteShare:i})})]}),o&&(0,a.jsxs)(Q._2,{onClick:()=>w(!0),children:[(0,a.jsx)(m.A,{className:"w-3.5 h-3.5"}),"Rename"]}),p&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Q.mB,{}),(0,a.jsxs)(Q._2,{className:"text-destructive focus:text-destructive",onClick:()=>j(!0),children:[(0,a.jsx)(f.A,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]}),o&&(0,a.jsx)(J.X,{open:b,onOpenChange:w,container:x,title:"Rename file",warning:ee("file"),initialValue:C,placeholder:"File name",confirmLabel:"Rename",onSubmit:e=>{w(!1);let n="".concat(e).concat(S);n!==t&&o(n)}}),p&&(0,a.jsx)(Z.T,{open:y,onOpenChange:j,container:x,variant:"danger",title:"Delete file",description:(0,a.jsxs)(a.Fragment,{children:["Delete ",(0,a.jsx)("span",{className:"font-medium text-foreground",children:t}),"? This can't be undone. ",et("file")]}),confirmLabel:"Delete",onConfirm:()=>{j(!1),p()}})]})}let eS="w-3.5 h-3.5 shrink-0",eF=(0,a.jsx)(p.A,{role:"img","aria-label":"Shared to web",className:"h-3.5 w-3.5 shrink-0 text-blue-500 dark:text-blue-400"});function eR(e){return(0,B.I3)(e,eS,"text-current")}let eA=new Set(["preview","text-editor","image","video"]);function eP(e){let t=e.replace(/\.[a-z][a-z0-9]{0,7}$/i,"");return t.length>0?t:e}let eI=new Set(["preview","canvas","image","video","text-editor","url-preview","vnc-preview","terminal"]);function eE(e){return"".concat("ui2_files_state",":").concat(e)}function eM(e){try{let t=localStorage.getItem(eE(e));if(!t)return null;let n=JSON.parse(t);return n&&"object"==typeof n&&!Array.isArray(n)?n:null}catch(e){return null}}function eD(e,t){try{var n;let l=null!=(n=eM(e))?n:{};localStorage.setItem(eE(e),JSON.stringify({...l,pane:t}))}catch(e){console.warn("[FilesPane] Failed to save UI state:",e)}}function eT(e){var t;let n=eM(e);return function(e){if(!e)return!1;let t=e.openTabs,n=e.inlineTabs,l=e.snapshotTabs;return!!(e.activeTab||e.activeInlineFilePath||e.activeSnapshotFilePath||Array.isArray(t)&&t.length>0||Array.isArray(n)&&n.length>0||Array.isArray(l)&&l.length>0)}(null!=(t=null==n?void 0:n.pane)?t:null)}function ez(e){var t,n,l;return{name:e.name,path:e.path,size:null!=(t=e.size)?t:0,mimetype:null!=(n=e.mimetype)?n:"",type:null!=(l=e.type)?l:"file",created_at:e.created_at,modified_at:e.modified_at,lastModified:e.lastModified}}function eL(e){return Array.isArray(e)?e.flatMap(e=>e&&"object"==typeof e?"string"!=typeof e.path||"string"!=typeof e.name?[]:[{name:e.name,path:e.path,size:"number"==typeof e.size?e.size:0,mimetype:"string"==typeof e.mimetype?e.mimetype:"",type:"string"==typeof e.type?e.type:"file",created_at:"string"==typeof e.created_at?e.created_at:void 0,modified_at:"string"==typeof e.modified_at?e.modified_at:void 0,lastModified:"string"==typeof e.lastModified?e.lastModified:void 0}]:[]):[]}function e_(e){return"snapshot-tab:".concat(e)}function eO(e){return e?e.startsWith("/")?e.slice(1):e:""}function eU(e,t){return eO(e)===eO(t)}function eW(e){var t,n;let{sessionId:l,sandboxId:s,renderWindowContent:c,onRefresh:d,onUploadFiles:u,onUploadFolder:h,onDeleteFile:m,onDeleteFolder:f,readOnly:p=!1,snapshotId:L,watermarkGeneratedMedia:_=!1,snapshotFiles:O,initialUiState:U,getUiStateRef:W}=e,B=(0,E.useAppDispatch)(),V=(0,E.useAppSelector)(e=>e.ui.floatingWindows),K=(0,E.useAppSelector)(z.selectUserSandboxId),J=(0,E.useAppSelector)(e=>{var t;return(null==(t=e.sessions.sessions.find(e=>e.id===l))?void 0:t.provider)==="codex"}),Z=(0,T._v)(),{broadcastDraftAsModified:ee,flushFileDrafts:et,modifiedFiles:en}=(0,eh.C)(),{sharedFiles:el,createShare:es,deleteShare:ea}=function(e){let[t,n]=(0,r.useState)(new Map),[l,s]=(0,r.useState)(!1),a=(0,r.useRef)(null),i=(0,r.useCallback)(async()=>{if(e){s(!0);try{let t=await q.j.listFileShares({sessionId:e,limit:100}),l=new Map;for(let e of t)l.set(H(e.filePath),e);n(l)}catch(e){console.error("[useFileShares] Failed to fetch shares:",e)}finally{s(!1)}}},[e]);return(0,r.useEffect)(()=>{e&&a.current!==e&&(a.current=e,i())},[e,i]),{sharedFiles:t,isLoading:l,refresh:i,createShare:(0,r.useCallback)(async t=>{if(!e)throw Error("No session");let{fileShare:l}=await q.j.createFileShare({sessionId:e,filePath:t});return n(e=>{let n=new Map(e);return n.set(H(t),l),n}),l},[e]),deleteShare:(0,r.useCallback)(async(e,t)=>{await q.j.deleteFileShare(e),n(e=>{let n=new Map(e);return n.delete(H(t)),n})},[])}}(p?null:l),[ei,eo]=(0,r.useState)(eg),ec=(0,r.useRef)(eg),[ed,ef]=(0,r.useState)(null),[eb,eE]=(0,r.useState)([]),[eT,eO]=(0,r.useState)([]),[eW,eQ]=(0,r.useState)([]),[eV,eK]=(0,r.useState)(void 0),eY=!p&&!L,[eJ,eZ]=(0,r.useState)(()=>
1{if(!eY)return 220;let e=localStorage.getItem(ek),t=e?parseInt(e,10):NaN;return isNaN(t)?220:Math.min(520,Math.max(200,t))}),[e0,e1]=(0,r.useState)(!1),[e5,e3]=(0,r.useState)(!1),e2=(0,r.useRef)(null),e4=(0,r.useRef)(!1),e6=(0,r.useRef)(0),e8=(0,r.useRef)(0),e7=(0,r.useRef)(null),e9=(0,r.useRef)(null),te=(0,r.useCallback)(e=>{var t;e.preventDefault(),e.stopPropagation(),null==(t=e9.current)||t.call(e9),e4.current=!0,e6.current=e.clientX,e8.current=eJ;let n=e.clientX,l=eJ;e1(!0),document.documentElement.classList.add("dragging-active"),document.body.style.cursor="col-resize",document.body.style.userSelect="none";let s=()=>{e7.current=null;let e=n-e6.current;eZ(l=Math.min(520,Math.max(200,e8.current+e)))},a=e=>{e4.current&&(e.preventDefault(),n=e.clientX,null===e7.current&&(e7.current=requestAnimationFrame(s)))},r=()=>{null!==e7.current&&cancelAnimationFrame(e7.current),s(),e4.current=!1,eY&&localStorage.setItem(ek,String(l)),e1(!1),document.documentElement.classList.remove("dragging-active"),document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",i),window.removeEventListener("blur",r),e9.current=null},i=e=>{n=e.clientX,r()};e9.current=r,window.addEventListener("mousemove",a),window.addEventListener("mouseup",i),window.addEventListener("blur",r)},[eJ,eY]);(0,r.useEffect)(()=>()=>{var e;null==(e=e9.current)||e.call(e9)},[]),(0,r.useEffect)(()=>{let e=()=>{e3(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);let tt=(0,r.useCallback)(()=>{if(e5)document.exitFullscreen();else{var e;null==(e=e2.current)||e.requestFullscreen()}},[e5]),tn=(0,r.useMemo)(()=>V.filter(e=>e.sessionId===l&&eI.has(e.type)),[V,l]);(0,r.useEffect)(()=>{if(0===tn.length){ei!==eg&&ei!==ev&&eo(eg);return}!ts.current&&(tn.some(e=>e.id===ei)||eo(tn[tn.length-1].id))},[tn.length]);let tl=(0,r.useRef)(!1),ts=(0,r.useRef)(!1),ta=(0,r.useCallback)((e,t)=>{ts.current=!0;let n=e.treeExpandedPaths;Array.isArray(n)&&eK(new Set(n));let s=e.tabOrder;Array.isArray(s)&&eQ(s.filter(e=>"string"==typeof e));let a=eL(e.inlineTabs),r=eL(e.snapshotTabs),i="string"==typeof e.activeInlineFilePath?e.activeInlineFilePath:void 0,o="string"==typeof e.activeSnapshotFilePath?e.activeSnapshotFilePath:void 0;if(a.length>0){let e=i?a.find(e=>eU(e.path,i)):void 0,t=null!=e?e:a[0];eE([t]),ef(t.path)}else i&&ef(i);r.length>0&&eO(r);let c=e.openTabs,d=e.activeTab;if(Array.isArray(c)&&c.length>0)for(let e of c)B((0,M.openFloatingWindow)({id:e.id,type:e.type,sessionId:l,filePath:e.filePath,fileName:e.fileName,url:e.url,x:0,y:0,width:800,height:600}));d===ev&&a.length>0?(eo(eg),ef(i&&a.some(e=>e.path===i)?i:a[0].path)):(null==d?void 0:d.startsWith("snapshot-tab:"))&&r.some(e=>e_(e.path)===d)?eo(d):o&&r.some(e=>e.path===o)?eo(e_(o)):d&&d!==eg&&d!==ev&&eo(d),requestAnimationFrame(()=>{null!=t&&t()||(ts.current=!1,tl.current=!0)})},[]);(0,r.useEffect)(()=>{let e=!1,t=()=>e;if(void 0!==U){if(!U){tl.current=!0;return}return ta(U,t),()=>{e=!0}}if(!eY||!l){tl.current=!0;return}let n=function(e){let t=eM(e);return(null==t?void 0:t.pane)&&"object"==typeof t.pane&&!Array.isArray(t.pane)?t.pane:null}(l);if(!n){tl.current=!0;return}return ta(n,t),()=>{e=!0}},[]);let tr=(0,r.useRef)(null),ti=(0,r.useRef)(null),to=(0,r.useCallback)(e=>{eY&&l&&tl.current&&!ts.current&&eD(l,e)},[l,eY]),tc=(0,r.useCallback)((e,t)=>{if(eY&&l&&tl.current&&!ts.current){if(null==t?void 0:t.immediate){tr.current&&(clearTimeout(tr.current),tr.current=null),ti.current=null,eD(l,e);return}ti.current=e,tr.current&&clearTimeout(tr.current),tr.current=setTimeout(()=>{ti.current&&(eD(l,ti.current),ti.current=null)},1e3)}},[l,eY]);(0,r.useEffect)(()=>{if(!eY||!l)return;let e=()=>{tr.current&&(clearTimeout(tr.current),tr.current=null);let e=ti.current;e&&!ts.current&&tl.current&&(ti.current=null,eD(l,e))};return window.addEventListener("pagehide",e),()=>{window.removeEventListener("pagehide",e),e()}},[l,eY]);let td=(0,r.useRef)(tn);td.current=tn,ec.current=ei;let tu=(0,r.useRef)(eV);tu.current=eV;let th=(0,r.useRef)(eb);th.current=eb;let tm=(0,r.useRef)(eT);tm.current=eT;let tf=(0,r.useRef)(ed);tf.current=ed;let tp=(0,r.useRef)(eW);tp.current=eW;let tx=(0,r.useCallback)(()=>{var e;let t=ec.current,n={openTabs:td.current.map(e=>({id:e.id,type:e.type,filePath:e.filePath,fileName:e.fileName,url:e.url})),inlineTabs:th.current.map(ez),snapshotTabs:tm.current.map(ez),activeTab:t!==eg?t:void 0,activeInlineFilePath:null!=(e=tf.current)?e:void 0,activeSnapshotFilePath:t.startsWith("snapshot-tab:")?t.slice(13):void 0};return void 0!==tu.current&&(n.treeExpandedPaths=Array.from(tu.current)),tp.current.length>0&&(n.tabOrder=tp.current),n},[]);(0,r.useEffect)(()=>
1{if(W)return W.current=tx,()=>{W.current=null}},[!!W]),(0,r.useEffect)(()=>{to(tx())},[tn,ei,eb,ed,eT,eW]),(0,r.useEffect)(()=>{void 0!==eV&&tc(tx())},[eV]);let tg=null!=(t=null!=s?s:K)?t:void 0,tv=!!O,{files:tb,isLoading:tw,refreshFiles:ty,loadDirectory:tj,loadedPaths:tN}=(0,D.ch)(l,{autoLoad:!tv&&!!l,useCentralizedData:!1,recursive:!0,publicMode:!tv&&p?{sandboxId:tg}:void 0}),tk=null!=O?O:tb,tC=!tv&&tw,[tS,tF]=(0,r.useState)([]),[tR,tA]=(0,r.useState)(0),tP=(0,r.useCallback)(()=>tA(e=>e+1),[]);(0,r.useEffect)(()=>{if(!l||tv||J)return;let e="/home/node/.claude/projects/-home-node-a0-workspace-".concat(l,"-workspace/memory"),t=!1;return(p?em.files.getPublicGlobalFiles(l,e,!0):em.files.getGlobalFiles(e,!0)).then(n=>{t||tF(n.files.filter(e=>"file"===e.type).map(t=>({name:t.name,path:"memory/".concat(t.path.replace(e+"/","")),size:t.size,mimetype:t.mimeType||"text/plain",type:"file",lastModified:t.lastModified})))}).catch(()=>{t||tF([])}),()=>{t=!0}},[l,p,tv,tR]);let tI=(0,r.useRef)(0);(0,r.useEffect)(()=>{if(!l||p||tv)return;let e="/home/node/.claude/projects/-home-node-a0-workspace-".concat(l,"-workspace/memory");Object.entries(en).some(t=>{let[n,l]=t;return l>tI.current&&n.startsWith(e)})&&(tI.current=Date.now(),tP())},[en,l,p,tv,tP]);let tE=(0,r.useRef)(!1);tk&&tk.length>0&&(tE.current=!0);let tM=tC&&!tE.current,tD=(0,r.useMemo)(()=>{let e=null!=tk?tk:[];return J?e:[...e,{name:"memory",path:"memory",size:0,mimetype:"",type:"directory"},...tS]},[tk,tS,J]),tT=tD.map(e=>{var t,n,l;return"".concat(e.path,"|").concat(null!=(n=null!=(t=e.modified_at)?t:e.lastModified)?n:"","|").concat(null!=(l=e.size)?l:"","|").concat(e.isLazy?"lazy":"loaded")}).join(";"),tz=(0,r.useMemo)(()=>tD,[tT]),tL=(0,r.useCallback)(e=>eT.find(t=>eU(t.path,e)),[eT]),t_=(0,r.useCallback)(()=>{var e,t;return ei===eg?ed:ei.startsWith("snapshot-tab:")?null:null!=(t=null==(e=tn.find(e=>e.id===ei))?void 0:e.filePath)?t:null},[ei,ed,tn]),tO=(0,r.useCallback)(async e=>{e&&(await et(e),ee(e))},[et,ee]),tU=(0,r.useCallback)(async e=>{await tO(t_()),eo(e)},[t_,tO]),tW=(0,r.useMemo)(()=>tn.reduce((e,t)=>!e||t.zIndex>e.zIndex?t:e,null),[tn]),tG=tW?"".concat(tW.id,":").concat(tW.zIndex):"",tB=(0,r.useRef)({count:0,signal:""});(0,r.useEffect)(()=>{let e=tB.current;tB.current={count:tn.length,signal:tG},tW&&!ts.current&&tG&&tG!==e.signal&&(""!==e.signal||!(tn.length<=e.count))&&ei!==tW.id&&tU(tW.id)},[tn.length,tW,tG,ei,tU]);let t$=e=>{ef(e.path),eE(t=>t.some(t=>eU(t.path,e.path))?t:[...t,e]),eo(eg)},tq=e=>{if(!e)return;let t=tz.find(t=>eU(t.path,e));t&&t$(t)},tH=async e=>{var t,n;if(await tO(t_()),L){let t=tL(e.path),n="snapshot-tab:".concat(e.path);t?tU(e_(t.path)):(eO(t=>t.some(t=>eU(t.path,e.path))?t:[...t,e]),tU(n));return}if(ew(e.path)){let n=ey(l,e.path);Z.openFile({name:e.name,path:n},{sessionId:l,sandboxId:null!=(t=null!=s?s:K)?t:void 0,isGlobalFile:!0});return}Z.openFile({name:e.name,path:e.path},{sessionId:l,sandboxId:null!=(n=null!=s?s:K)?n:void 0})};(0,r.useCallback)(async(e,t,n)=>{var s;let a=null!=(s=e.split("/").pop())?s:e,r=ew(e);if(r!==ew(t))return void X.oR.error("Cannot move files between memory and workspace");let i=X.oR.loading("Moving ".concat(a,"…"));try{if(r){let s=ey(l,e),r="".concat(ey(l,t),"/").concat(a);await em.files.moveGlobalFile(s,r,"directory"===n?"folder":"file"),tP()}else{let s=t?"".concat(t,"/").concat(a):a;await em.files.moveFile(l,e,s,"directory"===n?"folder":"file")}X.oR.success("Moved ".concat(a),{id:i}),ty()}catch(e){X.oR.error("Failed to move ".concat(a),{id:i})}},[l,ty,tP]);let tX=(0,r.useCallback)(async(e,t,n)=>{let s=e.includes("/")?e.substring(0,e.lastIndexOf("/")):"",a=s?"".concat(s,"/").concat(t):t,r=X.oR.loading("Renaming to ".concat(t,"…"));try{if(ew(e)){let t=ey(l,e),s=ey(l,a);await em.files.moveGlobalFile(t,s,"directory"===n?"folder":"file"),tP()}else await em.files.moveFile(l,e,a,"directory"===n?"folder":"file");return X.oR.success("Renamed to ".concat(t),{id:r}),ty(),!0}catch(e){return X.oR.error("Failed to rename",{id:r}),!1}},[l,ty,tP]),tQ=(0,r.useCallback)(async(e,t)=>{let n=X.oR.loading("Downloading ".concat(t,"…"));try{if(ew(e)){let n=ey(l,e);await (0,$.sN)({filePath:n,fileName:t,publicSessionId:p?l:void 0,restrictGeneratedMedia:_})}else await (0,$.Fq)({sessionId:l,filePath:e,fileName:t,readOnly:p,restrictGeneratedMedia:_,snapshotId:L});X.oR.success("Downloaded ".concat(t),{id:n})}catch(e){if((0,ex.xl)(e))return void(e.upgradeOpened?X.oR.dismiss(n):X.oR.error("Generated media cannot be downloaded from this shared link",{id:n}));X.oR.error("Failed to download ".concat(t),{id:n})}},[l,p,_,L]),tV=(0,r.useCallback)(async(e,t)=>{let n=X.oR.loading("Sharing ".concat(t,"…"));try{let{fileShare:s}=await q.j.createFileShare({sessionId:l,filePath:e}),a="".concat(window.location.origin,"/share/files/").concat(s.id);await navigator.clipboard.writeText(a),X.oR.success("Link copied! ".concat(t),{id:n})}catch(e){if((0,ex.xl)(e))return void X.oR.dismiss(n);X.oR.error("Failed to share ".concat(t),{id:n})}},[l]),tK=(0,r.useCallback)(async(e,t)=>{if(ew(e)){let n=e.startsWith("/")?e.slice(1):e,s=X.oR.loading('Downloading "'.concat(t,'"…'));try{let a=p?tz.filter(e=>"directory"!==e.type&&ew(e.path)&&(e.path===n||e.path.startsWith("".concat(n,"/")))).map(e=>({globalPath:ey(l,e.path),name:e.name})):(await em.files.getGlobalFiles(ey(l,e),!0)).files.filter(e=>"file"===e.type).map(e=>({globalPath:e.path,name:e.name}));if(0===a.length)return void X.oR.error("No files in folder",{id:s});for(let e of a)await (0,$.sN)({filePath:e.globalPath,fileName:e.name,publicSessionId:p?l:void 0,restrictGeneratedMedia:_});X.oR.success("Downloaded ".concat(a.length," file(s) from ").concat(t),{id:s})}catch(e){if((0,ex.xl)(e))return void(e.upgradeOpened?X.oR.dismiss(s):X.oR.error("Generated media cannot be downloaded from this shared link",{id:s}));X.oR.error("Failed to download ".concat(t),{id:s})}return}let n=X.oR.loading('Downloading "'.concat(t,'" as zip…'));try{await (0,$.XY)({sessionId:l,folderPath:e,folderName:t,readOnly:p,restrictGeneratedMedia:_}),X.oR.success("Downloaded ".concat(t,".zip"),{id:n})}catch(e){if((0,ex.xl)(e))return void(e.upgradeOpened?X.oR.dismiss(n):X.oR.error("Generated media cannot be downloaded from this shared link",{id:n}));X.oR.error("Failed to download ".concat(t),{id:n})}},[l,p,tz,_]),tY=(0,r.useCallback)(e=>{B((0,M.closeFloatingWindow)(e))},[B]),tJ=(0,r.useCallback)(e=>{eO(t=>t.filter(t=>t.path!==e)),ei===e_(e)&&eo(eg)},[ei]),tZ=(0,r.useCallback)(e=>{if(ew(e)){let t=ey(l,e),n=document.createElement("input");n.type="file",n.multiple=!0,n.onchange=async e=>{let n=e.target.files;
1if(!n||0===n.length)return;let l=Array.from(n).filter(e=>![".DS_Store","Thumbs.db"].includes(e.name));if(0===l.length)return;let s=X.oR.loading("Uploading ".concat(l.length," file(s)…"));try{await em.files.uploadGlobalFiles(l,t),X.oR.success("Uploaded ".concat(l.length," file(s)"),{id:s}),tP()}catch(e){X.oR.error("Failed to upload files",{id:s})}},n.click()}else null==u||u(e)},[l,u,tP]),t0=(0,r.useCallback)(e=>{if(ew(e)){let t=ey(l,e),n=document.createElement("input");n.type="file",n.webkitdirectory=!0,n.multiple=!0,n.onchange=async e=>{var n,l;let s=e.target.files;if(!s||0===s.length)return;let a=Array.from(s).filter(e=>![".DS_Store","Thumbs.db"].includes(e.name));if(0===a.length)return;let r=(null==(l=a[0])||null==(n=l.webkitRelativePath)?void 0:n.split("/")[0])||"Folder",i=X.oR.loading('Uploading folder "'.concat(r,'"…'));try{let e=new Map;for(let t of a){let n=(t.webkitRelativePath||t.name).split("/");n.pop();let l=n.join("/");e.has(l)||e.set(l,[]),e.get(l).push(t)}let n=Array.from(e.entries()).map(e=>{let[n,l]=e,s="".concat(t,"/").concat(n);return()=>em.files.uploadGlobalFiles(l,s)});await (0,I.P)(n,I.f),X.oR.success('Uploaded folder "'.concat(r,'"'),{id:i}),tP()}catch(e){X.oR.error('Failed to upload folder "'.concat(r,'"'),{id:i})}},n.click()}else null==h||h(e)},[l,h,tP]),t1=(0,r.useCallback)(async(e,t)=>{if(ew(e)){let n=ey(l,e),s=X.oR.loading('Deleting "'.concat(t,'"…'));try{await em.files.deleteGlobalFile(n,"file"),X.oR.success("Deleted ".concat(t),{id:s}),tP()}catch(e){X.oR.error("Failed to delete ".concat(t),{id:s})}}else null==m||m(e,t)},[l,m,tP]),t5=(0,r.useCallback)(async(e,t)=>{if(ew(e)){let n=ey(l,e),s=X.oR.loading('Deleting "'.concat(t,'"…'));try{await em.files.deleteGlobalFile(n,"folder"),X.oR.success("Deleted ".concat(t),{id:s}),tP()}catch(e){X.oR.error("Failed to delete ".concat(t),{id:s})}}else null==f||f(e,t)},[l,f,tP]),t3=(0,r.useCallback)(()=>{!tv&&(ty(),p||tP())},[tv,ty,p,tP]),t2=(0,r.useRef)(null),[t4,t6]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=t2.current;if(!e)return;let t=new ResizeObserver(e=>{let[t]=e;return t6(t.contentRect.width)});return t.observe(e),t6(e.getBoundingClientRect().width),()=>t.disconnect()},[]);let[t8,t7]=(0,r.useState)("system-ui, sans-serif"),[t9,ne]=(0,r.useState)(0);(0,r.useEffect)(()=>{var e;let t=t2.current&&getComputedStyle(t2.current).fontFamily;if(!t)return;t7(t);let n=!1;return null==(e=document.fonts)||e.ready.then(()=>{n||ne(e=>e+1)}),()=>{n=!0}},[]);let nt="400 14px ".concat(t8),nn="500 12px ".concat(t8),nl=(0,r.useMemo)(()=>{let e=[...tn.map(e=>{let t="vnc-preview"===e.type?"Browser":"app-console"===e.type?"Website":e.fileName||e.type.charAt(0).toUpperCase()+e.type.slice(1);return{id:e.id,icon:function(e){if(e.fileName&&eA.has(e.type)){var t;return eR({name:e.fileName,path:null!=(t=e.filePath)?t:e.fileName,size:0,mimetype:"",type:"file"})}switch(e.type){case"canvas":case"image":return(0,a.jsx)(x.A,{className:eS});case"video":return(0,a.jsx)(g.A,{className:eS});case"vnc-preview":case"url-preview":return(0,a.jsx)(v.A,{className:eS});case"terminal":return(0,a.jsx)(b.A,{className:eS});case"app-console":return(0,a.jsx)(w.A,{className:eS});default:return(0,a.jsx)(y.A,{className:eS})}}(e),title:t,label:e.fileName?eP(t):t,isFile:!!e.fileName,shared:!!e.filePath&&!!(null==el?void 0:el.has(eN(l,e.filePath))),onClose:()=>tY(e.id)}}),...eT.map(e=>({id:e_(e.path),icon:eR(e),title:e.name,label:eP(e.name),isFile:!0,shared:!1,onClose:()=>tJ(e.path)}))];if(0===eW.length)return e;let t=new Map(eW.map((e,t)=>[e,t]));return e.map((e,n)=>{var l;return{tab:e,rank:null!=(l=t.get(e.id))?l:eW.length+n}}).sort((e,t)=>e.rank-t.rank).map(e=>e.tab)},[tn,eT,eW,tY,tJ,el,l]),ns=(0,i.FR)((0,i.MS)(i.AN,{activationConstraint:{distance:5}})),na=(0,r.useCallback)(e=>{let{active:t,over:n}=e;if(!n||t.id===n.id)return;let l=nl.map(e=>e.id),s=l.indexOf(String(t.id)),a=l.indexOf(String(n.id));s<0||a<0||eQ((0,o.be)(l,s,a))},[nl]),nr=(0,r.useMemo)(()=>nl.map(e=>(function(e,t,n){let l=Math.min(Math.ceil(eG(e,t))+1,124),s=36+20*!!n,a=s+l;return{full:a,floor:Math.min(a,s+60)}})(e.label,nt,e.shared)),[nl,nt,t9]),ni=(0,r.useRef)(new Set),{visibleTabs:no,hiddenTabs:nc,tabFloors:nd}=(0,r.useMemo)(()=>{let e=nl.findIndex(e=>e.id===ei),t=new Set;nl.forEach((e,n)=>{ni.current.has(e.id)&&t.add(n)});let n=function(e,t,n,l,s){let a=new Set(t.map((e,t)=>t)),r=t.length;if(!e||0===r||t.reduce((e,t)=>
1e+t,0)+(r-1)*2<=e)return a;let i=eB(1,l),o=e$(e-i-2,t,n,s);for(let a=0;a<2;a++){let a=eB(r-o.size,l);if(a<=i)break;o=e$(e-(i=a)-2,t,n,s)}return o}(t4,nr.map(e=>e.full),e,nn,t),l=nl.filter((e,t)=>n.has(t));return ni.current=new Set(l.map(e=>e.id)),{visibleTabs:l,hiddenTabs:nl.filter((e,t)=>!n.has(t)),tabFloors:new Map(nl.map((e,t)=>{var n,l;return[e.id,null!=(l=null==(n=nr[t])?void 0:n.floor)?l:0]}))}},[nl,ei,t4,nr,nn,t9]),nu=ei===eg||ei===ev?null:null!=(n=tn.find(e=>e.id===ei))?n:null,nh=e5?e2.current:void 0,nm=d&&nu,nf=!p&&(u||h)?(0,a.jsxs)(Q.rI,{children:[(0,a.jsx)(G.C,{label:"Upload",container:nh,children:(0,a.jsx)(Q.ty,{asChild:!0,children:(0,a.jsx)("button",{className:"w-6 h-6 flex items-center justify-center rounded-sm [&_svg]:size-3 text-muted-foreground hover:text-foreground hover:bg-sidebar-item-hover transition-colors",children:(0,a.jsx)(j.A,{})})})}),(0,a.jsxs)(Q.SQ,{align:"end",className:"w-44 rounded-xl",container:e5?e2.current:void 0,children:[u&&(0,a.jsxs)(Q._2,{onClick:()=>u("/"),children:[(0,a.jsx)(y.A,{className:"w-3.5 h-3.5"}),"Upload files"]}),h&&(0,a.jsxs)(Q._2,{onClick:()=>
1h("/"),children:[(0,a.jsx)(N.A,{className:"w-3.5 h-3.5"}),"Upload folder"]})]})]}):null,np=(0,a.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[(0,a.jsxs)("div",{className:"pl-3 pr-1 h-8 flex items-center justify-between shrink-0",children:[(0,a.jsx)("span",{className:"text-xs font-semibold text-muted-foreground/60 select-none",children:"Explorer"}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[!tv&&(0,a.jsx)(ep.K,{title:"Refresh files",onClick:t3,disabled:tC,compact:!0,container:nh,children:(0,a.jsx)(k.A,{className:tC?"animate-spin":void 0})}),nf]})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,a.jsx)(er,{sessionFiles:tz,onFileClick:t$,onFileOpenInTab:tH,activeFilePath:null!=ed?ed:void 0,isLoading:tM,onRenameFile:p?void 0:tX,onDeleteFile:p?void 0:t1,onDeleteFolder:p?void 0:t5,onDownloadFile:tQ,onDownloadFolder:tK,onUploadFiles:p?void 0:tZ,onUploadFolder:p?void 0:t0,onShareFile:p?void 0:tV,readOnly:p,externalExpandedPaths:eV,onExpandedPathsChange:eK,sharedFiles:p?void 0:el,onCreateShare:p?void 0:es,onDeleteShare:p?void 0:ea,loadedPaths:tN,onLoadDirectory:tv?void 0:tj,portalContainer:e5?e2.current:null})})]});return(0,a.jsxs)("div",{ref:e2,className:"flex flex-col h-full w-full overflow-hidden bg-background",children:[e0&&(0,a.jsx)("div",{className:"fixed inset-0 z-100000 cursor-col-resize",style:{pointerEvents:"auto"},"aria-hidden":"true"}),(0,a.jsxs)("div",{className:"h-10 shrink-0 border-b border-border flex items-center gap-2 px-2 bg-background",children:[(0,a.jsx)(eH,{pinned:!0,active:ei===eg,onClick:async()=>{let e=t_();await tO(e),tq(e),eo(eg)},icon:(0,a.jsx)(C.A,{className:"w-3.5 h-3.5 shrink-0"}),title:"Explorer",iconOnly:!0,container:nh}),(0,a.jsx)("div",{className:"h-4 w-px shrink-0 bg-border","aria-hidden":"true"}),(0,a.jsxs)("div",{ref:t2,className:"flex items-center gap-0.5 flex-1 min-w-0 overflow-hidden",children:[(0,a.jsx)(i.Mp,{sensors:ns,collisionDetection:i.fp,modifiers:[eq],onDragEnd:na,children:(0,a.jsx)(o.gB,{items:no.map(e=>e.id),strategy:o.m$,children:no.map(e=>(0,a.jsx)(eX,{tab:e,active:ei===e.id,onClick:()=>tU(e.id),container:nh,minWidth:nd.get(e.id)},e.id))})}),nc.length>0&&(0,a.jsxs)(Q.rI,{children:[(0,a.jsx)(G.C,{label:"".concat(nc.length," more open ").concat(1===nc.length?"file":"files"),container:nh,children:(0,a.jsx)(Q.ty,{asChild:!0,children:(0,a.jsxs)("button",{type:"button",className:"h-7 shrink-0 flex items-center gap-0.5 rounded-md px-1.5 text-xs font-medium text-muted-foreground hover:bg-sidebar-item-hover hover:text-foreground transition-colors focus-visible:outline-none",children:[(0,a.jsx)(S.A,{className:"w-3.5 h-3.5 [stroke-width:1.5]"}),nc.length]})})}),(0,a.jsx)(Q.SQ,{align:"end",className:"w-64 rounded-xl",container:e5?e2.current:void 0,children:nc.map(e=>(0,a.jsxs)(Q._2,{onClick:()=>tU(e.id),className:"group gap-2 text-muted-foreground focus:text-foreground",children:[(0,a.jsx)("span",{className:"flex shrink-0 items-center",children:e.icon}),(0,a.jsx)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:e.isFile?(0,a.jsx)(Y,{name:e.title,className:"gap-1.5",trailing:e.shared?eF:null}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"min-w-0 truncate",children:e.title}),e.shared&&eF]})}),(0,a.jsx)("span",{role:"button","aria-label":"Close ".concat(e.title),onPointerDown:e=>e.stopPropagation(),onPointerUp:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),e.onClose()},className:"shrink-0 cursor-pointer rounded-full p-1 opacity-0 transition group-data-[highlighted]:opacity-100 hover:bg-foreground
1/10 hover:text-foreground",children:(0,a.jsx)(F.A,{className:"w-3.5 h-3.5"})})]},e.id))})]})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[nm&&(0,a.jsx)(ep.K,{title:"Refresh",onClick:()=>null==d?void 0:d(nu.id),container:nh,children:(0,a.jsx)(k.A,{className:"w-3.5 h-3.5"})}),(0,a.jsx)(ep.K,{title:e5?"Exit fullscreen":"Fullscreen",onClick:tt,container:nh,children:e5?(0,a.jsx)(R.A,{className:"w-3.5 h-3.5"}):(0,a.jsx)(A.A,{className:"w-3.5 h-3.5"})}),(()=>{var e;let t=ei===eg?eb.length>0?ed:null:null==nu?void 0:nu.filePath;if(!t)return null;let n=null!=(e=ej(l,t))?e:t,r=n.split("/").pop()||n,i=eN(l,t),o=ei!==eg&&!!nu,c=!p&&!L&&!n.startsWith("/home/"),d=!p&&!!el;return(0,a.jsx)(eC,{fileName:r,sharePath:i,share:(null==el?void 0:el.get(i))||null,onCreateShare:d?es:void 0,onDeleteShare:d?ea:void 0,onRename:c?e=>{(async()=>{if(!await tX(n,e,"file"))return;let t=n.includes("/")?n.slice(0,n.lastIndexOf("/")):"",a=t?"".concat(t,"/").concat(e):e;if(o){var r;tY(nu.id),Z.openFile({name:e,path:e
1w(a)?ey(l,a):a},{sessionId:l,sandboxId:null!=(r=null!=s?s:K)?r:void 0,isGlobalFile:ew(a)})}else ef(a)})()}:void 0,onDownload:()=>void tQ(n,r),onDelete:c?()=>{t1(n,r),o?tY(nu.id):ef(null)}:void 0,container:e5?e2.current:null})})()]})]}),(0,a.jsxs)("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[(0,a.jsxs)("div",{className:(0,I.cn)("absolute inset-0 flex",ei!==eg&&"hidden"),children:[(0,a.jsx)("div",{className:"shrink-0 overflow-hidden",style:{width:eJ},children:np}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden relative",children:[(0,a.jsx)("div",{className:"absolute inset-y-0 left-0 w-3 z-10 cursor-col-resize group",onMouseDown:te,children:(0,a.jsx)("div",{className:"absolute inset-y-0 left-0 w-px bg-border group-hover:w-[3px] group-hover:bg-blue-400 transition-all"})}),eb.length>0?eb.map(e=>(0,a.jsx)("div",{className:(0,I.cn)("absolute inset-0 overflow-hidden",!eU(ed,e.path)&&"hidden"),children:(0,a.jsx)(eu,{sessionId:l,file:e,readOnly:p,snapshotId:L,isGlobalFile:ew(e.path),globalFilePath:ew(e.path)?ey(l,e.path):void 0,watermarkGeneratedMedia:_})},e.path)):(0,a.jsxs)("div",{className:"h-full flex flex-col items-center justify-center select-none gap-3 px-8 pb-16",children:[(0,a.jsx)(P.A,{className:"w-8 h-8 text-zinc-300 dark:text-zinc-600",strokeWidth:1.5}),(0,a.jsx)("span",{className:"text-sm text-muted-foreground/60 text-center",children:"Select a file from Explorer to preview"})]})]})]}),tn.map(e=>(0,a.jsx)("div",{className:(0,I.cn)("absolute inset-0 overflow-hidden",ei!==e.id&&"hidden"),children:c(e.id)},e.id)),eT.map(e=>(0,a.jsx)("div",{className:(0,I.cn)("absolute inset-0 overflow-hidden",ei!=="snapshot-tab:".concat(e.path)&&"hidden"),children:(0,a.jsx)(eu,{sessionId:l,file:e,readOnly:!0,snapshotId:L,watermarkGeneratedMedia:_})},"snapshot-tab:".concat(e.path)))]})]})}function eG(e,t){return(void 0===s&&(s="undefined"==typeof document?null:document.createElement("canvas").getContext("2d")),s)?(s.font=t,s.measureText(e).width):7*e.length}function eB(e,t){return 28+Math.ceil(eG(String(e),t))+1}function e$(e,t,n,l){let s=new Set,a=0,r=n=>{if(s.has(n))return;let l=a+2*(s.size>0)+t[n];l>e||(s.add(n),a=l)};n>=0&&n<t.length&&(s.add(n),a=t[n]);for(let e=0;e<t.length;e++)l.has(e)&&r(e);for(let e=0;e<t.length;e++)r(e);return 0===s.size&&s.add(0),s}let eq=e=>{let{transform:t}=e;return{...t,y:0}};function eH(e){let{active:t,onClick:n,icon:l,title:s,label:r,minWidth:i,onClose:o,container:c,shared:d=!1,pinned:u=!1,iconOnly:h=!1,dragging:m=!1,dragRef:f,dragStyle:p,dragProps:x}=e;return(0,a.jsx)(G.C,{label:s,container:c,children:(0,a.jsxs)("button",{type:"button",ref:f,"aria-label":h?s:void 0,style:{...p,minWidth:i},...x,onClick:n,className:(0,I.cn)("group relative flex h-7 items-center gap-1.5 overflow-hidden rounded-md px-2 text-sm font-normal transition-colors select-none [&_svg]:[stroke-width:1.5]",u?"shrink-0":"flex-initial min-w-9",h&&"w-7 justify-center px-0",m?"bg-sidebar-item-hover text-foreground transition-none":t?"bg-sidebar-item-active text-foreground":"text-muted-foreground hover:bg-sidebar-item-hover hover:text-foreground"),children:[(0,a.jsxs)("span",{className:"relative flex size-3.5 shrink-0 items-center justify-center",children:[(0,a.jsx)("span",{className:(0,I.cn)("flex items-center transition-opacity",o&&"group-hover:opacity-0"),children:l}),o&&(0,a.jsx)("span",{role:"button","aria-label":"Close ".concat(s),onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),o()},className:"absolute -inset-1 flex cursor-pointer items-center justify-center rounded-full opacity-0 transition group-hover:opacity-100 hover:bg-foreground
1/10",children:(0,a.jsx)(F.A,{className:"size-3.5 shrink-0"})})]}),!h&&(0,a.jsx)("span",{className:"min-w-0 max-w-31 truncate text-left",children:null!=r?r:s}),d&&!h&&eF]})})}function eX(e){let{tab:t,active:n,onClick:l,container:s,minWidth:r}=e,{attributes:i,listeners:d,setNodeRef:u,transform:h,transition:m,isDragging:f}=(0,o.gl)({id:t.id});return(0,a.jsx)(eH,{active:n,onClick:l,icon:t.icon,title:t.title,label:t.label,shared:t.shared,minWidth:r,container:s,onClose:t.onClose,dragging:f,dragRef:u,dragStyle:{transform:c.Ks.Translate.toString(h),transition:m,zIndex:f?1:void 0},dragProps:{...i,...d,onPointerDown:e=>{var t;l(),null==d||null==(t=d.onPointerDown)||t.call(d,e)}}})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.