import{i as e}from"./lit-Cl9PTnWs.js";import{r as t}from"./i18n-Ber8EPgj.js";import{a as n,i as r,r as i,t as a}from"./cognitive-shared-hZ0I1rin.js";var o=90,s=864e5;function c(e){let n=Date.now()-e;if(n<0)return t(`common.justNow`)??`刚刚`;let r=Math.floor(n/6e4);if(r<1)return t(`common.justNow`)??`刚刚`;if(r<60)return`${r}分钟前`;let i=Math.floor(r/60);if(i<24)return`${i}小时前`;let a=Math.floor(i/24);return a<30?`${a}天前`:`${Math.floor(a/30)}个月前`}function l(e){let t=(Date.now()-e)/s;return Math.max(0,Math.round(o-t))}function u(t){return e`<span class="pill ${t===`self`?`info`:`warning`}">${t===`self`?`Agent`:`用户`}</span>`}function d(t){let n=l(t.createdAt),r=n<=7?`danger`:n<=30?`warning`:``;return e`
    <div class="card" style="padding: 12px;">
      <div style="display:flex; align-items:center; gap:8px; margin-bottom:8px; flex-wrap:wrap;">
        <span class="pill">${t.domain}</span>
        ${u(t.provenance)}
        <span
          class="pill ${t.reinforcedCount>2?`danger`:``}"
          style="font-weight:${t.reinforcedCount>2?`700`:`400`};"
        >
          ×${t.reinforcedCount}
        </span>
        ${r?e`<span class="pill ${r}">TTL ${n}天</span>`:e`<span class="pill" style="opacity:0.6;">TTL ${n}天</span>`}
      </div>
      <div style="margin-bottom:6px;">
        <strong>触发：</strong>
        <span class="text-muted">${t.trigger}</span>
      </div>
      <div class="callout danger" style="margin-bottom:6px; padding:6px 10px;">
        <strong>错误：</strong> ${t.mistake}
      </div>
      <div class="callout success" style="margin-bottom:6px; padding:6px 10px;">
        <strong>纠正：</strong> ${t.correction}
      </div>
      <div class="text-muted" style="font-size:0.85em;">
        创建于 ${c(t.createdAt)} · 上次强化于 ${c(t.lastReinforced)}
      </div>
    </div>
  `}function f(o){if(o.loading)return e`<div class="page-loader">${t(`common.loading`)}</div>`;if(o.error)return e`<div class="callout danger">${o.error}</div>`;let s=a(o.personaList);if(!s||s.agents.length===0)return e`
      <div class="card" style="padding:24px;text-align:center;">
        <div class="muted">暂无用户数据。先与机器人对话后，画像会自动生成。</div>
      </div>
    `;let c=o.corrections.toSorted((e,t)=>t.reinforcedCount-e.reinforcedCount),l=n({list:s,selectedUserId:o.userId,selectedAgentId:o.agentId,onUserSelect:o.onUserSelect,onRefresh:o.onRefresh,headerTitle:`用户`}),u;return u=o.userId?c.length===0?e`
      <div style="display:flex;flex-direction:column;gap:8px;">
        <div class="row" style="justify-content:space-between;align-items:center;">
          <h3 style="font-size:16px;font-weight:600;margin:0;">${t(`tabs.corrections`)}</h3>
        </div>
        <div class="callout info">暂无纠错记录。</div>
      </div>
    `:e`
      <div style="display:flex;flex-direction:column;gap:8px;">
        <div class="row" style="justify-content:space-between;align-items:center;">
          <h3 style="font-size:16px;font-weight:600;margin:0;">${t(`tabs.corrections`)}</h3>
          <span class="text-muted">${c.length} 条记录</span>
        </div>
        <div class="stack">${c.map(e=>d(e))}</div>
      </div>
    `:i(`请选择一个用户查看纠错记录`,`点击左侧用户卡片查看纠错历史。`),r(l,u)}export{f as renderCorrections};
//# sourceMappingURL=corrections-Tkmz83_U.js.map