Files
mai-bot/dashboard/dist/assets/index-P80u2Mbr.js

2 lines
25 KiB
JavaScript

import{j as e,r as o,R as Ie}from"./router-zNjPR4CY.js";import{x as _,D as Q,i as X,j as Y,k as Z,l as ee,a5 as se,L as m,a3 as te,B as h,E as ae,I as M,A as he,n as me,o as ue,q as je,r as ge,s as pe,t as fe,v as ve,g as Le,S as Be}from"./index-CuOHsLf7.js";import{S as A,a as O,b as P,c as $,d as p}from"./select-DGqIoF9r.js";import{B as C}from"./badge-CDs67obV.js";import{M as Me}from"./markdown-renderer-CrKRiZ7X.js";import{S as Ne}from"./switch-Kc2EZ0Ga.js";import{T as we}from"./textarea-8PIujbf-.js";import{o as Re,J as ce,au as de,a0 as oe,v as K,ap as Ve,G as He,y as qe,aq as Ge,b as be,X as _e,Y as Ue,az as We,w as Ke,S as Qe}from"./icons-DTcdLw9j.js";import{C as U}from"./checkbox-DWiVrbnx.js";import{T as Xe,a as Ye,b as B,c as E,d as Ze,e as b}from"./table-DFeDhBY_.js";import"./misc-BwRzHX8c.js";import"./radix-C-ZuImoP.js";import"./utils-DjBw3JGv.js";import"./markdown-6e5N06bH.js";const y="/api/webui/jargon";async function es(){const s=await _(`${y}/chats`,{});if(!s.ok){const t=await s.json();throw new Error(t.detail||"获取聊天列表失败")}return s.json()}async function ss(s){const t=new URLSearchParams;s.page&&t.append("page",s.page.toString()),s.page_size&&t.append("page_size",s.page_size.toString()),s.search&&t.append("search",s.search),s.chat_id&&t.append("chat_id",s.chat_id),s.is_jargon!==void 0&&s.is_jargon!==null&&t.append("is_jargon",s.is_jargon.toString()),s.is_global!==void 0&&t.append("is_global",s.is_global.toString());const n=await _(`${y}/list?${t}`,{});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取黑话列表失败")}return n.json()}async function ts(s){const t=await _(`${y}/${s}`,{});if(!t.ok){const n=await t.json();throw new Error(n.detail||"获取黑话详情失败")}return t.json()}async function as(s){const t=await _(`${y}/`,{method:"POST",body:JSON.stringify(s)});if(!t.ok){const n=await t.json();throw new Error(n.detail||"创建黑话失败")}return t.json()}async function ns(s,t){const n=await _(`${y}/${s}`,{method:"PATCH",body:JSON.stringify(t)});if(!n.ok){const i=await n.json();throw new Error(i.detail||"更新黑话失败")}return n.json()}async function ls(s){const t=await _(`${y}/${s}`,{method:"DELETE"});if(!t.ok){const n=await t.json();throw new Error(n.detail||"删除黑话失败")}return t.json()}async function is(s){const t=await _(`${y}/batch/delete`,{method:"POST",body:JSON.stringify({ids:s})});if(!t.ok){const n=await t.json();throw new Error(n.detail||"批量删除黑话失败")}return t.json()}async function rs(){const s=await _(`${y}/stats/summary`,{});if(!s.ok){const t=await s.json();throw new Error(t.detail||"获取黑话统计失败")}return s.json()}async function cs(s,t){const n=new URLSearchParams;s.forEach(r=>n.append("ids",r.toString())),n.append("is_jargon",t.toString());const i=await _(`${y}/batch/set-jargon?${n}`,{method:"POST"});if(!i.ok){const r=await i.json();throw new Error(r.detail||"批量设置黑话状态失败")}return i.json()}function W({icon:s,label:t,value:n,mono:i=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(m,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[s&&e.jsx(s,{className:"h-3 w-3"}),t]}),e.jsx("div",{className:Le("text-sm",i&&"font-mono",!n&&"text-muted-foreground"),children:n||"-"})]})}function ds({jargon:s,open:t,onOpenChange:n}){return s?e.jsx(Q,{open:t,onOpenChange:n,children:e.jsxs(X,{className:"max-w-2xl max-h-[80vh] grid grid-rows-[auto_1fr_auto] overflow-hidden",children:[e.jsxs(Y,{children:[e.jsx(Z,{children:"黑话详情"}),e.jsx(ee,{children:"查看黑话的完整信息"})]}),e.jsx(se,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 pb-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(W,{icon:Re,label:"记录ID",value:s.id.toString(),mono:!0}),e.jsx(W,{label:"使用次数",value:s.count.toString()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs text-muted-foreground",children:"内容"}),e.jsx("div",{className:"text-sm p-2 bg-muted rounded break-all whitespace-pre-wrap",children:s.content})]}),s.raw_content&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs text-muted-foreground",children:"原始内容"}),e.jsx("div",{className:"text-sm p-2 bg-muted rounded break-all",children:(()=>{try{const i=JSON.parse(s.raw_content);return Array.isArray(i)?i.map((r,c)=>e.jsxs("div",{children:[c>0&&e.jsx("hr",{className:"my-3 border-border"}),e.jsx("div",{className:"whitespace-pre-wrap",children:r})]},c)):e.jsx("div",{className:"whitespace-pre-wrap",children:s.raw_content})}catch{return e.jsx("div",{className:"whitespace-pre-wrap",children:s.raw_content})}})()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs text-muted-foreground",children:"含义"}),e.jsx("div",{className:"text-sm p-2 bg-muted rounded break-all",children:s.meaning?e.jsx(Me,{content:s.meaning}):"-"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(W,{label:"聊天",value:s.chat_name||s.chat_id}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs text-muted-foreground",children:"状态"}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.is_jargon===!0&&e.jsx(C,{variant:"default",className:"bg-green-600",children:"是黑话"}),s.is_jargon===!1&&e.jsx(C,{variant:"secondary",children:"非黑话"}),s.is_jargon===null&&e.jsx(C,{variant:"outline",children:"未判定"}),s.is_global&&e.jsx(C,{variant:"outline",className:"border-blue-500 text-blue-500",children:"全局"}),s.is_complete&&e.jsx(C,{variant:"outline",className:"border-purple-500 text-purple-500",children:"推断完成"})]})]})]}),s.inference_with_context&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs text-muted-foreground",children:"上下文推断结果"}),e.jsx("div",{className:"p-2 bg-muted rounded break-all whitespace-pre-wrap font-mono text-xs max-h-[200px] overflow-y-auto",children:s.inference_with_context})]}),s.inference_content_only&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(m,{className:"text-xs text-muted-foreground",children:"纯词条推断结果"}),e.jsx("div",{className:"p-2 bg-muted rounded break-all whitespace-pre-wrap font-mono text-xs max-h-[200px] overflow-y-auto",children:s.inference_content_only})]})]})}),e.jsx(te,{className:"flex-shrink-0",children:e.jsx(h,{onClick:()=>n(!1),children:"关闭"})})]})}):null}function os({open:s,onOpenChange:t,chatList:n,onSuccess:i}){const[r,c]=o.useState({content:"",meaning:"",chat_id:"",is_global:!1}),[u,f]=o.useState(!1),{toast:g}=ae(),N=async()=>{if(!r.content||!r.chat_id){g({title:"验证失败",description:"请填写必填字段:内容和聊天",variant:"destructive"});return}try{f(!0),await as(r),g({title:"创建成功",description:"黑话已创建"}),c({content:"",meaning:"",chat_id:"",is_global:!1}),i()}catch(x){g({title:"创建失败",description:x instanceof Error?x.message:"无法创建黑话",variant:"destructive"})}finally{f(!1)}};return e.jsx(Q,{open:s,onOpenChange:t,children:e.jsxs(X,{className:"max-w-2xl",confirmOnEnter:!0,children:[e.jsxs(Y,{children:[e.jsx(Z,{children:"新增黑话"}),e.jsx(ee,{children:"创建新的黑话记录"})]}),e.jsx(se,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(m,{htmlFor:"content",children:["内容 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(M,{id:"content",value:r.content,onChange:x=>c({...r,content:x.target.value}),placeholder:"输入黑话内容"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"meaning",children:"含义"}),e.jsx(we,{id:"meaning",value:r.meaning||"",onChange:x=>c({...r,meaning:x.target.value}),placeholder:"输入黑话含义(可选)",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(m,{htmlFor:"chat_id",children:["聊天 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(A,{value:r.chat_id,onValueChange:x=>c({...r,chat_id:x}),children:[e.jsx(O,{children:e.jsx(P,{placeholder:"选择关联的聊天"})}),e.jsx($,{children:n.map(x=>e.jsx(p,{value:x.chat_id,children:x.chat_name},x.chat_id))})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ne,{id:"is_global",checked:r.is_global,onCheckedChange:x=>c({...r,is_global:x})}),e.jsx(m,{htmlFor:"is_global",children:"设为全局黑话"})]})]})}),e.jsxs(te,{children:[e.jsx(h,{variant:"outline",onClick:()=>t(!1),children:"取消"}),e.jsx(h,{"data-dialog-action":"confirm",onClick:N,disabled:u,children:u?"创建中...":"创建"})]})]})})}function xs({jargon:s,open:t,onOpenChange:n,chatList:i,onSuccess:r}){const[c,u]=o.useState({}),[f,g]=o.useState(!1),{toast:N}=ae();o.useEffect(()=>{s&&u({content:s.content,meaning:s.meaning||"",chat_id:s.stream_id||s.chat_id,is_global:s.is_global,is_jargon:s.is_jargon})},[s]);const x=async()=>{if(s)try{g(!0),await ns(s.id,c),N({title:"保存成功",description:"黑话已更新"}),r()}catch(d){N({title:"保存失败",description:d instanceof Error?d.message:"无法更新黑话",variant:"destructive"})}finally{g(!1)}};return s?e.jsx(Q,{open:t,onOpenChange:n,children:e.jsxs(X,{className:"max-w-2xl",confirmOnEnter:!0,children:[e.jsxs(Y,{children:[e.jsx(Z,{children:"编辑黑话"}),e.jsx(ee,{children:"修改黑话的信息"})]}),e.jsx(se,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"edit_content",children:"内容"}),e.jsx(M,{id:"edit_content",value:c.content||"",onChange:d=>u({...c,content:d.target.value}),placeholder:"输入黑话内容"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"edit_meaning",children:"含义"}),e.jsx(we,{id:"edit_meaning",value:c.meaning||"",onChange:d=>u({...c,meaning:d.target.value}),placeholder:"输入黑话含义",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"edit_chat_id",children:"聊天"}),e.jsxs(A,{value:c.chat_id||"",onValueChange:d=>u({...c,chat_id:d}),children:[e.jsx(O,{children:e.jsx(P,{placeholder:"选择关联的聊天"})}),e.jsx($,{children:i.map(d=>e.jsx(p,{value:d.chat_id,children:d.chat_name},d.chat_id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"黑话状态"}),e.jsxs(A,{value:c.is_jargon===null?"null":c.is_jargon?.toString()||"null",onValueChange:d=>u({...c,is_jargon:d==="null"?null:d==="true"}),children:[e.jsx(O,{children:e.jsx(P,{})}),e.jsxs($,{children:[e.jsx(p,{value:"null",children:"未判定"}),e.jsx(p,{value:"true",children:"是黑话"}),e.jsx(p,{value:"false",children:"非黑话"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ne,{id:"edit_is_global",checked:c.is_global,onCheckedChange:d=>u({...c,is_global:d})}),e.jsx(m,{htmlFor:"edit_is_global",children:"全局黑话"})]})]})}),e.jsxs(te,{children:[e.jsx(h,{variant:"outline",onClick:()=>n(!1),children:"取消"}),e.jsx(h,{"data-dialog-action":"confirm",onClick:x,disabled:f,children:f?"保存中...":"保存"})]})]})}):null}function hs({jargon:s,open:t,onOpenChange:n,onConfirm:i}){return e.jsx(he,{open:t,onOpenChange:n,children:e.jsxs(me,{children:[e.jsxs(ue,{children:[e.jsx(je,{children:"确认删除"}),e.jsxs(ge,{children:['确定要删除黑话 "',s?.content,'" 吗?此操作不可撤销。']})]}),e.jsxs(pe,{children:[e.jsx(fe,{children:"取消"}),e.jsx(ve,{onClick:i,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})})}function ms({open:s,onOpenChange:t,onConfirm:n,count:i}){return e.jsx(he,{open:s,onOpenChange:t,children:e.jsxs(me,{children:[e.jsxs(ue,{children:[e.jsx(je,{children:"确认批量删除"}),e.jsxs(ge,{children:["您即将删除 ",i," 个黑话,此操作无法撤销。确定要继续吗?"]})]}),e.jsxs(pe,{children:[e.jsx(fe,{children:"取消"}),e.jsx(ve,{onClick:n,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})})}function xe(s){return s===!0?e.jsxs(C,{variant:"default",className:"bg-green-600 hover:bg-green-700",children:[e.jsx(be,{className:"h-3 w-3 mr-1"}),"是黑话"]}):s===!1?e.jsxs(C,{variant:"secondary",children:[e.jsx(_e,{className:"h-3 w-3 mr-1"}),"非黑话"]}):e.jsxs(C,{variant:"outline",children:[e.jsx(Ue,{className:"h-3 w-3 mr-1"}),"未判定"]})}function us({jargons:s,loading:t,total:n,page:i,pageSize:r,selectedIds:c,onEdit:u,onViewDetail:f,onDelete:g,onToggleSelect:N,onToggleSelectAll:x,onPageChange:d,onJumpToPage:J}){const[F,S]=Ie.useState(""),L=()=>{J(F),S("")};return e.jsxs("div",{className:"rounded-lg border bg-card",children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(Xe,{"aria-label":"黑话列表",children:[e.jsx(Ye,{children:e.jsxs(B,{children:[e.jsx(E,{className:"w-12",children:e.jsx(U,{checked:c.size===s.length&&s.length>0,onCheckedChange:x})}),e.jsx(E,{children:"内容"}),e.jsx(E,{children:"含义"}),e.jsx(E,{children:"聊天"}),e.jsx(E,{children:"状态"}),e.jsx(E,{className:"text-center",children:"次数"}),e.jsx(E,{className:"text-right",children:"操作"})]})}),e.jsx(Ze,{children:t?e.jsx(B,{children:e.jsx(b,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):s.length===0?e.jsx(B,{children:e.jsx(b,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):s.map(l=>e.jsxs(B,{children:[e.jsx(b,{children:e.jsx(U,{checked:c.has(l.id),onCheckedChange:()=>N(l.id)})}),e.jsx(b,{className:"font-medium max-w-[200px]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[l.is_global&&e.jsx("span",{title:"全局黑话",children:e.jsx(ce,{className:"h-4 w-4 text-blue-500 flex-shrink-0"})}),e.jsx("span",{className:"truncate",title:l.content,children:l.content})]})}),e.jsx(b,{className:"max-w-[200px] truncate",title:l.meaning||"",children:l.meaning||e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(b,{className:"max-w-[150px] truncate",title:l.chat_name||l.chat_id,children:l.chat_name||l.chat_id}),e.jsx(b,{children:xe(l.is_jargon)}),e.jsx(b,{className:"text-center",children:l.count}),e.jsx(b,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(h,{variant:"default",size:"sm",onClick:()=>u(l),children:[e.jsx(de,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(h,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>f(l),title:"查看详情",children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsxs(h,{size:"sm",onClick:()=>g(l),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(K,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},l.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:t?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):s.map(l=>e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(U,{checked:c.has(l.id),onCheckedChange:()=>N(l.id),className:"mt-1"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l.is_global&&e.jsx(ce,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}),e.jsx("h3",{className:"font-semibold text-sm break-all",children:l.content})]}),l.meaning&&e.jsx("p",{className:"text-sm text-muted-foreground break-all",children:l.meaning}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[xe(l.is_jargon),e.jsxs("span",{className:"text-muted-foreground",children:["次数: ",l.count]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:["聊天: ",l.chat_name||l.chat_id]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t",children:[e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>u(l),className:"text-xs px-2 py-1 h-auto",children:[e.jsx(de,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(h,{variant:"outline",size:"sm",onClick:()=>f(l),className:"text-xs px-2 py-1 h-auto",children:e.jsx(oe,{className:"h-3 w-3"})}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>g(l),className:"text-xs px-2 py-1 h-auto text-destructive hover:text-destructive",children:[e.jsx(K,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},l.id))}),n>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 px-4 py-3 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共 ",n," 条记录,第 ",i," / ",Math.ceil(n/r)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{variant:"outline",size:"sm",onClick:()=>d(1),disabled:i===1,className:"hidden sm:flex",children:e.jsx(Ve,{className:"h-4 w-4"})}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>d(i-1),disabled:i===1,children:[e.jsx(He,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{type:"number",value:F,onChange:l=>S(l.target.value),onKeyDown:l=>l.key==="Enter"&&L(),placeholder:i.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(n/r)}),e.jsx(h,{variant:"outline",size:"sm",onClick:L,disabled:!F,className:"h-8",children:"跳转"})]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>d(i+1),disabled:i>=Math.ceil(n/r),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(qe,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(h,{variant:"outline",size:"sm",onClick:()=>d(Math.ceil(n/r)),disabled:i>=Math.ceil(n/r),className:"hidden sm:flex",children:e.jsx(Ge,{className:"h-4 w-4"})})]})]})]})}function Es(){const[s,t]=o.useState([]),[n,i]=o.useState(!0),[r,c]=o.useState(0),[u,f]=o.useState(1),[g,N]=o.useState(20),[x,d]=o.useState(""),[J,F]=o.useState("all"),[S,L]=o.useState("all"),[l,ne]=o.useState(null),[ye,le]=o.useState(!1),[Se,R]=o.useState(!1),[Ce,V]=o.useState(!1),[I,H]=o.useState(null),[v,k]=o.useState(new Set),[ke,q]=o.useState(!1),[D,De]=o.useState({total:0,confirmed_jargon:0,confirmed_not_jargon:0,pending:0,global_count:0,complete_count:0,chat_count:0,top_chats:{}}),[G,Ee]=o.useState([]),{toast:w}=ae(),z=async()=>{try{i(!0);const a=await ss({page:u,page_size:g,search:x||void 0,chat_id:J==="all"?void 0:J,is_jargon:S==="all"?void 0:S==="true"?!0:S==="false"?!1:void 0});t(a.data),c(a.total)}catch(a){w({title:"加载失败",description:a instanceof Error?a.message:"无法加载黑话列表",variant:"destructive"})}finally{i(!1)}},T=async()=>{try{const a=await rs();a?.data&&De(a.data)}catch(a){console.error("加载统计数据失败:",a)}},Je=async()=>{try{const a=await es();a?.data&&Ee(a.data)}catch(a){console.error("加载聊天列表失败:",a)}};o.useEffect(()=>{z(),T(),Je()},[u,g,x,J,S]);const ze=async a=>{try{const j=await ts(a.id);ne(j.data),le(!0)}catch(j){w({title:"加载详情失败",description:j instanceof Error?j.message:"无法加载黑话详情",variant:"destructive"})}},Te=a=>{ne(a),R(!0)},Ae=async()=>{if(I)try{await ls(I.id),w({title:"删除成功",description:`已删除黑话: ${I.content}`}),H(null),z(),T()}catch(a){w({title:"删除失败",description:a instanceof Error?a.message:"无法删除黑话",variant:"destructive"})}},Oe=a=>{const j=new Set(v);j.has(a)?j.delete(a):j.add(a),k(j)},Pe=()=>{v.size===s.length&&s.length>0?k(new Set):k(new Set(s.map(a=>a.id)))},$e=async()=>{try{await is(Array.from(v)),w({title:"批量删除成功",description:`已删除 ${v.size} 个黑话`}),k(new Set),q(!1),z(),T()}catch(a){w({title:"批量删除失败",description:a instanceof Error?a.message:"无法批量删除黑话",variant:"destructive"})}},ie=async a=>{try{await cs(Array.from(v),a),w({title:"操作成功",description:`已将 ${v.size} 个词条设为${a?"黑话":"非黑话"}`}),k(new Set),z(),T()}catch(j){w({title:"操作失败",description:j instanceof Error?j.message:"批量设置失败",variant:"destructive"})}},Fe=a=>{const j=parseInt(a),re=Math.ceil(r/g);j>=1&&j<=re?f(j):w({title:"无效的页码",description:`请输入1-${re}之间的页码`,variant:"destructive"})};return e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsx("div",{className:"mb-4 sm:mb-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(We,{className:"h-8 w-8",strokeWidth:2}),"黑话"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦学习到的黑话和俗语"})]}),e.jsxs(h,{onClick:()=>V(!0),className:"gap-2",children:[e.jsx(Ke,{className:"h-4 w-4"}),"新增黑话"]})]})}),e.jsx(Be,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-7 gap-3",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"总数量"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1",children:D.total})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"已确认黑话"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-green-600",children:D.confirmed_jargon})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"确认非黑话"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-gray-500",children:D.confirmed_not_jargon})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"待判定"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-yellow-600",children:D.pending})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"全局黑话"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-blue-600",children:D.global_count})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"推断完成"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-purple-600",children:D.complete_count})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"关联聊天数"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1",children:D.chat_count})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{htmlFor:"search",children:"搜索"}),e.jsxs("div",{className:"relative",children:[e.jsx(Qe,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(M,{id:"search",placeholder:"搜索内容、含义...",value:x,onChange:a=>d(a.target.value),className:"pl-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{children:"聊天筛选"}),e.jsxs(A,{value:J,onValueChange:F,children:[e.jsx(O,{children:e.jsx(P,{placeholder:"全部聊天"})}),e.jsxs($,{children:[e.jsx(p,{value:"all",children:"全部聊天"}),G.map(a=>e.jsx(p,{value:a.chat_id,children:a.chat_name},a.chat_id))]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{children:"状态筛选"}),e.jsxs(A,{value:S,onValueChange:L,children:[e.jsx(O,{children:e.jsx(P,{placeholder:"全部状态"})}),e.jsxs($,{children:[e.jsx(p,{value:"all",children:"全部状态"}),e.jsx(p,{value:"true",children:"是黑话"}),e.jsx(p,{value:"false",children:"非黑话"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{htmlFor:"page-size",children:"每页显示"}),e.jsxs(A,{value:g.toString(),onValueChange:a=>{N(parseInt(a)),f(1),k(new Set)},children:[e.jsx(O,{id:"page-size",children:e.jsx(P,{})}),e.jsxs($,{children:[e.jsx(p,{value:"10",children:"10"}),e.jsx(p,{value:"20",children:"20"}),e.jsx(p,{value:"50",children:"50"}),e.jsx(p,{value:"100",children:"100"})]})]})]})]}),v.size>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-4 pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:["已选择 ",v.size," 个"]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>ie(!0),children:[e.jsx(be,{className:"h-4 w-4 mr-1"}),"标记为黑话"]}),e.jsxs(h,{variant:"outline",size:"sm",onClick:()=>ie(!1),children:[e.jsx(_e,{className:"h-4 w-4 mr-1"}),"标记为非黑话"]}),e.jsx(h,{variant:"outline",size:"sm",onClick:()=>k(new Set),children:"取消选择"}),e.jsxs(h,{variant:"destructive",size:"sm",onClick:()=>q(!0),children:[e.jsx(K,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]}),e.jsx(us,{jargons:s,loading:n,total:r,page:u,pageSize:g,selectedIds:v,onEdit:Te,onViewDetail:ze,onDelete:a=>H(a),onToggleSelect:Oe,onToggleSelectAll:Pe,onPageChange:f,onJumpToPage:Fe})]})}),e.jsx(ds,{jargon:l,open:ye,onOpenChange:le}),e.jsx(os,{open:Ce,onOpenChange:V,chatList:G,onSuccess:()=>{z(),T(),V(!1)}}),e.jsx(xs,{jargon:l,open:Se,onOpenChange:R,chatList:G,onSuccess:()=>{z(),T(),R(!1)}}),e.jsx(hs,{jargon:I,open:!!I,onOpenChange:()=>H(null),onConfirm:Ae}),e.jsx(ms,{open:ke,onOpenChange:q,onConfirm:$e,count:v.size})]})}export{Es as JargonManagementPage};