yamlover 0.3.21 → 0.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/yamlover.js +14 -0
- package/dist/client/assets/{decoded-CY5-anyl.js → decoded-CJRPjXa1.js} +1 -1
- package/dist/client/assets/{djvu-CbL4_9ak.js → djvu-DTScSRBE.js} +1 -1
- package/dist/client/assets/{docx-CCEuxO9n.js → docx-CZ_-bbiw.js} +1 -1
- package/dist/client/assets/{heic-BvS6Unla.js → heic-GGCTCDdl.js} +1 -1
- package/dist/client/assets/{imagemap-DBji1qL1.js → imagemap-99Y1w9r3.js} +1 -1
- package/dist/client/assets/{index-DqdQvRi4.js → index-Dwsn6NQE.js} +4 -4
- package/dist/client/assets/{map-BfHrzAqt.js → map-B1r-13cZ.js} +1 -1
- package/dist/client/assets/{openable-DIyqYrzm.js → openable-Bh72damS.js} +1 -1
- package/dist/client/assets/{paged-COP9CRTO.js → paged-DMHOhYfR.js} +1 -1
- package/dist/client/assets/{pdf-C-kvASQl.js → pdf-DNh_WoxB.js} +1 -1
- package/dist/client/assets/{psd-KxbPOIwA.js → psd-BODwPXZY.js} +1 -1
- package/dist/client/assets/{spreadsheet-DkG5umsc.js → spreadsheet-jmhwwLqI.js} +1 -1
- package/dist/client/assets/{tiff-sq_Q9sNj.js → tiff-B7WRQzVg.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server.js +488 -488
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as g,b as H,
|
|
1
|
+
import{j as g,b as H,u as W,a as q,r as a,D as z,f as K,e as V,c as X,i as Y,k as _}from"./index-Dwsn6NQE.js";import{L as d,w as Q,O as ee}from"./openable-Bh72damS.js";const y=t=>Number(t)||0,B=t=>t.replace(/[&<>"]/g,o=>({"&":"&","<":"<",">":">",'"':"""})[o]);function te(t){return t.map(o=>{const s=Y({name:o.label,color:o.color});return _(o.path)?`<span class="tagswatch" style="background:${s}" title="${B(o.label)}"></span>`:`<span class="tagtag" style="background:${s}">${B(o.label)}</span>`}).join("")}function ne(t,o,s,n,c){if(!t||n<=0||c<=0)return;const r=document.createElement("canvas");r.width=n,r.height=c;const p=r.getContext("2d");if(p){p.drawImage(t,o,s,n,c,0,0,n,c);try{return r.toDataURL("image/png")}catch{return}}}function oe(t,o){const s=new Map;for(const n of t){if(n.selector?.type!=="rect")continue;const c=JSON.stringify(n.selector);let r=s.get(c);r||(r={x:y(n.selector.x),y:y(n.selector.y),w:y(n.selector.w),h:y(n.selector.h),title:n.description,color:X(n),ann:V(n)?n:void 0,id:n.fragmentSlug?K(o,n.fragmentSlug):void 0,tags:[]},s.set(c,r)),n.tag&&r.tags.push({path:n.tag.path,label:n.tag.name,color:n.tag.color})}return[...s.values()]}function re({src:t,className:o,regions:s,onSelectRegion:n,onRegionClick:c,selectColor:r}){const p=a.useRef(null),w=a.useRef(null),f=a.useRef(null),E=a.useRef(null),v=a.useRef({w:1,h:1}),j=a.useRef(n),C=a.useRef(c),N=a.useRef(r),[O,k]=a.useState(null),[I,P]=a.useState(0),T=JSON.stringify(s??[]),L=!!n;a.useEffect(()=>{j.current=n,C.current=c,N.current=r}),a.useEffect(()=>{let l=!1,h=null;k(null);const e=new Image;return e.onload=()=>{if(l||!p.current)return;const m=e.naturalWidth||1,R=e.naturalHeight||1;v.current={w:m,h:R},E.current=e;const i=d.map(p.current,{crs:d.CRS.Simple,minZoom:-8,attributionControl:!1,zoomSnap:0}),x=[[0,0],[R,m]];d.imageOverlay(t,x).addTo(i),i.fitBounds(x),f.current=d.layerGroup().addTo(i),w.current=i,h=Q(i,{color:()=>N.current?.()??z,onSelect:L?(u,b)=>{const{h:F}=v.current,M=u.getWest(),G=u.getEast(),J=u.getSouth(),A=u.getNorth(),D=Math.round(M),U=Math.round(F-A),Z=Math.round(G-M),$=Math.round(A-J);j.current?.({type:"rect",x:D,y:U,w:Z,h:$},b,ne(E.current,D,U,Z,$))}:void 0}),P(u=>u+1)},e.onerror=()=>{l||k("could not load image")},e.src=t,()=>{l=!0,h?.(),w.current?.remove(),w.current=null,f.current=null}},[t]);const S=a.useRef(new Map);return a.useEffect(()=>{const l=f.current;if(!l)return;l.clearLayers(),S.current.clear();const{h}=v.current;for(const e of s??[]){const m=e.color||z,R=[[h-e.y,e.x],[h-(e.y+e.h),e.x+e.w]],i=d.rectangle(R,{className:"yo-region",color:m,weight:3,fillColor:m,fillOpacity:.25});if(e.title&&i.bindTooltip(e.title),e.ann){const x=e.ann,u=b=>{d.DomEvent.stop(b),C.current?.(x,{x:b.originalEvent.clientX,y:b.originalEvent.clientY})};i.on("click",u),i.on("contextmenu",u)}if(i.addTo(l),e.tags&&e.tags.length){const x=d.latLng(h-(e.y+e.h),e.x),u=d.divIcon({className:"yo-region-tags",html:te(e.tags),iconAnchor:[0,0]});d.marker(x,{icon:u,interactive:!1,keyboard:!1}).addTo(l)}e.id&&S.current.set(e.id,{rect:i,bounds:R})}},[T,I]),a.useEffect(()=>{const l=()=>{const h=w.current,e=decodeURIComponent(window.location.hash.slice(1)),m=e?S.current.get(e):void 0;!h||!m||(h.fitBounds(m.bounds,{maxZoom:h.getZoom(),padding:[40,40]}),m.rect.setStyle({weight:6,fillOpacity:.45}),window.setTimeout(()=>m.rect.setStyle({weight:3,fillOpacity:.25}),1e3))};return l(),window.addEventListener("hashchange",l),()=>window.removeEventListener("hashchange",l)},[T,I]),g.jsxs(g.Fragment,{children:[O&&g.jsxs("div",{className:"error",children:["image: ",O]}),g.jsx("div",{ref:p,className:o+(L?" yo-selectable":"")})]})}function le({node:t}){const o=W(t.path),{openCreate:s,openEdit:n,palette:c,preview:r,color:p}=q(o,t.path),w=oe(o.annotations,t.path);if(r?.selector.type==="rect"){const f=r.selector;w.push({x:y(f.x),y:y(f.y),w:y(f.w),h:y(f.h),color:r.color})}return g.jsxs("div",{className:"text",children:[t.title&&g.jsx("h1",{className:"chapter-title",children:t.title}),t.description&&g.jsx("p",{className:"chapter-subtitle",children:t.description}),g.jsx(re,{src:H(t.path),regions:w,onSelectRegion:(f,E,v)=>s(f,E,void 0,v),onRegionClick:n,selectColor:()=>p,className:"filemap fileimagemap"}),c]})}function se({src:t,path:o,onNavigate:s}){return g.jsx(ee,{path:o,onNavigate:s,title:"Open image on its own page",children:g.jsx("img",{className:"chunk-image",src:t,alt:"",loading:"lazy"})})}function ie({chunk:t,onNavigate:o}){return g.jsx(se,{src:H(t.path),path:t.path,onNavigate:o})}export{ie as ImageChunk,le as ImageView,re as PanZoomImage,se as StaticImageChunk};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-DNh_WoxB.js","assets/paged-DMHOhYfR.js","assets/pdf-m5e3jsV4.css","assets/djvu-DTScSRBE.js","assets/psd-BODwPXZY.js","assets/decoded-CJRPjXa1.js","assets/imagemap-99Y1w9r3.js","assets/openable-Bh72damS.js","assets/openable-CIGW-MKW.css","assets/tiff-B7WRQzVg.js","assets/_commonjs-dynamic-modules-TDtrdbi3.js","assets/heic-GGCTCDdl.js","assets/docx-CZ_-bbiw.js","assets/map-B1r-13cZ.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function r(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(i){if(i.ep)return;i.ep=!0;const s=r(i);fetch(i.href,s)}})();var T8=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fy(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var K_={exports:{}},Lu={},X_={exports:{}},Ot={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react.production.min.js
|
|
@@ -328,7 +328,7 @@ l0,-`+(r+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
328
328
|
`;const n=Array.from(e.childNodes).map(Pd).join("");if(r==="a"){const i=e.getAttribute("href")??"",s=n.trim();return/^https?:\/\//.test(i)&&s?`[${s}](${i})`:n}return r==="strong"||r==="b"?n.trim()?`**${n.trim()}**`:"":r==="em"||r==="i"?n.trim()?`*${n.trim()}*`:"":r==="code"?n.trim()?"`"+n.trim()+"`":"":r==="del"||r==="s"||r==="strike"?n.trim()?`~~${n.trim()}~~`:"":n}function zv(e){const t=[],r=n=>{for(const i of Array.from(n.childNodes))i instanceof HTMLElement&&(i.tagName==="DIV"||i.tagName==="P")?(t.push(`
|
|
329
329
|
`),r(i)):t.push(Pd(i))};return r(e),t.join("").replace(/^\n+/,"").replace(/\n+$/,"")}function j6(e){Nv(e,0)}function B6(e){e.focus();const t=window.getSelection();if(!t)return;const r=document.createRange();r.selectNodeContents(e),r.collapse(!1),t.removeAllRanges(),t.addRange(r)}function Nv(e,t){e.focus();const r=window.getSelection();if(!r)return;const n=document.createRange();let i=Math.max(0,t);const s=o=>{for(const f of Array.from(o.childNodes))if(f.nodeType===Node.TEXT_NODE){const h=f.textContent?.length??0;if(i<=h)return n.setStart(f,i),n.collapse(!0),!0;i-=h}else if(f instanceof HTMLElement){if(f.getAttribute("contenteditable")==="false"||f.hasAttribute("data-src")){const d=f.textContent?.length??0;if(i<=d)return n.setStartAfter(f),n.collapse(!0),!0;i-=d}else if(s(f))return!0}return!1};s(e)||(n.selectNodeContents(e),n.collapse(!1)),r.removeAllRanges(),r.addRange(n)}function Sc(e){const t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return null;const r=t.getRangeAt(0);return e.contains(r.startContainer)?r:null}function P6(e){const t=Sc(e);if(!t)return!1;const r=document.createRange();return r.selectNodeContents(e),r.setEnd(t.startContainer,t.startOffset),r.toString().length===0}function U6(e){const t=Sc(e);if(!t)return!1;const r=document.createRange();return r.selectNodeContents(e),r.setStart(t.endContainer,t.endOffset),r.toString().length===0}function Iv(e){const t=e.cloneRange();t.collapse(!0);let r=t.getBoundingClientRect();if(r.height===0&&r.top===0){const n=document.createElement("span");n.textContent="",t.insertNode(n),r=n.getBoundingClientRect();const i=n.parentNode;n.remove(),i?.normalize()}return r}function qv(e){const t=getComputedStyle(e),r=parseFloat(t.lineHeight);return Number.isFinite(r)&&r>0?r:(parseFloat(t.fontSize)||16)*1.4}function H6(e){const t=Sc(e);if(!t)return!1;if(e.clientHeight===0)return!0;const r=Iv(t);return r?r.top-e.getBoundingClientRect().top<qv(e)*.75:!0}function V6(e){const t=Sc(e);if(!t)return!1;if(e.clientHeight===0)return!0;const r=Iv(t);return r?e.getBoundingClientRect().bottom-r.bottom<qv(e)*.75:!0}function W6(e){const t=document.createElement("div");return t.innerHTML=Rv(e),t.textContent?.length??0}function Y6(e){const t=window.getSelection();if(!t||t.rangeCount===0||!e.contains(t.getRangeAt(0).endContainer))return null;const r=t.getRangeAt(0),n=i=>{const s=document.createRange();s.selectNodeContents(e),i==="head"?s.setEnd(r.endContainer,r.endOffset):s.setStart(r.endContainer,r.endOffset);const o=document.createElement("div");return o.appendChild(s.cloneContents()),zv(o)};return{head:n("head"),tail:n("tail")}}function G6(e,t){t==="start"?j6(e):t==="end"?B6(e):typeof t=="number"&&Nv(e,t)}const K6=({text:e,rev:t,focusAt:r,onFocused:n,onChangeText:i,onSplit:s,onArrowOut:o,onJoinPrev:f,onJoinNext:h})=>{const d=ft.useRef(null);return ft.useEffect(()=>{d.current&&(d.current.innerHTML=Rv(e))},[t]),ft.useEffect(()=>{r!=null&&d.current&&(G6(d.current,r),n())},[r]),ye.jsx("p",{ref:d,className:"chapter-prose editable",contentEditable:!0,suppressContentEditableWarning:!0,onInput:()=>{d.current&&i(zv(d.current))},onKeyDown:A=>{const z=d.current;if(z){if(A.key==="Enter"&&!A.shiftKey){A.preventDefault();const L=Y6(z);L&&s(L.head,L.tail);return}if(A.key==="ArrowUp"&&H6(z)){A.preventDefault(),o("up");return}if(A.key==="ArrowDown"&&V6(z)){A.preventDefault(),o("down");return}if(A.key==="Backspace"&&P6(z)){A.preventDefault(),f();return}if(A.key==="Delete"&&U6(z)){A.preventDefault(),h();return}}}})},X6=({text:e,rev:t,focusAt:r,onFocused:n,onChangeText:i,onArrowOut:s})=>{const o=ft.useRef(null),f=h=>{h.style.height="auto",h.style.height=h.scrollHeight+"px"};return ft.useEffect(()=>{o.current&&(o.current.value=e,f(o.current))},[t]),ft.useEffect(()=>{const h=o.current;if(r==null||!h)return;const d=r==="start"?0:r==="end"?h.value.length:r;h.focus(),h.setSelectionRange(d,d),n()},[r]),ye.jsx("textarea",{ref:o,className:"chapter-latex-src editable",spellCheck:!1,rows:1,defaultValue:e,onInput:h=>{const d=h.currentTarget;f(d),i(d.value)},onKeyDown:h=>{const d=h.currentTarget,A=d.value.slice(0,d.selectionStart),z=d.value.slice(d.selectionEnd),L=d.selectionStart===d.selectionEnd;if(h.key==="ArrowUp"&&L&&!A.includes(`
|
|
330
330
|
`)){h.preventDefault(),s("up");return}if(h.key==="ArrowDown"&&L&&!z.includes(`
|
|
331
|
-
`)){h.preventDefault(),s("down");return}}})};function Q6(e){return e===null||e==="text/marklower"||e==="text/markdown"?K6:e==="text/x-latex"?X6:null}function p_(e){return e===null||e==="text/marklower"||e==="text/markdown"}const Z6=/^([a-z][a-z0-9+.-]*:|\/\/|\/|#)/i;function J6(e){try{return decodeURIComponent(e)}catch{return e}}function Mv(e,t){if(!t)return null;const r=e.trim();if(!r||Z6.test(r))return null;const n=r.split(/[?#]/,1)[0],i=Vr(t).slice(0,-1);for(const s of n.split("/"))s===""||s==="."||(s===".."?i.pop():i.push(J6(s)));return i}function Dv(e,t){if(!t||!e.includes("<a"))return e;const r=document.createElement("template");r.innerHTML=e;for(const n of r.content.querySelectorAll("a[href]")){const i=Mv(n.getAttribute("href")||"",t);if(!i)continue;const s=Un(i);n.setAttribute("href",s),n.setAttribute("data-navpath",s)}return r.innerHTML}function Ud(e){return t=>{if(!e||t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;const r=t.target.closest?.("a[data-navpath]");r&&(t.preventDefault(),e(r.getAttribute("data-navpath")))}}const Lv=72,Jf=20,Of=400,Fv="yamlover.markupWidthCh",jv=()=>new URLSearchParams(window.location.search),Bv=e=>Number.isFinite(e)&&e>=Jf&&e<=Of;function O6(){try{const e=Number(localStorage.getItem(Fv));return Bv(e)?e:null}catch{return null}}function Ec(){const e=Number(jv().get("width"));return Bv(e)?e:O6()??Lv}function e7(e){try{localStorage.setItem(Fv,String(e))}catch{}const t=jv();t.delete("width"),e!==Lv&&t.set("width",String(e));const r=t.toString();window.history.replaceState({},"",window.location.pathname+(r?"?"+r:""))}function Pv({html:e,onNavigate:t}){return ye.jsx("div",{className:"markup",style:{maxWidth:`${Ec()}ch`},onClick:Ud(t),dangerouslySetInnerHTML:{__html:e}})}function Do({rerender:e}){const t=Ec(),[r,n]=ft.useState(String(t));ft.useEffect(()=>n(String(t)),[t]);const i=Number(r),s=r.trim()!==""&&Number.isInteger(i)&&i>=Jf&&i<=Of;return ye.jsx("input",{className:"markup-width"+(s?"":" invalid"),type:"text",inputMode:"numeric",title:"width, ch",value:r,onChange:o=>{const f=o.target.value;n(f);const h=Number(f);f.trim()!==""&&Number.isInteger(h)&&h>=Jf&&h<=Of&&(e7(h),e())}})}const Uv="$yamloverMixed";function t7(e){return e==null||e==="text/marklower"||e==="text/markdown"||e==="text/x-latex"}function r7(e,t){return e==="string"&&t7(t)}function Hd(e){return e==="x-yamlover-chapter"||e==="x-yamlover-task"}function eu(e,t){return Un([...Vr(e),t])}function n7(e){if(Array.isArray(e))return e;const t=e?.[Uv];return t?.entries?t.entries.filter(r=>r.key==null).map(r=>r.value):[]}function i7(e){const t=i=>Hd(Fr(i)?.format)?"subchapter":"chunk";if(Array.isArray(e))return e.map(i=>({kind:t(i),value:i}));const r=e?.[Uv];if(!r?.entries)return[];const n=[];for(const i of r.entries)i.key==="title"?n.push({kind:"title",value:i.value}):i.key==="description"?n.push({kind:"description",value:i.value}):i.key==null&&n.push({kind:t(i.value),value:i.value});return n}function __(e){const t=Fr(e)?.value??e;return typeof t=="string"?t:t==null?"":String(t)}let s7=0;const e0=()=>`ck${s7++}`;function m_(e,t="text/marklower"){return{id:e0(),rev:0,editable:!0,text:e,format:t,concrete:"yamlover",subchapter:!1,marker:null}}function a7(e){const r=n7(e.value).map(n=>{const i=Fr(n),s=i?.format??null;if(Hd(s))return{id:e0(),rev:0,editable:!1,text:"",format:s,concrete:i?.concrete??"yamlover",subchapter:!0,navPath:i?.path,title:i?.title,marker:n};const o=!i||typeof i.path=="string"&&i.path.startsWith(e.path+"["),f=i?.type,h=o&&r7(f,s);return{id:e0(),rev:0,editable:h,text:h?String(i?.value??n??""):"",format:s,concrete:i?.concrete??"yamlover",subchapter:!1,marker:n}});return{path:e.path,title:e.title??"",description:e.description??"",chunks:r}}function g_(e){return{path:e.path,title:e.title,description:e.description,chunks:e.chunks.map(t=>({...t}))}}function l7(e,t){const r=[],n=t.path;t.title!==e.title&&r.push({path:eu(n,"title"),op:"set",text:t.title}),t.description!==e.description&&r.push({path:eu(n,"description"),op:"set",text:t.description});const i=t.chunks.map(A=>A.id),s=new Map(t.chunks.map(A=>[A.id,A])),o=new Map(e.chunks.map(A=>[A.id,A])),f=e.chunks.map(A=>A.id),h=A=>eu(n,A),d=f.map((A,z)=>s.has(A)?-1:z).filter(A=>A>=0).sort((A,z)=>z-A);for(const A of d)r.push({path:h(A),op:"remove"}),f.splice(A,1);for(let A=0;A<i.length;A++){const z=i[A];f.includes(z)||(r.push({path:n,op:"insert",index:A,text:s.get(z).text}),f.splice(A,0,z))}for(let A=0;A<i.length;A++){const z=s.get(i[A]),L=o.get(i[A]);L&&z.editable&&z.text!==L.text&&r.push({path:h(A),op:"replace",text:z.text})}return r}function Hv({node:e,onNavigate:t}){const{unlocked:r}=e3(),{openAt:n,tagMenu:i}=wd({onCreate:(o,f,h)=>void cg(o,f,h).then(d=>t(d.path)).catch(d=>window.alert("create failed: "+d.message))}),s=o=>{o.target.closest(".chunk-body, .editable, a, button, textarea")||(o.preventDefault(),n(e.path,o.clientX,o.clientY,{format:e.format,concrete:e.concrete}))};return ye.jsxs("div",{className:"chapter-page",onContextMenu:s,children:[r?ye.jsx($7,{initialNode:e,onNavigate:t},e.path):ye.jsx(o7,{node:e,onNavigate:t}),i]})}function o7({node:e,onNavigate:t}){const r=i7(e.value);cc(e);let n=0;return ye.jsx("div",{className:"chapter",style:{maxWidth:`${Ec()}ch`},children:r.map((i,s)=>{if(i.kind==="title")return ye.jsx("h1",{className:"chapter-title",children:__(i.value)},s);if(i.kind==="description")return ye.jsx("p",{className:"chapter-subtitle",children:__(i.value)},s);if(i.kind==="subchapter"){const o=Fr(i.value);return ye.jsx(Vv,{path:o?.path,title:o?.title,onNavigate:t},s)}return ye.jsx(u7,{index:n++,item:i.value,basePath:e.path,documentPath:e.documentPath,onNavigate:t},s)})})}function u7({index:e,item:t,basePath:r,documentPath:n,onNavigate:i}){const s=Yv(t,n),o=Qa(s),f=o?.renderChunk?o.renderChunk(s,i):ye.jsx("p",{className:"chapter-prose",children:String(s.value??"")}),h=s.path?no(r,s.path):null;return ye.jsxs("div",{className:"chunk",id:h??void 0,"data-node-path":s.path||void 0,children:[ye.jsx(Wv,{index:e,anchor:h}),ye.jsx("div",{className:"chunk-body",children:f})]})}function Vv({path:e,title:t,onNavigate:r}){return ye.jsx("h2",{className:"chapter-link",children:ye.jsx("a",{className:"descend",href:e??"#",onClick:n=>{n.preventDefault(),e&&r(e)},children:t||"(untitled chapter)"})})}function c7(e){const t=ft.useRef(null);t.current===null&&(t.current=g_(e));const r=ft.useRef(e);r.current=e;const n=ft.useRef(void 0),i=ft.useRef(!1),s=ft.useRef(!1),o=ft.useCallback(async()=>{if(i.current){s.current=!0;return}const f=r.current,h=l7(t.current,f);if(h.length){i.current=!0;try{await w4(h),t.current=g_(f)}catch(d){window.alert("edit sync failed: "+d.message)}finally{i.current=!1,s.current&&(s.current=!1,o())}}},[]);return ft.useEffect(()=>(n.current&&clearTimeout(n.current),n.current=setTimeout(()=>void o(),500),()=>{n.current&&clearTimeout(n.current)}),[e,o]),ft.useCallback(()=>(n.current&&clearTimeout(n.current),o()),[o])}function $7({initialNode:e,onNavigate:t}){const[r,n]=ft.useState(()=>a7(e)),[i,s]=ft.useState(null),o=c7(r),f=ft.useRef(o);f.current=o,ft.useEffect(()=>()=>void f.current(),[]);const h=ft.useCallback((ne,ge)=>{n(Q=>({...Q,chunks:Q.chunks.map(F=>F.id===ne?{...F,text:ge}:F)}))},[]),d=ft.useCallback((ne,ge,Q)=>{n(F=>{const Y=F.chunks.findIndex(ve=>ve.id===ne);if(Y<0)return F;const pe=m_(Q,F.chunks[Y].format),se=F.chunks.slice();return se[Y]={...se[Y],text:ge,rev:se[Y].rev+1},se.splice(Y+1,0,pe),s({id:pe.id,at:"start"}),{...F,chunks:se}})},[]);ft.useCallback(ne=>{n(ge=>{const Q=m_(""),F=ge.chunks.slice();return F.splice(ne+1,0,Q),s({id:Q.id,at:"start"}),{...ge,chunks:F}})},[]);const A=ft.useCallback(ne=>{n(ge=>{const Q=ge.chunks.findIndex(pe=>pe.id===ne);if(Q<0||ge.chunks.length<=1)return ge;const F=ge.chunks.slice();F.splice(Q,1);const Y=F[Math.max(0,Q-1)];return Y?.editable&&s({id:Y.id,at:"end"}),{...ge,chunks:F}})},[]),z=ft.useCallback((ne,ge)=>{n(Q=>{const F=Q.chunks.findIndex(se=>se.id===ne),Y=ge==="up"?F-1:F+1,pe=Q.chunks[Y];return pe?.editable&&s({id:pe.id,at:ge==="up"?"end":"start"}),Q})},[]),L=ft.useCallback((ne,ge)=>{n(Q=>{const F=Q.chunks.findIndex(ue=>ue.id===ne),Y=ge==="prev"?F-1:F,pe=ge==="prev"?F:F+1;if(Y<0||pe>=Q.chunks.length)return Q;const se=Q.chunks[Y],ve=Q.chunks[pe];if(!se.editable||!ve.editable||!p_(se.format)||!p_(ve.format))return Q;const Z=W6(se.text),be=Q.chunks.slice();return be[Y]={...se,text:se.text+ve.text,rev:se.rev+1},be.splice(pe,1),s({id:se.id,at:Z}),{...Q,chunks:be}})},[]);return ye.jsxs("div",{className:"chapter",style:{maxWidth:`${Ec()}ch`},children:[ye.jsx(v_,{as:"h1",className:"chapter-title",placeholder:"Title",value:r.title,onCommit:ne=>n(ge=>({...ge,title:ne}))}),ye.jsx(v_,{as:"p",className:"chapter-subtitle",placeholder:"Description",value:r.description,onCommit:ne=>n(ge=>({...ge,description:ne}))}),r.chunks.map((ne,ge)=>ne.subchapter?ye.jsx(Vv,{path:ne.navPath,title:ne.title,onNavigate:t},ne.id):ye.jsx(f7,{index:ge,part:ne,basePath:r.path,documentPath:e.documentPath,onNavigate:t,focusAt:i?.id===ne.id?i.at:null,onFocused:()=>s(null),onChangeText:Q=>h(ne.id,Q),onSplit:(Q,F)=>d(ne.id,Q,F),onArrowOut:Q=>z(ne.id,Q),onJoinPrev:()=>L(ne.id,"prev"),onJoinNext:()=>L(ne.id,"next"),onRemove:r.chunks.filter(Q=>!Q.subchapter).length>1?()=>A(ne.id):void 0},ne.id))]})}function f7({index:e,part:t,basePath:r,documentPath:n,onNavigate:i,focusAt:s,onFocused:o,onChangeText:f,onSplit:h,onArrowOut:d,onJoinPrev:A,onJoinNext:z,onRemove:L}){const ne=eu(r,e),ge=no(r,ne),Q=t.editable?Q6(t.format):null;let F;if(Q)F=ye.jsx(Q,{text:t.text,rev:t.rev,focusAt:s,onFocused:o,onChangeText:f,onSplit:h,onArrowOut:d,onJoinPrev:A,onJoinNext:z});else{const Y=Yv(t.marker,n),pe=Qa(Y);F=pe?.renderChunk?pe.renderChunk(Y,i):ye.jsx("p",{className:"chapter-prose",children:String(Y.value??"")})}return ye.jsxs("div",{className:"chunk",id:ge??void 0,children:[ye.jsx(Wv,{index:e,anchor:ge}),ye.jsx("div",{className:"chunk-body",children:F}),Q&&L&&ye.jsx("span",{className:"chunk-tools",children:ye.jsx("button",{className:"chunk-tool",title:"Delete this paragraph",onClick:L,children:"🗑"})})]})}function v_({as:e,value:t,onCommit:r,className:n,placeholder:i}){const s=ft.useRef(null),o=ft.useRef(!1),f=e;return ft.useEffect(()=>{s.current&&!o.current&&(s.current.textContent=t)},[t]),ye.jsx(f,{ref:s,className:(n?n+" ":"")+"editable",contentEditable:!0,suppressContentEditableWarning:!0,"data-placeholder":i,onFocus:()=>o.current=!0,onBlur:()=>{o.current=!1,r((s.current?.textContent??"").trim())},onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),h.target.blur())}})}function Wv({index:e,anchor:t}){return t?ye.jsxs("a",{className:"chunk-index",href:`#${t}`,children:["§",e]}):ye.jsxs("span",{className:"chunk-index",children:["§",e]})}function Yv(e,t){const r=Fr(e);return{value:r?r.value:e,path:r?.path??"",type:r?.type??"string",format:r?.format??null,valueType:r?.valueType??"string",hasKeyed:r?.hasKeyed??!1,hasOrdinal:r?.hasOrdinal??!1,documentPath:t}}const d7="$yamloverRef",h7="x-yamlover-workflow";function Bs(e){const t=Fr(e);if(t)return t.path;const r=e?.[d7];return r&&typeof r.path=="string"?r.path:null}function Gv(e){const t=Tn(e).find(([n])=>n==="next")?.[1];if(t==null)return[];if(Array.isArray(t))return t.map(Bs).filter(n=>n!=null);const r=Bs(t);return r?[r]:[]}async function p7(e){const t=await on(e,1),r=Bs(Tn(t.value).find(([s])=>s==="initial")?.[1]),n=new Set,i=[];for(const[s,o]of Tn(t.value)){if(s==="initial"||s==="color")continue;const f=Fr(o);!f||f.format!==Ws||n.has(f.path)||(n.add(f.path),i.push({path:f.path,label:$c(f.path,f.title),color:f.color??null,next:[],initial:f.path===r}))}return await Promise.all(i.map(async s=>{try{s.next=Gv((await on(s.path,2)).value)}catch{}})),i}async function Kv(e,t,r){t!==r&&(t&&await Ou(e,t),await qa({target:e,tag:r}))}async function _7(e){const t=e.lastIndexOf(":");if(t<=0)return!1;try{return(await on(e.slice(0,t),0)).format===h7}catch{return!1}}async function t0(e){const t=await on(e,2);return{path:e,label:$c(e,t.title),color:md(t.value),next:Gv(t.value)}}const Lo=(e,t)=>{const r=Tn(e).find(([i])=>i===t)?.[1],n=Fr(r)?.value??r;return typeof n=="string"?n:typeof n=="number"?String(n):null};function m7({node:e,onNavigate:t}){const r=Va(Ys),[n,i]=ft.useState(null),s=Lo(e.value,"priority"),o=Lo(e.value,"assignee"),f=Lo(e.value,"due"),h=Lo(e.value,"estimate");ft.useEffect(()=>{let A=!1;return(async()=>{const z=await Wl(e.path).catch(()=>[]);let L=null;for(const ne of z){const ge=ne.tag?.path;if(!ge||!await _7(ge))continue;const Q=await t0(ge),F=await Promise.all(Q.next.map(Y=>t0(Y)));L={...Q,nextStates:F};break}A||i(L)})(),()=>{A=!0}},[e.path,r]);const d=async A=>{n&&await Kv(e.path,n.path,A).catch(()=>{})};return ye.jsxs("div",{className:"task",children:[ye.jsxs("div",{className:"task-strip",children:[n&&ye.jsx("span",{className:"task-state",style:{background:Hn({name:n.label,color:n.color})},children:n.label}),n?.nextStates.map(A=>ye.jsxs("button",{className:"task-advance",style:{borderColor:Hn({name:A.label,color:A.color})},onClick:()=>d(A.path),title:`Move to ${A.label}`,children:["→ ",A.label]},A.path)),s&&ye.jsx("span",{className:"board-chip prio-"+s,children:s}),o&&ye.jsxs("span",{className:"board-chip board-assignee",children:["@",o]}),f&&ye.jsx("span",{className:"board-chip board-due",children:f.slice(0,10)}),h&&ye.jsx("span",{className:"board-chip board-estimate",children:h})]}),ye.jsx(Hv,{node:e,onNavigate:t})]})}function g7(){const[e,t]=ft.useState(""),[r,n]=ft.useState(null),[i,s]=ft.useState(":.yamlover:settings.yamlover"),[o,f]=ft.useState("loading"),[h,d]=ft.useState(null),[A,z]=ft.useState(!1),L=Va(Ys);ft.useEffect(()=>{let ge=!0;return ug().then(Q=>{ge&&(t(F=>A?F:Q.source),n(Q.settings),s(Q.path),f(F=>F==="loading"?"ready":F))}).catch(Q=>ge&&d(String(Q.message||Q))),()=>{ge=!1}},[L]);const ne=ft.useCallback(async()=>{f("saving"),d(null);try{const{settings:ge}=await p4(e);n(ge),z(!1),f("ready")}catch(ge){d(String(ge.message||ge)),f("ready")}},[e]);return ye.jsxs("div",{className:"settings-view",children:[ye.jsxs("header",{className:"settings-head",children:[ye.jsx("span",{className:"settings-title",children:"⚙ Project configuration"}),ye.jsx("span",{className:"settings-path",children:i})]}),o==="loading"?ye.jsx("div",{className:"settings-dim",children:"loading…"}):ye.jsxs(ye.Fragment,{children:[r&&ye.jsxs("dl",{className:"settings-summary",children:[ye.jsx("dt",{children:"URI"}),ye.jsx("dd",{children:r.uri??ye.jsx("span",{className:"settings-dim",children:"— (no declared identity)"})}),ye.jsx("dt",{children:"Exports"}),ye.jsx("dd",{children:r.exports.length?r.exports.map(ge=>ye.jsx("code",{className:"settings-chip",children:ge},ge)):ye.jsx("span",{className:"settings-dim",children:"— (nothing exported)"})}),ye.jsx("dt",{children:"Tags location"}),ye.jsx("dd",{children:ye.jsx("code",{children:r.tags})}),ye.jsx("dt",{children:"Annotations location"}),ye.jsx("dd",{children:ye.jsx("code",{children:r.annotations})}),ye.jsx("dt",{children:"Sidecars"}),ye.jsx("dd",{children:ye.jsx("code",{children:r.sidecars})})]}),ye.jsx("label",{className:"settings-raw-label",children:"Source — settings.yamlover"}),ye.jsx("textarea",{className:"settings-raw",spellCheck:!1,value:e,onChange:ge=>{t(ge.target.value),z(!0)}}),h&&ye.jsx("div",{className:"settings-error",children:h}),ye.jsxs("div",{className:"settings-actions",children:[ye.jsx("span",{className:"settings-dim",children:"Defaults, never constraints — a node works wherever it lives."}),ye.jsx("button",{type:"button",className:"settings-save",onClick:ne,disabled:o!=="ready"||!A,children:o==="saving"?"Saving…":"Save"})]})]})]})}function Vd(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ks=Vd();function Xv(e){Ks=e}var Cs={exec:()=>null};function ra(e){let t=[];return r=>{let n=Math.max(0,Math.min(3,r-1)),i=t[n];return i||(i=e(n),t[n]=i),i}}function tr(e,t=""){let r=typeof e=="string"?e:e.source,n={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Or.caret,"$1"),r=r.replace(i,o),n},getRegex:()=>new RegExp(r,t)};return n}var v7=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Or={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:ra(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:ra(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:ra(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:ra(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:ra(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:ra(e=>new RegExp(`^ {0,${e}}>`))},y7=/^(?:[ \t]*(?:\n|$))+/,b7=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,x7=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,oo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,w7=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Wd=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Qv=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Zv=tr(Qv).replace(/bull/g,Wd).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).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/).replace(/\|table/g,"").getRegex(),k7=tr(Qv).replace(/bull/g,Wd).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).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/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Yd=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,S7=/^[^\n]+/,Gd=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,E7=tr(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Gd).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),A7=tr(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Wd).getRegex(),Ac="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",Kd=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,C7=tr("^ {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",Kd).replace("tag",Ac).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Jv=tr(Yd).replace("hr",oo).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[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ac).getRegex(),T7=tr(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Jv).getRegex(),Xd={blockquote:T7,code:b7,def:E7,fences:x7,heading:w7,hr:oo,html:C7,lheading:Zv,list:A7,newline:y7,paragraph:Jv,table:Cs,text:S7},y_=tr("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",oo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ac).getRegex(),R7={...Xd,lheading:k7,table:y_,paragraph:tr(Yd).replace("hr",oo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",y_).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ac).getRegex()},z7={...Xd,html:tr(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Kd).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:Cs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:tr(Yd).replace("hr",oo).replace("heading",` *#{1,6} *[^
|
|
331
|
+
`)){h.preventDefault(),s("down");return}}})};function Q6(e){return e===null||e==="text/marklower"||e==="text/markdown"?K6:e==="text/x-latex"?X6:null}function p_(e){return e===null||e==="text/marklower"||e==="text/markdown"}const Z6=/^([a-z][a-z0-9+.-]*:|\/\/|\/|#)/i;function J6(e){try{return decodeURIComponent(e)}catch{return e}}function Mv(e,t){if(!t)return null;const r=e.trim();if(!r||Z6.test(r))return null;const n=r.split(/[?#]/,1)[0],i=Vr(t).slice(0,-1);for(const s of n.split("/"))s===""||s==="."||(s===".."?i.pop():i.push(J6(s)));return i}function Dv(e,t){if(!t||!e.includes("<a"))return e;const r=document.createElement("template");r.innerHTML=e;for(const n of r.content.querySelectorAll("a[href]")){const i=Mv(n.getAttribute("href")||"",t);if(!i)continue;const s=Un(i);n.setAttribute("href",s),n.setAttribute("data-navpath",s)}return r.innerHTML}function Ud(e){return t=>{if(!e||t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;const r=t.target.closest?.("a[data-navpath]");r&&(t.preventDefault(),e(r.getAttribute("data-navpath")))}}const Lv=72,Jf=20,Of=400,Fv="yamlover.markupWidthCh",jv=()=>new URLSearchParams(window.location.search),Bv=e=>Number.isFinite(e)&&e>=Jf&&e<=Of;function O6(){try{const e=Number(localStorage.getItem(Fv));return Bv(e)?e:null}catch{return null}}function Ec(){const e=Number(jv().get("width"));return Bv(e)?e:O6()??Lv}function e7(e){try{localStorage.setItem(Fv,String(e))}catch{}const t=jv();t.delete("width"),e!==Lv&&t.set("width",String(e));const r=t.toString();window.history.replaceState({},"",window.location.pathname+(r?"?"+r:""))}function Pv({html:e,onNavigate:t}){return ye.jsx("div",{className:"markup",style:{maxWidth:`${Ec()}ch`},onClick:Ud(t),dangerouslySetInnerHTML:{__html:e}})}function Do({rerender:e}){const t=Ec(),[r,n]=ft.useState(String(t));ft.useEffect(()=>n(String(t)),[t]);const i=Number(r),s=r.trim()!==""&&Number.isInteger(i)&&i>=Jf&&i<=Of;return ye.jsx("input",{className:"markup-width"+(s?"":" invalid"),type:"text",inputMode:"numeric",title:"width, ch",value:r,onChange:o=>{const f=o.target.value;n(f);const h=Number(f);f.trim()!==""&&Number.isInteger(h)&&h>=Jf&&h<=Of&&(e7(h),e())}})}const Uv="$yamloverMixed";function t7(e){return e==null||e==="text/marklower"||e==="text/markdown"||e==="text/x-latex"}function r7(e,t){return e==="string"&&t7(t)}function Hd(e){return e==="x-yamlover-chapter"||e==="x-yamlover-task"}function eu(e,t){return Un([...Vr(e),t])}function n7(e){if(Array.isArray(e))return e;const t=e?.[Uv];return t?.entries?t.entries.filter(r=>r.key==null).map(r=>r.value):[]}function i7(e){const t=i=>Hd(Fr(i)?.format)?"subchapter":"chunk";if(Array.isArray(e))return e.map(i=>({kind:t(i),value:i}));const r=e?.[Uv];if(!r?.entries)return[];const n=[];for(const i of r.entries)i.key==="title"?n.push({kind:"title",value:i.value}):i.key==="description"?n.push({kind:"description",value:i.value}):i.key==null&&n.push({kind:t(i.value),value:i.value});return n}function __(e){const t=Fr(e)?.value??e;return typeof t=="string"?t:t==null?"":String(t)}let s7=0;const e0=()=>`ck${s7++}`;function m_(e,t="text/marklower"){return{id:e0(),rev:0,editable:!0,text:e,format:t,concrete:"yamlover",subchapter:!1,marker:null}}function a7(e){const r=n7(e.value).map(n=>{const i=Fr(n),s=i?.format??null;if(Hd(s))return{id:e0(),rev:0,editable:!1,text:"",format:s,concrete:i?.concrete??"yamlover",subchapter:!0,navPath:i?.path,title:i?.title,marker:n};const o=!i||typeof i.path=="string"&&i.path.startsWith(e.path+"["),f=i?.type,h=o&&r7(f,s);return{id:e0(),rev:0,editable:h,text:h?String(i?.value??n??""):"",format:s,concrete:i?.concrete??"yamlover",subchapter:!1,marker:n}});return{path:e.path,title:e.title??"",description:e.description??"",chunks:r}}function g_(e){return{path:e.path,title:e.title,description:e.description,chunks:e.chunks.map(t=>({...t}))}}function l7(e,t){const r=[],n=t.path;t.title!==e.title&&r.push({path:eu(n,"title"),op:"set",text:t.title}),t.description!==e.description&&r.push({path:eu(n,"description"),op:"set",text:t.description});const i=t.chunks.map(A=>A.id),s=new Map(t.chunks.map(A=>[A.id,A])),o=new Map(e.chunks.map(A=>[A.id,A])),f=e.chunks.map(A=>A.id),h=A=>eu(n,A),d=f.map((A,z)=>s.has(A)?-1:z).filter(A=>A>=0).sort((A,z)=>z-A);for(const A of d)r.push({path:h(A),op:"remove"}),f.splice(A,1);for(let A=0;A<i.length;A++){const z=i[A];f.includes(z)||(r.push({path:n,op:"insert",index:A,text:s.get(z).text}),f.splice(A,0,z))}for(let A=0;A<i.length;A++){const z=s.get(i[A]),L=o.get(i[A]);L&&z.editable&&z.text!==L.text&&r.push({path:h(A),op:"replace",text:z.text})}return r}function Hv({node:e,onNavigate:t}){const{unlocked:r}=e3(),{openAt:n,tagMenu:i}=wd({onCreate:(o,f,h)=>void cg(o,f,h).then(d=>t(d.path)).catch(d=>window.alert("create failed: "+d.message))}),s=o=>{o.target.closest(".chunk-body, .editable, a, button, textarea")||(o.preventDefault(),n(e.path,o.clientX,o.clientY,{format:e.format,concrete:e.concrete}))};return ye.jsxs("div",{className:"chapter-page",onContextMenu:s,children:[r?ye.jsx($7,{initialNode:e,onNavigate:t},e.path):ye.jsx(o7,{node:e,onNavigate:t}),i]})}function o7({node:e,onNavigate:t}){const r=i7(e.value);cc(e);let n=0;return ye.jsx("div",{className:"chapter",style:{maxWidth:`${Ec()}ch`},children:r.map((i,s)=>{if(i.kind==="title")return ye.jsx("h1",{className:"chapter-title",children:__(i.value)},s);if(i.kind==="description")return ye.jsx("p",{className:"chapter-subtitle",children:__(i.value)},s);if(i.kind==="subchapter"){const o=Fr(i.value);return ye.jsx(Vv,{path:o?.path,title:o?.title,onNavigate:t},s)}return ye.jsx(u7,{index:n++,item:i.value,basePath:e.path,documentPath:e.documentPath,onNavigate:t},s)})})}function u7({index:e,item:t,basePath:r,documentPath:n,onNavigate:i}){const s=Yv(t,n),o=Qa(s),f=o?.renderChunk?o.renderChunk(s,i):ye.jsx("p",{className:"chapter-prose",children:String(s.value??"")}),h=s.path?no(r,s.path):null;return ye.jsxs("div",{className:"chunk",id:h??void 0,"data-node-path":s.path||void 0,children:[ye.jsx(Wv,{index:e,anchor:h}),ye.jsx("div",{className:"chunk-body",children:f})]})}function Vv({path:e,title:t,onNavigate:r}){return ye.jsx("h2",{className:"chapter-link",children:ye.jsx("a",{className:"descend",href:e??"#",onClick:n=>{n.preventDefault(),e&&r(e)},children:t||"(untitled chapter)"})})}function c7(e){const t=ft.useRef(null);t.current===null&&(t.current=g_(e));const r=ft.useRef(e);r.current=e;const n=ft.useRef(void 0),i=ft.useRef(!1),s=ft.useRef(!1),o=ft.useCallback(async()=>{if(i.current){s.current=!0;return}const f=r.current,h=l7(t.current,f);if(h.length){i.current=!0;try{await w4(h),t.current=g_(f)}catch(d){window.alert("edit sync failed: "+d.message)}finally{i.current=!1,s.current&&(s.current=!1,o())}}},[]);return ft.useEffect(()=>(n.current&&clearTimeout(n.current),n.current=setTimeout(()=>void o(),500),()=>{n.current&&clearTimeout(n.current)}),[e,o]),ft.useCallback(()=>(n.current&&clearTimeout(n.current),o()),[o])}function $7({initialNode:e,onNavigate:t}){const[r,n]=ft.useState(()=>a7(e)),[i,s]=ft.useState(null),o=c7(r),f=ft.useRef(o);f.current=o,ft.useEffect(()=>()=>void f.current(),[]);const h=ft.useCallback((ne,ge)=>{n(Q=>({...Q,chunks:Q.chunks.map(F=>F.id===ne?{...F,text:ge}:F)}))},[]),d=ft.useCallback((ne,ge,Q)=>{n(F=>{const Y=F.chunks.findIndex(ve=>ve.id===ne);if(Y<0)return F;const pe=m_(Q,F.chunks[Y].format),se=F.chunks.slice();return se[Y]={...se[Y],text:ge,rev:se[Y].rev+1},se.splice(Y+1,0,pe),s({id:pe.id,at:"start"}),{...F,chunks:se}})},[]);ft.useCallback(ne=>{n(ge=>{const Q=m_(""),F=ge.chunks.slice();return F.splice(ne+1,0,Q),s({id:Q.id,at:"start"}),{...ge,chunks:F}})},[]);const A=ft.useCallback(ne=>{n(ge=>{const Q=ge.chunks.findIndex(pe=>pe.id===ne);if(Q<0||ge.chunks.length<=1)return ge;const F=ge.chunks.slice();F.splice(Q,1);const Y=F[Math.max(0,Q-1)];return Y?.editable&&s({id:Y.id,at:"end"}),{...ge,chunks:F}})},[]),z=ft.useCallback((ne,ge)=>{n(Q=>{const F=Q.chunks.findIndex(se=>se.id===ne),Y=ge==="up"?F-1:F+1,pe=Q.chunks[Y];return pe?.editable&&s({id:pe.id,at:ge==="up"?"end":"start"}),Q})},[]),L=ft.useCallback((ne,ge)=>{n(Q=>{const F=Q.chunks.findIndex(ue=>ue.id===ne),Y=ge==="prev"?F-1:F,pe=ge==="prev"?F:F+1;if(Y<0||pe>=Q.chunks.length)return Q;const se=Q.chunks[Y],ve=Q.chunks[pe];if(!se.editable||!ve.editable||!p_(se.format)||!p_(ve.format))return Q;const Z=W6(se.text),be=Q.chunks.slice();return be[Y]={...se,text:se.text+ve.text,rev:se.rev+1},be.splice(pe,1),s({id:se.id,at:Z}),{...Q,chunks:be}})},[]);return ye.jsxs("div",{className:"chapter",style:{maxWidth:`${Ec()}ch`},children:[ye.jsx(v_,{as:"h1",className:"chapter-title",placeholder:"Title",value:r.title,onCommit:ne=>n(ge=>({...ge,title:ne}))}),ye.jsx(v_,{as:"p",className:"chapter-subtitle",placeholder:"Description",value:r.description,onCommit:ne=>n(ge=>({...ge,description:ne}))}),r.chunks.map((ne,ge)=>ne.subchapter?ye.jsx(Vv,{path:ne.navPath,title:ne.title,onNavigate:t},ne.id):ye.jsx(f7,{index:ge,part:ne,basePath:r.path,documentPath:e.documentPath,onNavigate:t,focusAt:i?.id===ne.id?i.at:null,onFocused:()=>s(null),onChangeText:Q=>h(ne.id,Q),onSplit:(Q,F)=>d(ne.id,Q,F),onArrowOut:Q=>z(ne.id,Q),onJoinPrev:()=>L(ne.id,"prev"),onJoinNext:()=>L(ne.id,"next"),onRemove:r.chunks.filter(Q=>!Q.subchapter).length>1?()=>A(ne.id):void 0},ne.id))]})}function f7({index:e,part:t,basePath:r,documentPath:n,onNavigate:i,focusAt:s,onFocused:o,onChangeText:f,onSplit:h,onArrowOut:d,onJoinPrev:A,onJoinNext:z,onRemove:L}){const ne=eu(r,e),ge=no(r,ne),Q=t.editable?Q6(t.format):null;let F;if(Q)F=ye.jsx(Q,{text:t.text,rev:t.rev,focusAt:s,onFocused:o,onChangeText:f,onSplit:h,onArrowOut:d,onJoinPrev:A,onJoinNext:z});else{const Y=Yv(t.marker,n),pe=Qa(Y);F=pe?.renderChunk?pe.renderChunk(Y,i):ye.jsx("p",{className:"chapter-prose",children:String(Y.value??"")})}return ye.jsxs("div",{className:"chunk",id:ge??void 0,children:[ye.jsx(Wv,{index:e,anchor:ge}),ye.jsx("div",{className:"chunk-body",children:F}),Q&&L&&ye.jsx("span",{className:"chunk-tools",children:ye.jsx("button",{className:"chunk-tool",title:"Delete this paragraph",onClick:L,children:"🗑"})})]})}function v_({as:e,value:t,onCommit:r,className:n,placeholder:i}){const s=ft.useRef(null),o=ft.useRef(!1),f=e;return ft.useEffect(()=>{s.current&&!o.current&&(s.current.textContent=t)},[t]),ye.jsx(f,{ref:s,className:(n?n+" ":"")+"editable",contentEditable:!0,suppressContentEditableWarning:!0,"data-placeholder":i,onFocus:()=>o.current=!0,onBlur:()=>{o.current=!1,r((s.current?.textContent??"").trim())},onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),h.target.blur())}})}function Wv({index:e,anchor:t}){return t?ye.jsxs("a",{className:"chunk-index",href:`#${t}`,children:["§",e]}):ye.jsxs("span",{className:"chunk-index",children:["§",e]})}function Yv(e,t){const r=Fr(e);return{value:r?r.value:e,path:r?.path??"",type:r?.type??"string",format:r?.format??null,valueType:r?.valueType??"string",hasKeyed:r?.hasKeyed??!1,hasOrdinal:r?.hasOrdinal??!1,documentPath:t}}const d7="$yamloverRef",h7="x-yamlover-workflow";function Bs(e){const t=Fr(e);if(t)return t.path;const r=e?.[d7];return r&&typeof r.path=="string"?r.path:null}function Gv(e){const t=Tn(e).find(([n])=>n==="next")?.[1];if(t==null)return[];if(Array.isArray(t))return t.map(Bs).filter(n=>n!=null);const r=Bs(t);return r?[r]:[]}async function p7(e){const t=await on(e,1),r=Bs(Tn(t.value).find(([s])=>s==="initial")?.[1]),n=new Set,i=[];for(const[s,o]of Tn(t.value)){if(s==="initial"||s==="color")continue;const f=Fr(o);!f||f.format!==Ws||n.has(f.path)||(n.add(f.path),i.push({path:f.path,label:$c(f.path,f.title),color:f.color??null,next:[],initial:f.path===r}))}return await Promise.all(i.map(async s=>{try{s.next=Gv((await on(s.path,2)).value)}catch{}})),i}async function Kv(e,t,r){t!==r&&(t&&await Ou(e,t),await qa({target:e,tag:r}))}async function _7(e){const t=e.lastIndexOf(":");if(t<=0)return!1;try{return(await on(e.slice(0,t),0)).format===h7}catch{return!1}}async function t0(e){const t=await on(e,2);return{path:e,label:$c(e,t.title),color:md(t.value),next:Gv(t.value)}}const Lo=(e,t)=>{const r=Tn(e).find(([i])=>i===t)?.[1],n=Fr(r)?.value??r;return typeof n=="string"?n:typeof n=="number"?String(n):null};function m7({node:e,onNavigate:t}){const r=Va(Ys),[n,i]=ft.useState(null),s=Lo(e.value,"priority"),o=Lo(e.value,"assignee"),f=Lo(e.value,"due"),h=Lo(e.value,"estimate");ft.useEffect(()=>{let A=!1;return(async()=>{const z=await Wl(e.path).catch(()=>[]);let L=null;for(const ne of z){const ge=ne.tag?.path;if(!ge||!await _7(ge))continue;const Q=await t0(ge),F=await Promise.all(Q.next.map(Y=>t0(Y)));L={...Q,nextStates:F};break}A||i(L)})(),()=>{A=!0}},[e.path,r]);const d=async A=>{n&&await Kv(e.path,n.path,A).catch(()=>{})};return ye.jsxs("div",{className:"task",children:[ye.jsxs("div",{className:"task-strip",children:[n&&ye.jsx("span",{className:"task-state",style:{background:Hn({name:n.label,color:n.color})},children:n.label}),n?.nextStates.map(A=>ye.jsxs("button",{className:"task-advance",style:{borderColor:Hn({name:A.label,color:A.color})},onClick:()=>d(A.path),title:`Move to ${A.label}`,children:["→ ",A.label]},A.path)),s&&ye.jsx("span",{className:"board-chip prio-"+s,children:s}),o&&ye.jsxs("span",{className:"board-chip board-assignee",children:["@",o]}),f&&ye.jsx("span",{className:"board-chip board-due",children:f.slice(0,10)}),h&&ye.jsx("span",{className:"board-chip board-estimate",children:h})]}),ye.jsx(Hv,{node:e,onNavigate:t})]})}function g7(){const[e,t]=ft.useState(""),[r,n]=ft.useState(null),[i,s]=ft.useState(":.yamlover:settings.yamlover"),[o,f]=ft.useState("loading"),[h,d]=ft.useState(null),[A,z]=ft.useState(!1),L=Va(Ys);ft.useEffect(()=>{let ge=!0;return ug().then(Q=>{ge&&(t(F=>A?F:Q.source),n(Q.settings),s(Q.path),f(F=>F==="loading"?"ready":F))}).catch(Q=>ge&&d(String(Q.message||Q))),()=>{ge=!1}},[L]);const ne=ft.useCallback(async()=>{f("saving"),d(null);try{const{settings:ge}=await p4(e);n(ge),z(!1),f("ready")}catch(ge){d(String(ge.message||ge)),f("ready")}},[e]);return ye.jsxs("div",{className:"settings-view",children:[ye.jsxs("header",{className:"settings-head",children:[ye.jsx("span",{className:"settings-title",children:"⚙ Project configuration"}),ye.jsx("span",{className:"settings-path",children:i})]}),o==="loading"?ye.jsx("div",{className:"settings-dim",children:"loading…"}):ye.jsxs(ye.Fragment,{children:[r&&ye.jsxs("dl",{className:"settings-summary",children:[ye.jsx("dt",{children:"URI"}),ye.jsx("dd",{children:r.uri??ye.jsx("span",{className:"settings-dim",children:"— (no declared identity)"})}),ye.jsx("dt",{children:"Exports"}),ye.jsx("dd",{children:r.exports.length?r.exports.map(ge=>ye.jsx("code",{className:"settings-chip",children:ge},ge)):ye.jsx("span",{className:"settings-dim",children:"— (nothing exported)"})}),ye.jsx("dt",{children:"Tags location"}),ye.jsx("dd",{children:ye.jsx("code",{children:r.tags})}),ye.jsx("dt",{children:"Annotations location"}),ye.jsx("dd",{children:ye.jsx("code",{children:r.annotations})}),ye.jsx("dt",{children:"Sidecars"}),ye.jsx("dd",{children:ye.jsx("code",{children:r.sidecars})})]}),ye.jsx("label",{className:"settings-raw-label",children:"Source — settings.yamlover"}),ye.jsx("textarea",{className:"settings-raw",spellCheck:!1,value:e,onChange:ge=>{t(ge.target.value),z(!0)}}),h&&ye.jsx("div",{className:"settings-error",children:h}),ye.jsxs("div",{className:"settings-actions",children:[ye.jsx("span",{className:"settings-dim",children:"Defaults, never constraints — a node works wherever it lives."}),ye.jsx("button",{type:"button",className:"settings-save",onClick:ne,disabled:o!=="ready"||!A,children:o==="saving"?"Saving…":"Save"})]})]})]})}function Vd(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ks=Vd();function Xv(e){Ks=e}var Cs={exec:()=>null};function ra(e){let t=[];return r=>{let n=Math.max(0,Math.min(3,r-1)),i=t[n];return i||(i=e(n),t[n]=i),i}}function tr(e,t=""){let r=typeof e=="string"?e:e.source,n={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Or.caret,"$1"),r=r.replace(i,o),n},getRegex:()=>new RegExp(r,t)};return n}var v7=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Or={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:ra(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:ra(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:ra(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:ra(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:ra(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:ra(e=>new RegExp(`^ {0,${e}}>`))},y7=/^(?:[ \t]*(?:\n|$))+/,b7=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,x7=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,oo=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,w7=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Wd=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Qv=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Zv=tr(Qv).replace(/bull/g,Wd).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).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/).replace(/\|table/g,"").getRegex(),k7=tr(Qv).replace(/bull/g,Wd).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).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/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Yd=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,S7=/^[^\n]+/,Gd=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,E7=tr(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Gd).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),A7=tr(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Wd).getRegex(),Ac="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",Kd=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,C7=tr("^ {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",Kd).replace("tag",Ac).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Jv=tr(Yd).replace("hr",oo).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[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ac).getRegex(),T7=tr(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Jv).getRegex(),Xd={blockquote:T7,code:b7,def:E7,fences:x7,heading:w7,hr:oo,html:C7,lheading:Zv,list:A7,newline:y7,paragraph:Jv,table:Cs,text:S7},y_=tr("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",oo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ac).getRegex(),R7={...Xd,lheading:k7,table:y_,paragraph:tr(Yd).replace("hr",oo).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",y_).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ac).getRegex()},z7={...Xd,html:tr(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Kd).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:Cs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:tr(Yd).replace("hr",oo).replace("heading",` *#{1,6} *[^
|
|
332
332
|
]`).replace("lheading",Zv).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},N7=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,I7=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ov=/^( {2,}|\\)\n(?!\s*$)/,q7=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Xa=/[\p{P}\p{S}]/u,Cc=/[\s\p{P}\p{S}]/u,Qd=/[^\s\p{P}\p{S}]/u,M7=tr(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Cc).getRegex(),ey=/(?!~)[\p{P}\p{S}]/u,D7=/(?!~)[\s\p{P}\p{S}]/u,L7=/(?:[^\s\p{P}\p{S}]|~)/u,F7=tr(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",v7?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ty=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,j7=tr(ty,"u").replace(/punct/g,Xa).getRegex(),B7=tr(ty,"u").replace(/punct/g,ey).getRegex(),ry="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",P7=tr(ry,"gu").replace(/notPunctSpace/g,Qd).replace(/punctSpace/g,Cc).replace(/punct/g,Xa).getRegex(),U7=tr(ry,"gu").replace(/notPunctSpace/g,L7).replace(/punctSpace/g,D7).replace(/punct/g,ey).getRegex(),H7=tr("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Qd).replace(/punctSpace/g,Cc).replace(/punct/g,Xa).getRegex(),V7=tr(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Xa).getRegex(),W7="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Y7=tr(W7,"gu").replace(/notPunctSpace/g,Qd).replace(/punctSpace/g,Cc).replace(/punct/g,Xa).getRegex(),G7=tr(/\\(punct)/,"gu").replace(/punct/g,Xa).getRegex(),K7=tr(/^<(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(),X7=tr(Kd).replace("(?:-->|$)","-->").getRegex(),Q7=tr("^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",X7).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Iu=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Z7=tr(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Iu).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ny=tr(/^!?\[(label)\]\[(ref)\]/).replace("label",Iu).replace("ref",Gd).getRegex(),iy=tr(/^!?\[(ref)\](?:\[\])?/).replace("ref",Gd).getRegex(),J7=tr("reflink|nolink(?!\\()","g").replace("reflink",ny).replace("nolink",iy).getRegex(),b_=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Zd={_backpedal:Cs,anyPunctuation:G7,autolink:K7,blockSkip:F7,br:Ov,code:I7,del:Cs,delLDelim:Cs,delRDelim:Cs,emStrongLDelim:j7,emStrongRDelimAst:P7,emStrongRDelimUnd:H7,escape:N7,link:Z7,nolink:iy,punctuation:M7,reflink:ny,reflinkSearch:J7,tag:Q7,text:q7,url:Cs},O7={...Zd,link:tr(/^!?\[(label)\]\((.*?)\)/).replace("label",Iu).getRegex(),reflink:tr(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Iu).getRegex()},r0={...Zd,emStrongRDelimAst:U7,emStrongLDelim:B7,delLDelim:V7,delRDelim:Y7,url:tr(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",b_).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\S]|[^\s~\\]))\1(?=[^~]|$)/,text:tr(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",b_).getRegex()},ex={...r0,br:tr(Ov).replace("{2,}","*").getRegex(),text:tr(r0.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Fo={normal:Xd,gfm:R7,pedantic:z7},sl={normal:Zd,gfm:r0,breaks:ex,pedantic:O7},tx={"&":"&","<":"<",">":">",'"':""","'":"'"},x_=e=>tx[e];function si(e,t){if(t){if(Or.escapeTest.test(e))return e.replace(Or.escapeReplace,x_)}else if(Or.escapeTestNoEncode.test(e))return e.replace(Or.escapeReplaceNoEncode,x_);return e}function w_(e){try{e=encodeURI(e).replace(Or.percentDecode,"%")}catch{return null}return e}function k_(e,t){let r=e.replace(Or.findPipe,(s,o,f)=>{let h=!1,d=o;for(;--d>=0&&f[d]==="\\";)h=!h;return h?"|":" |"}),n=r.split(Or.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(Or.slashPipe,"|");return n}function Hi(e,t,r){let n=e.length;if(n===0)return"";let i=0;for(;i<n&&e.charAt(n-i-1)===t;)i++;return e.slice(0,n-i)}function S_(e){let t=e.split(`
|
|
333
333
|
`),r=t.length-1;for(;r>=0&&Or.blankLine.test(t[r]);)r--;return t.length-r<=2?e:t.slice(0,r+1).join(`
|
|
334
334
|
`)}function rx(e,t){if(e.indexOf(t[1])===-1)return-1;let r=0;for(let n=0;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]===t[0])r++;else if(e[n]===t[1]&&(r--,r<0))return n;return r>0?-2:-1}function nx(e,t=0){let r=t,n="";for(let i of e)if(i===" "){let s=4-r%4;n+=" ".repeat(s),r+=s}else n+=i,r++;return n}function E_(e,t,r,n,i){let s=t.href,o=t.title||null,f=e[1].replace(i.other.outputLinkReplace,"$1");n.state.inLink=!0;let h={type:e[0].charAt(0)==="!"?"image":"link",raw:r,href:s,title:o,text:f,tokens:n.inlineTokens(f)};return n.state.inLink=!1,h}function ix(e,t,r){let n=e.match(r.other.indentCodeCompensation);if(n===null)return t;let i=n[1];return t.split(`
|
|
@@ -620,7 +620,7 @@ Your browser does not support the video tag.
|
|
|
620
620
|
`)}function my(e){const[t,r]=ft.useState(null),[n,i]=ft.useState(null);return ft.useEffect(()=>{let s=!1;return r(null),i(null),fetch(vs(e)).then(o=>o.arrayBuffer()).then(o=>{if(s)return;const f=new TextDecoder("windows-1252").decode(new Uint8Array(o));r(Tx(f))}).catch(o=>!s&&i(String(o.message||o))),()=>{s=!0}},[e]),{html:t,error:n}}function Rx({node:e}){const{html:t,error:r}=my(e.path);return r?ye.jsxs("div",{className:"error",children:["rtf: ",r]}):t==null?ye.jsx("div",{className:"loading",children:"reading RTF…"}):ye.jsxs("div",{className:"text",children:[e.title&&ye.jsx("h1",{className:"chapter-title",children:e.title}),e.description&&ye.jsx("p",{className:"chapter-subtitle",children:e.description}),ye.jsx("div",{className:"markup",dangerouslySetInnerHTML:{__html:t}})]})}function zx({chunk:e}){const{html:t,error:r}=my(e.path);return r?ye.jsxs("div",{className:"error",children:["rtf: ",r]}):t==null?ye.jsx("div",{className:"loading",children:"reading RTF…"}):ye.jsx("div",{className:"markup",dangerouslySetInnerHTML:{__html:t}})}function gy({path:e}){return ye.jsxs("div",{className:"office-fallback",children:[ye.jsxs("p",{children:["Legacy ",ye.jsx("code",{children:".doc"})," (Word 97–2003) isn’t rendered in the browser — the old binary format has no reliable client-side parser. Newer ",ye.jsx("code",{children:".docx"})," files render in full."]}),ye.jsxs("p",{children:[ye.jsx("a",{className:"descend",href:vs(e),download:!0,children:"⤓ Download the document"})," ","to open it in an office application."]})]})}function Nx({node:e}){return ye.jsxs("div",{className:"text",children:[e.title&&ye.jsx("h1",{className:"chapter-title",children:e.title}),e.description&&ye.jsx("p",{className:"chapter-subtitle",children:e.description}),ye.jsx(gy,{path:e.path})]})}function Ix({chunk:e}){return ye.jsx(gy,{path:e.path})}var Yr=Uint8Array,Sn=Uint16Array,eh=Int32Array,Tc=new Yr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Rc=new Yr([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),a0=new Yr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),vy=function(e,t){for(var r=new Sn(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];for(var i=new eh(r[30]),n=1;n<30;++n)for(var s=r[n];s<r[n+1];++s)i[s]=s-r[n]<<5|n;return{b:r,r:i}},yy=vy(Tc,2),by=yy.b,l0=yy.r;by[28]=258,l0[258]=28;var xy=vy(Rc,0),qx=xy.b,C_=xy.r,o0=new Sn(32768);for(var $r=0;$r<32768;++$r){var Vi=($r&43690)>>1|($r&21845)<<1;Vi=(Vi&52428)>>2|(Vi&13107)<<2,Vi=(Vi&61680)>>4|(Vi&3855)<<4,o0[$r]=((Vi&65280)>>8|(Vi&255)<<8)>>1}var hi=function(e,t,r){for(var n=e.length,i=0,s=new Sn(t);i<n;++i)e[i]&&++s[e[i]-1];var o=new Sn(t);for(i=1;i<t;++i)o[i]=o[i-1]+s[i-1]<<1;var f;if(r){f=new Sn(1<<t);var h=15-t;for(i=0;i<n;++i)if(e[i])for(var d=i<<4|e[i],A=t-e[i],z=o[e[i]-1]++<<A,L=z|(1<<A)-1;z<=L;++z)f[o0[z]>>h]=d}else for(f=new Sn(n),i=0;i<n;++i)e[i]&&(f[i]=o0[o[e[i]-1]++]>>15-e[i]);return f},ps=new Yr(288);for(var $r=0;$r<144;++$r)ps[$r]=8;for(var $r=144;$r<256;++$r)ps[$r]=9;for(var $r=256;$r<280;++$r)ps[$r]=7;for(var $r=280;$r<288;++$r)ps[$r]=8;var Zl=new Yr(32);for(var $r=0;$r<32;++$r)Zl[$r]=5;var Mx=hi(ps,9,0),Dx=hi(ps,9,1),Lx=hi(Zl,5,0),Fx=hi(Zl,5,1),k$=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},Xn=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(t&7)&r},S$=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(t&7)},th=function(e){return(e+7)/8|0},zc=function(e,t,r){return(t==null||t<0)&&(t=0),(r==null||r>e.length)&&(r=e.length),new Yr(e.subarray(t,r))},jx=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],wn=function(e,t,r){var n=new Error(t||jx[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,wn),!r)throw n;return n},Bx=function(e,t,r,n){var i=e.length,s=n?n.length:0;if(!i||t.f&&!t.l)return r||new Yr(0);var o=!r,f=o||t.i!=2,h=t.i;o&&(r=new Yr(i*3));var d=function(dt){var lt=r.length;if(dt>lt){var xt=new Yr(Math.max(lt*2,dt));xt.set(r),r=xt}},A=t.f||0,z=t.p||0,L=t.b||0,ne=t.l,ge=t.d,Q=t.m,F=t.n,Y=i*8;do{if(!ne){A=Xn(e,z,1);var pe=Xn(e,z+1,3);if(z+=3,pe)if(pe==1)ne=Dx,ge=Fx,Q=9,F=5;else if(pe==2){var be=Xn(e,z,31)+257,ue=Xn(e,z+10,15)+4,Ee=be+Xn(e,z+5,31)+1;z+=14;for(var O=new Yr(Ee),Ce=new Yr(19),$e=0;$e<ue;++$e)Ce[a0[$e]]=Xn(e,z+$e*3,7);z+=ue*3;for(var w=k$(Ce),Ae=(1<<w)-1,j=hi(Ce,w,1),$e=0;$e<Ee;){var de=j[Xn(e,z,Ae)];z+=de&15;var se=de>>4;if(se<16)O[$e++]=se;else{var V=0,Fe=0;for(se==16?(Fe=3+Xn(e,z,3),z+=2,V=O[$e-1]):se==17?(Fe=3+Xn(e,z,7),z+=3):se==18&&(Fe=11+Xn(e,z,127),z+=7);Fe--;)O[$e++]=V}}var ce=O.subarray(0,be),U=O.subarray(be);Q=k$(ce),F=k$(U),ne=hi(ce,Q,1),ge=hi(U,F,1)}else wn(1);else{var se=th(z)+4,ve=e[se-4]|e[se-3]<<8,Z=se+ve;if(Z>i){h&&wn(0);break}f&&d(L+ve),r.set(e.subarray(se,Z),L),t.b=L+=ve,t.p=z=Z*8,t.f=A;continue}if(z>Y){h&&wn(0);break}}f&&d(L+131072);for(var x=(1<<Q)-1,$=(1<<F)-1,l=z;;l=z){var V=ne[S$(e,z)&x],c=V>>4;if(z+=V&15,z>Y){h&&wn(0);break}if(V||wn(2),c<256)r[L++]=c;else if(c==256){l=z,ne=null;break}else{var p=c-254;if(c>264){var $e=c-257,_=Tc[$e];p=Xn(e,z,(1<<_)-1)+by[$e],z+=_}var S=ge[S$(e,z)&$],C=S>>4;S||wn(3),z+=S&15;var U=qx[C];if(C>3){var _=Rc[C];U+=S$(e,z)&(1<<_)-1,z+=_}if(z>Y){h&&wn(0);break}f&&d(L+131072);var ee=L+p;if(L<U){var Le=s-U,nt=Math.min(U,ee);for(Le+L<0&&wn(3);L<nt;++L)r[L]=n[Le+L]}for(;L<ee;++L)r[L]=r[L-U]}}t.l=ne,t.p=l,t.b=L,t.f=A,ne&&(A=1,t.m=Q,t.d=ge,t.n=F)}while(!A);return L!=r.length&&o?zc(r,0,L):r.subarray(0,L)},yi=function(e,t,r){r<<=t&7;var n=t/8|0;e[n]|=r,e[n+1]|=r>>8},al=function(e,t,r){r<<=t&7;var n=t/8|0;e[n]|=r,e[n+1]|=r>>8,e[n+2]|=r>>16},E$=function(e,t){for(var r=[],n=0;n<e.length;++n)e[n]&&r.push({s:n,f:e[n]});var i=r.length,s=r.slice();if(!i)return{t:ky,l:0};if(i==1){var o=new Yr(r[0].s+1);return o[r[0].s]=1,{t:o,l:1}}r.sort(function(Z,be){return Z.f-be.f}),r.push({s:-1,f:25001});var f=r[0],h=r[1],d=0,A=1,z=2;for(r[0]={s:-1,f:f.f+h.f,l:f,r:h};A!=i-1;)f=r[r[d].f<r[z].f?d++:z++],h=r[d!=A&&r[d].f<r[z].f?d++:z++],r[A++]={s:-1,f:f.f+h.f,l:f,r:h};for(var L=s[0].s,n=1;n<i;++n)s[n].s>L&&(L=s[n].s);var ne=new Sn(L+1),ge=u0(r[A-1],ne,0);if(ge>t){var n=0,Q=0,F=ge-t,Y=1<<F;for(s.sort(function(be,ue){return ne[ue.s]-ne[be.s]||be.f-ue.f});n<i;++n){var pe=s[n].s;if(ne[pe]>t)Q+=Y-(1<<ge-ne[pe]),ne[pe]=t;else break}for(Q>>=F;Q>0;){var se=s[n].s;ne[se]<t?Q-=1<<t-ne[se]++-1:++n}for(;n>=0&&Q;--n){var ve=s[n].s;ne[ve]==t&&(--ne[ve],++Q)}ge=t}return{t:new Yr(ne),l:ge}},u0=function(e,t,r){return e.s==-1?Math.max(u0(e.l,t,r+1),u0(e.r,t,r+1)):t[e.s]=r},T_=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new Sn(++t),n=0,i=e[0],s=1,o=function(h){r[n++]=h},f=1;f<=t;++f)if(e[f]==i&&f!=t)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=e[f]}return{c:r.subarray(0,n),n:t}},ll=function(e,t){for(var r=0,n=0;n<t.length;++n)r+=e[n]*t[n];return r},wy=function(e,t,r){var n=r.length,i=th(t+2);e[i]=n&255,e[i+1]=n>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var s=0;s<n;++s)e[i+s+4]=r[s];return(i+4+n)*8},R_=function(e,t,r,n,i,s,o,f,h,d,A){yi(t,A++,r),++i[256];for(var z=E$(i,15),L=z.t,ne=z.l,ge=E$(s,15),Q=ge.t,F=ge.l,Y=T_(L),pe=Y.c,se=Y.n,ve=T_(Q),Z=ve.c,be=ve.n,ue=new Sn(19),Ee=0;Ee<pe.length;++Ee)++ue[pe[Ee]&31];for(var Ee=0;Ee<Z.length;++Ee)++ue[Z[Ee]&31];for(var O=E$(ue,7),Ce=O.t,$e=O.l,w=19;w>4&&!Ce[a0[w-1]];--w);var Ae=d+5<<3,j=ll(i,ps)+ll(s,Zl)+o,de=ll(i,L)+ll(s,Q)+o+14+3*w+ll(ue,Ce)+2*ue[16]+3*ue[17]+7*ue[18];if(h>=0&&Ae<=j&&Ae<=de)return wy(t,A,e.subarray(h,h+d));var V,Fe,ce,U;if(yi(t,A,1+(de<j)),A+=2,de<j){V=hi(L,ne,0),Fe=L,ce=hi(Q,F,0),U=Q;var x=hi(Ce,$e,0);yi(t,A,se-257),yi(t,A+5,be-1),yi(t,A+10,w-4),A+=14;for(var Ee=0;Ee<w;++Ee)yi(t,A+3*Ee,Ce[a0[Ee]]);A+=3*w;for(var $=[pe,Z],l=0;l<2;++l)for(var c=$[l],Ee=0;Ee<c.length;++Ee){var p=c[Ee]&31;yi(t,A,x[p]),A+=Ce[p],p>15&&(yi(t,A,c[Ee]>>5&127),A+=c[Ee]>>12)}}else V=Mx,Fe=ps,ce=Lx,U=Zl;for(var Ee=0;Ee<f;++Ee){var _=n[Ee];if(_>255){var p=_>>18&31;al(t,A,V[p+257]),A+=Fe[p+257],p>7&&(yi(t,A,_>>23&31),A+=Tc[p]);var S=_&31;al(t,A,ce[S]),A+=U[S],S>3&&(al(t,A,_>>5&8191),A+=Rc[S])}else al(t,A,V[_]),A+=Fe[_]}return al(t,A,V[256]),A+Fe[256]},Px=new eh([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ky=new Yr(0),Ux=function(e,t,r,n,i,s){var o=s.z||e.length,f=new Yr(n+o+5*(1+Math.ceil(o/7e3))+i),h=f.subarray(n,f.length-i),d=s.l,A=(s.r||0)&7;if(t){A&&(h[0]=s.r>>3);for(var z=Px[t-1],L=z>>13,ne=z&8191,ge=(1<<r)-1,Q=s.p||new Sn(32768),F=s.h||new Sn(ge+1),Y=Math.ceil(r/3),pe=2*Y,se=function(bt){return(e[bt]^e[bt+1]<<Y^e[bt+2]<<pe)&ge},ve=new eh(25e3),Z=new Sn(288),be=new Sn(32),ue=0,Ee=0,O=s.i||0,Ce=0,$e=s.w||0,w=0;O+2<o;++O){var Ae=se(O),j=O&32767,de=F[Ae];if(Q[j]=de,F[Ae]=j,$e<=O){var V=o-O;if((ue>7e3||Ce>24576)&&(V>423||!d)){A=R_(e,h,0,ve,Z,be,Ee,Ce,w,O-w,A),Ce=ue=Ee=0,w=O;for(var Fe=0;Fe<286;++Fe)Z[Fe]=0;for(var Fe=0;Fe<30;++Fe)be[Fe]=0}var ce=2,U=0,x=ne,$=j-de&32767;if(V>2&&Ae==se(O-$))for(var l=Math.min(L,V)-1,c=Math.min(32767,O),p=Math.min(258,V);$<=c&&--x&&j!=de;){if(e[O+ce]==e[O+ce-$]){for(var _=0;_<p&&e[O+_]==e[O+_-$];++_);if(_>ce){if(ce=_,U=$,_>l)break;for(var S=Math.min($,_-2),C=0,Fe=0;Fe<S;++Fe){var ee=O-$+Fe&32767,Le=Q[ee],nt=ee-Le&32767;nt>C&&(C=nt,de=ee)}}}j=de,de=Q[j],$+=j-de&32767}if(U){ve[Ce++]=268435456|l0[ce]<<18|C_[U];var dt=l0[ce]&31,lt=C_[U]&31;Ee+=Tc[dt]+Rc[lt],++Z[257+dt],++be[lt],$e=O+ce,++ue}else ve[Ce++]=e[O],++Z[e[O]]}}for(O=Math.max(O,$e);O<o;++O)ve[Ce++]=e[O],++Z[e[O]];A=R_(e,h,d,ve,Z,be,Ee,Ce,w,O-w,A),d||(s.r=A&7|h[A/8|0]<<3,A-=7,s.h=F,s.p=Q,s.i=O,s.w=$e)}else{for(var O=s.w||0;O<o+d;O+=65535){var xt=O+65535;xt>=o&&(h[A/8|0]=d,xt=o),A=wy(h,A+1,e.subarray(O,xt))}s.i=o}return zc(f,0,n+th(A)+i)},Hx=function(e,t,r,n,i){if(!i&&(i={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),o=new Yr(s.length+e.length);o.set(s),o.set(e,s.length),e=o,i.w=s.length}return Ux(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,r,n,i)},ui=function(e,t){return e[t]|e[t+1]<<8},Dn=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},A$=function(e,t){return Dn(e,t)+Dn(e,t+4)*4294967296};function Vx(e,t){return Hx(e,t||{},0,0)}function Wx(e,t){return Bx(e,{i:2},t&&t.out,t&&t.dictionary)}var c0=typeof TextDecoder<"u"&&new TextDecoder,Yx=0;try{c0.decode(ky,{stream:!0}),Yx=1}catch{}var Gx=function(e){for(var t="",r=0;;){var n=e[r++],i=(n>127)+(n>223)+(n>239);if(r+i>e.length)return{s:t,r:zc(e,r-1)};i?i==3?(n=((n&15)<<18|(e[r++]&63)<<12|(e[r++]&63)<<6|e[r++]&63)-65536,t+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?t+=String.fromCharCode((n&31)<<6|e[r++]&63):t+=String.fromCharCode((n&15)<<12|(e[r++]&63)<<6|e[r++]&63):t+=String.fromCharCode(n)}};function $0(e,t){if(t){for(var r="",n=0;n<e.length;n+=16384)r+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return r}else{if(c0)return c0.decode(e);var i=Gx(e),s=i.s,r=i.r;return r.length&&wn(8),s}}var Kx=function(e,t){return t+30+ui(e,t+26)+ui(e,t+28)},Xx=function(e,t,r){var n=ui(e,t+28),i=ui(e,t+30),s=$0(e.subarray(t+46,t+46+n),!(ui(e,t+8)&2048)),o=t+46+n,f=Qx(e,o,i,r,Dn(e,t+20),Dn(e,t+24),Dn(e,t+42)),h=f[0],d=f[1],A=f[2];return[ui(e,t+10),h,d,s,o+i+ui(e,t+32),A]},Qx=function(e,t,r,n,i,s,o){var f=i==4294967295,h=s==4294967295,d=o==4294967295,A=t+r,z=f+h+d;if(n&&z){for(;t+4<A;t+=4+ui(e,t+2))if(ui(e,t)==1)return[f?A$(e,t+4+8*h):i,h?A$(e,t+4):s,d?A$(e,t+4+8*(h+f)):o,1];n<2&&wn(13)}return[i,s,o,0]};function Zx(e,t){for(var r={},n=e.length-22;Dn(e,n)!=101010256;--n)(!n||e.length-n>65558)&&wn(13);var i=ui(e,n+8);if(!i)return{};var s=Dn(e,n+16),o=Dn(e,n-20)==117853008;if(o){var f=Dn(e,n-12);o=Dn(e,f)==101075792,o&&(i=Dn(e,f+32),s=Dn(e,f+48))}for(var h=0;h<i;++h){var d=Xx(e,s,o),A=d[0],z=d[1],L=d[2],ne=d[3],ge=d[4],Q=d[5],F=Kx(e,Q);s=ge,A?A==8?r[ne]=Wx(e.subarray(F,F+z),{out:new Yr(L)}):wn(14,"unknown compression type "+A):r[ne]=zc(e,F,F+z)}return r}const Jx={},Ox=Jx?.VITE_PLANTUML_SERVER?.replace(/\/+$/,"")??"https://www.plantuml.com/plantuml";function jo(e){return e<10?String.fromCharCode(48+e):(e-=10,e<26?String.fromCharCode(65+e):(e-=26,e<26?String.fromCharCode(97+e):(e-=26,e===0?"-":e===1?"_":"?")))}function C$(e,t,r){const n=e>>2,i=(e&3)<<4|t>>4,s=(t&15)<<2|r>>6,o=r&63;return jo(n&63)+jo(i&63)+jo(s&63)+jo(o&63)}function ew(e){let t="";for(let r=0;r<e.length;r+=3)r+2===e.length?t+=C$(e[r],e[r+1],0):r+1===e.length?t+=C$(e[r],0,0):t+=C$(e[r],e[r+1],e[r+2]);return t}function tw(e){const t=Vx(new TextEncoder().encode(e),{level:9});return`${Ox}/svg/${ew(t)}`}function Sy({source:e}){return ye.jsx("div",{className:"filemedia",children:ye.jsx("img",{className:"fileimage plantuml",src:tw(e),alt:"PlantUML diagram"})})}function rw({node:e}){return ye.jsxs("div",{className:"text",children:[e.title&&ye.jsx("h1",{className:"chapter-title",children:e.title}),e.description&&ye.jsx("p",{className:"chapter-subtitle",children:e.description}),ye.jsx(Sy,{source:String(ys(e.value)??"")})]})}function nw({chunk:e}){return ye.jsx(Sy,{source:String(e.value??"")})}const iw={object:{glyph:"{}",cls:"t-struct"},array:{glyph:"[]",cls:"t-struct"},string:{glyph:"“”",cls:"t-str"},integer:{glyph:"#",cls:"t-num"},number:{glyph:"½",cls:"t-num"},boolean:{glyph:"◧",cls:"t-bool"},null:{glyph:"∅",cls:"t-null"},binary:{glyph:"0110",cls:"t-bin binsq"}},sw={"date-time":"🕑",date:"📅",time:"🕑",duration:"⏳",email:"✉️","idn-email":"✉️",hostname:"🖥️","idn-hostname":"🖥️",ipv4:"🌐",ipv6:"🌐",uri:"🔗",iri:"🔗","uri-reference":"🔗","iri-reference":"🔗","uri-template":"🔗",url:"🔗",uuid:"🆔",regex:"🔣","json-pointer":"📍","relative-json-pointer":"📍",password:"🔑",color:"🎨"};function aw(e){return e==="x-yamlover-chapter"?"§":e==="x-yamlover-tag"?"🏷️":e.startsWith("x-yamlover-")?"🧩":e==="application/pdf"?"📕":e==="application/x-fictionbook+xml"?"📘":e==="application/epub+zip"?"📗":e==="image/vnd.djvu"?"📓":e.startsWith("image/")?"🖼️":e==="text/markdown"?"📝":e==="text/asciidoc"?"📃":e==="text/csv"||e==="text/tab-separated-values"?"▦":e==="text/x-plantuml"?"📊":e==="application/vnd.ms-excel"||e==="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"?"▦":e==="application/rtf"||e==="application/msword"||e==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?"📄":e==="application/vnd.google-earth.kml+xml"||e==="application/vnd.google-earth.kmz"?"🗺️":e.startsWith("text/")?"📄":e.startsWith("audio/")?"🔊":e.startsWith("video/")?"🎬":/^(u?int|float)\d/.test(e)?"💾":null}function Du(e,t,r){if(t==="x-yamlover-fragment")return{glyph:"",cls:"t-fmt frag-icon",title:"fragment"};if(t){const i=sw[t]??aw(t);if(i)return{glyph:i,cls:"t-fmt",title:t}}if(r==="dir")return{glyph:"📁",cls:"t-struct",title:"folder"};if(r==="dir/yamlover")return{glyph:"🗂️",cls:"t-struct",title:"yamlover folder"};const n=iw[e];return n?{glyph:n.glyph,cls:n.cls,title:e}:{glyph:"•",cls:"t-bin",title:e||"unknown"}}const lw="x-yamlover-board",ow=new Set(["x-yamlover-tag","x-yamlover-workflow","x-yamlover-board"]);function uw(e){return e.format===lw?!0:Tn(e.value).some(([t])=>t==="workflow"||t==="lanes")}const cw=new Set(["cancelled","canceled","rejected","wontfix","won't-fix","dropped","declined","abandoned","duplicate","invalid"]),T$=e=>cw.has(e.toLowerCase()),R$=(e,t)=>{const r=Tn(e).find(([n])=>n===t)?.[1];return typeof r=="string"?r:typeof r=="number"?String(r):null},$w=e=>{const t=e.lastIndexOf(":");return t<0?e:e.slice(t+1)};function fw(e){return Bs(Tn(e.value).find(([t])=>t==="workflow")?.[1])}function dw(e){const t=Tn(e.value).find(([r])=>r==="lanes")?.[1];return Array.isArray(t)?t.map(r=>Array.isArray(r)?r.map(Bs).filter(n=>!!n):[]):null}const hw=new Set(["workflow","lanes","yamlover","tags"]);function pw(e){return rh(e).filter(t=>t.link&&!hw.has(t.key)).filter(t=>!(t.link.format&&ow.has(t.link.format))).map(t=>t.link.path)}function _w(e){const t=Tn(e).find(([i])=>i==="yamlover-annotations")?.[1],r=Array.isArray(t)?t:[],n=[];for(const i of r){const s=Bs(i)??Bs(Tn(i).find(([o])=>o==="tag")?.[1]);s&&n.push(s)}return n}function mw({node:e,onNavigate:t,openContextMenu:r}){const n=Va(Ys),[i,s]=ft.useState([]),[o,f]=ft.useState([]),[h,d]=ft.useState(null),[A,z]=ft.useState(null),[L,ne]=ft.useState(null),[ge,Q]=ft.useState(null),F=ft.useRef(null);ft.useEffect(()=>{let Ee=!1;return(async()=>{try{const O=fw(e),$e=Tn(e.value).some(([de])=>de==="lanes")?dw(await on(e.path,3)):null;let w=[];if($e)w=await Promise.all($e.map(async de=>({tags:await Promise.all(de.map(t0))})));else if(O){const de=(await p7(O)).filter(ce=>!ce.initial),V=de.filter(ce=>ce.next.length>0),Fe=de.filter(ce=>ce.next.length===0);Fe.sort((ce,U)=>Number(T$(ce.label))-Number(T$(U.label))),w=[...V.map(ce=>({tags:[ce]})),...Fe.length?[{tags:Fe}]:[]]}const Ae=pw(e),j=await Promise.all(Ae.map(async de=>{const V=await on(de,2);return{path:de,title:V.title??$w(de),priority:R$(V.value,"priority"),assignee:R$(V.value,"assignee"),due:R$(V.value,"due"),tags:_w(V.value)}}));if(Ee)return;s(w),f(j),d(null)}catch(O){Ee||d(String(O?.message||O))}})(),()=>{Ee=!0}},[e.path,n]);const Y=()=>i.map(Ee=>Ee.tags.map(O=>O.path)),pe=Ee=>{m4(e.path,Ee).catch(O=>d(String(O?.message||O)))},se=(Ee,O)=>{const Ce=Y();Ce[Ee]||(Ce[Ee]=[]),Ce[Ee].includes(O)||Ce[Ee].push(O),pe(Ce)},ve=(Ee,O)=>{const Ce=Y().map(($e,w)=>w===Ee?$e.filter(Ae=>Ae!==O):$e);pe(Ce)},Z=()=>pe([...Y(),[]]),be=Ee=>pe(Y().filter((O,Ce)=>Ce!==Ee)),ue=async Ee=>{const O=A;if(z(null),ne(null),!(!O||Ee===O.from))try{await Kv(O.task,O.from,Ee),f(Ce=>Ce.map($e=>$e.path===O.task?{...$e,tags:[...$e.tags.filter(w=>w!==O.from),Ee]}:$e))}catch(Ce){d(String(Ce?.message||Ce))}};return ft.useEffect(()=>{if(!ge)return;const Ee=O=>{F.current?.contains(O.target)||Q(null)};return document.addEventListener("mousedown",Ee),()=>document.removeEventListener("mousedown",Ee)},[ge]),h?ye.jsxs("div",{className:"board-error",children:["Board error: ",h]}):ye.jsxs("div",{className:"board",children:[i.map((Ee,O)=>{const Ce=Ee.tags[0]?Hn({name:Ee.tags[0].label,color:Ee.tags[0].color}):"#6c7086",$e=Ee.tags.reduce((w,Ae)=>w+o.filter(j=>j.tags.includes(Ae.path)).length,0);return ye.jsxs("section",{className:"board-col",children:[ye.jsxs("header",{className:"board-col-head",style:{borderTopColor:Ce},children:[ye.jsxs("div",{className:"board-col-tags",children:[Ee.tags.length===1&&ye.jsx(Au,{tag:{path:Ee.tags[0].path,name:Ee.tags[0].label,color:Ee.tags[0].color},children:ye.jsx("button",{type:"button",className:"tagtag on",style:Nf(Hn({name:Ee.tags[0].label,color:Ee.tags[0].color})),onClick:()=>ve(O,Ee.tags[0].path),children:ye.jsx("span",{className:"tt-label",children:Ee.tags[0].label})})}),ye.jsx("button",{className:"board-lane-add",title:Ee.tags.length===0?"set this lane's tag":"add a sublane",onClick:w=>Q({lane:O,x:w.clientX,y:w.clientY}),children:"+"})]}),ye.jsx("span",{className:"board-col-count",children:$e}),ye.jsx("button",{className:"board-lane-del",title:"remove this lane",onClick:()=>be(O),children:"🗑"})]}),ye.jsx("div",{className:"board-col-body",children:Ee.tags.map((w,Ae)=>{const j=o.filter(Fe=>Fe.tags.includes(w.path)),de=Hn({name:w.label,color:w.color}),V=T$(w.label);return ye.jsxs("div",{className:"board-group"+(Ae>0?" board-group-split":"")+(L===w.path?" board-group-over":""),onDragOver:Fe=>{A&&(Fe.preventDefault(),L!==w.path&&ne(w.path))},onDrop:Fe=>{Fe.preventDefault(),ue(w.path)},children:[Ee.tags.length>1&&ye.jsxs("div",{className:"board-group-head",children:[ye.jsx("span",{className:"board-group-dot",style:{background:de}}),ye.jsx("span",{className:"board-group-title",children:w.label}),ye.jsx("span",{className:"board-col-count",children:j.length}),ye.jsx("button",{className:"board-group-del",title:"remove this sublane",onClick:()=>ve(O,w.path),children:"✕"})]}),ye.jsx("div",{className:"board-group-cards",children:j.map(Fe=>ye.jsxs("article",{className:"board-card"+(V?" board-card-negative":""),draggable:!0,onDragStart:()=>z({task:Fe.path,from:w.path}),onDragEnd:()=>{z(null),ne(null)},onClick:()=>t(Fe.path),onContextMenu:r?ce=>{ce.preventDefault(),r(Fe.path,ce.clientX,ce.clientY)}:void 0,title:pi(Fe.path),style:{borderLeftColor:de},children:[ye.jsx("div",{className:"board-card-title",children:Fe.title}),ye.jsxs("div",{className:"board-card-meta",children:[Fe.priority&&ye.jsx("span",{className:"board-chip prio-"+Fe.priority,children:Fe.priority}),Fe.assignee&&ye.jsxs("span",{className:"board-chip board-assignee",children:["@",Fe.assignee]}),Fe.due&&ye.jsx("span",{className:"board-chip board-due",children:Fe.due.slice(0,10)})]})]},Fe.path))})]},w.path)})})]},O)}),ye.jsx("button",{className:"board-add-lane",title:"add a lane",onClick:Z,children:"+ lane"}),ge&&ye.jsx(xd,{menuRef:F,x:ge.x,y:ge.y,applied:[],mode:"create",onPick:Ee=>{se(ge.lane,Ee.path),Q(null)},onClose:()=>Q(null),title:pi(e.path)})]})}function gw(e){const t=e.link;return t?t.format?t.format.replace(/^x-yamlover-/,"").replace(/^.*\//,""):Pa(t.concrete)?"folder":t.type??t.kind??"":"scalar"}function vw(e){const t=e.link;if(!t)return"";if(typeof t.count=="number")return`${t.count} item${t.count===1?"":"s"}`;if(typeof t.size=="number"){const r=["B","KB","MB","GB"];let n=t.size,i=0;for(;n>=1024&&i<r.length-1;)n/=1024,i++;return`${i===0?n:n.toFixed(1)} ${r[i]}`}return""}function yw({members:e,onNavigate:t,openContextMenu:r}){const{seq:n,paths:i}=i3(Ys),[s,o]=ft.useState({}),f=e.map(d=>d.link?.path).filter(d=>!!d),h=f.join("|");return ft.useEffect(()=>{let d=!1;return Promise.all(f.map(A=>Wl(A).then(z=>[A,z]).catch(()=>[A,[]]))).then(A=>{d||o(Object.fromEntries(A))}),()=>{d=!0}},[h]),ft.useEffect(()=>{if(n===0)return;const d=f.filter(z=>i.some(L=>L===z||L.startsWith(z+":")));if(d.length===0)return;let A=!1;return Promise.all(d.map(z=>Wl(z).then(L=>[z,L]).catch(()=>[z,[]]))).then(z=>{A||o(L=>({...L,...Object.fromEntries(z)}))}),()=>{A=!0}},[n]),ye.jsx("div",{className:"detailsview",children:ye.jsxs("table",{className:"details",children:[ye.jsx("thead",{children:ye.jsxs("tr",{children:[ye.jsx("th",{className:"details-name",children:"Name"}),ye.jsx("th",{className:"details-kind",children:"Kind"}),ye.jsx("th",{className:"details-tags",children:"Tags"}),ye.jsx("th",{className:"details-size",children:"Size"})]})}),ye.jsxs("tbody",{children:[e.map((d,A)=>{const z=d.link;if(!z)return null;const L=Du(z.type??z.kind,z.format??null,z.concrete),ne=z.title??d.key,ge=s[z.path]??[];return ye.jsxs("tr",{className:"details-row",onClick:()=>t(z.path),onContextMenu:r&&!d.up?Q=>{Q.preventDefault(),r(z.path,Q.clientX,Q.clientY)}:void 0,title:pi(z.path),children:[ye.jsxs("td",{className:"details-name",children:[ye.jsx("span",{className:"details-icon "+L.cls,title:L.title,children:L.glyph}),ye.jsx("span",{className:"details-label",children:ne})]}),ye.jsx("td",{className:"details-kind",children:gw(d)}),ye.jsx("td",{className:"details-tags",children:ge.map((Q,F)=>{if(!Q.tag)return null;const Y=Hn({name:Q.tag.name,color:Q.tag.color});return ye.jsx(Au,{tag:Q.tag,children:_d(Q.tag.path)?ye.jsx(Sg,{color:Y,title:""}):ye.jsx("span",{className:"tagtag",style:{background:Y},children:Q.tag.name})},F)})}),ye.jsx("td",{className:"details-size",children:vw(d)})]},`${z.path}#${A}`)}),e.length===0&&ye.jsx("tr",{children:ye.jsx("td",{className:"details-empty",colSpan:4,children:"empty"})})]})]})})}const bw="x-yamlover-annotation",xw="$yamloverMixed",z_={large:256,thumbnails:512};function ww(e){return Object.entries(e??{}).map(([t,r])=>({key:t,link:Fr(r),up:!0})).filter(t=>t.link!=null)}function rh(e){const t=e.value;if(Array.isArray(t))return t.map((n,i)=>({key:`[${i}]`,link:Fr(n),raw:n}));if(!t||typeof t!="object")return[];const r=t[xw];return Object.keys(t).length===1&&r?.entries?r.entries.map((n,i)=>({key:n.key??`[${i}]`,link:Fr(n.value),raw:n.value})):Object.entries(t).map(([n,i])=>({key:n,link:Fr(i),raw:i}))}function kw(e){return[...ww(e.relations),...rh(e)]}function Sw(e,t){const r=rh(e).filter(i=>i.link?.format!==bw),n=new Set(r.map(i=>i.link?.path).filter(Boolean));for(const i of t)n.has(i.path)||r.push({key:$c(i.path,i.title),link:i});return r}function Ew(e,t){return e.format===Ws?Sw(e,t):kw(e)}function Aw(e){if(e==null)return"null";if(Array.isArray(e))return"array";const t=typeof e;return t==="object"?"object":t==="boolean"?"boolean":t==="number"?Number.isInteger(e)?"integer":"number":"string"}function N_(e){if(e==null)return"~";const t=String(e).split(`
|
|
621
621
|
`,1)[0];return t.length>80?t.slice(0,79)+"…":t}function Cw(e){return!!e&&(e.includes("/")||e.startsWith("x-yamlover-"))}function Tw(e,t,r,n){if(r==="ArrowRight")return Math.min(t+1,n-1);if(r==="ArrowLeft")return Math.max(t-1,0);if(r==="Home")return 0;if(r==="End")return n-1;const i=e[t];if(!i)return t;const s=i.getBoundingClientRect(),o=s.left+s.width/2,f=s.top+s.height/2,h=r==="ArrowDown";let d=t,A=1/0;for(let z=0;z<n;z++){const L=e[z];if(!L||z===t)continue;const ne=L.getBoundingClientRect(),ge=ne.left+ne.width/2,Q=ne.top+ne.height/2;if(h?Q<=f+1:Q>=f-1)continue;const F=Math.abs(ge-o)*2+Math.abs(Q-f);F<A&&(A=F,d=z)}return d}function Rw(e,t){if(e.preview)return pp(e.preview,t,t);const r=e.format??null;return!r||!r.startsWith("image/")?null:r==="image/svg+xml"?vs(e.path):pp(e.path,t,t)}function zw({link:e,glyph:t,box:r}){const[n,i]=ft.useState(!1),s=n?null:Rw(e,r);return s?ye.jsx("img",{className:"dirview-icon dirview-thumb",src:s,alt:"",loading:"lazy",onError:()=>i(!0)}):ye.jsx("span",{className:"dirview-icon "+t.cls,title:t.title,children:t.glyph})}function Nw({it:e,active:t,view:r,setRef:n,onFocus:i,onNavigate:s,onContext:o}){const f=e.link,h=t?0:-1,d=f&&!e.up&&o?{onContextMenu:ne=>{ne.preventDefault(),o(f.path,ne.clientX,ne.clientY)}}:{};if(!f){const ne=Du(Aw(e.raw),null);return ye.jsxs("span",{className:"dirview-item",ref:n,tabIndex:h,onFocus:i,children:[ye.jsx("span",{className:"dirview-icon "+ne.cls,title:ne.title,children:ne.glyph}),ye.jsxs("span",{className:"dirview-label",children:[e.key,": ",N_(e.raw)]})]})}const A=Du(f.type??f.kind,f.format??null,f.concrete),z=e.up?R4(e.key):f.title??e.key,L=f.format===Ws?ye.jsx("span",{className:"tagtag",style:{background:Hn({name:z,color:f.color})},children:z}):f.kind==="scalar"&&!Cw(f.format)?ye.jsxs(ye.Fragment,{children:[z,": ",ye.jsx("span",{className:"val",children:N_(f.value)})]}):z;return ye.jsxs("a",{className:"dirview-item"+(e.up?" dirview-up":""),href:f.path,title:pi(f.path),ref:n,tabIndex:h,onFocus:i,onClick:ne=>{ne.preventDefault(),s(f.path)},...d,children:[z_[r]&&!e.up?ye.jsx(zw,{link:f,glyph:A,box:z_[r]}):ye.jsx("span",{className:"dirview-icon "+A.cls,title:A.title,children:A.glyph}),ye.jsx("span",{className:"dirview-label",children:L})]})}function Iw({node:e,view:t,onNavigate:r}){const n=e.format===Ws,[i,s]=ft.useState([]),o=Va(Ys),{openAt:f,tagMenu:h}=wd();ft.useEffect(()=>{if(s([]),!n)return;let pe=!1;return d4(e.path).then(se=>{pe||s(se.map(Fr).filter(ve=>ve!=null))}).catch(()=>{}),()=>{pe=!0}},[e.path,n,o]);const d=Ew(e,i),A=ft.useRef(null),z=ft.useRef([]);z.current.length=d.length;const[L,ne]=ft.useState(0);ft.useEffect(()=>{L>d.length-1&&ne(Math.max(0,d.length-1))},[d.length,L]);const ge=ft.useRef(!0);ft.useEffect(()=>{ne(0),ge.current=!0},[e.path]),ft.useEffect(()=>{!ge.current||!d.length||(ge.current=!1,!A.current?.closest(".chunk-body")&&z.current[0]?.focus({preventScroll:!0}))},[d.length,e.path]);const Q=pe=>{if(pe.ctrlKey||pe.altKey||pe.metaKey||!d.length)return;if(pe.key==="Enter"){const ve=d[L]?.link;ve&&(pe.preventDefault(),r(ve.path));return}if(!/^(Arrow(Up|Down|Left|Right)|Home|End)$/.test(pe.key))return;pe.preventDefault();const se=Tw(z.current,L,pe.key,d.length);se!==L&&(ne(se),z.current[se]?.focus())};if(t==="board")return ye.jsxs(ye.Fragment,{children:[h,ye.jsx(mw,{node:e,onNavigate:r,openContextMenu:f})]});if(t==="details")return ye.jsxs(ye.Fragment,{children:[h,ye.jsx(yw,{members:d,onNavigate:r,openContextMenu:f})]});const F=(n?Ag(e.value):null)??e.description,Y="dirview"+(t!=="small"?" dirview-lg":"")+(t==="thumbnails"?" dirview-thumbs":"");return ye.jsxs("div",{className:"explorerview",children:[h,F&&ye.jsx("div",{className:"dirhead",children:ye.jsx("p",{className:"tagdesc",children:F})}),ye.jsxs("div",{ref:A,className:Y,onKeyDown:Q,children:[d.map((pe,se)=>ye.jsx(Nw,{it:pe,active:se===L,view:t,setRef:ve=>{z.current[se]=ve},onFocus:()=>ne(se),onNavigate:r,onContext:f},`${pe.up?"^":""}${pe.link?.path??pe.key}#${se}`)),d.length===0&&ye.jsx("span",{className:"dirview-empty",children:"empty"})]})]})}const Ey="http://www.w3.org/1999/xlink",qw=new RegExp("[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F]","g");function Mw(e){const t=new Uint8Array(e),n=(new TextDecoder("latin1").decode(t.subarray(0,256)).match(/encoding=["']([^"']+)["']/i)?.[1]||"utf-8").toLowerCase();let i;try{i=new TextDecoder(n).decode(t)}catch{i=new TextDecoder("utf-8").decode(t)}return i.replace(qw,"")}function Dw(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Ay(e,t){if(e.nodeType===3)return Dw(e.textContent||"");if(e.nodeType!==1)return"";const r=e,n=()=>Array.from(r.childNodes).map(i=>Ay(i,t)).join("");switch(r.localName){case"section":return`<section class="fb2-section">${n()}</section>`;case"title":return`<div class="fb2-title">${n()}</div>`;case"subtitle":return`<p class="fb2-subtitle">${n()}</p>`;case"p":return`<p>${n()}</p>`;case"empty-line":return"<br/>";case"emphasis":return`<em>${n()}</em>`;case"strong":return`<strong>${n()}</strong>`;case"strikethrough":return`<s>${n()}</s>`;case"sub":return`<sub>${n()}</sub>`;case"sup":return`<sup>${n()}</sup>`;case"code":return`<code>${n()}</code>`;case"epigraph":case"cite":return`<blockquote class="fb2-cite">${n()}</blockquote>`;case"text-author":return`<p class="fb2-text-author">${n()}</p>`;case"poem":return`<div class="fb2-poem">${n()}</div>`;case"stanza":return`<div class="fb2-stanza">${n()}</div>`;case"v":return`<div class="fb2-v">${n()}</div>`;case"a":return`<span class="fb2-a">${n()}</span>`;case"image":{const i=r.getAttributeNS(Ey,"href")||r.getAttribute("l:href")||r.getAttribute("href")||"",s=t.get(i.replace(/^#/,""));return s?`<img class="fb2-img" src="${s}" alt=""/>`:""}case"title-info":case"description":case"binary":return"";default:return n()}}function I_({node:e}){const[t,r]=ft.useState(null),[n,i]=ft.useState(null);return ft.useEffect(()=>{let s=!1;return r(null),i(null),fetch(vs(e.path)).then(o=>o.arrayBuffer()).then(o=>{if(s)return;const f=new DOMParser().parseFromString(Mw(o),"application/xml"),h=f.getElementsByTagName("parsererror")[0];if(h)throw new Error(h.textContent?.trim().split(`
|
|
622
622
|
`)[0]||"invalid FB2 XML");const d=new Map;for(const se of Array.from(f.getElementsByTagNameNS("*","binary"))){const ve=se.getAttribute("id");if(ve){const Z=se.getAttribute("content-type")||"image/jpeg";d.set(ve,`data:${Z};base64,${(se.textContent||"").replace(/\s+/g,"")}`)}}const A=f.getElementsByTagNameNS("*","title-info")[0],z=(se,ve)=>se?.getElementsByTagNameNS("*",ve)[0]?.textContent?.trim()||"",L=z(A,"book-title")||void 0,ne=A&&Array.from(A.getElementsByTagNameNS("*","author")).map(se=>[z(se,"first-name"),z(se,"middle-name"),z(se,"last-name")].filter(Boolean).join(" ")||z(se,"nickname")).filter(Boolean).join(", "),ge=A?.getElementsByTagNameNS("*","coverpage")[0]?.getElementsByTagNameNS("*","image")[0],Q=(ge?.getAttributeNS(Ey,"href")||ge?.getAttribute("l:href")||"").replace(/^#/,""),F=Array.from(f.getElementsByTagNameNS("*","body")),Y=F.find(se=>se.getAttribute("name")!=="notes")||F[0],pe=Y?Array.from(Y.childNodes).map(se=>Ay(se,d)).join(""):"";r({title:L,author:ne||void 0,cover:Q?d.get(Q):void 0,html:pe})}).catch(o=>!s&&i(String(o.message||o))),()=>{s=!0}},[e.path]),n?ye.jsxs("div",{className:"error",children:["fb2: ",n]}):t?ye.jsxs("div",{className:"text fb2",children:[t.cover&&ye.jsx("img",{className:"fb2-cover",src:t.cover,alt:""}),t.title&&ye.jsx("h1",{className:"chapter-title",children:t.title}),t.author&&ye.jsx("p",{className:"chapter-subtitle",children:t.author}),ye.jsx("div",{className:"markup fb2-body",dangerouslySetInnerHTML:{__html:t.html}})]}):ye.jsx("div",{className:"loading",children:"loading FB2…"})}const q_="http://www.w3.org/1999/xlink";function z$(e,t){t=decodeURIComponent(t.split("#")[0].split("?")[0]);const r=(e?e.split("/"):[]).concat(t.split("/")),n=[];for(const i of r)i===""||i==="."||(i===".."?n.pop():n.push(i));return n.join("/")}function M_(e){const t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}function D_({node:e}){const[t,r]=ft.useState(null),[n,i]=ft.useState(null);return ft.useEffect(()=>{let s=!1;const o=[];return r(null),i(null),fetch(vs(e.path)).then(f=>f.arrayBuffer()).then(f=>{if(s)return;const h=Zx(new Uint8Array(f)),d=ue=>h[ue]?$0(h[ue]):"",A=ue=>new DOMParser().parseFromString(d(ue),"application/xml"),z=A("META-INF/container.xml").getElementsByTagNameNS("*","rootfile")[0]?.getAttribute("full-path");if(!z||!h[z])throw new Error("no OPF package document");const L=A(z),ne=M_(z),ge=new Map,Q=(ue,Ee="")=>{if(!h[ue])return"";const O=ge.get(ue);if(O)return O;const Ce=URL.createObjectURL(new Blob([h[ue]],{type:Ee}));return ge.set(ue,Ce),o.push(Ce),Ce},F=L.getElementsByTagNameNS("*","title")[0]?.textContent?.trim(),Y=Array.from(L.getElementsByTagNameNS("*","creator")).map(ue=>ue.textContent?.trim()).filter(Boolean).join(", "),pe=new Map;for(const ue of Array.from(L.getElementsByTagNameNS("*","item"))){const Ee=ue.getAttribute("id"),O=ue.getAttribute("href");Ee&&O&&pe.set(Ee,{path:z$(ne,O),type:ue.getAttribute("media-type")||""})}const se=Array.from(L.getElementsByTagNameNS("*","meta")).find(ue=>ue.getAttribute("name")==="cover")?.getAttribute("content"),ve=se?pe.get(se):void 0,Z=ve?Q(ve.path,ve.type):void 0,be=[];for(const ue of Array.from(L.getElementsByTagNameNS("*","itemref"))){const Ee=pe.get(ue.getAttribute("idref")||"");if(!Ee||!/html/.test(Ee.type)||!h[Ee.path])continue;const O=M_(Ee.path),$e=new DOMParser().parseFromString($0(h[Ee.path]),"text/html").body;if($e){$e.querySelectorAll("script, style, link").forEach(w=>w.remove());for(const w of Array.from($e.querySelectorAll("img"))){const Ae=w.getAttribute("src"),j=Ae?Q(z$(O,Ae)):"";j?w.setAttribute("src",j):w.removeAttribute("src")}for(const w of Array.from($e.querySelectorAll("image"))){const Ae=w.getAttributeNS(q_,"href")||w.getAttribute("href")||w.getAttribute("xlink:href"),j=Ae?Q(z$(O,Ae)):"";j&&w.setAttributeNS(q_,"xlink:href",j)}be.push(`<section class="epub-doc">${$e.innerHTML}</section>`)}}if(s){o.forEach(URL.revokeObjectURL);return}r({title:F,author:Y||void 0,cover:Z,html:be.join(`
|
|
623
|
-
`)})}).catch(f=>!s&&i(String(f.message||f))),()=>{s=!0,o.forEach(URL.revokeObjectURL)}},[e.path]),n?ye.jsxs("div",{className:"error",children:["epub: ",n]}):t?ye.jsxs("div",{className:"text epub",children:[t.cover&&ye.jsx("img",{className:"fb2-cover",src:t.cover,alt:""}),t.title&&ye.jsx("h1",{className:"chapter-title",children:t.title}),t.author&&ye.jsx("p",{className:"chapter-subtitle",children:t.author}),ye.jsx("div",{className:"markup epub-body",dangerouslySetInnerHTML:{__html:t.html}})]}):ye.jsx("div",{className:"loading",children:"unpacking EPUB…"})}function L_({node:e}){return ye.jsx("iframe",{className:"filehtml",src:vs(e.path),sandbox:"allow-same-origin",title:e.title??pi(e.path)})}const F_=ft.lazy(()=>In(()=>import("./pdf-C-kvASQl.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.PdfView}))),j_=ft.lazy(()=>In(()=>import("./djvu-CbL4_9ak.js"),__vite__mapDeps([3,1])).then(e=>({default:e.DjvuView}))),B_=ft.lazy(()=>In(()=>import("./psd-KxbPOIwA.js"),__vite__mapDeps([4,5,6,7,8])).then(e=>({default:e.PsdView}))),P_=ft.lazy(()=>In(()=>import("./tiff-sq_Q9sNj.js"),__vite__mapDeps([9,10,5,6,7,8])).then(e=>({default:e.TiffView}))),U_=ft.lazy(()=>In(()=>import("./heic-BvS6Unla.js"),__vite__mapDeps([11,5,6,7,8])).then(e=>({default:e.HeicView}))),Lw=ft.lazy(()=>In(()=>import("./docx-CCEuxO9n.js"),__vite__mapDeps([12,10])).then(e=>({default:e.DocxView}))),Fw=ft.lazy(()=>In(()=>import("./docx-CCEuxO9n.js"),__vite__mapDeps([12,10])).then(e=>({default:e.DocxChunk}))),jw=ft.lazy(()=>In(()=>import("./spreadsheet-DkG5umsc.js"),[]).then(e=>({default:e.SpreadsheetView}))),Bw=ft.lazy(()=>In(()=>import("./spreadsheet-DkG5umsc.js"),[]).then(e=>({default:e.SpreadsheetChunk}))),Pw=ft.lazy(()=>In(()=>import("./map-BfHrzAqt.js"),__vite__mapDeps([13,7,8])).then(e=>({default:e.MapView}))),Uw=ft.lazy(()=>In(()=>import("./map-BfHrzAqt.js"),__vite__mapDeps([13,7,8])).then(e=>({default:e.MapChunk}))),Hw=ft.lazy(()=>In(()=>import("./imagemap-DBji1qL1.js"),__vite__mapDeps([6,7,8])).then(e=>({default:e.ImageView}))),Vw=ft.lazy(()=>In(()=>import("./imagemap-DBji1qL1.js"),__vite__mapDeps([6,7,8])).then(e=>({default:e.ImageChunk}))),Pr=e=>ye.jsx(ft.Suspense,{fallback:ye.jsx("div",{className:"loading",children:"…"}),children:e}),Wi=e=>({path:e.path,type:e.type,format:e.format,concrete:null,title:null,description:null,value:e.value}),Ww=e=>({valueType:e.valueType??null,format:e.format??null,hasKeyed:!!e.hasKeyed,hasOrdinal:!!e.hasOrdinal}),dr=(...e)=>t=>t.format!==null&&e.includes(t.format),hl=(e,t,r,n)=>({name:e,label:t,icon:r,accepts:dr("x-yamlover-tag","x-yamlover-board"),specificity:2,render:(i,s)=>ye.jsx(Iw,{node:i,view:n,onNavigate:s})}),Cy=hl("tag-board","tag board","▥","board"),f0=[hl("thumbnails","thumbnails","🖼️","thumbnails"),hl("large-icons","large icons","⊞","large"),hl("small-icons","small icons","∷","small"),hl("details","details","☰","details")],Ea=f0.find(e=>e.name==="large-icons"),Ty=[{name:"settings",icon:"⚙️",accepts:dr("x-yamlover-config"),specificity:2,render:()=>ye.jsx(g7,{})},{name:"chapter",icon:"§",accepts:dr("x-yamlover-chapter"),specificity:2,depth:1,tocView:H_,render:(e,t)=>ye.jsx(Hv,{node:e,onNavigate:t}),config:e=>ye.jsx(Do,{rerender:e})},{name:"task",icon:"☑",accepts:dr("x-yamlover-task"),specificity:2,depth:1,tocView:H_,render:(e,t)=>ye.jsx(m7,{node:e,onNavigate:t}),config:e=>ye.jsx(Do,{rerender:e})},{name:"marklower",icon:"✍",accepts:e=>e.format==="text/marklower"||e.format===null&&e.valueType==="string",specificity:1,render:(e,t)=>ye.jsx(D6,{node:e,onNavigate:t}),renderChunk:(e,t)=>ye.jsx(L6,{chunk:e,onNavigate:t})},{name:"markdown",icon:"📝",accepts:dr("text/markdown"),specificity:2,render:(e,t)=>ye.jsx(ox,{node:e,onNavigate:t}),renderChunk:(e,t)=>ye.jsx(ux,{chunk:e,onNavigate:t}),config:e=>ye.jsx(Do,{rerender:e})},{name:"asciidoc",icon:"📃",accepts:dr("text/asciidoc"),specificity:2,render:(e,t)=>ye.jsx(hx,{node:e,onNavigate:t}),renderChunk:(e,t)=>ye.jsx(px,{chunk:e,onNavigate:t}),config:e=>ye.jsx(Do,{rerender:e})},{name:"csv",icon:"▦",accepts:dr("text/csv","text/tab-separated-values"),specificity:2,render:e=>ye.jsx(gx,{node:e}),renderChunk:e=>ye.jsx(yx,{chunk:e}),config:e=>ye.jsx(vx,{rerender:e})},{name:"plaintext",icon:"🗒️",accepts:dr("text/plain"),specificity:2,render:e=>ye.jsx(xx,{node:e}),renderChunk:e=>ye.jsx(wx,{chunk:e}),config:e=>ye.jsx(kx,{rerender:e})},{name:"rtf",icon:"📄",accepts:dr("application/rtf"),specificity:2,render:e=>ye.jsx(Rx,{node:e}),renderChunk:e=>ye.jsx(zx,{chunk:e})},{name:"docx",icon:"📄",accepts:dr("application/vnd.openxmlformats-officedocument.wordprocessingml.document"),specificity:2,render:e=>Pr(ye.jsx(Lw,{node:e})),renderChunk:e=>Pr(ye.jsx(Fw,{chunk:e}))},{name:"spreadsheet",icon:"▦",accepts:dr("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"),specificity:2,render:e=>Pr(ye.jsx(jw,{node:e})),renderChunk:e=>Pr(ye.jsx(Bw,{chunk:e}))},{name:"doc",icon:"📄",accepts:dr("application/msword"),specificity:2,render:e=>ye.jsx(Nx,{node:e}),renderChunk:e=>ye.jsx(Ix,{chunk:e})},{name:"map",icon:"🗺️",accepts:dr("application/vnd.google-earth.kml+xml","application/vnd.google-earth.kmz"),specificity:2,render:e=>Pr(ye.jsx(Pw,{node:e})),renderChunk:(e,t)=>Pr(ye.jsx(Uw,{chunk:e,onNavigate:t}))},{name:"latex",icon:"∑",accepts:dr("text/x-latex"),specificity:2,render:e=>ye.jsx(R6,{node:e}),renderChunk:e=>ye.jsx(z6,{chunk:e})},{name:"plantuml",icon:"📊",accepts:dr("text/x-plantuml"),specificity:2,render:e=>ye.jsx(rw,{node:e}),renderChunk:e=>ye.jsx(nw,{chunk:e})},Ea,{name:"image",icon:"🖼️",accepts:dr("image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/x-icon","image/svg+xml"),specificity:2,render:e=>Pr(ye.jsx(Hw,{node:e})),renderChunk:(e,t)=>Pr(ye.jsx(Vw,{chunk:e,onNavigate:t}))},{name:"html",icon:"🌐",accepts:dr("text/html"),specificity:2,render:e=>ye.jsx(L_,{node:e}),renderChunk:e=>ye.jsx(L_,{node:Wi(e)})},{name:"fb2",icon:"📘",accepts:dr("application/x-fictionbook+xml"),specificity:2,render:e=>ye.jsx(I_,{node:e}),renderChunk:e=>ye.jsx(I_,{node:Wi(e)})},{name:"epub",icon:"📗",accepts:dr("application/epub+zip"),specificity:2,render:e=>ye.jsx(D_,{node:e}),renderChunk:e=>ye.jsx(D_,{node:Wi(e)})},{name:"pdf",icon:"📕",accepts:dr("application/pdf"),specificity:2,render:e=>Pr(ye.jsx(F_,{node:e})),renderChunk:e=>Pr(ye.jsx(F_,{node:Wi(e)}))},{name:"djvu",icon:"📓",accepts:dr("image/vnd.djvu"),specificity:2,render:e=>Pr(ye.jsx(j_,{node:e})),renderChunk:e=>Pr(ye.jsx(j_,{node:Wi(e)}))},{name:"psd",icon:"🎨",accepts:dr("image/vnd.adobe.photoshop"),specificity:2,render:e=>Pr(ye.jsx(B_,{node:e})),renderChunk:(e,t)=>Pr(ye.jsx(B_,{node:Wi(e),chunk:{onNavigate:t}}))},{name:"tiff",icon:"🖼️",accepts:dr("image/tiff"),specificity:2,render:e=>Pr(ye.jsx(P_,{node:e})),renderChunk:(e,t)=>Pr(ye.jsx(P_,{node:Wi(e),chunk:{onNavigate:t}}))},{name:"heic",icon:"🖼️",accepts:dr("image/heic"),specificity:2,render:e=>Pr(ye.jsx(U_,{node:e})),renderChunk:(e,t)=>Pr(ye.jsx(U_,{node:Wi(e),chunk:{onNavigate:t}}))}];function H_(e){if(e.children.length===0)return{children:[],expandable:e.hasChildren,loaded:!1,loadDepth:2};const t=e.children.filter(r=>Hd(r.format));return{children:t,expandable:t.length>0,loaded:!0,loadDepth:2}}function Qa(e){const t=Ww(e);let r=null;for(const n of Ty)n.accepts(t)&&(r===null||n.specificity>r.specificity)&&(r=n);return r}function Yw(e){return uw(e)?[Cy,...f0]:f0}function N$(e){const t=[],r=Qa(e);return r&&r!==Ea&&t.push(r),(r===Ea||Kw(e))&&t.push(...Yw(e)),t}const Gw=new Set(["object","array","mixed","variant"]),Ry=e=>!!e.type&&Gw.has(e.type);function Kw(e){const t=e.concrete;return(Pa(t)||ec(t)||pg(t))&&Ry(e)}const V_=Ty.find(e=>e.name==="plaintext");function I$(e){return Pa(e.concrete)||Qa(e)===V_||!(ec(e.concrete)||pg(e.concrete)||e.format==="text/markdown"||e.format==="text/asciidoc")?null:dg(e.concrete)||typeof ys(e.value)=="string"?V_:null}function tu(e,t){const r=Qa(e);return r&&r!==Ea?r.name:r===Ea||Pa(t)&&Ry(e)?e.format==="x-yamlover-board"?Cy.name:Ea.name:null}function zy(e){const t=Qa(e);if(t?.tocView)return t.tocView(e);const r=e.children.length>0;return{children:e.children,expandable:r?e.children.length>0:e.hasChildren,loaded:r}}const Xw=ft.memo(function e({node:t,current:r,onSelect:n,onLoadChildren:i,onContext:s,depth:o=0}){const{children:f,expandable:h,loaded:d,loadDepth:A}=zy(t),[z,L]=ft.useState(f.length>0),[ne,ge]=ft.useState(!1),Q=t.path===r,F=Sl(t.path,r),Y=ft.useRef(null);ft.useEffect(()=>{F&&L(!0)},[F]),ft.useEffect(()=>{Q&&Y.current?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[Q]);const pe=Du(t.type,t.format,t.concrete),se=z&&pe.glyph==="📁"?"📂":pe.glyph,ve=async()=>{if(!z&&h&&!d){ge(!0);try{await i(t.path,A)}finally{ge(!1)}}L(Z=>!Z)};return ye.jsxs("div",{className:"tree-branch",children:[ye.jsxs("div",{ref:Y,className:"tree-row"+(Q?" selected":""),style:{paddingLeft:o*14+4},onContextMenu:s?Z=>{Z.preventDefault(),s(t,Z.clientX,Z.clientY)}:void 0,children:[h?ye.jsx("button",{className:"toggle"+(z?" open":"")+(ne?" loading":""),onClick:ve,"aria-label":z?"collapse":"expand",children:ye.jsx("span",{className:"chevron",children:"›"})}):ye.jsx("span",{className:"toggle leaf"}),ye.jsx("span",{className:"icon "+pe.cls,title:pe.title,children:se}),ye.jsx("span",{className:"tree-label",onClick:()=>n(t.path),title:`${pi(t.path)} (${t.type})`,children:t.label})]}),z&&f.map(Z=>ye.jsx(e,{node:Z,current:r,onSelect:n,onLoadChildren:i,onContext:s,depth:o+1},Z.path))]})});function Qw({tasks:e}){return e.length?ye.jsx("div",{className:"task-strip",children:e.map(t=>{const{done:r,total:n,message:i}=t.progress,s=t.state==="done"?100:n?Math.min(100,Math.floor(r/n*100)):null,o=n?`${r}/${n}`:t.state==="running"&&r>0?String(r):"";return ye.jsxs("span",{className:`task-chip ${t.state}`,title:t.error??i??t.label,children:[ye.jsxs("span",{className:"task-label",children:[t.label,o&&ye.jsxs("span",{className:"task-counts",children:[" ",o]}),t.state==="error"&&" — failed"]}),ye.jsx("span",{className:"task-bar",children:s!==null?ye.jsx("span",{className:"task-bar-fill",style:{width:`${s}%`}}):ye.jsx("span",{className:"task-bar-fill indeterminate"})})]},t.id)})}):null}function Zw(e){const t=/^(?:https?:\/\/)?(?:www\.)?arxiv\.org\/(?:abs|pdf|html)\/(.+?)(?:\.pdf)?(?:[?#][^\s]*)?$/i.exec(e.trim());if(!t)return null;const r=t[1];return/^(?:\d{4}\.\d{4,5}|[a-z-]+(?:\.[A-Z]{2})?\/\d{7})(?:v\d+)?$/.test(r)?{url:`https://arxiv.org/pdf/${r}`,name:`arxiv-${r.replace(/\//g,"-")}.pdf`}:null}function Jw(e){const t=/^(?:https?:\/\/)?(?:www\.|mobile\.)?(?:x\.com|twitter\.com)\/(\w{1,15})\/status(?:es)?\/(\d+)(?:[/?#][^\s]*)?$/i.exec(e.trim());return t?`https://twitter.com/${t[1]}/status/${t[2]}`:null}async function Ow(e){const t=await fetch(`https://publish.x.com/oembed?url=${encodeURIComponent(e)}&omit_script=true&dnt=true`);if(!t.ok)throw new Error(`oEmbed HTTP ${t.status}`);const r=await t.json(),i=new DOMParser().parseFromString((r.html??"").replace(/<br\s*\/?>/gi,`
|
|
623
|
+
`)})}).catch(f=>!s&&i(String(f.message||f))),()=>{s=!0,o.forEach(URL.revokeObjectURL)}},[e.path]),n?ye.jsxs("div",{className:"error",children:["epub: ",n]}):t?ye.jsxs("div",{className:"text epub",children:[t.cover&&ye.jsx("img",{className:"fb2-cover",src:t.cover,alt:""}),t.title&&ye.jsx("h1",{className:"chapter-title",children:t.title}),t.author&&ye.jsx("p",{className:"chapter-subtitle",children:t.author}),ye.jsx("div",{className:"markup epub-body",dangerouslySetInnerHTML:{__html:t.html}})]}):ye.jsx("div",{className:"loading",children:"unpacking EPUB…"})}function L_({node:e}){return ye.jsx("iframe",{className:"filehtml",src:vs(e.path),sandbox:"allow-same-origin",title:e.title??pi(e.path)})}const F_=ft.lazy(()=>In(()=>import("./pdf-DNh_WoxB.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.PdfView}))),j_=ft.lazy(()=>In(()=>import("./djvu-DTScSRBE.js"),__vite__mapDeps([3,1])).then(e=>({default:e.DjvuView}))),B_=ft.lazy(()=>In(()=>import("./psd-BODwPXZY.js"),__vite__mapDeps([4,5,6,7,8])).then(e=>({default:e.PsdView}))),P_=ft.lazy(()=>In(()=>import("./tiff-B7WRQzVg.js"),__vite__mapDeps([9,10,5,6,7,8])).then(e=>({default:e.TiffView}))),U_=ft.lazy(()=>In(()=>import("./heic-GGCTCDdl.js"),__vite__mapDeps([11,5,6,7,8])).then(e=>({default:e.HeicView}))),Lw=ft.lazy(()=>In(()=>import("./docx-CZ_-bbiw.js"),__vite__mapDeps([12,10])).then(e=>({default:e.DocxView}))),Fw=ft.lazy(()=>In(()=>import("./docx-CZ_-bbiw.js"),__vite__mapDeps([12,10])).then(e=>({default:e.DocxChunk}))),jw=ft.lazy(()=>In(()=>import("./spreadsheet-jmhwwLqI.js"),[]).then(e=>({default:e.SpreadsheetView}))),Bw=ft.lazy(()=>In(()=>import("./spreadsheet-jmhwwLqI.js"),[]).then(e=>({default:e.SpreadsheetChunk}))),Pw=ft.lazy(()=>In(()=>import("./map-B1r-13cZ.js"),__vite__mapDeps([13,7,8])).then(e=>({default:e.MapView}))),Uw=ft.lazy(()=>In(()=>import("./map-B1r-13cZ.js"),__vite__mapDeps([13,7,8])).then(e=>({default:e.MapChunk}))),Hw=ft.lazy(()=>In(()=>import("./imagemap-99Y1w9r3.js"),__vite__mapDeps([6,7,8])).then(e=>({default:e.ImageView}))),Vw=ft.lazy(()=>In(()=>import("./imagemap-99Y1w9r3.js"),__vite__mapDeps([6,7,8])).then(e=>({default:e.ImageChunk}))),Pr=e=>ye.jsx(ft.Suspense,{fallback:ye.jsx("div",{className:"loading",children:"…"}),children:e}),Wi=e=>({path:e.path,type:e.type,format:e.format,concrete:null,title:null,description:null,value:e.value}),Ww=e=>({valueType:e.valueType??null,format:e.format??null,hasKeyed:!!e.hasKeyed,hasOrdinal:!!e.hasOrdinal}),dr=(...e)=>t=>t.format!==null&&e.includes(t.format),hl=(e,t,r,n)=>({name:e,label:t,icon:r,accepts:dr("x-yamlover-tag","x-yamlover-board"),specificity:2,render:(i,s)=>ye.jsx(Iw,{node:i,view:n,onNavigate:s})}),Cy=hl("tag-board","tag board","▥","board"),f0=[hl("thumbnails","thumbnails","🖼️","thumbnails"),hl("large-icons","large icons","⊞","large"),hl("small-icons","small icons","∷","small"),hl("details","details","☰","details")],Ea=f0.find(e=>e.name==="large-icons"),Ty=[{name:"settings",icon:"⚙️",accepts:dr("x-yamlover-config"),specificity:2,render:()=>ye.jsx(g7,{})},{name:"chapter",icon:"§",accepts:dr("x-yamlover-chapter"),specificity:2,depth:1,tocView:H_,render:(e,t)=>ye.jsx(Hv,{node:e,onNavigate:t}),config:e=>ye.jsx(Do,{rerender:e})},{name:"task",icon:"☑",accepts:dr("x-yamlover-task"),specificity:2,depth:1,tocView:H_,render:(e,t)=>ye.jsx(m7,{node:e,onNavigate:t}),config:e=>ye.jsx(Do,{rerender:e})},{name:"marklower",icon:"✍",accepts:e=>e.format==="text/marklower"||e.format===null&&e.valueType==="string",specificity:1,render:(e,t)=>ye.jsx(D6,{node:e,onNavigate:t}),renderChunk:(e,t)=>ye.jsx(L6,{chunk:e,onNavigate:t})},{name:"markdown",icon:"📝",accepts:dr("text/markdown"),specificity:2,render:(e,t)=>ye.jsx(ox,{node:e,onNavigate:t}),renderChunk:(e,t)=>ye.jsx(ux,{chunk:e,onNavigate:t}),config:e=>ye.jsx(Do,{rerender:e})},{name:"asciidoc",icon:"📃",accepts:dr("text/asciidoc"),specificity:2,render:(e,t)=>ye.jsx(hx,{node:e,onNavigate:t}),renderChunk:(e,t)=>ye.jsx(px,{chunk:e,onNavigate:t}),config:e=>ye.jsx(Do,{rerender:e})},{name:"csv",icon:"▦",accepts:dr("text/csv","text/tab-separated-values"),specificity:2,render:e=>ye.jsx(gx,{node:e}),renderChunk:e=>ye.jsx(yx,{chunk:e}),config:e=>ye.jsx(vx,{rerender:e})},{name:"plaintext",icon:"🗒️",accepts:dr("text/plain"),specificity:2,render:e=>ye.jsx(xx,{node:e}),renderChunk:e=>ye.jsx(wx,{chunk:e}),config:e=>ye.jsx(kx,{rerender:e})},{name:"rtf",icon:"📄",accepts:dr("application/rtf"),specificity:2,render:e=>ye.jsx(Rx,{node:e}),renderChunk:e=>ye.jsx(zx,{chunk:e})},{name:"docx",icon:"📄",accepts:dr("application/vnd.openxmlformats-officedocument.wordprocessingml.document"),specificity:2,render:e=>Pr(ye.jsx(Lw,{node:e})),renderChunk:e=>Pr(ye.jsx(Fw,{chunk:e}))},{name:"spreadsheet",icon:"▦",accepts:dr("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"),specificity:2,render:e=>Pr(ye.jsx(jw,{node:e})),renderChunk:e=>Pr(ye.jsx(Bw,{chunk:e}))},{name:"doc",icon:"📄",accepts:dr("application/msword"),specificity:2,render:e=>ye.jsx(Nx,{node:e}),renderChunk:e=>ye.jsx(Ix,{chunk:e})},{name:"map",icon:"🗺️",accepts:dr("application/vnd.google-earth.kml+xml","application/vnd.google-earth.kmz"),specificity:2,render:e=>Pr(ye.jsx(Pw,{node:e})),renderChunk:(e,t)=>Pr(ye.jsx(Uw,{chunk:e,onNavigate:t}))},{name:"latex",icon:"∑",accepts:dr("text/x-latex"),specificity:2,render:e=>ye.jsx(R6,{node:e}),renderChunk:e=>ye.jsx(z6,{chunk:e})},{name:"plantuml",icon:"📊",accepts:dr("text/x-plantuml"),specificity:2,render:e=>ye.jsx(rw,{node:e}),renderChunk:e=>ye.jsx(nw,{chunk:e})},Ea,{name:"image",icon:"🖼️",accepts:dr("image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/x-icon","image/svg+xml"),specificity:2,render:e=>Pr(ye.jsx(Hw,{node:e})),renderChunk:(e,t)=>Pr(ye.jsx(Vw,{chunk:e,onNavigate:t}))},{name:"html",icon:"🌐",accepts:dr("text/html"),specificity:2,render:e=>ye.jsx(L_,{node:e}),renderChunk:e=>ye.jsx(L_,{node:Wi(e)})},{name:"fb2",icon:"📘",accepts:dr("application/x-fictionbook+xml"),specificity:2,render:e=>ye.jsx(I_,{node:e}),renderChunk:e=>ye.jsx(I_,{node:Wi(e)})},{name:"epub",icon:"📗",accepts:dr("application/epub+zip"),specificity:2,render:e=>ye.jsx(D_,{node:e}),renderChunk:e=>ye.jsx(D_,{node:Wi(e)})},{name:"pdf",icon:"📕",accepts:dr("application/pdf"),specificity:2,render:e=>Pr(ye.jsx(F_,{node:e})),renderChunk:e=>Pr(ye.jsx(F_,{node:Wi(e)}))},{name:"djvu",icon:"📓",accepts:dr("image/vnd.djvu"),specificity:2,render:e=>Pr(ye.jsx(j_,{node:e})),renderChunk:e=>Pr(ye.jsx(j_,{node:Wi(e)}))},{name:"psd",icon:"🎨",accepts:dr("image/vnd.adobe.photoshop"),specificity:2,render:e=>Pr(ye.jsx(B_,{node:e})),renderChunk:(e,t)=>Pr(ye.jsx(B_,{node:Wi(e),chunk:{onNavigate:t}}))},{name:"tiff",icon:"🖼️",accepts:dr("image/tiff"),specificity:2,render:e=>Pr(ye.jsx(P_,{node:e})),renderChunk:(e,t)=>Pr(ye.jsx(P_,{node:Wi(e),chunk:{onNavigate:t}}))},{name:"heic",icon:"🖼️",accepts:dr("image/heic"),specificity:2,render:e=>Pr(ye.jsx(U_,{node:e})),renderChunk:(e,t)=>Pr(ye.jsx(U_,{node:Wi(e),chunk:{onNavigate:t}}))}];function H_(e){if(e.children.length===0)return{children:[],expandable:e.hasChildren,loaded:!1,loadDepth:2};const t=e.children.filter(r=>Hd(r.format));return{children:t,expandable:t.length>0,loaded:!0,loadDepth:2}}function Qa(e){const t=Ww(e);let r=null;for(const n of Ty)n.accepts(t)&&(r===null||n.specificity>r.specificity)&&(r=n);return r}function Yw(e){return uw(e)?[Cy,...f0]:f0}function N$(e){const t=[],r=Qa(e);return r&&r!==Ea&&t.push(r),(r===Ea||Kw(e))&&t.push(...Yw(e)),t}const Gw=new Set(["object","array","mixed","variant"]),Ry=e=>!!e.type&&Gw.has(e.type);function Kw(e){const t=e.concrete;return(Pa(t)||ec(t)||pg(t))&&Ry(e)}const V_=Ty.find(e=>e.name==="plaintext");function I$(e){return Pa(e.concrete)||Qa(e)===V_||!(ec(e.concrete)||pg(e.concrete)||e.format==="text/markdown"||e.format==="text/asciidoc")?null:dg(e.concrete)||typeof ys(e.value)=="string"?V_:null}function tu(e,t){const r=Qa(e);return r&&r!==Ea?r.name:r===Ea||Pa(t)&&Ry(e)?e.format==="x-yamlover-board"?Cy.name:Ea.name:null}function zy(e){const t=Qa(e);if(t?.tocView)return t.tocView(e);const r=e.children.length>0;return{children:e.children,expandable:r?e.children.length>0:e.hasChildren,loaded:r}}const Xw=ft.memo(function e({node:t,current:r,onSelect:n,onLoadChildren:i,onContext:s,depth:o=0}){const{children:f,expandable:h,loaded:d,loadDepth:A}=zy(t),[z,L]=ft.useState(f.length>0),[ne,ge]=ft.useState(!1),Q=t.path===r,F=Sl(t.path,r),Y=ft.useRef(null);ft.useEffect(()=>{F&&L(!0)},[F]),ft.useEffect(()=>{Q&&Y.current?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[Q]);const pe=Du(t.type,t.format,t.concrete),se=z&&pe.glyph==="📁"?"📂":pe.glyph,ve=async()=>{if(!z&&h&&!d){ge(!0);try{await i(t.path,A)}finally{ge(!1)}}L(Z=>!Z)};return ye.jsxs("div",{className:"tree-branch",children:[ye.jsxs("div",{ref:Y,className:"tree-row"+(Q?" selected":""),style:{paddingLeft:o*14+4},onContextMenu:s?Z=>{Z.preventDefault(),s(t,Z.clientX,Z.clientY)}:void 0,children:[h?ye.jsx("button",{className:"toggle"+(z?" open":"")+(ne?" loading":""),onClick:ve,"aria-label":z?"collapse":"expand",children:ye.jsx("span",{className:"chevron",children:"›"})}):ye.jsx("span",{className:"toggle leaf"}),ye.jsx("span",{className:"icon "+pe.cls,title:pe.title,children:se}),ye.jsx("span",{className:"tree-label",onClick:()=>n(t.path),title:`${pi(t.path)} (${t.type})`,children:t.label})]}),z&&f.map(Z=>ye.jsx(e,{node:Z,current:r,onSelect:n,onLoadChildren:i,onContext:s,depth:o+1},Z.path))]})});function Qw({tasks:e}){return e.length?ye.jsx("div",{className:"task-strip",children:e.map(t=>{const{done:r,total:n,message:i}=t.progress,s=t.state==="done"?100:n?Math.min(100,Math.floor(r/n*100)):null,o=n?`${r}/${n}`:t.state==="running"&&r>0?String(r):"";return ye.jsxs("span",{className:`task-chip ${t.state}`,title:t.error??i??t.label,children:[ye.jsxs("span",{className:"task-label",children:[t.label,o&&ye.jsxs("span",{className:"task-counts",children:[" ",o]}),t.state==="error"&&" — failed"]}),ye.jsx("span",{className:"task-bar",children:s!==null?ye.jsx("span",{className:"task-bar-fill",style:{width:`${s}%`}}):ye.jsx("span",{className:"task-bar-fill indeterminate"})})]},t.id)})}):null}function Zw(e){const t=/^(?:https?:\/\/)?(?:www\.)?arxiv\.org\/(?:abs|pdf|html)\/(.+?)(?:\.pdf)?(?:[?#][^\s]*)?$/i.exec(e.trim());if(!t)return null;const r=t[1];return/^(?:\d{4}\.\d{4,5}|[a-z-]+(?:\.[A-Z]{2})?\/\d{7})(?:v\d+)?$/.test(r)?{url:`https://arxiv.org/pdf/${r}`,name:`arxiv-${r.replace(/\//g,"-")}.pdf`}:null}function Jw(e){const t=/^(?:https?:\/\/)?(?:www\.|mobile\.)?(?:x\.com|twitter\.com)\/(\w{1,15})\/status(?:es)?\/(\d+)(?:[/?#][^\s]*)?$/i.exec(e.trim());return t?`https://twitter.com/${t[1]}/status/${t[2]}`:null}async function Ow(e){const t=await fetch(`https://publish.x.com/oembed?url=${encodeURIComponent(e)}&omit_script=true&dnt=true`);if(!t.ok)throw new Error(`oEmbed HTTP ${t.status}`);const r=await t.json(),i=new DOMParser().parseFromString((r.html??"").replace(/<br\s*\/?>/gi,`
|
|
624
624
|
`),"text/html").querySelector("blockquote"),s=i?.querySelector("p")?.textContent?.trim();if(!s)throw new Error("no tweet text in the oEmbed payload");const o=(r.author_url??"").split("/").filter(Boolean).pop(),f=i?Array.from(i.querySelectorAll(":scope > a")):[],h=f[f.length-1]?.textContent?.trim(),d=[r.author_name,o&&`@${o}`].filter(Boolean).join(" "),A=[d&&`— ${d}`,h].filter(Boolean).join(", ");return[s,"",[A,r.url??e].filter(Boolean).join(`
|
|
625
625
|
`)].join(`
|
|
626
626
|
`)}const e8=new Set(["script","style","noscript","template","iframe","svg","head","title"]),t8=new Set(["p","div","section","article","main","aside","header","footer","figure","figcaption","ul","ol","table","thead","tbody","tr","dl","dt","dd","nav","form","body","html"]);function r8(e){const t=new DOMParser().parseFromString(e,"text/html"),r=s8(n8(t.body));if(!r.some(s=>s.kind!=="text"))return null;const n={chunks:[],children:[]},i=[{node:n,level:0}];for(const s of r)if(s.kind==="heading"){for(;i.length>1&&i[i.length-1].level>=s.level;)i.pop();const o={title:s.text||"Untitled",chunks:[],children:[]};i[i.length-1].node.children.push(o),i.push({node:o,level:s.level})}else i[i.length-1].node.chunks.push(s.kind==="image"?{image:{url:s.url,alt:s.alt}}:{text:s.text});return n}function n8(e){const t=[];let r="";const n=()=>{const s=r.replace(/[ \t]+/g," ").replace(/ ?\n ?/g,`
|
|
@@ -629,4 +629,4 @@ Your browser does not support the video tag.
|
|
|
629
629
|
`).map(h=>"> "+h).join(`
|
|
630
630
|
`)});return}if(o==="br"){r+=`
|
|
631
631
|
`;return}if(o==="td"||o==="th"){s.childNodes.forEach(i),r+=" ";return}if(t8.has(o)){n(),s.childNodes.forEach(i),n();return}if(!s.querySelector("img")){r+=Pd(s);return}s.childNodes.forEach(i)}};return i(e),n(),t}function i8(e){const t=e.getAttribute("src")||e.getAttribute("data-src")||"";return t.startsWith("//")?"https:"+t:/^https?:\/\//.test(t)||t.startsWith("data:image/")?t:null}function s8(e){const t=[];for(const r of e){const n=t[t.length-1];r.kind==="text"&&r.text.startsWith("- ")&&n?.kind==="text"&&n.text.startsWith("- ")?n.text+=`
|
|
632
|
-
`+r.text:t.push(r)}return t}const a8={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","image/bmp":"bmp","image/tiff":"tiff","image/avif":"avif"};async function Ny(e){return{title:e.title,chunks:await Promise.all(e.chunks.map(async t=>{if("text"in t)return{text:t.text};try{const r=await fetch(t.image.url);if(!r.ok)throw new Error(`HTTP ${r.status}`);const n=await r.blob();return{file:{name:l8(t.image.url,n.type),contentBase64:await o8(n)}}}catch{return{text:``}}})),children:await Promise.all(e.children.map(Ny))}}function l8(e,t){let r="";try{r=decodeURIComponent(new URL(e).pathname.split("/").pop()??"")}catch{}return(!r||e.startsWith("data:"))&&(r="image"),/\.[A-Za-z0-9]{2,5}$/.test(r)||(r+="."+(a8[t]||"bin")),r}function o8(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result).split(",")[1]||""),n.onerror=()=>r(new Error("could not read image")),n.readAsDataURL(e)})}function Iy(e){return e.chunks.filter(t=>"image"in t).length+e.children.reduce((t,r)=>t+Iy(r),0)}const qy=1,My=()=>new URLSearchParams(window.location.search);function nh(e){const t=e.trim().toLowerCase();return t===".inf"||t==="inf"}function W_(e){if(nh(e))return!0;const t=Number(e);return e.trim()!==""&&Number.isInteger(t)&&t>=qy}function d0(){const e=My().get("depth");if(e==null||e===""||nh(e))return null;const t=Number(e);return Number.isInteger(t)&&t>=qy?t:null}function u8(e){const t=My();e==null?t.delete("depth"):t.set("depth",String(e));const r=t.toString();window.history.replaceState({},"",window.location.pathname+(r?"?"+r:""))}function c8({onChange:e}){const t=d0(),r=t==null?".inf":String(t),[n,i]=ft.useState(r);ft.useEffect(()=>i(r),[r]);const s=W_(n);return ye.jsx("input",{className:"depth-control"+(s?"":" invalid"),type:"text",title:"depth",value:n,onChange:o=>{const f=o.target.value;i(f),W_(f)&&(u8(nh(f)?null:Number(f)),e())}})}const $8=new Set(["chapter","markdown","asciidoc","marklower"]),f8=new Set(["chapter","task"]),Dy=["yamlover","json5p","yamlover/schema"],pl="yamlover",q$=e=>e.endsWith("schema"),Y_=e=>e==="json5p"?"json":"yaml";function M$(e){return ec(e.concrete)?["yamlover","json5p","yamlover/schema"]:["yamlover","yamlover/schema"]}function D$(e,t,r){return r.includes(e)?e:tu(t,t.concrete)??pl}function d8(e){const t=Vr(e),r=t[t.length-1];return r===void 0?"":typeof r=="number"?`[${r}]`:r}const h8={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","image/bmp":"bmp","image/tiff":"tiff","application/pdf":"pdf"};function p8(e){const t=e.clipboardData;if(!t)return[];if(t.files&&t.files.length)return Array.from(t.files);const r=[];for(const n of Array.from(t.items||[]))if(n.kind==="file"){const i=n.getAsFile();i&&r.push(i)}return r}function _8(e){return e.name?e.name:`pasted.${h8[e.type]||"bin"}`}function m8(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result).split(",")[1]||""),n.onerror=()=>r(new Error("could not read file")),n.readAsDataURL(e)})}const g8=ft.memo(function({path:t,format:r,refreshSignal:n=0,onFormat:i,onNavigate:s,onContentChanged:o,onOpenUploaded:f}){const[h,d]=ft.useState(null),[A,z]=ft.useState(null),[L,ne]=ft.useState(null),[ge,Q]=ft.useState(null),[F,Y]=ft.useState(0),[pe,se]=ft.useState(!1),[ve,Z]=ft.useState(null),[be,ue]=ft.useState(!1),Ee=ft.useRef(t),[,O]=ft.useReducer(yt=>yt+1,0),Ce=bd(t);cc(h);const $e=ft.useRef(!1);ft.useEffect(()=>{const yt=gt=>{$e.current&&(gt.key==="F2"&&!pe?(gt.preventDefault(),se(!0)):gt.key==="Escape"&&pe&&(gt.preventDefault(),se(!1)))};return document.addEventListener("keydown",yt),()=>document.removeEventListener("keydown",yt)},[pe]),ft.useEffect(()=>{const yt=Ee.current!==t;if(pe&&!yt)return;Q(null),yt&&(d(null),Ee.current=t);let gt=!1;return on(t).then(wt=>{if(gt)return;const At=N$(wt),et=I$(wt),ze=[...At.map(Me=>Me.name),...M$(wt),...et?[et.name]:[]],je=D$(r,wt,ze),Ge=[...At,...et?[et]:[]].find(Me=>Me.name===je),y=Me=>!gt&&d(Me),I=Me=>!gt&&Q(Me.message),xe=Pa(wt.concrete)||wt.type==="binary"?1:1/0;if(Ge){const Me=Ge.depth??1;Me!==xe?on(t,Me).then(y).catch(I):d(wt)}else{const Me=d0();(Me===null?1/0:Me)===xe?d(wt):on(t,Me).then(y).catch(I)}}).catch(wt=>!gt&&Q(wt.message)),()=>{gt=!0}},[t,F,n,r,pe]),ft.useEffect(()=>{if(!h)return;const yt=gt=>{const wt=gt.target;if(wt&&(wt.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(wt.tagName)))return;const At=p8(gt);if(At.length>0){gt.preventDefault(),w(At);return}const et=gt.clipboardData?.getData("text/html")??"",ze=et?r8(et):null;if(ze){gt.preventDefault(),j(ze);return}const je=gt.clipboardData?.getData("text/plain")??"";if(!je.trim())return;gt.preventDefault();const Ge=Zw(je);if(Ge){Ae(Ge);return}const y=Jw(je);if(y){de(y);return}V(je)};return document.addEventListener("paste",yt),()=>document.removeEventListener("paste",yt)},[h,t]),ft.useEffect(()=>{if(!h)return;const yt=je=>Array.from(je.dataTransfer?.types||[]).includes("Files");let gt=0;const wt=je=>{yt(je)&&(je.preventDefault(),gt++,ue(!0))},At=je=>{yt(je)&&(je.preventDefault(),je.dataTransfer&&(je.dataTransfer.dropEffect="copy"))},et=()=>{gt=Math.max(0,gt-1),gt===0&&ue(!1)},ze=je=>{if(!yt(je))return;je.preventDefault(),gt=0,ue(!1);const Ge=Array.from(je.dataTransfer?.files||[]);Ge.length&&w(Ge)};return document.addEventListener("dragenter",wt),document.addEventListener("dragover",At),document.addEventListener("dragleave",et),document.addEventListener("drop",ze),()=>{document.removeEventListener("dragenter",wt),document.removeEventListener("dragover",At),document.removeEventListener("dragleave",et),document.removeEventListener("drop",ze)}},[h,t]);const w=async yt=>{try{Z(`uploading ${yt.length} file${yt.length>1?"s":""}…`);let gt=null;for(const wt of yt){const At=await m8(wt);gt=await y4(t,_8(wt),At)}Z(yt.length>1?`uploaded ${yt.length} files`:"uploaded"),window.setTimeout(()=>Z(null),1500),gt?.open?f?.(gt):(Y(wt=>wt+1),o?.(t))}catch(gt){Z("paste failed: "+gt.message),window.setTimeout(()=>Z(null),4e3)}},Ae=async({url:yt,name:gt})=>{try{Z(`downloading ${gt}…`);const wt=await fetch(yt);if(!wt.ok)throw new Error(`HTTP ${wt.status} fetching ${yt}`);const At=await wt.blob();await w([new File([At],gt,{type:"application/pdf"})])}catch(wt){Z("download failed: "+wt.message),window.setTimeout(()=>Z(null),4e3)}},j=async yt=>{try{const gt=Iy(yt);gt&&Z(`downloading ${gt} image${gt>1?"s":""}…`);const wt=await Ny(yt);Z("pasting…");const At=await x4(t,wt);Z(At.chapter?"chunks added":"chapter created"),window.setTimeout(()=>Z(null),1500),At.open?f?.(At):(Y(et=>et+1),o?.(t))}catch(gt){Z("paste failed: "+gt.message),window.setTimeout(()=>Z(null),4e3)}},de=async yt=>{try{Z("fetching tweet…"),await V(await Ow(yt))}catch(gt){Z("tweet fetch failed: "+gt.message),window.setTimeout(()=>Z(null),4e3)}},V=async yt=>{try{Z("pasting text…");const gt=await b4(t,yt);Z(gt.chapter?"chunk added":"chapter created"),window.setTimeout(()=>Z(null),1500),gt.open?f?.(gt):(Y(wt=>wt+1),o?.(t))}catch(gt){Z("paste failed: "+gt.message),window.setTimeout(()=>Z(null),4e3)}};if(ft.useEffect(()=>{h&&(document.title=h.title?.trim()||d8(t)||"yamlover")},[h,t]),ft.useEffect(()=>{if(z(null),ne(null),!h)return;const yt=N$(h),gt=I$(h),wt=[...yt.map(et=>et.name),...M$(h),...gt?[gt.name]:[]],At=D$(r,h,wt);[...yt,...gt?[gt]:[]].some(et=>et.name===At)||(q$(At)?f4(t,d0()??void 0).then(z).catch(et=>Q(et.message)):(h.type==="binary"||h.valueType==="binary")&&on(t,void 0,{binary:!0}).then(et=>ne(et.value)).catch(et=>Q(et.message)))},[r,t,h]),ge)return ye.jsx("div",{className:"error",children:ge});if(!h)return ye.jsx("div",{className:"loading",children:"…"});const Fe=N$(h),ce=M$(h),U=I$(h),x=U?[...Fe,U]:Fe,$=[...Fe.map(yt=>yt.name),...ce,...U?[U.name]:[]],l=D$(r,h,$),c=yt=>x.find(gt=>gt.name===yt)?.label??yt,p={yamlover:"y:",json5p:"{}","yamlover/schema":"$"},_=yt=>x.find(gt=>gt.name===yt)?.icon??p[yt]??yt,S=x.find(yt=>yt.name===l)??null,C=S!=null,ee=C&&!!S&&f8.has(S.name);$e.current=ee;const Le=h.documentPath??t;let nt,dt;C?(nt=h.value,dt=!0):q$(l)?(nt=A,dt=A!=null):h.type==="binary"||h.valueType==="binary"?(nt=L,dt=L!=null):(nt=h.value,dt=!0);const{tags:lt,rest:xt}=t3(h.relations),bt=[...lt];for(const yt of Ce)yt.fragmentSlug||yt.tag&&!bt.some(gt=>gt.path===yt.tag.path)&&bt.push({path:yt.tag.path,label:yt.tag.name,color:yt.tag.color});return ye.jsxs("div",{className:"nodeview",children:[ve&&ye.jsx("div",{className:"paste-toast",children:ve}),be&&ye.jsx("div",{className:"drop-overlay",children:"Drop file to upload"}),ye.jsxs("div",{className:"nodehead",children:[ye.jsxs("div",{className:"nodemeta",children:[ye.jsx("span",{className:"tag",children:h.type}),h.concrete&&ye.jsx("span",{className:"tag dim",children:h.concrete}),ye.jsx(Cg,{tags:bt,onNavigate:s})]}),ye.jsx("span",{className:"bar-sep","aria-hidden":"true",children:"|"}),ee&&ye.jsxs("button",{className:"lockbtn"+(pe?" unlocked":""),title:pe?"Editing — click or Esc to finish":"Read-only — click or F2 to edit","aria-pressed":pe,onClick:()=>se(yt=>!yt),children:[ye.jsx("span",{className:"lockbtn-icon","aria-hidden":"true",children:pe?"✓":"✏️"}),ye.jsx("span",{className:"lockbtn-label",children:pe?"Done":"Edit"})]}),ye.jsx("div",{className:"tabs",children:$.map(yt=>ye.jsxs(ft.Fragment,{children:[ye.jsx("button",{className:"tab"+(l===yt?" active":""),title:c(yt),"aria-label":c(yt),onClick:()=>i(yt),children:_(yt)}),C&&S&&yt===S.name&&S.config?.(O,h),!C&&yt===l&&ye.jsx(c8,{onChange:()=>Y(gt=>gt+1)})]},yt))})]}),!C&&h.description&&ye.jsx("p",{className:"nodedesc",children:h.description}),C?ye.jsx(kg.Provider,{value:{unlocked:pe},children:$8.has(S.name)&&!pe?ye.jsx(w3,{path:t,children:S.render(h,s)}):S.render(h,s)}):ye.jsxs("pre",{className:"code",children:[!q$(l)&&Object.keys(xt).length>0&&ye.jsxs(ye.Fragment,{children:[ye.jsx(bp,{value:xt,syntax:Y_(l),onNavigate:s,documentPath:Le,nodePath:t,anchors:!1}),ye.jsx("hr",{className:"reldiv"})]}),dt?ye.jsx(bp,{value:nt,syntax:Y_(l),onNavigate:s,documentPath:Le,nodePath:t,comments:h.comments}):"…"]})]})});function v8(e,t){return(e===":"?"":e)+":yamlover-fragments:"+t}function y8(e){const t=[],r=new Map;for(const n of e){if(!n.fragmentSlug)continue;let i=r.get(n.fragmentSlug);i?(!i.selector&&n.selector&&(i.selector=n.selector),!i.imageUrl&&n.imageUrl&&(i.imageUrl=n.imageUrl)):(i={slug:n.fragmentSlug,node:n.node,selector:n.selector,imageUrl:n.imageUrl,tags:[]},r.set(n.fragmentSlug,i),t.push(n.fragmentSlug)),n.tag&&!i.tags.some(s=>s.path===n.tag.path)&&i.tags.push({path:n.tag.path,label:n.tag.name,color:n.tag.color})}return t.map(n=>r.get(n))}function b8(e){const t=e.selector;if(t?.type==="text"&&typeof t.exact=="string")return t.exact;switch(t?.type){case"map":return"map region";case"pdf":return"PDF region";case"rect":return"image region";case"djvu":return"djvu region";default:return"fragment"}}function x8({path:e,groups:t,width:r,onNavigate:n}){const[i,s]=ft.useState(new Set),o=d=>{window.location.hash="#"+_g(d.node??e,d.slug)},f=async d=>{s(z=>new Set(z).add(d.slug));const A=v8(d.node??e,d.slug);try{for(const z of d.tags)await Ou(A,z.path)}catch(z){s(L=>{const ne=new Set(L);return ne.delete(d.slug),ne}),window.alert("delete failed: "+z.message)}},h=t.filter(d=>!i.has(d.slug));return h.length===0?null:ye.jsxs("aside",{className:"pane fragments",style:{width:r},children:[ye.jsxs("div",{className:"fragments-head",children:[ye.jsx("span",{className:"fragments-title",children:"Fragments"}),ye.jsx("span",{className:"fragments-count",children:h.length})]}),ye.jsx("ul",{className:"fragments-list",children:h.map(d=>ye.jsxs("li",{className:"fragment-row",children:[ye.jsxs("div",{className:"fragment-main",children:[ye.jsx("button",{type:"button",className:"fragment-locate",title:"Scroll to this fragment",onClick:()=>o(d),children:d.imageUrl?ye.jsx("img",{className:"fragment-thumb",src:d.imageUrl,alt:""}):ye.jsx("span",{className:"fragment-excerpt",children:b8(d)})}),ye.jsx("button",{type:"button",className:"fragment-delete",title:"Delete this fragment","aria-label":"Delete this fragment",onClick:()=>f(d),children:"✕"})]}),d.tags.length>0&&ye.jsx("div",{className:"fragment-tags",children:ye.jsx(Cg,{tags:d.tags,onNavigate:n})})]},d.slug))})]})}const w8=e=>Dy.includes(e),k8=(e,t)=>w8(e)&&(e!=="json5p"||ec(t));function G_(e){try{return localStorage.getItem(e)==="1"}catch{return!1}}const na=1;function h0(e,t,r){return e.path===t?{...e,children:r}:e.children.length?{...e,children:e.children.map(n=>h0(n,t,r))}:e}function Ly(e,t){if(!e)return t;const r=new Map(e.children.map(i=>[i.path,i])),n=t.children.length?t.children.map(i=>Ly(r.get(i.path),i)):t.hasChildren?e.children:[];return{...t,children:n}}function p0(e,t,r){return e.path===t?Ly(e,r):e.children.length?{...e,children:e.children.map(n=>p0(n,t,r))}:e}function ma(e,t){if(e.path===t)return e;for(const r of e.children){const n=ma(r,t);if(n)return n}return null}function S8(e,t){const r=Vr(t);for(let n=0;n<r.length;n++){const i=Un(r.slice(0,n)),s=ma(e,i);if(!s)return null;if(s.hasChildren&&s.children.length===0)return i}return null}function E8(e){if(!e)return[];const t=[],r=n=>{t.push(n.path);for(const i of zy(n).children)r(i)};return r(e),t}function A8(){const[e,t]=ft.useState(null),[r,n]=ft.useState(null),[i,s]=ft.useState(mp()),[o,f]=ft.useState(gp(pl)),[h,d]=ft.useState(""),[A,z]=ft.useState("idle"),L=ft.useCallback(()=>{const lt=":.yamlover:settings.yamlover";ea(lt,"settings",!1),s(lt),f("settings")},[]),[ne,ge]=ft.useState(320),[Q,F]=ft.useState(300),[Y,pe]=ft.useState(()=>G_("yo-left-collapsed")),[se,ve]=ft.useState(()=>G_("yo-right-collapsed"));ft.useEffect(()=>{try{localStorage.setItem("yo-left-collapsed",Y?"1":"0")}catch{}},[Y]),ft.useEffect(()=>{try{localStorage.setItem("yo-right-collapsed",se?"1":"0")}catch{}},[se]);const Z=ft.useRef(null),be=y8(bd(i)),ue=be.length>0&&!se&&!Dy.includes(o);ft.useEffect(()=>{hp().then(lt=>d(lt.root)).catch(()=>{})},[]);const[Ee,O]=ft.useState([]);ft.useEffect(()=>{$4().then(O).catch(()=>{})},[]);const Ce=ft.useCallback(lt=>{O(xt=>[...xt.filter(bt=>bt.id!==lt.id),lt].sort((bt,yt)=>bt.startedAt-yt.startedAt)),lt.state!=="running"&&setTimeout(()=>O(xt=>xt.filter(bt=>bt.id!==lt.id)),3e3)},[]),$e=ft.useRef(new URLSearchParams(window.location.search).has("format"));ft.useEffect(()=>{ea(i,o,!0)},[]),ft.useEffect(()=>{Os(":",na).then(t).catch(lt=>n(lt.message))},[]);const w=ft.useRef(!1);ft.useEffect(()=>{if($e.current||w.current||!e)return;const lt=ma(e,i);if(!lt)return;w.current=!0;const xt=tu(lt,lt.concrete);xt&&(f(xt),ea(i,xt,!0))},[e,i]);const Ae=ft.useCallback(async(lt,xt=na)=>{const bt=await Os(lt,xt);t(yt=>yt&&h0(yt,lt,bt.children))},[]);ft.useEffect(()=>{if(!e)return;const lt=S8(e,i);lt&&Ae(lt).catch(()=>{})},[e,i,Ae]);const j=ft.useRef(e);j.current=e;const de=ft.useRef(i);de.current=i;const[V,Fe]=ft.useState(0),ce=ft.useCallback(async lt=>{const xt=j.current;if(!xt)return;const bt=new Set;for(const gt of lt){const wt=Vr(gt);let At=":";for(let et=0;et<wt.length;et++){const ze=Un(wt.slice(0,et)),je=ma(xt,ze);if(!je)break;(ze===":"||je.children.length>0)&&(At=ze)}bt.add(At)}const yt=[...bt].filter(gt=>![...bt].some(wt=>wt!==gt&&Sl(wt,gt)));await Promise.all(yt.map(async gt=>{const wt=await Os(gt,na);t(At=>At&&p0(At,gt,wt))}))},[]),U=ft.useCallback(()=>{j.current||(Os(":",na).then(lt=>{t(lt),n(null)}).catch(()=>{}),hp().then(lt=>d(lt.root)).catch(()=>{}))},[]);ft.useEffect(()=>{if(typeof EventSource>"u")return;const lt=new EventSource(kr("/api/events"));let xt=!1;return lt.onopen=()=>{if(!xt){xt=!0;return}U(),Os(":",na).then(bt=>t(yt=>yt?p0(yt,":",bt):bt)).catch(()=>{}),Fe(bt=>bt+1)},lt.onmessage=bt=>{try{const yt=JSON.parse(bt.data);if(yt.type==="task"){const et=yt.task;Ce(et),et.state==="done"&&U();return}const gt=yt;U();const wt=[...gt.added,...gt.changed,...gt.removed,...(gt.moved??[]).flatMap(et=>[et.from,et.to])];if(!wt.length)return;n3({paths:wt,removed:gt.removed}),ce(wt).catch(()=>{});const At=de.current;wt.some(et=>et===At||Sl(et,At)||Sl(At,et))&&Fe(et=>et+1)}catch{}},()=>lt.close()},[ce,Ce,U]),ft.useEffect(()=>{const lt=()=>{s(mp()),f(gp(pl))};return window.addEventListener("popstate",lt),()=>window.removeEventListener("popstate",lt)},[]);const x=ft.useCallback(lt=>{const xt=e?ma(e,lt):null;let bt=o;xt&&(bt=tu(xt,xt.concrete)??(k8(o,xt.concrete)?o:pl)),ea(lt,bt,!1),s(lt),bt!==o&&f(bt)},[o,e]),$=ft.useCallback(lt=>{x(lt),Z.current?.focus()},[x]),{openAt:l,tagMenu:c}=wd({onCreate:(lt,xt,bt)=>void cg(lt,xt,bt).then(yt=>x(yt.path)).catch(yt=>window.alert("create failed: "+yt.message))}),p=ft.useCallback((lt,xt,bt)=>l(lt.path,xt,bt,lt),[l]),_=ft.useRef(x);_.current=x,ft.useEffect(()=>{const lt=xt=>{if(!(xt.ctrlKey||xt.altKey)||xt.key!=="ArrowDown"&&xt.key!=="ArrowUp")return;const bt=xt.target;if(bt&&(bt.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(bt.tagName)))return;const yt=E8(j.current),gt=yt.indexOf(de.current);if(gt<0)return;const wt=Math.min(Math.max(gt+(xt.key==="ArrowDown"?1:-1),0),yt.length-1);xt.preventDefault(),wt!==gt&&_.current(yt[wt])};return window.addEventListener("keydown",lt),()=>window.removeEventListener("keydown",lt)},[]);const S=ft.useCallback(lt=>{ea(i,lt,!0),f(lt)},[i]),C=ft.useCallback(lt=>{const xt=e?ma(e,lt):null;Ae(xt?lt:":").catch(()=>{})},[e,Ae]),ee=ft.useCallback(async lt=>{const xt=lt.dir??":";try{const bt=await Os(xt,na);t(wt=>wt&&h0(wt,xt,bt.children));const yt=bt.children.find(wt=>wt.path===lt.path),gt=(yt?tu(yt,yt.concrete):null)??pl;ea(lt.path,gt,!1),s(lt.path),f(gt)}catch{x(lt.path)}},[x]),Le=ft.useRef(null);ft.useEffect(()=>{const lt=bt=>{Le.current==="left"?ge(Math.min(Math.max(bt.clientX,160),window.innerWidth-240)):Le.current==="right"&&F(Math.min(Math.max(window.innerWidth-bt.clientX,200),window.innerWidth-240))},xt=()=>{Le.current=null,document.body.style.userSelect=""};return window.addEventListener("mousemove",lt),window.addEventListener("mouseup",xt),()=>{window.removeEventListener("mousemove",lt),window.removeEventListener("mouseup",xt)}},[]);const nt=lt=>{Le.current=lt,document.body.style.userSelect="none"},dt=ft.useCallback(async()=>{if(A!=="busy"){z("busy");try{const{files:lt}=await v4(),xt=lt.filter(bt=>bt.status!=="exists").map(bt=>bt.name);n(null),window.alert(xt.length?`Installed agent guide: ${xt.join(", ")}.`:"Agent guide is already up to date.")}catch(lt){n(`agent docs: ${lt.message}`)}finally{z("idle")}}},[A]);return ye.jsxs("div",{className:"app",children:[ye.jsxs("header",{className:"topbar",children:[ye.jsx("button",{type:"button",className:"crumb-action pane-toggle",title:Y?"Show the tree":"Hide the tree","aria-label":Y?"Show the tree":"Hide the tree","aria-pressed":!Y,onClick:()=>pe(lt=>!lt),children:Y?"»":"«"}),ye.jsxs("nav",{className:"crumbs",children:[ye.jsx("button",{type:"button",className:"crumb-action crumb-settings",title:"Project configuration (settings.yamlover)","aria-label":"Project configuration",onClick:L,children:"⚙"}),ye.jsx("button",{type:"button",className:"crumb-action",disabled:A==="busy",title:"Install the LLM agent guide (AGENTS.md + CLAUDE.md) into this project","aria-label":"Install LLM agent guide",onClick:dt,children:"🤖"}),z4(i,h).map((lt,xt)=>ye.jsxs("span",{children:[xt>0&&ye.jsx("span",{className:"crumb-sep",children:":"}),ye.jsx("a",{className:"crumb",href:lt.path,onClick:bt=>{bt.preventDefault(),x(lt.path)},children:lt.label})]},lt.path))]}),ye.jsxs("div",{className:"topbar-right",children:[ye.jsx(Qw,{tasks:Ee}),be.length>0&&ye.jsx("button",{type:"button",className:"crumb-action pane-toggle",title:se?"Show fragments":"Hide fragments","aria-label":se?"Show fragments":"Hide fragments","aria-pressed":!se,onClick:()=>ve(lt=>!lt),children:se?"«":"»"})]})]}),ye.jsxs("div",{className:"body",children:[!Y&&ye.jsxs(ye.Fragment,{children:[ye.jsx("aside",{className:"pane left",style:{width:ne},children:(()=>{const lt=e?void 0:Ee.find(xt=>xt.state==="running");if(lt){const{done:xt,total:bt}=lt.progress;return ye.jsxs("div",{className:"loading",children:[lt.label,"… ",bt?`${xt}/${bt}`:""]})}return r?ye.jsx("div",{className:"error",children:r}):e?ye.jsx(Xw,{node:e,current:i,onSelect:$,onLoadChildren:Ae,onContext:p}):ye.jsx("div",{className:"loading",children:"loading…"})})()}),ye.jsx("div",{className:"splitter",onMouseDown:()=>nt("left")})]}),ye.jsx("main",{className:"pane right",ref:Z,tabIndex:-1,children:(()=>{const lt=e?void 0:Ee.find(xt=>xt.state==="running");if(lt){const{done:xt,total:bt}=lt.progress;return ye.jsxs("div",{className:"loading",children:[lt.label,"… ",bt?`${xt}/${bt}`:""]})}return ye.jsx(g8,{path:i,format:o,refreshSignal:V,onFormat:S,onNavigate:x,onContentChanged:C,onOpenUploaded:ee})})()}),ue&&ye.jsxs(ye.Fragment,{children:[ye.jsx("div",{className:"splitter",onMouseDown:()=>nt("right")}),ye.jsx(x8,{path:i,groups:be,width:Q,onNavigate:x})]})]}),c]})}class C8 extends ft.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){console.error("yamlover UI crashed:",t)}render(){const{error:t}=this.state;return t?ye.jsxs("div",{className:"crash",children:[ye.jsx("h1",{children:"Something went wrong"}),ye.jsx("p",{children:"The viewer hit an error and stopped rendering."}),ye.jsx("pre",{children:t.message}),ye.jsxs("div",{className:"crash-actions",children:[ye.jsx("button",{onClick:()=>this.setState({error:null}),children:"Try again"}),ye.jsx("button",{onClick:()=>location.reload(),children:"Reload"})]})]}):this.props.children}}lg(document.getElementById("root")).render(ye.jsx(e2.StrictMode,{children:ye.jsx(C8,{children:ye.jsx(A8,{})})}));export{a3 as D,T8 as a,vs as b,l3 as c,Hn as d,wp as e,_g as f,Fy as g,x3 as h,_d as i,ye as j,v3 as k,R8 as p,ft as r,$0 as s,Zx as u,z8 as w};
|
|
632
|
+
`+r.text:t.push(r)}return t}const a8={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","image/bmp":"bmp","image/tiff":"tiff","image/avif":"avif"};async function Ny(e){return{title:e.title,chunks:await Promise.all(e.chunks.map(async t=>{if("text"in t)return{text:t.text};try{const r=await fetch(t.image.url);if(!r.ok)throw new Error(`HTTP ${r.status}`);const n=await r.blob();return{file:{name:l8(t.image.url,n.type),contentBase64:await o8(n)}}}catch{return{text:``}}})),children:await Promise.all(e.children.map(Ny))}}function l8(e,t){let r="";try{r=decodeURIComponent(new URL(e).pathname.split("/").pop()??"")}catch{}return(!r||e.startsWith("data:"))&&(r="image"),/\.[A-Za-z0-9]{2,5}$/.test(r)||(r+="."+(a8[t]||"bin")),r}function o8(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result).split(",")[1]||""),n.onerror=()=>r(new Error("could not read image")),n.readAsDataURL(e)})}function Iy(e){return e.chunks.filter(t=>"image"in t).length+e.children.reduce((t,r)=>t+Iy(r),0)}const qy=1,My=()=>new URLSearchParams(window.location.search);function nh(e){const t=e.trim().toLowerCase();return t===".inf"||t==="inf"}function W_(e){if(nh(e))return!0;const t=Number(e);return e.trim()!==""&&Number.isInteger(t)&&t>=qy}function d0(){const e=My().get("depth");if(e==null||e===""||nh(e))return null;const t=Number(e);return Number.isInteger(t)&&t>=qy?t:null}function u8(e){const t=My();e==null?t.delete("depth"):t.set("depth",String(e));const r=t.toString();window.history.replaceState({},"",window.location.pathname+(r?"?"+r:""))}function c8({onChange:e}){const t=d0(),r=t==null?".inf":String(t),[n,i]=ft.useState(r);ft.useEffect(()=>i(r),[r]);const s=W_(n);return ye.jsx("input",{className:"depth-control"+(s?"":" invalid"),type:"text",title:"depth",value:n,onChange:o=>{const f=o.target.value;i(f),W_(f)&&(u8(nh(f)?null:Number(f)),e())}})}const $8=new Set(["chapter","markdown","asciidoc","marklower"]),f8=new Set(["chapter","task"]),Dy=["yamlover","json5p","yamlover/schema"],pl="yamlover",q$=e=>e.endsWith("schema"),Y_=e=>e==="json5p"?"json":"yaml";function M$(e){return ec(e.concrete)?["yamlover","json5p","yamlover/schema"]:["yamlover","yamlover/schema"]}function D$(e,t,r){return r.includes(e)?e:tu(t,t.concrete)??pl}function d8(e){const t=Vr(e),r=t[t.length-1];return r===void 0?"":typeof r=="number"?`[${r}]`:r}const h8={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","image/bmp":"bmp","image/tiff":"tiff","application/pdf":"pdf"};function p8(e){const t=e.clipboardData;if(!t)return[];if(t.files&&t.files.length)return Array.from(t.files);const r=[];for(const n of Array.from(t.items||[]))if(n.kind==="file"){const i=n.getAsFile();i&&r.push(i)}return r}function _8(e){return e.name?e.name:`pasted.${h8[e.type]||"bin"}`}function m8(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result).split(",")[1]||""),n.onerror=()=>r(new Error("could not read file")),n.readAsDataURL(e)})}const g8=ft.memo(function({path:t,format:r,refreshSignal:n=0,onFormat:i,onNavigate:s,onContentChanged:o,onOpenUploaded:f}){const[h,d]=ft.useState(null),[A,z]=ft.useState(null),[L,ne]=ft.useState(null),[ge,Q]=ft.useState(null),[F,Y]=ft.useState(0),[pe,se]=ft.useState(!1),[ve,Z]=ft.useState(null),[be,ue]=ft.useState(!1),Ee=ft.useRef(t),[,O]=ft.useReducer(yt=>yt+1,0),Ce=bd(t);cc(h);const $e=ft.useRef(!1);ft.useEffect(()=>{const yt=gt=>{$e.current&&(gt.key==="F2"&&!pe?(gt.preventDefault(),se(!0)):gt.key==="Escape"&&pe&&(gt.preventDefault(),se(!1)))};return document.addEventListener("keydown",yt),()=>document.removeEventListener("keydown",yt)},[pe]),ft.useEffect(()=>{const yt=Ee.current!==t;if(pe&&!yt)return;Q(null),yt&&(d(null),Ee.current=t);let gt=!1;return on(t).then(wt=>{if(gt)return;const At=N$(wt),et=I$(wt),ze=[...At.map(Me=>Me.name),...M$(wt),...et?[et.name]:[]],je=D$(r,wt,ze),Ge=[...At,...et?[et]:[]].find(Me=>Me.name===je),y=Me=>!gt&&d(Me),I=Me=>!gt&&Q(Me.message),xe=Pa(wt.concrete)||wt.type==="binary"?1:1/0;if(Ge){const Me=Ge.depth??1;Me!==xe?on(t,Me).then(y).catch(I):d(wt)}else{const Me=d0();(Me===null?1/0:Me)===xe?d(wt):on(t,Me).then(y).catch(I)}}).catch(wt=>!gt&&Q(wt.message)),()=>{gt=!0}},[t,F,n,r,pe]),ft.useEffect(()=>{if(!h)return;const yt=gt=>{const wt=gt.target;if(wt&&(wt.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(wt.tagName)))return;const At=p8(gt);if(At.length>0){gt.preventDefault(),w(At);return}const et=gt.clipboardData?.getData("text/html")??"",ze=et?r8(et):null;if(ze){gt.preventDefault(),j(ze);return}const je=gt.clipboardData?.getData("text/plain")??"";if(!je.trim())return;gt.preventDefault();const Ge=Zw(je);if(Ge){Ae(Ge);return}const y=Jw(je);if(y){de(y);return}V(je)};return document.addEventListener("paste",yt),()=>document.removeEventListener("paste",yt)},[h,t]),ft.useEffect(()=>{if(!h)return;const yt=je=>Array.from(je.dataTransfer?.types||[]).includes("Files");let gt=0;const wt=je=>{yt(je)&&(je.preventDefault(),gt++,ue(!0))},At=je=>{yt(je)&&(je.preventDefault(),je.dataTransfer&&(je.dataTransfer.dropEffect="copy"))},et=()=>{gt=Math.max(0,gt-1),gt===0&&ue(!1)},ze=je=>{if(!yt(je))return;je.preventDefault(),gt=0,ue(!1);const Ge=Array.from(je.dataTransfer?.files||[]);Ge.length&&w(Ge)};return document.addEventListener("dragenter",wt),document.addEventListener("dragover",At),document.addEventListener("dragleave",et),document.addEventListener("drop",ze),()=>{document.removeEventListener("dragenter",wt),document.removeEventListener("dragover",At),document.removeEventListener("dragleave",et),document.removeEventListener("drop",ze)}},[h,t]);const w=async yt=>{try{Z(`uploading ${yt.length} file${yt.length>1?"s":""}…`);let gt=null;for(const wt of yt){const At=await m8(wt);gt=await y4(t,_8(wt),At)}Z(yt.length>1?`uploaded ${yt.length} files`:"uploaded"),window.setTimeout(()=>Z(null),1500),gt?.open?f?.(gt):(Y(wt=>wt+1),o?.(t))}catch(gt){Z("paste failed: "+gt.message),window.setTimeout(()=>Z(null),4e3)}},Ae=async({url:yt,name:gt})=>{try{Z(`downloading ${gt}…`);const wt=await fetch(yt);if(!wt.ok)throw new Error(`HTTP ${wt.status} fetching ${yt}`);const At=await wt.blob();await w([new File([At],gt,{type:"application/pdf"})])}catch(wt){Z("download failed: "+wt.message),window.setTimeout(()=>Z(null),4e3)}},j=async yt=>{try{const gt=Iy(yt);gt&&Z(`downloading ${gt} image${gt>1?"s":""}…`);const wt=await Ny(yt);Z("pasting…");const At=await x4(t,wt);Z(At.chapter?"chunks added":"chapter created"),window.setTimeout(()=>Z(null),1500),At.open?f?.(At):(Y(et=>et+1),o?.(t))}catch(gt){Z("paste failed: "+gt.message),window.setTimeout(()=>Z(null),4e3)}},de=async yt=>{try{Z("fetching tweet…"),await V(await Ow(yt))}catch(gt){Z("tweet fetch failed: "+gt.message),window.setTimeout(()=>Z(null),4e3)}},V=async yt=>{try{Z("pasting text…");const gt=await b4(t,yt);Z(gt.chapter?"chunk added":"chapter created"),window.setTimeout(()=>Z(null),1500),gt.open?f?.(gt):(Y(wt=>wt+1),o?.(t))}catch(gt){Z("paste failed: "+gt.message),window.setTimeout(()=>Z(null),4e3)}};if(ft.useEffect(()=>{h&&(document.title=h.title?.trim()||d8(t)||"yamlover")},[h,t]),ft.useEffect(()=>{if(z(null),ne(null),!h)return;const yt=N$(h),gt=I$(h),wt=[...yt.map(et=>et.name),...M$(h),...gt?[gt.name]:[]],At=D$(r,h,wt);[...yt,...gt?[gt]:[]].some(et=>et.name===At)||(q$(At)?f4(t,d0()??void 0).then(z).catch(et=>Q(et.message)):(h.type==="binary"||h.valueType==="binary")&&on(t,void 0,{binary:!0}).then(et=>ne(et.value)).catch(et=>Q(et.message)))},[r,t,h]),ge)return ye.jsx("div",{className:"error",children:ge});if(!h)return ye.jsx("div",{className:"loading",children:"…"});const Fe=N$(h),ce=M$(h),U=I$(h),x=U?[...Fe,U]:Fe,$=[...Fe.map(yt=>yt.name),...ce,...U?[U.name]:[]],l=D$(r,h,$),c=yt=>x.find(gt=>gt.name===yt)?.label??yt,p={yamlover:"y:",json5p:"{}","yamlover/schema":"$"},_=yt=>x.find(gt=>gt.name===yt)?.icon??p[yt]??yt,S=x.find(yt=>yt.name===l)??null,C=S!=null,ee=C&&!!S&&f8.has(S.name);$e.current=ee;const Le=h.documentPath??t;let nt,dt;C?(nt=h.value,dt=!0):q$(l)?(nt=A,dt=A!=null):h.type==="binary"||h.valueType==="binary"?(nt=L,dt=L!=null):(nt=h.value,dt=!0);const{tags:lt,rest:xt}=t3(h.relations),bt=[...lt];for(const yt of Ce)yt.fragmentSlug||yt.tag&&!bt.some(gt=>gt.path===yt.tag.path)&&bt.push({path:yt.tag.path,label:yt.tag.name,color:yt.tag.color});return ye.jsxs("div",{className:"nodeview",children:[ve&&ye.jsx("div",{className:"paste-toast",children:ve}),be&&ye.jsx("div",{className:"drop-overlay",children:"Drop file to upload"}),ye.jsxs("div",{className:"nodehead",children:[ye.jsxs("div",{className:"nodemeta",children:[ye.jsx("span",{className:"tag",children:h.type}),h.concrete&&ye.jsx("span",{className:"tag dim",children:h.concrete}),ye.jsx(Cg,{tags:bt,onNavigate:s})]}),ye.jsx("span",{className:"bar-sep","aria-hidden":"true",children:"|"}),ee&&ye.jsxs("button",{className:"lockbtn"+(pe?" unlocked":""),title:pe?"Editing — click or Esc to finish":"Read-only — click or F2 to edit","aria-pressed":pe,onClick:()=>se(yt=>!yt),children:[ye.jsx("span",{className:"lockbtn-icon","aria-hidden":"true",children:pe?"✓":"✏️"}),ye.jsx("span",{className:"lockbtn-label",children:pe?"Done":"Edit"})]}),ye.jsx("div",{className:"tabs",children:$.map(yt=>ye.jsxs(ft.Fragment,{children:[ye.jsx("button",{className:"tab"+(l===yt?" active":""),title:c(yt),"aria-label":c(yt),onClick:()=>i(yt),children:_(yt)}),C&&S&&yt===S.name&&S.config?.(O,h),!C&&yt===l&&ye.jsx(c8,{onChange:()=>Y(gt=>gt+1)})]},yt))})]}),!C&&h.description&&ye.jsx("p",{className:"nodedesc",children:h.description}),C?ye.jsx(kg.Provider,{value:{unlocked:pe},children:$8.has(S.name)&&!pe?ye.jsx(w3,{path:t,children:S.render(h,s)}):S.render(h,s)}):ye.jsxs("pre",{className:"code",children:[!q$(l)&&Object.keys(xt).length>0&&ye.jsxs(ye.Fragment,{children:[ye.jsx(bp,{value:xt,syntax:Y_(l),onNavigate:s,documentPath:Le,nodePath:t,anchors:!1}),ye.jsx("hr",{className:"reldiv"})]}),dt?ye.jsx(bp,{value:nt,syntax:Y_(l),onNavigate:s,documentPath:Le,nodePath:t,comments:h.comments}):"…"]})]})});function v8(e,t){return(e===":"?"":e)+":yamlover-fragments:"+t}function y8(e){const t=[],r=new Map;for(const n of e){if(!n.fragmentSlug)continue;let i=r.get(n.fragmentSlug);i?(!i.selector&&n.selector&&(i.selector=n.selector),!i.imageUrl&&n.imageUrl&&(i.imageUrl=n.imageUrl)):(i={slug:n.fragmentSlug,node:n.node,selector:n.selector,imageUrl:n.imageUrl,tags:[]},r.set(n.fragmentSlug,i),t.push(n.fragmentSlug)),n.tag&&!i.tags.some(s=>s.path===n.tag.path)&&i.tags.push({path:n.tag.path,label:n.tag.name,color:n.tag.color})}return t.map(n=>r.get(n))}function b8(e){const t=e.selector;if(t?.type==="text"&&typeof t.exact=="string")return t.exact;switch(t?.type){case"map":return"map region";case"pdf":return"PDF region";case"rect":return"image region";case"djvu":return"djvu region";default:return"fragment"}}function x8({path:e,groups:t,width:r,onNavigate:n}){const[i,s]=ft.useState(new Set),o=d=>{window.location.hash="#"+_g(d.node??e,d.slug)},f=async d=>{s(z=>new Set(z).add(d.slug));const A=v8(d.node??e,d.slug);try{for(const z of d.tags)await Ou(A,z.path)}catch(z){s(L=>{const ne=new Set(L);return ne.delete(d.slug),ne}),window.alert("delete failed: "+z.message)}},h=t.filter(d=>!i.has(d.slug));return h.length===0?null:ye.jsxs("aside",{className:"pane fragments",style:{width:r},children:[ye.jsxs("div",{className:"fragments-head",children:[ye.jsx("span",{className:"fragments-title",children:"Fragments"}),ye.jsx("span",{className:"fragments-count",children:h.length})]}),ye.jsx("ul",{className:"fragments-list",children:h.map(d=>ye.jsxs("li",{className:"fragment-row",children:[ye.jsxs("div",{className:"fragment-main",children:[ye.jsx("button",{type:"button",className:"fragment-locate",title:"Scroll to this fragment",onClick:()=>o(d),children:d.imageUrl?ye.jsx("img",{className:"fragment-thumb",src:d.imageUrl,alt:""}):ye.jsx("span",{className:"fragment-excerpt",children:b8(d)})}),ye.jsx("button",{type:"button",className:"fragment-delete",title:"Delete this fragment","aria-label":"Delete this fragment",onClick:()=>f(d),children:"✕"})]}),d.tags.length>0&&ye.jsx("div",{className:"fragment-tags",children:ye.jsx(Cg,{tags:d.tags,onNavigate:n})})]},d.slug))})]})}const w8=e=>Dy.includes(e),k8=(e,t)=>w8(e)&&(e!=="json5p"||ec(t));function G_(e){try{return localStorage.getItem(e)==="1"}catch{return!1}}const na=1;function h0(e,t,r){return e.path===t?{...e,children:r}:e.children.length?{...e,children:e.children.map(n=>h0(n,t,r))}:e}function Ly(e,t){if(!e)return t;const r=new Map(e.children.map(i=>[i.path,i])),n=t.children.length?t.children.map(i=>Ly(r.get(i.path),i)):t.hasChildren?e.children:[];return{...t,children:n}}function p0(e,t,r){return e.path===t?Ly(e,r):e.children.length?{...e,children:e.children.map(n=>p0(n,t,r))}:e}function ma(e,t){if(e.path===t)return e;for(const r of e.children){const n=ma(r,t);if(n)return n}return null}function S8(e,t){const r=Vr(t);for(let n=0;n<r.length;n++){const i=Un(r.slice(0,n)),s=ma(e,i);if(!s)return null;if(s.hasChildren&&s.children.length===0)return i}return null}function E8(e){if(!e)return[];const t=[],r=n=>{t.push(n.path);for(const i of zy(n).children)r(i)};return r(e),t}function A8(){const[e,t]=ft.useState(null),[r,n]=ft.useState(null),[i,s]=ft.useState(mp()),[o,f]=ft.useState(gp(pl)),[h,d]=ft.useState(""),[A,z]=ft.useState("idle"),L=ft.useCallback(()=>{const lt=":.yamlover:settings.yamlover";ea(lt,"settings",!1),s(lt),f("settings")},[]),[ne,ge]=ft.useState(320),[Q,F]=ft.useState(300),[Y,pe]=ft.useState(()=>G_("yo-left-collapsed")),[se,ve]=ft.useState(()=>G_("yo-right-collapsed"));ft.useEffect(()=>{try{localStorage.setItem("yo-left-collapsed",Y?"1":"0")}catch{}},[Y]),ft.useEffect(()=>{try{localStorage.setItem("yo-right-collapsed",se?"1":"0")}catch{}},[se]);const Z=ft.useRef(null),be=y8(bd(i)),ue=be.length>0&&!se&&!Dy.includes(o);ft.useEffect(()=>{hp().then(lt=>d(lt.root)).catch(()=>{})},[]);const[Ee,O]=ft.useState([]);ft.useEffect(()=>{$4().then(O).catch(()=>{})},[]);const Ce=ft.useCallback(lt=>{O(xt=>[...xt.filter(bt=>bt.id!==lt.id),lt].sort((bt,yt)=>bt.startedAt-yt.startedAt)),lt.state!=="running"&&setTimeout(()=>O(xt=>xt.filter(bt=>bt.id!==lt.id)),3e3)},[]),$e=ft.useRef(new URLSearchParams(window.location.search).has("format"));ft.useEffect(()=>{ea(i,o,!0)},[]),ft.useEffect(()=>{Os(":",na).then(t).catch(lt=>n(lt.message))},[]);const w=ft.useRef(!1);ft.useEffect(()=>{if($e.current||w.current||!e)return;const lt=ma(e,i);if(!lt)return;w.current=!0;const xt=tu(lt,lt.concrete);xt&&(f(xt),ea(i,xt,!0))},[e,i]);const Ae=ft.useCallback(async(lt,xt=na)=>{const bt=await Os(lt,xt);t(yt=>yt&&h0(yt,lt,bt.children))},[]);ft.useEffect(()=>{if(!e)return;const lt=S8(e,i);lt&&Ae(lt).catch(()=>{})},[e,i,Ae]);const j=ft.useRef(e);j.current=e;const de=ft.useRef(i);de.current=i;const[V,Fe]=ft.useState(0),ce=ft.useCallback(async lt=>{const xt=j.current;if(!xt)return;const bt=new Set;for(const gt of lt){const wt=Vr(gt);let At=":";for(let et=0;et<wt.length;et++){const ze=Un(wt.slice(0,et)),je=ma(xt,ze);if(!je)break;(ze===":"||je.children.length>0)&&(At=ze)}bt.add(At)}const yt=[...bt].filter(gt=>![...bt].some(wt=>wt!==gt&&Sl(wt,gt)));await Promise.all(yt.map(async gt=>{const wt=await Os(gt,na);t(At=>At&&p0(At,gt,wt))}))},[]),U=ft.useCallback(()=>{j.current||(Os(":",na).then(lt=>{t(lt),n(null)}).catch(()=>{}),hp().then(lt=>d(lt.root)).catch(()=>{}))},[]);ft.useEffect(()=>{if(typeof EventSource>"u")return;const lt=new EventSource(kr("/api/events"));let xt=!1;return lt.onopen=()=>{if(!xt){xt=!0;return}U(),Os(":",na).then(bt=>t(yt=>yt?p0(yt,":",bt):bt)).catch(()=>{}),Fe(bt=>bt+1)},lt.onmessage=bt=>{try{const yt=JSON.parse(bt.data);if(yt.type==="task"){const et=yt.task;Ce(et),et.state==="done"&&U();return}const gt=yt;U();const wt=[...gt.added,...gt.changed,...gt.removed,...(gt.moved??[]).flatMap(et=>[et.from,et.to])];if(!wt.length)return;n3({paths:wt,removed:gt.removed}),ce(wt).catch(()=>{});const At=de.current;wt.some(et=>et===At||Sl(et,At)||Sl(At,et))&&Fe(et=>et+1)}catch{}},()=>lt.close()},[ce,Ce,U]),ft.useEffect(()=>{const lt=()=>{s(mp()),f(gp(pl))};return window.addEventListener("popstate",lt),()=>window.removeEventListener("popstate",lt)},[]);const x=ft.useCallback(lt=>{const xt=e?ma(e,lt):null;let bt=o;xt&&(bt=tu(xt,xt.concrete)??(k8(o,xt.concrete)?o:pl)),ea(lt,bt,!1),s(lt),bt!==o&&f(bt)},[o,e]),$=ft.useCallback(lt=>{x(lt),Z.current?.focus()},[x]),{openAt:l,tagMenu:c}=wd({onCreate:(lt,xt,bt)=>void cg(lt,xt,bt).then(yt=>x(yt.path)).catch(yt=>window.alert("create failed: "+yt.message))}),p=ft.useCallback((lt,xt,bt)=>l(lt.path,xt,bt,lt),[l]),_=ft.useRef(x);_.current=x,ft.useEffect(()=>{const lt=xt=>{if(!(xt.ctrlKey||xt.altKey)||xt.key!=="ArrowDown"&&xt.key!=="ArrowUp")return;const bt=xt.target;if(bt&&(bt.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(bt.tagName)))return;const yt=E8(j.current),gt=yt.indexOf(de.current);if(gt<0)return;const wt=Math.min(Math.max(gt+(xt.key==="ArrowDown"?1:-1),0),yt.length-1);xt.preventDefault(),wt!==gt&&_.current(yt[wt])};return window.addEventListener("keydown",lt),()=>window.removeEventListener("keydown",lt)},[]);const S=ft.useCallback(lt=>{ea(i,lt,!0),f(lt)},[i]),C=ft.useCallback(lt=>{const xt=e?ma(e,lt):null;Ae(xt?lt:":").catch(()=>{})},[e,Ae]),ee=ft.useCallback(async lt=>{const xt=lt.dir??":";try{const bt=await Os(xt,na);t(wt=>wt&&h0(wt,xt,bt.children));const yt=bt.children.find(wt=>wt.path===lt.path),gt=(yt?tu(yt,yt.concrete):null)??pl;ea(lt.path,gt,!1),s(lt.path),f(gt)}catch{x(lt.path)}},[x]),Le=ft.useRef(null);ft.useEffect(()=>{const lt=bt=>{Le.current==="left"?ge(Math.min(Math.max(bt.clientX,160),window.innerWidth-240)):Le.current==="right"&&F(Math.min(Math.max(window.innerWidth-bt.clientX,200),window.innerWidth-240))},xt=()=>{Le.current=null,document.body.style.userSelect=""};return window.addEventListener("mousemove",lt),window.addEventListener("mouseup",xt),()=>{window.removeEventListener("mousemove",lt),window.removeEventListener("mouseup",xt)}},[]);const nt=lt=>{Le.current=lt,document.body.style.userSelect="none"},dt=ft.useCallback(async()=>{if(A!=="busy"){z("busy");try{const{files:lt}=await v4(),xt=lt.filter(bt=>bt.status!=="exists").map(bt=>bt.name);n(null),window.alert(xt.length?`Installed agent guide: ${xt.join(", ")}.`:"Agent guide is already up to date.")}catch(lt){n(`agent docs: ${lt.message}`)}finally{z("idle")}}},[A]);return ye.jsxs("div",{className:"app",children:[ye.jsxs("header",{className:"topbar",children:[ye.jsx("button",{type:"button",className:"crumb-action pane-toggle",title:Y?"Show the tree":"Hide the tree","aria-label":Y?"Show the tree":"Hide the tree","aria-pressed":!Y,onClick:()=>pe(lt=>!lt),children:Y?"»":"«"}),ye.jsxs("nav",{className:"crumbs",children:[ye.jsx("button",{type:"button",className:"crumb-action crumb-settings",title:"Project configuration (settings.yamlover)","aria-label":"Project configuration",onClick:L,children:"⚙"}),ye.jsx("button",{type:"button",className:"crumb-action",disabled:A==="busy",title:"Install the LLM agent guide (AGENTS.md + CLAUDE.md) into this project","aria-label":"Install LLM agent guide",onClick:dt,children:"🤖"}),z4(i,h).map((lt,xt)=>ye.jsxs("span",{children:[xt>0&&ye.jsx("span",{className:"crumb-sep",children:":"}),ye.jsx("a",{className:"crumb",href:lt.path,onClick:bt=>{bt.preventDefault(),x(lt.path)},children:lt.label})]},lt.path))]}),ye.jsxs("div",{className:"topbar-right",children:[ye.jsx(Qw,{tasks:Ee}),be.length>0&&ye.jsx("button",{type:"button",className:"crumb-action pane-toggle",title:se?"Show fragments":"Hide fragments","aria-label":se?"Show fragments":"Hide fragments","aria-pressed":!se,onClick:()=>ve(lt=>!lt),children:se?"«":"»"})]})]}),ye.jsxs("div",{className:"body",children:[!Y&&ye.jsxs(ye.Fragment,{children:[ye.jsx("aside",{className:"pane left",style:{width:ne},children:(()=>{const lt=e?void 0:Ee.find(xt=>xt.state==="running");if(lt){const{done:xt,total:bt}=lt.progress;return ye.jsxs("div",{className:"loading",children:[lt.label,"… ",bt?`${xt}/${bt}`:""]})}return r?ye.jsx("div",{className:"error",children:r}):e?ye.jsx(Xw,{node:e,current:i,onSelect:$,onLoadChildren:Ae,onContext:p}):ye.jsx("div",{className:"loading",children:"loading…"})})()}),ye.jsx("div",{className:"splitter",onMouseDown:()=>nt("left")})]}),ye.jsx("main",{className:"pane right",ref:Z,tabIndex:-1,children:(()=>{const lt=e?void 0:Ee.find(xt=>xt.state==="running");if(lt){const{done:xt,total:bt}=lt.progress;return ye.jsxs("div",{className:"loading",children:[lt.label,"… ",bt?`${xt}/${bt}`:""]})}return ye.jsx(g8,{path:i,format:o,refreshSignal:V,onFormat:S,onNavigate:x,onContentChanged:C,onOpenUploaded:ee})})()}),ue&&ye.jsxs(ye.Fragment,{children:[ye.jsx("div",{className:"splitter",onMouseDown:()=>nt("right")}),ye.jsx(x8,{path:i,groups:be,width:Q,onNavigate:x})]})]}),c]})}class C8 extends ft.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){console.error("yamlover UI crashed:",t)}render(){const{error:t}=this.state;return t?ye.jsxs("div",{className:"crash",children:[ye.jsx("h1",{children:"Something went wrong"}),ye.jsx("p",{children:"The viewer hit an error and stopped rendering."}),ye.jsx("pre",{children:t.message}),ye.jsxs("div",{className:"crash-actions",children:[ye.jsx("button",{onClick:()=>this.setState({error:null}),children:"Try again"}),ye.jsx("button",{onClick:()=>location.reload(),children:"Reload"})]})]}):this.props.children}}lg(document.getElementById("root")).render(ye.jsx(e2.StrictMode,{children:ye.jsx(C8,{children:ye.jsx(A8,{})})}));export{a3 as D,x3 as a,vs as b,l3 as c,T8 as d,wp as e,_g as f,Fy as g,Zx as h,Hn as i,ye as j,_d as k,R8 as p,ft as r,$0 as s,v3 as u,z8 as w};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as ft,s as pt,j as L,k as mt,h as gt,r as f,b as dt,D as Y,f as yt,e as ht,c as bt}from"./index-DqdQvRi4.js";import{O as Lt,L as O,w as xt}from"./openable-DIyqYrzm.js";function x(t,e){return Array.from(t.getElementsByTagName(e))}function v(t){return t[0]==="#"?t:`#${t}`}function Tt(t,e,n){return Array.from(t.getElementsByTagNameNS(n,e))}function m(t){return t?.normalize(),t?.textContent||""}function u(t,e,n){const r=t.getElementsByTagName(e);return r.length?r[0]:null}function T(t,e,n){const r={};if(!t)return r;const o=t.getElementsByTagName(e),i=o.length?o[0]:null;return i&&n?n(i,r):r}function k(t,e,n){const r=m(u(t,e));return r&&n?n(r)||{}:{}}function p(t,e,n){const r=Number.parseFloat(m(u(t,e)));if(!Number.isNaN(r))return n&&n(r),r}function M(t,e){const n={};for(const r of e)k(t,r,o=>{n[r]=o});return n}function et(t){return t?.nodeType===1}function nt(t,e){const n={},r=e==="stroke"||e==="fill"?e:`${e}-color`;return t[0]==="#"&&(t=t.substring(1)),t.length===6||t.length===3?n[r]=`#${t}`:t.length===8&&(n[`${e}-opacity`]=Number.parseInt(t.substring(0,2),16)/255,n[r]=`#${t.substring(6,8)}${t.substring(4,6)}${t.substring(2,4)}`),n}function _(t,e,n){const r={};return p(t,e,o=>{r[n]=o}),r}function V(t,e){return T(t,"color",n=>nt(m(n),e))}function $(t){return T(t,"Icon",(e,n)=>(k(e,"href",r=>{n.icon=r}),n))}function Nt(t){return T(t,"IconStyle",e=>Object.assign(V(e,"icon"),_(e,"scale","icon-scale"),_(e,"heading","icon-heading"),T(e,"hotSpot",n=>{const r=Number.parseFloat(n.getAttribute("x")||""),o=Number.parseFloat(n.getAttribute("y")||""),i=n.getAttribute("xunits")||"",s=n.getAttribute("yunits")||"";return!Number.isNaN(r)&&!Number.isNaN(o)?{"icon-offset":[r,o],"icon-offset-units":[i,s]}:{}}),$(e)))}function Ot(t){return T(t,"LabelStyle",e=>Object.assign(V(e,"label"),_(e,"scale","label-scale")))}function wt(t){return T(t,"LineStyle",e=>Object.assign(V(e,"stroke"),_(e,"width","stroke-width")))}function Et(t){return T(t,"PolyStyle",(e,n)=>Object.assign(n,T(e,"color",r=>nt(m(r),"fill")),k(e,"fill",r=>{if(r==="0")return{"fill-opacity":0}}),k(e,"outline",r=>{if(r==="0")return{"stroke-opacity":0}})))}function B(t){return Object.assign({},Et(t),wt(t),Ot(t),Nt(t))}const kt=/\s*/g,At=/^\s*|\s*$/g,Rt=/\s+/;function rt(t){return t.replace(kt,"").split(",").map(Number.parseFloat).filter(e=>!Number.isNaN(e)).slice(0,3)}function F(t){return t.replace(At,"").split(Rt).map(rt).filter(e=>e.length>=2)}function St(t){let e=x(t,"coord");e.length===0&&(e=Tt(t,"coord","*"));const n=e.map(r=>m(r).split(" ").map(Number.parseFloat));return n.length===0?null:{geometry:n.length>2?{type:"LineString",coordinates:n}:{type:"Point",coordinates:n[0]},times:x(t,"when").map(r=>m(r))}}function ot(t){if(t.length===0)return t;const e=t[0],n=t[t.length-1];let r=!0;for(let o=0;o<Math.max(e.length,n.length);o++)if(e[o]!==n[o]){r=!1;break}return r?t:t.concat([t[0]])}function S(t){return m(u(t,"coordinates"))}function it(t){let e=[],n=[];for(let r=0;r<t.childNodes.length;r++){const o=t.childNodes.item(r);if(et(o))switch(o.tagName){case"MultiGeometry":case"MultiTrack":case"gx:MultiTrack":{const i=it(o);e=e.concat(i.geometries),n=n.concat(i.coordTimes);break}case"Point":{const i=rt(S(o));i.length>=2&&e.push({type:"Point",coordinates:i});break}case"LinearRing":case"LineString":{const i=F(S(o));i.length>=2&&e.push({type:"LineString",coordinates:i});break}case"Polygon":{const i=[];for(const s of x(o,"LinearRing")){const c=ot(F(S(s)));c.length>=4&&i.push(c)}i.length&&e.push({type:"Polygon",coordinates:i});break}case"Track":case"gx:Track":{const i=St(o);if(!i)break;const{times:s,geometry:c}=i;e.push(c),s.length&&n.push(s);break}}}return{geometries:e,coordTimes:n}}const E=t=>Number(t),D={string:t=>t,int:E,uint:E,short:E,ushort:E,float:E,double:E,bool:t=>!!t};function U(t,e){return T(t,"ExtendedData",(n,r)=>{for(const o of x(n,"Data"))r[o.getAttribute("name")||""]=m(u(o,"value"));for(const o of x(n,"SimpleData")){const i=o.getAttribute("name")||"",s=e[i]||D.string;r[i]=s(m(o))}return r})}function Z(t){const e=u(t,"description");for(const n of Array.from(e?.childNodes||[]))if(n.nodeType===4)return{description:{"@type":"html",value:m(n)}};return{}}function z(t){return T(t,"TimeSpan",e=>({timespan:{begin:m(u(e,"begin")),end:m(u(e,"end"))}}))}function H(t){return T(t,"TimeStamp",e=>({timestamp:m(u(e,"when"))}))}function J(t,e){return k(t,"styleUrl",n=>(n=v(n),e[n]?Object.assign({styleUrl:n},e[n]):{styleUrl:n}))}var d;(function(t){t.ABSOLUTE="absolute",t.RELATIVE_TO_GROUND="relativeToGround",t.CLAMP_TO_GROUND="clampToGround",t.CLAMP_TO_SEAFLOOR="clampToSeaFloor",t.RELATIVE_TO_SEAFLOOR="relativeToSeaFloor"})(d||(d={}));function vt(t){switch(t?.textContent){case d.ABSOLUTE:return d.ABSOLUTE;case d.CLAMP_TO_GROUND:return d.CLAMP_TO_GROUND;case d.CLAMP_TO_SEAFLOOR:return d.CLAMP_TO_SEAFLOOR;case d.RELATIVE_TO_GROUND:return d.RELATIVE_TO_GROUND;case d.RELATIVE_TO_SEAFLOOR:return d.RELATIVE_TO_SEAFLOOR}return null}function _t(t){return u(t,"gx:LatLonQuad")?{geometry:{type:"Polygon",coordinates:[ot(F(S(t)))]}}:Ct(t)}const Mt=Math.PI/180;function Bt(t,e,n){const r=[(t[0]+t[2])/2,(t[1]+t[3])/2];return[e[0].map(o=>{const i=o[1]-r[1],s=o[0]-r[0],c=Math.sqrt(i**2+s**2),a=Math.atan2(i,s)+n*Mt;return[r[0]+Math.cos(a)*c,r[1]+Math.sin(a)*c]})]}function Ct(t){const e=u(t,"LatLonBox");if(e){const n=p(e,"north"),r=p(e,"west"),o=p(e,"east"),i=p(e,"south"),s=p(e,"rotation");if(typeof n=="number"&&typeof i=="number"&&typeof r=="number"&&typeof o=="number"){const c=[r,i,o,n];let a=[[[r,n],[o,n],[o,i],[r,i],[r,n]]];return typeof s=="number"&&(a=Bt(c,a,s)),{bbox:c,geometry:{type:"Polygon",coordinates:a}}}}return null}function It(t,e,n,r){const o=_t(t),i=o?.geometry||null;if(!i&&r.skipNullGeometry)return null;const s={type:"Feature",geometry:i,properties:Object.assign({"@geometry-type":"groundoverlay"},M(t,["name","address","visibility","open","phoneNumber","description"]),Z(t),J(t,e),B(t),$(t),U(t,n),z(t),H(t))};o?.bbox&&(s.bbox=o.bbox),s.properties?.visibility!==void 0&&(s.properties.visibility=s.properties.visibility!=="0");const c=t.getAttribute("id");return c!==null&&c!==""&&(s.id=c),s}function Pt(t){const e=u(t,"Region");return e?{coordinateBox:jt(e),lod:Gt(t)}:null}function Gt(t){const e=u(t,"Lod");return e?[p(e,"minLodPixels")??-1,p(e,"maxLodPixels")??-1,p(e,"minFadeExtent")??null,p(e,"maxFadeExtent")??null]:null}function jt(t){const e=u(t,"LatLonAltBox");if(e){const n=p(e,"north"),r=p(e,"west"),o=p(e,"east"),i=p(e,"south");if(vt(u(e,"altitudeMode")||u(e,"gx:altitudeMode"))&&console.debug("Encountered an unsupported feature of KML for togeojson: please contact developers for support of altitude mode."),typeof n=="number"&&typeof i=="number"&&typeof r=="number"&&typeof o=="number")return{bbox:[r,i,o,n],geometry:{type:"Polygon",coordinates:[[[r,n],[o,n],[o,i],[r,i],[r,n]]]}}}return null}function Ft(t){const e=u(t,"Link");return e?M(e,["href","refreshMode","refreshInterval","viewRefreshMode","viewRefreshTime","viewBoundScale","viewFormat","httpQuery"]):{}}function Dt(t,e,n,r){const o=Pt(t),i=o?.coordinateBox?.geometry||null;if(!i&&r.skipNullGeometry)return null;const s={type:"Feature",geometry:i,properties:Object.assign({"@geometry-type":"networklink"},M(t,["name","address","visibility","open","phoneNumber","styleUrl","refreshVisibility","flyToView","description"]),Z(t),J(t,e),B(t),$(t),U(t,n),z(t),H(t),Ft(t),o?.lod?{lod:o.lod}:{})};o?.coordinateBox?.bbox&&(s.bbox=o.coordinateBox.bbox),s.properties?.visibility!==void 0&&(s.properties.visibility=s.properties.visibility!=="0");const c=t.getAttribute("id");return c!==null&&c!==""&&(s.id=c),s}function Vt(t){return t.length===0?null:t.length===1?t[0]:{type:"GeometryCollection",geometries:t}}function $t(t,e,n,r){const{coordTimes:o,geometries:i}=it(t),s=Vt(i);if(!s&&r.skipNullGeometry)return null;const c={type:"Feature",geometry:s,properties:Object.assign(M(t,["name","address","visibility","open","phoneNumber","description"]),Z(t),J(t,e),B(t),U(t,n),z(t),H(t),o.length?{coordinateProperties:{times:o.length===1?o[0]:o}}:{})};c.properties?.visibility!==void 0&&(c.properties.visibility=c.properties.visibility!=="0");const a=t.getAttribute("id");return a!==null&&a!==""&&(c.id=a),c}function Ut(t){let e=t.getAttribute("id");const n=t.parentNode;return!e&&et(n)&&n.localName==="CascadingStyle"&&(e=n.getAttribute("kml:id")||n.getAttribute("id")),v(e||"")}function Zt(t){const e={};for(const n of x(t,"Style"))e[Ut(n)]=B(n);for(const n of x(t,"StyleMap")){const r=v(n.getAttribute("id")||"");k(n,"styleUrl",o=>{o=v(o),e[o]&&(e[r]=e[o])})}return e}function zt(t){const e={};for(const n of x(t,"SimpleField"))e[n.getAttribute("name")||""]=D[n.getAttribute("type")||""]||D.string;return e}function*Ht(t,e={skipNullGeometry:!1}){const n=t,r=Zt(n),o=zt(n);for(const i of x(n,"Placemark")){const s=$t(i,r,o,e);s&&(yield s)}for(const i of x(n,"GroundOverlay")){const s=It(i,r,o,e);s&&(yield s)}for(const i of x(n,"NetworkLink")){const s=Dt(i,r,o,e);s&&(yield s)}}function Jt(t,e={skipNullGeometry:!1}){return{type:"FeatureCollection",features:Array.from(Ht(t,e))}}function Kt(t){return t[0]===80&&t[1]===75&&t[2]===3&&t[3]===4}function tt(t){const e=new DOMParser().parseFromString(t,"application/xml");if(e.getElementsByTagName("parsererror").length)throw new Error("malformed KML XML");return Jt(e)}function Qt(t){if(Kt(t)){const e=ft(t),n=Object.keys(e).find(r=>r.toLowerCase().endsWith(".kml"));if(!n)throw new Error("no .kml document inside the KMZ archive");return tt(pt(e[n]))}return tt(new TextDecoder().decode(t))}const st={},Wt=st?.VITE_MAP_TILE_URL??"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",qt=st?.VITE_MAP_TILE_ATTRIBUTION??'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',N=t=>Number(t)||0;function Xt(t,e){return t.filter(n=>n.selector?.type==="map").map(n=>({n:N(n.selector.n),s:N(n.selector.s),e:N(n.selector.e),w:N(n.selector.w),title:n.description,color:bt(n),ann:ht(n)?n:void 0,id:n.fragmentSlug?yt(e,n.fragmentSlug):void 0}))}function ct(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Yt(t){return t?typeof t=="string"?ct(t):typeof t=="object"&&t["@type"]==="html"?String(t.value??""):"":""}function te(t,e,n=!0){const r=O.map(t,n?{}:{dragging:!1,scrollWheelZoom:!1,doubleClickZoom:!1,boxZoom:!1,keyboard:!1,touchZoom:!1,zoomControl:!1});O.tileLayer(Wt,{maxZoom:19,attribution:qt}).addTo(r);const i=O.geoJSON(e,{style:s=>{const c=s?.properties??{};return{color:c.stroke||"#3388ff",weight:c["stroke-width"]||2,opacity:c["stroke-opacity"]??1,fillColor:c.fill||"#3388ff",fillOpacity:c["fill-opacity"]??.2}},pointToLayer:(s,c)=>O.circleMarker(c,{radius:5,color:"#e23",weight:2,fillOpacity:.8}),onEachFeature:n?(s,c)=>{const a=s.properties??{},w=a.name?`<strong>${ct(a.name)}</strong>`:"",A=Yt(a.description),R=A?`<div class="map-popup-desc">${A}</div>`:"";(w||R)&&c.bindPopup(`${w}${R}`)}:void 0}).addTo(r).getBounds();return i.isValid()?r.fitBounds(i,{padding:[24,24],maxZoom:16}):r.setView([0,0],2),r}function at({path:t,className:e,regions:n,onSelectRegion:r,onRegionClick:o,selectColor:i,interactive:s=!0}){const c=f.useRef(null),a=f.useRef(null),w=f.useRef(null),A=f.useRef(r),R=f.useRef(o),K=f.useRef(i),[C,Q]=f.useState(null),[lt,I]=f.useState(!0),[W,ut]=f.useState(0),q=JSON.stringify(n??[]),X=!!r;f.useEffect(()=>{A.current=r,R.current=o,K.current=i}),f.useEffect(()=>{let y=!1,l=null;return Q(null),I(!0),fetch(dt(t)).then(g=>g.arrayBuffer()).then(g=>{if(y||!c.current)return;const h=te(c.current,Qt(new Uint8Array(g)),s);w.current=O.layerGroup().addTo(h),a.current=h,s&&(l=xt(h,{color:()=>K.current?.()??Y,onSelect:X?(b,G)=>A.current?.({type:"map",n:b.getNorth(),s:b.getSouth(),e:b.getEast(),w:b.getWest()},G):void 0})),ut(b=>b+1),I(!1)}).catch(g=>{y||(Q(String(g.message||g)),I(!1))}),()=>{y=!0,l?.(),a.current?.remove(),a.current=null,w.current=null}},[t]);const P=f.useRef(new Map);return f.useEffect(()=>{const y=w.current;if(y){y.clearLayers(),P.current.clear();for(const l of n??[]){const g=l.color||Y,h=[[l.s,l.w],[l.n,l.e]],b=O.rectangle(h,{className:"yo-region",color:g,weight:3,fillColor:g,fillOpacity:.25});if(l.title&&b.bindTooltip(l.title),l.ann){const G=l.ann;b.on("click",j=>{O.DomEvent.stop(j),R.current?.(G,{x:j.originalEvent.clientX,y:j.originalEvent.clientY})})}b.addTo(y),l.id&&P.current.set(l.id,{rect:b,bounds:h})}}},[q,W]),f.useEffect(()=>{const y=()=>{const l=a.current,g=decodeURIComponent(window.location.hash.slice(1)),h=g?P.current.get(g):void 0;!l||!h||(l.fitBounds(h.bounds,{maxZoom:l.getZoom(),padding:[40,40]}),h.rect.setStyle({weight:6,fillOpacity:.45}),window.setTimeout(()=>h.rect.setStyle({weight:3,fillOpacity:.25}),1e3))};return y(),window.addEventListener("hashchange",y),()=>window.removeEventListener("hashchange",y)},[q,W]),L.jsxs(L.Fragment,{children:[C&&L.jsxs("div",{className:"error",children:["map: ",C]}),L.jsx("div",{ref:c,className:e+(X?" yo-selectable":"")}),lt&&!C&&L.jsx("div",{className:"loading",children:"loading map…"})]})}function re({node:t}){const e=mt(t.path),{openCreate:n,openEdit:r,palette:o,preview:i,color:s}=gt(e,t.path),c=Xt(e.annotations,t.path);if(i?.selector.type==="map"){const a=i.selector;c.push({n:N(a.n),s:N(a.s),e:N(a.e),w:N(a.w),color:i.color})}return L.jsxs("div",{className:"text",children:[t.title&&L.jsx("h1",{className:"chapter-title",children:t.title}),t.description&&L.jsx("p",{className:"chapter-subtitle",children:t.description}),L.jsx(at,{path:t.path,regions:c,onSelectRegion:n,onRegionClick:r,selectColor:()=>s,className:"filemap"}),o]})}function oe({chunk:t,onNavigate:e}){return L.jsx(Lt,{path:t.path,onNavigate:e,title:"Open map on its own page",children:L.jsx(at,{path:t.path,className:"filemap chunk-map chunk-static",interactive:!1})})}export{oe as MapChunk,re as MapView};
|
|
1
|
+
import{h as ft,s as pt,j as L,u as mt,a as gt,r as f,b as dt,D as Y,f as yt,e as ht,c as bt}from"./index-Dwsn6NQE.js";import{O as Lt,L as O,w as xt}from"./openable-Bh72damS.js";function x(t,e){return Array.from(t.getElementsByTagName(e))}function v(t){return t[0]==="#"?t:`#${t}`}function Tt(t,e,n){return Array.from(t.getElementsByTagNameNS(n,e))}function m(t){return t?.normalize(),t?.textContent||""}function u(t,e,n){const r=t.getElementsByTagName(e);return r.length?r[0]:null}function T(t,e,n){const r={};if(!t)return r;const o=t.getElementsByTagName(e),i=o.length?o[0]:null;return i&&n?n(i,r):r}function k(t,e,n){const r=m(u(t,e));return r&&n?n(r)||{}:{}}function p(t,e,n){const r=Number.parseFloat(m(u(t,e)));if(!Number.isNaN(r))return n&&n(r),r}function M(t,e){const n={};for(const r of e)k(t,r,o=>{n[r]=o});return n}function et(t){return t?.nodeType===1}function nt(t,e){const n={},r=e==="stroke"||e==="fill"?e:`${e}-color`;return t[0]==="#"&&(t=t.substring(1)),t.length===6||t.length===3?n[r]=`#${t}`:t.length===8&&(n[`${e}-opacity`]=Number.parseInt(t.substring(0,2),16)/255,n[r]=`#${t.substring(6,8)}${t.substring(4,6)}${t.substring(2,4)}`),n}function _(t,e,n){const r={};return p(t,e,o=>{r[n]=o}),r}function V(t,e){return T(t,"color",n=>nt(m(n),e))}function $(t){return T(t,"Icon",(e,n)=>(k(e,"href",r=>{n.icon=r}),n))}function Nt(t){return T(t,"IconStyle",e=>Object.assign(V(e,"icon"),_(e,"scale","icon-scale"),_(e,"heading","icon-heading"),T(e,"hotSpot",n=>{const r=Number.parseFloat(n.getAttribute("x")||""),o=Number.parseFloat(n.getAttribute("y")||""),i=n.getAttribute("xunits")||"",s=n.getAttribute("yunits")||"";return!Number.isNaN(r)&&!Number.isNaN(o)?{"icon-offset":[r,o],"icon-offset-units":[i,s]}:{}}),$(e)))}function Ot(t){return T(t,"LabelStyle",e=>Object.assign(V(e,"label"),_(e,"scale","label-scale")))}function wt(t){return T(t,"LineStyle",e=>Object.assign(V(e,"stroke"),_(e,"width","stroke-width")))}function Et(t){return T(t,"PolyStyle",(e,n)=>Object.assign(n,T(e,"color",r=>nt(m(r),"fill")),k(e,"fill",r=>{if(r==="0")return{"fill-opacity":0}}),k(e,"outline",r=>{if(r==="0")return{"stroke-opacity":0}})))}function B(t){return Object.assign({},Et(t),wt(t),Ot(t),Nt(t))}const kt=/\s*/g,At=/^\s*|\s*$/g,Rt=/\s+/;function rt(t){return t.replace(kt,"").split(",").map(Number.parseFloat).filter(e=>!Number.isNaN(e)).slice(0,3)}function F(t){return t.replace(At,"").split(Rt).map(rt).filter(e=>e.length>=2)}function St(t){let e=x(t,"coord");e.length===0&&(e=Tt(t,"coord","*"));const n=e.map(r=>m(r).split(" ").map(Number.parseFloat));return n.length===0?null:{geometry:n.length>2?{type:"LineString",coordinates:n}:{type:"Point",coordinates:n[0]},times:x(t,"when").map(r=>m(r))}}function ot(t){if(t.length===0)return t;const e=t[0],n=t[t.length-1];let r=!0;for(let o=0;o<Math.max(e.length,n.length);o++)if(e[o]!==n[o]){r=!1;break}return r?t:t.concat([t[0]])}function S(t){return m(u(t,"coordinates"))}function it(t){let e=[],n=[];for(let r=0;r<t.childNodes.length;r++){const o=t.childNodes.item(r);if(et(o))switch(o.tagName){case"MultiGeometry":case"MultiTrack":case"gx:MultiTrack":{const i=it(o);e=e.concat(i.geometries),n=n.concat(i.coordTimes);break}case"Point":{const i=rt(S(o));i.length>=2&&e.push({type:"Point",coordinates:i});break}case"LinearRing":case"LineString":{const i=F(S(o));i.length>=2&&e.push({type:"LineString",coordinates:i});break}case"Polygon":{const i=[];for(const s of x(o,"LinearRing")){const c=ot(F(S(s)));c.length>=4&&i.push(c)}i.length&&e.push({type:"Polygon",coordinates:i});break}case"Track":case"gx:Track":{const i=St(o);if(!i)break;const{times:s,geometry:c}=i;e.push(c),s.length&&n.push(s);break}}}return{geometries:e,coordTimes:n}}const E=t=>Number(t),D={string:t=>t,int:E,uint:E,short:E,ushort:E,float:E,double:E,bool:t=>!!t};function U(t,e){return T(t,"ExtendedData",(n,r)=>{for(const o of x(n,"Data"))r[o.getAttribute("name")||""]=m(u(o,"value"));for(const o of x(n,"SimpleData")){const i=o.getAttribute("name")||"",s=e[i]||D.string;r[i]=s(m(o))}return r})}function Z(t){const e=u(t,"description");for(const n of Array.from(e?.childNodes||[]))if(n.nodeType===4)return{description:{"@type":"html",value:m(n)}};return{}}function z(t){return T(t,"TimeSpan",e=>({timespan:{begin:m(u(e,"begin")),end:m(u(e,"end"))}}))}function H(t){return T(t,"TimeStamp",e=>({timestamp:m(u(e,"when"))}))}function J(t,e){return k(t,"styleUrl",n=>(n=v(n),e[n]?Object.assign({styleUrl:n},e[n]):{styleUrl:n}))}var d;(function(t){t.ABSOLUTE="absolute",t.RELATIVE_TO_GROUND="relativeToGround",t.CLAMP_TO_GROUND="clampToGround",t.CLAMP_TO_SEAFLOOR="clampToSeaFloor",t.RELATIVE_TO_SEAFLOOR="relativeToSeaFloor"})(d||(d={}));function vt(t){switch(t?.textContent){case d.ABSOLUTE:return d.ABSOLUTE;case d.CLAMP_TO_GROUND:return d.CLAMP_TO_GROUND;case d.CLAMP_TO_SEAFLOOR:return d.CLAMP_TO_SEAFLOOR;case d.RELATIVE_TO_GROUND:return d.RELATIVE_TO_GROUND;case d.RELATIVE_TO_SEAFLOOR:return d.RELATIVE_TO_SEAFLOOR}return null}function _t(t){return u(t,"gx:LatLonQuad")?{geometry:{type:"Polygon",coordinates:[ot(F(S(t)))]}}:Ct(t)}const Mt=Math.PI/180;function Bt(t,e,n){const r=[(t[0]+t[2])/2,(t[1]+t[3])/2];return[e[0].map(o=>{const i=o[1]-r[1],s=o[0]-r[0],c=Math.sqrt(i**2+s**2),a=Math.atan2(i,s)+n*Mt;return[r[0]+Math.cos(a)*c,r[1]+Math.sin(a)*c]})]}function Ct(t){const e=u(t,"LatLonBox");if(e){const n=p(e,"north"),r=p(e,"west"),o=p(e,"east"),i=p(e,"south"),s=p(e,"rotation");if(typeof n=="number"&&typeof i=="number"&&typeof r=="number"&&typeof o=="number"){const c=[r,i,o,n];let a=[[[r,n],[o,n],[o,i],[r,i],[r,n]]];return typeof s=="number"&&(a=Bt(c,a,s)),{bbox:c,geometry:{type:"Polygon",coordinates:a}}}}return null}function It(t,e,n,r){const o=_t(t),i=o?.geometry||null;if(!i&&r.skipNullGeometry)return null;const s={type:"Feature",geometry:i,properties:Object.assign({"@geometry-type":"groundoverlay"},M(t,["name","address","visibility","open","phoneNumber","description"]),Z(t),J(t,e),B(t),$(t),U(t,n),z(t),H(t))};o?.bbox&&(s.bbox=o.bbox),s.properties?.visibility!==void 0&&(s.properties.visibility=s.properties.visibility!=="0");const c=t.getAttribute("id");return c!==null&&c!==""&&(s.id=c),s}function Pt(t){const e=u(t,"Region");return e?{coordinateBox:jt(e),lod:Gt(t)}:null}function Gt(t){const e=u(t,"Lod");return e?[p(e,"minLodPixels")??-1,p(e,"maxLodPixels")??-1,p(e,"minFadeExtent")??null,p(e,"maxFadeExtent")??null]:null}function jt(t){const e=u(t,"LatLonAltBox");if(e){const n=p(e,"north"),r=p(e,"west"),o=p(e,"east"),i=p(e,"south");if(vt(u(e,"altitudeMode")||u(e,"gx:altitudeMode"))&&console.debug("Encountered an unsupported feature of KML for togeojson: please contact developers for support of altitude mode."),typeof n=="number"&&typeof i=="number"&&typeof r=="number"&&typeof o=="number")return{bbox:[r,i,o,n],geometry:{type:"Polygon",coordinates:[[[r,n],[o,n],[o,i],[r,i],[r,n]]]}}}return null}function Ft(t){const e=u(t,"Link");return e?M(e,["href","refreshMode","refreshInterval","viewRefreshMode","viewRefreshTime","viewBoundScale","viewFormat","httpQuery"]):{}}function Dt(t,e,n,r){const o=Pt(t),i=o?.coordinateBox?.geometry||null;if(!i&&r.skipNullGeometry)return null;const s={type:"Feature",geometry:i,properties:Object.assign({"@geometry-type":"networklink"},M(t,["name","address","visibility","open","phoneNumber","styleUrl","refreshVisibility","flyToView","description"]),Z(t),J(t,e),B(t),$(t),U(t,n),z(t),H(t),Ft(t),o?.lod?{lod:o.lod}:{})};o?.coordinateBox?.bbox&&(s.bbox=o.coordinateBox.bbox),s.properties?.visibility!==void 0&&(s.properties.visibility=s.properties.visibility!=="0");const c=t.getAttribute("id");return c!==null&&c!==""&&(s.id=c),s}function Vt(t){return t.length===0?null:t.length===1?t[0]:{type:"GeometryCollection",geometries:t}}function $t(t,e,n,r){const{coordTimes:o,geometries:i}=it(t),s=Vt(i);if(!s&&r.skipNullGeometry)return null;const c={type:"Feature",geometry:s,properties:Object.assign(M(t,["name","address","visibility","open","phoneNumber","description"]),Z(t),J(t,e),B(t),U(t,n),z(t),H(t),o.length?{coordinateProperties:{times:o.length===1?o[0]:o}}:{})};c.properties?.visibility!==void 0&&(c.properties.visibility=c.properties.visibility!=="0");const a=t.getAttribute("id");return a!==null&&a!==""&&(c.id=a),c}function Ut(t){let e=t.getAttribute("id");const n=t.parentNode;return!e&&et(n)&&n.localName==="CascadingStyle"&&(e=n.getAttribute("kml:id")||n.getAttribute("id")),v(e||"")}function Zt(t){const e={};for(const n of x(t,"Style"))e[Ut(n)]=B(n);for(const n of x(t,"StyleMap")){const r=v(n.getAttribute("id")||"");k(n,"styleUrl",o=>{o=v(o),e[o]&&(e[r]=e[o])})}return e}function zt(t){const e={};for(const n of x(t,"SimpleField"))e[n.getAttribute("name")||""]=D[n.getAttribute("type")||""]||D.string;return e}function*Ht(t,e={skipNullGeometry:!1}){const n=t,r=Zt(n),o=zt(n);for(const i of x(n,"Placemark")){const s=$t(i,r,o,e);s&&(yield s)}for(const i of x(n,"GroundOverlay")){const s=It(i,r,o,e);s&&(yield s)}for(const i of x(n,"NetworkLink")){const s=Dt(i,r,o,e);s&&(yield s)}}function Jt(t,e={skipNullGeometry:!1}){return{type:"FeatureCollection",features:Array.from(Ht(t,e))}}function Kt(t){return t[0]===80&&t[1]===75&&t[2]===3&&t[3]===4}function tt(t){const e=new DOMParser().parseFromString(t,"application/xml");if(e.getElementsByTagName("parsererror").length)throw new Error("malformed KML XML");return Jt(e)}function Qt(t){if(Kt(t)){const e=ft(t),n=Object.keys(e).find(r=>r.toLowerCase().endsWith(".kml"));if(!n)throw new Error("no .kml document inside the KMZ archive");return tt(pt(e[n]))}return tt(new TextDecoder().decode(t))}const st={},Wt=st?.VITE_MAP_TILE_URL??"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",qt=st?.VITE_MAP_TILE_ATTRIBUTION??'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',N=t=>Number(t)||0;function Xt(t,e){return t.filter(n=>n.selector?.type==="map").map(n=>({n:N(n.selector.n),s:N(n.selector.s),e:N(n.selector.e),w:N(n.selector.w),title:n.description,color:bt(n),ann:ht(n)?n:void 0,id:n.fragmentSlug?yt(e,n.fragmentSlug):void 0}))}function ct(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Yt(t){return t?typeof t=="string"?ct(t):typeof t=="object"&&t["@type"]==="html"?String(t.value??""):"":""}function te(t,e,n=!0){const r=O.map(t,n?{}:{dragging:!1,scrollWheelZoom:!1,doubleClickZoom:!1,boxZoom:!1,keyboard:!1,touchZoom:!1,zoomControl:!1});O.tileLayer(Wt,{maxZoom:19,attribution:qt}).addTo(r);const i=O.geoJSON(e,{style:s=>{const c=s?.properties??{};return{color:c.stroke||"#3388ff",weight:c["stroke-width"]||2,opacity:c["stroke-opacity"]??1,fillColor:c.fill||"#3388ff",fillOpacity:c["fill-opacity"]??.2}},pointToLayer:(s,c)=>O.circleMarker(c,{radius:5,color:"#e23",weight:2,fillOpacity:.8}),onEachFeature:n?(s,c)=>{const a=s.properties??{},w=a.name?`<strong>${ct(a.name)}</strong>`:"",A=Yt(a.description),R=A?`<div class="map-popup-desc">${A}</div>`:"";(w||R)&&c.bindPopup(`${w}${R}`)}:void 0}).addTo(r).getBounds();return i.isValid()?r.fitBounds(i,{padding:[24,24],maxZoom:16}):r.setView([0,0],2),r}function at({path:t,className:e,regions:n,onSelectRegion:r,onRegionClick:o,selectColor:i,interactive:s=!0}){const c=f.useRef(null),a=f.useRef(null),w=f.useRef(null),A=f.useRef(r),R=f.useRef(o),K=f.useRef(i),[C,Q]=f.useState(null),[lt,I]=f.useState(!0),[W,ut]=f.useState(0),q=JSON.stringify(n??[]),X=!!r;f.useEffect(()=>{A.current=r,R.current=o,K.current=i}),f.useEffect(()=>{let y=!1,l=null;return Q(null),I(!0),fetch(dt(t)).then(g=>g.arrayBuffer()).then(g=>{if(y||!c.current)return;const h=te(c.current,Qt(new Uint8Array(g)),s);w.current=O.layerGroup().addTo(h),a.current=h,s&&(l=xt(h,{color:()=>K.current?.()??Y,onSelect:X?(b,G)=>A.current?.({type:"map",n:b.getNorth(),s:b.getSouth(),e:b.getEast(),w:b.getWest()},G):void 0})),ut(b=>b+1),I(!1)}).catch(g=>{y||(Q(String(g.message||g)),I(!1))}),()=>{y=!0,l?.(),a.current?.remove(),a.current=null,w.current=null}},[t]);const P=f.useRef(new Map);return f.useEffect(()=>{const y=w.current;if(y){y.clearLayers(),P.current.clear();for(const l of n??[]){const g=l.color||Y,h=[[l.s,l.w],[l.n,l.e]],b=O.rectangle(h,{className:"yo-region",color:g,weight:3,fillColor:g,fillOpacity:.25});if(l.title&&b.bindTooltip(l.title),l.ann){const G=l.ann;b.on("click",j=>{O.DomEvent.stop(j),R.current?.(G,{x:j.originalEvent.clientX,y:j.originalEvent.clientY})})}b.addTo(y),l.id&&P.current.set(l.id,{rect:b,bounds:h})}}},[q,W]),f.useEffect(()=>{const y=()=>{const l=a.current,g=decodeURIComponent(window.location.hash.slice(1)),h=g?P.current.get(g):void 0;!l||!h||(l.fitBounds(h.bounds,{maxZoom:l.getZoom(),padding:[40,40]}),h.rect.setStyle({weight:6,fillOpacity:.45}),window.setTimeout(()=>h.rect.setStyle({weight:3,fillOpacity:.25}),1e3))};return y(),window.addEventListener("hashchange",y),()=>window.removeEventListener("hashchange",y)},[q,W]),L.jsxs(L.Fragment,{children:[C&&L.jsxs("div",{className:"error",children:["map: ",C]}),L.jsx("div",{ref:c,className:e+(X?" yo-selectable":"")}),lt&&!C&&L.jsx("div",{className:"loading",children:"loading map…"})]})}function re({node:t}){const e=mt(t.path),{openCreate:n,openEdit:r,palette:o,preview:i,color:s}=gt(e,t.path),c=Xt(e.annotations,t.path);if(i?.selector.type==="map"){const a=i.selector;c.push({n:N(a.n),s:N(a.s),e:N(a.e),w:N(a.w),color:i.color})}return L.jsxs("div",{className:"text",children:[t.title&&L.jsx("h1",{className:"chapter-title",children:t.title}),t.description&&L.jsx("p",{className:"chapter-subtitle",children:t.description}),L.jsx(at,{path:t.path,regions:c,onSelectRegion:n,onRegionClick:r,selectColor:()=>s,className:"filemap"}),o]})}function oe({chunk:t,onNavigate:e}){return L.jsx(Lt,{path:t.path,onNavigate:e,title:"Open map on its own page",children:L.jsx(at,{path:t.path,className:"filemap chunk-map chunk-static",interactive:!1})})}export{oe as MapChunk,re as MapView};
|