@shawnstack/quickforge 1.6.8 → 1.6.9
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/README.md +10 -10
- package/dist/assets/AgentProfilesPage-5eqU0Cjk.js +1 -0
- package/dist/assets/ChatPanelHost-BNFeNRy-.js +244 -0
- package/dist/assets/{PluginsPage-3pZG7D7e.js → PluginsPage-C5OClNdT.js} +1 -1
- package/dist/assets/ScheduledTasksPage-yT10oaaM.js +2 -0
- package/dist/assets/{SettingsWorkspacePage-DWkPyGP_.js → SettingsWorkspacePage-DuXwIeLd.js} +346 -335
- package/dist/assets/SharedConversationPage-ClpUSa0F.js +1 -0
- package/dist/assets/TerminalDock-BmL-FeKv.js +2 -0
- package/dist/assets/WorkspaceInspector-yH23pXpj.js +13 -0
- package/dist/assets/abnfDiagram-VRR7QNED-Dl_Fvlqg.js +1 -0
- package/dist/assets/arc-Bhg4c0ht.js +1 -0
- package/dist/assets/architecture-TIHT7OUA-BgP-IMeo.js +1 -0
- package/dist/assets/architectureDiagram-ZJ3FMSHR-BuojN27B.js +36 -0
- package/dist/assets/array-CYkMkqnU.js +1 -0
- package/dist/assets/blockDiagram-677ZJIJ3-alDLbrR1.js +132 -0
- package/dist/assets/c4Diagram-LMCZKHZV-D1lKa4VT.js +10 -0
- package/dist/assets/channel-Rz20dKTK.js +1 -0
- package/dist/assets/chunk-2Q5K7J3B-Cb14ZF_k.js +1 -0
- package/dist/assets/chunk-32BRIVSS-CwWLNjMZ.js +1 -0
- package/dist/assets/chunk-52WLFC77-Be569m7d.js +10 -0
- package/dist/assets/chunk-5FCAYU7R-BSvoiWV1.js +1 -0
- package/dist/assets/chunk-5HE753X5-CRgsy8WS.js +1 -0
- package/dist/assets/chunk-5JV3BV7I-CdW477UR.js +1 -0
- package/dist/assets/chunk-5TONJI2A-CdtKzSmp.js +2 -0
- package/dist/assets/chunk-5VM5RSS4-BKjjssLZ.js +15 -0
- package/dist/assets/chunk-7BUUIJ7U-ByAXiXdn.js +1 -0
- package/dist/assets/chunk-BIQX33UG-DeG8SCT1.js +1 -0
- package/dist/assets/chunk-C7G6YPKG-D_zHT68Q.js +1 -0
- package/dist/assets/chunk-CQNSW5MT-CHpHoUSu.js +1 -0
- package/dist/assets/chunk-CYSBUYHQ-CRP50Vov.js +1 -0
- package/dist/assets/chunk-EMLP6XTP-DX6uQQ2v.js +1 -0
- package/dist/assets/chunk-EX3LRPZG-DAJRNkHR.js +231 -0
- package/dist/assets/chunk-FWX5IMBZ-XbM5yomC.js +2 -0
- package/dist/assets/chunk-HOUHSVGY-Ci0ljnb1.js +1 -0
- package/dist/assets/chunk-ICXQ74PX-Dy2WJ71z.js +2 -0
- package/dist/assets/chunk-JG7HCLWE-2PrkzHkt.js +2 -0
- package/dist/assets/chunk-JWPE2WC7-D32uacSM.js +1 -0
- package/dist/assets/chunk-KEIR6QF5-77hsebd7.js +161 -0
- package/dist/assets/chunk-MOJQB5TN-DIAFLtiS.js +88 -0
- package/dist/assets/chunk-MOZMSUNE-BbscOaEz.js +1 -0
- package/dist/assets/chunk-OGEWGWER-ivBVxzKe.js +1 -0
- package/dist/assets/chunk-OSBZ3O6U-frD0hkdx.js +1 -0
- package/dist/assets/chunk-PUDLZKDR-B-37Rxae.js +156 -0
- package/dist/assets/chunk-Q4XR5HBZ-Y90m2RTe.js +11 -0
- package/dist/assets/chunk-QBLGF6JB-DixBqslB.js +1 -0
- package/dist/assets/chunk-R7FJI6CG-DXS1UXn_.js +1 -0
- package/dist/assets/chunk-RYQCIY6F-n4JxhNd0.js +1 -0
- package/dist/assets/chunk-U6XO7XAA-yHlgxMmn.js +2 -0
- package/dist/assets/chunk-V7JOEXUC-Z6kuZfbl.js +206 -0
- package/dist/assets/chunk-VAUOI2AC-BOZvd2Sn.js +1 -0
- package/dist/assets/chunk-VR4S4FIN-Cs_SIQma.js +1 -0
- package/dist/assets/chunk-WYO6CB5R-CGExYbV-.js +128 -0
- package/dist/assets/chunk-XXDRQBXY-CD_EGCtT.js +1 -0
- package/dist/assets/chunk-Y2CYZVJY-CQltPwYk.js +1 -0
- package/dist/assets/chunk-YOTPTUD7-DopPXWSl.js +1 -0
- package/dist/assets/chunk-ZGVPDNZ5-CJHOeqMb.js +62 -0
- package/dist/assets/chunk-ZIRB5QZD-BBVc5mf6.js +32 -0
- package/dist/assets/classDiagram-OUVF2IWQ-C_ozTKCt.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-FOfFbbZF.js +1 -0
- package/dist/assets/cose-bilkent-JH36ORCC-DLjV-dTm.js +1 -0
- package/dist/assets/cynefin-VYW2F7L2-BzPhLtd5.js +1 -0
- package/dist/assets/cynefinDiagram-TSTJHNR4-BfH3zVS-.js +62 -0
- package/dist/assets/cytoscape.esm-DwdZnGOm.js +321 -0
- package/dist/assets/dagre-CY3D84Cl.js +1 -0
- package/dist/assets/dagre-VKFMJZFB-BIhwZCIZ.js +4 -0
- package/dist/assets/defaultLocale-Beh6XjaL.js +1 -0
- package/dist/assets/diagram-FQU43EPY-BHnzNM2w.js +3 -0
- package/dist/assets/diagram-G47NLZAW-C7-ZlmFT.js +24 -0
- package/dist/assets/diagram-NH7WQ7WH-C-P9Y7IR.js +24 -0
- package/dist/assets/diagram-OA4YK3LP-Ci5lZ_T5.js +30 -0
- package/dist/assets/diagram-WEI45ONY-C1xuK2bs.js +41 -0
- package/dist/assets/dist-DelZBZpK.js +1 -0
- package/dist/assets/ebnfDiagram-CCIWWBDH-DKQ5NWMD.js +1 -0
- package/dist/assets/erDiagram-Q63AITRT-HAWySadP.js +85 -0
- package/dist/assets/eventmodeling-45OFAUF4-BcgGbVJ-.js +1 -0
- package/dist/assets/flowDiagram-23GEKE2U-dtkzcC8E.js +1 -0
- package/dist/assets/ganttDiagram-NO4QXBWP-C1hwIcOA.js +292 -0
- package/dist/assets/gitGraph-TEB2WS4Q-VByWboBU.js +1 -0
- package/dist/assets/gitGraphDiagram-IHSO6WYX-DYUYxs1R.js +106 -0
- package/dist/assets/graphlib-CAISHZh4.js +1 -0
- package/dist/assets/icons-C7j5jdKo.js +1 -0
- package/dist/assets/index-Qof73j0o.css +3 -0
- package/dist/assets/index-_ut7awrd.js +63 -0
- package/dist/assets/info-DKCQHKI2-CZeDLZxx.js +1 -0
- package/dist/assets/infoDiagram-FWYZ7A6U-CnIL6tv4.js +2 -0
- package/dist/assets/init-Rr1s_RiX.js +1 -0
- package/dist/assets/ishikawaDiagram-FXEZZL3T-B7WXNycQ.js +70 -0
- package/dist/assets/journeyDiagram-5HDEW3XC-D4HvioyY.js +139 -0
- package/dist/assets/kanban-definition-HUTT4EX6-CDs763eS.js +89 -0
- package/dist/assets/line-ikKkQiFp.js +1 -0
- package/dist/assets/linear-GqPyxQkN.js +1 -0
- package/dist/assets/map-CJwjCvwr.js +1 -0
- package/dist/assets/{mcp-servers-dialog-VbGvNekJ.js → mcp-servers-dialog-DC2Zfojn.js} +2 -2
- package/dist/assets/mermaid-parser.core-CoE8cccr.js +4 -0
- package/dist/assets/mermaid-renderer-BmbSAmpG.js +2 -0
- package/dist/assets/mermaid.core-DlFSL90j.js +11 -0
- package/dist/assets/mindmap-definition-LN4V7U3C-DLdq0K9C.js +96 -0
- package/dist/assets/{monaco-CzxeAjEw.js → monaco-CdOyGlWD.js} +1 -1
- package/dist/assets/ordinal-CibZU3PM.js +1 -0
- package/dist/assets/{otel-DQf3c6v2.js → otel-BNGM50C-.js} +1 -1
- package/dist/assets/packet-7NZHBO7P-decrrxyX.js +1 -0
- package/dist/assets/path-BAQ3hXlG.js +1 -0
- package/dist/assets/pegDiagram-2B236MQR-Cm1kPRC2.js +1 -0
- package/dist/assets/{pi-ai-DjJwSQBQ.js → pi-ai-Cr3rpCXT.js} +2 -2
- package/dist/assets/{pi-web-ui-DqxtBlZL.js → pi-web-ui-DoRGtREc.js} +371 -371
- package/dist/assets/pie-RZYD4A2V-J1CasQZl.js +1 -0
- package/dist/assets/pieDiagram-ENE6RG2P-Df05wjjo.js +39 -0
- package/dist/assets/quadrantDiagram-ABIIQ3AL-BjCwGxJC.js +7 -0
- package/dist/assets/radar-I7S5WNFK-B-sZytUA.js +1 -0
- package/dist/assets/railroad-3IZDKUUU-BSaqNPm8.js +1 -0
- package/dist/assets/railroad-abnf-AHOZXSZD-lzZR7PxT.js +1 -0
- package/dist/assets/railroad-ebnf-EBAXGLYW-DQtz1Fh9.js +1 -0
- package/dist/assets/railroad-peg-LSFZ7HO6-CpMsuGY3.js +1 -0
- package/dist/assets/railroadDiagram-RFXS5EU6-CTUvpKkv.js +1 -0
- package/dist/assets/{react-vendor-BR9MG2D-.js → react-vendor-VqdnQHHS.js} +1 -1
- package/dist/assets/requirementDiagram-TGXJPOKE-BU1kvEku.js +84 -0
- package/dist/assets/rough.esm-Djo4Abte.js +1 -0
- package/dist/assets/sankeyDiagram-HTMAVEWB-BHmvxVqH.js +40 -0
- package/dist/assets/sequenceDiagram-DBY2YBRQ-CTpwICgg.js +162 -0
- package/dist/assets/sizeCapture-X5ZJPWSS-BbLhGaa4.js +1 -0
- package/dist/assets/{skills-dialog-B0jNVGZW.js → skills-dialog-Mnj8fZwq.js} +1 -1
- package/dist/assets/src-B4Tvg3gT.js +1 -0
- package/dist/assets/stateDiagram-2N3HPSRC-BxuDwIgT.js +1 -0
- package/dist/assets/stateDiagram-v2-6OUMAXLB-BGLshxcY.js +1 -0
- package/dist/assets/swimlanes-5IMT3BWC-EkZsiylV.js +2 -0
- package/dist/assets/swimlanesDiagram-G3AALYLV-CqdqxA-b.js +8 -0
- package/dist/assets/timeline-definition-FHXFAJF6-C9ewOCTa.js +120 -0
- package/dist/assets/treeView-QDETBFTQ-Byb71heW.js +1 -0
- package/dist/assets/treemap-6X3UGDF4-CMV1SJsq.js +1 -0
- package/dist/assets/vennDiagram-L72KCM5P-CR49Y4Lp.js +34 -0
- package/dist/assets/wardley-OPB4EBWU-DtCHtr2V.js +1 -0
- package/dist/assets/wardleyDiagram-EHGQE667-Cn0GgwWi.js +78 -0
- package/dist/assets/xychartDiagram-FW5EYKEG-DlmPNAvd.js +7 -0
- package/dist/index.html +8 -8
- package/package.json +2 -1
- package/server/agent-manager.mjs +174 -9
- package/server/agent-profile-files.mjs +86 -6
- package/server/agent-profile-schema.mjs +197 -0
- package/server/agent-profiles.mjs +172 -41
- package/server/auto-compaction.mjs +2 -2
- package/server/project-route-context.mjs +25 -0
- package/server/routes/agent-profiles.mjs +9 -3
- package/server/routes/project.mjs +6 -10
- package/server/routes/workspace.mjs +184 -11
- package/server/storage.mjs +34 -0
- package/server/subagents.mjs +64 -0
- package/server/tools/definitions.mjs +17 -1
- package/dist/assets/AgentProfilesPage-R7N7eDq5.js +0 -1
- package/dist/assets/ChatPanelHost-C4orgd5l.js +0 -242
- package/dist/assets/ScheduledTasksPage-BAqoK4xk.js +0 -2
- package/dist/assets/SharedConversationPage-C-1n_MmB.js +0 -1
- package/dist/assets/TerminalDock-B6KAXkIU.js +0 -2
- package/dist/assets/WorkspaceInspector-CkXyD_k4.js +0 -3
- package/dist/assets/WorkspaceReaderDialog-Dp2QAwBo.js +0 -1
- package/dist/assets/diff-line-counts-Dm5kKQOo.js +0 -10
- package/dist/assets/icons-DHoaB5uq.js +0 -1
- package/dist/assets/index-C77QCHE9.css +0 -3
- package/dist/assets/index-CZb_mGGF.js +0 -63
- package/dist/assets/useAppTheme-DsabFF9D.js +0 -1
- /package/dist/assets/{plugin-api-Ds5xGIL7.js → plugin-api-BbUkYm3Y.js} +0 -0
- /package/dist/assets/{xterm-aPHkK8RR.js → xterm-CGiQzDiR.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Vt as t,ht as n,i as r}from"./icons-C7j5jdKo.js";import{n as i}from"./react-vendor-VqdnQHHS.js";import{S as a,b as o,d as s,f as c,p as l,u}from"./pi-web-ui-DoRGtREc.js";import{U as d}from"./pi-ai-Cr3rpCXT.js";import{t as f}from"./logger-B65Akg8A.js";import{B as p,G as m,J as h,U as g,W as _,Y as v,Z as y,c as b,ct as x,l as S,lt as C,ot as w,pt as T,q as E,s as D,x as O}from"./index-_ut7awrd.js";import{ChatPanelHost as k}from"./ChatPanelHost-BNFeNRy-.js";var A=e(t(),1),j=`quickforgeClientMessageId`;function M(e){let t=e?.metadata;return t&&typeof t==`object`&&!Array.isArray(t)?t:void 0}function N(e){let t=M(e)?.[j];return typeof t==`string`&&t?t:void 0}function P(){return`qfcm_${typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function F(e){let t=N(e);if(t)return{message:e,clientMessageId:t};let n=P();return{message:{...e,metadata:{...M(e),[j]:n}},clientMessageId:n}}function I(e){return typeof e==`string`?e:Array.isArray(e)?e.filter(e=>e&&typeof e==`object`&&e.type===`text`).map(e=>e.text).filter(e=>typeof e==`string`).join(``):``}function L(e,t){if(!e||!t||e.role!==t.role)return!1;let n=N(e),r=N(t);return n&&r?n===r:I(e.content)===I(t.content)}async function R(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.body?{"content-type":`application/json`}:void 0,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Request failed: ${n.status}`);return r}var z=class e{state;streamFn=d;getApiKey;sessionId;shareId;permission;listeners=new Set;eventSource=null;disposed=!1;reconnectTimer=null;reconnectDelay=1e3;baseUrl=``;syncingThinkingLevel=!1;planMode=!1;onPlanModeConsumed;constructor(e,t){this.shareId=e,this.sessionId=t.sessionId||t.id||e,this.permission=t.permission??`read`;let n={systemPrompt:t.systemPrompt??``,model:t.model??{provider:`shared`,id:`shared`},thinkingLevel:t.thinkingLevel??`off`,messages:t.messages?.slice()??[],tools:t.tools??[],isStreaming:!!t.isStreaming,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:t.errorMessage,contextCompaction:t.contextCompaction??null,contextUsage:t.contextUsage??null};this.state=new Proxy(n,{set:(e,t,n)=>{let r=e[t];return e[t]=n,t===`thinkingLevel`&&!this.syncingThinkingLevel&&n!==r&&this.updateThinkingLevel(n).catch(e=>{f.error(`Failed to update shared thinking level:`,e)}),!0}}),this.connectEvents()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setNextPromptCapabilities(){}setPlanMode(e,t){this.planMode=e,this.onPlanModeConsumed=e?t:void 0}async prompt(e){if(this.disposed||this.permission!==`operate`)return;let{message:t,clientMessageId:n}=F(this.normalizeInput(e)),r=this.planMode?{type:`plan`}:void 0;if(this.planMode){this.planMode=!1;let e=this.onPlanModeConsumed;this.onPlanModeConsumed=void 0,e?.()}this.state.messages=[...this.state.messages,t],this.emit({type:`message_start`,message:t}),this.state.isStreaming||(this.state.isStreaming=!0,this.state.errorMessage=void 0,this.emit({type:`agent_start`}));try{await R(`/api/shared/${encodeURIComponent(this.shareId)}/message`,{method:`POST`,body:JSON.stringify({message:t,clientMessageId:n,command:r})})}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.state.isStreaming=!1,this.emit({type:`error`,error:t}),this.emit({type:`agent_end`,messages:this.state.messages}),e}}async updateModel(e){if(!(this.disposed||this.permission!==`operate`)){this.state.model=e;try{let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/model`,{method:`POST`,body:JSON.stringify({model:e})});t.model&&(this.state.model=t.model)}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.emit({type:`error`,error:t}),e}}}async updateThinkingLevel(e){if(!(this.disposed||this.permission!==`operate`)){!this.syncingThinkingLevel&&this.state.thinkingLevel!==e&&(this.state.thinkingLevel=e);try{let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/thinking-level`,{method:`POST`,body:JSON.stringify({thinkingLevel:e})});t.thinkingLevel&&(this.state.thinkingLevel=t.thinkingLevel)}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.emit({type:`error`,error:t}),e}}}abort(){this.permission===`operate`&&fetch(`/api/shared/${encodeURIComponent(this.shareId)}/abort`,{method:`POST`}).catch(e=>{f.error(`Failed to abort shared conversation:`,e)})}steer(){}followUp(){}reset(){this.state.messages=[],this.state.errorMessage=void 0,this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.state.pendingToolCalls=new Set}async rollback(e){if(this.permission!==`operate`)return;let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/rollback`,{method:`POST`,body:JSON.stringify({messageIndex:e})});return this.applyState(t.session),this.emit({type:`messages_replaced`,messages:this.state.messages}),t}dispose(){this.disposed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.eventSource?.close(),this.eventSource=null,this.listeners.clear()}static async loadState(e){return R(`/api/shared/${encodeURIComponent(e)}/session`)}static async create(t){return new e(t,await e.loadState(t))}normalizeInput(e){return typeof e==`string`?{role:`user`,content:e,timestamp:Date.now()}:Array.isArray(e)?[...e].reverse().find(e=>e.role===`user`||e.role===`user-with-attachments`)??e[e.length-1]:e}connectEvents(){this.disposed||(this.eventSource?.close(),this.baseUrl=``,this.openEventSource())}openEventSource(){if(this.disposed)return;let e=`${this.baseUrl}/api/shared/${encodeURIComponent(this.shareId)}/events`;this.eventSource=new EventSource(e,{withCredentials:!0}),this.eventSource.onopen=()=>{this.reconnectDelay=1e3};let t=[`state`,`agent_start`,`agent_end`,`message_start`,`message_end`,`turn_start`,`turn_end`,`message_update`,`tool_execution_start`,`tool_execution_update`,`tool_execution_end`,`error`,`title_updated`,`messages_replaced`,`auto_compact_completed`],n=e=>t=>{try{let n=JSON.parse(t.data);this.handleEvent(e?{type:e,...n}:n)}catch{}};this.eventSource.onmessage=n();for(let e of t)this.eventSource.addEventListener(e,n(e));this.eventSource.onerror=()=>{this.eventSource?.close(),this.eventSource=null,this.scheduleReconnect()}}scheduleReconnect(){this.disposed||this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4),this.openEventSource()},this.reconnectDelay))}handleEvent(e){if(e.type){switch(e.type){case`state`:this.applyState(e);break;case`agent_start`:this.state.isStreaming=!0,this.state.errorMessage=void 0;break;case`agent_end`:this.state.isStreaming=!1,this.state.streamingMessage=void 0;break;case`message_start`:if(e.message){let t=this.state.messages.findIndex(t=>L(t,e.message));if(t>=0){let n=this.state.messages.slice();n[t]=e.message,this.state.messages=n}else this.state.messages=[...this.state.messages,e.message];this.state.contextUsage=null}break;case`message_update`:e.message&&(this.state.streamingMessage=e.message);break;case`message_end`:e.message&&(this.state.messages=h(this.state.messages,e.message)),this.state.contextUsage=`contextUsage`in e?e.contextUsage:null,this.state.streamingMessage=void 0;break;case`messages_replaced`:e.messages&&(this.state.messages=e.messages,this.state.streamingMessage=void 0),`contextCompaction`in e&&(this.state.contextCompaction=e.contextCompaction),`contextUsage`in e&&(this.state.contextUsage=e.contextUsage);break;case`auto_compact_completed`:`contextCompaction`in e&&(this.state.contextCompaction=e.contextCompaction),`contextUsage`in e&&(this.state.contextUsage=e.contextUsage);break;case`tool_execution_start`:{let t=e;t.toolCallId&&(this.state.messages=v(this.state.messages,E(t),!0),this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId]));break}case`tool_execution_update`:{let t=e;this.state.messages=v(this.state.messages,t,!0),t.toolCallId&&(this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId]));break}case`tool_execution_end`:{let t=e;if(this.state.messages=v(this.state.messages,t,!1),t.toolCallId){let e=new Set(this.state.pendingToolCalls);e.delete(t.toolCallId),this.state.pendingToolCalls=e}break}case`error`:this.state.errorMessage=typeof e.error==`string`?e.error:`Unknown error`,this.state.isStreaming=!1;break}this.emit(e)}}applyState(e){this.sessionId=e.sessionId||e.id||this.sessionId,e.messages&&(this.state.messages=e.messages,this.state.contextUsage=e.contextUsage===void 0?null:e.contextUsage),e.systemPrompt!==void 0&&(this.state.systemPrompt=e.systemPrompt),e.model&&(this.state.model=e.model),e.thinkingLevel&&(this.syncingThinkingLevel=!0,this.state.thinkingLevel=e.thinkingLevel,this.syncingThinkingLevel=!1),e.tools&&(this.state.tools=e.tools),e.isStreaming!==void 0&&(this.state.isStreaming=!!e.isStreaming),e.errorMessage!==void 0&&(this.state.errorMessage=e.errorMessage),e.contextCompaction!==void 0&&(this.state.contextCompaction=e.contextCompaction),e.contextUsage!==void 0&&(this.state.contextUsage=e.contextUsage)}emit(e){for(let t of this.listeners)try{t(e)}catch{}}},B=i();function V(e){return{id:`shared-${e.provider}`,name:e.provider,type:e.api,baseUrl:e.baseUrl??``,models:[e]}}async function H(e,t){try{let t=await b(e);if(t.providers?.length)return t.providers}catch{}return t?[V(t)]:[]}function U(e,t){let n=t.model??{provider:`shared`,id:`shared`};return new z(e,{...t,model:n,thinkingLevel:t.thinkingLevel??y(n)})}function W(e,t){let n={settings:new u,providerKeys:new c,sessions:new s,customProviders:new l},r=new w(``,{blockedStores:[`sessions`,`provider-keys`],fakeProviderKeys:t?[t.provider]:void 0,storeOverrides:t?{"custom-providers":{keys:async()=>(await H(e,t)).map(e=>e.name),get:async n=>(await H(e,t)).find(e=>e.name===n)??null,has:async n=>(await H(e,t)).some(e=>e.name===n)}}:void 0});n.settings.setBackend(r),n.providerKeys.setBackend(r),n.sessions.setBackend(r),n.customProviders.setBackend(r),a(new o(n.settings,n.providerKeys,n.sessions,n.customProviders,r))}function G({shareId:e}){let[t,i]=(0,A.useState)(``),[a,o]=(0,A.useState)(null),[s,c]=(0,A.useState)(`read`),[l,u]=(0,A.useState)(`QuickForge 分享对话`),[d,h]=(0,A.useState)(),[v,y]=(0,A.useState)(!1),[b,w]=(0,A.useState)(),E=(0,A.useRef)(!1),j=s===`operate`,M=!!a,N=!!a?.state.tools?.length;(0,A.useEffect)(()=>{W(e,a?.state.model)},[a?.state.model,e]),(0,A.useEffect)(()=>()=>a?.dispose(),[a]);let P=(0,A.useCallback)(async(n=t.trim())=>{h(void 0),y(!0);try{let t=await S(e,n);c(t.permission),u(t.title||t.share.titleSnapshot||`QuickForge 分享对话`);let r=await z.loadState(e);W(e,r.model),o(U(e,r))}catch(e){h(e instanceof Error?e.message:`Failed to unlock shared conversation`)}finally{y(!1)}},[t,e]);(0,A.useEffect)(()=>{if(M||v||E.current)return;E.current=!0;let t=window.setTimeout(()=>{(async()=>{try{(await D(e)).share.hasPassword||await P(``)}catch(e){h(e instanceof Error?e.message:`Failed to load shared conversation`)}})()},0);return()=>window.clearTimeout(t)},[v,e,P,M]);let F=(0,A.useCallback)(async e=>{await g(e)},[]),I=(0,A.useCallback)(async()=>{if(!(!a||a.permission!==`operate`))try{let t=(await H(e,a.state.model)).flatMap(e=>e.models??[]);if(!t.length)return;O(a.state.model,t,t=>{!t.reasoning&&a.state.thinkingLevel!==`off`&&a.updateThinkingLevel(`off`).catch(e=>{f.error(`Failed to update shared thinking level:`,e)}),W(e,t),a.updateModel(t).catch(e=>{h(e instanceof Error?e.message:`Failed to update model`)})},void 0,{thinkingLevel:a.state.thinkingLevel,onThinkingLevelSelect:e=>{a.updateThinkingLevel(e).catch(e=>{f.error(`Failed to update shared thinking level:`,e),h(e instanceof Error?e.message:`Failed to update thinking level`)})}})}catch(e){h(e instanceof Error?e.message:`Failed to load models`)}},[a,e]),L=(0,A.useCallback)(e=>{w(t=>t?.id===e?void 0:t)},[]),R=(0,A.useCallback)(async e=>{if(!a||a.permission!==`operate`)return;if(h(void 0),a.state.isStreaming){p(T(`generationStillRunning`));return}let t=m(a.state.messages,e),n=t>=0?a.state.messages[t]:void 0;if(!n){p(T(`noConversationTurnToRollback`));return}try{await a.rollback(e),w({id:Date.now(),sessionId:a.sessionId,text:_(n),attachments:n.role===`user-with-attachments`?n.attachments:void 0})}catch(e){h(e instanceof Error?e.message:`Failed to roll back`)}},[a]);return M?(0,B.jsxs)(`div`,{className:`flex h-screen min-h-0 flex-col bg-background text-foreground`,children:[(0,B.jsx)(`header`,{className:C(`shrink-0 border-b px-4 py-3`,j?`border-red-300 bg-red-50 text-red-950`:`border-border bg-background`),children:(0,B.jsxs)(`div`,{className:`mx-auto flex max-w-4xl items-start gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:l}),(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs`,children:[(0,B.jsxs)(`span`,{className:C(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-medium`,j?`bg-red-100 text-red-700`:`bg-muted text-muted-foreground`),children:[j?(0,B.jsx)(r,{className:`size-3.5`}):null,j?`高危可操作`:`只读分享`]}),(0,B.jsx)(`span`,{className:C(j?`text-red-800`:`text-muted-foreground`),children:j?`正在操作分享者的原始对话`:`只能查看,不能发送或修改`})]}),j?null:(0,B.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`界面与正常对话保持一致`})]}),(0,B.jsxs)(x,{variant:`ghost`,size:`sm`,className:C(`shrink-0`,j?`text-red-700 hover:bg-red-100 hover:text-red-800`:void 0),onClick:()=>void g(window.location.href),"aria-label":j?`复制高危分享链接`:`复制分享链接`,title:j?`复制高危分享链接`:`复制分享链接`,children:[(0,B.jsx)(n,{className:`size-4`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:j?`复制高危链接`:`复制链接`})]})]})}),d?(0,B.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 py-2 text-sm text-destructive`,children:d}):null,(0,B.jsx)(k,{agent:a,revision:0,agentAccessMode:N?`full-access`:`default`,workspaceToolsEnabled:N,onModelSelect:I,onAccessModeChange:()=>void 0,onRollbackFromMessage:R,onRetryFromMessage:()=>void 0,onCopyAnswer:F,onForkFromMessage:()=>void 0,onApproveToolCall:()=>void 0,onRejectToolCall:()=>void 0,disableFork:!0,rollbackConfirmTitle:T(`sharedRollbackConfirmTitle`),rollbackConfirmDescription:T(`sharedRollbackConfirm`),readOnly:!j,restoredDraft:b,onRestoredDraftConsumed:L,bypassClientApiKeyCheck:!0})]}):(0,B.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-6 text-foreground`,children:(0,B.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-border bg-background p-6 shadow-quickforge`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,B.jsx)(r,{className:`size-5 text-amber-500`}),`QuickForge 局域网对话分享`]}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`如果分享者设置了密码,请输入密码。未设置密码的链接会自动打开。`}),(0,B.jsx)(`input`,{type:`password`,value:t,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P()},className:`mt-5 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-primary`,placeholder:`密码`,autoFocus:!0}),d?(0,B.jsx)(`div`,{className:`mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}):null,(0,B.jsx)(x,{className:`mt-5 w-full`,onClick:()=>void P(),disabled:v||!t.trim(),children:v?T(`loading`):`用密码打开分享对话`})]})})}export{G as SharedConversationPage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{At as t,B as n,C as r,N as i,R as a,Vt as o,c as s,n as c}from"./icons-C7j5jdKo.js";import{n as l}from"./react-vendor-VqdnQHHS.js";import{A as u,N as d,T as f,ct as p,lt as m,pt as h}from"./index-_ut7awrd.js";import{n as ee,t as g}from"./xterm-CGiQzDiR.js";var _=e(o(),1);async function v(e,t){let n=await fetch(e,{cache:`no-store`,...t}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Request failed: ${n.status}`);return r}function y(){return v(`/api/terminal/capabilities`)}function b(e){return v(`/api/terminal/sessions${e?`?projectId=${encodeURIComponent(e)}`:``}`)}function x(e){return v(`/api/terminal/sessions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})}function S(e){return v(`/api/terminal/sessions/${encodeURIComponent(e)}`,{method:`DELETE`})}function C(e,t){return v(`/api/terminal/sessions/${encodeURIComponent(e)}/input`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({data:t})})}function w(){return``}function te(){let e=w();if(e){let t=new URL(e);return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString().replace(/\/$/,``)}return`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}`}function T(){let[e,t]=(0,_.useState)(()=>f());return(0,_.useEffect)(()=>{if(typeof document>`u`)return;let e=document.documentElement,n=()=>t(f());n();let r=new MutationObserver(n);return r.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>r.disconnect()},[]),e}var E=l(),D={light:{background:`#ffffff`,foreground:`#1f2937`,cursor:`#1f2937`,selectionBackground:`#dbeafe`},dark:{background:`#171717`,foreground:`#e5e7eb`,cursor:`#e5e7eb`,selectionBackground:`#3f3f46`}};function ne({session:e,active:t,height:n,onReady:r,onExited:i,onConnectionError:a}){let o=T(),s=D[o],c=(0,_.useRef)(null),l=(0,_.useRef)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(null),m=(0,_.useRef)(null),v=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=c.current;if(!t)return;let n=!1,o=!1,_=!1,y=!1,b=t=>{n||_||y||(y=!0,a(e.id,t))},x=d(),S=new ee({cursorBlink:!0,convertEol:!1,fontFamily:getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,fontSize:x.fontSize,lineHeight:x.lineHeight,scrollback:5e3,theme:s}),C=new g;S.loadAddon(C),S.open(t),S.writeln(`\x1b[2mConnected to ${e.cwd}\x1b[0m`),l.current=S,f.current=C;let w=()=>{if(t.isConnected)try{C.fit();let{cols:e,rows:t}=S,n=p.current;n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify({type:`resize`,cols:e,rows:t}))}catch{}},T=new WebSocket(`${te()}/api/terminal/sessions/${encodeURIComponent(e.id)}/ws`);p.current=T,T.addEventListener(`open`,()=>{o=!0,y=!1,a(e.id,void 0),m.current=S.onData(e=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:`input`,data:e}))}),window.setTimeout(w,0)}),T.addEventListener(`message`,t=>{try{let n=JSON.parse(String(t.data));n.type===`ready`?r(e.id):n.type===`output`?S.write(n.data):n.type===`exit`?(_=!0,S.writeln(``),S.writeln(`\x1b[33m[process exited with code ${n.exitCode??`unknown`}]\x1b[0m`),i(e.id)):n.type===`error`&&S.writeln(`\x1b[31m${n.message}\x1b[0m`)}catch{}}),T.addEventListener(`error`,()=>{b(h(o?`terminalConnectionClosedUnexpectedly`:`terminalConnectionFailed`))}),T.addEventListener(`close`,e=>{m.current?.dispose(),m.current=null,!(n||_)&&(!e.wasClean||e.code!==1e3)&&b(h(o?`terminalConnectionClosedUnexpectedly`:`terminalConnectionFailed`))});let E=new ResizeObserver(()=>w());E.observe(t),v.current=E;let D=()=>{let e=d();S.options.fontSize=e.fontSize,S.options.lineHeight=e.lineHeight,window.setTimeout(w,0)};return window.addEventListener(u,D),window.setTimeout(w,50),()=>{n=!0,window.removeEventListener(u,D),E.disconnect(),v.current=null,m.current?.dispose(),m.current=null,T.close(),p.current=null,S.dispose(),l.current=null,f.current=null}},[o,a,i,r,e.cwd,e.id,s]),(0,_.useEffect)(()=>{if(!t)return;let e=f.current,n=l.current;window.setTimeout(()=>{try{e?.fit(),n?.focus()}catch{}},0)},[t,n]),(0,E.jsx)(`div`,{className:t?`h-full min-h-0 w-full pl-2 md:pl-3`:`hidden`,"aria-hidden":!t,children:(0,E.jsx)(`div`,{ref:c,className:`h-full min-h-0 w-full`})})}var re=180,ie=.7,ae=320;function O(e,t){let n=t?t.name:`Terminal`,r=new Set(e.map(e=>e.name));if(n!==`Terminal`&&!r.has(n))return n;let i=1;for(;r.has(`${n} ${i}`);)i+=1;return`${n} ${i}`}function k(e,t){let n=e?.terminalShellProfiles||[],r=t||e?.defaultTerminalShellProfileId||``;return n.find(e=>e.id===r)||n[0]}function A({project:e,onCollapse:o,pendingCommand:l,onPendingCommandHandled:u,variant:d=`dock`,singleSession:f=!1,panelInstanceId:ee,panelSessionId:g,onPanelSessionReady:v}){let[w,te]=(0,_.useState)(null),[T,D]=(0,_.useState)([]),[A,j]=(0,_.useState)(),[M,oe]=(0,_.useState)(ae),[N,se]=(0,_.useState)(!0),[P,ce]=(0,_.useState)(!1),[le,F]=(0,_.useState)(),[ue,I]=(0,_.useState)({}),[L,R]=(0,_.useState)(!1),[z,de]=(0,_.useState)(!1),B=(0,_.useRef)(!1),V=(0,_.useRef)(!1),H=(0,_.useRef)(new Set),fe=(0,_.useRef)(l),U=(0,_.useRef)(new Set),W=(0,_.useRef)(new Set),G=(0,_.useRef)(new Map),K=(0,_.useRef)(!0),pe=(0,_.useRef)(v),[me,he]=(0,_.useState)(()=>new Set),q=(0,_.useRef)(null),ge=(0,_.useRef)(null),J=e?.id,Y=d===`panel`&&!!ee,X=(0,_.useMemo)(()=>T.find(e=>e.id===A)??T[0],[A,T]);(0,_.useEffect)(()=>{fe.current=l},[l]),(0,_.useEffect)(()=>{pe.current=v},[v]),(0,_.useEffect)(()=>()=>{K.current=!1},[]);let _e=(0,_.useCallback)(async()=>{let e=await b(J);return D(e.sessions),j(t=>t&&e.sessions.some(e=>e.id===t)?t:e.sessions[0]?.id),e.sessions},[J]),ve=(0,_.useCallback)(async(e,t)=>{if(B.current)return;let n=k(w,t);B.current=!0,ce(!0),F(void 0),I({});try{let t=await x({projectId:J,name:O(e,n),cols:120,rows:30,shellProfileId:n?.id,shellProfileName:n?.name});D(e=>[...e,t]),j(t.id)}catch(e){F(e instanceof Error?e.message:h(`terminalCreateFailed`))}finally{B.current=!1,ce(!1)}},[w,J]);(0,_.useEffect)(()=>{let e=!1;return(async()=>{se(!0),F(void 0);try{let[t,n]=await Promise.all([y(),b(J)]);if(e)return;if(te(t),t.enabled&&Y&&g&&n.sessions.some(e=>e.id===g)){V.current=!0,D(n.sessions),j(g);return}if(t.enabled&&Y&&!V.current){V.current=!0;let r=k(t);try{let t=await x({projectId:J,name:O(n.sessions,r),cols:120,rows:30,shellProfileId:r?.id,shellProfileName:r?.name});if(e){S(t.id).catch(()=>{});return}D([...n.sessions,t]),j(t.id),pe.current?.(t.id);return}catch(t){e||F(t instanceof Error?t.message:h(`terminalCreateFailed`))}}if(D(n.sessions),j(n.sessions[0]?.id),t.enabled&&n.sessions.length===0&&!fe.current){let n=k(t);x({projectId:J,name:O([],n),cols:120,rows:30,shellProfileId:n?.id,shellProfileName:n?.name}).then(t=>{if(e){S(t.id).catch(()=>{});return}D([t]),j(t.id)}).catch(t=>{e||F(t instanceof Error?t.message:h(`terminalCreateFailed`))})}}catch(t){e||F(t instanceof Error?t.message:h(`terminalUnavailable`))}finally{e||se(!1)}})(),()=>{e=!0}},[Y,g,J]),(0,_.useEffect)(()=>{if(!L)return;let e=e=>{ge.current?.contains(e.target)||R(!1)},t=e=>{e.key===`Escape`&&R(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[L]),(0,_.useEffect)(()=>{if(!z)return;let e=e=>{e.key===`Escape`&&de(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[z]),(0,_.useEffect)(()=>{if(!l||H.current.has(l.id)||G.current.has(l.id)||U.current.has(l.id)||N||P||!w)return;if(!w.enabled){H.current.add(l.id),window.setTimeout(()=>{F(w.reason||h(`terminalUnavailable`)),u?.(l.id)},0);return}let e=X&&!X.exited?X:T.find(e=>!e.exited);if(e){G.current.set(l.id,e.id),window.setTimeout(()=>{K.current&&j(e.id)},0);return}U.current.add(l.id),window.setTimeout(()=>{K.current&&F(void 0)},0);let t=k(w);x({projectId:J,name:O(T,t),cols:120,rows:30,shellProfileId:t?.id,shellProfileName:t?.name}).then(e=>{if(!K.current){S(e.id).catch(()=>{});return}G.current.set(l.id,e.id),D(t=>t.some(t=>t.id===e.id)?t:[...t,e]),j(e.id)}).catch(e=>{K.current&&(F(e instanceof Error?e.message:h(`terminalCommandExecuteFailed`)),H.current.add(l.id),u?.(l.id))}).finally(()=>{U.current.delete(l.id)})},[X,w,P,N,u,l,J,T]),(0,_.useEffect)(()=>{if(!l||H.current.has(l.id)||W.current.has(l.id))return;let e=G.current.get(l.id),t=e?T.find(t=>t.id===e):X&&!X.exited?X:T.find(e=>!e.exited);!t||t.exited||!me.has(t.id)||(W.current.add(l.id),window.setTimeout(()=>{K.current&&(j(t.id),F(void 0))},0),(async()=>{try{if(l.execute){let e=l.command.split(`
|
|
2
|
+
`),n=e.flatMap((t,n)=>n<e.length-1?[t,`\r`]:[t]);n.push(`\r`),await C(t.id,n.join(``))}else await C(t.id,l.command)}catch(e){K.current&&F(e instanceof Error?e.message:h(`terminalCommandExecuteFailed`))}finally{H.current.add(l.id),W.current.delete(l.id),G.current.delete(l.id),K.current&&u?.(l.id)}})())},[X,u,l,me,T]);let ye=async e=>{F(void 0),I(t=>{if(!t[e])return t;let n={...t};return delete n[e],n});let t=T.filter(t=>t.id!==e);D(t),A===e&&j(t[0]?.id);try{await S(e)}catch(e){F(e instanceof Error?e.message:h(`terminalCloseFailed`)),_e().catch(()=>{})}},be=(0,_.useCallback)(e=>{D(t=>t.map(t=>t.id===e?{...t,exited:!0}:t)),he(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),xe=(0,_.useCallback)(e=>{he(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),Se=(0,_.useCallback)((e,t)=>{I(n=>{if(!t){if(!n[e])return n;let t={...n};return delete t[e],t}return n[e]===t?n:{...n,[e]:t}})},[]),Ce=e=>{q.current={startY:e.clientY,startHeight:M},e.currentTarget.setPointerCapture(e.pointerId)},we=e=>{let t=q.current;if(!t)return;let n=Math.max(re,Math.floor(window.innerHeight*ie));oe(Math.min(n,Math.max(re,t.startHeight+t.startY-e.clientY)))},Te=e=>{q.current=null;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}},Z=w?.terminalShellProfiles||[],Ee=w?.defaultTerminalShellProfileId||``,De=Z.find(e=>e.id===Ee)||Z[0],Oe=!!(w&&T.length>=w.maxSessions),ke=P||Oe,Ae=X?ue[X.id]:void 0,je=Y&&X?[X]:T,Q=le??Ae,$=d===`panel`,Me=$&&f,Ne=$?void 0:z?Q?`calc(100% - 4.25rem)`:`calc(100% - 2.25rem)`:Q?M-72:M-45;return(0,E.jsxs)(`div`,{className:m($?`flex min-h-0 flex-1 flex-col bg-background`:`shrink-0 border-t border-border bg-background`,z&&`quickforge-terminal-fullscreen z-40 flex flex-col border-t-0`),style:z||$?void 0:{height:M},children:[!z&&!$?(0,E.jsx)(`div`,{className:`h-1 cursor-row-resize bg-transparent hover:bg-border`,onPointerDown:Ce,onPointerMove:we,onPointerUp:Te,onPointerCancel:Te}):null,(0,E.jsxs)(`div`,{className:`flex h-9 items-center gap-1 border-b border-border px-2`,children:[(0,E.jsx)(s,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,E.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto`,children:je.map(e=>{let t=m(`flex max-w-44 shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground/72`,X?.id===e.id&&`bg-muted/28 text-foreground/90`);return Me?(0,E.jsxs)(`div`,{className:t,title:`${e.name} — ${e.cwd}`,children:[(0,E.jsx)(`span`,{className:m(`size-1.5 rounded-full`,e.exited?`bg-muted-foreground/40`:`bg-emerald-500/80`)}),(0,E.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id):(0,E.jsxs)(`button`,{type:`button`,className:m(t,`hover:bg-muted/20 hover:text-foreground/85`),onClick:()=>j(e.id),title:`${e.name} — ${e.cwd}`,children:[(0,E.jsx)(`span`,{className:m(`size-1.5 rounded-full`,e.exited?`bg-muted-foreground/40`:`bg-emerald-500/80`)}),(0,E.jsx)(`span`,{className:`truncate`,children:e.name}),(0,E.jsx)(`span`,{role:`button`,tabIndex:0,className:`ml-1 rounded-sm p-0.5 opacity-60 hover:bg-background hover:opacity-100`,onClick:t=>{t.stopPropagation(),ye(e.id)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ye(e.id))},"aria-label":h(`terminalCloseSession`,{name:e.name}),children:(0,E.jsx)(c,{className:`size-3`})})]},e.id)})}),Me?null:(0,E.jsxs)(`div`,{className:`relative shrink-0`,ref:ge,children:[(0,E.jsxs)(`div`,{className:`flex items-center overflow-hidden rounded-md border border-border bg-background`,children:[(0,E.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center text-foreground/85 transition-colors hover:bg-muted/20 disabled:pointer-events-none disabled:opacity-50`,onClick:()=>void ve(T),disabled:ke,title:De?h(`terminalNewWithProfile`,{name:De.name}):h(`terminalNew`),"aria-label":h(`terminalNew`),children:P?(0,E.jsx)(n,{className:`size-3.5 animate-spin`}):(0,E.jsx)(r,{className:`size-3.5`})}),Z.length>0?(0,E.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center border-l border-border text-muted-foreground/72 transition-colors hover:bg-muted/20 hover:text-foreground/85 disabled:pointer-events-none disabled:opacity-50`,onClick:()=>R(e=>!e),disabled:ke,title:h(`terminalSelectShell`),"aria-label":h(`terminalSelectShell`),"aria-expanded":L,children:(0,E.jsx)(t,{className:`size-3.5`})}):null]}),L?(0,E.jsxs)(`div`,{className:m(`absolute right-0 z-30 w-64 overflow-hidden rounded-lg border border-border bg-background p-1.5 shadow-[0_16px_38px_-22px_rgb(15_23_42_/_0.65)]`,$?`top-9`:`bottom-9`),children:[(0,E.jsx)(`div`,{className:`px-2 pb-1.5 pt-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60`,children:h(`terminalNewWith`)}),Z.map(e=>(0,E.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground/80 hover:bg-muted/20 hover:text-foreground/90`,onClick:()=>{R(!1),ve(T,e.id)},children:[(0,E.jsx)(`span`,{className:`inline-flex size-5 shrink-0 items-center justify-center rounded bg-muted/20 text-[10px] text-muted-foreground/70`,children:e.name.slice(0,1).toUpperCase()}),(0,E.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,E.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,E.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-muted-foreground/55`,children:e.command})]})]},e.id))]}):null]}),Me?null:(0,E.jsx)(p,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>de(e=>!e),title:h(z?`terminalExitFullscreen`:`terminalFullscreen`),"aria-label":h(z?`terminalExitFullscreen`:`terminalFullscreen`),children:z?(0,E.jsx)(i,{className:`size-3.5`}):(0,E.jsx)(a,{className:`size-3.5`})}),(0,E.jsx)(p,{variant:`ghost`,size:`icon`,className:m(`size-7`,$&&`hidden`),onClick:o,title:h(`terminalCollapse`),"aria-label":h(`terminalCollapse`),children:(0,E.jsx)(t,{className:`size-3.5`})})]}),Q?(0,E.jsx)(`div`,{className:`border-b border-border px-3 py-1.5 text-xs text-destructive`,children:Q}):null,(0,E.jsx)(`div`,{className:m(`min-h-0 bg-background`,$&&`flex-1`),style:Ne===void 0?void 0:{height:Ne},children:N?(0,E.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-xs text-muted-foreground/60`,children:[(0,E.jsx)(n,{className:`size-4 animate-spin`}),` `,h(`terminalStarting`)]}):w&&!w.enabled?(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-muted-foreground/60`,children:w.reason||h(`terminalUnavailable`)}):T.length===0?(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center text-xs text-muted-foreground/60`,children:h(`terminalNoSessions`)}):T.map(e=>(0,E.jsx)(ne,{session:e,active:e.id===X?.id,height:z?window.innerHeight-36:$?0:M,onReady:xe,onExited:be,onConnectionError:Se},e.id))})]})}export{A as TerminalDock,T as t};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{$ as t,At as n,B as r,C as i,Et as a,It as o,M as s,N as c,Ot as l,P as u,Q as d,R as f,Rt as p,U as m,Vt as h,W as g,Y as _,Z as v,_ as ee,_t as y,at as b,b as te,c as ne,ct as re,et as x,ft as ie,gt as S,ht as ae,jt as oe,lt as se,mt as ce,n as le,nt as C,o as ue,ot as w,pt as de,q as fe,rt as pe,st as me,tt as he,ut as ge,v as _e,x as ve}from"./icons-C7j5jdKo.js";import{n as ye}from"./react-vendor-VqdnQHHS.js";import{A as T,B as be,M as xe,V as Se,_ as Ce,a as E,ct as D,d as we,f as Te,g as Ee,h as De,i as O,lt as k,m as Oe,n as A,o as ke,p as Ae,pt as j,r as M,t as je,u as Me,v as Ne,y as Pe}from"./index-_ut7awrd.js";import{n as N,r as Fe,t as Ie}from"./mermaid-renderer-BmbSAmpG.js";import{TerminalDock as Le,t as Re}from"./TerminalDock-BmL-FeKv.js";import{n as ze,t as Be}from"./monaco-CdOyGlWD.js";var P=e(h(),1),F=ye();function Ve(e){let t=e.trim();if(!t.startsWith(`/api/workspace/preview/`))return!1;try{let e=new URL(t,window.location.origin);return e.origin===window.location.origin&&e.pathname.startsWith(`/api/workspace/preview/`)}catch{return!1}}function He(e){let t=e.trim().replace(/\\/g,`/`);return t.startsWith(`/`)||/^[a-zA-Z]:\//.test(t)}function Ue(e,t){let n=e.trim();if(!t||!Ve(n))return n;try{let e=new URL(n,window.location.origin),r=`/api/workspace/preview/${encodeURIComponent(t)}/`;return e.pathname.startsWith(r)?e.pathname.slice(r.length).split(`/`).map(e=>decodeURIComponent(e)).join(`/`):n}catch{return n}}function We(e,t){let n=e.trim();if(!n)return{url:``,displayUrl:``,error:``};if(Ve(n)){let e=new URL(n,window.location.origin);return{url:`${e.pathname}${e.search}${e.hash}`,displayUrl:Ue(n,t),error:``}}if(t&&He(n))return{url:ke(t,n),displayUrl:n,error:``};let r=/^https?:\/\//i.test(n)?n:`http://${n}`;try{let e=new URL(r);return e.protocol!==`http:`&&e.protocol!==`https:`?{url:``,displayUrl:n,error:j(`invalidPreviewUrl`)}:{url:e.toString(),displayUrl:e.toString(),error:``}}catch{return{url:``,displayUrl:n,error:j(`invalidPreviewUrl`)}}}function Ge({url:e,onUrlChange:t,projectId:n}){let r=(0,P.useMemo)(()=>We(e,n),[n,e]),[a,o]=(0,P.useState)({sourceUrl:e,value:r.displayUrl}),[c,l]=(0,P.useState)(``),[u,d]=(0,P.useState)(0),[f,m]=(0,P.useState)(!1),[h,_]=(0,P.useState)(100),v=(0,P.useRef)(null),ee=(0,P.useRef)(null),y=r.url,b=y.startsWith(`/api/workspace/preview/`)?`allow-scripts allow-same-origin allow-forms`:`allow-scripts allow-same-origin allow-forms allow-popups allow-downloads allow-modals allow-pointer-lock`,te=a.sourceUrl===e?a.value:r.displayUrl;(0,P.useEffect)(()=>{if(!f)return;function e(e){v.current?.contains(e.target)||m(!1)}return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[f]);function ne(){try{ee.current?.contentWindow?.history.back()}catch{}}function re(e=te){let r=We(e,n);if(r.error){l(r.error);return}l(``),o({sourceUrl:r.displayUrl,value:r.displayUrl}),t(r.displayUrl),r.url&&d(e=>e+1)}function x(){y&&d(e=>e+1)}function S(){y&&window.open(y,`_blank`,`noopener,noreferrer`)}return(0,F.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-border p-3`,children:[(0,F.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:e=>{e.preventDefault(),re()},children:[(0,F.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,onClick:ne,disabled:!y,"aria-label":j(`back`),title:j(`back`),children:(0,F.jsx)(p,{className:`size-4`})}),(0,F.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,onClick:x,disabled:!y,"aria-label":j(`refreshPreview`),title:j(`refreshPreview`),children:(0,F.jsx)(ve,{className:`size-4`})}),(0,F.jsxs)(`label`,{className:`mx-auto flex h-9 min-w-0 max-w-xl flex-1 items-center rounded-full border border-[color-mix(in_oklab,var(--border)_42%,transparent)] bg-muted/30 px-3 text-sm text-muted-foreground/65 focus-within:bg-background focus-within:text-foreground/85`,children:[(0,F.jsx)(`span`,{className:`sr-only`,children:j(`previewUrl`)}),(0,F.jsx)(`input`,{value:te,onChange:t=>{o({sourceUrl:e,value:t.target.value}),c&&l(``)},placeholder:j(`previewUrlPlaceholder`),className:`min-w-0 flex-1 bg-transparent text-center text-sm text-foreground/85 outline-none placeholder:text-muted-foreground/55`})]}),(0,F.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,onClick:S,disabled:!y,"aria-label":j(`openInBrowser`),title:j(`openInBrowser`),children:(0,F.jsx)(ge,{className:`size-4`})}),(0,F.jsxs)(`div`,{ref:v,className:`relative shrink-0`,children:[(0,F.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>m(e=>!e),"aria-label":j(`more`),title:j(`more`),"aria-haspopup":`menu`,"aria-expanded":f,children:(0,F.jsx)(ie,{className:`size-4`})}),f?(0,F.jsxs)(`div`,{className:`absolute right-0 top-10 z-30 w-48 rounded-2xl border border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-popover p-2 shadow-quickforge`,role:`menu`,children:[(0,F.jsx)(`div`,{className:`px-2 py-1.5 text-xs font-medium text-muted-foreground`,children:j(`zoom`)}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl px-1 py-1.5`,children:[(0,F.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8`,onClick:()=>_(e=>Math.max(50,e-10)),"aria-label":j(`zoomOut`),title:j(`zoomOut`),children:(0,F.jsx)(s,{className:`size-4`})}),(0,F.jsxs)(`button`,{type:`button`,className:`min-w-14 rounded-lg px-2 py-1 text-sm font-medium text-foreground/85 hover:bg-muted/50`,onClick:()=>_(100),title:j(`resetZoom`),children:[h,`%`]}),(0,F.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8`,onClick:()=>_(e=>Math.min(200,e+10)),"aria-label":j(`zoomIn`),title:j(`zoomIn`),children:(0,F.jsx)(i,{className:`size-4`})})]})]}):null]})]}),c?(0,F.jsx)(`div`,{className:`text-xs text-destructive`,children:c}):null]}),(0,F.jsx)(`div`,{className:`min-h-0 flex-1 bg-muted/10`,children:y?(0,F.jsx)(`div`,{className:`h-full w-full overflow-auto bg-background`,children:(0,F.jsx)(`iframe`,{ref:ee,title:j(`webPreview`),src:y,sandbox:b,className:`origin-top-left border-0 bg-background`,style:{width:`${1e4/h}%`,height:`${1e4/h}%`,transform:`scale(${h/100})`}},`${y}:${u}`)}):(0,F.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-8 text-center`,children:[(0,F.jsx)(g,{className:`size-20 stroke-[1.55] text-muted-foreground/75`}),(0,F.jsx)(`div`,{className:`mt-8 text-xl font-semibold tracking-tight text-foreground/88`,children:j(`noPreviewUrlTitle`)}),(0,F.jsx)(`div`,{className:`mt-4 max-w-xs text-base leading-6 text-muted-foreground/82`,children:j(`noPreviewUrlDescription`)})]})})]})}function Ke({source:e}){let[t,n]=(0,P.useState)({source:e,value:`preview`}),[r,i]=(0,P.useState)({source:``,dataUrl:``,error:!1});(0,P.useEffect)(()=>{let t=!1;return Fe(e).then(n=>{t||i({source:e,dataUrl:Ie(n),error:!1})}).catch(()=>{t||i({source:e,dataUrl:``,error:!0})}),()=>{t=!0}},[e]);let a=r.source===e?r:{source:e,dataUrl:``,error:!1},o=t.source===e?t.value:`preview`,s=r.source!==e,c=o===`source`||a.error;return(0,F.jsxs)(`figure`,{className:`my-5 overflow-hidden rounded-xl border border-border bg-muted/20`,children:[(0,F.jsxs)(`figcaption`,{className:`flex min-h-9 items-center justify-between gap-3 border-b border-border px-3 py-1.5`,children:[(0,F.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground/65`,children:`mermaid`}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-background/70 p-0.5`,children:[(0,F.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,disabled:!a.dataUrl,"aria-pressed":!c,onClick:()=>n({source:e,value:`preview`}),children:j(`svgPreviewMode`)}),(0,F.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:text-foreground`,"aria-pressed":c,onClick:()=>n({source:e,value:`source`}),children:j(`svgSourceMode`)})]})]}),s?(0,F.jsx)(`div`,{className:`flex min-h-28 items-center justify-center px-4 py-8 text-xs text-muted-foreground/70`,role:`status`,children:j(`mermaidRendering`)}):c?(0,F.jsxs)(F.Fragment,{children:[a.error?(0,F.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:j(`mermaidRenderFailed`)}):null,(0,F.jsx)(`pre`,{className:`overflow-auto p-4 text-[12px] leading-5`,children:(0,F.jsx)(`code`,{children:e})})]}):(0,F.jsx)(`div`,{className:`flex min-h-28 justify-center overflow-auto bg-background/45 p-4`,children:(0,F.jsx)(`img`,{className:`h-auto max-w-full object-contain`,src:a.dataUrl,alt:j(`mermaidPreviewLabel`)})})]})}function qe(){let[e,t]=(0,P.useState)(()=>xe());return(0,P.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>t(xe());return window.addEventListener(T,e),()=>window.removeEventListener(T,e)},[]),e}function I({path:e,content:t,language:n}){let r=Re(),i=qe();return(0,F.jsx)(Be,{value:t,language:n,theme:r===`dark`?`vs-dark`:`vs`,options:{readOnly:!0,contextmenu:!1,automaticLayout:!0,minimap:{enabled:!1},fontFamily:getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,fontSize:i.fontSize,lineHeight:i.lineHeight,lineNumbers:`on`,scrollBeyondLastLine:!1,wordWrap:`off`,renderLineHighlight:`line`,folding:!1,glyphMargin:!1,scrollbar:{verticalScrollbarSize:8,horizontalScrollbarSize:8}}},e)}function Je(e){let t=e.trim();if(t&&!/^(javascript|data|vbscript):/i.test(t)&&/^(https?:|mailto:|#|\/|\.\.?\/)/i.test(t))return t}function L(e,t){let n=[],r=/`([^`]+)`|\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|\*\*([^*]+)\*\*|__([^_]+)__|\*([^*\n]+)\*|_([^_\n]+)_/g,i=0,a=0,o;for(;o=r.exec(e);){o.index>i&&n.push(e.slice(i,o.index));let s=`${t}-inline-${a++}`;if(o[1])n.push((0,F.jsx)(`code`,{className:`rounded bg-muted/35 px-1 py-0.5 font-mono text-[0.85em] text-foreground/90`,children:o[1]},s));else if(o[2]&&o[3]){let e=Je(o[3]);n.push(e?(0,F.jsx)(`a`,{className:`text-primary underline-offset-4 hover:underline`,href:e,target:e.startsWith(`http`)?`_blank`:void 0,rel:`noreferrer`,children:o[2]},s):`[${o[2]}](${o[3]})`)}else o[4]||o[5]?n.push((0,F.jsx)(`strong`,{className:`font-semibold text-foreground/95`,children:o[4]||o[5]},s)):(o[6]||o[7])&&n.push((0,F.jsx)(`em`,{className:`italic`,children:o[6]||o[7]},s));i=r.lastIndex}return i<e.length&&n.push(e.slice(i)),n.length?n:[e]}function Ye(e,t){return e.split(`
|
|
2
|
+
`).flatMap((e,n)=>{let r=L(e,`${t}-line-${n}`);return n===0?r:[(0,F.jsx)(`br`,{},`${t}-br-${n}`),...r]})}function R(e){return/^\s*(```|~~~)/.test(e)}function Xe(e){return/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*$/.test(e)}function Ze(e,t){return!!(e[t]?.includes(`|`)&&e[t+1]&&Xe(e[t+1]))}function Qe(e,t){let n=e[t]??``;return R(n)||Ze(e,t)||/^\s{0,3}#{1,6}\s+/.test(n)||/^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/.test(n)||/^\s{0,3}>\s?/.test(n)||/^\s{0,3}[-*+]\s+/.test(n)||/^\s{0,3}\d+[.)]\s+/.test(n)}function z(e){return e.trim().replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim())}function $e(e){let t=e.replace(/\r\n?/g,`
|
|
3
|
+
`).split(`
|
|
4
|
+
`),n=[],r=0,i=0;for(;r<t.length;){let e=t[r],a=`markdown-block-${i++}`;if(!e.trim()){r+=1;continue}if(R(e)){let i=e.match(/^\s*(```|~~~)\s*([^`]*)$/),o=i?.[1]??"```",s=i?.[2]?.trim(),c=[];for(r+=1;r<t.length&&!t[r].trimStart().startsWith(o);)c.push(t[r]),r+=1;r<t.length&&(r+=1);let l=c.join(`
|
|
5
|
+
`);N(s)?n.push((0,F.jsx)(Ke,{source:l},a)):n.push((0,F.jsxs)(`figure`,{className:`my-5 overflow-hidden rounded-xl border border-border bg-muted/20`,children:[s?(0,F.jsx)(`figcaption`,{className:`border-b border-border px-3 py-1.5 font-mono text-[11px] text-muted-foreground/65`,children:s}):null,(0,F.jsx)(`pre`,{className:`overflow-auto p-4 text-[12px] leading-5`,children:(0,F.jsx)(`code`,{children:l})})]},a));continue}let o=e.match(/^\s{0,3}(#{1,6})\s+(.+?)\s*#*\s*$/);if(o){let e=o[1].length,t=o[2],i=[`mt-8 mb-3 border-border text-foreground/95`,e===1?`border-b pb-3 text-3xl font-semibold tracking-tight`:``,e===2?`border-b pb-2 text-2xl font-semibold tracking-tight`:``,e===3?`text-xl font-semibold`:``,e===4?`text-lg font-semibold`:``,e>=5?`text-base font-semibold`:``].filter(Boolean).join(` `),s=L(t,`${a}-heading`);e===1?n.push((0,F.jsx)(`h1`,{className:i,children:s},a)):e===2?n.push((0,F.jsx)(`h2`,{className:i,children:s},a)):e===3?n.push((0,F.jsx)(`h3`,{className:i,children:s},a)):e===4?n.push((0,F.jsx)(`h4`,{className:i,children:s},a)):e===5?n.push((0,F.jsx)(`h5`,{className:i,children:s},a)):n.push((0,F.jsx)(`h6`,{className:i,children:s},a)),r+=1;continue}if(/^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/.test(e)){n.push((0,F.jsx)(`hr`,{className:`my-6 border-border`},a)),r+=1;continue}if(Ze(t,r)){let e=z(t[r]);r+=2;let i=[];for(;r<t.length&&t[r].includes(`|`)&&t[r].trim();)i.push(z(t[r])),r+=1;n.push((0,F.jsx)(`div`,{className:`my-5 overflow-auto rounded-xl border border-border`,children:(0,F.jsxs)(`table`,{className:`w-full border-collapse text-left text-sm`,children:[(0,F.jsx)(`thead`,{className:`bg-muted/25 text-foreground/90`,children:(0,F.jsx)(`tr`,{children:e.map((e,t)=>(0,F.jsx)(`th`,{className:`border-b border-border px-3 py-2 font-semibold`,children:L(e,`${a}-th-${t}`)},`${a}-th-${t}`))})}),(0,F.jsx)(`tbody`,{children:i.map((t,n)=>(0,F.jsx)(`tr`,{className:`border-t border-border/70`,children:e.map((e,r)=>(0,F.jsx)(`td`,{className:`px-3 py-2 align-top text-foreground/85`,children:L(t[r]??``,`${a}-td-${n}-${r}`)},`${a}-td-${n}-${r}`))},`${a}-row-${n}`))})]})},a));continue}if(/^\s{0,3}>\s?/.test(e)){let e=[];for(;r<t.length&&/^\s{0,3}>\s?/.test(t[r]);)e.push(t[r].replace(/^\s{0,3}>\s?/,``)),r+=1;n.push((0,F.jsx)(`blockquote`,{className:`my-4 border-l-2 border-border pl-4 text-muted-foreground/85`,children:Ye(e.join(`
|
|
6
|
+
`),`${a}-quote`)},a));continue}if(/^\s{0,3}[-*+]\s+/.test(e)){let e=[];for(;r<t.length&&/^\s{0,3}[-*+]\s+/.test(t[r]);)e.push(t[r].replace(/^\s{0,3}[-*+]\s+/,``)),r+=1;n.push((0,F.jsx)(`ul`,{className:`my-4 list-disc space-y-1 pl-6`,children:e.map((e,t)=>(0,F.jsx)(`li`,{children:L(e,`${a}-li-${t}`)},`${a}-li-${t}`))},a));continue}if(/^\s{0,3}\d+[.)]\s+/.test(e)){let e=[];for(;r<t.length&&/^\s{0,3}\d+[.)]\s+/.test(t[r]);)e.push(t[r].replace(/^\s{0,3}\d+[.)]\s+/,``)),r+=1;n.push((0,F.jsx)(`ol`,{className:`my-4 list-decimal space-y-1 pl-6`,children:e.map((e,t)=>(0,F.jsx)(`li`,{children:L(e,`${a}-li-${t}`)},`${a}-li-${t}`))},a));continue}let s=[];for(;r<t.length&&t[r].trim()&&!Qe(t,r);)s.push(t[r].trim()),r+=1;n.push((0,F.jsx)(`p`,{className:`my-4 text-foreground/86`,children:L(s.join(` `),`${a}-p`)},a))}return n}function et({path:e,content:t,language:n,mode:r}){let i=(0,P.useMemo)(()=>$e(t),[t]);return(0,F.jsx)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:(0,F.jsx)(`div`,{className:`min-h-0 flex-1`,children:r===`source`?(0,F.jsx)(I,{path:e,content:t,language:n}):(0,F.jsx)(`div`,{className:`h-full overflow-auto bg-background`,children:(0,F.jsx)(`article`,{className:`quickforge-markdown-reader mx-auto max-w-3xl px-8 py-7 text-sm leading-7 text-foreground/88`,children:i.length?i:(0,F.jsx)(`p`,{className:`text-muted-foreground/70`,children:`This Markdown file is empty.`})})})})})}function tt({path:e,oldContent:t,newContent:n,language:r,status:i}){let a=Re(),o=qe();return(0,F.jsx)(ze,{original:t,modified:n,language:r,theme:a===`dark`?`vs-dark`:`vs`,options:{readOnly:!0,contextmenu:!1,automaticLayout:!0,renderSideBySide:!0,minimap:{enabled:!1},fontFamily:getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,fontSize:o.fontSize,lineHeight:o.lineHeight,scrollBeyondLastLine:!1,ignoreTrimWhitespace:!1,folding:!1,glyphMargin:!1,scrollbar:{verticalScrollbarSize:8,horizontalScrollbarSize:8}}},`${i}:${e}`)}function B(e,t){let n=e.replace(/\r\n?/g,`
|
|
7
|
+
`).split(`
|
|
8
|
+
`),r=t.replace(/\r\n?/g,`
|
|
9
|
+
`).split(`
|
|
10
|
+
`),i=n.length,a=r.length;if(i*a>4e6)return;let o=Array(a+1).fill(0),s=Array(a+1).fill(0);for(let e=1;e<=i;e++){let t=n[e-1];for(let e=1;e<=a;e++)s[e]=t===r[e-1]?o[e-1]+1:Math.max(o[e],s[e-1]);let i=o;o=s,s=i}let c=o[a];return{added:a-c,removed:i-c}}var V=3,nt=5e7;function H(e){let t=e.replace(/\r\n/g,`
|
|
11
|
+
`).replace(/\r/g,`
|
|
12
|
+
`).split(`
|
|
13
|
+
`);return t.length>1&&t[t.length-1]===``&&t.pop(),t}function U(e,t){let n=H(e),r=H(t);if(n.length*r.length>nt)return;let i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let e=n.length-1;e>=0;--e)for(let t=r.length-1;t>=0;--t)i[e][t]=n[e]===r[t]?i[e+1][t+1]+1:Math.max(i[e+1][t],i[e][t+1]);let a=[],o=0,s=0,c=1,l=1;for(;o<n.length||s<r.length;){if(o<n.length&&s<r.length&&n[o]===r[s]){a.push({kind:`context`,oldLine:c,newLine:l,text:n[o]}),o+=1,s+=1,c+=1,l+=1;continue}if(s<r.length&&(o>=n.length||i[o][s+1]>=i[o+1][s])){a.push({kind:`add`,newLine:l,text:r[s]}),s+=1,l+=1;continue}o<n.length&&(a.push({kind:`delete`,oldLine:c,text:n[o]}),o+=1,c+=1)}return a}function rt(e){let t=e.map(e=>e.kind!==`context`);e.forEach((n,r)=>{if(n.kind===`context`)return;let i=Math.max(0,r-V),a=Math.min(e.length-1,r+V);for(let e=i;e<=a;e+=1)t[e]=!0});let n=[],r=0,i=0;for(;r<e.length;){if(t[r]||e[r].kind!==`context`){n.push(e[r]),r+=1;continue}let a=r;for(;r<e.length&&!t[r]&&e[r].kind===`context`;)r+=1;let o=e.slice(a,r);n.push({kind:`collapsed`,id:`collapsed-${i++}-${a}`,count:o.length,rows:o})}return n}function it(e){return e===`add`?`bg-emerald-500/12 text-foreground`:e===`delete`?`bg-red-500/12 text-foreground`:`bg-background text-foreground/90`}function at(e){return e===`add`?`+`:e===`delete`?`-`:` `}function ot({row:e}){let t=e.kind===`delete`?e.oldLine:e.newLine??e.oldLine;return(0,F.jsxs)(`div`,{className:k(`grid min-w-max grid-cols-[3rem_minmax(34rem,1fr)] text-[13px] leading-6`,it(e.kind)),children:[(0,F.jsx)(`span`,{className:k(`select-none pr-3 text-right font-mono`,e.kind===`delete`&&`text-red-600 dark:text-red-500`,e.kind===`add`&&`text-emerald-600 dark:text-emerald-500`,e.kind===`context`&&`text-muted-foreground/62`),children:t??``}),(0,F.jsxs)(`code`,{className:`whitespace-pre pr-4 font-mono`,children:[(0,F.jsx)(`span`,{className:k(`mr-3 select-none`,e.kind===`add`&&`text-emerald-600 dark:text-emerald-500`,e.kind===`delete`&&`text-red-600 dark:text-red-500`),children:at(e.kind)}),e.text||` `]})]})}function st(e,t,n){let r=new Set(e[t]??[]);return r.has(n)?r.delete(n):r.add(n),{...e,[t]:[...r]}}function W({diff:e,loading:t,error:r}){let[i,a]=(0,P.useState)({}),o=e?`${e.path}\u0000${e.oldContent.length}\u0000${e.newContent.length}`:``,s=(0,P.useMemo)(()=>new Set(i[o]??[]),[o,i]),c=(0,P.useMemo)(()=>{if(!e)return;let t=U(e.oldContent,e.newContent);return t?rt(t):void 0},[e]);return t?(0,F.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-3 py-4 text-sm text-muted-foreground/70`,children:j(`workspaceLoadingDiff`)}):r?(0,F.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-3 py-4 text-sm text-destructive`,children:r}):e?c?c.length===0?(0,F.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-3 py-4 text-sm text-muted-foreground/70`,children:j(`workspaceNoDiffPreview`)}):(0,F.jsx)(`div`,{className:`rounded-b-xl border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background`,children:(0,F.jsx)(`div`,{className:`max-h-[28rem] overflow-auto pb-1`,children:(0,F.jsx)(`div`,{className:`min-w-max py-2`,children:c.map(e=>{if(e.kind!==`collapsed`)return(0,F.jsx)(ot,{row:e},`${e.kind}:${e.oldLine??``}:${e.newLine??``}:${e.text}`);let t=s.has(e.id);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`grid min-w-max grid-cols-[3rem_minmax(34rem,1fr)] gap-1 py-1 pr-4`,children:[(0,F.jsx)(`button`,{type:`button`,className:`flex h-12 items-center justify-center rounded-lg bg-muted/60 text-muted-foreground/75 transition-colors hover:bg-muted/78 hover:text-foreground/80`,onClick:()=>{a(t=>st(t,o,e.id))},"aria-expanded":t,title:j(`workspaceUnmodifiedLines`,{count:e.count}),children:(0,F.jsx)(n,{className:k(`size-4 transition-transform`,t&&`rotate-180`)})}),(0,F.jsx)(`button`,{type:`button`,className:`flex h-12 items-center rounded-lg bg-muted/60 px-4 text-left text-base font-medium text-muted-foreground/80 transition-colors hover:bg-muted/78 hover:text-foreground/80`,onClick:()=>{a(t=>st(t,o,e.id))},"aria-expanded":t,children:j(`workspaceUnmodifiedLines`,{count:e.count})})]}),t?e.rows.map(t=>(0,F.jsx)(ot,{row:t},`hidden:${e.id}:${t.oldLine}:${t.newLine}`)):null]},e.id)})})})}):(0,F.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-3 py-4 text-sm text-muted-foreground/70`,children:j(`workspaceDiffTooLarge`)}):(0,F.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-3 py-4 text-sm text-muted-foreground/70`,children:j(`workspaceNoDiffPreview`)})}var ct={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,css:`css`,scss:`scss`,less:`less`,html:`html`,htm:`html`,md:`markdown`,markdown:`markdown`,py:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,cs:`csharp`,php:`php`,swift:`swift`,kt:`kotlin`,kts:`kotlin`,sh:`shell`,bash:`shell`,zsh:`shell`,ps1:`powershell`,yml:`yaml`,yaml:`yaml`,xml:`xml`,sql:`sql`,dockerfile:`dockerfile`,toml:`toml`,ini:`ini`,env:`ini`};function G(e){let t=e.split(`/`).pop()?.toLowerCase()??``;return t===`dockerfile`||t.endsWith(`.dockerfile`)?`dockerfile`:ct[t.includes(`.`)?t.split(`.`).pop()??``:t]??`plaintext`}function K(e){return e.slice(e.lastIndexOf(`/`)+1)}function q(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t+1):``}var lt={typescript:{Icon:w,className:`text-sky-500 dark:text-sky-400`},javascript:{Icon:w,className:`text-amber-500 dark:text-amber-400`},python:{Icon:w,className:`text-blue-600 dark:text-blue-400`},go:{Icon:w,className:`text-cyan-600 dark:text-cyan-400`},rust:{Icon:w,className:`text-orange-600 dark:text-orange-400`},java:{Icon:w,className:`text-red-500 dark:text-red-400`},c:{Icon:w,className:`text-blue-500 dark:text-blue-400`},cpp:{Icon:w,className:`text-indigo-500 dark:text-indigo-400`},csharp:{Icon:w,className:`text-violet-500 dark:text-violet-400`},php:{Icon:w,className:`text-indigo-500 dark:text-indigo-400`},ruby:{Icon:w,className:`text-rose-500 dark:text-rose-400`},swift:{Icon:w,className:`text-orange-500 dark:text-orange-400`},kotlin:{Icon:w,className:`text-violet-500 dark:text-violet-400`},shell:{Icon:w,className:`text-green-600 dark:text-green-400`},powershell:{Icon:w,className:`text-blue-600 dark:text-blue-400`},json:{Icon:me,className:`text-amber-600 dark:text-amber-400`},css:{Icon:m,className:`text-sky-500 dark:text-sky-400`},scss:{Icon:m,className:`text-pink-500 dark:text-pink-400`},less:{Icon:m,className:`text-sky-500 dark:text-sky-400`},html:{Icon:de,className:`text-orange-500 dark:text-orange-400`},markdown:{Icon:x,className:`text-slate-500 dark:text-slate-400`},yaml:{Icon:b,className:`text-slate-500 dark:text-slate-400`},toml:{Icon:b,className:`text-slate-500 dark:text-slate-400`},ini:{Icon:b,className:`text-slate-500 dark:text-slate-400`},xml:{Icon:w,className:`text-slate-500 dark:text-slate-400`},sql:{Icon:ce,className:`text-indigo-500 dark:text-indigo-400`},dockerfile:{Icon:S,className:`text-sky-600 dark:text-sky-400`},plaintext:{Icon:x,className:`text-slate-500 dark:text-slate-400`}},ut=new Set([`png`,`jpg`,`jpeg`,`gif`,`svg`,`ico`,`webp`,`bmp`,`avif`]),J=new Set([`zip`,`tar`,`gz`,`tgz`,`rar`,`7z`,`bz2`,`xz`]),dt=new Set([`csv`,`tsv`,`xls`,`xlsx`]);function ft(e){if(e===`readme`||e.startsWith(`readme.`))return{Icon:o,className:`text-sky-500 dark:text-sky-400`};if(e===`license`||e.startsWith(`license.`)||e===`licence`||e.startsWith(`licence.`)||e===`copying`||e.startsWith(`copying.`))return{Icon:_e,className:`text-slate-500 dark:text-slate-400`};if(e===`makefile`||e.startsWith(`makefile.`))return{Icon:ue,className:`text-slate-500 dark:text-slate-400`};if(e.startsWith(`docker-compose`))return{Icon:S,className:`text-sky-600 dark:text-sky-400`};if(e===`.gitignore`||e===`.gitattributes`||e===`.gitmodules`)return{Icon:_e,className:`text-orange-500 dark:text-orange-400`};if(e===`.env`||e.startsWith(`.env.`))return{Icon:b,className:`text-slate-500 dark:text-slate-400`};if(e.endsWith(`.lock`)||e.endsWith(`-lock.json`)||e.endsWith(`-lock.yaml`))return{Icon:C,className:`text-slate-500 dark:text-slate-400`}}function pt(e){let n=K(e).toLowerCase(),r=ft(n);if(r)return r;let i=q(n);return ut.has(i)?{Icon:pe,className:`text-purple-500 dark:text-purple-400`}:J.has(i)?{Icon:re,className:`text-slate-500 dark:text-slate-400`}:dt.has(i)?{Icon:he,className:`text-green-600 dark:text-green-400`}:lt[G(e)]||{Icon:t,className:`text-slate-500 dark:text-slate-400`}}function mt(e,t){let n=e.toLowerCase();return n===`.git`||n===`.svn`||n===`.hg`?{Icon:d,className:`text-orange-500 dark:text-orange-400`}:{Icon:t?v:_,className:`text-slate-500 dark:text-slate-400`}}function ht({path:e,className:t=`size-3.5`}){let{Icon:n,className:r}=pt(e);return(0,F.jsx)(n,{className:`${r} ${t}`})}function gt({name:e,open:t,className:n=`size-3.5`}){let{Icon:r,className:i}=mt(e,t);return(0,F.jsx)(r,{className:`${i} ${n}`})}function _t(e){return j(e===`added`?`workspaceStatusAdded`:e===`deleted`?`workspaceStatusDeleted`:e===`renamed`?`workspaceStatusRenamed`:e===`untracked`?`workspaceStatusUntracked`:e===`conflicted`?`workspaceStatusConflict`:`workspaceStatusModified`)}function vt(e){let t=e.replace(/\\/g,`/`);return t.split(`/`).filter(Boolean).pop()||t||`—`}function Y(e,t,n){return e?.action===t&&(n?e.path===n:!e.path)}function yt(e){return!!(e.unstaged||e.status===`untracked`||e.conflict||!e.staged)}function bt({files:e,selectedPath:t,expandedDiff:n,expandedLoading:a,expandedError:o,onSelectFile:c,onRestoreFile:l,onStageFile:u,onUnstageFile:d,onOpenFile:f,onRestoreAll:p,onStageAll:m,onUnstageAll:h,showUnstageAll:g=!1,pendingAction:_,emptyMessage:v=j(`workspaceNoWorkingTreeChanges`)}){let ee=e.filter(yt),y=e.filter(e=>e.staged),b=Y(_,`restore`),ne=Y(_,`stage`),re=Y(_,`unstage`),x=!!_;return(0,F.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col bg-background`,children:[(0,F.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-2 pb-20 pt-1`,children:e.length===0?(0,F.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground/70`,children:v}):(0,F.jsx)(`div`,{className:`divide-y divide-[color-mix(in_oklab,var(--border)_28%,transparent)]`,children:e.map(e=>{let p=t===e.path,m=vt(e.path),h=Y(_,`restore`,e.path),v=Y(_,`stage`,e.path),ee=Y(_,`unstage`,e.path),y=e.status===`deleted`,b=g,ne=x||(b?!d||!e.staged:!u||!yt(e)),re=x||!l,ie=x||!f||y,S=e.oldPath?`${e.oldPath} → ${e.path}`:e.path;return(0,F.jsxs)(`div`,{className:k(`group overflow-hidden`,p&&`rounded-xl bg-muted/30`),children:[(0,F.jsxs)(`div`,{className:k(`grid min-h-[40px] grid-cols-[minmax(0,1fr)_auto] items-center gap-2 rounded-xl transition-colors`,p?`bg-muted/40`:`hover:bg-muted/24`),children:[(0,F.jsxs)(`button`,{type:`button`,className:`grid min-w-0 grid-cols-[24px_minmax(0,1fr)_auto] items-center gap-3 px-3 py-2 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>c(e.path),title:`${_t(e.status)} · ${S}`,"aria-expanded":p,children:[(0,F.jsx)(ht,{path:e.path,className:`size-[15px] shrink-0`}),(0,F.jsx)(`span`,{className:`min-w-0 truncate font-medium leading-[18px] text-foreground/90`,children:m}),typeof e.additions==`number`&&typeof e.deletions==`number`?(0,F.jsxs)(`span`,{className:`min-w-[64px] shrink-0 whitespace-nowrap text-right font-mono text-sm font-medium leading-[18px]`,children:[(0,F.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,e.additions]}),(0,F.jsxs)(`span`,{className:`ml-1.5 text-red-600 dark:text-red-500`,children:[`-`,e.deletions]})]}):(0,F.jsx)(`span`,{className:`min-w-[64px]`})]}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 pr-2 text-muted-foreground/55 opacity-80 transition-opacity group-hover:opacity-100`,children:[(0,F.jsx)(`button`,{type:`button`,className:`inline-flex size-[26px] items-center justify-center rounded-full transition-colors hover:bg-destructive/10 hover:text-destructive disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>l?.(e),disabled:re,"aria-label":j(`workspaceRestoreFile`),title:j(`workspaceRestoreFile`),children:h?(0,F.jsx)(r,{className:`size-3.5 animate-spin`}):(0,F.jsx)(te,{className:`size-4`})}),(0,F.jsx)(`button`,{type:`button`,className:k(`inline-flex size-[26px] items-center justify-center rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-40`,b?`hover:bg-amber-500/10 hover:text-amber-600 dark:hover:text-amber-500`:`hover:bg-emerald-500/10 hover:text-emerald-600 dark:hover:text-emerald-500`),onClick:()=>b?d?.(e):u?.(e),disabled:ne,"aria-label":j(b?`workspaceUnstageFile`:`workspaceStageFile`),title:j(b?`workspaceUnstageFile`:`workspaceStageFile`),children:v||ee?(0,F.jsx)(r,{className:`size-3.5 animate-spin`}):b?(0,F.jsx)(s,{className:`size-4`}):(0,F.jsx)(i,{className:`size-4`})}),(0,F.jsx)(`button`,{type:`button`,className:`inline-flex size-[26px] items-center justify-center rounded-full transition-colors hover:bg-muted/35 hover:text-foreground/85 disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>f?.(e),disabled:ie,"aria-label":j(`workspaceOpenFileInNewTab`),title:j(y?`workspaceCannotOpenDeletedFile`:`workspaceOpenFileInNewTab`),children:(0,F.jsx)(ge,{className:`size-4`})})]})]}),p?(0,F.jsx)(W,{diff:n,loading:a,error:o}):null]},`${e.status}:${e.oldPath??``}:${e.path}`)})})}),(0,F.jsx)(`div`,{className:`pointer-events-none absolute bottom-4 left-1/2 z-20 -translate-x-1/2`,children:(0,F.jsxs)(`div`,{className:`pointer-events-auto inline-flex items-center gap-1 rounded-full border border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background/95 p-1 shadow-quickforge`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center gap-2 rounded-full px-3 text-sm font-medium text-muted-foreground/78 transition-colors hover:bg-destructive/10 hover:text-destructive disabled:cursor-not-allowed disabled:opacity-40`,onClick:p,disabled:!p||e.length===0||x,"aria-label":j(`workspaceRestoreAll`),title:j(`workspaceRestoreAll`),children:[b?(0,F.jsx)(r,{className:`size-3.5 animate-spin`}):(0,F.jsx)(te,{className:`size-3.5`}),(0,F.jsx)(`span`,{children:j(`workspaceRestoreAll`)})]}),(0,F.jsxs)(`button`,{type:`button`,className:k(`inline-flex h-8 items-center gap-2 rounded-full px-3 text-sm font-medium text-muted-foreground/78 transition-colors disabled:cursor-not-allowed disabled:opacity-40`,g?`hover:bg-amber-500/10 hover:text-amber-600 dark:hover:text-amber-500`:`hover:bg-emerald-500/10 hover:text-emerald-600 dark:hover:text-emerald-500`),onClick:g?h:m,disabled:g?!h||y.length===0||x:!m||ee.length===0||x,"aria-label":j(g?`workspaceUnstageAll`:`workspaceStageAll`),title:j(g?`workspaceUnstageAll`:`workspaceStageAll`),children:[ne||re?(0,F.jsx)(r,{className:`size-3.5 animate-spin`}):g?(0,F.jsx)(s,{className:`size-3.5`}):(0,F.jsx)(i,{className:`size-3.5`}),(0,F.jsx)(`span`,{children:j(g?`workspaceUnstageAll`:`workspaceStageAll`)})]})]})})]})}function xt(e){return e?e.status===`added`?`A`:e.status===`deleted`?`D`:e.status===`renamed`?`R`:e.status===`untracked`?`U`:`M`:``}function St({projectId:e,path:t}){let[n,r]=(0,P.useState)(!1);return n?(0,F.jsx)(ht,{path:t,className:`size-3.5 shrink-0`}):(0,F.jsx)(`img`,{src:ke(e,t),alt:``,"aria-hidden":!0,loading:`lazy`,decoding:`async`,onError:()=>r(!0),className:`size-3.5 shrink-0 rounded-[3px] object-cover ring-1 ring-black/5 dark:ring-white/10`})}function Ct({node:e,depth:t,selectedPath:n,gitStatuses:r,onSelectFile:i,onPreviewFile:a,projectId:o}){let[s,c]=(0,P.useState)(t<1),u=e.type===`directory`,d=n===e.path,f=xt(r[e.path]),p=(u?void 0:A(e.path))===`image`,m=!!o&&p,h=!!a&&(p||O(e.path));function g(){a?.(e.path)}return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`group flex h-7 w-full items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors ${d?`bg-muted/28 text-foreground/90`:`text-muted-foreground/72 hover:bg-muted/20 hover:text-foreground/85`}`,style:{paddingLeft:`${.5+t*.75}rem`},onClick:()=>{u?c(e=>!e):p&&a?g():i(e.path)},title:e.path,children:[u?(0,F.jsx)(l,{className:`size-3 shrink-0 transition-transform ${s?`rotate-90`:``}`}):(0,F.jsx)(`span`,{className:`w-3 shrink-0`}),u?(0,F.jsx)(gt,{name:e.name,open:s,className:`size-3.5 shrink-0`}):m?(0,F.jsx)(St,{projectId:o,path:e.path}):(0,F.jsx)(ht,{path:e.path,className:`size-3.5 shrink-0`}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),f?(0,F.jsx)(`span`,{className:`shrink-0 font-mono text-[0.68rem] text-emerald-600 dark:text-emerald-500`,children:f}):null,h?(0,F.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":j(`openPreview`),title:j(`openPreview`),className:`-mr-1 shrink-0 rounded p-0.5 text-muted-foreground/60 opacity-0 transition-opacity hover:bg-muted/40 hover:text-foreground/85 focus-visible:opacity-100 focus-visible:text-foreground/85 focus-visible:outline-none group-hover:opacity-100`,onClick:e=>{e.stopPropagation(),g()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),g())},children:(0,F.jsx)(se,{className:`size-3.5`})}):null]}),u&&s?(0,F.jsx)(`div`,{children:(e.children??[]).map(e=>(0,F.jsx)(Ct,{node:e,depth:t+1,selectedPath:n,gitStatuses:r,onSelectFile:i,onPreviewFile:a,projectId:o},e.path))}):null]})}function wt({tree:e,selectedPath:t,gitStatuses:n={},onSelectFile:r,onPreviewFile:i,projectId:a}){return e.length===0?(0,F.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground/70`,children:j(`workspaceNoFilesToDisplay`)}):(0,F.jsx)(`div`,{className:`space-y-0.5`,children:e.map(e=>(0,F.jsx)(Ct,{node:e,depth:0,selectedPath:t,gitStatuses:n,onSelectFile:r,onPreviewFile:i,projectId:a},e.path))})}function Tt(e,t,n){return!!(e&&t&&e.projectId===t&&e.id!==n)}var Et=`quickforge:workspace-inspector-tabs:v1:`;function Dt(e){return`${Et}${e}`}function Ot(e,t){return e===`browser`?`browser`:`${e}:${t}`}function kt(e){return e===`files`||e===`review`||e===`terminal`||e===`browser`||e===`reader`}function At(){try{return globalThis.localStorage}catch{return}}function jt(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){if(!r||typeof r!=`object`||Array.isArray(r))continue;let e=r;if(!(typeof e.id!=`string`||!e.id||!kt(e.kind))){if(e.kind===`review`){if(t.has(e.kind))continue;t.add(e.kind)}if(e.kind===`reader`){let t=e.reader;if(!t||t.mode!==`file`||typeof t.path!=`string`||!t.path)continue;let r=Ot(t.mode,t.path);n.push({id:e.id,kind:e.kind,readerTabs:[{id:r,mode:t.mode,path:t.path,loading:!0}],activeReaderTabId:r});continue}n.push({id:e.id,kind:e.kind,...e.kind===`browser`&&typeof e.url==`string`?{url:e.url}:{},...e.kind===`review`?{reviewView:e.reviewView===`review`?`review`:`changes`}:{},...e.kind===`terminal`&&typeof e.terminalSessionId==`string`?{terminalSessionId:e.terminalSessionId}:{},...e.kind===`files`||e.kind===`review`?{readerTabs:[],activeReaderTabId:void 0}:{}})}}return n}function Mt(e,t=At()){if(!t)return{tabs:[]};try{let n=t.getItem(Dt(e));if(!n)return{tabs:[]};let r=JSON.parse(n),i=jt(r?.tabs),a=typeof r?.activePanelTabId==`string`&&i.some(e=>e.id===r.activePanelTabId)?r.activePanelTabId:i[0]?.id;return a?{tabs:i,activePanelTabId:a}:{tabs:i}}catch{return{tabs:[]}}}function Nt(e,t){let n=e.flatMap(e=>{if(e.kind===`reader`){let t=e.readerTabs?.find(t=>t.id===e.activeReaderTabId)??e.readerTabs?.[0];return!t||t.mode!==`file`?[]:[{id:e.id,kind:e.kind,reader:{mode:t.mode,path:t.path}}]}return[{id:e.id,kind:e.kind,...e.kind===`browser`?{url:e.url||``}:{},...e.kind===`review`?{reviewView:e.reviewView||`changes`}:{},...e.kind===`terminal`&&e.terminalSessionId?{terminalSessionId:e.terminalSessionId}:{}}]});return{tabs:n,activePanelTabId:t&&n.some(e=>e.id===t)?t:n[0]?.id}}function Pt(e,t,n,r=At()){if(!r)return!1;try{return r.setItem(Dt(e),JSON.stringify(Nt(t,n))),!0}catch{return!1}}function Ft(e){return e.reduce((e,t)=>{let n=t.id.match(/-(\d+)$/);if(!n)return e;let r=Number(n[1]);return Number.isFinite(r)?Math.max(e,r):e},0)+1}function It(){let e,t=0;return{token:n=>(n!==e&&(e=n,t+=1),{projectId:n,epoch:t}),isCurrent:n=>n.projectId===e&&n.epoch===t,invalidate:()=>(t+=1,t)}}function Lt(){if(typeof window>`u`)return 0;let e=window.getComputedStyle(document.body).getPropertyValue(`--quickforge-desktop-titlebar-height`).trim();if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Rt(e,t){return e===`browser`?`browser`:`${e}:${t}`}var zt=[{kind:`files`,label:j(`rightPanelFiles`),description:j(`rightPanelFilesDesc`),icon:_},{kind:`review`,label:j(`rightPanelReview`),description:j(`rightPanelReviewDesc`),icon:fe},{kind:`terminal`,label:j(`rightPanelTerminal`),description:j(`rightPanelTerminalDesc`),icon:ne},{kind:`browser`,label:j(`rightPanelBrowser`),description:j(`rightPanelBrowserDesc`),icon:g}],Bt=[{value:`unstaged`,label:j(`workspaceReviewFilterUnstaged`)},{value:`staged`,label:j(`workspaceReviewFilterStaged`)},{value:`all`,label:j(`workspaceReviewFilterAllBranches`)},{value:`last`,label:j(`workspaceReviewFilterLastRun`)}],Vt=Object.fromEntries(zt.map(e=>[e.kind,e]));function Ht(e){return e===`review`?`changes`:e}function X(e){let t=e.trim();if(!t)return`about:blank`;try{let e=new URL(t);return e.protocol===`about:`?t:e.host||t}catch{return t.split(/[\\/]/).pop()||t}}function Ut(e,t){if(e.kind===`terminal`)return t||j(`rightPanelTerminal`);if(e.kind===`browser`)return X(e.url||``);if(e.kind===`reader`){let t=e.readerTabs?.find(t=>t.id===e.activeReaderTabId)??e.readerTabs?.[0];return t?je(t.path):j(`rightPanelFiles`)}return Vt[e.kind].label}var Wt=340,Z=380,Q=640,Gt=`quickforge_workspaceInspectorWidth_v2`,Kt=140,qt=200,Jt=400;function Yt(){if(typeof window>`u`)return Z;try{let e=window.localStorage.getItem(Gt);if(!e)return Z;let t=Number(e);return Number.isFinite(t)?Math.min(Q,Math.max(Wt,t)):Z}catch{return Z}}function Xt(e,t){let n=t.trim().toLowerCase();return n?e.flatMap(e=>{let t=e.children?Xt(e.children,n):void 0;return!(e.name.toLowerCase().includes(n)||e.path.toLowerCase().includes(n))&&(!t||t.length===0)?[]:[{...e,...t?{children:t}:{}}]}):e}function Zt(e,t){let n=e?.trim();if(!n)return``;let r=n.replace(/\\/g,`/`).replace(/^\.\/+/g,``),i=t?.trim().replace(/\\/g,`/`).replace(/\/+$/g,``);return i&&r.startsWith(`${i}/`)&&(r=r.slice(i.length+1)),r.replace(/^\/+/,``)}function Qt(e,t){let n=new Set;for(let r of e){let e=Zt(r.path,t),i=Zt(r.outputFile,t);e&&n.add(e),i&&n.add(i)}return n}function $t(e){return j(e===`staged`?`workspaceNoStagedChanges`:e===`last`?`workspaceNoLastRunChanges`:`workspaceNoWorkingTreeChanges`)}function en(e){return e?e.language===`markdown`||/\.(md|markdown)$/i.test(e.path):!1}function tn(e,t=!1){return j(t?`readerFileMarkdownPrompt`:`readerFilePrompt`,{path:e})}function $(e){return j(`readerDiffPrompt`,{path:e})}function nn(e){return`Diff for ${e.oldPath?`${e.oldPath} -> ${e.path}`:e.path}\n\n--- OLD\n${e.oldContent}\n\n--- NEW\n${e.newContent}`}function rn({mode:e,file:t,diff:n,loading:r,error:i,onClose:a,onDraftRequest:o}){let[s,c]=(0,P.useState)(),[l,d]=(0,P.useState)(`preview`);async function f(e,t){t&&(await navigator.clipboard.writeText(t),c(e),window.setTimeout(()=>c(void 0),1200))}let p=e===`file`?t?.path:n?.path,m=e===`file`&&en(t),h=e===`file`?t?.content:n?nn(n):void 0,g=e===`file`&&t?tn(t.path,m):e===`diff`&&n?$(n.path):void 0,_=(0,P.useMemo)(()=>e===`diff`&&n?B(n.oldContent,n.newContent):void 0,[e,n]);return(0,F.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,F.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border px-3`,children:[m?(0,F.jsx)(`div`,{className:`inline-flex rounded-full bg-muted/25 p-1 text-xs`,children:[`preview`,`source`].map(e=>(0,F.jsx)(`button`,{type:`button`,className:e===l?`rounded-full bg-background px-3 py-1 font-medium text-foreground/90 shadow-[0_8px_20px_-16px_rgb(15_23_42_/_0.42)]`:`rounded-full px-3 py-1 text-muted-foreground/70 hover:text-foreground/85`,onClick:()=>d(e),children:j(e===`preview`?`markdownPreview`:`markdownSource`)},e))}):null,_?(0,F.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] font-medium`,children:[(0,F.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[`+`,_.added]}),(0,F.jsxs)(`span`,{className:`ml-1.5 text-red-600 dark:text-red-400`,children:[`-`,_.removed]})]}):null,(0,F.jsx)(`div`,{className:`flex-1`}),(0,F.jsx)(D,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>void f(`path`,p),disabled:!p,"aria-label":j(`copyPath`),title:j(`copyPath`),children:s===`path`?(0,F.jsx)(oe,{className:`size-3.5`}):(0,F.jsx)(ae,{className:`size-3.5`})}),(0,F.jsx)(D,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>void f(`content`,h),disabled:!h,"aria-label":j(`copyContent`),title:j(e===`file`?`copyContent`:`copyDiffContent`),children:s===`content`?(0,F.jsx)(oe,{className:`size-3.5`}):(0,F.jsx)(ae,{className:`size-3.5`})}),(0,F.jsx)(D,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>g&&o?.(g),disabled:!g||!o,"aria-label":j(`askAiAboutThis`),title:j(`askAiAboutThis`),children:(0,F.jsx)(u,{className:`size-3.5`})}),(0,F.jsx)(D,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:a,"aria-label":j(`close`),title:j(`close`),children:(0,F.jsx)(le,{className:`size-3.5`})})]}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 bg-background`,children:[r?(0,F.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground/70`,children:j(`openingReader`)}):null,!r&&i?(0,F.jsx)(`div`,{className:`p-4 text-sm text-destructive`,children:i}):null,!r&&!i&&e===`file`&&t?m?(0,F.jsx)(et,{path:t.path,content:t.content,language:t.language,mode:l},t.path):(0,F.jsx)(I,{path:t.path,content:t.content,language:t.language}):null,!r&&!i&&e===`diff`&&n?(0,F.jsx)(tt,{path:n.path,oldContent:n.oldContent,newContent:n.newContent,language:n.language,status:n.status}):null]})]})}function an({project:e,artifacts:t,changesCount:r,changedPaths:i,isGitRepository:a,gitBranch:o,onSelectFile:s,onSelectDiff:c,onPreviewFile:l}){let[u,d]=(0,P.useState)(!1),[f,p]=(0,P.useState)(()=>new Set),m=E(t),h=t.filter(e=>e.command);function g(e){p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,F.jsxs)(`div`,{className:`space-y-3 p-2`,children:[(0,F.jsxs)(`div`,{className:`rounded-lg border border-border bg-background px-3 py-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-foreground/90`,children:[(0,F.jsx)(y,{className:`size-3.5 text-emerald-600 dark:text-emerald-500`}),j(`workspaceCurrentArtifacts`)]}),t.length===0?(0,F.jsx)(`div`,{className:`mt-2 text-xs leading-5 text-muted-foreground/70`,children:j(`workspaceNoArtifacts`)}):(0,F.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[m.length?(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60`,children:[j(`workspaceFiles`),` `,m.length]}),m.slice(0,8).map(e=>{let t=e.path,n=M(t),r=i.has(t),a=typeof e.addedLines==`number`||typeof e.removedLines==`number`;return(0,F.jsxs)(`div`,{className:`group flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-xs text-foreground/85 transition-colors hover:bg-muted/20`,children:[(0,F.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>n?l(t):r?c(t):s(t),title:t,children:e.title||je(t)}),a?(0,F.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] font-medium`,children:[(0,F.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[`+`,e.addedLines??0]}),(0,F.jsxs)(`span`,{className:`ml-1 text-red-600 dark:text-red-400`,children:[`-`,e.removedLines??0]})]}):null,(0,F.jsx)(`span`,{className:`shrink-0 rounded-full bg-muted/30 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground/70`,children:e.kind}),n?(0,F.jsx)(`button`,{type:`button`,className:`shrink-0 inline-flex size-5 items-center justify-center text-blue-600 opacity-0 transition-opacity hover:bg-blue-500/10 hover:text-blue-700 group-hover:opacity-100 dark:text-blue-400`,onClick:()=>l(t),"aria-label":j(`previewArtifact`),title:j(`previewArtifact`),children:(0,F.jsx)(se,{className:`size-3.5`})}):null,(0,F.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground/70 opacity-0 transition-opacity hover:bg-muted/25 group-hover:opacity-100`,onClick:()=>r?c(t):s(t),children:j(r?`workspaceViewDiff`:`artifactPreviewViewSource`)})]},e.id)}),m.length>8?(0,F.jsxs)(`div`,{className:`px-2 text-[11px] text-muted-foreground/60`,children:[`+`,m.length-8]}):null]}):null,h.length?(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-1 py-1 text-left text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60 transition-colors hover:bg-muted/15 hover:text-foreground/75`,onClick:()=>d(e=>!e),"aria-expanded":u,children:[(0,F.jsx)(n,{className:k(`size-3.5 transition-transform`,u?``:`-rotate-90`)}),(0,F.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[j(`workspaceCommands`),` `,h.length]})]}),u?(0,F.jsx)(`div`,{className:`space-y-1`,children:h.map((e,t)=>{let r=f.has(e.id);return(0,F.jsxs)(`div`,{className:`rounded-md bg-muted/15 text-[11px] text-muted-foreground/80`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/20`,onClick:()=>g(e.id),"aria-expanded":r,children:[(0,F.jsx)(n,{className:k(`size-3 shrink-0 transition-transform`,r?``:`-rotate-90`)}),(0,F.jsxs)(`span`,{className:`shrink-0 font-medium text-muted-foreground/65`,children:[`#`,t+1]}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.command})]}),r?(0,F.jsxs)(`div`,{className:`space-y-1 px-2 pb-2 pt-1.5`,children:[(0,F.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-foreground/80`,children:e.command}),e.outputFile?(0,F.jsxs)(`div`,{className:`text-[10px] text-muted-foreground/65`,children:[j(`workspaceCommandOutput`),`: `,(0,F.jsx)(`span`,{className:`font-mono`,children:e.outputFile})]}):null]}):null]},e.id)})}):null]}):null]})]}),(0,F.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/10 px-3 py-3`,children:[(0,F.jsx)(`div`,{className:`text-xs font-medium text-foreground/85`,children:e?.name??j(`noProjectSelected`)}),(0,F.jsx)(`div`,{className:`mt-1 text-[11px] text-muted-foreground/65`,children:a?`${j(`workspaceCurrentBranch`)}: ${o||j(`unknown`)} · ${r} ${j(`workspaceChangeCount`)}`:j(`workspaceNotGitRepository`)})]})]})}function on({project:e,open:t,onOpenChange:r,onPreviewArtifact:o,onDraftRequest:s,request:l,onRequestHandled:u,artifacts:d=[],pendingTerminalCommand:p,onPendingTerminalCommandHandled:m}){let[h,g]=(0,P.useState)([]),[_,v]=(0,P.useState)([]),[b,te]=(0,P.useState)(),[ne,re]=(0,P.useState)(!1),[x,ie]=(0,P.useState)(!1),[S,ae]=(0,P.useState)(),[se,ce]=(0,P.useState)(``),[C,ue]=(0,P.useState)(`unstaged`),[w,de]=(0,P.useState)(),[fe,pe]=(0,P.useState)(),[me,he]=(0,P.useState)(!1),[ge,_e]=(0,P.useState)(),ye=(0,P.useRef)(void 0);ye.current||=e?.id?Mt(e.id):{tabs:[]};let[T,xe]=(0,P.useState)(()=>ye.current?.tabs??[]),[E,O]=(0,P.useState)(()=>ye.current?.activePanelTabId),[A,ke]=(0,P.useState)(!1),[M,je]=(0,P.useState)(!1),[N,Fe]=(0,P.useState)(!1),[Ie,Re]=(0,P.useState)(),[ze,Be]=(0,P.useState)(qt),[Ve,He]=(0,P.useState)(!1),[Ue,We]=(0,P.useState)(t),[Ke,qe]=(0,P.useState)(!1),[I,Je]=(0,P.useState)(Yt),[L,Ye]=(0,P.useState)(!1),[R,Xe]=(0,P.useState)(!1),[Ze,Qe]=(0,P.useState)(!1),z=(0,P.useRef)(null),$e=(0,P.useRef)(null),et=(0,P.useRef)(null),tt=(0,P.useRef)(null),B=(0,P.useRef)(null),V=(0,P.useRef)(null),nt=(0,P.useRef)(null),H=(0,P.useRef)(null),U=(0,P.useRef)(null),rt=(0,P.useRef)(null),it=(0,P.useRef)(Ft(ye.current?.tabs??[])),at=(0,P.useRef)(void 0),ot=(0,P.useRef)(void 0),st=(0,P.useRef)(void 0),W=(0,P.useRef)(It()),ct=(0,P.useRef)(new Set),G=(0,P.useRef)(0);(0,P.useEffect)(()=>{let e=W.current;return()=>{e.invalidate()}},[]);let K=e?.id;K&&W.current.token(K);let q=(0,P.useMemo)(()=>T.find(e=>e.id===E),[E,T]),lt=q?.activeReaderTabId,ut=(0,P.useMemo)(()=>q?.readerTabs||[],[q?.readerTabs]),J=(0,P.useMemo)(()=>ut.find(e=>e.id===lt),[lt,ut]),dt=!!(J&&J.mode!==`browser`&&(q?.kind===`reader`||q?.kind===`files`||q?.kind===`review`&&J.mode===`diff`)),ft=q?.kind===`review`?q.reviewView===`review`?`overview`:`changes`:`files`,pt=(0,P.useMemo)(()=>{let e={};for(let t of _)e[t.path]=t;return e},[_]),mt=(0,P.useMemo)(()=>{let e=new Set;for(let t of _)e.add(t.path),t.oldPath&&e.add(t.oldPath);return e},[_]),ht=(0,P.useMemo)(()=>Xt(h,se),[se,h]),gt=(0,P.useMemo)(()=>Qt(d,e?.path),[d,e?.path]),_t=(0,P.useMemo)(()=>C===`staged`?_.filter(e=>e.staged):C===`all`?_:C===`last`?_.filter(e=>gt.has(e.path)||(e.oldPath?gt.has(e.oldPath):!1)):_.filter(e=>e.unstaged||e.status===`untracked`||e.conflict||e.status===`conflicted`),[_,gt,C]);function vt(e){v(e.files),te(e.branch),re(e.isGitRepository)}async function Y(e,t,n,r){Re({action:e,path:t});try{vt(await n())}catch(e){await be(e instanceof Error?e.message:r)}finally{Re(void 0)}}async function yt(e){K&&await Y(`stage`,e.path,()=>Ce(K,e.path),j(`workspaceStageFailed`))}async function xt(){K&&await Y(`stage`,void 0,()=>Ee(K),j(`workspaceStageFailed`))}async function St(e){K&&await Y(`unstage`,e.path,()=>Pe(K,e.path),j(`workspaceUnstageFailed`))}async function Ct(){K&&await Y(`unstage`,void 0,()=>Ne(K),j(`workspaceUnstageFailed`))}async function Et(e){K&&await Se({title:j(`workspaceRestoreConfirmTitle`),description:j(`workspaceRestoreFileConfirm`,{path:e.path}),confirmLabel:j(`workspaceRestoreFile`),cancelLabel:j(`cancel`),variant:`destructive`})&&await Y(`restore`,e.path,()=>De(K,e.path),j(`workspaceRestoreFailed`))}async function Dt(){K&&await Se({title:j(`workspaceRestoreConfirmTitle`),description:j(`workspaceRestoreAllConfirm`),confirmLabel:j(`workspaceRestoreAll`),cancelLabel:j(`cancel`),variant:`destructive`})&&await Y(`restore`,void 0,()=>Oe(K),j(`workspaceRestoreFailed`))}function Ot(e){e.status!==`deleted`&&$(e.path)}(0,P.useEffect)(()=>{!w||_t.some(e=>e.path===w)||(de(void 0),pe(void 0),_e(void 0),he(!1))},[w,_t]),(0,P.useEffect)(()=>{if(t){let e=!1;return queueMicrotask(()=>{e||(We(!0),window.requestAnimationFrame(()=>{e||qe(!0)}))}),()=>{e=!0}}let e=!1;queueMicrotask(()=>{e||qe(!1)});let n=window.setTimeout(()=>We(!1),180);return()=>{e=!0,window.clearTimeout(n)}},[t]),(0,P.useEffect)(()=>{if(!A&&!M&&!N)return;let e=e=>{let t=e.target;A&&!$e.current?.contains(t)&&ke(!1),M&&!et.current?.contains(t)&&je(!1),N&&!tt.current?.contains(t)&&Fe(!1)},t=e=>{e.key===`Escape`&&(ke(!1),je(!1),Fe(!1))};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[A,N,M]),(0,P.useEffect)(()=>{!t||!Tt(l,K,st.current)||(st.current=l.id,l.kind===`review`?at.current?.(`review`,l.view):l.kind===`reader`?ot.current?.(l.path):l.kind===`browser`?at.current?.(`browser`,`browser`,{url:l.url}):at.current?.(l.kind,Ht(l.kind)),u?.(l.id))},[u,t,K,l]),(0,P.useEffect)(()=>{try{window.localStorage.setItem(Gt,String(I))}catch{}},[I]);let kt=(0,P.useCallback)(()=>{Je(e=>e<Q?Q:e)},[]);(0,P.useEffect)(()=>{!Ke||R||(q?.kind===`browser`||q?.kind===`terminal`||lt)&&kt()},[q?.kind,lt,Ke,R,kt]);let At=(0,P.useCallback)(async e=>{if(K){ie(!0),ae(void 0);try{let[t,n]=await Promise.all([Ae(K),we(K)]);if(e?.())return;g(t.tree),v(n.files),te(n.branch),re(n.isGitRepository)}catch(t){e?.()||ae(t instanceof Error?t.message:j(`workspaceLoadFailed`))}finally{e?.()||ie(!1)}}},[K]);(0,P.useEffect)(()=>{let e=!1;if(!(!K||!t))return queueMicrotask(()=>{e||At(()=>e)}),()=>{e=!0}},[At,t,K]),(0,P.useEffect)(()=>{K&&Pt(K,T,E)},[E,T,K]),(0,P.useEffect)(()=>{!E||T.some(e=>e.id===E)||O(T[0]?.id)},[E,T]),(0,P.useEffect)(()=>{if(!K)return;let e=T.flatMap(e=>e.kind===`reader`?(e.readerTabs||[]).filter(e=>e.loading&&e.mode===`file`).map(t=>({panelTabId:e.id,reader:t})):[]);for(let{panelTabId:t,reader:n}of e){let e=`${K}:${n.id}`;if(ct.current.has(e))continue;ct.current.add(e);let r=W.current.token(K);Te(K,n.path).then(e=>({file:e})).then(e=>{W.current.isCurrent(r)&&X(t,t=>({...t,readerTabs:(t.readerTabs||[]).map(t=>t.id===n.id?{...t,...e,loading:!1,error:void 0}:t)}))}).catch(e=>{W.current.isCurrent(r)&&X(t,t=>({...t,readerTabs:(t.readerTabs||[]).map(t=>t.id===n.id?{...t,loading:!1,error:e instanceof Error?e.message:j(`workspaceOpenFileFailed`)}:t)}))}).finally(()=>{ct.current.delete(e)})}},[T,K]);function jt(e,t){let n=`${e}-${it.current++}`;return e===`browser`?{id:n,kind:e,url:t?.url||``}:e===`reader`?{id:n,kind:e,readerTabs:t?.readerTab?[t.readerTab]:[],activeReaderTabId:t?.readerTab?.id}:e===`files`||e===`review`?{id:n,kind:e,...e===`review`?{reviewView:t?.reviewView||`changes`}:{},readerTabs:t?.readerTab?[t.readerTab]:[],activeReaderTabId:t?.readerTab?.id}:{id:n,kind:e}}function Nt(e){return jt(`reader`,{readerTab:e})}function X(e,t){xe(n=>n.map(n=>n.id===e?t(n):n))}function Z(e,t=Ht(e),n){let r=e===`review`?T.find(e=>e.kind===`review`):void 0,i=r||jt(e,{...n,...e===`review`?{reviewView:t===`review`?`review`:`changes`}:{}});return r||xe(e=>[...e,i]),r?.kind===`review`&&X(r.id,e=>({...e,reviewView:t===`review`?`review`:`changes`})),O(i.id),ke(!1),i}at.current=Z;function Zt(e){O(e.id)}function en(e){xe(t=>{let n=t.findIndex(t=>t.id===e),i=t.filter(t=>t.id!==e);return i.length===0?(O(void 0),r(!1),i):(E===e&&O((i[n]??i[n-1])?.id),i)})}function tn(e){if(o&&K){o(K,e);return}$(e)}async function $(e){if(!K)return;let t=W.current.token(K),n=Rt(`file`,e),r=T.find(e=>e.kind===`reader`&&e.readerTabs?.some(e=>e.id===n));if(r){O(r.id),X(r.id,e=>({...e,activeReaderTabId:n}));return}let i=Nt({id:n,mode:`file`,path:e,loading:!0});xe(e=>[...e,i]),O(i.id);try{let r=await Te(K,e);if(!W.current.isCurrent(t))return;X(i.id,e=>({...e,readerTabs:(e.readerTabs||[]).map(e=>e.id===n?{...e,file:r,loading:!1,error:void 0}:e)}))}catch(e){if(!W.current.isCurrent(t))return;X(i.id,t=>({...t,readerTabs:(t.readerTabs||[]).map(t=>t.id===n?{...t,loading:!1,error:e instanceof Error?e.message:j(`workspaceOpenFileFailed`)}:t)}))}}ot.current=$;async function nn(e,t){if(!K)return;let n=W.current.token(K),r=T.find(e=>e.kind===`review`)||Z(`review`,t?`changes`:`review`);O(r.id),t&&r.kind===`review`&&X(r.id,e=>({...e,reviewView:`changes`}));let i=Rt(`diff`,e);if(r.readerTabs?.some(e=>e.id===i)){X(r.id,e=>({...e,activeReaderTabId:i}));return}let a={id:i,mode:`diff`,path:e,loading:!0};X(r.id,e=>({...e,readerTabs:[...e.readerTabs||[],a],activeReaderTabId:i}));try{let t=await Me(K,e);if(!W.current.isCurrent(n))return;X(r.id,e=>({...e,readerTabs:(e.readerTabs||[]).map(e=>e.id===i?{...e,diff:t,loading:!1,error:void 0}:e)}))}catch(e){if(!W.current.isCurrent(n))return;X(r.id,t=>({...t,readerTabs:(t.readerTabs||[]).map(t=>t.id===i?{...t,loading:!1,error:e instanceof Error?e.message:j(`workspaceOpenDiffFailed`)}:t)}))}}async function on(e){if(!K)return;let t=W.current.token(K);if(w===e){G.current+=1,de(void 0),pe(void 0),_e(void 0),he(!1);return}let n=G.current+1;G.current=n,de(e),pe(void 0),_e(void 0),he(!0);try{let r=await Me(K,e);if(G.current!==n||!W.current.isCurrent(t))return;pe(r)}catch(e){if(G.current!==n||!W.current.isCurrent(t))return;_e(e instanceof Error?e.message:j(`workspaceOpenDiffFailed`))}finally{G.current===n&&W.current.isCurrent(t)&&he(!1)}}function sn(e){q&&X(q.id,t=>{let n=t.readerTabs||[],r=n.findIndex(t=>t.id===e),i=n.filter(t=>t.id!==e),a=t.activeReaderTabId===e?(i[r]??i[r-1])?.id:t.activeReaderTabId;return{...t,readerTabs:i,activeReaderTabId:a}})}async function cn(e){await nn(e,!1)}function ln(e){nt.current={startX:e.clientX,startWidth:I,currentWidth:I},rt.current={cursor:document.body.style.cursor,userSelect:document.body.style.userSelect},document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,Ye(!0),e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}}function un(e){let t=nt.current,n=z.current;!t||!n||(t.currentWidth=Math.min(Q,Math.max(Wt,t.startWidth+t.startX-e.clientX)),H.current===null&&(H.current=window.requestAnimationFrame(()=>{H.current=null;let e=nt.current;!e||!z.current||(z.current.style.width=`${e.currentWidth}px`)})))}function dn(e){let t=nt.current?.currentWidth;nt.current=null,H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null),typeof t==`number`&&(z.current&&(z.current.style.width=`${t}px`),Je(t));let n=rt.current;n&&(document.body.style.cursor=n.cursor,document.body.style.userSelect=n.userSelect,rt.current=null),Ye(!1);try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}function fn(e){B.current={startX:e.clientX,startWidth:ze,currentWidth:ze},document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,He(!0),e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}}function pn(e){let t=B.current;t&&(t.currentWidth=Math.min(Jt,Math.max(Kt,t.startWidth+e.clientX-t.startX)),V.current===null&&(V.current=window.requestAnimationFrame(()=>{V.current=null;let e=B.current;e&&Be(e.currentWidth)})))}function mn(e){let t=B.current?.currentWidth;B.current=null,V.current!==null&&(window.cancelAnimationFrame(V.current),V.current=null),typeof t==`number`&&Be(t),document.body.style.cursor=``,document.body.style.userSelect=``,He(!1);try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}let hn=(0,P.useCallback)(()=>{let e=z.current;if(!e){Xe(e=>!e);return}U.current?.cancel();let t=e.getBoundingClientRect(),n=window.innerWidth,r=Lt(),i=window.innerHeight-r,a=`${r}px`,o=`${i}px`,s=`cubic-bezier(0.22, 1, 0.36, 1)`;if(Qe(!0),!R){window.requestAnimationFrame(()=>{let e=z.current;if(!e)return;Object.assign(e.style,{position:`fixed`,left:`${t.left}px`,top:`${t.top}px`,right:`auto`,bottom:`auto`,width:`${t.width}px`,height:`${t.height}px`,minWidth:`0px`,maxWidth:`none`,zIndex:`40`});let r=e.animate([{left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`},{left:`0px`,top:a,width:`${n}px`,height:o}],{duration:240,easing:s,fill:`forwards`});U.current=r,r.onfinish=()=>{U.current=null,Xe(!0),window.requestAnimationFrame(()=>{r.cancel(),e.removeAttribute(`style`),window.requestAnimationFrame(()=>Qe(!1))})},r.oncancel=()=>{U.current=null,Qe(!1)}});return}window.requestAnimationFrame(()=>{let e=z.current;if(!e)return;Object.assign(e.style,{position:`fixed`,left:`0px`,top:a,right:`auto`,bottom:`auto`,width:`${t.width}px`,height:o,zIndex:`40`});let r=n-I,i=e.animate([{left:`0px`,top:a,width:`${t.width}px`,height:o},{left:`${r}px`,top:a,width:`${I}px`,height:o}],{duration:240,easing:s,fill:`forwards`});U.current=i,i.onfinish=()=>{U.current=null,Xe(!1),window.requestAnimationFrame(()=>{i.cancel(),e.style.position=``,e.style.left=``,e.style.top=``,e.style.right=``,e.style.bottom=``,e.style.height=``,e.style.zIndex=``,e.style.width=`${I}px`,e.style.minWidth=`${Wt}px`,e.style.maxWidth=`${Q}px`,window.requestAnimationFrame(()=>Qe(!1))})},i.oncancel=()=>{U.current=null,Qe(!1)}})},[R,I]);return(0,P.useEffect)(()=>{if(!R)return;let e=e=>{e.key===`Escape`&&Xe(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[R]),(0,P.useEffect)(()=>()=>{H.current!==null&&window.cancelAnimationFrame(H.current),V.current!==null&&window.cancelAnimationFrame(V.current),U.current?.cancel(),z.current&&z.current.removeAttribute(`style`);let e=rt.current;e&&(document.body.style.cursor=e.cursor,document.body.style.userSelect=e.userSelect)},[]),Ue?(0,F.jsx)(F.Fragment,{children:(0,F.jsxs)(`aside`,{ref:z,className:k(`relative hidden shrink-0 overflow-hidden flex-col bg-background transition-[width,min-width,max-width,opacity,transform] duration-200 ease-out will-change-[width,opacity,transform] lg:flex`,Ke?`translate-x-0 opacity-100`:`w-0 min-w-0 max-w-0 translate-x-4 opacity-0`,L?`transition-none`:``,R?`quickforge-workspace-inspector-fullscreen z-40 rounded-none border-l-0`:`lg:rounded-l-2xl`),style:Ke?R?void 0:{width:I,minWidth:Wt,maxWidth:Q}:void 0,children:[Ke&&!R?(0,F.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":Wt,"aria-valuemax":Q,"aria-valuenow":I,className:k(`group absolute inset-y-0 -left-2 z-20 flex w-4 cursor-col-resize items-center justify-center bg-transparent transition-colors hover:bg-border/40`,L?`bg-border/45`:``),onPointerDown:ln,onPointerMove:un,onPointerUp:dn,onPointerCancel:dn,children:(0,F.jsx)(`div`,{className:k(`flex h-10 w-3 items-center justify-center rounded-full border border-border bg-background text-muted-foreground/60 opacity-0 shadow-sm transition-opacity`,L?`opacity-100`:`group-hover:opacity-100`),children:(0,F.jsx)(a,{className:`size-3`})})}):null,(0,F.jsxs)(`div`,{className:k(`flex h-14 shrink-0 items-center gap-2 border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-3 pr-20 transition-opacity duration-150`,Ze?`opacity-0`:`opacity-100`),children:[T.length>0?(0,F.jsxs)(`div`,{ref:et,className:`relative shrink-0`,children:[(0,F.jsx)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-2xl bg-transparent text-muted-foreground/85 transition-colors hover:bg-muted/45 hover:text-foreground/90`,onClick:()=>je(e=>!e),"aria-label":j(`rightPanelOpenTabsTitle`),title:j(`rightPanelOpenTabsTitle`),"aria-haspopup":`menu`,"aria-expanded":M,children:(0,F.jsx)(n,{className:k(`size-4 transition-transform`,M&&`rotate-180`)})}),M?(0,F.jsx)(`div`,{className:`absolute left-0 top-12 z-40 w-72 max-w-[calc(100vw-2rem)] rounded-2xl border border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-popover p-2 shadow-quickforge`,role:`menu`,children:T.map(t=>{let n=(t.kind===`reader`?void 0:Vt[t.kind])?.icon??y,r=t.id===E,i=Ut(t,e?.name);return(0,F.jsxs)(`div`,{className:k(`group flex h-10 w-full items-center gap-2 rounded-xl px-2 transition-colors`,r?`bg-muted/55 text-foreground`:`text-foreground/86 hover:bg-muted/34 hover:text-foreground`),role:`none`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-medium`,onClick:()=>{Zt(t),je(!1)},role:`menuitem`,title:i,children:[(0,F.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground/80`}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i})]}),(0,F.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground/70 opacity-70 transition-colors hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100`,onClick:e=>{e.stopPropagation(),en(t.id)},"aria-label":j(`close`),children:(0,F.jsx)(le,{className:`size-3.5`})})]},t.id)})}):null]}):null,(0,F.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-hidden`,children:[T.map((t,n)=>{let r=(t.kind===`reader`?void 0:Vt[t.kind])?.icon??y,i=t.id===E,a=Ut(t,e?.name);return(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n>0?(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-3.5 w-px bg-[color-mix(in_oklab,var(--muted-foreground)_18%,transparent)]`}):null,(0,F.jsxs)(`button`,{type:`button`,className:k(`group flex h-10 max-w-40 items-center gap-2 rounded-2xl px-3 text-[13px] font-medium transition-colors`,i?`bg-[color-mix(in_oklab,var(--muted)_86%,transparent)] text-foreground/82 hover:bg-[color-mix(in_oklab,var(--muted)_86%,transparent)]`:`text-muted-foreground/45 hover:bg-[color-mix(in_oklab,var(--muted)_72%,transparent)] hover:text-muted-foreground/72`),onClick:()=>Zt(t),title:a,children:[(0,F.jsx)(r,{className:k(`size-4 shrink-0`,i?`text-foreground/74`:`text-muted-foreground/45 group-hover:text-muted-foreground/72`)}),(0,F.jsx)(`span`,{className:`min-w-0 truncate`,children:a}),(0,F.jsx)(`span`,{role:`button`,tabIndex:0,className:k(`ml-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full opacity-0 transition-all hover:bg-black hover:text-white group-hover:opacity-100`,i&&`opacity-100`),onClick:e=>{e.stopPropagation(),en(t.id)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),en(t.id))},"aria-label":j(`close`),children:(0,F.jsx)(le,{className:`size-3.5`})})]})]},t.id)}),T.length===0?(0,F.jsx)(`div`,{className:`min-w-0 flex-1`}):null]}),T.length>0?(0,F.jsxs)(`div`,{ref:$e,className:`relative shrink-0`,children:[(0,F.jsx)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-2xl bg-transparent text-muted-foreground/85 transition-colors hover:bg-muted/45 hover:text-foreground/90`,onClick:()=>ke(e=>!e),"aria-label":j(`rightPanelAddTab`),title:j(`rightPanelAddTab`),"aria-haspopup":`menu`,"aria-expanded":A,children:(0,F.jsx)(i,{className:`size-4 stroke-[1.9]`})}),A?(0,F.jsx)(`div`,{className:`absolute right-0 top-12 z-40 w-64 rounded-2xl border border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-popover p-2 shadow-quickforge`,role:`menu`,children:zt.map(e=>{let t=e.icon;return(0,F.jsxs)(`button`,{type:`button`,className:k(`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-[15px] font-medium transition-colors`,e.kind===q?.kind?`bg-muted/55 text-foreground`:`text-foreground/86 hover:bg-muted/34 hover:text-foreground`),onClick:()=>Z(e.kind,Ht(e.kind)),role:`menuitem`,children:[(0,F.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground/80`}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label})]},e.kind)})}):null]}):null,(0,F.jsx)(D,{variant:`ghost`,size:`icon`,className:`shrink-0`,onClick:hn,"aria-label":j(R?`workspaceExitFullscreen`:`workspaceFullscreen`),title:j(R?`workspaceExitFullscreen`:`workspaceFullscreen`),children:R?(0,F.jsx)(c,{className:`size-4`}):(0,F.jsx)(f,{className:`size-4`})})]}),(0,F.jsx)(`div`,{className:k(`flex min-h-0 flex-1 transition-opacity duration-150`,Ze?`opacity-0`:`opacity-100`),children:e?.id?q?q.kind===`browser`?(0,F.jsx)(Ge,{url:q.url||``,onUrlChange:e=>{X(q.id,t=>({...t,url:e}))},projectId:e.id}):q.kind===`terminal`?(0,F.jsx)(Le,{project:e,pendingCommand:p,onPendingCommandHandled:m,onCollapse:()=>en(q.id),variant:`panel`,singleSession:!0,panelInstanceId:q.id,panelSessionId:q.terminalSessionId,onPanelSessionReady:e=>X(q.id,t=>({...t,terminalSessionId:e}))},q.id):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:k(`flex min-h-0 flex-col bg-muted/20`,dt?`shrink-0 border-r-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)]`:`flex-1`),style:dt?{width:ze,minWidth:Kt,maxWidth:Jt}:void 0,children:S?(0,F.jsx)(`div`,{className:`p-4 text-sm text-destructive`,children:S}):(0,F.jsxs)(`div`,{className:k(`min-h-0 flex-1 p-2`,ft===`changes`?`flex flex-col overflow-hidden`:`overflow-auto`),children:[x?(0,F.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground/70`,children:j(`workspaceLoading`)}):null,!x&&ft===`overview`?(0,F.jsx)(an,{project:e,artifacts:d,changesCount:_.length,changedPaths:mt,isGitRepository:ne,gitBranch:b,onSelectFile:$,onSelectDiff:cn,onPreviewFile:tn}):null,!x&&ft===`files`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 rounded-md border-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-2 py-1.5 text-xs text-muted-foreground/65 focus-within:text-foreground/85`,children:[(0,F.jsx)(ee,{className:`size-3.5 shrink-0`}),(0,F.jsx)(`input`,{value:se,onChange:e=>ce(e.target.value),placeholder:j(`workspaceFilterFiles`),className:`min-w-0 flex-1 bg-transparent text-xs text-foreground/85 outline-none placeholder:text-muted-foreground/50`})]}),(0,F.jsx)(wt,{tree:ht,selectedPath:J?.mode===`file`?J.path:void 0,gitStatuses:pt,onSelectFile:$,onPreviewFile:tn,projectId:K})]}):null,!x&&ft===`changes`?ne?(0,F.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 px-2 pb-2`,children:[(0,F.jsxs)(`div`,{ref:tt,className:`relative min-w-0`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 min-w-32 items-center gap-2 rounded-xl border border-[color-mix(in_oklab,var(--border)_45%,transparent)] bg-background px-3 text-sm font-medium text-foreground/86 transition-colors hover:border-border/60 hover:bg-muted/30 hover:text-foreground`,onClick:()=>Fe(e=>!e),"aria-haspopup":`menu`,"aria-expanded":N,title:j(`workspaceReviewFilter`),children:[(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:Bt.find(e=>e.value===C)?.label}),(0,F.jsx)(n,{className:k(`size-3.5 shrink-0 text-muted-foreground/70 transition-transform`,N&&`rotate-180`)})]}),N?(0,F.jsx)(`div`,{className:`absolute left-0 top-10 z-40 w-48 rounded-2xl border border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-popover p-1.5 shadow-quickforge`,role:`menu`,"aria-label":j(`workspaceReviewFilter`),children:Bt.map(e=>{let t=e.value===C;return(0,F.jsxs)(`button`,{type:`button`,className:k(`flex h-9 w-full items-center gap-2 rounded-xl px-2.5 text-left text-sm font-medium transition-colors`,t?`bg-muted/55 text-foreground`:`text-foreground/82 hover:bg-muted/34 hover:text-foreground`),onClick:()=>{ue(e.value),Fe(!1)},role:`menuitemradio`,"aria-checked":t,children:[(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),t?(0,F.jsx)(oe,{className:`size-3.5 shrink-0 text-muted-foreground/80`}):null]},e.value)})}):null]}),(0,F.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-xl px-2.5 text-sm font-medium text-muted-foreground/72 transition-colors hover:bg-muted/30 hover:text-foreground/85 disabled:cursor-not-allowed disabled:opacity-60`,onClick:()=>void At(),disabled:x,"aria-label":j(`refreshWorkspace`),title:j(`refreshWorkspace`),children:[(0,F.jsx)(ve,{className:k(`size-3.5`,x&&`animate-spin`)}),(0,F.jsx)(`span`,{children:j(`refresh`)})]})]}),(0,F.jsx)(bt,{files:_t,selectedPath:w,expandedDiff:fe,expandedLoading:me,expandedError:ge,onSelectFile:on,onRestoreFile:Et,onStageFile:yt,onUnstageFile:St,onOpenFile:Ot,onRestoreAll:Dt,onStageAll:xt,onUnstageAll:Ct,showUnstageAll:C===`staged`,pendingAction:Ie,emptyMessage:$t(C)})]}):(0,F.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground/70`,children:j(`workspaceNotGitRepository`)}):null]})}),dt?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":Kt,"aria-valuemax":Jt,"aria-valuenow":ze,className:k(`group relative z-10 w-1.5 shrink-0 cursor-col-resize bg-transparent transition-colors`,Ve?`bg-primary/30`:`hover:bg-[color-mix(in_oklab,var(--border)_52%,transparent)]`),onPointerDown:fn,onPointerMove:pn,onPointerUp:mn,onPointerCancel:mn}),(0,F.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col bg-background`,children:J?(0,F.jsx)(rn,{mode:J.mode,file:J.file,diff:J.diff,loading:J.loading,error:J.error,onClose:()=>q.kind===`reader`?en(q.id):sn(J.id),onDraftRequest:s}):null})]}):null]}):(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-5`,children:(0,F.jsxs)(`div`,{className:`w-full max-w-[26rem] space-y-4`,children:[(0,F.jsxs)(`div`,{className:`text-center font-sans`,children:[(0,F.jsx)(`div`,{className:`text-lg font-semibold leading-tight tracking-[-0.01em] text-foreground/90`,children:j(`rightPanelOpenTabsTitle`)}),(0,F.jsx)(`div`,{className:`mt-2 text-sm leading-5 text-muted-foreground/70`,children:j(`rightPanelOpenTabsDescription`)})]}),(0,F.jsx)(`div`,{className:`space-y-2`,children:zt.map(e=>{let t=e.icon;return(0,F.jsxs)(`button`,{type:`button`,className:`flex w-full cursor-pointer items-center gap-3 rounded-xl border border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-muted/60 px-4 py-3 text-left transition-colors hover:bg-muted/72 active:bg-muted/82`,onClick:()=>Z(e.kind,Ht(e.kind)),children:[(0,F.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground/78`}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`text-sm font-medium text-foreground/90`,children:e.label}),(0,F.jsx)(`div`,{className:`mt-0.5 text-xs leading-4 text-muted-foreground/60`,children:e.description})]})]},e.kind)})})]})}):(0,F.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground/70`,children:j(`workspaceSelectProject`)})})]})}):null}export{on as WorkspaceInspector};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./chunk-5HE753X5-CRgsy8WS.js";import{n as t}from"./chunk-Y2CYZVJY-CQltPwYk.js";import{m as n}from"./src-B4Tvg3gT.js";import"./chunk-WYO6CB5R-CGExYbV-.js";import"./chunk-VAUOI2AC-BOZvd2Sn.js";import{n as r,r as i,t as a}from"./chunk-MOJQB5TN-DIAFLtiS.js";import{t as o}from"./chunk-JWPE2WC7-D32uacSM.js";import{t as s}from"./mermaid-parser.core-CoE8cccr.js";var c=e().RailroadAbnf.parser.LangiumParser,l=t(e=>{let t=e.alternatives.map(u);return t.length===1?t[0]:{type:`choice`,alternatives:t}},`transformAlternation`),u=t(e=>{let t=e.elements.map(f);return t.length===1?t[0]:{type:`sequence`,elements:t}},`transformConcatenation`),d=t(e=>{if(e.includes(`*`)){let[t,n]=e.split(`*`);return{min:t?parseInt(t,10):0,max:n?parseInt(n,10):1/0}}let t=parseInt(e,10);return{min:t,max:t}},`parseRepeat`),f=t(e=>{let t=p(e.primary);if(!e.repeat)return t;let{min:n,max:r}=d(e.repeat);return n===0&&r===1?{type:`optional`,element:t}:{type:`repetition`,element:t,min:n,max:r}},`transformElement`),p=t(e=>{switch(e.$type){case`AbnfStringLiteral`:return{type:`terminal`,value:e.value};case`AbnfNumVal`:return{type:`terminal`,value:e.value};case`AbnfRuleName`:return{type:`nonterminal`,name:e.name};case`AbnfGroup`:return l(e.element);case`AbnfOptionalGroup`:return{type:`optional`,element:l(e.element)};default:throw Error(`Unsupported ABNF primary node: ${e.$type}`)}},`transformPrimary`),m=t(e=>({name:e.name,definition:l(e.definition)}),`transformRule`),h=t(e=>{o(e,a),e.title&&a.setTitle(e.title),e.rules.map(e=>a.addRule(m(e)))},`populateDb`),g={parser:{parse:t(e=>{a.clear(),n.debug(`[ABNF Parser] Starting Langium parse`);let t=c.parse(e);if(t.lexerErrors.length>0||t.parserErrors.length>0)throw new s(t);let r=t.value;n.debug(`[ABNF Parser] Parsed rules:`,r.rules.length),h(r),n.debug(`[ABNF Parser] Parse complete`)},`parse`),parser:{yy:a}},db:a,renderer:i,styles:r};export{g as diagram};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./path-BAQ3hXlG.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,u as p}from"./dist-DelZBZpK.js";function m(e){return e.innerRadius}function h(e){return e.outerRadius}function g(e){return e.startAngle}function _(e){return e.endAngle}function v(e){return e&&e.padAngle}function y(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function b(e,t,n,r,i,a,o){var c=e-n,l=t-r,u=(o?a:-a)/d(c*c+l*l),f=u*l,p=-u*c,m=e+f,h=t+p,g=n+f,_=r+p,v=(m+g)/2,y=(h+_)/2,b=g-m,x=_-h,S=b*b+x*x,C=i-a,w=m*_-g*h,T=(x<0?-1:1)*d(s(0,C*C*S-w*w)),E=(w*x-b*T)/S,D=(-w*b-x*T)/S,O=(w*x+b*T)/S,k=(-w*b+x*T)/S,A=E-v,j=D-y,M=O-v,N=k-y;return A*A+j*j>M*M+N*N&&(E=O,D=k),{cx:E,cy:D,x01:-f,y01:-p,x11:E*(i/C-1),y11:D*(i/C-1)}}function x(){var s=m,x=h,S=e(0),C=null,w=g,T=_,E=v,D=null,O=t(k);function k(){var e,t,m=+s.apply(this,arguments),h=+x.apply(this,arguments),g=w.apply(this,arguments)-r,_=T.apply(this,arguments)-r,v=l(_-g),k=_>g;if(D||=e=O(),h<m&&(t=h,h=m,m=t),!(h>1e-12))D.moveTo(0,0);else if(v>c-1e-12)D.moveTo(h*u(g),h*a(g)),D.arc(0,0,h,g,_,!k),m>1e-12&&(D.moveTo(m*u(_),m*a(_)),D.arc(0,0,m,_,g,k));else{var A=g,j=_,M=g,N=_,P=v,F=v,I=E.apply(this,arguments)/2,L=I>1e-12&&(C?+C.apply(this,arguments):d(m*m+h*h)),R=p(l(h-m)/2,+S.apply(this,arguments)),z=R,B=R,V,H;if(L>1e-12){var U=o(L/m*a(I)),W=o(L/h*a(I));(P-=U*2)>1e-12?(U*=k?1:-1,M+=U,N-=U):(P=0,M=N=(g+_)/2),(F-=W*2)>1e-12?(W*=k?1:-1,A+=W,j-=W):(F=0,A=j=(g+_)/2)}var G=h*u(A),K=h*a(A),q=m*u(N),J=m*a(N);if(R>1e-12){var Y=h*u(j),X=h*a(j),Z=m*u(M),Q=m*a(M),$;if(v<i)if($=y(G,K,Z,Q,Y,X,q,J)){var ee=G-$[0],te=K-$[1],ne=Y-$[0],re=X-$[1],ie=1/a(f((ee*ne+te*re)/(d(ee*ee+te*te)*d(ne*ne+re*re)))/2),ae=d($[0]*$[0]+$[1]*$[1]);z=p(R,(m-ae)/(ie-1)),B=p(R,(h-ae)/(ie+1))}else z=B=0}F>1e-12?B>1e-12?(V=b(Z,Q,G,K,h,B,k),H=b(Y,X,q,J,h,B,k),D.moveTo(V.cx+V.x01,V.cy+V.y01),B<R?D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,h,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),!k),D.arc(H.cx,H.cy,B,n(H.y11,H.x11),n(H.y01,H.x01),!k))):(D.moveTo(G,K),D.arc(0,0,h,A,j,!k)):D.moveTo(G,K),!(m>1e-12)||!(P>1e-12)?D.lineTo(q,J):z>1e-12?(V=b(q,J,Y,X,m,-z,k),H=b(G,K,Z,Q,m,-z,k),D.lineTo(V.cx+V.x01,V.cy+V.y01),z<R?D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,m,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),k),D.arc(H.cx,H.cy,z,n(H.y11,H.x11),n(H.y01,H.x01),!k))):D.arc(0,0,m,N,M,k)}if(D.closePath(),e)return D=null,e+``||null}return k.centroid=function(){var e=(+s.apply(this,arguments)+ +x.apply(this,arguments))/2,t=(+w.apply(this,arguments)+ +T.apply(this,arguments))/2-i/2;return[u(t)*e,a(t)*e]},k.innerRadius=function(t){return arguments.length?(s=typeof t==`function`?t:e(+t),k):s},k.outerRadius=function(t){return arguments.length?(x=typeof t==`function`?t:e(+t),k):x},k.cornerRadius=function(t){return arguments.length?(S=typeof t==`function`?t:e(+t),k):S},k.padRadius=function(t){return arguments.length?(C=t==null?null:typeof t==`function`?t:e(+t),k):C},k.startAngle=function(t){return arguments.length?(w=typeof t==`function`?t:e(+t),k):w},k.endAngle=function(t){return arguments.length?(T=typeof t==`function`?t:e(+t),k):T},k.padAngle=function(t){return arguments.length?(E=typeof t==`function`?t:e(+t),k):E},k.context=function(e){return arguments.length?(D=e??null,k):D},k}export{x as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-KEIR6QF5-77hsebd7.js";import{n as e}from"./chunk-MOZMSUNE-BbscOaEz.js";export{e as createArchitectureServices};
|