@becomeopc/trendpublish 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/assets/{-association-list-CE--B0dM.js → -association-list-MaFlvvF5.js} +1 -1
- package/dashboard/assets/-channel-templates-B0KzH4gz.js +6 -0
- package/dashboard/assets/{-content-package-preview-DC4PLY9G.js → -content-package-preview-Bc225W8p.js} +1 -1
- package/dashboard/assets/-editor-page-DIrPd6Jj.js +1 -0
- package/dashboard/assets/-run-detail-view-CSb6Mp_W.js +12 -0
- package/dashboard/assets/{AnimatePresence-OeIRE0Xw.js → AnimatePresence-dRKyi9jP.js} +1 -1
- package/dashboard/assets/_app-C0k3Jpvj.js +1 -0
- package/dashboard/assets/app-dialog-CBRjH8y0.js +1 -0
- package/dashboard/assets/arrow-left-B1paVsKl.js +1 -0
- package/dashboard/assets/arrow-right-Bm6j4CRT.js +1 -0
- package/dashboard/assets/{articles-Bw-jie6T.js → articles-CJ24swVV.js} +1 -1
- package/dashboard/assets/automations-CSqhc87N.js +2 -0
- package/dashboard/assets/becomeopc-EvwYWHkB.js +1 -0
- package/dashboard/assets/check-_AvUITNy.js +1 -0
- package/dashboard/assets/chevron-down-CjEG9BtO.js +1 -0
- package/dashboard/assets/chevron-right-BcV2-ijN.js +1 -0
- package/dashboard/assets/connections-CUkG-3WF.js +1 -0
- package/dashboard/assets/content-plans-1_S1hkDo.js +1 -0
- package/dashboard/assets/content-plans_._planId.edit-2sqaHVmd.js +1 -0
- package/dashboard/assets/content-plans_.new-2sqaHVmd.js +1 -0
- package/dashboard/assets/{copy-CWp2fj5q.js → copy-C4Adx2li.js} +1 -1
- package/dashboard/assets/dropdown-menu-mpdg8__C.js +1 -0
- package/dashboard/assets/empty-state-B2PGtu_a.js +1 -0
- package/dashboard/assets/entity-list-B2WXTDDM.js +1 -0
- package/dashboard/assets/external-link-B2pLgsIl.js +1 -0
- package/dashboard/assets/{eye-Drma9Anf.js → eye-DyaLFyNg.js} +1 -1
- package/dashboard/assets/{file-text-BSOvvVFv.js → file-text-BqjzSiui.js} +1 -1
- package/dashboard/assets/{fingerprint-pattern-C_dvDw0n.js → fingerprint-pattern-CVznkwfS.js} +1 -1
- package/dashboard/assets/{flask-conical-DpX8Ww6S.js → flask-conical-B9Pn4z-3.js} +1 -1
- package/dashboard/assets/form-field-BJITE8Lh.js +1 -0
- package/dashboard/assets/identities-Bpb-f7oo.js +3 -0
- package/dashboard/assets/index-Bx1uywm3.js +51 -0
- package/dashboard/assets/index-ghPnBUnR.css +2 -0
- package/dashboard/assets/{input-D7j_2GhD.js → input-Br6N0XCJ.js} +1 -1
- package/dashboard/assets/jobs-BiQwL4Yt.js +1 -0
- package/dashboard/assets/jobs_._runId-DQ9L-G8H.js +1 -0
- package/dashboard/assets/knowledge-BePtU9f6.js +1 -0
- package/dashboard/assets/{layers-BHAmPdjS.js → layers-B6jc9X_5.js} +1 -1
- package/dashboard/assets/{layout-template-_-9A39QH.js → layout-template-11JYpJ5n.js} +1 -1
- package/dashboard/assets/library-BlLpV8Oh.js +1 -0
- package/dashboard/assets/{newspaper-Dcqy9j6N.js → newspaper-BF6EkBWC.js} +1 -1
- package/dashboard/assets/notifications-wLr7xSyr.js +1 -0
- package/dashboard/assets/page-grid-BR5GG4AN.js +1 -0
- package/dashboard/assets/pagination-CEYfdE0s.js +1 -0
- package/dashboard/assets/play-DYoZjslk.js +1 -0
- package/dashboard/assets/plus-DewHiaw6.js +1 -0
- package/dashboard/assets/publication-destination-picker-DAgQcLxS.js +1 -0
- package/dashboard/assets/publishing-DOrwrfAd.js +1 -0
- package/dashboard/assets/publishing_.styles-DUnbtaS6.js +1 -0
- package/dashboard/assets/publishing_.templates-pMvBK24N.js +1 -0
- package/dashboard/assets/{publishing_.templates_.sessions._sessionId-BKbSHrpn.js → publishing_.templates_.sessions._sessionId-FkykBbtF.js} +1 -1
- package/dashboard/assets/{radio-tower-tBHGxqPI.js → radio-tower-CS59Tvfq.js} +1 -1
- package/dashboard/assets/{react-ByivFozR.js → react-OqyHmgtK.js} +1 -1
- package/dashboard/assets/refresh-cw-BB9_0X86.js +1 -0
- package/dashboard/assets/{routes-zvPXw-Ia.js → routes-15GLqJa6.js} +1 -1
- package/dashboard/assets/{runs-DiLk0fOQ.js → runs-Cbz28Mf6.js} +1 -1
- package/dashboard/assets/{select-BUT5ahxS.js → select-9cx3otc_.js} +1 -1
- package/dashboard/assets/{settings-BZ3KUyq9.js → settings-CeJjvt-K.js} +1 -1
- package/dashboard/assets/sources-CsuPzTTH.js +1 -0
- package/dashboard/assets/{sparkles-ws1IsiGt.js → sparkles-C9YU6Kr5.js} +1 -1
- package/dashboard/assets/{sse-_t5PeRmk.js → sse-DQK6eHXZ.js} +2 -2
- package/dashboard/assets/tabs-DdmTx_k0.js +1 -0
- package/dashboard/assets/{textarea-B7N7g6fl.js → textarea-zbjD4aac.js} +1 -1
- package/dashboard/assets/{trash-2-C3dbRhyb.js → trash-2-CcgFunKh.js} +1 -1
- package/dashboard/assets/{use-onboarding-muxucTEZ.js → use-onboarding-fKNsbNhX.js} +1 -1
- package/dashboard/assets/use-workspace-snapshot-MZKeTfAJ.js +1 -0
- package/dashboard/assets/{useMutation-C221JCx3.js → useMutation-Xdq_89ou.js} +1 -1
- package/dashboard/assets/{workspace-DGt_GyLc.js → workspace-XH4e6E59.js} +1 -1
- package/dashboard/assets/{wrench-BHwKK2nB.js → wrench-C9HmhR9v.js} +1 -1
- package/dashboard/index.html +2 -2
- package/dist/app.js +1248 -399
- package/package.json +1 -1
- package/dashboard/assets/-channel-templates-CdLCNDrC.js +0 -6
- package/dashboard/assets/-editor-page-CS5uk_2L.js +0 -1
- package/dashboard/assets/-run-detail-view-Csh1ek6d.js +0 -12
- package/dashboard/assets/_app-Bci0KgUT.js +0 -1
- package/dashboard/assets/app-dialog-ChNc5zc0.js +0 -1
- package/dashboard/assets/arrow-left-BQWrTPzt.js +0 -1
- package/dashboard/assets/arrow-right-Da_6qwwr.js +0 -1
- package/dashboard/assets/automations-JF7dpk0H.js +0 -2
- package/dashboard/assets/check-C6hl-XsU.js +0 -1
- package/dashboard/assets/chevron-down-DXrCAjpz.js +0 -1
- package/dashboard/assets/chevron-right-okm7Mcup.js +0 -1
- package/dashboard/assets/connections-D_OfbK5O.js +0 -1
- package/dashboard/assets/content-plans-CmaGhnXT.js +0 -1
- package/dashboard/assets/content-plans_._planId.edit-BPCAxR7I.js +0 -1
- package/dashboard/assets/content-plans_.new-BPCAxR7I.js +0 -1
- package/dashboard/assets/dropdown-menu-BR9kBDP8.js +0 -1
- package/dashboard/assets/entity-list-C7fEITZj.js +0 -1
- package/dashboard/assets/form-field-BbOl9sGR.js +0 -1
- package/dashboard/assets/identities-B2SMnjY3.js +0 -3
- package/dashboard/assets/index-DC7b8xgR.js +0 -51
- package/dashboard/assets/index-pqOc3FQv.css +0 -2
- package/dashboard/assets/jobs-WwmifsK9.js +0 -1
- package/dashboard/assets/jobs_._runId-BZsBpBT-.js +0 -1
- package/dashboard/assets/knowledge-CnqdN8mY.js +0 -1
- package/dashboard/assets/library-Bo-F96xG.js +0 -1
- package/dashboard/assets/notifications-Dlx9WRAf.js +0 -1
- package/dashboard/assets/page-grid-x4teY0Qb.js +0 -1
- package/dashboard/assets/pagination-BIxivGX2.js +0 -1
- package/dashboard/assets/play-CqRcIakP.js +0 -1
- package/dashboard/assets/plus-Cgi-AlzH.js +0 -1
- package/dashboard/assets/publication-destination-picker-p0aE3sNP.js +0 -1
- package/dashboard/assets/publishing-DYavJU0X.js +0 -1
- package/dashboard/assets/publishing_.styles-DfbwPHCg.js +0 -1
- package/dashboard/assets/publishing_.templates-DoOVohr6.js +0 -1
- package/dashboard/assets/sources-DaQA2K6Y.js +0 -1
- package/dashboard/assets/tabs-DT--ZcFL.js +0 -1
- package/dashboard/assets/use-workspace-snapshot-CZmWKC_d.js +0 -1
- package/dashboard/assets/useQuery-CH_PyDWC.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{F as t,Ft as n,N as r,P as i,Pt as a,Q as o,U as s,W as c,X as l,Y as u,Z as d,et as f,ln as p,nn as m,q as h,sn as g}from"./index-DC7b8xgR.js";import{t as _}from"./useQuery-CH_PyDWC.js";import{t as v}from"./useMutation-C221JCx3.js";import{a as y,i as b,n as x,o as S,r as C,t as ee}from"./select-BUT5ahxS.js";import{a as w,i as T,n as E,o as D,r as O,t as k}from"./dropdown-menu-BR9kBDP8.js";import{n as A,t as j}from"./entity-list-C7fEITZj.js";import{t as M}from"./arrow-left-BQWrTPzt.js";import{n as N,r as P,t as F}from"./wrench-BHwKK2nB.js";import{t as I}from"./check-C6hl-XsU.js";import{t as L}from"./chevron-down-DXrCAjpz.js";import{n as te,t as ne}from"./pagination-BIxivGX2.js";import{t as re}from"./chevron-right-okm7Mcup.js";import{t as R}from"./eye-Drma9Anf.js";import{t as ie}from"./file-text-BSOvvVFv.js";import{t as ae}from"./layers-BHAmPdjS.js";import{t as oe}from"./plus-Cgi-AlzH.js";import{o as se,r as ce}from"./articles-Bw-jie6T.js";import{a as le,i as ue,n as de,o as fe,r as pe,s as me,t as he}from"./app-dialog-ChNc5zc0.js";import{t as ge}from"./input-D7j_2GhD.js";import{n as _e,t as ve}from"./react-ByivFozR.js";import{t as ye}from"./AnimatePresence-OeIRE0Xw.js";import{n as be}from"./use-workspace-snapshot-CZmWKC_d.js";import{t as z}from"./textarea-B7N7g6fl.js";import{t as B}from"./form-field-BbOl9sGR.js";import{r as V,t as H}from"./notifications-Dlx9WRAf.js";import{t as xe}from"./page-grid-x4teY0Qb.js";import"./types-D57tnOAh.js";import{t as Se}from"./tabs-DT--ZcFL.js";import{n as U,t as Ce}from"./sse-_t5PeRmk.js";var we=u(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Te=u(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Ee=u(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),De=u(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Oe=u(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),ke=u(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),Ae=u(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),je=u(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),Me=u(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Ne=u(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Pe=u(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),W={Active:`active`,Completed:`completed`,Incompatible:`incompatible`,Archived:`archived`},Fe={Running:`running`,Completed:`completed`,Interrupted:`interrupted`,Failed:`failed`},Ie={ClientCancelled:`client_cancelled`,ConnectionInterrupted:`connection_interrupted`,ExecutionFailed:`execution_failed`,RuntimeRestarted:`runtime_restarted`,TurnConflict:`turn_conflict`,ProtocolMismatch:`protocol_mismatch`},G={TurnStarted:`turn.started`,TurnCompleted:`turn.completed`,TurnInterrupted:`turn.interrupted`,TurnFailed:`turn.failed`,UserMessage:`message.user`,AssistantMessage:`message.assistant`,Question:`question.proposed`,Answer:`answer.user`,ToolStarted:`tool.started`,ToolCompleted:`tool.completed`,ToolFailed:`tool.failed`,ArtifactProposed:`artifact.proposed`,ArtifactSelected:`artifact.selected`,ArtifactPreviewed:`artifact.previewed`,ArtifactConfirmed:`artifact.confirmed`},K={SingleSelect:`single_select`,MultiSelect:`multi_select`,Text:`text`,UrlList:`url_list`,Confirm:`confirm`};function Le(e){let t=[],n=[],r=/<\/?think>/gi,i=0,a=!1;for(let o of e.matchAll(r)){let r=o.index??i;(a?n:t).push(e.slice(i,r)),a=!o[0].startsWith(`</`),i=r+o[0].length}return(a?n:t).push(e.slice(i)),{message:t.join(``),thinking:n.join(`
|
|
2
|
-
`).trim()}}var Re=(e,t,n=1,a=20)=>i(r.api[`channel-templates`].$get({query:{channel:e,publicationType:t,page:n,pageSize:a}})),ze=(e,t,n)=>i(r.api[`channel-templates`][`:id`].versions[`:versionId`].activate.$post({param:{id:e,versionId:t},json:{revision:n}})),Be=(e,n)=>{let r=new FormData;return r.set(`file`,e),r.set(`channel`,n.channel),r.set(`publicationType`,n.publicationType),r.set(`alt`,n.alt),t(`/api/channel-template-assets`,r)},Ve=e=>i(r.api[`chatbot-profiles`][`:profileId`].$get({param:{profileId:encodeURIComponent(e)}})),He=(e,t)=>i(r.api[`chat-sessions`].$post({json:{profileId:e,context:t}})),Ue=e=>i(r.api[`chat-sessions`].$get({query:{page:String(e.page??1),pageSize:String(e.pageSize??20),...e.profileId?{profileId:e.profileId}:{},...e.subjectKind?{subjectKind:e.subjectKind}:{},...e.subjectId?{subjectId:e.subjectId}:{},...e.status?{status:e.status}:{}}})),We=e=>i(r.api[`chat-sessions`][`:sessionId`].$get({param:{sessionId:e}})),Ge=(e,t={})=>i(r.api[`chat-sessions`][`:sessionId`].timeline.$get({param:{sessionId:e},query:{limit:String(t.limit??100),...t.beforeSequence===void 0?{}:{beforeSequence:String(t.beforeSequence)},...t.afterSequence===void 0?{}:{afterSequence:String(t.afterSequence)}}},{headers:et()})),Ke=e=>i(r.api[`chat-sessions`][`:sessionId`].$delete({param:{sessionId:e}})),qe=(e,t)=>i(r.api[`chat-sessions`][`:sessionId`].artifacts[`:artifactId`].select.$post({param:{sessionId:e,artifactId:t}}));async function Je(e,t,n,r={}){let i=`/api/chat-sessions/${encodeURIComponent(e)}/artifacts/${encodeURIComponent(t)}/preview`,o=await fetch(i,{method:`POST`,signal:r.signal,headers:{Authorization:`Bearer ${a.read()}`,Accept:`text/event-stream`,"Content-Type":`application/json`},body:JSON.stringify({contentPackageId:n})});if(!o.ok)throw new l({message:await o.text()||`${o.status}`,status:o.status,statusText:o.statusText,path:i});if(!U(o.headers.get(`content-type`))||!o.body)throw new d(`模板预览接口没有返回实时进度流`,!0);let s;if(await Ce(o.body,e=>{let t=JSON.parse(e);if(t.type===`progress`)r.onProgress?.(t.progress);else if(t.type===`completed`)s=t.artifact;else throw new d(t.message,!0)}),!s)throw new d(`模板预览连接结束但没有返回结果`,!0);return{artifact:s}}var Ye=(e,t,n)=>i(r.api[`chat-sessions`][`:sessionId`].artifacts[`:artifactId`].confirm.$post({param:{sessionId:e,artifactId:t},json:n}));async function Xe(e,t){let n=new URLSearchParams({afterSequence:String(t.afterSequence??0)}),r=`/api/chat-sessions/${encodeURIComponent(e)}/events?${n}`,i=new Headers({Authorization:`Bearer ${a.read()}`,Accept:`text/event-stream`,"X-Chatbot-Protocol":`2`});t.lastEventId&&i.set(`Last-Event-ID`,t.lastEventId);let o=await fetch(r,{signal:t.signal,headers:i});if(!o.ok)throw new d(`ChatBot 活动流连接失败:${o.status}`,!0);if(!U(o.headers.get(`content-type`))||!o.body)throw new d(`ChatBot 活动流返回了无效响应`,!1);await Ce(o.body,e=>{let n=$e(e);n.event.type===`persistent.event`&&t.onEvent(n.event.event)})}async function Ze(e,t,n){let r=`/api/chat-sessions/${encodeURIComponent(e)}/turns`,i=a.read(),o=await fetch(r,{method:`POST`,signal:n.signal,headers:{Authorization:`Bearer ${i}`,Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Chatbot-Protocol":`2`},body:JSON.stringify(t)});if(!o.ok){let e=await o.text()||`${o.status}`;throw new l({message:e,status:o.status,statusText:o.statusText,path:r})}if(!U(o.headers.get(`content-type`)))throw new d(`ChatBot 实时接口返回了无效的 Content-Type`,!1);if(!o.body)throw new d(`浏览器没有提供 ChatBot 响应流`,!1);await Ce(o.body,async e=>{let{event:t}=$e(e);if(t.type===`stream.error`)throw await n.onEvent(t),new d(t.error.message,t.error.retryable);await n.onEvent(t)})}var Qe=(e,t)=>i(r.api[`chat-sessions`][`:sessionId`].turns[`:turnId`].stop.$post({param:{sessionId:e,turnId:t}},{headers:et()}));function $e(e){let t=JSON.parse(e);if(t.protocolVersion!==2)throw new d(`ChatBot 实时协议不兼容:需要 v2`,!1);return t}function et(){return{"X-Chatbot-Protocol":`2`}}var q=e(p(),1),tt={phase:`idle`,liveText:``,liveToolCalls:[]};function nt(e,t){if(t.type===`reset`)return tt;if(t.type===`submitting`)return{phase:`settling`,turnId:t.turnId,liveText:``,liveToolCalls:[]};let n=t.event;if(n.type===`model.started`)return{...e,phase:`receiving_model`,turnId:n.turnId,modelCallId:n.modelCallId,liveText:``,liveToolCalls:[],error:void 0};if(n.type===`model.delta`)return{...e,phase:`receiving_model`,turnId:n.turnId,modelCallId:n.modelCallId,liveText:e.liveText+n.delta};if(n.type===`tool_call.delta`){let t=`${n.modelCallId}:${n.callIndex}`,r=e.liveToolCalls.find(e=>e.key===t),i={key:t,callId:n.callId??r?.callId,name:n.name??r?.name,argumentsText:!r||n.accumulatedArguments.length>=r.argumentsText.length?n.accumulatedArguments:r.argumentsText};return{...e,phase:`receiving_tool_call`,turnId:n.turnId,modelCallId:n.modelCallId,liveToolCalls:r?e.liveToolCalls.map(e=>e.key===t?i:e):[...e.liveToolCalls,i]}}if(n.type===`model.completed`)return{...e,phase:`settling`};if(n.type===`artifact.snapshot`)return{...J(e),phase:`artifact_ready`};if(n.type===`stream.error`)return{...J(e),phase:at(n.error.code)?`interrupted`:`failed`,error:{message:n.error.message,retryable:n.error.retryable}};if(n.type===`turn.snapshot`){let t=n.turn.status===Fe.Interrupted?`interrupted`:n.turn.status===Fe.Failed?`failed`:n.turn.outcome?.kind===`question`?`awaiting_user`:n.turn.outcome?.kind===`artifact`?`artifact_ready`:`completed`;return{...J(e),phase:t,turnId:n.turn.id}}let r=n.event;if(e.lastPersistentSequence!==void 0&&r.sequence<=e.lastPersistentSequence)return e;let i={...e,lastPersistentSequence:r.sequence};if(r.type===G.TurnStarted)return{...i,phase:`settling`,turnId:r.turnId,error:void 0};if(r.type===G.ToolStarted)return{...i,phase:`running_tool`,liveText:``,modelCallId:void 0,liveToolCalls:i.liveToolCalls.filter(e=>e.callId!==r.tool.callId)};if(r.type===G.ToolCompleted||r.type===G.ToolFailed)return{...i,phase:`settling`};if(r.type===G.AssistantMessage)return{...i,liveText:``};if(r.type===G.Question)return{...J(i),phase:`awaiting_user`};if(r.type===G.ArtifactProposed)return{...J(i),phase:`artifact_ready`};if(r.type===G.TurnCompleted){let e=r.turn.outcome?.kind===`question`?`awaiting_user`:r.turn.outcome?.kind===`artifact`?`artifact_ready`:`completed`;return{...J(i),phase:e}}return r.type===G.TurnInterrupted?{...J(i),phase:`interrupted`,error:r.turn.error?{message:r.turn.error.message,retryable:r.turn.error.retryable}:void 0}:r.type===G.TurnFailed?{...J(i),phase:`failed`,error:r.turn.error?{message:r.turn.error.message,retryable:r.turn.error.retryable}:void 0}:i}function rt(e){return e===`receiving_model`||e===`receiving_tool_call`||e===`running_tool`||e===`settling`}function it(e){let t=[...e].reverse().find(e=>e.type===G.Question);if(t?.question)return e.some(e=>e.sequence>t.sequence&&(e.type===G.Answer||e.type===G.UserMessage))?void 0:{eventId:t.id,questions:t.question.questions}}function J(e){return{...e,liveText:``,liveToolCalls:[],modelCallId:void 0}}function at(e){return e===Ie.ClientCancelled||e===Ie.ConnectionInterrupted||e===Ie.RuntimeRestarted}var Y=g();function ot({session:e,events:t,artifacts:n,viewModel:r,canLoadEarlier:i,loadingEarlier:a,onLoadEarlier:o,onSend:c,onStop:l,onRetry:u,onSelectArtifact:d,artifactWorkspace:p,composerTools:m,className:g}){let{generating:_,turn:v}=r,y=v.liveText,b=v.liveToolCalls,x=_e(),S=(0,q.useRef)(null),C=(0,q.useRef)(!0),[ee,w]=(0,q.useState)(``),[T,E]=(0,q.useState)([]),[D,O]=(0,q.useState)(`chat`),k=(0,q.useMemo)(()=>mt(t),[t]),A=(0,q.useMemo)(()=>it(t),[t]),j=!!p;return(0,q.useEffect)(()=>{if(!C.current)return;let e=S.current;e&&(e.scrollTop=e.scrollHeight)},[k.length,y,A?.questions]),(0,q.useEffect)(()=>E([]),[A?.eventId]),(0,Y.jsxs)(`div`,{className:f(`grid min-h-0 h-[min(680px,calc(100dvh-150px))] overflow-hidden`,j&&`grid-rows-[auto_minmax(0,1fr)] lg:grid-cols-[minmax(300px,1fr)_minmax(0,2fr)] lg:grid-rows-1`,g),children:[j?(0,Y.jsx)(`div`,{className:`flex border-b border-[var(--border)] bg-[var(--surface)] p-1 lg:hidden`,children:[{value:`chat`,label:`对话`,icon:Ae},{value:`artifact`,label:`候选`,icon:je}].map(e=>{let t=e.icon;return(0,Y.jsxs)(`button`,{type:`button`,className:f(`flex min-h-9 flex-1 items-center justify-center gap-2 rounded-[var(--radius-sm)] text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,D===e.value?`bg-[var(--surface-2)] font-medium text-[var(--ink)]`:`text-[var(--muted-strong)]`),onClick:()=>O(e.value),children:[(0,Y.jsx)(t,{className:`size-4`}),e.label]},e.value)})}):null,(0,Y.jsxs)(`section`,{className:f(`min-h-0 min-w-0 grid-rows-[minmax(0,1fr)_auto] overflow-hidden bg-[var(--surface)]`,j&&D===`artifact`?`hidden lg:grid`:`grid`),children:[(0,Y.jsx)(`div`,{ref:S,className:`scrollbar-stable min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain px-4 py-5`,onScroll:e=>{let t=e.currentTarget;C.current=t.scrollHeight-t.scrollTop-t.clientHeight<72},children:(0,Y.jsxs)(`div`,{className:`mx-auto grid min-w-0 w-full max-w-[760px] gap-5`,"aria-live":`polite`,children:[i&&o?(0,Y.jsx)(s,{variant:`ghost`,size:`sm`,className:`justify-self-center`,loading:a,onClick:o,children:`加载更早消息`}):null,k.length===0&&!y?(0,Y.jsxs)(`div`,{className:`py-12 text-center`,children:[(0,Y.jsx)(P,{className:`mx-auto size-5 text-[var(--muted)]`}),(0,Y.jsx)(`p`,{className:`mt-3 text-sm font-medium text-[var(--ink)]`,children:`开始描述你想要的排版`}),(0,Y.jsx)(`p`,{className:`mx-auto mt-1 max-w-[52ch] text-xs leading-5 text-[var(--muted-strong)]`,children:`可以直接说明参考公众号、内容密度、标题风格或希望调整的具体细节。`})]}):null,k.map(t=>(0,Y.jsx)(dt,{entry:t,artifacts:n,currentArtifactId:e.currentArtifactId,onSelectArtifact:e=>{d(e),O(`artifact`)}},t.key)),y||b.length||_?(0,Y.jsxs)(`div`,{className:`flex min-w-0 w-full items-start gap-3`,children:[(0,Y.jsx)(`span`,{className:`mt-0.5 grid size-7 shrink-0 place-items-center rounded-full bg-[var(--surface-2)] text-[var(--muted-strong)]`,children:y?(0,Y.jsx)(P,{className:`size-3.5`}):(0,Y.jsx)(h,{className:`size-3.5 animate-spin`})}),(0,Y.jsxs)(`div`,{className:`min-w-0 max-w-full flex-1 overflow-hidden pt-1 text-sm leading-6 text-[var(--ink)] [overflow-wrap:anywhere]`,children:[(0,Y.jsx)(ft,{content:y,fallback:b.length?`正在准备工具调用`:`正在整理回复`}),b.map(e=>(0,Y.jsxs)(`div`,{className:`mt-3 min-w-0 max-w-full overflow-hidden border-l-2 border-[var(--border-strong)] pl-3 text-xs text-[var(--muted-strong)]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(F,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-medium text-[var(--ink)]`,children:e.name??`工具调用`}),(0,Y.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:[e.argumentsText.length,` 字符`]})]}),e.argumentsText?(0,Y.jsx)(`pre`,{className:`mt-1 min-w-0 max-w-full max-h-28 overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-all font-mono text-[11px] leading-5`,children:e.argumentsText}):null]},e.key))]})]}):null,(0,Y.jsx)(ye,{initial:!1,children:A?(0,Y.jsx)(ve.div,{initial:{opacity:+!!x,y:x?0:10},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:x?0:.2,ease:[.16,1,.3,1]},children:(0,Y.jsx)(ct,{questions:A.questions,value:T,disabled:_,onChange:E})},A.eventId):null})]})}),(0,Y.jsx)(st,{value:ee,pendingAnswers:T.length,generating:_,onChange:w,onSubmit:()=>{let e=ee.trim();(e||T.length)&&(c({...e?{message:e}:{},...T.length?{answers:T}:{}}),w(``),E([]))},onStop:l,onRetry:u,tools:m})]}),(0,Y.jsx)(ye,{initial:!1,children:j?(0,Y.jsx)(ve.aside,{initial:{opacity:+!!x,x:x?0:24},animate:{opacity:1,x:0},transition:{duration:x?0:.24,ease:[.16,1,.3,1]},className:f(`min-h-0 min-w-0 overflow-hidden bg-[var(--surface)] lg:border-l lg:border-[var(--border)]`,D===`chat`&&`hidden lg:block`),children:p}):null})]})}function st({value:e,pendingAnswers:t,generating:n,onChange:r,onSubmit:i,onStop:a,onRetry:o,tools:s}){return(0,Y.jsx)(`div`,{className:`min-w-0 border-t border-[var(--border)] bg-[var(--surface)] px-4 py-3`,children:(0,Y.jsxs)(`div`,{className:`mx-auto grid min-w-0 w-full max-w-[760px] gap-2`,children:[s||o&&!n?(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Y.jsx)(`div`,{className:`min-w-0`,children:s}),o&&!n?(0,Y.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center gap-1.5 text-xs text-[var(--muted-strong)] hover:text-[var(--ink)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,onClick:o,children:[(0,Y.jsx)(N,{className:`size-3.5`}),`重试上次回复`]}):null]}):null,(0,Y.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Y.jsx)(z,{rows:2,value:e,disabled:n,placeholder:t?`可以补充说明后一起提交`:`输入消息`,className:`max-h-32 min-h-11 resize-none`,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),i())}}),n&&a?(0,Y.jsx)(c,{label:`停止生成`,onClick:a,children:(0,Y.jsx)(Ne,{className:`size-4 fill-current`})}):n?(0,Y.jsx)(c,{label:`回复正在其他页面生成`,disabled:!0,children:(0,Y.jsx)(h,{className:`size-4 animate-spin`})}):(0,Y.jsx)(c,{label:t?`提交回答`:`发送消息`,onClick:i,children:(0,Y.jsx)(se,{className:`size-4`})})]})]})})}function ct({questions:e,value:t,disabled:n,onChange:r}){let i=e=>t.find(t=>t.questionId===e)??{questionId:e},a=e=>r([...t.filter(t=>t.questionId!==e.questionId),e]);return(0,Y.jsx)(`div`,{className:`grid gap-5 border-y border-[var(--border)] py-4`,children:e.map(e=>{let t=i(e.id);return(0,Y.jsxs)(`fieldset`,{disabled:n,className:`grid gap-2.5`,children:[(0,Y.jsx)(`legend`,{className:`text-sm font-medium text-[var(--ink)]`,children:e.prompt}),e.description?(0,Y.jsx)(`p`,{className:`text-xs leading-5 text-[var(--muted-strong)]`,children:e.description}):null,e.options?.length?(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.options.map(n=>{let r=t.selectedOptionIds?.includes(n.id)??!1;return(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":r,title:n.description,className:f(`inline-flex min-h-9 items-center gap-2 rounded-[var(--radius-sm)] border px-3 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,r?`border-[var(--ink)] bg-[var(--ink)] text-white`:`border-[var(--border)] bg-[var(--surface)] text-[var(--ink)] hover:bg-[var(--surface-2)]`),onClick:()=>{let i=t.selectedOptionIds??[],o=e.type===K.MultiSelect?r?i.filter(e=>e!==n.id):[...i,n.id]:[n.id];a({...t,selectedOptionIds:o})},children:[r?(0,Y.jsx)(I,{className:`size-3.5`}):null,n.swatches?.length?(0,Y.jsx)(`span`,{className:`flex`,"aria-hidden":`true`,children:n.swatches.map(e=>(0,Y.jsx)(`span`,{className:`size-3 border border-white/50 first:rounded-l-sm last:rounded-r-sm`,style:{backgroundColor:e}},e))}):null,(0,Y.jsx)(`span`,{children:n.label})]},n.id)})}):null,e.type===K.Text?(0,Y.jsx)(z,{rows:2,value:t.text??``,onChange:e=>a({...t,text:e.target.value})}):null,e.type===K.UrlList?(0,Y.jsx)(z,{rows:3,value:t.urls?.join(`
|
|
3
|
-
`)??``,placeholder:`每行一个 URL`,onChange:e=>a({...t,urls:e.target.value.split(`
|
|
4
|
-
`).map(e=>e.trim()).filter(Boolean)})}):null,e.type===K.Confirm?(0,Y.jsx)(`div`,{className:`flex gap-2`,children:[{label:`确认`,value:!0},{label:`暂不`,value:!1}].map(e=>(0,Y.jsx)(s,{variant:t.confirmed===e.value?`primary`:`secondary`,size:`sm`,onClick:()=>a({...t,confirmed:e.value}),children:e.label},String(e.value)))}):null]},e.id)})})}function lt({event:e}){let t=e.type===G.ToolFailed,n=e.type===G.ToolStarted;return(0,Y.jsxs)(`details`,{className:`group min-w-0 max-w-full overflow-hidden text-xs text-[var(--muted-strong)]`,children:[(0,Y.jsxs)(`summary`,{className:`flex min-h-8 min-w-0 cursor-pointer list-none items-center gap-2 rounded-[var(--radius-sm)] px-2 hover:bg-[var(--surface-2)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,children:[t?(0,Y.jsx)(Ee,{className:`size-3.5 text-[var(--danger)]`}):n?(0,Y.jsx)(h,{className:`size-3.5 animate-spin`}):(0,Y.jsx)(F,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.tool?.label??e.tool?.name??`工具调用`}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0`,children:t?`失败`:n?`执行中`:`完成`}),(0,Y.jsx)(L,{className:`size-3 shrink-0 transition-transform group-open:rotate-180`})]}),(0,Y.jsx)(`pre`,{className:`mt-1 min-w-0 max-w-full max-h-40 overflow-x-hidden overflow-y-auto border-y border-[var(--border)] px-2 py-2 text-[11px] leading-5 whitespace-pre-wrap break-all`,children:JSON.stringify(e.tool?.error??e.tool?.observation??e.tool?.inputSummary??{},null,2)})]})}function ut({artifacts:e,currentArtifactId:t,onSelect:n,children:r}){return(0,Y.jsxs)(`div`,{className:`grid h-full min-h-0 min-w-0 grid-rows-[auto_minmax(0,1fr)] bg-[var(--surface)]`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 border-b border-[var(--border)] px-5 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Y.jsx)(`h3`,{className:`shrink-0 text-sm font-semibold text-[var(--ink)]`,children:`候选版本`}),(0,Y.jsxs)(`p`,{className:`truncate text-xs text-[var(--muted-strong)]`,children:[e.length,` 个不可变候选`]})]}),(0,Y.jsxs)(x,{value:t??e.at(-1)?.id??``,onValueChange:n,children:[(0,Y.jsx)(y,{size:`sm`,"aria-label":`选择模板候选`,className:`w-[168px] max-w-[45vw] text-xs`,children:(0,Y.jsx)(S,{})}),(0,Y.jsx)(C,{position:`popper`,align:`end`,children:e.map(e=>(0,Y.jsxs)(b,{value:e.id,className:`text-xs`,children:[`候选 `,e.ordinal,` ·`,` `,e.status===`confirmed`?`已保存`:e.status===`previewed`?`已预览`:`待预览`]},e.id))})]})]}),(0,Y.jsx)(`div`,{className:`scrollbar-stable min-h-0 min-w-0 overflow-x-hidden overflow-y-auto`,children:r})]})}function dt({entry:e,artifacts:t,currentArtifactId:n,onSelectArtifact:r}){if(e.kind===`tool`)return(0,Y.jsx)(lt,{event:e.event});if(e.kind===`artifact`){let i=t.find(t=>t.id===e.event.artifactId);return i?(0,Y.jsxs)(`button`,{type:`button`,className:f(`flex w-full items-center justify-between border-y border-[var(--border)] px-2 py-3 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,i.id===n&&`bg-[var(--surface-2)]`),onClick:()=>r(i.id),children:[(0,Y.jsxs)(`span`,{className:`font-medium text-[var(--ink)]`,children:[`已生成模板候选 `,i.ordinal]}),(0,Y.jsx)(`span`,{className:`text-xs text-[var(--muted-strong)]`,children:`查看`})]}):null}let i=e.event.type===G.UserMessage||e.event.type===G.Answer,a=e.event.content??ht(e.event.answers),o=i?void 0:Le(a);return(0,Y.jsxs)(`div`,{className:f(`flex min-w-0 w-full items-start gap-3`,i&&`flex-row-reverse`),children:[(0,Y.jsx)(`span`,{className:`mt-0.5 grid size-7 shrink-0 place-items-center rounded-full bg-[var(--surface-2)] text-[var(--muted-strong)]`,children:i?(0,Y.jsx)(Pe,{className:`size-3.5`}):(0,Y.jsx)(P,{className:`size-3.5`})}),(0,Y.jsxs)(`div`,{className:f(`min-w-0 max-w-[82%] break-words text-sm leading-6 whitespace-pre-wrap [overflow-wrap:anywhere]`,i?`rounded-[var(--radius-sm)] bg-[var(--ink)] px-3 py-2 text-white`:`min-w-0 flex-1 pt-1 text-[var(--ink)]`),children:[o?.thinking?(0,Y.jsx)(pt,{content:o.thinking}):null,o?o.message:a]})]})}function ft({content:e,fallback:t}){let n=Le(e);return(0,Y.jsxs)(`div`,{className:`grid min-w-0 max-w-full gap-2.5 overflow-hidden [overflow-wrap:anywhere]`,children:[n.thinking?(0,Y.jsx)(pt,{content:n.thinking,live:!0}):null,(0,Y.jsx)(`div`,{className:`min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n.message||(n.thinking?null:t)})]})}function pt({content:e,live:t=!1}){return(0,Y.jsxs)(`div`,{className:`min-w-0 max-w-full overflow-hidden border-y border-[var(--border)] bg-[var(--surface-2)] px-3 py-2 text-xs leading-5 text-[var(--muted-strong)]`,children:[(0,Y.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 font-medium text-[var(--ink)]`,children:[t?(0,Y.jsx)(h,{className:`size-3.5 animate-spin`}):(0,Y.jsx)(Te,{className:`size-3.5`}),(0,Y.jsx)(`span`,{children:`思考`})]}),(0,Y.jsx)(`div`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e})]})}function mt(e){let t=new Map;for(let n of e)n.tool?.callId&&(n.type===G.ToolCompleted||n.type===G.ToolFailed)&&t.set(n.tool.callId,n);return e.flatMap(e=>e.type===G.UserMessage||e.type===G.AssistantMessage||e.type===G.Answer||e.type===G.TurnInterrupted?[{key:e.id,kind:`message`,event:e}]:e.type===G.ToolStarted||e.type===G.ToolCompleted||e.type===G.ToolFailed?e.type===G.ToolStarted&&t.has(e.tool?.callId??``)?[]:[{key:e.id,kind:`tool`,event:e}]:e.type===G.ArtifactProposed?[{key:e.id,kind:`artifact`,event:e}]:[])}function ht(e){return(e??[]).map(e=>e.skipped?`已跳过`:[e.selectedOptionIds?.join(`、`),e.text,e.urls?.join(`、`),e.confirmed===void 0?void 0:e.confirmed?`确认`:`暂不`].filter(Boolean).join(` · `)).filter(Boolean).join(`
|
|
5
|
-
`)}var gt=48,_t=class{emit;immediate;pending=Promise.resolve();constructor(e,t=()=>!1){this.emit=e,this.immediate=t}present(e){let t=this.pending.then(()=>this.deliver(e));return this.pending=t.catch(()=>void 0),t}async deliver(e){if(e.type!==`model.delta`&&e.type!==`tool_call.delta`){await this.emit(e);return}let t=yt(e.delta);if(t.length===1||this.immediate()){await this.emit(e);return}let n=0;for(let[r,i]of t.entries()){if(r>0&&this.immediate()){await this.emit(vt(e,e.delta.slice(n),e.delta.length));return}n+=i.length,await this.emit(vt(e,i,n)),r<t.length-1&&await bt()}}};function vt(e,t,n){return e.type===`model.delta`?{...e,delta:t,accumulatedCharacters:e.accumulatedCharacters-e.delta.length+n}:{...e,delta:t,accumulatedArguments:e.accumulatedArguments.slice(0,e.accumulatedArguments.length-e.delta.length)+e.delta.slice(0,n)}}function yt(e){if(e.length<=gt)return[e];let t=[];for(let n=0;n<e.length;){let r=Math.min(n+gt,e.length),i=e.charCodeAt(r-1);r<e.length&&i>=55296&&i<=56319&&--r,t.push(e.slice(n,r)),n=r}return t}function bt(){return new Promise(e=>setTimeout(e,12))}function xt(e){let t=n(),[r,i]=(0,q.useReducer)(nt,tt),[a,o]=(0,q.useState)(),s=(0,q.useRef)(void 0),c=(0,q.useRef)(!1),l=e.sessionId,u=_({queryKey:[`chat-session`,l],queryFn:()=>We(l),enabled:!!(e.enabled&&l),refetchInterval:e=>e.state.data?.session.activeTurnId?1e3:!1,structuralSharing:(e,t)=>wt(e,t)}),d=_({queryKey:[`chat-timeline`,l],queryFn:()=>Ge(l,{limit:200}),enabled:!!(e.enabled&&l)}),f=v({mutationFn:()=>Ge(l,{beforeSequence:d.data?.nextBeforeSequence,limit:200}),onSuccess:e=>{t.setQueryData([`chat-timeline`,l],t=>({events:Ct(e.events,t?.events??[]),hasMore:e.hasMore,nextBeforeSequence:e.nextBeforeSequence}))},onError:e=>H.error(`加载更早消息失败`,e)}),p=(0,q.useCallback)(async e=>{i({type:`event`,event:e}),e.type===`persistent.event`?(t.setQueryData([`chat-timeline`,l],t=>({events:St(t?.events??[],e.event),hasMore:t?.hasMore??!1,nextBeforeSequence:t?.nextBeforeSequence})),(e.event.type===G.ArtifactProposed||e.event.type===G.ArtifactSelected||e.event.type===G.ArtifactPreviewed||e.event.type===G.ArtifactConfirmed||e.event.type===G.TurnCompleted||e.event.type===G.TurnInterrupted||e.event.type===G.TurnFailed)&&await t.invalidateQueries({queryKey:[`chat-session`,l]})):e.type===`artifact.snapshot`?t.setQueryData([`chat-session`,l],t=>t&&{...t,artifacts:X(t.artifacts,e.artifact)}):e.type===`turn.snapshot`&&t.setQueryData([`chat-session`,l],t=>t&&{...t,session:e.session})},[t,l]);(0,q.useEffect)(()=>{s.current?.abort(),s.current=void 0,c.current=!1,i({type:`reset`}),o(void 0)},[e.enabled,l]),(0,q.useEffect)(()=>{if(!e.enabled||!l)return;let n=new AbortController,r,i=0,a=t.getQueryData([`chat-timeline`,l])?.events.at(-1)?.sequence??0,o=async()=>{try{await Xe(l,{signal:n.signal,afterSequence:a,lastEventId:a?String(a):void 0,onEvent:e=>{a=Math.max(a,e.sequence),p({type:`persistent.event`,event:e})}})}catch{if(n.signal.aborted)return;i+=1,r=setTimeout(()=>void o(),Math.min(1e3*2**i,15e3))}};return o(),()=>{n.abort(),r&&clearTimeout(r)}},[p,e.enabled,t,l]);let m=async()=>{await Promise.all([t.invalidateQueries({queryKey:[`chat-session`,l]}),t.invalidateQueries({queryKey:[`chat-timeline`,l]}),t.invalidateQueries({queryKey:[`chat-sessions`,e.profileId]})])},h=async(t,n=crypto.randomUUID())=>{if(!l||rt(r.phase)||u.data?.session.activeTurnId)return;let a={clientTurnId:n,...t},d=new AbortController;s.current=d,c.current=!1,i({type:`submitting`});let f=new _t(async e=>await p(e),()=>e.reducedMotion||typeof document<`u`&&document.hidden);try{await Ze(l,a,{signal:d.signal,onEvent:async e=>await f.present(e)}),o(void 0),await m()}catch(e){!d.signal.aborted&&!c.current&&(o(a),H.error(`ChatBot 回复失败`,e),await m())}finally{s.current===d&&(s.current=void 0),c.current=!1}},g=u.data?.session,y=u.data?.artifacts??[],b=(0,q.useCallback)(e=>{t.setQueryData([`chat-session`,l],t=>t&&{...t,artifacts:X(t.artifacts,e)})},[t,l]);return{detail:u,timeline:d,loadEarlier:f,session:g,artifacts:y,currentArtifact:y.find(e=>e.id===g?.currentArtifactId)??y.at(-1),turnState:r,generating:rt(r.phase)||!!g?.activeTurnId,retryable:!!a,send:h,stop:async()=>{let e=s.current,t=r.turnId??g?.activeTurnId;c.current=!0;try{l&&t&&await Qe(l,t)}catch(e){H.error(`停止 ChatBot 回复失败`,e)}finally{e?.abort()}},retry:a?()=>{let{clientTurnId:e,...t}=a;return h(t,e)}:void 0,cacheArtifact:b,refresh:m}}function St(e,t){return e.some(e=>e.id===t.id||e.sequence===t.sequence)?e:[...e,t].sort((e,t)=>e.sequence-t.sequence)}function Ct(e,t){let n=new Map;for(let r of[...e,...t])n.set(r.id,r);return[...n.values()].sort((e,t)=>e.sequence-t.sequence)}function X(e,t){let n=e.find(e=>e.id===t.id);if(n&&n.updatedAt>t.updatedAt)return e;let r=Tt(n,t),i=r.length?{...t,preview:t.preview??r.at(-1),previews:r}:t;return[...e.filter(e=>e.id!==t.id),i].sort((e,t)=>e.ordinal-t.ordinal)}function wt(e,t){if(!e)return t;let n=t.artifacts.reduce((e,t)=>X(e,t),e.artifacts);return{session:e.session.revision>t.session.revision?e.session:t.session,artifacts:n}}function Tt(e,t){let n=new Map;for(let r of[e,t])if(r)for(let e of[...r.previews??[],...r.preview?[r.preview]:[]])n.set(e.id??e.receipt,e);return[...n.values()]}function Et({disabled:e,onSelect:t}){return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(D,{asChild:!0,children:(0,Y.jsxs)(s,{variant:`primary`,disabled:e,children:[(0,Y.jsx)(oe,{className:`size-4`}),`制作模板`]})}),(0,Y.jsxs)(E,{align:`end`,className:`w-72`,children:[(0,Y.jsx)(T,{children:`选择制作方式`}),(0,Y.jsx)(w,{}),(0,Y.jsxs)(O,{className:`items-start py-2.5`,onSelect:()=>t(`history`),children:[(0,Y.jsx)(Oe,{className:`mt-0.5 size-4`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`strong`,{className:`block text-sm font-medium`,children:`参考公众号`}),(0,Y.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-[var(--muted-strong)]`,children:`研究公众号和代表文章的历史排版。`})]})]}),(0,Y.jsxs)(O,{className:`items-start py-2.5`,onSelect:()=>t(`consultation`),children:[(0,Y.jsx)(Ae,{className:`mt-0.5 size-4`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`strong`,{className:`block text-sm font-medium`,children:`咨询排版风格`}),(0,Y.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-[var(--muted-strong)]`,children:`通过自由对话逐步确定视觉方向。`})]})]})]})]})}function Dt(){return(0,Y.jsx)(`div`,{className:`grid h-full min-h-0 place-items-center bg-[var(--surface-2)] p-6 text-center`,children:(0,Y.jsxs)(`div`,{className:`max-w-[38ch]`,children:[(0,Y.jsx)(ae,{className:`mx-auto size-5 text-[var(--muted)]`}),(0,Y.jsx)(`p`,{className:`mt-3 text-sm font-medium text-[var(--ink)]`,children:`候选与预览会显示在这里`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-strong)]`,children:`在左侧说明排版方向。Agent 提交首个候选后,右侧可以切换版本、生成手机预览并保存模板。`})]})})}function Ot({channel:e,publicationType:t,disabled:n,onUploaded:r}){let i=(0,q.useRef)(null),a=v({mutationFn:n=>Be(n,{channel:e,publicationType:t,alt:n.name.replace(/\.[^.]+$/,``).trim()||`模板固定素材`}),onSuccess:({asset:e})=>{H.success(`固定素材已上传`,`资源信息已发送给模板 Agent。`),r(e)},onError:e=>H.error(`上传固定素材失败`,e)});return(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`input`,{ref:i,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp`,className:`sr-only`,tabIndex:-1,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&a.mutate(t)}}),(0,Y.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,loading:a.isPending,disabled:n,title:`上传背景、纹理或装饰图片,最大 10MB`,onClick:()=>i.current?.click(),children:[a.isPending?null:(0,Y.jsx)(ke,{className:`size-3.5`}),`上传固定素材`]}),(0,Y.jsx)(`span`,{className:`hidden truncate text-[11px] text-[var(--muted-strong)] sm:inline`,children:`PNG / JPEG / GIF / WebP,最大 10MB`})]})}function kt({session:e,template:t,artifacts:n,artifact:r,onSelect:i,onChanged:a,onArtifactUpdated:o,onSaved:c}){let[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(!1),[g,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(`正在启动微信排版 Agent`),[S,C]=(0,q.useState)(t?.name??``),[w,T]=(0,q.useState)(t?.description??``),[E,D]=(0,q.useState)(()=>Q(Z(r).at(-1))??``),O=_({queryKey:[`content-packages`,`chat-template-preview`],queryFn:()=>ce(1,100)}),k=v({mutationFn:t=>Je(e.id,r.id,t,{onProgress:e=>x(e.label)}),onMutate:e=>{u(!1),D(`pending:${e}`),x(`正在启动微信排版 Agent`)},onSuccess:({artifact:e})=>{o(e);let t=Z(e).at(-1);t&&D(Q(t)??``),H.success(`模板预览已生成`,`可以在候选的预览结果中查看。`),a().catch(e=>H.error(`刷新预览列表失败`,e))},onError:e=>{D(Q(Z(r).at(-1))??``),H.error(`模板预览失败`,e)}}),A=k.data?.artifact,j=A?X([r],A)[0]??r:r,M=Z(j),N=M.find(e=>Q(e)===E)??M.at(-1),P=!N||Date.parse(N.expiresAt)<=Date.now();(0,q.useEffect)(()=>{if(k.isPending)return;let e=M.at(-1);e&&!M.some(e=>Q(e)===E)&&D(Q(e)??``)},[k.isPending,M,E]);let F=v({mutationFn:()=>Ye(e.id,r.id,{receipt:N.receipt,name:t?.name??S,description:w||void 0,templateId:t?.id,revision:t?.revision}),onSuccess:async()=>{m(!1),await a(),await c(),H.success(`模板版本已保存`,`保存不会自动激活,可以继续对话优化。`)},onError:e=>H.error(`保存模板版本失败`,e)}),I=(N?.result)?.content?.html,L=r.payload.outputMode===`prompt_with_dsl`?`prompt_with_dsl`:`prompt_only`;return(0,Y.jsxs)(ut,{artifacts:n,currentArtifactId:r.id,onSelect:i,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`section`,{className:`border-b border-[var(--border)]`,children:[(0,Y.jsx)(`div`,{className:`flex min-w-0 items-start justify-between gap-4 px-5 py-3`,children:(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h4`,{className:`text-sm font-semibold text-[var(--ink)]`,children:`候选定义`}),(0,Y.jsx)(V,{tone:L===`prompt_with_dsl`?`accent`:`info`,children:L===`prompt_with_dsl`?`固定 DSL`:`动态 HTML`})]}),(0,Y.jsx)(`p`,{className:`mt-1 line-clamp-2 max-w-[90ch] text-xs leading-5 text-[var(--muted-strong)]`,children:typeof r.payload.designSummary==`string`?r.payload.designSummary:``})]})}),(0,Y.jsxs)(`div`,{className:L===`prompt_with_dsl`?`grid border-t border-[var(--border)] lg:grid-cols-2 lg:divide-x lg:divide-[var(--border)]`:`border-t border-[var(--border)]`,children:[(0,Y.jsxs)(`section`,{className:`min-w-0 px-5 py-3`,children:[(0,Y.jsxs)(`h5`,{className:`flex items-center gap-2 text-xs font-semibold text-[var(--ink)]`,children:[(0,Y.jsx)(ie,{className:`size-3.5 text-[var(--muted-strong)]`}),`排版提示词`]}),(0,Y.jsx)(`pre`,{className:`mt-2 h-64 max-w-full overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words text-xs leading-5 text-[var(--muted-strong)] [overflow-wrap:anywhere]`,children:typeof r.payload.prompt==`string`?r.payload.prompt:``})]}),L===`prompt_with_dsl`?(0,Y.jsxs)(`section`,{className:`min-w-0 border-t border-[var(--border)] px-5 py-3 lg:border-t-0`,children:[(0,Y.jsxs)(`h5`,{className:`flex items-center gap-2 text-xs font-semibold text-[var(--ink)]`,children:[(0,Y.jsx)(we,{className:`size-3.5 text-[var(--accent)]`}),`微信布局 DSL`]}),(0,Y.jsx)(`pre`,{className:`mt-2 max-h-44 max-w-full overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-all font-mono text-[11px] leading-5 text-[var(--muted-strong)]`,children:JSON.stringify(r.payload.dsl??{},null,2)})]}):null]})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-4 border-b border-[var(--border)] px-5 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Y.jsx)(`h4`,{className:`text-sm font-semibold text-[var(--ink)]`,children:`预览结果`}),(0,Y.jsxs)(`p`,{className:`truncate text-xs text-[var(--muted-strong)]`,children:[M.length,` 条已完成记录`]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[r.status!==`confirmed`&&N?(0,Y.jsxs)(s,{variant:`ghost`,size:`sm`,disabled:P,title:P?`最新预览回执已过期,请重新生成预览`:void 0,onClick:()=>m(!0),children:[(0,Y.jsx)(Me,{className:`size-3.5`}),`保存模板`]}):null,(0,Y.jsxs)(s,{variant:`secondary`,size:`sm`,loading:k.isPending,disabled:k.isPending,onClick:()=>u(!0),children:[k.isPending?null:(0,Y.jsx)(R,{className:`size-3.5`}),k.isPending?`生成中`:`生成预览`]})]})]}),(0,Y.jsxs)(`div`,{className:`border-b border-[var(--border)]`,children:[k.isPending?(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5 px-5 py-2.5 text-sm`,children:[(0,Y.jsx)(h,{className:`size-4 shrink-0 animate-spin text-[var(--accent)]`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{className:`truncate font-medium text-[var(--ink)]`,children:jt(O.data?.items,k.variables)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--muted-strong)]`,role:`status`,"aria-live":`polite`,children:b})]}),(0,Y.jsx)(V,{tone:`info`,children:`生成中`})]}):null,[...M].reverse().map((e,t)=>{let n=Q(e),r=Date.parse(e.expiresAt)<=Date.now();return(0,Y.jsxs)(`button`,{type:`button`,className:`flex min-w-0 w-full items-center gap-2.5 border-t border-[var(--border)] bg-[var(--surface)] px-5 py-2.5 text-left transition-colors first:border-t-0 hover:bg-[var(--surface-2)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus)]`,onClick:()=>{D(n),f(!0)},children:[(0,Y.jsx)(R,{className:`size-4 shrink-0 text-[var(--muted)]`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium text-[var(--ink)]`,children:jt(O.data?.items,e.contentPackageId)}),(0,Y.jsxs)(`span`,{className:`mt-0.5 block text-xs text-[var(--muted-strong)]`,children:[At(e,j),` · 手机端文章预览`]})]}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-[var(--muted-strong)]`,children:r?`回执过期`:t===0?`最新`:`已完成`}),(0,Y.jsx)(re,{className:`size-3.5 shrink-0 text-[var(--muted)]`})]},n)}),!k.isPending&&M.length===0?(0,Y.jsxs)(`div`,{className:`px-5 py-8 text-center`,children:[(0,Y.jsx)(R,{className:`mx-auto size-5 text-[var(--muted)]`}),(0,Y.jsx)(`p`,{className:`mt-2 text-sm font-medium text-[var(--ink)]`,children:`还没有预览结果`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-strong)]`,children:`点击“生成预览”,选择一篇真实内容进行检查。`})]}):null]})]}),(0,Y.jsx)(pe,{open:d,onOpenChange:f,children:(0,Y.jsxs)(le,{showCloseButton:!1,className:`grid h-[min(780px,calc(100dvh-32px))] w-[min(410px,calc(100vw-24px))] max-w-[410px] grid-rows-[44px_minmax(0,1fr)] gap-0 overflow-hidden rounded-[20px] border border-[var(--border-strong)] bg-white p-0 shadow-[0_18px_52px_rgba(20,20,24,0.20)] sm:max-w-[410px]`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-[36px_minmax(0,1fr)_36px] items-center border-b border-[#e7e7e7] px-2 text-[#181818]`,children:[(0,Y.jsx)(ue,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,className:`grid size-8 place-items-center rounded-[var(--radius-sm)] transition-colors hover:bg-[#f4f4f4] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,children:(0,Y.jsx)(te,{className:`size-5`})})}),(0,Y.jsx)(me,{className:`truncate text-center text-sm font-semibold leading-5`,children:`公众号文章`}),(0,Y.jsx)(De,{className:`size-5 justify-self-center`,"aria-hidden":`true`}),(0,Y.jsx)(fe,{className:`sr-only`,children:N?jt(O.data?.items,N.contentPackageId):`微信文章手机端预览`})]}),N&&I?(0,Y.jsx)(`iframe`,{title:`微信文章手机端预览`,sandbox:``,srcDoc:`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"></head><body style="margin:16px;background:#fff">${I}</body></html>`,className:`min-h-0 size-full bg-white`}):(0,Y.jsx)(`div`,{className:`grid min-h-0 place-items-center px-6 text-center text-sm text-[var(--muted-strong)]`,children:`当前预览没有可展示的 HTML`})]})}),(0,Y.jsxs)(he,{open:p,onOpenChange:m,title:`保存模板版本`,description:`保存当前候选,不会自动激活,也不会修改已经存在的模板版本。`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-4`,children:[t?null:(0,Y.jsx)(B,{label:`模板名称`,required:!0,children:(0,Y.jsx)(ge,{value:S,onChange:e=>C(e.target.value)})}),(0,Y.jsx)(B,{label:`说明`,children:(0,Y.jsx)(ge,{value:w,onChange:e=>T(e.target.value)})})]}),(0,Y.jsxs)(de,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(s,{variant:`secondary`,onClick:()=>m(!1),children:`取消`}),(0,Y.jsx)(s,{variant:`primary`,disabled:P||!t&&!S.trim(),loading:F.isPending,onClick:()=>F.mutate(),children:`保存为模板版本`})]})]})]}),(0,Y.jsxs)(he,{open:l,onOpenChange:u,title:`生成模板预览`,description:`选择一篇真实内容,生成微信手机端文章预览。`,children:[(0,Y.jsx)(B,{label:`真实内容包`,required:!0,children:(0,Y.jsxs)(ee,{value:g,onChange:e=>y(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`请选择内容包`}),O.data?.items.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.contentPackage.document.title},e.id))]})}),(0,Y.jsxs)(de,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(s,{variant:`secondary`,onClick:()=>u(!1),children:`取消`}),(0,Y.jsx)(s,{variant:`primary`,disabled:!g,onClick:()=>k.mutate(g),children:`生成预览`})]})]})]})}function Z(e){let t=e.previews??[];return!e.preview||t.some(t=>t.receipt===e.preview?.receipt)?t:[...t,e.preview]}function Q(e){return e?.id??(e?`legacy:${e.receipt}`:void 0)}function At(e,t){return new Date(e.createdAt??t.updatedAt).toLocaleString(`zh-CN`)}function jt(e,t){return t?e?.find(e=>e.id===t)?.contentPackage.document.title??t:`未知内容包`}var Mt=20,$=`channel-template-authoring/weixin/article`;function Nt({channel:e,publicationType:t,page:r,onPageChange:i,onPublicationTypeChange:a}){let{data:o}=be({live:!1}),c=n(),l=m(),u=_({queryKey:[`channel-templates`,e,t,r],queryFn:()=>Re(e,t,r,Mt)}),d=_({queryKey:[`chatbot-profile`,$],queryFn:()=>Ve($)}),f=_({queryKey:[`chat-sessions`,$,`recent`],queryFn:()=>Ue({profileId:$,subjectKind:`channel-template`,page:1,pageSize:20})}),p=o?.publicationTypeProfiles.find(n=>n.channel===e&&n.type===t),h=o?.channelDefinitions.find(t=>t.id===e),g=(o?.publicationTypeProfiles??[]).filter(t=>t.channel===e&&t.layout),y=v({mutationFn:e=>ze(e.templateId,e.versionId,e.revision),onSuccess:async()=>{await c.invalidateQueries({queryKey:[`channel-templates`,e]}),await c.invalidateQueries({queryKey:[`workspace`]}),H.success(`模板版本已激活`,`账号选择激活版本时会使用该版本。`)},onError:e=>H.error(`激活模板失败`,e)}),b=n=>l({to:`/publishing/templates/sessions/$sessionId`,params:{sessionId:n},search:{channel:e,publicationType:t,page:r}}),x=v({mutationFn:e=>He($,{method:e.method,...e.templateId?{templateId:e.templateId}:{}}),onSuccess:async({session:e})=>{await c.invalidateQueries({queryKey:[`chat-sessions`,$]}),await b(e.id)},onError:e=>H.error(`创建模板对话失败`,e)}),S=v({mutationFn:Ke,onSuccess:async()=>{await c.invalidateQueries({queryKey:[`chat-sessions`,$]}),H.success(`制作会话已删除`)},onError:e=>H.error(`删除制作会话失败`,e)});return(0,Y.jsxs)(xe,{children:[g.length>1?(0,Y.jsx)(Se,{value:t,onChange:a,items:g.map(e=>({value:e.type,label:e.name})),className:`justify-self-start`}):null,o&&!p?.layout?(0,Y.jsx)(`p`,{className:`py-8 text-sm text-[var(--muted-strong)]`,children:`该渠道没有可配置的排版模板。`}):(0,Y.jsx)(j,{title:`${h?.name??e} · ${p?.name??t}排版模板`,description:`模板版本不可变;账号和内容方案可默认跟随激活版本,也可按需锁定具体版本。`,compact:!0,summary:`共 ${u.data?.total??0} 个模板`,action:(0,Y.jsx)(Et,{disabled:!d.data?.ready||x.isPending,onSelect:e=>x.mutate({method:e})}),empty:!u.data?.items.length,emptyTitle:`还没有渠道模板`,emptyDescription:`通过多轮对话研究历史排版或咨询风格,再预览并保存模板。`,pagination:(0,Y.jsx)(ne,{page:r,pageSize:Mt,total:u.data?.total??0,onChange:i}),children:u.data?.items.map(e=>{let t=e.versions.find(t=>t.id===e.activeVersionId),n=e.versions.at(-1);return(0,Y.jsxs)(A,{title:e.name,description:`${e.versions.length} 个不可变版本 · ${t?`已激活 v${t.version}`:`尚未激活`}`,status:e.enabled?`ready`:`disabled`,meta:n?(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(V,{tone:Ft(n.artifact)===`prompt_with_dsl`?`accent`:`info`,children:Ft(n.artifact)===`prompt_with_dsl`?`固定 DSL`:`动态 HTML`}),(0,Y.jsxs)(V,{children:[`最新 v`,n.version]})]}):void 0,children:[n&&n.id!==e.activeVersionId?(0,Y.jsxs)(s,{variant:`ghost`,loading:y.isPending,onClick:()=>y.mutate({templateId:e.id,versionId:n.id,revision:e.revision}),children:[(0,Y.jsx)(I,{className:`size-4`}),`激活 v`,n.version]}):null,(0,Y.jsx)(s,{variant:`ghost`,loading:x.isPending&&x.variables?.templateId===e.id,onClick:()=>x.mutate({method:`consultation`,templateId:e.id}),children:`继续优化`})]},e.id)})}),d.data&&!d.data.ready?(0,Y.jsxs)(`p`,{className:`border-y border-[var(--danger-border)] py-3 text-sm text-[var(--danger)]`,children:[`模板制作缺少可用连接:`,d.data.missingCapabilities.join(`、`),`。请先到连接页面完成配置。`]}):null,(0,Y.jsx)(j,{title:`制作会话`,description:`打开进行中或历史会话会进入独立制作页面,对话和预览互不挤占。`,compact:!0,summary:`最近 ${f.data?.items.length??0} 个会话`,empty:!f.data?.items.length,emptyTitle:`还没有制作会话`,emptyDescription:`从“制作模板”选择参考公众号或风格咨询后,会话会保留在这里。`,children:f.data?.items.map(e=>{let t=o?.channelTemplates.find(t=>t.id===e.subject.id);return(0,Y.jsx)(A,{title:t?`${t.name} · ${e.title}`:e.title,description:`${It(e.status)} · ${new Date(e.updatedAt).toLocaleString(`zh-CN`)}`,status:e.status===W.Incompatible?`warning`:`ready`,meta:e.currentArtifactId?(0,Y.jsx)(V,{children:`已有候选`}):void 0,onOpen:()=>void b(e.id),onDelete:()=>S.mutateAsync(e.id),deleteDescription:`只删除这次制作对话,不影响已经确认保存的模板版本。`,children:(0,Y.jsx)(s,{variant:`ghost`,onClick:()=>void b(e.id),children:`打开`})},e.id)})})]})}function Pt({sessionId:e,channel:t,publicationType:r,onBack:i}){let a=n(),c=_e(),{data:l}=be({live:!1}),u=xt({sessionId:e,enabled:!0,profileId:$,reducedMotion:!!c}),{timeline:d,loadEarlier:f,session:p,artifacts:m,currentArtifact:h}=u,g=l?.channelTemplates.find(e=>e.id===p?.subject.id),_=typeof p?.context.channel==`string`?p.context.channel:t,v=typeof p?.context.publicationType==`string`?p.context.publicationType:r;return u.detail.error||d.error?(0,Y.jsx)(`section`,{className:`grid min-h-80 place-items-center rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] p-6 text-center`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-sm font-semibold text-[var(--ink)]`,children:`无法打开模板制作会话`}),(0,Y.jsx)(`p`,{className:`mt-1 max-w-[60ch] text-sm text-[var(--muted-strong)]`,children:o(u.detail.error??d.error)}),(0,Y.jsxs)(s,{variant:`secondary`,className:`mt-4`,onClick:i,children:[(0,Y.jsx)(M,{className:`size-4`}),`返回模板列表`]})]})}):!p||!d.data?(0,Y.jsx)(`div`,{className:`grid min-h-[520px] place-items-center rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] text-sm text-[var(--muted-strong)]`,children:`正在恢复制作会话`}):(0,Y.jsxs)(`section`,{className:`grid h-[calc(100dvh-8.75rem)] min-h-[520px] grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 border-b border-[var(--border)] px-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsxs)(s,{variant:`ghost`,size:`sm`,onClick:i,children:[(0,Y.jsx)(M,{className:`size-4`}),`返回模板列表`]}),(0,Y.jsx)(`span`,{className:`hidden h-4 w-px bg-[var(--border)] sm:block`,"aria-hidden":!0}),(0,Y.jsx)(`p`,{className:`hidden min-w-0 truncate text-sm font-medium text-[var(--ink)] sm:block`,children:g?.name?`${g.name} · ${p.title}`:p.title})]}),(0,Y.jsx)(V,{tone:u.generating?`info`:`neutral`,children:u.generating?`正在生成`:It(p.status)})]}),(0,Y.jsx)(`div`,{className:`min-h-0`,children:(0,Y.jsx)(ot,{session:p,events:d.data.events,artifacts:m,className:`h-full`,viewModel:{turn:u.turnState,generating:u.generating},canLoadEarlier:d.data.hasMore,loadingEarlier:f.isPending,onLoadEarlier:()=>f.mutate(),onSend:e=>void u.send(e),onStop:u.generating?u.stop:void 0,onRetry:u.retry?()=>void u.retry?.():void 0,onSelectArtifact:e=>{qe(p.id,e).then(u.refresh)},composerTools:(0,Y.jsx)(Ot,{channel:_,publicationType:v,disabled:u.generating,onUploaded:e=>u.send({message:[`我上传了一个固定模板图片资源。请结合当前要求将它用于下一版固定 DSL 候选。`,`如果尚未确认固定 DSL 模式,请先实际询问是否切换;不要把资源字节写入候选。`,`资源元数据(可直接写入 DSL assets):${JSON.stringify(e)}`].join(`
|
|
6
|
-
`)})}),artifactWorkspace:h?(0,Y.jsx)(kt,{session:p,template:g,artifacts:m,artifact:h,onSelect:e=>void qe(p.id,e).then(u.refresh),onChanged:u.refresh,onArtifactUpdated:u.cacheArtifact,onSaved:async()=>{await a.invalidateQueries({queryKey:[`channel-templates`,_]}),await a.invalidateQueries({queryKey:[`workspace`]})}},h.id):(0,Y.jsx)(Dt,{})})})]})}function Ft(e){return e&&typeof e==`object`&&!Array.isArray(e)&&e.outputMode===`prompt_with_dsl`?`prompt_with_dsl`:`prompt_only`}function It(e){return e===W.Completed?`已保存,可继续优化`:e===W.Incompatible?`版本不可继续`:e===W.Archived?`已归档`:`制作中`}export{Nt as n,Pt as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{B as t,Ft as n,J as r,M as i,R as a,U as o,V as s,Y as c,et as l,k as u,ln as d,nn as f,rn as p,sn as m}from"./index-DC7b8xgR.js";import{t as h}from"./play-CqRcIakP.js";import{n as g,t as _}from"./react-ByivFozR.js";import"./types-D57tnOAh.js";import{n as ee}from"./use-workspace-snapshot-CZmWKC_d.js";import{t as v}from"./useMutation-C221JCx3.js";import{i as y}from"./articles-Bw-jie6T.js";import{t as b}from"./tabs-DT--ZcFL.js";import{t as x}from"./fingerprint-pattern-C_dvDw0n.js";import{t as S}from"./radio-tower-tBHGxqPI.js";import{t as C}from"./input-D7j_2GhD.js";import{t as w}from"./select-BUT5ahxS.js";import{n as T,r as E,t as D}from"./notifications-Dlx9WRAf.js";import{t as O}from"./form-field-BbOl9sGR.js";import{t as k}from"./AnimatePresence-OeIRE0Xw.js";import{t as A}from"./publication-destination-picker-p0aE3sNP.js";import{t as j}from"./src-DVp5YM1T.js";import{t as M}from"./-association-list-CE--B0dM.js";import{t as N}from"./useQuery-CH_PyDWC.js";import{a as P}from"./runs-DiLk0fOQ.js";import{t as F}from"./pagination-BIxivGX2.js";import{t as I}from"./-run-detail-view-Csh1ek6d.js";import{n as L,r as R,t as z}from"./-run-presentation-e-aAMUOA.js";var B=c(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),V=c(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),H=c(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),U=c(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),W=e(d(),1),G=m(),K=[[`basic`,`Agent 设置`,`策略、模型与预算`,U],[`identity`,`内容身份`,`定位、受众和语气`,x],[`knowledge`,`知识库`,`长期参考材料`,B],[`sources`,`输入来源`,`运行时内容输入`,V],[`publishing`,`发布账号`,`多渠道发布目的地`,S]];function q({section:e,onSectionChange:t,form:n,update:i,workspace:a,error:o}){let c=g(),u=K.findIndex(([t])=>t===e);return(0,G.jsxs)(`div`,{className:`grid min-h-0 gap-2 lg:h-full lg:grid-cols-[220px_minmax(0,1fr)] lg:overflow-hidden`,children:[(0,G.jsx)(`nav`,{"aria-label":`内容方案配置模块`,className:`min-w-0 overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] p-2 lg:h-full`,children:(0,G.jsx)(`div`,{className:`flex gap-1 overflow-x-auto lg:grid lg:overflow-visible`,children:K.map(([i,a,o,s])=>{let u=X(i,n);return(0,G.jsx)(`div`,{className:`min-w-[164px] lg:min-w-0`,children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(i),className:l(`relative isolate flex w-full items-center gap-3 overflow-hidden rounded-[var(--radius-sm)] px-2.5 py-2 text-left transition-colors duration-[var(--motion-base)] ease-[var(--ease-standard)]`,e===i?`text-[var(--ink)]`:`text-[var(--muted-strong)] hover:bg-[var(--surface-2)]`),children:[e===i?(0,G.jsx)(_.span,{layoutId:`content-plan-section-active`,className:`absolute inset-0 -z-10 rounded-[var(--radius-sm)] bg-[var(--surface-2)]`,transition:{duration:c?0:.28,ease:[.16,1,.3,1]}}):null,(0,G.jsx)(`span`,{className:`relative z-10 grid size-6 shrink-0 place-items-center text-[var(--muted-strong)]`,children:(0,G.jsx)(s,{className:`size-4`})}),(0,G.jsxs)(`span`,{className:`relative z-10 min-w-0 flex-1`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`strong`,{className:`block truncate text-sm font-semibold`,children:a}),u?(0,G.jsx)(r,{className:`size-3.5 shrink-0 text-[var(--success)]`}):null]}),(0,G.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-[var(--muted)]`,children:o})]})]})},i)})})}),(0,G.jsx)(`div`,{className:`scrollbar-stable min-h-[560px] min-w-0 overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] lg:h-full lg:min-h-0 lg:overflow-y-auto lg:overscroll-contain`,children:(0,G.jsx)(`div`,{className:`mx-auto w-full max-w-3xl px-5 py-5 sm:px-7 lg:py-6`,children:(0,G.jsx)(k,{initial:!1,mode:`wait`,custom:u,children:(0,G.jsxs)(_.div,{initial:{opacity:0,x:c?0:18,clipPath:c?`none`:`inset(0 0 0 12px)`},animate:{opacity:1,x:0,clipPath:`inset(0 0 0 0)`},exit:{opacity:0,x:c?0:-12,clipPath:c?`none`:`inset(0 12px 0 0)`},transition:{duration:c?0:.22,ease:[.16,1,.3,1]},children:[(0,G.jsx)(J,{section:e}),(0,G.jsx)(`div`,{className:`mt-6`,children:(0,G.jsx)(Y,{section:e,form:n,update:i,workspace:a})}),(0,G.jsx)(s,{error:o})]},e)})})})]})}function J({section:e}){let t=K.find(([t])=>t===e);return(0,G.jsxs)(`header`,{children:[(0,G.jsx)(`h3`,{className:`text-base font-semibold`,children:t[1]}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-[var(--muted-strong)]`,children:{basic:`选择 ReAct 策略和原生 Tool Calling 模型;策略不规定工具顺序。`,identity:`选择内容表达主体;身份只负责定位、受众、语气和边界。`,knowledge:`选择已上传的长期参考材料,不会在运行时重新抓取。`,sources:`选择 URL、查询等来源集合;工具连接统一在 Agent 设置中授权。`,publishing:`直接选择一个或多个账号;系统按渠道和发布类型启动独立 ReAct 会话。`}[e]})]})}function Y({section:e,form:t,update:n,workspace:r}){if(!r)return(0,G.jsx)(`p`,{className:`text-sm text-[var(--muted)]`,children:`正在加载配置…`});let i=new Map(r.connectorDefinitions.map(e=>[e.id,e])),a=e=>r.connections.filter(t=>t.enabled&&i.get(t.connectorId)?.capabilities.includes(e)),s=r.identities.filter(e=>e.enabled),c=r.knowledgeBases.filter(e=>e.enabled),l=r.sourceCollections.filter(e=>e.enabled);if(e===`basic`){let e=Z(t),o=r.connections.filter(e=>e.enabled?(i.get(e.connectorId)?.capabilities??[]).some(e=>[`source-search`,`source-fetch`].includes(e)):!1),s=e=>{let t=r.connections.find(t=>t.id===e);return t?{id:e,name:t.name,detail:i.get(t.connectorId)?.displayName??t.connectorId}:void 0};return(0,G.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-2`,children:[(0,G.jsx)(O,{label:`方案名称`,required:!0,children:(0,G.jsx)(C,{value:t.name,onChange:e=>n({...t,name:e.target.value}),placeholder:`例如:工程观察日报`})}),(0,G.jsx)(O,{label:`生成模型`,required:!0,children:(0,G.jsxs)(w,{value:e.modelConnectionId,onChange:r=>n({...t,connections:{...t.connections,chat:r.target.value},agent:{...e,modelConnectionId:r.target.value}}),children:[(0,G.jsx)(`option`,{value:``,children:`请选择 Chat 连接`}),a(`chat`).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,G.jsx)(O,{label:`内容策略`,required:!0,className:`md:col-span-2`,children:(0,G.jsx)(w,{value:e.strategyId,onChange:r=>n({...t,agent:{...e,strategyId:r.target.value}}),children:r.contentStrategies.map(e=>(0,G.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.description]},e.id))})}),(0,G.jsxs)(`section`,{className:`grid gap-2 border-t border-[var(--border)] pt-4 md:col-span-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`text-sm font-semibold`,children:`Agent 工具权限`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-strong)]`,children:`搜索和网页抓取连接会成为内容 Agent 的可调用工具;发布器工具由发布账号单独引用。`})]}),(0,G.jsx)(M,{items:e.toolConnectionIds.flatMap(e=>{let t=s(e);return t?[t]:[]}),available:o.filter(t=>!e.toolConnectionIds.includes(t.id)).map(e=>s(e.id)),empty:`尚未授权搜索或抓取工具`,addLabel:`添加工具连接`,onAdd:r=>n({...t,agent:{...e,toolConnectionIds:[...e.toolConnectionIds,r]}}),onRemove:r=>n({...t,agent:{...e,toolConnectionIds:e.toolConnectionIds.filter(e=>e!==r)}})})]}),(0,G.jsxs)(`details`,{className:`border-t border-[var(--border)] pt-4 md:col-span-2`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:`运行预算`}),(0,G.jsx)(`div`,{className:`mt-4 max-w-sm`,children:(0,G.jsx)(O,{label:`最大 Agent 轮次`,helper:`默认 24,范围 1–100;最后一轮只用于提交当前最佳结果`,children:(0,G.jsx)(C,{type:`number`,min:1,max:100,value:e.budget?.maxTurns??24,onChange:r=>n({...t,agent:{...e,budget:{...e.budget,maxTurns:Number(r.target.value)}}})})})})]})]})}if(e===`identity`){if(!s.length)return(0,G.jsx)(T,{className:`min-h-48 border-y border-[var(--border)]`,title:`还没有内容身份`,description:`先创建一个身份,定义内容的定位、受众、语气和表达边界。`,action:(0,G.jsx)(o,{size:`sm`,onClick:()=>window.location.href=`/dashboard/identities`,children:`创建内容身份`})});let e=r.identities.find(e=>e.id===t.identityId);return(0,G.jsx)(M,{items:e?[{id:e.id,name:e.name,detail:`定位:${e.positioning} 语气:${e.tone}`}]:[],available:e?[]:s.map(e=>({id:e.id,name:e.name,detail:`定位:${e.positioning} 语气:${e.tone}`})),empty:`还没有添加内容身份`,addLabel:`添加内容身份`,onAdd:e=>n({...t,identityId:e}),onRemove:()=>n({...t,identityId:``})})}return e===`knowledge`?c.length?(0,G.jsx)(M,{items:t.knowledgeBaseIds.flatMap(e=>{let t=r.knowledgeBases.find(t=>t.id===e);return t?[{id:t.id,name:t.name,detail:`${t.documents.length} 份参考文档`}]:[]}),available:c.filter(e=>!t.knowledgeBaseIds.includes(e.id)).map(e=>({id:e.id,name:e.name,detail:`${e.documents.length} 份参考文档`})),empty:`还没有添加知识库`,addLabel:`添加知识库`,onAdd:e=>n({...t,knowledgeBaseIds:[...t.knowledgeBaseIds,e]}),onRemove:e=>n({...t,knowledgeBaseIds:t.knowledgeBaseIds.filter(t=>t!==e)})}):(0,G.jsx)(T,{className:`min-h-48 border-y border-[var(--border)]`,title:`还没有知识库`,description:`知识库用于保存长期参考材料;这一步也可以暂时跳过。`,action:(0,G.jsx)(o,{size:`sm`,onClick:()=>window.location.href=`/dashboard/knowledge`,children:`新建知识库`})}):e===`sources`?(0,G.jsx)(M,{items:t.sourceCollectionIds.flatMap(e=>{let t=r.sourceCollections.find(t=>t.id===e);return t?[{id:t.id,name:t.name,detail:`${t.sources.filter(e=>e.enabled).length} 个动态来源`}]:[]}),available:l.filter(e=>!t.sourceCollectionIds.includes(e.id)).map(e=>({id:e.id,name:e.name,detail:`${e.sources.filter(e=>e.enabled).length} 个动态来源`})),empty:`还没有添加输入来源`,addLabel:`添加来源集合`,onAdd:e=>n({...t,sourceCollectionIds:[...t.sourceCollectionIds,e]}),onRemove:e=>n({...t,sourceCollectionIds:t.sourceCollectionIds.filter(t=>t!==e)})}):e===`publishing`?(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsx)(A,{accounts:r.channelAccounts,channels:r.channelDefinitions,profiles:r.publicationTypeProfiles,templates:r.channelTemplates,writingStyles:r.writingStyles,value:t.publishing.destinations,onChange:e=>n({...t,publishing:{destinations:e}})}),t.publishing.destinations.length?(0,G.jsx)(`p`,{className:`text-xs leading-5 text-[var(--muted-strong)]`,children:`每个账号与发布类型会独立格式化、上传和发布;单个失败不会中断其他目的地。`}):(0,G.jsx)(`p`,{className:`text-sm text-[var(--muted-strong)]`,children:`未选择发布账号:运行后仅生成可发布内容包,不经过额外审核门禁。`})]}):null}function X(e,t){return e===`basic`?!!(t.name.trim()&&t.agent?.modelConnectionId):e!==`identity`||!!t.identityId}function Z(e){return e.agent??{modelConnectionId:e.connections.chat??``,strategyId:`daily-brief`,toolConnectionIds:[...e.researchConnections?.search??[],...e.researchConnections?.fetch??[],...e.connections.image?[e.connections.image]:[]].filter((e,t,n)=>n.indexOf(e)===t)}}function te(e,t){let n=new Map(e.connectorDefinitions.map(e=>[e.id,e]));return e.connections.filter(e=>e.enabled&&n.get(e.connectorId)?.capabilities.includes(t))}var Q=20;function ne({planId:e,startedRunId:t,runError:n}){let r=f(),i=a.useSearch(),o=i.runPage??1,{data:c}=N({queryKey:[`runs`,`plan`,e,o],queryFn:()=>P(o,Q,e),enabled:!!e,refetchInterval:2e3}),u=c?.items??[],d=typeof i.run==`string`&&u.some(e=>e.id===i.run)?i.run:u[0]?.id??null;return(0,W.useEffect)(()=>{t&&r({to:`.`,search:e=>({...e,runPage:1,run:t,destination:void 0}),replace:!0,resetScroll:!1})},[r,t]),e?(0,G.jsxs)(`div`,{className:`grid min-h-0 gap-2 lg:h-full lg:grid-cols-[250px_minmax(0,1fr)] lg:overflow-hidden`,children:[(0,G.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,children:[(0,G.jsxs)(`div`,{className:`border-b border-[var(--border)] px-4 py-3.5`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold`,children:`运行记录`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted-strong)]`,children:`主会话与发布会话统一归档。`})]}),u.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`scrollbar-stable min-h-0 flex-1 divide-y divide-[var(--border)] lg:overflow-y-auto lg:overscroll-contain`,children:u.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void r({to:`.`,search:t=>({...t,run:e.id}),resetScroll:!1}),className:l(`flex min-h-10 w-full items-center gap-2 px-3 py-2 text-left hover:bg-[var(--surface-2)]`,d===e.id&&`bg-[var(--surface-2)]`),children:[(0,G.jsx)(`strong`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:z(e)}),(0,G.jsx)(E,{tone:R(e.status),children:L(e.status)})]},e.id))}),(0,G.jsx)(F,{compact:!0,className:`shrink-0 border-t border-[var(--border)]`,page:o,pageSize:Q,total:c?.total??0,onChange:e=>void r({to:`.`,search:t=>({...t,runPage:e,run:void 0,destination:void 0}),resetScroll:!1})})]}):(0,G.jsx)(T,{className:`min-h-64`,title:`还没有运行记录`,description:`运行内容方案后会显示在这里。`})]}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,G.jsx)(s,{error:n}),(0,G.jsx)(I,{className:`min-h-0 flex-1`,runId:d,planScoped:!0})]})]}):(0,G.jsx)(T,{className:`min-h-[420px] rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,title:`保存后显示运行记录`,description:`运行记录会按内容方案过滤。`})}function $(){return{name:``,enabled:!0,identityId:``,knowledgeBaseIds:[],sourceCollectionIds:[],connections:{},researchConnections:{search:[],fetch:[]},agent:{modelConnectionId:``,strategyId:j,toolConnectionIds:[]},publishing:{destinations:[]}}}function re(e){let t=n();return v({mutationFn:t=>e?i(e,t):u(t),onSuccess:()=>t.invalidateQueries({queryKey:[`content-plans`]})})}function ie(){let e=p({strict:!1}).planId,[r,i]=(0,W.useState)(),s=e??r,{data:c}=ee({live:!1}),l=re(s),u=n(),d=f(),m=a.useSearch(),x=m.tab===`runs`?`runs`:`config`,S=ae(m.panel),[C,w]=(0,W.useState)(1),[T,E]=(0,W.useState)($),[O,A]=(0,W.useState)(!1),[M,N]=(0,W.useState)(null),[P,F]=(0,W.useState)(null),I=t(),L=g(),R=(0,W.useRef)(null),z=c?.contentPlans.find(e=>e.id===s),B=v({mutationFn:e=>y({planId:e}),onSuccess:e=>{F(e.run.id),u.invalidateQueries({queryKey:[`runs`]}),D.success(`运行已启动`,`可在运行记录中查看实时活动。`)},onError:e=>D.error(`启动运行失败`,e)});(0,W.useEffect)(()=>{if(!c)return;let e=s??`__new__`;if(R.current!==e&&(!s||z)){if(s&&z)E({...z,revision:z.revision,knowledgeBaseIds:z.knowledgeBaseIds??[],researchConnections:z.researchConnections??{search:[],fetch:[]},publishing:z.publishing??{destinations:[]},agent:z.agent??{modelConnectionId:z.connections.chat??``,strategyId:j,toolConnectionIds:[...z.researchConnections?.search??[],...z.researchConnections?.fetch??[],...z.connections.image?[z.connections.image]:[]].filter((e,t,n)=>n.indexOf(e)===t)}});else if(!s){let e=$();e.identityId=c.identities.find(e=>e.enabled)?.id??``,e.connections.chat=te(c,`chat`)[0]?.id??``,e.agent.modelConnectionId=e.connections.chat,E(e)}R.current=e,A(!1)}},[c,z,s]),(0,W.useEffect)(()=>{let e=e=>{O&&e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[O]);let V=e=>{E(e),A(!0),N(null)},K=e=>{e!==x&&(w(e===`runs`?1:-1),d({to:`.`,search:t=>({...t,tab:e}),resetScroll:!1}))},J=e=>{x!==`config`&&w(-1),d({to:`.`,search:t=>({...t,tab:`config`,panel:e}),resetScroll:!1})},Y=()=>{O?I({title:`放弃未保存的修改?`,description:`当前配置修改尚未保存,离开后无法恢复。`,confirmLabel:`放弃修改`,action:()=>d({to:`/content-plans`,search:{page:1}})}):d({to:`/content-plans`,search:{page:1}})},X=()=>T.name.trim()?T.agent?.modelConnectionId?T.identityId?(N(null),!0):(J(`identity`),N(Error(`请添加内容身份`)),!1):(J(`basic`),N(Error(`请选择生成模型连接`)),!1):(J(`basic`),N(Error(`请填写方案名称`)),!1),Z=()=>{J(S),X()&&l.mutate(T,{onSuccess:()=>{A(!1),D.success(`内容方案已保存`,`“${T.name.trim()}”的配置已更新。`),d({to:`/content-plans`,search:{page:1}})},onError:e=>D.error(`保存内容方案失败`,e)})},Q=async()=>{if(!X())return;let e=s;if(!e||O)try{let t=await l.mutateAsync(T);e=t.contentPlan.id,i(e=>e??t.contentPlan.id),E(e=>({...e,revision:t.contentPlan.revision})),A(!1)}catch(e){D.error(`保存内容方案失败`,e);return}B.mutate(e)};return e&&c&&!z?(0,G.jsx)(`div`,{className:`rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] p-8 text-sm`,children:`内容方案不存在或已被删除。`}):(0,G.jsxs)(`section`,{className:`grid gap-4 lg:h-[calc(100dvh-6rem)] lg:grid-rows-[auto_minmax(0,1fr)] lg:overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsx)(b,{value:x,onChange:K,className:`w-fit`,items:[{value:`config`,label:`配置`,icon:(0,G.jsx)(U,{className:`size-3.5`})},{value:`runs`,label:`运行记录`,icon:(0,G.jsx)(H,{className:`size-3.5`})}]}),(0,G.jsx)(k,{initial:!1,mode:`popLayout`,children:x===`config`?(0,G.jsxs)(_.div,{initial:{opacity:0,x:L?0:12},animate:{opacity:1,x:0},exit:{opacity:0,x:L?0:-8},transition:{duration:L?0:.18,ease:[.16,1,.3,1]},className:`flex gap-2`,children:[(0,G.jsx)(o,{size:`sm`,variant:`ghost`,onClick:Y,children:`取消`}),(0,G.jsx)(o,{size:`sm`,variant:`primary`,loading:l.isPending,onClick:Z,children:`保存方案`})]},`config-actions`):(0,G.jsx)(_.div,{initial:{opacity:0,x:L?0:12},animate:{opacity:1,x:0},exit:{opacity:0,x:L?0:-8},transition:{duration:L?0:.18,ease:[.16,1,.3,1]},children:(0,G.jsxs)(o,{size:`sm`,variant:`primary`,loading:l.isPending||B.isPending,title:O||!s?`保存当前配置并运行`:`运行内容方案`,onClick:()=>void Q(),children:[(0,G.jsx)(h,{className:`size-3.5`}),`运行`]})},`run-action`)})]}),(0,G.jsx)(`div`,{className:`relative min-h-0 overflow-hidden`,children:(0,G.jsx)(k,{initial:!1,mode:`popLayout`,custom:C,children:(0,G.jsx)(_.div,{custom:C,initial:{opacity:0,x:L?0:C*22,filter:L?`none`:`blur(3px)`},animate:{opacity:1,x:0,filter:`none`},exit:{opacity:0,x:L?0:C*-14,filter:L?`none`:`blur(2px)`},transition:{duration:L?0:.24,ease:[.16,1,.3,1]},className:`h-full min-h-0`,children:x===`config`?(0,G.jsx)(q,{section:S,onSectionChange:J,form:T,update:V,workspace:c,error:M??l.error}):(0,G.jsx)(ne,{planId:s,startedRunId:P,runError:B.error??l.error})},x)})})]})}function ae(e){return e===`identity`||e===`knowledge`||e===`sources`||e===`publishing`?e:`basic`}export{ie as t};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{Ft as t,R as n,U as r,V as i,Y as a,et as o,ln as s,nn as c,sn as l}from"./index-DC7b8xgR.js";import{t as u}from"./useMutation-C221JCx3.js";import{t as d}from"./useQuery-CH_PyDWC.js";import{n as f,r as p,t as m}from"./wrench-BHwKK2nB.js";import{t as h}from"./eye-Drma9Anf.js";import{n as g,t as _}from"./react-ByivFozR.js";import"./types-D57tnOAh.js";import{c as v,i as y,l as b,n as x,o as ee,r as te,s as ne,t as re}from"./runs-DiLk0fOQ.js";import{n as ie,o as S,t as ae}from"./articles-Bw-jie6T.js";import{n as C,r as w,t as T}from"./notifications-Dlx9WRAf.js";import{t as E}from"./AnimatePresence-OeIRE0Xw.js";import{a as D,i as O,o as k,r as oe}from"./execution-Brd94hIY.js";import{t as se}from"./app-dialog-ChNc5zc0.js";import{t as ce}from"./-content-package-preview-DC4PLY9G.js";import{a as le,i as ue,n as A,o as j,r as M,t as N}from"./-run-presentation-e-aAMUOA.js";import{t as P}from"./newspaper-Dcqy9j6N.js";import{t as F}from"./chevron-down-DXrCAjpz.js";var I=a(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),L=a(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),R=a(`file-output`,[[`path`,{d:`M4.226 20.925A2 2 0 0 0 6 22h12a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.127`,key:`wfxp4w`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 11-3 3`,key:`1dgrs4`}],[`path`,{d:`m5 17-3-3h10`,key:`1mvvaf`}]]),z=a(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),de=a(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),B=a(`video`,[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]),V=e(s(),1),H=2e3;function fe(e){let n=t(),[r,i]=(0,V.useState)([]),[a,o]=(0,V.useState)(()=>e?G.read(e):[]),[s,c]=(0,V.useState)(`idle`),[l,u]=(0,V.useState)(`idle`),[f,p]=(0,V.useState)(!1),m=(0,V.useRef)(0),h=(0,V.useRef)(0),g=d({queryKey:[`runs`,e],queryFn:()=>te(e??``),enabled:!!e,refetchInterval:e=>U(e.state.data?.run.status)?H:!1}),_=d({queryKey:[`runs`,e,`activities`],queryFn:()=>y(e??``),enabled:!!e,refetchInterval:s===`unavailable`&&H}),x=(0,V.useMemo)(()=>W(_.data?.activities??[],r),[_.data?.activities,r]);return(0,V.useEffect)(()=>{i([]),o(e?G.read(e):[]),p(!1)},[e]),(0,V.useEffect)(()=>{if(!e)return;let t=++m.current,r=new AbortController,a,o=0,s=x.at(-1)?.sequence??0,l=()=>t===m.current&&!r.signal.aborted,u=async()=>{if(l()){c(o?`retrying`:`connecting`);try{await v(e,{signal:r.signal,afterSequence:s,lastEventId:s?String(s):void 0,onOpen:()=>l()&&c(`live`),onEvent:t=>{l()&&(s=Math.max(s,t.sequence),i(e=>W(e,[t])),n.invalidateQueries({queryKey:[`runs`,e]}))}})}catch{if(!l())return;o+=1,c(o>=5?`unavailable`:`retrying`),a=setTimeout(()=>void u(),Math.min(1e3*2**o,15e3))}}};return u(),()=>{r.abort(),a&&clearTimeout(a)}},[n,e]),(0,V.useEffect)(()=>{if(!e||!U(g.data?.run.status))return;G.read(e).length&&p(!0);let t=++h.current,n=new AbortController,r,i=0,a=()=>t===h.current&&!n.signal.aborted,s=async()=>{if(a()){u(i?`retrying`:`connecting`);try{await b(e,{signal:n.signal,onOpen:()=>a()&&u(`live`),onEvent:t=>{a()&&o(G.remember(e,t))}})}catch{if(!a())return;p(!0),i+=1,u(`retrying`),r=setTimeout(()=>void s(),Math.min(1e3*2**i,15e3))}}};return s(),()=>{n.abort(),r&&clearTimeout(r)}},[g.data?.run.status,e]),{...g,activities:x,modelEvents:a,activityStreamState:s,modelStreamState:l,modelStreamInterrupted:f}}function U(e){return e===k.Queued||e===k.Running}function W(e,t){let n=new Map(e.map(e=>[e.id,e]));return t.forEach(e=>{let t=n.get(e.id);(!t||e.sequence>=t.sequence)&&n.set(e.id,e)}),[...n.values()].sort((e,t)=>e.sequence-t.sequence)}var G=new class{maxRuns;maxEventsPerRun;streams=new Map;constructor(e=20,t=1e3){this.maxRuns=e,this.maxEventsPerRun=t}read(e){return[...this.streams.get(e)??[]]}remember(e,t){let n=[...this.streams.get(e)??[],t].slice(-this.maxEventsPerRun);for(this.streams.delete(e),this.streams.set(e,n);this.streams.size>this.maxRuns;){let e=this.streams.keys().next().value;if(typeof e!=`string`)break;this.streams.delete(e)}return[...n]}},K=l(),q=68,J=10;function pe({sessions:e,selected:t,sourceTitle:n,onSelect:r}){let i=g(),a=e.length*q+Math.max(0,e.length-1)*J,s=a/2,c=e.findIndex(e=>e.id===t);return(0,K.jsxs)(`section`,{className:`overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-[var(--border)] px-4 py-3`,children:[(0,K.jsx)(`strong`,{className:`text-sm`,children:`发布流程`}),(0,K.jsxs)(`span`,{className:`text-[11px] text-[var(--muted)]`,children:[e.filter(e=>e.status===k.Succeeded).length,`/`,e.length,` 个目的地完成`]})]}),(0,K.jsxs)(`div`,{className:`publication-flow-canvas`,children:[(0,K.jsx)(_.div,{className:`publication-flow-source-wrap`,initial:{opacity:0,x:i?0:-10},animate:{opacity:1,x:0},transition:{duration:i?0:.32,ease:[.16,1,.3,1]},children:(0,K.jsxs)(`div`,{className:`publication-flow-source publication-flow-node`,children:[(0,K.jsx)(`span`,{className:`publication-flow-icon`,children:(0,K.jsx)(R,{className:`size-4`})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`strong`,{className:`block truncate text-xs font-semibold`,children:`可发布内容包`}),(0,K.jsx)(`span`,{className:`mt-0.5 block truncate text-[11px] text-[var(--muted)]`,children:n})]})]})}),(0,K.jsxs)(`div`,{className:`publication-flow-rail`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{className:`publication-flow-line publication-flow-source-line`,style:{top:s}}),(0,K.jsx)(`span`,{className:`publication-flow-line publication-flow-trunk`,style:{top:q/2,height:Math.max(0,a-q)}}),e.map((e,t)=>{let n=X(t);return(0,K.jsx)(`span`,{className:`publication-flow-line publication-flow-branch`,"data-status":e.status,style:{top:n}},`branch-${e.id}`)}),c>=0?(0,K.jsx)(Y,{className:`publication-flow-selection-line`,sourceY:s,targetY:X(c)}):null,e.map((e,t)=>e.status===k.Running?(0,K.jsx)(Y,{className:`publication-flow-signal`,sourceY:s,targetY:X(t),animated:!0},`signal-${e.id}`):null)]}),(0,K.jsx)(`div`,{className:`publication-flow-destinations`,children:e.map((e,n)=>{let a=t===e.id;return(0,K.jsxs)(_.button,{layout:`position`,type:`button`,"aria-pressed":a,onClick:()=>r(e.id),initial:{opacity:0,x:i?0:12},animate:{opacity:1,x:0},transition:{duration:i?0:.3,delay:i?0:Math.min(n*.045,.18),ease:[.16,1,.3,1]},className:o(`publication-flow-channel publication-flow-node`,a&&`is-selected`),children:[a?(0,K.jsx)(_.span,{layoutId:`publication-flow-selected-node`,className:`publication-flow-selection`,transition:{duration:i?0:.24,ease:[.16,1,.3,1]}}):null,(0,K.jsx)(`span`,{className:`publication-flow-port`,"data-status":e.status}),(0,K.jsx)(`span`,{className:`publication-flow-icon`,children:me(e)}),(0,K.jsxs)(`span`,{className:`relative min-w-0 flex-1 text-left`,children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,K.jsx)(`strong`,{className:`truncate text-xs font-semibold`,children:e.destination?.accountName??`发布账号`}),(0,K.jsx)(w,{tone:M(e.status),children:A(e.status)})]}),(0,K.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-[var(--muted)]`,children:[Z(e),` · `,e.currentActivity??`等待开始`]})]})]},e.id)})})]})]})}function Y({className:e,sourceY:t,targetY:n,animated:r=!1}){let i=Math.min(t,n),a=Math.abs(t-n);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:o(e,`publication-flow-path-source`,r&&`is-animated`),style:{top:t}}),a?(0,K.jsx)(`span`,{className:o(e,`publication-flow-path-vertical`,r&&`is-animated`),"data-direction":n<t?`up`:`down`,style:{top:i,height:a}}):null,(0,K.jsx)(`span`,{className:o(e,`publication-flow-path-branch`,r&&`is-animated`),style:{top:n}})]})}function X(e){return q/2+e*78}function Z(e){let t=e.destination?.channel,n=e.destination?.publicationType;return`${t===`weixin-official-account`?`微信公众号`:t||`发布渠道`} · ${n===`article`?`图文`:n||`内容`}`}function me(e){return e.destination?.publicationType===`video`?(0,K.jsx)(B,{className:`size-4`}):e.destination?.publicationType===`audio`?(0,K.jsx)(I,{className:`size-4`}):e.destination?.channel===`weixin-official-account`?(0,K.jsx)(P,{className:`size-4`}):(0,K.jsx)(S,{className:`size-4`})}function he(e){return e.kind===D.Publication&&e.destination?.channel===`weixin-official-account`&&e.destination.publicationType===`article`}function ge({mode:e,preview:t,pending:n,error:r,onOpenChange:a}){let o=e===`cover`?`微信封面预览`:`微信 HTML 预览`;return(0,K.jsx)(se,{open:e!==null,onOpenChange:a,title:t?.title||o,description:o,size:e===`html`?`wide`:`medium`,children:n?(0,K.jsx)(`div`,{className:`grid min-h-72 place-items-center`,"aria-live":`polite`,children:(0,K.jsx)(`span`,{className:`text-sm text-[var(--muted)]`,children:`正在读取渠道准备结果…`})}):r?(0,K.jsxs)(`div`,{className:`grid min-h-48 content-center gap-3`,children:[(0,K.jsx)(i,{error:r}),(0,K.jsx)(`p`,{className:`text-center text-xs leading-5 text-[var(--muted)]`,children:`渠道 ReAct 完成内容准备后即可查看,不需要等待发布执行结束。`})]}):e===`cover`?t?.cover?(0,K.jsxs)(`figure`,{className:`grid gap-3`,children:[(0,K.jsx)(`div`,{className:`grid aspect-video place-items-center overflow-hidden rounded-[var(--radius-sm)] bg-[var(--surface-2)]`,children:(0,K.jsx)(`img`,{src:t.cover.source,alt:t.cover.alt||`${t.title}封面`,className:`h-full w-full object-contain`})}),(0,K.jsx)(`figcaption`,{className:`text-center text-xs leading-5 text-[var(--muted)]`,children:t.cover.alt||t.title})]}):(0,K.jsx)(C,{title:`没有可预览的封面`,description:`渠道准备结果未包含安全的封面图片地址。`}):t?.body.format===`html`?(0,K.jsxs)(`div`,{className:`grid gap-3`,children:[t.adaptation?(0,K.jsxs)(`details`,{className:`rounded-[var(--radius-sm)] border border-[var(--border)] bg-[var(--surface-2)] px-3 py-2 text-xs`,children:[(0,K.jsxs)(`summary`,{className:`cursor-pointer font-medium text-[var(--ink)]`,children:[`已按写作风格「`,t.adaptation.styleName,`」改写(点击查看改写文案)`]}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-sans text-xs leading-5 text-[var(--muted-strong)]`,children:t.adaptation.bodyMarkdown})]}):null,(0,K.jsx)(`iframe`,{title:`${t.title}微信 HTML 预览`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:_e(t.body.content),className:`h-[min(680px,70dvh)] w-full rounded-[var(--radius-sm)] border border-[var(--border)] bg-white`})]}):(0,K.jsx)(C,{title:`没有 HTML 预览`,description:`该渠道准备结果不是 HTML 格式。`})})}function _e(e){return`<!doctype html>
|
|
2
|
-
<html lang="zh-CN">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta name="referrer" content="no-referrer">
|
|
6
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
7
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data: http: https:; style-src 'unsafe-inline'; font-src data: http: https:; base-uri 'none'; form-action 'none'">
|
|
8
|
-
<style>html{background:#fff}body{box-sizing:border-box;max-width:677px;margin:0 auto;padding:24px 20px;color:#222;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;overflow-wrap:anywhere}img{max-width:100%;height:auto}pre{overflow:auto;white-space:pre-wrap}table{max-width:100%;border-collapse:collapse}</style>
|
|
9
|
-
</head>
|
|
10
|
-
<body>${e}</body>
|
|
11
|
-
</html>`}function ve({session:e,activities:t,modelEvents:n,retrying:i,hideHeader:a,onPreviewCover:o,onPreviewHtml:s,onRetry:c}){return(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[a?null:(0,K.jsx)(`section`,{className:`rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] p-4`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{className:`text-sm`,children:j(e)}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-[var(--muted)]`,children:e.kind===D.Publication?`渠道内容准备 · 发布执行`:`动态 ReAct 主会话`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o?(0,K.jsxs)(r,{size:`sm`,onClick:o,children:[(0,K.jsx)(z,{className:`size-4`}),`封面预览`]}):null,s?(0,K.jsxs)(r,{size:`sm`,onClick:s,children:[(0,K.jsx)(L,{className:`size-4`}),`HTML 预览`]}):null,(0,K.jsx)(w,{tone:M(e.status),children:A(e.status)}),c?(0,K.jsxs)(r,{loading:i,onClick:c,children:[(0,K.jsx)(f,{className:`size-4`}),`重试目的地`]}):null]})]})}),(0,K.jsx)(ye,{activities:be(t,e),modelEvents:n})]})}function ye({activities:e,modelEvents:t}){let n=(0,V.useMemo)(()=>we(t),[t]),r=(0,V.useMemo)(()=>e.filter(e=>!xe(e)),[e]);return(0,K.jsxs)(`section`,{className:`overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--border)] px-4 py-3`,children:[(0,K.jsx)(m,{className:`size-4`}),(0,K.jsx)(`strong`,{className:`text-sm`,children:`运行活动`}),(0,K.jsx)(`span`,{className:`text-[11px] text-[var(--muted)]`,children:`可恢复历史`})]}),r.length?(0,K.jsx)(`ol`,{className:`divide-y divide-[var(--border)]`,children:(0,K.jsx)(E,{initial:!1,children:r.map(e=>(0,K.jsx)(Se,{activity:e,modelOutput:e.taskId?n.get(e.taskId):void 0},e.id))})}):(0,K.jsx)(`p`,{className:`px-4 py-8 text-center text-xs text-[var(--muted)]`,children:`尚无活动记录`})]})}function be(e,t){return t.status!==k.Failed&&t.status!==k.NeedsAttention?e:e.map(e=>e.status===O.Running?{...e,status:t.status===k.NeedsAttention?O.NeedsAttention:O.Failed,error:e.error??(t.status===k.NeedsAttention?`服务重启,本轮执行已中断`:t.error),finishedAt:t.finishedAt??t.updatedAt,updatedAt:t.finishedAt??t.updatedAt}:e)}function xe(e){return!!e.taskId?.split(`/`).includes(`quality`)}function Se({activity:e,modelOutput:t}){let[n,r]=(0,V.useState)(!1),i=e.kind===oe.ModelTurn,a=g();return(0,K.jsxs)(_.li,{layout:`position`,initial:{opacity:0,y:a?0:8,filter:a?`none`:`blur(3px)`},animate:{opacity:1,y:0,filter:`none`},exit:{opacity:0,y:a?0:-4},transition:{duration:a?0:.2,ease:[.16,1,.3,1]},className:`px-4 py-3`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`grid w-full grid-cols-[minmax(0,1fr)_auto] gap-4 text-left`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`strong`,{className:`truncate text-xs font-medium`,children:e.label}),(0,K.jsx)(w,{tone:Le(e.status),children:Ie(e)})]}),e.summary?(0,K.jsx)(`span`,{className:`mt-1 block text-[11px] text-[var(--muted)]`,children:e.summary}):null]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-2 text-[10px] text-[var(--muted)]`,children:[new Date(e.updatedAt).toLocaleTimeString(),(0,K.jsx)(F,{className:o(`size-3 transition-transform`,n&&`rotate-180`)})]})]}),e.error?(0,K.jsx)(`p`,{className:`mt-2 text-xs text-[var(--danger)]`,children:e.error}):null,i&&(t||e.status===O.Running)?(0,K.jsx)(Ce,{activity:e,output:t}):null,(0,K.jsx)(E,{initial:!1,children:n?(0,K.jsx)(_.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:a?0:.22,ease:[.16,1,.3,1]},className:`overflow-hidden`,children:(0,K.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-[var(--border)] pt-3`,children:[(0,K.jsxs)(`p`,{className:`font-mono text-[10px] text-[var(--muted)]`,children:[e.taskId??e.id,` · 尝试 `,e.attempt??1]}),e.input===void 0?null:(0,K.jsx)(Q,{title:`输入摘要`,value:e.input}),e.output===void 0?null:(0,K.jsx)(Q,{title:`输出摘要`,value:e.output})]})}):null})]})}function Ce({activity:e,output:t}){let n=Me(e);return(0,K.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-[var(--muted)]`,children:[(0,K.jsx)(`span`,{children:t?.model??`模型生成中`}),(0,K.jsxs)(`span`,{children:[Te(t),` 字符`]}),t?.toolCharacters?(0,K.jsxs)(`span`,{children:[`工具参数 `,t.toolCharacters,` 字符`]}):null,t?.tokens===void 0?null:(0,K.jsxs)(`span`,{children:[t.tokens,` tokens`]}),(0,K.jsx)(`span`,{children:Pe(n)})]}),t?.content?(0,K.jsx)(ke,{value:t.content,className:`max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-[var(--radius-sm)] bg-[var(--surface-2)] p-3 font-mono text-[11px] leading-5`}):null,(t?.tools??[]).map(e=>(0,K.jsx)(ke,{value:De(e.arguments),className:`max-h-44 overflow-auto whitespace-pre-wrap break-all rounded-[var(--radius-sm)] border border-[var(--border)] p-3 font-mono text-[10px] leading-5`,prefix:(0,K.jsx)(`strong`,{children:e.name||`Tool Call ${e.index+1}`})},e.index))]})}function Q({title:e,value:t}){return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`strong`,{className:`text-[10px] text-[var(--muted)]`,children:e}),(0,K.jsx)(`pre`,{className:`mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-all rounded bg-[var(--surface-2)] p-2 font-mono text-[10px] leading-5`,children:JSON.stringify(t,null,2)})]})}function we(e){let t=new Map;for(let n of e){if(!n.taskId)continue;let e=Fe(n.data),r=t.get(n.taskId)??{content:``,characters:0,toolCharacters:0,partial:!1,tools:[]};if(typeof e.model==`string`&&(r.model=e.model),n.type===`response.delta`&&typeof e.delta==`string`){r.content+=e.delta;let t=typeof e.accumulatedCharacters==`number`?e.accumulatedCharacters:r.content.length;r.characters=t,t>r.content.length&&(r.partial=!0)}if(n.type===`response.tool_delta`){let t=typeof e.index==`number`?e.index:0,n=r.tools.find(e=>e.index===t)??{index:t,arguments:``};r.tools.includes(n)||r.tools.push(n),typeof e.name==`string`&&(n.name=e.name),typeof e.accumulatedArguments==`string`&&(n.arguments=e.accumulatedArguments),r.toolCharacters=r.tools.reduce((e,t)=>e+t.arguments.length,0)}n.type===`response.completed`&&(r.tokens=Ee(e.usage),typeof e.accumulatedCharacters==`number`&&(r.characters=e.accumulatedCharacters,e.accumulatedCharacters>r.content.length&&(r.partial=!0))),t.set(n.taskId,r)}return t}function Te(e){return(e?.characters??0)+(e?.toolCharacters??0)}function Ee(e){let t=Fe(e??null),n=t.totalTokens??t.total_tokens;return typeof n==`number`?n:void 0}function De(e){if(!e.trim())return`等待参数…`;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return Oe(e)}}function Oe(e){return e.replace(/\\u([\dA-Fa-f]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}function ke({value:e,className:t,prefix:n}){let r=(0,V.useRef)(null);return Ae(r,e),(0,K.jsxs)(`pre`,{ref:r,className:t,children:[n?(0,K.jsxs)(K.Fragment,{children:[n,`
|
|
12
|
-
`]}):null,e]})}function Ae(e,t,n=!0,r){let i=(0,V.useRef)(!0),a=(0,V.useRef)(r);(0,V.useEffect)(()=>{a.current!==r&&(a.current=r,i.current=!1,n&&e.current&&(e.current.scrollTop=0))},[n,e,r]),(0,V.useEffect)(()=>{let t=e.current;if(!n||!t)return;let r=()=>{i.current=je(t)};return t.addEventListener(`scroll`,r,{passive:!0}),()=>t.removeEventListener(`scroll`,r)},[n,e]),(0,V.useEffect)(()=>{n&&e.current&&i.current&&(e.current.scrollTop=e.current.scrollHeight)},[n,e,t])}function je(e){return e.scrollHeight-e.clientHeight-e.scrollTop<=32}function Me(e){let t=e.status===O.Running,[n,r]=(0,V.useState)(()=>Date.now());return(0,V.useEffect)(()=>{if(!t)return;r(Date.now());let e=window.setInterval(()=>r(Date.now()),100);return()=>window.clearInterval(e)},[t]),Ne(e,n)}function Ne(e,t=Date.now()){let n=Date.parse(e.startedAt);if(!Number.isFinite(n))return 0;let r=e.finishedAt?Date.parse(e.finishedAt):NaN,i=e.status===O.Running||!Number.isFinite(r)?t:r;return Math.max(0,i-n)}function Pe(e){return e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}function Fe(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Ie(e){return e.status===O.Running?`进行中`:e.status===O.Succeeded?`完成`:e.status===O.NeedsAttention&&e.error?.includes(`本轮执行已中断`)?`已中断`:e.status===O.NeedsAttention?`需要处理`:`失败`}function Le(e){return e===O.Running?`info`:e===O.Succeeded?`success`:e===O.NeedsAttention?`warning`:`danger`}function $(e){return e===`live`?`实时`:e===`retrying`?`恢复中`:e===`unavailable`?`轮询`:e===`connecting`?`连接中`:`待机`}function Re({runId:e,className:a,planScoped:s=!1}){let l=fe(e),m=t(),v=c(),y=n.useSearch(),[b,te]=(0,V.useState)(1),[S,O]=(0,V.useState)(1),[oe,j]=(0,V.useState)(!1),[P,F]=(0,V.useState)(null),I=(0,V.useId)(),L=g(),R=u({mutationFn:()=>ee(e),onSuccess:()=>(T.success(`运行已恢复`,`执行器将从安全检查点继续。`),m.invalidateQueries({queryKey:[`runs`,e]})),onError:e=>T.error(`恢复运行失败`,e)}),z=u({mutationFn:t=>ne(e,t),onSuccess:()=>(T.success(`目的地已重新执行`,`可在当前发布会话中查看进度。`),m.invalidateQueries({queryKey:[`runs`,e]})),onError:e=>T.error(`重试目的地失败`,e)}),B=l.data,H=d({queryKey:ae(B?.run.packageId),queryFn:()=>ie(B.run.packageId),enabled:!!B?.run.packageId}),U=B?.sessions.find(e=>e.kind===D.Main),W=B?.sessions.filter(e=>e.kind===D.Publication)??[],G=y.runTab===`publication`||!y.runTab&&!U&&W.length>0?`publication`:`main`,q=typeof y.destination==`string`?y.destination:null,J=W.find(e=>e.id===q)??W[0],Y=G===`main`?U:J,X=d({queryKey:re(e,J?.id),queryFn:()=>x(e,J.id),enabled:!!(e&&J&&P),retry:!1}),Z=(0,V.useRef)(null),me=l.activities.at(-1)?.sequence,_e=l.modelEvents.at(-1)?.id,ye=e=>{e!==G&&(te(e===`publication`?1:-1),v({to:`.`,search:t=>({...t,runTab:e}),resetScroll:!1}))},be=e=>{let t=W.findIndex(e=>e.id===q),n=W.findIndex(t=>t.id===e);O(t<0||n>=t?1:-1),v({to:`.`,search:t=>({...t,runTab:`publication`,destination:e}),resetScroll:!1})};if((0,V.useEffect)(()=>j(!1),[e]),(0,V.useEffect)(()=>F(null),[e,J?.id]),Ae(Z,`${Y?.id??``}:${me??``}:${_e??``}`,s,Y?.id),!e)return(0,K.jsx)(C,{className:o(`min-h-[420px] rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,a),title:`选择一次运行`,description:`查看动态 ReAct 活动、实时模型输出和独立发布结果。`});if(l.error)return(0,K.jsx)(`div`,{className:a,children:(0,K.jsx)(i,{error:l.error})});if(!B)return(0,K.jsx)(`div`,{className:o(`h-80 animate-pulse rounded bg-[var(--surface-2)]`,a)});let xe=B.run.status===k.Failed||B.run.status===k.NeedsAttention&&U?.status===k.NeedsAttention,Se=[{value:`main`,label:`主流程`,icon:(0,K.jsx)(p,{className:`size-3.5`})},{value:`publication`,label:`发布`,count:W.length,icon:(0,K.jsx)(de,{className:`size-3.5`})}],Ce=(0,K.jsxs)(`div`,{className:`flex min-h-11 flex-wrap items-center justify-between gap-x-5 border-t border-[var(--border)] px-4 sm:px-5`,children:[(0,K.jsx)(`div`,{role:`tablist`,"aria-label":`运行内容视图`,className:`flex h-11 items-stretch gap-5`,children:Se.map(e=>{let t=G===e.value;return(0,K.jsxs)(`button`,{id:`${I}-${e.value}-tab`,type:`button`,role:`tab`,"aria-selected":t,"aria-controls":`${I}-${e.value}-panel`,onClick:()=>ye(e.value),className:o(`relative inline-flex min-w-0 items-center gap-1.5 text-xs font-medium text-[var(--muted-strong)] transition-colors duration-[var(--motion-fast)] ease-[var(--ease-standard)] hover:text-[var(--ink)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)] focus-visible:ring-offset-2`,t&&`font-semibold text-[var(--ink)]`),children:[e.icon,(0,K.jsx)(`span`,{children:e.label}),e.count===void 0?null:(0,K.jsx)(`span`,{className:o(`min-w-5 rounded px-1.5 py-0.5 text-center text-[10px] font-semibold leading-4`,t?`bg-[var(--surface-3)] text-[var(--ink)]`:`bg-[var(--surface-2)] text-[var(--muted)]`),children:e.count}),t?(0,K.jsx)(_.span,{layoutId:`run-section-indicator-${I}`,className:`absolute inset-x-0 bottom-0 h-0.5 rounded-t bg-[var(--ink)]`,transition:{duration:L?0:.24,ease:[.16,1,.3,1]}}):null]},e.value)})}),(0,K.jsxs)(`span`,{className:`py-2 text-[11px] text-[var(--muted)]`,children:[`活动流:`,$(l.activityStreamState),` · 模型流:`,$(l.modelStreamState)]})]}),Q=(0,K.jsxs)(`div`,{className:`overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,children:[(0,K.jsxs)(`header`,{className:`p-4 sm:p-5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`h2`,{className:`truncate text-base font-semibold`,children:s?N(B.run):le(B.run)}),(0,K.jsx)(w,{tone:M(B.run.status),children:A(B.run.status)}),B.run.trigger.kind===`automation`?(0,K.jsx)(w,{children:`自动任务`}):null]}),(0,K.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--muted-strong)]`,children:[s?null:(0,K.jsxs)(K.Fragment,{children:[B.run.planName??`独立发布`,` · `]}),s?null:(0,K.jsxs)(K.Fragment,{children:[ue(B.run),` · `]}),new Date(B.run.createdAt).toLocaleString()]}),H.data?(0,K.jsx)(`p`,{className:`mt-2 text-xs text-[var(--muted)]`,children:B.run.kind===`publication`&&H.data.generationRun?`内容来自 ${N(H.data.generationRun)}`:`已生成可发布内容包`}):null]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[H.data?(0,K.jsxs)(r,{onClick:()=>j(!0),children:[(0,K.jsx)(h,{className:`size-4`}),`预览内容`]}):null,xe?(0,K.jsxs)(r,{loading:R.isPending,onClick:()=>R.mutate(),children:[(0,K.jsx)(f,{className:`size-4`}),`恢复运行`]}):null]})]}),B.run.error?(0,K.jsx)(`p`,{className:`mt-3 text-xs text-[var(--danger)]`,children:B.run.error}):null]}),Ce]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`section`,{className:o(`grid gap-4`,s&&`h-full min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden`,a),children:[Q,(0,K.jsx)(`div`,{ref:Z,className:o(`grid gap-4`,s&&`scrollbar-stable min-h-0 content-start overflow-y-auto overscroll-contain`),children:(0,K.jsx)(E,{initial:!1,mode:`wait`,custom:b,children:(0,K.jsx)(_.div,{id:`${I}-${G}-panel`,role:`tabpanel`,"aria-labelledby":`${I}-${G}-tab`,custom:b,initial:{opacity:0,x:L?0:b*18,filter:L?`none`:`blur(3px)`},animate:{opacity:1,x:0,filter:`none`},exit:{opacity:0,x:L?0:b*-12,filter:L?`none`:`blur(2px)`},transition:{duration:L?0:.22,ease:[.16,1,.3,1]},children:G===`publication`&&!W.length?(0,K.jsx)(C,{className:`min-h-64 rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,title:`仅生成可发布内容包`,description:`本次运行没有配置发布目的地。`}):(0,K.jsxs)(`div`,{className:`grid gap-4`,children:[G===`publication`?(0,K.jsx)(pe,{sessions:W,selected:J?.id,sourceTitle:le(B.run),onSelect:be}):null,(0,K.jsx)(E,{initial:!1,mode:`wait`,custom:S,children:(0,K.jsx)(_.div,{custom:S,initial:{opacity:0,x:L?0:S*14},animate:{opacity:1,x:0},exit:{opacity:0,x:L?0:S*-10},transition:{duration:L?0:.18,ease:[.16,1,.3,1]},className:`min-w-0`,children:Y?(0,K.jsx)(ve,{session:Y,activities:l.activities.filter(e=>e.sessionId===Y.id),modelEvents:l.modelEvents.filter(e=>e.sessionId===Y.id),retrying:z.isPending,hideHeader:Y.kind===D.Main,onPreviewCover:he(Y)?()=>F(`cover`):void 0,onPreviewHtml:he(Y)?()=>F(`html`):void 0,onRetry:Y.destination&&Y.status===k.Failed?()=>z.mutate(Y.destination.destinationId):void 0}):(0,K.jsx)(C,{title:`会话尚未开始`,description:`运行开始后会实时显示活动。`})},Y?.id??`${G}-empty`)})]})},G)})})]}),H.data?(0,K.jsx)(se,{open:oe,onOpenChange:j,title:H.data.contentPackage.contentPackage.document.title,description:`${H.data.contentPackage.contentPackage.schemaVersion} · 运行产物`,size:`wide`,children:(0,K.jsx)(ce,{value:H.data.contentPackage,generationRun:H.data.generationRun})}):null,(0,K.jsx)(ge,{mode:P,preview:X.data,pending:X.isPending,error:X.error,onOpenChange:e=>{e||F(null)}})]})}export{Re as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{$ as t,$t as n,Ft as r,K as i,Nt as a,Q as o,U as s,W as c,Y as l,an as u,en as d,et as f,in as p,ln as m,nn as h,on as g,sn as _,tn as v}from"./index-DC7b8xgR.js";import{t as y}from"./chevron-right-okm7Mcup.js";import{c as b,t as x}from"./app-dialog-ChNc5zc0.js";import{t as S}from"./input-D7j_2GhD.js";import{t as C}from"./fingerprint-pattern-C_dvDw0n.js";import{t as w}from"./layout-template-_-9A39QH.js";import{i as T,n as E,r as D,t as O}from"./use-onboarding-muxucTEZ.js";import{t as k}from"./newspaper-Dcqy9j6N.js";import{t as A}from"./radio-tower-tBHGxqPI.js";import{n as ee,t as j}from"./react-ByivFozR.js";import{n as M,r as N}from"./use-workspace-snapshot-CZmWKC_d.js";import{t as P}from"./arrow-right-Da_6qwwr.js";import{t as F}from"./check-C6hl-XsU.js";import{t as I}from"./sparkles-ws1IsiGt.js";function te(e){let t=g({warn:e?.router===void 0}),n=e?.router||t;return u(n.stores.__store,p(e,n))}var ne=l(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),re=l(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),ie=l(`file-archive`,[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]),L=l(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),ae=l(`library-big`,[[`rect`,{width:`8`,height:`18`,x:`3`,y:`3`,rx:`1`,key:`oynpb5`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M20.4 18.9c.2.5-.1 1.1-.6 1.3l-1.9.7c-.5.2-1.1-.1-1.3-.6L11.1 5.1c-.2-.5.1-1.1.6-1.3l1.9-.7c.5-.2 1.1.1 1.3.6Z`,key:`1qboyk`}]]),oe=l(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),R=l(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),z=l(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),B=l(`package-open`,[[`path`,{d:`M12 22v-9`,key:`x3hkom`}],[`path`,{d:`M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z`,key:`2ntwy6`}],[`path`,{d:`M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13`,key:`1pmm1c`}],[`path`,{d:`M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z`,key:`12ttoo`}]]),V=l(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),H=l(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),U=l(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),W=l(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),G=l(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),K=l(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),q=e(m(),1),J=[{id:`today`,label:`工作台`,shortLabel:`台`,description:`当前行动`,intent:`开始内容任务。`,icon:L,items:[{to:`/automations`,label:`任务`,description:`内容与发布编排`,detail:`选择内容方案、发布账号和触发方式。`,icon:D},{to:`/workspace`,label:`今天`,description:`下一步行动`,detail:`查看准备度和最近运行。`,icon:L}]},{id:`content`,label:`内容准备`,shortLabel:`内容`,description:`身份、素材与预设`,intent:`维护稳定内容输入。`,icon:k,items:[{to:`/identities`,label:`内容身份`,description:`定位与语气`,detail:`维护定位、受众、语气和表达边界。`,icon:C},{to:`/knowledge`,label:`知识库`,description:`参考资料`,detail:`上传并维护内容生产所需的长期参考材料。`,icon:ae},{to:`/sources`,label:`输入来源`,description:`动态数据输入`,detail:`维护运行时需要抓取的网页和数据来源。`,icon:k},{to:`/content-plans`,label:`内容方案`,description:`ReAct 策略与工具`,detail:`组合 Agent 策略、身份、知识库、授权工具和发布配置。`,icon:oe}]},{id:`publish`,label:`发布`,shortLabel:`发布`,description:`账号与目标`,intent:`管理渠道和扇出关系。`,icon:A,items:[{to:`/publishing`,label:`发布账号`,description:`身份 + 账号`,detail:`维护渠道、接入方式与账号凭证。`,icon:A},{to:`/publishing/styles`,label:`写作风格`,description:`平台语感与结构`,detail:`维护内置与自定义写作风格,在发布阶段按目标平台受控改写并保留证据引用。`,icon:U},{to:`/publishing/templates`,label:`排版模板`,description:`渠道视觉布局`,detail:`按渠道维护不可变排版模板版本与发布视觉规则。`,icon:w}]},{id:`records`,label:`记录`,shortLabel:`记录`,description:`任务与成品`,intent:`查看可靠执行和内容资产。`,icon:B,items:[{to:`/jobs`,label:`运行记录`,description:`执行状态与检查点`,detail:`查看每次运行的状态、失败原因与恢复操作。`,icon:B},{to:`/library`,label:`内容包`,description:`成品与发布`,detail:`查看渠道无关的内容包并发布。`,icon:ie}]},{id:`system`,label:`设置`,shortLabel:`设置`,description:`连接与架构`,intent:`维护外部能力和扩展。`,icon:K,items:[{to:`/connections`,label:`连接`,description:`外部服务能力`,detail:`维护模型、图片、通知和渠道 API 连接。`,icon:ne},{to:`/settings`,label:`运行架构`,description:`扩展注册`,detail:`查看 Agent 策略、工具和渠道发布类型。`,icon:K}]}],Y=J.flatMap(e=>[...e.items]);function se(e){let t=Y.flatMap(e=>[e.to,...e.activePrefixes??[]].map(t=>({candidate:e,prefix:t}))).filter(({prefix:t})=>e===t||e.startsWith(t.endsWith(`/`)?t:`${t}/`)).sort((e,t)=>t.prefix.length-e.prefix.length)[0]?.candidate??Y[0];return{domain:J.find(e=>e.items.some(e=>e.to===t.to))??J[0],item:t}}var X=_();function ce({open:e,onOpenChange:t}){let[n,r]=(0,q.useState)(``),i=h(),a=(0,q.useMemo)(()=>{let e=n.trim().toLowerCase();return e?Y.filter(t=>`${t.label}${t.description}${t.detail}`.toLowerCase().includes(e)):Y},[n]);return(0,q.useEffect)(()=>{let n=n=>{(n.metaKey||n.ctrlKey)&&n.key.toLowerCase()===`k`&&(n.preventDefault(),t(!e))};return globalThis.addEventListener(`keydown`,n),()=>globalThis.removeEventListener(`keydown`,n)},[e,t]),(0,X.jsxs)(x,{open:e,onOpenChange:t,title:`快速跳转`,description:`搜索页面和配置入口。`,children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(G,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-[var(--muted)]`}),(0,X.jsx)(S,{autoFocus:!0,className:`pl-9`,placeholder:`搜索页面`,value:n,onChange:e=>r(e.target.value)})]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-1`,children:a.map(e=>{let n=e.icon;return(0,X.jsxs)(`button`,{className:`flex min-h-12 items-center gap-3 rounded px-3 text-left hover:bg-[var(--surface-2)]`,onClick:()=>{t(!1),i({to:e.to})},children:[(0,X.jsx)(n,{className:`size-4`}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{className:`block text-sm`,children:e.label}),(0,X.jsx)(`span`,{className:`text-xs text-[var(--muted)]`,children:e.detail})]})]},e.to)})})]})}function le({activeItem:e,collapsed:t,open:n,onClose:r,onCommand:i,onSelect:a,onToggleCollapsed:o}){let s=h();return(0,X.jsx)(`aside`,{"aria-label":`工作台导航`,className:f(`fixed inset-y-0 left-0 z-40 w-[288px] max-w-[calc(100vw-20px)] -translate-x-full overflow-hidden border-r border-[var(--border)] bg-[var(--surface)] shadow-xl transition-[transform,width]`,`lg:inset-y-2 lg:left-2 lg:translate-x-0 lg:rounded-[var(--radius-lg)] lg:border lg:border-[color-mix(in_srgb,var(--border)_82%,transparent)] lg:shadow-[var(--shadow-card)]`,t?`lg:w-[72px]`:`lg:w-[220px]`,n&&`translate-x-0`),children:(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,X.jsxs)(`div`,{className:f(`flex h-[60px] shrink-0 items-center gap-2 border-b border-[color-mix(in_srgb,var(--border)_60%,transparent)] px-4`,t&&`lg:justify-center lg:px-2`),children:[(0,X.jsxs)(`button`,{className:f(`flex min-w-0 flex-1 items-center gap-3 text-left`,t&&`lg:flex-none`),onClick:()=>{a(),s({to:`/workspace`})},children:[(0,X.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-[10px] bg-[var(--accent)] text-[var(--accent-ink)] text-xs font-black`,children:`TP`}),(0,X.jsxs)(`span`,{className:f(`min-w-0`,t&&`lg:hidden`),children:[(0,X.jsx)(`span`,{className:`block text-[10px] font-semibold uppercase text-[var(--muted)]`,children:`TrendPublish`}),(0,X.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-semibold`,children:`内容工作台`})]})]}),(0,X.jsx)(c,{label:`搜索`,variant:`ghost`,className:f(`size-9 min-h-0`,t&&`lg:hidden`),onClick:i,children:(0,X.jsx)(G,{className:`size-4`})}),(0,X.jsx)(c,{label:`关闭导航`,variant:`ghost`,className:`size-9 min-h-0 lg:hidden`,onClick:r,children:(0,X.jsx)(b,{className:`size-4`})})]}),(0,X.jsx)(`nav`,{"aria-label":`工作台入口`,className:f(`min-h-0 flex-1 overflow-y-auto px-3 py-3`,t&&`lg:px-2`),children:(0,X.jsx)(`div`,{className:`grid gap-3`,children:J.map(n=>(0,X.jsxs)(`section`,{className:`grid gap-1`,children:[(0,X.jsx)(`div`,{className:f(`px-1.5 text-[11px] font-semibold uppercase tracking-wider text-[var(--muted)]`,t&&`lg:sr-only`),children:n.label}),n.items.map(n=>{let r=n.icon,i=n.to===e.to;return(0,X.jsxs)(d,{to:n.to,onClick:a,title:t?n.label:void 0,className:f(`relative flex min-h-10 items-center gap-2 rounded-[10px] px-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,t&&`lg:size-10 lg:justify-center lg:px-0`,i?`font-semibold text-[var(--ink)]`:`text-[var(--muted-strong)] hover:text-[var(--ink)]`),children:[i&&!t&&(0,X.jsx)(j.span,{layoutId:`nav-active-bg`,"aria-hidden":!0,className:`absolute inset-0 rounded-[10px] border-l border-[var(--accent)] bg-[var(--surface-3)]`,transition:{type:`spring`,stiffness:380,damping:32}}),i&&t&&(0,X.jsx)(`span`,{className:`absolute inset-0 rounded-[10px] bg-[var(--surface-3)]`}),(0,X.jsx)(r,{className:`relative z-[1] size-4 shrink-0`}),(0,X.jsx)(`span`,{className:f(`relative z-[1] truncate`,t&&`lg:hidden`),children:n.label})]},n.to)})]},n.id))})}),(0,X.jsx)(`div`,{className:`border-t border-[color-mix(in_srgb,var(--border)_60%,transparent)] p-3`,children:(0,X.jsx)(c,{label:t?`展开侧栏`:`收起侧栏`,variant:`ghost`,className:f(`hidden min-h-0 lg:inline-flex`,t?`size-10`:`h-10 w-full justify-start px-2`),onClick:o,children:t?(0,X.jsx)(H,{className:`size-5`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{className:`size-5`}),(0,X.jsx)(`span`,{children:`收起侧栏`})]})})})]})})}function ue({channels:e,value:t,onChange:n}){let r=ee();return(0,X.jsx)(`div`,{className:`border-t border-[color-mix(in_srgb,var(--border)_72%,transparent)] px-4 sm:px-5`,children:(0,X.jsxs)(`div`,{className:`flex min-h-11 min-w-0 items-stretch gap-5 overflow-x-auto scrollbar-stable`,children:[(0,X.jsx)(`span`,{className:`flex shrink-0 items-center text-sm font-medium text-[var(--muted-strong)]`,children:`渠道`}),(0,X.jsx)(`nav`,{"aria-label":`发布渠道`,className:`flex min-w-max items-stretch gap-1`,children:e.map(e=>{let i=e.id===t;return(0,X.jsxs)(`button`,{type:`button`,"aria-current":i?`page`:void 0,className:f(`relative min-w-20 px-3 text-sm font-medium text-[var(--muted)] transition-colors duration-[var(--motion-fast)] ease-[var(--ease-standard)] hover:text-[var(--ink)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus)]`,i&&`text-[var(--ink)]`),onClick:()=>n(e.id),children:[e.name,i?(0,X.jsx)(j.span,{layoutId:`publishing-channel-indicator`,"aria-hidden":!0,className:`absolute inset-x-3 bottom-0 h-px bg-[var(--ink)]`,transition:{duration:r?0:.24,ease:[.16,1,.3,1]}}):null]},e.id)})})]})})}function Z({className:e}){return(0,X.jsx)(`div`,{className:f(`animate-pulse rounded-[var(--radius-sm)] bg-[var(--surface-3)]`,e)})}function de(){let e=h(),{steps:t,pending:n}=E(),r=n[0];if(!r)return null;let i=t.findIndex(e=>e.id===r.id);return(0,X.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4 backdrop-blur-sm`,children:(0,X.jsxs)(`div`,{className:`w-full max-w-lg overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)] shadow-xl`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--border)] px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(I,{className:`size-4 text-[var(--accent)]`}),(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-[var(--ink)]`,children:`开始配置 TrendPublish`})]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`退出引导`,className:`text-[var(--muted-strong)] hover:text-[var(--ink)]`,onClick:()=>O.dismiss(),children:(0,X.jsx)(b,{className:`size-4`})})]}),(0,X.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,X.jsxs)(`p`,{className:`text-xs text-[var(--muted-strong)]`,children:[`第 `,i+1,` / `,t.length,` 步 · 走完即可发布第一篇`]}),(0,X.jsx)(`ol`,{className:`mt-3 grid gap-1.5`,children:t.map(e=>{let t=e.id===r.id;return(0,X.jsxs)(`li`,{className:t?`flex items-center gap-2 rounded-md bg-[var(--surface-2)] px-2 py-1.5 text-sm text-[var(--ink)]`:`flex items-center gap-2 px-2 py-1.5 text-sm text-[var(--muted-strong)]`,children:[e.done?(0,X.jsx)(F,{className:`size-4 text-[var(--success)]`}):(0,X.jsx)(T,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:e.done?`line-through opacity-70`:``,children:e.title}),e.optional?(0,X.jsx)(`span`,{className:`text-xs opacity-60`,children:`可选`}):null]},e.id)})}),(0,X.jsxs)(`div`,{className:`mt-4 rounded-md border border-[var(--border)] bg-[var(--surface-2)] p-3`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium text-[var(--ink)]`,children:r.title}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-[var(--muted-strong)]`,children:r.description})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t border-[var(--border)] px-5 py-3`,children:[(0,X.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>O.dismiss(),children:`退出引导`}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>O.skip(r.id),children:`跳过此步`}),(0,X.jsxs)(s,{variant:`primary`,size:`sm`,onClick:()=>{O.dismiss(),e({to:r.to})},children:[`去配置`,(0,X.jsx)(P,{className:`size-3.5`})]})]})]})]})})}var Q=`trendpublish.sidebar.collapsed`;function fe(){let{logout:e}=a(),[i,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(ve),d=h(),p=te({select:e=>e.location}),m=p.pathname,{domain:g,item:_}=se(m),v=M(),y=E(),b=r(),x=he({activeDomain:g,activeItem:_,pathname:m,identities:v.data?.identities??[]}),S=v.error,C=t(S),w=v.data?.channelDefinitions??[],T=p.search,D=w.find(e=>e.id===T.channel)??w[0],O=m.startsWith(`/publishing`)&&w.length>0,k=e=>{if(_.to===`/publishing/styles`)d({to:`/publishing/styles`,search:{channel:e,page:1}});else if(_.to===`/publishing/templates`){let t=w.find(t=>t.id===e),n=(v.data?.publicationTypeProfiles??[]).filter(t=>t.channel===e&&t.layout),r=n.find(e=>e.type===t?.defaultPublicationType)?.type??n[0]?.type;d({to:`/publishing/templates`,search:{channel:e,publicationType:r,page:1}})}else d({to:`/publishing`,search:{channel:e,page:1}})},A=()=>void b.invalidateQueries({queryKey:N()});return(0,X.jsxs)(`div`,{className:`min-h-dvh text-[var(--ink)]`,children:[(0,X.jsx)(le,{activeItem:_,collapsed:l,open:i,onClose:()=>o(!1),onCommand:()=>c(!0),onSelect:()=>o(!1),onToggleCollapsed:()=>{u(e=>{let t=!e;return ye(t),t})}}),i&&(0,X.jsx)(`button`,{type:`button`,"aria-label":`关闭导航遮罩`,className:`fixed inset-0 z-30 bg-black/36 backdrop-blur-[2px] lg:hidden`,onClick:()=>o(!1)}),(0,X.jsxs)(`div`,{className:f(`flex min-h-dvh flex-col transition-[padding] duration-[var(--motion-base)] ease-[var(--ease-standard)]`,l?`lg:pl-[80px]`:`lg:pl-[228px]`),children:[(0,X.jsx)($,{header:x,onOpenNavigation:()=>o(!0),onOpenCommand:()=>c(!0),onRefresh:A,onLogout:e,channelNavigation:O?(0,X.jsx)(ue,{channels:w,value:D?.id,onChange:k}):void 0}),(0,X.jsx)(`main`,{className:`flex-1 min-w-0 w-full px-2 pb-2`,children:(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[S&&(0,X.jsx)(_e,{error:S,unauthorized:C,onRefresh:A,onLogout:e}),(0,X.jsx)(`div`,{className:`motion-page`,children:(0,X.jsx)(q.Suspense,{fallback:(0,X.jsx)(pe,{activeItem:_}),children:(0,X.jsx)(n,{})})})]})})]}),(0,X.jsx)(ce,{open:s,onOpenChange:c}),y.showWizard?(0,X.jsx)(de,{}):null]})}function pe({activeItem:e}){return(0,X.jsxs)(`section`,{"aria-busy":`true`,"aria-label":`${e.label}加载中`,className:`grid gap-5`,children:[(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(Z,{className:`h-4 w-24`}),(0,X.jsx)(Z,{className:`h-8 w-[min(420px,70%)]`}),(0,X.jsx)(Z,{className:`h-4 w-[min(560px,82%)]`})]}),(0,X.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1.15fr)_minmax(280px,0.85fr)]`,children:[(0,X.jsx)(Z,{className:`min-h-[260px]`}),(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[(0,X.jsx)(Z,{className:`h-32`}),(0,X.jsx)(Z,{className:`h-32`})]})]})]})}function $({header:e,onOpenNavigation:t,onOpenCommand:n,onRefresh:r,onLogout:i,channelNavigation:a}){return(0,X.jsxs)(`header`,{className:f(`sticky top-2 z-20 mx-2 mt-2 mb-2 rounded-[var(--radius-lg)] border border-[color-mix(in_srgb,var(--border)_82%,transparent)] shadow-[var(--shadow-soft)]`,a?`overflow-hidden bg-[var(--surface)]`:`bg-[color-mix(in_srgb,var(--surface)_88%,transparent)] backdrop-blur-xl`),children:[(0,X.jsxs)(`div`,{className:`flex min-h-[60px] items-center justify-between gap-4 px-4 sm:px-5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(c,{label:`打开导航`,variant:`ghost`,className:`min-h-0 size-10 lg:hidden`,onClick:t,children:(0,X.jsx)(z,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(me,{breadcrumbs:e.breadcrumbs}),(0,X.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 items-baseline gap-3`,children:[(0,X.jsx)(`h1`,{className:`truncate text-base font-semibold text-[var(--ink)]`,children:e.title}),(0,X.jsx)(`p`,{className:`hidden truncate text-sm text-[var(--muted-strong)] md:block`,children:e.detail})]})]})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsxs)(s,{size:`sm`,variant:`secondary`,className:`hidden min-w-[136px] justify-start md:inline-flex`,onClick:n,children:[(0,X.jsx)(re,{className:`size-4`}),`快速跳转`,(0,X.jsx)(`span`,{className:`ml-auto rounded border border-[color-mix(in_srgb,var(--border)_74%,transparent)] px-1.5 py-0.5 text-[10px] text-[var(--muted)]`,children:`⌘K`})]}),(0,X.jsx)(c,{label:`刷新数据`,variant:`secondary`,className:`min-h-0 size-9`,onClick:r,children:(0,X.jsx)(W,{className:`size-4`})}),(0,X.jsx)(c,{label:`退出工作台`,variant:`ghost`,className:`min-h-0 size-9`,onClick:i,children:(0,X.jsx)(R,{className:`size-4`})})]})]}),a]})}function me({breadcrumbs:e}){return(0,X.jsx)(`nav`,{"aria-label":`当前位置`,className:`flex min-w-0 items-center gap-1.5 text-[11px] font-medium text-[var(--muted)]`,children:e.map((t,n)=>{let r=n===e.length-1;return(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[t.to&&!r?(0,X.jsx)(d,{to:t.to,className:`truncate rounded-[6px] transition hover:text-[var(--ink)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,children:t.label}):(0,X.jsx)(`span`,{"aria-current":r?`page`:void 0,className:f(`truncate`,r&&`text-[var(--muted-strong)]`),children:t.label}),!r&&(0,X.jsx)(y,{className:`size-3.5 shrink-0`})]},`${t.label}-${n}`)})})}function he({activeDomain:e,activeItem:t,pathname:n,identities:r}){let i=[{label:e.label,to:e.items[0]?.to},{label:t.label}],a=ge(n);if(n===`/content-plans/new`||/^\/content-plans\/[^/]+\/edit$/.test(n)){let r=n===`/content-plans/new`;return{breadcrumbs:[{label:e.label,to:e.items[0]?.to},{label:t.label,to:t.to},{label:r?`新建`:`编辑`}],title:r?`新建内容方案`:`编辑内容方案`,detail:`配置 ReAct 策略、身份、授权工具与发布账号。`}}if(/^\/publishing\/templates\/sessions\/[^/]+$/.test(n))return{breadcrumbs:[{label:e.label,to:e.items[0]?.to},{label:t.label,to:t.to},{label:`制作会话`}],title:`模板制作`,detail:`左侧持续对话,右侧比较候选并生成真实内容预览。`};if(t.to===`/identities`&&a){let n=r.find(e=>e.id===a)?.name||`身份详情`;return{breadcrumbs:[{label:e.label,to:e.items[0]?.to},{label:t.label,to:t.to},{label:n}],title:n,detail:`内容身份详情`}}return{breadcrumbs:i,title:t.label,detail:t.detail}}function ge(e){let t=e.match(/^\/identities\/([^/?#]+)/);if(!t?.[1])return``;try{return decodeURIComponent(t[1])}catch{return t[1]}}function _e({error:e,unauthorized:t,onRefresh:n,onLogout:r}){return(0,X.jsx)(`section`,{className:`rounded-[var(--radius)] border border-[var(--warning-border)] bg-[var(--warning-bg)] px-4 py-3`,children:(0,X.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center text-[var(--warning)]`,children:(0,X.jsx)(i,{className:`size-4`})}),(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsxs)(`p`,{className:`text-sm text-[var(--ink)]`,children:[(0,X.jsx)(`strong`,{className:`font-semibold`,children:t?`访问凭证需要更新`:`工作台数据暂时不可用`}),(0,X.jsx)(`span`,{className:`ml-2 text-[var(--muted-strong)]`,children:t?`当前访问凭证已失效或权限不足。请重新进入工作台。`:o(e)})]})})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2 sm:justify-end`,children:[(0,X.jsxs)(s,{type:`button`,variant:`secondary`,onClick:n,children:[(0,X.jsx)(W,{className:`size-4`}),`重试`]}),t&&(0,X.jsxs)(s,{type:`button`,variant:`primary`,onClick:r,children:[(0,X.jsx)(R,{className:`size-4`}),`重新进入`]})]})]})})}function ve(){return typeof localStorage>`u`?!1:localStorage.getItem(Q)===`true`}function ye(e){typeof localStorage<`u`&&localStorage.setItem(Q,String(e))}function be(){let{isAuthenticated:e}=a();return e?(0,X.jsx)(fe,{}):(0,X.jsx)(v,{to:`/`,replace:!0})}export{be as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{Y as t,cn as n,ct as r,dt as i,et as a,ft as o,ln as s,lt as c,ot as l,sn as u,st as d,ut as f}from"./index-DC7b8xgR.js";var p=t(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),m=e(n(),1),h=e(s(),1),g=u();function _({...e}){return(0,g.jsx)(l,{"data-slot":`dialog`,...e})}function v({...e}){return(0,g.jsx)(i,{"data-slot":`dialog-portal`,...e})}function y({...e}){return(0,g.jsx)(d,{"data-slot":`dialog-close`,...e})}function b({className:e,...t}){return(0,g.jsx)(f,{"data-slot":`dialog-overlay`,className:a(`dialog-overlay-motion fixed inset-0 z-50 bg-black/42`,e),...t})}function x({className:e,children:t,showCloseButton:n=!0,...i}){return(0,g.jsxs)(v,{"data-slot":`dialog-portal`,children:[(0,g.jsx)(b,{}),(0,g.jsx)(`div`,{className:`dialog-positioner`,children:(0,g.jsxs)(r,{"data-slot":`dialog-content`,className:a(`dialog-content-motion pointer-events-auto relative z-50 grid w-full max-w-[calc(100vw-2rem)] gap-4 rounded-lg border bg-background p-6 shadow-lg outline-none sm:max-w-lg`,e),...i,children:[t,n&&(0,g.jsxs)(d,{"data-slot":`dialog-close`,className:`absolute right-4 top-3.5 grid size-8 place-items-center rounded-[var(--radius-sm)] text-[var(--muted)] transition-colors hover:bg-[var(--surface-2)] hover:text-[var(--ink)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)] disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:size-4`,children:[(0,g.jsx)(p,{}),(0,g.jsx)(`span`,{className:`sr-only`,children:`关闭`})]})]})})]})}function S({className:e,...t}){return(0,g.jsx)(`div`,{"data-slot":`dialog-header`,className:a(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function C({className:e,...t}){return(0,g.jsx)(o,{"data-slot":`dialog-title`,className:a(`text-lg leading-none font-semibold`,e),...t})}function w({className:e,...t}){return(0,g.jsx)(c,{"data-slot":`dialog-description`,className:a(`text-sm text-muted-foreground`,e),...t})}var T=(0,h.createContext)(null);function E({open:e,onOpenChange:t,title:n,description:r,size:i=`default`,children:o,contentClassName:s}){let[c,l]=(0,h.useState)(null);return(0,g.jsx)(_,{open:e,onOpenChange:t,children:(0,g.jsx)(x,{className:a(`grid max-h-[min(800px,calc(100dvh-24px))] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 overflow-hidden rounded-[var(--radius)] border-[var(--border)] bg-[var(--surface)] p-0 shadow-[0_4px_12px_rgba(20,20,24,0.16)]`,i===`wide`?`sm:max-w-[min(1080px,calc(100vw-32px))]`:i===`medium`?`sm:max-w-[min(800px,calc(100vw-32px))]`:`sm:max-w-xl`),children:(0,g.jsxs)(T.Provider,{value:c,children:[(0,g.jsxs)(S,{className:`grid min-w-0 gap-1 border-b border-[var(--border)] bg-[var(--surface)] px-5 py-3.5 pr-14 text-left`,children:[(0,g.jsx)(C,{className:`min-w-0 break-words text-base font-semibold leading-6 text-[var(--ink)]`,children:n}),r?(0,g.jsx)(w,{className:`min-w-0 break-words text-xs leading-5 text-[var(--muted-strong)]`,children:r}):null]}),(0,g.jsx)(`div`,{"data-slot":`app-dialog-content`,className:a(`scrollbar-stable min-h-0 overflow-y-auto overscroll-contain bg-[var(--surface)] p-5`,s),children:o}),(0,g.jsx)(`div`,{"data-slot":`app-dialog-footer-root`,ref:l})]})})})}function D({className:e,...t}){let n=(0,h.useContext)(T);return n?(0,m.createPortal)((0,g.jsx)(`div`,{"data-slot":`app-dialog-footer`,className:a(`border-t border-[var(--border)] bg-[var(--surface)] px-5 py-3 [&_button]:min-h-8 [&_button]:px-2.5 [&_button]:text-xs`,e),...t}),n):null}export{x as a,p as c,y as i,D as n,w as o,_ as r,C as s,E as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Y as e}from"./index-DC7b8xgR.js";var t=e(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Y as e}from"./index-DC7b8xgR.js";var t=e(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]);export{t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{t}from"./useMutation-C221JCx3.js";import{t as n}from"./useQuery-CH_PyDWC.js";import{Ft as r,L as i,N as a,P as o,U as s,V as c,ln as l,sn as u,tt as d}from"./index-DC7b8xgR.js";import{t as f}from"./play-CqRcIakP.js";import{t as p}from"./plus-Cgi-AlzH.js";import{n as m}from"./use-workspace-snapshot-CZmWKC_d.js";import{t as h}from"./input-D7j_2GhD.js";import{t as g}from"./textarea-B7N7g6fl.js";import{t as _}from"./select-BUT5ahxS.js";import{n as v,t as y}from"./app-dialog-ChNc5zc0.js";import{t as b}from"./form-field-BbOl9sGR.js";import{r as x,t as S}from"./notifications-Dlx9WRAf.js";import{n as C,t as w}from"./entity-list-C7fEITZj.js";import{t as T}from"./pagination-BIxivGX2.js";import{t as E}from"./page-grid-x4teY0Qb.js";var D=(e=1,t=20)=>o(a.api.automations.$get({query:{page:String(e),pageSize:String(t)}})),O=e=>o(a.api.automations.$post({json:e})),k=(e,t)=>o(a.api.automations[`:id`].$patch({param:{id:e},json:t})),A=e=>o(a.api.automations[`:id`].$delete({param:{id:e}})),j=(e,t={})=>o(a.api.automations[`:id`].run.$post({param:{id:e},json:t})),M=e(l(),1),N=u(),P=20,F=()=>[`automations`];function I(e=1){return n({queryKey:[...F(),e],queryFn:()=>D(e,P)})}function L(){let e=r();return t({mutationFn:e=>A(e),onSuccess:()=>e.invalidateQueries({queryKey:F()})})}function R(){let e=r();return t({mutationFn:({id:e,body:t})=>e?k(e,t):O(t),onSuccess:()=>e.invalidateQueries({queryKey:F()})})}function z(){return t({mutationFn:({id:e,body:t={}})=>j(e,t)})}var B=()=>({name:``,enabled:!0,contentPlanId:``,instructions:``,keywords:[],trigger:{type:`manual`}});function V({page:e,onPageChange:t}){let{data:n,error:r}=I(e),{data:i}=m({live:!1}),[a,o]=(0,M.useState)(null),[c,l]=(0,M.useState)(null),u=R(),d=L(),h=n?.items??[],g=i?.contentPlans.some(e=>e.enabled)??!1;return r&&!n?null:(0,N.jsxs)(E,{children:[(0,N.jsx)(w,{title:`任务列表`,description:`任务只负责选择内容方案和触发方式;内容与发布配置由方案自身维护。`,compact:!0,summary:`共 ${n?.total??0} 个任务`,action:(0,N.jsxs)(s,{variant:`primary`,disabled:!g,onClick:()=>o(`new`),children:[(0,N.jsx)(p,{className:`size-4`}),`新建任务`]}),empty:!h.length,emptyTitle:g?`还没有自动化任务`:`先创建内容方案`,emptyDescription:g?`创建任务后,可从这里手动运行并查看状态。`:`内容方案组合模板、身份、参考输入和模型连接,是创建任务的前置条件。`,emptyAction:g?void 0:(0,N.jsx)(s,{onClick:()=>window.location.href=`/dashboard/content-plans`,children:`前往内容方案`}),pagination:(0,N.jsx)(T,{page:e,pageSize:P,total:n?.total??0,onChange:t}),children:h.map(e=>{let t=i?.contentPlans.find(t=>t.id===e.contentPlanId),n=i?.identities.find(e=>e.id===t?.identityId);return(0,N.jsx)(C,{title:e.name,description:`${t?.name??`方案缺失`} · ${n?.name??`身份缺失`}`,status:e.enabled&&t?.enabled?`ready`:`disabled`,meta:(0,N.jsx)(x,{children:G(e.trigger.type)}),onEdit:()=>o(e),deleteDescription:`任务删除后将不再触发,已有运行记录不会被删除。`,onDelete:()=>d.mutateAsync(e.id),children:(0,N.jsxs)(s,{disabled:!e.enabled||!t?.enabled,onClick:()=>l(e),children:[(0,N.jsx)(f,{className:`size-4`}),`运行`]})},e.id)})}),(0,N.jsx)(H,{value:a,open:!!a,onOpenChange:e=>!e&&o(null),onSave:e=>u.mutate({id:a===`new`?void 0:a.id,body:e},{onSuccess:()=>{o(null),S.success(`任务已保存`,`“${e.name}”的触发配置已更新。`)},onError:e=>S.error(`保存任务失败`,e)}),saving:u.isPending,error:u.error}),(0,N.jsx)(U,{automation:c,onOpenChange:e=>!e&&l(null)})]})}function H({value:e,open:t,onOpenChange:n,onSave:r,saving:i,error:a}){let{data:o}=m({live:!1}),[l,u]=(0,M.useState)(B()),[f,p]=(0,M.useState)(``);(0,M.useEffect)(()=>{if(!e)return;let t=e===`new`?B():{...e,revision:e.revision};e===`new`&&(t.contentPlanId=o?.contentPlans[0]?.id??``),u(t),p(t.keywords.join(`
|
|
2
|
-
`))},[e,o]);let x=o?.contentPlans.find(e=>e.id===l.contentPlanId),S=o?.identities.find(e=>e.id===x?.identityId),C=(x?.sourceCollectionIds??[]).map(e=>o?.sourceCollections.find(t=>t.id===e)?.name).filter(Boolean);return(0,N.jsxs)(y,{open:t,onOpenChange:n,title:e===`new`?`新建任务`:`编辑任务`,description:`选择要运行的内容方案,并配置何时触发。`,size:`wide`,children:[(0,N.jsxs)(`div`,{className:`grid gap-6`,children:[(0,N.jsxs)(`section`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,N.jsx)(b,{label:`任务名称`,required:!0,children:(0,N.jsx)(h,{value:l.name,onChange:e=>u({...l,name:e.target.value})})}),(0,N.jsx)(b,{label:`状态`,children:(0,N.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:l.enabled,onChange:e=>u({...l,enabled:e.target.checked})}),`启用任务`]})})]}),(0,N.jsxs)(`section`,{className:`grid gap-4 border-y border-[var(--border)] py-5`,children:[(0,N.jsx)(`h3`,{className:`text-sm font-semibold`,children:`内容与参考`}),(0,N.jsx)(b,{label:`内容方案`,required:!0,helper:`内容方案决定 ReAct 策略、身份、知识库、授权工具、模型和发布配置。`,children:(0,N.jsxs)(_,{value:l.contentPlanId,onChange:e=>u({...l,contentPlanId:e.target.value}),children:[(0,N.jsx)(`option`,{value:``,children:`请选择`}),o?.contentPlans.filter(e=>e.enabled).map(e=>(0,N.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),x?(0,N.jsxs)(`dl`,{className:`divide-y divide-[var(--border)] border-y border-[var(--border)] text-sm`,children:[(0,N.jsxs)(`div`,{className:`grid gap-1 py-3 sm:grid-cols-[140px_1fr]`,children:[(0,N.jsx)(`dt`,{className:`text-[var(--muted)]`,children:`内容身份`}),(0,N.jsx)(`dd`,{children:S?.name??`身份缺失`})]}),(0,N.jsxs)(`div`,{className:`grid gap-1 py-3 sm:grid-cols-[140px_1fr]`,children:[(0,N.jsx)(`dt`,{className:`text-[var(--muted)]`,children:`抓取数据源`}),(0,N.jsx)(`dd`,{children:C.join(`、`)||`未配置`})]})]}):null,(0,N.jsx)(b,{label:`领域与任务说明`,helper:`补充本任务关注的领域、判断标准和内容边界。`,children:(0,N.jsx)(g,{className:`min-h-28`,value:l.instructions??``,onChange:e=>u({...l,instructions:e.target.value})})}),(0,N.jsx)(b,{label:`关注关键词`,helper:`每行一个,用作运行上下文;热点监控接入后也会复用。`,children:(0,N.jsx)(g,{className:`min-h-24`,value:f,onChange:e=>p(e.target.value)})})]}),(0,N.jsxs)(`section`,{className:`grid gap-3 border-t border-[var(--border)] pt-5`,children:[(0,N.jsx)(`h3`,{className:`text-sm font-semibold`,children:`触发方式`}),(0,N.jsx)(b,{label:`当前方式`,children:(0,N.jsxs)(_,{value:l.trigger.type,onChange:e=>u({...l,trigger:W(e.target.value)}),children:[(0,N.jsx)(`option`,{value:`manual`,children:`手动触发`}),(0,N.jsx)(`option`,{value:`schedule`,children:`定时触发`}),(0,N.jsx)(`option`,{value:`hotspot`,children:`热点触发`}),(0,N.jsx)(`option`,{value:`api`,children:`API 触发`})]})}),l.trigger.type===`schedule`?(0,N.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,N.jsx)(b,{label:`Cron 表达式`,required:!0,children:(0,N.jsx)(h,{value:l.trigger.cron,onChange:e=>u({...l,trigger:{type:`schedule`,cron:e.target.value,timezone:l.trigger.type===`schedule`?l.trigger.timezone:`Asia/Shanghai`}}),placeholder:`0 9 * * *`})}),(0,N.jsx)(b,{label:`时区`,required:!0,children:(0,N.jsx)(h,{value:l.trigger.timezone,onChange:e=>u({...l,trigger:{type:`schedule`,cron:l.trigger.type===`schedule`?l.trigger.cron:`0 9 * * *`,timezone:e.target.value}})})})]}):null,l.trigger.type===`hotspot`?(0,N.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,N.jsx)(b,{label:`监控关键词`,required:!0,children:(0,N.jsx)(h,{value:l.trigger.query,onChange:e=>u({...l,trigger:{type:`hotspot`,query:e.target.value,intervalMinutes:l.trigger.type===`hotspot`?l.trigger.intervalMinutes:30}})})}),(0,N.jsx)(b,{label:`检查间隔(分钟)`,required:!0,children:(0,N.jsx)(h,{type:`number`,min:5,value:l.trigger.intervalMinutes,onChange:e=>u({...l,trigger:{type:`hotspot`,query:l.trigger.type===`hotspot`?l.trigger.query:``,intervalMinutes:Number(e.target.value)}})})})]}):null,l.trigger.type===`api`?(0,N.jsx)(b,{label:`调用标识`,helper:`用于在日志中区分调用方,可留空。`,children:(0,N.jsx)(h,{value:l.trigger.tokenName??``,onChange:e=>u({...l,trigger:{type:`api`,tokenName:e.target.value}})})}):null]}),(0,N.jsx)(c,{error:a})]}),(0,N.jsxs)(v,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(s,{onClick:()=>n(!1),children:`取消`}),(0,N.jsx)(s,{variant:`primary`,loading:i,disabled:!l.name.trim()||!l.contentPlanId,onClick:()=>r({...l,name:l.name.trim(),instructions:l.instructions?.trim()||void 0,keywords:d(f)}),children:`保存`})]})]})}function U({automation:e,onOpenChange:t}){let[n,r]=(0,M.useState)(``);(0,M.useEffect)(()=>r(``),[e]);let i=z();return(0,N.jsxs)(y,{open:!!e,onOpenChange:t,title:`运行任务`,description:e?.name??``,children:[(0,N.jsxs)(`div`,{className:`grid gap-4`,children:[(0,N.jsx)(b,{label:`本次指定主题`,helper:`可留空,由内容方案根据数据源选题。`,children:(0,N.jsx)(h,{value:n,onChange:e=>r(e.target.value)})}),(0,N.jsx)(`p`,{className:`text-xs leading-5 text-[var(--muted-strong)]`,children:`本次运行会执行内容方案中保存的生成与发布配置。`}),(0,N.jsx)(c,{error:i.error})]}),(0,N.jsxs)(v,{className:`flex justify-end gap-2`,children:[(0,N.jsx)(s,{onClick:()=>t(!1),children:`取消`}),(0,N.jsxs)(s,{variant:`primary`,loading:i.isPending,onClick:()=>i.mutate({id:e.id,body:{requestedTopic:n.trim()||void 0}},{onSuccess:()=>{t(!1),S.success(`任务已启动`,`可在运行记录中查看实时活动。`)},onError:e=>S.error(`启动任务失败`,e)}),children:[(0,N.jsx)(f,{className:`size-4`}),`开始运行`]})]})]})}function W(e){return e===`schedule`?{type:e,cron:`0 9 * * *`,timezone:`Asia/Shanghai`}:e===`hotspot`?{type:e,query:``,intervalMinutes:30}:e===`api`?{type:e,tokenName:``}:{type:`manual`}}function G(e){return{manual:`手动触发`,schedule:`定时触发`,hotspot:`热点触发`,api:`API 触发`}[e]}function K(){let{page:e}=i.useSearch(),t=i.useNavigate();return(0,N.jsx)(V,{page:e,onPageChange:e=>t({search:t=>({...t,page:e})})})}export{K as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Y as e}from"./index-DC7b8xgR.js";var t=e(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Y as e}from"./index-DC7b8xgR.js";var t=e(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Y as e}from"./index-DC7b8xgR.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{t}from"./useMutation-C221JCx3.js";import{t as n}from"./useQuery-CH_PyDWC.js";import{Ft as r,H as i,I as a,N as o,P as s,U as c,V as l,ln as u,sn as d}from"./index-DC7b8xgR.js";import{t as f}from"./flask-conical-DpX8Ww6S.js";import{t as p}from"./plus-Cgi-AlzH.js";import{t as m}from"./input-D7j_2GhD.js";import{t as h}from"./select-BUT5ahxS.js";import{t as g}from"./textarea-B7N7g6fl.js";import{n as _,t as v}from"./app-dialog-ChNc5zc0.js";import{t as y}from"./form-field-BbOl9sGR.js";import{r as b,t as x}from"./notifications-Dlx9WRAf.js";import{n as S,t as C}from"./entity-list-C7fEITZj.js";import{t as w}from"./page-grid-x4teY0Qb.js";import{t as T}from"./pagination-BIxivGX2.js";var E=(e=1,t=20)=>s(o.api.connections.$get({query:{page:String(e),pageSize:String(t)}})),D=e=>s(o.api.connections.$post({json:e})),O=(e,t)=>s(o.api.connections[`:id`].$patch({param:{id:e},json:t})),k=e=>s(o.api.connections[`:id`].$delete({param:{id:e}})),A=e=>s(o.api.connections.test.$post({json:e})),j=e(u(),1);function M(e,t){let n=e.trim(),r=new Set(t.map(e=>e.trim().toLocaleLowerCase()));if(!r.has(n.toLocaleLowerCase()))return n;let i=2;for(;r.has(`${n} ${i}`.toLocaleLowerCase());)i+=1;return`${n} ${i}`}var N=d(),P=()=>[`connections`],F=20;function I(e=1){return n({queryKey:[...P(),e],queryFn:()=>E(e,F)})}function L(){let e=r();return t({mutationFn:e=>k(e),onSuccess:()=>e.invalidateQueries({queryKey:P()})})}function R(){let e=r();return t({mutationFn:({id:e,body:t})=>e?O(e,t):D(t),onSuccess:()=>e.invalidateQueries({queryKey:P()})})}function z(){return t({mutationFn:e=>A(e)})}function B({page:e,onPageChange:t}){let{data:n}=I(e),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(!1),s=L(),l=n?.definitions??[],u=n?.items??[],d=(0,j.useMemo)(()=>new Map(l.map(e=>[e.id,e])),[l]);return(0,N.jsxs)(w,{children:[(0,N.jsx)(C,{title:`连接列表`,description:`超时、重试与恢复不属于连接配置;调用失败会由运行记录和检查点安全处理。`,compact:!0,summary:`共 ${n?.total??0} 个连接`,action:(0,N.jsxs)(c,{variant:`primary`,onClick:()=>o(!0),children:[(0,N.jsx)(p,{className:`size-4`}),`新建连接`]}),empty:!u.length,pagination:(0,N.jsx)(T,{page:e,pageSize:F,total:n?.total??0,onChange:t}),children:u.map(e=>{let t=d.get(e.connectorId);return(0,N.jsx)(S,{title:e.name,description:`${t?.displayName??e.connectorId} · ${t?.description??``}`,status:e.enabled?`ready`:`disabled`,meta:(0,N.jsx)(`span`,{className:`flex gap-1`,children:t?.capabilities.map(e=>(0,N.jsx)(b,{children:e},e))}),onEdit:()=>t&&i({definition:t,connection:e}),deleteDescription:`删除后无法恢复;正在被方案或账号使用时不会删除。`,onDelete:()=>s.mutateAsync(e.id)},e.id)})}),(0,N.jsx)(v,{open:a,onOpenChange:o,title:`选择 Connector`,description:`每个 Connector 定义一组稳定能力和所需基础字段。`,size:`medium`,children:(0,N.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:l.map(e=>(0,N.jsxs)(`button`,{className:`grid w-full gap-1 py-4 text-left hover:text-[var(--accent)]`,onClick:()=>{o(!1),i({definition:e,suggestedName:M(e.displayName,u.map(e=>e.name))})},children:[(0,N.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[e.displayName,(0,N.jsx)(`span`,{className:`flex gap-1`,children:e.capabilities.map(e=>(0,N.jsx)(b,{children:e},e))})]}),(0,N.jsx)(`span`,{className:`text-xs leading-5 text-[var(--muted-strong)]`,children:e.description})]},e.id))})}),(0,N.jsx)(V,{editor:r,onOpenChange:e=>!e&&i(null)})]})}function V({editor:e,onOpenChange:t}){let[n,r]=(0,j.useState)(``),[a,o]=(0,j.useState)(!0),[s,u]=(0,j.useState)({}),[d,p]=(0,j.useState)(`{}`),[h,b]=(0,j.useState)(`{}`),[S,C]=(0,j.useState)(`{}`),[w,T]=(0,j.useState)(!1),[E,D]=(0,j.useState)();(0,j.useEffect)(()=>{if(!e)return;r(e.connection?.name??e.suggestedName??e.definition.displayName),o(e.connection?.enabled??!0);let t=Object.fromEntries(e.definition.fields.filter(e=>e.defaultValue!==void 0).map(e=>[e.key,e.defaultValue]));u({...t,...e.connection?.settings}),p(JSON.stringify(e.connection?.overrides?.headers??{},null,2)),b(JSON.stringify(e.connection?.overrides?.query??{},null,2)),C(JSON.stringify(e.connection?.overrides?.body??{},null,2)),T(!1),D(void 0)},[e]);let O=()=>({id:e?.connection?.id,revision:e?.connection?.revision,connectorId:e.definition.id,name:n.trim(),enabled:a,settings:Object.fromEntries(e.definition.fields.filter(e=>e.location===`settings`).map(e=>[e.key,s[e.key]]).filter(([,e])=>e!==void 0&&e!==``)),credentials:Object.fromEntries(e.definition.fields.filter(e=>e.location===`credentials`).map(e=>[e.key,s[e.key]]).filter(([,e])=>e!==void 0&&e!==``)),overrides:e.definition.requestOverrides?{headers:U(d,`Headers`),query:U(h,`Query`),body:U(S,`Body`)}:void 0}),k=R(),A=z();if(!e)return null;let M=[...e.definition.fields].sort((e,t)=>(e.order??0)-(t.order??0)),P=M.filter(e=>e.defaultValue===void 0),F=M.filter(e=>e.defaultValue!==void 0),I=M.some(t=>{if(!t.required)return!1;let n=s[t.key];return n!==void 0&&n!==``?!1:!(t.location===`credentials`&&e.connection?.credentialState[t.key])});return(0,N.jsxs)(v,{open:!0,onOpenChange:t,title:e.connection?`编辑连接`:`新建连接`,description:`${e.definition.displayName} · ${e.definition.capabilities.join(` / `)}`,size:`medium`,children:[(0,N.jsxs)(`div`,{className:`grid gap-4`,children:[(0,N.jsx)(`div`,{className:`grid gap-4`,children:P.map(t=>(0,N.jsx)(H,{field:t,value:s[t.key],hasStoredCredential:!!e.connection?.credentialState[t.key],onChange:e=>u({...s,[t.key]:e})},`${t.location}:${t.key}`))}),(0,N.jsxs)(`details`,{className:`group border-t border-[var(--border)] pt-4`,open:w,onToggle:e=>T(e.currentTarget.open),children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer list-none text-sm font-medium text-[var(--muted-strong)] hover:text-[var(--ink)]`,children:[`高级设置`,(0,N.jsx)(`span`,{className:`ml-2 text-xs font-normal text-[var(--muted)]`,children:`名称、状态与接口参数`})]}),(0,N.jsxs)(`div`,{className:`mt-4 grid gap-4`,children:[(0,N.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[1fr_auto]`,children:[(0,N.jsx)(y,{label:`连接名称`,required:!0,children:(0,N.jsx)(m,{value:n,onChange:e=>r(e.target.value)})}),(0,N.jsx)(y,{label:`状态`,children:(0,N.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),`启用`]})})]}),F.length?(0,N.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:F.map(t=>(0,N.jsx)(H,{field:t,value:s[t.key],hasStoredCredential:!!e.connection?.credentialState[t.key],onChange:e=>u({...s,[t.key]:e})},`${t.location}:${t.key}`))}):null,e.definition.requestOverrides?(0,N.jsxs)(`details`,{className:`border-t border-[var(--border)] pt-4`,children:[(0,N.jsxs)(`summary`,{className:`cursor-pointer list-none text-sm font-medium`,children:[`请求覆盖`,(0,N.jsx)(`span`,{className:`ml-2 text-xs font-normal text-[var(--muted)]`,children:`Headers · Query · Body`})]}),(0,N.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-[var(--muted-strong)]`,children:`仅用于特殊接入;认证保留字段不能覆盖。`}),(0,N.jsxs)(`div`,{className:`mt-4 grid gap-4`,children:[(0,N.jsx)(y,{label:`Headers`,children:(0,N.jsx)(g,{className:`min-h-32 font-mono text-xs`,value:d,onChange:e=>p(e.target.value)})}),(0,N.jsx)(y,{label:`Query`,children:(0,N.jsx)(g,{className:`min-h-32 font-mono text-xs`,value:h,onChange:e=>b(e.target.value)})}),(0,N.jsx)(y,{label:`Body`,children:(0,N.jsx)(g,{className:`min-h-32 font-mono text-xs`,value:S,onChange:e=>C(e.target.value)})})]})]}):null]})]}),E?(0,N.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`rounded border px-3 py-2 text-xs ${E.success?`border-[var(--success-border)] bg-[var(--success-bg)] text-[var(--success)]`:`border-[var(--danger-border)] bg-[var(--danger-bg)] text-[var(--danger)]`}`,children:[E.message,` · `,E.latencyMs,` ms`]}):null,(0,N.jsx)(l,{error:k.error??A.error})]}),(0,N.jsxs)(_,{className:`flex justify-between gap-2`,children:[(0,N.jsxs)(c,{loading:A.isPending,disabled:I,onClick:()=>{D(void 0);try{A.mutate(O(),{onSuccess:e=>{D(e.test),e.test.success?x.success(`连接测试成功`,`${e.test.message} · ${e.test.latencyMs} ms`):x.error(`连接测试失败`,e.test.message)},onError:e=>x.error(`连接测试失败`,e)})}catch(e){D({success:!1,message:i(e),latencyMs:0}),x.error(`连接测试失败`,e)}},children:[(0,N.jsx)(f,{className:`size-4`}),`测试连接`]}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(c,{onClick:()=>t(!1),children:`取消`}),(0,N.jsx)(c,{variant:`primary`,loading:k.isPending,disabled:!n.trim()||I,onClick:()=>k.mutate({id:e.connection?.id,body:O()},{onSuccess:()=>{t(!1),x.success(`连接已保存`,`“${n.trim()}”可以用于 Agent。`)},onError:e=>x.error(`保存连接失败`,e)}),children:`保存连接`})]})]})]})}function H({field:e,value:t,hasStoredCredential:n,onChange:r}){return(0,N.jsx)(y,{label:e.label,required:e.required,helper:e.description,children:e.input===`boolean`?(0,N.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:!!t,onChange:e=>r(e.target.checked)}),`启用`]}):e.input===`select`?(0,N.jsx)(h,{value:W(t),onChange:e=>r(e.target.value),children:e.options?.map(e=>(0,N.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,N.jsx)(m,{type:e.input===`password`?`password`:e.input===`number`?`number`:e.input===`url`?`url`:`text`,value:W(t),placeholder:n?`留空保留已有值`:e.placeholder,onChange:t=>r(e.input===`number`?Number(t.target.value):t.target.value)})})}function U(e,t){let n=JSON.parse(e||`{}`);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`${t} 必须是 JSON 对象`);return n}function W(e){return typeof e==`string`||typeof e==`number`?String(e):``}function G(){let{page:e}=a.useSearch(),t=a.useNavigate();return(0,N.jsx)(B,{page:e,onPageChange:e=>t({search:t=>({...t,page:e})})})}export{G as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./useMutation-C221JCx3.js";import{t}from"./useQuery-CH_PyDWC.js";import{A as n,D as r,Ft as i,M as a,O as o,U as s,j as c,k as l,sn as u}from"./index-DC7b8xgR.js";import"./types-D57tnOAh.js";import{t as d}from"./copy-CWp2fj5q.js";import{t as f}from"./eye-Drma9Anf.js";import{t as p}from"./plus-Cgi-AlzH.js";import{n as m}from"./use-workspace-snapshot-CZmWKC_d.js";import{n as h,t as g}from"./entity-list-C7fEITZj.js";import{t as _}from"./src-DVp5YM1T.js";import{t as v}from"./page-grid-x4teY0Qb.js";import{t as y}from"./pagination-BIxivGX2.js";import{t as b}from"./notifications-Dlx9WRAf.js";var x=u(),S=20;function C(e=1){return t({queryKey:[...o(),e],queryFn:()=>c(e,S)})}function w(){let t=i();return e({mutationFn:e=>n(e),onSuccess:()=>t.invalidateQueries({queryKey:o()})})}function T(t){let n=i();return e({mutationFn:e=>t?a(t,e):l(e),onSuccess:()=>n.invalidateQueries({queryKey:o()})})}function E(){let t=i();return e({mutationFn:e=>l({name:`${e.name} (副本)`,enabled:!1,identityId:e.identityId,knowledgeBaseIds:e.knowledgeBaseIds??[],sourceCollectionIds:e.sourceCollectionIds,connections:{...e.connections},researchConnections:e.researchConnections??{search:[],fetch:[]},agent:e.agent?{...e.agent,toolConnectionIds:[...e.agent.toolConnectionIds],budget:e.agent.budget?{...e.agent.budget}:void 0}:void 0,publishing:{...e.publishing}}),onSuccess:()=>t.invalidateQueries({queryKey:o()})})}function D(){let{data:e}=m({live:!1}),{page:t}=r.useSearch(),n=r.useNavigate(),{data:i}=C(t),a=w(),o=E(),c=i?.items??[];return(0,x.jsx)(v,{children:(0,x.jsx)(g,{title:`内容方案`,description:`一个方案完整描述一次内容生产:使用谁的身份、参考什么、如何生成,以及生成后去哪里。`,compact:!0,summary:`共 ${i?.total??0} 个方案`,action:(0,x.jsxs)(s,{variant:`primary`,size:`sm`,onClick:()=>n({to:`/content-plans/new`}),children:[(0,x.jsx)(p,{className:`size-4`}),`新建方案`]}),empty:!c.length,emptyTitle:`还没有内容方案`,emptyDescription:`创建方案后,任务只需要选择方案和触发方式。`,pagination:(0,x.jsx)(y,{page:t,pageSize:S,total:i?.total??0,onChange:e=>n({search:t=>({...t,page:e})})}),children:c.map(t=>{let r=e?.identities.find(e=>e.id===t.identityId),i=e?.contentStrategies.find(e=>e.id===(t.agent?.strategyId??_)),c=t.publishing?.destinations??[];return(0,x.jsxs)(h,{title:t.name,description:`${r?.name??`身份缺失`} · ${i?.name??`每日资讯解读`} · ${t.knowledgeBaseIds?.length??0} 个知识库 · ${t.sourceCollectionIds.length} 个输入来源 · ${c.length?`${c.length} 个发布目的地`:`仅生成内容包`}`,status:t.enabled?`ready`:`disabled`,deleteDescription:`方案删除后无法恢复,已有运行记录不会被删除。`,onDelete:()=>a.mutateAsync(t.id),children:[(0,x.jsxs)(s,{variant:`ghost`,onClick:()=>n({to:`/content-plans/$planId/edit`,params:{planId:t.id}}),children:[(0,x.jsx)(f,{className:`size-3.5`}),`查看`]}),(0,x.jsxs)(s,{variant:`ghost`,loading:o.isPending&&o.variables?.id===t.id,onClick:()=>o.mutate(t,{onSuccess:()=>b.success(`内容方案已复制`,`已创建“${t.name} (副本)”。`),onError:e=>b.error(`复制内容方案失败`,e)}),children:[(0,x.jsx)(d,{className:`size-3.5`}),`复制`]})]},t.id)})})})}export{D as component,C as useContentPlans,w as useDeleteContentPlan,T as useSaveContentPlan};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./-editor-page-CS5uk_2L.js";var t=e;export{t as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./-editor-page-CS5uk_2L.js";var t=e;export{t as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{At as t,Ct as n,Dt as r,Et as i,Mt as a,Ot as o,St as s,Tt as c,_t as l,at as u,bt as d,et as f,gt as p,ht as m,it as h,jt as g,kt as _,ln as v,mt as ee,nt as y,pt as b,rt as x,sn as S,vt as C,wt as w,xt as T,yt as te}from"./index-DC7b8xgR.js";import{c as E,s as ne}from"./select-BUT5ahxS.js";var D=e(v(),1),re=Object.defineProperty,O=(e,t)=>re(e,`name`,{value:t,configurable:!0}),k=!1;function A(){let[e,t]=D.useState(k);return D.useEffect(()=>{k||(k=!0,t(!0))},[]),e}O(A,`useIsHydrated`);var j=D.useSyncExternalStore;function M(){return()=>{}}O(M,`subscribe`);function N(){return j(M,()=>!0,()=>!1)}O(N,`useIsHydratedModern`);var ie=typeof j==`function`?N:A,P=S(),ae=Object.defineProperty,F=(e,t)=>ae(e,`name`,{value:t,configurable:!0}),I=`rovingFocusGroup.onEntryFocus`,L={bubbles:!1,cancelable:!0},R=`RovingFocusGroup`,[z,B,V]=E(R),[oe,H]=o(R,[V]),U={Vertical:`vertical`,Horizontal:`horizontal`},se={LTR:`ltr`,RTL:`rtl`},[W,ce]=oe(R),le=D.forwardRef(F(function(e,t){return(0,P.jsx)(z.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,P.jsx)(z.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,P.jsx)(ue,{...e,ref:t})})})},`RovingFocusGroup`)),ue=D.forwardRef(F(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:l,currentTabStopId:u,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:f,onEntryFocus:p,preventScrollOnEntryFocus:m=!1,...h}=e,g=D.useRef(null),v=a(t,g),ee=ne(l),[y,b]=c({prop:u,defaultProp:d??null,onChange:f,caller:R}),[x,S]=D.useState(!1),C=s(p),w=B(n),T=D.useRef(!1),[te,E]=D.useState(0);return D.useEffect(()=>{let e=g.current;if(e)return e.addEventListener(I,C),()=>e.removeEventListener(I,C)},[C]),(0,P.jsx)(W,{scope:n,orientation:r,dir:ee,loop:o,currentTabStopId:y,onItemFocus:D.useCallback(e=>b(e),[b]),onItemShiftTab:D.useCallback(()=>S(!0),[]),onFocusableItemAdd:D.useCallback(()=>E(e=>e+1),[]),onFocusableItemRemove:D.useCallback(()=>E(e=>e-1),[]),children:(0,P.jsx)(_.div,{tabIndex:x||te===0?-1:0,"data-orientation":r,...h,ref:v,style:{outline:`none`,...e.style},onMouseDown:i(e.onMouseDown,()=>{T.current=!0}),onFocus:i(e.onFocus,e=>{let t=!T.current;if(e.target===e.currentTarget&&t&&!x){let t=new CustomEvent(I,L);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=w().filter(e=>e.focusable);G([e.find(e=>e.active),e.find(e=>e.id===y),...e].filter(Boolean).map(e=>e.ref.current),m)}}T.current=!1}),onBlur:i(e.onBlur,()=>S(!1))})})},`RovingFocusGroupImpl`)),de=`RovingFocusGroupItem`,fe=D.forwardRef(F(function(e,t){let{__scopeRovingFocusGroup:a,focusable:o=!0,active:s=!1,tabStopId:c,children:l,...u}=e,d=n(),f=c||d,p=ce(de,a),m=p.currentTabStopId===f,h=B(a),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:ee}=p,y=ie();return r(()=>{if(y&&o)return g(),()=>v()},[y,o,g,v]),D.useEffect(()=>{if(!y&&o)return g(),()=>v()},[y,o,g,v]),(0,P.jsx)(z.ItemSlot,{scope:a,id:f,focusable:o,active:s,children:(0,P.jsx)(_.span,{tabIndex:m?0:-1,"data-orientation":p.orientation,...u,ref:t,onMouseDown:i(e.onMouseDown,e=>{o?p.onItemFocus(f):e.preventDefault()}),onFocus:i(e.onFocus,()=>p.onItemFocus(f)),onKeyDown:i(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){p.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=he(e,p.orientation,p.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=h().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=p.loop?ge(n,r+1):n.slice(r+1)}setTimeout(()=>G(n))}}),children:typeof l==`function`?l({isCurrentTabStop:m,hasTabStop:ee!=null}):l})})},`RovingFocusGroupItem`)),pe={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function me(e,t){return t===se.RTL?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}F(me,`getDirectionAwareKey`);function he(e,t,n){let r=me(e.key,n);if(!(t===U.Vertical&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===U.Horizontal&&[`ArrowUp`,`ArrowDown`].includes(r)))return pe[r]}F(he,`getFocusIntent`);function G(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}F(G,`focusFirst`);function ge(e,t){return e.map((n,r)=>e[(t+r)%e.length])}F(ge,`wrapArray`);var _e=Object.defineProperty,K=(e,t)=>_e(e,`name`,{value:t,configurable:!0}),ve=[`Enter`,` `],ye=[`ArrowDown`,`PageUp`,`Home`],be=[`ArrowUp`,`PageDown`,`End`],xe=[...ye,...be];[...ve],[...ve];var q=`Menu`,[Se,Ce,we]=E(q),[J,Te]=o(q,[we,u,H]),Ee=u(),De=H(),[Oe,Y]=J(q),[ke,Ae]=J(q),je=K(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,c=Ee(t),[l,u]=D.useState(null),d=D.useRef(!1),f=s(a),p=ne(i);return D.useEffect(()=>{let e=K(()=>{d.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=K(()=>d.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),D.useEffect(()=>{if(!n)return;let e=K(()=>f(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,f]),(0,P.jsx)(y,{...c,children:(0,P.jsx)(Oe,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:(0,P.jsx)(ke,{scope:t,onClose:D.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:o,children:r})})})},`Menu`),Me=D.forwardRef(K(function(e,t){let{__scopeMenu:n,...r}=e,i=Ee(n);return(0,P.jsx)(x,{...i,...r,ref:t})},`MenuAnchor`)),Ne=`MenuPortal`,[Pe,Fe]=J(Ne,{forceMount:void 0}),Ie=K(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Y(Ne,t);return(0,P.jsx)(Pe,{scope:t,forceMount:n,children:(0,P.jsx)(w,{present:n||a.open,children:(0,P.jsx)(p,{asChild:!0,container:i,children:r})})})},`MenuPortal`),X=`MenuContent`,[Le,Re]=J(X),ze=D.forwardRef(K(function(e,t){let n=Fe(X,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Y(X,e.__scopeMenu),o=Ae(X,e.__scopeMenu);return(0,P.jsx)(Se.Provider,{scope:e.__scopeMenu,children:(0,P.jsx)(w,{present:r||a.open,children:(0,P.jsx)(Se.Slot,{scope:e.__scopeMenu,children:o.modal?(0,P.jsx)(Be,{...i,ref:t}):(0,P.jsx)(Ve,{...i,ref:t})})})})},`MenuContent`)),Be=D.forwardRef(K(function(e,t){let n=Y(X,e.__scopeMenu),r=D.useRef(null),o=a(t,r);return D.useEffect(()=>{let e=r.current;if(e)return b(e)},[]),(0,P.jsx)(Ue,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:i(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),Ve=D.forwardRef(K(function(e,t){let n=Y(X,e.__scopeMenu);return(0,P.jsx)(Ue,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),He=g(`MenuContent.ScrollLock`),Ue=D.forwardRef(K(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:c,disableOutsidePointerEvents:u,onEntryFocus:f,onEscapeKeyDown:p,onPointerDownOutside:g,onFocusOutside:_,onInteractOutside:v,onDismiss:y,disableOutsideScroll:b,...x}=e,S=Y(X,n),w=Ae(X,n),E=Ee(n),ne=De(n),re=Ce(n),[O,k]=D.useState(null),A=D.useRef(null),[j,M]=D.useState(null);te(j);let{nodes:N,registry:ie}=d(),ae=!!(o||b),F=a(t,A,S.onContentChange,M),I=D.useRef(0),L=D.useRef(``),R=D.useRef(0),z=D.useRef(null),B=D.useRef(`right`),V=D.useRef(0),oe=D.useMemo(()=>b?[A,...N.map(e=>({current:e}))]:[],[A,N,b]),H=b?ee:D.Fragment,U=b?{as:He,allowPinchZoom:!0,shards:oe}:void 0,se=K(e=>{let t=L.current+e,n=re().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=st(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;function s(e){L.current=e,window.clearTimeout(I.current),e!==``&&(I.current=window.setTimeout(()=>s(``),1e3))}K(s,`updateSearch`),s(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);D.useEffect(()=>()=>window.clearTimeout(I.current),[]),m();let W=D.useCallback(e=>B.current===z.current?.side&<(e,z.current?.area),[]);return(0,P.jsx)(Le,{scope:n,searchRef:L,onItemEnter:D.useCallback(e=>{W(e)&&e.preventDefault()},[W]),onItemLeave:D.useCallback(e=>{W(e)||(A.current?.focus(),k(null))},[W]),onTriggerLeave:D.useCallback(e=>{W(e)&&e.preventDefault()},[W]),pointerGraceTimerRef:R,onPointerGraceIntentChange:D.useCallback(e=>{z.current=e},[]),children:(0,P.jsx)(C,{registry:ae?ie:null,children:(0,P.jsx)(H,{...U,children:(0,P.jsx)(l,{asChild:!0,trapped:o,branches:N,onMountAutoFocus:i(s,e=>{e.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:(0,P.jsx)(T,{asChild:!0,disableOutsidePointerEvents:u,onEscapeKeyDown:p,onPointerDownOutside:g,onFocusOutside:_,onInteractOutside:v,onDismiss:y,children:(0,P.jsx)(le,{asChild:!0,...ne,dir:w.dir,orientation:`vertical`,loop:r,currentTabStopId:O,onCurrentTabStopIdChange:k,onEntryFocus:i(f,e=>{w.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,P.jsx)(h,{role:`menu`,"aria-orientation":`vertical`,"data-state":nt(S.open),"data-radix-menu-content":``,dir:w.dir,...E,...x,ref:F,style:{outline:`none`,...x.style},onKeyDown:i(x.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&se(e.key));let i=A.current;if(e.target!==i||!xe.includes(e.key))return;e.preventDefault();let a=re().filter(e=>!e.disabled).map(e=>e.ref.current);be.includes(e.key)&&a.reverse(),at(a)}),onBlur:i(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(I.current),L.current=``)}),onPointerMove:i(e.onPointerMove,Z(e=>{let t=e.target,n=V.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>V.current?`right`:`left`;B.current=t,V.current=e.clientX}}))})})})})})})})},`MenuContentImpl`)),We=D.forwardRef(K(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(_.div,{...r,ref:t})},`MenuLabel`)),Ge=`MenuItem`,Ke=`menu.itemSelect`,qe=D.forwardRef(K(function(e,n){let{disabled:r=!1,onSelect:o,...s}=e,c=D.useRef(null),l=Ae(Ge,e.__scopeMenu),u=Re(Ge,e.__scopeMenu),d=a(n,c),f=D.useRef(!1),p=K(()=>{let e=c.current;if(!r&&e){let n=new CustomEvent(Ke,{bubbles:!0,cancelable:!0});e.addEventListener(Ke,e=>o?.(e),{once:!0}),t(e,n),n.defaultPrevented?f.current=!1:l.onClose()}},`handleSelect`);return(0,P.jsx)(Je,{...s,ref:d,disabled:r,onClick:i(e.onClick,p),onPointerDown:t=>{e.onPointerDown?.(t),f.current=!0},onPointerUp:i(e.onPointerUp,e=>{f.current||e.currentTarget?.click()}),onKeyDown:i(e.onKeyDown,e=>{r||e.target!==e.currentTarget||(u.searchRef.current===``||e.key!==` `)&&ve.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),Je=D.forwardRef(K(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,c=Re(Ge,n),l=De(n),u=D.useRef(null),d=a(t,u),[f,p]=D.useState(!1),[m,h]=D.useState(``);return D.useEffect(()=>{let e=u.current;e&&h((e.textContent??``).trim())},[s.children]),(0,P.jsx)(Se.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:(0,P.jsx)(fe,{asChild:!0,...l,focusable:!r,children:(0,P.jsx)(_.div,{role:`menuitem`,"data-highlighted":f?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...s,ref:d,onPointerMove:i(e.onPointerMove,Z(e=>{r?c.onItemLeave(e):(c.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:i(e.onPointerLeave,Z(e=>c.onItemLeave(e))),onFocus:i(e.onFocus,()=>p(!0)),onBlur:i(e.onBlur,()=>p(!1))})})})},`MenuItemImpl`)),[Ye,Xe]=J(`MenuRadioGroup`,{value:void 0,onValueChange:K(()=>{},`onValueChange`)}),[Ze,Qe]=J(`MenuItemIndicator`,{checked:!1}),$e=D.forwardRef(K(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(_.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[et,tt]=J(`MenuSub`);function nt(e){return e?`open`:`closed`}K(nt,`getOpenState`);function rt(e){return e===`indeterminate`}K(rt,`isIndeterminate`);function it(e){return rt(e)?`indeterminate`:e?`checked`:`unchecked`}K(it,`getCheckedState`);function at(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}K(at,`focusFirst`);function ot(e,t){return e.map((n,r)=>e[(t+r)%e.length])}K(ot,`wrapArray`);function st(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ot(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}K(st,`getNextMatch`);function ct(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}K(ct,`isPointInPolygon`);function lt(e,t){return t?ct({x:e.clientX,y:e.clientY},t):!1}K(lt,`isPointerInGraceArea`);function Z(e){return t=>t.pointerType===`mouse`?e(t):void 0}K(Z,`whenMouse`);var ut=Object.defineProperty,Q=(e,t)=>ut(e,`name`,{value:t,configurable:!0}),dt=`DropdownMenu`,[ft,pt]=o(dt,[Te]),$=Te(),[mt,ht]=ft(dt),gt=Q(e=>{let{__scopeDropdownMenu:t,children:r,dir:i,open:a,defaultOpen:o,onOpenChange:s,modal:l=!0}=e,u=$(t),d=D.useRef(null),[f,p]=c({prop:a,defaultProp:o??!1,onChange:s,caller:dt});return(0,P.jsx)(mt,{scope:t,triggerId:n(),triggerRef:d,contentId:n(),open:f,onOpenChange:p,onOpenToggle:D.useCallback(()=>p(e=>!e),[p]),modal:l,children:(0,P.jsx)(je,{...u,open:f,onOpenChange:p,dir:i,modal:l,children:r})})},`DropdownMenu`),_t=`DropdownMenuTrigger`,vt=D.forwardRef(Q(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=ht(_t,n),c=$(n),l=a(t,s.triggerRef);return(0,P.jsx)(Me,{asChild:!0,...c,children:(0,P.jsx)(_.button,{type:`button`,id:s.triggerId,"aria-haspopup":`menu`,"aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...o,ref:l,onPointerDown:i(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(s.onOpenToggle(),s.open||e.preventDefault())}),onKeyDown:i(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&s.onOpenToggle(),e.key===`ArrowDown`&&s.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),yt=Q(e=>{let{__scopeDropdownMenu:t,...n}=e,r=$(t);return(0,P.jsx)(Ie,{...r,...n})},`DropdownMenuPortal`),bt=`DropdownMenuContent`,xt=D.forwardRef(Q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,a=ht(bt,n),o=$(n),s=D.useRef(!1);return(0,P.jsx)(ze,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...r,ref:t,onCloseAutoFocus:i(e.onCloseAutoFocus,e=>{s.current||a.triggerRef.current?.focus(),s.current=!1,e.preventDefault()}),onInteractOutside:i(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!a.modal||r)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),St=D.forwardRef(Q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,P.jsx)(We,{...i,...r,ref:t})},`DropdownMenuLabel`)),Ct=D.forwardRef(Q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,P.jsx)(qe,{...i,...r,ref:t})},`DropdownMenuItem`)),wt=D.forwardRef(Q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,P.jsx)($e,{...i,...r,ref:t})},`DropdownMenuSeparator`));function Tt({...e}){return(0,P.jsx)(gt,{"data-slot":`dropdown-menu`,...e})}function Et({...e}){return(0,P.jsx)(vt,{"data-slot":`dropdown-menu-trigger`,...e})}function Dt({className:e,sideOffset:t=4,...n}){return(0,P.jsx)(yt,{children:(0,P.jsx)(xt,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:f(`dropdown-content-motion z-50 max-h-[min(18rem,var(--radix-dropdown-menu-content-available-height))] min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-[var(--radius-sm)] border border-[var(--border)] bg-[var(--surface)] p-1 text-[var(--ink)] shadow-[var(--shadow-raised)]`,e),...n})})}function Ot({className:e,inset:t,variant:n=`default`,...r}){return(0,P.jsx)(Ct,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:f(`relative flex cursor-default items-center gap-2 rounded-[var(--radius-xs)] px-2 py-1.5 text-sm text-[var(--ink)] outline-hidden select-none focus:bg-[var(--surface-3)] focus:text-[var(--ink)] data-[disabled]:pointer-events-none data-[disabled]:text-[var(--muted)] data-[disabled]:opacity-55 data-[inset]:pl-8 data-[variant=destructive]:text-[var(--danger)] data-[variant=destructive]:focus:bg-[var(--danger-bg)] data-[variant=destructive]:focus:text-[var(--danger-strong)] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-[var(--muted)] data-[variant=destructive]:*:[svg]:text-[var(--danger)]!`,e),...r})}function kt({className:e,inset:t,...n}){return(0,P.jsx)(St,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:f(`px-2 py-1.5 text-sm font-medium text-[var(--muted-strong)] data-[inset]:pl-8`,e),...n})}function At({className:e,...t}){return(0,P.jsx)(wt,{"data-slot":`dropdown-menu-separator`,className:f(`-mx-1 my-1 h-px bg-[var(--border)]`,e),...t})}export{At as a,kt as i,Dt as n,Et as o,Ot as r,Tt as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{n as t,r as n,t as r}from"./notifications-Dlx9WRAf.js";import{Ct as i,Et as a,Mt as o,Ot as s,Tt as c,U as l,_t as u,at as d,bt as f,et as p,gt as m,ht as h,it as g,jt as _,kt as v,ln as y,mt as b,nt as x,pt as S,rt as C,sn as w,vt as T,wt as E,xt as D,yt as O}from"./index-DC7b8xgR.js";var k=e(y(),1),A=w(),ee=Object.defineProperty,j=(e,t)=>ee(e,`name`,{value:t,configurable:!0}),M=`Popover`,[N,te]=s(M,[d]),P=d(),[F,I]=N(M),L=j(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:a,onOpenChange:o,modal:s=!1}=e,l=P(t),u=k.useRef(null),[d,f]=k.useState(!1),[p,m]=k.useState(0),[h,g]=k.useState(0),[_,v]=c({prop:r,defaultProp:a??!1,onChange:o,caller:M});return(0,A.jsx)(x,{...l,children:(0,A.jsx)(F,{scope:t,contentId:i(),titleId:i(),descriptionId:i(),titlePresent:p>0,descriptionPresent:h>0,setTitleCount:m,setDescriptionCount:g,triggerRef:u,open:_,onOpenChange:v,onOpenToggle:k.useCallback(()=>v(e=>!e),[v]),hasCustomAnchor:d,onCustomAnchorAdd:k.useCallback(()=>f(!0),[]),onCustomAnchorRemove:k.useCallback(()=>f(!1),[]),modal:s,children:n})})},`Popover`),R=`PopoverTrigger`,z=k.forwardRef(j(function(e,t){let{__scopePopover:n,...r}=e,i=I(R,n),s=P(n),c=o(t,i.triggerRef),l=(0,A.jsx)(v.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":X(i.open),...r,ref:c,onClick:a(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?l:(0,A.jsx)(C,{asChild:!0,...s,children:l})},`PopoverTrigger`)),B=`PopoverPortal`,[V,H]=N(B,{forceMount:void 0}),U=j(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=I(B,t);return(0,A.jsx)(V,{scope:t,forceMount:n,children:(0,A.jsx)(E,{present:n||a.open,children:(0,A.jsx)(m,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),W=`PopoverContent`,G=k.forwardRef(j(function(e,t){let n=H(W,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=I(W,e.__scopePopover);return(0,A.jsx)(E,{present:r||a.open,children:a.modal?(0,A.jsx)(q,{...i,ref:t}):(0,A.jsx)(J,{...i,ref:t})})},`PopoverContent`)),K=_(`PopoverContent.RemoveScroll`),q=k.forwardRef(j(function(e,t){let n=I(W,e.__scopePopover),r=k.useRef(null),i=o(t,r),s=k.useRef(!1),{nodes:c,registry:l}=f();return k.useEffect(()=>{let e=r.current;if(e)return S(e)},[]),(0,A.jsx)(b,{as:K,allowPinchZoom:!0,shards:k.useMemo(()=>[r,...c.map(e=>({current:e}))],[r,c]),children:(0,A.jsx)(Y,{...e,ref:i,branchNodes:c,branchRegistry:l,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:a(e.onCloseAutoFocus,e=>{e.preventDefault(),s.current||n.triggerRef.current?.focus()}),onPointerDownOutside:a(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;s.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:a(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),J=k.forwardRef(j(function(e,t){let n=I(W,e.__scopePopover),r=k.useRef(!1),i=k.useRef(!1);return(0,A.jsx)(Y,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),Y=k.forwardRef(j(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:d,onInteractOutside:f,"aria-describedby":p,branchNodes:m,branchRegistry:_,...v}=e,y=I(W,n),b=P(n),[x,S]=k.useState(null),C=o(t,S);return O(x),h(),(0,A.jsx)(T,{registry:_,children:(0,A.jsx)(u,{asChild:!0,loop:!0,trapped:r,branches:m,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,A.jsx)(D,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:f,onEscapeKeyDown:c,onPointerDownOutside:l,onFocusOutside:d,onDismiss:()=>y.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,A.jsx)(g,{"data-state":X(y.open),role:`dialog`,id:y.contentId,"aria-labelledby":y.titlePresent?y.titleId:void 0,"aria-describedby":y.descriptionPresent?Z(p,y.descriptionId):p,...b,...v,ref:C,style:{...v.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})})},`PopoverContentImpl`));function X(e){return e?`open`:`closed`}j(X,`getState`);function Z(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}j(Z,`concatAriaDescribedby`);function Q({title:e,description:t,action:n,toolbar:r,compact:i,summary:a,children:o,className:s}){return(0,A.jsxs)(`section`,{"aria-label":e,className:p(`min-w-0 overflow-hidden rounded-[var(--radius)] border border-[var(--border)] bg-[var(--surface)]`,s),children:[(0,A.jsxs)(`div`,{className:`grid gap-3 border-b border-[var(--border)] px-4 py-3.5 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-center sm:px-5`,children:[i?(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h2`,{className:`sr-only`,children:e}),(0,A.jsx)(`p`,{className:`sr-only`,children:t}),(0,A.jsx)(`p`,{className:`text-xs font-medium text-[var(--muted-strong)]`,children:a??e})]}):(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-semibold text-[var(--ink)]`,children:e}),(0,A.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-[var(--muted-strong)]`,children:t})]}),(r||n)&&(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-2 lg:justify-end`,children:[r,n]})]}),(0,A.jsx)(`div`,{className:`divide-y divide-[var(--border)]`,children:o})]})}function ne(e){return(0,A.jsx)(L,{"data-slot":`popover`,...e})}function re(e){return(0,A.jsx)(z,{"data-slot":`popover-trigger`,...e})}function ie({className:e,align:t=`center`,sideOffset:n=6,...r}){return(0,A.jsx)(U,{children:(0,A.jsx)(G,{"data-slot":`popover-content`,align:t,sideOffset:n,className:p(`dropdown-content-motion z-50 w-72 origin-[var(--radix-popover-content-transform-origin)] rounded-[var(--radius-sm)] border border-[var(--border)] bg-[var(--surface)] p-3 text-[var(--ink)] shadow-[var(--shadow-raised)] outline-none`,e),...r})})}function ae({name:e,description:t,onConfirm:n}){let[i,a]=(0,k.useState)(!1),[o,s]=(0,k.useState)(!1),c=e=>{o||a(e)},u=async()=>{if(!o){s(!0);try{await n(),a(!1),r.success(`删除成功`,`“${e}”已删除。`)}catch(e){r.error(`删除失败`,e)}finally{s(!1)}}};return(0,A.jsxs)(ne,{open:i,onOpenChange:c,children:[(0,A.jsx)(re,{asChild:!0,children:(0,A.jsx)(l,{variant:`ghost`,children:`删除`})}),(0,A.jsx)(ie,{align:`end`,side:`top`,collisionPadding:12,children:(0,A.jsxs)(`div`,{className:`grid gap-3`,children:[(0,A.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,A.jsxs)(`p`,{className:`break-words text-sm font-semibold`,children:[`删除“`,e,`”?`]}),(0,A.jsx)(`p`,{className:`break-words text-xs leading-5 text-[var(--muted-strong)]`,children:t??`删除后无法恢复。`})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,A.jsx)(l,{size:`sm`,disabled:o,onClick:()=>c(!1),children:`取消`}),(0,A.jsx)(l,{size:`sm`,variant:`destructive`,loading:o,onClick:()=>void u(),children:`确认删除`})]})]})})]})}function oe({title:e,description:n,action:r,compact:i,summary:a,empty:o,emptyTitle:s,emptyDescription:c,emptyAction:l,pagination:u,children:d}){return(0,A.jsxs)(Q,{title:e,description:n,action:r,compact:i,summary:a,children:[o?(0,A.jsx)(t,{title:s??`暂无内容`,description:c??`创建第一个对象后会显示在这里。`,action:l}):d,u]})}function se({title:e,description:t,status:n,meta:r,onOpen:i,onEdit:a,onDelete:o,deleteDescription:s,children:c}){return(0,A.jsxs)(`div`,{className:`grid min-w-0 gap-3 px-4 py-3.5 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-center sm:px-5`,children:[i?(0,A.jsx)(`button`,{type:`button`,className:`min-w-0 rounded-[var(--radius-xs)] text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus)]`,onClick:i,children:(0,A.jsx)($,{title:e,description:t,status:n,meta:r})}):(0,A.jsx)(`div`,{className:`min-w-0`,children:(0,A.jsx)($,{title:e,description:t,status:n,meta:r})}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 lg:justify-end [&_button]:min-h-8 [&_button]:px-2.5 [&_button]:text-xs`,children:[c,a?(0,A.jsx)(l,{variant:`ghost`,onClick:a,children:`编辑`}):null,o?(0,A.jsx)(ae,{name:e,description:s,onConfirm:o}):null]})]})}function $({title:e,description:t,status:r,meta:i}){return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`truncate text-sm font-semibold text-[var(--ink)]`,children:e}),r&&r!==`ready`?(0,A.jsx)(n,{tone:r===`warning`?`warning`:`neutral`,children:r===`warning`?`需处理`:`已停用`}):null,i]}),(0,A.jsx)(`p`,{className:`mt-1 max-w-[90ch] text-xs leading-5 text-[var(--muted-strong)]`,children:t})]})}export{se as n,oe as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{et as e,sn as t}from"./index-DC7b8xgR.js";var n=t();function r({className:t,...r}){return(0,n.jsx)(`div`,{"data-slot":`field`,className:e(`grid gap-2 text-sm`,t),...r})}function i({className:t,...r}){return(0,n.jsx)(`label`,{"data-slot":`field-label`,className:e(`text-xs font-semibold uppercase text-[var(--muted)]`,t),...r})}function a({className:t,...r}){return(0,n.jsx)(`p`,{"data-slot":`field-description`,className:e(`text-xs leading-5 text-[var(--muted-strong)]`,t),...r})}function o({className:t,...r}){return(0,n.jsx)(`p`,{"data-slot":`field-error`,className:e(`text-xs leading-5 text-[var(--danger)]`,t),...r})}function s({label:t,children:s,htmlFor:c,required:l,helper:u,error:d,className:f}){return(0,n.jsxs)(r,{className:e(`gap-1.5`,f),children:[(0,n.jsxs)(i,{htmlFor:c,className:`flex items-center gap-1`,children:[t,l?(0,n.jsx)(`span`,{"aria-hidden":`true`,className:`text-[var(--danger)]`,children:`*`}):null]}),s,u||d?(0,n.jsx)(`div`,{className:`min-h-5`,"aria-live":`polite`,children:d?(0,n.jsx)(o,{children:d}):u?(0,n.jsx)(a,{children:u}):null}):null]})}export{s as t};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-DoHqwKmD.js";import{t}from"./useMutation-C221JCx3.js";import{t as n}from"./useQuery-CH_PyDWC.js";import{C as r,E as i,Ft as a,S as o,T as s,U as c,V as l,ln as u,sn as d,tt as f,w as p,x as m}from"./index-DC7b8xgR.js";import{t as h}from"./plus-Cgi-AlzH.js";import{t as g}from"./input-D7j_2GhD.js";import{t as _}from"./textarea-B7N7g6fl.js";import{n as v,t as y}from"./app-dialog-ChNc5zc0.js";import{t as b}from"./form-field-BbOl9sGR.js";import{n as x,t as S}from"./entity-list-C7fEITZj.js";import{t as C}from"./pagination-BIxivGX2.js";import{t as w}from"./notifications-Dlx9WRAf.js";import{t as T}from"./page-grid-x4teY0Qb.js";var E=e(u()),D=d(),O=20;function k(e=1){return n({queryKey:[...o(),e],queryFn:()=>s(e,O)})}function A(){let e=a();return t({mutationFn:e=>p(e),onSuccess:()=>e.invalidateQueries({queryKey:o()})})}function j(){let e=a();return t({mutationFn:({id:e,body:t})=>e?i(e,t):r(t),onSuccess:()=>e.invalidateQueries({queryKey:o()})})}var M={name:``,enabled:!0,positioning:``,audience:``,tone:``,forbiddenTopics:[]};function N(){let{page:e}=m.useSearch(),t=m.useNavigate(),{data:n}=k(e),[r,i]=(0,E.useState)(null),a=j(),o=A(),s=n?.items??[];return(0,D.jsxs)(T,{children:[(0,D.jsx)(S,{title:`身份列表`,description:`一个内容身份可以由不同内容方案发布到多个渠道账号。`,compact:!0,summary:`共 ${n?.total??0} 个身份`,action:(0,D.jsxs)(c,{variant:`primary`,onClick:()=>i(`new`),children:[(0,D.jsx)(h,{className:`size-4`}),`新建身份`]}),empty:!s.length,pagination:(0,D.jsx)(C,{page:e,pageSize:O,total:n?.total??0,onChange:e=>t({search:t=>({...t,page:e})})}),children:s.map(e=>(0,D.jsx)(x,{title:e.name,description:`${e.positioning} · 面向 ${e.audience} · ${e.tone}`,status:e.enabled?`ready`:`disabled`,onEdit:()=>i(e),onDelete:()=>o.mutateAsync(e.id)},e.id))}),(0,D.jsx)(P,{identity:r,open:!!r,onOpenChange:e=>!e&&i(null),onSave:e=>a.mutate({id:r===`new`?void 0:r.id,body:e},{onSuccess:()=>{i(null),w.success(`内容身份已保存`,`“${e.name}”已可用于内容方案。`)},onError:e=>w.error(`保存内容身份失败`,e)}),saving:a.isPending,error:a.error})]})}function P({identity:e,open:t,onOpenChange:n,onSave:r,saving:i,error:a}){let[o,s]=(0,E.useState)(M),[u,d]=(0,E.useState)(``);return(0,E.useEffect)(()=>{if(!e)return;let t=e===`new`?M:{...e,revision:e.revision};s(t),d(t.forbiddenTopics.join(`
|
|
2
|
-
`))},[e]),(0,D.jsxs)(y,{open:t,onOpenChange:n,title:e===`new`?`新建内容身份`:`编辑内容身份`,description:`只维护内容表达,不在这里绑定发布账号。`,size:`wide`,children:[(0,D.jsxs)(`div`,{className:`grid gap-5`,children:[(0,D.jsx)(F,{title:`基础信息`,children:(0,D.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,D.jsx)(b,{label:`名称`,required:!0,children:(0,D.jsx)(g,{value:o.name,onChange:e=>s({...o,name:e.target.value}),placeholder:`例如:工程观察`})}),(0,D.jsx)(b,{label:`语气`,required:!0,children:(0,D.jsx)(g,{value:o.tone,onChange:e=>s({...o,tone:e.target.value}),placeholder:`克制、直接、重证据`})}),(0,D.jsx)(b,{label:`定位`,required:!0,children:(0,D.jsx)(_,{className:`min-h-24`,value:o.positioning,onChange:e=>s({...o,positioning:e.target.value}),placeholder:`长期输出什么内容,以及坚持什么判断标准`})}),(0,D.jsx)(b,{label:`受众`,required:!0,children:(0,D.jsx)(_,{className:`min-h-24`,value:o.audience,onChange:e=>s({...o,audience:e.target.value}),placeholder:`读者是谁,以及他们为什么会持续关注`})})]})}),(0,D.jsx)(F,{title:`内容边界`,children:(0,D.jsx)(`div`,{className:`max-w-2xl`,children:(0,D.jsx)(b,{label:`禁止主题`,helper:`每行一条;主内容 Agent 与写作风格改写都会遵守这些边界。`,children:(0,D.jsx)(_,{className:`min-h-28`,value:u,onChange:e=>d(e.target.value),placeholder:`泛泛融资新闻
|
|
3
|
-
无技术细节的营销稿`})})})}),(0,D.jsx)(l,{error:a})]}),(0,D.jsxs)(v,{className:`flex justify-end gap-2`,children:[(0,D.jsx)(c,{onClick:()=>n(!1),children:`取消`}),(0,D.jsx)(c,{variant:`primary`,loading:i,disabled:!o.name.trim()||!o.positioning.trim()||!o.audience.trim()||!o.tone.trim(),onClick:()=>r({...o,forbiddenTopics:f(u)}),children:`保存`})]})]})}function F({title:e,children:t}){return(0,D.jsxs)(`section`,{className:`grid gap-3 border-t border-[var(--border)] pt-4 first:border-t-0 first:pt-0`,children:[(0,D.jsx)(`h3`,{className:`text-sm font-semibold text-[var(--ink)]`,children:e}),t]})}export{N as component,A as useDeleteIdentity,k as useIdentities,j as useSaveIdentity};
|