!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var s=t();for(var i in s)("object"==typeof exports?exports:e)[i]=s[i]}}(Depicter,(()=>(()=>{"use strict";var e={};(e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})})(e);const{Layer:t,env:s}=window.Depicter;return window.Depicter.externalLayers["survey:next"]=class extends t{constructor(e,t,i,n,o,r){super(e,t,i,n,o,r),this.type="survey:next",this.element.setAttribute("type","button"),this.frame.classList.add(`${s.prefix}-survey-next-layer`),this.frame.classList.add(`${s.prefix}-button-layer`),this.frame.classList.add(`${s.prefix}-no-swipe`)}_setupContent(){this.survey=this.holder.composer?.survey;const e=this.survey?.form;if(this.element.setAttribute("form",e.id),this.holder.composer.on("formSubmit, formSubmitted, formSubmitError",this._onFormSubmit.bind(this)),this.loading=document.createElement("div"),this.loading.classList.add(`${s.prefix}-dot-flashing`),[...Array(3)].forEach((()=>{const e=document.createElement("span");this.loading.appendChild(e)})),this.submitLabel=this.element.dataset.submitText||"Submit",this.content=this.element.querySelector(".dp-inner-content"),this.content.childNodes.forEach((e=>{3===e.nodeType&&(this.nextLabel=e.textContent)})),this.nextLabel)this.content.innerHTML=this.content.innerHTML.replace(this.nextLabel,`<span class="dp-label">${this.nextLabel}</span>`),this.label=this.content.querySelector("span.dp-label");else if(this.submitLabel){const e=document.createElement("span");e.classList.add("dp-label"),e.textContent=this.submitLabel,this.content.appendChild(e),this.label=e}console.trace("this.nextLabel",this.nextLabel),this.element.appendChild(this.loading),this._checkForReplaceLabel()}_toggleLoading(e){this.element.classList.toggle(`${s.prefix}-is-loading`,e)}_onFormSubmit(e){this.element.disabled=!1,"formSubmit"===e?this._toggleLoading(!0):this._toggleLoading(!1)}_replaceLabel(e){"submit"===e?(this.label&&(this.label.textContent=this.submitLabel),this._hideIconOnSubmit&&this.element.classList.add(`${s.prefix}-hide-icon`)):(this.label&&(this.label.textContent=this.nextLabel),this._hideIconOnSubmit&&this.element.classList.remove(`${s.prefix}-hide-icon`))}_checkForReplaceLabel(){this._hideIconOnSubmit="false"!==this.element.dataset.removeIconOnSubmit;const e=()=>{this.survey.isLastStep?(this._replaceLabel("submit"),this.element.setAttribute("type","submit")):(this.element.setAttribute("type","button"),this._replaceLabel("next"))};e(),this.holder.composer.on("isLastSurveyStep, foregroundLayersStatusCheck",e),this.element.addEventListener("click",(e=>{this.survey.isLastStep?this.survey.isProceedRestricted()&&(e.preventDefault(),this.holder.composer.trigger("surveyPreventProceed")):(this.holder.composer.navigator.next(),e.preventDefault())})),this.holder.composer.on("targetIndexChange",(()=>{this.holder.composer.navigator.targetIndex>this.survey.lastStepIndex?this.hide():this.show()}))}},e})()));