1import{r as e}from"./rolldown-runtime-DdACKOZr.js";import{T as s}from"./antd-Dfc2fGnp.js";import{r as t}from"./markdown-ArMu7oCU.js";import{c as r,o as a,s as l}from"./vendor-DvieLQTP.js";import{t as n}from"./building-2-vgkJsr2p.js";import{t as d}from"./chart-no-axes-column-CENLB3-p.js";import{t as o}from"./check-B98-ea8B.js";import{t as i}from"./circle-alert-DSJ662QQ.js";import{t as c}from"./circle-check-big-CXnF35dW.js";import{t as x}from"./circle-x-SPLkvgEp.js";import{t as m}from"./copy-BFXhXxkd.js";import{t as u}from"./external-link-Dv9JZEAR.js";import{t as b}from"./file-text-DCMBsAk5.js";import{t as p}from"./globe-C9Q4Mr_S.js";import{n as h,t as g}from"./link-DHM8m1ft.js";import{t as f}from"./layout-template-BY79V0Bu.js";import{t as y}from"./log-out-DSzw4Ew4.js";import{n as j,t as N}from"./settings-DukBW88F.js";import{t as v}from"./refresh-cw-OsgusxNu.js";import{t as w}from"./share-2-90og7S2T.js";import{t as k}from"./shield-Ci0sQ-5Z.js";import{t as _}from"./shopping-cart-CRZxtWHy.js";import{t as C}from"./square-check-big-DsvbUy5x.js";import{t as S}from"./trash-2-DWG5ADmU.js";import{t as z}from"./triangle-alert-DiO63X6L.js";import{t as A}from"./user-6kph8TcY.js";import{t as D}from"./users-d090TQ2q.js";import"./aiService-DtoVekQH.js";import{t as E}from"./request-5RU1Tr6b.js";import{K as I}from"./accountService-B5BrnMiu.js";import{n as T}from"./urlUtils-CrtweBf7.js";import{n as P,s as q}from"./orderService-CM4OMCAr.js";import{n as L,t as $}from"./SecondaryAccountManager-CdEsRROD.js";import{n as B,t as U}from"./TenantStatsPanel-BbnlpHuy.js";var F=e(s(),1),K=t();function M({showToast:e}){const s=s=>e?e(s):alert(s),[t,r]=(0,F.useState)([]),[a,l]=(0,F.useState)([]),[n,d]=(0,F.useState)(!1),[i,u]=(0,F.useState)(!1),[b,p]=(0,F.useState)(!1),[g,f]=(0,F.useState)(null),[y,N]=(0,F.useState)(null),[w,_]=(0,F.useState)(null),[C,A]=(0,F.useState)(1),[D,I]=(0,F.useState)({provider:"deepseek",display_name:"",api_key:"",model:"",base_url:"",is_default:!1,remark:""});(0,F.useEffect)(()=>{T(),P()},[]);const T=async()=>{try{const e=await E("/ai-config/providers");e.success&&l(e.data||[])}catch(e){console.error("å è½½æä¾åå表失败:",e)}},P=async()=>{d(!0);try{const e=await E("/ai-config/");e.success?(r(e.data||[]),u(!1)):(u(!0),s(e.error||"å è½½é
置失败"))}catch(e){console.error("å è½½é
置失败:",e),u(!0),s("ç½ç»éè¯¯ï¼æ æ³å è½½é
ç½®")}finally{d(!1)}},q=a.find(e=>e.provider===D.provider);return(0,K.jsxs)("div",{className:"space-y-6",children:[(0,K.jsxs)("div",{className:"bg-blue-50 border border-blue-200 rounded-xl px-4 py-3 flex items-start gap-3",children:[(0,K.jsx)(k,{size:18,className:"text-blue-500 mt-0.5 shrink-0"}),(0,K.jsxs)("div",{className:"text-sm text-blue-700",children:[(0,K.jsx)("span",{className:"font-bold",children:"API Key å®å
¨å å¯åå¨"}),"- æ¨ç API Key ä¼è¢«å å¯åå¨å¨æ°æ®åºä¸ï¼å端 bundle ä¸ä¸åæ´é²ä»»ä½ç¬¬ä¸æ¹ AI å¹³å°çå¯é¥ã AI 请æ±éè¿å端代ç转åï¼ä¿éå¯é¥å®å
¨ã"]})]}),i&&(0,K.jsxs)("div",{className:"bg-amber-50 border border-amber-200 rounded-xl px-4 py-3 flex items-center justify-between gap-3",children:[(0,K.jsxs)("div",{className:"flex items-start gap-3",children:[(0,K.jsx)(z,{size:18,className:"text-amber-500 mt-0.5 shrink-0"}),(0,K.jsxs)("div",{className:"text-sm text-amber-800",children:[(0,K.jsx)("span",{className:"font-bold",children:"é
ç½®å 载失败"}),' - å½åå表å¯è½ä¸å®æ´,请å
ç¹å»"éè¯"å 载已æé
ç½®åååå¢å æ¹,é¿å
误æä½ã']})]}),(0,K.jsx)("button",{onClick:P,className:"px-3 py-1.5 text-sm bg-amber-500 hover:bg-amber-600 text-white rounded-lg font-medium shrink-0",children:"éè¯å è½½"})]}),(0,K.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[{label:"æ»é
ç½®æ°",value:t.length,color:"bg-blue-50 text-blue-600 border-blue-200"},{label:"å·²å¯ç¨",value:t.filter(e=>e.is_active).length,color:"bg-green-50 text-green-600 border-green-200"},{label:"å·²ç¦ç¨",value:t.filter(e=>!e.is_active).length,color:"bg-red-50 text-red-500 border-red-200"},{label:"é»è®¤é
ç½®",value:t.filter(e=>e.is_default).length,color:"bg-purple-50 text-purple-600 border-purple-200"}].map((e,s)=>(0,K.jsxs)("div",{className:`${e.color} border rounded-xl p-4`,children:[(0,K.jsx)("div",{className:"text-xs opacity-75 mb-1",children:e.label}),(0,K.jsx)("div",{className:"text-2xl font-bold",children:e.value})]},s))}),b&&(0,K.jsxs)("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden",children:[(0,K.jsxs)("div",{className:"p-5 border-b border-gray-100 flex items-center justify-between bg-gray-50",children:[(0,K.jsxs)("div",{className:"font-bold text-gray-800 flex items-center gap-2",children:[g?(0,K.jsx)(v,{size:18,className:"text-blue-500"}):(0,K.jsx)(j,{size:18,className:"text-green-500"}),g?"ç¼è¾ AI é
ç½®":"æ·»å æ° AI é
ç½®"]}),(0,K.jsx)("button",{onClick:()=>{p(!1),f(null),I({provider:"deepseek",display_name:"",api_key:"",model:"",base_url:"",is_default:!1,remark:""})},className:"text-gray-400 hover:text-gray-600",children:"â"})]}),(0,K.jsxs)("div",{className:"p-5 space-y-4",children:[(0,K.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,K.jsxs)("div",{children:[(0,K.jsxs)("label",{className:"block text-sm font-medium text-gray-600 mb-1.5",children:["AI æä¾å ",(0,K.jsx)("span",{className:"text-red-400",children:"*"})]}
1),(0,K.jsx)("select",{value:D.provider,onChange:e=>I(s=>({...s,provider:e.target.value})),disabled:!!g,className:"w-full border border-gray-200 rounded-lg px-3 py-2.5 text-sm outline-none focus:border-blue-500 bg-white",children:a.map(e=>(0,K.jsx)("option",{value:e.provider,children:e.label},e.provider))})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("label",{className:"block text-sm font-medium text-gray-600 mb-1.5",children:"æ¾ç¤ºåç§°ï¼éå¡«ï¼"}),(0,K.jsx)("input",{type:"text",value:D.display_name,onChange:e=>I(s=>({...s,display_name:e.target.value})),placeholder:"å¦ï¼è±å
-ç产ãåé®-æµè¯",className:"w-full border border-gray-200 rounded-lg px-3 py-2.5 text-sm outline-none focus:border-blue-500"})]}),(0,K.jsxs)("div",{className:"md:col-span-2",children:[(0,K.jsxs)("label",{className:"block text-sm font-medium text-gray-600 mb-1.5",children:["API Key ",(0,K.jsx)("span",{className:"text-red-400",children:"*"})]}),(0,K.jsx)("input",{type:"password",value:D.api_key,onChange:e=>I(s=>({...s,api_key:e.target.value})),placeholder:g?"ç空åä¸ä¿®æ¹":"请è¾å
¥ API Key",className:"w-full border border-gray-200 rounded-lg px-3 py-2.5 text-sm outline-none focus:border-blue-500 font-mono"}),q&&(0,K.jsxs)("div",{className:"text-xs text-gray-400 mt-1",children:["é»è®¤ Endpoint: ",q.defaultUrl]})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("label",{className:"block text-sm font-medium text-gray-600 mb-1.5",children:"模ååç§°ï¼éå¡«ï¼"}),(0,K.jsx)("input",{type:"text",value:D.model,onChange:e=>I(s=>({...s,model:e.target.value})),placeholder:"å¦ï¼"+(q?.defaultUrl?.includes("deepseek")?"deepseek-chat":"gpt-4"),className:"w-full border border-gray-200 rounded-lg px-3 py-2.5 text-sm outline-none focus:border-blue-500 font-mono"})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("label",{className:"block text-sm font-medium text-gray-600 mb-1.5",children:"èªå®ä¹ Endpointï¼éå¡«ï¼"}),(0,K.jsx)("input",{type:"text",value:D.base_url,onChange:e=>I(s=>({...s,base_url:e.target.value})),placeholder:"ç空使ç¨é»è®¤ endpoint",className:"w-full border border-gray-200 rounded-lg px-3 py-2.5 text-sm outline-none focus:border-blue-500 font-mono"})]}),(0,K.jsxs)("div",{className:"md:col-span-2",children:[(0,K.jsx)("label",{className:"block text-sm font-medium text-gray-600 mb-1.5",children:"夿³¨"}),(0,K.jsx)("input",{type:"text",value:D.remark,onChange:e=>I(s=>({...s,remark:e.target.value})),placeholder:"å¦ï¼ç产ç¯å¢ãæµè¯ç¯å¢",className:"w-full border border-gray-200 rounded-lg px-3 py-2.5 text-sm outline-none focus:border-blue-500"})]})]}),(0,K.jsxs)("div",{className:"flex items-center gap-2",children:[(0,K.jsx)("input",{type:"checkbox",id:"is_default",checked:D.is_default,onChange:e=>I(s=>({...s,is_default:e.target.checked}
1)),className:"accent-blue-500 w-4 h-4"}),(0,K.jsx)("label",{htmlFor:"is_default",className:"text-sm text-gray-600",children:"设为该æä¾åçé»è®¤é
ç½®"})]}),(0,K.jsxs)("div",{className:"flex gap-3 pt-2",children:[(0,K.jsxs)("button",{onClick:g?()=>(async e=>{if(!t.find(s=>s.id===e))return;const r={...D};r.api_key.trim()||delete r.api_key,r.base_url.trim()||delete r.base_url,r.model.trim()||delete r.model,r.remark.trim()||delete r.remark,r.display_name.trim()||delete r.display_name;try{const t=await E(`/ai-config/${e}`,{method:"PUT",body:r});t.success?(s("é
ç½®æ´æ°æåï¼"),f(null),I({provider:"deepseek",display_name:"",api_key:"",model:"",base_url:"",is_default:!1,remark:""}),P()):s(t.error||"æ´æ°å¤±è´¥")}catch(a){console.error("æ´æ°é
置失败:",a),s("ç½ç»éè¯¯ï¼æ´æ°å¤±è´¥")}})(g):async()=>{if(!D.api_key.trim())return s("API Key å¿
å¡«");const e={...D};e.base_url.trim()||delete e.base_url,e.model.trim()||delete e.model,e.remark.trim()||delete e.remark,e.display_name.trim()||delete e.display_name;try{const t=await E("/ai-config/",{method:"POST",body:e});t.success?(s("é
ç½®æ·»å æåï¼"),p(!1),I({provider:"deepseek",display_name:"",api_key:"",model:"",base_url:"",is_default:!1,remark:""}),P()):s(t.error||"æ·»å 失败")}catch(t){console.error("æ·»å é
置失败:",t),s("ç½ç»éè¯¯ï¼æ·»å 失败")}},className:"px-6 py-2.5 bg-blue-500 text-white rounded-lg text-sm font-medium hover:bg-blue-600 transition-colors flex items-center gap-2",children:[g?(0,K.jsx)(v,{size:16}):(0,K.jsx)(j,{size:16}),g?"ä¿åä¿®æ¹":"确认添å "]}),(0,K.jsx)("button",{onClick:()=>{p(!1),f(null),I({provider:"deepseek",display_name:"",api_key:"",model:"",base_url:"",is_default:!1,remark:""})},className:"px-6 py-2.5 border border-gray-200 text-gray-500 rounded-lg text-sm hover:bg-gray-50 transition-colors",children:"åæ¶"})]})]})]}),(0,K.jsxs)("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden",children:[(0,K.jsxs)("div",{className:"p-5 border-b border-gray-100 flex items-center justify-between",children:[(0,K.jsxs)("div",{className:"flex items-center gap-2",children:[(0,K.jsx)(h,{size:18,className:"text-blue-500"}),(0,K.jsx)("span",{className:"font-bold text-gray-800",children:"AI é
ç½®å表"}),(0,K.jsxs)("span",{className:"text-sm text-gray-400",children:["(",t.length," 个é
ç½®)"]})]}),(0,K.jsxs)("button",{onClick:()=>p(!0),disabled:b||i,title:i?"é
ç½®å 载失败,请å
éè¯å è½½":"",className:"px-4 py-2 bg-blue-500 text-white rounded-lg text-sm font-medium hover:bg-blue-600 transition-colors flex items-center gap-2 disabled:bg-gray-300 disabled:cursor-not-allowed",children:[(0,K.jsx)(j,{size:16}),"æ·»å é
ç½®"]})]}),n?(0,K.jsx)("div",{className:"p-12 text-center text-gray-400",children:"å è½½ä¸..."}):0===t.length?(0,K.jsxs)("div",{className:"p-12 text-center text-gray-400",children:[(0,K.jsx)(k,{size:48,className:"mx-auto mb-3 opacity-30"}),(0,K.jsx)("div",{className:"text-sm",children:"ææ AI é
ç½®ï¼ç¹å»å³ä¸è§æ·»å "}),(0,K.jsx)("div",{className:"text-xs mt-1",children:"æ·»å åå³å¯å®å
¨åå¨ API Key å¹¶ç¨äº AI 代ç"})]}):(0,K.jsx)("div",{className:"divide-y divide-gray-100",children:t.slice(10*(C-1),10*C).map(e=>{const r=a.find(s=>s.provider===e.provider);return(0,K.jsxs)("div",{className:"p-5 hover:bg-gray-50 transition-colors",children:[(0,K.jsxs)("div",{className:"flex flex-wrap items-start gap-4",children:[(0,K.jsxs)("div",{className:"flex items-center gap-3 min-w-[200px]",children:[(0,K.jsx)("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-white font-bold "+("deepseek"===e.provider?"bg-blue-500":"doubao"===e.provider?"bg-pink-400":"qianwen"===e.provider?"bg-indigo-500":"kimi"===e.provider?"bg-cyan-500":"yuanbao"===e.provider?"bg-green-500":"zhipu"===e.provider?"bg-violet-500":"bg-gray-500"),children:r?.label?.charAt(0)||"?"}),(0,K.jsxs)("div",{children:[(0,K.jsx)("div",{className:"font-semibold text-gray-800",children:e.display_name||r?.label||e.provider}),(0,K.jsx)("div",{className:"text-xs text-gray-400",children:e.provider})]})]}),(0,K.jsxs)("div",{className:"flex-1 grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[(0,K.jsxs)("div",{children:[(0,K.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"API Key"}),(0,K.jsxs)("div",{className:"flex items-center gap-2",children:[(0,K.jsx)("span",{className:"font-mono text-gray-700 bg-gray-100 px-2 py-1 rounded text-xs",children:e.api_key_masked}),(0,K.jsx)("button",{onClick:()=>{return s=e.api_key_masked,t=e.id,navigator.clipboard.writeText(s),_(t),void setTimeout(()=>_(null),2e3);var s,t},className:"text-gray-400 hover:text-blue-500 transition-colors",title:"å¤å¶",children:w===e.id?(0,K.jsx)(o,{size:14,className:"text-green-500"}):(0,K.jsx)(m,{size:14})})]})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"模å"}),(0,K.jsx)("div",{className:"text-gray-700",children:e.model||"-"})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Endpoint"}),(0,K.jsx)("div",{className:"text-xs text-gray-700 truncate max-w-[150px]",title:e.base_url||r?.defaultUrl,children:e.base_url||r?.defaultUrl||"-"})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"ç¶æ"}),(0,K.jsxs)("div",{className:"flex items-center gap-2",children:[e.is_default&&(0,K.jsx)("span",{className:"px-2 py-0.5 bg-purple-100 text-purple-600 rounded text-xs font-medium",children:"é»è®¤"}),(0,K.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium "+(e.is_active?"bg-green-100 text-green-600":"bg-red-100 text-red-500"),children:e.is_active?"â å¯ç¨":"â ç¦ç¨"})]})]})]}),(0,K.jsxs)("div",{className:"flex items-center gap-2 ml-auto",children:[!e.is_default&&(0,K.jsx)("button",{onClick:()=>(async e=>{try{const t=await E(`/ai-config/${e}/set-default`,{method:"PATCH"});t.success?(s("已设置为é»è®¤é
ç½®"),P()):s(t.error||"æä½å¤±è´¥")}catch(t){console.error("设置é»è®¤å¤±è´¥:",t),s("ç½ç»éè¯¯ï¼æä½å¤±è´¥")}})(e.id),className:"px-3 py-1.5 text-xs bg-purple-50 text-purple-600 rounded hover:bg-purple-100 transition-colors",title:"设为é»è®¤",children:"设为é»è®¤"}),(0,K.jsxs)("button",{onClick:()=>(async e=>{const r=t.find(s=>
1s.id===e);if(r)try{const t=await E(`/ai-config/${e}`,{method:"PUT",body:{is_active:!r.is_active}});t.success?(s(r.is_active?"å·²ç¦ç¨":"å·²å¯ç¨"),P()):s(t.error||"æä½å¤±è´¥")}catch(a){console.error("åæ¢ç¶æå¤±è´¥:",a),s("ç½ç»éè¯¯ï¼æä½å¤±è´¥")}})(e.id),className:"px-3 py-1.5 text-xs rounded hover:opacity-80 transition-colors "+(e.is_active?"bg-orange-50 text-orange-500":"bg-green-50 text-green-600"),children:[e.is_active?(0,K.jsx)(x,{size:14}):(0,K.jsx)(c,{size:14}),e.is_active?"ç¦ç¨":"å¯ç¨"]}),(0,K.jsxs)("button",{onClick:()=>(e=>{f(e.id),I({provider:e.provider,display_name:e.display_name||"",api_key:"",model:e.model||"",base_url:e.base_url||"",is_default:e.is_default,remark:e.remark||""}),p(!0)})(e),className:"px-3 py-1.5 text-xs bg-blue-50 text-blue-600 rounded hover:bg-blue-100 transition-colors flex items-center gap-1",children:[(0,K.jsx)(v,{size:14}),"ç¼è¾"]}),(0,K.jsxs)("button",{onClick:()=>(async e=>{if(window.confirm("确认å 餿¤é
ç½®ï¼å é¤åæ æ³æ¢å¤ã"))try{const t=await E(`/ai-config/${e}`,{method:"DELETE"});t.success?(s("é
置已å é¤"),P()):s(t.error||"å é¤å¤±è´¥")}catch(t){console.error("å é¤é
置失败:",t),s("ç½ç»é误ï¼å é¤å¤±è´¥")}})(e.id),className:"px-3 py-1.5 text-xs bg-red-50 text-red-400 rounded hover:bg-red-100 transition-colors flex items-center gap-1",children:[(0,K.jsx)(S,{size:14}),"å é¤"]})]})]}),e.remark&&(0,K.jsxs)("div",{className:"mt-3 text-xs text-gray-400 ml-14",children:["夿³¨: ",e.remark]})]},e.id)})}),(0,K.jsx)(L,{total:t.length,currentPage:C,pageSize:10,onChange:A})]}),(0,K.jsx)("div",{className:"text-center text-xs text-gray-400 pb-4",children:"API Key ç»è¿ AES-256-GCM å å¯åå¨ï¼åç«¯æ æ³è·åææãAI 请æ±éè¿å端代ç转åï¼ä¿éå¯é¥å®å
¨ã"})]})}var O=({systemConfig:e,setSystemConfig:s,clientsData:t,setClientsData:o,orders:c,setOrders:m,onLogout:v,showToast:k,initialModule:z,initialDetail:L,hideShell:O})=>{const Q=l(),R=r();a();const[G,H]=(0,F.useState)(z||"clients"),[J,W]=(0,F.useState)(()=>{if("client"===L&&R.id){const e=R.id;return Object.values(t).find(s=>s.username===e||s.username===e.split("-")[0])||null}return null});(0,F.useEffect)(()=>{z&&H(z)},[z]);const[Z,V]=(0,F.useState)(e.apis||[]),[X,Y]=(0,F.useState)(e.publishPlatforms||[]),[ee,se]=(0,F.useState)([]),[te,re]=(0,F.useState)(!0),[ae,le]=(0,F.useState)(!1),[ne,de]=(0,F.useState)(null),[oe,ie]=(0,F.useState)(0),[ce,xe]=(0,F.useState)(0),[me,ue]=(0,F.useState)("æ£å¸¸"),[be,pe]=(0,F.useState)("2099-12-31"),[he,ge]=(0,F.useState)(!1),[fe,ye]=(0,F.useState)({username:"",password:"",name:"",industry:"",contact:"",quota:1e4,expireDate:"2099-12-31"}),[je,Ne]=(0,F.useState)(e.templates[0]||null),[ve,we]=(0,F.useState)(null),[ke,_e]=(0,F.useState)(""),[Ce,Se]=(0,F.useState)(null),[ze,Ae]=(0,F.useState)([]),[De,Ee]=(0,F.useState)(!1),[Ie,Te]=(0,F.useState)(1),[Pe,qe]=(0,F.useState)(0),[Le,$e]=(0,F.useState)(""),[Be,Ue]=(0,F.useState)(null),[Fe,Ke]=(0,F.useState)(""),Me=10,Oe=e=>{const s={clients:T.dashboard(),tenants:"/admin/tenants.html",api:T.apiConfig(),template:T.templates(),platforms:T.platforms(),newsSources:T.newsSources(),orders:T.orders()};Q(s[e]||T.dashboard())},Qe=(e,s,t)=>Y(X.map(r=>r.id===e?{...r,[s]:t}:r)),Re=async()=>{re(!0);try{const e=await E("/media-platforms/admin/all");e?.success&&Array.isArray(e.data)&&se(e.data)}catch(e){console.error("å è½½åªä½å¹³å°å¤±è´¥:",e),k("å è½½åªä½å¹³å°å¤±è´¥")}finally{re(!1)}};(0,F.useEffect)(()=>{Re()},[]);const Ge=(e,s,t)=>{se(r=>{const a=r.map(r=>r.id===e?{...r,[s]:t}:r),l=a.find(s=>s.id===e);return l&&(clearTimeout(window._mediaSaveTimer?.[e]),window._mediaSaveTimer||(window._mediaSaveTimer={}),window._mediaSaveTimer[e]=setTimeout(async()=>{try{await E(`/media-platforms/${e}`,{method:"PUT",body:{name:l.name,category:l.category,region:l.region,price:l.price,description:l.description,url:l.url,index_type:l.index_type,delivery_time:l.delivery_time,sort_order:l.sort_order,status:l.status}})}catch(s){k("èªå¨ä¿å失败")}},600)),a})},He=(e,s,t)=>Ne(r=>({...r,templates:r.templates.map(r=>r.id===e?{...r,[s]:t}:r)})),Je=(0,F.useCallback)(async()=>{Ee(!0);try{const e=await P({status:Le||void 0,page:Ie,pageSize:Me});e.success?(Ae(e.data||[]),qe(e.total||0)):(k(e.error||"å 载订å失败"),Ae([]))}catch(e){console.error("[AdminDashboard] loadRealOrders error:",e),k("å 载订å失败")}finally{Ee(!1)}},[Le,Ie,k]);(0,F.useEffect)(()=>{"orders"===G&&Je()},[G,Je]);const We=Object.values(t);return(0,K.jsxs)("div",{className:O?"":"min-h-screen bg-gray-100 flex animate-fadeIn relative",children:[he&&(0,K.jsx)("div",{className:"fixed inset-0 bg-slate-900/60 flex items-center justify-center z-[1000] p-4 backdrop-blur-sm",children:(0,K.jsxs)("div",{className:"bg-white rounded-2xl w-full max-w-[480px] max-h-[90vh] flex flex-col shadow-2xl animate-modal-pop",children:[(0,K.jsxs)("div",{className:"flex justify-between items-center p-6 border-b border-gray-100 shrink-0",children:[(0,K.jsxs)("h3",{className:"text-lg font-bold text-gray-800 flex items-center gap-2",children:[(0,K.jsx)(D,{size:18,className:"text-blue-600"})," å¼è®¾æ°åè´¦å·"]}),(0,K.jsx)("button",{onClick:()=>ge(!1),className:"text-gray-400 hover:text-gray-600 transition-colors",children:"Ã"})]}),(0,K.jsxs)("div",{className:"p-6 flex-1 overflow-y-auto space-y-4",children:[(0,K.jsxs)("div",{className:"flex gap-4",children:[(0,K.jsxs)("div",{className:"flex-1",children:[(0,K.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["ç»å½è´¦å· ",(0,K.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,K.jsx)("input",{type:"text",value:fe.username,onChange:e=>ye({...fe,username:e.target.value}),className:"w-full border border-gray-300 rounded-lg p-2.5 focus:ring-2 focus:ring-blue-500 outline-none text-sm",placeholder:"å¦: client
101"})]}),(0,K.jsxs)("div",{className:"flex-1",children:[(0,K.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["ç»å½å¯ç ",(0,K.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,K.jsx)("input",{type:"text",value:fe.password,onChange:e=>ye({...fe,password:e.target.value}),className:"w-full border border-gray-300 rounded-lg p-2.5 focus:ring-2 focus:ring-blue-500 outline-none text-sm",placeholder:"设置å¯ç "})]})]}),(0,K.jsxs)("div",{className:"flex gap-4",children:[(0,K.jsxs)("div",{className:"flex-1",children:[(0,K.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["客æ·ä¼ä¸åç§° ",(0,K.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,K.jsx)("input",{type:"text",value:fe.name,onChange:e=>ye({...fe,name:e.target.value}),className:"w-full border border-gray-300 rounded-lg p-2.5 focus:ring-2 focus:ring-blue-500 outline-none text-sm",placeholder:"å
¨ç§°ï¼å°åæ¥è³å
¶åºç¡ä¿¡æ¯"})]}),(0,K.jsxs)("div",{className:"flex-1",children:[(0,K.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"åå§åé
ç®åç¹"}),(0,K.jsx)("input",{type:"number",value:fe.quota,onChange:e=>ye({...fe,quota:e.target.value}),className:"w-full border border-gray-300 rounded-lg p-2.5 focus:ring-2 focus:ring-blue-500 outline-none text-sm"})]})]}),(0,K.jsxs)("div",{className:"flex gap-4",children:[(0,K.jsxs)("div",{className:"flex-1",children:[(0,K.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"æå±è¡ä¸"}),(0,K.jsx)("input",{type:"text",value:fe.industry,onChange:e=>ye({...fe,industry:e.target.value}),className:"w-full border border-gray-300 rounded-lg p-2.5 focus:ring-2 focus:ring-blue-500 outline-none text-sm",placeholder:"请è¾å
¥æå±è¡ä¸"})]}),(0,K.jsxs)("div",{className:"flex-1",children:[(0,K.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"主è¦è系人"}),(0,K.jsx)("input",{type:"text",value:fe.contact,onChange:e=>ye({...fe,contact:e.target.value}),className:"w-full border border-gray-300 rounded-lg p-2.5 focus:ring-2 focus:ring-blue-500 outline-none text-sm",placeholder:"å§å"})]})]}),(0,K.jsxs)("div",{children:[(0,K.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["设置账å·å°ææ¶é´ ",(0,K.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,K.jsx)("input",{type:"date",value:fe.expireDate,onChange:e=>ye({...fe,expireDate:e.target.value}),className:"w-full border border-gray-300 rounded-lg p-2.5 focus:ring-2 focus:ring-blue-500 outline-none text-sm"})]})]}),(0,K.jsxs)("div",{className:"flex justify-end gap-3 bg-gray-50 p-5 rounded-b-2xl border-t border-gray-100 shrink-0",children:[(0,K.jsx)("button",{onClick:()=>ge(!1),className:"px-5 py-2 rounded-lg border border-gray-300 text-gray-600 hover:bg-white text-sm font-medium",children:"åæ¶"}),(0,K.jsx)("button",{onClick:async()=>{if(!fe.username.trim()||!fe.password.trim()||!fe.name.trim())return k("请填åå¿
填项ï¼ç»å½è´¦å·ãå¯ç ãä¼ä¸åç§°");if(t[fe.username])return k("该ç»å½è´¦å·å·²åå¨ï¼è¯·æ´æ¢");try{const e=await E("/accounts",{method:"POST",body:{phone:fe.username||"",username:fe.username,password:fe.password,name:fe.name,parent_id:null,
1status:I.ENABLED,remark:fe.industry||"",company_name:fe.name||"",compute_quota:parseInt(fe.quota)||0,industry:fe.industry||"",expire_date:fe.expireDate||"2099-12-31"}});if(e.success){const e={username:fe.username,password:fe.password,name:fe.name,industry:fe.industry,contact:fe.contact,status:I.ENABLED,expireDate:fe.expireDate,quota:parseInt(fe.quota)||1e4,usedQuota:0,balance:0,companyInfo:{name:fe.name,shortName:fe.name.substring(0,4),industry:fe.industry,phone:"",website:"",companyPositioning:"",companyIntro:"",endorsement:"",customerPersona:"",customerPainPoint:"",competitors:"",productInfo:"",afterSales:"",customerCase:"",otherInfo:""},keywords:[],customDirectives:[],trainingTasks:[],articles:[]};o(s=>({...s,[fe.username]:e})),ge(!1),ye({username:"",password:"",name:"",industry:"",contact:"",quota:1e4,expireDate:"2099-12-31"}),k(`æåæ·»å åè´¦å·: ${fe.name}ï¼è´¦å·ä¿¡æ¯å·²åå
¥äºç«¯æ°æ®åº`)}else k(`å建失败: ${e.error||"æªç¥é误"}`)}catch(e){console.error("å建账å·å¤±è´¥:",e),k(`å建失败: ${e.message||"ç½ç»é误"}`)}},className:"px-5 py-2 rounded-lg bg-gradient-to-r from-[#1a3a6b] to-[#2563eb] text-white hover:from-[#0f2847] hover:to-[#1a3a6b] font-medium shadow-md text-sm",children:"å建账å·"})]})]})}),ne&&(0,K.jsx)("div",{className:"fixed inset-0 bg-slate-900/60 flex items-center justify-center z-[1000] p-4 backdrop-blur-sm",children:(0,K.jsxs)("div",{className:"bg-white rounded-2xl w-full max-w-[440px] max-h-[90vh] flex flex-col shadow-2xl animate-modal-pop",children:[(0,K.jsxs)("div",{className:"flex justify-between items-center p-6 border-b border-gray-100 shrink-0",children:[(0,K.jsxs)("h3",{className:"text-lg font-bold text-gray-800 flex items-center gap-2",children:[(0,K.jsx)(N,{size:18})," èµäº§ä¸æé管æ§"]}),(0,K.jsx)("button",{onClick:()=>de(null),className:"text-gray-400 hover:text-gray-600",children:"Ã"})]}),(0,K.jsxs)("div",{className:"p-6 flex-1 overflow-y-auto",children:[(0,K.jsxs)("div",{className:"mb-4 text-sm text-gray-600 bg-blue-50 p-3 rounded-lg border border-blue-100",children:["å½å管ç客æ·ï¼",(0,K.jsx)("span",{className:"font-semibold text-blue-700",children:ne.name})]}),(0,K.jsxs)("div",{className:"space-y-4",children:[(0,K.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,K.jsxs)("div",{children:[(0,K.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"è´¦å·å¯å管æ§"}),(0,K.jsxs)("select",{value:me,onChange:e=>ue(e.target.value),className:"w-full border rounded-lg p-2 focus:ring-2 focus:ring-blue-500 outline-none font-bold "+("æ£å¸¸"===me?"text-blue-600 border-blue-300":"text-red-600 border-red-300"),children:[(0,K.jsx)("option",{value:"æ£å¸¸",children:"æ£å¸¸ä½¿ç¨"}),(0,K.jsx)("option",{value:"å·²åç¨",children:"强å¶åç¨"})]})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"è´¦å·å°ææ¶é´"}),(0,K.jsx)("input",{type:"date",value:be,onChange:e=>pe(e.target.value),className:"w-full border border-gray-300 rounded-lg p-2 focus:ring-2 focus:ring-blue-500 outline-none"})]})]}),(0,K.jsxs)("div",{className:"pt-4 border-t border-gray-100",children:[(0,K.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["设置æ»ç®åç¹æ° (å½åå·²æ¶è: ",ne.usedQuota," ç¹)"]}),(0,K.jsx)("input",{type:"number",value:oe,onChange:e=>ie(e.target.value),className:"w-full border border-gray-300 rounded-lg p-2 focus:ring-2 focus:ring-blue-500 outline-none"})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"设置å稿ç°éä½é¢ (å
)"}),(0,K.jsx)("input",{type:"number",value:ce,onChange:e=>xe(e.target.value),className:"w-full border border-orange-300 rounded-lg p-2 focus:ring-2 focus:ring-orange-500 outline-none text-orange-600 font-bold"})]})]})]}),(0,K.jsxs)("div",{className:"flex justify-end gap-3 bg-gray-50 p-5 rounded-b-2xl border-t border-gray-100 shrink-0",children:[(0,K.jsx)("button",{onClick:()=>de(null),className:"px-4 py-2 rounded-lg border border-gray-300 text-gray-600 hover:bg-white text-sm font-medium",children:"åæ¶"}),(0,K.jsx)("button",{onClick:async()=>
1{if(ne)try{await E(`/accounts/${ne.id}/status`,{method:"PATCH",body:{status:me===I.ENABLED?I.ENABLED:I.DISABLED}}),await E(`/accounts/${ne.id}`,{method:"PUT",body:{phone:ne.contact||"",username:ne.username,password:ne.password,status:me===I.ENABLED?I.ENABLED:I.DISABLED,remark:ne.industry||"",name:ne.name||"",industry:ne.industry||"",expire_date:be||"2099-12-31",quota:parseInt(oe)||0,balance:parseFloat(ce)||0,company_name:ne.name||"",compute_quota:parseInt(oe)||0}}),o(e=>({...e,[ne.username]:{...e[ne.username],quota:parseInt(oe)||0,balance:parseFloat(ce)||0,status:me,expireDate:be}})),k(`å·²æåæ´æ°å®¢æ· ${ne.name} çç¶æä¸èµäº§ï¼å¹¶åæ¥äºç«¯`),de(null)}catch(e){console.error("æ´æ°è´¦å·å¤±è´¥:",e),k(`æ´æ°å¤±è´¥: ${e.message||"ç½ç»é误"}`)}},className:"px-4 py-2 rounded-lg bg-gradient-to-r from-[#1a3a6b] to-[#2563eb] text-white hover:from-[#0f2847] hover:to-[#1a3a6b] font-medium shadow-md text-sm",children:"æ´æ°é
ç½®åå
¥äºç«¯"})]})]})}),ve&&(0,K.jsx)("div",{className:"fixed inset-0 bg-slate-900/60 flex items-center justify-center z-[1000] p-4 backdrop-blur-sm",children:(0,K.jsxs)("div",{className:"bg-white rounded-2xl w-full max-w-[480px] max-h-[90vh] flex flex-col shadow-2xl animate-modal-pop",children:[(0,K.jsxs)("div",{className:"flex justify-between items-center p-6 border-b border-gray-100 shrink-0",children:[(0,K.jsx)("h3",{className:"text-lg font-bold text-gray-800",children:"交ä»åå¸é¾æ¥"}),(0,K.jsx)("button",{onClick:()=>we(null),className:"text-gray-400 hover:text-gray-600",children:"Ã"})]}),(0,K.jsxs)("div",{className:"p-6 flex-1 overflow-y-auto",children:[(0,K.jsxs)("div",{className:"mb-4 text-sm text-gray-600",children:["è¯·ä¸ºå®¢æ· ",(0,K.jsx)("span",{className:"font-bold",children:ve.submitter_name||ve.submitter_username||"-"})," ç ",(0,K.jsxs)("span",{className:"text-blue-600 font-bold",children:["[",ve.media_name||ve.current_media_name||"-","]"]})," å稿订åå¡«å
¥å®é
å·²åå¸ç龿¥ï¼"]}),(0,K.jsx)("input",{type:"url",value:ke,onChange:e=>_e(e.target.value),className:"w-full border border-gray-300 rounded-lg p-3 focus:ring-2 focus:ring-blue-500 outline-none font-mono text-sm text-gray-600",placeholder:"http://..."})]}),(0,K.jsxs)("div",{className:"flex justify-end gap-3 bg-gray-50 p-5 rounded-b-2xl border-t border-gray-100 shrink-0",children:[(0,K.jsx)("button",{onClick:()=>we(null),className:"px-4 py-2 rounded-lg border border-gray-300 text-gray-600 hover:bg-white",children:"åæ¶"}),(0,K.jsx)("button",{onClick:async()=>{if(!ke.trim())return k("å¿
须填ååå¸åçç½å龿¥!");if(!ve)return;if("å¾
å¤ç"===ve.status){const e=await q(ve.id,{status:"å¤çä¸",admin_note:"å¼å§å¤ç"});if(!e.success)return void k(e.error||"ç¶ææ¨è¿å¤±è´¥")}const e=await q(ve.id,{status:"å·²åå¸",publish_url:ke.trim()});e.success?(k("订åå·²æå交ä»,åå¸é¾æ¥å·²åæ¥ç»åè´¦å·!"),we(null),_e(""),Je()):k(e.error||"交ä»å¤±è´¥,请éè¯")},className:"px-4 py-2 rounded-lg bg-gradient-to-r from-[#1a3a6b] to-[#2563eb] text-white hover:from-[#0f2847] hover:to-[#1a3a6b] font-medium shadow-md",children:"确认交ä»"})]})]})}),Be&&(0,K.jsx)("div",{className:"fixed inset-0 bg-slate-900/60 flex items-center justify-center z-[1000] p-4 backdrop-blur-sm",children:(0,K.jsxs)("div",{className:"bg-white rounded-2xl w-full max-w-[480px] max-h-[90vh] flex flex-col shadow-2xl animate-modal-pop",children:[(0,K.jsxs)("div",{className:"flex justify-between items-center p-6 border-b border-gray-100 shrink-0",children:[(0,K.jsx)("h3",{className:"text-lg font-bold text-gray-800",children:"驳å订å"}),(0,K.jsx)("button",{onClick:()=>Ue(null),className:"text-gray-400 hover:text-gray-600",children:"Ã"})]}),(0,K.jsxs)("div",{className:"p-6 flex-1 overflow-y-auto space-y-3",children:[(0,K.jsxs)("div",{className:"text-sm text-gray-600",children:["订å ",(0,K.jsx)("span",{className:"font-bold text-blue-600",children:Be.order_no})," å°è¢«é©³å, Â¥",Number(Be.amount||0).toFixed(2)," ä¼èªå¨éè¿è³åè´¦å·ä½é¢ã"]}),(0,K.jsxs)("div",{children:[(0,K.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["驳ååå ",(0,K.jsx)("span",{className:"text-gray-400 text-xs",children:"(éå¡«)"})]}
1),(0,K.jsx)("textarea",{value:Fe,onChange:e=>Ke(e.target.value),rows:3,maxLength:200,placeholder:'å¡«åååè´¦å·å¯ä»¥çå°,ä¸å¡«åæ¾ç¤º"主账å·é©³å"',className:"w-full border border-gray-300 rounded-lg p-3 focus:ring-2 focus:ring-blue-500 outline-none text-sm resize-none"}),(0,K.jsxs)("div",{className:"text-xs text-gray-400 mt-1 text-right",children:[Fe.length,"/200"]})]})]}),(0,K.jsxs)("div",{className:"flex justify-end gap-3 bg-gray-50 p-5 rounded-b-2xl border-t border-gray-100 shrink-0",children:[(0,K.jsx)("button",{onClick:()=>Ue(null),className:"px-4 py-2 rounded-lg border border-gray-300 text-gray-600 hover:bg-white",children:"åæ¶"}),(0,K.jsx)("button",{onClick:async()=>{if(!Be)return;if("å¾
å¤ç"===Be.status){const e=await q(Be.id,{status:"å¤çä¸",admin_note:"å¼å§å¤ç(åå¤é©³å)"});if(!e.success)return void k(e.error||"ç¶ææ¨è¿å¤±è´¥")}const e=await q(Be.id,{status:"已失败",failure_reason:Fe.trim()||"主账å·é©³å"});e.success?(k(`订å已驳å,Â¥${Number(Be.amount).toFixed(2)} å·²éè¿è³åè´¦å·ä½é¢`),Ue(null),Ke(""),Je()):k(e.error||"驳å失败,请éè¯")},className:"px-4 py-2 rounded-lg bg-gradient-to-r from-red-500 to-red-600 hover:from-red-600 hover:to-red-700 text-white font-medium shadow-md",children:"确认驳å"})]})]})}),Ce&&(0,K.jsx)("div",{className:"fixed inset-0 bg-slate-900/60 flex items-center justify-center z-[1000] p-4 backdrop-blur-sm overflow-y-auto",children:(0,K.jsxs)("div",{className:"bg-white rounded-2xl w-full max-w-4xl max-h-[90vh] flex flex-col shadow-2xl animate-modal-pop my-auto",children:[(0,K.jsxs)("div",{className:"p-6 border-b border-gray-100 flex justify-between items-start bg-gray-50 rounded-t-2xl shrink-0",children:[(0,K.jsxs)("div",{className:"pr-8",children:[(0,K.jsx)("h3",{className:"text-xl font-bold text-gray-800 mb-2",children:Ce.title}),Ce.media_name&&(0,K.jsxs)("div",{className:"flex gap-4 text-sm",children:[(0,K.jsxs)("span",{className:"bg-blue-100 text-blue-800 px-2 py-0.5 rounded font-medium",children:["ç®æ åªä½: ",Ce.media_name]}),(0,K.jsxs)("span",{className:"bg-orange-100 text-orange-800 px-2 py-0.5 rounded font-medium",children:["æå±å®¢æ·: ",Ce.submitter_name||"æªå¡«å"]})]})]}),(0,K.jsx)("button",{onClick:()=>Se(null),className:"text-gray-400 hover:text-gray-600 shrink-0 bg-white border border-gray-200 rounded p-1",children:"Ã"})]}),(0,K.jsxs)("div",{className:"p-6 flex-1 overflow-y-auto",children:[(0,K.jsx)("div",{className:"whitespace-pre-wrap text-gray-700 leading-relaxed font-serif text-base mb-6 pb-6 border-b border-gray-100",children:Ce.content}),Ce.remark&&(0,K.jsxs)("div",{className:"bg-orange-50/50 p-4 rounded-lg border border-orange-100",children:[(0,K.jsxs)("h4",{className:"text-sm font-bold text-orange-800 mb-2 flex items-center gap-1",children:[(0,K.jsx)(i,{size:16})," åç¨¿ç¹æ®å¤æ³¨è¦æ±ï¼"]}),(0,K.jsx)("p",{className:"text-sm text-gray-700 whitespace-pre-wrap",children:Ce.remark})]})]}),(0,K.jsx)("div",{className:"p-4 border-t border-gray-100 flex justify-end bg-gray-50 rounded-b-2xl shrink-0",children:(0,K.jsx)("button",{onClick:()=>Se(null),className:"px-6 py-2.5 bg-gradient-to-r from-[#1a3a6b] to-[#2563eb] text-white rounded-lg hover:from-[#0f2847] hover:to-[#1a3a6b] font-medium shadow-sm transition-colors",children:"å
³éé¢è§"})})]})}),!O&&(0,K.jsxs)("aside",{className:"w-40 bg-[#0a1628] text-slate-300 flex flex-col shadow-xl z-20 shrink-0",children:[(0,K.jsxs)("div",{className:"h-16 flex items-center justify-center border-b border-slate-800 text-white font-bold text-base tracking-wider gap-2",children:[(0,K.jsx)(N,{size:18,className:"text-blue-500"}),"æ»æ§åå°"]}),(0,K.jsxs)("nav",{className:"flex-1 py-6 space-y-2 px-3 overflow-y-auto",children:[(0,K.jsxs)("button",{onClick:()=>{Oe("clients"),W(null)},className:"w-full flex items-center gap-2 px-3 py-2.5 rounded-lg transition-colors text-sm "+("clients"===G?"bg-gradient-to-r from-green-400/90 to-cyan-500/90 text-white":"hover:bg-slate-800"),children:[(0,K.jsx)(D,{size:18})," èµäº§ä¸è´¦å·"]}),(0,K.jsxs)("button",{onClick:()=>{Oe("api"),W(null)},className:"w-full flex items-center gap-2 px-3 py-2.5 rounded-lg transition-colors text-sm "+("api"===G?"bg-gradient-to-r from-green-400/90 to-cyan-500/90 text-white":"hover:bg-slate-800"),children:[(0,K.jsx)(h,{size:18})," AI æ¥å£é
ç½®"]}),(0,K.jsxs)("button",{onClick:()=>{Oe("template"),W(null)},className:"w-full flex items-center gap-2 px-3 py-2.5 rounded-lg transition-colors text-sm "+("template"===G?"bg-gradient-to-r from-green-400/90 to-cyan-500/90 text-white":"hover:bg-slate-800"),children:[(0,K.jsx)(f,{size:18})," 夿¨¡æ¿åº"]}),(0,K.jsxs)("button",{onClick:()=>{Oe("platforms"),W(null)},className:"w-full flex items-center gap-2 px-3 py-2.5 rounded-lg transition-colors text-sm "+("platforms"===G?"bg-gradient-to-r from-green-400/90 to-cyan-500/90 text-white":"hover:bg-slate-800"),children:[(0,K.jsx)(w,{size:18})," åå¸å¹³å°ç®¡ç"]}),(0,K.jsxs)("button",{onClick:()=>{Oe("newsSources"),W(null)},className:"w-full flex items-center gap-2 px-3 py-2.5 rounded-lg transition-colors text-sm "+("newsSources"===G?"bg-gradient-to-r from-green-400/90 to-cyan-500/90 text-white":"hover:bg-slate-800"),children:[(0,K.jsx)(p,{size:18})," æ°é»æºç®¡ç"]}),(0,K.jsxs)("button",{onClick:()=>{Oe("orders"),W(null)},className:"w-full flex items-center gap-2 px-3 py-2.5 rounded-lg transition-colors text-sm "+("orders"===G?"bg-gradient-to-r from-green-400/90 to-cyan-500/90 text-white":"hover:bg-slate-800"),children:[(0,K.jsx)(_,{size:18})," åæè®¢åå¤ç"]}),(0,K.jsxs)("button",{onClick:()=>{Oe("tenants"),W(null)},className:"w-full flex items-center gap-2 px-3 py-2.5 rounded-lg transition-colors text-sm "+("tenants"===G?"bg-gradient-to-r from-green-400/90 to-cyan-500/90 text-white":"hover:bg-slate-800"),children:[(0,K.jsx)(n,{size:18})," ç§æ·ç®¡ç"]})]}),(0,K.jsx)("div",{className:"p-3 border-t border-slate-800",children:(0,K.jsxs)("button",{onClick:v,className:"w-full flex items-center gap-2 px-3 py-2.5 rounded-lg hover:bg-red-500 hover:text-white transition-colors text-sm",children:[(0,K.jsx)(y,{size:18})," éåºç»å½"]})})]}),(0,K.jsxs)("main",{className:O?"":"flex-1 flex flex-col h-screen overflow-hidden",children:[!O&&(0,K.jsxs)("header",{className:"h-16 bg-white shadow-sm flex items-center justify-between px-8 z-10 shrink-0",children:[(0,K.jsxs)("h2",{className:"text-xl font-semibold text-gray-800 flex items-center gap-2",children:["clients"===G&&J&&(0,K.jsx)("button",{onClick:()=>W(null),className:"text-sm text-blue-600 hover:text-blue-800 bg-blue-50 px-2 py-1 rounded border border-blue-200 mr-2",children:"â è¿åå表"}),"clients"===G&&(J?`ã${J.name}ãåå°ä¸å¡æ°æ®æç»`:"å
¨å
¨å±åè´¦å·çå½å¨æä¸äºèµäº§ç®¡æ§"),"api"===G&&"å¹³å° API æ¥å£å
¨å±é
ç½®","template"===G&&"å
¨å±é¢è®¾æç« 模æ¿åº (ä¸åè³åè´¦å·)","platforms"===G&&"åååªä½å¹³å°ç®¡ç (ä¸åè³åè´¦å·)","newsSources"===G&&"æ°é»æºåå¸ç®¡ç (ä¸åè³åè´¦å·)","orders"===G&&"å®¢æ·æ°é»æ
1ºåå¸åæè®¢åå¤ç","tenants"===G&&"å¤ç§æ·è´´çè´¦å·ç®¡ç"]}),(0,K.jsxs)("div",{className:"flex items-center gap-3 text-sm text-gray-600",children:[(0,K.jsx)("span",{className:"bg-slate-100 p-2 rounded-full",children:(0,K.jsx)(A,{size:16})}),"è¶
级管çå (主账å·)"]})]}),(0,K.jsxs)("div",{className:O?"":"flex-1 overflow-y-auto p-8 flex flex-col",children:[(0,K.jsxs)("div",{className:O?"":"flex-1",children:["clients"===G&&!J&&(0,K.jsxs)("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden",children:[(0,K.jsxs)("div",{className:"p-4 border-b flex justify-between items-center bg-gray-50",children:[(0,K.jsx)("input",{type:"text",placeholder:"æç´¢åè´¦å·åç§°...",className:"border border-gray-300 rounded-md px-3 py-1.5 text-sm outline-none focus:border-blue-500"}),(0,K.jsxs)("button",{onClick:()=>ge(!0),className:"bg-gradient-to-r from-[#1a3a6b] to-[#2563eb] text-white px-4 py-1.5 rounded-md text-sm hover:from-[#0f2847] hover:to-[#1a3a6b] flex items-center gap-1",children:[(0,K.jsx)(j,{size:16})," æ·»å åè´¦å·"]})]}),(0,K.jsxs)("table",{className:"w-full text-left text-sm text-gray-600",children:[(0,K.jsx)("thead",{className:"bg-slate-50 text-gray-700 border-b border-gray-200",children:(0,K.jsxs)("tr",{children:[(0,K.jsx)("th",{className:"p-4",children:"ç»å½è´¦å·"}),(0,K.jsx)("th",{className:"p-4",children:"ä¼ä¸åç§°"}),(0,K.jsx)("th",{className:"p-4",children:"å°ææ¶é´ä¸ç¶æ"}),(0,K.jsx)("th",{className:"p-4",children:"ç®å (å·²æ¶è/æ»è®¡)"}),(0,K.jsx)("th",{className:"p-4",children:"å稿ä½é¢ (å
)"}),(0,K.jsx)("th",{className:"p-4 text-center",children:"æä½"})]})}),(0,K.jsx)("tbody",{children:We.map(e=>{const s=new Date>new Date(e.expireDate);return(0,K.jsxs)("tr",{className:"border-b border-gray-100 hover:bg-slate-50",children:[(0,K.jsx)("td",{className:"p-4 font-mono text-gray-500",children:e.username}),(0,K.jsx)("td",{className:"p-4 font-medium text-gray-800",children:e.name}),(0,K.jsx)("td",{className:"p-4",children:(0,K.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,K.jsx)("span",{className:"text-gray-600 font-mono text-xs",children:e.expireDate}),(0,K.jsx)("span",{className:"px-2 py-0.5 rounded text-[10px] w-max font-bold "+(e.status!==I.ENABLED||s?"bg-red-100 text-red-700":"bg-blue-100 text-blue-700"),children:e.status===I.DISABLED?"已被æå¨åç¨":s?"å·²è¿æåç¨":"è´¦å·æ£å¸¸"})]})}),(0,K.jsx)("td",{className:"p-4",children:(0,K.jsxs)("div",{className:"flex items-center gap-2",children:[(0,K.jsx)("span",{className:"font-semibold "+(e.usedQuota+20>e.quota?"text-red-600":"text-blue-700"),children:e.usedQuota})," / ",e.quota]})}),(0,K.jsxs)("td",{className:"p-4 font-bold text-orange-500",children:["Â¥",(e.balance||0).toFixed(2)]}),(0,K.jsxs)("td",{className:"p-4 text-center flex justify-center gap-3",children:[(0,K.jsx)("button",{onClick:()=>(e=>{de(e),ie(e.quota),xe(e.balance||0),ue(e.status||I.ENABLED),pe(e.expireDate||"2099-12-31")})(e),className:"text-blue-600 hover:underline text-xs bg-blue-50 px-2 py-1 rounded border border-blue-200",children:"管çå¯åä¸èµäº§"}),(0,K.jsx)("button",{onClick:()=>W(e),className:"text-blue-600 hover:underline text-xs border border-blue-200 px-2 py-1 rounded bg-blue-50",children:"äºç«¯æ°æ®éè§"})]})]},e.username)})})]})]}),"orders"===G&&(0,K.jsxs)("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden",children:[(0,K.jsx)("div",{className:"p-4 border-b bg-gray-50 text-sm",children:(0,K.jsxs)("div",{className:"flex flex-wrap gap-4 items-center justify-between",children:[(0,K.jsxs)("div",{className:"flex gap-4 items-center",children:[(0,K.jsx)("span",{className:"font-bold text-gray-800",children:"å
¨é¨å®¢æ·å稿订å"}),(0,K.jsxs)("span",{className:"text-gray-500",children:["å¾
å¤ç/å¤çä¸: ",(0,K.jsx)("span",{className:"text-orange-500 font-bold",children:ze.filter(e=>"å¾
å¤ç"===e.status||"å¤çä¸"===e.status).length})," ç¬"]})]}),(0,K.jsx)("div",{className:"flex gap-2",children:["","å¾
å¤ç","å¤çä¸","å·²åå¸","已失败","已忶"].map(e=>(0,K.jsx)("button",{onClick:()=>{$e(e),Te(1)},className:"px-3 py-1 rounded text-xs font-medium transition-colors "+(Le===e?"bg-blue-600 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:e||"å
¨é¨"},e))})]})}),(0,K.jsxs)("table",{className:"w-full text-left text-sm text-gray-600",children:[(0,K.jsx)("thead",{className:"bg-slate-50 text-gray-700 border-b border-gray-200",children:(0,K.jsxs)("tr",{children:[(0,K.jsx)("th",{className:"p-4 w-12 text-center",children:"åºå·"}),(0,K.jsx)("th",{className:"p-4 w-24",children:"åè´¦å·"}),(0,K.jsx)("th",{className:"p-4 w-1/3",children:"æäº¤æç« æ é¢"}),(0,K.jsx)("th",{className:"p-4 w-32",children:"æå®æ°é»æºåªä½"}),(0,K.jsx)("th",{className:"p-4 w-24",children:"æ£è´¹(å
)"}),(0,K.jsx)("th",{className:"p-4 w-36",children:"æäº¤æ¶é´"}),(0,K.jsx)("th",{className:"p-4 w-24 text-center",children:"ç¶æ"}),(0,K.jsx)("th",{className:"p-4 text-center",children:"å稿æä½"})]})}),(0,K.jsx)("tbody",{children:De?(0,K.jsx)("tr",{children:(0,K.jsx)("td",{colSpan:"8",className:"p-12 text-center text-gray-400",children:"å è½½ä¸..."})}):0===ze.length?(0,K.jsx)("tr",{children:(0,K.jsx)("td",{colSpan:"8",className:"p-12 text-center text-gray-400",children:"ç®å没æä»»ä½å®¢æ·æäº¤å稿订å"})}):ze.map((e,s)=>{const t="å¾
å¤ç"===e.status||"å¤çä¸"===e.status,r="å·²åå¸"===e.status;return"已失败"===e.status||e.status,(0,K.jsxs)("tr",{className:"border-b border-gray-100 hover:bg-slate-50",children:[(0,K.jsx)("td",{className:"p-4 text-center text-gray-400",children:(Ie-1)*Me+s+1}),(0,K.jsx)("td",{className:"p-4 font-bold text-gray-700",children:e.submitter_name||e.submitter_username||"-"}),(0,K.jsx)("td",{className:"p-4",children:(0,K.jsxs)("span",{onClick:()=>Se(e),className:"font-medium text-blue-700 hover:underline cursor-pointer flex items-center gap-1",children:[(0,K.jsx)(b,{size:14})," ",e.title]})}),(0,K.jsx)("td",{className:"p-4 font-bold text-blue-800",children:e.media_name||e.current_media_name||"-"}),(0,K.jsxs)("td",{className:"p-4 font-bold text-orange-500",children:["Â¥",Number(e.amount).toFixed(2)]}),(0,K.jsx)("td",{className:"p-4 text-gray-500 text-xs",children:new Date(e.submitted_at).toLocaleStr
1ing("zh-CN")}),(0,K.jsx)("td",{className:"p-4 text-center",children:(0,K.jsx)("span",{className:"px-2 py-1 rounded text-xs font-medium "+(t?"bg-orange-100 text-orange-700 animate-pulse":r?"bg-blue-100 text-blue-700":"bg-red-100 text-red-700"),children:e.status})}),(0,K.jsx)("td",{className:"p-4 text-center",children:t?(0,K.jsxs)("div",{className:"flex justify-center gap-2",children:[(0,K.jsxs)("button",{onClick:()=>{we(e),_e("")},className:"bg-gradient-to-r from-[#1a3a6b] to-[#2563eb] text-white hover:from-[#0f2847] hover:to-[#1a3a6b] px-3 py-1 rounded text-xs shadow-sm flex items-center gap-1",children:[(0,K.jsx)(C,{size:14})," å叿å"]}),(0,K.jsxs)("button",{onClick:()=>(e=>{Ue(e),Ke("")})(e),className:"bg-white border border-red-300 text-red-500 hover:bg-red-50 px-3 py-1 rounded text-xs shadow-sm flex items-center gap-1",children:[(0,K.jsx)(x,{size:14})," 驳å鿬¾"]})]}):r?e.publish_url?(0,K.jsxs)("a",{href:e.publish_url,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline text-xs flex items-center justify-center gap-1",children:[(0,K.jsx)(u,{size:14})," æ£æ¥å·²å龿¥"]}):(0,K.jsx)("span",{className:"text-gray-400 text-xs",children:"æ 龿¥"}):"已失败"===e.status?(0,K.jsx)("span",{className:"text-gray-400 text-xs cursor-help",title:e.failure_reason||"主账å·é©³å",children:"已驳å鿬¾"}):(0,K.jsx)("span",{className:"text-gray-400 text-xs",children:"已忶"})})]},e.id)})})]}),Pe>0&&(0,K.jsxs)("div",{className:"p-4 border-t border-gray-200 flex justify-center items-center gap-2",children:[(0,K.jsx)("button",{onClick:()=>Te(e=>Math.max(1,e-1)),disabled:1===Ie,className:"px-3 py-1.5 border border-gray-300 rounded text-sm text-gray-600 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"ä¸ä¸é¡µ"}),(()=>{const e=Math.ceil(Pe/Me),s=[];if(e<=7)for(let t=1;t<=e;t++)s.push(t);else Ie<=4?s.push(1,2,3,4,5,"...",e):Ie>=e-3?s.push(1,"...",e-4,e-3,e-2,e-1,e):s.push(1,"...",Ie-1,Ie,Ie+1,"...",e);return s.map((e,s)=>"..."===e?(0,K.jsx)("span",{className:"px-2 text-gray-400",children:"···"},`dots-${s}`):(0,K.jsx)("button",{onClick:()=>Te(e),className:"min-w-[32px] px-2 py-1.5 border rounded text-sm font-medium transition-colors "+(Ie===e?"bg-blue-600 text-white border-blue-600":"border-gray-300 text-gray-600 hover:bg-gray-50"),children:e},e))})(),(0,K.jsx)("button",{onClick:()=>Te(e=>Math.min(Math.ceil(Pe/Me),e+1)),disabled:Ie>=Math.ceil(Pe/Me),className:"px-3 py-1.5 border border-gray-300 rounded text-sm text-gray-600 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"ä¸ä¸é¡µ"}),(0,K.jsxs)("span",{className:"ml-4 text-sm text-gray-500",children:["å
± ",Pe," æ¡, 第 ",Ie," / ",Math.ceil(Pe/Me)," 页"]})]})]}),"clients"===G&&J&&(0,K.jsxs)("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden mb-6",children:[(0,K.jsxs)("div",{className:"p-4 border-b bg-gray-50 flex gap-4 text-sm text-gray-600",children:[(0,K.jsx)("div",{className:"font-bold text-gray-800 border-r pr-4",children:"äºç«¯æ°æ®éè§é¢æ¿"}),(0,K.jsxs)("div",{children:["åè´¦å·: ",(0,K.jsx)("span",{className:"font-bold text-blue-600",children:J.username})]}),(0,K.jsxs)("div",{children:["äºç«¯å·²åé¿å°¾è¯æ°: ",(0,K.jsxs)("span",{className:"font-bold text-blue-600",children:[(J.keywords||[]).length," 个"]})]}),(0,K.jsxs)("div",{children:["äºç«¯å·²åæç« æ°: ",(0,K.jsxs)("span",{className:"font-bold text-blue-600",children:[J.articles.length," ç¯"]})]})]}),(0,K.jsxs)("div",{className:"p-4",children:[(0,K.jsx)("h4",{className:"text-sm font-bold text-gray-700 mb-2 border-l-4 border-blue-600 pl-2",children:"æååºçä¸å¡é¿å°¾è¯"}),(0,K.jsx)("div",{className:"flex flex-wrap gap-2 mb-6",children:J.keywords&&0!==J.keywords.length?J.keywords.map((e,s)=>(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 text-blue-700 px-3 py-1 rounded-full text-xs font-medium",children:e},s)):(0,K.jsx)("span",{className:"text-xs text-gray-400",children:"å®¢æ·ææªé
置任ä½å
³é®è¯"})}),(0,K.jsx)("h4",{className:"text-sm font-bold text-gray-700 mb-2 border-l-4 border-blue-600 pl-2",children:"çæçä¼è´¨æç« åæ¡£"}),(0,K.jsxs)("table",{className:"w-full text-left text-sm text-gray-600 border border-gray-100",children:[(0,K.jsx)("thead",{className:"bg-slate-50 text-gray-700 border-b border-gray-200",children:(0,K.jsxs)("tr",{children:[(0,K.jsx)("th",{className:"p-3 w-16",children:"åºå·"}),(0,K.jsx)("th",{className:"p-3",children:"æç« æ é¢ (AIç´åºå¹¶åæ¥äºç«¯)"}),(0,K.jsx)("th",{className:"p-3 text-center",children:"ç¶æ"}),(0,K.jsx)("th",{className:"p-3 text-center",children:"æä½"})]})}),(0,K.jsx)("tbody",{children:0===J.articles.length?(0,K.jsx)("tr",{children:(0,K.jsx)("td",{colSpan:"4",className:"p-12 text-center text-gray-400",children:"è¯¥å®¢æ·ææªçæä»»ä½æç« "})}):J.articles.map((e,s)=>(0,K.jsxs)("tr",{className:"border-b border-gray-100 hover:bg-slate-50",children:[(0,K.jsx)("td",{className:"p-3",children:s+1}),(0,K.jsx)("td",{className:"p-3 font-medium text-gray-800",children:e.title}),(0,K.jsx)("td",{className:"p-3 text-center",children:(0,K.jsx)("span",{className:"bg-blue-50 text-blue-600 px-2 py-1 rounded text-xs",children:e.status})}),(0,K.jsx)("td",{className:"p-3 text-center",children:(0,K.jsx)("button",{onClick:()=>Se(e),className:"text-blue-600 text-xs border border-blue-200 px-2 py-1 rounded hover:bg-blue-50",children:"é¢è§å
容"})})]},e.id))})]})]})]}),"api"===G&&(0,K.jsx)(M,{showToast:k}),"platforms"===G&&(0,K.jsxs)("div",{className:"bg-white p-8 rounded-xl shadow-sm border border-gray-200 max-w-4xl",children:[(0,K.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,K.jsxs)("div",{children:[(0,K.jsx)("h3",{className:"text-lg font-medium text-gray-800 border-l-4 border-blue-600 pl-3",children:"åå¸å¹³å°ä¸è·³è½¬é¾æ¥ç®¡ç"}),(0,K.jsxs)("p",{className:"text-sm text-gray-500 mt-2 pl-4",children:["卿¤å¤é
置平å°åï¼åè´¦å·å°å¨ãåå¸ç³»ç»ãä¸çå°è¿äºå¹³å°æé®ãåè´¦å·",(0,K.jsx)("span",{className:"font-bold text-red-500",children:"æ æ³çå°"}),'åºå±çå®URLï¼ç¹å»æé®å³ä¼"æé¾"èªå¨è·³è½¬ã']})]}),(0,K.jsxs)("button",{onClick:()=>Y([...X,{id:"p_"+Date.now(),name:"æ°å»ºååå¹³å°",url:"https://"}]),className:"text-sm bg-gradient-to-r from-[#1a3a6b] to-[#2563eb] text-white px-4 py-2 rounded-lg hover:from-[#0f2847] hover:to-[#1a3a6b] flex items-center gap-1 shadow-sm",children:[(0,K.jsx)(j,{size:16})," æ·»å åå¸å¹³å°"]})]}),(0,K.jsx)("div",{className:"space-y-3 mb-8",children:0===X.length?(0,K.jsx)("div",{className:"text-center p-8 text-gray-400 border border-dashed border-gray-300 rounded-lg",children:"ææ å¹³å°é
ç½®"}):X.map(e=>(0,K.jsxs)("div",{className:"flex items-center gap-4 p-4 rounded-lg border border-gray-200 bg-gray-50",children:[(0,K.jsxs)("div",{className:"w-1/3",children:[(0,K.jsxs)("label",{className:"block text-xs text-gray-500 mb-1",children:["å¹³å°å¯¹å¤å±ç¤ºåç§° ",(0,K.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,K.jsx)("input",{type:"text",value:e.name,onChange:s=>Qe(e.id,"name",s.target.value),className:"w-full border border-gray-300 rounded px-3 py-2 outline-none focus:border-blue-500 text-sm font-medium text-gray-800",placeholder:"å¦ï¼å¤´æ¡å·åä½è
åå°"})]}),(0,K.jsxs)("div",{className:"flex-1",children:[(0,K.jsxs)("label",{className:"block text-xs text-gray-500 mb-1",children:["åºå±è·³è½¬é¾æ¥ (éè URL) ",(0,K.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,K.jsxs)("div",{className:"relative",children:[(0,K.jsx)(g,{size:14,className:"absolute left-3 top-3 text-gray-400"}),(0,K.jsx)("input",{type:"url",value:e.url,onChange:s=>Qe(e.id,"url",s.target.value),className:"w-full border border-gray-300 rounded px-3 pl-8 py-2 outline-none focus:border-blue-500 text-sm text-gray-600 font-mono",placeholder:"https://..."})]})]}),(0,K.jsx)("div",{className:"flex items-center pt-5 px-2",children:(0,K.jsx)("button",{onClick:()=>{return s=e.id,Y(X.filter(e=>e.id!==s));var s},className:"text-gray-400 hover:text-red-500",title:"å é¤å¹³å°",children:(0,K.jsx)(S,{size:18})})})]},e.id))}),(0,K.jsx)("div",{className:"pt-4 border-t border-gray-100 text-right",children:(0,K.jsx)("button",{onClick:()=>{s(e=>({...e,publishPlatforms:X})),k("ååå¹³å°é
置已ä¿åï¼å·²åæ¥äºç«¯åä¸åè³åè´¦å·ï¼")},className:"bg-gradient-to-r from-[#1a3a6b] to-[#2563eb] hover:from-[#0f2847] hover:to-[#1a3a6b] text-white px-8 py-2.5 rounded-lg shadow font-medium",children:"å
¨éä¿å并忥äºç«¯ä¸å"})})]}),"newsSources"===G&&(0,K.jsxs)("div",{className:"bg-white p-8 rounded-xl shadow-sm border border-gray-200",children:[(0,K.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,K.jsxs)("div",{children:[(0,K.jsx)("h3",{className:"text-lg font-medium text-gray-800 border-l-4 border-blue-600 pl-3",children:"æ°é»æºåå¸åªä½ç®¡ç"}),(0,K.jsx)("p",{className:"text-sm text-gray-500 mt-2 pl-4",children:"é
ç½®æ°é»æºåªä½ï¼åè´¦å·å¯å¨åå¸ç³»ç»ä¸æ£ç´¢å¹¶æ¶èä½é¢è¿è¡å稿ä¸åãä¿®æ¹å³æ¶çæï¼æ éæå¨ä¿åã"})]}),(0,K.jsxs)("button",{onClick:async()=>{le(!0);try{const e=await E("/media-platforms",{method:"POST",body:{name:"",category:"æ°é»èµè®¯",region:"å
¨å½",price:0,url:"",index_type:"ç½é¡µæ¶å½",description:""}});e?.success?await Re():k(e?.error||"æ·»å 失败")}catch(e){k("æ·»å åªä½å¤±è´¥")}finally{le(!1)}},disabled:ae,className:"text-sm bg-gradient-to-r from-[#1a3a6b] to-[#2563eb] text-white px-4 py-2 rounded-lg hover:from-[#0f2847] hover:to-[#1a3a6b] flex items-center gap-1 shadow-sm disabled:opacity-50",children:[(0,K.jsx)(j,{size:16})," æ·»å æ°é»æºåªä½"]})]}),te?(0,K.jsx)("div",{className:"text-center py-12 text-gray-400",children:"å è½½ä¸..."}):(0,K.jsx)("div",{className:"overflow-x-auto border border-gray-200 rounded-lg mb-8",children:(0,K.jsxs)("table",{className:"w-full text-left text-sm whitespace-nowrap min-w-[1100px]",children:[(0,K.jsx)("thead",{className:"bg-gray-50 text-gray-700 border-b border-gray-200",children:(0,K.jsxs)("tr",{children:[(0,K.jsx)("th",{className:"p-3 w-28",children:"åªä½ç±»å"}),(0,K.jsx)("th",{className:"p-3 w-24",children:"åºå"}),(0,K.jsx)("th",{className:"p-3 w-32",children:"åªä½åç§°"}),(0,K.jsx)("th",{className:"p-3 w-24",children:"æ£è´¹ä»·æ ¼(å
)"}),(0,K.jsx)("th",{className:"p-3 w-40",children:"ç½ç«æ¡ä¾(URL)"}),(0,K.jsx)("th",{className:"p-3 w-32",children:"æ¶å½ç±»å"}),(0,K.jsx)("th",{className:"p-3 w-48",children:"夿³¨"}),(0,K.jsx)("th",{className:"p-3 w-20 text-center",children:"ç¶æ"}),(0,K.jsx)("th",{className:"p-3 w-16 text-center",children:"æä½"})]})}),(0,K.jsx)("tbody",{children:0===ee.length?(0,K.jsx)("tr",{children:(0,K.jsx)("td",{colSpan:"9",className:"p-12 text-center text-gray-400",children:"ææ æ°é»æºåªä½ï¼è¯·æ·»å "})}):ee.map(e=>(0,K.jsxs)("tr",{className:"border-b border-gray-100 hover:bg-gray-50 "+("å·²åç¨"===e.status?"opacity-50":""),children:[(0,K.jsx)("td",{className:"p-2",children:(0,K.jsx)("input",{type:"text",value:e.category||"",onChange:s=>Ge(e.id,"category",s.target.value),className:"w-full border border-gray-300 rounded px-2 py-1 outline-none focus:border-blue-500 text-sm",placeholder:"æ°é»èµè®¯"})}),(0,K.jsx)("td",{className:"p-2",children:(0,K.jsx)("input",{type:"text",value:e.region||"",onChange:s=>Ge(e.id,"region",s.target.value),className:"w-full border border-gray-300 rounded px-2 py-1 outline-none focus:border-blue-500 text-sm",placeholder:"å
¨å½"})}),(0,K.jsx)("td",{className:"p-2",children:(0,K.jsx)("input",{type:"text",value:e.name||"",onChange:s=>Ge(e.id,"name",s.target.value),className:"w-full border border-gray-300 rounded px-2 py-1 outline-none focus:border-blue-500 text-sm font-medium",placeholder:"åªä½åç§°"})}),(0,K.jsx)("td",{className:"p-2",children:(0,K.jsx)("input",{type:"number",value:e.price??0,onChange:s=>Ge(e.id,"price",parseFloat(s.target.value)||0),className:"w-full border border-gray-300 rounded px-2 py-1 outline-none focus:border-blue-500 text-sm text-orange-600 font-bold"})}),(0,K.jsx)("td",{className:"p-2",children:(0,K.jsx)("input",{type:"url",value:e.url||"",onChange:s=>Ge(e.id,"url",s.target.value),className:"w-full border border-gray-300 rounded px-2 py-1 outline-none focus:border-blue-500 text-sm font-mono text-gray-500",placeholder:"http://..."})}),(0,K.jsx)("td",{className:"p-2",children:(0,K.jsx)("input",{type:"text",value:e.index_type||"",onChange:s=>Ge(e.id,"index_type",s.target.value),className:"w-full border border-gray-300 rounded px-2 py-1 outline-none focus:border-blue-500 text-sm",placeholder:"ç½é¡µæ¶å½"})}),(0,K.jsx)("td",{className:"p-2",children:(0,K.jsx)("input",{type:"text",value:e.description||"",onChange:s=>Ge(e.id,"description",s.target.value),className:"w-full border border-gray-300 rounded px-2 py-1 outline-none focus:border-blue-500 text-sm text-gray-500",placeholder:"夿³¨ä¿¡æ¯"})}),(0,K.jsx)("td",{className:"p-2 text-center",children:(0,K.jsx)("button",{onClick:()=>Ge(e.id,"status","å¯ç¨"===e.status?"å·²åç¨":"å¯ç¨"),className:"px-2 py-1 rounded text-xs font-medium "+("å¯ç¨"===e.status?"bg-green-100 text-green-700":"bg-gray-100 text-gray-500"),children:"å¯ç¨"===e.status?"å¯ç¨":"å·²åç¨"})}),(0,K.jsx)("td",{className:"p-2 text-center",children:(0,K.jsx)("button",{onClick:()=>(async e=>{le(!0);try{const s=await E(`/media-platforms/${e}`,{method:"DELETE"});s?.success?await Re():k(s?.error||"å é¤å¤±è´¥")}catch(s){k("å é¤åªä½å¤±è´¥")}finally{le(!1)}})(e.id),className:"text-gray-400 hover:text-red-500 p-1",disabled:ae,children:(0,K.jsx)(S,{size:16,className:"mx-auto"})})})]},e.id))})]})})]}),"template"===G&&(0,K.jsxs)("div",{className:"flex gap-6 h-[calc(100vh-180px)]",children:[(0,K.jsxs)("div",{className:"w-1/3 bg-white rounded-xl shadow-sm border border-gray-200 flex flex-col overflow-hidden shrink-0",children:[(0,K.jsxs)("div",{className:"p-4 border-b border-gray-100 flex justify-between items-center bg-gray-50",children:[(0,K.jsx)("span",{className:"font-bold text-gray-700",children:"模æ¿ç±»ç®åç»"}),(0,K.jsxs)("button",{onClick:()=>{const e={id:"cat_"+Date.now(),mainCategory:"æ°å»ºå¤§ç±»",subCategory:"æ°å»ºå°ç±»",templates:[{id:"t_"+Date.now(),name:"æ°å»ºæç« 模æ¿",content:"请è¾å
¥æ¨¡æ¿ç³»ç»æä»¤...\næ¬æ¬¡æ ¸å¿æ°åé¿å°¾è¯: {å½åæ°å主è¯}"}]};s(s=>({...s,templates:[...s.templates,e]})),Ne(e)},className:"text-sm bg-white border border-blue-600 text-blue-600 px-3 py-1 rounded hover:bg-blue-50 flex items-center gap-1",children:[(0,K.jsx)(j,{size:14})," æ°å¢ç±»ç®"]})]}),(0,K.jsxs)("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:[e.templates.map(e=>(0,K.jsxs)("div",{onClick:()=>Ne(e),className:"p-3 rounded-lg border cursor-pointer transition-all flex flex-col gap-1 group "+(je?.id===e.id?"bg-blue-50 border-blue-500":"border-gray-200 hover:border-blue-300"),children:[(0,K.jsxs)("div",{className:"flex justify-between items-center",children:[(0,K.jsx)("span",{className:"font-bold "+(je?.id===e.id?"text-blue-800":"text-gray-700"),children:e.subCategory}),(0,K.jsx)("button",{onClick:t=>{var r;t.stopPropagation(),r=e.id,s(e=>{const s=e.templates.filter(e=>e.id!==r);return je?.id===r&&Ne(s[0]||null),{...e,templates:s}}),k("æ´ä¸ªç±»ç®åå
鍿¨¡æ¿å·²å é¤")},className:"text-red-300 hover:text-red-600 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,K.jsx)(S,{size:16})})]}),(0,K.jsxs)("div",{className:"flex justify-between items-center mt-1",children:[(0,K.jsx)("span",{className:"text-xs bg-gray-100 px-1.5 py-0.5 rounded text-gray-500",children:e.mainCategory}),(0,K.jsxs)("span",{className:"text-xs text-blue-600 font-medium",children:["å
å« ",e.templates.length," 个模æ¿"]})]})]},e.id)),0===e.templates.length&&(0,K.jsx)("div",{className:"text-center text-gray-400 text-sm mt-10",children:"ææ ç±»ç®ï¼è¯·æ°å¢"})]})]}),(0,K.jsx)("div",{className:"flex-1 bg-white rounded-xl shadow-sm border border-gray-200 flex flex-col overflow-hidden",children:je?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)("div",{className:"p-6 border-b border-gray-100 bg-gray-50",children:(0,K.jsxs)("div",{className:"flex gap-4",children:[(0,K.jsxs)("div",{className:"flex-1",children:[(0,K.jsxs)("label
1",{className:"block text-sm font-medium text-gray-700 mb-1",children:["大类ç®åç§° ",(0,K.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,K.jsx)("input",{type:"text",value:je.mainCategory,onChange:e=>Ne({...je,mainCategory:e.target.value}),className:"w-full border border-gray-300 rounded-lg p-2 focus:ring-2 focus:ring-blue-500 outline-none text-sm",placeholder:"ä¾å¦ï¼éç¨è¥é"})]}),(0,K.jsxs)("div",{className:"flex-1",children:[(0,K.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["å°ç±»ç®åç§° ",(0,K.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,K.jsx)("input",{type:"text",value:je.subCategory,onChange:e=>Ne({...je,subCategory:e.target.value}),className:"w-full border border-gray-300 rounded-lg p-2 focus:ring-2 focus:ring-blue-500 outline-none text-sm",placeholder:"ä¾å¦ï¼åçå®£ä¼ "})]})]})}),(0,K.jsxs)("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[(0,K.jsxs)("div",{className:"flex justify-between items-center",children:[(0,K.jsx)("h4",{className:"font-bold text-gray-800 border-l-4 border-blue-600 pl-2",children:"该类ç®ä¸çå
·ä½æç« 模æ¿é
ç½®"}),(0,K.jsxs)("button",{onClick:()=>Ne(e=>({...e,templates:[...e.templates,{id:"t_"+Date.now(),name:"æ°å¢æ¨¡æ¿é项",content:""}]})),className:"text-sm text-blue-600 hover:text-blue-800 flex items-center gap-1 font-medium bg-blue-50 px-3 py-1 rounded-md",children:[(0,K.jsx)(j,{size:14})," æ·»å ä¸ä¸ªæ°æ¨¡æ¿é项"]})]}),je.templates.map(e=>(0,K.jsxs)("div",{className:"p-5 border border-gray-200 rounded-xl bg-white shadow-sm relative",children:[(0,K.jsx)("div",{className:"absolute top-4 right-4",children:(0,K.jsx)("button",{onClick:()=>{return s=e.id,Ne(e=>({...e,templates:e.templates.filter(e=>e.id!==s)}));var s},className:"text-gray-400 hover:text-red-500",title:"å é¤è¯¥æ¨¡æ¿",children:(0,K.jsx)(S,{size:18})})}),(0,K.jsxs)("div",{className:"mb-4 pr-8",children:[(0,K.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["模æ¿å¯¹å¤åç§° (ä¾åè´¦å·éæ©æ¶æ¾ç¤º) ",(0,K.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,K.jsx)("input",{type:"text",value:e.name,onChange:s=>He(e.id,"name",s.target.value),className:"w-full border border-gray-300 rounded-lg p-2 focus:ring-2 focus:ring-blue-500 outline-none font-bold text-blue-800 bg-blue-50/30",placeholder:"ä¾å¦ï¼é»è®¤è¥éæ åç"})]}),(0,K.jsxs)("div",{children:[(0,K.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["æç« åºå±æç¤ºè¯æä»¤ / Prompt (对åè´¦å·",(0,K.jsx)("span",{className:"text-red-500 font-bold",children:"å®å
¨éè"}),")"]}),(0,K.jsx)("textarea",{rows:5,value:e.content,onChange:s=>He(e.id,"content",s.target.value),className:"w-full border border-gray-300 rounded-lg p-3 focus:ring-2 focus:ring-blue-500 outline-none font-mono text-sm leading-relaxed resize-none bg-slate-50",placeholder:"请è¾å
¥åè¯AIåºè¯¥å¦ä½å©ç¨ä¸é¢è¿äºä¼ä¸åéå»åæç« çæä»¤..."})]})]},e.id)),0===je.templates.length&&(0,K.jsx)("div",{className:"text-center p-8 text-gray-400 border border-dashed border-gray-300 rounded-lg",children:"请ç¹å»å³ä¸æ¹æé®æ·»å 模æ¿é项"})]}),(0,K.jsxs)("div",{className:"p-4 border-t border-gray-100 bg-white flex justify-between items-center shrink-0",children:[(0,K.jsxs)("div",{className:"text-xs text-blue-600 flex gap-2 items-center flex-wrap max-w-2xl",children:[(0,K.jsx)("span",{className:"text-gray-500 font-bold",children:"注å
¥åé大å
¨ï¼"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{å
¬å¸åç§°}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{æå¤è¡ä¸}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{ç«äºå¯¹æ}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{èç³»çµè¯}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{å®ç½å°å}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{ä¼ä¸å®ä½}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{ä¼ä¸ä»ç»}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{ä¿¡ä»»è书}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{客æ·ç»å}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{客æ·çç¹}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{产åä»ç»}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{产åæå¡}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{å®åæå¡}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{å®¢æ·æ¡ä¾}"}),(0,K.jsx)("span",{className:"bg-blue-50 border border-blue-100 px-1.5 py-0.5 rounded",children:"{å
¶ä»ä¿¡æ¯}"}),(0,K.jsx)("span",{className:"bg-orange-50 border border-orange-200 text-orange-700 px-1.5 py-0.5 rounded font-bold",children:"{å½åæ°å主è¯}"})]}),(0,K.jsx)("button",{onClick:()=>je.mainCategory.trim()&&je.subCategory.trim()?0===je.templates.length?k("请è³å°ä¸ºè¯¥ç±»ç®æ·»å ä¸ä¸ªå
·ä½æç« 模æ¿"):(s(e=>{const s=e.templates.map(e=>e.id===je.id?je:e);return{...e,templates:s}}),void k("ç±»ç®å模æ¿é
置已ä¿å并忥è³äºç«¯ï¼")):k("大类ç®åå°ç±»ç®ä¸è½ä¸ºç©º"),className:"bg-gradient-to-r from-[#1a3a6b] to-[#2563eb] hover:from-[#0f2847] hover:to-[#1a3a6b] text-white px-8 py-3 rounded-lg shadow font-medium shrink-0 ml-4",children:"忥ä¿åè³äºç«¯æ°æ®åº"})]})]}):(0,K.jsx)("div",{className:"flex-1 flex items-center justify-center text-gray-400",children:"请å¨å·¦ä¾§éæ©ææ°å¢ä¸ä¸ªç±»ç®åç»"})})]}),"tenants"===G&&(0,K.jsx)("div",{children:"brandConfig"===L?(0,K.jsx)(B,{showToast:k}):"quotaStats"===L?(0,K.jsx)(U,{showToast:k}):"subAccountSummary"===L?(0,K.jsx)(U,{showSubAccountSummary:!0,showToast:k}):(0,K.jsxs)("div",{className:"space-y-6",children:[(0,K.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,K.jsxs)("button",{onClick:()=>Q(T.dashboard()),className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm transition-colors "+(L?"bg-gray-100 text-gray-600 hover:bg-gray-200":"bg-gradient-to-r from-[#1a3a6b] to-[#2563eb] text-white"),children:[(0,K.jsx)(D,{size:16})," ç§æ·å表"]}),(0,K.jsxs)("button",{onClick:()=>Q("/admin/tenants.html?detail=subAccountSummary"),className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm transition-colors "+("subAccountSummary"===L?"bg-gradient-to-r from-[#1a3a6b] to-[#2563eb] text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"),children:[(0,K.jsx)(d,{size:16})," åè´¦å·æ¶èæç»"]})]}),(0,K.jsx)($,{showToast:k}),(0,K.jsx)(U,{showAllTenants:!0,showToast:k})]})})]}),(0,K.jsx)("div",{className:"mt-8 pt-4 border-t border-gray-200 text-xs text-gray-400 shrink-0",children:"çæææÂ©ä¸è森辰çµåå塿éå
¬å¸"})]})]})]})};export{O as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.