import{getBlocksHeight as s,getArticleOffsetTop as f,getNavHeight as h}from"./getBlocksHeight.js";function g(t,e=0){if(typeof t>"u"){window.scrollTo({top:0,behavior:"smooth"});return}const o=s(),n=h();if(!o[e])return;const{height:r,offset:c}=o[e],i=Math.round(c-n+r*(Math.round(t)/100));window.scrollTo({top:i,behavior:"smooth"})}const p=t=>{const e=f(),o=h();if(t<e)return{percentScrolled:0,sequenceNumber:-1};const n=s(),r=l(t+o,n),{height:c,offset:i}=n[r];return{percentScrolled:Math.round((t+o-i)/c*100),sequenceNumber:r}};function l(t,e){return e.findIndex(({offset:o,height:n})=>t>=o&&t<o+n)}export{g as syncScrollWithEditor,p as syncScrollWithProject};
