const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-session-runtime-CeFJDILJ.js","assets/vendor-lit-B2r-dKc0.js","assets/vendor-mini-lit-CpUQub-j.js","assets/vendor-lucide-B9Yl1Gez.js","assets/vendor-marked-_iteVaMm.js","assets/app-review-C3CmcSYC.js","assets/app-panel-workspace-C3XDRCgE.js","assets/app-routing-C_r2pdnC.js","assets/app-review-DNV3xjGU.css","assets/app-message-reducer-wATqnZGf.js","assets/vendor-sortable-B1o3v0Qs.js","assets/app-inbox-CaZD85aD.js","assets/app-pr-walkthrough-WipZACSB.js","assets/app-session-runtime--8a3Kqim.css","assets/dialogs-BrZ9PEV7.js"])))=>i.map(i=>d[i]);
import{r as c,p as ae,s as W,_ as E}from"./app-review-C3CmcSYC.js";import{b as i,A as L}from"./vendor-lit-B2r-dKc0.js";import{a as j,B as q}from"./vendor-mini-lit-CpUQub-j.js";import{K as ne,N as z,V as me,W as K,X as ie,Y as fe,M as ve,Z as H,S as ge}from"./app-session-runtime-CeFJDILJ.js";import{setHashRoute as F}from"./app-routing-C_r2pdnC.js";import{g as re,r as he,a as V,s as be,b as le,c as J,d as X,e as we,i as $e}from"./config-scope-JGNcscE4.js";import{s as Z,P as ye,m as _e}from"./vendor-lucide-B9Yl1Gez.js";import"./app-panel-workspace-C3XDRCgE.js";import"./vendor-marked-_iteVaMm.js";import"./app-message-reducer-wATqnZGf.js";import"./vendor-sortable-B1o3v0Qs.js";import"./app-inbox-CaZD85aD.js";import"./app-pr-walkthrough-WipZACSB.js";const N=["File System","Shell","Web","Browser","Agent","Team","Tasks","Gates","Other"];function l(e){return{type:"tool_result",content:[{type:"text",text:e}],tool_use_id:"mock"}}const ke={bash:{params:{command:"npm run check"},result:l(`No errors found.
`)},bash_bg:{params:{action:"create",command:"npm run dev"},result:l('{"id":"bg-1","status":"running"}')},read:{params:{path:"src/app/main.ts",limit:20},result:l(`import { html } from 'lit';
import { state } from './state.js';
// ...(18 more lines)`)},write:{params:{path:"src/app/example.ts",content:`export const hello = 'world';
`},result:l("File written: src/app/example.ts (1 line)")},edit:{params:{path:"src/app/main.ts",oldText:"const x = 1;",newText:"const x = 2;"},result:l("Successfully replaced text in src/app/main.ts.")},ls:{params:{path:"src/app"},result:l(`main.ts
render.ts
routing.ts
state.ts
api.ts
sidebar.ts`)},grep:{params:{pattern:"renderTool",path:"src/"},result:l(`src/ui/tools/index.ts:74: export function renderTool(
src/app/tool-manager-page.ts:10: import { renderTool } from '../ui/tools/index.js';`)},find:{params:{pattern:"**/*.css",path:"src/"},result:l(`src/app/app.css
src/app/role-manager.css
src/app/tool-manager.css`)},web_search:{params:{query:"lit html template best practices"},result:l(`1. Lit — Best Practices
   https://lit.dev/docs/components/best-practices/
   Guidelines for building efficient Lit components.

2. Web Components Guide
   https://developer.mozilla.org/en-US/docs/Web/API/Web_Components
   MDN reference for Web Components APIs.`)},web_fetch:{params:{url:"https://lit.dev/docs/"},result:l("Lit is a simple library for building fast, lightweight web components. It provides reactive state, declarative templates, and a small footprint...")},browser_navigate:{params:{url:"https://localhost:5173/dashboard"},result:l("Navigated to https://localhost:5173/dashboard")},browser_click:{params:{selector:"button[type='submit']"},result:l("Clicked element matching button[type='submit']")},browser_type:{params:{selector:"#username",text:"admin@example.com"},result:l("Typed into #username")},browser_eval:{params:{expression:"document.querySelectorAll('.todo-item').length"},result:l("12")},browser_wait:{params:{selector:".dashboard-content",timeout:5e3},result:l("Element .dashboard-content is visible")},browser_screenshot:{params:{selector:".main-content"},result:l("Screenshot captured")},delegate:{params:{instructions:"Review the auth module for security issues"},result:l(`No critical issues found. 2 minor suggestions:
1. Add rate limiting to login endpoint
2. Use constant-time comparison for tokens`)},workflow:{params:{action:"status"},result:l('{"workflow_id":"code-review","phase":"analysis","status":"in-progress","artifacts_collected":2}')},team_spawn:{params:{role:"coder",task:"Implement user authentication module"},result:l('{"sessionId":"sess-abc123","role":"coder","status":"idle"}')},team_list:{params:{},result:l('{"agents":[{"role":"coder","status":"working","sessionId":"sess-abc123","task":"Implement auth"},{"role":"reviewer","status":"idle","sessionId":"sess-def456","task":"Awaiting code review"}]}')},team_dismiss:{params:{session_id:"sess-abc123"},result:l('{"status":"dismissed","sessionId":"sess-abc123"}')},team_complete:{params:{},result:l('{"status":"completed","agents_dismissed":3}')},team_steer:{params:{session_id:"sess-abc123",message:"Focus on error handling first"},result:l('{"status":"steered"}')},team_prompt:{params:{session_id:"sess-abc123",message:"Run the test suite and fix any failures"},result:l('{"status":"queued","position":1}')},team_abort:{params:{session_id:"sess-abc123"},result:l('{"status":"aborted"}')},task_list:{params:{},result:l('{"tasks":[{"id":"task-001","title":"Implement login endpoint","type":"implementation","state":"complete"},{"id":"task-002","title":"Review auth module","type":"code-review","state":"in-progress"},{"id":"task-003","title":"Write integration tests","type":"testing","state":"todo"}]}')},task_create:{params:{title:"Add rate limiting middleware",type:"implementation"},result:l('{"id":"task-004","title":"Add rate limiting middleware","type":"implementation","state":"todo"}')},task_update:{params:{task_id:"task-002abcd",state:"complete",result_summary:"No issues found"},result:l('{"id":"task-002abcd","title":"Review auth module","type":"code-review","state":"complete"}')}};function xe(e){return ke[e]||{params:{example:"value"},result:l("OK")}}function Pe(e){const s=xe(e),t=H(e,s.params,void 0,!0),o=H(e,s.params,s.result,!1);return i`
		<div class="tools-renderer-preview">
			<div class="tools-renderer-preview-label">In progress</div>
			<div class="tools-renderer-preview-box">${t.content}</div>
			<div class="tools-renderer-preview-label">Complete</div>
			<div class="tools-renderer-preview-box">${o.content}</div>
		</div>
	`}let v="list",d=[],M=[],g={},I=[],B=new Set,G=new Set,n=null,R=!0,A="",k="",b="",w="",f="",y=!1,x=new Set,_="access";const Q={allow:"Allow",ask:"Ask",never:"Never"};function Se(e,s,t){if(t?.[e])return t[e];if(t){const a=e.split("__");if(a.length>=3){const r=a.slice(0,2).join("__");if(t[r])return t[r]}if(t[s])return t[s]}const o=d.find(a=>a.name===e);return o?.grantPolicy?o.grantPolicy:g[s]?g[s]:"allow"}function Te(e,s,t){if(t?.[e])return"tool override";if(t){const a=e.split("__");if(a.length>=3){const r=a.slice(0,2).join("__");if(t[r])return`from ${r}`}if(t[s])return`from ${s} role override`}return d.find(a=>a.name===e)?.grantPolicy?"tool default":g[s]?"group default":"system default"}async function O(){const e=re(),s=e?`/api/tools?projectId=${encodeURIComponent(e)}`:"/api/tools";try{const t=await ae(s);if(!t.ok)return[];const o=await t.json(),a=o.tools||o||[];return a.length>0&&typeof a[0]=="string"?a.map(r=>({name:r,description:"",group:"Other"})):a}catch{return[]}}async function at(){v="list",n=null,R=!0,y=!1,c();const[e,s,t,o]=await Promise.all([O(),ne(),z(),me()]);d=e,M=s,g=t,I=o,x=new Set(N);for(const a of d){const r=a.group||"Other";x.add(r)}R=!1,c()}function nt(){v="list",n=null,R=!0,y=!1}function T(){v="list",n=null,F("tools")}function $(e){v="edit",n=e,A=e.description,k=e.group,b=e.docs||"",w=e.detail_docs||"",f=e.grantPolicy||"",_="access",y=!1,F("tool-edit",e.name)}function ee(e,s,t,o,a){return i`
		<div class="tools-access-row">
			<span class="tools-access-row-label">${e}</span>
			<select class="tools-select tools-access-row-select"
				.value=${s}
				@change=${r=>t(r.target.value)}>
				${o.map(r=>i`<option value=${r.value} ?selected=${s===r.value}>${r.label}</option>`)}
			</select>
			<span class="tools-access-row-hint">${a?i`\u2192 ${a}`:L}</span>

		</div>
	`}function it(e){const s=d.find(t=>t.name===e);s?(v="edit",n=s,A=s.description,k=s.group,b=s.docs||"",w=s.detail_docs||"",f=s.grantPolicy||"",y=!1,c(),K(e).then(t=>{t&&n?.name===e&&(n=t,b===(s.docs||"")&&(b=t.docs||""),w===(s.detail_docs||"")&&(w=t.detail_docs||""),f===(s.grantPolicy||"")&&(f=t.grantPolicy||""),c())})):K(e).then(t=>{t?(v="edit",n=t,A=t.description,k=t.group,b=t.docs||"",w=t.detail_docs||"",f=t.grantPolicy||"",y=!1):(v="list",n=null),c()})}async function Ae(){if(!W.creatingSession){W.creatingSession=!0,c();try{const e=V(),t=await ae("/api/sessions",{method:"POST",body:JSON.stringify({toolAssistant:!0,projectId:e==="system"?"system":e})});if(!t.ok){const{errorFromResponse:r}=await E(async()=>{const{errorFromResponse:p}=await import("./app-session-runtime-CeFJDILJ.js").then(u=>u.bh);return{errorFromResponse:p}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]));throw await r(t,`Session creation failed: ${t.status}`)}const{id:o}=await t.json(),{connectToSession:a}=await E(async()=>{const{connectToSession:r}=await import("./app-session-runtime-CeFJDILJ.js").then(p=>p.bo);return{connectToSession:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]));await a(o,!1,{isToolAssistant:!0})}catch(e){const{showConnectionError:s}=await E(async()=>{const{showConnectionError:p}=await import("./dialogs-BrZ9PEV7.js");return{showConnectionError:p}},__vite__mapDeps([14,5,6,7,1,8,2,3,4,0,9,10,11,12,13])),{errorDetails:t}=await E(async()=>{const{errorDetails:p}=await import("./app-session-runtime-CeFJDILJ.js").then(u=>u.bh);return{errorDetails:p}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])),{message:o,code:a,stack:r}=t(e);s("Failed to create tool assistant",o,{code:a,stack:r})}finally{W.creatingSession=!1,c()}}}async function Ce(){if(!n)return;if(y=!0,c(),await fe(n.name,{description:A,group:k,docs:b,detail_docs:w,grantPolicy:f||null})){const[s]=await Promise.all([ve()]);d=s;const t=d.find(o=>o.name===n.name);if(t){const o=await K(t.name);$(o||t)}else T();return}y=!1,c()}function Oe(e){x.has(e)?x.delete(e):x.add(e),c()}function te(e){B.has(e)?B.delete(e):B.add(e),c()}function se(e,s){const t=`${e}::${s??""}`;G.has(t)?G.delete(t):G.add(t),c()}function Re(e,s){if(s.op!==void 0)return{sub:s.subNamespace,op:s.op};const t=`mcp__${e}__`,o=s.name.startsWith(t)?s.name.slice(t.length):s.name,a=o.indexOf("__");return a<0?{op:o}:{sub:o.slice(0,a),op:o.slice(a+2)}}async function De(e,s){await ie(e,s||null),g=await z(),c()}function oe(e,s,t){return i`
		<select class="tool-group-select"
			data-testid=${t}
			.value=${s}
			@click=${o=>o.stopPropagation()}
			@keydown=${o=>o.stopPropagation()}
			@change=${async o=>{o.stopPropagation();const a=o.target.value;await De(e,a)}}>
			<option value="" ?selected=${!s}>Allow (default)</option>
			<option value="allow" ?selected=${s==="allow"}>Allow</option>
			<option value="ask" ?selected=${s==="ask"}>Ask</option>
			<option value="never" ?selected=${s==="never"}>Never</option>
		</select>
	`}function Ie(){if(I.length===0)return i``;const e=i`<svg class="tool-group-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>`,s=new Map;for(const t of d)s.set(t.name,t);return i`
		<div class="tool-group" data-testid="mcp-section">
			<div class="tool-group-header" style="cursor: default;">
				<span class="tool-group-name">MCP</span>
				<span class="tool-group-count">${I.length} server${I.length!==1?"s":""}</span>
			</div>
			<div class="tool-group-items">
				${I.map(t=>{const o=B.has(t.name),a=t.status==="connected"?"text-emerald-600":t.status==="error"?"text-red-600":"text-muted-foreground",r=`mcp__${t.name}`,p=g[r]||"",u=new Map;for(const m of t.tools){const P=Re(t.name,m).sub??"",D=u.get(P)??[];D.push(m),u.set(P,D)}const C=Array.from(u.keys()).sort();return i`
						<div class="mcp-server-row" data-testid="mcp-server-row" data-server-name=${t.name}>
							<div class="tool-group-header"
								data-testid="mcp-server-toggle"
								tabindex="0" role="button"
								style="cursor: pointer;"
								@click=${()=>te(t.name)}
								@keydown=${m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),te(t.name))}}>
								<span style="display:inline-flex;transform:rotate(${o?0:-90}deg);transition:transform 0.15s;">${e}</span>
								<span class="tool-group-name">${t.name}</span>
								<span class="text-xs ${a}" data-testid="mcp-server-status">${t.status}</span>
								<span class="tool-group-count">${t.toolCount} operation${t.toolCount!==1?"s":""}</span>
								<span class="tool-group-policy-label">Group Policy:</span>
								${oe(r,p,"mcp-server-policy")}
							</div>
							${t.status==="error"&&t.error?i`<div class="text-xs text-red-600 px-3 pb-2" data-testid="mcp-server-error">${t.error}</div>`:L}
							${o?i`<div class="tool-group-items" style="padding-left: 1rem;">
										${C.length===0?i`<div class="tools-note px-3 py-2">No operations available.</div>`:C.map(m=>{const h=u.get(m),P=m.length>0,D=P?`mcp__${t.name}__${m}`:`mcp__${t.name}`,de=g[D]||"",pe=`${t.name}::${m}`,U=G.has(pe),Y=P?m:t.name;return i`
														<div class="mcp-tool-row" data-testid="mcp-tool-row" data-tool-name=${Y}>
															<div class="tool-group-header"
																data-testid="mcp-tool-toggle"
																tabindex="0" role="button"
																style="cursor: pointer;"
																@click=${()=>se(t.name,P?m:void 0)}
																@keydown=${S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),se(t.name,P?m:void 0))}}>
																<span style="display:inline-flex;transform:rotate(${U?0:-90}deg);transition:transform 0.15s;">${e}</span>
																<span class="tool-group-name">${Y}</span>
																<span class="tool-group-count">${h.length} operation${h.length!==1?"s":""}</span>
																<span class="tool-group-policy-label">Tool Policy:</span>
																${oe(D,de,"mcp-tool-policy")}
															</div>
															${U?i`<div class="mcp-server-ops" data-testid="mcp-server-ops" style="padding-left: 1.5rem;">
																		${h.map(S=>{const ue=s.get(S.name)??{name:S.name,description:S.description,group:`MCP: ${t.name}`};return ce(ue)})}
																	</div>`:L}
														</div>
													`})}
									</div>`:L}
						</div>
					`})}
			</div>
		</div>
	`}function Le(){if(v==="edit"&&n){const e=n&&(A!==n.description||k!==n.group||b!==(n.docs||"")||w!==(n.detail_docs||"")||f!==(n.grantPolicy||""));return i`
			<div class="tools-nav">
				<div class="tools-nav-left">
					<button class="tools-back" @click=${T} title="Back to tools">
						${j(Z,"sm")}
					</button>
					<div class="tools-title-group">
						<span class="tools-breadcrumb" @click=${T}>Tools</span>
						<span class="tools-breadcrumb-sep">/</span>
						<h1 class="tools-title">${n.name}</h1>
					</div>
				</div>
				<div class="tools-nav-right">
					${q({variant:"default",size:"sm",onClick:Ce,disabled:y||!e,children:y?"Saving…":"Save"})}
				</div>
			</div>
		`}return i`
		<div class="tools-nav">
			<div class="tools-nav-left">
				<button class="tools-back" @click=${()=>F("landing")} title="Back to sessions">
					${j(Z,"sm")}
				</button>
				<h1 class="tools-title">Tools</h1>
				<button
					class="text-xs text-muted-foreground hover:text-foreground transition-colors ml-2"
					@click=${()=>{F("settings","directories")}}
				>Manage scan directories &rarr;</button>
			</div>
			<div class="tools-nav-right">
				${q({variant:"default",size:"sm",onClick:Ae,children:i`<span class="inline-flex items-center gap-1.5 font-semibold">${j(ye,"sm")} New Tool</span>`})}
			</div>
		</div>
	`}async function Ee(e){be(e),R=!0,c(),d=await O(),x=new Set(N);for(const s of d){const t=s.group||"Other";x.add(t)}R=!1,c()}function ce(e){const s=e.origin,t=e.overrides,o=$e(s);return i`
		<div class="tool-row ${o?"config-item-inherited":""}" tabindex="0" role="button"
			@click=${()=>$(e)}
			@keydown=${a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),$(e))}}>
			<span class="tool-row-name">${e.name} ${le(s,t)}</span>
			<span class="tool-row-desc">${e.description}</span>
			<div class="tool-row-actions">
				<button class="tool-row-action-btn" @click=${a=>{a.stopPropagation(),$(e)}} title="Edit">
					${j(_e,"sm")}
				</button>
			</div>
		</div>
	`}function je(){if(R)return i`
			<div class="tools-loading">
				<svg class="animate-spin" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
					<path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
				</svg>
				<span>Loading tools\u2026</span>
			</div>
		`;if(d.length===0)return i`
			<div class="tools-empty">
				<p class="tools-empty-title">No tools found</p>
				<p class="tools-empty-desc">Tools are registered by the agent runtime and appear here automatically.</p>
			</div>
		`;const e=new Map;for(const o of d){if(o.name.startsWith("mcp__"))continue;const a=o.group||"Other",r=e.get(a)||[];r.push(o),e.set(a,r)}const s=N.filter(o=>e.has(o));for(const o of e.keys())s.includes(o)||s.push(o);const t=i`<svg class="tool-group-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>`;return i`
		<p class="text-sm text-muted-foreground mb-6" style="max-width: 700px; margin-inline: auto;">Tools are the capabilities available to agents \u2014 file editing, shell commands, web search, and more. This page lets you view and document them.</p>
		<div class="tools-list">
			${s.map(o=>{const a=e.get(o),r=x.has(o),p=g[o]||"";return i`
					<div class="tool-group ${r?"collapsed":""}">
						<div class="tool-group-header" title="Toggle ${o} group" @click=${()=>Oe(o)}>
							${t}
							<span class="tool-group-name">${o}</span>
							<span class="tool-group-count">${a.length} tool${a.length!==1?"s":""}</span>
							<span class="tool-group-policy-label">Group Policy:</span>
							<select class="tool-group-select"
								.value=${p}
								@click=${u=>u.stopPropagation()}
								@change=${async u=>{u.stopPropagation();const C=u.target.value;await ie(o,C||null),g=await z(),c()}}>
								<option value="" ?selected=${!p}>Allow (default)</option>
								<option value="allow" ?selected=${p==="allow"}>Allow</option>
								<option value="ask" ?selected=${p==="ask"}>Ask</option>
								<option value="never" ?selected=${p==="never"}>Never</option>
							</select>
						</div>
						<div class="tool-group-items">
							${a.map(u=>ce(u))}
						</div>
					</div>
				`})}
			${Ie()}
		</div>
	`}const Me=[{value:"",label:"Use group default"},{value:"allow",label:"Allow"},{value:"ask",label:"Ask"},{value:"never",label:"Never"}],Be=[{value:"",label:"Use default"},{value:"allow",label:"Allow"},{value:"ask",label:"Ask"},{value:"never",label:"Never"}];function Ge(){if(!n)return i``;const e=n.name,s=n.group||"Other",t=g[s]||"allow",o=Q[t]||t;return i`
		<!-- Default Grant Policy -->
		<div class="tools-section">
			<h2 class="tools-section-title">Default Grant Policy</h2>
			<p class="tools-note">Controls what happens when an agent uses this tool without explicit role permission.</p>
			<div class="tools-access-list">
				${ee("Default",f,a=>{f=a,c()},Me,f?void 0:`${o} [from group]`)}
			</div>
		</div>

		<!-- Role Access -->
		<div class="tools-section">
			<h2 class="tools-section-title">Role Access</h2>
			${M.length>0?i`
				<div class="tools-access-list">
					${M.map(a=>{const r=a.toolPolicies?.[e]||"",p=Se(e,s,a.toolPolicies),u=Q[p]||p,C=Te(e,s,a.toolPolicies);return ee(a.label,r,async m=>{const h={...a.toolPolicies||{}};m?h[e]=m:delete h[e],await ge(a.name,{toolPolicies:Object.keys(h).length>0?h:{}}),M=await ne(),c()},Be,`${u} [${C}]`)})}
				</div>
			`:i`<p class="tools-note">No roles defined yet.</p>`}
		</div>
	`}function Fe(){return n?i`
		<div class="tools-section">
			<h2 class="tools-section-title">Prompt Documentation</h2>
			<p class="tools-note">Injected into every agent's system prompt. Keep brief — critical notes and gotchas only.</p>
			<textarea
				class="tools-docs-editor"
				style="min-height:120px"
				.value=${b}
				placeholder="Brief notes for the system prompt..."
				@input=${e=>{b=e.target.value,c()}}
			></textarea>
		</div>
		<div class="tools-section" style="flex:1;display:flex;flex-direction:column;">
			<h2 class="tools-section-title">Detailed Documentation</h2>
			<p class="tools-note">Full reference — examples, edge cases. Agents read on demand; NOT injected into prompts.</p>
			<textarea
				class="tools-docs-editor"
				.value=${w}
				placeholder="Full documentation with examples, edge cases..."
				@input=${e=>{w=e.target.value,c()}}
			></textarea>
		</div>
	`:i``}function Ne(){return n?i`
		<div class="tools-section">
			<div class="tools-renderer-card-inline">
				<span class="tools-renderer-dot ${n.hasRenderer?"tools-renderer-dot--custom":"tools-renderer-dot--default"}"></span>
				<span class="tools-renderer-label">${n.hasRenderer?"Custom renderer":"Default renderer"}</span>
				${n.rendererFile?i`<span class="tools-renderer-path" style="margin-left:auto;">${n.rendererFile}</span>`:L}
			</div>
		</div>
		<div class="tools-section">
			<h2 class="tools-section-title">Preview</h2>
			${Pe(n.name)}
		</div>
	`:i``}function We(){switch(_){case"access":return Ge();case"context":return Fe();case"renderer":return Ne()}}function Ke(){return n?i`
		<div class="tools-edit">
			<div class="tools-edit-main">
				<!-- Compact identity rows -->
				<div class="tools-identity-section">
					${n.origin?i`<div class="mb-1 inline-flex items-center gap-2">${le(n.origin,n.overrides)}${ze()}</div>`:""}
					<div class="tools-identity-row">
						<label class="tools-field-label">Name</label>
						<div class="tools-field-readonly">${n.name}</div>
						<label class="tools-field-label" style="margin-left:8px;">Group</label>
						<select class="tools-select" style="width:auto"
							.value=${k}
							@change=${e=>{k=e.target.value,c()}}>
							${N.map(e=>i`<option value=${e} ?selected=${k===e}>${e}</option>`)}
						</select>
					</div>
					<div class="tools-identity-row">
						<label class="tools-field-label">Description</label>
						<input class="tools-input"
							.value=${A}
							placeholder="Short description of what this tool does"
							@input=${e=>{A=e.target.value,c()}} />
					</div>
				</div>

				<!-- Sub-tab row -->
				<div class="tools-tab-bar">
					<button class="tools-tab ${_==="access"?"tools-tab--active":""}"
						@click=${()=>{_="access",c()}}>Access</button>
					<button class="tools-tab ${_==="context"?"tools-tab--active":""}"
						@click=${()=>{_="context",c()}}>Context</button>
					<button class="tools-tab ${_==="renderer"?"tools-tab--active":""}"
						@click=${()=>{_="renderer",c()}}>Renderer</button>
				</div>

				<!-- Tab content -->
				<div class="tools-tab-content">
					${We()}
				</div>
			</div>
		</div>
	`:i``}function ze(){if(!n)return"";const e=n.origin;if(!e)return"";const s=V(),t=re();if(s==="system"){if(e==="builtin")return i`<button class="config-action-btn" @click=${async()=>{if(await J("tools",n.name,"server")){d=await O();const o=d.find(a=>a.name===n.name);o?$(o):T()}}}>Customize at Server Level</button>`;if(e==="server")return i`<button class="config-action-btn config-action-btn--revert" @click=${async()=>{if(await X("tools",n.name,"server")){d=await O();const o=d.find(a=>a.name===n.name);o?$(o):T()}}}>Revert to Builtin</button>`}else{if(e==="builtin"||e==="server")return i`<button class="config-action-btn" @click=${async()=>{if(await J("tools",n.name,"project",t)){d=await O();const o=d.find(a=>a.name===n.name);o?$(o):T()}}}>Customize for ${we()}</button>`;if(e==="project")return i`<button class="config-action-btn config-action-btn--revert" @click=${async()=>{if(await X("tools",n.name,"project",t)){d=await O();const o=d.find(a=>a.name===n.name);o?$(o):T()}}}>Revert to Inherited</button>`}return""}function rt(){return i`
		<div class="tools-container">
			${Le()}
			${v==="list"?he(V(),Ee):""}
			<div class="tools-body">
				${v==="list"?je():Ke()}
			</div>
		</div>
	`}export{nt as clearToolPageState,at as loadToolPageData,it as navigateToToolEdit,rt as renderToolManagerPage};
