import{f as e,p as t}from"./lit-runtime-DA0-mbwP.js";import{o as n,t as r}from"./string-coerce-kcFITeCw.js";import{_ as i,ft as a,z as o}from"./index-x7xgmgRf.js";var s=[`running`,`done`,`error`];function c(e){return o(e,{hour:`numeric`,minute:`2-digit`,second:`2-digit`},``)}function l(e){if(!Number.isFinite(e)||e<0)return n(`common.na`);if(e<1e3)return n(`activity.duration.ms`,{count:String(Math.round(e))});if(e<6e4)return n(`activity.duration.seconds`,{count:(e/1e3).toFixed(1)});let t=Math.round(e/1e3),r=Math.floor(t/60),i=t%60;return n(`activity.duration.minutes`,{minutes:String(r),seconds:String(i)})}function u(e){return n(`activity.status.${e}`)}function d(e){return e===1?n(`activity.argumentHiddenOne`):n(`activity.argumentsHidden`,{count:String(e)})}function f(e){return n(`activity.entrySummary`,{argumentSummary:d(e.hiddenArgumentCount),status:u(e.status),tool:e.toolName})}function p(e,t){return t?r([e.toolName,e.status,e.summary,f(e),e.outputPreview,e.runId,e.toolCallId,e.sessionKey].filter(Boolean).join(` `)).includes(t):!0}function m(e){return a(e.map(e=>e.toolName))}function h(e){let t=r(e.filterText);return e.entries.filter(n=>!e.statusFilters[n.status]||e.toolFilter&&n.toolName!==e.toolFilter?!1:p(n,t))}function g(e,n){return t`
    <label class="activity-status-filter activity-status-filter--${n}">
      <input
        type="checkbox"
        .checked=${e.statusFilters[n]}
        @change=${t=>e.onStatusToggle(n,t.target.checked)}
      />
      <span>${u(n)}</span>
    </label>
  `}function _(r,a){let o=r.expandedIds.has(a.id);return t`
    <details
      class="activity-entry activity-entry--${a.status}"
      role="listitem"
      .open=${o}
      @toggle=${e=>r.onEntryToggle(a.id,e.currentTarget.open)}
    >
      <summary class="activity-entry__summary">
        <span class="activity-entry__chevron" aria-hidden="true">${i.chevronRight}</span>
        <span class="activity-entry__main">
          <span class="activity-entry__title">
            <span class="activity-status activity-status--${a.status}">
              ${u(a.status)}
            </span>
            <span class="activity-entry__tool mono">${a.toolName}</span>
          </span>
          <span class="activity-entry__text">${f(a)}</span>
        </span>
        <span class="activity-entry__meta">
          <span>${c(a.updatedAt)}</span>
          <span>${l(a.durationMs)}</span>
        </span>
      </summary>
      <div class="activity-entry__body">
        <div class="activity-entry__facts">
          <span>${d(a.hiddenArgumentCount)}</span>
          <span class="mono">${n(`activity.toolCallId`)}: ${a.toolCallId}</span>
          <span class="mono">${n(`activity.runId`)}: ${a.runId}</span>
          ${a.sessionKey?t`<span class="mono">${n(`activity.session`)}: ${a.sessionKey}</span>`:e}
        </div>
        ${a.outputPreview?t`
              <pre class="activity-entry__preview">${a.outputPreview}</pre>
              ${a.outputTruncated?t`<div class="activity-entry__note">${n(`activity.outputTruncated`)}</div>`:e}
            `:t`<div class="activity-entry__note">${n(`activity.noOutputPreview`)}</div>`}
      </div>
    </details>
  `}function v(e){let r=m(e.entries),i=h(e),a=e.filterText.trim()||e.toolFilter||s.some(t=>!e.statusFilters[t]);return t`
    <section class="activity-page" aria-label=${n(`activity.title`)}>
      <div class="activity-toolbar" aria-label=${n(`activity.filtersLabel`)}>
        <label class="activity-field activity-field--search">
          <span>${n(`activity.search`)}</span>
          <input
            type="search"
            .value=${e.filterText}
            placeholder=${n(`activity.searchPlaceholder`)}
            @input=${t=>e.onFilterTextChange(t.target.value)}
          />
        </label>
        <label class="activity-field">
          <span>${n(`activity.toolFilter`)}</span>
          <select
            .value=${e.toolFilter}
            @change=${t=>e.onToolFilterChange(t.target.value)}
          >
            <option value="">${n(`activity.allTools`)}</option>
            ${r.map(e=>t`<option value=${e}>${e}</option>`)}
          </select>
        </label>
        <div class="activity-status-filters" role="group" aria-label=${n(`activity.statusFilters`)}>
          ${s.map(t=>g(e,t))}
        </div>
        <label class="activity-autofollow">
          <input
            type="checkbox"
            .checked=${e.autoFollow}
            @change=${t=>e.onToggleAutoFollow(t.target.checked)}
          />
          <span>${n(`activity.autoFollow`)}</span>
        </label>
        <div class="activity-actions">
          <button
            type="button"
            class="btn btn--sm"
            ?disabled=${i.length===0}
            @click=${e.onExpandAll}
          >
            ${n(`activity.expandAll`)}
          </button>
          <button
            type="button"
            class="btn btn--sm"
            ?disabled=${e.expandedIds.size===0}
            @click=${e.onCollapseAll}
          >
            ${n(`activity.collapseAll`)}
          </button>
          <button
            type="button"
            class="btn btn--sm danger"
            ?disabled=${e.entries.length===0}
            @click=${e.onClear}
          >
            ${n(`activity.clear`)}
          </button>
        </div>
        <div class="activity-toolbar__count" aria-live="polite">
          ${n(`activity.visibleCount`,{visible:String(i.length),total:String(e.entries.length)})}
        </div>
      </div>

      <div
        class="activity-stream"
        role="list"
        aria-label=${n(`activity.streamLabel`)}
        @scroll=${e.onScroll}
      >
        ${i.length===0?t`
              <div class="activity-empty">
                ${e.entries.length===0||!a?n(`activity.empty`):n(`activity.emptyFiltered`)}
              </div>
            `:i.map(t=>_(e,t))}
      </div>
    </section>
  `}export{v as renderActivity};
//# sourceMappingURL=activity-PbcitnGu.js.map