class LiquidFilterBehavior extends LiquidBehavior{static behaviorName="liquidFilter";static viewModelEvents={"change:items":"onChangeItems","change:filteredItems":"onChangeFilteredItems"};static viewEvents={"change:filter":"onChangeFilter"};static domEvents={"click .lqd-filter-trigger":"onClickFilterTrigger"};get ui(){return{filterItems:".lqd-filter-item",filterTriggers:".lqd-filter-trigger"}}initialize(){this.on("filter:began",this.onFilterBegan),this.on("filter:done",this.onFilterDone),this.view.model.set({currentFilter:"*"},{silent:!0})}onChangeItems(t,i){const e=i.map(r=>r.el);this.trigger("filter:began",e)}onChangeFilteredItems(t,i){const e=i.map(r=>r.el);this.trigger("filter:done",e)}onClickFilterTrigger(t){const e=t.currentTarget.dataset.lqdFilterTrigger;this.view.model.get("currentFilter")!==e&&(this.view.model.set({currentFilter:e}),this.view.trigger("change:filter",e))}onChangeFilter(t){const i=this.view.model.get("items");let e=i;t!=="*"&&(e=i.filter(n=>n.filterCat.find(l=>l===t)));const r=i.map(n=>{const l=e.findIndex(s=>s.el===n.el);return n.isFiltered=l>=0,n});this.view.model.set({items:[...r]}),this.view.model.hasChanged("items")||this.view.model.trigger("change:items",this.view.model,i),this.view.model.get("items").forEach(n=>{n.el.style.display=n.isFiltered?"":"none"}),this.view.trigger("before:filter:animation"),this.view.model.set({filteredItems:[...e]}),this.view.model.hasChanged("filteredItems")||this.view.model.trigger("change:filteredItems",this.view.model,e),this.view.trigger("after:filter:animation")}onFilterBegan(t){t&&(this.elementsState=Flip.getState(t))}onFilterDone(t){const e="power2.inOut";this.containerState&&Flip.from(this.containerState,{duration:.56,simple:!0}),this.elementsState&&t?.length&&Flip.from(this.elementsState,{duration:.56,ease:e,scale:!0,absolute:!0,zIndex:5,onEnter:r=>gsap.fromTo(r,{opacity:0,scale:0},{opacity:1,scale:1,duration:.56,ease:e}),onLeave:r=>gsap.to(r,{opacity:0,scale:0,duration:.56,ease:e}),onComplete:()=>{this.view.trigger("finished:filter:animation")}})}}typeof window<"u"&&(window.liquid?.app?window.liquid?.app?.model?.set("loadedBehaviors",[...window.liquid.app.model.get("loadedBehaviors"),LiquidFilterBehavior]):window.liquid?.loadedBehaviors?.push(LiquidFilterBehavior));
