{"version":3,"file":"pane_controller-BBAh0NfA.js","sources":["../../../app/javascript/controllers/step/condition/pane_controller.js"],"sourcesContent":["import PaneController from \"../../journeys/pane_controller\"\nimport { get } from \"@rails/request.js\"\n\nexport default class extends PaneController {\n static values = {\n stepId: String,\n wait: Number,\n waitDuration: { type: String, default: 'minutes' },\n stepName: String,\n }\n\n static targets = [\n \"error\",\n \"option\",\n \"saveChanges\",\n \"condition\",\n \"wait\",\n \"waitSummary\",\n \"waitPeriodSelect\",\n \"waitPeriodInput\",\n \"waitDetails\",\n \"stepNameInput\",\n \"enableWaitCheckbox\",\n \"removeButton\"\n ]\n\n connect() {\n this.waitDetailsTarget.addEventListener('toggle', ({ target }) => {\n if(target.open) {\n this.focus(this.waitPeriodInputTarget, { moveCursorToEnd: true })\n }\n })\n\n super.connect()\n }\n\n sync(commit = false) {\n this.dispatch(\"sync\", {\n detail: {\n stepId: this.stepIdValue,\n commit,\n stepName: this.stepNameValue,\n },\n target: document.documentElement,\n })\n\n this.hasUnsavedChanges = false\n }\n\n saveAndHide() {\n this.stepNameValue = this.stepNameInputTarget.value.trim()\n\n this.sync(true)\n this._hide()\n\n this.clearQueue()\n\n if (this.hasErrorTarget) {\n this.errorTarget.remove()\n }\n\n this.conditionTargets.forEach((condition) => {\n if(condition.classList.contains(\"hidden\")) {\n this.dispatch(\"condition:remove\", {\n target: condition\n })\n }\n })\n\n this.waitDetailsTarget.open = false\n this.removeButtonTarget.classList.remove('hidden')\n }\n\n cancel() {\n this._abort()\n this._hide()\n\n setTimeout(this.clearQueue, 1000)\n }\n\n _abort() {\n this.dispatch(\"sync:abort\", {\n detail: this.stepIdValue,\n target: document.documentElement,\n })\n this.hasUnsavedChanges = false\n }\n\n\n disableWait() {\n this.waitTarget.classList.add('text-night-40', 'cursor-pointer')\n this.waitTarget.querySelectorAll('input:not([type=\"radio\"]), select').forEach(this.disable)\n\n this.dispatch('disable', {\n target: this.waitPeriodSelectTarget,\n })\n\n this.waitSummaryTarget.innerText = t.automation.condition.wait.summary.disabled\n }\n\n enableWait() {\n this.waitTarget.classList.remove('text-night-40', 'cursor-pointer')\n this.waitTarget.querySelectorAll('input:not([type=\"radio\"]), select').forEach(this.enable)\n\n this.dispatch('enable', {\n target: this.waitPeriodSelectTarget,\n })\n\n this.syncWaitPeriodLabel()\n this.focus(this.waitPeriodInputTarget, { moveCursorToEnd: true })\n }\n\n enableWaitByContainer() {\n if(this.enableWaitCheckboxTarget.checked) return\n\n this.enableWaitCheckboxTarget.click()\n this.enableWait()\n }\n\n onWaitPeriodChange({ target }) {\n if(!target.value) return\n\n this.waitValue = parseInt(target.value)\n this.syncWaitPeriodLabel()\n }\n\n onWaitDurationChange({ detail: value }) {\n this.waitDurationValue = value\n\n this.syncWaitPeriodLabel()\n this.focus(this.waitPeriodInputTarget, { moveCursorToEnd: true })\n }\n\n syncWaitPeriodLabel() {\n if(this.waitValue === 1) {\n this.waitSummaryTarget.innerText = t.automation.condition.wait.summary[this.waitDurationValue].one\n } else {\n this.waitSummaryTarget.innerText = t.automation.condition.wait.summary[this.waitDurationValue].other.replace('%{count}', this.waitValue)\n }\n }\n\n onConditionClick({ currentTarget }) {\n this.setHasUnsavedChanges()\n get(currentTarget.dataset.url, { responseKind: \"turbo-stream\" })\n }\n\n setHasUnsavedChanges() {\n this.hasUnsavedChanges = true\n window.paneId = this.element.id\n }\n\n enableSubmit() {\n this.saveChangesTarget.disabled = false\n }\n\n disableSubmit() {\n this.saveChangesTarget.disabled = true\n }\n\n get nameChanged() {\n return this.stepNameValue !== this.stepNameInputTarget.value.trim()\n }\n}\n"],"names":["pane_controller","PaneController","target","commit","condition","value","currentTarget","get","__publicField"],"mappings":"8PAGe,MAAKA,UAASC,CAAe,CAuB1C,SAAU,CACR,KAAK,kBAAkB,iBAAiB,SAAU,CAAC,CAAE,OAAAC,CAAM,IAAO,CAC7DA,EAAO,MACR,KAAK,MAAM,KAAK,sBAAuB,CAAE,gBAAiB,EAAM,CAAA,CAEnE,CAAA,EAED,M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