import{m as e,p as t}from"./lit-runtime-gkTRPNbC.js";import{o as n}from"./string-coerce-DvNMpYW3.js";import{A as r,C as i,D as a,E as o,L as s,O as c,S as l,T as u,_ as d,b as f,j as p,k as m,v as h,w as g,x as _,y as v}from"./index-B1ruzz-3.js";var y=[{id:`bugfix`,title:`Fix: `,notes:`Symptom:
Cause:
Acceptance:
Proof:`,labels:`fix, test`,priority:`high`},{id:`docs`,title:`Docs: `,notes:`Page:
Change:
Source proof:`,labels:`docs`,priority:`normal`},{id:`release`,title:`Release: `,notes:`Scope:
Verification:
Closeout:`,labels:`release`,priority:`urgent`},{id:`pr_review`,title:`Review PR `,notes:`Surface:
Risks:
Proof:`,labels:`review`,priority:`normal`},{id:`plugin`,title:`Plugin: `,notes:`Boundary:
Config/docs:
Tests:`,labels:`plugin`,priority:`normal`}];function b(e){return n(`workboard.status.${e}`)}function x(e){return e?s(e,{month:`short`,day:`numeric`},``):``}function S(e){return e.canWrite!==!1}function C(e){switch(e.kind){case`created`:return n(`workboard.eventCreated`);case`edited`:return n(`workboard.eventEdited`);case`moved`:return e.toStatus?n(`workboard.eventMovedTo`,{status:b(e.toStatus)}):n(`workboard.eventMoved`);case`linked`:return n(`workboard.eventLinked`);case`specified`:return n(`workboard.eventSpecified`);case`decomposed`:return n(`workboard.eventDecomposed`);case`claimed`:return n(`workboard.eventClaimed`);case`heartbeat`:return n(`workboard.eventHeartbeat`);case`execution_updated`:return n(`workboard.eventExecutionUpdated`);case`attempt_started`:return n(`workboard.eventAttemptStarted`);case`attempt_updated`:return n(`workboard.eventAttemptUpdated`);case`comment_added`:return n(`workboard.eventCommentAdded`);case`link_added`:return n(`workboard.eventLinkAdded`);case`proof_added`:return n(`workboard.eventProofAdded`);case`artifact_added`:return n(`workboard.eventArtifactAdded`);case`attachment_added`:return n(`workboard.eventAttachmentAdded`);case`diagnostic`:return n(`workboard.eventDiagnostic`);case`notification`:return n(`workboard.eventNotification`);case`dispatch`:return n(`workboard.eventDispatch`);case`orchestration`:return n(`workboard.eventOrchestration`);case`protocol_violation`:return n(`workboard.eventProtocolViolation`);case`archived`:return n(`workboard.eventArchived`);case`unarchived`:return n(`workboard.eventUnarchived`);case`stale`:return n(`workboard.eventStale`)}return``}function w(r){let i=(r.events??[]).toReversed().slice(0,4);return i.length===0?t:e`
    <ol class="workboard-events" aria-label=${n(`workboard.eventsLabel`)}>
      ${i.map(t=>e`
          <li>
            <span>${C(t)}</span>
            <time>${x(t.at)}</time>
          </li>
        `)}
    </ol>
  `}function T(r,i){let a=r.metadata,o=[a?.templateId?n(`workboard.template.${a.templateId}`):null,i??r.taskId?n(`workboard.badgeTaskLinked`):null,a?.failureCount?n(`workboard.badgeFailures`,{count:String(a.failureCount)}):null,a?.comments?.length?n(`workboard.badgeComments`,{count:String(a.comments.length)}):null,a?.proof?.length?n(`workboard.badgeProof`,{count:String(a.proof.length)}):null,a?.claim?n(`workboard.badgeClaimed`,{owner:a.claim.ownerId}):null,a?.diagnostics?.length?n(`workboard.badgeDiagnostics`,{count:String(a.diagnostics.length)}):null,a?.stale?n(`workboard.badgeStale`):null].filter(e=>!!e);return o.length===0?t:e`
    <div class="workboard-card__badges">${o.map(t=>e`<span>${t}</span>`)}</div>
  `}function E(e,t){if(t.priority!==`all`&&e.priority!==t.priority)return!1;let n=t.query.trim().toLowerCase();return n?[e.title,e.notes,e.agentId,e.sessionKey,e.execution?.engine,e.execution?.mode,e.execution?.model,e.execution?.sessionKey,e.metadata?.templateId,e.metadata?.automation?.tenant,e.metadata?.automation?.idempotencyKey,e.metadata?.automation?.workspace?.kind,e.metadata?.automation?.workspace?.path,e.metadata?.automation?.workspace?.branch,...e.metadata?.automation?.skills??[],...e.metadata?.automation?.createdCardIds??[],...(e.metadata?.comments??[]).map(e=>e.body),...(e.metadata?.links??[]).flatMap(e=>[e.title,e.url,e.targetCardId]),...(e.metadata?.proof??[]).flatMap(e=>[e.label,e.command,e.url,e.note]),...(e.metadata?.artifacts??[]).flatMap(e=>[e.label,e.url,e.path,e.mimeType]),...(e.metadata?.attachments??[]).flatMap(e=>[e.fileName,e.mimeType,e.note]),...(e.metadata?.workerLogs??[]).map(e=>e.message),e.metadata?.workerProtocol?.state,e.metadata?.workerProtocol?.detail,e.metadata?.claim?.ownerId,...(e.metadata?.diagnostics??[]).flatMap(e=>[e.kind,e.severity,e.title,e.detail]),...(e.metadata?.notifications??[]).map(e=>e.message),...e.labels].filter(e=>typeof e==`string`).some(e=>e.toLowerCase().includes(n)):!0}function D(e,t){let n=e.filter(e=>e.status===t).map(e=>e.position);return(n.length?Math.max(...n):0)+1e3}function O(e){if(e.archived||e.kind===`global`)return!1;let t=[e.key,e.label,e.displayName].filter(e=>typeof e==`string`).join(`:`).toLowerCase();return!/(^|:)heartbeat(:|$)/.test(t)}function k(e){return e.target instanceof Element?!!e.target.closest(`button, a, input, select, textarea`):!1}function A(e,t){e.detailCardId=t.id,e.detailCommentBody=``}function j(e){e.draftOpen=!1,e.editingCardId=null,e.draftTitle=``,e.draftNotes=``,e.draftStatus=`todo`,e.draftPriority=`normal`,e.draftLabels=``,e.draftAgentId=``,e.draftSessionKey=``,e.draftTemplateId=``,e.draftCommentBody=``}function M(e){j(e),e.draftOpen=!0}function N(e,t){e.draftOpen=!0,e.editingCardId=t.id,e.draftTitle=t.title,e.draftNotes=t.notes??``,e.draftStatus=t.status,e.draftPriority=t.priority,e.draftLabels=t.labels.join(`, `),e.draftAgentId=t.agentId??``,e.draftSessionKey=t.sessionKey??``,e.draftTemplateId=t.metadata?.templateId??``,e.draftCommentBody=``}function P(e,t){let n=y.find(e=>e.id===t);n&&(e.draftTemplateId=n.id,e.draftTitle=n.title,e.draftNotes=n.notes,e.draftLabels=n.labels,e.draftPriority=n.priority)}function F(r){let i=u(r.host),a=r.agentsList?.agents??[],o=r.sessions.filter(O);if(!i.draftOpen)return t;let s=!!i.editingCardId,l=(i.editingCardId?i.cards.find(e=>e.id===i.editingCardId)??null:null)?.metadata?.comments??[],f=s&&i.busyCardId===i.editingCardId;return e`
    <div
      class="workboard-modal"
      role="presentation"
      @click=${e=>{e.target===e.currentTarget&&(j(i),r.onRequestUpdate?.())}}
    >
      <form
        class="workboard-draft"
        role="dialog"
        aria-modal="true"
        aria-labelledby="workboard-card-modal-title"
        @submit=${e=>{e.preventDefault(),!(i.loading||f)&&c({host:r.host,client:r.client,requestUpdate:r.onRequestUpdate})}}
      >
        <div class="workboard-modal__header">
          <div>
            <h2 id="workboard-card-modal-title">
              ${n(s?`workboard.editCard`:`workboard.newCard`)}
            </h2>
            <p>${n(s?`workboard.editCardHelp`:`workboard.newCardHelp`)}</p>
          </div>
          <button
            class="btn btn--icon workboard-card__icon"
            type="button"
            title=${n(`common.cancel`)}
            @click=${()=>{j(i),r.onRequestUpdate?.()}}
          >
            ${d.x}
          </button>
        </div>
        ${s?t:e`
              <div class="workboard-template-strip" aria-label=${n(`workboard.templatesLabel`)}>
                ${y.map(t=>e`
                    <button
                      class="btn btn--xs ${i.draftTemplateId===t.id?`workboard-template-strip__button--active`:``}"
                      type="button"
                      @click=${()=>{P(i,t.id),r.onRequestUpdate?.()}}
                    >
                      ${n(`workboard.template.${t.id}`)}
                    </button>
                  `)}
              </div>
            `}
        <div class="workboard-draft__main">
          <label class="workboard-field">
            <span>${n(`workboard.fieldTitle`)}</span>
            <input
              class="input workboard-draft__title"
              placeholder=${n(`workboard.titlePlaceholder`)}
              .value=${i.draftTitle}
              @input=${e=>{i.draftTitle=e.currentTarget.value,r.onRequestUpdate?.()}}
            />
          </label>
          <label class="workboard-field">
            <span>${n(`workboard.fieldNotes`)}</span>
            <textarea
              class="input workboard-draft__notes"
              placeholder=${n(`workboard.notesPlaceholder`)}
              .value=${i.draftNotes}
              @input=${e=>{i.draftNotes=e.currentTarget.value,r.onRequestUpdate?.()}}
            ></textarea>
          </label>
        </div>
        <div class="workboard-draft__meta">
          <label class="workboard-field">
            <span>${n(`workboard.fieldStatus`)}</span>
            <select
              class="input"
              .value=${i.draftStatus}
              @change=${e=>{i.draftStatus=e.currentTarget.value,r.onRequestUpdate?.()}}
            >
              ${i.statuses.map(t=>e`<option value=${t}>${b(t)}</option>`)}
            </select>
          </label>
          <label class="workboard-field">
            <span>${n(`workboard.fieldPriority`)}</span>
            <select
              class="input"
              .value=${i.draftPriority}
              @change=${e=>{i.draftPriority=e.currentTarget.value,r.onRequestUpdate?.()}}
            >
              ${h.map(t=>e`<option value=${t}>${t}</option>`)}
            </select>
          </label>
          <label class="workboard-field">
            <span>${n(`workboard.fieldAgent`)}</span>
            <select
              class="input"
              .value=${i.draftAgentId}
              @change=${e=>{i.draftAgentId=e.currentTarget.value,r.onRequestUpdate?.()}}
            >
              <option value="">${n(`workboard.defaultAgent`)}</option>
              ${a.map(t=>e`<option value=${t.id}>
                    ${t.name??t.identity?.name??t.id}
                  </option>`)}
            </select>
          </label>
          <label class="workboard-field">
            <span>${n(`workboard.fieldSession`)}</span>
            <select
              class="input"
              .value=${i.draftSessionKey}
              @change=${e=>{i.draftSessionKey=e.currentTarget.value,r.onRequestUpdate?.()}}
            >
              <option value="">${n(`workboard.noLinkedSession`)}</option>
              ${o.map(t=>e`<option value=${t.key}>
                    ${t.displayName??t.label??t.key}
                  </option>`)}
            </select>
          </label>
          <label class="workboard-field workboard-field--wide">
            <span>${n(`workboard.fieldLabels`)}</span>
            <input
              class="input"
              placeholder=${n(`workboard.labelsPlaceholder`)}
              .value=${i.draftLabels}
              @input=${e=>{i.draftLabels=e.currentTarget.value,r.onRequestUpdate?.()}}
            />
          </label>
        </div>
        ${s?e`
              <section
                class="workboard-field workboard-field--wide"
                aria-labelledby="workboard-card-comments-title"
              >
                <span id="workboard-card-comments-title">
                  ${n(`workboard.badgeComments`,{count:String(l.length)})}
                </span>
                ${l.length?e`
                      <ol>
                        ${l.map(t=>e`<li>${t.body}</li>`)}
                      </ol>
                    `:t}
                <textarea
                  class="input workboard-comments__input"
                  aria-labelledby="workboard-card-comments-title"
                  maxlength="2000"
                  .value=${i.draftCommentBody}
                  @input=${e=>{i.draftCommentBody=e.currentTarget.value,r.onRequestUpdate?.()}}
                ></textarea>
                <div class="workboard-modal__actions">
                  <button
                    class="btn"
                    type="button"
                    ?disabled=${i.loading||f||!i.draftCommentBody.trim()}
                    @click=${()=>{v({host:r.host,client:r.client,requestUpdate:r.onRequestUpdate})}}
                  >
                    ${d.plus} ${n(`common.create`)}
                  </button>
                </div>
              </section>
            `:t}
        <div class="workboard-modal__actions">
          <button
            class="btn primary"
            ?disabled=${i.loading||f||!i.draftTitle.trim()}
          >
            ${n(s?`common.save`:`common.create`)}
          </button>
          <button
            class="btn"
            type="button"
            @click=${()=>{j(i),r.onRequestUpdate?.()}}
          >
            ${n(`common.cancel`)}
          </button>
        </div>
      </form>
    </div>
  `}function I(e){switch(e.state){case`running`:return{label:n(`workboard.lifecycleRunning`),detail:n(`workboard.lifecycleRunningDetail`),tone:`live`};case`succeeded`:return{label:n(`workboard.lifecycleDone`),detail:n(`workboard.lifecycleDoneDetail`),tone:`done`};case`failed`:return{label:n(`workboard.lifecycleNeedsReview`),detail:n(`workboard.lifecycleNeedsReviewDetail`),tone:`blocked`};case`stale`:return{label:n(`workboard.lifecycleStale`),detail:n(`workboard.lifecycleStaleDetail`),tone:`blocked`};case`idle`:return{label:n(`workboard.lifecycleLinked`),detail:n(`workboard.lifecycleIdleDetail`),tone:`idle`};case`missing`:return{label:n(`workboard.lifecycleMissing`),detail:n(`workboard.lifecycleMissingDetail`),tone:`blocked`};case`unlinked`:return{label:n(`workboard.lifecycleUnlinked`),detail:n(`workboard.lifecycleUnlinkedDetail`),tone:`idle`}}throw Error(`Unknown workboard lifecycle state.`)}function L(e){return e.status===`queued`||e.status===`running`?e.progressSummary??e.title??e.taskId:e.terminalSummary??e.error??e.progressSummary??e.title??e.taskId}function R(e,t){switch(e.status){case`queued`:case`running`:return t.state===`running`;case`completed`:return t.state===`succeeded`;case`failed`:case`cancelled`:case`timed_out`:return t.state===`failed`}return!1}function z(e){return e?.status===`queued`||e?.status===`running`}function B(e,t,n){let r=e.tasksByCardId.get(n.id),a=i(n,t),o=z(r),s=n.sessionKey??n.execution?.sessionKey;return!o&&(!s||!a)}function V(t,r,i){let a=g(t,r,i),o=I(a),s=a.session,c=t.execution,l=a.state===`stale`,u=i?R(i,a):!1,d=i&&u?n(`workboard.taskStatus.${i.status}`):null;return e`
    <div class="workboard-card__lifecycle">
      <span class="workboard-lifecycle workboard-lifecycle--${o.tone}">
        ${d??(l||!c?o.label:`${c.engine} ${c.mode}`)}
      </span>
      <span class="workboard-card__lifecycle-detail">
        ${i&&u?L(i):l?o.detail:s?.displayName??s?.label??o.detail}
      </span>
    </div>
  `}function H(t,r,i,a){let o=u(t.host).busyCardId===r.id,s=i?n(a===`autonomous`?`workboard.runEngine`:`workboard.openEngine`,{engine:i}):n(`workboard.runDefaultAgent`);return e`
    <button
      class="btn btn--xs workboard-card__start workboard-card__start--${a} ${i?``:`workboard-card__start--default`}"
      title=${s}
      ?disabled=${o||!t.connected}
      @click=${async()=>{let e=await m({host:t.host,client:t.client,card:r,...i?{engine:i}:{},mode:a,requestUpdate:t.onRequestUpdate});e&&t.onOpenSession(e)}}
    >
      ${a===`autonomous`?d.play:d.penLine} ${i??n(`workboard.start`)}
    </button>
  `}function U(n,r){let i=n.canModelOverride!==!1;return e`
    <div class="workboard-card__execution-controls">
      ${H(n,r,null,`autonomous`)}
      ${i?e`${H(n,r,`codex`,`autonomous`)}
          ${H(n,r,`claude`,`autonomous`)}`:t}
      ${H(n,r,`codex`,`manual`)}
      ${H(n,r,`claude`,`manual`)}
    </div>
  `}function W(n,r){if(typeof r!=`string`&&typeof r!=`number`)return t;let i=String(r).trim();return i?e`
    <div class="workboard-detail__row">
      <span>${n}</span>
      <strong>${i}</strong>
    </div>
  `:t}function G(n,r,i=t){let a=r.map(e=>e.trim()).filter(Boolean).slice(-6);return a.length===0?i:e`
    <section class="workboard-detail__section">
      <h3>${n}</h3>
      <ol class="workboard-detail__list">
        ${a.map(t=>e`<li>${t}</li>`)}
      </ol>
    </section>
  `}function K(r){let i=u(r.host),a=i.detailCardId?i.cards.find(e=>e.id===i.detailCardId)??null:null;if(!a||a.metadata?.archivedAt)return t;let o=i.tasksByCardId.get(a.id),s=g(a,r.sessions,o),c=I(s),l=o?R(o,s):!1,f=a.sessionKey??a.execution?.sessionKey,p=S(r),m=a.metadata?.comments??[],h=a.metadata?.attempts??[],_=a.metadata?.links??[],y=a.metadata?.proof??[],w=a.metadata?.artifacts??[],T=a.metadata?.attachments??[],E=a.metadata?.diagnostics??[],D=a.metadata?.workerLogs??[],O=a.metadata?.workerProtocol,k=a.metadata?.automation,A=(a.events??[]).slice(-6).toReversed(),j=i.busyCardId===a.id,M=p&&B(i,r.sessions,a);return e`
    <aside class="workboard-detail-drawer" aria-label=${n(`workboard.detailTitle`)}>
      <div class="workboard-detail">
        <header class="workboard-detail__header">
          <div>
            <span class="workboard-card__priority">${a.priority}</span>
            <h2>${a.title}</h2>
          </div>
          <button
            class="btn btn--icon workboard-card__icon"
            type="button"
            title=${n(`common.cancel`)}
            @click=${()=>{i.detailCardId=null,i.detailCommentBody=``,r.onRequestUpdate?.()}}
          >
            ${d.x}
          </button>
        </header>

        <section class="workboard-detail__section">
          <div class="workboard-card__lifecycle">
            <span class="workboard-lifecycle workboard-lifecycle--${c.tone}">
              ${c.label}
            </span>
            <span class="workboard-card__lifecycle-detail">
              ${o&&l?L(o):s.session?.displayName??c.detail}
            </span>
          </div>
          <div class="workboard-detail__grid">
            ${W(n(`workboard.fieldStatus`),b(a.status))}
            ${W(n(`workboard.fieldAgent`),a.agentId??n(`workboard.defaultAgent`))}
            ${W(n(`workboard.detailTask`),o?.taskId??a.taskId)}
            ${W(n(`workboard.fieldSession`),f)}
            ${W(n(`workboard.detailRun`),a.runId??a.execution?.runId)}
            ${W(n(`workboard.detailUpdated`),x(a.updatedAt))}
          </div>
        </section>

        ${a.notes?e`
              <section class="workboard-detail__section">
                <h3>${n(`workboard.fieldNotes`)}</h3>
                <p>${a.notes}</p>
              </section>
            `:t}
        ${G(n(`workboard.fieldLabels`),a.labels)}
        ${G(n(`workboard.badgeAttempts`,{count:String(h.length)}),h.map(e=>[e.status,e.model,e.sessionKey,e.error].filter(Boolean).join(` - `)))}
        ${G(n(`workboard.badgeLinks`,{count:String(_.length)}),_.map(e=>[e.type,e.title,e.targetCardId,e.url].filter(Boolean).join(` - `)))}
        ${G(n(`workboard.detailProof`),y.map(e=>[e.status,e.label,e.command,e.url,e.note].filter(Boolean).join(` - `)))}
        ${G(n(`workboard.badgeArtifacts`,{count:String(w.length)}),w.map(e=>[e.label,e.url,e.path,e.mimeType].filter(Boolean).join(` - `)))}
        ${G(n(`workboard.badgeAttachments`,{count:String(T.length)}),T.map(e=>[e.fileName,e.mimeType,e.note].filter(Boolean).join(` - `)))}
        ${G(n(`workboard.detailDiagnostics`),E.map(e=>`${e.severity}: ${e.title}`))}
        ${G(n(`workboard.detailWorkerLogs`),D.map(e=>`${e.level}: ${e.message}`))}
        ${O?G(n(`workboard.detailWorkerProtocol`),[O.state,O.detail??``,O.updatedAt?n(`workboard.detailUpdatedValue`,{time:x(O.updatedAt)}):``]):t}
        ${k?G(n(`workboard.detailAutomation`),[k.tenant?n(`workboard.detailAutomationTenant`,{tenant:k.tenant}):``,k.boardId?n(`workboard.detailAutomationBoard`,{board:k.boardId}):``,k.skills?.length?n(`workboard.detailAutomationSkills`,{skills:k.skills.join(`, `)}):``,k.workspace?n(`workboard.detailAutomationWorkspace`,{workspace:[k.workspace.kind,k.workspace.path,k.workspace.branch].filter(Boolean).join(` `)}):``,k.dispatchCount?n(`workboard.badgeDispatches`,{count:String(k.dispatchCount)}):``,k.lastDispatchAt?n(`workboard.detailUpdatedValue`,{time:x(k.lastDispatchAt)}):``,k.summary?n(`workboard.detailAutomationSummary`,{summary:k.summary}):``]):t}
        ${G(n(`workboard.eventsLabel`),A.map(e=>`${C(e)} ${x(e.at)}`))}

        <section class="workboard-detail__section">
          <h3>${n(`workboard.detailOperatorNotes`)}</h3>
          ${m.length?e`
                <ol class="workboard-detail__list">
                  ${m.slice(-6).map(t=>e`<li>${t.body}</li>`)}
                </ol>
              `:e`<p>${n(`workboard.detailNoNotes`)}</p>`}
          ${p?e`
                <textarea
                  class="input workboard-detail__note"
                  maxlength="2000"
                  placeholder=${n(`workboard.detailNotePlaceholder`)}
                  .value=${i.detailCommentBody}
                  @input=${e=>{i.detailCommentBody=e.currentTarget.value,r.onRequestUpdate?.()}}
                ></textarea>
                <button
                  class="btn"
                  type="button"
                  ?disabled=${j||!i.detailCommentBody.trim()}
                  @click=${()=>v({host:r.host,client:r.client,cardId:a.id,body:i.detailCommentBody,requestUpdate:r.onRequestUpdate})}
                >
                  ${d.plus} ${n(`workboard.detailAddNote`)}
                </button>
              `:t}
        </section>

        <div class="workboard-detail__actions">
          ${f?e`
                <button
                  class="btn"
                  type="button"
                  @click=${()=>r.onOpenSession(f)}
                >
                  ${d.messageSquare} ${n(`workboard.openSession`)}
                </button>
              `:t}
          ${M?U(r,a):t}
        </div>
      </div>
    </aside>
  `}function q(r){let i=r.lastDispatchSummary;return i?e`
    <div class="callout">
      ${n(i.started+i.failures+i.promoted+i.blocked+i.reclaimed+i.orchestrated===0?`workboard.dispatchSummaryEmpty`:`workboard.dispatchSummary`,{started:String(i.started),failures:String(i.failures),promoted:String(i.promoted),blocked:String(i.blocked),reclaimed:String(i.reclaimed),orchestrated:String(i.orchestrated)})}
    </div>
  `:t}function J(a,o){let s=u(a.host),c=s.tasksByCardId.get(o.id),l=i(o,a.sessions),p=s.busyCardId===o.id,m=s.syncingCardIds.has(o.id),h=z(c),g=h||l?.hasActiveRun===!0||l?.hasActiveRun!==!1&&l?.status===`running`,v=o.sessionKey??o.execution?.sessionKey,y=S(a),b=y&&B(s,a.sessions,o);return e`
    <article
      class="workboard-card priority-${o.priority} ${p?`workboard-card--busy`:``} workboard-card--openable"
      role="button"
      tabindex="0"
      title=${n(`workboard.viewDetails`)}
      draggable=${y?`true`:`false`}
      @click=${e=>{k(e)||(A(s,o),a.onRequestUpdate?.())}}
      @keydown=${e=>{k(e)||e.key!==`Enter`&&e.key!==` `||(A(s,o),a.onRequestUpdate?.(),e.preventDefault())}}
      @dragstart=${e=>{if(!y){e.preventDefault();return}s.draggedCardId=o.id,e.dataTransfer?.setData(`text/plain`,o.id),e.dataTransfer?.setDragImage(e.currentTarget,16,16),a.onRequestUpdate?.()}}
      @dragend=${()=>{s.draggedCardId=null,a.onRequestUpdate?.()}}
    >
      <div class="workboard-card__top">
        <span class="workboard-card__priority">${o.priority}</span>
        ${g?e`<span class="workboard-live">${n(`workboard.live`)}</span>`:t}
        ${m?e`<span class="workboard-live">${n(`common.saving`)}</span>`:t}
      </div>
      <h3>${o.title}</h3>
      ${o.notes?e`<p>${o.notes}</p>`:t}
      ${V(o,a.sessions,c)}
      ${o.labels.length?e`<div class="workboard-labels">
            ${o.labels.map(t=>e`<span>${t}</span>`)}
          </div>`:t}
      ${T(o,c)}
      <div class="workboard-card__meta">
        ${o.agentId?e`<span>${o.agentId}</span>`:e`<span>${n(`workboard.defaultAgent`)}</span>`}
        <span>${x(o.updatedAt)}</span>
      </div>
      ${w(o)}
      <div class="workboard-card__actions">
        <button
          class="btn btn--icon workboard-card__icon"
          title=${n(`workboard.viewDetails`)}
          @click=${()=>{A(s,o),a.onRequestUpdate?.()}}
        >
          ${d.panelRightOpen}
        </button>
        ${y?e`
              <button
                class="btn btn--icon workboard-card__icon"
                title=${n(`workboard.editCard`)}
                @click=${()=>{N(s,o),a.onRequestUpdate?.()}}
              >
                ${d.edit}
              </button>
            `:t}
        ${v?e`
              <button
                class="btn btn--icon workboard-card__icon"
                title=${n(`workboard.openSession`)}
                @click=${()=>a.onOpenSession(v)}
              >
                ${d.messageSquare}
              </button>
              ${y&&g?e`
                    <button
                      class="btn btn--icon workboard-card__icon"
                      title=${n(`workboard.stopSession`)}
                      ?disabled=${p||!a.connected}
                      @click=${()=>r({host:a.host,client:a.client,card:o,requestUpdate:a.onRequestUpdate})}
                    >
                      ${d.stop}
                    </button>
                  `:t}
            `:t}
        ${!v&&y&&h?e`
              <button
                class="btn btn--icon workboard-card__icon"
                title=${n(`workboard.stopSession`)}
                ?disabled=${p||!a.connected}
                @click=${()=>r({host:a.host,client:a.client,card:o,requestUpdate:a.onRequestUpdate})}
              >
                ${d.stop}
              </button>
            `:t}
        ${b?H(a,o,null,`autonomous`):t}
        ${y?e`
              <button
                class="btn btn--icon workboard-card__icon"
                title=${n(`workboard.archiveCard`)}
                ?disabled=${p}
                @click=${()=>f({host:a.host,client:a.client,cardId:o.id,requestUpdate:a.onRequestUpdate})}
              >
                ${d.check}
              </button>
              <button
                class="btn btn--icon workboard-card__icon workboard-card__delete"
                title=${n(`workboard.deleteCard`)}
                ?disabled=${p}
                @click=${()=>_({host:a.host,client:a.client,cardId:o.id,requestUpdate:a.onRequestUpdate})}
              >
                ${d.trash}
              </button>
            `:t}
      </div>
    </article>
  `}function Y(t,r,i){let o=u(t.host),s=S(t);return e`
    <section
      class="workboard-column ${o.draggedCardId?`workboard-column--drop`:``}"
      @dragover=${e=>{s&&o.draggedCardId&&e.preventDefault()}}
      @drop=${e=>{if(e.preventDefault(),!s)return;let n=e.dataTransfer?.getData(`text/plain`)||o.draggedCardId;n&&a({host:t.host,client:t.client,cardId:n,status:r,position:D(o.cards,r),requestUpdate:t.onRequestUpdate})}}
    >
      <div class="workboard-column__header">
        <h2>${b(r)}</h2>
        <span>${i.length}</span>
      </div>
      <div class="workboard-column__cards">
        ${i.length?i.map(e=>J(t,e)):e`<div class="workboard-empty">${n(`workboard.emptyColumn`)}</div>`}
      </div>
    </section>
  `}function X(r){let i=u(r.host);if(r.pluginEnabled&&(o({host:r.host,client:r.client,requestUpdate:r.onRequestUpdate}),p({host:r.host,client:r.client,sessions:r.sessions,canWrite:r.canWrite,requestUpdate:r.onRequestUpdate})),!r.pluginEnabled)return e`
      <section class="workboard">
        <div class="callout">
          ${n(`workboard.disabledHelpStart`)}
          <code>${n(`workboard.enableConfigKey`)}</code>${n(`workboard.disabledHelpEnd`)}
        </div>
      </section>
    `;let a=i.cards.filter(e=>!e.metadata?.archivedAt).filter(e=>E(e,{query:i.query,priority:i.priorityFilter})),s=S(r),c=new Map;for(let e of i.statuses)c.set(e,[]);for(let e of a)c.get(e.status)?.push(e);return e`
    <section class="workboard">
      <div class="workboard-toolbar">
        <div class="workboard-toolbar__filters">
          <input
            class="input"
            type="search"
            placeholder=${n(`workboard.searchPlaceholder`)}
            .value=${i.query}
            @input=${e=>{i.query=e.currentTarget.value,r.onRequestUpdate?.()}}
          />
          <select
            class="input"
            .value=${i.priorityFilter}
            @change=${e=>{i.priorityFilter=e.currentTarget.value,r.onRequestUpdate?.()}}
          >
            <option value="all">${n(`workboard.allPriorities`)}</option>
            ${h.map(t=>e`<option value=${t}>${t}</option>`)}
          </select>
        </div>
        <div class="workboard-toolbar__actions">
          <button
            class="btn"
            ?disabled=${i.loading}
            @click=${()=>o({host:r.host,client:r.client,requestUpdate:r.onRequestUpdate,force:!0})}
          >
            ${i.loading?n(`common.refreshing`):n(`common.refresh`)}
          </button>
          ${s?e`
                <button
                  class="btn"
                  ?disabled=${i.loading}
                  @click=${()=>l({host:r.host,client:r.client,requestUpdate:r.onRequestUpdate})}
                >
                  ${d.zap} ${n(`workboard.dispatch`)}
                </button>
              `:t}
          ${s?e`
                <button
                  class="btn primary"
                  @click=${()=>{M(i),r.onRequestUpdate?.()}}
                >
                  ${d.plus} ${n(`workboard.newCard`)}
                </button>
              `:t}
        </div>
      </div>
      ${i.error?e`<div class="callout danger">${i.error}</div>`:t}
      ${q(i)} ${F(r)} ${K(r)}
      <div class="workboard-board">
        ${i.statuses.map(e=>Y(r,e,c.get(e)??[]))}
      </div>
    </section>
  `}export{X as renderWorkboard};
//# sourceMappingURL=workboard-BY4OM5ak.js.map