import{b as c}from"./vendor-lit-B2r-dKc0.js";import{a as m}from"./vendor-mini-lit-CpUQub-j.js";import{aG as h,aC as w,aE as g}from"./app-session-runtime-CeFJDILJ.js";import{aI as l}from"./vendor-lucide-B9Yl1Gez.js";import"./vendor-marked-_iteVaMm.js";import"./app-review-C3CmcSYC.js";import"./app-panel-workspace-C3XDRCgE.js";import"./app-routing-C_r2pdnC.js";import"./app-message-reducer-wATqnZGf.js";import"./vendor-sortable-B1o3v0Qs.js";import"./app-inbox-CaZD85aD.js";import"./app-pr-walkthrough-WipZACSB.js";function u(r){return r&&r.content?.filter(e=>e.type==="text").map(e=>e.text).join(`
`)||""}function A(r){if(!r||r.isError)return!1;const e=u(r);if(!e)return!1;try{const s=JSON.parse(e);return s&&typeof s=="object"&&s.status==="posted"}catch{return!1}}function v(r){if(!r||r.isError)return null;const e=u(r);if(!e)return null;try{const s=JSON.parse(e);if(s&&Array.isArray(s.answers))return s.answers.every(t=>t&&typeof t=="object"&&typeof t.question=="string"&&(typeof t.selected=="string"||Array.isArray(t.selected)&&t.selected.every(o=>typeof o=="string"))&&(t.other_text===null||typeof t.other_text=="string"))?s.answers:null}catch{}return null}function k(r){return u(r)||"ask_user_choices failed."}function p(r,e){return r!=="inprogress"?g(r,l,e):c`
		<div class="flex items-center justify-between gap-2 text-sm text-muted-foreground">
			<div class="flex items-center gap-2">
				<span class="inline-block text-foreground">${m(l,"sm")}</span>
				${e}
			</div>
			<span
				class="inline-block h-2.5 w-2.5 rounded-full bg-foreground ask-heartbeat"
				aria-label="Waiting for your answer"
				title="Waiting for your answer"
			></span>
		</div>
	`}class S{render(e,s,d,t){h();const o=w(s,d);if(!e||!Array.isArray(e.questions)||e.questions.length===0)return{content:c`<div>${p(o,"Preparing questions…")}</div>`,isCustom:!1};const n=A(s),y=n&&t?.toolUseId&&t?.getAskResponseAnswers?t.getAskResponseAnswers(t.toolUseId):null,f=n?null:v(s),a=y??f,i=!!s?.isError||o!=="inprogress"&&!!s&&!n&&!f;return{content:c`
				<div class="space-y-2">
					${(o==="inprogress"||n&&!a&&!i)&&!a&&!i?p("inprogress","Multiple-choice question"):g(o,l,"Multiple-choice question")}
					<ask-user-choices-widget
						.questions=${e.questions}
						.answers=${a}
						.sessionId=${t?.sessionId??""}
						.toolUseId=${t?.toolUseId??""}
						.errored=${i}
						.errorText=${i?k(s):""}
					></ask-user-choices-widget>
				</div>`,isCustom:!1}}}export{S as AskUserChoicesRenderer};
