{"version":3,"file":"preview_controller-eyS9xS4K.js","sources":["../../../app/javascript/controllers/step/message/preview_controller.js"],"sourcesContent":["import PreviewController from \"../../template/preview_controller\"\n\nexport default class extends PreviewController {\n static values = {\n stepId: String,\n }\n\n initialize() {\n super.initialize()\n this.observer = new ResizeObserver(() => {\n this.dispatch(\"size:change\", { target: document.documentElement })\n })\n\n this.content = this.contentValue\n }\n\n connect() {\n this.observer.observe(this.element)\n super.connect()\n }\n\n sync({ detail }) {\n this.updatePreview({ detail })\n }\n\n updatePreview({ detail }) {\n this.paragraphsTarget.innerHTML = ''\n\n if(!detail.string) {\n this.paragraphsTarget.innerHTML = this.translations.campaign.broadcasts.new.fields.body.placeholder\n return\n }\n\n super.updatePreview({ detail })\n }\n\n saveChanges({ detail }) {\n if (detail.stepId === this.stepIdValue && detail.commit) {\n this.smsCount = detail.smsCount\n this.content = detail.body\n this.smsLength = detail.smsLength || 160\n this.sync({ detail })\n this.previewBody({ detail })\n\n this.previewFooter({ detail: detail.footer })\n this.previewButtons({ detail: detail.buttons })\n\n if(detail.attachments) {\n this.previewAttachment({ detail: detail.attachments[0] })\n } else {\n this.previewAttachment({ detail: null })\n }\n }\n }\n\n abortChanges({ detail }) {\n if (detail.stepId === this.stepIdValue && this.content) {\n super.sync({ data: { smsCount: this.smsCount, body: this.content, smsLength: this.smsLength || 160 } })\n }\n }\n}\n"],"names":["preview_controller","PreviewController","detail","__publicField"],"mappings":"yNAEe,MAAKA,UAASC,CAAkB,CAK7C,YAAa,CACX,MAAM,WAAU,EAChB,KAAK,SAAW,IAAI,eAAe,IAAM,CACvC,KAAK,SAAS,cAAe,CAAE,OAAQ,SAAS,eAAiB,CAAA,CAClE,CAAA,EAED,KAAK,QAAU,KAAK,YACxB,CAEE,SAAU,CACR,KAAK,SAAS,QAAQ,KAAK,OAAO,EAClC,MAAM,QAAO,CACjB,CAEE,KAAK,CAAE,OAAAC,GAAU,CACf,KAAK,cAAc,CAAE,OAAAA,CAAQ,CAAA,CACjC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