text: /* surveyJS Lite v3.0.2 | Valerio Di Punzio (@SimplySayHi) | https://www.valeriodipunzio.com/plugins/surveyJS/ | https://github.com/SimplySayHi/surveyJS | MIT license */
  const e=e=>Element.prototype.isPrototypeOf(e),s="sjs:init",t=e=>(Object.getOwnPropertyNames(e).forEach(s=>{const r=e[s];"object"==typeof r&&null!==r&&t(r)}),Object.freeze(e)),r=e=>"[object Object]"===Object.prototype.toString.call(e),a=function(e={}){return Array.from(arguments).slice(1).filter(e=>!!e).forEach(s=>{Object.keys(s).forEach(t=>{Array.isArray(s[t])?e[t]=(e[t]||[]).concat(s[t].slice(0)):r(s[t])?e[t]=a(e[t]||{},s[t]):Array.isArray(e[t])?e[t].push(s[t]):e[t]=s[t]})}),e},o=(e,s)=>Object.keys(e).reduce((s,t)=>{const r=new RegExp("{{"+t+"}}","g");return s.replace(r,e[t])},s),i=e=>(e[0].sort&&e.sort((e,s)=>e.sort>s.sort),e),l=(e=[])=>i(e).reduce((e,s)=>e+`<option value="${s.value}">${s.label}</option>`,""),n=(e,s,t)=>{const r=["data","id","label","nested","related","sort"];/^(option|textarea)$/.test(e.type)&&r.push("type","value");let a="";return Object.keys(e).filter(e=>-1===r.indexOf(e)).forEach(s=>{a+=` ${s}="${e[s]}"`}),e.data&&Object.keys(e.data).forEach(s=>{a+=` data-${((e="",s=!1)=>{let t=e.trim().replace(/(([_ ])([a-z]))|(([a-z])?([A-Z]))/g,(e,s,t,r,a,o,i)=>(r?"-"+r:(o||"")+"-"+i).toLowerCase());return s?t.toUpperCase():t})(s)}="${e.data[s]}"`}),t&&(a+=" required"),e.related&&(a+=" data-require-more"),a+=` id="${s}"`,a.trim()},c=(e,s,t)=>{let r="",d="";return i(e).forEach((i,u)=>{let p="";const f="option"===i.type?"select":i.type;if("select"===f&&d===f)return;d=f,s.question.checks&&(i=a({},i,{data:{checks:s.question.checks}}));const m=`${f}-${s.surveyId}-${s.question.id}-${"select"===f?u+1:i.id}`,y={questionNumber:s.question.index+1,wrapperClasses:t.cssClasses.wrapper[f]||t.cssClasses.wrapper.field,fieldAttributes:n(i,m,s.question.isRequired),fieldClasses:t.cssClasses[f]||t.cssClasses.field,answerType:f,answerCode:m,addMoreName:"",labelString:i.label||"",labelClasses:t.cssClasses.label};let v="";if(i.related){const e=i.related.type||"select",s="select"===e,r=s?a({},i):i.related;r.type=s?"option":e,r.id="",r.data=a({},r.data,{requiredFrom:"#"+m}),delete r.related;const c={fieldAttributes:n(r,"",!1),answerType:e,addMoreName:"-more",fieldClasses:s?t.cssClasses.select:t.cssClasses[e]||t.cssClasses.field};if(v=t.templates[e]||t.templates.input,s){const e=l(i.related);v=v.replace("{{optionsHtml}}",e)}v=o(c,v)}const w=((e,s)=>({field:s[e]||s.input,label:/^(checkbox|nested|radio|related)$/.test(e)?s.label:"",wrapper:s.wrapper[e]||s.wrapper.field}))(i.related?"related":i.nested?"nested":f,t.templates);let b="";i.nested&&(b=c(i.nested,s,t));let h="";"select"===f&&(h=l(e)),p=w.wrapper.replace("{{relatedFieldHTML}}",v).replace("{{fieldTemplate}}",w.field).replace("{{optionsHtml}}",h).replace("{{labelTemplate}}",w.label).replace("{{nestedFieldsHTML}}",b),r+=o(y,p)}),r},d=(e,s,t)=>{const a=((e,s,t)=>i(e).reduce((e,a,i)=>{if(a.external)return e;let l=t.templates.wrapper.question;const n=a.id,d=i+1,u={surveyId:s,question:{id:n,index:i,isRequired:!!a.required}};a.checks&&(u.question.checks=a.checks);const p=c(a.answers,u,t),f=a.checks?JSON.parse(a.checks):"",m=f[0]||"",y=f[1]||"",v=f&&t.messages.maxChoice?" ("+y+" "+t.messages.maxChoice+")":"",w={questionId:n,questionNumber:d,questionText:a.question+v,answersHTML:p};if(l=o(w,l),t.showErrorMessage){let e=""!==f?t.messages.errorMultiChoice:a.errorMessage||t.messages.error;r(e)&&(e=""),l=l.replace(/{{errorTemplates}}/g,e)}return e+o({checksMin:m,checksMax:y},l)},""))(e.questions,e.id,t);s.querySelector("[data-surveyjs-body]").insertAdjacentHTML("beforeend",a);const l=e.questions.filter(e=>e.external);if(l.length>0){const t=s.closest("[data-surveyjs-wrapper]");l.forEach((s,r)=>{const a=t.querySelector('[data-surveyjs-external="'+(r+1)+'"]');a.setAttribute("data-question-id",s.id),s.answers.forEach((t,r)=>{const o=a.querySelectorAll("[data-field]")[r],i={id:`${t.type}-${e.id}-${s.id}-${t.id}`,type:t.type,value:t.value,required:!!s.required};Object.keys(i).forEach(e=>{o[e]=i[e]});const l=o.closest("[data-answer]");l.querySelector("label").setAttribute("for",i.id),l.querySelector("[data-label]").innerHTML=t.label,a.querySelector("[data-question]").innerHTML=s.question})})}};class u{constructor(r,o={}){const i=arguments.length,l=(s=>{const t=typeof s,r="string"===t&&e(document.querySelector(s))&&"form"===document.querySelector(s).tagName.toLowerCase();return{result:e(s)||r,element:"string"===t?document.querySelector(s):s}})(r);if(0===i||i>0&&!r)throw new Error('First argument "formEl" is missing or falsy!');if(n=r,NodeList.prototype.isPrototypeOf(n))throw new Error('First argument "formEl" must be a single DOM node or a form CSS selector, not a NodeList!');var n;if(!l.result)throw new Error('First argument "formEl" is not a DOM node nor a form CSS selector!');if(!o.url||"string"!=typeof o.url)throw new Error('"options.url" is missing or not a string!');const c=this;c.formEl=l.element,c.options=a({},u.prototype.options,o),r=c.formEl,o=c.options,r.querySelector("[data-surveyjs-body]").insertAdjacentHTML("beforebegin",o.templates.loading);const p=((e=location.href,s={})=>{let t;if(s.headers=new Headers(s.headers),s.timeout>0){const e=new AbortController,r=e.signal;s.signal=r,t=window.setTimeout(()=>{e.abort()},s.timeout)}return fetch(e,s).then(e=>{if(!e.ok)throw new Error(e.statusText);return e.json()}).catch(e=>{throw new Error(e.message)}).finally(()=>{t&&window.clearTimeout(t)})})(o.url,o.initAjaxOptions).then(e=>"success"!==e.status.toLowerCase()?Promise.reject(e):(e.data.questions&&e.data.questions.length>0&&(d(e.data,r,o),Object.defineProperty(c,"data",{value:t(e.data)}),c.isInitialized=!0,r.closest("[data-surveyjs-wrapper]").classList.add("surveyjs-init-success")),e)).finally(()=>{const e=r.querySelector("[data-surveyjs-loading]");e&&e.parentNode.removeChild(e)});((e,s,t={},r={})=>{r=a({},{bubbles:!0},r);const o=new Event(s,r);o.data=t,e.dispatchEvent(o)})(r,s,p)}static setOptions(e){u.prototype.options=a({},u.prototype.options,e)}}u.prototype.isInitialized=!1,u.prototype.options={cssClasses:{checkbox:"form-check-input",field:"form-control",file:"form-control-file",label:"form-check-label",radio:"form-check-input",wrapper:{checkbox:"form-check",field:"",radio:"form-check"}},initAjaxOptions:{cache:"no-store",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json"},method:"GET",mode:"same-origin",redirect:"follow",timeout:0},messages:{maxChoice:"answers max",error:"Answer is necessary.",errorMultiChoice:"You must choose from {{checksMin}} to {{checksMax}} answers."},showErrorMessage:!0,templates:{error:'<div class="surveyjs-error-message">{{errorMessage}}</div>',input:'<input {{fieldAttributes}} name="surveyjs-answer-{{questionNumber}}{{addMoreName}}" class="surveyjs-input surveyjs-{{answerType}} {{fieldClasses}}" />',label:'<label for="{{answerCode}}" class="surveyjs-label {{labelClasses}}">{{labelString}}</label>',loading:'<div class="surveyjs-loading" data-surveyjs-loading>Loading...</div>',select:'<select {{fieldAttributes}} name="surveyjs-answer-{{questionNumber}}{{addMoreName}}" class="surveyjs-select {{fieldClasses}}">{{optionsHtml}}</select>',textarea:'<textarea {{fieldAttributes}} name="surveyjs-answer-{{questionNumber}}" class="surveyjs-textarea {{fieldClasses}}"></textarea>',wrapper:{field:'<div class="surveyjs-field-wrapper surveyjs-{{answerType}}-wrapper {{wrapperClasses}}">{{fieldTemplate}}{{labelTemplate}}</div>',nested:'<div class="surveyjs-field-wrapper surveyjs-nested-wrapper">{{labelTemplate}}<div class="surveyjs-nested-inner">{{nestedFieldsHTML}}</div></div>',question:'<div class="surveyjs-question-wrapper" data-question-id="{{questionId}}"><div class="surveyjs-question-text">{{questionText}}</div><div class="surveyjs-answers-wrapper">{{answersHTML}}</div><div class="surveyjs-errors-wrapper" data-surveyjs-errors>{{errorTemplates}}</div></div>',related:'<div class="surveyjs-field-wrapper surveyjs-related-wrapper input-group"><div class="input-group-prepend"><div class="surveyjs-radio-wrapper input-group-text form-check">{{fieldTemplate}}{{labelTemplate}}</div></div>{{relatedFieldHTML}}</div>'}}},u.prototype.version="3.0.2";export default u;
  //# sourceMappingURL=surveyjs-esm.min.js.map
  