import{r as _,a as g,t as F,i as C,b as l}from"./vendor-lit-B2r-dKc0.js";import{aC as O,aE as x}from"./app-session-runtime-CeFJDILJ.js";import{a as j}from"./vendor-mini-lit-CpUQub-j.js";import{e as E,aa as R,p as b}from"./vendor-lucide-B9Yl1Gez.js";import{p as A}from"./proposal-rev-marker-BsTX0uwt.js";import"./app-review-C3CmcSYC.js";import"./app-panel-workspace-C3XDRCgE.js";import"./app-routing-C_r2pdnC.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";var L=Object.defineProperty,N=Object.getOwnPropertyDescriptor,f=(e,t,r,n)=>{for(var o=n>1?void 0:n?N(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(n?s(t,r,o):s(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 l`
			<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?l`<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 i=e[n];(i==null||i==="")&&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 i=O(r,n),s=y[this._toolName]||y.propose_goal,p=w(u(t),u(o?.toolCallInput));if(!p&&n)return{content:l`
					<div>
						${x(i,b,`Generating ${s.label.toLowerCase()}…`)}
					</div>
				`,isCustom:!1};const v=p?.[s.titleField]||"",m=p?.[s.previewField]||"",a=A(r),P=h=>{h.preventDefault(),h.stopPropagation();const c={type:s.type};p&&(c.fields=p),typeof a=="number"&&a>0?c.rev=a:p||(c.fields={}),document.dispatchEvent(new CustomEvent("proposal-open",{detail:c}))};return{content:l`
				<div class="space-y-2">
					${x(i,b,s.label)}
					${v?l`<div class="text-sm font-medium">${v}</div>`:""}
					${typeof a=="number"&&a>0?l`<div class="text-xs text-muted-foreground" data-testid="proposal-rev">rev ${a}</div>`:""}
					${m?l`<expandable-section .summary=${S(m,80)}><markdown-block .content=${m}></markdown-block></expandable-section>`:""}
					${r?l`
						<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};
