@principal-ade/panel-layouts 0.3.1 → 0.3.3
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.
- package/dist/index.d.ts +98 -1
- package/dist/index.esm.js +960 -669
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";require('./index.css');var we=Object.defineProperty;var Te=(s,e,t)=>e in s?we(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var V=(s,e,t)=>Te(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const J=require("@principal-ade/panels"),r=require("react"),o=require("react/jsx-runtime"),O=require("@principal-ade/industry-theme");class ce{constructor(){V(this,"storageKey","panel-layouts")}async load(e){try{const t=localStorage.getItem(`${this.storageKey}:${e}`);return t?JSON.parse(t):null}catch(t){return console.error(`Failed to load panel layout for ${e}:`,t),null}}async save(e,t){try{localStorage.setItem(`${this.storageKey}:${e}`,JSON.stringify(t))}catch(a){console.error(`Failed to save panel layout for ${e}:`,a)}}}function je(s){const{viewKey:e,defaultSizes:t,panelType:a,adapter:n=new ce}=s,[l,i]=r.useState(t),[d,h]=r.useState(s.collapsed),p=r.useRef(s.collapsed),w=r.useRef({}),u=r.useRef(null),f=r.useRef(null);r.useEffect(()=>{(async()=>{const b=await n.load(e);b!=null&&b.sizes&&(i(b.sizes),x(b.sizes))})()},[e]);const x=r.useCallback(y=>{"left"in y&&y.left>0&&(w.current.left=y.left),"middle"in y&&y.middle>0&&(w.current.middle=y.middle),"right"in y&&y.right>0&&(w.current.right=y.right)},[]),m=r.useCallback(y=>{const b=w.current[y];if(b&&b>0)return b;if(y==="left"&&"left"in t&&t.left>0)return t.left;if(y==="right"&&"right"in t&&t.right>0)return t.right},[t]),c=r.useRef(t);r.useEffect(()=>{("left"in t&&t.left!==c.current.left||"middle"in t&&"middle"in c.current&&t.middle!==c.current.middle||"right"in t&&t.right!==c.current.right)&&(i(t),x(t),c.current=t)},[t,x]),r.useEffect(()=>{const y=s.collapsed.left!==p.current.left,b="right"in s.collapsed&&"right"in p.current&&s.collapsed.right!==p.current.right;(y||b)&&(h(s.collapsed),p.current={...s.collapsed})},[s.collapsed.left,s.collapsed.right]);const g=r.useCallback(async y=>{try{await n.save(e,{sizes:y})}catch(b){console.error(`Failed to save panel preferences for ${e}:`,b)}},[e,n]),S=r.useCallback(y=>{const b={...y};let T=!0;if("left"in y){const j=!!(d!=null&&d.left),P=y.left;if(j){const v=m("left");v!==void 0&&v>0?b.left=v:T=!1}else P===0&&(T=!1)}if(a==="three-panel"&&"right"in y){const j=!!(d!=null&&d.right),P=y.right;if(j){const v=m("right");v!==void 0&&v>0?b.right=v:T=!1}else P===0&&(T=!1)}if(i(b),x(b),u.current&&(clearTimeout(u.current),u.current=null),!T){f.current=null;return}f.current=b,u.current=setTimeout(()=>{const j=f.current;j&&(g(j),f.current=null),u.current=null},500)},[d,m,a,g,x]);r.useEffect(()=>()=>{if(u.current){const y=f.current;y&&(g(y),f.current=null),clearTimeout(u.current),u.current=null}},[g]);const R=r.useCallback(async()=>{},[]),I=r.useCallback(async()=>{},[]),C=r.useCallback(async()=>{},[]),z=r.useCallback(async()=>{},[]);return a==="three-panel"?{type:"three-panel",sizes:l,collapsed:d,handlePanelResize:S,handleLeftCollapseComplete:R,handleLeftExpandComplete:I,handleRightCollapseComplete:C,handleRightExpandComplete:z}:{type:"two-panel",sizes:l,collapsed:d,handlePanelResize:S,handleLeftCollapseComplete:R,handleLeftExpandComplete:I}}class pe{constructor(){V(this,"PRESETS_KEY","panel-layouts:workspace-presets");V(this,"REPO_STATE_PREFIX","panel-layouts:repo-state:")}async loadWorkspacePresets(){try{const e=localStorage.getItem(this.PRESETS_KEY);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to load workspace presets:",e),{}}}async saveWorkspacePresets(e){try{localStorage.setItem(this.PRESETS_KEY,JSON.stringify(e))}catch(t){throw console.error("Failed to save workspace presets:",t),t}}async loadRepositoryState(e){try{const t=`${this.REPO_STATE_PREFIX}${e}`,a=localStorage.getItem(t);return a?JSON.parse(a):null}catch(t){return console.error(`Failed to load repository state for ${e}:`,t),null}}async saveRepositoryState(e,t){try{const a=`${this.REPO_STATE_PREFIX}${e}`;localStorage.setItem(a,JSON.stringify(t))}catch(a){throw console.error(`Failed to save repository state for ${e}:`,a),a}}async loadAllRepositoryStates(){try{const e={};for(let t=0;t<localStorage.length;t++){const a=localStorage.key(t);if(a&&a.startsWith(this.REPO_STATE_PREFIX)){const n=a.substring(this.REPO_STATE_PREFIX.length),l=localStorage.getItem(a);if(l)try{e[n]=JSON.parse(l)}catch(i){console.error(`Failed to parse repository state for ${n}:`,i)}}}return e}catch(e){return console.error("Failed to load all repository states:",e),{}}}}class W{static setAdapter(e){this.adapter=e}static async getWorkspaceLayouts(){const e=this.getBuiltInWorkspaceLayouts();return{...await this.adapter.loadWorkspacePresets(),...e}}static async getWorkspaceLayout(e){return(await this.getWorkspaceLayouts())[e]||null}static async createWorkspaceLayout(e){const t=await this.adapter.loadWorkspacePresets(),a=this.generateWorkspaceId(e.name),n={id:a,name:e.name,description:e.description,layout:e.layout,defaultSizes:e.defaultSizes,defaultCollapsed:e.defaultCollapsed,createdAt:Date.now(),updatedAt:Date.now(),isBuiltIn:!1},l={...t,[a]:n};return await this.adapter.saveWorkspacePresets(l),n}static async updateWorkspaceLayout(e,t){const a=await this.adapter.loadWorkspacePresets(),n=a[e];if(!n)return console.error(`Workspace layout ${e} not found`),null;if(n.isBuiltIn)return console.error(`Cannot update built-in workspace layout ${e}`),null;const l={...n,...t,id:e,createdAt:n.createdAt,updatedAt:Date.now()},i={...a,[e]:l};return await this.adapter.saveWorkspacePresets(i),l}static async deleteWorkspaceLayout(e){const t=await this.adapter.loadWorkspacePresets(),a=t[e];if(!a)return console.error(`Workspace layout ${e} not found`),!1;if(a.isBuiltIn)return console.error(`Cannot delete built-in workspace layout ${e}`),!1;const n={...t};return delete n[e],await this.adapter.saveWorkspacePresets(n),!0}static async getRepositoryState(e){return await this.adapter.loadRepositoryState(e)}static async setRepositoryState(e,t){await this.adapter.saveRepositoryState(e,t)}static async updateRepositorySizes(e,t){const a=await this.getRepositoryState(e);a&&await this.setRepositoryState(e,{...a,sizes:t})}static async updateRepositoryCollapsed(e,t){const a=await this.getRepositoryState(e);a&&await this.setRepositoryState(e,{...a,collapsed:t})}static hasStateDeviation(e,t){const a=t.defaultSizes?JSON.stringify(e.sizes)!==JSON.stringify(t.defaultSizes):!1,n=t.defaultCollapsed?JSON.stringify(e.collapsed)!==JSON.stringify(t.defaultCollapsed):!1;return{hasSizeDeviation:a,hasCollapsedDeviation:n}}static async updateWorkspaceFromRepositoryState(e,t){const a=await this.getWorkspaceLayout(e),n=await this.getRepositoryState(t);if(!a||!n||a.isBuiltIn){console.error("Cannot update built-in workspace or workspace/state not found");return}await this.updateWorkspaceLayout(e,{defaultSizes:n.sizes,defaultCollapsed:n.collapsed})}static async resetRepositoryToWorkspaceDefaults(e,t){const a=await this.getWorkspaceLayout(t);if(!a){console.error(`Workspace ${t} not found`);return}const n=await this.getRepositoryState(e);n&&await this.setRepositoryState(e,{...n,sizes:a.defaultSizes||{left:20,middle:45,right:35},collapsed:a.defaultCollapsed||{left:!1,right:!1}})}static isLayoutMatchingWorkspace(e,t){return this.areLayoutsEqual(e,t.layout)}static async findMatchingWorkspace(e){const t=await this.getWorkspaceLayouts();for(const[a,n]of Object.entries(t))if(this.isLayoutMatchingWorkspace(e,n))return a;return null}static areLayoutsEqual(e,t){return JSON.stringify(e)===JSON.stringify(t)}static generateWorkspaceId(e){return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-${Date.now()}`}static getBuiltInWorkspaceLayouts(){const e=Date.now();return{"project-management":{id:"project-management",name:"Project Management",description:"Tasks, dependencies, issues, file tree, docs, drawings, multi terminal, city visualization, code viewer, markdown slides, and excalidraw",layout:{left:{type:"tabs",panels:["tasks","dependencies","gitIssues","fileTree","docs","drawings"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"multiTerminal",right:{type:"tabs",panels:["cityVisualization","codeViewer","markdownViewer","excalidrawDiagram"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:45,right:35},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0},"code-review":{id:"code-review",name:"Code Review",description:"Git changes, pull requests, and file tree on left, git diff and code viewer in middle, city map on right",layout:{left:{type:"tabs",panels:["gitChanges","gitPullRequests","fileTree"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:{type:"tabs",panels:["gitDiff","codeViewer"],config:{defaultActiveTab:0,tabPosition:"top"}},right:"cityVisualization"},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0},documentation:{id:"documentation",name:"Documentation",description:"Docs, markdown viewer, and code viewer",layout:{left:"docs",middle:"markdownViewer",right:"codeViewer"},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},"agent-work":{id:"agent-work",name:"Agent Work",description:"Tasks, agent sessions, file tree, agent context, git changes, docs, multi terminal, city map, agent events, code viewer, and markdown slides",layout:{left:{type:"tabs",panels:["tasks","agentSessions","fileTree","agentContext","gitChanges","docs"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"multiTerminal",right:{type:"tabs",panels:["cityVisualization","agentEvents","codeViewer","markdownViewer"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:45,right:35},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0},"quality-check":{id:"quality-check",name:"Quality Check",description:"Package information, tools, and dependencies on left; city visualization map in middle; multi terminal and code viewer on right (collapsed)",layout:{left:{type:"tabs",panels:["packageInfo","tools","dependencies"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"cityVisualization",right:{type:"tabs",panels:["multiTerminal","codeViewer"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:45,right:35},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},drawing:{id:"drawing",name:"Drawing",description:"Drawings and docs, excalidraw diagram, multi terminal and markdown viewer",layout:{left:{type:"tabs",panels:["drawings","docs"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"excalidrawDiagram",right:{type:"tabs",panels:["multiTerminal","markdownViewer"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},"old-school":{id:"old-school",name:"Old School",description:"File tree, search, git changes, and docs on left; code viewer and markdown viewer in middle; multi terminal and city map on right (collapsed)",layout:{left:{type:"tabs",panels:["fileTree","search","gitChanges","docs"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:{type:"tabs",panels:["codeViewer","markdownViewer"],config:{defaultActiveTab:0,tabPosition:"top"}},right:{type:"tabs",panels:["multiTerminal","cityVisualization"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},"principal-office":{id:"principal-office",name:"Principal Office",description:"Alexandria docs on left, MDX editor in middle, multi terminal on right",layout:{left:"docs",middle:"mdxEditor",right:"multiTerminal"},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0}}}static async initializeWorkspaceLayouts(){const e=await this.adapter.loadWorkspacePresets();Object.keys(e).length}}V(W,"adapter",new pe);function Se(s={}){const{repositoryKey:e,autoInitialize:t=!1,defaultWorkspaceId:a}=s,[n,l]=r.useState({}),[i,d]=r.useState(null),[h,p]=r.useState(null),[w,u]=r.useState(!0),[f,x]=r.useState(null),m=r.useCallback(async()=>{try{u(!0),x(null);const T=await W.getWorkspaceLayouts();if(l(T),e){let j=await W.getRepositoryState(e);if(!j&&t){const P=a||"project-management",v=await W.getWorkspaceLayout(P);v&&(j={workspaceId:P,sizes:v.defaultSizes||{left:20,middle:45,right:35},collapsed:v.defaultCollapsed||{left:!1,right:!1}},await W.setRepositoryState(e,j))}if(d(j),j!=null&&j.workspaceId){const P=await W.getWorkspaceLayout(j.workspaceId);p(P)}else p(null)}}catch(T){x(T),console.error("Failed to load workspace data:",T)}finally{u(!1)}},[e,t,a]);r.useEffect(()=>{m()},[m]);const c=r.useCallback(async T=>await W.getWorkspaceLayout(T),[]),g=r.useCallback(async T=>{const j=await W.createWorkspaceLayout(T);return await m(),j},[m]),S=r.useCallback(async(T,j)=>{const P=await W.updateWorkspaceLayout(T,j);return await m(),P},[m]),R=r.useCallback(async T=>{const j=await W.deleteWorkspaceLayout(T);return j&&await m(),j},[m]),I=r.useCallback(async T=>{if(!e){console.error("Cannot apply workspace without repositoryKey");return}const j=await W.getWorkspaceLayout(T);if(!j){console.error(`Workspace ${T} not found`);return}const P={workspaceId:T,sizes:j.defaultSizes||{left:20,middle:45,right:35},collapsed:j.defaultCollapsed||{left:!1,right:!1}};await W.setRepositoryState(e,P),await m()},[e,m]),C=r.useCallback(async T=>{if(!e){console.error("Cannot update sizes without repositoryKey");return}await W.updateRepositorySizes(e,T),await m()},[e,m]),z=r.useCallback(async T=>{if(!e){console.error("Cannot update collapsed without repositoryKey");return}await W.updateRepositoryCollapsed(e,T),await m()},[e,m]),y=r.useCallback(async()=>{if(!e||!(i!=null&&i.workspaceId)){console.error("Cannot reset without repositoryKey and active workspace");return}await W.resetRepositoryToWorkspaceDefaults(e,i.workspaceId),await m()},[e,i==null?void 0:i.workspaceId,m]),b=r.useCallback(async()=>{await m()},[m]);return{workspaces:n,repositoryState:i,activeWorkspace:h,loading:w,error:f,getWorkspace:c,createWorkspace:g,updateWorkspace:S,deleteWorkspace:R,applyWorkspace:I,updateSizes:C,updateCollapsed:z,resetToDefaults:y,refresh:b}}function Ce(s={}){const{initialFocus:e=null,collapsed:t={},panelType:a="three-panel",onFocusChange:n,events:l,getPanelId:i}=s,[d,h]=r.useState(e),p=r.useCallback(c=>{const g=d;if(h(c),n==null||n(c),l&&i){if(g){const R=i(g);R&&l.emit({type:"panel:blur",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:R,panelSlot:g,nextPanelId:i(c)}})}const S=i(c);S&&l.emit({type:"panel:focus",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:S,panelSlot:c,source:"keyboard-shortcut"}})}},[d,n,l,i]),w=r.useCallback(()=>{const c=d;if(h(null),n==null||n(null),l&&i&&c){const g=i(c);g&&l.emit({type:"panel:blur",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:g,panelSlot:c}})}},[d,n,l,i]),u=r.useCallback(()=>{const c=[];return t.left||c.push("left"),c.push("middle"),a==="three-panel"&&!t.right&&c.push("right"),c},[t,a]),f=r.useCallback(()=>{const c=u();if(c.length===0)return;if(d===null){p(c[0]);return}const g=c.indexOf(d);if(g===-1){p(c[0]);return}const S=(g+1)%c.length;p(c[S])},[d,u,p]),x=r.useCallback(()=>{const c=u();if(c.length===0)return;if(d===null){p(c[c.length-1]);return}const g=c.indexOf(d);if(g===-1){p(c[c.length-1]);return}const S=g===0?c.length-1:g-1;p(c[S])},[d,u,p]),m=r.useCallback(c=>d===c,[d]);return{focusedPanel:d,setFocus:p,clearFocus:w,focusNext:f,focusPrevious:x,isFocused:m}}function ve(s){const{enabled:e=!0,focusedPanel:t,collapsed:a,panelType:n,setFocus:l,onExpand:i,onCollapse:d}=s,h=r.useRef(t),p=r.useRef(a),w=r.useRef(n);r.useEffect(()=>{h.current=t},[t]),r.useEffect(()=>{p.current=a},[a]),r.useEffect(()=>{w.current=n},[n]);const u=r.useCallback(f=>{if(!f.altKey||f.ctrlKey||f.metaKey||f.shiftKey)return;const x=f.code,m=h.current,c=p.current,g=w.current;x==="Digit1"||x==="Numpad1"?(f.preventDefault(),c.left?i("left"):m!=="left"?l("left"):(d("left"),l("middle"))):x==="Digit2"||x==="Numpad2"?(f.preventDefault(),l("middle")):(x==="Digit3"||x==="Numpad3")&&g==="three-panel"&&(f.preventDefault(),c.right?i("right"):m!=="right"?l("right"):(d("right"),l("middle")))},[l,i,d]);r.useEffect(()=>{if(e)return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[e,u])}function Pe(s,e,t,a){r.useEffect(()=>{const n=e.on("panel:focus",i=>{i.payload.panelId===s&&t()});let l;return a&&(l=e.on("panel:blur",i=>{i.payload.panelId===s&&a()})),()=>{n(),l==null||l()}},[s,e,t,a])}const Ie=({isFocused:s,className:e="",style:t={}})=>{if(!s)return null;const a={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",border:"2px solid var(--panel-focus-border-color, #0066cc)",borderRadius:"4px",boxShadow:"0 0 0 1px var(--panel-focus-shadow-color, rgba(0, 102, 204, 0.2))",zIndex:1e3,transition:"opacity 0.15s ease-in-out",...t};return o.jsx("div",{className:`panel-focus-indicator ${e}`,style:a,role:"presentation","aria-hidden":"true"})},X=({value:s,onChange:e,onSubmit:t,onClose:a,onHistoryPrevious:n,onHistoryNext:l,mode:i,status:d,placeholder:h="What would you like to do?",disabled:p=!1,autoFocus:w=!0,agentAvailable:u=!0})=>{const{theme:f}=O.useTheme(),x=r.useRef(null);r.useEffect(()=>{w&&x.current&&x.current.focus()},[w]);const m=g=>{switch(g.stopPropagation(),g.key){case"Enter":g.preventDefault(),t();break;case"Escape":g.preventDefault(),a();break;case"ArrowUp":g.preventDefault(),n();break;case"ArrowDown":g.preventDefault(),l();break}},c=d==="thinking"||d==="executing";return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:f.colors.background,borderBottom:`1px solid ${f.colors.border}`},children:[o.jsx("span",{style:{color:i==="quick-command"?f.colors.info:u?f.colors.primary:f.colors.textMuted,fontFamily:f.fonts.monospace,fontSize:"14px",userSelect:"none",display:"flex",alignItems:"center"},children:i==="quick-command"?o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("polyline",{points:"4 17 10 11 4 5"}),o.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}):u?o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),o.jsx("circle",{cx:"12",cy:"5",r:"2"}),o.jsx("path",{d:"M12 7v4"}),o.jsx("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),o.jsx("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]}):">"}),o.jsx("input",{ref:x,"data-agent-command-palette-input":!0,type:"text",value:s,onChange:g=>e(g.target.value),onKeyDown:m,placeholder:h,disabled:p||c,style:{flex:1,backgroundColor:"transparent",border:"none",outline:"none",color:f.colors.text,fontFamily:f.fonts.monospace,fontSize:"14px",caretColor:f.colors.primary}}),c&&o.jsxs("span",{style:{color:f.colors.info,fontSize:"12px",display:"flex",alignItems:"center",gap:"4px"},children:[o.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:f.colors.info,animation:"pulse 1s ease-in-out infinite"}}),d==="thinking"?"Thinking...":"Executing..."]}),!c&&o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:f.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${f.colors.border}`,fontSize:"11px",color:f.colors.textMuted},children:"Alt+P"})]})};X.displayName="AgentCommandInput";const We=({status:s})=>{const{theme:e}=O.useTheme(),t={display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",fontSize:"12px"};switch(s){case"pending":return o.jsx("span",{style:{...t,color:e.colors.textMuted},children:"○"});case"running":return o.jsx("span",{style:{...t,color:e.colors.info,animation:"spin 1s linear infinite"},children:"◐"});case"success":return o.jsx("span",{style:{...t,color:e.colors.success},children:"✓"});case"error":return o.jsx("span",{style:{...t,color:e.colors.error},children:"✗"})}},Re=s=>{const e=Object.entries(s);return e.length===0?"":e.map(([t,a])=>t==="args"&&Array.isArray(a)?a.join(", "):typeof a=="string"?`"${a}"`:JSON.stringify(a)).join(", ")},Ae=({tool:s,compact:e})=>{const{theme:t}=O.useTheme(),a=Re(s.args);return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:e?"4px 0":"8px 0",fontFamily:t.fonts.monospace,fontSize:"13px"},children:[o.jsx(We,{status:s.status}),o.jsxs("span",{style:{color:t.colors.text},children:[s.name,a&&o.jsxs("span",{style:{color:t.colors.textMuted},children:["(",a,")"]})]}),s.status==="running"&&o.jsx("span",{style:{marginLeft:"auto",color:t.colors.info,fontSize:"11px"},children:"[running]"}),s.status==="success"&&o.jsx("span",{style:{marginLeft:"auto",color:t.colors.success,fontSize:"11px"},children:"[done]"}),s.status==="error"&&o.jsx("span",{style:{marginLeft:"auto",color:t.colors.error,fontSize:"11px"},title:s.error,children:"[error]"})]})},Y=({tools:s,compact:e=!1})=>{const{theme:t}=O.useTheme();return s.length===0?null:o.jsx("div",{style:{padding:e?"8px 16px":"12px 16px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"4px",margin:"8px 16px"},children:s.map(a=>o.jsx(Ae,{tool:a,compact:e},a.id))})};Y.displayName="ToolExecutionList";const Z=({response:s,streaming:e=!1})=>{const{theme:t}=O.useTheme();if(!s)return null;const a=s.toLowerCase().startsWith("error"),n=s.toLowerCase().startsWith("done")||s.toLowerCase().startsWith("executed");return o.jsxs("div",{style:{padding:"12px 16px",color:a?t.colors.error:n?t.colors.success:t.colors.text,fontSize:"13px",display:"flex",alignItems:"center",gap:"8px"},children:[n&&o.jsx("span",{children:"✓"}),a&&o.jsx("span",{children:"✗"}),o.jsxs("span",{children:[s,e&&o.jsx("span",{style:{display:"inline-block",width:"2px",height:"14px",backgroundColor:t.colors.primary,marginLeft:"2px",animation:"blink 1s step-end infinite"}})]})]})};Z.displayName="AgentResponseDisplay";const de=({palette:s,config:e})=>{const{theme:t}=O.useTheme(),a=r.useRef(null),{isOpen:n,close:l,query:i,setQuery:d,mode:h,status:p,pendingTools:w,completedTools:u,agentResponse:f,submit:x,historyPrevious:m,historyNext:c,suggestions:g,agentAvailable:S}=s;r.useEffect(()=>{if(!n)return;const F=A=>{a.current&&!a.current.contains(A.target)&&l()},M=setTimeout(()=>{document.addEventListener("mousedown",F)},100);return()=>{clearTimeout(M),document.removeEventListener("mousedown",F)}},[n,l]);const[R,I]=r.useState(!1),[C,z]=r.useState(!1);if(r.useEffect(()=>{if(n)z(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{I(!0)})});else{I(!1);const F=setTimeout(()=>{z(!1)},150);return()=>clearTimeout(F)}},[n]),!C)return null;const y=S?(e==null?void 0:e.placeholder)||"What would you like to do?":"Quick command mode (agent unavailable)",b=[...u,...w],T=b.length>0,j=f&&p!=="idle",P=S&&!i&&p==="idle"&&g.length>0,v=(h==="quick-command"||!S)&&p==="idle",B=!S&&h!=="quick-command"&&p==="idle";return o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{position:"fixed",inset:0,zIndex:999},onClick:l}),o.jsxs("div",{ref:a,className:e==null?void 0:e.className,style:{position:"fixed",bottom:0,left:0,right:0,maxHeight:"50vh",backgroundColor:t.colors.surface,borderTop:`1px solid ${t.colors.border}`,boxShadow:t.shadows[2],zIndex:1e3,display:"flex",flexDirection:"column-reverse",overflow:"hidden",transform:R?"translateY(0)":"translateY(100%)",transition:"transform 150ms ease-out",...e==null?void 0:e.style},children:[o.jsxs("div",{children:[o.jsx(X,{value:i,onChange:d,onSubmit:x,onClose:l,onHistoryPrevious:m,onHistoryNext:c,mode:h,status:p,placeholder:y,agentAvailable:S}),o.jsxs("div",{style:{padding:"8px 16px",borderTop:`1px solid ${t.colors.border}`,display:"flex",gap:"16px",fontSize:"12px",color:t.colors.textMuted,backgroundColor:t.colors.background},children:[o.jsxs("span",{children:[o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"Enter"})," ","Execute"]}),o.jsxs("span",{children:[o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"Esc"})," ","Close"]}),o.jsxs("span",{children:[o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"↑↓"})," ","History"]}),o.jsxs("span",{style:{marginLeft:"auto"},children:[o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"/"})," ","Quick command"]})]})]}),o.jsxs("div",{style:{overflow:"auto"},children:[T&&o.jsx(Y,{tools:b,compact:b.length>3}),j&&o.jsx(Z,{response:f,streaming:p==="thinking"}),P&&o.jsxs("div",{style:{padding:"12px 16px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[o.jsx("span",{style:{color:t.colors.textMuted,fontSize:"12px",marginRight:"4px"},children:"Try:"}),g.map((F,M)=>o.jsxs("button",{onClick:()=>{d(F)},style:{padding:"4px 10px",backgroundColor:t.colors.backgroundSecondary,border:`1px solid ${t.colors.border}`,borderRadius:"12px",color:t.colors.textSecondary,fontSize:"12px",cursor:"pointer",transition:"background-color 150ms ease"},onMouseEnter:A=>{A.currentTarget.style.backgroundColor=t.colors.backgroundTertiary},onMouseLeave:A=>{A.currentTarget.style.backgroundColor=t.colors.backgroundSecondary},children:['"',F,'"']},M))]}),B&&o.jsxs("div",{style:{padding:"12px 16px",fontSize:"12px",color:t.colors.warning,display:"flex",alignItems:"center",gap:"8px"},children:[o.jsx("span",{children:"Agent unavailable."}),o.jsxs("span",{style:{color:t.colors.textMuted},children:["Use quick commands (start with ",o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"/"}),")"]})]}),v&&o.jsxs("div",{style:{padding:"12px 16px",fontSize:"12px",color:t.colors.textMuted,fontFamily:t.fonts.monospace},children:[o.jsx("div",{style:{marginBottom:"8px",color:t.colors.textSecondary},children:"Quick commands:"}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[o.jsxs("div",{children:[o.jsx("span",{style:{color:t.colors.info},children:"/toggle"})," ",o.jsx("span",{style:{color:t.colors.textMuted},children:"<left|right>"})," ","- Toggle sidebar visibility"]}),o.jsxs("div",{children:[o.jsx("span",{style:{color:t.colors.info},children:"/switch"})," ",o.jsx("span",{style:{color:t.colors.textMuted},children:"<slot> <panel>"})," ","- Switch panel content"]}),o.jsxs("div",{children:[o.jsx("span",{style:{color:t.colors.info},children:"/collapse"})," ","- Collapse all sidebars"]}),o.jsxs("div",{children:[o.jsx("span",{style:{color:t.colors.info},children:"/expand"})," ","- Expand all sidebars"]})]})]})]})]}),o.jsx("style",{children:`
|
|
1
|
+
"use strict";require('./index.css');var ze=Object.defineProperty;var Le=(s,e,t)=>e in s?ze(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var J=(s,e,t)=>Le(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("@principal-ade/panels"),n=require("react"),o=require("react/jsx-runtime"),N=require("@principal-ade/industry-theme");class ge{constructor(){J(this,"storageKey","panel-layouts")}async load(e){try{const t=localStorage.getItem(`${this.storageKey}:${e}`);return t?JSON.parse(t):null}catch(t){return console.error(`Failed to load panel layout for ${e}:`,t),null}}async save(e,t){try{localStorage.setItem(`${this.storageKey}:${e}`,JSON.stringify(t))}catch(r){console.error(`Failed to save panel layout for ${e}:`,r)}}}function Ee(s){const{viewKey:e,defaultSizes:t,panelType:r,adapter:a=new ge}=s,[l,i]=n.useState(t),[d,m]=n.useState(s.collapsed),c=n.useRef(s.collapsed),x=n.useRef({}),u=n.useRef(null),h=n.useRef(null);n.useEffect(()=>{(async()=>{const S=await a.load(e);S!=null&&S.sizes&&(i(S.sizes),k(S.sizes))})()},[e]);const k=n.useCallback(b=>{"left"in b&&b.left>0&&(x.current.left=b.left),"middle"in b&&b.middle>0&&(x.current.middle=b.middle),"right"in b&&b.right>0&&(x.current.right=b.right)},[]),y=n.useCallback(b=>{const S=x.current[b];if(S&&S>0)return S;if(b==="left"&&"left"in t&&t.left>0)return t.left;if(b==="right"&&"right"in t&&t.right>0)return t.right},[t]),p=n.useRef(t);n.useEffect(()=>{("left"in t&&t.left!==p.current.left||"middle"in t&&"middle"in p.current&&t.middle!==p.current.middle||"right"in t&&t.right!==p.current.right)&&(i(t),k(t),p.current=t)},[t,k]),n.useEffect(()=>{const b=s.collapsed.left!==c.current.left,S="right"in s.collapsed&&"right"in c.current&&s.collapsed.right!==c.current.right;(b||S)&&(m(s.collapsed),c.current={...s.collapsed})},[s.collapsed.left,s.collapsed.right]);const f=n.useCallback(async b=>{try{await a.save(e,{sizes:b})}catch(S){console.error(`Failed to save panel preferences for ${e}:`,S)}},[e,a]),T=n.useCallback(b=>{const S={...b};let w=!0;if("left"in b){const j=!!(d!=null&&d.left),v=b.left;if(j){const P=y("left");P!==void 0&&P>0?S.left=P:w=!1}else v===0&&(w=!1)}if(r==="three-panel"&&"right"in b){const j=!!(d!=null&&d.right),v=b.right;if(j){const P=y("right");P!==void 0&&P>0?S.right=P:w=!1}else v===0&&(w=!1)}if(i(S),k(S),u.current&&(clearTimeout(u.current),u.current=null),!w){h.current=null;return}h.current=S,u.current=setTimeout(()=>{const j=h.current;j&&(f(j),h.current=null),u.current=null},500)},[d,y,r,f,k]);n.useEffect(()=>()=>{if(u.current){const b=h.current;b&&(f(b),h.current=null),clearTimeout(u.current),u.current=null}},[f]);const I=n.useCallback(async()=>{},[]),L=n.useCallback(async()=>{},[]),C=n.useCallback(async()=>{},[]),W=n.useCallback(async()=>{},[]);return r==="three-panel"?{type:"three-panel",sizes:l,collapsed:d,handlePanelResize:T,handleLeftCollapseComplete:I,handleLeftExpandComplete:L,handleRightCollapseComplete:C,handleRightExpandComplete:W}:{type:"two-panel",sizes:l,collapsed:d,handlePanelResize:T,handleLeftCollapseComplete:I,handleLeftExpandComplete:L}}class xe{constructor(){J(this,"PRESETS_KEY","panel-layouts:workspace-presets");J(this,"REPO_STATE_PREFIX","panel-layouts:repo-state:")}async loadWorkspacePresets(){try{const e=localStorage.getItem(this.PRESETS_KEY);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to load workspace presets:",e),{}}}async saveWorkspacePresets(e){try{localStorage.setItem(this.PRESETS_KEY,JSON.stringify(e))}catch(t){throw console.error("Failed to save workspace presets:",t),t}}async loadRepositoryState(e){try{const t=`${this.REPO_STATE_PREFIX}${e}`,r=localStorage.getItem(t);return r?JSON.parse(r):null}catch(t){return console.error(`Failed to load repository state for ${e}:`,t),null}}async saveRepositoryState(e,t){try{const r=`${this.REPO_STATE_PREFIX}${e}`;localStorage.setItem(r,JSON.stringify(t))}catch(r){throw console.error(`Failed to save repository state for ${e}:`,r),r}}async loadAllRepositoryStates(){try{const e={};for(let t=0;t<localStorage.length;t++){const r=localStorage.key(t);if(r&&r.startsWith(this.REPO_STATE_PREFIX)){const a=r.substring(this.REPO_STATE_PREFIX.length),l=localStorage.getItem(r);if(l)try{e[a]=JSON.parse(l)}catch(i){console.error(`Failed to parse repository state for ${a}:`,i)}}}return e}catch(e){return console.error("Failed to load all repository states:",e),{}}}}class R{static setAdapter(e){this.adapter=e}static async getWorkspaceLayouts(){const e=this.getBuiltInWorkspaceLayouts();return{...await this.adapter.loadWorkspacePresets(),...e}}static async getWorkspaceLayout(e){return(await this.getWorkspaceLayouts())[e]||null}static async createWorkspaceLayout(e){const t=await this.adapter.loadWorkspacePresets(),r=this.generateWorkspaceId(e.name),a={id:r,name:e.name,description:e.description,layout:e.layout,defaultSizes:e.defaultSizes,defaultCollapsed:e.defaultCollapsed,createdAt:Date.now(),updatedAt:Date.now(),isBuiltIn:!1},l={...t,[r]:a};return await this.adapter.saveWorkspacePresets(l),a}static async updateWorkspaceLayout(e,t){const r=await this.adapter.loadWorkspacePresets(),a=r[e];if(!a)return console.error(`Workspace layout ${e} not found`),null;if(a.isBuiltIn)return console.error(`Cannot update built-in workspace layout ${e}`),null;const l={...a,...t,id:e,createdAt:a.createdAt,updatedAt:Date.now()},i={...r,[e]:l};return await this.adapter.saveWorkspacePresets(i),l}static async deleteWorkspaceLayout(e){const t=await this.adapter.loadWorkspacePresets(),r=t[e];if(!r)return console.error(`Workspace layout ${e} not found`),!1;if(r.isBuiltIn)return console.error(`Cannot delete built-in workspace layout ${e}`),!1;const a={...t};return delete a[e],await this.adapter.saveWorkspacePresets(a),!0}static async getRepositoryState(e){return await this.adapter.loadRepositoryState(e)}static async setRepositoryState(e,t){await this.adapter.saveRepositoryState(e,t)}static async updateRepositorySizes(e,t){const r=await this.getRepositoryState(e);r&&await this.setRepositoryState(e,{...r,sizes:t})}static async updateRepositoryCollapsed(e,t){const r=await this.getRepositoryState(e);r&&await this.setRepositoryState(e,{...r,collapsed:t})}static hasStateDeviation(e,t){const r=t.defaultSizes?JSON.stringify(e.sizes)!==JSON.stringify(t.defaultSizes):!1,a=t.defaultCollapsed?JSON.stringify(e.collapsed)!==JSON.stringify(t.defaultCollapsed):!1;return{hasSizeDeviation:r,hasCollapsedDeviation:a}}static async updateWorkspaceFromRepositoryState(e,t){const r=await this.getWorkspaceLayout(e),a=await this.getRepositoryState(t);if(!r||!a||r.isBuiltIn){console.error("Cannot update built-in workspace or workspace/state not found");return}await this.updateWorkspaceLayout(e,{defaultSizes:a.sizes,defaultCollapsed:a.collapsed})}static async resetRepositoryToWorkspaceDefaults(e,t){const r=await this.getWorkspaceLayout(t);if(!r){console.error(`Workspace ${t} not found`);return}const a=await this.getRepositoryState(e);a&&await this.setRepositoryState(e,{...a,sizes:r.defaultSizes||{left:20,middle:45,right:35},collapsed:r.defaultCollapsed||{left:!1,right:!1}})}static isLayoutMatchingWorkspace(e,t){return this.areLayoutsEqual(e,t.layout)}static async findMatchingWorkspace(e){const t=await this.getWorkspaceLayouts();for(const[r,a]of Object.entries(t))if(this.isLayoutMatchingWorkspace(e,a))return r;return null}static areLayoutsEqual(e,t){return JSON.stringify(e)===JSON.stringify(t)}static generateWorkspaceId(e){return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-${Date.now()}`}static getBuiltInWorkspaceLayouts(){const e=Date.now();return{"project-management":{id:"project-management",name:"Project Management",description:"Tasks, dependencies, issues, file tree, docs, drawings, multi terminal, city visualization, code viewer, markdown slides, and excalidraw",layout:{left:{type:"tabs",panels:["tasks","dependencies","gitIssues","fileTree","docs","drawings"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"multiTerminal",right:{type:"tabs",panels:["cityVisualization","codeViewer","markdownViewer","excalidrawDiagram"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:45,right:35},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0},"code-review":{id:"code-review",name:"Code Review",description:"Git changes, pull requests, and file tree on left, git diff and code viewer in middle, city map on right",layout:{left:{type:"tabs",panels:["gitChanges","gitPullRequests","fileTree"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:{type:"tabs",panels:["gitDiff","codeViewer"],config:{defaultActiveTab:0,tabPosition:"top"}},right:"cityVisualization"},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0},documentation:{id:"documentation",name:"Documentation",description:"Docs, markdown viewer, and code viewer",layout:{left:"docs",middle:"markdownViewer",right:"codeViewer"},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},"agent-work":{id:"agent-work",name:"Agent Work",description:"Tasks, agent sessions, file tree, agent context, git changes, docs, multi terminal, city map, agent events, code viewer, and markdown slides",layout:{left:{type:"tabs",panels:["tasks","agentSessions","fileTree","agentContext","gitChanges","docs"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"multiTerminal",right:{type:"tabs",panels:["cityVisualization","agentEvents","codeViewer","markdownViewer"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:45,right:35},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0},"quality-check":{id:"quality-check",name:"Quality Check",description:"Package information, tools, and dependencies on left; city visualization map in middle; multi terminal and code viewer on right (collapsed)",layout:{left:{type:"tabs",panels:["packageInfo","tools","dependencies"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"cityVisualization",right:{type:"tabs",panels:["multiTerminal","codeViewer"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:45,right:35},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},drawing:{id:"drawing",name:"Drawing",description:"Drawings and docs, excalidraw diagram, multi terminal and markdown viewer",layout:{left:{type:"tabs",panels:["drawings","docs"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:"excalidrawDiagram",right:{type:"tabs",panels:["multiTerminal","markdownViewer"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},"old-school":{id:"old-school",name:"Old School",description:"File tree, search, git changes, and docs on left; code viewer and markdown viewer in middle; multi terminal and city map on right (collapsed)",layout:{left:{type:"tabs",panels:["fileTree","search","gitChanges","docs"],config:{defaultActiveTab:0,tabPosition:"top"}},middle:{type:"tabs",panels:["codeViewer","markdownViewer"],config:{defaultActiveTab:0,tabPosition:"top"}},right:{type:"tabs",panels:["multiTerminal","cityVisualization"],config:{defaultActiveTab:0,tabPosition:"top"}}},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!0},createdAt:e,updatedAt:e,isBuiltIn:!0},"principal-office":{id:"principal-office",name:"Principal Office",description:"Alexandria docs on left, MDX editor in middle, multi terminal on right",layout:{left:"docs",middle:"mdxEditor",right:"multiTerminal"},defaultSizes:{left:20,middle:50,right:30},defaultCollapsed:{left:!1,right:!1},createdAt:e,updatedAt:e,isBuiltIn:!0}}}static async initializeWorkspaceLayouts(){const e=await this.adapter.loadWorkspacePresets();Object.keys(e).length}}J(R,"adapter",new xe);function _e(s={}){const{repositoryKey:e,autoInitialize:t=!1,defaultWorkspaceId:r}=s,[a,l]=n.useState({}),[i,d]=n.useState(null),[m,c]=n.useState(null),[x,u]=n.useState(!0),[h,k]=n.useState(null),y=n.useCallback(async()=>{try{u(!0),k(null);const w=await R.getWorkspaceLayouts();if(l(w),e){let j=await R.getRepositoryState(e);if(!j&&t){const v=r||"project-management",P=await R.getWorkspaceLayout(v);P&&(j={workspaceId:v,sizes:P.defaultSizes||{left:20,middle:45,right:35},collapsed:P.defaultCollapsed||{left:!1,right:!1}},await R.setRepositoryState(e,j))}if(d(j),j!=null&&j.workspaceId){const v=await R.getWorkspaceLayout(j.workspaceId);c(v)}else c(null)}}catch(w){k(w),console.error("Failed to load workspace data:",w)}finally{u(!1)}},[e,t,r]);n.useEffect(()=>{y()},[y]);const p=n.useCallback(async w=>await R.getWorkspaceLayout(w),[]),f=n.useCallback(async w=>{const j=await R.createWorkspaceLayout(w);return await y(),j},[y]),T=n.useCallback(async(w,j)=>{const v=await R.updateWorkspaceLayout(w,j);return await y(),v},[y]),I=n.useCallback(async w=>{const j=await R.deleteWorkspaceLayout(w);return j&&await y(),j},[y]),L=n.useCallback(async w=>{if(!e){console.error("Cannot apply workspace without repositoryKey");return}const j=await R.getWorkspaceLayout(w);if(!j){console.error(`Workspace ${w} not found`);return}const v={workspaceId:w,sizes:j.defaultSizes||{left:20,middle:45,right:35},collapsed:j.defaultCollapsed||{left:!1,right:!1}};await R.setRepositoryState(e,v),await y()},[e,y]),C=n.useCallback(async w=>{if(!e){console.error("Cannot update sizes without repositoryKey");return}await R.updateRepositorySizes(e,w),await y()},[e,y]),W=n.useCallback(async w=>{if(!e){console.error("Cannot update collapsed without repositoryKey");return}await R.updateRepositoryCollapsed(e,w),await y()},[e,y]),b=n.useCallback(async()=>{if(!e||!(i!=null&&i.workspaceId)){console.error("Cannot reset without repositoryKey and active workspace");return}await R.resetRepositoryToWorkspaceDefaults(e,i.workspaceId),await y()},[e,i==null?void 0:i.workspaceId,y]),S=n.useCallback(async()=>{await y()},[y]);return{workspaces:a,repositoryState:i,activeWorkspace:m,loading:x,error:h,getWorkspace:p,createWorkspace:f,updateWorkspace:T,deleteWorkspace:I,applyWorkspace:L,updateSizes:C,updateCollapsed:W,resetToDefaults:b,refresh:S}}function De(s={}){const{initialFocus:e=null,collapsed:t={},panelType:r="three-panel",onFocusChange:a,events:l,getPanelId:i}=s,[d,m]=n.useState(e),c=n.useCallback(p=>{const f=d;if(m(p),a==null||a(p),l&&i){if(f){const I=i(f);I&&l.emit({type:"panel:blur",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:I,panelSlot:f,nextPanelId:i(p)}})}const T=i(p);T&&l.emit({type:"panel:focus",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:T,panelSlot:p,source:"keyboard-shortcut"}})}},[d,a,l,i]),x=n.useCallback(()=>{const p=d;if(m(null),a==null||a(null),l&&i&&p){const f=i(p);f&&l.emit({type:"panel:blur",source:"panel-layouts",timestamp:Date.now(),payload:{panelId:f,panelSlot:p}})}},[d,a,l,i]),u=n.useCallback(()=>{const p=[];return t.left||p.push("left"),p.push("middle"),r==="three-panel"&&!t.right&&p.push("right"),p},[t,r]),h=n.useCallback(()=>{const p=u();if(p.length===0)return;if(d===null){c(p[0]);return}const f=p.indexOf(d);if(f===-1){c(p[0]);return}const T=(f+1)%p.length;c(p[T])},[d,u,c]),k=n.useCallback(()=>{const p=u();if(p.length===0)return;if(d===null){c(p[p.length-1]);return}const f=p.indexOf(d);if(f===-1){c(p[p.length-1]);return}const T=f===0?p.length-1:f-1;c(p[T])},[d,u,c]),y=n.useCallback(p=>d===p,[d]);return{focusedPanel:d,setFocus:c,clearFocus:x,focusNext:h,focusPrevious:k,isFocused:y}}function qe(s){const{enabled:e=!0,focusedPanel:t,collapsed:r,panelType:a,setFocus:l,onExpand:i,onCollapse:d}=s,m=n.useRef(t),c=n.useRef(r),x=n.useRef(a);n.useEffect(()=>{m.current=t},[t]),n.useEffect(()=>{c.current=r},[r]),n.useEffect(()=>{x.current=a},[a]);const u=n.useCallback(h=>{if(!h.altKey||h.ctrlKey||h.metaKey||h.shiftKey)return;const k=h.code,y=m.current,p=c.current,f=x.current;k==="Digit1"||k==="Numpad1"?(h.preventDefault(),p.left?i("left"):y!=="left"?l("left"):(d("left"),l("middle"))):k==="Digit2"||k==="Numpad2"?(h.preventDefault(),l("middle")):(k==="Digit3"||k==="Numpad3")&&f==="three-panel"&&(h.preventDefault(),p.right?i("right"):y!=="right"?l("right"):(d("right"),l("middle")))},[l,i,d]);n.useEffect(()=>{if(e)return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[e,u])}function $e(s,e,t,r){n.useEffect(()=>{const a=e.on("panel:focus",i=>{i.payload.panelId===s&&t()});let l;return r&&(l=e.on("panel:blur",i=>{i.payload.panelId===s&&r()})),()=>{a(),l==null||l()}},[s,e,t,r])}const Fe=({isFocused:s,className:e="",style:t={}})=>{if(!s)return null;const r={position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",border:"2px solid var(--panel-focus-border-color, #0066cc)",borderRadius:"4px",boxShadow:"0 0 0 1px var(--panel-focus-shadow-color, rgba(0, 102, 204, 0.2))",zIndex:1e3,transition:"opacity 0.15s ease-in-out",...t};return o.jsx("div",{className:`panel-focus-indicator ${e}`,style:r,role:"presentation","aria-hidden":"true"})},re=({value:s,onChange:e,onSubmit:t,onClose:r,onHistoryPrevious:a,onHistoryNext:l,mode:i,status:d,placeholder:m="What would you like to do?",disabled:c=!1,autoFocus:x=!0,agentAvailable:u=!0,showAutocomplete:h=!1,onAutocompleteNext:k,onAutocompletePrevious:y,onAutocompleteAccept:p})=>{const{theme:f}=N.useTheme(),T=n.useRef(null);n.useEffect(()=>{x&&T.current&&T.current.focus()},[x]);const I=C=>{switch(C.stopPropagation(),C.key){case"Enter":C.preventDefault(),t();break;case"Escape":C.preventDefault(),r();break;case"Tab":h&&p&&(C.preventDefault(),p());break;case"ArrowUp":C.preventDefault(),h&&y?y():a();break;case"ArrowDown":C.preventDefault(),h&&k?k():l();break}},L=d==="thinking"||d==="executing";return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:f.colors.background,borderBottom:`1px solid ${f.colors.border}`},children:[o.jsx("span",{style:{color:i==="quick-command"?f.colors.info:u?f.colors.primary:f.colors.textMuted,fontFamily:f.fonts.monospace,fontSize:f.fontSizes[1],userSelect:"none",display:"flex",alignItems:"center"},children:i==="quick-command"?o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("polyline",{points:"4 17 10 11 4 5"}),o.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]}):u?o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),o.jsx("circle",{cx:"12",cy:"5",r:"2"}),o.jsx("path",{d:"M12 7v4"}),o.jsx("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),o.jsx("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]}):">"}),o.jsx("input",{ref:T,"data-agent-command-palette-input":!0,type:"text",value:s,onChange:C=>e(C.target.value),onKeyDown:I,placeholder:m,disabled:c||L,style:{flex:1,backgroundColor:"transparent",border:"none",outline:"none",color:f.colors.text,fontFamily:f.fonts.monospace,fontSize:f.fontSizes[1],caretColor:f.colors.primary}}),L&&o.jsxs("span",{style:{color:f.colors.info,fontSize:f.fontSizes[0],display:"flex",alignItems:"center",gap:"4px"},children:[o.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",backgroundColor:f.colors.info,animation:"pulse 1s ease-in-out infinite"}}),d==="thinking"?"Thinking...":"Executing..."]}),!L&&o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:f.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${f.colors.border}`,fontSize:f.fontSizes[0],color:f.colors.textMuted},children:"Alt+P"})]})};re.displayName="AgentCommandInput";const Me=({status:s})=>{const{theme:e}=N.useTheme(),t={display:"inline-flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",fontSize:e.fontSizes[0]};switch(s){case"pending":return o.jsx("span",{style:{...t,color:e.colors.textMuted},children:"○"});case"running":return o.jsx("span",{style:{...t,color:e.colors.info,animation:"spin 1s linear infinite"},children:"◐"});case"success":return o.jsx("span",{style:{...t,color:e.colors.success},children:"✓"});case"error":return o.jsx("span",{style:{...t,color:e.colors.error},children:"✗"})}},Oe=s=>{const e=Object.entries(s);return e.length===0?"":e.map(([t,r])=>t==="args"&&Array.isArray(r)?r.join(", "):typeof r=="string"?`"${r}"`:JSON.stringify(r)).join(", ")},Ne=({tool:s,compact:e})=>{const{theme:t}=N.useTheme(),r=Oe(s.args);return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:e?"4px 0":"8px 0",fontFamily:t.fonts.monospace,fontSize:t.fontSizes[1]},children:[o.jsx(Me,{status:s.status}),o.jsxs("span",{style:{color:t.colors.text},children:[s.name,r&&o.jsxs("span",{style:{color:t.colors.textMuted},children:["(",r,")"]})]}),s.status==="running"&&o.jsx("span",{style:{marginLeft:"auto",color:t.colors.info,fontSize:t.fontSizes[0]},children:"[running]"}),s.status==="success"&&o.jsx("span",{style:{marginLeft:"auto",color:t.colors.success,fontSize:t.fontSizes[0]},children:"[done]"}),s.status==="error"&&o.jsx("span",{style:{marginLeft:"auto",color:t.colors.error,fontSize:t.fontSizes[0]},title:s.error,children:"[error]"})]})},ae=({tools:s,compact:e=!1})=>{const{theme:t}=N.useTheme();return s.length===0?null:o.jsx("div",{style:{padding:e?"8px 16px":"12px 16px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"4px",margin:"8px 16px"},children:s.map(r=>o.jsx(Ne,{tool:r,compact:e},r.id))})};ae.displayName="ToolExecutionList";const ne=({response:s,streaming:e=!1})=>{const{theme:t}=N.useTheme();if(!s)return null;const r=s.toLowerCase().startsWith("error"),a=s.toLowerCase().startsWith("done")||s.toLowerCase().startsWith("executed");return o.jsxs("div",{style:{padding:"12px 16px",color:r?t.colors.error:a?t.colors.success:t.colors.text,fontSize:t.fontSizes[1],display:"flex",alignItems:"center",gap:"8px"},children:[a&&o.jsx("span",{children:"✓"}),r&&o.jsx("span",{children:"✗"}),o.jsxs("span",{children:[s,e&&o.jsx("span",{style:{display:"inline-block",width:"2px",height:"14px",backgroundColor:t.colors.primary,marginLeft:"2px",animation:"blink 1s step-end infinite"}})]})]})};ne.displayName="AgentResponseDisplay";function Be({text:s,matchedIndices:e,highlightColor:t}){if(!e.length)return o.jsx(o.Fragment,{children:s});const r=new Set(e),a=s.split("");return o.jsx(o.Fragment,{children:a.map((l,i)=>o.jsx("span",{style:{color:r.has(i)?t:"inherit",fontWeight:r.has(i)?600:"inherit"},children:l},i))})}const le=({matches:s,selectedIndex:e,onSelect:t,maxVisible:r=6})=>{const{theme:a}=N.useTheme(),l=n.useRef(null),i=n.useRef(null);if(n.useEffect(()=>{i.current&&l.current&&i.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[e]),s.length===0)return null;const m=48*r;return o.jsx("div",{ref:l,style:{maxHeight:`${m}px`,overflowY:"auto",borderTop:`1px solid ${a.colors.border}`},children:s.map((c,x)=>{const u=x===e,h=c.command;return o.jsxs("div",{ref:u?i:void 0,onClick:()=>t(x),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 16px",cursor:"pointer",backgroundColor:u?a.colors.backgroundSecondary:"transparent",borderLeft:u?`2px solid ${a.colors.primary}`:"2px solid transparent",transition:"background-color 100ms ease"},onMouseEnter:k=>{u||(k.currentTarget.style.backgroundColor=a.colors.backgroundSecondary)},onMouseLeave:k=>{u||(k.currentTarget.style.backgroundColor="transparent")},children:[o.jsx("span",{style:{color:a.colors.info,fontFamily:a.fonts.monospace,fontSize:a.fontSizes[1],flexShrink:0},children:"/"}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{fontFamily:a.fonts.monospace,fontSize:a.fontSizes[1],color:a.colors.text},children:[o.jsx(Be,{text:h.name,matchedIndices:c.matchedOn===h.name?c.matchedIndices:[],highlightColor:a.colors.primary}),c.matchedOn!==h.name&&o.jsxs("span",{style:{color:a.colors.textMuted,marginLeft:"8px",fontSize:a.fontSizes[0]},children:["(alias: ",c.matchedOn,")"]})]}),o.jsx("div",{style:{fontSize:a.fontSizes[0],color:a.colors.textMuted,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:h.description})]}),h.args&&h.args.length>0&&o.jsx("div",{style:{fontSize:a.fontSizes[0],color:a.colors.textMuted,fontFamily:a.fonts.monospace,flexShrink:0},children:h.args.map((k,y)=>o.jsxs("span",{children:[y>0&&" ",o.jsx("span",{style:{color:k.required?a.colors.warning:a.colors.textMuted},children:k.required?`<${k.name}>`:`[${k.name}]`})]},k.name))}),u&&o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:a.colors.backgroundTertiary,borderRadius:"3px",border:`1px solid ${a.colors.border}`,fontSize:a.fontSizes[0],color:a.colors.textMuted,flexShrink:0},children:"Tab"})]},`${h.name}-${x}`)})})};le.displayName="QuickCommandAutocomplete";const ke=({palette:s,config:e})=>{const{theme:t}=N.useTheme(),r=n.useRef(null),{isOpen:a,close:l,query:i,setQuery:d,mode:m,status:c,pendingTools:x,completedTools:u,agentResponse:h,submit:k,historyPrevious:y,historyNext:p,suggestions:f,agentAvailable:T,quickCommandMatches:I,selectedAutocompleteIndex:L,autocompleteNext:C,autocompletePrevious:W,autocompleteAccept:b,showAutocomplete:S}=s;n.useEffect(()=>{if(!a)return;const _=q=>{r.current&&!r.current.contains(q.target)&&l()},D=setTimeout(()=>{document.addEventListener("mousedown",_)},100);return()=>{clearTimeout(D),document.removeEventListener("mousedown",_)}},[a,l]);const[w,j]=n.useState(!1),[v,P]=n.useState(!1);if(n.useEffect(()=>{if(a)P(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{j(!0)})});else{j(!1);const _=setTimeout(()=>{P(!1)},150);return()=>clearTimeout(_)}},[a]),!v)return null;const E=T?(e==null?void 0:e.placeholder)||"What would you like to do?":"Quick command mode (agent unavailable)",F=[...u,...x],Y=F.length>0,Q=h&&c!=="idle",V=T&&!i&&c==="idle"&&f.length>0,H=(m==="quick-command"||!T)&&c==="idle",Z=!T&&m!=="quick-command"&&c==="idle";return o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{position:"fixed",inset:0,zIndex:999},onClick:l}),o.jsxs("div",{ref:r,className:e==null?void 0:e.className,style:{position:"fixed",bottom:0,left:0,right:0,maxHeight:"50vh",backgroundColor:t.colors.surface,borderTop:`1px solid ${t.colors.border}`,boxShadow:t.shadows[2],zIndex:1e3,display:"flex",flexDirection:"column-reverse",overflow:"hidden",transform:w?"translateY(0)":"translateY(100%)",transition:"transform 150ms ease-out",...e==null?void 0:e.style},children:[o.jsxs("div",{children:[o.jsx(re,{value:i,onChange:d,onSubmit:k,onClose:l,onHistoryPrevious:y,onHistoryNext:p,mode:m,status:c,placeholder:E,agentAvailable:T,showAutocomplete:S,onAutocompleteNext:C,onAutocompletePrevious:W,onAutocompleteAccept:b}),o.jsxs("div",{style:{padding:"8px 16px",borderTop:`1px solid ${t.colors.border}`,display:"flex",gap:"16px",fontSize:t.fontSizes[0],color:t.colors.textMuted,backgroundColor:t.colors.background},children:[o.jsxs("span",{children:[o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"Enter"})," ","Execute"]}),o.jsxs("span",{children:[o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"Esc"})," ","Close"]}),o.jsxs("span",{children:[o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"↑↓"})," ","History"]}),o.jsxs("span",{style:{marginLeft:"auto"},children:[o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"/"})," ","Quick command"]})]})]}),o.jsxs("div",{style:{overflow:"auto"},children:[Y&&o.jsx(ae,{tools:F,compact:F.length>3}),Q&&o.jsx(ne,{response:h,streaming:c==="thinking"}),V&&o.jsxs("div",{style:{padding:"12px 16px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[o.jsx("span",{style:{color:t.colors.textMuted,fontSize:t.fontSizes[0],marginRight:"4px"},children:"Try:"}),f.map((_,D)=>o.jsxs("button",{onClick:()=>{d(_)},style:{padding:"4px 10px",backgroundColor:t.colors.backgroundSecondary,border:`1px solid ${t.colors.border}`,borderRadius:"12px",color:t.colors.textSecondary,fontSize:t.fontSizes[0],cursor:"pointer",transition:"background-color 150ms ease"},onMouseEnter:q=>{q.currentTarget.style.backgroundColor=t.colors.backgroundTertiary},onMouseLeave:q=>{q.currentTarget.style.backgroundColor=t.colors.backgroundSecondary},children:['"',_,'"']},D))]}),Z&&o.jsxs("div",{style:{padding:"12px 16px",fontSize:t.fontSizes[0],color:t.colors.warning,display:"flex",alignItems:"center",gap:"8px"},children:[o.jsx("span",{children:"Agent unavailable."}),o.jsxs("span",{style:{color:t.colors.textMuted},children:["Use quick commands (start with ",o.jsx("kbd",{style:{padding:"2px 6px",backgroundColor:t.colors.backgroundSecondary,borderRadius:"3px",border:`1px solid ${t.colors.border}`},children:"/"}),")"]})]}),H&&o.jsxs("div",{style:{padding:"12px 16px",fontSize:t.fontSizes[0],color:t.colors.textMuted,fontFamily:t.fonts.monospace},children:[o.jsx("div",{style:{marginBottom:"8px",color:t.colors.textSecondary},children:"Quick commands:"}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[o.jsxs("div",{children:[o.jsx("span",{style:{color:t.colors.info},children:"/toggle"})," ",o.jsx("span",{style:{color:t.colors.textMuted},children:"<left|right>"})," ","- Toggle sidebar visibility"]}),o.jsxs("div",{children:[o.jsx("span",{style:{color:t.colors.info},children:"/switch"})," ",o.jsx("span",{style:{color:t.colors.textMuted},children:"<slot> <panel>"})," ","- Switch panel content"]}),o.jsxs("div",{children:[o.jsx("span",{style:{color:t.colors.info},children:"/collapse"})," ","- Collapse all sidebars"]}),o.jsxs("div",{children:[o.jsx("span",{style:{color:t.colors.info},children:"/expand"})," ","- Expand all sidebars"]})]})]}),S&&o.jsx(le,{matches:I,selectedIndex:L,onSelect:_=>{const D=I[_];if(D){const q=D.command;let G=`/${q.name}`;q.args&&q.args.length>0&&(G+=" "),d(G)}}})]})]}),o.jsx("style",{children:`
|
|
2
2
|
@keyframes pulse {
|
|
3
3
|
0%, 100% { opacity: 1; }
|
|
4
4
|
50% { opacity: 0.5; }
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
0%, 100% { opacity: 1; }
|
|
12
12
|
50% { opacity: 0; }
|
|
13
13
|
}
|
|
14
|
-
`})]})};de.displayName="AgentCommandPalette";const Le=["hide sidebars","show terminal","focus editor"];function _e({events:s,keyboard:e={key:"p",altKey:!0},config:t={},onExecuteTool:a,initialSuggestions:n=Le,agentAvailable:l=!0}={}){const[i,d]=r.useState(!1),[h,p]=r.useState(""),[w,u]=r.useState("natural"),[f,x]=r.useState("idle"),[m,c]=r.useState([]),[g,S]=r.useState([]),[R,I]=r.useState(""),[C,z]=r.useState([]),[y,b]=r.useState(-1),T=r.useMemo(()=>n,[n]),j=r.useCallback(k=>{p(k),u(k.startsWith("/")?"quick-command":"natural")},[]),P=r.useCallback(()=>{d(!0),l?(p(""),u("natural")):(p("/"),u("quick-command")),x("idle"),c([]),S([]),I(""),b(-1),s==null||s.emit({type:"agent-command-palette:opened",source:"agent-command-palette",timestamp:Date.now(),payload:{}})},[s,l]),v=r.useCallback(()=>{d(!1),s==null||s.emit({type:"agent-command-palette:closed",source:"agent-command-palette",timestamp:Date.now(),payload:{}})},[s]),B=r.useCallback(()=>{i?v():P()},[i,P,v]),F=r.useCallback(()=>{p(""),u("natural"),x("idle"),c([]),S([]),I(""),b(-1)},[]),M=r.useCallback(k=>{const L={...k,status:"pending"};return c(_=>[..._,L]),L},[]),A=r.useCallback((k,L,_,N)=>{c(E=>{const q=E.find($=>$.id===k);if(!q)return E;const D={...q,status:L,result:_,error:N};return L==="success"||L==="error"?(S($=>[...$,D]),E.filter($=>$.id!==k)):E.map($=>$.id===k?D:$)})},[]),H=r.useCallback(async k=>{const L=k.replace(/^\//,"").trim().split(/\s+/),_=L[0],N=L.slice(1);if(!_)return;x("executing");const E=`quick-${Date.now()}`;M({id:E,name:_,args:{args:N}}),A(E,"running");try{if(a){const D=await a(_,{args:N});A(E,"success",String(D))}else A(E,"success","Tool executed (no handler)");z(D=>[{query:k,timestamp:Date.now(),toolsExecuted:[_],success:!0},...D.slice(0,(t.maxHistoryEntries||50)-1)]),x("complete"),I(`Executed: ${_}`);const q=t.autoCloseDelay??1e3;q>0&&setTimeout(()=>v(),q)}catch(q){const D=q instanceof Error?q.message:"Unknown error";A(E,"error",void 0,D),x("error"),I(`Error: ${D}`)}},[a,M,A,t.autoCloseDelay,t.maxHistoryEntries,v]),xe=r.useCallback(()=>{if(h.trim()){if(w==="quick-command"){H(h);return}if(!l){I("Agent unavailable. Use quick commands (start with /)."),x("error");return}x("thinking"),s==null||s.emit({type:"agent-command-palette:submit",source:"agent-command-palette",timestamp:Date.now(),payload:{query:h,mode:w}}),z(k=>[{query:h,timestamp:Date.now(),toolsExecuted:[],success:!0},...k.slice(0,(t.maxHistoryEntries||50)-1)])}},[h,w,H,s,t.maxHistoryEntries,l]),ke=r.useCallback(()=>{if(C.length===0)return;const k=y<C.length-1?y+1:y;b(k),C[k]&&(p(C[k].query),u(C[k].query.startsWith("/")?"quick-command":"natural"))},[C,y]),be=r.useCallback(()=>{if(y<=0){b(-1),p(""),u("natural");return}const k=y-1;b(k),C[k]&&(p(C[k].query),u(C[k].query.startsWith("/")?"quick-command":"natural"))},[C,y]),G=r.useCallback(k=>{const{key:L="p",altKey:_=!0,ctrlKey:N=!1,metaKey:E=!1,shiftKey:q=!1}=e,D=k.altKey===_&&k.ctrlKey===N&&k.metaKey===E&&k.shiftKey===q;if((_?k.code===`Key${L.toUpperCase()}`:k.key.toLowerCase()===L.toLowerCase())&&D){const K=k.target;if(!K.closest("[data-agent-command-palette-input]")&&(K.tagName==="INPUT"||K.tagName==="TEXTAREA"||K.isContentEditable))return;k.preventDefault(),B()}},[e,B]);return r.useEffect(()=>(window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)),[G]),{agentAvailable:l,isOpen:i,open:P,close:v,toggle:B,query:h,setQuery:j,mode:w,status:f,setStatus:x,pendingTools:m,completedTools:g,agentResponse:R,setAgentResponse:I,submit:xe,executeQuickCommand:H,addPendingTool:M,updateToolStatus:A,history:C,historyPrevious:ke,historyNext:be,suggestions:T,clear:F}}const ee={name:"get_visible_panels",description:"Get the current visibility state of all panel slots (left, middle, right). Returns which panels are active in each slot and whether side panels are collapsed.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{left:{type:"object",properties:{panelId:{type:"string",description:"The ID of the panel in the left slot"},collapsed:{type:"boolean",description:"Whether the left panel is collapsed"},size:{type:"number",description:"Width percentage of the left panel"}}},middle:{type:"object",properties:{panelId:{type:"string",description:"The ID of the panel in the middle slot"},size:{type:"number",description:"Width percentage of the middle panel"}}},right:{type:"object",properties:{panelId:{type:"string",description:"The ID of the panel in the right slot"},collapsed:{type:"boolean",description:"Whether the right panel is collapsed"},size:{type:"number",description:"Width percentage of the right panel"}}},workspaceId:{type:"string",description:"The ID of the currently active workspace layout"}}},tags:["panel","layout","visibility","state","query"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:get-visibility"}},te={name:"get_panel_state",description:"Get the current state of a specific panel. Returns panel-specific state data if the panel supports state queries.",inputs:{type:"object",properties:{panelId:{type:"string",description:'The ID of the panel to query state from (e.g., "file-tree", "terminal")'}},required:["panelId"]},outputs:{type:"object",properties:{panelId:{type:"string",description:"The queried panel ID"},hasState:{type:"boolean",description:"Whether the panel supports state queries"},state:{type:"object",description:"The panel state (shape depends on the panel)"}}},tags:["panel","state","query"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:get-state"}},se={name:"list_panels_with_state",description:"Get a list of all panels that support state queries. Use this to discover which panels can be queried with get_panel_state.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{panels:{type:"array",items:{type:"object",properties:{panelId:{type:"string",description:"The panel ID"},name:{type:"string",description:"The panel display name"},description:{type:"string",description:"Description of the state this panel provides"}}},description:"List of panels that support state queries"}}},tags:["panel","state","query","discovery"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:list-state-panels"}},oe={name:"toggle_panel",description:"Collapse or expand a side panel to give more space to the main content area.",inputs:{type:"object",properties:{panel:{type:"string",enum:["left","right"],description:'Which panel to toggle: "left" or "right"'}},required:["panel"]},outputs:{type:"object",properties:{success:{type:"boolean"},panel:{type:"string"},action:{type:"string"}}},tags:["panel","layout","toggle","collapse","expand","sidebar"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:toggle"}},ae={name:"collapse_all_panels",description:"Collapse both left and right panels to maximize the main content area. Useful for focus mode.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{success:{type:"boolean"},action:{type:"string"}}},tags:["panel","layout","collapse","focus","maximize"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:collapse-all"}},re={name:"expand_all_panels",description:"Expand both left and right panels to show all content. Restores the default layout.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{success:{type:"boolean"},action:{type:"string"}}},tags:["panel","layout","expand","restore","show"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:expand-all"}},ne={name:"switch_panel",description:"Change which content is displayed in a panel slot (left, middle, or right).",inputs:{type:"object",properties:{slot:{type:"string",enum:["left","middle","right"],description:'Which slot to change: "left", "middle", or "right"'},panel:{type:"string",description:"The panel ID to display in the slot"}},required:["slot","panel"]},outputs:{type:"object",properties:{success:{type:"boolean"},slot:{type:"string"},panel:{type:"string"}}},tags:["panel","layout","switch","navigation","view"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:switch"}},le={name:"focus_panel",description:"Set focus to a specific panel slot for keyboard navigation.",inputs:{type:"object",properties:{slot:{type:"string",enum:["left","middle","right"],description:'Which slot to focus: "left", "middle", or "right"'}},required:["slot"]},outputs:{type:"object",properties:{success:{type:"boolean"},slot:{type:"string"}}},tags:["panel","focus","navigation","keyboard"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:focus"}},ie={name:"reset_layout",description:"Reset panel sizes to the default layout configuration.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{success:{type:"boolean"},action:{type:"string"}}},tags:["panel","layout","reset","default","restore"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:reset-layout"}},ue=[ee,te,se,oe,ae,re,ne,le,ie],Ee=[ee,te,se],De=[oe,ae,re,ne,le,ie],ze={id:"panel-layouts",name:"Panel Layouts",description:"Generic panel layout and state query operations",tools:ue};function fe(s){const e={};if(s.inputs.properties)for(const[t,a]of Object.entries(s.inputs.properties)){const n=a;e[t]={type:n.type||"string",description:n.description,...n.enum&&{enum:n.enum}}}return{name:s.name,description:s.description,parameters:{type:"object",properties:e,required:s.inputs.required||[]}}}function qe(s){return{functionDeclarations:s.map(fe)}}function ye(s){return{type:"function",function:{name:s.name,description:s.description,parameters:s.inputs}}}function Fe(s){return s.map(ye)}function he(s){return{name:s.name,description:s.description,input_schema:s.inputs}}function $e(s){return s.map(he)}function ge(s){return{name:s.name,description:s.description,parameters:s.inputs}}function Oe(s){return s.map(ge)}function Me(s,e={}){const{header:t="You have access to the following tools:",includeParameters:a=!0}=e,n=s.map(l=>{let i=`- ${l.name}: ${l.description}`;if(a&&l.inputs.properties){const d=Object.entries(l.inputs.properties).map(([h,p])=>{var f;const w=p,u=(f=l.inputs.required)!=null&&f.includes(h)?" (required)":"";return` - ${h}: ${w.description||w.type}${u}`}).join(`
|
|
14
|
+
`})]})};ke.displayName="AgentCommandPalette";function te(s,e){const t=s.toLowerCase(),r=e.toLowerCase();if(!t)return{score:0,matchedIndices:[]};const a=[];let l=0,i=0,d=0,m=-1;for(let c=0;c<r.length&&l<t.length;c++)r[c]===t[l]&&(a.push(c),m===c-1?(d++,i+=d*2):d=1,c===0&&(i+=10),c>0&&/[_\-\s]/.test(e[c-1])&&(i+=5),i+=1,m=c,l++);return l<t.length?null:(i-=e.length*.1,t===r&&(i+=20),r.startsWith(t)&&(i+=15),{score:i,matchedIndices:a})}function be(s,e,t=10){const r=s.replace(/^\//,"").trim();if(!r)return e.slice(0,t).map(l=>({command:l,score:0,matchedIndices:[],matchedOn:l.name}));const a=[];for(const l of e){const i=te(r,l.name);if(i){a.push({command:l,score:i.score,matchedIndices:i.matchedIndices,matchedOn:l.name});continue}if(l.aliases)for(const d of l.aliases){const m=te(r,d);if(m){a.push({command:l,score:m.score-2,matchedIndices:m.matchedIndices,matchedOn:d});break}}}return a.sort((l,i)=>i.score-l.score).slice(0,t)}const Ve=["hide sidebars","show terminal","focus editor"];function Ke({events:s,keyboard:e={key:"p",altKey:!0},config:t={},onExecuteTool:r,initialSuggestions:a=Ve,agentAvailable:l=!0,quickCommands:i=[]}={}){const[d,m]=n.useState(!1),[c,x]=n.useState(""),[u,h]=n.useState("natural"),[k,y]=n.useState("idle"),[p,f]=n.useState([]),[T,I]=n.useState([]),[L,C]=n.useState(""),[W,b]=n.useState([]),[S,w]=n.useState(-1),j=n.useMemo(()=>a,[a]),[v,P]=n.useState(-1),E=n.useMemo(()=>u!=="quick-command"||!i.length?[]:be(c,i),[c,u,i]),F=n.useMemo(()=>u==="quick-command"&&k==="idle"&&E.length>0&&c.length>0,[u,k,E.length,c.length]);n.useEffect(()=>{P(E.length>0?0:-1)},[E.length]);const Y=n.useCallback(g=>{x(g),h(g.startsWith("/")?"quick-command":"natural")},[]),Q=n.useCallback(()=>{m(!0),l?(x(""),h("natural")):(x("/"),h("quick-command")),y("idle"),f([]),I([]),C(""),w(-1),s==null||s.emit({type:"agent-command-palette:opened",source:"agent-command-palette",timestamp:Date.now(),payload:{}})},[s,l]),V=n.useCallback(()=>{m(!1),s==null||s.emit({type:"agent-command-palette:closed",source:"agent-command-palette",timestamp:Date.now(),payload:{}})},[s]),H=n.useCallback(()=>{d?V():Q()},[d,Q,V]),Z=n.useCallback(()=>{x(""),h("natural"),y("idle"),f([]),I([]),C(""),w(-1)},[]),_=n.useCallback(g=>{const A={...g,status:"pending"};return f(z=>[...z,A]),A},[]),D=n.useCallback((g,A,z,K)=>{f($=>{const O=$.find(B=>B.id===g);if(!O)return $;const M={...O,status:A,result:z,error:K};return A==="success"||A==="error"?(I(B=>[...B,M]),$.filter(B=>B.id!==g)):$.map(B=>B.id===g?M:B)})},[]),q=n.useCallback(async g=>{const A=g.replace(/^\//,"").trim().split(/\s+/),z=A[0],K=A.slice(1);if(!z)return;y("executing");const $=`quick-${Date.now()}`;_({id:$,name:z,args:{args:K}}),D($,"running");try{if(r){const M=await r(z,{args:K});D($,"success",String(M))}else D($,"success","Tool executed (no handler)");b(M=>[{query:g,timestamp:Date.now(),toolsExecuted:[z],success:!0},...M.slice(0,(t.maxHistoryEntries||50)-1)]),y("complete"),C(`Executed: ${z}`);const O=t.autoCloseDelay??1e3;O>0&&setTimeout(()=>V(),O)}catch(O){const M=O instanceof Error?O.message:"Unknown error";D($,"error",void 0,M),y("error"),C(`Error: ${M}`)}},[r,_,D,t.autoCloseDelay,t.maxHistoryEntries,V]),G=n.useCallback(()=>{if(c.trim()){if(u==="quick-command"){q(c);return}if(!l){C("Agent unavailable. Use quick commands (start with /)."),y("error");return}y("thinking"),s==null||s.emit({type:"agent-command-palette:submit",source:"agent-command-palette",timestamp:Date.now(),payload:{query:c,mode:u}}),b(g=>[{query:c,timestamp:Date.now(),toolsExecuted:[],success:!0},...g.slice(0,(t.maxHistoryEntries||50)-1)])}},[c,u,q,s,t.maxHistoryEntries,l]),Pe=n.useCallback(()=>{if(W.length===0)return;const g=S<W.length-1?S+1:S;w(g),W[g]&&(x(W[g].query),h(W[g].query.startsWith("/")?"quick-command":"natural"))},[W,S]),Ie=n.useCallback(()=>{if(S<=0){w(-1),x(""),h("natural");return}const g=S-1;w(g),W[g]&&(x(W[g].query),h(W[g].query.startsWith("/")?"quick-command":"natural"))},[W,S]),ee=n.useCallback(g=>{const{key:A="p",altKey:z=!0,ctrlKey:K=!1,metaKey:$=!1,shiftKey:O=!1}=e,M=g.altKey===z&&g.ctrlKey===K&&g.metaKey===$&&g.shiftKey===O;if((z?g.code===`Key${A.toUpperCase()}`:g.key.toLowerCase()===A.toLowerCase())&&M){const U=g.target;if(!U.closest("[data-agent-command-palette-input]")&&(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable))return;g.preventDefault(),H()}},[e,H]);n.useEffect(()=>(window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)),[ee]);const We=n.useCallback(()=>{F&&P(g=>g<E.length-1?g+1:0)},[F,E.length]),Ae=n.useCallback(()=>{F&&P(g=>g>0?g-1:E.length-1)},[F,E.length]),Re=n.useCallback(()=>{if(!F||v<0)return;const g=E[v];if(!g)return;const A=g.command;let z=`/${A.name}`;A.args&&A.args.length>0&&(z+=" "),x(z),P(-1)},[F,v,E]);return{agentAvailable:l,isOpen:d,open:Q,close:V,toggle:H,query:c,setQuery:Y,mode:u,status:k,setStatus:y,pendingTools:p,completedTools:T,agentResponse:L,setAgentResponse:C,submit:G,executeQuickCommand:q,addPendingTool:_,updateToolStatus:D,history:W,historyPrevious:Pe,historyNext:Ie,suggestions:j,clear:Z,quickCommandMatches:E,selectedAutocompleteIndex:v,autocompleteNext:We,autocompletePrevious:Ae,autocompleteAccept:Re,showAutocomplete:F}}const ie={name:"get_visible_panels",description:"Get the current visibility state of all panel slots (left, middle, right). Returns which panels are active in each slot and whether side panels are collapsed.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{left:{type:"object",properties:{panelId:{type:"string",description:"The ID of the panel in the left slot"},collapsed:{type:"boolean",description:"Whether the left panel is collapsed"},size:{type:"number",description:"Width percentage of the left panel"}}},middle:{type:"object",properties:{panelId:{type:"string",description:"The ID of the panel in the middle slot"},size:{type:"number",description:"Width percentage of the middle panel"}}},right:{type:"object",properties:{panelId:{type:"string",description:"The ID of the panel in the right slot"},collapsed:{type:"boolean",description:"Whether the right panel is collapsed"},size:{type:"number",description:"Width percentage of the right panel"}}},workspaceId:{type:"string",description:"The ID of the currently active workspace layout"}}},tags:["panel","layout","visibility","state","query"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:get-visibility"}},ce={name:"get_panel_state",description:"Get the current state of a specific panel. Returns panel-specific state data if the panel supports state queries.",inputs:{type:"object",properties:{panelId:{type:"string",description:'The ID of the panel to query state from (e.g., "file-tree", "terminal")'}},required:["panelId"]},outputs:{type:"object",properties:{panelId:{type:"string",description:"The queried panel ID"},hasState:{type:"boolean",description:"Whether the panel supports state queries"},state:{type:"object",description:"The panel state (shape depends on the panel)"}}},tags:["panel","state","query"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:get-state"}},de={name:"list_panels_with_state",description:"Get a list of all panels that support state queries. Use this to discover which panels can be queried with get_panel_state.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{panels:{type:"array",items:{type:"object",properties:{panelId:{type:"string",description:"The panel ID"},name:{type:"string",description:"The panel display name"},description:{type:"string",description:"Description of the state this panel provides"}}},description:"List of panels that support state queries"}}},tags:["panel","state","query","discovery"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:list-state-panels"}},pe={name:"toggle_panel",description:"Collapse or expand a side panel to give more space to the main content area.",inputs:{type:"object",properties:{panel:{type:"string",enum:["left","right"],description:'Which panel to toggle: "left" or "right"'}},required:["panel"]},outputs:{type:"object",properties:{success:{type:"boolean"},panel:{type:"string"},action:{type:"string"}}},tags:["panel","layout","toggle","collapse","expand","sidebar"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:toggle"}},ue={name:"collapse_all_panels",description:"Collapse both left and right panels to maximize the main content area. Useful for focus mode.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{success:{type:"boolean"},action:{type:"string"}}},tags:["panel","layout","collapse","focus","maximize"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:collapse-all"}},fe={name:"expand_all_panels",description:"Expand both left and right panels to show all content. Restores the default layout.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{success:{type:"boolean"},action:{type:"string"}}},tags:["panel","layout","expand","restore","show"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:expand-all"}},he={name:"switch_panel",description:"Change which content is displayed in a panel slot (left, middle, or right).",inputs:{type:"object",properties:{slot:{type:"string",enum:["left","middle","right"],description:'Which slot to change: "left", "middle", or "right"'},panel:{type:"string",description:"The panel ID to display in the slot"}},required:["slot","panel"]},outputs:{type:"object",properties:{success:{type:"boolean"},slot:{type:"string"},panel:{type:"string"}}},tags:["panel","layout","switch","navigation","view"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:switch"}},ye={name:"focus_panel",description:"Set focus to a specific panel slot for keyboard navigation.",inputs:{type:"object",properties:{slot:{type:"string",enum:["left","middle","right"],description:'Which slot to focus: "left", "middle", or "right"'}},required:["slot"]},outputs:{type:"object",properties:{success:{type:"boolean"},slot:{type:"string"}}},tags:["panel","focus","navigation","keyboard"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:focus"}},me={name:"reset_layout",description:"Reset panel sizes to the default layout configuration.",inputs:{type:"object",properties:{},required:[]},outputs:{type:"object",properties:{success:{type:"boolean"},action:{type:"string"}}},tags:["panel","layout","reset","default","restore"],tool_call_template:{call_template_type:"panel_event",event_type:"panel:reset-layout"}},we=[ie,ce,de,pe,ue,fe,he,ye,me],Qe=[ie,ce,de],He=[pe,ue,fe,he,ye,me],Je={id:"panel-layouts",name:"Panel Layouts",description:"Generic panel layout and state query operations",tools:we};function Se(s){const e={};if(s.inputs.properties)for(const[t,r]of Object.entries(s.inputs.properties)){const a=r;e[t]={type:a.type||"string",description:a.description,...a.enum&&{enum:a.enum}}}return{name:s.name,description:s.description,parameters:{type:"object",properties:e,required:s.inputs.required||[]}}}function Ge(s){return{functionDeclarations:s.map(Se)}}function je(s){return{type:"function",function:{name:s.name,description:s.description,parameters:s.inputs}}}function Ue(s){return s.map(je)}function Te(s){return{name:s.name,description:s.description,input_schema:s.inputs}}function Xe(s){return s.map(Te)}function Ce(s){return{name:s.name,description:s.description,parameters:s.inputs}}function Ye(s){return s.map(Ce)}function Ze(s,e={}){const{header:t="You have access to the following tools:",includeParameters:r=!0}=e,a=s.map(l=>{let i=`- ${l.name}: ${l.description}`;if(r&&l.inputs.properties){const d=Object.entries(l.inputs.properties).map(([m,c])=>{var h;const x=c,u=(h=l.inputs.required)!=null&&h.includes(m)?" (required)":"";return` - ${m}: ${x.description||x.type}${u}`}).join(`
|
|
15
15
|
`);d&&(i+=`
|
|
16
16
|
${d}`)}return i});return`${t}
|
|
17
17
|
|
|
18
|
-
${
|
|
18
|
+
${a.join(`
|
|
19
19
|
|
|
20
|
-
`)}`}const
|
|
20
|
+
`)}`}const et=({size:s=18})=>o.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),o.jsx("path",{d:"M9 3v18"})]}),tt=({size:s=18})=>o.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),o.jsx("path",{d:"M9 3v18"}),o.jsx("path",{d:"m16 15-3-3 3-3"})]}),st=({size:s=18})=>o.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),o.jsx("path",{d:"M15 3v18"})]}),ot=({size:s=18})=>o.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),o.jsx("path",{d:"M15 3v18"}),o.jsx("path",{d:"m8 9 3 3-3 3"})]}),se=({isCollapsed:s,onToggle:e,side:t="left",iconSize:r=18,style:a,shortcutHint:l="Cmd/Ctrl+B",title:i,className:d})=>{const{theme:m}=N.useTheme(),c=()=>t==="right"?s?o.jsx(st,{size:r}):o.jsx(ot,{size:r}):s?o.jsx(et,{size:r}):o.jsx(tt,{size:r}),x=()=>`${s?"Show":"Hide"} ${t==="right"?"Right Panel":"Sidebar"}${l?` (${l})`:""}`;return o.jsx("button",{onClick:e,title:i??x(),className:d,style:{background:"transparent",border:"none",color:s?m.colors.textSecondary:m.colors.primary,cursor:"pointer",padding:"6px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",width:"32px",height:"32px",...a},onMouseEnter:u=>{u.currentTarget.style.backgroundColor=m.colors.backgroundTertiary,u.currentTarget.style.color=m.colors.primary},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent",u.currentTarget.style.color=s?m.colors.textSecondary:m.colors.primary},children:c()})},rt=({size:s=14})=>o.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M8 3 4 7l4 4"}),o.jsx("path",{d:"M4 7h16"}),o.jsx("path",{d:"m16 21 4-4-4-4"}),o.jsx("path",{d:"M20 17H4"})]}),at=({size:s=14})=>o.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"m16 3 4 4-4 4"}),o.jsx("path",{d:"M20 7H4"}),o.jsx("path",{d:"m8 21-4-4 4-4"}),o.jsx("path",{d:"M4 17h16"})]}),oe=({onSwitch:s,variant:e="left-middle",iconSize:t=14,style:r,title:a,className:l})=>{const{theme:i}=N.useTheme(),d=()=>e==="left-middle"?"Switch left and middle panels":"Switch right and middle panels",m=e==="left-middle"?rt:at;return o.jsx("button",{onClick:s,title:a??d(),className:l,style:{background:"transparent",border:"none",color:i.colors.textSecondary,cursor:"pointer",padding:"6px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",width:"32px",height:"32px",...r},onMouseEnter:c=>{c.currentTarget.style.backgroundColor=i.colors.backgroundTertiary,c.currentTarget.style.color=i.colors.text},onMouseLeave:c=>{c.currentTarget.style.backgroundColor="transparent",c.currentTarget.style.color=i.colors.textSecondary},children:o.jsx(m,{size:t})})},nt=({size:s=14})=>o.jsxs("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),o.jsx("path",{d:"M3 9h18"}),o.jsx("path",{d:"M9 21V9"})]}),ve=({onConfigure:s,iconSize:e=14,style:t,title:r="Configure panel layout",className:a})=>{const{theme:l}=N.useTheme();return o.jsx("button",{onClick:s,title:r,className:a,style:{background:"transparent",border:"none",color:l.colors.textSecondary,cursor:"pointer",padding:"6px",borderRadius:"4px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s",width:"32px",height:"32px",...t},onMouseEnter:i=>{i.currentTarget.style.backgroundColor=l.colors.backgroundTertiary,i.currentTarget.style.color=l.colors.text},onMouseLeave:i=>{i.currentTarget.style.backgroundColor="transparent",i.currentTarget.style.color=l.colors.textSecondary},children:o.jsx(nt,{size:e})})},lt=({leftSidebarCollapsed:s=!1,onToggleLeftSidebar:e,showLeftSidebarControl:t=!1,rightSidebarCollapsed:r=!1,onToggleRightSidebar:a,showRightSidebarControl:l=!1,onSwitchLeftMiddlePanels:i,showSwitchLeftMiddle:d=!1,onSwitchRightMiddlePanels:m,showSwitchRightMiddle:c=!1,onConfigurePanels:x,showConfigureButton:u=!1,gap:h=4,style:k,className:y,iconSize:p,leftCollapseButtonProps:f,rightCollapseButtonProps:T,leftMiddleSwitchButtonProps:I,rightMiddleSwitchButtonProps:L,configureButtonProps:C})=>t&&e||d&&i||u&&x||c&&m||l&&a?o.jsxs("div",{className:y,style:{display:"flex",alignItems:"center",gap:`${h}px`,...k},children:[t&&e&&o.jsx(se,{isCollapsed:s,onToggle:e,side:"left",iconSize:p??18,...f}),d&&i&&o.jsx(oe,{onSwitch:i,variant:"left-middle",iconSize:p??14,...I}),u&&x&&o.jsx(ve,{onConfigure:x,iconSize:p??14,...C}),c&&m&&o.jsx(oe,{onSwitch:m,variant:"right-middle",iconSize:p??14,...L}),l&&a&&o.jsx(se,{isCollapsed:r,onToggle:a,side:"right",iconSize:p??18,...T})]}):null;Object.defineProperty(exports,"EditableConfigurablePanelLayout",{enumerable:!0,get:()=>X.EditableConfigurablePanelLayout});Object.defineProperty(exports,"ResponsiveConfigurablePanelLayout",{enumerable:!0,get:()=>X.ResponsiveConfigurablePanelLayout});Object.defineProperty(exports,"mapThemeToPanelVars",{enumerable:!0,get:()=>X.mapThemeToPanelVars});Object.defineProperty(exports,"mapThemeToTabVars",{enumerable:!0,get:()=>X.mapThemeToTabVars});exports.AgentCommandInput=re;exports.AgentCommandPalette=ke;exports.AgentResponseDisplay=ne;exports.FocusIndicator=Fe;exports.LocalStoragePersistenceAdapter=ge;exports.LocalStorageWorkspaceAdapter=xe;exports.PanelCollapseButton=se;exports.PanelConfigureButton=ve;exports.PanelControls=lt;exports.PanelSwitchButton=oe;exports.QuickCommandAutocomplete=le;exports.ToolExecutionList=ae;exports.WorkspaceLayoutService=R;exports.collapseAllPanelsTool=ue;exports.expandAllPanelsTool=fe;exports.focusPanelTool=ye;exports.fuzzyMatch=te;exports.generateToolsSystemPrompt=Ze;exports.getPanelStateTool=ce;exports.getVisiblePanelsTool=ie;exports.layoutActionTools=He;exports.layoutTools=we;exports.layoutToolsMetadata=Je;exports.listPanelsWithStateTool=de;exports.resetLayoutTool=me;exports.searchQuickCommands=be;exports.stateQueryTools=Qe;exports.switchPanelTool=he;exports.togglePanelTool=pe;exports.toolToAIFunction=Ce;exports.toolToAnthropicFormat=Te;exports.toolToGeminiFunction=Se;exports.toolToOpenAIFunction=je;exports.toolsToAIFunctions=Ye;exports.toolsToAnthropicFormat=Xe;exports.toolsToGeminiFormat=Ge;exports.toolsToOpenAIFormat=Ue;exports.useAgentCommandPalette=Ke;exports.usePanelFocus=De;exports.usePanelFocusListener=$e;exports.usePanelKeyboardShortcuts=qe;exports.usePanelPersistence=Ee;exports.useWorkspace=_e;
|
|
21
21
|
//# sourceMappingURL=index.js.map
|