import{s as I}from"./chunk-LvLJmgfZ.js";import{u as j}from"./useEvent-D91BmmQi.js";import{t as M}from"./react-Bj1aDYRI.js";import{ft as _,x as H}from"./cells-CJLUCcQg.js";import{t as S}from"./compiler-runtime-B3qBwwSJ.js";import{g as k}from"./useEventListener-C0195JsF.js";import{E as $}from"./config-B-Q7J_6d.js";import{t as x}from"./cn-DYvqRARy.js";import{t as B}from"./jsx-runtime-Blw4afVn.js";var L=S(),g=I(M(),1);function T(){return $()==="edit"?document.getElementById("App"):void 0}function E(t){let e=(0,L.c)(7),[r,a]=(0,g.useState)(void 0),[o,s]=(0,g.useState)(void 0),l=(0,g.useRef)(null),n=(0,g.useRef)(null),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=new Map,e[0]=f):f=e[0];let u=(0,g.useRef)(f),i,m;e[1]===t?(i=e[2],m=e[3]):(i=()=>t.length===0?void 0:(l.current=new IntersectionObserver(d=>{let v=!1;if(d.forEach(p=>{let b=p.target;p.isIntersecting?(!n.current||b.getBoundingClientRect().top<n.current.getBoundingClientRect().top)&&(n.current=b,v=!0):b===n.current&&(n.current=null,v=!0)}),v&&n.current){let p=_(n.current);a("id"in p?p.id:p.path),s(u.current.get(n.current))}},{root:T(),rootMargin:"0px",threshold:0}),t.forEach(d=>{var v;if(d){let p=_(d[0]),b=t.map(D).filter(w=>"id"in p?w.id===p.id:w.textContent===d[0].textContent).indexOf(d[0]);u.current.set(d[0],b),(v=l.current)==null||v.observe(d[0])}}),()=>{l.current&&l.current.disconnect(),n.current=null}),m=[t],e[1]=t,e[2]=i,e[3]=m),(0,g.useEffect)(i,m);let c;return e[4]!==r||e[5]!==o?(c={activeHeaderId:r,activeOccurrences:o},e[4]=r,e[5]=o,e[6]=c):c=e[6],c}function D(t){let[e]=t;return e}function O(t){if(t.length===0)return[];let e=new Map;return t.map(r=>{let a="id"in r.by?r.by.id:r.by.path,o=e.get(a)??0;e.set(a,o+1);let s=N(r,o);return s?[s,a]:null}).filter(Boolean)}function C(t,e){let r=N(t,e);if(!r){k.warn("Could not find element for outline item",t);return}r.scrollIntoView({behavior:"smooth",block:"start"}),r.classList.add("outline-item-highlight"),setTimeout(()=>{r.classList.remove("outline-item-highlight")},3e3)}function N(t,e){return"id"in t.by?document.querySelectorAll(`[id="${CSS.escape(t.by.id)}"]`)[e]:document.evaluate(t.by.path,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}var y=S(),h=I(B(),1);const A=()=>{let t=(0,y.c)(19),{items:e}=j(H),r;t[0]===e?r=t[1]:(r=O(e),t[0]=e,t[1]=r);let{activeHeaderId:a,activeOccurrences:o}=E(r),[s,l]=g.useState(!1);if(e.length<2)return null;let n,f,u;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=()=>l(!0),f=()=>l(!1),u=x("fixed top-[25vh] right-8 z-10000 print:hidden","hidden md:block"),t[2]=n,t[3]=f,t[4]=u):(n=t[2],f=t[3],u=t[4]);let i=s?"left-[-280px] opacity-100":"left-[300px] opacity-0",m;t[5]===i?m=t[6]:(m=x("-top-4 max-h-[70vh] bg-background rounded-lg shadow-lg absolute overflow-auto transition-all duration-300 w-[300px] border",i),t[5]=i,t[6]=m);let c;t[7]!==a||t[8]!==o||t[9]!==e||t[10]!==m?(c=(0,h.jsx)(R,{className:m,items:e,activeHeaderId:a,activeOccurrences:o}),t[7]=a,t[8]=o,t[9]=e,t[10]=m,t[11]=c):c=t[11];let d;t[12]!==a||t[13]!==o||t[14]!==e?(d=(0,h.jsx)(P,{items:e,activeHeaderId:a,activeOccurrences:o}),t[12]=a,t[13]=o,t[14]=e,t[15]=d):d=t[15];let v;return t[16]!==c||t[17]!==d?(v=(0,h.jsxs)("div",{onMouseEnter:n,onMouseLeave:f,className:u,children:[c,d]}),t[16]=c,t[17]=d,t[18]=v):v=t[18],v},P=t=>{let e=(0,y.c)(8),{items:r,activeHeaderId:a,activeOccurrences:o}=t,s,l;if(e[0]!==a||e[1]!==o||e[2]!==r){let f=new Map;s="flex flex-col gap-4 items-end max-h-[70vh] overflow-hidden",l=r.map((u,i)=>{let m="id"in u.by?u.by.id:u.by.path,c=f.get(m)??0;return f.set(m,c+1),(0,h.jsx)("div",{className:x("h-[2px] bg-muted-foreground/60",u.level===1&&"w-5",u.level===2&&"w-4",u.level===3&&"w-3",u.level===4&&"w-2",c===o&&a===m&&"bg-foreground"),onClick:()=>C(u,c)},`${m}-${i}`)}),e[0]=a,e[1]=o,e[2]=r,e[3]=s,e[4]=l}else s=e[3],l=e[4];let n;return e[5]!==s||e[6]!==l?(n=(0,h.jsx)("div",{className:s,children:l}),e[5]=s,e[6]=l,e[7]=n):n=e[7],n},R=t=>{let e=(0,y.c)(11),{items:r,activeHeaderId:a,activeOccurrences:o,className:s}=t,l,n;if(e[0]!==a||e[1]!==o||e[2]!==s||e[3]!==r){let u=new Map;e[6]===s?l=e[7]:(l=x("flex flex-col overflow-auto py-4 pl-2",s),e[6]=s,e[7]=l),n=r.map((i,m)=>{let c="id"in i.by?i.by.id:i.by.path,d=u.get(c)??0;u.set(c,d+1);let v=`${c}-${m}`,p={className:x("px-2 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l",i.level===1&&"font-semibold",i.level===2&&"ml-3",i.level===3&&"ml-6",i.level===4&&"ml-9",d===o&&a===c&&"text-accent-foreground"),onClick:()=>C(i,d)};return i.html?(0,h.jsx)("div",{...p,dangerouslySetInnerHTML:{__html:i.html}},v):(0,h.jsx)("div",{...p,children:i.name},v)}),e[0]=a,e[1]=o,e[2]=s,e[3]=r,e[4]=l,e[5]=n}else l=e[4],n=e[5];let f;return e[8]!==l||e[9]!==n?(f=(0,h.jsx)("div",{className:l,children:n}),e[8]=l,e[9]=n,e[10]=f):f=e[10],f};export{E as i,R as n,O as r,A as t};
