import{i as e,n as t}from"./lit-Cl9PTnWs.js";import{r as n}from"./i18n-Ber8EPgj.js";import{a as r,i,r as a,t as o}from"./cognitive-shared-hZ0I1rin.js";function s(e){if(!e)return`-`;let t=Math.floor((Date.now()-e)/1e3);return t<60?`刚刚`:t<3600?`${Math.floor(t/60)}分钟前`:t<86400?`${Math.floor(t/3600)}小时前`:`${Math.floor(t/86400)}天前`}function c(e){switch(e){case`scheduled`:return`定时`;case`event`:return`事件`;case`conversational`:return`对话`;default:return e}}function l(e){switch(e){case`positive`:return`color: #22c55e; border-color: rgba(34,197,94,0.3); background: rgba(34,197,94,0.08);`;case`negative`:return`color: #ef4444; border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.08);`;case`neutral`:return`color: #eab308; border-color: rgba(234,179,8,0.3); background: rgba(234,179,8,0.08);`;case`engaged`:return`color: #3b82f6; border-color: rgba(59,130,246,0.3); background: rgba(59,130,246,0.08);`;default:return`color: var(--muted);`}}function u(e){switch(e){case`positive`:return`正面`;case`negative`:return`负面`;case`neutral`:return`中立`;case`engaged`:return`互动`;default:return`无反馈`}}function d(e){return e.promptVariant?.patternFrame==null?`knowledge`:`pattern`}function f(e){return e===`pattern`?`行为模式`:`知识`}function p(n,r){let i=d(n);return e`
    <div class="card" style="animation-delay: 0s;">
      <!-- Header row: mode + trigger + time -->
      <div class="row" style="margin-bottom: 10px; flex-wrap: wrap;">
        <span
          class="pill"
          style="font-size: 12px; padding: 3px 8px;"
          title=${i===`pattern`?`行为模式洞察`:`知识洞察`}
        >
          ${f(i)}
        </span>
        <span class="pill" style="font-size: 12px; padding: 3px 8px;">
          ${c(n.triggerSource)}
        </span>
        <span style="font-size: 13px; color: var(--muted); margin-left: auto;">
          ${s(n.generatedAt)}
        </span>
      </div>

      <!-- Content -->
      <div style="font-size: 15px; line-height: 1.6; margin-bottom: 12px; white-space: pre-wrap;">
        ${n.content}
      </div>

      <!-- Target domains -->
      ${n.targetDomains.length>0?e`
            <div class="row" style="flex-wrap: wrap; gap: 6px; margin-bottom: 10px;">
              ${n.targetDomains.map(t=>e`<span class="pill" style="font-size: 12px; padding: 2px 8px;">${t}</span>`)}
            </div>
          `:t}

      <!-- Sources -->
      ${n.sources.length>0?e`
            <div style="margin-bottom: 10px;">
              <span style="font-size: 12px; color: var(--muted);">来源：</span>
              ${n.sources.map(t=>e`<a
                    href=${t.url}
                    target="_blank"
                    rel="noopener noreferrer"
                    style="font-size: 12px; margin-left: 6px; text-decoration: underline; color: var(--info);"
                    >${t.title}</a
                  >`)}
            </div>
          `:t}

      <!-- Footer: feedback pill + thumbs -->
      <div class="row" style="margin-top: 8px; flex-wrap: wrap; gap: 8px;">
        <span
          class="pill"
          style="font-size: 12px; padding: 3px 8px; ${l(n.feedback)}"
        >
          ${u(n.feedback)}
        </span>
        <span style="flex: 1;"></span>
        <button
          class="btn btn--sm"
          style=${n.feedback===`positive`?`color: #22c55e; border-color: rgba(34,197,94,0.4);`:``}
          title="正面反馈"
          @click=${()=>r(n.id,`positive`)}
        >
          👍
        </button>
        <button
          class="btn btn--sm"
          style=${n.feedback===`negative`?`color: #ef4444; border-color: rgba(239,68,68,0.4);`:``}
          title="负面反馈"
          @click=${()=>r(n.id,`negative`)}
        >
          👎
        </button>
      </div>
    </div>
  `}function m(t){if(t.loading)return e`<div class="page-loader">${n(`common.loading`)}</div>`;if(t.error)return e`<div class="callout danger">${t.error}</div>`;let s=o(t.personaList);if(!s||s.agents.length===0)return e`
      <section class="stack">
        <div class="card">
          <div class="card-title">${n(`tabs.insights`)}</div>
          <div class="callout info">暂无用户画像数据。先与机器人对话后，画像会自动生成。</div>
        </div>
      </section>
    `;let c=t.insights,l=t.agentId&&t.userId,u;return u=l?c.length===0?e`<div class="callout info">该用户暂无洞察记录。</div>`:e`
      <div class="stack">${c.map(e=>p(e,t.onFeedback))}</div>
    `:a(`请选择一个用户查看洞察`,`点击左侧用户卡片查看洞察记录。`),i(r({list:s,selectedUserId:t.userId,selectedAgentId:t.agentId,onUserSelect:t.onUserSelect,onRefresh:t.onRefresh,headerTitle:`用户`}),u)}export{m as renderInsights};
//# sourceMappingURL=insights-C2nYxwFJ.js.map