1import{o as e,t}from"./react-DEqKRp68.js";import{t as n}from"./jsx-runtime-BRPZiU6H.js";import{_ as r,b as i,y as a}from"./useRenderElement-BFoZu6yZ.js";var o=e(t()),s=o.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function c(){return o.useContext(s)}var l=n();function u(e){let{children:t,elementsRef:n,labelsRef:c,onMapChange:u}=e,m=a(u),h=o.useRef(0),g=i(f).current,_=i(d).current,[v,y]=o.useState(0),b=o.useRef(v),x=a((e,t)=>{_.set(e,t??null),b.current+=1,y(b.current)}),S=a(e=>{_.delete(e),b.current+=1,y(b.current)}),C=o.useMemo(()=>{let e=new Map;return Array.from(_.keys()).filter(e=>e.isConnected).sort(p).forEach((t,n)=>{let r=_.get(t)??{};e.set(t,{...r,index:n})}),e},[_,v]);r(()=>{if(typeof MutationObserver!=`function`||C.size===0)return;let e=new MutationObserver(e=>{let t=new Set,n=e=>t.has(e)?t.delete(e):t.add(e);e.forEach(e=>{e.removedNodes.forEach(n),e.addedNodes.forEach(n)}),t.size===0&&(b.current+=1,y(b.current))});
1return C.forEach((t,n)=>{n.parentElement&&e.observe(n.parentElement,{childList:!0})}),()=>{e.disconnect()}},[C]),r(()=>{b.current===v&&(n.current.length!==C.size&&(n.current.length=C.size),c&&c.current.length!==C.size&&(c.current.length=C.size),h.current=C.size),m(C)},[m,C,n,c,v]),r(()=>()=>{n.current=[]},[n]),r(()=>()=>{c&&(c.current=[])},[c]);let w=a(e=>(g.add(e),()=>{g.delete(e)}));r(()=>{g.forEach(e=>e(C))},[g,C]);let T=o.useMemo(()=>({register:x,unregister:S,subscribeMapChange:w,elementsRef:n,labelsRef:c,nextIndexRef:h}),[x,S,w,n,c,h]);return(0,l.jsx)(s.Provider,{value:T,children:t})}function d(){return new Map}function f(){return new Set}function p(e,t){let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}var m=o.createContext(void 0);function h(){return o.useContext(m)?.direction??`ltr`}var g=function(e){return e[e.None=0]=`None`,e[e.GuessFromOrder=1]=`GuessFromOrder`,e}({});function _(e={}){let{label:t,metadata:n,textRef:i,indexGuessBehavior:a,index:s}=e,{register:l,unregister:u,subscribeMapChange:d,elementsRef:f,labelsRef:p,nextIndexRef:m}=c(),h=o.useRef(-1),[_,v]=o.useState(s??(a===g.GuessFromOrder?()=>{if(h.current===-1){let e=m.current;m.current+=1,h.current=e}return h.current}:-1)),y=o.useRef(null),b=o.useCallback(e=>{if(y.current=e,_!==-1&&e!==null&&(f.current[_]=e,p)){let n=t!==void 0;p.current[_]=n?t:i?.current?.textContent??e.textContent}},[_,f,p,t,i]);return r(()=>{if(s!=null)return;let e=y.current;if(e)return l(e,n),()=>{u(e)}},[s,l,u,n]),r(()=>{if(s==null)return d(e=>{let t=y.current?e.get(y.current)?.index:null;t!=null&&v(t)})},[s,d,v]),o.useMemo(()=>({ref:b,index:_}),[_,b])}export{u as i,_ as n,h as r,g as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.