{"version":3,"file":"product_controller-B6clmtBs.js","sources":["../../../app/javascript/controllers/filter/product_controller.js"],"sourcesContent":["import ApplicationController from '../application_controller'\n\nexport default class extends ApplicationController {\n static values = {\n type: { type: String, default: 'name' },\n }\n\n static targets = [\n 'filter',\n 'filterOption',\n ]\n\n setFilter({ currentTarget }) {\n this.typeValue = currentTarget.dataset.optionValue\n\n this.filterTargets.forEach((filter) => {\n if(filter.dataset.type === this.typeValue) {\n this.show(filter)\n\n this.dispatch('show', {\n target: filter\n })\n } else {\n this.hide(filter)\n\n this.dispatch('hide', {\n target: filter\n })\n }\n })\n }\n\n focus() {\n const filter = this.filterTargets.find(filter => filter.dataset.type === this.typeValue)\n\n this.dispatch('focus', {\n target: filter\n })\n }\n\n saveState() {\n this.state = {\n type: this.typeValue\n }\n\n const filter = this.filterTargets.find(filter => filter.dataset.type === this.typeValue)\n\n this.dispatch('state:save', {\n target: filter\n })\n }\n\n restoreState() {\n if(!this.state) return\n\n this.typeValue = this.state.type\n\n this.filterTargets.forEach((filter) => {\n if(filter.dataset.type === this.state.type) {\n this.show(filter)\n } else {\n this.hide(filter)\n }\n\n this.dispatch('state:restore', {\n target: filter\n })\n })\n\n this.filterOptionTargets.find(option => option.dataset.optionValue === this.state.type).click()\n }\n}\n"],"names":["product_controller","ApplicationController","currentTarget","filter","option","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CAUjD,UAAU,CAAE,cAAAC,GAAiB,CAC3B,KAAK,UAAYA,EAAc,QAAQ,YAEvC,KAAK,cAAc,QAASC,GAAW,CAClCA,EAAO,QAAQ,OAAS,KAAK,WAC9B,KAAK,KAAKA,CAAM,EAEhB,KAAK,SAAS,OAAQ,CACpB,OAAQA,CACT,CAAA,IAED,KAAK,KAAKA,CAAM,EAEhB,KAAK,SAAS,OAAQ,CACpB,OAAQA,CACT,CAAA,EAEJ,CAAA,CACL,CAEE,OAAQ,CACN,MAAMA,EAAS,KAAK,cAAc,KAAKA,GAAUA,EAAO,QAAQ,OAAS,KAAK,SAAS,EAEvF,KAAK,SAAS,QAAS,CACrB,OAAQA,CACT,CAAA,CACL,CAEE,WAAY,CACV,KAAK,MAAQ,CACX,KAAM,KAAK,SACjB,EAEI,MAAMA,EAAS,KAAK,cAAc,KAAKA,GAAUA,EAAO,QAAQ,OAAS,KAAK,SAAS,EAEvF,KAAK,SAAS,aAAc,CAC1B,OAAQA,CACT,CAAA,CACL,CAEE,cAAe,CACT,KAAK,QAET,KAAK,UAAY,KAAK,MAAM,KAE5B,KAAK,cAAc,QAASA,GAAW,CAClCA,EAAO,QAAQ,OAAS,KAAK,MAAM,KACpC,KAAK,KAAKA,CAAM,EAEhB,KAAK,KAAKA,CAAM,EAGlB,KAAK,SAAS,gBAAiB,CAC7B,OAAQA,CACT,CAAA,CACF,CAAA,EAED,KAAK,oBAAoB,KAAKC,GAAUA,EAAO,QAAQ,cAAgB,KAAK,MAAM,IAAI,EAAE,MAAK,EACjG,CACA,CApEEC,EADkBL,EACX,SAAS,CACd,KAAM,CAAE,KAAM,OAAQ,QAAS,MAAQ,CAC3C,GAEEK,EALkBL,EAKX,UAAU,CACf,SACA,cACJ"}