{"version":3,"file":"radio_controller-xN-SG05Z.js","sources":["../../../app/javascript/controllers/radio_controller.js"],"sourcesContent":["import ApplicationController from \"./application_controller\"\n\nexport default class extends ApplicationController {\n static targets = [\"radio\", \"checkmarkContainer\"]\n static classes = [\"active\"]\n\n initialize() {\n if(this.hasRadioTarget) {\n this.toggleActiveClass()\n }\n }\n\n check() {\n this.radioTarget.checked = true\n\n this.dispatch(\"toggled\", {\n target: document.documentElement,\n detail: this.radioTarget\n })\n\n this.dispatch(\"change\", { detail: this.radioTarget.value, target: this.radioTarget })\n this.toggleActiveClass()\n }\n\n radioToggled({ target, detail }) {\n if(detail === this.radioTarget || detail.name !== this.radioTarget.name) return\n\n this.radioTarget.checked = false\n this.dispatch(\"change\", { detail: this.radioTarget.value, target: this.radioTarget })\n\n this.toggleActiveClass()\n }\n\n toggleActiveClass() {\n if(this.radioTarget.checked) {\n this.addClass(this.element, ...this.elementClasses)\n if(this.hasCheckmarkContainerTarget) {\n this.show(this.checkmarkContainerTarget)\n }\n\n this.element.setAttribute('data-active', true)\n } else {\n this.removeClass(this.element, ...this.elementClasses)\n\n if(this.hasCheckmarkContainerTarget) {\n this.hide(this.checkmarkContainerTarget)\n }\n\n this.element.removeAttribute('data-active')\n }\n }\n\n get elementClasses() {\n return this.hasActiveClass ? this.activeClasses : [\"border-lavender\"]\n }\n}\n"],"names":["radio_controller","ApplicationController","target","detail","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CAIjD,YAAa,CACR,KAAK,gBACN,KAAK,kBAAiB,CAE5B,CAEE,OAAQ,CACN,KAAK,YAAY,QAAU,GAE3B,KAAK,SAAS,UAAW,CACvB,OAAQ,SAAS,gBACjB,OAAQ,KAAK,WACd,CAAA,EAED,KAAK,SAAS,SAAU,CAAE,OAAQ,KAAK,YAAY,MAAO,OAAQ,KAAK,WAAa,CAAA,EACpF,KAAK,kBAAiB,CAC1B,CAEE,aAAa,CAAE,OAAAC,EAAQ,OAAAC,GAAU,CAC5BA,IAAW,KAAK,aAAeA,EAAO,OAAS,KAAK,YAAY,OAEnE,KAAK,YAAY,QAAU,GAC3B,KAAK,SAAS,SAAU,CAAE,OAAQ,KAAK,YAAY,MAAO,OAAQ,KAAK,WAAa,CAAA,EAEpF,KAAK,kBAAiB,EAC1B,CAEE,mBAAoB,CACf,KAAK,YAAY,SAClB,KAAK,SAAS,KAAK,QAAS,GAAG,KAAK,cAAc,EAC/C,KAAK,6BACN,KAAK,KAAK,KAAK,wBAAwB,EAGzC,KAAK,QAAQ,aAAa,cAAe,EAAI,IAE7C,KAAK,YAAY,KAAK,QAAS,GAAG,KAAK,cAAc,EAElD,KAAK,6BACN,KAAK,KAAK,KAAK,wBAAwB,EAGzC,KAAK,QAAQ,gBAAgB,aAAa,EAEhD,CAEE,IAAI,gBAAiB,CACnB,OAAO,KAAK,eAAiB,KAAK,cAAgB,CAAC,iBAAiB,CACxE,CACA,CApDEC,EADkBJ,EACX,UAAU,CAAC,QAAS,oBAAoB,GAC/CI,EAFkBJ,EAEX,UAAU,CAAC,QAAQ"}