living-ai-documentation 3.60.0 → 3.61.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-nGpyW4mV.js → index-CCreABLx.js} +78 -78
- package/dist/frontend-svelte/assets/index-tG5nsuIP.css +1 -0
- package/dist/frontend-svelte/assets/{main-D-b1ZWKj.js → main-B1NZokva.js} +1 -1
- package/dist/frontend-svelte/i18n/en.json +1 -1
- package/dist/frontend-svelte/i18n/fr.json +1 -1
- package/dist/frontend-svelte/index.html +2 -2
- package/package.json +1 -1
- package/dist/frontend-svelte/assets/index-DkQQPAK_.css +0 -1
|
@@ -88,7 +88,7 @@ Texte`};case`link`:return{text:ut(`snip-link-text`),textFallback:Y(`snippet.link
|
|
|
88
88
|
|
|
89
89
|
`,t+1);return n>=0?n:e.length}s=s.previousElementSibling}let c=a.nextElementSibling;for(;c;){let t=jf(e,c,r);if(t!==null){let n=e.lastIndexOf(`
|
|
90
90
|
|
|
91
|
-
`,t);return n>=0?n:0}c=c.nextElementSibling}return e.length}function Nf(e,t,n){if(!e||typeof t!=`string`)return()=>{};let r=Sf(t);wf(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=df(e.type),o=pf(e.type);Ef(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=Mf(t,e,i.target,r,i.clientY);o!==null&&(i.preventDefault(),Ef(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?.type===`table`&&(t.preventDefault(),t.stopPropagation(),Tf(),n.onEdit({...a,tableFocusCell:Of(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(),Ef(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=>{hf&&!hf.contains(e.target)&&Tf()},l=e=>{e.key===`Escape`&&Tf()};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),Tf(),e.querySelectorAll(`[data-inline-snippet-index]`).forEach(e=>{e.removeAttribute(`data-inline-snippet-index`),e.classList.remove(`ld-inline-snippet-target`)})}}var Pf=200*1024*1024,Ff=Math.round(Pf/1024/1024);Math.ceil(Pf*1.4);var If=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>`),Lf=U(`<div id="doc-content" data-testid="doc-content"></div>`),Rf=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>`),zf=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>`),Bf=U(`<!> <!> <!> <!>`,1);function Vf(e,t){qe(t,!0);let n=qi(t,`onopen`,3,()=>{}),r=qi(t,`onanchor`,3,D),i=qi(t,`onconfirmdelete`,3,void 0),a=qi(t,`oncontentwired`,3,void 0),o=qi(t,`rewireSignal`,3,void 0),s=qi(t,`editing`,15,!1),c=qi(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`})}Ji(()=>{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 gd(V(l),t.html,{content:t.content,codeBlockMaxHeight:X.codeBlockMaxHeight,t:Y,onDocLink:(e,t)=>n()(e,t),onAnchor:r(),docId:t.docId,docs:X.allDocs,docsFolder:X.docsFolder,folderPaths:X.allFolderPaths,onKanbanDocsChange:e=>{X.allDocs=e},onKanbanFolderPathsChange:e=>{X.allFolderPaths=e}})||(f=Nf(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 te(){s(!1),c(null)}async function O(){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(){let e=Hu(t.content);e&&(F(m,`inline-edit`),F(h,e,!0),F(p,!0))}function A(){return s()}function re(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 le(e,t,r)})()}}function ie(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 le(e,n,r)})()}function ae(e){e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}function oe(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function se(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()})}let ce=Pf;async function le(e,n,r){if(e.size>ce){c({text:Y(`doc.file_too_large`)+` (${(e.size/1024/1024).toFixed(1)} MB, max ${Ff} MB)`,cls:`text-red-500 dark:text-red-400`});return}c({text:Y(`doc.uploading_file`),cls:`text-gray-400`});try{let i=await oe(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();se(`[📎 ${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 ue(){F(_,!1),b=null}async function de(){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 oe(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();se(``,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 fe(){F(C,null),F(w,``)}function pe(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 me(e){e.key===`Escape`&&V(C)&&fe()}var he={enterEdit:ee,cancelEdit:te,save:O,openSnippets:k,openKanbanColumnsEditor:ne,isEditing:A},ge=Bf();Nr(`keydown`,on,me);var _e=R(ge),ve=e=>{var t=If();yn(t),Ui(t,e=>F(u,e),()=>V(u)),Nr(`paste`,t,re),Nr(`drop`,t,ie),Nr(`dragover`,t,ae),Fi(t,()=>V(d),e=>F(d,e)),W(e,t)},ye=e=>{var t=Lf();Ui(t,e=>F(l,e),()=>V(l)),B(()=>vi(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,pe),W(e,t)};K(_e,e=>{s()?e(ve):e(ye,-1)});var be=z(_e,2);cf(be,{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 xe=z(be,2),Se=e=>{var t=Rf(),n=L(t),r=L(n),i=L(r);j(r);var a=z(r,2),o=L(a),s=L(o),c=z(s),l=L(c,!0);j(c),j(o);var u=z(o,2),d=L(u);ki(d);var f=z(d,2),p=L(f);j(f),j(u),j(a);var m=z(a,2),h=L(m),g=L(h,!0);j(h);var _=z(h,2),b=L(_,!0);j(_),j(m),j(n),j(t),B((e,t,n,r,a)=>{G(i,`🖼️ ${e??``}`),G(s,`${t??``} `),G(l,n),Ai(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,ue),H(`click`,_,de),W(e,t)};K(xe,e=>{V(_)&&e(Se)});var Ce=z(xe,2),we=e=>{var t=zf(),n=L(t),r=z(n,2);j(t),B(()=>{J(n,`src`,V(C)),J(n,`alt`,V(w))}),H(`click`,t,fe),H(`click`,n,e=>e.stopPropagation()),H(`click`,r,fe),W(e,t)};return K(Ce,e=>{V(C)&&e(we)}),W(e,ge),Je(he)}Pr([`click`,`input`]);var Hf=U(`<span> </span> <code> </code>`,1),Uf=U(`<button type="button" data-testid="bp-copy-doc-id"><i aria-hidden="true"></i></button>`),Wf=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),Gf=U(`<span> </span>`),Kf=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>`),qf=U(`<div class="bpadr-read"><!></div> <!>`,1),Jf=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),Yf=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>`),Xf=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>`),Zf=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>`),Qf=U(`<!> <!>`,1);function $f(e,t){qe(t,!0);let n=qi(t,`onchanged`,3,()=>{}),r=`001_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 te(){await fetch(`/api/blueprint/blueprint-folder`,{method:`POST`}),V(g)&&await E(V(g),i(V(g).folder.name))}async function O(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=Qf(),ie=R(re),ae=e=>{var t=Xf(),n=L(t),i=L(n),a=L(i),g=L(a),w=L(g),T=e=>{var t=Hf(),n=R(t),r=L(n,!0);j(n);var i=z(n,2),a=L(i,!0);j(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)}),j(g);var ne=z(g,2),A=e=>{var t=Uf(),n=L(t);j(t),B(e=>{J(t,`title`,e),vi(t,1,`bpadr-copy-btn ${V(C)?`copied`:``}`),vi(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)}),j(a);var re=z(a,2),ie=L(re),ae=e=>{var t=Wf(),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);j(re),j(i);var se=z(i,2),ce=e=>{var t=qf(),n=R(t),r=L(n);{let e=N(()=>V(h)??``);Ui(Vf(r,{get docId(){return V(e)},get content(){return V(d)},get html(){return V(f)},onsave:O,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(_))}j(n);var i=z(n,2),a=e=>{var t=Kf(),n=L(t),r=e=>{var t=Gf(),n=L(t,!0);j(t),B(()=>{vi(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);j(i);var o=z(i,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c,!0);j(c),j(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=Jf(),n=R(t),i=L(n);ki(i);var a=z(i,2);ki(a),Ai(a,r);var s=z(a,2),d=L(s),f=L(d,!0);j(d);var p=z(d,2);ki(p),j(s);var m=z(s,2),g=L(m),_=L(g,!0);j(g);var v=z(g,2);yn(v),Ui(v,e=>F(b,e),()=>V(b)),j(m);var y=z(m,2),S=L(y),C=L(S,!0);j(S);var w=z(S,2),T=L(w,!0);j(w);var E=z(w,2),ee=L(E,!0);j(E),j(y),j(n),cf(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)=>{Ai(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),Fi(p,()=>V(c),e=>F(c,e)),Fi(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=Yf(),n=L(t);si(n,()=>Y(`blueprint.adr.folder_missing`,{name:V(p)}),!0),j(n);var r=z(n,2),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2),l=L(c,!0);j(c),j(a),j(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,te),W(e,t)};K(se,e=>{V(o)===`doc`?e(ce):V(o)===`form`?e(le,1):V(o)===`folder-confirm`&&e(ue,2)}),j(n),j(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=Zf(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a);var c=z(a,2),l=L(c),u=L(l,!0);j(l);var d=z(l,2),f=L(d,!0);j(d),j(c),j(n),j(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),Je(A)}Pr([`click`]);var ep=U(`<span class="breadcrumb-sep">›</span>`),tp=U(`<span class="breadcrumb-item current"> </span>`),np=U(`<button class="breadcrumb-item" type="button"> </button>`),rp=U(`<!> <!>`,1),ip=U(`<nav class="breadcrumb"></nav>`),ap=U(`<div class="app-shell"><!> <section class="workspace-shell"><!> <!></section></div> <!>`,1);function op(e,t){qe(t,!0),Ji(async()=>{try{await Sa((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=ap(),f=R(d),p=L(f);{let e=N(()=>Y(`blueprint.subtitle`));Xo(p,{title:`Blueprint`,get subtitle(){return V(e)},children:(e,t)=>{var r=ip();q(r,21,()=>V(n),Qr,(e,t,r)=>{var i=rp(),a=R(i),o=e=>{W(e,ep())};K(a,e=>{r>0&&e(o)});var c=z(a,2),l=e=>{var n=tp(),r=L(n,!0);j(n),B(()=>G(r,V(t).name)),W(e,n)},u=e=>{var n=np(),r=L(n,!0);j(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)}),j(r),W(e,r)},$$slots:{default:!0}})}var m=z(p,2),h=L(m);Ui(ks(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=>{Ui(Ys(e,{onclose:l,onnavigate:u}),e=>F(a,e,!0),()=>V(a))};K(g,e=>{V(r)!==null&&e(_)}),j(m),j(f),Ui($f(z(f,2),{onchanged:()=>V(i).loadPath(V(n).at(-1)?.path??``,!1)}),e=>F(o,e,!0),()=>V(o)),W(e,d),Je()}Pr([`click`]);var sp=164,cp=64,lp=132,up=78,dp=6,fp=24,pp=96,mp=540,hp=780,gp=1/2,_p=9999,vp=44,yp=255,bp=178,xp=Math.PI*.7,Sp=Math.PI*1.1,Cp=Math.PI*1.45,wp=Math.PI*1.75,Tp=14,Ep=260,Dp=56,Op=32,kp=[`pointerdown`,`mousedown`,`click`,`dblclick`,`touchstart`,`wheel`],Ap=.35,jp=2.2,Mp=.0018,Np=4,Pp=46,Fp=4,Ip=44,Lp=360,Rp=300,zp=44,Bp=48,Vp=7,Hp=875,Up=450,Wp=600*1e3,Gp,Z,Kp,qp,Jp,Yp,Xp,Zp=[],Qp,$p,em,tm,nm,rm,im,am,om,sm,cm,lm,um,dm,fm,pm,mm,hm,gm,_m,vm,ym=null,bm=null,xm=null,Q,$,Sm,Cm=!1;function wm(){return Gp=document.getElementById(`workspaceCanvas`),Z=Gp.getContext(`2d`),Kp=document.getElementById(`apiStatus`),qp=document.getElementById(`addButton`),Jp=document.getElementById(`fitButton`),Yp=document.getElementById(`testNodeButton`),Xp=document.getElementById(`loadModelsButton`),Qp=document.getElementById(`closePanelButton`),$p=document.getElementById(`deleteNodeButton`),em=document.getElementById(`renameConfirmOverlay`),tm=document.getElementById(`renameConfirmMessage`),nm=document.getElementById(`cancelRenameButton`),rm=document.getElementById(`confirmRenameButton`),im=document.getElementById(`deleteConfirmOverlay`),am=document.getElementById(`deleteConfirmMessage`),om=document.getElementById(`cancelDeleteButton`),sm=document.getElementById(`confirmDeleteButton`),cm=document.getElementById(`agentRunOverlay`),lm=document.getElementById(`agentRunTitle`),um=document.getElementById(`agentRunHint`),dm=document.getElementById(`agentRunInputField`),fm=document.getElementById(`agentRunInput`),pm=document.getElementById(`agentRunResult`),mm=document.getElementById(`cancelAgentRunButton`),hm=document.getElementById(`executeAgentRunButton`),gm=document.getElementById(`fallbackPanelHost`),_m=document.getElementById(`configSurface`),vm=_m,ym=null,bm=null,xm=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`),modelFilter:document.getElementById(`nodeModelFilter`),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`),agentProvider:document.getElementById(`nodeAgentProvider`),systemPrompt:document.getElementById(`nodeSystemPrompt`),requiresUserInput:document.getElementById(`nodeRequiresUserInput`),userInputDescriptionField:document.getElementById(`agentUserInputDescriptionField`),userInputDescription:document.getElementById(`nodeUserInputDescription`),expectedOutputMarker:document.getElementById(`nodeExpectedOutputMarker`)},$={entities:Wm([Um(`root`,`Living AI Documentation`,`system`,null),Um(`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},Cm=!!Gp.requestPaint&&typeof Z.drawElementImage==`function`,Cm?($.apiMode=`html-in-canvas`,Kp.textContent=`HTML-in-Canvas active`,Kp.classList.add(`is-live`),Gp.onpaint=Xh):(gm.appendChild(_m),Kp.textContent=`DOM fallback`,Kp.classList.add(`is-fallback`)),Sm=new ResizeObserver(([e])=>{let t=e.devicePixelContentBoxSize?.[0],n=e.contentRect.width,r=e.contentRect.height;$.dpr=t?t.inlineSize/n:window.devicePixelRatio||1,Gp.width=t?t.inlineSize:Math.floor(n*$.dpr),Gp.height=t?t.blockSize:Math.floor(r*$.dpr),Qm(),og(!1,!$.cameraX&&!$.cameraY),Yh()}),Sm.observe(Gp,{box:`device-pixel-content-box`}),Tm(),Em(),qp.addEventListener(`click`,()=>{Ym()}),Jp.addEventListener(`click`,()=>{Qm(),og(!0,!0),jm(),Yh()}),Gp.addEventListener(`pointerdown`,e=>{if(e.target!==Gp)return;let t=kg(e),n=gg(t),r=[...$.entities].reverse().find(e=>Sg(e,n));if(r){r.id!==`root`&&uh(r.id);return}$.isPanning=!0,$.didPan=!1,$.panStartX=t.x,$.panStartY=t.y,$.panStartCameraX=$.cameraX,$.panStartCameraY=$.cameraY,Gp.classList.add(`is-panning`),Gp.setPointerCapture?.(e.pointerId)}),Gp.addEventListener(`pointermove`,e=>{if(!$.isPanning)return;let t=kg(e),n=t.x-$.panStartX,r=t.y-$.panStartY;Math.hypot(n,r)>Np&&($.didPan=!0),$.cameraX=$.panStartCameraX+n,$.cameraY=$.panStartCameraY+r,Yh()}),Gp.addEventListener(`pointerup`,e=>{$.isPanning&&($.isPanning=!1,Gp.classList.remove(`is-panning`),Gp.releasePointerCapture?.(e.pointerId),!$.didPan&&$.selectedId?uh(null):$.didPan&&jm())}),Gp.addEventListener(`pointercancel`,e=>{$.isPanning=!1,Gp.classList.remove(`is-panning`),Gp.releasePointerCapture?.(e.pointerId)}),Gp.addEventListener(`wheel`,e=>{e.target===Gp&&(e.preventDefault(),hg(kg(e),Math.exp(-e.deltaY*Mp)),jm())},{passive:!1}),vm.addEventListener(`submit`,e=>{e.preventDefault(),vh(),$.lastSaveAt=new Date,Qm(),Nm(!0),Yh()}),vm.addEventListener(`input`,()=>{vh(),Qm(),$.panelDirty=!0,Yh()}),Qp.addEventListener(`click`,()=>{uh(null)}),$p.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let t=$.selectedId,n=t?Gh(t):null;!n||Kh(t)||dh(n)}),om.addEventListener(`click`,fh),im.addEventListener(`click`,e=>{e.target===im&&fh()}),sm.addEventListener(`click`,()=>{$.pendingDeleteId&&ph($.pendingDeleteId),fh()}),Yp.addEventListener(`click`,()=>{if(Wh()?.kind===`agent`){wh();return}zh()}),Xp.addEventListener(`click`,()=>{Rh()}),Q.copyProviderId.addEventListener(`click`,()=>{Vh()}),Q.name.addEventListener(`blur`,()=>{if(Wh()?.kind!==`agent`)return;let e=Q.name.value.trim();if(!e||!ym||!bm||e===ym)return;let t=Km(e);t!==bm&&(tm.textContent=`Renommer le dossier "${bm}" en "${t}" ?`,em.hidden=!1,nm.focus())}),nm.addEventListener(`click`,()=>{em.hidden=!0;let e=Wh();e&&ym&&(e.label=ym,Q.name.value=ym,Qm(),Yh())}),rm.addEventListener(`click`,()=>{em.hidden=!0;let e=Wh();if(!e||!bm)return;e.config.workspaceFolder=bm,Q.workspaceFolder.value=bm;let t=Q.name.value.trim();t&&(ym=t),bm=Km(t),jm()}),Q.modelFilter.addEventListener(`input`,()=>{Lh()}),Q.model.addEventListener(`change`,()=>{Yp.disabled=!Q.model.value;let e=Wh();e&&(e.config.model=Q.model.value)}),Q.agentProvider.addEventListener(`change`,()=>{bh(Q.agentProvider.value)}),mm.addEventListener(`click`,()=>{Th()}),hm.addEventListener(`click`,()=>{Eh()}),cm.addEventListener(`click`,e=>{e.target===cm&&Th()}),Om(),()=>{Mm(),Sm.disconnect(),$?.saveTimerId&&clearTimeout($.saveTimerId)}}function Tm(){for(let e of kp)_m.addEventListener(e,Dm),gm.addEventListener(e,Dm)}function Em(){for(let e of kp)im.addEventListener(e,Dm),em.addEventListener(e,Dm),cm.addEventListener(e,Dm)}function Dm(e){e.stopPropagation()}async function Om(){let e=await So();e?.entities?.length&&($.entities=km(e.entities),$.cameraX=Hm(e.camera?.x,$.cameraX),$.cameraY=Hm(e.camera?.y,$.cameraY),$.zoom=_g(Hm(e.camera?.zoom,$.zoom),Ap,jp),$.lastSaveAt=e.updatedAt?new Date(e.updatedAt):null),$.isHydrated=!0,Qm(),e?.entities?.length||og(!1,!0),_h(),Yh()}function km(e){let t=e.map(Am).filter(e=>!!e),n=t.some(e=>e.id===`root`),r=t.some(e=>e.id===`mcp`),i=[...n?[]:[Um(`root`,`Living AI Documentation`,`system`,null)],...t,...r?[]:[Um(`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:{...Um(e.id,e.label,t,n).config,...e.config}}})}function Am(e){if(!Lm(e))return null;let t=Rm(e.id),n=Rm(e.label),r=zm(e.kind);if(!t||!n||!r)return null;let i=e.parentId===null?null:Rm(e.parentId),a=Lm(e.config)?e.config:{};return{id:t,label:n,kind:r,parentId:i,x:Hm(e.x,0),y:Hm(e.y,0),angle:Hm(e.angle,0),config:{endpoint:Rm(a.endpoint)||Gm(t,r),token:Rm(a.token),model:Rm(a.model),providerType:Vm(a.providerType),toolMode:Bm(a.toolMode),timeout:Hm(a.timeout,180),description:Rm(a.description)||Jm(r),workspaceFolder:Rm(a.workspaceFolder)||(r===`agent`?Km(n):``),systemPrompt:Rm(a.systemPrompt),requiresUserInput:a.requiresUserInput===!0,userInputDescription:Rm(a.userInputDescription),expectedOutputMarker:Rm(a.expectedOutputMarker)}}}function jm(){$.isHydrated&&($.saveTimerId&&clearTimeout($.saveTimerId),$.saveTimerId=window.setTimeout(()=>{$.saveTimerId=null,Nm(!1)},Up))}function Mm(){$.panelDirty&&Nm(!1)}async function Nm(e=!1){if(!$.isHydrated)return;$.panelDirty=!1,$.saveTimerId&&(clearTimeout($.saveTimerId),$.saveTimerId=null);let t=$.selectedId&&document.activeElement===Q.token&&Nh(Q.token.value)?{entityId:$.selectedId,value:Q.token.value,selectionStart:Q.token.selectionStart,selectionEnd:Q.token.selectionEnd}:null,n=await Co(Im());if(n){if($.entities=km(n.entities),t&&$.selectedId===t.entityId){let e=Wh();e?.kind===`llm`&&(e.config.token=t.value)}$.lastSaveAt=new Date(n.updatedAt),Wh()&&!vm.contains(document.activeElement)&&_h(),t&&$.selectedId===t.entityId&&(Q.token.value=t.value,Q.token.setSelectionRange(t.selectionStart,t.selectionEnd)),e&&Fm(`Workspace saved`)}else e&&Fm(`Save failed`)}function Pm(e,t){return yo(e,t)}function Fm(e,t=`success`,n,r){return bo(e,t,n,r)}function Im(){return{version:1,updatedAt:new Date().toISOString(),entities:$.entities.map(e=>{let t={...e.config,token:Ph(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 Lm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Rm(e){return typeof e==`string`?e:``}function zm(e){return e===`system`||e===`llm`||e===`agent`||e===`mcp`?e:null}function Bm(e){return e===`chat`?`chat`:`tools`}function Vm(e){return e===`image`?`image`:`chat`}function Hm(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function Um(e,t,n,r){return{id:e,label:t,kind:n,parentId:r,x:0,y:0,angle:0,config:{endpoint:Gm(e,n),token:``,model:``,providerType:`chat`,toolMode:`tools`,timeout:180,description:Jm(n),workspaceFolder:n===`agent`?Km(t):``,systemPrompt:``,requiresUserInput:!1,userInputDescription:``,expectedOutputMarker:``}}}function Wm(e){return e.map(e=>({...e,config:{...e.config}}))}function Gm(e,t){return t===`llm`?`http://localhost:11434`:t===`mcp`?`http://localhost:4321/mcp`:``}function Km(e){return`AI/WORKSPACE/${qm(e)}`}function qm(e){return e.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`llm_provider`}function Jm(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 Ym(){let e=Wh(),t=e?.kind===`llm`?e:Gh(e?.parentId);if(t?.kind===`llm`&&t.config.providerType!==`image`){Zm(t.id);return}Xm()}function Xm(){let e=!!$.selectedId,t=qh(`root`).filter(e=>e.kind===`llm`).length+1,n=Um(`provider-${Date.now().toString(36)}`,`LLM Provider ${t}`,`llm`,`root`);$.entities=[...$.entities,n],$.selectedId=n.id,Qm(),sg(e,!0,!0),_h(),jm(),Yh()}function Zm(e){let t=!!$.selectedId,n=qh(e).filter(e=>e.kind===`agent`).length+1,r=Um(`agent-${Date.now().toString(36)}`,`Agent ${n}`,`agent`,e);$.entities=[...$.entities,r],$.selectedId=r.id,Qm(),sg(t,!0,!0),_h(),jm(),Yh()}function Qm(){let e=Gh(`root`);e.x=0,e.y=0,e.angle=0,$m(e)}function $m(e){let t=qh(e.id),n=ah(t,lp,yp,{spread:Math.PI*2,includeSubtree:!1}),r=new Map(t.map(e=>[e.id,rh(e,n)]));for(let n=0;n<=Vp;n+=1)if(eh(e,t,r),th(),!nh(t,r))return;eh(e,t,r),th()}function eh(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)||yp;t.angle=a,t.x=e.x+Math.cos(a)*o,t.y=e.y+Math.sin(a)*o})}function th(){for(let e of $.entities.filter(e=>e.kind===`llm`))ih(e)}function nh(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];Og(Tg(a),Tg(o),zp)&&(t.set(a.id,Math.min(Hp,t.get(a.id)+Bp)),t.set(o.id,Math.min(Hp,t.get(o.id)+Bp)),n=!0)}return n}function rh(e,t){if(e.kind!==`llm`)return t;let n=qh(e.id).length;if(n<=Fp)return t;let r=(n-Fp)*Ip,i=Math.max(0,ch(e)-Rp)*.65;return t+Math.min(Lp,Math.max(r,i))}function ih(e){let t=qh(e.id);if(!t.length)return;let n=Math.atan2(e.y,e.x),r=oh(t.length),i=ah(t,up,bp,{spread:r,includeSubtree:!1});t.forEach((a,o)=>{let s=sh(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 ah(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?ch(e):lh(e))),s=t+o+Pp;if(e.length===1)return Math.max(n,s);let c=o*2+Pp,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 oh(e){return e<=1?0:e<=2?xp:e<=4?Sp:e<=7?Cp:wp}function sh(e,t,n,r){return r<=1||t===0?e:e-t/2+n/(r-1)*t}function ch(e){if(e.kind!==`llm`)return lh(e);let t=qh(e.id);return t.length?ah(t,up,bp,{spread:oh(t.length),includeSubtree:!1})+Math.max(...t.map(e=>lh(e))):up}function lh(e){if(e.kind===`system`)return lp;if(e.kind===`llm`)return up;let{width:t,height:n}=wg(e);return Math.hypot(t/2,n/2)}function uh(e){e!==$.selectedId&&Mm();let t=!!$.selectedId;$.selectedId=e;let n=e?Gh(e):null;ym=n?.kind===`agent`?n.label:null,bm=n?.kind===`agent`?n.config.workspaceFolder||Km(n.label):null,Qm(),sg(t,!!e,!0),_h(),Yh()}function dh(e){let t=Jh(e.id),n=qh(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,am.textContent=`You are about to delete "${e.label}".${r} This action cannot be undone.`,im.hidden=!1,sm.focus()}function fh(){$.pendingDeleteId=null,im.hidden=!0}function ph(e){let t=Gh(e);if(!t||Kh(e))return;let n=t.parentId||`root`,r=!!$.selectedId,i=new Set([e,...Jh(e)]);$.entities=$.entities.filter(e=>!i.has(e.id)),$.selectedId=Gh(n)?n:null,Qm(),sg(r,!!$.selectedId,!0),_h(),jm(),Yh()}var mh=0;async function hh(e){let t=++mh,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 To({endpoint:n});if(t===mh){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,gh(Q.mcpToolsList,i.tools??[],`No tools exposed.`),gh(Q.mcpPromptsList,i.prompts??[],`No prompts exposed.`)}}function gh(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 _h(){let e=Wh(),t=!!e;if(_m.hidden=!t,gm.hidden=!t||Cm,!e){qp.title=`Add LLM provider`,Yp.textContent=`Test`,Yp.hidden=!0,Yp.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,Ch(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=Uh(e),Q.kind.disabled=!0,Q.llmFields.hidden=e.kind===`mcp`||e.kind===`agent`,Sh(e),Q.mcpInventory.hidden=e.kind!==`mcp`,e.kind===`mcp`?hh(e):mh+=1,Q.agentSection.hidden=e.kind!==`agent`,e.kind===`agent`&&yh(e),Q.systemPrompt.value=e.config.systemPrompt,Q.requiresUserInput.checked=e.config.requiresUserInput,xh(),Q.userInputDescription.value=e.config.userInputDescription,Q.expectedOutputMarker.value=e.config.expectedOutputMarker,$p.hidden=Kh(e.id),Yp.textContent=`Test`,Yp.hidden=e.kind!==`llm`&&e.kind!==`agent`,Yp.disabled=e.kind===`llm`?!e.config.model:e.kind!==`agent`;let n=e.kind===`llm`?e:Gh(e.parentId);qp.title=n?.kind===`llm`&&n.config.providerType!==`image`?`Add agent`:`Add LLM provider`}function vh(){let e=Wh();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,xh(),Sh(e),Q.typeBadge.textContent=Uh(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 yh(e){let t=Q.agentProvider;t.innerHTML=``;let n=$.entities.filter(e=>e.kind===`llm`&&e.config.providerType!==`image`);for(let e of n){let n=document.createElement(`option`);n.value=e.id,n.textContent=e.label,t.appendChild(n)}t.value=e.parentId??``}function bh(e){let t=Wh();if(t?.kind!==`agent`)return;let n=Gh(e);n?.kind===`llm`&&t.parentId!==e&&(t.parentId=e,t.config.model=n.config.model,t.config.timeout=n.config.timeout,Qm(),jm(),Yh())}function xh(){let e=Wh()?.kind===`agent`&&Q.requiresUserInput.checked;Q.userInputDescriptionField.hidden=!e,Q.userInputDescription.required=e}function Sh(e){let t=e.kind===`llm`,n=e.config.providerType===`image`;Q.providerIdField.hidden=!t,Q.toolModeField.hidden=!t||n,Xp.title=Y(n?`workspace.model.load_image`:`workspace.model.load_chat`),Yp.title=n?`Test image provider configuration`:`Test chat provider configuration`}function Ch(e){let t=Array.from(Q.model.options).map(e=>e.value);if(e&&!t.includes(e)){Ih([]),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 wh(){let e=Wh();if(e?.kind!==`agent`)return;vh();let t=Gh(e.parentId??``);if(t?.kind!==`llm`){Fm(`No parent LLM found for this agent.`,`error`);return}if(!t.config.model){Fm(`Parent LLM has no model selected.`,`error`);return}if(!e.config.systemPrompt.trim()){Fm(`Write a system prompt first.`,`error`);return}if(e.config.requiresUserInput&&!e.config.userInputDescription.trim()){Fm(`Describe the required user input first.`,`error`);return}xm=e.id,lm.textContent=`Test ${e.label}`,um.textContent=e.config.requiresUserInput?e.config.userInputDescription:`Run this agent with its configured system prompt.`,dm.hidden=!e.config.requiresUserInput,fm.required=e.config.requiresUserInput,fm.value=``,pm.hidden=!0,pm.textContent=``,hm.disabled=!1,hm.textContent=`Run`,cm.hidden=!1,e.config.requiresUserInput?window.setTimeout(()=>fm.focus(),0):window.setTimeout(()=>hm.focus(),0)}function Th(){cm.hidden=!0,xm=null}async function Eh(){if(fm.required&&!fm.value.trim()){fm.reportValidity();return}let e=xm?Gh(xm):null;if(e?.kind!==`agent`){jh(`error`,`The selected agent is no longer available.`);return}let t=Gh(e.parentId??``);if(t?.kind!==`llm`){jh(`error`,`No parent LLM found for this agent.`);return}hm.disabled=!0,hm.textContent=`Running…`;let n=Pm(`Running agent…`);Oh();let r=$.entities.find(e=>e.kind===`mcp`),i=!1,a=await Eo({providerId:t.id,endpoint:t.config.endpoint,model:t.config.model,systemPrompt:e.config.systemPrompt,userInput:fm.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`&&Pm(Dh(e),n),kh(e)});hm.disabled=!1,hm.textContent=`Run`,a.ok&&a.content?(Ah(a.content),Fm(`Agent responded. Result saved in AI/WORKSPACE.`,`success`,Wp,n)):(i||kh({type:`error`,message:a.error??`Agent failed.`}),pm.dataset.state=`error`,Fm(a.error??`Agent failed.`,`error`,Wp,n))}function Dh(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 Oh(){pm.hidden=!1,pm.dataset.state=`loading`,pm.textContent=``,kh({type:`status`,message:`Preparing agent request`})}function kh(e){pm.hidden=!1,e.type===`error`&&(pm.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),pm.appendChild(t),pm.scrollTop=pm.scrollHeight}function Ah(e){pm.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),pm.appendChild(t),pm.scrollTop=pm.scrollHeight}function jh(e,t){pm.hidden=!1,pm.dataset.state=e,pm.textContent=t}var Mh=/^(?:env:[A-Za-z_][A-Za-z0-9_]*|\$\{[A-Za-z_][A-Za-z0-9_]*\})$/;function Nh(e){let t=e.trim();return t!==``&&!Mh.test(t)}function Ph(e){let t=e.trim();return Nh(t)?``:t}var Fh=`API token must reference an environment variable, e.g. env:LLM_API_KEY`;function Ih(e){Zp=e,Q.modelFilter.value=``,Q.modelFilter.hidden=e.length===0,Lh()}function Lh(){if(Zp.length===0)return;let e=Q.model.value,t=Q.modelFilter.value.toLowerCase().split(/\s+/).filter(Boolean),n=Zp.filter(e=>{let n=e.toLowerCase();return t.every(e=>n.includes(e))}),r=e&&Zp.includes(e)&&!n.includes(e)?[e,...n]:n;Q.model.innerHTML=``;for(let e of r){let t=document.createElement(`option`);t.value=e,t.textContent=e,Q.model.appendChild(t)}if(n.length===0){let e=document.createElement(`option`);e.value=``,e.disabled=!0,e.textContent=Y(`workspace.model.no_match`),Q.model.appendChild(e)}Q.model.value=e&&r.includes(e)?e:r[0]??``,Q.modelFilter.title=Y(`workspace.model.filter_count`,{shown:String(n.length),total:String(Zp.length)})}async function Rh(){let e=Wh();if(e?.kind!==`llm`)return;vh();let t=e.config.endpoint;if(!t){Fm(Y(`workspace.model.endpoint_required`));return}if(Nh(e.config.token)){Fm(Fh);return}Xp.classList.add(`loading`),Xp.disabled=!0,Q.model.disabled=!0;let n=await wo({endpoint:t,token:e.config.token,providerType:e.config.providerType});if(Xp.classList.remove(`loading`),Xp.disabled=!1,Q.model.disabled=!1,!n.ok||!n.models?.length){Fm(n.error??Y(`workspace.model.none_found`));return}let r=Q.model.value;Ih(n.models),Q.model.value=n.models.includes(r)?r:n.models[0],Lh(),e.config.model=Q.model.value,Yp.disabled=!Q.model.value,Fm(n.models.length===1?Y(`workspace.model.loaded_one`):Y(`workspace.model.loaded_many`,{count:String(n.models.length)})),Yh()}async function zh(){let e=Wh();if(e?.kind!==`llm`)return;if(vh(),Nh(e.config.token)){Fm(Fh);return}Yp.disabled=!0,Pm(`Testing ${e.config.model}…`),Yh();let t=e.config.providerType===`image`?await Bh(e):await Oo({endpoint:e.config.endpoint,token:e.config.token,model:e.config.model,timeout:e.config.timeout});Yp.disabled=!1,t.ok?Fm(t.detail??`Connection OK`,`success`):Fm(t.error||`Connection failed (${t.status||`no status`})`,`error`),Yh()}async function Bh(e){let t=await wo({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 Vh(){let e=Wh();if(e?.kind===`llm`)try{await navigator.clipboard.writeText(e.id),Fm(`Provider ID copied`,`success`)}catch{Q.providerId.select(),Fm(`Provider ID selected`,`success`)}}function Hh(e){return{system:`System`,llm:`LLM provider`,agent:`Agent`,mcp:`MCP`}[e]||`Node`}function Uh(e){return e.kind===`llm`&&e.config.providerType===`image`?`Image provider`:Hh(e.kind)}function Wh(){return $.selectedId?Gh($.selectedId):null}function Gh(e){return $.entities.find(t=>t.id===e)}function Kh(e){return e===`root`||e===`mcp`}function qh(e){return $.entities.filter(t=>t.parentId===e)}function Jh(e){let t=[];for(let n of qh(e))t.push(n.id,...Jh(n.id));return t}function Yh(){Cm?Gp.requestPaint():requestAnimationFrame(Xh)}function Xh(){let e=Gp.width/$.dpr,t=Gp.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),Zh(e,t),Qh(),Z.restore(),Cm&&ag(e,t)}function Zh(e,t){Z.save(),Z.lineWidth=1/$.zoom;let n=gg({x:0,y:0}),r=gg({x:e,y:t}),i=Math.floor(n.x/fp)*fp,a=Math.ceil(r.x/fp)*fp,o=Math.floor(n.y/fp)*fp,s=Math.ceil(r.y/fp)*fp;for(let e=i;e<=a;e+=fp)Z.strokeStyle=e%pp===0?`#d7dce5`:`#edf0f4`,Ng(e,o,e,s);for(let e=o;e<=s;e+=fp)Z.strokeStyle=e%pp===0?`#d7dce5`:`#edf0f4`,Ng(i,e,a,e);Z.restore()}function Qh(){$h();for(let e of $.entities)eg(e)}function $h(){Z.save(),Z.lineWidth=2/$.zoom;for(let e of $.entities){let t=Gh(e.parentId);if(!t)continue;let n=Math.atan2(e.y-t.y,e.x-t.x),r=vg(t,n),i=vg(e,n+Math.PI);Z.strokeStyle=rg(e).connection,Z.beginPath(),Z.moveTo(r.x,r.y),Z.lineTo(i.x,i.y),Z.stroke()}Z.restore()}function eg(e){if(e.kind===`system`||e.kind===`llm`){tg(e);return}ng(e)}function tg(e){let t=e.id===$.selectedId,n=rg(e),r=e.kind===`system`?lp:up,i=qh(e.id),a=Math.max(dp,i.length),o=Ag(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`,Mg(e.label,e.x,e.y-8,r*1.32,e.kind===`system`?26:20),ig(e,t,r),Z.restore()}function ng(e){let t=e.id===$.selectedId,n=rg(e),r=e.kind===`mcp`?116:sp,i=e.kind===`mcp`?58:cp;Z.save(),jg(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`,Mg(e.label,e.x,e.y,r*.78,18),ig(e,t,Math.max(r,i)/2),Z.restore()}function rg(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=Gh(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 ig(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 ag(e,t){if(!Wh())return;let n=Cg(e),r=Math.min(_p,t-118),i=e-n-24,a=Math.max(24,(t-r)/2);try{let e=Z.drawElementImage(_m,i,a,n,r);_m.style.transform=e.toString()}catch{Kp.textContent=`Waiting for HTML snapshot`}}function og(e,t){let n=Gp.clientWidth,r=Gp.clientHeight,i=Wh()?Cg(n)+vp:0,a=Math.max(360,n-i),o=fg(),s=pg(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){mg(),$.cameraX=d,$.cameraY=f,$.zoom=c,$.panelShiftX=i;return}$.panelShiftX=i,dg(d,f,c)}function sg(e,t,n){if(t){if(e){let e=cg();$.panelShiftX+=Math.max(0,-e),ug(e,n)}else{let e=Wh();if(e){let t=Cg(Gp.clientWidth)+vp,n=(Gp.clientWidth-t)/2-e.x*$.zoom,r=n-$.cameraX;$.panelShiftX=-r,dg(n,$.cameraY,$.zoom)}}return}if(!e)return;let r=$.panelShiftX;$.panelShiftX=0,ug(r,n)}function cg(){let e=Wh();if(!e)return 0;let t=Gp.clientWidth-Cg(Gp.clientWidth)-24-Op,n=lg(e);return n.right<=t?0:t-n.right}function lg(e){let t=Eg(e);return{left:t.left*$.zoom+$.cameraX,top:t.top*$.zoom+$.cameraY,right:t.right*$.zoom+$.cameraX,bottom:t.bottom*$.zoom+$.cameraY}}function ug(e,t){if(mg(),!e)return;let n=$.cameraX+e;if(!t){$.cameraX=n;return}dg(n,$.cameraY,$.zoom)}function dg(e,t,n){mg();let r=$.cameraX,i=$.cameraY,a=$.zoom,o=performance.now();function s(c){let l=Math.min(1,(c-o)/Ep),u=1-(1-l)**3;$.cameraX=r+(e-r)*u,$.cameraY=i+(t-i)*u,$.zoom=a+(n-a)*u,Qm(),Yh(),l<1?$.viewAnimationId=requestAnimationFrame(s):$.viewAnimationId=null}$.viewAnimationId=requestAnimationFrame(s)}function fg(){return $.entities.reduce((e,t)=>{let n=lh(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 pg(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-Dp*2),o=Math.max(1,n-Dp*2);return _g(Math.min(1,a/r,o/i),Ap,1)}function mg(){$.viewAnimationId&&(cancelAnimationFrame($.viewAnimationId),$.viewAnimationId=null)}function hg(e,t){mg();let n=gg(e);$.zoom=_g($.zoom*t,Ap,jp),$.cameraX=e.x-n.x*$.zoom,$.cameraY=e.y-n.y*$.zoom,Yh()}function gg(e){return{x:(e.x-$.cameraX)/$.zoom,y:(e.y-$.cameraY)/$.zoom}}function _g(e,t,n){return Math.min(n,Math.max(t,e))}function vg(e,t){if(e.kind!==`system`&&e.kind!==`llm`)return xg(e,t);let n=e.kind===`system`?lp:up,r=qh(e.id);return yg(e,n,Math.max(dp,r.length),t)||{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function yg(e,t,n,r){let i={x:Math.cos(r),y:Math.sin(r)},a=Ag(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=bg(i,s);if(Math.abs(l)<1e-4)continue;let u=bg(c,s)/l,d=bg(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 bg(e,t){return e.x*t.y-e.y*t.x}function xg(e,t){let n=wg(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 Sg(e,t){if(e.kind===`system`||e.kind===`llm`){let n=e.kind===`system`?lp:up;return Math.hypot(t.x-e.x,t.y-e.y)<=n+Tp}let{width:n,height:r}=wg(e);return Math.abs(t.x-e.x)<=n/2+Tp&&Math.abs(t.y-e.y)<=r/2+Tp}function Cg(e){return Math.min(hp,Math.max(mp,Math.floor(e*gp)))}function wg(e){return e.kind===`mcp`?{width:116,height:58}:{width:sp,height:cp}}function Tg(e){return[e,...Jh(e.id).map(Gh)].filter(Boolean).map(Eg).reduce(Dg)}function Eg(e){if(e.kind===`system`||e.kind===`llm`){let t=e.kind===`system`?lp:up;return{left:e.x-t,top:e.y-t,right:e.x+t,bottom:e.y+t}}let{width:t,height:n}=wg(e);return{left:e.x-t/2,top:e.y-n/2,right:e.x+t/2,bottom:e.y+n/2}}function Dg(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 Og(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 kg(e){let t=Gp.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function Ag(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 jg(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 Mg(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 Ng(e,t,n,r){Z.beginPath(),Z.moveTo(e,t),Z.lineTo(n,r),Z.stroke()}var Pg=U(`<div class="status-row"><span id="apiStatus"></span></div>`),Fg=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> </span> <input id="nodeModelFilter" class="model-filter" type="search" autocomplete="off" spellcheck="false" hidden=""/> <div class="model-select-wrap"><select id="nodeModel" name="nodeModel"><option disabled="" selected=""> </option></select> <button id="loadModelsButton" class="icon-button" type="button">↻</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="agentProviderField" class="field wide"><span>LLM provider</span> <select id="nodeAgentProvider" name="nodeAgentProvider"></select> <small class="field-note">Move this agent to another LLM provider. It inherits the target provider\'s model and timeout.</small></label> <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 Ig(e,t){qe(t,!0),Ji(async()=>{try{await Sa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}return wm()});var n=Fg(),r=L(n);Xo(r,{title:`Living AI Documentation`,subtitle:`Graph-native configuration workspace`,children:(e,t)=>{var n=Pg(),r=L(n);vi(r,1,`status-pill `),r.textContent=`Detecting canvas API`,j(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`,j(l),j(c);var m=z(c,2),h=z(L(m),6),g=L(h),_=L(g,!0);j(g);var v=z(g,2),y=z(v,2),b=L(y),x=L(b),S=L(x,!0);j(x),x.value=x.__value=``,j(b);var C=z(b,2);j(y),j(h),Ie(6),j(m),Ie(2),j(s),Ie(6),j(o),j(a),Ie(2),j(i),Ie(6),j(n),B((e,t,n,r)=>{G(_,e),J(v,`placeholder`,t),G(S,n),J(C,`title`,r)},[()=>Y(`workspace.model.label`),()=>Y(`workspace.model.filter_placeholder`),()=>Y(`workspace.model.placeholder`),()=>Y(`workspace.model.load`)]),W(e,n),Je()}var Lg=U(`<p class="files-msg svelte-4q2lov"> </p>`),Rg=U(`<p class="files-msg files-msg--error svelte-4q2lov"> </p>`),zg=U(`<p class="files-msg files-msg--empty svelte-4q2lov"> </p>`),Bg=U(`<option> </option>`),Vg=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>`),Hg=U(`<span class="files-folder svelte-4q2lov"> </span> ·`,1),Ug=U(`<p class="files-row-error svelte-4q2lov"> </p>`),Wg=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>`),Gg=U(`<ul class="files-list svelte-4q2lov"></ul>`),Kg=U(`<!> <!>`,1),qg=U(`<!> <div class="app-shell"><!> <div class="files-page svelte-4q2lov"><!></div></div>`,1);function Jg(e,t){qe(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=Pf,f=N(()=>V(a)?V(r).filter(e=>e.folder===V(a)||e.folder.startsWith(V(a)+`/`)):V(r));function p(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 m(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 h(){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 g(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function _(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>d){F(c,{...V(c),[e.filename]:Y(`files.error_replace`)+`${(r.size/1024/1024).toFixed(1)} MB (max ${Ff} MB)`},!0);return}F(l,{...V(l),[e.filename]:!0},!0),F(c,{...V(c),[e.filename]:``},!0);try{let t=await g(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 h()}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 v(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 h()}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)}}}Ji(async()=>{try{await Sa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}await h()});var y=qg(),b=R(y);Ui(Xd(b,{}),e=>F(n,e,!0),()=>V(n));var x=z(b,2),S=L(x);{let e=N(()=>Y(`files.title`));Xo(S,{get title(){return V(e)},subtitle:``})}var C=z(S,2),w=L(C),T=e=>{var t=Lg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},E=e=>{var t=Rg(),n=L(t,!0);j(t),B(()=>G(n,V(s))),W(e,t)},D=e=>{var t=zg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`files.empty`)]),W(e,t)},ee=e=>{var t=Kg(),n=R(t),r=e=>{var t=Vg(),n=L(t),r=L(n,!0);j(n);var o=z(n,2),s=L(o),c=L(s,!0);j(s),s.value=s.__value=``,q(z(s),16,()=>V(i),e=>e,(e,t)=>{var n=Bg(),r=L(n,!0);j(n);var i={};B(()=>{G(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),W(e,n)}),j(o);var l;Si(o),j(t),B((e,t)=>{G(r,e),G(c,t),l!==(l=V(a))&&(o.value=(o.__value=V(a))??``,xi(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=zg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`files.empty_filter`)]),W(e,t)},d=e=>{var t=Gg();q(t,21,()=>V(f),Qr,(e,t)=>{var n=Wg(),r=z(L(n),2),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o),d=e=>{var n=Hg(),r=R(n),i=L(r,!0);j(r),Ie(),B(()=>G(i,V(t).folder)),W(e,n)};K(s,e=>{V(t).folder&&e(d)});var f=z(s),h=e=>{var n=Ur();B(e=>G(n,`${e??``} ·`),[()=>m(V(t).uploadedAt)]),W(e,n)};K(f,e=>{V(t).uploadedAt&&e(h)});var g=z(f,1,!0);j(o);var y=z(o,2),b=e=>{var n=Ug(),r=L(n,!0);j(n),B(()=>G(r,V(c)[V(t).filename])),W(e,n)};K(y,e=>{V(c)[V(t).filename]&&e(b)}),j(r);var x=z(r,2),S=L(x),C=L(S,!0);j(S);var w=z(S,2),T=L(w,!0);j(w),j(x),j(n),B((e,n,r)=>{J(i,`href`,V(t).url),G(a,V(t).displayName||V(t).filename),G(g,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)},[()=>p(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,()=>_(V(t))),H(`click`,w,()=>v(V(t))),W(e,n)}),j(t),W(e,t)};K(o,e=>{V(f).length===0?e(s):e(d,-1)}),W(e,t)};K(w,e=>{V(o)?e(T):V(s)?e(E,1):V(r).length===0?e(D,2):e(ee,-1)}),j(C),j(x),W(e,y),Je()}Pr([`change`,`click`]);var Yg=U(`<p class="browser-msg"> </p>`),Xg=U(`<p class="browser-msg browser-msg--error"> </p>`),Zg=U(`<button class="browser-row browser-row--dir"><span class="browser-row-name"> </span></button>`),Qg=U(`<span class="badge-added"> </span>`),$g=U(`<button class="link-btn"> </button>`),e_=U(`<div class="browser-row browser-row--file"><span class="browser-row-name"> </span> <!></div>`),t_=U(`<!> <!>`,1),n_=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>`),r_=U(`<p class="empty-msg svelte-e5jhdq"> </p>`),i_=U(`<button class="remove-btn"> </button>`),a_=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>`),o_=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 s_(e,t){qe(t,!0);let n=qi(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=o_(),y=L(v),b=L(y),x=L(b,!0);j(b);var S=z(b,2),C=L(S),w=L(C);j(C);var T=z(C,2),E=L(T,!0);j(T),j(S),j(y);var D=z(y,2),ee=e=>{var t=n_(),n=L(t),r=L(n),d=L(r,!0);j(r);var f=z(r,2),p=L(f,!0);j(f),j(n);var m=z(n,2),g=L(m),v=e=>{var t=Yg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},y=e=>{var t=Xg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.cannot_read_dir`)]),W(e,t)},b=e=>{var t=Yg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.empty_dir`)]),W(e,t)},x=e=>{var t=t_(),n=R(t);q(n,17,()=>V(o),Qr,(e,t)=>{var n=Zg(),r=L(n),i=L(r);j(r),j(n),B(()=>G(i,`📁 ${V(t).name??``}`)),H(`click`,n,()=>h(V(t).path)),W(e,n)}),q(z(n,2),17,()=>V(s),Qr,(e,t)=>{var n=e_(),r=L(n),i=L(r);j(r);var a=z(r,2),o=e=>{var t=Qg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.added`)]),W(e,t)},s=N(()=>V(u).has(V(t).name)),c=e=>{var n=$g(),r=L(n,!0);j(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)}),j(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)}),j(m),j(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 te=z(D,2),O=L(te),k=e=>{var t=r_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.no_instructions`)]),W(e,t)},ne=e=>{var r=Wr();q(R(r),17,n,Qr,(e,n)=>{var r=a_(),i=L(r),a=L(i),o=L(a,!0);j(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)}),j(s),j(i);var h=z(i,2),g=L(h),_=L(g,!0);j(g);var v=z(g,2),y=e=>{var r=i_(),i=L(r,!0);j(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)}),j(h),j(r),B((e,t,r,i)=>{J(a,`href`,e),G(o,V(n).path),G(c,`${t??``} · ${r??``} `),vi(g,1,fi(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(O,e=>{n().length?e(ne,-1):e(k)}),j(te),j(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),Je()}Pr([`click`]);var c_=U(`<span class="rules-folder svelte-1r3tey2"> </span>`),l_=U(`<p class="empty-msg svelte-1r3tey2"> </p>`),u_=U(`<span class="tag svelte-1r3tey2"> </span>`),d_=U(`<div class="rule-tags svelte-1r3tey2"></div>`),f_=U(`<div class="rule-applies svelte-1r3tey2"> </div>`),p_=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>`),m_=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 h_(e,t){qe(t,!0);let n=qi(t,`rules`,19,()=>[]),r=qi(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=m_(),g=L(h),_=L(g),v=L(_),y=L(v,!0);j(v);var b=z(v,2),x=e=>{var t=c_(),n=L(t,!0);j(t),B(()=>G(n,r())),W(e,t)};K(b,e=>{r()&&e(x)}),j(_);var S=z(_,2),C=L(S),w=e=>{var t=l_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.no_rules`)]),W(e,t)},T=e=>{var t=Wr();q(R(t),17,n,Qr,(e,t)=>{var n=p_(),r=L(n),i=L(r),a=L(i),o=L(a),s=L(o,!0);j(o),j(a);var c=z(a,2),l=L(c,!0);j(c),j(i);var u=z(i,2),p=L(u,!0);j(u),j(r);var m=z(r,2),h=L(m,!0);j(m);var g=z(m,2),_=e=>{var n=d_();q(n,21,()=>V(t).tags,Qr,(e,t)=>{var n=u_(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(n),W(e,n)};K(g,e=>{V(t).tags?.length&&e(_)});var v=z(g,2),y=e=>{var n=f_(),r=L(n,!0);j(n),B(e=>G(r,e),[()=>V(t).appliesTo.join(`, `)]),W(e,n)};K(v,e=>{V(t).appliesTo?.length&&e(y)}),j(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)}),j(S),j(g);var E=z(g,2),D=L(E),ee=L(D,!0);j(D);var te=z(D,2),O=L(te),k=L(O,!0);j(O);var ne=z(O,2);ki(ne),j(te);var A=z(te,2),re=L(A),ie=L(re,!0);j(re);var ae=z(re,2),oe=L(ae),se=L(oe,!0);j(oe),oe.value=oe.__value=`guideline`;var ce=z(oe),le=L(ce,!0);j(ce),ce.value=ce.__value=`warning`;var ue=z(ce),de=L(ue,!0);j(ue),ue.value=ue.__value=`required`,j(ae),j(A);var fe=z(A,2),pe=L(fe),me=L(pe,!0);j(pe);var he=z(pe,2);ki(he),j(fe);var ge=z(fe,2),_e=L(ge),ve=L(_e,!0);j(_e);var ye=z(_e,2);ki(ye),j(ge);var be=z(ge,2),xe=L(be),Se=L(xe,!0);j(xe);var Ce=z(xe,2);ki(Ce),j(be);var we=z(be,2),Te=L(we),Ee=L(Te,!0);j(Te);var De=z(Te,2);yn(De),j(we);var Oe=z(we,2),ke=L(Oe,!0);j(Oe),j(E),j(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(Ee,m),J(De,`placeholder`,h),Oe.disabled=g,G(ke,_)},[()=>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`)]),Fi(ne,()=>V(i),e=>F(i,e)),Ci(ae,()=>V(a),e=>F(a,e)),Fi(he,()=>V(o),e=>F(o,e)),Fi(ye,()=>V(s),e=>F(s,e)),Fi(Ce,()=>V(c),e=>F(c,e)),Fi(De,()=>V(l),e=>F(l,e)),H(`click`,Oe,m),W(e,h),Je()}Pr([`click`]);var g_=U(`<p class="empty-msg svelte-1ui2b6s"> </p>`),__=U(`<p class="mcp-desc svelte-1ui2b6s"> </p>`),v_=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>`),y_=U(`<div class="mcp-result svelte-1ui2b6s" data-testid="mcp-result"></div>`),b_=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>`),x_=U(`<p class="mcp-arg-desc svelte-1ui2b6s"> </p>`),S_=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>`),C_=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>`),w_=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 T_(e,t){qe(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(`
|
|
91
|
+
`,t);return n>=0?n:0}c=c.nextElementSibling}return e.length}function Nf(e,t,n){if(!e||typeof t!=`string`)return()=>{};let r=Sf(t);wf(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=df(e.type),o=pf(e.type);Ef(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=Mf(t,e,i.target,r,i.clientY);o!==null&&(i.preventDefault(),Ef(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?.type===`table`&&(t.preventDefault(),t.stopPropagation(),Tf(),n.onEdit({...a,tableFocusCell:Of(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(),Ef(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=>{hf&&!hf.contains(e.target)&&Tf()},l=e=>{e.key===`Escape`&&Tf()};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),Tf(),e.querySelectorAll(`[data-inline-snippet-index]`).forEach(e=>{e.removeAttribute(`data-inline-snippet-index`),e.classList.remove(`ld-inline-snippet-target`)})}}var Pf=200*1024*1024,Ff=Math.round(Pf/1024/1024);Math.ceil(Pf*1.4);var If=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>`),Lf=U(`<div id="doc-content" data-testid="doc-content"></div>`),Rf=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>`),zf=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>`),Bf=U(`<!> <!> <!> <!>`,1);function Vf(e,t){qe(t,!0);let n=qi(t,`onopen`,3,()=>{}),r=qi(t,`onanchor`,3,D),i=qi(t,`onconfirmdelete`,3,void 0),a=qi(t,`oncontentwired`,3,void 0),o=qi(t,`rewireSignal`,3,void 0),s=qi(t,`editing`,15,!1),c=qi(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`})}Ji(()=>{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 gd(V(l),t.html,{content:t.content,codeBlockMaxHeight:X.codeBlockMaxHeight,t:Y,onDocLink:(e,t)=>n()(e,t),onAnchor:r(),docId:t.docId,docs:X.allDocs,docsFolder:X.docsFolder,folderPaths:X.allFolderPaths,onKanbanDocsChange:e=>{X.allDocs=e},onKanbanFolderPathsChange:e=>{X.allFolderPaths=e}})||(f=Nf(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 te(){s(!1),c(null)}async function O(){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(){let e=Hu(t.content);e&&(F(m,`inline-edit`),F(h,e,!0),F(p,!0))}function A(){return s()}function re(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 le(e,t,r)})()}}function ie(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 le(e,n,r)})()}function ae(e){e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}function oe(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function se(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()})}let ce=Pf;async function le(e,n,r){if(e.size>ce){c({text:Y(`doc.file_too_large`)+` (${(e.size/1024/1024).toFixed(1)} MB, max ${Ff} MB)`,cls:`text-red-500 dark:text-red-400`});return}c({text:Y(`doc.uploading_file`),cls:`text-gray-400`});try{let i=await oe(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();se(`[📎 ${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 ue(){F(_,!1),b=null}async function de(){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 oe(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();se(``,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 fe(){F(C,null),F(w,``)}function pe(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 me(e){e.key===`Escape`&&V(C)&&fe()}var he={enterEdit:ee,cancelEdit:te,save:O,openSnippets:k,openKanbanColumnsEditor:ne,isEditing:A},ge=Bf();Nr(`keydown`,on,me);var _e=R(ge),ve=e=>{var t=If();yn(t),Ui(t,e=>F(u,e),()=>V(u)),Nr(`paste`,t,re),Nr(`drop`,t,ie),Nr(`dragover`,t,ae),Fi(t,()=>V(d),e=>F(d,e)),W(e,t)},ye=e=>{var t=Lf();Ui(t,e=>F(l,e),()=>V(l)),B(()=>vi(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,pe),W(e,t)};K(_e,e=>{s()?e(ve):e(ye,-1)});var be=z(_e,2);cf(be,{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 xe=z(be,2),Se=e=>{var t=Rf(),n=L(t),r=L(n),i=L(r);j(r);var a=z(r,2),o=L(a),s=L(o),c=z(s),l=L(c,!0);j(c),j(o);var u=z(o,2),d=L(u);ki(d);var f=z(d,2),p=L(f);j(f),j(u),j(a);var m=z(a,2),h=L(m),g=L(h,!0);j(h);var _=z(h,2),b=L(_,!0);j(_),j(m),j(n),j(t),B((e,t,n,r,a)=>{G(i,`🖼️ ${e??``}`),G(s,`${t??``} `),G(l,n),Ai(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,ue),H(`click`,_,de),W(e,t)};K(xe,e=>{V(_)&&e(Se)});var Ce=z(xe,2),we=e=>{var t=zf(),n=L(t),r=z(n,2);j(t),B(()=>{J(n,`src`,V(C)),J(n,`alt`,V(w))}),H(`click`,t,fe),H(`click`,n,e=>e.stopPropagation()),H(`click`,r,fe),W(e,t)};return K(Ce,e=>{V(C)&&e(we)}),W(e,ge),Je(he)}Pr([`click`,`input`]);var Hf=U(`<span> </span> <code> </code>`,1),Uf=U(`<button type="button" data-testid="bp-copy-doc-id"><i aria-hidden="true"></i></button>`),Wf=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),Gf=U(`<span> </span>`),Kf=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>`),qf=U(`<div class="bpadr-read"><!></div> <!>`,1),Jf=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),Yf=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>`),Xf=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>`),Zf=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>`),Qf=U(`<!> <!>`,1);function $f(e,t){qe(t,!0);let n=qi(t,`onchanged`,3,()=>{}),r=`001_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 te(){await fetch(`/api/blueprint/blueprint-folder`,{method:`POST`}),V(g)&&await E(V(g),i(V(g).folder.name))}async function O(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=Qf(),ie=R(re),ae=e=>{var t=Xf(),n=L(t),i=L(n),a=L(i),g=L(a),w=L(g),T=e=>{var t=Hf(),n=R(t),r=L(n,!0);j(n);var i=z(n,2),a=L(i,!0);j(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)}),j(g);var ne=z(g,2),A=e=>{var t=Uf(),n=L(t);j(t),B(e=>{J(t,`title`,e),vi(t,1,`bpadr-copy-btn ${V(C)?`copied`:``}`),vi(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)}),j(a);var re=z(a,2),ie=L(re),ae=e=>{var t=Wf(),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);j(re),j(i);var se=z(i,2),ce=e=>{var t=qf(),n=R(t),r=L(n);{let e=N(()=>V(h)??``);Ui(Vf(r,{get docId(){return V(e)},get content(){return V(d)},get html(){return V(f)},onsave:O,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(_))}j(n);var i=z(n,2),a=e=>{var t=Kf(),n=L(t),r=e=>{var t=Gf(),n=L(t,!0);j(t),B(()=>{vi(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);j(i);var o=z(i,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c,!0);j(c),j(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=Jf(),n=R(t),i=L(n);ki(i);var a=z(i,2);ki(a),Ai(a,r);var s=z(a,2),d=L(s),f=L(d,!0);j(d);var p=z(d,2);ki(p),j(s);var m=z(s,2),g=L(m),_=L(g,!0);j(g);var v=z(g,2);yn(v),Ui(v,e=>F(b,e),()=>V(b)),j(m);var y=z(m,2),S=L(y),C=L(S,!0);j(S);var w=z(S,2),T=L(w,!0);j(w);var E=z(w,2),ee=L(E,!0);j(E),j(y),j(n),cf(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)=>{Ai(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),Fi(p,()=>V(c),e=>F(c,e)),Fi(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=Yf(),n=L(t);si(n,()=>Y(`blueprint.adr.folder_missing`,{name:V(p)}),!0),j(n);var r=z(n,2),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2),l=L(c,!0);j(c),j(a),j(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,te),W(e,t)};K(se,e=>{V(o)===`doc`?e(ce):V(o)===`form`?e(le,1):V(o)===`folder-confirm`&&e(ue,2)}),j(n),j(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=Zf(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a);var c=z(a,2),l=L(c),u=L(l,!0);j(l);var d=z(l,2),f=L(d,!0);j(d),j(c),j(n),j(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),Je(A)}Pr([`click`]);var ep=U(`<span class="breadcrumb-sep">›</span>`),tp=U(`<span class="breadcrumb-item current"> </span>`),np=U(`<button class="breadcrumb-item" type="button"> </button>`),rp=U(`<!> <!>`,1),ip=U(`<nav class="breadcrumb"></nav>`),ap=U(`<div class="app-shell"><!> <section class="workspace-shell"><!> <!></section></div> <!>`,1);function op(e,t){qe(t,!0),Ji(async()=>{try{await Sa((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=ap(),f=R(d),p=L(f);{let e=N(()=>Y(`blueprint.subtitle`));Xo(p,{title:`Blueprint`,get subtitle(){return V(e)},children:(e,t)=>{var r=ip();q(r,21,()=>V(n),Qr,(e,t,r)=>{var i=rp(),a=R(i),o=e=>{W(e,ep())};K(a,e=>{r>0&&e(o)});var c=z(a,2),l=e=>{var n=tp(),r=L(n,!0);j(n),B(()=>G(r,V(t).name)),W(e,n)},u=e=>{var n=np(),r=L(n,!0);j(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)}),j(r),W(e,r)},$$slots:{default:!0}})}var m=z(p,2),h=L(m);Ui(ks(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=>{Ui(Ys(e,{onclose:l,onnavigate:u}),e=>F(a,e,!0),()=>V(a))};K(g,e=>{V(r)!==null&&e(_)}),j(m),j(f),Ui($f(z(f,2),{onchanged:()=>V(i).loadPath(V(n).at(-1)?.path??``,!1)}),e=>F(o,e,!0),()=>V(o)),W(e,d),Je()}Pr([`click`]);var sp=164,cp=64,lp=132,up=78,dp=6,fp=24,pp=96,mp=540,hp=780,gp=1/2,_p=9999,vp=44,yp=255,bp=178,xp=Math.PI*.7,Sp=Math.PI*1.1,Cp=Math.PI*1.45,wp=Math.PI*1.75,Tp=14,Ep=260,Dp=56,Op=32,kp=[`pointerdown`,`mousedown`,`click`,`dblclick`,`touchstart`,`wheel`],Ap=.35,jp=2.2,Mp=.0018,Np=4,Pp=46,Fp=4,Ip=44,Lp=360,Rp=300,zp=44,Bp=48,Vp=7,Hp=875,Up=450,Wp=600*1e3,Gp,Z,Kp,qp,Jp,Yp,Xp,Zp=[],Qp=new Map,$p=[],em=-1,tm,nm,rm,im,am,om,sm,cm,lm,um,dm,fm,pm,mm,hm,gm,_m,vm,ym,bm,xm,Sm=null,Cm=null,wm=null,Q,$,Tm,Em=!1;function Dm(){return Gp=document.getElementById(`workspaceCanvas`),Z=Gp.getContext(`2d`),Kp=document.getElementById(`apiStatus`),qp=document.getElementById(`addButton`),Jp=document.getElementById(`fitButton`),Yp=document.getElementById(`testNodeButton`),Xp=document.getElementById(`loadModelsButton`),tm=document.getElementById(`closePanelButton`),nm=document.getElementById(`deleteNodeButton`),rm=document.getElementById(`renameConfirmOverlay`),im=document.getElementById(`renameConfirmMessage`),am=document.getElementById(`cancelRenameButton`),om=document.getElementById(`confirmRenameButton`),sm=document.getElementById(`deleteConfirmOverlay`),cm=document.getElementById(`deleteConfirmMessage`),lm=document.getElementById(`cancelDeleteButton`),um=document.getElementById(`confirmDeleteButton`),dm=document.getElementById(`agentRunOverlay`),fm=document.getElementById(`agentRunTitle`),pm=document.getElementById(`agentRunHint`),mm=document.getElementById(`agentRunInputField`),hm=document.getElementById(`agentRunInput`),gm=document.getElementById(`agentRunResult`),_m=document.getElementById(`cancelAgentRunButton`),vm=document.getElementById(`executeAgentRunButton`),ym=document.getElementById(`fallbackPanelHost`),bm=document.getElementById(`configSurface`),xm=bm,Sm=null,Cm=null,wm=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`),modelFilter:document.getElementById(`nodeModelFilter`),modelResults:document.getElementById(`nodeModelResults`),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`),agentProvider:document.getElementById(`nodeAgentProvider`),systemPrompt:document.getElementById(`nodeSystemPrompt`),requiresUserInput:document.getElementById(`nodeRequiresUserInput`),userInputDescriptionField:document.getElementById(`agentUserInputDescriptionField`),userInputDescription:document.getElementById(`nodeUserInputDescription`),expectedOutputMarker:document.getElementById(`nodeExpectedOutputMarker`)},$={entities:qm([Km(`root`,`Living AI Documentation`,`system`,null),Km(`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},Em=!!Gp.requestPaint&&typeof Z.drawElementImage==`function`,Em?($.apiMode=`html-in-canvas`,Kp.textContent=`HTML-in-Canvas active`,Kp.classList.add(`is-live`),Gp.onpaint=ng):(ym.appendChild(bm),Kp.textContent=`DOM fallback`,Kp.classList.add(`is-fallback`)),Tm=new ResizeObserver(([e])=>{let t=e.devicePixelContentBoxSize?.[0],n=e.contentRect.width,r=e.contentRect.height;$.dpr=t?t.inlineSize/n:window.devicePixelRatio||1,Gp.width=t?t.inlineSize:Math.floor(n*$.dpr),Gp.height=t?t.blockSize:Math.floor(r*$.dpr),th(),fg(!1,!$.cameraX&&!$.cameraY),tg()}),Tm.observe(Gp,{box:`device-pixel-content-box`}),Om(),km(),qp.addEventListener(`click`,()=>{Qm()}),Jp.addEventListener(`click`,()=>{th(),fg(!0,!0),Pm(),tg()}),Gp.addEventListener(`pointerdown`,e=>{if(e.target!==Gp)return;let t=Fg(e),n=Sg(t),r=[...$.entities].reverse().find(e=>Og(e,n));if(r){r.id!==`root`&&ph(r.id);return}$.isPanning=!0,$.didPan=!1,$.panStartX=t.x,$.panStartY=t.y,$.panStartCameraX=$.cameraX,$.panStartCameraY=$.cameraY,Gp.classList.add(`is-panning`),Gp.setPointerCapture?.(e.pointerId)}),Gp.addEventListener(`pointermove`,e=>{if(!$.isPanning)return;let t=Fg(e),n=t.x-$.panStartX,r=t.y-$.panStartY;Math.hypot(n,r)>Np&&($.didPan=!0),$.cameraX=$.panStartCameraX+n,$.cameraY=$.panStartCameraY+r,tg()}),Gp.addEventListener(`pointerup`,e=>{$.isPanning&&($.isPanning=!1,Gp.classList.remove(`is-panning`),Gp.releasePointerCapture?.(e.pointerId),!$.didPan&&$.selectedId?ph(null):$.didPan&&Pm())}),Gp.addEventListener(`pointercancel`,e=>{$.isPanning=!1,Gp.classList.remove(`is-panning`),Gp.releasePointerCapture?.(e.pointerId)}),Gp.addEventListener(`wheel`,e=>{e.target===Gp&&(e.preventDefault(),xg(Fg(e),Math.exp(-e.deltaY*Mp)),Pm())},{passive:!1}),xm.addEventListener(`submit`,e=>{e.preventDefault(),xh(),$.lastSaveAt=new Date,th(),Im(!0),tg()}),xm.addEventListener(`input`,()=>{xh(),th(),$.panelDirty=!0,tg()}),tm.addEventListener(`click`,()=>{ph(null)}),nm.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let t=$.selectedId,n=t?Zh(t):null;!n||Qh(t)||mh(n)}),lm.addEventListener(`click`,hh),sm.addEventListener(`click`,e=>{e.target===sm&&hh()}),um.addEventListener(`click`,()=>{$.pendingDeleteId&&gh($.pendingDeleteId),hh()}),Yp.addEventListener(`click`,()=>{if(Xh()?.kind===`agent`){Dh();return}Gh()}),Xp.addEventListener(`click`,()=>{Wh()}),Q.copyProviderId.addEventListener(`click`,()=>{qh()}),Q.name.addEventListener(`blur`,()=>{if(Xh()?.kind!==`agent`)return;let e=Q.name.value.trim();if(!e||!Sm||!Cm||e===Sm)return;let t=Ym(e);t!==Cm&&(im.textContent=`Renommer le dossier "${Cm}" en "${t}" ?`,rm.hidden=!1,am.focus())}),am.addEventListener(`click`,()=>{rm.hidden=!0;let e=Xh();e&&Sm&&(e.label=Sm,Q.name.value=Sm,th(),tg())}),om.addEventListener(`click`,()=>{rm.hidden=!0;let e=Xh();if(!e||!Cm)return;e.config.workspaceFolder=Cm,Q.workspaceFolder.value=Cm;let t=Q.name.value.trim();t&&(Sm=t),Cm=Ym(t),Pm()}),Q.modelFilter.addEventListener(`input`,e=>{e.stopPropagation(),em=-1,Vh()}),Q.modelFilter.addEventListener(`focus`,()=>{Vh()}),Q.modelFilter.addEventListener(`blur`,()=>{Hh()}),Q.modelFilter.addEventListener(`keydown`,e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if($p.length===0)return;e.preventDefault();let t=$p.length;em=e.key===`ArrowDown`?(em+1)%t:em<=0?t-1:em-1,Vh()}else if(e.key===`Enter`){e.preventDefault();let t=$p[em]??($p.length===1?$p[0]:void 0);t&&Uh(t)}else e.key===`Escape`&&Q.modelFilter.value&&(e.preventDefault(),e.stopPropagation(),Q.modelFilter.value=``,Hh())}),Q.modelResults.addEventListener(`mousedown`,e=>{e.preventDefault()}),Q.modelResults.addEventListener(`click`,e=>{let t=e.target.closest(`[data-model]`);t?.dataset.model&&Uh(t.dataset.model)}),Q.model.addEventListener(`change`,()=>{Yp.disabled=!Q.model.value;let e=Xh();e&&(e.config.model=Q.model.value)}),Q.agentProvider.addEventListener(`change`,()=>{Ch(Q.agentProvider.value)}),_m.addEventListener(`click`,()=>{Oh()}),vm.addEventListener(`click`,()=>{kh()}),dm.addEventListener(`click`,e=>{e.target===dm&&Oh()}),jm(),()=>{Fm(),Tm.disconnect(),$?.saveTimerId&&clearTimeout($.saveTimerId)}}function Om(){for(let e of kp)bm.addEventListener(e,Am),ym.addEventListener(e,Am)}function km(){for(let e of kp)sm.addEventListener(e,Am),rm.addEventListener(e,Am),dm.addEventListener(e,Am)}function Am(e){e.stopPropagation()}async function jm(){let e=await So();e?.entities?.length&&($.entities=Mm(e.entities),$.cameraX=Gm(e.camera?.x,$.cameraX),$.cameraY=Gm(e.camera?.y,$.cameraY),$.zoom=Cg(Gm(e.camera?.zoom,$.zoom),Ap,jp),$.lastSaveAt=e.updatedAt?new Date(e.updatedAt):null),$.isHydrated=!0,th(),e?.entities?.length||fg(!1,!0),bh(),tg()}function Mm(e){let t=e.map(Nm).filter(e=>!!e),n=t.some(e=>e.id===`root`),r=t.some(e=>e.id===`mcp`),i=[...n?[]:[Km(`root`,`Living AI Documentation`,`system`,null)],...t,...r?[]:[Km(`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:{...Km(e.id,e.label,t,n).config,...e.config}}})}function Nm(e){if(!Bm(e))return null;let t=Vm(e.id),n=Vm(e.label),r=Hm(e.kind);if(!t||!n||!r)return null;let i=e.parentId===null?null:Vm(e.parentId),a=Bm(e.config)?e.config:{};return{id:t,label:n,kind:r,parentId:i,x:Gm(e.x,0),y:Gm(e.y,0),angle:Gm(e.angle,0),config:{endpoint:Vm(a.endpoint)||Jm(t,r),token:Vm(a.token),model:Vm(a.model),providerType:Wm(a.providerType),toolMode:Um(a.toolMode),timeout:Gm(a.timeout,180),description:Vm(a.description)||Zm(r),workspaceFolder:Vm(a.workspaceFolder)||(r===`agent`?Ym(n):``),systemPrompt:Vm(a.systemPrompt),requiresUserInput:a.requiresUserInput===!0,userInputDescription:Vm(a.userInputDescription),expectedOutputMarker:Vm(a.expectedOutputMarker)}}}function Pm(){$.isHydrated&&($.saveTimerId&&clearTimeout($.saveTimerId),$.saveTimerId=window.setTimeout(()=>{$.saveTimerId=null,Im(!1)},Up))}function Fm(){$.panelDirty&&Im(!1)}async function Im(e=!1){if(!$.isHydrated)return;$.panelDirty=!1,$.saveTimerId&&(clearTimeout($.saveTimerId),$.saveTimerId=null);let t=$.selectedId&&document.activeElement===Q.token&&Ih(Q.token.value)?{entityId:$.selectedId,value:Q.token.value,selectionStart:Q.token.selectionStart,selectionEnd:Q.token.selectionEnd}:null,n=await Co(zm());if(n){if($.entities=Mm(n.entities),t&&$.selectedId===t.entityId){let e=Xh();e?.kind===`llm`&&(e.config.token=t.value)}$.lastSaveAt=new Date(n.updatedAt),Xh()&&!xm.contains(document.activeElement)&&bh(),t&&$.selectedId===t.entityId&&(Q.token.value=t.value,Q.token.setSelectionRange(t.selectionStart,t.selectionEnd)),e&&Rm(`Workspace saved`)}else e&&Rm(`Save failed`)}function Lm(e,t){return yo(e,t)}function Rm(e,t=`success`,n,r){return bo(e,t,n,r)}function zm(){return{version:1,updatedAt:new Date().toISOString(),entities:$.entities.map(e=>{let t={...e.config,token:Lh(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 Bm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Vm(e){return typeof e==`string`?e:``}function Hm(e){return e===`system`||e===`llm`||e===`agent`||e===`mcp`?e:null}function Um(e){return e===`chat`?`chat`:`tools`}function Wm(e){return e===`image`?`image`:`chat`}function Gm(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function Km(e,t,n,r){return{id:e,label:t,kind:n,parentId:r,x:0,y:0,angle:0,config:{endpoint:Jm(e,n),token:``,model:``,providerType:`chat`,toolMode:`tools`,timeout:180,description:Zm(n),workspaceFolder:n===`agent`?Ym(t):``,systemPrompt:``,requiresUserInput:!1,userInputDescription:``,expectedOutputMarker:``}}}function qm(e){return e.map(e=>({...e,config:{...e.config}}))}function Jm(e,t){return t===`llm`?`http://localhost:11434`:t===`mcp`?`http://localhost:4321/mcp`:``}function Ym(e){return`AI/WORKSPACE/${Xm(e)}`}function Xm(e){return e.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`llm_provider`}function Zm(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 Qm(){let e=Xh(),t=e?.kind===`llm`?e:Zh(e?.parentId);if(t?.kind===`llm`&&t.config.providerType!==`image`){eh(t.id);return}$m()}function $m(){let e=!!$.selectedId,t=$h(`root`).filter(e=>e.kind===`llm`).length+1,n=Km(`provider-${Date.now().toString(36)}`,`LLM Provider ${t}`,`llm`,`root`);$.entities=[...$.entities,n],$.selectedId=n.id,th(),pg(e,!0,!0),bh(),Pm(),tg()}function eh(e){let t=!!$.selectedId,n=$h(e).filter(e=>e.kind===`agent`).length+1,r=Km(`agent-${Date.now().toString(36)}`,`Agent ${n}`,`agent`,e);$.entities=[...$.entities,r],$.selectedId=r.id,th(),pg(t,!0,!0),bh(),Pm(),tg()}function th(){let e=Zh(`root`);e.x=0,e.y=0,e.angle=0,nh(e)}function nh(e){let t=$h(e.id),n=ch(t,lp,yp,{spread:Math.PI*2,includeSubtree:!1}),r=new Map(t.map(e=>[e.id,oh(e,n)]));for(let n=0;n<=Vp;n+=1)if(rh(e,t,r),ih(),!ah(t,r))return;rh(e,t,r),ih()}function rh(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)||yp;t.angle=a,t.x=e.x+Math.cos(a)*o,t.y=e.y+Math.sin(a)*o})}function ih(){for(let e of $.entities.filter(e=>e.kind===`llm`))sh(e)}function ah(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];Pg(jg(a),jg(o),zp)&&(t.set(a.id,Math.min(Hp,t.get(a.id)+Bp)),t.set(o.id,Math.min(Hp,t.get(o.id)+Bp)),n=!0)}return n}function oh(e,t){if(e.kind!==`llm`)return t;let n=$h(e.id).length;if(n<=Fp)return t;let r=(n-Fp)*Ip,i=Math.max(0,dh(e)-Rp)*.65;return t+Math.min(Lp,Math.max(r,i))}function sh(e){let t=$h(e.id);if(!t.length)return;let n=Math.atan2(e.y,e.x),r=lh(t.length),i=ch(t,up,bp,{spread:r,includeSubtree:!1});t.forEach((a,o)=>{let s=uh(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 ch(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?dh(e):fh(e))),s=t+o+Pp;if(e.length===1)return Math.max(n,s);let c=o*2+Pp,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 lh(e){return e<=1?0:e<=2?xp:e<=4?Sp:e<=7?Cp:wp}function uh(e,t,n,r){return r<=1||t===0?e:e-t/2+n/(r-1)*t}function dh(e){if(e.kind!==`llm`)return fh(e);let t=$h(e.id);return t.length?ch(t,up,bp,{spread:lh(t.length),includeSubtree:!1})+Math.max(...t.map(e=>fh(e))):up}function fh(e){if(e.kind===`system`)return lp;if(e.kind===`llm`)return up;let{width:t,height:n}=Ag(e);return Math.hypot(t/2,n/2)}function ph(e){e!==$.selectedId&&Fm();let t=!!$.selectedId;$.selectedId=e;let n=e?Zh(e):null;Sm=n?.kind===`agent`?n.label:null,Cm=n?.kind===`agent`?n.config.workspaceFolder||Ym(n.label):null,th(),pg(t,!!e,!0),bh(),tg()}function mh(e){let t=eg(e.id),n=$h(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,cm.textContent=`You are about to delete "${e.label}".${r} This action cannot be undone.`,sm.hidden=!1,um.focus()}function hh(){$.pendingDeleteId=null,sm.hidden=!0}function gh(e){let t=Zh(e);if(!t||Qh(e))return;let n=t.parentId||`root`,r=!!$.selectedId,i=new Set([e,...eg(e)]);$.entities=$.entities.filter(e=>!i.has(e.id)),$.selectedId=Zh(n)?n:null,th(),pg(r,!!$.selectedId,!0),bh(),Pm(),tg()}var _h=0;async function vh(e){let t=++_h,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 To({endpoint:n});if(t===_h){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,yh(Q.mcpToolsList,i.tools??[],`No tools exposed.`),yh(Q.mcpPromptsList,i.prompts??[],`No prompts exposed.`)}}function yh(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 bh(){let e=Xh(),t=!!e;if(bm.hidden=!t,ym.hidden=!t||Em,!e){qp.title=`Add LLM provider`,Yp.textContent=`Test`,Yp.hidden=!0,Yp.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,Eh(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=Yh(e),Q.kind.disabled=!0,Q.llmFields.hidden=e.kind===`mcp`||e.kind===`agent`,Th(e),Q.mcpInventory.hidden=e.kind!==`mcp`,e.kind===`mcp`?vh(e):_h+=1,Q.agentSection.hidden=e.kind!==`agent`,e.kind===`agent`&&Sh(e),Q.systemPrompt.value=e.config.systemPrompt,Q.requiresUserInput.checked=e.config.requiresUserInput,wh(),Q.userInputDescription.value=e.config.userInputDescription,Q.expectedOutputMarker.value=e.config.expectedOutputMarker,nm.hidden=Qh(e.id),Yp.textContent=`Test`,Yp.hidden=e.kind!==`llm`&&e.kind!==`agent`,Yp.disabled=e.kind===`llm`?!e.config.model:e.kind!==`agent`;let n=e.kind===`llm`?e:Zh(e.parentId);qp.title=n?.kind===`llm`&&n.config.providerType!==`image`?`Add agent`:`Add LLM provider`}function xh(){let e=Xh();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,wh(),Th(e),Q.typeBadge.textContent=Yh(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 Sh(e){let t=Q.agentProvider;t.innerHTML=``;let n=$.entities.filter(e=>e.kind===`llm`&&e.config.providerType!==`image`);for(let e of n){let n=document.createElement(`option`);n.value=e.id,n.textContent=e.label,t.appendChild(n)}t.value=e.parentId??``}function Ch(e){let t=Xh();if(t?.kind!==`agent`)return;let n=Zh(e);n?.kind===`llm`&&t.parentId!==e&&(t.parentId=e,t.config.model=n.config.model,t.config.timeout=n.config.timeout,th(),Pm(),tg())}function wh(){let e=Xh()?.kind===`agent`&&Q.requiresUserInput.checked;Q.userInputDescriptionField.hidden=!e,Q.userInputDescription.required=e}function Th(e){let t=e.kind===`llm`,n=e.config.providerType===`image`;Q.providerIdField.hidden=!t,Q.toolModeField.hidden=!t||n,Xp.title=Y(n?`workspace.model.load_image`:`workspace.model.load_chat`),Yp.title=n?`Test image provider configuration`:`Test chat provider configuration`}function Eh(e){let t=Xh(),n=t?.kind===`llm`?Qp.get(zh(t)):void 0;if(n){let t=e&&!n.includes(e)?[e,...n]:n;t!==Zp&&Bh(t),Q.model.value=e||t[0];return}Zp.length>0&&(Bh([]),Q.model.innerHTML=``);let r=Array.from(Q.model.options).map(e=>e.value);if(e&&!r.includes(e)){Q.model.innerHTML=``;let t=document.createElement(`option`);t.value=e,t.textContent=e,Q.model.appendChild(t)}Q.model.value=e||(r[0]??``)}function Dh(){let e=Xh();if(e?.kind!==`agent`)return;xh();let t=Zh(e.parentId??``);if(t?.kind!==`llm`){Rm(`No parent LLM found for this agent.`,`error`);return}if(!t.config.model){Rm(`Parent LLM has no model selected.`,`error`);return}if(!e.config.systemPrompt.trim()){Rm(`Write a system prompt first.`,`error`);return}if(e.config.requiresUserInput&&!e.config.userInputDescription.trim()){Rm(`Describe the required user input first.`,`error`);return}wm=e.id,fm.textContent=`Test ${e.label}`,pm.textContent=e.config.requiresUserInput?e.config.userInputDescription:`Run this agent with its configured system prompt.`,mm.hidden=!e.config.requiresUserInput,hm.required=e.config.requiresUserInput,hm.value=``,gm.hidden=!0,gm.textContent=``,vm.disabled=!1,vm.textContent=`Run`,dm.hidden=!1,e.config.requiresUserInput?window.setTimeout(()=>hm.focus(),0):window.setTimeout(()=>vm.focus(),0)}function Oh(){dm.hidden=!0,wm=null}async function kh(){if(hm.required&&!hm.value.trim()){hm.reportValidity();return}let e=wm?Zh(wm):null;if(e?.kind!==`agent`){Ph(`error`,`The selected agent is no longer available.`);return}let t=Zh(e.parentId??``);if(t?.kind!==`llm`){Ph(`error`,`No parent LLM found for this agent.`);return}vm.disabled=!0,vm.textContent=`Running…`;let n=Lm(`Running agent…`);jh();let r=$.entities.find(e=>e.kind===`mcp`),i=!1,a=await Eo({providerId:t.id,endpoint:t.config.endpoint,model:t.config.model,systemPrompt:e.config.systemPrompt,userInput:hm.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`&&Lm(Ah(e),n),Mh(e)});vm.disabled=!1,vm.textContent=`Run`,a.ok&&a.content?(Nh(a.content),Rm(`Agent responded. Result saved in AI/WORKSPACE.`,`success`,Wp,n)):(i||Mh({type:`error`,message:a.error??`Agent failed.`}),gm.dataset.state=`error`,Rm(a.error??`Agent failed.`,`error`,Wp,n))}function Ah(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 jh(){gm.hidden=!1,gm.dataset.state=`loading`,gm.textContent=``,Mh({type:`status`,message:`Preparing agent request`})}function Mh(e){gm.hidden=!1,e.type===`error`&&(gm.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),gm.appendChild(t),gm.scrollTop=gm.scrollHeight}function Nh(e){gm.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),gm.appendChild(t),gm.scrollTop=gm.scrollHeight}function Ph(e,t){gm.hidden=!1,gm.dataset.state=e,gm.textContent=t}var Fh=/^(?:env:[A-Za-z_][A-Za-z0-9_]*|\$\{[A-Za-z_][A-Za-z0-9_]*\})$/;function Ih(e){let t=e.trim();return t!==``&&!Fh.test(t)}function Lh(e){let t=e.trim();return Ih(t)?``:t}var Rh=`API token must reference an environment variable, e.g. env:LLM_API_KEY`;function zh(e){return`${e.config.providerType}|${e.config.endpoint}`}function Bh(e){if(Zp=e,e.length>0){Q.model.innerHTML=``;for(let t of e){let e=document.createElement(`option`);e.value=t,e.textContent=t,Q.model.appendChild(e)}}Q.modelFilter.value=``,Q.modelFilter.hidden=e.length===0,Hh()}function Vh(){let e=Q.modelFilter.value.toLowerCase().split(/\s+/).filter(Boolean);if(e.length===0||Zp.length===0){Hh();return}if($p=Zp.filter(t=>{let n=t.toLowerCase();return e.every(e=>n.includes(e))}),em>=$p.length&&(em=-1),Q.modelResults.innerHTML=``,$p.forEach((e,t)=>{let n=document.createElement(`li`);n.id=`nodeModelResult-${t}`,n.role=`option`,n.dataset.model=e,n.textContent=e,n.classList.toggle(`active`,t===em),n.setAttribute(`aria-selected`,String(e===Q.model.value)),Q.modelResults.appendChild(n)}),$p.length===0){let e=document.createElement(`li`);e.className=`empty`,e.textContent=Y(`workspace.model.no_match`),Q.modelResults.appendChild(e)}let t=Y(`workspace.model.filter_count`,{shown:String($p.length),total:String(Zp.length)});Q.modelResults.setAttribute(`aria-label`,t),Q.modelFilter.title=t,Q.modelResults.hidden=!1,Q.modelFilter.setAttribute(`aria-expanded`,`true`),em>=0?(Q.modelFilter.setAttribute(`aria-activedescendant`,`nodeModelResult-${em}`),Q.modelResults.children[em]?.scrollIntoView({block:`nearest`})):Q.modelFilter.removeAttribute(`aria-activedescendant`)}function Hh(){$p=[],em=-1,Q.modelResults.hidden=!0,Q.modelResults.innerHTML=``,Q.modelFilter.setAttribute(`aria-expanded`,`false`),Q.modelFilter.removeAttribute(`aria-activedescendant`)}function Uh(e){Q.model.value=e,Q.model.dispatchEvent(new Event(`input`,{bubbles:!0})),Q.model.dispatchEvent(new Event(`change`,{bubbles:!0})),Q.modelFilter.value=``,Hh()}async function Wh(){let e=Xh();if(e?.kind!==`llm`)return;xh();let t=e.config.endpoint;if(!t){Rm(Y(`workspace.model.endpoint_required`));return}if(Ih(e.config.token)){Rm(Rh);return}Xp.classList.add(`loading`),Xp.disabled=!0,Q.model.disabled=!0;let n=await wo({endpoint:t,token:e.config.token,providerType:e.config.providerType});if(Xp.classList.remove(`loading`),Xp.disabled=!1,Q.model.disabled=!1,!n.ok||!n.models?.length){Rm(n.error??Y(`workspace.model.none_found`));return}let r=Q.model.value;Qp.set(zh(e),n.models),Bh(n.models),Q.model.value=n.models.includes(r)?r:n.models[0],e.config.model=Q.model.value,Yp.disabled=!Q.model.value,Rm(n.models.length===1?Y(`workspace.model.loaded_one`):Y(`workspace.model.loaded_many`,{count:String(n.models.length)})),tg()}async function Gh(){let e=Xh();if(e?.kind!==`llm`)return;if(xh(),Ih(e.config.token)){Rm(Rh);return}Yp.disabled=!0,Lm(`Testing ${e.config.model}…`),tg();let t=e.config.providerType===`image`?await Kh(e):await Oo({endpoint:e.config.endpoint,token:e.config.token,model:e.config.model,timeout:e.config.timeout});Yp.disabled=!1,t.ok?Rm(t.detail??`Connection OK`,`success`):Rm(t.error||`Connection failed (${t.status||`no status`})`,`error`),tg()}async function Kh(e){let t=await wo({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 qh(){let e=Xh();if(e?.kind===`llm`)try{await navigator.clipboard.writeText(e.id),Rm(`Provider ID copied`,`success`)}catch{Q.providerId.select(),Rm(`Provider ID selected`,`success`)}}function Jh(e){return{system:`System`,llm:`LLM provider`,agent:`Agent`,mcp:`MCP`}[e]||`Node`}function Yh(e){return e.kind===`llm`&&e.config.providerType===`image`?`Image provider`:Jh(e.kind)}function Xh(){return $.selectedId?Zh($.selectedId):null}function Zh(e){return $.entities.find(t=>t.id===e)}function Qh(e){return e===`root`||e===`mcp`}function $h(e){return $.entities.filter(t=>t.parentId===e)}function eg(e){let t=[];for(let n of $h(e))t.push(n.id,...eg(n.id));return t}function tg(){Em?Gp.requestPaint():requestAnimationFrame(ng)}function ng(){let e=Gp.width/$.dpr,t=Gp.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),rg(e,t),ig(),Z.restore(),Em&&dg(e,t)}function rg(e,t){Z.save(),Z.lineWidth=1/$.zoom;let n=Sg({x:0,y:0}),r=Sg({x:e,y:t}),i=Math.floor(n.x/fp)*fp,a=Math.ceil(r.x/fp)*fp,o=Math.floor(n.y/fp)*fp,s=Math.ceil(r.y/fp)*fp;for(let e=i;e<=a;e+=fp)Z.strokeStyle=e%pp===0?`#d7dce5`:`#edf0f4`,zg(e,o,e,s);for(let e=o;e<=s;e+=fp)Z.strokeStyle=e%pp===0?`#d7dce5`:`#edf0f4`,zg(i,e,a,e);Z.restore()}function ig(){ag();for(let e of $.entities)og(e)}function ag(){Z.save(),Z.lineWidth=2/$.zoom;for(let e of $.entities){let t=Zh(e.parentId);if(!t)continue;let n=Math.atan2(e.y-t.y,e.x-t.x),r=wg(t,n),i=wg(e,n+Math.PI);Z.strokeStyle=lg(e).connection,Z.beginPath(),Z.moveTo(r.x,r.y),Z.lineTo(i.x,i.y),Z.stroke()}Z.restore()}function og(e){if(e.kind===`system`||e.kind===`llm`){sg(e);return}cg(e)}function sg(e){let t=e.id===$.selectedId,n=lg(e),r=e.kind===`system`?lp:up,i=$h(e.id),a=Math.max(dp,i.length),o=Ig(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`,Rg(e.label,e.x,e.y-8,r*1.32,e.kind===`system`?26:20),ug(e,t,r),Z.restore()}function cg(e){let t=e.id===$.selectedId,n=lg(e),r=e.kind===`mcp`?116:sp,i=e.kind===`mcp`?58:cp;Z.save(),Lg(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`,Rg(e.label,e.x,e.y,r*.78,18),ug(e,t,Math.max(r,i)/2),Z.restore()}function lg(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=Zh(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 ug(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 dg(e,t){if(!Xh())return;let n=kg(e),r=Math.min(_p,t-118),i=e-n-24,a=Math.max(24,(t-r)/2);try{let e=Z.drawElementImage(bm,i,a,n,r);bm.style.transform=e.toString()}catch{Kp.textContent=`Waiting for HTML snapshot`}}function fg(e,t){let n=Gp.clientWidth,r=Gp.clientHeight,i=Xh()?kg(n)+vp:0,a=Math.max(360,n-i),o=vg(),s=yg(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){bg(),$.cameraX=d,$.cameraY=f,$.zoom=c,$.panelShiftX=i;return}$.panelShiftX=i,_g(d,f,c)}function pg(e,t,n){if(t){if(e){let e=mg();$.panelShiftX+=Math.max(0,-e),gg(e,n)}else{let e=Xh();if(e){let t=kg(Gp.clientWidth)+vp,n=(Gp.clientWidth-t)/2-e.x*$.zoom,r=n-$.cameraX;$.panelShiftX=-r,_g(n,$.cameraY,$.zoom)}}return}if(!e)return;let r=$.panelShiftX;$.panelShiftX=0,gg(r,n)}function mg(){let e=Xh();if(!e)return 0;let t=Gp.clientWidth-kg(Gp.clientWidth)-24-Op,n=hg(e);return n.right<=t?0:t-n.right}function hg(e){let t=Mg(e);return{left:t.left*$.zoom+$.cameraX,top:t.top*$.zoom+$.cameraY,right:t.right*$.zoom+$.cameraX,bottom:t.bottom*$.zoom+$.cameraY}}function gg(e,t){if(bg(),!e)return;let n=$.cameraX+e;if(!t){$.cameraX=n;return}_g(n,$.cameraY,$.zoom)}function _g(e,t,n){bg();let r=$.cameraX,i=$.cameraY,a=$.zoom,o=performance.now();function s(c){let l=Math.min(1,(c-o)/Ep),u=1-(1-l)**3;$.cameraX=r+(e-r)*u,$.cameraY=i+(t-i)*u,$.zoom=a+(n-a)*u,th(),tg(),l<1?$.viewAnimationId=requestAnimationFrame(s):$.viewAnimationId=null}$.viewAnimationId=requestAnimationFrame(s)}function vg(){return $.entities.reduce((e,t)=>{let n=fh(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 yg(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-Dp*2),o=Math.max(1,n-Dp*2);return Cg(Math.min(1,a/r,o/i),Ap,1)}function bg(){$.viewAnimationId&&(cancelAnimationFrame($.viewAnimationId),$.viewAnimationId=null)}function xg(e,t){bg();let n=Sg(e);$.zoom=Cg($.zoom*t,Ap,jp),$.cameraX=e.x-n.x*$.zoom,$.cameraY=e.y-n.y*$.zoom,tg()}function Sg(e){return{x:(e.x-$.cameraX)/$.zoom,y:(e.y-$.cameraY)/$.zoom}}function Cg(e,t,n){return Math.min(n,Math.max(t,e))}function wg(e,t){if(e.kind!==`system`&&e.kind!==`llm`)return Dg(e,t);let n=e.kind===`system`?lp:up,r=$h(e.id);return Tg(e,n,Math.max(dp,r.length),t)||{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function Tg(e,t,n,r){let i={x:Math.cos(r),y:Math.sin(r)},a=Ig(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=Eg(i,s);if(Math.abs(l)<1e-4)continue;let u=Eg(c,s)/l,d=Eg(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 Eg(e,t){return e.x*t.y-e.y*t.x}function Dg(e,t){let n=Ag(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 Og(e,t){if(e.kind===`system`||e.kind===`llm`){let n=e.kind===`system`?lp:up;return Math.hypot(t.x-e.x,t.y-e.y)<=n+Tp}let{width:n,height:r}=Ag(e);return Math.abs(t.x-e.x)<=n/2+Tp&&Math.abs(t.y-e.y)<=r/2+Tp}function kg(e){return Math.min(hp,Math.max(mp,Math.floor(e*gp)))}function Ag(e){return e.kind===`mcp`?{width:116,height:58}:{width:sp,height:cp}}function jg(e){return[e,...eg(e.id).map(Zh)].filter(Boolean).map(Mg).reduce(Ng)}function Mg(e){if(e.kind===`system`||e.kind===`llm`){let t=e.kind===`system`?lp:up;return{left:e.x-t,top:e.y-t,right:e.x+t,bottom:e.y+t}}let{width:t,height:n}=Ag(e);return{left:e.x-t/2,top:e.y-n/2,right:e.x+t/2,bottom:e.y+n/2}}function Ng(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 Pg(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 Fg(e){let t=Gp.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function Ig(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 Lg(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 Rg(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 zg(e,t,n,r){Z.beginPath(),Z.moveTo(e,t),Z.lineTo(n,r),Z.stroke()}var Bg=U(`<div class="status-row"><span id="apiStatus"></span></div>`),Vg=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> </span> <input id="nodeModelFilter" class="model-filter" type="search" role="combobox" aria-autocomplete="list" aria-controls="nodeModelResults" aria-expanded="false" autocomplete="off" spellcheck="false" hidden=""/> <ul id="nodeModelResults" class="model-results" role="listbox" hidden=""></ul> <div class="model-select-wrap"><select id="nodeModel" name="nodeModel"><option disabled="" selected=""> </option></select> <button id="loadModelsButton" class="icon-button" type="button">↻</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="agentProviderField" class="field wide"><span>LLM provider</span> <select id="nodeAgentProvider" name="nodeAgentProvider"></select> <small class="field-note">Move this agent to another LLM provider. It inherits the target provider\'s model and timeout.</small></label> <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 Hg(e,t){qe(t,!0),Ji(async()=>{try{await Sa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}return Dm()});var n=Vg(),r=L(n);Xo(r,{title:`Living AI Documentation`,subtitle:`Graph-native configuration workspace`,children:(e,t)=>{var n=Bg(),r=L(n);vi(r,1,`status-pill `),r.textContent=`Detecting canvas API`,j(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`,j(l),j(c);var m=z(c,2),h=z(L(m),6),g=L(h),_=L(g,!0);j(g);var v=z(g,2),y=z(v,4),b=L(y),x=L(b),S=L(x,!0);j(x),x.value=x.__value=``,j(b);var C=z(b,2);j(y),j(h),Ie(6),j(m),Ie(2),j(s),Ie(6),j(o),j(a),Ie(2),j(i),Ie(6),j(n),B((e,t,n,r)=>{G(_,e),J(v,`placeholder`,t),G(S,n),J(C,`title`,r)},[()=>Y(`workspace.model.label`),()=>Y(`workspace.model.filter_placeholder`),()=>Y(`workspace.model.placeholder`),()=>Y(`workspace.model.load`)]),W(e,n),Je()}var Ug=U(`<p class="files-msg svelte-4q2lov"> </p>`),Wg=U(`<p class="files-msg files-msg--error svelte-4q2lov"> </p>`),Gg=U(`<p class="files-msg files-msg--empty svelte-4q2lov"> </p>`),Kg=U(`<option> </option>`),qg=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>`),Jg=U(`<span class="files-folder svelte-4q2lov"> </span> ·`,1),Yg=U(`<p class="files-row-error svelte-4q2lov"> </p>`),Xg=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>`),Zg=U(`<ul class="files-list svelte-4q2lov"></ul>`),Qg=U(`<!> <!>`,1),$g=U(`<!> <div class="app-shell"><!> <div class="files-page svelte-4q2lov"><!></div></div>`,1);function e_(e,t){qe(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=Pf,f=N(()=>V(a)?V(r).filter(e=>e.folder===V(a)||e.folder.startsWith(V(a)+`/`)):V(r));function p(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 m(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 h(){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 g(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}function _(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>d){F(c,{...V(c),[e.filename]:Y(`files.error_replace`)+`${(r.size/1024/1024).toFixed(1)} MB (max ${Ff} MB)`},!0);return}F(l,{...V(l),[e.filename]:!0},!0),F(c,{...V(c),[e.filename]:``},!0);try{let t=await g(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 h()}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 v(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 h()}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)}}}Ji(async()=>{try{await Sa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}await h()});var y=$g(),b=R(y);Ui(Xd(b,{}),e=>F(n,e,!0),()=>V(n));var x=z(b,2),S=L(x);{let e=N(()=>Y(`files.title`));Xo(S,{get title(){return V(e)},subtitle:``})}var C=z(S,2),w=L(C),T=e=>{var t=Ug(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},E=e=>{var t=Wg(),n=L(t,!0);j(t),B(()=>G(n,V(s))),W(e,t)},D=e=>{var t=Gg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`files.empty`)]),W(e,t)},ee=e=>{var t=Qg(),n=R(t),r=e=>{var t=qg(),n=L(t),r=L(n,!0);j(n);var o=z(n,2),s=L(o),c=L(s,!0);j(s),s.value=s.__value=``,q(z(s),16,()=>V(i),e=>e,(e,t)=>{var n=Kg(),r=L(n,!0);j(n);var i={};B(()=>{G(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),W(e,n)}),j(o);var l;Si(o),j(t),B((e,t)=>{G(r,e),G(c,t),l!==(l=V(a))&&(o.value=(o.__value=V(a))??``,xi(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=Gg(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`files.empty_filter`)]),W(e,t)},d=e=>{var t=Zg();q(t,21,()=>V(f),Qr,(e,t)=>{var n=Xg(),r=z(L(n),2),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o),d=e=>{var n=Jg(),r=R(n),i=L(r,!0);j(r),Ie(),B(()=>G(i,V(t).folder)),W(e,n)};K(s,e=>{V(t).folder&&e(d)});var f=z(s),h=e=>{var n=Ur();B(e=>G(n,`${e??``} ·`),[()=>m(V(t).uploadedAt)]),W(e,n)};K(f,e=>{V(t).uploadedAt&&e(h)});var g=z(f,1,!0);j(o);var y=z(o,2),b=e=>{var n=Yg(),r=L(n,!0);j(n),B(()=>G(r,V(c)[V(t).filename])),W(e,n)};K(y,e=>{V(c)[V(t).filename]&&e(b)}),j(r);var x=z(r,2),S=L(x),C=L(S,!0);j(S);var w=z(S,2),T=L(w,!0);j(w),j(x),j(n),B((e,n,r)=>{J(i,`href`,V(t).url),G(a,V(t).displayName||V(t).filename),G(g,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)},[()=>p(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,()=>_(V(t))),H(`click`,w,()=>v(V(t))),W(e,n)}),j(t),W(e,t)};K(o,e=>{V(f).length===0?e(s):e(d,-1)}),W(e,t)};K(w,e=>{V(o)?e(T):V(s)?e(E,1):V(r).length===0?e(D,2):e(ee,-1)}),j(C),j(x),W(e,y),Je()}Pr([`change`,`click`]);var t_=U(`<p class="browser-msg"> </p>`),n_=U(`<p class="browser-msg browser-msg--error"> </p>`),r_=U(`<button class="browser-row browser-row--dir"><span class="browser-row-name"> </span></button>`),i_=U(`<span class="badge-added"> </span>`),a_=U(`<button class="link-btn"> </button>`),o_=U(`<div class="browser-row browser-row--file"><span class="browser-row-name"> </span> <!></div>`),s_=U(`<!> <!>`,1),c_=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>`),l_=U(`<p class="empty-msg svelte-e5jhdq"> </p>`),u_=U(`<button class="remove-btn"> </button>`),d_=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>`),f_=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 p_(e,t){qe(t,!0);let n=qi(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=f_(),y=L(v),b=L(y),x=L(b,!0);j(b);var S=z(b,2),C=L(S),w=L(C);j(C);var T=z(C,2),E=L(T,!0);j(T),j(S),j(y);var D=z(y,2),ee=e=>{var t=c_(),n=L(t),r=L(n),d=L(r,!0);j(r);var f=z(r,2),p=L(f,!0);j(f),j(n);var m=z(n,2),g=L(m),v=e=>{var t=t_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},y=e=>{var t=n_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.cannot_read_dir`)]),W(e,t)},b=e=>{var t=t_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.empty_dir`)]),W(e,t)},x=e=>{var t=s_(),n=R(t);q(n,17,()=>V(o),Qr,(e,t)=>{var n=r_(),r=L(n),i=L(r);j(r),j(n),B(()=>G(i,`📁 ${V(t).name??``}`)),H(`click`,n,()=>h(V(t).path)),W(e,n)}),q(z(n,2),17,()=>V(s),Qr,(e,t)=>{var n=o_(),r=L(n),i=L(r);j(r);var a=z(r,2),o=e=>{var t=i_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.added`)]),W(e,t)},s=N(()=>V(u).has(V(t).name)),c=e=>{var n=a_(),r=L(n,!0);j(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)}),j(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)}),j(m),j(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 te=z(D,2),O=L(te),k=e=>{var t=l_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.no_instructions`)]),W(e,t)},ne=e=>{var r=Wr();q(R(r),17,n,Qr,(e,n)=>{var r=d_(),i=L(r),a=L(i),o=L(a,!0);j(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)}),j(s),j(i);var h=z(i,2),g=L(h),_=L(g,!0);j(g);var v=z(g,2),y=e=>{var r=u_(),i=L(r,!0);j(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)}),j(h),j(r),B((e,t,r,i)=>{J(a,`href`,e),G(o,V(n).path),G(c,`${t??``} · ${r??``} `),vi(g,1,fi(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(O,e=>{n().length?e(ne,-1):e(k)}),j(te),j(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),Je()}Pr([`click`]);var m_=U(`<span class="rules-folder svelte-1r3tey2"> </span>`),h_=U(`<p class="empty-msg svelte-1r3tey2"> </p>`),g_=U(`<span class="tag svelte-1r3tey2"> </span>`),__=U(`<div class="rule-tags svelte-1r3tey2"></div>`),v_=U(`<div class="rule-applies svelte-1r3tey2"> </div>`),y_=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>`),b_=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 x_(e,t){qe(t,!0);let n=qi(t,`rules`,19,()=>[]),r=qi(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=b_(),g=L(h),_=L(g),v=L(_),y=L(v,!0);j(v);var b=z(v,2),x=e=>{var t=m_(),n=L(t,!0);j(t),B(()=>G(n,r())),W(e,t)};K(b,e=>{r()&&e(x)}),j(_);var S=z(_,2),C=L(S),w=e=>{var t=h_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.no_rules`)]),W(e,t)},T=e=>{var t=Wr();q(R(t),17,n,Qr,(e,t)=>{var n=y_(),r=L(n),i=L(r),a=L(i),o=L(a),s=L(o,!0);j(o),j(a);var c=z(a,2),l=L(c,!0);j(c),j(i);var u=z(i,2),p=L(u,!0);j(u),j(r);var m=z(r,2),h=L(m,!0);j(m);var g=z(m,2),_=e=>{var n=__();q(n,21,()=>V(t).tags,Qr,(e,t)=>{var n=g_(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(n),W(e,n)};K(g,e=>{V(t).tags?.length&&e(_)});var v=z(g,2),y=e=>{var n=v_(),r=L(n,!0);j(n),B(e=>G(r,e),[()=>V(t).appliesTo.join(`, `)]),W(e,n)};K(v,e=>{V(t).appliesTo?.length&&e(y)}),j(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)}),j(S),j(g);var E=z(g,2),D=L(E),ee=L(D,!0);j(D);var te=z(D,2),O=L(te),k=L(O,!0);j(O);var ne=z(O,2);ki(ne),j(te);var A=z(te,2),re=L(A),ie=L(re,!0);j(re);var ae=z(re,2),oe=L(ae),se=L(oe,!0);j(oe),oe.value=oe.__value=`guideline`;var ce=z(oe),le=L(ce,!0);j(ce),ce.value=ce.__value=`warning`;var ue=z(ce),de=L(ue,!0);j(ue),ue.value=ue.__value=`required`,j(ae),j(A);var fe=z(A,2),pe=L(fe),me=L(pe,!0);j(pe);var he=z(pe,2);ki(he),j(fe);var ge=z(fe,2),_e=L(ge),ve=L(_e,!0);j(_e);var ye=z(_e,2);ki(ye),j(ge);var be=z(ge,2),xe=L(be),Se=L(xe,!0);j(xe);var Ce=z(xe,2);ki(Ce),j(be);var we=z(be,2),Te=L(we),Ee=L(Te,!0);j(Te);var De=z(Te,2);yn(De),j(we);var Oe=z(we,2),ke=L(Oe,!0);j(Oe),j(E),j(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(Ee,m),J(De,`placeholder`,h),Oe.disabled=g,G(ke,_)},[()=>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`)]),Fi(ne,()=>V(i),e=>F(i,e)),Ci(ae,()=>V(a),e=>F(a,e)),Fi(he,()=>V(o),e=>F(o,e)),Fi(ye,()=>V(s),e=>F(s,e)),Fi(Ce,()=>V(c),e=>F(c,e)),Fi(De,()=>V(l),e=>F(l,e)),H(`click`,Oe,m),W(e,h),Je()}Pr([`click`]);var S_=U(`<p class="empty-msg svelte-1ui2b6s"> </p>`),C_=U(`<p class="mcp-desc svelte-1ui2b6s"> </p>`),w_=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>`),T_=U(`<div class="mcp-result svelte-1ui2b6s" data-testid="mcp-result"></div>`),E_=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>`),D_=U(`<p class="mcp-arg-desc svelte-1ui2b6s"> </p>`),O_=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>`),k_=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>`),A_=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 j_(e,t){qe(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(`
|
|
92
92
|
|
|
93
93
|
`):Array.isArray(t.content)?t.content.map(e=>e&&e.type===`text`&&typeof e.text==`string`?b(e.text):y(e)).join(`
|
|
94
94
|
|
|
@@ -96,75 +96,75 @@ Texte`};case`link`:return{text:ut(`snip-link-text`),textFallback:Y(`snippet.link
|
|
|
96
96
|
`)}function T(e){if(typeof e==`string`)return e;if(!e||typeof e!=`object`)return String(e??``);if(e.error)return JSON.stringify(e.error,null,2);let t=e.result;return t?.isError?(Array.isArray(t.content)?t.content.map(e=>e&&e.type===`text`&&typeof e.text==`string`?e.text:JSON.stringify(e,null,2)).filter(Boolean):[]).join(`
|
|
97
97
|
|
|
98
98
|
`)||JSON.stringify(t,null,2):JSON.stringify(e,null,2)}async function E(e,t,n){let r=await fetch(`/api/context/mcp-result`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e,content:t,kind:n})});if(!r.ok)throw Error(await r.text()||`HTTP ${r.status}`);return r.json()}function D(e){let t=encodeURIComponent(String(e||``).replace(/\.md$/i,``));return`/?doc=`+encodeURIComponent(t)}async function ee(e,t){let n=d(e,t),r={};try{r=n.argsJson.trim()?JSON.parse(n.argsJson):{}}catch{f(e,t,{error:Y(`context.mcp_invalid_json`)});return}f(e,t,{running:!0,error:``,resultHtml:`<span class="mcp-running">${Y(`context.mcp_running`)}</span>`});try{await v();let n=e===`tool`?await _(2,`tools/call`,{name:t,arguments:r}):await _(2,`prompts/get`,{name:t,arguments:r});if(n.error||n.result?.isError){let r=T(n);f(e,t,{running:!1,error:Y(`context.mcp_error`),resultHtml:r?`<pre class="mcp-error-pre">${O(r)}</pre>`:``});return}let i=e===`tool`?V(o).find(e=>e.name===t):null,{path:a}=await E(t,e===`tool`&&i?w(i,r,n):x(n),e),s=D(a);f(e,t,{running:!1,error:``,resultHtml:`<div class="mcp-saved-label">${O(Y(`context.mcp_saved_to`))}</div>
|
|
99
|
-
<a href="${O(s)}" target="_blank" rel="noopener" class="mcp-saved-link">📄 ${O(a)}</a>`})}catch(n){f(e,t,{running:!1,error:n.message||String(n),resultHtml:``})}}async function te(e){let n=V(e===`tool`?o:s);if(!n.length)return;F(c,!0);let r=n.length;try{for(let i=0;i<n.length;i++)t.onStatus(Y(`context.mcp_running_all`).replace(`{current}`,String(i+1)).replace(`{total}`,String(r))),await ee(e,n[i].name);t.onStatus(Y(`context.mcp_done_all`).replace(`{total}`,String(r)))}finally{F(c,!1)}}function O(e){return String(e??``).replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e])}async function k(){try{let e=await fetch(`/mcp`);if(!e.ok)throw Error(await e.text());let t=await e.json(),c=Array.isArray(t.tools)?t.tools:[],l=Array.isArray(t.prompts)?t.prompts:[];F(n,Y(`context.mcp_available`),!0),F(r,!0),F(i,t.transport||`-`,!0),F(a,t.endpoint||`POST /mcp`,!0),F(o,c,!0),F(s,l,!0),c.forEach(m),l.forEach(h)}catch{F(n,Y(`context.mcp_unavailable`),!0),F(r,!1),F(i,`-`),F(a,`/mcp`),F(o,[],!0),F(s,[],!0)}}var ne={load:k},A=w_(),re=L(A),ie=L(re),ae=L(ie,!0);j(ie);var oe=z(ie,2),se=L(oe,!0);j(oe),j(re);var ce=z(re,2),le=L(ce,!0);j(ce);var ue=z(ce,2),de=L(ue),fe=L(de),pe=L(fe,!0);j(fe);var me=z(fe,2),he=L(me,!0);j(me),j(de);var ge=z(de,2),_e=L(ge),ve=L(_e,!0);j(_e);var ye=z(_e,2),be=L(ye,!0);j(ye),j(ge);var xe=z(ge,2),Se=L(xe),Ce=L(Se,!0);j(Se);var we=z(Se,2),Te=L(we,!0);j(we),j(xe),j(ue);var Ee=z(ue,2),De=L(Ee),Oe=L(De),ke=L(Oe,!0);j(Oe);var Ae=z(Oe,2),je=L(Ae),Me=L(je,!0);j(je);var Ne=z(je,2),Pe=L(Ne,!0);j(Ne),j(Ae),j(De);var Fe=z(De,2),Ie=L(Fe),Le=e=>{var t=g_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.mcp_no_tools`)]),W(e,t)},Re=e=>{var t=Wr();q(R(t),17,()=>V(o),Qr,(e,t)=>{let n=N(()=>V(l).get(V(t).name)??{argsJson:`{}`,running:!1,error:``,resultHtml:``});var r=b_(),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=e=>{var n=__(),r=L(n,!0);j(n),B(()=>G(r,V(t).description)),W(e,n)};K(o,e=>{V(t).description&&e(s)});var c=z(o,2),u=e=>{var n=v_(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n),B((e,t)=>{G(i,e),G(o,t)},[()=>Y(`context.mcp_input_schema`),()=>JSON.stringify(V(t).inputSchema,null,2)]),W(e,n)};K(c,e=>{V(t).inputSchema&&e(u)});var d=z(c,2),p=L(d),m=L(p,!0);j(p);var h=z(p,2);yn(h);var g=z(h,2),_=L(g),v=L(_,!0);j(_);var y=z(_,2),b=L(y,!0);j(y),j(g);var x=z(g,2),S=e=>{var t=y_();si(t,()=>V(n).resultHtml,!0),j(t),W(e,t)};K(x,e=>{V(n).resultHtml&&e(S)}),j(d),j(r),B((e,r)=>{G(a,V(t).name),G(m,e),Ai(h,V(n).argsJson),G(v,V(n).error),y.disabled=V(n).running,G(b,r)},[()=>Y(`context.mcp_request_json`),()=>Y(`context.mcp_run_tool`)]),H(`input`,h,e=>f(`tool`,V(t).name,{argsJson:e.target.value})),H(`click`,y,()=>ee(`tool`,V(t).name)),W(e,r)}),W(e,t)};K(Ie,e=>{V(o).length?e(Re,-1):e(Le)}),j(Fe),j(Ee);var ze=z(Ee,2),Be=L(ze),Ve=L(Be),He=L(Ve,!0);j(Ve);var Ue=z(Ve,2),We=L(Ue),Ge=L(We,!0);j(We);var Ke=z(We,2),Ye=L(Ke,!0);j(Ke),j(Ue),j(Be);var Xe=z(Be,2),Ze=L(Xe),Qe=e=>{var t=g_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.mcp_no_prompts`)]),W(e,t)},$e=e=>{var t=Wr();q(R(t),17,()=>V(s),Qr,(e,t)=>{let n=N(()=>V(u).get(V(t).name)??{argsJson:`{}`,running:!1,error:``,resultHtml:``});var r=b_(),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=e=>{var n=__(),r=L(n,!0);j(n),B(()=>G(r,V(t).description)),W(e,n)};K(o,e=>{V(t).description&&e(s)});var c=z(o,2),l=e=>{var n=C_(),r=L(n),i=L(r,!0);j(r);var a=z(r,2);q(a,21,()=>V(t).arguments,Qr,(e,t)=>{var n=S_(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var c=z(r,2),l=e=>{var n=x_(),r=L(n,!0);j(n),B(()=>G(r,V(t).description)),W(e,n)};K(c,e=>{V(t).description&&e(l)}),j(n),B(e=>{G(a,V(t).name),G(s,e)},[()=>V(t).required?Y(`context.mcp_required`):Y(`context.mcp_optional`)]),W(e,n)}),j(a),j(n),B(e=>G(i,e),[()=>Y(`context.mcp_arguments`)]),W(e,n)};K(c,e=>{V(t).arguments?.length&&e(l)});var d=z(c,2),p=L(d),m=L(p,!0);j(p);var h=z(p,2);yn(h);var g=z(h,2),_=L(g),v=L(_,!0);j(_);var y=z(_,2),b=L(y,!0);j(y),j(g);var x=z(g,2),S=e=>{var t=y_();si(t,()=>V(n).resultHtml,!0),j(t),W(e,t)};K(x,e=>{V(n).resultHtml&&e(S)}),j(d),j(r),B((e,r)=>{G(a,V(t).name),G(m,e),Ai(h,V(n).argsJson),G(v,V(n).error),y.disabled=V(n).running,G(b,r)},[()=>Y(`context.mcp_request_json`),()=>Y(`context.mcp_get_prompt`)]),H(`input`,h,e=>f(`prompt`,V(t).name,{argsJson:e.target.value})),H(`click`,y,()=>ee(`prompt`,V(t).name)),W(e,r)}),W(e,t)};return K(Ze,e=>{V(s).length?e($e,-1):e(Qe)}),j(Xe),j(ze),j(A),B((e,t,l,u,d,f,p,m,h,g)=>{G(ae,e),G(se,t),G(le,l),G(pe,u),vi(me,1,fi(V(r)?`mcp-info-value ok`:`mcp-info-value err`),`svelte-1ui2b6s`),G(he,V(n)),G(ve,d),G(be,V(i)),G(Ce,f),G(Te,V(a)),G(ke,p),G(Me,V(o).length),Ne.disabled=V(c)||!V(o).length,G(Pe,m),G(He,h),G(Ge,V(s).length),Ke.disabled=V(c)||!V(s).length,G(Ye,g)},[()=>Y(`context.mcp_title`),()=>Y(`context.mcp_refresh`),()=>Y(`context.mcp_intro`),()=>Y(`context.mcp_status`),()=>Y(`context.mcp_transport`),()=>Y(`context.mcp_endpoint`),()=>Y(`context.mcp_tools`),()=>Y(`context.mcp_run_all_tools`),()=>Y(`context.mcp_prompts`),()=>Y(`context.mcp_get_all_prompts`)]),H(`click`,oe,k),H(`click`,Ne,()=>te(`tool`)),H(`click`,Ke,()=>te(`prompt`)),W(e,A),Je(ne)}Pr([`click`,`input`]);var E_=U(`<p class="status-text svelte-rpj1e5"> </p>`),D_=U(`<div class="app-shell"><!> <main class="context-scroll svelte-rpj1e5"><div class="context-inner svelte-rpj1e5"><section class="page-intro svelte-rpj1e5"><h2 class="page-title svelte-rpj1e5"> </h2> <p class="page-desc svelte-rpj1e5"> </p> <!></section> <!> <!> <!></div></main></div> <!>`,1);function O_(e,t){qe(t,!0);let n=P(``),r=P(I([])),i=P(I([])),a=P(``),o=P(null),s=P(null),c=P(null);function l(e){F(n,e,!0)}async function u(){l(Y(`context.loading`));let e=await fetch(`/api/context/orientation`);if(!e.ok)throw Error(await e.text());let t=await e.json();F(o,t,!0),F(r,t.instructions||[],!0),F(i,t.rules||[],!0),F(a,t.rulesFolder||``,!0),l(``)}async function d(e){l(Y(`context.adding_instruction_file`));let t=await fetch(`/api/context/instructions`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})});if(!t.ok)throw Error(await t.text());await u()}async function f(e){if(!await V(s).show({kicker:Y(`context.remove_instruction_title`),title:Y(`context.remove_instruction_title`),message:Y(`context.remove_instruction_message`).replace(`{name}`,e),confirmLabel:Y(`common.remove`),cancelLabel:Y(`common.cancel`)||`Cancel`,danger:!0}))return;l(Y(`context.removing_instruction_file`));let t=await fetch(`/api/context/instructions/`+encodeURIComponent(e),{method:`DELETE`});if(!t.ok)throw Error(await t.text());await u()}async function p(e){l(Y(`context.saving_rule`));let t=await fetch(`/api/context/rules`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await t.text());await u()}Ji(async()=>{try{let e=await fetch(`/api/config`);await Sa((e.ok?await e.json():{}).language||`en`)}catch{await Sa(`en`)}document.title=Y(`context.title`),await u().catch(e=>l(e.message)),await V(c).load().catch(()=>{})});var m=D_(),h=R(m),g=L(h);Xo(g,{get navigate(){return t.navigate}});var _=z(g,2),v=L(_),y=L(v),b=L(y),x=L(b,!0);j(b);var S=z(b,2),C=L(S,!0);j(S);var w=z(S,2),T=e=>{var t=E_(),r=L(t,!0);j(t),B(()=>G(r,V(n))),W(e,t)};K(w,e=>{V(n)&&e(T)}),j(y);var E=z(y,2);s_(E,{onAdd:d,onRemove:f,get items(){return V(r)},set items(e){F(r,e,!0)}});var D=z(E,2);h_(D,{get rules(){return V(i)},get rulesFolder(){return V(a)},onAdd:p}),Ui(T_(z(D,2),{onStatus:l}),e=>F(c,e,!0),()=>V(c)),j(v),j(_),j(h),Ui(Xd(z(h,2),{}),e=>F(s,e,!0),()=>V(s)),B((e,t)=>{G(x,e),G(C,t)},[()=>Y(`context.orientation_title`),()=>Y(`context.orientation_intro`)]),W(e,m),Je()}async function k_(){return fetch(`/api/config`).then(e=>e.json())}async function A_(){return fetch(`/api/documents`).then(e=>e.json())}async function j_(e){return fetch(`/api/browse/alldirs?path=${encodeURIComponent(e)}`).then(e=>e.json())}async function M_(e){let t=await fetch(`/api/documents/${e}`);if(!t.ok)throw Error(t.statusText);return t.json()}async function N_(){try{let e=await fetch(`/api/annotations`).then(e=>e.json()),t={};for(let[n,r]of Object.entries(e||{})){t[n]=r;try{t[encodeURIComponent(n)]=r}catch{}}return t}catch{return{}}}async function P_(){try{return await fetch(`/api/documents/file-counts`).then(e=>e.json())}catch{return{}}}async function F_(){try{return await fetch(`/api/documents/statuses`).then(e=>e.json())}catch{return{}}}async function I_(e){return fetch(`/api/documents/search?q=${encodeURIComponent(e)}`).then(e=>e.json())}function L_(e){return((e.filename||``).split(`/`).pop()??``).match(/^(\d{4}_\d{2}_\d{2}(?:_\d{2}_\d{2})?)/)?.[1]??``}function R_(e){return e===`alphabetical`?(e,t)=>(e.title||e.filename||``).localeCompare(t.title||t.filename||``):(t,n)=>{let r=L_(t),i=L_(n);return r&&i?e===`oldest`?r.localeCompare(i):i.localeCompare(r):r?-1:i?1:(t.filename||``).localeCompare(n.filename||``)}}function z_(e,t){for(let n of Object.values(e.categories))n.sort(t);for(let n of Object.values(e.children))z_(n,t)}function B_(e,t,n,r=`recent`){let i={categories:{},children:{}};for(let t of e){let e=i;for(let n of t.folder||[])e.children[n]||(e.children[n]={categories:{},children:{}}),e=e.children[n];e.categories[t.category]||(e.categories[t.category]=[]),e.categories[t.category].push(t)}if(n)for(let e of t){let t=e.split(`/`).filter(Boolean),n=i;for(let e of t)n.children[e]||(n.children[e]={categories:{},children:{}}),n=n.children[e]}return z_(i,R_(r)),i}function V_(e){let t=Object.values(e.categories).reduce((e,t)=>e+t.length,0);for(let n of Object.values(e.children))t+=V_(n);return t}function H_(e,t){let n=0;for(let r of Object.values(e.categories))for(let e of r)t[e.id]>0&&(n+=1);for(let r of Object.values(e.children))n+=H_(r,t);return n}function U_(e,t){let n=0;for(let r of Object.values(e.categories))for(let e of r)t[e.id]>0&&(n+=1);for(let r of Object.values(e.children))n+=U_(r,t);return n}function W_(e){return e.replace(/^\d+_/,``).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function G_(e){return Object.keys(e.children).sort((e,t)=>e.localeCompare(t))}function K_(e){return Object.keys(e.categories).filter(e=>e!==`General`).sort((e,t)=>e.localeCompare(t))}function q_(e,t=`recent`){return Object.values(e.categories).flat().sort(R_(t))}var J_=U(`<span class="inline-flex items-center justify-center w-5 h-5 rounded-full bg-green-500 text-[10px] font-bold text-white border border-green-600 shadow-sm">V</span>`),Y_=U(`<span class="inline-flex items-center justify-center w-5 h-5 rounded-full bg-orange-500 text-[10px] font-bold text-white border border-orange-600 shadow-sm">S</span>`),X_=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-yellow-300 dark:bg-yellow-400 text-[10px] font-bold text-yellow-900 border border-yellow-500 shadow-sm"> </span>`),Z_=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-sky-200 dark:bg-sky-300 text-[10px] font-bold text-sky-900 border border-sky-500 shadow-sm"> </span>`),Q_=U(`<div class="text-xs text-gray-400 dark:text-gray-500 mt-0.5"> </div>`),$_=U(`<button><div class="leading-snug flex items-center justify-between gap-2"><span class="truncate"> </span> <span class="flex items-center gap-1 shrink-0"><!> <!> <!></span></div> <!></button>`),ev=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-orange-400 dark:bg-orange-500 text-[10px] font-bold text-white border border-orange-600 shadow-sm"> </span>`),tv=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-slate-400 dark:bg-slate-500 text-[10px] font-bold text-white border border-slate-600 shadow-sm"> </span>`),nv=U(`<div class="pl-2"></div>`),rv=U(`<div class="mb-0.5"><button class="w-full flex items-center justify-between px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider hover:bg-gray-50 dark:hover:bg-gray-800/60 rounded-md transition-colors"><span class="flex items-center gap-2"><span> </span> <!> <!></span> <span class="flex items-center gap-1.5"><span class="font-normal normal-case text-gray-400"> </span> <span>▸</span></span></button> <!></div>`),iv=U(`<div class="pl-3"><!></div>`),av=U(`<div class="mb-1"><button class="w-full flex items-center justify-between px-3 py-1.5 text-xs font-semibold text-violet-600 dark:text-violet-400 uppercase tracking-wider hover:bg-gray-50 dark:hover:bg-gray-800/60 rounded-md transition-colors"><span class="flex items-center gap-2 min-w-0"><span class="truncate"> </span> <!> <!></span> <span class="flex items-center gap-1.5"><span class="font-normal normal-case text-gray-400"> </span> <span>▸</span></span></button> <!></div>`),ov=U(`<!> <!>`,1),sv=U(`<!> <!> <!>`,1);function cv(e,t){qe(t,!0);let n=(e,n=f)=>{let r=N(()=>X.annotationCounts[n().id]||0),i=N(()=>X.fileAttachmentCounts[n().id]||0),a=N(()=>c(n()));var o=$_(),l=L(o),u=L(l),d=L(u,!0);j(u);var p=z(u,2),m=L(p),h=e=>{var t=J_();B(e=>J(t,`title`,e),[()=>Y(`sidebar.status_to_validate`)]),W(e,t)},g=e=>{var t=Y_();B(e=>J(t,`title`,e),[()=>Y(`sidebar.status_superseeded`)]),W(e,t)};K(m,e=>{V(a)===`V`?e(h):V(a)===`S`&&e(g,1)});var _=z(m,2),v=e=>{var t=X_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(r))},[()=>s(V(r),`sidebar.annotation_badge`)]),W(e,t)};K(_,e=>{V(r)>0&&!X.markerHidden&&e(v)});var y=z(_,2),b=e=>{var t=Z_(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(i))},[()=>s(V(i),`sidebar.file_attachment_badge`)]),W(e,t)};K(y,e=>{V(i)>0&&!X.hideAttachments&&e(b)}),j(p),j(l);var x=z(l,2),S=e=>{var t=Q_(),r=L(t,!0);j(t),B(()=>G(r,n().formattedDate)),W(e,t)};K(x,e=>{n().formattedDate&&e(S)}),j(o),B(()=>{J(o,`id`,`item-${n().id??``}`),vi(o,1,`doc-item w-full text-left px-3 py-1.5 rounded-md text-sm transition-colors text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800/60 ${n().id===X.currentDocId?`active`:``}`),G(d,n().title)}),H(`click`,o,()=>t.onopen(n().id)),W(e,o)},r=(e,r=f)=>{let i=N(()=>a(r())),o=N(()=>X.expandedCategories.has(V(i))),c=N(()=>t.node.categories[r()]),l=N(()=>V(c).reduce((e,t)=>e+ +(X.annotationCounts[t.id]>0),0)),u=N(()=>V(c).reduce((e,t)=>e+ +(X.fileAttachmentCounts[t.id]>0),0));var d=rv(),p=L(d),m=L(p),h=L(m),g=L(h,!0);j(h);var _=z(h,2),v=e=>{var t=ev(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(l))},[()=>s(V(l),`sidebar.annotated_docs_badge`)]),W(e,t)};K(_,e=>{V(l)>0&&!X.markerHidden&&e(v)});var y=z(_,2),b=e=>{var t=tv(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(u))},[()=>s(V(u),`sidebar.file_attached_docs_badge`)]),W(e,t)};K(y,e=>{V(u)>0&&!X.hideAttachments&&e(b)}),j(m);var x=z(m,2),S=L(x),C=L(S,!0);j(S);var w=z(S,2);j(x),j(p);var T=z(p,2),E=e=>{var t=nv();q(t,21,()=>V(c),e=>e.id,(e,t)=>{n(e,()=>V(t))}),j(t),W(e,t)};K(T,e=>{V(o)&&e(E)}),j(d),B(()=>{G(g,r()),G(C,V(c).length),vi(w,1,`transition-transform duration-200 ${V(o)?`rotate-90`:``}`)}),H(`click`,p,()=>X.toggleCategory(V(i))),W(e,d)},i=(e,n=f)=>{let r=N(()=>o(n())),i=N(()=>X.expandedFolders.has(V(r))),a=N(()=>t.node.children[n()]),c=N(()=>V_(V(a))),l=N(()=>H_(V(a),X.annotationCounts)),u=N(()=>U_(V(a),X.fileAttachmentCounts));var d=av(),p=L(d),m=L(p),h=L(m),g=L(h);j(h);var _=z(h,2),v=e=>{var t=ev(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(l))},[()=>s(V(l),`sidebar.annotated_docs_badge`)]),W(e,t)};K(_,e=>{V(l)>0&&!X.markerHidden&&e(v)});var y=z(_,2),b=e=>{var t=tv(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(u))},[()=>s(V(u),`sidebar.file_attached_docs_badge`)]),W(e,t)};K(y,e=>{V(u)>0&&!X.hideAttachments&&e(b)}),j(m);var x=z(m,2),S=L(x),C=L(S,!0);j(S);var w=z(S,2);j(x),j(p);var T=z(p,2),E=e=>{var r=iv(),i=L(r);{let e=N(()=>[...t.folderPath,n()]);cv(i,{get node(){return V(a)},get folderPath(){return V(e)},get onopen(){return t.onopen}})}j(r),W(e,r)};K(T,e=>{V(i)&&e(E)}),j(d),B(e=>{J(h,`title`,n()),G(g,`📁 ${e??``}`),G(C,V(c)),vi(w,1,`transition-transform duration-200 ${V(i)?`rotate-90`:``}`)},[()=>W_(n())]),H(`click`,p,()=>X.toggleFolder(V(r))),W(e,d)};function a(e){return[...t.folderPath,e].join(`|`)}function o(e){return[...t.folderPath,e].join(`|`)}function s(e,t){return`${e} ${Y(t)}${e>1?`s`:``}`}function c(e){if(!X.highlightStatusState)return null;let t=String(X.docStatuses[e.id]||``).trim().toLowerCase();return t===`to be validated`?`V`:X.highlightStatusState===2&&t===`superseeded`?`S`:null}var l=Wr(),u=R(l),d=e=>{var r=ov(),a=R(r);q(a,17,()=>q_(t.node,X.sidebarSort),e=>e.id,(e,t)=>{n(e,()=>V(t))}),q(z(a,2),16,()=>G_(t.node),e=>e,(e,t)=>{i(e,()=>t)}),W(e,r)},p=e=>{var n=sv(),a=R(n),o=e=>{r(e,()=>`General`)};K(a,e=>{t.node.categories.General&&e(o)});var s=z(a,2);q(s,16,()=>G_(t.node),e=>e,(e,t)=>{i(e,()=>t)}),q(z(s,2),16,()=>K_(t.node),e=>e,(e,t)=>{r(e,()=>t)}),W(e,n)};K(u,e=>{X.hideCategories?e(d):e(p,-1)}),W(e,l),Je()}Pr([`click`]);var lv=U(`<p class="px-4 py-8 text-sm text-gray-400 text-center"> </p>`),uv=U(`<aside><div class="sticky top-0 z-10 bg-white dark:bg-gray-900 p-3 border-b border-gray-100 dark:border-gray-800"><div class="relative sm:hidden"><input type="search" class="w-full 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> <div class="flex items-center justify-between mt-2 sm:mt-0"><p class="text-xs text-gray-400 dark:text-gray-500"> </p> <div class="flex items-center gap-2"><button><i class="fa-solid fa-certificate"></i></button> <button><i class="fa-solid fa-paperclip"></i></button> <button><i class="fa-solid fa-tags"></i></button> <button class="text-gray-400 hover:text-blue-500 dark:text-gray-500 dark:hover:text-blue-400 transition-colors leading-none"><i class="fa-solid fa-file-export"></i></button> <button class="text-gray-400 hover:text-blue-500 dark:text-gray-500 dark:hover:text-blue-400 transition-colors leading-none"><i class="fa-solid fa-folder-plus"></i></button> <button class="text-gray-400 hover:text-blue-500 dark:text-gray-500 dark:hover:text-blue-400 transition-colors leading-none"><i class="fa-solid fa-file-circle-plus"></i></button></div></div></div> <nav data-testid="category-tree" class="flex-1 py-2 space-y-0.5"><!></nav> <div aria-hidden="true"></div></aside>`);function dv(e,t){qe(t,!0);let n=N(()=>B_(X.filteredDocs,X.allFolderPaths,!X.searchQuery,X.sidebarSort)),r=N(()=>X.filteredDocs.length),i=N(()=>X.filteredDocs.length===0&&X.allFolderPaths.length===0),a=`ld-sidebar-w`,o=P(null),s=P(!1),c=P(null);kn(()=>{let e=parseInt(localStorage.getItem(a)||``,10);Number.isFinite(e)&&F(o,Math.max(200,Math.min(600,e)),!0)});function l(e){e.preventDefault();let t=e.clientX,n=V(c).getBoundingClientRect().width;F(s,!0),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let r=e=>{F(o,Math.max(200,Math.min(600,n+e.clientX-t)),!0)},i=()=>{if(document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i),document.body.style.cursor=``,document.body.style.userSelect=``,F(s,!1),V(o)!=null)try{localStorage.setItem(a,String(V(o)))}catch{}};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)}var u=uv(),d=L(u),f=L(d),p=L(f);ki(p),Ie(2),j(f);var m=z(f,2),h=L(m),g=L(h);j(h);var _=z(h,2),v=L(_),y=z(v,2),b=z(y,2),x=z(b,2),S=z(x,2),C=z(S,2);j(_),j(m),j(d);var w=z(d,2),T=L(w),E=e=>{var t=lv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`sidebar.no_docs`)]),W(e,t)},D=e=>{cv(e,{get node(){return V(n)},folderPath:[],get onopen(){return t.onopen}})};K(T,e=>{V(i)?e(E):e(D,-1)}),j(w);var ee=z(w,2);j(u),Ui(u,e=>F(c,e),()=>V(c)),B((e,t,n,i,a,c,l)=>{vi(u,1,`no-print ${V(o)==null?`w-72`:``} shrink-0 flex flex-col border-r border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 overflow-y-auto relative`),bi(u,V(o)==null?``:`width:${V(o)}px`),J(p,`placeholder`,e),Ai(p,X.searchQuery),G(g,`${V(r)??``} document${V(r)===1?``:`s`}`),J(v,`title`,t),vi(v,1,`hover:opacity-80 transition-colors leading-none ${X.highlightStatusState===0?`text-gray-400 dark:text-gray-500`:X.highlightStatusState===1?`text-green-500 dark:text-green-400`:`text-orange-500 dark:text-orange-400`}`),J(y,`title`,n),vi(y,1,`transition-colors leading-none ${X.hideAttachments?`text-gray-400 dark:text-gray-500`:`text-blue-500 dark:text-blue-400`}`),J(b,`title`,i),vi(b,1,`transition-colors leading-none ${X.hideCategories?`text-gray-400 dark:text-gray-500`:`text-blue-500 dark:text-blue-400`}`),J(x,`title`,a),J(S,`title`,c),J(C,`title`,l),vi(ee,1,`absolute top-0 right-[-2px] w-1.5 h-full cursor-col-resize z-20 select-none transition-colors ${V(s)?`bg-blue-500/55`:`hover:bg-blue-500/35`}`)},[()=>Y(`nav.search_mobile_placeholder`),()=>Y(`nav.toggle_status_highlight`),()=>Y(`nav.toggle_attachments`),()=>Y(`nav.toggle_categories`),()=>Y(`nav.export`),()=>Y(`nav.new_folder`),()=>Y(`nav.new_document`)]),H(`input`,p,e=>t.onsearch(e.target.value)),H(`click`,v,()=>X.cycleHighlightStatus()),H(`click`,y,()=>X.toggleHideAttachments()),H(`click`,b,()=>X.toggleHideCategories()),H(`click`,x,function(...e){t.onexport?.apply(this,e)}),H(`click`,S,function(...e){t.onnewfolder?.apply(this,e)}),H(`click`,C,function(...e){t.onnewdoc?.apply(this,e)}),H(`mousedown`,ee,l),W(e,u),Je()}Pr([`input`,`click`,`mousedown`]);var fv=`background:rgba(250,204,21,0.5);border-radius:2px;cursor:pointer;padding:0 1px;`;function pv(e,t,n){e.querySelectorAll(`mark[data-annotation-id]`).forEach(e=>{let t=e.parentNode;t&&(t.replaceChild(document.createTextNode(e.textContent||``),e),t.normalize())});for(let n of t)hv(e,n);e.querySelectorAll(`mark[data-annotation-id]`).forEach(e=>{(e.textContent||``).trim()||e.remove()}),n&&mv(e,!1)}function mv(e,t){e.querySelectorAll(`mark[data-annotation-id]`).forEach(e=>{let n=e;n.style.background=t?`rgba(250,204,21,0.5)`:`transparent`,n.style.cursor=t?`pointer`:`default`,n.style.pointerEvents=t?`auto`:`none`})}function hv(e,t){let n=(t.selectedText||``).replace(/\s+/g,` `).trim(),r=(t.contextBefore||``).replace(/\s+/g,` `).trim(),i=(t.contextAfter||``).replace(/\s+/g,` `).trim();if(!n)return;let a=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),o=e=>e.split(/\s+/).filter(Boolean).map(a).join(`\\s+`),s=e.textContent||``,c=o(n),l=null;if(r||i){let e=(r?`${o(r)}\\s*`:``)+`(`+c+`)`+(i?`\\s*${o(i)}`:``);try{l=new RegExp(e,`d`).exec(s)}catch{}}if(!l)try{l=RegExp(`(${c})`,`d`).exec(s)}catch{return}let u=l&&l.indices;if(!l||!u?.[1])return;let[d,f]=u[1],p=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),m=[],h=0;for(;p.nextNode();){let e=p.currentNode,t=e.nodeValue?.length,n=h,r=h+t;if(h=r,r<=d)continue;if(n>=f)break;let i=Math.max(0,d-n),a=Math.min(t,f-n);i<a&&m.push({node:e,start:i,end:a})}for(let{node:e,start:n,end:r}of m){let i=e;n>0&&n<i.nodeValue?.length&&(i=i.splitText(n));let a=r-n;a>0&&a<i.nodeValue?.length&&i.splitText(a);let o=document.createElement(`mark`);o.setAttribute(`data-annotation-id`,t.id),o.setAttribute(`style`,fv),i.parentNode?.insertBefore(o,i),o.appendChild(i)}}var gv=U(`<div class="fixed z-50 w-80 bg-yellow-50 dark:bg-yellow-900/80 border-2 border-yellow-300 dark:border-yellow-600 rounded-xl shadow-2xl p-4 flex flex-col gap-3"><div class="text-xs font-semibold text-yellow-700 dark:text-yellow-300 flex items-center gap-2"><span>✎</span><span> </span></div> <div class="text-xs text-yellow-800 dark:text-yellow-200 bg-yellow-100 dark:bg-yellow-800/50 rounded px-2 py-1 italic max-h-16 overflow-y-auto border border-yellow-200 dark:border-yellow-700"> </div> <textarea rows="4" class="w-full text-sm rounded-lg border border-yellow-300 dark:border-yellow-600 bg-white dark:bg-yellow-950 text-gray-900 dark:text-gray-100 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-yellow-400 resize-none"></textarea> <div class="flex justify-end gap-2"><button class="text-sm px-3 py-1.5 rounded-lg border border-yellow-300 dark:border-yellow-600 text-yellow-700 dark:text-yellow-300 hover:bg-yellow-100 dark:hover:bg-yellow-800 transition-colors"> </button> <button class="text-sm px-4 py-1.5 rounded-lg bg-yellow-400 hover:bg-yellow-500 dark:bg-yellow-600 dark:hover:bg-yellow-500 text-yellow-900 dark:text-white font-semibold transition-colors"> </button></div></div>`),_v=U(`<div class="text-xs font-semibold text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-700 rounded px-2 py-1"> </div>`),vv=U(`<div class="fixed z-50 w-80 bg-yellow-50 dark:bg-yellow-900/80 border-2 border-yellow-300 dark:border-yellow-600 rounded-xl shadow-2xl p-4 flex flex-col gap-2"><div class="text-xs font-semibold text-yellow-700 dark:text-yellow-300 flex items-center gap-2"><span>✎</span><span class="font-normal text-yellow-600 dark:text-yellow-400"> </span></div> <!> <div class="text-sm text-gray-800 dark:text-gray-100 whitespace-pre-wrap max-h-48 overflow-y-auto"> </div> <div class="flex justify-end pt-1 border-t border-yellow-200 dark:border-yellow-700"><button class="text-xs px-3 py-1.5 rounded-lg border border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors flex items-center gap-1"> </button></div></div>`),yv=U(`<div class="fixed z-50 w-72 bg-white dark:bg-gray-900 border border-red-200 dark:border-red-700 rounded-xl shadow-2xl p-4 flex flex-col gap-3"><p class="text-sm text-gray-700 dark:text-gray-200"> </p> <div class="flex justify-end gap-2"><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"> </button> <button 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>`),bv=U(`<button> </button>`),xv=U(`<div class="fixed top-14 right-0 w-10 flex flex-col items-center py-2 gap-2 z-40 overflow-y-auto" style="max-height: calc(100vh - 3.5rem)"></div>`),Sv=U(`<!> <!> <!> <!>`,1);function Cv(e,t){qe(t,!0);let n=P(I([])),r=P(null),i=P(``),a=P(null),o=P(null),s=P(I([])),c=null;Ji(()=>{let e=document.getElementById(`home-content-area`);if(!e)return;let t=()=>{c&&clearTimeout(c),F(a,null)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)});function l(e,t,n=320,r=260){let i=window.innerWidth,a=window.innerHeight,o=e;return o+n>i-16&&(o=i-n-16),o<8&&(o=8),{x:o,y:Math.min(t,a-r)}}async function u(e){F(n,[],!0);try{F(n,await fetch(`/api/annotations/`+encodeURIComponent(e)).then(e=>e.json()),!0)}catch{F(n,[],!0)}d()}function d(){t.contentEl&&(pv(t.contentEl,V(n),X.markerHidden),f())}kn(()=>{t.contentEl&&mv(t.contentEl,!X.markerHidden)});function f(){if(!t.contentEl){F(s,[],!0);return}F(s,V(n).map(e=>({id:e.id,note:e.note.length>60?e.note.slice(0,60)+`…`:e.note,orphan:!t.contentEl.querySelector(`mark[data-annotation-id="${e.id}"]`)})),!0)}function p(){if(!X.markerActive||V(r)||!t.contentEl)return;let e=window.getSelection();if(!e||e.isCollapsed||!e.toString().trim()||!t.contentEl.contains(e.anchorNode))return;let n=e.getRangeAt(0),a=document.createRange();a.selectNodeContents(t.contentEl),a.setEnd(n.startContainer,n.startOffset);let o=a.toString().length,s=n.toString(),c=t.contentEl.textContent||``,u=e=>e.replace(/\s+/g,` `).trim(),d=u(s),f=u(c.slice(Math.max(0,o-30),o)),p=u(c.slice(o+s.length,o+s.length+30)),m=n.getBoundingClientRect(),h=l(m.left,m.bottom+8);F(r,{x:h.x,y:h.y,preview:d.length>120?d.slice(0,120)+`…`:d,selectedText:d,contextBefore:f,contextAfter:p},!0),F(i,``)}function m(){F(r,null),window.getSelection()?.removeAllRanges()}async function h(){if(!V(r)||!t.docId)return;let e=V(i).trim();if(e)try{let i=await fetch(`/api/annotations/`+encodeURIComponent(t.docId),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({selectedText:V(r).selectedText,contextBefore:V(r).contextBefore,contextAfter:V(r).contextAfter,note:e})}).then(e=>e.json());F(n,[...V(n),i],!0),m(),d(),X.annotationCounts={...X.annotationCounts,[t.docId]:(X.annotationCounts[t.docId]||0)+1}}catch{}}kn(()=>{if(!t.contentEl)return;let e=t.contentEl,r=e=>{let t=e.target.closest(`mark[data-annotation-id]`);if(!t)return;let r=V(n).find(e=>e.id===t.dataset.annotationId);r&&g(r,t)},i=e=>{let t=e;t.target.closest(`mark[data-annotation-id]`)&&(t.relatedTarget&&t.relatedTarget.closest?.(`mark[data-annotation-id]`)||_())};return e.addEventListener(`mouseover`,r),e.addEventListener(`mouseout`,i),()=>{e.removeEventListener(`mouseover`,r),e.removeEventListener(`mouseout`,i)}});function g(e,n){c&&clearTimeout(c);let r=!t.contentEl?.querySelector(`mark[data-annotation-id="${e.id}"]`),i=n.getBoundingClientRect(),o=l(i.left,i.bottom+8);F(a,{ann:e,x:o.x,y:o.y,orphan:r},!0)}function _(){c=window.setTimeout(()=>{F(a,null)},1500)}function v(){V(a)&&(F(o,{id:V(a).ann.id,x:V(a).x,y:V(a).y},!0),F(a,null))}async function y(){if(!V(o)||!t.docId)return;let e=V(o).id;try{await fetch(`/api/annotations/${encodeURIComponent(t.docId)}/${e}`,{method:`DELETE`}),F(n,V(n).filter(t=>t.id!==e),!0),F(o,null),d();let r=(X.annotationCounts[t.docId]||0)-1,i={...X.annotationCounts};r<=0?delete i[t.docId]:i[t.docId]=r,X.annotationCounts=i}catch{}}function b(e,t){return e.getBoundingClientRect().top+t.scrollTop-t.getBoundingClientRect().top}function x(e,t){let n=e.parentElement;for(;n&&n!==t;)n.tagName===`DETAILS`&&(n.open=!0),n=n.parentElement}function S(e,r){let i=t.contentEl?.querySelector(`mark[data-annotation-id="${e}"]`),o=document.getElementById(`home-content-area`);if(i&&o){if(V(a)?.ann.id===e){c&&clearTimeout(c);return}x(i,o),o.scrollTo({top:b(i,o)-o.clientHeight/2,behavior:`smooth`})}else{let t=V(n).find(t=>t.id===e);t&&g(t,r.currentTarget)}}function C(e,r){c&&clearTimeout(c);let i=V(n).find(t=>t.id===e);if(!i)return;let a=t.contentEl?.querySelector(`mark[data-annotation-id="${e}"]`),o=document.getElementById(`home-content-area`);if(!a||!o){g(i,r.currentTarget);return}x(a,o),o.scrollTo({top:b(a,o)-o.clientHeight/2,behavior:`smooth`});let s,l=()=>{clearTimeout(s),s=window.setTimeout(()=>{o.removeEventListener(`scroll`,l),g(i,a)},80)};o.addEventListener(`scroll`,l),s=window.setTimeout(()=>{o.removeEventListener(`scroll`,l),g(i,a)},600)}function w(e){let t=V(a)?.ann.id===e.id;return e.orphan?t?`#b91c1c`:`#ef4444`:t?`#f97316`:`#facc15`}function T(e){return new Date(e).toLocaleDateString(`fr-FR`,{day:`2-digit`,month:`short`,year:`numeric`})}var E={load:u,apply:d},D=Sv();Nr(`mouseup`,on,p);var ee=R(D),te=e=>{var t=gv(),n=L(t),a=z(L(n)),o=L(a,!0);j(a),j(n);var s=z(n,2),c=L(s,!0);j(s);var l=z(s,2);yn(l),vn(l,!0);var u=z(l,2),d=L(u),f=L(d,!0);j(d);var p=z(d,2),g=L(p,!0);j(p),j(u),j(t),B((e,n,i,a)=>{bi(t,`left:${V(r).x??``}px;top:${V(r).y??``}px`),G(o,e),G(c,V(r).preview),J(l,`placeholder`,n),G(f,i),G(g,a)},[()=>Y(`annotation.title`),()=>Y(`annotation.placeholder`),()=>Y(`common.cancel`),()=>Y(`annotation.save_btn`)]),Fi(l,()=>V(i),e=>F(i,e)),H(`click`,d,m),H(`click`,p,h),W(e,t)};K(ee,e=>{V(r)&&e(te)});var O=z(ee,2),k=e=>{var t=vv(),n=L(t),r=z(L(n)),i=L(r,!0);j(r),j(n);var o=z(n,2),s=e=>{var t=_v(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`annotation.orphan`)]),W(e,t)};K(o,e=>{V(a).orphan&&e(s)});var l=z(o,2),u=L(l,!0);j(l);var d=z(l,2),f=L(d),p=L(f,!0);j(f),j(d),j(t),B((e,n)=>{bi(t,`left:${V(a).x??``}px;top:${V(a).y??``}px`),G(i,e),G(u,V(a).ann.note),G(p,n)},[()=>T(V(a).ann.createdAt),()=>Y(`annotation.delete_btn`)]),Nr(`mouseenter`,t,()=>{c&&clearTimeout(c)}),Nr(`mouseleave`,t,_),H(`click`,f,v),W(e,t)};K(O,e=>{V(a)&&e(k)});var ne=z(O,2),A=e=>{var t=yv(),n=L(t),r=L(n,!0);j(n);var i=z(n,2),a=L(i),s=L(a,!0);j(a);var c=z(a,2),l=L(c,!0);j(c),j(i),j(t),B((e,n,i)=>{bi(t,`left:${V(o).x??``}px;top:${V(o).y??``}px`),G(r,e),G(s,n),G(l,i)},[()=>Y(`annotation.confirm_delete`),()=>Y(`common.cancel`),()=>Y(`annotation.confirm_btn`)]),H(`click`,a,()=>F(o,null)),H(`click`,c,y),W(e,t)};K(ne,e=>{V(o)&&e(A)});var re=z(ne,2),ie=e=>{var t=xv();q(t,21,()=>V(s),e=>e.id,(e,t)=>{var n=bv(),r=L(n,!0);j(n),B((e,i)=>{J(n,`title`,e),vi(n,1,`w-8 h-8 rounded border-2 shadow text-xs flex items-center justify-center transition-colors shrink-0 ${V(t).orphan?`border-red-600 text-white`:`border-yellow-500`}`),bi(n,`background:${i??``}`),G(r,V(t).orphan?`⚠`:`✎`)},[()=>V(t).orphan?`${Y(`annotation.orphan`)}\n\n${V(t).note}`:V(t).note,()=>w(V(t))]),H(`click`,n,e=>S(V(t).id,e)),Nr(`mouseenter`,n,e=>C(V(t).id,e)),Nr(`mouseleave`,n,_),W(e,n)}),j(t),W(e,t)};return K(re,e=>{V(s).length>0&&!X.markerHidden&&e(ie)}),W(e,D),Je(E)}Pr([`click`]);var wv=`#dc2626`,Tv=`#eab308`,Ev=`#16a34a`;function Dv(e){let t=Math.max(0,Math.min(1,e))*100;return t>80?Ev:t>=60?Tv:t>=40?`#f97316`:wv}function Ov(e){let t=Math.max(0,Math.min(1,e))*100;return t>=100?Ev:t<30?wv:t<60?`linear-gradient(to right, ${wv} 0%, ${wv} 60%, ${Tv} 100%)`:t<80?`linear-gradient(to right, ${wv} 0%, ${Tv} 40%, ${Tv} 100%)`:`linear-gradient(to right, ${Tv} 0%, ${Ev} 40%, ${Ev} 100%)`}var kv=new class{#e=P(null);get report(){return V(this.#e)}set report(e){F(this.#e,e,!0)}async load(e){if(!e)return this.report=null,null;try{let t=await fetch(`/api/metadata/${encodeURIComponent(e)}`);if(!t.ok)throw Error(t.statusText);this.report=await t.json()}catch{this.report=null}return this.report}async refresh(e){let t=await fetch(`/api/metadata/${encodeURIComponent(e)}/refresh`,{method:`POST`});if(!t.ok)throw Error(t.statusText);this.report=await t.json()}async addPath(e,t){let n=await fetch(`/api/metadata/${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||n.statusText)}this.report=await n.json()}async removePath(e,t){let n=await fetch(`/api/metadata/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})});if(!n.ok)throw Error(n.statusText);this.report=await n.json()}},Av=U(`<div data-testid="accuracy-gauge" class="no-print mt-5 flex items-center gap-3 mr-auto w-full sm:w-80 cursor-pointer select-none"><span class="text-xs text-gray-500 dark:text-gray-400 shrink-0"> </span> <div class="flex-1 h-4 rounded-full bg-gray-200 dark:bg-gray-700 overflow-hidden"><div class="h-full w-full transition-all"></div></div> <span data-testid="accuracy-gauge-value" class="text-xs font-semibold shrink-0 tabular-nums"> </span></div>`);function jv(e,t){qe(t,!0);let n=N(()=>kv.report),r=N(()=>V(n)?Math.round(V(n).accuracy*100):0),i=N(()=>V(n)?Y(`accuracy.tooltip`).replace(`{unchanged}`,String(V(n).unchanged)).replace(`{modified}`,String(V(n).modified)).replace(`{missing}`,String(V(n).missing)).replace(`{total}`,String(V(n).total)):``);var a=Wr(),o=R(a),s=e=>{var a=Av(),o=L(a),s=L(o,!0);j(o);var c=z(o,2),l=L(c);j(c);var u=z(c,2),d=L(u);j(u),j(a),B((e,t,n)=>{J(a,`title`,V(i)),G(s,e),bi(l,`background:${t??``}`),bi(u,`color:${n??``}`),G(d,`${V(r)??``}%`)},[()=>Y(`accuracy.label`),()=>Ov(V(n).accuracy),()=>Dv(V(n).accuracy)]),H(`click`,a,function(...e){t.onopen?.apply(this,e)}),W(e,a)};K(o,e=>{V(n)&&V(n).total>0&&e(s)}),W(e,a),Je()}Pr([`click`]);var Mv=/^(\s*(?:\*\*status:\*\*|status:)\s*).+?\s*$/im;function Nv(e){if(typeof e!=`string`)return null;let t=e.match(/^---\s*\n([\s\S]*?)\n---/);if(!t)return null;let n=t[1].match(/^\s*(?:\*\*status:\*\*|status:)\s*(.+?)\s*$/im);return n?n[1].trim():null}function Pv(e,t){return e.replace(Mv,`$1${t}`)}function Fv(e){return/%5BWORKLOG%5D/i.test(e)}var Iv=U(`<div data-testid="metadata-readonly-banner" class="text-xs text-amber-800 dark:text-amber-200 bg-amber-50 dark:bg-amber-900/30 border-l-4 border-amber-500 rounded-r px-3 py-2"> </div>`),Lv=U(`<div class="px-3 py-4 text-center text-xs text-gray-400"> </div>`),Rv=U(`<span class="inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300"><i class="fa-solid fa-check"></i> </span>`),zv=U(`<span class="inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300"><i class="fa-solid fa-triangle-exclamation"></i> </span>`),Bv=U(`<span class="inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300"><i class="fa-solid fa-circle-xmark"></i> </span>`),Vv=U(`<button class="metadata-row-remove text-xs px-2 py-1 rounded-lg border border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors"><i class="fa-solid fa-trash"></i></button>`),Hv=U(`<div class="flex items-center gap-2 px-3 py-2 border-b border-gray-100 dark:border-gray-800"><div class="flex-1 min-w-0"><div class="text-sm font-mono truncate text-gray-800 dark:text-gray-200"> </div></div> <!> <!></div>`),Uv=U(`<div class="flex items-center gap-2 flex-wrap"><button data-testid="metadata-add-btn" class="text-sm px-3 py-1.5 rounded-lg border border-blue-200 dark:border-blue-700 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 transition-colors"><i class="fa-solid fa-plus"></i> </button> <button data-testid="metadata-refresh-btn" 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"><i class="fa-solid fa-arrows-rotate"></i> </button></div>`),Wv=U(`<div class="px-3 py-2 text-xs text-gray-400"> </div>`),Gv=U(`<div class="px-3 py-2 text-xs text-red-500"> </div>`),Kv=U(`<button class="w-full text-left px-3 py-1.5 text-sm hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center gap-2"><i class="fa-solid fa-folder text-yellow-500"></i> <span class="truncate"> </span></button>`),qv=U(`<button class="w-full text-left px-3 py-1.5 text-sm hover:bg-blue-50 dark:hover:bg-blue-900/30 flex items-center gap-2"><i class="fa-solid fa-file text-gray-400"></i> <span class="truncate"> </span> <i class="fa-solid fa-plus ml-auto text-blue-500 text-xs"></i></button>`),Jv=U(`<!> <!>`,1),Yv=U(`<div class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden text-sm"><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"> </button> <span class="text-xs text-gray-500 dark:text-gray-400 font-mono truncate flex-1"> </span></div> <div class="max-h-56 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800"><!></div></div>`),Xv=U(`<p class="text-xs text-red-500"> </p>`),Zv=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div data-testid="metadata-modal" class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-2xl mx-4 p-6 space-y-4"><div class="flex items-start justify-between gap-4"><div><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"><i class="fa-solid fa-code-compare mr-1"></i> </h3> <p class="text-xs text-gray-500 dark:text-gray-400 mt-1"> </p></div> <button class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 transition-colors"><i class="fa-solid fa-xmark text-lg"></i></button></div> <div class="text-xs text-gray-600 dark:text-gray-300 bg-gray-50 dark:bg-gray-800 rounded-lg px-3 py-2"></div> <!> <div data-testid="metadata-list" class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden"><div class="max-h-64 overflow-y-auto"><!></div></div> <!> <!> <!> <div class="flex justify-end"><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></div></div></div>`);function Qv(e,t){qe(t,!0);let n=N(()=>kv.report),r=N(()=>Nv(t.content)===`SuperSeeded`),i=P(``),a=P(!1),o=P(!1),s=P(``),c=P(null),l=P(I([])),u=P(I([])),d=P(!1),f=P(``);kn(()=>{t.open||(F(o,!1),F(s,``),F(i,``))});function p(e){F(i,Y(`common.error_prefix`)+e),setTimeout(()=>{F(i,``)},5e3)}function m(){return!V(n)||V(n).total===0?``:`<span class="font-semibold">${Math.round(V(n).accuracy*100)}%</span> · ${V(n).unchanged}/${V(n).total} ${Y(`metadata.status.unchanged`)} · ${V(n).modified} ${Y(`metadata.status.modified`)} · ${V(n).missing} ${Y(`metadata.status.missing`)}`}async function h(){F(a,!0);try{await kv.refresh(t.docId)}catch(e){p(e instanceof Error?e.message:String(e))}finally{F(a,!1)}}async function g(e){try{await kv.removePath(t.docId,e),V(o)&&y(V(s))}catch(e){p(e instanceof Error?e.message:String(e))}}async function _(e){try{await kv.addPath(t.docId,e),V(o)&&y(V(s))}catch(e){p(e instanceof Error?e.message:String(e))}}function v(){F(o,!V(o)),V(o)&&y(``)}async function y(e){F(d,!0),F(f,``);try{let t=await fetch(`/api/browse-source?path=`+encodeURIComponent(e||``));if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||t.statusText)}let r=await t.json();F(s,r.current||``,!0),F(c,r.parent,!0),F(l,r.dirs||[],!0);let i=new Set((V(n)?.items||[]).map(e=>e.path));F(u,(r.files||[]).filter(e=>!i.has(e.path)),!0)}catch(e){F(f,e instanceof Error?e.message:String(e),!0)}finally{F(d,!1)}}function b(){V(c)!==null&&y(V(c))}var x=Wr(),S=R(x),C=e=>{var p=Zv(),x=L(p),S=L(x),C=L(S),w=L(C),T=z(L(w));j(w);var E=z(w,2),D=L(E,!0);j(E),j(C);var ee=z(C,2);j(S);var te=z(S,2);si(te,m,!0),j(te);var O=z(te,2),k=e=>{var t=Iv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`metadata.readonly_banner`)]),W(e,t)};K(O,e=>{V(r)&&e(k)});var ne=z(O,2),A=L(ne),re=L(A),ie=e=>{var t=Lv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`metadata.empty`)]),W(e,t)},ae=e=>{var t=Wr();q(R(t),17,()=>V(n).items,e=>e.path,(e,t)=>{var n=Hv(),i=L(n),a=L(i),o=L(a,!0);j(a),j(i);var s=z(i,2),c=e=>{var t=Rv(),n=z(L(t));j(t),B(e=>G(n,` ${e??``}`),[()=>Y(`metadata.status.unchanged`)]),W(e,t)},l=e=>{var t=zv(),n=z(L(t));j(t),B(e=>G(n,` ${e??``}`),[()=>Y(`metadata.status.modified`)]),W(e,t)},u=e=>{var t=Bv(),n=z(L(t));j(t),B(e=>G(n,` ${e??``}`),[()=>Y(`metadata.status.missing`)]),W(e,t)};K(s,e=>{V(t).status===`unchanged`?e(c):V(t).status===`modified`?e(l,1):e(u,-1)});var d=z(s,2),f=e=>{var n=Vv();B(e=>J(n,`title`,e),[()=>Y(`metadata.remove`)]),H(`click`,n,()=>g(V(t).path)),W(e,n)};K(d,e=>{V(r)||e(f)}),j(n),B(()=>{J(a,`title`,V(t).path),G(o,V(t).path)}),W(e,n)}),W(e,t)};K(re,e=>{!V(n)||V(n).items.length===0?e(ie):e(ae,-1)}),j(A),j(ne);var oe=z(ne,2),se=e=>{var t=Uv(),n=L(t),r=z(L(n));j(n);var i=z(n,2),o=z(L(i));j(i),j(t),B((e,t)=>{G(r,` ${e??``}`),i.disabled=V(a),G(o,` ${t??``}`)},[()=>Y(`metadata.add`),()=>Y(`metadata.refresh`)]),H(`click`,n,v),H(`click`,i,h),W(e,t)};K(oe,e=>{V(r)||e(se)});var ce=z(oe,2),le=e=>{var t=Yv(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n);var p=z(n,2),m=L(p),h=e=>{var t=Wv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},g=e=>{var t=Gv(),n=L(t,!0);j(t),B(()=>G(n,V(f))),W(e,t)},v=e=>{var t=Wv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.empty_dir`)]),W(e,t)},x=e=>{var t=Jv(),n=R(t);q(n,17,()=>V(l),e=>e.path,(e,t)=>{var n=Kv(),r=z(L(n),2),i=L(r,!0);j(r),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>y(V(t).path)),W(e,n)}),q(z(n,2),17,()=>V(u),e=>e.path,(e,t)=>{var n=qv(),r=z(L(n),2),i=L(r,!0);j(r),Ie(2),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>_(V(t).path)),W(e,n)}),W(e,t)};K(m,e=>{V(d)?e(h):V(f)?e(g,1):V(l).length===0&&V(u).length===0?e(v,2):e(x,-1)}),j(p),j(t),B(e=>{r.disabled=V(c)===null,G(i,e),G(o,V(s)?`/`+V(s):`/ (sourceRoot)`)},[()=>Y(`common.up`)]),H(`click`,r,b),W(e,t)};K(ce,e=>{V(o)&&e(le)});var ue=z(ce,2),de=e=>{var t=Xv(),n=L(t,!0);j(t),B(()=>G(n,V(i))),W(e,t)};K(ue,e=>{V(i)&&e(de)});var fe=z(ue,2),pe=L(fe),me=L(pe,!0);j(pe),j(fe),j(x),j(p),B((e,t,n,r)=>{G(T,` ${e??``}`),G(D,t),J(ee,`title`,n),G(me,r)},[()=>Y(`metadata.title`),()=>Y(`metadata.subtitle`),()=>Y(`common.close`),()=>Y(`common.close`)]),H(`click`,p,e=>{e.target===e.currentTarget&&t.onclose()}),H(`click`,ee,function(...e){t.onclose?.apply(this,e)}),H(`click`,pe,function(...e){t.onclose?.apply(this,e)}),W(e,p)};K(S,e=>{t.open&&e(C)}),W(e,x),Je()}Pr([`click`]);var $v=U(`<div class="text-xs font-medium text-amber-700 dark:text-amber-300"> </div>`),ey=U(`<div> </div>`),ty=U(`<button type="button"><div class="flex items-center gap-2 font-semibold text-gray-800 dark:text-gray-100"><span class="font-mono text-blue-600 dark:text-blue-400"> </span> <span class="truncate"> </span></div> <div class="mt-1 text-gray-500 dark:text-gray-400"> </div></button>`),ny=U(`<div class="mt-3 flex gap-2 overflow-x-auto pb-1"></div>`),ry=U(`<p class="mt-3 text-sm text-gray-500 dark:text-gray-400"> </p>`),iy=U(`<div class="flex h-full items-center justify-center text-sm text-gray-500 dark:text-gray-400"> </div>`),ay=U(`<div class="m-5 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-950/30 dark:text-red-300"> </div>`),oy=U(`<div class="mx-5 mt-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-2 text-sm text-amber-800 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-200"> </div>`),sy=U(`<button type="button" class="mt-0.5 inline-flex h-7 w-8 items-center justify-center rounded-md border border-blue-200 bg-white font-mono text-sm font-bold text-blue-600 transition-colors hover:bg-blue-50 disabled:cursor-wait disabled:opacity-50 dark:border-blue-800 dark:bg-gray-950 dark:text-blue-300 dark:hover:bg-blue-950/40"> </button>`),cy=U(`<div><span> </span> <pre class="m-0 whitespace-pre-wrap break-words px-2 py-0.5 font-mono"> </pre></div> <div class="flex items-start justify-center border-r border-gray-200 bg-gray-50 px-1 py-0.5 dark:border-gray-800 dark:bg-gray-900/70"><!></div> <div><span> </span> <pre class="m-0 whitespace-pre-wrap break-words px-2 py-0.5 font-mono"> </pre></div>`,1),ly=U(`<!> <div class="h-full overflow-auto p-5"><div class="grid min-w-[980px] grid-cols-[minmax(0,1fr)_3.25rem_minmax(0,1fr)] overflow-hidden rounded-lg border border-gray-200 text-xs dark:border-gray-800"><div class="border-b border-r border-gray-200 bg-gray-100 px-3 py-2 font-semibold text-gray-700 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-200"> </div> <div class="border-b border-r border-gray-200 bg-gray-100 px-2 py-2 text-center font-semibold text-gray-400 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-500"></div> <div class="border-b border-gray-200 bg-gray-100 px-3 py-2 font-semibold text-gray-700 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-200"> </div> <!></div></div>`,1),uy=U(`<div data-testid="versions-modal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4"><div class="flex h-[90vh] w-full max-w-7xl flex-col overflow-hidden rounded-xl border border-gray-200 bg-white shadow-2xl dark:border-gray-700 dark:bg-gray-950"><header class="flex shrink-0 items-start justify-between gap-4 border-b border-gray-200 px-5 py-4 dark:border-gray-800"><div><h2 class="text-lg font-semibold text-gray-900 dark:text-gray-50"><i class="fa-solid fa-code-branch mr-2"></i> </h2> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400"> </p></div> <button type="button" class="rounded-lg border border-gray-200 px-3 py-1.5 text-sm text-gray-600 transition-colors hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800"><i class="fa-solid fa-xmark"></i></button></header> <div class="shrink-0 border-b border-gray-200 px-5 py-3 dark:border-gray-800"><div class="flex flex-wrap items-end gap-3"><label class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400"> <input type="number" class="mt-1 block w-28 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm text-gray-800 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100"/></label> <button type="button" class="rounded-lg bg-blue-600 px-3 py-1.5 text-sm font-semibold text-white transition-colors hover:bg-blue-700 disabled:opacity-50"><i class="fa-solid fa-arrows-rotate mr-1"></i> </button> <button type="button" class="rounded-lg bg-green-600 px-3 py-1.5 text-sm font-semibold text-white transition-colors hover:bg-green-700 disabled:cursor-not-allowed disabled:opacity-50"><i class="fa-solid fa-floppy-disk mr-1"></i> </button> <div class="text-xs text-gray-500 dark:text-gray-400"> </div> <!> <!></div> <!></div> <section class="min-h-0 flex-1 overflow-hidden"><!></section></div></div>`);function dy(e,t){qe(t,!0);let n=3650,r=P(30),i=P(30),a=P(!1),o=P(``),s=P(null),c=P(null),l=P(null),u=P(``),d=``,f=P(``),p=P(!1),m=N(()=>V(l)?.headContent??t.content),h=N(()=>V(f)),g=N(()=>V(f)!==V(m)),_=N(()=>T(V(l)?.baseContent??``,V(h))),v=N(()=>V(_).rows),y=N(()=>V(l)?.baseContent!==null&&V(l)?.baseContent!==void 0);kn(()=>{t.docId,F(f,t.content,!0)});function b(e){return Number.isFinite(e)?Math.max(1,Math.min(n,Math.floor(e))):30}function x(e){return e.length?e.replace(/\r\n/g,`
|
|
99
|
+
<a href="${O(s)}" target="_blank" rel="noopener" class="mcp-saved-link">📄 ${O(a)}</a>`})}catch(n){f(e,t,{running:!1,error:n.message||String(n),resultHtml:``})}}async function te(e){let n=V(e===`tool`?o:s);if(!n.length)return;F(c,!0);let r=n.length;try{for(let i=0;i<n.length;i++)t.onStatus(Y(`context.mcp_running_all`).replace(`{current}`,String(i+1)).replace(`{total}`,String(r))),await ee(e,n[i].name);t.onStatus(Y(`context.mcp_done_all`).replace(`{total}`,String(r)))}finally{F(c,!1)}}function O(e){return String(e??``).replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e])}async function k(){try{let e=await fetch(`/mcp`);if(!e.ok)throw Error(await e.text());let t=await e.json(),c=Array.isArray(t.tools)?t.tools:[],l=Array.isArray(t.prompts)?t.prompts:[];F(n,Y(`context.mcp_available`),!0),F(r,!0),F(i,t.transport||`-`,!0),F(a,t.endpoint||`POST /mcp`,!0),F(o,c,!0),F(s,l,!0),c.forEach(m),l.forEach(h)}catch{F(n,Y(`context.mcp_unavailable`),!0),F(r,!1),F(i,`-`),F(a,`/mcp`),F(o,[],!0),F(s,[],!0)}}var ne={load:k},A=A_(),re=L(A),ie=L(re),ae=L(ie,!0);j(ie);var oe=z(ie,2),se=L(oe,!0);j(oe),j(re);var ce=z(re,2),le=L(ce,!0);j(ce);var ue=z(ce,2),de=L(ue),fe=L(de),pe=L(fe,!0);j(fe);var me=z(fe,2),he=L(me,!0);j(me),j(de);var ge=z(de,2),_e=L(ge),ve=L(_e,!0);j(_e);var ye=z(_e,2),be=L(ye,!0);j(ye),j(ge);var xe=z(ge,2),Se=L(xe),Ce=L(Se,!0);j(Se);var we=z(Se,2),Te=L(we,!0);j(we),j(xe),j(ue);var Ee=z(ue,2),De=L(Ee),Oe=L(De),ke=L(Oe,!0);j(Oe);var Ae=z(Oe,2),je=L(Ae),Me=L(je,!0);j(je);var Ne=z(je,2),Pe=L(Ne,!0);j(Ne),j(Ae),j(De);var Fe=z(De,2),Ie=L(Fe),Le=e=>{var t=S_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.mcp_no_tools`)]),W(e,t)},Re=e=>{var t=Wr();q(R(t),17,()=>V(o),Qr,(e,t)=>{let n=N(()=>V(l).get(V(t).name)??{argsJson:`{}`,running:!1,error:``,resultHtml:``});var r=E_(),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=e=>{var n=C_(),r=L(n,!0);j(n),B(()=>G(r,V(t).description)),W(e,n)};K(o,e=>{V(t).description&&e(s)});var c=z(o,2),u=e=>{var n=w_(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n),B((e,t)=>{G(i,e),G(o,t)},[()=>Y(`context.mcp_input_schema`),()=>JSON.stringify(V(t).inputSchema,null,2)]),W(e,n)};K(c,e=>{V(t).inputSchema&&e(u)});var d=z(c,2),p=L(d),m=L(p,!0);j(p);var h=z(p,2);yn(h);var g=z(h,2),_=L(g),v=L(_,!0);j(_);var y=z(_,2),b=L(y,!0);j(y),j(g);var x=z(g,2),S=e=>{var t=T_();si(t,()=>V(n).resultHtml,!0),j(t),W(e,t)};K(x,e=>{V(n).resultHtml&&e(S)}),j(d),j(r),B((e,r)=>{G(a,V(t).name),G(m,e),Ai(h,V(n).argsJson),G(v,V(n).error),y.disabled=V(n).running,G(b,r)},[()=>Y(`context.mcp_request_json`),()=>Y(`context.mcp_run_tool`)]),H(`input`,h,e=>f(`tool`,V(t).name,{argsJson:e.target.value})),H(`click`,y,()=>ee(`tool`,V(t).name)),W(e,r)}),W(e,t)};K(Ie,e=>{V(o).length?e(Re,-1):e(Le)}),j(Fe),j(Ee);var ze=z(Ee,2),Be=L(ze),Ve=L(Be),He=L(Ve,!0);j(Ve);var Ue=z(Ve,2),We=L(Ue),Ge=L(We,!0);j(We);var Ke=z(We,2),Ye=L(Ke,!0);j(Ke),j(Ue),j(Be);var Xe=z(Be,2),Ze=L(Xe),Qe=e=>{var t=S_(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`context.mcp_no_prompts`)]),W(e,t)},$e=e=>{var t=Wr();q(R(t),17,()=>V(s),Qr,(e,t)=>{let n=N(()=>V(u).get(V(t).name)??{argsJson:`{}`,running:!1,error:``,resultHtml:``});var r=E_(),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=e=>{var n=C_(),r=L(n,!0);j(n),B(()=>G(r,V(t).description)),W(e,n)};K(o,e=>{V(t).description&&e(s)});var c=z(o,2),l=e=>{var n=k_(),r=L(n),i=L(r,!0);j(r);var a=z(r,2);q(a,21,()=>V(t).arguments,Qr,(e,t)=>{var n=O_(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var c=z(r,2),l=e=>{var n=D_(),r=L(n,!0);j(n),B(()=>G(r,V(t).description)),W(e,n)};K(c,e=>{V(t).description&&e(l)}),j(n),B(e=>{G(a,V(t).name),G(s,e)},[()=>V(t).required?Y(`context.mcp_required`):Y(`context.mcp_optional`)]),W(e,n)}),j(a),j(n),B(e=>G(i,e),[()=>Y(`context.mcp_arguments`)]),W(e,n)};K(c,e=>{V(t).arguments?.length&&e(l)});var d=z(c,2),p=L(d),m=L(p,!0);j(p);var h=z(p,2);yn(h);var g=z(h,2),_=L(g),v=L(_,!0);j(_);var y=z(_,2),b=L(y,!0);j(y),j(g);var x=z(g,2),S=e=>{var t=T_();si(t,()=>V(n).resultHtml,!0),j(t),W(e,t)};K(x,e=>{V(n).resultHtml&&e(S)}),j(d),j(r),B((e,r)=>{G(a,V(t).name),G(m,e),Ai(h,V(n).argsJson),G(v,V(n).error),y.disabled=V(n).running,G(b,r)},[()=>Y(`context.mcp_request_json`),()=>Y(`context.mcp_get_prompt`)]),H(`input`,h,e=>f(`prompt`,V(t).name,{argsJson:e.target.value})),H(`click`,y,()=>ee(`prompt`,V(t).name)),W(e,r)}),W(e,t)};return K(Ze,e=>{V(s).length?e($e,-1):e(Qe)}),j(Xe),j(ze),j(A),B((e,t,l,u,d,f,p,m,h,g)=>{G(ae,e),G(se,t),G(le,l),G(pe,u),vi(me,1,fi(V(r)?`mcp-info-value ok`:`mcp-info-value err`),`svelte-1ui2b6s`),G(he,V(n)),G(ve,d),G(be,V(i)),G(Ce,f),G(Te,V(a)),G(ke,p),G(Me,V(o).length),Ne.disabled=V(c)||!V(o).length,G(Pe,m),G(He,h),G(Ge,V(s).length),Ke.disabled=V(c)||!V(s).length,G(Ye,g)},[()=>Y(`context.mcp_title`),()=>Y(`context.mcp_refresh`),()=>Y(`context.mcp_intro`),()=>Y(`context.mcp_status`),()=>Y(`context.mcp_transport`),()=>Y(`context.mcp_endpoint`),()=>Y(`context.mcp_tools`),()=>Y(`context.mcp_run_all_tools`),()=>Y(`context.mcp_prompts`),()=>Y(`context.mcp_get_all_prompts`)]),H(`click`,oe,k),H(`click`,Ne,()=>te(`tool`)),H(`click`,Ke,()=>te(`prompt`)),W(e,A),Je(ne)}Pr([`click`,`input`]);var M_=U(`<p class="status-text svelte-rpj1e5"> </p>`),N_=U(`<div class="app-shell"><!> <main class="context-scroll svelte-rpj1e5"><div class="context-inner svelte-rpj1e5"><section class="page-intro svelte-rpj1e5"><h2 class="page-title svelte-rpj1e5"> </h2> <p class="page-desc svelte-rpj1e5"> </p> <!></section> <!> <!> <!></div></main></div> <!>`,1);function P_(e,t){qe(t,!0);let n=P(``),r=P(I([])),i=P(I([])),a=P(``),o=P(null),s=P(null),c=P(null);function l(e){F(n,e,!0)}async function u(){l(Y(`context.loading`));let e=await fetch(`/api/context/orientation`);if(!e.ok)throw Error(await e.text());let t=await e.json();F(o,t,!0),F(r,t.instructions||[],!0),F(i,t.rules||[],!0),F(a,t.rulesFolder||``,!0),l(``)}async function d(e){l(Y(`context.adding_instruction_file`));let t=await fetch(`/api/context/instructions`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})});if(!t.ok)throw Error(await t.text());await u()}async function f(e){if(!await V(s).show({kicker:Y(`context.remove_instruction_title`),title:Y(`context.remove_instruction_title`),message:Y(`context.remove_instruction_message`).replace(`{name}`,e),confirmLabel:Y(`common.remove`),cancelLabel:Y(`common.cancel`)||`Cancel`,danger:!0}))return;l(Y(`context.removing_instruction_file`));let t=await fetch(`/api/context/instructions/`+encodeURIComponent(e),{method:`DELETE`});if(!t.ok)throw Error(await t.text());await u()}async function p(e){l(Y(`context.saving_rule`));let t=await fetch(`/api/context/rules`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await t.text());await u()}Ji(async()=>{try{let e=await fetch(`/api/config`);await Sa((e.ok?await e.json():{}).language||`en`)}catch{await Sa(`en`)}document.title=Y(`context.title`),await u().catch(e=>l(e.message)),await V(c).load().catch(()=>{})});var m=N_(),h=R(m),g=L(h);Xo(g,{get navigate(){return t.navigate}});var _=z(g,2),v=L(_),y=L(v),b=L(y),x=L(b,!0);j(b);var S=z(b,2),C=L(S,!0);j(S);var w=z(S,2),T=e=>{var t=M_(),r=L(t,!0);j(t),B(()=>G(r,V(n))),W(e,t)};K(w,e=>{V(n)&&e(T)}),j(y);var E=z(y,2);p_(E,{onAdd:d,onRemove:f,get items(){return V(r)},set items(e){F(r,e,!0)}});var D=z(E,2);x_(D,{get rules(){return V(i)},get rulesFolder(){return V(a)},onAdd:p}),Ui(j_(z(D,2),{onStatus:l}),e=>F(c,e,!0),()=>V(c)),j(v),j(_),j(h),Ui(Xd(z(h,2),{}),e=>F(s,e,!0),()=>V(s)),B((e,t)=>{G(x,e),G(C,t)},[()=>Y(`context.orientation_title`),()=>Y(`context.orientation_intro`)]),W(e,m),Je()}async function F_(){return fetch(`/api/config`).then(e=>e.json())}async function I_(){return fetch(`/api/documents`).then(e=>e.json())}async function L_(e){return fetch(`/api/browse/alldirs?path=${encodeURIComponent(e)}`).then(e=>e.json())}async function R_(e){let t=await fetch(`/api/documents/${e}`);if(!t.ok)throw Error(t.statusText);return t.json()}async function z_(){try{let e=await fetch(`/api/annotations`).then(e=>e.json()),t={};for(let[n,r]of Object.entries(e||{})){t[n]=r;try{t[encodeURIComponent(n)]=r}catch{}}return t}catch{return{}}}async function B_(){try{return await fetch(`/api/documents/file-counts`).then(e=>e.json())}catch{return{}}}async function V_(){try{return await fetch(`/api/documents/statuses`).then(e=>e.json())}catch{return{}}}async function H_(e){return fetch(`/api/documents/search?q=${encodeURIComponent(e)}`).then(e=>e.json())}function U_(e){return((e.filename||``).split(`/`).pop()??``).match(/^(\d{4}_\d{2}_\d{2}(?:_\d{2}_\d{2})?)/)?.[1]??``}function W_(e){return e===`alphabetical`?(e,t)=>(e.title||e.filename||``).localeCompare(t.title||t.filename||``):(t,n)=>{let r=U_(t),i=U_(n);return r&&i?e===`oldest`?r.localeCompare(i):i.localeCompare(r):r?-1:i?1:(t.filename||``).localeCompare(n.filename||``)}}function G_(e,t){for(let n of Object.values(e.categories))n.sort(t);for(let n of Object.values(e.children))G_(n,t)}function K_(e,t,n,r=`recent`){let i={categories:{},children:{}};for(let t of e){let e=i;for(let n of t.folder||[])e.children[n]||(e.children[n]={categories:{},children:{}}),e=e.children[n];e.categories[t.category]||(e.categories[t.category]=[]),e.categories[t.category].push(t)}if(n)for(let e of t){let t=e.split(`/`).filter(Boolean),n=i;for(let e of t)n.children[e]||(n.children[e]={categories:{},children:{}}),n=n.children[e]}return G_(i,W_(r)),i}function q_(e){let t=Object.values(e.categories).reduce((e,t)=>e+t.length,0);for(let n of Object.values(e.children))t+=q_(n);return t}function J_(e,t){let n=0;for(let r of Object.values(e.categories))for(let e of r)t[e.id]>0&&(n+=1);for(let r of Object.values(e.children))n+=J_(r,t);return n}function Y_(e,t){let n=0;for(let r of Object.values(e.categories))for(let e of r)t[e.id]>0&&(n+=1);for(let r of Object.values(e.children))n+=Y_(r,t);return n}function X_(e){return e.replace(/^\d+_/,``).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Z_(e){return Object.keys(e.children).sort((e,t)=>e.localeCompare(t))}function Q_(e){return Object.keys(e.categories).filter(e=>e!==`General`).sort((e,t)=>e.localeCompare(t))}function $_(e,t=`recent`){return Object.values(e.categories).flat().sort(W_(t))}var ev=U(`<span class="inline-flex items-center justify-center w-5 h-5 rounded-full bg-green-500 text-[10px] font-bold text-white border border-green-600 shadow-sm">V</span>`),tv=U(`<span class="inline-flex items-center justify-center w-5 h-5 rounded-full bg-orange-500 text-[10px] font-bold text-white border border-orange-600 shadow-sm">S</span>`),nv=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-yellow-300 dark:bg-yellow-400 text-[10px] font-bold text-yellow-900 border border-yellow-500 shadow-sm"> </span>`),rv=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-sky-200 dark:bg-sky-300 text-[10px] font-bold text-sky-900 border border-sky-500 shadow-sm"> </span>`),iv=U(`<div class="text-xs text-gray-400 dark:text-gray-500 mt-0.5"> </div>`),av=U(`<button><div class="leading-snug flex items-center justify-between gap-2"><span class="truncate"> </span> <span class="flex items-center gap-1 shrink-0"><!> <!> <!></span></div> <!></button>`),ov=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-orange-400 dark:bg-orange-500 text-[10px] font-bold text-white border border-orange-600 shadow-sm"> </span>`),sv=U(`<span class="inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-slate-400 dark:bg-slate-500 text-[10px] font-bold text-white border border-slate-600 shadow-sm"> </span>`),cv=U(`<div class="pl-2"></div>`),lv=U(`<div class="mb-0.5"><button class="w-full flex items-center justify-between px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider hover:bg-gray-50 dark:hover:bg-gray-800/60 rounded-md transition-colors"><span class="flex items-center gap-2"><span> </span> <!> <!></span> <span class="flex items-center gap-1.5"><span class="font-normal normal-case text-gray-400"> </span> <span>▸</span></span></button> <!></div>`),uv=U(`<div class="pl-3"><!></div>`),dv=U(`<div class="mb-1"><button class="w-full flex items-center justify-between px-3 py-1.5 text-xs font-semibold text-violet-600 dark:text-violet-400 uppercase tracking-wider hover:bg-gray-50 dark:hover:bg-gray-800/60 rounded-md transition-colors"><span class="flex items-center gap-2 min-w-0"><span class="truncate"> </span> <!> <!></span> <span class="flex items-center gap-1.5"><span class="font-normal normal-case text-gray-400"> </span> <span>▸</span></span></button> <!></div>`),fv=U(`<!> <!>`,1),pv=U(`<!> <!> <!>`,1);function mv(e,t){qe(t,!0);let n=(e,n=f)=>{let r=N(()=>X.annotationCounts[n().id]||0),i=N(()=>X.fileAttachmentCounts[n().id]||0),a=N(()=>c(n()));var o=av(),l=L(o),u=L(l),d=L(u,!0);j(u);var p=z(u,2),m=L(p),h=e=>{var t=ev();B(e=>J(t,`title`,e),[()=>Y(`sidebar.status_to_validate`)]),W(e,t)},g=e=>{var t=tv();B(e=>J(t,`title`,e),[()=>Y(`sidebar.status_superseeded`)]),W(e,t)};K(m,e=>{V(a)===`V`?e(h):V(a)===`S`&&e(g,1)});var _=z(m,2),v=e=>{var t=nv(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(r))},[()=>s(V(r),`sidebar.annotation_badge`)]),W(e,t)};K(_,e=>{V(r)>0&&!X.markerHidden&&e(v)});var y=z(_,2),b=e=>{var t=rv(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(i))},[()=>s(V(i),`sidebar.file_attachment_badge`)]),W(e,t)};K(y,e=>{V(i)>0&&!X.hideAttachments&&e(b)}),j(p),j(l);var x=z(l,2),S=e=>{var t=iv(),r=L(t,!0);j(t),B(()=>G(r,n().formattedDate)),W(e,t)};K(x,e=>{n().formattedDate&&e(S)}),j(o),B(()=>{J(o,`id`,`item-${n().id??``}`),vi(o,1,`doc-item w-full text-left px-3 py-1.5 rounded-md text-sm transition-colors text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800/60 ${n().id===X.currentDocId?`active`:``}`),G(d,n().title)}),H(`click`,o,()=>t.onopen(n().id)),W(e,o)},r=(e,r=f)=>{let i=N(()=>a(r())),o=N(()=>X.expandedCategories.has(V(i))),c=N(()=>t.node.categories[r()]),l=N(()=>V(c).reduce((e,t)=>e+ +(X.annotationCounts[t.id]>0),0)),u=N(()=>V(c).reduce((e,t)=>e+ +(X.fileAttachmentCounts[t.id]>0),0));var d=lv(),p=L(d),m=L(p),h=L(m),g=L(h,!0);j(h);var _=z(h,2),v=e=>{var t=ov(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(l))},[()=>s(V(l),`sidebar.annotated_docs_badge`)]),W(e,t)};K(_,e=>{V(l)>0&&!X.markerHidden&&e(v)});var y=z(_,2),b=e=>{var t=sv(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(u))},[()=>s(V(u),`sidebar.file_attached_docs_badge`)]),W(e,t)};K(y,e=>{V(u)>0&&!X.hideAttachments&&e(b)}),j(m);var x=z(m,2),S=L(x),C=L(S,!0);j(S);var w=z(S,2);j(x),j(p);var T=z(p,2),E=e=>{var t=cv();q(t,21,()=>V(c),e=>e.id,(e,t)=>{n(e,()=>V(t))}),j(t),W(e,t)};K(T,e=>{V(o)&&e(E)}),j(d),B(()=>{G(g,r()),G(C,V(c).length),vi(w,1,`transition-transform duration-200 ${V(o)?`rotate-90`:``}`)}),H(`click`,p,()=>X.toggleCategory(V(i))),W(e,d)},i=(e,n=f)=>{let r=N(()=>o(n())),i=N(()=>X.expandedFolders.has(V(r))),a=N(()=>t.node.children[n()]),c=N(()=>q_(V(a))),l=N(()=>J_(V(a),X.annotationCounts)),u=N(()=>Y_(V(a),X.fileAttachmentCounts));var d=dv(),p=L(d),m=L(p),h=L(m),g=L(h);j(h);var _=z(h,2),v=e=>{var t=ov(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(l))},[()=>s(V(l),`sidebar.annotated_docs_badge`)]),W(e,t)};K(_,e=>{V(l)>0&&!X.markerHidden&&e(v)});var y=z(_,2),b=e=>{var t=sv(),n=L(t,!0);j(t),B(e=>{J(t,`title`,e),G(n,V(u))},[()=>s(V(u),`sidebar.file_attached_docs_badge`)]),W(e,t)};K(y,e=>{V(u)>0&&!X.hideAttachments&&e(b)}),j(m);var x=z(m,2),S=L(x),C=L(S,!0);j(S);var w=z(S,2);j(x),j(p);var T=z(p,2),E=e=>{var r=uv(),i=L(r);{let e=N(()=>[...t.folderPath,n()]);mv(i,{get node(){return V(a)},get folderPath(){return V(e)},get onopen(){return t.onopen}})}j(r),W(e,r)};K(T,e=>{V(i)&&e(E)}),j(d),B(e=>{J(h,`title`,n()),G(g,`📁 ${e??``}`),G(C,V(c)),vi(w,1,`transition-transform duration-200 ${V(i)?`rotate-90`:``}`)},[()=>X_(n())]),H(`click`,p,()=>X.toggleFolder(V(r))),W(e,d)};function a(e){return[...t.folderPath,e].join(`|`)}function o(e){return[...t.folderPath,e].join(`|`)}function s(e,t){return`${e} ${Y(t)}${e>1?`s`:``}`}function c(e){if(!X.highlightStatusState)return null;let t=String(X.docStatuses[e.id]||``).trim().toLowerCase();return t===`to be validated`?`V`:X.highlightStatusState===2&&t===`superseeded`?`S`:null}var l=Wr(),u=R(l),d=e=>{var r=fv(),a=R(r);q(a,17,()=>$_(t.node,X.sidebarSort),e=>e.id,(e,t)=>{n(e,()=>V(t))}),q(z(a,2),16,()=>Z_(t.node),e=>e,(e,t)=>{i(e,()=>t)}),W(e,r)},p=e=>{var n=pv(),a=R(n),o=e=>{r(e,()=>`General`)};K(a,e=>{t.node.categories.General&&e(o)});var s=z(a,2);q(s,16,()=>Z_(t.node),e=>e,(e,t)=>{i(e,()=>t)}),q(z(s,2),16,()=>Q_(t.node),e=>e,(e,t)=>{r(e,()=>t)}),W(e,n)};K(u,e=>{X.hideCategories?e(d):e(p,-1)}),W(e,l),Je()}Pr([`click`]);var hv=U(`<p class="px-4 py-8 text-sm text-gray-400 text-center"> </p>`),gv=U(`<aside><div class="sticky top-0 z-10 bg-white dark:bg-gray-900 p-3 border-b border-gray-100 dark:border-gray-800"><div class="relative sm:hidden"><input type="search" class="w-full 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> <div class="flex items-center justify-between mt-2 sm:mt-0"><p class="text-xs text-gray-400 dark:text-gray-500"> </p> <div class="flex items-center gap-2"><button><i class="fa-solid fa-certificate"></i></button> <button><i class="fa-solid fa-paperclip"></i></button> <button><i class="fa-solid fa-tags"></i></button> <button class="text-gray-400 hover:text-blue-500 dark:text-gray-500 dark:hover:text-blue-400 transition-colors leading-none"><i class="fa-solid fa-file-export"></i></button> <button class="text-gray-400 hover:text-blue-500 dark:text-gray-500 dark:hover:text-blue-400 transition-colors leading-none"><i class="fa-solid fa-folder-plus"></i></button> <button class="text-gray-400 hover:text-blue-500 dark:text-gray-500 dark:hover:text-blue-400 transition-colors leading-none"><i class="fa-solid fa-file-circle-plus"></i></button></div></div></div> <nav data-testid="category-tree" class="flex-1 py-2 space-y-0.5"><!></nav> <div aria-hidden="true"></div></aside>`);function _v(e,t){qe(t,!0);let n=N(()=>K_(X.filteredDocs,X.allFolderPaths,!X.searchQuery,X.sidebarSort)),r=N(()=>X.filteredDocs.length),i=N(()=>X.filteredDocs.length===0&&X.allFolderPaths.length===0),a=`ld-sidebar-w`,o=P(null),s=P(!1),c=P(null);kn(()=>{let e=parseInt(localStorage.getItem(a)||``,10);Number.isFinite(e)&&F(o,Math.max(200,Math.min(600,e)),!0)});function l(e){e.preventDefault();let t=e.clientX,n=V(c).getBoundingClientRect().width;F(s,!0),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let r=e=>{F(o,Math.max(200,Math.min(600,n+e.clientX-t)),!0)},i=()=>{if(document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i),document.body.style.cursor=``,document.body.style.userSelect=``,F(s,!1),V(o)!=null)try{localStorage.setItem(a,String(V(o)))}catch{}};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)}var u=gv(),d=L(u),f=L(d),p=L(f);ki(p),Ie(2),j(f);var m=z(f,2),h=L(m),g=L(h);j(h);var _=z(h,2),v=L(_),y=z(v,2),b=z(y,2),x=z(b,2),S=z(x,2),C=z(S,2);j(_),j(m),j(d);var w=z(d,2),T=L(w),E=e=>{var t=hv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`sidebar.no_docs`)]),W(e,t)},D=e=>{mv(e,{get node(){return V(n)},folderPath:[],get onopen(){return t.onopen}})};K(T,e=>{V(i)?e(E):e(D,-1)}),j(w);var ee=z(w,2);j(u),Ui(u,e=>F(c,e),()=>V(c)),B((e,t,n,i,a,c,l)=>{vi(u,1,`no-print ${V(o)==null?`w-72`:``} shrink-0 flex flex-col border-r border-gray-200 dark:border-gray-800 bg-white dark:bg-gray-900 overflow-y-auto relative`),bi(u,V(o)==null?``:`width:${V(o)}px`),J(p,`placeholder`,e),Ai(p,X.searchQuery),G(g,`${V(r)??``} document${V(r)===1?``:`s`}`),J(v,`title`,t),vi(v,1,`hover:opacity-80 transition-colors leading-none ${X.highlightStatusState===0?`text-gray-400 dark:text-gray-500`:X.highlightStatusState===1?`text-green-500 dark:text-green-400`:`text-orange-500 dark:text-orange-400`}`),J(y,`title`,n),vi(y,1,`transition-colors leading-none ${X.hideAttachments?`text-gray-400 dark:text-gray-500`:`text-blue-500 dark:text-blue-400`}`),J(b,`title`,i),vi(b,1,`transition-colors leading-none ${X.hideCategories?`text-gray-400 dark:text-gray-500`:`text-blue-500 dark:text-blue-400`}`),J(x,`title`,a),J(S,`title`,c),J(C,`title`,l),vi(ee,1,`absolute top-0 right-[-2px] w-1.5 h-full cursor-col-resize z-20 select-none transition-colors ${V(s)?`bg-blue-500/55`:`hover:bg-blue-500/35`}`)},[()=>Y(`nav.search_mobile_placeholder`),()=>Y(`nav.toggle_status_highlight`),()=>Y(`nav.toggle_attachments`),()=>Y(`nav.toggle_categories`),()=>Y(`nav.export`),()=>Y(`nav.new_folder`),()=>Y(`nav.new_document`)]),H(`input`,p,e=>t.onsearch(e.target.value)),H(`click`,v,()=>X.cycleHighlightStatus()),H(`click`,y,()=>X.toggleHideAttachments()),H(`click`,b,()=>X.toggleHideCategories()),H(`click`,x,function(...e){t.onexport?.apply(this,e)}),H(`click`,S,function(...e){t.onnewfolder?.apply(this,e)}),H(`click`,C,function(...e){t.onnewdoc?.apply(this,e)}),H(`mousedown`,ee,l),W(e,u),Je()}Pr([`input`,`click`,`mousedown`]);var vv=`background:rgba(250,204,21,0.5);border-radius:2px;cursor:pointer;padding:0 1px;`;function yv(e,t,n){e.querySelectorAll(`mark[data-annotation-id]`).forEach(e=>{let t=e.parentNode;t&&(t.replaceChild(document.createTextNode(e.textContent||``),e),t.normalize())});for(let n of t)xv(e,n);e.querySelectorAll(`mark[data-annotation-id]`).forEach(e=>{(e.textContent||``).trim()||e.remove()}),n&&bv(e,!1)}function bv(e,t){e.querySelectorAll(`mark[data-annotation-id]`).forEach(e=>{let n=e;n.style.background=t?`rgba(250,204,21,0.5)`:`transparent`,n.style.cursor=t?`pointer`:`default`,n.style.pointerEvents=t?`auto`:`none`})}function xv(e,t){let n=(t.selectedText||``).replace(/\s+/g,` `).trim(),r=(t.contextBefore||``).replace(/\s+/g,` `).trim(),i=(t.contextAfter||``).replace(/\s+/g,` `).trim();if(!n)return;let a=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),o=e=>e.split(/\s+/).filter(Boolean).map(a).join(`\\s+`),s=e.textContent||``,c=o(n),l=null;if(r||i){let e=(r?`${o(r)}\\s*`:``)+`(`+c+`)`+(i?`\\s*${o(i)}`:``);try{l=new RegExp(e,`d`).exec(s)}catch{}}if(!l)try{l=RegExp(`(${c})`,`d`).exec(s)}catch{return}let u=l&&l.indices;if(!l||!u?.[1])return;let[d,f]=u[1],p=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),m=[],h=0;for(;p.nextNode();){let e=p.currentNode,t=e.nodeValue?.length,n=h,r=h+t;if(h=r,r<=d)continue;if(n>=f)break;let i=Math.max(0,d-n),a=Math.min(t,f-n);i<a&&m.push({node:e,start:i,end:a})}for(let{node:e,start:n,end:r}of m){let i=e;n>0&&n<i.nodeValue?.length&&(i=i.splitText(n));let a=r-n;a>0&&a<i.nodeValue?.length&&i.splitText(a);let o=document.createElement(`mark`);o.setAttribute(`data-annotation-id`,t.id),o.setAttribute(`style`,vv),i.parentNode?.insertBefore(o,i),o.appendChild(i)}}var Sv=U(`<div class="fixed z-50 w-80 bg-yellow-50 dark:bg-yellow-900/80 border-2 border-yellow-300 dark:border-yellow-600 rounded-xl shadow-2xl p-4 flex flex-col gap-3"><div class="text-xs font-semibold text-yellow-700 dark:text-yellow-300 flex items-center gap-2"><span>✎</span><span> </span></div> <div class="text-xs text-yellow-800 dark:text-yellow-200 bg-yellow-100 dark:bg-yellow-800/50 rounded px-2 py-1 italic max-h-16 overflow-y-auto border border-yellow-200 dark:border-yellow-700"> </div> <textarea rows="4" class="w-full text-sm rounded-lg border border-yellow-300 dark:border-yellow-600 bg-white dark:bg-yellow-950 text-gray-900 dark:text-gray-100 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-yellow-400 resize-none"></textarea> <div class="flex justify-end gap-2"><button class="text-sm px-3 py-1.5 rounded-lg border border-yellow-300 dark:border-yellow-600 text-yellow-700 dark:text-yellow-300 hover:bg-yellow-100 dark:hover:bg-yellow-800 transition-colors"> </button> <button class="text-sm px-4 py-1.5 rounded-lg bg-yellow-400 hover:bg-yellow-500 dark:bg-yellow-600 dark:hover:bg-yellow-500 text-yellow-900 dark:text-white font-semibold transition-colors"> </button></div></div>`),Cv=U(`<div class="text-xs font-semibold text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-700 rounded px-2 py-1"> </div>`),wv=U(`<div class="fixed z-50 w-80 bg-yellow-50 dark:bg-yellow-900/80 border-2 border-yellow-300 dark:border-yellow-600 rounded-xl shadow-2xl p-4 flex flex-col gap-2"><div class="text-xs font-semibold text-yellow-700 dark:text-yellow-300 flex items-center gap-2"><span>✎</span><span class="font-normal text-yellow-600 dark:text-yellow-400"> </span></div> <!> <div class="text-sm text-gray-800 dark:text-gray-100 whitespace-pre-wrap max-h-48 overflow-y-auto"> </div> <div class="flex justify-end pt-1 border-t border-yellow-200 dark:border-yellow-700"><button class="text-xs px-3 py-1.5 rounded-lg border border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors flex items-center gap-1"> </button></div></div>`),Tv=U(`<div class="fixed z-50 w-72 bg-white dark:bg-gray-900 border border-red-200 dark:border-red-700 rounded-xl shadow-2xl p-4 flex flex-col gap-3"><p class="text-sm text-gray-700 dark:text-gray-200"> </p> <div class="flex justify-end gap-2"><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"> </button> <button 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>`),Ev=U(`<button> </button>`),Dv=U(`<div class="fixed top-14 right-0 w-10 flex flex-col items-center py-2 gap-2 z-40 overflow-y-auto" style="max-height: calc(100vh - 3.5rem)"></div>`),Ov=U(`<!> <!> <!> <!>`,1);function kv(e,t){qe(t,!0);let n=P(I([])),r=P(null),i=P(``),a=P(null),o=P(null),s=P(I([])),c=null;Ji(()=>{let e=document.getElementById(`home-content-area`);if(!e)return;let t=()=>{c&&clearTimeout(c),F(a,null)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)});function l(e,t,n=320,r=260){let i=window.innerWidth,a=window.innerHeight,o=e;return o+n>i-16&&(o=i-n-16),o<8&&(o=8),{x:o,y:Math.min(t,a-r)}}async function u(e){F(n,[],!0);try{F(n,await fetch(`/api/annotations/`+encodeURIComponent(e)).then(e=>e.json()),!0)}catch{F(n,[],!0)}d()}function d(){t.contentEl&&(yv(t.contentEl,V(n),X.markerHidden),f())}kn(()=>{t.contentEl&&bv(t.contentEl,!X.markerHidden)});function f(){if(!t.contentEl){F(s,[],!0);return}F(s,V(n).map(e=>({id:e.id,note:e.note.length>60?e.note.slice(0,60)+`…`:e.note,orphan:!t.contentEl.querySelector(`mark[data-annotation-id="${e.id}"]`)})),!0)}function p(){if(!X.markerActive||V(r)||!t.contentEl)return;let e=window.getSelection();if(!e||e.isCollapsed||!e.toString().trim()||!t.contentEl.contains(e.anchorNode))return;let n=e.getRangeAt(0),a=document.createRange();a.selectNodeContents(t.contentEl),a.setEnd(n.startContainer,n.startOffset);let o=a.toString().length,s=n.toString(),c=t.contentEl.textContent||``,u=e=>e.replace(/\s+/g,` `).trim(),d=u(s),f=u(c.slice(Math.max(0,o-30),o)),p=u(c.slice(o+s.length,o+s.length+30)),m=n.getBoundingClientRect(),h=l(m.left,m.bottom+8);F(r,{x:h.x,y:h.y,preview:d.length>120?d.slice(0,120)+`…`:d,selectedText:d,contextBefore:f,contextAfter:p},!0),F(i,``)}function m(){F(r,null),window.getSelection()?.removeAllRanges()}async function h(){if(!V(r)||!t.docId)return;let e=V(i).trim();if(e)try{let i=await fetch(`/api/annotations/`+encodeURIComponent(t.docId),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({selectedText:V(r).selectedText,contextBefore:V(r).contextBefore,contextAfter:V(r).contextAfter,note:e})}).then(e=>e.json());F(n,[...V(n),i],!0),m(),d(),X.annotationCounts={...X.annotationCounts,[t.docId]:(X.annotationCounts[t.docId]||0)+1}}catch{}}kn(()=>{if(!t.contentEl)return;let e=t.contentEl,r=e=>{let t=e.target.closest(`mark[data-annotation-id]`);if(!t)return;let r=V(n).find(e=>e.id===t.dataset.annotationId);r&&g(r,t)},i=e=>{let t=e;t.target.closest(`mark[data-annotation-id]`)&&(t.relatedTarget&&t.relatedTarget.closest?.(`mark[data-annotation-id]`)||_())};return e.addEventListener(`mouseover`,r),e.addEventListener(`mouseout`,i),()=>{e.removeEventListener(`mouseover`,r),e.removeEventListener(`mouseout`,i)}});function g(e,n){c&&clearTimeout(c);let r=!t.contentEl?.querySelector(`mark[data-annotation-id="${e.id}"]`),i=n.getBoundingClientRect(),o=l(i.left,i.bottom+8);F(a,{ann:e,x:o.x,y:o.y,orphan:r},!0)}function _(){c=window.setTimeout(()=>{F(a,null)},1500)}function v(){V(a)&&(F(o,{id:V(a).ann.id,x:V(a).x,y:V(a).y},!0),F(a,null))}async function y(){if(!V(o)||!t.docId)return;let e=V(o).id;try{await fetch(`/api/annotations/${encodeURIComponent(t.docId)}/${e}`,{method:`DELETE`}),F(n,V(n).filter(t=>t.id!==e),!0),F(o,null),d();let r=(X.annotationCounts[t.docId]||0)-1,i={...X.annotationCounts};r<=0?delete i[t.docId]:i[t.docId]=r,X.annotationCounts=i}catch{}}function b(e,t){return e.getBoundingClientRect().top+t.scrollTop-t.getBoundingClientRect().top}function x(e,t){let n=e.parentElement;for(;n&&n!==t;)n.tagName===`DETAILS`&&(n.open=!0),n=n.parentElement}function S(e,r){let i=t.contentEl?.querySelector(`mark[data-annotation-id="${e}"]`),o=document.getElementById(`home-content-area`);if(i&&o){if(V(a)?.ann.id===e){c&&clearTimeout(c);return}x(i,o),o.scrollTo({top:b(i,o)-o.clientHeight/2,behavior:`smooth`})}else{let t=V(n).find(t=>t.id===e);t&&g(t,r.currentTarget)}}function C(e,r){c&&clearTimeout(c);let i=V(n).find(t=>t.id===e);if(!i)return;let a=t.contentEl?.querySelector(`mark[data-annotation-id="${e}"]`),o=document.getElementById(`home-content-area`);if(!a||!o){g(i,r.currentTarget);return}x(a,o),o.scrollTo({top:b(a,o)-o.clientHeight/2,behavior:`smooth`});let s,l=()=>{clearTimeout(s),s=window.setTimeout(()=>{o.removeEventListener(`scroll`,l),g(i,a)},80)};o.addEventListener(`scroll`,l),s=window.setTimeout(()=>{o.removeEventListener(`scroll`,l),g(i,a)},600)}function w(e){let t=V(a)?.ann.id===e.id;return e.orphan?t?`#b91c1c`:`#ef4444`:t?`#f97316`:`#facc15`}function T(e){return new Date(e).toLocaleDateString(`fr-FR`,{day:`2-digit`,month:`short`,year:`numeric`})}var E={load:u,apply:d},D=Ov();Nr(`mouseup`,on,p);var ee=R(D),te=e=>{var t=Sv(),n=L(t),a=z(L(n)),o=L(a,!0);j(a),j(n);var s=z(n,2),c=L(s,!0);j(s);var l=z(s,2);yn(l),vn(l,!0);var u=z(l,2),d=L(u),f=L(d,!0);j(d);var p=z(d,2),g=L(p,!0);j(p),j(u),j(t),B((e,n,i,a)=>{bi(t,`left:${V(r).x??``}px;top:${V(r).y??``}px`),G(o,e),G(c,V(r).preview),J(l,`placeholder`,n),G(f,i),G(g,a)},[()=>Y(`annotation.title`),()=>Y(`annotation.placeholder`),()=>Y(`common.cancel`),()=>Y(`annotation.save_btn`)]),Fi(l,()=>V(i),e=>F(i,e)),H(`click`,d,m),H(`click`,p,h),W(e,t)};K(ee,e=>{V(r)&&e(te)});var O=z(ee,2),k=e=>{var t=wv(),n=L(t),r=z(L(n)),i=L(r,!0);j(r),j(n);var o=z(n,2),s=e=>{var t=Cv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`annotation.orphan`)]),W(e,t)};K(o,e=>{V(a).orphan&&e(s)});var l=z(o,2),u=L(l,!0);j(l);var d=z(l,2),f=L(d),p=L(f,!0);j(f),j(d),j(t),B((e,n)=>{bi(t,`left:${V(a).x??``}px;top:${V(a).y??``}px`),G(i,e),G(u,V(a).ann.note),G(p,n)},[()=>T(V(a).ann.createdAt),()=>Y(`annotation.delete_btn`)]),Nr(`mouseenter`,t,()=>{c&&clearTimeout(c)}),Nr(`mouseleave`,t,_),H(`click`,f,v),W(e,t)};K(O,e=>{V(a)&&e(k)});var ne=z(O,2),A=e=>{var t=Tv(),n=L(t),r=L(n,!0);j(n);var i=z(n,2),a=L(i),s=L(a,!0);j(a);var c=z(a,2),l=L(c,!0);j(c),j(i),j(t),B((e,n,i)=>{bi(t,`left:${V(o).x??``}px;top:${V(o).y??``}px`),G(r,e),G(s,n),G(l,i)},[()=>Y(`annotation.confirm_delete`),()=>Y(`common.cancel`),()=>Y(`annotation.confirm_btn`)]),H(`click`,a,()=>F(o,null)),H(`click`,c,y),W(e,t)};K(ne,e=>{V(o)&&e(A)});var re=z(ne,2),ie=e=>{var t=Dv();q(t,21,()=>V(s),e=>e.id,(e,t)=>{var n=Ev(),r=L(n,!0);j(n),B((e,i)=>{J(n,`title`,e),vi(n,1,`w-8 h-8 rounded border-2 shadow text-xs flex items-center justify-center transition-colors shrink-0 ${V(t).orphan?`border-red-600 text-white`:`border-yellow-500`}`),bi(n,`background:${i??``}`),G(r,V(t).orphan?`⚠`:`✎`)},[()=>V(t).orphan?`${Y(`annotation.orphan`)}\n\n${V(t).note}`:V(t).note,()=>w(V(t))]),H(`click`,n,e=>S(V(t).id,e)),Nr(`mouseenter`,n,e=>C(V(t).id,e)),Nr(`mouseleave`,n,_),W(e,n)}),j(t),W(e,t)};return K(re,e=>{V(s).length>0&&!X.markerHidden&&e(ie)}),W(e,D),Je(E)}Pr([`click`]);var Av=`#dc2626`,jv=`#eab308`,Mv=`#16a34a`;function Nv(e){let t=Math.max(0,Math.min(1,e))*100;return t>80?Mv:t>=60?jv:t>=40?`#f97316`:Av}function Pv(e){let t=Math.max(0,Math.min(1,e))*100;return t>=100?Mv:t<30?Av:t<60?`linear-gradient(to right, ${Av} 0%, ${Av} 60%, ${jv} 100%)`:t<80?`linear-gradient(to right, ${Av} 0%, ${jv} 40%, ${jv} 100%)`:`linear-gradient(to right, ${jv} 0%, ${Mv} 40%, ${Mv} 100%)`}var Fv=new class{#e=P(null);get report(){return V(this.#e)}set report(e){F(this.#e,e,!0)}async load(e){if(!e)return this.report=null,null;try{let t=await fetch(`/api/metadata/${encodeURIComponent(e)}`);if(!t.ok)throw Error(t.statusText);this.report=await t.json()}catch{this.report=null}return this.report}async refresh(e){let t=await fetch(`/api/metadata/${encodeURIComponent(e)}/refresh`,{method:`POST`});if(!t.ok)throw Error(t.statusText);this.report=await t.json()}async addPath(e,t){let n=await fetch(`/api/metadata/${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||n.statusText)}this.report=await n.json()}async removePath(e,t){let n=await fetch(`/api/metadata/${encodeURIComponent(e)}`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t})});if(!n.ok)throw Error(n.statusText);this.report=await n.json()}},Iv=U(`<div data-testid="accuracy-gauge" class="no-print mt-5 flex items-center gap-3 mr-auto w-full sm:w-80 cursor-pointer select-none"><span class="text-xs text-gray-500 dark:text-gray-400 shrink-0"> </span> <div class="flex-1 h-4 rounded-full bg-gray-200 dark:bg-gray-700 overflow-hidden"><div class="h-full w-full transition-all"></div></div> <span data-testid="accuracy-gauge-value" class="text-xs font-semibold shrink-0 tabular-nums"> </span></div>`);function Lv(e,t){qe(t,!0);let n=N(()=>Fv.report),r=N(()=>V(n)?Math.round(V(n).accuracy*100):0),i=N(()=>V(n)?Y(`accuracy.tooltip`).replace(`{unchanged}`,String(V(n).unchanged)).replace(`{modified}`,String(V(n).modified)).replace(`{missing}`,String(V(n).missing)).replace(`{total}`,String(V(n).total)):``);var a=Wr(),o=R(a),s=e=>{var a=Iv(),o=L(a),s=L(o,!0);j(o);var c=z(o,2),l=L(c);j(c);var u=z(c,2),d=L(u);j(u),j(a),B((e,t,n)=>{J(a,`title`,V(i)),G(s,e),bi(l,`background:${t??``}`),bi(u,`color:${n??``}`),G(d,`${V(r)??``}%`)},[()=>Y(`accuracy.label`),()=>Pv(V(n).accuracy),()=>Nv(V(n).accuracy)]),H(`click`,a,function(...e){t.onopen?.apply(this,e)}),W(e,a)};K(o,e=>{V(n)&&V(n).total>0&&e(s)}),W(e,a),Je()}Pr([`click`]);var Rv=/^(\s*(?:\*\*status:\*\*|status:)\s*).+?\s*$/im;function zv(e){if(typeof e!=`string`)return null;let t=e.match(/^---\s*\n([\s\S]*?)\n---/);if(!t)return null;let n=t[1].match(/^\s*(?:\*\*status:\*\*|status:)\s*(.+?)\s*$/im);return n?n[1].trim():null}function Bv(e,t){return e.replace(Rv,`$1${t}`)}function Vv(e){return/%5BWORKLOG%5D/i.test(e)}var Hv=U(`<div data-testid="metadata-readonly-banner" class="text-xs text-amber-800 dark:text-amber-200 bg-amber-50 dark:bg-amber-900/30 border-l-4 border-amber-500 rounded-r px-3 py-2"> </div>`),Uv=U(`<div class="px-3 py-4 text-center text-xs text-gray-400"> </div>`),Wv=U(`<span class="inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300"><i class="fa-solid fa-check"></i> </span>`),Gv=U(`<span class="inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300"><i class="fa-solid fa-triangle-exclamation"></i> </span>`),Kv=U(`<span class="inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300"><i class="fa-solid fa-circle-xmark"></i> </span>`),qv=U(`<button class="metadata-row-remove text-xs px-2 py-1 rounded-lg border border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors"><i class="fa-solid fa-trash"></i></button>`),Jv=U(`<div class="flex items-center gap-2 px-3 py-2 border-b border-gray-100 dark:border-gray-800"><div class="flex-1 min-w-0"><div class="text-sm font-mono truncate text-gray-800 dark:text-gray-200"> </div></div> <!> <!></div>`),Yv=U(`<div class="flex items-center gap-2 flex-wrap"><button data-testid="metadata-add-btn" class="text-sm px-3 py-1.5 rounded-lg border border-blue-200 dark:border-blue-700 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 transition-colors"><i class="fa-solid fa-plus"></i> </button> <button data-testid="metadata-refresh-btn" 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"><i class="fa-solid fa-arrows-rotate"></i> </button></div>`),Xv=U(`<div class="px-3 py-2 text-xs text-gray-400"> </div>`),Zv=U(`<div class="px-3 py-2 text-xs text-red-500"> </div>`),Qv=U(`<button class="w-full text-left px-3 py-1.5 text-sm hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center gap-2"><i class="fa-solid fa-folder text-yellow-500"></i> <span class="truncate"> </span></button>`),$v=U(`<button class="w-full text-left px-3 py-1.5 text-sm hover:bg-blue-50 dark:hover:bg-blue-900/30 flex items-center gap-2"><i class="fa-solid fa-file text-gray-400"></i> <span class="truncate"> </span> <i class="fa-solid fa-plus ml-auto text-blue-500 text-xs"></i></button>`),ey=U(`<!> <!>`,1),ty=U(`<div class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden text-sm"><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"> </button> <span class="text-xs text-gray-500 dark:text-gray-400 font-mono truncate flex-1"> </span></div> <div class="max-h-56 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800"><!></div></div>`),ny=U(`<p class="text-xs text-red-500"> </p>`),ry=U(`<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50"><div data-testid="metadata-modal" class="bg-white dark:bg-gray-900 rounded-xl shadow-xl w-full max-w-2xl mx-4 p-6 space-y-4"><div class="flex items-start justify-between gap-4"><div><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"><i class="fa-solid fa-code-compare mr-1"></i> </h3> <p class="text-xs text-gray-500 dark:text-gray-400 mt-1"> </p></div> <button class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 transition-colors"><i class="fa-solid fa-xmark text-lg"></i></button></div> <div class="text-xs text-gray-600 dark:text-gray-300 bg-gray-50 dark:bg-gray-800 rounded-lg px-3 py-2"></div> <!> <div data-testid="metadata-list" class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden"><div class="max-h-64 overflow-y-auto"><!></div></div> <!> <!> <!> <div class="flex justify-end"><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></div></div></div>`);function iy(e,t){qe(t,!0);let n=N(()=>Fv.report),r=N(()=>zv(t.content)===`SuperSeeded`),i=P(``),a=P(!1),o=P(!1),s=P(``),c=P(null),l=P(I([])),u=P(I([])),d=P(!1),f=P(``);kn(()=>{t.open||(F(o,!1),F(s,``),F(i,``))});function p(e){F(i,Y(`common.error_prefix`)+e),setTimeout(()=>{F(i,``)},5e3)}function m(){return!V(n)||V(n).total===0?``:`<span class="font-semibold">${Math.round(V(n).accuracy*100)}%</span> · ${V(n).unchanged}/${V(n).total} ${Y(`metadata.status.unchanged`)} · ${V(n).modified} ${Y(`metadata.status.modified`)} · ${V(n).missing} ${Y(`metadata.status.missing`)}`}async function h(){F(a,!0);try{await Fv.refresh(t.docId)}catch(e){p(e instanceof Error?e.message:String(e))}finally{F(a,!1)}}async function g(e){try{await Fv.removePath(t.docId,e),V(o)&&y(V(s))}catch(e){p(e instanceof Error?e.message:String(e))}}async function _(e){try{await Fv.addPath(t.docId,e),V(o)&&y(V(s))}catch(e){p(e instanceof Error?e.message:String(e))}}function v(){F(o,!V(o)),V(o)&&y(``)}async function y(e){F(d,!0),F(f,``);try{let t=await fetch(`/api/browse-source?path=`+encodeURIComponent(e||``));if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||t.statusText)}let r=await t.json();F(s,r.current||``,!0),F(c,r.parent,!0),F(l,r.dirs||[],!0);let i=new Set((V(n)?.items||[]).map(e=>e.path));F(u,(r.files||[]).filter(e=>!i.has(e.path)),!0)}catch(e){F(f,e instanceof Error?e.message:String(e),!0)}finally{F(d,!1)}}function b(){V(c)!==null&&y(V(c))}var x=Wr(),S=R(x),C=e=>{var p=ry(),x=L(p),S=L(x),C=L(S),w=L(C),T=z(L(w));j(w);var E=z(w,2),D=L(E,!0);j(E),j(C);var ee=z(C,2);j(S);var te=z(S,2);si(te,m,!0),j(te);var O=z(te,2),k=e=>{var t=Hv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`metadata.readonly_banner`)]),W(e,t)};K(O,e=>{V(r)&&e(k)});var ne=z(O,2),A=L(ne),re=L(A),ie=e=>{var t=Uv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`metadata.empty`)]),W(e,t)},ae=e=>{var t=Wr();q(R(t),17,()=>V(n).items,e=>e.path,(e,t)=>{var n=Jv(),i=L(n),a=L(i),o=L(a,!0);j(a),j(i);var s=z(i,2),c=e=>{var t=Wv(),n=z(L(t));j(t),B(e=>G(n,` ${e??``}`),[()=>Y(`metadata.status.unchanged`)]),W(e,t)},l=e=>{var t=Gv(),n=z(L(t));j(t),B(e=>G(n,` ${e??``}`),[()=>Y(`metadata.status.modified`)]),W(e,t)},u=e=>{var t=Kv(),n=z(L(t));j(t),B(e=>G(n,` ${e??``}`),[()=>Y(`metadata.status.missing`)]),W(e,t)};K(s,e=>{V(t).status===`unchanged`?e(c):V(t).status===`modified`?e(l,1):e(u,-1)});var d=z(s,2),f=e=>{var n=qv();B(e=>J(n,`title`,e),[()=>Y(`metadata.remove`)]),H(`click`,n,()=>g(V(t).path)),W(e,n)};K(d,e=>{V(r)||e(f)}),j(n),B(()=>{J(a,`title`,V(t).path),G(o,V(t).path)}),W(e,n)}),W(e,t)};K(re,e=>{!V(n)||V(n).items.length===0?e(ie):e(ae,-1)}),j(A),j(ne);var oe=z(ne,2),se=e=>{var t=Yv(),n=L(t),r=z(L(n));j(n);var i=z(n,2),o=z(L(i));j(i),j(t),B((e,t)=>{G(r,` ${e??``}`),i.disabled=V(a),G(o,` ${t??``}`)},[()=>Y(`metadata.add`),()=>Y(`metadata.refresh`)]),H(`click`,n,v),H(`click`,i,h),W(e,t)};K(oe,e=>{V(r)||e(se)});var ce=z(oe,2),le=e=>{var t=ty(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n);var p=z(n,2),m=L(p),h=e=>{var t=Xv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},g=e=>{var t=Zv(),n=L(t,!0);j(t),B(()=>G(n,V(f))),W(e,t)},v=e=>{var t=Xv(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.empty_dir`)]),W(e,t)},x=e=>{var t=ey(),n=R(t);q(n,17,()=>V(l),e=>e.path,(e,t)=>{var n=Qv(),r=z(L(n),2),i=L(r,!0);j(r),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>y(V(t).path)),W(e,n)}),q(z(n,2),17,()=>V(u),e=>e.path,(e,t)=>{var n=$v(),r=z(L(n),2),i=L(r,!0);j(r),Ie(2),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>_(V(t).path)),W(e,n)}),W(e,t)};K(m,e=>{V(d)?e(h):V(f)?e(g,1):V(l).length===0&&V(u).length===0?e(v,2):e(x,-1)}),j(p),j(t),B(e=>{r.disabled=V(c)===null,G(i,e),G(o,V(s)?`/`+V(s):`/ (sourceRoot)`)},[()=>Y(`common.up`)]),H(`click`,r,b),W(e,t)};K(ce,e=>{V(o)&&e(le)});var ue=z(ce,2),de=e=>{var t=ny(),n=L(t,!0);j(t),B(()=>G(n,V(i))),W(e,t)};K(ue,e=>{V(i)&&e(de)});var fe=z(ue,2),pe=L(fe),me=L(pe,!0);j(pe),j(fe),j(x),j(p),B((e,t,n,r)=>{G(T,` ${e??``}`),G(D,t),J(ee,`title`,n),G(me,r)},[()=>Y(`metadata.title`),()=>Y(`metadata.subtitle`),()=>Y(`common.close`),()=>Y(`common.close`)]),H(`click`,p,e=>{e.target===e.currentTarget&&t.onclose()}),H(`click`,ee,function(...e){t.onclose?.apply(this,e)}),H(`click`,pe,function(...e){t.onclose?.apply(this,e)}),W(e,p)};K(S,e=>{t.open&&e(C)}),W(e,x),Je()}Pr([`click`]);var ay=U(`<div class="text-xs font-medium text-amber-700 dark:text-amber-300"> </div>`),oy=U(`<div> </div>`),sy=U(`<button type="button"><div class="flex items-center gap-2 font-semibold text-gray-800 dark:text-gray-100"><span class="font-mono text-blue-600 dark:text-blue-400"> </span> <span class="truncate"> </span></div> <div class="mt-1 text-gray-500 dark:text-gray-400"> </div></button>`),cy=U(`<div class="mt-3 flex gap-2 overflow-x-auto pb-1"></div>`),ly=U(`<p class="mt-3 text-sm text-gray-500 dark:text-gray-400"> </p>`),uy=U(`<div class="flex h-full items-center justify-center text-sm text-gray-500 dark:text-gray-400"> </div>`),dy=U(`<div class="m-5 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-950/30 dark:text-red-300"> </div>`),fy=U(`<div class="mx-5 mt-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-2 text-sm text-amber-800 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-200"> </div>`),py=U(`<button type="button" class="mt-0.5 inline-flex h-7 w-8 items-center justify-center rounded-md border border-blue-200 bg-white font-mono text-sm font-bold text-blue-600 transition-colors hover:bg-blue-50 disabled:cursor-wait disabled:opacity-50 dark:border-blue-800 dark:bg-gray-950 dark:text-blue-300 dark:hover:bg-blue-950/40"> </button>`),my=U(`<div><span> </span> <pre class="m-0 whitespace-pre-wrap break-words px-2 py-0.5 font-mono"> </pre></div> <div class="flex items-start justify-center border-r border-gray-200 bg-gray-50 px-1 py-0.5 dark:border-gray-800 dark:bg-gray-900/70"><!></div> <div><span> </span> <pre class="m-0 whitespace-pre-wrap break-words px-2 py-0.5 font-mono"> </pre></div>`,1),hy=U(`<!> <div class="h-full overflow-auto p-5"><div class="grid min-w-[980px] grid-cols-[minmax(0,1fr)_3.25rem_minmax(0,1fr)] overflow-hidden rounded-lg border border-gray-200 text-xs dark:border-gray-800"><div class="border-b border-r border-gray-200 bg-gray-100 px-3 py-2 font-semibold text-gray-700 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-200"> </div> <div class="border-b border-r border-gray-200 bg-gray-100 px-2 py-2 text-center font-semibold text-gray-400 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-500"></div> <div class="border-b border-gray-200 bg-gray-100 px-3 py-2 font-semibold text-gray-700 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-200"> </div> <!></div></div>`,1),gy=U(`<div data-testid="versions-modal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4"><div class="flex h-[90vh] w-full max-w-7xl flex-col overflow-hidden rounded-xl border border-gray-200 bg-white shadow-2xl dark:border-gray-700 dark:bg-gray-950"><header class="flex shrink-0 items-start justify-between gap-4 border-b border-gray-200 px-5 py-4 dark:border-gray-800"><div><h2 class="text-lg font-semibold text-gray-900 dark:text-gray-50"><i class="fa-solid fa-code-branch mr-2"></i> </h2> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400"> </p></div> <button type="button" class="rounded-lg border border-gray-200 px-3 py-1.5 text-sm text-gray-600 transition-colors hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800"><i class="fa-solid fa-xmark"></i></button></header> <div class="shrink-0 border-b border-gray-200 px-5 py-3 dark:border-gray-800"><div class="flex flex-wrap items-end gap-3"><label class="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400"> <input type="number" class="mt-1 block w-28 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm text-gray-800 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100"/></label> <button type="button" class="rounded-lg bg-blue-600 px-3 py-1.5 text-sm font-semibold text-white transition-colors hover:bg-blue-700 disabled:opacity-50"><i class="fa-solid fa-arrows-rotate mr-1"></i> </button> <button type="button" class="rounded-lg bg-green-600 px-3 py-1.5 text-sm font-semibold text-white transition-colors hover:bg-green-700 disabled:cursor-not-allowed disabled:opacity-50"><i class="fa-solid fa-floppy-disk mr-1"></i> </button> <div class="text-xs text-gray-500 dark:text-gray-400"> </div> <!> <!></div> <!></div> <section class="min-h-0 flex-1 overflow-hidden"><!></section></div></div>`);function _y(e,t){qe(t,!0);let n=3650,r=P(30),i=P(30),a=P(!1),o=P(``),s=P(null),c=P(null),l=P(null),u=P(``),d=``,f=P(``),p=P(!1),m=N(()=>V(l)?.headContent??t.content),h=N(()=>V(f)),g=N(()=>V(f)!==V(m)),_=N(()=>T(V(l)?.baseContent??``,V(h))),v=N(()=>V(_).rows),y=N(()=>V(l)?.baseContent!==null&&V(l)?.baseContent!==void 0);kn(()=>{t.docId,F(f,t.content,!0)});function b(e){return Number.isFinite(e)?Math.max(1,Math.min(n,Math.floor(e))):30}function x(e){return e.length?e.replace(/\r\n/g,`
|
|
100
100
|
`).split(`
|
|
101
101
|
`):[]}function S(){return{text:``,lineNumber:null,kind:`empty`}}function C(e,t){let n=[],r=[],i=Math.max(e.length,t.length);for(let a=0;a<i;a+=1){let i=e[a],o=t[a];if(i===o)n.push({left:{text:i??``,lineNumber:i===void 0?null:a+1,kind:i===void 0?`empty`:`context`},right:{text:o??``,lineNumber:o===void 0?null:a+1,kind:o===void 0?`empty`:`context`},hunkId:null,showApply:!1});else{let e={id:r.length,oldStart:a,oldDeleteCount:i===void 0?0:1,newStart:a,newDeleteCount:o===void 0?0:1,oldLines:i===void 0?[]:[i],newLines:o===void 0?[]:[o]};r.push(e),n.push({left:i===void 0?S():{text:i,lineNumber:a+1,kind:`removed`},right:o===void 0?S():{text:o,lineNumber:a+1,kind:`added`},hunkId:e.id,showApply:!0})}}return{rows:n,hunks:r}}function w(e,t,n){let r=n.filter(e=>e.kind===`removed`),i=n.filter(e=>e.kind===`added`),a={id:t.length,oldStart:r[0]?r[0].oldLine-1:i[0]?.oldIndex??0,oldDeleteCount:r.length,newStart:i[0]?i[0].newLine-1:r[0]?.newIndex??0,newDeleteCount:i.length,oldLines:r.map(e=>e.text),newLines:i.map(e=>e.text)};t.push(a);let o=Math.max(r.length,i.length);for(let t=0;t<o;t+=1){let n=r[t],o=i[t];e.push({left:n?{text:n.text,lineNumber:n.oldLine,kind:`removed`}:S(),right:o?{text:o.text,lineNumber:o.newLine,kind:`added`}:S(),hunkId:a.id,showApply:t===0})}}function T(e,t){let n=x(e),r=x(t);if(n.length*r.length>4e6)return C(n,r);let i=r.length+1,a=new Uint32Array((n.length+1)*i);for(let e=n.length-1;e>=0;--e)for(let t=r.length-1;t>=0;--t){let o=e*i+t;a[o]=n[e]===r[t]?a[(e+1)*i+t+1]+1:Math.max(a[(e+1)*i+t],a[e*i+t+1])}let o=[],s=0,c=0;for(;s<n.length||c<r.length;)s<n.length&&c<r.length&&n[s]===r[c]?(o.push({kind:`context`,oldText:n[s],newText:r[c],oldLine:s+1,newLine:c+1}),s+=1,c+=1):c<r.length&&(s===n.length||a[s*i+c+1]>=a[(s+1)*i+c])?(o.push({kind:`added`,text:r[c],newLine:c+1,oldIndex:s}),c+=1):s<n.length&&(o.push({kind:`removed`,text:n[s],oldLine:s+1,newIndex:c}),s+=1);let l=[],u=[],d=[];for(let e of o)e.kind===`context`?(d.length&&(w(l,u,d),d=[]),l.push({left:{text:e.oldText,lineNumber:e.oldLine,kind:`context`},right:{text:e.newText,lineNumber:e.newLine,kind:`context`},hunkId:null,showApply:!1})):d.push(e);return d.length&&w(l,u,d),{rows:l,hunks:u}}function E(e){return e===`added`?`bg-green-50 text-green-900 dark:bg-green-950/40 dark:text-green-100`:e===`removed`?`bg-red-50 text-red-900 dark:bg-red-950/40 dark:text-red-100`:e===`empty`?`bg-gray-50 dark:bg-gray-900/60`:`bg-white text-gray-800 dark:bg-gray-950 dark:text-gray-200`}function D(e){return e===`added`?`bg-green-100 text-green-700 dark:bg-green-950 dark:text-green-300`:e===`removed`?`bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300`:`bg-gray-100 text-gray-400 dark:bg-gray-900 dark:text-gray-500`}function ee(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function te(e){return V(u)===e||V(l)?.baseRef===e}function O(e){return e===null?null:V(_).hunks.find(t=>t.id===e)||null}async function k(e){if(V(c)!==null)return;let n=x(V(f)||t.content);if(n.slice(e.newStart,e.newStart+e.newDeleteCount).join(`
|
|
102
102
|
`)!==e.newLines.join(`
|
|
103
103
|
`)){F(s,{text:Y(`versions.apply_stale`),cls:`text-red-600 dark:text-red-400`},!0);return}F(c,e.id,!0),F(s,null);try{F(f,[...n.slice(0,e.newStart),...e.oldLines,...n.slice(e.newStart+e.newDeleteCount)].join(`
|
|
104
|
-
`),!0),F(s,{text:Y(`versions.apply_success`),cls:`text-green-600 dark:text-green-400`},!0)}catch(e){F(s,{text:Y(`versions.apply_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-600 dark:text-red-400`},!0)}finally{F(c,null)}}async function ne(){if(!(!V(g)||V(p))){F(p,!0),F(s,null);try{await t.onsave(V(f)),d=``,await ie(V(u)),F(s,{text:Y(`versions.save_success`),cls:`text-green-600 dark:text-green-400`},!0)}catch(e){F(s,{text:Y(`versions.save_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-600 dark:text-red-400`},!0)}finally{F(p,!1)}}}function A(){F(f,t.content,!0),F(s,null),F(c,null),F(p,!1)}function re(){A(),t.onclose()}async function ie(e=V(u)){let n=b(V(i)),r=`${t.docId}:${n}:${e||`default`}`;if(!t.open||V(a)||r===d)return;F(a,!0),F(o,``);let c=V(g);c||F(s,null);try{let i=new URLSearchParams({documentId:t.docId,sinceDays:String(n)});e&&i.set(`baseRef`,e);let a=await fetch(`/api/git/document-versions?${i.toString()}`),o=await a.json();if(!a.ok||!o.ok)throw Error(o.message||o.error||Y(`versions.load_failed`));let s=o;F(l,s,!0),F(u,s.baseRef,!0),c||F(f,s.headContent??t.content,!0),d=r}catch(e){F(o,e instanceof Error?e.message:String(e),!0),F(l,null),d=``}finally{F(a,!1)}}function ae(){F(i,b(Number(V(r))),!0),F(r,V(i),!0),F(u,``),d=``,ie(``)}function oe(e){F(u,e,!0),d=``,ie(e)}kn(()=>{if(!t.open){A(),d=``,F(u,``);return}t.docId,V(i),ie()});var se=Wr(),ce=R(se),le=e=>{var t=
|
|
104
|
+
`),!0),F(s,{text:Y(`versions.apply_success`),cls:`text-green-600 dark:text-green-400`},!0)}catch(e){F(s,{text:Y(`versions.apply_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-600 dark:text-red-400`},!0)}finally{F(c,null)}}async function ne(){if(!(!V(g)||V(p))){F(p,!0),F(s,null);try{await t.onsave(V(f)),d=``,await ie(V(u)),F(s,{text:Y(`versions.save_success`),cls:`text-green-600 dark:text-green-400`},!0)}catch(e){F(s,{text:Y(`versions.save_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-600 dark:text-red-400`},!0)}finally{F(p,!1)}}}function A(){F(f,t.content,!0),F(s,null),F(c,null),F(p,!1)}function re(){A(),t.onclose()}async function ie(e=V(u)){let n=b(V(i)),r=`${t.docId}:${n}:${e||`default`}`;if(!t.open||V(a)||r===d)return;F(a,!0),F(o,``);let c=V(g);c||F(s,null);try{let i=new URLSearchParams({documentId:t.docId,sinceDays:String(n)});e&&i.set(`baseRef`,e);let a=await fetch(`/api/git/document-versions?${i.toString()}`),o=await a.json();if(!a.ok||!o.ok)throw Error(o.message||o.error||Y(`versions.load_failed`));let s=o;F(l,s,!0),F(u,s.baseRef,!0),c||F(f,s.headContent??t.content,!0),d=r}catch(e){F(o,e instanceof Error?e.message:String(e),!0),F(l,null),d=``}finally{F(a,!1)}}function ae(){F(i,b(Number(V(r))),!0),F(r,V(i),!0),F(u,``),d=``,ie(``)}function oe(e){F(u,e,!0),d=``,ie(e)}kn(()=>{if(!t.open){A(),d=``,F(u,``);return}t.docId,V(i),ie()});var se=Wr(),ce=R(se),le=e=>{var t=gy(),i=L(t),u=L(i),d=L(u),f=L(d),m=z(L(f),1,!0);j(f);var h=z(f,2),_=L(h,!0);j(h),j(d);var b=z(d,2);j(u);var x=z(u,2),S=L(x),C=L(S),w=L(C),T=z(w);ki(T),J(T,`min`,1),J(T,`max`,n),j(C);var A=z(C,2),ie=z(L(A),1,!0);j(A);var se=z(A,2),ce=z(L(se),1,!0);j(se);var le=z(se,2),ue=L(le,!0);j(le);var de=z(le,2),fe=e=>{var t=ay(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`versions.unsaved_changes`)]),W(e,t)};K(de,e=>{V(g)&&e(fe)});var pe=z(de,2),me=e=>{var t=oy(),n=L(t,!0);j(t),B(()=>{vi(t,1,`text-xs font-medium ${V(s).cls??``}`),G(n,V(s).text)}),W(e,t)};K(pe,e=>{V(s)&&e(me)}),j(S);var he=z(S,2),ge=e=>{var t=cy();q(t,21,()=>V(l).commits,e=>e.hash,(e,t)=>{var n=sy(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var c=z(r,2),l=L(c);j(c),j(n),B((e,r,i)=>{J(n,`title`,e),vi(n,1,`min-w-64 rounded-lg border px-3 py-2 text-left text-xs transition-colors ${r??``}`),G(a,V(t).shortHash),G(s,V(t).subject),G(l,`${i??``} · ${V(t).author??``}`)},[()=>Y(`versions.select_commit`).replace(`{hash}`,V(t).shortHash),()=>te(V(t).hash)?`border-blue-500 bg-blue-50 ring-2 ring-blue-500/30 dark:border-blue-400 dark:bg-blue-950/40`:`border-gray-200 bg-gray-50 hover:border-blue-300 hover:bg-blue-50/70 dark:border-gray-700 dark:bg-gray-900 dark:hover:border-blue-700 dark:hover:bg-blue-950/30`,()=>ee(V(t).date)]),H(`click`,n,()=>oe(V(t).hash)),W(e,n)}),j(t),W(e,t)},_e=e=>{var t=ly(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`versions.no_commits`)]),W(e,t)};K(he,e=>{V(l)?.commits?.length?e(ge):V(l)&&!V(a)&&e(_e,1)}),j(x);var ve=z(x,2),ye=L(ve),be=e=>{var t=uy(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},xe=e=>{var t=dy(),n=L(t,!0);j(t),B(()=>G(n,V(o))),W(e,t)},Se=e=>{var t=hy(),n=R(t),r=e=>{var t=fy(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`versions.no_head_content`)]),W(e,t)};K(n,e=>{V(y)||e(r)});var i=z(n,2),a=L(i),o=L(a),s=L(o,!0);j(o);var u=z(o,4),d=L(u,!0);j(u),q(z(u,2),17,()=>V(v),Qr,(e,t)=>{var n=my(),r=R(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var l=z(r,2),u=L(l),d=e=>{let n=N(()=>O(V(t).hunkId));var r=Wr(),i=R(r),a=e=>{var t=py(),r=L(t,!0);j(t),B(e=>{t.disabled=V(c)!==null,J(t,`title`,e),G(r,V(c)===V(n).id?`...`:`<`)},[()=>Y(`versions.apply_hunk`)]),H(`click`,t,()=>k(V(n))),W(e,t)};K(i,e=>{V(n)&&e(a)}),W(e,r)};K(u,e=>{V(t).showApply&&e(d)}),j(l);var f=z(l,2),p=L(f),m=L(p,!0);j(p);var h=z(p,2),g=L(h,!0);j(h),j(f),B((e,n,o,c)=>{vi(r,1,`grid grid-cols-[4rem_1fr] border-r border-gray-200 font-mono leading-5 dark:border-gray-800 ${e??``}`),vi(i,1,`select-none px-2 py-0.5 text-right ${n??``}`),G(a,V(t).right.lineNumber??``),G(s,V(t).right.text),vi(f,1,`grid grid-cols-[4rem_1fr] font-mono leading-5 ${o??``}`),vi(p,1,`select-none px-2 py-0.5 text-right ${c??``}`),G(m,V(t).left.lineNumber??``),G(g,V(t).left.text)},[()=>E(V(t).right.kind),()=>D(V(t).right.kind),()=>E(V(t).left.kind),()=>D(V(t).left.kind)]),W(e,n)}),j(a),j(i),B((e,t)=>{G(s,e),G(d,t)},[()=>Y(V(g)?`versions.right_title_draft`:`versions.right_title`),()=>Y(`versions.left_title`).replace(`{ref}`,V(l).baseRef)]),W(e,t)},Ce=e=>{var t=uy(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`versions.path_pending`)]),W(e,t)};K(ye,e=>{V(a)?e(be):V(o)?e(xe,1):V(l)?e(Se,2):e(Ce,-1)}),j(ve),j(i),j(t),B((e,t,n,r,i,o,s)=>{G(m,e),G(_,t),J(b,`title`,n),G(w,`${r??``} `),A.disabled=V(a),G(ie,i),se.disabled=!V(g)||V(p)||V(a),G(ce,o),G(ue,s)},[()=>Y(`versions.title`),()=>V(l)?.relativePath||Y(`versions.path_pending`),()=>Y(`common.close`),()=>Y(`versions.period_label`),()=>Y(`versions.refresh`),()=>V(p)?Y(`versions.saving`):Y(`common.save`),()=>Y(`versions.base_ref`).replace(`{ref}`,V(l)?.baseRef||`HEAD`)]),H(`click`,t,e=>{e.target===e.currentTarget&&re()}),H(`click`,b,re),Fi(T,()=>V(r),e=>F(r,e)),H(`click`,A,ae),H(`click`,se,ne),W(e,t)};K(ce,e=>{t.open&&e(le)}),W(e,se),Je()}Pr([`click`]);function vy(e){let t=``,n=[],r=!0;for(let i=0;i<e.length;i++){let a=e[i].normalize(`NFD`);for(let e=0;e<a.length;e++){let o=a.charCodeAt(e);if(!(o>=768&&o<=879))if(o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122){let e=o>=65&&o<=90?o+32:o;t+=String.fromCharCode(e),n.push(i),r=!1}else r||=(t+=` `,n.push(i),!0)}}return n.push(e.length),t.endsWith(` `)&&(t=t.slice(0,-1),n.splice(n.length-2,1)),{normalized:t,map:n}}function yy(e){return vy(e).normalized}function by(e,t,n){if(e===t)return 0;let r=e.length,i=t.length;if(Math.abs(r-i)>n)return n+1;let a=null,o=Array(i+1),s=Array(i+1);for(let e=0;e<=i;e++)o[e]=e;for(let c=1;c<=r;c++){s[0]=c;let r=c;for(let n=1;n<=i;n++){let i=e.charCodeAt(c-1)===t.charCodeAt(n-1)?0:1,l=Math.min(o[n]+1,s[n-1]+1,o[n-1]+i);c>1&&n>1&&e.charCodeAt(c-1)===t.charCodeAt(n-2)&&e.charCodeAt(c-2)===t.charCodeAt(n-1)&&(l=Math.min(l,a?.[n-2]+1)),s[n]=l,l<r&&(r=l)}if(r>n)return n+1;a=o,o=s,s=Array(i+1)}return o[i]}function xy(e){return e>=7?2:+(e>=4)}function Sy(e){return String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function Cy(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function wy(e,t,n){t.innerHTML=``,t.classList.add(`hidden`);let r=e.querySelectorAll(`[data-ld-local-search]`);if(!r.length)return;r.forEach(e=>{e.remove()});let i=(()=>{let t=new Set;return yy(e.textContent||``).split(` `).forEach(e=>{e.length>=3&&t.add(e)}),Array.from(t)})(),a=n(`local_search.placeholder`)||`Search in this document…`,o=n(`local_search.clear`)||`Clear`,s=document.createElement(`div`);s.className=`no-print mt-4 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 overflow-hidden`,s.innerHTML=`
|
|
105
105
|
<div class="flex items-center gap-2 px-3 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50">
|
|
106
106
|
<span class="text-gray-400 select-none" aria-hidden="true">🔎</span>
|
|
107
107
|
<input type="text" id="ld-local-search-input" autocomplete="off"
|
|
108
108
|
class="flex-1 bg-transparent border-0 text-sm text-gray-700 dark:text-gray-300 placeholder:text-gray-400 focus:outline-none focus:ring-0"
|
|
109
|
-
placeholder="${
|
|
109
|
+
placeholder="${Sy(a)}" />
|
|
110
110
|
<button type="button" id="ld-local-search-clear"
|
|
111
111
|
class="hidden text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 shrink-0 px-1"
|
|
112
|
-
title="${
|
|
112
|
+
title="${Sy(o)}" aria-label="${Sy(o)}">✕</button>
|
|
113
113
|
</div>
|
|
114
114
|
<div id="ld-local-search-results" class="hidden">
|
|
115
115
|
<div id="ld-local-search-title" class="px-3 py-1.5 text-xs font-medium text-gray-500 dark:text-gray-400 border-b border-gray-100 dark:border-gray-800"></div>
|
|
116
116
|
<ol id="ld-local-search-list" class="max-h-40 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800 list-none m-0 p-0"></ol>
|
|
117
|
-
</div>`,t.appendChild(s),t.classList.remove(`hidden`);let c=s.querySelector(`#ld-local-search-input`),l=s.querySelector(`#ld-local-search-clear`),u=s.querySelector(`#ld-local-search-results`),d=s.querySelector(`#ld-local-search-title`),f=s.querySelector(`#ld-local-search-list`),p=null;function m(){e.querySelectorAll(`mark.ld-local-mark`).forEach(e=>{let t=e.parentNode;for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}),e.normalize()}function h(e,t){let n=new Set;t.includes(e)&&n.add(e);let r=hy(e.length);if(r===0)return n;let a=e[0];for(let t of i)t!==e&&(Math.abs(t.length-e.length)>r||e.length>=3&&t[0]!==a||my(e,t,r)<=r&&n.add(t));return n}function g(t){if(m(),!t){u.classList.add(`hidden`),l.classList.add(`hidden`),f.innerHTML=``;return}l.classList.remove(`hidden`);let r=py(t),i=r.split(` `).filter(Boolean);if(!i.length){u.classList.add(`hidden`);return}let a=py(e.textContent||``),o=i.map(e=>h(e,a));if(!o.some(e=>e.size>0)){d.textContent=n(`local_search.no_results`)||`No matches found.`,f.innerHTML=``,u.classList.remove(`hidden`);return}let s=new Set;o.forEach((e,t)=>{e.forEach(e=>{let n=e===i[t];s.add(n?e:`\\b${_y(e)}\\b`)})});let c=Array.from(s).sort((e,t)=>t.length-e.length),p=RegExp(`(${c.map(e=>e.startsWith(`\\b`)?e:_y(e)).join(`|`)})`,`g`),g=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){return e.parentElement?.closest(`mark`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),v=[];for(;g.nextNode();)v.push(g.currentNode);let y=0,b=new Map;v.forEach(e=>{let t=e.textContent||``,{normalized:n,map:r}=fy(t);if(!n)return;let i=[],a;for(p.lastIndex=0;(a=p.exec(n))!==null;){if(a[0].length===0){p.lastIndex++;continue}i.push({start:a.index,end:a.index+a[0].length,term:a[0]})}if(!i.length)return;let s=e.parentElement?.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre, blockquote`)||e.parentElement,c=``,l=0;i.forEach(e=>{let n=r[e.start],i=r[e.end];if(!(n<l)&&(c+=gy(t.slice(l,n)),c+=`<mark class="ld-local-mark" id="ld-local-match-${y++}">${gy(t.slice(n,i))}</mark>`,l=i,s)){b.has(s)||b.set(s,new Set);let t=b.get(s);o.forEach((n,r)=>{n.has(e.term)&&t.add(r)})}}),c+=gy(t.slice(l));let u=document.createElement(`span`);u.innerHTML=c,e.parentNode?.replaceChild(u,e)});let x=i.length,S=[];for(let[e,t]of b.entries())t.size===x&&S.push(e);let C;if(S.length>0){let t=new Set(S);C=Array.from(e.querySelectorAll(`mark.ld-local-mark`)).filter(e=>{let n=e.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre, blockquote`)||e.parentElement;return t.has(n)})}else C=Array.from(e.querySelectorAll(`mark.ld-local-mark`));if(!C.length){d.textContent=n(`local_search.no_results`)||`No matches found.`,f.innerHTML=``,u.classList.remove(`hidden`);return}d.textContent=(C.length===1?n(`local_search.count_singular`)||`{count} match`:n(`local_search.count_plural`)||`{count} matches`).replace(`{count}`,String(C.length)),f.innerHTML=C.map((e,t)=>{let n=e.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre, blockquote`)||e.parentElement,i=(n?n.textContent||``:e.textContent||``).trim(),a=py(i),s=-1;for(let e of o)for(let t of e){let e=a.indexOf(t);e>=0&&(s<0||e<s)&&(s=e)}s<0&&(s=a.indexOf(r.split(` `)[0])),s<0&&(s=0);let c=Math.max(0,s-40),l=Math.min(i.length,s+80),u=(c>0?`…`:``)+i.slice(c,l)+(l<i.length?`…`:``);return`<li><button type="button" data-target="${e.id}" class="ld-local-item w-full text-left px-3 py-1.5 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors text-xs"><span class="text-gray-400 font-mono mr-2">${t+1}.</span>${gy(u)}</button></li>`}).join(``),u.classList.remove(`hidden`),f.querySelectorAll(`.ld-local-item`).forEach(e=>{e.addEventListener(`click`,()=>_(e.dataset.target))})}function _(t){let n=document.getElementById(t),r=document.getElementById(`home-content-area`);if(!n||!r)return;let i=n.parentElement;for(;i&&i!==r;)i.tagName===`DETAILS`&&!i.open&&(i.open=!0),i=i.parentElement;e.querySelectorAll(`mark.ld-local-mark.ld-local-active`).forEach(e=>e.classList.remove(`ld-local-active`)),n.classList.add(`ld-local-active`),f.querySelectorAll(`.ld-local-item`).forEach(e=>{e.classList.toggle(`ld-local-item-active`,e.dataset.target===t)});let a=document.querySelector(`#home-doc-view header`),o=a?a.getBoundingClientRect().height:0,s=n.getBoundingClientRect().top,c=r.getBoundingClientRect().top,l=o+(r.clientHeight-o)/3;r.scrollTop+=s-c-l}c.addEventListener(`input`,()=>{p&&clearTimeout(p),p=window.setTimeout(()=>g(c.value.trim()),250)}),l.addEventListener(`click`,()=>{c.value=``,g(``),c.focus()}),c.addEventListener(`keydown`,e=>{e.key===`Escape`&&(c.value=``,g(``),c.blur())})}var yy={codeLabel:`Code block.`,imageLabel:`Image: {alt}.`,diagramLabel:`Diagram.`,tableLabel:`Table.`,readCode:!1},by=new Set([`H1`,`H2`,`H3`,`H4`,`H5`,`H6`]);function xy(e){return e.classList.contains(`mermaid`)||e.querySelector(`.mermaid`)!==null}function Sy(e){let t=[];for(let n of e.matchAll(/[^.!?…\n]*(?:[.!?…]+|\n+|$)/g)){let e=n[0];if(e.length===0)continue;let r=e.length-e.trimStart().length,i=e.trim();if(i){let e=n.index+r;t.push({text:i,start:e,end:e+i.length})}}return t}function Cy(e,t){let n=(e.textContent??``).replace(/\s+/g,` `).trim();if(!n)return null;let r=Sy(n);return{type:t,el:e,spokenText:n,sentences:r.length?r:[{text:n,start:0,end:n.length}],highlightWhole:!1}}function wy(e,t,n){let r=n.trim();return r?{type:t,el:e,spokenText:r,sentences:[{text:r,start:0,end:r.length}],highlightWhole:!0}:null}function Ty(e,t,n){for(let r of Array.from(e.children)){let e=r.tagName;if(xy(r)){Ey(n,wy(r,`diagram`,t.diagramLabel));continue}if(e===`PRE`||e===`DIV`&&r.querySelector(`:scope > pre`)){Ey(n,t.readCode?Cy(r,`code`):wy(r,`code`,t.codeLabel));continue}if(e===`TABLE`){Ey(n,wy(r,`table`,t.tableLabel));continue}if(e===`IMG`||e===`FIGURE`&&r.querySelector(`img`)){let i=(e===`IMG`?r:r.querySelector(`img`))?.getAttribute(`alt`)?.trim()??``;Ey(n,wy(r,`image`,t.imageLabel.includes(`{alt}`)?i?t.imageLabel.replace(`{alt}`,i):t.imageLabel.replace(/:?\s*\{alt\}/,``).trim()||`Image.`:t.imageLabel));continue}if(by.has(e)){Ey(n,Cy(r,`heading`));continue}if(e===`P`){Ey(n,Cy(r,`paragraph`));continue}if(e===`LI`){Ey(n,Cy(r,`list-item`));continue}if(e===`BLOCKQUOTE`){r.querySelector(`:scope > p, :scope > ul, :scope > ol`)?Ty(r,t,n):Ey(n,Cy(r,`quote`));continue}if(e===`UL`||e===`OL`||e===`DIV`||e===`SECTION`||e===`DETAILS`){Ty(r,t,n);continue}}}function Ey(e,t){t&&e.push(t)}function Dy(e,t={}){let n={...yy,...t},r=[];return Ty(e,n,r),r}var Oy=`tts-sentence`;function ky(){if(typeof document>`u`||document.getElementById(`tts-highlight-style`))return;let e=document.createElement(`style`);e.id=`tts-highlight-style`,e.textContent=`::highlight(${Oy}){background-color:rgba(250,204,21,0.45);color:inherit;}.dark ::highlight(${Oy}){background-color:rgba(250,204,21,0.35);}`,document.head.appendChild(e)}function Ay(e,t,n){let r=[],i=!0,a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=a.nextNode();for(;o;){let e=o.data;for(let t=0;t<e.length;t++)/\s/.test(e[t])?i||=(r.push({node:o,offset:t}),!0):(r.push({node:o,offset:t}),i=!1);o=a.nextNode()}if(t>=r.length)return null;let s=r[t],c=document.createRange();if(c.setStart(s.node,s.offset),n<r.length){let e=r[n];c.setEnd(e.node,e.offset)}else{let e=r[r.length-1];c.setEnd(e.node,e.offset+1)}return c}var jy=new class{#e=P(`idle`);get status(){return V(this.#e)}set status(e){F(this.#e,e,!0)}#t=P(-1);get index(){return V(this.#t)}set index(e){F(this.#t,e,!0)}#n=P(0);get total(){return V(this.#n)}set total(e){F(this.#n,e,!0)}#r=P(null);get error(){return V(this.#r)}set error(e){F(this.#r,e,!0)}units=[];ctx=null;source=null;cache=new Map;token=0;voice;speed;language=`en`;fallbackEl=null;get active(){return this.status===`playing`||this.status===`paused`||this.status===`loading`}async start(e,t={}){this.stop();let{voice:n,speed:r,language:i,...a}=t;this.voice=n,this.speed=r,this.language=i??`en`;let o=Dy(e,a);if(this.units=o.flatMap(e=>e.highlightWhole?[{seg:e,text:e.spokenText,start:0,end:e.spokenText.length,whole:!0}]:e.sentences.map(t=>({seg:e,text:t.text,start:t.start,end:t.end,whole:!1}))),this.total=this.units.length,this.units.length===0)return;this.ctx=new AudioContext,this.error=null;let s=++this.token;this.status=`loading`,await this.playFrom(0,s)}async playFrom(e,t){if(t!==this.token)return;if(e>=this.units.length){this.stop();return}this.index=e,this.highlight(this.units[e]);let n;try{n=await this.audioFor(e)}catch(e){if(t!==this.token)return;this.error=e instanceof Error?e.message:String(e),this.stop(!1);return}if(t!==this.token||!this.ctx)return;this.prefetch(e+1);let r=this.ctx.createBufferSource();r.buffer=n,r.connect(this.ctx.destination),r.onended=()=>{t===this.token&&(this.source=null,this.playFrom(e+1,t))},this.source=r,this.status=`playing`,r.start()}audioFor(e){let t=this.cache.get(e);return t||(t=this.fetchAudio(this.units[e].text),this.cache.set(e,t)),t}prefetch(e){e<this.units.length&&!this.cache.has(e)&&this.cache.set(e,this.fetchAudio(this.units[e].text).catch(e=>Promise.reject(e)))}async fetchAudio(e){let t=await fetch(`/api/tts`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,voice:this.voice,speed:this.speed,language:this.language})});if(!t.ok){let e=`HTTP ${t.status}`;try{e=(await t.json()).error||e}catch{}throw Error(e)}let n=await t.arrayBuffer();return this.ctx?.decodeAudioData(n)}pause(){this.status===`playing`&&this.ctx&&(this.ctx.suspend(),this.status=`paused`)}resume(){this.status===`paused`&&this.ctx&&(this.ctx.resume(),this.status=`playing`)}toggle(){this.status===`playing`?this.pause():this.status===`paused`&&this.resume()}stop(e=!0){if(this.token++,this.source){try{this.source.onended=null,this.source.stop()}catch{}this.source=null}this.ctx&&=(this.ctx.close(),null),this.cache.clear(),this.clearHighlight(),this.status=`idle`,this.index=-1,this.total=0,e&&(this.error=null)}highlight(e){ky(),this.clearHighlight();let t=typeof CSS<`u`&&`highlights`in CSS&&typeof Highlight<`u`;if(t&&!e.whole){let t=Ay(e.seg.el,e.start,e.end);t?CSS.highlights.set(Oy,new Highlight(t)):this.fallbackHighlight(e.seg.el)}else if(t){let t=document.createRange();t.selectNodeContents(e.seg.el),CSS.highlights.set(Oy,new Highlight(t))}else this.fallbackHighlight(e.seg.el);e.seg.el.scrollIntoView({block:`center`,behavior:`smooth`})}fallbackHighlight(e){e.classList.add(`tts-active`),this.fallbackEl=e}clearHighlight(){typeof CSS<`u`&&`highlights`in CSS&&CSS.highlights.delete(Oy),this.fallbackEl&&=(this.fallbackEl.classList.remove(`tts-active`),null)}},My=Symbol.for(`yaml.alias`),Ny=Symbol.for(`yaml.document`),Py=Symbol.for(`yaml.map`),Fy=Symbol.for(`yaml.pair`),Iy=Symbol.for(`yaml.scalar`),Ly=Symbol.for(`yaml.seq`),Ry=Symbol.for(`yaml.node.type`),zy=e=>!!e&&typeof e==`object`&&e[Ry]===My,By=e=>!!e&&typeof e==`object`&&e[Ry]===Ny,Vy=e=>!!e&&typeof e==`object`&&e[Ry]===Py,Hy=e=>!!e&&typeof e==`object`&&e[Ry]===Fy,Uy=e=>!!e&&typeof e==`object`&&e[Ry]===Iy,Wy=e=>!!e&&typeof e==`object`&&e[Ry]===Ly;function Gy(e){if(e&&typeof e==`object`)switch(e[Ry]){case Py:case Ly:return!0}return!1}function Ky(e){if(e&&typeof e==`object`)switch(e[Ry]){case My:case Py:case Iy:case Ly:return!0}return!1}var qy=e=>(Uy(e)||Gy(e))&&!!e.anchor,Jy=Symbol(`break visit`),Yy=Symbol(`skip children`),Xy=Symbol(`remove node`);function Zy(e,t){let n=tb(t);By(e)?Qy(null,e.contents,n,Object.freeze([e]))===Xy&&(e.contents=null):Qy(null,e,n,Object.freeze([]))}Zy.BREAK=Jy,Zy.SKIP=Yy,Zy.REMOVE=Xy;function Qy(e,t,n,r){let i=nb(e,t,n,r);if(Ky(i)||Hy(i))return rb(e,r,i),Qy(e,i,n,r);if(typeof i!=`symbol`){if(Gy(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=Qy(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===Jy)return Jy;else i===Xy&&(t.items.splice(e,1),--e)}}else if(Hy(t)){r=Object.freeze(r.concat(t));let e=Qy(`key`,t.key,n,r);if(e===Jy)return Jy;e===Xy&&(t.key=null);let i=Qy(`value`,t.value,n,r);if(i===Jy)return Jy;i===Xy&&(t.value=null)}}return i}async function $y(e,t){let n=tb(t);By(e)?await eb(null,e.contents,n,Object.freeze([e]))===Xy&&(e.contents=null):await eb(null,e,n,Object.freeze([]))}$y.BREAK=Jy,$y.SKIP=Yy,$y.REMOVE=Xy;async function eb(e,t,n,r){let i=await nb(e,t,n,r);if(Ky(i)||Hy(i))return rb(e,r,i),eb(e,i,n,r);if(typeof i!=`symbol`){if(Gy(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await eb(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===Jy)return Jy;else i===Xy&&(t.items.splice(e,1),--e)}}else if(Hy(t)){r=Object.freeze(r.concat(t));let e=await eb(`key`,t.key,n,r);if(e===Jy)return Jy;e===Xy&&(t.key=null);let i=await eb(`value`,t.value,n,r);if(i===Jy)return Jy;i===Xy&&(t.value=null)}}return i}function tb(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function nb(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(Vy(t))return n.Map?.(e,t,r);if(Wy(t))return n.Seq?.(e,t,r);if(Hy(t))return n.Pair?.(e,t,r);if(Uy(t))return n.Scalar?.(e,t,r);if(zy(t))return n.Alias?.(e,t,r)}function rb(e,t,n){let r=t[t.length-1];if(Gy(r))r.items[e]=n;else if(Hy(r))e===`key`?r.key=n:r.value=n;else if(By(r))r.contents=n;else{let e=zy(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var ib={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},ab=e=>e.replace(/[!,[\]{}]/g,e=>ib[e]),ob=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+ab(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&Ky(e.contents)){let t={};Zy(e.contents,(e,n)=>{Ky(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
|
|
118
|
-
`)}};
|
|
119
|
-
`)?
|
|
117
|
+
</div>`,t.appendChild(s),t.classList.remove(`hidden`);let c=s.querySelector(`#ld-local-search-input`),l=s.querySelector(`#ld-local-search-clear`),u=s.querySelector(`#ld-local-search-results`),d=s.querySelector(`#ld-local-search-title`),f=s.querySelector(`#ld-local-search-list`),p=null;function m(){e.querySelectorAll(`mark.ld-local-mark`).forEach(e=>{let t=e.parentNode;for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}),e.normalize()}function h(e,t){let n=new Set;t.includes(e)&&n.add(e);let r=xy(e.length);if(r===0)return n;let a=e[0];for(let t of i)t!==e&&(Math.abs(t.length-e.length)>r||e.length>=3&&t[0]!==a||by(e,t,r)<=r&&n.add(t));return n}function g(t){if(m(),!t){u.classList.add(`hidden`),l.classList.add(`hidden`),f.innerHTML=``;return}l.classList.remove(`hidden`);let r=yy(t),i=r.split(` `).filter(Boolean);if(!i.length){u.classList.add(`hidden`);return}let a=yy(e.textContent||``),o=i.map(e=>h(e,a));if(!o.some(e=>e.size>0)){d.textContent=n(`local_search.no_results`)||`No matches found.`,f.innerHTML=``,u.classList.remove(`hidden`);return}let s=new Set;o.forEach((e,t)=>{e.forEach(e=>{let n=e===i[t];s.add(n?e:`\\b${Cy(e)}\\b`)})});let c=Array.from(s).sort((e,t)=>t.length-e.length),p=RegExp(`(${c.map(e=>e.startsWith(`\\b`)?e:Cy(e)).join(`|`)})`,`g`),g=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){return e.parentElement?.closest(`mark`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),v=[];for(;g.nextNode();)v.push(g.currentNode);let y=0,b=new Map;v.forEach(e=>{let t=e.textContent||``,{normalized:n,map:r}=vy(t);if(!n)return;let i=[],a;for(p.lastIndex=0;(a=p.exec(n))!==null;){if(a[0].length===0){p.lastIndex++;continue}i.push({start:a.index,end:a.index+a[0].length,term:a[0]})}if(!i.length)return;let s=e.parentElement?.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre, blockquote`)||e.parentElement,c=``,l=0;i.forEach(e=>{let n=r[e.start],i=r[e.end];if(!(n<l)&&(c+=Sy(t.slice(l,n)),c+=`<mark class="ld-local-mark" id="ld-local-match-${y++}">${Sy(t.slice(n,i))}</mark>`,l=i,s)){b.has(s)||b.set(s,new Set);let t=b.get(s);o.forEach((n,r)=>{n.has(e.term)&&t.add(r)})}}),c+=Sy(t.slice(l));let u=document.createElement(`span`);u.innerHTML=c,e.parentNode?.replaceChild(u,e)});let x=i.length,S=[];for(let[e,t]of b.entries())t.size===x&&S.push(e);let C;if(S.length>0){let t=new Set(S);C=Array.from(e.querySelectorAll(`mark.ld-local-mark`)).filter(e=>{let n=e.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre, blockquote`)||e.parentElement;return t.has(n)})}else C=Array.from(e.querySelectorAll(`mark.ld-local-mark`));if(!C.length){d.textContent=n(`local_search.no_results`)||`No matches found.`,f.innerHTML=``,u.classList.remove(`hidden`);return}d.textContent=(C.length===1?n(`local_search.count_singular`)||`{count} match`:n(`local_search.count_plural`)||`{count} matches`).replace(`{count}`,String(C.length)),f.innerHTML=C.map((e,t)=>{let n=e.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre, blockquote`)||e.parentElement,i=(n?n.textContent||``:e.textContent||``).trim(),a=yy(i),s=-1;for(let e of o)for(let t of e){let e=a.indexOf(t);e>=0&&(s<0||e<s)&&(s=e)}s<0&&(s=a.indexOf(r.split(` `)[0])),s<0&&(s=0);let c=Math.max(0,s-40),l=Math.min(i.length,s+80),u=(c>0?`…`:``)+i.slice(c,l)+(l<i.length?`…`:``);return`<li><button type="button" data-target="${e.id}" class="ld-local-item w-full text-left px-3 py-1.5 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors text-xs"><span class="text-gray-400 font-mono mr-2">${t+1}.</span>${Sy(u)}</button></li>`}).join(``),u.classList.remove(`hidden`),f.querySelectorAll(`.ld-local-item`).forEach(e=>{e.addEventListener(`click`,()=>_(e.dataset.target))})}function _(t){let n=document.getElementById(t),r=document.getElementById(`home-content-area`);if(!n||!r)return;let i=n.parentElement;for(;i&&i!==r;)i.tagName===`DETAILS`&&!i.open&&(i.open=!0),i=i.parentElement;e.querySelectorAll(`mark.ld-local-mark.ld-local-active`).forEach(e=>e.classList.remove(`ld-local-active`)),n.classList.add(`ld-local-active`),f.querySelectorAll(`.ld-local-item`).forEach(e=>{e.classList.toggle(`ld-local-item-active`,e.dataset.target===t)});let a=document.querySelector(`#home-doc-view header`),o=a?a.getBoundingClientRect().height:0,s=n.getBoundingClientRect().top,c=r.getBoundingClientRect().top,l=o+(r.clientHeight-o)/3;r.scrollTop+=s-c-l}c.addEventListener(`input`,()=>{p&&clearTimeout(p),p=window.setTimeout(()=>g(c.value.trim()),250)}),l.addEventListener(`click`,()=>{c.value=``,g(``),c.focus()}),c.addEventListener(`keydown`,e=>{e.key===`Escape`&&(c.value=``,g(``),c.blur())})}var Ty={codeLabel:`Code block.`,imageLabel:`Image: {alt}.`,diagramLabel:`Diagram.`,tableLabel:`Table.`,readCode:!1},Ey=new Set([`H1`,`H2`,`H3`,`H4`,`H5`,`H6`]);function Dy(e){return e.classList.contains(`mermaid`)||e.querySelector(`.mermaid`)!==null}function Oy(e){let t=[];for(let n of e.matchAll(/[^.!?…\n]*(?:[.!?…]+|\n+|$)/g)){let e=n[0];if(e.length===0)continue;let r=e.length-e.trimStart().length,i=e.trim();if(i){let e=n.index+r;t.push({text:i,start:e,end:e+i.length})}}return t}function ky(e,t){let n=(e.textContent??``).replace(/\s+/g,` `).trim();if(!n)return null;let r=Oy(n);return{type:t,el:e,spokenText:n,sentences:r.length?r:[{text:n,start:0,end:n.length}],highlightWhole:!1}}function Ay(e,t,n){let r=n.trim();return r?{type:t,el:e,spokenText:r,sentences:[{text:r,start:0,end:r.length}],highlightWhole:!0}:null}function jy(e,t,n){for(let r of Array.from(e.children)){let e=r.tagName;if(Dy(r)){My(n,Ay(r,`diagram`,t.diagramLabel));continue}if(e===`PRE`||e===`DIV`&&r.querySelector(`:scope > pre`)){My(n,t.readCode?ky(r,`code`):Ay(r,`code`,t.codeLabel));continue}if(e===`TABLE`){My(n,Ay(r,`table`,t.tableLabel));continue}if(e===`IMG`||e===`FIGURE`&&r.querySelector(`img`)){let i=(e===`IMG`?r:r.querySelector(`img`))?.getAttribute(`alt`)?.trim()??``;My(n,Ay(r,`image`,t.imageLabel.includes(`{alt}`)?i?t.imageLabel.replace(`{alt}`,i):t.imageLabel.replace(/:?\s*\{alt\}/,``).trim()||`Image.`:t.imageLabel));continue}if(Ey.has(e)){My(n,ky(r,`heading`));continue}if(e===`P`){My(n,ky(r,`paragraph`));continue}if(e===`LI`){My(n,ky(r,`list-item`));continue}if(e===`BLOCKQUOTE`){r.querySelector(`:scope > p, :scope > ul, :scope > ol`)?jy(r,t,n):My(n,ky(r,`quote`));continue}if(e===`UL`||e===`OL`||e===`DIV`||e===`SECTION`||e===`DETAILS`){jy(r,t,n);continue}}}function My(e,t){t&&e.push(t)}function Ny(e,t={}){let n={...Ty,...t},r=[];return jy(e,n,r),r}var Py=`tts-sentence`;function Fy(){if(typeof document>`u`||document.getElementById(`tts-highlight-style`))return;let e=document.createElement(`style`);e.id=`tts-highlight-style`,e.textContent=`::highlight(${Py}){background-color:rgba(250,204,21,0.45);color:inherit;}.dark ::highlight(${Py}){background-color:rgba(250,204,21,0.35);}`,document.head.appendChild(e)}function Iy(e,t,n){let r=[],i=!0,a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=a.nextNode();for(;o;){let e=o.data;for(let t=0;t<e.length;t++)/\s/.test(e[t])?i||=(r.push({node:o,offset:t}),!0):(r.push({node:o,offset:t}),i=!1);o=a.nextNode()}if(t>=r.length)return null;let s=r[t],c=document.createRange();if(c.setStart(s.node,s.offset),n<r.length){let e=r[n];c.setEnd(e.node,e.offset)}else{let e=r[r.length-1];c.setEnd(e.node,e.offset+1)}return c}var Ly=new class{#e=P(`idle`);get status(){return V(this.#e)}set status(e){F(this.#e,e,!0)}#t=P(-1);get index(){return V(this.#t)}set index(e){F(this.#t,e,!0)}#n=P(0);get total(){return V(this.#n)}set total(e){F(this.#n,e,!0)}#r=P(null);get error(){return V(this.#r)}set error(e){F(this.#r,e,!0)}units=[];ctx=null;source=null;cache=new Map;token=0;voice;speed;language=`en`;fallbackEl=null;get active(){return this.status===`playing`||this.status===`paused`||this.status===`loading`}async start(e,t={}){this.stop();let{voice:n,speed:r,language:i,...a}=t;this.voice=n,this.speed=r,this.language=i??`en`;let o=Ny(e,a);if(this.units=o.flatMap(e=>e.highlightWhole?[{seg:e,text:e.spokenText,start:0,end:e.spokenText.length,whole:!0}]:e.sentences.map(t=>({seg:e,text:t.text,start:t.start,end:t.end,whole:!1}))),this.total=this.units.length,this.units.length===0)return;this.ctx=new AudioContext,this.error=null;let s=++this.token;this.status=`loading`,await this.playFrom(0,s)}async playFrom(e,t){if(t!==this.token)return;if(e>=this.units.length){this.stop();return}this.index=e,this.highlight(this.units[e]);let n;try{n=await this.audioFor(e)}catch(e){if(t!==this.token)return;this.error=e instanceof Error?e.message:String(e),this.stop(!1);return}if(t!==this.token||!this.ctx)return;this.prefetch(e+1);let r=this.ctx.createBufferSource();r.buffer=n,r.connect(this.ctx.destination),r.onended=()=>{t===this.token&&(this.source=null,this.playFrom(e+1,t))},this.source=r,this.status=`playing`,r.start()}audioFor(e){let t=this.cache.get(e);return t||(t=this.fetchAudio(this.units[e].text),this.cache.set(e,t)),t}prefetch(e){e<this.units.length&&!this.cache.has(e)&&this.cache.set(e,this.fetchAudio(this.units[e].text).catch(e=>Promise.reject(e)))}async fetchAudio(e){let t=await fetch(`/api/tts`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,voice:this.voice,speed:this.speed,language:this.language})});if(!t.ok){let e=`HTTP ${t.status}`;try{e=(await t.json()).error||e}catch{}throw Error(e)}let n=await t.arrayBuffer();return this.ctx?.decodeAudioData(n)}pause(){this.status===`playing`&&this.ctx&&(this.ctx.suspend(),this.status=`paused`)}resume(){this.status===`paused`&&this.ctx&&(this.ctx.resume(),this.status=`playing`)}toggle(){this.status===`playing`?this.pause():this.status===`paused`&&this.resume()}stop(e=!0){if(this.token++,this.source){try{this.source.onended=null,this.source.stop()}catch{}this.source=null}this.ctx&&=(this.ctx.close(),null),this.cache.clear(),this.clearHighlight(),this.status=`idle`,this.index=-1,this.total=0,e&&(this.error=null)}highlight(e){Fy(),this.clearHighlight();let t=typeof CSS<`u`&&`highlights`in CSS&&typeof Highlight<`u`;if(t&&!e.whole){let t=Iy(e.seg.el,e.start,e.end);t?CSS.highlights.set(Py,new Highlight(t)):this.fallbackHighlight(e.seg.el)}else if(t){let t=document.createRange();t.selectNodeContents(e.seg.el),CSS.highlights.set(Py,new Highlight(t))}else this.fallbackHighlight(e.seg.el);e.seg.el.scrollIntoView({block:`center`,behavior:`smooth`})}fallbackHighlight(e){e.classList.add(`tts-active`),this.fallbackEl=e}clearHighlight(){typeof CSS<`u`&&`highlights`in CSS&&CSS.highlights.delete(Py),this.fallbackEl&&=(this.fallbackEl.classList.remove(`tts-active`),null)}},Ry=Symbol.for(`yaml.alias`),zy=Symbol.for(`yaml.document`),By=Symbol.for(`yaml.map`),Vy=Symbol.for(`yaml.pair`),Hy=Symbol.for(`yaml.scalar`),Uy=Symbol.for(`yaml.seq`),Wy=Symbol.for(`yaml.node.type`),Gy=e=>!!e&&typeof e==`object`&&e[Wy]===Ry,Ky=e=>!!e&&typeof e==`object`&&e[Wy]===zy,qy=e=>!!e&&typeof e==`object`&&e[Wy]===By,Jy=e=>!!e&&typeof e==`object`&&e[Wy]===Vy,Yy=e=>!!e&&typeof e==`object`&&e[Wy]===Hy,Xy=e=>!!e&&typeof e==`object`&&e[Wy]===Uy;function Zy(e){if(e&&typeof e==`object`)switch(e[Wy]){case By:case Uy:return!0}return!1}function Qy(e){if(e&&typeof e==`object`)switch(e[Wy]){case Ry:case By:case Hy:case Uy:return!0}return!1}var $y=e=>(Yy(e)||Zy(e))&&!!e.anchor,eb=Symbol(`break visit`),tb=Symbol(`skip children`),nb=Symbol(`remove node`);function rb(e,t){let n=sb(t);Ky(e)?ib(null,e.contents,n,Object.freeze([e]))===nb&&(e.contents=null):ib(null,e,n,Object.freeze([]))}rb.BREAK=eb,rb.SKIP=tb,rb.REMOVE=nb;function ib(e,t,n,r){let i=cb(e,t,n,r);if(Qy(i)||Jy(i))return lb(e,r,i),ib(e,i,n,r);if(typeof i!=`symbol`){if(Zy(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=ib(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===eb)return eb;else i===nb&&(t.items.splice(e,1),--e)}}else if(Jy(t)){r=Object.freeze(r.concat(t));let e=ib(`key`,t.key,n,r);if(e===eb)return eb;e===nb&&(t.key=null);let i=ib(`value`,t.value,n,r);if(i===eb)return eb;i===nb&&(t.value=null)}}return i}async function ab(e,t){let n=sb(t);Ky(e)?await ob(null,e.contents,n,Object.freeze([e]))===nb&&(e.contents=null):await ob(null,e,n,Object.freeze([]))}ab.BREAK=eb,ab.SKIP=tb,ab.REMOVE=nb;async function ob(e,t,n,r){let i=await cb(e,t,n,r);if(Qy(i)||Jy(i))return lb(e,r,i),ob(e,i,n,r);if(typeof i!=`symbol`){if(Zy(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=await ob(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===eb)return eb;else i===nb&&(t.items.splice(e,1),--e)}}else if(Jy(t)){r=Object.freeze(r.concat(t));let e=await ob(`key`,t.key,n,r);if(e===eb)return eb;e===nb&&(t.key=null);let i=await ob(`value`,t.value,n,r);if(i===eb)return eb;i===nb&&(t.value=null)}}return i}function sb(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function cb(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(qy(t))return n.Map?.(e,t,r);if(Xy(t))return n.Seq?.(e,t,r);if(Jy(t))return n.Pair?.(e,t,r);if(Yy(t))return n.Scalar?.(e,t,r);if(Gy(t))return n.Alias?.(e,t,r)}function lb(e,t,n){let r=t[t.length-1];if(Zy(r))r.items[e]=n;else if(Jy(r))e===`key`?r.key=n:r.value=n;else if(Ky(r))r.contents=n;else{let e=Gy(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var ub={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},db=e=>e.replace(/[!,[\]{}]/g,e=>ub[e]),fb=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+db(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&Qy(e.contents)){let t={};rb(e.contents,(e,n)=>{Qy(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
|
|
118
|
+
`)}};fb.defaultYaml={explicit:!1,version:`1.2`},fb.defaultTags={"!!":`tag:yaml.org,2002:`};function pb(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function mb(e){let t=new Set;return rb(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function hb(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function gb(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i||=mb(e);let a=hb(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(Yy(t.node)||Zy(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function _b(e,t,n,r){if(r&&typeof r==`object`)if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=_b(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=_b(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=_b(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=_b(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}return e.call(t,n,r)}function vb(e,t,n){if(Array.isArray(e))return e.map((e,t)=>vb(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!$y(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var yb=class{constructor(e){Object.defineProperty(this,Wy,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Ky(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=vb(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?_b(i,{"":o},``,o):o}},bb=class extends yb{constructor(e){super(Ry),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e){let t;return rb(e,{Node:(e,n)=>{if(n===this)return rb.BREAK;n.anchor===this.source&&(t=n)}}),t}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(vb(a,null,t),n.get(a)),!o||o.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=xb(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(pb(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function xb(e,t,n){if(Gy(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(Zy(t)){let r=0;for(let i of t.items){let t=xb(e,i,n);t>r&&(r=t)}return r}else if(Jy(t)){let r=xb(e,t.key,n),i=xb(e,t.value,n);return Math.max(r,i)}return 1}var Sb=e=>!e||typeof e!=`function`&&typeof e!=`object`,Cb=class extends yb{constructor(e){super(Hy),this.value=e}toJSON(e,t){return t?.keep?this.value:vb(this.value,e,t)}toString(){return String(this.value)}};Cb.BLOCK_FOLDED=`BLOCK_FOLDED`,Cb.BLOCK_LITERAL=`BLOCK_LITERAL`,Cb.PLAIN=`PLAIN`,Cb.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Cb.QUOTE_SINGLE=`QUOTE_SINGLE`;var wb=`tag:yaml.org,2002:`;function Tb(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function Eb(e,t,n){if(Ky(e)&&(e=e.contents),Qy(e))return e;if(Jy(e)){let t=n.schema[By].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor||=i(e),new bb(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=wb+t.slice(2));let l=Tb(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new Cb(e);return c&&(c.node=t),t}l=e instanceof Map?o[By]:Symbol.iterator in Object(e)?o[Uy]:o[By]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new Cb(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function Db(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return Eb(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var Ob=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,kb=class extends yb{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>Qy(t)||Jy(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Ob(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(Zy(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Db(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(Zy(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&Yy(i)?i.value:i:Zy(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!Jy(t))return!1;let n=t.value;return n==null||e&&Yy(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return Zy(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(Zy(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,Db(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},Ab=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function jb(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Mb=(e,t,n)=>e.endsWith(`
|
|
119
|
+
`)?jb(n,t):n.includes(`
|
|
120
120
|
`)?`
|
|
121
|
-
`+
|
|
122
|
-
`)n===`block`&&(h=
|
|
121
|
+
`+jb(n,t):(e.endsWith(` `)?``:` `)+n,Nb=`flow`,Pb=`block`,Fb=`quoted`;function Ib(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=Lb(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
|
|
122
|
+
`)n===`block`&&(h=Lb(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
|
|
123
123
|
`&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
|
|
124
|
-
`&&t!==` `&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function
|
|
125
|
-
`);r=t,i=t+1,a=e[i]}return r}var
|
|
126
|
-
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function
|
|
124
|
+
`&&t!==` `&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function Lb(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
125
|
+
`);r=t,i=t+1,a=e[i]}return r}var Rb=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),zb=e=>/^(%|---|\.\.\.)/m.test(e);function Bb(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
|
|
126
|
+
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function Vb(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(zb(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
|
|
127
127
|
|
|
128
128
|
`;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
|
|
129
|
-
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:
|
|
130
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return
|
|
129
|
+
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:Ib(o,a,Fb,Rb(t,!1))}function Hb(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
130
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return Vb(e,t);let n=t.indent||(zb(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:Ib(r,n,Nb,Rb(t,!1))}function Ub(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=Vb;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?Hb:i&&!t?Vb:n?Hb:Vb}return r(e,t)}var Wb;try{Wb=RegExp(`(^|(?<!
|
|
131
131
|
))
|
|
132
132
|
+(?!
|
|
133
|
-
|$)`,`g`)}catch{
|
|
133
|
+
|$)`,`g`)}catch{Wb=/\n+(?!\n|$)/g}function Gb({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n)||/^\s*$/.test(n))return Ub(n,r);let l=r.indent||(r.forceBlockIndent||zb(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===Cb.BLOCK_FOLDED?!1:t===Cb.BLOCK_LITERAL?!0:!Bb(n,c,l.length);if(!n)return u?`|
|
|
134
134
|
`:`>
|
|
135
135
|
`;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
|
|
136
136
|
`&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
|
|
137
137
|
`);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
|
|
138
|
-
`&&(p=p.slice(0,-1)),p.replace(
|
|
138
|
+
`&&(p=p.slice(0,-1)),p.replace(Wb,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
|
|
139
139
|
`)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(u?`|`:`>`)+(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),u)return n=n.replace(/\n+/g,`$&${l}`),`${y}\n${l}${v}${n}${p}`;n=n.replace(/\n+/g,`
|
|
140
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`);let b=
|
|
141
|
-
`)||u&&/[[\]{},]/.test(a))return
|
|
142
|
-
`)?
|
|
143
|
-
`))return
|
|
144
|
-
`:``,v){let e=l(v);S+=`\n${
|
|
140
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`);let b=Ib(`${v}${n}${p}`,l,Pb,Rb(r,!0));return`${y}\n${l}${b}`}function Kb(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
|
|
141
|
+
`)||u&&/[[\]{},]/.test(a))return Ub(a,t);if(!a||/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
|
|
142
|
+
`)?Ub(a,t):Gb(e,t,n,r);if(!s&&!u&&i!==Cb.PLAIN&&a.includes(`
|
|
143
|
+
`))return Gb(e,t,n,r);if(zb(a)){if(c===``)return t.forceBlockIndent=!0,Gb(e,t,n,r);if(s&&c===l)return Ub(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return Ub(a,t)}return s?d:Ib(d,c,Nb,Rb(t,!1))}function qb(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==Cb.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Cb.QUOTE_DOUBLE);let c=e=>{switch(e){case Cb.BLOCK_FOLDED:case Cb.BLOCK_LITERAL:return i||a?Ub(o.value,t):Gb(o,t,n,r);case Cb.QUOTE_DOUBLE:return Vb(o.value,t);case Cb.QUOTE_SINGLE:return Hb(o.value,t);case Cb.PLAIN:return Kb(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function Jb(e,t){let n=Object.assign({blockQuote:!0,commentString:Ab,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function Yb(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(Yy(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??typeof r;throw Error(`Tag not resolved for ${e} value`)}return n}function Xb(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(Yy(e)||Zy(e))&&e.anchor;a&&pb(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag?e.tag:t.default?null:t.tag;return o&&i.push(r.directives.tagString(o)),i.join(` `)}function Zb(e,t,n,r){if(Jy(e))return e.toString(t,n,r);if(Gy(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=Qy(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i||=Yb(t.doc.schema.tags,a);let o=Xb(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):Yy(a)?qb(a,t,n,r):a.toString(t,n,r);return o?Yy(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function Qb({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=Qy(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(Zy(e)||!Qy(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||Zy(e)||(Yy(e)?e.type===Cb.BLOCK_FOLDED||e.type===Cb.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=Zb(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=Mb(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=Mb(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=Mb(g,n.indent,l(f))));let _,v,y;Qy(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&Yy(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&Xy(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=Zb(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
|
|
144
|
+
`:``,v){let e=l(v);S+=`\n${jb(e,n.indent)}`}x===``&&!n.inFlow?S===`
|
|
145
145
|
`&&(S=`
|
|
146
146
|
|
|
147
|
-
`):S+=`\n${n.indent}`}else if(!p&&
|
|
147
|
+
`):S+=`\n${n.indent}`}else if(!p&&Zy(t)){let e=x[0],r=x.indexOf(`
|
|
148
148
|
`),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(S=`\n${n.indent}`)}}else(x===``||x[0]===`
|
|
149
|
-
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=
|
|
149
|
+
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=Mb(g,n.indent,l(y)):h&&i&&i(),g}function $b(e,t){(e===`debug`||e===`warn`)&&(typeof process<`u`&&process.emitWarning?process.emitWarning(t):console.warn(t))}var ex=`<<`;function tx(e,t,{key:n,value:r}){if(e?.doc.schema.merge&&nx(n))if(r=Gy(r)?r.resolve(e.doc):r,Xy(r))for(let n of r.items)rx(e,t,n);else if(Array.isArray(r))for(let n of r)rx(e,t,n);else rx(e,t,r);else{let i=vb(n,``,e);if(t instanceof Map)t.set(i,vb(r,i,e));else if(t instanceof Set)t.add(i);else{let a=ix(n,i,e),o=vb(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}var nx=e=>e===ex||Yy(e)&&e.value===ex&&(!e.type||e.type===Cb.PLAIN);function rx(e,t,n){let r=e&&Gy(n)?n.resolve(e.doc):n;if(!qy(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function ix(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(Qy(e)&&n?.doc){let t=Jb(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),$b(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function ax(e,t,n){return new ox(Eb(e,void 0,n),Eb(t,void 0,n))}var ox=class e{constructor(e,t=null){Object.defineProperty(this,Wy,{value:Vy}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return Qy(n)&&(n=n.clone(t)),Qy(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return tx(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?Qb(this,e,t,n):JSON.stringify(this)}};function sx(e,t,n){return(t.inFlow??e.flow?lx:cx)(e,t,n)}function cx({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(Qy(i))!d&&i.spaceBefore&&f.push(``),ux(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(Jy(i)){let e=Qy(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),ux(n,f,e.commentBefore,d))}d=!1;let s=Zb(i,u,()=>o=null,()=>d=!0);o&&(s+=Mb(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
|
|
150
150
|
`}}return e?(p+=`
|
|
151
|
-
`+
|
|
151
|
+
`+jb(l(e),c),s&&s()):d&&o&&o(),p}function lx({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(Qy(i))i.spaceBefore&&d.push(``),ux(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(Jy(i)){let e=Qy(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),ux(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=Qy(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=Zb(i,c,()=>a=null);n<e.length-1&&(o+=`,`),a&&(o+=Mb(o,r,s(a))),!l&&(d.length>u||o.includes(`
|
|
152
152
|
`))&&(l=!0),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
|
|
153
|
-
`;return`${e}\n${i}${p}`}else return`${f}${o}${d.join(` `)}${o}${p}`}function
|
|
154
|
-
`:` `)}return
|
|
155
|
-
`)?(n.push(`...`),n.push(
|
|
153
|
+
`;return`${e}\n${i}${p}`}else return`${f}${o}${d.join(` `)}${o}${p}`}function ux({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=jb(t(r),e);n.push(i.trimStart())}}function dx(e,t){let n=Yy(t)?t.value:t;for(let r of e)if(Jy(r)&&(r.key===t||r.key===n||Yy(r.key)&&r.key.value===n))return r}var fx=class extends kb{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(By,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(ax(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=Jy(e)?e:!e||typeof e!=`object`||!(`key`in e)?new ox(e,e?.value):new ox(e.key,e.value);let r=dx(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);Yy(r.value)&&Sb(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=dx(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=dx(this.items,e)?.value;return(!t&&Yy(n)?n.value:n)??void 0}has(e){return!!dx(this.items,e)}set(e,t){this.add(new ox(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)tx(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!Jy(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),sx(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},px={collection:`map`,default:!0,nodeClass:fx,tag:`tag:yaml.org,2002:map`,resolve(e,t){return qy(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>fx.from(e,t,n)},mx=class extends kb{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(Uy,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=hx(e);return typeof t==`number`?this.items.splice(t,1).length>0:!1}get(e,t){let n=hx(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&Yy(r)?r.value:r}has(e){let t=hx(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=hx(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];Yy(r)&&Sb(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(vb(e,String(r++),t));return n}toString(e,t,n){return e?sx(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(Eb(a,void 0,n))}}return i}};function hx(e){let t=Yy(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var gx={collection:`seq`,default:!0,nodeClass:mx,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return Xy(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>mx.from(e,t,n)},_x={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),qb(e,t,n,r)}},vx={identify:e=>e==null,createNode:()=>new Cb(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Cb(null),stringify:({source:e},t)=>typeof e==`string`&&vx.test.test(e)?e:t.options.nullStr},yx={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Cb(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&yx.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function bx({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^\d/.test(a)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var xx={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:bx},Sx={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():bx(e)}},Cx={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new Cb(parseFloat(e)),n=e.indexOf(`.`);return n!==-1&&e[e.length-1]===`0`&&(t.minFractionDigits=e.length-n-1),t},stringify:bx},wx=e=>typeof e==`bigint`||Number.isInteger(e),Tx=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function Ex(e,t,n){let{value:r}=e;return wx(r)&&r>=0?n+r.toString(t):bx(e)}var Dx={identify:e=>wx(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>Tx(e,2,8,n),stringify:e=>Ex(e,8,`0o`)},Ox={identify:wx,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>Tx(e,0,10,n),stringify:bx},kx={identify:e=>wx(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>Tx(e,2,16,n),stringify:e=>Ex(e,16,`0x`)},Ax=[px,gx,_x,vx,yx,Dx,Ox,kx,xx,Sx,Cx];function jx(e){return typeof e==`bigint`||Number.isInteger(e)}var Mx=({value:e})=>JSON.stringify(e),Nx=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:Mx},{identify:e=>e==null,createNode:()=>new Cb(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:Mx},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true|false$/,resolve:e=>e===`true`,stringify:Mx},{identify:jx,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>jx(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Mx}],Px=[px,gx].concat(Nx,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}}),Fx={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,t){if(typeof Buffer==`function`)return Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}else return t(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:t,value:n},r,i,a){let o=n,s;if(typeof Buffer==`function`)s=o instanceof Buffer?o.toString(`base64`):Buffer.from(o.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<o.length;++t)e+=String.fromCharCode(o[t]);s=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(t||=Cb.BLOCK_LITERAL,t!==Cb.QUOTE_DOUBLE){let e=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),n=Math.ceil(s.length/e),i=Array(n);for(let t=0,r=0;t<n;++t,r+=e)i[t]=s.substr(r,e);s=i.join(t===Cb.BLOCK_LITERAL?`
|
|
154
|
+
`:` `)}return qb({comment:e,type:t,value:s},r,i,a)}};function Ix(e,t){if(Xy(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!Jy(r)){if(qy(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new ox(new Cb(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=Jy(r)?r:new ox(r)}}else t(`Expected a sequence for this tag`);return e}function Lx(e,t,n){let{replacer:r}=n,i=new mx(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e))if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(ax(o,s,n))}return i}var Rx={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:Ix,createNode:Lx},zx=class e extends mx{constructor(){super(),this.add=fx.prototype.add.bind(this),this.delete=fx.prototype.delete.bind(this),this.get=fx.prototype.get.bind(this),this.has=fx.prototype.has.bind(this),this.set=fx.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(Jy(e)?(r=vb(e.key,``,t),i=vb(e.value,r,t)):r=vb(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=Lx(e,t,n),i=new this;return i.items=r.items,i}};zx.tag=`tag:yaml.org,2002:omap`;var Bx={collection:`seq`,identify:e=>e instanceof Map,nodeClass:zx,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=Ix(e,t),r=[];for(let{key:e}of n.items)Yy(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new zx,n)},createNode:(e,t,n)=>zx.from(e,t,n)};function Vx({value:e,source:t},n){return t&&(e?Hx:Ux).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var Hx={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Cb(!0),stringify:Vx},Ux={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Cb(!1),stringify:Vx},Wx={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:bx},Gx={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():bx(e)}},Kx={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Cb(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:bx},qx=e=>typeof e==`bigint`||Number.isInteger(e);function Jx(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function Yx(e,t,n){let{value:r}=e;if(qx(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return bx(e)}var Xx={identify:qx,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>Jx(e,2,2,n),stringify:e=>Yx(e,2,`0b`)},Zx={identify:qx,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>Jx(e,1,8,n),stringify:e=>Yx(e,8,`0`)},Qx={identify:qx,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>Jx(e,0,10,n),stringify:bx},$x={identify:qx,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>Jx(e,2,16,n),stringify:e=>Yx(e,16,`0x`)},eS=class e extends fx{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=Jy(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new ox(e.key,null):new ox(e,null),dx(this.items,t.key)||this.items.push(t)}get(e,t){let n=dx(this.items,e);return!t&&Jy(n)?Yy(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=dx(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new ox(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(ax(e,null,n));return i}};eS.tag=`tag:yaml.org,2002:set`;var tS={collection:`map`,identify:e=>e instanceof Set,nodeClass:eS,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>eS.from(e,t,n),resolve(e,t){if(qy(e)){if(e.hasAllNullValues(!0))return Object.assign(new eS,e);t(`Set items must all have null values`)}else t(`Expected a mapping for this tag`);return e}};function nS(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function rS(e){let{value:t}=e,n=e=>e;if(typeof t==`bigint`)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return bx(e);let r=``;t<0&&(r=`-`,t*=n(-1));let i=n(60),a=[t%i];return t<60?a.unshift(0):(t=(t-a[0])/i,a.unshift(t%i),t>=60&&(t=(t-a[0])/i,a.unshift(t))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}var iS={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>nS(e,n),stringify:rS},aS={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>nS(e,!1),stringify:rS},oS={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(oS.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,i,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+`00`).substr(1,3)):0,l=Date.UTC(n,r-1,i,a||0,o||0,s||0,c),u=t[8];if(u&&u!==`Z`){let e=nS(u,!1);Math.abs(e)<30&&(e*=60),l-=6e4*e}return new Date(l)},stringify:({value:e})=>e.toISOString().replace(/((T00:00)?:00)?\.000Z$/,``)},sS=[px,gx,_x,vx,Hx,Ux,Xx,Zx,Qx,$x,Wx,Gx,Kx,Fx,Bx,Rx,tS,iS,aS,oS],cS=new Map([[`core`,Ax],[`failsafe`,[px,gx,_x]],[`json`,Px],[`yaml11`,sS],[`yaml-1.1`,sS]]),lS={binary:Fx,bool:yx,float:Cx,floatExp:Sx,floatNaN:xx,floatTime:aS,int:Ox,intHex:kx,intOct:Dx,intTime:iS,map:px,null:vx,omap:Bx,pairs:Rx,seq:gx,set:tS,timestamp:oS},uS={"tag:yaml.org,2002:binary":Fx,"tag:yaml.org,2002:omap":Bx,"tag:yaml.org,2002:pairs":Rx,"tag:yaml.org,2002:set":tS,"tag:yaml.org,2002:timestamp":oS};function dS(e,t){let n=cS.get(t);if(!n)if(Array.isArray(e))n=[];else{let e=Array.from(cS.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)n=n.concat(t);else typeof e==`function`&&(n=e(n.slice()));return n.map(e=>{if(typeof e!=`string`)return e;let t=lS[e];if(t)return t;let n=Object.keys(lS).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag "${e}"; use one of ${n}`)})}var fS=(e,t)=>e.key<t.key?-1:+(e.key>t.key),pS=class e{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?dS(e,`compat`):e?dS(null,e):null,this.merge=!!n,this.name=typeof i==`string`&&i||`core`,this.knownTags=r?uS:{},this.tags=dS(t,this.name),this.toStringOptions=o??null,Object.defineProperty(this,By,{value:px}),Object.defineProperty(this,Hy,{value:_x}),Object.defineProperty(this,Uy,{value:gx}),this.sortMapEntries=typeof a==`function`?a:a===!0?fS:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function mS(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(n.push(t),r=!0):e.directives.docStart&&(r=!0)}r&&n.push(`---`);let i=Jb(e,t),{commentString:a}=i.options;if(e.commentBefore){n.length!==1&&n.unshift(``);let t=a(e.commentBefore);n.unshift(jb(t,``))}let o=!1,s=null;if(e.contents){if(Qy(e.contents)){if(e.contents.spaceBefore&&r&&n.push(``),e.contents.commentBefore){let t=a(e.contents.commentBefore);n.push(jb(t,``))}i.forceBlockIndent=!!e.comment,s=e.contents.comment}let t=s?void 0:()=>o=!0,c=Zb(e.contents,i,()=>s=null,t);s&&(c+=Mb(c,``,a(s))),(c[0]===`|`||c[0]===`>`)&&n[n.length-1]===`---`?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(Zb(e.contents,i));if(e.directives?.docEnd)if(e.comment){let t=a(e.comment);t.includes(`
|
|
155
|
+
`)?(n.push(`...`),n.push(jb(t,``))):n.push(`... ${t}`)}else n.push(`...`);else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(jb(a(t),``)))}return n.join(`
|
|
156
156
|
`)+`
|
|
157
|
-
`}var
|
|
158
|
-
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t&&t.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function
|
|
159
|
-
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(
|
|
160
|
-
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||
|
|
161
|
-
`+_.comment:g.comment=_.comment);let e=new
|
|
162
|
-
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&
|
|
163
|
-
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],
|
|
164
|
-
`+_.comment:g.comment=_.comment);let y=new
|
|
165
|
-
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function
|
|
157
|
+
`}var hS=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Wy,{value:zy});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new fb({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[Wy]:{value:zy}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=Qy(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){gS(this.contents)&&this.contents.add(e)}addIn(e,t){gS(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=mb(this);e.anchor=!t||n.has(t)?hb(t||`a`,n):t}return new bb(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=gb(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=Eb(e,l,p);return o&&Zy(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new ox(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return gS(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Ob(e)?this.contents==null?!1:(this.contents=null,!0):gS(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Zy(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Ob(e)?!t&&Yy(this.contents)?this.contents.value:this.contents:Zy(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Zy(this.contents)?this.contents.has(e):!1}hasIn(e){return Ob(e)?this.contents!==void 0:Zy(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Db(this.schema,[e],t):gS(this.contents)&&this.contents.set(e,t)}setIn(e,t){Ob(e)?this.contents=t:this.contents==null?this.contents=Db(this.schema,Array.from(e),t):gS(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new fb({version:`1.1`}),n={merge:!0,resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new fb({version:e}),n={merge:!1,resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new pS(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=vb(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?_b(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return mS(this,e)}};function gS(e){if(Zy(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var _S=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},vS=class extends _S{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},yS=class extends _S{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},bS=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
|
|
158
|
+
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t&&t.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function xS(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:c=!0:f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x===null&&(x=i.offset),l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x===null&&(x=i.offset),l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function SS(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
|
|
159
|
+
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(SS(t.key)||SS(t.value))return!0}return!1;default:return!0}}function CS(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&SS(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function wS(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(t,n)=>t===n||Yy(t)&&Yy(n)&&t.value===n.value&&!(t.value===`<<`&&e.schema.merge);return t.some(e=>i(e.key,n))}var TS=`All mapping items must start at the same column`;function ES({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??fx)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=xS(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,TS)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
|
|
160
|
+
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||SS(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,TS);let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&CS(r.indent,u,i),wS(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=xS(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&CS(r.indent,f,i),s=c.range[2];let l=new ox(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
|
|
161
|
+
`+_.comment:g.comment=_.comment);let e=new ox(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function DS({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??mx)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=xS(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||l)l&&l.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&CS(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function OS(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var kS=`Block collections are not allowed within flow collections`,AS=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function jS({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?fx:mx))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1);let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=xS(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
|
|
162
|
+
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&SS(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];Jy(t)&&(t=t.value??t.key),t.comment?t.comment+=`
|
|
163
|
+
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],AS(m)&&i(r.range,`BLOCK_IN_FLOW`,kS)}else{let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);AS(f)&&i(g.range,`BLOCK_IN_FLOW`,kS);let _=xS(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source&&m.source[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?AS(m)&&i(v.range,`BLOCK_IN_FLOW`,kS):_.comment&&(g.comment?g.comment+=`
|
|
164
|
+
`+_.comment:g.comment=_.comment);let y=new ox(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;wS(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new fx(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f&&f.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=OS(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
|
|
165
|
+
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function MS(e,t,n,r,i,a){let o=n.type===`block-map`?ES(e,t,n,r,a):n.type===`block-seq`?DS(e,t,n,r,a):jS(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function NS(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===fx.tagName&&s===`map`||o===mx.tagName&&s===`seq`)return MS(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r&&r.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?.collection?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),MS(e,t,n,i,o)}let l=MS(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=Qy(u)?u:new Cb(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function PS(e,t,n){let r=t.offset,i=FS(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?Cb.BLOCK_FOLDED:Cb.BLOCK_LITERAL,o=t.source?IS(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
|
|
166
166
|
`.repeat(Math.max(1,o.length-1)):``,n=r+i.length;return t.source&&(n+=t.source.length),{value:e,type:a,comment:i.comment,range:[r,n,n]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let t=0;t<s;++t){let[r,a]=o[t];if(a===``||a===`\r`)i.indent===0&&r.length>c&&(c=r.length);else{r.length<c&&n(l+r.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),i.indent===0&&(c=r.length),u=t,c===0&&!e.atRoot&&n(l,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}l+=r.length+a.length+1}for(let e=o.length-1;e>=s;--e)o[e][0].length>c&&(s=e+1);let d=``,f=``,p=!1;for(let e=0;e<u;++e)d+=o[e][0].slice(c)+`
|
|
167
|
-
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===
|
|
167
|
+
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===Cb.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
|
|
168
168
|
`):t.length>c||r[0]===` `?(f===` `?f=`
|
|
169
169
|
`:!p&&f===`
|
|
170
170
|
`&&(f=`
|
|
@@ -177,51 +177,51 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
177
177
|
`+o[e][0].slice(c);d[d.length-1]!==`
|
|
178
178
|
`&&(d+=`
|
|
179
179
|
`);break;default:d+=`
|
|
180
|
-
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function
|
|
180
|
+
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function FS({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function IS(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function LS(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=Cb.PLAIN,c=RS(a,l);break;case`single-quoted-scalar`:s=Cb.QUOTE_SINGLE,c=zS(a,l);break;case`double-quoted-scalar`:s=Cb.QUOTE_DOUBLE,c=VS(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=OS(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function RS(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`;break}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),BS(e)}function zS(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),BS(e.slice(1,-1)).replace(/''/g,`'`)}function BS(e){let t,n;try{t=RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
181
181
|
`,`sy`),n=RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
182
182
|
`,`sy`)}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=t.exec(e);if(!r)return e;let i=r[1],a=` `,o=t.lastIndex;for(n.lastIndex=o;r=n.exec(e);)r[1]===``?a===`
|
|
183
183
|
`?i+=a:a=`
|
|
184
|
-
`:(i+=a+r[1],a=` `),o=n.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(e),i+a+(r?.[1]??``)}function
|
|
184
|
+
`:(i+=a+r[1],a=` `),o=n.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(e),i+a+(r?.[1]??``)}function VS(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(!(i===`\r`&&e[r+1]===`
|
|
185
185
|
`))if(i===`
|
|
186
|
-
`){let{fold:t,offset:i}=
|
|
186
|
+
`){let{fold:t,offset:i}=HS(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=US[i];if(a)n+=a;else if(i===`
|
|
187
187
|
`)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
|
|
188
|
-
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a={x:2,u:4,U:8}[i];n+=
|
|
188
|
+
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a={x:2,u:4,U:8}[i];n+=WS(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
|
|
189
189
|
`&&!(a===`\r`&&e[r+2]===`
|
|
190
|
-
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function
|
|
190
|
+
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function HS(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
|
|
191
191
|
`||r===`\r`)&&!(r===`\r`&&e[t+2]!==`
|
|
192
192
|
`);)r===`
|
|
193
193
|
`&&(n+=`
|
|
194
|
-
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var
|
|
195
|
-
`,r:`\r`,t:` `,v:`\v`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function
|
|
194
|
+
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var US={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
|
|
195
|
+
`,r:`\r`,t:` `,v:`\v`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function WS(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(a)){let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}return String.fromCodePoint(a)}function GS(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?PS(e,t,r):LS(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l=n&&c?KS(e.schema,i,c,n,r):t.type===`scalar`?qS(e,i,t,r):e.schema[Hy],u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=Yy(a)?a:new Cb(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new Cb(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function KS(e,t,n,r,i){if(n===`!`)return e[Hy];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n)if(t.default&&t.test)a.push(t);else return t;for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[Hy])}function qS({directives:e,schema:t},n,r,i){let a=t.tags.find(e=>e.default&&e.test?.test(n))||t[Hy];if(t.compat){let o=t.compat.find(e=>e.default&&e.test?.test(n))??t[Hy];a.tag!==o.tag&&i(r,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${e.tagString(a.tag)} or ${e.tagString(o.tag)}`,!0)}return a}function JS(e,t,n){if(t){n===null&&(n=t.length);for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var YS={composeNode:XS,composeEmptyNode:ZS};function XS(e,t,n,r){let{spaceBefore:i,comment:a,anchor:o,tag:s}=n,c,l=!0;switch(t.type){case`alias`:c=QS(e,t,r),(o||s)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:c=GS(e,t,s,r),o&&(c.anchor=o.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:c=NS(YS,e,t,n,r),o&&(c.anchor=o.source.substring(1));break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),c=ZS(e,t.offset,void 0,null,n,r),l=!1}return o&&c.anchor===``&&r(o,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&(c.spaceBefore=!0),a&&(t.type===`scalar`&&t.source===``?c.comment=a:c.commentBefore=a),e.options.keepSourceTokens&&l&&(c.srcToken=t),c}function ZS(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=GS(e,{type:`scalar`,offset:JS(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function QS({options:e},{offset:t,source:n,end:r},i){let a=new bb(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=OS(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function $S(e,t,{offset:n,start:r,value:i,end:a},o){let s=new hS(void 0,Object.assign({_directives:t},e)),c={atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=xS(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?XS(c,i,l,o):ZS(c,l.end,r,null,l,o);let u=s.contents.range[2],d=OS(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function eC(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function tC(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
|
|
196
196
|
|
|
197
197
|
`:`
|
|
198
|
-
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var
|
|
198
|
+
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var nC=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=eC(e);r?this.warnings.push(new yS(i,t,n)):this.errors.push(new vS(i,t,n))},this.directives=new fb({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=tC(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(Zy(i)&&!i.flow&&i.items.length>0){let e=i.items[0];Jy(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:tC(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=eC(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=$S(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new vS(eC(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new vS(eC(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=OS(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new vS(eC(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new hS(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},rC=Symbol(`break visit`),iC=Symbol(`skip children`),aC=Symbol(`remove item`);function oC(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),sC(Object.freeze([]),e,t)}oC.BREAK=rC,oC.SKIP=iC,oC.REMOVE=aC,oC.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},oC.parentCollection=(e,t)=>{let n=oC.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function sC(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=sC(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===rC)return rC;else r===aC&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function cC(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
|
|
199
199
|
`:case`\r
|
|
200
|
-
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function
|
|
201
|
-
`:case`\r`:case` `:return!0;default:return!1}}var
|
|
202
|
-
\r `),
|
|
200
|
+
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function lC(e){switch(e){case void 0:case` `:case`
|
|
201
|
+
`:case`\r`:case` `:return!0;default:return!1}}var uC=new Set(`0123456789ABCDEFabcdef`),dC=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),fC=new Set(`,[]{}`),pC=new Set(` ,[]{}
|
|
202
|
+
\r `),mC=e=>!e||pC.has(e),hC=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
|
|
203
203
|
`?!0:t===`\r`?this.buffer[e+1]===`
|
|
204
204
|
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
|
|
205
205
|
`||!t&&!this.atEnd)return e+n+1}return t===`
|
|
206
|
-
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&
|
|
207
|
-
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}else n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&
|
|
206
|
+
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&lC(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
207
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}else n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&lC(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!lC(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&lC(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,yield*this.parseBlockStart()}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(mC),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&lC(r[3]))&&!(n===this.indentNext-1&&this.flowLevel===1&&(r[0]===`]`||r[0]===`}`)))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(mC),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||lC(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
|
|
208
208
|
`,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
|
|
209
|
-
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>
|
|
209
|
+
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>lC(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
|
|
210
210
|
`:e=r,t=0;break;case`\r`:{let e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
|
|
211
211
|
`)break}default:break loop}if(!n&&!this.atEnd)return this.setNext(`block-scalar`);if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
|
|
212
212
|
`,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===` `;)n=this.buffer[++r];if(n===` `){for(;n===` `||n===` `||n===`\r`||n===`
|
|
213
213
|
`;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let n=e-1,r=this.buffer[n];r===`\r`&&(r=this.buffer[--n]);let i=n;for(;r===` `;)r=this.buffer[--n];if(r===`
|
|
214
|
-
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(!0);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(
|
|
214
|
+
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(!0);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(lC(r)||e&&fC.has(r))break;t=n}else if(lC(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
|
|
215
215
|
`?(n+=1,r=`
|
|
216
|
-
`,i=this.buffer[n+1]):t=n),i===`#`||e&&
|
|
217
|
-
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&
|
|
216
|
+
`,i=this.buffer[n+1]):t=n),i===`#`||e&&fC.has(i))break;if(r===`
|
|
217
|
+
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&fC.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){switch(this.charAt(0)){case`!`:return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`&`:return(yield*this.pushUntil(mC))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`-`:case`?`:case`:`:{let e=this.flowLevel>0,t=this.charAt(1);if(lC(t)||e&&fC.has(t))return e?this.flowKey&&=!1:this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!lC(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(dC.has(t))t=this.buffer[++e];else if(t===`%`&&uC.has(this.buffer[e+1])&&uC.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
218
218
|
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
|
|
219
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},
|
|
219
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},gC=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function _C(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function vC(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function yC(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function bC(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function xC(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function SC(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!_C(t.start,`explicit-key-ind`)&&!_C(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,yC(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}var CC=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new hC,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=cC(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&(!e||e.type!==`doc-end`)){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&SC(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&vC(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:vC(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=xC(bC(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
|
|
220
220
|
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
221
|
-
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(
|
|
221
|
+
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(_C(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=xC(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(_C(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(yC(t.key)&&!_C(t.sep,`newline`)){let e=xC(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):_C(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let t=this.startBlockValue(e);if(t){n&&t.type!==`block-seq`&&e.items.push({start:i}),this.stack.push(t);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||_C(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e&&e.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=xC(bC(t));SC(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
|
|
222
222
|
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
223
|
-
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=
|
|
224
|
-
`)}\n---\n`+e.slice(r.length)}var PC=e=>e.normalize(`NFC`).normalize(`NFD`).replace(/[̀-ͯ]/g,``).toLowerCase();function FC(e,t){let n=PC(t);if(!n)return[];let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=[];for(;r.nextNode();)i.push(r.currentNode);let a=0;i.forEach(e=>{let t=(e.textContent||``).normalize(`NFC`),r=PC(t);if(!r.includes(n))return;let i=``,o=0;for(;o<=r.length;){let e=r.indexOf(n,o);if(e===-1){i+=t.slice(o);break}i+=t.slice(o,e),i+=`<mark id="match-${a++}">${t.slice(e,e+n.length)}</mark>`,o=e+n.length}let s=document.createElement(`span`);s.innerHTML=i,e.parentNode?.replaceChild(s,e)});let o=[];return e.querySelectorAll(`mark[id^='match-']`).forEach(e=>{let r=((e.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre`)||e.parentElement).textContent||``).trim(),i=PC(r).indexOf(n),a=Math.max(0,i-40),s=Math.min(r.length,i+t.length+40),c=(a>0?`…`:``)+r.slice(a,s)+(s<r.length?`…`:``);o.push({id:e.id,snippet:c})}),o}function IC(e){let t=document.getElementById(e),n=document.getElementById(`home-content-area`);if(!t||!n)return;let r=t.parentElement;for(;r&&r!==n;)r.tagName===`DETAILS`&&!r.open&&(r.open=!0),r=r.parentElement;document.querySelectorAll(`mark.match-active`).forEach(e=>{e.classList.remove(`match-active`)}),t.classList.add(`match-active`);let i=document.querySelector(`#home-doc-view header`),a=i?i.getBoundingClientRect().height:0,o=t.getBoundingClientRect().top,s=n.getBoundingClientRect().top,c=a+(n.clientHeight-a)/3;n.scrollTop+=o-s-c}var LC=U(`<span class="inline-block text-xs font-semibold px-2.5 py-0.5 rounded-full bg-violet-100 text-violet-700 dark:bg-violet-900/40 dark:text-violet-300"> </span>`),RC=U(`<span class="text-xs text-gray-400 dark:text-gray-500"> </span>`),zC=U(`<button type="button" data-testid="copy-doc-id-btn"><i aria-hidden="true"></i></button>`),BC=U(`<span class="inline-block text-[11px] px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 border border-gray-200 dark:border-gray-700"> </span>`),VC=U(`<div class="mt-1.5 flex items-center gap-1.5 flex-wrap" data-testid="doc-tags"></div>`),HC=U(`<span> </span>`),UC=U(`<div data-testid="edit-actions" class="flex items-center gap-2"><!> <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"> </button> <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"> </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"> </button></div>`),WC=U(`<button data-testid="validate-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-green-700 bg-green-600 text-white font-semibold hover:bg-green-700 transition-colors"><i class="fa-solid fa-check" style="margin-right:4px"></i> </button>`),GC=U(`<button data-testid="tts-toggle" class="no-print text-sm px-3 py-1.5 rounded-lg border border-blue-300 dark:border-blue-700 bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 hover:bg-blue-100 dark:hover:bg-blue-900/50 transition-colors"><i></i></button> <button data-testid="tts-stop" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-stop"></i></button>`,1),KC=U(`<button data-testid="tts-play" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-headphones" style="margin-right:4px"></i> </button>`),qC=Hr(`<g><line x1="8" y1="8" x2="92" y2="92" stroke="currentColor" stroke-width="8" stroke-linecap="round"></line><line x1="92" y1="8" x2="8" y2="92" stroke="currentColor" stroke-width="8" stroke-linecap="round"></line></g>`),JC=U(`<button data-testid="versions-btn" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-code-branch"></i> </button>`),YC=U(`<!> <button data-testid="marker-doc-btn"><svg width="18" height="18" viewBox="0 0 100 100" fill="none" style="display:inline-block;vertical-align:middle;margin-right:4px"><rect x="28" y="10" width="44" height="52" rx="6" transform="rotate(40 50 50)" stroke="currentColor" stroke-width="6"></rect><rect x="52" y="8" width="22" height="30" rx="6" transform="rotate(40 50 50)" stroke="currentColor" stroke-width="6"></rect><polygon points="28,60 10,80 30,80 38,72" stroke="currentColor" stroke-width="5" stroke-linejoin="round"></polygon><polygon points="28,48 19,70 36,75 55,70" stroke="currentColor" stroke-width="5" stroke-linejoin="round"></polygon><line x1="10" y1="90" x2="72" y2="90" stroke="currentColor" stroke-width="6" stroke-linecap="round"></line><!></svg> </button> <button data-testid="export-pdf-btn" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"> </button> <button data-testid="metadata-btn" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-code-compare"></i> </button> <!> <button data-testid="edit-doc-btn" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-file-pen"></i> </button>`,1),XC=U(`<button data-testid="kanban-edit-columns" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-gear"></i> </button>`),ZC=U(`<button data-testid="toc-toggle-btn"><i class="fa-solid fa-list-ul"></i></button>`),QC=U(`<div data-testid="view-actions" class="flex items-center gap-2"><button data-testid="favorite-doc-btn"><i style="margin-right:4px"></i> </button> <!> <!> <!> <button data-testid="delete-doc-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors"><i class="fa-solid fa-trash"></i> </button> <!></div>`),$C=U(`<span class="text-gray-300 dark:text-gray-600 mx-1">·</span>`),ew=U(`<!> <button class="text-blue-600 dark:text-blue-400 hover:underline"> </button>`,1),tw=U(`<div class="no-print mt-2 flex flex-wrap gap-1 text-xs"></div>`),nw=U(`<li><button class="w-full text-left px-3 py-1.5 hover:bg-yellow-100 dark:hover:bg-yellow-900/30 transition-colors"><span class="text-yellow-600 dark:text-yellow-500 font-mono text-xs mr-2"> </span><span class="text-xs"> </span></button></li>`),rw=U(`<div class="mt-4 rounded-lg bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 text-sm text-yellow-800 dark:text-yellow-300 overflow-hidden"><div class="px-3 py-2 font-medium border-b border-yellow-200 dark:border-yellow-800"> </div> <ol class="max-h-40 overflow-y-auto divide-y divide-yellow-100 dark:divide-yellow-900/40 list-none m-0 p-0"></ol></div>`),iw=U(`<div data-testid="tts-error" class="mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300"> </div>`),aw=U(`<div class="hidden no-print"></div>`),ow=U(`<li class="m-0 p-0"><button type="button" class="block w-full text-left bg-transparent border-0 cursor-pointer text-xs text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:underline py-0.5 leading-snug transition-colors truncate"> </button></li>`),sw=U(`<div></div> <aside class="no-print shrink-0 sticky self-start overflow-y-auto py-8 pr-4 pl-3 ld-toc-aside"><p class="text-xs font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500 mb-3"> </p> <nav><ul class="space-y-1 list-none m-0 p-0"></ul></nav></aside>`,1),cw=U(`<div data-testid="tts-language-modal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4"><div class="w-full max-w-sm rounded-xl border border-gray-200 bg-white p-5 shadow-2xl dark:border-gray-700 dark:bg-gray-900"><h2 class="text-base font-semibold text-gray-900 dark:text-gray-50"> </h2> <p class="mt-2 text-sm text-gray-600 dark:text-gray-300"> </p> <div class="mt-4 grid grid-cols-2 gap-2"><button type="button" data-testid="tts-language-en" class="rounded-lg border border-gray-200 px-3 py-2 text-sm font-semibold text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800"> </button> <button type="button" data-testid="tts-language-fr" class="rounded-lg border border-gray-200 px-3 py-2 text-sm font-semibold text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800"> </button></div> <div class="mt-3 flex justify-end"><button type="button" class="rounded-lg border border-gray-200 px-3 py-1.5 text-sm text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800"> </button></div></div></div>`),lw=U(`<div class="fixed inset-0 z-50 bg-black/50 flex items-center justify-center 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 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 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>`),uw=U(`<header id="home-doc-header" class="sticky top-0 z-10 bg-gray-50 dark:bg-gray-950 px-6 pt-8 pb-6 border-b border-gray-300 dark:border-gray-800"><div class="flex items-start gap-4 flex-wrap"><div class="shrink min-w-0"><div class="flex items-center gap-2 flex-wrap"><span class="flex items-center gap-2 flex-wrap"><!> <span class="inline-block text-xs font-semibold px-2.5 py-0.5 rounded-full bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"> </span></span> <!> <h1 data-testid="doc-title" class="min-w-0 text-xs font-normal text-gray-900 dark:text-gray-50 leading-tight"> </h1> <!></div> <!></div> <div class="flex items-center gap-2 flex-wrap ml-auto"><!></div></div> <!> <!> <!> <!> <!></header> <div class="flex min-h-full items-start"><article id="home-doc-view" data-testid="doc-view" class="flex-1 min-w-0 px-6 pt-8 pb-8"><!></article> <!></div> <!> <!> <!> <!> <!> <!>`,1);function dw(e,t){qe(t,!0);let n=/<div\s+data-ld-kanban\b/i,r=qi(t,`navHistory`,19,()=>[]),i=P(null),a=P(null),o=P(null),s=P(null),c=P(!1),l=P(!1),u=P(!1),d=P(null),f=P(I([])),p=``,m=N(()=>V(f).length?Y(V(f).length===1?`search.notice_singular`:`search.notice_plural`).replace(`{count}`,String(V(f).length)).replace(`{query}`,X.searchQuery):``),h=N(()=>Nv(t.doc.content)),g=N(()=>n.test(t.doc.content)),_=N(()=>Ho.has(t.doc.id)),v=N(()=>(V(h)||``).toUpperCase()===`TO BE VALIDATED`),y=P(!1),b=P(null),x=P(!1),S=P(!1),C=P(!1),w=P(!1),T=P(!1);async function E(){try{let e=await(await fetch(`/api/git/status`)).json();F(u,e.mode===`enabled`&&e.ok===!0,!0)}catch{F(u,!1)}}kn(()=>{if(t.doc.id,V(g),V(g)){F(u,!1);return}E()}),kn(()=>{V(g)&&V(y)&&(F(y,!1),F(b,null))});function D(e,t){let n=document.getElementById(`home-content-area`);if(!n)return;let r=document.getElementById(`home-doc-header`),i=r?r.getBoundingClientRect().height:0,a=e.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop;n.scrollTo({top:Math.max(0,a-i-16),behavior:t?`smooth`:`auto`})}function ee(e){let t=document.getElementById(e);t&&D(t,!1)}function te(e){F(i,e,!0);let n=t.doc.id,r=X.searchQuery;if(V(g)){F(f,[],!0),F(A,[],!0),p=n;return}let a=typeof r==`string`&&r.toLowerCase().startsWith(`metadata://`);F(f,r&&!a?FC(e,r):[],!0),V(d)&&vy(e,V(d),Y),n===p?V(o)?.apply():(p=n,V(o)?.load(n),kv.load(n)),F(A,Array.from(e.querySelectorAll(`h1,h2,h3,h4,h5,h6`)).map(e=>({id:e.id,text:e.textContent?.trim()??``,level:parseInt(e.tagName[1])})).filter(e=>e.id&&e.text),!0)}function O(){return V(s).show({title:Y(`snippet.inline_delete_title`),message:Y(`snippet.inline_delete_message`),confirmLabel:Y(`snippet.inline_delete_confirm_btn`),cancelLabel:Y(`common.cancel`),danger:!0})}async function k(){let e=1;try{let n=await kv.load(t.doc.id);n&&typeof n.accuracy==`number`&&(e=n.accuracy)}catch{}let n=Math.round(e*100),r=n<100,i=Fv(t.doc.id),a=Y(i?`doc.validate_worklog_message`:`doc.validate_message`),o=r?Y(`doc.validate_detail_low_accuracy`).replace(`{accuracy}`,n+`%`):void 0;if(!await V(s).show({title:Y(`doc.validate_title`),message:a,detail:o,confirmLabel:Y(`doc.validate_confirm`),cancelLabel:Y(`common.cancel`)}))return;let c=Pv(t.doc.content,i?`Done`:`Accepted`);if(c!==t.doc.content)try{await t.onsave(c),r&&await fetch(`/api/metadata/`+encodeURIComponent(t.doc.id)+`/refresh`,{method:`POST`}),await kv.load(t.doc.id),X.docStatuses={...X.docStatuses,[t.doc.id]:i?`Done`:`Accepted`}}catch(e){F(b,{text:Y(`doc.validate_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`},!0)}}kn(()=>{try{F(x,localStorage.getItem(`ld-full-width`)===`1`)}catch{}});let ne=P(!1),A=P(I([])),re=N(()=>!V(g)&&V(ne)&&V(A).length>0),ie=`ld-toc-w`,ae=P(!1),oe=P(null),se=P(null),ce=P(0);kn(()=>{if(!V(se))return;let e=new ResizeObserver(()=>{F(ce,V(se).offsetHeight,!0)});return e.observe(V(se)),F(ce,V(se).offsetHeight,!0),()=>e.disconnect()});function le(e){if(e.preventDefault(),!V(oe))return;let t=e.clientX,n=V(oe).getBoundingClientRect().width;F(ae,!0),V(oe).style.transition=`none`,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let r=e=>{let r=Math.max(160,Math.min(400,n-(e.clientX-t)));V(oe).style.width=r+`px`},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i),document.body.style.cursor=``,document.body.style.userSelect=``,F(ae,!1),V(oe).style.transition=``;try{localStorage.setItem(ie,String(parseInt(V(oe).style.width,10)))}catch{}};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)}kn(()=>{try{F(ne,localStorage.getItem(`ld-toc-open`)===`1`)}catch{}try{let e=parseInt(localStorage.getItem(ie)||``,10);V(oe)&&e>=160&&e<=400&&(V(oe).style.width=e+`px`)}catch{}});function ue(){F(ne,!V(ne));try{localStorage.setItem(`ld-toc-open`,V(ne)?`1`:`0`)}catch{}}function de(e){let t=document.getElementById(e),n=document.getElementById(`home-content-area`);if(!t||!n)return;let r=t.parentElement;for(;r&&r!==n;)r.tagName===`DETAILS`&&(r.open=!0),r=r.parentElement;D(t,!0)}async function fe(){try{await navigator.clipboard.writeText(decodeURIComponent(t.doc.id)),F(C,!0),setTimeout(()=>F(C,!1),1800)}catch{}}function pe(){window.print()}function me(e){V(i)&&jy.start(V(i),{language:e,codeLabel:Y(`tts.code_label`),imageLabel:Y(`tts.image_label`),diagramLabel:Y(`tts.diagram_label`),tableLabel:Y(`tts.table_label`)})}function he(){let e=MC(t.doc.content);if(!e){F(w,!0);return}me(e)}async function ge(e){F(T,!0);try{let n=NC(t.doc.content,e);n!==t.doc.content&&await t.onsave(n),F(w,!1),me(e)}catch(e){F(b,{text:Y(`tts.language_save_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`},!0)}finally{F(T,!1)}}kn(()=>(t.doc.id,V(y),()=>{F(w,!1),jy.stop()}));var _e=uw(),ve=R(_e),ye=L(ve),be=L(ye),xe=L(be),Se=L(xe),Ce=L(Se);q(Ce,17,()=>t.doc.folder||[],Qr,(e,t)=>{var n=LC(),r=L(n,!0);j(n),B(e=>{J(n,`title`,V(t)),G(r,e)},[()=>W_(V(t))]),W(e,n)});var we=z(Ce,2),Te=L(we,!0);j(we),j(Se);var Ee=z(Se,2),De=e=>{var n=RC(),r=L(n,!0);j(n),B(()=>G(r,t.doc.formattedDate)),W(e,n)};K(Ee,e=>{t.doc.formattedDate&&e(De)});var Oe=z(Ee,2),ke=L(Oe,!0);j(Oe);var Ae=z(Oe,2),je=e=>{var t=zC(),n=L(t);j(t),B(e=>{J(t,`title`,e),vi(t,1,`no-print inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-gray-200 text-xs text-gray-500 transition-colors hover:bg-gray-50 hover:text-blue-600 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-blue-400 ${V(C)?`text-green-600 dark:text-green-400`:``}`),vi(n,1,`fa-${V(C)?`solid fa-check`:`regular fa-copy`}`)},[()=>Y(`doc.copy_mcp_id`)]),H(`click`,t,fe),W(e,t)};K(Ae,e=>{V(g)||e(je)}),j(xe);var Me=z(xe,2),Ne=e=>{var n=VC();q(n,20,()=>t.doc.tags,e=>e,(e,t)=>{var n=BC(),r=L(n);j(n),B(()=>G(r,`#${t??``}`)),W(e,n)}),j(n),W(e,n)};K(Me,e=>{t.doc.tags&&t.doc.tags.length&&e(Ne)}),j(be);var Pe=z(be,2),Fe=L(Pe),Ie=e=>{var t=UC(),n=L(t),r=e=>{var t=HC(),n=L(t,!0);j(t),B(()=>{vi(t,1,`text-xs ${V(b).cls??``}`),G(n,V(b).text)}),W(e,t)};K(n,e=>{V(b)&&e(r)});var i=z(n,2),o=L(i,!0);j(i);var s=z(i,2),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(t),B((e,t,n,r)=>{G(o,e),J(s,`title`,t),G(c,n),G(u,r)},[()=>Y(`common.cancel`),()=>Y(`doc.snippets`),()=>Y(`doc.snippets_btn`),()=>Y(`common.save`)]),H(`click`,i,()=>V(a).cancelEdit()),H(`click`,s,()=>V(a).openSnippets()),H(`click`,l,()=>V(a).save()),W(e,t)},Le=e=>{let n=N(()=>X.markerActive?`#fef08a`:`#bfdbfe`),r=N(()=>X.markerActive?`#fef08a`:`#93c5fd`),i=N(()=>X.markerActive?`#fde047`:`#93c5fd`);var o=QC(),s=L(o),d=L(s),f=z(d,1,!0);j(s);var p=z(s,2),m=e=>{var t=WC(),n=z(L(t),1,!0);j(t),B((e,r)=>{J(t,`title`,e),G(n,r)},[()=>Y(`doc.validate_mode`),()=>Y(`doc.validate_btn`)]),H(`click`,t,k),W(e,t)};K(p,e=>{V(v)&&!V(g)&&e(m)});var h=z(p,2),y=e=>{var t=YC(),o=R(t),s=e=>{var t=GC(),n=R(t),r=L(n);j(n);var i=z(n,2);B((e,t)=>{J(n,`title`,e),vi(r,1,`fa-solid ${jy.status===`playing`?`fa-pause`:`fa-play`}`),J(i,`title`,t)},[()=>jy.status===`playing`?Y(`tts.pause`):Y(`tts.resume`),()=>Y(`tts.stop`)]),H(`click`,n,()=>jy.toggle()),H(`click`,i,()=>jy.stop()),W(e,t)},d=e=>{var t=KC(),n=z(L(t),1,!0);j(t),B((e,r)=>{J(t,`title`,e),G(n,r)},[()=>Y(`tts.play`),()=>Y(`tts.play_btn`)]),H(`click`,t,he),W(e,t)};K(o,e=>{jy.active?e(s):e(d,-1)});var f=z(o,2),p=L(f),m=L(p),h=z(m),g=z(h),_=z(g),v=z(_,2),y=e=>{W(e,qC())};K(v,e=>{X.markerHidden&&e(y)}),j(p);var b=z(p,1,!0);j(f);var x=z(f,2),S=L(x);j(x);var C=z(x,2),w=z(L(C));j(C);var T=z(C,2),E=e=>{var t=JC(),n=z(L(t));j(t),B((e,r)=>{J(t,`title`,e),G(n,` ${r??``}`)},[()=>Y(`versions.button_title`),()=>Y(`versions.button`)]),H(`click`,t,()=>F(l,!0)),W(e,t)};K(T,e=>{V(u)&&e(E)});var D=z(T,2),ee=z(L(D));j(D),B((e,t,a,o,s,c,l,u)=>{J(f,`title`,e),vi(f,1,`no-print text-sm px-3 py-1.5 rounded-lg border transition-colors ${X.markerActive?`border-yellow-400 bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-300`:`border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700`}`),J(m,`fill`,V(n)),J(h,`fill`,V(r)),J(g,`fill`,V(i)),J(_,`fill`,V(i)),G(b,t),J(x,`title`,a),G(S,`📄 ${o??``}`),J(C,`title`,s),G(w,` ${c??``}`),J(D,`title`,l),G(ee,` ${u??``}`)},[()=>Y(`doc.marker_mode`),()=>Y(`doc.marker_btn`),()=>Y(`doc.export_pdf`),()=>Y(`doc.export_pdf_btn`),()=>Y(`metadata.button_title`),()=>Y(`metadata.button`),()=>Y(`doc.edit`),()=>Y(`doc.edit_btn`)]),H(`click`,f,()=>X.toggleMarker()),H(`click`,x,pe),H(`click`,C,()=>F(c,!0)),H(`click`,D,()=>V(a).enterEdit()),W(e,t)};K(h,e=>{V(g)||e(y)});var b=z(h,2),x=e=>{var t=XC(),n=z(L(t));j(t),B((e,r)=>{J(t,`title`,e),G(n,` ${r??``}`)},[()=>Y(`kanban.edit_columns`),()=>Y(`kanban.edit_columns`)]),H(`click`,t,()=>V(a).openKanbanColumnsEditor()),W(e,t)};K(b,e=>{V(g)&&e(x)});var C=z(b,2),w=z(L(C));j(C);var T=z(C,2),E=e=>{var t=ZC();B(e=>{J(t,`title`,e),vi(t,1,`no-print text-sm px-3 py-1.5 rounded-lg border transition-colors ${V(ne)?`border-blue-400 bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400`:`border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700`}`)},[()=>Y(`doc.toc_toggle`)]),H(`click`,t,ue),W(e,t)};K(T,e=>{V(g)||e(E)}),j(o),B((e,t,n,r)=>{J(s,`aria-pressed`,V(_)),J(s,`title`,e),vi(s,1,`no-print text-sm px-3 py-1.5 rounded-lg border transition-colors ${V(_)?`border-amber-300 bg-amber-50 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400`:`border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700`}`),vi(d,1,`fa-${V(_)?`solid`:`regular`} fa-star`),G(f,t),J(C,`title`,n),G(w,` ${r??``}`)},[()=>V(_)?Y(`favorites.remove`):Y(`favorites.add`),()=>Y(`favorites.button`),()=>Y(`doc.delete`),()=>Y(`doc.delete_btn`)]),H(`click`,s,()=>Ho.toggle({id:t.doc.id,title:t.doc.title})),H(`click`,C,()=>F(S,!0)),W(e,o)};K(Fe,e=>{V(y)?e(Ie):e(Le,-1)}),j(Pe),j(ye);var Re=z(ye,2),ze=e=>{jv(e,{onopen:()=>F(c,!0)})};K(Re,e=>{!V(y)&&!V(g)&&e(ze)});var Be=z(Re,2),Ve=e=>{var n=tw();q(n,21,r,Qr,(e,n,r)=>{var i=ew(),a=R(i),o=e=>{W(e,$C())};K(a,e=>{r>0&&e(o)});var s=z(a,2),c=L(s);j(s),B(()=>G(c,`← ${V(n).title??``}`)),H(`click`,s,()=>t.ongoback?.(r)),W(e,i)}),j(n),W(e,n)};K(Be,e=>{!V(y)&&r().length&&e(Ve)});var He=z(Be,2),Ue=e=>{var t=rw(),n=L(t),r=L(n,!0);j(n);var i=z(n,2);q(i,23,()=>V(f),e=>e.id,(e,t,n)=>{var r=nw(),i=L(r),a=L(i),o=L(a);j(a);var s=z(a),c=L(s,!0);j(s),j(i),j(r),B(()=>{G(o,`${V(n)+1}.`),G(c,V(t).snippet)}),H(`click`,i,()=>IC(V(t).id)),W(e,r)}),j(i),j(t),B(()=>G(r,V(m))),W(e,t)};K(He,e=>{!V(y)&&!V(g)&&V(f).length&&X.searchQuery&&e(Ue)});var We=z(He,2),Ge=e=>{var t=iw(),n=L(t,!0);j(t),B(()=>G(n,jy.error)),W(e,t)};K(We,e=>{!V(y)&&!V(g)&&jy.error&&e(Ge)});var Ke=z(We,2),Ye=e=>{var t=aw();Ui(t,e=>F(d,e),()=>V(d)),W(e,t)};K(Ke,e=>{V(g)||e(Ye)}),j(ve),Ui(ve,e=>F(se,e),()=>V(se));var Xe=z(ve,2),Ze=L(Xe);Ui(Vf(L(Ze),{get docId(){return t.doc.id},get content(){return t.doc.content},get html(){return t.doc.html},get onsave(){return t.onsave},get onopen(){return t.onopen},onanchor:ee,onconfirmdelete:O,oncontentwired:te,get rewireSignal(){return X.searchQuery},get editing(){return V(y)},set editing(e){F(y,e,!0)},get saveMsg(){return V(b)},set saveMsg(e){F(b,e,!0)}}),e=>F(a,e,!0),()=>V(a)),j(Ze);var Qe=z(Ze,2),$e=e=>{var t=sw(),n=R(t),r=z(n,2),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o);q(s,21,()=>V(A),Qr,(e,t)=>{var n=ow(),r=L(n),i=L(r,!0);j(r),j(n),B(()=>{bi(n,`padding-left: ${(V(t).level-1)*.75}rem`),J(r,`title`,V(t).text),G(i,V(t).text)}),H(`click`,r,()=>de(V(t).id)),W(e,n)}),j(s),j(o),j(r),Ui(r,e=>F(oe,e),()=>V(oe)),B(e=>{vi(n,1,`no-print w-1 shrink-0 self-stretch cursor-col-resize select-none transition-colors ${V(ae)?`bg-blue-500/60`:`bg-transparent hover:bg-blue-500/40`}`),bi(r,`width: 224px; top: ${V(ce)??``}px; min-height: calc(100vh - ${V(ce)??``}px); max-height: calc(100vh - ${V(ce)??``}px)`),G(a,e)},[()=>Y(`doc.toc_title`)]),H(`mousedown`,n,le),W(e,t)};K(Qe,e=>{V(re)&&e($e)}),j(Xe);var et=z(Xe,2),tt=e=>{Ui(Cv(e,{get contentEl(){return V(i)},get docId(){return t.doc.id}}),e=>F(o,e,!0),()=>V(o))};K(et,e=>{V(g)||e(tt)});var nt=z(et,2);Qv(nt,{get open(){return V(c)},get docId(){return t.doc.id},get content(){return t.doc.content},onclose:()=>F(c,!1)});var rt=z(nt,2);dy(rt,{get open(){return V(l)},get docId(){return t.doc.id},get content(){return t.doc.content},get onsave(){return t.onsave},onclose:()=>F(l,!1)});var it=z(rt,2);Ui(Xd(it,{}),e=>F(s,e,!0),()=>V(s));var at=z(it,2),ot=e=>{var t=cw(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a);var s=z(a,2),c=L(s),l=L(c,!0);j(c);var u=z(c,2),d=L(u,!0);j(u),j(s);var f=z(s,2),p=L(f),m=L(p,!0);j(p),j(f),j(n),j(t),B((e,t,n,r,a)=>{G(i,e),G(o,t),c.disabled=V(T),G(l,n),u.disabled=V(T),G(d,r),p.disabled=V(T),G(m,a)},[()=>Y(`tts.language_title`),()=>Y(`tts.language_message`),()=>Y(`tts.language_en`),()=>Y(`tts.language_fr`),()=>Y(`common.cancel`)]),H(`click`,t,e=>{e.target===e.currentTarget&&!V(T)&&F(w,!1)}),H(`click`,c,()=>ge(`en`)),H(`click`,u,()=>ge(`fr`)),H(`click`,p,()=>F(w,!1)),W(e,t)};K(at,e=>{V(w)&&e(ot)});var st=z(at,2),ct=e=>{var n=lw(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c),u=L(l,!0);j(l);var d=z(l,2),f=L(d,!0);j(d),j(c),j(r),j(n),B((e,n,r)=>{G(a,e),G(s,t.doc.title),G(u,n),G(f,r)},[()=>Y(`doc.confirm_delete`),()=>Y(`common.cancel`),()=>Y(`doc.confirm_delete_btn`)]),H(`click`,n,e=>{e.target===e.currentTarget&&F(S,!1)}),H(`click`,l,()=>F(S,!1)),H(`click`,d,async()=>{F(S,!1),await t.ondelete()}),W(e,n)};K(st,e=>{V(S)&&e(ct)}),B(()=>{G(Te,t.doc.category),G(ke,t.doc.title)}),W(e,_e),Je()}Pr([`click`,`mousedown`]);var fw=U(`<p class="px-3 py-4 text-xs text-gray-400 text-center"> </p>`),pw=U(`<p class="px-3 py-3 text-xs text-red-400 text-center"> </p>`),mw=U(`<p class="px-3 py-3 text-xs text-gray-400 text-center"> </p>`),hw=U(`<button class="w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><span class="text-gray-400 shrink-0">📁</span> <span class="truncate text-gray-700 dark:text-gray-300"> </span></button>`),gw=U(`<div class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden text-sm"><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"> </button> <span class="text-xs text-gray-500 dark:text-gray-400 font-mono truncate flex-1"> </span></div> <div class="max-h-40 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800"><!></div></div>`),_w=U(`<p class="text-xs text-red-500"> </p>`),vw=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-md mx-4 p-6 space-y-4"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"><svg width="16" height="16" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="inline-block mr-1 align-text-bottom"><path d="M2 5a2 2 0 012-2h3.586a1 1 0 01.707.293L9.707 4.707A1 1 0 0010.414 5H16a2 2 0 012 2v8a2 2 0 01-2 2H4a2 2 0 01-2-2V5z" stroke="currentColor" stroke-width="1.5" fill="none"></path><line x1="10" y1="8" x2="10" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></line><line x1="7" y1="11" x2="13" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></line></svg> <span> </span></h3> <div class="space-y-1.5"><label for="new-folder-name" class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <input id="new-folder-name" type="text" class="w-full 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 focus:outline-none focus:ring-2 focus:ring-blue-500"/></div> <div class="space-y-1.5"><label class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <div class="flex items-center gap-2"><span class="flex-1 text-sm text-gray-600 dark:text-gray-300 font-mono truncate"> </span> <button class="text-xs px-2 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shrink-0"> </button></div> <!></div> <div class="space-y-1"><label class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <p class="text-xs font-mono text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 truncate"> </p></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>`);function yw(e,t){qe(t,!0);let n=P(``),r=P(null),i=P(null),a=P(``),o=P(``),s=P(`/ (root)`),c=P(!1),l=P(``),u=P(I([])),d=P(!1),f=P(!1),p=P(``),m=P(!1),h=P(null),g=!1;kn(()=>{t.open&&!g?(g=!0,_()):t.open||(g=!1)});async function _(){try{F(n,(await fetch(`/api/config`).then(e=>e.json())).docsFolder||``,!0)}catch{F(n,``)}let e=``;if(X.currentDocId){let t=decodeURIComponent(X.currentDocId);if(!t.startsWith(`/`)){let n=t.split(`/`);n.length>1&&(e=n.slice(0,-1).join(`/`))}}F(a,e?V(n)+`/`+e:V(n),!0),F(r,V(a),!0),F(i,null),F(o,``),F(s,e?`/`+e:`/ (root)`,!0),F(c,!1),F(p,``),F(m,!1),setTimeout(()=>V(h)?.focus(),50)}let v=N(()=>{let e=Oa(V(o));if(!e)return Y(`modal.new_folder.enter_name`);let t=V(a)||V(n),r=t.startsWith(V(n))?t.slice(V(n).length).replace(/^\//,``):``;return(r?r+`/`:``)+e});function y(e){let t=e.currentTarget,n=Oa(t.value);t.value!==n&&(t.value=n),V(o)!==n&&F(o,n,!0)}function b(){F(c,!V(c)),V(c)&&x(V(r)||V(n))}async function x(e){F(d,!0),F(f,!1);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(r,t.current,!0),F(i,t.parent,!0),F(a,t.current,!0),F(l,t.current,!0),F(s,(t.current.startsWith(V(n)+`/`)?t.current.slice(V(n).length):t.current===V(n)?``:t.current)||`/ (root)`,!0),F(u,t.dirs||[],!0)}catch{F(f,!0),F(u,[],!0)}finally{F(d,!1)}}let S=N(()=>V(r)===V(n));function C(){V(i)&&x(V(i))}async function w(){let e=Oa(V(o));if(F(p,``),!e){F(p,Y(`modal.new_folder.error_empty`),!0);return}if(!/^[a-zA-Z0-9_.-]+$/.test(e)){F(p,Y(`modal.new_folder.error_invalid_chars`),!0);return}let r=V(a)||V(n);if(r===V(n)&&(e===`files`||e===`images`)){F(p,Y(`modal.new_folder.error_reserved`),!0);return}let i=r.endsWith(`/`)?r+e:r+`/`+e;F(m,!0);try{let e=await fetch(`/api/browse/mkdir`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:i})});if(!e.ok)throw Error(await e.text());t.onclose(),t.onsuccess()}catch(e){F(m,!1),F(p,Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e)))}}var T=Wr(),E=R(T),D=e=>{var n=vw(),r=L(n),i=L(r),a=z(L(i),2),g=L(a,!0);j(a),j(i);var _=z(i,2),T=L(_),E=L(T,!0);j(T);var D=z(T,2);ki(D),Ui(D,e=>F(h,e),()=>V(h)),j(_);var ee=z(_,2),te=L(ee),O=L(te,!0);j(te);var k=z(te,2),ne=L(k),A=L(ne,!0);j(ne);var re=z(ne,2),ie=L(re,!0);j(re),j(k);var ae=z(k,2),oe=e=>{var t=gw(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n);var s=z(n,2),c=L(s),p=e=>{var t=fw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},m=e=>{var t=pw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`modal.new_folder.error_loading`)]),W(e,t)},h=e=>{var t=mw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`modal.new_folder.no_subfolders`)]),W(e,t)},g=e=>{var t=Wr();q(R(t),17,()=>V(u),e=>e.path,(e,t)=>{var n=hw(),r=z(L(n),2),i=L(r,!0);j(r),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>x(V(t).path)),W(e,n)}),W(e,t)};K(c,e=>{V(d)?e(p):V(f)?e(m,1):V(u).length===0?e(h,2):e(g,-1)}),j(s),j(t),B(e=>{r.disabled=V(S),G(i,e),G(o,V(l))},[()=>Y(`common.up`)]),H(`click`,r,C),W(e,t)};K(ae,e=>{V(c)&&e(oe)}),j(ee);var se=z(ee,2),ce=L(se),le=L(ce,!0);j(ce);var ue=z(ce,2),de=L(ue,!0);j(ue),j(se);var fe=z(se,2),pe=e=>{var t=_w(),n=L(t,!0);j(t),B(()=>G(n,V(p))),W(e,t)};K(fe,e=>{V(p)&&e(pe)});var me=z(fe,2),he=L(me),ge=L(he,!0);j(he);var _e=z(he,2),ve=L(_e,!0);j(_e),j(me),j(r),j(n),B((e,t,n,r,i,a,o,c)=>{G(g,e),G(E,t),J(D,`placeholder`,n),G(O,r),G(A,V(s)),G(ie,i),G(le,a),G(de,V(v)),G(ge,o),_e.disabled=V(m),G(ve,c)},[()=>Y(`modal.new_folder.title`),()=>Y(`modal.new_folder.name_label`),()=>Y(`modal.new_folder.name_placeholder`),()=>Y(`modal.new_folder.location_label`),()=>Y(`modal.new_folder.browse_btn`),()=>Y(`modal.new_folder.will_be_created`),()=>Y(`common.cancel`),()=>V(m)?Y(`modal.new_folder.creating_btn`):Y(`modal.new_folder.create_btn`)]),H(`click`,n,e=>{e.target===e.currentTarget&&t.onclose()}),H(`input`,D,y),Fi(D,()=>V(o),e=>F(o,e)),H(`click`,re,b),H(`click`,he,function(...e){t.onclose?.apply(this,e)}),H(`click`,_e,w),W(e,n)};K(E,e=>{t.open&&e(D)}),W(e,T),Je()}Pr([`click`,`input`]);var bw=U(`<p class="text-sm text-gray-400 py-2"> </p>`),xw=U(`<p class="text-sm text-red-500"> </p>`),Sw=U(`<label class="flex items-center gap-3 px-1 py-1.5 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer"><input type="checkbox" class="w-4 h-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"/> <span class="text-sm text-gray-700 dark:text-gray-300"> </span></label>`),Cw=U(`<div><div class="max-h-48 overflow-y-auto space-y-0.5 border border-gray-200 dark:border-gray-700 rounded-lg p-2"><!></div></div>`),ww=U(`<div><p class="text-xs text-gray-500 dark:text-gray-400"> </p> <div class="flex justify-end gap-3 pt-2"><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>`),Tw=U(`<div><p class="text-xs text-gray-500 dark:text-gray-400"> </p> <div class="flex justify-end gap-3 pt-2"><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 border border-blue-500 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 font-semibold 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>`),Ew=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-4"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"><i class="fa-solid fa-file-export mr-2 text-blue-500"></i> <span> </span></h3> <div class="flex gap-0 border-b border-gray-200 dark:border-gray-700"><button> </button> <button> </button> <button> </button></div> <!> <!> <!> <!></div></div>`);function Dw(e,t){qe(t,!0);let n=P(`markdown`),r=!1,i=P(!1),a=P(!1),o=P(I([])),s=P(I({})),c=P(!1),l=P(!1),u=P(!1),d=P(!1),f=!1;kn(()=>{t.open&&!f?(f=!0,F(n,`markdown`),r=!1,F(o,[],!0),F(s,{},!0)):t.open||(f=!1)});function p(e){return String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function m(e){F(n,e,!0),e===`html`&&h()}async function h(){if(!r){F(i,!0),F(a,!1);try{let e=await fetch(`/api/documents`).then(e=>e.json()),t=new Set;e.forEach(e=>t.add(e.folder?.[0]??e.category??`General`)),F(o,[...t].sort((e,t)=>e===`General`?-1:t===`General`?1:e.localeCompare(t)),!0),r=!0}catch{F(a,!0)}finally{F(i,!1)}}}async function g(){F(c,!0);try{let e=await fetch(`/api/export/markdown`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!e.ok)throw Error(await e.text());let n=await e.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`export-markdown.zip`,i.click(),URL.revokeObjectURL(r),t.onclose()}catch(e){alert(Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e)))}finally{F(c,!1)}}async function _(e){let n=V(o).filter(e=>V(s)[e]);if(n.length){F(e===`confluence`?u:l,!0);try{let r=await fetch(`/api/export/html`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({folders:n,mode:e})});if(!r.ok)throw Error(await r.text());let i=await r.blob(),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`export-${e}.zip`,o.click(),URL.revokeObjectURL(a),t.onclose()}catch(e){alert(Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e)))}finally{F(u,!1),F(l,!1)}}}async function v(){F(d,!0);try{let e=X.allDocs&&X.allDocs.length?X.allDocs:await fetch(`/api/documents`).then(e=>e.json()),n={};for(let t=0;t<e.length;t+=5){let r=e.slice(t,t+5),i=await Promise.all(r.map(e=>fetch(`/api/documents/`+e.id).then(e=>e.ok?e.json():null).catch(()=>null)));for(let r of i)r&&(n[r.id??e[t]?.id]=r);r.forEach((e,t)=>{i[t]&&(n[e.id]=i[t])})}function r(e){let t={categories:{},children:{}};for(let n of e){let e=t;for(let t of n.folder||[])e.children[t]||(e.children[t]={categories:{},children:{}}),e=e.children[t];e.categories[n.category]||(e.categories[n.category]=[]),e.categories[n.category].push(n)}return t}function i(e){let t=[];e.categories.General&&t.push(...e.categories.General);let n=Object.keys(e.children).sort((e,t)=>e.localeCompare(t));for(let r of n)t.push(...i(e.children[r]));let r=Object.keys(e.categories).filter(e=>e!==`General`).sort((e,t)=>e.localeCompare(t));for(let n of r)t.push(...e.categories[n]);return t}function a(e){return e.replace(/^\d+_/,``).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function o(e,t){let n=``,r=t*1.25,i=(e,i)=>{let a=t===0&&e===`General`?`General`:e;n+=`<li style="margin-left:${r}rem;margin-top:${t===0?`0.75`:`0.4`}rem;">`,n+=`<span style="font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.05em;color:#6b7280;">${a}</span>`,n+=`<ul style="margin:0.2rem 0 0 0;padding:0;list-style:none;">`;for(let e of i)n+=`<li style="margin-left:${r+.75}rem;padding:0.15rem 0;">`,n+=`<a href="#doc-${e.id}" style="color:#1d4ed8;text-decoration:none;font-size:0.875rem;">${p(e.title)}</a>`,e.formattedDate&&(n+=`<span style="color:#9ca3af;font-size:0.7rem;margin-left:0.5rem;">${p(e.formattedDate)}</span>`),n+=`</li>`;n+=`</ul></li>`};e.categories.General&&i(`General`,e.categories.General);let s=Object.keys(e.children).sort((e,t)=>e.localeCompare(t));for(let i of s)n+=`<li style="margin-left:${r}rem;margin-top:0.75rem;">`,n+=`<span style="font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.05em;color:#7c3aed;">📁 ${a(i)}</span>`,n+=`<ul style="margin:0.2rem 0 0 0;padding:0;list-style:none;">`,n+=o(e.children[i],t+1),n+=`</ul></li>`;let c=Object.keys(e.categories).filter(e=>e!==`General`).sort((e,t)=>e.localeCompare(t));for(let t of c)i(t,e.categories[t]);return n}function s(e){return e.replace(/href="[^"]*\?doc=([^"&#]+)(?:#[^"]*)?"/g,(e,t)=>`href="#doc-${t}"`)}let c=p(document.title||`Living Documentation`),l=r(e),u=i(l),d=`<!DOCTYPE html>
|
|
223
|
+
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=xC(bC(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=xC(bC(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function wC(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new gC||null,prettyErrors:t}}function TC(e,t={}){let{lineCounter:n,prettyErrors:r}=wC(t),i=new CC(n?.addNewLine),a=new nC(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new vS(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(bS(e,n)),o.warnings.forEach(bS(e,n))),o}function EC(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=TC(e,n);if(!i)return null;if(i.warnings.forEach(e=>$b(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}var DC=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,OC=/^\s*\*\*[A-Za-z0-9_-]+\s*:\s*\*\*/m,kC=/^\s*(?:\*\*)?([A-Za-z0-9_-]+)(?:\*\*)?\s*:\s*(?:\*\*)?\s*(.*?)\s*$/;function AC(e){if(typeof e!=`string`)return{data:{},body:``,format:`none`,raw:``};let t=e.match(DC);if(!t)return{data:{},body:e,format:`none`,raw:``};let n=t[1],r=e.slice(t[0].length);if(OC.test(n))return{data:jC(n),body:r,format:`legacy`,raw:n};try{let e=EC(n);return{data:e&&typeof e==`object`&&!Array.isArray(e)?e:{},body:r,format:`yaml`,raw:n}}catch{return{data:jC(n),body:r,format:`legacy`,raw:n}}}function jC(e){let t={};for(let n of e.split(/\r?\n/)){let e=kC.exec(n);if(!e)continue;let r=e[1],i=e[2];r.toLowerCase()===`tags`?t[r]=i.split(`,`).map(e=>e.trim()).filter(Boolean):t[r]=i}return t}function MC(e,t){let n=t.toLowerCase();for(let t of Object.keys(e))if(t.toLowerCase()===n)return e[t]}function NC(e){return e==null?null:Array.isArray(e)?e.map(e=>String(e)).join(`, `):String(e)}function PC(e,t){let{data:n}=AC(e);for(let e of t){let t=MC(n,e);if(t!=null)return NC(t)}return null}var FC=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/,IC=/^(\s*(?:\*\*)?(?:language|lang|locale|langue)(?:\*\*)?\s*:\s*(?:\*\*)?\s*)(.+?)\s*$/i;function LC(e){let t=(e??``).trim().toLowerCase();return t?t===`en`||t.startsWith(`en-`)||t===`english`||t===`anglais`?`en`:t===`fr`||t.startsWith(`fr-`)||t===`french`||t===`francais`||t===`français`?`fr`:null:null}function RC(e){return LC(PC(e,[`language`,`lang`,`locale`,`langue`]))}function zC(e,t){let n=e.match(FC);if(!n)return`---\n**language:** ${t}\n---\n\n${e}`;let r=n[0],i=n[1].split(/\r?\n/),a=i.findIndex(e=>IC.test(e));if(a>=0)i[a]=i[a].replace(IC,`$1${t}`);else{let e=i.findIndex(e=>/^\s*(?:\*\*)?date(?:\*\*)?\s*:\s*(?:\*\*)?/i.test(e)),n=e>=0?e+1:i.length;i.splice(n,0,`**language:** ${t}`)}return`---\n${i.join(`
|
|
224
|
+
`)}\n---\n`+e.slice(r.length)}var BC=e=>e.normalize(`NFC`).normalize(`NFD`).replace(/[̀-ͯ]/g,``).toLowerCase();function VC(e,t){let n=BC(t);if(!n)return[];let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=[];for(;r.nextNode();)i.push(r.currentNode);let a=0;i.forEach(e=>{let t=(e.textContent||``).normalize(`NFC`),r=BC(t);if(!r.includes(n))return;let i=``,o=0;for(;o<=r.length;){let e=r.indexOf(n,o);if(e===-1){i+=t.slice(o);break}i+=t.slice(o,e),i+=`<mark id="match-${a++}">${t.slice(e,e+n.length)}</mark>`,o=e+n.length}let s=document.createElement(`span`);s.innerHTML=i,e.parentNode?.replaceChild(s,e)});let o=[];return e.querySelectorAll(`mark[id^='match-']`).forEach(e=>{let r=((e.closest(`p, li, td, h1, h2, h3, h4, h5, h6, pre`)||e.parentElement).textContent||``).trim(),i=BC(r).indexOf(n),a=Math.max(0,i-40),s=Math.min(r.length,i+t.length+40),c=(a>0?`…`:``)+r.slice(a,s)+(s<r.length?`…`:``);o.push({id:e.id,snippet:c})}),o}function HC(e){let t=document.getElementById(e),n=document.getElementById(`home-content-area`);if(!t||!n)return;let r=t.parentElement;for(;r&&r!==n;)r.tagName===`DETAILS`&&!r.open&&(r.open=!0),r=r.parentElement;document.querySelectorAll(`mark.match-active`).forEach(e=>{e.classList.remove(`match-active`)}),t.classList.add(`match-active`);let i=document.querySelector(`#home-doc-view header`),a=i?i.getBoundingClientRect().height:0,o=t.getBoundingClientRect().top,s=n.getBoundingClientRect().top,c=a+(n.clientHeight-a)/3;n.scrollTop+=o-s-c}var UC=U(`<span class="inline-block text-xs font-semibold px-2.5 py-0.5 rounded-full bg-violet-100 text-violet-700 dark:bg-violet-900/40 dark:text-violet-300"> </span>`),WC=U(`<span class="text-xs text-gray-400 dark:text-gray-500"> </span>`),GC=U(`<button type="button" data-testid="copy-doc-id-btn"><i aria-hidden="true"></i></button>`),KC=U(`<span class="inline-block text-[11px] px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 border border-gray-200 dark:border-gray-700"> </span>`),qC=U(`<div class="mt-1.5 flex items-center gap-1.5 flex-wrap" data-testid="doc-tags"></div>`),JC=U(`<span> </span>`),YC=U(`<div data-testid="edit-actions" class="flex items-center gap-2"><!> <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"> </button> <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"> </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"> </button></div>`),XC=U(`<button data-testid="validate-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-green-700 bg-green-600 text-white font-semibold hover:bg-green-700 transition-colors"><i class="fa-solid fa-check" style="margin-right:4px"></i> </button>`),ZC=U(`<button data-testid="tts-toggle" class="no-print text-sm px-3 py-1.5 rounded-lg border border-blue-300 dark:border-blue-700 bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 hover:bg-blue-100 dark:hover:bg-blue-900/50 transition-colors"><i></i></button> <button data-testid="tts-stop" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-stop"></i></button>`,1),QC=U(`<button data-testid="tts-play" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-headphones" style="margin-right:4px"></i> </button>`),$C=Hr(`<g><line x1="8" y1="8" x2="92" y2="92" stroke="currentColor" stroke-width="8" stroke-linecap="round"></line><line x1="92" y1="8" x2="8" y2="92" stroke="currentColor" stroke-width="8" stroke-linecap="round"></line></g>`),ew=U(`<button data-testid="versions-btn" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-code-branch"></i> </button>`),tw=U(`<!> <button data-testid="marker-doc-btn"><svg width="18" height="18" viewBox="0 0 100 100" fill="none" style="display:inline-block;vertical-align:middle;margin-right:4px"><rect x="28" y="10" width="44" height="52" rx="6" transform="rotate(40 50 50)" stroke="currentColor" stroke-width="6"></rect><rect x="52" y="8" width="22" height="30" rx="6" transform="rotate(40 50 50)" stroke="currentColor" stroke-width="6"></rect><polygon points="28,60 10,80 30,80 38,72" stroke="currentColor" stroke-width="5" stroke-linejoin="round"></polygon><polygon points="28,48 19,70 36,75 55,70" stroke="currentColor" stroke-width="5" stroke-linejoin="round"></polygon><line x1="10" y1="90" x2="72" y2="90" stroke="currentColor" stroke-width="6" stroke-linecap="round"></line><!></svg> </button> <button data-testid="export-pdf-btn" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"> </button> <button data-testid="metadata-btn" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-code-compare"></i> </button> <!> <button data-testid="edit-doc-btn" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-file-pen"></i> </button>`,1),nw=U(`<button data-testid="kanban-edit-columns" class="no-print 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-200 dark:hover:bg-gray-700 transition-colors"><i class="fa-solid fa-gear"></i> </button>`),rw=U(`<button data-testid="toc-toggle-btn"><i class="fa-solid fa-list-ul"></i></button>`),iw=U(`<div data-testid="view-actions" class="flex items-center gap-2"><button data-testid="favorite-doc-btn"><i style="margin-right:4px"></i> </button> <!> <!> <!> <button data-testid="delete-doc-btn" class="no-print text-sm px-3 py-1.5 rounded-lg border border-red-200 dark:border-red-700 text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/40 transition-colors"><i class="fa-solid fa-trash"></i> </button> <!></div>`),aw=U(`<span class="text-gray-300 dark:text-gray-600 mx-1">·</span>`),ow=U(`<!> <button class="text-blue-600 dark:text-blue-400 hover:underline"> </button>`,1),sw=U(`<div class="no-print mt-2 flex flex-wrap gap-1 text-xs"></div>`),cw=U(`<li><button class="w-full text-left px-3 py-1.5 hover:bg-yellow-100 dark:hover:bg-yellow-900/30 transition-colors"><span class="text-yellow-600 dark:text-yellow-500 font-mono text-xs mr-2"> </span><span class="text-xs"> </span></button></li>`),lw=U(`<div class="mt-4 rounded-lg bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 text-sm text-yellow-800 dark:text-yellow-300 overflow-hidden"><div class="px-3 py-2 font-medium border-b border-yellow-200 dark:border-yellow-800"> </div> <ol class="max-h-40 overflow-y-auto divide-y divide-yellow-100 dark:divide-yellow-900/40 list-none m-0 p-0"></ol></div>`),uw=U(`<div data-testid="tts-error" class="mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300"> </div>`),dw=U(`<div class="hidden no-print"></div>`),fw=U(`<li class="m-0 p-0"><button type="button" class="block w-full text-left bg-transparent border-0 cursor-pointer text-xs text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:underline py-0.5 leading-snug transition-colors truncate"> </button></li>`),pw=U(`<div></div> <aside class="no-print shrink-0 sticky self-start overflow-y-auto py-8 pr-4 pl-3 ld-toc-aside"><p class="text-xs font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500 mb-3"> </p> <nav><ul class="space-y-1 list-none m-0 p-0"></ul></nav></aside>`,1),mw=U(`<div data-testid="tts-language-modal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4"><div class="w-full max-w-sm rounded-xl border border-gray-200 bg-white p-5 shadow-2xl dark:border-gray-700 dark:bg-gray-900"><h2 class="text-base font-semibold text-gray-900 dark:text-gray-50"> </h2> <p class="mt-2 text-sm text-gray-600 dark:text-gray-300"> </p> <div class="mt-4 grid grid-cols-2 gap-2"><button type="button" data-testid="tts-language-en" class="rounded-lg border border-gray-200 px-3 py-2 text-sm font-semibold text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800"> </button> <button type="button" data-testid="tts-language-fr" class="rounded-lg border border-gray-200 px-3 py-2 text-sm font-semibold text-gray-700 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800"> </button></div> <div class="mt-3 flex justify-end"><button type="button" class="rounded-lg border border-gray-200 px-3 py-1.5 text-sm text-gray-600 transition-colors hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800"> </button></div></div></div>`),hw=U(`<div class="fixed inset-0 z-50 bg-black/50 flex items-center justify-center 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 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 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>`),gw=U(`<header id="home-doc-header" class="sticky top-0 z-10 bg-gray-50 dark:bg-gray-950 px-6 pt-8 pb-6 border-b border-gray-300 dark:border-gray-800"><div class="flex items-start gap-4 flex-wrap"><div class="shrink min-w-0"><div class="flex items-center gap-2 flex-wrap"><span class="flex items-center gap-2 flex-wrap"><!> <span class="inline-block text-xs font-semibold px-2.5 py-0.5 rounded-full bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"> </span></span> <!> <h1 data-testid="doc-title" class="min-w-0 text-xs font-normal text-gray-900 dark:text-gray-50 leading-tight"> </h1> <!></div> <!></div> <div class="flex items-center gap-2 flex-wrap ml-auto"><!></div></div> <!> <!> <!> <!> <!></header> <div class="flex min-h-full items-start"><article id="home-doc-view" data-testid="doc-view" class="flex-1 min-w-0 px-6 pt-8 pb-8"><!></article> <!></div> <!> <!> <!> <!> <!> <!>`,1);function _w(e,t){qe(t,!0);let n=/<div\s+data-ld-kanban\b/i,r=qi(t,`navHistory`,19,()=>[]),i=P(null),a=P(null),o=P(null),s=P(null),c=P(!1),l=P(!1),u=P(!1),d=P(null),f=P(I([])),p=``,m=N(()=>V(f).length?Y(V(f).length===1?`search.notice_singular`:`search.notice_plural`).replace(`{count}`,String(V(f).length)).replace(`{query}`,X.searchQuery):``),h=N(()=>zv(t.doc.content)),g=N(()=>n.test(t.doc.content)),_=N(()=>Ho.has(t.doc.id)),v=N(()=>(V(h)||``).toUpperCase()===`TO BE VALIDATED`),y=P(!1),b=P(null),x=P(!1),S=P(!1),C=P(!1),w=P(!1),T=P(!1);async function E(){try{let e=await(await fetch(`/api/git/status`)).json();F(u,e.mode===`enabled`&&e.ok===!0,!0)}catch{F(u,!1)}}kn(()=>{if(t.doc.id,V(g),V(g)){F(u,!1);return}E()}),kn(()=>{V(g)&&V(y)&&(F(y,!1),F(b,null))});function D(e,t){let n=document.getElementById(`home-content-area`);if(!n)return;let r=document.getElementById(`home-doc-header`),i=r?r.getBoundingClientRect().height:0,a=e.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop;n.scrollTo({top:Math.max(0,a-i-16),behavior:t?`smooth`:`auto`})}function ee(e){let t=document.getElementById(e);t&&D(t,!1)}function te(e){F(i,e,!0);let n=t.doc.id,r=X.searchQuery;if(V(g)){F(f,[],!0),F(A,[],!0),p=n;return}let a=typeof r==`string`&&r.toLowerCase().startsWith(`metadata://`);F(f,r&&!a?VC(e,r):[],!0),V(d)&&wy(e,V(d),Y),n===p?V(o)?.apply():(p=n,V(o)?.load(n),Fv.load(n)),F(A,Array.from(e.querySelectorAll(`h1,h2,h3,h4,h5,h6`)).map(e=>({id:e.id,text:e.textContent?.trim()??``,level:parseInt(e.tagName[1])})).filter(e=>e.id&&e.text),!0)}function O(){return V(s).show({title:Y(`snippet.inline_delete_title`),message:Y(`snippet.inline_delete_message`),confirmLabel:Y(`snippet.inline_delete_confirm_btn`),cancelLabel:Y(`common.cancel`),danger:!0})}async function k(){let e=1;try{let n=await Fv.load(t.doc.id);n&&typeof n.accuracy==`number`&&(e=n.accuracy)}catch{}let n=Math.round(e*100),r=n<100,i=Vv(t.doc.id),a=Y(i?`doc.validate_worklog_message`:`doc.validate_message`),o=r?Y(`doc.validate_detail_low_accuracy`).replace(`{accuracy}`,n+`%`):void 0;if(!await V(s).show({title:Y(`doc.validate_title`),message:a,detail:o,confirmLabel:Y(`doc.validate_confirm`),cancelLabel:Y(`common.cancel`)}))return;let c=Bv(t.doc.content,i?`Done`:`Accepted`);if(c!==t.doc.content)try{await t.onsave(c),r&&await fetch(`/api/metadata/`+encodeURIComponent(t.doc.id)+`/refresh`,{method:`POST`}),await Fv.load(t.doc.id),X.docStatuses={...X.docStatuses,[t.doc.id]:i?`Done`:`Accepted`}}catch(e){F(b,{text:Y(`doc.validate_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`},!0)}}kn(()=>{try{F(x,localStorage.getItem(`ld-full-width`)===`1`)}catch{}});let ne=P(!1),A=P(I([])),re=N(()=>!V(g)&&V(ne)&&V(A).length>0),ie=`ld-toc-w`,ae=P(!1),oe=P(null),se=P(null),ce=P(0);kn(()=>{if(!V(se))return;let e=new ResizeObserver(()=>{F(ce,V(se).offsetHeight,!0)});return e.observe(V(se)),F(ce,V(se).offsetHeight,!0),()=>e.disconnect()});function le(e){if(e.preventDefault(),!V(oe))return;let t=e.clientX,n=V(oe).getBoundingClientRect().width;F(ae,!0),V(oe).style.transition=`none`,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let r=e=>{let r=Math.max(160,Math.min(400,n-(e.clientX-t)));V(oe).style.width=r+`px`},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i),document.body.style.cursor=``,document.body.style.userSelect=``,F(ae,!1),V(oe).style.transition=``;try{localStorage.setItem(ie,String(parseInt(V(oe).style.width,10)))}catch{}};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)}kn(()=>{try{F(ne,localStorage.getItem(`ld-toc-open`)===`1`)}catch{}try{let e=parseInt(localStorage.getItem(ie)||``,10);V(oe)&&e>=160&&e<=400&&(V(oe).style.width=e+`px`)}catch{}});function ue(){F(ne,!V(ne));try{localStorage.setItem(`ld-toc-open`,V(ne)?`1`:`0`)}catch{}}function de(e){let t=document.getElementById(e),n=document.getElementById(`home-content-area`);if(!t||!n)return;let r=t.parentElement;for(;r&&r!==n;)r.tagName===`DETAILS`&&(r.open=!0),r=r.parentElement;D(t,!0)}async function fe(){try{await navigator.clipboard.writeText(decodeURIComponent(t.doc.id)),F(C,!0),setTimeout(()=>F(C,!1),1800)}catch{}}function pe(){window.print()}function me(e){V(i)&&Ly.start(V(i),{language:e,codeLabel:Y(`tts.code_label`),imageLabel:Y(`tts.image_label`),diagramLabel:Y(`tts.diagram_label`),tableLabel:Y(`tts.table_label`)})}function he(){let e=RC(t.doc.content);if(!e){F(w,!0);return}me(e)}async function ge(e){F(T,!0);try{let n=zC(t.doc.content,e);n!==t.doc.content&&await t.onsave(n),F(w,!1),me(e)}catch(e){F(b,{text:Y(`tts.language_save_failed`)+(e instanceof Error?e.message:String(e)),cls:`text-red-500 dark:text-red-400`},!0)}finally{F(T,!1)}}kn(()=>(t.doc.id,V(y),()=>{F(w,!1),Ly.stop()}));var _e=gw(),ve=R(_e),ye=L(ve),be=L(ye),xe=L(be),Se=L(xe),Ce=L(Se);q(Ce,17,()=>t.doc.folder||[],Qr,(e,t)=>{var n=UC(),r=L(n,!0);j(n),B(e=>{J(n,`title`,V(t)),G(r,e)},[()=>X_(V(t))]),W(e,n)});var we=z(Ce,2),Te=L(we,!0);j(we),j(Se);var Ee=z(Se,2),De=e=>{var n=WC(),r=L(n,!0);j(n),B(()=>G(r,t.doc.formattedDate)),W(e,n)};K(Ee,e=>{t.doc.formattedDate&&e(De)});var Oe=z(Ee,2),ke=L(Oe,!0);j(Oe);var Ae=z(Oe,2),je=e=>{var t=GC(),n=L(t);j(t),B(e=>{J(t,`title`,e),vi(t,1,`no-print inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-gray-200 text-xs text-gray-500 transition-colors hover:bg-gray-50 hover:text-blue-600 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-blue-400 ${V(C)?`text-green-600 dark:text-green-400`:``}`),vi(n,1,`fa-${V(C)?`solid fa-check`:`regular fa-copy`}`)},[()=>Y(`doc.copy_mcp_id`)]),H(`click`,t,fe),W(e,t)};K(Ae,e=>{V(g)||e(je)}),j(xe);var Me=z(xe,2),Ne=e=>{var n=qC();q(n,20,()=>t.doc.tags,e=>e,(e,t)=>{var n=KC(),r=L(n);j(n),B(()=>G(r,`#${t??``}`)),W(e,n)}),j(n),W(e,n)};K(Me,e=>{t.doc.tags&&t.doc.tags.length&&e(Ne)}),j(be);var Pe=z(be,2),Fe=L(Pe),Ie=e=>{var t=YC(),n=L(t),r=e=>{var t=JC(),n=L(t,!0);j(t),B(()=>{vi(t,1,`text-xs ${V(b).cls??``}`),G(n,V(b).text)}),W(e,t)};K(n,e=>{V(b)&&e(r)});var i=z(n,2),o=L(i,!0);j(i);var s=z(i,2),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(t),B((e,t,n,r)=>{G(o,e),J(s,`title`,t),G(c,n),G(u,r)},[()=>Y(`common.cancel`),()=>Y(`doc.snippets`),()=>Y(`doc.snippets_btn`),()=>Y(`common.save`)]),H(`click`,i,()=>V(a).cancelEdit()),H(`click`,s,()=>V(a).openSnippets()),H(`click`,l,()=>V(a).save()),W(e,t)},Le=e=>{let n=N(()=>X.markerActive?`#fef08a`:`#bfdbfe`),r=N(()=>X.markerActive?`#fef08a`:`#93c5fd`),i=N(()=>X.markerActive?`#fde047`:`#93c5fd`);var o=iw(),s=L(o),d=L(s),f=z(d,1,!0);j(s);var p=z(s,2),m=e=>{var t=XC(),n=z(L(t),1,!0);j(t),B((e,r)=>{J(t,`title`,e),G(n,r)},[()=>Y(`doc.validate_mode`),()=>Y(`doc.validate_btn`)]),H(`click`,t,k),W(e,t)};K(p,e=>{V(v)&&!V(g)&&e(m)});var h=z(p,2),y=e=>{var t=tw(),o=R(t),s=e=>{var t=ZC(),n=R(t),r=L(n);j(n);var i=z(n,2);B((e,t)=>{J(n,`title`,e),vi(r,1,`fa-solid ${Ly.status===`playing`?`fa-pause`:`fa-play`}`),J(i,`title`,t)},[()=>Ly.status===`playing`?Y(`tts.pause`):Y(`tts.resume`),()=>Y(`tts.stop`)]),H(`click`,n,()=>Ly.toggle()),H(`click`,i,()=>Ly.stop()),W(e,t)},d=e=>{var t=QC(),n=z(L(t),1,!0);j(t),B((e,r)=>{J(t,`title`,e),G(n,r)},[()=>Y(`tts.play`),()=>Y(`tts.play_btn`)]),H(`click`,t,he),W(e,t)};K(o,e=>{Ly.active?e(s):e(d,-1)});var f=z(o,2),p=L(f),m=L(p),h=z(m),g=z(h),_=z(g),v=z(_,2),y=e=>{W(e,$C())};K(v,e=>{X.markerHidden&&e(y)}),j(p);var b=z(p,1,!0);j(f);var x=z(f,2),S=L(x);j(x);var C=z(x,2),w=z(L(C));j(C);var T=z(C,2),E=e=>{var t=ew(),n=z(L(t));j(t),B((e,r)=>{J(t,`title`,e),G(n,` ${r??``}`)},[()=>Y(`versions.button_title`),()=>Y(`versions.button`)]),H(`click`,t,()=>F(l,!0)),W(e,t)};K(T,e=>{V(u)&&e(E)});var D=z(T,2),ee=z(L(D));j(D),B((e,t,a,o,s,c,l,u)=>{J(f,`title`,e),vi(f,1,`no-print text-sm px-3 py-1.5 rounded-lg border transition-colors ${X.markerActive?`border-yellow-400 bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-300`:`border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700`}`),J(m,`fill`,V(n)),J(h,`fill`,V(r)),J(g,`fill`,V(i)),J(_,`fill`,V(i)),G(b,t),J(x,`title`,a),G(S,`📄 ${o??``}`),J(C,`title`,s),G(w,` ${c??``}`),J(D,`title`,l),G(ee,` ${u??``}`)},[()=>Y(`doc.marker_mode`),()=>Y(`doc.marker_btn`),()=>Y(`doc.export_pdf`),()=>Y(`doc.export_pdf_btn`),()=>Y(`metadata.button_title`),()=>Y(`metadata.button`),()=>Y(`doc.edit`),()=>Y(`doc.edit_btn`)]),H(`click`,f,()=>X.toggleMarker()),H(`click`,x,pe),H(`click`,C,()=>F(c,!0)),H(`click`,D,()=>V(a).enterEdit()),W(e,t)};K(h,e=>{V(g)||e(y)});var b=z(h,2),x=e=>{var t=nw(),n=z(L(t));j(t),B((e,r)=>{J(t,`title`,e),G(n,` ${r??``}`)},[()=>Y(`kanban.edit_columns`),()=>Y(`kanban.edit_columns`)]),H(`click`,t,()=>V(a).openKanbanColumnsEditor()),W(e,t)};K(b,e=>{V(g)&&e(x)});var C=z(b,2),w=z(L(C));j(C);var T=z(C,2),E=e=>{var t=rw();B(e=>{J(t,`title`,e),vi(t,1,`no-print text-sm px-3 py-1.5 rounded-lg border transition-colors ${V(ne)?`border-blue-400 bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400`:`border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700`}`)},[()=>Y(`doc.toc_toggle`)]),H(`click`,t,ue),W(e,t)};K(T,e=>{V(g)||e(E)}),j(o),B((e,t,n,r)=>{J(s,`aria-pressed`,V(_)),J(s,`title`,e),vi(s,1,`no-print text-sm px-3 py-1.5 rounded-lg border transition-colors ${V(_)?`border-amber-300 bg-amber-50 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400`:`border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700`}`),vi(d,1,`fa-${V(_)?`solid`:`regular`} fa-star`),G(f,t),J(C,`title`,n),G(w,` ${r??``}`)},[()=>V(_)?Y(`favorites.remove`):Y(`favorites.add`),()=>Y(`favorites.button`),()=>Y(`doc.delete`),()=>Y(`doc.delete_btn`)]),H(`click`,s,()=>Ho.toggle({id:t.doc.id,title:t.doc.title})),H(`click`,C,()=>F(S,!0)),W(e,o)};K(Fe,e=>{V(y)?e(Ie):e(Le,-1)}),j(Pe),j(ye);var Re=z(ye,2),ze=e=>{Lv(e,{onopen:()=>F(c,!0)})};K(Re,e=>{!V(y)&&!V(g)&&e(ze)});var Be=z(Re,2),Ve=e=>{var n=sw();q(n,21,r,Qr,(e,n,r)=>{var i=ow(),a=R(i),o=e=>{W(e,aw())};K(a,e=>{r>0&&e(o)});var s=z(a,2),c=L(s);j(s),B(()=>G(c,`← ${V(n).title??``}`)),H(`click`,s,()=>t.ongoback?.(r)),W(e,i)}),j(n),W(e,n)};K(Be,e=>{!V(y)&&r().length&&e(Ve)});var He=z(Be,2),Ue=e=>{var t=lw(),n=L(t),r=L(n,!0);j(n);var i=z(n,2);q(i,23,()=>V(f),e=>e.id,(e,t,n)=>{var r=cw(),i=L(r),a=L(i),o=L(a);j(a);var s=z(a),c=L(s,!0);j(s),j(i),j(r),B(()=>{G(o,`${V(n)+1}.`),G(c,V(t).snippet)}),H(`click`,i,()=>HC(V(t).id)),W(e,r)}),j(i),j(t),B(()=>G(r,V(m))),W(e,t)};K(He,e=>{!V(y)&&!V(g)&&V(f).length&&X.searchQuery&&e(Ue)});var We=z(He,2),Ge=e=>{var t=uw(),n=L(t,!0);j(t),B(()=>G(n,Ly.error)),W(e,t)};K(We,e=>{!V(y)&&!V(g)&&Ly.error&&e(Ge)});var Ke=z(We,2),Ye=e=>{var t=dw();Ui(t,e=>F(d,e),()=>V(d)),W(e,t)};K(Ke,e=>{V(g)||e(Ye)}),j(ve),Ui(ve,e=>F(se,e),()=>V(se));var Xe=z(ve,2),Ze=L(Xe);Ui(Vf(L(Ze),{get docId(){return t.doc.id},get content(){return t.doc.content},get html(){return t.doc.html},get onsave(){return t.onsave},get onopen(){return t.onopen},onanchor:ee,onconfirmdelete:O,oncontentwired:te,get rewireSignal(){return X.searchQuery},get editing(){return V(y)},set editing(e){F(y,e,!0)},get saveMsg(){return V(b)},set saveMsg(e){F(b,e,!0)}}),e=>F(a,e,!0),()=>V(a)),j(Ze);var Qe=z(Ze,2),$e=e=>{var t=pw(),n=R(t),r=z(n,2),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o);q(s,21,()=>V(A),Qr,(e,t)=>{var n=fw(),r=L(n),i=L(r,!0);j(r),j(n),B(()=>{bi(n,`padding-left: ${(V(t).level-1)*.75}rem`),J(r,`title`,V(t).text),G(i,V(t).text)}),H(`click`,r,()=>de(V(t).id)),W(e,n)}),j(s),j(o),j(r),Ui(r,e=>F(oe,e),()=>V(oe)),B(e=>{vi(n,1,`no-print w-1 shrink-0 self-stretch cursor-col-resize select-none transition-colors ${V(ae)?`bg-blue-500/60`:`bg-transparent hover:bg-blue-500/40`}`),bi(r,`width: 224px; top: ${V(ce)??``}px; min-height: calc(100vh - ${V(ce)??``}px); max-height: calc(100vh - ${V(ce)??``}px)`),G(a,e)},[()=>Y(`doc.toc_title`)]),H(`mousedown`,n,le),W(e,t)};K(Qe,e=>{V(re)&&e($e)}),j(Xe);var et=z(Xe,2),tt=e=>{Ui(kv(e,{get contentEl(){return V(i)},get docId(){return t.doc.id}}),e=>F(o,e,!0),()=>V(o))};K(et,e=>{V(g)||e(tt)});var nt=z(et,2);iy(nt,{get open(){return V(c)},get docId(){return t.doc.id},get content(){return t.doc.content},onclose:()=>F(c,!1)});var rt=z(nt,2);_y(rt,{get open(){return V(l)},get docId(){return t.doc.id},get content(){return t.doc.content},get onsave(){return t.onsave},onclose:()=>F(l,!1)});var it=z(rt,2);Ui(Xd(it,{}),e=>F(s,e,!0),()=>V(s));var at=z(it,2),ot=e=>{var t=mw(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a);var s=z(a,2),c=L(s),l=L(c,!0);j(c);var u=z(c,2),d=L(u,!0);j(u),j(s);var f=z(s,2),p=L(f),m=L(p,!0);j(p),j(f),j(n),j(t),B((e,t,n,r,a)=>{G(i,e),G(o,t),c.disabled=V(T),G(l,n),u.disabled=V(T),G(d,r),p.disabled=V(T),G(m,a)},[()=>Y(`tts.language_title`),()=>Y(`tts.language_message`),()=>Y(`tts.language_en`),()=>Y(`tts.language_fr`),()=>Y(`common.cancel`)]),H(`click`,t,e=>{e.target===e.currentTarget&&!V(T)&&F(w,!1)}),H(`click`,c,()=>ge(`en`)),H(`click`,u,()=>ge(`fr`)),H(`click`,p,()=>F(w,!1)),W(e,t)};K(at,e=>{V(w)&&e(ot)});var st=z(at,2),ct=e=>{var n=hw(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c),u=L(l,!0);j(l);var d=z(l,2),f=L(d,!0);j(d),j(c),j(r),j(n),B((e,n,r)=>{G(a,e),G(s,t.doc.title),G(u,n),G(f,r)},[()=>Y(`doc.confirm_delete`),()=>Y(`common.cancel`),()=>Y(`doc.confirm_delete_btn`)]),H(`click`,n,e=>{e.target===e.currentTarget&&F(S,!1)}),H(`click`,l,()=>F(S,!1)),H(`click`,d,async()=>{F(S,!1),await t.ondelete()}),W(e,n)};K(st,e=>{V(S)&&e(ct)}),B(()=>{G(Te,t.doc.category),G(ke,t.doc.title)}),W(e,_e),Je()}Pr([`click`,`mousedown`]);var vw=U(`<p class="px-3 py-4 text-xs text-gray-400 text-center"> </p>`),yw=U(`<p class="px-3 py-3 text-xs text-red-400 text-center"> </p>`),bw=U(`<p class="px-3 py-3 text-xs text-gray-400 text-center"> </p>`),xw=U(`<button class="w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"><span class="text-gray-400 shrink-0">📁</span> <span class="truncate text-gray-700 dark:text-gray-300"> </span></button>`),Sw=U(`<div class="border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden text-sm"><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"> </button> <span class="text-xs text-gray-500 dark:text-gray-400 font-mono truncate flex-1"> </span></div> <div class="max-h-40 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800"><!></div></div>`),Cw=U(`<p class="text-xs text-red-500"> </p>`),ww=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-md mx-4 p-6 space-y-4"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"><svg width="16" height="16" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="inline-block mr-1 align-text-bottom"><path d="M2 5a2 2 0 012-2h3.586a1 1 0 01.707.293L9.707 4.707A1 1 0 0010.414 5H16a2 2 0 012 2v8a2 2 0 01-2 2H4a2 2 0 01-2-2V5z" stroke="currentColor" stroke-width="1.5" fill="none"></path><line x1="10" y1="8" x2="10" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></line><line x1="7" y1="11" x2="13" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></line></svg> <span> </span></h3> <div class="space-y-1.5"><label for="new-folder-name" class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <input id="new-folder-name" type="text" class="w-full 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 focus:outline-none focus:ring-2 focus:ring-blue-500"/></div> <div class="space-y-1.5"><label class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <div class="flex items-center gap-2"><span class="flex-1 text-sm text-gray-600 dark:text-gray-300 font-mono truncate"> </span> <button class="text-xs px-2 py-1.5 rounded-lg border border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors shrink-0"> </button></div> <!></div> <div class="space-y-1"><label class="block text-xs font-medium text-gray-500 dark:text-gray-400"> </label> <p class="text-xs font-mono text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 truncate"> </p></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>`);function Tw(e,t){qe(t,!0);let n=P(``),r=P(null),i=P(null),a=P(``),o=P(``),s=P(`/ (root)`),c=P(!1),l=P(``),u=P(I([])),d=P(!1),f=P(!1),p=P(``),m=P(!1),h=P(null),g=!1;kn(()=>{t.open&&!g?(g=!0,_()):t.open||(g=!1)});async function _(){try{F(n,(await fetch(`/api/config`).then(e=>e.json())).docsFolder||``,!0)}catch{F(n,``)}let e=``;if(X.currentDocId){let t=decodeURIComponent(X.currentDocId);if(!t.startsWith(`/`)){let n=t.split(`/`);n.length>1&&(e=n.slice(0,-1).join(`/`))}}F(a,e?V(n)+`/`+e:V(n),!0),F(r,V(a),!0),F(i,null),F(o,``),F(s,e?`/`+e:`/ (root)`,!0),F(c,!1),F(p,``),F(m,!1),setTimeout(()=>V(h)?.focus(),50)}let v=N(()=>{let e=Oa(V(o));if(!e)return Y(`modal.new_folder.enter_name`);let t=V(a)||V(n),r=t.startsWith(V(n))?t.slice(V(n).length).replace(/^\//,``):``;return(r?r+`/`:``)+e});function y(e){let t=e.currentTarget,n=Oa(t.value);t.value!==n&&(t.value=n),V(o)!==n&&F(o,n,!0)}function b(){F(c,!V(c)),V(c)&&x(V(r)||V(n))}async function x(e){F(d,!0),F(f,!1);try{let t=await fetch(`/api/browse?path=`+encodeURIComponent(e)).then(e=>e.json());F(r,t.current,!0),F(i,t.parent,!0),F(a,t.current,!0),F(l,t.current,!0),F(s,(t.current.startsWith(V(n)+`/`)?t.current.slice(V(n).length):t.current===V(n)?``:t.current)||`/ (root)`,!0),F(u,t.dirs||[],!0)}catch{F(f,!0),F(u,[],!0)}finally{F(d,!1)}}let S=N(()=>V(r)===V(n));function C(){V(i)&&x(V(i))}async function w(){let e=Oa(V(o));if(F(p,``),!e){F(p,Y(`modal.new_folder.error_empty`),!0);return}if(!/^[a-zA-Z0-9_.-]+$/.test(e)){F(p,Y(`modal.new_folder.error_invalid_chars`),!0);return}let r=V(a)||V(n);if(r===V(n)&&(e===`files`||e===`images`)){F(p,Y(`modal.new_folder.error_reserved`),!0);return}let i=r.endsWith(`/`)?r+e:r+`/`+e;F(m,!0);try{let e=await fetch(`/api/browse/mkdir`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:i})});if(!e.ok)throw Error(await e.text());t.onclose(),t.onsuccess()}catch(e){F(m,!1),F(p,Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e)))}}var T=Wr(),E=R(T),D=e=>{var n=ww(),r=L(n),i=L(r),a=z(L(i),2),g=L(a,!0);j(a),j(i);var _=z(i,2),T=L(_),E=L(T,!0);j(T);var D=z(T,2);ki(D),Ui(D,e=>F(h,e),()=>V(h)),j(_);var ee=z(_,2),te=L(ee),O=L(te,!0);j(te);var k=z(te,2),ne=L(k),A=L(ne,!0);j(ne);var re=z(ne,2),ie=L(re,!0);j(re),j(k);var ae=z(k,2),oe=e=>{var t=Sw(),n=L(t),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a),j(n);var s=z(n,2),c=L(s),p=e=>{var t=vw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},m=e=>{var t=yw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`modal.new_folder.error_loading`)]),W(e,t)},h=e=>{var t=bw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`modal.new_folder.no_subfolders`)]),W(e,t)},g=e=>{var t=Wr();q(R(t),17,()=>V(u),e=>e.path,(e,t)=>{var n=xw(),r=z(L(n),2),i=L(r,!0);j(r),j(n),B(()=>G(i,V(t).name)),H(`click`,n,()=>x(V(t).path)),W(e,n)}),W(e,t)};K(c,e=>{V(d)?e(p):V(f)?e(m,1):V(u).length===0?e(h,2):e(g,-1)}),j(s),j(t),B(e=>{r.disabled=V(S),G(i,e),G(o,V(l))},[()=>Y(`common.up`)]),H(`click`,r,C),W(e,t)};K(ae,e=>{V(c)&&e(oe)}),j(ee);var se=z(ee,2),ce=L(se),le=L(ce,!0);j(ce);var ue=z(ce,2),de=L(ue,!0);j(ue),j(se);var fe=z(se,2),pe=e=>{var t=Cw(),n=L(t,!0);j(t),B(()=>G(n,V(p))),W(e,t)};K(fe,e=>{V(p)&&e(pe)});var me=z(fe,2),he=L(me),ge=L(he,!0);j(he);var _e=z(he,2),ve=L(_e,!0);j(_e),j(me),j(r),j(n),B((e,t,n,r,i,a,o,c)=>{G(g,e),G(E,t),J(D,`placeholder`,n),G(O,r),G(A,V(s)),G(ie,i),G(le,a),G(de,V(v)),G(ge,o),_e.disabled=V(m),G(ve,c)},[()=>Y(`modal.new_folder.title`),()=>Y(`modal.new_folder.name_label`),()=>Y(`modal.new_folder.name_placeholder`),()=>Y(`modal.new_folder.location_label`),()=>Y(`modal.new_folder.browse_btn`),()=>Y(`modal.new_folder.will_be_created`),()=>Y(`common.cancel`),()=>V(m)?Y(`modal.new_folder.creating_btn`):Y(`modal.new_folder.create_btn`)]),H(`click`,n,e=>{e.target===e.currentTarget&&t.onclose()}),H(`input`,D,y),Fi(D,()=>V(o),e=>F(o,e)),H(`click`,re,b),H(`click`,he,function(...e){t.onclose?.apply(this,e)}),H(`click`,_e,w),W(e,n)};K(E,e=>{t.open&&e(D)}),W(e,T),Je()}Pr([`click`,`input`]);var Ew=U(`<p class="text-sm text-gray-400 py-2"> </p>`),Dw=U(`<p class="text-sm text-red-500"> </p>`),Ow=U(`<label class="flex items-center gap-3 px-1 py-1.5 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer"><input type="checkbox" class="w-4 h-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"/> <span class="text-sm text-gray-700 dark:text-gray-300"> </span></label>`),kw=U(`<div><div class="max-h-48 overflow-y-auto space-y-0.5 border border-gray-200 dark:border-gray-700 rounded-lg p-2"><!></div></div>`),Aw=U(`<div><p class="text-xs text-gray-500 dark:text-gray-400"> </p> <div class="flex justify-end gap-3 pt-2"><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>`),jw=U(`<div><p class="text-xs text-gray-500 dark:text-gray-400"> </p> <div class="flex justify-end gap-3 pt-2"><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 border border-blue-500 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 font-semibold 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>`),Mw=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-4"><h3 class="text-base font-semibold text-gray-900 dark:text-gray-50"><i class="fa-solid fa-file-export mr-2 text-blue-500"></i> <span> </span></h3> <div class="flex gap-0 border-b border-gray-200 dark:border-gray-700"><button> </button> <button> </button> <button> </button></div> <!> <!> <!> <!></div></div>`);function Nw(e,t){qe(t,!0);let n=P(`markdown`),r=!1,i=P(!1),a=P(!1),o=P(I([])),s=P(I({})),c=P(!1),l=P(!1),u=P(!1),d=P(!1),f=!1;kn(()=>{t.open&&!f?(f=!0,F(n,`markdown`),r=!1,F(o,[],!0),F(s,{},!0)):t.open||(f=!1)});function p(e){return String(e??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function m(e){F(n,e,!0),e===`html`&&h()}async function h(){if(!r){F(i,!0),F(a,!1);try{let e=await fetch(`/api/documents`).then(e=>e.json()),t=new Set;e.forEach(e=>t.add(e.folder?.[0]??e.category??`General`)),F(o,[...t].sort((e,t)=>e===`General`?-1:t===`General`?1:e.localeCompare(t)),!0),r=!0}catch{F(a,!0)}finally{F(i,!1)}}}async function g(){F(c,!0);try{let e=await fetch(`/api/export/markdown`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!e.ok)throw Error(await e.text());let n=await e.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`export-markdown.zip`,i.click(),URL.revokeObjectURL(r),t.onclose()}catch(e){alert(Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e)))}finally{F(c,!1)}}async function _(e){let n=V(o).filter(e=>V(s)[e]);if(n.length){F(e===`confluence`?u:l,!0);try{let r=await fetch(`/api/export/html`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({folders:n,mode:e})});if(!r.ok)throw Error(await r.text());let i=await r.blob(),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`export-${e}.zip`,o.click(),URL.revokeObjectURL(a),t.onclose()}catch(e){alert(Y(`common.error_prefix`)+(e instanceof Error?e.message:String(e)))}finally{F(u,!1),F(l,!1)}}}async function v(){F(d,!0);try{let e=X.allDocs&&X.allDocs.length?X.allDocs:await fetch(`/api/documents`).then(e=>e.json()),n={};for(let t=0;t<e.length;t+=5){let r=e.slice(t,t+5),i=await Promise.all(r.map(e=>fetch(`/api/documents/`+e.id).then(e=>e.ok?e.json():null).catch(()=>null)));for(let r of i)r&&(n[r.id??e[t]?.id]=r);r.forEach((e,t)=>{i[t]&&(n[e.id]=i[t])})}function r(e){let t={categories:{},children:{}};for(let n of e){let e=t;for(let t of n.folder||[])e.children[t]||(e.children[t]={categories:{},children:{}}),e=e.children[t];e.categories[n.category]||(e.categories[n.category]=[]),e.categories[n.category].push(n)}return t}function i(e){let t=[];e.categories.General&&t.push(...e.categories.General);let n=Object.keys(e.children).sort((e,t)=>e.localeCompare(t));for(let r of n)t.push(...i(e.children[r]));let r=Object.keys(e.categories).filter(e=>e!==`General`).sort((e,t)=>e.localeCompare(t));for(let n of r)t.push(...e.categories[n]);return t}function a(e){return e.replace(/^\d+_/,``).replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function o(e,t){let n=``,r=t*1.25,i=(e,i)=>{let a=t===0&&e===`General`?`General`:e;n+=`<li style="margin-left:${r}rem;margin-top:${t===0?`0.75`:`0.4`}rem;">`,n+=`<span style="font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.05em;color:#6b7280;">${a}</span>`,n+=`<ul style="margin:0.2rem 0 0 0;padding:0;list-style:none;">`;for(let e of i)n+=`<li style="margin-left:${r+.75}rem;padding:0.15rem 0;">`,n+=`<a href="#doc-${e.id}" style="color:#1d4ed8;text-decoration:none;font-size:0.875rem;">${p(e.title)}</a>`,e.formattedDate&&(n+=`<span style="color:#9ca3af;font-size:0.7rem;margin-left:0.5rem;">${p(e.formattedDate)}</span>`),n+=`</li>`;n+=`</ul></li>`};e.categories.General&&i(`General`,e.categories.General);let s=Object.keys(e.children).sort((e,t)=>e.localeCompare(t));for(let i of s)n+=`<li style="margin-left:${r}rem;margin-top:0.75rem;">`,n+=`<span style="font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.05em;color:#7c3aed;">📁 ${a(i)}</span>`,n+=`<ul style="margin:0.2rem 0 0 0;padding:0;list-style:none;">`,n+=o(e.children[i],t+1),n+=`</ul></li>`;let c=Object.keys(e.categories).filter(e=>e!==`General`).sort((e,t)=>e.localeCompare(t));for(let t of c)i(t,e.categories[t]);return n}function s(e){return e.replace(/href="[^"]*\?doc=([^"&#]+)(?:#[^"]*)?"/g,(e,t)=>`href="#doc-${t}"`)}let c=p(document.title||`Living Documentation`),l=r(e),u=i(l),d=`<!DOCTYPE html>
|
|
225
225
|
<html>
|
|
226
226
|
<head>
|
|
227
227
|
<meta charset="UTF-8">
|
|
@@ -275,20 +275,20 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
275
275
|
setTimeout(() => window.print(), 800);
|
|
276
276
|
<\/script>
|
|
277
277
|
</body>
|
|
278
|
-
</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=Ew(),f=L(r),p=L(f),h=z(L(p),2),x=L(h,!0);j(h),j(p);var S=z(p,2),C=L(S),w=L(C,!0);j(C);var T=z(C,2),E=L(T,!0);j(T);var D=z(T,2),ee=L(D,!0);j(D),j(S);var te=z(S,2),O=e=>{var t=Cw(),n=L(t),r=L(n),c=e=>{var t=bw(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},l=e=>{var t=xw(),n=L(t);j(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=Sw(),r=L(n);ki(r);var i,a=z(r,2),o=L(a,!0);j(a),j(n),B(()=>{i!==(i=t)&&(r.value=(r.__value=t)??``),G(o,t)}),Ri(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)}),j(n),j(t),W(e,t)};K(te,e=>{V(n)===`html`&&e(O)});var k=z(te,2),ne=e=>{var n=ww(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var l=z(o,2),u=L(l,!0);j(l),j(a),j(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=Tw(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2),d=L(c,!0);j(c);var f=z(c,2),p=L(f,!0);j(f),j(a),j(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=ww(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2),l=L(c,!0);j(c),j(a),j(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)}),j(f),j(r),B((e,t,r,i)=>{G(x,e),vi(C,1,fi(V(n)===`markdown`?y:b)),G(w,t),vi(T,1,fi(V(n)===`html`?y:b)),G(E,r),vi(D,1,fi(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),Je()}Pr([`click`]);var Ow=U(`<p class="px-3 py-4 text-xs text-gray-400 text-center"> </p>`),kw=U(`<p> </p>`),Aw=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>`),jw=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>`),Mw=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>`),Nw=U(`<label class="flex items-center gap-1.5 text-xs text-gray-700 dark:text-gray-300 cursor-pointer"><input type="checkbox"/> </label>`),Pw=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>`),Fw=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>`),Iw=U(`<!> <!>`,1),Lw=U(`<div> </div>`),Rw=U(`<div> </div> <div> </div> <div> </div> <!>`,1),zw=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>`),Bw=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>`),Vw=U(`<p class="absolute inset-0 flex items-center justify-center text-gray-400 dark:text-gray-500 text-sm animate-pulse"> </p>`),Hw=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>`),Uw=U(`<div class="text-gray-400 text-center py-2">—</div>`),Ww=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>`),Gw=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 Kw(e,t){qe(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),te=P(``),O=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(te)&&Ne(V(te))}function ce(){V(S)&&Me()}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 Te(){F(ye,!V(ye)),V(ye)&&Ee(V(xe)||V(p)||`/`)}async function Ee(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 De(){V(be)&&Ee(V(be))}function Oe(){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 ke=P(null),Ae=P(null),je=P(!1);function Me(){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(je,!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(ke)||!V(Ae))return;let e=V(ke),t=V(Ae);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(je,!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=>Ne(e[0])})})}function Ne(e){if(!V(C)||!V(S))return;let t=[...V(C).get(e)||[]].sort(),n=V(S).get(e)||0;F(te,e,!0),F(O,n,!0),F(k,t,!0),F(ee,!0)}function Pe(){F(ee,!1)}async function Fe(){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(je,!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),Me()}catch(e){F(g,`Error: `+e.message)}}let Ie=!1;kn(()=>{t.open&&!Ie?(Ie=!0,F(g,`Choose a root folder and click Launch.`),F(_,!0),F(je,!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||(Ie=!1)});var Le=Wr(),Re=R(Le),ze=e=>{var n=Gw(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var c=z(r,2),l=L(c),u=L(l),d=L(u,!0);j(u);var f=z(u,2);ki(f);var b=z(f,2),S=z(L(b)),C=L(S,!0);j(S),j(b);var w=z(b,2),ne=L(w,!0);j(w),j(l);var ie=z(l,2),se=L(ie),le=L(se,!0);j(se);var fe=z(se,2);yn(fe);var xe=z(fe,2),Me=z(L(xe)),Ie=L(Me,!0);j(Me),j(xe),j(ie);var Le=z(ie,2),Re=e=>{var t=Mw(),n=L(t),r=L(n),i=z(r,2),a=L(i,!0);j(i),j(n);var o=z(n,2),s=L(o),c=e=>{var t=Ow(),n=L(t,!0);j(t),B(()=>G(n,V(he))),W(e,t)},l=e=>{var t=kw(),n=L(t,!0);j(t),B(()=>{vi(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),Qr,(e,t)=>{var n=Wr(),r=R(n),i=e=>{var n=Aw(),r=L(n),i=z(L(r),2),a=L(i,!0);j(i),j(r);var o=z(r,2);j(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=jw(),r=L(n),i=z(L(r),2),a=L(i,!0);j(i),j(r);var o=z(r,2);j(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)}),j(o),j(t),B(()=>{r.disabled=!V(de),G(a,V(pe))}),H(`click`,r,ve),W(e,t)};K(Le,e=>{V(ue)&&e(Re)});var ze=z(Le,2),Be=L(ze),Ve=L(Be,!0);j(Be);var He=z(Be,2),Ue=L(He);ki(Ue);var We=z(Ue);j(He),q(z(He,2),17,()=>V(y),e=>e.value,(e,t,n)=>{var r=Nw(),i=L(r);ki(i);var a=z(i);j(r),B(()=>G(a,` ${V(t).label??``}`)),H(`change`,i,re),Ri(i,()=>V(t).checked,e=>V(t).checked=e),W(e,r)}),j(ze);var Ge=z(ze,2),Ke=e=>{var t=Mw(),n=L(t),r=L(n),i=z(r,2),a=L(i,!0);j(i),j(n);var o=z(n,2),s=L(o),c=e=>{var t=Ow(),n=L(t,!0);j(t),B(()=>G(n,V(we))),W(e,t)},l=e=>{var t=Iw(),n=R(t),r=e=>{var t=kw(),n=L(t,!0);j(t),B(()=>{vi(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),Qr,(e,t)=>{var n=Pw(),r=L(n),i=z(L(r),2),a=L(i,!0);j(i),j(r);var o=z(r,2);j(n),B(()=>G(a,V(t).name)),H(`click`,r,()=>Ee(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=Fw(),n=z(L(t)),r=L(n,!0);j(n),j(t),B(()=>G(r,V(Se))),H(`click`,t,Oe),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)}),j(o),j(t),B(()=>{r.disabled=!V(be),G(a,V(Se))}),H(`click`,r,De),W(e,t)};K(Ge,e=>{V(ye)&&e(Ke)}),j(c);var qe=z(c,2),Je=L(qe),Ye=e=>{var t=Bw(),n=L(t),r=L(n),i=e=>{var t=Rw(),n=R(t),r=L(n);j(n);var i=z(n,2),a=L(i);j(i);var o=z(i,2),s=L(o);j(o);var c=z(o,2),l=e=>{var t=Lw(),n=L(t);j(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)}),j(n);var a=z(n,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2);ki(c);var l=z(c,2),u=L(l,!0);j(l),j(a);var d=z(a,2),f=L(d,!0);j(d);var p=z(d,2);q(p,21,()=>V(D),Qr,(e,t,n)=>{var r=zw(),i=L(r);i.textContent=n+1;var a=z(i,2),o=L(a),s=L(o),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(o);var d=z(o,2),f=L(d);j(d),j(a),j(r),B(()=>{G(c,V(t).word),G(u,V(t).freq),bi(f,`width:${V(t).pct??``}%`)}),H(`click`,r,()=>Ne(V(t).word)),W(e,r)}),j(p),j(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`)]),Fi(c,()=>V(h),e=>F(h,e)),H(`click`,l,ce),W(e,t)};K(Je,e=>{V(v)&&e(Ye)});var Xe=z(Je,2),Ze=L(Xe),Qe=e=>{var t=Vw(),n=L(t,!0);j(t),B(()=>G(n,V(g))),W(e,t)};K(Ze,e=>{V(_)&&e(Qe)});var $e=z(Ze,2);let et;Ui($e,e=>F(ke,e),()=>V(ke)),j(Xe),Ui(Xe,e=>F(Ae,e),()=>V(Ae));var tt=z(Xe,2),nt=e=>{var t=Ww(),n=L(t),r=L(n),i=L(r);j(r);var a=z(r,2);j(n);var o=z(n,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c),u=e=>{var t=Wr();q(R(t),17,()=>V(k),Qr,(e,t)=>{var n=Hw(),r=L(n),i=L(r,!0);j(r);var a=z(r,2);j(n),B(()=>G(i,V(t))),H(`click`,a,()=>ae(V(t))),W(e,n)}),W(e,t)},d=e=>{W(e,Uw())};K(l,e=>{V(k).length?e(u):e(d,-1)}),j(c),j(t),B(e=>{G(i,`${V(te)??``} ×${V(O)??``}`),G(s,e)},[()=>Y(`wc.found_in`)]),H(`click`,a,Pe),W(e,t)};K(tt,e=>{V(ee)&&e(nt)}),j(qe),j(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(Ie,l),G(Ve,u),ji(Ue,V(x)),G(We,` ${f??``}`),et=vi($e,1,``,null,et,{hidden:!V(je)})},[()=>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)}),Fi(f,()=>V(p),e=>F(p,e)),H(`click`,b,Te),H(`click`,w,Fe),H(`input`,fe,oe),Fi(fe,()=>V(m),e=>F(m,e)),H(`click`,xe,ge),H(`change`,Ue,A),W(e,n)};K(Re,e=>{t.open&&e(ze)}),W(e,Le),Je()}Pr([`click`,`input`,`change`]);var qw=U(`<button title="Toggle dark mode" class="ghost-button" aria-label="Toggle dark mode"> </button>`),Jw=U(`<button class="ghost-button"><i class="fa-solid fa-cloud"></i></button> <!>`,1),Yw=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>`),Xw=U(`<p class="p-8 text-red-500"> </p>`),Zw=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>`),Qw=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 $w(e,t){qe(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(!1),d=P(`Living AI Documentation`),f=P(`YYYY_MM_DD_HH_mm_[Category]_title.md`),p=null;function m(){try{let e=localStorage.getItem(`ld-dark`);if(e!==null)return e===`true`}catch{}return window.matchMedia(`(prefers-color-scheme: dark)`).matches}function h(e){es()&&(e=!1),F(l,e,!0),document.documentElement.classList.toggle(`dark`,e)}function g(){h(!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 _(e){let t=e.trim();if(p&&clearTimeout(p),!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())),p=window.setTimeout(async()=>{try{let e=await I_(t);t===X.searchQuery&&(X.searchResults=e)}catch{}},350)}let v=P(I([]));function y(e){let t=V(v)[e];t&&(F(v,V(v).slice(0,e),!0),b(t.id,!1,`restore`))}async function b(e,t=!1,n=!1,r=null){if(n===!0&&X.currentDocId&&X.currentDocId!==e){let t=V(v).findIndex(t=>t.id===e);if(t!==-1)F(v,V(v).slice(0,t),!0);else{let e=X.allDocs.find(e=>e.id===X.currentDocId);F(v,[...V(v),{id:X.currentDocId,title:e?e.title:X.currentDocId}],!0)}}else n||F(v,[],!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 M_(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 x(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 M_(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 S(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 C(){if(!V(o))return;let e=V(o).id;if(!(await fetch(`/api/documents/`+encodeURIComponent(e),{method:`DELETE`})).ok)return;let t=S(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 b(t):(X.currentDocId=null,F(o,null),history.pushState({},``,location.pathname))}async function w(){let[e,t]=await Promise.all([A_(),k_()]);if(X.allDocs=e,X.docsFolder=typeof t.docsFolder==`string`?t.docsFolder:``,t.docsFolder)try{X.allFolderPaths=await j_(t.docsFolder)}catch{X.allFolderPaths=[]}let[n,r,i]=await Promise.all([N_(),P_(),F_()]);X.annotationCounts=n,X.fileAttachmentCounts=r,X.docStatuses=i}Ji(async()=>{F(u,es(),!0),h(m());let e=await k_();await Sa(e.language||`en`),e.title&&(document.title=e.title,F(d,e.title,!0)),e.filenamePattern&&F(f,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.sidebarSort=[`recent`,`oldest`,`alphabetical`].includes(e.sidebarSort)?e.sidebarSort:`recent`,X.codeBlockMaxHeight>0&&document.documentElement.style.setProperty(`--ld-code-max-h`,X.codeBlockMaxHeight+`px`),X.expandedCategories.size===0&&(X.expandedCategories=new Set([`DOCUMENTATION`,`General`])),await w();let t=new URLSearchParams(location.search).get(`doc`);if(t)b(t,!0,!1,location.hash?location.hash.slice(1):null);else{let t=Array.isArray(e.favorites)?e.favorites:[],n=t.length?t[0]?.id:void 0,r=(n?X.allDocs.find(e=>e.id===n):void 0)??X.allDocs.find(e=>e.category===`DOCUMENTATION`)??X.allDocs.find(e=>e.category===`General`)??X.allDocs[0];r&&b(r.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&&b(t,!0,!1,n)};window.addEventListener(`popstate`,n);let r=()=>{w()};return window.addEventListener(`ld:documents-changed`,r),()=>{window.removeEventListener(`popstate`,n),window.removeEventListener(`ld:documents-changed`,r)}});var T=Qw(),E=R(T),D=L(E);Xo(D,{get title(){return V(d)},subtitle:``,actions:e=>{var t=Jw(),n=R(t),r=z(n,2),i=e=>{var t=qw(),n=L(t,!0);j(t),B(()=>G(n,V(l)?`☀`:`☾`)),H(`click`,t,g),W(e,t)};K(r,e=>{V(u)||e(i)}),B((e,t)=>{J(n,`title`,e),J(n,`aria-label`,t)},[()=>Y(`nav.word_cloud`),()=>Y(`nav.word_cloud`)]),H(`click`,n,()=>F(a,!0)),W(e,t)},children:(e,t)=>{var n=Yw(),r=L(n);ki(r),Ie(2),j(n),B(e=>{J(r,`placeholder`,e),Ai(r,X.searchQuery)},[()=>Y(`nav.search_placeholder`)]),H(`input`,r,e=>_(e.target.value)),W(e,n)},$$slots:{actions:!0,default:!0}});var ee=z(D,2),te=L(ee);dv(te,{onopen:e=>b(e),onsearch:_,onexport:()=>F(i,!0),onnewfolder:()=>F(n,!0),onnewdoc:()=>F(r,!0)});var O=z(te,2),k=L(O),ne=e=>{var t=Wr(),n=R(t),r=e=>{var t=Xw(),n=L(t,!0);j(t),B(()=>G(n,V(c))),W(e,t)},i=e=>{dw(e,{get doc(){return V(o)},get navHistory(){return V(v)},ongoback:y,onopen:(e,t)=>b(e,!1,!0,t),onsave:x,ondelete:C})};K(n,e=>{V(c)?e(r):e(i,-1)}),W(e,t)},A=e=>{var t=Zw(),n=L(t),r=z(L(n),2),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a);var s=z(a,2),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(n),j(t),B((e,t,n)=>{G(i,e),G(o,t),G(c,V(f)),G(u,n)},[()=>Y(`welcome.title`),()=>Y(`welcome.hint`),()=>Y(`welcome.pattern_hint`)]),W(e,t)};K(k,e=>{V(o)?e(ne):e(A,-1)}),j(O),j(ee),j(E);var re=z(E,2);yw(re,{get open(){return V(n)},onclose:()=>F(n,!1),onsuccess:w});var ie=z(re,2);Wa(ie,{get open(){return V(r)},onclose:()=>F(r,!1),onsuccess:async e=>{await w(),b(e)}});var ae=z(ie,2);Dw(ae,{get open(){return V(i)},onclose:()=>F(i,!1)}),Kw(z(ae,2),{get open(){return V(a)},onclose:()=>F(a,!1)}),W(e,T),Je()}Pr([`click`,`input`]);var eT=`modulepreload`,tT=function(e){return`/`+e},nT={},rT=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=tT(t,n),t=s(t),t in nT)return;nT[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`:eT,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)})},iT=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.
|
|
278
|
+
</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=Mw(),f=L(r),p=L(f),h=z(L(p),2),x=L(h,!0);j(h),j(p);var S=z(p,2),C=L(S),w=L(C,!0);j(C);var T=z(C,2),E=L(T,!0);j(T);var D=z(T,2),ee=L(D,!0);j(D),j(S);var te=z(S,2),O=e=>{var t=kw(),n=L(t),r=L(n),c=e=>{var t=Ew(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},l=e=>{var t=Dw(),n=L(t);j(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=Ow(),r=L(n);ki(r);var i,a=z(r,2),o=L(a,!0);j(a),j(n),B(()=>{i!==(i=t)&&(r.value=(r.__value=t)??``),G(o,t)}),Ri(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)}),j(n),j(t),W(e,t)};K(te,e=>{V(n)===`html`&&e(O)});var k=z(te,2),ne=e=>{var n=Aw(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var l=z(o,2),u=L(l,!0);j(l),j(a),j(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=jw(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2),d=L(c,!0);j(c);var f=z(c,2),p=L(f,!0);j(f),j(a),j(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=Aw(),r=L(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2),l=L(c,!0);j(c),j(a),j(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)}),j(f),j(r),B((e,t,r,i)=>{G(x,e),vi(C,1,fi(V(n)===`markdown`?y:b)),G(w,t),vi(T,1,fi(V(n)===`html`?y:b)),G(E,r),vi(D,1,fi(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),Je()}Pr([`click`]);var Pw=U(`<p class="px-3 py-4 text-xs text-gray-400 text-center"> </p>`),Fw=U(`<p> </p>`),Iw=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>`),Lw=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>`),Rw=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>`),zw=U(`<label class="flex items-center gap-1.5 text-xs text-gray-700 dark:text-gray-300 cursor-pointer"><input type="checkbox"/> </label>`),Bw=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>`),Vw=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>`),Hw=U(`<!> <!>`,1),Uw=U(`<div> </div>`),Ww=U(`<div> </div> <div> </div> <div> </div> <!>`,1),Gw=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>`),Kw=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>`),qw=U(`<p class="absolute inset-0 flex items-center justify-center text-gray-400 dark:text-gray-500 text-sm animate-pulse"> </p>`),Jw=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>`),Yw=U(`<div class="text-gray-400 text-center py-2">—</div>`),Xw=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>`),Zw=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 Qw(e,t){qe(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),te=P(``),O=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(te)&&Ne(V(te))}function ce(){V(S)&&Me()}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 Te(){F(ye,!V(ye)),V(ye)&&Ee(V(xe)||V(p)||`/`)}async function Ee(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 De(){V(be)&&Ee(V(be))}function Oe(){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 ke=P(null),Ae=P(null),je=P(!1);function Me(){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(je,!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(ke)||!V(Ae))return;let e=V(ke),t=V(Ae);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(je,!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=>Ne(e[0])})})}function Ne(e){if(!V(C)||!V(S))return;let t=[...V(C).get(e)||[]].sort(),n=V(S).get(e)||0;F(te,e,!0),F(O,n,!0),F(k,t,!0),F(ee,!0)}function Pe(){F(ee,!1)}async function Fe(){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(je,!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),Me()}catch(e){F(g,`Error: `+e.message)}}let Ie=!1;kn(()=>{t.open&&!Ie?(Ie=!0,F(g,`Choose a root folder and click Launch.`),F(_,!0),F(je,!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||(Ie=!1)});var Le=Wr(),Re=R(Le),ze=e=>{var n=Zw(),r=L(n),i=L(r),a=L(i,!0);j(i);var o=z(i,2),s=L(o,!0);j(o),j(r);var c=z(r,2),l=L(c),u=L(l),d=L(u,!0);j(u);var f=z(u,2);ki(f);var b=z(f,2),S=z(L(b)),C=L(S,!0);j(S),j(b);var w=z(b,2),ne=L(w,!0);j(w),j(l);var ie=z(l,2),se=L(ie),le=L(se,!0);j(se);var fe=z(se,2);yn(fe);var xe=z(fe,2),Me=z(L(xe)),Ie=L(Me,!0);j(Me),j(xe),j(ie);var Le=z(ie,2),Re=e=>{var t=Rw(),n=L(t),r=L(n),i=z(r,2),a=L(i,!0);j(i),j(n);var o=z(n,2),s=L(o),c=e=>{var t=Pw(),n=L(t,!0);j(t),B(()=>G(n,V(he))),W(e,t)},l=e=>{var t=Fw(),n=L(t,!0);j(t),B(()=>{vi(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),Qr,(e,t)=>{var n=Wr(),r=R(n),i=e=>{var n=Iw(),r=L(n),i=z(L(r),2),a=L(i,!0);j(i),j(r);var o=z(r,2);j(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=Lw(),r=L(n),i=z(L(r),2),a=L(i,!0);j(i),j(r);var o=z(r,2);j(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)}),j(o),j(t),B(()=>{r.disabled=!V(de),G(a,V(pe))}),H(`click`,r,ve),W(e,t)};K(Le,e=>{V(ue)&&e(Re)});var ze=z(Le,2),Be=L(ze),Ve=L(Be,!0);j(Be);var He=z(Be,2),Ue=L(He);ki(Ue);var We=z(Ue);j(He),q(z(He,2),17,()=>V(y),e=>e.value,(e,t,n)=>{var r=zw(),i=L(r);ki(i);var a=z(i);j(r),B(()=>G(a,` ${V(t).label??``}`)),H(`change`,i,re),Ri(i,()=>V(t).checked,e=>V(t).checked=e),W(e,r)}),j(ze);var Ge=z(ze,2),Ke=e=>{var t=Rw(),n=L(t),r=L(n),i=z(r,2),a=L(i,!0);j(i),j(n);var o=z(n,2),s=L(o),c=e=>{var t=Pw(),n=L(t,!0);j(t),B(()=>G(n,V(we))),W(e,t)},l=e=>{var t=Hw(),n=R(t),r=e=>{var t=Fw(),n=L(t,!0);j(t),B(()=>{vi(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),Qr,(e,t)=>{var n=Bw(),r=L(n),i=z(L(r),2),a=L(i,!0);j(i),j(r);var o=z(r,2);j(n),B(()=>G(a,V(t).name)),H(`click`,r,()=>Ee(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=Vw(),n=z(L(t)),r=L(n,!0);j(n),j(t),B(()=>G(r,V(Se))),H(`click`,t,Oe),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)}),j(o),j(t),B(()=>{r.disabled=!V(be),G(a,V(Se))}),H(`click`,r,De),W(e,t)};K(Ge,e=>{V(ye)&&e(Ke)}),j(c);var qe=z(c,2),Je=L(qe),Ye=e=>{var t=Kw(),n=L(t),r=L(n),i=e=>{var t=Ww(),n=R(t),r=L(n);j(n);var i=z(n,2),a=L(i);j(i);var o=z(i,2),s=L(o);j(o);var c=z(o,2),l=e=>{var t=Uw(),n=L(t);j(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)}),j(n);var a=z(n,2),o=L(a),s=L(o,!0);j(o);var c=z(o,2);ki(c);var l=z(c,2),u=L(l,!0);j(l),j(a);var d=z(a,2),f=L(d,!0);j(d);var p=z(d,2);q(p,21,()=>V(D),Qr,(e,t,n)=>{var r=Gw(),i=L(r);i.textContent=n+1;var a=z(i,2),o=L(a),s=L(o),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(o);var d=z(o,2),f=L(d);j(d),j(a),j(r),B(()=>{G(c,V(t).word),G(u,V(t).freq),bi(f,`width:${V(t).pct??``}%`)}),H(`click`,r,()=>Ne(V(t).word)),W(e,r)}),j(p),j(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`)]),Fi(c,()=>V(h),e=>F(h,e)),H(`click`,l,ce),W(e,t)};K(Je,e=>{V(v)&&e(Ye)});var Xe=z(Je,2),Ze=L(Xe),Qe=e=>{var t=qw(),n=L(t,!0);j(t),B(()=>G(n,V(g))),W(e,t)};K(Ze,e=>{V(_)&&e(Qe)});var $e=z(Ze,2);let et;Ui($e,e=>F(ke,e),()=>V(ke)),j(Xe),Ui(Xe,e=>F(Ae,e),()=>V(Ae));var tt=z(Xe,2),nt=e=>{var t=Xw(),n=L(t),r=L(n),i=L(r);j(r);var a=z(r,2);j(n);var o=z(n,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c),u=e=>{var t=Wr();q(R(t),17,()=>V(k),Qr,(e,t)=>{var n=Jw(),r=L(n),i=L(r,!0);j(r);var a=z(r,2);j(n),B(()=>G(i,V(t))),H(`click`,a,()=>ae(V(t))),W(e,n)}),W(e,t)},d=e=>{W(e,Yw())};K(l,e=>{V(k).length?e(u):e(d,-1)}),j(c),j(t),B(e=>{G(i,`${V(te)??``} ×${V(O)??``}`),G(s,e)},[()=>Y(`wc.found_in`)]),H(`click`,a,Pe),W(e,t)};K(tt,e=>{V(ee)&&e(nt)}),j(qe),j(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(Ie,l),G(Ve,u),ji(Ue,V(x)),G(We,` ${f??``}`),et=vi($e,1,``,null,et,{hidden:!V(je)})},[()=>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)}),Fi(f,()=>V(p),e=>F(p,e)),H(`click`,b,Te),H(`click`,w,Fe),H(`input`,fe,oe),Fi(fe,()=>V(m),e=>F(m,e)),H(`click`,xe,ge),H(`change`,Ue,A),W(e,n)};K(Re,e=>{t.open&&e(ze)}),W(e,Le),Je()}Pr([`click`,`input`,`change`]);var $w=U(`<button title="Toggle dark mode" class="ghost-button" aria-label="Toggle dark mode"> </button>`),eT=U(`<button class="ghost-button"><i class="fa-solid fa-cloud"></i></button> <!>`,1),tT=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>`),nT=U(`<p class="p-8 text-red-500"> </p>`),rT=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>`),iT=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 aT(e,t){qe(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(!1),d=P(`Living AI Documentation`),f=P(`YYYY_MM_DD_HH_mm_[Category]_title.md`),p=null;function m(){try{let e=localStorage.getItem(`ld-dark`);if(e!==null)return e===`true`}catch{}return window.matchMedia(`(prefers-color-scheme: dark)`).matches}function h(e){es()&&(e=!1),F(l,e,!0),document.documentElement.classList.toggle(`dark`,e)}function g(){h(!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 _(e){let t=e.trim();if(p&&clearTimeout(p),!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())),p=window.setTimeout(async()=>{try{let e=await H_(t);t===X.searchQuery&&(X.searchResults=e)}catch{}},350)}let v=P(I([]));function y(e){let t=V(v)[e];t&&(F(v,V(v).slice(0,e),!0),b(t.id,!1,`restore`))}async function b(e,t=!1,n=!1,r=null){if(n===!0&&X.currentDocId&&X.currentDocId!==e){let t=V(v).findIndex(t=>t.id===e);if(t!==-1)F(v,V(v).slice(0,t),!0);else{let e=X.allDocs.find(e=>e.id===X.currentDocId);F(v,[...V(v),{id:X.currentDocId,title:e?e.title:X.currentDocId}],!0)}}else n||F(v,[],!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 R_(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 x(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 R_(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 S(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 C(){if(!V(o))return;let e=V(o).id;if(!(await fetch(`/api/documents/`+encodeURIComponent(e),{method:`DELETE`})).ok)return;let t=S(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 b(t):(X.currentDocId=null,F(o,null),history.pushState({},``,location.pathname))}async function w(){let[e,t]=await Promise.all([I_(),F_()]);if(X.allDocs=e,X.docsFolder=typeof t.docsFolder==`string`?t.docsFolder:``,t.docsFolder)try{X.allFolderPaths=await L_(t.docsFolder)}catch{X.allFolderPaths=[]}let[n,r,i]=await Promise.all([z_(),B_(),V_()]);X.annotationCounts=n,X.fileAttachmentCounts=r,X.docStatuses=i}Ji(async()=>{F(u,es(),!0),h(m());let e=await F_();await Sa(e.language||`en`),e.title&&(document.title=e.title,F(d,e.title,!0)),e.filenamePattern&&F(f,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.sidebarSort=[`recent`,`oldest`,`alphabetical`].includes(e.sidebarSort)?e.sidebarSort:`recent`,X.codeBlockMaxHeight>0&&document.documentElement.style.setProperty(`--ld-code-max-h`,X.codeBlockMaxHeight+`px`),X.expandedCategories.size===0&&(X.expandedCategories=new Set([`DOCUMENTATION`,`General`])),await w();let t=new URLSearchParams(location.search).get(`doc`);if(t)b(t,!0,!1,location.hash?location.hash.slice(1):null);else{let t=Array.isArray(e.favorites)?e.favorites:[],n=t.length?t[0]?.id:void 0,r=(n?X.allDocs.find(e=>e.id===n):void 0)??X.allDocs.find(e=>e.category===`DOCUMENTATION`)??X.allDocs.find(e=>e.category===`General`)??X.allDocs[0];r&&b(r.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&&b(t,!0,!1,n)};window.addEventListener(`popstate`,n);let r=()=>{w()};return window.addEventListener(`ld:documents-changed`,r),()=>{window.removeEventListener(`popstate`,n),window.removeEventListener(`ld:documents-changed`,r)}});var T=iT(),E=R(T),D=L(E);Xo(D,{get title(){return V(d)},subtitle:``,actions:e=>{var t=eT(),n=R(t),r=z(n,2),i=e=>{var t=$w(),n=L(t,!0);j(t),B(()=>G(n,V(l)?`☀`:`☾`)),H(`click`,t,g),W(e,t)};K(r,e=>{V(u)||e(i)}),B((e,t)=>{J(n,`title`,e),J(n,`aria-label`,t)},[()=>Y(`nav.word_cloud`),()=>Y(`nav.word_cloud`)]),H(`click`,n,()=>F(a,!0)),W(e,t)},children:(e,t)=>{var n=tT(),r=L(n);ki(r),Ie(2),j(n),B(e=>{J(r,`placeholder`,e),Ai(r,X.searchQuery)},[()=>Y(`nav.search_placeholder`)]),H(`input`,r,e=>_(e.target.value)),W(e,n)},$$slots:{actions:!0,default:!0}});var ee=z(D,2),te=L(ee);_v(te,{onopen:e=>b(e),onsearch:_,onexport:()=>F(i,!0),onnewfolder:()=>F(n,!0),onnewdoc:()=>F(r,!0)});var O=z(te,2),k=L(O),ne=e=>{var t=Wr(),n=R(t),r=e=>{var t=nT(),n=L(t,!0);j(t),B(()=>G(n,V(c))),W(e,t)},i=e=>{_w(e,{get doc(){return V(o)},get navHistory(){return V(v)},ongoback:y,onopen:(e,t)=>b(e,!1,!0,t),onsave:x,ondelete:C})};K(n,e=>{V(c)?e(r):e(i,-1)}),W(e,t)},A=e=>{var t=rT(),n=L(t),r=z(L(n),2),i=L(r,!0);j(r);var a=z(r,2),o=L(a,!0);j(a);var s=z(a,2),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(n),j(t),B((e,t,n)=>{G(i,e),G(o,t),G(c,V(f)),G(u,n)},[()=>Y(`welcome.title`),()=>Y(`welcome.hint`),()=>Y(`welcome.pattern_hint`)]),W(e,t)};K(k,e=>{V(o)?e(ne):e(A,-1)}),j(O),j(ee),j(E);var re=z(E,2);Tw(re,{get open(){return V(n)},onclose:()=>F(n,!1),onsuccess:w});var ie=z(re,2);Wa(ie,{get open(){return V(r)},onclose:()=>F(r,!1),onsuccess:async e=>{await w(),b(e)}});var ae=z(ie,2);Nw(ae,{get open(){return V(i)},onclose:()=>F(i,!1)}),Qw(z(ae,2),{get open(){return V(a)},onclose:()=>F(a,!1)}),W(e,T),Je()}Pr([`click`,`input`]);var oT=`modulepreload`,sT=function(e){return`/`+e},cT={},lT=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=sT(t,n),t=s(t),t in cT)return;cT[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`:oT,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)})},uT=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.
|
|
279
279
|
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
|
|
280
280
|
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
|
|
281
|
-
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 aT(e,t){qe(t,!0),Ji(()=>{let e;return(async()=>{let t=`en`;try{t=(await fetch(`/api/config`).then(e=>e.json())).language||`en`}catch{}await Sa(t);let{initDiagram:r}=await rT(async()=>{let{initDiagram:e}=await import(`./main-D-b1ZWKj.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=iT(),o=L(a),s=L(o),c=L(s,!0);j(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),te=z(ee,4),O=z(te,4),k=z(O,4),ne=z(k,2),A=z(ne,8),re=z(A,4),ie=z(re,4),ae=L(ie),oe=L(ae,!0);j(ae),j(ie),j(o);var se=z(o,2),ce=L(se),le=L(ce),ue=L(le),de=L(ue,!0);j(ue);var fe=z(ue,2),pe=L(fe,!0);j(fe),j(le),Ie(2),j(ce);var me=z(ce,2),he=z(me,2),ge=z(L(he),10),_e=z(L(ge),8),ve=z(_e,2);j(ge);var ye=z(ge,2),be=L(ye),xe=L(be),Se=L(xe,!0);j(xe);var Ce=z(xe,2);j(be),Ie(2),j(ye);var we=z(ye,2),Te=L(we),Ee=z(Te,4),De=L(Ee),Oe=z(De,4),ke=z(Oe,4),Ae=z(ke,2),je=z(Ae,4),Me=z(je,2),Ne=z(Me,2),Pe=z(Ne,4),Fe=z(Pe,2),Le=z(Fe,2),Re=z(Le,4),ze=z(Re,2),Be=z(ze,2),Ve=z(Be,4),He=L(Ve),Ue=z(He,2),We=z(Ue,2),Ge=z(We,2),Ke=z(Ge,2);Ie(2),j(Ve);var Ye=z(Ve,2),Xe=z(Ye,2),Ze=z(Xe,4),Qe=z(Ze,2),$e=z(Qe,2),et=z($e,4),tt=z(et,2),nt=z(tt,4),rt=z(nt,4),it=z(rt,2),at=z(it,4);j(Ee),j(we);var ot=z(we,2),st=L(ot),ct=L(st,!0);j(st);var lt=z(st,2),ut=z(L(lt),2),dt=L(ut,!0);j(ut),j(lt);var ft=z(lt,2),M=L(ft);j(ft);var pt=z(ft,2),mt=z(L(pt),2),ht=L(mt,!0);j(mt),j(pt);var gt=z(pt,4),_t=z(L(gt),2),vt=L(_t,!0);j(_t),j(gt);var yt=z(gt,2),N=L(yt);j(yt);var bt=z(yt,2),xt=L(bt),St=L(xt,!0);j(xt);var Ct=z(xt,2),wt=L(Ct,!0);j(Ct),Ie(2),j(bt),j(ot);var Tt=z(ot,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);j(Dt),j(Tt);var Zt=z(Tt,2),Qt=z(Zt,2),$t=z(L(Qt),2),en=L($t,!0);j($t),j(Qt),j(he),j(se);var tn=z(se,4),nn=L(tn),I=L(nn),rn=L(I,!0);j(I);var an=z(I,4),on=L(an);Ie(2),j(an);var sn=z(an,2),cn=L(sn,!0);j(sn);var ln=z(sn,2),un=L(ln),dn=L(un,!0);j(un);var fn=z(un,2),pn=L(fn,!0);j(fn),j(ln),j(nn),j(tn),j(a),B((e,t,n,i,a,o,s,ie,ae,se,ce,le,ue,fe,he,ge,ye,be,xe,we,Ee,j,Ie,Ve,qe,Je,ot,st,lt,ut,ft,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`,Ee),J(te,`placeholder`,j),J(O,`title`,Ie),J(k,`title`,Ve),J(ne,`title`,qe),J(A,`title`,Je),J(re,`title`,ot),G(oe,st),G(de,lt),G(pe,ut),vi(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`,ft),J(ve,`title`,pt),G(Se,mt),J(Ce,`title`,gt),J(Te,`title`,_t),J(De,`title`,yt),J(Oe,`title`,bt),J(ke,`title`,xt),J(Ae,`title`,Ct),J(je,`title`,Tt),J(Me,`title`,Dt),J(Ne,`title`,P),J(Pe,`title`,Qt),J(Fe,`title`,F),J(Le,`title`,$t),J(Re,`title`,tn),J(ze,`title`,nn),J(Be,`title`,I),J(He,`title`,an),J(Ue,`title`,sn),J(We,`title`,ln),J(Ge,`title`,un),J(Ke,`title`,fn),J(Ye,`title`,L),J(Xe,`title`,R),J(Ze,`title`,z),J(Qe,`title`,mn),J($e,`title`,hn),J(et,`title`,gn),J(tt,`title`,_n),J(nt,`title`,vn),J(rt,`title`,yn),J(it,`title`,bn),J(at,`title`,xn),G(ct,Sn),G(dt,Cn),J(M,`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),Je()}Pr([`click`,`mousedown`]);var oT=U(`<span class="legend-item svelte-1bqlvrg"><span class="legend-dot svelte-1bqlvrg"></span> </span>`),sT=U(`<p class="graph-msg svelte-1bqlvrg"> </p>`),cT=U(`<p class="graph-msg graph-error svelte-1bqlvrg"> </p>`),lT=U(`<div class="graph-page svelte-1bqlvrg"><!> <div class="graph-toolbar svelte-1bqlvrg"><span class="graph-counts svelte-1bqlvrg"> </span> <div class="graph-legend svelte-1bqlvrg"></div></div> <div class="graph-canvas-wrap svelte-1bqlvrg"><!> <div class="graph-canvas svelte-1bqlvrg"></div></div></div>`);function uT(e,t){qe(t,!0);let n={ADR:`#3b82f6`,Worklog:`#22c55e`,Rule:`#f97316`,"Technical Doc":`#a855f7`,Document:`#64748b`,Concept:`#14b8a6`},r,i=P(!0),a=P(``),o=P(I({nodes:0,edges:0})),s=P(I([]));function c(e){return n[e]??`#94a3b8`}Ji(()=>{let e;return(async()=>{let t=`en`;try{t=(await fetch(`/api/config`).then(e=>e.json())).language||`en`}catch{}await Sa(t);try{let t=await fetch(`/api/graph`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();F(o,{nodes:n.nodes.length,edges:n.edges.length},!0),F(s,[...new Set(n.nodes.map(e=>e.type))].sort().map(e=>({type:e,color:c(e)})),!0);let i=window.vis;if(!i)throw Error(Y(`graph.renderer_error`));let a=new i.DataSet(n.nodes.map(e=>({id:e.id,label:e.title,title:e.folder?`${e.folder} · ${e.type}`:e.type,color:{background:c(e.type),border:`rgba(100,116,139,0.9)`},shape:`dot`,size:12}))),l=new i.DataSet(n.edges.map((e,t)=>({id:t,from:e.from,to:e.to}))),u=getComputedStyle(document.body).color||`#334155`;e=new i.Network(r,{nodes:a,edges:l},{nodes:{font:{color:u,size:13,face:`inherit`},borderWidth:1.5},edges:{arrows:{to:{enabled:!0,scaleFactor:.5}},color:{color:`rgba(148,163,184,0.55)`,highlight:`#3b82f6`},smooth:{enabled:!0,type:`continuous`,roundness:.4},width:1},physics:{solver:`forceAtlas2Based`,forceAtlas2Based:{gravitationalConstant:-45,springLength:120,avoidOverlap:.6},stabilization:{iterations:250}},interaction:{hover:!0,tooltipDelay:150,navigationButtons:!1}}),e.on(`click`,e=>{e.nodes&&e.nodes.length>0&&(window.location.href=`/?doc=`+encodeURIComponent(e.nodes[0]))})}catch(e){F(a,e.message,!0)}finally{F(i,!1)}})(),()=>e?.destroy?.()});var l=lT(),u=L(l);{let e=N(()=>Y(`graph.title`)||`Concept graph`);Xo(u,{get title(){return V(e)},subtitle:``})}var d=z(u,2),f=L(d),p=L(f);j(f);var m=z(f,2);q(m,21,()=>V(s),e=>e.type,(e,t)=>{var n=oT(),r=L(n),i=z(r,1,!0);j(n),B(()=>{bi(r,`background:${V(t).color??``}`),G(i,V(t).type)}),W(e,n)}),j(m),j(d);var h=z(d,2),g=L(h),_=e=>{var t=sT(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`graph.loading`)||`Loading graph…`]),W(e,t)},v=e=>{var t=cT(),n=L(t,!0);j(t),B(()=>G(n,V(a))),W(e,t)},y=e=>{var t=sT(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`graph.empty`)||`No concepts to graph yet.`]),W(e,t)};K(g,e=>{V(i)?e(_):V(a)?e(v,1):V(o).nodes===0&&e(y,2)}),Ui(z(g,2),e=>r=e,()=>r),j(h),j(l),B(()=>G(p,`${V(o).nodes??``} · ${V(o).edges??``}`)),W(e,l),Je()}We();var dT={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 fT(){dT.isDirty=!0,document.getElementById(`btnSave`).disabled=!1}var pT=`custom-shape`,mT=`custom-shape:`,hT=[{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 gT(e){return typeof e==`string`&&e.startsWith(`custom-shape:`)}function _T(e){return gT(e)?e.slice(13):null}function vT(e){return e&&dT.customShapeDefs&&dT.customShapeDefs.get(e)||null}function yT(e){let t=vT(e);return[t&&t.width||65,t&&t.height||65]}function bT(e){let t=vT(e);return t&&Array.isArray(t.anchors)&&t.anchors.length?t.anchors:hT}function xT(e){let t=vT(e);return t&&[`center`,`below`,`above`,`right`,`left`].includes(t.labelPlacement)?t.labelPlacement:`below`}async function ST(){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:[];dT.customShapeLibraries=n,dT.customShapeDefs=new Map,n.forEach(e=>{(e.shapes||[]).forEach(e=>dT.customShapeDefs.set(e.id,e))})}catch{dT.customShapeLibraries=[],dT.customShapeDefs=new Map}}function CT(){let e=document.getElementById(`customShapeBar`),t=document.getElementById(`customShapeBarBody`);if(!e||!t)return;t.innerHTML=``;let n=(dT.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:`${mT}${e.id}`}}))}),t.appendChild(n)})}function wT(){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(hT)}}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=`
|
|
281
|
+
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 dT(e,t){qe(t,!0),Ji(()=>{let e;return(async()=>{let t=`en`;try{t=(await fetch(`/api/config`).then(e=>e.json())).language||`en`}catch{}await Sa(t);let{initDiagram:r}=await lT(async()=>{let{initDiagram:e}=await import(`./main-B1NZokva.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=uT(),o=L(a),s=L(o),c=L(s,!0);j(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),te=z(ee,4),O=z(te,4),k=z(O,4),ne=z(k,2),A=z(ne,8),re=z(A,4),ie=z(re,4),ae=L(ie),oe=L(ae,!0);j(ae),j(ie),j(o);var se=z(o,2),ce=L(se),le=L(ce),ue=L(le),de=L(ue,!0);j(ue);var fe=z(ue,2),pe=L(fe,!0);j(fe),j(le),Ie(2),j(ce);var me=z(ce,2),he=z(me,2),ge=z(L(he),10),_e=z(L(ge),8),ve=z(_e,2);j(ge);var ye=z(ge,2),be=L(ye),xe=L(be),Se=L(xe,!0);j(xe);var Ce=z(xe,2);j(be),Ie(2),j(ye);var we=z(ye,2),Te=L(we),Ee=z(Te,4),De=L(Ee),Oe=z(De,4),ke=z(Oe,4),Ae=z(ke,2),je=z(Ae,4),Me=z(je,2),Ne=z(Me,2),Pe=z(Ne,4),Fe=z(Pe,2),Le=z(Fe,2),Re=z(Le,4),ze=z(Re,2),Be=z(ze,2),Ve=z(Be,4),He=L(Ve),Ue=z(He,2),We=z(Ue,2),Ge=z(We,2),Ke=z(Ge,2);Ie(2),j(Ve);var Ye=z(Ve,2),Xe=z(Ye,2),Ze=z(Xe,4),Qe=z(Ze,2),$e=z(Qe,2),et=z($e,4),tt=z(et,2),nt=z(tt,4),rt=z(nt,4),it=z(rt,2),at=z(it,4);j(Ee),j(we);var ot=z(we,2),st=L(ot),ct=L(st,!0);j(st);var lt=z(st,2),ut=z(L(lt),2),dt=L(ut,!0);j(ut),j(lt);var ft=z(lt,2),M=L(ft);j(ft);var pt=z(ft,2),mt=z(L(pt),2),ht=L(mt,!0);j(mt),j(pt);var gt=z(pt,4),_t=z(L(gt),2),vt=L(_t,!0);j(_t),j(gt);var yt=z(gt,2),N=L(yt);j(yt);var bt=z(yt,2),xt=L(bt),St=L(xt,!0);j(xt);var Ct=z(xt,2),wt=L(Ct,!0);j(Ct),Ie(2),j(bt),j(ot);var Tt=z(ot,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);j(Dt),j(Tt);var Zt=z(Tt,2),Qt=z(Zt,2),$t=z(L(Qt),2),en=L($t,!0);j($t),j(Qt),j(he),j(se);var tn=z(se,4),nn=L(tn),I=L(nn),rn=L(I,!0);j(I);var an=z(I,4),on=L(an);Ie(2),j(an);var sn=z(an,2),cn=L(sn,!0);j(sn);var ln=z(sn,2),un=L(ln),dn=L(un,!0);j(un);var fn=z(un,2),pn=L(fn,!0);j(fn),j(ln),j(nn),j(tn),j(a),B((e,t,n,i,a,o,s,ie,ae,se,ce,le,ue,fe,he,ge,ye,be,xe,we,Ee,j,Ie,Ve,qe,Je,ot,st,lt,ut,ft,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`,Ee),J(te,`placeholder`,j),J(O,`title`,Ie),J(k,`title`,Ve),J(ne,`title`,qe),J(A,`title`,Je),J(re,`title`,ot),G(oe,st),G(de,lt),G(pe,ut),vi(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`,ft),J(ve,`title`,pt),G(Se,mt),J(Ce,`title`,gt),J(Te,`title`,_t),J(De,`title`,yt),J(Oe,`title`,bt),J(ke,`title`,xt),J(Ae,`title`,Ct),J(je,`title`,Tt),J(Me,`title`,Dt),J(Ne,`title`,P),J(Pe,`title`,Qt),J(Fe,`title`,F),J(Le,`title`,$t),J(Re,`title`,tn),J(ze,`title`,nn),J(Be,`title`,I),J(He,`title`,an),J(Ue,`title`,sn),J(We,`title`,ln),J(Ge,`title`,un),J(Ke,`title`,fn),J(Ye,`title`,L),J(Xe,`title`,R),J(Ze,`title`,z),J(Qe,`title`,mn),J($e,`title`,hn),J(et,`title`,gn),J(tt,`title`,_n),J(nt,`title`,vn),J(rt,`title`,yn),J(it,`title`,bn),J(at,`title`,xn),G(ct,Sn),G(dt,Cn),J(M,`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),Je()}Pr([`click`,`mousedown`]);var fT=U(`<span class="legend-item svelte-1bqlvrg"><span class="legend-dot svelte-1bqlvrg"></span> </span>`),pT=U(`<p class="graph-msg svelte-1bqlvrg"> </p>`),mT=U(`<p class="graph-msg graph-error svelte-1bqlvrg"> </p>`),hT=U(`<div class="graph-page svelte-1bqlvrg"><!> <div class="graph-toolbar svelte-1bqlvrg"><span class="graph-counts svelte-1bqlvrg"> </span> <div class="graph-legend svelte-1bqlvrg"></div></div> <div class="graph-canvas-wrap svelte-1bqlvrg"><!> <div class="graph-canvas svelte-1bqlvrg"></div></div></div>`);function gT(e,t){qe(t,!0);let n={ADR:`#3b82f6`,Worklog:`#22c55e`,Rule:`#f97316`,"Technical Doc":`#a855f7`,Document:`#64748b`,Concept:`#14b8a6`},r,i=P(!0),a=P(``),o=P(I({nodes:0,edges:0})),s=P(I([]));function c(e){return n[e]??`#94a3b8`}Ji(()=>{let e;return(async()=>{let t=`en`;try{t=(await fetch(`/api/config`).then(e=>e.json())).language||`en`}catch{}await Sa(t);try{let t=await fetch(`/api/graph`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();F(o,{nodes:n.nodes.length,edges:n.edges.length},!0),F(s,[...new Set(n.nodes.map(e=>e.type))].sort().map(e=>({type:e,color:c(e)})),!0);let i=window.vis;if(!i)throw Error(Y(`graph.renderer_error`));let a=new i.DataSet(n.nodes.map(e=>({id:e.id,label:e.title,title:e.folder?`${e.folder} · ${e.type}`:e.type,color:{background:c(e.type),border:`rgba(100,116,139,0.9)`},shape:`dot`,size:12}))),l=new i.DataSet(n.edges.map((e,t)=>({id:t,from:e.from,to:e.to}))),u=getComputedStyle(document.body).color||`#334155`;e=new i.Network(r,{nodes:a,edges:l},{nodes:{font:{color:u,size:13,face:`inherit`},borderWidth:1.5},edges:{arrows:{to:{enabled:!0,scaleFactor:.5}},color:{color:`rgba(148,163,184,0.55)`,highlight:`#3b82f6`},smooth:{enabled:!0,type:`continuous`,roundness:.4},width:1},physics:{solver:`forceAtlas2Based`,forceAtlas2Based:{gravitationalConstant:-45,springLength:120,avoidOverlap:.6},stabilization:{iterations:250}},interaction:{hover:!0,tooltipDelay:150,navigationButtons:!1}}),e.on(`click`,e=>{e.nodes&&e.nodes.length>0&&(window.location.href=`/?doc=`+encodeURIComponent(e.nodes[0]))})}catch(e){F(a,e.message,!0)}finally{F(i,!1)}})(),()=>e?.destroy?.()});var l=hT(),u=L(l);{let e=N(()=>Y(`graph.title`)||`Concept graph`);Xo(u,{get title(){return V(e)},subtitle:``})}var d=z(u,2),f=L(d),p=L(f);j(f);var m=z(f,2);q(m,21,()=>V(s),e=>e.type,(e,t)=>{var n=fT(),r=L(n),i=z(r,1,!0);j(n),B(()=>{bi(r,`background:${V(t).color??``}`),G(i,V(t).type)}),W(e,n)}),j(m),j(d);var h=z(d,2),g=L(h),_=e=>{var t=pT(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`graph.loading`)||`Loading graph…`]),W(e,t)},v=e=>{var t=mT(),n=L(t,!0);j(t),B(()=>G(n,V(a))),W(e,t)},y=e=>{var t=pT(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`graph.empty`)||`No concepts to graph yet.`]),W(e,t)};K(g,e=>{V(i)?e(_):V(a)?e(v,1):V(o).nodes===0&&e(y,2)}),Ui(z(g,2),e=>r=e,()=>r),j(h),j(l),B(()=>G(p,`${V(o).nodes??``} · ${V(o).edges??``}`)),W(e,l),Je()}We();var _T={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 vT(){_T.isDirty=!0,document.getElementById(`btnSave`).disabled=!1}var yT=`custom-shape`,bT=`custom-shape:`,xT=[{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 ST(e){return typeof e==`string`&&e.startsWith(`custom-shape:`)}function CT(e){return ST(e)?e.slice(13):null}function wT(e){return e&&_T.customShapeDefs&&_T.customShapeDefs.get(e)||null}function TT(e){let t=wT(e);return[t&&t.width||65,t&&t.height||65]}function ET(e){let t=wT(e);return t&&Array.isArray(t.anchors)&&t.anchors.length?t.anchors:xT}function DT(e){let t=wT(e);return t&&[`center`,`below`,`above`,`right`,`left`].includes(t.labelPlacement)?t.labelPlacement:`below`}async function OT(){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:[];_T.customShapeLibraries=n,_T.customShapeDefs=new Map,n.forEach(e=>{(e.shapes||[]).forEach(e=>_T.customShapeDefs.set(e.id,e))})}catch{_T.customShapeLibraries=[],_T.customShapeDefs=new Map}}function kT(){let e=document.getElementById(`customShapeBar`),t=document.getElementById(`customShapeBarBody`);if(!e||!t)return;t.innerHTML=``;let n=(_T.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:`${bT}${e.id}`}}))}),t.appendChild(n)})}function AT(){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(xT)}}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=`
|
|
282
282
|
<input class="field !h-7 text-xs" value="${d(t.id)}">
|
|
283
283
|
<input class="field !h-7 text-xs" type="number" min="0" max="100" step="1" value="${Math.round(t.x*100)}">
|
|
284
284
|
<input class="field !h-7 text-xs" type="number" min="0" max="100" step="1" value="${Math.round(t.y*100)}">
|
|
285
285
|
<button class="btn btn-danger !h-7 !px-0">×</button>
|
|
286
|
-
`;let[s,c,u]=o.querySelectorAll(`input`);s.addEventListener(`input`,()=>{t.id=s.value.trim()||`p${n+1}`,b()}),c.addEventListener(`input`,()=>{t.x=l(Number(c.value)/100),b()}),u.addEventListener(`input`,()=>{t.y=l(Number(u.value)/100),b()}),o.querySelector(`button`).addEventListener(`click`,()=>{i.anchors=i.anchors.filter(e=>e!==t),b()}),e.anchorList.appendChild(o)})}function x(t,n){let r=e.previewStage.getBoundingClientRect();t.x=l((n.clientX-r.left)/r.width),t.y=l((n.clientY-r.top)/r.height)}let S=[],C=(e,t,n,r)=>{e.addEventListener(t,n,r),S.push(()=>e.removeEventListener(t,n,r))};return C(e.previewStage,`pointermove`,e=>{if(!a||!i)return;let t=i.anchors.find(e=>e.id===a);t&&(x(t,e),b())}),C(window,`pointerup`,()=>{a=null}),C(e.previewStage,`click`,e=>{if(e.target.closest(`.anchor-dot`)||a||!i)return;let t={id:`p${(i.anchors||[]).length+1}`,x:.5,y:.5};x(t,e),i.anchors=[...i.anchors||[],t],b()}),C(document.getElementById(`btnAddLibrary`),`click`,async()=>{let e={id:o(`lib`),name:`New library`,shapes:[]};t.libraries.push(e),n=e.id,r=null,i=h(),g(),await m()}),C(e.librarySelect,`change`,()=>{n=e.librarySelect.value,r=s()?.shapes[0]?.id||null,i=c()?structuredClone(c()):h(),g()}),C(e.libraryName,`change`,async()=>{let t=s();t&&(t.name=e.libraryName.value.trim()||t.name,_(),await m())}),C(document.getElementById(`btnNewShape`),`click`,()=>{r=null,i=h(),g()}),C(document.getElementById(`btnDeleteShape`),`click`,async()=>{let e=s();!e||!r||(e.shapes=e.shapes.filter(e=>e.id!==r),r=e.shapes[0]?.id||null,i=c()?structuredClone(c()):h(),g(),await m())}),C(document.getElementById(`btnDefaultAnchors`),`click`,()=>{i.anchors=structuredClone(
|
|
287
|
-
position.</p></div> <div class="space-y-4"><div class="grid grid-cols-2 gap-3"><label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Shape name</span> <input id="shapeName" class="field w-full" placeholder="Shape name"/></label> <label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Image / SVG</span> <input id="imageFile" type="file" accept="image/*,.svg" class="block w-full text-sm"/></label> <label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Width</span> <input id="shapeWidth" type="number" min="16" max="1200" class="field w-full"/></label> <label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Height</span> <input id="shapeHeight" type="number" min="16" max="1200" class="field w-full"/></label> <label class="space-y-1 col-span-2"><span class="block text-xs font-semibold text-gray-500">Text placement</span> <select id="labelPlacement" class="field w-full"><option> </option><option> </option><option> </option><option> </option><option> </option></select></label> <label class="col-span-2 flex items-start gap-2 rounded-md border border-gray-200 bg-white px-2 py-2 text-sm"><input id="shapeShowInDiagram" type="checkbox" class="mt-0.5 h-4 w-4 rounded border-gray-300 text-blue-600"/> <span class="space-y-0.5"><span class="block font-semibold text-gray-700"> </span> <span class="block text-xs text-gray-500"> </span></span></label></div> <div class="flex flex-wrap gap-2"><button id="btnDefaultAnchors" class="btn">Use 8 default anchors</button> <button id="btnClearAnchors" class="btn">Clear anchors</button> <button id="btnSaveShape" class="btn btn-primary">Save shape</button></div> <div><div class="flex items-center justify-between mb-2"><h2 class="text-xs font-semibold uppercase tracking-wide text-gray-500">Anchors</h2> <span id="anchorCount" class="text-xs text-gray-500"></span></div> <div id="anchorList" class="space-y-1"></div></div></div></div></section></main></div>`);function
|
|
286
|
+
`;let[s,c,u]=o.querySelectorAll(`input`);s.addEventListener(`input`,()=>{t.id=s.value.trim()||`p${n+1}`,b()}),c.addEventListener(`input`,()=>{t.x=l(Number(c.value)/100),b()}),u.addEventListener(`input`,()=>{t.y=l(Number(u.value)/100),b()}),o.querySelector(`button`).addEventListener(`click`,()=>{i.anchors=i.anchors.filter(e=>e!==t),b()}),e.anchorList.appendChild(o)})}function x(t,n){let r=e.previewStage.getBoundingClientRect();t.x=l((n.clientX-r.left)/r.width),t.y=l((n.clientY-r.top)/r.height)}let S=[],C=(e,t,n,r)=>{e.addEventListener(t,n,r),S.push(()=>e.removeEventListener(t,n,r))};return C(e.previewStage,`pointermove`,e=>{if(!a||!i)return;let t=i.anchors.find(e=>e.id===a);t&&(x(t,e),b())}),C(window,`pointerup`,()=>{a=null}),C(e.previewStage,`click`,e=>{if(e.target.closest(`.anchor-dot`)||a||!i)return;let t={id:`p${(i.anchors||[]).length+1}`,x:.5,y:.5};x(t,e),i.anchors=[...i.anchors||[],t],b()}),C(document.getElementById(`btnAddLibrary`),`click`,async()=>{let e={id:o(`lib`),name:`New library`,shapes:[]};t.libraries.push(e),n=e.id,r=null,i=h(),g(),await m()}),C(e.librarySelect,`change`,()=>{n=e.librarySelect.value,r=s()?.shapes[0]?.id||null,i=c()?structuredClone(c()):h(),g()}),C(e.libraryName,`change`,async()=>{let t=s();t&&(t.name=e.libraryName.value.trim()||t.name,_(),await m())}),C(document.getElementById(`btnNewShape`),`click`,()=>{r=null,i=h(),g()}),C(document.getElementById(`btnDeleteShape`),`click`,async()=>{let e=s();!e||!r||(e.shapes=e.shapes.filter(e=>e.id!==r),r=e.shapes[0]?.id||null,i=c()?structuredClone(c()):h(),g(),await m())}),C(document.getElementById(`btnDefaultAnchors`),`click`,()=>{i.anchors=structuredClone(xT),b()}),C(document.getElementById(`btnClearAnchors`),`click`,()=>{i.anchors=[],b()}),C(document.getElementById(`btnSaveShape`),`click`,async()=>{let t=s();if(!t||!i||!i.imageSrc)return;i.name=e.shapeName.value.trim()||`Untitled shape`,i.width=Math.max(16,Math.min(1200,Math.round(Number(e.shapeWidth.value)||65))),i.height=Math.max(16,Math.min(1200,Math.round(Number(e.shapeHeight.value)||65))),i.labelPlacement=u(e.labelPlacement.value),i.showInDiagram=e.shapeShowInDiagram.checked;let n=t.shapes.findIndex(e=>e.id===i.id);n>=0?t.shapes[n]=structuredClone(i):t.shapes.push(structuredClone(i)),r=i.id,g(),await m()}),[`shapeName`,`shapeWidth`,`shapeHeight`,`labelPlacement`,`shapeShowInDiagram`].forEach(t=>{C(document.getElementById(t),`input`,()=>{i.name=e.shapeName.value,i.width=Number(e.shapeWidth.value)||65,i.height=Number(e.shapeHeight.value)||65,i.labelPlacement=u(e.labelPlacement.value),i.showInDiagram=e.shapeShowInDiagram.checked})}),C(e.imageFile,`change`,async()=>{let t=e.imageFile.files&&e.imageFile.files[0];if(!t||!i)return;let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(r.result),r.onerror=n,r.readAsDataURL(t)}),r=(t.name.split(`.`).pop()||`png`).toLowerCase().replace(/[^a-z0-9]/g,``)||`png`,a=t.name.replace(/\.[^.]+$/,``).slice(0,60),o=await(await fetch(`/api/images/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({data:n,ext:r,name:a})})).json();i.imageSrc=`/images/${o.filename}`,(!e.shapeName.value||e.shapeName.value===`New shape`)&&(i.name=a||i.name),y()}),p(),()=>{S.forEach(e=>e()),S.length=0}}var jT=U(`<div class="ld-shape-editor h-screen overflow-hidden bg-gray-50 text-gray-900"><header class="h-12 border-b border-gray-200 bg-white flex items-center gap-2 px-3"><button class="btn">← Back</button> <h1 class="text-sm font-semibold">Shape editor</h1> <span id="saveState" class="ml-auto text-xs text-gray-500"></span></header> <main class="h-[calc(100vh-3rem)] grid grid-cols-[17rem_1fr] overflow-hidden"><aside class="border-r border-gray-200 bg-white flex flex-col min-h-0"><div class="p-3 border-b border-gray-200 space-y-2"><label class="block text-xs font-semibold text-gray-500">Library</label> <div class="flex gap-2"><select id="librarySelect" class="field flex-1"></select> <button id="btnAddLibrary" class="btn">+</button></div> <input id="libraryName" class="field w-full" placeholder="Library name"/></div> <div class="p-3 border-b border-gray-200 flex gap-2"><button id="btnNewShape" class="btn btn-primary flex-1">New shape</button> <button id="btnDeleteShape" class="btn btn-danger">Delete</button></div> <div id="shapeList" class="flex-1 overflow-y-auto p-2 space-y-1"></div></aside> <section class="min-w-0 min-h-0 overflow-y-auto p-5"><div class="grid grid-cols-[minmax(20rem,34rem)_minmax(20rem,1fr)] gap-5 items-start"><div class="space-y-3"><div id="previewStage"><img id="previewImage" alt=""/></div> <p class="text-xs text-gray-500">Click on the image to add an anchor. Drag anchors to refine their
|
|
287
|
+
position.</p></div> <div class="space-y-4"><div class="grid grid-cols-2 gap-3"><label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Shape name</span> <input id="shapeName" class="field w-full" placeholder="Shape name"/></label> <label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Image / SVG</span> <input id="imageFile" type="file" accept="image/*,.svg" class="block w-full text-sm"/></label> <label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Width</span> <input id="shapeWidth" type="number" min="16" max="1200" class="field w-full"/></label> <label class="space-y-1"><span class="block text-xs font-semibold text-gray-500">Height</span> <input id="shapeHeight" type="number" min="16" max="1200" class="field w-full"/></label> <label class="space-y-1 col-span-2"><span class="block text-xs font-semibold text-gray-500">Text placement</span> <select id="labelPlacement" class="field w-full"><option> </option><option> </option><option> </option><option> </option><option> </option></select></label> <label class="col-span-2 flex items-start gap-2 rounded-md border border-gray-200 bg-white px-2 py-2 text-sm"><input id="shapeShowInDiagram" type="checkbox" class="mt-0.5 h-4 w-4 rounded border-gray-300 text-blue-600"/> <span class="space-y-0.5"><span class="block font-semibold text-gray-700"> </span> <span class="block text-xs text-gray-500"> </span></span></label></div> <div class="flex flex-wrap gap-2"><button id="btnDefaultAnchors" class="btn">Use 8 default anchors</button> <button id="btnClearAnchors" class="btn">Clear anchors</button> <button id="btnSaveShape" class="btn btn-primary">Save shape</button></div> <div><div class="flex items-center justify-between mb-2"><h2 class="text-xs font-semibold uppercase tracking-wide text-gray-500">Anchors</h2> <span id="anchorCount" class="text-xs text-gray-500"></span></div> <div id="anchorList" class="space-y-1"></div></div></div></div></section></main></div>`);function MT(e,t){qe(t,!1),Ji(async()=>{try{await Sa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{await Sa(`en`)}return AT()}),Gi();var n=jT(),r=L(n),i=L(r);Ie(4),j(r);var a=z(r,2),o=z(L(a),2),s=L(o),c=z(L(s),2),l=L(c),u=z(L(l),8),d=z(L(u),2),f=L(d),p=L(f,!0);j(f),f.value=f.__value=`below`;var m=z(f),h=L(m,!0);j(m),m.value=m.__value=`above`;var g=z(m),_=L(g,!0);j(g),g.value=g.__value=`right`;var v=z(g),y=L(v,!0);j(v),v.value=v.__value=`left`;var b=z(v),x=L(b,!0);j(b),b.value=b.__value=`center`,j(d),j(u);var S=z(u,2),C=z(L(S),2),w=L(C),T=L(w,!0);j(w);var E=z(w,2),D=L(E,!0);j(E),j(C),j(S),j(l),Ie(4),j(c),j(s),j(o),j(a),j(n),B((e,t,n,r,i,a,o)=>{G(p,e),G(h,t),G(_,n),G(y,r),G(x,i),G(T,a),G(D,o)},[()=>Y(`shape_editor.label_placement.below`),()=>Y(`shape_editor.label_placement.above`),()=>Y(`shape_editor.label_placement.right`),()=>Y(`shape_editor.label_placement.left`),()=>Y(`shape_editor.label_placement.center`),()=>Y(`shape_editor.show_in_diagram_label`),()=>Y(`shape_editor.show_in_diagram_hint`)]),H(`click`,i,()=>history.back()),W(e,n),Je()}Pr([`click`]);function NT(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var PT=NT();function FT(e){PT=e}var IT=/[&<>"']/,LT=new RegExp(IT.source,`g`),RT=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,zT=new RegExp(RT.source,`g`),BT={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},VT=e=>BT[e];function HT(e,t){if(t){if(IT.test(e))return e.replace(LT,VT)}else if(RT.test(e))return e.replace(zT,VT);return e}var UT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function WT(e){return e.replace(UT,(e,t)=>(t=t.toLowerCase(),t===`colon`?`:`:t.charAt(0)===`#`?t.charAt(1)===`x`?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):``))}var GT=/(^|[^\[])\^/g;function KT(e,t){let n=typeof e==`string`?e:e.source;t||=``;let r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(GT,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}function qT(e){try{e=encodeURI(e).replace(/%25/g,`%`)}catch{return null}return e}var JT={exec:()=>null};function YT(e,t){let n=e.replace(/\|/g,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(/ \|/),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(/\\\|/g,`|`);return n}function XT(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function ZT(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return-1}function QT(e,t,n,r){let i=t.href,a=t.title?HT(t.title):null,o=e[1].replace(/\\([\[\]])/g,`$1`);if(e[0].charAt(0)!==`!`){r.state.inLink=!0;let e={type:`link`,raw:n,href:i,title:a,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,e}return{type:`image`,raw:n,href:i,title:a,text:HT(o)}}function $T(e,t){let n=e.match(/^(\s+)(?:```)/);if(n===null)return t;let r=n[1];return t.split(`
|
|
288
288
|
`).map(e=>{let t=e.match(/^\s+/);if(t===null)return e;let[n]=t;return n.length>=r.length?e.slice(r.length):e}).join(`
|
|
289
|
-
`)}var
|
|
290
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n
|
|
291
|
-
$1`);e=
|
|
289
|
+
`)}var eE=class{options;rules;lexer;constructor(e){this.options=e||PT}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(/^ {1,4}/gm,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:XT(e,`
|
|
290
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=$T(e,t[3]||``);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){let t=XT(e,`#`);(this.options.pedantic||!t||/ $/.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:t[0]}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,`
|
|
291
|
+
$1`);e=XT(e.replace(/^ *>[ \t]?/gm,``),`
|
|
292
292
|
`);let n=this.lexer.state.top;this.lexer.state.top=!0;let r=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:`blockquote`,raw:t[0],tokens:r,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=RegExp(`^( {0,3}${n})((?:[\t ][^\\n]*)?(?:\\n|$))`),o=``,s=``,c=!1;for(;e;){let n=!1;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;o=t[0],e=e.substring(o.length);let r=t[2].split(`
|
|
293
293
|
`,1)[0].replace(/^\t+/,e=>` `.repeat(3*e.length)),l=e.split(`
|
|
294
294
|
`,1)[0],u=0;this.options.pedantic?(u=2,s=r.trimStart()):(u=t[2].search(/[^ ]/),u=u>4?1:u,s=r.slice(u),u+=t[1].length);let d=!1;if(!r&&/^ *$/.test(l)&&(o+=l+`
|
|
@@ -296,10 +296,10 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
296
296
|
`,1)[0];if(l=c,this.options.pedantic&&(l=l.replace(/^ {1,4}(?=( {4})*[^ ])/g,` `)),i.test(l)||a.test(l)||t.test(l)||n.test(e))break;if(l.search(/[^ ]/)>=u||!l.trim())s+=`
|
|
297
297
|
`+l.slice(u);else{if(d||r.search(/[^ ]/)>=4||i.test(r)||a.test(r)||n.test(r))break;s+=`
|
|
298
298
|
`+l}!d&&!l.trim()&&(d=!0),o+=c+`
|
|
299
|
-
`,e=e.substring(c.length+1),r=l.slice(u)}}i.loose||(c?i.loose=!0:/\n *\n *$/.test(o)&&(c=!0));let f=null,p;this.options.gfm&&(f=/^\[[ xX]\] /.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(/^\[[ xX]\] +/,``))),i.items.push({type:`list_item`,raw:o,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=o}i.items[i.items.length-1].raw=o.trimEnd(),i.items[i.items.length-1].text=s.trimEnd(),i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){let t=i.items[e].tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>/\n.*\n/.test(e.raw))}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(/\s+/g,` `),n=t[2]?t[2].replace(/^<(.*)>$/,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!/[:|]/.test(t[2]))return;let n=
|
|
300
|
-
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)/^ *-+: *$/.test(e)?a.align.push(`right`):/^ *:-+: *$/.test(e)?a.align.push(`center`):/^ *:-+ *$/.test(e)?a.align.push(`left`):a.align.push(null);for(let e of n)a.header.push({text:e,tokens:this.lexer.inline(e)});for(let e of i)a.rows.push(
|
|
301
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:
|
|
302
|
-
]`).replace(`lheading`,
|
|
299
|
+
`,e=e.substring(c.length+1),r=l.slice(u)}}i.loose||(c?i.loose=!0:/\n *\n *$/.test(o)&&(c=!0));let f=null,p;this.options.gfm&&(f=/^\[[ xX]\] /.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(/^\[[ xX]\] +/,``))),i.items.push({type:`list_item`,raw:o,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=o}i.items[i.items.length-1].raw=o.trimEnd(),i.items[i.items.length-1].text=s.trimEnd(),i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){let t=i.items[e].tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>/\n.*\n/.test(e.raw))}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(/\s+/g,` `),n=t[2]?t[2].replace(/^<(.*)>$/,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!/[:|]/.test(t[2]))return;let n=YT(t[1]),r=t[2].replace(/^\||\| *$/g,``).split(`|`),i=t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,``).split(`
|
|
300
|
+
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)/^ *-+: *$/.test(e)?a.align.push(`right`):/^ *:-+: *$/.test(e)?a.align.push(`center`):/^ *:-+ *$/.test(e)?a.align.push(`left`):a.align.push(null);for(let e of n)a.header.push({text:e,tokens:this.lexer.inline(e)});for(let e of i)a.rows.push(YT(e,a.header.length).map(e=>({text:e,tokens:this.lexer.inline(e)})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
301
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:HT(t[1])}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&/^</.test(e)){if(!/>$/.test(e))return;let t=XT(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=ZT(t[2],`()`);if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),/^</.test(n)&&(n=this.options.pedantic&&!/>$/.test(e)?n.slice(1):n.slice(1,-1)),QT(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(/\s+/g,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return QT(n,e,n[0],this.lexer)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&!(r[3]&&n.match(/[\p{L}\p{N}]/u))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g,` `),n=/[^ ]/.test(e),r=/^ /.test(e)&&/ $/.test(e);return n&&r&&(e=e.substring(1,e.length-1)),e=HT(e,!0),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=HT(t[1]),n=`mailto:`+e):(e=HT(t[1]),n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=HT(t[0]),n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=HT(t[0]),n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e;return e=this.lexer.state.inRawBlock?t[0]:HT(t[0]),{type:`text`,raw:t[0],text:e}}}},tE=/^(?: *(?:\n|$))+/,nE=/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,rE=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,iE=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,aE=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,oE=/(?:[*+-]|\d{1,9}[.)])/,sE=KT(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,oE).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),cE=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,lE=/^[^\n]+/,uE=/(?!\s*\])(?:\\.|[^\[\]\\])+/,dE=KT(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace(`label`,uE).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),fE=KT(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,oE).getRegex(),pE=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,mE=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,hE=KT(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))`,`i`).replace(`comment`,mE).replace(`tag`,pE).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),gE=KT(cE).replace(`hr`,iE).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,pE).getRegex(),_E={blockquote:KT(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,gE).getRegex(),code:nE,def:dE,fences:rE,heading:aE,hr:iE,html:hE,lheading:sE,list:fE,newline:tE,paragraph:gE,table:JT,text:lE},vE=KT(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,iE).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,` {4}[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,pE).getRegex(),yE={..._E,table:vE,paragraph:KT(cE).replace(`hr`,iE).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,vE).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,pE).getRegex()},bE={..._E,html:KT(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,mE).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:JT,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:KT(cE).replace(`hr`,iE).replace(`heading`,` *#{1,6} *[^
|
|
302
|
+
]`).replace(`lheading`,sE).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},xE=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,SE=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,CE=/^( {2,}|\\)\n(?!\s*$)/,wE=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,TE=`\\p{P}\\p{S}`,EE=KT(/^((?![*_])[\spunctuation])/,`u`).replace(/punctuation/g,TE).getRegex(),DE=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,OE=KT(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,`u`).replace(/punct/g,TE).getRegex(),kE=KT(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])`,`gu`).replace(/punct/g,TE).getRegex(),AE=KT(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])`,`gu`).replace(/punct/g,TE).getRegex(),jE=KT(/\\([punct])/,`gu`).replace(/punct/g,TE).getRegex(),ME=KT(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),NE=KT(mE).replace(`(?:-->|$)`,`-->`).getRegex(),PE=KT(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,NE).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),FE=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,IE=KT(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace(`label`,FE).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),LE=KT(/^!?\[(label)\]\[(ref)\]/).replace(`label`,FE).replace(`ref`,uE).getRegex(),RE=KT(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,uE).getRegex(),zE={_backpedal:JT,anyPunctuation:jE,autolink:ME,blockSkip:DE,br:CE,code:SE,del:JT,emStrongLDelim:OE,emStrongRDelimAst:kE,emStrongRDelimUnd:AE,escape:xE,link:IE,nolink:RE,punctuation:EE,reflink:LE,reflinkSearch:KT(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,LE).replace(`nolink`,RE).getRegex(),tag:PE,text:wE,url:JT},BE={...zE,link:KT(/^!?\[(label)\]\((.*?)\)/).replace(`label`,FE).getRegex(),reflink:KT(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,FE).getRegex()},VE={...zE,escape:KT(xE).replace(`])`,`~|])`).getRegex(),url:KT(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,`i`).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},HE={...VE,br:KT(CE).replace(`{2,}`,`*`).getRegex(),text:KT(VE.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},UE={normal:_E,gfm:yE,pedantic:bE},WE={normal:zE,gfm:VE,breaks:HE,pedantic:BE},GE=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||PT,this.options.tokenizer=this.options.tokenizer||new eE,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={block:UE.normal,inline:WE.normal};this.options.pedantic?(t.block=UE.pedantic,t.inline=WE.pedantic):this.options.gfm&&(t.block=UE.gfm,this.options.breaks?t.inline=WE.breaks:t.inline=WE.gfm),this.tokenizer.rules=t}static get rules(){return{block:UE,inline:WE}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(/\r\n|\r/g,`
|
|
303
303
|
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[]){e=this.options.pedantic?e.replace(/\t/g,` `).replace(/^ +$/gm,``):e.replace(/^( *)(\t+)/gm,(e,t,n)=>t+` `.repeat(n.length));let n,r,i,a;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(r=>(n=r.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length),n.raw.length===1&&t.length>0?t[t.length-1].raw+=`
|
|
304
304
|
`:t.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length),r=t[t.length-1],r&&(r.type===`paragraph`||r.type===`text`)?(r.raw+=`
|
|
305
305
|
`+n.raw,r.text+=`
|
|
@@ -309,9 +309,9 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
309
309
|
`+n.raw,r.text+=`
|
|
310
310
|
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n),a=i.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length),r=t[t.length-1],r&&r.type===`text`?(r.raw+=`
|
|
311
311
|
`+n.raw,r.text+=`
|
|
312
|
-
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,r,i,a=e,o,s,c;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)e.includes(o[0].slice(o[0].lastIndexOf(`[`)+1,-1))&&(a=a.slice(0,o.index)+`[`+`a`.repeat(o[0].length-2)+`]`+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,o.index)+`[`+`a`.repeat(o[0].length-2)+`]`+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,o.index)+`++`+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(s||(c=``),s=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(r=>(n=r.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),r=t[t.length-1],r&&n.type===`text`&&r.type===`text`?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length),r=t[t.length-1],r&&n.type===`text`&&r.type===`text`?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,a,c)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}if(i=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(i)){e=e.substring(n.raw.length),n.raw.slice(-1)!==`_`&&(c=n.raw.slice(-1)),s=!0,r=t[t.length-1],r&&r.type===`text`?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},
|
|
313
|
-
`,r?`<pre><code class="language-`+
|
|
314
|
-
`:`<pre><code>`+(n?e:
|
|
312
|
+
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,r,i,a=e,o,s,c;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)e.includes(o[0].slice(o[0].lastIndexOf(`[`)+1,-1))&&(a=a.slice(0,o.index)+`[`+`a`.repeat(o[0].length-2)+`]`+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,o.index)+`[`+`a`.repeat(o[0].length-2)+`]`+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,o.index)+`++`+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;e;)if(s||(c=``),s=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(r=>(n=r.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),r=t[t.length-1],r&&n.type===`text`&&r.type===`text`?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length),r=t[t.length-1],r&&n.type===`text`&&r.type===`text`?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,a,c)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}if(i=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(i)){e=e.substring(n.raw.length),n.raw.slice(-1)!==`_`&&(c=n.raw.slice(-1)),s=!0,r=t[t.length-1],r&&r.type===`text`?(r.raw+=n.raw,r.text+=n.text):t.push(n);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},KE=class{options;constructor(e){this.options=e||PT}code(e,t,n){let r=(t||``).match(/^\S*/)?.[0];return e=e.replace(/\n$/,``)+`
|
|
313
|
+
`,r?`<pre><code class="language-`+HT(r)+`">`+(n?e:HT(e,!0))+`</code></pre>
|
|
314
|
+
`:`<pre><code>`+(n?e:HT(e,!0))+`</code></pre>
|
|
315
315
|
`}blockquote(e){return`<blockquote>\n${e}</blockquote>\n`}html(e,t){return e}heading(e,t,n){return`<h${t}>${e}</h${t}>\n`}hr(){return`<hr>
|
|
316
316
|
`}list(e,t,n){let r=t?`ol`:`ul`,i=t&&n!==1?` start="`+n+`"`:``;return`<`+r+i+`>
|
|
317
317
|
`+e+`</`+r+`>
|
|
@@ -319,10 +319,10 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
319
319
|
<thead>
|
|
320
320
|
`+e+`</thead>
|
|
321
321
|
`+t+`</table>
|
|
322
|
-
`}tablerow(e){return`<tr>\n${e}</tr>\n`}tablecell(e,t){let n=t.header?`th`:`td`;return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>\n`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return`<br>`}del(e){return`<del>${e}</del>`}link(e,t,n){let r=
|
|
323
|
-
`+(a.tokens?this.parseInline(a.tokens):a.text);n+=t?this.renderer.paragraph(o):o;continue}default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t){t||=this.renderer;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}switch(i.type){case`escape`:{let e=i;n+=t.text(e.text);break}case`html`:{let e=i;n+=t.html(e.text);break}case`link`:{let e=i;n+=t.link(e.href,e.title,this.parseInline(e.tokens,t));break}case`image`:{let e=i;n+=t.image(e.href,e.title,e.text);break}case`strong`:{let e=i;n+=t.strong(this.parseInline(e.tokens,t));break}case`em`:{let e=i;n+=t.em(this.parseInline(e.tokens,t));break}case`codespan`:{let e=i;n+=t.codespan(e.text);break}case`br`:n+=t.br();break;case`del`:{let e=i;n+=t.del(this.parseInline(e.tokens,t));break}case`text`:{let e=i;n+=t.text(e.text);break}default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},
|
|
324
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+IT(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function GE(e,t){return WE.parse(e,t)}GE.options=GE.setOptions=function(e){return WE.setOptions(e),GE.defaults=WE.defaults,kT(GE.defaults),GE},GE.getDefaults=DT,GE.defaults=OT,GE.use=function(...e){return WE.use(...e),GE.defaults=WE.defaults,kT(GE.defaults),GE},GE.walkTokens=function(e,t){return WE.walkTokens(e,t)},GE.parseInline=WE.parseInline,GE.Parser=HE,GE.parser=HE.parse,GE.Renderer=BE,GE.TextRenderer=VE,GE.Lexer=zE,GE.lexer=zE.lex,GE.Tokenizer=JT,GE.Hooks=UE,GE.parse=GE,GE.options,GE.setOptions,GE.use,GE.walkTokens,GE.parseInline,HE.parse,zE.lex;var KE=U(`<iframe sandbox="" class="svelte-zodsi8"></iframe>`);function qE(e,t){qe(t,!0);let n=P(!1);Ji(()=>{let e=()=>{F(n,document.documentElement.classList.contains(`dark`),!0)};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()});let r=N(()=>GE.parse(t.content.replace(/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/,``),{async:!1})),i=N(()=>`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>html{color-scheme:${V(n)?`dark`:`light`}}body{font:15px/1.7 system-ui;margin:24px;overflow-wrap:anywhere}h1{font-size:1.7em}h2{font-size:1.3em}pre{overflow:auto;padding:16px;background:light-dark(#f1f5f9,#1e293b);border-radius:8px}code{font-family:monospace}table{border-collapse:collapse;width:100%}th,td{border:1px solid #8886;padding:8px;text-align:left}blockquote{border-left:3px solid #8886;padding-left:16px;margin-left:0}img{max-width:100%}a{color:light-dark(#2563eb,#93c5fd)}</style></head><body>${V(r)}</body></html>`);var a=Wr();Zr(R(a),()=>V(i),e=>{var t=KE();B(e=>{J(t,`title`,e),J(t,`srcdoc`,V(i))},[()=>Y(`templates.preview`)]),W(e,t)}),W(e,a),Je()}var JE=U(`<span> </span>`),YE=U(`<span class="success svelte-3z3jlz"> </span>`),XE=U(`<div role="alert" class="error svelte-3z3jlz"><span> </span><button class="secondary-button svelte-3z3jlz"> </button></div>`),ZE=U(`<p> </p>`),QE=U(`<button><span class="svelte-3z3jlz"> </span><span class="svelte-3z3jlz"> </span></button>`),$E=U(`<details class="folder-actions"><summary class="svelte-3z3jlz"> </summary><div class="actions svelte-3z3jlz"><button class="secondary-button svelte-3z3jlz"> </button><button class="text-button danger svelte-3z3jlz" data-testid="template-delete-folder"> </button></div></details>`),eD=U(`<form class="folder-form svelte-3z3jlz"><label for="template-folder-input" class="svelte-3z3jlz"> </label> <input id="template-folder-input" maxlength="120" aria-describedby="template-folder-error" class="svelte-3z3jlz"/> <span id="template-folder-error" class="error svelte-3z3jlz" role="alert"> </span> <div class="actions svelte-3z3jlz"><button class="primary-button svelte-3z3jlz" data-testid="template-add-folder"> </button><button type="button" class="text-button svelte-3z3jlz"> </button></div></form>`),tD=U(`<button><span class="item-title svelte-3z3jlz"> </span><span class="hint svelte-3z3jlz"> </span></button>`),nD=U(`<button class="primary-button svelte-3z3jlz"> </button>`),rD=U(`<div class="empty svelte-3z3jlz"><h2 class="svelte-3z3jlz"> </h2><p class="svelte-3z3jlz"> </p><!></div>`),iD=U(`<option> </option>`),aD=U(`<form class="edit-form svelte-3z3jlz"><div class="pane-heading svelte-3z3jlz"><h2 class="svelte-3z3jlz"> </h2><span class="draft-status svelte-3z3jlz"> </span></div> <footer class="editor-footer svelte-3z3jlz"><span class="hint svelte-3z3jlz"> </span><div class="actions svelte-3z3jlz"><button type="button" class="secondary-button svelte-3z3jlz"> </button><button class="primary-button svelte-3z3jlz" data-testid="template-save"> </button></div></footer> <div class="fields svelte-3z3jlz"><div><label for="template-name" class="svelte-3z3jlz"> </label><input id="template-name" maxlength="120" aria-describedby="template-name-error" class="svelte-3z3jlz"/><span class="error svelte-3z3jlz" id="template-name-error" role="alert"> </span></div><div><label for="template-destination" class="svelte-3z3jlz"> </label><select id="template-destination" class="svelte-3z3jlz"></select></div></div> <label for="template-content" class="svelte-3z3jlz"> </label> <div class="editor-body svelte-3z3jlz"><textarea id="template-content" maxlength="1000000" spellcheck="false" class="svelte-3z3jlz"></textarea><details class="live-preview svelte-3z3jlz"><summary class="svelte-3z3jlz"> </summary><!></details></div></form>`),oD=U(`<pre class="svelte-3z3jlz"> </pre>`),sD=U(`<div class="detail-heading svelte-3z3jlz"><span class="eyebrow svelte-3z3jlz"> </span><h2 class="svelte-3z3jlz"> </h2><div class="actions svelte-3z3jlz"><button class="primary-button svelte-3z3jlz"> </button><button class="secondary-button svelte-3z3jlz" id="template-edit" data-testid="template-edit"> </button><details class="more-actions svelte-3z3jlz"><summary class="svelte-3z3jlz"> </summary><div class="actions svelte-3z3jlz"><button class="text-button svelte-3z3jlz"> </button><button class="text-button danger svelte-3z3jlz"> </button></div></details></div><p class="hint svelte-3z3jlz"> </p></div> <div class="preview-heading svelte-3z3jlz"><h3 class="svelte-3z3jlz"> </h3><button class="text-button svelte-3z3jlz"> </button></div> <div class="preview-content svelte-3z3jlz"><!></div>`,1),cD=U(`<div class="empty svelte-3z3jlz"><h2 class="svelte-3z3jlz"> </h2><p class="svelte-3z3jlz"> </p></div>`),lD=U(`<div><aside class="folder-pane svelte-3z3jlz"><div class="pane-heading svelte-3z3jlz"><h2 class="svelte-3z3jlz"> </h2><button class="text-button svelte-3z3jlz"> </button></div> <button> <span class="svelte-3z3jlz"> </span></button> <!> <p class="hint svelte-3z3jlz"> </p> <!> <!></aside> <section class="list-pane svelte-3z3jlz"><label for="template-search" class="svelte-3z3jlz"> </label><input type="search" id="template-search" class="svelte-3z3jlz"/> <div class="list-caption svelte-3z3jlz"> </div> <div class="template-list svelte-3z3jlz"></div></section> <section class="detail-pane svelte-3z3jlz"><button class="text-button mobile-back svelte-3z3jlz"> </button> <!></section></div>`),uD=U(`<!> <div class="template-library svelte-3z3jlz" data-testid="templates-manager"><header class="library-heading svelte-3z3jlz"><div><h1 class="svelte-3z3jlz"> </h1><p class="svelte-3z3jlz"> </p></div> <button class="primary-button svelte-3z3jlz" data-testid="template-new"><span aria-hidden="true">+</span> </button></header> <div class="feedback svelte-3z3jlz" aria-live="polite"><!> <!></div> <!></div> <!>`,1);function dD(e,t){qe(t,!0);let n=ka(),r=P(I({version:1,folders:[]})),i=P(!1),a=P(!1),o=P(``),s=P(``),c=P(``),l=P(``),u=P(``),d=P(!1),f=P(``),p=P(``),m=P(``),h=P(``),g=P(``),_=P(``),v=P(null),y=P(``),b=P(``),x=P(``),S=P(!1),C=P(!1),w=P(!1),T=P(void 0),E,D=N(()=>V(r).folders.flatMap(e=>e.templates.map(t=>({...t,folderId:e.id,folderName:e.name})))),ee=N(()=>V(r).folders.find(e=>e.id===V(l))),te=N(()=>V(D).find(e=>e.id===V(u))),O=e=>e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).toLocaleLowerCase(),k=N(()=>V(D).filter(e=>(!V(l)||e.folderId===V(l))&&O(e.name+` `+e.content).includes(O(V(c))))),ne=()=>JSON.stringify([V(p),V(m),V(h)]),A=N(()=>V(d)&&ne()!==V(g)||V(v)!==null&&V(y)!==V(b));async function re(){if(V(a))return!1;if(!V(A))return!0;let e=await E.show({title:Y(`templates.unsaved_title`),message:Y(`templates.unsaved_message`),confirmLabel:Y(`templates.discard`),cancelLabel:Y(`templates.keep_editing`),danger:!0});return e&&(F(d,!1),F(v,null)),e}async function ie(e){await re()&&(F(d,!1),F(v,null),F(o,``),F(s,``),await e())}async function ae(){F(r,await n(),!0),F(i,!0),V(l)&&!V(r).folders.some(e=>e.id===V(l))&&F(l,``),V(D).some(e=>e.id===V(u))||F(u,V(D)[0]?.id||``,!0)}async function oe(e){if(!V(a)){F(a,!0),F(o,``),F(s,``);try{await e()}catch(e){F(o,e instanceof Error?e.message:Y(`templates.errors.storage_error`),!0)}finally{F(a,!1)}}}let se=()=>ie(()=>oe(ae));Ji(()=>(oe(ae),Bo(re)));function ce(e){(V(A)||V(a))&&(e.preventDefault(),e.returnValue=``)}async function le(e){await ie(()=>{F(l,e,!0),F(w,!1),F(u,V(D).find(t=>!e||t.folderId===e)?.id||``,!0)})}async function ue(e){await ie(()=>{F(u,e,!0),F(w,!0),F(S,!1)})}async function de(e,t=!1){await ie(async()=>{if(F(f,t?``:e?.id||``,!0),F(h,e?.folderId||V(l)||V(r).folders[0]?.id||``,!0),F(p,e?.name||``,!0),t&&e){let t=Y(`templates.copy_name`,{name:e.name});F(p,t,!0);let n=2;for(;V(D).some(e=>e.folderId===V(h)&&e.name.toLocaleLowerCase()===V(p).toLocaleLowerCase());)F(p,`${t} ${n++}`)}F(m,e?.content||``,!0),F(g,t?``:ne(),!0),F(_,``),F(d,!0),F(w,!0),await xr(),document.getElementById(`template-name`)?.focus()})}async function fe(){if(F(_,``),!V(p).trim()||V(p).trim().length>120){F(_,Y(`templates.errors.invalid_name`),!0);return}if(V(D).some(e=>e.id!==V(f)&&e.folderId===V(h)&&e.name.toLocaleLowerCase()===V(p).trim().toLocaleLowerCase())){F(_,Y(`templates.errors.duplicate_name`),!0);return}await oe(async()=>{let e=await n(V(f)?`/${V(f)}`:`/folders/${V(h)}/templates`,V(f)?`PUT`:`POST`,{name:V(p),content:V(m),folderId:V(h)});F(r,{...V(r),folders:V(r).folders.map(t=>({...t,templates:[...t.templates.filter(t=>t.id!==e.id),...t.id===V(h)?[e]:[]]}))},!0),F(u,e.id,!0),F(l,V(h),!0),F(c,``),F(d,!1),F(S,!1),F(s,Y(`templates.saved`),!0),await xr(),document.getElementById(`template-edit`)?.focus()})}async function pe(e){await ie(async()=>{F(y,e===`rename`&&V(ee)?.name||``,!0),F(b,V(y),!0),F(v,e,!0),F(x,``),await xr(),document.getElementById(`template-folder-input`)?.focus()})}async function me(){if(!V(y).trim()||V(y).trim().length>120){F(x,Y(`templates.errors.invalid_name`),!0);return}if(V(r).folders.some(e=>(V(v)===`new`||e.id!==V(l))&&e.name.toLocaleLowerCase()===V(y).trim().toLocaleLowerCase())){F(x,Y(`templates.errors.duplicate_name`),!0);return}await oe(async()=>{let e=await n(V(v)===`new`?`/folders`:`/folders/${V(l)}`,V(v)===`new`?`POST`:`PUT`,{name:V(y)});F(r,{...V(r),folders:V(v)===`new`?[...V(r).folders,e]:V(r).folders.map(t=>t.id===e.id?e:t)},!0),F(l,e.id,!0),F(u,e.templates[0]?.id||``,!0),F(v,null),F(x,``),F(s,Y(`templates.folder_saved`),!0)})}async function he(e){if(!await re())return;let t=V(e?ee:te);t&&await E.show({title:Y(e?`templates.delete_folder`:`templates.delete_template`),message:Y(`templates.delete_message`,{name:t.name}),detail:e?Y(`templates.delete_count`,{count:String(V(ee)?.templates.length||0)}):Y(`templates.independent`),confirmLabel:Y(`common.remove`),cancelLabel:Y(`common.cancel`),danger:!0})&&await oe(async()=>{await n(e?`/folders/${t.id}?confirm=true`:`/${t.id}`,`DELETE`),F(r,{...V(r),folders:e?V(r).folders.filter(e=>e.id!==t.id):V(r).folders.map(e=>({...e,templates:e.templates.filter(e=>e.id!==t.id)}))},!0),e&&F(l,``),F(u,V(D).find(e=>!V(l)||e.folderId===V(l))?.id||``,!0),F(d,!1),F(w,!1),F(s,Y(`templates.deleted`),!0)})}function ge(e){(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&V(d)&&(e.preventDefault(),V(a)||fe())}var _e=uD();Nr(`beforeunload`,on,ce),Nr(`keydown`,on,ge);var ve=R(_e);Ui(Xd(ve,{}),e=>E=e,()=>E);var ye=z(ve,2),be=L(ye),xe=L(be),Se=L(xe),Ce=L(Se,!0);j(Se);var we=z(Se),Te=L(we,!0);j(we),j(xe);var Ee=z(xe,2),De=z(L(Ee));j(Ee),j(be);var Oe=z(be,2),ke=L(Oe),Ae=e=>{var t=JE(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},je=e=>{var t=YE(),n=L(t);j(t),B(()=>G(n,`✓ ${V(s)??``}`)),W(e,t)};K(ke,e=>{V(a)?e(Ae):V(s)&&e(je,1)});var Me=z(ke,2),Ne=e=>{var t=XE(),n=L(t),r=L(n,!0);j(n);var i=z(n),s=L(i,!0);j(i),j(t),B(e=>{G(r,V(o)),i.disabled=V(a),G(s,e)},[()=>Y(`templates.reload`)]),H(`click`,i,se),W(e,t)};K(Me,e=>{V(o)&&e(Ne)}),j(Oe);var Pe=z(Oe,2),Fe=e=>{var t=Wr(),n=R(t),r=e=>{var t=ZE(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`templates.load_failed`)]),W(e,t)};K(n,e=>{!V(a)&&V(o)&&e(r)}),W(e,t)},Ie=e=>{var t=lD();let n;var i=L(t),o=L(i),s=L(o),g=L(s,!0);j(s);var b=z(s),E=L(b,!0);j(b),j(o);var O=z(o,2);let ne;var re=L(O,!0),ae=z(re),oe=L(ae,!0);j(ae),j(O);var se=z(O,2);q(se,17,()=>V(r).folders,e=>e.id,(e,t)=>{var n=QE();let r;var i=L(n),o=L(i);j(i);var s=z(i),c=L(s,!0);j(s),j(n),B(()=>{r=vi(n,1,`folder-item svelte-3z3jlz`,null,r,{chosen:V(l)===V(t).id}),J(n,`aria-pressed`,V(l)===V(t).id),n.disabled=V(a),G(o,`▱ ${V(t).name??``}`),G(c,V(t).templates.length)}),H(`click`,n,()=>le(V(t).id)),W(e,n)});var ce=z(se,2),ge=L(ce,!0);j(ce);var _e=z(ce,2),ve=e=>{var t=$E(),n=L(t),r=L(n,!0);j(n);var i=z(n),o=L(i),s=L(o,!0);j(o);var c=z(o),l=L(c,!0);j(c),j(i),j(t),B((e,t,n)=>{G(r,e),o.disabled=V(a),G(s,t),c.disabled=V(a),G(l,n)},[()=>Y(`templates.folder_actions`),()=>Y(`templates.rename`),()=>Y(`common.remove`)]),H(`click`,o,()=>pe(`rename`)),H(`click`,c,()=>he(!0)),W(e,t)};K(_e,e=>{V(ee)&&e(ve)});var ye=z(_e,2),be=e=>{var t=eD(),n=L(t),r=L(n,!0);j(n);var i=z(n,2);ki(i);var o=z(i,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c),u=L(l,!0);j(l);var d=z(l),f=L(d,!0);j(d),j(c),j(t),B((e,t,n,o)=>{G(r,e),i.disabled=V(a),J(i,`aria-invalid`,!!V(x)),G(s,V(x)),l.disabled=t,G(u,n),d.disabled=V(a),G(f,o)},[()=>Y(V(v)===`new`?`templates.new_folder`:`templates.rename_folder`),()=>V(a)||!V(y).trim(),()=>Y(V(v)===`new`?`common.create`:`common.save`),()=>Y(`common.cancel`)]),Nr(`submit`,t,e=>{e.preventDefault(),me()}),Fi(i,()=>V(y),e=>F(y,e)),H(`click`,d,()=>ie(()=>{})),W(e,t)};K(ye,e=>{V(v)&&e(be)}),j(i);var xe=z(i,2),Se=L(xe),Ce=L(Se,!0);j(Se);var we=z(Se);ki(we);var Te=z(we,2),Ee=L(Te,!0);j(Te);var De=z(Te,2);q(De,21,()=>V(k),e=>e.id,(e,t)=>{var n=tD();let r;var i=L(n),o=L(i,!0);j(i);var s=z(i),c=L(s,!0);j(s),j(n),B(()=>{r=vi(n,1,`template-item svelte-3z3jlz`,null,r,{chosen:V(u)===V(t).id}),J(n,`aria-pressed`,V(u)===V(t).id),n.disabled=V(a),G(o,V(t).name),G(c,V(t).folderName)}),H(`click`,n,()=>ue(V(t).id)),W(e,n)},e=>{var t=rD(),n=L(t),i=L(n,!0);j(n);var a=z(n),o=L(a,!0);j(a);var s=z(a),l=e=>{var t=nD(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`templates.new_folder`)]),H(`click`,t,()=>pe(`new`)),W(e,t)};K(s,e=>{V(r).folders.length||e(l)}),j(t),B((e,t)=>{G(i,e),G(o,t)},[()=>Y(V(r).folders.length?V(c)?`templates.no_results`:`templates.folder_empty`:`templates.welcome`),()=>Y(V(r).folders.length?V(c)?`templates.search_hint`:`templates.empty_hint`:`templates.start_hint`)]),W(e,t)}),j(De),j(xe);var Oe=z(xe,2),ke=L(Oe),Ae=L(ke);j(ke);var je=z(ke,2),Me=e=>{var t=aD(),n=L(t),i=L(n),o=L(i,!0);j(i);var s=z(i),c=L(s,!0);j(s),j(n);var l=z(n,2),u=L(l),d=L(u,!0);j(u);var g=z(u),v=L(g),y=L(v,!0);j(v);var b=z(v),x=L(b,!0);j(b),j(g),j(l);var S=z(l,2),w=L(S),T=L(w),E=L(T,!0);j(T);var D=z(T);ki(D);var ee=z(D),te=L(ee,!0);j(ee),j(w);var O=z(w),k=L(O),ne=L(k,!0);j(k);var re=z(k);q(re,21,()=>V(r).folders,Qr,(e,t)=>{var n=iD(),r=L(n,!0);j(n);var i={};B(()=>{G(r,V(t).name),i!==(i=V(t).id)&&(n.value=(n.__value=V(t).id)??``)}),W(e,n)}),j(re),j(O),j(S);var ae=z(S,2),oe=L(ae,!0);j(ae);var se=z(ae,2),ce=L(se);yn(ce);var le=z(ce),ue=L(le),de=L(ue,!0);j(ue);var pe=z(ue),me=e=>{qE(e,{get content(){return V(m)}})};K(pe,e=>{V(C)&&e(me)}),j(le),j(se),j(t),B((e,t,n,r,i,s,l,u,f,p)=>{G(o,e),G(c,t),G(d,n),v.disabled=V(a),G(y,r),b.disabled=i,G(x,s),G(E,l),D.disabled=V(a),J(D,`aria-invalid`,!!V(_)),G(te,V(_)),G(ne,u),re.disabled=V(a),G(oe,f),ce.disabled=V(a),G(de,p)},[()=>Y(V(f)?`templates.edit`:`templates.new_template`),()=>Y(V(A)?`templates.unsaved`:`templates.no_changes`),()=>Y(`templates.save_shortcut`),()=>Y(`common.cancel`),()=>V(a)||!V(p).trim()||!V(h),()=>Y(`templates.save_template`),()=>Y(`templates.name`),()=>Y(`templates.folder`),()=>Y(`templates.content`),()=>Y(`templates.preview`)]),Nr(`submit`,t,e=>{e.preventDefault(),fe()}),H(`click`,v,()=>ie(()=>{})),Fi(D,()=>V(p),e=>F(p,e)),Ci(re,()=>V(h),e=>F(h,e)),Fi(ce,()=>V(m),e=>F(m,e)),Wi(`open`,`toggle`,le,e=>F(C,e),()=>V(C)),W(e,t)},Ne=e=>{var t=sD(),n=R(t),r=L(n),i=L(r);j(r);var o=z(r),s=L(o,!0);j(o);var c=z(o),l=L(c),u=L(l,!0);j(l);var d=z(l),f=L(d,!0);j(d);var p=z(d),m=L(p),h=L(m,!0);j(m);var g=z(m),_=L(g),v=L(_,!0);j(_);var y=z(_),b=L(y,!0);j(y),j(g),j(p),j(c);var x=z(c),C=L(x,!0);j(x),j(n);var w=z(n,2),E=L(w),D=L(E,!0);j(E);var ee=z(E),O=L(ee,!0);j(ee),j(w);var k=z(w,2),ne=L(k),A=e=>{var t=oD(),n=L(t,!0);j(t),B(()=>G(n,V(te).content)),W(e,t)},re=e=>{qE(e,{get content(){return V(te).content}})};K(ne,e=>{V(S)?e(A):e(re,-1)}),j(k),B((e,t,n,r,o,c,p,m,g)=>{G(i,`${V(te).folderName??``} / ${e??``}`),G(s,V(te).name),l.disabled=V(a),G(u,t),d.disabled=V(a),G(f,n),G(h,r),_.disabled=V(a),G(v,o),y.disabled=V(a),G(b,c),G(C,p),G(D,m),J(ee,`aria-pressed`,V(S)),G(O,g)},[()=>Y(`templates.template`),()=>Y(`templates.use`),()=>Y(`templates.edit`),()=>Y(`templates.more`),()=>Y(`templates.duplicate`),()=>Y(`common.remove`),()=>Y(`templates.independent`),()=>Y(`templates.preview`),()=>Y(V(S)?`templates.formatted`:`templates.source`)]),H(`click`,l,()=>F(T,V(te)?.id,!0)),H(`click`,d,()=>de(V(te))),H(`click`,_,()=>de(V(te),!0)),H(`click`,y,()=>he(!1)),H(`click`,ee,()=>F(S,!V(S))),W(e,t)},Pe=e=>{var t=cD(),n=L(t),r=L(n,!0);j(n);var i=z(n),a=L(i,!0);j(i),j(t),B((e,t)=>{G(r,e),G(a,t)},[()=>Y(`templates.select_template`),()=>Y(`templates.preview_hint`)]),W(e,t)};K(je,e=>{V(d)?e(Me):V(te)?e(Ne,1):e(Pe,-1)}),j(Oe),j(t),B((e,r,o,s,c,u,d,f,p,m,h)=>{n=vi(t,1,`library-layout svelte-3z3jlz`,null,n,{"show-detail":V(w)}),J(i,`aria-label`,e),G(g,r),b.disabled=V(a),G(E,o),ne=vi(O,1,`folder-item svelte-3z3jlz`,null,ne,{chosen:!V(l)}),J(O,`aria-pressed`,!V(l)),O.disabled=V(a),G(re,s),G(oe,V(D).length),G(ge,c),J(xe,`aria-label`,u),G(Ce,d),J(we,`placeholder`,f),G(Ee,p),J(Oe,`aria-label`,m),ke.disabled=V(a),G(Ae,`← ${h??``}`)},[()=>Y(`templates.folders`),()=>Y(`templates.folders`),()=>Y(`templates.add_folder`),()=>Y(`templates.all`),()=>Y(`templates.folder_hint`),()=>Y(`templates.menu`),()=>Y(`templates.search`),()=>Y(`templates.search_placeholder`),()=>Y(`templates.result_count`,{count:String(V(k).length)}),()=>Y(`templates.detail`),()=>Y(`templates.back_list`)]),H(`click`,b,()=>pe(`new`)),H(`click`,O,()=>le(``)),Fi(we,()=>V(c),e=>F(c,e)),H(`click`,ke,()=>ie(()=>{F(w,!1)})),W(e,t)};K(Pe,e=>{V(i)?e(Ie,-1):e(Fe)}),j(ye);var Le=z(ye,2),Re=e=>{Wa(e,{open:!0,get initialTemplateId(){return V(T)},onclose:()=>F(T,void 0),onsuccess:e=>{window.location.href=`/?doc=`+encodeURIComponent(e)}})};K(Le,e=>{V(T)&&e(Re)}),B((e,t,n)=>{J(ye,`aria-busy`,V(a)),G(Ce,e),G(Te,t),Ee.disabled=V(a)||!V(i)||!V(r).folders.length,G(De,` ${n??``}`)},[()=>Y(`templates.library`),()=>Y(`templates.library_subtitle`),()=>Y(`templates.new_template`)]),H(`click`,Ee,()=>de()),W(e,_e),Je()}Pr([`click`]);var fD=U(`<div class="app-shell templates-shell svelte-j6d35n"><!> <!></div>`);function pD(e,t){qe(t,!1),Ji(async()=>{try{let e=await fetch(`/api/config`);e.ok&&await Sa((await e.json()).language||`en`)}catch{}}),Gi();var n=fD(),r=L(n);{let e=bt(()=>Y(`templates.library`));Xo(r,{get title(){return V(e)},subtitle:``})}dD(z(r,2),{}),j(n),W(e,n),Je()}var mD=I({tasks:[],notes:[],links:[]}),hD=!1,gD=null;async function _D(){try{let e=await fetch(`/api/survival-kit`);if(e.ok){let t=await e.json();mD.tasks=Array.isArray(t.tasks)?t.tasks:[],mD.notes=Array.isArray(t.notes)?t.notes:[],mD.links=Array.isArray(t.links)?t.links:[]}}catch{}finally{hD=!0}}async function vD(){try{await fetch(`/api/survival-kit`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({tasks:mD.tasks,notes:mD.notes,links:mD.links})})}catch{}}function yD(){hD&&(gD&&clearTimeout(gD),gD=setTimeout(()=>{gD=null,vD()},400))}var bD=U(`<button type="button"> </button>`),xD=U(`<p class="sk-empty svelte-lo2xyl"> </p>`),SD=U(`<div><button type="button" aria-label="toggle"></button> <span class="sk-task-text svelte-lo2xyl"> </span> <span class="sk-task-tag svelte-lo2xyl"> </span> <button type="button" class="sk-task-del svelte-lo2xyl">✕</button></div>`),CD=U(`<div class="sk-panel-head"><h2 class="sk-panel-title"> <span class="sk-accent">.</span></h2> <p class="sk-panel-sub"> </p></div> <div class="sk-add-bar svelte-lo2xyl"><input type="text" class="svelte-lo2xyl"/> <select class="svelte-lo2xyl"><option> </option><option> </option><option> </option></select> <button type="button" class="sk-add-btn svelte-lo2xyl">+</button></div> <div class="sk-filters svelte-lo2xyl"></div> <div class="sk-tasks svelte-lo2xyl"><!></div>`,1);function wD(e,t){qe(t,!0);let n=P(``),r=P(`normal`),i=P(`all`),a=[{key:`all`,label:()=>Y(`survival.tasks_filter_all`)},{key:`todo`,label:()=>Y(`survival.tasks_filter_todo`)},{key:`done`,label:()=>Y(`survival.tasks_filter_done`)},{key:`urgent`,label:()=>Y(`survival.tasks_filter_urgent`)},{key:`normal`,label:()=>Y(`survival.tasks_filter_normal`)},{key:`later`,label:()=>Y(`survival.tasks_filter_later`)}];function o(e){return Y(`survival.tasks_priority_${e}`)}let s=N(()=>mD.tasks.filter(e=>V(i)===`todo`?!e.done:V(i)===`done`?e.done:V(i)===`urgent`||V(i)===`normal`||V(i)===`later`?e.priority===V(i):!0));function c(){let e=V(n).trim();e&&(mD.tasks.unshift({id:Date.now(),text:e,priority:V(r),done:!1}),F(n,``),yD())}function l(e){let t=mD.tasks.find(t=>t.id===e);t&&(t.done=!t.done),yD()}function u(e){mD.tasks=mD.tasks.filter(t=>t.id!==e),yD()}var d=CD(),f=R(d),p=L(f),m=L(p,!0);Ie(),j(p);var h=z(p,2),g=L(h,!0);j(h),j(f);var _=z(f,2),v=L(_);ki(v);var y=z(v,2),b=L(y),x=L(b,!0);j(b),b.value=b.__value=`normal`;var S=z(b),C=L(S,!0);j(S),S.value=S.__value=`urgent`;var w=z(S),T=L(w,!0);j(w),w.value=w.__value=`later`,j(y);var E=z(y,2);j(_);var D=z(_,2);q(D,21,()=>a,Qr,(e,t)=>{var n=bD();let r;var a=L(n,!0);j(n),B(e=>{r=vi(n,1,`svelte-lo2xyl`,null,r,{active:V(i)===V(t).key}),G(a,e)},[()=>V(t).label()]),H(`click`,n,()=>F(i,V(t).key,!0)),W(e,n)}),j(D);var ee=z(D,2),te=L(ee),O=e=>{var t=xD(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`survival.tasks_empty`)]),W(e,t)},k=e=>{var t=Wr();q(R(t),17,()=>V(s),e=>e.id,(e,t)=>{var n=SD();let r;var i=L(n);let a;var s=z(i,2),c=L(s,!0);j(s);var d=z(s,2),f=L(d,!0);j(d);var p=z(d,2);j(n),B((e,o)=>{r=vi(n,1,`sk-task sk-task--${V(t).priority??``}`,`svelte-lo2xyl`,r,{done:V(t).done}),a=vi(i,1,`sk-check svelte-lo2xyl`,null,a,{checked:V(t).done}),G(c,V(t).text),G(f,e),J(p,`title`,o)},[()=>o(V(t).priority),()=>Y(`survival.tasks_delete_title`)]),H(`click`,i,()=>l(V(t).id)),H(`click`,p,()=>u(V(t).id)),W(e,n)}),W(e,t)};K(te,e=>{V(s).length===0?e(O):e(k,-1)}),j(ee),B((e,t,n,r,i,a)=>{G(m,e),G(g,t),J(v,`placeholder`,n),G(x,r),G(C,i),G(T,a)},[()=>Y(`survival.tasks_title`),()=>Y(`survival.tasks_subtitle`),()=>Y(`survival.tasks_input_placeholder`),()=>Y(`survival.tasks_priority_normal`),()=>Y(`survival.tasks_priority_urgent`),()=>Y(`survival.tasks_priority_later`)]),H(`keydown`,v,e=>e.key===`Enter`&&c()),Fi(v,()=>V(n),e=>F(n,e)),Ci(y,()=>V(r),e=>F(r,e)),H(`click`,E,c),W(e,d),Je()}Pr([`keydown`,`click`]);var TD=[`t-green`,`t-violet`,`t-amber`,`t-sky`,`t-rose`,`t-teal`],ED=U(`<div class="sk-modal-backdrop svelte-1rcj86" role="presentation"><div class="sk-modal svelte-1rcj86" role="dialog" aria-modal="true"><h3 class="sk-modal-title svelte-1rcj86"> </h3> <div class="sk-modal-body svelte-1rcj86"><!></div> <div class="sk-modal-actions svelte-1rcj86"><button type="button" class="sk-btn svelte-1rcj86"> </button> <button type="button"> </button></div></div></div>`);function DD(e,t){qe(t,!0);let n=qi(t,`open`,3,!1),r=qi(t,`title`,3,``),i=qi(t,`confirmLabel`,19,()=>Y(`common.save`)),a=qi(t,`danger`,3,!1);function o(e){e.target===e.currentTarget&&t.onClose()}function s(e){e.key===`Escape`&&t.onClose()}var c=Wr(),l=R(c),u=e=>{var n=ED(),c=L(n),l=L(c),u=L(l,!0);j(l);var d=z(l,2);ci(L(d),()=>t.children),j(d);var f=z(d,2),p=L(f),m=L(p,!0);j(p);var h=z(p,2);let g;var _=L(h,!0);j(h),j(f),j(c),j(n),B(e=>{G(u,r()),G(m,e),g=vi(h,1,`sk-btn sk-btn--primary svelte-1rcj86`,null,g,{"sk-btn--danger":a()}),G(_,i())},[()=>Y(`common.cancel`)]),H(`click`,n,o),H(`keydown`,n,s),H(`click`,p,function(...e){t.onClose?.apply(this,e)}),H(`click`,h,function(...e){t.onConfirm?.apply(this,e)}),W(e,n)};K(l,e=>{n()&&e(u)}),W(e,c),Je()}Pr([`click`,`keydown`]);var OD=U(`<p class="sk-empty svelte-hpbata"> </p>`),kD=U(`<strong> </strong>`),AD=U(`<p> </p>`),jD=U(`<div class="sk-pre-wrap svelte-hpbata"><pre> </pre> <button type="button" class="sk-copy svelte-hpbata"> </button></div>`),MD=U(`<li> </li>`),ND=U(`<ul></ul>`),PD=U(`<th> </th>`),FD=U(`<td> </td>`),ID=U(`<tr></tr>`),LD=U(`<div class="sk-table-wrap svelte-hpbata"><table><thead><tr></tr></thead><tbody></tbody></table></div>`),RD=U(`<div class="sk-bloc svelte-hpbata"><div class="sk-bloc-content svelte-hpbata"><!></div> <div class="sk-bloc-actions svelte-hpbata"><button type="button" class="sk-mini svelte-hpbata">✎</button> <button type="button" class="sk-mini sk-mini--del svelte-hpbata">✕</button></div></div>`),zD=U(`<div><div class="sk-note-head svelte-hpbata"><h3 class="svelte-hpbata"> </h3> <div class="sk-note-actions svelte-hpbata"><button type="button" class="sk-mini svelte-hpbata">✎</button> <button type="button" class="sk-mini sk-mini--del svelte-hpbata">✕</button></div> <button type="button" class="sk-toggle svelte-hpbata" aria-label="toggle"><svg viewBox="0 0 10 6" width="10" height="6"><path d="M1 1 L5 5 L9 1" stroke="currentColor" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div> <div class="sk-note-body svelte-hpbata"><!> <div class="sk-note-foot svelte-hpbata"><button type="button" class="sk-add-bloc svelte-hpbata"> </button></div></div></div>`),BD=U(`<option> </option>`),VD=U(`<label for="sk-note-titre"> </label> <input id="sk-note-titre" type="text"/> <label for="sk-note-color"> </label> <select id="sk-note-color"></select>`,1),HD=U(`<input id="sk-bloc-content" type="text"/>`),UD=U(`<textarea id="sk-bloc-content" rows="6"></textarea>`),WD=U(`<label for="sk-bloc-type"> </label> <select id="sk-bloc-type"><option> </option><option> </option><option> </option><option> </option><option> </option></select> <label for="sk-bloc-content"> </label> <!>`,1),GD=U(`<div class="sk-panel-head"><h2 class="sk-panel-title"> <span class="sk-accent">.</span></h2> <p class="sk-panel-sub"> </p></div> <div class="sk-toolbar svelte-hpbata"><button type="button" class="sk-tool svelte-hpbata"> </button> <button type="button" class="sk-tool svelte-hpbata"> </button> <button type="button" class="sk-tool sk-tool--add svelte-hpbata"> </button></div> <div><!> <!></div> <!> <!>`,1);function KD(e,t){qe(t,!0);let n=P(!1),r=P(I({})),i=P(null),a=P(!1),o=P(-1),s=P(``),c=P(`t-green`),l=P(!1),u=P(-1),d=P(-1),f=P(`p`),p=P(``),m={"t-green":`survival.color_green`,"t-violet":`survival.color_violet`,"t-amber":`survival.color_amber`,"t-sky":`survival.color_sky`,"t-rose":`survival.color_rose`,"t-teal":`survival.color_teal`},h=N(()=>mD.notes.length>0&&mD.notes.every(e=>V(r)[e.id]));function g(e){V(r)[e]=!V(r)[e]}function _(){if(V(h))F(r,{},!0);else{let e={};mD.notes.forEach(t=>e[t.id]=!0),F(r,e,!0)}}function v(){F(o,-1),F(s,``),F(c,`t-green`),F(a,!0)}function y(e){F(o,e,!0),F(s,mD.notes[e].titre,!0),F(c,mD.notes[e].theme,!0),F(a,!0)}function b(){let e=V(s).trim();if(e){if(V(o)===-1){let t=Date.now();mD.notes.push({id:t,theme:V(c),titre:e,blocs:[]}),V(r)[t]=!0}else mD.notes[V(o)].titre=e,mD.notes[V(o)].theme=V(c);yD(),F(a,!1)}}async function x(e){await t.confirmDelete(Y(`survival.confirm_del_note_title`),Y(`survival.confirm_del_note_msg`))&&(mD.notes.splice(e,1),yD())}function S(e){return e.type===`ul`?e.items.join(`
|
|
322
|
+
`}tablerow(e){return`<tr>\n${e}</tr>\n`}tablecell(e,t){let n=t.header?`th`:`td`;return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>\n`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return`<br>`}del(e){return`<del>${e}</del>`}link(e,t,n){let r=qT(e);if(r===null)return n;e=r;let i=`<a href="`+e+`"`;return t&&(i+=` title="`+t+`"`),i+=`>`+n+`</a>`,i}image(e,t,n){let r=qT(e);if(r===null)return n;e=r;let i=`<img src="${e}" alt="${n}"`;return t&&(i+=` title="${t}"`),i+=`>`,i}text(e){return e}},qE=class{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return``+n}image(e,t,n){return``+n}br(){return``}},JE=class e{options;renderer;textRenderer;constructor(e){this.options=e||PT,this.options.renderer=this.options.renderer||new KE,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new qE}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(t!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`paragraph`,`text`].includes(e.type)){n+=t||``;continue}}switch(i.type){case`space`:continue;case`hr`:n+=this.renderer.hr();continue;case`heading`:{let e=i;n+=this.renderer.heading(this.parseInline(e.tokens),e.depth,WT(this.parseInline(e.tokens,this.textRenderer)));continue}case`code`:{let e=i;n+=this.renderer.code(e.text,e.lang,!!e.escaped);continue}case`table`:{let e=i,t=``,r=``;for(let t=0;t<e.header.length;t++)r+=this.renderer.tablecell(this.parseInline(e.header[t].tokens),{header:!0,align:e.align[t]});t+=this.renderer.tablerow(r);let a=``;for(let t=0;t<e.rows.length;t++){let n=e.rows[t];r=``;for(let t=0;t<n.length;t++)r+=this.renderer.tablecell(this.parseInline(n[t].tokens),{header:!1,align:e.align[t]});a+=this.renderer.tablerow(r)}n+=this.renderer.table(t,a);continue}case`blockquote`:{let e=i,t=this.parse(e.tokens);n+=this.renderer.blockquote(t);continue}case`list`:{let e=i,t=e.ordered,r=e.start,a=e.loose,o=``;for(let t=0;t<e.items.length;t++){let n=e.items[t],r=n.checked,i=n.task,s=``;if(n.task){let e=this.renderer.checkbox(!!r);a?n.tokens.length>0&&n.tokens[0].type===`paragraph`?(n.tokens[0].text=e+` `+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type===`text`&&(n.tokens[0].tokens[0].text=e+` `+n.tokens[0].tokens[0].text)):n.tokens.unshift({type:`text`,text:e+` `}):s+=e+` `}s+=this.parse(n.tokens,a),o+=this.renderer.listitem(s,i,!!r)}n+=this.renderer.list(o,t,r);continue}case`html`:{let e=i;n+=this.renderer.html(e.text,e.block);continue}case`paragraph`:{let e=i;n+=this.renderer.paragraph(this.parseInline(e.tokens));continue}case`text`:{let a=i,o=a.tokens?this.parseInline(a.tokens):a.text;for(;r+1<e.length&&e[r+1].type===`text`;)a=e[++r],o+=`
|
|
323
|
+
`+(a.tokens?this.parseInline(a.tokens):a.text);n+=t?this.renderer.paragraph(o):o;continue}default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t){t||=this.renderer;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}switch(i.type){case`escape`:{let e=i;n+=t.text(e.text);break}case`html`:{let e=i;n+=t.html(e.text);break}case`link`:{let e=i;n+=t.link(e.href,e.title,this.parseInline(e.tokens,t));break}case`image`:{let e=i;n+=t.image(e.href,e.title,e.text);break}case`strong`:{let e=i;n+=t.strong(this.parseInline(e.tokens,t));break}case`em`:{let e=i;n+=t.em(this.parseInline(e.tokens,t));break}case`codespan`:{let e=i;n+=t.codespan(e.text);break}case`br`:n+=t.br();break;case`del`:{let e=i;n+=t.del(this.parseInline(e.tokens,t));break}case`text`:{let e=i;n+=t.text(e.text);break}default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},YE=class{options;constructor(e){this.options=e||PT}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}},XE=new class{defaults=NT();options=this.setOptions;parse=this.#e(GE.lex,JE.parse);parseInline=this.#e(GE.lexInline,JE.parseInline);Parser=JE;Renderer=KE;TextRenderer=qE;Lexer=GE;Tokenizer=eE;Hooks=YE;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new KE(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if(n===`options`)continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new eE(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new YE;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if(n===`options`)continue;let r=n,i=e.hooks[r],a=t[r];YE.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(i.call(t,e)).then(e=>a.call(t,e));let n=i.call(t,e);return a.call(t,n)}:t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return GE.lex(e,t??this.defaults)}parser(e,t){return JE.parse(e,t??this.defaults)}#e(e,t){return(n,r)=>{let i={...r},a={...this.defaults,...i};this.defaults.async===!0&&i.async===!1&&(a.silent||console.warn(`marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.`),a.async=!0);let o=this.#t(!!a.silent,!!a.async);if(n==null)return o(Error(`marked(): input parameter is undefined or null`));if(typeof n!=`string`)return o(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(n)+`, string expected`));if(a.hooks&&(a.hooks.options=a),a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(n):n).then(t=>e(t,a)).then(e=>a.hooks?a.hooks.processAllTokens(e):e).then(e=>a.walkTokens?Promise.all(this.walkTokens(e,a.walkTokens)).then(()=>e):e).then(e=>t(e,a)).then(e=>a.hooks?a.hooks.postprocess(e):e).catch(o);try{a.hooks&&(n=a.hooks.preprocess(n));let r=e(n,a);a.hooks&&(r=a.hooks.processAllTokens(r)),a.walkTokens&&this.walkTokens(r,a.walkTokens);let i=t(r,a);return a.hooks&&(i=a.hooks.postprocess(i)),i}catch(e){return o(e)}}}#t(e,t){return n=>{if(n.message+=`
|
|
324
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+HT(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function ZE(e,t){return XE.parse(e,t)}ZE.options=ZE.setOptions=function(e){return XE.setOptions(e),ZE.defaults=XE.defaults,FT(ZE.defaults),ZE},ZE.getDefaults=NT,ZE.defaults=PT,ZE.use=function(...e){return XE.use(...e),ZE.defaults=XE.defaults,FT(ZE.defaults),ZE},ZE.walkTokens=function(e,t){return XE.walkTokens(e,t)},ZE.parseInline=XE.parseInline,ZE.Parser=JE,ZE.parser=JE.parse,ZE.Renderer=KE,ZE.TextRenderer=qE,ZE.Lexer=GE,ZE.lexer=GE.lex,ZE.Tokenizer=eE,ZE.Hooks=YE,ZE.parse=ZE,ZE.options,ZE.setOptions,ZE.use,ZE.walkTokens,ZE.parseInline,JE.parse,GE.lex;var QE=U(`<iframe sandbox="" class="svelte-zodsi8"></iframe>`);function $E(e,t){qe(t,!0);let n=P(!1);Ji(()=>{let e=()=>{F(n,document.documentElement.classList.contains(`dark`),!0)};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()});let r=N(()=>ZE.parse(t.content.replace(/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/,``),{async:!1})),i=N(()=>`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:;"><style>html{color-scheme:${V(n)?`dark`:`light`}}body{font:15px/1.7 system-ui;margin:24px;overflow-wrap:anywhere}h1{font-size:1.7em}h2{font-size:1.3em}pre{overflow:auto;padding:16px;background:light-dark(#f1f5f9,#1e293b);border-radius:8px}code{font-family:monospace}table{border-collapse:collapse;width:100%}th,td{border:1px solid #8886;padding:8px;text-align:left}blockquote{border-left:3px solid #8886;padding-left:16px;margin-left:0}img{max-width:100%}a{color:light-dark(#2563eb,#93c5fd)}</style></head><body>${V(r)}</body></html>`);var a=Wr();Zr(R(a),()=>V(i),e=>{var t=QE();B(e=>{J(t,`title`,e),J(t,`srcdoc`,V(i))},[()=>Y(`templates.preview`)]),W(e,t)}),W(e,a),Je()}var eD=U(`<span> </span>`),tD=U(`<span class="success svelte-3z3jlz"> </span>`),nD=U(`<div role="alert" class="error svelte-3z3jlz"><span> </span><button class="secondary-button svelte-3z3jlz"> </button></div>`),rD=U(`<p> </p>`),iD=U(`<button><span class="svelte-3z3jlz"> </span><span class="svelte-3z3jlz"> </span></button>`),aD=U(`<details class="folder-actions"><summary class="svelte-3z3jlz"> </summary><div class="actions svelte-3z3jlz"><button class="secondary-button svelte-3z3jlz"> </button><button class="text-button danger svelte-3z3jlz" data-testid="template-delete-folder"> </button></div></details>`),oD=U(`<form class="folder-form svelte-3z3jlz"><label for="template-folder-input" class="svelte-3z3jlz"> </label> <input id="template-folder-input" maxlength="120" aria-describedby="template-folder-error" class="svelte-3z3jlz"/> <span id="template-folder-error" class="error svelte-3z3jlz" role="alert"> </span> <div class="actions svelte-3z3jlz"><button class="primary-button svelte-3z3jlz" data-testid="template-add-folder"> </button><button type="button" class="text-button svelte-3z3jlz"> </button></div></form>`),sD=U(`<button><span class="item-title svelte-3z3jlz"> </span><span class="hint svelte-3z3jlz"> </span></button>`),cD=U(`<button class="primary-button svelte-3z3jlz"> </button>`),lD=U(`<div class="empty svelte-3z3jlz"><h2 class="svelte-3z3jlz"> </h2><p class="svelte-3z3jlz"> </p><!></div>`),uD=U(`<option> </option>`),dD=U(`<form class="edit-form svelte-3z3jlz"><div class="pane-heading svelte-3z3jlz"><h2 class="svelte-3z3jlz"> </h2><span class="draft-status svelte-3z3jlz"> </span></div> <footer class="editor-footer svelte-3z3jlz"><span class="hint svelte-3z3jlz"> </span><div class="actions svelte-3z3jlz"><button type="button" class="secondary-button svelte-3z3jlz"> </button><button class="primary-button svelte-3z3jlz" data-testid="template-save"> </button></div></footer> <div class="fields svelte-3z3jlz"><div><label for="template-name" class="svelte-3z3jlz"> </label><input id="template-name" maxlength="120" aria-describedby="template-name-error" class="svelte-3z3jlz"/><span class="error svelte-3z3jlz" id="template-name-error" role="alert"> </span></div><div><label for="template-destination" class="svelte-3z3jlz"> </label><select id="template-destination" class="svelte-3z3jlz"></select></div></div> <label for="template-content" class="svelte-3z3jlz"> </label> <div class="editor-body svelte-3z3jlz"><textarea id="template-content" maxlength="1000000" spellcheck="false" class="svelte-3z3jlz"></textarea><details class="live-preview svelte-3z3jlz"><summary class="svelte-3z3jlz"> </summary><!></details></div></form>`),fD=U(`<pre class="svelte-3z3jlz"> </pre>`),pD=U(`<div class="detail-heading svelte-3z3jlz"><span class="eyebrow svelte-3z3jlz"> </span><h2 class="svelte-3z3jlz"> </h2><div class="actions svelte-3z3jlz"><button class="primary-button svelte-3z3jlz"> </button><button class="secondary-button svelte-3z3jlz" id="template-edit" data-testid="template-edit"> </button><details class="more-actions svelte-3z3jlz"><summary class="svelte-3z3jlz"> </summary><div class="actions svelte-3z3jlz"><button class="text-button svelte-3z3jlz"> </button><button class="text-button danger svelte-3z3jlz"> </button></div></details></div><p class="hint svelte-3z3jlz"> </p></div> <div class="preview-heading svelte-3z3jlz"><h3 class="svelte-3z3jlz"> </h3><button class="text-button svelte-3z3jlz"> </button></div> <div class="preview-content svelte-3z3jlz"><!></div>`,1),mD=U(`<div class="empty svelte-3z3jlz"><h2 class="svelte-3z3jlz"> </h2><p class="svelte-3z3jlz"> </p></div>`),hD=U(`<div><aside class="folder-pane svelte-3z3jlz"><div class="pane-heading svelte-3z3jlz"><h2 class="svelte-3z3jlz"> </h2><button class="text-button svelte-3z3jlz"> </button></div> <button> <span class="svelte-3z3jlz"> </span></button> <!> <p class="hint svelte-3z3jlz"> </p> <!> <!></aside> <section class="list-pane svelte-3z3jlz"><label for="template-search" class="svelte-3z3jlz"> </label><input type="search" id="template-search" class="svelte-3z3jlz"/> <div class="list-caption svelte-3z3jlz"> </div> <div class="template-list svelte-3z3jlz"></div></section> <section class="detail-pane svelte-3z3jlz"><button class="text-button mobile-back svelte-3z3jlz"> </button> <!></section></div>`),gD=U(`<!> <div class="template-library svelte-3z3jlz" data-testid="templates-manager"><header class="library-heading svelte-3z3jlz"><div><h1 class="svelte-3z3jlz"> </h1><p class="svelte-3z3jlz"> </p></div> <button class="primary-button svelte-3z3jlz" data-testid="template-new"><span aria-hidden="true">+</span> </button></header> <div class="feedback svelte-3z3jlz" aria-live="polite"><!> <!></div> <!></div> <!>`,1);function _D(e,t){qe(t,!0);let n=ka(),r=P(I({version:1,folders:[]})),i=P(!1),a=P(!1),o=P(``),s=P(``),c=P(``),l=P(``),u=P(``),d=P(!1),f=P(``),p=P(``),m=P(``),h=P(``),g=P(``),_=P(``),v=P(null),y=P(``),b=P(``),x=P(``),S=P(!1),C=P(!1),w=P(!1),T=P(void 0),E,D=N(()=>V(r).folders.flatMap(e=>e.templates.map(t=>({...t,folderId:e.id,folderName:e.name})))),ee=N(()=>V(r).folders.find(e=>e.id===V(l))),te=N(()=>V(D).find(e=>e.id===V(u))),O=e=>e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).toLocaleLowerCase(),k=N(()=>V(D).filter(e=>(!V(l)||e.folderId===V(l))&&O(e.name+` `+e.content).includes(O(V(c))))),ne=()=>JSON.stringify([V(p),V(m),V(h)]),A=N(()=>V(d)&&ne()!==V(g)||V(v)!==null&&V(y)!==V(b));async function re(){if(V(a))return!1;if(!V(A))return!0;let e=await E.show({title:Y(`templates.unsaved_title`),message:Y(`templates.unsaved_message`),confirmLabel:Y(`templates.discard`),cancelLabel:Y(`templates.keep_editing`),danger:!0});return e&&(F(d,!1),F(v,null)),e}async function ie(e){await re()&&(F(d,!1),F(v,null),F(o,``),F(s,``),await e())}async function ae(){F(r,await n(),!0),F(i,!0),V(l)&&!V(r).folders.some(e=>e.id===V(l))&&F(l,``),V(D).some(e=>e.id===V(u))||F(u,V(D)[0]?.id||``,!0)}async function oe(e){if(!V(a)){F(a,!0),F(o,``),F(s,``);try{await e()}catch(e){F(o,e instanceof Error?e.message:Y(`templates.errors.storage_error`),!0)}finally{F(a,!1)}}}let se=()=>ie(()=>oe(ae));Ji(()=>(oe(ae),Bo(re)));function ce(e){(V(A)||V(a))&&(e.preventDefault(),e.returnValue=``)}async function le(e){await ie(()=>{F(l,e,!0),F(w,!1),F(u,V(D).find(t=>!e||t.folderId===e)?.id||``,!0)})}async function ue(e){await ie(()=>{F(u,e,!0),F(w,!0),F(S,!1)})}async function de(e,t=!1){await ie(async()=>{if(F(f,t?``:e?.id||``,!0),F(h,e?.folderId||V(l)||V(r).folders[0]?.id||``,!0),F(p,e?.name||``,!0),t&&e){let t=Y(`templates.copy_name`,{name:e.name});F(p,t,!0);let n=2;for(;V(D).some(e=>e.folderId===V(h)&&e.name.toLocaleLowerCase()===V(p).toLocaleLowerCase());)F(p,`${t} ${n++}`)}F(m,e?.content||``,!0),F(g,t?``:ne(),!0),F(_,``),F(d,!0),F(w,!0),await xr(),document.getElementById(`template-name`)?.focus()})}async function fe(){if(F(_,``),!V(p).trim()||V(p).trim().length>120){F(_,Y(`templates.errors.invalid_name`),!0);return}if(V(D).some(e=>e.id!==V(f)&&e.folderId===V(h)&&e.name.toLocaleLowerCase()===V(p).trim().toLocaleLowerCase())){F(_,Y(`templates.errors.duplicate_name`),!0);return}await oe(async()=>{let e=await n(V(f)?`/${V(f)}`:`/folders/${V(h)}/templates`,V(f)?`PUT`:`POST`,{name:V(p),content:V(m),folderId:V(h)});F(r,{...V(r),folders:V(r).folders.map(t=>({...t,templates:[...t.templates.filter(t=>t.id!==e.id),...t.id===V(h)?[e]:[]]}))},!0),F(u,e.id,!0),F(l,V(h),!0),F(c,``),F(d,!1),F(S,!1),F(s,Y(`templates.saved`),!0),await xr(),document.getElementById(`template-edit`)?.focus()})}async function pe(e){await ie(async()=>{F(y,e===`rename`&&V(ee)?.name||``,!0),F(b,V(y),!0),F(v,e,!0),F(x,``),await xr(),document.getElementById(`template-folder-input`)?.focus()})}async function me(){if(!V(y).trim()||V(y).trim().length>120){F(x,Y(`templates.errors.invalid_name`),!0);return}if(V(r).folders.some(e=>(V(v)===`new`||e.id!==V(l))&&e.name.toLocaleLowerCase()===V(y).trim().toLocaleLowerCase())){F(x,Y(`templates.errors.duplicate_name`),!0);return}await oe(async()=>{let e=await n(V(v)===`new`?`/folders`:`/folders/${V(l)}`,V(v)===`new`?`POST`:`PUT`,{name:V(y)});F(r,{...V(r),folders:V(v)===`new`?[...V(r).folders,e]:V(r).folders.map(t=>t.id===e.id?e:t)},!0),F(l,e.id,!0),F(u,e.templates[0]?.id||``,!0),F(v,null),F(x,``),F(s,Y(`templates.folder_saved`),!0)})}async function he(e){if(!await re())return;let t=V(e?ee:te);t&&await E.show({title:Y(e?`templates.delete_folder`:`templates.delete_template`),message:Y(`templates.delete_message`,{name:t.name}),detail:e?Y(`templates.delete_count`,{count:String(V(ee)?.templates.length||0)}):Y(`templates.independent`),confirmLabel:Y(`common.remove`),cancelLabel:Y(`common.cancel`),danger:!0})&&await oe(async()=>{await n(e?`/folders/${t.id}?confirm=true`:`/${t.id}`,`DELETE`),F(r,{...V(r),folders:e?V(r).folders.filter(e=>e.id!==t.id):V(r).folders.map(e=>({...e,templates:e.templates.filter(e=>e.id!==t.id)}))},!0),e&&F(l,``),F(u,V(D).find(e=>!V(l)||e.folderId===V(l))?.id||``,!0),F(d,!1),F(w,!1),F(s,Y(`templates.deleted`),!0)})}function ge(e){(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&V(d)&&(e.preventDefault(),V(a)||fe())}var _e=gD();Nr(`beforeunload`,on,ce),Nr(`keydown`,on,ge);var ve=R(_e);Ui(Xd(ve,{}),e=>E=e,()=>E);var ye=z(ve,2),be=L(ye),xe=L(be),Se=L(xe),Ce=L(Se,!0);j(Se);var we=z(Se),Te=L(we,!0);j(we),j(xe);var Ee=z(xe,2),De=z(L(Ee));j(Ee),j(be);var Oe=z(be,2),ke=L(Oe),Ae=e=>{var t=eD(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},je=e=>{var t=tD(),n=L(t);j(t),B(()=>G(n,`✓ ${V(s)??``}`)),W(e,t)};K(ke,e=>{V(a)?e(Ae):V(s)&&e(je,1)});var Me=z(ke,2),Ne=e=>{var t=nD(),n=L(t),r=L(n,!0);j(n);var i=z(n),s=L(i,!0);j(i),j(t),B(e=>{G(r,V(o)),i.disabled=V(a),G(s,e)},[()=>Y(`templates.reload`)]),H(`click`,i,se),W(e,t)};K(Me,e=>{V(o)&&e(Ne)}),j(Oe);var Pe=z(Oe,2),Fe=e=>{var t=Wr(),n=R(t),r=e=>{var t=rD(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`templates.load_failed`)]),W(e,t)};K(n,e=>{!V(a)&&V(o)&&e(r)}),W(e,t)},Ie=e=>{var t=hD();let n;var i=L(t),o=L(i),s=L(o),g=L(s,!0);j(s);var b=z(s),E=L(b,!0);j(b),j(o);var O=z(o,2);let ne;var re=L(O,!0),ae=z(re),oe=L(ae,!0);j(ae),j(O);var se=z(O,2);q(se,17,()=>V(r).folders,e=>e.id,(e,t)=>{var n=iD();let r;var i=L(n),o=L(i);j(i);var s=z(i),c=L(s,!0);j(s),j(n),B(()=>{r=vi(n,1,`folder-item svelte-3z3jlz`,null,r,{chosen:V(l)===V(t).id}),J(n,`aria-pressed`,V(l)===V(t).id),n.disabled=V(a),G(o,`▱ ${V(t).name??``}`),G(c,V(t).templates.length)}),H(`click`,n,()=>le(V(t).id)),W(e,n)});var ce=z(se,2),ge=L(ce,!0);j(ce);var _e=z(ce,2),ve=e=>{var t=aD(),n=L(t),r=L(n,!0);j(n);var i=z(n),o=L(i),s=L(o,!0);j(o);var c=z(o),l=L(c,!0);j(c),j(i),j(t),B((e,t,n)=>{G(r,e),o.disabled=V(a),G(s,t),c.disabled=V(a),G(l,n)},[()=>Y(`templates.folder_actions`),()=>Y(`templates.rename`),()=>Y(`common.remove`)]),H(`click`,o,()=>pe(`rename`)),H(`click`,c,()=>he(!0)),W(e,t)};K(_e,e=>{V(ee)&&e(ve)});var ye=z(_e,2),be=e=>{var t=oD(),n=L(t),r=L(n,!0);j(n);var i=z(n,2);ki(i);var o=z(i,2),s=L(o,!0);j(o);var c=z(o,2),l=L(c),u=L(l,!0);j(l);var d=z(l),f=L(d,!0);j(d),j(c),j(t),B((e,t,n,o)=>{G(r,e),i.disabled=V(a),J(i,`aria-invalid`,!!V(x)),G(s,V(x)),l.disabled=t,G(u,n),d.disabled=V(a),G(f,o)},[()=>Y(V(v)===`new`?`templates.new_folder`:`templates.rename_folder`),()=>V(a)||!V(y).trim(),()=>Y(V(v)===`new`?`common.create`:`common.save`),()=>Y(`common.cancel`)]),Nr(`submit`,t,e=>{e.preventDefault(),me()}),Fi(i,()=>V(y),e=>F(y,e)),H(`click`,d,()=>ie(()=>{})),W(e,t)};K(ye,e=>{V(v)&&e(be)}),j(i);var xe=z(i,2),Se=L(xe),Ce=L(Se,!0);j(Se);var we=z(Se);ki(we);var Te=z(we,2),Ee=L(Te,!0);j(Te);var De=z(Te,2);q(De,21,()=>V(k),e=>e.id,(e,t)=>{var n=sD();let r;var i=L(n),o=L(i,!0);j(i);var s=z(i),c=L(s,!0);j(s),j(n),B(()=>{r=vi(n,1,`template-item svelte-3z3jlz`,null,r,{chosen:V(u)===V(t).id}),J(n,`aria-pressed`,V(u)===V(t).id),n.disabled=V(a),G(o,V(t).name),G(c,V(t).folderName)}),H(`click`,n,()=>ue(V(t).id)),W(e,n)},e=>{var t=lD(),n=L(t),i=L(n,!0);j(n);var a=z(n),o=L(a,!0);j(a);var s=z(a),l=e=>{var t=cD(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`templates.new_folder`)]),H(`click`,t,()=>pe(`new`)),W(e,t)};K(s,e=>{V(r).folders.length||e(l)}),j(t),B((e,t)=>{G(i,e),G(o,t)},[()=>Y(V(r).folders.length?V(c)?`templates.no_results`:`templates.folder_empty`:`templates.welcome`),()=>Y(V(r).folders.length?V(c)?`templates.search_hint`:`templates.empty_hint`:`templates.start_hint`)]),W(e,t)}),j(De),j(xe);var Oe=z(xe,2),ke=L(Oe),Ae=L(ke);j(ke);var je=z(ke,2),Me=e=>{var t=dD(),n=L(t),i=L(n),o=L(i,!0);j(i);var s=z(i),c=L(s,!0);j(s),j(n);var l=z(n,2),u=L(l),d=L(u,!0);j(u);var g=z(u),v=L(g),y=L(v,!0);j(v);var b=z(v),x=L(b,!0);j(b),j(g),j(l);var S=z(l,2),w=L(S),T=L(w),E=L(T,!0);j(T);var D=z(T);ki(D);var ee=z(D),te=L(ee,!0);j(ee),j(w);var O=z(w),k=L(O),ne=L(k,!0);j(k);var re=z(k);q(re,21,()=>V(r).folders,Qr,(e,t)=>{var n=uD(),r=L(n,!0);j(n);var i={};B(()=>{G(r,V(t).name),i!==(i=V(t).id)&&(n.value=(n.__value=V(t).id)??``)}),W(e,n)}),j(re),j(O),j(S);var ae=z(S,2),oe=L(ae,!0);j(ae);var se=z(ae,2),ce=L(se);yn(ce);var le=z(ce),ue=L(le),de=L(ue,!0);j(ue);var pe=z(ue),me=e=>{$E(e,{get content(){return V(m)}})};K(pe,e=>{V(C)&&e(me)}),j(le),j(se),j(t),B((e,t,n,r,i,s,l,u,f,p)=>{G(o,e),G(c,t),G(d,n),v.disabled=V(a),G(y,r),b.disabled=i,G(x,s),G(E,l),D.disabled=V(a),J(D,`aria-invalid`,!!V(_)),G(te,V(_)),G(ne,u),re.disabled=V(a),G(oe,f),ce.disabled=V(a),G(de,p)},[()=>Y(V(f)?`templates.edit`:`templates.new_template`),()=>Y(V(A)?`templates.unsaved`:`templates.no_changes`),()=>Y(`templates.save_shortcut`),()=>Y(`common.cancel`),()=>V(a)||!V(p).trim()||!V(h),()=>Y(`templates.save_template`),()=>Y(`templates.name`),()=>Y(`templates.folder`),()=>Y(`templates.content`),()=>Y(`templates.preview`)]),Nr(`submit`,t,e=>{e.preventDefault(),fe()}),H(`click`,v,()=>ie(()=>{})),Fi(D,()=>V(p),e=>F(p,e)),Ci(re,()=>V(h),e=>F(h,e)),Fi(ce,()=>V(m),e=>F(m,e)),Wi(`open`,`toggle`,le,e=>F(C,e),()=>V(C)),W(e,t)},Ne=e=>{var t=pD(),n=R(t),r=L(n),i=L(r);j(r);var o=z(r),s=L(o,!0);j(o);var c=z(o),l=L(c),u=L(l,!0);j(l);var d=z(l),f=L(d,!0);j(d);var p=z(d),m=L(p),h=L(m,!0);j(m);var g=z(m),_=L(g),v=L(_,!0);j(_);var y=z(_),b=L(y,!0);j(y),j(g),j(p),j(c);var x=z(c),C=L(x,!0);j(x),j(n);var w=z(n,2),E=L(w),D=L(E,!0);j(E);var ee=z(E),O=L(ee,!0);j(ee),j(w);var k=z(w,2),ne=L(k),A=e=>{var t=fD(),n=L(t,!0);j(t),B(()=>G(n,V(te).content)),W(e,t)},re=e=>{$E(e,{get content(){return V(te).content}})};K(ne,e=>{V(S)?e(A):e(re,-1)}),j(k),B((e,t,n,r,o,c,p,m,g)=>{G(i,`${V(te).folderName??``} / ${e??``}`),G(s,V(te).name),l.disabled=V(a),G(u,t),d.disabled=V(a),G(f,n),G(h,r),_.disabled=V(a),G(v,o),y.disabled=V(a),G(b,c),G(C,p),G(D,m),J(ee,`aria-pressed`,V(S)),G(O,g)},[()=>Y(`templates.template`),()=>Y(`templates.use`),()=>Y(`templates.edit`),()=>Y(`templates.more`),()=>Y(`templates.duplicate`),()=>Y(`common.remove`),()=>Y(`templates.independent`),()=>Y(`templates.preview`),()=>Y(V(S)?`templates.formatted`:`templates.source`)]),H(`click`,l,()=>F(T,V(te)?.id,!0)),H(`click`,d,()=>de(V(te))),H(`click`,_,()=>de(V(te),!0)),H(`click`,y,()=>he(!1)),H(`click`,ee,()=>F(S,!V(S))),W(e,t)},Pe=e=>{var t=mD(),n=L(t),r=L(n,!0);j(n);var i=z(n),a=L(i,!0);j(i),j(t),B((e,t)=>{G(r,e),G(a,t)},[()=>Y(`templates.select_template`),()=>Y(`templates.preview_hint`)]),W(e,t)};K(je,e=>{V(d)?e(Me):V(te)?e(Ne,1):e(Pe,-1)}),j(Oe),j(t),B((e,r,o,s,c,u,d,f,p,m,h)=>{n=vi(t,1,`library-layout svelte-3z3jlz`,null,n,{"show-detail":V(w)}),J(i,`aria-label`,e),G(g,r),b.disabled=V(a),G(E,o),ne=vi(O,1,`folder-item svelte-3z3jlz`,null,ne,{chosen:!V(l)}),J(O,`aria-pressed`,!V(l)),O.disabled=V(a),G(re,s),G(oe,V(D).length),G(ge,c),J(xe,`aria-label`,u),G(Ce,d),J(we,`placeholder`,f),G(Ee,p),J(Oe,`aria-label`,m),ke.disabled=V(a),G(Ae,`← ${h??``}`)},[()=>Y(`templates.folders`),()=>Y(`templates.folders`),()=>Y(`templates.add_folder`),()=>Y(`templates.all`),()=>Y(`templates.folder_hint`),()=>Y(`templates.menu`),()=>Y(`templates.search`),()=>Y(`templates.search_placeholder`),()=>Y(`templates.result_count`,{count:String(V(k).length)}),()=>Y(`templates.detail`),()=>Y(`templates.back_list`)]),H(`click`,b,()=>pe(`new`)),H(`click`,O,()=>le(``)),Fi(we,()=>V(c),e=>F(c,e)),H(`click`,ke,()=>ie(()=>{F(w,!1)})),W(e,t)};K(Pe,e=>{V(i)?e(Ie,-1):e(Fe)}),j(ye);var Le=z(ye,2),Re=e=>{Wa(e,{open:!0,get initialTemplateId(){return V(T)},onclose:()=>F(T,void 0),onsuccess:e=>{window.location.href=`/?doc=`+encodeURIComponent(e)}})};K(Le,e=>{V(T)&&e(Re)}),B((e,t,n)=>{J(ye,`aria-busy`,V(a)),G(Ce,e),G(Te,t),Ee.disabled=V(a)||!V(i)||!V(r).folders.length,G(De,` ${n??``}`)},[()=>Y(`templates.library`),()=>Y(`templates.library_subtitle`),()=>Y(`templates.new_template`)]),H(`click`,Ee,()=>de()),W(e,_e),Je()}Pr([`click`]);var vD=U(`<div class="app-shell templates-shell svelte-j6d35n"><!> <!></div>`);function yD(e,t){qe(t,!1),Ji(async()=>{try{let e=await fetch(`/api/config`);e.ok&&await Sa((await e.json()).language||`en`)}catch{}}),Gi();var n=vD(),r=L(n);{let e=bt(()=>Y(`templates.library`));Xo(r,{get title(){return V(e)},subtitle:``})}_D(z(r,2),{}),j(n),W(e,n),Je()}var bD=I({tasks:[],notes:[],links:[]}),xD=!1,SD=null;async function CD(){try{let e=await fetch(`/api/survival-kit`);if(e.ok){let t=await e.json();bD.tasks=Array.isArray(t.tasks)?t.tasks:[],bD.notes=Array.isArray(t.notes)?t.notes:[],bD.links=Array.isArray(t.links)?t.links:[]}}catch{}finally{xD=!0}}async function wD(){try{await fetch(`/api/survival-kit`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({tasks:bD.tasks,notes:bD.notes,links:bD.links})})}catch{}}function TD(){xD&&(SD&&clearTimeout(SD),SD=setTimeout(()=>{SD=null,wD()},400))}var ED=U(`<button type="button"> </button>`),DD=U(`<p class="sk-empty svelte-lo2xyl"> </p>`),OD=U(`<div><button type="button" aria-label="toggle"></button> <span class="sk-task-text svelte-lo2xyl"> </span> <span class="sk-task-tag svelte-lo2xyl"> </span> <button type="button" class="sk-task-del svelte-lo2xyl">✕</button></div>`),kD=U(`<div class="sk-panel-head"><h2 class="sk-panel-title"> <span class="sk-accent">.</span></h2> <p class="sk-panel-sub"> </p></div> <div class="sk-add-bar svelte-lo2xyl"><input type="text" class="svelte-lo2xyl"/> <select class="svelte-lo2xyl"><option> </option><option> </option><option> </option></select> <button type="button" class="sk-add-btn svelte-lo2xyl">+</button></div> <div class="sk-filters svelte-lo2xyl"></div> <div class="sk-tasks svelte-lo2xyl"><!></div>`,1);function AD(e,t){qe(t,!0);let n=P(``),r=P(`normal`),i=P(`all`),a=[{key:`all`,label:()=>Y(`survival.tasks_filter_all`)},{key:`todo`,label:()=>Y(`survival.tasks_filter_todo`)},{key:`done`,label:()=>Y(`survival.tasks_filter_done`)},{key:`urgent`,label:()=>Y(`survival.tasks_filter_urgent`)},{key:`normal`,label:()=>Y(`survival.tasks_filter_normal`)},{key:`later`,label:()=>Y(`survival.tasks_filter_later`)}];function o(e){return Y(`survival.tasks_priority_${e}`)}let s=N(()=>bD.tasks.filter(e=>V(i)===`todo`?!e.done:V(i)===`done`?e.done:V(i)===`urgent`||V(i)===`normal`||V(i)===`later`?e.priority===V(i):!0));function c(){let e=V(n).trim();e&&(bD.tasks.unshift({id:Date.now(),text:e,priority:V(r),done:!1}),F(n,``),TD())}function l(e){let t=bD.tasks.find(t=>t.id===e);t&&(t.done=!t.done),TD()}function u(e){bD.tasks=bD.tasks.filter(t=>t.id!==e),TD()}var d=kD(),f=R(d),p=L(f),m=L(p,!0);Ie(),j(p);var h=z(p,2),g=L(h,!0);j(h),j(f);var _=z(f,2),v=L(_);ki(v);var y=z(v,2),b=L(y),x=L(b,!0);j(b),b.value=b.__value=`normal`;var S=z(b),C=L(S,!0);j(S),S.value=S.__value=`urgent`;var w=z(S),T=L(w,!0);j(w),w.value=w.__value=`later`,j(y);var E=z(y,2);j(_);var D=z(_,2);q(D,21,()=>a,Qr,(e,t)=>{var n=ED();let r;var a=L(n,!0);j(n),B(e=>{r=vi(n,1,`svelte-lo2xyl`,null,r,{active:V(i)===V(t).key}),G(a,e)},[()=>V(t).label()]),H(`click`,n,()=>F(i,V(t).key,!0)),W(e,n)}),j(D);var ee=z(D,2),te=L(ee),O=e=>{var t=DD(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`survival.tasks_empty`)]),W(e,t)},k=e=>{var t=Wr();q(R(t),17,()=>V(s),e=>e.id,(e,t)=>{var n=OD();let r;var i=L(n);let a;var s=z(i,2),c=L(s,!0);j(s);var d=z(s,2),f=L(d,!0);j(d);var p=z(d,2);j(n),B((e,o)=>{r=vi(n,1,`sk-task sk-task--${V(t).priority??``}`,`svelte-lo2xyl`,r,{done:V(t).done}),a=vi(i,1,`sk-check svelte-lo2xyl`,null,a,{checked:V(t).done}),G(c,V(t).text),G(f,e),J(p,`title`,o)},[()=>o(V(t).priority),()=>Y(`survival.tasks_delete_title`)]),H(`click`,i,()=>l(V(t).id)),H(`click`,p,()=>u(V(t).id)),W(e,n)}),W(e,t)};K(te,e=>{V(s).length===0?e(O):e(k,-1)}),j(ee),B((e,t,n,r,i,a)=>{G(m,e),G(g,t),J(v,`placeholder`,n),G(x,r),G(C,i),G(T,a)},[()=>Y(`survival.tasks_title`),()=>Y(`survival.tasks_subtitle`),()=>Y(`survival.tasks_input_placeholder`),()=>Y(`survival.tasks_priority_normal`),()=>Y(`survival.tasks_priority_urgent`),()=>Y(`survival.tasks_priority_later`)]),H(`keydown`,v,e=>e.key===`Enter`&&c()),Fi(v,()=>V(n),e=>F(n,e)),Ci(y,()=>V(r),e=>F(r,e)),H(`click`,E,c),W(e,d),Je()}Pr([`keydown`,`click`]);var jD=[`t-green`,`t-violet`,`t-amber`,`t-sky`,`t-rose`,`t-teal`],MD=U(`<div class="sk-modal-backdrop svelte-1rcj86" role="presentation"><div class="sk-modal svelte-1rcj86" role="dialog" aria-modal="true"><h3 class="sk-modal-title svelte-1rcj86"> </h3> <div class="sk-modal-body svelte-1rcj86"><!></div> <div class="sk-modal-actions svelte-1rcj86"><button type="button" class="sk-btn svelte-1rcj86"> </button> <button type="button"> </button></div></div></div>`);function ND(e,t){qe(t,!0);let n=qi(t,`open`,3,!1),r=qi(t,`title`,3,``),i=qi(t,`confirmLabel`,19,()=>Y(`common.save`)),a=qi(t,`danger`,3,!1);function o(e){e.target===e.currentTarget&&t.onClose()}function s(e){e.key===`Escape`&&t.onClose()}var c=Wr(),l=R(c),u=e=>{var n=MD(),c=L(n),l=L(c),u=L(l,!0);j(l);var d=z(l,2);ci(L(d),()=>t.children),j(d);var f=z(d,2),p=L(f),m=L(p,!0);j(p);var h=z(p,2);let g;var _=L(h,!0);j(h),j(f),j(c),j(n),B(e=>{G(u,r()),G(m,e),g=vi(h,1,`sk-btn sk-btn--primary svelte-1rcj86`,null,g,{"sk-btn--danger":a()}),G(_,i())},[()=>Y(`common.cancel`)]),H(`click`,n,o),H(`keydown`,n,s),H(`click`,p,function(...e){t.onClose?.apply(this,e)}),H(`click`,h,function(...e){t.onConfirm?.apply(this,e)}),W(e,n)};K(l,e=>{n()&&e(u)}),W(e,c),Je()}Pr([`click`,`keydown`]);var PD=U(`<p class="sk-empty svelte-hpbata"> </p>`),FD=U(`<strong> </strong>`),ID=U(`<p> </p>`),LD=U(`<div class="sk-pre-wrap svelte-hpbata"><pre> </pre> <button type="button" class="sk-copy svelte-hpbata"> </button></div>`),RD=U(`<li> </li>`),zD=U(`<ul></ul>`),BD=U(`<th> </th>`),VD=U(`<td> </td>`),HD=U(`<tr></tr>`),UD=U(`<div class="sk-table-wrap svelte-hpbata"><table><thead><tr></tr></thead><tbody></tbody></table></div>`),WD=U(`<div class="sk-bloc svelte-hpbata"><div class="sk-bloc-content svelte-hpbata"><!></div> <div class="sk-bloc-actions svelte-hpbata"><button type="button" class="sk-mini svelte-hpbata">✎</button> <button type="button" class="sk-mini sk-mini--del svelte-hpbata">✕</button></div></div>`),GD=U(`<div><div class="sk-note-head svelte-hpbata"><h3 class="svelte-hpbata"> </h3> <div class="sk-note-actions svelte-hpbata"><button type="button" class="sk-mini svelte-hpbata">✎</button> <button type="button" class="sk-mini sk-mini--del svelte-hpbata">✕</button></div> <button type="button" class="sk-toggle svelte-hpbata" aria-label="toggle"><svg viewBox="0 0 10 6" width="10" height="6"><path d="M1 1 L5 5 L9 1" stroke="currentColor" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div> <div class="sk-note-body svelte-hpbata"><!> <div class="sk-note-foot svelte-hpbata"><button type="button" class="sk-add-bloc svelte-hpbata"> </button></div></div></div>`),KD=U(`<option> </option>`),qD=U(`<label for="sk-note-titre"> </label> <input id="sk-note-titre" type="text"/> <label for="sk-note-color"> </label> <select id="sk-note-color"></select>`,1),JD=U(`<input id="sk-bloc-content" type="text"/>`),YD=U(`<textarea id="sk-bloc-content" rows="6"></textarea>`),XD=U(`<label for="sk-bloc-type"> </label> <select id="sk-bloc-type"><option> </option><option> </option><option> </option><option> </option><option> </option></select> <label for="sk-bloc-content"> </label> <!>`,1),ZD=U(`<div class="sk-panel-head"><h2 class="sk-panel-title"> <span class="sk-accent">.</span></h2> <p class="sk-panel-sub"> </p></div> <div class="sk-toolbar svelte-hpbata"><button type="button" class="sk-tool svelte-hpbata"> </button> <button type="button" class="sk-tool svelte-hpbata"> </button> <button type="button" class="sk-tool sk-tool--add svelte-hpbata"> </button></div> <div><!> <!></div> <!> <!>`,1);function QD(e,t){qe(t,!0);let n=P(!1),r=P(I({})),i=P(null),a=P(!1),o=P(-1),s=P(``),c=P(`t-green`),l=P(!1),u=P(-1),d=P(-1),f=P(`p`),p=P(``),m={"t-green":`survival.color_green`,"t-violet":`survival.color_violet`,"t-amber":`survival.color_amber`,"t-sky":`survival.color_sky`,"t-rose":`survival.color_rose`,"t-teal":`survival.color_teal`},h=N(()=>bD.notes.length>0&&bD.notes.every(e=>V(r)[e.id]));function g(e){V(r)[e]=!V(r)[e]}function _(){if(V(h))F(r,{},!0);else{let e={};bD.notes.forEach(t=>e[t.id]=!0),F(r,e,!0)}}function v(){F(o,-1),F(s,``),F(c,`t-green`),F(a,!0)}function y(e){F(o,e,!0),F(s,bD.notes[e].titre,!0),F(c,bD.notes[e].theme,!0),F(a,!0)}function b(){let e=V(s).trim();if(e){if(V(o)===-1){let t=Date.now();bD.notes.push({id:t,theme:V(c),titre:e,blocs:[]}),V(r)[t]=!0}else bD.notes[V(o)].titre=e,bD.notes[V(o)].theme=V(c);TD(),F(a,!1)}}async function x(e){await t.confirmDelete(Y(`survival.confirm_del_note_title`),Y(`survival.confirm_del_note_msg`))&&(bD.notes.splice(e,1),TD())}function S(e){return e.type===`ul`?e.items.join(`
|
|
325
325
|
`):e.type===`table`?[e.headers.join(` | `),...e.rows.map(e=>e.join(` | `))].join(`
|
|
326
|
-
`):e.content}function C(e){F(u,e,!0),F(d,-1),F(f,`p`),F(p,``),F(l,!0)}function w(e,t){F(u,e,!0),F(d,t,!0);let n=
|
|
326
|
+
`):e.content}function C(e){F(u,e,!0),F(d,-1),F(f,`p`),F(p,``),F(l,!0)}function w(e,t){F(u,e,!0),F(d,t,!0);let n=bD.notes[e].blocs[t];F(f,n.type,!0),F(p,S(n),!0),F(l,!0)}function T(){let e=V(p);if(!e.trim())return null;if(V(f)===`ul`){let t=e.split(`
|
|
327
327
|
`).map(e=>e.trim()).filter(Boolean);return t.length?{type:`ul`,items:t}:null}if(V(f)===`table`){let t=e.split(`
|
|
328
|
-
`).map(e=>e.trim()).filter(Boolean);return t.length?{type:`table`,headers:t[0].split(`|`).map(e=>e.trim()),rows:t.slice(1).map(e=>e.split(`|`).map(e=>e.trim()))}:null}return{type:V(f),content:e}}function E(){let e=T();e&&(V(d)===-1?mD.notes[V(u)].blocs.push(e):mD.notes[V(u)].blocs[V(d)]=e,yD(),F(l,!1))}async function D(e,n){await t.confirmDelete(Y(`survival.confirm_del_bloc_title`),Y(`survival.irreversible`))&&(mD.notes[e].blocs.splice(n,1),yD())}async function ee(e,t){try{await navigator.clipboard.writeText(e),F(i,t,!0),setTimeout(()=>F(i,V(i)===t?null:V(i),!0),1500)}catch{}}let te=N(()=>V(f)===`ul`?Y(`survival.modal_bloc_placeholder_ul`):V(f)===`pre`?Y(`survival.modal_bloc_placeholder_pre`):V(f)===`table`?Y(`survival.modal_bloc_placeholder_table`):V(f)===`b`?Y(`survival.modal_bloc_placeholder_b`):Y(`survival.modal_bloc_placeholder_p`));var O=GD(),k=R(O),ne=L(k),A=L(ne,!0);Ie(),j(ne);var re=z(ne,2),ie=L(re,!0);j(re),j(k);var ae=z(k,2),oe=L(ae),se=L(oe,!0);j(oe);var ce=z(oe,2),le=L(ce,!0);j(ce);var ue=z(ce,2),de=L(ue,!0);j(ue),j(ae);var fe=z(ae,2);let pe;var me=L(fe),he=e=>{var t=OD(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`survival.notes_empty`)]),W(e,t)};K(me,e=>{mD.notes.length===0&&e(he)}),q(z(me,2),19,()=>mD.notes,e=>e.id,(e,t,n)=>{let a=N(()=>!V(r)[V(t).id]);var o=zD();let s;var c=L(o),l=L(c),u=L(l,!0);j(l);var d=z(l,2),f=L(d),p=z(f,2);j(d);var m=z(d,2);j(c);var h=z(c,2),_=L(h);q(_,17,()=>V(t).blocs,Qr,(e,r,a)=>{var o=RD(),s=L(o),c=L(s),l=e=>{var t=kD(),n=L(t,!0);j(t),B(()=>G(n,V(r).content)),W(e,t)},u=e=>{var t=AD(),n=L(t,!0);j(t),B(()=>G(n,V(r).content)),W(e,t)},d=e=>{let n=N(()=>`${V(t).id}-${a}`);var o=jD(),s=L(o),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(o),B(e=>{G(c,V(r).content),G(u,e)},[()=>V(i)===V(n)?Y(`survival.notes_btn_copied`):Y(`survival.notes_btn_copy`)]),H(`click`,l,()=>ee(V(r).content,V(n))),W(e,o)},f=e=>{var t=ND();q(t,21,()=>V(r).items,Qr,(e,t)=>{var n=MD(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(t),W(e,t)},p=e=>{var t=LD(),n=L(t),i=L(n),a=L(i);q(a,21,()=>V(r).headers,Qr,(e,t)=>{var n=PD(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(a),j(i);var o=z(i);q(o,21,()=>V(r).rows,Qr,(e,t)=>{var n=ID();q(n,21,()=>V(t),Qr,(e,t)=>{var n=FD(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(n),W(e,n)}),j(o),j(n),j(t),W(e,t)};K(c,e=>{V(r).type===`b`?e(l):V(r).type===`p`?e(u,1):V(r).type===`pre`?e(d,2):V(r).type===`ul`?e(f,3):V(r).type===`table`&&e(p,4)}),j(s);var m=z(s,2),h=L(m),g=z(h,2);j(m),j(o),H(`click`,h,()=>w(V(n),a)),H(`click`,g,()=>D(V(n),a)),W(e,o)});var v=z(_,2),b=L(v),S=L(b,!0);j(b),j(v),j(h),j(o),B(e=>{s=vi(o,1,`sk-note ${V(t).theme??``}`,`svelte-hpbata`,s,{collapsed:V(a)}),G(u,V(t).titre),G(S,e)},[()=>Y(`survival.notes_btn_add_bloc`)]),H(`click`,f,()=>y(V(n))),H(`click`,p,()=>x(V(n))),H(`click`,m,()=>g(V(t).id)),H(`click`,b,()=>C(V(n))),W(e,o)}),j(fe);var ge=z(fe,2);{let e=N(()=>V(o)===-1?Y(`survival.modal_note_title`):Y(`survival.modal_edit_note_title`)),t=N(()=>V(o)===-1?Y(`common.create`):Y(`common.save`));DD(ge,{get open(){return V(a)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:b,onClose:()=>F(a,!1),children:(e,t)=>{var n=VD(),r=R(n),i=L(r,!0);j(r);var a=z(r,2);ki(a);var o=z(a,2),l=L(o,!0);j(o);var u=z(o,2);q(u,21,()=>TD,Qr,(e,t)=>{var n=BD(),r=L(n,!0);j(n);var i={};B(e=>{G(r,e),i!==(i=V(t))&&(n.value=(n.__value=V(t))??``)},[()=>Y(m[V(t)])]),W(e,n)}),j(u),B((e,t,n)=>{G(i,e),J(a,`placeholder`,t),G(l,n)},[()=>Y(`survival.modal_note_label_title`),()=>Y(`survival.modal_note_placeholder`),()=>Y(`survival.modal_label_color`)]),H(`keydown`,a,e=>e.key===`Enter`&&b()),Fi(a,()=>V(s),e=>F(s,e)),Ci(u,()=>V(c),e=>F(c,e)),W(e,n)},$$slots:{default:!0}})}var _e=z(ge,2);{let e=N(()=>V(d)===-1?Y(`survival.modal_bloc_new`):Y(`survival.modal_bloc_edit`)),t=N(()=>Y(`common.save`));DD(_e,{get open(){return V(l)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:E,onClose:()=>F(l,!1),children:(e,t)=>{var n=WD(),r=R(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o),o.value=o.__value=`b`;var c=z(o),l=L(c,!0);j(c),c.value=c.__value=`p`;var u=z(c),d=L(u,!0);j(u),u.value=u.__value=`pre`;var m=z(u),h=L(m,!0);j(m),m.value=m.__value=`ul`;var g=z(m),_=L(g,!0);j(g),g.value=g.__value=`table`,j(a);var v=z(a,2),y=L(v,!0);j(v);var b=z(v,2),x=e=>{var t=HD();ki(t),B(()=>J(t,`placeholder`,V(te))),H(`keydown`,t,e=>e.key===`Enter`&&E()),Fi(t,()=>V(p),e=>F(p,e)),W(e,t)},S=e=>{var t=UD();yn(t),B(()=>J(t,`placeholder`,V(te))),Fi(t,()=>V(p),e=>F(p,e)),W(e,t)};K(b,e=>{V(f)===`b`?e(x):e(S,-1)}),B((e,t,n,r,a,o,c)=>{G(i,e),G(s,t),G(l,n),G(d,r),G(h,a),G(_,o),G(y,c)},[()=>Y(`survival.modal_bloc_label_type`),()=>Y(`survival.modal_bloc_type_b`),()=>Y(`survival.modal_bloc_type_p`),()=>Y(`survival.modal_bloc_type_pre`),()=>Y(`survival.modal_bloc_type_ul`),()=>Y(`survival.modal_bloc_type_table`),()=>Y(`survival.modal_bloc_label_content`)]),Ci(a,()=>V(f),e=>F(f,e)),W(e,n)},$$slots:{default:!0}})}B((e,t,r,i,a)=>{G(A,e),G(ie,t),G(se,r),G(le,i),G(de,a),pe=vi(fe,1,`sk-notes svelte-hpbata`,null,pe,{"edit-mode":V(n)})},[()=>Y(`survival.notes_title`),()=>Y(`survival.notes_subtitle`),()=>V(n)?Y(`survival.btn_read_mode`):Y(`survival.btn_edit_mode`),()=>V(h)?Y(`survival.btn_collapse_all`):Y(`survival.btn_expand_all`),()=>Y(`survival.notes_btn_add`)]),H(`click`,oe,()=>F(n,!V(n))),H(`click`,ce,_),H(`click`,ue,v),W(e,O),Je()}Pr([`click`,`keydown`]);var qD=U(`<p class="sk-empty svelte-1j811iq"> </p>`),JD=U(`<span class="sk-link-desc svelte-1j811iq"> </span>`),YD=U(`<a target="_blank" rel="noopener" class="sk-link svelte-1j811iq"><span class="sk-link-text svelte-1j811iq"><span class="sk-link-name svelte-1j811iq"> </span><!></span> <span class="sk-arrow svelte-1j811iq">↗</span> <span class="sk-link-actions svelte-1j811iq"><button type="button" class="sk-mini svelte-1j811iq">✎</button> <button type="button" class="sk-mini sk-mini--del svelte-1j811iq">✕</button></span></a>`),XD=U(`<section><div class="sk-cat-head svelte-1j811iq"><h3 class="svelte-1j811iq"> </h3> <div class="sk-cat-actions svelte-1j811iq"><button type="button" class="sk-mini svelte-1j811iq">+</button> <button type="button" class="sk-mini sk-mini--del svelte-1j811iq">✕</button></div> <button type="button" class="sk-toggle svelte-1j811iq" aria-label="toggle"><svg viewBox="0 0 10 6" width="10" height="6"><path d="M1 1 L5 5 L9 1" stroke="currentColor" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div> <div class="sk-links svelte-1j811iq"></div></section>`),ZD=U(`<option> </option>`),QD=U(`<label for="sk-cat-name"> </label> <input id="sk-cat-name" type="text"/> <label for="sk-cat-color"> </label> <select id="sk-cat-color"></select>`,1),$D=U(`<label for="sk-link-nom"> </label> <input id="sk-link-nom" type="text"/> <label for="sk-link-desc"> </label> <input id="sk-link-desc" type="text"/> <label for="sk-link-url"> </label> <input id="sk-link-url" type="text" placeholder="https://…"/>`,1),eO=U(`<div class="sk-panel-head"><h2 class="sk-panel-title"> <span class="sk-accent">.</span></h2> <p class="sk-panel-sub"> </p></div> <div class="sk-toolbar svelte-1j811iq"><button type="button" class="sk-tool svelte-1j811iq"> </button> <button type="button" class="sk-tool svelte-1j811iq"> </button> <button type="button" class="sk-tool sk-tool--add svelte-1j811iq"> </button></div> <div><!> <!></div> <!> <!>`,1);function tO(e,t){qe(t,!0);let n=P(!1),r=P(I({})),i=P(!1),a=P(``),o=P(`t-green`),s=P(!1),c=P(-1),l=P(-1),u=P(``),d=P(``),f=P(``),p={"t-green":`survival.color_green`,"t-violet":`survival.color_violet`,"t-amber":`survival.color_amber`,"t-sky":`survival.color_sky`,"t-rose":`survival.color_rose`,"t-teal":`survival.color_teal`},m=N(()=>mD.links.length>0&&mD.links.every(e=>V(r)[e.titre]));function h(e){V(r)[e]=!V(r)[e]}function g(){if(V(m))F(r,{},!0);else{let e={};mD.links.forEach(t=>e[t.titre]=!0),F(r,e,!0)}}function _(){F(a,``),F(o,`t-green`),F(i,!0)}function v(){let e=V(a).trim();e&&(mD.links.push({theme:V(o),titre:e,liens:[]}),yD(),F(i,!1))}async function y(e){mD.links[e],await t.confirmDelete(Y(`survival.confirm_del_cat_title`),Y(`survival.confirm_del_cat_msg`))&&(mD.links.splice(e,1),yD())}function b(e){F(c,e,!0),F(l,-1),F(u,``),F(d,``),F(f,``),F(s,!0)}function x(e,t,n){e.preventDefault();let r=mD.links[t].liens[n];F(c,t,!0),F(l,n,!0),F(u,r.nom,!0),F(d,r.desc,!0),F(f,r.url,!0),F(s,!0)}function S(){let e=V(u).trim(),t=V(f).trim();if(!e||!t)return;let n={nom:e,desc:V(d).trim(),url:t};V(l)===-1?mD.links[V(c)].liens.push(n):mD.links[V(c)].liens[V(l)]=n,yD(),F(s,!1)}async function C(e,n,r){e.preventDefault(),await t.confirmDelete(Y(`survival.confirm_del_link_title`),Y(`survival.irreversible`))&&(mD.links[n].liens.splice(r,1),yD())}var w=eO(),T=R(w),E=L(T),D=L(E,!0);Ie(),j(E);var ee=z(E,2),te=L(ee,!0);j(ee),j(T);var O=z(T,2),k=L(O),ne=L(k,!0);j(k);var A=z(k,2),re=L(A,!0);j(A);var ie=z(A,2),ae=L(ie,!0);j(ie),j(O);var oe=z(O,2);let se;var ce=L(oe),le=e=>{var t=qD(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`survival.links_empty`)]),W(e,t)};K(ce,e=>{mD.links.length===0&&e(le)}),q(z(ce,2),19,()=>mD.links,(e,t)=>e.titre+t,(e,t,n)=>{let i=N(()=>!V(r)[V(t).titre]);var a=XD();let o;var s=L(a),c=L(s),l=L(c,!0);j(c);var u=z(c,2),d=L(u),f=z(d,2);j(u);var p=z(u,2);j(s);var m=z(s,2);q(m,21,()=>V(t).liens,Qr,(e,t,r)=>{var i=YD(),a=L(i),o=L(a),s=L(o,!0);j(o);var c=z(o),l=e=>{var n=JD(),r=L(n);j(n),B(()=>G(r,`— ${V(t).desc??``}`)),W(e,n)};K(c,e=>{V(t).desc&&e(l)}),j(a);var u=z(a,4),d=L(u),f=z(d,2);j(u),j(i),B((e,n)=>{J(i,`href`,V(t).url),G(s,V(t).nom),J(d,`title`,e),J(f,`title`,n)},[()=>Y(`survival.links_edit_link_title`),()=>Y(`survival.links_del_link_title`)]),H(`click`,d,e=>x(e,V(n),r)),H(`click`,f,e=>C(e,V(n),r)),W(e,i)}),j(m),j(a),B((e,n)=>{o=vi(a,1,`sk-cat ${V(t).theme??``}`,`svelte-1j811iq`,o,{collapsed:V(i)}),G(l,V(t).titre),J(d,`title`,e),J(f,`title`,n)},[()=>Y(`survival.links_add_link_title`),()=>Y(`survival.links_del_cat_title`)]),H(`click`,d,()=>b(V(n))),H(`click`,f,()=>y(V(n))),H(`click`,p,()=>h(V(t).titre)),W(e,a)}),j(oe);var ue=z(oe,2);{let e=N(()=>Y(`survival.modal_cat_title`)),t=N(()=>Y(`common.add`));DD(ue,{get open(){return V(i)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:v,onClose:()=>F(i,!1),children:(e,t)=>{var n=QD(),r=R(n),i=L(r,!0);j(r);var s=z(r,2);ki(s);var c=z(s,2),l=L(c,!0);j(c);var u=z(c,2);q(u,21,()=>TD,Qr,(e,t)=>{var n=ZD(),r=L(n,!0);j(n);var i={};B(e=>{G(r,e),i!==(i=V(t))&&(n.value=(n.__value=V(t))??``)},[()=>Y(p[V(t)])]),W(e,n)}),j(u),B((e,t,n)=>{G(i,e),J(s,`placeholder`,t),G(l,n)},[()=>Y(`survival.modal_cat_label_name`),()=>Y(`survival.modal_cat_placeholder_name`),()=>Y(`survival.modal_label_color`)]),H(`keydown`,s,e=>e.key===`Enter`&&v()),Fi(s,()=>V(a),e=>F(a,e)),Ci(u,()=>V(o),e=>F(o,e)),W(e,n)},$$slots:{default:!0}})}var de=z(ue,2);{let e=N(()=>V(l)===-1?Y(`survival.modal_link_title`):Y(`survival.modal_edit_link_title`)),t=N(()=>V(l)===-1?Y(`common.add`):Y(`common.save`));DD(de,{get open(){return V(s)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:S,onClose:()=>F(s,!1),children:(e,t)=>{var n=$D(),r=R(n),i=L(r,!0);j(r);var a=z(r,2);ki(a);var o=z(a,2),s=L(o,!0);j(o);var c=z(o,2);ki(c);var l=z(c,2),p=L(l,!0);j(l);var m=z(l,2);ki(m),B((e,t,n,r,o)=>{G(i,e),J(a,`placeholder`,t),G(s,n),J(c,`placeholder`,r),G(p,o)},[()=>Y(`survival.modal_link_label_name`),()=>Y(`survival.modal_link_placeholder_name`),()=>Y(`survival.modal_link_label_desc`),()=>Y(`survival.modal_link_placeholder_desc`),()=>Y(`survival.modal_link_label_url`)]),Fi(a,()=>V(u),e=>F(u,e)),Fi(c,()=>V(d),e=>F(d,e)),H(`keydown`,m,e=>e.key===`Enter`&&S()),Fi(m,()=>V(f),e=>F(f,e)),W(e,n)},$$slots:{default:!0}})}B((e,t,r,i,a)=>{G(D,e),G(te,t),G(ne,r),G(re,i),G(ae,a),se=vi(oe,1,`sk-cats svelte-1j811iq`,null,se,{"edit-mode":V(n)})},[()=>Y(`survival.links_title`),()=>Y(`survival.links_subtitle`),()=>V(n)?Y(`survival.btn_read_mode`):Y(`survival.btn_edit_mode`),()=>V(m)?Y(`survival.btn_collapse_all`):Y(`survival.btn_expand_all`),()=>Y(`survival.links_btn_add_cat`)]),H(`click`,k,()=>F(n,!V(n))),H(`click`,A,g),H(`click`,ie,_),W(e,w),Je()}Pr([`click`,`keydown`]);var nO=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),rO=U(`<p class="sk-loading svelte-ha6eja"> </p>`),iO=U(`<div class="sk-grid svelte-ha6eja"><section class="sk-col svelte-ha6eja"><div class="sk-inner svelte-ha6eja"><!></div></section> <section class="sk-col svelte-ha6eja"><div class="sk-inner svelte-ha6eja"><!></div></section> <section class="sk-col svelte-ha6eja"><div class="sk-inner svelte-ha6eja"><!></div></section></div>`),aO=U(`<!> <div class="app-shell sk-root svelte-ha6eja"><!> <!></div> <!>`,1);function oO(e,t){qe(t,!0);let n=P(null),r=P(!1),i=P(!1),a=P(!1);async function o(e,t){return V(n).show({title:e,message:t,confirmLabel:Y(`survival.irreversible_delete`),cancelLabel:Y(`common.cancel`),danger:!0})}function s(e){F(i,e,!0),document.documentElement.classList.toggle(`dark`,e)}function c(){let e=!1;try{let t=localStorage.getItem(`ld-dark`);e=t===null?window.matchMedia(`(prefers-color-scheme: dark)`).matches:t===`true`}catch{}s(e)}function l(){s(!V(i));try{localStorage.setItem(`ld-dark`,String(V(i)))}catch{}}Ji(async()=>{c();try{await Sa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}await _D(),F(r,!0)});var u=aO(),d=R(u);Ui(Xd(d,{}),e=>F(n,e,!0),()=>V(n));var f=z(d,2),p=L(f);{let e=e=>{var t=nO(),n=R(t),r=z(n,2),o=L(r,!0);j(r),B((e,t)=>{J(n,`title`,e),J(n,`aria-label`,t),G(o,V(i)?`☀`:`☾`)},[()=>Y(`nav.word_cloud`),()=>Y(`nav.word_cloud`)]),H(`click`,n,()=>F(a,!0)),H(`click`,r,l),W(e,t)},t=N(()=>Y(`survival.title`)),n=N(()=>Y(`survival.subtitle`));Xo(p,{get title(){return V(t)},get subtitle(){return V(n)},actions:e,$$slots:{actions:!0}})}var m=z(p,2),h=e=>{var t=rO(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},g=e=>{var t=iO(),n=L(t),r=L(n);wD(L(r),{}),j(r),j(n);var i=z(n,2),a=L(i);KD(L(a),{confirmDelete:o}),j(a),j(i);var s=z(i,2),c=L(s);tO(L(c),{confirmDelete:o}),j(c),j(s),j(t),W(e,t)};K(m,e=>{V(r)?e(g,-1):e(h)}),j(f),Kw(z(f,2),{get open(){return V(a)},onclose:()=>F(a,!1)}),W(e,u),Je()}Pr([`click`]);var sO=`git-integration-config`,cO=`git-integration-status`,lO=`git-integration-save`,uO=`/admin#git-integration`,dO=120*1e3,fO=!1,pO=!1;function mO(e){let t=Date.parse(e);return Number.isFinite(t)&&Date.now()-t<dO}function hO(e){let t=e.toLowerCase();return t.includes(`cannot lock ref 'head'`)&&t.includes(`but expected`)?`un autre commit a modifié HEAD pendant l'autocommit. Réessayez l'enregistrement.`:e}async function gO(){if(!fO){fO=!0;try{let e=await fetch(`/api/git/status`,{cache:`no-store`});if(!e.ok)return;let t=await e.json();if(t.mode===`unconfigured`){bo(`Veuillez configurer l'intégration Git dans la page Admin.`,`error`,600*1e3,{id:sO,href:uO,linkLabel:`Admin`}),uo(cO),uo(lO);return}if(uo(sO),t.mode===`disabled`){uo(cO),uo(lO);return}if(!t.ok){bo(`Intégration Git : ${t.message}`,`error`,600*1e3,{id:cO,href:uO,linkLabel:`Admin`});return}if(t.dirtyOutsideDocsCount>0){let e=t.docsFolder?.trim()||`docsFolder`;bo(`Git : ${t.dirtyOutsideDocsCount} changement(s) hors ${e} seront ignorés par Living Documentation.`,`error`,600*1e3,cO)}else uo(cO);let n=t.lastSave;n&&mO(n.timestamp)&&(n.error||n.warning)?bo(`Git : ${hO(n.error||n.warning||``)}`,`error`,600*1e3,{id:lO,href:uO,linkLabel:`Admin`}):uo(lO)}catch{}finally{fO=!1}}}function _O(){if(pO)return;pO=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{let r=await e(t,n),i=typeof t==`string`?t:t instanceof URL?t.toString():t.url;return(n?.method||(t instanceof Request?t.method:`GET`)).toUpperCase()!==`GET`&&!i.includes(`/api/git/`)&&(i.startsWith(`/api/`)||i.startsWith(`/mcp`)||i.startsWith(window.location.origin))&&window.setTimeout(()=>void gO(),80),r}}var vO=U(`<p style="padding:2rem"> </p>`);function yO(e,t){qe(t,!0);function n(e){return e.length>1?e.replace(/\/+$/,``):e}let r=new Set([`/`,`/admin`,`/workspace`,`/blueprint`,`/diagram`,`/shape-editor`,`/context`,`/files`,`/survival-kit`,`/templates`,`/graph`]),i=window.location.pathname+window.location.search+window.location.hash,a=P(I(n(window.location.pathname)));async function o(e){let t=new URL(e,window.location.href),r=n(t.pathname),o=`${r}${t.search}${t.hash}`;if(o===`${window.location.pathname}${window.location.search}${window.location.hash}`){vo();return}await Vo()&&(history.pushState(null,``,o),i=o,F(a,r,!0),vo(),gO(),window.dispatchEvent(new PopStateEvent(`popstate`)))}function s(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;if(!(t instanceof HTMLAnchorElement)||t.target||t.hasAttribute(`download`))return;let i=new URL(t.href,window.location.href);if(i.origin!==window.location.origin)return;let a=n(i.pathname);r.has(a)&&(e.preventDefault(),o(`${a}${i.search}${i.hash}`))}Ji(()=>(vo(),_O(),gO(),document.addEventListener(`click`,s,!0),()=>{document.removeEventListener(`click`,s,!0)})),window.addEventListener(`popstate`,async()=>{if(!await Vo()){history.pushState(null,``,i);return}i=window.location.pathname+window.location.search+window.location.hash,F(a,n(window.location.pathname),!0),vo(),gO()}),kn(()=>{V(a)===`/blueprint`?document.documentElement.setAttribute(`data-blueprint`,``):document.documentElement.removeAttribute(`data-blueprint`)});function c(e){o(e)}var l=Wr(),u=R(l),d=e=>{pD(e,{})},f=e=>{bs(e,{navigate:c})},p=e=>{op(e,{})},m=e=>{Ig(e,{})},h=e=>{Jg(e,{})},g=e=>{O_(e,{navigate:c})},_=e=>{aT(e,{})},v=e=>{uT(e,{})},y=e=>{ET(e,{})},b=e=>{oO(e,{})},x=e=>{$w(e,{})},S=e=>{var t=vO(),n=L(t);j(t),B(()=>G(n,`Route "${V(a)??``}" — not yet migrated.`)),W(e,t)};K(u,e=>{V(a)===`/templates`?e(d):V(a)===`/admin`?e(f,1):V(a)===`/blueprint`?e(p,2):V(a)===`/workspace`?e(m,3):V(a)===`/files`?e(h,4):V(a)===`/context`?e(g,5):V(a)===`/diagram`?e(_,6):V(a)===`/graph`?e(v,7):V(a)===`/shape-editor`?e(y,8):V(a)===`/survival-kit`?e(b,9):V(a)===`/`?e(x,10):e(S,-1)}),W(e,l),Je()}var bO=new Set,xO=!1;function SO(e){bO.add(e)}function CO(){if(xO)return;xO=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{let r=await e(t,n);try{let e=typeof t==`string`?t:t instanceof URL?t.toString():t.url;(n?.method||(t instanceof Request?t.method:`GET`)).toUpperCase()===`GET`&&/\/api\/config(?:\?|$)/.test(e)&&r.clone().json().then(e=>{for(let t of bO)try{t(e)}catch{}}).catch(()=>{})}catch{}return r}}ts(),SO(e=>ns(e)),SO(e=>Ho.syncFromConfig(e)),SO(va),CO(),vo(),Sa(xa()).finally(()=>{Gr(yO,{target:document.getElementById(`app`)})});export{vT as a,ST as c,dT as d,ld as f,yT as i,CT as l,Y as m,_T as n,xT as o,Sa as p,bT as r,gT as s,pT as t,fT as u};
|
|
328
|
+
`).map(e=>e.trim()).filter(Boolean);return t.length?{type:`table`,headers:t[0].split(`|`).map(e=>e.trim()),rows:t.slice(1).map(e=>e.split(`|`).map(e=>e.trim()))}:null}return{type:V(f),content:e}}function E(){let e=T();e&&(V(d)===-1?bD.notes[V(u)].blocs.push(e):bD.notes[V(u)].blocs[V(d)]=e,TD(),F(l,!1))}async function D(e,n){await t.confirmDelete(Y(`survival.confirm_del_bloc_title`),Y(`survival.irreversible`))&&(bD.notes[e].blocs.splice(n,1),TD())}async function ee(e,t){try{await navigator.clipboard.writeText(e),F(i,t,!0),setTimeout(()=>F(i,V(i)===t?null:V(i),!0),1500)}catch{}}let te=N(()=>V(f)===`ul`?Y(`survival.modal_bloc_placeholder_ul`):V(f)===`pre`?Y(`survival.modal_bloc_placeholder_pre`):V(f)===`table`?Y(`survival.modal_bloc_placeholder_table`):V(f)===`b`?Y(`survival.modal_bloc_placeholder_b`):Y(`survival.modal_bloc_placeholder_p`));var O=ZD(),k=R(O),ne=L(k),A=L(ne,!0);Ie(),j(ne);var re=z(ne,2),ie=L(re,!0);j(re),j(k);var ae=z(k,2),oe=L(ae),se=L(oe,!0);j(oe);var ce=z(oe,2),le=L(ce,!0);j(ce);var ue=z(ce,2),de=L(ue,!0);j(ue),j(ae);var fe=z(ae,2);let pe;var me=L(fe),he=e=>{var t=PD(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`survival.notes_empty`)]),W(e,t)};K(me,e=>{bD.notes.length===0&&e(he)}),q(z(me,2),19,()=>bD.notes,e=>e.id,(e,t,n)=>{let a=N(()=>!V(r)[V(t).id]);var o=GD();let s;var c=L(o),l=L(c),u=L(l,!0);j(l);var d=z(l,2),f=L(d),p=z(f,2);j(d);var m=z(d,2);j(c);var h=z(c,2),_=L(h);q(_,17,()=>V(t).blocs,Qr,(e,r,a)=>{var o=WD(),s=L(o),c=L(s),l=e=>{var t=FD(),n=L(t,!0);j(t),B(()=>G(n,V(r).content)),W(e,t)},u=e=>{var t=ID(),n=L(t,!0);j(t),B(()=>G(n,V(r).content)),W(e,t)},d=e=>{let n=N(()=>`${V(t).id}-${a}`);var o=LD(),s=L(o),c=L(s,!0);j(s);var l=z(s,2),u=L(l,!0);j(l),j(o),B(e=>{G(c,V(r).content),G(u,e)},[()=>V(i)===V(n)?Y(`survival.notes_btn_copied`):Y(`survival.notes_btn_copy`)]),H(`click`,l,()=>ee(V(r).content,V(n))),W(e,o)},f=e=>{var t=zD();q(t,21,()=>V(r).items,Qr,(e,t)=>{var n=RD(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(t),W(e,t)},p=e=>{var t=UD(),n=L(t),i=L(n),a=L(i);q(a,21,()=>V(r).headers,Qr,(e,t)=>{var n=BD(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(a),j(i);var o=z(i);q(o,21,()=>V(r).rows,Qr,(e,t)=>{var n=HD();q(n,21,()=>V(t),Qr,(e,t)=>{var n=VD(),r=L(n,!0);j(n),B(()=>G(r,V(t))),W(e,n)}),j(n),W(e,n)}),j(o),j(n),j(t),W(e,t)};K(c,e=>{V(r).type===`b`?e(l):V(r).type===`p`?e(u,1):V(r).type===`pre`?e(d,2):V(r).type===`ul`?e(f,3):V(r).type===`table`&&e(p,4)}),j(s);var m=z(s,2),h=L(m),g=z(h,2);j(m),j(o),H(`click`,h,()=>w(V(n),a)),H(`click`,g,()=>D(V(n),a)),W(e,o)});var v=z(_,2),b=L(v),S=L(b,!0);j(b),j(v),j(h),j(o),B(e=>{s=vi(o,1,`sk-note ${V(t).theme??``}`,`svelte-hpbata`,s,{collapsed:V(a)}),G(u,V(t).titre),G(S,e)},[()=>Y(`survival.notes_btn_add_bloc`)]),H(`click`,f,()=>y(V(n))),H(`click`,p,()=>x(V(n))),H(`click`,m,()=>g(V(t).id)),H(`click`,b,()=>C(V(n))),W(e,o)}),j(fe);var ge=z(fe,2);{let e=N(()=>V(o)===-1?Y(`survival.modal_note_title`):Y(`survival.modal_edit_note_title`)),t=N(()=>V(o)===-1?Y(`common.create`):Y(`common.save`));ND(ge,{get open(){return V(a)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:b,onClose:()=>F(a,!1),children:(e,t)=>{var n=qD(),r=R(n),i=L(r,!0);j(r);var a=z(r,2);ki(a);var o=z(a,2),l=L(o,!0);j(o);var u=z(o,2);q(u,21,()=>jD,Qr,(e,t)=>{var n=KD(),r=L(n,!0);j(n);var i={};B(e=>{G(r,e),i!==(i=V(t))&&(n.value=(n.__value=V(t))??``)},[()=>Y(m[V(t)])]),W(e,n)}),j(u),B((e,t,n)=>{G(i,e),J(a,`placeholder`,t),G(l,n)},[()=>Y(`survival.modal_note_label_title`),()=>Y(`survival.modal_note_placeholder`),()=>Y(`survival.modal_label_color`)]),H(`keydown`,a,e=>e.key===`Enter`&&b()),Fi(a,()=>V(s),e=>F(s,e)),Ci(u,()=>V(c),e=>F(c,e)),W(e,n)},$$slots:{default:!0}})}var _e=z(ge,2);{let e=N(()=>V(d)===-1?Y(`survival.modal_bloc_new`):Y(`survival.modal_bloc_edit`)),t=N(()=>Y(`common.save`));ND(_e,{get open(){return V(l)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:E,onClose:()=>F(l,!1),children:(e,t)=>{var n=XD(),r=R(n),i=L(r,!0);j(r);var a=z(r,2),o=L(a),s=L(o,!0);j(o),o.value=o.__value=`b`;var c=z(o),l=L(c,!0);j(c),c.value=c.__value=`p`;var u=z(c),d=L(u,!0);j(u),u.value=u.__value=`pre`;var m=z(u),h=L(m,!0);j(m),m.value=m.__value=`ul`;var g=z(m),_=L(g,!0);j(g),g.value=g.__value=`table`,j(a);var v=z(a,2),y=L(v,!0);j(v);var b=z(v,2),x=e=>{var t=JD();ki(t),B(()=>J(t,`placeholder`,V(te))),H(`keydown`,t,e=>e.key===`Enter`&&E()),Fi(t,()=>V(p),e=>F(p,e)),W(e,t)},S=e=>{var t=YD();yn(t),B(()=>J(t,`placeholder`,V(te))),Fi(t,()=>V(p),e=>F(p,e)),W(e,t)};K(b,e=>{V(f)===`b`?e(x):e(S,-1)}),B((e,t,n,r,a,o,c)=>{G(i,e),G(s,t),G(l,n),G(d,r),G(h,a),G(_,o),G(y,c)},[()=>Y(`survival.modal_bloc_label_type`),()=>Y(`survival.modal_bloc_type_b`),()=>Y(`survival.modal_bloc_type_p`),()=>Y(`survival.modal_bloc_type_pre`),()=>Y(`survival.modal_bloc_type_ul`),()=>Y(`survival.modal_bloc_type_table`),()=>Y(`survival.modal_bloc_label_content`)]),Ci(a,()=>V(f),e=>F(f,e)),W(e,n)},$$slots:{default:!0}})}B((e,t,r,i,a)=>{G(A,e),G(ie,t),G(se,r),G(le,i),G(de,a),pe=vi(fe,1,`sk-notes svelte-hpbata`,null,pe,{"edit-mode":V(n)})},[()=>Y(`survival.notes_title`),()=>Y(`survival.notes_subtitle`),()=>V(n)?Y(`survival.btn_read_mode`):Y(`survival.btn_edit_mode`),()=>V(h)?Y(`survival.btn_collapse_all`):Y(`survival.btn_expand_all`),()=>Y(`survival.notes_btn_add`)]),H(`click`,oe,()=>F(n,!V(n))),H(`click`,ce,_),H(`click`,ue,v),W(e,O),Je()}Pr([`click`,`keydown`]);var $D=U(`<p class="sk-empty svelte-1j811iq"> </p>`),eO=U(`<span class="sk-link-desc svelte-1j811iq"> </span>`),tO=U(`<a target="_blank" rel="noopener" class="sk-link svelte-1j811iq"><span class="sk-link-text svelte-1j811iq"><span class="sk-link-name svelte-1j811iq"> </span><!></span> <span class="sk-arrow svelte-1j811iq">↗</span> <span class="sk-link-actions svelte-1j811iq"><button type="button" class="sk-mini svelte-1j811iq">✎</button> <button type="button" class="sk-mini sk-mini--del svelte-1j811iq">✕</button></span></a>`),nO=U(`<section><div class="sk-cat-head svelte-1j811iq"><h3 class="svelte-1j811iq"> </h3> <div class="sk-cat-actions svelte-1j811iq"><button type="button" class="sk-mini svelte-1j811iq">+</button> <button type="button" class="sk-mini sk-mini--del svelte-1j811iq">✕</button></div> <button type="button" class="sk-toggle svelte-1j811iq" aria-label="toggle"><svg viewBox="0 0 10 6" width="10" height="6"><path d="M1 1 L5 5 L9 1" stroke="currentColor" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div> <div class="sk-links svelte-1j811iq"></div></section>`),rO=U(`<option> </option>`),iO=U(`<label for="sk-cat-name"> </label> <input id="sk-cat-name" type="text"/> <label for="sk-cat-color"> </label> <select id="sk-cat-color"></select>`,1),aO=U(`<label for="sk-link-nom"> </label> <input id="sk-link-nom" type="text"/> <label for="sk-link-desc"> </label> <input id="sk-link-desc" type="text"/> <label for="sk-link-url"> </label> <input id="sk-link-url" type="text" placeholder="https://…"/>`,1),oO=U(`<div class="sk-panel-head"><h2 class="sk-panel-title"> <span class="sk-accent">.</span></h2> <p class="sk-panel-sub"> </p></div> <div class="sk-toolbar svelte-1j811iq"><button type="button" class="sk-tool svelte-1j811iq"> </button> <button type="button" class="sk-tool svelte-1j811iq"> </button> <button type="button" class="sk-tool sk-tool--add svelte-1j811iq"> </button></div> <div><!> <!></div> <!> <!>`,1);function sO(e,t){qe(t,!0);let n=P(!1),r=P(I({})),i=P(!1),a=P(``),o=P(`t-green`),s=P(!1),c=P(-1),l=P(-1),u=P(``),d=P(``),f=P(``),p={"t-green":`survival.color_green`,"t-violet":`survival.color_violet`,"t-amber":`survival.color_amber`,"t-sky":`survival.color_sky`,"t-rose":`survival.color_rose`,"t-teal":`survival.color_teal`},m=N(()=>bD.links.length>0&&bD.links.every(e=>V(r)[e.titre]));function h(e){V(r)[e]=!V(r)[e]}function g(){if(V(m))F(r,{},!0);else{let e={};bD.links.forEach(t=>e[t.titre]=!0),F(r,e,!0)}}function _(){F(a,``),F(o,`t-green`),F(i,!0)}function v(){let e=V(a).trim();e&&(bD.links.push({theme:V(o),titre:e,liens:[]}),TD(),F(i,!1))}async function y(e){bD.links[e],await t.confirmDelete(Y(`survival.confirm_del_cat_title`),Y(`survival.confirm_del_cat_msg`))&&(bD.links.splice(e,1),TD())}function b(e){F(c,e,!0),F(l,-1),F(u,``),F(d,``),F(f,``),F(s,!0)}function x(e,t,n){e.preventDefault();let r=bD.links[t].liens[n];F(c,t,!0),F(l,n,!0),F(u,r.nom,!0),F(d,r.desc,!0),F(f,r.url,!0),F(s,!0)}function S(){let e=V(u).trim(),t=V(f).trim();if(!e||!t)return;let n={nom:e,desc:V(d).trim(),url:t};V(l)===-1?bD.links[V(c)].liens.push(n):bD.links[V(c)].liens[V(l)]=n,TD(),F(s,!1)}async function C(e,n,r){e.preventDefault(),await t.confirmDelete(Y(`survival.confirm_del_link_title`),Y(`survival.irreversible`))&&(bD.links[n].liens.splice(r,1),TD())}var w=oO(),T=R(w),E=L(T),D=L(E,!0);Ie(),j(E);var ee=z(E,2),te=L(ee,!0);j(ee),j(T);var O=z(T,2),k=L(O),ne=L(k,!0);j(k);var A=z(k,2),re=L(A,!0);j(A);var ie=z(A,2),ae=L(ie,!0);j(ie),j(O);var oe=z(O,2);let se;var ce=L(oe),le=e=>{var t=$D(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`survival.links_empty`)]),W(e,t)};K(ce,e=>{bD.links.length===0&&e(le)}),q(z(ce,2),19,()=>bD.links,(e,t)=>e.titre+t,(e,t,n)=>{let i=N(()=>!V(r)[V(t).titre]);var a=nO();let o;var s=L(a),c=L(s),l=L(c,!0);j(c);var u=z(c,2),d=L(u),f=z(d,2);j(u);var p=z(u,2);j(s);var m=z(s,2);q(m,21,()=>V(t).liens,Qr,(e,t,r)=>{var i=tO(),a=L(i),o=L(a),s=L(o,!0);j(o);var c=z(o),l=e=>{var n=eO(),r=L(n);j(n),B(()=>G(r,`— ${V(t).desc??``}`)),W(e,n)};K(c,e=>{V(t).desc&&e(l)}),j(a);var u=z(a,4),d=L(u),f=z(d,2);j(u),j(i),B((e,n)=>{J(i,`href`,V(t).url),G(s,V(t).nom),J(d,`title`,e),J(f,`title`,n)},[()=>Y(`survival.links_edit_link_title`),()=>Y(`survival.links_del_link_title`)]),H(`click`,d,e=>x(e,V(n),r)),H(`click`,f,e=>C(e,V(n),r)),W(e,i)}),j(m),j(a),B((e,n)=>{o=vi(a,1,`sk-cat ${V(t).theme??``}`,`svelte-1j811iq`,o,{collapsed:V(i)}),G(l,V(t).titre),J(d,`title`,e),J(f,`title`,n)},[()=>Y(`survival.links_add_link_title`),()=>Y(`survival.links_del_cat_title`)]),H(`click`,d,()=>b(V(n))),H(`click`,f,()=>y(V(n))),H(`click`,p,()=>h(V(t).titre)),W(e,a)}),j(oe);var ue=z(oe,2);{let e=N(()=>Y(`survival.modal_cat_title`)),t=N(()=>Y(`common.add`));ND(ue,{get open(){return V(i)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:v,onClose:()=>F(i,!1),children:(e,t)=>{var n=iO(),r=R(n),i=L(r,!0);j(r);var s=z(r,2);ki(s);var c=z(s,2),l=L(c,!0);j(c);var u=z(c,2);q(u,21,()=>jD,Qr,(e,t)=>{var n=rO(),r=L(n,!0);j(n);var i={};B(e=>{G(r,e),i!==(i=V(t))&&(n.value=(n.__value=V(t))??``)},[()=>Y(p[V(t)])]),W(e,n)}),j(u),B((e,t,n)=>{G(i,e),J(s,`placeholder`,t),G(l,n)},[()=>Y(`survival.modal_cat_label_name`),()=>Y(`survival.modal_cat_placeholder_name`),()=>Y(`survival.modal_label_color`)]),H(`keydown`,s,e=>e.key===`Enter`&&v()),Fi(s,()=>V(a),e=>F(a,e)),Ci(u,()=>V(o),e=>F(o,e)),W(e,n)},$$slots:{default:!0}})}var de=z(ue,2);{let e=N(()=>V(l)===-1?Y(`survival.modal_link_title`):Y(`survival.modal_edit_link_title`)),t=N(()=>V(l)===-1?Y(`common.add`):Y(`common.save`));ND(de,{get open(){return V(s)},get title(){return V(e)},get confirmLabel(){return V(t)},onConfirm:S,onClose:()=>F(s,!1),children:(e,t)=>{var n=aO(),r=R(n),i=L(r,!0);j(r);var a=z(r,2);ki(a);var o=z(a,2),s=L(o,!0);j(o);var c=z(o,2);ki(c);var l=z(c,2),p=L(l,!0);j(l);var m=z(l,2);ki(m),B((e,t,n,r,o)=>{G(i,e),J(a,`placeholder`,t),G(s,n),J(c,`placeholder`,r),G(p,o)},[()=>Y(`survival.modal_link_label_name`),()=>Y(`survival.modal_link_placeholder_name`),()=>Y(`survival.modal_link_label_desc`),()=>Y(`survival.modal_link_placeholder_desc`),()=>Y(`survival.modal_link_label_url`)]),Fi(a,()=>V(u),e=>F(u,e)),Fi(c,()=>V(d),e=>F(d,e)),H(`keydown`,m,e=>e.key===`Enter`&&S()),Fi(m,()=>V(f),e=>F(f,e)),W(e,n)},$$slots:{default:!0}})}B((e,t,r,i,a)=>{G(D,e),G(te,t),G(ne,r),G(re,i),G(ae,a),se=vi(oe,1,`sk-cats svelte-1j811iq`,null,se,{"edit-mode":V(n)})},[()=>Y(`survival.links_title`),()=>Y(`survival.links_subtitle`),()=>V(n)?Y(`survival.btn_read_mode`):Y(`survival.btn_edit_mode`),()=>V(m)?Y(`survival.btn_collapse_all`):Y(`survival.btn_expand_all`),()=>Y(`survival.links_btn_add_cat`)]),H(`click`,k,()=>F(n,!V(n))),H(`click`,A,g),H(`click`,ie,_),W(e,w),Je()}Pr([`click`,`keydown`]);var cO=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),lO=U(`<p class="sk-loading svelte-ha6eja"> </p>`),uO=U(`<div class="sk-grid svelte-ha6eja"><section class="sk-col svelte-ha6eja"><div class="sk-inner svelte-ha6eja"><!></div></section> <section class="sk-col svelte-ha6eja"><div class="sk-inner svelte-ha6eja"><!></div></section> <section class="sk-col svelte-ha6eja"><div class="sk-inner svelte-ha6eja"><!></div></section></div>`),dO=U(`<!> <div class="app-shell sk-root svelte-ha6eja"><!> <!></div> <!>`,1);function fO(e,t){qe(t,!0);let n=P(null),r=P(!1),i=P(!1),a=P(!1);async function o(e,t){return V(n).show({title:e,message:t,confirmLabel:Y(`survival.irreversible_delete`),cancelLabel:Y(`common.cancel`),danger:!0})}function s(e){F(i,e,!0),document.documentElement.classList.toggle(`dark`,e)}function c(){let e=!1;try{let t=localStorage.getItem(`ld-dark`);e=t===null?window.matchMedia(`(prefers-color-scheme: dark)`).matches:t===`true`}catch{}s(e)}function l(){s(!V(i));try{localStorage.setItem(`ld-dark`,String(V(i)))}catch{}}Ji(async()=>{c();try{await Sa((await fetch(`/api/config`).then(e=>e.json())).language||`en`)}catch{}await CD(),F(r,!0)});var u=dO(),d=R(u);Ui(Xd(d,{}),e=>F(n,e,!0),()=>V(n));var f=z(d,2),p=L(f);{let e=e=>{var t=cO(),n=R(t),r=z(n,2),o=L(r,!0);j(r),B((e,t)=>{J(n,`title`,e),J(n,`aria-label`,t),G(o,V(i)?`☀`:`☾`)},[()=>Y(`nav.word_cloud`),()=>Y(`nav.word_cloud`)]),H(`click`,n,()=>F(a,!0)),H(`click`,r,l),W(e,t)},t=N(()=>Y(`survival.title`)),n=N(()=>Y(`survival.subtitle`));Xo(p,{get title(){return V(t)},get subtitle(){return V(n)},actions:e,$$slots:{actions:!0}})}var m=z(p,2),h=e=>{var t=lO(),n=L(t,!0);j(t),B(e=>G(n,e),[()=>Y(`common.loading`)]),W(e,t)},g=e=>{var t=uO(),n=L(t),r=L(n);AD(L(r),{}),j(r),j(n);var i=z(n,2),a=L(i);QD(L(a),{confirmDelete:o}),j(a),j(i);var s=z(i,2),c=L(s);sO(L(c),{confirmDelete:o}),j(c),j(s),j(t),W(e,t)};K(m,e=>{V(r)?e(g,-1):e(h)}),j(f),Qw(z(f,2),{get open(){return V(a)},onclose:()=>F(a,!1)}),W(e,u),Je()}Pr([`click`]);var pO=`git-integration-config`,mO=`git-integration-status`,hO=`git-integration-save`,gO=`/admin#git-integration`,_O=120*1e3,vO=!1,yO=!1;function bO(e){let t=Date.parse(e);return Number.isFinite(t)&&Date.now()-t<_O}function xO(e){let t=e.toLowerCase();return t.includes(`cannot lock ref 'head'`)&&t.includes(`but expected`)?`un autre commit a modifié HEAD pendant l'autocommit. Réessayez l'enregistrement.`:e}async function SO(){if(!vO){vO=!0;try{let e=await fetch(`/api/git/status`,{cache:`no-store`});if(!e.ok)return;let t=await e.json();if(t.mode===`unconfigured`){bo(`Veuillez configurer l'intégration Git dans la page Admin.`,`error`,600*1e3,{id:pO,href:gO,linkLabel:`Admin`}),uo(mO),uo(hO);return}if(uo(pO),t.mode===`disabled`){uo(mO),uo(hO);return}if(!t.ok){bo(`Intégration Git : ${t.message}`,`error`,600*1e3,{id:mO,href:gO,linkLabel:`Admin`});return}if(t.dirtyOutsideDocsCount>0){let e=t.docsFolder?.trim()||`docsFolder`;bo(`Git : ${t.dirtyOutsideDocsCount} changement(s) hors ${e} seront ignorés par Living Documentation.`,`error`,600*1e3,mO)}else uo(mO);let n=t.lastSave;n&&bO(n.timestamp)&&(n.error||n.warning)?bo(`Git : ${xO(n.error||n.warning||``)}`,`error`,600*1e3,{id:hO,href:gO,linkLabel:`Admin`}):uo(hO)}catch{}finally{vO=!1}}}function CO(){if(yO)return;yO=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{let r=await e(t,n),i=typeof t==`string`?t:t instanceof URL?t.toString():t.url;return(n?.method||(t instanceof Request?t.method:`GET`)).toUpperCase()!==`GET`&&!i.includes(`/api/git/`)&&(i.startsWith(`/api/`)||i.startsWith(`/mcp`)||i.startsWith(window.location.origin))&&window.setTimeout(()=>void SO(),80),r}}var wO=U(`<p style="padding:2rem"> </p>`);function TO(e,t){qe(t,!0);function n(e){return e.length>1?e.replace(/\/+$/,``):e}let r=new Set([`/`,`/admin`,`/workspace`,`/blueprint`,`/diagram`,`/shape-editor`,`/context`,`/files`,`/survival-kit`,`/templates`,`/graph`]),i=window.location.pathname+window.location.search+window.location.hash,a=P(I(n(window.location.pathname)));async function o(e){let t=new URL(e,window.location.href),r=n(t.pathname),o=`${r}${t.search}${t.hash}`;if(o===`${window.location.pathname}${window.location.search}${window.location.hash}`){vo();return}await Vo()&&(history.pushState(null,``,o),i=o,F(a,r,!0),vo(),SO(),window.dispatchEvent(new PopStateEvent(`popstate`)))}function s(e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;if(!(t instanceof HTMLAnchorElement)||t.target||t.hasAttribute(`download`))return;let i=new URL(t.href,window.location.href);if(i.origin!==window.location.origin)return;let a=n(i.pathname);r.has(a)&&(e.preventDefault(),o(`${a}${i.search}${i.hash}`))}Ji(()=>(vo(),CO(),SO(),document.addEventListener(`click`,s,!0),()=>{document.removeEventListener(`click`,s,!0)})),window.addEventListener(`popstate`,async()=>{if(!await Vo()){history.pushState(null,``,i);return}i=window.location.pathname+window.location.search+window.location.hash,F(a,n(window.location.pathname),!0),vo(),SO()}),kn(()=>{V(a)===`/blueprint`?document.documentElement.setAttribute(`data-blueprint`,``):document.documentElement.removeAttribute(`data-blueprint`)});function c(e){o(e)}var l=Wr(),u=R(l),d=e=>{yD(e,{})},f=e=>{bs(e,{navigate:c})},p=e=>{op(e,{})},m=e=>{Hg(e,{})},h=e=>{e_(e,{})},g=e=>{P_(e,{navigate:c})},_=e=>{dT(e,{})},v=e=>{gT(e,{})},y=e=>{MT(e,{})},b=e=>{fO(e,{})},x=e=>{aT(e,{})},S=e=>{var t=wO(),n=L(t);j(t),B(()=>G(n,`Route "${V(a)??``}" — not yet migrated.`)),W(e,t)};K(u,e=>{V(a)===`/templates`?e(d):V(a)===`/admin`?e(f,1):V(a)===`/blueprint`?e(p,2):V(a)===`/workspace`?e(m,3):V(a)===`/files`?e(h,4):V(a)===`/context`?e(g,5):V(a)===`/diagram`?e(_,6):V(a)===`/graph`?e(v,7):V(a)===`/shape-editor`?e(y,8):V(a)===`/survival-kit`?e(b,9):V(a)===`/`?e(x,10):e(S,-1)}),W(e,l),Je()}var EO=new Set,DO=!1;function OO(e){EO.add(e)}function kO(){if(DO)return;DO=!0;let e=window.fetch.bind(window);window.fetch=async(t,n)=>{let r=await e(t,n);try{let e=typeof t==`string`?t:t instanceof URL?t.toString():t.url;(n?.method||(t instanceof Request?t.method:`GET`)).toUpperCase()===`GET`&&/\/api\/config(?:\?|$)/.test(e)&&r.clone().json().then(e=>{for(let t of EO)try{t(e)}catch{}}).catch(()=>{})}catch{}return r}}ts(),OO(e=>ns(e)),OO(e=>Ho.syncFromConfig(e)),OO(va),kO(),vo(),Sa(xa()).finally(()=>{Gr(TO,{target:document.getElementById(`app`)})});export{wT as a,OT as c,_T as d,ld as f,TT as i,kT as l,Y as m,CT as n,DT as o,Sa as p,ET as r,ST as s,yT as t,vT as u};
|