import{r as _,a as g,t as F,i as C,b as i}from"./vendor-lit-BtHfzs80.js";import{au as O,aw as x}from"./index-rvuS68Al.js";import{a as j}from"./vendor-mini-lit-Cx886NBU.js";import{e as E,a9 as R,p as b}from"./vendor-lucide-DBEJLfdn.js";import{p as A}from"./proposal-rev-marker-BsTX0uwt.js";import"./vendor-marked-_iteVaMm.js";import"./vendor-sortable-B1o3v0Qs.js";var L=Object.defineProperty,N=Object.getOwnPropertyDescriptor,f=(e,t,r,n)=>{for(var o=n>1?void 0:n?N(t,r):t,s=e.length-1,l;s>=0;s--)(l=e[s])&&(o=(n?l(t,r,o):l(o))||o);return n&&o&&L(t,r,o),o};let d=class extends C{constructor(){super(...arguments),this.defaultExpanded=!1,this.expanded=!1,this.capturedChildren=[]}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.capturedChildren=Array.from(this.childNodes),this.innerHTML="",this.expanded=this.defaultExpanded}render(){return i`
			<div>
				<button
					@click=${()=>{this.expanded=!this.expanded}}
					class="flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors w-full text-left"
				>
					${j(this.expanded?E:R,"sm")}
					<span>${this.summary}</span>
				</button>
				${this.expanded?i`<div class="mt-2">${this.capturedChildren}</div>`:""}
			</div>
		`}};f([g()],d.prototype,"summary",2);f([g({type:Boolean})],d.prototype,"defaultExpanded",2);f([_()],d.prototype,"expanded",2);d=f([F("expandable-section")],d);const y={propose_goal:{label:"Goal Proposal",type:"goal",titleField:"title",previewField:"spec"},propose_role:{label:"Role Proposal",type:"role",titleField:"name",previewField:"prompt"},propose_tool:{label:"Tool Proposal",type:"tool",titleField:"tool",previewField:"content"},propose_staff:{label:"Staff Proposal",type:"staff",titleField:"name",previewField:"prompt"},propose_project:{label:"Project Proposal",type:"project",titleField:"name",previewField:"root_path"}};function S(e,t=150){return e?e.length>t?e.slice(0,t)+"…":e:""}function w(e,t){if(!e)return t;if(!t)return e;const r={...t,...e};for(const[n,o]of Object.entries(t)){const s=e[n];(s==null||s==="")&&o!==void 0&&o!==null&&o!==""&&(r[n]=o)}return r}function u(e){if(!e)return null;if(typeof e=="object"&&e!==null&&!Array.isArray(e))return w(u(e.arguments),u(e.input))??e;if(typeof e=="string")try{return JSON.parse(e)}catch{return null}return null}class ${constructor(t){this._toolName=t||"propose_goal"}withToolName(t){return new $(t)}render(t,r,n,o){const s=O(r,n),l=y[this._toolName]||y.propose_goal,a=w(u(t),u(o?.toolCallInput));if(!a&&n)return{content:i`
					<div>
						${x(s,b,`Generating ${l.label.toLowerCase()}…`)}
					</div>
				`,isCustom:!1};const v=a?.[l.titleField]||"",m=a?.[l.previewField]||"",p=A(r),P=h=>{h.preventDefault(),h.stopPropagation();const c={type:l.type};a&&(c.fields=a),typeof p=="number"&&p>0?c.rev=p:a||(c.fields={}),document.dispatchEvent(new CustomEvent("proposal-open",{detail:c}))};return{content:i`
				<div class="space-y-2">
					${x(s,b,l.label)}
					${v?i`<div class="text-sm font-medium">${v}</div>`:""}
					${typeof p=="number"&&p>0?i`<div class="text-xs text-muted-foreground" data-testid="proposal-rev">rev ${p}</div>`:""}
					${m?i`<expandable-section .summary=${S(m,80)}><markdown-block .content=${m}></markdown-block></expandable-section>`:""}
					${r?i`
						<div class="flex justify-end">
							<button
								@click=${P}
								class="inline-flex items-center gap-1 px-2 py-1 text-xs font-medium rounded bg-primary/10 text-primary hover:bg-primary/20 transition-colors cursor-pointer"
								data-testid="proposal-open-button"
							>
								Open proposal
							</button>
						</div>
					`:""}
				</div>
			`,isCustom:!1}}}export{$ as ProposalRenderer,A as parseRevFromResult};
