@imenam/mcp-documentor 1.0.94 → 1.0.95
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/README.md +24 -2
- package/dist/shared/read-only.js +1 -0
- package/dist/shared/schemas/doc.schema.d.ts +20 -0
- package/dist/shared/schemas/doc.schema.js +20 -0
- package/dist/src/core/comment-store.d.ts +87 -0
- package/dist/src/core/comment-store.js +189 -0
- package/dist/src/core/markdown-text.d.ts +7 -0
- package/dist/src/core/markdown-text.js +16 -0
- package/dist/src/core/publication-store.d.ts +4 -0
- package/dist/src/core/publication-store.js +6 -0
- package/dist/src/gui-worker.js +87 -5
- package/dist/src/index.js +180 -1
- package/dist/src/tools/comments.d.ts +29 -0
- package/dist/src/tools/comments.js +104 -0
- package/gui/dist/assets/{DocContent-B2hgJIHP.js → DocContent-D2Pgvsaw.js} +87 -87
- package/gui/dist/assets/{arc-3c1bsell.js → arc-ytJX8b9b.js} +1 -1
- package/gui/dist/assets/{architectureDiagram-3BPJPVTR-gOvE5Nh-.js → architectureDiagram-3BPJPVTR-vChxNmWw.js} +1 -1
- package/gui/dist/assets/{blockDiagram-GPEHLZMM-d2PyOGgB.js → blockDiagram-GPEHLZMM-D19nVYke.js} +1 -1
- package/gui/dist/assets/{c4Diagram-AAUBKEIU-Fq_MnzGd.js → c4Diagram-AAUBKEIU-7kCjxzBQ.js} +1 -1
- package/gui/dist/assets/channel-DegAVRd2.js +1 -0
- package/gui/dist/assets/{chunk-2J33WTMH-C8rPGvzC.js → chunk-2J33WTMH-CrEHZokt.js} +1 -1
- package/gui/dist/assets/{chunk-4BX2VUAB-CMO6CGqC.js → chunk-4BX2VUAB-AGQbPC36.js} +1 -1
- package/gui/dist/assets/{chunk-55IACEB6-ewoEucdu.js → chunk-55IACEB6-1dY_RrZJ.js} +1 -1
- package/gui/dist/assets/{chunk-727SXJPM-DVlayzbx.js → chunk-727SXJPM-DFrVc2F4.js} +1 -1
- package/gui/dist/assets/{chunk-AQP2D5EJ-CahwsWX2.js → chunk-AQP2D5EJ-Bf5AjFYW.js} +1 -1
- package/gui/dist/assets/{chunk-FMBD7UC4-CTfqQvPB.js → chunk-FMBD7UC4-ytPdLd3c.js} +1 -1
- package/gui/dist/assets/{chunk-ND2GUHAM-D16nBstn.js → chunk-ND2GUHAM-MQj2MK8N.js} +1 -1
- package/gui/dist/assets/{chunk-QZHKN3VN-BhYm6b_1.js → chunk-QZHKN3VN-BFpijhFi.js} +1 -1
- package/gui/dist/assets/classDiagram-4FO5ZUOK-C8gjytbe.js +1 -0
- package/gui/dist/assets/classDiagram-v2-Q7XG4LA2-C8gjytbe.js +1 -0
- package/gui/dist/assets/{cose-bilkent-S5V4N54A-BMWhCTQz.js → cose-bilkent-S5V4N54A-DydPBClW.js} +1 -1
- package/gui/dist/assets/{dagre-BM42HDAG-B8q9fjYt.js → dagre-BM42HDAG-Dt1NYir9.js} +1 -1
- package/gui/dist/assets/{diagram-2AECGRRQ-BEQd6l9g.js → diagram-2AECGRRQ-By8731FV.js} +1 -1
- package/gui/dist/assets/{diagram-5GNKFQAL-CYSk25NC.js → diagram-5GNKFQAL-6DboNPr2.js} +1 -1
- package/gui/dist/assets/{diagram-KO2AKTUF-pYuzMimB.js → diagram-KO2AKTUF-BlsHXUTP.js} +1 -1
- package/gui/dist/assets/{diagram-LMA3HP47-Coes1K5H.js → diagram-LMA3HP47-NlfihhmZ.js} +1 -1
- package/gui/dist/assets/{diagram-OG6HWLK6-B9QD3Aih.js → diagram-OG6HWLK6-BuPvvcLW.js} +1 -1
- package/gui/dist/assets/{erDiagram-TEJ5UH35-BaTQh6lK.js → erDiagram-TEJ5UH35-Bwh4WcoJ.js} +1 -1
- package/gui/dist/assets/{flowDiagram-I6XJVG4X-CD3j0V3z.js → flowDiagram-I6XJVG4X-Cpo3jFt_.js} +1 -1
- package/gui/dist/assets/{ganttDiagram-6RSMTGT7-CI8luwIp.js → ganttDiagram-6RSMTGT7-MTzCwVCF.js} +4 -4
- package/gui/dist/assets/{gitGraphDiagram-PVQCEYII-CZicCj5w.js → gitGraphDiagram-PVQCEYII-TGZH1N13.js} +1 -1
- package/gui/dist/assets/{infoDiagram-5YYISTIA-BBBZLBfU.js → infoDiagram-5YYISTIA-CjtHqsAF.js} +1 -1
- package/gui/dist/assets/{ishikawaDiagram-YF4QCWOH-JzhvbF8X.js → ishikawaDiagram-YF4QCWOH-BubX7AqP.js} +1 -1
- package/gui/dist/assets/{journeyDiagram-JHISSGLW-z2Fq1AWA.js → journeyDiagram-JHISSGLW-BT5Bu4px.js} +1 -1
- package/gui/dist/assets/{kanban-definition-UN3LZRKU-CsERU4RU.js → kanban-definition-UN3LZRKU-CyiNLbBC.js} +1 -1
- package/gui/dist/assets/{linear-bwdTeoS5.js → linear-rOmZOzd-.js} +1 -1
- package/gui/dist/assets/main-BvGBQ4na.css +1 -0
- package/gui/dist/assets/main-DqcEvJHv.js +10 -0
- package/gui/dist/assets/{mindmap-definition-RKZ34NQL-Hhnd5vi2.js → mindmap-definition-RKZ34NQL-Cvy4YAiE.js} +1 -1
- package/gui/dist/assets/{pieDiagram-4H26LBE5-DCSptoQo.js → pieDiagram-4H26LBE5-BKrVYqW5.js} +1 -1
- package/gui/dist/assets/public-BOnoF84L.js +1 -0
- package/gui/dist/assets/public-BmtG1Lfn.css +1 -0
- package/gui/dist/assets/{quadrantDiagram-W4KKPZXB-CFG_TBfZ.js → quadrantDiagram-W4KKPZXB-DG_N325e.js} +1 -1
- package/gui/dist/assets/{requirementDiagram-4Y6WPE33-DUHthbad.js → requirementDiagram-4Y6WPE33-oWqsr2x0.js} +1 -1
- package/gui/dist/assets/{sankeyDiagram-5OEKKPKP-CcivnX5S.js → sankeyDiagram-5OEKKPKP-B8uXp_JX.js} +1 -1
- package/gui/dist/assets/{sequenceDiagram-3UESZ5HK-DD3f-L7G.js → sequenceDiagram-3UESZ5HK-bZUsMsnM.js} +1 -1
- package/gui/dist/assets/{stateDiagram-AJRCARHV-DP6QuANT.js → stateDiagram-AJRCARHV-3o_sYDh3.js} +1 -1
- package/gui/dist/assets/stateDiagram-v2-BHNVJYJU-CfMfyWVZ.js +1 -0
- package/gui/dist/assets/{timeline-definition-PNZ67QCA-DpSvFfP9.js → timeline-definition-PNZ67QCA-BWMaBPME.js} +1 -1
- package/gui/dist/assets/{vennDiagram-CIIHVFJN-DU7Clt-k.js → vennDiagram-CIIHVFJN-BuBBjBVe.js} +1 -1
- package/gui/dist/assets/{wardley-L42UT6IY-By2c-zj1.js → wardley-L42UT6IY-Da4i2-Py.js} +1 -1
- package/gui/dist/assets/{wardleyDiagram-YWT4CUSO-BJeFdhb5.js → wardleyDiagram-YWT4CUSO-Cv3OBAYm.js} +1 -1
- package/gui/dist/assets/{xychartDiagram-2RQKCTM6-ZeDSX3nQ.js → xychartDiagram-2RQKCTM6-DFmCIdof.js} +1 -1
- package/gui/dist/index.html +3 -3
- package/gui/dist/public.html +3 -3
- package/package.json +5 -1
- package/gui/dist/assets/channel-D0TrBTBU.js +0 -1
- package/gui/dist/assets/classDiagram-4FO5ZUOK-BZarwo9C.js +0 -1
- package/gui/dist/assets/classDiagram-v2-Q7XG4LA2-BZarwo9C.js +0 -1
- package/gui/dist/assets/main-BB0ARNyc.js +0 -10
- package/gui/dist/assets/main-DDy8gF40.css +0 -1
- package/gui/dist/assets/public-Bds7tw8V.css +0 -1
- package/gui/dist/assets/public-D8L9bJEM.js +0 -1
- package/gui/dist/assets/stateDiagram-v2-BHNVJYJU-DCHGEDGQ.js +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{b9 as i,bN as No,b8 as O,bb as e,bm as ls,bp as tn,bq as sn,br as nn,bO as wo,bP as ko,bi as Co,be as Es,bf as $s,bg as Rs,bQ as Ps,bR as So,bS as Eo,bT as $o,bU as Ro,bV as Po,bW as an,bw as on,bt as is,bu as De,bn as rn,bX as Qt,bY as Do,bZ as ln,b_ as cn,bh as Lo,bj as To,bk as ct,bl as Mo,bv as Io,bs as Ao,bx as _o}from"./DocContent-D2Pgvsaw.js";var Ds="popstate";function Ls(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function zo(t={}){function s(o,r){let{pathname:l="/",search:c="",hash:d=""}=Ie(o.location.hash.substring(1));return!l.startsWith("/")&&!l.startsWith(".")&&(l="/"+l),Zt("",{pathname:l,search:c,hash:d},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(o,r){let l=o.document.querySelector("base"),c="";if(l&&l.getAttribute("href")){let d=o.location.href,h=d.indexOf("#");c=h===-1?d:d.slice(0,h)}return c+"#"+(typeof r=="string"?r:Ze(r))}function a(o,r){re(o.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(r)})`)}return Oo(s,n,a,t)}function X(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function re(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Fo(){return Math.random().toString(36).substring(2,10)}function Ts(t,s){return{usr:t.state,key:t.key,idx:s,masked:t.unstable_mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Zt(t,s,n=null,a,o){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof s=="string"?Ie(s):s,state:n,key:s&&s.key||a||Fo(),unstable_mask:o}}function Ze({pathname:t="/",search:s="",hash:n=""}){return s&&s!=="?"&&(t+=s.charAt(0)==="?"?s:"?"+s),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function Ie(t){let s={};if(t){let n=t.indexOf("#");n>=0&&(s.hash=t.substring(n),t=t.substring(0,n));let a=t.indexOf("?");a>=0&&(s.search=t.substring(a),t=t.substring(0,a)),t&&(s.pathname=t)}return s}function Oo(t,s,n,a={}){let{window:o=document.defaultView,v5Compat:r=!1}=a,l=o.history,c="POP",d=null,h=m();h==null&&(h=0,l.replaceState({...l.state,idx:h},""));function m(){return(l.state||{idx:null}).idx}function u(){c="POP";let g=m(),b=g==null?null:g-h;h=g,d&&d({action:c,location:j.location,delta:b})}function p(g,b){c="PUSH";let y=Ls(g)?g:Zt(j.location,g,b);n&&n(y,g),h=m()+1;let x=Ts(y,h),v=j.createHref(y.unstable_mask||y);try{l.pushState(x,"",v)}catch(w){if(w instanceof DOMException&&w.name==="DataCloneError")throw w;o.location.assign(v)}r&&d&&d({action:c,location:j.location,delta:1})}function f(g,b){c="REPLACE";let y=Ls(g)?g:Zt(j.location,g,b);n&&n(y,g),h=m();let x=Ts(y,h),v=j.createHref(y.unstable_mask||y);l.replaceState(x,"",v),r&&d&&d({action:c,location:j.location,delta:0})}function C(g){return Uo(g)}let j={get action(){return c},get location(){return t(o,l)},listen(g){if(d)throw new Error("A history only accepts one active listener");return o.addEventListener(Ds,u),d=g,()=>{o.removeEventListener(Ds,u),d=null}},createHref(g){return s(o,g)},createURL:C,encodeLocation(g){let b=C(g);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:p,replace:f,go(g){return l.go(g)}};return j}function Uo(t,s=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),X(n,"No window.location.(origin|href) available to create URL");let a=typeof t=="string"?t:Ze(t);return a=a.replace(/ $/,"%20"),!s&&a.startsWith("//")&&(a=n+a),new URL(a,n)}function dn(t,s,n="/"){return Ho(t,s,n,!1)}function Ho(t,s,n,a){let o=typeof s=="string"?Ie(s):s,r=xe(o.pathname||"/",n);if(r==null)return null;let l=un(t);Bo(l);let c=null;for(let d=0;c==null&&d<l.length;++d){let h=er(r);c=Qo(l[d],h,a)}return c}function un(t,s=[],n=[],a="",o=!1){let r=(l,c,d=o,h)=>{let m={relativePath:h===void 0?l.path||"":h,caseSensitive:l.caseSensitive===!0,childrenIndex:c,route:l};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(a)&&d)return;X(m.relativePath.startsWith(a),`Absolute route path "${m.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(a.length)}let u=ue([a,m.relativePath]),p=n.concat(m);l.children&&l.children.length>0&&(X(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${u}".`),un(l.children,s,p,u,d)),!(l.path==null&&!l.index)&&s.push({path:u,score:Yo(u,l.index),routesMeta:p})};return t.forEach((l,c)=>{if(l.path===""||!l.path?.includes("?"))r(l,c);else for(let d of hn(l.path))r(l,c,!0,d)}),s}function hn(t){let s=t.split("/");if(s.length===0)return[];let[n,...a]=s,o=n.endsWith("?"),r=n.replace(/\?$/,"");if(a.length===0)return o?[r,""]:[r];let l=hn(a.join("/")),c=[];return c.push(...l.map(d=>d===""?r:[r,d].join("/"))),o&&c.push(...l),c.map(d=>t.startsWith("/")&&d===""?"/":d)}function Bo(t){t.sort((s,n)=>s.score!==n.score?n.score-s.score:Xo(s.routesMeta.map(a=>a.childrenIndex),n.routesMeta.map(a=>a.childrenIndex)))}var Wo=/^:[\w-]+$/,Vo=3,qo=2,Go=1,Ko=10,Jo=-2,Ms=t=>t==="*";function Yo(t,s){let n=t.split("/"),a=n.length;return n.some(Ms)&&(a+=Jo),s&&(a+=qo),n.filter(o=>!Ms(o)).reduce((o,r)=>o+(Wo.test(r)?Vo:r===""?Go:Ko),a)}function Xo(t,s){return t.length===s.length&&t.slice(0,-1).every((a,o)=>a===s[o])?t[t.length-1]-s[s.length-1]:0}function Qo(t,s,n=!1){let{routesMeta:a}=t,o={},r="/",l=[];for(let c=0;c<a.length;++c){let d=a[c],h=c===a.length-1,m=r==="/"?s:s.slice(r.length)||"/",u=bt({path:d.relativePath,caseSensitive:d.caseSensitive,end:h},m),p=d.route;if(!u&&h&&n&&!a[a.length-1].route.index&&(u=bt({path:d.relativePath,caseSensitive:d.caseSensitive,end:!1},m)),!u)return null;Object.assign(o,u.params),l.push({params:o,pathname:ue([r,u.pathname]),pathnameBase:ar(ue([r,u.pathnameBase])),route:p}),u.pathnameBase!=="/"&&(r=ue([r,u.pathnameBase]))}return l}function bt(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,a]=Zo(t.path,t.caseSensitive,t.end),o=s.match(n);if(!o)return null;let r=o[0],l=r.replace(/(.)\/+$/,"$1"),c=o.slice(1);return{params:a.reduce((h,{paramName:m,isOptional:u},p)=>{if(m==="*"){let C=c[p]||"";l=r.slice(0,r.length-C.length).replace(/(.)\/+$/,"$1")}const f=c[p];return u&&!f?h[m]=void 0:h[m]=(f||"").replace(/%2F/g,"/"),h},{}),pathname:r,pathnameBase:l,pattern:t}}function Zo(t,s=!1,n=!0){re(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let a=[],o="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,c,d,h,m)=>{if(a.push({paramName:c,isOptional:d!=null}),d){let u=m.charAt(h+l.length);return u&&u!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(a.push({paramName:"*"}),o+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":t!==""&&t!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,s?void 0:"i"),a]}function er(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return re(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${s}).`),t}}function xe(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let n=s.endsWith("/")?s.length-1:s.length,a=t.charAt(n);return a&&a!=="/"?null:t.slice(n)||"/"}var tr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function sr(t,s="/"){let{pathname:n,search:a="",hash:o=""}=typeof t=="string"?Ie(t):t,r;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?r=Is(n.substring(1),"/"):r=Is(n,s)):r=s,{pathname:r,search:or(a),hash:rr(o)}}function Is(t,s){let n=s.replace(/\/+$/,"").split("/");return t.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function Bt(t,s,n,a){return`Cannot include a '${t}' character in a manually specified \`to.${s}\` field [${JSON.stringify(a)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function nr(t){return t.filter((s,n)=>n===0||s.route.path&&s.route.path.length>0)}function mn(t){let s=nr(t);return s.map((n,a)=>a===s.length-1?n.pathname:n.pathnameBase)}function cs(t,s,n,a=!1){let o;typeof t=="string"?o=Ie(t):(o={...t},X(!o.pathname||!o.pathname.includes("?"),Bt("?","pathname","search",o)),X(!o.pathname||!o.pathname.includes("#"),Bt("#","pathname","hash",o)),X(!o.search||!o.search.includes("#"),Bt("#","search","hash",o)));let r=t===""||o.pathname==="",l=r?"/":o.pathname,c;if(l==null)c=n;else{let u=s.length-1;if(!a&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),u-=1;o.pathname=p.join("/")}c=u>=0?s[u]:"/"}let d=sr(o,c),h=l&&l!=="/"&&l.endsWith("/"),m=(r||l===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(h||m)&&(d.pathname+="/"),d}var ue=t=>t.join("/").replace(/\/\/+/g,"/"),ar=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),or=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,rr=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,lr=class{constructor(t,s,n,a=!1){this.status=t,this.statusText=s||"",this.internal=a,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function ir(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function cr(t){return t.map(s=>s.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var pn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function fn(t,s){let n=t;if(typeof n!="string"||!tr.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let a=n,o=!1;if(pn)try{let r=new URL(window.location.href),l=n.startsWith("//")?new URL(r.protocol+n):new URL(n),c=xe(l.pathname,s);l.origin===r.origin&&c!=null?n=c+l.search+l.hash:o=!0}catch{re(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:a,isExternal:o,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var gn=["POST","PUT","PATCH","DELETE"];new Set(gn);var dr=["GET",...gn];new Set(dr);var Ae=i.createContext(null);Ae.displayName="DataRouter";var Ct=i.createContext(null);Ct.displayName="DataRouterState";var ur=i.createContext(!1),xn=i.createContext({isTransitioning:!1});xn.displayName="ViewTransition";var hr=i.createContext(new Map);hr.displayName="Fetchers";var mr=i.createContext(null);mr.displayName="Await";var ae=i.createContext(null);ae.displayName="Navigation";var St=i.createContext(null);St.displayName="Location";var ve=i.createContext({outlet:null,matches:[],isDataRoute:!1});ve.displayName="Route";var ds=i.createContext(null);ds.displayName="RouteError";var vn="REACT_ROUTER_ERROR",pr="REDIRECT",fr="ROUTE_ERROR_RESPONSE";function gr(t){if(t.startsWith(`${vn}:${pr}:{`))try{let s=JSON.parse(t.slice(28));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string"&&typeof s.location=="string"&&typeof s.reloadDocument=="boolean"&&typeof s.replace=="boolean")return s}catch{}}function xr(t){if(t.startsWith(`${vn}:${fr}:{`))try{let s=JSON.parse(t.slice(40));if(typeof s=="object"&&s&&typeof s.status=="number"&&typeof s.statusText=="string")return new lr(s.status,s.statusText,s.data)}catch{}}function vr(t,{relative:s}={}){X(et(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:a}=i.useContext(ae),{hash:o,pathname:r,search:l}=tt(t,{relative:s}),c=r;return n!=="/"&&(c=r==="/"?n:ue([n,r])),a.createHref({pathname:c,search:l,hash:o})}function et(){return i.useContext(St)!=null}function he(){return X(et(),"useLocation() may be used only in the context of a <Router> component."),i.useContext(St).location}var jn="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function bn(t){i.useContext(ae).static||i.useLayoutEffect(t)}function oe(){let{isDataRoute:t}=i.useContext(ve);return t?Dr():jr()}function jr(){X(et(),"useNavigate() may be used only in the context of a <Router> component.");let t=i.useContext(Ae),{basename:s,navigator:n}=i.useContext(ae),{matches:a}=i.useContext(ve),{pathname:o}=he(),r=JSON.stringify(mn(a)),l=i.useRef(!1);return bn(()=>{l.current=!0}),i.useCallback((d,h={})=>{if(re(l.current,jn),!l.current)return;if(typeof d=="number"){n.go(d);return}let m=cs(d,JSON.parse(r),o,h.relative==="path");t==null&&s!=="/"&&(m.pathname=m.pathname==="/"?s:ue([s,m.pathname])),(h.replace?n.replace:n.push)(m,h.state,h)},[s,n,r,o,t])}i.createContext(null);function tt(t,{relative:s}={}){let{matches:n}=i.useContext(ve),{pathname:a}=he(),o=JSON.stringify(mn(n));return i.useMemo(()=>cs(t,JSON.parse(o),a,s==="path"),[t,o,a,s])}function br(t,s){return yn(t)}function yn(t,s,n){X(et(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=i.useContext(ae),{matches:o}=i.useContext(ve),r=o[o.length-1],l=r?r.params:{},c=r?r.pathname:"/",d=r?r.pathnameBase:"/",h=r&&r.route;{let g=h&&h.path||"";wn(c,!h||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${g}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
2
|
+
|
|
3
|
+
Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let m=he(),u;u=m;let p=u.pathname||"/",f=p;if(d!=="/"){let g=d.replace(/^\//,"").split("/");f="/"+p.replace(/^\//,"").split("/").slice(g.length).join("/")}let C=dn(t,{pathname:f});return re(h||C!=null,`No routes matched location "${u.pathname}${u.search}${u.hash}" `),re(C==null||C[C.length-1].route.element!==void 0||C[C.length-1].route.Component!==void 0||C[C.length-1].route.lazy!==void 0,`Matched leaf route at location "${u.pathname}${u.search}${u.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),Cr(C&&C.map(g=>Object.assign({},g,{params:Object.assign({},l,g.params),pathname:ue([d,a.encodeLocation?a.encodeLocation(g.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?d:ue([d,a.encodeLocation?a.encodeLocation(g.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),o,n)}function yr(){let t=Pr(),s=ir(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:a},r={padding:"2px 4px",backgroundColor:a},l=null;return console.error("Error handled by React Router default ErrorBoundary:",t),l=i.createElement(i.Fragment,null,i.createElement("p",null,"💿 Hey developer 👋"),i.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",i.createElement("code",{style:r},"ErrorBoundary")," or"," ",i.createElement("code",{style:r},"errorElement")," prop on your route.")),i.createElement(i.Fragment,null,i.createElement("h2",null,"Unexpected Application Error!"),i.createElement("h3",{style:{fontStyle:"italic"}},s),n?i.createElement("pre",{style:o},n):null,l)}var Nr=i.createElement(yr,null),Nn=class extends i.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,s){return s.location!==t.location||s.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:s.error,location:s.location,revalidation:t.revalidation||s.revalidation}}componentDidCatch(t,s){this.props.onError?this.props.onError(t,s):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const n=xr(t.digest);n&&(t=n)}let s=t!==void 0?i.createElement(ve.Provider,{value:this.props.routeContext},i.createElement(ds.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?i.createElement(wr,{error:t},s):s}};Nn.contextType=ur;var Wt=new WeakMap;function wr({children:t,error:s}){let{basename:n}=i.useContext(ae);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let a=gr(s.digest);if(a){let o=Wt.get(s);if(o)throw o;let r=fn(a.location,n);if(pn&&!Wt.get(s))if(r.isExternal||a.reloadDocument)window.location.href=r.absoluteURL||r.to;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(r.to,{replace:a.replace}));throw Wt.set(s,l),l}return i.createElement("meta",{httpEquiv:"refresh",content:`0;url=${r.absoluteURL||r.to}`})}}return t}function kr({routeContext:t,match:s,children:n}){let a=i.useContext(Ae);return a&&a.static&&a.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=s.route.id),i.createElement(ve.Provider,{value:t},n)}function Cr(t,s=[],n){let a=n?.state;if(t==null){if(!a)return null;if(a.errors)t=a.matches;else if(s.length===0&&!a.initialized&&a.matches.length>0)t=a.matches;else return null}let o=t,r=a?.errors;if(r!=null){let m=o.findIndex(u=>u.route.id&&r?.[u.route.id]!==void 0);X(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(r).join(",")}`),o=o.slice(0,Math.min(o.length,m+1))}let l=!1,c=-1;if(n&&a){l=a.renderFallback;for(let m=0;m<o.length;m++){let u=o[m];if((u.route.HydrateFallback||u.route.hydrateFallbackElement)&&(c=m),u.route.id){let{loaderData:p,errors:f}=a,C=u.route.loader&&!p.hasOwnProperty(u.route.id)&&(!f||f[u.route.id]===void 0);if(u.route.lazy||C){n.isStatic&&(l=!0),c>=0?o=o.slice(0,c+1):o=[o[0]];break}}}}let d=n?.onError,h=a&&d?(m,u)=>{d(m,{location:a.location,params:a.matches?.[0]?.params??{},unstable_pattern:cr(a.matches),errorInfo:u})}:void 0;return o.reduceRight((m,u,p)=>{let f,C=!1,j=null,g=null;a&&(f=r&&u.route.id?r[u.route.id]:void 0,j=u.route.errorElement||Nr,l&&(c<0&&p===0?(wn("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,g=null):c===p&&(C=!0,g=u.route.hydrateFallbackElement||null)));let b=s.concat(o.slice(0,p+1)),y=()=>{let x;return f?x=j:C?x=g:u.route.Component?x=i.createElement(u.route.Component,null):u.route.element?x=u.route.element:x=m,i.createElement(kr,{match:u,routeContext:{outlet:m,matches:b,isDataRoute:a!=null},children:x})};return a&&(u.route.ErrorBoundary||u.route.errorElement||p===0)?i.createElement(Nn,{location:a.location,revalidation:a.revalidation,component:j,error:f,children:y(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:h}):y()},null)}function us(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Sr(t){let s=i.useContext(Ae);return X(s,us(t)),s}function Er(t){let s=i.useContext(Ct);return X(s,us(t)),s}function $r(t){let s=i.useContext(ve);return X(s,us(t)),s}function hs(t){let s=$r(t),n=s.matches[s.matches.length-1];return X(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Rr(){return hs("useRouteId")}function Pr(){let t=i.useContext(ds),s=Er("useRouteError"),n=hs("useRouteError");return t!==void 0?t:s.errors?.[n]}function Dr(){let{router:t}=Sr("useNavigate"),s=hs("useNavigate"),n=i.useRef(!1);return bn(()=>{n.current=!0}),i.useCallback(async(o,r={})=>{re(n.current,jn),n.current&&(typeof o=="number"?await t.navigate(o):await t.navigate(o,{fromRouteId:s,...r}))},[t,s])}var As={};function wn(t,s,n){!s&&!As[t]&&(As[t]=!0,re(!1,n))}i.memo(Lr);function Lr({routes:t,future:s,state:n,isStatic:a,onError:o}){return yn(t,void 0,{state:n,isStatic:a,onError:o})}function Tr({basename:t="/",children:s=null,location:n,navigationType:a="POP",navigator:o,static:r=!1,unstable_useTransitions:l}){X(!et(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=t.replace(/^\/*/,"/"),d=i.useMemo(()=>({basename:c,navigator:o,static:r,unstable_useTransitions:l,future:{}}),[c,o,r,l]);typeof n=="string"&&(n=Ie(n));let{pathname:h="/",search:m="",hash:u="",state:p=null,key:f="default",unstable_mask:C}=n,j=i.useMemo(()=>{let g=xe(h,c);return g==null?null:{location:{pathname:g,search:m,hash:u,state:p,key:f,unstable_mask:C},navigationType:a}},[c,h,m,u,p,f,a,C]);return re(j!=null,`<Router basename="${c}"> is not able to match the URL "${h}${m}${u}" because it does not start with the basename, so the <Router> won't render anything.`),j==null?null:i.createElement(ae.Provider,{value:d},i.createElement(St.Provider,{children:s,value:j}))}var ft="get",gt="application/x-www-form-urlencoded";function Et(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Mr(t){return Et(t)&&t.tagName.toLowerCase()==="button"}function Ir(t){return Et(t)&&t.tagName.toLowerCase()==="form"}function Ar(t){return Et(t)&&t.tagName.toLowerCase()==="input"}function _r(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function zr(t,s){return t.button===0&&(!s||s==="_self")&&!_r(t)}var dt=null;function Fr(){if(dt===null)try{new FormData(document.createElement("form"),0),dt=!1}catch{dt=!0}return dt}var Or=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Vt(t){return t!=null&&!Or.has(t)?(re(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${gt}"`),null):t}function Ur(t,s){let n,a,o,r,l;if(Ir(t)){let c=t.getAttribute("action");a=c?xe(c,s):null,n=t.getAttribute("method")||ft,o=Vt(t.getAttribute("enctype"))||gt,r=new FormData(t)}else if(Mr(t)||Ar(t)&&(t.type==="submit"||t.type==="image")){let c=t.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=t.getAttribute("formaction")||c.getAttribute("action");if(a=d?xe(d,s):null,n=t.getAttribute("formmethod")||c.getAttribute("method")||ft,o=Vt(t.getAttribute("formenctype"))||Vt(c.getAttribute("enctype"))||gt,r=new FormData(c,t),!Fr()){let{name:h,type:m,value:u}=t;if(m==="image"){let p=h?`${h}.`:"";r.append(`${p}x`,"0"),r.append(`${p}y`,"0")}else h&&r.append(h,u)}}else{if(Et(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=ft,a=null,o=gt,l=t}return r&&o==="text/plain"&&(l=r,r=void 0),{action:a,method:n.toLowerCase(),encType:o,formData:r,body:l}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function ms(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function Hr(t,s,n,a){let o=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return n?o.pathname.endsWith("/")?o.pathname=`${o.pathname}_.${a}`:o.pathname=`${o.pathname}.${a}`:o.pathname==="/"?o.pathname=`_root.${a}`:s&&xe(o.pathname,s)==="/"?o.pathname=`${s.replace(/\/$/,"")}/_root.${a}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${a}`,o}async function Br(t,s){if(t.id in s)return s[t.id];try{let n=await import(t.module);return s[t.id]=n,n}catch(n){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Wr(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function Vr(t,s,n){let a=await Promise.all(t.map(async o=>{let r=s.routes[o.route.id];if(r){let l=await Br(r,n);return l.links?l.links():[]}return[]}));return Jr(a.flat(1).filter(Wr).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function _s(t,s,n,a,o,r){let l=(d,h)=>n[h]?d.route.id!==n[h].route.id:!0,c=(d,h)=>n[h].pathname!==d.pathname||n[h].route.path?.endsWith("*")&&n[h].params["*"]!==d.params["*"];return r==="assets"?s.filter((d,h)=>l(d,h)||c(d,h)):r==="data"?s.filter((d,h)=>{let m=a.routes[d.route.id];if(!m||!m.hasLoader)return!1;if(l(d,h)||c(d,h))return!0;if(d.route.shouldRevalidate){let u=d.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:d.params,defaultShouldRevalidate:!0});if(typeof u=="boolean")return u}return!0}):[]}function qr(t,s,{includeHydrateFallback:n}={}){return Gr(t.map(a=>{let o=s.routes[a.route.id];if(!o)return[];let r=[o.module];return o.clientActionModule&&(r=r.concat(o.clientActionModule)),o.clientLoaderModule&&(r=r.concat(o.clientLoaderModule)),n&&o.hydrateFallbackModule&&(r=r.concat(o.hydrateFallbackModule)),o.imports&&(r=r.concat(o.imports)),r}).flat(1))}function Gr(t){return[...new Set(t)]}function Kr(t){let s={},n=Object.keys(t).sort();for(let a of n)s[a]=t[a];return s}function Jr(t,s){let n=new Set;return new Set(s),t.reduce((a,o)=>{let r=JSON.stringify(Kr(o));return n.has(r)||(n.add(r),a.push({key:r,link:o})),a},[])}function kn(){let t=i.useContext(Ae);return ms(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Yr(){let t=i.useContext(Ct);return ms(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var ps=i.createContext(void 0);ps.displayName="FrameworkContext";function Cn(){let t=i.useContext(ps);return ms(t,"You must render this element inside a <HydratedRouter> element"),t}function Xr(t,s){let n=i.useContext(ps),[a,o]=i.useState(!1),[r,l]=i.useState(!1),{onFocus:c,onBlur:d,onMouseEnter:h,onMouseLeave:m,onTouchStart:u}=s,p=i.useRef(null);i.useEffect(()=>{if(t==="render"&&l(!0),t==="viewport"){let j=b=>{b.forEach(y=>{l(y.isIntersecting)})},g=new IntersectionObserver(j,{threshold:.5});return p.current&&g.observe(p.current),()=>{g.disconnect()}}},[t]),i.useEffect(()=>{if(a){let j=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(j)}}},[a]);let f=()=>{o(!0)},C=()=>{o(!1),l(!1)};return n?t!=="intent"?[r,p,{}]:[r,p,{onFocus:qe(c,f),onBlur:qe(d,C),onMouseEnter:qe(h,f),onMouseLeave:qe(m,C),onTouchStart:qe(u,f)}]:[!1,p,{}]}function qe(t,s){return n=>{t&&t(n),n.defaultPrevented||s(n)}}function Qr({page:t,...s}){let{router:n}=kn(),a=i.useMemo(()=>dn(n.routes,t,n.basename),[n.routes,t,n.basename]);return a?i.createElement(el,{page:t,matches:a,...s}):null}function Zr(t){let{manifest:s,routeModules:n}=Cn(),[a,o]=i.useState([]);return i.useEffect(()=>{let r=!1;return Vr(t,s,n).then(l=>{r||o(l)}),()=>{r=!0}},[t,s,n]),a}function el({page:t,matches:s,...n}){let a=he(),{future:o,manifest:r,routeModules:l}=Cn(),{basename:c}=kn(),{loaderData:d,matches:h}=Yr(),m=i.useMemo(()=>_s(t,s,h,r,a,"data"),[t,s,h,r,a]),u=i.useMemo(()=>_s(t,s,h,r,a,"assets"),[t,s,h,r,a]),p=i.useMemo(()=>{if(t===a.pathname+a.search+a.hash)return[];let j=new Set,g=!1;if(s.forEach(y=>{let x=r.routes[y.route.id];!x||!x.hasLoader||(!m.some(v=>v.route.id===y.route.id)&&y.route.id in d&&l[y.route.id]?.shouldRevalidate||x.hasClientLoader?g=!0:j.add(y.route.id))}),j.size===0)return[];let b=Hr(t,c,o.unstable_trailingSlashAwareDataRequests,"data");return g&&j.size>0&&b.searchParams.set("_routes",s.filter(y=>j.has(y.route.id)).map(y=>y.route.id).join(",")),[b.pathname+b.search]},[c,o.unstable_trailingSlashAwareDataRequests,d,a,r,m,s,t,l]),f=i.useMemo(()=>qr(u,r),[u,r]),C=Zr(u);return i.createElement(i.Fragment,null,p.map(j=>i.createElement("link",{key:j,rel:"prefetch",as:"fetch",href:j,...n})),f.map(j=>i.createElement("link",{key:j,rel:"modulepreload",href:j,...n})),C.map(({key:j,link:g})=>i.createElement("link",{key:j,nonce:n.nonce,...g,crossOrigin:g.crossOrigin??n.crossOrigin})))}function tl(...t){return s=>{t.forEach(n=>{typeof n=="function"?n(s):n!=null&&(n.current=s)})}}var sl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{sl&&(window.__reactRouterVersion="7.13.1")}catch{}function nl({basename:t,children:s,unstable_useTransitions:n,window:a}){let o=i.useRef();o.current==null&&(o.current=zo({window:a,v5Compat:!0}));let r=o.current,[l,c]=i.useState({action:r.action,location:r.location}),d=i.useCallback(h=>{n===!1?c(h):i.startTransition(()=>c(h))},[n]);return i.useLayoutEffect(()=>r.listen(d),[r,d]),i.createElement(Tr,{basename:t,children:s,location:l.location,navigationType:l.action,navigator:r,unstable_useTransitions:n})}var Sn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,En=i.forwardRef(function({onClick:s,discover:n="render",prefetch:a="none",relative:o,reloadDocument:r,replace:l,unstable_mask:c,state:d,target:h,to:m,preventScrollReset:u,viewTransition:p,unstable_defaultShouldRevalidate:f,...C},j){let{basename:g,navigator:b,unstable_useTransitions:y}=i.useContext(ae),x=typeof m=="string"&&Sn.test(m),v=fn(m,g);m=v.to;let w=vr(m,{relative:o}),$=he(),R=null;if(c){let F=cs(c,[],$.unstable_mask?$.unstable_mask.pathname:"/",!0);g!=="/"&&(F.pathname=F.pathname==="/"?g:ue([g,F.pathname])),R=b.createHref(F)}let[N,P,L]=Xr(a,C),S=ll(m,{replace:l,unstable_mask:c,state:d,target:h,preventScrollReset:u,relative:o,viewTransition:p,unstable_defaultShouldRevalidate:f,unstable_useTransitions:y});function I(F){s&&s(F),F.defaultPrevented||S(F)}let E=!(v.isExternal||r),B=i.createElement("a",{...C,...L,href:(E?R:void 0)||v.absoluteURL||w,onClick:E?I:s,ref:tl(j,P),target:h,"data-discover":!x&&n==="render"?"true":void 0});return N&&!x?i.createElement(i.Fragment,null,B,i.createElement(Qr,{page:w})):B});En.displayName="Link";var al=i.forwardRef(function({"aria-current":s="page",caseSensitive:n=!1,className:a="",end:o=!1,style:r,to:l,viewTransition:c,children:d,...h},m){let u=tt(l,{relative:h.relative}),p=he(),f=i.useContext(Ct),{navigator:C,basename:j}=i.useContext(ae),g=f!=null&&hl(u)&&c===!0,b=C.encodeLocation?C.encodeLocation(u).pathname:u.pathname,y=p.pathname,x=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;n||(y=y.toLowerCase(),x=x?x.toLowerCase():null,b=b.toLowerCase()),x&&j&&(x=xe(x,j)||x);const v=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let w=y===b||!o&&y.startsWith(b)&&y.charAt(v)==="/",$=x!=null&&(x===b||!o&&x.startsWith(b)&&x.charAt(b.length)==="/"),R={isActive:w,isPending:$,isTransitioning:g},N=w?s:void 0,P;typeof a=="function"?P=a(R):P=[a,w?"active":null,$?"pending":null,g?"transitioning":null].filter(Boolean).join(" ");let L=typeof r=="function"?r(R):r;return i.createElement(En,{...h,"aria-current":N,className:P,ref:m,style:L,to:l,viewTransition:c},typeof d=="function"?d(R):d)});al.displayName="NavLink";var ol=i.forwardRef(({discover:t="render",fetcherKey:s,navigate:n,reloadDocument:a,replace:o,state:r,method:l=ft,action:c,onSubmit:d,relative:h,preventScrollReset:m,viewTransition:u,unstable_defaultShouldRevalidate:p,...f},C)=>{let{unstable_useTransitions:j}=i.useContext(ae),g=dl(),b=ul(c,{relative:h}),y=l.toLowerCase()==="get"?"get":"post",x=typeof c=="string"&&Sn.test(c),v=w=>{if(d&&d(w),w.defaultPrevented)return;w.preventDefault();let $=w.nativeEvent.submitter,R=$?.getAttribute("formmethod")||l,N=()=>g($||w.currentTarget,{fetcherKey:s,method:R,navigate:n,replace:o,state:r,relative:h,preventScrollReset:m,viewTransition:u,unstable_defaultShouldRevalidate:p});j&&n!==!1?i.startTransition(()=>N()):N()};return i.createElement("form",{ref:C,method:y,action:b,onSubmit:a?d:v,...f,"data-discover":!x&&t==="render"?"true":void 0})});ol.displayName="Form";function rl(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function $n(t){let s=i.useContext(Ae);return X(s,rl(t)),s}function ll(t,{target:s,replace:n,unstable_mask:a,state:o,preventScrollReset:r,relative:l,viewTransition:c,unstable_defaultShouldRevalidate:d,unstable_useTransitions:h}={}){let m=oe(),u=he(),p=tt(t,{relative:l});return i.useCallback(f=>{if(zr(f,s)){f.preventDefault();let C=n!==void 0?n:Ze(u)===Ze(p),j=()=>m(t,{replace:C,unstable_mask:a,state:o,preventScrollReset:r,relative:l,viewTransition:c,unstable_defaultShouldRevalidate:d});h?i.startTransition(()=>j()):j()}},[u,m,p,n,a,o,s,t,r,l,c,d,h])}var il=0,cl=()=>`__${String(++il)}__`;function dl(){let{router:t}=$n("useSubmit"),{basename:s}=i.useContext(ae),n=Rr(),a=t.fetch,o=t.navigate;return i.useCallback(async(r,l={})=>{let{action:c,method:d,encType:h,formData:m,body:u}=Ur(r,s);if(l.navigate===!1){let p=l.fetcherKey||cl();await a(p,n,l.action||c,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:m,body:u,formMethod:l.method||d,formEncType:l.encType||h,flushSync:l.flushSync})}else await o(l.action||c,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:m,body:u,formMethod:l.method||d,formEncType:l.encType||h,replace:l.replace,state:l.state,fromRouteId:n,flushSync:l.flushSync,viewTransition:l.viewTransition})},[a,o,s,n])}function ul(t,{relative:s}={}){let{basename:n}=i.useContext(ae),a=i.useContext(ve);X(a,"useFormAction must be used inside a RouteContext");let[o]=a.matches.slice(-1),r={...tt(t||".",{relative:s})},l=he();if(t==null){r.search=l.search;let c=new URLSearchParams(r.search),d=c.getAll("index");if(d.some(m=>m==="")){c.delete("index"),d.filter(u=>u).forEach(u=>c.append("index",u));let m=c.toString();r.search=m?`?${m}`:""}}return(!t||t===".")&&o.route.index&&(r.search=r.search?r.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(r.pathname=r.pathname==="/"?n:ue([n,r.pathname])),Ze(r)}function hl(t,{relative:s}={}){let n=i.useContext(xn);X(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:a}=$n("useViewTransitionState"),o=tt(t,{relative:s});if(!n.isTransitioning)return!1;let r=xe(n.currentLocation.pathname,a)||n.currentLocation.pathname,l=xe(n.nextLocation.pathname,a)||n.nextLocation.pathname;return bt(o.pathname,l)!=null||bt(o.pathname,r)!=null}var ml=No();const Rn={name:"book-open",size:24,node:[["path",{d:"M12 5v16",key:"1f6ucr"}],["path",{d:"M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z",key:"1fyvmf"}]]};Rn.node;const pl=O(Rn);const Pn={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};Pn.node;const ke=O(Pn);const Dn={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};Dn.node;const $t=O(Dn);const Ln={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Ln.node;const fl=O(Ln);const Tn={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};Tn.node;const Mn=O(Tn);const In={name:"chevrons-down-up",size:24,node:[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]};In.node;const gl=O(In);const An={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]};An.node;const xl=O(An);const _n={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};_n.node;const vl=O(_n);const zn={name:"circle-check",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 9-5.5 5.5L8 12",key:"xofnsj"}]],aliases:["check-circle-2"]};zn.node;const Ke=O(zn);const Fn={name:"clock-alert",size:24,node:[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["path",{d:"M20 12v5",key:"12wsvk"}],["path",{d:"M20 21h.01",key:"1p6o6n"}],["path",{d:"M21.25 8.2A10 10 0 1 0 16 21.16",key:"17fp9f"}]]};Fn.node;const jl=O(Fn);const On={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};On.node;const Un=O(On);const Hn={name:"cloud",size:24,node:[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]};Hn.node;const fs=O(Hn);const Bn={name:"copy",size:24,node:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};Bn.node;const Rt=O(Bn);const Wn={name:"download",size:24,node:[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]};Wn.node;const bl=O(Wn);const Vn={name:"external-link",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]};Vn.node;const qn=O(Vn);const Gn={name:"file-text",size:24,node:[["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"}]]};Gn.node;const Kn=O(Gn);const Jn={name:"files",size:24,node:[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]};Jn.node;const yl=O(Jn);const Yn={name:"folder-open",size:24,node:[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]};Yn.node;const Pt=O(Yn);const Xn={name:"folder",size:24,node:[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]};Xn.node;const Qn=O(Xn);const Zn={name:"git-branch",size:24,node:[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]]};Zn.node;const Nl=O(Zn);const ea={name:"git-commit-horizontal",size:24,node:[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],aliases:["git-commit"]};ea.node;const wl=O(ea);const ta={name:"git-fork",size:24,node:[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]};ta.node;const yt=O(ta);const sa={name:"globe",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]};sa.node;const Dt=O(sa);const na={name:"import",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]};na.node;const kl=O(na);const aa={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};aa.node;const Cl=O(aa);const oa={name:"key-round",size:24,node:[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]};oa.node;const Sl=O(oa);const ra={name:"laptop",size:24,node:[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]]};ra.node;const gs=O(ra);const la={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};la.node;const qt=O(la);const ia={name:"lock",size:24,node:[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]};ia.node;const El=O(ia);const ca={name:"package",size:24,node:[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]};ca.node;const $l=O(ca);const da={name:"panel-left-close",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],aliases:["sidebar-close"]};da.node;const Rl=O(da);const ua={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};ua.node;const ha=O(ua);const ma={name:"refresh-cw",size:24,node:[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]};ma.node;const Nt=O(ma);const pa={name:"scan-search",size:24,node:[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]]};pa.node;const Pl=O(pa);const fa={name:"scroll-text",size:24,node:[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]};fa.node;const ga=O(fa);const xa={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};xa.node;const Lt=O(xa);const va={name:"settings",size:24,node:[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]};va.node;const ja=O(va);const ba={name:"trash",size:24,node:[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],aliases:["trash-2"]};ba.node;const Dl=O(ba);const ya={name:"triangle-alert",size:24,node:[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["alert-triangle"]};ya.node;const xs=O(ya);const Na={name:"unlink",size:24,node:[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]};Na.node;const vs=O(Na),Ll={currentProject:"default",projects:["default"],docs:[],selectedDocId:null,selectedDoc:null,freshnessResult:null,searchQuery:"",searchResults:[],hasReceivedInitialState:!1,searchAllProjects:!1,historyEntries:null,historyVersionContent:null,exportBundles:[],readOnly:!1,syncEnabled:!1,codeSourceMigrationPending:!1,codeSourcesVersion:0,publicationsVersion:0,commentsVersion:0,commentSummary:{project:"",docs:{}}};let A={...Ll},xt=[];function Y(){xt.forEach(t=>t())}function J(){const[,t]=i.useState(0),s=i.useCallback(()=>{const n=()=>t(a=>a+1);return xt.push(n),()=>{xt=xt.filter(a=>a!==n)}},[]);return i.useState(()=>s()),{...A,setProjects:n=>{A={...A,projects:n},Y()},setCurrentProject:n=>{A={...A,currentProject:n},Y()},setDocs:n=>{A={...A,docs:n},Y()},setSelectedDocId:n=>{A={...A,selectedDocId:n,freshnessResult:null},Y()},setSelectedDoc:n=>{A={...A,selectedDoc:n},Y()},setFreshnessResult:n=>{A={...A,freshnessResult:n},Y()},setSearchQuery:n=>{A={...A,searchQuery:n},Y()},setSearchResults:n=>{A={...A,searchResults:n},Y()},clearSearch:()=>{A={...A,searchQuery:"",searchResults:[]},Y()},setSearchAllProjects:n=>{A={...A,searchAllProjects:n},Y()},setHistoryEntries:n=>{A={...A,historyEntries:n,historyVersionContent:null},Y()},setHistoryVersionContent:n=>{A={...A,historyVersionContent:n},Y()},setExportBundles:n=>{A={...A,exportBundles:n},Y()},bumpCodeSourcesVersion:()=>{A={...A,codeSourcesVersion:A.codeSourcesVersion+1},Y()},bumpPublicationsVersion:()=>{A={...A,publicationsVersion:A.publicationsVersion+1},Y()},bumpCommentsVersion:()=>{A={...A,commentsVersion:A.commentsVersion+1},Y()},setCommentSummary:(n,a)=>{A={...A,commentSummary:{project:n,docs:a}},Y()},setCodeSourceMigrationPending:n=>{A={...A,codeSourceMigrationPending:n},Y()},applyInitialState:n=>{const a=n.projects??n.config?.projects??A.projects,o=a.length===A.projects.length&&a.every((r,l)=>r===A.projects[l]);A={...A,projects:o?A.projects:a,docs:n.docs??A.docs,exportBundles:n.bundles??A.exportBundles,readOnly:n.readOnly??A.readOnly,syncEnabled:n.syncEnabled??A.syncEnabled,codeSourceMigrationPending:n.codeSourceMigrationPending??A.codeSourceMigrationPending,hasReceivedInitialState:!0},Y()}}}function se(t,s){const n=encodeURIComponent(t);if(!s)return`/${n}`;const a=s.split("/").filter(Boolean).map(o=>encodeURIComponent(o)).join("/");return a?`/${n}/${a}`:`/${n}`}function zs(t){const s=t.replace(/^\/+|\/+$/g,"");if(!s)return{project:null,docId:null};const n=s.split("/").filter(Boolean);if(n.length===0)return{project:null,docId:null};const a=decodeURIComponent(n[0]);if(n.length===1)return{project:a,docId:null};const o=n.slice(1).map(r=>decodeURIComponent(r)).join("/");return{project:a,docId:o}}function ge(t){return t.split("/").filter(Boolean).map(s=>encodeURIComponent(s)).join("/")}const vt="/_logs";function wt(t){return`${vt}/${t}`}const wa="/_publications";function js(t){return t.replace(/\/+$/,"")===wa}function ka(t){const s=t.replace(/\/+$/,"");return s!==vt&&!s.startsWith(`${vt}/`)?null:s.slice(vt.length+1)==="github"?"github":"server"}const Ca=t=>`mcp-documentor:expanded-folders:${t}`;function Fs(t){try{const s=JSON.parse(localStorage.getItem(Ca(t))??"null");return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function Tl(t,s){try{localStorage.setItem(Ca(t),JSON.stringify(s))}catch{}}function Sa(t,s,n,a){const o=new URLSearchParams;s&&o.set("flat","1"),n&&o.set("headers","1"),o.set("project",a);const r=o.toString(),l=document.createElement("a");l.href=`/api/export-zip/${t.id}${r?`?${r}`:""}`,l.download=t.zipFilename,l.click()}function Ml({bundle:t,onClose:s}){const[n,a]=i.useState(!1),[o,r]=i.useState(!1),{currentProject:l}=J();return e.jsx("div",{className:"settings-overlay",onClick:s,children:e.jsxs("div",{className:"settings-popover export-bundle-modal",onClick:c=>c.stopPropagation(),children:[e.jsx("h2",{className:"settings-title",children:t.name}),t.description&&e.jsx("p",{className:"export-bundle-modal-desc",children:t.description}),e.jsx("div",{className:"export-bundle-modal-meta",children:e.jsxs("span",{className:"export-bundle-modal-filename",children:["📦 ",t.zipFilename]})}),e.jsxs("div",{className:"export-bundle-modal-section",children:[e.jsxs("div",{className:"export-bundle-modal-section-title",children:["Documents inclus (",t.docs.length,")"]}),e.jsx("ul",{className:"export-bundle-modal-docs",children:t.docs.map(c=>e.jsx("li",{className:"export-bundle-modal-doc-item",children:e.jsx("span",{className:"export-bundle-modal-doc-ref",children:c})},c))})]}),e.jsxs("div",{className:"export-bundle-modal-toggle-row",children:[e.jsx("span",{className:"export-bundle-modal-toggle-label",children:"Ne pas conserver l'arborescence"}),e.jsx("button",{role:"switch","aria-checked":n,className:`toggle-switch${n?" toggle-switch--on":""}`,onClick:()=>a(c=>!c)})]}),e.jsxs("div",{className:"export-bundle-modal-toggle-row",children:[e.jsx("span",{className:"export-bundle-modal-toggle-label",children:"Inclure les entêtes (métadonnées)"}),e.jsx("button",{role:"switch","aria-checked":o,className:`toggle-switch${o?" toggle-switch--on":""}`,onClick:()=>r(c=>!c)})]}),e.jsxs("div",{className:"settings-actions",children:[e.jsx("button",{className:"settings-cancel-btn",onClick:s,children:"Fermer"}),e.jsx("button",{className:"settings-save-btn",onClick:()=>{Sa(t,n,o,l),s()},children:"↓ Télécharger ZIP"})]})]})})}function Il(){const{exportBundles:t,currentProject:s}=J(),[n,a]=i.useState(null);return t.length===0?e.jsx("div",{className:"nav-empty",children:"No export bundles yet."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"export-bundles-list",children:t.map(o=>e.jsxs("div",{className:"export-bundle-item",onClick:()=>a(o),children:[e.jsxs("div",{className:"export-bundle-info",children:[e.jsx("span",{className:"export-bundle-name",children:o.name}),o.description&&e.jsx("span",{className:"export-bundle-desc",children:o.description}),e.jsxs("span",{className:"export-bundle-meta",children:[o.docs.length," doc",o.docs.length!==1?"s":""]})]}),e.jsx("button",{className:"export-bundle-btn",onClick:r=>{r.stopPropagation(),Sa(o,!1,!1,s)},title:`Télécharger ${o.zipFilename}`,children:"↓ ZIP"})]},o.id))}),n&&e.jsx(Ml,{bundle:n,onClose:()=>a(null)})]})}const Ea="mcp-documentor:project";function Os(){try{return localStorage.getItem(Ea)}catch{return null}}function Al(t){try{localStorage.setItem(Ea,t)}catch{}}async function $a(t){try{const s=await fetch(`/api/docs?project=${encodeURIComponent(t)}`);return s.ok?(await s.json()).docs??[]:[]}catch{return[]}}async function _l(t){try{const s=await fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t})});return s.ok?{ok:!0,projects:(await s.json()).projects}:{ok:!1}}catch{return{ok:!1}}}function zl(t){const s=t.split(/[^a-zA-Z0-9]+/).filter(Boolean);return s.length===0?"?":(s.length>1?s[0][0]+s[1][0]:s[0].slice(0,2)).toUpperCase()}function Fl(t){let s=0;for(const n of t)s=s*31+n.charCodeAt(0)>>>0;return`hsl(${s%360}, 52%, 46%)`}async function le(t,s){const n=await fetch(t,s);let a=null;try{a=await n.json()}catch{}if(!n.ok)throw new Error(a?.error??`HTTP ${n.status}`);return a}const _e=t=>({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});async function Ra(){return(await le("/api/code-sources")).projects}async function Ol(t,s){return(await le("/api/code-sources/search",{..._e({query:t}),signal:s})).results}function Ul(t,s,n){return le("/api/code-sources/inspect",{..._e({repo:t,branch:s}),signal:n})}function Hl(t,s,n,a){return le("/api/code-sources/preview",{..._e({project:t,config:s,codeRoot:n}),signal:a})}function Bl(t,s,n){return le("/api/code-sources/apply",_e({project:t,config:s,codeRoot:n}))}function Wl(t,s){return le("/api/code-roots/inspect",{..._e({path:t}),signal:s})}function Vl(){return le("/api/code-roots")}function ql(t){return le("/api/code-roots/apply",_e({path:t}))}function Gl(){return le("/api/github-token")}async function Pa(){return(await le("/api/code-source-migration")).report}function Kl(){return le("/api/code-source-migration/ack",{method:"POST"})}function Us(t){const s=t.config;return s?s.kind==="github"?`${s.repo} · ${s.branch??"default branch"}`:t.codeRoot?`Local · ${t.codeRoot}`:"Local working copy":"Settings unreadable"}function Jl({source:t,size:s,active:n}){if(t?.error)return e.jsx(xs,{size:s,className:"source-icon error"});const a=`source-icon${n?" active":""}`;return t?.config?.kind==="github"?e.jsx(fs,{size:s,className:a}):e.jsx(gs,{size:s,className:a})}function Hs({project:t,size:s}){return e.jsx("span",{className:"project-avatar",style:{width:s,height:s,background:Fl(t),fontSize:Math.round(s*.36)},children:zl(t)})}function Da({variant:t,onOpenSettings:s}){const n=oe(),{currentProject:a,projects:o,applyInitialState:r,codeSourcesVersion:l}=J(),[c,d]=i.useState(""),[h,m]=i.useState(!1),[u,p]=i.useState(!1),[f,C]=i.useState(0),[j,g]=i.useState({}),b=i.useRef(null),y=i.useRef(null),x=i.useCallback(()=>{Ra().then(E=>g(Object.fromEntries(E.map(B=>[B.project,B])))).catch(()=>{})},[]);i.useEffect(x,[l,o,x]),i.useEffect(()=>{u&&x()},[u,x]),i.useEffect(()=>{u&&!h&&b.current?.focus()},[u,h]),i.useEffect(()=>{b.current?.querySelector(`[data-index="${f}"]`)?.scrollIntoView({block:"nearest"})},[f]);const v=E=>{n(se(E,null))},w=()=>{C(Math.max(0,o.indexOf(a))),m(!1),p(!0)},$=()=>{p(!1),m(!1),y.current?.focus()},R=E=>{$(),v(E)},N=E=>{p(!1),s(E)},P=E=>{E.key==="ArrowDown"?(E.preventDefault(),C(B=>Math.min(o.length-1,B+1))):E.key==="ArrowUp"?(E.preventDefault(),C(B=>Math.max(0,B-1))):E.key==="Enter"?(E.preventDefault(),o[f]&&R(o[f])):(E.key==="Escape"||E.key==="Tab")&&$()},L=async()=>{const E=c.trim().replace(/[^a-zA-Z0-9_-]/g,"-");if(!E)return;const{ok:B,projects:F}=await _l(E);B&&(F&&r({projects:F}),d(""),$(),v(E))},S=j[a],I=S?`${a} — ${S.error??Us(S)}`:a;return e.jsxs("div",{className:`project-selector project-selector--${t}`,children:[e.jsxs("button",{ref:y,className:`project-trigger${u?" open":""}${S?.error?" error":""}`,onClick:()=>u?$():w(),onKeyDown:E=>{E.key==="ArrowDown"&&!u&&(E.preventDefault(),w())},title:I,"aria-haspopup":"listbox","aria-expanded":u,children:[e.jsx(Hs,{project:a,size:t==="rail"?32:28}),t==="card"&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"project-trigger-text",children:[e.jsx("span",{className:"project-trigger-label",children:a}),e.jsx("span",{className:`project-trigger-caption${S?.error?" error":""}`,children:S?.error?"Code source to fix":"Current project"})]}),e.jsx(xl,{size:14,className:"project-trigger-caret"})]})]}),u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"menu-backdrop",onClick:$}),e.jsxs("div",{className:"project-menu",children:[e.jsx("div",{className:"project-menu-label",children:"Projects · code source"}),e.jsx("div",{className:"project-menu-list",role:"listbox",tabIndex:-1,ref:b,onKeyDown:P,"aria-activedescendant":`project-option-${f}`,children:o.map((E,B)=>{const F=j[E],W=E===a;return e.jsxs("div",{id:`project-option-${B}`,"data-index":B,role:"option","aria-selected":W,className:`project-option${W?" current":""}${B===f?" highlighted":""}`,onMouseEnter:()=>C(B),onClick:()=>R(E),children:[e.jsx(Hs,{project:E,size:24}),e.jsxs("div",{className:"project-option-text",children:[e.jsx("span",{className:"project-option-name",children:E}),F&&e.jsxs("span",{className:`project-option-source${F.error?" error":""}`,children:[e.jsx(Jl,{source:F,size:11,active:F.config?.kind==="github"}),F.error??Us(F)]})]}),F?.error?e.jsx("button",{className:"project-option-fix",onClick:T=>{T.stopPropagation(),N(E)},children:"Fix"}):e.jsxs(e.Fragment,{children:[W&&e.jsx(ke,{size:14,className:"project-option-check"}),e.jsx("button",{className:"project-option-gear",title:`Settings of ${E}`,onClick:T=>{T.stopPropagation(),N(E)},children:e.jsx(ja,{size:14})})]})]},E)})}),e.jsx("div",{className:"project-menu-footer",children:h?e.jsxs("div",{className:"new-project-row",children:[e.jsx("input",{className:"new-project-input",type:"text",placeholder:"New project",value:c,autoFocus:!0,onChange:E=>d(E.target.value),onKeyDown:E=>{E.key==="Enter"&&L(),E.key==="Escape"&&m(!1)}}),e.jsx("button",{className:"new-project-btn",onClick:L,title:"Create project",children:e.jsx(ke,{size:14})})]}):e.jsxs("button",{className:"project-menu-action",onClick:()=>m(!0),children:[e.jsx(ha,{size:14}),"New project"]})})]})]})]})}function Yl({focusToken:t}){const s=oe(),n=i.useRef(null),{searchQuery:a,searchResults:o,searchAllProjects:r,setSearchAllProjects:l,setSearchQuery:c,setSearchResults:d,clearSearch:h,currentProject:m,selectedDocId:u}=J(),[p,f]=i.useState(a);i.useEffect(()=>{n.current?.focus(),n.current?.select()},[t]);const C=async()=>{if(p.trim()){c(p);try{const y=await(await fetch("/api/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:p,top_k:10,all_projects:r,project:m})})).json();d(y.results||[])}catch{d([])}}},j=()=>{f(""),h(),s(se(m,null))},g=b=>{b.key==="Enter"&&C(),b.key==="Escape"&&p&&j()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"search-box",children:[e.jsxs("div",{className:"search-field",children:[e.jsx(Lt,{size:14,className:"search-field-icon"}),e.jsx("input",{ref:n,className:"search-input",type:"text",placeholder:"Search documentation",value:p,onChange:b=>f(b.target.value),onKeyDown:g}),p?e.jsx("button",{className:"search-clear-btn",onClick:j,title:"Clear search",children:"✕"}):e.jsx("span",{className:"search-kbd",children:"⌘K"})]}),e.jsxs("div",{className:"segmented",role:"radiogroup","aria-label":"Search scope",children:[e.jsx("button",{role:"radio","aria-checked":!r,className:`segmented-option${r?"":" active"}`,onClick:()=>l(!1),children:"This project"}),e.jsx("button",{role:"radio","aria-checked":r,className:`segmented-option${r?" active":""}`,onClick:()=>l(!0),children:"All projects"})]})]}),a&&o.length===0&&e.jsx("div",{className:"nav-empty",children:"No match."}),o.map(b=>{const y=b.project??m,x=u===b.id&&m===y;return e.jsxs("div",{className:`search-result${x?" active":""}`,onClick:()=>s(se(y,b.id)),children:[e.jsxs("div",{className:"search-result-head",children:[e.jsx("span",{className:"search-result-title",children:b.title}),e.jsxs("span",{className:"search-result-score",children:[(b.score*100).toFixed(0),"%"]})]}),b.project&&e.jsxs("div",{className:"search-result-meta",children:["Project: ",b.project]}),e.jsxs("div",{className:"search-result-excerpt",children:[b.excerpt.substring(0,80),"..."]})]},`${y}::${b.id}`)})]})}function Xl(t){const s=[],n=new Map;for(const a of t){if(!a.folder){s.push(a);continue}const o=a.folder.split("/").filter(Boolean);let r=n,l="";for(let c=0;c<o.length;c++){const d=o[c];l=l?`${l}/${d}`:d,r.has(d)||r.set(d,{name:d,path:l,children:new Map,docs:[]});const h=r.get(d);c===o.length-1?h.docs.push(a):r=h.children}}return{rootDocs:s,folders:n}}function La(t){let s=t.docs.length;for(const n of t.children.values())s+=La(n);return s}function Ta(t){return t.docs.some(s=>s.isStale)||[...t.children.values()].some(Ta)}function Ma(t,s){return t.docs.some(n=>(s[n.id]?.unread??0)>0)||[...t.children.values()].some(n=>Ma(n,s))}function Ia(){const{commentSummary:t,currentProject:s}=J();return t.project===s?t.docs:{}}function Aa(t){return[...t.values()].flatMap(s=>[s.path,...Aa(s.children)])}function Ql(t){if(!t)return"";const s=new Date(t),n=a=>String(a).padStart(2,"0");return`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())} ${n(s.getHours())}:${n(s.getMinutes())}`}const es=t=>8+t*16;function jt({doc:t,selectedDocId:s,onSelect:n,depth:a=0,showCreatedAt:o=!1}){const r=Ia()[t.id]?.unread??0;return e.jsxs("div",{className:`tree-row tree-row--doc${s===t.id?" active":""}`,style:{paddingLeft:es(a)+16},onClick:()=>n(t.id),title:t.isStale?`${t.title} — outdated`:t.title,children:[e.jsx(Kn,{size:14,className:"tree-row-icon"}),e.jsx("span",{className:"tree-row-label",children:t.title}),o&&t.createdAt&&e.jsx("span",{className:"tree-row-meta",children:Ql(t.createdAt)}),r>0&&e.jsxs("span",{className:"tree-comments",title:`${r} unread comment${r>1?"s":""}`,children:[e.jsx(ls,{size:11}),r]}),t.isStale&&e.jsx("span",{className:"stale-dot"})]})}function _a({nodes:t,depth:s,selectedDocId:n,onSelect:a,expanded:o,onToggle:r}){const l=Ia();return e.jsx(e.Fragment,{children:[...t.entries()].sort(([c],[d])=>c.localeCompare(d)).map(([,c])=>{const d=!!o[c.path],h=d?$t:fl,m=d?Pt:Qn;return e.jsxs("div",{children:[e.jsxs("div",{className:"tree-row tree-row--folder",style:{paddingLeft:es(s)},onClick:()=>r(c.path),children:[e.jsx(h,{size:12,className:"tree-row-chevron"}),e.jsx(m,{size:14,className:"tree-row-icon"}),e.jsx("span",{className:"tree-row-label",children:c.name}),Ma(c,l)&&e.jsx("span",{className:"tree-comments",title:"Contains unread comments",children:e.jsx(ls,{size:11})}),Ta(c)&&e.jsx("span",{className:"stale-dot",title:"Contains outdated docs"}),e.jsx("span",{className:"tree-row-count",children:La(c)})]}),d&&e.jsxs("div",{className:"tree-children",style:{"--guide-x":`${es(s)+6}px`},children:[c.docs.map(u=>e.jsx(jt,{doc:u,selectedDocId:n,onSelect:a,depth:s+1},u.id)),e.jsx(_a,{nodes:c.children,depth:s+1,selectedDocId:n,onSelect:a,expanded:o,onToggle:r})]})]},c.path)})})}function Zl({mode:t,searchFocusToken:s,onCreateDoc:n,onOpenProjectSettings:a,onClose:o}){const r=oe(),{docs:l,selectedDocId:c,currentProject:d,exportBundles:h,readOnly:m}=J(),[u,p]=i.useState(()=>({project:d,folders:Fs(d)}));u.project!==d&&p({project:d,folders:Fs(d)});const f=u.folders,C=P=>{const L=P(f);Tl(d,L),p({project:d,folders:L})},j=i.useMemo(()=>Xl(l),[l]),g=i.useMemo(()=>l.filter(P=>P.isStale),[l]),b=i.useMemo(()=>[...l].sort((P,L)=>{const S=P.createdAt?new Date(P.createdAt).getTime():0;return(L.createdAt?new Date(L.createdAt).getTime():0)-S}),[l]),y=l.find(P=>P.id===c)?.folder,x=i.useMemo(()=>{const P={};let L="";for(const S of(y??"").split("/").filter(Boolean))L=L?`${L}/${S}`:S,P[L]=!0;return{...P,...f}},[y,f]),v=P=>{r(se(d,P))},w=P=>{C(L=>({...L,[P]:!x[P]}))},$=()=>{C(()=>Object.fromEntries(Aa(j.folders).map(P=>[P,!1])))},R={docs:{title:"Documentation",count:`${l.length} doc${l.length===1?"":"s"}`},search:{title:"Search"},outdated:{title:"Outdated",count:String(g.length)},recent:{title:"Recent",count:String(b.length)},exports:{title:"Export bundles",count:String(h.length)}},N=()=>{switch(t){case"search":return e.jsx(Yl,{focusToken:s});case"exports":return e.jsx(Il,{});case"recent":return b.length===0?e.jsx("div",{className:"nav-empty",children:"No documentation entries yet."}):b.map(P=>e.jsx(jt,{doc:P,selectedDocId:c,onSelect:v,showCreatedAt:!0},P.id));case"outdated":return g.length===0?e.jsx("div",{className:"nav-empty",children:"All docs are up to date."}):g.map(P=>e.jsx(jt,{doc:P,selectedDocId:c,onSelect:v},P.id));case"docs":return l.length===0?e.jsx("div",{className:"nav-empty",children:"No documentation entries yet."}):e.jsxs(e.Fragment,{children:[e.jsx(_a,{nodes:j.folders,depth:0,selectedDocId:c,onSelect:v,expanded:x,onToggle:w}),j.rootDocs.map(P=>e.jsx(jt,{doc:P,selectedDocId:c,onSelect:v},P.id))]})}};return e.jsxs("div",{className:"nav-panel",children:[e.jsxs("div",{className:"nav-panel-project",children:[e.jsx(Da,{variant:"card",onOpenSettings:a}),!m&&e.jsx("button",{className:"nav-panel-new",onClick:n,title:"Create a new document manually",children:e.jsx(ha,{size:16})})]}),e.jsxs("div",{className:"nav-panel-heading",children:[e.jsx("span",{className:"nav-panel-title",children:R[t].title}),R[t].count&&e.jsx("span",{className:"nav-panel-count",children:R[t].count}),t==="docs"&&e.jsx("button",{className:"nav-panel-tool",onClick:$,title:"Collapse all folders",children:e.jsx(gl,{size:15})}),e.jsx("button",{className:"nav-panel-tool",onClick:o,title:"Hide panel",children:e.jsx(Rl,{size:15})})]}),e.jsx("div",{className:"nav-panel-scroll",children:N()})]})}function ei({report:t,trackedFiles:s,onViewCode:n}){if(t.status==="no_tracking")return e.jsx("p",{className:"file-status-view",style:{color:"#8b949e",fontSize:13},children:"No tracked files for this entry."});const a=l=>t.modified.includes(l)?"modified":t.missing.includes(l)?"missing":(t.anchors_lost??[]).includes(l)?"anchors_lost":"ok",o=l=>!!l.sections?.length&&!(t.anchors_lost??[]).includes(l.path),r=l=>{switch(l){case"ok":return e.jsx("span",{className:"status-ok",children:"✓"});case"modified":return e.jsx("span",{className:"status-modified",children:"⚠ Modified"});case"missing":return e.jsx("span",{className:"status-missing",children:"✕ Missing"});case"anchors_lost":return e.jsx("span",{className:"status-anchors-lost",children:"⚠ Anchors lost"});default:return null}};return e.jsxs("div",{className:"file-status-view",style:{marginBottom:16},children:[e.jsxs("h3",{style:{fontSize:14,color:"#8b949e",margin:"0 0 8px 0"},children:["Tracked Files — ",t.status==="stale"?"Stale":"Up to date"]}),e.jsxs("table",{className:"file-status-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"File"}),e.jsx("th",{children:"Snapshot Date"}),e.jsx("th",{children:"Status"})]})}),e.jsx("tbody",{children:s.map(l=>{const c=a(l.path);return e.jsxs("tr",{onClick:o(l)?()=>n(l.path):void 0,className:o(l)?"file-row file-row--clickable":"file-row",title:o(l)?"Cliquer pour voir le code de la section":void 0,children:[e.jsxs("td",{children:[l.path,o(l)&&e.jsx("span",{className:"file-row-code-hint",children:" 〈/〉"})]}),e.jsx("td",{children:new Date(l.lastModifiedAt).toLocaleString()}),e.jsx("td",{children:r(c)})]},l.path)})})]})]})}function ti(t){return t.startsWith("+++ ")||t.startsWith("--- ")||t.startsWith("diff ")||t.startsWith("index ")?"file-header":t.startsWith("@@")?"hunk":t.startsWith("+")?"added":t.startsWith("-")?"removed":t.startsWith("###")?"section-title":t==="---"?"separator":"context"}function si(t){return t.split(`
|
|
4
|
+
`).map(s=>({type:ti(s),content:s}))}function ni({diffText:t}){const s=si(t);return e.jsx("div",{className:"diff-viewer",children:e.jsx("pre",{className:"diff-pre",children:s.map((n,a)=>e.jsx("div",{className:`diff-line diff-line--${n.type}`,children:e.jsx("span",{className:"diff-line-content",children:n.content||" "})},a))})})}class ai{diff(s,n,a={}){let o;typeof a=="function"?(o=a,a={}):"callback"in a&&(o=a.callback);const r=this.castInput(s,a),l=this.castInput(n,a),c=this.removeEmpty(this.tokenize(r,a)),d=this.removeEmpty(this.tokenize(l,a));return this.diffWithOptionsObj(c,d,a,o)}diffWithOptionsObj(s,n,a,o){var r;const l=y=>{if(y=this.postProcess(y,a),o){setTimeout(function(){o(y)},0);return}else return y},c=n.length,d=s.length;let h=1,m=c+d;a.maxEditLength!=null&&(m=Math.min(m,a.maxEditLength));const u=(r=a.timeout)!==null&&r!==void 0?r:1/0,p=Date.now()+u,f=[{oldPos:-1,lastComponent:void 0}];let C=this.extractCommon(f[0],n,s,0,a);if(f[0].oldPos+1>=d&&C+1>=c)return l(this.buildValues(f[0].lastComponent,n,s));let j=-1/0,g=1/0;const b=()=>{for(let y=Math.max(j,-h);y<=Math.min(g,h);y+=2){let x;const v=f[y-1],w=f[y+1];v&&(f[y-1]=void 0);let $=!1;if(w){const N=w.oldPos-y;$=w&&0<=N&&N<c}const R=v&&v.oldPos+1<d;if(!$&&!R){f[y]=void 0;continue}if(!R||$&&v.oldPos<w.oldPos?x=this.addToPath(w,!0,!1,0,a):x=this.addToPath(v,!1,!0,1,a),C=this.extractCommon(x,n,s,y,a),x.oldPos+1>=d&&C+1>=c)return l(this.buildValues(x.lastComponent,n,s))||!0;f[y]=x,x.oldPos+1>=d&&(g=Math.min(g,y-1)),C+1>=c&&(j=Math.max(j,y+1))}h++};if(o)(function y(){setTimeout(function(){if(h>m||Date.now()>p)return o(void 0);b()||y()},0)})();else for(;h<=m&&Date.now()<=p;){const y=b();if(y)return y}}addToPath(s,n,a,o,r){const l=s.lastComponent;return l&&!r.oneChangePerToken&&l.added===n&&l.removed===a?{oldPos:s.oldPos+o,lastComponent:{count:l.count+1,added:n,removed:a,previousComponent:l.previousComponent}}:{oldPos:s.oldPos+o,lastComponent:{count:1,added:n,removed:a,previousComponent:l}}}extractCommon(s,n,a,o,r){const l=n.length,c=a.length;let d=s.oldPos,h=d-o,m=0;for(;h+1<l&&d+1<c&&this.equals(a[d+1],n[h+1],r);)h++,d++,m++,r.oneChangePerToken&&(s.lastComponent={count:1,previousComponent:s.lastComponent,added:!1,removed:!1});return m&&!r.oneChangePerToken&&(s.lastComponent={count:m,previousComponent:s.lastComponent,added:!1,removed:!1}),s.oldPos=d,h}equals(s,n,a){return a.comparator?a.comparator(s,n):s===n||!!a.ignoreCase&&s.toLowerCase()===n.toLowerCase()}removeEmpty(s){const n=[];for(let a=0;a<s.length;a++)s[a]&&n.push(s[a]);return n}castInput(s,n){return s}tokenize(s,n){return Array.from(s)}join(s){return s.join("")}postProcess(s,n){return s}get useLongestToken(){return!1}buildValues(s,n,a){const o=[];let r;for(;s;)o.push(s),r=s.previousComponent,delete s.previousComponent,s=r;o.reverse();const l=o.length;let c=0,d=0,h=0;for(;c<l;c++){const m=o[c];if(m.removed)m.value=this.join(a.slice(h,h+m.count)),h+=m.count;else{if(!m.added&&this.useLongestToken){let u=n.slice(d,d+m.count);u=u.map(function(p,f){const C=a[h+f];return C.length>p.length?C:p}),m.value=this.join(u)}else m.value=this.join(n.slice(d,d+m.count));d+=m.count,m.added||(h+=m.count)}}return o}}function Bs(t,s){let n;for(n=0;n<t.length&&n<s.length;n++)if(t[n]!=s[n])return t.slice(0,n);return t.slice(0,n)}function Ws(t,s){let n;if(!t||!s||t[t.length-1]!=s[s.length-1])return"";for(n=0;n<t.length&&n<s.length;n++)if(t[t.length-(n+1)]!=s[s.length-(n+1)])return t.slice(-n);return t.slice(-n)}function ts(t,s,n){if(t.slice(0,s.length)!=s)throw Error(`string ${JSON.stringify(t)} doesn't start with prefix ${JSON.stringify(s)}; this is a bug`);return n+t.slice(s.length)}function ss(t,s,n){if(!s)return t+n;if(t.slice(-s.length)!=s)throw Error(`string ${JSON.stringify(t)} doesn't end with suffix ${JSON.stringify(s)}; this is a bug`);return t.slice(0,-s.length)+n}function Ge(t,s){return ts(t,s,"")}function ut(t,s){return ss(t,s,"")}function Vs(t,s){return s.slice(0,oi(t,s))}function oi(t,s){let n=0;t.length>s.length&&(n=t.length-s.length);let a=s.length;t.length<s.length&&(a=t.length);const o=Array(a);let r=0;o[0]=0;for(let l=1;l<a;l++){for(s[l]==s[r]?o[l]=o[r]:o[l]=r;r>0&&s[l]!=s[r];)r=o[r];s[l]==s[r]&&r++}r=0;for(let l=n;l<t.length;l++){for(;r>0&&t[l]!=s[r];)r=o[r];t[l]==s[r]&&r++}return r}function za(t,s){const n=[];for(const a of Array.from(s.segment(t))){const o=a.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(o)?n[n.length-1]+=o:n.push(o)}return n}function ns(t,s){if(s)return Je(t,s)[1];let n;for(n=t.length-1;n>=0&&t[n].match(/\s/);n--);return t.substring(n+1)}function Me(t,s){if(s)return Je(t,s)[0];const n=t.match(/^\s*/);return n?n[0]:""}function Je(t,s){if(!s)return[Me(t),ns(t)];if(s.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');const n=za(t,s),a=n[0],o=n[n.length-1],r=/\s/.test(a)?a:"",l=/\s/.test(o)?o:"";return[r,l]}const qs="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",ri=new RegExp(`[${qs}]+|\\s+|[^${qs}]`,"ug");class li extends ai{equals(s,n,a){return a.ignoreCase&&(s=s.toLowerCase(),n=n.toLowerCase()),s.trim()===n.trim()}tokenize(s,n={}){let a;if(n.intlSegmenter){const l=n.intlSegmenter;if(l.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');a=za(s,l)}else a=s.match(ri)||[];const o=[];let r=null;return a.forEach(l=>{/\s/.test(l)?r==null?o.push(l):o.push(o.pop()+l):r!=null&&/\s/.test(r)?o[o.length-1]==r?o.push(o.pop()+l):o.push(r+l):o.push(l),r=l}),o}join(s){return s.map((n,a)=>a==0?n:n.replace(/^\s+/,"")).join("")}postProcess(s,n){if(!s||n.oneChangePerToken)return s;let a=null,o=null,r=null;return s.forEach(l=>{l.added?o=l:l.removed?r=l:((o||r)&&Gs(a,r,o,l,n.intlSegmenter),a=l,o=null,r=null)}),(o||r)&&Gs(a,r,o,null,n.intlSegmenter),s}}const ii=new li;function ci(t,s,n){return ii.diff(t,s,n)}function Gs(t,s,n,a,o){if(s&&n){const[r,l]=Je(s.value,o),[c,d]=Je(n.value,o);if(t){const h=Bs(r,c);t.value=ss(t.value,c,h),s.value=Ge(s.value,h),n.value=Ge(n.value,h)}if(a){const h=Ws(l,d);a.value=ts(a.value,d,h),s.value=ut(s.value,h),n.value=ut(n.value,h)}}else if(n){if(t){const r=Me(n.value,o);n.value=n.value.substring(r.length)}if(a){const r=Me(a.value,o);a.value=a.value.substring(r.length)}}else if(t&&a){const r=Me(a.value,o),[l,c]=Je(s.value,o),d=Bs(r,l);s.value=Ge(s.value,d);const h=Ws(Ge(r,d),c);s.value=ut(s.value,h),a.value=ts(a.value,r,h),t.value=ss(t.value,r,r.slice(0,r.length-h.length))}else if(a){const r=Me(a.value,o),l=ns(s.value,o),c=Vs(l,r);s.value=ut(s.value,c)}else if(t){const r=ns(t.value,o),l=Me(s.value,o),c=Vs(r,l);s.value=Ge(s.value,c)}}const Gt={create:"Created",update:"Updated",patch:"Patched",delete:"Deleted",snapshot:"Snapshot"},Kt={create:"➕",update:"📝",patch:"🩹",delete:"🗑️",snapshot:"📸"};function di(t,s){const n={};t.title!==s.title&&(n.title={from:t.title,to:s.title});const a=s.tags.filter(f=>!t.tags.includes(f)),o=t.tags.filter(f=>!s.tags.includes(f));(a.length||o.length)&&(n.tags={added:a,removed:o});const r=t.tracked_files.map(f=>f.path),l=s.tracked_files.map(f=>f.path),c=l.filter(f=>!r.includes(f)),d=r.filter(f=>!l.includes(f));(c.length||d.length)&&(n.tracked_files={added:c,removed:d});const h=t.related_docs??[],m=s.related_docs??[],u=m.filter(f=>!h.includes(f)),p=h.filter(f=>!m.includes(f));return(u.length||p.length)&&(n.related_docs={added:u,removed:p}),n}function ui({diff:t}){return e.jsxs("div",{className:"history-meta-diff",children:[e.jsx("span",{className:"history-meta-diff-title",children:"Metadata changes"}),t.title&&e.jsxs("div",{className:"history-meta-diff-row",children:[e.jsx("span",{className:"history-meta-diff-field",children:"Title"}),e.jsx("span",{className:"history-meta-diff-chip--removed",children:t.title.from}),e.jsx("span",{className:"history-meta-diff-arrow",children:"→"}),e.jsx("span",{className:"history-meta-diff-chip--added",children:t.title.to})]}),t.tags&&e.jsxs("div",{className:"history-meta-diff-row",children:[e.jsx("span",{className:"history-meta-diff-field",children:"Tags"}),e.jsxs("div",{className:"history-meta-diff-chips",children:[t.tags.removed.map(s=>e.jsxs("span",{className:"history-meta-diff-chip--removed",children:["− ",s]},s)),t.tags.added.map(s=>e.jsxs("span",{className:"history-meta-diff-chip--added",children:["+ ",s]},s))]})]}),t.tracked_files&&e.jsxs("div",{className:"history-meta-diff-row",children:[e.jsx("span",{className:"history-meta-diff-field",children:"Tracked files"}),e.jsxs("div",{className:"history-meta-diff-chips",children:[t.tracked_files.removed.map(s=>e.jsxs("span",{className:"history-meta-diff-chip--removed",children:["− ",s]},s)),t.tracked_files.added.map(s=>e.jsxs("span",{className:"history-meta-diff-chip--added",children:["+ ",s]},s))]})]}),t.related_docs&&e.jsxs("div",{className:"history-meta-diff-row",children:[e.jsx("span",{className:"history-meta-diff-field",children:"Related docs"}),e.jsxs("div",{className:"history-meta-diff-chips",children:[t.related_docs.removed.map(s=>e.jsxs("span",{className:"history-meta-diff-chip--removed",children:["− ",s]},s)),t.related_docs.added.map(s=>e.jsxs("span",{className:"history-meta-diff-chip--added",children:["+ ",s]},s))]})]})]})}function hi({changes:t}){return e.jsx("div",{className:"history-inline-diff",children:t.map((s,n)=>s.added?e.jsx("span",{className:"history-inline-diff--added",children:s.value},n):s.removed?e.jsx("span",{className:"history-inline-diff--removed",children:s.value},n):e.jsx("span",{children:s.value},n))})}function mi(t){const s=[],n=[];let a=null;for(const o of t)o.changeType==="snapshot"?(a={snapshot:o,subEntries:[]},n.push(a)):a===null?s.push(o):a.subEntries.push(o);return{uncommitted:s,groups:n}}function pi({docId:t,project:s,entries:n,selectedVersion:a,onSelectVersion:o,markdownComponents:r}){const[l,c]=i.useState(null),[d,h]=i.useState(!1),[m,u]=i.useState(new Set),{uncommitted:p,groups:f}=i.useMemo(()=>mi(n),[n]),C=v=>{u(w=>{const $=new Set(w);return $.has(v)?$.delete(v):$.add(v),$})},j=a!==null&&(a.changeType==="update"||a.changeType==="patch"||a.changeType==="snapshot")&&a.version>1,g=(()=>{if(!a||!j)return null;if(a.changeType==="snapshot"){const v=n.filter(w=>w.version<a.version&&w.changeType==="snapshot").sort((w,$)=>$.version-w.version);return v.length>0?v[0].version:Math.min(...n.map(w=>w.version))}return a.version-1})(),b=g!==null?n.find(v=>v.version===g)??null:null,y=b?di(b.metadata,a.metadata):null,x=y&&Object.keys(y).length>0;return i.useEffect(()=>{if(c(null),!a||!j||g===null)return;let v=!1;return h(!0),fetch(`/api/history-version/${ge(t)}/${g}?project=${encodeURIComponent(s)}`).then(w=>w.json()).then(w=>{if(v)return;const $=w?.content??"",R=a.content??"";c(ci($,R))}).catch(()=>{v||c([])}).finally(()=>{v||h(!1)}),()=>{v=!0}},[a?.version]),n.length===0?e.jsx("div",{className:"history-viewer",children:e.jsx("div",{className:"doc-viewer-empty",children:"No version history available for this document."})}):e.jsxs("div",{className:"history-viewer",children:[e.jsxs("div",{className:"history-list",children:[p.length>0&&e.jsxs("div",{className:"history-uncommitted",children:[e.jsx("span",{className:"history-uncommitted-label",children:"Non archivé"}),p.map(v=>{const w=a?.version===v.version,$=new Date(v.changedAt).toLocaleString(),R=Gt[v.changeType]??v.changeType,N=Kt[v.changeType]??"❓";return e.jsxs("button",{className:`history-entry history-entry--sub${w?" history-entry--active":""}`,onClick:()=>o(v.version),children:[e.jsxs("div",{className:"history-entry-header",children:[e.jsxs("span",{className:"history-entry-version",children:["v",v.version]}),e.jsxs("span",{className:`history-entry-type history-entry-type--${v.changeType}`,children:[N," ",R]})]}),e.jsx("span",{className:"history-entry-date",children:$})]},v.version)})]}),f.length===0&&p.length===0&&e.jsx("div",{className:"doc-viewer-empty",children:"No version history available."}),f.map(v=>{const w=a?.version===v.snapshot.version,$=m.has(v.snapshot.version),R=new Date(v.snapshot.changedAt).toLocaleString();return e.jsxs("div",{className:"history-group",children:[e.jsx("div",{className:`history-entry history-entry--snapshot-card${w?" history-entry--active":""}`,children:e.jsxs("button",{className:"history-entry-snapshot-main",onClick:()=>o(v.snapshot.version),children:[e.jsxs("div",{className:"history-entry-header",children:[e.jsxs("span",{className:"history-entry-version",children:["Version ",v.snapshot.version]}),e.jsx("span",{className:"history-entry-type history-entry-type--snapshot",children:"📸 Snapshot"})]}),e.jsxs("div",{className:"history-entry-footer",children:[e.jsx("span",{className:"history-entry-date",children:R}),v.subEntries.length>0&&e.jsx("span",{className:`history-group-toggle${$?" history-group-toggle--open":""}`,onClick:N=>{N.stopPropagation(),C(v.snapshot.version)},role:"button",tabIndex:0,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.stopPropagation(),C(v.snapshot.version))},children:$?"Masquer ▲":`Voir les ${v.subEntries.length} modification${v.subEntries.length>1?"s":""} ▼`})]})]})}),$&&e.jsx("div",{className:"history-group-entries",children:v.subEntries.map(N=>{const P=a?.version===N.version,L=new Date(N.changedAt).toLocaleString(),S=Gt[N.changeType]??N.changeType,I=Kt[N.changeType]??"❓";return e.jsxs("button",{className:`history-entry history-entry--sub${P?" history-entry--active":""}`,onClick:()=>o(N.version),children:[e.jsxs("div",{className:"history-entry-header",children:[e.jsxs("span",{className:"history-entry-version",children:["v",N.version]}),e.jsxs("span",{className:`history-entry-type history-entry-type--${N.changeType}`,children:[I," ",S]})]}),e.jsx("span",{className:"history-entry-date",children:L})]},N.version)})})]},v.snapshot.version)})]}),e.jsx("div",{className:"history-content",children:a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"history-content-meta",children:[e.jsxs("div",{className:"history-content-meta-title",children:[e.jsx("strong",{children:a.metadata.title}),e.jsxs("span",{className:"history-content-version",children:["Version ",a.version]})]}),e.jsxs("div",{className:"history-content-meta-info",children:[e.jsxs("span",{className:`history-entry-type history-entry-type--${a.changeType}`,children:[Kt[a.changeType]??"❓"," ",Gt[a.changeType]??a.changeType]}),e.jsx("span",{className:"history-content-date",children:new Date(a.changedAt).toLocaleString()}),j&&d&&e.jsx("span",{className:"history-diff-loading",children:"Loading diff…"}),j&&!d&&g!==null&&e.jsxs("span",{className:"history-diff-base",children:["vs v",g]})]}),x&&e.jsx(ui,{diff:y})]}),j&&a.changeType==="snapshot"&&!d&&l!==null&&e.jsxs("div",{className:"history-diff-recap-banner",children:["Récapitulatif des modifications effectuées depuis le dernier évènement ",e.jsx("strong",{children:"snapshot"})]}),j?l!==null?e.jsx(hi,{changes:l}):null:e.jsx("div",{className:"doc-content",children:e.jsx(tn,{remarkPlugins:[nn],rehypePlugins:[sn],components:r,children:a.content??""})})]}):e.jsx("div",{className:"doc-viewer-empty",children:"Select a version to view its content."})})]})}const fi={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",java:"java",rs:"rust",cs:"csharp",cpp:"cpp",c:"c",sh:"bash",bash:"bash",zsh:"bash",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",md:"markdown",css:"css",scss:"scss",html:"html",xml:"xml",sql:"sql"};function gi(t){const s=t.split(".").pop()?.toLowerCase()??"";return fi[s]??"text"}function xi({docId:t,project:s,filePath:n,onClose:a}){const[o,r]=i.useState([]),[l,c]=i.useState(!0),[d,h]=i.useState(null);i.useEffect(()=>{const u=new AbortController,p=n.split("/").map(encodeURIComponent).join("/");return fetch(`/api/file-section/${p}?docId=${encodeURIComponent(t)}&project=${encodeURIComponent(s)}`,{signal:u.signal}).then(f=>f.json()).then(f=>{if(f.error)throw new Error(f.error);r(f.sections??[])}).catch(f=>{f.name!=="AbortError"&&h(f.message)}).finally(()=>c(!1)),()=>u.abort()},[t,n]),i.useEffect(()=>{const u=p=>{p.key==="Escape"&&a()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[a]);const m=gi(n);return e.jsx("div",{className:"modal-overlay",onClick:a,children:e.jsxs("div",{className:"modal-content",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{className:"modal-title",children:n}),e.jsx("button",{className:"modal-close-btn",onClick:a,children:"✕"})]}),e.jsxs("div",{className:"modal-body",children:[l&&e.jsx("p",{style:{color:"#8b949e",fontSize:13},children:"Loading…"}),d&&e.jsx("p",{style:{color:"#f85149",fontSize:13},children:d}),!l&&!d&&o.map((u,p)=>e.jsxs("div",{children:[e.jsxs("p",{className:"section-code-header",children:["Lines ",u.start,"–",u.end]}),e.jsx(wo,{language:m,style:ko,customStyle:{margin:0,borderRadius:"6px",fontSize:"13px"},codeTagProps:{style:{fontFamily:"'Fira Code', 'Cascadia Code', Consolas, monospace"}},showLineNumbers:!0,startingLineNumber:u.start,children:u.code})]},p))]})]})})}function vi({project:t,triggerRef:s,onInsert:n,onClose:a}){const[o,r]=i.useState("upload"),[l,c]=i.useState(""),[d,h]=i.useState(""),[m,u]=i.useState(!1),[p,f]=i.useState(null),[C,j]=i.useState([]),[g,b]=i.useState({visibility:"hidden"}),y=i.useRef(null);i.useLayoutEffect(()=>{const R=y.current;if(!R)return;const N=R.offsetHeight,P=360;b({position:"fixed",top:Math.max(8,(window.innerHeight-N)/2),left:Math.max(8,(window.innerWidth-P)/2),width:P,visibility:"visible"})},[s]),i.useEffect(()=>{fetch(`/api/images/${encodeURIComponent(t)}`).then(R=>R.json()).then(R=>j(R)).catch(()=>{})},[t]),i.useEffect(()=>{function R(N){y.current&&!y.current.contains(N.target)&&s.current!==N.target&&a()}return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[a,s]);const x=i.useCallback(async R=>{u(!0),f(null);try{const N=new FormData;N.append("file",R);const P=await fetch(`/api/images?project=${encodeURIComponent(t)}`,{method:"POST",body:N});if(!P.ok){const S=await P.json().catch(()=>({}));throw new Error(S.error??"Upload failed")}const{url:L}=await P.json();n(``),a()}catch(N){f(N instanceof Error?N.message:"Upload failed")}finally{u(!1)}},[t,l,n,a]),v=async R=>{const N=R.target.files?.[0];N&&await x(N)};i.useEffect(()=>{const R=async N=>{const L=Array.from(N.clipboardData?.items??[]).find(B=>B.type.startsWith("image/"));if(!L)return;N.preventDefault();const S=L.getAsFile();if(!S)return;const I=S.type.split("/")[1]??"png",E=new File([S],`paste-${Date.now()}.${I}`,{type:S.type});await x(E)};return document.addEventListener("paste",R),()=>document.removeEventListener("paste",R)},[x]);const w=()=>{d.trim()&&(n(`})`),a())},$=R=>{n(``),a()};return ml.createPortal(e.jsxs("div",{className:"image-insert-popover",ref:y,style:g,children:[e.jsxs("div",{className:"image-insert-header",children:[e.jsx("span",{className:"image-insert-title",children:"Insert image"}),e.jsx("button",{className:"image-insert-close",onClick:a,title:"Close",children:"✕"})]}),e.jsxs("div",{className:"image-insert-tabs",children:[e.jsx("button",{className:`image-insert-tab${o==="upload"?" active":""}`,onClick:()=>r("upload"),children:"Upload"}),e.jsx("button",{className:`image-insert-tab${o==="url"?" active":""}`,onClick:()=>r("url"),children:"URL"})]}),e.jsxs("div",{className:"image-insert-alt-row",children:[e.jsx("label",{className:"image-insert-label",children:"Alt text"}),e.jsx("input",{className:"image-insert-input",type:"text",placeholder:"Description (optional)",value:l,onChange:R=>c(R.target.value)})]}),o==="upload"?e.jsxs("div",{className:"image-insert-tab-content",children:[e.jsxs("label",{className:`image-upload-label${m?" uploading":""}`,children:[e.jsx("input",{type:"file",accept:"image/*",style:{display:"none"},onChange:v,disabled:m}),m?"⏳ Uploading…":"📁 Choose a file"]}),e.jsx("p",{className:"image-paste-hint",children:"or press Ctrl+V / ⌘V to paste from clipboard"}),p&&e.jsx("div",{className:"image-insert-error",children:p})]}):e.jsxs("div",{className:"image-insert-tab-content",children:[e.jsx("input",{className:"image-insert-input",type:"text",placeholder:"https://example.com/image.png",value:d,onChange:R=>h(R.target.value),onKeyDown:R=>R.key==="Enter"&&w()}),e.jsx("button",{className:"image-insert-btn-insert",onClick:w,disabled:!d.trim(),children:"Insert"})]}),C.length>0&&e.jsxs("div",{className:"image-insert-gallery-section",children:[e.jsx("div",{className:"image-insert-gallery-label",children:"Project images"}),e.jsx("div",{className:"image-thumbs",children:C.map(R=>e.jsx("img",{src:R.url,alt:R.filename,className:"image-thumb",title:R.filename,onClick:()=>$(R.url)},R.filename))})]})]}),document.body)}function Ks(t,s){return!t||t.status==="no_tracking"?"unknown":t.modified.includes(s)?"modified":t.missing.includes(s)?"missing":(t.anchors_lost??[]).includes(s)?"anchors_lost":t.unchanged.includes(s)?"ok":"unknown"}function ji(t){if(!t)return"—";const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const n=a=>String(a).padStart(2,"0");return`${s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}, ${n(s.getHours())}:${n(s.getMinutes())}`}function bi({doc:t,isStale:s,report:n,toc:a,activeHeadingId:o,version:r,onSelectHeading:l,onSelectFile:c,onClose:d,tab:h,onTab:m,comments:u,unreadComments:p}){const f=oe(),{docs:C,projects:j,currentProject:g}=J(),b=x=>!!t.tracked_files.find(w=>w.path===x)?.sections?.length&&Ks(n,x)!=="anchors_lost",y=u!==null&&h==="comments";return e.jsxs("aside",{className:"context-rail",children:[e.jsxs("div",{className:"rail-section rail-section--toc",children:[e.jsxs("div",{className:"rail-section-head",children:[u!==null?e.jsxs("div",{className:"rail-tabs",children:[e.jsx("button",{type:"button",className:`rail-tab${y?"":" active"}`,onClick:()=>m("page"),children:"On this page"}),e.jsxs("button",{type:"button",className:`rail-tab${y?" active":""}`,onClick:()=>m("comments"),children:["Comments",p>0&&e.jsx("span",{className:"rail-tab-count",children:p})]})]}):e.jsx("span",{className:"rail-label",children:a.length>0?"On this page":""}),e.jsx("button",{className:"rail-collapse-btn",onClick:d,title:"Hide details (Ctrl/⌘ + \\)",children:"▷|"})]}),y&&u,!y&&a.length>0&&e.jsx("nav",{className:"rail-toc",children:a.map(x=>e.jsx("button",{className:`rail-toc-item rail-toc-item--h${x.level}${o===x.id?" active":""}`,onClick:()=>l(x.id),children:x.text},x.id))})]}),!y&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rail-section",children:[e.jsx("span",{className:"rail-label",children:"Status"}),e.jsxs("div",{className:"rail-row",children:[e.jsx("span",{className:"rail-key",children:"Freshness"}),e.jsx("span",{className:`rail-chip${s?" rail-chip--stale":" rail-chip--fresh"}`,children:s?"Outdated":"Up to date"})]}),e.jsxs("div",{className:"rail-row",children:[e.jsx("span",{className:"rail-key",children:"Last updated"}),e.jsx("span",{className:"rail-val",children:ji(t.updatedAt)})]}),e.jsxs("div",{className:"rail-row",children:[e.jsx("span",{className:"rail-key",children:"Version"}),e.jsx("span",{className:"rail-val",children:r!==null?`v${r}`:"—"})]})]}),t.tracked_files.length>0&&e.jsxs("div",{className:"rail-section",children:[e.jsxs("span",{className:"rail-label",children:["Tracked files · ",t.tracked_files.length]}),e.jsx("div",{className:"rail-files",children:t.tracked_files.map(x=>{const v=Ks(n,x.path),w=b(x.path);return e.jsxs("button",{className:`rail-file${w?" rail-file--clickable":""}`,onClick:w?()=>c(x.path):void 0,title:w?`${x.path} — voir le code de la section`:x.path,children:[e.jsx("span",{className:`rail-file-dot rail-file-dot--${v}`}),e.jsx("span",{className:"rail-file-path",children:x.path})]},x.path)})}),e.jsx("div",{className:"rail-legend",children:"modified · up to date · missing · anchors lost"})]}),t.tags.length>0&&e.jsxs("div",{className:"rail-section",children:[e.jsx("span",{className:"rail-label",children:"Tags"}),e.jsx("div",{className:"rail-tags",children:t.tags.map(x=>e.jsx("span",{className:"tag-badge",children:x},x))})]}),t.related_docs&&t.related_docs.length>0&&e.jsxs("div",{className:"rail-section",children:[e.jsx("span",{className:"rail-label",children:"Related pages"}),e.jsx("div",{className:"rail-links",children:t.related_docs.map(x=>{const v=x.indexOf(":");if(v!==-1){const $=x.slice(0,v),R=x.slice(v+1);return j.includes($)?e.jsxs("button",{className:"rail-link rail-link--cross-project",onClick:()=>f(se($,R)),title:`Projet : ${$}`,children:["↗ ",$," · ",R]},x):e.jsxs("span",{className:"rail-link rail-link--broken",children:[x," (projet introuvable)"]},x)}const w=C.find($=>$.id===x);return w?e.jsxs("button",{className:"rail-link",onClick:()=>f(se(g,x)),children:["▤ ",w.title]},x):e.jsxs("span",{className:"rail-link rail-link--broken",children:[x," (lien cassé)"]},x)})})]})]})]})}function Jt(t){return!t.root.read||t.replies.some(s=>!s.read)}function yi(t){return[t.root.id,...t.replies.map(s=>s.id)]}function ht(t){return t===null?"an unversioned publication":`v${t}`}function Ni({data:t,locatedIds:s,activeId:n,hoveredId:a,readOnly:o,onActivate:r,onHover:l}){const c=Co(t.comments),d=c.filter(N=>!N.root.detached),h=c.filter(N=>N.root.detached),m=t.comments.filter(N=>!N.read).length,[u,p]=i.useState(m>0?"unread":"all"),[f,C]=i.useState(null),[j,g]=i.useState(!1),[b,y]=i.useState(null),x=t.publication?.id,v=t.publication?.commentsClosed===!0;if(!x)return e.jsx("div",{className:"cp-empty",children:"This document is not published: readers cannot comment on it."});const w=async N=>{g(!0),y(null);try{await N()}catch(P){y(P instanceof Error?P.message:String(P))}finally{g(!1)}},$=u==="unread"?d.filter(Jt):d,R=(N,P)=>{const{root:L}=N,S=Jt(N),I=s.has(L.id);return e.jsxs("div",{className:`cp-card${S?" cp-card--unread":""}${P?" cp-card--detached":""}${n===L.id||a===L.id?" cp-card--active":""}`,onClick:()=>r(L.id),onMouseEnter:()=>l(L.id),onMouseLeave:()=>l(null),children:[e.jsxs("div",{className:"cp-head",children:[P?e.jsx(vs,{size:12,className:"cp-state cp-state--detached"}):S?e.jsx("span",{className:"cp-dot",title:"Unread"}):e.jsx(ke,{size:12,className:"cp-state cp-state--read"}),e.jsx("span",{className:"cp-author",title:Es,children:$s(L.author)}),e.jsxs("span",{className:"cp-time",title:new Date(L.createdAt).toLocaleString(),children:["· ",Rs(L.createdAt)]}),!o&&e.jsxs("span",{className:"cp-actions",onClick:E=>E.stopPropagation(),children:[S&&e.jsx("button",{type:"button",className:"cp-icon",title:"Mark as read",disabled:j,onClick:()=>w(()=>Ps(x,yi(N))),children:e.jsx(ke,{size:14})}),e.jsx("button",{type:"button",className:"cp-icon cp-icon--danger",title:"Delete",disabled:j,onClick:()=>C(L.id),children:e.jsx(Dl,{size:14})})]})]}),L.anchor&&e.jsxs("div",{className:`cp-quote${I||P?"":" cp-quote--lost"}`,children:["« ",L.anchor.exact," »",P&&L.detached?` — ${ht(L.detached.fromVersion)}`:""]}),!P&&!I&&e.jsx("div",{className:"cp-note",children:"Passage changed since the publication: not highlighted here."}),e.jsx("div",{className:"cp-body",children:L.body}),N.replies.map(E=>e.jsxs("div",{className:`cp-reply${E.read?"":" cp-reply--unread"}`,children:[e.jsxs("div",{className:"cp-reply-head",children:[e.jsx("span",{title:Es,children:$s(E.author)})," · ",Rs(E.createdAt)]}),e.jsx("div",{className:"cp-body",children:E.body})]},E.id)),P&&L.detached&&e.jsxs("div",{className:"cp-note",children:["Detached when the publication went from ",ht(L.detached.fromVersion)," to"," ",ht(L.detached.toVersion)]}),f===L.id&&e.jsxs("div",{className:"cp-confirm",onClick:E=>E.stopPropagation(),children:[e.jsxs("span",{children:["Delete this comment",N.replies.length>0?` and its ${N.replies.length} replies`:"","?"]}),e.jsx("button",{type:"button",className:"cp-confirm-btn",onClick:()=>C(null),disabled:j,children:"Cancel"}),e.jsx("button",{type:"button",className:"cp-confirm-btn cp-confirm-btn--danger",disabled:j,onClick:()=>w(async()=>{await So(x,[L.id]),C(null)}),children:"Delete"})]})]},L.id)};return e.jsxs("div",{className:"cp",children:[e.jsxs("div",{className:"cp-toolbar",children:[e.jsxs("button",{type:"button",className:`cp-filter${u==="unread"?" active":""}`,onClick:()=>p("unread"),children:["Unread · ",c.filter(Jt).length]}),e.jsxs("button",{type:"button",className:`cp-filter${u==="all"?" active":""}`,onClick:()=>p("all"),children:["All · ",d.length]}),!o&&m>0&&e.jsx("button",{type:"button",className:"cp-mark-all",disabled:j,onClick:()=>w(()=>Ps(x,null)),children:"Mark all as read"})]}),e.jsxs("div",{className:"cp-usage",children:[e.jsxs("span",{children:[t.comments.length," / ",t.limit," comments on the published ",ht(t.publication?.version??null),v&&" · closed to new comments"]}),!o&&e.jsx("button",{type:"button",className:"cp-close-toggle",disabled:j,title:v?"Let readers add comments again":"Readers keep seeing the comments but can no longer add any",onClick:()=>w(()=>Eo(x,!v)),children:v?"Reopen comments":"Close comments"})]}),b&&e.jsx("div",{className:"cp-error",children:b}),$.length===0?h.length===0&&e.jsx("div",{className:"cp-empty",children:u==="unread"?"No unread comment.":"No comment yet."}):$.map(N=>R(N,!1)),h.length>0&&e.jsxs("div",{className:"cp-detached",children:[e.jsxs("span",{className:"rail-label",children:["Detached · ",h.length]}),e.jsx("div",{className:"cp-detached-text",children:"Their passage is absent from the published version: readers no longer see them. They still count toward the limit until deleted."}),h.map(N=>R(N,!0))]})]})}function wi(t,s){const{commentsVersion:n,publicationsVersion:a}=J(),[o,r]=i.useState(null),[l,c]=i.useState(0),d=`${t}\0${s??""}`;i.useEffect(()=>{if(!s)return;let m=!1;return $o(t,s).then(u=>{m||r({key:d,data:u})}).catch(u=>console.error(`Comments of "${s}" could not be loaded: ${u.message}`)),()=>{m=!0}},[d,t,s,n,a,l]);const h=i.useCallback(()=>c(m=>m+1),[]);return{data:o?.key===d?o.data:null,reload:h}}function ki(){const{currentProject:t,commentsVersion:s,publicationsVersion:n,hasReceivedInitialState:a,setCommentSummary:o}=J();i.useEffect(()=>{if(!a)return;let r=!1;return Ro(t).then(l=>{r||o(t,l)}).catch(l=>console.error(`Comment counts of "${t}" could not be loaded: ${l.message}`)),()=>{r=!0}},[t,s,n,a])}function Ci(t){const{commentSummary:s,currentProject:n}=J();return!t||s.project!==n?null:s.docs[t]??null}function Fa(){const[t,s]=i.useState(!1);return{copied:t,copy:async a=>{await navigator.clipboard.writeText(a),s(!0),setTimeout(()=>s(!1),2e3)}}}function Oa(t){const{publicationsVersion:s}=J(),[n,a]=i.useState(null),[o,r]=i.useState(null),[l,c]=i.useState(0);i.useEffect(()=>{let h=!1;return Po(t).then(m=>{h||(a({project:t,publications:m}),r(null))}).catch(m=>{h||r(m.message)}),()=>{h=!0}},[t,s,l]);const d=i.useCallback(()=>c(h=>h+1),[]);return{publications:n?.project===t?n.publications:null,error:o,reload:d}}function Si({project:t,doc:s,latestVersion:n,readOnly:a}){const{publications:o,reload:r}=Oa(t),[l,c]=i.useState(!1),d=o?.find(m=>m.docId===s.id)??null;if(i.useEffect(()=>{if(!l)return;const m=u=>{u.key==="Escape"&&c(!1)};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[l]),o===null||!d&&a)return null;const h=()=>{l||r(),c(!l)};return e.jsxs("div",{className:"menu-anchor",children:[e.jsxs("button",{className:`btn-secondary publish-btn${l?" publish-btn--open":""}`,onClick:h,title:d?"Public link of this document":"Publish this document",children:[e.jsx(Dt,{size:14,className:d?"publish-btn-icon--published":void 0}),d?"Published":"Publish",d?.status==="modified"&&e.jsx("span",{className:"publish-btn-dot",title:"Changed since it was published"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"menu-backdrop",onClick:()=>c(!1)}),e.jsx("div",{className:"publish-popover",role:"dialog","aria-label":d?"Document published":"Publish this document",children:d?e.jsx($i,{publication:d,readOnly:a,onClose:()=>c(!1),onChanged:r}):e.jsx(Ei,{project:t,doc:s,latestVersion:n,onClose:()=>c(!1),onChanged:r})})]})]})}function Ua({title:t,published:s,onClose:n}){return e.jsxs("div",{className:"publish-head",children:[s&&e.jsx("span",{className:"publish-online-dot"}),e.jsx("span",{className:"publish-title",children:t}),e.jsx("button",{className:"publish-close",onClick:n,"aria-label":"Close",children:e.jsx(rn,{size:14})})]})}function Ha({label:t,value:s,onChange:n,placeholder:a,multiline:o}){return e.jsxs("label",{className:"publish-field",children:[e.jsxs("span",{className:"publish-field-label",children:[t," ",e.jsx("span",{className:"publish-field-optional",children:"(optional)"})]}),o?e.jsx("textarea",{className:"publish-input publish-input--multiline",value:s,maxLength:Qt,rows:3,placeholder:a,onChange:r=>n(r.target.value),autoFocus:!0}):e.jsx("input",{className:"publish-input",value:s,maxLength:Qt,placeholder:a,onChange:r=>n(r.target.value)})]})}function Ei({project:t,doc:s,latestVersion:n,onClose:a,onChanged:o}){const[r,l]=i.useState(""),[c,d]=i.useState(!1),[h,m]=i.useState(null),u=async()=>{d(!0),m(null);try{await Do(t,s.id,r),o()}catch(p){m(p instanceof Error?p.message:String(p))}finally{d(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(Ua,{title:"Publish this document",onClose:a}),e.jsx("p",{className:"publish-text",children:"The public link shows the current version, frozen. Later changes only appear there once the publication is updated."}),e.jsxs("div",{className:"publish-version",children:[e.jsx(wl,{size:14}),"Version ",De(n)," · modified ",is(s.updatedAt)]}),e.jsx(Ha,{label:"Version note",value:r,onChange:l,placeholder:"e.g. First version shared with the infra team",multiline:!0}),e.jsxs("div",{className:"publish-access",children:[e.jsx(on,{size:14}),"Anyone with the link can read this document."]}),h&&e.jsx("div",{className:"publish-error",children:h}),e.jsxs("div",{className:"publish-actions",children:[e.jsx("button",{className:"btn-secondary",onClick:a,disabled:c,children:"Cancel"}),e.jsxs("button",{className:"btn-primary",onClick:u,disabled:c,children:[e.jsx(Dt,{size:14}),c?"Publishing…":"Publish"]})]})]})}function $i({publication:t,readOnly:s,onClose:n,onChanged:a}){const[o,r]=i.useState(""),[l,c]=i.useState(!1),[d,h]=i.useState(null),[m,u]=i.useState(!1),{copied:p,copy:f}=Fa(),C=an(t.token),j=t.status==="modified",g=async b=>{c(!0),h(null);try{await b(),r(""),u(!1),a()}catch(y){h(y instanceof Error?y.message:String(y))}finally{c(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(Ua,{title:"Document published",published:!0,onClose:n}),e.jsxs("div",{className:"publish-link",children:[e.jsx(on,{size:14,className:"publish-link-icon"}),e.jsx("span",{className:"publish-link-url",title:C,children:C}),e.jsx("a",{className:"publish-icon-btn",href:C,target:"_blank",rel:"noopener noreferrer",title:"Open the public page",children:e.jsx(qn,{size:14})}),e.jsx("button",{className:"publish-copy-btn",onClick:()=>f(C),title:"Copy the link",children:p?e.jsx(ke,{size:14}):e.jsx(Rt,{size:14})})]}),e.jsxs("div",{className:"publish-meta",children:["Published ",is(t.publishedAt)," · version ",De(t.version)]}),t.note&&e.jsx("div",{className:"publish-quote",children:t.note}),e.jsx("div",{className:"publish-sep"}),j?e.jsxs("div",{className:"publish-warning",children:[e.jsx(xs,{size:14}),e.jsxs("div",{children:["The document changed since it was published.",e.jsx("br",{}),"Published: ",De(t.version)," · current: ",De(t.currentVersion)]})]}):e.jsxs("div",{className:"publish-uptodate",children:[e.jsx(Ke,{size:14}),"The published version is up to date."]}),!s&&j&&!m&&e.jsx(Ha,{label:"Note for the new version",value:o,onChange:r,placeholder:"e.g. Added the Entry points section"}),d&&e.jsx("div",{className:"publish-error",children:d}),!s&&(m?e.jsx(Ba,{busy:l,onCancel:()=>u(!1),onConfirm:()=>g(()=>ln(t.id))}):e.jsxs("div",{className:"publish-actions publish-actions--split",children:[e.jsxs("button",{className:"btn-secondary publish-danger-btn",onClick:()=>u(!0),disabled:l,children:[e.jsx(vs,{size:14}),"Unpublish"]}),j&&e.jsxs("button",{className:"btn-primary",onClick:()=>g(()=>cn(t.id,o)),disabled:l,children:[e.jsx(Nt,{size:14}),l?"Updating…":"Update publication"]})]}))]})}function Ba({title:t,busy:s,onCancel:n,onConfirm:a}){return e.jsxs("div",{className:"publish-confirm",children:[e.jsx("div",{className:"publish-confirm-title",children:t?`Unpublish “${t}”?`:"Unpublish this document?"}),e.jsx("div",{className:"publish-confirm-text",children:"The link stops working immediately. Publishing again creates a new link."}),e.jsxs("div",{className:"publish-actions",children:[e.jsx("button",{className:"btn-secondary",onClick:n,disabled:s,children:"Cancel"}),e.jsx("button",{className:"publish-confirm-btn",onClick:a,disabled:s,children:s?"Unpublishing…":"Unpublish"})]})]})}function Js(t){return t.replace(/[^a-zA-Z0-9_\-. ]/g,"_")}const Ri=1280,as="mcp-documentor.contextRail",Ye=()=>typeof window>"u"||window.innerWidth>=Ri;function Pi(){try{const t=JSON.parse(localStorage.getItem(as)??"null");return t&&t.wide===Ye()?t.open:null}catch{return null}}function Yt(t){try{t===null?localStorage.removeItem(as):localStorage.setItem(as,JSON.stringify({open:t,wide:Ye()}))}catch{}}function Ys(t){if(!t)return"the last snapshot";const s=new Date(t);if(Number.isNaN(s.getTime()))return"the last snapshot";const n=a=>String(a).padStart(2,"0");return`${s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})} ${n(s.getHours())}:${n(s.getMinutes())}`}function Di(){const t=oe(),s=J(),{selectedDoc:n,selectedDocId:a,freshnessResult:o,setFreshnessResult:r,setSelectedDoc:l,setDocs:c,docs:d,currentProject:h,projects:m,historyEntries:u,historyVersionContent:p,setHistoryEntries:f,setHistoryVersionContent:C,readOnly:j,codeSourcesVersion:g}=s,b=i.useRef(null),y=i.useRef(null),x=i.useRef(null),[v,w]=i.useState("document"),[$,R]=i.useState(null),[N,P]=i.useState(!1),[L,S]=i.useState(!1),[I,E]=i.useState(!1),[B,F]=i.useState(!1),[W,T]=i.useState(!1),[V,K]=i.useState(""),[ee,ie]=i.useState(!1),[st,Le]=i.useState(null),[ze,je]=i.useState(!1),[Ce,be]=i.useState(null),[nt,Se]=i.useState(null),[Fe,Z]=i.useState(!1),[me,ce]=i.useState(!1),[Ee,$e]=i.useState(!1),[Te,ye]=i.useState(null),[M,U]=i.useState(!1),[q,G]=i.useState(!1),[pe,Mt]=i.useState([]),[so,It]=i.useState(null),[ys,Oe]=i.useState(()=>Pi()??Ye()),[no,Ue]=i.useState("page"),[fe,ao]=i.useState(null),[At,_t]=i.useState(null),[zt,at]=i.useState(null),Ns=i.useRef(null),Ft=k=>{Yt(k),Oe(k)},ws=v==="diff",ks=v==="history";i.useEffect(()=>{window.__pdfReady=!!(n&&!W)},[n,W]),i.useEffect(()=>{let k=Ye();const D=()=>{const _=Ye();_!==k&&(k=_,Yt(null),Oe(_))};return window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]),i.useEffect(()=>{const k=D=>{(D.metaKey||D.ctrlKey)&&D.key==="\\"&&(D.preventDefault(),Oe(_=>(Yt(!_),!_)))};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[]),i.useEffect(()=>{if(!a)return;window.__pdfReady=!1,window.__mermaidPending=0,b.current&&(b.current.scrollTop=0),w("document"),R(null),E(!1),f(null),T(!1),Le(null),be(null),ce(!1),ye(null),U(!1),G(!1),Mt([]),It(null),Ue("page"),_t(null),at(null);const k=ge(a),D=new AbortController;let _=!1;const H=encodeURIComponent(h);return fetch(`/api/doc/${k}?project=${H}`,{signal:D.signal}).then(z=>z.json()).then(z=>{_||(z.doc?l(z.doc):E(!0))}).catch(z=>{_||z.name==="AbortError"||E(!0)}),fetch(`/api/freshness/${k}?project=${H}`,{signal:D.signal}).then(z=>z.json()).then(z=>{_||!z.report||r(z.report)}).catch(()=>{}),fetch(`/api/history/${k}?project=${H}`,{signal:D.signal}).then(z=>z.json()).then(z=>{_||f(z.versions??[])}).catch(()=>{}),()=>{_=!0,D.abort()}},[a,h]),i.useEffect(()=>{if(g===0||!a)return;const k=new AbortController;return fetch(`/api/freshness/${ge(a)}?project=${encodeURIComponent(h)}`,{signal:k.signal}).then(D=>D.json()).then(D=>{D.report&&r(D.report)}).catch(()=>{}),()=>k.abort()},[g]),i.useEffect(()=>{if(v!=="document"||W||!n){Mt([]);return}const k=requestAnimationFrame(()=>{const D=b.current?.querySelector(".doc-content");if(!D)return;const _=[...D.querySelectorAll("h1, h2, h3")];Mt(_.filter(H=>H.id).map(H=>({id:H.id,text:H.textContent??"",level:Number(H.tagName.slice(1))})))});return()=>cancelAnimationFrame(k)},[n,v,W]),i.useEffect(()=>{const k=b.current;if(!k||pe.length===0)return;const D=()=>{const _=k.getBoundingClientRect().top+80;let H=pe[0].id;for(const z of pe){const te=document.getElementById(z.id);te&&te.getBoundingClientRect().top<=_&&(H=z.id)}It(H)};return D(),k.addEventListener("scroll",D,{passive:!0}),()=>k.removeEventListener("scroll",D)},[pe]);const oo=i.useCallback(k=>{document.getElementById(k)?.scrollIntoView({behavior:"smooth",block:"start"}),It(k)},[]),Re=wi(h,n?.id),Ne=Ci(n?.id),ot=Lo(fe),ro=i.useMemo(()=>(Re.data?.comments??[]).filter(k=>!k.parentId&&!k.detached),[Re.data]),de=To(ot,ro),lo=(Re.data?.comments??[]).filter(k=>!k.read).length;i.useEffect(()=>{const k=Re.data;!n||!k||Ns.current===n.id||(Ns.current=n.id,k.comments.some(D=>!D.read)&&(Ue("comments"),Oe(!0)))},[Re.data,n]),i.useEffect(()=>{ct("dc-passage",[...de.values()].map(_=>_.range));const k=zt??At,D=k?de.get(k):void 0;ct("dc-focus",D?[D.range]:[])},[de,zt,At]),i.useEffect(()=>()=>{ct("dc-passage",[]),ct("dc-focus",[])},[]);const Ot=i.useCallback((k,D)=>{if(!ot)return null;const _=Mo(k,D),H=_?ot.indexAt(_.node,_.offset):null;if(H===null)return null;for(const[z,te]of de)if(H>=te.start&&H<te.end)return z;return null},[ot,de]);i.useEffect(()=>{if(!fe||de.size===0)return;const k=z=>{if(!window.getSelection()?.isCollapsed||z.target.closest("a, button"))return;const te=Ot(z.clientX,z.clientY);te&&(_t(te),Ue("comments"),Oe(!0))};let D=0;const _=z=>{cancelAnimationFrame(D),D=requestAnimationFrame(()=>at(Ot(z.clientX,z.clientY)))},H=()=>{cancelAnimationFrame(D),at(null)};return fe.addEventListener("click",k),fe.addEventListener("mousemove",_),fe.addEventListener("mouseleave",H),()=>{cancelAnimationFrame(D),fe.removeEventListener("click",k),fe.removeEventListener("mousemove",_),fe.removeEventListener("mouseleave",H)}},[fe,de,Ot]);const io=i.useCallback(k=>{_t(k),de.get(k)?.range.startContainer.parentElement?.scrollIntoView({behavior:"smooth",block:"center"})},[de]),Ut=i.useMemo(()=>({code:Io,a({href:k,children:D,..._}){if(k?.startsWith("doc://")){const H=k.slice(6),z=H.indexOf(":");if(z!==-1){const ne=H.slice(0,z),We=H.slice(z+1),Ve=m.includes(ne);return e.jsx("button",{className:Ve?"doc-inline-link doc-inline-link--cross-project":"doc-inline-link doc-inline-link--broken",onClick:()=>{Ve&&t(se(ne,We))},title:Ve?`Projet : ${ne}`:`Projet introuvable : ${ne}`,children:D})}const te=H,Be=d.some(ne=>ne.id===te);return e.jsx("button",{className:Be?"doc-inline-link":"doc-inline-link doc-inline-link--broken",onClick:()=>{Be&&t(se(h,te))},title:Be?void 0:`Document introuvable : ${te}`,children:D})}return k?.startsWith("#")?e.jsx("a",{href:k,onClick:H=>{H.preventDefault(),document.getElementById(k.slice(1))?.scrollIntoView({behavior:"smooth"})},..._,children:D}):e.jsx("a",{href:k,target:"_blank",rel:"noopener noreferrer",..._,children:D})},img({src:k,alt:D,..._}){return e.jsx("img",{src:k,alt:D??"",className:"doc-image",..._})}}),[d,m,h,t]),co=i.useMemo(()=>n&&e.jsx(tn,{remarkPlugins:[nn],rehypePlugins:[sn],components:Ut,urlTransform:k=>k.startsWith("doc://")?k:Ao(k),children:n.content}),[n,Ut]);if(!n&&!a)return e.jsx("div",{className:"doc-viewer",children:e.jsx("div",{className:"doc-viewer-empty",children:"Select a documentation entry to view"})});if(a&&I&&!n)return e.jsx("div",{className:"doc-viewer",children:e.jsx("div",{className:"doc-viewer-empty",children:"No documentation at this path in the current project."})});const uo=async()=>{if(n)try{const D=await(await fetch(`/api/freshness/${ge(n.id)}?project=${encodeURIComponent(h)}`)).json();D.report&&r(D.report)}catch{}},ho=async()=>{n&&(await navigator.clipboard.writeText(n.content),S(!0),setTimeout(()=>S(!1),2e3))},mo=()=>{if(!n)return;const k=new Blob([n.content],{type:"text/markdown;charset=utf-8"}),D=URL.createObjectURL(k),_=document.createElement("a");_.href=D,_.download=`${Js(n.title)}.md`,document.body.appendChild(_),_.click(),document.body.removeChild(_),URL.revokeObjectURL(D)},po=async()=>{if(!n)return;const k=Number(localStorage.getItem("printScale")??100)/100,D=h,_=n.id;je(!0),be(null);try{const H=new URLSearchParams({project:D,docId:_,scale:String(k)}),z=await fetch(`/api/pdf?${H}`);if(z.status===503){const We=await z.json();be(We.message??"Navigateur introuvable pour la génération PDF."),setTimeout(()=>be(null),8e3);return}if(!z.ok){be("Échec de la génération PDF."),setTimeout(()=>be(null),5e3);return}const te=await z.blob(),Be=await new Promise((We,Ve)=>{const it=new FileReader;it.onload=()=>We(it.result),it.onerror=Ve,it.readAsDataURL(te)}),ne=document.createElement("a");ne.href=Be,ne.download=`${Js(n.title)}.pdf`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne)}finally{je(!1)}},fo=async()=>{if(!(!n||u!==null)){F(!0);try{const D=await(await fetch(`/api/history/${ge(n.id)}?project=${encodeURIComponent(h)}`)).json();f(D.versions??[])}catch{f([])}finally{F(!1)}}},go=async()=>{if(!(!n||$!==null)){P(!0);try{const D=await(await fetch(`/api/git-diff/${ge(n.id)}?project=${encodeURIComponent(h)}`)).json();R(D.diff??D.error??"No diff available.")}catch{R("Failed to load diff.")}finally{P(!1)}}},He=k=>{w(k),U(!1),G(!1),k!=="document"&&T(!1),k==="diff"&&go(),k==="history"&&fo()},xo=k=>{const D=y.current;if(!D)return;const _=D.selectionStart,H=D.selectionEnd,z=V.slice(0,_)+k+V.slice(H);K(z),requestAnimationFrame(()=>{D.selectionStart=D.selectionEnd=_+k.length,D.focus()})},vo=async()=>{if(n){ie(!0),Le(null);try{const k=ge(n.id),D=await fetch(`/api/doc/${k}?project=${encodeURIComponent(h)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:V})}),_=await D.json();if(!D.ok||_.error)throw new Error(_.error||"Save failed");const H=new Date().toISOString();l({...n,content:V,updatedAt:H}),c(d.map(z=>z.id===n.id?{...z,updatedAt:H}:z)),T(!1)}catch(k){Le(k instanceof Error?k.message:"Save failed")}finally{ie(!1)}}},jo=async()=>{if(n){$e(!0),ye(null);try{const k=ge(n.id),D=await fetch(`/api/doc/${k}?project=${encodeURIComponent(h)}`,{method:"DELETE"}),_=await D.json();if(!D.ok||_.error)throw new Error(_.error||"Delete failed");const H=n.id;c(d.filter(z=>z.id!==H)),l(null),r(null),ce(!1),t(se(h,null),{replace:!0})}catch(k){ye(k instanceof Error?k.message:"Delete failed")}finally{$e(!1)}}},Ht=n?d.find(k=>k.id===n.id):void 0,Cs=Ht?.isStale??!1,Pe=n?.tracked_files.length??0,rt=o?.modified.length??0,lt=u&&u.length>0?u[0].version:null,Ss=n&&Pe>0?n.tracked_files.map(k=>k.lastModifiedAt).filter(Boolean).sort().slice(-1)[0]:void 0,bo=[...Ht?.folder?Ht.folder.split("/").filter(Boolean):[],n?.title??"…"],yo=!j&&!!n&&v==="document";return e.jsxs("div",{className:"doc-viewer",children:[e.jsxs("div",{className:"doc-main",ref:b,children:[e.jsxs("div",{className:"doc-topbar",children:[e.jsxs("div",{className:"doc-topbar-left",children:[e.jsxs("div",{className:"doc-breadcrumb",children:[e.jsx("button",{className:"nav-btn",onClick:()=>t(-1),title:"Go back",children:"←"}),e.jsx("button",{className:"nav-btn",onClick:()=>t(1),title:"Go forward",children:"→"}),bo.map((k,D)=>e.jsxs("span",{className:"doc-breadcrumb-segment",children:[D>0&&e.jsx("span",{className:"doc-breadcrumb-sep",children:"/"}),k]},`${k}-${D}`))]}),e.jsx("h1",{className:"doc-title",children:n?.title??"…"})]}),e.jsxs("div",{className:"doc-actions",children:[!ys&&n&&e.jsx("button",{className:"icon-btn",onClick:()=>Ft(!0),title:"Show details (Ctrl/⌘ + \\)",children:"|◁"}),n&&!W&&Ne&&Ne.total>0&&e.jsxs("button",{className:"btn-secondary doc-comments-btn",onClick:()=>{Ue("comments"),Ft(!0)},title:Ne.unread>0?`${Ne.total} comments, ${Ne.unread} unread`:`${Ne.total} comments`,children:[e.jsx(ls,{size:13}),Ne.total,Ne.unread>0&&e.jsx("span",{className:"doc-comments-dot"})]}),n&&!W&&e.jsx(Si,{project:h,doc:n,latestVersion:lt,readOnly:j},n.id),yo&&e.jsx("button",{className:`btn-primary${W?" active":""}`,onClick:()=>{!W&&n&&K(n.content),T(!W),Le(null)},title:W?"Cancel editing":"Edit document",children:W?"✕ Cancel":"✎ Edit"}),n&&!W&&e.jsxs("div",{className:"menu-anchor",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>{U(k=>!k),G(!1)},title:"Export this document",children:"↓ Export ▾"}),M&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"menu-backdrop",onClick:()=>U(!1)}),e.jsxs("div",{className:"menu-popover",children:[e.jsx("button",{className:"menu-item",onClick:()=>{U(!1),ho()},children:L?"✓ Copied!":"⎘ Copy markdown"}),e.jsx("button",{className:"menu-item",onClick:()=>{U(!1),mo()},children:"↓ Download .md"}),e.jsx("button",{className:"menu-item",disabled:ze,onClick:()=>{U(!1),po()},children:ze?"⏳ PDF…":"↓ Download PDF"})]})]})]}),n&&!W&&e.jsxs("div",{className:"menu-anchor",children:[e.jsx("button",{className:"btn-icon-secondary",onClick:()=>{G(k=>!k),U(!1)},title:"More actions",children:"⋯"}),q&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"menu-backdrop",onClick:()=>G(!1)}),e.jsxs("div",{className:"menu-popover menu-popover--right",children:[Pe>0&&e.jsx("button",{className:"menu-item",onClick:()=>{G(!1),uo()},children:"⟳ Re-check freshness"}),e.jsx("button",{className:"menu-item",onClick:()=>{G(!1),navigator.clipboard.writeText(n.id)},children:"⎘ Copy doc ID"}),!j&&e.jsx("button",{className:"menu-item menu-item--danger",onClick:()=>{G(!1),ye(null),ce(!0)},children:"🗑 Delete document"})]})]})]})]})]}),e.jsxs("nav",{className:"doc-tabs",children:[e.jsx("button",{className:`doc-tab${v==="document"?" active":""}`,onClick:()=>He("document"),children:"Document"}),Pe>0&&e.jsx("button",{className:`doc-tab${ws?" active":""}`,onClick:()=>He("diff"),children:N?"Diff…":`Diff${rt>0?` · ${rt}`:""}`}),e.jsx("button",{className:`doc-tab${ks?" active":""}`,onClick:()=>He("history"),children:B?"History…":`History${lt!==null?` · v${lt}`:""}`}),Pe>0&&e.jsxs("button",{className:`doc-tab${v==="files"?" active":""}`,onClick:()=>He("files"),children:["Tracked files · ",Pe]})]}),Ce&&e.jsx("div",{className:"pdf-error-banner",children:Ce}),v==="document"&&!W&&Cs&&Pe>0&&e.jsxs("div",{className:"stale-banner",children:[e.jsx("span",{className:"stale-banner-icon",children:"⚠"}),e.jsxs("div",{className:"stale-banner-body",children:[e.jsx("span",{className:"stale-banner-text",children:rt>0?`${rt} of ${Pe} tracked files changed since the snapshot taken on ${Ys(Ss)}.`:`Tracked files changed since the snapshot taken on ${Ys(Ss)}.`}),e.jsx("button",{className:"stale-banner-link",onClick:()=>He("diff"),children:"View diff"})]})]}),v==="files"&&n&&(o?e.jsx(ei,{report:o,trackedFiles:n.tracked_files,docId:n.id,onViewCode:Se}):e.jsx("div",{className:"doc-tab-loading",children:"Checking tracked files…"})),ks&&n&&e.jsx(pi,{docId:n.id,project:h,entries:u??[],selectedVersion:p,onSelectVersion:async k=>{const _=await(await fetch(`/api/history-version/${ge(n.id)}/${k}?project=${encodeURIComponent(h)}`)).json();C(_??null)},markdownComponents:Ut}),ws&&(N&&$===null?e.jsx("div",{className:"doc-tab-loading",children:"Loading diff…"}):e.jsx(ni,{diffText:$??""})),v==="document"&&(W&&n?e.jsxs("div",{className:"doc-editor",children:[e.jsx("textarea",{ref:y,className:"doc-editor-textarea",value:V,onChange:k=>K(k.target.value),spellCheck:!1}),e.jsxs("div",{className:"doc-editor-actions",children:[st&&e.jsx("span",{className:"doc-editor-error",children:st}),e.jsxs("div",{className:"doc-editor-actions-right",children:[e.jsx("button",{ref:x,type:"button",className:"image-insert-trigger-btn",onClick:()=>Z(k=>!k),title:"Insert image",children:"🖼 Image"}),Fe&&e.jsx(vi,{project:h,triggerRef:x,onInsert:xo,onClose:()=>Z(!1)}),e.jsx("button",{type:"button",className:"save-btn",onClick:vo,disabled:ee,children:ee?"Saving…":"✓ Save"})]})]})]}):e.jsx("div",{className:"doc-content",ref:ao,children:co}))]}),ys&&n&&e.jsx(bi,{doc:n,isStale:Cs,report:o,toc:pe,activeHeadingId:so,version:lt,onSelectHeading:oo,onSelectFile:Se,onClose:()=>Ft(!1),tab:no,onTab:Ue,unreadComments:lo,comments:Re.data?.publication?e.jsx(Ni,{data:Re.data,locatedIds:new Set(de.keys()),activeId:At,hoveredId:zt,readOnly:j,onActivate:k=>{v!=="document"&&w("document"),io(k)},onHover:at},n.id):null}),me&&n&&e.jsx("div",{className:"modal-overlay",onClick:()=>!Ee&&ce(!1),children:e.jsxs("div",{className:"modal-content delete-modal",onClick:k=>k.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{className:"modal-title",children:"Delete documentation"}),e.jsx("button",{className:"modal-close-btn",onClick:()=>ce(!1),disabled:Ee,children:"✕"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("p",{className:"delete-modal-text",children:["Delete ",e.jsx("strong",{children:n.title})," (",e.jsx("code",{children:n.id}),") from project"," ",e.jsx("strong",{children:h}),"? This action cannot be undone from the interface."]}),Te&&e.jsx("span",{className:"doc-editor-error",children:Te}),e.jsxs("div",{className:"delete-modal-actions",children:[e.jsx("button",{type:"button",className:"copy-btn",onClick:()=>ce(!1),disabled:Ee,children:"Cancel"}),e.jsx("button",{type:"button",className:"delete-btn delete-btn--confirm",onClick:jo,disabled:Ee,children:Ee?"Deleting…":"🗑 Delete"})]})]})]})}),nt&&n&&e.jsx(xi,{docId:n.id,project:h,filePath:nt,onClose:()=>Se(null)})]})}async function bs(t,s){const n=await fetch(t,s);let a=null;try{a=await n.json()}catch{}if(!n.ok)throw new Error(a?.error??`HTTP ${n.status}`);return a}function Li(){return bs("/api/logs")}function Ti(t,s){const n=s?`?knownSize=${s.size}&knownMtime=${encodeURIComponent(s.mtime??"")}`:"";return bs(`/api/logs/${t}${n}`)}function Mi(){return bs("/api/logs/open-folder",{method:"POST"})}const Ii=t=>`/api/logs/${t}/download`;function Xe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t<10*1024?1:0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Q(t){return t.toLocaleString("fr-FR")}function Wa(t,s){return t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate()}function Tt(t){return Wa(new Date(t),new Date)}function Va(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return t;const n=(o,r=2)=>String(o).padStart(r,"0"),a=`${n(s.getHours())}:${n(s.getMinutes())}:${n(s.getSeconds())}.${n(s.getMilliseconds(),3)}`;return Wa(s,new Date)?a:`${n(s.getDate())}/${n(s.getMonth()+1)} ${a.slice(0,8)}`}function mt(t){return`${Q(t)} ms`}const qa={hour:"Last hour",today:"Today",day:"Last 24 hours",week:"Last 7 days",all:"All loaded"};function Ga(t,s){if(s==="all")return!0;if(s==="today")return Tt(t);const n=Date.now()-new Date(t).getTime(),a=s==="hour"?36e5:s==="day"?864e5:7*864e5;return n<=a}const Ai=3e3;function Ka(t,s,n){i.useEffect(()=>{if(!s||(t(),!n))return;const a=setInterval(t,Ai);return()=>clearInterval(a)},[s,n,t])}function os(t,s,n){const[a,o]=i.useState(null),[r,l]=i.useState(null),[c,d]=i.useState(null),h=i.useRef(void 0),m=i.useRef(!1),u=i.useCallback(async()=>{if(!m.current){m.current=!0;try{const p=await Ti(t,h.current);"unchanged"in p||(h.current=p.file,o(p)),l(null),d(Date.now())}catch(p){l(p instanceof Error?p.message:String(p))}finally{m.current=!1}}},[t]);return Ka(u,s,n),{data:a,error:r,checkedAt:c}}function _i(t){const[s,n]=i.useState(null),[a,o]=i.useState(null),r=i.useCallback(async()=>{try{n(await Li()),o(null)}catch(l){o(l instanceof Error?l.message:String(l))}},[]);return Ka(r,!0,t),{directory:s,error:a}}function zi(t=1e3){const[s,n]=i.useState(()=>Date.now());return i.useEffect(()=>{const a=setInterval(()=>n(Date.now()),t);return()=>clearInterval(a)},[t]),s}function Fi(){const{syncEnabled:t,readOnly:s,currentProject:n}=J(),[a,o]=i.useState(null),[r,l]=i.useState(!1),[c,d]=i.useState(null),h=i.useCallback(async()=>{try{const j=await fetch("/api/sync/status"),g=await j.json();o(j.ok&&!g.error?g:null)}catch{o(null)}},[]);if(i.useEffect(()=>{!t||s||h()},[t,s,n,h]),!t||s)return null;const m=async()=>{if(!r){l(!0),d(null);try{const j=await fetch("/api/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),g=await j.json();!j.ok||g.error?d({ok:!1,message:g.error??`HTTP ${j.status}`}):d({ok:!0,message:g.message??"Sync terminée."})}catch(j){d({ok:!1,message:j?.message??"Sync failed"})}finally{l(!1),h()}}},u=[];a?.ahead&&u.push(`↑${a.ahead}`),a?.behind&&u.push(`↓${a.behind}`),a?.dirty?.length&&u.push(`●${a.dirty.length}`);const p=a?.conflicted?.length??0,f=r?"Sync…":p>0?`Conflits à résoudre (${p} fichier(s))`:["Sync",a?.branch,...u.length>0?[u.join(" ")]:[]].filter(Boolean).join(" · "),C=p>0?"!":u[0];return e.jsxs("div",{className:"sync-button-wrapper",children:[e.jsxs("button",{className:`rail-btn${p>0?" conflict":""}`,onClick:m,disabled:r,"data-tooltip":f,"aria-label":f,children:[e.jsx(Nt,{size:20,className:r?"spinning":void 0}),C&&e.jsx("span",{className:`rail-badge rail-badge--${p>0?"danger":"accent"}`,children:C})]}),c&&e.jsxs("div",{className:`sync-result${c.ok?"":" error"}`,children:[e.jsx("pre",{children:c.message}),e.jsx("button",{className:"sync-result-close",onClick:()=>d(null),title:"Fermer",children:"✕"})]})]})}function we({icon:t,label:s,active:n,onClick:a,children:o}){return e.jsxs("button",{className:`rail-btn${n?" active":""}`,onClick:a,"data-tooltip":s,"aria-label":s,children:[e.jsx(t,{size:20}),o]})}function Oi({active:t,onSelect:s,onOpenSettings:n,onOpenProjectSettings:a}){const{docs:o,commentSummary:r,currentProject:l}=J(),c=o.filter(u=>u.isStale).length,d=r.project===l?Object.values(r.docs).reduce((u,p)=>u+p.unread,0):0,h=os("github",!0,!0),m=i.useMemo(()=>(h.data?.entries??[]).filter(u=>Tt(u.ts)&&!u.ok).length,[h.data]);return e.jsxs("nav",{className:"nav-rail",children:[e.jsx("div",{className:"rail-logo",title:"MCP Documentor",children:e.jsx(pl,{size:18})}),e.jsx(Da,{variant:"rail",onOpenSettings:a}),e.jsx("div",{className:"rail-sep"}),e.jsx(we,{icon:yl,label:"Documentation",active:t==="docs",onClick:()=>s("docs")}),e.jsx(we,{icon:Lt,label:"Search ⌘K",active:t==="search",onClick:()=>s("search")}),e.jsx(we,{icon:jl,label:c>0?`Outdated · ${c}`:"Outdated",active:t==="outdated",onClick:()=>s("outdated"),children:c>0&&e.jsx("span",{className:"rail-badge rail-badge--warn",children:c})}),e.jsx(we,{icon:Un,label:"Recent",active:t==="recent",onClick:()=>s("recent")}),e.jsx(we,{icon:$l,label:"Export bundles",active:t==="exports",onClick:()=>s("exports")}),e.jsx(we,{icon:Dt,label:d>0?`Publications · ${d} unread comments`:"Publications",active:t==="publications",onClick:()=>s("publications"),children:d>0&&e.jsx("span",{className:"rail-badge rail-badge--accent",children:d})}),e.jsx("div",{className:"rail-sep"}),e.jsx(we,{icon:ga,label:m>0?`Logs · ${m} failed today`:"Logs",active:t==="logs",onClick:()=>s("logs"),children:m>0&&e.jsx("span",{className:"rail-dot"})}),e.jsx("div",{className:"rail-spacer"}),e.jsx(Fi,{}),e.jsx(we,{icon:ja,label:"Settings",active:!1,onClick:n})]})}function Ui({onClose:t,onShowMigrationReport:s}){const{readOnly:n}=J(),[a,o]=i.useState(!1),[r,l]=i.useState(""),[c,d]=i.useState(null),[h,m]=i.useState(""),[u,p]=i.useState(""),[f,C]=i.useState("text-embedding-3-small"),[j,g]=i.useState(100);i.useEffect(()=>{const w=localStorage.getItem("printScale");w&&g(Number(w)),Pa().then($=>o(!!$)).catch(()=>{}),Vl().then($=>l($.default??"")).catch(()=>{}),fetch("/api/config").then($=>$.json()).then($=>{$.dataDir&&m($.dataDir),$.model&&C($.model)}).catch(()=>{})},[]);const b=async(w,$)=>{await fetch("/api/configurations/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:w,value:$})})},y=async()=>{d(null);try{const{path:w}=await ql(r);l(w??""),d({ok:!0,text:w?"Saved":"Removed"})}catch(w){d({ok:!1,text:w.message})}},x=()=>{localStorage.setItem("printScale",String(j))},v=async()=>{await b("MCP_DATA_DIR",h),u&&await b("MCP_DOCUMENTOR_OPENAI_API_KEY",u),await b("MCP_DOCUMENTOR_OPENAI_MODEL",f),t()};return e.jsx("div",{className:"settings-overlay",onClick:t,children:e.jsxs("div",{className:"settings-popover",onClick:w=>w.stopPropagation(),children:[e.jsx("h2",{className:"settings-title",children:"Settings"}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Data Directory"}),e.jsx("input",{className:"settings-input",type:"text",value:h,onChange:w=>m(w.target.value),placeholder:"Leave empty for default"})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"OpenAI API Key"}),e.jsx("input",{className:"settings-input",type:"password",value:u,onChange:w=>p(w.target.value),placeholder:"sk-..."})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Embedding Model"}),e.jsx("input",{className:"settings-input",type:"text",value:f,onChange:w=>C(w.target.value)})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Print Scale (%)"}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("input",{className:"settings-input",type:"number",min:30,max:150,value:j,onChange:w=>g(Number(w.target.value)),style:{width:"80px"}}),e.jsx("button",{className:"settings-save-btn",onClick:x,children:"Apply"})]})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Default code root (this machine)"}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("input",{className:"settings-input",type:"text",value:r,disabled:n,onChange:w=>l(w.target.value),placeholder:"Absolute path — used by projects without their own root"}),!n&&e.jsx("button",{className:"settings-save-btn",onClick:y,children:"Apply"})]}),c&&e.jsx("span",{className:`settings-hint${c.ok?"":" error"}`,children:c.text})]}),a&&e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Code sources"}),e.jsx("button",{className:"settings-link-btn",onClick:s,children:"View the environment variables migration report"})]}),e.jsxs("div",{className:"settings-actions",children:[e.jsx("button",{className:"settings-cancel-btn",onClick:t,children:"Cancel"}),!n&&e.jsx("button",{className:"settings-save-btn",onClick:v,children:"Save"})]})]})})}function Hi({value:t,onChange:s,options:n}){const[a,o]=i.useState(!1),[r,l]=i.useState(-1),c=i.useRef(null),d=i.useMemo(()=>{const u=t.trim().toLowerCase();return u?n.filter(p=>p.toLowerCase().includes(u)):n},[n,t]);i.useEffect(()=>{if(!a)return;const u=p=>{c.current&&!c.current.contains(p.target)&&o(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[a]),i.useEffect(()=>{l(-1)},[t,a]);const h=u=>{s(u),o(!1)},m=u=>{u.key==="ArrowDown"?(u.preventDefault(),a||o(!0),l(p=>Math.min(p+1,d.length-1))):u.key==="ArrowUp"?(u.preventDefault(),l(p=>Math.max(p-1,0))):u.key==="Enter"&&a&&r>=0&&d[r]?(u.preventDefault(),h(d[r])):u.key==="Escape"&&o(!1)};return e.jsxs("div",{className:"folder-combobox",ref:c,children:[e.jsx("input",{className:"settings-input",value:t,onChange:u=>{s(u.target.value),a||o(!0)},onFocus:()=>o(!0),onKeyDown:m,placeholder:"optional, e.g. backend/auth or backend/auth/new-subfolder",autoComplete:"off",spellCheck:!1}),e.jsx("button",{type:"button",className:"folder-combobox-toggle",onClick:()=>o(u=>!u),tabIndex:-1,"aria-label":"Toggle folder list",children:"▾"}),a&&e.jsxs("div",{className:"folder-combobox-menu",children:[e.jsx("div",{className:"folder-combobox-header",children:"Existing folders"}),d.length===0?e.jsx("div",{className:"folder-combobox-empty",children:n.length===0?"No folder yet — type a path to create one.":"No match — will create a new folder."}):e.jsx("ul",{className:"folder-combobox-list",children:d.map((u,p)=>e.jsx("li",{className:`folder-combobox-item${p===r?" active":""}`,onMouseDown:f=>{f.preventDefault(),h(u)},onMouseEnter:()=>l(p),children:u},u))})]})]})}function Bi({onClose:t}){const s=oe(),{currentProject:n,projects:a,docs:o}=J(),[r,l]=i.useState(n),[c,d]=i.useState(""),[h,m]=i.useState(""),[u,p]=i.useState(""),[f,C]=i.useState(""),[j,g]=i.useState(!1),[b,y]=i.useState(null),[x,v]=i.useState(null),w=i.useMemo(()=>{const N=new Set;for(const P of o)if(P.folder){const L=P.folder.split("/").filter(Boolean);for(let S=1;S<=L.length;S++)N.add(L.slice(0,S).join("/"))}return Array.from(N).sort()},[o]);i.useEffect(()=>{if(r===n){v(null);return}let N=!1;return fetch(`/api/folders?project=${encodeURIComponent(r)}`).then(P=>P.json()).then(P=>{N||(Array.isArray(P?.folders)?v(P.folders):v([]))}).catch(()=>{N||v([])}),()=>{N=!0}},[r,n]);const $=r===n?w:x??[],R=async()=>{if(!c.trim()||!f.trim()){y("Title and content are required");return}g(!0),y(null);try{const N=u.split(",").map(S=>S.trim()).filter(Boolean),P=await fetch("/api/doc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:c.trim(),content:f,folder:h.trim()||void 0,tags:N.length?N:void 0,project:r})}),L=await P.json();if(!P.ok||L.error)throw new Error(L.error||"Create failed");t(),L.id&&r===n&&s(se(n,L.id))}catch(N){y(N instanceof Error?N.message:"Create failed")}finally{g(!1)}};return e.jsx("div",{className:"settings-overlay",onClick:t,children:e.jsxs("div",{className:"settings-popover create-doc-popover",onClick:N=>N.stopPropagation(),children:[e.jsx("h2",{className:"settings-title",children:"New document"}),e.jsxs("div",{className:"create-doc-grid",children:[e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Project"}),e.jsx("select",{className:"settings-input",value:r,onChange:N=>l(N.target.value),children:a.map(N=>e.jsxs("option",{value:N,children:[N,N===n?" (current)":""]},N))})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Title *"}),e.jsx("input",{className:"settings-input",value:c,onChange:N=>d(N.target.value)})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Folder"}),e.jsx(Hi,{value:h,onChange:m,options:$}),e.jsx("div",{className:"create-doc-hint",children:"Pick from the existing tree or type a new path to add a sub-folder."})]}),e.jsxs("div",{className:"settings-field",children:[e.jsx("label",{className:"settings-label",children:"Tags"}),e.jsx("input",{className:"settings-input",value:u,onChange:N=>p(N.target.value),placeholder:"comma, separated, tags"})]})]}),e.jsxs("div",{className:"settings-field create-doc-content-field",children:[e.jsx("label",{className:"settings-label",children:"Content *"}),e.jsx("textarea",{className:"doc-editor-textarea create-doc-textarea",value:f,onChange:N=>C(N.target.value),spellCheck:!1,placeholder:`# My new document
|
|
5
|
+
|
|
6
|
+
Write Markdown here…`})]}),e.jsxs("div",{className:"settings-actions",children:[b&&e.jsx("span",{className:"doc-editor-error",style:{marginRight:"auto"},children:b}),e.jsx("button",{className:"settings-cancel-btn",onClick:t,disabled:j,children:"Cancel"}),e.jsx("button",{className:"settings-save-btn",onClick:R,disabled:j,children:j?"Creating…":"Create"})]})]})})}const Xs=400,Wi=350,Vi=300,qi=/^(https?:\/\/github\.com\/|git@github\.com:)?[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+(\.git)?(#.+)?$/i;function Gi(t){const s=Math.max(0,(Date.now()-new Date(t).getTime())/1e3);if(Number.isNaN(s))return"";if(s<60)return"just now";const n=[[3600*24*365,"year"],[3600*24*30,"month"],[3600*24,"day"],[3600,"hour"],[60,"minute"]];for(const[a,o]of n)if(s>=a){const r=Math.floor(s/a);return`${r} ${o}${r>1?"s":""} ago`}return""}function Ki({project:t,onClose:s}){const{readOnly:n}=J(),[a,o]=i.useState(null),[r,l]=i.useState("local"),[c,d]=i.useState(""),[h,m]=i.useState({state:"idle"}),[u,p]=i.useState(""),[f,C]=i.useState(""),[j,g]=i.useState({state:"idle"}),[b,y]=i.useState({state:"idle"}),[x,v]=i.useState({state:"loading"}),[w,$]=i.useState(!1),[R,N]=i.useState(null),P=i.useRef(null),[L,S]=i.useState(""),[I,E]=i.useState({state:"idle"}),[B,F]=i.useState(!1),[W,T]=i.useState(0);i.useEffect(()=>{let M=!1;return Ra().then(U=>{if(M)return;const q=U.find(G=>G.project===t)??{project:t};o(q),q.codeRootOrigin==="project"&&q.codeRoot&&d(q.codeRoot),q.config?.kind==="github"&&(l("github"),p(q.config.repo),C(q.config.branch??""))}).catch(U=>!M&&o({project:t,error:U.message})),Gl().then(U=>!M&&v({state:"done",value:U})).catch(U=>!M&&v({state:"failed",error:U.message})),()=>{M=!0}},[t]),i.useEffect(()=>{const M=U=>{U.key==="Escape"&&s()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[s]),i.useEffect(()=>{if(r!=="local"||c.trim()===""){m({state:"idle"});return}const M=new AbortController;m({state:"loading"});const U=setTimeout(()=>{Wl(c.trim(),M.signal).then(q=>m({state:"done",value:q})).catch(q=>{q.name!=="AbortError"&&m({state:"failed",error:q.message})})},Xs);return()=>{clearTimeout(U),M.abort()}},[r,c]),i.useEffect(()=>{const M=L.trim();if(M.replace("/","").length<2){E({state:"idle"});return}const U=new AbortController;E({state:"loading"});const q=setTimeout(()=>{Ol(M,U.signal).then(G=>{E({state:"done",value:G}),T(0)}).catch(G=>{G.name!=="AbortError"&&E({state:"failed",error:G.message})})},Wi);return()=>{clearTimeout(q),U.abort()}},[L]);const V=B&&!(I.state==="done"&&I.value.some(M=>M.fullName.toLowerCase()===u.trim().toLowerCase()));i.useEffect(()=>{if(V)return;if(r!=="github"||!qi.test(u.trim())){g({state:"idle"}),P.current=null;return}const M=P.current;if(M&&M.repo===u&&M.branch===f)return;const U=new AbortController;g({state:"loading"});const q=setTimeout(()=>{Ul(u.trim(),f||void 0,U.signal).then(G=>{g({state:"done",value:G});const pe=G.ok&&!f?G.branch:f;P.current={repo:u,branch:pe},pe!==f&&C(pe)}).catch(G=>{G.name!=="AbortError"&&g({state:"failed",error:G.message})})},Xs);return()=>{clearTimeout(q),U.abort()}},[r,u,f,V]);const K=c.trim()===""||h.state==="done"&&h.value.ok,ee=i.useMemo(()=>r==="local"?K?{kind:"local"}:null:j.state!=="done"||!j.value.ok?null:{kind:"github",repo:j.value.repo.fullName,branch:j.value.branch},[r,j,K]),ie=r==="local"?c.trim():void 0,st=ee?JSON.stringify([ee,ie]):null;i.useEffect(()=>{if(!ee){y({state:"idle"});return}const M=new AbortController;y({state:"loading"});const U=setTimeout(()=>{Hl(t,ee,ie,M.signal).then(q=>y({state:"done",value:q})).catch(q=>{q.name!=="AbortError"&&y({state:"failed",error:q.message})})},Vi);return()=>{clearTimeout(U),M.abort()}},[t,st]);const Le=M=>{p(M),C(""),S(M),F(!0)},ze=M=>{p(M),C(""),S(""),F(!1)},je=I.state==="done"?I.value:[],Ce=B&&I.state!=="idle",be=M=>{Ce&&(M.key==="ArrowDown"?(M.preventDefault(),T(U=>Math.min(je.length-1,U+1))):M.key==="ArrowUp"?(M.preventDefault(),T(U=>Math.max(0,U-1))):M.key==="Enter"&&je[W]?(M.preventDefault(),ze(je[W].fullName)):M.key==="Escape"&&(M.stopPropagation(),F(!1)))},nt=async()=>{if(ee){$(!0),N(null);try{await Bl(t,ee,ie),s()}catch(M){N(M.message),$(!1)}}},Se=a?.defaultCodeRoot??(a?.codeRootOrigin==="default"?a.codeRoot:void 0),Fe=h.state==="failed"?h.error:h.state==="done"&&!h.value.ok?h.value.error:null,Z=j.state==="done"?j.value:null,me=Z?.repo,ce=Z?.branches??[],Ee=j.state==="failed"?j.error:Z&&!Z.ok&&Z.field==="repo"?Z.error:null,$e=Ce?null:Ee,Te=Z&&!Z.ok&&Z.field==="branch"?Z.error:null,ye=f&&!ce.includes(f)?[f,...ce]:ce;return e.jsx("div",{className:"modal-overlay",onClick:s,children:e.jsxs("div",{className:"project-settings",onClick:M=>M.stopPropagation(),role:"dialog","aria-label":"Project settings",children:[e.jsxs("header",{className:"ps-header",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"ps-title",children:"Project settings"}),e.jsxs("div",{className:"ps-subtitle",children:[e.jsx(Qn,{size:13}),t]})]}),e.jsx("button",{className:"ps-close",onClick:s,title:"Close (Esc)",children:e.jsx(rn,{size:18})})]}),e.jsxs("div",{className:"ps-body",children:[a?.error&&!a.config&&e.jsxs("div",{className:"ps-alert error",children:[e.jsx(vl,{size:14}),e.jsxs("span",{children:["The saved settings cannot be read: ",a.error,". Applying replaces them."]})]}),e.jsx("div",{className:"ps-section-label",children:"Where is the code read from?"}),e.jsxs("div",{className:"ps-modes",role:"radiogroup",children:[e.jsxs("button",{className:`ps-mode${r==="local"?" selected":""}`,role:"radio","aria-checked":r==="local",disabled:n,onClick:()=>l("local"),children:[e.jsx(gs,{size:16,className:"ps-mode-icon"}),e.jsxs("span",{className:"ps-mode-text",children:[e.jsx("span",{className:"ps-mode-title",children:"Local working copy"}),e.jsx("span",{className:"ps-mode-desc",children:"Current checkout, uncommitted work included"})]}),r==="local"&&e.jsx(Ke,{size:16,className:"ps-mode-check"})]}),e.jsxs("button",{className:`ps-mode${r==="github"?" selected":""}`,role:"radio","aria-checked":r==="github",disabled:n,onClick:()=>l("github"),children:[e.jsx(fs,{size:16,className:"ps-mode-icon"}),e.jsxs("span",{className:"ps-mode-text",children:[e.jsx("span",{className:"ps-mode-title",children:"GitHub repository"}),e.jsx("span",{className:"ps-mode-desc",children:"Published code of one branch"})]}),r==="github"&&e.jsx(Ke,{size:16,className:"ps-mode-check"})]})]}),r==="local"&&e.jsxs("label",{className:"ps-field",children:[e.jsx("span",{className:"ps-label",children:"Code root on this machine"}),e.jsxs("span",{className:`ps-input-wrap${Fe?" invalid":""}`,children:[e.jsx(Pt,{size:14,className:"ps-input-icon"}),e.jsx("input",{className:"ps-input",value:c,placeholder:Se?`Machine default: ${Se}`:"Absolute path of the repository",autoFocus:!0,disabled:n,onChange:M=>d(M.target.value)}),h.state==="loading"&&e.jsx(qt,{size:14,className:"ps-input-status spinning"}),h.state==="done"&&h.value.ok&&e.jsx(Ke,{size:14,className:"ps-input-status ok"}),!n&&c!==""&&e.jsx("button",{type:"button",className:"ps-link muted ps-input-action",onClick:()=>d(""),children:"Use default"})]}),Fe?e.jsx("span",{className:"ps-help error",children:Fe}):c.trim()!==""?h.state==="done"?e.jsx("span",{className:"ps-help ok",children:"Folder found · used by this project only, on this machine"}):e.jsx("span",{className:"ps-help",children:"Checked as you type."}):Se?e.jsx("span",{className:"ps-help",children:"Uses the machine default. Stored on this machine only, never synced."}):e.jsx("span",{className:"ps-help",children:"No code root on this machine: only tracked files stored with an absolute path can be read."})]}),r==="github"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"ps-field",children:[e.jsx("label",{className:"ps-label",htmlFor:"ps-repo-input",children:"Repository"}),e.jsxs("div",{className:"ps-combobox",children:[e.jsxs("span",{className:`ps-input-wrap${$e?" invalid":""}`,children:[me?e.jsx(yt,{size:14,className:"ps-input-icon"}):e.jsx(Lt,{size:14,className:"ps-input-icon"}),e.jsx("input",{id:"ps-repo-input",className:"ps-input",value:u,placeholder:"Search a repository, or paste owner/repo",autoFocus:!0,autoComplete:"off",disabled:n,role:"combobox","aria-expanded":Ce,"aria-controls":"ps-repo-suggestions",onChange:M=>Le(M.target.value),onKeyDown:be,onFocus:()=>F(!0),onBlur:()=>F(!1)}),(j.state==="loading"||I.state==="loading")&&e.jsx(qt,{size:14,className:"ps-input-status spinning"}),j.state!=="loading"&&I.state!=="loading"&&me&&!$e&&e.jsx(Ke,{size:14,className:"ps-input-status ok"})]}),Ce&&e.jsxs("ul",{className:"ps-suggestions",id:"ps-repo-suggestions",role:"listbox",children:[I.state==="loading"&&e.jsx("li",{className:"ps-suggestion-note",children:"Searching…"}),I.state==="failed"&&e.jsx("li",{className:"ps-suggestion-note error",children:I.error}),I.state==="done"&&je.length===0&&e.jsx("li",{className:"ps-suggestion-note",children:"No repository found"}),je.map((M,U)=>e.jsxs("li",{role:"option","aria-selected":U===W,className:`ps-suggestion${U===W?" highlighted":""}`,onMouseEnter:()=>T(U),onMouseDown:q=>{q.preventDefault(),ze(M.fullName)},children:[e.jsxs("span",{className:"ps-suggestion-name",children:[M.private?e.jsx(El,{size:12}):e.jsx(yt,{size:12}),M.fullName]}),M.description&&e.jsx("span",{className:"ps-suggestion-desc",children:M.description})]},M.fullName))]})]}),$e?e.jsx("span",{className:"ps-help error",children:$e}):me?e.jsxs("span",{className:"ps-help ok",children:["Found · ",me.private?"private":"public"," · default branch ",me.defaultBranch]}):e.jsxs("span",{className:"ps-help",children:["Searched as you type",x.state==="done"&&x.value.configured?", private repositories included":"","."]})]}),e.jsxs("label",{className:"ps-field",children:[e.jsx("span",{className:"ps-label",children:"Branch"}),e.jsxs("span",{className:`ps-input-wrap${Te?" invalid":""}`,children:[e.jsx(Nl,{size:14,className:"ps-input-icon"}),e.jsxs("select",{className:"ps-input ps-select",value:f,disabled:n||ye.length===0,onChange:M=>C(M.target.value),children:[ye.length===0&&e.jsx("option",{value:"",children:"—"}),ye.map(M=>e.jsxs("option",{value:M,children:[M,M===me?.defaultBranch?" (default)":""]},M))]}),f&&f===me?.defaultBranch&&e.jsx("span",{className:"ps-chip",children:"default"})]}),Te?e.jsx("span",{className:"ps-help error",children:Te}):Z?.ok?e.jsxs("span",{className:"ps-help",children:["Head ",Z.head.sha.slice(0,7)," · ",Z.head.message," · ",Gi(Z.head.date)]}):null]}),e.jsxs("div",{className:"ps-field",children:[e.jsx("span",{className:"ps-label",children:"GitHub access"}),e.jsxs("span",{className:"ps-token",children:[e.jsx(Sl,{size:14,className:`ps-token-icon${x.state==="done"&&x.value.login?" ok":x.state==="done"&&x.value.error?" error":""}`}),e.jsxs("span",{className:"ps-token-text",children:[x.state==="loading"&&"Checking the token…",x.state==="failed"&&x.error,x.state==="done"&&(x.value.configured?x.value.login?`${x.value.variable} · connected as ${x.value.login}`:`${x.value.variable} rejected — ${x.value.error}`:`${x.value.variable} is not set · public repositories only`)]})]}),e.jsx("span",{className:"ps-help",children:"Set in the MCP server's environment variables only — not editable here."})]})]}),b.state!=="idle"&&e.jsxs("div",{className:`ps-preview${b.state==="failed"||b.state==="done"&&b.value.sourceError?" error":""}`,children:[b.state==="loading"?e.jsx(qt,{size:16,className:"ps-preview-icon spinning"}):e.jsx(Pl,{size:16,className:"ps-preview-icon"}),e.jsxs("div",{className:"ps-preview-text",children:[b.state==="loading"&&e.jsx("span",{className:"ps-preview-title",children:"Checking the docs against this source…"}),b.state==="failed"&&e.jsx("span",{className:"ps-preview-title",children:b.error}),b.state==="done"&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"ps-preview-title",children:["Checked against ",b.value.label," — ",b.value.docs," doc",b.value.docs===1?"":"s"]}),e.jsx("span",{className:"ps-preview-counts",children:b.value.sourceError?b.value.sourceError:[`${b.value.upToDate} up to date`,`${b.value.stale} would be outdated`,`${b.value.unverifiable} unverifiable`,...b.value.broken>0?[`${b.value.broken} with broken tracking`]:[]].join(" · ")})]})]})]})]}),e.jsxs("footer",{className:"ps-footer",children:[e.jsxs("div",{className:"ps-footer-note",children:[e.jsx(Cl,{size:14}),e.jsxs("span",{children:["Source saved with the docs, shared across machines.",e.jsx("br",{}),"Applied at once — no restart."]})]}),R&&e.jsx("span",{className:"ps-help error ps-save-error",children:R}),e.jsx("button",{className:"ps-btn",onClick:s,children:"Cancel"}),!n&&e.jsx("button",{className:"ps-btn primary",onClick:nt,disabled:!ee||w,children:w?"Applying…":"Apply"})]})]})})}function Ji({entry:t}){return t.status!=="imported"?e.jsx(xs,{size:14,className:"mig-icon warn"}):t.kind==="code-root"?e.jsx(Pt,{size:14,className:"mig-icon"}):t.kind==="local"?e.jsx(gs,{size:14,className:"mig-icon"}):e.jsx(fs,{size:14,className:"mig-icon accent"})}function Yi({onClose:t,onReviewProject:s}){const[n,a]=i.useState(null),[o,r]=i.useState(null),[l,c]=i.useState(!1);i.useEffect(()=>{Pa().then(a).catch(u=>r(u.message))},[]);const d=u=>{Kl().catch(()=>{}).finally(()=>{t(),u?.()})};i.useEffect(()=>{const u=p=>{p.key==="Escape"&&d()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[]);const h=async()=>{if(n)try{await navigator.clipboard.writeText(n.variables.join(`
|
|
7
|
+
`)),c(!0),setTimeout(()=>c(!1),1500)}catch{}},m=n?.entries.find(u=>u.status==="imported"&&u.project)?.project;return e.jsx("div",{className:"modal-overlay",onClick:()=>d(),children:e.jsxs("div",{className:"migration-report",onClick:u=>u.stopPropagation(),role:"dialog","aria-label":"Code source settings imported",children:[e.jsxs("header",{className:"mig-header",children:[e.jsx("span",{className:"mig-badge",children:e.jsx(kl,{size:18})}),e.jsxs("div",{children:[e.jsx("h2",{className:"mig-title",children:"Code source settings imported"}),e.jsx("p",{className:"mig-subtitle",children:"Found in this server's environment. They now live in each project's settings."})]})]}),o&&e.jsx("div",{className:"ps-alert error mig-error",children:o}),n&&e.jsxs(e.Fragment,{children:[n.entries.length>0&&e.jsxs("table",{className:"mig-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Project"}),e.jsx("th",{children:"Now configured as"}),e.jsx("th",{children:"From"})]})}),e.jsx("tbody",{children:n.entries.map((u,p)=>e.jsxs("tr",{className:u.status!=="imported"?"not-imported":void 0,children:[e.jsx("td",{className:u.project?void 0:"mig-scope",children:u.project??"This machine"}),e.jsx("td",{children:e.jsxs("span",{className:"mig-source",children:[e.jsx(Ji,{entry:u}),u.detail]})}),e.jsx("td",{className:"mig-from",children:u.from})]},p))})]}),e.jsxs("div",{className:"mig-callout",children:[e.jsxs("div",{className:"mig-callout-text",children:[e.jsx("span",{className:"mig-callout-title",children:"These variables are no longer read"}),e.jsx("span",{className:"mig-callout-desc",children:"Remove them from the env block of .mcp.json. Until then, the server ignores them and says so in its log."}),e.jsx("pre",{className:"mig-vars",children:n.variables.join(`
|
|
8
|
+
`)})]}),e.jsx("button",{className:"mig-copy",onClick:h,title:"Copy the list",children:l?e.jsx(ke,{size:14}):e.jsx(Rt,{size:14})})]})]}),e.jsxs("footer",{className:"mig-footer",children:[e.jsx("span",{className:"mig-footer-note",children:"This report stays in Settings."}),m&&e.jsx("button",{className:"ps-btn",onClick:()=>d(()=>s(m)),children:"Review project settings"}),e.jsx("button",{className:"ps-btn primary",onClick:()=>d(),children:"Done"})]})]})})}function rs({tone:t,children:s,wide:n}){return e.jsx("span",{className:`logs-badge logs-badge--${t}${n?" logs-badge--wide":""}`,children:s})}function Ja({source:t,title:s,meta:n,following:a,onToggleFollow:o}){const[r,l]=i.useState(null),c=async()=>{l(null);try{await Mi()}catch(d){l(d instanceof Error?d.message:String(d))}};return e.jsxs("div",{className:"logs-page-header",children:[e.jsxs("div",{className:"logs-page-heading",children:[e.jsxs("div",{className:"logs-breadcrumb",children:["Logs / ",s]}),e.jsx("h2",{className:"logs-title",children:s}),e.jsx("div",{className:"logs-file-meta",children:n}),r&&e.jsx("div",{className:"logs-inline-error",children:r})]}),e.jsxs("div",{className:"logs-actions",children:[e.jsxs("button",{className:`logs-btn logs-follow-btn${a?" active":""}`,onClick:o,title:a?"Stop following new lines":"Follow new lines as they are written",children:[e.jsx("span",{className:"logs-live-dot"}),a?"Following":"Paused"]}),e.jsxs("button",{className:"logs-btn",onClick:c,title:"Open the log directory on the server machine",children:[e.jsx(Pt,{size:14}),"Open folder"]}),e.jsxs("a",{className:"logs-btn",href:Ii(t),download:!0,title:"Download the whole file",children:[e.jsx(bl,{size:14}),"Download"]})]})]})}function Ya({value:t,onChange:s,placeholder:n}){return e.jsxs("label",{className:"logs-search",children:[e.jsx(Lt,{size:14}),e.jsx("input",{value:t,onChange:a=>s(a.target.value),placeholder:n,spellCheck:!1})]})}function Xa({options:t,value:s,onChange:n}){return e.jsx("div",{className:"logs-segmented",role:"tablist",children:t.map(a=>e.jsxs("button",{role:"tab","aria-selected":a.value===s,className:`logs-segment logs-tone--${a.tone??"neutral"}${a.value===s?" active":""}`,onClick:()=>n(a.value),children:[a.label,e.jsx("span",{className:"logs-segment-count",children:a.count.toLocaleString("fr-FR")})]},a.value))})}function Qe({value:t,onChange:s,options:n,prefix:a,withClock:o,width:r}){const l=n.find(c=>c.value===t)?.label??t;return e.jsxs("label",{className:"logs-select",style:{width:r},children:[o&&e.jsx(Un,{size:14}),e.jsxs("span",{className:"logs-select-value",children:[a?`${a}: `:"",l]}),e.jsx($t,{size:12}),e.jsx("select",{value:t,onChange:c=>s(c.target.value),children:n.map(c=>e.jsx("option",{value:c.value,children:c.label},c.value))})]})}function Xi(t,s){if(t===null)return"not loaded yet";const n=Math.max(0,Math.round((s-t)/1e3));return n<60?`updated ${n} s ago`:`updated ${Math.round(n/60)} min ago`}function Qa({following:t,text:s,checkedAt:n,error:a}){const o=zi();return e.jsxs("div",{className:"logs-status",children:[e.jsx("span",{className:`logs-live-dot${t?"":" paused"}`}),a?e.jsx("span",{className:"logs-status-error",children:a}):e.jsxs("span",{children:[s," · ",Xi(n,o)]}),e.jsx("span",{className:"logs-status-order",children:"Newest at the bottom"})]})}function Za({contentKey:t,className:s,children:n}){const a=i.useRef(null),o=i.useRef(!0);i.useLayoutEffect(()=>{const l=a.current;l&&o.current&&(l.scrollTop=l.scrollHeight)},[t]);const r=()=>{const l=a.current;l&&(o.current=l.scrollHeight-l.scrollTop-l.clientHeight<40)};return e.jsx("div",{className:s,ref:a,onScroll:r,children:n})}const Qi=["today","day","week","all"];function Zi(t){return t.ok?"ok":t.status==="404"||t.status==="422"?"warn":"error"}function ec(t){return t.status==="ok"?"OK":t.status==="rejected"?"Rejected":t.status==="failed"?"Failed":t.status==="network error"?"Network":t.status}function tc(t){return i.useMemo(()=>{const s=t.filter(c=>Tt(c.ts)),n=s.filter(c=>!c.ok),a=new Map;for(const c of n)a.set(c.status,(a.get(c.status)??0)+1);const o=s.reduce((c,d)=>!c||d.durationMs>c.durationMs?d:c,null),r=s.length?Math.round(s.reduce((c,d)=>c+d.durationMs,0)/s.length):null,l=[...t].reverse().find(c=>c.rateLimit)?.rateLimit??null;return{total:s.length,git:s.filter(c=>c.kind==="git").length,api:s.filter(c=>c.kind==="api").length,failed:n.length,failureSummary:[...a].map(([c,d])=>`${d} × ${c}`).join(" · "),average:r,slowest:o,rate:l}},[t])}function sc(t){const s=`GET /repos/${t.repo}/`;return!t.repo||!t.command.startsWith(s)?t.command:`GET /repos/…/${t.command.slice(s.length)}`}function nc({data:t,error:s,checkedAt:n,following:a,onToggleFollow:o}){const[r,l]=i.useState(""),[c,d]=i.useState("all"),[h,m]=i.useState("all"),[u,p]=i.useState("all"),[f,C]=i.useState("today"),[j,g]=i.useState(new Set),[b,y]=i.useState(null),x=i.useMemo(()=>t?.entries??[],[t]),v=tc(x),w=i.useMemo(()=>[...new Set(x.map(T=>T.trigger))].sort((T,V)=>T.localeCompare(V)),[x]),$=i.useMemo(()=>{const T=r.trim().toLowerCase();return x.filter(V=>Ga(V.ts,f)&&(h==="all"||h==="ok"===V.ok)&&(u==="all"||V.trigger===u)&&(!T||V.action.toLowerCase().includes(T)||V.command.toLowerCase().includes(T)||(V.repo??"").toLowerCase().includes(T)||(V.error??"").toLowerCase().includes(T)))},[x,r,f,h,u]),R=i.useMemo(()=>c==="all"?$:$.filter(T=>T.kind===c),[$,c]),N=R.slice(-1e3),P=`${t?.file.size}:${N.length}:${c}:${h}:${u}:${f}:${r}`,L=T=>g(V=>{const K=new Set(V);return K.has(T)?K.delete(T):K.add(T),K}),S=async(T,V)=>{try{await navigator.clipboard.writeText(T.raw),y(V),setTimeout(()=>y(K=>K===V?null:K),1500)}catch{}},I=t?.file,E=I?I.exists?`${I.path} · ${Xe(I.size)} · one line per call to GitHub`:`${I.path} · no call to GitHub recorded yet`:"Loading…",B=`${a?"Following new calls":"Paused"} · ${Q(R.length)} of ${Q(x.length)} calls match`+(R.length>N.length?` · showing the latest ${Q(N.length)}`:"")+(t?.unreadable?` · ${t.unreadable} unreadable`:""),F=v.rate,W=F?.reset?new Date(F.reset):null;return e.jsxs("div",{className:"logs-panel",children:[e.jsx(Ja,{source:"github",title:"GitHub access",meta:E,following:a,onToggleFollow:o}),e.jsxs("div",{className:"logs-stats",children:[e.jsxs("div",{className:"logs-stat",children:[e.jsx("div",{className:"logs-stat-label",children:"Calls today"}),e.jsxs("div",{className:"logs-stat-row",children:[e.jsx("span",{className:"logs-stat-value",children:Q(v.total)}),e.jsxs("span",{className:"logs-stat-detail",children:[Q(v.git)," git · ",Q(v.api)," REST API"]})]})]}),e.jsxs("div",{className:"logs-stat",children:[e.jsx("div",{className:"logs-stat-label",children:"Failed"}),e.jsxs("div",{className:"logs-stat-row",children:[e.jsx("span",{className:`logs-stat-value${v.failed?" error":""}`,children:Q(v.failed)}),e.jsx("span",{className:"logs-stat-detail",children:v.failed?v.failureSummary:"no failure today"})]})]}),e.jsxs("div",{className:"logs-stat",children:[e.jsx("div",{className:"logs-stat-label",children:"Average duration"}),e.jsxs("div",{className:"logs-stat-row",children:[e.jsx("span",{className:"logs-stat-value",children:v.average===null?"—":mt(v.average)}),v.slowest&&e.jsxs("span",{className:"logs-stat-detail",title:v.slowest.command,children:["slowest: ",v.slowest.kind==="git"?v.slowest.command.split(" ").slice(0,2).join(" "):v.slowest.action," ",mt(v.slowest.durationMs)]})]})]}),e.jsxs("div",{className:"logs-stat",children:[e.jsxs("div",{className:"logs-stat-label",children:["API rate limit",W&&e.jsxs("span",{className:"logs-stat-aside",children:["resets ",W.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"})]})]}),F?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"logs-stat-value small",children:[Q(F.remaining)," / ",Q(F.limit)]}),e.jsx("div",{className:"logs-gauge",children:e.jsx("div",{className:`logs-gauge-fill${F.remaining/F.limit<.1?" low":""}`,style:{width:`${Math.max(0,Math.min(100,F.remaining/F.limit*100))}%`}})})]}):e.jsxs("div",{className:"logs-stat-row",children:[e.jsx("span",{className:"logs-stat-value small",children:"—"}),e.jsx("span",{className:"logs-stat-detail",children:"known after the next API call"})]})]})]}),e.jsxs("div",{className:"logs-toolbar",children:[e.jsx(Ya,{value:r,onChange:l,placeholder:"Filter by command, path, repository…"}),e.jsx(Xa,{value:c,onChange:d,options:[{value:"all",label:"All",count:$.length},{value:"git",label:"Git",count:$.filter(T=>T.kind==="git").length,tone:"git"},{value:"api",label:"REST API",count:$.filter(T=>T.kind==="api").length,tone:"info"}]}),e.jsx("div",{className:"logs-toolbar-spacer"}),e.jsx(Qe,{value:h,onChange:m,prefix:"Status",width:130,options:[{value:"all",label:"all"},{value:"ok",label:"succeeded"},{value:"failed",label:"failed"}]}),e.jsx(Qe,{value:u,onChange:p,prefix:"Triggered by",width:200,options:[{value:"all",label:"all"},...w.map(T=>({value:T,label:T}))]}),e.jsx(Qe,{value:f,onChange:C,withClock:!0,width:150,options:Qi.map(T=>({value:T,label:qa[T]}))})]}),e.jsxs("div",{className:"logs-table",children:[e.jsxs("div",{className:"logs-table-head logs-github-grid",children:[e.jsx("span",{children:"Time"}),e.jsx("span",{children:"Kind"}),e.jsx("span",{children:"What was done"}),e.jsx("span",{children:"Repository"}),e.jsx("span",{children:"Triggered by"}),e.jsx("span",{children:"Status"}),e.jsx("span",{className:"align-right",children:"Duration"})]}),e.jsxs(Za,{className:"logs-table-body",contentKey:P,children:[N.length===0&&e.jsx("div",{className:"logs-empty",children:t?x.length?"No call matches these filters.":"No call to GitHub recorded yet.":s?"":"Loading…"}),N.map((T,V)=>{const K=`${T.ts}|${R.length-N.length+V}`,ee=j.has(K),ie=Zi(T);return e.jsxs("div",{className:`logs-row logs-row--tall${ee?` open logs-row--${ie==="ok"?"info":ie}`:""}`,children:[e.jsxs("button",{className:"logs-row-line logs-github-grid",onClick:()=>L(K),title:T.ts,children:[e.jsx("span",{className:"logs-cell-time",children:Va(T.ts)}),e.jsx("span",{children:e.jsx(rs,{tone:T.kind==="git"?"git":"info",children:T.kind==="git"?"GIT":"API"})}),e.jsxs("span",{className:"logs-cell-what",children:[e.jsx("span",{className:"logs-cell-action",children:T.action}),e.jsx("span",{className:"logs-cell-command",title:T.command,children:sc(T)})]}),e.jsx("span",{className:`logs-cell-repo${T.repo?"":" muted"}`,children:T.repo??"—"}),e.jsx("span",{className:"logs-cell-trigger",children:T.trigger}),e.jsx("span",{children:e.jsx(rs,{tone:ie,wide:!0,children:ec(T)})}),e.jsx("span",{className:"logs-cell-duration",children:mt(T.durationMs)}),ee?e.jsx(Mn,{size:12,className:"logs-row-chevron"}):e.jsx($t,{size:12,className:"logs-row-chevron hover-only"})]}),ee&&e.jsxs("div",{className:"logs-row-detail logs-detail--github",children:[e.jsxs("div",{className:"logs-detail-main",children:[e.jsx("div",{className:"logs-detail-text",children:T.ok?`Completed in ${mt(T.durationMs)}.`:T.error??"Failed without an error message."}),e.jsx("pre",{className:"logs-detail-context",children:[`time ${T.ts}`,`command ${T.command}`,`trigger ${T.trigger}`,...T.rateLimit?[`quota ${Q(T.rateLimit.remaining)} / ${Q(T.rateLimit.limit)} requests left`]:[]].join(`
|
|
9
|
+
`)})]}),e.jsxs("button",{className:"logs-btn logs-btn--small",onClick:()=>S(T,K),children:[b===K?e.jsx(ke,{size:12}):e.jsx(Rt,{size:12}),b===K?"Copied":"Copy log line"]})]})]},K)})]})]}),e.jsx(Qa,{following:a,text:B,checkedAt:n,error:s})]})}const Xt={DEBUG:"neutral",INFO:"info",WARN:"warn",ERROR:"error"},ac=["DEBUG","INFO","WARN","ERROR"],oc=["hour","day","week","all"],rc="GitHub";function lc({data:t,error:s,checkedAt:n,following:a,onToggleFollow:o}){const r=oe(),[l,c]=i.useState(""),[d,h]=i.useState("all"),[m,u]=i.useState("all"),[p,f]=i.useState("day"),[C,j]=i.useState(new Set),g=i.useMemo(()=>t?.entries??[],[t]),b=i.useMemo(()=>[...new Set(g.map(S=>S.scope))].sort((S,I)=>S.localeCompare(I)),[g]),y=i.useMemo(()=>{const S=l.trim().toLowerCase();return g.filter(I=>(m==="all"||I.scope===m)&&Ga(I.ts,p)&&(!S||I.message.toLowerCase().includes(S)||I.scope.toLowerCase().includes(S)||I.continuation.some(E=>E.toLowerCase().includes(S))))},[g,l,m,p]),x=i.useMemo(()=>{const S={DEBUG:0,INFO:0,WARN:0,ERROR:0};for(const I of y)S[I.level]++;return S},[y]),v=i.useMemo(()=>d==="all"?y:y.filter(S=>S.level===d),[y,d]),w=v.slice(-1500),$=`${t?.file.size}:${w.length}:${d}:${m}:${p}:${l}`,R=S=>j(I=>{const E=new Set(I);return E.has(S)?E.delete(S):E.add(S),E}),N=t?.file,P=N?N.exists?`${N.path} · ${Xe(N.size)} · ${t.partial?`last ${Q(g.length)} lines`:`${Q(g.length)} lines`}`:`${N.path} · not written yet`:"Loading…",L=`${a?"Following new lines":"Paused"} · ${Q(v.length)} of ${Q(g.length)} lines match`+(v.length>w.length?` · showing the latest ${Q(w.length)}`:"")+(t?.unreadable?` · ${t.unreadable} unreadable`:"");return e.jsxs("div",{className:"logs-panel",children:[e.jsx(Ja,{source:"server",title:"Full log",meta:P,following:a,onToggleFollow:o}),e.jsxs("div",{className:"logs-toolbar",children:[e.jsx(Ya,{value:l,onChange:c,placeholder:"Filter messages, tools, paths…"}),e.jsx(Xa,{value:d,onChange:h,options:[{value:"all",label:"All",count:y.length},...ac.map(S=>({value:S,label:S[0]+S.slice(1).toLowerCase(),count:x[S],tone:Xt[S]}))]}),e.jsx("div",{className:"logs-toolbar-spacer"}),e.jsx(Qe,{value:m,onChange:u,prefix:"Source",width:150,options:[{value:"all",label:"all"},...b.map(S=>({value:S,label:S}))]}),e.jsx(Qe,{value:p,onChange:f,withClock:!0,width:150,options:oc.map(S=>({value:S,label:qa[S]}))})]}),e.jsxs("div",{className:"logs-table",children:[e.jsxs("div",{className:"logs-table-head logs-server-grid",children:[e.jsx("span",{children:"Time"}),e.jsx("span",{children:"Level"}),e.jsx("span",{children:"Source"}),e.jsx("span",{children:"Message"})]}),e.jsxs(Za,{className:"logs-table-body",contentKey:$,children:[w.length===0&&e.jsx("div",{className:"logs-empty",children:t?"No line matches these filters.":s?"":"Loading…"}),w.map((S,I)=>{const E=`${S.ts}|${S.pid}|${v.length-w.length+I}`,B=C.has(E),F=S.scope===rc;return e.jsxs("div",{className:`logs-row${B?` open logs-row--${Xt[S.level]}`:""}`,children:[e.jsxs("button",{className:"logs-row-line logs-server-grid",onClick:()=>R(E),title:S.ts,children:[e.jsx("span",{className:"logs-cell-time",children:Va(S.ts)}),e.jsx("span",{children:e.jsx(rs,{tone:Xt[S.level],children:S.level})}),e.jsx("span",{className:`logs-cell-scope${F?" github":""}`,children:S.scope}),e.jsxs("span",{className:`logs-cell-message logs-level-text--${S.level.toLowerCase()}`,children:[S.message,S.continuation.length>0&&!B&&e.jsxs("span",{className:"logs-more",children:[" +",S.continuation.length," lines"]})]}),B?e.jsx(Mn,{size:12,className:"logs-row-chevron"}):e.jsx($t,{size:12,className:"logs-row-chevron hover-only"})]}),B&&e.jsxs("div",{className:"logs-row-detail logs-detail--server",children:[e.jsx("pre",{className:"logs-detail-context",children:[`time ${S.ts}`,`process ${S.process} · PID ${S.pid}`,`scope ${S.scope}`,"",S.message,...S.continuation].join(`
|
|
10
|
+
`)}),F&&e.jsxs("button",{className:"logs-link",onClick:()=>r(wt("github")),children:[e.jsx(yt,{size:12}),"Open in GitHub log"]})]})]},E)})]})]}),e.jsx(Qa,{following:a,text:L,checkedAt:n,error:s})]})}function ic({source:t}){const s=oe(),[n,a]=i.useState(!0),o=()=>a(p=>!p),{directory:r}=_i(n),l=os("server",t==="server",n),c=os("github",!0,n),d=i.useMemo(()=>new Map((r?.files??[]).map(p=>[p.id,p])),[r]),h=i.useMemo(()=>{const p=(c.data?.entries??[]).filter(f=>Tt(f.ts));return{calls:p.length,failed:p.filter(f=>!f.ok).length}},[c.data]),m=d.get("server"),u=d.get("github");return e.jsxs("div",{className:"logs-view",children:[e.jsxs("aside",{className:"logs-sidebar",children:[e.jsx("div",{className:"logs-sidebar-label",children:"Server"}),e.jsxs("button",{className:`logs-source${t==="server"?" active":""}`,onClick:()=>s(wt("server")),children:[e.jsx(ga,{size:16,className:"logs-source-icon"}),e.jsxs("span",{className:"logs-source-text",children:[e.jsx("span",{className:"logs-source-title",children:"Full log"}),e.jsxs("span",{className:"logs-source-sub",children:["server.log · ",m?Xe(m.size):"…"," · every event"]})]}),t==="server"&&n&&e.jsx("span",{className:"logs-live-dot",title:"Following"})]}),e.jsx("div",{className:"logs-sidebar-label",children:"Specific logs"}),e.jsxs("button",{className:`logs-source${t==="github"?" active":""}`,onClick:()=>s(wt("github")),children:[e.jsx(yt,{size:16,className:"logs-source-icon"}),e.jsxs("span",{className:"logs-source-text",children:[e.jsx("span",{className:"logs-source-title",children:"GitHub access"}),e.jsxs("span",{className:"logs-source-sub",children:["github.log · ",Q(h.calls)," call",h.calls===1?"":"s"," today"]})]}),h.failed>0&&e.jsxs("span",{className:"logs-source-badge",children:[h.failed," failed"]}),t==="github"&&n&&h.failed===0&&e.jsx("span",{className:"logs-live-dot",title:"Following"})]}),e.jsxs("div",{className:"logs-sidebar-footer",children:[e.jsx("div",{className:"logs-sidebar-label",children:"Log directory"}),e.jsx("div",{className:"logs-dir",title:r?.dir,children:r?.dir??"…"}),e.jsxs("div",{className:"logs-dir-sizes",children:["server.log ",m?Xe(m.size):"—"," · github.log"," ",u?.exists?Xe(u.size):"not written yet"]})]})]}),e.jsx("main",{className:"logs-main",children:t==="server"?e.jsx(lc,{...l,following:n,onToggleFollow:o}):e.jsx(nc,{...c,following:n,onToggleFollow:o})})]})}function cc(){const{currentProject:t,readOnly:s}=J(),{publications:n,error:a,reload:o}=Oa(t),[r,l]=i.useState("all"),c=n??[],d=c.filter(u=>u.status==="modified").length,m=[...r==="modified"?c.filter(u=>u.status==="modified"):c].sort((u,p)=>u.title.localeCompare(p.title));return e.jsxs("div",{className:"pubs-view",children:[e.jsxs("header",{className:"pubs-header",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"pubs-title",children:"Publications"}),e.jsx("div",{className:"pubs-subtitle",children:n===null?"Loading…":`${c.length} document${c.length===1?"":"s"} published in ${t}`+(d>0?` · ${d} changed since published`:"")})]}),e.jsxs("div",{className:"pubs-filter",role:"tablist",children:[e.jsxs("button",{className:r==="all"?"active":"",onClick:()=>l("all"),children:["All · ",c.length]}),e.jsxs("button",{className:r==="modified"?"active":"",onClick:()=>l("modified"),children:["Changed · ",d]})]})]}),a&&e.jsx("div",{className:"publish-error pubs-load-error",children:a}),n!==null&&c.length===0&&e.jsxs("div",{className:"pubs-empty",children:[e.jsx(Dt,{size:28}),e.jsxs("div",{children:["No published document in ",t,"."]}),e.jsx("div",{className:"pubs-empty-hint",children:"Publish one from the toolbar of the document."})]}),c.length>0&&e.jsxs("div",{className:"pubs-table",children:[e.jsxs("div",{className:"pubs-row pubs-row--head",children:[e.jsx("span",{children:"Document"}),e.jsx("span",{children:"Version note"}),e.jsx("span",{children:"Published"}),e.jsx("span",{children:"State"}),e.jsx("span",{})]}),m.map(u=>e.jsx(uc,{publication:u,readOnly:s,onChanged:o},u.id)),m.length===0&&e.jsx("div",{className:"pubs-row-empty",children:"No publication changed since it was published."})]})]})}function dc({publication:t}){return t.status==="missing"?e.jsx("span",{className:"pubs-badge pubs-badge--missing",children:"Document removed"}):t.status==="modified"?e.jsxs("span",{className:"pubs-badge pubs-badge--modified",children:["Changed · ",De(t.version)," → ",De(t.currentVersion)]}):e.jsxs("span",{className:"pubs-badge pubs-badge--current",children:["Up to date · ",De(t.version)]})}function uc({publication:t,readOnly:s,onChanged:n}){const a=oe(),{copied:o,copy:r}=Fa(),[l,c]=i.useState("idle"),[d,h]=i.useState(""),[m,u]=i.useState(!1),[p,f]=i.useState(null),C=an(t.token),j=t.docId.includes("/")?t.docId.slice(0,t.docId.lastIndexOf("/")):"",g=async b=>{u(!0),f(null);try{await b(),c("idle"),h(""),n()}catch(y){f(y instanceof Error?y.message:String(y))}finally{u(!1)}};return e.jsxs("div",{className:`pubs-row-wrap${l!=="idle"?" pubs-row-wrap--active":""}`,children:[e.jsxs("div",{className:"pubs-row",children:[e.jsxs("span",{className:"pubs-doc",children:[e.jsx(Kn,{size:14,className:"pubs-doc-icon"}),e.jsxs("span",{className:"pubs-doc-text",children:[t.status==="missing"?e.jsx("span",{className:"pubs-doc-title pubs-doc-title--missing",children:t.title}):e.jsx("button",{className:"pubs-doc-title",onClick:()=>a(se(t.project,t.docId)),title:"Open the document",children:t.title}),e.jsx("span",{className:"pubs-doc-folder",children:j||"root"})]})]}),e.jsx("span",{className:`pubs-note${t.note?"":" pubs-note--empty"}`,title:t.note||void 0,children:t.note||"—"}),e.jsx("span",{className:"pubs-date",children:is(t.publishedAt)}),e.jsx("span",{children:e.jsx(dc,{publication:t})}),e.jsxs("span",{className:"pubs-actions",children:[!s&&t.status==="modified"&&e.jsxs("button",{className:`pubs-update-btn${l==="update"?" active":""}`,onClick:()=>c(l==="update"?"idle":"update"),children:[e.jsx(Nt,{size:14}),"Update"]}),e.jsx("button",{className:"publish-icon-btn",onClick:()=>r(C),title:"Copy the link",children:o?e.jsx(ke,{size:14}):e.jsx(Rt,{size:14})}),e.jsx("a",{className:"publish-icon-btn",href:C,target:"_blank",rel:"noopener noreferrer",title:"Open the public page",children:e.jsx(qn,{size:14})}),!s&&e.jsx("button",{className:`publish-icon-btn publish-icon-btn--danger${l==="unpublish"?" active":""}`,onClick:()=>c(l==="unpublish"?"idle":"unpublish"),title:"Unpublish",children:e.jsx(vs,{size:14})})]})]}),l==="update"&&e.jsxs("div",{className:"pubs-row-panel",children:[e.jsxs("label",{className:"publish-field pubs-row-panel-field",children:[e.jsxs("span",{className:"publish-field-label",children:["Note for the new version ",e.jsx("span",{className:"publish-field-optional",children:"(optional)"})]}),e.jsx("input",{className:"publish-input",value:d,maxLength:Qt,placeholder:"e.g. Added the Entry points section",onChange:b=>h(b.target.value),autoFocus:!0})]}),e.jsxs("div",{className:"publish-actions",children:[e.jsx("button",{className:"btn-secondary",onClick:()=>c("idle"),disabled:m,children:"Cancel"}),e.jsxs("button",{className:"btn-primary",onClick:()=>g(()=>cn(t.id,d)),disabled:m,children:[e.jsx(Nt,{size:14}),m?"Updating…":"Update publication"]})]})]}),l==="unpublish"&&e.jsx("div",{className:"pubs-row-panel",children:e.jsx(Ba,{title:t.title,busy:m,onCancel:()=>c("idle"),onConfirm:()=>g(()=>ln(t.id))})}),p&&e.jsx("div",{className:"publish-error pubs-row-error",children:p})]})}const eo="mcp-documentor.panelWidth",kt=264,hc=200,mc=520,to=t=>Math.min(mc,Math.max(hc,Math.round(t)));function pc(){try{const t=Number(localStorage.getItem(eo));return t?to(t):kt}catch{return kt}}function Qs(t){try{localStorage.setItem(eo,String(t))}catch{}}function fc(){const[t,s]=i.useState(pc),[n,a]=i.useState(!1);return{width:t,resizing:n,startResize:l=>{l.preventDefault();const c=l.clientX,d=t;let h=d;a(!0);const m=p=>{h=to(d+p.clientX-c),s(h)},u=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",u),a(!1),Qs(h)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",u)},resetWidth:()=>{s(kt),Qs(kt)}}}function gc(){const{codeSourceMigrationPending:t,setCodeSourceMigrationPending:s,currentProject:n,selectedDocId:a}=J(),o=he(),r=oe(),l=ka(o.pathname),c=js(o.pathname),d=l!==null||c,[h,m]=i.useState(!1),[u,p]=i.useState(!1),[f,C]=i.useState("docs"),[j,g]=i.useState(!0),b=fc(),[y,x]=i.useState(0),[v,w]=i.useState(null),[$,R]=i.useState(!1),N=$||t,P=()=>{d&&r(se(n,a))};i.useEffect(()=>{const I=E=>{(E.metaKey||E.ctrlKey)&&E.key.toLowerCase()==="k"&&(E.preventDefault(),d&&r(se(n,a)),C("search"),g(!0),x(B=>B+1))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[d,r,n,a]);const L=I=>{if(I==="logs"){l||r(wt("server"));return}if(I==="publications"){c||r(wa);return}if(!d&&I===f){g(E=>!E);return}P(),C(I),g(!0)},S=l?"logs":c?"publications":j?f:null;return e.jsxs("div",{className:"dashboard",children:[e.jsx(Oi,{active:S,onSelect:L,onOpenSettings:()=>m(!h),onOpenProjectSettings:w}),u&&e.jsx(Bi,{onClose:()=>p(!1)}),h&&e.jsx(Ui,{onClose:()=>m(!1),onShowMigrationReport:()=>{m(!1),R(!0)}}),v&&e.jsx(Ki,{project:v,onClose:()=>w(null)}),N&&e.jsx(Yi,{onClose:()=>{R(!1),s(!1)},onReviewProject:w}),l?e.jsx(ic,{source:l}):c?e.jsx(cc,{}):e.jsxs("div",{className:"dashboard-body",children:[e.jsxs("div",{className:`nav-panel-wrapper${j?"":" collapsed"}${b.resizing?" resizing":""}`,style:{"--panel-width":`${b.width}px`},children:[e.jsx(Zl,{mode:f,searchFocusToken:y,onCreateDoc:()=>p(!0),onOpenProjectSettings:w,onClose:()=>g(!1)}),j&&e.jsx("div",{className:"nav-panel-resizer",onPointerDown:b.startResize,onDoubleClick:b.resetWidth,title:"Drag to resize · double-click to reset"})]}),e.jsx(Di,{})]})]})}const pt="[mcp-documentor]",xc=3e3;async function Zs(t){const s=await fetch(t);if(!s.ok)throw new Error(`${t} answered HTTP ${s.status}: ${await s.text()}`);return s.json()}const vc=()=>{const t=J(),s=i.useRef(t);s.current=t,i.useEffect(()=>{let n=null,a,o=!1;const r=h=>{$a(h).then(m=>{s.current.currentProject===h&&s.current.setDocs(m)})},l=h=>{if(h.type==="INITIAL_STATE")console.info(`${pt} Received INITIAL_STATE from server`),s.current.applyInitialState(h.data);else if(h.type==="CONFIG_UPDATED")console.info(`${pt} Received CONFIG_UPDATED from server`);else if(h.type==="BUNDLES_UPDATED")console.info(`${pt} Received BUNDLES_UPDATED from server`),s.current.setExportBundles(h.data?.bundles??[]);else if(h.type==="PROJECTS_CHANGED")s.current.applyInitialState({projects:h.data?.projects??[]});else if(h.type==="CODE_SOURCES_CHANGED"){s.current.bumpCodeSourcesVersion();const m=h.data?.project,u=s.current.currentProject;(!m||m===u)&&r(u)}else if(h.type==="DOCS_CHANGED"){const m=h.data?.project;m&&m===s.current.currentProject&&(r(m),s.current.bumpPublicationsVersion())}else h.type==="PUBLICATIONS_CHANGED"?h.data?.project===s.current.currentProject&&s.current.bumpPublicationsVersion():h.type==="COMMENTS_CHANGED"&&h.data?.project===s.current.currentProject&&s.current.bumpCommentsVersion()},c=async h=>{const m=await Zs("/api/initial-state");o||(s.current.applyInitialState(m),h&&(s.current.bumpCodeSourcesVersion(),s.current.bumpPublicationsVersion(),s.current.bumpCommentsVersion(),r(s.current.currentProject)))},d=async()=>{try{const h=n?`?since=${n.seq}&epoch=${encodeURIComponent(n.epoch)}`:"",m=await Zs(`/api/changes${h}`);if(o)return;m.reset?await c(n!==null):m.events.forEach(l),n={epoch:m.epoch,seq:m.seq}}catch(h){console.error(`${pt} Polling /api/changes failed: ${h instanceof Error?h.message:String(h)}`)}o||(a=setTimeout(d,xc))};return d(),()=>{o=!0,clearTimeout(a)}},[])};function en(t){return ka(t)!==null||js(t)}function jc(){const t=he(),s=oe(),{hasReceivedInitialState:n,projects:a,setCurrentProject:o,setDocs:r,setSelectedDocId:l,setSelectedDoc:c}=J();i.useEffect(()=>{if(!n||en(t.pathname))return;const{project:m}=zs(t.pathname);if(m)return;const u=Os(),p=(u&&a.includes(u)?u:a[0])??"default";s(se(p,null),{replace:!0})},[n,a,t.pathname,s]),i.useEffect(()=>{if(!n||!js(t.pathname))return;const m=Os();o((m&&a.includes(m)?m:a[0])??"default")},[n,a,t.pathname]);const{project:d,docId:h}=en(t.pathname)?{project:null,docId:null}:zs(t.pathname);i.useEffect(()=>{if(!d)return;let m=!1;return o(d),Al(d),(async()=>{const u=await $a(d);m||r(u)})(),()=>{m=!0}},[d]),i.useEffect(()=>{d&&(l(h),h===null&&c(null))},[d,h])}function bc(){return vc(),jc(),ki(),br([{path:"*",element:e.jsx(gc,{})}])}function yc(){return e.jsx(nl,{children:e.jsx(bc,{})})}_o.createRoot(document.getElementById("root")).render(e.jsx(i.StrictMode,{children:e.jsx(yc,{})}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as ae}from"./chunk-55IACEB6-
|
|
1
|
+
import{g as ae}from"./chunk-55IACEB6-1dY_RrZJ.js";import{s as ce}from"./chunk-2J33WTMH-CrEHZokt.js";import{_ as h,l as I,o as le,r as he,D as de,G as j,c as P,i as G,b3 as ge,V as ue,W as pe,X as fe}from"./DocContent-D2Pgvsaw.js";const _=[];for(let t=0;t<256;++t)_.push((t+256).toString(16).slice(1));function me(t,e=0){return(_[t[e+0]]+_[t[e+1]]+_[t[e+2]]+_[t[e+3]]+"-"+_[t[e+4]]+_[t[e+5]]+"-"+_[t[e+6]]+_[t[e+7]]+"-"+_[t[e+8]]+_[t[e+9]]+"-"+_[t[e+10]]+_[t[e+11]]+_[t[e+12]]+_[t[e+13]]+_[t[e+14]]+_[t[e+15]]).toLowerCase()}const ye=new Uint8Array(16);function Ee(){return crypto.getRandomValues(ye)}function _e(t,e,a){return crypto.randomUUID?crypto.randomUUID():be(t)}function be(t,e,a){t=t||{};const l=t.random??t.rng?.()??Ee();if(l.length<16)throw new Error("Random bytes length must be >= 16");return l[6]=l[6]&15|64,l[8]=l[8]&63|128,me(l)}var q=(function(){var t=h(function(L,s,i,o){for(i=i||{},o=L.length;o--;i[L[o]]=s);return i},"o"),e=[1,4],a=[1,13],l=[1,12],n=[1,15],d=[1,16],f=[1,20],y=[1,19],E=[6,7,8],b=[1,26],v=[1,24],R=[1,25],g=[6,7,11],A=[1,6,13,15,16,19,22],J=[1,33],K=[1,34],$=[1,6,7,11,13,15,16,19,22],H={trace:h(function(){},"trace"),yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,MINDMAP:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,ICON:15,CLASS:16,nodeWithId:17,nodeWithoutId:18,NODE_DSTART:19,NODE_DESCR:20,NODE_DEND:21,NODE_ID:22,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"MINDMAP",11:"EOF",13:"SPACELIST",15:"ICON",16:"CLASS",19:"NODE_DSTART",20:"NODE_DESCR",21:"NODE_DEND",22:"NODE_ID"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[18,3],[17,1],[17,4]],performAction:h(function(s,i,o,c,p,r,B){var u=r.length-1;switch(p){case 6:case 7:return c;case 8:c.getLogger().trace("Stop NL ");break;case 9:c.getLogger().trace("Stop EOF ");break;case 11:c.getLogger().trace("Stop NL2 ");break;case 12:c.getLogger().trace("Stop EOF2 ");break;case 15:c.getLogger().info("Node: ",r[u].id),c.addNode(r[u-1].length,r[u].id,r[u].descr,r[u].type);break;case 16:c.getLogger().trace("Icon: ",r[u]),c.decorateNode({icon:r[u]});break;case 17:case 21:c.decorateNode({class:r[u]});break;case 18:c.getLogger().trace("SPACELIST");break;case 19:c.getLogger().trace("Node: ",r[u].id),c.addNode(0,r[u].id,r[u].descr,r[u].type);break;case 20:c.decorateNode({icon:r[u]});break;case 25:c.getLogger().trace("node found ..",r[u-2]),this.$={id:r[u-1],descr:r[u-1],type:c.getType(r[u-2],r[u])};break;case 26:this.$={id:r[u],descr:r[u],type:c.nodeType.DEFAULT};break;case 27:c.getLogger().trace("node found ..",r[u-3]),this.$={id:r[u-3],descr:r[u-1],type:c.getType(r[u-2],r[u])};break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:e},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:e},{6:a,7:[1,10],9:9,12:11,13:l,14:14,15:n,16:d,17:17,18:18,19:f,22:y},t(E,[2,3]),{1:[2,2]},t(E,[2,4]),t(E,[2,5]),{1:[2,6],6:a,12:21,13:l,14:14,15:n,16:d,17:17,18:18,19:f,22:y},{6:a,9:22,12:11,13:l,14:14,15:n,16:d,17:17,18:18,19:f,22:y},{6:b,7:v,10:23,11:R},t(g,[2,22],{17:17,18:18,14:27,15:[1,28],16:[1,29],19:f,22:y}),t(g,[2,18]),t(g,[2,19]),t(g,[2,20]),t(g,[2,21]),t(g,[2,23]),t(g,[2,24]),t(g,[2,26],{19:[1,30]}),{20:[1,31]},{6:b,7:v,10:32,11:R},{1:[2,7],6:a,12:21,13:l,14:14,15:n,16:d,17:17,18:18,19:f,22:y},t(A,[2,14],{7:J,11:K}),t($,[2,8]),t($,[2,9]),t($,[2,10]),t(g,[2,15]),t(g,[2,16]),t(g,[2,17]),{20:[1,35]},{21:[1,36]},t(A,[2,13],{7:J,11:K}),t($,[2,11]),t($,[2,12]),{21:[1,37]},t(g,[2,25]),t(g,[2,27])],defaultActions:{2:[2,1],6:[2,2]},parseError:h(function(s,i){if(i.recoverable)this.trace(s);else{var o=new Error(s);throw o.hash=i,o}},"parseError"),parse:h(function(s){var i=this,o=[0],c=[],p=[null],r=[],B=this.table,u="",U=0,Q=0,ie=2,Z=1,se=r.slice.call(arguments,1),m=Object.create(this.lexer),T={yy:{}};for(var W in this.yy)Object.prototype.hasOwnProperty.call(this.yy,W)&&(T.yy[W]=this.yy[W]);m.setInput(s,T.yy),T.yy.lexer=m,T.yy.parser=this,typeof m.yylloc>"u"&&(m.yylloc={});var X=m.yylloc;r.push(X);var re=m.options&&m.options.ranges;typeof T.yy.parseError=="function"?this.parseError=T.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function oe(S){o.length=o.length-2*S,p.length=p.length-S,r.length=r.length-S}h(oe,"popStack");function ee(){var S;return S=c.pop()||m.lex()||Z,typeof S!="number"&&(S instanceof Array&&(c=S,S=c.pop()),S=i.symbols_[S]||S),S}h(ee,"lex");for(var k,O,x,z,C={},V,N,te,F;;){if(O=o[o.length-1],this.defaultActions[O]?x=this.defaultActions[O]:((k===null||typeof k>"u")&&(k=ee()),x=B[O]&&B[O][k]),typeof x>"u"||!x.length||!x[0]){var Y="";F=[];for(V in B[O])this.terminals_[V]&&V>ie&&F.push("'"+this.terminals_[V]+"'");m.showPosition?Y="Parse error on line "+(U+1)+`:
|
|
2
2
|
`+m.showPosition()+`
|
|
3
3
|
Expecting `+F.join(", ")+", got '"+(this.terminals_[k]||k)+"'":Y="Parse error on line "+(U+1)+": Unexpected "+(k==Z?"end of input":"'"+(this.terminals_[k]||k)+"'"),this.parseError(Y,{text:m.match,token:this.terminals_[k]||k,line:m.yylineno,loc:X,expected:F})}if(x[0]instanceof Array&&x.length>1)throw new Error("Parse Error: multiple actions possible at state: "+O+", token: "+k);switch(x[0]){case 1:o.push(k),p.push(m.yytext),r.push(m.yylloc),o.push(x[1]),k=null,Q=m.yyleng,u=m.yytext,U=m.yylineno,X=m.yylloc;break;case 2:if(N=this.productions_[x[1]][1],C.$=p[p.length-N],C._$={first_line:r[r.length-(N||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(N||1)].first_column,last_column:r[r.length-1].last_column},re&&(C._$.range=[r[r.length-(N||1)].range[0],r[r.length-1].range[1]]),z=this.performAction.apply(C,[u,Q,U,T.yy,x[1],p,r].concat(se)),typeof z<"u")return z;N&&(o=o.slice(0,-1*N*2),p=p.slice(0,-1*N),r=r.slice(0,-1*N)),o.push(this.productions_[x[1]][0]),p.push(C.$),r.push(C._$),te=B[o[o.length-2]][o[o.length-1]],o.push(te);break;case 3:return!0}}return!0},"parse")},ne=(function(){var L={EOF:1,parseError:h(function(i,o){if(this.yy.parser)this.yy.parser.parseError(i,o);else throw new Error(i)},"parseError"),setInput:h(function(s,i){return this.yy=i||this.yy||{},this._input=s,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:h(function(){var s=this._input[0];this.yytext+=s,this.yyleng++,this.offset++,this.match+=s,this.matched+=s;var i=s.match(/(?:\r\n?|\n).*/g);return i?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),s},"input"),unput:h(function(s){var i=s.length,o=s.split(/(?:\r\n?|\n)/g);this._input=s+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-i),this.offset-=i;var c=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),o.length-1&&(this.yylineno-=o.length-1);var p=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:o?(o.length===c.length?this.yylloc.first_column:0)+c[c.length-o.length].length-o[0].length:this.yylloc.first_column-i},this.options.ranges&&(this.yylloc.range=[p[0],p[0]+this.yyleng-i]),this.yyleng=this.yytext.length,this},"unput"),more:h(function(){return this._more=!0,this},"more"),reject:h(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:h(function(s){this.unput(this.match.slice(s))},"less"),pastInput:h(function(){var s=this.matched.substr(0,this.matched.length-this.match.length);return(s.length>20?"...":"")+s.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:h(function(){var s=this.match;return s.length<20&&(s+=this._input.substr(0,20-s.length)),(s.substr(0,20)+(s.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:h(function(){var s=this.pastInput(),i=new Array(s.length+1).join("-");return s+this.upcomingInput()+`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{ab as S,a3 as R,b2 as K,g as Q,s as Y,a as tt,b as et,q as at,p as nt,_ as d,l as z,c as rt,F as it,I as st,N as ot,e as lt,z as ct,G as ut}from"./DocContent-
|
|
1
|
+
import{ab as S,a3 as R,b2 as K,g as Q,s as Y,a as tt,b as et,q as at,p as nt,_ as d,l as z,c as rt,F as it,I as st,N as ot,e as lt,z as ct,G as ut}from"./DocContent-D2Pgvsaw.js";import{p as dt}from"./chunk-4BX2VUAB-AGQbPC36.js";import{p as pt}from"./wardley-L42UT6IY-Da4i2-Py.js";import{d as P}from"./arc-ytJX8b9b.js";import{o as gt}from"./ordinal-Cboi1Yqb.js";import"./init-Gi6I4Gst.js";function ft(t,a){return a<t?-1:a>t?1:a>=t?0:NaN}function ht(t){return t}function mt(){var t=ht,a=ft,f=null,y=S(0),s=S(R),p=S(0);function o(e){var r,l=(e=K(e)).length,g,h,v=0,c=new Array(l),i=new Array(l),x=+y.apply(this,arguments),w=Math.min(R,Math.max(-R,s.apply(this,arguments)-x)),m,D=Math.min(Math.abs(w)/l,p.apply(this,arguments)),$=D*(w<0?-1:1),u;for(r=0;r<l;++r)(u=i[c[r]=r]=+t(e[r],r,e))>0&&(v+=u);for(a!=null?c.sort(function(A,C){return a(i[A],i[C])}):f!=null&&c.sort(function(A,C){return f(e[A],e[C])}),r=0,h=v?(w-l*$)/v:0;r<l;++r,x=m)g=c[r],u=i[g],m=x+(u>0?u*h:0)+$,i[g]={data:e[g],index:r,value:u,startAngle:x,endAngle:m,padAngle:D};return i}return o.value=function(e){return arguments.length?(t=typeof e=="function"?e:S(+e),o):t},o.sortValues=function(e){return arguments.length?(a=e,f=null,o):a},o.sort=function(e){return arguments.length?(f=e,a=null,o):f},o.startAngle=function(e){return arguments.length?(y=typeof e=="function"?e:S(+e),o):y},o.endAngle=function(e){return arguments.length?(s=typeof e=="function"?e:S(+e),o):s},o.padAngle=function(e){return arguments.length?(p=typeof e=="function"?e:S(+e),o):p},o}var vt=ut.pie,F={sections:new Map,showData:!1},T=F.sections,W=F.showData,xt=structuredClone(vt),St=d(()=>structuredClone(xt),"getConfig"),yt=d(()=>{T=new Map,W=F.showData,ct()},"clear"),wt=d(({label:t,value:a})=>{if(a<0)throw new Error(`"${t}" has invalid value: ${a}. Negative values are not allowed in pie charts. All slice values must be >= 0.`);T.has(t)||(T.set(t,a),z.debug(`added new section: ${t}, with value: ${a}`))},"addSection"),At=d(()=>T,"getSections"),Ct=d(t=>{W=t},"setShowData"),Dt=d(()=>W,"getShowData"),_={getConfig:St,clear:yt,setDiagramTitle:nt,getDiagramTitle:at,setAccTitle:et,getAccTitle:tt,setAccDescription:Y,getAccDescription:Q,addSection:wt,getSections:At,setShowData:Ct,getShowData:Dt},$t=d((t,a)=>{dt(t,a),a.setShowData(t.showData),t.sections.map(a.addSection)},"populateDb"),Tt={parse:d(async t=>{const a=await pt("pie",t);z.debug(a),$t(a,_)},"parse")},bt=d(t=>`
|
|
2
2
|
.pieCircle{
|
|
3
3
|
stroke: ${t.pieStrokeColor};
|
|
4
4
|
stroke-width : ${t.pieStrokeWidth};
|