import{aI as f,p as x,E as T,r as C,ao as d,at as w,ba as y}from"./app-k0jcl5PQ.js";import{u as S}from"./Bpw1_OdO.chunk.js";import{S as b}from"./BwBaQklX.chunk.js";let I;const z=({setActiveId:e,headingElements:s,controlledId:c,setControlledId:l})=>{const t=f.useRef(0);f.useEffect(()=>{const n=o=>{o.forEach(u=>{if(c){e(c),I=window.setTimeout(()=>{l("")},800);return}if(u.isIntersecting)e(u.target.id),t.current=window.scrollY;else{const p=t.current-window.scrollY>0,_=s.findIndex(m=>m.id===u.target.id),i=s[_-1];p&&(i!=null&&i.id)&&e(i==null?void 0:i.id)}})},r=new IntersectionObserver(n,{rootMargin:"-67px 0px -80% 0px"});return s.forEach(o=>r.observe(o)),()=>{I&&window.clearTimeout(I),r.disconnect()}},[e,s.length,c])},W=80,R=(e,s)=>{const[c,l]=f.useState(!1),t=S(s),n=s;f.useLayoutEffect(()=>{if(!c||t!==n){const r=e.find(o=>o&&(o==null?void 0:o.id)===n);if(r){const o=r.getBoundingClientRect();window.scrollBy({top:o.top-W,behavior:"smooth"}),c||l(!0)}}},[e,t,n,c])},k="_itemsWrapper_tzf1d_1",v="_anchorWrapper_tzf1d_5",D="_selectedItem_tzf1d_47",E="_tocIndent1_tzf1d_87",O="_tocIndent2_tzf1d_90",a={itemsWrapper:k,anchorWrapper:v,default:"_default_tzf1d_36",selectedItem:D,tocIndent1:E,tocIndent2:O};function N(e){const s={actionType:C.Click,entity:T.Widget,location:x.TableOfContents};function c(t){var n;b.preventScrollTop(),e.setControlledId(t.id),(n=e.onItemClick)==null||n.call(e,t),setTimeout(()=>{var r;return(r=document.getElementById(t.id))==null?void 0:r.focus()})}function l(t){return t.tocIndentation===1?a.tocIndent1:t.tocIndentation===2?a.tocIndent2:""}return d.jsx("div",{className:`${a.itemsWrapper}`,children:e.items.map((t,n)=>e.localState?d.jsx(w,{className:`${a.anchorWrapper} ${e.activeId===t.id?a.selectedItem:""}`,onClick:()=>{c(t)},children:d.jsx("div",{className:`${!e.activeId&&n===0?a.default:""} `,children:t.name})},t.id):d.jsx(y,{appLink:e.getAppLink(t),appLinkOptions:{replace:!0},className:`${a.anchorWrapper} ${e.activeId===t.id?a.selectedItem:""}`,onClick:()=>{c(t)},analyticsData:{...e.analyticsData,id:t.id,name:t.name},analyticsOptions:s,children:d.jsx("div",{className:`${!e.activeId&&n===0?a.default:""} ${l(t)}`,children:t.name})},t.id))})}export{N as T,R as a,z as u};
//# sourceMappingURL=neLjacsa.chunk.js.map
