import{r as i,c as t,h as s,g as e}from"./p-890a2f7e.js";import{d as r}from"./p-7dfab099.js";import{d as l}from"./p-9f421a09.js";import"./p-112455b1.js";import"./p-1ae2b158.js";const o={Filter:"Filtrera","Remove filter":"Ta bort filter","Apply filter":"Tillämpa filter"},h=class{constructor(s){i(this,s),this.filterChanged=t(this,"filterChanged",7),this.textEntered=!1,this.criteriaString=""}async componentWillLoad(){this.t=l.create({sv:o},this.element)}checkTextEntered(){const i=this.inputElement;n(i)&&(this.textEntered=""!=i.value)}onFilter(i){this.criteriaString=i.detail.filter,this.applyFilter(),this.checkTextEntered()}criteriaStringChanged(){const i=this.inputElement;n(i)&&(i.value=this.criteriaString),this.textEntered=!0,this.applyFilter()}applyFilter(i){this.filter=i||r.and(r.parse(this.criteriaString)).generalize(),this.filterChanged.emit(this.value?r.filter(this.filter,this.value):this.filter)}reset(){this.criteriaString="",this.applyFilter();const i=this.inputElement;n(i)&&(i.value=""),this.textEntered=!1}render(){return s("form",null,s("ig-autocomplete-input",{template:this.template,ref:i=>this.inputElement=i,name:"filter",onKeyDown:this.checkTextEntered.bind(this)},this.t("Filter")),s("smoothly-submit",{fill:"clear",prevent:!0,onSubmit:i=>this.onFilter(i),style:{visibility:this.textEntered?"visible":"hidden"}},s("smoothly-icon",{toolTip:this.t("Apply filter"),name:"search",size:"small"})),s("smoothly-submit",{fill:"clear",prevent:!0,onSubmit:()=>this.reset()},s("smoothly-icon",{toolTip:this.t("Remove filter"),size:"small",name:"backspace"})))}get element(){return e(this)}static get watchers(){return{criteriaString:["criteriaStringChanged"]}}};function n(i){return null==i.value||"string"==typeof i.value}h.style=".sc-ig-filter-h{display:block;width:100%;max-width:90em;margin:auto}[hidden].sc-ig-filter-h{display:none}.sc-ig-filter-h>form.sc-ig-filter{border:1px solid rgb(var(--smoothly-medium-color));margin:0.2em 0 0.5em 0;clear:both}.sc-ig-filter-h>form.sc-ig-filter>ig-autocomplete-input.sc-ig-filter{width:calc(100% - 80px);display:inline-block}.sc-ig-filter-h>form.sc-ig-filter>smoothly-input.sc-ig-filter{width:calc(100% - 80px);display:inline-block}.sc-ig-filter-h>form.sc-ig-filter>smoothly-submit.sc-ig-filter{display:inline-block}";export{h as ig_filter}