import{s as I}from"./chunk-LvLJmgfZ.js";import{u as j}from"./useEvent-WUlsM6MC.js";import{t as M}from"./react-Bj1aDYRI.js";import{S as H,rt as S,st as k}from"./cells-CCtxWKxf.js";import{t as _}from"./compiler-runtime-B3qBwwSJ.js";import{m as $}from"./useEventListener-CjXriKgk.js";import{t as B}from"./jsx-runtime-CP2fAiZX.js";import{t as x}from"./cn-d_A4rA-x.js";var L=_(),g=I(M(),1);function T(){return k()==="edit"?document.getElementById("App"):void 0}function O(t){let e=(0,L.c)(7),[r,c]=(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(h=>{let b=h.target;h.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 h=S(n.current);c("id"in h?h.id:h.path),s(u.current.get(n.current))}},{root:T(),rootMargin:"0px",threshold:0}),t.forEach(d=>{var v;if(d){let h=S(d[0]),b=t.map(D).filter(w=>"id"in h?w.id===h.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 a;return e[4]!==r||e[5]!==o?(a={activeHeaderId:r,activeOccurrences:o},e[4]=r,e[5]=o,e[6]=a):a=e[6],a}function D(t){let[e]=t;return e}function C(t){if(t.length===0)return[];let e=new Map;return t.map(r=>{let c="id"in r.by?r.by.id:r.by.path,o=e.get(c)??0;e.set(c,o+1);let s=N(r,o);return s?[s,c]:null}).filter(Boolean)}function E(t,e){let r=N(t,e);if(!r){$.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=_(),p=I(B(),1);const A=()=>{let t=(0,y.c)(19),{items:e}=j(H),r;t[0]===e?r=t[1]:(r=C(e),t[0]=e,t[1]=r);let{activeHeaderId:c,activeOccurrences:o}=O(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 a;t[7]!==c||t[8]!==o||t[9]!==e||t[10]!==m?(a=(0,p.jsx)(R,{className:m,items:e,activeHeaderId:c,activeOccurrences:o}),t[7]=c,t[8]=o,t[9]=e,t[10]=m,t[11]=a):a=t[11];let d;t[12]!==c||t[13]!==o||t[14]!==e?(d=(0,p.jsx)(P,{items:e,activeHeaderId:c,activeOccurrences:o}),t[12]=c,t[13]=o,t[14]=e,t[15]=d):d=t[15];let v;return t[16]!==a||t[17]!==d?(v=(0,p.jsxs)("div",{onMouseEnter:n,onMouseLeave:f,className:u,children:[a,d]}),t[16]=a,t[17]=d,t[18]=v):v=t[18],v},P=t=>{let e=(0,y.c)(8),{items:r,activeHeaderId:c,activeOccurrences:o}=t,s,l;if(e[0]!==c||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,a=f.get(m)??0;return f.set(m,a+1),(0,p.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",a===o&&c===m&&"bg-foreground"),onClick:()=>E(u,a)},`${m}-${i}`)}),e[0]=c,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,p.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:c,activeOccurrences:o,className:s}=t,l,n;if(e[0]!==c||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 a="id"in i.by?i.by.id:i.by.path,d=u.get(a)??0;u.set(a,d+1);let v=`${a}-${m}`,h={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&&c===a&&"text-accent-foreground"),onClick:()=>E(i,d)};return i.html?(0,p.jsx)("div",{...h,dangerouslySetInnerHTML:{__html:i.html}},v):(0,p.jsx)("div",{...h,children:i.name},v)}),e[0]=c,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,p.jsx)("div",{className:l,children:n}),e[8]=l,e[9]=n,e[10]=f):f=e[10],f};export{O as i,R as n,C as r,A as t};
