const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./input-dialog-BErqtvL-.js","./rolldown-runtime-DkW27tQK.js","./control-ui-core-pH6nakZ-.js","./control-ui-foundation-CeFMP1Ly.js","./lit-runtime-BEtFSUCp.js","./control-ui-core-DGVkFhVB.js","./control-ui-core-Br5DB0Zj.js","./gateway-runtime-DUNO4Mi1.js","./control-ui-core-C8H8-RSs.css"])))=>i.map(i=>d[i]);
import{n as e}from"./rolldown-runtime-DkW27tQK.js";import{Ei as t,Nr as n,Pr as r,er as i,ki as a,pn as o,un as s}from"./control-ui-foundation-CeFMP1Ly.js";import{$s as c,Aa as l,Ba as u,Cn as d,Da as f,Dc as p,Di as m,Ga as h,Na as g,Oa as _,Oc as v,Qa as y,So as b,U as x,Ua as S,Va as C,Wa as w,X as ee,Z as te,Zn as T,_c as E,b as D,bc as O,eo as ne,fl as re,fs as k,g as ie,gc as ae,hc as oe,hl as se,ja as A,jc as j,ka as ce,ki as le,lr as ue,mc as de,ml as fe,ms as pe,ps as me,qs as he,u as ge,uo as _e,vr as ve,w as ye,wn as be,wr as xe,xo as Se,y as Ce,yr as we}from"./control-ui-core-pH6nakZ-.js";import{G as M,J as N,W as Te,Z as Ee,at as De,rt as P}from"./lit-runtime-BEtFSUCp.js";import{Cn as Oe,Jt as ke,Ot as Ae,Sn as je,kt as Me,ln as Ne,m as Pe,p as Fe,qt as Ie}from"./control-ui-core-DGVkFhVB.js";import{Ft as Le,Ht as Re,Lt as F,N as ze,Rt as Be,qt as I}from"./control-ui-core-Br5DB0Zj.js";import{F as Ve,I as He,In as Ue,L as We,Ln as Ge,z as Ke}from"./control-ui-boot-wpHCbPL9.js";import{a as L,r as qe}from"./gateway-runtime-DUNO4Mi1.js";import{Bo as Je,Ca as Ye,D as Xe,Es as Ze,Ld as Qe,Ss as $e,Ts as et,Vo as tt,_l as nt,bn as R,br as rt,bs as it,cn as at,cu as z,f as ot,fo as st,g as ct,iu as lt,kc as ut,l as dt,lu as ft,mn as pt,on as mt,os as ht,po as gt,ru as _t,ss as vt,su as yt,tu as bt,v as xt,vl as St,vn as Ct,wa as B,ws as wt,x as V,xr as Tt,xs as Et,y as Dt,yn as Ot}from"./control-ui-boot-Cdpgu1Gm.js";import{n as kt,t as At}from"./transcript-search-BCLBZZfW.js";import{t as jt}from"./web-awesome-popover-DTDr8XNA.js";import{n as Mt,r as Nt}from"./worktree-preservation-ITy-qaJx.js";import{d as Pt,t as Ft}from"./workboard-D4DxP9hk.js";import{n as It,t as Lt}from"./settings-workspace-Bo4nqRhI.js";import{n as Rt,t as zt}from"./gateway-page-controller-bzyUg03c.js";import{o as Bt,s as Vt}from"./presenter-CKFufLDk.js";import{n as Ht,t as Ut}from"./agent-scope-control-C6P46hJO.js";import{n as Wt,t as Gt}from"./capacity-meter-CmKC-EhZ.js";import{n as Kt,t as qt}from"./sessions-hub-header-DEIZ2OS0.js";function Jt(e){return[...new Set((e?.sessions??[]).map(e=>p(e.key)?.agentId).filter(e=>!!e))]}function Yt(e,t){return Object.fromEntries(Jt(e).map(e=>[e,t(e)]).filter(e=>!!e[1]))}function Xt(){return(Xt=e((()=>{O()})))()}function Zt(e,t){let n=(e?.sessions??[]).map(e=>e.category?.trim()).filter(e=>!!e);return[...new Set([...t,...n.toSorted((e,t)=>e.localeCompare(t))])]}async function Qt(e){if(!e.sessions||e.knownCategories.includes(e.name))return`completed`;try{return await e.sessions.groupsPut([...e.sessions.state.groups??[],e.name])===`completed`&&e.isCurrent()?`completed`:`stale`}catch(t){return e.isCurrent()?(e.onError(k(t)),`failed`):`stale`}}function $t(){return($t=e((()=>{pe()})))()}function en(){return yt(se()?.getItem(H))}function tn(e){try{se()?.setItem(H,e)}catch{}}var H;function nn(){return(nn=e((()=>{lt(),H=`openclaw:sessions:group-by`})))()}function U(e,t){return Object.hasOwn(e,t)?e[t]??null:null}function rn(e,t){let n=Xe(e,t),r=ct(e.thinkingDefault??(n?t?.thinkingDefault:void 0)),i=e.thinkingLevels?.length?e.thinkingLevels:n&&t?.thinkingLevels?.length?t.thinkingLevels:(e.thinkingOptions?.length?e.thinkingOptions:n&&t?.thinkingOptions?.length?t.thinkingOptions:In).map(e=>({id:V(e),label:e}));return[{value:``,label:r},...i.map(e=>({value:V(e.id),label:xt(e.id,e.label)}))]}function W(e,t){return!t||e.some(e=>e.value===t)?[...e]:[...e,{value:t,label:xt(t)}]}function G(e,t=!1){return e.map(e=>({value:e,label:I(e===``?`sessionsView.inherit`:t&&e===`off`?`sessionsView.offExplicit`:`sessionsView.${e}`)}))}function an(e){return I(Bn[e]??`sessionsView.statusUnknown`)}function on(e){let t=y(e),n=e.hasActiveRun===!1&&(!e.status||e.status===`running`),r=e.status===`queued`?I(`sessionsView.statusQueued`):t?I(`sessionsView.statusLive`):n?I(`sessionsView.statusIdle`):e.status?an(e.status):I(`sessionsView.statusUnknown`),i=e.status===`queued`?`warn`:t||e.status===`done`?`ok`:n||!e.status?`muted`:`danger`,a=`${I(`sessionsView.status`)}: ${r}`;return N`
    <openclaw-tooltip .content=${a}>
      ${R({kind:i,label:r})}
    </openclaw-tooltip>
  `}function K(e){return b(e.key)?`cron`:e.kind}function sn(e){let t=K(e);return N`
    <span class="session-avatar session-avatar--${t}" aria-hidden="true">
      ${Vn[t]??F.circle}
      ${y(e)?N`<span class="session-avatar__status"></span>`:M}
    </span>
  `}function cn(e){let t=e.totalTokens;if(typeof t!=`number`||!Number.isFinite(t))return N`<span class="muted">${I(`common.na`)}</span>`;let n=e.totalTokensFresh!==!1,r=`${n?``:`~`}${ge(t)}`,i=typeof e.contextTokens==`number`&&e.contextTokens>0?e.contextTokens:null;if(!i)return N`<span class="session-tokens__value">${r}</span>`;let a=Math.min(100,Math.round(t/i*100)),o=n?a>=Un?`danger`:a>=Hn?`warn`:`ok`:`stale`,s=I(n?`sessionsView.contextUsage`:`sessionsView.contextUsageApprox`,{percent:String(a),used:t.toLocaleString(),context:i.toLocaleString()});return N`
    <openclaw-tooltip .content=${s}>
      <div class="session-tokens">
        <span class="session-tokens__value"
          >${r} / ${ge(i)}</span
        >
        ${Wt({mode:`continuous`,percent:a,tone:o,label:s})}
      </div>
    </openclaw-tooltip>
  `}function ln(e,t,n){let r=e.filter(e=>e.unread===!0&&e.archived!==!0).length,i=e.filter(e=>e.archived===!0).length,a=[[String(t),I(`sessionsView.statusLive`),t>0],[String(r),I(`sessionsView.unread`),r>0]];return n!==`active`&&a.push([String(i),I(`sessionsView.archived`),!1]),N`
    <span class="sessions-heading-facts">
      ${a.map(([e,t,n],r)=>N`
          ${r>0?N`<span class="sessions-heading-fact__separator" aria-hidden="true">·</span>`:M}
          <span
            class=${n?`sessions-heading-fact sessions-heading-fact--active`:`sessions-heading-fact`}
          >
            <strong>${e}</strong> ${t}
          </span>
        `)}
    </span>
  `}function un(e,t){let n=t.find(t=>t.key===e.sessionKey);return a(n?.label)??a(n?.displayName)??e.sessionKey}function dn(e,t){let n=e.transcriptSearchQuery.trim().length>0,r=e.transcriptSearch,i=r.status===`results`?r.results:[],a=r.status===`loading`;return N`
    <section
      class="sessions-transcript-search"
      aria-label=${I(`sessionsView.transcriptSearchTitle`)}
    >
      <form
        class="sessions-transcript-search__form"
        role="search"
        aria-label=${I(`sessionsView.transcriptSearchTitle`)}
        @submit=${t=>{t.preventDefault(),e.transcriptSearchAvailable&&n&&!a&&e.onTranscriptSearch()}}
      >
        <div class="data-table-search sessions-transcript-search__input">
          <input
            type="search"
            maxlength="4096"
            aria-label=${I(`sessionsView.transcriptSearchInputLabel`)}
            placeholder=${I(`sessionsView.transcriptSearchPlaceholder`)}
            .value=${e.transcriptSearchQuery}
            ?disabled=${!e.transcriptSearchAvailable}
            @input=${t=>e.onTranscriptSearchChange(t.target.value)}
          />
        </div>
        <button
          class="btn primary"
          type="submit"
          ?disabled=${!e.transcriptSearchAvailable||!n||a}
        >
          ${I(a?`sessionsView.transcriptSearchSearching`:`sessionsView.transcriptSearchAction`)}
        </button>
        ${n?N`
              <button class="btn" type="button" @click=${e.onClearTranscriptSearch}>
                ${I(`sessionsView.transcriptSearchClear`)}
              </button>
            `:M}
      </form>
      ${e.transcriptSearchAvailable?M:N`
            <div class="muted" role="status">${I(`sessionsView.transcriptSearchUnavailable`)}</div>
          `}
      <div
        class="sessions-transcript-search__status"
        aria-live="polite"
        aria-busy=${a?`true`:`false`}
      >
        ${a?N`<span class="muted">${I(`sessionsView.transcriptSearchSearching`)}</span>`:M}
        ${r.status===`error`?N`
              <div
                class="sessions-transcript-search__notice sessions-transcript-search__notice--danger"
              >
                <span>${I(`sessionsView.transcriptSearchError`)}: ${r.message}</span>
                <button class="btn btn--sm" type="button" @click=${e.onTranscriptSearch}>
                  ${I(`sessionsView.transcriptSearchRetry`)}
                </button>
              </div>
            `:M}
        ${r.status===`results`&&r.indexing?N`
              <div class="sessions-transcript-search__notice">
                <span>${I(`sessionsView.transcriptSearchIndexing`)}</span>
                <button
                  class="btn btn--sm"
                  type="button"
                  ?disabled=${a}
                  @click=${e.onTranscriptSearch}
                >
                  ${I(`sessionsView.transcriptSearchRetry`)}
                </button>
              </div>
            `:M}
        ${r.status===`results`&&i.length===0&&!r.indexing?N`
              <div class="sessions-transcript-search__empty" role="status">
                ${I(`sessionsView.transcriptSearchEmpty`)}
              </div>
            `:M}
        ${i.length>0?N`
              <div class="sessions-transcript-search__results">
                <div class="sessions-transcript-search__summary">
                  <strong
                    >${I(`sessionsView.transcriptSearchMatches`,{count:String(i.length)})}</strong
                  >
                  ${r.status===`results`&&r.truncated?N`<span class="muted"
                        >${I(`sessionsView.transcriptSearchTruncated`)}</span
                      >`:M}
                </div>
                <div class="sessions-transcript-search__list">
                  ${i.map(n=>{let r=n.timestamp>0?D(n.timestamp):I(`common.na`),i=n.timestamp>0?Ce(n.timestamp):r;return N`
                      <button
                        class="sessions-transcript-search__result"
                        type="button"
                        @click=${()=>e.onNavigateToChat?.(n.sessionKey)}
                      >
                        <span class="sessions-transcript-search__result-header">
                          <strong>${un(n,t)}</strong>
                          <span class="muted" title=${i}>
                            ${I(`sessionsView.${n.role}`)} · ${r}
                          </span>
                        </span>
                        <span class="sessions-transcript-search__snippet">${n.snippet}</span>
                        <span class="sessions-transcript-search__key">${n.sessionKey}</span>
                      </button>
                    `})}
                </div>
              </div>
            `:M}
      </div>
    </section>
  `}function fn(e){return Array.from({length:Wn},(t,n)=>N`
      <tr class="session-skeleton-row" aria-hidden="true">
        ${Array.from({length:e},(e,t)=>t===0?N`<td class="data-table-checkbox-col"></td>`:N`<td>
                <span
                  class="session-skeleton ${t===1?`session-skeleton--key`:``}"
                  style=${`animation-delay: ${n*120}ms`}
                ></span>
              </td>`)}
      </tr>
    `)}function pn(e,n,r){let i=t(n);return i?e.filter(e=>{if([e.key,e.label,e.category,e.kind,e.displayName,c(e.agentRuntime),e.status,e.goal?`${e.goal.objective} ${e.goal.status} ${ot(e.goal)} ${e.goal.lastStatusNote??``}`:``,y(e)?`live running`:e.hasActiveRun===!1?`idle`:``].some(e=>t(e).includes(i)))return!0;let n=v(e.key);return(n?t(U(r,n.agentId)?.name):``).includes(i)}):e}function mn(e,t,n){let r=n===`asc`?1:-1;return[...e].toSorted((e,n)=>{let i=(n.pinnedAt??0)-(e.pinnedAt??0);return i===0?(t===`key`||t===`kind`?(e[t]??``).localeCompare(n[t]??``):t===`updated`?(e.updatedAt??0)-(n.updatedAt??0):(e.totalTokens??e.inputTokens??e.outputTokens??0)-(n.totalTokens??n.inputTokens??n.outputTokens??0))*r:i})}function hn(e,t,n){let r=t*n;return e.slice(r,r+n)}function gn(e){return t(e.searchQuery).length>0||o(e.activeMinutes)!==void 0||!e.includeGlobal}function _n(e){let t=Gn[e];return t?I(t):e}function vn(e){return I(e===1?`sessionsView.checkpoint`:`sessionsView.checkpoints`,{count:String(e)})}function yn(e){return typeof e.tokensBefore==`number`&&typeof e.tokensAfter==`number`&&Number.isFinite(e.tokensBefore)&&Number.isFinite(e.tokensAfter)?I(`sessionsView.tokenRange`,{before:e.tokensBefore.toLocaleString(),after:e.tokensAfter.toLocaleString()}):typeof e.tokensBefore==`number`&&Number.isFinite(e.tokensBefore)?I(`sessionsView.tokensBefore`,{count:e.tokensBefore.toLocaleString()}):I(`sessionsView.tokenDeltaUnavailable`)}function bn(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?null:ie(e)??`0ms`}function xn(e){if(!e)return M;let t=e.status===`active`?`accent`:e.status===`complete`?`ok`:e.status===`blocked`||e.status===`budget_limited`||e.status===`usage_limited`?`warn`:`muted`,n=dt(e);return N`
    <openclaw-tooltip .content=${n}>
      <span tabindex="0" aria-label=${n}>
        ${R({kind:t,label:ot(e)})}
      </span>
    </openclaw-tooltip>
  `}function Sn(e){let{row:t,updated:n,checkpointCount:r}=e,i=[{label:I(`sessionsView.key`),value:t.key},{label:I(`sessionsView.kind`),value:t.kind},{label:I(`sessionsView.updated`),value:n},{label:I(`sessionsView.tokens`),value:Bt(t)},{label:I(`sessionsView.compaction`),value:vn(r)}],o=(e,t)=>{let n=a(t);n&&i.push({label:e,value:n})};o(I(`sessionsView.group`),t.category),o(I(`sessionsView.status`),t.status),t.goal&&i.push({label:I(`sessionsView.goal`),value:dt(t.goal)}),o(I(`sessionsView.goalNote`),t.goal?.lastStatusNote),o(I(`sessionsView.model`),t.model),o(I(`sessionsView.provider`),t.modelProvider),o(I(`sessionsView.runtime`),c(t.agentRuntime)),o(I(`sessionsView.runDuration`),bn(t.runtimeMs)),o(I(`sessionsView.surface`),t.surface),o(I(`sessionsView.subject`),t.subject),o(I(`sessionsView.room`),t.room),o(I(`sessionsView.space`),t.space),o(I(`sessionsView.sessionId`),t.sessionId);for(let[e,n]of[[I(`sessionsView.activeRun`),t.hasActiveRun],[I(`sessionsView.archived`),t.archived],[I(`sessionsView.pinned`),t.pinned]])typeof n==`boolean`&&i.push({label:e,value:I(n?`common.yes`:`common.no`)});return i}function q(e){return e.groupBy===`category`?8:7}function Cn(e){return I(Q[e]??Q.none)}function wn(e,t){let{id:n}=e;if(t.groupBy===`date`)return I({today:`sessionsView.dateToday`,yesterday:`sessionsView.dateYesterday`,week:`sessionsView.dateThisWeek`,older:`sessionsView.dateOlder`}[n]??`sessionsView.dateNoActivity`);if(n===``)return I(`sessionsView.ungrouped`);if(t.groupBy===`agent`){let e=U(t.agentIdentityById,n),r=a(e?.name);if(r){let t=a(e?.emoji);return t?`${t} ${r}`:r}}return t.groupBy===`person`&&e.rows[0]?.owner?.actor.label?.trim()||n}function J(e,t){e.currentTarget?.classList.toggle(`session-drop-target--active`,t)}function Tn(e,t){if(e.groupBy!==`category`||e.groupWriteDisabledReason)return{dragover:M,dragleave:M,drop:M};let n=e=>e.dataTransfer?.types.includes(z)===!0;return{dragover:e=>{n(e)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),J(e,!0))},dragleave:e=>J(e,!1),drop:r=>{if(!n(r))return;r.preventDefault(),J(r,!1);let i=r.dataTransfer?.getData(z);i&&e.onAssignCategory(i,t)}}}function En(e,t){let n=wn(e,t),r=e.rows.length===1?I(`sessionsView.groupRowCountOne`,{count:`1`}):I(`sessionsView.groupRowCount`,{count:String(e.rows.length)}),i=Tn(t,e.id===``?null:e.id);return N`
    <tr
      class="session-group-row"
      @dragover=${i.dragover}
      @dragleave=${i.dragleave}
      @drop=${i.drop}
    >
      <td colspan=${q(t)}>
        <div class="session-group-row__header">
          <span class="session-group-row__icon" aria-hidden="true">${F.folder}</span>
          <span class="session-group-row__label">${n}</span>
          <span class="session-group-row__count">${r}</span>
        </div>
      </td>
    </tr>
  `}function Dn(e,t){let n=a(e.category)??``,r=[...t.knownCategories];return n&&!r.includes(n)&&r.push(n),N`
    <td>
      <select
        ?disabled=${t.loading||!!t.groupWriteDisabledReason}
        title=${t.groupWriteDisabledReason??M}
        aria-label=${I(`sessionsView.moveToGroup`)}
        class="session-group-select"
        @change=${r=>{if(t.groupWriteDisabledReason)return;let i=r.target;if(i.value===Z){i.value=n,t.onRequestNewCategory(e.key);return}t.onAssignCategory(e.key,i.value||null)}}
      >
        <option value="" ?selected=${!n}>${I(`sessionsView.ungrouped`)}</option>
        ${r.map(e=>N`<option value=${e} ?selected=${n===e}>${e}</option>`)}
        <option value=${Z}>${I(`sessionsView.newGroup`)}</option>
      </select>
    </td>
  `}function On(e){return e instanceof Element&&!!e.closest(`a, button, input, label, select, textarea`)}function kn(e){let t=[`session-filter-check`,`session-filter-toggle`,e.extraClass??``,e.checked?`session-filter-check--active`:``].filter(Boolean).join(` `);return N`
    <openclaw-tooltip .content=${e.title}>
      <label class=${t}>
        <input
          name=${e.name}
          class="session-filter-check__input"
          type="checkbox"
          .checked=${e.checked}
          @change=${t=>e.onChange(t.target.checked)}
        />
        <span class="session-filter-check__mark" aria-hidden="true">${F.check}</span>
        <span class="session-filter-check__label">${e.label}</span>
      </label>
    </openclaw-tooltip>
  `}function Y(e){return N`
    <label class="session-override-field">
      <span class="session-override-field__label">${e.label}</span>
      <select
        class="settings-select"
        ?disabled=${e.disabled}
        title=${e.disabledReason??M}
        @change=${t=>e.onChange(t.target.value)}
      >
        ${e.options.map(t=>N`<option value=${t.value} ?selected=${e.current===t.value}>
              ${t.label}
            </option>`)}
      </select>
    </label>
  `}function An(e){let t=e.result?.sessions??[],n=pn(t,e.searchQuery,e.agentIdentityById),r=mn(n,e.sortColumn,e.sortDir),i=r.length,a=Math.max(1,Math.ceil(i/e.pageSize)),o=Math.min(e.page,a-1),s=e.groupBy===`none`?null:_t({rows:r,mode:e.groupBy,knownCategories:e.knownCategories}),c=hn(s?s.flatMap(e=>e.rows):r,o,e.pageSize),l=t.length===0?gn(e):n.length===0,u=t.filter(e=>y(e)).length,d=t.filter(e=>e.archived===!0).length,f=e.statusFilter===`archived`?I(`sessionsView.noArchivedSessions`):e.statusFilter===`active`?I(`sessionsView.noActiveSessions`):I(`sessionsView.noSessions`),p=(t,n,r=``)=>{let i=e.sortColumn===t,a=i&&e.sortDir===`asc`?`desc`:`asc`;return N`
      <th
        class=${r}
        data-sortable
        data-sort-dir=${i?e.sortDir:``}
        aria-sort=${i?e.sortDir===`asc`?`ascending`:`descending`:M}
        @click=${()=>e.onSortChange(t,i?a:`desc`)}
      >
        <button class="data-table-sort-button" type="button">
          ${n}
          <span class="data-table-sort-icon" aria-hidden="true">${F.arrowUpDown}</span>
        </button>
      </th>
    `},m=N`
    ${I(`sessionsView.title`)}
    ${e.result?N`
          <openclaw-tooltip .content=${I(`sessionsView.store`,{path:e.result.path})}>
            <span class="settings-count">${t.length}</span>
          </openclaw-tooltip>
        `:M}
    ${e.result?ln(t,u,e.statusFilter):M}
  `,h=N`
    ${e.statusFilter===`archived`?N`
          <button
            class="btn danger"
            ?disabled=${e.loading||d===0||!!e.deleteArchivedDisabledReason}
            title=${e.deleteArchivedDisabledReason??M}
            @click=${e.onDeleteAllArchived}
          >
            ${F.trash} ${I(`sessionsView.deleteAllArchived`)}
          </button>
        `:M}
    <button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
      ${e.loading?I(`common.loading`):I(`common.refresh`)}
    </button>
  `,g=[e.error?N`<div class="sessions-error" role="alert">${e.error}</div>`:M,Ct({title:I(`sessionsView.transcriptSearchTitle`)},dn(e,t)),Ct({title:m,actions:h},Nn(e,{paginated:c,groups:s,emptyBecauseFiltered:l,emptyMessage:f,totalRows:i,totalPages:a,page:o,sortHeader:p}))];return pt(g,{wide:!0})}function jn(e,t){e.currentTarget instanceof Element&&e.currentTarget.previousElementSibling?.setAttribute(`aria-expanded`,String(t))}function Mn(e){let t=[[`activeMinutes`,`minutes`,I(`sessionsView.active`),I(`sessionsView.activeTooltip`,{count:e.activeMinutes.trim()}),I(`sessionsView.minutesPlaceholder`),e.statusFilter!==`active`],[`limit`,`limit`,I(`sessionsView.limit`),I(`sessionsView.limitTooltip`),M,!1]],n=[[`includeGlobal`,I(`sessionsView.global`),I(`sessionsView.globalTooltip`)],[`includeUnknown`,I(`sessionsView.unknown`),I(`sessionsView.unknownTooltip`)]],{activeMinutes:r,limit:i,includeGlobal:a,includeUnknown:o}=e,s=(t,n)=>e.onFiltersChange({activeMinutes:r,limit:i,includeGlobal:a,includeUnknown:o,[t]:n}),c=r.trim()!==``||i.trim()!==`50`||!a||o||e.groupBy!==`none`;return N`
    <button
      id="sessions-filter-popover-trigger"
      type="button"
      class="btn btn--sm sessions-filter-popover__trigger ${c?`active`:``}"
      title=${I(`sessionsView.filters`)}
      aria-label=${I(`sessionsView.filters`)}
      aria-haspopup="dialog"
      aria-expanded="false"
    >
      ${F.listFilter}
    </button>
    <wa-popover
      class="sessions-filter-popover"
      for="sessions-filter-popover-trigger"
      placement="bottom-end"
      without-arrow
      @wa-show=${e=>jn(e,!0)}
      @wa-hide=${e=>jn(e,!1)}
    >
      <div class="sessions-filter-popover__panel">
        <div class="sessions-filter-popover__fields">
          ${t.map(([t,n,r,i,a,o])=>N`
              <openclaw-tooltip .content=${i}>
                <label class="session-filter-field">
                  <span class="session-filter-label">${r}</span>
                  <input
                    class="session-filter-input session-filter-input--${n}"
                    placeholder=${a}
                    .value=${e[t]}
                    ?disabled=${o}
                    @input=${e=>s(t,e.target.value)}
                  />
                </label>
              </openclaw-tooltip>
            `)}
        </div>
        <div
          class="session-filter-toggle-group"
          role="group"
          aria-label=${I(`sessionsView.sourceFilters`)}
        >
          ${n.map(([t,n,r])=>kn({name:t,checked:e[t],label:n,title:r,onChange:e=>s(t,e)}))}
        </div>
        <label class="session-groupby">
          <span class="session-groupby__label">${I(`sessionsView.groupBy`)}</span>
          <select
            class="session-groupby__select"
            @change=${t=>e.onGroupByChange(t.target.value)}
          >
            ${bt.filter(t=>t!==`person`||e.personGroupingAvailable).map(t=>N`
                <option value=${t} ?selected=${e.groupBy===t}>
                  ${Cn(t)}
                </option>
              `)}
          </select>
        </label>
        ${e.groupBy===`category`?N`
              <button
                class="btn btn--sm"
                ?disabled=${!!e.groupWriteDisabledReason}
                title=${e.groupWriteDisabledReason??M}
                @click=${()=>e.onRequestNewCategory()}
              >
                ${F.plus} ${I(`sessionsView.newGroup`)}
              </button>
            `:M}
      </div>
    </wa-popover>
  `}function Nn(e,t){let{paginated:n,groups:r,emptyBecauseFiltered:i,emptyMessage:a,totalRows:o,totalPages:s,page:c}=t,l=t.sortHeader,u=i?I(`sessionsView.noSessionsMatchFilters`):a,d=r?new Set(n.map(e=>e.key)):null;return N`
    <div
      class="sessions-toolbar sessions-filter-bar"
      aria-label=${I(`sessionsView.filterControls`)}
    >
      <div class="data-table-search sessions-toolbar__search">
        ${F.search}
        <input
          type="text"
          placeholder=${I(`sessionsView.searchPlaceholder`)}
          .value=${e.searchQuery}
          @input=${t=>e.onSearchChange(t.target.value)}
        />
      </div>
      ${Ot({value:e.statusFilter,ariaLabel:I(`sessionsView.sessionState`),className:`sessions-view-segment`,options:[{value:`active`,label:I(`common.active`)},{value:`archived`,label:I(`sessionsView.archived`),title:I(`sessionsView.archivedOnlyTooltip`)},{value:`all`,label:I(`sessionsView.all`)}],onChange:t=>e.onStatusFilterChange(t)})}
      ${Mn(e)}
    </div>

    ${e.selectedKeys.size>0?N`
          <div class="data-table-bulk-bar">
            <span>${I(`sessionsView.selected`,{count:String(e.selectedKeys.size)})}</span>
            <button class="btn btn--sm" @click=${e.onDeselectAll}>
              ${I(`common.unselect`)}
            </button>
            <button
              class="btn btn--sm danger"
              ?disabled=${e.loading||!!e.deleteSelectedDisabledReason}
              title=${e.deleteSelectedDisabledReason??M}
              @click=${e.onDeleteSelected}
            >
              ${F.trash} ${I(`sessionsView.deleteSelected`)}
            </button>
          </div>
        `:M}

    <div class="data-table-container">
      <table class="data-table sessions-table">
        <thead>
          <tr>
            <th class="data-table-checkbox-col">
              ${n.length>0?N`<input
                    type="checkbox"
                    .checked=${n.length>0&&n.every(t=>e.selectedKeys.has(t.key))}
                    .indeterminate=${n.some(t=>e.selectedKeys.has(t.key))&&!n.every(t=>e.selectedKeys.has(t.key))}
                    @change=${()=>{n.every(t=>e.selectedKeys.has(t.key))?e.onDeselectPage(n.map(e=>e.key)):e.onSelectPage(n.map(e=>e.key))}}
                    aria-label=${I(`sessionsView.selectAllOnPage`)}
                  />`:M}
            </th>
            ${l(`key`,I(`sessionsView.key`),`data-table-key-col`)}
            ${e.groupBy===`category`?N`<th>${I(`sessionsView.group`)}</th>`:M}
            ${l(`kind`,I(`sessionsView.kind`))}
            <th class="session-status-col">${I(`sessionsView.status`)}</th>
            ${l(`updated`,I(`sessionsView.updated`))}
            ${l(`tokens`,I(`sessionsView.tokens`))}
            <th class="session-actions-col">
              <span class="sr-only">${I(`sessionsView.actions`)}</span>
            </th>
          </tr>
        </thead>
        <tbody>
          ${e.loading&&!e.result?fn(q(e)):n.length===0?N`
                  <tr>
                    <td colspan=${q(e)} class="data-table-empty-cell">
                      <div class="data-table-empty-state" role="status" aria-live="polite">
                        <div class="data-table-empty-state__message">
                          ${i?F.search:F.messageSquare}
                          <span>${u}</span>
                        </div>
                        ${i?N`
                              <button class="btn btn--sm" @click=${e.onClearFilters}>
                                ${I(`sessionsView.showAll`)}
                              </button>
                            `:M}
                      </div>
                    </td>
                  </tr>
                `:r?r.flatMap(t=>{let n=t.rows.filter(e=>d?.has(e.key));if(n.length===0&&t.rows.length>0)return[];let r=n.flatMap(t=>Pn(t,e));return r.unshift(En(t,e)),r}):n.flatMap(t=>Pn(t,e))}
        </tbody>
      </table>
    </div>

    ${o>0?N`
          <div class="data-table-pagination">
            <div class="data-table-pagination__info">
              ${I(`sessionsView.pagination`,{start:String(c*e.pageSize+1),end:String(Math.min((c+1)*e.pageSize,o)),total:String(o)})}
            </div>
            <div class="data-table-pagination__controls">
              <select
                class="data-table-pagination__size"
                aria-label=${I(`sessionsView.pageSize`)}
                .value=${String(e.pageSize)}
                @change=${t=>e.onPageSizeChange(Number(t.target.value))}
              >
                ${zn.map(t=>N`<option value=${t} ?selected=${t===e.pageSize}>
                      ${I(`sessionsView.rowsPerPage`,{count:String(t)})}
                    </option>`)}
              </select>
              <button ?disabled=${c<=0} @click=${()=>e.onPageChange(c-1)}>
                ${I(`common.previous`)}
              </button>
              <button
                ?disabled=${c>=s-1}
                @click=${()=>e.onPageChange(c+1)}
              >
                ${I(`common.next`)}
              </button>
            </div>
          </div>
        `:M}
  `}function Pn(e,t){let n=e.updatedAt?D(e.updatedAt):I(`common.na`),r=e.latestCompactionCheckpoint,i=e.compactionCheckpointCount??0,o=Math.max(i,+!!r),s=i>0||!!r,c=t.expandedSessionKey===e.key,l=`session-details-${encodeURIComponent(e.key)}`,u=a(e.displayName)??null,d=a(e.label)??``,f=!!(u&&u!==e.key&&u!==d),p=v(e.key),m=p?U(t.agentIdentityById,p.agentId):null,h=a(m?.emoji)??``,g=a(m?.name)??``,_=g&&p?`${h?`${h} `:``}${g} (${p.channel})`:null,y=_??e.key,b=e.kind!==`global`,S=b?A({face:ce(e),sessionKey:e.key,fallbackAgentId:t.agentId,basePath:t.basePath,row:e,mainKey:t.mainKey,preferenceDerivedFace:!0}).href:null,C=`session-kind session-kind--${K(e)}`,w=[`session-data-row`,`session-data-row--expandable`,t.statusFilter===`all`&&e.archived===!0?`session-data-row--archived`:``,c?`session-data-row--expanded`:``,t.sessionMenu?.key===e.key?`session-data-row--menu-open`:``].filter(Boolean).join(` `),te=I(c?`sessionsView.hideSessionDetails`:`sessionsView.showSessionDetails`,{count:y}),T=t.groupBy===`category`,E=Tn(t,a(e.category)??null),O=n=>ee(n,n instanceof KeyboardEvent?n.currentTarget.querySelector(`button[aria-haspopup="menu"]`):null,(n,r,i)=>t.onOpenSessionMenu(e,{x:r,y:i},n));return[N`<tr
      class=${w}
      tabindex="0"
      aria-expanded=${String(c)}
      aria-controls=${l}
      draggable=${T?`true`:M}
      aria-description=${T?I(`sessionsView.dragSessionHint`):M}
      @dragstart=${T?t=>{t.dataTransfer?.setData(z,e.key),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`)}:M}
      @dragover=${E.dragover}
      @dragleave=${E.dragleave}
      @drop=${E.drop}
      @contextmenu=${O}
      @click=${n=>{On(n.target)||t.onToggleDetails(e.key)}}
      @keydown=${n=>{O(n),!n.defaultPrevented&&(On(n.target)||(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t.onToggleDetails(e.key)))}}
    >
      <td class="data-table-checkbox-col">
        <input
          type="checkbox"
          .checked=${t.selectedKeys.has(e.key)}
          @change=${()=>t.onToggleSelect(e.key)}
          aria-label=${`${I(`sessionsView.selectSession`)}: ${e.key}`}
        />
      </td>
      <td class="data-table-key-col">
        <openclaw-tooltip .content=${y}>
          <div class=${_?`session-key-cell`:`mono session-key-cell`}>
            ${sn(e)}
            <div class="session-key-cell__text">
              <span class="session-key-cell__primary">
                ${e.unread===!0?N`<span
                      class="session-unread-dot"
                      role="img"
                      aria-label=${I(`sessionsView.unread`)}
                    ></span>`:M}
                ${b?N`<a
                      href=${S}
                      class="session-link"
                      @click=${n=>{x(n)&&t.onNavigateToChat&&(n.preventDefault(),t.onNavigateToChat(e.key))}}
                      >${_??e.key}</a
                    >`:N`<span>${_??e.key}</span>`}
                ${d?N`<span class="session-label-chip" title=${d}
                      >${d}</span
                    >`:M}
              </span>
              ${f?N`<span class="muted session-key-display-name">${u}</span>`:M}
            </div>
          </div>
        </openclaw-tooltip>
      </td>
      ${T?Dn(e,t):M}
      <td>
        <span class=${C}>${K(e)}</span>
      </td>
      <td class="session-status-col">
        <div class="session-status-stack">
          ${on(e)} ${xn(e.goal)}
          ${t.statusFilter===`all`&&e.archived===!0?R({kind:`muted`,label:I(`sessionsView.archived`)}):M}
        </div>
      </td>
      <td>${n}</td>
      <td class="session-token-cell">${cn(e)}</td>
      <td class="session-actions-cell">
        <div class="session-actions">
          <button
            class="session-details-toggle"
            type="button"
            aria-expanded=${String(c)}
            aria-controls=${l}
            aria-label=${te}
            @click=${n=>{n.stopPropagation(),t.onToggleDetails(e.key)}}
          >
            ${o>0?N`<span class="settings-count session-compaction-count"
                  >${o}</span
                >`:M}
            ${F.chevronDown}
          </button>
          <button
            class="icon-btn"
            type="button"
            title=${I(`chat.sidebar.openSessionMenu`)}
            aria-label=${I(`chat.sidebar.openSessionMenu`)}
            aria-haspopup="menu"
            aria-expanded=${String(t.sessionMenu?.key===e.key)}
            @click=${n=>{n.stopPropagation();let r=n.currentTarget,i=r.getBoundingClientRect();t.onOpenSessionMenu(e,{x:i.right,y:i.bottom+4},r)}}
          >
            ${F.moreHorizontal}
          </button>
        </div>
      </td>
    </tr>`,...c?[Fn({row:e,props:t,detailsId:l,friendlyKeyLabel:_,displayName:u,showDisplayName:f,kindClass:C,updated:n,visibleCheckpointCount:o,hasCheckpoints:s})]:[]]}function Fn(e){let{row:t,props:n,detailsId:r,friendlyKeyLabel:i,displayName:o,showDisplayName:s,kindClass:c,updated:l,visibleCheckpointCount:u,hasCheckpoints:d}=e,f=t.thinkingLevel??``,p=f?V(f):``,m=W(rn(t,n.result?.defaults),p),h=t.fastMode===`auto`?`auto`:t.fastMode===!0?`on`:t.fastMode===!1?`off`:``,g=W(G(Ln),h),_=t.verboseLevel??``,v=W(G(X,!0),_),y=t.reasoningLevel??``,b=W(G(Rn),y),x=n.checkpointItemsByKey[t.key]??[],S=n.checkpointErrorByKey[t.key],C=vn(u),w=Sn({row:t,updated:l,checkpointCount:u});return N`<tr id=${r} class="session-details-row">
    <td colspan=${q(n)}>
      <div class="session-details-panel">
        <div class="session-details-panel__hero">
          <div>
            <div class="session-details-panel__eyebrow">${I(`sessionsView.sessionDetails`)}</div>
            <div class="session-details-panel__title">${i??t.key}</div>
            ${s?N`<div class="muted session-details-panel__subtitle">${o}</div>`:M}
          </div>
          <div class="session-details-panel__badges">
            ${on(t)} ${xn(t.goal)}
            <span class=${c}>${K(t)}</span>
          </div>
        </div>

        <div class="session-details-section">
          <div class="session-details-panel__eyebrow">${I(`sessionsView.overrides`)}</div>
          <div class="session-overrides-grid">
            <label class="session-override-field">
              <span class="session-override-field__label">${I(`sessionsView.label`)}</span>
              <input
                class="settings-input"
                .value=${t.label??``}
                ?disabled=${n.loading||!!n.patchWriteDisabledReason}
                title=${n.patchWriteDisabledReason??M}
                placeholder=${I(`sessionsView.optionalPlaceholder`)}
                @change=${e=>{let r=a(e.target.value)??null;n.onPatch(t.key,{label:r})}}
              />
            </label>
            ${Y({label:I(`sessionsView.thinking`),disabled:n.loading||!!n.patchAdminDisabledReason,disabledReason:n.patchAdminDisabledReason,options:m,current:p,onChange:e=>n.onPatch(t.key,{thinkingLevel:e||null})})}
            ${Y({label:I(`sessionsView.fast`),disabled:n.loading||!!n.patchAdminDisabledReason,disabledReason:n.patchAdminDisabledReason,options:g,current:h,onChange:e=>n.onPatch(t.key,{fastMode:e===``?null:e===`auto`?`auto`:e===`on`})})}
            ${Y({label:I(`sessionsView.verbose`),disabled:n.loading||!!n.patchAdminDisabledReason,disabledReason:n.patchAdminDisabledReason,options:v,current:_,onChange:e=>n.onPatch(t.key,{verboseLevel:e||null})})}
            ${Y({label:I(`sessionsView.reasoning`),disabled:n.loading||!!n.patchAdminDisabledReason,disabledReason:n.patchAdminDisabledReason,options:b,current:y,onChange:e=>n.onPatch(t.key,{reasoningLevel:e||null})})}
          </div>
        </div>

        <div class="session-details-grid">
          ${w.map(e=>N`
              <div class="session-detail-stat">
                <div class="session-detail-stat__label">${e.label}</div>
                <openclaw-tooltip .content=${e.value}>
                  <div class="session-detail-stat__value">${e.value}</div>
                </openclaw-tooltip>
              </div>
            `)}
        </div>

        <div class="session-details-section">
          <div class="session-details-section__header">
            <div>
              <div class="session-details-panel__eyebrow">
                ${I(`sessionsView.compactionHistory`)}
              </div>
              <div class="session-details-section__title">${C}</div>
            </div>
          </div>
          ${n.checkpointLoadingKey===t.key?N`<div class="muted session-details-empty">
                ${I(`sessionsView.loadingCheckpoints`)}
              </div>`:S?N`<div class="callout danger" role="alert">${S}</div>`:!d||x.length===0?N`<div class="muted session-details-empty">
                    ${I(`sessionsView.noCheckpoints`)}
                  </div>`:N`
                    <div class="session-checkpoint-list">
                      ${x.map(e=>N`
                          <div class="session-checkpoint-card">
                            <div class="session-checkpoint-card__header">
                              <strong>
                                ${_n(e.reason)} ·
                                ${D(e.createdAt)}
                              </strong>
                              <span class="muted session-checkpoint-card__delta">
                                ${yn(e)}
                              </span>
                            </div>
                            ${e.summary?N`<div class="session-checkpoint-card__summary">
                                  ${e.summary}
                                </div>`:N`<div class="muted">${I(`sessionsView.noSummary`)}</div>`}
                            <div class="session-checkpoint-card__actions">
                              <button
                                class="btn btn--sm"
                                ?disabled=${n.checkpointBusyKey===e.checkpointId||!!n.checkpointBranchDisabledReason}
                                title=${n.checkpointBranchDisabledReason??M}
                                @click=${()=>n.onBranchFromCheckpoint(t.key,e.checkpointId)}
                              >
                                ${I(`sessionsView.branchFromCheckpoint`)}
                              </button>
                              <button
                                class="btn btn--sm"
                                ?disabled=${n.checkpointBusyKey===e.checkpointId||!!n.checkpointRestoreDisabledReason}
                                title=${n.checkpointRestoreDisabledReason??M}
                                @click=${()=>n.onRestoreCheckpoint(t.key,e.checkpointId)}
                              >
                                ${I(`sessionsView.restoreCheckpoint`)}
                              </button>
                            </div>
                          </div>
                        `)}
                    </div>
                  `}
        </div>
      </div>
    </td>
  </tr>`}var In,X,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Z,Q;function Kn(){return(Kn=e((()=>{s(),Te(),Gt(),Be(),Le(),ze(),jt(),mt(),Re(),he(),Dt(),ye(),te(),Vt(),Se(),ft(),lt(),f(),O(),S(),In=[`off`,`minimal`,`low`,`medium`,`high`],X=[``,`off`,`on`,`full`],Ln=[``,`auto`,`on`,`off`],Rn=[``,`off`,`on`,`stream`],zn=[10,25,50,100],Bn={queued:`sessionsView.statusQueued`,running:`sessionsView.statusRunning`,done:`sessionsView.statusDone`,failed:`sessionsView.statusFailed`,killed:`sessionsView.statusKilled`,timeout:`sessionsView.statusTimeout`},Vn={cron:F.clock,direct:F.messageSquare,group:F.users,global:F.globe,unknown:F.circle},Hn=65,Un=85,Wn=4,Gn={manual:`sessionsView.manual`,"auto-threshold":`sessionsView.autoThreshold`,"overflow-retry":`sessionsView.overflowRetry`,"timeout-retry":`sessionsView.timeoutRetry`},Z=`__new-group__`,Q={none:`sessionsView.groupByNone`,category:`sessionsView.groupByCategory`,person:`sessionsView.groupByPerson`,channel:`sessionsView.groupByChannel`,kind:`sessionsView.groupByKind`,agent:`sessionsView.groupByAgent`,date:`sessionsView.groupByDate`}})))()}var qn,$;function Jn(){return(Jn=e((()=>{Ge(),Ve(),s(),Te(),Ee(),Ne(),Ae(),Pe(),ke(),Ut(),wt(),Ye(),rt(),tt(),ut(),qt(),mt(),Lt(),Re(),T(),nt(),pe(),qe(),st(),u(),it(),g(),vt(),f(),O(),At(),Nt(),w(),d(),Ft(),Rt(),fe(),we(),Xt(),$t(),nn(),m(),Kn(),r(),qn=`https://docs.openclaw.ai/concepts/session`,$=class extends re{constructor(...e){super(...e),this.result=null,this.loading=!1,this.error=null,this.activeMinutes=``,this.limit=`50`,this.includeGlobal=!0,this.includeUnknown=!1,this.statusFilter=`active`,this.searchQuery=``,this.transcriptSearchQuery=``,this.submittedTranscriptSearchQuery=``,this.transcriptSearch={status:`idle`},this.sortColumn=`updated`,this.sortDir=`desc`,this.groupBy=en(),this.page=0,this.pageSize=25,this.selectedKeys=new Set,this.sessionMenu=null,this.sessionMenuWork=null,this.expandedSessionKey=null,this.deepLinkSessionKey=null,this.checkpointItemsByKey={},this.checkpointTaskKey=null,this.checkpointBusyKey=null,this.checkpointErrorByKey={},this.pageEpoch=0,this.routeDataEnabled=!0,this.sessionMutationPending=!1,this.sessionMenuTrigger=null,this.sessionMenuWorkVersion=0,this.observeAgentScope=Qe(()=>{this.resetTranscriptSearchState(this.transcriptSearchQuery),this.deepLinkSessionKey||(this.page=0,this.selectedKeys=new Set,this.routeDataEnabled=!1,this.bindSessionList()),this.requestUpdate()}),this.subscriptions=new ve(this).watch(()=>this.context?.agentIdentity,(e,t)=>e.subscribe(t)).effect(()=>this.context?.agentSelection,e=>this.observeAgentScope(e)).watch(()=>this.context?.runtimeConfig,(e,t)=>e.subscribe(t)).watch(()=>this.context?.workboard,(e,t)=>e.subscribe(t)),this.gatewayLifecycle=new zt(this,{getGateway:()=>this.context?.gateway,onIdentityChange:()=>{let e=this.listBinding?.sessions.listSnapshot(this.listBinding.query).result;this.resetProviderState(),this.appliedListResult=e},invalidateRequests:()=>this.invalidatePageWork()}),this.transcriptSearchTask=new He(this,{args:()=>this.transcriptSearchArgs(),task:async([e,t,n,r,i])=>{if(!e||!t||!n||!i)return null;let a=await kt({client:e,query:t,listSessions:n.sessions.list,listOptions:this.sessionListOptions(n),resolveAgentId:e=>p(e)?.agentId??this.sessionAgentId(e,n)});return{results:a.results,indexing:a.indexing===!0,truncated:a.truncated===!0}},onComplete:e=>{this.transcriptSearch=e?{status:`results`,...e}:{status:`idle`}},onError:e=>{this.transcriptSearch={status:`error`,message:k(e)}}}),this.checkpointTask=new He(this,{autoRun:!1,args:()=>[null,``],task:async([e,t])=>!e||!t?We:{sessionKey:t,checkpoints:await e.sessions.listCheckpoints(t,{agentId:this.sessionAgentId(t,e.context)})},onComplete:({sessionKey:e,checkpoints:t})=>{this.checkpointItemsByKey={...this.checkpointItemsByKey,[e]:t}},onError:e=>{let t=this.checkpointTaskKey;t&&(this.checkpointErrorByKey={...this.checkpointErrorByKey,[t]:k(e)})}}),this.dialogLifecycle=null}transcriptSearchArgs(){let e=this.context,t=e?.gateway.snapshot;return[t?.phase===`connected`?t.client??null:null,this.submittedTranscriptSearchQuery,e??null,e?.agentSelection.state.scopeId??null,t?L(t,`sessions.search`)===!0:!1]}willUpdate(e){let t=this.context?.sessions;t&&this.listBinding&&this.listBinding.sessions!==t&&(this.unsubscribeList?.(),this.unsubscribeList=void 0,this.listBinding=void 0,this.invalidatePageWork(),this.resetProviderState()),(e.has(`routeData`)||e.has(`context`))&&this.applyRouteData(),this.bindSessionList()}disconnectedCallback(){this.unsubscribeList?.(),this.unsubscribeList=void 0,this.listBinding=void 0,this.subscriptions.clear(),this.invalidatePageWork(),this.dialogLifecycle?.abort(),super.disconnectedCallback()}invalidatePageWork(){this.pageEpoch+=1,this.submittedTranscriptSearchQuery=``,this.transcriptSearch={status:`idle`},this.transcriptSearchTask.run(this.transcriptSearchArgs()),this.resetCheckpointTask(),this.loading=!1,this.checkpointBusyKey=null,this.sessionMutationPending=!1,this.closeSessionMenu()}resetProviderState(){this.result=null,this.error=null,this.loading=!1,this.resetTranscriptSearchState(``),this.selectedKeys=new Set,this.expandedSessionKey=null,this.deepLinkSessionKey=null,this.checkpointItemsByKey={},this.checkpointTaskKey=null,this.checkpointBusyKey=null,this.checkpointErrorByKey={},this.appliedListResult=void 0}captureRequestScope(){let e=this.context;if(!this.isConnected||!e)return null;let t=e.gateway,n=this.gatewayLifecycle.gateway===t?this.gatewayLifecycle.client:null;return!this.gatewayLifecycle.connected||!n?null:{epoch:this.pageEpoch,context:e,gateway:t,sessions:e.sessions,workboard:e.workboard,client:n}}isRequestScopeCurrent(e){let t=this.context,n=t?.gateway;return this.isConnected&&this.pageEpoch===e.epoch&&t===e.context&&n===e.gateway&&t.sessions===e.sessions&&t.workboard===e.workboard&&n.snapshot.phase===`connected`&&n.snapshot.client===e.client}mutationDisabledReason(e){let t=C(this.context?.gateway.snapshot,e);return t.allowed?void 0:t.reason}requireMutationAccess(e,t){let n=C(e.gateway.snapshot,t);return n.allowed?!0:(this.error=n.reason,!1)}selectedDeleteDisabledReason(){let e=new Map(this.result?.sessions.map(e=>[e.key,e])??[]);for(let t of this.selectedKeys){let n=e.get(t),r=this.mutationDisabledReason({method:`sessions.delete`,params:{key:t,...n?.archived===!0?{archivedOnly:!0}:{}}});if(r)return r}}applyRouteData(){let e=this.routeData,t=this.context;if(!(!e||!t)&&(e!==this.appliedRouteData&&(this.appliedRouteData=e,this.routeDataEnabled=!0),this.routeDataEnabled)){if(this.statusFilter=e.statusFilter,e.expandedSessionKey?(this.activeMinutes=``,this.limit=`50`,this.includeGlobal=!0,this.includeUnknown=!0,this.searchQuery=``,this.page=0,this.selectedKeys=new Set):(this.activeMinutes=``,this.limit=`50`,this.includeGlobal=!0,this.includeUnknown=!1),this.expandedSessionKey=e.expandedSessionKey,this.deepLinkSessionKey=e.expandedSessionKey,!this.gatewayLifecycle.isRouteDataCurrent(e)||e.sessions!==t.sessions){this.routeDataEnabled=!1,this.refreshSessionList(),e.expandedSessionKey&&this.loadCheckpoint(e.expandedSessionKey);return}this.result=e.result?ne(e.result,{archivedFilter:e.statusFilter}):null,this.appliedListResult=e.result,this.error=e.error,this.loading=e.loading,this.ensureAgentIdentities(this.result),e.expandedSessionKey&&this.loadCheckpoint(e.expandedSessionKey)}}sessionAgentId(e,t=this.context){if(!t)return;let{agentId:n}=_e({assistantAgentId:t.agentSelection.state.selectedId,hello:t.gateway.snapshot.hello},e);return n}sessionPathAgentId(e,t){return this.sessionAgentId(e,t)??_(t)}sessionListOptions(e){return le(e,{activeMinutes:o(this.activeMinutes),limit:o(this.limit)??50,includeGlobal:this.includeGlobal,includeUnknown:this.includeUnknown,statusFilter:this.statusFilter,deepLinkSessionKey:this.deepLinkSessionKey})}bindSessionList(e=!0){let t=this.context;if(!t)return;let n=t.sessions,r=this.sessionListOptions(t),i=JSON.stringify(r),a=this.listBinding;if(a?.sessions===n&&a.key===i)return a;this.unsubscribeList?.(),this.resetTranscriptSearchState(this.transcriptSearchQuery);let o={sessions:n,query:r,key:i};this.listBinding=o,this.appliedListResult=void 0;let s=e=>{this.applyListSnapshot(o,e)};this.unsubscribeList=n.subscribeList(r,s);let c=n.listSnapshot(r);return s(c),e&&!c.result&&!c.loading&&t.gateway.snapshot.phase===`connected`&&n.refreshList({...r,force:!0}),o}applyListSnapshot(e,t){if(this.listBinding!==e||this.context?.sessions!==e.sessions)return;this.loading=t.loading,this.error=t.error;let n=t.result;if(!n||n===this.appliedListResult)return;let r=this.result;this.appliedListResult=n,this.result=ne(n,{archivedFilter:this.statusFilter}),this.ensureAgentIdentities(this.result);let i=this.reconcileCheckpointCache(r,this.result);i&&this.loadCheckpoint(i)}async refreshSessionList(e=this.captureRequestScope()){if(!e)return;this.routeDataEnabled=!1;let t=this.bindSessionList(!1);!t||t.sessions!==e.sessions||!this.isRequestScopeCurrent(e)||(await t.sessions.refreshList({...t.query,force:!0}),this.isRequestScopeCurrent(e)&&this.listBinding===t&&this.applyListSnapshot(t,t.sessions.listSnapshot(t.query)))}adoptCurrentListSnapshot(){let e=this.listBinding;e&&this.applyListSnapshot(e,e.sessions.listSnapshot(e.query))}resetTranscriptSearchState(e){this.transcriptSearchQuery=e,this.submittedTranscriptSearchQuery=``,this.transcriptSearch={status:`idle`},this.transcriptSearchTask.run(this.transcriptSearchArgs())}updateTranscriptSearchQuery(e){e!==this.transcriptSearchQuery&&this.resetTranscriptSearchState(e)}clearTranscriptSearch(){this.resetTranscriptSearchState(``)}async runTranscriptSearch(){let e=this.transcriptSearchQuery.trim();if(!e){this.clearTranscriptSearch();return}let t=this.captureRequestScope();!t||L(t.gateway.snapshot,`sessions.search`)!==!0||(this.transcriptSearchQuery=e,this.submittedTranscriptSearchQuery=e,this.transcriptSearch={status:`loading`},await this.transcriptSearchTask.run(this.transcriptSearchArgs()))}ensureAgentIdentities(e){let t=this.context;if(!t||!e)return;let n=Jt(e).filter(e=>!t.agentIdentity.get(e));n.length!==0&&t.agentIdentity.ensure(n)}reconcileCheckpointCache(e,t){let n=new Map((t?.sessions??[]).map(e=>[e.key,e])),r=new Map((e?.sessions??[]).map(e=>[e.key,e])),i={...this.checkpointItemsByKey},a={...this.checkpointErrorByKey},o=null;for(let e of Object.keys(i)){let t=n.get(e),s=r.get(e);(!t||!s||s.compactionCheckpointCount!==t.compactionCheckpointCount||s.latestCompactionCheckpoint?.checkpointId!==t.latestCompactionCheckpoint?.checkpointId)&&(delete i[e],delete a[e],this.expandedSessionKey===e&&(o=e))}return this.checkpointItemsByKey=i,this.checkpointErrorByKey=a,o}updateFilters(e){this.activeMinutes=e.activeMinutes,this.limit=e.limit,this.includeGlobal=e.includeGlobal,this.includeUnknown=e.includeUnknown,this.page=0,this.selectedKeys=new Set,this.deepLinkSessionKey=null,this.refreshSessionList()}updateStatusFilter(e){let t=this.context;e===this.statusFilter||!t||(this.statusFilter=e,this.page=0,this.selectedKeys=new Set,this.deepLinkSessionKey=null,this.loading=!0,this.error=null,t.navigate(`sessions`,e===`active`?void 0:{search:`?status=${e}`}))}async deleteSelected(){let e=[...this.selectedKeys];if(e.length===0||this.loading||this.sessionMutationPending)return;let t=this.captureRequestScope();if(!t)return;let n=new Map(this.result?.sessions.map(e=>[e.key,e])??[]),r=e.map(e=>n.get(e)??{key:e}),i=I(e.length===1?`sessionsView.deleteSelectedConfirmOne`:`sessionsView.deleteSelectedConfirm`,{count:String(e.length)});!await B({message:i,confirmLabel:I(`common.delete`),danger:!0})||!this.isRequestScopeCurrent(t)||await this.deleteSessions(r)}async deleteSessions(e,t={}){if(e.length===0||this.loading||this.sessionMutationPending)return;let n=this.captureRequestScope();if(!n)return;let r=e.map(e=>({key:e.key,agentId:this.sessionAgentId(e.key,n.context),...t,...e.sessionId?{expectedSessionId:e.sessionId}:{},...e.archived===!0?{archivedOnly:!0}:{}}));for(let e of r)if(!this.requireMutationAccess(n,{method:`sessions.delete`,params:e}))return;this.sessionMutationPending=!0;let i=null;try{let e=await n.sessions.deleteMany(r);if(!this.isRequestScopeCurrent(n))return;if(e.preservedWorktrees.length>0&&window.alert(Mt(e.preservedWorktrees)),e.deleted.length>0){let t=new Set(e.deleted),r=new Set(this.selectedKeys);for(let t of e.deleted)r.delete(t);this.selectedKeys=r,this.expandedSessionKey&&t.has(this.expandedSessionKey)&&(this.expandedSessionKey=null),this.deepLinkSessionKey&&t.has(this.deepLinkSessionKey)&&(this.deepLinkSessionKey=null);let i=e.deleted.find(e=>de(e,n.gateway.snapshot.sessionKey));if(i){let e=p(i)?.agentId??n.context.agentSelection.state.selectedId??`main`;Me({selection:n.context.agentSelection,gateway:n.gateway,agentId:e,sessionKey:oe({agentId:e,mainKey:j({agentsList:n.context.agents.state.agentsList,hello:n.gateway.snapshot.hello})})})}}await this.refreshSessionList(n),e.errors.length>0&&(i=me(e.errors.join(`; `)))}catch(e){this.isRequestScopeCurrent(n)&&(i=k(e))}finally{this.isRequestScopeCurrent(n)&&(this.sessionMutationPending=!1,this.adoptCurrentListSnapshot(),i&&(this.error=i))}}async deleteAllArchived(){let e=this.captureRequestScope();if(!e||this.loading||this.sessionMutationPending)return;let t;try{let{search:n,agentId:r,...i}=this.sessionListOptions(e.context),a=e.context.agentSelection.state.scopeId?.trim(),o={...i,...a?{agentId:a}:{}},s=await ht({list:t=>e.sessions.list({...o,limit:1e3,offset:t}),isCurrent:()=>this.isRequestScopeCurrent(e),missingResultError:e.sessions.state.error??`archived session enumeration returned no result`,stalledPaginationError:`archived session enumeration did not advance`,incompletePaginationError:`archived session enumeration was incomplete`});if(!s)return;t=s}catch(t){this.isRequestScopeCurrent(e)&&(this.error=k(t));return}let n=t.filter(e=>e.archived===!0);n.length!==0&&(!await B({message:I(`sessionsView.deleteAllArchivedConfirm`,{count:String(n.length)}),confirmLabel:I(`common.delete`),danger:!0})||!this.isRequestScopeCurrent(e)||await this.deleteSessions(n,{deleteTranscript:!0}))}async deleteSessionFromMenu(e){let t=a(e.label)??e.key,n=this.captureRequestScope();!n||!await B({message:I(`sessionsView.deleteSessionConfirm`,{session:t}),confirmLabel:I(`common.delete`),danger:!0})||!this.isRequestScopeCurrent(n)||await this.deleteSessions([e])}async stopCloudWorker(e){let t=a(e.label)??e.key,n=Ze(e.placement);if(!n||n.blocksActiveRun&&e.hasActiveRun===!0)return;let r=this.captureRequestScope();if(!r||!await B({message:I(`sessionsView.stopCloudWorkerConfirm`,{session:t}),confirmLabel:I(`sessionsView.stopCloudWorkerConfirmAction`),danger:!0})||!this.isRequestScopeCurrent(r)||!this.requireMutationAccess(r,n))return;this.sessionMutationPending=!0;let i=null;try{let t=p(e.key)?.agentId;await et(r.client,{key:e.key,...t?{agentId:t}:{}}),this.isRequestScopeCurrent(r)&&await this.refreshSessionList(r)}catch(e){this.isRequestScopeCurrent(r)&&(i=k(e))}finally{this.isRequestScopeCurrent(r)&&(this.sessionMutationPending=!1,this.adoptCurrentListSnapshot(),i&&(this.error=i))}}knownCategories(){return Zt(this.result,this.context?.sessions.state.groups??[])}setGroupBy(e){this.groupBy=e,this.page=0,tn(e)}async rememberCustomGroup(e,t=this.captureRequestScope()){return t?this.requireMutationAccess(t,{method:`sessions.groups.put`,requiredScope:`operator.write`})?Qt({name:e,knownCategories:this.knownCategories(),sessions:t.sessions,isCurrent:()=>this.isRequestScopeCurrent(t),onError:e=>{this.error=e}}):`failed`:`stale`}assignCategory(e,t){let n=this.result?.sessions.find(t=>t.key===e);n&&(n.category?.trim()||null)!==t&&(t&&this.rememberCustomGroup(t),this.patchSession(e,{category:t}))}async withDialogLifecycle(e){let t=this.dialogLifecycle;if(t)return e(t.signal);let n=new AbortController;this.dialogLifecycle=n;try{return await e(n.signal)}finally{this.dialogLifecycle===n&&(this.dialogLifecycle=null)}}async loadInputDialog(){try{return(await n(async()=>{let{showInputDialog:e}=await import(`./input-dialog-BErqtvL-.js`);return{showInputDialog:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url)).showInputDialog}catch(e){return this.error=k(e),null}}async requestNewCategory(e){let t=this.result?.sessions.find(t=>t.key===e);if(e&&!t?.sessionId){this.error=I(`common.refresh`);return}await this.withDialogLifecycle(async e=>{await(await this.loadInputDialog())?.({signal:e,title:I(`sessionsView.newGroupTitle`),label:I(`sessionsView.newGroupPrompt`),submitLabel:I(`sessionsView.newGroupCreate`),requireValue:!0,submit:e=>this.writeNewCategory(e,t)})})}async writeNewCategory(e,t){this.error=null;let n=this.captureRequestScope();if(!n)return I(`sessionsView.newGroupFailed`);let r=await this.rememberCustomGroup(e,n);if(r!==`completed`)return r===`failed`?this.error??I(`sessionsView.newGroupFailed`):I(`sessionsView.newGroupStale`);if(!t)return null;let i=await this.patchSession(t.key,{category:e},n,t.sessionId);return i===`failed`?this.error??I(`sessionsView.newGroupFailed`):i===`stale`?I(`sessionsView.newGroupStale`):null}async renameSession(e){let t=await this.withDialogLifecycle(async t=>await(await this.loadInputDialog())?.({signal:t,title:I(`sessionsView.renameSessionPrompt`),defaultValue:a(e.label)??``})??null);if(t===null)return;let n={label:a(t)??null};this.patchSession(e.key,n,void 0,e.sessionId)}async patchSession(e,t,n=this.captureRequestScope(),r){if(!n)return this.error=I(`sessionsView.actionRequiresConnection`),`failed`;if(typeof t.archived==`boolean`&&!r?.trim())return this.error=`Session lifecycle action requires a durable session identity.`,`failed`;let i=this.sessionAgentId(e,n.context);if(!this.requireMutationAccess(n,{method:`sessions.patch`,params:{key:e,...t,...i?{agentId:i}:{}}}))return`failed`;try{let a=await n.sessions.patch(e,t,{agentId:i,...r?{expectedSessionId:r}:{}});if(!this.isRequestScopeCurrent(n))return`stale`;if(!a)return this.error=n.sessions.state.error,`failed`;if(await this.refreshSessionList(n),!this.isRequestScopeCurrent(n))return`stale`;let o=new Set(this.selectedKeys);return o.delete(e),this.selectedKeys=o,`completed`}catch(e){return this.isRequestScopeCurrent(n)?(this.error=k(e),`failed`):`stale`}}async archiveSessionWithUndo(e){let t=this.captureRequestScope();if(!t||await this.patchSession(e.key,{archived:!0},t,e.sessionId)!==`completed`||!this.isRequestScopeCurrent(t))return;let n=this.sessionAgentId(e.key,t.context);h({message:I(`sessionsView.sessionArchived`),actionLabel:I(`common.undo`),onAction:()=>{t.sessions.patch(e.key,{archived:!1,...e.pinned===!0?{pinned:!0}:{}},{agentId:n,expectedSessionId:e.sessionId})}})}async forkSession(e,t=!1){let n=this.captureRequestScope();if(!n)return;let r=this.sessionAgentId(e,n.context),i={parentSessionKey:e,fork:!0,...t?{forkFrom:`last-completed`}:{},...r?{agentId:r}:{}};if(this.requireMutationAccess(n,{method:`sessions.create`,params:i}))try{let e=await n.sessions.create(i);if(!this.isRequestScopeCurrent(n))return;e?n.context.navigate(`chat`,{...A({context:n.context,face:`chat`,sessionKey:e,agentId:r??this.sessionPathAgentId(e,n.context)}).options,hash:``}):n.sessions.state.error&&(this.error=n.sessions.state.error)}catch(e){this.isRequestScopeCurrent(n)&&(this.error=k(e))}}async toggleSessionDetails(e){if(!this.context)return;let t=this.deepLinkSessionKey!==null;if(this.deepLinkSessionKey=null,t&&this.refreshSessionList(),this.expandedSessionKey===e){this.resetCheckpointTask(),this.expandedSessionKey=null;return}this.expandedSessionKey=e;let n=this.result?.sessions.find(t=>t.key===e);if(!((n?.compactionCheckpointCount??0)>0||n?.latestCompactionCheckpoint)){this.checkpointItemsByKey[e]||(this.checkpointItemsByKey={...this.checkpointItemsByKey,[e]:[]});return}this.checkpointItemsByKey[e]||await this.loadCheckpoint(e)}async loadCheckpoint(e){let t=this.captureRequestScope();if(!t){this.checkpointErrorByKey={...this.checkpointErrorByKey,[e]:I(`sessionsView.actionRequiresConnection`)};return}this.checkpointTaskKey=e,this.checkpointErrorByKey={...this.checkpointErrorByKey,[e]:``},await this.checkpointTask.run([t,e])}resetCheckpointTask(){this.checkpointTaskKey=null,this.checkpointTask.run([null,``])}get checkpointLoadingKey(){return this.checkpointTask.status===Ke.PENDING?this.checkpointTaskKey:null}async branchCheckpoint(e,t){let n=this.captureRequestScope();if(!(!n||!await B({message:I(`sessionsView.branchCheckpointConfirm`),confirmLabel:I(`common.create`)})||!this.isRequestScopeCurrent(n))&&this.requireMutationAccess(n,{method:`sessions.compaction.branch`,requiredScope:`operator.write`})){this.checkpointBusyKey=t;try{let r=await n.sessions.branchCheckpoint(e,t,{agentId:this.sessionAgentId(e,n.context)});this.isRequestScopeCurrent(n)&&n.context.navigate(`chat`,{...A({context:n.context,face:`chat`,sessionKey:r.key,agentId:this.sessionPathAgentId(r.key,n.context)}).options,hash:``})}catch(e){this.isRequestScopeCurrent(n)&&(this.error=k(e))}finally{this.isRequestScopeCurrent(n)&&this.checkpointBusyKey===t&&(this.checkpointBusyKey=null)}}}async restoreCheckpoint(e,t){let n=this.captureRequestScope();if(!(!n||!await B({message:I(`sessionsView.restoreCheckpointConfirm`),confirmLabel:I(`common.restore`),danger:!0})||!this.isRequestScopeCurrent(n))&&this.requireMutationAccess(n,{method:`sessions.compaction.restore`,requiredScope:`operator.admin`})){this.checkpointBusyKey=t;try{await n.sessions.restoreCheckpoint(e,t,{agentId:this.sessionAgentId(e,n.context)})}catch(e){this.isRequestScopeCurrent(n)&&(this.error=k(e))}finally{this.isRequestScopeCurrent(n)&&this.checkpointBusyKey===t&&(this.checkpointBusyKey=null)}}}openSessionMenu(e,t,n){if(this.sessionMenu?.key===e.key&&n){this.closeSessionMenu();return}this.sessionMenu={key:e.key,...t},this.sessionMenuTrigger=n,this.loadSessionMenuWork(e)}closeSessionMenu(){this.context&&$e(this.context.gateway).unwatch(this),this.sessionMenu=null,this.sessionMenuTrigger=null,this.sessionMenuWorkVersion+=1,this.sessionMenuWork=null}loadSessionMenuWork(e){let t=++this.sessionMenuWorkVersion;if(!e.worktree){this.sessionMenuWork=null;return}this.sessionMenuWork={loading:!0,pullRequestUrl:null,worktreePath:null};let n=this.captureRequestScope();if(!n){this.sessionMenuWork={loading:!1,pullRequestUrl:null,worktreePath:null};return}let r=$e(n.context.gateway),i=Et(e.key,this.sessionAgentId(e.key,n.context));Je({client:n.client,loadPullRequests:L(n.context.gateway.snapshot,`controlUi.sessionPullRequests.subscribe`)===!0?()=>r.load(this,i):void 0,worktreeId:e.worktree.id,execNode:e.execNode}).then(e=>{t===this.sessionMenuWorkVersion&&(this.sessionMenuWork={loading:!1,...e})})}renderSessionMenu(){let e=this.sessionMenu,t=this.context,n=e?this.result?.sessions.find(t=>t.key===e.key):null;if(!e||!t||!n)return M;let r=t.gateway.snapshot,i=xe(t.runtimeConfig.state.configSnapshot)&&Ie(r.hello?.auth??null),o=t.workboard.state,s=new Set(o.cards.filter(be).flatMap(e=>[e.sessionKey,e.execution?.sessionKey]).filter(e=>typeof e==`string`&&e.length>0)),c=j({agentsList:t.agents.state.agentsList,hello:r.hello}),l=ae(n,c),u=E([n],c),d=Ze(n.placement),f=!!(d&&(d.method!==`sessions.reclaim`||n.hasActiveRun!==!0)&&L(r,d.method)===!0);return N`
      <openclaw-session-menu
        .session=${{label:a(n.label)??n.key,sessionId:a(n.sessionId)??null,pinned:n.pinned===!0,unread:n.unread===!0,archived:n.archived===!0,category:a(n.category)??null,icon:a(n.icon)??null,color:a(n.color)??null,categoryClearReturnsToGroups:!1}}
        .anchor=${e}
        .trigger=${this.sessionMenuTrigger}
        .disabled=${this.loading}
        .actionDisabledReasons=${Tt({snapshot:r,session:n,cloudWorkerStopAction:d})}
        .forkDisabled=${n.modelSelectionLocked===!0}
        .forkFromLastCompleted=${n.hasActiveRun===!0}
        .archiveAllowed=${l}
        .deleteAllowed=${u}
        .cloudWorkerStopAllowed=${f}
        .groups=${this.knownCategories()}
        .work=${this.sessionMenuWork}
        .workboard=${i&&n.kind!==`global`?{captured:s.has(n.key),busy:o.capturingSessionKeys.has(n.key)}:null}
        .onClose=${()=>this.closeSessionMenu()}
        .onAction=${e=>{switch(e.kind){case`open-pr`:gt(e.url);break;case`open-in`:St(e.editor,e.path);break;case`copy-session-id`:ue(n.sessionId??``).then(e=>{h({message:I(e?`common.copied`:`common.copyFailed`)})});break;case`toggle-pin`:this.patchSession(n.key,{pinned:n.pinned!==!0});break;case`toggle-unread`:this.patchSession(n.key,{unread:n.unread!==!0});break;case`rename`:this.renameSession(n);break;case`set-color`:this.patchSession(n.key,{color:e.color});break;case`set-icon`:this.patchSession(n.key,{icon:e.icon});break;case`fork`:this.forkSession(n.key,n.hasActiveRun===!0);break;case`workboard`:this.addToWorkboard(n);break;case`move-to-group`:this.assignCategory(n.key,e.category);break;case`new-group`:this.requestNewCategory(n.key);break;case`toggle-archived`:n.archived===!0?this.patchSession(n.key,{archived:!1},void 0,n.sessionId):this.archiveSessionWithUndo(n);break;case`assign-owner`:this.context?.sessions.assignOwner(n.key,e.owner);break;case`stop-cloud-worker`:this.stopCloudWorker(n);break;case`delete`:this.deleteSessionFromMenu(n)}}}
      ></openclaw-session-menu>
    `}render(){let e=this.context,t=(this.result?.owners?.length??0)>1;return e?N`
      ${Kt({active:`sessions`,title:Oe(`sessions`),subtitle:N`${je(`sessions`)} ${at(qn)}`,actions:Ht({agents:e.agents.state.agentsList?.agents??[],selection:e.agentSelection}),onSelect:t=>{t!==`sessions`&&e.navigate(t)}})}
      ${It(An({loading:this.loading,result:this.result,error:this.error,activeMinutes:this.activeMinutes,limit:this.limit,includeGlobal:this.includeGlobal,includeUnknown:this.includeUnknown,statusFilter:this.statusFilter,basePath:e.basePath,agentId:_(e),mainKey:j({agentsList:e.agents.state.agentsList,hello:e.gateway.snapshot.hello}),searchQuery:this.searchQuery,transcriptSearchAvailable:L(e.gateway.snapshot,`sessions.search`)===!0,transcriptSearchQuery:this.transcriptSearchQuery,transcriptSearch:this.transcriptSearchTask.status===Ke.PENDING?{status:`loading`}:this.transcriptSearch,agentIdentityById:Yt(this.result,t=>e.agentIdentity.get(t)??void 0),sortColumn:this.sortColumn,sortDir:this.sortDir,groupBy:t||this.groupBy!==`person`?this.groupBy:`none`,personGroupingAvailable:t,knownCategories:this.knownCategories(),page:this.page,pageSize:this.pageSize,selectedKeys:this.selectedKeys,sessionMenu:this.sessionMenu,expandedSessionKey:this.expandedSessionKey,checkpointItemsByKey:this.checkpointItemsByKey,checkpointLoadingKey:this.checkpointLoadingKey,checkpointBusyKey:this.checkpointBusyKey,checkpointErrorByKey:this.checkpointErrorByKey,patchWriteDisabledReason:this.mutationDisabledReason({method:`sessions.patch`,params:{key:``,label:null}}),patchAdminDisabledReason:this.mutationDisabledReason({method:`sessions.patch`,params:{key:``,thinkingLevel:null}}),groupWriteDisabledReason:this.mutationDisabledReason({method:`sessions.groups.put`,requiredScope:`operator.write`}),deleteArchivedDisabledReason:this.mutationDisabledReason({method:`sessions.delete`,params:{key:``,archivedOnly:!0,deleteTranscript:!0}}),checkpointBranchDisabledReason:this.mutationDisabledReason({method:`sessions.compaction.branch`,requiredScope:`operator.write`}),checkpointRestoreDisabledReason:this.mutationDisabledReason({method:`sessions.compaction.restore`,requiredScope:`operator.admin`}),deleteSelectedDisabledReason:this.selectedDeleteDisabledReason(),onFiltersChange:e=>this.updateFilters(e),onClearFilters:()=>{this.activeMinutes=``,this.limit=`50`,this.includeGlobal=!0,this.includeUnknown=!1,this.searchQuery=``,this.page=0,this.selectedKeys=new Set,this.deepLinkSessionKey=null,this.refreshSessionList()},onSearchChange:e=>{this.searchQuery=e,this.page=0,this.selectedKeys=new Set},onTranscriptSearchChange:e=>this.updateTranscriptSearchQuery(e),onTranscriptSearch:()=>void this.runTranscriptSearch(),onClearTranscriptSearch:()=>this.clearTranscriptSearch(),onSortChange:(e,t)=>{this.sortColumn=e,this.sortDir=t,this.page=0},onGroupByChange:e=>this.setGroupBy(e),onAssignCategory:(e,t)=>this.assignCategory(e,t),onRequestNewCategory:e=>void this.requestNewCategory(e),onPageChange:e=>{this.page=e},onPageSizeChange:e=>{this.pageSize=e,this.page=0},onRefresh:()=>void this.refreshSessionList(),onStatusFilterChange:e=>this.updateStatusFilter(e),onDeleteAllArchived:()=>void this.deleteAllArchived(),onPatch:(e,t)=>void this.patchSession(e,t),onToggleSelect:e=>{let t=new Set(this.selectedKeys);t.has(e)?t.delete(e):t.add(e),this.selectedKeys=t},onSelectPage:e=>{this.selectedKeys=new Set([...this.selectedKeys,...e])},onDeselectPage:e=>{let t=new Set(this.selectedKeys);for(let n of e)t.delete(n);this.selectedKeys=t},onDeselectAll:()=>{this.selectedKeys=new Set},onDeleteSelected:()=>void this.deleteSelected(),onNavigateToChat:t=>{let n=l(e,t);e.navigate(n,{...A({context:e,face:n,sessionKey:t,agentId:this.sessionPathAgentId(t,e),preferenceDerivedFace:!0}).options,hash:``})},onOpenSessionMenu:(e,t,n)=>this.openSessionMenu(e,t,n),onToggleDetails:e=>void this.toggleSessionDetails(e),onBranchFromCheckpoint:(e,t)=>void this.branchCheckpoint(e,t),onRestoreCheckpoint:(e,t)=>void this.restoreCheckpoint(e,t)}),{id:`sessions-hub-panel`})}
      ${this.renderSessionMenu()}
    `:N``}async addToWorkboard(e){let t=this.captureRequestScope();if(t)try{await Pt({host:t.workboard,client:t.client,session:e,requestUpdate:()=>{this.isRequestScopeCurrent(t)&&t.workboard.notify()}}),this.isRequestScopeCurrent(t)&&t.context.navigate(`workboard`)}catch(e){this.isRequestScopeCurrent(t)&&(this.error=k(e))}}},i([Ue({context:Fe,subscribe:!0})],$.prototype,`context`,void 0),i([De({attribute:!1})],$.prototype,`routeData`,void 0),i([P()],$.prototype,`result`,void 0),i([P()],$.prototype,`loading`,void 0),i([P()],$.prototype,`error`,void 0),i([P()],$.prototype,`activeMinutes`,void 0),i([P()],$.prototype,`limit`,void 0),i([P()],$.prototype,`includeGlobal`,void 0),i([P()],$.prototype,`includeUnknown`,void 0),i([P()],$.prototype,`statusFilter`,void 0),i([P()],$.prototype,`searchQuery`,void 0),i([P()],$.prototype,`transcriptSearchQuery`,void 0),i([P()],$.prototype,`submittedTranscriptSearchQuery`,void 0),i([P()],$.prototype,`transcriptSearch`,void 0),i([P()],$.prototype,`sortColumn`,void 0),i([P()],$.prototype,`sortDir`,void 0),i([P()],$.prototype,`groupBy`,void 0),i([P()],$.prototype,`page`,void 0),i([P()],$.prototype,`pageSize`,void 0),i([P()],$.prototype,`selectedKeys`,void 0),i([P()],$.prototype,`sessionMenu`,void 0),i([P()],$.prototype,`sessionMenuWork`,void 0),i([P()],$.prototype,`expandedSessionKey`,void 0),i([P()],$.prototype,`checkpointItemsByKey`,void 0),i([P()],$.prototype,`checkpointTaskKey`,void 0),i([P()],$.prototype,`checkpointBusyKey`,void 0),i([P()],$.prototype,`checkpointErrorByKey`,void 0),customElements.get(`openclaw-sessions-page`)||customElements.define(`openclaw-sessions-page`,$)})))()}Jn();
//# sourceMappingURL=sessions-page-B7PLe-y3.js.map