living-ai-documentation 3.35.0 → 3.37.0
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/dist/frontend-svelte/assets/{index-Ji7cY_k-.js → index-BjHN0FJd.js} +2 -2
- package/dist/frontend-svelte/assets/{index-CwVzt4Ag.css → index-c_1Dt9Nx.css} +1 -1
- package/dist/frontend-svelte/assets/{main-DCIeFe1K.js → main-CgFZwst-.js} +1 -1
- package/dist/frontend-svelte/index.html +2 -2
- package/dist/src/lib/git.d.ts +8 -0
- package/dist/src/lib/git.d.ts.map +1 -1
- package/dist/src/lib/git.js +63 -0
- package/dist/src/lib/git.js.map +1 -1
- package/dist/src/mcp/server.d.ts.map +1 -1
- package/dist/src/mcp/server.js +62 -0
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/mcp/tools/context.d.ts +18 -0
- package/dist/src/mcp/tools/context.d.ts.map +1 -0
- package/dist/src/mcp/tools/context.js +153 -0
- package/dist/src/mcp/tools/context.js.map +1 -0
- package/package.json +1 -1
|
@@ -84,7 +84,7 @@ Texte`};case`link`:return{text:Se(`snip-link-text`),textFallback:Y(`snippet.link
|
|
|
84
84
|
|
|
85
85
|
`,t+1);return n>=0?n:e.length}s=s.previousElementSibling}let c=a.nextElementSibling;for(;c;){let t=mu(e,c,r);if(t!==null){let n=e.lastIndexOf(`
|
|
86
86
|
|
|
87
|
-
`,t);return n>=0?n:0}c=c.nextElementSibling}return e.length}function gu(e,t,n){if(!e||typeof t!=`string`)return()=>{};let r=au(t);su(e,r);let i=i=>{let a=i.target?.closest(`[data-inline-snippet-index]`);if(a&&e.contains(a)){let e=r[Number(a.dataset.inlineSnippetIndex)];if(!e)return;i.preventDefault();let t=Yl(e.type),o=Zl(e.type);lu(i,[{iconClass:t.iconClass,labelKey:t.labelKey,dataAction:`edit`,dataType:e.type,onActivate:()=>n.onEdit(e)},{iconClass:o.iconClass,labelKey:o.labelKey,dataAction:`delete`,dataType:e.type,onActivate:()=>n.onDelete(e)}]);return}if(!e.contains(i.target))return;let o=hu(t,e,i.target,r,i.clientY);o!==null&&(i.preventDefault(),lu(i,{iconClass:`fa-solid fa-plus`,labelKey:`snippet.inline_insert_btn`,dataAction:`insert`,onActivate:()=>n.onInsert(o)}))};e.addEventListener(`contextmenu`,i);let a=t=>{let i=t.target?.closest(`[data-inline-snippet-index]`);if(!i||!e.contains(i))return;let a=r[Number(i.dataset.inlineSnippetIndex)];!a||a.type!==`table`||(t.preventDefault(),t.stopPropagation(),cu(),n.onEdit({...a,tableFocusCell:du(t.target,i)||void 0}))};e.addEventListener(`dblclick`,a);let o=e.closest(`#home-content-area`)||e.closest(`main`),s=null;o&&(s=r=>{r.defaultPrevented||e.offsetParent!==null&&(r.target?.closest(`textarea, input, [data-inline-snippet-index]`)||e.contains(r.target)||(r.preventDefault(),lu(r,{iconClass:`fa-solid fa-plus`,labelKey:`snippet.inline_insert_btn`,dataAction:`insert`,onActivate:()=>n.onInsert(t.length)})))},o.addEventListener(`contextmenu`,s));let c=e=>{$l&&!$l.contains(e.target)&&cu()},l=e=>{e.key===`Escape`&&cu()};return document.addEventListener(`click`,c),document.addEventListener(`keydown`,l),()=>{e.removeEventListener(`contextmenu`,i),e.removeEventListener(`dblclick`,a),o&&s&&o.removeEventListener(`contextmenu`,s),document.removeEventListener(`click`,c),document.removeEventListener(`keydown`,l),cu(),e.querySelectorAll(`[data-inline-snippet-index]`).forEach(e=>{e.removeAttribute(`data-inline-snippet-index`),e.classList.remove(`ld-inline-snippet-target`)})}}var _u=U(`<textarea id="doc-editor" data-testid="doc-editor" spellcheck="false" class="w-full min-h-[70vh] px-4 py-3 text-sm font-mono leading-relaxed rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-y"></textarea>`),vu=U(`<div id="doc-content" data-testid="doc-content"></div>`),yu=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-sm mx-4 p-6 space-y-5"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"> </h3> <div class="space-y-1.5"><label for="img-paste-name" class="block text-xs font-medium text-gray-500 dark:text-gray-400"> <span class="font-normal text-gray-400"> </span></label> <div class="flex items-center gap-2"><input id="img-paste-name" type="text" class="flex-1 px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono focus:outline-none focus:ring-2 focus:ring-blue-500"/> <span class="text-xs text-gray-400 shrink-0"> </span></div></div> <div class="flex justify-end gap-3 pt-1"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div></div></div>`),bu=U(`<div data-testid="content-lightbox" class="fixed inset-0 z-50 bg-white flex items-center justify-center cursor-pointer p-4"><img data-testid="lightbox-image" class="max-w-full max-h-full object-contain select-none"/> <button class="absolute top-4 right-4 text-gray-500 hover:text-gray-950 text-2xl leading-none">×</button></div>`),xu=U(`<!> <!> <!> <!>`,1);function Su(e,t){Ke(t,!0);let n=Wi(t,`onopen`,3,()=>{}),r=Wi(t,`onanchor`,3,D),i=Wi(t,`onconfirmdelete`,3,void 0),a=Wi(t,`oncontentwired`,3,void 0),o=Wi(t,`rewireSignal`,3,void 0),s=Wi(t,`editing`,15,!1),c=Wi(t,`saveMsg`,15,null),l=P(null),u=P(null),d=P(``),f=null,p=P(!1),m=P(`insert`),h=P(null),g=P(0),_=P(!1),v=P(``),y=P(`png`),b=null,x=0,S=0,C=P(null),w=P(``),T=/[̀-ͯ]/g;function E(e){return(e||``).normalize(`NFD`).replace(T,``).toLowerCase().replace(/[^a-z0-9]/g,`_`)}function D(e){document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})}Gi(()=>{let e=window;return e.openSnippetsModal=()=>{F(m,`insert`),F(p,!0)},e.openSnippetsModalForInlineInsert=e=>{F(m,`inline-insert`),F(g,Math.max(0,Number(e)||0),!0),F(p,!0)},()=>{delete e.openSnippetsModal,delete e.openSnippetsModalForInlineInsert}}),kn(()=>{if(o(),t.html,t.content,f?.(),f=null,!(s()||!V(l)))return Us(V(l),t.html,{content:t.content,codeBlockMaxHeight:X.codeBlockMaxHeight,t:Y,onDocLink:(e,t)=>n()(e,t),onAnchor:r()}),f=gu(V(l),t.content,{onEdit:e=>{F(m,`inline-edit`),F(h,e,!0),F(p,!0)},onInsert:e=>{F(m,`inline-insert`),F(g,e,!0),F(p,!0)},onDelete:async e=>{(i()?await i()():confirm(Y(`snippet.inline_delete_message`)))&&await t.onsave(t.content.slice(0,e.start)+t.content.slice(e.end))}}),a()?.(V(l)),()=>{f?.(),f=null}});function ee(){F(d,t.content,!0),s(!0),c(null),requestAnimationFrame(()=>V(u)?.focus())}function O(){s(!1),c(null)}async function te(){c({text:Y(`doc.saving`),cls:`text-gray-400`});try{await t.onsave(V(d)),s(!1),c(null)}catch(e){c({text:Y(`error.save`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`})}}function k(){F(m,`insert`),F(p,!0)}function ne(){return s()}function A(e){let t=Array.from(e.clipboardData?.items??[]).find(e=>e.type.startsWith(`image/`));if(t){e.preventDefault(),x=V(u).selectionStart,S=V(u).selectionEnd,F(y,t.type.split(`/`)[1].replace(`jpeg`,`jpg`)||`png`,!0);let n=t.getAsFile();if(!n)return;b=n,F(v,E(Date.now().toString()),!0),F(_,!0);return}let n=Array.from(e.clipboardData?.files??[]).filter(e=>!e.type.startsWith(`image/`));if(n.length){e.preventDefault();let t=V(u).selectionStart,r=V(u).selectionEnd;(async()=>{for(let e of n)await se(e,t,r)})()}}function re(e){let t=Array.from(e.dataTransfer?.files??[]).filter(e=>!e.type.startsWith(`image/`));if(!t.length)return;e.preventDefault(),e.stopPropagation();let n=V(u).selectionStart,r=V(u).selectionEnd;(async()=>{for(let e of t)await se(e,n,r)})()}function ie(e){e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}function ae(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function oe(e,t,n){let r=V(d).slice(0,t),i=V(d).slice(n);F(d,r+e+i),requestAnimationFrame(()=>{V(u).selectionStart=V(u).selectionEnd=t+e.length,V(u).focus()})}async function se(e,n,r){if(e.size>19922944){c({text:Y(`doc.file_too_large`)+` (${(e.size/1024/1024).toFixed(1)} MB, max 19 MB)`,cls:`text-red-500 dark:text-red-400`});return}c({text:Y(`doc.uploading_file`),cls:`text-gray-400`});try{let i=await ae(e),a=await fetch(`/api/files/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:i,name:e.name,documentId:t.docId})});if(!a.ok){let e=``;try{e=(await a.json()).error||``}catch{e=await a.text()}throw Error(e||`HTTP ${a.status}`)}let{url:o,originalName:s}=await a.json();oe(`[📎 ${s||e.name}](${o})`,n,r),c(null)}catch(e){c({text:Y(`doc.file_upload_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`})}}function ce(){F(_,!1),b=null}async function le(){let e=E(V(v))||Date.now().toString();if(F(_,!1),b){c({text:Y(`doc.uploading_image`),cls:`text-gray-400`});try{let t=await ae(b),n=await fetch(`/api/images/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:t,ext:V(y),name:e})});if(!n.ok)throw Error(await n.text());let{filename:r}=await n.json();oe(``,x,S),c(null)}catch(e){c({text:Y(`doc.image_upload_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`})}finally{b=null}}}function ue(){F(C,null),F(w,``)}function de(e){if(!e.shiftKey&&!e.metaKey)return;let t=e.target,n=t.closest(`img`),r=t.closest(`.mermaid`)?.querySelector(`svg`);if(!n&&!r)return;if(e.preventDefault(),e.stopPropagation(),n){F(C,n.src,!0),F(w,n.alt||``,!0);return}let i=new XMLSerializer().serializeToString(r);F(C,`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`),F(w,Y(`doc.mermaid_diagram_alt`),!0)}function fe(e){e.key===`Escape`&&V(C)&&ue()}var pe={enterEdit:ee,cancelEdit:O,save:te,openSnippets:k,isEditing:ne},me=xu();Nr(`keydown`,on,fe);var he=R(me),ge=e=>{var t=_u();yn(t),Vi(t,e=>F(u,e),()=>V(u)),Nr(`paste`,t,A),Nr(`drop`,t,re),Nr(`dragover`,t,ie),Ni(t,()=>V(d),e=>F(d,e)),W(e,t)},_e=e=>{var t=vu();Vi(t,e=>F(l,e),()=>V(l)),B(()=>gi(t,1,`prose prose-gray dark:prose-invert max-w-none prose-headings:scroll-mt-4 prose-headings:font-semibold prose-h1:text-[2.1875rem] prose-h2:text-[1.8125rem] prose-h3:text-[1.5rem] prose-h4:text-[1.25rem] prose-a:text-blue-600 dark:prose-a:text-blue-400 prose-code:before:content-none prose-code:after:content-none ${X.codeBlockLightTheme?`prose-pre:bg-[#f6f8fa] prose-pre:text-gray-800 prose-pre:border prose-pre:border-gray-200 prose-pre:rounded-lg dark:prose-pre:bg-[#0d1117] dark:prose-pre:text-gray-100 dark:prose-pre:border-gray-700`:`prose-pre:bg-[#0d1117] prose-pre:border prose-pre:border-gray-700`} ${X.imageRoundedCorners?`[&_img]:rounded-xl`:``} ${X.imageCentered?`[&_img]:mx-auto [&_img]:block`:``} ${X.imageBorder?`[&_img]:[box-shadow:0_0_0_1px_rgba(0,0,0,0.10),0_4px_12px_rgba(0,0,0,0.04)] dark:[&_img]:[box-shadow:0_0_0_1px_rgba(255,255,255,0.08),0_4px_12px_rgba(255,255,255,0.25)]`:``}`)),H(`click`,t,de),W(e,t)};K(he,e=>{s()?e(ge):e(_e,-1)});var ve=z(he,2);Kl(ve,{get open(){return V(p)},get editor(){return V(u)},get mode(){return V(m)},get docId(){return t.docId},get content(){return t.content},get range(){return V(h)},get insertPos(){return V(g)},get onsave(){return t.onsave},onclose:()=>F(p,!1)});var ye=z(ve,2),be=e=>{var t=yu(),n=L(t),r=L(n),i=L(r);M(r);var a=z(r,2),o=L(a),s=L(o),c=z(s),l=L(c,!0);M(c),M(o);var u=z(o,2),d=L(u);Di(d);var f=z(d,2),p=L(f);M(f),M(u),M(a);var m=z(a,2),h=L(m),g=L(h,!0);M(h);var _=z(h,2),b=L(_,!0);M(_),M(m),M(n),M(t),B((e,t,n,r,a)=>{G(i,`🖼️ ${e??``}`),G(s,`${t??``} `),G(l,n),Oi(d,V(v)),G(p,`.${V(y)??``}`),G(g,r),G(b,a)},[()=>Y(`modal.img_paste.title`),()=>Y(`modal.img_paste.filename_label`),()=>Y(`modal.img_paste.saved_hint`),()=>Y(`common.cancel`),()=>Y(`modal.img_paste.paste_btn`)]),H(`input`,d,e=>F(v,E(e.target.value),!0)),H(`click`,h,ce),H(`click`,_,le),W(e,t)};K(ye,e=>{V(_)&&e(be)});var xe=z(ye,2),Se=e=>{var t=bu(),n=L(t),r=z(n,2);M(t),B(()=>{J(n,`src`,V(C)),J(n,`alt`,V(w))}),H(`click`,t,ue),H(`click`,n,e=>e.stopPropagation()),H(`click`,r,ue),W(e,t)};return K(xe,e=>{V(C)&&e(Se)}),W(e,me),qe(pe)}Pr([`click`,`input`]);var Cu=U(`<span> </span> <code> </code>`,1),wu=U(`<button type="button" data-testid="bp-copy-doc-id"><i aria-hidden="true"></i></button>`),Tu=U(`<button class="bpadr-icon-btn" data-testid="bp-edit" type="button">✏️</button> <button class="bpadr-icon-btn" data-testid="bp-delete" type="button">🗑️</button>`,1),Eu=U(`<span> </span>`),Du=U(`<footer class="bpadr-footer bpadr-doc-footer"><!> <button type="button" class="bpadr-btn-ghost" data-testid="bp-cancel"> </button> <button type="button" class="bpadr-btn-ghost" data-testid="bp-snippets"> </button> <button type="button" class="bpadr-btn-primary" data-testid="bp-save"> </button></footer>`),Ou=U(`<div class="bpadr-read"><!></div> <!>`,1),ku=U(`<form class="bpadr-form"><input type="hidden" name="category"/> <input type="hidden" name="folder"/> <div class="bpadr-field"><label for="adr-title"> </label> <input id="adr-title" type="text" class="bpadr-input"/></div> <div class="bpadr-field bpadr-field-grow"><label for="adr-content"> </label> <textarea id="adr-content" class="bpadr-textarea"></textarea></div> <footer class="bpadr-footer"><button type="button" class="bpadr-btn-ghost"> </button> <button type="button" data-testid="bp-form-snippets" class="bpadr-btn-ghost"> </button> <button type="submit" class="bpadr-btn-primary"> </button></footer></form> <!>`,1),Au=U(`<div class="bpadr-folder-confirm"><p></p> <p class="bpadr-muted"> </p> <footer class="bpadr-footer"><button type="button" class="bpadr-btn-ghost"> </button> <button type="button" class="bpadr-btn-primary"> </button></footer></div>`),ju=U(`<div class="bpadr-overlay"><div class="bpadr-modal"><header class="bpadr-header"><div class="bpadr-title-row"><h2 class="bpadr-title"><!></h2> <!></div> <div class="bpadr-header-actions"><!> <button class="bpadr-icon-btn" type="button" title="Close">×</button></div></header> <!></div></div>`),Mu=U(`<div class="fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4"><div class="w-full max-w-sm bg-white dark:bg-gray-900 border border-red-200 dark:border-red-700 rounded-xl shadow-2xl p-5 flex flex-col gap-3"><p class="text-sm text-gray-700 dark:text-gray-200"> </p> <p class="text-xs text-gray-500 dark:text-gray-400 italic truncate"> </p> <div class="flex justify-end gap-2 mt-2"><button type="button" data-testid="bp-delete-cancel" class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button type="button" data-testid="bp-delete-confirm" class="text-sm px-4 py-1.5 rounded-lg bg-red-500 hover:bg-red-600 text-white font-semibold transition-colors"> </button></div></div></div>`),Nu=U(`<!> <!>`,1);function Pu(e,t){Ke(t,!0);let n=Wi(t,`onchanged`,3,()=>{}),r=`000_BLUEPRINT`;function i(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toUpperCase().replace(/[^A-Z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`FOLDER`}function a(e){return`/${(e.folder.path||e.folder.name).replace(/^\/+|\/+$/g,``)||e.folder.name}`}let o=P(`closed`),s=P(``),c=P(``),l=P(``),u=P(``),d=P(``),f=P(``),p=P(``),m=P(``),h=P(null),g=P(null),_=P(null),v=P(!1),y=P(null),b=P(null),x=P(!1),S=P(!1),C=P(!1);async function w(e){F(g,e,!0),F(h,null),F(v,!1),F(y,null);let t=i(e.folder.name);if(F(l,t,!0),F(c,e.folder.name,!0),F(u,``),F(d,``),F(f,``),F(m,a(e),!0),F(s,Y(`blueprint.adr.new_title`,{folder:e.folder.name}),!0),F(o,`form`),!(await fetch(`/api/blueprint/blueprint-folder`).then(e=>e.json())).exists){F(p,r),F(o,`folder-confirm`);return}await E(e,t)}async function T(e){return fetch(`/api/documents/${encodeURIComponent(e)}`).then(e=>e.json())}async function E(e,t){let n=await fetch(`/api/blueprint/blueprint-adr?category=${encodeURIComponent(t)}`).then(e=>e.json());if(n.found&&n.doc){F(h,n.doc.id,!0);let e=await T(n.doc.id);F(c,e.title,!0),F(d,e.content,!0),F(f,e.html,!0),F(s,e.title,!0),F(v,!1),F(o,`doc`)}else F(c,e.folder.name,!0),F(u,``),F(o,`form`)}function D(){F(o,`closed`),F(v,!1),F(h,null),F(g,null),F(m,``),F(C,!1)}async function ee(){if(V(h))try{await navigator.clipboard.writeText(decodeURIComponent(V(h))),F(C,!0),setTimeout(()=>F(C,!1),1800)}catch{}}async function O(){await fetch(`/api/blueprint/blueprint-folder`,{method:`POST`}),V(g)&&await E(V(g),i(V(g).folder.name))}async function te(e){if(!V(h))return;await fetch(`/api/documents/${encodeURIComponent(V(h))}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:V(c).trim()||V(g)?.folder.name||Y(`common.untitled`),category:V(l),folder:r,content:e})});let t=await T(V(h));F(s,t.title,!0),F(d,t.content,!0),F(f,t.html,!0)}async function k(e){e.preventDefault();let t={title:V(c).trim()||V(g)?.folder.name||Y(`common.untitled`),category:V(l),folder:r},i=await fetch(`/api/documents/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}).then(e=>e.json());F(h,i.id,!0);let a=await T(i.id);F(s,a.title,!0),F(d,a.content,!0),F(f,a.html,!0),F(v,!1),F(o,`doc`),n()()}async function ne(){F(S,!1),V(h)&&(await fetch(`/api/documents/${encodeURIComponent(V(h))}`,{method:`DELETE`}),D(),n()())}var A={open:w},re=Nu(),ie=R(re),ae=e=>{var t=ju(),n=L(t),i=L(n),a=L(i),g=L(a),w=L(g),T=e=>{var t=Cu(),n=R(t),r=L(n,!0);M(n);var i=z(n,2),a=L(i,!0);M(i),B(e=>{G(r,e),G(a,V(m))},[()=>Y(`blueprint.adr.folder_title`)]),W(e,t)},E=e=>{var t=Ur();B(()=>G(t,V(s))),W(e,t)};K(w,e=>{V(m)?e(T):e(E,-1)}),M(g);var ne=z(g,2),A=e=>{var t=wu(),n=L(t);M(t),B(e=>{J(t,`title`,e),gi(t,1,`bpadr-copy-btn ${V(C)?`copied`:``}`),gi(n,1,`fa-${V(C)?`solid fa-check`:`regular fa-copy`}`)},[()=>Y(`doc.copy_mcp_id`)]),H(`click`,t,ee),W(e,t)};K(ne,e=>{V(h)&&e(A)}),M(a);var re=z(a,2),ie=L(re),ae=e=>{var t=Tu(),n=R(t),r=z(n,2);B((e,t)=>{J(n,`title`,e),J(r,`title`,t)},[()=>Y(`doc.edit`),()=>Y(`doc.delete`)]),H(`click`,n,()=>V(_).enterEdit()),H(`click`,r,()=>F(S,!0)),W(e,t)};K(ie,e=>{V(o)===`doc`&&!V(v)&&e(ae)});var oe=z(ie,2);M(re),M(i);var se=z(i,2),ce=e=>{var t=Ou(),n=R(t),r=L(n);{let e=N(()=>V(h)??``);Vi(Su(r,{get docId(){return V(e)},get content(){return V(d)},get html(){return V(f)},onsave:te,get editing(){return V(v)},set editing(e){F(v,e,!0)},get saveMsg(){return V(y)},set saveMsg(e){F(y,e,!0)}}),e=>F(_,e,!0),()=>V(_))}M(n);var i=z(n,2),a=e=>{var t=Du(),n=L(t),r=e=>{var t=Eu(),n=L(t,!0);M(t),B(()=>{gi(t,1,`text-xs ${V(y).cls??``}`),G(n,V(y).text)}),W(e,t)};K(n,e=>{V(y)&&e(r)});var i=z(n,2),a=L(i,!0);M(i);var o=z(i,2),s=L(o,!0);M(o);var c=z(o,2),l=L(c,!0);M(c),M(t),B((e,t,n)=>{G(a,e),G(s,t),G(l,n)},[()=>Y(`common.cancel`),()=>Y(`doc.snippets_btn`),()=>Y(`common.save`)]),H(`click`,i,()=>V(_).cancelEdit()),H(`click`,o,()=>V(_).openSnippets()),H(`click`,c,()=>V(_).save()),W(e,t)};K(i,e=>{V(v)&&e(a)}),W(e,t)},le=e=>{var t=ku(),n=R(t),i=L(n);Di(i);var a=z(i,2);Di(a),Oi(a,r);var s=z(a,2),d=L(s),f=L(d,!0);M(d);var p=z(d,2);Di(p),M(s);var m=z(s,2),g=L(m),_=L(g,!0);M(g);var v=z(g,2);yn(v),Vi(v,e=>F(b,e),()=>V(b)),M(m);var y=z(m,2),S=L(y),C=L(S,!0);M(S);var w=z(S,2),T=L(w,!0);M(w);var E=z(w,2),ee=L(E,!0);M(E),M(y),M(n),Kl(z(n,2),{get open(){return V(x)},get editor(){return V(b)},mode:`insert`,get content(){return V(u)},onclose:()=>F(x,!1)}),B((e,t,n,r,a)=>{Oi(i,V(l)),G(f,e),G(_,t),G(C,n),G(T,r),G(ee,a)},[()=>Y(`blueprint.adr.title_label`),()=>Y(`blueprint.adr.content_label`),()=>Y(`common.cancel`),()=>Y(`doc.snippets_btn`),()=>Y(`common.save`)]),Nr(`submit`,n,k),Ni(p,()=>V(c),e=>F(c,e)),Ni(v,()=>V(u),e=>F(u,e)),H(`click`,S,()=>{V(h)?F(o,`doc`):D()}),H(`click`,w,()=>F(x,!0)),W(e,t)},ue=e=>{var t=Au(),n=L(t);ai(n,()=>Y(`blueprint.adr.folder_missing`,{name:V(p)}),!0),M(n);var r=z(n,2),i=L(r,!0);M(r);var a=z(r,2),o=L(a),s=L(o,!0);M(o);var c=z(o,2),l=L(c,!0);M(c),M(a),M(t),B((e,t,n)=>{G(i,e),G(s,t),G(l,n)},[()=>Y(`blueprint.adr.folder_create_prompt`),()=>Y(`common.cancel`),()=>Y(`blueprint.adr.create_folder_btn`)]),H(`click`,o,D),H(`click`,c,O),W(e,t)};K(se,e=>{V(o)===`doc`?e(ce):V(o)===`form`?e(le,1):V(o)===`folder-confirm`&&e(ue,2)}),M(n),M(t),H(`click`,t,e=>{e.target===e.currentTarget&&D()}),H(`click`,oe,D),W(e,t)};K(ie,e=>{V(o)!==`closed`&&e(ae)});var oe=z(ie,2),se=e=>{var t=Mu(),n=L(t),r=L(n),i=L(r,!0);M(r);var a=z(r,2),o=L(a,!0);M(a);var c=z(a,2),l=L(c),u=L(l,!0);M(l);var d=z(l,2),f=L(d,!0);M(d),M(c),M(n),M(t),B((e,t,n)=>{G(i,e),G(o,V(s)),G(u,t),G(f,n)},[()=>Y(`doc.confirm_delete`),()=>Y(`common.cancel`),()=>Y(`doc.confirm_delete_btn`)]),H(`click`,t,e=>{e.target===e.currentTarget&&F(S,!1)}),H(`click`,l,()=>F(S,!1)),H(`click`,d,ne),W(e,t)};return K(oe,e=>{V(S)&&e(se)}),W(e,re),qe(A)}Pr([`click`]);var Fu=U(`<span class="breadcrumb-sep">›</span>`),Iu=U(`<span class="breadcrumb-item current"> </span>`),Lu=U(`<button class="breadcrumb-item" type="button"> </button>`),Ru=U(`<!> <!>`,1),zu=U(`<nav class="breadcrumb"></nav>`),Bu=U(`<div class="app-shell"><!> <section class="workspace-shell"><!> <!></section></div> <!>`,1);function Vu(e,t){Ke(t,!0),Gi(async()=>{try{await pa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}});let n=P(I([])),r=P(null),i=P(null),a=P(null),o=P(null);function s(e){l(),V(i).loadPath(e,!0)}async function c(e){F(r,e.folder.path,!0),await xr(),await V(a).open(e.folder.path)}function l(){F(r,null)}async function u(e){await V(i).navigateToFolder(e)}var d=Bu(),f=R(d),p=L(f);{let e=N(()=>Y(`blueprint.subtitle`));$a(p,{title:`Blueprint`,get subtitle(){return V(e)},children:(e,t)=>{var r=zu();q(r,21,()=>V(n),Xr,(e,t,r)=>{var i=Ru(),a=R(i),o=e=>{W(e,Fu())};K(a,e=>{r>0&&e(o)});var c=z(a,2),l=e=>{var n=Iu(),r=L(n,!0);M(n),B(()=>G(r,V(t).name)),W(e,n)},u=e=>{var n=Lu(),r=L(n,!0);M(n),B(()=>G(r,V(t).name)),H(`click`,n,()=>s(V(t).path)),W(e,n)};K(c,e=>{r===V(n).length-1?e(l):e(u,-1)}),W(e,i)}),M(r),W(e,r)},$$slots:{default:!0}})}var m=z(p,2),h=L(m);Vi(To(h,{get activeExplorerPath(){return V(r)},onbreadcrumbchange:e=>F(n,e,!0),onopenexplorer:c,onclosefilerexplorer:l,onopenAdr:e=>V(o).open(e)}),e=>F(i,e,!0),()=>V(i));var g=z(h,2),_=e=>{Vi(Go(e,{onclose:l,onnavigate:u}),e=>F(a,e,!0),()=>V(a))};K(g,e=>{V(r)!==null&&e(_)}),M(m),M(f),Vi(Pu(z(f,2),{onchanged:()=>V(i).loadPath(V(n).at(-1)?.path??``,!1)}),e=>F(o,e,!0),()=>V(o)),W(e,d),qe()}Pr([`click`]);var Hu=164,Uu=64,Wu=132,Gu=78,Ku=6,qu=24,Ju=96,Yu=540,Xu=780,Zu=1/2,Qu=9999,$u=44,ed=255,td=178,nd=Math.PI*.7,rd=Math.PI*1.1,id=Math.PI*1.45,ad=Math.PI*1.75,od=14,sd=260,cd=56,ld=32,ud=[`pointerdown`,`mousedown`,`click`,`dblclick`,`touchstart`,`wheel`],dd=.35,fd=2.2,pd=.0018,md=4,hd=46,gd=4,_d=44,vd=360,yd=300,bd=44,xd=48,Sd=7,Cd=875,wd=450,Td=600*1e3,Ed,Z,Dd,Od,kd,Ad,jd,Md,Nd,Pd,Fd,Id,Ld,Rd,zd,Bd,Vd,Hd,Ud,Wd,Gd,Kd,qd,Jd,Yd,Xd,Zd,Qd,$d=null,ef=null,tf=null,Q,$,nf,rf=!1;function af(){return Ed=document.getElementById(`workspaceCanvas`),Z=Ed.getContext(`2d`),Dd=document.getElementById(`apiStatus`),Od=document.getElementById(`addButton`),kd=document.getElementById(`fitButton`),Ad=document.getElementById(`testNodeButton`),jd=document.getElementById(`loadModelsButton`),Md=document.getElementById(`closePanelButton`),Nd=document.getElementById(`deleteNodeButton`),Pd=document.getElementById(`renameConfirmOverlay`),Fd=document.getElementById(`renameConfirmMessage`),Id=document.getElementById(`cancelRenameButton`),Ld=document.getElementById(`confirmRenameButton`),Rd=document.getElementById(`deleteConfirmOverlay`),zd=document.getElementById(`deleteConfirmMessage`),Bd=document.getElementById(`cancelDeleteButton`),Vd=document.getElementById(`confirmDeleteButton`),Hd=document.getElementById(`agentRunOverlay`),Ud=document.getElementById(`agentRunTitle`),Wd=document.getElementById(`agentRunHint`),Gd=document.getElementById(`agentRunInputField`),Kd=document.getElementById(`agentRunInput`),qd=document.getElementById(`agentRunResult`),Jd=document.getElementById(`cancelAgentRunButton`),Yd=document.getElementById(`executeAgentRunButton`),Xd=document.getElementById(`fallbackPanelHost`),Zd=document.getElementById(`configSurface`),Qd=Zd,$d=null,ef=null,tf=null,Q={name:document.getElementById(`nodeName`),kind:document.getElementById(`nodeKind`),providerIdField:document.getElementById(`providerIdField`),providerId:document.getElementById(`nodeProviderId`),copyProviderId:document.getElementById(`copyProviderIdButton`),endpoint:document.getElementById(`nodeEndpoint`),token:document.getElementById(`nodeToken`),model:document.getElementById(`nodeModel`),providerTypeChat:document.getElementById(`nodeProviderTypeChat`),providerTypeImage:document.getElementById(`nodeProviderTypeImage`),toolModeField:document.getElementById(`toolModeField`),toolModeTools:document.getElementById(`nodeToolModeTools`),toolModeChat:document.getElementById(`nodeToolModeChat`),workspaceField:document.getElementById(`agentWorkspaceField`),workspaceFolder:document.getElementById(`nodeWorkspaceFolder`),timeout:document.getElementById(`nodeTimeout`),description:document.getElementById(`nodeDescription`),typeBadge:document.getElementById(`nodeTypeBadge`),llmFields:document.getElementById(`llmFields`),mcpInventory:document.getElementById(`mcpInventory`),mcpInventoryStatus:document.getElementById(`mcpInventoryStatus`),mcpToolsList:document.getElementById(`mcpToolsList`),mcpPromptsList:document.getElementById(`mcpPromptsList`),agentSection:document.getElementById(`agentSection`),systemPrompt:document.getElementById(`nodeSystemPrompt`),requiresUserInput:document.getElementById(`nodeRequiresUserInput`),userInputDescriptionField:document.getElementById(`agentUserInputDescriptionField`),userInputDescription:document.getElementById(`nodeUserInputDescription`),expectedOutputMarker:document.getElementById(`nodeExpectedOutputMarker`)},$={entities:Tf([wf(`root`,`Living AI Documentation`,`system`,null),wf(`mcp`,`MCP`,`mcp`,`root`)]),selectedId:null,cameraX:0,cameraY:0,zoom:1,isPanning:!1,panStartX:0,panStartY:0,panStartCameraX:0,panStartCameraY:0,didPan:!1,viewAnimationId:null,dpr:window.devicePixelRatio||1,apiMode:`fallback`,lastSaveAt:null,pendingDeleteId:null,panelShiftX:0,saveTimerId:null,panelDirty:!1,isHydrated:!1},rf=!!Ed.requestPaint&&typeof Z.drawElementImage==`function`,rf?($.apiMode=`html-in-canvas`,Dd.textContent=`HTML-in-Canvas active`,Dd.classList.add(`is-live`),Ed.onpaint=Dp):(Xd.appendChild(Zd),Dd.textContent=`DOM fallback`,Dd.classList.add(`is-fallback`)),nf=new ResizeObserver(([e])=>{let t=e.devicePixelContentBoxSize&&e.devicePixelContentBoxSize[0],n=e.contentRect.width,r=e.contentRect.height;$.dpr=t?t.inlineSize/n:window.devicePixelRatio||1,Ed.width=t?t.inlineSize:Math.floor(n*$.dpr),Ed.height=t?t.blockSize:Math.floor(r*$.dpr),Nf(),Lp(!1,!$.cameraX&&!$.cameraY),Ep()}),nf.observe(Ed,{box:`device-pixel-content-box`}),of(),sf(),Od.addEventListener(`click`,()=>{Af()}),kd.addEventListener(`click`,()=>{Nf(),Lp(!0,!0),ff(),Ep()}),Ed.addEventListener(`pointerdown`,e=>{if(e.target!==Ed)return;let t=om(e),n=qp(t),r=[...$.entities].reverse().find(e=>$p(e,n));if(r){r.id!==`root`&&Gf(r.id);return}$.isPanning=!0,$.didPan=!1,$.panStartX=t.x,$.panStartY=t.y,$.panStartCameraX=$.cameraX,$.panStartCameraY=$.cameraY,Ed.classList.add(`is-panning`),Ed.setPointerCapture?.(e.pointerId)}),Ed.addEventListener(`pointermove`,e=>{if(!$.isPanning)return;let t=om(e),n=t.x-$.panStartX,r=t.y-$.panStartY;Math.hypot(n,r)>md&&($.didPan=!0),$.cameraX=$.panStartCameraX+n,$.cameraY=$.panStartCameraY+r,Ep()}),Ed.addEventListener(`pointerup`,e=>{$.isPanning&&($.isPanning=!1,Ed.classList.remove(`is-panning`),Ed.releasePointerCapture?.(e.pointerId),!$.didPan&&$.selectedId?Gf(null):$.didPan&&ff())}),Ed.addEventListener(`pointercancel`,e=>{$.isPanning=!1,Ed.classList.remove(`is-panning`),Ed.releasePointerCapture?.(e.pointerId)}),Ed.addEventListener(`wheel`,e=>{e.target===Ed&&(e.preventDefault(),Kp(om(e),Math.exp(-e.deltaY*pd)),ff())},{passive:!1}),Qd.addEventListener(`submit`,e=>{e.preventDefault(),$f(),$.lastSaveAt=new Date,Nf(),mf(!0),Ep()}),Qd.addEventListener(`input`,()=>{$f(),Nf(),$.panelDirty=!0,Ep()}),Md.addEventListener(`click`,()=>{Gf(null)}),Nd.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let t=$.selectedId,n=t?Sp(t):null;!n||Cp(t)||Kf(n)}),Bd.addEventListener(`click`,qf),Rd.addEventListener(`click`,e=>{e.target===Rd&&qf()}),Vd.addEventListener(`click`,()=>{$.pendingDeleteId&&Jf($.pendingDeleteId),qf()}),Ad.addEventListener(`click`,()=>{if(xp()?.kind===`agent`){rp();return}gp()}),jd.addEventListener(`click`,()=>{hp()}),Q.copyProviderId.addEventListener(`click`,()=>{vp()}),Q.name.addEventListener(`blur`,()=>{let e=xp();if(!e||e.kind!==`agent`)return;let t=Q.name.value.trim();if(!t||!$d||!ef||t===$d)return;let n=Df(t);n!==ef&&(Fd.textContent=`Renommer le dossier "${ef}" en "${n}" ?`,Pd.hidden=!1,Id.focus())}),Id.addEventListener(`click`,()=>{Pd.hidden=!0;let e=xp();e&&$d&&(e.label=$d,Q.name.value=$d,Nf(),Ep())}),Ld.addEventListener(`click`,()=>{Pd.hidden=!0;let e=xp();if(!e||!ef)return;e.config.workspaceFolder=ef,Q.workspaceFolder.value=ef;let t=Q.name.value.trim();t&&($d=t),ef=Df(t),ff()}),Q.model.addEventListener(`change`,()=>{Ad.disabled=!Q.model.value;let e=xp();e&&(e.config.model=Q.model.value)}),Jd.addEventListener(`click`,()=>{ip()}),Yd.addEventListener(`click`,()=>{ap()}),Hd.addEventListener(`click`,e=>{e.target===Hd&&ip()}),lf(),()=>{pf(),nf.disconnect(),$?.saveTimerId&&clearTimeout($.saveTimerId)}}function of(){for(let e of ud)Zd.addEventListener(e,cf),Xd.addEventListener(e,cf)}function sf(){for(let e of ud)Rd.addEventListener(e,cf),Pd.addEventListener(e,cf),Hd.addEventListener(e,cf)}function cf(e){e.stopPropagation()}async function lf(){let e=await Fa();e?.entities?.length&&($.entities=uf(e.entities),$.cameraX=Cf(e.camera?.x,$.cameraX),$.cameraY=Cf(e.camera?.y,$.cameraY),$.zoom=Jp(Cf(e.camera?.zoom,$.zoom),dd,fd),$.lastSaveAt=e.updatedAt?new Date(e.updatedAt):null),$.isHydrated=!0,Nf(),e?.entities?.length||Lp(!1,!0),Qf(),Ep()}function uf(e){let t=e.map(df).filter(e=>!!e),n=t.some(e=>e.id===`root`),r=t.some(e=>e.id===`mcp`),i=[...n?[]:[wf(`root`,`Living AI Documentation`,`system`,null)],...t,...r?[]:[wf(`mcp`,`MCP`,`mcp`,`root`)]],a=new Set(i.map(e=>e.id));return i.map(e=>{let t=e.id===`root`?`system`:e.id===`mcp`?`mcp`:e.kind,n=e.id===`root`?null:e.id===`mcp`?`root`:e.parentId&&a.has(e.parentId)?e.parentId:null;return{...e,kind:t,parentId:n,config:{...wf(e.id,e.label,t,n).config,...e.config}}})}function df(e){if(!vf(e))return null;let t=yf(e.id),n=yf(e.label),r=bf(e.kind);if(!t||!n||!r)return null;let i=e.parentId===null?null:yf(e.parentId),a=vf(e.config)?e.config:{};return{id:t,label:n,kind:r,parentId:i,x:Cf(e.x,0),y:Cf(e.y,0),angle:Cf(e.angle,0),config:{endpoint:yf(a.endpoint)||Ef(t,r),token:yf(a.token),model:yf(a.model),providerType:Sf(a.providerType),toolMode:xf(a.toolMode),timeout:Cf(a.timeout,180),description:yf(a.description)||kf(r),workspaceFolder:yf(a.workspaceFolder)||(r===`agent`?Df(n):``),systemPrompt:yf(a.systemPrompt),requiresUserInput:a.requiresUserInput===!0,userInputDescription:yf(a.userInputDescription),expectedOutputMarker:yf(a.expectedOutputMarker)}}}function ff(){$.isHydrated&&($.saveTimerId&&clearTimeout($.saveTimerId),$.saveTimerId=window.setTimeout(()=>{$.saveTimerId=null,mf(!1)},wd))}function pf(){$.panelDirty&&mf(!1)}async function mf(e=!1){if(!$.isHydrated)return;$.panelDirty=!1,$.saveTimerId&&(clearTimeout($.saveTimerId),$.saveTimerId=null);let t=$.selectedId&&document.activeElement===Q.token&&fp(Q.token.value)?{entityId:$.selectedId,value:Q.token.value,selectionStart:Q.token.selectionStart,selectionEnd:Q.token.selectionEnd}:null,n=await Ia(_f());if(n){if($.entities=uf(n.entities),t&&$.selectedId===t.entityId){let e=xp();e?.kind===`llm`&&(e.config.token=t.value)}$.lastSaveAt=new Date(n.updatedAt),xp()&&!Qd.contains(document.activeElement)&&Qf(),t&&$.selectedId===t.entityId&&(Q.token.value=t.value,Q.token.setSelectionRange(t.selectionStart,t.selectionEnd)),e&&gf(`Workspace saved`)}else e&&gf(`Save failed`)}function hf(e,t){return Ma(e,t)}function gf(e,t=`success`,n,r){return Na(e,t,n,r)}function _f(){return{version:1,updatedAt:new Date().toISOString(),entities:$.entities.map(e=>{let t={...e.config,token:pp(e.config.token)};return{id:e.id,label:e.label,kind:e.kind,parentId:e.parentId,x:e.x,y:e.y,angle:e.angle,config:t}}),camera:{x:$.cameraX,y:$.cameraY,zoom:$.zoom}}}function vf(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yf(e){return typeof e==`string`?e:``}function bf(e){return e===`system`||e===`llm`||e===`agent`||e===`mcp`?e:null}function xf(e){return e===`chat`?`chat`:`tools`}function Sf(e){return e===`image`?`image`:`chat`}function Cf(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function wf(e,t,n,r){return{id:e,label:t,kind:n,parentId:r,x:0,y:0,angle:0,config:{endpoint:Ef(e,n),token:``,model:``,providerType:`chat`,toolMode:`tools`,timeout:180,description:kf(n),workspaceFolder:n===`agent`?Df(t):``,systemPrompt:``,requiresUserInput:!1,userInputDescription:``,expectedOutputMarker:``}}}function Tf(e){return e.map(e=>({...e,config:{...e.config}}))}function Ef(e,t){return t===`llm`?`http://localhost:11434`:t===`mcp`?`http://localhost:4321/mcp`:``}function Df(e){return`AI/WORKSPACE/${Of(e)}`}function Of(e){return e.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`llm_provider`}function kf(e){let t={system:`Owns the documentation workspace, MCP access, providers, and agent topology.`,llm:`Routes model calls and hosts the agents assigned to this provider.`,agent:`Runs focused automation against documentation, source, or quality signals.`,mcp:`Exposes the local Living Documentation MCP consultation panel to agents.`};return t[e]||t.agent}function Af(){let e=xp(),t=e?.kind===`llm`?e:Sp(e?.parentId);if(t?.kind===`llm`&&t.config.providerType!==`image`){Mf(t.id);return}jf()}function jf(){let e=!!$.selectedId,t=wp(`root`).filter(e=>e.kind===`llm`).length+1,n=wf(`provider-${Date.now().toString(36)}`,`LLM Provider ${t}`,`llm`,`root`);$.entities=[...$.entities,n],$.selectedId=n.id,Nf(),Rp(e,!0,!0),Qf(),ff(),Ep()}function Mf(e){let t=!!$.selectedId,n=wp(e).filter(e=>e.kind===`agent`).length+1,r=wf(`agent-${Date.now().toString(36)}`,`Agent ${n}`,`agent`,e);$.entities=[...$.entities,r],$.selectedId=r.id,Nf(),Rp(t,!0,!0),Qf(),ff(),Ep()}function Nf(){let e=Sp(`root`);e.x=0,e.y=0,e.angle=0,Pf(e)}function Pf(e){let t=wp(e.id),n=Bf(t,Wu,ed,{spread:Math.PI*2,includeSubtree:!1}),r=new Map(t.map(e=>[e.id,Rf(e,n)]));for(let n=0;n<=Sd;n+=1)if(Ff(e,t,r),If(),!Lf(t,r))return;Ff(e,t,r),If()}function Ff(e,t,n){let r=Math.max(1,t.length);t.forEach((t,i)=>{let a=-Math.PI/2+i/r*Math.PI*2,o=n.get(t.id)||ed;t.angle=a,t.x=e.x+Math.cos(a)*o,t.y=e.y+Math.sin(a)*o})}function If(){for(let e of $.entities.filter(e=>e.kind===`llm`))zf(e)}function Lf(e,t){let n=!1;for(let r=0;r<e.length;r+=1)for(let i=r+1;i<e.length;i+=1){let a=e[r],o=e[i];am(nm(a),nm(o),bd)&&(t.set(a.id,Math.min(Cd,t.get(a.id)+xd)),t.set(o.id,Math.min(Cd,t.get(o.id)+xd)),n=!0)}return n}function Rf(e,t){if(e.kind!==`llm`)return t;let n=wp(e.id).length;if(n<=gd)return t;let r=(n-gd)*_d,i=Math.max(0,Uf(e)-yd)*.65;return t+Math.min(vd,Math.max(r,i))}function zf(e){let t=wp(e.id);if(!t.length)return;let n=Math.atan2(e.y,e.x),r=Vf(t.length),i=Bf(t,Gu,td,{spread:r,includeSubtree:!1});t.forEach((a,o)=>{let s=Hf(n,r,o,t.length);a.angle=s,a.x=e.x+Math.cos(s)*i,a.y=e.y+Math.sin(s)*i})}function Bf(e,t,n,r={}){if(!e.length)return n;let i=!!r.includeSubtree,a=r.spread||Math.PI*2,o=Math.max(...e.map(e=>i?Uf(e):Wf(e))),s=t+o+hd;if(e.length===1)return Math.max(n,s);let c=o*2+hd,l=a>=Math.PI*2-.001?Math.PI*2/e.length:a/(e.length-1),u=c/(2*Math.sin(l/2));return Math.max(n,s,u)}function Vf(e){return e<=1?0:e<=2?nd:e<=4?rd:e<=7?id:ad}function Hf(e,t,n,r){return r<=1||t===0?e:e-t/2+n/(r-1)*t}function Uf(e){if(e.kind!==`llm`)return Wf(e);let t=wp(e.id);return t.length?Bf(t,Gu,td,{spread:Vf(t.length),includeSubtree:!1})+Math.max(...t.map(e=>Wf(e))):Gu}function Wf(e){if(e.kind===`system`)return Wu;if(e.kind===`llm`)return Gu;let{width:t,height:n}=tm(e);return Math.hypot(t/2,n/2)}function Gf(e){e!==$.selectedId&&pf();let t=!!$.selectedId;$.selectedId=e;let n=e?Sp(e):null;$d=n?.kind===`agent`?n.label:null,ef=n?.kind===`agent`?n.config.workspaceFolder||Df(n.label):null,Nf(),Rp(t,!!e,!0),Qf(),Ep()}function Kf(e){let t=Tp(e.id),n=wp(e.id).length,r=t.length?` This node has ${n} direct child${n===1?``:`ren`} and ${t.length} total descendant${t.length===1?``:`s`}; they will also be deleted.`:` This node has no children.`;$.pendingDeleteId=e.id,zd.textContent=`You are about to delete "${e.label}".${r} This action cannot be undone.`,Rd.hidden=!1,Vd.focus()}function qf(){$.pendingDeleteId=null,Rd.hidden=!0}function Jf(e){let t=Sp(e);if(!t||Cp(e))return;let n=t.parentId||`root`,r=!!$.selectedId,i=new Set([e,...Tp(e)]);$.entities=$.entities.filter(e=>!i.has(e.id)),$.selectedId=Sp(n)?n:null,Nf(),Rp(r,!!$.selectedId,!0),Qf(),ff(),Ep()}var Yf=0;async function Xf(e){let t=++Yf,n=e.config.endpoint.trim(),r=Q.mcpInventoryStatus;if(Q.mcpToolsList.replaceChildren(),Q.mcpPromptsList.replaceChildren(),!n){r.hidden=!1,r.textContent=`Set an endpoint to load the MCP tools and prompts.`;return}r.hidden=!1,r.textContent=`Loading MCP tools and prompts…`;let i=await Ra({endpoint:n});if(t===Yf){if(!i.ok){r.hidden=!1,r.textContent=i.error?`Failed to load MCP inventory: ${i.error}`:`Failed to load MCP inventory.`;return}r.hidden=!0,Zf(Q.mcpToolsList,i.tools??[],`No tools exposed.`),Zf(Q.mcpPromptsList,i.prompts??[],`No prompts exposed.`)}}function Zf(e,t,n){if(e.replaceChildren(),t.length===0){let t=document.createElement(`li`);t.className=`inventory-empty`,t.textContent=n,e.appendChild(t);return}for(let n of t){let t=document.createElement(`li`);t.textContent=n,e.appendChild(t)}}function Qf(){let e=xp(),t=!!e;if(Zd.hidden=!t,Xd.hidden=!t||rf,!e){Od.title=`Add LLM provider`,Ad.textContent=`Test`,Ad.hidden=!0,Ad.disabled=!0;return}Q.name.value=e.label,Q.kind.value=e.kind,Q.providerId.value=e.kind===`llm`?e.id:``,Q.endpoint.value=e.config.endpoint,Q.token.value=e.config.token,np(e.config.model),Q.providerTypeChat.checked=e.config.providerType!==`image`,Q.providerTypeImage.checked=e.config.providerType===`image`,Q.toolModeTools.checked=e.config.toolMode!==`chat`,Q.toolModeChat.checked=e.config.toolMode===`chat`,Q.workspaceFolder.value=e.config.workspaceFolder,Q.workspaceField.hidden=e.kind!==`agent`,Q.timeout.value=String(e.config.timeout),Q.description.value=e.config.description,Q.typeBadge.textContent=bp(e),Q.kind.disabled=!0,Q.llmFields.hidden=e.kind===`mcp`||e.kind===`agent`,tp(e),Q.mcpInventory.hidden=e.kind!==`mcp`,e.kind===`mcp`?Xf(e):Yf+=1,Q.agentSection.hidden=e.kind!==`agent`,Q.systemPrompt.value=e.config.systemPrompt,Q.requiresUserInput.checked=e.config.requiresUserInput,ep(),Q.userInputDescription.value=e.config.userInputDescription,Q.expectedOutputMarker.value=e.config.expectedOutputMarker,Nd.hidden=Cp(e.id),Ad.textContent=`Test`,Ad.hidden=e.kind!==`llm`&&e.kind!==`agent`,Ad.disabled=e.kind===`llm`?!e.config.model:e.kind!==`agent`;let n=e.kind===`llm`?e:Sp(e.parentId);Od.title=n?.kind===`llm`&&n.config.providerType!==`image`?`Add agent`:`Add LLM provider`}function $f(){let e=xp();if(e&&(e.label=Q.name.value.trim()||`Untitled node`,e.kind=Q.kind.value,e.config.endpoint=Q.endpoint.value,e.config.token=Q.token.value,e.config.model=Q.model.value,e.config.providerType=Q.providerTypeImage.checked?`image`:`chat`,e.config.toolMode=Q.toolModeChat.checked?`chat`:`tools`,e.config.timeout=Number(Q.timeout.value||30),e.config.description=Q.description.value,e.config.systemPrompt=Q.systemPrompt.value,e.config.requiresUserInput=Q.requiresUserInput.checked,e.config.userInputDescription=Q.userInputDescription.value,e.config.expectedOutputMarker=Q.expectedOutputMarker.value,ep(),tp(e),Q.typeBadge.textContent=bp(e),e.kind===`llm`))for(let t of $.entities)t.parentId===e.id&&t.kind===`agent`&&(t.config.model=e.config.model,t.config.timeout=e.config.timeout)}function ep(){let e=xp()?.kind===`agent`&&Q.requiresUserInput.checked;Q.userInputDescriptionField.hidden=!e,Q.userInputDescription.required=e}function tp(e){let t=e.kind===`llm`,n=e.config.providerType===`image`;Q.providerIdField.hidden=!t,Q.toolModeField.hidden=!t||n,jd.title=n?`Load image models from endpoint`:`Load chat models from endpoint`,Ad.title=n?`Test image provider configuration`:`Test chat provider configuration`}function np(e){let t=Array.from(Q.model.options).map(e=>e.value);if(e&&!t.includes(e)){Q.model.innerHTML=``;let t=document.createElement(`option`);t.value=e,t.textContent=e,Q.model.appendChild(t)}Q.model.value=e||(t[0]??``)}function rp(){let e=xp();if(!e||e.kind!==`agent`)return;$f();let t=Sp(e.parentId??``);if(!t||t.kind!==`llm`){gf(`No parent LLM found for this agent.`,`error`);return}if(!t.config.model){gf(`Parent LLM has no model selected.`,`error`);return}if(!e.config.systemPrompt.trim()){gf(`Write a system prompt first.`,`error`);return}if(e.config.requiresUserInput&&!e.config.userInputDescription.trim()){gf(`Describe the required user input first.`,`error`);return}tf=e.id,Ud.textContent=`Test ${e.label}`,Wd.textContent=e.config.requiresUserInput?e.config.userInputDescription:`Run this agent with its configured system prompt.`,Gd.hidden=!e.config.requiresUserInput,Kd.required=e.config.requiresUserInput,Kd.value=``,qd.hidden=!0,qd.textContent=``,Yd.disabled=!1,Yd.textContent=`Run`,Hd.hidden=!1,e.config.requiresUserInput?window.setTimeout(()=>Kd.focus(),0):window.setTimeout(()=>Yd.focus(),0)}function ip(){Hd.hidden=!0,tf=null}async function ap(){if(Kd.required&&!Kd.value.trim()){Kd.reportValidity();return}let e=tf?Sp(tf):null;if(!e||e.kind!==`agent`){up(`error`,`The selected agent is no longer available.`);return}let t=Sp(e.parentId??``);if(!t||t.kind!==`llm`){up(`error`,`No parent LLM found for this agent.`);return}Yd.disabled=!0,Yd.textContent=`Running…`;let n=hf(`Running agent…`);sp();let r=$.entities.find(e=>e.kind===`mcp`),i=!1,a=await za({providerId:t.id,endpoint:t.config.endpoint,model:t.config.model,systemPrompt:e.config.systemPrompt,userInput:Kd.value.trim()||void 0,timeout:t.config.timeout,mcpEndpoint:t.config.toolMode===`chat`?void 0:r?.config.endpoint||void 0,toolMode:t.config.toolMode,expectedOutputMarker:e.config.expectedOutputMarker||void 0},e=>{e.type===`error`&&(i=!0),e.type!==`final`&&e.type!==`error`&&hf(op(e),n),cp(e)});Yd.disabled=!1,Yd.textContent=`Run`,a.ok&&a.content?(lp(a.content),gf(`Agent responded. Result saved in AI/WORKSPACE.`,`success`,Td,n)):(i||cp({type:`error`,message:a.error??`Agent failed.`}),qd.dataset.state=`error`,gf(a.error??`Agent failed.`,`error`,Td,n))}function op(e){return e.type===`tool_call`&&e.toolName?`Agent tool call: ${e.toolName}`:e.type===`tool_result`&&e.toolName?`Agent tool result: ${e.toolName}`:`Agent: ${e.message}`}function sp(){qd.hidden=!1,qd.dataset.state=`loading`,qd.textContent=``,cp({type:`status`,message:`Preparing agent request`})}function cp(e){qd.hidden=!1,e.type===`error`&&(qd.dataset.state=`error`);let t=document.createElement(`div`);t.className=`agent-run-event agent-run-event-${e.type.replace(`_`,`-`)}`;let n=document.createElement(`span`);n.className=`agent-run-event-dot`,n.setAttribute(`aria-hidden`,`true`);let r=document.createElement(`div`);r.className=`agent-run-event-body`;let i=document.createElement(`p`);i.className=`agent-run-event-title`,i.textContent=e.message,r.appendChild(i);let a=[];if(e.turn&&a.push(`Turn ${e.turn}`),e.toolName&&a.push(e.toolName),e.detail&&a.push(e.detail),a.length){let e=document.createElement(`p`);e.className=`agent-run-event-meta`,e.textContent=a.join(` · `),r.appendChild(e)}t.append(n,r),qd.appendChild(t),qd.scrollTop=qd.scrollHeight}function lp(e){qd.dataset.state=`success`;let t=document.createElement(`section`);t.className=`agent-run-final`;let n=document.createElement(`h3`);n.textContent=`Final response`;let r=document.createElement(`pre`);r.textContent=e,t.append(n,r),qd.appendChild(t),qd.scrollTop=qd.scrollHeight}function up(e,t){qd.hidden=!1,qd.dataset.state=e,qd.textContent=t}var dp=/^(?:env:[A-Za-z_][A-Za-z0-9_]*|\$\{[A-Za-z_][A-Za-z0-9_]*\})$/;function fp(e){let t=e.trim();return t!==``&&!dp.test(t)}function pp(e){let t=e.trim();return fp(t)?``:t}var mp=`API token must reference an environment variable, e.g. env:LLM_API_KEY`;async function hp(){let e=xp();if(!e||e.kind!==`llm`)return;$f();let t=e.config.endpoint;if(!t){gf(`Set an endpoint first.`);return}if(fp(e.config.token)){gf(mp);return}jd.classList.add(`loading`),jd.disabled=!0,Q.model.disabled=!0;let n=await La({endpoint:t,token:e.config.token,providerType:e.config.providerType});if(jd.classList.remove(`loading`),jd.disabled=!1,Q.model.disabled=!1,!n.ok||!n.models?.length){gf(n.error??`No models found.`);return}let r=Q.model.value;Q.model.innerHTML=``;for(let e of n.models){let t=document.createElement(`option`);t.value=e,t.textContent=e,Q.model.appendChild(t)}Q.model.value=n.models.includes(r)?r:n.models[0],e.config.model=Q.model.value,Ad.disabled=!Q.model.value,gf(`${n.models.length} model${n.models.length===1?``:`s`} loaded.`),Ep()}async function gp(){let e=xp();if(!e||e.kind!==`llm`)return;if($f(),fp(e.config.token)){gf(mp);return}Ad.disabled=!0,hf(`Testing ${e.config.model}…`),Ep();let t=e.config.providerType===`image`?await _p(e):await Va({endpoint:e.config.endpoint,token:e.config.token,model:e.config.model,timeout:e.config.timeout});Ad.disabled=!1,t.ok?gf(t.detail??`Connection OK`,`success`):gf(t.error||`Connection failed (${t.status||`no status`})`,`error`),Ep()}async function _p(e){let t=await La({endpoint:e.config.endpoint,token:e.config.token,providerType:`image`});if(!t.ok)return{ok:!1,error:t.error??`Image provider test failed`};let n=e.config.model.trim();return n&&t.models?.length&&!t.models.includes(n)?{ok:!1,error:`Image models loaded, but "${n}" was not found.`}:{ok:!0,detail:`${t.models?.length??0} image model${t.models?.length===1?``:`s`} available`}}async function vp(){let e=xp();if(!(!e||e.kind!==`llm`))try{await navigator.clipboard.writeText(e.id),gf(`Provider ID copied`,`success`)}catch{Q.providerId.select(),gf(`Provider ID selected`,`success`)}}function yp(e){return{system:`System`,llm:`LLM provider`,agent:`Agent`,mcp:`MCP`}[e]||`Node`}function bp(e){return e.kind===`llm`&&e.config.providerType===`image`?`Image provider`:yp(e.kind)}function xp(){return $.selectedId?Sp($.selectedId):null}function Sp(e){return $.entities.find(t=>t.id===e)}function Cp(e){return e===`root`||e===`mcp`}function wp(e){return $.entities.filter(t=>t.parentId===e)}function Tp(e){let t=[];for(let n of wp(e))t.push(n.id,...Tp(n.id));return t}function Ep(){rf?Ed.requestPaint():requestAnimationFrame(Dp)}function Dp(){let e=Ed.width/$.dpr,t=Ed.height/$.dpr;Z.reset(),Z.setTransform($.dpr,0,0,$.dpr,0,0),Z.clearRect(0,0,e,t),Z.save(),Z.translate($.cameraX,$.cameraY),Z.scale($.zoom,$.zoom),Op(e,t),kp(),Z.restore(),rf&&Ip(e,t)}function Op(e,t){Z.save(),Z.lineWidth=1/$.zoom;let n=qp({x:0,y:0}),r=qp({x:e,y:t}),i=Math.floor(n.x/qu)*qu,a=Math.ceil(r.x/qu)*qu,o=Math.floor(n.y/qu)*qu,s=Math.ceil(r.y/qu)*qu;for(let e=i;e<=a;e+=qu)Z.strokeStyle=e%Ju===0?`#d7dce5`:`#edf0f4`,um(e,o,e,s);for(let e=o;e<=s;e+=qu)Z.strokeStyle=e%Ju===0?`#d7dce5`:`#edf0f4`,um(i,e,a,e);Z.restore()}function kp(){Ap();for(let e of $.entities)jp(e)}function Ap(){Z.save(),Z.lineWidth=2/$.zoom;for(let e of $.entities){let t=Sp(e.parentId);if(!t)continue;let n=Math.atan2(e.y-t.y,e.x-t.x),r=Yp(t,n),i=Yp(e,n+Math.PI);Z.strokeStyle=Pp(e).connection,Z.beginPath(),Z.moveTo(r.x,r.y),Z.lineTo(i.x,i.y),Z.stroke()}Z.restore()}function jp(e){if(e.kind===`system`||e.kind===`llm`){Mp(e);return}Np(e)}function Mp(e){let t=e.id===$.selectedId,n=Pp(e),r=e.kind===`system`?Wu:Gu,i=wp(e.id),a=Math.max(Ku,i.length),o=sm(e.x,e.y,r,a);Z.save(),Z.beginPath(),o.forEach((e,t)=>{t===0?Z.moveTo(e.x,e.y):Z.lineTo(e.x,e.y)}),Z.closePath(),Z.fillStyle=t?n.selectedFill:n.fill,Z.strokeStyle=t?n.selectedStroke:n.stroke,Z.lineWidth=(t?3:2)/$.zoom,Z.shadowColor=n.shadow,Z.shadowBlur=e.kind===`system`?20:14,Z.shadowOffsetY=e.kind===`system`?8:5,Z.fill(),Z.shadowColor=`transparent`,Z.stroke(),Z.fillStyle=t?n.selectedText:n.text,Z.textAlign=`center`,Z.textBaseline=`middle`,Z.font=e.kind===`system`?`800 21px Inter, system-ui, sans-serif`:`800 16px Inter, system-ui, sans-serif`,lm(e.label,e.x,e.y-8,r*1.32,e.kind===`system`?26:20),Fp(e,t,r),Z.restore()}function Np(e){let t=e.id===$.selectedId,n=Pp(e),r=e.kind===`mcp`?116:Hu,i=e.kind===`mcp`?58:Uu;Z.save(),cm(e.x-r/2,e.y-i/2,r,i,20),Z.fillStyle=t?n.selectedFill:n.fill,Z.strokeStyle=t?n.selectedStroke:n.stroke,Z.lineWidth=(t?3:2)/$.zoom,Z.shadowColor=n.shadow,Z.shadowBlur=10,Z.shadowOffsetY=4,Z.fill(),Z.shadowColor=`transparent`,Z.stroke(),Z.fillStyle=t?n.selectedText:n.text,Z.font=`760 15px Inter, system-ui, sans-serif`,Z.textAlign=`center`,Z.textBaseline=`middle`,lm(e.label,e.x,e.y,r*.78,18),Fp(e,t,Math.max(r,i)/2),Z.restore()}function Pp(e){return e.kind===`system`?{fill:`#111827`,stroke:`#111827`,selectedFill:`#111827`,selectedStroke:`#111827`,text:`#ffffff`,selectedText:`#ffffff`,shadow:`rgb(17 24 39 / 18%)`,connection:`#475569`}:e.kind===`llm`&&e.config.providerType===`image`?{fill:`#facc15`,stroke:`#ca8a04`,selectedFill:`#eab308`,selectedStroke:`#a16207`,text:`#111827`,selectedText:`#111827`,shadow:`rgb(250 204 21 / 22%)`,connection:`#ca8a04`}:e.kind===`llm`?{fill:`#f97316`,stroke:`#ea580c`,selectedFill:`#fb923c`,selectedStroke:`#c2410c`,text:`#431407`,selectedText:`#431407`,shadow:`rgb(249 115 22 / 20%)`,connection:`#ea580c`}:e.kind===`mcp`?{fill:`#64748b`,stroke:`#475569`,selectedFill:`#475569`,selectedStroke:`#334155`,text:`#ffffff`,selectedText:`#ffffff`,shadow:`rgb(100 116 139 / 18%)`,connection:`#64748b`}:e.kind===`agent`?{fill:`#fdba74`,stroke:`#f97316`,selectedFill:`#fb923c`,selectedStroke:`#ea580c`,text:`#111827`,selectedText:`#111827`,shadow:`rgb(249 115 22 / 18%)`,connection:`#f97316`}:{fill:`#ffffff`,stroke:`#0f172a`,selectedFill:`#111827`,selectedStroke:`#0f172a`,text:`#111827`,selectedText:`#ffffff`,shadow:`rgb(15 23 42 / 8%)`,connection:`#111827`}}function Fp(e,t,n){t&&(Z.beginPath(),Z.arc(e.x+n*.62,e.y-n*.66,5,0,Math.PI*2),Z.fillStyle=`#34d399`,Z.fill())}function Ip(e,t){if(!xp())return;let n=em(e),r=Math.min(Qu,t-118),i=e-n-24,a=Math.max(24,(t-r)/2);try{let e=Z.drawElementImage(Zd,i,a,n,r);Zd.style.transform=e.toString()}catch{Dd.textContent=`Waiting for HTML snapshot`}}function Lp(e,t){let n=Ed.clientWidth,r=Ed.clientHeight,i=xp()?em(n)+$u:0,a=Math.max(360,n-i),o=Up(),s=Wp(o,a,r),c=t?s:Math.min($.zoom,s),l=(o.minX+o.maxX)/2,u=(o.minY+o.maxY)/2,d=a*.5-l*c,f=r*.5-u*c;if(!e||!$.cameraX||!$.cameraY){Gp(),$.cameraX=d,$.cameraY=f,$.zoom=c,$.panelShiftX=i;return}$.panelShiftX=i,Hp(d,f,c)}function Rp(e,t,n){if(t){if(e){let e=zp();$.panelShiftX+=Math.max(0,-e),Vp(e,n)}else{let e=xp();if(e){let t=em(Ed.clientWidth)+$u,n=(Ed.clientWidth-t)/2-e.x*$.zoom,r=n-$.cameraX;$.panelShiftX=-r,Hp(n,$.cameraY,$.zoom)}}return}if(!e)return;let r=$.panelShiftX;$.panelShiftX=0,Vp(r,n)}function zp(){let e=xp();if(!e)return 0;let t=Ed.clientWidth-em(Ed.clientWidth)-24-ld,n=Bp(e);return n.right<=t?0:t-n.right}function Bp(e){let t=rm(e);return{left:t.left*$.zoom+$.cameraX,top:t.top*$.zoom+$.cameraY,right:t.right*$.zoom+$.cameraX,bottom:t.bottom*$.zoom+$.cameraY}}function Vp(e,t){if(Gp(),!e)return;let n=$.cameraX+e;if(!t){$.cameraX=n;return}Hp(n,$.cameraY,$.zoom)}function Hp(e,t,n){Gp();let r=$.cameraX,i=$.cameraY,a=$.zoom,o=performance.now();function s(c){let l=Math.min(1,(c-o)/sd),u=1-(1-l)**3;$.cameraX=r+(e-r)*u,$.cameraY=i+(t-i)*u,$.zoom=a+(n-a)*u,Nf(),Ep(),l<1?$.viewAnimationId=requestAnimationFrame(s):$.viewAnimationId=null}$.viewAnimationId=requestAnimationFrame(s)}function Up(){return $.entities.reduce((e,t)=>{let n=Wf(t);return{minX:Math.min(e.minX,t.x-n),minY:Math.min(e.minY,t.y-n),maxX:Math.max(e.maxX,t.x+n),maxY:Math.max(e.maxY,t.y+n)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0})}function Wp(e,t,n){let r=e.maxX-e.minX,i=e.maxY-e.minY;if(!Number.isFinite(r)||!Number.isFinite(i)||r<=0||i<=0)return 1;let a=Math.max(1,t-cd*2),o=Math.max(1,n-cd*2);return Jp(Math.min(1,a/r,o/i),dd,1)}function Gp(){$.viewAnimationId&&(cancelAnimationFrame($.viewAnimationId),$.viewAnimationId=null)}function Kp(e,t){Gp();let n=qp(e);$.zoom=Jp($.zoom*t,dd,fd),$.cameraX=e.x-n.x*$.zoom,$.cameraY=e.y-n.y*$.zoom,Ep()}function qp(e){return{x:(e.x-$.cameraX)/$.zoom,y:(e.y-$.cameraY)/$.zoom}}function Jp(e,t,n){return Math.min(n,Math.max(t,e))}function Yp(e,t){if(e.kind!==`system`&&e.kind!==`llm`)return Qp(e,t);let n=e.kind===`system`?Wu:Gu,r=wp(e.id);return Xp(e,n,Math.max(Ku,r.length),t)||{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function Xp(e,t,n,r){let i={x:Math.cos(r),y:Math.sin(r)},a=sm(e.x,e.y,t,n),o=null;for(let t=0;t<a.length;t+=1){let n=a[t],r=a[(t+1)%a.length],s={x:r.x-n.x,y:r.y-n.y},c={x:n.x-e.x,y:n.y-e.y},l=Zp(i,s);if(Math.abs(l)<1e-4)continue;let u=Zp(c,s)/l,d=Zp(c,i)/l;if(u>=0&&d>=0&&d<=1){let t={x:e.x+i.x*u,y:e.y+i.y*u};(!o||u<o.rayDistance)&&(o={...t,rayDistance:u})}}return o?{x:o.x,y:o.y}:null}function Zp(e,t){return e.x*t.y-e.y*t.x}function Qp(e,t){let n=tm(e),r=n.width/2,i=n.height/2,a=Math.cos(t),o=Math.sin(t),s=Math.min(Math.abs(r/(a||2**-52)),Math.abs(i/(o||2**-52)));return{x:e.x+a*s,y:e.y+o*s}}function $p(e,t){if(e.kind===`system`||e.kind===`llm`){let n=e.kind===`system`?Wu:Gu;return Math.hypot(t.x-e.x,t.y-e.y)<=n+od}let{width:n,height:r}=tm(e);return Math.abs(t.x-e.x)<=n/2+od&&Math.abs(t.y-e.y)<=r/2+od}function em(e){return Math.min(Xu,Math.max(Yu,Math.floor(e*Zu)))}function tm(e){return e.kind===`mcp`?{width:116,height:58}:{width:Hu,height:Uu}}function nm(e){return[e,...Tp(e.id).map(Sp)].filter(Boolean).map(rm).reduce(im)}function rm(e){if(e.kind===`system`||e.kind===`llm`){let t=e.kind===`system`?Wu:Gu;return{left:e.x-t,top:e.y-t,right:e.x+t,bottom:e.y+t}}let{width:t,height:n}=tm(e);return{left:e.x-t/2,top:e.y-n/2,right:e.x+t/2,bottom:e.y+n/2}}function im(e,t){return{left:Math.min(e.left,t.left),top:Math.min(e.top,t.top),right:Math.max(e.right,t.right),bottom:Math.max(e.bottom,t.bottom)}}function am(e,t,n){return!(e.right+n<t.left||e.left-n>t.right||e.bottom+n<t.top||e.top-n>t.bottom)}function om(e){let t=Ed.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function sm(e,t,n,r){return Array.from({length:r},(i,a)=>{let o=-Math.PI/2+a/r*Math.PI*2;return{x:e+Math.cos(o)*n,y:t+Math.sin(o)*n}})}function cm(e,t,n,r,i){let a=e+n,o=t+r;Z.beginPath(),Z.moveTo(e+i,t),Z.lineTo(a-i,t),Z.quadraticCurveTo(a,t,a,t+i),Z.lineTo(a,o-i),Z.quadraticCurveTo(a,o,a-i,o),Z.lineTo(e+i,o),Z.quadraticCurveTo(e,o,e,o-i),Z.lineTo(e,t+i),Z.quadraticCurveTo(e,t,e+i,t),Z.closePath()}function lm(e,t,n,r,i){let a=e.split(/\s+/),o=[],s=``;for(let e of a){let t=s?`${s} ${e}`:e;Z.measureText(t).width>r&&s?(o.push(s),s=e):s=t}o.push(s);let c=n-(o.length-1)*i/2;o.forEach((e,n)=>{Z.fillText(e,t,c+n*i)})}function um(e,t,n,r){Z.beginPath(),Z.moveTo(e,t),Z.lineTo(n,r),Z.stroke()}var dm=U(`<div class="status-row"><span id="apiStatus"></span></div>`),fm=U('<div class="app-shell"><!> <section class="workspace-shell" aria-label="Configuration graph workspace"><nav class="rail" aria-label="Workspace tools"><button id="addButton" class="tool-button primary" type="button" title="Add node">+</button> <button id="fitButton" class="tool-button" type="button" title="Fit view">⌖</button></nav> <canvas id="workspaceCanvas" class="workspace-canvas" layoutsubtree=""><form id="configSurface" class="config-surface" autocomplete="off"><div class="panel-kicker"><span id="nodeTypeBadge">Provider</span> <button id="closePanelButton" class="icon-button close" type="button" title="Close panel">×</button></div> <div class="panel-title-row"><label class="eyebrow" for="nodeName">Node name</label> <input id="nodeName" name="nodeName" class="title-input" type="text"/></div> <div class="form-grid"><label class="field"><span>Kind</span> <select id="nodeKind" name="nodeKind"><option>System</option><option>LLM provider</option><option>Agent</option><option>MCP</option></select></label> <div id="llmFields" class="contents"><div id="providerIdField" class="field wide"><span>Provider ID</span> <div class="model-select-wrap"><input id="nodeProviderId" name="nodeProviderId" type="text" readonly=""/> <button id="copyProviderIdButton" class="icon-button" type="button" title="Copy provider ID">⧉</button></div> <small class="field-note">Technical node id. Use it when a tool or agent workflow needs to reference this provider, for example as <code>imageProviderId</code> with <code>generate_image</code>.</small></div> <label class="field wide"><span>Endpoint</span> <input id="nodeEndpoint" name="nodeEndpoint" type="url" placeholder="http://localhost:11434"/></label> <label class="field wide"><span>API token</span> <input id="nodeToken" name="nodeToken" type="text" autocomplete="off" spellcheck="false" placeholder="env:LLM_API_KEY"/> <small class="field-note">Reference an environment variable only — <code>env:VAR_NAME</code> (or <code>{VAR_NAME}</code>). The secret is read from the server environment at request time; literal tokens are not stored (the workspace file is tracked by git).</small></label> <div class="field wide model-field-row"><span>Model</span> <div class="model-select-wrap"><select id="nodeModel" name="nodeModel"><option disabled="" selected="">— click ↻ to load models —</option></select> <button id="loadModelsButton" class="icon-button" type="button" title="Load models from endpoint">↻</button></div></div> <fieldset class="field wide tool-mode-field"><legend>Provider type</legend> <label class="radio-card"><input id="nodeProviderTypeChat" name="nodeProviderType" type="radio" value="chat"/> <span><strong>Chat completion</strong> <small>Uses OpenAI-compatible <code>/chat/completions</code>.</small></span></label> <label class="radio-card"><input id="nodeProviderTypeImage" name="nodeProviderType" type="radio" value="image"/> <span><strong>Image generation</strong> <small>Used by <code>generate_image</code> with the provider id above.</small></span></label></fieldset> <fieldset id="toolModeField" class="field wide tool-mode-field"><legend>Tool calling</legend> <label class="radio-card"><input id="nodeToolModeTools" name="nodeToolMode" type="radio" value="tools"/> <span><strong>Allow MCP tools</strong> <small>Agents can send OpenAI-compatible <code>tools</code> payloads.</small></span></label> <label class="radio-card"><input id="nodeToolModeChat" name="nodeToolMode" type="radio" value="chat"/> <span><strong>Chat only</strong> <small>Agents never send tools, even when an MCP endpoint exists.</small></span></label></fieldset> <label class="field"><span>Timeout</span> <input id="nodeTimeout" name="nodeTimeout" type="number" min="1" max="600" step="1"/></label></div> <label class="field wide"><span>Description</span> <textarea id="nodeDescription" name="nodeDescription" rows="3"></textarea></label></div> <section id="agentSection" class="agent-section" hidden=""><label id="agentWorkspaceField" class="field wide"><span>Workspace folder</span> <input id="nodeWorkspaceFolder" name="nodeWorkspaceFolder" type="text" readonly=""/></label> <label class="field wide"><span>System prompt</span> <textarea id="nodeSystemPrompt" name="nodeSystemPrompt" rows="5" placeholder="You are a helpful assistant…"></textarea></label> <label class="field wide checkbox-field"><input id="nodeRequiresUserInput" name="nodeRequiresUserInput" type="checkbox"/> <span>Require a user input</span></label> <label id="agentUserInputDescriptionField" class="field wide" hidden=""><span>Describe User input</span> <textarea id="nodeUserInputDescription" name="nodeUserInputDescription" rows="3" placeholder="Describe exactly what the user must provide before running this agent."></textarea></label> <label class="field wide"><span>Required output marker</span> <input id="nodeExpectedOutputMarker" name="nodeExpectedOutputMarker" type="text" placeholder="Optional, e.g. ```mermaid"/></label></section> <section id="mcpInventory" class="mcp-inventory" hidden=""><div class="inventory-header"><span>MCP consultation surface</span> <strong>Streamable HTTP</strong></div> <p id="mcpInventoryStatus" class="inventory-status" hidden=""></p> <div class="inventory-grid"><article><h2>Tools</h2> <ul id="mcpToolsList"></ul></article> <article><h2>Prompts</h2> <ul id="mcpPromptsList"></ul></article></div></section> <footer class="panel-actions"><div class="panel-actions-left"><button id="testNodeButton" class="secondary-button" type="button">Test</button></div> <div class="panel-actions-right"><button id="deleteNodeButton" class="danger-button" type="button">Delete</button></div></footer></form></canvas> <div id="fallbackPanelHost" class="fallback-panel-host" hidden=""></div></section> <div id="deleteConfirmOverlay" class="confirm-overlay" hidden=""><section class="confirm-dialog" role="dialog" aria-modal="true" aria-labelledby="deleteConfirmTitle"><div><p class="confirm-kicker">Destructive change</p> <h2 id="deleteConfirmTitle">Delete node?</h2> <p id="deleteConfirmMessage" class="confirm-message"></p></div> <footer class="confirm-actions"><button id="cancelDeleteButton" class="secondary-button" type="button">Cancel</button> <button id="confirmDeleteButton" class="danger-button" type="button">Delete</button></footer></section></div> <div id="renameConfirmOverlay" class="confirm-overlay" hidden=""><section class="confirm-dialog" role="dialog" aria-modal="true" aria-labelledby="renameConfirmTitle"><div><p class="confirm-kicker">Renommage de dossier</p> <h2 id="renameConfirmTitle">Renommer le dossier ?</h2> <p id="renameConfirmMessage" class="confirm-message"></p></div> <footer class="confirm-actions"><button id="cancelRenameButton" class="secondary-button" type="button">Annuler</button> <button id="confirmRenameButton" class="primary-button" type="button">Renommer</button></footer></section></div> <div id="agentRunOverlay" class="confirm-overlay" hidden=""><section class="agent-run-dialog" role="dialog" aria-modal="true" aria-labelledby="agentRunTitle"><div><p class="confirm-kicker">Agent test</p> <h2 id="agentRunTitle">Run agent</h2> <p id="agentRunHint" class="confirm-message"></p></div> <label id="agentRunInputField" class="field wide agent-run-input-field"><span>User input</span> <textarea id="agentRunInput" name="agentRunInput" rows="6" placeholder="Document ID, question, or any input for the agent…"></textarea></label> <div id="agentRunResult" class="agent-run-result" hidden=""></div> <footer class="confirm-actions"><button id="cancelAgentRunButton" class="secondary-button" type="button">Close</button> <button id="executeAgentRunButton" class="primary-button" type="button">Run</button></footer></section></div></div>');function pm(e,t){Ke(t,!0),Gi(async()=>{try{await pa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}return af()});var n=fm(),r=L(n);$a(r,{title:`Living AI Documentation`,subtitle:`Graph-native configuration workspace`,children:(e,t)=>{var n=dm(),r=L(n);gi(r,1,`status-pill `),r.textContent=`Detecting canvas API`,M(n),W(e,n)},$$slots:{default:!0}});var i=z(r,2),a=z(L(i),2),o=L(a),s=z(L(o),4),c=L(s),l=z(L(c),2),u=L(l);u.value=u.__value=`system`;var d=z(u);d.value=d.__value=`llm`;var f=z(d);f.value=f.__value=`agent`;var p=z(f);p.value=p.__value=`mcp`,M(l),M(c);var m=z(c,2),h=z(L(m),6),g=z(L(h),2),_=L(g),v=L(_);v.value=v.__value=``,M(_),Fe(2),M(g),M(h),Fe(6),M(m),Fe(2),M(s),Fe(6),M(o),M(a),Fe(2),M(i),Fe(6),M(n),W(e,n),qe()}var mm=U(`<p class="files-msg svelte-4q2lov"> </p>`),hm=U(`<p class="files-msg files-msg--error svelte-4q2lov"> </p>`),gm=U(`<p class="files-msg files-msg--empty svelte-4q2lov"> </p>`),_m=U(`<option> </option>`),vm=U(`<div class="files-toolbar svelte-4q2lov"><label for="files-folder-filter" class="svelte-4q2lov"> </label> <select id="files-folder-filter" data-testid="files-folder-filter" class="svelte-4q2lov"><option> </option><!></select></div>`),ym=U(`<span class="files-folder svelte-4q2lov"> </span> ·`,1),bm=U(`<p class="files-row-error svelte-4q2lov"> </p>`),xm=U(`<li class="files-row svelte-4q2lov"><span class="files-icon svelte-4q2lov">📎</span> <div class="files-info svelte-4q2lov"><a target="_blank" rel="noopener" class="files-name svelte-4q2lov"> </a> <div class="files-meta svelte-4q2lov"><!><!> </div> <!></div> <div class="files-actions svelte-4q2lov"><button type="button" class="files-btn svelte-4q2lov"> </button> <button type="button" class="files-btn files-btn--danger svelte-4q2lov"> </button></div></li>`),Sm=U(`<ul class="files-list svelte-4q2lov"></ul>`),Cm=U(`<!> <!>`,1),wm=U(`<!> <div class="app-shell"><!> <div class="files-page svelte-4q2lov"><!></div></div>`,1);function Tm(e,t){Ke(t,!0);let n=P(null),r=P(I([])),i=P(I([])),a=P(``),o=P(!0),s=P(``),c=P(I({})),l=P(I({})),u=P(I({})),d=N(()=>V(a)?V(r).filter(e=>e.folder===V(a)||e.folder.startsWith(V(a)+`/`)):V(r));function f(e){return e<1024?Y(`files.size_bytes`).replace(`{n}`,String(e)):e<1024*1024?Y(`files.size_kb`).replace(`{n}`,(e/1024).toFixed(1)):Y(`files.size_mb`).replace(`{n}`,(e/1024/1024).toFixed(2))}function p(e){if(!e)return``;let t=new Date(e);if(isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}async function m(){F(o,!0),F(s,``);try{let e=await fetch(`/api/files`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();F(r,Array.isArray(t.files)?t.files:[],!0),F(i,Array.isArray(t.folders)?t.folders:[],!0),V(a)&&!V(i).includes(V(a))&&F(a,``)}catch(e){F(s,Y(`files.error_load`)+(e instanceof Error?e.message:String(e)))}finally{F(o,!1)}}function h(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function g(e){let t=document.createElement(`input`);t.type=`file`,t.style.display=`none`,document.body.appendChild(t),t.addEventListener(`change`,async()=>{let r=t.files?.[0];if(t.remove(),r&&await V(n).show({kicker:Y(`files.confirm_replace_title`),title:Y(`files.confirm_replace_message`).replace(`{name}`,e.displayName||e.filename).replace(`{newName}`,r.name),message:Y(`files.confirm_replace_detail`),confirmLabel:Y(`files.replace`),cancelLabel:Y(`common.cancel`),danger:!0})){if(r.size>19922944){F(c,{...V(c),[e.filename]:Y(`files.error_replace`)+`${(r.size/1024/1024).toFixed(1)} MB (max 19 MB)`},!0);return}F(l,{...V(l),[e.filename]:!0},!0),F(c,{...V(c),[e.filename]:``},!0);try{let t=await h(r),n=await fetch(`/api/files/${encodeURIComponent(e.filename)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`HTTP ${n.status}`)}await m()}catch(t){F(c,{...V(c),[e.filename]:Y(`files.error_replace`)+(t instanceof Error?t.message:String(t))},!0)}finally{F(l,{...V(l),[e.filename]:!1},!0)}}}),t.click()}async function _(e){if(await V(n).show({kicker:Y(`files.confirm_delete_title`),title:Y(`files.confirm_delete_message`).replace(`{name}`,e.displayName||e.filename),message:Y(`files.confirm_delete_detail`),confirmLabel:Y(`files.delete`),cancelLabel:Y(`common.cancel`),danger:!0})){F(u,{...V(u),[e.filename]:!0},!0),F(c,{...V(c),[e.filename]:``},!0);try{let t=await fetch(`/api/files/${encodeURIComponent(e.filename)}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`HTTP ${t.status}`)}await m()}catch(t){F(c,{...V(c),[e.filename]:Y(`files.error_delete`)+(t instanceof Error?t.message:String(t))},!0)}finally{F(u,{...V(u),[e.filename]:!1},!0)}}}Gi(async()=>{try{await pa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}await m()});var v=wm(),y=R(v);Vi(Ul(y,{}),e=>F(n,e,!0),()=>V(n));var b=z(y,2),x=L(b);{let e=N(()=>Y(`files.title`));$a(x,{get title(){return V(e)},subtitle:``})}var S=z(x,2),C=L(S),w=e=>{var t=mm(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},T=e=>{var t=hm(),n=L(t,!0);M(t),B(()=>G(n,V(s))),W(e,t)},E=e=>{var t=gm(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`files.empty`)]),W(e,t)},D=e=>{var t=Cm(),n=R(t),r=e=>{var t=vm(),n=L(t),r=L(n,!0);M(n);var o=z(n,2),s=L(o),c=L(s,!0);M(s),s.value=s.__value=``,q(z(s),16,()=>V(i),e=>e,(e,t)=>{var n=_m(),r=L(n,!0);M(n);var i={};B(()=>{G(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),W(e,n)}),M(o);var l;bi(o),M(t),B((e,t)=>{G(r,e),G(c,t),l!==(l=V(a))&&(o.value=(o.__value=V(a))??``,yi(o,V(a)))},[()=>Y(`files.filter_label`),()=>Y(`files.filter_all`)]),H(`change`,o,e=>F(a,e.target.value,!0)),W(e,t)};K(n,e=>{V(i).length>0&&e(r)});var o=z(n,2),s=e=>{var t=gm(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`files.empty_filter`)]),W(e,t)},m=e=>{var t=Sm();q(t,21,()=>V(d),Xr,(e,t)=>{var n=xm(),r=z(L(n),2),i=L(r),a=L(i,!0);M(i);var o=z(i,2),s=L(o),d=e=>{var n=ym(),r=R(n),i=L(r,!0);M(r),Fe(),B(()=>G(i,V(t).folder)),W(e,n)};K(s,e=>{V(t).folder&&e(d)});var m=z(s),h=e=>{var n=Ur();B(e=>G(n,`${e??``} ·`),[()=>p(V(t).uploadedAt)]),W(e,n)};K(m,e=>{V(t).uploadedAt&&e(h)});var v=z(m,1,!0);M(o);var y=z(o,2),b=e=>{var n=bm(),r=L(n,!0);M(n),B(()=>G(r,V(c)[V(t).filename])),W(e,n)};K(y,e=>{V(c)[V(t).filename]&&e(b)}),M(r);var x=z(r,2),S=L(x),C=L(S,!0);M(S);var w=z(S,2),T=L(w,!0);M(w),M(x),M(n),B((e,n,r)=>{J(i,`href`,V(t).url),G(a,V(t).displayName||V(t).filename),G(v,e),S.disabled=V(l)[V(t).filename]||V(u)[V(t).filename],G(C,n),w.disabled=V(l)[V(t).filename]||V(u)[V(t).filename],G(T,r)},[()=>f(V(t).size||0),()=>V(l)[V(t).filename]?Y(`files.replacing`):Y(`files.replace`),()=>V(u)[V(t).filename]?Y(`files.deleting`):Y(`files.delete`)]),H(`click`,S,()=>g(V(t))),H(`click`,w,()=>_(V(t))),W(e,n)}),M(t),W(e,t)};K(o,e=>{V(d).length===0?e(s):e(m,-1)}),W(e,t)};K(C,e=>{V(o)?e(w):V(s)?e(T,1):V(r).length===0?e(E,2):e(D,-1)}),M(S),M(b),W(e,v),qe()}Pr([`change`,`click`]);var Em=U(`<p class="browser-msg"> </p>`),Dm=U(`<p class="browser-msg browser-msg--error"> </p>`),Om=U(`<button class="browser-row browser-row--dir"><span class="browser-row-name"> </span></button>`),km=U(`<span class="badge-added"> </span>`),Am=U(`<button class="link-btn"> </button>`),jm=U(`<div class="browser-row browser-row--file"><span class="browser-row-name"> </span> <!></div>`),Mm=U(`<!> <!>`,1),Nm=U(`<div class="file-browser"><div class="file-browser-toolbar"><button class="link-btn"> </button> <span class="file-browser-path"> </span></div> <div class="file-browser-list" data-testid="instruction-browse-list"><!></div></div>`),Pm=U(`<p class="empty-msg svelte-e5jhdq"> </p>`),Fm=U(`<button class="remove-btn"> </button>`),Im=U(`<div class="instruction-row svelte-e5jhdq"><div class="instruction-info svelte-e5jhdq"><a class="instruction-path svelte-e5jhdq"> </a> <div class="instruction-meta svelte-e5jhdq"> <!></div></div> <div class="instruction-actions svelte-e5jhdq"><span> </span> <!></div></div>`),Lm=U(`<div class="section-card svelte-e5jhdq"><div class="section-header svelte-e5jhdq"><span class="section-title svelte-e5jhdq"> </span> <div class="header-actions svelte-e5jhdq"><span class="count-label svelte-e5jhdq"> </span> <button class="secondary-button btn-sm"> </button></div></div> <!> <div class="instruction-list svelte-e5jhdq" data-testid="instruction-list"><!></div></div>`);function Rm(e,t){Ke(t,!0);let n=Wi(t,`items`,27,()=>I([])),r=P(!1),i=P(``),a=P(``),o=P(I([])),s=P(I([])),c=P(!1),l=P(!1),u=N(()=>new Set(n().map(e=>d(e.path))));function d(e){return String(e||``).split(/[/\\]/).pop()||``}function f(e){let t=encodeURIComponent(String(e||``).replace(/\.md$/i,``));return`/?doc=`+encodeURIComponent(t)}function p(e){return Y(`context.root.${e}`)}function m(e){return Y(`context.type.${e}`)}async function h(e){F(c,!0),F(l,!1);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(i,t.current,!0),F(a,t.parent||``,!0),F(o,t.dirs||[],!0),F(s,t.files||[],!0)}catch{F(l,!0)}finally{F(c,!1)}}async function g(){F(r,!V(r)),V(r)&&!V(i)&&await h((await fetch(`/api/context/orientation`).then(e=>e.json()).catch(()=>({}))).sourceRoot||``)}async function _(e){await t.onAdd(e),V(r)&&V(i)&&await h(V(i))}var v=Lm(),y=L(v),b=L(y),x=L(b,!0);M(b);var S=z(b,2),C=L(S),w=L(C);M(C);var T=z(C,2),E=L(T,!0);M(T),M(S),M(y);var D=z(y,2),ee=e=>{var t=Nm(),n=L(t),r=L(n),d=L(r,!0);M(r);var f=z(r,2),p=L(f,!0);M(f),M(n);var m=z(n,2),g=L(m),v=e=>{var t=Em(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},y=e=>{var t=Dm(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`common.cannot_read_dir`)]),W(e,t)},b=e=>{var t=Em(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`common.empty_dir`)]),W(e,t)},x=e=>{var t=Mm(),n=R(t);q(n,17,()=>V(o),Xr,(e,t)=>{var n=Om(),r=L(n),i=L(r);M(r),M(n),B(()=>G(i,`📁 ${V(t).name??``}`)),H(`click`,n,()=>h(V(t).path)),W(e,n)}),q(z(n,2),17,()=>V(s),Xr,(e,t)=>{var n=jm(),r=L(n),i=L(r);M(r);var a=z(r,2),o=e=>{var t=km(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`context.added`)]),W(e,t)},s=N(()=>V(u).has(V(t).name)),c=e=>{var n=Am(),r=L(n,!0);M(n),B(e=>G(r,e),[()=>Y(`context.add_file_action`)]),H(`click`,n,()=>_(V(t).path)),W(e,n)};K(a,e=>{V(s)?e(o):e(c,-1)}),M(n),B(()=>G(i,`📄 ${V(t).name??``}`)),W(e,n)}),W(e,t)};K(g,e=>{V(c)?e(v):V(l)?e(y,1):!V(o).length&&!V(s).length?e(b,2):e(x,-1)}),M(m),M(t),B(e=>{r.disabled=!V(a),G(d,e),G(p,V(i))},[()=>Y(`common.up`)]),H(`click`,r,()=>V(a)&&h(V(a))),W(e,t)};K(D,e=>{V(r)&&e(ee)});var O=z(D,2),te=L(O),k=e=>{var t=Pm(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`context.no_instructions`)]),W(e,t)},ne=e=>{var r=Wr();q(R(r),17,n,Xr,(e,n)=>{var r=Im(),i=L(r),a=L(i),o=L(a,!0);M(a);var s=z(a,2),c=L(s),l=z(c),u=e=>{var t=Ur();B(e=>G(t,`· ${e??``} KB`),[()=>Math.round(V(n).size/1024)]),W(e,t)};K(l,e=>{V(n).size!==null&&e(u)}),M(s),M(i);var h=z(i,2),g=L(h),_=L(g,!0);M(g);var v=z(g,2),y=e=>{var r=Fm(),i=L(r,!0);M(r),B(e=>G(i,e),[()=>Y(`common.remove`)]),H(`click`,r,()=>t.onRemove(d(V(n).path))),W(e,r)};K(v,e=>{V(n).exists&&e(y)}),M(h),M(r),B((e,t,r,i)=>{J(a,`href`,e),G(o,V(n).path),G(c,`${t??``} · ${r??``} `),gi(g,1,ui(V(n).exists?`status-ok`:`status-missing`),`svelte-e5jhdq`),G(_,i)},[()=>f(V(n).path),()=>p(V(n).root),()=>m(V(n).type),()=>V(n).exists?Y(`context.exists`):Y(`context.missing`)]),W(e,r)}),W(e,r)};K(te,e=>{n().length?e(ne,-1):e(k)}),M(O),M(v),B((e,t,r)=>{G(x,e),G(w,`${t??``}/${n().length??``}`),G(E,r)},[()=>Y(`context.instructions_title`),()=>n().filter(e=>e.exists).length,()=>V(r)?Y(`context.hide_instruction_browser`):Y(`context.add_instruction_file`)]),H(`click`,T,g),W(e,v),qe()}Pr([`click`]);var zm=U(`<span class="rules-folder svelte-1r3tey2"> </span>`),Bm=U(`<p class="empty-msg svelte-1r3tey2"> </p>`),Vm=U(`<span class="tag svelte-1r3tey2"> </span>`),Hm=U(`<div class="rule-tags svelte-1r3tey2"></div>`),Um=U(`<div class="rule-applies svelte-1r3tey2"> </div>`),Wm=U(`<article class="rule-row svelte-1r3tey2"><div class="rule-top svelte-1r3tey2"><div class="rule-title-wrap svelte-1r3tey2"><h3 class="rule-title svelte-1r3tey2"><a class="rule-link svelte-1r3tey2"> </a></h3> <a class="rule-path svelte-1r3tey2"> </a></div> <span class="severity-badge svelte-1r3tey2"> </span></div> <p class="rule-desc svelte-1r3tey2"> </p> <!> <!></article>`),Gm=U(`<div class="rules-layout svelte-1r3tey2"><div class="section-card svelte-1r3tey2"><div class="section-header svelte-1r3tey2"><span class="section-title svelte-1r3tey2" data-testid="rules-title"> </span> <!></div> <div class="rule-list svelte-1r3tey2" data-testid="rule-list"><!></div></div> <div class="section-card aside-card svelte-1r3tey2"><span class="section-title svelte-1r3tey2" data-testid="add-rule-title"> </span> <div class="field-group"><label class="field-label" for="ruleTitle"> </label> <input id="ruleTitle" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleSeverity"> </label> <select id="ruleSeverity" class="field-input"><option> </option><option> </option><option> </option></select></div> <div class="field-group"><label class="field-label" for="ruleDescription"> </label> <input id="ruleDescription" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleTags"> </label> <input id="ruleTags" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleAppliesTo"> </label> <input id="ruleAppliesTo" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleBody"> </label> <textarea id="ruleBody" rows="7" class="field-input"></textarea></div> <button class="btn-primary" style="width:100%"> </button></div></div>`);function Km(e,t){Ke(t,!0);let n=Wi(t,`rules`,19,()=>[]),r=Wi(t,`rulesFolder`,3,``),i=P(``),a=P(`guideline`),o=P(``),s=P(``),c=P(``),l=P(``),u=P(!1);function d(e){let t=encodeURIComponent(String(e||``).replace(/\.md$/i,``));return`/?doc=`+encodeURIComponent(t)}function f(e){let t=`context.rule_severity_${e}`,n=Y(t);return n===t?e:n}function p(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}async function m(){if(V(i).trim()){F(u,!0);try{await t.onAdd({title:V(i).trim(),severity:V(a),description:V(o).trim(),tags:p(V(s)),appliesTo:p(V(c)),body:V(l).trim()}),F(i,``),F(o,``),F(s,``),F(c,``),F(l,``)}finally{F(u,!1)}}}var h=Gm(),g=L(h),_=L(g),v=L(_),y=L(v,!0);M(v);var b=z(v,2),x=e=>{var t=zm(),n=L(t,!0);M(t),B(()=>G(n,r())),W(e,t)};K(b,e=>{r()&&e(x)}),M(_);var S=z(_,2),C=L(S),w=e=>{var t=Bm(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`context.no_rules`)]),W(e,t)},T=e=>{var t=Wr();q(R(t),17,n,Xr,(e,t)=>{var n=Wm(),r=L(n),i=L(r),a=L(i),o=L(a),s=L(o,!0);M(o),M(a);var c=z(a,2),l=L(c,!0);M(c),M(i);var u=z(i,2),p=L(u,!0);M(u),M(r);var m=z(r,2),h=L(m,!0);M(m);var g=z(m,2),_=e=>{var n=Hm();q(n,21,()=>V(t).tags,Xr,(e,t)=>{var n=Vm(),r=L(n,!0);M(n),B(()=>G(r,V(t))),W(e,n)}),M(n),W(e,n)};K(g,e=>{V(t).tags?.length&&e(_)});var v=z(g,2),y=e=>{var n=Um(),r=L(n,!0);M(n),B(e=>G(r,e),[()=>V(t).appliesTo.join(`, `)]),W(e,n)};K(v,e=>{V(t).appliesTo?.length&&e(y)}),M(n),B((e,n,r)=>{J(o,`href`,e),G(s,V(t).title),J(c,`href`,n),G(l,V(t).path),G(p,r),G(h,V(t).description)},[()=>d(V(t).path),()=>d(V(t).path),()=>f(V(t).severity)]),W(e,n)}),W(e,t)};K(C,e=>{n().length?e(T,-1):e(w)}),M(S),M(g);var E=z(g,2),D=L(E),ee=L(D,!0);M(D);var O=z(D,2),te=L(O),k=L(te,!0);M(te);var ne=z(te,2);Di(ne),M(O);var A=z(O,2),re=L(A),ie=L(re,!0);M(re);var ae=z(re,2),oe=L(ae),se=L(oe,!0);M(oe),oe.value=oe.__value=`guideline`;var ce=z(oe),le=L(ce,!0);M(ce),ce.value=ce.__value=`warning`;var ue=z(ce),de=L(ue,!0);M(ue),ue.value=ue.__value=`required`,M(ae),M(A);var fe=z(A,2),pe=L(fe),me=L(pe,!0);M(pe);var he=z(pe,2);Di(he),M(fe);var ge=z(fe,2),_e=L(ge),ve=L(_e,!0);M(_e);var ye=z(_e,2);Di(ye),M(ge);var be=z(ge,2),xe=L(be),Se=L(xe,!0);M(xe);var Ce=z(xe,2);Di(Ce),M(be);var we=z(be,2),j=L(we),Te=L(j,!0);M(j);var Ee=z(j,2);yn(Ee),M(we);var De=z(we,2),Oe=L(De,!0);M(De),M(E),M(h),B((e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)=>{G(y,e),G(ee,t),G(k,n),J(ne,`placeholder`,r),G(ie,i),G(se,a),G(le,o),G(de,s),G(me,c),J(he,`placeholder`,l),G(ve,u),J(ye,`placeholder`,d),G(Se,f),J(Ce,`placeholder`,p),G(Te,m),J(Ee,`placeholder`,h),De.disabled=g,G(Oe,_)},[()=>Y(`context.rules_title`),()=>Y(`context.add_rule_title`),()=>Y(`context.rule_title_label`),()=>Y(`context.rule_title_placeholder`),()=>Y(`context.rule_severity_label`),()=>Y(`context.rule_severity_guideline`),()=>Y(`context.rule_severity_warning`),()=>Y(`context.rule_severity_required`),()=>Y(`context.rule_description_label`),()=>Y(`context.rule_description_placeholder`),()=>Y(`context.rule_tags_label`),()=>Y(`context.rule_tags_placeholder`),()=>Y(`context.rule_applies_to_label`),()=>Y(`context.rule_applies_to_placeholder`),()=>Y(`context.rule_body_label`),()=>Y(`context.rule_body_placeholder`),()=>V(u)||!V(i).trim(),()=>Y(`context.add_rule_button`)]),Ni(ne,()=>V(i),e=>F(i,e)),xi(ae,()=>V(a),e=>F(a,e)),Ni(he,()=>V(o),e=>F(o,e)),Ni(ye,()=>V(s),e=>F(s,e)),Ni(Ce,()=>V(c),e=>F(c,e)),Ni(Ee,()=>V(l),e=>F(l,e)),H(`click`,De,m),W(e,h),qe()}Pr([`click`]);var qm=U(`<p class="empty-msg svelte-1ui2b6s"> </p>`),Jm=U(`<p class="mcp-desc svelte-1ui2b6s"> </p>`),Ym=U(`<div class="mcp-schema-wrap svelte-1ui2b6s"><h4 class="mcp-schema-title svelte-1ui2b6s"> </h4> <pre class="mcp-schema-pre svelte-1ui2b6s"> </pre></div>`),Xm=U(`<div class="mcp-result svelte-1ui2b6s" data-testid="mcp-result"></div>`),Zm=U(`<details class="mcp-detail svelte-1ui2b6s"><summary class="mcp-summary svelte-1ui2b6s"> </summary> <!> <!> <div class="mcp-run-area svelte-1ui2b6s"><label class="mcp-run-label svelte-1ui2b6s"> </label> <textarea rows="4" spellcheck="false" class="field-input mcp-textarea svelte-1ui2b6s" data-testid="mcp-args"></textarea> <div class="mcp-run-footer svelte-1ui2b6s"><span class="mcp-error-text svelte-1ui2b6s" data-testid="mcp-error"> </span> <button class="btn-primary btn-sm"> </button></div> <!></div></details>`),Qm=U(`<p class="mcp-arg-desc svelte-1ui2b6s"> </p>`),$m=U(`<li class="mcp-arg-item svelte-1ui2b6s"><div class="mcp-arg-name-row svelte-1ui2b6s"><span class="mcp-arg-name svelte-1ui2b6s"> </span> <span class="mcp-arg-req svelte-1ui2b6s"> </span></div> <!></li>`),eh=U(`<div class="mcp-schema-wrap svelte-1ui2b6s"><h4 class="mcp-schema-title svelte-1ui2b6s"> </h4> <ul class="mcp-args-list svelte-1ui2b6s"></ul></div>`),th=U(`<div class="section-card svelte-1ui2b6s"><div class="section-header svelte-1ui2b6s"><span class="section-title svelte-1ui2b6s" data-testid="mcp-title"> </span> <button class="secondary-button btn-sm"> </button></div> <p class="section-desc svelte-1ui2b6s"> </p> <div class="mcp-info-grid svelte-1ui2b6s"><div class="mcp-info-cell svelte-1ui2b6s"><div class="mcp-info-label svelte-1ui2b6s"> </div> <div> </div></div> <div class="mcp-info-cell svelte-1ui2b6s"><div class="mcp-info-label svelte-1ui2b6s"> </div> <div class="mcp-info-value mono svelte-1ui2b6s"> </div></div> <div class="mcp-info-cell wide svelte-1ui2b6s"><div class="mcp-info-label svelte-1ui2b6s"> </div> <div class="mcp-info-value mono break svelte-1ui2b6s" data-testid="mcp-endpoint"> </div></div></div> <div><div class="subsection-header svelte-1ui2b6s"><span class="subsection-title svelte-1ui2b6s"> </span> <div class="subsection-actions svelte-1ui2b6s"><span class="count-label svelte-1ui2b6s"> </span> <button class="secondary-button btn-sm"> </button></div></div> <div class="mcp-items svelte-1ui2b6s" data-testid="mcp-tool-list"><!></div></div> <div><div class="subsection-header svelte-1ui2b6s"><span class="subsection-title svelte-1ui2b6s"> </span> <div class="subsection-actions svelte-1ui2b6s"><span class="count-label svelte-1ui2b6s"> </span> <button class="secondary-button btn-sm"> </button></div></div> <div class="mcp-items svelte-1ui2b6s" data-testid="mcp-prompt-list"><!></div></div></div>`);function nh(e,t){Ke(t,!0);let n=P(`-`),r=P(!1),i=P(`-`),a=P(`-`),o=P(I([])),s=P(I([])),c=P(!1),l=P(I(new Map)),u=P(I(new Map));function d(e,t){let n=V(e===`tool`?l:u);return n.has(t)||n.set(t,{argsJson:`{}`,running:!1,error:``,resultHtml:``}),n.get(t)}function f(e,t,n){let r=V(e===`tool`?l:u).get(t)??{argsJson:`{}`,running:!1,error:``,resultHtml:``};e===`tool`?F(l,new Map(V(l)).set(t,{...r,...n}),!0):F(u,new Map(V(u)).set(t,{...r,...n}),!0)}function p(e){if(!e||typeof e!=`object`)return null;if(e.type===`string`)return``;if(e.type===`number`||e.type===`integer`)return 0;if(e.type===`boolean`)return!1;if(e.type===`array`)return[];if(e.type===`object`||e.properties){let t={},n=e.properties||{};return(Array.isArray(e.required)?e.required:[]).forEach(e=>{t[e]=p(n[e])??``}),t}return null}function m(e){let t=p(e.inputSchema)??{},n=JSON.stringify(t,null,2);F(l,new Map(V(l)).set(e.name,{argsJson:n,running:!1,error:``,resultHtml:``}),!0)}function h(e){let t={};(e.arguments||[]).forEach(e=>{e.required&&(t[e.name]=``)});let n=JSON.stringify(t,null,2);F(u,new Map(V(u)).set(e.name,{argsJson:n,running:!1,error:``,resultHtml:``}),!0)}function g(e){let t=e.match(/^data:\s*(\{.*\})\s*$/m);if(!t)throw Error(e.slice(0,300)||`No MCP response body`);return JSON.parse(t[1])}async function _(e,t,n){let r=await fetch(`/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json, text/event-stream`},body:JSON.stringify({jsonrpc:`2.0`,id:e,method:t,params:n})}),i=await r.text();if(!r.ok)throw Error(i||`HTTP ${r.status}`);return g(i)}async function v(){await _(1,`initialize`,{protocolVersion:`2025-03-26`,capabilities:{},clientInfo:{name:`living-ai-documentation-context`,version:`1.0.0`}})}function y(e){return"```json\n"+JSON.stringify(e,null,2).replaceAll("```","`\\`\\`")+"\n```"}function b(e){if(typeof e!=`string`)return y(e);try{return y(JSON.parse(e))}catch{return e}}function x(e){if(typeof e==`string`)return e;if(!e||typeof e!=`object`)return String(e??``);if(e.error)return y(e.error);let t=e.result;return!t||typeof t!=`object`?y(e):Array.isArray(t.messages)?t.messages.map(e=>`${e.role?`[${e.role}]`:``}\n${b(e.content?.text??e.content??e)}`.trim()).join(`
|
|
87
|
+
`,t);return n>=0?n:0}c=c.nextElementSibling}return e.length}function gu(e,t,n){if(!e||typeof t!=`string`)return()=>{};let r=au(t);su(e,r);let i=i=>{let a=i.target?.closest(`[data-inline-snippet-index]`);if(a&&e.contains(a)){let e=r[Number(a.dataset.inlineSnippetIndex)];if(!e)return;i.preventDefault();let t=Yl(e.type),o=Zl(e.type);lu(i,[{iconClass:t.iconClass,labelKey:t.labelKey,dataAction:`edit`,dataType:e.type,onActivate:()=>n.onEdit(e)},{iconClass:o.iconClass,labelKey:o.labelKey,dataAction:`delete`,dataType:e.type,onActivate:()=>n.onDelete(e)}]);return}if(!e.contains(i.target))return;let o=hu(t,e,i.target,r,i.clientY);o!==null&&(i.preventDefault(),lu(i,{iconClass:`fa-solid fa-plus`,labelKey:`snippet.inline_insert_btn`,dataAction:`insert`,onActivate:()=>n.onInsert(o)}))};e.addEventListener(`contextmenu`,i);let a=t=>{let i=t.target?.closest(`[data-inline-snippet-index]`);if(!i||!e.contains(i))return;let a=r[Number(i.dataset.inlineSnippetIndex)];!a||a.type!==`table`||(t.preventDefault(),t.stopPropagation(),cu(),n.onEdit({...a,tableFocusCell:du(t.target,i)||void 0}))};e.addEventListener(`dblclick`,a);let o=e.closest(`#home-content-area`)||e.closest(`main`),s=null;o&&(s=r=>{r.defaultPrevented||e.offsetParent!==null&&(r.target?.closest(`textarea, input, [data-inline-snippet-index]`)||e.contains(r.target)||(r.preventDefault(),lu(r,{iconClass:`fa-solid fa-plus`,labelKey:`snippet.inline_insert_btn`,dataAction:`insert`,onActivate:()=>n.onInsert(t.length)})))},o.addEventListener(`contextmenu`,s));let c=e=>{$l&&!$l.contains(e.target)&&cu()},l=e=>{e.key===`Escape`&&cu()};return document.addEventListener(`click`,c),document.addEventListener(`keydown`,l),()=>{e.removeEventListener(`contextmenu`,i),e.removeEventListener(`dblclick`,a),o&&s&&o.removeEventListener(`contextmenu`,s),document.removeEventListener(`click`,c),document.removeEventListener(`keydown`,l),cu(),e.querySelectorAll(`[data-inline-snippet-index]`).forEach(e=>{e.removeAttribute(`data-inline-snippet-index`),e.classList.remove(`ld-inline-snippet-target`)})}}var _u=U(`<textarea id="doc-editor" data-testid="doc-editor" spellcheck="false" class="w-full min-h-[70vh] px-4 py-3 text-sm font-mono leading-relaxed rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-y"></textarea>`),vu=U(`<div id="doc-content" data-testid="doc-content"></div>`),yu=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-sm mx-4 p-6 space-y-5"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"> </h3> <div class="space-y-1.5"><label for="img-paste-name" class="block text-xs font-medium text-gray-500 dark:text-gray-400"> <span class="font-normal text-gray-400"> </span></label> <div class="flex items-center gap-2"><input id="img-paste-name" type="text" class="flex-1 px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono focus:outline-none focus:ring-2 focus:ring-blue-500"/> <span class="text-xs text-gray-400 shrink-0"> </span></div></div> <div class="flex justify-end gap-3 pt-1"><button class="text-sm px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button class="text-sm px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors"> </button></div></div></div>`),bu=U(`<div data-testid="content-lightbox" class="fixed inset-0 z-50 bg-white flex items-center justify-center cursor-pointer p-4"><img data-testid="lightbox-image" class="max-w-full max-h-full object-contain select-none"/> <button class="absolute top-4 right-4 text-gray-500 hover:text-gray-950 text-2xl leading-none">×</button></div>`),xu=U(`<!> <!> <!> <!>`,1);function Su(e,t){Ke(t,!0);let n=Wi(t,`onopen`,3,()=>{}),r=Wi(t,`onanchor`,3,D),i=Wi(t,`onconfirmdelete`,3,void 0),a=Wi(t,`oncontentwired`,3,void 0),o=Wi(t,`rewireSignal`,3,void 0),s=Wi(t,`editing`,15,!1),c=Wi(t,`saveMsg`,15,null),l=P(null),u=P(null),d=P(``),f=null,p=P(!1),m=P(`insert`),h=P(null),g=P(0),_=P(!1),v=P(``),y=P(`png`),b=null,x=0,S=0,C=P(null),w=P(``),T=/[̀-ͯ]/g;function E(e){return(e||``).normalize(`NFD`).replace(T,``).toLowerCase().replace(/[^a-z0-9]/g,`_`)}function D(e){document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})}Gi(()=>{let e=window;return e.openSnippetsModal=()=>{F(m,`insert`),F(p,!0)},e.openSnippetsModalForInlineInsert=e=>{F(m,`inline-insert`),F(g,Math.max(0,Number(e)||0),!0),F(p,!0)},()=>{delete e.openSnippetsModal,delete e.openSnippetsModalForInlineInsert}}),kn(()=>{if(o(),t.html,t.content,f?.(),f=null,!(s()||!V(l)))return Us(V(l),t.html,{content:t.content,codeBlockMaxHeight:X.codeBlockMaxHeight,t:Y,onDocLink:(e,t)=>n()(e,t),onAnchor:r()}),f=gu(V(l),t.content,{onEdit:e=>{F(m,`inline-edit`),F(h,e,!0),F(p,!0)},onInsert:e=>{F(m,`inline-insert`),F(g,e,!0),F(p,!0)},onDelete:async e=>{(i()?await i()():confirm(Y(`snippet.inline_delete_message`)))&&await t.onsave(t.content.slice(0,e.start)+t.content.slice(e.end))}}),a()?.(V(l)),()=>{f?.(),f=null}});function ee(){F(d,t.content,!0),s(!0),c(null),requestAnimationFrame(()=>V(u)?.focus())}function O(){s(!1),c(null)}async function te(){c({text:Y(`doc.saving`),cls:`text-gray-400`});try{await t.onsave(V(d)),s(!1),c(null)}catch(e){c({text:Y(`error.save`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`})}}function k(){F(m,`insert`),F(p,!0)}function ne(){return s()}function A(e){let t=Array.from(e.clipboardData?.items??[]).find(e=>e.type.startsWith(`image/`));if(t){e.preventDefault(),x=V(u).selectionStart,S=V(u).selectionEnd,F(y,t.type.split(`/`)[1].replace(`jpeg`,`jpg`)||`png`,!0);let n=t.getAsFile();if(!n)return;b=n,F(v,E(Date.now().toString()),!0),F(_,!0);return}let n=Array.from(e.clipboardData?.files??[]).filter(e=>!e.type.startsWith(`image/`));if(n.length){e.preventDefault();let t=V(u).selectionStart,r=V(u).selectionEnd;(async()=>{for(let e of n)await se(e,t,r)})()}}function re(e){let t=Array.from(e.dataTransfer?.files??[]).filter(e=>!e.type.startsWith(`image/`));if(!t.length)return;e.preventDefault(),e.stopPropagation();let n=V(u).selectionStart,r=V(u).selectionEnd;(async()=>{for(let e of t)await se(e,n,r)})()}function ie(e){e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}function ae(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function oe(e,t,n){let r=V(d).slice(0,t),i=V(d).slice(n);F(d,r+e+i),requestAnimationFrame(()=>{V(u).selectionStart=V(u).selectionEnd=t+e.length,V(u).focus()})}async function se(e,n,r){if(e.size>19922944){c({text:Y(`doc.file_too_large`)+` (${(e.size/1024/1024).toFixed(1)} MB, max 19 MB)`,cls:`text-red-500 dark:text-red-400`});return}c({text:Y(`doc.uploading_file`),cls:`text-gray-400`});try{let i=await ae(e),a=await fetch(`/api/files/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:i,name:e.name,documentId:t.docId})});if(!a.ok){let e=``;try{e=(await a.json()).error||``}catch{e=await a.text()}throw Error(e||`HTTP ${a.status}`)}let{url:o,originalName:s}=await a.json();oe(`[📎 ${s||e.name}](${o})`,n,r),c(null)}catch(e){c({text:Y(`doc.file_upload_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`})}}function ce(){F(_,!1),b=null}async function le(){let e=E(V(v))||Date.now().toString();if(F(_,!1),b){c({text:Y(`doc.uploading_image`),cls:`text-gray-400`});try{let t=await ae(b),n=await fetch(`/api/images/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:t,ext:V(y),name:e})});if(!n.ok)throw Error(await n.text());let{filename:r}=await n.json();oe(``,x,S),c(null)}catch(e){c({text:Y(`doc.image_upload_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`})}finally{b=null}}}function ue(){F(C,null),F(w,``)}function de(e){if(!e.shiftKey&&!e.metaKey)return;let t=e.target,n=t.closest(`img`),r=t.closest(`.mermaid`)?.querySelector(`svg`);if(!n&&!r)return;if(e.preventDefault(),e.stopPropagation(),n){F(C,n.src,!0),F(w,n.alt||``,!0);return}let i=new XMLSerializer().serializeToString(r);F(C,`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`),F(w,Y(`doc.mermaid_diagram_alt`),!0)}function fe(e){e.key===`Escape`&&V(C)&&ue()}var pe={enterEdit:ee,cancelEdit:O,save:te,openSnippets:k,isEditing:ne},me=xu();Nr(`keydown`,on,fe);var he=R(me),ge=e=>{var t=_u();yn(t),Vi(t,e=>F(u,e),()=>V(u)),Nr(`paste`,t,A),Nr(`drop`,t,re),Nr(`dragover`,t,ie),Ni(t,()=>V(d),e=>F(d,e)),W(e,t)},_e=e=>{var t=vu();Vi(t,e=>F(l,e),()=>V(l)),B(()=>gi(t,1,`prose prose-gray dark:prose-invert max-w-none prose-headings:scroll-mt-4 prose-headings:font-semibold prose-h1:text-[2.1875rem] prose-h2:text-[1.8125rem] prose-h3:text-[1.5rem] prose-h4:text-[1.25rem] prose-a:text-blue-600 dark:prose-a:text-blue-400 prose-code:before:content-none prose-code:after:content-none ${X.codeBlockLightTheme?`prose-pre:bg-[#f6f8fa] prose-pre:text-gray-800 prose-pre:border prose-pre:border-gray-200 prose-pre:rounded-lg dark:prose-pre:bg-[#0d1117] dark:prose-pre:text-gray-100 dark:prose-pre:border-gray-700`:`prose-pre:bg-[#0d1117] prose-pre:border prose-pre:border-gray-700`} ${X.imageRoundedCorners?`[&_img]:rounded-xl`:``} ${X.imageCentered?`[&_img]:mx-auto [&_img]:block`:``} ${X.imageBorder?`[&_img]:[box-shadow:0_0_0_1px_rgba(0,0,0,0.10),0_4px_12px_rgba(0,0,0,0.04)] dark:[&_img]:[box-shadow:0_0_0_1px_rgba(255,255,255,0.08),0_4px_12px_rgba(255,255,255,0.25)]`:``}`)),H(`click`,t,de),W(e,t)};K(he,e=>{s()?e(ge):e(_e,-1)});var ve=z(he,2);Kl(ve,{get open(){return V(p)},get editor(){return V(u)},get mode(){return V(m)},get docId(){return t.docId},get content(){return t.content},get range(){return V(h)},get insertPos(){return V(g)},get onsave(){return t.onsave},onclose:()=>F(p,!1)});var ye=z(ve,2),be=e=>{var t=yu(),n=L(t),r=L(n),i=L(r);M(r);var a=z(r,2),o=L(a),s=L(o),c=z(s),l=L(c,!0);M(c),M(o);var u=z(o,2),d=L(u);Di(d);var f=z(d,2),p=L(f);M(f),M(u),M(a);var m=z(a,2),h=L(m),g=L(h,!0);M(h);var _=z(h,2),b=L(_,!0);M(_),M(m),M(n),M(t),B((e,t,n,r,a)=>{G(i,`🖼️ ${e??``}`),G(s,`${t??``} `),G(l,n),Oi(d,V(v)),G(p,`.${V(y)??``}`),G(g,r),G(b,a)},[()=>Y(`modal.img_paste.title`),()=>Y(`modal.img_paste.filename_label`),()=>Y(`modal.img_paste.saved_hint`),()=>Y(`common.cancel`),()=>Y(`modal.img_paste.paste_btn`)]),H(`input`,d,e=>F(v,E(e.target.value),!0)),H(`click`,h,ce),H(`click`,_,le),W(e,t)};K(ye,e=>{V(_)&&e(be)});var xe=z(ye,2),Se=e=>{var t=bu(),n=L(t),r=z(n,2);M(t),B(()=>{J(n,`src`,V(C)),J(n,`alt`,V(w))}),H(`click`,t,ue),H(`click`,n,e=>e.stopPropagation()),H(`click`,r,ue),W(e,t)};return K(xe,e=>{V(C)&&e(Se)}),W(e,me),qe(pe)}Pr([`click`,`input`]);var Cu=U(`<span> </span> <code> </code>`,1),wu=U(`<button type="button" data-testid="bp-copy-doc-id"><i aria-hidden="true"></i></button>`),Tu=U(`<button class="bpadr-icon-btn" data-testid="bp-edit" type="button">✏️</button> <button class="bpadr-icon-btn" data-testid="bp-delete" type="button">🗑️</button>`,1),Eu=U(`<span> </span>`),Du=U(`<footer class="bpadr-footer bpadr-doc-footer"><!> <button type="button" class="bpadr-btn-ghost" data-testid="bp-cancel"> </button> <button type="button" class="bpadr-btn-ghost" data-testid="bp-snippets"> </button> <button type="button" class="bpadr-btn-primary" data-testid="bp-save"> </button></footer>`),Ou=U(`<div class="bpadr-read"><!></div> <!>`,1),ku=U(`<form class="bpadr-form"><input type="hidden" name="category"/> <input type="hidden" name="folder"/> <div class="bpadr-field"><label for="adr-title"> </label> <input id="adr-title" type="text" class="bpadr-input"/></div> <div class="bpadr-field bpadr-field-grow"><label for="adr-content"> </label> <textarea id="adr-content" class="bpadr-textarea"></textarea></div> <footer class="bpadr-footer"><button type="button" class="bpadr-btn-ghost"> </button> <button type="button" data-testid="bp-form-snippets" class="bpadr-btn-ghost"> </button> <button type="submit" class="bpadr-btn-primary"> </button></footer></form> <!>`,1),Au=U(`<div class="bpadr-folder-confirm"><p></p> <p class="bpadr-muted"> </p> <footer class="bpadr-footer"><button type="button" class="bpadr-btn-ghost"> </button> <button type="button" class="bpadr-btn-primary"> </button></footer></div>`),ju=U(`<div class="bpadr-overlay"><div class="bpadr-modal"><header class="bpadr-header"><div class="bpadr-title-row"><h2 class="bpadr-title"><!></h2> <!></div> <div class="bpadr-header-actions"><!> <button class="bpadr-icon-btn" type="button" title="Close">×</button></div></header> <!></div></div>`),Mu=U(`<div class="fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4"><div class="w-full max-w-sm bg-white dark:bg-gray-900 border border-red-200 dark:border-red-700 rounded-xl shadow-2xl p-5 flex flex-col gap-3"><p class="text-sm text-gray-700 dark:text-gray-200"> </p> <p class="text-xs text-gray-500 dark:text-gray-400 italic truncate"> </p> <div class="flex justify-end gap-2 mt-2"><button type="button" data-testid="bp-delete-cancel" class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"> </button> <button type="button" data-testid="bp-delete-confirm" class="text-sm px-4 py-1.5 rounded-lg bg-red-500 hover:bg-red-600 text-white font-semibold transition-colors"> </button></div></div></div>`),Nu=U(`<!> <!>`,1);function Pu(e,t){Ke(t,!0);let n=Wi(t,`onchanged`,3,()=>{}),r=`000_BLUEPRINT`;function i(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toUpperCase().replace(/[^A-Z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`FOLDER`}function a(e){return`/${(e.folder.path||e.folder.name).replace(/^\/+|\/+$/g,``)||e.folder.name}`}let o=P(`closed`),s=P(``),c=P(``),l=P(``),u=P(``),d=P(``),f=P(``),p=P(``),m=P(``),h=P(null),g=P(null),_=P(null),v=P(!1),y=P(null),b=P(null),x=P(!1),S=P(!1),C=P(!1);async function w(e){F(g,e,!0),F(h,null),F(v,!1),F(y,null);let t=i(e.folder.name);if(F(l,t,!0),F(c,e.folder.name,!0),F(u,``),F(d,``),F(f,``),F(m,a(e),!0),F(s,Y(`blueprint.adr.new_title`,{folder:e.folder.name}),!0),F(o,`form`),!(await fetch(`/api/blueprint/blueprint-folder`).then(e=>e.json())).exists){F(p,r),F(o,`folder-confirm`);return}await E(e,t)}async function T(e){return fetch(`/api/documents/${encodeURIComponent(e)}`).then(e=>e.json())}async function E(e,t){let n=await fetch(`/api/blueprint/blueprint-adr?category=${encodeURIComponent(t)}`).then(e=>e.json());if(n.found&&n.doc){F(h,n.doc.id,!0);let e=await T(n.doc.id);F(c,e.title,!0),F(d,e.content,!0),F(f,e.html,!0),F(s,e.title,!0),F(v,!1),F(o,`doc`)}else F(c,e.folder.name,!0),F(u,``),F(o,`form`)}function D(){F(o,`closed`),F(v,!1),F(h,null),F(g,null),F(m,``),F(C,!1)}async function ee(){if(V(h))try{await navigator.clipboard.writeText(decodeURIComponent(V(h))),F(C,!0),setTimeout(()=>F(C,!1),1800)}catch{}}async function O(){await fetch(`/api/blueprint/blueprint-folder`,{method:`POST`}),V(g)&&await E(V(g),i(V(g).folder.name))}async function te(e){if(!V(h))return;await fetch(`/api/documents/${encodeURIComponent(V(h))}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:V(c).trim()||V(g)?.folder.name||Y(`common.untitled`),category:V(l),folder:r,content:e})});let t=await T(V(h));F(s,t.title,!0),F(d,t.content,!0),F(f,t.html,!0)}async function k(e){e.preventDefault();let t={title:V(c).trim()||V(g)?.folder.name||Y(`common.untitled`),category:V(l),folder:r},i=await fetch(`/api/documents/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}).then(e=>e.json());F(h,i.id,!0);let a=await T(i.id);F(s,a.title,!0),F(d,a.content,!0),F(f,a.html,!0),F(v,!1),F(o,`doc`),n()()}async function ne(){F(S,!1),V(h)&&(await fetch(`/api/documents/${encodeURIComponent(V(h))}`,{method:`DELETE`}),D(),n()())}var A={open:w},re=Nu(),ie=R(re),ae=e=>{var t=ju(),n=L(t),i=L(n),a=L(i),g=L(a),w=L(g),T=e=>{var t=Cu(),n=R(t),r=L(n,!0);M(n);var i=z(n,2),a=L(i,!0);M(i),B(e=>{G(r,e),G(a,V(m))},[()=>Y(`blueprint.adr.folder_title`)]),W(e,t)},E=e=>{var t=Ur();B(()=>G(t,V(s))),W(e,t)};K(w,e=>{V(m)?e(T):e(E,-1)}),M(g);var ne=z(g,2),A=e=>{var t=wu(),n=L(t);M(t),B(e=>{J(t,`title`,e),gi(t,1,`bpadr-copy-btn ${V(C)?`copied`:``}`),gi(n,1,`fa-${V(C)?`solid fa-check`:`regular fa-copy`}`)},[()=>Y(`doc.copy_mcp_id`)]),H(`click`,t,ee),W(e,t)};K(ne,e=>{V(h)&&e(A)}),M(a);var re=z(a,2),ie=L(re),ae=e=>{var t=Tu(),n=R(t),r=z(n,2);B((e,t)=>{J(n,`title`,e),J(r,`title`,t)},[()=>Y(`doc.edit`),()=>Y(`doc.delete`)]),H(`click`,n,()=>V(_).enterEdit()),H(`click`,r,()=>F(S,!0)),W(e,t)};K(ie,e=>{V(o)===`doc`&&!V(v)&&e(ae)});var oe=z(ie,2);M(re),M(i);var se=z(i,2),ce=e=>{var t=Ou(),n=R(t),r=L(n);{let e=N(()=>V(h)??``);Vi(Su(r,{get docId(){return V(e)},get content(){return V(d)},get html(){return V(f)},onsave:te,get editing(){return V(v)},set editing(e){F(v,e,!0)},get saveMsg(){return V(y)},set saveMsg(e){F(y,e,!0)}}),e=>F(_,e,!0),()=>V(_))}M(n);var i=z(n,2),a=e=>{var t=Du(),n=L(t),r=e=>{var t=Eu(),n=L(t,!0);M(t),B(()=>{gi(t,1,`text-xs ${V(y).cls??``}`),G(n,V(y).text)}),W(e,t)};K(n,e=>{V(y)&&e(r)});var i=z(n,2),a=L(i,!0);M(i);var o=z(i,2),s=L(o,!0);M(o);var c=z(o,2),l=L(c,!0);M(c),M(t),B((e,t,n)=>{G(a,e),G(s,t),G(l,n)},[()=>Y(`common.cancel`),()=>Y(`doc.snippets_btn`),()=>Y(`common.save`)]),H(`click`,i,()=>V(_).cancelEdit()),H(`click`,o,()=>V(_).openSnippets()),H(`click`,c,()=>V(_).save()),W(e,t)};K(i,e=>{V(v)&&e(a)}),W(e,t)},le=e=>{var t=ku(),n=R(t),i=L(n);Di(i);var a=z(i,2);Di(a),Oi(a,r);var s=z(a,2),d=L(s),f=L(d,!0);M(d);var p=z(d,2);Di(p),M(s);var m=z(s,2),g=L(m),_=L(g,!0);M(g);var v=z(g,2);yn(v),Vi(v,e=>F(b,e),()=>V(b)),M(m);var y=z(m,2),S=L(y),C=L(S,!0);M(S);var w=z(S,2),T=L(w,!0);M(w);var E=z(w,2),ee=L(E,!0);M(E),M(y),M(n),Kl(z(n,2),{get open(){return V(x)},get editor(){return V(b)},mode:`insert`,get content(){return V(u)},onclose:()=>F(x,!1)}),B((e,t,n,r,a)=>{Oi(i,V(l)),G(f,e),G(_,t),G(C,n),G(T,r),G(ee,a)},[()=>Y(`blueprint.adr.title_label`),()=>Y(`blueprint.adr.content_label`),()=>Y(`common.cancel`),()=>Y(`doc.snippets_btn`),()=>Y(`common.save`)]),Nr(`submit`,n,k),Ni(p,()=>V(c),e=>F(c,e)),Ni(v,()=>V(u),e=>F(u,e)),H(`click`,S,()=>{V(h)?F(o,`doc`):D()}),H(`click`,w,()=>F(x,!0)),W(e,t)},ue=e=>{var t=Au(),n=L(t);ai(n,()=>Y(`blueprint.adr.folder_missing`,{name:V(p)}),!0),M(n);var r=z(n,2),i=L(r,!0);M(r);var a=z(r,2),o=L(a),s=L(o,!0);M(o);var c=z(o,2),l=L(c,!0);M(c),M(a),M(t),B((e,t,n)=>{G(i,e),G(s,t),G(l,n)},[()=>Y(`blueprint.adr.folder_create_prompt`),()=>Y(`common.cancel`),()=>Y(`blueprint.adr.create_folder_btn`)]),H(`click`,o,D),H(`click`,c,O),W(e,t)};K(se,e=>{V(o)===`doc`?e(ce):V(o)===`form`?e(le,1):V(o)===`folder-confirm`&&e(ue,2)}),M(n),M(t),H(`click`,t,e=>{e.target===e.currentTarget&&D()}),H(`click`,oe,D),W(e,t)};K(ie,e=>{V(o)!==`closed`&&e(ae)});var oe=z(ie,2),se=e=>{var t=Mu(),n=L(t),r=L(n),i=L(r,!0);M(r);var a=z(r,2),o=L(a,!0);M(a);var c=z(a,2),l=L(c),u=L(l,!0);M(l);var d=z(l,2),f=L(d,!0);M(d),M(c),M(n),M(t),B((e,t,n)=>{G(i,e),G(o,V(s)),G(u,t),G(f,n)},[()=>Y(`doc.confirm_delete`),()=>Y(`common.cancel`),()=>Y(`doc.confirm_delete_btn`)]),H(`click`,t,e=>{e.target===e.currentTarget&&F(S,!1)}),H(`click`,l,()=>F(S,!1)),H(`click`,d,ne),W(e,t)};return K(oe,e=>{V(S)&&e(se)}),W(e,re),qe(A)}Pr([`click`]);var Fu=U(`<span class="breadcrumb-sep">›</span>`),Iu=U(`<span class="breadcrumb-item current"> </span>`),Lu=U(`<button class="breadcrumb-item" type="button"> </button>`),Ru=U(`<!> <!>`,1),zu=U(`<nav class="breadcrumb"></nav>`),Bu=U(`<div class="app-shell"><!> <section class="workspace-shell"><!> <!></section></div> <!>`,1);function Vu(e,t){Ke(t,!0),Gi(async()=>{try{await pa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}});let n=P(I([])),r=P(null),i=P(null),a=P(null),o=P(null);function s(e){l(),V(i).loadPath(e,!0)}async function c(e){F(r,e.folder.path,!0),await xr(),await V(a).open(e.folder.path)}function l(){F(r,null)}async function u(e){await V(i).navigateToFolder(e)}var d=Bu(),f=R(d),p=L(f);{let e=N(()=>Y(`blueprint.subtitle`));$a(p,{title:`Blueprint`,get subtitle(){return V(e)},children:(e,t)=>{var r=zu();q(r,21,()=>V(n),Xr,(e,t,r)=>{var i=Ru(),a=R(i),o=e=>{W(e,Fu())};K(a,e=>{r>0&&e(o)});var c=z(a,2),l=e=>{var n=Iu(),r=L(n,!0);M(n),B(()=>G(r,V(t).name)),W(e,n)},u=e=>{var n=Lu(),r=L(n,!0);M(n),B(()=>G(r,V(t).name)),H(`click`,n,()=>s(V(t).path)),W(e,n)};K(c,e=>{r===V(n).length-1?e(l):e(u,-1)}),W(e,i)}),M(r),W(e,r)},$$slots:{default:!0}})}var m=z(p,2),h=L(m);Vi(To(h,{get activeExplorerPath(){return V(r)},onbreadcrumbchange:e=>F(n,e,!0),onopenexplorer:c,onclosefilerexplorer:l,onopenAdr:e=>V(o).open(e)}),e=>F(i,e,!0),()=>V(i));var g=z(h,2),_=e=>{Vi(Go(e,{onclose:l,onnavigate:u}),e=>F(a,e,!0),()=>V(a))};K(g,e=>{V(r)!==null&&e(_)}),M(m),M(f),Vi(Pu(z(f,2),{onchanged:()=>V(i).loadPath(V(n).at(-1)?.path??``,!1)}),e=>F(o,e,!0),()=>V(o)),W(e,d),qe()}Pr([`click`]);var Hu=164,Uu=64,Wu=132,Gu=78,Ku=6,qu=24,Ju=96,Yu=540,Xu=780,Zu=1/2,Qu=9999,$u=44,ed=255,td=178,nd=Math.PI*.7,rd=Math.PI*1.1,id=Math.PI*1.45,ad=Math.PI*1.75,od=14,sd=260,cd=56,ld=32,ud=[`pointerdown`,`mousedown`,`click`,`dblclick`,`touchstart`,`wheel`],dd=.35,fd=2.2,pd=.0018,md=4,hd=46,gd=4,_d=44,vd=360,yd=300,bd=44,xd=48,Sd=7,Cd=875,wd=450,Td=600*1e3,Ed,Z,Dd,Od,kd,Ad,jd,Md,Nd,Pd,Fd,Id,Ld,Rd,zd,Bd,Vd,Hd,Ud,Wd,Gd,Kd,qd,Jd,Yd,Xd,Zd,Qd,$d=null,ef=null,tf=null,Q,$,nf,rf=!1;function af(){return Ed=document.getElementById(`workspaceCanvas`),Z=Ed.getContext(`2d`),Dd=document.getElementById(`apiStatus`),Od=document.getElementById(`addButton`),kd=document.getElementById(`fitButton`),Ad=document.getElementById(`testNodeButton`),jd=document.getElementById(`loadModelsButton`),Md=document.getElementById(`closePanelButton`),Nd=document.getElementById(`deleteNodeButton`),Pd=document.getElementById(`renameConfirmOverlay`),Fd=document.getElementById(`renameConfirmMessage`),Id=document.getElementById(`cancelRenameButton`),Ld=document.getElementById(`confirmRenameButton`),Rd=document.getElementById(`deleteConfirmOverlay`),zd=document.getElementById(`deleteConfirmMessage`),Bd=document.getElementById(`cancelDeleteButton`),Vd=document.getElementById(`confirmDeleteButton`),Hd=document.getElementById(`agentRunOverlay`),Ud=document.getElementById(`agentRunTitle`),Wd=document.getElementById(`agentRunHint`),Gd=document.getElementById(`agentRunInputField`),Kd=document.getElementById(`agentRunInput`),qd=document.getElementById(`agentRunResult`),Jd=document.getElementById(`cancelAgentRunButton`),Yd=document.getElementById(`executeAgentRunButton`),Xd=document.getElementById(`fallbackPanelHost`),Zd=document.getElementById(`configSurface`),Qd=Zd,$d=null,ef=null,tf=null,Q={name:document.getElementById(`nodeName`),kind:document.getElementById(`nodeKind`),providerIdField:document.getElementById(`providerIdField`),providerId:document.getElementById(`nodeProviderId`),copyProviderId:document.getElementById(`copyProviderIdButton`),endpoint:document.getElementById(`nodeEndpoint`),token:document.getElementById(`nodeToken`),model:document.getElementById(`nodeModel`),providerTypeChat:document.getElementById(`nodeProviderTypeChat`),providerTypeImage:document.getElementById(`nodeProviderTypeImage`),toolModeField:document.getElementById(`toolModeField`),toolModeTools:document.getElementById(`nodeToolModeTools`),toolModeChat:document.getElementById(`nodeToolModeChat`),workspaceField:document.getElementById(`agentWorkspaceField`),workspaceFolder:document.getElementById(`nodeWorkspaceFolder`),timeout:document.getElementById(`nodeTimeout`),description:document.getElementById(`nodeDescription`),typeBadge:document.getElementById(`nodeTypeBadge`),llmFields:document.getElementById(`llmFields`),mcpInventory:document.getElementById(`mcpInventory`),mcpInventoryStatus:document.getElementById(`mcpInventoryStatus`),mcpToolsList:document.getElementById(`mcpToolsList`),mcpPromptsList:document.getElementById(`mcpPromptsList`),agentSection:document.getElementById(`agentSection`),systemPrompt:document.getElementById(`nodeSystemPrompt`),requiresUserInput:document.getElementById(`nodeRequiresUserInput`),userInputDescriptionField:document.getElementById(`agentUserInputDescriptionField`),userInputDescription:document.getElementById(`nodeUserInputDescription`),expectedOutputMarker:document.getElementById(`nodeExpectedOutputMarker`)},$={entities:Tf([wf(`root`,`Living AI Documentation`,`system`,null),wf(`mcp`,`MCP`,`mcp`,`root`)]),selectedId:null,cameraX:0,cameraY:0,zoom:1,isPanning:!1,panStartX:0,panStartY:0,panStartCameraX:0,panStartCameraY:0,didPan:!1,viewAnimationId:null,dpr:window.devicePixelRatio||1,apiMode:`fallback`,lastSaveAt:null,pendingDeleteId:null,panelShiftX:0,saveTimerId:null,panelDirty:!1,isHydrated:!1},rf=!!Ed.requestPaint&&typeof Z.drawElementImage==`function`,rf?($.apiMode=`html-in-canvas`,Dd.textContent=`HTML-in-Canvas active`,Dd.classList.add(`is-live`),Ed.onpaint=Dp):(Xd.appendChild(Zd),Dd.textContent=`DOM fallback`,Dd.classList.add(`is-fallback`)),nf=new ResizeObserver(([e])=>{let t=e.devicePixelContentBoxSize&&e.devicePixelContentBoxSize[0],n=e.contentRect.width,r=e.contentRect.height;$.dpr=t?t.inlineSize/n:window.devicePixelRatio||1,Ed.width=t?t.inlineSize:Math.floor(n*$.dpr),Ed.height=t?t.blockSize:Math.floor(r*$.dpr),Nf(),Lp(!1,!$.cameraX&&!$.cameraY),Ep()}),nf.observe(Ed,{box:`device-pixel-content-box`}),of(),sf(),Od.addEventListener(`click`,()=>{Af()}),kd.addEventListener(`click`,()=>{Nf(),Lp(!0,!0),ff(),Ep()}),Ed.addEventListener(`pointerdown`,e=>{if(e.target!==Ed)return;let t=om(e),n=qp(t),r=[...$.entities].reverse().find(e=>$p(e,n));if(r){r.id!==`root`&&Gf(r.id);return}$.isPanning=!0,$.didPan=!1,$.panStartX=t.x,$.panStartY=t.y,$.panStartCameraX=$.cameraX,$.panStartCameraY=$.cameraY,Ed.classList.add(`is-panning`),Ed.setPointerCapture?.(e.pointerId)}),Ed.addEventListener(`pointermove`,e=>{if(!$.isPanning)return;let t=om(e),n=t.x-$.panStartX,r=t.y-$.panStartY;Math.hypot(n,r)>md&&($.didPan=!0),$.cameraX=$.panStartCameraX+n,$.cameraY=$.panStartCameraY+r,Ep()}),Ed.addEventListener(`pointerup`,e=>{$.isPanning&&($.isPanning=!1,Ed.classList.remove(`is-panning`),Ed.releasePointerCapture?.(e.pointerId),!$.didPan&&$.selectedId?Gf(null):$.didPan&&ff())}),Ed.addEventListener(`pointercancel`,e=>{$.isPanning=!1,Ed.classList.remove(`is-panning`),Ed.releasePointerCapture?.(e.pointerId)}),Ed.addEventListener(`wheel`,e=>{e.target===Ed&&(e.preventDefault(),Kp(om(e),Math.exp(-e.deltaY*pd)),ff())},{passive:!1}),Qd.addEventListener(`submit`,e=>{e.preventDefault(),$f(),$.lastSaveAt=new Date,Nf(),mf(!0),Ep()}),Qd.addEventListener(`input`,()=>{$f(),Nf(),$.panelDirty=!0,Ep()}),Md.addEventListener(`click`,()=>{Gf(null)}),Nd.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let t=$.selectedId,n=t?Sp(t):null;!n||Cp(t)||Kf(n)}),Bd.addEventListener(`click`,qf),Rd.addEventListener(`click`,e=>{e.target===Rd&&qf()}),Vd.addEventListener(`click`,()=>{$.pendingDeleteId&&Jf($.pendingDeleteId),qf()}),Ad.addEventListener(`click`,()=>{if(xp()?.kind===`agent`){rp();return}gp()}),jd.addEventListener(`click`,()=>{hp()}),Q.copyProviderId.addEventListener(`click`,()=>{vp()}),Q.name.addEventListener(`blur`,()=>{let e=xp();if(!e||e.kind!==`agent`)return;let t=Q.name.value.trim();if(!t||!$d||!ef||t===$d)return;let n=Df(t);n!==ef&&(Fd.textContent=`Renommer le dossier "${ef}" en "${n}" ?`,Pd.hidden=!1,Id.focus())}),Id.addEventListener(`click`,()=>{Pd.hidden=!0;let e=xp();e&&$d&&(e.label=$d,Q.name.value=$d,Nf(),Ep())}),Ld.addEventListener(`click`,()=>{Pd.hidden=!0;let e=xp();if(!e||!ef)return;e.config.workspaceFolder=ef,Q.workspaceFolder.value=ef;let t=Q.name.value.trim();t&&($d=t),ef=Df(t),ff()}),Q.model.addEventListener(`change`,()=>{Ad.disabled=!Q.model.value;let e=xp();e&&(e.config.model=Q.model.value)}),Jd.addEventListener(`click`,()=>{ip()}),Yd.addEventListener(`click`,()=>{ap()}),Hd.addEventListener(`click`,e=>{e.target===Hd&&ip()}),lf(),()=>{pf(),nf.disconnect(),$?.saveTimerId&&clearTimeout($.saveTimerId)}}function of(){for(let e of ud)Zd.addEventListener(e,cf),Xd.addEventListener(e,cf)}function sf(){for(let e of ud)Rd.addEventListener(e,cf),Pd.addEventListener(e,cf),Hd.addEventListener(e,cf)}function cf(e){e.stopPropagation()}async function lf(){let e=await Fa();e?.entities?.length&&($.entities=uf(e.entities),$.cameraX=Cf(e.camera?.x,$.cameraX),$.cameraY=Cf(e.camera?.y,$.cameraY),$.zoom=Jp(Cf(e.camera?.zoom,$.zoom),dd,fd),$.lastSaveAt=e.updatedAt?new Date(e.updatedAt):null),$.isHydrated=!0,Nf(),e?.entities?.length||Lp(!1,!0),Qf(),Ep()}function uf(e){let t=e.map(df).filter(e=>!!e),n=t.some(e=>e.id===`root`),r=t.some(e=>e.id===`mcp`),i=[...n?[]:[wf(`root`,`Living AI Documentation`,`system`,null)],...t,...r?[]:[wf(`mcp`,`MCP`,`mcp`,`root`)]],a=new Set(i.map(e=>e.id));return i.map(e=>{let t=e.id===`root`?`system`:e.id===`mcp`?`mcp`:e.kind,n=e.id===`root`?null:e.id===`mcp`?`root`:e.parentId&&a.has(e.parentId)?e.parentId:null;return{...e,kind:t,parentId:n,config:{...wf(e.id,e.label,t,n).config,...e.config}}})}function df(e){if(!vf(e))return null;let t=yf(e.id),n=yf(e.label),r=bf(e.kind);if(!t||!n||!r)return null;let i=e.parentId===null?null:yf(e.parentId),a=vf(e.config)?e.config:{};return{id:t,label:n,kind:r,parentId:i,x:Cf(e.x,0),y:Cf(e.y,0),angle:Cf(e.angle,0),config:{endpoint:yf(a.endpoint)||Ef(t,r),token:yf(a.token),model:yf(a.model),providerType:Sf(a.providerType),toolMode:xf(a.toolMode),timeout:Cf(a.timeout,180),description:yf(a.description)||kf(r),workspaceFolder:yf(a.workspaceFolder)||(r===`agent`?Df(n):``),systemPrompt:yf(a.systemPrompt),requiresUserInput:a.requiresUserInput===!0,userInputDescription:yf(a.userInputDescription),expectedOutputMarker:yf(a.expectedOutputMarker)}}}function ff(){$.isHydrated&&($.saveTimerId&&clearTimeout($.saveTimerId),$.saveTimerId=window.setTimeout(()=>{$.saveTimerId=null,mf(!1)},wd))}function pf(){$.panelDirty&&mf(!1)}async function mf(e=!1){if(!$.isHydrated)return;$.panelDirty=!1,$.saveTimerId&&(clearTimeout($.saveTimerId),$.saveTimerId=null);let t=$.selectedId&&document.activeElement===Q.token&&fp(Q.token.value)?{entityId:$.selectedId,value:Q.token.value,selectionStart:Q.token.selectionStart,selectionEnd:Q.token.selectionEnd}:null,n=await Ia(_f());if(n){if($.entities=uf(n.entities),t&&$.selectedId===t.entityId){let e=xp();e?.kind===`llm`&&(e.config.token=t.value)}$.lastSaveAt=new Date(n.updatedAt),xp()&&!Qd.contains(document.activeElement)&&Qf(),t&&$.selectedId===t.entityId&&(Q.token.value=t.value,Q.token.setSelectionRange(t.selectionStart,t.selectionEnd)),e&&gf(`Workspace saved`)}else e&&gf(`Save failed`)}function hf(e,t){return Ma(e,t)}function gf(e,t=`success`,n,r){return Na(e,t,n,r)}function _f(){return{version:1,updatedAt:new Date().toISOString(),entities:$.entities.map(e=>{let t={...e.config,token:pp(e.config.token)};return{id:e.id,label:e.label,kind:e.kind,parentId:e.parentId,x:e.x,y:e.y,angle:e.angle,config:t}}),camera:{x:$.cameraX,y:$.cameraY,zoom:$.zoom}}}function vf(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yf(e){return typeof e==`string`?e:``}function bf(e){return e===`system`||e===`llm`||e===`agent`||e===`mcp`?e:null}function xf(e){return e===`chat`?`chat`:`tools`}function Sf(e){return e===`image`?`image`:`chat`}function Cf(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function wf(e,t,n,r){return{id:e,label:t,kind:n,parentId:r,x:0,y:0,angle:0,config:{endpoint:Ef(e,n),token:``,model:``,providerType:`chat`,toolMode:`tools`,timeout:180,description:kf(n),workspaceFolder:n===`agent`?Df(t):``,systemPrompt:``,requiresUserInput:!1,userInputDescription:``,expectedOutputMarker:``}}}function Tf(e){return e.map(e=>({...e,config:{...e.config}}))}function Ef(e,t){return t===`llm`?`http://localhost:11434`:t===`mcp`?`http://localhost:4321/mcp`:``}function Df(e){return`AI/WORKSPACE/${Of(e)}`}function Of(e){return e.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`llm_provider`}function kf(e){let t={system:`Owns the documentation workspace, MCP access, providers, and agent topology.`,llm:`Routes model calls and hosts the agents assigned to this provider.`,agent:`Runs focused automation against documentation, source, or quality signals.`,mcp:`Exposes the local Living Documentation MCP consultation panel to agents.`};return t[e]||t.agent}function Af(){let e=xp(),t=e?.kind===`llm`?e:Sp(e?.parentId);if(t?.kind===`llm`&&t.config.providerType!==`image`){Mf(t.id);return}jf()}function jf(){let e=!!$.selectedId,t=wp(`root`).filter(e=>e.kind===`llm`).length+1,n=wf(`provider-${Date.now().toString(36)}`,`LLM Provider ${t}`,`llm`,`root`);$.entities=[...$.entities,n],$.selectedId=n.id,Nf(),Rp(e,!0,!0),Qf(),ff(),Ep()}function Mf(e){let t=!!$.selectedId,n=wp(e).filter(e=>e.kind===`agent`).length+1,r=wf(`agent-${Date.now().toString(36)}`,`Agent ${n}`,`agent`,e);$.entities=[...$.entities,r],$.selectedId=r.id,Nf(),Rp(t,!0,!0),Qf(),ff(),Ep()}function Nf(){let e=Sp(`root`);e.x=0,e.y=0,e.angle=0,Pf(e)}function Pf(e){let t=wp(e.id),n=Bf(t,Wu,ed,{spread:Math.PI*2,includeSubtree:!1}),r=new Map(t.map(e=>[e.id,Rf(e,n)]));for(let n=0;n<=Sd;n+=1)if(Ff(e,t,r),If(),!Lf(t,r))return;Ff(e,t,r),If()}function Ff(e,t,n){let r=Math.max(1,t.length);t.forEach((t,i)=>{let a=-Math.PI/2+i/r*Math.PI*2,o=n.get(t.id)||ed;t.angle=a,t.x=e.x+Math.cos(a)*o,t.y=e.y+Math.sin(a)*o})}function If(){for(let e of $.entities.filter(e=>e.kind===`llm`))zf(e)}function Lf(e,t){let n=!1;for(let r=0;r<e.length;r+=1)for(let i=r+1;i<e.length;i+=1){let a=e[r],o=e[i];am(nm(a),nm(o),bd)&&(t.set(a.id,Math.min(Cd,t.get(a.id)+xd)),t.set(o.id,Math.min(Cd,t.get(o.id)+xd)),n=!0)}return n}function Rf(e,t){if(e.kind!==`llm`)return t;let n=wp(e.id).length;if(n<=gd)return t;let r=(n-gd)*_d,i=Math.max(0,Uf(e)-yd)*.65;return t+Math.min(vd,Math.max(r,i))}function zf(e){let t=wp(e.id);if(!t.length)return;let n=Math.atan2(e.y,e.x),r=Vf(t.length),i=Bf(t,Gu,td,{spread:r,includeSubtree:!1});t.forEach((a,o)=>{let s=Hf(n,r,o,t.length);a.angle=s,a.x=e.x+Math.cos(s)*i,a.y=e.y+Math.sin(s)*i})}function Bf(e,t,n,r={}){if(!e.length)return n;let i=!!r.includeSubtree,a=r.spread||Math.PI*2,o=Math.max(...e.map(e=>i?Uf(e):Wf(e))),s=t+o+hd;if(e.length===1)return Math.max(n,s);let c=o*2+hd,l=a>=Math.PI*2-.001?Math.PI*2/e.length:a/(e.length-1),u=c/(2*Math.sin(l/2));return Math.max(n,s,u)}function Vf(e){return e<=1?0:e<=2?nd:e<=4?rd:e<=7?id:ad}function Hf(e,t,n,r){return r<=1||t===0?e:e-t/2+n/(r-1)*t}function Uf(e){if(e.kind!==`llm`)return Wf(e);let t=wp(e.id);return t.length?Bf(t,Gu,td,{spread:Vf(t.length),includeSubtree:!1})+Math.max(...t.map(e=>Wf(e))):Gu}function Wf(e){if(e.kind===`system`)return Wu;if(e.kind===`llm`)return Gu;let{width:t,height:n}=tm(e);return Math.hypot(t/2,n/2)}function Gf(e){e!==$.selectedId&&pf();let t=!!$.selectedId;$.selectedId=e;let n=e?Sp(e):null;$d=n?.kind===`agent`?n.label:null,ef=n?.kind===`agent`?n.config.workspaceFolder||Df(n.label):null,Nf(),Rp(t,!!e,!0),Qf(),Ep()}function Kf(e){let t=Tp(e.id),n=wp(e.id).length,r=t.length?` This node has ${n} direct child${n===1?``:`ren`} and ${t.length} total descendant${t.length===1?``:`s`}; they will also be deleted.`:` This node has no children.`;$.pendingDeleteId=e.id,zd.textContent=`You are about to delete "${e.label}".${r} This action cannot be undone.`,Rd.hidden=!1,Vd.focus()}function qf(){$.pendingDeleteId=null,Rd.hidden=!0}function Jf(e){let t=Sp(e);if(!t||Cp(e))return;let n=t.parentId||`root`,r=!!$.selectedId,i=new Set([e,...Tp(e)]);$.entities=$.entities.filter(e=>!i.has(e.id)),$.selectedId=Sp(n)?n:null,Nf(),Rp(r,!!$.selectedId,!0),Qf(),ff(),Ep()}var Yf=0;async function Xf(e){let t=++Yf,n=e.config.endpoint.trim(),r=Q.mcpInventoryStatus;if(Q.mcpToolsList.replaceChildren(),Q.mcpPromptsList.replaceChildren(),!n){r.hidden=!1,r.textContent=`Set an endpoint to load the MCP tools and prompts.`;return}r.hidden=!1,r.textContent=`Loading MCP tools and prompts…`;let i=await Ra({endpoint:n});if(t===Yf){if(!i.ok){r.hidden=!1,r.textContent=i.error?`Failed to load MCP inventory: ${i.error}`:`Failed to load MCP inventory.`;return}r.hidden=!0,Zf(Q.mcpToolsList,i.tools??[],`No tools exposed.`),Zf(Q.mcpPromptsList,i.prompts??[],`No prompts exposed.`)}}function Zf(e,t,n){if(e.replaceChildren(),t.length===0){let t=document.createElement(`li`);t.className=`inventory-empty`,t.textContent=n,e.appendChild(t);return}for(let n of t){let t=document.createElement(`li`);t.textContent=n,e.appendChild(t)}}function Qf(){let e=xp(),t=!!e;if(Zd.hidden=!t,Xd.hidden=!t||rf,!e){Od.title=`Add LLM provider`,Ad.textContent=`Test`,Ad.hidden=!0,Ad.disabled=!0;return}Q.name.value=e.label,Q.kind.value=e.kind,Q.providerId.value=e.kind===`llm`?e.id:``,Q.endpoint.value=e.config.endpoint,Q.token.value=e.config.token,np(e.config.model),Q.providerTypeChat.checked=e.config.providerType!==`image`,Q.providerTypeImage.checked=e.config.providerType===`image`,Q.toolModeTools.checked=e.config.toolMode!==`chat`,Q.toolModeChat.checked=e.config.toolMode===`chat`,Q.workspaceFolder.value=e.config.workspaceFolder,Q.workspaceField.hidden=e.kind!==`agent`,Q.timeout.value=String(e.config.timeout),Q.description.value=e.config.description,Q.typeBadge.textContent=bp(e),Q.kind.disabled=!0,Q.llmFields.hidden=e.kind===`mcp`||e.kind===`agent`,tp(e),Q.mcpInventory.hidden=e.kind!==`mcp`,e.kind===`mcp`?Xf(e):Yf+=1,Q.agentSection.hidden=e.kind!==`agent`,Q.systemPrompt.value=e.config.systemPrompt,Q.requiresUserInput.checked=e.config.requiresUserInput,ep(),Q.userInputDescription.value=e.config.userInputDescription,Q.expectedOutputMarker.value=e.config.expectedOutputMarker,Nd.hidden=Cp(e.id),Ad.textContent=`Test`,Ad.hidden=e.kind!==`llm`&&e.kind!==`agent`,Ad.disabled=e.kind===`llm`?!e.config.model:e.kind!==`agent`;let n=e.kind===`llm`?e:Sp(e.parentId);Od.title=n?.kind===`llm`&&n.config.providerType!==`image`?`Add agent`:`Add LLM provider`}function $f(){let e=xp();if(e&&(e.label=Q.name.value.trim()||`Untitled node`,e.kind=Q.kind.value,e.config.endpoint=Q.endpoint.value,e.config.token=Q.token.value,e.config.model=Q.model.value,e.config.providerType=Q.providerTypeImage.checked?`image`:`chat`,e.config.toolMode=Q.toolModeChat.checked?`chat`:`tools`,e.config.timeout=Number(Q.timeout.value||30),e.config.description=Q.description.value,e.config.systemPrompt=Q.systemPrompt.value,e.config.requiresUserInput=Q.requiresUserInput.checked,e.config.userInputDescription=Q.userInputDescription.value,e.config.expectedOutputMarker=Q.expectedOutputMarker.value,ep(),tp(e),Q.typeBadge.textContent=bp(e),e.kind===`llm`))for(let t of $.entities)t.parentId===e.id&&t.kind===`agent`&&(t.config.model=e.config.model,t.config.timeout=e.config.timeout)}function ep(){let e=xp()?.kind===`agent`&&Q.requiresUserInput.checked;Q.userInputDescriptionField.hidden=!e,Q.userInputDescription.required=e}function tp(e){let t=e.kind===`llm`,n=e.config.providerType===`image`;Q.providerIdField.hidden=!t,Q.toolModeField.hidden=!t||n,jd.title=n?`Load image models from endpoint`:`Load chat models from endpoint`,Ad.title=n?`Test image provider configuration`:`Test chat provider configuration`}function np(e){let t=Array.from(Q.model.options).map(e=>e.value);if(e&&!t.includes(e)){Q.model.innerHTML=``;let t=document.createElement(`option`);t.value=e,t.textContent=e,Q.model.appendChild(t)}Q.model.value=e||(t[0]??``)}function rp(){let e=xp();if(!e||e.kind!==`agent`)return;$f();let t=Sp(e.parentId??``);if(!t||t.kind!==`llm`){gf(`No parent LLM found for this agent.`,`error`);return}if(!t.config.model){gf(`Parent LLM has no model selected.`,`error`);return}if(!e.config.systemPrompt.trim()){gf(`Write a system prompt first.`,`error`);return}if(e.config.requiresUserInput&&!e.config.userInputDescription.trim()){gf(`Describe the required user input first.`,`error`);return}tf=e.id,Ud.textContent=`Test ${e.label}`,Wd.textContent=e.config.requiresUserInput?e.config.userInputDescription:`Run this agent with its configured system prompt.`,Gd.hidden=!e.config.requiresUserInput,Kd.required=e.config.requiresUserInput,Kd.value=``,qd.hidden=!0,qd.textContent=``,Yd.disabled=!1,Yd.textContent=`Run`,Hd.hidden=!1,e.config.requiresUserInput?window.setTimeout(()=>Kd.focus(),0):window.setTimeout(()=>Yd.focus(),0)}function ip(){Hd.hidden=!0,tf=null}async function ap(){if(Kd.required&&!Kd.value.trim()){Kd.reportValidity();return}let e=tf?Sp(tf):null;if(!e||e.kind!==`agent`){up(`error`,`The selected agent is no longer available.`);return}let t=Sp(e.parentId??``);if(!t||t.kind!==`llm`){up(`error`,`No parent LLM found for this agent.`);return}Yd.disabled=!0,Yd.textContent=`Running…`;let n=hf(`Running agent…`);sp();let r=$.entities.find(e=>e.kind===`mcp`),i=!1,a=await za({providerId:t.id,endpoint:t.config.endpoint,model:t.config.model,systemPrompt:e.config.systemPrompt,userInput:Kd.value.trim()||void 0,timeout:t.config.timeout,mcpEndpoint:t.config.toolMode===`chat`?void 0:r?.config.endpoint||void 0,toolMode:t.config.toolMode,expectedOutputMarker:e.config.expectedOutputMarker||void 0},e=>{e.type===`error`&&(i=!0),e.type!==`final`&&e.type!==`error`&&hf(op(e),n),cp(e)});Yd.disabled=!1,Yd.textContent=`Run`,a.ok&&a.content?(lp(a.content),gf(`Agent responded. Result saved in AI/WORKSPACE.`,`success`,Td,n)):(i||cp({type:`error`,message:a.error??`Agent failed.`}),qd.dataset.state=`error`,gf(a.error??`Agent failed.`,`error`,Td,n))}function op(e){return e.type===`tool_call`&&e.toolName?`Agent tool call: ${e.toolName}`:e.type===`tool_result`&&e.toolName?`Agent tool result: ${e.toolName}`:`Agent: ${e.message}`}function sp(){qd.hidden=!1,qd.dataset.state=`loading`,qd.textContent=``,cp({type:`status`,message:`Preparing agent request`})}function cp(e){qd.hidden=!1,e.type===`error`&&(qd.dataset.state=`error`);let t=document.createElement(`div`);t.className=`agent-run-event agent-run-event-${e.type.replace(`_`,`-`)}`;let n=document.createElement(`span`);n.className=`agent-run-event-dot`,n.setAttribute(`aria-hidden`,`true`);let r=document.createElement(`div`);r.className=`agent-run-event-body`;let i=document.createElement(`p`);i.className=`agent-run-event-title`,i.textContent=e.message,r.appendChild(i);let a=[];if(e.turn&&a.push(`Turn ${e.turn}`),e.toolName&&a.push(e.toolName),e.detail&&a.push(e.detail),a.length){let e=document.createElement(`p`);e.className=`agent-run-event-meta`,e.textContent=a.join(` · `),r.appendChild(e)}t.append(n,r),qd.appendChild(t),qd.scrollTop=qd.scrollHeight}function lp(e){qd.dataset.state=`success`;let t=document.createElement(`section`);t.className=`agent-run-final`;let n=document.createElement(`h3`);n.textContent=`Final response`;let r=document.createElement(`pre`);r.textContent=e,t.append(n,r),qd.appendChild(t),qd.scrollTop=qd.scrollHeight}function up(e,t){qd.hidden=!1,qd.dataset.state=e,qd.textContent=t}var dp=/^(?:env:[A-Za-z_][A-Za-z0-9_]*|\$\{[A-Za-z_][A-Za-z0-9_]*\})$/;function fp(e){let t=e.trim();return t!==``&&!dp.test(t)}function pp(e){let t=e.trim();return fp(t)?``:t}var mp=`API token must reference an environment variable, e.g. env:LLM_API_KEY`;async function hp(){let e=xp();if(!e||e.kind!==`llm`)return;$f();let t=e.config.endpoint;if(!t){gf(`Set an endpoint first.`);return}if(fp(e.config.token)){gf(mp);return}jd.classList.add(`loading`),jd.disabled=!0,Q.model.disabled=!0;let n=await La({endpoint:t,token:e.config.token,providerType:e.config.providerType});if(jd.classList.remove(`loading`),jd.disabled=!1,Q.model.disabled=!1,!n.ok||!n.models?.length){gf(n.error??`No models found.`);return}let r=Q.model.value;Q.model.innerHTML=``;for(let e of n.models){let t=document.createElement(`option`);t.value=e,t.textContent=e,Q.model.appendChild(t)}Q.model.value=n.models.includes(r)?r:n.models[0],e.config.model=Q.model.value,Ad.disabled=!Q.model.value,gf(`${n.models.length} model${n.models.length===1?``:`s`} loaded.`),Ep()}async function gp(){let e=xp();if(!e||e.kind!==`llm`)return;if($f(),fp(e.config.token)){gf(mp);return}Ad.disabled=!0,hf(`Testing ${e.config.model}…`),Ep();let t=e.config.providerType===`image`?await _p(e):await Va({endpoint:e.config.endpoint,token:e.config.token,model:e.config.model,timeout:e.config.timeout});Ad.disabled=!1,t.ok?gf(t.detail??`Connection OK`,`success`):gf(t.error||`Connection failed (${t.status||`no status`})`,`error`),Ep()}async function _p(e){let t=await La({endpoint:e.config.endpoint,token:e.config.token,providerType:`image`});if(!t.ok)return{ok:!1,error:t.error??`Image provider test failed`};let n=e.config.model.trim();return n&&t.models?.length&&!t.models.includes(n)?{ok:!1,error:`Image models loaded, but "${n}" was not found.`}:{ok:!0,detail:`${t.models?.length??0} image model${t.models?.length===1?``:`s`} available`}}async function vp(){let e=xp();if(!(!e||e.kind!==`llm`))try{await navigator.clipboard.writeText(e.id),gf(`Provider ID copied`,`success`)}catch{Q.providerId.select(),gf(`Provider ID selected`,`success`)}}function yp(e){return{system:`System`,llm:`LLM provider`,agent:`Agent`,mcp:`MCP`}[e]||`Node`}function bp(e){return e.kind===`llm`&&e.config.providerType===`image`?`Image provider`:yp(e.kind)}function xp(){return $.selectedId?Sp($.selectedId):null}function Sp(e){return $.entities.find(t=>t.id===e)}function Cp(e){return e===`root`||e===`mcp`}function wp(e){return $.entities.filter(t=>t.parentId===e)}function Tp(e){let t=[];for(let n of wp(e))t.push(n.id,...Tp(n.id));return t}function Ep(){rf?Ed.requestPaint():requestAnimationFrame(Dp)}function Dp(){let e=Ed.width/$.dpr,t=Ed.height/$.dpr;Z.reset(),Z.setTransform($.dpr,0,0,$.dpr,0,0),Z.clearRect(0,0,e,t),Z.save(),Z.translate($.cameraX,$.cameraY),Z.scale($.zoom,$.zoom),Op(e,t),kp(),Z.restore(),rf&&Ip(e,t)}function Op(e,t){Z.save(),Z.lineWidth=1/$.zoom;let n=qp({x:0,y:0}),r=qp({x:e,y:t}),i=Math.floor(n.x/qu)*qu,a=Math.ceil(r.x/qu)*qu,o=Math.floor(n.y/qu)*qu,s=Math.ceil(r.y/qu)*qu;for(let e=i;e<=a;e+=qu)Z.strokeStyle=e%Ju===0?`#d7dce5`:`#edf0f4`,um(e,o,e,s);for(let e=o;e<=s;e+=qu)Z.strokeStyle=e%Ju===0?`#d7dce5`:`#edf0f4`,um(i,e,a,e);Z.restore()}function kp(){Ap();for(let e of $.entities)jp(e)}function Ap(){Z.save(),Z.lineWidth=2/$.zoom;for(let e of $.entities){let t=Sp(e.parentId);if(!t)continue;let n=Math.atan2(e.y-t.y,e.x-t.x),r=Yp(t,n),i=Yp(e,n+Math.PI);Z.strokeStyle=Pp(e).connection,Z.beginPath(),Z.moveTo(r.x,r.y),Z.lineTo(i.x,i.y),Z.stroke()}Z.restore()}function jp(e){if(e.kind===`system`||e.kind===`llm`){Mp(e);return}Np(e)}function Mp(e){let t=e.id===$.selectedId,n=Pp(e),r=e.kind===`system`?Wu:Gu,i=wp(e.id),a=Math.max(Ku,i.length),o=sm(e.x,e.y,r,a);Z.save(),Z.beginPath(),o.forEach((e,t)=>{t===0?Z.moveTo(e.x,e.y):Z.lineTo(e.x,e.y)}),Z.closePath(),Z.fillStyle=t?n.selectedFill:n.fill,Z.strokeStyle=t?n.selectedStroke:n.stroke,Z.lineWidth=(t?3:2)/$.zoom,Z.shadowColor=n.shadow,Z.shadowBlur=e.kind===`system`?20:14,Z.shadowOffsetY=e.kind===`system`?8:5,Z.fill(),Z.shadowColor=`transparent`,Z.stroke(),Z.fillStyle=t?n.selectedText:n.text,Z.textAlign=`center`,Z.textBaseline=`middle`,Z.font=e.kind===`system`?`800 21px Inter, system-ui, sans-serif`:`800 16px Inter, system-ui, sans-serif`,lm(e.label,e.x,e.y-8,r*1.32,e.kind===`system`?26:20),Fp(e,t,r),Z.restore()}function Np(e){let t=e.id===$.selectedId,n=Pp(e),r=e.kind===`mcp`?116:Hu,i=e.kind===`mcp`?58:Uu;Z.save(),cm(e.x-r/2,e.y-i/2,r,i,20),Z.fillStyle=t?n.selectedFill:n.fill,Z.strokeStyle=t?n.selectedStroke:n.stroke,Z.lineWidth=(t?3:2)/$.zoom,Z.shadowColor=n.shadow,Z.shadowBlur=10,Z.shadowOffsetY=4,Z.fill(),Z.shadowColor=`transparent`,Z.stroke(),Z.fillStyle=t?n.selectedText:n.text,Z.font=`760 15px Inter, system-ui, sans-serif`,Z.textAlign=`center`,Z.textBaseline=`middle`,lm(e.label,e.x,e.y,r*.78,18),Fp(e,t,Math.max(r,i)/2),Z.restore()}function Pp(e){if(e.kind===`system`)return{fill:`#111827`,stroke:`#111827`,selectedFill:`#111827`,selectedStroke:`#111827`,text:`#ffffff`,selectedText:`#ffffff`,shadow:`rgb(17 24 39 / 18%)`,connection:`#475569`};if(e.kind===`llm`&&e.config.providerType===`image`)return{fill:`#facc15`,stroke:`#ca8a04`,selectedFill:`#eab308`,selectedStroke:`#a16207`,text:`#111827`,selectedText:`#111827`,shadow:`rgb(250 204 21 / 22%)`,connection:`#ca8a04`};if(e.kind===`llm`&&e.config.toolMode===`chat`)return{fill:`#f472b6`,stroke:`#db2777`,selectedFill:`#ec4899`,selectedStroke:`#be185d`,text:`#500724`,selectedText:`#500724`,shadow:`rgb(244 114 182 / 20%)`,connection:`#db2777`};if(e.kind===`llm`)return{fill:`#f97316`,stroke:`#ea580c`,selectedFill:`#fb923c`,selectedStroke:`#c2410c`,text:`#431407`,selectedText:`#431407`,shadow:`rgb(249 115 22 / 20%)`,connection:`#ea580c`};if(e.kind===`mcp`)return{fill:`#64748b`,stroke:`#475569`,selectedFill:`#475569`,selectedStroke:`#334155`,text:`#ffffff`,selectedText:`#ffffff`,shadow:`rgb(100 116 139 / 18%)`,connection:`#64748b`};if(e.kind===`agent`){let t=Sp(e.parentId);return t?.kind===`llm`&&t.config.toolMode===`chat`?{fill:`#f9a8d4`,stroke:`#f472b6`,selectedFill:`#ec4899`,selectedStroke:`#db2777`,text:`#111827`,selectedText:`#111827`,shadow:`rgb(244 114 182 / 18%)`,connection:`#f472b6`}:{fill:`#fdba74`,stroke:`#f97316`,selectedFill:`#fb923c`,selectedStroke:`#ea580c`,text:`#111827`,selectedText:`#111827`,shadow:`rgb(249 115 22 / 18%)`,connection:`#f97316`}}return{fill:`#ffffff`,stroke:`#0f172a`,selectedFill:`#111827`,selectedStroke:`#0f172a`,text:`#111827`,selectedText:`#ffffff`,shadow:`rgb(15 23 42 / 8%)`,connection:`#111827`}}function Fp(e,t,n){t&&(Z.beginPath(),Z.arc(e.x+n*.62,e.y-n*.66,5,0,Math.PI*2),Z.fillStyle=`#34d399`,Z.fill())}function Ip(e,t){if(!xp())return;let n=em(e),r=Math.min(Qu,t-118),i=e-n-24,a=Math.max(24,(t-r)/2);try{let e=Z.drawElementImage(Zd,i,a,n,r);Zd.style.transform=e.toString()}catch{Dd.textContent=`Waiting for HTML snapshot`}}function Lp(e,t){let n=Ed.clientWidth,r=Ed.clientHeight,i=xp()?em(n)+$u:0,a=Math.max(360,n-i),o=Up(),s=Wp(o,a,r),c=t?s:Math.min($.zoom,s),l=(o.minX+o.maxX)/2,u=(o.minY+o.maxY)/2,d=a*.5-l*c,f=r*.5-u*c;if(!e||!$.cameraX||!$.cameraY){Gp(),$.cameraX=d,$.cameraY=f,$.zoom=c,$.panelShiftX=i;return}$.panelShiftX=i,Hp(d,f,c)}function Rp(e,t,n){if(t){if(e){let e=zp();$.panelShiftX+=Math.max(0,-e),Vp(e,n)}else{let e=xp();if(e){let t=em(Ed.clientWidth)+$u,n=(Ed.clientWidth-t)/2-e.x*$.zoom,r=n-$.cameraX;$.panelShiftX=-r,Hp(n,$.cameraY,$.zoom)}}return}if(!e)return;let r=$.panelShiftX;$.panelShiftX=0,Vp(r,n)}function zp(){let e=xp();if(!e)return 0;let t=Ed.clientWidth-em(Ed.clientWidth)-24-ld,n=Bp(e);return n.right<=t?0:t-n.right}function Bp(e){let t=rm(e);return{left:t.left*$.zoom+$.cameraX,top:t.top*$.zoom+$.cameraY,right:t.right*$.zoom+$.cameraX,bottom:t.bottom*$.zoom+$.cameraY}}function Vp(e,t){if(Gp(),!e)return;let n=$.cameraX+e;if(!t){$.cameraX=n;return}Hp(n,$.cameraY,$.zoom)}function Hp(e,t,n){Gp();let r=$.cameraX,i=$.cameraY,a=$.zoom,o=performance.now();function s(c){let l=Math.min(1,(c-o)/sd),u=1-(1-l)**3;$.cameraX=r+(e-r)*u,$.cameraY=i+(t-i)*u,$.zoom=a+(n-a)*u,Nf(),Ep(),l<1?$.viewAnimationId=requestAnimationFrame(s):$.viewAnimationId=null}$.viewAnimationId=requestAnimationFrame(s)}function Up(){return $.entities.reduce((e,t)=>{let n=Wf(t);return{minX:Math.min(e.minX,t.x-n),minY:Math.min(e.minY,t.y-n),maxX:Math.max(e.maxX,t.x+n),maxY:Math.max(e.maxY,t.y+n)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0})}function Wp(e,t,n){let r=e.maxX-e.minX,i=e.maxY-e.minY;if(!Number.isFinite(r)||!Number.isFinite(i)||r<=0||i<=0)return 1;let a=Math.max(1,t-cd*2),o=Math.max(1,n-cd*2);return Jp(Math.min(1,a/r,o/i),dd,1)}function Gp(){$.viewAnimationId&&(cancelAnimationFrame($.viewAnimationId),$.viewAnimationId=null)}function Kp(e,t){Gp();let n=qp(e);$.zoom=Jp($.zoom*t,dd,fd),$.cameraX=e.x-n.x*$.zoom,$.cameraY=e.y-n.y*$.zoom,Ep()}function qp(e){return{x:(e.x-$.cameraX)/$.zoom,y:(e.y-$.cameraY)/$.zoom}}function Jp(e,t,n){return Math.min(n,Math.max(t,e))}function Yp(e,t){if(e.kind!==`system`&&e.kind!==`llm`)return Qp(e,t);let n=e.kind===`system`?Wu:Gu,r=wp(e.id);return Xp(e,n,Math.max(Ku,r.length),t)||{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function Xp(e,t,n,r){let i={x:Math.cos(r),y:Math.sin(r)},a=sm(e.x,e.y,t,n),o=null;for(let t=0;t<a.length;t+=1){let n=a[t],r=a[(t+1)%a.length],s={x:r.x-n.x,y:r.y-n.y},c={x:n.x-e.x,y:n.y-e.y},l=Zp(i,s);if(Math.abs(l)<1e-4)continue;let u=Zp(c,s)/l,d=Zp(c,i)/l;if(u>=0&&d>=0&&d<=1){let t={x:e.x+i.x*u,y:e.y+i.y*u};(!o||u<o.rayDistance)&&(o={...t,rayDistance:u})}}return o?{x:o.x,y:o.y}:null}function Zp(e,t){return e.x*t.y-e.y*t.x}function Qp(e,t){let n=tm(e),r=n.width/2,i=n.height/2,a=Math.cos(t),o=Math.sin(t),s=Math.min(Math.abs(r/(a||2**-52)),Math.abs(i/(o||2**-52)));return{x:e.x+a*s,y:e.y+o*s}}function $p(e,t){if(e.kind===`system`||e.kind===`llm`){let n=e.kind===`system`?Wu:Gu;return Math.hypot(t.x-e.x,t.y-e.y)<=n+od}let{width:n,height:r}=tm(e);return Math.abs(t.x-e.x)<=n/2+od&&Math.abs(t.y-e.y)<=r/2+od}function em(e){return Math.min(Xu,Math.max(Yu,Math.floor(e*Zu)))}function tm(e){return e.kind===`mcp`?{width:116,height:58}:{width:Hu,height:Uu}}function nm(e){return[e,...Tp(e.id).map(Sp)].filter(Boolean).map(rm).reduce(im)}function rm(e){if(e.kind===`system`||e.kind===`llm`){let t=e.kind===`system`?Wu:Gu;return{left:e.x-t,top:e.y-t,right:e.x+t,bottom:e.y+t}}let{width:t,height:n}=tm(e);return{left:e.x-t/2,top:e.y-n/2,right:e.x+t/2,bottom:e.y+n/2}}function im(e,t){return{left:Math.min(e.left,t.left),top:Math.min(e.top,t.top),right:Math.max(e.right,t.right),bottom:Math.max(e.bottom,t.bottom)}}function am(e,t,n){return!(e.right+n<t.left||e.left-n>t.right||e.bottom+n<t.top||e.top-n>t.bottom)}function om(e){let t=Ed.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function sm(e,t,n,r){return Array.from({length:r},(i,a)=>{let o=-Math.PI/2+a/r*Math.PI*2;return{x:e+Math.cos(o)*n,y:t+Math.sin(o)*n}})}function cm(e,t,n,r,i){let a=e+n,o=t+r;Z.beginPath(),Z.moveTo(e+i,t),Z.lineTo(a-i,t),Z.quadraticCurveTo(a,t,a,t+i),Z.lineTo(a,o-i),Z.quadraticCurveTo(a,o,a-i,o),Z.lineTo(e+i,o),Z.quadraticCurveTo(e,o,e,o-i),Z.lineTo(e,t+i),Z.quadraticCurveTo(e,t,e+i,t),Z.closePath()}function lm(e,t,n,r,i){let a=e.split(/\s+/),o=[],s=``;for(let e of a){let t=s?`${s} ${e}`:e;Z.measureText(t).width>r&&s?(o.push(s),s=e):s=t}o.push(s);let c=n-(o.length-1)*i/2;o.forEach((e,n)=>{Z.fillText(e,t,c+n*i)})}function um(e,t,n,r){Z.beginPath(),Z.moveTo(e,t),Z.lineTo(n,r),Z.stroke()}var dm=U(`<div class="status-row"><span id="apiStatus"></span></div>`),fm=U('<div class="app-shell"><!> <section class="workspace-shell" aria-label="Configuration graph workspace"><nav class="rail" aria-label="Workspace tools"><button id="addButton" class="tool-button primary" type="button" title="Add node">+</button> <button id="fitButton" class="tool-button" type="button" title="Fit view">⌖</button></nav> <canvas id="workspaceCanvas" class="workspace-canvas" layoutsubtree=""><form id="configSurface" class="config-surface" autocomplete="off"><div class="panel-kicker"><span id="nodeTypeBadge">Provider</span> <button id="closePanelButton" class="icon-button close" type="button" title="Close panel">×</button></div> <div class="panel-title-row"><label class="eyebrow" for="nodeName">Node name</label> <input id="nodeName" name="nodeName" class="title-input" type="text"/></div> <div class="form-grid"><label class="field"><span>Kind</span> <select id="nodeKind" name="nodeKind"><option>System</option><option>LLM provider</option><option>Agent</option><option>MCP</option></select></label> <div id="llmFields" class="contents"><div id="providerIdField" class="field wide"><span>Provider ID</span> <div class="model-select-wrap"><input id="nodeProviderId" name="nodeProviderId" type="text" readonly=""/> <button id="copyProviderIdButton" class="icon-button" type="button" title="Copy provider ID">⧉</button></div> <small class="field-note">Technical node id. Use it when a tool or agent workflow needs to reference this provider, for example as <code>imageProviderId</code> with <code>generate_image</code>.</small></div> <label class="field wide"><span>Endpoint</span> <input id="nodeEndpoint" name="nodeEndpoint" type="url" placeholder="http://localhost:11434"/></label> <label class="field wide"><span>API token</span> <input id="nodeToken" name="nodeToken" type="text" autocomplete="off" spellcheck="false" placeholder="env:LLM_API_KEY"/> <small class="field-note">Reference an environment variable only — <code>env:VAR_NAME</code> (or <code>{VAR_NAME}</code>). The secret is read from the server environment at request time; literal tokens are not stored (the workspace file is tracked by git).</small></label> <div class="field wide model-field-row"><span>Model</span> <div class="model-select-wrap"><select id="nodeModel" name="nodeModel"><option disabled="" selected="">— click ↻ to load models —</option></select> <button id="loadModelsButton" class="icon-button" type="button" title="Load models from endpoint">↻</button></div></div> <fieldset class="field wide tool-mode-field"><legend>Provider type</legend> <label class="radio-card"><input id="nodeProviderTypeChat" name="nodeProviderType" type="radio" value="chat"/> <span><strong>Chat completion</strong> <small>Uses OpenAI-compatible <code>/chat/completions</code>.</small></span></label> <label class="radio-card"><input id="nodeProviderTypeImage" name="nodeProviderType" type="radio" value="image"/> <span><strong>Image generation</strong> <small>Used by <code>generate_image</code> with the provider id above.</small></span></label></fieldset> <fieldset id="toolModeField" class="field wide tool-mode-field"><legend>Tool calling</legend> <label class="radio-card"><input id="nodeToolModeTools" name="nodeToolMode" type="radio" value="tools"/> <span><strong>Allow MCP tools</strong> <small>Agents can send OpenAI-compatible <code>tools</code> payloads.</small></span></label> <label class="radio-card"><input id="nodeToolModeChat" name="nodeToolMode" type="radio" value="chat"/> <span><strong>Chat only</strong> <small>Agents never send tools, even when an MCP endpoint exists.</small></span></label></fieldset> <label class="field"><span>Timeout</span> <input id="nodeTimeout" name="nodeTimeout" type="number" min="1" max="600" step="1"/></label></div> <label class="field wide"><span>Description</span> <textarea id="nodeDescription" name="nodeDescription" rows="3"></textarea></label></div> <section id="agentSection" class="agent-section" hidden=""><label id="agentWorkspaceField" class="field wide"><span>Workspace folder</span> <input id="nodeWorkspaceFolder" name="nodeWorkspaceFolder" type="text" readonly=""/></label> <label class="field wide"><span>System prompt</span> <textarea id="nodeSystemPrompt" name="nodeSystemPrompt" rows="5" placeholder="You are a helpful assistant…"></textarea></label> <label class="field wide checkbox-field"><input id="nodeRequiresUserInput" name="nodeRequiresUserInput" type="checkbox"/> <span>Require a user input</span></label> <label id="agentUserInputDescriptionField" class="field wide" hidden=""><span>Describe User input</span> <textarea id="nodeUserInputDescription" name="nodeUserInputDescription" rows="3" placeholder="Describe exactly what the user must provide before running this agent."></textarea></label> <label class="field wide"><span>Required output marker</span> <input id="nodeExpectedOutputMarker" name="nodeExpectedOutputMarker" type="text" placeholder="Optional, e.g. ```mermaid"/></label></section> <section id="mcpInventory" class="mcp-inventory" hidden=""><div class="inventory-header"><span>MCP consultation surface</span> <strong>Streamable HTTP</strong></div> <p id="mcpInventoryStatus" class="inventory-status" hidden=""></p> <div class="inventory-grid"><article><h2>Tools</h2> <ul id="mcpToolsList"></ul></article> <article><h2>Prompts</h2> <ul id="mcpPromptsList"></ul></article></div></section> <footer class="panel-actions"><div class="panel-actions-left"><button id="testNodeButton" class="secondary-button" type="button">Test</button></div> <div class="panel-actions-right"><button id="deleteNodeButton" class="danger-button" type="button">Delete</button></div></footer></form></canvas> <div id="fallbackPanelHost" class="fallback-panel-host" hidden=""></div></section> <div id="deleteConfirmOverlay" class="confirm-overlay" hidden=""><section class="confirm-dialog" role="dialog" aria-modal="true" aria-labelledby="deleteConfirmTitle"><div><p class="confirm-kicker">Destructive change</p> <h2 id="deleteConfirmTitle">Delete node?</h2> <p id="deleteConfirmMessage" class="confirm-message"></p></div> <footer class="confirm-actions"><button id="cancelDeleteButton" class="secondary-button" type="button">Cancel</button> <button id="confirmDeleteButton" class="danger-button" type="button">Delete</button></footer></section></div> <div id="renameConfirmOverlay" class="confirm-overlay" hidden=""><section class="confirm-dialog" role="dialog" aria-modal="true" aria-labelledby="renameConfirmTitle"><div><p class="confirm-kicker">Renommage de dossier</p> <h2 id="renameConfirmTitle">Renommer le dossier ?</h2> <p id="renameConfirmMessage" class="confirm-message"></p></div> <footer class="confirm-actions"><button id="cancelRenameButton" class="secondary-button" type="button">Annuler</button> <button id="confirmRenameButton" class="primary-button" type="button">Renommer</button></footer></section></div> <div id="agentRunOverlay" class="confirm-overlay" hidden=""><section class="agent-run-dialog" role="dialog" aria-modal="true" aria-labelledby="agentRunTitle"><div><p class="confirm-kicker">Agent test</p> <h2 id="agentRunTitle">Run agent</h2> <p id="agentRunHint" class="confirm-message"></p></div> <label id="agentRunInputField" class="field wide agent-run-input-field"><span>User input</span> <textarea id="agentRunInput" name="agentRunInput" rows="6" placeholder="Document ID, question, or any input for the agent…"></textarea></label> <div id="agentRunResult" class="agent-run-result" hidden=""></div> <footer class="confirm-actions"><button id="cancelAgentRunButton" class="secondary-button" type="button">Close</button> <button id="executeAgentRunButton" class="primary-button" type="button">Run</button></footer></section></div></div>');function pm(e,t){Ke(t,!0),Gi(async()=>{try{await pa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}return af()});var n=fm(),r=L(n);$a(r,{title:`Living AI Documentation`,subtitle:`Graph-native configuration workspace`,children:(e,t)=>{var n=dm(),r=L(n);gi(r,1,`status-pill `),r.textContent=`Detecting canvas API`,M(n),W(e,n)},$$slots:{default:!0}});var i=z(r,2),a=z(L(i),2),o=L(a),s=z(L(o),4),c=L(s),l=z(L(c),2),u=L(l);u.value=u.__value=`system`;var d=z(u);d.value=d.__value=`llm`;var f=z(d);f.value=f.__value=`agent`;var p=z(f);p.value=p.__value=`mcp`,M(l),M(c);var m=z(c,2),h=z(L(m),6),g=z(L(h),2),_=L(g),v=L(_);v.value=v.__value=``,M(_),Fe(2),M(g),M(h),Fe(6),M(m),Fe(2),M(s),Fe(6),M(o),M(a),Fe(2),M(i),Fe(6),M(n),W(e,n),qe()}var mm=U(`<p class="files-msg svelte-4q2lov"> </p>`),hm=U(`<p class="files-msg files-msg--error svelte-4q2lov"> </p>`),gm=U(`<p class="files-msg files-msg--empty svelte-4q2lov"> </p>`),_m=U(`<option> </option>`),vm=U(`<div class="files-toolbar svelte-4q2lov"><label for="files-folder-filter" class="svelte-4q2lov"> </label> <select id="files-folder-filter" data-testid="files-folder-filter" class="svelte-4q2lov"><option> </option><!></select></div>`),ym=U(`<span class="files-folder svelte-4q2lov"> </span> ·`,1),bm=U(`<p class="files-row-error svelte-4q2lov"> </p>`),xm=U(`<li class="files-row svelte-4q2lov"><span class="files-icon svelte-4q2lov">📎</span> <div class="files-info svelte-4q2lov"><a target="_blank" rel="noopener" class="files-name svelte-4q2lov"> </a> <div class="files-meta svelte-4q2lov"><!><!> </div> <!></div> <div class="files-actions svelte-4q2lov"><button type="button" class="files-btn svelte-4q2lov"> </button> <button type="button" class="files-btn files-btn--danger svelte-4q2lov"> </button></div></li>`),Sm=U(`<ul class="files-list svelte-4q2lov"></ul>`),Cm=U(`<!> <!>`,1),wm=U(`<!> <div class="app-shell"><!> <div class="files-page svelte-4q2lov"><!></div></div>`,1);function Tm(e,t){Ke(t,!0);let n=P(null),r=P(I([])),i=P(I([])),a=P(``),o=P(!0),s=P(``),c=P(I({})),l=P(I({})),u=P(I({})),d=N(()=>V(a)?V(r).filter(e=>e.folder===V(a)||e.folder.startsWith(V(a)+`/`)):V(r));function f(e){return e<1024?Y(`files.size_bytes`).replace(`{n}`,String(e)):e<1024*1024?Y(`files.size_kb`).replace(`{n}`,(e/1024).toFixed(1)):Y(`files.size_mb`).replace(`{n}`,(e/1024/1024).toFixed(2))}function p(e){if(!e)return``;let t=new Date(e);if(isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}async function m(){F(o,!0),F(s,``);try{let e=await fetch(`/api/files`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();F(r,Array.isArray(t.files)?t.files:[],!0),F(i,Array.isArray(t.folders)?t.folders:[],!0),V(a)&&!V(i).includes(V(a))&&F(a,``)}catch(e){F(s,Y(`files.error_load`)+(e instanceof Error?e.message:String(e)))}finally{F(o,!1)}}function h(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function g(e){let t=document.createElement(`input`);t.type=`file`,t.style.display=`none`,document.body.appendChild(t),t.addEventListener(`change`,async()=>{let r=t.files?.[0];if(t.remove(),r&&await V(n).show({kicker:Y(`files.confirm_replace_title`),title:Y(`files.confirm_replace_message`).replace(`{name}`,e.displayName||e.filename).replace(`{newName}`,r.name),message:Y(`files.confirm_replace_detail`),confirmLabel:Y(`files.replace`),cancelLabel:Y(`common.cancel`),danger:!0})){if(r.size>19922944){F(c,{...V(c),[e.filename]:Y(`files.error_replace`)+`${(r.size/1024/1024).toFixed(1)} MB (max 19 MB)`},!0);return}F(l,{...V(l),[e.filename]:!0},!0),F(c,{...V(c),[e.filename]:``},!0);try{let t=await h(r),n=await fetch(`/api/files/${encodeURIComponent(e.filename)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`HTTP ${n.status}`)}await m()}catch(t){F(c,{...V(c),[e.filename]:Y(`files.error_replace`)+(t instanceof Error?t.message:String(t))},!0)}finally{F(l,{...V(l),[e.filename]:!1},!0)}}}),t.click()}async function _(e){if(await V(n).show({kicker:Y(`files.confirm_delete_title`),title:Y(`files.confirm_delete_message`).replace(`{name}`,e.displayName||e.filename),message:Y(`files.confirm_delete_detail`),confirmLabel:Y(`files.delete`),cancelLabel:Y(`common.cancel`),danger:!0})){F(u,{...V(u),[e.filename]:!0},!0),F(c,{...V(c),[e.filename]:``},!0);try{let t=await fetch(`/api/files/${encodeURIComponent(e.filename)}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`HTTP ${t.status}`)}await m()}catch(t){F(c,{...V(c),[e.filename]:Y(`files.error_delete`)+(t instanceof Error?t.message:String(t))},!0)}finally{F(u,{...V(u),[e.filename]:!1},!0)}}}Gi(async()=>{try{await pa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}await m()});var v=wm(),y=R(v);Vi(Ul(y,{}),e=>F(n,e,!0),()=>V(n));var b=z(y,2),x=L(b);{let e=N(()=>Y(`files.title`));$a(x,{get title(){return V(e)},subtitle:``})}var S=z(x,2),C=L(S),w=e=>{var t=mm(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},T=e=>{var t=hm(),n=L(t,!0);M(t),B(()=>G(n,V(s))),W(e,t)},E=e=>{var t=gm(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`files.empty`)]),W(e,t)},D=e=>{var t=Cm(),n=R(t),r=e=>{var t=vm(),n=L(t),r=L(n,!0);M(n);var o=z(n,2),s=L(o),c=L(s,!0);M(s),s.value=s.__value=``,q(z(s),16,()=>V(i),e=>e,(e,t)=>{var n=_m(),r=L(n,!0);M(n);var i={};B(()=>{G(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),W(e,n)}),M(o);var l;bi(o),M(t),B((e,t)=>{G(r,e),G(c,t),l!==(l=V(a))&&(o.value=(o.__value=V(a))??``,yi(o,V(a)))},[()=>Y(`files.filter_label`),()=>Y(`files.filter_all`)]),H(`change`,o,e=>F(a,e.target.value,!0)),W(e,t)};K(n,e=>{V(i).length>0&&e(r)});var o=z(n,2),s=e=>{var t=gm(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`files.empty_filter`)]),W(e,t)},m=e=>{var t=Sm();q(t,21,()=>V(d),Xr,(e,t)=>{var n=xm(),r=z(L(n),2),i=L(r),a=L(i,!0);M(i);var o=z(i,2),s=L(o),d=e=>{var n=ym(),r=R(n),i=L(r,!0);M(r),Fe(),B(()=>G(i,V(t).folder)),W(e,n)};K(s,e=>{V(t).folder&&e(d)});var m=z(s),h=e=>{var n=Ur();B(e=>G(n,`${e??``} ·`),[()=>p(V(t).uploadedAt)]),W(e,n)};K(m,e=>{V(t).uploadedAt&&e(h)});var v=z(m,1,!0);M(o);var y=z(o,2),b=e=>{var n=bm(),r=L(n,!0);M(n),B(()=>G(r,V(c)[V(t).filename])),W(e,n)};K(y,e=>{V(c)[V(t).filename]&&e(b)}),M(r);var x=z(r,2),S=L(x),C=L(S,!0);M(S);var w=z(S,2),T=L(w,!0);M(w),M(x),M(n),B((e,n,r)=>{J(i,`href`,V(t).url),G(a,V(t).displayName||V(t).filename),G(v,e),S.disabled=V(l)[V(t).filename]||V(u)[V(t).filename],G(C,n),w.disabled=V(l)[V(t).filename]||V(u)[V(t).filename],G(T,r)},[()=>f(V(t).size||0),()=>V(l)[V(t).filename]?Y(`files.replacing`):Y(`files.replace`),()=>V(u)[V(t).filename]?Y(`files.deleting`):Y(`files.delete`)]),H(`click`,S,()=>g(V(t))),H(`click`,w,()=>_(V(t))),W(e,n)}),M(t),W(e,t)};K(o,e=>{V(d).length===0?e(s):e(m,-1)}),W(e,t)};K(C,e=>{V(o)?e(w):V(s)?e(T,1):V(r).length===0?e(E,2):e(D,-1)}),M(S),M(b),W(e,v),qe()}Pr([`change`,`click`]);var Em=U(`<p class="browser-msg"> </p>`),Dm=U(`<p class="browser-msg browser-msg--error"> </p>`),Om=U(`<button class="browser-row browser-row--dir"><span class="browser-row-name"> </span></button>`),km=U(`<span class="badge-added"> </span>`),Am=U(`<button class="link-btn"> </button>`),jm=U(`<div class="browser-row browser-row--file"><span class="browser-row-name"> </span> <!></div>`),Mm=U(`<!> <!>`,1),Nm=U(`<div class="file-browser"><div class="file-browser-toolbar"><button class="link-btn"> </button> <span class="file-browser-path"> </span></div> <div class="file-browser-list" data-testid="instruction-browse-list"><!></div></div>`),Pm=U(`<p class="empty-msg svelte-e5jhdq"> </p>`),Fm=U(`<button class="remove-btn"> </button>`),Im=U(`<div class="instruction-row svelte-e5jhdq"><div class="instruction-info svelte-e5jhdq"><a class="instruction-path svelte-e5jhdq"> </a> <div class="instruction-meta svelte-e5jhdq"> <!></div></div> <div class="instruction-actions svelte-e5jhdq"><span> </span> <!></div></div>`),Lm=U(`<div class="section-card svelte-e5jhdq"><div class="section-header svelte-e5jhdq"><span class="section-title svelte-e5jhdq"> </span> <div class="header-actions svelte-e5jhdq"><span class="count-label svelte-e5jhdq"> </span> <button class="secondary-button btn-sm"> </button></div></div> <!> <div class="instruction-list svelte-e5jhdq" data-testid="instruction-list"><!></div></div>`);function Rm(e,t){Ke(t,!0);let n=Wi(t,`items`,27,()=>I([])),r=P(!1),i=P(``),a=P(``),o=P(I([])),s=P(I([])),c=P(!1),l=P(!1),u=N(()=>new Set(n().map(e=>d(e.path))));function d(e){return String(e||``).split(/[/\\]/).pop()||``}function f(e){let t=encodeURIComponent(String(e||``).replace(/\.md$/i,``));return`/?doc=`+encodeURIComponent(t)}function p(e){return Y(`context.root.${e}`)}function m(e){return Y(`context.type.${e}`)}async function h(e){F(c,!0),F(l,!1);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(i,t.current,!0),F(a,t.parent||``,!0),F(o,t.dirs||[],!0),F(s,t.files||[],!0)}catch{F(l,!0)}finally{F(c,!1)}}async function g(){F(r,!V(r)),V(r)&&!V(i)&&await h((await fetch(`/api/context/orientation`).then(e=>e.json()).catch(()=>({}))).sourceRoot||``)}async function _(e){await t.onAdd(e),V(r)&&V(i)&&await h(V(i))}var v=Lm(),y=L(v),b=L(y),x=L(b,!0);M(b);var S=z(b,2),C=L(S),w=L(C);M(C);var T=z(C,2),E=L(T,!0);M(T),M(S),M(y);var D=z(y,2),ee=e=>{var t=Nm(),n=L(t),r=L(n),d=L(r,!0);M(r);var f=z(r,2),p=L(f,!0);M(f),M(n);var m=z(n,2),g=L(m),v=e=>{var t=Em(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},y=e=>{var t=Dm(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`common.cannot_read_dir`)]),W(e,t)},b=e=>{var t=Em(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`common.empty_dir`)]),W(e,t)},x=e=>{var t=Mm(),n=R(t);q(n,17,()=>V(o),Xr,(e,t)=>{var n=Om(),r=L(n),i=L(r);M(r),M(n),B(()=>G(i,`📁 ${V(t).name??``}`)),H(`click`,n,()=>h(V(t).path)),W(e,n)}),q(z(n,2),17,()=>V(s),Xr,(e,t)=>{var n=jm(),r=L(n),i=L(r);M(r);var a=z(r,2),o=e=>{var t=km(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`context.added`)]),W(e,t)},s=N(()=>V(u).has(V(t).name)),c=e=>{var n=Am(),r=L(n,!0);M(n),B(e=>G(r,e),[()=>Y(`context.add_file_action`)]),H(`click`,n,()=>_(V(t).path)),W(e,n)};K(a,e=>{V(s)?e(o):e(c,-1)}),M(n),B(()=>G(i,`📄 ${V(t).name??``}`)),W(e,n)}),W(e,t)};K(g,e=>{V(c)?e(v):V(l)?e(y,1):!V(o).length&&!V(s).length?e(b,2):e(x,-1)}),M(m),M(t),B(e=>{r.disabled=!V(a),G(d,e),G(p,V(i))},[()=>Y(`common.up`)]),H(`click`,r,()=>V(a)&&h(V(a))),W(e,t)};K(D,e=>{V(r)&&e(ee)});var O=z(D,2),te=L(O),k=e=>{var t=Pm(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`context.no_instructions`)]),W(e,t)},ne=e=>{var r=Wr();q(R(r),17,n,Xr,(e,n)=>{var r=Im(),i=L(r),a=L(i),o=L(a,!0);M(a);var s=z(a,2),c=L(s),l=z(c),u=e=>{var t=Ur();B(e=>G(t,`· ${e??``} KB`),[()=>Math.round(V(n).size/1024)]),W(e,t)};K(l,e=>{V(n).size!==null&&e(u)}),M(s),M(i);var h=z(i,2),g=L(h),_=L(g,!0);M(g);var v=z(g,2),y=e=>{var r=Fm(),i=L(r,!0);M(r),B(e=>G(i,e),[()=>Y(`common.remove`)]),H(`click`,r,()=>t.onRemove(d(V(n).path))),W(e,r)};K(v,e=>{V(n).exists&&e(y)}),M(h),M(r),B((e,t,r,i)=>{J(a,`href`,e),G(o,V(n).path),G(c,`${t??``} · ${r??``} `),gi(g,1,ui(V(n).exists?`status-ok`:`status-missing`),`svelte-e5jhdq`),G(_,i)},[()=>f(V(n).path),()=>p(V(n).root),()=>m(V(n).type),()=>V(n).exists?Y(`context.exists`):Y(`context.missing`)]),W(e,r)}),W(e,r)};K(te,e=>{n().length?e(ne,-1):e(k)}),M(O),M(v),B((e,t,r)=>{G(x,e),G(w,`${t??``}/${n().length??``}`),G(E,r)},[()=>Y(`context.instructions_title`),()=>n().filter(e=>e.exists).length,()=>V(r)?Y(`context.hide_instruction_browser`):Y(`context.add_instruction_file`)]),H(`click`,T,g),W(e,v),qe()}Pr([`click`]);var zm=U(`<span class="rules-folder svelte-1r3tey2"> </span>`),Bm=U(`<p class="empty-msg svelte-1r3tey2"> </p>`),Vm=U(`<span class="tag svelte-1r3tey2"> </span>`),Hm=U(`<div class="rule-tags svelte-1r3tey2"></div>`),Um=U(`<div class="rule-applies svelte-1r3tey2"> </div>`),Wm=U(`<article class="rule-row svelte-1r3tey2"><div class="rule-top svelte-1r3tey2"><div class="rule-title-wrap svelte-1r3tey2"><h3 class="rule-title svelte-1r3tey2"><a class="rule-link svelte-1r3tey2"> </a></h3> <a class="rule-path svelte-1r3tey2"> </a></div> <span class="severity-badge svelte-1r3tey2"> </span></div> <p class="rule-desc svelte-1r3tey2"> </p> <!> <!></article>`),Gm=U(`<div class="rules-layout svelte-1r3tey2"><div class="section-card svelte-1r3tey2"><div class="section-header svelte-1r3tey2"><span class="section-title svelte-1r3tey2" data-testid="rules-title"> </span> <!></div> <div class="rule-list svelte-1r3tey2" data-testid="rule-list"><!></div></div> <div class="section-card aside-card svelte-1r3tey2"><span class="section-title svelte-1r3tey2" data-testid="add-rule-title"> </span> <div class="field-group"><label class="field-label" for="ruleTitle"> </label> <input id="ruleTitle" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleSeverity"> </label> <select id="ruleSeverity" class="field-input"><option> </option><option> </option><option> </option></select></div> <div class="field-group"><label class="field-label" for="ruleDescription"> </label> <input id="ruleDescription" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleTags"> </label> <input id="ruleTags" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleAppliesTo"> </label> <input id="ruleAppliesTo" class="field-input"/></div> <div class="field-group"><label class="field-label" for="ruleBody"> </label> <textarea id="ruleBody" rows="7" class="field-input"></textarea></div> <button class="btn-primary" style="width:100%"> </button></div></div>`);function Km(e,t){Ke(t,!0);let n=Wi(t,`rules`,19,()=>[]),r=Wi(t,`rulesFolder`,3,``),i=P(``),a=P(`guideline`),o=P(``),s=P(``),c=P(``),l=P(``),u=P(!1);function d(e){let t=encodeURIComponent(String(e||``).replace(/\.md$/i,``));return`/?doc=`+encodeURIComponent(t)}function f(e){let t=`context.rule_severity_${e}`,n=Y(t);return n===t?e:n}function p(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}async function m(){if(V(i).trim()){F(u,!0);try{await t.onAdd({title:V(i).trim(),severity:V(a),description:V(o).trim(),tags:p(V(s)),appliesTo:p(V(c)),body:V(l).trim()}),F(i,``),F(o,``),F(s,``),F(c,``),F(l,``)}finally{F(u,!1)}}}var h=Gm(),g=L(h),_=L(g),v=L(_),y=L(v,!0);M(v);var b=z(v,2),x=e=>{var t=zm(),n=L(t,!0);M(t),B(()=>G(n,r())),W(e,t)};K(b,e=>{r()&&e(x)}),M(_);var S=z(_,2),C=L(S),w=e=>{var t=Bm(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`context.no_rules`)]),W(e,t)},T=e=>{var t=Wr();q(R(t),17,n,Xr,(e,t)=>{var n=Wm(),r=L(n),i=L(r),a=L(i),o=L(a),s=L(o,!0);M(o),M(a);var c=z(a,2),l=L(c,!0);M(c),M(i);var u=z(i,2),p=L(u,!0);M(u),M(r);var m=z(r,2),h=L(m,!0);M(m);var g=z(m,2),_=e=>{var n=Hm();q(n,21,()=>V(t).tags,Xr,(e,t)=>{var n=Vm(),r=L(n,!0);M(n),B(()=>G(r,V(t))),W(e,n)}),M(n),W(e,n)};K(g,e=>{V(t).tags?.length&&e(_)});var v=z(g,2),y=e=>{var n=Um(),r=L(n,!0);M(n),B(e=>G(r,e),[()=>V(t).appliesTo.join(`, `)]),W(e,n)};K(v,e=>{V(t).appliesTo?.length&&e(y)}),M(n),B((e,n,r)=>{J(o,`href`,e),G(s,V(t).title),J(c,`href`,n),G(l,V(t).path),G(p,r),G(h,V(t).description)},[()=>d(V(t).path),()=>d(V(t).path),()=>f(V(t).severity)]),W(e,n)}),W(e,t)};K(C,e=>{n().length?e(T,-1):e(w)}),M(S),M(g);var E=z(g,2),D=L(E),ee=L(D,!0);M(D);var O=z(D,2),te=L(O),k=L(te,!0);M(te);var ne=z(te,2);Di(ne),M(O);var A=z(O,2),re=L(A),ie=L(re,!0);M(re);var ae=z(re,2),oe=L(ae),se=L(oe,!0);M(oe),oe.value=oe.__value=`guideline`;var ce=z(oe),le=L(ce,!0);M(ce),ce.value=ce.__value=`warning`;var ue=z(ce),de=L(ue,!0);M(ue),ue.value=ue.__value=`required`,M(ae),M(A);var fe=z(A,2),pe=L(fe),me=L(pe,!0);M(pe);var he=z(pe,2);Di(he),M(fe);var ge=z(fe,2),_e=L(ge),ve=L(_e,!0);M(_e);var ye=z(_e,2);Di(ye),M(ge);var be=z(ge,2),xe=L(be),Se=L(xe,!0);M(xe);var Ce=z(xe,2);Di(Ce),M(be);var we=z(be,2),j=L(we),Te=L(j,!0);M(j);var Ee=z(j,2);yn(Ee),M(we);var De=z(we,2),Oe=L(De,!0);M(De),M(E),M(h),B((e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)=>{G(y,e),G(ee,t),G(k,n),J(ne,`placeholder`,r),G(ie,i),G(se,a),G(le,o),G(de,s),G(me,c),J(he,`placeholder`,l),G(ve,u),J(ye,`placeholder`,d),G(Se,f),J(Ce,`placeholder`,p),G(Te,m),J(Ee,`placeholder`,h),De.disabled=g,G(Oe,_)},[()=>Y(`context.rules_title`),()=>Y(`context.add_rule_title`),()=>Y(`context.rule_title_label`),()=>Y(`context.rule_title_placeholder`),()=>Y(`context.rule_severity_label`),()=>Y(`context.rule_severity_guideline`),()=>Y(`context.rule_severity_warning`),()=>Y(`context.rule_severity_required`),()=>Y(`context.rule_description_label`),()=>Y(`context.rule_description_placeholder`),()=>Y(`context.rule_tags_label`),()=>Y(`context.rule_tags_placeholder`),()=>Y(`context.rule_applies_to_label`),()=>Y(`context.rule_applies_to_placeholder`),()=>Y(`context.rule_body_label`),()=>Y(`context.rule_body_placeholder`),()=>V(u)||!V(i).trim(),()=>Y(`context.add_rule_button`)]),Ni(ne,()=>V(i),e=>F(i,e)),xi(ae,()=>V(a),e=>F(a,e)),Ni(he,()=>V(o),e=>F(o,e)),Ni(ye,()=>V(s),e=>F(s,e)),Ni(Ce,()=>V(c),e=>F(c,e)),Ni(Ee,()=>V(l),e=>F(l,e)),H(`click`,De,m),W(e,h),qe()}Pr([`click`]);var qm=U(`<p class="empty-msg svelte-1ui2b6s"> </p>`),Jm=U(`<p class="mcp-desc svelte-1ui2b6s"> </p>`),Ym=U(`<div class="mcp-schema-wrap svelte-1ui2b6s"><h4 class="mcp-schema-title svelte-1ui2b6s"> </h4> <pre class="mcp-schema-pre svelte-1ui2b6s"> </pre></div>`),Xm=U(`<div class="mcp-result svelte-1ui2b6s" data-testid="mcp-result"></div>`),Zm=U(`<details class="mcp-detail svelte-1ui2b6s"><summary class="mcp-summary svelte-1ui2b6s"> </summary> <!> <!> <div class="mcp-run-area svelte-1ui2b6s"><label class="mcp-run-label svelte-1ui2b6s"> </label> <textarea rows="4" spellcheck="false" class="field-input mcp-textarea svelte-1ui2b6s" data-testid="mcp-args"></textarea> <div class="mcp-run-footer svelte-1ui2b6s"><span class="mcp-error-text svelte-1ui2b6s" data-testid="mcp-error"> </span> <button class="btn-primary btn-sm"> </button></div> <!></div></details>`),Qm=U(`<p class="mcp-arg-desc svelte-1ui2b6s"> </p>`),$m=U(`<li class="mcp-arg-item svelte-1ui2b6s"><div class="mcp-arg-name-row svelte-1ui2b6s"><span class="mcp-arg-name svelte-1ui2b6s"> </span> <span class="mcp-arg-req svelte-1ui2b6s"> </span></div> <!></li>`),eh=U(`<div class="mcp-schema-wrap svelte-1ui2b6s"><h4 class="mcp-schema-title svelte-1ui2b6s"> </h4> <ul class="mcp-args-list svelte-1ui2b6s"></ul></div>`),th=U(`<div class="section-card svelte-1ui2b6s"><div class="section-header svelte-1ui2b6s"><span class="section-title svelte-1ui2b6s" data-testid="mcp-title"> </span> <button class="secondary-button btn-sm"> </button></div> <p class="section-desc svelte-1ui2b6s"> </p> <div class="mcp-info-grid svelte-1ui2b6s"><div class="mcp-info-cell svelte-1ui2b6s"><div class="mcp-info-label svelte-1ui2b6s"> </div> <div> </div></div> <div class="mcp-info-cell svelte-1ui2b6s"><div class="mcp-info-label svelte-1ui2b6s"> </div> <div class="mcp-info-value mono svelte-1ui2b6s"> </div></div> <div class="mcp-info-cell wide svelte-1ui2b6s"><div class="mcp-info-label svelte-1ui2b6s"> </div> <div class="mcp-info-value mono break svelte-1ui2b6s" data-testid="mcp-endpoint"> </div></div></div> <div><div class="subsection-header svelte-1ui2b6s"><span class="subsection-title svelte-1ui2b6s"> </span> <div class="subsection-actions svelte-1ui2b6s"><span class="count-label svelte-1ui2b6s"> </span> <button class="secondary-button btn-sm"> </button></div></div> <div class="mcp-items svelte-1ui2b6s" data-testid="mcp-tool-list"><!></div></div> <div><div class="subsection-header svelte-1ui2b6s"><span class="subsection-title svelte-1ui2b6s"> </span> <div class="subsection-actions svelte-1ui2b6s"><span class="count-label svelte-1ui2b6s"> </span> <button class="secondary-button btn-sm"> </button></div></div> <div class="mcp-items svelte-1ui2b6s" data-testid="mcp-prompt-list"><!></div></div></div>`);function nh(e,t){Ke(t,!0);let n=P(`-`),r=P(!1),i=P(`-`),a=P(`-`),o=P(I([])),s=P(I([])),c=P(!1),l=P(I(new Map)),u=P(I(new Map));function d(e,t){let n=V(e===`tool`?l:u);return n.has(t)||n.set(t,{argsJson:`{}`,running:!1,error:``,resultHtml:``}),n.get(t)}function f(e,t,n){let r=V(e===`tool`?l:u).get(t)??{argsJson:`{}`,running:!1,error:``,resultHtml:``};e===`tool`?F(l,new Map(V(l)).set(t,{...r,...n}),!0):F(u,new Map(V(u)).set(t,{...r,...n}),!0)}function p(e){if(!e||typeof e!=`object`)return null;if(e.type===`string`)return``;if(e.type===`number`||e.type===`integer`)return 0;if(e.type===`boolean`)return!1;if(e.type===`array`)return[];if(e.type===`object`||e.properties){let t={},n=e.properties||{};return(Array.isArray(e.required)?e.required:[]).forEach(e=>{t[e]=p(n[e])??``}),t}return null}function m(e){let t=p(e.inputSchema)??{},n=JSON.stringify(t,null,2);F(l,new Map(V(l)).set(e.name,{argsJson:n,running:!1,error:``,resultHtml:``}),!0)}function h(e){let t={};(e.arguments||[]).forEach(e=>{e.required&&(t[e.name]=``)});let n=JSON.stringify(t,null,2);F(u,new Map(V(u)).set(e.name,{argsJson:n,running:!1,error:``,resultHtml:``}),!0)}function g(e){let t=e.match(/^data:\s*(\{.*\})\s*$/m);if(!t)throw Error(e.slice(0,300)||`No MCP response body`);return JSON.parse(t[1])}async function _(e,t,n){let r=await fetch(`/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json, text/event-stream`},body:JSON.stringify({jsonrpc:`2.0`,id:e,method:t,params:n})}),i=await r.text();if(!r.ok)throw Error(i||`HTTP ${r.status}`);return g(i)}async function v(){await _(1,`initialize`,{protocolVersion:`2025-03-26`,capabilities:{},clientInfo:{name:`living-ai-documentation-context`,version:`1.0.0`}})}function y(e){return"```json\n"+JSON.stringify(e,null,2).replaceAll("```","`\\`\\`")+"\n```"}function b(e){if(typeof e!=`string`)return y(e);try{return y(JSON.parse(e))}catch{return e}}function x(e){if(typeof e==`string`)return e;if(!e||typeof e!=`object`)return String(e??``);if(e.error)return y(e.error);let t=e.result;return!t||typeof t!=`object`?y(e):Array.isArray(t.messages)?t.messages.map(e=>`${e.role?`[${e.role}]`:``}\n${b(e.content?.text??e.content??e)}`.trim()).join(`
|
|
88
88
|
|
|
89
89
|
`):Array.isArray(t.content)?t.content.map(e=>e&&e.type===`text`&&typeof e.text==`string`?b(e.text):y(e)).join(`
|
|
90
90
|
|
|
@@ -168,7 +168,7 @@ Texte`};case`link`:return{text:Se(`snip-link-text`),textFallback:Y(`snippet.link
|
|
|
168
168
|
</html>`,f=window.open(``,`_blank`);if(!f){alert(Y(`error.pdf_popup`));return}f.document.write(d),f.document.close(),t.onclose()}catch(e){alert(Y(`error.pdf_export`)+(e instanceof Error?e.message:String(e)))}finally{F(d,!1)}}let y=`px-4 py-2 text-sm border-b-2 border-blue-500 text-blue-600 dark:text-blue-400 font-semibold transition-colors`,b=`px-4 py-2 text-sm text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors`;var x=Wr(),S=R(x),C=e=>{var r=cv(),f=L(r),p=L(f),h=z(L(p),2),x=L(h,!0);M(h),M(p);var S=z(p,2),C=L(S),w=L(C,!0);M(C);var T=z(C,2),E=L(T,!0);M(T);var D=z(T,2),ee=L(D,!0);M(D),M(S);var O=z(S,2),te=e=>{var t=av(),n=L(t),r=L(n),c=e=>{var t=nv(),n=L(t,!0);M(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},l=e=>{var t=rv(),n=L(t);M(t),B(e=>G(n,`${e??``}failed to load folders`),[()=>Y(`common.error_prefix`)]),W(e,t)},u=e=>{var t=Wr();q(R(t),16,()=>V(o),e=>e,(e,t)=>{var n=iv(),r=L(n);Di(r);var i,a=z(r,2),o=L(a,!0);M(a),M(n),B(()=>{i!==(i=t)&&(r.value=(r.__value=t)??``),G(o,t)}),Ii(r,()=>V(s)[t],e=>V(s)[t]=e),W(e,n)}),W(e,t)};K(r,e=>{V(i)?e(c):V(a)?e(l,1):e(u,-1)}),M(n),M(t),W(e,t)};K(O,e=>{V(n)===`html`&&e(te)});var k=z(O,2),ne=e=>{var n=ov(),r=L(n),i=L(r,!0);M(r);var a=z(r,2),o=L(a),s=L(o,!0);M(o);var l=z(o,2),u=L(l,!0);M(l),M(a),M(n),B((e,t,n)=>{G(i,e),G(s,t),l.disabled=V(c),G(u,n)},[()=>Y(`modal.export.markdown_hint`),()=>Y(`common.cancel`),()=>V(c)?`⏳`:Y(`modal.export.markdown_btn`)]),H(`click`,o,function(...e){t.onclose?.apply(this,e)}),H(`click`,l,g),W(e,n)};K(k,e=>{V(n)===`markdown`&&e(ne)});var A=z(k,2),re=e=>{var n=sv(),r=L(n),i=L(r,!0);M(r);var a=z(r,2),o=L(a),s=L(o,!0);M(o);var c=z(o,2),d=L(c,!0);M(c);var f=z(c,2),p=L(f,!0);M(f),M(a),M(n),B((e,t,n,r)=>{G(i,e),G(s,t),c.disabled=V(l),G(d,n),f.disabled=V(u),G(p,r)},[()=>Y(`modal.export_html.hint`),()=>Y(`common.cancel`),()=>V(l)?`⏳`:Y(`modal.export_html.notion_btn`),()=>V(u)?`⏳`:Y(`modal.export_html.confluence_btn`)]),H(`click`,o,function(...e){t.onclose?.apply(this,e)}),H(`click`,c,()=>_(`notion`)),H(`click`,f,()=>_(`confluence`)),W(e,n)};K(A,e=>{V(n)===`html`&&e(re)});var ie=z(A,2),ae=e=>{var n=ov(),r=L(n),i=L(r,!0);M(r);var a=z(r,2),o=L(a),s=L(o,!0);M(o);var c=z(o,2),l=L(c,!0);M(c),M(a),M(n),B((e,t,n)=>{G(i,e),G(s,t),c.disabled=V(d),G(l,n)},[()=>Y(`modal.export.pdf_hint`),()=>Y(`common.cancel`),()=>V(d)?`⏳`:Y(`modal.export.pdf_btn`)]),H(`click`,o,function(...e){t.onclose?.apply(this,e)}),H(`click`,c,v),W(e,n)};K(ie,e=>{V(n)===`pdf`&&e(ae)}),M(f),M(r),B((e,t,r,i)=>{G(x,e),gi(C,1,ui(V(n)===`markdown`?y:b)),G(w,t),gi(T,1,ui(V(n)===`html`?y:b)),G(E,r),gi(D,1,ui(V(n)===`pdf`?y:b)),G(ee,i)},[()=>Y(`modal.export.title`),()=>Y(`modal.export.tab_markdown`),()=>Y(`modal.export.tab_html`),()=>Y(`modal.export.tab_pdf`)]),H(`click`,r,e=>{e.target===e.currentTarget&&t.onclose()}),H(`click`,C,()=>m(`markdown`)),H(`click`,T,()=>m(`html`)),H(`click`,D,()=>m(`pdf`)),W(e,r)};K(S,e=>{t.open&&e(C)}),W(e,x),qe()}Pr([`click`]);var uv=U(`<p class="px-3 py-4 text-xs text-gray-400 text-center"> </p>`),dv=U(`<p> </p>`),fv=U(`<div class="group flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><button class="flex-1 flex items-center gap-2 px-3 py-2 text-sm text-left"><span class="text-gray-400 shrink-0">📁</span> <span class="text-gray-700 dark:text-gray-300 truncate"> </span></button> <button title="Add to exclusions" class="shrink-0 text-red-400 hover:text-red-600 px-3 py-2 text-sm font-bold transition-colors">⊖</button></div>`),pv=U(`<div class="group flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><span class="flex-1 flex items-center gap-2 px-3 py-2 text-sm text-gray-500 dark:text-gray-400"><span class="shrink-0 opacity-40">📄</span> <span class="truncate font-mono"> </span></span> <button title="Add to exclusions" class="shrink-0 text-red-400 hover:text-red-600 px-3 py-2 text-sm font-bold transition-colors">⊖</button></div>`),mv=U(`<div class="border-t border-gray-200 dark:border-gray-700"><div class="flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"><button class="text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-30 disabled:pointer-events-none shrink-0">↑ Up</button> <span class="font-mono text-xs text-gray-400 dark:text-gray-500 truncate flex-1 text-right"> </span></div> <div class="divide-y divide-gray-100 dark:divide-gray-800 max-h-52 overflow-y-auto"><!></div></div>`),hv=U(`<label class="flex items-center gap-1.5 text-xs text-gray-700 dark:text-gray-300 cursor-pointer"><input type="checkbox"/> </label>`),gv=U(`<div class="group flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><button class="flex-1 flex items-center gap-2 px-3 py-2 text-sm text-left"><span class="text-gray-400 shrink-0">📁</span> <span class="text-gray-700 dark:text-gray-300 truncate"> </span></button> <button title="Exclude this folder" class="shrink-0 opacity-0 group-hover:opacity-100 text-red-400 hover:text-red-600 px-3 py-2 text-sm transition-opacity">⊖</button></div>`),_v=U(`<button class="w-full px-3 py-2 text-xs text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-950/30 text-left font-medium border-t border-gray-100 dark:border-gray-800">✓ Select: <span class="font-mono"> </span></button>`),vv=U(`<!> <!>`,1),yv=U(`<div> </div>`),bv=U(`<div> </div> <div> </div> <div> </div> <!>`,1),xv=U(`<div role="button" tabindex="0" class="flex items-center gap-2 px-3 py-1 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors"><span class="text-gray-400 dark:text-gray-600 w-5 text-right shrink-0 tabular-nums text-xs"></span> <div class="flex-1 min-w-0"><div class="flex items-center justify-between gap-1"><span class="text-gray-800 dark:text-gray-200 font-medium truncate text-xs"> </span> <span class="text-gray-400 dark:text-gray-600 tabular-nums shrink-0 text-xs"> </span></div> <div class="h-1 bg-gray-100 dark:bg-gray-800 rounded-full mt-0.5"><div class="h-1 bg-blue-400 dark:bg-blue-600 rounded-full"></div></div></div></div>`),Sv=U(`<div class="w-56 shrink-0 border-r border-gray-200 dark:border-gray-800 flex flex-col bg-white dark:bg-gray-900 overflow-hidden"><div class="px-3 py-2 text-xs text-gray-500 dark:text-gray-400 space-y-0.5 border-b border-gray-100 dark:border-gray-800"><!></div> <div class="px-3 py-2 border-b border-gray-100 dark:border-gray-800 flex items-center gap-2"><span class="text-xs text-gray-500 dark:text-gray-400 shrink-0 cursor-help"> </span> <input type="number" min="1" max="20" class="w-12 px-1.5 py-0.5 text-xs rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-800 dark:text-gray-200 focus:outline-none"/> <button class="text-xs text-blue-600 dark:text-blue-400 hover:underline"> </button></div> <p class="px-3 pt-2 pb-1 text-xs font-semibold text-gray-400 dark:text-gray-600 uppercase tracking-wider"> </p> <div class="flex-1 overflow-y-auto"></div></div>`),Cv=U(`<p class="absolute inset-0 flex items-center justify-center text-gray-400 dark:text-gray-500 text-sm animate-pulse"> </p>`),wv=U(`<div class="flex items-center gap-1 group py-0.5"><span class="text-gray-600 dark:text-gray-400 break-all font-mono flex-1 text-xs"> </span> <button title="Exclude this file" class="shrink-0 opacity-0 group-hover:opacity-100 text-red-400 hover:text-red-600 text-xs leading-none px-1 transition-opacity">⊖</button></div>`),Tv=U(`<div class="text-gray-400 text-center py-2">—</div>`),Ev=U(`<div class="w-80 shrink-0 border-l border-gray-200 dark:border-gray-800 flex flex-col bg-white dark:bg-gray-900 overflow-hidden"><div class="px-3 py-2 border-b border-gray-100 dark:border-gray-800 flex items-center justify-between"><span class="font-bold text-sm text-gray-900 dark:text-gray-100"> </span> <button class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 text-xs leading-none">✕</button></div> <p class="px-3 pt-2 pb-1 text-xs font-semibold text-gray-400 dark:text-gray-600 uppercase tracking-wider"> </p> <div class="flex-1 overflow-y-auto px-3 py-1 space-y-1 text-xs"><!></div></div>`),Dv=U(`<div class="fixed inset-0 z-50 flex flex-col bg-white dark:bg-gray-950"><div class="flex items-center justify-between px-6 h-14 border-b border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shrink-0"><h2 class="font-semibold text-base"> </h2> <button class="text-sm px-3 py-1.5 rounded-lg text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"> </button></div> <div class="border-b border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 shrink-0"><div class="flex items-center gap-3 px-6 py-3"><label class="text-xs font-medium text-gray-500 dark:text-gray-400 shrink-0"> </label> <input type="text" readonly="" spellcheck="false" class="flex-1 px-3 py-1.5 text-sm rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono cursor-default focus:outline-none"/> <button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shrink-0">📁 <span> </span></button> <button class="text-sm px-4 py-1.5 rounded-lg bg-blue-600 hover:bg-blue-700 text-white font-semibold transition-colors shrink-0"> </button></div> <div class="flex items-start gap-3 px-6 pb-2"><label class="text-xs font-medium text-gray-500 dark:text-gray-400 shrink-0 pt-1.5"> </label> <textarea rows="3" spellcheck="false" class="flex-1 px-3 py-1.5 text-sm rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 font-mono focus:outline-none focus:ring-1 focus:ring-blue-400 resize-y"></textarea> <button class="text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shrink-0">📁 <span> </span></button></div> <!> <div class="flex items-center gap-x-4 gap-y-2 px-6 pb-3 flex-wrap"><span class="text-xs font-medium text-gray-500 dark:text-gray-400 shrink-0"> </span> <label class="flex items-center gap-1.5 text-xs font-medium text-blue-600 dark:text-blue-400 cursor-pointer shrink-0"><input type="checkbox"/> </label> <!></div> <!></div> <div class="flex-1 overflow-hidden flex"><!> <div class="flex-1 relative overflow-hidden"><!> <canvas style="position: absolute; inset: 0"></canvas></div> <!></div></div>`);function Ov(e,t){Ke(t,!0);let n=new Set(`the.a.an.and.or.but.not.nor.so.yet.both.either.neither.is.are.was.were.be.been.being.have.has.had.do.does.did.will.would.shall.should.may.might.can.could.must.need.dare.ought.used.to.of.in.for.on.with.at.by.from.up.about.into.through.during.before.after.above.below.between.out.off.over.under.again.further.then.once.here.there.when.where.why.how.all.each.few.more.most.other.some.such.no.only.own.same.than.too.very.just.also.still.already.always.never.often.sometimes.usually.this.that.these.those.its.your.our.their.his.her.him.she.you.they.we.me.my.it.who.which.what.whose.whom.if.though.although.because.since.while.unless.until.whether.as.like.via.per.i.am.he.us.see.now.new.old.got.let.put.say.said.says.get.use.make.made.take.come.came.go.went.know.think.look.want.give.seem.back.down.even.much.well.good.work.tell.keep.hold.turn.move.play.live.help.run.start.off.way.too.few.show.hear.etc.eg.ie.one.two.three.four.five.six.seven.eight.nine.ten.le.la.les.un.une.des.du.de.d.l.au.aux.ce.ci.cet.cette.ces.mon.ma.mes.ton.ta.tes.son.sa.ses.notre.nos.votre.vos.leur.leurs.je.tu.il.elle.on.nous.vous.ils.elles.me.te.se.lui.y.en.qui.que.quoi.dont.où.et.ou.mais.donc.or.ni.car.si.ne.pas.plus.moins.très.bien.mal.peu.beaucoup.trop.assez.aussi.comme.pour.par.avec.sans.dans.sur.sous.entre.vers.chez.contre.avant.après.pendant.depuis.selon.malgré.sauf.est.sont.était.être.avoir.fait.faire.dit.dire.peut.pouvoir.doit.devoir.veut.vouloir.sait.savoir.va.aller.vient.venir.tout.tous.toute.toutes.autre.autres.même.chaque.quel.quelle.quels.quelles.aucun.aucune.certain.certaine.plusieurs.quelque.quelques.tel.telle.tels.telles.cela.ceci.ça.celui.celle.ceux.celles.ici.voici.voilà.alors.ainsi.encore.déjà.jamais.toujours.souvent.parfois.rien.personne.chose.fois.jour.temps.part.cas.point.lieu.monde.cependant.néanmoins.pourtant.toutefois.quand.lorsque.puisque.parce.afin.puis.lors.notamment.surtout.seulement.vraiment.enfin.ensuite.ailleurs.là.ici.voici.voilà.dont.lequel.laquelle.lesquels.lesquelles`.split(`.`)),r=new Set(`public.private.protected.static.void.class.interface.abstract.final.const.let.var.function.return.if.else.for.while.do.switch.case.break.continue.try.catch.throw.throws.finally.new.this.self.super.import.export.from.package.module.require.include.using.namespace.struct.enum.trait.impl.fn.def.func.fun.val.mut.async.await.yield.lambda.extends.implements.override.virtual.sealed.data.object.companion.where.when.match.guard.defer.go.chan.select.type.alias.as.is.in.of.with.true.false.null.nil.none.undefined.println.printf.fmt.log.print.main.args.argv.init.setup.teardown.describe.test.expect.assert.before.after.not.and.or.delete.typeof.instanceof.readonly.keyof.infer.never.unknown.declare.satisfies.get.set.add.remove.update.create.find.fetch.load.save.put.post.patch.list.map.filter.reduce.sort.merge.parse.format.convert.transform.validate.check.handle.process.execute.start.stop.reset.clear.close.open.read.write.send.receive.emit.trigger.dispatch.subscribe.unsubscribe.listen.notify.register.unregister.bind.apply.call.invoke.callback.handler.listener.middleware.interceptor.resolver.provider.consumer.producer.builder.factory.adapter.wrapper.proxy.decorator.observer.visitor.strategy.command.controller.service.repository.dao.dto.entity.model.schema.config.context.state.store.action.reducer.selector.hook.ref.effect.memo.component.module.plugin.extension.util.utils.helper.helpers.common.shared.base.default.index.app.core.lib.src.test.spec.mock.stub.fixture.impl.internal.api.sdk.client.server.request.response.status.code.error.exception.message.result.data.value.key.name.label.title.description.item.element.node.child.parent.root.container.wrapper.layout.view.page.screen.panel.header.footer.sidebar.navbar.body.content.section.row.col.column.grid.flex.block.inline.span.div.input.output.param.params.arg.option.options.props.attr.attrs.field.fields.property.properties.method.methods.string.number.boolean.integer.float.double.long.short.byte.char.array.object.map.set.list.vector.queue.stack.hash.table.tree.graph.pair.tuple.optional.nullable.void.unit.any.bool.bytes.none.int.str.bool.all.each.every.some.many.single.multi.first.last.next.prev.previous.current.old.temp.tmp.new.top.bottom.left.right.center.middle.start.end.begin.min.max.count.total.sum.avg.size.length.width.height.depth.flag.num.idx.id.uid.uuid.num.str.val.obj.arr.fn.cb.ctx.req.res.err.msg.src.dst.evt.doc.db.io.fs.os.env.sys.http.https.url.uri.path.port.host.tcp.udp.ssl.tls.html.css.json.xml.yml.yaml.csv.sql.regex.utf.ascii.rgb.rgba.hex.px.em.rem.vh.vw.auto.inherit.initial.application.file.local.source.messages.logging.alerting.programmed.offset.offsets.zone.zoned.decimal.big.integer.constructor.mapper.captor.publisher.verify.subscriber.org.edr.ack.ref.ssr.ssg.csr.isr.mockito.junit.vitest.jest.mocha.rspec.pytest.cypress.playwright.captor.spy.given.then.verify.times.never.invocation.argumentcaptor.inorder.donothing.doreturn.ippon.springframework.jakarta.javax.todo.fixme.hack.note.deprecated.experimental.eslint.prettier.typescript.javascript.java.kotlin.python.golang.rust.csharp.swift.ruby.spring.boot.javax.jakarta.hibernate.lombok.gradle.maven.webpack.vite.react.angular.vue.svelte.nuxt.express.fastapi.flask.django.rails.fiber.gin.actix.tokio.asyncio.junit.jest.mocha.pytest.rspec.docker.kubernetes.aws.gcp.azure.terraform.ansible.nginx.apache.linux.nextjs.remix.astro.sveltekit.gatsby.nuxtjs.qwik.solid.vercel.netlify.cloudflare.supabase.firebase.mongodb.postgres.prisma.drizzle.typeorm.sequelize.mongoose.redis.neon.trpc.graphql.grpc.rest.openapi.swagger.zod.yup.valibot.tailwind.shadcn.radix.headless.chakra.mantine.antd.mui.tanstack.tanstackquery.zustand.jotai.recoil.redux.mobx.storybook.cypress.playwright.vitest.turbopack.turborepo.getserversideprops.getstaticprops.getstaticpaths.generatestaticparams.generatemetadata.serveraction.revalidate.notfound.redirect.permanentredirect.unstablecache.unstablenostore.cookies.headers.userouter.usepathname.usesearchparams.useparams.useformstate.useformstatus.useoptimistic.useserveraction.classname.onclick.onchange.onsubmit.onfocus.onblur.onkeydown.onkeyup.onmousedown.onmouseup.defaultvalue.htmlfor.tabindex.strokewidth.viewbox.fillopacity.strokeopacity.pathdata.children.fragment.portal.suspense.errorboundary.strictmode.createelement.createcontext.createref.forwardref.usestate.useeffect.useref.usecontext.usememo.usecallback.usereducer.useid.usetransition.usedeferredvalue.useimperativehandle.mutex.lock.thread.goroutine.coroutine.channel.buffer.stream.pipe.observable.promise.future.completable.deferred.disposable.lifecycle.scope.annotation.attribute.metadata.reflection.generic.template.macro.preprocessor.compiler.runtime.debug.release.production.development.staging.build.deploy.lint.coverage.report.the.and.for.are.but.not.you.all.this.that.with.have.from.they.will.been.can.has.was.its.our.their.more.also.when.what.about.which.would.into.than.then.each.just.over.after.such.here.some.were.very.only`.split(`.`));function i(e){return n.has(e)||r.has(e)||e.length<3||/^\d+$/.test(e)||/^[^a-z]/.test(e)}function a(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).replace(/[_\-./]+/g,` `).toLowerCase().trim().split(/\s+/).filter(e=>e.length>=3)}function o(e){return e.toLowerCase().split(/[^a-zàâäéèêëïîôùûü]+/).filter(e=>e.length>=3)}let s=[{value:`adoc`,cat:`prose`},{value:`asciidoc`,cat:`prose`},{value:`asm`,cat:`code`},{value:`astro`,cat:`code`},{value:`avsc`,cat:`config`},{value:`bash`,cat:`code`},{value:`bat`,cat:`code`},{value:`bicep`,cat:`config`},{value:`c`,cat:`code`},{value:`cc`,cat:`code`},{value:`cfg`,cat:`config`},{value:`cjs`,cat:`code`},{value:`clj`,cat:`code`},{value:`cljs`,cat:`code`},{value:`cmake`,cat:`code`},{value:`cmd`,cat:`code`},{value:`conf`,cat:`config`},{value:`cpp`,cat:`code`},{value:`cql`,cat:`code`},{value:`cs`,cat:`code`},{value:`cshtml`,cat:`code`},{value:`css`,cat:`config`},{value:`cxx`,cat:`code`},{value:`dart`,cat:`code`},{value:`env`,cat:`config`},{value:`erb`,cat:`code`},{value:`erl`,cat:`code`},{value:`ex`,cat:`code`},{value:`exs`,cat:`code`},{value:`fish`,cat:`code`},{value:`fs`,cat:`code`},{value:`fsx`,cat:`code`},{value:`go`,cat:`code`},{value:`gql`,cat:`code`},{value:`gradle`,cat:`code`},{value:`graphql`,cat:`code`},{value:`groovy`,cat:`code`},{value:`h`,cat:`code`},{value:`hcl`,cat:`config`},{value:`hpp`,cat:`code`},{value:`hs`,cat:`code`},{value:`html`,cat:`config`},{value:`ini`,cat:`config`},{value:`java`,cat:`code`},{value:`jl`,cat:`code`},{value:`js`,cat:`code`},{value:`json`,cat:`config`},{value:`jsx`,cat:`code`,jsx:!0},{value:`kt`,cat:`code`},{value:`less`,cat:`config`},{value:`lua`,cat:`code`},{value:`m`,cat:`code`},{value:`md`,cat:`prose`,def:!0},{value:`mdx`,cat:`prose`},{value:`mjs`,cat:`code`},{value:`mk`,cat:`code`},{value:`ml`,cat:`code`},{value:`mli`,cat:`code`},{value:`mm`,cat:`code`},{value:`nim`,cat:`code`},{value:`php`,cat:`code`},{value:`pl`,cat:`code`},{value:`prisma`,cat:`code`},{value:`properties`,cat:`config`},{value:`proto`,cat:`code`},{value:`ps1`,cat:`code`},{value:`py`,cat:`code`},{value:`r`,cat:`code`},{value:`razor`,cat:`code`},{value:`rb`,cat:`code`},{value:`rs`,cat:`code`},{value:`rst`,cat:`prose`},{value:`s`,cat:`code`},{value:`scala`,cat:`code`},{value:`scss`,cat:`config`},{value:`sh`,cat:`code`},{value:`sol`,cat:`code`},{value:`sql`,cat:`code`},{value:`styl`,cat:`config`},{value:`svelte`,cat:`code`},{value:`swift`,cat:`code`},{value:`tex`,cat:`prose`},{value:`tf`,cat:`config`},{value:`tfvars`,cat:`config`},{value:`thrift`,cat:`code`},{value:`toml`,cat:`config`},{value:`ts`,cat:`code`},{value:`tsx`,cat:`code`,jsx:!0},{value:`txt`,cat:`prose`},{value:`v`,cat:`code`},{value:`vb`,cat:`code`},{value:`vue`,cat:`code`},{value:`xml`,cat:`config`},{value:`yaml`,cat:`config`},{value:`yml`,cat:`config`},{value:`zig`,cat:`code`},{value:`zsh`,cat:`code`}],c=new Set(s.filter(e=>e.cat===`prose`).map(e=>e.value)),l=new Set(s.filter(e=>e.cat===`code`).map(e=>e.value)),u=new Set(s.filter(e=>e.cat===`config`).map(e=>e.value)),d=new Set(s.filter(e=>e.jsx).map(e=>e.value));function f(e,t){let n=[];if(c.has(t)){let t=e.replace(/^\s*(import|export\s+\{[^}]*\}|export\s+\*|package|require|#include|from\s+['"][^'"]+['"]\s*(import)?)\b.*/gm,``).replace(/```[\s\S]*?```/g,` `).replace(/`[^`\n]+`/g,` `).replace(/!\[[^\]]*\]\([^)]*\)/g,` `).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/https?:\/\/\S+/g,` `).replace(/[#*_~>`|!\[\](){}=+\-]/g,` `);n.push(...o(t))}else l.has(t)?(d.has(t)&&(e=e.replace(/<\/?[A-Z][A-Za-z0-9.]*[^>]*>/g,` `),e=e.replace(/<\/?(div|span|main|section|article|aside|nav|header|footer|form|input|button|select|option|textarea|table|thead|tbody|tr|td|th|ul|ol|li|a|img|p|h[1-6]|label|figure|figcaption|picture|video|audio|canvas|svg|path|circle|rect|g|defs|use|link|meta|head|html|body|script|style|br|hr|strong|em|code|pre|blockquote|small|sub|sup)\b[^>]*>/gi,` `),e=e.replace(/\b(className|onClick|onChange|onSubmit|onFocus|onBlur|onKeyDown|onKeyUp|onMouseDown|onMouseUp|htmlFor|tabIndex|strokeWidth|viewBox|fillOpacity|strokeOpacity|defaultValue|placeholder|disabled|checked|readOnly|required|multiple|autoFocus|autoComplete|type|href|src|alt|width|height|style|key|ref)\s*=/g,` =`)),e=e.replace(/^\s*(import\s+[\w.*{},\s'"@/-]+;?|from\s+['"][^'"]+['"]\s*;?|package\s+[\w.]+;?|namespace\s+[\w.]+;?|using\s+[\w.]+;?|require\s*\(?\s*['"][^'"]+['"]\s*\)?;?)\s*$/gm,``),e.replace(/(?:\/\/|#(?!.*[{}[\]<>])| -- )\s*(.+)$/gm,(e,t)=>(n.push(...o(t)),e)),e.replace(/\/\*[\s\S]*?\*\//g,e=>(n.push(...o(e)),e)),e.replace(/"""[\s\S]*?"""|'''[\s\S]*?'''/g,e=>(n.push(...o(e)),e)),e.replace(/["'`]([A-Za-zÀ-ÿ][A-Za-zÀ-ÿ\s,.'éàèùâêîôûç]{3,})["'`]/g,(e,t)=>(n.push(...o(t)),e)),e.replace(/\b([A-Za-z][A-Za-z0-9_]{2,})\b/g,(e,t)=>(n.push(...a(t)),e))):u.has(t)&&(e.replace(/:\s*["']([^"']{3,})["']/g,(e,t)=>(n.push(...o(t)),e)),e.replace(/\b([A-Za-z][A-Za-z0-9_]{2,})\b/g,(e,t)=>(n.push(...a(t)),e)));return n.filter(e=>!i(e))}let p=P(``),m=P(``),h=P(1),g=P(``),_=P(!0),v=P(!1),y=P(I(s.map(e=>({value:e.value,label:`.`+e.value,checked:!!e.def}))));function b(){return V(y).filter(e=>e.checked).map(e=>e.value)}let x=N(()=>V(y).every(e=>e.checked)),S=P(null),C=P(null),w=P(0),T=P(null),E=P(I([])),D=P(I([])),ee=P(!1),O=P(``),te=P(0),k=P(I([]));function ne(){localStorage.setItem(`wc-exts`,JSON.stringify(b()))}function A(){let e=V(x);F(y,V(y).map(t=>({...t,checked:!e})),!0),ne()}function re(){ne()}function ie(){return new Set((V(m)||``).split(/[\n,]/).map(e=>e.trim()).filter(Boolean))}function ae(e){let t=ie();t.has(e)||(t.add(e),F(m,[...t].join(`, `),!0),localStorage.setItem(`wc-exclude`,V(m)),V(ue)&&_e(V(fe)),se())}function oe(){localStorage.setItem(`wc-exclude`,V(m)),V(ue)&&_e(V(fe)),se()}function se(){V(ee)&&V(O)&&Me(V(O))}function ce(){V(S)&&je()}function le(){let e=localStorage.getItem(`wc-root`);e&&(F(p,e,!0),F(xe,e,!0));let t=localStorage.getItem(`wc-exclude`);t&&F(m,t,!0);let n=localStorage.getItem(`wc-exts`);if(n)try{let e=JSON.parse(n);F(y,V(y).map(t=>({...t,checked:e.includes(t.value)})),!0)}catch{}}let ue=P(!1),de=P(null),fe=P(``),pe=P(``),me=P(null),he=P(``);function ge(){F(ue,!V(ue)),V(ue)&&_e(V(fe)||V(p)||`/`)}async function _e(e){F(me,null),F(he,`Loading…`);try{let t=await fetch(`/api/browse?all=1&path=`+encodeURIComponent(e)).then(e=>e.json());F(fe,t.current,!0),F(de,t.parent,!0),F(pe,t.current,!0);let n=V(p).trim(),r=(e,t)=>n&&e.startsWith(n+`/`)?e.slice(n.length+1):t,i=ie(),a=(t.dirs||[]).filter(e=>!i.has(r(e.path,e.name))).map(e=>({kind:`dir`,name:e.name,path:e.path,entry:r(e.path,e.name)})),o=b(),s=(t.files||[]).filter(e=>o.some(t=>e.name.endsWith(`.`+t))).filter(e=>!i.has(r(e.path,e.name))).map(e=>({kind:`file`,name:e.name,entry:r(e.path,e.name)})),c=[...a,...s];F(me,c,!0),F(he,c.length?``:`Empty directory`,!0)}catch{F(me,[],!0),F(he,`Cannot read directory`)}}function ve(){V(de)&&_e(V(de))}let ye=P(!1),be=P(null),xe=P(``),Se=P(``),Ce=P(null),we=P(``);function j(){F(ye,!V(ye)),V(ye)&&Te(V(xe)||V(p)||`/`)}async function Te(e){F(Ce,null),F(we,`Loading…`);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(xe,t.current,!0),F(be,t.parent,!0),F(Se,t.current,!0),F(Ce,(t.dirs||[]).map(e=>({name:e.name,path:e.path})),!0),F(we,V(Ce).length?``:`No sub-folders`,!0)}catch{F(Ce,[],!0),F(we,`Cannot read directory`)}}function Ee(){V(be)&&Te(V(be))}function De(){F(p,V(xe),!0),localStorage.setItem(`wc-root`,V(xe)),F(ye,!1),F(m,``),localStorage.removeItem(`wc-exclude`),F(fe,V(xe),!0)}let Oe=P(null),ke=P(null),Ae=P(!1);function je(){if(!V(S)||!V(C))return;let e=Math.max(1,V(h)||1),t=[...V(S).entries()].sort((e,t)=>t[1]-e[1]),n=t.filter(([t])=>(V(C).get(t)||new Set).size>=e).slice(0,150);if(!n.length){let n=t.length;F(g,n?`${n} domain word(s) found but none appear in ${e}+ file(s). Lower the "Min files" threshold to 1.`:`No domain words extracted. Try adding more file extensions or a broader folder.`,!0),F(_,!0),F(Ae,!1),F(v,!1);return}let r=[...V(S).keys()].filter(t=>(V(C).get(t)||new Set).size>=e).length;F(T,{scanned:V(w),unique:r,shown:n.length},!0);let i=n.slice(0,50),a=i[0][1];F(D,i.map(([e,t])=>({word:e,freq:t,pct:Math.round(t/a*100)})),!0),F(v,!0),F(_,!1);let o=document.documentElement.classList.contains(`dark`),s=o?[`#60a5fa`,`#34d399`,`#f9a8d4`,`#a78bfa`,`#fbbf24`,`#6ee7b7`,`#93c5fd`,`#fb923c`,`#4ade80`,`#f472b6`]:[`#1d4ed8`,`#047857`,`#7c3aed`,`#b45309`,`#be123c`,`#0369a1`,`#4338ca`,`#c2410c`,`#15803d`,`#9333ea`];requestAnimationFrame(()=>{if(!V(Oe)||!V(ke))return;let e=V(Oe),t=V(ke);e.width=Math.max(400,t.offsetWidth),e.height=Math.max(300,t.offsetHeight),e.style.width=e.width+`px`,e.style.height=e.height+`px`,F(Ae,!0);let n=Math.sqrt(e.width*e.height/(800*500)),r=Math.min(220,Math.round(72*n)),c=i.map(([e,t])=>[e,Math.max(12,Math.round(r*t/a))]);window.WordCloud?.(e,{list:c,gridSize:Math.round(4*e.width/1024),fontFamily:`ui-sans-serif, system-ui, sans-serif`,color:()=>s[Math.floor(Math.random()*s.length)],backgroundColor:o?`#030712`:`#ffffff`,rotateRatio:.2,minSize:6,shrinkToFit:!0,click:e=>Me(e[0])})})}function Me(e){if(!V(C)||!V(S))return;let t=[...V(C).get(e)||[]].sort(),n=V(S).get(e)||0;F(O,e,!0),F(te,n,!0),F(k,t,!0),F(ee,!0)}function Ne(){F(ee,!1)}async function Pe(){let e=V(p).trim();if(!e){F(g,`Please select a root folder first.`),F(_,!0);return}let t=b();if(!t.length){F(g,`Please select at least one extension.`),F(_,!0);return}F(ye,!1),F(v,!1),F(ee,!1),F(g,`Reading files…`),F(_,!0),F(Ae,!1);try{let n=V(m).trim(),r=n?n.split(/[\n,]/).map(e=>e.trim()).filter(Boolean):[];localStorage.setItem(`wc-exclude`,n);let i=new URLSearchParams({path:e});t.forEach(e=>i.append(`ext`,e)),r.forEach(e=>i.append(`exclude`,e));let a=await fetch(`/api/wordcloud?`+i);if(!a.ok){F(g,`Error: `+((await a.json()).error||a.statusText));return}let{files:o,fileTexts:s}=await a.json();F(g,`Analyzing ${o} file(s)…`);let c=new Map,l=new Map,u=new Set;F(w,o,!0);for(let{path:e,text:t}of s){let n=(e.split(`.`).pop()||``).toLowerCase();n&&u.add(n);let r=f(t,n),i=new Set;for(let t of r)c.set(t,(c.get(t)||0)+1),i.has(t)||(i.add(t),l.has(t)||l.set(t,new Set),l.get(t).add(e))}F(S,c,!0),F(C,l,!0),F(E,[...u].sort().map(e=>`.`+e),!0),je()}catch(e){F(g,`Error: `+e.message)}}let Fe=!1;kn(()=>{t.open&&!Fe?(Fe=!0,F(g,`Choose a root folder and click Launch.`),F(_,!0),F(Ae,!1),F(v,!1),F(ee,!1),F(S,null),F(C,null),F(T,null),F(D,[],!0),F(ye,!1),F(ue,!1),F(h,1),le(),V(p)||fetch(`/api/config`).then(e=>e.json()).then(e=>{e.docsFolder&&(F(p,e.docsFolder,!0),F(xe,e.docsFolder,!0))}).catch(()=>{})):t.open||(Fe=!1)});var Ie=Wr(),Le=R(Ie),Re=e=>{var n=Dv(),r=L(n),i=L(r),a=L(i,!0);M(i);var o=z(i,2),s=L(o,!0);M(o),M(r);var c=z(r,2),l=L(c),u=L(l),d=L(u,!0);M(u);var f=z(u,2);Di(f);var b=z(f,2),S=z(L(b)),C=L(S,!0);M(S),M(b);var w=z(b,2),ne=L(w,!0);M(w),M(l);var ie=z(l,2),se=L(ie),le=L(se,!0);M(se);var fe=z(se,2);yn(fe);var xe=z(fe,2),je=z(L(xe)),Fe=L(je,!0);M(je),M(xe),M(ie);var Ie=z(ie,2),Le=e=>{var t=mv(),n=L(t),r=L(n),i=z(r,2),a=L(i,!0);M(i),M(n);var o=z(n,2),s=L(o),c=e=>{var t=uv(),n=L(t,!0);M(t),B(()=>G(n,V(he))),W(e,t)},l=e=>{var t=dv(),n=L(t,!0);M(t),B(()=>{gi(t,1,`px-3 py-3 text-xs ${V(he)===`Cannot read directory`?`text-red-400`:`text-gray-400`} text-center`),G(n,V(he))}),W(e,t)},u=e=>{var t=Wr();q(R(t),17,()=>V(me),Xr,(e,t)=>{var n=Wr(),r=R(n),i=e=>{var n=fv(),r=L(n),i=z(L(r),2),a=L(i,!0);M(i),M(r);var o=z(r,2);M(n),B(()=>G(a,V(t).name)),H(`click`,r,()=>_e(V(t).path)),H(`click`,o,()=>ae(V(t).entry)),W(e,n)},a=e=>{var n=pv(),r=L(n),i=z(L(r),2),a=L(i,!0);M(i),M(r);var o=z(r,2);M(n),B(()=>G(a,V(t).name)),H(`click`,o,()=>ae(V(t).entry)),W(e,n)};K(r,e=>{V(t).kind===`dir`?e(i):e(a,-1)}),W(e,n)}),W(e,t)};K(s,e=>{V(me)===null?e(c):V(me).length===0?e(l,1):e(u,-1)}),M(o),M(t),B(()=>{r.disabled=!V(de),G(a,V(pe))}),H(`click`,r,ve),W(e,t)};K(Ie,e=>{V(ue)&&e(Le)});var Re=z(Ie,2),ze=L(Re),Be=L(ze,!0);M(ze);var Ve=z(ze,2),He=L(Ve);Di(He);var Ue=z(He);M(Ve),q(z(Ve,2),17,()=>V(y),e=>e.value,(e,t,n)=>{var r=hv(),i=L(r);Di(i);var a=z(i);M(r),B(()=>G(a,` ${V(t).label??``}`)),H(`change`,i,re),Ii(i,()=>V(t).checked,e=>V(t).checked=e),W(e,r)}),M(Re);var We=z(Re,2),Ge=e=>{var t=mv(),n=L(t),r=L(n),i=z(r,2),a=L(i,!0);M(i),M(n);var o=z(n,2),s=L(o),c=e=>{var t=uv(),n=L(t,!0);M(t),B(()=>G(n,V(we))),W(e,t)},l=e=>{var t=vv(),n=R(t),r=e=>{var t=dv(),n=L(t,!0);M(t),B(()=>{gi(t,1,`px-3 py-3 text-xs ${V(we)===`Cannot read directory`?`text-red-400`:`text-gray-400`} text-center`),G(n,V(we))}),W(e,t)},i=e=>{var t=Wr();q(R(t),17,()=>V(Ce),Xr,(e,t)=>{var n=gv(),r=L(n),i=z(L(r),2),a=L(i,!0);M(i),M(r);var o=z(r,2);M(n),B(()=>G(a,V(t).name)),H(`click`,r,()=>Te(V(t).path)),H(`click`,o,()=>ae(V(t).name)),W(e,n)}),W(e,t)};K(n,e=>{V(Ce).length===0?e(r):e(i,-1)});var a=z(n,2),o=e=>{var t=_v(),n=z(L(t)),r=L(n,!0);M(n),M(t),B(()=>G(r,V(Se))),H(`click`,t,De),W(e,t)};K(a,e=>{V(we)!==`Cannot read directory`&&e(o)}),W(e,t)};K(s,e=>{V(Ce)===null?e(c):e(l,-1)}),M(o),M(t),B(()=>{r.disabled=!V(be),G(a,V(Se))}),H(`click`,r,Ee),W(e,t)};K(We,e=>{V(ye)&&e(Ge)}),M(c);var Ke=z(c,2),qe=L(Ke),Je=e=>{var t=Sv(),n=L(t),r=L(n),i=e=>{var t=bv(),n=R(t),r=L(n);M(n);var i=z(n,2),a=L(i);M(i);var o=z(i,2),s=L(o);M(o);var c=z(o,2),l=e=>{var t=yv(),n=L(t);M(t),B((e,r)=>{J(t,`title`,e),G(n,`${V(E).length??``} extension${V(E).length>1?`s`:``} found (${r??``})`)},[()=>V(E).join(`, `),()=>V(E).join(`, `)]),W(e,t)};K(c,e=>{V(E).length&&e(l)}),B(()=>{G(r,`${V(T).scanned??``} file(s) scanned`),G(a,`${V(T).unique??``} unique domain words`),G(s,`${V(T).shown??``} shown`)}),W(e,t)};K(r,e=>{V(T)&&e(i)}),M(n);var a=z(n,2),o=L(a),s=L(o,!0);M(o);var c=z(o,2);Di(c);var l=z(c,2),u=L(l,!0);M(l),M(a);var d=z(a,2),f=L(d,!0);M(d);var p=z(d,2);q(p,21,()=>V(D),Xr,(e,t,n)=>{var r=xv(),i=L(r);i.textContent=n+1;var a=z(i,2),o=L(a),s=L(o),c=L(s,!0);M(s);var l=z(s,2),u=L(l,!0);M(l),M(o);var d=z(o,2),f=L(d);M(d),M(a),M(r),B(()=>{G(c,V(t).word),G(u,V(t).freq),vi(f,`width:${V(t).pct??``}%`)}),H(`click`,r,()=>Me(V(t).word)),W(e,r)}),M(p),M(t),B((e,t,n,r,i,a)=>{J(o,`title`,e),G(s,t),J(c,`title`,n),J(l,`title`,r),G(u,i),G(f,a)},[()=>Y(`wc.min_files_hint`),()=>Y(`wc.min_files_label`),()=>Y(`wc.min_files_hint`),()=>Y(`wc.apply_hint`),()=>Y(`wc.apply_btn`),()=>Y(`wc.top_words`)]),Ni(c,()=>V(h),e=>F(h,e)),H(`click`,l,ce),W(e,t)};K(qe,e=>{V(v)&&e(Je)});var Ye=z(qe,2),Xe=L(Ye),Ze=e=>{var t=Cv(),n=L(t,!0);M(t),B(()=>G(n,V(g))),W(e,t)};K(Xe,e=>{V(_)&&e(Ze)});var Qe=z(Xe,2);let $e;Vi(Qe,e=>F(Oe,e),()=>V(Oe)),M(Ye),Vi(Ye,e=>F(ke,e),()=>V(ke));var et=z(Ye,2),tt=e=>{var t=Ev(),n=L(t),r=L(n),i=L(r);M(r);var a=z(r,2);M(n);var o=z(n,2),s=L(o,!0);M(o);var c=z(o,2),l=L(c),u=e=>{var t=Wr();q(R(t),17,()=>V(k),Xr,(e,t)=>{var n=wv(),r=L(n),i=L(r,!0);M(r);var a=z(r,2);M(n),B(()=>G(i,V(t))),H(`click`,a,()=>ae(V(t))),W(e,n)}),W(e,t)},d=e=>{W(e,Tv())};K(l,e=>{V(k).length?e(u):e(d,-1)}),M(c),M(t),B(e=>{G(i,`${V(O)??``} ×${V(te)??``}`),G(s,e)},[()=>Y(`wc.found_in`)]),H(`click`,a,Ne),W(e,t)};K(et,e=>{V(ee)&&e(tt)}),M(Ke),M(n),B((e,t,n,r,i,o,c,l,u,f)=>{G(a,e),G(s,t),G(d,n),G(C,r),G(ne,i),G(le,o),J(fe,`placeholder`,c),G(Fe,l),G(Be,u),ki(He,V(x)),G(Ue,` ${f??``}`),$e=gi(Qe,1,``,null,$e,{hidden:!V(Ae)})},[()=>Y(`wc.title`),()=>Y(`wc.close_btn`),()=>Y(`wc.search_root_label`),()=>Y(`wc.browse_btn`),()=>Y(`wc.launch_btn`),()=>Y(`wc.exclude_label`),()=>Y(`wc.exclude_placeholder`),()=>Y(`wc.browse_btn`),()=>Y(`wc.extensions_label`),()=>Y(`wc.all_btn`)]),H(`click`,o,function(...e){t.onclose?.apply(this,e)}),Ni(f,()=>V(p),e=>F(p,e)),H(`click`,b,j),H(`click`,w,Pe),H(`input`,fe,oe),Ni(fe,()=>V(m),e=>F(m,e)),H(`click`,xe,ge),H(`change`,He,A),W(e,n)};K(Le,e=>{t.open&&e(Re)}),W(e,Ie),qe()}Pr([`click`,`input`,`change`]);var kv=U(`<button class="ghost-button"><i class="fa-solid fa-cloud"></i></button> <button title="Toggle dark mode" class="ghost-button" aria-label="Toggle dark mode"> </button>`,1),Av=U(`<div class="relative hidden sm:block"><input type="search" class="w-56 pl-8 pr-3 py-1.5 text-sm rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"/> <span class="absolute left-2.5 top-2 text-gray-400 text-sm pointer-events-none">🔍</span></div>`),jv=U(`<p class="p-8 text-red-500"> </p>`),Mv=U(`<div class="h-full flex items-center justify-center p-8"><div class="max-w-md text-center"><div class="text-5xl mb-4 select-none" aria-hidden="true">📚</div> <h2 class="text-xl font-semibold text-gray-700 dark:text-gray-300 mb-2"> </h2> <p class="text-sm text-gray-500 dark:text-gray-500"> </p> <p class="mt-4 text-xs text-gray-400 dark:text-gray-600 font-mono bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 inline-block"> </p> <p class="mt-2 text-xs text-gray-400"> </p></div></div>`),Nv=U(`<div class="app-shell bg-gray-50 text-gray-900 dark:bg-gray-900 dark:text-gray-100"><!> <div class="flex overflow-hidden"><!> <main id="home-content-area" class="flex-1 overflow-y-auto"><!></main></div></div> <!> <!> <!> <!>`,1);function Pv(e,t){Ke(t,!0);let n=P(!1),r=P(!1),i=P(!1),a=P(!1),o=P(null),s=P(!1),c=P(``),l=P(!1),u=P(`Living AI Documentation`),d=P(`YYYY_MM_DD_HH_mm_[Category]_title.md`),f=null;function p(){try{let e=localStorage.getItem(`ld-dark`);if(e!==null)return e===`true`}catch{}return window.matchMedia(`(prefers-color-scheme: dark)`).matches}function m(e){F(l,e,!0),document.documentElement.classList.toggle(`dark`,e)}function h(){m(!V(l));try{localStorage.setItem(`ld-dark`,String(V(l)))}catch{}}kn(()=>{let e=document.getElementById(`hljs-dark`),t=document.getElementById(`hljs-light`);if(!e||!t)return;let n=X.codeBlockLightTheme&&!V(l);e.disabled=n,t.disabled=!n,document.body.classList.toggle(`ld-code-light`,n)});function g(e){let t=e.trim();if(f&&clearTimeout(f),!t){X.searchQuery=``,X.searchResults=null;return}X.searchQuery=t,X.searchResults=X.allDocs.filter(e=>e.title.toLowerCase().includes(t.toLowerCase())||e.category.toLowerCase().includes(t.toLowerCase())),f=window.setTimeout(async()=>{try{let e=await ph(t);t===X.searchQuery&&(X.searchResults=e)}catch{}},350)}let _=P(I([]));function v(e){let t=V(_)[e];t&&(F(_,V(_).slice(0,e),!0),y(t.id,!1,`restore`))}async function y(e,t=!1,n=!1,r=null){if(n===!0&&X.currentDocId&&X.currentDocId!==e){let t=V(_).findIndex(t=>t.id===e);if(t!==-1)F(_,V(_).slice(0,t),!0);else{let e=X.allDocs.find(e=>e.id===X.currentDocId);F(_,[...V(_),{id:X.currentDocId,title:e?e.title:X.currentDocId}],!0)}}else n||F(_,[],!0);X.currentDocId=e;let i=X.allDocs.find(t=>t.id===e);if(i&&X.revealDoc(i),!t){let t=new URL(location.href);t.searchParams.set(`doc`,e),t.hash=r?`#${r}`:``,history.pushState({docId:e,anchor:r||null},``,t)}F(s,!0),F(c,``);try{let t=await lh(e);t.id=e,F(o,t,!0),document.title=t.title,requestAnimationFrame(()=>{let e=document.getElementById(`home-content-area`);if(r){let t=document.getElementById(r);t&&e&&(e.scrollTop+=t.getBoundingClientRect().top-e.getBoundingClientRect().top-80)}else e&&(e.scrollTop=0)})}catch(e){F(c,Y(`doc.failed_to_load`)+(e instanceof Error?e.message:String(e)))}finally{F(s,!1)}}async function b(e){if(!V(o))return;let t=V(o).id,n=await fetch(`/api/documents/`+t,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:e})});if(!n.ok)throw Error(await n.text());let r=await lh(t);r.id=t,F(o,r,!0);let i=e.match(/\]\(\s*\.?\/files\/[^)\s]+/g),a={...X.fileAttachmentCounts};i&&i.length?a[t]=i.length:delete a[t],X.fileAttachmentCounts=a}function x(e){let t=X.allDocs.find(t=>t.id===e);if(!t)return null;let n=(t.folder||[]).join(`/`),r=e=>(e.folder||[]).join(`/`)===n,i=X.hideCategories?X.allDocs.filter(r).slice().sort((e,t)=>(e.filename||``).localeCompare(t.filename||``)):X.allDocs.filter(e=>r(e)&&e.category===t.category),a=i.findIndex(t=>t.id===e);if(a===-1)return null;let o=i[a+1]??i[a-1];return o?o.id:null}async function S(){if(!V(o))return;let e=V(o).id;if(!(await fetch(`/api/documents/`+encodeURIComponent(e),{method:`DELETE`})).ok)return;let t=x(e);X.allDocs=X.allDocs.filter(t=>t.id!==e),Array.isArray(X.searchResults)&&(X.searchResults=X.searchResults.filter(t=>t.id!==e));let n={...X.annotationCounts};delete n[e],X.annotationCounts=n;let r={...X.fileAttachmentCounts};delete r[e],X.fileAttachmentCounts=r,t?await y(t):(X.currentDocId=null,F(o,null),history.pushState({},``,location.pathname))}async function C(){let[e,t]=await Promise.all([sh(),oh()]);if(X.allDocs=e,t.docsFolder)try{X.allFolderPaths=await ch(t.docsFolder)}catch{X.allFolderPaths=[]}let[n,r,i]=await Promise.all([uh(),dh(),fh()]);X.annotationCounts=n,X.fileAttachmentCounts=r,X.docStatuses=i}Gi(async()=>{m(p());let e=await oh();await pa(e.language||`en`),e.title&&(document.title=e.title,F(u,e.title,!0)),e.filenamePattern&&F(d,e.filenamePattern+`.md`),X.exclusiveFolderExpansion=!!e.exclusiveFolderExpansion,X.exclusiveCategoryExpansion=!!e.exclusiveCategoryExpansion,X.codeBlockMaxHeight=typeof e.codeBlockMaxHeight==`number`?e.codeBlockMaxHeight:400,X.imageRoundedCorners=!!e.imageRoundedCorners,X.imageCentered=!!e.imageCentered,X.imageBorder=!!e.imageBorder,X.codeBlockLightTheme=!!e.codeBlockLightTheme,X.codeBlockMaxHeight>0&&document.documentElement.style.setProperty(`--ld-code-max-h`,X.codeBlockMaxHeight+`px`),X.expandedCategories.size===0&&(X.expandedCategories=new Set([`General`])),await C();let t=new URLSearchParams(location.search).get(`doc`);if(t)y(t,!0,!1,location.hash?location.hash.slice(1):null);else{let e=X.allDocs.find(e=>e.category===`General`)??X.allDocs[0];e&&y(e.id,!0)}let n=e=>{let t=e.state?.docId||new URLSearchParams(location.search).get(`doc`),n=e.state?.anchor||(location.hash.length>1?location.hash.slice(1):null);t&&y(t,!0,!1,n)};window.addEventListener(`popstate`,n);let r=()=>{C()};return window.addEventListener(`ld:documents-changed`,r),()=>{window.removeEventListener(`popstate`,n),window.removeEventListener(`ld:documents-changed`,r)}});var w=Nv(),T=R(w),E=L(T);$a(E,{get title(){return V(u)},subtitle:``,actions:e=>{var t=kv(),n=R(t),r=z(n,2),i=L(r,!0);M(r),B((e,t)=>{J(n,`title`,e),J(n,`aria-label`,t),G(i,V(l)?`☀`:`☾`)},[()=>Y(`nav.word_cloud`),()=>Y(`nav.word_cloud`)]),H(`click`,n,()=>F(a,!0)),H(`click`,r,h),W(e,t)},children:(e,t)=>{var n=Av(),r=L(n);Di(r),Fe(2),M(n),B(e=>{J(r,`placeholder`,e),Oi(r,X.searchQuery)},[()=>Y(`nav.search_placeholder`)]),H(`input`,r,e=>g(e.target.value)),W(e,n)},$$slots:{actions:!0,default:!0}});var D=z(E,2),ee=L(D);zh(ee,{onopen:e=>y(e),onsearch:g,onexport:()=>F(i,!0),onnewfolder:()=>F(n,!0),onnewdoc:()=>F(r,!0)});var O=z(ee,2),te=L(O),k=e=>{var t=Wr(),n=R(t),r=e=>{var t=jv(),n=L(t,!0);M(t),B(()=>G(n,V(c))),W(e,t)},i=e=>{F_(e,{get doc(){return V(o)},get navHistory(){return V(_)},ongoback:v,onopen:(e,t)=>y(e,!1,!0,t),onsave:b,ondelete:S})};K(n,e=>{V(c)?e(r):e(i,-1)}),W(e,t)},ne=e=>{var t=Mv(),n=L(t),r=z(L(n),2),i=L(r,!0);M(r);var a=z(r,2),o=L(a,!0);M(a);var s=z(a,2),c=L(s,!0);M(s);var l=z(s,2),u=L(l,!0);M(l),M(n),M(t),B((e,t,n)=>{G(i,e),G(o,t),G(c,V(d)),G(u,n)},[()=>Y(`welcome.title`),()=>Y(`welcome.hint`),()=>Y(`welcome.pattern_hint`)]),W(e,t)};K(te,e=>{V(o)?e(k):e(ne,-1)}),M(O),M(D),M(T);var A=z(T,2);K_(A,{get open(){return V(n)},onclose:()=>F(n,!1),onsuccess:C});var re=z(A,2);tv(re,{get open(){return V(r)},onclose:()=>F(r,!1),onsuccess:async e=>{await C(),y(e)}});var ie=z(re,2);lv(ie,{get open(){return V(i)},onclose:()=>F(i,!1)}),Ov(z(ie,2),{get open(){return V(a)},onclose:()=>F(a,!1)}),W(e,w),qe()}Pr([`click`,`input`]);var Fv=`modulepreload`,Iv=function(e){return`/`+e},Lv={},Rv=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,new URL(`../../../src/node/plugins/importAnalysisBuild.ts`,import.meta.url)).href}r=o(t.map(t=>{if(t=Iv(t,n),t=s(t),t in Lv)return;Lv[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Fv,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},zv=U(`<div class="flex flex-col h-screen overflow-hidden bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100"><header class="flex items-center gap-1 px-2 h-12 shrink-0 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-sm z-10"><button class="tool-btn !w-auto px-2 text-xs font-medium text-gray-500 dark:text-gray-400"> </button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnSidebar" class="tool-btn">☰</button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnCopyDiagramId" class="tool-btn"><svg width="15" height="15" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="5" width="8" height="9" rx="1.5"></rect><path d="M3 11V3a1 1 0 0 1 1-1h7"></path></svg></button> <button id="toolSelect" class="tool-btn tool-active"><svg width="11" height="13" viewBox="0 0 11 13" fill="currentColor" stroke="none"><path d="M1 1 L1 12 L4 9 L6.5 13 L8 12.2 L5.5 8.2 L10 8.2 Z"></path></svg></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="toolBox" class="tool-btn"><svg width="15" height="10" viewBox="0 0 15 10" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1" y="1" width="13" height="8" rx="1"></rect></svg></button> <button id="toolEllipse" class="tool-btn"><svg width="16" height="10" viewBox="0 0 16 10" fill="none" stroke="currentColor" stroke-width="1.5"><ellipse cx="8" cy="5" rx="7" ry="4"></ellipse></svg></button> <button id="toolDatabase" class="tool-btn"><svg width="12" height="16" viewBox="0 0 12 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><ellipse cx="6" cy="3" rx="5" ry="2"></ellipse><path d="M1 3v10c0 1.1 2.2 2 5 2s5-.9 5-2V3"></path><path d="M11 7.5c0 1.1-2.2 2-5 2s-5-.9-5-2"></path></svg></button> <button id="toolCircle" class="tool-btn"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="6.5" cy="6.5" r="5.5"></circle></svg></button> <button id="toolActor" class="tool-btn"><svg width="12" height="17" viewBox="0 0 12 17" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><circle cx="6" cy="3" r="2.2"></circle><line x1="6" y1="5.2" x2="6" y2="10"></line><line x1="1.5" y1="7.5" x2="10.5" y2="7.5"></line><line x1="6" y1="10" x2="2.5" y2="15"></line><line x1="6" y1="10" x2="9.5" y2="15"></line></svg></button> <button id="toolPostIt" class="tool-btn"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.4"><path d="M1 1 H9 L12 4 V12 H1 Z"></path><path d="M9 1 V4 H12" stroke-opacity="0.5"></path></svg></button> <button id="toolTextFree" class="tool-btn" style="font-size:11px; font-weight:600;">T</button> <button id="toolImage" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="1" width="12" height="12" rx="1.5"></rect><circle cx="4.5" cy="4.5" r="1.2"></circle><path d="M1 9.5 L4 6.5 L6.5 9 L9 7 L13 10.5"></path></svg></button> <a href="/shape-editor" class="tool-btn">✦</a> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="toolArrow" class="tool-btn">→</button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnDelete" class="tool-btn"><svg width="11" height="11" viewBox="0 0 11 11" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="1" y1="1" x2="10" y2="10"></line><line x1="10" y1="1" x2="1" y2="10"></line></svg></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnDiagramDefaults" class="tool-btn"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492M5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0"></path><path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.474l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115z"></path></svg></button> <button id="btnAlign" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4"><line x1="0.5" y1="7.5" x2="13.5" y2="7.5"></line><line x1="3.5" y1="0.5" x2="3.5" y2="13.5" stroke-dasharray="1.5 1.5"></line><line x1="10.5" y1="0.5" x2="10.5" y2="13.5" stroke-dasharray="1.5 1.5"></line></svg></button> <button id="btnGrid" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.2"><line x1="5" y1="1" x2="5" y2="13"></line><line x1="9" y1="1" x2="9" y2="13"></line><line x1="1" y1="5" x2="13" y2="5"></line><line x1="1" y1="9" x2="13" y2="9"></line><rect x="1" y="1" width="12" height="12" rx="1"></rect></svg></button> <button id="btnEdgeStraight" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><line x1="2" y1="12" x2="12" y2="2"></line><polyline points="8,2 12,2 12,6"></polyline></svg></button> <button id="btnEvidenceMode" class="tool-btn"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M4 1.5 H8.5 L11 4 V12.5 H4 Z"></path><path d="M8.5 1.5 V4 H11"></path><path d="M1.5 5.5 H6.5"></path><path d="M1.5 8 H6.5"></path><path d="M1.5 10.5 H5"></path></svg></button> <button id="btnResizeMode" class="tool-btn active-tool"><svg id="icon-resize-corner" width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="1" width="12" height="12" stroke-dasharray="2.5 2"></rect><line x1="4" y1="4" x2="10" y2="10"></line><polyline points="7,10 10,10 10,7"></polyline></svg> <svg id="icon-resize-center" width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="hidden"><rect x="1" y="1" width="12" height="12" stroke-dasharray="2.5 2"></rect><line x1="4" y1="4" x2="10" y2="10"></line><polyline points="4,6.5 4,4 6.5,4"></polyline><polyline points="10,7.5 10,10 7.5,10"></polyline><line x1="10" y1="4" x2="4" y2="10"></line><polyline points="7.5,4 10,4 10,6.5"></polyline><polyline points="4,7.5 4,10 6.5,10"></polyline></svg></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <input id="diagramTitle" type="text" class="flex-1 min-w-0 px-2 py-1 text-sm bg-transparent border-0 focus:outline-none focus:ring-1 focus:ring-blue-500 rounded text-gray-700 dark:text-gray-300 placeholder:text-gray-400"/> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnZoomOut" class="tool-btn">−</button> <span id="zoomLevel" class="text-xs text-gray-500 dark:text-gray-400 w-10 text-center tabular-nums select-none">100%</span> <button id="btnZoomIn" class="tool-btn">+</button> <button id="btnZoomReset" class="tool-btn">⊡</button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnDark" class="tool-btn"><span id="darkIcon">☽</span></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnDebug" class="hidden tool-btn text-xs font-mono">dbg</button> <div id="sepDebug" class="hidden w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnExportDrawio" class="tool-btn"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg></button> <div class="w-px h-6 bg-gray-200 dark:bg-gray-700 mx-0.5"></div> <button id="btnSave" disabled="" class="px-3 py-1.5 text-xs font-semibold rounded-lg bg-blue-600 hover:bg-blue-700 text-white disabled:opacity-40 disabled:cursor-not-allowed shrink-0 transition-colors"><span> </span></button></header> <div class="flex flex-1 overflow-hidden"><div id="sidebar" class="w-56 shrink-0 border-r border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 flex flex-col overflow-hidden" style="transition: width 0.2s ease"><div class="flex items-center justify-between px-3 py-2 border-b border-gray-200 dark:border-gray-700 shrink-0"><span class="text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider"> </span> <button id="btnNewDiagram" class="text-xs font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors"> </button></div> <div id="diagramList" class="flex-1 overflow-y-auto py-1"></div></div> <div role="separator" aria-orientation="vertical"></div> <div class="relative flex-1 overflow-hidden bg-gray-50 dark:bg-gray-950"><div id="vis-canvas" class="w-full h-full"></div> <div id="customShapeBar" class="hidden"><div id="customShapeBarBody"></div></div> <div id="debugLayer"></div> <div id="evidenceLayer" class="hidden"></div> <div id="stampOverlay" style="position:absolute;inset:0;display:none;z-index:11;cursor:crosshair;"></div> <div id="selectionOverlay"><div id="rh-tl" class="resize-handle" style="top: -5px; left: -5px; cursor: nw-resize"></div> <div id="rh-tr" class="resize-handle" style="top: -5px; right: -5px; cursor: ne-resize"></div> <div id="rh-bl" class="resize-handle" style="bottom: -5px; left: -5px; cursor: sw-resize"></div> <div id="rh-br" class="resize-handle" style="bottom: -5px; right: -5px; cursor: se-resize"></div> <div id="rh-rotate">↻</div> <div id="rh-label-rotate" style="left: 0; top: -28px;"><svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><g transform="rotate(25,5,5)"><line x1="2.5" y1="3" x2="7.5" y2="3"></line><line x1="5" y1="3" x2="5" y2="8"></line></g></svg></div></div> <aside id="evidencePanel" class="hidden absolute top-0 right-0 bottom-0 w-80 max-w-[85vw] z-30 bg-gray-50 dark:bg-gray-900 border-l border-gray-200 dark:border-gray-700 shadow-xl flex flex-col"><div class="flex items-center justify-between gap-2 px-4 py-3 border-b border-gray-200 dark:border-gray-700"><h2 id="evidencePanelTitle" class="text-sm font-semibold text-gray-800 dark:text-gray-100"> </h2> <button id="btnEvidenceClose" class="tool-btn !w-7 !h-7">×</button></div> <div id="evidencePanelBody" class="flex-1 overflow-y-auto p-3 space-y-3"></div></aside> <div id="nodePanel" class="float-panel hidden"><button id="btnNodeLock" class="tool-btn !w-6 !h-6 text-sm">🔒</button> <div class="panel-sep"></div> <div id="nodePanelControls" class="contents"><button id="nodeColorSwatch" style="width:1.5rem;height:1.5rem;border-radius:0.25rem;border:2px solid #a8a29e;background:#f5f5f4;cursor:pointer;flex-shrink:0;"></button> <div class="panel-sep"></div> <input id="nodeBgOpacity" type="range" min="0" max="100" step="5" value="100" class="w-16 h-1 accent-orange-500 cursor-pointer"/> <div class="panel-sep"></div> <button id="btnNodeLabelEdit" class="tool-btn !w-6 !h-6">✎</button> <button id="btnNodeLink" class="tool-btn !w-6 !h-6"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7.5a3.5 3.5 0 0 0 5 0l1.5-1.5a3.5 3.5 0 0 0-5-5L5 2.5"></path><path d="M8 5.5a3.5 3.5 0 0 0-5 0L1.5 7a3.5 3.5 0 0 0 5 5L8 10.5"></path></svg></button> <div class="panel-sep"></div> <button id="btnNodeFontDecrease" class="tool-btn !w-8 !h-6" style="font-size: 10px">Aa−</button> <span id="nodeFontSizeValue" class="inline-flex items-center justify-center min-w-[2.25rem] h-6 px-1 text-[11px] font-mono text-gray-700 dark:text-gray-200 border border-gray-300 dark:border-gray-600 rounded bg-white/80 dark:bg-gray-800/80">13</span> <button id="btnNodeFontIncrease" class="tool-btn !w-8 !h-6" style="font-size: 10px">Aa+</button> <div class="panel-sep"></div> <button id="btnAlignLeft" class="tool-btn !w-6 !h-6"><svg width="12" height="10" viewBox="0 0 12 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><line x1="1" y1="2" x2="11" y2="2"></line><line x1="1" y1="5" x2="7" y2="5"></line><line x1="1" y1="8" x2="9" y2="8"></line></svg></button> <button id="btnAlignCenter" class="tool-btn !w-6 !h-6"><svg width="12" height="10" viewBox="0 0 12 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><line x1="1" y1="2" x2="11" y2="2"></line><line x1="2.5" y1="5" x2="9.5" y2="5"></line><line x1="1.5" y1="8" x2="10.5" y2="8"></line></svg></button> <button id="btnAlignRight" class="tool-btn !w-6 !h-6"><svg width="12" height="10" viewBox="0 0 12 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><line x1="1" y1="2" x2="11" y2="2"></line><line x1="5" y1="5" x2="11" y2="5"></line><line x1="3" y1="8" x2="11" y2="8"></line></svg></button> <div class="panel-sep"></div> <button id="btnValignTop" class="tool-btn !w-6 !h-6"><svg width="10" height="12" viewBox="0 0 10 12" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="1" y1="1.5" x2="9" y2="1.5" stroke-width="2"></line><line x1="1" y1="5" x2="8" y2="5" stroke-width="1.3"></line><line x1="1" y1="8.5" x2="6" y2="8.5" stroke-width="1.3"></line></svg></button> <button id="btnValignMiddle" class="tool-btn !w-6 !h-6"><svg width="10" height="12" viewBox="0 0 10 12" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="1" y1="2.5" x2="8" y2="2.5" stroke-width="1.3"></line><line x1="1" y1="6" x2="9" y2="6" stroke-width="2"></line><line x1="1" y1="9.5" x2="6" y2="9.5" stroke-width="1.3"></line></svg></button> <button id="btnValignBottom" class="tool-btn !w-6 !h-6"><svg width="10" height="12" viewBox="0 0 10 12" fill="none" stroke="currentColor" stroke-linecap="round"><line x1="1" y1="3.5" x2="8" y2="3.5" stroke-width="1.3"></line><line x1="1" y1="7" x2="6" y2="7" stroke-width="1.3"></line><line x1="1" y1="10.5" x2="9" y2="10.5" stroke-width="2"></line></svg></button> <div class="panel-sep"></div> <div id="customShapeLabelPlacementControls" class="hidden"><button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="above">T↑</button> <button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="below">T↓</button> <button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="left">←T</button> <button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="right">T→</button> <button class="tool-btn !w-7 !h-6 font-mono text-[10px]" data-label-placement="center">T□</button> <div class="panel-sep"></div></div> <button id="btnZOrderBack" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="5" width="8" height="8" rx="1"></rect><rect x="5" y="1" width="8" height="8" rx="1" stroke-opacity="0.35"></rect></svg></button> <button id="btnZOrderFront" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="1" y="5" width="8" height="8" rx="1" stroke-opacity="0.35"></rect><rect x="5" y="1" width="8" height="8" rx="1"></rect></svg></button> <div class="panel-sep"></div> <button id="btnStampColor" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M7 2 C7 2 3 6.5 3 9 a4 4 0 0 0 8 0 C11 6.5 7 2 7 2 Z" fill="currentColor" fill-opacity="0.25"></path></svg></button> <button id="btnStampFontSize" class="tool-btn !w-7 !h-6 font-mono text-xs font-bold">Aa</button> <button id="btnStampSize" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="4" width="6" height="6" rx="0.8" fill="currentColor" fill-opacity="0.25"></rect><path d="M10 2 L12 2 L12 4"></path><path d="M12 2 L9 5"></path><path d="M10 12 L12 12 L12 10"></path><path d="M12 12 L9 9"></path></svg></button> <div class="panel-sep"></div> <button id="btnRotateCCW" class="tool-btn !w-7 !h-6" style="font-size:15px; line-height:1;">↺</button> <button id="btnRotateCW" class="tool-btn !w-7 !h-6" style="font-size:15px; line-height:1;">↻</button> <div class="panel-sep"></div> <button id="btnCopyPng" class="tool-btn !h-6 px-1.5 font-mono text-xs font-semibold flex items-center gap-0.5"><svg width="10" height="10" viewBox="0 0 10 10" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="7" x2="5" y2="1"></line><polyline points="2,4 5,1 8,4"></polyline><line x1="1" y1="9" x2="9" y2="9"></line></svg> PNG</button> <div class="panel-sep"></div> <button id="btnGroup" class="tool-btn !w-8 !h-7"><svg width="22" height="14" viewBox="0 0 22 14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"><rect x="0.7" y="1" width="20.6" height="12" rx="2" stroke-dasharray="2.5,1.5"></rect><rect x="4" y="4.5" width="3" height="5" rx="1" fill="currentColor"></rect><rect x="15" y="4.5" width="3" height="5" rx="1" fill="currentColor"></rect></svg></button> <button id="btnUngroup" class="tool-btn !w-8 !h-7"><svg width="26" height="14" viewBox="0 0 26 14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"><rect x="0.7" y="1" width="9" height="12" rx="2" stroke-dasharray="2.5,1.5"></rect><rect x="3" y="4.5" width="3" height="5" rx="1" fill="currentColor"></rect><rect x="16.3" y="1" width="9" height="12" rx="2" stroke-dasharray="2.5,1.5"></rect><rect x="19" y="4.5" width="3" height="5" rx="1" fill="currentColor"></rect></svg></button> <div class="panel-sep"></div> <button id="btnSaveShapeDefault" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492M5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0"></path><path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.474l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115z"></path></svg></button></div></div> <div id="linkPanel" class="float-panel hidden" style="min-width:260px; flex-direction:column; align-items:stretch; gap:0.5rem; padding:0.75rem;"><div class="text-xs font-semibold text-gray-500 dark:text-gray-400 mb-1"> </div> <label class="flex items-center gap-2 text-xs cursor-pointer"><input type="radio" name="linkType" id="linkTypeUrl" value="url" class="accent-orange-500"/> <span> </span></label> <div id="linkUrlRow"><input id="linkUrlInput" type="url" class="w-full text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-orange-400"/></div> <label class="flex items-center gap-2 text-xs cursor-pointer"><input type="radio" name="linkType" id="linkTypeDiagram" value="diagram" class="accent-orange-500"/> <span> </span></label> <div id="linkDiagramRow" class="hidden"><select id="linkDiagramSelect" class="w-full text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-orange-400"></select></div> <label class="flex items-center gap-2 text-xs cursor-pointer"><input type="radio" name="linkType" id="linkTypeNew" value="new" class="accent-orange-500"/> <span> </span></label> <div id="linkNewRow" class="hidden"><input id="linkNewName" type="text" class="w-full text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-orange-400"/></div> <div class="flex gap-1 mt-1"><button id="btnLinkSave" class="flex-1 text-xs bg-orange-500 hover:bg-orange-600 text-white rounded px-2 py-1"> </button> <button id="btnLinkRemove" class="text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-600"> </button> <button id="btnLinkCancel" class="text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 hover:bg-gray-100 dark:hover:bg-gray-700">✕</button></div></div> <div id="edgePanel" class="float-panel hidden"><button id="btnEdgeLock" class="tool-btn !w-6 !h-6 text-sm">🔒</button> <div class="panel-sep"></div> <div id="edgePanelControls" class="contents"><button id="edgeBtnNone" class="tool-btn !w-7 !h-6 font-mono text-xs">—</button> <button id="edgeBtnFrom" class="tool-btn !w-7 !h-6 text-xs">←</button> <button id="edgeBtnTo" class="tool-btn !w-7 !h-6 text-xs">→</button> <button id="edgeBtnBoth" class="tool-btn !w-8 !h-6 text-xs">←→</button> <div class="panel-sep"></div> <button id="edgeBtnSolid" class="tool-btn !w-8 !h-6"><svg width="22" height="4" viewBox="0 0 22 4"><line x1="1" y1="2" x2="21" y2="2" stroke="currentColor" stroke-width="2" stroke-linecap="round"></line></svg></button> <button id="edgeBtnDashed" class="tool-btn !w-8 !h-6"><svg width="22" height="4" viewBox="0 0 22 4"><line x1="1" y1="2" x2="21" y2="2" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-dasharray="4,3"></line></svg></button> <div class="panel-sep"></div> <button id="btnEdgeFontDecrease" class="tool-btn !w-8 !h-6" style="font-size: 10px">Aa−</button> <span id="edgeFontSizeValue" class="inline-flex items-center justify-center min-w-[2.25rem] h-6 px-1 text-[11px] font-mono text-gray-700 dark:text-gray-200 border border-gray-300 dark:border-gray-600 rounded bg-white/80 dark:bg-gray-800/80">11</span> <button id="btnEdgeFontIncrease" class="tool-btn !w-8 !h-6" style="font-size: 10px">Aa+</button> <div class="panel-sep"></div> <button id="btnEdgeLabelEdit" class="tool-btn !w-6 !h-6">✎</button> <button id="btnEdgeLabelWidthReset" class="tool-btn !w-6 !h-6 text-xs">↔</button> <div class="panel-sep"></div> <button id="btnEdgeLabelRotateCCW" class="tool-btn !w-7 !h-6 text-sm">↺</button> <button id="btnEdgeLabelRotateCW" class="tool-btn !w-7 !h-6 text-sm">↻</button> <div class="panel-sep"></div> <button id="btnEdgeLabelOffsetLeft" class="tool-btn !w-6 !h-6 text-sm">←</button> <button id="btnEdgeLabelOffsetRight" class="tool-btn !w-6 !h-6 text-sm">→</button> <button id="btnEdgeLabelOffsetUp" class="tool-btn !w-6 !h-6 text-sm">↑</button> <button id="btnEdgeLabelOffsetDown" class="tool-btn !w-6 !h-6 text-sm">↓</button> <button id="btnEdgeLabelOffsetReset" class="tool-btn !w-6 !h-6 text-xs">⊙</button> <div class="panel-sep"></div> <button id="btnEdgeWidthDecrease" class="tool-btn !w-7 !h-6" style="font-size:10px">W−</button> <button id="btnEdgeWidthIncrease" class="tool-btn !w-7 !h-6" style="font-size:10px">W+</button> <div class="panel-sep"></div> <button id="edgeColorSwatch" style="width:1.5rem;height:1.5rem;border-radius:0.25rem;border:2px solid #a8a29e;background:#a8a29e;cursor:pointer;flex-shrink:0;"></button> <div class="panel-sep"></div> <button id="btnEdgeClearPorts" class="tool-btn !w-8 !h-6 text-xs">⊗</button> <div class="panel-sep"></div> <button id="btnSaveEdgeDefault" class="tool-btn !w-7 !h-6"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492M5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0"></path><path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52zm-2.633.283c.246-.835 1.428-.835 1.674 0l.094.319a1.873 1.873 0 0 0 2.693 1.115l.291-.16c.764-.415 1.6.42 1.184 1.185l-.159.292a1.873 1.873 0 0 0 1.116 2.692l.318.094c.835.246.835 1.428 0 1.674l-.319.094a1.873 1.873 0 0 0-1.115 2.693l.16.291c.415.764-.42 1.6-1.185 1.184l-.291-.159a1.873 1.873 0 0 0-2.693 1.116l-.094.318c-.246.835-1.428.835-1.674 0l-.094-.319a1.873 1.873 0 0 0-2.692-1.115l-.292.16c-.764.415-1.6-.42-1.184-1.185l.159-.291A1.873 1.873 0 0 0 1.945 8.93l-.319-.094c-.835-.246-.835-1.428 0-1.674l.319-.094A1.873 1.873 0 0 0 3.06 4.474l-.16-.292c-.415-.764.42-1.6 1.185-1.184l.292.159a1.873 1.873 0 0 0 2.692-1.115z"></path></svg></button></div></div> <textarea id="labelInput" class="hidden" rows="1"></textarea> <div id="emptyState" class="absolute inset-0 flex flex-col items-center justify-center text-gray-400 dark:text-gray-600 pointer-events-none select-none"><svg width="52" height="44" viewBox="0 0 52 44" fill="none" stroke="currentColor" stroke-width="1.5" class="mb-3 opacity-50"><rect x="2" y="4" width="18" height="12" rx="2"></rect><rect x="32" y="28" width="18" height="12" rx="2"></rect><line x1="20" y1="10" x2="32" y2="34" stroke-dasharray="4,3"></line><rect x="17" y="16" width="18" height="12" rx="2"></rect><line x1="26" y1="16" x2="26" y2="10" stroke-dasharray="4,3"></line></svg> <p class="text-sm"> </p></div></div></div> <div id="toastContainer"></div> <div id="imageNameModal" style="display:none;position:fixed;inset:0;z-index:1000;background:rgba(0,0,0,0.5);" class="flex items-center justify-center"><div class="bg-white dark:bg-gray-800 rounded-xl shadow-2xl p-6 w-80 flex flex-col gap-3"><p class="text-sm font-semibold text-gray-700 dark:text-gray-200"> </p> <p class="text-xs text-gray-400 dark:text-gray-500">Lettres, chiffres, <code class="bg-gray-100 dark:bg-gray-700 px-0.5 rounded">_</code> et <code class="bg-gray-100 dark:bg-gray-700 px-0.5 rounded">-</code> uniquement.
|
|
169
169
|
Laisser vide pour un nom automatique.</p> <div class="flex items-center gap-1"><input id="imageNameInput" type="text" autocomplete="off" spellcheck="false" class="flex-1 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700
|
|
170
170
|
text-gray-900 dark:text-gray-100 text-sm px-2 py-1 outline-none focus:ring-2 focus:ring-blue-400"/> <span class="text-xs text-gray-400 dark:text-gray-500 whitespace-nowrap">.png</span></div> <p id="imageNameError" class="text-xs text-red-500 hidden"> </p> <div class="flex gap-2 justify-end"><button id="imageNameCancel" class="px-3 py-1 text-xs rounded border border-gray-300 dark:border-gray-600
|
|
171
|
-
text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"> </button> <button id="imageNameConfirm" class="px-3 py-1 text-xs rounded bg-blue-500 text-white hover:bg-blue-600"> </button></div></div></div></div>`);function Bv(e,t){Ke(t,!0),Gi(()=>{let e;return(async()=>{let t=`en`;try{t=(await fetch(`/api/config`).then(e=>e.json())).language||`en`}catch{}await pa(t);let{initDiagram:r}=await Rv(async()=>{let{initDiagram:e}=await import(`./main-DCIeFe1K.js`);return{initDiagram:e}},[]);e=r();let i=document.getElementById(`sidebar`),a=parseInt(localStorage.getItem(n)||``,10);i&&Number.isFinite(a)&&(i.style.width=a+`px`)})(),()=>e?.()});let n=`ld-diagram-sidebar-w`,r=P(!1);function i(e){e.preventDefault();let t=document.getElementById(`sidebar`);if(!t)return;let i=e.clientX,a=t.getBoundingClientRect().width;F(r,!0),t.style.transition=`none`,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let o=e=>{let n=Math.max(160,Math.min(480,a+e.clientX-i));t.style.width=n+`px`},s=()=>{document.removeEventListener(`mousemove`,o),document.removeEventListener(`mouseup`,s),document.body.style.cursor=``,document.body.style.userSelect=``,F(r,!1),t.style.transition=``;try{localStorage.setItem(n,String(parseInt(t.style.width,10)))}catch{}};document.addEventListener(`mousemove`,o),document.addEventListener(`mouseup`,s)}var a=zv(),o=L(a),s=L(o),c=L(s,!0);M(s);var l=z(s,4),u=z(l,4),d=z(u,2),f=z(d,4),p=z(f,2),m=z(p,2),h=z(m,2),g=z(h,2),_=z(g,2),v=z(_,2),y=z(v,2),b=z(y,2),x=z(b,4),S=z(x,4),C=z(S,4),w=z(C,2),T=z(w,2),E=z(T,2),D=z(E,2),ee=z(D,2),O=z(ee,4),te=z(O,4),k=z(te,4),ne=z(k,2),A=z(ne,8),re=z(A,4),ie=z(re,4),ae=L(ie),oe=L(ae,!0);M(ae),M(ie),M(o);var se=z(o,2),ce=L(se),le=L(ce),ue=L(le),de=L(ue,!0);M(ue);var fe=z(ue,2),pe=L(fe,!0);M(fe),M(le),Fe(2),M(ce);var me=z(ce,2),he=z(me,2),ge=z(L(he),10),_e=z(L(ge),8),ve=z(_e,2);M(ge);var ye=z(ge,2),be=L(ye),xe=L(be),Se=L(xe,!0);M(xe);var Ce=z(xe,2);M(be),Fe(2),M(ye);var we=z(ye,2),j=L(we),Te=z(j,4),Ee=L(Te),De=z(Ee,4),Oe=z(De,4),ke=z(Oe,2),Ae=z(ke,4),je=z(Ae,2),Me=z(je,2),Ne=z(Me,4),Pe=z(Ne,2),Ie=z(Pe,2),Le=z(Ie,4),Re=z(Le,2),ze=z(Re,2),Be=z(ze,4),Ve=L(Be),He=z(Ve,2),Ue=z(He,2),We=z(Ue,2),Ge=z(We,2);Fe(2),M(Be);var Je=z(Be,2),Ye=z(Je,2),Xe=z(Ye,4),Ze=z(Xe,2),Qe=z(Ze,2),$e=z(Qe,4),et=z($e,2),tt=z(et,4),nt=z(tt,4),rt=z(nt,2),it=z(rt,4);M(Te),M(we);var at=z(we,2),ot=L(at),st=L(ot,!0);M(ot);var ct=z(ot,2),lt=z(L(ct),2),ut=L(lt,!0);M(lt),M(ct);var dt=z(ct,2),ft=L(dt);M(dt);var pt=z(dt,2),mt=z(L(pt),2),ht=L(mt,!0);M(mt),M(pt);var gt=z(pt,4),_t=z(L(gt),2),vt=L(_t,!0);M(_t),M(gt);var yt=z(gt,2),N=L(yt);M(yt);var bt=z(yt,2),xt=L(bt),St=L(xt,!0);M(xt);var Ct=z(xt,2),wt=L(Ct,!0);M(Ct),Fe(2),M(bt),M(at);var Tt=z(at,2),Et=L(Tt),Dt=z(Et,4),Ot=L(Dt),kt=z(Ot,2),At=z(kt,2),jt=z(At,2),Mt=z(jt,4),Nt=z(Mt,2),Pt=z(Nt,4),Ft=z(Pt,2),It=z(Ft,2),Lt=z(It,4),Rt=z(Lt,2),zt=z(Rt,4),Bt=z(zt,2),Vt=z(Bt,4),Ht=z(Vt,2),Ut=z(Ht,2),Wt=z(Ut,2),Gt=z(Wt,2),Kt=z(Gt,4),qt=z(Kt,2),Jt=z(qt,4),Yt=z(Jt,4),Xt=z(Yt,4);M(Dt),M(Tt);var Zt=z(Tt,2),Qt=z(Zt,2),$t=z(L(Qt),2),en=L($t,!0);M($t),M(Qt),M(he),M(se);var tn=z(se,4),nn=L(tn),I=L(nn),rn=L(I,!0);M(I);var an=z(I,4),on=L(an);Fe(2),M(an);var sn=z(an,2),cn=L(sn,!0);M(sn);var ln=z(sn,2),un=L(ln),dn=L(un,!0);M(un);var fn=z(un,2),pn=L(fn,!0);M(fn),M(ln),M(nn),M(tn),M(a),B((e,t,n,i,a,o,s,ie,ae,se,ce,le,ue,fe,he,ge,ye,be,xe,we,Te,M,Fe,Be,Ke,qe,at,ot,ct,lt,dt,pt,mt,gt,_t,yt,bt,xt,Ct,Tt,Dt,P,Qt,F,$t,tn,nn,I,an,sn,ln,un,fn,L,R,z,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,B,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar)=>{G(c,e),J(l,`title`,t),J(u,`title`,n),J(d,`title`,i),J(f,`title`,a),J(p,`title`,o),J(m,`title`,s),J(h,`title`,ie),J(g,`title`,ae),J(_,`title`,se),J(v,`title`,ce),J(y,`title`,le),J(b,`title`,ue),J(x,`title`,fe),J(S,`title`,he),J(C,`title`,ge),J(w,`title`,ye),J(T,`title`,be),J(E,`title`,xe),J(D,`title`,we),J(ee,`title`,Te),J(O,`placeholder`,M),J(te,`title`,Fe),J(k,`title`,Be),J(ne,`title`,Ke),J(A,`title`,qe),J(re,`title`,at),G(oe,ot),G(de,ct),G(pe,lt),gi(me,1,`w-1 shrink-0 cursor-col-resize select-none transition-colors ${V(r)?`bg-blue-500/60`:`bg-transparent hover:bg-blue-500/40`}`),J(_e,`title`,dt),J(ve,`title`,pt),G(Se,mt),J(Ce,`title`,gt),J(j,`title`,_t),J(Ee,`title`,yt),J(De,`title`,bt),J(Oe,`title`,xt),J(ke,`title`,Ct),J(Ae,`title`,Tt),J(je,`title`,Dt),J(Me,`title`,P),J(Ne,`title`,Qt),J(Pe,`title`,F),J(Ie,`title`,$t),J(Le,`title`,tn),J(Re,`title`,nn),J(ze,`title`,I),J(Ve,`title`,an),J(He,`title`,sn),J(Ue,`title`,ln),J(We,`title`,un),J(Ge,`title`,fn),J(Je,`title`,L),J(Ye,`title`,R),J(Xe,`title`,z),J(Ze,`title`,mn),J(Qe,`title`,hn),J($e,`title`,gn),J(et,`title`,_n),J(tt,`title`,vn),J(nt,`title`,yn),J(rt,`title`,bn),J(it,`title`,xn),G(st,Sn),G(ut,Cn),J(ft,`placeholder`,wn),G(ht,Tn),G(vt,En),J(N,`placeholder`,Dn),G(St,On),G(wt,kn),J(Et,`title`,An),J(Ot,`title`,jn),J(kt,`title`,Mn),J(At,`title`,Nn),J(jt,`title`,Pn),J(Mt,`title`,Fn),J(Nt,`title`,B),J(Pt,`title`,In),J(Ft,`title`,Ln),J(It,`title`,Rn),J(Lt,`title`,zn),J(Rt,`title`,Bn),J(zt,`title`,Vn),J(Bt,`title`,Hn),J(Vt,`title`,Un),J(Ht,`title`,Wn),J(Ut,`title`,Gn),J(Wt,`title`,Kn),J(Gt,`title`,qn),J(Kt,`title`,Jn),J(qt,`title`,Yn),J(Jt,`title`,Xn),J(Yt,`title`,Zn),J(Xt,`title`,Qn),J(Zt,`placeholder`,$n),G(en,er),G(rn,tr),J(on,`placeholder`,nr),G(cn,rr),G(dn,ir),G(pn,ar)},[()=>Y(`diagram.back_btn`),()=>Y(`diagram.diagrams_list_title`),()=>Y(`diagram.toolbar.copy_mcp_id`),()=>Y(`diagram.toolbar.select`),()=>Y(`diagram.toolbar.box`),()=>Y(`diagram.toolbar.ellipse`),()=>Y(`diagram.toolbar.database`),()=>Y(`diagram.toolbar.circle`),()=>Y(`diagram.toolbar.actor`),()=>Y(`diagram.toolbar.postit`),()=>Y(`diagram.toolbar.text_free`),()=>Y(`diagram.toolbar.image`),()=>Y(`diagram.toolbar.shape_editor`),()=>Y(`diagram.toolbar.arrow`),()=>Y(`diagram.toolbar.delete`),()=>Y(`diagram.toolbar.defaults`),()=>Y(`diagram.toolbar.align_guides`),()=>Y(`diagram.toolbar.grid`),()=>Y(`diagram.toolbar.edge_style`),()=>Y(`diagram.toolbar.evidence_mode`),()=>Y(`diagram.toolbar.resize_corner`),()=>Y(`diagram.toolbar.title_placeholder`),()=>Y(`diagram.toolbar.zoom_out`),()=>Y(`diagram.toolbar.zoom_in`),()=>Y(`diagram.toolbar.fit`),()=>Y(`diagram.toolbar.debug`),()=>Y(`diagram.toolbar.export_drawio`),()=>Y(`diagram.toolbar.save`),()=>Y(`diagram.sidebar.title`),()=>Y(`diagram.sidebar.new_btn`),()=>Y(`diagram.selection.rotate_shape`),()=>Y(`diagram.selection.rotate_text`),()=>Y(`diagram.evidence.panel_title`),()=>Y(`diagram.evidence.close`),()=>Y(`diagram.node_panel.lock`),()=>Y(`diagram.node_panel.color`),()=>Y(`diagram.node_panel.bg_opacity`),()=>Y(`diagram.node_panel.edit_label`),()=>Y(`diagram.node_panel.edit_link`),()=>Y(`diagram.node_panel.font_decrease`),()=>Y(`diagram.node_panel.font_size_value`),()=>Y(`diagram.node_panel.font_increase`),()=>Y(`diagram.node_panel.align_left`),()=>Y(`diagram.node_panel.align_center`),()=>Y(`diagram.node_panel.align_right`),()=>Y(`diagram.node_panel.align_top`),()=>Y(`diagram.node_panel.align_middle`),()=>Y(`diagram.node_panel.align_bottom`),()=>Y(`diagram.node_panel.custom_label_above`),()=>Y(`diagram.node_panel.custom_label_below`),()=>Y(`diagram.node_panel.custom_label_left`),()=>Y(`diagram.node_panel.custom_label_right`),()=>Y(`diagram.node_panel.custom_label_center`),()=>Y(`diagram.node_panel.send_back`),()=>Y(`diagram.node_panel.bring_front`),()=>Y(`diagram.node_panel.stamp_color`),()=>Y(`diagram.node_panel.stamp_font`),()=>Y(`diagram.node_panel.stamp_size`),()=>Y(`diagram.node_panel.rotate_ccw`),()=>Y(`diagram.node_panel.rotate_cw`),()=>Y(`diagram.node_panel.copy_png`),()=>Y(`diagram.node_panel.group`),()=>Y(`diagram.node_panel.ungroup`),()=>Y(`diagram.node_panel.save_as_default`),()=>Y(`diagram.link_panel.title`),()=>Y(`diagram.link_panel.external`),()=>Y(`diagram.link_panel.url_placeholder`),()=>Y(`diagram.link_panel.existing_diagram`),()=>Y(`diagram.link_panel.new_diagram`),()=>Y(`diagram.link_panel.diagram_name_placeholder`),()=>Y(`diagram.link_panel.save_btn`),()=>Y(`diagram.link_panel.remove_btn`),()=>Y(`diagram.edge_panel.lock`),()=>Y(`diagram.edge_panel.no_arrow`),()=>Y(`diagram.edge_panel.arrow_from`),()=>Y(`diagram.edge_panel.arrow_to`),()=>Y(`diagram.edge_panel.arrow_both`),()=>Y(`diagram.edge_panel.solid`),()=>Y(`diagram.edge_panel.dashed`),()=>Y(`diagram.edge_panel.font_decrease`),()=>Y(`diagram.edge_panel.font_size_value`),()=>Y(`diagram.edge_panel.font_increase`),()=>Y(`diagram.edge_panel.edit_label`),()=>Y(`diagram.edge_panel.reset_label_width`),()=>Y(`diagram.edge_panel.rotate_label_ccw`),()=>Y(`diagram.edge_panel.rotate_label_cw`),()=>Y(`diagram.edge_panel.offset_label_left`),()=>Y(`diagram.edge_panel.offset_label_right`),()=>Y(`diagram.edge_panel.offset_label_up`),()=>Y(`diagram.edge_panel.offset_label_down`),()=>Y(`diagram.edge_panel.offset_label_reset`),()=>Y(`diagram.edge_panel.width_decrease`),()=>Y(`diagram.edge_panel.width_increase`),()=>Y(`diagram.edge_panel.color`),()=>Y(`diagram.edge_panel.clear_ports`),()=>Y(`diagram.edge_panel.save_as_default`),()=>Y(`diagram.label_input.placeholder`),()=>Y(`diagram.empty_state`),()=>Y(`diagram.image_modal.title`),()=>Y(`diagram.image_modal.placeholder`),()=>Y(`diagram.image_modal.error_chars`),()=>Y(`diagram.image_modal.cancel_btn`),()=>Y(`diagram.image_modal.paste_btn`)]),H(`click`,s,()=>history.back()),H(`mousedown`,me,i),W(e,a),qe()}Pr([`click`,`mousedown`]),Ue();var Vv={network:null,nodes:null,edges:null,diagrams:[],currentDiagramId:null,currentTool:`select`,pendingShape:`box`,selectedNodeIds:[],selectedEdgeIds:[],alignGuides:!0,gridEnabled:!0,debugMode:!1,isDirty:!1,sidebarOpen:!0,editingNodeId:null,editingEdgeId:null,resizeDrag:null,rotateDrag:null,labelRotateDrag:null,activeStamp:null,stampTargetIds:[],clipboard:null,canonicalOrder:[],edgesStraight:!1,resizeSymmetric:!1,nodeColorOverrides:{},customShapeLibraries:[],customShapeDefs:new Map,edgeLabelCanvasPos:{},edgeLabelBBox:{},freeArrowFirstPoint:null,exportingPng:!1,evidenceMode:!1};function Hv(){Vv.isDirty=!0,document.getElementById(`btnSave`).disabled=!1}var Uv=`custom-shape`,Wv=`custom-shape:`,Gv=[{id:`N`,x:.5,y:0},{id:`NE`,x:1,y:0},{id:`E`,x:1,y:.5},{id:`SE`,x:1,y:1},{id:`S`,x:.5,y:1},{id:`SW`,x:0,y:1},{id:`W`,x:0,y:.5},{id:`NW`,x:0,y:0}];function Kv(e){return typeof e==`string`&&e.startsWith(`custom-shape:`)}function qv(e){return Kv(e)?e.slice(13):null}function Jv(e){return e&&Vv.customShapeDefs&&Vv.customShapeDefs.get(e)||null}function Yv(e){let t=Jv(e);return[t&&t.width||65,t&&t.height||65]}function Xv(e){let t=Jv(e);return t&&Array.isArray(t.anchors)&&t.anchors.length?t.anchors:Gv}function Zv(e){let t=Jv(e);return t&&[`center`,`below`,`above`,`right`,`left`].includes(t.labelPlacement)?t.labelPlacement:`below`}async function Qv(){try{let e=await fetch(`/api/shape-libraries`);if(!e.ok)throw Error(`shape libraries unavailable`);let t=await e.json(),n=Array.isArray(t.libraries)?t.libraries:[];Vv.customShapeLibraries=n,Vv.customShapeDefs=new Map,n.forEach(e=>{(e.shapes||[]).forEach(e=>Vv.customShapeDefs.set(e.id,e))})}catch{Vv.customShapeLibraries=[],Vv.customShapeDefs=new Map}}function $v(){let e=document.getElementById(`customShapeBar`),t=document.getElementById(`customShapeBarBody`);if(!e||!t)return;t.innerHTML=``;let n=(Vv.customShapeLibraries||[]).flatMap(e=>(e.shapes||[]).filter(e=>e.showInDiagram!==!1).map(t=>({...t,libraryName:e.name})));e.classList.toggle(`hidden`,n.length===0),n.forEach(e=>{let n=document.createElement(`button`);n.type=`button`,n.className=`custom-shape-btn`,n.title=`${e.libraryName||``}${e.libraryName?` · `:``}${e.name}`,n.dataset.customShapeId=e.id;let r=document.createElement(`img`);r.src=e.imageSrc,r.alt=``,r.draggable=!1,n.appendChild(r),n.addEventListener(`click`,()=>{window.dispatchEvent(new CustomEvent(`diagram:setTool`,{detail:{tool:`addNode`,shape:`${Wv}${e.id}`}}))}),t.appendChild(n)})}function ey(){let e={saveState:document.getElementById(`saveState`),librarySelect:document.getElementById(`librarySelect`),libraryName:document.getElementById(`libraryName`),shapeList:document.getElementById(`shapeList`),previewStage:document.getElementById(`previewStage`),previewImage:document.getElementById(`previewImage`),shapeName:document.getElementById(`shapeName`),imageFile:document.getElementById(`imageFile`),shapeWidth:document.getElementById(`shapeWidth`),shapeHeight:document.getElementById(`shapeHeight`),labelPlacement:document.getElementById(`labelPlacement`),shapeShowInDiagram:document.getElementById(`shapeShowInDiagram`),anchorList:document.getElementById(`anchorList`),anchorCount:document.getElementById(`anchorCount`)},t={libraries:[]},n=null,r=null,i=null,a=null,o=e=>`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,s=()=>t.libraries.find(e=>e.id===n)||null,c=()=>s()?.shapes.find(e=>e.id===r)||null,l=e=>Math.max(0,Math.min(1,e)),u=e=>[`below`,`above`,`right`,`left`,`center`].includes(e)?e:`below`,d=e=>String(e??``).replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]);function f(t){e.saveState.textContent=t,t&&setTimeout(()=>{e.saveState.textContent===t&&(e.saveState.textContent=``)},1800)}async function p(){t=await(await fetch(`/api/shape-libraries`)).json(),Array.isArray(t.libraries)||(t.libraries=[]),t.libraries.length||t.libraries.push({id:o(`lib`),name:`My shapes`,shapes:[]}),n=t.libraries[0].id,r=t.libraries[0].shapes[0]?.id||null,i=c()?structuredClone(c()):h(),g()}async function m(){t=await(await fetch(`/api/shape-libraries`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).json(),f(`Saved`)}function h(){return{id:o(`shape`),name:`New shape`,imageSrc:``,width:65,height:65,labelPlacement:`below`,showInDiagram:!0,anchors:structuredClone(Gv)}}function g(){_(),v(),y()}function _(){e.librarySelect.innerHTML=``,t.libraries.forEach(t=>{let r=document.createElement(`option`);r.value=t.id,r.textContent=t.name,r.selected=t.id===n,e.librarySelect.appendChild(r)}),e.libraryName.value=s()?.name||``}function v(){let t=s();e.shapeList.innerHTML=``,(t?.shapes||[]).forEach(t=>{let n=document.createElement(`button`);n.type=`button`,n.className=`shape-item w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm text-left hover:bg-gray-100 ${t.id===r?`active`:``}`;let a=document.createElement(`img`);a.src=t.imageSrc,a.alt=``,a.className=`w-6 h-6 object-contain shrink-0`;let o=document.createElement(`span`);o.className=`truncate`,o.textContent=t.name,n.append(a,o),n.addEventListener(`click`,()=>{r=t.id,i=structuredClone(t),g()}),e.shapeList.appendChild(n)}),t?.shapes?.length||(e.shapeList.innerHTML=`<p class="text-xs text-gray-400 px-2 py-2">No shape yet.</p>`)}function y(){i||=h(),e.previewStage.style.aspectRatio=`${Math.max(16,Number(i.width)||65)} / ${Math.max(16,Number(i.height)||65)}`,e.previewImage.src=i.imageSrc||``,e.previewImage.style.display=i.imageSrc?`block`:`none`,e.shapeName.value=i.name||``,e.shapeWidth.value=i.width||65,e.shapeHeight.value=i.height||65,e.labelPlacement.value=u(i.labelPlacement),e.shapeShowInDiagram.checked=i.showInDiagram!==!1,b()}function b(){e.previewStage.querySelectorAll(`.anchor-dot`).forEach(e=>e.remove()),e.anchorList.innerHTML=``;let t=i.anchors||[];e.anchorCount.textContent=`${t.length} anchor${t.length>1?`s`:``}`,t.forEach((t,n)=>{let r=document.createElement(`button`);r.type=`button`,r.className=`anchor-dot`,r.style.left=`${t.x*100}%`,r.style.top=`${t.y*100}%`,r.dataset.anchorId=t.id,r.innerHTML=`<span>${t.id}</span>`,r.addEventListener(`pointerdown`,e=>{e.preventDefault(),a=t.id,r.setPointerCapture(e.pointerId)}),e.previewStage.appendChild(r);let o=document.createElement(`div`);o.className=`grid grid-cols-[4.5rem_1fr_1fr_2rem] gap-2 items-center`,o.innerHTML=`
|
|
171
|
+
text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"> </button> <button id="imageNameConfirm" class="px-3 py-1 text-xs rounded bg-blue-500 text-white hover:bg-blue-600"> </button></div></div></div></div>`);function Bv(e,t){Ke(t,!0),Gi(()=>{let e;return(async()=>{let t=`en`;try{t=(await fetch(`/api/config`).then(e=>e.json())).language||`en`}catch{}await pa(t);let{initDiagram:r}=await Rv(async()=>{let{initDiagram:e}=await import(`./main-CgFZwst-.js`);return{initDiagram:e}},[]);e=r();let i=document.getElementById(`sidebar`),a=parseInt(localStorage.getItem(n)||``,10);i&&Number.isFinite(a)&&(i.style.width=a+`px`)})(),()=>e?.()});let n=`ld-diagram-sidebar-w`,r=P(!1);function i(e){e.preventDefault();let t=document.getElementById(`sidebar`);if(!t)return;let i=e.clientX,a=t.getBoundingClientRect().width;F(r,!0),t.style.transition=`none`,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let o=e=>{let n=Math.max(160,Math.min(480,a+e.clientX-i));t.style.width=n+`px`},s=()=>{document.removeEventListener(`mousemove`,o),document.removeEventListener(`mouseup`,s),document.body.style.cursor=``,document.body.style.userSelect=``,F(r,!1),t.style.transition=``;try{localStorage.setItem(n,String(parseInt(t.style.width,10)))}catch{}};document.addEventListener(`mousemove`,o),document.addEventListener(`mouseup`,s)}var a=zv(),o=L(a),s=L(o),c=L(s,!0);M(s);var l=z(s,4),u=z(l,4),d=z(u,2),f=z(d,4),p=z(f,2),m=z(p,2),h=z(m,2),g=z(h,2),_=z(g,2),v=z(_,2),y=z(v,2),b=z(y,2),x=z(b,4),S=z(x,4),C=z(S,4),w=z(C,2),T=z(w,2),E=z(T,2),D=z(E,2),ee=z(D,2),O=z(ee,4),te=z(O,4),k=z(te,4),ne=z(k,2),A=z(ne,8),re=z(A,4),ie=z(re,4),ae=L(ie),oe=L(ae,!0);M(ae),M(ie),M(o);var se=z(o,2),ce=L(se),le=L(ce),ue=L(le),de=L(ue,!0);M(ue);var fe=z(ue,2),pe=L(fe,!0);M(fe),M(le),Fe(2),M(ce);var me=z(ce,2),he=z(me,2),ge=z(L(he),10),_e=z(L(ge),8),ve=z(_e,2);M(ge);var ye=z(ge,2),be=L(ye),xe=L(be),Se=L(xe,!0);M(xe);var Ce=z(xe,2);M(be),Fe(2),M(ye);var we=z(ye,2),j=L(we),Te=z(j,4),Ee=L(Te),De=z(Ee,4),Oe=z(De,4),ke=z(Oe,2),Ae=z(ke,4),je=z(Ae,2),Me=z(je,2),Ne=z(Me,4),Pe=z(Ne,2),Ie=z(Pe,2),Le=z(Ie,4),Re=z(Le,2),ze=z(Re,2),Be=z(ze,4),Ve=L(Be),He=z(Ve,2),Ue=z(He,2),We=z(Ue,2),Ge=z(We,2);Fe(2),M(Be);var Je=z(Be,2),Ye=z(Je,2),Xe=z(Ye,4),Ze=z(Xe,2),Qe=z(Ze,2),$e=z(Qe,4),et=z($e,2),tt=z(et,4),nt=z(tt,4),rt=z(nt,2),it=z(rt,4);M(Te),M(we);var at=z(we,2),ot=L(at),st=L(ot,!0);M(ot);var ct=z(ot,2),lt=z(L(ct),2),ut=L(lt,!0);M(lt),M(ct);var dt=z(ct,2),ft=L(dt);M(dt);var pt=z(dt,2),mt=z(L(pt),2),ht=L(mt,!0);M(mt),M(pt);var gt=z(pt,4),_t=z(L(gt),2),vt=L(_t,!0);M(_t),M(gt);var yt=z(gt,2),N=L(yt);M(yt);var bt=z(yt,2),xt=L(bt),St=L(xt,!0);M(xt);var Ct=z(xt,2),wt=L(Ct,!0);M(Ct),Fe(2),M(bt),M(at);var Tt=z(at,2),Et=L(Tt),Dt=z(Et,4),Ot=L(Dt),kt=z(Ot,2),At=z(kt,2),jt=z(At,2),Mt=z(jt,4),Nt=z(Mt,2),Pt=z(Nt,4),Ft=z(Pt,2),It=z(Ft,2),Lt=z(It,4),Rt=z(Lt,2),zt=z(Rt,4),Bt=z(zt,2),Vt=z(Bt,4),Ht=z(Vt,2),Ut=z(Ht,2),Wt=z(Ut,2),Gt=z(Wt,2),Kt=z(Gt,4),qt=z(Kt,2),Jt=z(qt,4),Yt=z(Jt,4),Xt=z(Yt,4);M(Dt),M(Tt);var Zt=z(Tt,2),Qt=z(Zt,2),$t=z(L(Qt),2),en=L($t,!0);M($t),M(Qt),M(he),M(se);var tn=z(se,4),nn=L(tn),I=L(nn),rn=L(I,!0);M(I);var an=z(I,4),on=L(an);Fe(2),M(an);var sn=z(an,2),cn=L(sn,!0);M(sn);var ln=z(sn,2),un=L(ln),dn=L(un,!0);M(un);var fn=z(un,2),pn=L(fn,!0);M(fn),M(ln),M(nn),M(tn),M(a),B((e,t,n,i,a,o,s,ie,ae,se,ce,le,ue,fe,he,ge,ye,be,xe,we,Te,M,Fe,Be,Ke,qe,at,ot,ct,lt,dt,pt,mt,gt,_t,yt,bt,xt,Ct,Tt,Dt,P,Qt,F,$t,tn,nn,I,an,sn,ln,un,fn,L,R,z,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,B,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar)=>{G(c,e),J(l,`title`,t),J(u,`title`,n),J(d,`title`,i),J(f,`title`,a),J(p,`title`,o),J(m,`title`,s),J(h,`title`,ie),J(g,`title`,ae),J(_,`title`,se),J(v,`title`,ce),J(y,`title`,le),J(b,`title`,ue),J(x,`title`,fe),J(S,`title`,he),J(C,`title`,ge),J(w,`title`,ye),J(T,`title`,be),J(E,`title`,xe),J(D,`title`,we),J(ee,`title`,Te),J(O,`placeholder`,M),J(te,`title`,Fe),J(k,`title`,Be),J(ne,`title`,Ke),J(A,`title`,qe),J(re,`title`,at),G(oe,ot),G(de,ct),G(pe,lt),gi(me,1,`w-1 shrink-0 cursor-col-resize select-none transition-colors ${V(r)?`bg-blue-500/60`:`bg-transparent hover:bg-blue-500/40`}`),J(_e,`title`,dt),J(ve,`title`,pt),G(Se,mt),J(Ce,`title`,gt),J(j,`title`,_t),J(Ee,`title`,yt),J(De,`title`,bt),J(Oe,`title`,xt),J(ke,`title`,Ct),J(Ae,`title`,Tt),J(je,`title`,Dt),J(Me,`title`,P),J(Ne,`title`,Qt),J(Pe,`title`,F),J(Ie,`title`,$t),J(Le,`title`,tn),J(Re,`title`,nn),J(ze,`title`,I),J(Ve,`title`,an),J(He,`title`,sn),J(Ue,`title`,ln),J(We,`title`,un),J(Ge,`title`,fn),J(Je,`title`,L),J(Ye,`title`,R),J(Xe,`title`,z),J(Ze,`title`,mn),J(Qe,`title`,hn),J($e,`title`,gn),J(et,`title`,_n),J(tt,`title`,vn),J(nt,`title`,yn),J(rt,`title`,bn),J(it,`title`,xn),G(st,Sn),G(ut,Cn),J(ft,`placeholder`,wn),G(ht,Tn),G(vt,En),J(N,`placeholder`,Dn),G(St,On),G(wt,kn),J(Et,`title`,An),J(Ot,`title`,jn),J(kt,`title`,Mn),J(At,`title`,Nn),J(jt,`title`,Pn),J(Mt,`title`,Fn),J(Nt,`title`,B),J(Pt,`title`,In),J(Ft,`title`,Ln),J(It,`title`,Rn),J(Lt,`title`,zn),J(Rt,`title`,Bn),J(zt,`title`,Vn),J(Bt,`title`,Hn),J(Vt,`title`,Un),J(Ht,`title`,Wn),J(Ut,`title`,Gn),J(Wt,`title`,Kn),J(Gt,`title`,qn),J(Kt,`title`,Jn),J(qt,`title`,Yn),J(Jt,`title`,Xn),J(Yt,`title`,Zn),J(Xt,`title`,Qn),J(Zt,`placeholder`,$n),G(en,er),G(rn,tr),J(on,`placeholder`,nr),G(cn,rr),G(dn,ir),G(pn,ar)},[()=>Y(`diagram.back_btn`),()=>Y(`diagram.diagrams_list_title`),()=>Y(`diagram.toolbar.copy_mcp_id`),()=>Y(`diagram.toolbar.select`),()=>Y(`diagram.toolbar.box`),()=>Y(`diagram.toolbar.ellipse`),()=>Y(`diagram.toolbar.database`),()=>Y(`diagram.toolbar.circle`),()=>Y(`diagram.toolbar.actor`),()=>Y(`diagram.toolbar.postit`),()=>Y(`diagram.toolbar.text_free`),()=>Y(`diagram.toolbar.image`),()=>Y(`diagram.toolbar.shape_editor`),()=>Y(`diagram.toolbar.arrow`),()=>Y(`diagram.toolbar.delete`),()=>Y(`diagram.toolbar.defaults`),()=>Y(`diagram.toolbar.align_guides`),()=>Y(`diagram.toolbar.grid`),()=>Y(`diagram.toolbar.edge_style`),()=>Y(`diagram.toolbar.evidence_mode`),()=>Y(`diagram.toolbar.resize_corner`),()=>Y(`diagram.toolbar.title_placeholder`),()=>Y(`diagram.toolbar.zoom_out`),()=>Y(`diagram.toolbar.zoom_in`),()=>Y(`diagram.toolbar.fit`),()=>Y(`diagram.toolbar.debug`),()=>Y(`diagram.toolbar.export_drawio`),()=>Y(`diagram.toolbar.save`),()=>Y(`diagram.sidebar.title`),()=>Y(`diagram.sidebar.new_btn`),()=>Y(`diagram.selection.rotate_shape`),()=>Y(`diagram.selection.rotate_text`),()=>Y(`diagram.evidence.panel_title`),()=>Y(`diagram.evidence.close`),()=>Y(`diagram.node_panel.lock`),()=>Y(`diagram.node_panel.color`),()=>Y(`diagram.node_panel.bg_opacity`),()=>Y(`diagram.node_panel.edit_label`),()=>Y(`diagram.node_panel.edit_link`),()=>Y(`diagram.node_panel.font_decrease`),()=>Y(`diagram.node_panel.font_size_value`),()=>Y(`diagram.node_panel.font_increase`),()=>Y(`diagram.node_panel.align_left`),()=>Y(`diagram.node_panel.align_center`),()=>Y(`diagram.node_panel.align_right`),()=>Y(`diagram.node_panel.align_top`),()=>Y(`diagram.node_panel.align_middle`),()=>Y(`diagram.node_panel.align_bottom`),()=>Y(`diagram.node_panel.custom_label_above`),()=>Y(`diagram.node_panel.custom_label_below`),()=>Y(`diagram.node_panel.custom_label_left`),()=>Y(`diagram.node_panel.custom_label_right`),()=>Y(`diagram.node_panel.custom_label_center`),()=>Y(`diagram.node_panel.send_back`),()=>Y(`diagram.node_panel.bring_front`),()=>Y(`diagram.node_panel.stamp_color`),()=>Y(`diagram.node_panel.stamp_font`),()=>Y(`diagram.node_panel.stamp_size`),()=>Y(`diagram.node_panel.rotate_ccw`),()=>Y(`diagram.node_panel.rotate_cw`),()=>Y(`diagram.node_panel.copy_png`),()=>Y(`diagram.node_panel.group`),()=>Y(`diagram.node_panel.ungroup`),()=>Y(`diagram.node_panel.save_as_default`),()=>Y(`diagram.link_panel.title`),()=>Y(`diagram.link_panel.external`),()=>Y(`diagram.link_panel.url_placeholder`),()=>Y(`diagram.link_panel.existing_diagram`),()=>Y(`diagram.link_panel.new_diagram`),()=>Y(`diagram.link_panel.diagram_name_placeholder`),()=>Y(`diagram.link_panel.save_btn`),()=>Y(`diagram.link_panel.remove_btn`),()=>Y(`diagram.edge_panel.lock`),()=>Y(`diagram.edge_panel.no_arrow`),()=>Y(`diagram.edge_panel.arrow_from`),()=>Y(`diagram.edge_panel.arrow_to`),()=>Y(`diagram.edge_panel.arrow_both`),()=>Y(`diagram.edge_panel.solid`),()=>Y(`diagram.edge_panel.dashed`),()=>Y(`diagram.edge_panel.font_decrease`),()=>Y(`diagram.edge_panel.font_size_value`),()=>Y(`diagram.edge_panel.font_increase`),()=>Y(`diagram.edge_panel.edit_label`),()=>Y(`diagram.edge_panel.reset_label_width`),()=>Y(`diagram.edge_panel.rotate_label_ccw`),()=>Y(`diagram.edge_panel.rotate_label_cw`),()=>Y(`diagram.edge_panel.offset_label_left`),()=>Y(`diagram.edge_panel.offset_label_right`),()=>Y(`diagram.edge_panel.offset_label_up`),()=>Y(`diagram.edge_panel.offset_label_down`),()=>Y(`diagram.edge_panel.offset_label_reset`),()=>Y(`diagram.edge_panel.width_decrease`),()=>Y(`diagram.edge_panel.width_increase`),()=>Y(`diagram.edge_panel.color`),()=>Y(`diagram.edge_panel.clear_ports`),()=>Y(`diagram.edge_panel.save_as_default`),()=>Y(`diagram.label_input.placeholder`),()=>Y(`diagram.empty_state`),()=>Y(`diagram.image_modal.title`),()=>Y(`diagram.image_modal.placeholder`),()=>Y(`diagram.image_modal.error_chars`),()=>Y(`diagram.image_modal.cancel_btn`),()=>Y(`diagram.image_modal.paste_btn`)]),H(`click`,s,()=>history.back()),H(`mousedown`,me,i),W(e,a),qe()}Pr([`click`,`mousedown`]),Ue();var Vv={network:null,nodes:null,edges:null,diagrams:[],currentDiagramId:null,currentTool:`select`,pendingShape:`box`,selectedNodeIds:[],selectedEdgeIds:[],alignGuides:!0,gridEnabled:!0,debugMode:!1,isDirty:!1,sidebarOpen:!0,editingNodeId:null,editingEdgeId:null,resizeDrag:null,rotateDrag:null,labelRotateDrag:null,activeStamp:null,stampTargetIds:[],clipboard:null,canonicalOrder:[],edgesStraight:!1,resizeSymmetric:!1,nodeColorOverrides:{},customShapeLibraries:[],customShapeDefs:new Map,edgeLabelCanvasPos:{},edgeLabelBBox:{},freeArrowFirstPoint:null,exportingPng:!1,evidenceMode:!1};function Hv(){Vv.isDirty=!0,document.getElementById(`btnSave`).disabled=!1}var Uv=`custom-shape`,Wv=`custom-shape:`,Gv=[{id:`N`,x:.5,y:0},{id:`NE`,x:1,y:0},{id:`E`,x:1,y:.5},{id:`SE`,x:1,y:1},{id:`S`,x:.5,y:1},{id:`SW`,x:0,y:1},{id:`W`,x:0,y:.5},{id:`NW`,x:0,y:0}];function Kv(e){return typeof e==`string`&&e.startsWith(`custom-shape:`)}function qv(e){return Kv(e)?e.slice(13):null}function Jv(e){return e&&Vv.customShapeDefs&&Vv.customShapeDefs.get(e)||null}function Yv(e){let t=Jv(e);return[t&&t.width||65,t&&t.height||65]}function Xv(e){let t=Jv(e);return t&&Array.isArray(t.anchors)&&t.anchors.length?t.anchors:Gv}function Zv(e){let t=Jv(e);return t&&[`center`,`below`,`above`,`right`,`left`].includes(t.labelPlacement)?t.labelPlacement:`below`}async function Qv(){try{let e=await fetch(`/api/shape-libraries`);if(!e.ok)throw Error(`shape libraries unavailable`);let t=await e.json(),n=Array.isArray(t.libraries)?t.libraries:[];Vv.customShapeLibraries=n,Vv.customShapeDefs=new Map,n.forEach(e=>{(e.shapes||[]).forEach(e=>Vv.customShapeDefs.set(e.id,e))})}catch{Vv.customShapeLibraries=[],Vv.customShapeDefs=new Map}}function $v(){let e=document.getElementById(`customShapeBar`),t=document.getElementById(`customShapeBarBody`);if(!e||!t)return;t.innerHTML=``;let n=(Vv.customShapeLibraries||[]).flatMap(e=>(e.shapes||[]).filter(e=>e.showInDiagram!==!1).map(t=>({...t,libraryName:e.name})));e.classList.toggle(`hidden`,n.length===0),n.forEach(e=>{let n=document.createElement(`button`);n.type=`button`,n.className=`custom-shape-btn`,n.title=`${e.libraryName||``}${e.libraryName?` · `:``}${e.name}`,n.dataset.customShapeId=e.id;let r=document.createElement(`img`);r.src=e.imageSrc,r.alt=``,r.draggable=!1,n.appendChild(r),n.addEventListener(`click`,()=>{window.dispatchEvent(new CustomEvent(`diagram:setTool`,{detail:{tool:`addNode`,shape:`${Wv}${e.id}`}}))}),t.appendChild(n)})}function ey(){let e={saveState:document.getElementById(`saveState`),librarySelect:document.getElementById(`librarySelect`),libraryName:document.getElementById(`libraryName`),shapeList:document.getElementById(`shapeList`),previewStage:document.getElementById(`previewStage`),previewImage:document.getElementById(`previewImage`),shapeName:document.getElementById(`shapeName`),imageFile:document.getElementById(`imageFile`),shapeWidth:document.getElementById(`shapeWidth`),shapeHeight:document.getElementById(`shapeHeight`),labelPlacement:document.getElementById(`labelPlacement`),shapeShowInDiagram:document.getElementById(`shapeShowInDiagram`),anchorList:document.getElementById(`anchorList`),anchorCount:document.getElementById(`anchorCount`)},t={libraries:[]},n=null,r=null,i=null,a=null,o=e=>`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,s=()=>t.libraries.find(e=>e.id===n)||null,c=()=>s()?.shapes.find(e=>e.id===r)||null,l=e=>Math.max(0,Math.min(1,e)),u=e=>[`below`,`above`,`right`,`left`,`center`].includes(e)?e:`below`,d=e=>String(e??``).replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]);function f(t){e.saveState.textContent=t,t&&setTimeout(()=>{e.saveState.textContent===t&&(e.saveState.textContent=``)},1800)}async function p(){t=await(await fetch(`/api/shape-libraries`)).json(),Array.isArray(t.libraries)||(t.libraries=[]),t.libraries.length||t.libraries.push({id:o(`lib`),name:`My shapes`,shapes:[]}),n=t.libraries[0].id,r=t.libraries[0].shapes[0]?.id||null,i=c()?structuredClone(c()):h(),g()}async function m(){t=await(await fetch(`/api/shape-libraries`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})).json(),f(`Saved`)}function h(){return{id:o(`shape`),name:`New shape`,imageSrc:``,width:65,height:65,labelPlacement:`below`,showInDiagram:!0,anchors:structuredClone(Gv)}}function g(){_(),v(),y()}function _(){e.librarySelect.innerHTML=``,t.libraries.forEach(t=>{let r=document.createElement(`option`);r.value=t.id,r.textContent=t.name,r.selected=t.id===n,e.librarySelect.appendChild(r)}),e.libraryName.value=s()?.name||``}function v(){let t=s();e.shapeList.innerHTML=``,(t?.shapes||[]).forEach(t=>{let n=document.createElement(`button`);n.type=`button`,n.className=`shape-item w-full flex items-center gap-2 px-2 py-1.5 rounded text-sm text-left hover:bg-gray-100 ${t.id===r?`active`:``}`;let a=document.createElement(`img`);a.src=t.imageSrc,a.alt=``,a.className=`w-6 h-6 object-contain shrink-0`;let o=document.createElement(`span`);o.className=`truncate`,o.textContent=t.name,n.append(a,o),n.addEventListener(`click`,()=>{r=t.id,i=structuredClone(t),g()}),e.shapeList.appendChild(n)}),t?.shapes?.length||(e.shapeList.innerHTML=`<p class="text-xs text-gray-400 px-2 py-2">No shape yet.</p>`)}function y(){i||=h(),e.previewStage.style.aspectRatio=`${Math.max(16,Number(i.width)||65)} / ${Math.max(16,Number(i.height)||65)}`,e.previewImage.src=i.imageSrc||``,e.previewImage.style.display=i.imageSrc?`block`:`none`,e.shapeName.value=i.name||``,e.shapeWidth.value=i.width||65,e.shapeHeight.value=i.height||65,e.labelPlacement.value=u(i.labelPlacement),e.shapeShowInDiagram.checked=i.showInDiagram!==!1,b()}function b(){e.previewStage.querySelectorAll(`.anchor-dot`).forEach(e=>e.remove()),e.anchorList.innerHTML=``;let t=i.anchors||[];e.anchorCount.textContent=`${t.length} anchor${t.length>1?`s`:``}`,t.forEach((t,n)=>{let r=document.createElement(`button`);r.type=`button`,r.className=`anchor-dot`,r.style.left=`${t.x*100}%`,r.style.top=`${t.y*100}%`,r.dataset.anchorId=t.id,r.innerHTML=`<span>${t.id}</span>`,r.addEventListener(`pointerdown`,e=>{e.preventDefault(),a=t.id,r.setPointerCapture(e.pointerId)}),e.previewStage.appendChild(r);let o=document.createElement(`div`);o.className=`grid grid-cols-[4.5rem_1fr_1fr_2rem] gap-2 items-center`,o.innerHTML=`
|
|
172
172
|
<input class="field !h-7 text-xs" value="${d(t.id)}">
|
|
173
173
|
<input class="field !h-7 text-xs" type="number" min="0" max="100" step="1" value="${Math.round(t.x*100)}">
|
|
174
174
|
<input class="field !h-7 text-xs" type="number" min="0" max="100" step="1" value="${Math.round(t.y*100)}">
|