const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-proposal-views-CORLubTd.js","assets/vendor-lit-B2r-dKc0.js","assets/dialogs-BrZ9PEV7.js","assets/app-review-C3CmcSYC.js","assets/app-panel-workspace-C3XDRCgE.js","assets/app-routing-C_r2pdnC.js","assets/app-review-DNV3xjGU.css","assets/vendor-mini-lit-CpUQub-j.js","assets/vendor-lucide-B9Yl1Gez.js","assets/vendor-marked-_iteVaMm.js","assets/app-session-runtime-CeFJDILJ.js","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/role-manager-page-CI1AvNQv.js","assets/config-scope-JGNcscE4.js","assets/settings-page-CwiRxxvO.js","assets/workflow-page-BL4cMP8Q.js","assets/ModelSelector-hAoZmp01.js","assets/ident-CvQrffF1.js","assets/edit-B9XsMHfU.js","assets/Input-Ck0OPeqZ.js","assets/ImageModelSelector-D_Zuy8sx.js","assets/tool-manager-page-BMC_NEuE.js","assets/render-triggers-6uF6FsL1.js"])))=>i.map(i=>d[i]);
import{s as t,a as g,r as l,P as Tt,ag as V,p as O,_}from"./app-review-C3CmcSYC.js";import{b as i,n as k,e as $}from"./vendor-lit-B2r-dKc0.js";import{I as J,a as R,B as P}from"./vendor-mini-lit-CpUQub-j.js";import{aV as ut,aW as Q,aX as De,aY as jt,w as Be,aZ as Ct,a_ as Et,al as It,aw as ge,aO as At,a$ as M,P as Dt,B as Lt,Q as Ot,b0 as Rt,b1 as Mt,r as vt,b2 as Ht,M as Nt,b3 as Wt,b4 as Ft,b5 as Gt,b6 as N,b7 as gt,aL as wt,b8 as Vt,b9 as oe,ba as Bt}from"./app-session-runtime-CeFJDILJ.js";import{setHashRoute as X,clearSessionModel as Le}from"./app-routing-C_r2pdnC.js";import{isHistoricalProposalTab as qt,proposalRevisionFromPanelTab as xt,activeSidePanelTabIdForSession as Ut,findPanelTab as zt,setActivePanelTabIdForSession as Yt,proposalPanelTabId as Kt}from"./app-panel-workspace-C3XDRCgE.js";import{C as Jt,b as Qt,E as Xt,m as Zt,G as eo,ao as to,W as oo,U as ro,j as so}from"./vendor-lucide-B9Yl1Gez.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 qe=new WeakMap,ao=5;function no(e){let r=qe.get(e);return r||(r={stickToBottom:!0,lastScrollHeight:e.scrollHeight,lastProgScrollTop:null,lastProgScrollHeight:null,selectionStart:0,selectionEnd:0,attached:!1},qe.set(e,r)),r.attached||(io(e,r),r.attached=!0),r}function io(e,r){const n=()=>{if(r.lastProgScrollTop!==null&&r.lastProgScrollHeight!==null&&e.scrollTop===r.lastProgScrollTop&&e.scrollHeight===r.lastProgScrollHeight){r.lastProgScrollTop=null,r.lastProgScrollHeight=null;return}r.stickToBottom=e.scrollHeight-e.scrollTop-e.clientHeight<ao},o=()=>{r.stickToBottom=!1},s=c=>{["PageUp","PageDown","Home","End","ArrowUp","ArrowDown"].includes(c.key)&&(r.stickToBottom=!1)},a=()=>{e instanceof HTMLTextAreaElement&&(r.selectionStart=e.selectionStart,r.selectionEnd=e.selectionEnd)};e.addEventListener("scroll",n,{passive:!0}),e.addEventListener("wheel",o,{passive:!0}),e.addEventListener("touchstart",o,{passive:!0}),e.addEventListener("keydown",s),e.addEventListener("select",a),e.addEventListener("keyup",a),e.addEventListener("click",a)}function T(e){if(!e)return;const r=no(e),n=e.scrollHeight,o=n-r.lastScrollHeight;if(o<0){if(r.lastScrollHeight=n,e instanceof HTMLTextAreaElement)try{e.setSelectionRange(r.selectionStart,r.selectionEnd)}catch{}return}if(o===0){if(e instanceof HTMLTextAreaElement)try{e.setSelectionRange(r.selectionStart,r.selectionEnd)}catch{}return}if(r.lastScrollHeight=n,r.stickToBottom){const s=n-e.clientHeight;r.lastProgScrollTop=s,r.lastProgScrollHeight=n,e.scrollTop=n}if(e instanceof HTMLTextAreaElement)try{e.setSelectionRange(r.selectionStart,r.selectionEnd)}catch{}}function Oe(e){return e?t.archivedSessions.some(r=>r.id===e):!1}let $e=null,Ue=!1;function lo(){return $e||(Ue||(Ue=!0,_(()=>import("./project-proposal-views-CORLubTd.js"),__vite__mapDeps([0,1])).then(e=>{$e=e,l()})),null)}function ze(e,r){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),o=n.lastIndexOf("/"),s=o>0?n.slice(0,o):n,a=o>0?n.slice(o+1):n,c=r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,10)||"untitled";return`${s}/${a}-wt/goal-${c}-xxxxxxxx/`}const me=new Map,Se=new Set;let W=[],L="",re=!1,se=!0,ae=!1,q=[];function Vo(e){L=e}function bt(e){if(!e){W=[];return}const r=me.get(e);if(r){W=r;return}Se.has(e)||(Se.add(e),Et(e).then(n=>{me.set(e,n),Se.delete(e),W=n,!L&&n.length>0&&(L=n[0].id),!F&&n.length>0&&(F=n[0].id),l()}))}function ue(e){return e?me.has(e)?(me.get(e)||[]).length===0?"empty":"ready":"loading":"no-project"}let _e=!1;const ce=new Map,ne=new Set;function co(e){ce.has(e)||ne.has(e)||(ne.add(e),O(`/api/projects/${e}/structured`).then(r=>r.json()).then(r=>{const n=Array.isArray(r?.components)?r.components:[],o=new Set;for(const a of n)o.add(a.repo||".");const s={repoCount:o.size,componentCount:n.length,multiRepo:n.some(a=>(a.repo||".")!==".")};ce.set(e,s),ne.delete(e),l()}).catch(()=>{ce.set(e,{repoCount:1,componentCount:0,multiRepo:!1}),ne.delete(e),l()}))}const K=new Map;let ie=!1;function po(e){K.has(e)||ie||(ie=!0,O(`/api/projects/${e}/qa-testing-config`).then(r=>r.json()).then(r=>{K.set(e,!!r.configured),ie=!1,l()}).catch(()=>{K.set(e,!1),ie=!1,l()}))}function Re(){t.sandboxStatus||_e||(_e=!0,It().then(e=>{_e=!1,e&&(t.sandboxStatus=e,l())}))}function Z(){return i`
		<span class="inline-flex items-center gap-1.5 text-[11px] text-muted-foreground"
			  data-testid="proposal-streaming-badge"
			  aria-live="polite">
			<span class="w-1.5 h-1.5 rounded-full bg-primary animate-pulse"></span>
			Streaming…
		</span>
	`}const j="border-l-2 border-l-primary/70 animate-pulse",Ye=$(),Ke=$(),Je=$(),Qe=$(),Xe=$(),Ze=$(),et=$();let E=0,Ee=0;async function fo(e){try{await navigator.clipboard.writeText(e)}catch{const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();try{document.execCommand("copy")}catch{}r.remove()}Ee=Date.now(),l(),setTimeout(()=>{Date.now()-Ee>=1500&&l()},1600)}let I=0,A=0,ve="",le=null;function Bo(e){ve=e,le&&clearTimeout(le),le=setTimeout(()=>{ve="",le=null,l()},2500),l()}function Me(e){e==="goal"?E=0:e==="role"?I=0:e==="staff"&&(A=0)}function we(){t.assistantHasProposal=Tt.some(e=>t.activeProposals[e]!=null)}function He(e,r){e&&(r==="goal"||r==="role"||r==="staff")&&(De(e,r),Me(r))}function Ne(e){const r=jt(),n=Kt(e),o=Ut(t,Be());if(o===n||!zt(r,o)){const s=r[0];s?Ct(s):Yt(t,Be(),"")}}function xe(e){const r=t.activeProposals[e],n=r?.sessionId??g();He(n,e),n&&r?.fields&&ut(n,e,r.fields),delete t.activeProposals[e],we(),Ne(e),n&&Q(n,e),l()}function We(){return ve?i`<div class="review-toast" data-testid="proposal-toast">${ve}</div>`:""}const tt=$(),ot=$(),rt=$(),st=$(),at=$(),nt=$();function ht(e){ge();const r=e.linkedProjectId?t.projects.find(p=>p.id===e.linkedProjectId):null,n=e.workflowState??"ready",o=n==="empty",s=n==="loading",a=ze(r?r.rootPath:e.cwd,e.title),c=W.find(p=>p.id===e.workflowId);c&&e.linkedProjectId&&po(e.linkedProjectId),e.linkedProjectId&&co(e.linkedProjectId);const u=e.linkedProjectId?ce.get(e.linkedProjectId):void 0,f=[];if(c){for(const p of c.gates)if(p.verify){for(const w of p.verify)if(w.optional){const C=w.optionalLabel||w.label||w.name;f.push({name:w.name,label:C,description:w.description,type:w.type})}}}const m=!!t.sandboxStatus?.configured,x=!!(t.sandboxStatus?.available&&t.sandboxStatus?.imageExists),v="text-xs text-muted-foreground font-medium shrink-0";queueMicrotask(()=>{T(Ye.value),T(Ke.value)});const h=(b?.type==="goal"?b.rev:t.activeProposals.goal?.rev)??0;return i`
		<div class="flex-1 overflow-y-auto px-5 pt-3 md:pt-4 pb-3 flex flex-col gap-2.5">
			${h>0?i`<div class="text-xs text-muted-foreground -mb-1" data-testid="proposal-panel-rev">rev ${h}</div>`:""}
			${o?i`
				<div
					class="rounded-md border p-3 flex flex-col gap-2"
					style="border-color: color-mix(in oklch, var(--warning) 40%, transparent); background: color-mix(in oklch, var(--warning) 10%, transparent);"
					data-testid="goal-form-no-workflows-banner"
				>
					<div class="text-sm font-medium">This project has no workflows yet</div>
					<p class="text-xs text-muted-foreground">Goals need a workflow to define gates and verification. Run the project assistant to scaffold workflows for this project.</p>
					<button
						class="self-start text-xs px-3 py-1.5 rounded-md border border-border bg-background hover:bg-secondary text-foreground"
						@click=${e.onOpenProjectAssistant}
						data-testid="goal-form-open-project-assistant"
						?disabled=${!e.onOpenProjectAssistant}
					>Open Project Assistant</button>
				</div>
			`:""}
			<div class="flex flex-col md:flex-row gap-2.5 md:items-center">
				<div class="flex items-center gap-2 flex-1 min-w-0">
					<label class="${v} w-20 md:w-16">Title</label>
					<div class="flex-1 min-w-0">
						${J({type:"text",value:e.title,placeholder:"Goal title",onInput:e.onTitleChange})}
					</div>
				</div>
				${s?i`
					<div class="flex items-center gap-2 md:shrink-0">
						<label class="${v} w-20 md:w-auto">Workflow</label>
						<div class="flex-1 md:flex-none md:w-44 h-9 rounded-md bg-muted/40 animate-pulse" data-testid="goal-form-workflow-skeleton"></div>
					</div>
				`:W.length>0?i`
					<div class="flex items-center gap-2 md:shrink-0">
						<label class="${v} w-20 md:w-auto">Workflow</label>
						<select
							class="flex-1 md:flex-none md:w-44 text-sm px-2 py-1.5 rounded-md border border-border bg-background text-foreground h-9"
							.value=${e.workflowId}
							@change=${e.onWorkflowChange}
						>
							${W.map(p=>i`
								<option value=${p.id} ?selected=${e.workflowId===p.id}>${p.name} (${p.gates.length} gates)</option>
							`)}
						</select>
					</div>
				`:""}
			</div>
			${r?i`
				<div class="flex items-center gap-2 text-[11px] text-muted-foreground min-w-0">
					<span class="${v} w-20 md:w-16">Worktree</span>
					<span class="truncate flex-1 min-w-0" title=${r.rootPath+" → "+a}>
						<span class="font-medium text-foreground/80">${r.name}</span>
						<code class="text-[10px] font-mono opacity-80 ml-1">${a}</code>
					</span>
				</div>
				${u?.multiRepo?i`
					<div class="flex items-center gap-2 text-[11px] text-muted-foreground min-w-0" data-testid="multi-repo-indicator">
						<span class="${v} w-20 md:w-16"></span>
						<span class="truncate flex-1 min-w-0 text-amber-600 dark:text-amber-400">
							Will create ${u.componentCount} worktree${u.componentCount===1?"":"s"}
							across ${u.repoCount} repo${u.repoCount===1?"":"s"}.
						</span>
					</div>
				`:""}
			`:i`
				<div class="flex items-start gap-2">
					<label class="${v} w-20 md:w-16 mt-2">Directory</label>
					<div class="flex-1 min-w-0">
						${At({value:e.cwd,onInput:e.onCwdChange,onSelect:e.onCwdSelect,dropdownOpen:e.cwdDropdownOpen,onToggle:e.onCwdToggle,highlightedIndex:e.cwdHighlightIndex,onHighlight:e.onCwdHighlight})}
						<p class="text-[11px] text-muted-foreground mt-0.5 opacity-70 truncate" title=${a}>Worktree: <code class="text-[10px]">${a}</code></p>
					</div>
				</div>
			`}
			<div class="flex flex-wrap items-center gap-x-4 gap-y-1.5 pt-0.5">
				${m?i`
					<label class="flex items-center gap-1.5 cursor-pointer ${x?"":"opacity-40 pointer-events-none"}">
						<input type="checkbox" class="toggle-switch" .checked=${e.sandboxed}
							?disabled=${!x}
							@change=${e.onSandboxChange} />
						<span class="text-xs text-muted-foreground font-medium">Sandbox</span>
						<span title=${x?"Runs each team agent in an isolated Docker container with restricted filesystem and network access":"Docker sandbox is configured but unavailable — check Docker status and image in Settings"}
							class="text-[9px] text-muted-foreground cursor-help">ⓘ</span>
					</label>
				`:""}
				<label class="flex items-center gap-1.5 cursor-pointer">
					<input type="checkbox" class="toggle-switch" .checked=${e.autoStartTeam}
						@change=${e.onAutoStartTeamChange} />
					<span class="text-xs text-muted-foreground font-medium">Auto-start team</span>
					<span title="Automatically start the team lead when the worktree is ready"
						class="text-[9px] text-muted-foreground cursor-help">ⓘ</span>
				</label>
				${f.map(p=>{const w=p.type==="agent-qa"&&!!e.linkedProjectId&&K.has(e.linkedProjectId)&&!K.get(e.linkedProjectId);return i`
					<label class="flex items-center gap-1.5 cursor-pointer ${w?"opacity-40 pointer-events-none":""}">
						<input type="checkbox" class="toggle-switch"
							.checked=${e.enabledOptionalSteps.includes(p.name)}
							?disabled=${w}
							@change=${C=>{const be=C.target.checked?e.enabledOptionalSteps.includes(p.name)?e.enabledOptionalSteps:[...e.enabledOptionalSteps,p.name]:e.enabledOptionalSteps.filter(he=>he!==p.name);e.onOptionalStepsChange(be)}}
						/>
						<span class="text-xs text-muted-foreground font-medium">${p.label}</span>
						${p.description?i`
							<span title=${w?"Set qa_start_command on a component's config map to enable QA testing":p.description}
								class="text-[9px] text-muted-foreground cursor-help">ⓘ</span>
						`:""}
					</label>
				`})}
			</div>
			<div class="flex-1 flex flex-col min-h-0">
				<div class="flex items-center justify-between mb-1.5">
					<div class="flex items-center gap-1">
						<label class="text-xs text-muted-foreground font-medium">Spec</label>
						${e.commentable&&!e.specEditMode&&E>0?i`
							<span class="ml-2 text-[10px] px-1.5 py-0.5 rounded-full bg-primary/15 text-primary"
								data-testid="proposal-comment-count">
								${E} comment${E===1?"":"s"}
							</span>
						`:""}
					</div>
					<div class="flex items-center gap-1">
						${(()=>{const p=Date.now()-Ee<1500;return i`<button
								class="inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded border border-border ${p?"text-primary border-primary":"text-muted-foreground hover:text-foreground hover:bg-secondary"} transition-colors"
								title="Copy spec markdown"
								@click=${()=>fo(e.spec)}
							>
								${R(p?Jt:Qt,"xs")}
								<span>${p?"Copied":"Copy"}</span>
							</button>`})()}
						<button
							class="inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-secondary transition-colors"
							title="Toggle edit/preview mode"
							@click=${e.onSpecEditToggle}
						>
							${R(e.specEditMode?Xt:Zt,"xs")}
							<span>${e.specEditMode?"Preview":"Edit"}</span>
						</button>
					</div>
				</div>
				${e.specEditMode?i`<textarea
							${k(Ke)}
							class="flex-1 min-h-[200px] p-3 text-sm font-mono rounded-md border border-border bg-background text-foreground resize-y focus:outline-none focus:ring-1 focus:ring-ring ${e.streaming?j:""}"
							.value=${e.spec}
							@input=${e.onSpecChange}
						></textarea>`:i`<div ${k(Ye)} class="flex-1 min-h-[200px] p-3 rounded-md border border-border bg-secondary/30 overflow-y-auto text-sm ${e.streaming?j:""}">
							${e.commentable?i`<commentable-markdown
										${k(Xe)}
										.markdown=${e.spec||"_No spec content yet_"}
										.sessionId=${g()||""}
										.bucket=${"proposal:goal"}
										@annotation-change=${p=>{E=p.detail?.count??0,l()}}
									></commentable-markdown>`:i`<markdown-block .content=${e.spec||"_No spec content yet_"}></markdown-block>`}
						</div>`}
			</div>
		</div>
		<div class="shrink-0 flex flex-col gap-3 px-5 py-3 border-t border-border">
			<div class="flex items-center justify-end gap-2">
				${e.streaming?Z():""}
				${e.commentable&&E>0&&!e.streaming?P({variant:"secondary",onClick:()=>{const p=Xe.value;if(!p)return;const w=p.sendFeedback();w&&t.remoteAgent&&t.remoteAgent.prompt(w),E=0,l()},children:i`<span data-testid="proposal-send-feedback">Send feedback (${E})</span>`}):""}
				${e.onDismiss?P({variant:"ghost",onClick:e.onDismiss,children:"Dismiss"}):""}
				<span
					data-testid="proposal-primary-submit"
					title=${o?"This project has no workflows yet — run the project assistant first.":""}
				>${P({variant:"default",onClick:e.onCreate,disabled:(e.createDisabled??!e.title.trim())||!!e.streaming||o,children:e.saving?"Creating…":i`<span class="inline-flex items-center gap-1.5">${R(eo,"sm")} Create Goal</span>`})}</span>
			</div>
		</div>
	`}function mo(){if(!t.previewProjectId){const o=g(),s=o?t.gatewaySessions.find(c=>c.id===o):void 0;let a=s?.projectId;if(!a&&s?.reattemptGoalId&&(a=t.goals.find(c=>c.id===s.reattemptGoalId)?.projectId),!a){const c=t.activeProposals.goal?.fields?.cwd;if(c){const u=m=>m.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase(),f=u(c);a=t.projects.find(m=>u(m.rootPath)===f)?.id}}a&&t.projects.some(c=>c.id===a)&&(t.previewProjectId=a)}bt(t.previewProjectId||void 0),Re();const e=async()=>{const o=t.previewTitle.trim();if(!o)return;if(!t.previewProjectId){N("No project selected for this goal","Select a project from the + New Goal picker before creating a goal.");return}if(ue(t.previewProjectId)==="empty"){N("This project has no workflows yet","Run the project assistant from the goal panel banner (or Settings → Components) to scaffold workflows before creating a goal.");return}const s=g(),a=t.previewProjectId||void 0,c=L||void 0,u=re,f=se,m=q.length>0?q:void 0,v=t.gatewaySessions.find(p=>p.id===s)?.reattemptGoalId;let h;try{h=await gt(o,t.previewCwd.trim(),{spec:t.previewSpec,workflowId:c,reattemptOf:v||void 0,sandboxed:u,projectId:a,enabledOptionalSteps:m,autoStartTeam:f})}catch(p){const{message:w,code:C,stack:ee}=wt(p);N("Failed to create goal",w,{code:C,stack:ee});return}h&&(t.remoteAgent&&(t.remoteAgent.disconnect(),t.remoteAgent=null,t.connectionStatus="disconnected"),t.assistantType=null,s&&De(s,"goal"),Me("goal"),delete t.activeProposals.goal,t.previewProjectId="",L="",re=!1,se=!0,q=[],s&&Bt(s),localStorage.removeItem("gateway.sessionId"),t.appView="authenticated",s&&Q(s,"goal"),v&&(await O(`/api/goals/${v}`,{method:"DELETE"}),await O(`/api/goals/${h.id}`,{method:"PUT",body:JSON.stringify({reattemptOf:v})})),s&&!Oe(s)&&(await O(`/api/sessions/${s}`,{method:"DELETE"}),Le(s)),await vt(),X("goal-dashboard",h.id,!0),l())},r=async()=>{const o=t.previewProjectId?t.projects.find(a=>a.id===t.previewProjectId):null;if(!o)return;const{createProjectAssistantSession:s}=await _(async()=>{const{createProjectAssistantSession:a}=await import("./dialogs-BrZ9PEV7.js");return{createProjectAssistantSession:a}},__vite__mapDeps([2,3,4,5,1,6,7,8,9,10,11,12,13,14,15]));await s(o.rootPath,!1,{projectId:o.id,existingProjectName:o.name||""})},n=b?.type==="goal";return i`
		<div class="goal-preview-panel flex-1 flex flex-col border-l border-border min-h-0 relative" data-panel="goal-proposal" data-historical-proposal=${n?"true":"false"}>
			${We()}
			${ht({title:t.previewTitle,spec:t.previewSpec,cwd:t.previewCwd,workflowId:L,sandboxed:re,specEditMode:t.previewSpecEditMode,enabledOptionalSteps:q,linkedProjectId:t.previewProjectId||void 0,workflowState:ue(t.previewProjectId||void 0),onOpenProjectAssistant:r,onTitleChange:o=>{t.previewTitle=o.target.value,t.previewTitleEdited=!0;const s=g();s&&oe(s),t._goalTitleDebounceTimer&&clearTimeout(t._goalTitleDebounceTimer);const a=o.target.value.trim();a.length>=3&&a!==t._lastSummarizedGoalTitle&&t.remoteAgent&&(t._goalTitleDebounceTimer=setTimeout(()=>{t._lastSummarizedGoalTitle=a,t.remoteAgent?.summarizeGoalTitle(a),t._goalTitleDebounceTimer=null},1e3))},onSpecChange:o=>{t.previewSpec=o.target.value,t.previewSpecEdited=!0;const s=g();s&&oe(s)},onCwdChange:o=>{t.previewCwd=o,t.previewCwdEdited=!0;const s=g();s&&oe(s),l()},onCwdSelect:o=>{t.previewCwd=o,t.previewCwdEdited=!0;const s=g();s&&oe(s),l()},onWorkflowChange:o=>{L=o.target.value,l()},onSandboxChange:o=>{re=o.target.checked,l()},onSpecEditToggle:()=>{t.previewSpecEditMode=!t.previewSpecEditMode,l()},onOptionalStepsChange:o=>{q=o,l()},autoStartTeam:se,onAutoStartTeamChange:o=>{se=o.target.checked,l()},cwdDropdownOpen:t.cwdDropdownOpen,cwdHighlightIndex:t.cwdHighlightIndex,onCwdToggle:o=>{t.cwdDropdownOpen=o,l()},onCwdHighlight:o=>{t.cwdHighlightIndex=o},onCreate:e,streaming:V("goal_proposal"),commentable:!0})}
		</div>
	`}let Ie=[],it=!1;function uo(){it||(it=!0,Nt().then(e=>{Ie=e,l()}))}function vo(){ge(),uo();const e=V("role_proposal");queueMicrotask(()=>{T(Je.value),T(Qe.value)});const r=async()=>{const o=t.rolePreviewName.trim(),s=t.rolePreviewLabel.trim();if(!o||!s)return;const a=t.activeProposals.role?.sessionId??g(),c=t.assistantType==="role",u=t.rolePreviewTools.split(",").map(v=>v.trim()).filter(Boolean),f={};for(const v of u)f[v]="allow";if(!await Wt({name:o,label:s,promptTemplate:t.rolePreviewPrompt,toolPolicies:Object.keys(f).length>0?f:void 0,accessory:t.rolePreviewAccessory}))return;He(a,"role"),delete t.activeProposals.role,we(),Ne("role"),a&&(Ft(a),Q(a,"role")),c&&(t.remoteAgent&&(t.remoteAgent.disconnect(),t.remoteAgent=null,t.connectionStatus="disconnected"),t.assistantType=null,localStorage.removeItem("gateway.sessionId"),a&&!Oe(a)&&(await O(`/api/sessions/${a}`,{method:"DELETE"}),Le(a)));const{loadRolePageData:x}=await _(async()=>{const{loadRolePageData:v}=await import("./role-manager-page-CI1AvNQv.js");return{loadRolePageData:v}},__vite__mapDeps([16,3,4,5,1,6,7,8,9,10,11,12,13,14,15,17,18,19,2,20,21,22,23,24]));await x(),X("roles"),l()},n=t.rolePreviewTools.split(",").map(o=>o.trim()).filter(Boolean);return i`
		<div class="goal-preview-panel flex-1 flex flex-col border-l border-border min-h-0 relative" data-panel="role-proposal">
			${We()}
			<div class="flex-1 overflow-y-auto p-5 flex flex-col gap-4">
				<div>
					<label class="text-xs text-muted-foreground mb-1.5 block font-medium">Name</label>
					${J({type:"text",value:t.rolePreviewName,placeholder:"role-name (lowercase, hyphens)",onInput:o=>{t.rolePreviewName=o.target.value,t.rolePreviewNameEdited=!0;const s=g();s&&M(s)}})}
				</div>
				<div>
					<label class="text-xs text-muted-foreground mb-1.5 block font-medium">Label</label>
					${J({type:"text",value:t.rolePreviewLabel,placeholder:"Display Label",onInput:o=>{t.rolePreviewLabel=o.target.value,t.rolePreviewLabelEdited=!0;const s=g();s&&M(s)}})}
				</div>
				<div>
					<label class="text-xs text-muted-foreground mb-1.5 block font-medium">Accessory</label>
					<div class="flex flex-wrap gap-2">
						${Dt.map(o=>{const s=Ot(o),a=t.rolePreviewAccessory===o;return i`
								<button
									class="flex flex-col items-center gap-1 px-2 py-1.5 rounded border transition-colors ${a?"border-primary bg-primary/10":"border-border hover:border-muted-foreground/50"}"
									@click=${()=>{t.rolePreviewAccessory=o,t.rolePreviewAccessoryEdited=!0;const c=g();c&&M(c),l()}}
									title=${s.label}
								>
									${Lt("idle",!1,void 0,a,!1,o==="crown",o==="bandana",o)}
									<span class="text-[10px] text-muted-foreground">${s.label}</span>
								</button>
							`})}
					</div>
				</div>
				<div>
					<label class="text-xs text-muted-foreground mb-1.5 block font-medium">Tools</label>
					<div class="flex flex-wrap gap-1 mb-2">
						${n.map(o=>i`
							<span class="inline-flex items-center gap-1 px-2 py-0.5 text-xs rounded-full bg-secondary text-secondary-foreground">
								${o}
								<button class="hover:text-destructive" title="Remove tool" @click=${()=>{const s=n.filter(c=>c!==o);t.rolePreviewTools=s.join(", "),t.rolePreviewToolsEdited=!0;const a=g();a&&M(a),l()}}>&times;</button>
							</span>
						`)}
						${n.length===0?i`<span class="text-xs text-muted-foreground italic">All tools allowed</span>`:""}
					</div>
					${Ie.length>0?i`
						<div class="flex flex-wrap gap-1">
							${Ie.filter(o=>!n.includes(o.name)).map(o=>i`
								<button
									class="text-[10px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-secondary transition-colors"
									title="${o.description}"
									@click=${()=>{const s=[...n,o.name];t.rolePreviewTools=s.join(", "),t.rolePreviewToolsEdited=!0;const a=g();a&&M(a),l()}}
								>+ ${o.name}</button>
							`)}
						</div>
					`:""}
				</div>
				<div class="flex-1 flex flex-col min-h-0">
					<div class="flex items-center justify-between mb-1.5">
						<div class="flex items-center gap-1">
							<label class="text-xs text-muted-foreground font-medium">System Prompt</label>
							${!t.rolePreviewPromptEditMode&&I>0?i`
								<span class="ml-2 text-[10px] px-1.5 py-0.5 rounded-full bg-primary/15 text-primary"
									data-testid="proposal-comment-count">
									${I} comment${I===1?"":"s"}
								</span>
							`:""}
						</div>
						<button
							class="text-[10px] px-2 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-secondary transition-colors"
							title="Toggle edit/preview mode"
							@click=${()=>{t.rolePreviewPromptEditMode=!t.rolePreviewPromptEditMode,l()}}
						>
							${t.rolePreviewPromptEditMode?"Preview":"Edit"}
						</button>
					</div>
					${t.rolePreviewPromptEditMode?i`<textarea
								${k(Qe)}
								class="flex-1 min-h-[200px] p-3 text-sm font-mono rounded-md border border-border bg-background text-foreground resize-y focus:outline-none focus:ring-1 focus:ring-ring ${e?j:""}"
								.value=${t.rolePreviewPrompt}
								@input=${o=>{t.rolePreviewPrompt=o.target.value,t.rolePreviewPromptEdited=!0;const s=g();s&&M(s)}}
							></textarea>`:i`<div ${k(Je)} class="flex-1 min-h-[200px] p-3 rounded-md border border-border bg-secondary/30 overflow-y-auto text-sm ${e?j:""}">
								<commentable-markdown
									${k(Ze)}
									.markdown=${t.rolePreviewPrompt||"_No prompt content yet_"}
									.sessionId=${g()||""}
									.bucket=${"proposal:role"}
									@annotation-change=${o=>{I=o.detail?.count??0,l()}}
								></commentable-markdown>
							</div>`}
				</div>
			</div>
			<div class="shrink-0 flex items-center justify-end gap-2 px-5 py-3 border-t border-border">
				${e?Z():""}
				${I>0&&!e?P({variant:"secondary",onClick:()=>{const o=Ze.value;if(!o)return;const s=o.sendFeedback();s&&t.remoteAgent&&t.remoteAgent.prompt(s),I=0,l()},children:i`<span data-testid="proposal-send-feedback">Send feedback (${I})</span>`}):""}
				${t.assistantType?"":P({variant:"ghost",onClick:()=>xe("role"),children:"Dismiss"})}
				<span data-testid="proposal-primary-submit">${P({variant:"default",onClick:r,disabled:!t.rolePreviewName.trim()||!t.rolePreviewLabel.trim()||e,children:i`<span class="inline-flex items-center gap-1.5">${R(ro,"sm")} Create Role</span>`})}</span>
			</div>
		</div>
	`}function go(){ge();const e=V("tool_proposal");queueMicrotask(()=>{T(tt.value),T(ot.value),T(rt.value)});const r=()=>{if(t.assistantType==="tool"){Ht();return}xe("tool")},n=async()=>{const f=t.toolPreviewName.trim();if(!f)return;const{loadToolPageData:m}=await _(async()=>{const{loadToolPageData:x}=await import("./tool-manager-page-BMC_NEuE.js");return{loadToolPageData:x}},__vite__mapDeps([25,3,4,5,1,6,7,8,9,10,11,12,13,14,15,17]));await m(),X("tool-edit",f),l()},o=t.toolPreviewChecklist,s=[{key:"docs",label:"Documentation",desc:"Usage examples, parameter descriptions"},{key:"renderer",label:"Renderer",desc:"Custom tool call display component"},{key:"tests",label:"Tests",desc:"Unit and E2E test coverage"},{key:"config",label:"Configuration",desc:"Tool metadata, groups, role access"}],a=f=>f==="done"?i`<span class="text-green-500">&#10003;</span>`:f==="in-progress"?i`<span class="text-yellow-500 animate-pulse">&#9679;</span>`:i`<span class="text-muted-foreground">&#9675;</span>`,c=Object.values(o).filter(f=>f==="done").length,u=s.length;return i`
		<div class="goal-preview-panel flex-1 flex flex-col border-l border-border min-h-0" data-panel="tool-proposal">
			<div ${k(rt)} class="flex-1 overflow-y-auto p-5 flex flex-col gap-4 ${e?j:""}">
				<!-- Tool name header -->
				<div>
					<div class="text-xs text-muted-foreground mb-1">Tool</div>
					<div class="text-lg font-semibold">${t.toolPreviewName||i`<span class="text-muted-foreground italic">Waiting for assistant...</span>`}</div>
				</div>

				<!-- Progress bar -->
				<div>
					<div class="flex items-center justify-between mb-1.5">
						<span class="text-xs text-muted-foreground font-medium">Progress</span>
						<span class="text-xs text-muted-foreground">${c}/${u}</span>
					</div>
					<div class="h-1.5 rounded-full bg-secondary overflow-hidden">
						<div class="h-full rounded-full bg-primary transition-all duration-500" style="width: ${c/u*100}%"></div>
					</div>
				</div>

				<!-- Checklist -->
				<div class="flex flex-col gap-2">
					${s.map(f=>i`
						<div class="flex items-start gap-2.5 p-2.5 rounded-md border border-border ${o[f.key]==="done"?"bg-green-500/5":""}">
							<div class="mt-0.5 text-sm">${a(o[f.key])}</div>
							<div class="flex-1 min-w-0">
								<div class="text-sm font-medium">${f.label}</div>
								<div class="text-xs text-muted-foreground">${f.desc}</div>
							</div>
						</div>
					`)}
				</div>

				<!-- Documentation preview -->
				${t.toolPreviewDocs?i`
					<div>
						<div class="text-xs text-muted-foreground mb-1.5 font-medium">Documentation Preview</div>
						<div ${k(tt)} class="p-3 rounded-md border border-border bg-secondary/30 overflow-y-auto text-sm max-h-[200px] ${e?j:""}">
							<markdown-block .content=${t.toolPreviewDocs}></markdown-block>
						</div>
					</div>
				`:""}

				<!-- Renderer preview -->
				${t.toolPreviewRendererHtml?i`
					<div>
						<div class="text-xs text-muted-foreground mb-1.5 font-medium">Renderer Preview</div>
						<div ${k(ot)} class="p-3 rounded-md border border-border bg-secondary/30 overflow-y-auto text-sm max-h-[300px] ${e?j:""}">
							<markdown-block .content=${t.toolPreviewRendererHtml}></markdown-block>
						</div>
					</div>
				`:""}
			</div>

			<!-- Footer -->
			<div class="shrink-0 flex items-center justify-end gap-2 px-5 py-3 border-t border-border">
				${e?Z():""}
				${P({variant:"ghost",onClick:r,children:t.assistantType==="tool"?"Close":"Dismiss"})}
				${t.toolPreviewName?i`<span data-testid="proposal-primary-submit">${P({variant:"default",onClick:n,disabled:e,children:i`<span class="inline-flex items-center gap-1.5">${R(oo,"sm")} View Tool</span>`})}</span>`:""}
			</div>
		</div>
	`}let Te=null,lt=!1;function Fe(){return Te||(lt||(lt=!0,_(()=>import("./render-triggers-6uF6FsL1.js"),__vite__mapDeps([26,1,3,4,5,6])).then(e=>{Te=e,l()})),null)}function wo(e){const r=Fe();if(r)return r.parseTriggers(e);try{const n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}function xo(){const e=Fe();return e?e.renderTriggersEditor():i`<div class="text-xs text-muted-foreground italic p-3 border border-dashed border-border rounded-md">Loading triggers editor…</div>`}function dt(){const e=Fe();return e?e.hasInvalidGoalTriggersForPreview():!1}function Pt(){return t.activeProposals.staff?.sessionId||g()}function yt(e=Pt()){if(!e)return;const r=t.gatewaySessions.find(o=>o.id===e)||t.archivedSessions.find(o=>o.id===e);if(r?.projectId)return r.projectId;const n=g();if(e===n||e===t.selectedSessionId||e===t.remoteAgent?.gatewaySessionId)return t.chatPanel?.agentInterface?.projectId||void 0}function Ge(){const e=yt();return e?t.projects.find(r=>r.id===e):void 0}function ct(e=Ge()){const r=t.staffPreviewCwd.trim();return r||e?.rootPath||void 0}function bo(e=Ge()){t.staffPreviewCwdEdited||t.staffPreviewCwd.trim()||e?.rootPath&&(t.staffPreviewCwd=e.rootPath)}function ho(){ge(),Re();const e=Ge();bo(e);const r=V("staff_proposal"),n=ct(e);queueMicrotask(()=>{T(st.value),T(at.value)});const o=async()=>{const s=t.staffPreviewName.trim();if(!s||dt())return;const a=Pt(),c=t.assistantType==="staff";let u=[];try{u=JSON.parse(t.staffPreviewTriggers)}catch{}const f=ae,m=yt(),x=m?t.projects.find(p=>p.id===m):void 0,v=ct(x),h=await Rt({name:s,description:t.staffPreviewDescription,systemPrompt:t.staffPreviewPrompt,cwd:v,worktree:t.staffPreviewWorktree,triggers:u,projectId:m,sandboxed:f});if(h){if(ae=!1,t.staffPreviewWorktree=!0,He(a,"staff"),delete t.activeProposals.staff,we(),Ne("staff"),a&&Q(a,"staff"),c&&(t.remoteAgent&&(t.remoteAgent.disconnect(),t.remoteAgent=null,t.connectionStatus="disconnected"),t.assistantType=null,localStorage.removeItem("gateway.sessionId"),X("landing"),t.appView="authenticated",a&&!Oe(a)&&(await O(`/api/sessions/${a}`,{method:"DELETE"}),Le(a))),Mt(),await vt(),h?.currentSessionId){const{connectToSession:p}=await _(async()=>{const{connectToSession:w}=await import("./app-session-runtime-CeFJDILJ.js").then(C=>C.bo);return{connectToSession:w}},__vite__mapDeps([10,1,7,8,9,3,4,5,6,11,12,13,14,15]));await p(h.currentSessionId,!1)}l()}};return i`
		<div class="goal-preview-panel flex-1 flex flex-col border-l border-border min-h-0 relative" data-panel="staff-proposal">
			${We()}
			<div class="flex-1 overflow-y-auto p-5 flex flex-col gap-4">
				<div>
					<label class="text-xs text-muted-foreground mb-1.5 block font-medium">Name</label>
					${J({type:"text",value:t.staffPreviewName,placeholder:"Staff agent name",onInput:s=>{t.staffPreviewName=s.target.value,t.staffPreviewNameEdited=!0}})}
				</div>
				<div>
					<label class="text-xs text-muted-foreground mb-1.5 block font-medium">Description</label>
					<textarea
						class="w-full p-2 text-sm rounded-md border border-border bg-background text-foreground resize-y focus:outline-none focus:ring-1 focus:ring-ring"
						rows="2"
						placeholder="What does this staff agent do?"
						.value=${t.staffPreviewDescription}
						@input=${s=>{t.staffPreviewDescription=s.target.value,t.staffPreviewDescriptionEdited=!0}}
					></textarea>
				</div>
				<div data-testid="staff-proposal-cwd-field">
					<label class="text-xs text-muted-foreground mb-1.5 block font-medium">Working Directory</label>
					<input
						type="text"
						data-testid="staff-proposal-cwd-input"
						class="flex h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-sm md:text-sm text-foreground shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] dark:bg-input/30"
						.value=${t.staffPreviewCwd}
						placeholder=${e?.rootPath||"Project working directory"}
						@input=${s=>{t.staffPreviewCwd=s.target.value,t.staffPreviewCwdEdited=!0}}
					/>
					<p class="mt-1 text-[11px] text-muted-foreground" data-testid="staff-proposal-cwd-hint">
						${e?i`Selected project: <span class="font-medium text-foreground/80">${e.name}</span> · <code class="text-[10px]">${e.rootPath}</code>`:n?i`Using <code class="text-[10px]">${n}</code>`:"No project cwd is available; the server will validate the request."}
					</p>
				</div>
				<div data-testid="staff-proposal-worktree-control">
					<label class="flex items-center gap-2 cursor-pointer">
						<input
							type="checkbox"
							data-testid="staff-proposal-worktree-checkbox"
							.checked=${t.staffPreviewWorktree}
							@change=${s=>{t.staffPreviewWorktree=s.target.checked,l()}}
						/>
						<span class="text-xs text-muted-foreground font-medium">Create worktree when supported</span>
						<span title="Uses an isolated project worktree for git-backed projects. Turn off to run directly in the project directory."
							class="text-[9px] text-muted-foreground cursor-help">ⓘ</span>
					</label>
					<p class="mt-1 text-[11px] text-muted-foreground" data-testid="staff-proposal-worktree-mode">
						${t.staffPreviewWorktree?"Auto: Bobbit will use a project worktree when supported.":"Opt-out: this staff agent will run in the project directory."}
					</p>
				</div>
				<div>
					<label class="flex items-center gap-1.5 cursor-pointer ${t.sandboxStatus?.available&&t.sandboxStatus?.imageExists?"":"opacity-40 pointer-events-none"}">
						<input type="checkbox" class="toggle-switch" .checked=${ae}
							?disabled=${!(t.sandboxStatus?.available&&t.sandboxStatus?.imageExists)}
							@change=${s=>{ae=s.target.checked,l()}} />
						<span class="text-xs text-muted-foreground font-medium">Sandbox (Docker)</span>
						<span title=${t.sandboxStatus?.available&&t.sandboxStatus?.imageExists?"Runs this staff agent in an isolated Docker container with restricted filesystem and network access":"Docker sandbox is configured but unavailable — check Docker status and image in Settings"}
							class="text-[9px] text-muted-foreground cursor-help">ⓘ</span>
					</label>
				</div>
				<div>
					<div class="flex items-center justify-between mb-1.5">
						<label class="text-xs text-muted-foreground font-medium">Triggers</label>
						<button
							class="text-[10px] px-2 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-secondary transition-colors"
							title="Add trigger"
							@click=${()=>{const s=wo(t.staffPreviewTriggers);s.push({type:"manual",config:{},enabled:!0,prompt:""}),t.staffPreviewTriggers=JSON.stringify(s),t.staffPreviewTriggersEdited=!0,l()}}
						>+ Add trigger</button>
					</div>
					${xo()}
				</div>
				<div>
					<div class="flex items-center justify-between mb-1.5">
						<div class="flex items-center gap-1">
							<label class="text-xs text-muted-foreground font-medium">System Prompt</label>
							${!t.staffPreviewPromptEditMode&&A>0?i`
								<span class="ml-2 text-[10px] px-1.5 py-0.5 rounded-full bg-primary/15 text-primary"
									data-testid="proposal-comment-count">
									${A} comment${A===1?"":"s"}
								</span>
							`:""}
						</div>
						<button
							class="text-[10px] px-2 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-secondary transition-colors"
							title="Toggle edit/preview mode"
							@click=${()=>{t.staffPreviewPromptEditMode=!t.staffPreviewPromptEditMode,l()}}
						>
							${t.staffPreviewPromptEditMode?"Preview":"Edit"}
						</button>
					</div>
					${t.staffPreviewPromptEditMode?i`<textarea
								${k(at)}
								class="p-3 text-sm font-mono rounded-md border border-border bg-background text-foreground resize-y focus:outline-none focus:ring-1 focus:ring-ring ${r?j:""}"
								style="min-height:150px; max-height:400px; width:100%"
								.value=${t.staffPreviewPrompt}
								@input=${s=>{t.staffPreviewPrompt=s.target.value,t.staffPreviewPromptEdited=!0}}
							></textarea>`:i`<div ${k(st)} class="p-3 rounded-md border border-border bg-secondary/30 overflow-y-auto text-sm ${r?j:""}" style="min-height:150px; max-height:400px">
								<commentable-markdown
									${k(et)}
									.markdown=${t.staffPreviewPrompt||"_No prompt content yet_"}
									.sessionId=${g()||""}
									.bucket=${"proposal:staff"}
									@annotation-change=${s=>{A=s.detail?.count??0,l()}}
								></commentable-markdown>
							</div>`}
				</div>
			</div>
			<div class="shrink-0 flex items-center justify-end gap-2 px-5 py-3 border-t border-border">
				${r?Z():""}
				${A>0&&!r?P({variant:"secondary",onClick:()=>{const s=et.value;if(!s)return;const a=s.sendFeedback();a&&t.remoteAgent&&t.remoteAgent.prompt(a),A=0,l()},children:i`<span data-testid="proposal-send-feedback">Send feedback (${A})</span>`}):""}
				${t.assistantType?"":P({variant:"ghost",onClick:()=>xe("staff"),children:"Dismiss"})}
				<span data-testid="proposal-primary-submit">${P({variant:"default",onClick:o,disabled:!t.staffPreviewName.trim()||r||dt(),children:i`<span class="inline-flex items-center gap-1.5">${R(to,"sm")} Create Staff</span>`})}</span>
			</div>
		</div>
	`}const Po=new Set(["build_command","test_command","typecheck_command","test_unit_command","test_e2e_command","worktree_setup_command"]),yo=new Set(["config_directories","sandbox_tokens","components","workflows"]),ko=new Set(["qa_start_command","qa_build_command","qa_health_check","qa_browser_entry","qa_env","qa_max_duration_minutes","qa_max_scenarios"]),$o=new Set(["sandbox","sandbox_image","sandbox_mounts","sandbox_credentials","sandbox_github_token","sandbox_host_token_overrides"]),je=[{key:"name",label:"Project Name"},{key:"worktree_root",label:"Worktree Root"},{key:"worktree_pool_size",label:"Worktree Pool Size"}];let Ae="components";function qo(){Ae="components"}function So(){const e=b?.type==="project"?{sessionId:t.activeProposals.project?.sessionId??"",fields:b.fields,rev:b.rev,mode:t.activeProposals.project?.mode}:t.activeProposals.project,r=V("project_proposal");if(queueMicrotask(()=>{T(nt.value)}),!e){const d=g();return(d?t.projectProposalAcceptedBySessionId[d]:!1)&&d?i`
				<div class="flex-1 flex flex-col min-h-0 w-full" data-panel="project-proposal" data-state="accepted">
					<div class="flex-1 flex items-center justify-center p-5">
						<div class="flex flex-col items-center gap-3 text-center max-w-sm">
							<div class="text-base font-medium" data-testid="project-changes-saved-heading">Changes Saved</div>
							<p class="text-sm text-muted-foreground">Your project configuration has been updated.</p>
							${P({variant:"default",onClick:async()=>{const{confirmAction:Pe}=await _(async()=>{const{confirmAction:ke}=await import("./dialogs-BrZ9PEV7.js");return{confirmAction:ke}},__vite__mapDeps([2,3,4,5,1,6,7,8,9,10,11,12,13,14,15]));if(!await Pe("Terminate Project Assistant","End this assistant session and return to the dashboard?","Terminate",!0))return;const{terminateProjectAssistantSession:ye}=await _(async()=>{const{terminateProjectAssistantSession:ke}=await import("./app-session-runtime-CeFJDILJ.js").then(_t=>_t.bo);return{terminateProjectAssistantSession:ke}},__vite__mapDeps([10,1,7,8,9,3,4,5,6,11,12,13,14,15]));await ye(d)},children:"Terminate Project Assistant"})}
						</div>
					</div>
				</div>
			`:i`
			<div class="flex-1 flex flex-col min-h-0 w-full" data-panel="project-proposal">
				<div class="flex-1 flex items-center justify-center text-muted-foreground text-sm p-5">
					Waiting for project analysis…
				</div>
			</div>
		`}const n=e.fields,o=n.components??[],s=n.workflows??{},a={};for(const[d,y]of Object.entries(n))if(!(d==="components"||d==="workflows"))if(typeof y=="string")a[d]=y;else if(y==null)a[d]="";else try{a[d]=JSON.stringify(y)}catch{a[d]=String(y)}const c=e.mode??"provisional",u=c==="registered",f=new Set(je.map(d=>d.key)),m=[];for(const d of Object.keys(a))d!=="root_path"&&(Po.has(d)||yo.has(d)||ko.has(d)||$o.has(d)||f.has(d)||m.push(d));const x=async()=>{const{acceptProjectProposal:d}=await _(async()=>{const{acceptProjectProposal:y}=await import("./app-session-runtime-CeFJDILJ.js").then(S=>S.bo);return{acceptProjectProposal:y}},__vite__mapDeps([10,1,7,8,9,3,4,5,6,11,12,13,14,15]));await d()},v=()=>{e?.sessionId&&Gt(e.sessionId),xe("project")},h=(d,y)=>{const S=t.activeProposals.project;S&&(d==="components"||d==="workflows"||(S.fields[d]=y,(t.assistantType==="project"||t.assistantType==="project-scaffolding")&&Vt(S.sessionId),l()))},p={name:"my-project",worktree_root:"C:\\Users\\me\\my-project-wt   (default: <root>-wt)",worktree_pool_size:"2"},w=(d,y)=>{const S=a[d]??"",Pe=p[d]??"";return i`
			<div data-field=${d}>
				<label class="text-xs text-muted-foreground mb-1.5 block font-medium">${y}</label>
				${J({type:d==="worktree_pool_size"?"number":"text",value:S,placeholder:Pe,onInput:ye=>h(d,ye.target.value)})}
			</div>
		`},C=je.map(d=>d.key),ee=d=>je.find(S=>S.key===d)?.label??d,be=u?"Apply Changes":"Accept Project",he=!a.name?.trim(),te=Ae,kt=d=>{Ae=d,l()},B=lo(),Ve=i`
		<div data-testid="settings-view" class="flex flex-col gap-4">
			${w("name","Project Name")}
			<div data-field="root_path" data-readonly="true">
				<label class="text-xs text-muted-foreground mb-1.5 block font-medium">Root Path</label>
				<div class="px-3 py-1.5 text-sm font-mono rounded-md border border-border bg-secondary/30 text-foreground/80 truncate" title=${a.root_path||""}>
					${a.root_path||"—"}
				</div>
			</div>
			${C.filter(d=>d!=="name").map(d=>w(d,ee(d)))}
			${m.length>0?i`
				<details data-testid="other-settings-group" class="border-t border-border pt-3">
					<summary class="text-xs text-muted-foreground cursor-pointer select-none font-medium">
						Other settings (${m.length})
					</summary>
					<p class="text-[11px] text-muted-foreground mt-2 mb-3">
						Non-standard project.yaml fields. The agent or a previous user added these; edit them here or remove the entry by clearing the value.
					</p>
					<div class="flex flex-col gap-4">
						${m.map(d=>w(d,d))}
					</div>
				</details>
			`:""}
		</div>
	`,$t=b?.type==="project";return i`
		<div class="flex-1 flex flex-col min-h-0 min-w-0 w-full overflow-hidden" data-panel="project-proposal" data-mode=${c} data-historical-proposal=${$t?"true":"false"}>
			<div class="shrink-0 px-5 pt-4 pb-3 flex items-baseline gap-3 min-w-0">
				<div class="text-sm font-medium shrink-0">${a.name||"(unnamed project)"}</div>
				${e.rev>0?i`<span class="text-xs text-muted-foreground shrink-0" data-testid="proposal-panel-rev">rev ${e.rev}</span>`:""}
				<div class="text-[11px] text-muted-foreground font-mono truncate min-w-0" title=${a.root_path||""}>${a.root_path||""}</div>
			</div>
			${B?B.viewTabs(te,kt,{components:o.length,workflows:Object.keys(s).length}):i`<div class="px-5 py-2 text-xs text-muted-foreground">Loading project views…</div>`}
			<div ${k(nt)} class="flex-1 min-w-0 overflow-y-auto overflow-x-hidden p-5 ${r?j:""}">
				${!B||te==="settings"?Ve:te==="components"?B.componentsView(o):te==="workflows"?B.workflowsView(s,o):Ve}
			</div>
			<div class="shrink-0 flex items-center justify-end gap-2 px-5 py-3 border-t border-border">
				${r?Z():""}
				${P({variant:"ghost",onClick:v,children:"Dismiss"})}
				<span data-testid="proposal-primary-submit">${P({variant:"default",onClick:x,disabled:he||r,children:i`<span class="inline-flex items-center gap-1.5" data-testid="accept-label">${R(so,"sm")} ${be}</span>`})}</span>
			</div>
		</div>
	`}function _o(e){switch(e){case"goal":return Eo();case"project":return So();case"role":return vo();case"tool":return go();case"staff":return ho();default:return""}}function pt(e,r){return e==="goal"&&r()==="goal"?mo():_o(e)}function To(e){if(e.kind!=="proposal"||e.source.type!=="proposal")return"";const r=e.source.proposalType,n=xt(e);return i`
		<div class="goal-preview-panel flex-1 flex flex-col min-h-0 w-full" data-panel=${`${r}-proposal`} data-historical-proposal="true">
			<div class="flex-1 flex items-center justify-center text-muted-foreground text-sm p-5">
				Loading proposal revision${n?` ${n}`:""}…
			</div>
		</div>
	`}let z="",Y="",pe="",F="",fe=!1,ft=!1,mt=-1,H=!1,de=!1,U=!0,D=[],G=null,b=null,Ce=null;function jo(e){const r=e.components;if(Array.isArray(r)&&r.length>0)return e;const n={build_command:"build",test_command:"test",typecheck_command:"check",test_unit_command:"unit",test_e2e_command:"e2e"},o={};for(const[f,m]of Object.entries(n)){const x=e[f];typeof x=="string"&&x.trim().length>0&&(o[m]=x.trim())}const s=e.worktree_setup_command;if(!(Object.keys(o).length>0||typeof s=="string"&&s.trim().length>0))return e;const u={name:typeof e.name=="string"&&e.name.trim()||"default",repo:".",commands:o};return typeof s=="string"&&s.trim()&&(u.worktree_setup_command=s.trim()),{...e,components:[u]}}function Co(){const r=b?.type==="goal"?b.fields:t.activeProposals.goal?.fields;if(!r)return;const n=`${r.title}|${r.spec}|${r.cwd||""}|${r.workflow||""}|${r.options||""}`;if(G===n)return;G=n,z=r.title,pe=r.spec;const o=t.previewProjectId?t.projects.find(s=>s.id===t.previewProjectId):void 0;Y=r.cwd||o?.rootPath||"",F=r.workflow||"",fe=!1,D=r.options?r.options.split(",").map(s=>s.trim()).filter(Boolean):[],H=!1}function Eo(){if(!t.previewProjectId){const o=g(),s=o?t.gatewaySessions.find(c=>c.id===o):void 0;let a=s?.projectId;if(!a&&s?.reattemptGoalId&&(a=t.goals.find(c=>c.id===s.reattemptGoalId)?.projectId),!a){const c=t.activeProposals.goal?.fields?.cwd;if(c){const u=m=>m.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase(),f=u(c);a=t.projects.find(m=>u(m.rootPath)===f)?.id}}a&&t.projects.some(c=>c.id===a)&&(t.previewProjectId=a)}Co(),bt(t.previewProjectId||void 0),Re();const e=async()=>{const o=z.trim();if(!o||H)return;if(!t.previewProjectId){N("No project selected for this goal","The assistant session is not linked to a project. Dismiss this proposal and start a new goal from the + New Goal button.");return}if(ue(t.previewProjectId)==="empty"){N("This project has no workflows yet","Run the project assistant from the goal panel banner (or Settings → Components) to scaffold workflows before creating a goal.");return}const s=de,a=U,c=F||void 0,u=D.length>0?D:void 0,f=t.previewProjectId||void 0;H=!0,l();let m;try{try{m=await gt(o,Y.trim(),{spec:pe,workflowId:c,sandboxed:s,projectId:f,enabledOptionalSteps:u,autoStartTeam:a})}catch(x){const{message:v,code:h,stack:p}=wt(x);N("Failed to create goal",v,{code:h,stack:p});return}if(!m)return;delete t.activeProposals.goal,D=[],G=null,de=!1,U=!0,X("goal-dashboard",m.id,!0)}finally{H=!1,l()}},r=async()=>{const o=t.previewProjectId?t.projects.find(a=>a.id===t.previewProjectId):null;if(!o)return;const{createProjectAssistantSession:s}=await _(async()=>{const{createProjectAssistantSession:a}=await import("./dialogs-BrZ9PEV7.js");return{createProjectAssistantSession:a}},__vite__mapDeps([2,3,4,5,1,6,7,8,9,10,11,12,13,14,15]));await s(o.rootPath,!1,{projectId:o.id,existingProjectName:o.name||""})},n=()=>{const o=t.activeProposals.goal?.fields,s=g();s&&De(s,"goal"),Me("goal"),delete t.activeProposals.goal,G=null,D=[],U=!0;const a=g();a&&o&&(ut(a,o),Q(a,"goal")),we(),t.isPreviewSession?(t.previewPanelActiveTab="preview",t.previewPanelTab==="goal"&&(t.previewPanelTab="preview")):t.previewPanelTab==="goal"&&(t.previewPanelTab="chat"),l()};return ht({title:z,spec:pe,cwd:Y,workflowId:F,sandboxed:de,specEditMode:fe,enabledOptionalSteps:D,linkedProjectId:t.previewProjectId||void 0,workflowState:ue(t.previewProjectId||void 0),onOpenProjectAssistant:r,onTitleChange:o=>{z=o.target.value},onSpecChange:o=>{pe=o.target.value},onCwdChange:o=>{Y=o,l()},onCwdSelect:o=>{Y=o,l()},onWorkflowChange:o=>{F=o.target.value,l()},onSandboxChange:o=>{de=o.target.checked,l()},onSpecEditToggle:()=>{fe=!fe,l()},onOptionalStepsChange:o=>{D=o,l()},autoStartTeam:U,onAutoStartTeamChange:o=>{U=o.target.checked,l()},cwdDropdownOpen:ft,cwdHighlightIndex:mt,onCwdToggle:o=>{ft=o,l()},onCwdHighlight:o=>{mt=o},onCreate:e,onDismiss:n,saving:H,createDisabled:!z.trim()||H,streaming:V("goal_proposal"),commentable:!0})}function Uo(e,r){if(e.kind!=="proposal"||e.source.type!=="proposal")return"";const n=e.source.proposalType;if(qt(e)){const o=e.state?.fields&&typeof e.state.fields=="object"&&!Array.isArray(e.state.fields)?e.state.fields:void 0;if(!o)return To(e);const s=xt(e)||1;if(!b||b.type!==n||Ce!==o||b.rev!==s){const a=n==="project"?jo(o):o;b={type:n,fields:a,rev:s},Ce=o,G=null}return pt(n,r)}return b&&b.type===n&&(b=null,Ce=null,G=null),pt(n,r)}export{xe as dismissTypedProposal,Uo as proposalPanelContent,qo as resetProjectProposalPanel,Me as resetProposalAnnCount,Vo as setSelectedWorkflowId,Bo as showProposalToast};
