{"version":3,"file":"progress_controller-ZZPRqS5A.js","sources":["../../../app/javascript/controllers/progress_controller.js"],"sourcesContent":["import { Controller } from \"@hotwired/stimulus\"\n\nexport default class extends Controller {\n static values = {\n widthClass: String,\n firstPage: Boolean,\n }\n\n initialize() {\n super.initialize()\n this.wizardStepChanged = this.wizardStepChanged.bind(this)\n }\n\n connect() {\n super.connect()\n\n if (this.firstPageValue) {\n this._changeHistoryStateToTurboStream()\n }\n\n window.addEventListener(\"popstate\", this.wizardStepChanged)\n }\n\n disconnect() {\n this.element.classList.replace(this.widthClassValue, \"w-2/12\")\n this.widthClassValue = \"w-2/12\"\n }\n\n progress(e) {\n if (e.dataset.title) {\n const brandName = document.title.split(\"-\")[1]\n document.title = `${e.dataset.title} - ${brandName}`\n }\n\n this.element.classList.replace(this.widthClassValue, e.dataset.stepClass)\n this.widthClassValue = e.dataset.stepClass\n }\n\n widthClassValueChanged() {\n if (this.widthClassValue === \"w-full\") {\n this.removeRoundedCorners()\n } else {\n this.applyRoundedCorners()\n }\n }\n\n removeRoundedCorners() {\n this.element.classList.remove(\"rounded-tr-lg\", \"rounded-br-lg\")\n }\n\n applyRoundedCorners() {\n this.element.classList.add(\"rounded-tr-lg\", \"rounded-br-lg\")\n }\n\n wizardStepChanged(event) {\n // when a user presses browser back-button inside a wizard step\n // turbo updates url but not the page since we are manually updating urls\n // when we return a stream response\n\n // when back-button pressed manually perform visit\n if (event.state.turbo_stream_response) {\n Turbo.visit(window.location.href, { action: \"replace\" })\n }\n }\n\n _changeHistoryStateToTurboStream() {\n history.replaceState(\n { turbo_stream_response: true },\n window.location.title,\n window.location.href\n )\n }\n}\n"],"names":["progress_controller","Controller","brandName","event","__publicField"],"mappings":"4MAEe,MAAKA,UAASC,CAAW,CAMtC,YAAa,CACX,MAAM,WAAU,EAChB,KAAK,kBAAoB,KAAK,kBAAkB,KAAK,IAAI,CAC7D,CAEE,SAAU,CACR,MAAM,QAAO,EAET,KAAK,gBACP,KAAK,iCAAgC,EAGvC,OAAO,iBAAiB,WAAY,KAAK,iBAAiB,CAC9D,CAEE,YAAa,CACX,KAAK,QAAQ,UAAU,QAAQ,KAAK,gBAAiB,QAAQ,EAC7D,KAAK,gBAAkB,QAC3B,CAEE,SAAS,EAAG,CACV,GAAI,EAAE,QAAQ,MAAO,CACnB,MAAMC,EAAY,SAAS,MAAM,MAAM,GAAG,EAAE,CAAC,EAC7C,SAAS,MAAQ,GAAG,EAAE,QAAQ,KAAK,MAAMA,CAAS,EACxD,CAEI,KAAK,QAAQ,UAAU,QAAQ,KAAK,gBAAiB,EAAE,QAAQ,SAAS,EACxE,KAAK,gBAAkB,EAAE,QAAQ,SACrC,CAEE,wBAAyB,CACnB,KAAK,kBAAoB,SAC3B,KAAK,qBAAoB,EAEzB,KAAK,oBAAmB,CAE9B,CAEE,sBAAuB,CACrB,KAAK,QAAQ,UAAU,OAAO,gBAAiB,eAAe,CAClE,CAEE,qBAAsB,CACpB,KAAK,QAAQ,UAAU,IAAI,gBAAiB,eAAe,CAC/D,CAEE,kBAAkBC,EAAO,CAMnBA,EAAM,MAAM,uBACd,MAAM,MAAM,OAAO,SAAS,KAAM,CAAE,OAAQ,SAAW,CAAA,CAE7D,CAEE,kCAAmC,CACjC,QAAQ,aACN,CAAE,sBAAuB,EAAM,EAC/B,OAAO,SAAS,MAChB,OAAO,SAAS,IACtB,CACA,CACA,CArEEC,EADkBJ,EACX,SAAS,CACd,WAAY,OACZ,UAAW,OACf"}