{"version":3,"file":"button_controller-DU1RFfP6.js","sources":["../../../app/javascript/controllers/compose/template/button_controller.js"],"sourcesContent":["import ApplicationController from '../../application_controller'\n\nexport default class extends ApplicationController {\n static values = {\n type: String,\n }\n\n static targets = [\n 'valueInput',\n 'titleInput',\n 'quickReply',\n 'url',\n 'phone',\n 'removeButton',\n ]\n\n connect() {\n super.connect()\n this.validate()\n }\n\n focusRow() {\n if(this.hasTitleInputTarget) {\n this.focus(this.titleInputTarget, { moveCursorToEnd: true })\n } else {\n this.focusValueInput()\n }\n }\n\n focusValueInput() {\n this.focus(this.valueInputTarget, { moveCursorToEnd: true })\n }\n\n resetRow() {\n this.valueInputTarget.value = ''\n\n if(this.hasTitleInputTarget) {\n this.titleInputTarget.value = ''\n }\n }\n\n validate() {\n let validation;\n\n if(this.hasTitleInputTarget) {\n validation = this.titleInputTarget.value.trim().length > 0 && this.valueInputTarget.value.trim().length > 0\n } else {\n validation = this.valueInputTarget.value.trim().length > 0\n }\n\n if(validation) {\n this.element.setAttribute('data-valid', '')\n } else {\n this.element.removeAttribute('data-valid')\n }\n }\n\n remove() {\n if(this.element.dataset.type === 'phone') {\n this.element.parentElement.remove()\n } else {\n this.element.remove()\n }\n }\n\n showRemoveButton() {\n this.show(this.removeButtonTarget)\n }\n\n hideRemoveButton() {\n this.hide(this.removeButtonTarget)\n }\n\n toObject() {\n return {\n type: this.typeValue,\n title: this.hasTitleInputTarget ? this.titleInputTarget.value.trim() : this.valueInputTarget.value.trim(),\n value: this.valueInputTarget.value,\n index: Array.from(this.element.parentElement.children).indexOf(this.element),\n }\n }\n\n get isValid() {\n return false\n }\n\n get isInvalid() {\n return !this.isValid\n }\n}\n"],"names":["button_controller","ApplicationController","validation","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CAcjD,SAAU,CACR,MAAM,QAAO,EACb,KAAK,SAAQ,CACjB,CAEE,UAAW,CACN,KAAK,oBACN,KAAK,MAAM,KAAK,iBAAkB,CAAE,gBAAiB,EA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