1import a from"woody_library_woody_controller";import{timeout as c}from"woody_lib_utils";class d extends a{#t;#n;#e;#s;#i;#o;constructor(t){super(t)}async init(t){if(super.init(t),this.#s=this.el.getAttribute("data-scrollytelling-group-index"),!this.#s)throw new Error("`data-scrollytelling-group-index` attribute is missed on element : ",this.el);if(this.#t=this.el.querySelectorAll("[data-scrollytelling-sections] section[data-uuid]"),!this.#t)throw new Error("`[data-scrollytelling-sections] section[data-uuid]` elements are missed in element : ",this.el);if(this.#n=this.el.querySelector("[data-scrollytelling-map]"),this.#n){if(this.#e=this.#n.querySelector("woody-map"),!this.#e)throw new Error("`[data-scrollytelling-map] woody-map` element is missed");this.#e.addEventListener("pinclick",i=>{this.#o=null,this._onClickSectionPin(i.detail?.section_uuid)})}const e=this.#n.querySelector("[data-scrollytelling-content-toggler]");e&&(e.addEventListener("click",i=>{i.preventDefault(),this._onClickGroupContentToggler()}),e.addEventListener("keypress",i=>{i.preventDefault(),(i.keyCode==13||i.keyCode==32)&&this._onClickGroupContentToggler()})),this.#i=new IntersectionObserver(i=>{let o=i.filter(n=>n.isIntersecting).sort((n,l)=>n.boundingClientRect.top-l.boundingClientRect.top);if(o.length>0&&this.#o&&(o=o.filter(n=>String(this.#o)===String(n.target.dataset.uuid)),this.#o=null),o.length>0){let n=o[0];this._onIntersectSection(n.target.dataset.uuid)}},{threshold:.2}),this.startObserver()}setSelectedSection(t){this.#o=t,this._setSelectedSection(t),this._showOnList(t)}startObserver(){this.#i&&this.#t.forEach(t=>this.#i.observe(t))}stopObserver(){this.#i&&this.#t.forEach(t=>this.#i.unobserve(t))}_onClickGroupContentToggler(){this.el.classList.contains("content-expanded")?this.el.classList.remove("content-expanded"):this.el.classList.add("content-expanded"),this.el.dispatchEvent(new CustomEvent("onClickGroupContentToggler"))}_setSelectedSection(t){let e=!1;this.#t&&this.#t.length>0&&this.#t.forEach(i=>{String(t)===String(i.dataset.uuid)?(i.classList.add("active"),e=!0):i.classList.remove("active")}),e?this.el.classList.add("active"):this.el.classList.remove("active")}_onClickSectionPin(t){this._setSelectedSection(t),this._showOnList(t),this.el.dispatchEvent(new CustomEvent("onClickSectionPin",{detail:{group_index:this.#s,section_uuid:t}}))}_onIntersectSection(t){this._setSelectedSection(t),this._showOnMap(t),this.el.dispatchEvent(new CustomEvent("onScrollytellingIntersectSection",{detail:{group_index:this.#s,section_uuid:t}}))}async _showOnList(t){this.stopObserver();const e=this._getSectionForUuid(t);e&&this._scrollTo(e),await c(800),this.startObserver()}_showOnMap(t){if(!t){console.warn("ScrollytellingController - showOnMap - section_uuid is null");return}if(!this.#e)return;const e=this._getSectionForUuid(t);if(!e){console.warn("ScrollytellingController - showOnMap - no section found for uuid: "+t);return}if(!e.dataset.locationLat||!e.dataset.locationLng){console.warn('ScrollytellingController - showOnMap - found section for uuid "'+t+'" does not have "data-location-lat" and "data-location-lng" attributes');return}this.#e?.loaded?this.#e.setSelectedPinIndexForLocation(e.dataset.locationLat,e.dataset.locationLng,!0,!1):this.#e.addEventListener("ready",()=>{this.#e.setSelectedPinIndexForLocation(e.dataset.locationLat,e.dataset.locationLng,!0,!1)})}_scrollTo(t){const e=this.el.getBoundingClientRect(),i=t.getBoundingClientRect(),o=e.top+window.scrollY,n=e.bottom+window.scrollY;let s=i.top+window.scrollY-80;const r=window.innerHeight;s+r>n&&(s=n-r),s<o&&(s=o),window.scrollTo({top:s,behavior:"smooth"})}_getSectionForUuid(t){let e;for(let i=0;i<this.#t.length;i++){const o=this.#t[i];if(String(t)===String(o.dataset.uuid)){e=o;break}}return e}}export{d as default};
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.