1import{C as n}from"./controller-DL_XDwt0.js";import"./app-CQlf5mo4.js";class f extends n{static get targets(){return["toggle","panel","chip","card","group","filters","search","routesViewport","routesGroup","routesPrev","routesNext"]}static get values(){return{routeStep:{type:Number,default:3}}}initialize(){this.activeFilters=new Set(["all"]),this.activeKind="all",this.searchQuery="",this.routeIndex=0,this.routeOffset=0,this.onClickOutside=this.onClickOutside.bind(this),this.updateRoutesCarousel=this.updateRoutesCarousel.bind(this)}connect(){this.syncChipAvailability(),this.updateAltBackgrounds(),this.hasRoutesViewportTarget&&(this.routesObserver=new ResizeObserver(this.updateRoutesCarousel),this.routesObserver.observe(this.routesViewportTarget),this.updateRoutesCarousel())}disconnect(){var t;(t=this.routesObserver)==null||t.disconnect(),window.removeEventListener("click",this.onClickOutside)}togglePanel(){const t=!this.panelTarget.classList.contains("film-filters__chips-panel--open");this.panelTarget.classList.toggle("film-filters__chips-panel--open",t),this.panelTarget.setAttribute("aria-hidden",String(!t)),this.toggleTarget.setAttribute("aria-expanded",String(t)),this.filtersTarget.classList.toggle("film-filters--open",t),t?(window.addEventListener("click",this.onClickOutside),requestAnimationFrame(()=>this.updateRoutesCarousel())):window.removeEventListener("click",this.onClickOutside)}onClickOutside(t){this.filtersTarget.contains(t.target)||(this.panelTarget.classList.remove("film-filters__chips-panel--open"),this.panelTarget.setAttribute("aria-hidden","true"),this.toggleTarget.setAttribute("aria-expanded","false"),this.filtersTarget.classList.remove("film-filters--open"),window.removeEventListener("click",this.onClickOutside))}selectChip(t){const{filmFilterValue:e,filmFilterKind:i}=t.currentTarget.dataset;e==="all"||this.activeFilters.has(e)?(this.activeFilters=new Set(["all"]),this.activeKind="all"):(this.activeFilters=new Set([e]),this.activeKind=i),this.updateChipStates(),this.filterCards()}updateChipStates(){this.chipTargets.forEach(t=>{const e=this.activeFilters.has(t.dataset.filmFilterValue);t.classList.toggle("film-filters__chip--active",e),t.setAttribute("aria-pressed",String(e))})}search(){this.searchQuery=this.searchTarget.value.toLowerCase().trim(),this.filterCards()}syncChipAvailability(){const t=this.element.querySelector(".month-nav__pill--active"),e=new Set(JSON.parse((t==null?void 0:t.dataset.monthNavSpotlights)||"[]"));let i=!1;this.chipTargets.forEach(s=>{if(s.dataset.filmFilterKind!=="spotlight")return;const r=s.dataset.filmFilterValue;s.disabled=!e.has(r),s.disabled&&this.activeFilters.has(r)&&(i=!0)}),i&&(this.activeFilters=new Set(["all"]),this.activeKind="all",this.updateChipStates())}filterCards(){this.syncChipAvailability();const t=this.activeKind==="all",[e]=this.activeFilters,i=this.searchQuery;this.cardTargets.forEach(s=>{var h;const r=JSON.parse(s.dataset.filmFilterSpotlight||"[]"),o=JSON.parse(s.dataset.filmFilterTags||"[]"),l=t||this.activeKind==="spotlight"&&r.includes(e)||this.activeKind==="route"&&o.includes(e),a=!i||((h=s.querySelector(".film-card__title"))==null?void 0:h.textContent.toLowerCase().includes(i));s.hidden=!l||!a}),this.groupTargets.forEach(s=>{var l;const r=this.cardTargets.filter(a=>s.contains(a)).some(a=>!a.hidden),o=(l=this.element.querySelector(".month-nav__pill--active"))==null?void 0:l.dataset.monthNavMonth;s.hidden=o&&s.dataset.monthNavMonth!==o||!r}),this.updateAltBackgrounds()}updateAltBackgrounds(){let t=0;this.groupTargets.forEach(e=>{e.classList.remove("film-date-group--alt"),e.hidden||(t%2===1&&e.classList.add("film-date-group--alt"),t++)})}scrollRoutesPrev(){this.shiftRoutes(-this.currentRouteStep)}scrollRoutesNext(){this.shiftRoutes(this.currentRouteStep)}get currentRouteStep(){return window.matchMedia("(max-width: 47.9375em)").matches?1:this.routeStepValue}shiftRoutes(t){if(!this.hasRoutesGroupTarget||t>0&&this.routeOffset>=this.maxRouteOffset||t<0&&this.routeOffset<=0)return;const e=Math.max(0,this.routeChips.length-1);this.routeIndex=Math.max(0,Math.min(this.routeIndex+t,e)),this.applyRouteTransform()}updateRoutesCarousel(){this.applyRouteTransform()}applyRouteTransform(){if(!this.hasRoutesGroupTarget||!this.hasRoutesViewportTarget)return;const t=this.maxRouteOffset;if(t<=0){this.routeIndex=0,this.routeOffset=0,this.routesGroupTarget.style.transform="",this.updateRouteArrows();return}const e=this.routeChips[this.routeIndex],i=Math.min(Math.max(0,e?e.offsetLeft:0),t);this.routeOffset=i,this.routesGroupTarget.style.transform=`translateX(-${i}px)`,this.updateRouteArrows()}updateRouteArrows(){if(!this.hasRoutesViewportTarget)return;const t=this.maxRouteOffset,e=t>1,i=this.routeOffset<=1,s=this.routeOffset>=t-1;
1if(this.routesViewportTarget.classList.toggle("film-filters__routes--overflow",e),this.routesViewportTarget.classList.toggle("film-filters__routes--at-start",!e||i),this.routesViewportTarget.classList.toggle("film-filters__routes--at-end",!e||s),this.hasRoutesPrevTarget){const r=!e||i;this.routesPrevTarget.disabled=r,this.routesPrevTarget.hidden=r}if(this.hasRoutesNextTarget){const r=!e||s;this.routesNextTarget.disabled=r,this.routesNextTarget.hidden=r}}get routeChips(){return this.hasRoutesGroupTarget?Array.from(this.routesGroupTarget.children):[]}get maxRouteOffset(){return!this.hasRoutesGroupTarget||!this.hasRoutesViewportTarget?0:Math.max(0,this.routesGroupTarget.scrollWidth-this.routesViewportTarget.clientWidth)}}export{f as default}; 2//# sourceMappingURL=film-filter_controller-BhZ2ypoj.js.map
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.