@fgbg/mdocs 1.2.0 → 1.2.2
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/agent-skills/changelog/SKILL.md +25 -1
- package/agent-skills/index/SKILL.md +1 -0
- package/agent-skills/index.json +8 -1
- package/agent-skills/usage-html-documents/SKILL.md +40 -0
- package/dist/server/agent/Config/config.js +26 -5
- package/dist/server/agent/Config/config.js.map +1 -1
- package/dist/server/agent/Config/config.test.js +23 -3
- package/dist/server/agent/Config/config.test.js.map +1 -1
- package/dist/server/documents/document.service.js +68 -59
- package/dist/server/documents/document.service.js.map +1 -1
- package/dist/server/documents/graph.integration.test.js +1 -0
- package/dist/server/documents/graph.integration.test.js.map +1 -1
- package/dist/server/documents/graph.service.js +14 -4
- package/dist/server/documents/graph.service.js.map +1 -1
- package/dist/server/documents/tree-and-folders.test.js +16 -0
- package/dist/server/documents/tree-and-folders.test.js.map +1 -1
- package/dist/server/documents/tree.service.js +13 -7
- package/dist/server/documents/tree.service.js.map +1 -1
- package/dist/server/routes/documents.routes.js +7 -1
- package/dist/server/routes/documents.routes.js.map +1 -1
- package/dist/server/routes/graph.routes.js +21 -4
- package/dist/server/routes/graph.routes.js.map +1 -1
- package/dist/server/routes/tree.routes.js +2 -1
- package/dist/server/routes/tree.routes.js.map +1 -1
- package/dist/shared/docPath.js +2 -2
- package/dist/shared/docPath.js.map +1 -1
- package/dist/shared/file-type-policy.js +12 -14
- package/dist/shared/file-type-policy.js.map +1 -1
- package/dist/shared/file-type-policy.test.js +37 -0
- package/dist/shared/file-type-policy.test.js.map +1 -0
- package/dist/shared/file-types.js +3 -4
- package/dist/shared/file-types.js.map +1 -1
- package/dist/shared/storagePath.js +11 -8
- package/dist/shared/storagePath.js.map +1 -1
- package/dist/web/assets/AgentChatPanel-dADh_kOG.js +22 -0
- package/dist/web/assets/AgentSkillFormCard-DEKBKWH-.js +6 -0
- package/dist/web/assets/{AiWriteWorkbench-i9ZoyX3p.js → AiWriteWorkbench-DezZBKI2.js} +1 -1
- package/dist/web/assets/{DiagramEditor-NtNY3sZL-CAQtZY2E.js → DiagramEditor-NtNY3sZL-5TyWJGgH.js} +1 -1
- package/dist/web/assets/{DocumentEditor-oFGmAxnV.js → DocumentEditor-D39RTLYE.js} +1 -1
- package/dist/web/assets/HtmlEditor-Bmpi_p2t.js +1 -0
- package/dist/web/assets/HtmlEditor-Bw2cVxtF.css +1 -0
- package/dist/web/assets/MergeView-WUR136do.js +10 -0
- package/dist/web/assets/{PlaygroundPage-BLEC6-Uf.js → PlaygroundPage-CPzJG_Wk.js} +1 -1
- package/dist/web/assets/SettingsPage-CuwYAiJh.js +1 -0
- package/dist/web/assets/{Toolbar-Dz9Cn_hv.js → Toolbar-JoV5KtuT.js} +1 -1
- package/dist/web/assets/{VisitorPickerModal-eagVdEZA.js → VisitorPickerModal-ImaQvyyf.js} +1 -1
- package/dist/web/assets/{code-xml-CZsyEkCa.js → code-xml-DX89c1sd.js} +1 -1
- package/dist/web/assets/{copy-BUUKT-QO.js → copy-yWKSE1g1.js} +1 -1
- package/dist/web/assets/diagram-Bk84WZto.js +3320 -0
- package/dist/web/assets/index-CwzlBu2W.js +263 -0
- package/dist/web/assets/index-uw_8eaPv.css +1 -0
- package/dist/web/assets/{meta2dEngine-BD2XbzaV-nAmL0RaW.js → meta2dEngine-BD2XbzaV-DUaWTg_P.js} +1 -1
- package/dist/web/assets/{motion-BgtuAqBE.js → motion-DFABYlwt.js} +1 -1
- package/dist/web/assets/{plus-BkiPFt2u.js → plus-B0mmDuSt.js} +1 -1
- package/dist/web/assets/{react--aHzEjEz.js → react-BJcufYxR.js} +3 -3
- package/dist/web/assets/{ui-RahDNce8.js → ui-CvA4pq3d.js} +3 -3
- package/dist/web/index.html +5 -5
- package/package.json +2 -2
- package/dist/web/assets/AgentChatPanel-Dd8Xnyia.js +0 -27
- package/dist/web/assets/AgentSkillFormCard-dsAy12lL.js +0 -6
- package/dist/web/assets/MergeView-DgEbzTVh.js +0 -10
- package/dist/web/assets/SettingsPage-BcCvamXH.js +0 -1
- package/dist/web/assets/diagram-DtU2xxz3.js +0 -5772
- package/dist/web/assets/index-DI_31upJ.js +0 -248
- package/dist/web/assets/index-YRgNGXBI.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diagram-
|
|
2
|
-
var gS=Object.defineProperty;var bS=(e,t,r)=>t in e?gS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var he=(e,t,r)=>bS(e,typeof t!="symbol"?t+"":t,r);import{r as u,j as N,R as q,a as vS,b as Eo,c as yS,m as Rl,T as su,d as T5,e as j5,f as A5,g as R5,h as z5,i as xb,k as xS,M as wS,l as CS,n as SS,o as wb,p as kS,q as $S,s as DS,t as _S,u as B5,S as ES,v as MS,w as IS,x as FS,y as ad,z as TS,_ as Nh,A as jS,B as Oh,C as cl,P as AS,D as lu,E as RS,F as zS,G as BS,H as PS,I as NS,J as OS,K as LS,L as Cb,N as Lh,O as HS,Q as qS,U as WS,V as VS,W as GS,X as US,Y as XS,Z as YS,$ as KS,a0 as Sb,a1 as kb,a2 as $b,a3 as ba,a4 as ZS,a5 as QS,a6 as JS,a7 as ek}from"./react-vendor-BuABiQkA.js";import{c as tk,r as rk,g as nk,s as Hh,G as ok,m as ul,u as ik,C as qn,M as ak,a as sk,b as P5,d as qh,T as lk,e as ck}from"./motion-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diagram-Bk84WZto.js","assets/react-vendor-BuABiQkA.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var gS=Object.defineProperty;var bS=(e,t,r)=>t in e?gS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var he=(e,t,r)=>bS(e,typeof t!="symbol"?t+"":t,r);import{r as u,j as N,R as q,a as vS,b as Eo,c as yS,m as Rl,T as su,d as T5,e as j5,f as A5,g as R5,h as z5,i as xb,k as xS,M as wS,l as CS,n as SS,o as wb,p as kS,q as $S,s as DS,t as _S,u as B5,S as ES,v as MS,w as IS,x as FS,y as ad,z as TS,_ as Nh,A as jS,B as Oh,C as cl,P as AS,D as lu,E as RS,F as zS,G as BS,H as PS,I as NS,J as OS,K as LS,L as Cb,N as Lh,O as HS,Q as qS,U as WS,V as VS,W as GS,X as US,Y as XS,Z as YS,$ as KS,a0 as Sb,a1 as kb,a2 as $b,a3 as ba,a4 as ZS,a5 as QS,a6 as JS,a7 as ek}from"./react-vendor-BuABiQkA.js";import{c as tk,r as rk,g as nk,s as Hh,G as ok,m as ul,u as ik,C as qn,M as ak,a as sk,b as P5,d as qh,T as lk,e as ck}from"./motion-DFABYlwt.js";const Wh=u.createContext(null);u.memo(({children:e,motion:t})=>N.jsx(Wh,{value:t,children:e}));const dte=()=>{const e=u.use(Wh);if(!e)throw new Error("Please wrap your app with <ConfigProvider> (or <MotionProvider>) and pass the motion component");return e};function uk(e){var t=[];if(e.length===0)return"";if(typeof e[0]!="string")throw new TypeError("Url must be a string. Received "+e[0]);if(e[0].match(/^[^/:]+:\/*$/)&&e.length>1){var r=e.shift();e[0]=r+e[0]}e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(var n=0;n<e.length;n++){var o=e[n];if(typeof o!="string")throw new TypeError("Url must be a string. Received "+o);o!==""&&(n>0&&(o=o.replace(/^[\/]+/,"")),n<e.length-1?o=o.replace(/[\/]+$/,""):o=o.replace(/[\/]+$/,"/"),t.push(o))}var i=t.join("/");i=i.replace(/\/(\?|&|#[^!])/g,"$1");var a=i.split("?");return i=a.shift()+(a.length>0?"?":"")+a.join("&"),i}function Db(){var e;return typeof arguments[0]=="object"?e=arguments[0]:e=[].slice.call(arguments),uk(e)}const dk="https://unpkg.com",fk="https://registry.npmmirror.com",N5=({pkg:e,version:t="latest",path:r,proxy:n})=>{switch(n){case"unpkg":return Db(dk,`${e}@${t}`,r);default:return Db(fk,e,t,"files",r)}},Vh=u.createContext(null),O5=u.createContext({locale:"en",t:e=>e}),fc=e=>typeof(e==null?void 0:e.then)=="function",fte=u.memo(({children:e,config:t,locale:r,resources:n,motion:o})=>{const i=r??"en",[a,s]=u.useState(()=>n&&!fc(n)?n:void 0),[l,c]=u.useState(i),d=u.useRef(0);u.useEffect(()=>{const m=++d.current;if(!n){s(void 0),c(i);return}if(fc(n)){const h=i;n.then(g=>{d.current===m&&(s(g),c(h))}).catch(()=>{d.current});return}s(n),c(i)},[i,n]);const f=fc(n)?a:n,p=fc(n)?l:i;return N.jsx(O5,{value:u.useMemo(()=>{const m=Array.isArray(f)?f:f?Object.values(f):[],h=Object.assign({},...m);return{locale:p,t:y=>h[y]||y}},[p,f]),children:N.jsx(Vh,{value:t??null,children:N.jsx(Wh,{value:o,children:e})})})}),_b=({pkg:e,version:t,path:r})=>N5({path:r,pkg:e,proxy:"aliyun",version:t}),Gh=()=>{const e=u.use(Vh);return e?(e==null?void 0:e.proxy)!=="custom"?({pkg:t,version:r,path:n})=>N5({path:n,pkg:t,proxy:e.proxy,version:r}):(e==null?void 0:e.customCdnFn)||_b:_b},pk=()=>u.use(O5);function L5(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Mo(e){"@babel/helpers - typeof";return Mo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Mo(e)}function mk(e,t){if(Mo(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(Mo(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function H5(e){var t=mk(e,"string");return Mo(t)=="symbol"?t:t+""}function hk(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,H5(n.key),n)}}function q5(e,t,r){return t&&hk(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function W5(e,t,r){return(t=H5(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var gk=function(){function e(){L5(this,e),W5(this,"_cacheList",[tk])}return q5(e,[{key:"add",value:function(r){var n=this.getCache(r.key);return n||(this._cacheList.push(r),r)}},{key:"delete",value:function(r){this._cacheList=this._cacheList.filter(function(n){return n.key!==r.key})}},{key:"hasCache",value:function(r){return this._cacheList.some(function(n){return n.key===r.key})}},{key:"getCache",value:function(r){return this._cacheList.find(function(n){return n.key===r})}},{key:"getCacheList",value:function(){return this._cacheList}}]),e}(),Eb=typeof document<"u",V5=function(t,r){return"".concat(t,"-").concat(r)},bk=function(t,r,n,o){var i=o.hashPriority;rk(t,r,n);var a=".".concat(V5(t.key,r.name)),s=i==="low"?":where(".concat(a,")"):a;if(t.inserted[r.name]===void 0){var l="",c=r;do{var d=t.insert(r===c?s:"",c,t.sheet,!0);!Eb&&d!==void 0&&(l+=d),c=c.next}while(c!==void 0);if(!Eb&&l.length!==0)return l}},Uh=function(t){return Mo(t)==="object"&&"styles"in t&&"name"in t&&"toString"in t},vk=function e(t){for(var r="",n=0;n<t.length;n++){var o=t[n];if(o!==null){var i=void 0;switch(Mo(o)){case"boolean":break;case"object":{if(Array.isArray(o))i=e(o);else{i="";for(var a in o)o[a]&&a&&(i&&(i+=" "),i+=a)}break}default:i=o}i&&(r&&(r+=" "),r+=i)}}return r},yk=function(t,r,n){var o=[],i=nk(t,o,n);return o.length<2?n:i+r(o)},xk=function(t,r){return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];var a=Hh(o,t.registered,void 0);return bk(t,a,!1,r),V5(t.key,a.name)}},wk=function(t,r){return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];var a=o.map(function(s){return Uh(s)?r(s):s});return yk(t.registered,r,vk(a))}},Xh=function(t,r){var n=xk(t,{hashPriority:r.hashPriority||"high",label:r.label}),o=wk(t,n);return{css:n,cx:o}},zl=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return Hh(r)},G5="acss";function Mb(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function Ot(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Mb(Object(r),!0).forEach(function(n){W5(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Mb(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var Ck=function(t){return u.createContext(t)},Sk=function(t){return function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return u.memo(function(i){var a=t();return N.jsx(ok,{styles:Hh(n,void 0,Ot(Ot({},i),{},{theme:a}))})})}};const ut=e=>{const t=u.useRef(e);return t.current=e,u.useCallback((...n)=>{var o;return(o=t.current)==null?void 0:o.call(t,...n)},[])};function uo(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}const Ib=uo()?u.useLayoutEffect:u.useEffect,Vt=(e,t)=>{const r=u.useRef(!0);Ib(()=>e(r.current),t),Ib(()=>(r.current=!1,()=>{r.current=!0}),[])},x0=(e,t)=>{Vt(r=>{if(!r)return e()},t)},kk=e=>{const t=u.useRef(!1),[r,n]=u.useState(e);u.useEffect(()=>(t.current=!1,()=>{t.current=!0}),[]);function o(i,a){a&&t.current||n(i)}return[r,o]};function Jt(e,t){const[r,n]=u.useState(e),o=t!==void 0?t:r;return Vt(i=>{i||n(t)},[t]),[o,n]}var U5={exports:{}},Kt={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-is.production.min.js
|
|
5
5
|
*
|
|
@@ -2444,7 +2444,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
2444
2444
|
overflow: hidden;
|
|
2445
2445
|
max-width: 100%;
|
|
2446
2446
|
height: auto;
|
|
2447
|
-
`})),RV=ur(Cn.root,{defaultVariants:{variant:"filled"},variants:{variant:{filled:Cn.filled,outlined:Cn.outlined,borderless:Cn.borderless}}}),zV="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiBmaWxsPSIjM0IzQjNCIi8+CjxwYXRoIGQ9Ik0xNTYuODg4IDkxLjAwMkgxMDAuMTEyQzk1LjYzMjkgOTEuMDAyIDkyLjAwMTUgOTQuNjMzNCA5Mi4wMDE1IDk5LjExMjdWMTU1Ljg4OEM5Mi4wMDE1IDE2MC4zNjcgOTUuNjMyOSAxNjMuOTk5IDEwMC4xMTIgMTYzLjk5OUgxNTYuODg4QzE2MS4zNjcgMTYzLjk5OSAxNjQuOTk4IDE2MC4zNjcgMTY0Ljk5OCAxNTUuODg4Vjk5LjExMjdDMTY0Ljk5OCA5NC42MzM0IDE2MS4zNjcgOTEuMDAyIDE1Ni44ODggOTEuMDAyWiIgc3Ryb2tlPSIjNjI2MjYyIiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTY0Ljk5OCAxMzkuNjY4TDE1Mi40ODQgMTI3LjE1M0MxNTAuOTYyIDEyNS42MzIgMTQ4LjkgMTI0Ljc3OCAxNDYuNzQ5IDEyNC43NzhDMTQ0LjU5OSAxMjQuNzc4IDE0Mi41MzYgMTI1LjYzMiAxNDEuMDE1IDEyNy4xNTNMMTA0LjE2OCAxNjRNMTE2LjMzNCAxMjMuNDQ1QzEyMC44MTMgMTIzLjQ0NSAxMjQuNDQ1IDExOS44MTQgMTI0LjQ0NSAxMTUuMzM0QzEyNC40NDUgMTEwLjg1NSAxMjAuODEzIDEwNy4yMjQgMTE2LjMzNCAxMDcuMjI0QzExMS44NTUgMTA3LjIyNCAxMDguMjIzIDExMC44NTUgMTA4LjIyMyAxMTUuMzM0QzEwOC4yMjMgMTE5LjgxNCAxMTEuODU1IDEyMy40NDUgMTE2LjMzNCAxMjMuNDQ1WiIgc3Ryb2tlPSIjNjI2MjYyIiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K",BV="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiBmaWxsPSIjRUNFQ0VDIi8+CjxwYXRoIGQ9Ik0xNTYuODg4IDkxLjAwMkgxMDAuMTEyQzk1LjYzMjkgOTEuMDAyIDkyLjAwMTUgOTQuNjMzNCA5Mi4wMDE1IDk5LjExMjdWMTU1Ljg4OEM5Mi4wMDE1IDE2MC4zNjcgOTUuNjMyOSAxNjMuOTk5IDEwMC4xMTIgMTYzLjk5OUgxNTYuODg4QzE2MS4zNjcgMTYzLjk5OSAxNjQuOTk4IDE2MC4zNjcgMTY0Ljk5OCAxNTUuODg4Vjk5LjExMjdDMTY0Ljk5OCA5NC42MzM0IDE2MS4zNjcgOTEuMDAyIDE1Ni44ODggOTEuMDAyWiIgc3Ryb2tlPSIjRDdEN0Q3IiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTY0Ljk5OCAxMzkuNjY4TDE1Mi40ODQgMTI3LjE1M0MxNTAuOTYyIDEyNS42MzIgMTQ4LjkgMTI0Ljc3OCAxNDYuNzQ5IDEyNC43NzhDMTQ0LjU5OSAxMjQuNzc4IDE0Mi41MzYgMTI1LjYzMiAxNDEuMDE1IDEyNy4xNTNMMTA0LjE2OCAxNjRNMTE2LjMzNCAxMjMuNDQ1QzEyMC44MTMgMTIzLjQ0NSAxMjQuNDQ1IDExOS44MTQgMTI0LjQ0NSAxMTUuMzM0QzEyNC40NDUgMTEwLjg1NSAxMjAuODEzIDEwNy4yMjQgMTE2LjMzNCAxMDcuMjI0QzExMS44NTUgMTA3LjIyNCAxMDguMjIzIDExMC44NTUgMTA4LjIyMyAxMTUuMzM0QzEwOC4yMjMgMTE5LjgxNCAxMTEuODU1IDEyMy40NDUgMTE2LjMzNCAxMjMuNDQ1WiIgc3Ryb2tlPSIjRDdEN0Q3IiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K",r9=u.memo(({children:e,visible:t})=>{const r=u.useRef(null);return u.useEffect(()=>{if(!r.current)return;const n=o=>{o.preventDefault()};t?r.current.addEventListener("wheel",n,{passive:!1}):r.current.removeEventListener("wheel",n)},[t]),N.jsx("div",{ref:r,children:e})});var PV={"image.copy":"Copy","image.copyFailed":"Copy Failed","image.copySuccess":"Copy Success","image.download":"Download","image.downloadFailed":"Download Failed","image.downloadSuccess":"Download Success","image.flipHorizontal":"Flip Horizontal","image.flipVertical":"Flip Vertical","image.rotateLeft":"Rotate Left","image.rotateRight":"Rotate Right","image.zoomIn":"Zoom In","image.zoomOut":"Zoom Out"};const NV=e=>new Promise((t,r)=>{const n=new Image,o=URL.createObjectURL(e);n.onload=()=>{URL.revokeObjectURL(o);const i=document.createElement("canvas");i.width=n.naturalWidth,i.height=n.naturalHeight;const a=i.getContext("2d");if(!a){r(new Error("Canvas context not available"));return}a.drawImage(n,0,0),i.toBlob(s=>{s?t(s):r(new Error("Failed to convert to PNG"))},"image/png",1)},n.onerror=()=>{URL.revokeObjectURL(o),r(new Error("Failed to load image"))},n.src=o}),OV=async e=>{const t=(e.type||"").toLowerCase();return t==="image/png"||t==="image/svg+xml"?{[t]:e}:{"image/png":await NV(e)}},LV=e=>{try{const t=new URL(e).pathname.match(/\/([^/]+)$/);return t?decodeURIComponent(t[1]):"image"}catch{return"image"}},HV=e=>{var t;return{"image/svg+xml":"svg","image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/webp":"webp","image/gif":"gif"}[e==null?void 0:e.toLowerCase()]||((t=e==null?void 0:e.split("/")[1])==null?void 0:t.split("+")[0])||"png"},n9=u.memo(({children:e,info:t,minScale:r,maxScale:n})=>{const{t:o}=IW(PV),[i,a]=u.useState(null),[s,l]=u.useState(!1),[c,d]=u.useState(!1),{transform:{scale:f},actions:{onFlipY:p,onFlipX:m,onRotateLeft:h,onRotateRight:g,onZoomOut:y,onZoomIn:b},image:{url:v}}=t,x=u.useCallback(async()=>{d(!0);try{const S=await(await fetch(v,{mode:"cors"})).blob(),C=URL.createObjectURL(S);let k=LV(v);const D=HV(S.type);k.includes(".")?k.endsWith(".svg+xml")&&(k=k.replace(/\.svg\+xml$/i,".svg")):k=`${k}.${D}`,await jW(C,k),URL.revokeObjectURL(C),Wa.success(o("image.downloadSuccess"))}catch{Wa.error(o("image.downloadFailed"))}finally{d(!1)}},[v,o]),w=u.useCallback(async()=>{l(!0);try{const S=await OV(await(await fetch(v,{mode:"cors"})).blob());await navigator.clipboard.write([new ClipboardItem(S)]),Wa.success(o("image.copySuccess"))}catch{Wa.error(o("image.copyFailed"))}finally{l(!1)}},[v,o]);return N.jsx(E1,{popupContainer:i??void 0,children:N.jsxs(or,{horizontal:!0,className:Cn.toolbar,gap:4,ref:a,children:[N.jsx(dn,{icon:XH,title:o("image.flipHorizontal"),onClick:m}),N.jsx(dn,{icon:GH,title:o("image.flipVertical"),onClick:p}),N.jsx(dn,{icon:OH,title:o("image.rotateLeft"),onClick:h}),N.jsx(dn,{icon:HH,title:o("image.rotateRight"),onClick:g}),N.jsx(dn,{disabled:f===r,icon:tq,title:o("image.zoomOut"),onClick:y}),N.jsx(dn,{disabled:f===n,icon:JH,title:o("image.zoomIn"),onClick:b}),N.jsx(dn,{icon:Zw,loading:s,title:o("image.copy"),onClick:w}),N.jsx(dn,{icon:EH,loading:c,title:o("image.download"),onClick:x}),e]})})}),qV=e=>{const[t,r]=u.useState(!1);return u.useMemo(()=>{if(e===!1)return e;const{onVisibleChange:n,onOpenChange:o,minScale:i=.32,maxScale:a=32,toolbarAddon:s,rootClassName:l,imageRender:c,toolbarRender:d,...f}=e===!0?{}:e||{};return{actionsRender:(p,m)=>{const h=N.jsx(n9,{info:m,maxScale:a,minScale:i,children:s});return d?d(h,m):h},closeIcon:N.jsx(jt,{color:"#fff",icon:Wu}),imageRender:(p,m)=>{const h=N.jsx(r9,{visible:t,children:p});return c?c(h,m):h},maxScale:a,minScale:i,onOpenChange:(p,m)=>{r(p),o==null||o(p,m),n==null||n(p,!p,m.current)},rootClassName:Fe(Cn.preview,l),...f}},[e,t,Cn])},{PreviewGroup:WV}=l1,o9=u.memo(({items:e,children:t,enable:r=!0,preview:n})=>{const o=qV(n);return r?N.jsx(WV,{items:e,preview:o,children:t}):t});o9.displayName="PreviewGroup";const VV=e=>{const[t,r]=u.useState(!1);return u.useMemo(()=>{if(e===!1)return e;const{onVisibleChange:n,onOpenChange:o,minScale:i=.32,maxScale:a=32,toolbarAddon:s,rootClassName:l,imageRender:c,toolbarRender:d,actionsRender:f,...p}=e===!0?{}:e||{};return{actionsRender:f||((m,h)=>{const g=N.jsx(n9,{info:h,maxScale:a,minScale:i,children:s});return d?d(g,h):g}),closeIcon:N.jsx(jt,{color:"#fff",icon:Wu}),imageRender:(m,h)=>{const g=N.jsx(r9,{visible:t,children:m});return c?c(g,h):g},maxScale:a,minScale:i,onOpenChange:m=>{r(m),o==null||o(m),n==null||n(m,!m)},rootClassName:Fe(Cn.preview,l),styles:{mask:{backdropFilter:"blur(8px)"}},...p}},[e,t,Cn])},i9=u.memo(({ref:e,style:t,preview:r,isLoading:n,maxHeight:o="100%",maxWidth:i="100%",minHeight:a,minWidth:s,actions:l,className:c,alwaysShowActions:d,variant:f="filled",objectFit:p="cover",classNames:m,styles:h,onClick:g,width:y,height:b,...v})=>{const{isDarkMode:x}=En(),w=d?Cn.actionsVisible:Cn.actionsHidden,S=VV(r);return n?N.jsx("div",{onClick:g,children:N.jsx(la.Avatar,{active:!0,style:{borderRadius:Ce.borderRadius,height:b,maxHeight:o,maxWidth:i,minHeight:a,minWidth:s,width:y}})}):N.jsxs(or,{className:Fe(RV({variant:f}),c),ref:e,style:t,children:[l&&N.jsx("div",{className:Fe(w,d?"":"actions-hidden"),children:l}),N.jsx(l1,{className:Fe(Cn.image,m==null?void 0:m.image),fallback:x?zV:BV,height:b,loading:"lazy",preview:r===!1?!1:S,width:y,classNames:{root:Fe(Cn.wrapper,m==null?void 0:m.wrapper)},style:{maxHeight:o,maxWidth:i,minHeight:a,minWidth:s,objectFit:p||"cover",...h==null?void 0:h.image},styles:{root:h==null?void 0:h.wrapper},onClick:g,...v})]})});i9.displayName="Image";const B1=i9;B1.PreviewGroup=o9;const a9=[{displayName:"Lobe Theme",id:"lobe-theme"},{background:"#fbf9ff",displayName:"Mermaid Default",id:"default"},{background:"#fffcf8",displayName:"Mermaid Base",id:"base"},{background:"#000",displayName:"Mermaid Dark",id:"dark"},{background:"#f9ffeb",displayName:"Mermaid Forest",id:"forest"},{background:"#fff",displayName:"Mermaid Neutral",id:"neutral"}],Zo=new Map,Jy=500,GV=()=>{if(Zo.size>Jy){const e=Math.floor(Jy*.2),t=Array.from(Zo.keys()).slice(0,e);for(const r of t)Zo.delete(r)}};let Sf=null;const s9=()=>typeof window>"u"?Promise.resolve(null):(Sf||(Sf=Nh(()=>import("./diagram-DtU2xxz3.js").then(e=>e.z),__vite__mapDeps([0,1])).then(e=>e.default)),Sf),l9=(e,t,r="strict")=>({fontFamily:e.fontFamilyCode,gantt:{useWidth:1920},securityLevel:r,startOnLoad:!1,theme:t||(e.isDarkMode?"dark":"neutral"),themeVariables:t?void 0:{errorBkgColor:e.colorTextDescription,errorTextColor:e.colorTextDescription,fontFamily:e.fontFamily,lineColor:e.colorTextSecondary,mainBkg:e.colorBgContainer,noteBkgColor:e.colorInfoBg,noteTextColor:e.colorInfoText,pie1:e.geekblue,pie2:e.colorWarning,pie3:e.colorSuccess,pie4:e.colorError,primaryBorderColor:e.colorBorder,primaryColor:e.colorBgContainer,primaryTextColor:e.colorText,secondaryBorderColor:e.colorInfoBorder,secondaryColor:e.colorInfoBg,secondaryTextColor:e.colorInfoText,tertiaryBorderColor:e.colorSuccessBorder,tertiaryColor:e.colorSuccessBg,tertiaryTextColor:e.colorSuccessText,textColor:e.colorText}}),UV=(e,{id:t,theme:r,securityLevel:n})=>{const o=m1(),[i,a]=u.useState(""),s=u.useMemo(()=>l9(o,r,n),[o.fontFamilyCode,o.isDarkMode,o.colorTextDescription,o.fontFamily,o.colorTextSecondary,o.colorBgContainer,o.colorInfoBg,o.colorInfoText,o.geekblue,o.colorWarning,o.colorSuccess,o.colorError,o.colorBorder,o.colorInfoBorder,o.colorSuccessBorder,o.colorSuccessBg,o.colorSuccessText,o.colorText,r,n]),l=u.useMemo(()=>{const c=e.length<1e4?e:Il.hashStr(e);return[t,r||(o.isDarkMode?"d":"l"),c].filter(Boolean).join("-")},[e,t,o.isDarkMode,r]);return u.useEffect(()=>{const c=Zo.get(l);if(c){c.then(f=>{a(f)}).catch(()=>{});return}const d=(async()=>{try{const f=await s9();if(!f)return"";if(await f.parse(e)){f.initialize(s);const{svg:p}=await f.render(t,e);return p}else throw new Error("Mermaid 语法无效")}catch(f){return console.error("Mermaid 解析错误:",f),""}})();Zo.set(l,d),GV(),d.then(f=>{Zo.get(l)===d&&a(f)}).catch(()=>{Zo.get(l)===d&&Zo.delete(l)})},[l,e,t,s]),i},c9=u.memo(({children:e,className:t,fallbackClassName:r,ref:n,style:o,theme:i,variant:a})=>{const s=e??"",l=i==="lobe-theme"||!i,c=u.useMemo(()=>{var g;if(!l)return(g=a9.find(y=>y.id===i))==null?void 0:g.background},[l,i]),d=UV(s,{id:Lw(`mermaid-${u.useId()}`),theme:l?void 0:i}),f=!d,[p,m]=u.useState();u.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]),u.useEffect(()=>{if(f||!d)return;let g=d;if(typeof window<"u"&&typeof navigator<"u"&&navigator.userAgent.includes("Firefox")){const b=new DOMParser().parseFromString(d,"image/svg+xml"),v=b.documentElement;if(v&&v.hasAttribute("viewBox")){const x=v.getAttribute("viewBox").split(" ");Array.isArray(x)&&x.length===4&&(v.setAttribute("width",x[2]),v.setAttribute("height",x[3])),g=new XMLSerializer().serializeToString(b)}}const y=new Blob([g],{type:"image/svg+xml"});m(URL.createObjectURL(y))},[f,d]);const h={background:a==="filled"?c:void 0,margin:0,minWidth:300,padding:a==="borderless"?0:16,position:"relative",width:"100%",...o};return p?N.jsx(B1,{alt:"mermaid",className:t,maxHeight:480,minWidth:300,objectFit:"contain",ref:n,src:p,style:h,variant:"borderless",width:"100%"}):N.jsx("div",{className:r,style:o,children:N.jsx("div",{style:{padding:16},children:"Loading..."})})});c9.displayName="StaticMermaid";const XV=(e,{enabled:t=!0,id:r,theme:n})=>{const o=m1(),[i,a]=u.useState(""),s=u.useRef(""),l=u.useRef(e),c=u.useRef(void 0),d=u.useMemo(()=>l9(o,n),[o.fontFamilyCode,o.isDarkMode,o.colorTextDescription,o.fontFamily,o.colorTextSecondary,o.colorBgContainer,o.colorInfoBg,o.colorInfoText,o.geekblue,o.colorWarning,o.colorSuccess,o.colorError,o.colorBorder,o.colorInfoBorder,o.colorSuccessBorder,o.colorSuccessBg,o.colorSuccessText,o.colorText,n]);return u.useEffect(()=>{l.current=e},[e]),u.useEffect(()=>{if(!t){a(""),s.current="";const m=c.current;m&&clearTimeout(m);return}const f=l.current;if(f===s.current&&i)return;const p=c.current;return p&&clearTimeout(p),c.current=setTimeout(async()=>{const m=l.current;if(m===f)try{const h=await s9();if(!h)return;if(await h.parse(m)){h.initialize(d);const{svg:g}=await h.render(r,m);l.current===m&&(a(g),s.current=m)}}catch(h){m===l.current&&console.error("Mermaid 解析错误:",h)}},300),()=>{const m=c.current;m&&clearTimeout(m)}},[t,e,r,d,i]),i},u9=u.memo(({children:e,className:t,fallbackClassName:r,ref:n,style:o,theme:i,variant:a})=>{const s=e??"",l=i==="lobe-theme"||!i,c=u.useMemo(()=>{var g;if(!l)return(g=a9.find(y=>y.id===i))==null?void 0:g.background},[l,i]),d=XV(s,{enabled:!0,id:Lw(`mermaid-${u.useId()}`),theme:l?void 0:i}),f=!d,[p,m]=u.useState();u.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]),u.useEffect(()=>{if(f||!d){m(void 0);return}let g=d;if(typeof window<"u"&&typeof navigator<"u"&&navigator.userAgent.includes("Firefox")){const b=new DOMParser().parseFromString(d,"image/svg+xml"),v=b.documentElement;if(v&&v.hasAttribute("viewBox")){const x=v.getAttribute("viewBox").split(" ");Array.isArray(x)&&x.length===4&&(v.setAttribute("width",x[2]),v.setAttribute("height",x[3])),g=new XMLSerializer().serializeToString(b)}}const y=new Blob([g],{type:"image/svg+xml"});m(URL.createObjectURL(y))},[f,d]);const h={background:a==="filled"?c:void 0,margin:0,minWidth:300,padding:a==="borderless"?0:16,position:"relative",width:"100%",...o};return p?N.jsx(B1,{alt:"mermaid",className:t,maxHeight:480,minWidth:300,objectFit:"contain",ref:n,src:p,style:h,variant:"borderless",width:"100%"}):N.jsx("div",{className:r,style:o,children:N.jsx("div",{style:{padding:16},children:"Rendering..."})})});u9.displayName="StreamMermaid";const YV=tc`
|
|
2447
|
+
`})),RV=ur(Cn.root,{defaultVariants:{variant:"filled"},variants:{variant:{filled:Cn.filled,outlined:Cn.outlined,borderless:Cn.borderless}}}),zV="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiBmaWxsPSIjM0IzQjNCIi8+CjxwYXRoIGQ9Ik0xNTYuODg4IDkxLjAwMkgxMDAuMTEyQzk1LjYzMjkgOTEuMDAyIDkyLjAwMTUgOTQuNjMzNCA5Mi4wMDE1IDk5LjExMjdWMTU1Ljg4OEM5Mi4wMDE1IDE2MC4zNjcgOTUuNjMyOSAxNjMuOTk5IDEwMC4xMTIgMTYzLjk5OUgxNTYuODg4QzE2MS4zNjcgMTYzLjk5OSAxNjQuOTk4IDE2MC4zNjcgMTY0Ljk5OCAxNTUuODg4Vjk5LjExMjdDMTY0Ljk5OCA5NC42MzM0IDE2MS4zNjcgOTEuMDAyIDE1Ni44ODggOTEuMDAyWiIgc3Ryb2tlPSIjNjI2MjYyIiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTY0Ljk5OCAxMzkuNjY4TDE1Mi40ODQgMTI3LjE1M0MxNTAuOTYyIDEyNS42MzIgMTQ4LjkgMTI0Ljc3OCAxNDYuNzQ5IDEyNC43NzhDMTQ0LjU5OSAxMjQuNzc4IDE0Mi41MzYgMTI1LjYzMiAxNDEuMDE1IDEyNy4xNTNMMTA0LjE2OCAxNjRNMTE2LjMzNCAxMjMuNDQ1QzEyMC44MTMgMTIzLjQ0NSAxMjQuNDQ1IDExOS44MTQgMTI0LjQ0NSAxMTUuMzM0QzEyNC40NDUgMTEwLjg1NSAxMjAuODEzIDEwNy4yMjQgMTE2LjMzNCAxMDcuMjI0QzExMS44NTUgMTA3LjIyNCAxMDguMjIzIDExMC44NTUgMTA4LjIyMyAxMTUuMzM0QzEwOC4yMjMgMTE5LjgxNCAxMTEuODU1IDEyMy40NDUgMTE2LjMzNCAxMjMuNDQ1WiIgc3Ryb2tlPSIjNjI2MjYyIiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K",BV="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiBmaWxsPSIjRUNFQ0VDIi8+CjxwYXRoIGQ9Ik0xNTYuODg4IDkxLjAwMkgxMDAuMTEyQzk1LjYzMjkgOTEuMDAyIDkyLjAwMTUgOTQuNjMzNCA5Mi4wMDE1IDk5LjExMjdWMTU1Ljg4OEM5Mi4wMDE1IDE2MC4zNjcgOTUuNjMyOSAxNjMuOTk5IDEwMC4xMTIgMTYzLjk5OUgxNTYuODg4QzE2MS4zNjcgMTYzLjk5OSAxNjQuOTk4IDE2MC4zNjcgMTY0Ljk5OCAxNTUuODg4Vjk5LjExMjdDMTY0Ljk5OCA5NC42MzM0IDE2MS4zNjcgOTEuMDAyIDE1Ni44ODggOTEuMDAyWiIgc3Ryb2tlPSIjRDdEN0Q3IiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTY0Ljk5OCAxMzkuNjY4TDE1Mi40ODQgMTI3LjE1M0MxNTAuOTYyIDEyNS42MzIgMTQ4LjkgMTI0Ljc3OCAxNDYuNzQ5IDEyNC43NzhDMTQ0LjU5OSAxMjQuNzc4IDE0Mi41MzYgMTI1LjYzMiAxNDEuMDE1IDEyNy4xNTNMMTA0LjE2OCAxNjRNMTE2LjMzNCAxMjMuNDQ1QzEyMC44MTMgMTIzLjQ0NSAxMjQuNDQ1IDExOS44MTQgMTI0LjQ0NSAxMTUuMzM0QzEyNC40NDUgMTEwLjg1NSAxMjAuODEzIDEwNy4yMjQgMTE2LjMzNCAxMDcuMjI0QzExMS44NTUgMTA3LjIyNCAxMDguMjIzIDExMC44NTUgMTA4LjIyMyAxMTUuMzM0QzEwOC4yMjMgMTE5LjgxNCAxMTEuODU1IDEyMy40NDUgMTE2LjMzNCAxMjMuNDQ1WiIgc3Ryb2tlPSIjRDdEN0Q3IiBzdHJva2Utd2lkdGg9IjguMTEwNzciIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4K",r9=u.memo(({children:e,visible:t})=>{const r=u.useRef(null);return u.useEffect(()=>{if(!r.current)return;const n=o=>{o.preventDefault()};t?r.current.addEventListener("wheel",n,{passive:!1}):r.current.removeEventListener("wheel",n)},[t]),N.jsx("div",{ref:r,children:e})});var PV={"image.copy":"Copy","image.copyFailed":"Copy Failed","image.copySuccess":"Copy Success","image.download":"Download","image.downloadFailed":"Download Failed","image.downloadSuccess":"Download Success","image.flipHorizontal":"Flip Horizontal","image.flipVertical":"Flip Vertical","image.rotateLeft":"Rotate Left","image.rotateRight":"Rotate Right","image.zoomIn":"Zoom In","image.zoomOut":"Zoom Out"};const NV=e=>new Promise((t,r)=>{const n=new Image,o=URL.createObjectURL(e);n.onload=()=>{URL.revokeObjectURL(o);const i=document.createElement("canvas");i.width=n.naturalWidth,i.height=n.naturalHeight;const a=i.getContext("2d");if(!a){r(new Error("Canvas context not available"));return}a.drawImage(n,0,0),i.toBlob(s=>{s?t(s):r(new Error("Failed to convert to PNG"))},"image/png",1)},n.onerror=()=>{URL.revokeObjectURL(o),r(new Error("Failed to load image"))},n.src=o}),OV=async e=>{const t=(e.type||"").toLowerCase();return t==="image/png"||t==="image/svg+xml"?{[t]:e}:{"image/png":await NV(e)}},LV=e=>{try{const t=new URL(e).pathname.match(/\/([^/]+)$/);return t?decodeURIComponent(t[1]):"image"}catch{return"image"}},HV=e=>{var t;return{"image/svg+xml":"svg","image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/webp":"webp","image/gif":"gif"}[e==null?void 0:e.toLowerCase()]||((t=e==null?void 0:e.split("/")[1])==null?void 0:t.split("+")[0])||"png"},n9=u.memo(({children:e,info:t,minScale:r,maxScale:n})=>{const{t:o}=IW(PV),[i,a]=u.useState(null),[s,l]=u.useState(!1),[c,d]=u.useState(!1),{transform:{scale:f},actions:{onFlipY:p,onFlipX:m,onRotateLeft:h,onRotateRight:g,onZoomOut:y,onZoomIn:b},image:{url:v}}=t,x=u.useCallback(async()=>{d(!0);try{const S=await(await fetch(v,{mode:"cors"})).blob(),C=URL.createObjectURL(S);let k=LV(v);const D=HV(S.type);k.includes(".")?k.endsWith(".svg+xml")&&(k=k.replace(/\.svg\+xml$/i,".svg")):k=`${k}.${D}`,await jW(C,k),URL.revokeObjectURL(C),Wa.success(o("image.downloadSuccess"))}catch{Wa.error(o("image.downloadFailed"))}finally{d(!1)}},[v,o]),w=u.useCallback(async()=>{l(!0);try{const S=await OV(await(await fetch(v,{mode:"cors"})).blob());await navigator.clipboard.write([new ClipboardItem(S)]),Wa.success(o("image.copySuccess"))}catch{Wa.error(o("image.copyFailed"))}finally{l(!1)}},[v,o]);return N.jsx(E1,{popupContainer:i??void 0,children:N.jsxs(or,{horizontal:!0,className:Cn.toolbar,gap:4,ref:a,children:[N.jsx(dn,{icon:XH,title:o("image.flipHorizontal"),onClick:m}),N.jsx(dn,{icon:GH,title:o("image.flipVertical"),onClick:p}),N.jsx(dn,{icon:OH,title:o("image.rotateLeft"),onClick:h}),N.jsx(dn,{icon:HH,title:o("image.rotateRight"),onClick:g}),N.jsx(dn,{disabled:f===r,icon:tq,title:o("image.zoomOut"),onClick:y}),N.jsx(dn,{disabled:f===n,icon:JH,title:o("image.zoomIn"),onClick:b}),N.jsx(dn,{icon:Zw,loading:s,title:o("image.copy"),onClick:w}),N.jsx(dn,{icon:EH,loading:c,title:o("image.download"),onClick:x}),e]})})}),qV=e=>{const[t,r]=u.useState(!1);return u.useMemo(()=>{if(e===!1)return e;const{onVisibleChange:n,onOpenChange:o,minScale:i=.32,maxScale:a=32,toolbarAddon:s,rootClassName:l,imageRender:c,toolbarRender:d,...f}=e===!0?{}:e||{};return{actionsRender:(p,m)=>{const h=N.jsx(n9,{info:m,maxScale:a,minScale:i,children:s});return d?d(h,m):h},closeIcon:N.jsx(jt,{color:"#fff",icon:Wu}),imageRender:(p,m)=>{const h=N.jsx(r9,{visible:t,children:p});return c?c(h,m):h},maxScale:a,minScale:i,onOpenChange:(p,m)=>{r(p),o==null||o(p,m),n==null||n(p,!p,m.current)},rootClassName:Fe(Cn.preview,l),...f}},[e,t,Cn])},{PreviewGroup:WV}=l1,o9=u.memo(({items:e,children:t,enable:r=!0,preview:n})=>{const o=qV(n);return r?N.jsx(WV,{items:e,preview:o,children:t}):t});o9.displayName="PreviewGroup";const VV=e=>{const[t,r]=u.useState(!1);return u.useMemo(()=>{if(e===!1)return e;const{onVisibleChange:n,onOpenChange:o,minScale:i=.32,maxScale:a=32,toolbarAddon:s,rootClassName:l,imageRender:c,toolbarRender:d,actionsRender:f,...p}=e===!0?{}:e||{};return{actionsRender:f||((m,h)=>{const g=N.jsx(n9,{info:h,maxScale:a,minScale:i,children:s});return d?d(g,h):g}),closeIcon:N.jsx(jt,{color:"#fff",icon:Wu}),imageRender:(m,h)=>{const g=N.jsx(r9,{visible:t,children:m});return c?c(g,h):g},maxScale:a,minScale:i,onOpenChange:m=>{r(m),o==null||o(m),n==null||n(m,!m)},rootClassName:Fe(Cn.preview,l),styles:{mask:{backdropFilter:"blur(8px)"}},...p}},[e,t,Cn])},i9=u.memo(({ref:e,style:t,preview:r,isLoading:n,maxHeight:o="100%",maxWidth:i="100%",minHeight:a,minWidth:s,actions:l,className:c,alwaysShowActions:d,variant:f="filled",objectFit:p="cover",classNames:m,styles:h,onClick:g,width:y,height:b,...v})=>{const{isDarkMode:x}=En(),w=d?Cn.actionsVisible:Cn.actionsHidden,S=VV(r);return n?N.jsx("div",{onClick:g,children:N.jsx(la.Avatar,{active:!0,style:{borderRadius:Ce.borderRadius,height:b,maxHeight:o,maxWidth:i,minHeight:a,minWidth:s,width:y}})}):N.jsxs(or,{className:Fe(RV({variant:f}),c),ref:e,style:t,children:[l&&N.jsx("div",{className:Fe(w,d?"":"actions-hidden"),children:l}),N.jsx(l1,{className:Fe(Cn.image,m==null?void 0:m.image),fallback:x?zV:BV,height:b,loading:"lazy",preview:r===!1?!1:S,width:y,classNames:{root:Fe(Cn.wrapper,m==null?void 0:m.wrapper)},style:{maxHeight:o,maxWidth:i,minHeight:a,minWidth:s,objectFit:p||"cover",...h==null?void 0:h.image},styles:{root:h==null?void 0:h.wrapper},onClick:g,...v})]})});i9.displayName="Image";const B1=i9;B1.PreviewGroup=o9;const a9=[{displayName:"Lobe Theme",id:"lobe-theme"},{background:"#fbf9ff",displayName:"Mermaid Default",id:"default"},{background:"#fffcf8",displayName:"Mermaid Base",id:"base"},{background:"#000",displayName:"Mermaid Dark",id:"dark"},{background:"#f9ffeb",displayName:"Mermaid Forest",id:"forest"},{background:"#fff",displayName:"Mermaid Neutral",id:"neutral"}],Zo=new Map,Jy=500,GV=()=>{if(Zo.size>Jy){const e=Math.floor(Jy*.2),t=Array.from(Zo.keys()).slice(0,e);for(const r of t)Zo.delete(r)}};let Sf=null;const s9=()=>typeof window>"u"?Promise.resolve(null):(Sf||(Sf=Nh(()=>import("./diagram-Bk84WZto.js").then(e=>e.z),__vite__mapDeps([0,1])).then(e=>e.default)),Sf),l9=(e,t,r="strict")=>({fontFamily:e.fontFamilyCode,gantt:{useWidth:1920},securityLevel:r,startOnLoad:!1,theme:t||(e.isDarkMode?"dark":"neutral"),themeVariables:t?void 0:{errorBkgColor:e.colorTextDescription,errorTextColor:e.colorTextDescription,fontFamily:e.fontFamily,lineColor:e.colorTextSecondary,mainBkg:e.colorBgContainer,noteBkgColor:e.colorInfoBg,noteTextColor:e.colorInfoText,pie1:e.geekblue,pie2:e.colorWarning,pie3:e.colorSuccess,pie4:e.colorError,primaryBorderColor:e.colorBorder,primaryColor:e.colorBgContainer,primaryTextColor:e.colorText,secondaryBorderColor:e.colorInfoBorder,secondaryColor:e.colorInfoBg,secondaryTextColor:e.colorInfoText,tertiaryBorderColor:e.colorSuccessBorder,tertiaryColor:e.colorSuccessBg,tertiaryTextColor:e.colorSuccessText,textColor:e.colorText}}),UV=(e,{id:t,theme:r,securityLevel:n})=>{const o=m1(),[i,a]=u.useState(""),s=u.useMemo(()=>l9(o,r,n),[o.fontFamilyCode,o.isDarkMode,o.colorTextDescription,o.fontFamily,o.colorTextSecondary,o.colorBgContainer,o.colorInfoBg,o.colorInfoText,o.geekblue,o.colorWarning,o.colorSuccess,o.colorError,o.colorBorder,o.colorInfoBorder,o.colorSuccessBorder,o.colorSuccessBg,o.colorSuccessText,o.colorText,r,n]),l=u.useMemo(()=>{const c=e.length<1e4?e:Il.hashStr(e);return[t,r||(o.isDarkMode?"d":"l"),c].filter(Boolean).join("-")},[e,t,o.isDarkMode,r]);return u.useEffect(()=>{const c=Zo.get(l);if(c){c.then(f=>{a(f)}).catch(()=>{});return}const d=(async()=>{try{const f=await s9();if(!f)return"";if(await f.parse(e)){f.initialize(s);const{svg:p}=await f.render(t,e);return p}else throw new Error("Mermaid 语法无效")}catch(f){return console.error("Mermaid 解析错误:",f),""}})();Zo.set(l,d),GV(),d.then(f=>{Zo.get(l)===d&&a(f)}).catch(()=>{Zo.get(l)===d&&Zo.delete(l)})},[l,e,t,s]),i},c9=u.memo(({children:e,className:t,fallbackClassName:r,ref:n,style:o,theme:i,variant:a})=>{const s=e??"",l=i==="lobe-theme"||!i,c=u.useMemo(()=>{var g;if(!l)return(g=a9.find(y=>y.id===i))==null?void 0:g.background},[l,i]),d=UV(s,{id:Lw(`mermaid-${u.useId()}`),theme:l?void 0:i}),f=!d,[p,m]=u.useState();u.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]),u.useEffect(()=>{if(f||!d)return;let g=d;if(typeof window<"u"&&typeof navigator<"u"&&navigator.userAgent.includes("Firefox")){const b=new DOMParser().parseFromString(d,"image/svg+xml"),v=b.documentElement;if(v&&v.hasAttribute("viewBox")){const x=v.getAttribute("viewBox").split(" ");Array.isArray(x)&&x.length===4&&(v.setAttribute("width",x[2]),v.setAttribute("height",x[3])),g=new XMLSerializer().serializeToString(b)}}const y=new Blob([g],{type:"image/svg+xml"});m(URL.createObjectURL(y))},[f,d]);const h={background:a==="filled"?c:void 0,margin:0,minWidth:300,padding:a==="borderless"?0:16,position:"relative",width:"100%",...o};return p?N.jsx(B1,{alt:"mermaid",className:t,maxHeight:480,minWidth:300,objectFit:"contain",ref:n,src:p,style:h,variant:"borderless",width:"100%"}):N.jsx("div",{className:r,style:o,children:N.jsx("div",{style:{padding:16},children:"Loading..."})})});c9.displayName="StaticMermaid";const XV=(e,{enabled:t=!0,id:r,theme:n})=>{const o=m1(),[i,a]=u.useState(""),s=u.useRef(""),l=u.useRef(e),c=u.useRef(void 0),d=u.useMemo(()=>l9(o,n),[o.fontFamilyCode,o.isDarkMode,o.colorTextDescription,o.fontFamily,o.colorTextSecondary,o.colorBgContainer,o.colorInfoBg,o.colorInfoText,o.geekblue,o.colorWarning,o.colorSuccess,o.colorError,o.colorBorder,o.colorInfoBorder,o.colorSuccessBorder,o.colorSuccessBg,o.colorSuccessText,o.colorText,n]);return u.useEffect(()=>{l.current=e},[e]),u.useEffect(()=>{if(!t){a(""),s.current="";const m=c.current;m&&clearTimeout(m);return}const f=l.current;if(f===s.current&&i)return;const p=c.current;return p&&clearTimeout(p),c.current=setTimeout(async()=>{const m=l.current;if(m===f)try{const h=await s9();if(!h)return;if(await h.parse(m)){h.initialize(d);const{svg:g}=await h.render(r,m);l.current===m&&(a(g),s.current=m)}}catch(h){m===l.current&&console.error("Mermaid 解析错误:",h)}},300),()=>{const m=c.current;m&&clearTimeout(m)}},[t,e,r,d,i]),i},u9=u.memo(({children:e,className:t,fallbackClassName:r,ref:n,style:o,theme:i,variant:a})=>{const s=e??"",l=i==="lobe-theme"||!i,c=u.useMemo(()=>{var g;if(!l)return(g=a9.find(y=>y.id===i))==null?void 0:g.background},[l,i]),d=XV(s,{enabled:!0,id:Lw(`mermaid-${u.useId()}`),theme:l?void 0:i}),f=!d,[p,m]=u.useState();u.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]),u.useEffect(()=>{if(f||!d){m(void 0);return}let g=d;if(typeof window<"u"&&typeof navigator<"u"&&navigator.userAgent.includes("Firefox")){const b=new DOMParser().parseFromString(d,"image/svg+xml"),v=b.documentElement;if(v&&v.hasAttribute("viewBox")){const x=v.getAttribute("viewBox").split(" ");Array.isArray(x)&&x.length===4&&(v.setAttribute("width",x[2]),v.setAttribute("height",x[3])),g=new XMLSerializer().serializeToString(b)}}const y=new Blob([g],{type:"image/svg+xml"});m(URL.createObjectURL(y))},[f,d]);const h={background:a==="filled"?c:void 0,margin:0,minWidth:300,padding:a==="borderless"?0:16,position:"relative",width:"100%",...o};return p?N.jsx(B1,{alt:"mermaid",className:t,maxHeight:480,minWidth:300,objectFit:"contain",ref:n,src:p,style:h,variant:"borderless",width:"100%"}):N.jsx("div",{className:r,style:o,children:N.jsx("div",{style:{padding:16},children:"Rendering..."})})});u9.displayName="StreamMermaid";const YV=tc`
|
|
2448
2448
|
0% {
|
|
2449
2449
|
opacity: 0;
|
|
2450
2450
|
}
|
package/dist/web/index.html
CHANGED
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
opacity: 0.65;
|
|
28
28
|
}
|
|
29
29
|
</style>
|
|
30
|
-
<script type="module" crossorigin src="/assets/index-
|
|
30
|
+
<script type="module" crossorigin src="/assets/index-CwzlBu2W.js"></script>
|
|
31
31
|
<link rel="modulepreload" crossorigin href="/assets/react-vendor-BuABiQkA.js">
|
|
32
|
-
<link rel="modulepreload" crossorigin href="/assets/motion-
|
|
33
|
-
<link rel="modulepreload" crossorigin href="/assets/ui-
|
|
34
|
-
<link rel="modulepreload" crossorigin href="/assets/diagram-
|
|
35
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
32
|
+
<link rel="modulepreload" crossorigin href="/assets/motion-DFABYlwt.js">
|
|
33
|
+
<link rel="modulepreload" crossorigin href="/assets/ui-CvA4pq3d.js">
|
|
34
|
+
<link rel="modulepreload" crossorigin href="/assets/diagram-Bk84WZto.js">
|
|
35
|
+
<link rel="stylesheet" crossorigin href="/assets/index-uw_8eaPv.css">
|
|
36
36
|
</head>
|
|
37
37
|
<body>
|
|
38
38
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgbg/mdocs",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "A Markdown knowledge base for small teams",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"express": "^4.21.0",
|
|
57
57
|
"lexical": "0.42.0",
|
|
58
58
|
"lucide-react": "^0.562.0",
|
|
59
|
-
"mermaid": "11.
|
|
59
|
+
"mermaid": "^11.16.1",
|
|
60
60
|
"motion": "^12.0.0",
|
|
61
61
|
"multer": "^2.1.1",
|
|
62
62
|
"node-diff3": "^3.2.0",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diagram-DtU2xxz3.js","assets/ui-RahDNce8.js","assets/react-vendor-BuABiQkA.js","assets/motion-BgtuAqBE.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as l,j as e,_ as tt,b as st}from"./react-vendor-BuABiQkA.js";import{c as X,N as Pe,ag as te,ah as Ee,ai as nt,i as $e,aj as at,ak as rt,al as it,am as ot,an as lt,ao as Le,ap as ct,aq as dt,ar as ut}from"./index-DI_31upJ.js";import{H as mt,A as ze,S as pt,a as ft}from"./AgentSkillFormCard-dsAy12lL.js";import{C as ht}from"./code-xml-CZsyEkCa.js";import{C as Be,a as He}from"./copy-BUUKT-QO.js";import{P as gt}from"./plus-BkiPFt2u.js";import{ae as xt,af as yt}from"./ui-RahDNce8.js";import"./diagram-DtU2xxz3.js";import"./motion-BgtuAqBE.js";/**
|
|
3
|
-
* @license lucide-react v0.562.0 - ISC
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the ISC license.
|
|
6
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const jt=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],kt=X("file-text",jt);/**
|
|
8
|
-
* @license lucide-react v0.562.0 - ISC
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the ISC license.
|
|
11
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const Nt=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],bt=X("maximize-2",Nt);/**
|
|
13
|
-
* @license lucide-react v0.562.0 - ISC
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the ISC license.
|
|
16
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const vt=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],wt=X("minimize-2",vt);/**
|
|
18
|
-
* @license lucide-react v0.562.0 - ISC
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the ISC license.
|
|
21
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const Ct=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],St=X("zoom-in",Ct);/**
|
|
23
|
-
* @license lucide-react v0.562.0 - ISC
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the ISC license.
|
|
26
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/const It=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],_t=X("zoom-out",It);function ge(s){var n;return s==null||typeof s=="boolean"?"":typeof s=="string"||typeof s=="number"?String(s):Array.isArray(s)?s.map(ge).join(""):typeof s=="object"&&"props"in s?ge((n=s.props)==null?void 0:n.children):""}function At(s){return s?/\blanguage-mermaid\b|\bmermaid\b/i.test(s):!1}function Mt(s){const n=Array.isArray(s)?s:[s];for(const r of n){if(r==null||typeof r!="object"||!("props"in r))continue;const c=r.props;if(!(!c||!At(c.className)))return ge(c.children).replace(/\n$/,"")}return null}const Rt=.4,Et=4,ee=.2;let fe=null;function $t(){return fe||(fe=tt(()=>import("./diagram-DtU2xxz3.js").then(s=>s.A),__vite__mapDeps([0,1,2,3])).then(s=>{const n=s.default;return n.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral",fontFamily:"ui-sans-serif, system-ui, sans-serif"}),n})),fe}function he(s){return Math.min(Et,Math.max(Rt,s))}function zt(s){const[n,r]=l.useState(1),[c,k]=l.useState({x:0,y:0}),g=l.useRef(null),[_,N]=l.useState(!1);l.useEffect(()=>{const u=C=>{C.key==="Escape"&&s.onClose()};window.addEventListener("keydown",u);const f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",u),document.body.style.overflow=f}},[s.onClose]);function I(u){u.button===0&&(u.currentTarget.setPointerCapture(u.pointerId),g.current={pointerId:u.pointerId,startX:u.clientX,startY:u.clientY,originX:c.x,originY:c.y},N(!0))}function A(u){const f=g.current;!f||f.pointerId!==u.pointerId||k({x:f.originX+(u.clientX-f.startX),y:f.originY+(u.clientY-f.startY)})}function M(u){const f=g.current;if(!(!f||f.pointerId!==u.pointerId)){g.current=null,N(!1);try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}}}function v(u){u.preventDefault();const f=u.deltaY>0?-ee:ee;r(C=>he(Number((C+f).toFixed(2))))}return st.createPortal(e.jsxs("div",{className:"mdocs-agent-mermaid-float",role:"dialog","aria-modal":"true","aria-label":"Mermaid 图预览",children:[e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-backdrop","aria-label":"关闭预览",onClick:s.onClose}),e.jsxs("div",{className:"mdocs-agent-mermaid-float-chrome",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-float-tools",children:[e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>r(u=>he(Number((u-ee).toFixed(2)))),title:"缩小","aria-label":"缩小",children:e.jsx(_t,{size:16,"aria-hidden":!0})}),e.jsxs("span",{className:"mdocs-agent-mermaid-float-scale",children:[Math.round(n*100),"%"]}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>r(u=>he(Number((u+ee).toFixed(2)))),title:"放大","aria-label":"放大",children:e.jsx(St,{size:16,"aria-hidden":!0})}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:()=>{r(1),k({x:0,y:0})},title:"重置",children:"重置"}),e.jsx("button",{type:"button",className:"mdocs-agent-mermaid-float-btn",onClick:s.onClose,title:"关闭","aria-label":"关闭",children:e.jsx(te,{size:16,"aria-hidden":!0})})]}),e.jsx("div",{className:_?"mdocs-agent-mermaid-float-stage is-dragging":"mdocs-agent-mermaid-float-stage",onPointerDown:I,onPointerMove:A,onPointerUp:M,onPointerCancel:M,onWheel:v,children:e.jsx("div",{className:"mdocs-agent-mermaid-float-canvas",style:{transform:`translate(calc(-50% + ${c.x}px), calc(-50% + ${c.y}px)) scale(${n})`},dangerouslySetInnerHTML:{__html:s.svg}})}),e.jsx("p",{className:"mdocs-agent-mermaid-float-hint",children:"拖动平移 · 滚轮缩放 · Esc 关闭"})]})]}),document.body)}function Tt(s){const n=l.useId().replace(/:/g,""),[r,c]=l.useState("diagram"),[k,g]=l.useState(null),[_,N]=l.useState(null),[I,A]=l.useState(!1),[M,v]=l.useState(!1),u=l.useRef(null),f=l.useRef(0),C=s.source.trim();l.useEffect(()=>()=>{u.current!=null&&window.clearTimeout(u.current)},[]),l.useEffect(()=>{if(r!=="diagram")return;if(!C){g(null),N(null);return}const x=++f.current,E=window.setTimeout(()=>{(async()=>{try{const $=await $t();if(x!==f.current)return;const O=`mdocs-agent-mmd-${n}-${x}`,{svg:T}=await $.render(O,C);if(x!==f.current)return;g(T),N(null)}catch($){if(x!==f.current)return;g(null),N($ instanceof Error?$.message:"Mermaid 渲染失败")}})()},200);return()=>{window.clearTimeout(E),f.current+=1}},[r,C,n]);async function H(){if(C)try{await navigator.clipboard.writeText(C),A(!0),u.current!=null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>A(!1),1500)}catch{}}return e.jsxs("div",{className:"mdocs-agent-mermaid",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-toolbar",children:[e.jsxs("div",{className:"mdocs-agent-mermaid-toggle",role:"group","aria-label":"Mermaid 显示模式",children:[e.jsxs("button",{type:"button",className:r==="diagram"?"mdocs-agent-mermaid-toggle-btn is-active":"mdocs-agent-mermaid-toggle-btn",onClick:()=>c("diagram"),"aria-pressed":r==="diagram",title:"图谱",children:[e.jsx(Pe,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"图谱"})]}),e.jsxs("button",{type:"button",className:r==="code"?"mdocs-agent-mermaid-toggle-btn is-active":"mdocs-agent-mermaid-toggle-btn",onClick:()=>c("code"),"aria-pressed":r==="code",title:"代码",children:[e.jsx(ht,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"代码"})]})]}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy mdocs-agent-mermaid-copy",onClick:()=>void H(),"aria-label":I?"已复制":"复制代码",title:I?"已复制":"复制",children:I?e.jsx(Be,{size:14,"aria-hidden":!0}):e.jsx(He,{size:14,"aria-hidden":!0})})]}),r==="diagram"?e.jsx("div",{className:"mdocs-agent-mermaid-diagram",children:_?e.jsxs("div",{className:"mdocs-agent-mermaid-error",role:"alert",children:[e.jsx("p",{children:"无法渲染该图,可切换到代码查看源码。"}),e.jsx("pre",{children:_})]}):k?e.jsx("div",{className:"mdocs-agent-mermaid-svg mdocs-agent-mermaid-svg-hit",role:"button",tabIndex:0,onClick:()=>v(!0),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),v(!0))},title:"点击放大预览","aria-label":"点击放大预览 Mermaid 图",children:e.jsx("span",{className:"mdocs-agent-mermaid-svg-inner",dangerouslySetInnerHTML:{__html:k}})}):e.jsx("div",{className:"mdocs-agent-mermaid-loading",children:"渲染中…"})}):e.jsx("div",{className:"mdocs-agent-panel-md-pre-wrap mdocs-agent-mermaid-code",children:e.jsx("pre",{children:s.codeChildren??e.jsx("code",{className:"language-mermaid",children:C})})}),M&&k?e.jsx(zt,{svg:k,onClose:()=>v(!1)}):null]})}function xe(s){var n;return s==null||typeof s=="boolean"?"":typeof s=="string"||typeof s=="number"?String(s):Array.isArray(s)?s.map(xe).join(""):typeof s=="object"&&"props"in s?xe((n=s.props)==null?void 0:n.children):""}function qt(s){const[n,r]=l.useState(!1),c=l.useRef(null),k=xe(s.children).replace(/\n$/,"");l.useEffect(()=>()=>{c.current!=null&&window.clearTimeout(c.current)},[]);async function g(){if(k)try{await navigator.clipboard.writeText(k),r(!0),c.current!=null&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>r(!1),1500)}catch{}}return e.jsxs("div",{className:"mdocs-agent-panel-md-pre-wrap",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-md-copy",onClick:()=>void g(),"aria-label":n?"已复制":"复制代码",title:n?"已复制":"复制",children:n?e.jsx(Be,{size:14,"aria-hidden":!0}):e.jsx(He,{size:14,"aria-hidden":!0})}),e.jsx("pre",{children:s.children})]})}function Dt(s){const n=Mt(s.children);return n!=null?e.jsx(Tt,{source:n,codeChildren:s.children}):e.jsx(qt,{children:s.children})}function Te(s){return e.jsx("div",{className:"mdocs-agent-panel-md",children:e.jsx(xt,{remarkPlugins:[yt],components:{pre:({children:n})=>e.jsx(Dt,{children:n})},children:s.children})})}const Ft=["如何发布文档?","草稿是什么?","如何创建域?"];function qe(s,n){return n.map((r,c)=>{const k=r.skillNames&&r.skillNames.length>0?r.skillNames:r.skillIds&&r.skillIds.length>0?r.skillIds:void 0;return{id:`h-${s}-${c}-${r.role}`,role:r.role,content:r.content,skillNames:k}})}function Pt(s,n){const r=s.slice(),c=r[r.length-1];return(c==null?void 0:c.type)==="text"?r[r.length-1]={type:"text",text:c.text+n}:r.push({type:"text",text:n}),r}function Lt(s,n){const r=s.slice(),c=r[r.length-1];return(c==null?void 0:c.type)==="thinking"?r[r.length-1]={type:"thinking",text:c.text+n}:r.push({type:"thinking",text:n}),r}function De(s){return s!=null&&s.length?s.filter(n=>n.type==="text").map(n=>n.text).join(""):""}function Bt(s){return!!(s!=null&&s.some(n=>n.type==="thinking"&&n.text.length>0))}function Ht(s){const n=new Date(s);if(Number.isNaN(n.getTime()))return"";const r=new Date;return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})}function Fe(s){if(s>=1e3){const n=s/1e3;return`${n>=10?Math.round(n):Math.round(n*10)/10}K`}return String(s)}function Ot(s){const{block:n,onResolved:r}=s,[c,k]=l.useState(""),[g,_]=l.useState(!1),[N,I]=l.useState(1),A=l.useRef(!1),M=l.useRef(r);M.current=r;const v=n.status==="open",u=l.useRef(0);l.useEffect(()=>{if(!v)return;A.current=!1;const x=new Date(n.expiresAt).getTime(),E=Date.now(),$=Math.max(x-E,1);u.current=$,I(1);const O=()=>{const z=x-Date.now(),m=Math.max(0,Math.min(1,z/$));I(m),z<=0&&!A.current&&(A.current=!0,dt(n.requestId).catch(()=>{}).finally(()=>{M.current(n.requestId,"","expired")}))};O();const T=window.setInterval(O,100);return()=>window.clearInterval(T)},[v,n.expiresAt,n.requestId]);async function f(x){const E=x.trim();if(!(!E||g||!v)){_(!0);try{await ut(n.requestId,E),r(n.requestId,E,"selected")}catch{r(n.requestId,E,"failed")}finally{_(!1)}}}async function C(){if(!(g||!v)){_(!0),A.current=!0;try{await Le(n.requestId),r(n.requestId,"","cancelled")}catch{r(n.requestId,"","failed")}finally{_(!1)}}}const H=Math.max(0,Math.ceil(N*u.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card"+(v?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:n.title}),v?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[H,"s"]}):null]}),v?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(N*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${N})`}})}):null,n.status==="selected"&&n.selected?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已选择:",n.selected]}):null,n.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,n.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,选择已失效"}):null,n.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,v?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-agent-choice-options",children:n.options.map(x=>e.jsx("button",{type:"button",className:"mdocs-agent-choice-option",disabled:g,onClick:()=>void f(x),children:x},x))}),e.jsxs("div",{className:"mdocs-agent-choice-custom",children:[e.jsx("input",{value:c,disabled:g,placeholder:"或输入自己的内容…",onChange:x=>k(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),f(c))}}),e.jsx("button",{type:"button",disabled:g||!c.trim(),onClick:()=>void f(c),children:"提交"})]}),e.jsx("div",{className:"mdocs-agent-choice-footer",children:e.jsx("button",{type:"button",className:"mdocs-agent-choice-cancel",disabled:g,onClick:()=>void C(),children:"取消"})})]}):null]})}function Wt(s){const k=2*Math.PI*8.75,g=Math.min(100,Math.max(0,s.percent)),_=k*(1-g/100),N=g>=90?"danger":g>=70?"warn":"ok",I=`上下文 ${g}% · 已用 ${Fe(s.used)} / ${Fe(s.limit)} tokens`;return e.jsx("span",{className:"mdocs-agent-panel-context mdocs-agent-panel-context-"+N,"data-tooltip":I,"aria-label":I,role:"img",tabIndex:0,children:e.jsxs("svg",{width:20,height:20,viewBox:"0 0 20 20","aria-hidden":!0,children:[e.jsx("circle",{className:"mdocs-agent-panel-context-track",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5}),e.jsx("circle",{className:"mdocs-agent-panel-context-value",cx:20/2,cy:20/2,r:8.75,fill:"none",strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:k,strokeDashoffset:_,transform:`rotate(-90 ${20/2} ${20/2})`})]})})}function Kt(s){var n;for(const r of s)if(!(r.role!=="assistant"||!((n=r.blocks)!=null&&n.length))){for(const c of r.blocks)if((c.type==="choice_card"||c.type==="skill_form_card")&&c.status==="open")return!0}return!1}const ts=l.forwardRef(function(n,r){const{open:c,onClose:k,visitorName:g,anchorStyle:_,fullscreen:N,onToggleFullscreen:I,domainId:A,documentId:M,documentTitle:v,documentPath:u,graphFileId:f,graphLabel:C,onOpenDocument:H,onTreeChanged:x,onDocumentOverwritten:E,onOpenCoding:$}=n,O=((g==null?void 0:g.trim().charAt(0))||"我").toUpperCase(),[T,z]=l.useState(!1),[m,U]=l.useState(null),[Oe,Y]=l.useState(null),[F,w]=l.useState([]),[se,G]=l.useState(null),[ye,We]=l.useState([]),[Ke,je]=l.useState(!1),[V,Z]=l.useState(""),[W,ke]=l.useState([]),[Ne,ne]=l.useState(!1),[b,J]=l.useState(!1),[be,P]=l.useState(null),[Q,ve]=l.useState(null),[ae,B]=l.useState(!1),[L,we]=l.useState(!1),Xe=l.useRef(null),re=l.useRef(null),q=l.useRef(null),Ce=l.useRef(0),K=l.useRef(!0),ie=l.useRef(F);ie.current=F;const Se=!!(M!=null&&M.trim())&&!Ne,Ue=(v==null?void 0:v.trim())||"当前文档",Ie=(u==null?void 0:u.trim())||"",oe=!!(f!=null&&f.trim())&&!Ne,Ye=(C==null?void 0:C.trim())||"当前图谱";l.useEffect(()=>{ne(!1)},[M,f]);function _e(t){return Ce.current+=1,`${t}-${Ce.current}`}function Ge(t,p=48){return t.scrollHeight-t.scrollTop-t.clientHeight<=p}function D(){const t=re.current;!t||!K.current||(t.scrollTop=t.scrollHeight)}function Ve(){const t=re.current;t&&(K.current=Ge(t))}async function Ze(){je(!0);try{const t=await rt();We(t.sessions),se||G(t.lastOpenedSessionId)}catch{}finally{je(!1)}}async function le(){try{const t=await at();ve(t)}catch{}}async function Ae(){try{const t=await Ee();U(t),Y(null)}catch(t){U(null),Y(t instanceof Error?t.message:String(t))}}l.useEffect(()=>{var p;if(!c){z(!1),(p=q.current)==null||p.abort(),q.current=null,J(!1);return}let t=!1;return(async()=>{try{const i=await Ee();t||(U(i),Y(null))}catch(i){t||(U(null),Y(i instanceof Error?i.message:String(i)))}})(),le(),()=>{t=!0}},[c]),l.useEffect(()=>{if(!c)return;let t=!1;return(async()=>{try{const p=await nt();if(t)return;G(p.sessionId),w(i=>i.length>0?i:qe(p.sessionId,p.messages))}catch{}})(),()=>{t=!0}},[c]),l.useEffect(()=>{!c||!T||Ze()},[c,T]);function ce(){if(!L){if(Kt(ie.current)){B(!0);return}B(!1),k()}}async function Je(){var i;if(L)return;we(!0);const t=ie.current,p=[];for(const S of t)if(!(S.role!=="assistant"||!S.blocks))for(const h of S.blocks)h.type==="choice_card"&&h.status==="open"&&p.push(Le(h.requestId).catch(()=>{})),h.type==="skill_form_card"&&h.status==="open"&&p.push(ct(h.requestId).catch(()=>{}));await Promise.all(p),(i=q.current)==null||i.abort(),w(S=>S.map(h=>h.role!=="assistant"||!h.blocks?h:{...h,blocks:h.blocks.map(y=>y.type==="choice_card"&&y.status==="open"?{...y,status:"cancelled"}:y.type==="skill_form_card"&&y.status==="open"?{...y,status:"cancelled"}:y)})),B(!1),we(!1),k()}const de=l.useRef(ce);de.current=ce,l.useImperativeHandle(r,()=>({requestClose:()=>de.current()}),[]),l.useEffect(()=>{if(!c){B(!1);return}const t=p=>{if(p.key==="Escape"){if(ae){L||B(!1);return}if(T){z(!1);return}de.current()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[c,T,ae,L]);async function ue(t){var y;const p=t.trim();if(!p||b)return;if(!(m!=null&&m.enabled)){P((m==null?void 0:m.reason)==="missing_api_key"?"请先配置 API Key":(m==null?void 0:m.reason)==="skills_missing"?"手册 skills 未就绪,请确认已构建 agent-skills":"助手暂不可用");return}(y=q.current)==null||y.abort();const i=new AbortController;q.current=i;const S={id:_e("u"),role:"user",content:p,skillNames:W.length>0?[...W]:void 0},h=_e("a");K.current=!0,w(R=>[...R,S,{id:h,role:"assistant",content:""}]),Z(""),J(!0),P(null),z(!1),requestAnimationFrame(()=>D());try{let R=!1;await lt(p,{skillNames:W.length>0?W:void 0,references:{domainId:(A==null?void 0:A.trim())||void 0,documentId:!oe&&Se?M.trim():void 0,graphFileId:oe?f.trim():void 0},signal:i.signal,onEvent:o=>{o.type==="text_delta"?(w(j=>j.map(a=>{if(a.id!==h)return a;const d=Pt(a.blocks??[],o.text);return{...a,blocks:d,content:De(d)}})),requestAnimationFrame(()=>D())):o.type==="thinking_delta"?(w(j=>j.map(a=>{if(a.id!==h)return a;const d=Lt(a.blocks??[],o.text);return{...a,blocks:d}})),requestAnimationFrame(()=>D())):o.type==="sources"?(w(j=>j.map(a=>{if(a.id!==h)return a;const d=(a.blocks??[]).slice(),pe=d[d.length-1];return(pe==null?void 0:pe.type)==="sources"?d[d.length-1]={type:"sources",items:o.items}:d.push({type:"sources",items:o.items}),{...a,blocks:d}})),requestAnimationFrame(()=>D())):o.type==="document_table"?(w(j=>j.map(a=>{if(a.id!==h)return a;const d=[...a.blocks??[],{type:"document_table",title:o.title,rows:o.rows}];return{...a,blocks:d}})),requestAnimationFrame(()=>D())):o.type==="document_card"?(w(j=>j.map(a=>{if(a.id!==h)return a;const d=[...a.blocks??[],{type:"document_card",documentId:o.documentId,title:o.title,path:o.path,preview:o.preview}];return{...a,blocks:d}})),requestAnimationFrame(()=>D())):o.type==="tool_notice"?(w(j=>j.map(a=>{if(a.id!==h)return a;const d=[...a.blocks??[],{type:"tool_notice",toolName:o.toolName,text:o.text}];return{...a,blocks:d}})),requestAnimationFrame(()=>D())):o.type==="choice_card"?(w(j=>j.map(a=>{if(a.id!==h)return a;const d=[...a.blocks??[],{type:"choice_card",requestId:o.requestId,title:o.title,options:o.options,expiresAt:o.expiresAt,status:"open"}];return{...a,blocks:d}})),requestAnimationFrame(()=>D())):o.type==="choice_expired"?w(j=>j.map(a=>a.id!==h||!a.blocks?a:{...a,blocks:a.blocks.map(d=>d.type==="choice_card"&&d.requestId===o.requestId&&d.status==="open"?{...d,status:"expired"}:d)})):o.type==="skill_form_card"?(w(j=>j.map(a=>{if(a.id!==h)return a;const d=[...a.blocks??[],{type:"skill_form_card",requestId:o.requestId,mode:o.mode,title:o.title,currentName:o.currentName,initialName:o.initialName,initialDescription:o.initialDescription,initialBody:o.initialBody,expiresAt:o.expiresAt,status:"open"}];return{...a,blocks:d}})),requestAnimationFrame(()=>D())):o.type==="skill_form_expired"?w(j=>j.map(a=>a.id!==h||!a.blocks?a:{...a,blocks:a.blocks.map(d=>d.type==="skill_form_card"&&d.requestId===o.requestId&&d.status==="open"?{...d,status:"expired"}:d)})):o.type==="tree_changed"?x==null||x():o.type==="document_overwritten"?E==null||E({documentId:o.documentId,headCommitId:o.headCommitId}):o.type==="open_coding"?$==null||$({documentId:o.documentId,displayName:o.displayName}):o.type==="context_usage"?ve({percent:o.percent,used:o.used,limit:o.limit}):o.type==="error"&&(R=!0,P(o.message))}}),!i.signal.aborted&&!R&&ke([])}catch(R){if(i.signal.aborted)return;P(R instanceof Error?R.message:String(R))}finally{q.current===i&&(q.current=null),J(!1)}}async function Qe(){var t;if(!b){(t=q.current)==null||t.abort(),P(null),z(!1),J(!1);try{const p=await it();G(p.sessionId),w([]),Z(""),K.current=!0,le()}catch(p){P(p instanceof Error?p.message:String(p))}}}async function et(t){var p;if(!b){if(t===se){z(!1);return}(p=q.current)==null||p.abort(),P(null);try{const i=await ot(t);G(i.sessionId),w(qe(i.sessionId,i.messages)),Z(""),z(!1),K.current=!0,requestAnimationFrame(()=>D()),le()}catch(i){P(i instanceof Error?i.message:String(i))}}}function Me(t){!t||!H||H(t)}if(!c)return null;const me=(m==null?void 0:m.reason)==="missing_api_key",Re=Oe??(m&&!m.enabled&&!me?m.reason==="skills_missing"?"skills 未就绪":"助手暂不可用":null);return e.jsxs("div",{ref:Xe,className:"mdocs-agent-panel"+(N?" mdocs-agent-panel--fullscreen":""),role:"dialog","aria-label":"mdocs 智能助手","aria-modal":N?!0:void 0,style:N?void 0:_,children:[e.jsxs("header",{className:"mdocs-agent-panel-header",children:[e.jsxs("div",{className:"mdocs-agent-panel-title",children:[e.jsx("img",{src:$e,alt:"",className:"mdocs-agent-panel-title-logo"}),e.jsx("span",{children:"mdocs 智能助手"})]}),e.jsxs("div",{className:"mdocs-agent-panel-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"新会话","aria-label":"新会话",disabled:b,onClick:()=>void Qe(),children:e.jsx(gt,{size:16,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn"+(T?" active":""),title:"历史会话","aria-label":"历史会话",onClick:()=>z(t=>!t),children:e.jsx(mt,{size:16,strokeWidth:1.8})}),I?e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:N?"退出全屏":"全屏","aria-label":N?"退出全屏":"全屏",onClick:I,children:N?e.jsx(wt,{size:16,strokeWidth:1.8}):e.jsx(bt,{size:16,strokeWidth:1.8})}):null,e.jsx("button",{type:"button",className:"mdocs-agent-panel-icon-btn",title:"关闭","aria-label":"关闭",onClick:ce,children:e.jsx(te,{size:16,strokeWidth:1.8})})]})]}),T?e.jsxs("div",{className:"mdocs-agent-panel-history",children:[e.jsxs("div",{className:"mdocs-agent-panel-history-head",children:[e.jsx("span",{children:"历史会话"}),e.jsx("button",{type:"button",className:"mdocs-agent-panel-history-back",onClick:()=>z(!1),children:"返回对话"})]}),Ke?e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"加载中…"}):ye.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-history-empty",children:"暂无历史会话"}),e.jsx("p",{className:"mdocs-agent-panel-history-hint",children:"发一条消息后会出现在这里"})]}):e.jsx("ul",{className:"mdocs-agent-panel-history-list",children:ye.map(t=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"mdocs-agent-panel-history-item"+(t.id===se?" active":""),disabled:b,onClick:()=>void et(t.id),children:[e.jsx("span",{className:"mdocs-agent-panel-history-title",children:t.title}),e.jsx("span",{className:"mdocs-agent-panel-history-time",children:Ht(t.updatedAt)})]})},t.id))})]}):e.jsxs("div",{className:"mdocs-agent-panel-body",children:[e.jsx("div",{className:"mdocs-agent-panel-welcome",ref:re,onScroll:Ve,children:F.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mdocs-agent-panel-hello",children:"你好,我是 mdocs 智能助手"}),e.jsx("p",{className:"mdocs-agent-panel-desc",children:"我能答疑、搜文档、整理结构,也能帮你写全文;需要精细改稿请点文档顶栏「帮写」。"}),me?e.jsx(ze,{onConfigured:Ae}):Re?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:Re}):e.jsx("div",{className:"mdocs-agent-panel-chips",children:Ft.map(t=>e.jsx("button",{type:"button",className:"mdocs-agent-panel-chip",onClick:()=>void ue(t),disabled:b||!(m!=null&&m.enabled),children:t},t))})]}):e.jsx("div",{className:"mdocs-agent-panel-messages",children:F.map(t=>{var p;return e.jsxs("div",{className:"mdocs-agent-panel-msg"+(t.role==="user"?" mdocs-agent-panel-msg-user":" mdocs-agent-panel-msg-assistant"),children:[t.role==="assistant"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-ai","aria-hidden":!0,children:e.jsx("img",{src:$e,alt:""})}):null,e.jsxs("div",{className:"mdocs-agent-panel-msg-bubble",children:[t.role==="user"&&t.skillNames&&t.skillNames.length>0?e.jsxs("div",{className:"mdocs-agent-msg-skills",children:["Skill ×",t.skillNames.length]}):null,t.role==="assistant"?t.blocks&&t.blocks.length>0?e.jsxs("div",{className:"mdocs-agent-panel-timeline",children:[t.blocks.map((i,S)=>{var h;return i.type==="thinking"?i.text?e.jsxs("details",{className:"mdocs-agent-panel-think-fold",open:b&&t.id===((h=F[F.length-1])==null?void 0:h.id),children:[e.jsx("summary",{children:"思考中"}),e.jsx("pre",{className:"mdocs-agent-panel-think-body",children:i.text})]},`${t.id}-th-${S}`):null:i.type==="text"?i.text?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Te,{children:i.text})},`${t.id}-t-${S}`):null:i.type==="sources"?i.items.length===0?null:e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:["已阅读 ",i.items.length," 个页面"]}),e.jsx("ol",{className:"mdocs-agent-panel-sources-list",children:i.items.map(y=>e.jsx("li",{children:e.jsx("a",{href:y.url,target:"_blank",rel:"noreferrer",children:y.name})},y.id))})]})},`${t.id}-s-${S}`):i.type==="tool_notice"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx("p",{className:"mdocs-agent-panel-tool-notice",children:i.text})},`${t.id}-n-${S}`):i.type==="choice_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(Ot,{block:i,onResolved:(y,R,o)=>{w(j=>j.map(a=>a.id!==t.id||!a.blocks?a:{...a,blocks:a.blocks.map(d=>d.type==="choice_card"&&d.requestId===y?{...d,status:o,selected:o==="selected"?R:d.selected}:d)}))}})},`${t.id}-ch-${S}`):i.type==="skill_form_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsx(pt,{block:i,onResolved:(y,R,o)=>{w(j=>j.map(a=>a.id!==t.id||!a.blocks?a:{...a,blocks:a.blocks.map(d=>d.type==="skill_form_card"&&d.requestId===y?{...d,status:R,submittedName:R==="submitted"?o:d.submittedName}:d)}))}})},`${t.id}-sf-${S}`):i.type==="document_card"?e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[e.jsxs("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:y=>{y.preventDefault(),y.stopPropagation(),Me(i.documentId)},children:["《",i.title,"》"]}),e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:"文档预览"})]}),e.jsxs("div",{className:"mdocs-agent-panel-doc-card-body",children:[i.path?e.jsx("p",{className:"mdocs-agent-panel-doc-card-path",children:i.path}):null,i.preview?e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview",children:i.preview}):e.jsx("p",{className:"mdocs-agent-panel-doc-card-preview muted",children:"(无正文预览)"})]})]})},`${t.id}-c-${S}`):e.jsx("div",{className:"mdocs-agent-panel-block",children:e.jsxs("details",{className:"mdocs-agent-panel-tool-fold",children:[e.jsxs("summary",{children:[i.title,e.jsx("span",{className:"mdocs-agent-panel-tool-fold-hint",children:i.rows.length===0?"无结果":`${i.rows.length} 条`})]}),e.jsx("div",{className:"mdocs-agent-panel-doc-table-wrap",children:i.rows.length===0?e.jsx("p",{className:"mdocs-agent-panel-doc-table-empty",children:"无结果"}):e.jsxs("table",{className:"mdocs-agent-panel-doc-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"文章名字"}),e.jsx("th",{children:"文章内容"})]})}),e.jsx("tbody",{children:i.rows.map(y=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",className:"mdocs-agent-panel-doc-link",onClick:()=>Me(y.documentId),children:y.title})}),e.jsx("td",{children:y.summary||"-"})]},y.documentId))})]})})]})},`${t.id}-d-${S}`)}),b&&t.id===((p=F[F.length-1])==null?void 0:p.id)&&!De(t.blocks)&&!Bt(t.blocks)?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null]}):t.content?e.jsx(Te,{children:t.content}):b?e.jsxs("span",{className:"mdocs-agent-panel-thinking","aria-label":"思考中",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null:t.content]}),t.role==="user"?e.jsx("div",{className:"mdocs-agent-panel-avatar mdocs-agent-panel-avatar-user","aria-hidden":!0,children:O}):null]},t.id)})})}),be?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:be}):null,me&&F.length>0?e.jsx(ze,{onConfigured:Ae}):null,e.jsx(ft,{selectedNames:W,onChange:ke,disabled:b||!(m!=null&&m.enabled)}),e.jsxs("div",{className:"mdocs-agent-panel-input-wrap",children:[oe?e.jsxs("div",{className:"mdocs-agent-doc-ref mdocs-agent-graph-ref",children:[e.jsx(Pe,{size:15,strokeWidth:1.75,className:"mdocs-agent-doc-ref-icon","aria-hidden":!0}),e.jsxs("div",{className:"mdocs-agent-doc-ref-text",children:[e.jsx("span",{className:"mdocs-agent-doc-ref-title",children:Ye}),e.jsx("span",{className:"mdocs-agent-doc-ref-path",children:"图谱(只读)"})]}),e.jsx("button",{type:"button",className:"mdocs-agent-doc-ref-unlink",title:"取消引用","aria-label":"取消引用当前图谱",disabled:b,onClick:()=>ne(!0),children:e.jsx(te,{size:14,strokeWidth:2,"aria-hidden":!0})})]}):Se?e.jsxs("div",{className:"mdocs-agent-doc-ref",children:[e.jsx(kt,{size:15,strokeWidth:1.75,className:"mdocs-agent-doc-ref-icon","aria-hidden":!0}),e.jsxs("div",{className:"mdocs-agent-doc-ref-text",children:[e.jsx("span",{className:"mdocs-agent-doc-ref-title",children:Ue}),Ie?e.jsx("span",{className:"mdocs-agent-doc-ref-path",children:Ie}):null]}),e.jsx("button",{type:"button",className:"mdocs-agent-doc-ref-unlink",title:"取消引用","aria-label":"取消引用当前文档",disabled:b,onClick:()=>ne(!0),children:e.jsx(te,{size:14,strokeWidth:2,"aria-hidden":!0})})]}):null,e.jsxs("div",{className:"mdocs-agent-panel-input-body",children:[e.jsx("textarea",{className:"mdocs-agent-panel-input",rows:2,placeholder:m!=null&&m.enabled?"把你的问题告诉我…":"请先配置 API Key",value:V,disabled:b||!(m!=null&&m.enabled),onChange:t=>Z(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),ue(V))}}),Q?e.jsx(Wt,{percent:Q.percent,used:Q.used,limit:Q.limit}):null,e.jsx("button",{type:"button",className:b?"mdocs-agent-panel-send mdocs-agent-panel-send-stop":"mdocs-agent-panel-send",disabled:b?!1:!(m!=null&&m.enabled)||!V.trim(),onClick:()=>{var t;if(b){(t=q.current)==null||t.abort();return}ue(V)},title:b?"停止":"发送","aria-label":b?"停止":"发送",children:b?"■":"↑"})]})]}),e.jsx("p",{className:"mdocs-agent-panel-footnote",children:"内容由 AI 生成,仅供参考"})]}),ae?e.jsx("div",{className:"mdocs-agent-close-confirm-backdrop",role:"presentation",onClick:()=>{L||B(!1)},children:e.jsxs("div",{className:"mdocs-message-dialog mdocs-agent-close-confirm",role:"dialog","aria-modal":"true","aria-labelledby":"mdocs-agent-close-confirm-title",onClick:t=>t.stopPropagation(),children:[e.jsx("h3",{id:"mdocs-agent-close-confirm-title",className:"mdocs-message-dialog-title",children:"有待处理的倒计时"}),e.jsx("p",{className:"mdocs-message-dialog-body",children:"当前还有选择卡或 Skill 表单在倒计时。强制关闭会取消这些操作并退出助手;也可以继续等待完成后再关。"}),e.jsxs("div",{className:"mdocs-message-dialog-actions mdocs-agent-close-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",disabled:L,onClick:()=>B(!1),children:"继续等待"}),e.jsx("button",{type:"button",disabled:L,onClick:()=>void Je(),children:L?"关闭中…":"强制关闭并退出"})]})]})}):null]})});export{ts as AgentChatPanel};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{c as K,a2 as q,b as L,a0 as R,at as T,ap as B,au as P}from"./index-DI_31upJ.js";import{r as n,j as e}from"./react-vendor-BuABiQkA.js";/**
|
|
2
|
-
* @license lucide-react v0.562.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const F=[["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"}]],H=K("history",F),E=5;function O(o){const s=n.useRef(!0),i=n.useRef(null),[m,v]=n.useState([]),[p,x]=n.useState(!1),[g,b]=n.useState(null);n.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]),n.useEffect(()=>{(async()=>{try{const t=await q();if(!s.current)return;v(t)}catch(t){if(!s.current)return;b(t instanceof Error?t.message:String(t))}})()},[]),n.useEffect(()=>{if(!p)return;function t(f){const r=i.current;!r||r.contains(f.target)||x(!1)}function l(f){f.key==="Escape"&&x(!1)}return document.addEventListener("mousedown",t),document.addEventListener("keydown",l),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("keydown",l)}},[p]);const c=m.filter(t=>o.selectedNames.includes(t.name));function h(t){if(o.disabled)return;const l=new Set(o.selectedNames);if(l.has(t))l.delete(t);else{if(l.size>=E)return;l.add(t)}o.onChange([...l])}return m.length===0&&!g?null:e.jsxs("div",{className:"mdocs-agent-skill-ref",ref:i,children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-bar",children:[e.jsxs("div",{className:"mdocs-agent-skill-ref-anchor",children:[p&&m.length>0?e.jsxs("div",{className:"mdocs-agent-skill-popover",role:"listbox","aria-label":"选择 Skill",children:[e.jsxs("div",{className:"mdocs-agent-skill-popover-hint",children:["选择要引用的 Skill(最多 ",E," 个)"]}),e.jsx("ul",{className:"mdocs-agent-skill-popover-list",children:m.map(t=>{const l=o.selectedNames.includes(t.name),f=!l&&o.selectedNames.length>=E;return e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":l,className:"mdocs-agent-skill-popover-item"+(l?" mdocs-agent-skill-popover-item-on":""),disabled:o.disabled||f,onClick:()=>h(t.name),children:[e.jsx("span",{className:"mdocs-agent-skill-popover-check","aria-hidden":!0,children:l?"✓":""}),e.jsxs("span",{className:"mdocs-agent-skill-popover-text",children:[e.jsx("span",{className:"mdocs-agent-skill-popover-name",children:t.name}),t.description?e.jsx("span",{className:"mdocs-agent-skill-popover-desc",children:t.description}):e.jsx("span",{className:"mdocs-agent-skill-popover-desc mdocs-agent-skill-popover-desc-muted",children:"无简介"})]})]})},t.id)})})]}):null,e.jsxs("button",{type:"button",className:"mdocs-agent-skill-ref-toggle"+(p?" mdocs-agent-skill-ref-toggle-open":""),disabled:o.disabled||m.length===0,onClick:()=>x(t=>!t),"aria-expanded":p,"aria-haspopup":"listbox",title:"引用 Skill",children:["Skill",c.length>0?` · ${c.length}`:""]})]}),c.map(t=>e.jsxs("button",{type:"button",className:"mdocs-agent-skill-chip mdocs-agent-skill-chip-on",disabled:o.disabled,onClick:()=>h(t.name),title:"移除引用",children:[t.name,e.jsx("span",{"aria-hidden":!0,children:" ×"})]},t.name))]}),g?e.jsx("p",{className:"mdocs-agent-panel-status-warn",children:g}):null]})}const _=[{value:"openai-completions",label:"OpenAI 兼容"},{value:"anthropic-messages",label:"Anthropic 兼容"}];function W(o){const{t:s}=L(),[i,m]=n.useState("deepseek"),[v,p]=n.useState(""),[x,g]=n.useState(""),[b,c]=n.useState("openai-completions"),[h,t]=n.useState(""),[l,f]=n.useState(!1),[r,y]=n.useState(!1),[S,u]=n.useState(null),w=n.useRef(!1);function C(a){if(p(a),w.current)return;a.toLowerCase().includes("anthropic")?c("anthropic-messages"):c("openai-completions")}function I(a){w.current=!0,c(a)}async function j(){var N;const a=h.trim();if(!a){u("请输入 API Key");return}y(!0),u(null);try{if(i==="deepseek")await R({kind:"deepseek",modelId:"deepseek-v4-flash",apiKey:a});else{const k=v.trim();if(!k){u("请输入 API 地址");return}const A=x.trim();if(!A){u("请输入 Model ID");return}await R({kind:"custom",baseUrl:k,modelId:A,apiType:b,apiKey:a})}t(""),p(""),g(""),await((N=o.onConfigured)==null?void 0:N.call(o))}catch(k){u(k instanceof Error?k.message:String(k))}finally{y(!1)}}const d=h.trim()&&(i==="deepseek"||v.trim()&&x.trim());return e.jsxs("div",{className:"mdocs-agent-apikey-inline",children:[e.jsx("p",{className:"mdocs-agent-apikey-inline-lead",children:"配置 AI 供应商后即可使用(仅本人可见,不会分享给其他访客)"}),e.jsxs("div",{className:"mdocs-agent-kind-tabs mdocs-agent-apikey-inline-tabs",role:"tablist","aria-label":"配置方式",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":i==="deepseek",className:i==="deepseek"?"active":"",onClick:()=>m("deepseek"),disabled:r,children:"Deepseek"}),e.jsx("button",{type:"button",role:"tab","aria-selected":i==="custom",className:i==="custom"?"active":"",onClick:()=>m("custom"),disabled:r,children:"自定义"})]}),i==="custom"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"mdocs-agent-field mdocs-agent-apikey-inline-field",children:[e.jsx("span",{children:"API 地址"}),e.jsx("input",{type:"url",value:v,onChange:a=>C(a.target.value),placeholder:"https://api.example.com/v1",className:"mdocs-agent-mono",disabled:r,onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),j())}})]}),e.jsxs("label",{className:"mdocs-agent-field mdocs-agent-apikey-inline-field",children:[e.jsx("span",{children:"API 协议"}),e.jsx("div",{className:"mdocs-agent-apikey-inline-protocol",children:_.map(a=>e.jsx("button",{type:"button",className:b===a.value?"active":"",onClick:()=>I(a.value),disabled:r,children:a.label},a.value))})]}),e.jsxs("label",{className:"mdocs-agent-field mdocs-agent-apikey-inline-field",children:[e.jsx("span",{children:"Model ID"}),e.jsx("input",{type:"text",value:x,onChange:a=>g(a.target.value),placeholder:"模型名称,如 gpt-4o / claude-3-5-sonnet",className:"mdocs-agent-mono",disabled:r,onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),j())}})]})]}):null,e.jsxs("div",{className:"mdocs-agent-config-apikey mdocs-agent-apikey-inline-field",children:[e.jsx("input",{type:l?"text":"password",value:h,onChange:a=>t(a.target.value),placeholder:s("agentConfigApiKeyPlaceholder"),autoComplete:"off",disabled:r,onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),j())}}),e.jsx("button",{type:"button",className:"mdocs-agent-config-eye","aria-label":s(l?"agentConfigHideKey":"agentConfigShowKey"),onClick:()=>f(a=>!a),disabled:r,children:l?e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":!0,children:[e.jsx("path",{d:"M3 3l18 18"}),e.jsx("path",{d:"M10.6 10.6a2 2 0 002.8 2.8"}),e.jsx("path",{d:"M9.9 5.1A10.5 0 0121 12c-.6 1.1-1.4 2.1-2.4 2.9"}),e.jsx("path",{d:"M6.1 6.1C4.5 7.4 3.2 9.1 2.5 12c1.5 3.5 5 7 9.5 7 1.4 0 2.7-.3 3.9-.8"})]}):e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":!0,children:[e.jsx("path",{d:"M2.5 12C4 8.5 7.5 5 12 5s8 3.5 9.5 7c-1.5 3.5-5 7-9.5 7s-8-3.5-9.5-7z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]}),S?e.jsx("p",{className:"mdocs-agent-apikey-inline-error",children:S}):null,e.jsx("button",{type:"button",className:"mdocs-agent-apikey-inline-save",onClick:()=>void j(),disabled:r||!d,children:r?s("saving"):"保存并启用"})]})}const U=/^[A-Za-z0-9_]+$/;function X(o){const{block:s,onResolved:i}=o,[m,v]=n.useState(s.initialName),[p,x]=n.useState(s.initialDescription),[g,b]=n.useState(s.initialBody),[c,h]=n.useState(!1),[t,l]=n.useState(null),[f,r]=n.useState(1),y=n.useRef(!1),S=n.useRef(i);S.current=i;const u=s.status==="open",w=n.useRef(0);n.useEffect(()=>{if(!u)return;y.current=!1;const d=new Date(s.expiresAt).getTime(),a=Date.now(),N=Math.max(d-a,1);w.current=N,r(1);const k=()=>{const M=d-Date.now(),D=Math.max(0,Math.min(1,M/N));r(D),M<=0&&!y.current&&(y.current=!0,T(s.requestId).catch(()=>{}).finally(()=>{S.current(s.requestId,"expired")}))};k();const A=window.setInterval(k,100);return()=>window.clearInterval(A)},[u,s.expiresAt,s.requestId]);async function C(){if(c||!u)return;const d=m.trim();if(!d){l("名称不能为空");return}if(!U.test(d)){l("名称仅允许英文、数字、下划线");return}if(!g.trim()){l("正文不能为空");return}h(!0),l(null);try{await P(s.requestId,{name:d,description:p.trim(),body:g}),i(s.requestId,"submitted",d)}catch{i(s.requestId,"failed")}finally{h(!1)}}async function I(){if(!(c||!u)){h(!0),l(null),y.current=!0;try{await B(s.requestId),i(s.requestId,"cancelled")}catch{i(s.requestId,"failed")}finally{h(!1)}}}const j=Math.max(0,Math.ceil(f*w.current/1e3));return e.jsxs("div",{className:"mdocs-agent-choice-card mdocs-agent-skill-form-card"+(u?"":" mdocs-agent-choice-card-done"),children:[e.jsxs("div",{className:"mdocs-agent-choice-head",children:[e.jsx("p",{className:"mdocs-agent-choice-title",children:s.title}),u?e.jsxs("span",{className:"mdocs-agent-choice-timer","aria-live":"polite",children:[j,"s"]}):null]}),u?e.jsx("div",{className:"mdocs-agent-choice-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(f*100),children:e.jsx("div",{className:"mdocs-agent-choice-progress-bar",style:{transform:`scaleX(${f})`}})}):null,s.status==="submitted"?e.jsxs("p",{className:"mdocs-agent-choice-result",children:["已提交",s.submittedName?`:${s.submittedName}`:""]}):null,s.status==="cancelled"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已取消"}):null,s.status==="expired"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"已超时,表单已失效"}):null,s.status==="failed"?e.jsx("p",{className:"mdocs-agent-choice-result muted",children:"提交失败或已失效"}):null,u?e.jsxs("div",{className:"mdocs-agent-skill-form-fields",children:[e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"名称(英文数字下划线)"}),e.jsx("input",{type:"text",value:m,onChange:d=>v(d.target.value),maxLength:64,disabled:c,autoComplete:"off",spellCheck:!1})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"简介"}),e.jsx("input",{type:"text",value:p,onChange:d=>x(d.target.value),maxLength:200,disabled:c})]}),e.jsxs("label",{className:"mdocs-agent-skill-form-field",children:[e.jsx("span",{children:"正文"}),e.jsx("textarea",{value:g,onChange:d=>b(d.target.value),rows:8,disabled:c})]}),t?e.jsx("p",{className:"mdocs-agent-skill-form-error",children:t}):null,e.jsxs("div",{className:"mdocs-agent-skill-form-actions",children:[e.jsx("button",{type:"button",className:"mdocs-agent-skill-form-cancel",disabled:c,onClick:()=>void I(),children:"取消"}),e.jsx("button",{type:"button",disabled:c,onClick:()=>void C(),children:c?"提交中…":s.mode==="create"?"创建":"保存"})]})]}):null]})}export{W as A,H,X as S,O as a};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import{r as b,j as o}from"./react-vendor-BuABiQkA.js";import{b as V,av as _,aw as J,ax as Q,ay as X}from"./index-DI_31upJ.js";import{E as Y,B as Z}from"./react--aHzEjEz.js";import"./ui-RahDNce8.js";import"./motion-BgtuAqBE.js";import"./diagram-DtU2xxz3.js";import"./editor-CL03se2B.js";import"./plus-BkiPFt2u.js";import"./copy-BUUKT-QO.js";function B({lexicalJson:e,onMarkdown:n,onError:s}){const[u,l]=b.useState(null),i=b.useRef(!1);return b.useEffect(()=>{i.current=!1},[e]),b.useEffect(()=>{if(!(!u||i.current))try{u.setDocument("json",e);const c=u.getDocument("markdown");typeof c=="string"&&(i.current=!0,n(c))}catch{s==null||s()}},[u,e,n,s]),o.jsx("div",{className:"mdocs-lexical-md-bridge","aria-hidden":!0,children:o.jsx(Y,{content:e,type:"json",editable:!1,onInit:l,plugins:[Z]})})}function ee(e){const{t:n}=V(),[s,u]=b.useState(0),l=e.segments.filter(t=>t.kind==="conflict"),i=e.unresolvedCount>0;b.useEffect(()=>{if(l.length===0){u(0);return}u(t=>Math.min(t,l.length-1))},[l.length]);function c(t){l.length!==0&&u(d=>{var f;const a=(d+t+l.length)%l.length;return(f=document.getElementById(`mdocs-merge-hunk-${a}`))==null||f.scrollIntoView({block:"center",behavior:"smooth"}),a})}let r=-1;return o.jsxs("div",{className:"mdocs-merge-inline-pane",children:[o.jsxs("div",{className:"mdocs-merge-inline-toolbar",children:[o.jsx("span",{className:"mdocs-merge-inline-hint",children:i?n("mergeReviewHint"):l.length===0?n("mergeNoConflicts"):n("mergeEditAfterResolve")}),l.length>0?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:e.onUseAllMine,children:n("mergeUseAllMine")}),o.jsx("button",{type:"button",onClick:e.onUseAllTheirs,children:n("mergeUseAllTheirs")})]}):null]}),i?o.jsxs("div",{className:"mdocs-merge-inline",role:"document",children:[e.segments.map((t,d)=>{if(t.kind==="unchanged")return o.jsx("pre",{className:"mdocs-merge-inline-same",children:t.lines.map((x,g)=>o.jsxs("div",{className:"mdocs-ai-write-line ctx",children:[o.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),o.jsx("span",{className:"mdocs-ai-write-code",children:x||" "})]},g))},`u-${d}`);r+=1;const a=r,f=t.resolution!=="unresolved",m=a===s;return o.jsxs("div",{id:`mdocs-merge-hunk-${a}`,className:"mdocs-merge-inline-hunk"+(m?" is-active":"")+(f?" is-resolved":""),onClick:()=>u(a),children:[f?o.jsx("div",{className:"mdocs-merge-hunk-resolved-tag",children:t.resolution==="remote"?n("mergeReceive"):n("mergeReject")}):o.jsxs("div",{className:"mdocs-merge-hunk-actions",children:[o.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:x=>{x.stopPropagation(),e.onReject(t.id)},children:n("mergeReject")}),o.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:x=>{x.stopPropagation(),e.onReceive(t.id)},children:n("mergeReceive")})]}),o.jsxs("pre",{className:"mdocs-ai-write-hunk-pre",children:[t.localLines.map((x,g)=>o.jsxs("div",{className:"mdocs-ai-write-line del",children:[o.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),o.jsx("span",{className:"mdocs-ai-write-code",children:x||" "})]},`l${g}`)),t.remoteLines.map((x,g)=>o.jsxs("div",{className:"mdocs-ai-write-line add",children:[o.jsx("span",{className:"mdocs-ai-write-rail","aria-hidden":!0}),o.jsx("span",{className:"mdocs-ai-write-code",children:x||" "})]},`r${g}`))]})]},t.id)}),l.length>0?o.jsxs("div",{className:"mdocs-ai-write-float-nav",role:"toolbar","aria-label":"冲突导航",children:[o.jsx("button",{type:"button","aria-label":"上一段",onClick:()=>c(-1),children:"↑"}),o.jsxs("span",{children:[s+1," / ",l.length]}),o.jsx("button",{type:"button","aria-label":"下一段",onClick:()=>c(1),children:"↓"}),l[s]&&l[s].resolution==="unresolved"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-reject",onClick:()=>e.onReject(l[s].id),children:n("mergeReject")}),o.jsx("button",{type:"button",className:"mdocs-ai-write-hunk-accept",onClick:()=>e.onReceive(l[s].id),children:n("mergeReceive")})]}):null]}):null]}):o.jsx("textarea",{className:"mdocs-merge-inline-editor",value:e.editableMarkdown,onChange:t=>e.onEditableChange(t.target.value),spellCheck:!1})]})}function te(e,n){let s={};for(let i=0;i<n.length;i++){const c=n[i];s[c]?s[c].push(i):s[c]=[i]}let l=[{buffer1index:-1,buffer2index:-1,chain:null}];for(let i=0;i<e.length;i++){const c=e[i],r=s[c]||[];let t=0,d=l[0];for(let a=0;a<r.length;a++){const f=r[a];let m;for(m=t;m<l.length&&!(l[m].buffer2index<f&&(m===l.length-1||l[m+1].buffer2index>f));m++);if(m<l.length){const x={buffer1index:i,buffer2index:f,chain:l[m]};if(t===l.length?l.push(d):l[t]=d,t=m+1,d=x,t===l.length)break}}l[t]=d}return l[l.length-1]}function q(e,n){const s=te(e,n);let u=[],l=e.length,i=n.length;for(let c=s;c!==null;c=c.chain){const r=l-c.buffer1index-1,t=i-c.buffer2index-1;l=c.buffer1index,i=c.buffer2index,(r||t)&&u.push({buffer1:[l+1,r],buffer1Content:e.slice(l+1,l+1+r),buffer2:[i+1,t],buffer2Content:n.slice(i+1,i+1+t)})}return u.reverse(),u}function ne(e,n,s){let u=[];function l(t,d){u.push({ab:d,oStart:t.buffer1[0],oLength:t.buffer1[1],abStart:t.buffer2[0],abLength:t.buffer2[1]})}q(n,e).forEach(t=>l(t,"a")),q(n,s).forEach(t=>l(t,"b")),u.sort((t,d)=>t.oStart-d.oStart);let i=[],c=0;function r(t){t>c&&(i.push({stable:!0,buffer:"o",bufferStart:c,bufferLength:t-c,bufferContent:n.slice(c,t)}),c=t)}for(;u.length;){let t=u.shift(),d=t.oStart,a=t.oStart+t.oLength,f=[t];for(r(d);u.length;){const m=u[0],x=m.oStart;if(x>a)break;a=Math.max(a,x+m.oLength),f.push(u.shift())}if(f.length===1){if(t.abLength>0){const m=t.ab==="a"?e:s;i.push({stable:!0,buffer:t.ab,bufferStart:t.abStart,bufferLength:t.abLength,bufferContent:m.slice(t.abStart,t.abStart+t.abLength)})}}else{let m={a:[e.length,-1,n.length,-1],b:[s.length,-1,n.length,-1]};for(;f.length;){t=f.shift();const v=t.oStart,p=v+t.oLength,L=t.abStart,w=L+t.abLength;let S=m[t.ab];S[0]=Math.min(L,S[0]),S[1]=Math.max(w,S[1]),S[2]=Math.min(v,S[2]),S[3]=Math.max(p,S[3])}const x=m.a[0]+(d-m.a[2]),g=m.a[1]+(a-m.a[3]),j=m.b[0]+(d-m.b[2]),h=m.b[1]+(a-m.b[3]);let y={stable:!1,aStart:x,aLength:g-x,aContent:e.slice(x,g),oStart:d,oLength:a-d,oContent:n.slice(d,a),bStart:j,bLength:h-j,bContent:s.slice(j,h)};i.push(y)}c=a}return r(n.length),i}function le(e,n,s,u){u=Object.assign({excludeFalseConflicts:!0,stringSeparator:/\s+/},u),typeof e=="string"&&(e=e.split(u.stringSeparator)),typeof n=="string"&&(n=n.split(u.stringSeparator)),typeof s=="string"&&(s=s.split(u.stringSeparator));let i=[];const c=ne(e,n,s);let r=[];function t(){r.length&&i.push({ok:r}),r=[]}function d(a,f){if(a.length!==f.length)return!1;for(let m=0;m<a.length;m++)if(a[m]!==f[m])return!1;return!0}return c.forEach(a=>{a.stable?r.push(...a.bufferContent):u.excludeFalseConflicts&&d(a.aContent,a.bContent)?r.push(...a.aContent):(t(),i.push({conflict:{a:a.aContent,aIndex:a.aStart,o:a.oContent,oIndex:a.oStart,b:a.bContent,bIndex:a.bStart}}))}),t(),i}const se=/^<!--\s*mdocs-merge-conflict:([^\s]+)\s*-->$/;function ie(e){return`<!-- mdocs-merge-conflict:${e} -->`}function oe(e){const n=e.trim().match(se);return(n==null?void 0:n[1])??null}function M(e){return e===""?[]:e.split(`
|
|
2
|
-
`)}function H(e,n){return e.length===n.length&&e.every((s,u)=>s===n[u])}function ce(e,n,s){const u=M(e),l=M(n),i=M(s);if(l.length===0&&n==="")return re(e,s);const c=le(u,l,i),r=[];let t=0,d=0,a=0,f=0;const m=(g,j,h,y)=>{r.push({kind:"conflict",id:`conflict-${t}`,conflictKind:y,baseLines:g,localLines:j,remoteLines:h,resolution:"unresolved"}),t+=1},x=(g,j,h)=>{if(j.length===0&&g.length===0&&h.length===0)return;if(H(g,j)&&H(h,j)){j.length>0&&r.push({kind:"unchanged",lines:[...j]});return}if(g.length===j.length&&h.length===j.length){let v=[];const p=()=>{v.length>0&&(r.push({kind:"unchanged",lines:v}),v=[])};for(let L=0;L<j.length;L+=1){const w=j[L],S=g[L],N=h[L];S===w&&N===w?v.push(w):(p(),m([w],[S],[N],S!==w&&N!==w&&S!==N?"true_conflict":"change"))}p();return}const y=g.join(`
|
|
3
|
-
`)!==j.join(`
|
|
4
|
-
`)&&h.join(`
|
|
5
|
-
`)!==j.join(`
|
|
6
|
-
`)&&g.join(`
|
|
7
|
-
`)!==h.join(`
|
|
8
|
-
`)?"true_conflict":"change";m(j,g,h,y)};for(let g=0;g<c.length;g+=1){const j=c[g],h=j.conflict;if(h){x(u.slice(d,h.aIndex),l.slice(a,h.oIndex),i.slice(f,h.bIndex)),m(h.o,h.a,h.b,"true_conflict"),d=h.aIndex+h.a.length,a=h.oIndex+h.o.length,f=h.bIndex+h.b.length;continue}if(j.ok){const y=c[g+1],v=y==null?void 0:y.conflict;v?(x(u.slice(d,v.aIndex),l.slice(a,v.oIndex),i.slice(f,v.bIndex)),d=v.aIndex,a=v.oIndex,f=v.bIndex):(x(u.slice(d),l.slice(a),i.slice(f)),d=u.length,a=l.length,f=i.length)}}return r}function ae(e,n){const s=e.length,u=n.length,l=Array.from({length:s+1},()=>new Array(u+1).fill(0));for(let t=1;t<=s;t+=1)for(let d=1;d<=u;d+=1)e[t-1]===n[d-1]?l[t][d]=l[t-1][d-1]+1:l[t][d]=Math.max(l[t-1][d],l[t][d-1]);const i=[];let c=s,r=u;for(;c>0||r>0;)c>0&&r>0&&e[c-1]===n[r-1]?(i.push({type:"equal",line:e[c-1]}),c-=1,r-=1):r>0&&(c===0||l[c][r-1]>=l[c-1][r])?(i.push({type:"add",line:n[r-1]}),r-=1):(i.push({type:"del",line:e[c-1]}),c-=1);return i.reverse()}function re(e,n){const s=M(e),u=M(n),l=ae(s,u),i=[];let c=0,r=0;for(;r<l.length;){if(l[r].type==="equal"){const f=[];for(;r<l.length&&l[r].type==="equal";)f.push(l[r].line),r+=1;i.push({kind:"unchanged",lines:f});continue}const d=[],a=[];for(;r<l.length&&l[r].type!=="equal";){const f=l[r];f.type==="del"&&d.push(f.line),f.type==="add"&&a.push(f.line),r+=1}i.push({kind:"conflict",id:`conflict-${c}`,conflictKind:"true_conflict",baseLines:[],localLines:d,remoteLines:a,resolution:"unresolved"}),c+=1}return i}function ue(e){return e.filter(n=>n.kind==="conflict").length}function de(e){return e.filter(n=>n.kind==="conflict"&&n.resolution==="unresolved").length}function fe(e){switch(e.resolution){case"local":return e.localLines;case"remote":return e.remoteLines;case"both":return[...e.localLines,...e.remoteLines];case"manual":return e.manualLines??[];default:return[]}}function me(e){const n=[];for(const s of e)s.kind==="unchanged"?n.push(...s.lines):s.resolution==="unresolved"?n.push(ie(s.id)):n.push(...fe(s));return n.join(`
|
|
9
|
-
`)}function O(e){return M(e).filter(n=>!oe(n)).join(`
|
|
10
|
-
`)}function F(e,n,s,u){return e.map(l=>l.kind!=="conflict"||l.id!==n?l:{...l,resolution:s,manualLines:s==="manual"?l.manualLines??[]:void 0})}function ye(e){const{t:n}=V(),[s,u]=b.useState(""),[l,i]=b.useState(""),[c,r]=b.useState(null),[t,d]=b.useState(!1),[a,f]=b.useState(!1),[m,x]=b.useState(null),[g,j]=b.useState(""),[h,y]=b.useState(null),[v,p]=b.useState(null),[L,w]=b.useState(!1),[S,N]=b.useState(!0);b.useEffect(()=>{let k=!1;return N(!0),x(null),j(""),y(null),p(null),(async()=>{try{const C=await _(e.documentId);if(k)return;x(C.content)}catch{k||e.onError(n("mergeLoadRemoteFailed")),k||N(!1)}})(),()=>{k=!0}},[e.documentId,e.onError,n]),b.useEffect(()=>{let k=!1;return r(null),i(""),d(!1),f(!1),(async()=>{try{const C=await J(e.documentId,e.conflict.localBaseCommitId,e.conflict.remoteCommitId);if(k)return;if(C.mode==="three_way"&&C.mergeBaseContent){r(C.mergeBaseContent);return}d(!0),f(!0)}catch{if(k)return;d(!0),f(!0)}})(),()=>{k=!0}},[e.documentId,e.conflict.localBaseCommitId,e.conflict.remoteCommitId]);const P=b.useCallback(k=>{j(k),N(!1)},[]),W=b.useCallback(k=>{u(k)},[]),K=b.useCallback(k=>{i(k),f(!0)},[]),z=b.useCallback(()=>{d(!0),i(""),f(!0)},[]);b.useEffect(()=>{!s||!g||S||!a||(y(ce(s,l,g)),p(null))},[s,g,l,a,S,e.conflict.remoteCommitId]);const R=b.useMemo(()=>h?O(me(h)):"",[h]),A=h?ue(h):0,I=h?de(h):0,T=v??R;b.useEffect(()=>{I===0&&h&&v===null&&p(R)},[I,h,R,v]);function $(k){y(C=>{if(!C)return C;let E=C;for(const D of C)D.kind==="conflict"&&(E=F(E,D.id,k));return E}),p(null)}async function G(){if(I>0){e.onError(n("mergeConflictsUnresolved",{count:String(I)}));return}const k=O(T);w(!0);try{const{content:C}=await Q({content:k,from:"markdown",to:"lexical"});await X(e.documentId,{content:C,displayName:e.displayName,version:{localBaseCommitId:e.conflict.localBaseCommitId,merge:{remoteCommitId:e.conflict.remoteCommitId,localSnapshotContent:e.conflict.localSnapshotContent}}});const E=await _(e.documentId);e.onSuccess(E)}catch(C){e.onError(C instanceof Error?C.message:String(C))}finally{w(!1)}}const U=!!(s&&g&&h&&!S&&a);return o.jsxs("div",{className:"mdocs-merge-overlay",children:[o.jsx(B,{lexicalJson:e.conflict.localSnapshotContent,onMarkdown:W,onError:()=>e.onError(n("mergeLoadLocalFailed"))}),c?o.jsx(B,{lexicalJson:c,onMarkdown:K,onError:z}):null,m?o.jsx(B,{lexicalJson:m,onMarkdown:P,onError:()=>{N(!1),e.onError(n("mergeLoadRemoteFailed"))}}):null,o.jsxs("header",{className:"mdocs-merge-toolbar",children:[o.jsxs("div",{className:"mdocs-merge-toolbar-title",children:[o.jsx("h2",{children:n("mergeTitle")}),U&&A>0?o.jsx("span",{className:`mdocs-merge-conflict-pill ${I>0?"pending":"resolved"}`,children:I>0?n("mergeConflictsPending",{unresolved:String(I),total:String(A)}):n("mergeConflictsResolved",{total:String(A)})}):null,t?o.jsx("span",{className:"mdocs-merge-base-warning",children:n("mergeBaseMissing")}):null]}),o.jsxs("div",{className:"mdocs-merge-toolbar-actions",children:[o.jsx("button",{type:"button",className:"secondary",disabled:L,onClick:e.onClose,children:n("cancel")}),o.jsx("button",{type:"button",className:"primary",disabled:L||!U||I>0,onClick:()=>void G(),children:n(L?"publishing":"mergeComplete")})]})]}),o.jsx("div",{className:"mdocs-merge-body mdocs-merge-body--inline",children:U?o.jsx(ee,{segments:h,unresolvedCount:I,onReceive:k=>{y(C=>C&&F(C,k,"remote")),p(null)},onReject:k=>{y(C=>C&&F(C,k,"local")),p(null)},onUseAllMine:()=>$("local"),onUseAllTheirs:()=>$("remote"),editableMarkdown:T,onEditableChange:p}):o.jsx("p",{className:"mdocs-merge-loading",children:n("mergeLoadingRemote")})})]})}export{ye as MergeView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as a,j as e}from"./react-vendor-BuABiQkA.js";import{b as te,q as Je,s as Qe,D as Xe,l as Ne,t as es,v as ss,w as J,x as ye,y as ts,z as as,A as ns,a as is,d as Ee,B as ze,C as Fe,E as ls,G as cs,H as rs,I as os,J as ds,K as Be,L as je,O as ms,Q as us,R as hs,T as ps,U as gs,f as fs,V as xs,W as js,X as bs,Y as Ns,Z as ys,_ as Ke,$ as vs,a0 as ks,a1 as ws,a2 as Ss,a3 as Cs,a4 as Ds,a5 as Is,a6 as Ts,a7 as As,a8 as Es,a9 as Ps,aa as Ms,ab as Ls,P as Rs,ac as zs,ad as Fs,ae as Bs,r as Ks,k as $s,af as Os,n as Vs,o as Us}from"./index-DI_31upJ.js";import{V as $e,a as Ws,M as Pe}from"./VisitorPickerModal-eagVdEZA.js";import"./ui-RahDNce8.js";import"./motion-BgtuAqBE.js";import"./diagram-DtU2xxz3.js";function _s({draft:t,onClose:s,onSuccess:v}){const{t:u,lang:m}=te(),[z,r]=a.useState([]),[N,j]=a.useState(t.domainId??""),[k,n]=a.useState([]),[y,h]=a.useState(""),[I,S]=a.useState(`${t.displayName||"untitled"}_recovered.md`),[p,f]=a.useState(!1),[A,M]=a.useState(null),C=a.useRef(null),E=a.useRef(!0);a.useEffect(()=>(E.current=!0,()=>{E.current=!1}),[]),a.useEffect(()=>{Je().then(b=>{E.current&&r(b)})},[]),a.useEffect(()=>{N&&(n([]),h(""),Qe(N).then(b=>{E.current&&n(b)}).catch(()=>{E.current&&n([])}))},[N]),a.useEffect(()=>{const b=window.setTimeout(()=>{var T;return(T=C.current)==null?void 0:T.focus()},0);return()=>window.clearTimeout(b)},[]),a.useEffect(()=>{const b=T=>{T.key==="Escape"&&s()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[s]);function B(b,T){for(const w of b){if(w.type==="folder"&&w.path===T)return w.documentId;if(w.type==="folder"){const P=B(w.children,T);if(P)return P}}return null}async function R(b){b.preventDefault(),f(!0),M(null);const T=I.replace(/\s+/g,"_").replace(/[^a-zA-Z0-9_\-.]/g,""),w=T.endsWith(".md")?T:T+".md",P=w.replace(/\.md$/i,"");try{const d=y?`${y}/${w}`:w,c=y?B(k,y)??void 0:void 0;await ss({fileName:w,displayName:P,content:t.content,domainId:N,parentId:c}),v()}catch(d){M(J(u,d))}finally{f(!1)}}return e.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:b=>{b.target===b.currentTarget&&!p&&s()},children:e.jsxs("div",{className:"mdocs-dialog card mdocs-recovery-dialog",role:"dialog","aria-modal":"true",children:[e.jsx("h1",{children:u("recoverDraft")}),e.jsx("p",{className:"muted",children:u("recoverDraftDesc",{name:t.displayName||u("unknownTitle")})}),e.jsxs("form",{onSubmit:R,className:"mdocs-dialog-form",children:[e.jsxs("label",{className:"mdocs-dialog-label",children:[u("domainLabel"),z.length>0&&e.jsx(Xe,{domains:z,value:N,onChange:j,onDomainsChange:r,ariaLabel:u("domainLabel"),localizeName:b=>Ne(b,m,u)})]}),e.jsxs("label",{className:"mdocs-dialog-label mdocs-recovery-tree-label",children:[u("recoverTargetFolder"),e.jsx("div",{className:"mdocs-recovery-tree",children:e.jsx(es,{nodes:k,activeDocumentId:null,selectedParentPath:y,onOpen:()=>{},onOpenFolder:b=>h(b),onContextMenu:()=>{},onDeselect:()=>h("")})})]}),e.jsxs("label",{className:"mdocs-dialog-label",children:[u("fileNameLabel"),e.jsx("input",{ref:C,value:I,onChange:b=>S(b.target.value),placeholder:"recovered.md",maxLength:200,disabled:p})]}),A&&e.jsx("div",{className:"mdocs-dialog-error",children:A}),e.jsxs("div",{className:"mdocs-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>!p&&s(),disabled:p,children:u("cancel")}),e.jsx("button",{type:"submit",className:"primary",disabled:p,children:u(p?"creating":"create")})]})]})]})})}function Hs({onPublish:t,onClose:s,onCountChange:v,onRecover:u}){const{t:m}=te(),[z,r]=a.useState([]),[N,j]=a.useState(new Set),[k,n]=a.useState(!1),[y,h]=a.useState(null),[I,S]=a.useState(null),[p,f]=a.useState(null),A=a.useRef(null),M=a.useRef(!0);a.useEffect(()=>(M.current=!0,ye().then(c=>{if(!M.current)return;const g=c.filter(D=>!D.published);r(g),v==null||v(g.length)}),()=>{M.current=!1,A.current&&(clearTimeout(A.current),A.current=null)}),[]),a.useEffect(()=>{const c=g=>{g.key==="Escape"&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]);const C=a.useCallback((c,g)=>{f({message:c,type:g}),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>f(null),3e3)},[]);async function E(c){await as(c),j(g=>new Set(g).add(c));try{await t(c),r(g=>{const D=g.filter(F=>F.documentId!==c);return v==null||v(D.length),D}),C(m("published"),"success")}catch(g){g instanceof ns||C(m("publishFailed"),"error");const D=await is(c);D&&r(F=>F.map(V=>V.documentId===c?D:V))}finally{j(g=>{const D=new Set(g);return D.delete(c),D})}}async function B(c){h(null),await Ee(c),r(g=>{const D=g.filter(F=>F.documentId!==c);return v==null||v(D.length),D}),C(m("draftDeleted"),"success")}function R(c){const g=z.find(D=>D.documentId===c);g&&S(g)}function b(c){S(null),Ee(c),r(g=>{const D=g.filter(F=>F.documentId!==c);return v==null||v(D.length),D}),u==null||u(z.find(g=>g.documentId===c)),C(m("published"),"success")}async function T(){n(!0);let c=0,g=0;for(const V of z)try{await t(V.documentId),c++}catch{g++}const F=(await ye()).filter(V=>!V.published);r(F),v==null||v(F.length),g===0?C(m("publishAll"),"success"):C(`${c} published, ${g} failed`,"error"),n(!1)}const w=c=>new Date(c).toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),P=c=>ts(m,c,c.publishError??"UNKNOWN"),d=z;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mdocs-drawer-overlay",onClick:s}),e.jsxs("div",{className:"mdocs-drawer",role:"dialog","aria-modal":"true",children:[e.jsxs("header",{className:"mdocs-drawer-header",children:[e.jsxs("div",{className:"mdocs-drawer-header-text",children:[e.jsxs("h2",{className:"mdocs-drawer-title",children:[m("unpublishedDrafts"),d.length>0&&e.jsx("span",{className:"mdocs-drawer-count-badge",children:d.length})]}),e.jsx("span",{className:"mdocs-drawer-subtitle",children:m("draftCount",{count:String(d.length)})})]}),e.jsx("button",{type:"button",className:"mdocs-drawer-close-btn",onClick:s,"aria-label":m("close"),children:"×"})]}),e.jsx("div",{className:"mdocs-drawer-body",children:d.length===0?e.jsxs("div",{className:"mdocs-drawer-empty",children:[e.jsx("div",{className:"mdocs-drawer-empty-icon","aria-hidden":"true",children:"✓"}),e.jsx("p",{className:"mdocs-drawer-empty-text",children:m("draftsEmptyState")})]}):e.jsx("div",{className:"mdocs-drawer-items",children:d.map(c=>{const g=!!c.publishError;return e.jsxs("div",{className:g?"mdocs-drawer-item mdocs-drawer-item-failed":"mdocs-drawer-item",children:[e.jsx("div",{className:"mdocs-drawer-item-icon","aria-hidden":"true",children:"📄"}),e.jsxs("div",{className:"mdocs-drawer-item-info",children:[e.jsx("span",{className:"mdocs-drawer-item-name",children:c.displayName||m("unknownTitle")}),g?e.jsxs("span",{className:"mdocs-drawer-item-error",children:[w(c.publishErrorAt)," · ",P(c)]}):e.jsxs("span",{className:"mdocs-drawer-item-meta",children:[w(c.updatedAt)," · ",m("localSnapshot")]})]}),e.jsxs("div",{className:"mdocs-drawer-item-actions",children:[g?e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-primary",disabled:k,onClick:()=>R(c.documentId),children:m("recoverDraft")}):e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-primary",disabled:N.has(c.documentId)||k,onClick:()=>void E(c.documentId),children:N.has(c.documentId)?m("publishing"):m("publish")}),e.jsx("button",{type:"button",className:"mdocs-btn-ghost mdocs-btn-ghost-danger",disabled:k,onClick:()=>h(c.documentId),children:m("delete")})]})]},c.documentId)})})}),e.jsxs("footer",{className:"mdocs-drawer-footer",children:[e.jsx("button",{type:"button",onClick:s,children:m("close")}),e.jsx("button",{type:"button",className:"primary",disabled:d.length===0||k,onClick:()=>void T(),children:k?m("publishing"):`${m("publishAll")} (${d.length})`})]}),p&&e.jsx("div",{className:"mdocs-drawer-toast mdocs-drawer-toast--"+p.type,role:"status",children:p.message})]}),y&&e.jsx("div",{className:"mdocs-dialog-backdrop",role:"presentation",onMouseDown:c=>{c.target===c.currentTarget&&h(null)},children:e.jsxs("div",{className:"mdocs-dialog card",role:"dialog","aria-modal":"true",children:[e.jsx("h1",{children:m("delete")}),e.jsx("p",{className:"muted",children:m("confirmDeleteDraft")}),e.jsxs("div",{className:"mdocs-dialog-actions",children:[e.jsx("button",{type:"button",onClick:()=>h(null),children:m("cancel")}),e.jsx("button",{type:"button",className:"danger",onClick:()=>void B(y),children:m("delete")})]})]})}),I&&e.jsx(_s,{draft:I,onClose:()=>S(null),onSuccess:()=>b(I.documentId)})]})}function qs(){const{t,lang:s}=te(),v=ze(),u=a.useRef(!1),[m,z]=a.useState([]),[r,N]=a.useState(!1),[j,k]=a.useState(""),[n,y]=a.useState("restricted"),[h,I]=a.useState(!1),[S,p]=a.useState(null),[f,A]=a.useState(null),[M,C]=a.useState(""),[E,B]=a.useState(""),[R,b]=a.useState("all"),[T,w]=a.useState(null);a.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);const P=a.useCallback(async()=>{N(!0),p(null);try{const x=await Fe();if(!u.current)return;z(x)}catch(x){if(!u.current)return;p(J(t,x))}finally{u.current&&N(!1)}},[t]);a.useEffect(()=>{P()},[P]);async function d(x){if(x.preventDefault(),!j.trim()){p(t("domainNameRequired"));return}I(!0),p(null);try{if(await ds({domainName:j.trim(),permission:n}),!u.current)return;k(""),y("restricted"),await P()}catch($){if(!u.current)return;p(J(t,$))}finally{u.current&&I(!1)}}async function c(x){if(M.trim()){p(null);try{if(await os(x,M.trim()),!u.current)return;A(null),w(null),await P()}catch($){if(!u.current)return;p(J(t,$))}}}function g(x){A(x.domainId),C(x.domainName),w(null)}function D(){A(null),w(null)}async function F(x,$){p(null);try{if(await rs(x,$),!u.current)return;w(null),await P()}catch(U){if(!u.current)return;p(J(t,U))}}async function V(x){if(window.confirm(t("deleteDomainConfirmDetail",{name:x.domainName,count:String(x.docCount)}))){p(null);try{if(await cs(x.domainId),!u.current)return;await P()}catch($){if(!u.current)return;p(J(t,$))}}}const H=a.useCallback(x=>ls(x,t),[t]),q=a.useCallback(x=>Ne(x.domainName,s,t),[s,t]),G=a.useMemo(()=>{const x=E.trim().toLowerCase();return m.filter($=>R!=="all"&&$.permission!==R?!1:x?Ne($.domainName,s,t).toLowerCase().includes(x)||$.domainName.toLowerCase().includes(x):!0)},[m,E,R,s,t]),W=a.useCallback((x,$)=>{const U=H(x.permission);return $?`${U} ${t("domainTypeBuiltinSuffix")}`:U},[H,t]);return{domains:m,loadingDomains:r,domainError:S,newDomainName:j,setNewDomainName:k,newDomainPermission:n,setNewDomainPermission:y,creating:h,handleCreateDomain:d,renamingId:f,setRenamingId:A,renameDraft:M,setRenameDraft:C,startRename:g,cancelRename:D,handleRename:c,changeTypeForId:T,setChangeTypeForId:w,handlePermissionChange:F,handleDelete:V,domainSearch:E,setDomainSearch:B,domainFilter:R,setDomainFilter:b,filteredDomains:G,visitorId:v,plabel:H,localizeDomain:q,domainTypeLabel:W}}function Gs(){const{t}=te(),s=qs(),[v,u]=a.useState([]),[m,z]=a.useState(null),[r,N]=a.useState(null),j=a.useCallback(async()=>{try{const n=await Be();u(n)}catch{u([])}},[]);a.useEffect(()=>{j()},[j]);async function k(n){z(null);try{const y=await gs(n.domainId);N({domainId:n.domainId,creatorVisitorId:n.creatorVisitorId,initialIds:y.map(h=>h.visitorId),memberRows:y})}catch(y){z({kind:"err",text:J(t,y)})}}return e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:t("domainManagement")})}),e.jsx("p",{className:"mdocs-domain-mgmt-restricted-hint",children:t("domainMgmtRestrictedMemberHint")}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsxs("div",{className:"mdocs-settings-card mdocs-domain-mgmt-create",children:[e.jsx("div",{className:"mdocs-settings-card-title",children:t("createDomain")}),e.jsxs("form",{onSubmit:s.handleCreateDomain,className:"mdocs-domain-mgmt-create-form",children:[e.jsxs("label",{className:"mdocs-domain-mgmt-field",children:[e.jsx("span",{className:"mdocs-domain-mgmt-label",children:t("domainName")}),e.jsx("input",{value:s.newDomainName,onChange:n=>s.setNewDomainName(n.target.value),placeholder:t("domainName"),maxLength:100,disabled:s.creating,className:"mdocs-domain-name-input"})]}),e.jsxs("fieldset",{className:"mdocs-domain-mgmt-fieldset",children:[e.jsx("legend",{className:"mdocs-domain-mgmt-label",children:t("domainPermission")}),e.jsx("div",{className:"mdocs-domain-mgmt-type-radios",children:je.map(n=>e.jsxs("label",{className:"mdocs-domain-mgmt-radio",children:[e.jsx("input",{type:"radio",name:"newDomainPermission",checked:s.newDomainPermission===n,onChange:()=>s.setNewDomainPermission(n),disabled:s.creating}),e.jsx("span",{children:s.plabel(n)})]},n))})]}),e.jsx("button",{type:"submit",className:"primary mdocs-domain-mgmt-submit",disabled:s.creating,children:s.creating?t("creating"):t("create")})]})]}),m&&e.jsx("div",{className:"mdocs-settings-card",style:{color:m.kind==="ok"?"var(--mdocs-success, #0a7)":"var(--mdocs-danger)"},children:e.jsx("span",{className:"mdocs-settings-item-desc",children:m.text})}),s.domainError&&e.jsx("div",{className:"mdocs-settings-card mdocs-domain-error",children:e.jsx("span",{className:"mdocs-settings-item-desc",style:{color:"var(--mdocs-danger)"},children:s.domainError})}),e.jsxs("div",{className:"mdocs-settings-card mdocs-domain-mgmt-toolbar",children:[e.jsx("input",{type:"search",value:s.domainSearch,onChange:n=>s.setDomainSearch(n.target.value),placeholder:t("domainSearchPlaceholder"),className:"mdocs-domain-mgmt-search","aria-label":t("domainSearchPlaceholder")}),e.jsx("div",{className:"mdocs-domain-mgmt-filters",role:"group","aria-label":t("domainPermission"),children:["all",...je].map(n=>e.jsx("button",{type:"button",className:"mdocs-domain-mgmt-filter"+(s.domainFilter===n?" active":""),"aria-pressed":s.domainFilter===n,onClick:()=>s.setDomainFilter(n),children:n==="all"?t("domainFilterAll"):s.plabel(n)},n))})]}),s.loadingDomains?e.jsx("div",{className:"mdocs-settings-card",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("loading")})}):s.domains.length===0?e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("noDomains")})}):s.filteredDomains.length===0?e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:t("domainNoMatch")})}):e.jsx("div",{className:"mdocs-settings-card mdocs-domain-table-wrap",children:e.jsxs("table",{className:"mdocs-domain-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:t("domainColName")}),e.jsx("th",{scope:"col",children:t("domainColType")}),e.jsx("th",{scope:"col",className:"mdocs-domain-table-num",children:t("domainColDocCount")}),e.jsx("th",{scope:"col",children:t("domainColActions")})]})}),e.jsx("tbody",{children:s.filteredDomains.map(n=>{const y=ms(n,s.visitorId),h=us(n.domainId),I=hs(n),S=I?t("domainTooltipTypeLocked",{count:String(n.docCount)}):void 0;return e.jsxs("tr",{className:h?"mdocs-domain-table-row-builtin":void 0,children:[e.jsx("td",{children:s.renamingId===n.domainId?e.jsxs("div",{className:"mdocs-domain-table-rename",children:[e.jsx("input",{value:s.renameDraft,onChange:p=>s.setRenameDraft(p.target.value),maxLength:100,autoFocus:!0,className:"mdocs-domain-name-input"}),e.jsx("button",{type:"button",className:"primary",onClick:()=>void s.handleRename(n.domainId),children:t("save")}),e.jsx("button",{type:"button",onClick:s.cancelRename,children:t("cancel")})]}):e.jsxs("div",{className:"mdocs-domain-table-name-cell",children:[e.jsx("span",{className:"mdocs-domain-table-name",children:s.localizeDomain(n)}),h&&e.jsx("span",{className:"mdocs-domain-badge-builtin",children:t("domainBuiltIn")}),!y&&!h&&e.jsx("span",{className:"mdocs-domain-badge-shared",children:t("shared")})]})}),e.jsx("td",{children:e.jsxs("span",{className:"mdocs-domain-table-type",title:S,children:[e.jsx("span",{className:"mdocs-domain-permission-badge","data-permission":n.permission,children:s.domainTypeLabel(n,h)}),I&&!h&&e.jsx("span",{className:"mdocs-domain-type-lock","aria-hidden":"true",children:"🔒"})]})}),e.jsx("td",{className:"mdocs-domain-table-num",children:n.docCount}),e.jsxs("td",{className:"mdocs-domain-table-actions",children:[h&&e.jsx("span",{className:"mdocs-domain-not-modifiable",children:t("domainNotModifiable")}),!h&&!y&&e.jsx("span",{className:"mdocs-domain-not-creator-inline",children:t("domainNotCreator")}),!h&&y&&s.changeTypeForId===n.domainId&&e.jsxs("div",{className:"mdocs-domain-change-type-panel",children:[e.jsx("div",{className:"mdocs-domain-permission-select",children:je.map(p=>e.jsx("button",{type:"button",className:n.permission===p?"active":"",onClick:()=>void s.handlePermissionChange(n.domainId,p),children:s.plabel(p)},p))}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>s.setChangeTypeForId(null),children:t("cancel")})]}),!h&&y&&s.renamingId!==n.domainId&&s.changeTypeForId!==n.domainId&&e.jsxs("div",{className:"mdocs-domain-action-buttons",children:[e.jsx("button",{type:"button",className:"secondary",title:I?t("domainLocked"):void 0,onClick:()=>{s.setChangeTypeForId(null),s.startRename(n)},disabled:I,children:t("rename")}),e.jsx("button",{type:"button",className:"secondary",title:I?S:void 0,onClick:()=>{s.setRenamingId(null),s.setChangeTypeForId(n.domainId)},disabled:I,children:t("domainChangeType")}),e.jsx("button",{type:"button",className:"secondary",title:I?t("domainLocked"):void 0,onClick:()=>void s.handleDelete(n),disabled:I,children:t("deleteDomain")}),n.permission==="restricted"&&!h&&e.jsx("button",{type:"button",className:"secondary",onClick:()=>void k(n),children:t("domainMembersManageButton")})]})]})]},n.domainId)})})]})})]}),e.jsx($e,{open:r!==null,title:t("domainMembersPickerTitle"),initialSelectedIds:(r==null?void 0:r.initialIds)??[],lockedIds:r?[r.creatorVisitorId]:[],seedMembers:r==null?void 0:r.memberRows,templates:v,onClose:()=>N(null),onConfirm:async n=>{r&&(await ps(r.domainId,n),z({kind:"ok",text:t("domainMembersSaved",{count:String(n.length)})}))}})]})}function Me(t){return t.length<=6?t:`${t.slice(0,6)}…`}function Zs(){const{t}=te(),s=a.useRef(!0),[v,u]=a.useState([]),[m,z]=a.useState(!0),[r,N]=a.useState(null),[j,k]=a.useState(1),[n,y]=a.useState(null),[h,I]=a.useState(""),[S,p]=a.useState([]),[f,A]=a.useState(!1),[M,C]=a.useState(null),[E,B]=a.useState(!1),R=ze(),[b,T]=a.useState([]),[w,P]=a.useState("idle"),[d,c]=a.useState("");a.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]),a.useEffect(()=>{P("loading"),fs().then(o=>{s.current&&(T(o),P("ok"))}).catch(()=>{s.current&&P("err")})},[]);const g=a.useMemo(()=>{const o=new Map;for(const L of b)o.set(L.visitorId,L.visitorName);return o},[b]),D=a.useCallback(async()=>{z(!0),C(null);try{const o=await Be();s.current&&u(o)}catch(o){s.current&&C(J(t,o))}finally{s.current&&z(!1)}},[t]);a.useEffect(()=>{D()},[D]);const F=a.useMemo(()=>S.map(o=>{const L=b.find(O=>O.visitorId===o);return{visitorId:o,name:L?L.visitorName:t("visitorPickerUnknownVisitor"),muted:!L}}),[S,b,t]);function V(o){p(L=>L.includes(o)?L.filter(O=>O!==o):[...L,o])}const H=j===1?h.trim().length>0:j===2?S.length>0:!0;function q(){if(!(j>=3)){if(!H){B(!0);return}B(!1),k(j+1),c("")}}function G(){j<=1||(B(!1),k(j-1))}function W(){N(null),y(null),I(""),p(R?[R]:[]),C(null),k(1),c(""),B(!1)}function x(o){N(null),y(o.id),I(o.displayName);const L=R&&!o.visitorIds.includes(R)?[...o.visitorIds,R]:[...o.visitorIds];p(L),C(null),k(1),c(""),B(!1)}async function $(){if(!(!h.trim()||S.length===0)){A(!0),C(null);try{if(n===null?await xs({displayName:h.trim(),visitorIds:S}):await js(n,{displayName:h.trim(),visitorIds:S}),!s.current)return;W(),await D()}catch(o){if(!s.current)return;C(J(t,o))}finally{s.current&&A(!1)}}}async function U(o){A(!0),C(null);try{if(await bs(o),!s.current)return;N(null),n===o&&W(),await D()}catch(L){if(!s.current)return;C(J(t,L))}finally{s.current&&A(!1)}}const Z=[{key:1,label:t("memberTemplateStepName")},{key:2,label:t("memberTemplateStepMembers")},{key:3,label:t("memberTemplateStepSave")}],Q=`${(j-1)/2*100}%`;return e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsx("h2",{className:"mdocs-settings-title",children:t(n!==null?"memberTemplateUpdate":"memberTemplateFormNew")}),n!==null&&e.jsx("button",{type:"button",className:"secondary",onClick:W,style:{fontSize:12},children:t("memberTemplateCancelEdit")})]}),e.jsxs("div",{className:"mdocs-wizard-progress",children:[e.jsx("div",{className:"mdocs-wizard-progress-track",children:e.jsx("div",{className:"mdocs-wizard-progress-fill",style:{width:Q}})}),e.jsx("div",{className:"mdocs-wizard-progress-steps",children:Z.map(o=>{const L=j===o.key,O=j>o.key;return e.jsxs("div",{className:"mdocs-wizard-step-indicator",children:[e.jsx("div",{className:`mdocs-wizard-step-circle${L?" current":""}${O?" done":""}`,children:O?"✓":o.key}),e.jsx("span",{className:`mdocs-wizard-step-label${L?" current":""}${O?" done":""}`,children:o.label})]},o.key)})})]}),M&&e.jsx("div",{className:"mdocs-settings-item-desc",style:{color:"var(--mdocs-danger)",marginBottom:12,marginTop:12},children:M}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsxs("div",{className:"mdocs-settings-card mdocs-wizard-card",children:[j===1&&e.jsxs("div",{className:"mdocs-wizard-step-content",children:[e.jsx("input",{className:"mdocs-wizard-name-input",value:h,onChange:o=>I(o.target.value),placeholder:t("memberTemplateNamePlaceholder"),maxLength:200,disabled:f,autoFocus:!0,"aria-invalid":E&&!h.trim()}),E&&!h.trim()&&e.jsx("p",{className:"mdocs-wizard-hint",style:{color:"var(--mdocs-danger)"},children:t("domainNameRequired")})]}),j===2&&e.jsxs("div",{className:"mdocs-wizard-step-content",children:[e.jsx(Ws,{visitors:b,loadState:w,searchFilter:d,onSearchChange:c,selectedIds:new Set(S),onToggle:V,selectedRows:F,myVisitorId:R}),e.jsx("p",{className:`mdocs-wizard-hint${E&&S.length===0?" danger":""}`,children:"💡 "+t("memberTemplateStep2Hint")})]}),j===3&&e.jsx("div",{className:"mdocs-wizard-step-content",children:e.jsxs("div",{className:"mdocs-wizard-preview-card",children:[e.jsxs("div",{className:"mdocs-wizard-preview-row",children:[e.jsx("span",{className:"mdocs-wizard-preview-label",children:t("memberTemplateNameLabel")}),e.jsx("span",{className:"mdocs-wizard-preview-value",children:h})]}),e.jsxs("div",{className:"mdocs-wizard-preview-row",children:[e.jsx("span",{className:"mdocs-wizard-preview-label",children:t("memberTemplateIdsLabel")}),e.jsx("span",{className:"mdocs-wizard-preview-value",children:t("memberTemplateSelectedSummary",{count:String(S.length)})})]}),S.length>0&&e.jsxs("div",{className:"mdocs-wizard-preview-tags",children:[S.slice(0,15).map(o=>e.jsx("span",{className:"mdocs-wizard-preview-tag",children:Me(o)},o)),S.length>15&&e.jsxs("span",{className:"mdocs-wizard-preview-tag mdocs-wizard-preview-tag-more",children:["+",S.length-15]})]})]})}),e.jsxs("div",{className:"mdocs-wizard-footer",children:[e.jsxs("button",{type:"button",className:"secondary",onClick:G,children:["← ",t("memberTemplateWizardBack")]}),j<3?e.jsxs("button",{type:"button",className:"primary",onClick:q,children:[t("memberTemplateWizardNext")," →"]}):e.jsx("button",{type:"button",className:"primary",onClick:()=>void $(),children:t(f?"saving":n===null?"memberTemplateCreate":"memberTemplateUpdate")})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("div",{className:"mdocs-settings-card-title",children:t("memberTemplateSavedList")}),m?e.jsx("span",{className:"mdocs-settings-item-desc",children:t("loading")}):v.length===0?e.jsxs("div",{className:"mdocs-member-template-empty",children:[e.jsx("span",{className:"mdocs-settings-item-desc",children:t("memberTemplateEmpty")}),n===null&&e.jsx("button",{type:"button",className:"primary",onClick:W,children:t("memberTemplateEmptyAction")})]}):e.jsx("ul",{className:"mdocs-member-template-list",children:v.map(o=>e.jsx("li",{className:"mdocs-member-template-row",children:r===o.id?e.jsxs("div",{className:"mdocs-member-template-confirm-row",children:[e.jsx("span",{className:"mdocs-member-template-confirm-text",children:t("memberTemplateConfirmDeleteDesc",{name:o.displayName})}),e.jsxs("div",{className:"mdocs-member-template-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary",style:{color:"var(--mdocs-danger)"},onClick:()=>void U(o.id),children:t(f?"saving":"memberTemplateConfirmDeleteSubmit")}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>N(null),children:t("memberTemplateConfirmDeleteCancel")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mdocs-member-template-row-head",children:[e.jsx("strong",{children:o.displayName}),e.jsx("span",{className:"mdocs-settings-item-desc",children:t("memberTemplateCount",{count:String(o.visitorIds.length)})}),o.visitorIds.length>0&&e.jsx("div",{className:"mdocs-member-template-tags mdocs-member-template-tags-scroll",children:o.visitorIds.map(L=>e.jsx("span",{className:"mdocs-member-template-tag",children:g.get(L)??Me(L)},L))})]}),e.jsxs("div",{className:"mdocs-member-template-row-actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>x(o),children:t("edit")}),e.jsx("button",{type:"button",className:"secondary",onClick:()=>N(o.id),children:t("memberTemplateDelete")})]})]})},o.id))})]})]})]})}const Ys=[{value:"deepseek-v4-flash",label:"deepseek-v4-flash"},{value:"deepseek-v4-pro",label:"deepseek-v4-pro"}],Js=[{value:"openai-completions",label:"OpenAI 兼容"},{value:"anthropic-messages",label:"Anthropic 兼容"}];function Qs(t,s,v){return t==="deepseek"?"Deepseek":s||v}function Le(t){return`${Qs(t.kind,t.providerId,t.name)} · ${t.modelId} · ${t.name}`}function Xs(){const{t}=te(),s=a.useRef(!0),[v,u]=a.useState(""),[m,z]=a.useState([]),[r,N]=a.useState(null),[j,k]=a.useState(null),[n,y]=a.useState("deepseek"),[h,I]=a.useState(""),[S,p]=a.useState(""),[f,A]=a.useState(""),[M,C]=a.useState("openai-completions"),[E,B]=a.useState("deepseek-v4-flash"),[R,b]=a.useState(128e3),[T,w]=a.useState(""),[P,d]=a.useState(!1),[c,g]=a.useState(null),[D,F]=a.useState(!1),[V,H]=a.useState(!0),[q,G]=a.useState(!1),[W,x]=a.useState(null),[$,U]=a.useState(!1),[Z,Q]=a.useState(!1),[o,L]=a.useState(!1),[O,ae]=a.useState(null),[re,ie]=a.useState(null),le=a.useRef(!1);a.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]);const X=a.useCallback(async()=>{const l=await Ns();if(s.current)return z(l),l},[]);function ee(){k(null),y("deepseek"),I(""),p(""),A(""),C("openai-completions"),B("deepseek-v4-flash"),b(128e3),w(""),d(!1),g(null),F(!1),Q(!1),L(!1),x(null),U(!1)}function oe(l){k(l.id),y(l.kind),I(l.name),p(l.providerId??""),A(l.baseUrl),C(l.apiType),B(l.modelId),b(l.contextWindow||128e3),d(l.hasApiKey),g(l.apiKeyMasked),w(""),F(l.isDefault)}a.useEffect(()=>{(async()=>{try{const l=await ys();if(!s.current)return;u(l.visitorName);const _=await X();if(!s.current||!_)return;_.length===0&&(ee(),N("create"))}catch(l){if(!s.current)return;x(l instanceof Error?l.message:String(l)),N("create")}finally{s.current&&H(!1)}})()},[X]);function me(){ee(),N("create")}function de(l){oe(l),N("edit"),U(!1),x(null)}function se(){ee(),N(null)}async function ue(l){if(!(l.isDefault||re)){ie(l.id),x(null);try{await vs(l.id),await X()}catch(_){if(!s.current)return;x(_ instanceof Error?_.message:String(_))}finally{s.current&&ie(null)}}}async function he(){if(O){G(!0),x(null);try{await ws(O.id);const l=await X();if(!s.current)return;r==="edit"&&j===O.id&&se(),((l==null?void 0:l.length)??0)===0&&(ee(),N("create"))}catch(l){if(!s.current)return;x(l instanceof Error?l.message:String(l))}finally{s.current&&(G(!1),ae(null))}}}async function pe(){G(!0),x(null),U(!1);try{const l=n==="custom"?{...r==="edit"&&j?{id:j}:{},...r==="create"&&D?{isDefault:!0}:{},kind:n,baseUrl:f,modelId:E,providerId:S.trim()||void 0,apiType:M,name:h,contextWindow:R,...T.trim()?{apiKey:T.trim()}:{}}:{...r==="edit"&&j?{id:j}:{},...r==="create"&&D?{isDefault:!0}:{},kind:n,modelId:E,name:h,contextWindow:R,...T.trim()?{apiKey:T.trim()}:{}};if(await ks(l),!s.current)return;await X(),U(!0),N(null),ee()}catch(l){if(!s.current)return;x(l instanceof Error?l.message:String(l))}finally{s.current&&G(!1)}}const ce=r!==null;return e.jsxs("div",{className:"mdocs-agent-config-panel",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsx("h2",{className:"mdocs-settings-title",children:t("agentConfig")}),!V&&!ce?e.jsx("button",{type:"button",className:"secondary",onClick:me,children:"添加配置"}):null]}),e.jsxs("div",{className:"mdocs-settings-cards",children:[!V&&m.length>0&&!ce?e.jsxs("div",{className:"mdocs-settings-card mdocs-agent-config-card",children:[e.jsx("p",{className:"mdocs-agent-config-lead",children:"选择默认配置后,智能助手与帮写将使用该模型。"}),e.jsx("ul",{className:"mdocs-agent-config-list",children:m.map(l=>e.jsxs("li",{className:"mdocs-agent-config-item",children:[e.jsxs("label",{className:"mdocs-agent-config-item-default",children:[e.jsx("input",{type:"radio",name:"agent-default-config",checked:l.isDefault,disabled:re!==null,onChange:()=>void ue(l)}),e.jsx("span",{children:l.isDefault?"默认":"设为默认"})]}),e.jsxs("div",{className:"mdocs-agent-config-item-main",children:[e.jsx("strong",{children:Le(l)}),l.kind==="custom"?e.jsx("span",{className:"mdocs-agent-badge",children:"自定义"}):null,e.jsx("p",{className:"mdocs-agent-config-item-meta",children:l.hasApiKey?`Key ${l.apiKeyMasked??"已配置"}`:"未配置 Key"})]}),e.jsxs("div",{className:"mdocs-agent-config-item-actions",children:[e.jsx("button",{type:"button",className:"secondary small",onClick:()=>de(l),children:t("edit")}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>ae(l),children:"删除"})]})]},l.id))}),$?e.jsx("p",{className:"mdocs-agent-config-ok",children:t("saved")}):null,W?e.jsx("p",{className:"mdocs-agent-config-error",children:W}):null]}):null,ce?e.jsxs("div",{className:"mdocs-settings-card mdocs-agent-config-card",children:[e.jsx("p",{className:"mdocs-agent-config-lead",children:r==="create"?"新建模型配置":"编辑模型配置"}),e.jsxs("div",{className:"mdocs-agent-form",children:[e.jsxs("div",{className:"mdocs-agent-kind-tabs",role:"tablist","aria-label":"配置方式",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":n==="deepseek",className:n==="deepseek"?"active":"",onClick:()=>y("deepseek"),children:"Deepseek"}),e.jsx("button",{type:"button",role:"tab","aria-selected":n==="custom",className:n==="custom"?"active":"",onClick:()=>y("custom"),children:"自定义"})]}),n==="deepseek"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:t("agentConfigModel")}),e.jsx(Pe,{options:[...Ys],value:E,onChange:B})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:t("agentConfigApiKey")}),e.jsxs("div",{className:"mdocs-agent-config-apikey",children:[e.jsx("input",{type:Z?"text":"password",value:T,onChange:l=>w(l.target.value),placeholder:P?t("agentConfigApiKeyConfigured").replace("{{masked}}",c??"…"):t("agentConfigApiKeyPlaceholder"),autoComplete:"off"}),e.jsx("button",{type:"button",className:"mdocs-agent-config-eye","aria-label":t(Z?"agentConfigHideKey":"agentConfigShowKey"),onClick:()=>Q(l=>!l),children:Z?"隐藏":"显示"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:"API 地址"}),e.jsx("input",{type:"url",value:f,onChange:l=>{const _=l.target.value;if(A(_),le.current)return;_.toLowerCase().includes("anthropic")?C("anthropic-messages"):C("openai-completions")},placeholder:"https://api.example.com/v1",className:"mdocs-agent-mono"})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:"Model ID"}),e.jsx("input",{type:"text",value:E,onChange:l=>B(l.target.value),placeholder:"模型名称,如 gpt-4o",className:"mdocs-agent-mono"})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:t("agentConfigApiKey")}),e.jsxs("div",{className:"mdocs-agent-config-apikey",children:[e.jsx("input",{type:Z?"text":"password",value:T,onChange:l=>w(l.target.value),placeholder:P?t("agentConfigApiKeyConfigured").replace("{{masked}}",c??"…"):"粘贴 API Key",autoComplete:"off"}),e.jsx("button",{type:"button",className:"mdocs-agent-config-eye","aria-label":t(Z?"agentConfigHideKey":"agentConfigShowKey"),onClick:()=>Q(l=>!l),children:Z?"隐藏":"显示"})]})]})]}),e.jsxs("details",{className:"mdocs-agent-advanced",open:o,onToggle:l=>L(l.target.open),children:[e.jsx("summary",{children:"高级选项"}),n==="custom"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:"Provider ID(选填)"}),e.jsx("input",{type:"text",value:S,onChange:l=>p(l.target.value),placeholder:"不填则自动从 API 地址提取域名"})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:"API 协议"}),e.jsx(Pe,{options:[...Js],value:M,onChange:l=>{le.current=!0,C(l)}})]})]}):null,e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:t("agentConfigName")}),e.jsx("input",{type:"text",value:h,onChange:l=>I(l.target.value),placeholder:t("agentConfigNameDefault").replace("{{name}}",v||"…")})]}),e.jsxs("label",{className:"mdocs-agent-field",children:[e.jsx("span",{children:t("agentConfigContextWindow")}),e.jsx("input",{type:"number",min:1e3,max:2e6,step:1e3,value:R,onChange:l=>b(Number(l.target.value)||128e3)}),e.jsx("p",{className:"mdocs-agent-field-hint",children:t("agentConfigContextWindowDesc")})]})]}),r==="create"&&m.length>0?e.jsxs("label",{className:"mdocs-agent-config-default-check",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:l=>F(l.target.checked)}),e.jsx("span",{children:"保存后设为默认配置"})]}):null,W?e.jsx("p",{className:"mdocs-agent-config-error",children:W}):null,e.jsxs("div",{className:"mdocs-agent-config-actions",children:[e.jsx("button",{type:"button",onClick:()=>void pe(),disabled:q,children:t(q?"saving":"save")}),m.length>0?e.jsx("button",{type:"button",className:"secondary",onClick:se,disabled:q,children:t("cancel")}):null]})]})]}):V?e.jsx("div",{className:"mdocs-settings-card mdocs-agent-config-card",children:e.jsx("p",{className:"mdocs-agent-config-muted",children:t("loading")})}):null]}),O?e.jsx(Ke,{title:"删除配置",message:`确定删除「${Le(O)}」?${O.isDefault&&m.length>1?" 删除后将自动把另一条设为默认。":""}`,confirmLabel:"删除",cancelLabel:t("cancel"),onConfirm:()=>void he(),onCancel:()=>ae(null)}):null]})}const et=/^[A-Za-z0-9_]+$/;function be(t){return et.test(t.trim())}function st(){const t=a.useRef(!0),[s,v]=a.useState([]),[u,m]=a.useState(!0),[z,r]=a.useState(null),[N,j]=a.useState(null),[k,n]=a.useState(!1),[y,h]=a.useState(""),[I,S]=a.useState(""),[p,f]=a.useState(""),[A,M]=a.useState(!1);a.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]);async function C(){m(!0),r(null);try{const d=await Ss();if(!t.current)return;v(d)}catch(d){if(!t.current)return;r(d instanceof Error?d.message:String(d))}finally{t.current&&m(!1)}}a.useEffect(()=>{C()},[]);function E(){n(!0),j(null),h(""),S(""),f(""),r(null)}function B(d){n(!1),j(d.id),h(d.name),S(d.description),f(d.body),r(null)}function R(){n(!1),j(null),h(""),S(""),f("")}async function b(){const d=y.trim();if(!be(d)){r("名称仅允许英文、数字、下划线");return}if(!p.trim()){r("正文不能为空");return}M(!0),r(null);try{if(k?await Cs({name:d,description:I,body:p}):N&&await Ds(N,{name:d,description:I,body:p}),!t.current)return;R(),await C()}catch(c){if(!t.current)return;r(c instanceof Error?c.message:String(c))}finally{t.current&&M(!1)}}async function T(d){if(window.confirm("删除该 Skill?已引用的历史轮次将跳过缺失项。")){r(null);try{if(await Is(d),!t.current)return;N===d&&R(),await C()}catch(c){if(!t.current)return;r(c instanceof Error?c.message:String(c))}}}const w=k||N!==null,P=!y.trim()||be(y);return e.jsxs("div",{className:"mdocs-agent-skills-panel",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsxs("h2",{className:"mdocs-settings-title",children:["Agent Skills",!u&&s.length>0?e.jsx("span",{className:"mdocs-agent-skills-count",children:s.length}):null]}),w?null:e.jsx("button",{type:"button",className:"secondary",onClick:E,children:"新建"})]}),e.jsx("div",{className:"mdocs-settings-cards",children:e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("p",{className:"mdocs-settings-item-desc mdocs-agent-skills-lead",children:"私人提示词宏。名称对本账号唯一,仅英文、数字、下划线;智能助手 / 帮写里按名称引用。"}),z?e.jsx("p",{className:"mdocs-agent-skills-error",children:z}):null,w?e.jsxs("div",{className:"mdocs-agent-skills-form",children:[e.jsx("div",{className:"mdocs-agent-skills-form-head",children:e.jsx("strong",{children:k?"新建 Skill":"编辑 Skill"})}),e.jsxs("label",{className:"mdocs-agent-skills-field",children:[e.jsx("span",{children:"名称"}),e.jsx("input",{type:"text",value:y,onChange:d=>h(d.target.value),maxLength:64,spellCheck:!1,autoComplete:"off",placeholder:"e.g. weekly_report",className:P?void 0:"mdocs-agent-skills-input-invalid"}),P?e.jsx("span",{className:"mdocs-agent-skills-hint",children:"引用与索引键,保存后按此名称使用"}):e.jsx("span",{className:"mdocs-agent-skills-hint-bad",children:"仅允许 A–Z、a–z、0–9、_"})]}),e.jsxs("label",{className:"mdocs-agent-skills-field",children:[e.jsx("span",{children:"简介(可选)"}),e.jsx("input",{type:"text",value:I,onChange:d=>S(d.target.value),maxLength:200,placeholder:"一句话说明用途"})]}),e.jsxs("label",{className:"mdocs-agent-skills-field",children:[e.jsx("span",{children:"正文"}),e.jsx("textarea",{value:p,onChange:d=>f(d.target.value),rows:10,placeholder:"写入 Agent 应遵守的步骤与约束…"})]}),e.jsxs("div",{className:"mdocs-agent-config-actions",children:[e.jsx("button",{type:"button",onClick:()=>void b(),disabled:A||!P||!y.trim()||!p.trim(),children:A?"保存中…":"保存"}),e.jsx("button",{type:"button",className:"secondary",onClick:R,disabled:A,children:"取消"})]})]}):null,u?e.jsx("p",{className:"mdocs-settings-item-desc",children:"加载中…"}):null,!u&&s.length===0&&!w?e.jsxs("div",{className:"mdocs-agent-skills-empty",children:[e.jsx("p",{children:"还没有 Skill"}),e.jsx("button",{type:"button",className:"secondary",onClick:E,children:"新建第一个"})]}):null,!u&&s.length>0?e.jsx("ul",{className:"mdocs-agent-skills-list",children:s.map(d=>{const c=be(d.name),g=N===d.id;return e.jsxs("li",{className:"mdocs-agent-skills-item"+(g?" mdocs-agent-skills-item-active":""),children:[e.jsxs("div",{className:"mdocs-agent-skills-item-main",children:[e.jsxs("div",{className:"mdocs-agent-skills-item-title-row",children:[e.jsx("code",{className:"mdocs-agent-skills-name",children:d.name}),c?null:e.jsx("span",{className:"mdocs-agent-skills-badge-warn",title:"名称含非法字符,请编辑改为英文数字下划线",children:"需改名"})]}),e.jsx("span",{className:"mdocs-agent-skills-desc",children:d.description.trim()||"无简介"})]}),e.jsxs("div",{className:"mdocs-agent-skills-item-actions",children:[e.jsx("button",{type:"button",className:"secondary small",onClick:()=>B(d),disabled:w&&!g,children:"编辑"}),e.jsx("button",{type:"button",className:"secondary small",onClick:()=>void T(d.id),disabled:w,children:"删除"})]})]},d.id)})}):null]})})]})}function Re(t,s){const v=localStorage.getItem(t);return v===null?s:v==="true"}function rt(t){const{t:s,lang:v,setLang:u}=te(),{onBack:m,onPublishDraft:z}=t,r=Ts(),[N,j]=a.useState(!1),k=a.useRef(!0);a.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]),a.useEffect(()=>{r||j(!1)},[r]);const[n,y]=a.useState(()=>Re("mdocs.autoPublish",!1)),[h,I]=a.useState(()=>Re("mdocs.autoEdit",!0)),[S,p]=a.useState(!1),[f,A]=a.useState("general");function M(i){A(i),r&&j(!1)}const C=s(f==="general"?"general":f==="bookmarks"?"bookmarkTitle":f==="myDocuments"?"myDocuments":f==="domainManagement"?"domainManagement":f==="memberTemplates"?"memberTemplates":f==="agentConfig"?"agentConfig":"saveAndPublish"),[E,B]=a.useState([]),[R,b]=a.useState(!0),[T,w]=a.useState(null),[P,d]=a.useState(!1),[c,g]=a.useState(!1),[D,F]=a.useState(!1),[V,H]=a.useState(!1),[q,G]=a.useState(null),[W,x]=a.useState(!1),[$,U]=a.useState(!1),[Z,Q]=a.useState(!1),[o,L]=a.useState(""),[O,ae]=a.useState(!1),[re,ie]=a.useState(!1),[le,X]=a.useState(0),[ee,oe]=a.useState([]),[me,de]=a.useState(!1),[se,ue]=a.useState(""),[he,pe]=a.useState([]),[ce,l]=a.useState(!1),[_,ve]=a.useState(""),[Oe,Ve]=a.useState([]),[Ue,ge]=a.useState(!1),[fe,ke]=a.useState(null),[xe,we]=a.useState(new Map);a.useEffect(()=>{localStorage.setItem("mdocs.autoPublish",String(n))},[n]),a.useEffect(()=>{localStorage.setItem("mdocs.autoEdit",String(h))},[h]),a.useEffect(()=>{f==="savePublish"&&ye().then(i=>{k.current&&X(i.filter(K=>!K.published).length)})},[f]),a.useEffect(()=>{f==="bookmarks"&&We(),f==="myDocuments"&&De()},[f]),a.useEffect(()=>{Ce()},[]),a.useEffect(()=>{Fe().then(i=>{k.current&&Ve(i)}).catch(()=>{})},[]);const Se=new Map(Oe.map(i=>[i.domainId,i.domainName]));async function Ce(){try{b(!0);const i=await As();if(!k.current)return;B(i)}catch{}finally{k.current&&b(!1)}}async function We(){try{de(!0);const i=await Es();if(!k.current)return;oe(i)}catch{}finally{k.current&&de(!1)}}async function De(){try{l(!0);const i=await Ps();if(!k.current)return;pe(i)}catch{}finally{k.current&&l(!1)}}async function _e(i){try{await Ks(i),oe(K=>K.filter(ne=>ne.documentId!==i))}catch{}}function He(){if(E.some(K=>!K.revoked)){g(!0);return}Ie()}async function Ie(){try{d(!0);const i=await Os();w({token:i.token,name:i.name}),await Ce()}finally{d(!1)}}async function qe(){try{Q(!0);const i=await Fs();G(i.recoveryCode)}finally{Q(!1)}}async function Ge(i){i.preventDefault();const K=o.trim();if(!(K&&K.length<4))try{ae(!0),await Bs(K),L(""),ie(!0),setTimeout(()=>ie(!1),3e3)}finally{ae(!1)}}async function Ze(i){ke(i);try{const K=await $s(i),ne=new Map;K.forEach(Y=>{ne.set(Y.visitorId,Y.permission)}),we(ne)}catch{we(new Map)}ge(!0)}async function Ye(i){if(fe)try{const K=new Set(i.map(Y=>Y.visitorId)),ne=new Set(xe.keys());for(const Y of ne)K.has(Y)||await Vs(fe,Y);for(const Y of i)await Us(fe,Y.visitorId,Y.permission);await De()}finally{ge(!1),ke(null)}}const Te=ee.filter(i=>{if(!se.trim())return!0;const K=se.toLowerCase();return(i.displayName||i.relativePath||"").toLowerCase().includes(K)||(i.ownerVisitorName||"").toLowerCase().includes(K)||(i.domainId||"").toLowerCase().includes(K)}),Ae=he.filter(i=>{if(!_.trim())return!0;const K=_.toLowerCase();return(i.displayName||i.relativePath||"").toLowerCase().includes(K)||(i.domainId||"").toLowerCase().includes(K)});return e.jsxs("div",{className:"mdocs-layout"+(r?" mdocs-layout--reader mdocs-layout--settings":""),children:[r&&N?e.jsx("button",{type:"button",className:"mdocs-mobile-nav-scrim","aria-label":s("collapseSidebar"),onClick:()=>j(!1)}):null,e.jsxs("aside",{className:"mdocs-sidebar"+(r?N?" mdocs-sidebar--drawer-open":" mdocs-sidebar--drawer":""),children:[e.jsxs("header",{className:"mdocs-sidebar-header",children:[e.jsxs("div",{className:"mdocs-brand",children:[e.jsx("img",{src:Ms,alt:s("brand"),className:"mdocs-brand-logo"}),e.jsx("span",{children:s("brand")})]}),r?e.jsx("button",{type:"button",className:"mdocs-sidebar-toggle",onClick:()=>j(!1),"aria-label":s("collapseSidebar"),style:{background:"none",border:"none",cursor:"pointer",padding:"6px",color:"var(--mdocs-text-muted, #999)",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Ls,{size:18})}):null]}),e.jsxs("nav",{className:"mdocs-config-tree",children:[e.jsx("div",{className:"mdocs-config-item"+(f==="general"?" active":""),onClick:()=>M("general"),children:s("general")}),e.jsx("div",{className:"mdocs-config-item"+(f==="bookmarks"?" active":""),onClick:()=>M("bookmarks"),children:s("bookmarkTitle")}),e.jsx("div",{className:"mdocs-config-item"+(f==="myDocuments"?" active":""),onClick:()=>M("myDocuments"),children:s("myDocuments")}),e.jsx("div",{className:"mdocs-config-item"+(f==="domainManagement"?" active":""),onClick:()=>M("domainManagement"),children:s("domainManagement")}),e.jsx("div",{className:"mdocs-config-item"+(f==="memberTemplates"?" active":""),onClick:()=>M("memberTemplates"),children:s("memberTemplates")}),e.jsx("div",{className:"mdocs-config-item"+(f==="agentConfig"?" active":""),onClick:()=>M("agentConfig"),children:s("agentConfig")}),e.jsx("div",{className:"mdocs-config-item"+(f==="savePublish"?" active":""),onClick:()=>M("savePublish"),children:s("saveAndPublish")})]}),e.jsx("footer",{className:"mdocs-settings-sidebar-footer",onClick:m,children:s("backToDocs")})]}),e.jsxs("main",{className:"mdocs-main",children:[r?e.jsxs("div",{className:"mdocs-settings-mobile-bar",children:[e.jsx("button",{type:"button",className:"mdocs-reader-nav-btn",onClick:()=>j(!0),"aria-label":s("expandSidebar"),children:e.jsx(Rs,{size:18,strokeWidth:1.75})}),e.jsx("span",{className:"mdocs-settings-mobile-bar-title",children:C})]}):null,zs(),f==="general"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("general")})}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsx("span",{className:"mdocs-settings-item-info",children:e.jsx("span",{className:"mdocs-settings-card-title",children:s("language")})}),e.jsxs("span",{className:"mdocs-settings-lang",children:[e.jsx("button",{type:"button",className:v==="en"?"active":"",onClick:()=>u("en"),children:"EN"}),e.jsx("span",{children:"/"}),e.jsx("button",{type:"button",className:v==="zh"?"active":"",onClick:()=>u("zh"),children:"中"})]})]})}),e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoEdit")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoEditDesc")})]}),e.jsx("button",{type:"button",className:"mdocs-toggle"+(h?" active":""),role:"switch","aria-checked":h,onClick:()=>I(i=>!i),children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsxs("div",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("cliToken")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("cliTokenDesc")}),!R&&E.length>0&&e.jsx("span",{className:"mdocs-settings-item-desc",style:{marginTop:8,fontSize:"0.85em",opacity:.8},children:E.map(i=>e.jsxs("span",{style:{display:"block"},children:[i.name," — ",new Date(i.createdAt).toLocaleString()," ",i.revoked?`(${s("cliTokenRevoked")})`:`(${s("cliTokenActive")})`]},i.tokenId))})]}),e.jsx("button",{type:"button",className:"secondary",onClick:He,disabled:P||R,children:P?"…":E.some(i=>!i.revoked)?s("cliTokenReset"):s("cliTokenCreate")})]}),T&&e.jsxs("div",{className:"mdocs-settings-secret-result mdocs-settings-secret-result--ok",children:[e.jsxs("div",{className:"mdocs-settings-secret-result-head",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("cliTokenGenerated")}),e.jsx("span",{className:"mdocs-settings-secret-value",children:T.token})]}),e.jsxs("div",{className:"mdocs-settings-secret-result-actions",children:[e.jsx("button",{type:"button",className:"secondary",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(T.token),H(!1),F(!0),window.setTimeout(()=>F(!1),2e3)}catch{F(!1),H(!0),window.setTimeout(()=>H(!1),3e3)}})()},children:s(D?"cliTokenCopied":"cliTokenCopy")}),e.jsx("button",{type:"button",onClick:()=>w(null),children:s("close")})]}),D&&e.jsxs("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--ok",role:"status",children:["✓ ",s("cliTokenCopied")]}),V&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--err",role:"status",children:s("cliTokenCopyFailed")})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsxs("div",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔑 恢复码"}),e.jsx("span",{className:"mdocs-settings-item-desc",children:"当 Token 丢失时,可用恢复码找回身份。生成后请立即保存,仅显示一次。"})]}),e.jsx("button",{type:"button",className:"secondary",onClick:qe,disabled:Z,children:Z?"…":"生成恢复码"})]}),q&&e.jsxs("div",{className:"mdocs-settings-secret-result mdocs-settings-secret-result--warn",children:[e.jsxs("div",{className:"mdocs-settings-secret-result-head",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔑 你的恢复码"}),e.jsx("span",{className:"mdocs-settings-item-desc",style:{marginTop:8},children:"请立即复制保存,关闭后不可再查看。"}),e.jsx("div",{className:"mdocs-settings-secret-code",children:q})]}),e.jsxs("div",{className:"mdocs-settings-secret-result-actions",children:[e.jsx("button",{type:"button",className:"primary",onClick:()=>{(async()=>{try{await navigator.clipboard.writeText(q),U(!1),x(!0),window.setTimeout(()=>x(!1),2e3)}catch{x(!1),U(!0),window.setTimeout(()=>U(!1),3e3)}})()},children:W?"已复制":"复制恢复码"}),e.jsx("button",{type:"button",onClick:()=>G(null),children:s("close")})]}),W&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--ok",role:"status",children:"✓ 已复制到剪贴板"}),$&&e.jsx("div",{className:"mdocs-settings-copy-feedback mdocs-settings-copy-feedback--err",role:"status",children:"复制失败,请手动选中上方内容复制"})]})]}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("div",{className:"mdocs-settings-item",children:e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:"🔐 登录密码"}),e.jsx("span",{className:"mdocs-settings-item-desc",children:"设置密码后,可在其他浏览器或设备用「用户名+密码」登录。"})]})}),e.jsxs("form",{onSubmit:Ge,style:{marginTop:12},children:[e.jsx("input",{type:"password",placeholder:"输入新密码(至少 4 位,留空则清除密码)",value:o,onChange:i=>L(i.target.value),minLength:0,style:{marginBottom:8}}),re&&e.jsx("div",{style:{color:"#4caf50",marginBottom:8,fontSize:"0.875rem"},children:"✓ 密码设置成功"}),e.jsx("button",{type:"submit",className:"secondary",disabled:O,children:O?"设置中…":"保存密码"})]})]})]})]}):f==="bookmarks"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("bookmarkTitle")})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("input",{type:"text",className:"mdocs-settings-search",placeholder:s("bookmarkSearch"),value:se,onChange:i=>ue(i.target.value)}),me?e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:s("loading")}):e.jsx(e.Fragment,{children:Te.length===0?e.jsx("div",{style:{textAlign:"center",padding:"40px 0",opacity:.6},children:s(se?"bookmarkNoMatch":"bookmarkEmpty")}):e.jsx("div",{className:"mdocs-settings-table-wrap",children:e.jsxs("table",{className:"mdocs-settings-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("bookmarkColTitle")}),e.jsx("th",{children:s("bookmarkColDomain")}),e.jsx("th",{children:s("bookmarkColAuthor")}),e.jsx("th",{children:s("bookmarkColTime")}),e.jsx("th",{style:{textAlign:"right"}})]})}),e.jsx("tbody",{children:Te.map(i=>e.jsxs("tr",{children:[e.jsx("td",{style:{cursor:"pointer",fontWeight:500},onClick:()=>t.onOpenDocument(i.documentId),children:i.displayName||i.relativePath||"Untitled"}),e.jsx("td",{children:i.isDeleted?e.jsx("span",{style:{opacity:.5,fontStyle:"italic"},children:"已删除"}):Se.get(i.domainId||"")||i.domainId||"—"}),e.jsx("td",{children:i.ownerVisitorName||"—"}),e.jsx("td",{children:new Date(i.bookmarkedAt).toLocaleDateString()}),e.jsx("td",{style:{textAlign:"right"},children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>_e(i.documentId),children:s("bookmarkRemove")})})]},i.documentId))})]})})})]})]}):f==="myDocuments"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx("div",{className:"mdocs-settings-header",children:e.jsx("h2",{className:"mdocs-settings-title",children:s("myDocuments")})}),e.jsxs("div",{className:"mdocs-settings-card",children:[e.jsx("input",{type:"text",className:"mdocs-settings-search",placeholder:"搜索文章…",value:_,onChange:i=>ve(i.target.value)}),ce?e.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:s("loading")}):e.jsx(e.Fragment,{children:Ae.length===0?e.jsx("div",{style:{textAlign:"center",padding:"40px 0",opacity:.6},children:s(_?"myDocumentsNoMatch":"myDocumentsEmpty")}):e.jsx("div",{className:"mdocs-settings-table-wrap",children:e.jsxs("table",{className:"mdocs-settings-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("myDocumentsColTitle")}),e.jsx("th",{children:s("myDocumentsColDomain")}),e.jsx("th",{children:s("myDocumentsColUpdated")}),e.jsx("th",{children:s("myDocumentsColCreated")}),e.jsx("th",{colSpan:2})]})}),e.jsx("tbody",{children:Ae.map(i=>e.jsxs("tr",{children:[e.jsx("td",{style:{cursor:"pointer",fontWeight:500},onClick:()=>t.onOpenDocument(i.documentId),children:i.displayName||i.relativePath||"Untitled"}),e.jsx("td",{children:Se.get(i.domainId||"")||i.domainId||"—"}),e.jsx("td",{children:new Date(i.updatedAt).toLocaleDateString()}),e.jsx("td",{children:new Date(i.createdAt).toLocaleDateString()}),e.jsx("td",{style:{textAlign:"right"},children:e.jsx("button",{type:"button",className:"secondary small",onClick:()=>Ze(i.documentId),children:s("docInfoInviteMember")})}),e.jsx("td",{style:{textAlign:"right",paddingLeft:0},children:e.jsx("button",{type:"button",className:"primary small",onClick:()=>t.onOpenDocument(i.documentId),children:s("bookmarkOpen")})})]},i.documentId))})]})})})]})]}):f==="domainManagement"?e.jsx(Gs,{}):f==="memberTemplates"?e.jsx(Zs,{}):f==="agentConfig"?e.jsxs("div",{className:"mdocs-settings",children:[e.jsx(Xs,{}),e.jsx(st,{})]}):e.jsxs("div",{className:"mdocs-settings",children:[e.jsxs("div",{className:"mdocs-settings-header",children:[e.jsx("h2",{className:"mdocs-settings-title",children:s("saveAndPublish")}),e.jsx("button",{type:"button",className:"secondary",onClick:m,children:s("backToDocs")})]}),e.jsxs("div",{className:"mdocs-settings-cards",children:[e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoSave")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoSaveAlwaysOnDesc")})]}),e.jsx("span",{className:"mdocs-toggle active",role:"switch","aria-checked":"true","aria-disabled":"true",style:{opacity:.6,cursor:"not-allowed"},children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),e.jsx("div",{className:"mdocs-settings-card",children:e.jsxs("label",{className:"mdocs-settings-item",children:[e.jsxs("span",{className:"mdocs-settings-item-info",children:[e.jsx("span",{className:"mdocs-settings-card-title",children:s("autoPublish")}),e.jsx("span",{className:"mdocs-settings-item-desc",children:s("autoPublishDesc")})]}),e.jsx("button",{type:"button",className:"mdocs-toggle"+(n?" active":""),role:"switch","aria-checked":n,onClick:()=>y(i=>!i),children:e.jsx("span",{className:"mdocs-toggle-knob"})})]})}),le>0?e.jsxs("button",{className:"mdocs-settings-card mdocs-settings-draft-link",onClick:()=>p(!0),children:[e.jsxs("span",{className:"mdocs-settings-draft-link-text",children:["📄 ",s("viewDrafts")," (",le,")"]}),e.jsx("span",{className:"mdocs-settings-draft-arrow","aria-hidden":"true",children:"›"})]}):e.jsx("div",{className:"mdocs-settings-card mdocs-settings-draft-empty",children:e.jsx("span",{className:"mdocs-settings-item-desc",children:s("noDrafts")})})]})]}),S&&e.jsx(Hs,{onPublish:z,onClose:()=>p(!1),onCountChange:X,onRecover:t.onRecoverDraft})]}),c&&e.jsx(Ke,{title:s("cliToken"),message:s("cliTokenResetConfirm"),confirmLabel:s("cliTokenReset"),cancelLabel:s("cancel"),busy:P,onConfirm:()=>{g(!1),Ie()},onCancel:()=>g(!1)}),e.jsx($e,{open:Ue,title:s("docInfoInviteMember"),initialSelectedIds:[...xe.keys()],initialPermissions:xe,templates:[],showPermissionSelect:!0,permissionOptions:[{value:"read",label:s("invitePermissionRead")},{value:"edit",label:s("invitePermissionEdit")}],onClose:()=>ge(!1),onConfirm:i=>{Ye(i)}})]})}export{rt as SettingsPage};
|