import{s as y}from"./chunk-DZLz74EQ.js";import{c as j}from"./jotai-DDOP7CKM.js";import{t as M}from"./react-BcIddLXZ.js";import{C as H,et as C}from"./cells-B6jS0AIj.js";import{n as O,t as k}from"./jsx-runtime-DvsdsEjx.js";import{u as $}from"./hotkeys-Lbk6RHir.js";import{t as x}from"./cn-C5VTNYKf.js";import{t as B}from"./mode-BdfAcJv1.js";var D=y(O(),1),h=y(M(),1);function L(){return B()==="edit"?document.getElementById("App"):void 0}function S(t){let e=(0,D.c)(7),[r,o]=(0,h.useState)(void 0),[i,s]=(0,h.useState)(void 0),l=(0,h.useRef)(null),n=(0,h.useRef)(null),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=new Map,e[0]=f):f=e[0];let u=(0,h.useRef)(f),c,m;e[1]===t?(c=e[2],m=e[3]):(c=()=>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=C(n.current);o("id"in p?p.id:p.path),s(u.current.get(n.current))}},{root:L(),rootMargin:"0px",threshold:0}),t.forEach(d=>{var v;if(d){let p=C(d[0]),b=t.map(T).filter(I=>"id"in p?I.id===p.id:I.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]=c,e[3]=m),(0,h.useEffect)(c,m);let a;return e[4]!==r||e[5]!==i?(a={activeHeaderId:r,activeOccurrences:i},e[4]=r,e[5]=i,e[6]=a):a=e[6],a}function T(t){let[e]=t;return e}function _(t){if(t.length===0)return[];let e=new Map;return t.map(r=>{let o="id"in r.by?r.by.id:r.by.path,i=e.get(o)??0;e.set(o,i+1);let s=N(r,i);return s?[s,o]: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 w=y(O(),1),g=y(k(),1);const A=()=>{let t=(0,w.c)(19),{items:e}=j(H),r;t[0]===e?r=t[1]:(r=_(e),t[0]=e,t[1]=r);let{activeHeaderId:o,activeOccurrences:i}=S(r),[s,l]=h.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","hidden md:block"),t[2]=n,t[3]=f,t[4]=u):(n=t[2],f=t[3],u=t[4]);let c=s?"-left-[280px] opacity-100":"left-[300px] opacity-0",m;t[5]===c?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",c),t[5]=c,t[6]=m);let a;t[7]!==o||t[8]!==i||t[9]!==e||t[10]!==m?(a=(0,g.jsx)(R,{className:m,items:e,activeHeaderId:o,activeOccurrences:i}),t[7]=o,t[8]=i,t[9]=e,t[10]=m,t[11]=a):a=t[11];let d;t[12]!==o||t[13]!==i||t[14]!==e?(d=(0,g.jsx)(P,{items:e,activeHeaderId:o,activeOccurrences:i}),t[12]=o,t[13]=i,t[14]=e,t[15]=d):d=t[15];let v;return t[16]!==a||t[17]!==d?(v=(0,g.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,w.c)(8),{items:r,activeHeaderId:o,activeOccurrences:i}=t,s,l;if(e[0]!==o||e[1]!==i||e[2]!==r){let f=new Map;s="flex flex-col gap-4 items-end max-h-[70vh] overflow-hidden",l=r.map((u,c)=>{let m="id"in u.by?u.by.id:u.by.path,a=f.get(m)??0;return f.set(m,a+1),(0,g.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===i&&o===m&&"bg-foreground"),onClick:()=>E(u,a)},`${m}-${c}`)}),e[0]=o,e[1]=i,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,g.jsx)("div",{className:s,children:l}),e[5]=s,e[6]=l,e[7]=n):n=e[7],n},R=t=>{let e=(0,w.c)(11),{items:r,activeHeaderId:o,activeOccurrences:i,className:s}=t,l,n;if(e[0]!==o||e[1]!==i||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((c,m)=>{let a="id"in c.by?c.by.id:c.by.path,d=u.get(a)??0;return u.set(a,d+1),(0,g.jsx)("div",{className:x("px-2 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l",c.level===1&&"font-semibold",c.level===2&&"ml-3",c.level===3&&"ml-6",c.level===4&&"ml-9",d===i&&o===a&&"text-accent-foreground"),onClick:()=>E(c,d),children:c.name},`${a}-${m}`)}),e[0]=o,e[1]=i,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,g.jsx)("div",{className:l,children:n}),e[8]=l,e[9]=n,e[10]=f):f=e[10],f};export{S as i,R as n,_ as r,A as t};
