freemium-survey-components 2.0.481 → 2.0.482

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.esm.js CHANGED
@@ -36,4 +36,4 @@ const X$=(e,t,n,a,o=!0)=>{const i=[];let r=t;const c=Math.min(e.byteLength,t+n-1
36
36
  * FilePondPluginFileValidateType 1.2.9
37
37
  * Licensed under MIT, https://opensource.org/licenses/MIT/
38
38
  * Please visit https://pqina.nl/filepond/ for details.
39
- */;const f5=({addFilter:e,utils:t})=>{const{Type:n,isString:a,replaceInString:o,guesstimateMimeType:i,getExtensionFromFilename:r,getFilenameFromURL:c}=t,s=(e,t)=>e.some((e=>{return/\*$/.test(e)?(n=e,(/^[^/]+/.exec(t)||[]).pop()===n.slice(0,-2)):e===t;var n})),l=(e,t,n)=>{if(0===t.length)return!0;const o=(e=>{let t="";if(a(e)){const n=c(e),a=r(n);a&&(t=i(a))}else t=e.type;return t})(e);return n?new Promise(((a,i)=>{n(e,o).then((e=>{s(t,e)?a():i()})).catch(i)})):s(t,o)};return e("SET_ATTRIBUTE_TO_OPTION_MAP",(e=>Object.assign(e,{accept:"acceptedFileTypes"}))),e("ALLOW_HOPPER_ITEM",((e,{query:t})=>!t("GET_ALLOW_FILE_TYPE_VALIDATION")||l(e,t("GET_ACCEPTED_FILE_TYPES")))),e("LOAD_FILE",((e,{query:t})=>new Promise(((n,a)=>{if(!t("GET_ALLOW_FILE_TYPE_VALIDATION"))return void n(e);const i=t("GET_ACCEPTED_FILE_TYPES"),r=t("GET_FILE_VALIDATE_TYPE_DETECT_TYPE"),c=l(e,i,r),s=()=>{const e=i.map((e=>t=>null!==e[t]&&(e[t]||t))(t("GET_FILE_VALIDATE_TYPE_LABEL_EXPECTED_TYPES_MAP"))).filter((e=>!1!==e)),n=e.filter(((t,n)=>e.indexOf(t)===n));a({status:{main:t("GET_LABEL_FILE_TYPE_NOT_ALLOWED"),sub:o(t("GET_FILE_VALIDATE_TYPE_LABEL_EXPECTED_TYPES"),{allTypes:n.join(", "),allButLastType:n.slice(0,-1).join(", "),lastType:n[n.length-1]})}})};if("boolean"==typeof c)return c?n(e):s();c.then((()=>{n(e)})).catch(s)})))),{options:{allowFileTypeValidation:[!0,n.BOOLEAN],acceptedFileTypes:[[],n.ARRAY],labelFileTypeNotAllowed:["File is of invalid type",n.STRING],fileValidateTypeLabelExpectedTypes:["Expects {allButLastType} or {lastType}",n.STRING],fileValidateTypeLabelExpectedTypesMap:[{},n.OBJECT],fileValidateTypeDetectType:[null,n.FUNCTION]}}};"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:f5}));K(h5,f5,V$,m5),B3(H3,I3,D3,V3);const O5=b((({onClick:e,maxFileSize:n=16,visible:a=!0,supportedFileFormats:o,translationVariables:i,fileErrors:r},c)=>{const[l,p]=s(!1),u=i?.drop_your_file?i?.drop_your_file:t.createElement(t.Fragment,null,"Drop your file here, or Browse");return t.createElement("div",{ref:c,className:"file-upload-container "+(r?.current?.main?"errored":""),onClick:e,style:{visibility:a?"visible":"hidden"},onDragOver:e=>{e.preventDefault(),e.target.classList.add("push-backward")}}," ",t.createElement(Ge,{name:"file-upload-icon"}),"string"!=typeof u?t.createElement("p",null,u):t.createElement("p",{className:"drop-your-file-container",dangerouslySetInnerHTML:{__html:u}}),t.createElement("p",{className:"max-size"},((e,t,n)=>{if(n&&e&&t)return e.replace(t,n)})(i?.max_file_size,"{{max_file_size}}",String(n))||`Maximum file size : ${n} MB`),t.createElement("p",{className:"support file-formats"},i?.supported_file_formats||"Supported file formats: "," ",(o=o.join(", ")).trim()?t.createElement(t.Fragment,null,l?o:o.slice(0,20)," ",t.createElement("span",{onClick:()=>p(!l),style:{color:"#2C5CC5",textDecoration:"underline",cursor:"pointer"}},l?i?.show_less||"Show less":i?.show_more||"Show more")):"No formats selected"),t.createElement("div",{className:"filepond--drip"}))})),A5=({question:e,onChangeHandler:n,onFileUpload:a,setErrors:o,translationVariables:i,surveyServAssetUrl:c,value:l,preview:p})=>{const[u,d]=s([]),[b,M]=s([]),z=r(),m=e.type_info?.file_field?.max_file_size||10,h=r(null),f=r(),[O,A]=s(!1);let v=!1;t.useEffect((()=>{const t=localStorage.getItem(`uploadedFile-${e?.name}`),n=t?JSON.parse(t):"";n?.source&&(n.options={...n.options,file:{name:l,size:n.fileSize}},l&&d([n]))}),[]);const g=async(t,o)=>{try{if(v)return;if(f.current&&we(h.current)||t){const i=t??f.current.getFiles()?.[0]?.file;if(i&&a){v=!0;const t=await a(i.type,i.size,i.name,e);if(o&&o(!0,50,100),t.startsWith("http")&&c){const a=await fetch(t,{method:"PUT",headers:{"Content-Type":i.type,"Content-Disposition":"attachment"},body:i}),o=new URL(t),r=`${c}${o.pathname}`;if(!a.ok)throw console.error("Error uploading file"),new Error("Error uploading file");localStorage.setItem(`uploadedFile-${e?.name}`,JSON.stringify({source:r,options:{type:"local"},fileSize:f.current.getFiles()?.[0]?.fileSize})),n(i.name)}else n(p?"dummy":null),console.error("Error fetching pre-signed url");v=!1}}}catch(e){throw console.error("error in uploading file",e,"stringified error",JSON.stringify(e)),new Error("Error uploading file")}};return t.useEffect((()=>{(()=>{const t=e.type_info?.file_field?.allowed_file_types,n=Object.keys(Oe).map((e=>{if((t||[]).includes(e))return Oe[e].concat(",")})).join(" ").trim().slice(0,-1);M(n.split(", "))})()}),[]),t.createElement(t.Fragment,null,t.createElement(Q,{ref:f,files:u,labelFileProcessing:i?.uploading_text??"Uploading..",labelFileProcessingComplete:i?.upload_complete??"Upload complete",labelMaxFileSizeExceeded:i?.file_too_large??"The file is too large and cannot be uploaded.",labelMaxFileSize:"",labelTapToCancel:"",labelTapToUndo:"",labelFileTypeNotAllowed:i?.invalid_type??"The file mismatch. Retry by uploading the supported file type.",fileValidateTypeLabelExpectedTypes:"",beforeAddFile:e=>(h.current?.main&&(h.current=null,o({}),d([e]),A(!0)),!0),onremovefile:()=>{O?A(!1):(d([]),o({}),h.current=null,n(null))},allowReplace:!0,server:{process:async(e,t,n,a,o,i)=>{i(!0,0,100);try{await g(t,i),i(!0,100,100),a(t.name)}catch(e){o("An error occurred during upload")}}},onpreparefile:(e,t)=>{const n=new FileReader;n.onloadend=()=>{const t=n.result??"",a=new Blob([t],{type:e.fileType}),o=new File([a],e.filename,{type:e.fileType});g(o)},n.readAsArrayBuffer(t)},onerror:t=>{h.current=t,o({[e.name]:t})},required:!0,credits:!1,allowFileTypeValidation:!0,acceptedFileTypes:b,fileValidateTypeDetectType:(e,t)=>new Promise(((t,n)=>{const a=e.name.split(".");t(`.${a[a.length-1].toLowerCase()}`)})),imageEditor:{legacyDataToImageState:hJ,createEditor:Q3,imageReader:[N3,{}],imageWriter:[P3,{}],imageProcessor:rF,imageEditorAfterWriteImage:({src:e,dest:t,imageState:n})=>new Promise(((a,o)=>{rF(e,{imageReader:N3(),imageWriter:P3({targetSize:{width:128,height:15,fit:"cover"}}),imageState:n}).then((n=>{a([{name:"input_",file:e},{name:"output_",file:t},{name:"thumb_",file:n.dest}])})).catch(o)})),editorOptions:{utils:["crop","finetune","filter","annotate"],imageOrienter:$3(),shapePreprocessor:J3(),...X3,...j3,..._3,locale:{...F3,...G3,...Z3,...Y3,...K3,...U3}}},allowFileSizeValidation:!0,maxFileSize:`${m}MB`,onupdatefiles:e=>{z.current?.classList.remove("push-backward"),e.length&&d(e)},maxFiles:1,name:`${e.id}-files`}),t.createElement(O5,{ref:z,onClick:e=>{const t=e.target;"path"!==t?.tagName&&"P"!==t?.tagName&&(!t?.className||t?.className instanceof SVGAnimatedString||t.className.includes("format-type-toggler"))||f.current.browse()},fileErrors:h,visible:Boolean(!u.length||h.current?.main),maxFileSize:m,translationVariables:{...i,tTimeZones:[{id:"",offset:"",timeZone:""}]},supportedFileFormats:b}),h?.current?.main&&t.createElement("div",{className:"file-error"},t.createElement(Ge,{name:"info"}),t.createElement("span",null,`${h?.current?.main}\n ${h.current?.sub}`)))},v5=e=>{switch(e){case"EMAIL":return"email";case"PHONE":return"tel";case"NUMBER":return"number";default:return"text"}},g5=({question:e,autoFocusDelay:n,onChangeHandler:a,surveyStyle:o,formValues:i,fieldErrors:r,translationVariables:c,language:s,isQuestionBgDark:l,isMobile:p,isWidget:u,widgetStyle:d})=>{const b=e.type_info?.form_fields?.layout,M=e.type_info?.form_fields?.fields;return t.createElement("div",{className:`fsc-form-field-container layout-${(p||u&&"compact"===d?"VERTICAL":b??"VERTICAL").toLowerCase()}`.trim()},M?.map(((p,u)=>{const d="NUMBER"===p?.type||"PHONE"===p.type?18:256;return t.createElement("div",{className:"fsc-form-field",key:p.id},"DATE"!==p?.type&&"DATE_TIME"!==p?.type?t.createElement(t.Fragment,null,"PHONE"===p.type?t.createElement(Ka,{key:u,surveyLayout:o??"card",setFocus:0===u&&"standard"!==o,autoFocusDelay:n,label:p?.label||"",type:"tel",isRequired:!!p.required,showCount:!0,maxLength:d,value:p.id&&i[e.name]?.[p.id]||"",onChangeHandler:(t,n)=>{p.id&&a({...i[e.name]??{},[p.id]:t||null},!0)},isErrored:!(!p.id||!i?.[e.name]?.[p.id])&&!!r?.[p?.id||""],errorText:p.id&&i[e.name]?.[p.id]?r?.[p?.id]:"",translationVariables:c}):t.createElement(ja,{isQuestionBgDark:l,key:u,setFocus:0===u&&"standard"!==o,autoFocusDelay:n,onKeyDown:e=>{"PHONE"===p?.type&&Be(e),"NUMBER"===p?.type&&_e(e)},showCount:!0,maxLength:d,placeholder:"NUMBER"===p?.type?"0":void 0,label:p?.label||"",type:v5(p?.type??"TEXT"),isRequired:!!p.required,value:p.id?i[e.name]?.[p.id]??"":"",onChange:t=>{p.id&&a({...i[e.name]??{},[p.id]:t.target.value.slice(0,d)||null})},onBlur:t=>{if(p.id){const n=i[e.name]?.[p.id],o=t.target.value.slice(0,d);(qe(n)||we(n))&&(qe(o)||we(o))||a?.({...i[e.name]??{},[p.id]:o||null},!1)}},isErrored:!(!p.id||!i?.[e.name]?.[p.id])&&!!r?.[p?.id||""],errorText:p.id&&i[e.name]?.[p.id]?r?.[p?.id]:""})):t.createElement(t.Fragment,null,"DATE_TIME"===p?.type?t.createElement(Uq,{id:p.id??"",name:e.name??"",label:p?.label??"",isRequired:!!p.required,allowOnlyFuture:!!e.type_info?.meta?.allow_future_date,language:s,useAmPm:!e.type_info?.meta?.time_format,showTimezoneSelect:!1,onChange:t=>{a({...i[e.name]??{},...p.id&&{[p.id]:t}},!0)},value:p?.id&&i[e?.name]?.[p?.id],type:"FORM_FIELD",translationVariables:c}):t.createElement(Fq,{id:p.id??"",name:e.name??"",label:p?.label??"",isRequired:!!p.required,allowOnlyFuture:!!e.type_info?.meta?.allow_future_date,language:s,onChange:t=>{a({...i[e.name]??{},...p.id&&{[p.id]:t}},!0)},value:p?.id&&i[e?.name]?.[p?.id],type:"FORM_FIELD",translationVariables:c})))})))};var y5="rovingFocusGroup.onEntryFocus",q5={bubbles:!1,cancelable:!0},W5="RovingFocusGroup",[w5,L5,R5]=Nt(W5),[C5,x5]=ot(W5,[R5]),[k5,E5]=C5(W5),T5=b(((e,t)=>y(w5.Provider,{scope:e.__scopeRovingFocusGroup,children:y(w5.Slot,{scope:e.__scopeRovingFocusGroup,children:y(S5,{...e,ref:t})})})));T5.displayName=W5;var S5=b(((e,t)=>{const{__scopeRovingFocusGroup:a,orientation:o,loop:i=!1,dir:l,currentTabStopId:p,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:d,onEntryFocus:b,preventScrollOnEntryFocus:M=!1,...z}=e,m=r(null),h=at(t,m),f=$t(l),[O=null,A]=st({prop:p,defaultProp:u,onChange:d}),[v,g]=s(!1),q=ct(b),W=L5(a),w=r(!1),[L,R]=s(0);return c((()=>{const e=m.current;if(e)return e.addEventListener(y5,q),()=>e.removeEventListener(y5,q)}),[q]),y(k5,{scope:a,orientation:o,dir:f,loop:i,currentTabStopId:O,onItemFocus:n((e=>A(e)),[A]),onItemShiftTab:n((()=>g(!0)),[]),onFocusableItemAdd:n((()=>R((e=>e+1))),[]),onFocusableItemRemove:n((()=>R((e=>e-1))),[]),children:y(Ot.div,{tabIndex:v||0===L?-1:0,"data-orientation":o,...z,ref:h,style:{outline:"none",...e.style},onMouseDown:rt(e.onMouseDown,(()=>{w.current=!0})),onFocus:rt(e.onFocus,(e=>{const t=!w.current;if(e.target===e.currentTarget&&t&&!v){const t=new CustomEvent(y5,q5);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){const e=W().filter((e=>e.focusable));_5([e.find((e=>e.active)),e.find((e=>e.id===O)),...e].filter(Boolean).map((e=>e.ref.current)),M)}}w.current=!1})),onBlur:rt(e.onBlur,(()=>g(!1)))})})})),N5="RovingFocusGroupItem",P5=b(((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:a=!0,active:o=!1,tabStopId:i,...r}=e,s=cn(),l=i||s,p=E5(N5,n),u=p.currentTabStopId===l,d=L5(n),{onFocusableItemAdd:b,onFocusableItemRemove:M}=p;return c((()=>{if(a)return b(),()=>M()}),[a,b,M]),y(w5.ItemSlot,{scope:n,id:l,focusable:a,active:o,children:y(Ot.span,{tabIndex:u?0:-1,"data-orientation":p.orientation,...r,ref:t,onMouseDown:rt(e.onMouseDown,(e=>{a?p.onItemFocus(l):e.preventDefault()})),onFocus:rt(e.onFocus,(()=>p.onItemFocus(l))),onKeyDown:rt(e.onKeyDown,(e=>{if("Tab"===e.key&&e.shiftKey)return void p.onItemShiftTab();if(e.target!==e.currentTarget)return;const t=function(e,t,n){const a=function(e,t){return"rtl"!==t?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}(e.key,n);return"vertical"===t&&["ArrowLeft","ArrowRight"].includes(a)||"horizontal"===t&&["ArrowUp","ArrowDown"].includes(a)?void 0:$5[a]}(e,p.orientation,p.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=d().filter((e=>e.focusable)).map((e=>e.ref.current));if("last"===t)n.reverse();else if("prev"===t||"next"===t){"prev"===t&&n.reverse();const a=n.indexOf(e.currentTarget);n=p.loop?function(e,t){return e.map(((n,a)=>e[(t+a)%e.length]))}(n,a+1):n.slice(a+1)}setTimeout((()=>_5(n)))}}))})})}));P5.displayName=N5;var $5={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _5(e,t=!1){const n=document.activeElement;for(const a of e){if(a===n)return;if(a.focus({preventScroll:t}),document.activeElement!==n)return}}var B5=T5,H5=P5,D5="Radio",[I5,V5]=ot(D5),[X5,j5]=I5(D5),F5=b(((e,t)=>{const{__scopeRadio:n,name:a,checked:o=!1,required:i,disabled:c,value:l="on",onCheck:p,form:u,...d}=e,[b,M]=s(null),z=at(t,(e=>M(e))),m=r(!1),h=!b||(u||!!b.closest("form"));return W(X5,{scope:n,checked:o,disabled:c,children:[y(Ot.button,{type:"button",role:"radio","aria-checked":o,"data-state":Z5(o),"data-disabled":c?"":void 0,disabled:c,value:l,...d,ref:z,onClick:rt(e.onClick,(e=>{o||p?.(),h&&(m.current=e.isPropagationStopped(),m.current||e.stopPropagation())}))}),h&&y(Y5,{control:b,bubbles:!m.current,name:a,value:l,checked:o,required:i,disabled:c,form:u,style:{transform:"translateX(-100%)"}})]})}));F5.displayName=D5;var U5="RadioIndicator",G5=b(((e,t)=>{const{__scopeRadio:n,forceMount:a,...o}=e,i=j5(U5,n);return y(dt,{present:a||i.checked,children:y(Ot.span,{"data-state":Z5(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})}));G5.displayName=U5;var Y5=e=>{const{control:t,checked:n,bubbles:a=!0,...o}=e,i=r(null),s=lt(n),l=ut(t);return c((()=>{const e=i.current,t=window.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(t,"checked").set;if(s!==n&&o){const t=new Event("click",{bubbles:a});o.call(e,n),e.dispatchEvent(t)}}),[s,n,a]),y("input",{type:"radio","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:i,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function Z5(e){return e?"checked":"unchecked"}var K5=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Q5="RadioGroup",[J5,e4]=ot(Q5,[x5,V5]),t4=x5(),n4=V5(),[a4,o4]=J5(Q5),i4=b(((e,t)=>{const{__scopeRadioGroup:n,name:a,defaultValue:o,value:i,required:r=!1,disabled:c=!1,orientation:s,dir:l,loop:p=!0,onValueChange:u,...d}=e,b=t4(n),M=$t(l),[z,m]=st({prop:i,defaultProp:o,onChange:u});return y(a4,{scope:n,name:a,required:r,disabled:c,value:z,onValueChange:m,children:y(B5,{asChild:!0,...b,orientation:s,dir:M,loop:p,children:y(Ot.div,{role:"radiogroup","aria-required":r,"aria-orientation":s,"data-disabled":c?"":void 0,dir:M,...d,ref:t})})})}));i4.displayName=Q5;var r4="RadioGroupItem",c4=b(((e,t)=>{const{__scopeRadioGroup:n,disabled:a,...o}=e,i=o4(r4,n),s=i.disabled||a,l=t4(n),p=n4(n),u=r(null),d=at(t,u),b=i.value===o.value,M=r(!1);return c((()=>{const e=e=>{K5.includes(e.key)&&(M.current=!0)},t=()=>M.current=!1;return document.addEventListener("keydown",e),document.addEventListener("keyup",t),()=>{document.removeEventListener("keydown",e),document.removeEventListener("keyup",t)}}),[]),y(H5,{asChild:!0,...l,focusable:!s,active:b,children:y(F5,{disabled:s,required:i.required,checked:b,...p,...o,name:i.name,ref:d,onCheck:()=>i.onValueChange(o.value),onKeyDown:rt((e=>{"Enter"===e.key&&e.preventDefault()})),onFocus:rt(o.onFocus,(()=>{M.current&&u.current?.click()}))})})}));c4.displayName=r4;var s4=b(((e,t)=>{const{__scopeRadioGroup:n,...a}=e,o=n4(n);return y(G5,{...o,...a,ref:t})}));s4.displayName="RadioGroupIndicator";var l4=i4,p4=c4,u4=s4;const d4=e=>{const{checked:n,className:a,disabled:o,id:i,isRequired:r,label:c,name:s,readOnly:l,onChange:p,...u}=e;return t.createElement(l4,{className:`fsc-radio ${a??""}`.trim(),name:s,"aria-label":c||"Radio button",value:n?"default":"",required:r,disabled:o,"aria-readonly":l,onValueChange:e=>{p?.(!n,e)},...u},t.createElement("div",{className:"fsc-radio-container"},t.createElement(p4,{checked:n,"aria-checked":n,className:"fsc-radio-item",disabled:o,"aria-readonly":l,id:i,value:"default"},t.createElement(u4,{className:"fsc-radio-indicator"})),c&&t.createElement("label",{htmlFor:i,className:"fsc-radio-label"},c,c&&r&&t.createElement("span",null,"*"))))},b4=e=>{const{type_info:{matrix_properties:n},onChangeHandler:a,value:o}=e;return t.createElement("div",{className:"matrix-container","data-test-input":"matrix"},t.createElement("table",{className:"st-mt-table"},t.createElement("thead",{className:"st-mt-thead"},t.createElement("tr",{className:"st-mt-tr"},t.createElement("th",{className:"m-s-b-s-q-m-s-th-empty st-mt-th"}),n?.rating_labels?.map(((e,n)=>e.is_active?t.createElement("th",{key:e.id,className:"m-s-b-s-q-m-s-th st-mt-th"},t.createElement("div",{className:"m-s-b-s-q-m-s-th-div"},e.text)):null)))),t.createElement("tbody",{className:"st-mt-tbody"},n?.statements?.map(((e,i)=>e.is_active?t.createElement("tr",{key:e.id,className:"m-s-b-s-q-m-s-tr-hover st-mt-tr"},t.createElement("td",{className:"m-s-b-s-q-m-s-input st-mt-td"},e.text),n?.rating_labels?.map(((r,c)=>{if(!r.is_active)return null;const s=o?.find((t=>t?.statement_id===e?.id));return t.createElement("td",{key:r.id,className:"m-s-b-s-q-m-s-switch st-mt-td"},"SINGLE_ANSWER"===n?.type&&t.createElement(d4,{key:r.id||`${i}-key-${c}`,name:`q-m-s-radio-${i}-key-${c}`,checked:!!s?.rating_labels?.find((e=>e?.id===r?.id)),id:r.id??"",onChange:()=>{e?.id&&r?.id&&a(s?.statement_id?[...o||[]].map((e=>e?.statement_id===s?.statement_id?{...s,rating_labels:[{id:r.id||"",text:r?.text||""}]}:e)):[...o||[],{statement_id:e.id,rating_labels:[{id:r.id,text:r?.text||""}]}])},label:""}),"MULTIPLE_ANSWERS"===n?.type&&t.createElement(Tt,{key:r.id||`${i}-key-${c}`,name:`q-m-s-checkbox-${i}-key-${c}`,checked:!!s?.rating_labels?.find((e=>e?.id===r?.id)),id:r.id??"",onChange:t=>{e?.id&&r?.id&&a(s?.statement_id?[...o||[]].map((e=>e.statement_id===s.statement_id?{...s,rating_labels:t?[...s.rating_labels||[],{id:r.id||"",text:r?.text||""}]:(s.rating_labels||[]).filter((e=>e?.id!==r.id))}:e)):[...o||[],{statement_id:e.id,rating_labels:[{id:r.id,text:r?.text||""}]}])}}))}))):null)))))},M4=e=>{const{type_info:{matrix_properties:n},onChangeHandler:a,name:o,isMobile:i,isReverseAnimation:r,statementIndex:c,value:s,widgetStyle:l,language:p="en"}=e,u=t.useMemo((()=>(n?.statements||[]).find(((e,t)=>t===c))),[n?.statements,c]),d=t.useMemo((()=>s?.find((e=>e?.statement_id===u?.id))),[u,s]);return t.createElement("div",{className:"matrix-wd-container","data-test-input":"matrix"},t.createElement("div",{className:"matrix-st-count"},`${c+1}/${(n?.statements||[]).length}`),t.createElement(DE,{exitBeforeEnter:!0},t.createElement(PE.div,{key:`${u?.id??""}`,initial:{opacity:0,x:Re(p,r)},animate:{opacity:1,x:0},exit:{opacity:0,x:Ce(p,r)},transition:{duration:.2}},t.createElement("div",{className:"matrix-st-text"},u?.text),t.createElement("div",{className:`matrix-st-labels wd-style-${l} ${i?"mt-mobile":""}`.trim()},"MULTIPLE_ANSWERS"===n?.type&&t.createElement(f$,{name:o??"",onChangeHandler:e=>{if(u?.id){const t=d?.statement_id?[...s||[]].map((t=>t.statement_id===d.statement_id?{...d,rating_labels:e.map((e=>{const t=n?.rating_labels?.find((t=>t.id===e));return{id:e,text:t?.text||""}}))}:t)):[...s||[],{statement_id:u.id,rating_labels:e.map((e=>{const t=n?.rating_labels?.find((t=>t.id===e));return{id:e,text:t?.text||""}}))}];a(t)}},saveOthersValue:()=>{},options:(n?.rating_labels??[]).map((e=>({id:e.id,value:e.text}))),values:(d?.rating_labels??[]).map((e=>e.id??"")),autoFocusDelay:0,othersValue:""}),"SINGLE_ANSWER"===n?.type&&t.createElement(IE,{name:o??"",language:p||"en",onChangeHandler:e=>{const t=n?.rating_labels?.find((t=>t.id===e));u?.id&&e&&a(d?.statement_id?[...s||[]].map((n=>n?.statement_id===d?.statement_id?{...d,rating_labels:[{id:e||"",text:t?.text||""}]}:n)):[...s||[],{statement_id:u.id,rating_labels:[{id:e,text:t?.text||""}]}])},saveOthersValue:()=>{},options:(n?.rating_labels??[]).map((e=>({id:e.id,value:e.text}))),value:d?.rating_labels?.[0]?.id??"",othersValue:""})))))},z4=({question:e,autoFocusDelay:n,setFocus:a,formValues:o,surveyLayout:i,onChangeHandler:r,isQuestionBgDark:c})=>{const s=e?.type_info?.number_field?.decimal,l=e?.type_info?.number_field?.decimal_point,p=s?2===l?"0.01":"0.1":"1",u=o[e.name],[d,b]=t.useState(u);t.useEffect((()=>{d&&!u&&b(u)}),[u]);const{maxLength:M,maxNumber:z}=t.useMemo((()=>{const e=s?16:18;var t;return{maxLength:e,maxNumber:(t=e)>=16?10n**BigInt(t)-1n:10**t-1}}),[s]),m=e=>{s&&!qe(l)&&(e.split(".")?.[1]?.length??0)>(l??0)||r(e?We(e,s||!1):"",!1)};return t.createElement("div",{className:"responsive-input-field"},t.createElement(ja,{autoFocusDelay:n,isRequired:!!e.required,type:"number",step:p,placeholder:e?.type_info?.meta?.placeholder??s?"0.0"+(2===l?"0":""):"0",onKeyDown:e=>{const{key:t,keyCode:n,which:a,code:o}=e;if(["e","E"].includes(t)&&e.currentTarget.value&&e.preventDefault(),"."===t&&s||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||["Backspace","Shift","Tab","ArrowDown","ArrowUp","ArrowLeft","ArrowRight","-","+","e","E"].includes(t))return;if(["e","E"].includes(t))return;const i=void 0===a?n??o:a;String.fromCharCode(i).match(/^[0-9]+$/)||e.preventDefault()},..."card"===i?{value:u??"",onChange:e=>{if(e.target.value.includes("e+"))return;const t=BigInt(e.target.value.split(".")[0]??"");BigInt(t)<=z&&e.target.value.length<=M&&m(e.target.value)}}:{value:d??"",onChange:e=>{if(e.target.value.includes("e+"))return;const t=BigInt(e.target.value.split(".")[0]??""),n=e.target.value.split(".")[1]??"";if(n.length>(l??0))return;const a=BigInt(t);a<=z&&e.target.value.length<=M&&b(`${a}${qe(n)||we(n)?"":`.${n}`}`)},onBlur:()=>{return e=d,void((qe(u)||we(u))&&(qe(d)||we(d))||d===u||m(e));var e}},setFocus:a,showCount:!0,max:`${z}`,maxLength:M,isQuestionBgDark:c}))},m4=({question:e,questionCommentOnchangeHandler:n,commentsMeta:a,setFocus:o,isQuestionBgDark:i,isCommentsEnabled:r})=>{const[c,s]=t.useState(a?.toString());return r?t.createElement(DE,null,t.createElement(PE.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},transition:{duration:.3,ease:"easeInOut"},exit:{height:0,opacity:0},className:"question-comments"},t.createElement(wP,{showCount:!0,maxLength:1500,rows:2,isRequired:!!e.required,placeholder:e?.type_info?.comment_placeholder??"Enter your comment",onChange:t=>{const a=t.target.value||"";s(a),n?.(e.name,a)},value:a||c,setFocus:!0,isQuestionBgDark:i,"aria-label":e.name}))):null},h4=e=>{switch(e){case"EMAIL":return"email";case"PHONE":return"tel";case"URL":return"url";default:return"text"}},f4=e=>{switch(e){case"PHONE":return"phone";case"EMAIL":return"email";case"URL":return"url";default:return""}},O4=({question:e,autoFocusDelay:n,formValues:a,onChangeHandler:o,textboxErrors:i,surveyLayout:r,setFocus:c,onKeyDownHandler:s,translationVariables:l,isQuestionBgDark:p})=>{const u=e?.type_info?.text_field?.text_type,d=a[e.name],[b,M]=t.useState(d);return t.useEffect((()=>{b&&!d&&M(d)}),[d]),t.createElement("div",{className:"responsive-input-field"},"PHONE"===u?t.createElement(Ka,{startAdornment:t.createElement(Ge,{fill:"var(--choices-answers-color, var(--question-text-color, var(--default-question-text-color)))",name:f4(u)}),type:h4(u),setFocus:c,autoFocusDelay:n,label:"",isRequired:!!e.required,value:d,isErrored:!!i[e.name],errorText:i[e.name]||"",placeholder:e?.type_info?.meta?.placeholder??"",onChangeHandler:o,maxLength:18,showCount:!0,onKeyDownHandler:s,surveyLayout:r,translationVariables:l}):t.createElement(ja,{startAdornment:u&&"TEXT"!==u&&t.createElement(Ge,{fill:"var(--choices-answers-color, var(--question-text-color, var(--default-question-text-color)))",name:f4(u)}),type:h4(u),setFocus:c,autoFocusDelay:n,showCount:!0,label:"",onKeyDown:s,isRequired:!!e.required,isErrored:!!i[e.name],errorText:i[e.name]||"",placeholder:e?.type_info?.meta?.placeholder??"",..."card"===r?{value:d??"",onChange:e=>o(e.target.value)}:{onBlur:e=>{(qe(d)||we(d))&&(qe(b)||we(b))||b===d||o?.(e.target.value,!0)},value:b??"",onChange:e=>M(e.target.value)},maxLength:50,isQuestionBgDark:p}))},A4=({surveyLanguage:e,language:n="en",question:a,formValues:o,othersMeta:i,onChangeHandler:r,saveOthersValue:c,autoFocusDelay:s,isFinalQn:l,isWidget:p,isMobile:u,initialPivotAnswer:d,initialQuestionAnswer:b,isInitialTransition:M,formQuestionErrors:z,dateQuestionErrors:m,contactFormErrors:h,activeIndexOfRenderedStatement:f={},textboxQuestionErrors:O,isReverseAnimation:A,fileUploadErrors:v,preview:g,onFileUpload:y,widgetStyle:q="default",setErrors:W,translationVariables:w,surveyServAssetUrl:L,setFocus:R,block:C,onKeyDown:x,surveyStyle:k,isQuestionBgDark:E})=>{const T=a?.type_info?.question_comment,S=a?.type_info?.footer_text&&a.type_info.meta?.question_hint?t.createElement("div",{className:"svs-footer question-hint ss-question-hint",role:"note",dangerouslySetInnerHTML:{__html:a?.type_info?.footer_text}}):t.createElement(t.Fragment,null),N=o[a.name],[P,$]=t.useState(N);switch(t.useEffect((()=>{P&&!N&&$(N)}),[N]),a?.type_info?.question_type){case"MATRIX_RATING_SCALE":return t.createElement(t.Fragment,null,p||u?t.createElement(M4,{language:n,name:a.name,isReverseAnimation:A,type_info:a?.type_info||{},onChangeHandler:e=>{r(e?.filter((e=>(e.rating_labels||[]).length>0)))},isMobile:u,value:o[a.name]||[],statementIndex:f[a.name]??0,widgetStyle:q}):t.createElement(b4,{type_info:a?.type_info||{},onChangeHandler:e=>{r(e?.filter((e=>(e.rating_labels||[]).length>0)))},value:o[a.name]||[]}),S);case"RANGE":return t.createElement(t.Fragment,null,t.createElement(jE,{question:a,onChangeHandler:r,isWidget:p,isMobile:u,widgetStyle:q,value:o[a.name],initialPivotAnswer:d,isInitialTransition:M}),T&&null!=o[a.name]&&t.createElement(m4,{question:a,questionCommentOnchangeHandler:c,commentsMeta:i?.[a?.name],surveyStyle:k,setFocus:R,isQuestionBgDark:E,isCommentsEnabled:T}),S);case"CHECKBOX":case"MULTI_SELECT":return t.createElement(t.Fragment,null,t.createElement(f$,{name:a.name,values:o[a.name],othersValue:i[a.name],options:a?.choices||[],onChangeHandler:r,saveOthersValue:c,isOthersOption:!!(a?.choices||[]).find((e=>e.meta?.is_others)),othersRequired:!!a?.type_info.meta?.othersRequired,autoFocusDelay:s,translationVariables:w,othersInputPlaceholder:a?.type_info?.comment_placeholder}),T&&null!=o[a.name]&&t.createElement(m4,{question:a,questionCommentOnchangeHandler:c,commentsMeta:i?.[a?.name],surveyStyle:k,setFocus:R,isQuestionBgDark:E,isCommentsEnabled:T}),S);case"RADIO":case"DROPDOWN":return t.createElement(t.Fragment,null,t.createElement(IE,{autoFocusDelay:s,name:a.name,onChangeHandler:r,initialQuestionAnswer:b,displayFormat:a?.type_info?.meta?.display_format||"LIST",saveOthersValue:c,options:a?.choices||[],value:o[a.name],othersValue:i[a.name],isOthersOption:!!(a?.choices||[]).find((e=>e.meta?.is_others)),language:n||"en",othersRequired:!!a?.type_info.meta?.othersRequired,isFinalQn:l,translationVariables:w,isQuestionBgDark:E,othersInputPlaceholder:a?.type_info?.comment_placeholder}),T&&null!=o[a.name]&&t.createElement(m4,{question:a,questionCommentOnchangeHandler:c,commentsMeta:i?.[a?.name],surveyStyle:k,setFocus:R,isQuestionBgDark:E,isCommentsEnabled:T}),S);case"TEXT":return t.createElement(t.Fragment,null,t.createElement(O4,{question:a,autoFocusDelay:s,formValues:o,onChangeHandler:r,textboxErrors:O||"",setFocus:R,onKeyDownHandler:x,surveyLayout:k??"card",translationVariables:w,isQuestionBgDark:E}),S);case"NUMBER":return t.createElement(t.Fragment,null,t.createElement(z4,{question:a,autoFocusDelay:s,formValues:o,setFocus:R,onChangeHandler:r,surveyLayout:k??"card",isQuestionBgDark:E}),S);case"FORM_FIELD":return t.createElement(t.Fragment,null,t.createElement(g5,{widgetStyle:q,question:a,isWidget:p,isMobile:u,surveyStyle:k,isRequired:!!a.required,autoFocusDelay:s,translationVariables:w,onChangeHandler:(e,t)=>{r(e,"card"!==k&&t)},formValues:o,fieldErrors:z?.[a.name]||{},language:n||"en",isQuestionBgDark:E}),S);case"CONTACT_FORM":return t.createElement(t.Fragment,null,t.createElement(A$,{question:a,setFocus:R,autoFocusDelay:s,onChangeHandler:r,translationVariables:w,formValues:o,fieldErrors:h?.[a.name]||{},language:n||"en",isQuestionBgDark:E}),S);case"PARAGRAPH":return t.createElement(t.Fragment,null,t.createElement(wP,{showCount:!0,maxLength:1500,autoFocusDelay:s,isRequired:!!a.required,placeholder:a?.type_info?.meta?.placeholder??"",..."card"===k?{value:N??"",onChange:e=>r(e.target.value)}:{onBlur:e=>{(qe(N)||we(N))&&(qe(P)||we(P))||P===N||r?.(e.target.value,!0)},value:P??"",onChange:e=>$(e.target.value)},setFocus:R,isQuestionBgDark:E,"aria-label":a.name}),S);case"BOOLEAN":case"RESOLUTION":return t.createElement(t.Fragment,null,t.createElement(Qe,{type_info:a?.type_info,onSelect:r,value:o[a.name]}),T&&null!=o[a.name]&&t.createElement(m4,{question:a,questionCommentOnchangeHandler:c,commentsMeta:i?.[a?.name],surveyStyle:k,setFocus:R,isQuestionBgDark:E,isCommentsEnabled:T}),S);case"MESSAGE":return S;case"CONSENT":return t.createElement(t.Fragment,null,t.createElement(O$,{question:a,onChange:r,value:o[a.name]}),S);case"SLIDER":const e=a?.type_info.meta?.slider;return t.createElement(t.Fragment,null,t.createElement(qP,{defaultValue:[o[a.name]??e?.opening_position],isRequired:!!a.required,dir:Le(n)?"rtl":"ltr",answer:o[a.name],min:e?.min,max:e?.max,onValueChange:([e],t)=>r(e,"card"!==k&&t),isInput:e?.numerical_input_box,gridLines:e?.grid_lines,stopAtGrid:e?.stop_at_grid_lines,allowDecimals:e?.allow_decimal,decimalPoints:e?.decimal_points,isMobile:u||"compact"===q}),T&&null!=o[a.name]&&t.createElement(m4,{question:a,questionCommentOnchangeHandler:c,commentsMeta:i?.[a?.name],surveyStyle:k,setFocus:R,isQuestionBgDark:E,isCommentsEnabled:T}),S);case"RANK_ORDER":const{others_meta:v,...C}=o;return t.createElement(t.Fragment,null,t.createElement(LN,{valueItems:C[a.name],items:a?.choices||[],onReorder:(e,t)=>r(e,"card"!==k&&t)}),S);case"DATE_TIME":return t.createElement(t.Fragment,null,"DATE_TIME"===a.type_info.meta?.question_format?t.createElement(Uq,{id:a.id??"",name:a.name??"",type:"QUESTION",displayFormat:a.type_info.meta?.format??void 0,allowOnlyFuture:a.type_info.meta?.allow_future_date||!1,useAmPm:!a.type_info.meta?.time_format,showTimezoneSelect:!!a.type_info.meta?.time_zone,onChange:(e,t)=>{r(e,"card"!==k&&t)},setErrors:e=>{W((t=>({...t,dateQuestionErrors:e})))},fieldErrors:m?.[a.name]??[],value:o[a.name]||"",translationVariables:w,language:n||"en",isQuestionBgDark:E,isWidget:p}):t.createElement(Fq,{allowOnlyFuture:a.type_info.meta?.allow_future_date||!1,type:"QUESTION",displayFormat:a.type_info.meta?.format??void 0,onChange:e=>{r(e,!1)},value:o[a.name]||"",translationVariables:w,language:n||"en",fieldErrors:m?.[a.name]??[],isQuestionBgDark:E,isWidget:p}),S);case"FILE":return t.createElement(A5,{setErrors:e=>{W({formQuestionErrors:z,textboxQuestionErrors:O,contactFormErrors:h,fileUploadErrors:e,dateQuestionErrors:m})},preview:g,onChangeHandler:r,question:a,onFileUpload:y,value:o[a.name]||"",translationVariables:w,surveyServAssetUrl:L});default:return console.error(`Question type ${a?.type_info?.question_type} not found`),null}},v4=({surveyServAssetUrl:e,thankYouQuestion:n,preview:a,placeholders:o,canResubmit:i,resetSurvey:r,navigateToStart:l,isMobile:p,allowMultipleSubmission:u,pivot:d,answers:b,questions:M,rangeToRender:z,translationVariables:m})=>{const{redirectUrl:h,redirectDelay:f,show_custom_button:O,show_review_links:A,show_social_links:v,image_url:g}=n?.type_info?.meta??{},[y,q]=s(f??10),[W,w]=t.useState(!1);return c((()=>{if(!a&&h){const e=setInterval((()=>q((e=>e>1?e-1:("undefined"!=typeof window&&(window.location.href=h??""),0)))),1e3);return()=>{clearInterval(e),w(!1)}}return()=>{w(!1)}}),[]),t.createElement("div",{className:"question-container ss-question-container thankyou"},g&&t.createElement("img",{className:"thankyou-logo-img ss-thankyou-logo",src:g,alt:"thankyou_logo"}),t.createElement(t.Fragment,null,xe(n)),t.createElement("div",{className:"text ss-thankyou-message",dangerouslySetInnerHTML:{__html:Ee({questionText:n.text,placeholders:o,npsRating:Te({theme:"nps",answers:b,questions:M})??"",npsRatingLabel:Se({theme:"nps",answers:b,questions:M}),csatRating:Te({theme:"csat",answers:b,questions:M})??"",csatRatingLabel:Se({theme:"csat",answers:b,questions:M}),cesRating:Te({theme:"ces",answers:b,questions:M})??"",cesRatingLabel:Se({theme:"ces",answers:b,questions:M}),preference:d?.question.type_info?.scale_properties?.labels?.preference,isPreview:a})}}),(i||u)&&t.createElement("div",{className:("wrap-up-actions "+(p?"mobile":"")).trim()},i&&t.createElement("button",{className:"action-button",tabIndex:0,disabled:W,onClick:()=>{w(!0),l()},"aria-label":m?.edit_response||"Edit your response"},t.createElement(Ge,{name:"edit"}),m?.edit_response||"Edit your response"),u&&t.createElement("button",{className:"action-button",tabIndex:0,disabled:W,onClick:()=>{w(!0),r()},"aria-label":m?.another_response||"Submit another response"},t.createElement(Ge,{name:"reload"}),m?.another_response||"Submit another response")),h&&t.createElement("div",{className:"redirection-container"},t.createElement("div",{className:"redirection-text"},$e(y,m?.redirect_msg),t.createElement("br",null)),t.createElement("a",{className:"link",href:h},h)),(O||A||v)&&t.createElement(h$,{show_custom_button:O,show_review_links:A,show_social_links:v,surveyServAssetUrl:e}))},g4=({activeIndexOfRenderedStatement:e,navigateToPreviousBlock:n,canDisplayDisableButtonParams:a,navigateToNextBlock:o,translationVariables:i,setAnimationInProgress:r,animationInProgress:c,question:s})=>t.createElement("div",{className:"freemium-survey-step-navigation ss-navigation-buttons","data-navigation-element":"1"},t.createElement("button",{disabled:c||JP("navigation-prev",a),className:"navigation-button ss-navigation-button",onClick:()=>{r(!0),setTimeout((()=>{r(!1)}),se),n()},title:s.name&&(e?.[s.name]??0)>0?i?.prev_statement||"go to previous statement":i?.prev_question||"go to previous question"},t.createElement(Ge,{name:"arrow-previous"})),t.createElement("button",{className:"navigation-button ss-navigation-button",disabled:c||JP("navigation-next",a),title:i?.next_question||"Go to next question",onClick:()=>{r(!0),setTimeout((()=>{r(!1)}),se),o()}},t.createElement(Ge,{name:"arrow-next"}))),y4=e=>{const{initialStatementHasAnswer:n,answers:a,renderedBlocks:o,blocks:i,activeIndexOfBlocks:r,activeIndexOfRenderedStatement:c={},activeIndexOfRenderedBlocks:l,saveFormValues:p,onSubmitHandler:u,skipBlock:d,skipStatement:b,survey:M,navigateToNextBlock:z,navigateToPreviousBlock:m,isInitialTransition:h,initialPivotAnswer:f,translationVariables:O,navigateToNextStatement:A,canDisplayDisableButtonParams:v,formQuestionErrors:g,dateQuestionErrors:y,textboxQuestionErrors:q,contactFormErrors:W,questions:w,pages:L,buttonRef:R,isReverseAnimation:C,isSubmitting:x}=e,[k,E]=s(!1),{question:T}=o[l],S={...v,isSubmitting:x},N=T?.type_info?.meta?.display_format,P=SP({blocks:i,activeIndexOfBlocks:r,renderedBlocks:o,activeIndexOfRenderedBlocks:l,questions:w});return t.createElement(t.Fragment,null,(GP("message",S)||GP("consent",S))&&t.createElement(DE,{exitBeforeEnter:!0},t.createElement(PE.div,{key:T.name??"",id:`consent-buttons-${T.name??""}`,className:"question-consent-buttons ss-consent-action-buttons",initial:{opacity:0,x:Re(e.language,C)},animate:{opacity:1,x:0},exit:{opacity:0,x:Ce(e.language,C)},transition:{duration:.2}},GP("consent",S)&&"BUTTON"===N&&fe.map((e=>t.createElement(et,{key:l+String(e.recordAs),onClick:()=>{E(!0),setTimeout((()=>{E(!1)}),se),p(o[l],e.recordAs,!0)},disabled:k||JP("consent",S),variant:qe(a.formValues?.[T.name])||a.formValues?.[T.name]===e.recordAs?"primary":"secondary",className:("consent-button ss-action-consent-button "+(a.formValues?.[T.name]===e.recordAs?"selected":"")).trim()},T?.type_info?.scale_properties?.labels?.values?.[e.id]||e.defaultValue))),GP("message",S)&&t.createElement(et,{onClick:()=>{E(!0),setTimeout((()=>{E(!1)}),se),P?u("COMPLETE"):d()},disabled:k||JP("message",S),className:"message-button ss-action-message-button"},T?.type_info?.scale_properties?.labels?.values?.[0]||"Begin"))),(GP("navigation",S)||GP("next",S)||GP("next-statement",S)||GP("submit",S)||GP("skip",S)||GP("skip-statement",S))&&t.createElement("div",{className:"question-footer ss-question-footer-container"},GP("navigation",S)?t.createElement(g4,{animationInProgress:k,setAnimationInProgress:E,answers:a,canDisplayDisableButtonParams:S,activeIndexOfBlocks:r,activeIndexOfRenderedBlocks:l,renderedBlocks:o,initialStatementHasAnswer:n,blocks:i,activeIndexOfRenderedStatement:c,navigateToNextBlock:z,navigateToPreviousBlock:m,translationVariables:O,pages:L,question:T}):t.createElement("div",null),t.createElement("div",{className:"action-buttons ss-action-buttons"},GP("skip",S)&&t.createElement(et,{className:"skip-button ss-action-skip-button",onClick:()=>{E(!0),setTimeout((()=>{E(!1)}),se),d()},variant:"secondary","aria-label":"skip question",disabled:k||x},e?.survey?.meta?.action_button?.skip||O?.actionButtonText?.skip||O?.skip||"Skip"),GP("skip-statement",S)&&t.createElement(et,{className:"skip-button ss-action-skip-button",onClick:()=>{E(!0),setTimeout((()=>{E(!1)}),se),b()},"aria-label":"skip statement",variant:"secondary",disabled:k||x},e?.survey?.meta?.action_button?.skip||O?.actionButtonText?.skip||O?.skip||"Skip"),GP("next",S)&&t.createElement(et,{ref:R,onClick:()=>{E(!0),setTimeout((()=>{E(!1)}),se),0!==l||!h||"RANGE"!==T.type_info?.question_type&&"BOOLEAN"!==T.type_info?.question_type||T.type_info?.question_comment||void 0===f?p(o[l],"CHECKBOX"===T?.type_info?.meta?.display_format&&"CONSENT"===T?.type_info?.question_type?a.formValues[T.name]??!1:a.formValues[T.name],!0):p(o[l],f,!0)},disabled:k||JP("next",S),className:"next-button ss-action-next-button"},e?.survey?.meta?.action_button?.next||O?.actionButtonText?.next||O?.next||"Next"),GP("next-statement",S)&&t.createElement(et,{ref:R,onClick:()=>{E(!0),setTimeout((()=>{E(!1)}),se),A?.(T.name)},disabled:k||!!JP("next-statement",S),className:"next-button ss-action-next-button"},e?.survey?.meta?.action_button?.next||O?.actionButtonText?.next||O?.next||"Next"),GP("submit",S)&&t.createElement("div",{className:"submit ss-action-submit-button"},t.createElement(et,{ref:R,disabled:k||JP("submit",S),onClick:()=>{we(y?.[T.name])&&we(g?.[T.name])&&we(q?.[T.name])&&we(W?.[T.name])&&(E(!0),setTimeout((()=>{E(!1)}),se),u("COMPLETE"))}},M?.meta?.action_button?.submit||O?.actionButtonText?.submit||O?.submit_survey||"Submit")))))},q4=e=>{const{blocks:n,pages:a,activePage:i,renderedBlocks:l,activeBlock:p,activeIndexOfBlocks:u,activeIndexOfRenderedBlocks:d,isSurveyCompleted:b,isReverseAnimation:M,saveFormValues:z,saveOthersValue:m,skipBlock:h,skipStatement:f,onSubmitHandler:O,navigateToNextBlock:A,navigateToPreviousBlock:v,answers:g,questions:y,pivot:q,isInitialTransition:W,resetSurvey:w,activeIndexOfRenderedStatement:L,navigateToNextStatement:R,navigateToPreviousStatement:C,navigateToStart:x,translationVariables:k,initialStatementHasAnswer:E,dateQuestionErrors:T,formQuestionErrors:S,textboxQuestionErrors:N,contactFormErrors:P,fileUploadErrors:$,setErrors:_,expanded:B,setExpanded:H,isQuestionBgDark:D,isSubmitting:I}=d$(e);Ie("Card",{...e,answers:g,activePage:i,activeBlock:p,renderedBlocks:l,activeIndexOfBlocks:u,activeIndexOfRenderedBlocks:d,activeIndexOfRenderedStatement:L});const V=r(null),X=we(g.formValues)&&e.survey.prompt_settings?.is_enabled&&e.preview,[j,F]=s(X),U=t.useMemo((()=>ke(q?.question)),[q?.question]),G=o((()=>n.filter((({name:e},t,n)=>!BP({nextBlockName:e||"",blocks:n,questions:y}))).length),[n,y]);c((()=>{p&&e.onBlockChange?.(p,i)}),[p,e]),c((()=>{e.survey.theme&&Ne(e.survey.theme,e.surveyServAssetUrl??"")}),[e.survey.theme,e.surveyServAssetUrl]),c((()=>{e.getSurveyProgress?.({totalBlocks:G,isSurveyCompleted:b,noOfAnswers:u})}),[G,b,u]);const Y={answers:g,blocks:n,blockIndex:d,activeIndexOfBlocks:u,initialStatementHasAnswer:E,activeIndexOfRenderedBlocks:d,activeIndexOfRenderedStatement:L,renderedBlocks:l,isMobile:!!e.isMobile,surveyStyle:e.surveyStyle,isWidget:!!e.isWidget,initialPivotAnswer:e.initialPivotAnswer,isInitialTransition:W,questions:y,pages:a,activeIndexOfSet:0,branchSeparatePage:!1,pivot:q};return p&&p.question?t.createElement("div",{className:`freemium-survey-components card-survey-style ${Le(e.language||"en")?"freemium-survey-rtl":"freemium-survey-ltr"} ${e.isMobile?"mobile-preview":""}`.trim(),id:"freemium-survey"},t.createElement("div",{className:("question-holder "+(j?"prompt":"")).trim()},!b&&!j&&!e.isWidget&&a.length>0&&i?.page_id&&t.createElement(b$,{expanded:B,id:i.page_id,setExpanded:H,activePage:i,translationVariables:k}),t.createElement("div",{className:"questions ss-questions"},b?t.createElement(v4,{surveyServAssetUrl:e.surveyServAssetUrl??"",thankYouQuestion:NP({pivotQn:q?.question,pivotQnAnswer:q?.answer,block:HP({activeBlock:p,blocks:e.survey.blocks?.filter((e=>!e.is_deleted)),answers:g,questions:y,activeIndexOfBlocks:u,renderedBlocks:l,contactData:e.contactData,surveyLayout:"card",pages:a}),questions:y}),canResubmit:e.canResubmit,allowMultipleSubmission:e.allowMultipleSubmission,navigateToStart:()=>{e.handleAction?e.handleAction("EDIT_RESPONSE",x):x()},resetSurvey:()=>{e.handleAction?e.handleAction("RE_SUBMIT",w):w()},preview:!!e.preview,placeholders:e.placeholders,isMobile:e.isMobile,pivot:q,rangeToRender:U,translationVariables:k,answers:g}):t.createElement(t.Fragment,null,!j&&e.isWidget&&a.length>0&&i?.page_id&&t.createElement(b$,{expanded:B,id:i.page_id,setExpanded:H,activePage:i,translationVariables:k}),t.createElement(DE,{exitBeforeEnter:!0},t.createElement(PE.div,{id:`${p.question.name}`,className:"question-container ss-question-container","data-test-question-name":p.question.name,key:`${p.question.name}`,initial:{opacity:0,x:Re(e.language,M)},animate:{opacity:1,x:0},exit:{opacity:0,x:Ce(e.language,M)},transition:{duration:.2}},j&&e.survey.prompt_settings?t.createElement(z$,{config:e.survey.prompt_settings,onSelect:t=>{e.onAnsweringPrompt?.(t),1===t&&F(!1)},placeholders:e.placeholders,isPreview:!!e.preview}):t.createElement(t.Fragment,null,t.createElement("div",{className:("question-text ss-question-text "+(p.required?"required":"")).trim(),dangerouslySetInnerHTML:{__html:Ee({questionText:p?.question.text,placeholders:e.placeholders,npsRating:Te({theme:"nps",answers:g,questions:y})??"",npsRatingLabel:Se({theme:"nps",answers:g,questions:y}),csatRating:Te({theme:"csat",answers:g,questions:y})??"",csatRatingLabel:Se({theme:"csat",answers:g,questions:y}),cesRating:Te({theme:"ces",answers:g,questions:y})??"",cesRatingLabel:Se({theme:"ces",answers:g,questions:y}),preference:q?.question.type_info?.scale_properties?.labels?.preference,isPreview:!!e.preview})},"aria-label":`question-${d}`,role:"heading","aria-level":1}),t.createElement(A4,{setFocus:!0,onKeyDown:e=>{"Enter"===e.key&&V.current&&V.current.click()},isReverseAnimation:M,preview:!!e.preview,surveyServAssetUrl:e.surveyServAssetUrl,setErrors:_,onFileUpload:e.onFileUpload,language:e.language||"en",surveyStyle:e.surveyStyle,surveyLanguage:e.survey.language,block:p,question:p.question,isFinalQn:SP({blocks:n,activeIndexOfBlocks:u,renderedBlocks:l,activeIndexOfRenderedBlocks:d,questions:y}),formValues:g.formValues,othersMeta:g.others,autoFocusDelay:"standard"===e.surveyStyle?350:0,activeIndexOfRenderedStatement:L,saveOthersValue:m,onChangeHandler:(e,t)=>{z(p,e,t)},isMobile:!!e.isMobile,initialPivotAnswer:e.initialPivotAnswer,initialQuestionAnswer:e.initialQuestionAnswer,isInitialTransition:W,formQuestionErrors:S,dateQuestionErrors:T,textboxQuestionErrors:N,fileUploadErrors:$,contactFormErrors:P,translationVariables:k,isQuestionBgDark:D})))),!j&&t.createElement(y4,{isWidget:!1,language:e.language||"en",isReverseAnimation:M,surveyStyle:e.surveyStyle,canDisplayDisableButtonParams:Y,answers:g,renderedBlocks:l,blocks:n,pages:a,activeIndexOfRenderedStatement:L,buttonRef:V,survey:e.survey,initialStatementHasAnswer:E,navigateToNextStatement:R,navigateToPreviousStatement:C,activeIndexOfRenderedBlocks:d,activeIndexOfBlocks:u,saveFormValues:z,skipBlock:h,skipStatement:f,onSubmitHandler:O,navigateToPreviousBlock:v,navigateToNextBlock:A,isInitialTransition:W,initialPivotAnswer:e.initialPivotAnswer,isMobile:!!e.isMobile,translationVariables:k,formQuestionErrors:S,dateQuestionErrors:T,textboxQuestionErrors:N,fileUploadErrors:$,contactFormErrors:P,questions:y,isSubmitting:I})))),!e.footerProps?.hideFooter&&(e?.footerProps?.languageDDComponent||e?.footerProps?.showFWBranding||e.footerProps?.footerContent)?t.createElement(Ya,{...e.footerProps,surveyStyle:e.surveyStyle,bgColor:e.survey.theme?.palette?.footer_background??e.survey.theme?.palette?.survey_background??m$}):null):null},W4=e=>{const n=!!e.survey.meta?.branch_separate_page,a=e.survey.question_details?.questions||[],i=e.contactData||{},l=e.translationVariables||{},p=r({}),[u,d]=s(e.survey?.blocks?.filter((e=>"TY"!==e.name&&!e.is_deleted))),[b,M]=s({formQuestionErrors:{},textboxQuestionErrors:{},fileUploadErrors:{},contactFormErrors:{},dateQuestionErrors:{}}),[z,m]=s(!1),[h,f]=s(0),[O,A]=s(e.survey.pages??[]),[v,g]=s(O?.[0]),[y,q]=s(!1),W=o((()=>a$({pages:O,blocks:u,questions:a,initialPivotAnswer:e.initialPivotAnswer,responses:e.answers,answerStatus:e.answerStatus||"PARTIAL",branchSeparatePage:n,surveyLayout:"standard",contactData:i})),[u,a,e.answers]),[w,L]=s(W.renderedBlocks),[R,C]=s(W.activeIndexOfRenderedBlocks),[x,k]=s(0),[E,T]=s(W.activeIndexOfRenderedStatement),S=r(W.pivot),N=r(W.isInitialTransition),[P,$]=s(""),[_,B]=s(W.answers),H=r(((W.isConsideredCompleted||"PARTIAL"===e.answerStatus)&&e.canResubmit)??!1),[D,I]=s(!1),V=w[R],X=t.useMemo((()=>w.length>0?u?.findIndex((e=>e.name===w[R]?.name)):0),[R]),j=o((()=>{const t=e.survey.theme?.palette?.question_background;return!!t&&Ve(t)}),[e.survey.theme?.palette?.question_background]);c((()=>{e.survey.updated_at!==P&&(Ie("useEffect",{updated_at:e.survey.updated_at,props:e}),A(e.survey.pages??[]),d(e.survey.blocks?.filter((e=>"TY"!==e.name&&!e.is_deleted))),g(e.survey.pages?.[0]),$(e.survey.updated_at??""))}),[e.survey.updated_at]),c((()=>{Ie("useEffect",{renderedBlocks:w,pages:O,activeIndexOfRenderedBlocks:R,props:e});const t=w?.[R]?.page_id,a=O.find((e=>e.page_id===t));O.length>0&&t&&a?.page_id&&g(a),void 0!==w?.[R]?.orderOfSet&&n&&k(w?.[R]?.orderOfSet)}),[w,O,R]),c((()=>{Ie("useEffect",{blocks:u,initialPivotAnswer:e.initialPivotAnswer,props:e});let t={..._};if(W.isConsideredCompleted&&N.current&&e.canResubmit)return;const{others_meta:o,...r}=e.answers||{};S.current={...S.current,question:kP({questions:a,blocks:u})};const c=a.find((e=>e.name===u?.[0]?.question_name||e.name===u?.[0]?.question_names?.[0]))??S.current.question;if(we(r)||void 0===e.initialPivotAnswer||r[c.name]===e.initialPivotAnswer||(t={..._,formValues:{..._.formValues,[c.name]:e.initialPivotAnswer},moveToNextPage:!0}),void 0!==e.initialPivotAnswer){const n=EP(S.current.question,e.initialPivotAnswer);S.current={...S.current,answer:"BOOLEAN"===c?.type_info?.question_type||"RESOLUTION"===c?.type_info?.question_type?Boolean(n):n},t={..._,formValues:{..._.formValues,[c.name]:S.current.answer},moveToNextPage:!1}}else void 0!==e.initialQuestionAnswer&&(t={..._,formValues:{..._.formValues,[c.name]:e.initialQuestionAnswer},moveToNextPage:!1});B(t);const s=NP({pivotQn:S.current.question,pivotQnAnswer:S.current.answer,block:u[0],questions:a}),l=u?.find((e=>e.question_name===s?.name)),d="NEXT"===l?.nav_option,b=(s?.dependent_blocks?.filter((e=>"ALL"!==e.condition_type)).length??0)>0,M=!d||b&&!s?.type_info?.pivot_question?[]:t$({activeBlock:{...u[0],question:s},blocks:u,questions:a,answers:t,pages:O,renderedBlocks:w,contactData:i,surveyLayout:"standard",initialTransition:!0,isEditResponse:H.current,branchSeparatePage:n}),z=[{...u[0],question:s},...M];if(L(n?Xe(z,p):z),(e=>{if(null==e||0===Object.keys(e).length)return!0;const t=Object.keys(e).filter((e=>""!==e&&!qe(e)&&"others_meta"!==e));return t.every((t=>!e[t]))&&(!e.others_meta||0===Object.keys(e.others_meta).length)})({others_meta:{},...t.formValues})||N.current)C(u.findIndex((e=>z[0].name===e.name))),k(0);else{const e=z?.[z.length-1];C(z.findIndex((t=>t.name===e?.name))),n&&k(e?.orderOfSet!==x?e?.orderOfSet:0)}T({})}),[u,e.initialPivotAnswer,h]);c((()=>{if(Ie("useEffect",{answers:_,blocks:u,props:e}),!(W.isConsideredCompleted&&N.current&&e.canResubmit)&&(!we(_.formValues)||_.moveToNextPage)&&u&&F(V,_.commitDirtyValue))if(UP({blocks:u,activeIndexOfBlocks:X,renderedBlocks:w,activeIndexOfRenderedBlocks:R,answers:_,questions:a,activePage:v,pages:O,surveyLayout:"standard"})){if(void 0!==e.initialPivotAnswer&&1===w.length&&N.current&&!_.commitDirtyValue);else if(_.commitDirtyValue){const t=XP({renderedBlocks:w,activeBlock:V,blocks:u,activeIndexOfBlocks:X,answers:_,questions:a,contactData:i,pages:O,surveyLayout:"standard",isDisplayBlock:!0});if(t!==1/0)N.current||!V.question.type_info?.question_type||V.question.type_info?.question_comment||["FORM_FIELD","MULTI_SELECT","RANK_ORDER"].includes(V.question.type_info?.question_type)?U():(e=>{e!==1/0&&setTimeout((()=>{const t=NP({pivotQn:S.current?.question,pivotQnAnswer:S.current?.answer,block:u?.[e],questions:a});if(t?.name){const e=document?.querySelector(`.question-container.standard-card-${t.name}`),n=document?.querySelector(`.question-container.standard-card-${t.name} input`),a=document?.querySelector(`.question-container.standard-card-${t.name} textarea`);e?.scrollIntoView({behavior:"smooth",block:"center",inline:"start"}),setTimeout((()=>{n?.focus(),a?.focus()}),le)}U()}),0)})(t),(!_.moveToNextPage&&!n&&t&&t>0&&u[t-1]?.page_id===u[t]?.page_id||_.moveToNextPage)&&((e,t)=>{if(e===1/0)return;const o=u?.[e];let r=S.current?.question;o?.display_logic?.some((e=>"BASED_ON_RATING_GROUP"===e.logic_type))&&(r=kP({questions:a,blocks:u,displayLogic:o?.display_logic}));const c=NP({pivotQn:r??S.current?.question,pivotQnAnswer:_?.formValues[r?.name]??S.current?.answer,block:o,questions:a}),s=e$({renderedBlocks:w,activeIndexOfRenderedBlocks:R}),l=u?.[e],d=t$({activeBlock:{...l,question:c},answers:_,blocks:u,questions:a,pages:O,renderedBlocks:w,contactData:i,surveyLayout:"standard",isEditResponse:H.current,branchSeparatePage:n}),b=[...s,...c?.name?[{...l,question:c}]:[],...d];T((e=>{const t={...e};return b.forEach((e=>{"MATRIX_RATING_SCALE"===e.question.type_info?.question_type&&(t[e.question.name]=0)})),t}));const M=n?Xe(b,p):b;L(M),t||C(s.length)})(t,!_.moveToNextPage&&!n);else{GP("submit",{answers:_,blocks:u,blockIndex:0,activeIndexOfBlocks:X,initialStatementHasAnswer:Y,activeIndexOfRenderedBlocks:R,activeIndexOfRenderedStatement:E,renderedBlocks:w,activePage:v,isMobile:!!e.isMobile,surveyStyle:e.surveyStyle,isWidget:!!e.isWidget,initialPivotAnswer:e.initialPivotAnswer,isInitialTransition:N.current,questions:a,pages:O,contactData:e.contactData,activeIndexOfSet:x,branchSeparatePage:n,isSubmitting:y})||U("COMPLETE")}}}else("MATRIX_RATING_SCALE"===V?.question?.type_info?.question_type||_.commitDirtyValue)&&U()}),[_,u]);const F=(e,t)=>{if(e?.question_name)switch(e.question?.type_info?.question_type){case"DATE_TIME":return!t||r$({answer:_.formValues?.[e.question_name]||"",errorSetter:M,questionName:e.question_name,errors:b,translationVariables:l});case"FORM_FIELD":return i$({fields:e.question?.type_info?.form_fields?.fields,answers:_.formValues?.[e.question_name]||{},errorSetter:M,questionName:e.question_name,errors:b,translationVariables:l});case"TEXT":return c$({type:e.question?.type_info?.text_field?.text_type,answer:_.formValues?.[e.question_name]||"",errorSetter:M,questionName:e.question_name,errors:b,translationVariables:l});case"CONTACT_FORM":return s$({fields:e.question?.type_info?.contact_form?.fields,answers:_.formValues?.[e.question_name]||{},errorSetter:M,questionName:e.question_name,errors:b,translationVariables:l});case"FILE":return l$({errors:b.fileUploadErrors})||!e.required}return!0},U=(t="PARTIAL")=>{let n=()=>{},o=0;if(w.some(((e,t)=>(o=t,!F(e,!0)))))return void C(o);let r={..._.formValues};if("COMPLETE"===t){q(!0),n=()=>{q(!1),I(!0),H.current=!1};r=p$({pages:O,answers:{..._,formValues:r},blocks:u,questions:a,contactData:i,surveyLayout:"standard"})}e.onSubmit({...r,others_meta:_.others},n,t,H.current?"EDIT":"CREATE")},G=e=>{T((t=>({...t,[e]:(qe(t[e])?0:t[e])+1})))},Y=t.useMemo((()=>{if("MATRIX_RATING_SCALE"!==V?.question?.type_info?.question_type)return!1;const e=V?.question?.type_info?.matrix_properties?.statements||[],t=e?.[E?.[V?.question.name]]??0,n=(_.formValues[V?.question.name]||[]).find((e=>e.statement_id===t?.id));return(n?.rating_labels||[]).length>0}),[E,R]),Z=()=>{const e=O.findIndex((e=>e.page_id===v?.page_id));let t=1,n=O?.[e+t];for(;!w.map((e=>e.page_id)).includes(n?.page_id)&&e+t<O.length;)n=O?.[e+ ++t];const a=w.find((e=>e.page_id===n?.page_id));n?.page_id&&g(n),"number"==typeof a?.orderOfSet&&k(a.orderOfSet);const o=w.findIndex((e=>e.page_id===n?.page_id));-1!==o&&C(o)},K=()=>{const e=O.findIndex((e=>e.page_id===v?.page_id));let t=1,n=O?.[e-t];for(;e-t>=0&&(!n||!w.some((e=>e.page_id===n.page_id)));)t++,n=O[e-t];if(!n)return;const a=w.find((e=>e.page_id===n.page_id));n.page_id&&g(n),"number"==typeof a?.orderOfSet&&k(a.orderOfSet);const o=w.findIndex((e=>e.name===a?.name));-1!==o&&C(o)};return{blocks:u,pages:O,navigateToNextSet:()=>{const e=w.find((e=>e.orderOfSet===x+1));if(e){n&&void 0!==e?.orderOfSet&&k(e?.orderOfSet);const t=O.find((t=>t.page_id===e?.page_id));t?.page_id&&g(t),B((e=>({...e,moveToNextPage:!1})))}else Z()},navigateToPreviousSet:()=>{const e=w.find((e=>e.orderOfSet===x-1));if(!e)return void K();n&&"number"==typeof e.orderOfSet&&k(e.orderOfSet);const t=O.find((t=>t.page_id===e.page_id));t?.page_id&&g(t);const a=w.findIndex((t=>t.name===e.name));-1!==a&&C(a)},activePage:v,questions:a,renderedBlocks:w,initialStatementHasAnswer:Y,activeBlock:V,activeIndexOfBlocks:X,activeIndexOfRenderedBlocks:R,activeIndexOfRenderedStatement:E,navigateToNextStatement:G,navigateToPreviousStatement:e=>{T((t=>({...t,[e]:(qe(t[e])?0:t[e])-1})))},isInitialTransition:N.current,isSurveyCompleted:D,pivot:S.current,answers:_,translationVariables:l,...b,setErrors:M,saveFormValues:(e,t,o=!1,r=R)=>{if(y)return;N.current=!1,e.question.name===S.current?.question.name&&(S.current={...S.current,answer:"BOOLEAN"===S.current?.question?.type_info?.question_type?Boolean(t):t}),r!==R&&C(r);const c={..._,formValues:{..._.formValues,[e.question.name]:"BOOLEAN"===e.question?.type_info?.question_type||"RESOLUTION"===e.question?.type_info?.question_type?Boolean(t):t},commitDirtyValue:o,moveToNextPage:!1};n$((({renderedBlocks:e,activeIndexOfRenderedBlocks:t})=>e$({renderedBlocks:e,activeIndexOfRenderedBlocks:t}).map((({question:e})=>e)))({renderedBlocks:w,activeIndexOfRenderedBlocks:r}),c),H.current&&(e.category??[]).length>0&&(e.category?.forEach((e=>{e.question_name&&(c.formValues[e.question_name]=null)})),c.formValues[e.question.name]=t),B(c),(e.question?.dependent_blocks?.length??0)>0&&L((t=>{const o=t.slice(0,r+1),s=t$({activeBlock:e,blocks:u,questions:a,answers:c,pages:O,renderedBlocks:o,contactData:i,surveyLayout:"standard",isEditResponse:H.current,branchSeparatePage:n}),l=[...o,...s];return n?Xe(l,p):l}));const s=w[r];"SINGLE_ANSWER"===s.question.type_info?.matrix_properties?.type&&(E?.[s.question.name]??0)<(s.question?.type_info?.matrix_properties?.statements||[]).length-1&&setTimeout((()=>{G?.(s.question.name)}),0)},saveOthersValue:(e,t,n=R)=>{if(n!==R&&C(n),null===t){const t={..._.others};delete t[e],B({..._,commitDirtyValue:!1,others:t,moveToNextPage:!1})}else B({..._,commitDirtyValue:!1,others:{..._.others,[e]:t},moveToNextPage:!1})},clearRadioSelection:e=>{C(e);const t=w[e].question;t.type_info?.pivot_question&&(S.current={question:t,answer:void 0}),delete _.formValues[t.name],delete _.others[t.name],"DATE_TIME"===t.type_info?.question_type&&b.dateQuestionErrors?.[t.name]&&M((e=>{const n={...e.dateQuestionErrors};return delete n[t.name],{...e,dateQuestionErrors:n}}));const o=(({renderedBlocks:e,answers:t})=>{const n=e.reduce(((e,n)=>(n?.question?.name&&void 0!==t.formValues[n.question.name]&&(e[n.question.name]=t.formValues[n.question.name]),e)),{});return{...t,formValues:n}})({renderedBlocks:w,answers:_}),r={...o,formValues:{...o.formValues},moveToNextPage:!1,commitDirtyValue:!1},c=t$({activeBlock:w[e],blocks:u,questions:a,answers:r,pages:O,renderedBlocks:w,contactData:i,surveyLayout:"standard",isEditResponse:H.current,branchSeparatePage:n});T((e=>{const t={...e};return c.forEach((e=>{"MATRIX_RATING_SCALE"===e.question.type_info?.question_type&&(t[e.question.name]=0)})),t}));const s=[...w.slice(0,e+1),...c];L(n?Xe(s,p):s),B(r)},onSubmitHandler:U,navigateToStart:()=>{H.current=!0,I(!1),T({}),C(0),n&&("number"==typeof w?.[0].orderOfSet?k(w?.[0].orderOfSet):k(0))},isValidQuestion:F,resetSurvey:()=>{I(!1),N.current=!0,f((e=>e+1)),B({formValues:{},others:{},commitDirtyValue:!1,moveToNextPage:!1}),u$(localStorage)},moveToNextPage:e=>{const t={};e&&O.length>0&&w.forEach((e=>{v?.page_id!==e.page_id||n&&x!==e.orderOfSet||"MESSAGE"===e.question.type_info?.question_type||(t[e.question.name]=null)})),we(_.formValues??{})&&O.length>0&&w.forEach((e=>{v?.page_id!==e.page_id||n&&x!==e.orderOfSet||"MESSAGE"!==e.question.type_info?.question_type||(t[e.question.name]=null)}));const a=w.filter((e=>v?.page_id===e?.page_id)),o=a[a.length-1],i=w.findIndex((e=>e.name===o?.name));R!==i&&C(i),setTimeout((()=>{B((e=>({...e,formValues:{...e.formValues,...t},commitDirtyValue:!0,moveToNextPage:!0})))}),0)},moveToNextSet:e=>{let t=0;if(w.some(((e,n)=>(t=n,!F(e,!0)))))return void C(t);const a={};w.forEach((t=>{v?.page_id!==t.page_id||n&&x!==t.orderOfSet||!e&&void 0!==_.formValues[t.question.name]||(a[t.question.name]=null)})),we(_.formValues??{})&&O.length>0&&w.forEach((e=>{v?.page_id!==e.page_id||n&&x!==e.orderOfSet||"MESSAGE"!==e.question.type_info?.question_type||(a[e.question.name]=null)}));const o=w.filter((e=>v?.page_id===e?.page_id&&(!n||x===e.orderOfSet))),i=o[o.length-1],r=w.findIndex((e=>e.name===i?.name));C(r),setTimeout((()=>{B((e=>({...e,formValues:{...e.formValues,...a},commitDirtyValue:!0,moveToNextPage:!0})))}),0)},setIsSubmitting:q,isSubmitting:y,expanded:z,setExpanded:m,activeIndexOfSet:x,setActiveRenderedBlockIndex:C,isQuestionBgDark:j}},w4=["next","next-statement","next-page","next-set","skip","skip-statement","skip-page","skip-set","submit","navigation","set-navigation","clear-selection","message","consent","navigation-prev","navigation-next","navigation-page-prev","navigation-page-next","previous-matrix-statement","next-matrix-statement","navigation-set-prev","navigation-set-next"],L4=({translationVariables:e,canDisplayDisableButtonParams:n,navigateToNextSet:a,navigateToPreviousSet:o})=>t.createElement("div",{className:"freemium-survey-step-navigation ss-navigation-buttons","data-navigation-element":"1"},t.createElement("button",{disabled:JP("navigation-set-prev",n),className:"navigation-button ss-navigation-button",onClick:o,title:e?.prev_question??"go to previous question"},t.createElement(Ge,{name:"arrow-previous"})),t.createElement("button",{className:"navigation-button ss-navigation-button",disabled:JP("navigation-set-next",n),title:e?.next_question||"Go to next question",onClick:a},t.createElement(Ge,{name:"arrow-next"}))),R4=({surveyServAssetUrl:e,thankYouQuestion:n,preview:a,placeholders:o,canResubmit:i,allowMultipleSubmission:r,navigateToStart:l,resetSurvey:p,isMobile:u,pivot:d,answers:b,questions:M,rangeToRender:z,translationVariables:m})=>{const{redirectUrl:h,redirectDelay:f,image_url:O,show_custom_button:A,show_review_links:v,show_social_links:g}=n?.type_info?.meta??{},[y,q]=s(f??10),[W,w]=t.useState(!1);return c((()=>{if(!a&&h){const e=setInterval((()=>q((e=>e>1?e-1:("undefined"!=typeof window&&(window.location.href=h??""),0)))),1e3);return()=>{clearInterval(e),w(!1)}}return()=>{w(!1)}}),[]),t.createElement("div",{className:"thankyou-container"},t.createElement("div",{className:"question-container ss-question-container thankyou"},O&&t.createElement("img",{className:"thankyou-logo-img ss-thankyou-logo",src:O,alt:"thankyou_logo"}),t.createElement(t.Fragment,null,xe(n)),t.createElement("div",{className:"text ss-thankyou-message",dangerouslySetInnerHTML:{__html:Ee({questionText:n.text,placeholders:o,npsRating:Te({theme:"nps",answers:b,questions:M})??"",npsRatingLabel:Se({theme:"nps",answers:b,questions:M}),csatRating:Te({theme:"csat",answers:b,questions:M})??"",csatRatingLabel:Se({theme:"csat",answers:b,questions:M}),cesRating:Te({theme:"ces",answers:b,questions:M})??"",cesRatingLabel:Se({theme:"ces",answers:b,questions:M}),preference:d?.question.type_info?.scale_properties?.labels?.preference,isPreview:a})}}),(i||r)&&t.createElement("div",{className:("wrap-up-actions "+(u?"mobile":"")).trim()},i&&t.createElement("button",{className:"action-button",tabIndex:0,disabled:W,onClick:()=>{w(!0),l()}},t.createElement(Ge,{name:"edit"}),m?.edit_response||"Edit your response"),r&&t.createElement("button",{className:"action-button",tabIndex:0,disabled:W,onClick:()=>{w(!0),p()}},t.createElement(Ge,{name:"reload"}),m?.another_response||"Submit another response")),h&&t.createElement(t.Fragment,null,t.createElement("div",{className:"redirection-text"},$e(y,m?.redirect_msg),t.createElement("br",null)),t.createElement("a",{className:"link",href:h},h)),t.createElement(h$,{show_custom_button:A,show_review_links:v,show_social_links:g,surveyServAssetUrl:e})))},C4=e=>{const{blockIndex:n,renderedBlocks:a,activeIndexOfRenderedBlocks:o,translationVariables:i,saveFormValues:r,answers:c,clearRadioSelection:s,canDisplayDisableButtonParams:l,navigateToNextStatement:p,navigateToPreviousStatement:u,isSubmitting:d,isMobile:b}=e,M={};w4.forEach((e=>{M[e]=!!GP(e,l)}));const z=a[n??o],{question:m}=z,h=m?.type_info?.meta?.display_format;return M?.consent||M?.["previous-matrix-statement"]||M?.["next-matrix-statement"]||M?.["clear-selection"]||M?.message?t.createElement("div",{className:"question-footer ss-question-footer-container"},t.createElement("div",null,(M?.["previous-matrix-statement"]||M?.["next-matrix-statement"])&&"MATRIX_RATING_SCALE"===m?.type_info?.question_type&&t.createElement("div",{className:"freemium-survey-step-navigation ss-navigation-buttons","data-navigation-element":"1"},t.createElement("button",{disabled:JP("previous-matrix-statement",l),className:"navigation-button ss-navigation-button",onClick:()=>{u(m.name)},title:i?.prev_question??"go to previous question"},t.createElement(Ge,{name:"arrow-previous"})),t.createElement("button",{className:"navigation-button ss-navigation-button",disabled:JP("next-matrix-statement",l),title:i?.next_question||"Go to next question",onClick:()=>{p(m.name)}},t.createElement(Ge,{name:"arrow-next"})))),t.createElement("div",{className:("action-buttons ss-action-buttons "+(M.consent?"question-consent-buttons ss-consent-action-buttons":"")).trim()},M?.["clear-selection"]&&t.createElement(et,{className:"sec-button",variant:"secondary",onClick:()=>s(n),disabled:d},e?.survey?.meta?.action_button?.clear_selection||i?.actionButtonText?.clear_selection||i?.clear_selection||"Clear selection"),b&&"MATRIX_RATING_SCALE"===m.type_info?.question_type&&"MULTIPLE_ANSWERS"===m?.type_info?.matrix_properties?.type&&M?.["next-matrix-statement"]&&t.createElement(et,{disabled:JP("next-matrix-statement",l),className:"primary-button",variant:"primary",onClick:()=>{p(m.name)}},e?.survey?.meta?.action_button?.next||i?.actionButtonText?.next||i?.next||"Next"),M?.consent&&"BUTTON"===h&&fe.map((e=>t.createElement(et,{key:o+String(e.recordAs),onClick:()=>{r(z,e.recordAs,!1,n)},disabled:JP("consent",l),variant:qe(c.formValues?.[m.name])||c.formValues?.[m.name]===e.recordAs?"primary":"secondary",className:("consent-button ss-action-consent-button "+(c.formValues?.[m.name]===e.recordAs?"selected":"")).trim()},m?.type_info?.scale_properties?.labels?.values?.[e.id]??e.defaultValue))))):null},x4=e=>{const{pages:n,activePage:a,navigateToNextSet:i,navigateToPreviousSet:l,isInitialTransition:p,blocks:u,renderedBlocks:d,activeBlock:b,activeIndexOfBlocks:M,activeIndexOfRenderedBlocks:z,isSurveyCompleted:m,translationVariables:h,saveFormValues:f,saveOthersValue:O,clearRadioSelection:A,onSubmitHandler:v,answers:g,questions:y,resetSurvey:q,initialStatementHasAnswer:W,navigateToStart:w,activeIndexOfRenderedStatement:L,navigateToNextStatement:R,navigateToPreviousStatement:C,pivot:x,formQuestionErrors:k,dateQuestionErrors:E,textboxQuestionErrors:T,contactFormErrors:S,fileUploadErrors:N,setErrors:P,isSubmitting:$,setIsSubmitting:_,moveToNextSet:B,expanded:H,setExpanded:D,activeIndexOfSet:I,isValidQuestion:V,setActiveRenderedBlockIndex:X,isQuestionBgDark:j}=W4(e);Ie("Standard",{...e,answers:g,activePage:a,activeBlock:b,renderedBlocks:d,activeIndexOfSet:I,activeIndexOfBlocks:M,activeIndexOfRenderedBlocks:z,activeIndexOfRenderedStatement:L});const F=!!e.survey.meta?.branch_separate_page,U=r(null),G=r({}),Y=r(null),Z=o((()=>ke(x?.question)),[x?.question]),K=o((()=>u.filter((({name:e},t,n)=>!BP({nextBlockName:e||"",blocks:n,questions:y}))).length),[u,y]),Q=we(g.formValues)&&e.survey.prompt_settings?.is_enabled&&e.preview,[J,ee]=s(Q),te=d.filter((e=>a?.page_id===e?.page_id));c((()=>{const t=Object.values(g.formValues).filter((e=>"string"==typeof e&&""!==e.trim()||"number"==typeof e||"boolean"==typeof e||Array.isArray(e)&&e.length>0||"object"==typeof e&&null!==e&&Object.keys(e).length>0)).length;e.getSurveyProgress?.({totalBlocks:K,isSurveyCompleted:m,noOfAnswers:m||t>K?K:t})}),[K,g,m]),c((()=>{e.survey.theme&&Ne(e.survey.theme,e.surveyServAssetUrl??"")}),[e.survey.theme,e.surveyServAssetUrl]),c((()=>{setTimeout((()=>{Y.current&&Object.keys(g.formValues).length&&Y.current?.scrollIntoView({inline:"start",block:"start",behavior:"smooth"})}),0),b&&e.onBlockChange?.(b,a)}),[a?.page_id]);const[ne,ae]=s(!1);if(!b||!b.question)return null;const{question:oe}=d[z],ie={answers:g,blocks:u,blockIndex:0,activeIndexOfBlocks:M,initialStatementHasAnswer:W,activeIndexOfRenderedBlocks:z,activeIndexOfRenderedStatement:L,renderedBlocks:d,activePage:a,isMobile:!!e.isMobile,surveyStyle:e.surveyStyle,isWidget:!!e.isWidget,initialPivotAnswer:e.initialPivotAnswer,isInitialTransition:p,questions:y,pages:n,contactData:e.contactData,activeIndexOfSet:I,branchSeparatePage:F,isSubmitting:$,secBtnTxt:e.secBtnTxt,isNavigatedBefore:ne,pivot:x},re={};w4.forEach((e=>{re[e]=!!GP(e,ie)}));const ce=d[d.length-1];return t.createElement("div",{className:`freemium-survey-components ${Le(e.language||"en")?"freemium-survey-rtl":"freemium-survey-ltr"} ${e.isMobile?"mobile-preview":""} standard-survey-style`,id:"freemium-survey",ref:Y},J&&e.survey.prompt_settings?t.createElement("div",{className:"questions ss-questions"},t.createElement("div",{className:"question-container ss-question-container"},t.createElement(z$,{config:e.survey.prompt_settings,onSelect:t=>{e.onAnsweringPrompt?.(t),1===t&&ee(!1)},placeholders:e.placeholders,isPreview:!!e.preview}))):t.createElement(t.Fragment,null,m?t.createElement(R4,{surveyServAssetUrl:e.surveyServAssetUrl??"",thankYouQuestion:NP({pivotQn:x?.question,pivotQnAnswer:x?.answer,block:HP({activeBlock:ce,blocks:e.survey.blocks?.filter((e=>!e.is_deleted)),answers:g,questions:y,activeIndexOfBlocks:u.findIndex((e=>e.name===ce.name)),renderedBlocks:d,contactData:e.contactData,surveyLayout:"standard",pages:n}),questions:y}),answers:g,preview:!!e.preview,placeholders:e.placeholders,pivot:{...x,question:x?.question||{name:""},answer:x?.answer},rangeToRender:Z,canResubmit:e.canResubmit,isMobile:e.isMobile,allowMultipleSubmission:e.allowMultipleSubmission,translationVariables:h,navigateToStart:()=>{e.handleAction?e.handleAction("EDIT_RESPONSE",(()=>{_(!1),w()})):(_(!1),w())},resetSurvey:()=>{e.handleAction?e.handleAction("RE_SUBMIT",(()=>{_(!1),q()})):(_(!1),q())}}):t.createElement(t.Fragment,null,n.length>0&&a?.page_id&&t.createElement(b$,{expanded:H,id:a.page_id,setExpanded:D,activePage:a,translationVariables:h}),t.createElement("div",{className:("questions "+(e?.secBtnTxt?"sec-btn":"")).trim()},d.map(((o,i)=>{if(n.length>0&&a?.page_id!==o?.page_id||e.survey.meta?.branch_separate_page&&o.orderOfSet!==I)return null;const r=te.findIndex((e=>e.name===o.name)),c=XP({renderedBlocks:d,activeBlock:b,blocks:u,activeIndexOfBlocks:M,answers:g,questions:y,contactData:e.contactData,pages:n,surveyLayout:"standard"});return t.createElement(PE.div,{id:o.question.name,key:o.question.name,ref:U,className:`question-container ss-question-container standard-card-${o.question.name}`,"data-test-question-name":b.question.name,initial:{opacity:0},animate:{opacity:1,x:0},exit:{opacity:0},transition:{duration:.2,delay:r?r/15:0},..."MULTI_SELECT"===b.question.type_info?.question_type&&c!==1/0&&-1!==c&&void 0!==g.formValues?.[o.question.name]&&G.current[o.question.name]!==g.formValues?.[o.question.name]?{onMouseLeave:()=>{f(o,g.formValues?.[o.question.name],!0,i),G.current[o.question.name]=g.formValues?.[o.question.name]}}:{}},t.createElement("div",{className:`question-text ss-question-text ${o.required?"required":""} ${0===i?"nps":""}`.trim(),dangerouslySetInnerHTML:{__html:Ee({questionText:o.question.text,placeholders:e.placeholders,npsRating:Te({theme:"nps",answers:g,questions:y})??"",npsRatingLabel:Se({theme:"nps",answers:g,questions:y}),csatRating:Te({theme:"csat",answers:g,questions:y})??"",csatRatingLabel:Se({theme:"csat",answers:g,questions:y}),cesRating:Te({theme:"ces",answers:g,questions:y})??"",cesRatingLabel:Se({theme:"ces",answers:g,questions:y}),preference:x?.question.type_info?.scale_properties?.labels?.preference,isPreview:!!e.preview})},"aria-label":`question-${i}`,role:"heading","aria-level":1}),t.createElement(A4,{surveyServAssetUrl:e.surveyServAssetUrl,fileUploadErrors:N,setErrors:P,onFileUpload:e.onFileUpload,block:o,preview:!!e.preview,surveyLanguage:e.survey.language,language:e.language||"en",question:o.question,surveyStyle:e.surveyStyle,isFinalQn:SP({blocks:u,activeIndexOfBlocks:M,renderedBlocks:d,activeIndexOfRenderedBlocks:z,questions:y}),formValues:g.formValues,othersMeta:g.others,isMobile:!!e.isMobile,autoFocusDelay:20,activeIndexOfRenderedStatement:L,saveOthersValue:(e,t)=>{O(e,t,i)},onChangeHandler:(e,t)=>{const n=o.question.type_info?.question_type;f(o,e,!!n&&["RANGE","DROPDOWN","BOOLEAN"].includes(n)||t,i)},initialPivotAnswer:e.initialPivotAnswer,initialQuestionAnswer:e.initialQuestionAnswer,formQuestionErrors:k,dateQuestionErrors:E,textboxQuestionErrors:T,contactFormErrors:S,translationVariables:h,isQuestionBgDark:j}),"MESSAGE"!==o.question.type_info?.question_type&&t.createElement(C4,{canDisplayDisableButtonParams:{...ie,blockIndex:i},language:e.language||"en",isWidget:!1,surveyStyle:e.surveyStyle,answers:g,renderedBlocks:d,blocks:u,pages:n,survey:e.survey,blockIndex:i,isInitialTransition:p,activeIndexOfRenderedBlocks:z,initialStatementHasAnswer:W,navigateToNextStatement:R,navigateToPreviousStatement:C,activeIndexOfRenderedStatement:L,activeIndexOfBlocks:M,saveFormValues:f,isMobile:!!e.isMobile,clearRadioSelection:A,initialPivotAnswer:e.initialPivotAnswer,translationVariables:h,formQuestionErrors:k,dateQuestionErrors:E,textboxQuestionErrors:T,contactFormErrors:S,fileUploadErrors:N,questions:y,isSubmitting:$}))}))),t.createElement("div",{className:"page-actions"},t.createElement("div",null,re["set-navigation"]&&t.createElement(L4,{answers:g,canDisplayDisableButtonParams:ie,activeIndexOfBlocks:M,pages:n,activeIndexOfRenderedBlocks:z,renderedBlocks:d,initialStatementHasAnswer:W,blocks:u,activeIndexOfRenderedStatement:L,translationVariables:h,navigateToPreviousSet:l,navigateToNextSet:i})),t.createElement("div",{className:"page-action-buttons ss-page-action-buttons"},e?.secBtnTxt&&t.createElement(et,{variant:"secondary",onClick:()=>{ae(!0),e?.handleSecondaryAction?.({answers:g.formValues,survey:e.survey})},"aria-label":"secondary-action",disabled:$},e.secBtnTxt),re["skip-set"]&&t.createElement(et,{variant:"secondary",onClick:()=>{ae(!0),B(!0)},"aria-label":"skip set",disabled:$},e?.survey?.meta?.action_button?.skip||h?.actionButtonText?.skip||h?.skip||"Skip"),re?.["next-set"]&&t.createElement(et,{onClick:()=>{B(),ae(!0)},disabled:!!JP("next-set",ie),className:"next-set"},e?.survey?.meta?.action_button?.next||h?.actionButtonText?.next||h?.next||"Next"),re.submit&&!re?.["next-set"]&&t.createElement(et,{disabled:!!JP("submit",ie),onClick:()=>{let e=0;d.some(((t,n)=>(e=n,!V(t,!0))))?X(e):we(E?.[oe.name])&&we(k?.[oe.name])&&we(T?.[oe.name])&&we(N?.[oe.name])&&we(S?.[oe.name])&&v("COMPLETE")}},e?.survey?.meta?.action_button?.submit||h?.actionButtonText?.submit||h?.submit_survey||"Submit"))))),!e.secBtnTxt&&!e.footerProps?.hideFooter&&(e?.footerProps?.languageDDComponent||e?.footerProps?.showFWBranding||e.footerProps?.footerContent)&&t.createElement(Ya,{...e.footerProps,surveyStyle:e.surveyStyle,bgColor:e.survey.theme?.palette?.footer_background??e.survey.theme?.palette?.survey_background??m$}))},k4=e=>t.createElement("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("g",{clipPath:"url(#clip0_8207_70478)"},t.createElement("rect",{width:"10",height:"10",fill:"white",fillOpacity:"0.01"}),t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.62499 3.19375C8.62499 3.4 8.79374 3.56875 8.99999 3.56875C9.20624 3.56875 9.37499 3.4 9.37499 3.19375V1C9.37499 0.79375 9.20624 0.625 8.99999 0.625H6.80624C6.59999 0.625 6.43124 0.79375 6.43124 1C6.43124 1.20625 6.59999 1.375 6.80624 1.375H8.09377L5.66876 3.80001C5.52501 3.95001 5.52501 4.18751 5.66876 4.33126C5.73751 4.40626 5.83751 4.44376 5.93126 4.44376V4.45001C6.02501 4.45001 6.11876 4.41251 6.19376 4.33751L8.62499 1.90628V3.19375ZM1 9.37501H1.00738H3.19375C3.4 9.37501 3.56875 9.20626 3.56875 9.00001C3.56875 8.79376 3.4 8.62501 3.19375 8.62501H1.90626L4.3375 6.19376C4.48125 6.04376 4.48125 5.80626 4.3375 5.66251C4.1875 5.51876 3.95 5.51876 3.80625 5.66251L1.375 8.09376V6.80626C1.375 6.60001 1.20625 6.43126 1 6.43126C0.79375 6.43126 0.625 6.60001 0.625 6.80626V9.00001C0.625 9.20626 0.79375 9.37501 1 9.37501Z",fill:"#264966"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_8207_70478"},t.createElement("rect",{width:"10",height:"10",fill:"white"})))),E4=e=>t.createElement("svg",{width:"8",height:"2",viewBox:"0 0 8 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("path",{d:"M7.3 1.4H0.7C0.313401 1.4 0 1.0866 0 0.699999C0 0.3134 0.313401 0 0.7 0H7.3C7.6866 0 8 0.3134 8 0.699999C8 1.0866 7.6866 1.4 7.3 1.4Z",fill:"#264966"})),T4=({surveyServAssetUrl:e,thankYouQuestion:n,placeholders:a,canResubmit:o,navigateToStart:i,resetSurvey:r,widgetStyle:s,allowMultipleSubmission:l,pivot:p,rangeToRender:u,answers:d,questions:b,translationVariables:M,isQuestionBgDark:z})=>{const{show_custom_button:m,show_review_links:h,show_social_links:f,image_url:O}=n?.type_info?.meta??{},[A,v]=t.useState(!1);return c((()=>()=>{v(!1)}),[]),t.createElement("div",{className:"question-container ss-question-container thankyou"},O&&t.createElement("img",{className:"thankyou-logo-img ss-thankyou-logo",src:O,alt:"thankyou_logo"}),t.createElement("div",{className:O?"heading":"heading thankyou-image"},t.createElement(t.Fragment,null,xe(n))),t.createElement("div",{className:O?"text ss-thankyou-message":"text ss-thankyou-message thankyou-image",dangerouslySetInnerHTML:{__html:Ee({questionText:n.text,placeholders:a,npsRating:Te({theme:"nps",answers:d,questions:b})??"",npsRatingLabel:Se({theme:"nps",answers:d,questions:b}),csatRating:Te({theme:"csat",answers:d,questions:b})??"",csatRatingLabel:Se({theme:"csat",answers:d,questions:b}),cesRating:Te({theme:"ces",answers:d,questions:b})??"",cesRatingLabel:Se({theme:"ces",answers:d,questions:b}),preference:p?.question.type_info?.scale_properties?.labels?.preference})}}),(o||l)&&t.createElement("div",{className:`wrap-up-actions ${O?"":"thank-you-image"} ${"compact"===s?"mobile":""}`.trim()},o&&t.createElement("button",{className:"action-button",tabIndex:0,disabled:A,onClick:()=>{v(!0),i()}},t.createElement(Ge,{name:"edit"}),M?.edit_response||"Edit your response"),l&&t.createElement("button",{className:"action-button",tabIndex:0,disabled:A,onClick:()=>{v(!0),r()}},t.createElement(Ge,{name:"reload"}),M?.another_response||"Submit another response")),t.createElement(h$,{show_custom_button:m,show_review_links:h,show_social_links:f,surveyServAssetUrl:e}))},S4=({translationVariables:e,activeIndexOfRenderedStatement:n,navigateToPreviousBlock:a,navigateToNextBlock:o,question:i,canDisplayDisableButtonParams:r,animationInProgress:c,setAnimationInProgress:s})=>t.createElement("div",{className:"freemium-survey-step-navigation ss-navigation-buttons","data-navigation-element":"1"},t.createElement("button",{disabled:c||!!JP("navigation-prev",r),className:"navigation-button ss-navigation-button",onClick:()=>{s(!0),setTimeout((()=>{s(!1)}),se),a()},title:i.name&&(n?.[i.name]??0)>0?e?.prev_statement||"go to previous statement":e?.prev_question||"go to previous question"},t.createElement(Ge,{name:"arrow-previous"})),t.createElement("button",{className:"navigation-button ss-navigation-button",disabled:c||!!JP("navigation-next",r),onClick:()=>{s(!0),setTimeout((()=>{s(!1)}),se),o()},title:e?.next_question||"go to next question"},t.createElement(Ge,{name:"arrow-next"}))),N4=e=>{const{widgetStyle:n,answers:a,initialStatementHasAnswer:o,renderedBlocks:i,blocks:r,activeIndexOfBlocks:c,navigateToNextStatement:l,activeIndexOfRenderedBlocks:p,translationVariables:u,saveFormValues:d,activeIndexOfRenderedStatement:b={},onSubmitHandler:M,skipBlock:z,skipStatement:m,navigateToNextBlock:h,navigateToPreviousBlock:f,formQuestionErrors:O,dateQuestionErrors:A,textboxQuestionErrors:v,fileUploadErrors:g,contactFormErrors:y,canDisplayDisableButtonParams:q,pages:W,setFooterElementRef:w,isSubmitting:L}=e,[R,C]=s(!1),{question:x}=i[p],k=x?.type_info?.question_type,E={...q,isSubmitting:L},T=(e=!1)=>{const n=e?[...fe].reverse():[...fe];return GP("consent",E)&&"BUTTON"===N&&n.map((e=>t.createElement(et,{key:p+String(e.id),onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),d(i[p],e.recordAs,!0)},disabled:R||JP("consent",E),variant:qe(a.formValues?.[x.name])||a.formValues?.[x.name]===e.recordAs?"primary":"secondary",className:("consent-button ss-action-consent-button "+(a.formValues?.[x.name]===e.recordAs?"selected":"")).trim()},x?.type_info?.scale_properties?.labels?.values?.[e.id]||e.defaultValue)))},S="compact"===n&&(GP("navigation",E)&&GP("skip",E)||"CONSENT"===k||"MESSAGE"===k),N=x?.type_info?.meta?.display_format;return t.createElement(t.Fragment,null,(GP("navigation",E)||GP("next",E)||GP("next-statement",E)||GP("consent",E)||GP("submit",E)||GP("skip",E)||GP("skip-statement",E)||GP("message",E))&&t.createElement("div",{className:"question-footer ss-question-footer-container",ref:e=>e?w?.(e):null},S?t.createElement("div",{className:"compact-footer-container"},GP("next",E)&&t.createElement(et,{onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),d(i[p],"CHECKBOX"===x?.type_info?.meta?.display_format&&"CONSENT"===x?.type_info?.question_type?a.formValues[x.name]??!1:a.formValues[x.name],!0)},disabled:R||!!JP("next",E),className:"next-button ss-action-next-button"},e?.survey?.meta?.action_button?.next||u?.next||"Next"),GP("message",E)&&t.createElement(et,{onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),z()},disabled:R||JP("message",E),className:"message-button ss-action-message-button"},x?.type_info?.scale_properties?.labels?.values?.[0]||"Begin"),GP("submit",E)&&t.createElement("div",{className:"submit ss-action-submit-button"},t.createElement(et,{disabled:R||!!JP("submit",E),onClick:()=>{we(A?.[x.name])&&we(O?.[x.name])&&we(v?.[x.name])&&we(g?.[x.name])&&we(y?.[x.name])&&(C(!0),setTimeout((()=>{C(!1)}),se),M("COMPLETE"))}},e?.survey?.meta?.action_button?.submit||u?.actionButtonText?.submit||u?.submit_survey||"Submit")),GP("next-statement",E)&&t.createElement(et,{onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),l?.(x.name)},disabled:R||!!JP("next-statement",E),className:"next-button ss-action-next-button"},e?.survey?.meta?.action_button?.next||u?.actionButtonText?.next||u?.next||"Next"),T(),t.createElement("div",{className:"compact-footer-layout"},t.createElement(S4,{animationInProgress:R,setAnimationInProgress:C,answers:a,canDisplayDisableButtonParams:E,pages:W,activeIndexOfBlocks:c,activeIndexOfRenderedBlocks:p,renderedBlocks:i,initialStatementHasAnswer:o,blocks:r,activeIndexOfRenderedStatement:b,question:x,translationVariables:u,navigateToNextBlock:h,navigateToPreviousBlock:f}),"MESSAGE"!==k&&!r[c].required&&t.createElement(et,{className:"skip-button ss-action-skip-button",onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),z()},variant:"secondary","aria-label":"skip question",disabled:R},e?.survey?.meta?.action_button?.skip||u?.actionButtonText?.skip||u?.skip||"Skip"))):t.createElement(t.Fragment,null,GP("navigation",E)?t.createElement(S4,{animationInProgress:R,setAnimationInProgress:C,answers:a,pages:W,canDisplayDisableButtonParams:E,activeIndexOfBlocks:c,activeIndexOfRenderedBlocks:p,activeIndexOfRenderedStatement:b,renderedBlocks:i,blocks:r,question:x,initialStatementHasAnswer:o,translationVariables:u,navigateToNextBlock:h,navigateToPreviousBlock:f}):t.createElement("div",null),t.createElement("div",{className:"action-buttons ss-action-buttons"},GP("skip",E)&&t.createElement(et,{className:"skip-button ss-action-skip-button",variant:"secondary",onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),z()},"aria-label":"skip question",disabled:R},e?.survey?.meta?.action_button?.skip||u?.actionButtonText?.skip||u?.skip||"Skip"),GP("skip-statement",E)&&t.createElement(et,{className:"skip-button ss-action-skip-button",variant:"secondary",onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),m()},"aria-label":"skip statement",disabled:R},e?.survey?.meta?.action_button?.skip||u?.actionButtonText?.skip||u?.skip||"Skip"),T(!0),GP("next",E)&&t.createElement(et,{onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),d(i[p],"CHECKBOX"===x?.type_info?.meta?.display_format&&"CONSENT"===x?.type_info?.question_type?a.formValues[x.name]??!1:a.formValues[x.name],!0)},disabled:R||!!JP("next",E),className:"next-button ss-action-next-button"},e?.survey?.meta?.action_button?.next||u?.actionButtonText?.next||u?.next||"Next"),GP("next-statement",E)&&t.createElement(et,{onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),l?.(x.name)},disabled:R||!!JP("next-statement",E),className:"next-button ss-action-next-button"},e?.survey?.meta?.action_button?.next||u?.actionButtonText?.next||u?.next||"Next"),GP("submit",E)&&t.createElement("div",{className:"submit ss-action-submit-button"},t.createElement(et,{disabled:R||!!JP("submit",E),onClick:()=>{we(A?.[x.name])&&we(O?.[x.name])&&we(v?.[x.name])&&we(g?.[x.name])&&we(y?.[x.name])&&(C(!0),setTimeout((()=>{C(!1)}),se),M("COMPLETE"))}},e?.survey?.meta?.action_button?.submit||u?.actionButtonText?.submit||u?.submit_survey||"Submit")),GP("message",E)&&t.createElement(et,{onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),z()},disabled:R||JP("message",E),className:"next-button ss-action-next-button"},x?.type_info?.scale_properties?.labels?.values?.[0]||"Begin")))))},P4=e=>{const{pages:n,activePage:a,blocks:o,renderedBlocks:i,activeBlock:l,activeIndexOfBlocks:p,activeIndexOfRenderedBlocks:u,isSurveyCompleted:d,isReverseAnimation:b,translationVariables:M,saveFormValues:z,saveOthersValue:m,skipBlock:h,skipStatement:f,initialStatementHasAnswer:O,onSubmitHandler:A,navigateToNextBlock:v,activeIndexOfRenderedStatement:g,navigateToNextStatement:y,navigateToPreviousStatement:q,navigateToPreviousBlock:W,answers:w,questions:L,resetSurvey:R,navigateToStart:C,pivot:x,formQuestionErrors:k,dateQuestionErrors:E,textboxQuestionErrors:T,fileUploadErrors:S,contactFormErrors:N,setErrors:P,expanded:$,setExpanded:_,isQuestionBgDark:B,isSubmitting:H}=d$({...e,isWidget:!0});Ie("Widget",{...e,renderedBlocks:i,activeIndexOfBlocks:p,answers:w,activeIndexOfRenderedBlocks:u,activeBlock:l});const[D,I]=s(null),[V,X]=s(null),[j,F]=s(null),[U,G]=s(0),Y=t.useMemo((()=>ke(x?.question)),[x?.question]),Z=we(w.formValues)&&e.survey.prompt_settings?.is_enabled,[K,Q]=s(Z),J=r(Z?-1:u),ee=()=>{if(null===D||!D||"undefined"==typeof window||"undefined"==typeof document)return;const t=Math.max(document?.documentElement.clientHeight||0,window.innerHeight||0)-(V?.scrollHeight??0)-(j?.scrollHeight??0)-164,n=Math.min(D?.scrollHeight,Math.min(ue[e.widgetStyle],t));U!==n&&G(n)};c((()=>{setTimeout((()=>{ee()}),0)}),[K,d,D,g[l?.question?.name],u,j,$,k,Object.keys(E),Object.keys(T),Object.keys(S),Object.keys(N)]),c((()=>{"MATRIX_RATING_SCALE"===l?.question?.type_info?.question_type&&setTimeout((()=>{ee()}),0)}),[g[l?.question?.name]]),c((()=>{e.loadAsNewSurvey&&e.handleAction&&e.handleAction("RE_SUBMIT",R)}),[]),c((()=>{e.setCurrentSurveyState?.({question:i[u]?.question,npsScore:x?.answer})}),[u,x?.answer]),c((()=>{u!==J.current&&(J.current=-1)}),[u]);const te={answers:w,blocks:o,blockIndex:u,activeIndexOfBlocks:p,initialStatementHasAnswer:O,activeIndexOfRenderedBlocks:u,activeIndexOfRenderedStatement:g,renderedBlocks:i,isMobile:!!e.isMobile,surveyStyle:"card",isWidget:!0,questions:L,pages:n,contactData:e.contactData,activeIndexOfSet:0,branchSeparatePage:!1,pivot:x};if(!l||!l?.question)return null;const ne=d?o.length:p+(d?1:0),ae=d?100:(ne>0?100/o.length:0)*ne;return t.createElement("div",{className:`freemium-survey-components widget-survey-components\n ${e.widgetStyle}-style`.trim(),id:"freemium-survey"},d||K||!e.survey.meta?.progress_bar?null:t.createElement("div",{className:"widget-progressbar"},t.createElement("div",{className:"progress-completion"},ae.toFixed(),"%"),t.createElement(Gq,{totalSteps:o.length,completedSteps:p+(d?1:0),isWidget:!0})),!K&&!e.minimized&&n.length>0&&a?.page_id&&!d&&t.createElement(b$,{ref:e=>e?F(e):null,expanded:$,id:a.page_id,setExpanded:_,activePage:a,translationVariables:M}),t.createElement("div",{className:"questions ss-questions",style:{...Z&&K||J.current===u?{transition:"none"}:{}}},t.createElement(DE,{exitBeforeEnter:!0},t.createElement(PE.div,{id:`${l.question.name}`,className:`question-container ss-question-container ${d?"thankyou":""} ${K?"prompt-container":""}`.trim(),"data-test-question-name":l.question.name,key:`${l.question.name}`,initial:{opacity:0,x:Re(e.language,b)},animate:{opacity:1,x:0},exit:{opacity:0,x:Ce(e.language,b)},transition:{duration:.2}},t.createElement("div",{className:"animation-container",style:{height:e.minimized?0:U>0&&!$?`${U}px`:"auto"}},t.createElement("div",{className:"scroll-container",ref:e=>e?I(e):null},K&&e.survey.prompt_settings?t.createElement(z$,{config:e.survey.prompt_settings,onSelect:t=>{e.onAnsweringPrompt(t),1===t&&Q(!1)},placeholders:e.placeholders}):t.createElement(t.Fragment,null,d?t.createElement(T4,{surveyServAssetUrl:e.surveyServAssetUrl??"",thankYouQuestion:NP({pivotQn:x?.question,pivotQnAnswer:x?.answer,block:HP({activeBlock:l,blocks:e.survey.blocks?.filter((e=>!e.is_deleted)),answers:w,questions:L,activeIndexOfBlocks:p,renderedBlocks:i,contactData:e.contactData,surveyLayout:"card",pages:n}),questions:L}),placeholders:e.placeholders,canResubmit:e.canResubmit,widgetStyle:e.widgetStyle,navigateToStart:()=>{e.handleAction?e.handleAction("EDIT_RESPONSE",C):C()},resetSurvey:()=>{e.handleAction?e.handleAction("RE_SUBMIT",R):R()},allowMultipleSubmission:e.allowMultipleSubmission,pivot:x,rangeToRender:Y,translationVariables:M,isQuestionBgDark:B,answers:w}):t.createElement(t.Fragment,null,t.createElement("div",{className:`question-text ss-question-text ${!l.question.type_info?.pivot_question&&l.required?"required":""} ${"RANGE"===l?.question?.type_info?.question_type?"range-question-text":""}`.trim(),dangerouslySetInnerHTML:{__html:Ee({questionText:l?.question.text,placeholders:e.placeholders,npsRating:Te({theme:"nps",answers:w,questions:L})??"",npsRatingLabel:Se({theme:"nps",answers:w,questions:L}),csatRating:Te({theme:"csat",answers:w,questions:L})??"",csatRatingLabel:Se({theme:"csat",answers:w,questions:L}),cesRating:Te({theme:"ces",answers:w,questions:L})??"",cesRatingLabel:Se({theme:"ces",answers:w,questions:L}),preference:x?.question.type_info?.scale_properties?.labels?.preference})},"aria-label":`question-${u}`,role:"heading","aria-level":1}),"MESSAGE"!==l.question.type_info?.question_type&&t.createElement("div",{className:"question-wrapper",onTransitionEndCapture:e=>e.stopPropagation()},t.createElement(A4,{setFocus:!0,surveyStyle:"card",isReverseAnimation:b,language:e?.language||"en",surveyServAssetUrl:e.surveyServAssetUrl,fileUploadErrors:S,setErrors:P,onFileUpload:e.onFileUpload,surveyLanguage:e.survey.language,block:l,question:l.question,isFinalQn:SP({blocks:o,activeIndexOfBlocks:p,renderedBlocks:i,activeIndexOfRenderedBlocks:u,questions:L}),formValues:w.formValues,widgetStyle:e.widgetStyle,isMobile:!1,othersMeta:w.others,autoFocusDelay:0,activeIndexOfRenderedStatement:g,isWidget:!0,saveOthersValue:(e,t)=>{m(e,t),setTimeout((()=>{ee()}),0)},onChangeHandler:e=>{setTimeout((()=>{ee()}),0),z(l,e)},formQuestionErrors:k,dateQuestionErrors:E,textboxQuestionErrors:T,contactFormErrors:N,translationVariables:M,isQuestionBgDark:B})))))))),!d&&!K&&t.createElement(N4,{pages:n,isWidget:!0,language:e.language||"en",widgetStyle:e.widgetStyle,setFooterElementRef:X,surveyStyle:"standard",answers:w,survey:e.survey,canDisplayDisableButtonParams:{...te,blockIndex:u,activeIndexOfRenderedBlocks:u},isMobile:!1,renderedBlocks:i,initialStatementHasAnswer:O,activeIndexOfRenderedStatement:g,blocks:o,activeIndexOfRenderedBlocks:u,navigateToNextStatement:y,navigateToPreviousStatement:q,activeIndexOfBlocks:p,translationVariables:M,saveFormValues:z,skipBlock:h,skipStatement:f,onSubmitHandler:A,navigateToPreviousBlock:W,navigateToNextBlock:v,formQuestionErrors:k,dateQuestionErrors:E,textboxQuestionErrors:T,fileUploadErrors:S,contactFormErrors:N,questions:L,isSubmitting:H})))},$4={default:{width:522,11:6,10:6,9:8,8:8,7:18,6:22,5:28,4:32,3:36},compact:{width:522,11:6,10:6,9:8,8:8,7:18,6:22,5:28,4:32,3:36},cozy:{width:582,11:12,10:12,9:12,8:12,7:18,6:22,5:28,4:32,3:36}},_4=({language:e="en",survey:n,preview:a,placeholders:o,contactData:i,overRideComponent:c,onSubmit:l,onDismiss:p,onClose:u,isMobile:d,surveyType:b,unsubscribeUrl:M,isSurveyCompleted:z,children:m=null,answerStatus:h,loadSurveyCollapsed:f=!1,handleAction:O,answers:A,onAnsweringPrompt:v,allowMultipleSubmission:g,loadAsNewSurvey:y,canResubmit:q,translationVariables:W,surveyServAssetUrl:w,footerProps:L,surveyPoweredBy:R,onFileUpload:C,isQuestionBgDark:x,hideMinimize:k,position:E,collector:T,backdropColor:S})=>{const N=n.question_details?.questions||[],[P,$]=s(),[_,B]=s(!1),[H,D]=s(f),[I,V]=s(!1),{theme:X}=n,[j,F]=s(null),U=t.useMemo((()=>((e=[])=>{const t=e.sort(((e,t)=>Number(e.order)-Number(t.order)));return t.find((e=>!e.is_deleted))??t[0]})(n.blocks||[])),[n.blocks]),G=U?.question_name?U?.question_name??"":U?.category?.[0].question_name??"",Y=N.find((e=>e.name===G)),Z=()=>{B(!0),setTimeout((()=>{u?.()}),300)},K=r(null);function Q(e){const t=document?.getElementById("freshworks-survey-widget"),n=e?.channel_info?.web_in_app_channel_info;let a="";if(S?a=S:n?.backdrop_enabled&&n?.backdrop_color&&(a=n?.backdrop_color),t&&a)try{const e=(o=a,Object.entries({...de,backgroundColor:o}).map((([e,t])=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${t}`)).join("; "));t.style.cssText=e}catch(e){console.error("Error applying styles to widgetElement:",e)}var o}return t.useEffect((()=>{const e=document?.documentElement;if(!e||!n.question_details?.questions)return;let t=0;(n.question_details.questions??[]).forEach((e=>{const n=ke(e);"RANGE"===e.type_info?.question_type&&n.length>t&&(t=n.length)}));const a=42*t+$4[b][t]*(t-1);e.style.setProperty("--fsc-max-range-question-width",Math.min($4[b].width,a)+"px")}),[n,b]),t.useEffect((()=>{X&&(Ne(X,w??""),V(Ve(X.palette?.footer_background??X.palette?.survey_background??m$)))}),[X,w]),t.useEffect((()=>{Q(T)}),[T]),t.createElement("div",{id:"freshworks-survey-widget",className:`align-${E||""}`},n.theme?.advanced?.additional_css&&t.createElement("style",null,n.theme?.advanced?.additional_css?.replaceAll("\n","")?.replaceAll("!important","").replaceAll(/;/g," !important;")),t.createElement("div",{className:`surveyserv-widget-container ${Le(e||"en")?"freemium-survey-rtl":"freemium-survey-ltr"} ${d?"widget-mobile":""} ${b}-container-style ${H?"minimized":""}`,id:"surveyserv-widget-container"},t.createElement("header",{id:"surveyserv-widget-header",className:("widget-header "+(H?"minimized":"")).trim()},H?t.createElement("span",{className:"header-content minimized",dangerouslySetInnerHTML:{__html:Ee({questionText:(!P&&n.prompt_settings?.is_enabled?n.prompt_settings.text:j?.question?.text)??He(Y?.text||""),placeholders:{...o,"{{nps.rating}}":String(j?.npsScore??"")}})}}):t.createElement("div",null),t.createElement("div",{className:"icons"},!z&&!k&&t.createElement(et,{onClick:()=>{D((e=>!e))},variant:"secondary",className:"svs-icon minimize-btn",title:H?W?.maximize||"Maximize widget":W?.minimize||"Minimize widget"},H?t.createElement(k4,null):t.createElement(E4,null)),t.createElement(et,{ref:K,onClick:()=>{z?Z():p()},variant:"secondary",title:W?.dismiss||"Dismiss widget",className:"svs-icon minimize-btn"},t.createElement(LP,null)))),m,t.createElement("main",{className:("widget-main "+(H?"minimized":"")).trim()},c?t.createElement(t.Fragment,null,c):t.createElement(P4,{surveyServAssetUrl:w,answers:A,minimized:H,widgetStyle:b,answerStatus:h,language:e||"en",survey:n,placeholders:o,isMobile:!!d,contactData:i,onFileUpload:C,allowMultipleSubmission:g,loadAsNewSurvey:y,canResubmit:q,onSubmit:l,setCurrentSurveyState:F,widgetHeaderQuerySelector:H?void 0:"#surveyserv-widget-header",onAnsweringPrompt:e=>{v?.(e),$(e),0==e&&we(n.prompt_settings?.declined_message)&&Z()},handleAction:O,translationVariables:W})),(()=>{const e=!!M&&!H,n=!!L?.showFWBranding;return e||n?t.createElement("footer",{className:`widget-footer ${H?"minimized":""} survey-footer-${I?"dark":"light"}`.trim()},t.createElement("div",null,e&&t.createElement("a",{href:M,target:"_blank",rel:"noopener noreferrer",onClick:e=>{a&&e.preventDefault(),e.stopPropagation(),Z()}},W?.unsubscribe||"Unsubscribe")),n&&t.createElement("div",{className:"footer-text"},t.createElement(Ga,{surveyPoweredBy:R,isDark:I}))):null})()))},B4=e=>{const{survey:n,answers:a}=CP(e.survey,e.answers),[o,i]=t.useState(!1);return t.useEffect((()=>{"undefined"!=typeof window&&window&&window.matchMedia&&"undefined"!=typeof sessionStorage&&sessionStorage&&sessionStorage.clear&&(Ie("Survey matchMedia",{innerHeight:window.innerHeight,innerWidth:window.innerWidth}),i(window.matchMedia("(max-width: 550px)").matches),u$(localStorage))}),[]),t.useEffect((()=>{const t=document?.documentElement;!qe(e.surveyServAssetUrl)&&t&&setTimeout((()=>{t.style.setProperty("--fsc-whatsapp-chat-background",`url(${e.surveyServAssetUrl}/survey/whatsapp-chat-bg.svg)`)}),0)}),[e.surveyServAssetUrl]),Ie("Survey",{...e,survey:n,isMobile:o,answers:a}),t.createElement(t.Fragment,null,n.theme?.advanced?.additional_css&&t.createElement("style",null,n.theme?.advanced?.additional_css?.replaceAll("\n","")?.replaceAll("!important","").replaceAll(/;/g," !important;")),"standard"===e.surveyStyle?t.createElement(x4,{...e,answers:a,survey:n,isMobile:o||!!e.isMobile,initialQuestionAnswer:e.initialQuestionAnswer}):t.createElement(q4,{...e,answers:a,survey:n,isMobile:o||!!e.isMobile,surveyStyle:"card",initialQuestionAnswer:e.initialQuestionAnswer}))},H4=e=>{const{survey:n,answers:a}=CP(e.survey,e.answers);return Ie("WebInAppContainer",{...e,survey:n,answers:a}),t.createElement(_4,{...e,survey:n,answers:a})},D4=e=>{const[n,a]=t.useState(!1),[o,i]=t.useState(!1);return t.useEffect((()=>{"undefined"!=typeof window&&window&&window.matchMedia&&(a(window.matchMedia("(max-width: 550px)").matches),"cozy"===e.surveyType&&i(window.matchMedia("(max-width: 1080px)").matches))}),[]),Ie("WebInAppSurvey",{...e,isMobile:n,isDefault:o}),e.isLoading?t.createElement("div",{id:"freshworks-survey-widget"},t.createElement("div",{className:`surveyserv-widget-container ${Le(e.language||"en")?"freemium-survey-rtl":"freemium-survey-ltr"} ${n?"widget-mobile":""} ${e.surveyType}-container-style`,id:"surveyserv-widget-container"},t.createElement("header",{id:"surveyserv-widget-header",className:"widget-header".trim()},t.createElement("div",null),t.createElement(et,{onClick:()=>{setTimeout((()=>{e?.onClose?.()}),300)},variant:"secondary",title:e.translationVariables?.dismiss||"Dismiss widget",className:"svs-icon minimize-btn"},t.createElement(LP,null))),t.createElement("main",{className:"widget-main widget-loader".trim()},e.overRideComponent??t.createElement(Za,null)))):t.createElement(t.Fragment,null,e?.survey?.id?t.createElement(H4,{...e,isMobile:n,surveyType:n?"compact":o?"default":e.surveyType}):null)},I4=e=>{const{question:n,surveyStyle:a,language:o,onAnswer:i,translationVariables:r,surveyServAssetUrl:c,block:s,theme:l}=e,[p,u]=t.useState(!!e.isMobile);return t.useEffect((()=>{"undefined"!=typeof window&&window&&window.matchMedia&&u(window.matchMedia("(max-width: 550px)").matches||!!e.isMobile)}),[]),t.useEffect((()=>{l&&Ne(l,c??"")}),[l,c]),Ie("QuestionPreview",{...e,isMobile:p}),t.createElement(t.Fragment,null,l?.advanced?.additional_css&&t.createElement("style",null,l?.advanced?.additional_css?.replaceAll("\n","")?.replaceAll("!important","").replaceAll(/;/g," !important;")),t.createElement("div",{className:`freemium-survey-components question-preview ${a}-survey-style ${Le(o||"en")?"freemium-survey-rtl":"freemium-survey-ltr"} ${p?"mobile-preview":""}`.trim(),id:"freemium-survey"},t.createElement("div",{className:"question-holder"},t.createElement("div",{className:"questions ss-questions"},t.createElement(PE.div,{id:`${n.name}`,className:"question-container ss-question-container","data-test-question-name":n.name,key:`${n.name}`,initial:{opacity:0,x:Re(o,!1)},animate:{opacity:1,x:0},exit:{opacity:0,x:Ce(o,!1)},transition:{duration:.2}},t.createElement("div",{className:`question-text ss-question-text ${s.required?"required":""} ${"RANGE"===n?.type_info?.question_type?"range-question-text":""}`.trim(),dangerouslySetInnerHTML:{__html:Ee({questionText:n.text,placeholders:{},npsRating:"",npsRatingLabel:"",csatRating:"",csatRatingLabel:"",cesRating:"",cesRatingLabel:"",preference:n.type_info?.scale_properties?.labels?.preference})},"aria-label":"question-0",role:"heading","aria-level":1}),t.createElement(A4,{surveyStyle:a,language:e?.language||"en",surveyServAssetUrl:c,surveyLanguage:e?.language,block:s,question:n,formValues:{},isMobile:p,othersMeta:{},saveOthersValue:(e,t)=>{},onChangeHandler:e=>{i?.({value:e,block:s,question:n})},translationVariables:r??{},activeIndexOfRenderedStatement:{},autoFocusDelay:0,contactFormErrors:{},dateQuestionErrors:{},fileUploadErrors:{},formQuestionErrors:{},textboxQuestionErrors:{},setErrors:()=>{}}))))))},V4=(e,t)=>{c((()=>{if(e){e.style.height="0px";const t=e.scrollHeight;e.style.height=t+"px"}}),[e,t])},X4=["😭","😞","🙁","😕","😐","🙂","😊","😃","😄","😀"],j4={10:[1,2,3,4,5,6,7,8,9,10],9:[1,2,3,4,5,6,7,9,10],8:[1,2,3,4,6,7,9,10],7:[1,2,3,5,6,8,10],6:[1,2,4,6,8,10],5:[1,3,5,8,10],4:[1,4,7,10],3:[1,5,10]};function F4(e,t){const n=j4[t];if(!n||e<1||e>Number(t))return"";const a=n[e-1]-1;return X4[a]||""}const U4=e=>e?.length&&e?.length>20?e?.trim()?.slice(0,20)+"...":e||"",G4=({rating:e,question:n,type:a})=>{const{range:o}=n?.type_info?.scale_properties||{},i=(n?.type_info?.scale_properties?.labels?.values||[]).length;let r=Number(o?.[o.length-1]?.max||i);const c=n?.type_info?.type_variant||"";if(a)switch(c){case"TICK":return t.createElement("span",null,e?"✅":"❌");case"THUMBS":return t.createElement(Ge,{name:e?"whatsapp-thumbs-up":"whatsapp-thumbs-down"});case"EMOJI":{const n=i<=2;return t.createElement(t.Fragment,null,n?function(e){return X4[[1,10][e]-1]}(e):F4(e,r||10))}case"NUMBER":return t.createElement(t.Fragment,null,e);case"TEXT":return null}return t.createElement(t.Fragment,null,"TEXT"!==c&&Array.from({length:e},((e,n)=>t.createElement(Ge,{name:"whatsapp-star",id:`choice-${n}`,key:n}))))},Y4=({title:e="Acme.inc",type:n="facebook"})=>t.createElement("div",{className:`meta-header meta-header--${n}`},t.createElement("div",{className:"meta-header-left"},t.createElement(Ge,{name:"meta-back-arrow",fill:"facebook"!==n?"#262626":void 0}),t.createElement("div",{className:"meta-header-brand"},t.createElement("div",{className:"meta-logo"},e?.trim()?.charAt(0)?.toUpperCase()),t.createElement("span",{className:"meta-title"},e),t.createElement(Ge,{name:"verified-blue-tick",fill:"whatsapp"===n?"#00E25C":void 0}))),"whatsapp"!==n&&t.createElement("div",{className:"meta-header-right"},"instagram"===n&&t.createElement(Ge,{name:"instagram-phone",fill:"instagram"!==n?"#262626":void 0}),t.createElement(Ge,{name:"facebook-video",fill:"facebook"!==n?"#262626":void 0}))),Z4=({children:e,title:n="Acme.inc",type:a="facebook"})=>{const o="facebook"===a?"meta-wrapper facebook-wrapper":"whatsapp"===a?"meta-wrapper whatsapp-wrapper":"meta-wrapper instagram-wrapper";return t.createElement("div",{className:o},t.createElement("div",{className:"meta-mobile"},t.createElement("div",{className:"meta-mobile-actions"},t.createElement("div",{className:"meta-left-side-buttons-container"},t.createElement("div",{className:"meta-side-buttons left"}),t.createElement("div",{className:"meta-side-buttons left-2"})),t.createElement("div",{className:"meta-side-buttons right"})),t.createElement("div",{className:"meta-phone-frame"},t.createElement(Y4,{title:n,type:a}),e)))},K4=({children:e,title:n,closeModal:a,isModalOpen:o,type:i})=>t.createElement(X,{in:o,unmountOnExit:!0,timeout:500,classNames:"fade",key:n},t.createElement("div",{className:"options-popup",style:{}},t.createElement("header",null,t.createElement("button",{onClick:a,className:"close-btn"},"facebook"===i?t.createElement("span",{style:{fontSize:"10px",fontWeight:"400",gap:"10px"}},"Cancel"):t.createElement(LP,null)),"facebook"===i?t.createElement("div",{className:"option-tab-bar"}):t.createElement("h4",null,n)),t.createElement("main",{className:"fsc-range-main"},e),t.createElement("footer",null,"facebook"===i?t.createElement("div",{className:"privacy-text"},"Your response will be sent directly to Acme.inc",t.createElement("br",null),"and not shown in this chat.",t.createElement("br",null),"View Acme.inc"," ",t.createElement("span",{style:{color:"#1877F2"}},"privacy policy")):"Tap an item to select it"))),Q4=({question:e,saveFormValues:n,type:a,answers:o})=>{const[i,l]=s(!1),[p,u]=s(o?.formValues[e.name]),[d,b]=s(null),[M,z]=s(null),{range:m}=e?.type_info?.scale_properties||{},h=Number(m?.[0]?.min),f=Number(m?.[m.length-1]?.max),O="descending"===e?.type_info?.scale_properties?.order,A=[...e?.type_info?.scale_properties?.labels?.values||[]],v=e?.type_info?.scale_properties?.labels?.preference;c((()=>{"instagram"===a&&l(!0)}),[a]);const g=r(Array.from({length:f+(0===h?1:0)},((e,t)=>O?f-t:t+h)));if(g.current.length<=3){const o="THUMBS"===e?.type_info?.type_variant||2===g.current.length;if("facebook"===a)return t.createElement("ul",{className:"choices dropdown-choices"},g.current.map(((i,r)=>o?t.createElement("li",{className:"choice dropdown-choice",key:`thumbs-${i}-${r}`},t.createElement("button",{className:"action",onClick:()=>{n(i)}},t.createElement("span",{className:"ellipsis-wrapper"},"TEXT"!==e?.type_info?.type_variant&&t.createElement(G4,{rating:i,question:e,type:a})," ","all"===e?.type_info?.scale_properties?.labels?.preference&&U4(e?.type_info?.scale_properties?.labels?.values?.[i]||"")))):t.createElement("li",{className:"choice dropdown-choice",key:`choice-${i}-${r}`},t.createElement("button",{onClick:()=>{n(i)}},t.createElement("span",{className:"star-rating-wrapper"},t.createElement(G4,{rating:i,question:e,type:a}),"all"===v?t.createElement("span",null," ",U4(A[i-1]||"")):"edges"===v&&(0===r||r===A.length-1)&&t.createElement("span",null," ",U4(0===h?A[i]||"":A[i-1]||""))))))));const i="whatsapp"===a?"choices--vertical":"";return t.createElement("ul",{className:`choices ${i} ${(o||"all"!==e?.type_info?.scale_properties?.labels?.preference)&&"one-line"}`},g.current.map(((i,r)=>o?t.createElement("li",{className:"choice range-choice",key:`thumbs-${i}-${r}`},t.createElement("button",{onClick:()=>{n(i),u(!0)}},t.createElement("span",{className:"ellipsis-wrapper"},"whatsapp"===a&&"TEXT"!==e?.type_info?.type_variant&&t.createElement(G4,{rating:i,question:e,type:a}),"instagram"===a&&t.createElement(G4,{rating:i,question:e,type:a})," ","all"===e?.type_info?.scale_properties?.labels?.preference&&U4(e?.type_info?.scale_properties?.labels?.values?.[i]||"")))):t.createElement("li",{className:"choice range-choice",key:`choice-${i}-${r}`},t.createElement("button",{onClick:()=>{n(i),u(!0)}},t.createElement("span",{className:"star-rating-wrapper"},t.createElement(G4,{rating:i,question:e,type:a})," ","all"===v||"edges"===v&&(0===r||r===A.length-1)?U4(0===h?A[i]:A[i-1]):null))))))}const y="facebook"===a&&p||"instagram"===a;return t.createElement(t.Fragment,null,!y&&t.createElement("button",{onClick:()=>l(!0),className:"choices-button choice"},"facebook"!==a&&t.createElement(Ge,{name:"whatsapp-choices"}),"facebook"===a?"Rate experience":"Rate Support"),t.createElement(K4,{title:"facebook"===a?"Rate experience":"Rate Support",isModalOpen:i,closeModal:()=>{l(!1),b(null),z(null)},type:a},"facebook"===a?t.createElement("div",{className:"facebook-rating-modal"},t.createElement("h2",{className:"modal-question-name"},e?.text),t.createElement("div",{className:"rating-labels"},g.current.map(((e,n)=>"all"!==v&&"edges"!==v||0!==n&&n!==A?.length-1?null:t.createElement("span",{key:n},A[n])))),"STAR"===e?.type_info?.type_variant&&t.createElement("div",{className:"star-container"},g.current.map(((e,n)=>{const a=(M||d||0)>=e;return t.createElement("button",{className:"star-button",onClick:()=>b(e),onMouseEnter:()=>z(e),onMouseLeave:()=>z(null)},t.createElement(Ge,{name:"facebook-star",fill:a?"#1877F2":"#E4E6EA",id:`star-${n}`}))}))),"EMOJI"===e?.type_info?.type_variant&&t.createElement("div",{className:"emoji-container"},g.current.map(((n,a)=>{const o=d===n||M===n,i=e?.type_info?.scale_properties?.range?.[e?.type_info?.scale_properties?.range?.length-1]?.max;return t.createElement("button",{onClick:()=>b(n),onMouseEnter:()=>z(n),onMouseLeave:()=>z(null),className:"emoji-button "+(o?"selected":"")},F4(n,i))}))),"NUMBER"===e?.type_info?.type_variant&&t.createElement("div",{style:{gap:0===Number(m?.[0].min)?"8px":"12px"},className:"number-container "+(g.current.length>5?"grid-layout":"single-row")},g.current.map(((e,n)=>{const a=d===e;return t.createElement("button",{key:e,className:"number-button "+(a?"selected":""),onClick:()=>b(e),onMouseEnter:()=>z(e),onMouseLeave:()=>z(null),style:{backgroundColor:a?"#48A0F8":"#E4E6EA",color:a?"#fff":"#000"}},e)}))),t.createElement("button",{className:"submit-button",onClick:()=>{we(d)||(n(d),l(!1),u(!0),b(null))},disabled:we(d)},"Submit")):g.current.map(((o,i)=>t.createElement("div",{className:"option-row",key:o},t.createElement("button",{onClick:()=>{n(o),l(!1),u(!0)}},t.createElement("span",{className:"star-rating-wrapper"},"whatsapp"===a&&t.createElement(G4,{rating:o,question:e,type:a}),"instagram"===a&&t.createElement(G4,{rating:o,question:e,type:a})," ","all"===v||"edges"===v&&(0===i||i===A.length-1)?U4(0===h?A[o]:A[o-1]):null)))))))},J4=({question:e,saveFormValues:n,type:a,answers:o,setCurrentOtherChoice:i,setShowOtherInput:r})=>{const[l,p]=s(!1),[u,d]=s(o?.formValues[e.name]),b="facebook"===a&&u||"instagram"===a;return c((()=>{"instagram"!==a||u||p(!0)}),[a,u]),t.createElement(t.Fragment,null,!b&&t.createElement("button",{onClick:()=>p(!0),className:"choices-button choice"},"facebook"!==a&&t.createElement(Ge,{name:"whatsapp-choices"}),"Select answer"),t.createElement(K4,{title:"Select a choice",isModalOpen:l,closeModal:()=>p(!1),type:a},"facebook"===a&&t.createElement("h2",{className:"modal-question-name"},e?.text),t.createElement("ul",{className:`choices multi-choice ${a}`},e.choices.filter((e=>!e?.meta?.is_deleted)).map(((a,o)=>t.createElement("li",{className:"choice",style:{boxShadow:"none"},key:`${a}-${o}`},t.createElement("button",{onClick:()=>{n(a.id),p(!1),d(!0);const t=a.meta?.is_others;if(t){const t=e.type_info?.comment_placeholder||"";i({id:e.name,placeholder:t,value:a.id||""}),r(!0)}}},t.createElement("div",{className:"ellipsis-wrapper"},U4(a.value)))))))))},e6=e=>{const n=r(null);return V4(n.current,String(e.value)??""),c((()=>{e.autoFocus&&n.current?.focus()}),[e.autoFocus]),t.createElement("div",{className:"textarea-container"},t.createElement("textarea",{placeholder:"Type a message",ref:n,rows:1,onChange:e.onChange,value:e.value}),t.createElement("button",{onClick:()=>{n.current&&n.current?.value&&!we(n.current?.value)&&(e.onSubmit(),n.current.value="")}},t.createElement(Ge,{name:"whatsapp-send"})))},t6=e=>{const n=r(null);return V4(n.current,String(e.value)??""),c((()=>{e.autoFocus&&n.current?.focus()}),[e.autoFocus]),t.createElement("div",{className:"input-container"},t.createElement("div",{className:"input-field"},t.createElement("div",{className:"facebook-textarea-container "},t.createElement("textarea",{placeholder:"Aa",ref:n,rows:1,onChange:e.onChange,value:e.value}),t.createElement(Ge,{name:"facebook-smile"}))),t.createElement("div",{className:"icon-container"},we(e.value)?t.createElement(Ge,{name:"facebook-thumbsup"}):t.createElement("button",{type:"button",onClick:()=>{we(e.value)||(e.onSubmit(),n.current&&(n.current.value=""))}},t.createElement(Ge,{name:"facebook-send"}))))},n6=({text:e,placeholders:n,pivot:a,rangeToRender:o,questions:i,answers:r})=>t.createElement("div",{className:"question-text-container"},t.createElement("div",{className:"question-text ss-question-text",dangerouslySetInnerHTML:{__html:Ee({questionText:e,placeholders:n,npsRating:Te({theme:"nps",answers:r,questions:i})??"",npsRatingLabel:Se({theme:"nps",answers:r,questions:i}),csatRating:Te({theme:"csat",answers:r,questions:i})??"",csatRatingLabel:Se({theme:"csat",answers:r,questions:i}),cesRating:Te({theme:"ces",answers:r,questions:i})??"",cesRatingLabel:Se({theme:"ces",answers:r,questions:i}),preference:a?.question.type_info?.scale_properties?.labels?.preference,isPreview:!0})},role:"heading","aria-level":1})),a6=e=>{switch(e.type){case"whatsapp":return t.createElement(o6,{...e});case"instagram":return t.createElement(i6,{...e});case"facebook":return t.createElement(r6,{...e})}},o6=e=>{const{block:n,saveFormValues:a,type:o,translationVariables:i,language:r,answers:s,setCurrentOtherChoice:l,setShowOtherInput:p}=e,u=n.question?.type_info?.question_type;switch(c((()=>{"MESSAGE"===u&&a(null,!1)}),[u]),u){case"RANGE":return t.createElement(Q4,{answers:s,type:o,question:n.question,saveFormValues:e=>a(e,!0)});case"DROPDOWN":const c=(n?.question?.choices||[]).filter((e=>!e.meta?.is_deleted));return c.length<=3?t.createElement(u6,{...e,saveFormValues:e=>a(e,!0),setCurrentOtherChoice:l,setShowOtherInput:p}):t.createElement(J4,{answers:s,dir:Le(r||"en")?"rtl":"ltr",question:n.question,saveFormValues:e=>a(e,!0),type:o,translationVariables:i,setCurrentOtherChoice:l,setShowOtherInput:p});case"MULTI_SELECT":return t.createElement(J4,{answers:s,dir:Le(r||"en")?"rtl":"ltr",question:n.question,saveFormValues:e=>a(e,!0),type:o,translationVariables:i,setCurrentOtherChoice:l,setShowOtherInput:p});case"CONSENT":return t.createElement(p6,{...e,saveFormValues:e=>a(e,!0)});case"RESOLUTION":case"BOOLEAN":return t.createElement(l6,{...e,saveFormValues:e=>a(e,!0)});case"PARAGRAPH":case"DATE":case"DATE_TIME":case"MESSAGE":case"TEXT":case"NUMBER":return null;default:return console.error(`Question type ${u} not supported for ${o}`),null}},i6=e=>{const{block:n,saveFormValues:a,type:o,translationVariables:i,language:r,answers:s,setCurrentOtherChoice:l,setShowOtherInput:p}=e,u=n.question?.type_info?.question_type;switch(c((()=>{"MESSAGE"===u&&a(null,!1)}),[u]),u){case"RANGE":return t.createElement(Q4,{answers:s,type:o,question:n.question,saveFormValues:e=>a(e,!0)});case"DROPDOWN":case"MULTI_SELECT":return t.createElement(J4,{answers:s,dir:Le(r||"en")?"rtl":"ltr",question:n.question,saveFormValues:e=>a(e,!0),type:o,translationVariables:i,setCurrentOtherChoice:l,setShowOtherInput:p});case"CONSENT":return t.createElement(p6,{...e,saveFormValues:e=>a(e,!0)});case"RESOLUTION":case"BOOLEAN":return t.createElement(l6,{...e,saveFormValues:e=>a(e,!0)});case"PARAGRAPH":case"DATE":case"DATE_TIME":case"MESSAGE":case"TEXT":case"NUMBER":return null;default:return console.error(`Question type ${u} not supported for ${o}`),null}},r6=({block:e,saveFormValues:n,type:a,translationVariables:o,language:i,answers:r,setCurrentOtherChoice:c,setShowOtherInput:s})=>{const l=e.question?.type_info?.question_type;switch(l){case"RANGE":return"RANGE"===l&&Number(e.question?.type_info?.scale_properties?.range?.length)<3?t.createElement(s6,{question:e.question,saveFormValues:e=>n(e,!0),setCurrentOtherChoice:c,setShowOtherInput:s}):t.createElement(Q4,{answers:r,type:a,question:e.question,saveFormValues:e=>n(e,!0)});case"DROPDOWN":case"MULTI_SELECT":return Array.isArray(e.question?.choices)&&e.question.choices.filter((e=>!e?.meta?.is_deleted))?.length<=3?t.createElement(s6,{setCurrentOtherChoice:c,setShowOtherInput:s,question:e.question,saveFormValues:e=>n(e,!0)}):t.createElement(J4,{answers:r,dir:Le(i||"en")?"rtl":"ltr",question:e.question,saveFormValues:e=>n(e,!0),type:a,translationVariables:o,setCurrentOtherChoice:c,setShowOtherInput:s});case"PARAGRAPH":case"DATE":case"DATE_TIME":case"TEXT":return null;case"BOOLEAN":case"RESOLUTION":case"CONSENT":return t.createElement(s6,{question:e.question,saveFormValues:e=>n(e,!0),setCurrentOtherChoice:c,setShowOtherInput:s});case"MESSAGE":return n(!0,!1),null;default:return console.error(`Question type ${l} not supported for ${a}`),null}},c6=({config:e,placeholders:n,onSelect:a,promptAccepted:i,type:r})=>{const c=o((()=>e.reverse_order?e.choices?.reverse():e.choices),[e]);return t.createElement(t.Fragment,null,t.createElement("div",{className:"question-container ss-question-container "+(null==i?"active":"")},t.createElement(n6,{text:e.text,placeholders:n}),t.createElement("ul",{className:"choices one-line"},c?.map(((e,n)=>t.createElement("li",{className:"choice",key:`prompt-${e}-${n}`},t.createElement("button",{className:"action",onClick:()=>{a(Number(e.id))}},t.createElement(Ge,{name:Number(e.id)?"whatsapp-thumbs-up":"whatsapp-thumbs-down"}),e.value)))))),void 0!==i&&t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"whatsapp"===r&&t.createElement("div",{className:"reply-block"},t.createElement("p",{className:"user"},"Acme.inc"),t.createElement("p",{className:"question",dangerouslySetInnerHTML:{__html:Ee({questionText:e.text,placeholders:n})}})),t.createElement("div",{className:"answer-text"},t.createElement(Ge,{name:Number(i)?"whatsapp-thumbs-up":"whatsapp-thumbs-down"}),c.find((e=>e.id==i))?.value))),!1===i&&e.is_declined&&e.declined_message&&t.createElement("div",{className:"question-container ss-question-container"},t.createElement(n6,{text:e.declined_message,placeholders:n})))},s6=({question:e,saveFormValues:n,setCurrentOtherChoice:a,setShowOtherInput:i})=>{const[r,c]=s(!1),l=e?.type_info?.question_type,p=o((()=>{if(e?.choices&&Array.isArray(e.choices.filter((e=>!e?.meta?.is_deleted)))&&!we(e.choices))return e.choices.filter((e=>!e?.meta?.is_deleted)).map((e=>({id:e.id,value:e.value,numericValue:e.id,isOthers:e.meta?.is_others})));if("CONSENT"===l){if("CHECKBOX"===e?.type_info?.meta?.display_format){const t=e?.type_info?.scale_properties?.labels?.values?.[e?.type_info?.scale_properties?.labels?.values?.length-1];return[{id:0,value:t,numericValue:1}]}{const t=e?.type_info?.scale_properties?.labels?.values?.slice(0,2);return[{id:0,value:t[0],numericValue:1},{id:1,value:t[1],numericValue:0}]}}const t=e?.type_info?.scale_properties?.labels?.values;return(e?.type_info?.scale_properties?.range||[]).map(((e,n)=>({id:e.id,value:t?.[n]||e.label,numericValue:n})))}),[e]),u="DROPDOWN"===l||"MULTI_SELECT"===l;return t.createElement(t.Fragment,null,!r&&t.createElement("ul",{className:"choices "+(u?"dropdown-choices":"boolean-choices")},p.map(((o,r)=>t.createElement("li",{className:"choice "+(u?"dropdown-choice":"boolean-choice"),key:`${l}-${o.id}-${r}`},t.createElement("button",{className:"action",onClick:()=>(t=>{t.isOthers?(c(!0),i(!0),a({id:e.name,placeholder:e.type_info?.comment_placeholder,value:t.numericValue})):n("CONSENT"===l?t.value:t.numericValue,!0)})(o)},!u&&t.createElement(G4,{rating:o.numericValue,question:e,type:"facebook"}),t.createElement("span",{className:"ellipsis-wrapper"},U4(o?.value||""))))))))},l6=({type:e,block:n,saveFormValues:a,answers:o})=>{const i=n?.question,[r,c]=s(o?.formValues[i.name]),l="descending"===i?.type_info?.scale_properties?.order;let p=i?.type_info?.scale_properties?.labels?.values||[];l&&(p=p?.slice().reverse());const u="all"===i?.type_info?.scale_properties?.labels?.preference,d=e=>l?(e+1)%2:e;return"instagram"===e&&r?null:t.createElement("ul",{className:"choices reply-buttons"},p?.map(((o,r)=>t.createElement("li",{className:"choice reply-button",key:`prompt-${o}-${r}`},t.createElement("button",{className:"action",onClick:()=>{c(!0),a(Boolean(d(r)),!0)}},t.createElement("span",{className:"ellipsis-wrapper"},"whatsapp"===e&&"TEXT"!==n.question.type_info?.type_variant&&t.createElement(G4,{rating:d(r),question:i,type:e}),"instagram"===e&&t.createElement(G4,{type:e,question:i,rating:d(r)})," ",u&&U4(o)))))))},p6=({block:e,saveFormValues:n})=>{const a=e?.question,o=a?.type_info?.meta?.display_format,i="BUTTON"===o?fe.map((e=>({id:e.id,value:a?.type_info?.scale_properties?.labels?.values?.[e.id]||e.defaultValue}))):[{id:2,value:a?.type_info?.scale_properties?.labels?.values?.[2]||""}];return t.createElement("ul",{className:"choices reply-buttons"},i?.map(((e,a)=>t.createElement("li",{className:"choice reply-button",key:`prompt-${e?.id}-${a}`},t.createElement("button",{className:"action",onClick:()=>n(e.value)},U4(e.value))))))},u6=({block:e,saveFormValues:n,setCurrentOtherChoice:a,setShowOtherInput:o})=>{const i=e.question,r=(e?.question?.choices||[]).filter((e=>!e.meta?.is_deleted));return t.createElement("ul",{className:"choices reply-buttons"},r?.map(((e,r)=>t.createElement("li",{className:"choice reply-button",key:`prompt-${e?.id}-${r}`},t.createElement("button",{className:"action",onClick:()=>{n(e.id);const t=e.meta?.is_others;if(t){const t=i?.type_info?.comment_placeholder||"";a&&a({id:i.name,placeholder:t,value:e.id||""}),o&&o(!0)}}},t.createElement("span",{className:"ellipsis-wrapper"},U4(e.value||"")))))))},d6=({title:e,...n})=>{const{activeBlock:a,activeIndexOfBlocks:o,activeIndexOfRenderedBlocks:i,answers:l,saveFormValues:p,saveOthersValue:u,blocks:d,questions:b,renderedBlocks:M,onSubmitHandler:z,isSurveyCompleted:m,pivot:h}=d$(n),{type:f="facebook"}=n,{question_type:O}=a?.question.type_info??{},A=t.useMemo((()=>ke(h?.question)),[h?.question]),v=r(null),[g,y]=s(void 0);let q=!1;const[W,w]=s(!1),[L,R]=s(null),[C,x]=s(null),k=SP({blocks:d,activeIndexOfBlocks:o,renderedBlocks:M,activeIndexOfRenderedBlocks:i,questions:b});if(c((()=>{v.current&&v.current.scroll({top:1e4,behavior:"smooth"})}),[a,l,m]),!a?.question)return null;const E=a?.question.type_info?.scale_properties?.range,T=Array.isArray(E)?E[E.length-1]?.max:void 0,S=(!n.survey.prompt_settings||g)&&(a?.question.choices&&("MULTI_SELECT"===a?.question.type_info?.question_type||"DROPDOWN"===a?.question.type_info?.question_type)&&(a?.question.choices.filter((e=>!e?.meta?.is_deleted))?.length>3||a.question?.choices?.some((e=>e?.meta?.is_others&&!e?.meta?.is_deleted)))||"RANGE"===a?.question.type_info?.question_type&&void 0!==T&&Number(T)>3);return t.createElement(Z4,{title:e,type:"facebook"},t.createElement("div",{className:"fb-chat-body"},t.createElement("div",{className:"fb-msg-container"},t.createElement("div",{className:"fb-scroll-wrapper",ref:v},n.survey.prompt_settings&&t.createElement("div",{className:"fb-prompt-container"},t.createElement(c6,{config:n.survey.prompt_settings,onSelect:e=>y(1===e),promptAccepted:g,placeholders:n.placeholders,type:f})),(!n.survey.prompt_settings||g)&&M.map(((e,r)=>{if(!(!W||e.name!==a.name))return null;const c=e.question.type_info,s=c?.scale_properties,u=s?.labels,O=u?.preference,v=u?.values||[],g=s?.range,y=Number(g?.[0]?.min||0),C=Number(g?.[g.length-1]?.max||v.length);return t.createElement(t.Fragment,{key:e.name},t.createElement("div",{className:"fb-question-container ss-question-container "+(m||r!==M.length-1?"":"active")},t.createElement(n6,{text:e.question.text,placeholders:n.placeholders,pivot:h,rangeToRender:A}),a?.name===e.name&&!l?.formValues?.[e.question.name]&&!S&&t.createElement(a6,{setShowOtherInput:w,setCurrentOtherChoice:R,language:n.language||"en",block:e,placeholders:n.placeholders,saveFormValues:(t,n)=>{p(e,t,n),setTimeout((()=>{!0===n&&SP({blocks:d,activeIndexOfBlocks:o,renderedBlocks:M,activeIndexOfRenderedBlocks:i,questions:b})&&z("COMPLETE")}))},type:f,answers:l})),qe(l.formValues[e.question.name])||e.name===a.name&&!l.commitDirtyValue&&!e.question.choices?.find((t=>t.id===l.formValues[e.question.name]&&t.meta?.is_others))?null:t.createElement("div",{className:"fb-answers-container"},t.createElement("div",{className:"fb-answers"},(()=>{const n=e.question.choices?.find((t=>t.id===l.formValues[e.question.name]&&t.meta?.is_others));if("MESSAGE"!==c?.question_type){if(n)return n.value||"Other";if("RANGE"===c?.question_type){const n=Number(l.formValues[e.question.name]),a=0===y&&1===C&&"THUMBS"!==c?.type_variant,o=c?.type_variant;if(a||"THUMBS"===o||"TICK"===o||"EMOJI"===o&&v.length<=2)return t.createElement("div",{className:"fb-answer-text"},t.createElement(G4,{rating:n,question:e.question,type:"facebook"})," ","all"===O&&U4(0===y?v[n]||"":v[n-1]||""));if("TEXT"===o)return t.createElement("div",{className:"fb-answer-text"},t.createElement(G4,{rating:n,question:e.question,type:"facebook"})," ","all"===O&&U4(0===y?v[n]||"":v[n-1]||""));if("NUMBER"===o)return t.createElement("div",{className:"fb-answer-text"},n,("all"===O||"edges"===O&&(n===y||n===C))&&` ${U4(v[n-(0===y&&n===C&&v.length<C+1?1:y)]||"")}`);if("EMOJI"===o||"STAR"===o)return t.createElement("div",{className:"fb-answer-text"},t.createElement("div",{className:"EMOJI"===o?"fb-emoji-rating-wrapper":"fb-star-rating-wrapper"},t.createElement(G4,{rating:n,question:e.question,type:"facebook"}),("all"===O||"edges"===O&&(1===n||n===v.length))&&t.createElement("span",null," ",U4(0===y?v[n]||"":v[n-1]||""))))}if("BOOLEAN"===c?.question_type||"RESOLUTION"===c?.question_type){const n=Number(l.formValues[e.question.name]);if("RESOLUTION"===c?.question_type){const e=a?.question?.dependent_blocks?.find((e=>"TY"===e?.next_block));e&&(q=e?.choice_id?.includes(l?.formValues?.[a?.question?.name]?.toString()||""))}return t.createElement("div",{className:"fb-answer-text"},t.createElement(G4,{rating:n,question:e.question,type:"facebook"})," ","all"===O&&U4(v[n]||""))}if("DROPDOWN"===c?.question_type||"MULTI_SELECT"===c?.question_type){const n=U4(e.question.choices?.find((t=>t.id===l.formValues[e.question.name]))?.value||l.formValues[e.question.name]?.toString()||"");return t.createElement("div",{className:"fb-answer-text"},n)}return t.createElement("div",{className:"fb-answer-text"},l.formValues[e.question.name]?.toString())}})())),(!W||L&&L.id!==e.question.name)&&e.question.choices?.find((t=>t.id===l.formValues[e.question.name]&&t.meta?.is_others))&&t.createElement("div",{className:"fb-question-container ss-question-container"},t.createElement(n6,{text:e.question.type_info?.comment_placeholder||"Enter your comment",placeholders:n.placeholders,pivot:h,rangeToRender:A})),l.others&&l.others[e.question.name]&&t.createElement("div",{className:"fb-answers-container"},t.createElement("div",{className:"fb-answers"},l.others[e.question.name])))})),W&&L&&t.createElement("div",{className:"fb-question-container ss-question-container "},t.createElement(n6,{text:L?.placeholder||"Enter your comment",placeholders:n.placeholders,pivot:h,rangeToRender:A})),(m||q)&&t.createElement("div",{className:"fb-question-container ss-question-container",id:"new"},t.createElement(n6,{text:NP({pivotQn:h?.question,pivotQnAnswer:h?.answer,block:n.survey.blocks?.find((e=>"TY"===e.name)),questions:b})?.text,placeholders:n.placeholders,pivot:h,rangeToRender:A}))))),S&&!W&&!m&&t.createElement("div",{className:"fb-quick-reply-area"},t.createElement("div",{className:"fb-quick-reply-buttons scrollable"},(()=>{const e=a?.question.type_info,n=e?.scale_properties,o=n?.labels,i=o?.values||[],r=n?.range;return"RANGE"===e?.question_type?i.map(((n,c)=>t.createElement("button",{key:c,className:"fb-quick-reply-button",onClick:()=>{p(a,c+1,!0),k&&z("COMPLETE")}},"STAR"===e?.type_variant?t.createElement("div",{className:"fb-star-rating-wrapper"},t.createElement("span",null,Array.from({length:c+1},((e,n)=>t.createElement(Ge,{key:`qr-star-${n}`,name:"whatsapp-star",id:`qr-star-${n}`})))),"all"===o?.preference||"edges"===o?.preference&&(0===c||c===i.length-1)?` ${U4(n||"")}`:""):"EMOJI"===e?.type_variant?t.createElement("div",{className:"fb-emoji-rating-wrapper"},t.createElement("span",null,F4(c+1,Number(r?.[r.length-1]?.max)||10)),"all"===o?.preference||"edges"===o?.preference&&(0===c||c===i.length-1)?` ${U4(n||"")}`:""):"NUMBER"===e?.type_variant?t.createElement("div",{className:"fb-emoji-rating-wrapper"},t.createElement("span",null,c+1),"all"===o?.preference||"edges"===o?.preference&&(0===c||c===i.length-1)?` ${U4(n||"")}`:""):U4(n||"")))):a?.question.choices?.filter((e=>!e?.meta?.is_deleted))?.map((e=>t.createElement("button",{key:e.id,className:"fb-quick-reply-button",onClick:()=>{const t=e.meta?.is_others;if(t||p(a,e.id||"",!0),t){p(a,e.id||"",!0);const t=a.question.type_info?.comment_placeholder||"";R({id:a.question.name,placeholder:t,value:e.id||""}),w(!0)}else k&&z("COMPLETE")}},t.createElement("span",{className:"fb-ellipsis-wrapper"},U4(e?.value||"")))))})())),t.createElement("div",{className:"fb-input-bar"},t.createElement("div",{className:"fb-input-icons"},t.createElement(Ge,{name:"facebook-actions"}),t.createElement(Ge,{name:"facebook-camera"}),t.createElement(Ge,{name:"facebook-photo"}),t.createElement(Ge,{name:"facebook-mic"})),t.createElement(t6,{onChange:e=>{if(W&&L)x(e.target.value);else{["PARAGRAPH","TEXT","NUMBER","DATE_TIME"].includes(O||"")&&!m&&p(a,e.target.value)}},value:m?"":W&&L?l.others?.[L.id]||C||"":["PARAGRAPH","TEXT","NUMBER","DATE_TIME"].includes(O||"")&&l.formValues[a.question.name]?l.formValues[a.question.name]:"",activeBlock:a,autoFocus:W||["PARAGRAPH","TEXT","NUMBER","DATE_TIME"].includes(O||""),onSubmit:()=>{W&&L?(u(L.id,C),w(!1),x(null),R(null),k&&z("COMPLETE")):(p(a,l?.formValues?.[a.question.name],!0),k&&z("COMPLETE"))}})))},{entries:b6,setPrototypeOf:M6,isFrozen:z6,getPrototypeOf:m6,getOwnPropertyDescriptor:h6}=Object;let{freeze:f6,seal:O6,create:A6}=Object,{apply:v6,construct:g6}="undefined"!=typeof Reflect&&Reflect;f6||(f6=function(e){return e}),O6||(O6=function(e){return e}),v6||(v6=function(e,t,n){return e.apply(t,n)}),g6||(g6=function(e,t){return new e(...t)});const y6=_6(Array.prototype.forEach),q6=_6(Array.prototype.lastIndexOf),W6=_6(Array.prototype.pop),w6=_6(Array.prototype.push),L6=_6(Array.prototype.splice),R6=_6(String.prototype.toLowerCase),C6=_6(String.prototype.toString),x6=_6(String.prototype.match),k6=_6(String.prototype.replace),E6=_6(String.prototype.indexOf),T6=_6(String.prototype.trim),S6=_6(Object.prototype.hasOwnProperty),N6=_6(RegExp.prototype.test),P6=($6=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g6($6,t)});var $6;function _6(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,a=new Array(n>1?n-1:0),o=1;o<n;o++)a[o-1]=arguments[o];return v6(e,t,a)}}function B6(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:R6;M6&&M6(e,null);let a=t.length;for(;a--;){let o=t[a];if("string"==typeof o){const e=n(o);e!==o&&(z6(t)||(t[a]=e),o=e)}e[o]=!0}return e}function H6(e){for(let t=0;t<e.length;t++){S6(e,t)||(e[t]=null)}return e}function D6(e){const t=A6(null);for(const[n,a]of b6(e)){S6(e,n)&&(Array.isArray(a)?t[n]=H6(a):a&&"object"==typeof a&&a.constructor===Object?t[n]=D6(a):t[n]=a)}return t}function I6(e,t){for(;null!==e;){const n=h6(e,t);if(n){if(n.get)return _6(n.get);if("function"==typeof n.value)return _6(n.value)}e=m6(e)}return function(){return null}}const V6=f6(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),X6=f6(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),j6=f6(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),F6=f6(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),U6=f6(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),G6=f6(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Y6=f6(["#text"]),Z6=f6(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),K6=f6(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Q6=f6(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),J6=f6(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),e8=O6(/\{\{[\w\W]*|[\w\W]*\}\}/gm),t8=O6(/<%[\w\W]*|[\w\W]*%>/gm),n8=O6(/\$\{[\w\W]*/gm),a8=O6(/^data-[\-\w.\u00B7-\uFFFF]+$/),o8=O6(/^aria-[\-\w]+$/),i8=O6(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),r8=O6(/^(?:\w+script|data):/i),c8=O6(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),s8=O6(/^html$/i),l8=O6(/^[a-z][.\w]*(-[.\w]+)+$/i);var p8=Object.freeze({__proto__:null,ARIA_ATTR:o8,ATTR_WHITESPACE:c8,CUSTOM_ELEMENT:l8,DATA_ATTR:a8,DOCTYPE_NAME:s8,ERB_EXPR:t8,IS_ALLOWED_URI:i8,IS_SCRIPT_OR_DATA:r8,MUSTACHE_EXPR:e8,TMPLIT_EXPR:n8});const u8=1,d8=3,b8=7,M8=8,z8=9,m8=function(){return"undefined"==typeof window?null:window};var h8=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m8();const n=t=>e(t);if(n.version="3.2.6",n.removed=[],!t||!t.document||t.document.nodeType!==z8||!t.Element)return n.isSupported=!1,n;let{document:a}=t;const o=a,i=o.currentScript,{DocumentFragment:r,HTMLTemplateElement:c,Node:s,Element:l,NodeFilter:p,NamedNodeMap:u=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:d,DOMParser:b,trustedTypes:M}=t,z=l.prototype,m=I6(z,"cloneNode"),h=I6(z,"remove"),f=I6(z,"nextSibling"),O=I6(z,"childNodes"),A=I6(z,"parentNode");if("function"==typeof c){const e=a.createElement("template");e.content&&e.content.ownerDocument&&(a=e.content.ownerDocument)}let v,g="";const{implementation:y,createNodeIterator:q,createDocumentFragment:W,getElementsByTagName:w}=a,{importNode:L}=o;let R={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof b6&&"function"==typeof A&&y&&void 0!==y.createHTMLDocument;const{MUSTACHE_EXPR:C,ERB_EXPR:x,TMPLIT_EXPR:k,DATA_ATTR:E,ARIA_ATTR:T,IS_SCRIPT_OR_DATA:S,ATTR_WHITESPACE:N,CUSTOM_ELEMENT:P}=p8;let{IS_ALLOWED_URI:$}=p8,_=null;const B=B6({},[...V6,...X6,...j6,...U6,...Y6]);let H=null;const D=B6({},[...Z6,...K6,...Q6,...J6]);let I=Object.seal(A6(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),V=null,X=null,j=!0,F=!0,U=!1,G=!0,Y=!1,Z=!0,K=!1,Q=!1,J=!1,ee=!1,te=!1,ne=!1,ae=!0,oe=!1,ie=!0,re=!1,ce={},se=null;const le=B6({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let pe=null;const ue=B6({},["audio","video","img","source","image","track"]);let de=null;const be=B6({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Me="http://www.w3.org/1998/Math/MathML",ze="http://www.w3.org/2000/svg",me="http://www.w3.org/1999/xhtml";let he=me,fe=!1,Oe=null;const Ae=B6({},[Me,ze,me],C6);let ve=B6({},["mi","mo","mn","ms","mtext"]),ge=B6({},["annotation-xml"]);const ye=B6({},["title","style","font","a","script"]);let qe=null;const We=["application/xhtml+xml","text/html"];let we=null,Le=null;const Re=a.createElement("form"),Ce=function(e){return e instanceof RegExp||e instanceof Function},xe=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Le||Le!==e){if(e&&"object"==typeof e||(e={}),e=D6(e),qe=-1===We.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,we="application/xhtml+xml"===qe?C6:R6,_=S6(e,"ALLOWED_TAGS")?B6({},e.ALLOWED_TAGS,we):B,H=S6(e,"ALLOWED_ATTR")?B6({},e.ALLOWED_ATTR,we):D,Oe=S6(e,"ALLOWED_NAMESPACES")?B6({},e.ALLOWED_NAMESPACES,C6):Ae,de=S6(e,"ADD_URI_SAFE_ATTR")?B6(D6(be),e.ADD_URI_SAFE_ATTR,we):be,pe=S6(e,"ADD_DATA_URI_TAGS")?B6(D6(ue),e.ADD_DATA_URI_TAGS,we):ue,se=S6(e,"FORBID_CONTENTS")?B6({},e.FORBID_CONTENTS,we):le,V=S6(e,"FORBID_TAGS")?B6({},e.FORBID_TAGS,we):D6({}),X=S6(e,"FORBID_ATTR")?B6({},e.FORBID_ATTR,we):D6({}),ce=!!S6(e,"USE_PROFILES")&&e.USE_PROFILES,j=!1!==e.ALLOW_ARIA_ATTR,F=!1!==e.ALLOW_DATA_ATTR,U=e.ALLOW_UNKNOWN_PROTOCOLS||!1,G=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Y=e.SAFE_FOR_TEMPLATES||!1,Z=!1!==e.SAFE_FOR_XML,K=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,ne=e.RETURN_TRUSTED_TYPE||!1,J=e.FORCE_BODY||!1,ae=!1!==e.SANITIZE_DOM,oe=e.SANITIZE_NAMED_PROPS||!1,ie=!1!==e.KEEP_CONTENT,re=e.IN_PLACE||!1,$=e.ALLOWED_URI_REGEXP||i8,he=e.NAMESPACE||me,ve=e.MATHML_TEXT_INTEGRATION_POINTS||ve,ge=e.HTML_INTEGRATION_POINTS||ge,I=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Ce(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(I.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Ce(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(I.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(I.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Y&&(F=!1),te&&(ee=!0),ce&&(_=B6({},Y6),H=[],!0===ce.html&&(B6(_,V6),B6(H,Z6)),!0===ce.svg&&(B6(_,X6),B6(H,K6),B6(H,J6)),!0===ce.svgFilters&&(B6(_,j6),B6(H,K6),B6(H,J6)),!0===ce.mathMl&&(B6(_,U6),B6(H,Q6),B6(H,J6))),e.ADD_TAGS&&(_===B&&(_=D6(_)),B6(_,e.ADD_TAGS,we)),e.ADD_ATTR&&(H===D&&(H=D6(H)),B6(H,e.ADD_ATTR,we)),e.ADD_URI_SAFE_ATTR&&B6(de,e.ADD_URI_SAFE_ATTR,we),e.FORBID_CONTENTS&&(se===le&&(se=D6(se)),B6(se,e.FORBID_CONTENTS,we)),ie&&(_["#text"]=!0),K&&B6(_,["html","head","body"]),_.table&&(B6(_,["tbody"]),delete V.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw P6('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw P6('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');v=e.TRUSTED_TYPES_POLICY,g=v.createHTML("")}else void 0===v&&(v=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const a="data-tt-policy-suffix";t&&t.hasAttribute(a)&&(n=t.getAttribute(a));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}}(M,i)),null!==v&&"string"==typeof g&&(g=v.createHTML(""));f6&&f6(e),Le=e}},ke=B6({},[...X6,...j6,...F6]),Ee=B6({},[...U6,...G6]),Te=function(e){w6(n.removed,{element:e});try{A(e).removeChild(e)}catch(t){h(e)}},Se=function(e,t){try{w6(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){w6(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ee||te)try{Te(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ne=function(e){let t=null,n=null;if(J)e="<remove></remove>"+e;else{const t=x6(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===qe&&he===me&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=v?v.createHTML(e):e;if(he===me)try{t=(new b).parseFromString(o,qe)}catch(e){}if(!t||!t.documentElement){t=y.createDocument(he,"template",null);try{t.documentElement.innerHTML=fe?g:o}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(a.createTextNode(n),i.childNodes[0]||null),he===me?w.call(t,K?"html":"body")[0]:K?t.documentElement:i},Pe=function(e){return q.call(e.ownerDocument||e,e,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},$e=function(e){return e instanceof d&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof u)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},_e=function(e){return"function"==typeof s&&e instanceof s};function Be(e,t,a){y6(e,(e=>{e.call(n,t,a,Le)}))}const He=function(e){let t=null;if(Be(R.beforeSanitizeElements,e,null),$e(e))return Te(e),!0;const a=we(e.nodeName);if(Be(R.uponSanitizeElement,e,{tagName:a,allowedTags:_}),Z&&e.hasChildNodes()&&!_e(e.firstElementChild)&&N6(/<[/\w!]/g,e.innerHTML)&&N6(/<[/\w!]/g,e.textContent))return Te(e),!0;if(e.nodeType===b8)return Te(e),!0;if(Z&&e.nodeType===M8&&N6(/<[/\w]/g,e.data))return Te(e),!0;if(!_[a]||V[a]){if(!V[a]&&Ie(a)){if(I.tagNameCheck instanceof RegExp&&N6(I.tagNameCheck,a))return!1;if(I.tagNameCheck instanceof Function&&I.tagNameCheck(a))return!1}if(ie&&!se[a]){const t=A(e)||e.parentNode,n=O(e)||e.childNodes;if(n&&t){for(let a=n.length-1;a>=0;--a){const o=m(n[a],!0);o.__removalCount=(e.__removalCount||0)+1,t.insertBefore(o,f(e))}}}return Te(e),!0}return e instanceof l&&!function(e){let t=A(e);t&&t.tagName||(t={namespaceURI:he,tagName:"template"});const n=R6(e.tagName),a=R6(t.tagName);return!!Oe[e.namespaceURI]&&(e.namespaceURI===ze?t.namespaceURI===me?"svg"===n:t.namespaceURI===Me?"svg"===n&&("annotation-xml"===a||ve[a]):Boolean(ke[n]):e.namespaceURI===Me?t.namespaceURI===me?"math"===n:t.namespaceURI===ze?"math"===n&&ge[a]:Boolean(Ee[n]):e.namespaceURI===me?!(t.namespaceURI===ze&&!ge[a])&&!(t.namespaceURI===Me&&!ve[a])&&!Ee[n]&&(ye[n]||!ke[n]):!("application/xhtml+xml"!==qe||!Oe[e.namespaceURI]))}(e)?(Te(e),!0):"noscript"!==a&&"noembed"!==a&&"noframes"!==a||!N6(/<\/no(script|embed|frames)/i,e.innerHTML)?(Y&&e.nodeType===d8&&(t=e.textContent,y6([C,x,k],(e=>{t=k6(t,e," ")})),e.textContent!==t&&(w6(n.removed,{element:e.cloneNode()}),e.textContent=t)),Be(R.afterSanitizeElements,e,null),!1):(Te(e),!0)},De=function(e,t,n){if(ae&&("id"===t||"name"===t)&&(n in a||n in Re))return!1;if(F&&!X[t]&&N6(E,t));else if(j&&N6(T,t));else if(!H[t]||X[t]){if(!(Ie(e)&&(I.tagNameCheck instanceof RegExp&&N6(I.tagNameCheck,e)||I.tagNameCheck instanceof Function&&I.tagNameCheck(e))&&(I.attributeNameCheck instanceof RegExp&&N6(I.attributeNameCheck,t)||I.attributeNameCheck instanceof Function&&I.attributeNameCheck(t))||"is"===t&&I.allowCustomizedBuiltInElements&&(I.tagNameCheck instanceof RegExp&&N6(I.tagNameCheck,n)||I.tagNameCheck instanceof Function&&I.tagNameCheck(n))))return!1}else if(de[t]);else if(N6($,k6(n,N,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==E6(n,"data:")||!pe[e]){if(U&&!N6(S,k6(n,N,"")));else if(n)return!1}else;return!0},Ie=function(e){return"annotation-xml"!==e&&x6(e,P)},Ve=function(e){Be(R.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||$e(e))return;const a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:H,forceKeepAttr:void 0};let o=t.length;for(;o--;){const i=t[o],{name:r,namespaceURI:c,value:s}=i,l=we(r),p=s;let u="value"===r?p:T6(p);if(a.attrName=l,a.attrValue=u,a.keepAttr=!0,a.forceKeepAttr=void 0,Be(R.uponSanitizeAttribute,e,a),u=a.attrValue,!oe||"id"!==l&&"name"!==l||(Se(r,e),u="user-content-"+u),Z&&N6(/((--!?|])>)|<\/(style|title)/i,u)){Se(r,e);continue}if(a.forceKeepAttr)continue;if(!a.keepAttr){Se(r,e);continue}if(!G&&N6(/\/>/i,u)){Se(r,e);continue}Y&&y6([C,x,k],(e=>{u=k6(u,e," ")}));const d=we(e.nodeName);if(De(d,l,u)){if(v&&"object"==typeof M&&"function"==typeof M.getAttributeType)if(c);else switch(M.getAttributeType(d,l)){case"TrustedHTML":u=v.createHTML(u);break;case"TrustedScriptURL":u=v.createScriptURL(u)}if(u!==p)try{c?e.setAttributeNS(c,r,u):e.setAttribute(r,u),$e(e)?Te(e):W6(n.removed)}catch(t){Se(r,e)}}else Se(r,e)}Be(R.afterSanitizeAttributes,e,null)},Xe=function e(t){let n=null;const a=Pe(t);for(Be(R.beforeSanitizeShadowDOM,t,null);n=a.nextNode();)Be(R.uponSanitizeShadowNode,n,null),He(n),Ve(n),n.content instanceof r&&e(n.content);Be(R.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null,i=null,c=null,l=null;if(fe=!e,fe&&(e="\x3c!--\x3e"),"string"!=typeof e&&!_e(e)){if("function"!=typeof e.toString)throw P6("toString is not a function");if("string"!=typeof(e=e.toString()))throw P6("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Q||xe(t),n.removed=[],"string"==typeof e&&(re=!1),re){if(e.nodeName){const t=we(e.nodeName);if(!_[t]||V[t])throw P6("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof s)a=Ne("\x3c!----\x3e"),i=a.ownerDocument.importNode(e,!0),i.nodeType===u8&&"BODY"===i.nodeName||"HTML"===i.nodeName?a=i:a.appendChild(i);else{if(!ee&&!Y&&!K&&-1===e.indexOf("<"))return v&&ne?v.createHTML(e):e;if(a=Ne(e),!a)return ee?null:ne?g:""}a&&J&&Te(a.firstChild);const p=Pe(re?e:a);for(;c=p.nextNode();)He(c),Ve(c),c.content instanceof r&&Xe(c.content);if(re)return e;if(ee){if(te)for(l=W.call(a.ownerDocument);a.firstChild;)l.appendChild(a.firstChild);else l=a;return(H.shadowroot||H.shadowrootmode)&&(l=L.call(o,l,!0)),l}let u=K?a.outerHTML:a.innerHTML;return K&&_["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&N6(s8,a.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+a.ownerDocument.doctype.name+">\n"+u),Y&&y6([C,x,k],(e=>{u=k6(u,e," ")})),v&&ne?v.createHTML(u):u},n.setConfig=function(){xe(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Q=!0},n.clearConfig=function(){Le=null,Q=!1},n.isValidAttribute=function(e,t,n){Le||xe({});const a=we(e),o=we(t);return De(a,o,n)},n.addHook=function(e,t){"function"==typeof t&&w6(R[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=q6(R[e],t);return-1===n?void 0:L6(R[e],n,1)[0]}return W6(R[e])},n.removeHooks=function(e){R[e]=[]},n.removeAllHooks=function(){R={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();const f8=t.memo((e=>{const{meta_image:n,meta_title:a,meta_description:o,meta_host:i,short_url:r,message:c,channel:s}=e;let l="",p="";if(i){let e=i;e.endsWith("/")||(e+="/"),r&&(e+=r),l=e;try{p=new URL(e).hostname}catch(t){console.warn("Invalid URL provided:",e)}}const u=Boolean(n),d=("fsc-link-preview "+("whatsapp"===s?"fsc-link-preview--whatsapp":"")).trim(),b=("fsc-link-preview__meta "+(u?"":"fsc-link-preview__meta--no-logo")).trim(),M=u||p||a||o;return t.createElement("div",{className:d},M&&t.createElement("div",{className:b},u&&t.createElement("div",{className:"fsc-link-preview__meta__logo"},t.createElement("img",{src:n,alt:"page logo",loading:"lazy"})),p&&t.createElement("div",{className:"fsc-link-preview__meta__domain"},p),a&&t.createElement("div",{className:"fsc-link-preview__meta__title"},a),o&&t.createElement("div",{className:"fsc-link-preview__meta__description"},o)),c&&t.createElement("div",{className:"fsc-link-preview__message",dangerouslySetInnerHTML:{__html:h8.sanitize(c)}}),l&&t.createElement("div",{className:"fsc-link-preview__url"},t.createElement("a",{href:l,target:"_blank",rel:"noopener noreferrer","aria-label":`Visit ${p||l}`},l)))}));f8.displayName="LinkPreview";const O8=({block:e,props:n,answers:a,questions:o,pivot:i})=>t.createElement("div",{className:"reply-block"},t.createElement("p",{className:"user"},"Acme.inc"),t.createElement("p",{className:"question",dangerouslySetInnerHTML:{__html:h8.sanitize(Ee({questionText:e.question.text||"",placeholders:n.placeholders,npsRating:Te({theme:"nps",answers:a,questions:o})??"",npsRatingLabel:Se({theme:"nps",answers:a,questions:o}),csatRating:Te({theme:"csat",answers:a,questions:o})??"",csatRatingLabel:Se({theme:"csat",answers:a,questions:o}),cesRating:Te({theme:"ces",answers:a,questions:o})??"",cesRatingLabel:Se({theme:"ces",answers:a,questions:o}),preference:i?.question.type_info?.scale_properties?.labels?.preference,isPreview:!0}))}})),A8=({block:e,activeBlock:n,answers:a,props:o,questions:i,pivot:r,setRedirectToThankYouPage:c})=>{const{type:s="whatsapp"}=o,l=e.question?.type_info?.question_type,p=e.question.type_info?.scale_properties?.labels?.preference,u=e.question.type_info?.scale_properties?.labels?.values||[];if(e.name===n.name&&!a.commitDirtyValue||ae.isNil(a.formValues[e.question.name]))return null;if("RESOLUTION"===l||"BOOLEAN"===l){if("RESOLUTION"===l){const e=n?.question?.dependent_blocks?.find((e=>e?.next_block?.includes("TY")));e&&c&&c(e?.choice_id?.includes(a?.formValues?.[n?.question?.name]?.toString()||""))}const p=Number(a.formValues[e.question.name]);return t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},t.createElement(t.Fragment,null,"whatsapp"===s&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},"whatsapp"===s&&"TEXT"!==e.question.type_info?.type_variant&&t.createElement(G4,{rating:p,question:e?.question,type:s}),"instagram"===s&&t.createElement(G4,{rating:p,question:e?.question,type:s})," ","all"===e.question.type_info?.scale_properties?.labels?.preference&&U4(e.question.type_info?.scale_properties?.labels?.values?.[p]||"")))))}if("CONSENT"===l)return t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"whatsapp"===s&&a.formValues[e.question.name]&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},a.formValues[e.question.name]?.toString())));if("RANGE"===l){const{range:n}=e?.question?.type_info?.scale_properties||{},c=Number(n?.[0]?.min),l=Number(n?.[n.length-1]?.max),d=0===c&&1===l&&"THUMBS"!==e.question.type_info?.type_variant,b=Number(a.formValues[e.question.name]),M=U4(0===c?u[b]:u[b-1]),z=e.question.type_info?.type_variant;if(d)return t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"whatsapp"===s&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},"whatsapp"===s&&"TEXT"!==e.question.type_info?.type_variant&&t.createElement(G4,{type:s,rating:Number(a.formValues[e.question.name]),question:e?.question}),"instagram"===s&&t.createElement(G4,{type:s,rating:b,question:e?.question})," ","all"===e.question.type_info?.scale_properties?.labels?.preference&&M)));if("TEXT"===z)return t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"whatsapp"===s&&a.formValues[e.question.name]&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},M)));if("NUMBER"===z){const n=0===c?Number(b)+1:b;return t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"whatsapp"===s&&n&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},t.createElement("div",{className:"star-rating-wrapper"},"instagram"===s&&t.createElement("span",null,Number(a.formValues[e.question.name])),"whatsapp"===s&&t.createElement(G4,{rating:Number(a.formValues[e.question.name]),question:e?.question,type:s})," ","all"===p||"edges"===p&&(1===n||n===u.length)?M:null))))}if("EMOJI"===z&&"instagram"===s)return t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},t.createElement("div",{className:"answer-text"},t.createElement("div",{className:"star-rating-wrapper"},t.createElement("span",null,F4(b,l||10))," ","all"===p||"edges"===p&&(1===a.formValues[e.question.name]||a.formValues[e.question.name]===u.length)?M:null))))}return"DROPDOWN"===l?t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"whatsapp"===s&&a.formValues[e.question.name]&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},e.question.choices?.find((t=>t.id===a.formValues[e.question.name]))?.value?U4(e.question.choices?.find((t=>t.id===a.formValues[e.question.name]))?.value||""):U4(a.formValues[e.question.name]?.toString()||"")))):t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"THUMBS"===e.question.type_info?.type_variant?t.createElement(t.Fragment,null,"whatsapp"===s&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},t.createElement(G4,{rating:Number(a.formValues[e.question.name]),question:e?.question,type:s}),"all"===e.question.type_info?.scale_properties?.labels?.preference&&U4(e.question.type_info?.scale_properties?.labels?.values?.[Number(a.formValues[e.question.name])]||""))):"EMOJI"===e.question.type_info?.type_variant||"STAR"===e.question.type_info?.type_variant||"NUMBER"===e.question.type_info?.type_variant?t.createElement(t.Fragment,null,"whatsapp"===s&&a.formValues[e.question.name]&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},t.createElement("div",{className:"star-rating-wrapper"},t.createElement(G4,{rating:Number(a.formValues[e.question.name]),question:e?.question,type:s})," ","all"===p||"edges"===p&&(1===a.formValues[e.question.name]||a.formValues[e.question.name]===u.length)?U4(u[Number(a.formValues[e.question.name])-1]):null))):"DROPDOWN"===e.question.type_info?.question_type||"MULTI_SELECT"===e.question.type_info?.question_type?t.createElement(t.Fragment,null,U4(e.question.choices?.find((t=>t.id===a.formValues[e.question.name]))?.value||"")||U4(a.formValues[e.question.name]?.toString()||"")):t.createElement(t.Fragment,null,a.formValues[e.question.name]?.toString())))},v8=e=>{const{activeBlock:n,activeIndexOfBlocks:a,activeIndexOfRenderedBlocks:o,answers:i,saveFormValues:l,saveOthersValue:p,blocks:u,questions:d,renderedBlocks:b,onSubmitHandler:M,isSurveyCompleted:z,pivot:m}=d$(e),{type:h="whatsapp",title:f="Acme.inc"}=e,{question_type:O}=n?.question.type_info??{},A=t.useMemo((()=>ke(m?.question)),[m?.question]),v=r(null),[g,y]=s(void 0),[q,W]=s(!1),[w,L]=s(!1),[R,C]=s(null),[x,k]=s(null),E=SP({blocks:u,activeIndexOfBlocks:a,renderedBlocks:b,activeIndexOfRenderedBlocks:o,questions:d});if(c((()=>{v.current&&v.current.scroll({top:v.current.scrollHeight,behavior:"smooth"})}),[n,i,z]),!n||!n.question)return null;const T=["PARAGRAPH","DATE","DATE_TIME","NUMBER","TEXT"].includes(O||""),S="instagram"===h,N=t.createElement(t.Fragment,null,t.createElement("div",{className:"msg-container"},t.createElement("div",{className:"scroll-wrapper",ref:v},e.survey.prompt_settings?t.createElement(c6,{config:e.survey.prompt_settings,onSelect:e=>{y(1===e)},promptAccepted:g,placeholders:e.placeholders,type:h}):null,!e.survey.prompt_settings||g?b.map(((r,c)=>!w||r.name!==n.name?t.createElement(t.Fragment,null,t.createElement("div",{className:"question-container ss-question-container "+(z||c!==b.length-1?"":"PARAGRAPH"===O||"TEXT"===O||"NUMBER"===O?"input-active":"active")},t.createElement(n6,{text:r.question.text,placeholders:e.placeholders,pivot:m,rangeToRender:A}),t.createElement(a6,{language:e.language||"en",block:r,placeholders:e.placeholders,setCurrentOtherChoice:C,setShowOtherInput:L,saveFormValues:(e,t)=>{l(r,e,t),setTimeout((()=>{!0===t&&SP({blocks:u,activeIndexOfBlocks:a,renderedBlocks:b,activeIndexOfRenderedBlocks:o,questions:d})&&M("COMPLETE")}))},type:h,answers:i})),t.createElement(A8,{block:r,activeBlock:n,questions:d,answers:i,props:e,pivot:m,setRedirectToThankYouPage:W}),(!w||R&&R.id!==r.question.name)&&r.question.choices?.find((e=>e.id===i.formValues[r.question.name]&&e.meta?.is_others))&&t.createElement("div",{className:"question-container ss-question-container"},t.createElement(n6,{text:r.question.type_info?.comment_placeholder||"Please specify",placeholders:e.placeholders,pivot:m,rangeToRender:A})),i.others&&i.others[r.question.name]&&t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},i.others[r.question.name]))):null)):null,w&&R&&t.createElement("div",{className:"question-container ss-question-container active"},t.createElement(n6,{text:R?.placeholder||"",placeholders:e.placeholders,pivot:m,rangeToRender:A})),(z||q)&&t.createElement("div",{className:"question-container ss-question-container",id:"new"},t.createElement(n6,{text:NP({pivotQn:m?.question,pivotQnAnswer:m?.answer,block:e.survey.blocks?.find((e=>e.name?.includes("TY"))),questions:d})?.text,placeholders:e.placeholders,pivot:m,rangeToRender:A})))),t.createElement(e6,{onChange:e=>{w&&R?k(e.target.value):T&&!z&&l(n,e.target.value)},value:z?"":w&&R?i.others?.[R.id]||x||"":i.formValues[n.question.name]?i.formValues[n.question.name]:"",activeBlock:!0,autoFocus:T,onSubmit:()=>{w&&R?(p(R.id,x),L(!1),k(null),C(null)):l(n,i?.formValues?.[n.question.name],!0),E&&M("COMPLETE")}}));return S?t.createElement(Z4,{type:"instagram",title:f},t.createElement("div",{className:`${h} whatsapp-container`},N)):t.createElement(Z4,{type:"whatsapp",title:f},t.createElement("div",{className:`${h} whatsapp-container`},N))},g8=e=>"facebook"===e.channel?t.createElement("div",{className:`${e.channel} facebook-container fb-link-preview`},t.createElement(Z4,{type:"facebook"},t.createElement("div",{className:"msg-container"},t.createElement("div",{className:"scroll-wrapper"},t.createElement("div",{className:"question-container ss-question-container active"},t.createElement(f8,{...e})))),t.createElement("div",{className:"fb-input-bar"},t.createElement("div",{className:"fb-input-icons"},t.createElement(Ge,{name:"facebook-actions"}),t.createElement(Ge,{name:"facebook-camera"}),t.createElement(Ge,{name:"facebook-photo"}),t.createElement(Ge,{name:"facebook-mic"})),t.createElement(t6,null)))):"instagram"===e.channel?t.createElement(Z4,{type:"instagram"},t.createElement("div",{className:`${e.channel} instagram-container`},t.createElement("div",{className:"msg-container"},t.createElement("div",{className:"scroll-wrapper"},t.createElement("div",{className:"question-container ss-question-container active"},t.createElement(f8,{...e})))),t.createElement(e6,{onSubmit:e=>{Ie("LinkPreviewChannel","submitted")}}))):t.createElement(Z4,{type:"whatsapp"},t.createElement("div",{className:`${e.channel} whatsapp-container`},t.createElement("div",{className:"msg-container"},t.createElement("div",{className:"scroll-wrapper"},t.createElement("div",{className:"question-container ss-question-container active"},t.createElement(f8,{...e})))),t.createElement(e6,{onSubmit:e=>{Ie("LinkPreviewChannel","submitted")}}))),y8=e=>{const{survey:n,previewConfig:a}=e,[o,i]=s(!1),[r,c]=s(!1),[l,p]=s({others_meta:{}}),{block:u,question:d,agentName:b,userName:M}=t.useMemo((()=>{const e=n.blocks.find((e=>!e.is_deleted)),t=n.question_details?.questions?.find((t=>t.name===e?.question_name||e?.category?.map((e=>e.question_name)).includes(t.name)));return{block:e,question:t,agentName:a?.agent?.firstName||a?.agent?.lastName?`${a?.agent?.firstName??""} ${a?.agent?.lastName??""}`.trim():"John Doe",userName:a?.user?.firstName||a?.user?.lastName?`${a?.user?.firstName??""} ${a?.user?.lastName??""}`.trim():"Hartmann"}}),[a?.agent?.firstName,a?.agent?.lastName,a?.user?.firstName,a?.user?.lastName,n.blocks,n.question_details?.questions]);return u?.name&&d?.name?t.createElement("div",{className:"web-chat-channel"},t.createElement("div",{className:"wc-header"},t.createElement("div",{className:"wc-h-action-button"},t.createElement(Ge,{name:"arrow-left"})),t.createElement("div",{className:"wc-h-info"},t.createElement("div",{className:"wc-h-info-main wc-wrap-text"},a?.topicName??"Instant support"),t.createElement("div",{className:"wc-h-info-sub wc-wrap-text"},a?.topicDescription??"Typically responds in 5 mins")),t.createElement("div",{className:"wc-h-action-button"},t.createElement(Ge,{name:"close"}))),t.createElement("div",{className:"wc-body"},t.createElement("div",{className:"wc-body-scroll-container"},t.createElement("div",{className:"wc-agent-details"},t.createElement("div",{className:"wc-icon"},a?.agent?.imageUrl?t.createElement("img",{src:a?.agent?.imageUrl,alt:b,className:"wc-a-avatar"}):b?.slice(0,1)),t.createElement("div",{className:"wc-a-info"},t.createElement("div",{className:"wc-a-i-name wc-break-text"},b),t.createElement("div",{className:"wc-a-i-designation wc-break-text"},a?.agent?.designation??"Sr. Customer support agent"))),t.createElement("div",{className:"wc-agent-chat-wrapper"},t.createElement("div",{className:"wc-icon"},a?.user?.imageUrl?t.createElement("img",{src:a?.user?.imageUrl,alt:M,className:"wc-a-avatar"}):M?.slice(0,1)),t.createElement("div",{className:"w-a-c-container"},t.createElement("div",{className:"wc-a-s-name wc-break-text"},M),t.createElement("div",{className:"wc-a-survey-wrapper"},t.createElement(I4,{block:u,question:d,surveyStyle:"card",onAnswer:e=>{p({...e.question.name?{[e.question.name]:e.value}:{},others_meta:{}}),i(!0)},isMobile:!0,theme:e.survey.theme??{},language:e.language,surveyServAssetUrl:e.surveyServAssetUrl,translationVariables:e.translationVariables})),t.createElement("div",{className:"wc-a-timestamp wc-break-text"},a?.timeString??(new Date).toLocaleTimeString())))),t.createElement("div",{className:"wc-footer"},t.createElement("div",{className:"w-f-link wc-wrap-text"},a?.actionText??"Continue chat"))),t.createElement("div",{className:"web-chat-survey-preview"},o&&t.createElement(D4,{answers:l,answerStatus:"PARTIAL",language:e.language,surveyServAssetUrl:e.surveyServAssetUrl,translationVariables:e.translationVariables,preview:!0,isSurveyCompleted:r,onAnsweringPrompt:e=>{},onDismiss:()=>{i(!1)},onClose:()=>{i(!1)},onSubmit:(e,t,n)=>{"COMPLETE"===n&&(c(!0),setTimeout((()=>{t()}),0))},isMobile:!0,placeholders:{},survey:e.survey,surveyType:"compact"}))):null},q8=e=>{Ie("ChannelPreview",e);const{survey:n,answers:a}=CP(e.survey,e.answers);return t.useEffect((()=>{const t=document?.documentElement;!qe(e.surveyServAssetUrl)&&t&&setTimeout((()=>{t.style.setProperty("--fsc-whatsapp-chat-background",`url(${e.surveyServAssetUrl}/survey/whatsapp-chat-bg.svg)`)}),0)}),[e.surveyServAssetUrl]),t.useEffect((()=>{n.theme&&Ne(n.theme,e.surveyServAssetUrl??"")}),[n.theme,e.surveyServAssetUrl]),"chat"===e.channel?t.createElement(y8,{...e,survey:n,answers:a}):"facebook"===e.channel?t.createElement(d6,{...e,type:"facebook",survey:n,answers:a}):"whatsapp"===e.channel||"instagram"===e.channel?t.createElement(v8,{type:e.channel,...e,survey:n,answers:a}):(console.error(`Channel ${e.channel} not supported`),null)},W8=e=>{Ie("ChannelLinkPreview",e);return t.useEffect((()=>{const t=document?.documentElement;!qe(e.surveyServAssetUrl)&&t&&setTimeout((()=>{t.style.setProperty("--fsc-whatsapp-chat-background",`url(${e.surveyServAssetUrl}/survey/whatsapp-chat-bg.svg)`)}),0)}),[e.surveyServAssetUrl]),["whatsapp","instagram","facebook"].includes(e.channel)?t.createElement(g8,{...e}):(console.error(`Channel ${e.channel} not supported`),null)};var w8=Object.freeze({__proto__:null,allPathsLoader:function(e,t){return yi(void 0,void 0,void 0,(function(){return qi(this,(function(n){switch(n.label){case 0:return[4,Promise.resolve().then((function(){return kr}))];case 1:return[2,(0,n.sent().getIconPaths)(e,t)]}}))}))}}),L8=Object.freeze({__proto__:null,splitPathsBySizeLoader:function(e,t){return yi(void 0,void 0,void 0,(function(){var n,a;return qi(this,(function(o){switch(o.label){case 0:return n=qr(e),t!==wr.STANDARD?[3,2]:[4,Promise.resolve().then((function(){return Lr}))];case 1:return a=o.sent(),[3,4];case 2:return[4,Promise.resolve().then((function(){return Rr}))];case 3:a=o.sent(),o.label=4;case 4:return[2,a[n]]}}))}))}});export{ge as ALL_FONTS,Qe as Binary,et as Button,W8 as ChannelLinkPreview,q8 as ChannelPreview,Tt as Checkbox,ve as DEFAULT_FONT,Fq as DatePicker,Uq as DateTimePicker,Fa as Dropdown,ye as FONT_SIZE_OPTIONS,ja as Input,Za as Loader,Ka as PhoneNumberInput,Gq as ProgressBar,I4 as QuestionPreview,IE as RadioGroup,jE as Range,LN as RankOrder,qP as Slider,B4 as Survey,Ya as SurveyFooter,WP as SurveyProgress,wP as TextArea,D4 as WebInAppSurvey};
39
+ */;const f5=({addFilter:e,utils:t})=>{const{Type:n,isString:a,replaceInString:o,guesstimateMimeType:i,getExtensionFromFilename:r,getFilenameFromURL:c}=t,s=(e,t)=>e.some((e=>{return/\*$/.test(e)?(n=e,(/^[^/]+/.exec(t)||[]).pop()===n.slice(0,-2)):e===t;var n})),l=(e,t,n)=>{if(0===t.length)return!0;const o=(e=>{let t="";if(a(e)){const n=c(e),a=r(n);a&&(t=i(a))}else t=e.type;return t})(e);return n?new Promise(((a,i)=>{n(e,o).then((e=>{s(t,e)?a():i()})).catch(i)})):s(t,o)};return e("SET_ATTRIBUTE_TO_OPTION_MAP",(e=>Object.assign(e,{accept:"acceptedFileTypes"}))),e("ALLOW_HOPPER_ITEM",((e,{query:t})=>!t("GET_ALLOW_FILE_TYPE_VALIDATION")||l(e,t("GET_ACCEPTED_FILE_TYPES")))),e("LOAD_FILE",((e,{query:t})=>new Promise(((n,a)=>{if(!t("GET_ALLOW_FILE_TYPE_VALIDATION"))return void n(e);const i=t("GET_ACCEPTED_FILE_TYPES"),r=t("GET_FILE_VALIDATE_TYPE_DETECT_TYPE"),c=l(e,i,r),s=()=>{const e=i.map((e=>t=>null!==e[t]&&(e[t]||t))(t("GET_FILE_VALIDATE_TYPE_LABEL_EXPECTED_TYPES_MAP"))).filter((e=>!1!==e)),n=e.filter(((t,n)=>e.indexOf(t)===n));a({status:{main:t("GET_LABEL_FILE_TYPE_NOT_ALLOWED"),sub:o(t("GET_FILE_VALIDATE_TYPE_LABEL_EXPECTED_TYPES"),{allTypes:n.join(", "),allButLastType:n.slice(0,-1).join(", "),lastType:n[n.length-1]})}})};if("boolean"==typeof c)return c?n(e):s();c.then((()=>{n(e)})).catch(s)})))),{options:{allowFileTypeValidation:[!0,n.BOOLEAN],acceptedFileTypes:[[],n.ARRAY],labelFileTypeNotAllowed:["File is of invalid type",n.STRING],fileValidateTypeLabelExpectedTypes:["Expects {allButLastType} or {lastType}",n.STRING],fileValidateTypeLabelExpectedTypesMap:[{},n.OBJECT],fileValidateTypeDetectType:[null,n.FUNCTION]}}};"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:f5}));K(h5,f5,V$,m5),B3(H3,I3,D3,V3);const O5=b((({onClick:e,maxFileSize:n=16,visible:a=!0,supportedFileFormats:o,translationVariables:i,fileErrors:r},c)=>{const[l,p]=s(!1),u=i?.drop_your_file?i?.drop_your_file:t.createElement(t.Fragment,null,"Drop your file here, or Browse");return t.createElement("div",{ref:c,className:"file-upload-container "+(r?.current?.main?"errored":""),onClick:e,style:{visibility:a?"visible":"hidden"},onDragOver:e=>{e.preventDefault(),e.target.classList.add("push-backward")}}," ",t.createElement(Ge,{name:"file-upload-icon"}),"string"!=typeof u?t.createElement("p",null,u):t.createElement("p",{className:"drop-your-file-container",dangerouslySetInnerHTML:{__html:u}}),t.createElement("p",{className:"max-size"},((e,t,n)=>{if(n&&e&&t)return e.replace(t,n)})(i?.max_file_size,"{{max_file_size}}",String(n))||`Maximum file size : ${n} MB`),t.createElement("p",{className:"support file-formats"},i?.supported_file_formats||"Supported file formats: "," ",(o=o.join(", ")).trim()?t.createElement(t.Fragment,null,l?o:o.slice(0,20)," ",t.createElement("span",{onClick:()=>p(!l),style:{color:"#2C5CC5",textDecoration:"underline",cursor:"pointer"}},l?i?.show_less||"Show less":i?.show_more||"Show more")):"No formats selected"),t.createElement("div",{className:"filepond--drip"}))})),A5=({question:e,onChangeHandler:n,onFileUpload:a,setErrors:o,translationVariables:i,surveyServAssetUrl:c,value:l,preview:p})=>{const[u,d]=s([]),[b,M]=s([]),z=r(),m=e.type_info?.file_field?.max_file_size||10,h=r(null),f=r(),[O,A]=s(!1);let v=!1;t.useEffect((()=>{const t=localStorage.getItem(`uploadedFile-${e?.name}`),n=t?JSON.parse(t):"";n?.source&&(n.options={...n.options,file:{name:l,size:n.fileSize}},l&&d([n]))}),[]);const g=async(t,o)=>{try{if(v)return;if(f.current&&we(h.current)||t){const i=t??f.current.getFiles()?.[0]?.file;if(i&&a){v=!0;const t=await a(i.type,i.size,i.name,e);if(o&&o(!0,50,100),t.startsWith("http")&&c){const a=await fetch(t,{method:"PUT",headers:{"Content-Type":i.type,"Content-Disposition":"attachment"},body:i}),o=new URL(t),r=`${c}${o.pathname}`;if(!a.ok)throw console.error("Error uploading file"),new Error("Error uploading file");localStorage.setItem(`uploadedFile-${e?.name}`,JSON.stringify({source:r,options:{type:"local"},fileSize:f.current.getFiles()?.[0]?.fileSize})),n(i.name)}else n(p?"dummy":null),console.error("Error fetching pre-signed url");v=!1}}}catch(e){throw console.error("error in uploading file",e,"stringified error",JSON.stringify(e)),new Error("Error uploading file")}};return t.useEffect((()=>{(()=>{const t=e.type_info?.file_field?.allowed_file_types,n=Object.keys(Oe).map((e=>{if((t||[]).includes(e))return Oe[e].concat(",")})).join(" ").trim().slice(0,-1);M(n.split(", "))})()}),[]),t.createElement(t.Fragment,null,t.createElement(Q,{ref:f,files:u,labelFileProcessing:i?.uploading_text??"Uploading..",labelFileProcessingComplete:i?.upload_complete??"Upload complete",labelMaxFileSizeExceeded:i?.file_too_large??"The file is too large and cannot be uploaded.",labelMaxFileSize:"",labelTapToCancel:"",labelTapToUndo:"",labelFileTypeNotAllowed:i?.invalid_type??"The file mismatch. Retry by uploading the supported file type.",fileValidateTypeLabelExpectedTypes:"",beforeAddFile:e=>(h.current?.main&&(h.current=null,o({}),d([e]),A(!0)),!0),onremovefile:()=>{O?A(!1):(d([]),o({}),h.current=null,n(null))},allowReplace:!0,server:{process:async(e,t,n,a,o,i)=>{i(!0,0,100);try{await g(t,i),i(!0,100,100),a(t.name)}catch(e){o("An error occurred during upload")}}},onpreparefile:(e,t)=>{const n=new FileReader;n.onloadend=()=>{const t=n.result??"",a=new Blob([t],{type:e.fileType}),o=new File([a],e.filename,{type:e.fileType});g(o)},n.readAsArrayBuffer(t)},onerror:t=>{h.current=t,o({[e.name]:t})},required:!0,credits:!1,allowFileTypeValidation:!0,acceptedFileTypes:b,fileValidateTypeDetectType:(e,t)=>new Promise(((t,n)=>{const a=e.name.split(".");t(`.${a[a.length-1].toLowerCase()}`)})),imageEditor:{legacyDataToImageState:hJ,createEditor:Q3,imageReader:[N3,{}],imageWriter:[P3,{}],imageProcessor:rF,imageEditorAfterWriteImage:({src:e,dest:t,imageState:n})=>new Promise(((a,o)=>{rF(e,{imageReader:N3(),imageWriter:P3({targetSize:{width:128,height:15,fit:"cover"}}),imageState:n}).then((n=>{a([{name:"input_",file:e},{name:"output_",file:t},{name:"thumb_",file:n.dest}])})).catch(o)})),editorOptions:{utils:["crop","finetune","filter","annotate"],imageOrienter:$3(),shapePreprocessor:J3(),...X3,...j3,..._3,locale:{...F3,...G3,...Z3,...Y3,...K3,...U3}}},allowFileSizeValidation:!0,maxFileSize:`${m}MB`,onupdatefiles:e=>{z.current?.classList.remove("push-backward"),e.length&&d(e)},maxFiles:1,name:`${e.id}-files`}),t.createElement(O5,{ref:z,onClick:e=>{const t=e.target;"path"!==t?.tagName&&"P"!==t?.tagName&&(!t?.className||t?.className instanceof SVGAnimatedString||t.className.includes("format-type-toggler"))||f.current.browse()},fileErrors:h,visible:Boolean(!u.length||h.current?.main),maxFileSize:m,translationVariables:{...i,tTimeZones:[{id:"",offset:"",timeZone:""}]},supportedFileFormats:b}),h?.current?.main&&t.createElement("div",{className:"file-error"},t.createElement(Ge,{name:"info"}),t.createElement("span",null,`${h?.current?.main}\n ${h.current?.sub}`)))},v5=e=>{switch(e){case"EMAIL":return"email";case"PHONE":return"tel";case"NUMBER":return"number";default:return"text"}},g5=({question:e,autoFocusDelay:n,onChangeHandler:a,surveyStyle:o,formValues:i,fieldErrors:r,translationVariables:c,language:s,isQuestionBgDark:l,isMobile:p,isWidget:u,widgetStyle:d})=>{const b=e.type_info?.form_fields?.layout,M=e.type_info?.form_fields?.fields;return t.createElement("div",{className:`fsc-form-field-container layout-${(p||u&&"compact"===d?"VERTICAL":b??"VERTICAL").toLowerCase()}`.trim()},M?.map(((p,u)=>{const d="NUMBER"===p?.type||"PHONE"===p.type?18:256;return t.createElement("div",{className:"fsc-form-field",key:p.id},"DATE"!==p?.type&&"DATE_TIME"!==p?.type?t.createElement(t.Fragment,null,"PHONE"===p.type?t.createElement(Ka,{key:u,surveyLayout:o??"card",setFocus:0===u&&"standard"!==o,autoFocusDelay:n,label:p?.label||"",type:"tel",isRequired:!!p.required,showCount:!0,maxLength:d,value:p.id&&i[e.name]?.[p.id]||"",onChangeHandler:(t,n)=>{p.id&&a({...i[e.name]??{},[p.id]:t||null},!0)},isErrored:!(!p.id||!i?.[e.name]?.[p.id])&&!!r?.[p?.id||""],errorText:p.id&&i[e.name]?.[p.id]?r?.[p?.id]:"",translationVariables:c}):t.createElement(ja,{isQuestionBgDark:l,key:u,setFocus:0===u&&"standard"!==o,autoFocusDelay:n,onKeyDown:e=>{"PHONE"===p?.type&&Be(e),"NUMBER"===p?.type&&_e(e)},showCount:!0,maxLength:d,placeholder:"NUMBER"===p?.type?"0":void 0,label:p?.label||"",type:v5(p?.type??"TEXT"),isRequired:!!p.required,value:p.id?i[e.name]?.[p.id]??"":"",onChange:t=>{p.id&&a({...i[e.name]??{},[p.id]:t.target.value.slice(0,d)||null})},onBlur:t=>{if(p.id){const n=i[e.name]?.[p.id],o=t.target.value.slice(0,d);(qe(n)||we(n))&&(qe(o)||we(o))||a?.({...i[e.name]??{},[p.id]:o||null},!1)}},isErrored:!(!p.id||!i?.[e.name]?.[p.id])&&!!r?.[p?.id||""],errorText:p.id&&i[e.name]?.[p.id]?r?.[p?.id]:""})):t.createElement(t.Fragment,null,"DATE_TIME"===p?.type?t.createElement(Uq,{id:p.id??"",name:e.name??"",label:p?.label??"",isRequired:!!p.required,allowOnlyFuture:!!e.type_info?.meta?.allow_future_date,language:s,useAmPm:!e.type_info?.meta?.time_format,showTimezoneSelect:!1,onChange:t=>{a({...i[e.name]??{},...p.id&&{[p.id]:t}},!0)},value:p?.id&&i[e?.name]?.[p?.id],type:"FORM_FIELD",translationVariables:c}):t.createElement(Fq,{id:p.id??"",name:e.name??"",label:p?.label??"",isRequired:!!p.required,allowOnlyFuture:!!e.type_info?.meta?.allow_future_date,language:s,onChange:t=>{a({...i[e.name]??{},...p.id&&{[p.id]:t}},!0)},value:p?.id&&i[e?.name]?.[p?.id],type:"FORM_FIELD",translationVariables:c})))})))};var y5="rovingFocusGroup.onEntryFocus",q5={bubbles:!1,cancelable:!0},W5="RovingFocusGroup",[w5,L5,R5]=Nt(W5),[C5,x5]=ot(W5,[R5]),[k5,E5]=C5(W5),T5=b(((e,t)=>y(w5.Provider,{scope:e.__scopeRovingFocusGroup,children:y(w5.Slot,{scope:e.__scopeRovingFocusGroup,children:y(S5,{...e,ref:t})})})));T5.displayName=W5;var S5=b(((e,t)=>{const{__scopeRovingFocusGroup:a,orientation:o,loop:i=!1,dir:l,currentTabStopId:p,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:d,onEntryFocus:b,preventScrollOnEntryFocus:M=!1,...z}=e,m=r(null),h=at(t,m),f=$t(l),[O=null,A]=st({prop:p,defaultProp:u,onChange:d}),[v,g]=s(!1),q=ct(b),W=L5(a),w=r(!1),[L,R]=s(0);return c((()=>{const e=m.current;if(e)return e.addEventListener(y5,q),()=>e.removeEventListener(y5,q)}),[q]),y(k5,{scope:a,orientation:o,dir:f,loop:i,currentTabStopId:O,onItemFocus:n((e=>A(e)),[A]),onItemShiftTab:n((()=>g(!0)),[]),onFocusableItemAdd:n((()=>R((e=>e+1))),[]),onFocusableItemRemove:n((()=>R((e=>e-1))),[]),children:y(Ot.div,{tabIndex:v||0===L?-1:0,"data-orientation":o,...z,ref:h,style:{outline:"none",...e.style},onMouseDown:rt(e.onMouseDown,(()=>{w.current=!0})),onFocus:rt(e.onFocus,(e=>{const t=!w.current;if(e.target===e.currentTarget&&t&&!v){const t=new CustomEvent(y5,q5);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){const e=W().filter((e=>e.focusable));_5([e.find((e=>e.active)),e.find((e=>e.id===O)),...e].filter(Boolean).map((e=>e.ref.current)),M)}}w.current=!1})),onBlur:rt(e.onBlur,(()=>g(!1)))})})})),N5="RovingFocusGroupItem",P5=b(((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:a=!0,active:o=!1,tabStopId:i,...r}=e,s=cn(),l=i||s,p=E5(N5,n),u=p.currentTabStopId===l,d=L5(n),{onFocusableItemAdd:b,onFocusableItemRemove:M}=p;return c((()=>{if(a)return b(),()=>M()}),[a,b,M]),y(w5.ItemSlot,{scope:n,id:l,focusable:a,active:o,children:y(Ot.span,{tabIndex:u?0:-1,"data-orientation":p.orientation,...r,ref:t,onMouseDown:rt(e.onMouseDown,(e=>{a?p.onItemFocus(l):e.preventDefault()})),onFocus:rt(e.onFocus,(()=>p.onItemFocus(l))),onKeyDown:rt(e.onKeyDown,(e=>{if("Tab"===e.key&&e.shiftKey)return void p.onItemShiftTab();if(e.target!==e.currentTarget)return;const t=function(e,t,n){const a=function(e,t){return"rtl"!==t?e:"ArrowLeft"===e?"ArrowRight":"ArrowRight"===e?"ArrowLeft":e}(e.key,n);return"vertical"===t&&["ArrowLeft","ArrowRight"].includes(a)||"horizontal"===t&&["ArrowUp","ArrowDown"].includes(a)?void 0:$5[a]}(e,p.orientation,p.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=d().filter((e=>e.focusable)).map((e=>e.ref.current));if("last"===t)n.reverse();else if("prev"===t||"next"===t){"prev"===t&&n.reverse();const a=n.indexOf(e.currentTarget);n=p.loop?function(e,t){return e.map(((n,a)=>e[(t+a)%e.length]))}(n,a+1):n.slice(a+1)}setTimeout((()=>_5(n)))}}))})})}));P5.displayName=N5;var $5={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _5(e,t=!1){const n=document.activeElement;for(const a of e){if(a===n)return;if(a.focus({preventScroll:t}),document.activeElement!==n)return}}var B5=T5,H5=P5,D5="Radio",[I5,V5]=ot(D5),[X5,j5]=I5(D5),F5=b(((e,t)=>{const{__scopeRadio:n,name:a,checked:o=!1,required:i,disabled:c,value:l="on",onCheck:p,form:u,...d}=e,[b,M]=s(null),z=at(t,(e=>M(e))),m=r(!1),h=!b||(u||!!b.closest("form"));return W(X5,{scope:n,checked:o,disabled:c,children:[y(Ot.button,{type:"button",role:"radio","aria-checked":o,"data-state":Z5(o),"data-disabled":c?"":void 0,disabled:c,value:l,...d,ref:z,onClick:rt(e.onClick,(e=>{o||p?.(),h&&(m.current=e.isPropagationStopped(),m.current||e.stopPropagation())}))}),h&&y(Y5,{control:b,bubbles:!m.current,name:a,value:l,checked:o,required:i,disabled:c,form:u,style:{transform:"translateX(-100%)"}})]})}));F5.displayName=D5;var U5="RadioIndicator",G5=b(((e,t)=>{const{__scopeRadio:n,forceMount:a,...o}=e,i=j5(U5,n);return y(dt,{present:a||i.checked,children:y(Ot.span,{"data-state":Z5(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:t})})}));G5.displayName=U5;var Y5=e=>{const{control:t,checked:n,bubbles:a=!0,...o}=e,i=r(null),s=lt(n),l=ut(t);return c((()=>{const e=i.current,t=window.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(t,"checked").set;if(s!==n&&o){const t=new Event("click",{bubbles:a});o.call(e,n),e.dispatchEvent(t)}}),[s,n,a]),y("input",{type:"radio","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:i,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function Z5(e){return e?"checked":"unchecked"}var K5=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Q5="RadioGroup",[J5,e4]=ot(Q5,[x5,V5]),t4=x5(),n4=V5(),[a4,o4]=J5(Q5),i4=b(((e,t)=>{const{__scopeRadioGroup:n,name:a,defaultValue:o,value:i,required:r=!1,disabled:c=!1,orientation:s,dir:l,loop:p=!0,onValueChange:u,...d}=e,b=t4(n),M=$t(l),[z,m]=st({prop:i,defaultProp:o,onChange:u});return y(a4,{scope:n,name:a,required:r,disabled:c,value:z,onValueChange:m,children:y(B5,{asChild:!0,...b,orientation:s,dir:M,loop:p,children:y(Ot.div,{role:"radiogroup","aria-required":r,"aria-orientation":s,"data-disabled":c?"":void 0,dir:M,...d,ref:t})})})}));i4.displayName=Q5;var r4="RadioGroupItem",c4=b(((e,t)=>{const{__scopeRadioGroup:n,disabled:a,...o}=e,i=o4(r4,n),s=i.disabled||a,l=t4(n),p=n4(n),u=r(null),d=at(t,u),b=i.value===o.value,M=r(!1);return c((()=>{const e=e=>{K5.includes(e.key)&&(M.current=!0)},t=()=>M.current=!1;return document.addEventListener("keydown",e),document.addEventListener("keyup",t),()=>{document.removeEventListener("keydown",e),document.removeEventListener("keyup",t)}}),[]),y(H5,{asChild:!0,...l,focusable:!s,active:b,children:y(F5,{disabled:s,required:i.required,checked:b,...p,...o,name:i.name,ref:d,onCheck:()=>i.onValueChange(o.value),onKeyDown:rt((e=>{"Enter"===e.key&&e.preventDefault()})),onFocus:rt(o.onFocus,(()=>{M.current&&u.current?.click()}))})})}));c4.displayName=r4;var s4=b(((e,t)=>{const{__scopeRadioGroup:n,...a}=e,o=n4(n);return y(G5,{...o,...a,ref:t})}));s4.displayName="RadioGroupIndicator";var l4=i4,p4=c4,u4=s4;const d4=e=>{const{checked:n,className:a,disabled:o,id:i,isRequired:r,label:c,name:s,readOnly:l,onChange:p,...u}=e;return t.createElement(l4,{className:`fsc-radio ${a??""}`.trim(),name:s,"aria-label":c||"Radio button",value:n?"default":"",required:r,disabled:o,"aria-readonly":l,onValueChange:e=>{p?.(!n,e)},...u},t.createElement("div",{className:"fsc-radio-container"},t.createElement(p4,{checked:n,"aria-checked":n,className:"fsc-radio-item",disabled:o,"aria-readonly":l,id:i,value:"default"},t.createElement(u4,{className:"fsc-radio-indicator"})),c&&t.createElement("label",{htmlFor:i,className:"fsc-radio-label"},c,c&&r&&t.createElement("span",null,"*"))))},b4=e=>{const{type_info:{matrix_properties:n},onChangeHandler:a,value:o}=e;return t.createElement("div",{className:"matrix-container","data-test-input":"matrix"},t.createElement("table",{className:"st-mt-table"},t.createElement("thead",{className:"st-mt-thead"},t.createElement("tr",{className:"st-mt-tr"},t.createElement("th",{className:"m-s-b-s-q-m-s-th-empty st-mt-th"}),n?.rating_labels?.map(((e,n)=>e.is_active?t.createElement("th",{key:e.id,className:"m-s-b-s-q-m-s-th st-mt-th"},t.createElement("div",{className:"m-s-b-s-q-m-s-th-div"},e.text)):null)))),t.createElement("tbody",{className:"st-mt-tbody"},n?.statements?.map(((e,i)=>e.is_active?t.createElement("tr",{key:e.id,className:"m-s-b-s-q-m-s-tr-hover st-mt-tr"},t.createElement("td",{className:"m-s-b-s-q-m-s-input st-mt-td"},e.text),n?.rating_labels?.map(((r,c)=>{if(!r.is_active)return null;const s=o?.find((t=>t?.statement_id===e?.id));return t.createElement("td",{key:r.id,className:"m-s-b-s-q-m-s-switch st-mt-td"},"SINGLE_ANSWER"===n?.type&&t.createElement(d4,{key:r.id||`${i}-key-${c}`,name:`q-m-s-radio-${i}-key-${c}`,checked:!!s?.rating_labels?.find((e=>e?.id===r?.id)),id:r.id??"",onChange:()=>{e?.id&&r?.id&&a(s?.statement_id?[...o||[]].map((e=>e?.statement_id===s?.statement_id?{...s,rating_labels:[{id:r.id||"",text:r?.text||""}]}:e)):[...o||[],{statement_id:e.id,rating_labels:[{id:r.id,text:r?.text||""}]}])},label:""}),"MULTIPLE_ANSWERS"===n?.type&&t.createElement(Tt,{key:r.id||`${i}-key-${c}`,name:`q-m-s-checkbox-${i}-key-${c}`,checked:!!s?.rating_labels?.find((e=>e?.id===r?.id)),id:r.id??"",onChange:t=>{e?.id&&r?.id&&a(s?.statement_id?[...o||[]].map((e=>e.statement_id===s.statement_id?{...s,rating_labels:t?[...s.rating_labels||[],{id:r.id||"",text:r?.text||""}]:(s.rating_labels||[]).filter((e=>e?.id!==r.id))}:e)):[...o||[],{statement_id:e.id,rating_labels:[{id:r.id,text:r?.text||""}]}])}}))}))):null)))))},M4=e=>{const{type_info:{matrix_properties:n},onChangeHandler:a,name:o,isMobile:i,isReverseAnimation:r,statementIndex:c,value:s,widgetStyle:l,language:p="en"}=e,u=t.useMemo((()=>(n?.statements||[]).find(((e,t)=>t===c))),[n?.statements,c]),d=t.useMemo((()=>s?.find((e=>e?.statement_id===u?.id))),[u,s]);return t.createElement("div",{className:"matrix-wd-container","data-test-input":"matrix"},t.createElement("div",{className:"matrix-st-count"},`${c+1}/${(n?.statements||[]).length}`),t.createElement(DE,{exitBeforeEnter:!0},t.createElement(PE.div,{key:`${u?.id??""}`,initial:{opacity:0,x:Re(p,r)},animate:{opacity:1,x:0},exit:{opacity:0,x:Ce(p,r)},transition:{duration:.2}},t.createElement("div",{className:"matrix-st-text"},u?.text),t.createElement("div",{className:`matrix-st-labels wd-style-${l} ${i?"mt-mobile":""}`.trim()},"MULTIPLE_ANSWERS"===n?.type&&t.createElement(f$,{name:o??"",onChangeHandler:e=>{if(u?.id){const t=d?.statement_id?[...s||[]].map((t=>t.statement_id===d.statement_id?{...d,rating_labels:e.map((e=>{const t=n?.rating_labels?.find((t=>t.id===e));return{id:e,text:t?.text||""}}))}:t)):[...s||[],{statement_id:u.id,rating_labels:e.map((e=>{const t=n?.rating_labels?.find((t=>t.id===e));return{id:e,text:t?.text||""}}))}];a(t)}},saveOthersValue:()=>{},options:(n?.rating_labels??[]).map((e=>({id:e.id,value:e.text}))),values:(d?.rating_labels??[]).map((e=>e.id??"")),autoFocusDelay:0,othersValue:""}),"SINGLE_ANSWER"===n?.type&&t.createElement(IE,{name:o??"",language:p||"en",onChangeHandler:e=>{const t=n?.rating_labels?.find((t=>t.id===e));u?.id&&e&&a(d?.statement_id?[...s||[]].map((n=>n?.statement_id===d?.statement_id?{...d,rating_labels:[{id:e||"",text:t?.text||""}]}:n)):[...s||[],{statement_id:u.id,rating_labels:[{id:e,text:t?.text||""}]}])},saveOthersValue:()=>{},options:(n?.rating_labels??[]).map((e=>({id:e.id,value:e.text}))),value:d?.rating_labels?.[0]?.id??"",othersValue:""})))))},z4=({question:e,autoFocusDelay:n,setFocus:a,formValues:o,surveyLayout:i,onChangeHandler:r,isQuestionBgDark:c})=>{const s=e?.type_info?.number_field?.decimal,l=e?.type_info?.number_field?.decimal_point,p=s?2===l?"0.01":"0.1":"1",u=o[e.name],[d,b]=t.useState(u);t.useEffect((()=>{d&&!u&&b(u)}),[u]);const{maxLength:M,maxNumber:z}=t.useMemo((()=>{const e=s?16:18;var t;return{maxLength:e,maxNumber:(t=e)>=16?10n**BigInt(t)-1n:10**t-1}}),[s]),m=e=>{s&&!qe(l)&&(e.split(".")?.[1]?.length??0)>(l??0)||r(e?We(e,s||!1):"",!1)};return t.createElement("div",{className:"responsive-input-field"},t.createElement(ja,{autoFocusDelay:n,isRequired:!!e.required,type:"number",step:p,placeholder:e?.type_info?.meta?.placeholder??s?"0.0"+(2===l?"0":""):"0",onKeyDown:e=>{const{key:t,keyCode:n,which:a,code:o}=e;if(["e","E"].includes(t)&&e.currentTarget.value&&e.preventDefault(),"."===t&&s||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||["Backspace","Shift","Tab","ArrowDown","ArrowUp","ArrowLeft","ArrowRight","-","+","e","E"].includes(t))return;if(["e","E"].includes(t))return;const i=void 0===a?n??o:a;String.fromCharCode(i).match(/^[0-9]+$/)||e.preventDefault()},..."card"===i?{value:u??"",onChange:e=>{if(e.target.value.includes("e+"))return;const t=BigInt(e.target.value.split(".")[0]??"");BigInt(t)<=z&&e.target.value.length<=M&&m(e.target.value)}}:{value:d??"",onChange:e=>{if(e.target.value.includes("e+"))return;const t=BigInt(e.target.value.split(".")[0]??""),n=e.target.value.split(".")[1]??"";if(n.length>(l??0))return;const a=BigInt(t);a<=z&&e.target.value.length<=M&&b(`${a}${qe(n)||we(n)?"":`.${n}`}`)},onBlur:()=>{return e=d,void((qe(u)||we(u))&&(qe(d)||we(d))||d===u||m(e));var e}},setFocus:a,showCount:!0,max:`${z}`,maxLength:M,isQuestionBgDark:c}))},m4=({question:e,questionCommentOnchangeHandler:n,commentsMeta:a,setFocus:o,isQuestionBgDark:i,isCommentsEnabled:r})=>{const[c,s]=t.useState(a?.toString());return r?t.createElement(DE,null,t.createElement(PE.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},transition:{duration:.3,ease:"easeInOut"},exit:{height:0,opacity:0},className:"question-comments"},t.createElement(wP,{showCount:!0,maxLength:1500,rows:2,isRequired:!!e.required,placeholder:e?.type_info?.comment_placeholder??"Enter your comment",onChange:t=>{const a=t.target.value||"";s(a),n?.(e.name,a)},value:a||c,setFocus:!0,isQuestionBgDark:i,"aria-label":e.name}))):null},h4=e=>{switch(e){case"EMAIL":return"email";case"PHONE":return"tel";case"URL":return"url";default:return"text"}},f4=e=>{switch(e){case"PHONE":return"phone";case"EMAIL":return"email";case"URL":return"url";default:return""}},O4=({question:e,autoFocusDelay:n,formValues:a,onChangeHandler:o,textboxErrors:i,surveyLayout:r,setFocus:c,onKeyDownHandler:s,translationVariables:l,isQuestionBgDark:p})=>{const u=e?.type_info?.text_field?.text_type,d=a[e.name],[b,M]=t.useState(d);return t.useEffect((()=>{b&&!d&&M(d)}),[d]),t.createElement("div",{className:"responsive-input-field"},"PHONE"===u?t.createElement(Ka,{startAdornment:t.createElement(Ge,{fill:"var(--choices-answers-color, var(--question-text-color, var(--default-question-text-color)))",name:f4(u)}),type:h4(u),setFocus:c,autoFocusDelay:n,label:"",isRequired:!!e.required,value:d,isErrored:!!i[e.name],errorText:i[e.name]||"",placeholder:e?.type_info?.meta?.placeholder??"",onChangeHandler:o,maxLength:18,showCount:!0,onKeyDownHandler:s,surveyLayout:r,translationVariables:l}):t.createElement(ja,{startAdornment:u&&"TEXT"!==u&&t.createElement(Ge,{fill:"var(--choices-answers-color, var(--question-text-color, var(--default-question-text-color)))",name:f4(u)}),type:h4(u),setFocus:c,autoFocusDelay:n,showCount:!0,label:"",onKeyDown:s,isRequired:!!e.required,isErrored:!!i[e.name],errorText:i[e.name]||"",placeholder:e?.type_info?.meta?.placeholder??"",..."card"===r?{value:d??"",onChange:e=>o(e.target.value)}:{onBlur:e=>{(qe(d)||we(d))&&(qe(b)||we(b))||b===d||o?.(e.target.value,!0)},value:b??"",onChange:e=>M(e.target.value)},maxLength:50,isQuestionBgDark:p}))},A4=({surveyLanguage:e,language:n="en",question:a,formValues:o,othersMeta:i,onChangeHandler:r,saveOthersValue:c,autoFocusDelay:s,isFinalQn:l,isWidget:p,isMobile:u,initialPivotAnswer:d,initialQuestionAnswer:b,isInitialTransition:M,formQuestionErrors:z,dateQuestionErrors:m,contactFormErrors:h,activeIndexOfRenderedStatement:f={},textboxQuestionErrors:O,isReverseAnimation:A,fileUploadErrors:v,preview:g,onFileUpload:y,widgetStyle:q="default",setErrors:W,translationVariables:w,surveyServAssetUrl:L,setFocus:R,block:C,onKeyDown:x,surveyStyle:k,isQuestionBgDark:E})=>{const T=a?.type_info?.question_comment,S=a?.type_info?.footer_text&&a.type_info.meta?.question_hint?t.createElement("div",{className:"svs-footer question-hint ss-question-hint",role:"note",dangerouslySetInnerHTML:{__html:a?.type_info?.footer_text}}):t.createElement(t.Fragment,null),N=o[a.name],[P,$]=t.useState(N);switch(t.useEffect((()=>{P&&!N&&$(N)}),[N]),a?.type_info?.question_type){case"MATRIX_RATING_SCALE":return t.createElement(t.Fragment,null,p||u?t.createElement(M4,{language:n,name:a.name,isReverseAnimation:A,type_info:a?.type_info||{},onChangeHandler:e=>{r(e?.filter((e=>(e.rating_labels||[]).length>0)))},isMobile:u,value:o[a.name]||[],statementIndex:f[a.name]??0,widgetStyle:q}):t.createElement(b4,{type_info:a?.type_info||{},onChangeHandler:e=>{r(e?.filter((e=>(e.rating_labels||[]).length>0)))},value:o[a.name]||[]}),S);case"RANGE":return t.createElement(t.Fragment,null,t.createElement(jE,{question:a,onChangeHandler:r,isWidget:p,isMobile:u,widgetStyle:q,value:o[a.name],initialPivotAnswer:d,isInitialTransition:M}),T&&null!=o[a.name]&&t.createElement(m4,{question:a,questionCommentOnchangeHandler:c,commentsMeta:i?.[a?.name],surveyStyle:k,setFocus:R,isQuestionBgDark:E,isCommentsEnabled:T}),S);case"CHECKBOX":case"MULTI_SELECT":return t.createElement(t.Fragment,null,t.createElement(f$,{name:a.name,values:o[a.name],othersValue:i[a.name],options:a?.choices||[],onChangeHandler:r,saveOthersValue:c,isOthersOption:!!(a?.choices||[]).find((e=>e.meta?.is_others)),othersRequired:!!a?.type_info.meta?.othersRequired,autoFocusDelay:s,translationVariables:w,othersInputPlaceholder:a?.type_info?.comment_placeholder}),T&&null!=o[a.name]&&t.createElement(m4,{question:a,questionCommentOnchangeHandler:c,commentsMeta:i?.[a?.name],surveyStyle:k,setFocus:R,isQuestionBgDark:E,isCommentsEnabled:T}),S);case"RADIO":case"DROPDOWN":return t.createElement(t.Fragment,null,t.createElement(IE,{autoFocusDelay:s,name:a.name,onChangeHandler:r,initialQuestionAnswer:b,displayFormat:a?.type_info?.meta?.display_format||"LIST",saveOthersValue:c,options:a?.choices||[],value:o[a.name],othersValue:i[a.name],isOthersOption:!!(a?.choices||[]).find((e=>e.meta?.is_others)),language:n||"en",othersRequired:!!a?.type_info.meta?.othersRequired,isFinalQn:l,translationVariables:w,isQuestionBgDark:E,othersInputPlaceholder:a?.type_info?.comment_placeholder}),T&&null!=o[a.name]&&t.createElement(m4,{question:a,questionCommentOnchangeHandler:c,commentsMeta:i?.[a?.name],surveyStyle:k,setFocus:R,isQuestionBgDark:E,isCommentsEnabled:T}),S);case"TEXT":return t.createElement(t.Fragment,null,t.createElement(O4,{question:a,autoFocusDelay:s,formValues:o,onChangeHandler:r,textboxErrors:O||"",setFocus:R,onKeyDownHandler:x,surveyLayout:k??"card",translationVariables:w,isQuestionBgDark:E}),S);case"NUMBER":return t.createElement(t.Fragment,null,t.createElement(z4,{question:a,autoFocusDelay:s,formValues:o,setFocus:R,onChangeHandler:r,surveyLayout:k??"card",isQuestionBgDark:E}),S);case"FORM_FIELD":return t.createElement(t.Fragment,null,t.createElement(g5,{widgetStyle:q,question:a,isWidget:p,isMobile:u,surveyStyle:k,isRequired:!!a.required,autoFocusDelay:s,translationVariables:w,onChangeHandler:(e,t)=>{r(e,"card"!==k&&t)},formValues:o,fieldErrors:z?.[a.name]||{},language:n||"en",isQuestionBgDark:E}),S);case"CONTACT_FORM":return t.createElement(t.Fragment,null,t.createElement(A$,{question:a,setFocus:R,autoFocusDelay:s,onChangeHandler:r,translationVariables:w,formValues:o,fieldErrors:h?.[a.name]||{},language:n||"en",isQuestionBgDark:E}),S);case"PARAGRAPH":return t.createElement(t.Fragment,null,t.createElement(wP,{showCount:!0,maxLength:1500,autoFocusDelay:s,isRequired:!!a.required,placeholder:a?.type_info?.meta?.placeholder??"",..."card"===k?{value:N??"",onChange:e=>r(e.target.value)}:{onBlur:e=>{(qe(N)||we(N))&&(qe(P)||we(P))||P===N||r?.(e.target.value,!0)},value:P??"",onChange:e=>$(e.target.value)},setFocus:R,isQuestionBgDark:E,"aria-label":a.name}),S);case"BOOLEAN":case"RESOLUTION":return t.createElement(t.Fragment,null,t.createElement(Qe,{type_info:a?.type_info,onSelect:r,value:o[a.name]}),T&&null!=o[a.name]&&t.createElement(m4,{question:a,questionCommentOnchangeHandler:c,commentsMeta:i?.[a?.name],surveyStyle:k,setFocus:R,isQuestionBgDark:E,isCommentsEnabled:T}),S);case"MESSAGE":return S;case"CONSENT":return t.createElement(t.Fragment,null,t.createElement(O$,{question:a,onChange:r,value:o[a.name]}),S);case"SLIDER":const e=a?.type_info.meta?.slider;return t.createElement(t.Fragment,null,t.createElement(qP,{defaultValue:[o[a.name]??e?.opening_position],isRequired:!!a.required,dir:Le(n)?"rtl":"ltr",answer:o[a.name],min:e?.min,max:e?.max,onValueChange:([e],t)=>r(e,"card"!==k&&t),isInput:e?.numerical_input_box,gridLines:e?.grid_lines,stopAtGrid:e?.stop_at_grid_lines,allowDecimals:e?.allow_decimal,decimalPoints:e?.decimal_points,isMobile:u||"compact"===q}),T&&null!=o[a.name]&&t.createElement(m4,{question:a,questionCommentOnchangeHandler:c,commentsMeta:i?.[a?.name],surveyStyle:k,setFocus:R,isQuestionBgDark:E,isCommentsEnabled:T}),S);case"RANK_ORDER":const{others_meta:v,...C}=o;return t.createElement(t.Fragment,null,t.createElement(LN,{valueItems:C[a.name],items:a?.choices||[],onReorder:(e,t)=>r(e,"card"!==k&&t)}),S);case"DATE_TIME":return t.createElement(t.Fragment,null,"DATE_TIME"===a.type_info.meta?.question_format?t.createElement(Uq,{id:a.id??"",name:a.name??"",type:"QUESTION",displayFormat:a.type_info.meta?.format??void 0,allowOnlyFuture:a.type_info.meta?.allow_future_date||!1,useAmPm:!a.type_info.meta?.time_format,showTimezoneSelect:!!a.type_info.meta?.time_zone,onChange:(e,t)=>{r(e,"card"!==k&&t)},setErrors:e=>{W((t=>({...t,dateQuestionErrors:e})))},fieldErrors:m?.[a.name]??[],value:o[a.name]||"",translationVariables:w,language:n||"en",isQuestionBgDark:E,isWidget:p}):t.createElement(Fq,{allowOnlyFuture:a.type_info.meta?.allow_future_date||!1,type:"QUESTION",displayFormat:a.type_info.meta?.format??void 0,onChange:e=>{r(e,!1)},value:o[a.name]||"",translationVariables:w,language:n||"en",fieldErrors:m?.[a.name]??[],isQuestionBgDark:E,isWidget:p}),S);case"FILE":return t.createElement(A5,{setErrors:e=>{W({formQuestionErrors:z,textboxQuestionErrors:O,contactFormErrors:h,fileUploadErrors:e,dateQuestionErrors:m})},preview:g,onChangeHandler:r,question:a,onFileUpload:y,value:o[a.name]||"",translationVariables:w,surveyServAssetUrl:L});default:return console.error(`Question type ${a?.type_info?.question_type} not found`),null}},v4=({surveyServAssetUrl:e,thankYouQuestion:n,preview:a,placeholders:o,canResubmit:i,resetSurvey:r,navigateToStart:l,isMobile:p,allowMultipleSubmission:u,pivot:d,answers:b,questions:M,rangeToRender:z,translationVariables:m})=>{const{redirectUrl:h,redirectDelay:f,show_custom_button:O,show_review_links:A,show_social_links:v,image_url:g}=n?.type_info?.meta??{},[y,q]=s(f??10),[W,w]=t.useState(!1);return c((()=>{if(!a&&h){const e=setInterval((()=>q((e=>e>1?e-1:("undefined"!=typeof window&&(window.location.href=h??""),0)))),1e3);return()=>{clearInterval(e),w(!1)}}return()=>{w(!1)}}),[]),t.createElement("div",{className:"question-container ss-question-container thankyou"},g&&t.createElement("img",{className:"thankyou-logo-img ss-thankyou-logo",src:g,alt:"thankyou_logo"}),t.createElement(t.Fragment,null,xe(n)),t.createElement("div",{className:"text ss-thankyou-message",dangerouslySetInnerHTML:{__html:Ee({questionText:n.text,placeholders:o,npsRating:Te({theme:"nps",answers:b,questions:M})??"",npsRatingLabel:Se({theme:"nps",answers:b,questions:M}),csatRating:Te({theme:"csat",answers:b,questions:M})??"",csatRatingLabel:Se({theme:"csat",answers:b,questions:M}),cesRating:Te({theme:"ces",answers:b,questions:M})??"",cesRatingLabel:Se({theme:"ces",answers:b,questions:M}),preference:d?.question.type_info?.scale_properties?.labels?.preference,isPreview:a})}}),(i||u)&&t.createElement("div",{className:("wrap-up-actions "+(p?"mobile":"")).trim()},i&&t.createElement("button",{className:"action-button",tabIndex:0,disabled:W,onClick:()=>{w(!0),l()},"aria-label":m?.edit_response||"Edit your response"},t.createElement(Ge,{name:"edit"}),m?.edit_response||"Edit your response"),u&&t.createElement("button",{className:"action-button",tabIndex:0,disabled:W,onClick:()=>{w(!0),r()},"aria-label":m?.another_response||"Submit another response"},t.createElement(Ge,{name:"reload"}),m?.another_response||"Submit another response")),h&&t.createElement("div",{className:"redirection-container"},t.createElement("div",{className:"redirection-text"},$e(y,m?.redirect_msg),t.createElement("br",null)),t.createElement("a",{className:"link",href:h},h)),(O||A||v)&&t.createElement(h$,{show_custom_button:O,show_review_links:A,show_social_links:v,surveyServAssetUrl:e}))},g4=({activeIndexOfRenderedStatement:e,navigateToPreviousBlock:n,canDisplayDisableButtonParams:a,navigateToNextBlock:o,translationVariables:i,setAnimationInProgress:r,animationInProgress:c,question:s})=>t.createElement("div",{className:"freemium-survey-step-navigation ss-navigation-buttons","data-navigation-element":"1"},t.createElement("button",{disabled:c||JP("navigation-prev",a),className:"navigation-button ss-navigation-button",onClick:()=>{r(!0),setTimeout((()=>{r(!1)}),se),n()},title:s.name&&(e?.[s.name]??0)>0?i?.prev_statement||"go to previous statement":i?.prev_question||"go to previous question"},t.createElement(Ge,{name:"arrow-previous"})),t.createElement("button",{className:"navigation-button ss-navigation-button",disabled:c||JP("navigation-next",a),title:i?.next_question||"Go to next question",onClick:()=>{r(!0),setTimeout((()=>{r(!1)}),se),o()}},t.createElement(Ge,{name:"arrow-next"}))),y4=e=>{const{initialStatementHasAnswer:n,answers:a,renderedBlocks:o,blocks:i,activeIndexOfBlocks:r,activeIndexOfRenderedStatement:c={},activeIndexOfRenderedBlocks:l,saveFormValues:p,onSubmitHandler:u,skipBlock:d,skipStatement:b,survey:M,navigateToNextBlock:z,navigateToPreviousBlock:m,isInitialTransition:h,initialPivotAnswer:f,translationVariables:O,navigateToNextStatement:A,canDisplayDisableButtonParams:v,formQuestionErrors:g,dateQuestionErrors:y,textboxQuestionErrors:q,contactFormErrors:W,questions:w,pages:L,buttonRef:R,isReverseAnimation:C,isSubmitting:x}=e,[k,E]=s(!1),{question:T}=o[l],S={...v,isSubmitting:x},N=T?.type_info?.meta?.display_format,P=SP({blocks:i,activeIndexOfBlocks:r,renderedBlocks:o,activeIndexOfRenderedBlocks:l,questions:w});return t.createElement(t.Fragment,null,(GP("message",S)||GP("consent",S))&&t.createElement(DE,{exitBeforeEnter:!0},t.createElement(PE.div,{key:T.name??"",id:`consent-buttons-${T.name??""}`,className:"question-consent-buttons ss-consent-action-buttons",initial:{opacity:0,x:Re(e.language,C)},animate:{opacity:1,x:0},exit:{opacity:0,x:Ce(e.language,C)},transition:{duration:.2}},GP("consent",S)&&"BUTTON"===N&&fe.map((e=>t.createElement(et,{key:l+String(e.recordAs),onClick:()=>{E(!0),setTimeout((()=>{E(!1)}),se),p(o[l],e.recordAs,!0)},disabled:k||JP("consent",S),variant:qe(a.formValues?.[T.name])||a.formValues?.[T.name]===e.recordAs?"primary":"secondary",className:("consent-button ss-action-consent-button "+(a.formValues?.[T.name]===e.recordAs?"selected":"")).trim()},T?.type_info?.scale_properties?.labels?.values?.[e.id]||e.defaultValue))),GP("message",S)&&t.createElement(et,{onClick:()=>{E(!0),setTimeout((()=>{E(!1)}),se),P?u("COMPLETE"):d()},disabled:k||JP("message",S),className:"message-button ss-action-message-button"},T?.type_info?.scale_properties?.labels?.values?.[0]||"Begin"))),(GP("navigation",S)||GP("next",S)||GP("next-statement",S)||GP("submit",S)||GP("skip",S)||GP("skip-statement",S))&&t.createElement("div",{className:"question-footer ss-question-footer-container"},GP("navigation",S)?t.createElement(g4,{animationInProgress:k,setAnimationInProgress:E,answers:a,canDisplayDisableButtonParams:S,activeIndexOfBlocks:r,activeIndexOfRenderedBlocks:l,renderedBlocks:o,initialStatementHasAnswer:n,blocks:i,activeIndexOfRenderedStatement:c,navigateToNextBlock:z,navigateToPreviousBlock:m,translationVariables:O,pages:L,question:T}):t.createElement("div",null),t.createElement("div",{className:"action-buttons ss-action-buttons"},GP("skip",S)&&t.createElement(et,{className:"skip-button ss-action-skip-button",onClick:()=>{E(!0),setTimeout((()=>{E(!1)}),se),d()},variant:"secondary","aria-label":"skip question",disabled:k||x},e?.survey?.meta?.action_button?.skip||O?.actionButtonText?.skip||O?.skip||"Skip"),GP("skip-statement",S)&&t.createElement(et,{className:"skip-button ss-action-skip-button",onClick:()=>{E(!0),setTimeout((()=>{E(!1)}),se),b()},"aria-label":"skip statement",variant:"secondary",disabled:k||x},e?.survey?.meta?.action_button?.skip||O?.actionButtonText?.skip||O?.skip||"Skip"),GP("next",S)&&t.createElement(et,{ref:R,onClick:()=>{E(!0),setTimeout((()=>{E(!1)}),se),0!==l||!h||"RANGE"!==T.type_info?.question_type&&"BOOLEAN"!==T.type_info?.question_type||T.type_info?.question_comment||void 0===f?p(o[l],"CHECKBOX"===T?.type_info?.meta?.display_format&&"CONSENT"===T?.type_info?.question_type?a.formValues[T.name]??!1:a.formValues[T.name],!0):p(o[l],f,!0)},disabled:k||JP("next",S),className:"next-button ss-action-next-button"},e?.survey?.meta?.action_button?.next||O?.actionButtonText?.next||O?.next||"Next"),GP("next-statement",S)&&t.createElement(et,{ref:R,onClick:()=>{E(!0),setTimeout((()=>{E(!1)}),se),A?.(T.name)},disabled:k||!!JP("next-statement",S),className:"next-button ss-action-next-button"},e?.survey?.meta?.action_button?.next||O?.actionButtonText?.next||O?.next||"Next"),GP("submit",S)&&t.createElement("div",{className:"submit ss-action-submit-button"},t.createElement(et,{ref:R,disabled:k||JP("submit",S),onClick:()=>{we(y?.[T.name])&&we(g?.[T.name])&&we(q?.[T.name])&&we(W?.[T.name])&&(E(!0),setTimeout((()=>{E(!1)}),se),u("COMPLETE"))}},M?.meta?.action_button?.submit||O?.actionButtonText?.submit||O?.submit_survey||"Submit")))))},q4=e=>{const{blocks:n,pages:a,activePage:i,renderedBlocks:l,activeBlock:p,activeIndexOfBlocks:u,activeIndexOfRenderedBlocks:d,isSurveyCompleted:b,isReverseAnimation:M,saveFormValues:z,saveOthersValue:m,skipBlock:h,skipStatement:f,onSubmitHandler:O,navigateToNextBlock:A,navigateToPreviousBlock:v,answers:g,questions:y,pivot:q,isInitialTransition:W,resetSurvey:w,activeIndexOfRenderedStatement:L,navigateToNextStatement:R,navigateToPreviousStatement:C,navigateToStart:x,translationVariables:k,initialStatementHasAnswer:E,dateQuestionErrors:T,formQuestionErrors:S,textboxQuestionErrors:N,contactFormErrors:P,fileUploadErrors:$,setErrors:_,expanded:B,setExpanded:H,isQuestionBgDark:D,isSubmitting:I}=d$(e);Ie("Card",{...e,answers:g,activePage:i,activeBlock:p,renderedBlocks:l,activeIndexOfBlocks:u,activeIndexOfRenderedBlocks:d,activeIndexOfRenderedStatement:L});const V=r(null),X=we(g.formValues)&&e.survey.prompt_settings?.is_enabled&&e.preview,[j,F]=s(X),U=t.useMemo((()=>ke(q?.question)),[q?.question]),G=o((()=>n.filter((({name:e},t,n)=>!BP({nextBlockName:e||"",blocks:n,questions:y}))).length),[n,y]);c((()=>{p&&e.onBlockChange?.(p,i)}),[p,e]),c((()=>{e.survey.theme&&Ne(e.survey.theme,e.surveyServAssetUrl??"")}),[e.survey.theme,e.surveyServAssetUrl]),c((()=>{e.getSurveyProgress?.({totalBlocks:G,isSurveyCompleted:b,noOfAnswers:u})}),[G,b,u]);const Y={answers:g,blocks:n,blockIndex:d,activeIndexOfBlocks:u,initialStatementHasAnswer:E,activeIndexOfRenderedBlocks:d,activeIndexOfRenderedStatement:L,renderedBlocks:l,isMobile:!!e.isMobile,surveyStyle:e.surveyStyle,isWidget:!!e.isWidget,initialPivotAnswer:e.initialPivotAnswer,isInitialTransition:W,questions:y,pages:a,activeIndexOfSet:0,branchSeparatePage:!1,pivot:q};return p&&p.question?t.createElement("div",{className:`freemium-survey-components card-survey-style ${Le(e.language||"en")?"freemium-survey-rtl":"freemium-survey-ltr"} ${e.isMobile?"mobile-preview":""}`.trim(),id:"freemium-survey"},t.createElement("div",{className:("question-holder "+(j?"prompt":"")).trim()},!b&&!j&&!e.isWidget&&a.length>0&&i?.page_id&&t.createElement(b$,{expanded:B,id:i.page_id,setExpanded:H,activePage:i,translationVariables:k}),t.createElement("div",{className:"questions ss-questions"},b?t.createElement(v4,{surveyServAssetUrl:e.surveyServAssetUrl??"",thankYouQuestion:NP({pivotQn:q?.question,pivotQnAnswer:q?.answer,block:HP({activeBlock:p,blocks:e.survey.blocks?.filter((e=>!e.is_deleted)),answers:g,questions:y,activeIndexOfBlocks:u,renderedBlocks:l,contactData:e.contactData,surveyLayout:"card",pages:a}),questions:y}),canResubmit:e.canResubmit,allowMultipleSubmission:e.allowMultipleSubmission,navigateToStart:()=>{e.handleAction?e.handleAction("EDIT_RESPONSE",x):x()},resetSurvey:()=>{e.handleAction?e.handleAction("RE_SUBMIT",w):w()},preview:!!e.preview,placeholders:e.placeholders,isMobile:e.isMobile,pivot:q,rangeToRender:U,translationVariables:k,answers:g}):t.createElement(t.Fragment,null,!j&&e.isWidget&&a.length>0&&i?.page_id&&t.createElement(b$,{expanded:B,id:i.page_id,setExpanded:H,activePage:i,translationVariables:k}),t.createElement(DE,{exitBeforeEnter:!0},t.createElement(PE.div,{id:`${p.question.name}`,className:"question-container ss-question-container","data-test-question-name":p.question.name,key:`${p.question.name}`,initial:{opacity:0,x:Re(e.language,M)},animate:{opacity:1,x:0},exit:{opacity:0,x:Ce(e.language,M)},transition:{duration:.2}},j&&e.survey.prompt_settings?t.createElement(z$,{config:e.survey.prompt_settings,onSelect:t=>{e.onAnsweringPrompt?.(t),1===t&&F(!1)},placeholders:e.placeholders,isPreview:!!e.preview}):t.createElement(t.Fragment,null,t.createElement("div",{className:("question-text ss-question-text "+(p.required?"required":"")).trim(),dangerouslySetInnerHTML:{__html:Ee({questionText:p?.question.text,placeholders:e.placeholders,npsRating:Te({theme:"nps",answers:g,questions:y})??"",npsRatingLabel:Se({theme:"nps",answers:g,questions:y}),csatRating:Te({theme:"csat",answers:g,questions:y})??"",csatRatingLabel:Se({theme:"csat",answers:g,questions:y}),cesRating:Te({theme:"ces",answers:g,questions:y})??"",cesRatingLabel:Se({theme:"ces",answers:g,questions:y}),preference:q?.question.type_info?.scale_properties?.labels?.preference,isPreview:!!e.preview})},"aria-label":`question-${d}`,role:"heading","aria-level":1}),t.createElement(A4,{setFocus:!0,onKeyDown:e=>{"Enter"===e.key&&V.current&&V.current.click()},isReverseAnimation:M,preview:!!e.preview,surveyServAssetUrl:e.surveyServAssetUrl,setErrors:_,onFileUpload:e.onFileUpload,language:e.language||"en",surveyStyle:e.surveyStyle,surveyLanguage:e.survey.language,block:p,question:p.question,isFinalQn:SP({blocks:n,activeIndexOfBlocks:u,renderedBlocks:l,activeIndexOfRenderedBlocks:d,questions:y}),formValues:g.formValues,othersMeta:g.others,autoFocusDelay:"standard"===e.surveyStyle?350:0,activeIndexOfRenderedStatement:L,saveOthersValue:m,onChangeHandler:(e,t)=>{z(p,e,t)},isMobile:!!e.isMobile,initialPivotAnswer:e.initialPivotAnswer,initialQuestionAnswer:e.initialQuestionAnswer,isInitialTransition:W,formQuestionErrors:S,dateQuestionErrors:T,textboxQuestionErrors:N,fileUploadErrors:$,contactFormErrors:P,translationVariables:k,isQuestionBgDark:D})))),!j&&t.createElement(y4,{isWidget:!1,language:e.language||"en",isReverseAnimation:M,surveyStyle:e.surveyStyle,canDisplayDisableButtonParams:Y,answers:g,renderedBlocks:l,blocks:n,pages:a,activeIndexOfRenderedStatement:L,buttonRef:V,survey:e.survey,initialStatementHasAnswer:E,navigateToNextStatement:R,navigateToPreviousStatement:C,activeIndexOfRenderedBlocks:d,activeIndexOfBlocks:u,saveFormValues:z,skipBlock:h,skipStatement:f,onSubmitHandler:O,navigateToPreviousBlock:v,navigateToNextBlock:A,isInitialTransition:W,initialPivotAnswer:e.initialPivotAnswer,isMobile:!!e.isMobile,translationVariables:k,formQuestionErrors:S,dateQuestionErrors:T,textboxQuestionErrors:N,fileUploadErrors:$,contactFormErrors:P,questions:y,isSubmitting:I})))),!e.footerProps?.hideFooter&&(e?.footerProps?.languageDDComponent||e?.footerProps?.showFWBranding||e.footerProps?.footerContent)?t.createElement(Ya,{...e.footerProps,surveyStyle:e.surveyStyle,bgColor:e.survey.theme?.palette?.footer_background??e.survey.theme?.palette?.survey_background??m$}):null):null},W4=e=>{const n=!!e.survey.meta?.branch_separate_page,a=e.survey.question_details?.questions||[],i=e.contactData||{},l=e.translationVariables||{},p=r({}),[u,d]=s(e.survey?.blocks?.filter((e=>"TY"!==e.name&&!e.is_deleted))),[b,M]=s({formQuestionErrors:{},textboxQuestionErrors:{},fileUploadErrors:{},contactFormErrors:{},dateQuestionErrors:{}}),[z,m]=s(!1),[h,f]=s(0),[O,A]=s(e.survey.pages??[]),[v,g]=s(O?.[0]),[y,q]=s(!1),W=o((()=>a$({pages:O,blocks:u,questions:a,initialPivotAnswer:e.initialPivotAnswer,responses:e.answers,answerStatus:e.answerStatus||"PARTIAL",branchSeparatePage:n,surveyLayout:"standard",contactData:i})),[u,a,e.answers]),[w,L]=s(W.renderedBlocks),[R,C]=s(W.activeIndexOfRenderedBlocks),[x,k]=s(0),[E,T]=s(W.activeIndexOfRenderedStatement),S=r(W.pivot),N=r(W.isInitialTransition),[P,$]=s(""),[_,B]=s(W.answers),H=r(((W.isConsideredCompleted||"PARTIAL"===e.answerStatus)&&e.canResubmit)??!1),[D,I]=s(!1),V=w[R],X=t.useMemo((()=>w.length>0?u?.findIndex((e=>e.name===w[R]?.name)):0),[R]),j=o((()=>{const t=e.survey.theme?.palette?.question_background;return!!t&&Ve(t)}),[e.survey.theme?.palette?.question_background]);c((()=>{e.survey.updated_at!==P&&(Ie("useEffect",{updated_at:e.survey.updated_at,props:e}),A(e.survey.pages??[]),d(e.survey.blocks?.filter((e=>"TY"!==e.name&&!e.is_deleted))),g(e.survey.pages?.[0]),$(e.survey.updated_at??""))}),[e.survey.updated_at]),c((()=>{Ie("useEffect",{renderedBlocks:w,pages:O,activeIndexOfRenderedBlocks:R,props:e});const t=w?.[R]?.page_id,a=O.find((e=>e.page_id===t));O.length>0&&t&&a?.page_id&&g(a),void 0!==w?.[R]?.orderOfSet&&n&&k(w?.[R]?.orderOfSet)}),[w,O,R]),c((()=>{Ie("useEffect",{blocks:u,initialPivotAnswer:e.initialPivotAnswer,props:e});let t={..._};if(W.isConsideredCompleted&&N.current&&e.canResubmit)return;const{others_meta:o,...r}=e.answers||{};S.current={...S.current,question:kP({questions:a,blocks:u})};const c=a.find((e=>e.name===u?.[0]?.question_name||e.name===u?.[0]?.question_names?.[0]))??S.current.question;if(we(r)||void 0===e.initialPivotAnswer||r[c.name]===e.initialPivotAnswer||(t={..._,formValues:{..._.formValues,[c.name]:e.initialPivotAnswer},moveToNextPage:!0}),void 0!==e.initialPivotAnswer){const n=EP(S.current.question,e.initialPivotAnswer);S.current={...S.current,answer:"BOOLEAN"===c?.type_info?.question_type||"RESOLUTION"===c?.type_info?.question_type?Boolean(n):n},t={..._,formValues:{..._.formValues,[c.name]:S.current.answer},moveToNextPage:!1}}else void 0!==e.initialQuestionAnswer&&(t={..._,formValues:{..._.formValues,[c.name]:e.initialQuestionAnswer},moveToNextPage:!1});B(t);const s=NP({pivotQn:S.current.question,pivotQnAnswer:S.current.answer,block:u[0],questions:a}),l=u?.find((e=>e.question_name===s?.name)),d="NEXT"===l?.nav_option,b=(s?.dependent_blocks?.filter((e=>"ALL"!==e.condition_type)).length??0)>0,M=!d||b&&!s?.type_info?.pivot_question?[]:t$({activeBlock:{...u[0],question:s},blocks:u,questions:a,answers:t,pages:O,renderedBlocks:w,contactData:i,surveyLayout:"standard",initialTransition:!0,isEditResponse:H.current,branchSeparatePage:n}),z=[{...u[0],question:s},...M];if(L(n?Xe(z,p):z),(e=>{if(null==e||0===Object.keys(e).length)return!0;const t=Object.keys(e).filter((e=>""!==e&&!qe(e)&&"others_meta"!==e));return t.every((t=>!e[t]))&&(!e.others_meta||0===Object.keys(e.others_meta).length)})({others_meta:{},...t.formValues})||N.current)C(u.findIndex((e=>z[0].name===e.name))),k(0);else{const e=z?.[z.length-1];C(z.findIndex((t=>t.name===e?.name))),n&&k(e?.orderOfSet!==x?e?.orderOfSet:0)}T({})}),[u,e.initialPivotAnswer,h]);c((()=>{if(Ie("useEffect",{answers:_,blocks:u,props:e}),!(W.isConsideredCompleted&&N.current&&e.canResubmit)&&(!we(_.formValues)||_.moveToNextPage)&&u&&F(V,_.commitDirtyValue))if(UP({blocks:u,activeIndexOfBlocks:X,renderedBlocks:w,activeIndexOfRenderedBlocks:R,answers:_,questions:a,activePage:v,pages:O,surveyLayout:"standard"})){if(void 0!==e.initialPivotAnswer&&1===w.length&&N.current&&!_.commitDirtyValue);else if(_.commitDirtyValue){const t=XP({renderedBlocks:w,activeBlock:V,blocks:u,activeIndexOfBlocks:X,answers:_,questions:a,contactData:i,pages:O,surveyLayout:"standard",isDisplayBlock:!0});if(t!==1/0)N.current||!V.question.type_info?.question_type||V.question.type_info?.question_comment||["FORM_FIELD","MULTI_SELECT","RANK_ORDER"].includes(V.question.type_info?.question_type)?U():(e=>{e!==1/0&&setTimeout((()=>{const t=NP({pivotQn:S.current?.question,pivotQnAnswer:S.current?.answer,block:u?.[e],questions:a});if(t?.name){const e=document?.querySelector(`.question-container.standard-card-${t.name}`),n=document?.querySelector(`.question-container.standard-card-${t.name} input`),a=document?.querySelector(`.question-container.standard-card-${t.name} textarea`);e?.scrollIntoView({behavior:"smooth",block:"center",inline:"start"}),setTimeout((()=>{n?.focus(),a?.focus()}),le)}U()}),0)})(t),(!_.moveToNextPage&&!n&&t&&t>0&&u[t-1]?.page_id===u[t]?.page_id||_.moveToNextPage)&&((e,t)=>{if(e===1/0)return;const o=u?.[e];let r=S.current?.question;o?.display_logic?.some((e=>"BASED_ON_RATING_GROUP"===e.logic_type))&&(r=kP({questions:a,blocks:u,displayLogic:o?.display_logic}));const c=NP({pivotQn:r??S.current?.question,pivotQnAnswer:_?.formValues[r?.name]??S.current?.answer,block:o,questions:a}),s=e$({renderedBlocks:w,activeIndexOfRenderedBlocks:R}),l=u?.[e],d=t$({activeBlock:{...l,question:c},answers:_,blocks:u,questions:a,pages:O,renderedBlocks:w,contactData:i,surveyLayout:"standard",isEditResponse:H.current,branchSeparatePage:n}),b=[...s,...c?.name?[{...l,question:c}]:[],...d];T((e=>{const t={...e};return b.forEach((e=>{"MATRIX_RATING_SCALE"===e.question.type_info?.question_type&&(t[e.question.name]=0)})),t}));const M=n?Xe(b,p):b;L(M),t||C(s.length)})(t,!_.moveToNextPage&&!n);else{GP("submit",{answers:_,blocks:u,blockIndex:0,activeIndexOfBlocks:X,initialStatementHasAnswer:Y,activeIndexOfRenderedBlocks:R,activeIndexOfRenderedStatement:E,renderedBlocks:w,activePage:v,isMobile:!!e.isMobile,surveyStyle:e.surveyStyle,isWidget:!!e.isWidget,initialPivotAnswer:e.initialPivotAnswer,isInitialTransition:N.current,questions:a,pages:O,contactData:e.contactData,activeIndexOfSet:x,branchSeparatePage:n,isSubmitting:y})||U("COMPLETE")}}}else("MATRIX_RATING_SCALE"===V?.question?.type_info?.question_type||_.commitDirtyValue)&&U()}),[_,u]);const F=(e,t)=>{if(e?.question_name)switch(e.question?.type_info?.question_type){case"DATE_TIME":return!t||r$({answer:_.formValues?.[e.question_name]||"",errorSetter:M,questionName:e.question_name,errors:b,translationVariables:l});case"FORM_FIELD":return i$({fields:e.question?.type_info?.form_fields?.fields,answers:_.formValues?.[e.question_name]||{},errorSetter:M,questionName:e.question_name,errors:b,translationVariables:l});case"TEXT":return c$({type:e.question?.type_info?.text_field?.text_type,answer:_.formValues?.[e.question_name]||"",errorSetter:M,questionName:e.question_name,errors:b,translationVariables:l});case"CONTACT_FORM":return s$({fields:e.question?.type_info?.contact_form?.fields,answers:_.formValues?.[e.question_name]||{},errorSetter:M,questionName:e.question_name,errors:b,translationVariables:l});case"FILE":return l$({errors:b.fileUploadErrors})||!e.required}return!0},U=(t="PARTIAL")=>{let n=()=>{},o=0;if(w.some(((e,t)=>(o=t,!F(e,!0)))))return void C(o);let r={..._.formValues};if("COMPLETE"===t){q(!0),n=()=>{q(!1),I(!0),H.current=!1};r=p$({pages:O,answers:{..._,formValues:r},blocks:u,questions:a,contactData:i,surveyLayout:"standard"})}e.onSubmit({...r,others_meta:_.others},n,t,H.current?"EDIT":"CREATE")},G=e=>{T((t=>({...t,[e]:(qe(t[e])?0:t[e])+1})))},Y=t.useMemo((()=>{if("MATRIX_RATING_SCALE"!==V?.question?.type_info?.question_type)return!1;const e=V?.question?.type_info?.matrix_properties?.statements||[],t=e?.[E?.[V?.question.name]]??0,n=(_.formValues[V?.question.name]||[]).find((e=>e.statement_id===t?.id));return(n?.rating_labels||[]).length>0}),[E,R]),Z=()=>{const e=O.findIndex((e=>e.page_id===v?.page_id));let t=1,n=O?.[e+t];for(;!w.map((e=>e.page_id)).includes(n?.page_id)&&e+t<O.length;)n=O?.[e+ ++t];const a=w.find((e=>e.page_id===n?.page_id));n?.page_id&&g(n),"number"==typeof a?.orderOfSet&&k(a.orderOfSet);const o=w.findIndex((e=>e.page_id===n?.page_id));-1!==o&&C(o)},K=()=>{const e=O.findIndex((e=>e.page_id===v?.page_id));let t=1,n=O?.[e-t];for(;e-t>=0&&(!n||!w.some((e=>e.page_id===n.page_id)));)t++,n=O[e-t];if(!n)return;const a=w.find((e=>e.page_id===n.page_id));n.page_id&&g(n),"number"==typeof a?.orderOfSet&&k(a.orderOfSet);const o=w.findIndex((e=>e.name===a?.name));-1!==o&&C(o)};return{blocks:u,pages:O,navigateToNextSet:()=>{const e=w.find((e=>e.orderOfSet===x+1));if(e){n&&void 0!==e?.orderOfSet&&k(e?.orderOfSet);const t=O.find((t=>t.page_id===e?.page_id));t?.page_id&&g(t),B((e=>({...e,moveToNextPage:!1})))}else Z()},navigateToPreviousSet:()=>{const e=w.find((e=>e.orderOfSet===x-1));if(!e)return void K();n&&"number"==typeof e.orderOfSet&&k(e.orderOfSet);const t=O.find((t=>t.page_id===e.page_id));t?.page_id&&g(t);const a=w.findIndex((t=>t.name===e.name));-1!==a&&C(a)},activePage:v,questions:a,renderedBlocks:w,initialStatementHasAnswer:Y,activeBlock:V,activeIndexOfBlocks:X,activeIndexOfRenderedBlocks:R,activeIndexOfRenderedStatement:E,navigateToNextStatement:G,navigateToPreviousStatement:e=>{T((t=>({...t,[e]:(qe(t[e])?0:t[e])-1})))},isInitialTransition:N.current,isSurveyCompleted:D,pivot:S.current,answers:_,translationVariables:l,...b,setErrors:M,saveFormValues:(e,t,o=!1,r=R)=>{if(y)return;N.current=!1,e.question.name===S.current?.question.name&&(S.current={...S.current,answer:"BOOLEAN"===S.current?.question?.type_info?.question_type?Boolean(t):t}),r!==R&&C(r);const c={..._,formValues:{..._.formValues,[e.question.name]:"BOOLEAN"===e.question?.type_info?.question_type||"RESOLUTION"===e.question?.type_info?.question_type?Boolean(t):t},commitDirtyValue:o,moveToNextPage:!1};n$((({renderedBlocks:e,activeIndexOfRenderedBlocks:t})=>e$({renderedBlocks:e,activeIndexOfRenderedBlocks:t}).map((({question:e})=>e)))({renderedBlocks:w,activeIndexOfRenderedBlocks:r}),c),H.current&&(e.category??[]).length>0&&(e.category?.forEach((e=>{e.question_name&&(c.formValues[e.question_name]=null)})),c.formValues[e.question.name]=t),B(c),(e.question?.dependent_blocks?.length??0)>0&&L((t=>{const o=t.slice(0,r+1),s=t$({activeBlock:e,blocks:u,questions:a,answers:c,pages:O,renderedBlocks:o,contactData:i,surveyLayout:"standard",isEditResponse:H.current,branchSeparatePage:n}),l=[...o,...s];return n?Xe(l,p):l}));const s=w[r];"SINGLE_ANSWER"===s.question.type_info?.matrix_properties?.type&&(E?.[s.question.name]??0)<(s.question?.type_info?.matrix_properties?.statements||[]).length-1&&setTimeout((()=>{G?.(s.question.name)}),0)},saveOthersValue:(e,t,n=R)=>{if(n!==R&&C(n),null===t){const t={..._.others};delete t[e],B({..._,commitDirtyValue:!1,others:t,moveToNextPage:!1})}else B({..._,commitDirtyValue:!1,others:{..._.others,[e]:t},moveToNextPage:!1})},clearRadioSelection:e=>{C(e);const t=w[e].question;t.type_info?.pivot_question&&(S.current={question:t,answer:void 0}),delete _.formValues[t.name],delete _.others[t.name],"DATE_TIME"===t.type_info?.question_type&&b.dateQuestionErrors?.[t.name]&&M((e=>{const n={...e.dateQuestionErrors};return delete n[t.name],{...e,dateQuestionErrors:n}}));const o=(({renderedBlocks:e,answers:t})=>{const n=e.reduce(((e,n)=>(n?.question?.name&&void 0!==t.formValues[n.question.name]&&(e[n.question.name]=t.formValues[n.question.name]),e)),{});return{...t,formValues:n}})({renderedBlocks:w,answers:_}),r={...o,formValues:{...o.formValues},moveToNextPage:!1,commitDirtyValue:!1},c=t$({activeBlock:w[e],blocks:u,questions:a,answers:r,pages:O,renderedBlocks:w,contactData:i,surveyLayout:"standard",isEditResponse:H.current,branchSeparatePage:n});T((e=>{const t={...e};return c.forEach((e=>{"MATRIX_RATING_SCALE"===e.question.type_info?.question_type&&(t[e.question.name]=0)})),t}));const s=[...w.slice(0,e+1),...c];L(n?Xe(s,p):s),B(r)},onSubmitHandler:U,navigateToStart:()=>{H.current=!0,I(!1),T({}),C(0),n&&("number"==typeof w?.[0].orderOfSet?k(w?.[0].orderOfSet):k(0))},isValidQuestion:F,resetSurvey:()=>{I(!1),N.current=!0,f((e=>e+1)),B({formValues:{},others:{},commitDirtyValue:!1,moveToNextPage:!1}),u$(localStorage)},moveToNextPage:e=>{const t={};e&&O.length>0&&w.forEach((e=>{v?.page_id!==e.page_id||n&&x!==e.orderOfSet||"MESSAGE"===e.question.type_info?.question_type||(t[e.question.name]=null)})),we(_.formValues??{})&&O.length>0&&w.forEach((e=>{v?.page_id!==e.page_id||n&&x!==e.orderOfSet||"MESSAGE"!==e.question.type_info?.question_type||(t[e.question.name]=null)}));const a=w.filter((e=>v?.page_id===e?.page_id)),o=a[a.length-1],i=w.findIndex((e=>e.name===o?.name));R!==i&&C(i),setTimeout((()=>{B((e=>({...e,formValues:{...e.formValues,...t},commitDirtyValue:!0,moveToNextPage:!0})))}),0)},moveToNextSet:e=>{let t=0;if(w.some(((e,n)=>(t=n,!F(e,!0)))))return void C(t);const a={};w.forEach((t=>{v?.page_id!==t.page_id||n&&x!==t.orderOfSet||!e&&void 0!==_.formValues[t.question.name]||(a[t.question.name]=null)})),we(_.formValues??{})&&O.length>0&&w.forEach((e=>{v?.page_id!==e.page_id||n&&x!==e.orderOfSet||"MESSAGE"!==e.question.type_info?.question_type||(a[e.question.name]=null)}));const o=w.filter((e=>v?.page_id===e?.page_id&&(!n||x===e.orderOfSet))),i=o[o.length-1],r=w.findIndex((e=>e.name===i?.name));C(r),setTimeout((()=>{B((e=>({...e,formValues:{...e.formValues,...a},commitDirtyValue:!0,moveToNextPage:!0})))}),0)},setIsSubmitting:q,isSubmitting:y,expanded:z,setExpanded:m,activeIndexOfSet:x,setActiveRenderedBlockIndex:C,isQuestionBgDark:j}},w4=["next","next-statement","next-page","next-set","skip","skip-statement","skip-page","skip-set","submit","navigation","set-navigation","clear-selection","message","consent","navigation-prev","navigation-next","navigation-page-prev","navigation-page-next","previous-matrix-statement","next-matrix-statement","navigation-set-prev","navigation-set-next"],L4=({translationVariables:e,canDisplayDisableButtonParams:n,navigateToNextSet:a,navigateToPreviousSet:o})=>t.createElement("div",{className:"freemium-survey-step-navigation ss-navigation-buttons","data-navigation-element":"1"},t.createElement("button",{disabled:JP("navigation-set-prev",n),className:"navigation-button ss-navigation-button",onClick:o,title:e?.prev_question??"go to previous question"},t.createElement(Ge,{name:"arrow-previous"})),t.createElement("button",{className:"navigation-button ss-navigation-button",disabled:JP("navigation-set-next",n),title:e?.next_question||"Go to next question",onClick:a},t.createElement(Ge,{name:"arrow-next"}))),R4=({surveyServAssetUrl:e,thankYouQuestion:n,preview:a,placeholders:o,canResubmit:i,allowMultipleSubmission:r,navigateToStart:l,resetSurvey:p,isMobile:u,pivot:d,answers:b,questions:M,rangeToRender:z,translationVariables:m})=>{const{redirectUrl:h,redirectDelay:f,image_url:O,show_custom_button:A,show_review_links:v,show_social_links:g}=n?.type_info?.meta??{},[y,q]=s(f??10),[W,w]=t.useState(!1);return c((()=>{if(!a&&h){const e=setInterval((()=>q((e=>e>1?e-1:("undefined"!=typeof window&&(window.location.href=h??""),0)))),1e3);return()=>{clearInterval(e),w(!1)}}return()=>{w(!1)}}),[]),t.createElement("div",{className:"thankyou-container"},t.createElement("div",{className:"question-container ss-question-container thankyou"},O&&t.createElement("img",{className:"thankyou-logo-img ss-thankyou-logo",src:O,alt:"thankyou_logo"}),t.createElement(t.Fragment,null,xe(n)),t.createElement("div",{className:"text ss-thankyou-message",dangerouslySetInnerHTML:{__html:Ee({questionText:n.text,placeholders:o,npsRating:Te({theme:"nps",answers:b,questions:M})??"",npsRatingLabel:Se({theme:"nps",answers:b,questions:M}),csatRating:Te({theme:"csat",answers:b,questions:M})??"",csatRatingLabel:Se({theme:"csat",answers:b,questions:M}),cesRating:Te({theme:"ces",answers:b,questions:M})??"",cesRatingLabel:Se({theme:"ces",answers:b,questions:M}),preference:d?.question.type_info?.scale_properties?.labels?.preference,isPreview:a})}}),(i||r)&&t.createElement("div",{className:("wrap-up-actions "+(u?"mobile":"")).trim()},i&&t.createElement("button",{className:"action-button",tabIndex:0,disabled:W,onClick:()=>{w(!0),l()}},t.createElement(Ge,{name:"edit"}),m?.edit_response||"Edit your response"),r&&t.createElement("button",{className:"action-button",tabIndex:0,disabled:W,onClick:()=>{w(!0),p()}},t.createElement(Ge,{name:"reload"}),m?.another_response||"Submit another response")),h&&t.createElement(t.Fragment,null,t.createElement("div",{className:"redirection-text"},$e(y,m?.redirect_msg),t.createElement("br",null)),t.createElement("a",{className:"link",href:h},h)),t.createElement(h$,{show_custom_button:A,show_review_links:v,show_social_links:g,surveyServAssetUrl:e})))},C4=e=>{const{blockIndex:n,renderedBlocks:a,activeIndexOfRenderedBlocks:o,translationVariables:i,saveFormValues:r,answers:c,clearRadioSelection:s,canDisplayDisableButtonParams:l,navigateToNextStatement:p,navigateToPreviousStatement:u,isSubmitting:d,isMobile:b}=e,M={};w4.forEach((e=>{M[e]=!!GP(e,l)}));const z=a[n??o],{question:m}=z,h=m?.type_info?.meta?.display_format;return M?.consent||M?.["previous-matrix-statement"]||M?.["next-matrix-statement"]||M?.["clear-selection"]||M?.message?t.createElement("div",{className:"question-footer ss-question-footer-container"},t.createElement("div",null,(M?.["previous-matrix-statement"]||M?.["next-matrix-statement"])&&"MATRIX_RATING_SCALE"===m?.type_info?.question_type&&t.createElement("div",{className:"freemium-survey-step-navigation ss-navigation-buttons","data-navigation-element":"1"},t.createElement("button",{disabled:JP("previous-matrix-statement",l),className:"navigation-button ss-navigation-button",onClick:()=>{u(m.name)},title:i?.prev_question??"go to previous question"},t.createElement(Ge,{name:"arrow-previous"})),t.createElement("button",{className:"navigation-button ss-navigation-button",disabled:JP("next-matrix-statement",l),title:i?.next_question||"Go to next question",onClick:()=>{p(m.name)}},t.createElement(Ge,{name:"arrow-next"})))),t.createElement("div",{className:("action-buttons ss-action-buttons "+(M.consent?"question-consent-buttons ss-consent-action-buttons":"")).trim()},M?.["clear-selection"]&&t.createElement(et,{className:"sec-button",variant:"secondary",onClick:()=>s(n),disabled:d},e?.survey?.meta?.action_button?.clear_selection||i?.actionButtonText?.clear_selection||i?.clear_selection||"Clear selection"),b&&"MATRIX_RATING_SCALE"===m.type_info?.question_type&&"MULTIPLE_ANSWERS"===m?.type_info?.matrix_properties?.type&&M?.["next-matrix-statement"]&&t.createElement(et,{disabled:JP("next-matrix-statement",l),className:"primary-button",variant:"primary",onClick:()=>{p(m.name)}},e?.survey?.meta?.action_button?.next||i?.actionButtonText?.next||i?.next||"Next"),M?.consent&&"BUTTON"===h&&fe.map((e=>t.createElement(et,{key:o+String(e.recordAs),onClick:()=>{r(z,e.recordAs,!1,n)},disabled:JP("consent",l),variant:qe(c.formValues?.[m.name])||c.formValues?.[m.name]===e.recordAs?"primary":"secondary",className:("consent-button ss-action-consent-button "+(c.formValues?.[m.name]===e.recordAs?"selected":"")).trim()},m?.type_info?.scale_properties?.labels?.values?.[e.id]??e.defaultValue))))):null},x4=e=>{const{pages:n,activePage:a,navigateToNextSet:i,navigateToPreviousSet:l,isInitialTransition:p,blocks:u,renderedBlocks:d,activeBlock:b,activeIndexOfBlocks:M,activeIndexOfRenderedBlocks:z,isSurveyCompleted:m,translationVariables:h,saveFormValues:f,saveOthersValue:O,clearRadioSelection:A,onSubmitHandler:v,answers:g,questions:y,resetSurvey:q,initialStatementHasAnswer:W,navigateToStart:w,activeIndexOfRenderedStatement:L,navigateToNextStatement:R,navigateToPreviousStatement:C,pivot:x,formQuestionErrors:k,dateQuestionErrors:E,textboxQuestionErrors:T,contactFormErrors:S,fileUploadErrors:N,setErrors:P,isSubmitting:$,setIsSubmitting:_,moveToNextSet:B,expanded:H,setExpanded:D,activeIndexOfSet:I,isValidQuestion:V,setActiveRenderedBlockIndex:X,isQuestionBgDark:j}=W4(e);Ie("Standard",{...e,answers:g,activePage:a,activeBlock:b,renderedBlocks:d,activeIndexOfSet:I,activeIndexOfBlocks:M,activeIndexOfRenderedBlocks:z,activeIndexOfRenderedStatement:L});const F=!!e.survey.meta?.branch_separate_page,U=r(null),G=r({}),Y=r(null),Z=o((()=>ke(x?.question)),[x?.question]),K=o((()=>u.filter((({name:e},t,n)=>!BP({nextBlockName:e||"",blocks:n,questions:y}))).length),[u,y]),Q=we(g.formValues)&&e.survey.prompt_settings?.is_enabled&&e.preview,[J,ee]=s(Q),te=d.filter((e=>a?.page_id===e?.page_id));c((()=>{const t=Object.values(g.formValues).filter((e=>"string"==typeof e&&""!==e.trim()||"number"==typeof e||"boolean"==typeof e||Array.isArray(e)&&e.length>0||"object"==typeof e&&null!==e&&Object.keys(e).length>0)).length;e.getSurveyProgress?.({totalBlocks:K,isSurveyCompleted:m,noOfAnswers:m||t>K?K:t})}),[K,g,m]),c((()=>{e.survey.theme&&Ne(e.survey.theme,e.surveyServAssetUrl??"")}),[e.survey.theme,e.surveyServAssetUrl]),c((()=>{setTimeout((()=>{Y.current&&Object.keys(g.formValues).length&&Y.current?.scrollIntoView({inline:"start",block:"start",behavior:"smooth"})}),0),b&&e.onBlockChange?.(b,a)}),[a?.page_id]);const[ne,ae]=s(!1);if(!b||!b.question)return null;const{question:oe}=d[z],ie={answers:g,blocks:u,blockIndex:0,activeIndexOfBlocks:M,initialStatementHasAnswer:W,activeIndexOfRenderedBlocks:z,activeIndexOfRenderedStatement:L,renderedBlocks:d,activePage:a,isMobile:!!e.isMobile,surveyStyle:e.surveyStyle,isWidget:!!e.isWidget,initialPivotAnswer:e.initialPivotAnswer,isInitialTransition:p,questions:y,pages:n,contactData:e.contactData,activeIndexOfSet:I,branchSeparatePage:F,isSubmitting:$,secBtnTxt:e.secBtnTxt,isNavigatedBefore:ne,pivot:x},re={};w4.forEach((e=>{re[e]=!!GP(e,ie)}));const ce=d[d.length-1];return t.createElement("div",{className:`freemium-survey-components ${Le(e.language||"en")?"freemium-survey-rtl":"freemium-survey-ltr"} ${e.isMobile?"mobile-preview":""} standard-survey-style`,id:"freemium-survey",ref:Y},J&&e.survey.prompt_settings?t.createElement("div",{className:"questions ss-questions"},t.createElement("div",{className:"question-container ss-question-container"},t.createElement(z$,{config:e.survey.prompt_settings,onSelect:t=>{e.onAnsweringPrompt?.(t),1===t&&ee(!1)},placeholders:e.placeholders,isPreview:!!e.preview}))):t.createElement(t.Fragment,null,m?t.createElement(R4,{surveyServAssetUrl:e.surveyServAssetUrl??"",thankYouQuestion:NP({pivotQn:x?.question,pivotQnAnswer:x?.answer,block:HP({activeBlock:ce,blocks:e.survey.blocks?.filter((e=>!e.is_deleted)),answers:g,questions:y,activeIndexOfBlocks:u.findIndex((e=>e.name===ce.name)),renderedBlocks:d,contactData:e.contactData,surveyLayout:"standard",pages:n}),questions:y}),answers:g,preview:!!e.preview,placeholders:e.placeholders,pivot:{...x,question:x?.question||{name:""},answer:x?.answer},rangeToRender:Z,canResubmit:e.canResubmit,isMobile:e.isMobile,allowMultipleSubmission:e.allowMultipleSubmission,translationVariables:h,navigateToStart:()=>{e.handleAction?e.handleAction("EDIT_RESPONSE",(()=>{_(!1),w()})):(_(!1),w())},resetSurvey:()=>{e.handleAction?e.handleAction("RE_SUBMIT",(()=>{_(!1),q()})):(_(!1),q())}}):t.createElement(t.Fragment,null,n.length>0&&a?.page_id&&t.createElement(b$,{expanded:H,id:a.page_id,setExpanded:D,activePage:a,translationVariables:h}),t.createElement("div",{className:("questions "+(e?.secBtnTxt?"sec-btn":"")).trim()},d.map(((o,i)=>{if(n.length>0&&a?.page_id!==o?.page_id||e.survey.meta?.branch_separate_page&&o.orderOfSet!==I)return null;const r=te.findIndex((e=>e.name===o.name)),c=XP({renderedBlocks:d,activeBlock:b,blocks:u,activeIndexOfBlocks:M,answers:g,questions:y,contactData:e.contactData,pages:n,surveyLayout:"standard"});return t.createElement(PE.div,{id:o.question.name,key:o.question.name,ref:U,className:`question-container ss-question-container standard-card-${o.question.name}`,"data-test-question-name":b.question.name,initial:{opacity:0},animate:{opacity:1,x:0},exit:{opacity:0},transition:{duration:.2,delay:r?r/15:0},..."MULTI_SELECT"===b.question.type_info?.question_type&&c!==1/0&&-1!==c&&void 0!==g.formValues?.[o.question.name]&&G.current[o.question.name]!==g.formValues?.[o.question.name]?{onMouseLeave:()=>{f(o,g.formValues?.[o.question.name],!0,i),G.current[o.question.name]=g.formValues?.[o.question.name]}}:{}},t.createElement("div",{className:`question-text ss-question-text ${o.required?"required":""} ${0===i?"nps":""}`.trim(),dangerouslySetInnerHTML:{__html:Ee({questionText:o.question.text,placeholders:e.placeholders,npsRating:Te({theme:"nps",answers:g,questions:y})??"",npsRatingLabel:Se({theme:"nps",answers:g,questions:y}),csatRating:Te({theme:"csat",answers:g,questions:y})??"",csatRatingLabel:Se({theme:"csat",answers:g,questions:y}),cesRating:Te({theme:"ces",answers:g,questions:y})??"",cesRatingLabel:Se({theme:"ces",answers:g,questions:y}),preference:x?.question.type_info?.scale_properties?.labels?.preference,isPreview:!!e.preview})},"aria-label":`question-${i}`,role:"heading","aria-level":1}),t.createElement(A4,{surveyServAssetUrl:e.surveyServAssetUrl,fileUploadErrors:N,setErrors:P,onFileUpload:e.onFileUpload,block:o,preview:!!e.preview,surveyLanguage:e.survey.language,language:e.language||"en",question:o.question,surveyStyle:e.surveyStyle,isFinalQn:SP({blocks:u,activeIndexOfBlocks:M,renderedBlocks:d,activeIndexOfRenderedBlocks:z,questions:y}),formValues:g.formValues,othersMeta:g.others,isMobile:!!e.isMobile,autoFocusDelay:20,activeIndexOfRenderedStatement:L,saveOthersValue:(e,t)=>{O(e,t,i)},onChangeHandler:(e,t)=>{const n=o.question.type_info?.question_type;f(o,e,!!n&&["RANGE","DROPDOWN","BOOLEAN"].includes(n)||t,i)},initialPivotAnswer:e.initialPivotAnswer,initialQuestionAnswer:e.initialQuestionAnswer,formQuestionErrors:k,dateQuestionErrors:E,textboxQuestionErrors:T,contactFormErrors:S,translationVariables:h,isQuestionBgDark:j}),"MESSAGE"!==o.question.type_info?.question_type&&t.createElement(C4,{canDisplayDisableButtonParams:{...ie,blockIndex:i},language:e.language||"en",isWidget:!1,surveyStyle:e.surveyStyle,answers:g,renderedBlocks:d,blocks:u,pages:n,survey:e.survey,blockIndex:i,isInitialTransition:p,activeIndexOfRenderedBlocks:z,initialStatementHasAnswer:W,navigateToNextStatement:R,navigateToPreviousStatement:C,activeIndexOfRenderedStatement:L,activeIndexOfBlocks:M,saveFormValues:f,isMobile:!!e.isMobile,clearRadioSelection:A,initialPivotAnswer:e.initialPivotAnswer,translationVariables:h,formQuestionErrors:k,dateQuestionErrors:E,textboxQuestionErrors:T,contactFormErrors:S,fileUploadErrors:N,questions:y,isSubmitting:$}))}))),t.createElement("div",{className:"page-actions"},t.createElement("div",null,re["set-navigation"]&&t.createElement(L4,{answers:g,canDisplayDisableButtonParams:ie,activeIndexOfBlocks:M,pages:n,activeIndexOfRenderedBlocks:z,renderedBlocks:d,initialStatementHasAnswer:W,blocks:u,activeIndexOfRenderedStatement:L,translationVariables:h,navigateToPreviousSet:l,navigateToNextSet:i})),t.createElement("div",{className:"page-action-buttons ss-page-action-buttons"},e?.secBtnTxt&&t.createElement(et,{variant:"secondary",onClick:()=>{ae(!0),e?.handleSecondaryAction?.({answers:g.formValues,survey:e.survey})},"aria-label":"secondary-action",disabled:$},e.secBtnTxt),re["skip-set"]&&t.createElement(et,{variant:"secondary",onClick:()=>{ae(!0),B(!0)},"aria-label":"skip set",disabled:$},e?.survey?.meta?.action_button?.skip||h?.actionButtonText?.skip||h?.skip||"Skip"),re?.["next-set"]&&t.createElement(et,{onClick:()=>{B(),ae(!0)},disabled:!!JP("next-set",ie),className:"next-set"},e?.survey?.meta?.action_button?.next||h?.actionButtonText?.next||h?.next||"Next"),re.submit&&!re?.["next-set"]&&t.createElement(et,{disabled:!!JP("submit",ie),onClick:()=>{let e=0;d.some(((t,n)=>(e=n,!V(t,!0))))?X(e):we(E?.[oe.name])&&we(k?.[oe.name])&&we(T?.[oe.name])&&we(N?.[oe.name])&&we(S?.[oe.name])&&v("COMPLETE")}},e?.survey?.meta?.action_button?.submit||h?.actionButtonText?.submit||h?.submit_survey||"Submit"))))),!e.secBtnTxt&&!e.footerProps?.hideFooter&&(e?.footerProps?.languageDDComponent||e?.footerProps?.showFWBranding||e.footerProps?.footerContent)&&t.createElement(Ya,{...e.footerProps,surveyStyle:e.surveyStyle,bgColor:e.survey.theme?.palette?.footer_background??e.survey.theme?.palette?.survey_background??m$}))},k4=e=>t.createElement("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("g",{clipPath:"url(#clip0_8207_70478)"},t.createElement("rect",{width:"10",height:"10",fill:"white",fillOpacity:"0.01"}),t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.62499 3.19375C8.62499 3.4 8.79374 3.56875 8.99999 3.56875C9.20624 3.56875 9.37499 3.4 9.37499 3.19375V1C9.37499 0.79375 9.20624 0.625 8.99999 0.625H6.80624C6.59999 0.625 6.43124 0.79375 6.43124 1C6.43124 1.20625 6.59999 1.375 6.80624 1.375H8.09377L5.66876 3.80001C5.52501 3.95001 5.52501 4.18751 5.66876 4.33126C5.73751 4.40626 5.83751 4.44376 5.93126 4.44376V4.45001C6.02501 4.45001 6.11876 4.41251 6.19376 4.33751L8.62499 1.90628V3.19375ZM1 9.37501H1.00738H3.19375C3.4 9.37501 3.56875 9.20626 3.56875 9.00001C3.56875 8.79376 3.4 8.62501 3.19375 8.62501H1.90626L4.3375 6.19376C4.48125 6.04376 4.48125 5.80626 4.3375 5.66251C4.1875 5.51876 3.95 5.51876 3.80625 5.66251L1.375 8.09376V6.80626C1.375 6.60001 1.20625 6.43126 1 6.43126C0.79375 6.43126 0.625 6.60001 0.625 6.80626V9.00001C0.625 9.20626 0.79375 9.37501 1 9.37501Z",fill:"#264966"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_8207_70478"},t.createElement("rect",{width:"10",height:"10",fill:"white"})))),E4=e=>t.createElement("svg",{width:"8",height:"2",viewBox:"0 0 8 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},t.createElement("path",{d:"M7.3 1.4H0.7C0.313401 1.4 0 1.0866 0 0.699999C0 0.3134 0.313401 0 0.7 0H7.3C7.6866 0 8 0.3134 8 0.699999C8 1.0866 7.6866 1.4 7.3 1.4Z",fill:"#264966"})),T4=({surveyServAssetUrl:e,thankYouQuestion:n,placeholders:a,canResubmit:o,navigateToStart:i,resetSurvey:r,widgetStyle:s,allowMultipleSubmission:l,pivot:p,rangeToRender:u,answers:d,questions:b,translationVariables:M,isQuestionBgDark:z})=>{const{show_custom_button:m,show_review_links:h,show_social_links:f,image_url:O}=n?.type_info?.meta??{},[A,v]=t.useState(!1);return c((()=>()=>{v(!1)}),[]),t.createElement("div",{className:"question-container ss-question-container thankyou"},O&&t.createElement("img",{className:"thankyou-logo-img ss-thankyou-logo",src:O,alt:"thankyou_logo"}),t.createElement("div",{className:O?"heading":"heading thankyou-image"},t.createElement(t.Fragment,null,xe(n))),t.createElement("div",{className:O?"text ss-thankyou-message":"text ss-thankyou-message thankyou-image",dangerouslySetInnerHTML:{__html:Ee({questionText:n.text,placeholders:a,npsRating:Te({theme:"nps",answers:d,questions:b})??"",npsRatingLabel:Se({theme:"nps",answers:d,questions:b}),csatRating:Te({theme:"csat",answers:d,questions:b})??"",csatRatingLabel:Se({theme:"csat",answers:d,questions:b}),cesRating:Te({theme:"ces",answers:d,questions:b})??"",cesRatingLabel:Se({theme:"ces",answers:d,questions:b}),preference:p?.question.type_info?.scale_properties?.labels?.preference})}}),(o||l)&&t.createElement("div",{className:`wrap-up-actions ${O?"":"thank-you-image"} ${"compact"===s?"mobile":""}`.trim()},o&&t.createElement("button",{className:"action-button",tabIndex:0,disabled:A,onClick:()=>{v(!0),i()}},t.createElement(Ge,{name:"edit"}),M?.edit_response||"Edit your response"),l&&t.createElement("button",{className:"action-button",tabIndex:0,disabled:A,onClick:()=>{v(!0),r()}},t.createElement(Ge,{name:"reload"}),M?.another_response||"Submit another response")),t.createElement(h$,{show_custom_button:m,show_review_links:h,show_social_links:f,surveyServAssetUrl:e}))},S4=({translationVariables:e,activeIndexOfRenderedStatement:n,navigateToPreviousBlock:a,navigateToNextBlock:o,question:i,canDisplayDisableButtonParams:r,animationInProgress:c,setAnimationInProgress:s})=>t.createElement("div",{className:"freemium-survey-step-navigation ss-navigation-buttons","data-navigation-element":"1"},t.createElement("button",{disabled:c||!!JP("navigation-prev",r),className:"navigation-button ss-navigation-button",onClick:()=>{s(!0),setTimeout((()=>{s(!1)}),se),a()},title:i.name&&(n?.[i.name]??0)>0?e?.prev_statement||"go to previous statement":e?.prev_question||"go to previous question"},t.createElement(Ge,{name:"arrow-previous"})),t.createElement("button",{className:"navigation-button ss-navigation-button",disabled:c||!!JP("navigation-next",r),onClick:()=>{s(!0),setTimeout((()=>{s(!1)}),se),o()},title:e?.next_question||"go to next question"},t.createElement(Ge,{name:"arrow-next"}))),N4=e=>{const{widgetStyle:n,answers:a,initialStatementHasAnswer:o,renderedBlocks:i,blocks:r,activeIndexOfBlocks:c,navigateToNextStatement:l,activeIndexOfRenderedBlocks:p,translationVariables:u,saveFormValues:d,activeIndexOfRenderedStatement:b={},onSubmitHandler:M,skipBlock:z,skipStatement:m,navigateToNextBlock:h,navigateToPreviousBlock:f,formQuestionErrors:O,dateQuestionErrors:A,textboxQuestionErrors:v,fileUploadErrors:g,contactFormErrors:y,canDisplayDisableButtonParams:q,pages:W,setFooterElementRef:w,isSubmitting:L}=e,[R,C]=s(!1),{question:x}=i[p],k=x?.type_info?.question_type,E={...q,isSubmitting:L},T=(e=!1)=>{const n=e?[...fe].reverse():[...fe];return GP("consent",E)&&"BUTTON"===N&&n.map((e=>t.createElement(et,{key:p+String(e.id),onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),d(i[p],e.recordAs,!0)},disabled:R||JP("consent",E),variant:qe(a.formValues?.[x.name])||a.formValues?.[x.name]===e.recordAs?"primary":"secondary",className:("consent-button ss-action-consent-button "+(a.formValues?.[x.name]===e.recordAs?"selected":"")).trim()},x?.type_info?.scale_properties?.labels?.values?.[e.id]||e.defaultValue)))},S="compact"===n&&(GP("navigation",E)&&GP("skip",E)||"CONSENT"===k||"MESSAGE"===k),N=x?.type_info?.meta?.display_format;return t.createElement(t.Fragment,null,(GP("navigation",E)||GP("next",E)||GP("next-statement",E)||GP("consent",E)||GP("submit",E)||GP("skip",E)||GP("skip-statement",E)||GP("message",E))&&t.createElement("div",{className:"question-footer ss-question-footer-container",ref:e=>e?w?.(e):null},S?t.createElement("div",{className:"compact-footer-container"},GP("next",E)&&t.createElement(et,{onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),d(i[p],"CHECKBOX"===x?.type_info?.meta?.display_format&&"CONSENT"===x?.type_info?.question_type?a.formValues[x.name]??!1:a.formValues[x.name],!0)},disabled:R||!!JP("next",E),className:"next-button ss-action-next-button"},e?.survey?.meta?.action_button?.next||u?.next||"Next"),GP("message",E)&&t.createElement(et,{onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),z()},disabled:R||JP("message",E),className:"message-button ss-action-message-button"},x?.type_info?.scale_properties?.labels?.values?.[0]||"Begin"),GP("submit",E)&&t.createElement("div",{className:"submit ss-action-submit-button"},t.createElement(et,{disabled:R||!!JP("submit",E),onClick:()=>{we(A?.[x.name])&&we(O?.[x.name])&&we(v?.[x.name])&&we(g?.[x.name])&&we(y?.[x.name])&&(C(!0),setTimeout((()=>{C(!1)}),se),M("COMPLETE"))}},e?.survey?.meta?.action_button?.submit||u?.actionButtonText?.submit||u?.submit_survey||"Submit")),GP("next-statement",E)&&t.createElement(et,{onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),l?.(x.name)},disabled:R||!!JP("next-statement",E),className:"next-button ss-action-next-button"},e?.survey?.meta?.action_button?.next||u?.actionButtonText?.next||u?.next||"Next"),T(),t.createElement("div",{className:"compact-footer-layout"},t.createElement(S4,{animationInProgress:R,setAnimationInProgress:C,answers:a,canDisplayDisableButtonParams:E,pages:W,activeIndexOfBlocks:c,activeIndexOfRenderedBlocks:p,renderedBlocks:i,initialStatementHasAnswer:o,blocks:r,activeIndexOfRenderedStatement:b,question:x,translationVariables:u,navigateToNextBlock:h,navigateToPreviousBlock:f}),"MESSAGE"!==k&&!r[c].required&&t.createElement(et,{className:"skip-button ss-action-skip-button",onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),z()},variant:"secondary","aria-label":"skip question",disabled:R},e?.survey?.meta?.action_button?.skip||u?.actionButtonText?.skip||u?.skip||"Skip"))):t.createElement(t.Fragment,null,GP("navigation",E)?t.createElement(S4,{animationInProgress:R,setAnimationInProgress:C,answers:a,pages:W,canDisplayDisableButtonParams:E,activeIndexOfBlocks:c,activeIndexOfRenderedBlocks:p,activeIndexOfRenderedStatement:b,renderedBlocks:i,blocks:r,question:x,initialStatementHasAnswer:o,translationVariables:u,navigateToNextBlock:h,navigateToPreviousBlock:f}):t.createElement("div",null),t.createElement("div",{className:"action-buttons ss-action-buttons"},GP("skip",E)&&t.createElement(et,{className:"skip-button ss-action-skip-button",variant:"secondary",onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),z()},"aria-label":"skip question",disabled:R},e?.survey?.meta?.action_button?.skip||u?.actionButtonText?.skip||u?.skip||"Skip"),GP("skip-statement",E)&&t.createElement(et,{className:"skip-button ss-action-skip-button",variant:"secondary",onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),m()},"aria-label":"skip statement",disabled:R},e?.survey?.meta?.action_button?.skip||u?.actionButtonText?.skip||u?.skip||"Skip"),T(!0),GP("next",E)&&t.createElement(et,{onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),d(i[p],"CHECKBOX"===x?.type_info?.meta?.display_format&&"CONSENT"===x?.type_info?.question_type?a.formValues[x.name]??!1:a.formValues[x.name],!0)},disabled:R||!!JP("next",E),className:"next-button ss-action-next-button"},e?.survey?.meta?.action_button?.next||u?.actionButtonText?.next||u?.next||"Next"),GP("next-statement",E)&&t.createElement(et,{onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),l?.(x.name)},disabled:R||!!JP("next-statement",E),className:"next-button ss-action-next-button"},e?.survey?.meta?.action_button?.next||u?.actionButtonText?.next||u?.next||"Next"),GP("submit",E)&&t.createElement("div",{className:"submit ss-action-submit-button"},t.createElement(et,{disabled:R||!!JP("submit",E),onClick:()=>{we(A?.[x.name])&&we(O?.[x.name])&&we(v?.[x.name])&&we(g?.[x.name])&&we(y?.[x.name])&&(C(!0),setTimeout((()=>{C(!1)}),se),M("COMPLETE"))}},e?.survey?.meta?.action_button?.submit||u?.actionButtonText?.submit||u?.submit_survey||"Submit")),GP("message",E)&&t.createElement(et,{onClick:()=>{C(!0),setTimeout((()=>{C(!1)}),se),z()},disabled:R||JP("message",E),className:"next-button ss-action-next-button"},x?.type_info?.scale_properties?.labels?.values?.[0]||"Begin")))))},P4=e=>{const{pages:n,activePage:a,blocks:o,renderedBlocks:i,activeBlock:l,activeIndexOfBlocks:p,activeIndexOfRenderedBlocks:u,isSurveyCompleted:d,isReverseAnimation:b,translationVariables:M,saveFormValues:z,saveOthersValue:m,skipBlock:h,skipStatement:f,initialStatementHasAnswer:O,onSubmitHandler:A,navigateToNextBlock:v,activeIndexOfRenderedStatement:g,navigateToNextStatement:y,navigateToPreviousStatement:q,navigateToPreviousBlock:W,answers:w,questions:L,resetSurvey:R,navigateToStart:C,pivot:x,formQuestionErrors:k,dateQuestionErrors:E,textboxQuestionErrors:T,fileUploadErrors:S,contactFormErrors:N,setErrors:P,expanded:$,setExpanded:_,isQuestionBgDark:B,isSubmitting:H}=d$({...e,isWidget:!0});Ie("Widget",{...e,renderedBlocks:i,activeIndexOfBlocks:p,answers:w,activeIndexOfRenderedBlocks:u,activeBlock:l});const[D,I]=s(null),[V,X]=s(null),[j,F]=s(null),[U,G]=s(0),Y=t.useMemo((()=>ke(x?.question)),[x?.question]),Z=we(w.formValues)&&e.survey.prompt_settings?.is_enabled,[K,Q]=s(Z),J=r(Z?-1:u),ee=()=>{if(null===D||!D||"undefined"==typeof window||"undefined"==typeof document)return;const t=Math.max(document?.documentElement.clientHeight||0,window.innerHeight||0)-(V?.scrollHeight??0)-(j?.scrollHeight??0)-164,n=Math.min(D?.scrollHeight,Math.min(ue[e.widgetStyle],t));U!==n&&G(n)};c((()=>{setTimeout((()=>{ee()}),0)}),[K,d,D,g[l?.question?.name],u,j,$,k,Object.keys(E),Object.keys(T),Object.keys(S),Object.keys(N)]),c((()=>{"MATRIX_RATING_SCALE"===l?.question?.type_info?.question_type&&setTimeout((()=>{ee()}),0)}),[g[l?.question?.name]]),c((()=>{e.loadAsNewSurvey&&e.handleAction&&e.handleAction("RE_SUBMIT",R)}),[]),c((()=>{e.setCurrentSurveyState?.({question:i[u]?.question,npsScore:x?.answer})}),[u,x?.answer]),c((()=>{u!==J.current&&(J.current=-1)}),[u]);const te={answers:w,blocks:o,blockIndex:u,activeIndexOfBlocks:p,initialStatementHasAnswer:O,activeIndexOfRenderedBlocks:u,activeIndexOfRenderedStatement:g,renderedBlocks:i,isMobile:!!e.isMobile,surveyStyle:"card",isWidget:!0,questions:L,pages:n,contactData:e.contactData,activeIndexOfSet:0,branchSeparatePage:!1,pivot:x};if(!l||!l?.question)return null;const ne=d?o.length:p+(d?1:0),ae=d?100:(ne>0?100/o.length:0)*ne;return t.createElement("div",{className:`freemium-survey-components widget-survey-components\n ${e.widgetStyle}-style`.trim(),id:"freemium-survey"},d||K||!e.survey.meta?.progress_bar?null:t.createElement("div",{className:"widget-progressbar"},t.createElement("div",{className:"progress-completion"},ae.toFixed(),"%"),t.createElement(Gq,{totalSteps:o.length,completedSteps:p+(d?1:0),isWidget:!0})),!K&&!e.minimized&&n.length>0&&a?.page_id&&!d&&t.createElement(b$,{ref:e=>e?F(e):null,expanded:$,id:a.page_id,setExpanded:_,activePage:a,translationVariables:M}),t.createElement("div",{className:"questions ss-questions",style:{...Z&&K||J.current===u?{transition:"none"}:{}}},t.createElement(DE,{exitBeforeEnter:!0},t.createElement(PE.div,{id:`${l.question.name}`,className:`question-container ss-question-container ${d?"thankyou":""} ${K?"prompt-container":""}`.trim(),"data-test-question-name":l.question.name,key:`${l.question.name}`,initial:{opacity:0,x:Re(e.language,b)},animate:{opacity:1,x:0},exit:{opacity:0,x:Ce(e.language,b)},transition:{duration:.2}},t.createElement("div",{className:"animation-container",style:{height:e.minimized?0:U>0&&!$?`${U}px`:"auto"}},t.createElement("div",{className:"scroll-container",ref:e=>e?I(e):null},K&&e.survey.prompt_settings?t.createElement(z$,{config:e.survey.prompt_settings,onSelect:t=>{e.onAnsweringPrompt(t),1===t&&Q(!1)},placeholders:e.placeholders}):t.createElement(t.Fragment,null,d?t.createElement(T4,{surveyServAssetUrl:e.surveyServAssetUrl??"",thankYouQuestion:NP({pivotQn:x?.question,pivotQnAnswer:x?.answer,block:HP({activeBlock:l,blocks:e.survey.blocks?.filter((e=>!e.is_deleted)),answers:w,questions:L,activeIndexOfBlocks:p,renderedBlocks:i,contactData:e.contactData,surveyLayout:"card",pages:n}),questions:L}),placeholders:e.placeholders,canResubmit:e.canResubmit,widgetStyle:e.widgetStyle,navigateToStart:()=>{e.handleAction?e.handleAction("EDIT_RESPONSE",C):C()},resetSurvey:()=>{e.handleAction?e.handleAction("RE_SUBMIT",R):R()},allowMultipleSubmission:e.allowMultipleSubmission,pivot:x,rangeToRender:Y,translationVariables:M,isQuestionBgDark:B,answers:w}):t.createElement(t.Fragment,null,t.createElement("div",{className:`question-text ss-question-text ${!l.question.type_info?.pivot_question&&l.required?"required":""} ${"RANGE"===l?.question?.type_info?.question_type?"range-question-text":""}`.trim(),dangerouslySetInnerHTML:{__html:Ee({questionText:l?.question.text,placeholders:e.placeholders,npsRating:Te({theme:"nps",answers:w,questions:L})??"",npsRatingLabel:Se({theme:"nps",answers:w,questions:L}),csatRating:Te({theme:"csat",answers:w,questions:L})??"",csatRatingLabel:Se({theme:"csat",answers:w,questions:L}),cesRating:Te({theme:"ces",answers:w,questions:L})??"",cesRatingLabel:Se({theme:"ces",answers:w,questions:L}),preference:x?.question.type_info?.scale_properties?.labels?.preference})},"aria-label":`question-${u}`,role:"heading","aria-level":1}),"MESSAGE"!==l.question.type_info?.question_type&&t.createElement("div",{className:"question-wrapper",onTransitionEndCapture:e=>e.stopPropagation()},t.createElement(A4,{setFocus:!0,surveyStyle:"card",isReverseAnimation:b,language:e?.language||"en",surveyServAssetUrl:e.surveyServAssetUrl,fileUploadErrors:S,setErrors:P,onFileUpload:e.onFileUpload,surveyLanguage:e.survey.language,block:l,question:l.question,isFinalQn:SP({blocks:o,activeIndexOfBlocks:p,renderedBlocks:i,activeIndexOfRenderedBlocks:u,questions:L}),formValues:w.formValues,widgetStyle:e.widgetStyle,isMobile:!1,othersMeta:w.others,autoFocusDelay:0,activeIndexOfRenderedStatement:g,isWidget:!0,saveOthersValue:(e,t)=>{m(e,t),setTimeout((()=>{ee()}),0)},onChangeHandler:e=>{setTimeout((()=>{ee()}),0),z(l,e)},formQuestionErrors:k,dateQuestionErrors:E,textboxQuestionErrors:T,contactFormErrors:N,translationVariables:M,isQuestionBgDark:B})))))))),!d&&!K&&t.createElement(N4,{pages:n,isWidget:!0,language:e.language||"en",widgetStyle:e.widgetStyle,setFooterElementRef:X,surveyStyle:"standard",answers:w,survey:e.survey,canDisplayDisableButtonParams:{...te,blockIndex:u,activeIndexOfRenderedBlocks:u},isMobile:!1,renderedBlocks:i,initialStatementHasAnswer:O,activeIndexOfRenderedStatement:g,blocks:o,activeIndexOfRenderedBlocks:u,navigateToNextStatement:y,navigateToPreviousStatement:q,activeIndexOfBlocks:p,translationVariables:M,saveFormValues:z,skipBlock:h,skipStatement:f,onSubmitHandler:A,navigateToPreviousBlock:W,navigateToNextBlock:v,formQuestionErrors:k,dateQuestionErrors:E,textboxQuestionErrors:T,fileUploadErrors:S,contactFormErrors:N,questions:L,isSubmitting:H})))},$4={default:{width:522,11:6,10:6,9:8,8:8,7:18,6:22,5:28,4:32,3:36},compact:{width:522,11:6,10:6,9:8,8:8,7:18,6:22,5:28,4:32,3:36},cozy:{width:582,11:12,10:12,9:12,8:12,7:18,6:22,5:28,4:32,3:36}},_4=({language:e="en",survey:n,preview:a,placeholders:o,contactData:i,overRideComponent:c,onSubmit:l,onDismiss:p,onClose:u,isMobile:d,surveyType:b,unsubscribeUrl:M,isSurveyCompleted:z,children:m=null,answerStatus:h,loadSurveyCollapsed:f=!1,handleAction:O,answers:A,onAnsweringPrompt:v,allowMultipleSubmission:g,loadAsNewSurvey:y,canResubmit:q,translationVariables:W,surveyServAssetUrl:w,footerProps:L,surveyPoweredBy:R,onFileUpload:C,isQuestionBgDark:x,hideMinimize:k,position:E,collector:T,backdropColor:S})=>{const N=n.question_details?.questions||[],[P,$]=s(),[_,B]=s(!1),[H,D]=s(f),[I,V]=s(!1),{theme:X}=n,[j,F]=s(null),U=t.useMemo((()=>((e=[])=>{const t=e.sort(((e,t)=>Number(e.order)-Number(t.order)));return t.find((e=>!e.is_deleted))??t[0]})(n.blocks||[])),[n.blocks]),G=U?.question_name?U?.question_name??"":U?.category?.[0].question_name??"",Y=N.find((e=>e.name===G)),Z=()=>{B(!0),setTimeout((()=>{u?.()}),300)},K=r(null);function Q(e){const t=document?.getElementById("freshworks-survey-widget"),n=e?.channel_info?.web_in_app_channel_info;let a="";if(S?a=S:n?.backdrop_enabled&&n?.backdrop_color&&(a=n?.backdrop_color),t&&a)try{const e=(o=a,Object.entries({...de,backgroundColor:o}).map((([e,t])=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${t}`)).join("; "));t.style.cssText=e}catch(e){console.error("Error applying styles to widgetElement:",e)}var o}return t.useEffect((()=>{const e=document?.documentElement;if(!e||!n.question_details?.questions)return;let t=0;(n.question_details.questions??[]).forEach((e=>{const n=ke(e);"RANGE"===e.type_info?.question_type&&n.length>t&&(t=n.length)}));const a=42*t+$4[b][t]*(t-1);e.style.setProperty("--fsc-max-range-question-width",Math.min($4[b].width,a)+"px")}),[n,b]),t.useEffect((()=>{X&&(Ne(X,w??""),V(Ve(X.palette?.footer_background??X.palette?.survey_background??m$)))}),[X,w]),t.useEffect((()=>{Q(T)}),[T]),t.createElement("div",{id:"freshworks-survey-widget",className:`align-${E||""}`},n.theme?.advanced?.additional_css&&t.createElement("style",null,n.theme?.advanced?.additional_css?.replaceAll("\n","")?.replaceAll("!important","").replaceAll(/;/g," !important;")),t.createElement("div",{className:`surveyserv-widget-container ${Le(e||"en")?"freemium-survey-rtl":"freemium-survey-ltr"} ${d?"widget-mobile":""} ${b}-container-style ${H?"minimized":""}`,id:"surveyserv-widget-container"},t.createElement("header",{id:"surveyserv-widget-header",className:("widget-header "+(H?"minimized":"")).trim()},H?t.createElement("span",{className:"header-content minimized",dangerouslySetInnerHTML:{__html:Ee({questionText:(!P&&n.prompt_settings?.is_enabled?n.prompt_settings.text:j?.question?.text)??He(Y?.text||""),placeholders:{...o,"{{nps.rating}}":String(j?.npsScore??"")}})}}):t.createElement("div",null),t.createElement("div",{className:"icons"},!z&&!k&&t.createElement(et,{onClick:()=>{D((e=>!e))},variant:"secondary",className:"svs-icon minimize-btn",title:H?W?.maximize||"Maximize widget":W?.minimize||"Minimize widget"},H?t.createElement(k4,null):t.createElement(E4,null)),t.createElement(et,{ref:K,onClick:()=>{z?Z():p()},variant:"secondary",title:W?.dismiss||"Dismiss widget",className:"svs-icon minimize-btn"},t.createElement(LP,null)))),m,t.createElement("main",{className:("widget-main "+(H?"minimized":"")).trim()},c?t.createElement(t.Fragment,null,c):t.createElement(P4,{surveyServAssetUrl:w,answers:A,minimized:H,widgetStyle:b,answerStatus:h,language:e||"en",survey:n,placeholders:o,isMobile:!!d,contactData:i,onFileUpload:C,allowMultipleSubmission:g,loadAsNewSurvey:y,canResubmit:q,onSubmit:l,setCurrentSurveyState:F,widgetHeaderQuerySelector:H?void 0:"#surveyserv-widget-header",onAnsweringPrompt:e=>{v?.(e),$(e),0==e&&we(n.prompt_settings?.declined_message)&&Z()},handleAction:O,translationVariables:W})),(()=>{const e=!!M&&!H,n=!!L?.showFWBranding;return e||n?t.createElement("footer",{className:`widget-footer ${H?"minimized":""} survey-footer-${I?"dark":"light"}`.trim()},t.createElement("div",null,e&&t.createElement("a",{href:M,target:"_blank",rel:"noopener noreferrer",onClick:e=>{a&&e.preventDefault(),e.stopPropagation(),Z()}},W?.unsubscribe||"Unsubscribe")),n&&t.createElement("div",{className:"footer-text"},t.createElement(Ga,{surveyPoweredBy:R,isDark:I}))):null})()))},B4=e=>{const{survey:n,answers:a}=CP(e.survey,e.answers),[o,i]=t.useState(!1);return t.useEffect((()=>{"undefined"!=typeof window&&window&&window.matchMedia&&"undefined"!=typeof sessionStorage&&sessionStorage&&sessionStorage.clear&&(Ie("Survey matchMedia",{innerHeight:window.innerHeight,innerWidth:window.innerWidth}),i(window.matchMedia("(max-width: 550px)").matches),u$(localStorage))}),[]),t.useEffect((()=>{const t=document?.documentElement;!qe(e.surveyServAssetUrl)&&t&&setTimeout((()=>{t.style.setProperty("--fsc-whatsapp-chat-background",`url(${e.surveyServAssetUrl}/survey/whatsapp-chat-bg.svg)`)}),0)}),[e.surveyServAssetUrl]),Ie("Survey",{...e,survey:n,isMobile:o,answers:a}),t.createElement(t.Fragment,null,n.theme?.advanced?.additional_css&&t.createElement("style",null,n.theme?.advanced?.additional_css?.replaceAll("\n","")?.replaceAll("!important","").replaceAll(/;/g," !important;")),"standard"===e.surveyStyle?t.createElement(x4,{...e,answers:a,survey:n,isMobile:o||!!e.isMobile,initialQuestionAnswer:e.initialQuestionAnswer}):t.createElement(q4,{...e,answers:a,survey:n,isMobile:o||!!e.isMobile,surveyStyle:"card",initialQuestionAnswer:e.initialQuestionAnswer}))},H4=e=>{const{survey:n,answers:a}=CP(e.survey,e.answers);return Ie("WebInAppContainer",{...e,survey:n,answers:a}),t.createElement(_4,{...e,survey:n,answers:a})},D4=e=>{const[n,a]=t.useState(!1),[o,i]=t.useState(!1);return t.useEffect((()=>{"undefined"!=typeof window&&window&&window.matchMedia&&(a(window.matchMedia("(max-width: 550px)").matches),"cozy"===e.surveyType&&i(window.matchMedia("(max-width: 1080px)").matches))}),[]),Ie("WebInAppSurvey",{...e,isMobile:n,isDefault:o}),e.isLoading?t.createElement("div",{id:"freshworks-survey-widget"},t.createElement("div",{className:`surveyserv-widget-container ${Le(e.language||"en")?"freemium-survey-rtl":"freemium-survey-ltr"} ${n?"widget-mobile":""} ${e.surveyType}-container-style`,id:"surveyserv-widget-container"},t.createElement("header",{id:"surveyserv-widget-header",className:"widget-header".trim()},t.createElement("div",null),t.createElement(et,{onClick:()=>{setTimeout((()=>{e?.onClose?.()}),300)},variant:"secondary",title:e.translationVariables?.dismiss||"Dismiss widget",className:"svs-icon minimize-btn"},t.createElement(LP,null))),t.createElement("main",{className:"widget-main widget-loader".trim()},e.overRideComponent??t.createElement(Za,null)))):t.createElement(t.Fragment,null,e?.survey?.id?t.createElement(H4,{...e,isMobile:n,surveyType:n?"compact":o?"default":e.surveyType}):null)},I4=e=>{const{question:n,surveyStyle:a,language:o,onAnswer:i,translationVariables:r,surveyServAssetUrl:c,block:s,theme:l}=e,[p,u]=t.useState(!!e.isMobile);return t.useEffect((()=>{"undefined"!=typeof window&&window&&window.matchMedia&&u(window.matchMedia("(max-width: 550px)").matches||!!e.isMobile)}),[]),t.useEffect((()=>{l&&Ne(l,c??"")}),[l,c]),Ie("QuestionPreview",{...e,isMobile:p}),t.createElement(t.Fragment,null,l?.advanced?.additional_css&&t.createElement("style",null,l?.advanced?.additional_css?.replaceAll("\n","")?.replaceAll("!important","").replaceAll(/;/g," !important;")),t.createElement("div",{className:`freemium-survey-components question-preview ${a}-survey-style ${Le(o||"en")?"freemium-survey-rtl":"freemium-survey-ltr"} ${p?"mobile-preview":""}`.trim(),id:"freemium-survey"},t.createElement("div",{className:"question-holder"},t.createElement("div",{className:"questions ss-questions"},t.createElement(PE.div,{id:`${n.name}`,className:"question-container ss-question-container","data-test-question-name":n.name,key:`${n.name}`,initial:{opacity:0,x:Re(o,!1)},animate:{opacity:1,x:0},exit:{opacity:0,x:Ce(o,!1)},transition:{duration:.2}},t.createElement("div",{className:`question-text ss-question-text ${s.required?"required":""} ${"RANGE"===n?.type_info?.question_type?"range-question-text":""}`.trim(),dangerouslySetInnerHTML:{__html:Ee({questionText:n.text,placeholders:{},npsRating:"",npsRatingLabel:"",csatRating:"",csatRatingLabel:"",cesRating:"",cesRatingLabel:"",preference:n.type_info?.scale_properties?.labels?.preference})},"aria-label":"question-0",role:"heading","aria-level":1}),t.createElement(A4,{surveyStyle:a,language:e?.language||"en",surveyServAssetUrl:c,surveyLanguage:e?.language,block:s,question:n,formValues:{},isMobile:p,othersMeta:{},saveOthersValue:(e,t)=>{},onChangeHandler:e=>{i?.({value:e,block:s,question:n})},translationVariables:r??{},activeIndexOfRenderedStatement:{},autoFocusDelay:0,contactFormErrors:{},dateQuestionErrors:{},fileUploadErrors:{},formQuestionErrors:{},textboxQuestionErrors:{},setErrors:()=>{}}))))))},V4=(e,t)=>{c((()=>{if(e){e.style.height="0px";const t=e.scrollHeight;e.style.height=t+"px"}}),[e,t])},X4=["😭","😞","🙁","😕","😐","🙂","😊","😃","😄","😀"],j4={10:[1,2,3,4,5,6,7,8,9,10],9:[1,2,3,4,5,6,7,9,10],8:[1,2,3,4,6,7,9,10],7:[1,2,3,5,6,8,10],6:[1,2,4,6,8,10],5:[1,3,5,8,10],4:[1,4,7,10],3:[1,5,10]};function F4(e,t){const n=j4[t];if(!n||e<1||e>Number(t))return"";const a=n[e-1]-1;return X4[a]||""}const U4=e=>e?.length&&e?.length>20?e?.trim()?.slice(0,20)+"...":e||"",G4=({rating:e,question:n,type:a})=>{const{range:o}=n?.type_info?.scale_properties||{},i=(n?.type_info?.scale_properties?.labels?.values||[]).length;let r=Number(o?.[o.length-1]?.max||i);const c=n?.type_info?.type_variant||"";if(a)switch(c){case"TICK":return t.createElement("span",null,e?"✅":"❌");case"THUMBS":return t.createElement(Ge,{name:e?"whatsapp-thumbs-up":"whatsapp-thumbs-down"});case"EMOJI":{const n=i<=2;return t.createElement(t.Fragment,null,n?function(e){return X4[[1,10][e]-1]}(e):F4(e,r||10))}case"NUMBER":return t.createElement(t.Fragment,null,e);case"TEXT":return null}return t.createElement(t.Fragment,null,"TEXT"!==c&&Array.from({length:e},((e,n)=>t.createElement(Ge,{name:"whatsapp-star",id:`choice-${n}`,key:n}))))},Y4=({title:e="Acme.inc",type:n="facebook"})=>t.createElement("div",{className:`meta-header meta-header--${n}`},t.createElement("div",{className:"meta-header-left"},t.createElement(Ge,{name:"meta-back-arrow",fill:"facebook"!==n?"#262626":void 0}),t.createElement("div",{className:"meta-header-brand"},t.createElement("div",{className:"meta-logo"},e?.trim()?.charAt(0)?.toUpperCase()),t.createElement("span",{className:"meta-title"},e),t.createElement(Ge,{name:"verified-blue-tick",fill:"whatsapp"===n?"#00E25C":void 0}))),"whatsapp"!==n&&t.createElement("div",{className:"meta-header-right"},"instagram"===n&&t.createElement(Ge,{name:"instagram-phone",fill:"instagram"!==n?"#262626":void 0}),t.createElement(Ge,{name:"facebook-video",fill:"facebook"!==n?"#262626":void 0}))),Z4=({children:e,title:n="Acme.inc",type:a="facebook"})=>{const o="facebook"===a?"meta-wrapper facebook-wrapper":"whatsapp"===a?"meta-wrapper whatsapp-wrapper":"meta-wrapper instagram-wrapper";return t.createElement("div",{className:o},t.createElement("div",{className:"meta-mobile"},t.createElement("div",{className:"meta-mobile-actions"},t.createElement("div",{className:"meta-left-side-buttons-container"},t.createElement("div",{className:"meta-side-buttons left"}),t.createElement("div",{className:"meta-side-buttons left-2"})),t.createElement("div",{className:"meta-side-buttons right"})),t.createElement("div",{className:"meta-phone-frame"},t.createElement(Y4,{title:n,type:a}),e)))},K4=({children:e,title:n,closeModal:a,isModalOpen:o,type:i})=>t.createElement(X,{in:o,unmountOnExit:!0,timeout:500,classNames:"fade",key:n},t.createElement("div",{className:"options-popup",style:{}},t.createElement("header",null,t.createElement("button",{onClick:a,className:"close-btn"},"facebook"===i?t.createElement("span",{style:{fontSize:"10px",fontWeight:"400",gap:"10px"}},"Cancel"):t.createElement(LP,null)),"facebook"===i?t.createElement("div",{className:"option-tab-bar"}):t.createElement("h4",null,n)),t.createElement("main",{className:"fsc-range-main"},e),t.createElement("footer",null,"facebook"===i?t.createElement("div",{className:"privacy-text"},"Your response will be sent directly to Acme.inc",t.createElement("br",null),"and not shown in this chat.",t.createElement("br",null),"View Acme.inc"," ",t.createElement("span",{style:{color:"#1877F2"}},"privacy policy")):"Tap an item to select it"))),Q4=({question:e,saveFormValues:n,type:a,answers:o})=>{const[i,l]=s(!1),[p,u]=s(o?.formValues[e.name]),[d,b]=s(null),[M,z]=s(null),{range:m}=e?.type_info?.scale_properties||{},h=Number(m?.[0]?.min),f=Number(m?.[m.length-1]?.max),O="descending"===e?.type_info?.scale_properties?.order,A=[...e?.type_info?.scale_properties?.labels?.values||[]],v=e?.type_info?.scale_properties?.labels?.preference;c((()=>{"instagram"===a&&l(!0)}),[a]);const g=r(Array.from({length:f+(0===h?1:0)},((e,t)=>O?f-t:t+h)));if(g.current.length<=3){const o="THUMBS"===e?.type_info?.type_variant||2===g.current.length;if("facebook"===a)return t.createElement("ul",{className:"choices dropdown-choices"},g.current.map(((i,r)=>o?t.createElement("li",{className:"choice dropdown-choice",key:`thumbs-${i}-${r}`},t.createElement("button",{className:"action",onClick:()=>{n(i)}},t.createElement("span",{className:"ellipsis-wrapper"},"TEXT"!==e?.type_info?.type_variant&&t.createElement(G4,{rating:i,question:e,type:a})," ","all"===e?.type_info?.scale_properties?.labels?.preference&&U4(e?.type_info?.scale_properties?.labels?.values?.[i]||"")))):t.createElement("li",{className:"choice dropdown-choice",key:`choice-${i}-${r}`},t.createElement("button",{onClick:()=>{n(i)}},t.createElement("span",{className:"star-rating-wrapper"},t.createElement(G4,{rating:i,question:e,type:a}),"all"===v?t.createElement("span",{className:"star-rating-label"}," ",U4(A[i-1]||"")):"edges"===v&&(0===r||r===A.length-1)&&t.createElement("span",{className:"star-rating-label"}," ",U4(0===h?A[i]||"":A[i-1]||""))))))));const i="whatsapp"===a?"choices--vertical":"";return t.createElement("ul",{className:`choices ${i} ${(o||"all"!==e?.type_info?.scale_properties?.labels?.preference)&&"one-line"}`},g.current.map(((i,r)=>o?t.createElement("li",{className:"choice range-choice",key:`thumbs-${i}-${r}`},t.createElement("button",{onClick:()=>{n(i),u(!0)}},t.createElement("span",{className:"ellipsis-wrapper"},"whatsapp"===a&&"TEXT"!==e?.type_info?.type_variant&&t.createElement(G4,{rating:i,question:e,type:a}),"instagram"===a&&t.createElement(G4,{rating:i,question:e,type:a})," ","all"===e?.type_info?.scale_properties?.labels?.preference&&U4(e?.type_info?.scale_properties?.labels?.values?.[i]||"")))):t.createElement("li",{className:"choice range-choice",key:`choice-${i}-${r}`},t.createElement("button",{onClick:()=>{n(i),u(!0)}},t.createElement("span",{className:"star-rating-wrapper"},t.createElement(G4,{rating:i,question:e,type:a})," ","all"===v||"edges"===v&&(0===r||r===A.length-1)?U4(0===h?A[i]:A[i-1]):null))))))}const y="facebook"===a&&p||"instagram"===a;return t.createElement(t.Fragment,null,!y&&t.createElement("button",{onClick:()=>l(!0),className:"choices-button choice"},"facebook"!==a&&t.createElement(Ge,{name:"whatsapp-choices"}),"facebook"===a?"Rate experience":"Rate Support"),t.createElement(K4,{title:"facebook"===a?"Rate experience":"Rate Support",isModalOpen:i,closeModal:()=>{l(!1),b(null),z(null)},type:a},"facebook"===a?t.createElement("div",{className:"facebook-rating-modal"},t.createElement("h2",{className:"modal-question-name"},e?.text),t.createElement("div",{className:"rating-labels"},g.current.map(((e,n)=>"all"!==v&&"edges"!==v||0!==n&&n!==A?.length-1?null:t.createElement("span",{key:n},A[n])))),"STAR"===e?.type_info?.type_variant&&t.createElement("div",{className:"star-container"},g.current.map(((e,n)=>{const a=(M||d||0)>=e;return t.createElement("button",{className:"star-button",onClick:()=>b(e),onMouseEnter:()=>z(e),onMouseLeave:()=>z(null)},t.createElement(Ge,{name:"facebook-star",fill:a?"#1877F2":"#E4E6EA",id:`star-${n}`}))}))),"EMOJI"===e?.type_info?.type_variant&&t.createElement("div",{className:"emoji-container"},g.current.map(((n,a)=>{const o=d===n||M===n,i=e?.type_info?.scale_properties?.range?.[e?.type_info?.scale_properties?.range?.length-1]?.max;return t.createElement("button",{onClick:()=>b(n),onMouseEnter:()=>z(n),onMouseLeave:()=>z(null),className:"emoji-button "+(o?"selected":"")},F4(n,i))}))),"NUMBER"===e?.type_info?.type_variant&&t.createElement("div",{style:{gap:0===Number(m?.[0].min)?"8px":"12px"},className:"number-container "+(g.current.length>5?"grid-layout":"single-row")},g.current.map(((e,n)=>{const a=d===e;return t.createElement("button",{key:e,className:"number-button "+(a?"selected":""),onClick:()=>b(e),onMouseEnter:()=>z(e),onMouseLeave:()=>z(null),style:{backgroundColor:a?"#48A0F8":"#E4E6EA",color:a?"#fff":"#000"}},e)}))),t.createElement("button",{className:"submit-button",onClick:()=>{we(d)||(n(d),l(!1),u(!0),b(null))},disabled:we(d)},"Submit")):g.current.map(((o,i)=>t.createElement("div",{className:"option-row",key:o},t.createElement("button",{onClick:()=>{n(o),l(!1),u(!0)}},t.createElement("span",{className:"star-rating-wrapper"},"whatsapp"===a&&t.createElement(G4,{rating:o,question:e,type:a}),"instagram"===a&&t.createElement(G4,{rating:o,question:e,type:a})," ","all"===v||"edges"===v&&(0===i||i===A.length-1)?U4(0===h?A[o]:A[o-1]):null)))))))},J4=({question:e,saveFormValues:n,type:a,answers:o,setCurrentOtherChoice:i,setShowOtherInput:r})=>{const[l,p]=s(!1),[u,d]=s(o?.formValues[e.name]),b="facebook"===a&&u||"instagram"===a;return c((()=>{"instagram"!==a||u||p(!0)}),[a,u]),t.createElement(t.Fragment,null,!b&&t.createElement("button",{onClick:()=>p(!0),className:"choices-button choice"},"facebook"!==a&&t.createElement(Ge,{name:"whatsapp-choices"}),"Select answer"),t.createElement(K4,{title:"Select a choice",isModalOpen:l,closeModal:()=>p(!1),type:a},"facebook"===a&&t.createElement("h2",{className:"modal-question-name"},e?.text),t.createElement("ul",{className:`choices multi-choice ${a}`},e.choices.filter((e=>!e?.meta?.is_deleted)).map(((a,o)=>t.createElement("li",{className:"choice",style:{boxShadow:"none"},key:`${a}-${o}`},t.createElement("button",{onClick:()=>{n(a.id),p(!1),d(!0);const t=a.meta?.is_others;if(t){const t=e.type_info?.comment_placeholder||"";i({id:e.name,placeholder:t,value:a.id||""}),r(!0)}}},t.createElement("div",{className:"ellipsis-wrapper"},U4(a.value)))))))))},e6=e=>{const n=r(null);V4(n.current,String(e.value)??""),c((()=>{e.autoFocus&&n.current?.focus()}),[e.autoFocus]);const a=()=>{n.current&&n.current?.value&&!we(n.current?.value)&&(e.onSubmit(),n.current.value="")};return t.createElement("div",{className:"textarea-container"},t.createElement("textarea",{placeholder:"Type a message",ref:n,rows:1,onChange:e.onChange,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),a())},value:e.value}),t.createElement("button",{onClick:a},t.createElement(Ge,{name:"whatsapp-send"})))},t6=e=>{const n=r(null);return V4(n.current,String(e.value)??""),c((()=>{e.autoFocus&&n.current?.focus()}),[e.autoFocus]),t.createElement("div",{className:"input-container"},t.createElement("div",{className:"input-field"},t.createElement("div",{className:"facebook-textarea-container "},t.createElement("textarea",{placeholder:"Aa",ref:n,rows:1,onChange:e.onChange,onKeyDown:t=>{"Enter"!==t.key||t.shiftKey||(t.preventDefault(),we(e.value)||(e.onSubmit(),n.current&&(n.current.value="")))},value:e.value}),t.createElement(Ge,{name:"facebook-smile"}))),t.createElement("div",{className:"icon-container"},we(e.value)?t.createElement(Ge,{name:"facebook-thumbsup"}):t.createElement("button",{type:"button",onClick:()=>{we(e.value)||(e.onSubmit(),n.current&&(n.current.value=""))}},t.createElement(Ge,{name:"facebook-send"}))))},n6=({text:e,placeholders:n,pivot:a,rangeToRender:o,questions:i,answers:r})=>t.createElement("div",{className:"question-text-container"},t.createElement("div",{className:"question-text ss-question-text",dangerouslySetInnerHTML:{__html:Ee({questionText:e,placeholders:n,npsRating:Te({theme:"nps",answers:r,questions:i})??"",npsRatingLabel:Se({theme:"nps",answers:r,questions:i}),csatRating:Te({theme:"csat",answers:r,questions:i})??"",csatRatingLabel:Se({theme:"csat",answers:r,questions:i}),cesRating:Te({theme:"ces",answers:r,questions:i})??"",cesRatingLabel:Se({theme:"ces",answers:r,questions:i}),preference:a?.question.type_info?.scale_properties?.labels?.preference,isPreview:!0})},role:"heading","aria-level":1})),a6=e=>{switch(e.type){case"whatsapp":return t.createElement(o6,{...e});case"instagram":return t.createElement(i6,{...e});case"facebook":return t.createElement(r6,{...e})}},o6=e=>{const{block:n,saveFormValues:a,type:o,translationVariables:i,language:r,answers:s,setCurrentOtherChoice:l,setShowOtherInput:p}=e,u=n.question?.type_info?.question_type;switch(c((()=>{"MESSAGE"===u&&a(null,!1)}),[u]),u){case"RANGE":return t.createElement(Q4,{answers:s,type:o,question:n.question,saveFormValues:e=>a(e,!0)});case"DROPDOWN":const c=(n?.question?.choices||[]).filter((e=>!e.meta?.is_deleted));return c.length<=3?t.createElement(u6,{...e,saveFormValues:e=>a(e,!0),setCurrentOtherChoice:l,setShowOtherInput:p}):t.createElement(J4,{answers:s,dir:Le(r||"en")?"rtl":"ltr",question:n.question,saveFormValues:e=>a(e,!0),type:o,translationVariables:i,setCurrentOtherChoice:l,setShowOtherInput:p});case"MULTI_SELECT":return t.createElement(J4,{answers:s,dir:Le(r||"en")?"rtl":"ltr",question:n.question,saveFormValues:e=>a(e,!0),type:o,translationVariables:i,setCurrentOtherChoice:l,setShowOtherInput:p});case"CONSENT":return t.createElement(p6,{...e,saveFormValues:e=>a(e,!0)});case"RESOLUTION":case"BOOLEAN":return t.createElement(l6,{...e,saveFormValues:e=>a(e,!0)});case"PARAGRAPH":case"DATE":case"DATE_TIME":case"MESSAGE":case"TEXT":case"NUMBER":return null;default:return console.error(`Question type ${u} not supported for ${o}`),null}},i6=e=>{const{block:n,saveFormValues:a,type:o,translationVariables:i,language:r,answers:s,setCurrentOtherChoice:l,setShowOtherInput:p}=e,u=n.question?.type_info?.question_type;switch(c((()=>{"MESSAGE"===u&&a(null,!1)}),[u]),u){case"RANGE":return t.createElement(Q4,{answers:s,type:o,question:n.question,saveFormValues:e=>a(e,!0)});case"DROPDOWN":case"MULTI_SELECT":return t.createElement(J4,{answers:s,dir:Le(r||"en")?"rtl":"ltr",question:n.question,saveFormValues:e=>a(e,!0),type:o,translationVariables:i,setCurrentOtherChoice:l,setShowOtherInput:p});case"CONSENT":return t.createElement(p6,{...e,saveFormValues:e=>a(e,!0)});case"RESOLUTION":case"BOOLEAN":return t.createElement(l6,{...e,saveFormValues:e=>a(e,!0)});case"PARAGRAPH":case"DATE":case"DATE_TIME":case"MESSAGE":case"TEXT":case"NUMBER":return null;default:return console.error(`Question type ${u} not supported for ${o}`),null}},r6=({block:e,saveFormValues:n,type:a,translationVariables:o,language:i,answers:r,setCurrentOtherChoice:c,setShowOtherInput:s})=>{const l=e.question?.type_info?.question_type;switch(l){case"RANGE":return"RANGE"===l&&Number(e.question?.type_info?.scale_properties?.range?.length)<3?t.createElement(s6,{question:e.question,saveFormValues:e=>n(e,!0),setCurrentOtherChoice:c,setShowOtherInput:s}):t.createElement(Q4,{answers:r,type:a,question:e.question,saveFormValues:e=>n(e,!0)});case"DROPDOWN":case"MULTI_SELECT":return Array.isArray(e.question?.choices)&&e.question.choices.filter((e=>!e?.meta?.is_deleted))?.length<=3?t.createElement(s6,{setCurrentOtherChoice:c,setShowOtherInput:s,question:e.question,saveFormValues:e=>n(e,!0)}):t.createElement(J4,{answers:r,dir:Le(i||"en")?"rtl":"ltr",question:e.question,saveFormValues:e=>n(e,!0),type:a,translationVariables:o,setCurrentOtherChoice:c,setShowOtherInput:s});case"PARAGRAPH":case"DATE":case"DATE_TIME":case"TEXT":return null;case"BOOLEAN":case"RESOLUTION":case"CONSENT":return t.createElement(s6,{question:e.question,saveFormValues:e=>n(e,!0),setCurrentOtherChoice:c,setShowOtherInput:s});case"MESSAGE":return n(!0,!1),null;default:return console.error(`Question type ${l} not supported for ${a}`),null}},c6=({config:e,placeholders:n,onSelect:a,promptAccepted:i,type:r})=>{const c=o((()=>e.reverse_order?e.choices?.reverse():e.choices),[e]);return t.createElement(t.Fragment,null,t.createElement("div",{className:"question-container ss-question-container "+(null==i?"active":"")},t.createElement(n6,{text:e.text,placeholders:n}),t.createElement("ul",{className:"choices one-line"},c?.map(((e,n)=>t.createElement("li",{className:"choice",key:`prompt-${e}-${n}`},t.createElement("button",{className:"action",onClick:()=>{a(Number(e.id))}},t.createElement(Ge,{name:Number(e.id)?"whatsapp-thumbs-up":"whatsapp-thumbs-down"}),e.value)))))),void 0!==i&&t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"whatsapp"===r&&t.createElement("div",{className:"reply-block"},t.createElement("p",{className:"user"},"Acme.inc"),t.createElement("p",{className:"question",dangerouslySetInnerHTML:{__html:Ee({questionText:e.text,placeholders:n})}})),t.createElement("div",{className:"answer-text"},t.createElement(Ge,{name:Number(i)?"whatsapp-thumbs-up":"whatsapp-thumbs-down"}),c.find((e=>e.id==i))?.value))),!1===i&&e.is_declined&&e.declined_message&&t.createElement("div",{className:"question-container ss-question-container"},t.createElement(n6,{text:e.declined_message,placeholders:n})))},s6=({question:e,saveFormValues:n,setCurrentOtherChoice:a,setShowOtherInput:i})=>{const[r,c]=s(!1),l=e?.type_info?.question_type,p=o((()=>{if(e?.choices&&Array.isArray(e.choices.filter((e=>!e?.meta?.is_deleted)))&&!we(e.choices))return e.choices.filter((e=>!e?.meta?.is_deleted)).map((e=>({id:e.id,value:e.value,numericValue:e.id,isOthers:e.meta?.is_others})));if("CONSENT"===l){if("CHECKBOX"===e?.type_info?.meta?.display_format){const t=e?.type_info?.scale_properties?.labels?.values?.[e?.type_info?.scale_properties?.labels?.values?.length-1];return[{id:0,value:t,numericValue:1}]}{const t=e?.type_info?.scale_properties?.labels?.values?.slice(0,2);return[{id:0,value:t[0],numericValue:1},{id:1,value:t[1],numericValue:0}]}}const t=e?.type_info?.scale_properties?.labels?.values;return(e?.type_info?.scale_properties?.range||[]).map(((e,n)=>({id:e.id,value:t?.[n]||e.label,numericValue:n})))}),[e]),u="DROPDOWN"===l||"MULTI_SELECT"===l;return t.createElement(t.Fragment,null,!r&&t.createElement("ul",{className:"choices "+(u?"dropdown-choices":"boolean-choices")},p.map(((o,r)=>t.createElement("li",{className:"choice "+(u?"dropdown-choice":"boolean-choice"),key:`${l}-${o.id}-${r}`},t.createElement("button",{className:"action",onClick:()=>(t=>{t.isOthers?(c(!0),i(!0),a({id:e.name,placeholder:e.type_info?.comment_placeholder,value:t.numericValue})):n("CONSENT"===l?t.value:t.numericValue,!0)})(o)},!u&&t.createElement(G4,{rating:o.numericValue,question:e,type:"facebook"}),t.createElement("span",{className:"ellipsis-wrapper"},U4(o?.value||""))))))))},l6=({type:e,block:n,saveFormValues:a,answers:o})=>{const i=n?.question,[r,c]=s(o?.formValues[i.name]),l="descending"===i?.type_info?.scale_properties?.order;let p=i?.type_info?.scale_properties?.labels?.values||[];l&&(p=p?.slice().reverse());const u="all"===i?.type_info?.scale_properties?.labels?.preference,d=e=>l?(e+1)%2:e;return"instagram"===e&&r?null:t.createElement("ul",{className:"choices reply-buttons"},p?.map(((o,r)=>t.createElement("li",{className:"choice reply-button",key:`prompt-${o}-${r}`},t.createElement("button",{className:"action",onClick:()=>{c(!0),a(Boolean(d(r)),!0)}},t.createElement("span",{className:"ellipsis-wrapper"},"whatsapp"===e&&"TEXT"!==n.question.type_info?.type_variant&&t.createElement(G4,{rating:d(r),question:i,type:e}),"instagram"===e&&t.createElement(G4,{type:e,question:i,rating:d(r)})," ",u&&U4(o)))))))},p6=({block:e,saveFormValues:n})=>{const a=e?.question,o=a?.type_info?.meta?.display_format,i="BUTTON"===o?fe.map((e=>({id:e.id,value:a?.type_info?.scale_properties?.labels?.values?.[e.id]||e.defaultValue}))):[{id:2,value:a?.type_info?.scale_properties?.labels?.values?.[2]||""}];return t.createElement("ul",{className:"choices reply-buttons"},i?.map(((e,a)=>t.createElement("li",{className:"choice reply-button",key:`prompt-${e?.id}-${a}`},t.createElement("button",{className:"action",onClick:()=>n(e.value)},U4(e.value))))))},u6=({block:e,saveFormValues:n,setCurrentOtherChoice:a,setShowOtherInput:o})=>{const i=e.question,r=(e?.question?.choices||[]).filter((e=>!e.meta?.is_deleted));return t.createElement("ul",{className:"choices reply-buttons"},r?.map(((e,r)=>t.createElement("li",{className:"choice reply-button",key:`prompt-${e?.id}-${r}`},t.createElement("button",{className:"action",onClick:()=>{n(e.id);const t=e.meta?.is_others;if(t){const t=i?.type_info?.comment_placeholder||"";a&&a({id:i.name,placeholder:t,value:e.id||""}),o&&o(!0)}}},t.createElement("span",{className:"ellipsis-wrapper"},U4(e.value||"")))))))},d6=({title:e,...n})=>{const{activeBlock:a,activeIndexOfBlocks:o,activeIndexOfRenderedBlocks:i,answers:l,saveFormValues:p,saveOthersValue:u,blocks:d,questions:b,renderedBlocks:M,onSubmitHandler:z,isSurveyCompleted:m,pivot:h}=d$(n),{type:f="facebook"}=n,{question_type:O}=a?.question.type_info??{},A=t.useMemo((()=>ke(h?.question)),[h?.question]),v=r(null),[g,y]=s(void 0);let q=!1;const[W,w]=s(!1),[L,R]=s(null),[C,x]=s(null),k=(e,t,n=!0)=>{if(!0!==n)return;const a=((e,t,n)=>{const a="BOOLEAN"===t||"RESOLUTION"===t?Boolean(n):n;return{...l,formValues:{...l.formValues,[e]:a}}})(e.question.name,e.question?.type_info?.question_type,t);SP({blocks:d,activeIndexOfBlocks:o,renderedBlocks:M,activeIndexOfRenderedBlocks:i,questions:b,answers:a})&&z("COMPLETE")},E=SP({blocks:d,activeIndexOfBlocks:o,renderedBlocks:M,activeIndexOfRenderedBlocks:i,questions:b,answers:l});if(c((()=>{v.current&&v.current.scroll({top:1e4,behavior:"smooth"})}),[a,l,m]),!a?.question)return null;const T=a?.question.type_info?.scale_properties?.range,S=Array.isArray(T)?T[T.length-1]?.max:void 0,N=(!n.survey.prompt_settings||g)&&(a?.question.choices&&("MULTI_SELECT"===a?.question.type_info?.question_type||"DROPDOWN"===a?.question.type_info?.question_type)&&(a?.question.choices.filter((e=>!e?.meta?.is_deleted))?.length>3||a.question?.choices?.some((e=>e?.meta?.is_others&&!e?.meta?.is_deleted)))||"RANGE"===a?.question.type_info?.question_type&&void 0!==S&&Number(S)>3);return t.createElement(Z4,{title:e,type:"facebook"},t.createElement("div",{className:"fb-chat-body"},t.createElement("div",{className:"fb-msg-container"},t.createElement("div",{className:"fb-scroll-wrapper",ref:v},n.survey.prompt_settings&&t.createElement("div",{className:"fb-prompt-container"},t.createElement(c6,{config:n.survey.prompt_settings,onSelect:e=>y(1===e),promptAccepted:g,placeholders:n.placeholders,type:f})),(!n.survey.prompt_settings||g)&&M.map(((e,o)=>{const i=W&&L?M.findIndex((e=>e.question.name===L.id)):-1;if(-1!==i&&o>i)return null;const r=e.question.type_info,c=r?.scale_properties,s=c?.labels,u=s?.preference,d=s?.values||[],b=c?.range,z=Number(b?.[0]?.min||0),O=Number(b?.[b.length-1]?.max||d.length);return t.createElement(t.Fragment,{key:e.name},t.createElement("div",{className:"fb-question-container ss-question-container "+(m||o!==M.length-1?"":"active")},t.createElement(n6,{text:e.question.text,placeholders:n.placeholders,pivot:h,rangeToRender:A}),a?.name===e.name&&!l?.formValues?.[e.question.name]&&!N&&(!W||L?.id!==e.question.name)&&t.createElement(a6,{setShowOtherInput:w,setCurrentOtherChoice:R,language:n.language||"en",block:e,placeholders:n.placeholders,saveFormValues:(t,n)=>{p(e,t,n),setTimeout((()=>{!!e.question.choices?.find((e=>e.id===String(t)&&e.meta?.is_others))||k(e,t,n)}))},type:f,answers:l})),qe(l.formValues[e.question.name])||e.name===a.name&&!l.commitDirtyValue&&!e.question.choices?.find((t=>t.id===l.formValues[e.question.name]&&t.meta?.is_others))?null:t.createElement("div",{className:"fb-answers-container"},t.createElement("div",{className:"fb-answers"},(()=>{const n=e.question.choices?.find((t=>t.id===l.formValues[e.question.name]&&t.meta?.is_others));if("MESSAGE"!==r?.question_type){if(n)return n.value||"Other";if("RANGE"===r?.question_type){const n=Number(l.formValues[e.question.name]),a=0===z&&1===O&&"THUMBS"!==r?.type_variant,o=r?.type_variant;if(a||"THUMBS"===o||"TICK"===o||"EMOJI"===o&&d.length<=2)return t.createElement("div",{className:"fb-answer-text"},t.createElement(G4,{rating:n,question:e.question,type:"facebook"})," ","all"===u&&U4(0===z?d[n]||"":d[n-1]||""));if("TEXT"===o)return t.createElement("div",{className:"fb-answer-text"},t.createElement(G4,{rating:n,question:e.question,type:"facebook"})," ","all"===u&&U4(0===z?d[n]||"":d[n-1]||""));if("NUMBER"===o)return t.createElement("div",{className:"fb-answer-text"},n,("all"===u||"edges"===u&&(n===z||n===O))&&` ${U4(d[n-(0===z&&n===O&&d.length<O+1?1:z)]||"")}`);if("EMOJI"===o||"STAR"===o)return t.createElement("div",{className:"fb-answer-text"},t.createElement("div",{className:"EMOJI"===o?"fb-emoji-rating-wrapper":"fb-star-rating-wrapper"},t.createElement(G4,{rating:n,question:e.question,type:"facebook"}),("all"===u||"edges"===u&&(1===n||n===d.length))&&t.createElement("span",null," ",U4(0===z?d[n]||"":d[n-1]||""))))}if("BOOLEAN"===r?.question_type||"RESOLUTION"===r?.question_type){const n=Number(l.formValues[e.question.name]);if("RESOLUTION"===r?.question_type){const e=a?.question?.dependent_blocks?.find((e=>"TY"===e?.next_block));e&&(q=e?.choice_id?.includes(l?.formValues?.[a?.question?.name]?.toString()||""))}return t.createElement("div",{className:"fb-answer-text"},t.createElement(G4,{rating:n,question:e.question,type:"facebook"})," ","all"===u&&U4(d[n]||""))}if("DROPDOWN"===r?.question_type||"MULTI_SELECT"===r?.question_type){const n=U4(e.question.choices?.find((t=>t.id===l.formValues[e.question.name]))?.value||l.formValues[e.question.name]?.toString()||"");return t.createElement("div",{className:"fb-answer-text"},n)}return t.createElement("div",{className:"fb-answer-text"},l.formValues[e.question.name]?.toString())}})())),(!W||L&&L.id!==e.question.name)&&e.question.choices?.find((t=>t.id===l.formValues[e.question.name]&&t.meta?.is_others))&&t.createElement("div",{className:"fb-question-container ss-question-container"},t.createElement(n6,{text:e.question.type_info?.comment_placeholder||"Enter your comment",placeholders:n.placeholders,pivot:h,rangeToRender:A})),l.others&&l.others[e.question.name]&&t.createElement("div",{className:"fb-answers-container"},t.createElement("div",{className:"fb-answers"},l.others[e.question.name])))})),W&&L&&t.createElement("div",{className:"fb-question-container ss-question-container "},t.createElement(n6,{text:L?.placeholder||"Enter your comment",placeholders:n.placeholders,pivot:h,rangeToRender:A})),(m||q)&&t.createElement("div",{className:"fb-question-container ss-question-container",id:"new"},t.createElement(n6,{text:NP({pivotQn:h?.question,pivotQnAnswer:h?.answer,block:n.survey.blocks?.find((e=>"TY"===e.name)),questions:b})?.text,placeholders:n.placeholders,pivot:h,rangeToRender:A}))))),N&&!W&&!m&&t.createElement("div",{className:"fb-quick-reply-area"},t.createElement("div",{className:"fb-quick-reply-buttons scrollable"},(()=>{const e=a?.question.type_info,n=e?.scale_properties,o=n?.labels,i=o?.values||[],r=n?.range,c=Number(r?.[0]?.min),s=Number.isFinite(c)?c:1;return"RANGE"===e?.question_type?i.map(((n,c)=>{const l="NUMBER"===e?.type_variant?s+c:c+1;return t.createElement("button",{key:c,className:"fb-quick-reply-button",onClick:()=>{p(a,l,!0),k(a,l)}},"STAR"===e?.type_variant?t.createElement("div",{className:"fb-star-rating-wrapper"},t.createElement("span",null,Array.from({length:l},((e,n)=>t.createElement(Ge,{key:`qr-star-${n}`,name:"whatsapp-star",id:`qr-star-${n}`})))),"all"===o?.preference||"edges"===o?.preference&&(0===c||c===i.length-1)?` ${U4(n||"")}`:""):"EMOJI"===e?.type_variant?t.createElement("div",{className:"fb-emoji-rating-wrapper"},t.createElement("span",null,F4(l,Number(r?.[r.length-1]?.max)||10)),"all"===o?.preference||"edges"===o?.preference&&(0===c||c===i.length-1)?` ${U4(n||"")}`:""):"NUMBER"===e?.type_variant?t.createElement("div",{className:"fb-emoji-rating-wrapper"},t.createElement("span",null,l),"all"===o?.preference||"edges"===o?.preference&&(0===c||c===i.length-1)?` ${U4(n||"")}`:""):U4(n||""))})):a?.question.choices?.filter((e=>!e?.meta?.is_deleted))?.map((e=>t.createElement("button",{key:e.id,className:"fb-quick-reply-button",onClick:()=>{const t=e.meta?.is_others;if(t||p(a,e.id||"",!0),t){p(a,e.id||"",!0);const t=a.question.type_info?.comment_placeholder||"";R({id:a.question.name,placeholder:t,value:e.id||""}),w(!0)}else{const t=e.id||"";k(a,t)}}},t.createElement("span",{className:"fb-ellipsis-wrapper"},U4(e?.value||"")))))})())),t.createElement("div",{className:"fb-input-bar"},t.createElement("div",{className:"fb-input-icons"},t.createElement(Ge,{name:"facebook-actions"}),t.createElement(Ge,{name:"facebook-camera"}),t.createElement(Ge,{name:"facebook-photo"}),t.createElement(Ge,{name:"facebook-mic"})),t.createElement(t6,{onChange:e=>{if(W&&L)x(e.target.value);else{["PARAGRAPH","TEXT","NUMBER","DATE_TIME"].includes(O||"")&&!m&&p(a,e.target.value)}},value:m?"":W&&L?l.others?.[L.id]||C||"":["PARAGRAPH","TEXT","NUMBER","DATE_TIME"].includes(O||"")&&l.formValues[a.question.name]?l.formValues[a.question.name]:"",activeBlock:a,autoFocus:W||["PARAGRAPH","TEXT","NUMBER","DATE_TIME"].includes(O||""),onSubmit:()=>{if(W&&L){u(L.id,C),w(!1),x(null);const e=M.findIndex((e=>e.question.name===L.id)),t=-1!==e?d.findIndex((t=>t.name===M[e].name)):-1,n=-1!==t&&SP({blocks:d,activeIndexOfBlocks:t,renderedBlocks:M,activeIndexOfRenderedBlocks:e,questions:b,answers:l});R(null),n&&z("COMPLETE")}else p(a,l?.formValues?.[a.question.name],!0),E&&z("COMPLETE")}})))},{entries:b6,setPrototypeOf:M6,isFrozen:z6,getPrototypeOf:m6,getOwnPropertyDescriptor:h6}=Object;let{freeze:f6,seal:O6,create:A6}=Object,{apply:v6,construct:g6}="undefined"!=typeof Reflect&&Reflect;f6||(f6=function(e){return e}),O6||(O6=function(e){return e}),v6||(v6=function(e,t,n){return e.apply(t,n)}),g6||(g6=function(e,t){return new e(...t)});const y6=_6(Array.prototype.forEach),q6=_6(Array.prototype.lastIndexOf),W6=_6(Array.prototype.pop),w6=_6(Array.prototype.push),L6=_6(Array.prototype.splice),R6=_6(String.prototype.toLowerCase),C6=_6(String.prototype.toString),x6=_6(String.prototype.match),k6=_6(String.prototype.replace),E6=_6(String.prototype.indexOf),T6=_6(String.prototype.trim),S6=_6(Object.prototype.hasOwnProperty),N6=_6(RegExp.prototype.test),P6=($6=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g6($6,t)});var $6;function _6(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,a=new Array(n>1?n-1:0),o=1;o<n;o++)a[o-1]=arguments[o];return v6(e,t,a)}}function B6(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:R6;M6&&M6(e,null);let a=t.length;for(;a--;){let o=t[a];if("string"==typeof o){const e=n(o);e!==o&&(z6(t)||(t[a]=e),o=e)}e[o]=!0}return e}function H6(e){for(let t=0;t<e.length;t++){S6(e,t)||(e[t]=null)}return e}function D6(e){const t=A6(null);for(const[n,a]of b6(e)){S6(e,n)&&(Array.isArray(a)?t[n]=H6(a):a&&"object"==typeof a&&a.constructor===Object?t[n]=D6(a):t[n]=a)}return t}function I6(e,t){for(;null!==e;){const n=h6(e,t);if(n){if(n.get)return _6(n.get);if("function"==typeof n.value)return _6(n.value)}e=m6(e)}return function(){return null}}const V6=f6(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),X6=f6(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),j6=f6(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),F6=f6(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),U6=f6(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),G6=f6(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Y6=f6(["#text"]),Z6=f6(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),K6=f6(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Q6=f6(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),J6=f6(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),e8=O6(/\{\{[\w\W]*|[\w\W]*\}\}/gm),t8=O6(/<%[\w\W]*|[\w\W]*%>/gm),n8=O6(/\$\{[\w\W]*/gm),a8=O6(/^data-[\-\w.\u00B7-\uFFFF]+$/),o8=O6(/^aria-[\-\w]+$/),i8=O6(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),r8=O6(/^(?:\w+script|data):/i),c8=O6(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),s8=O6(/^html$/i),l8=O6(/^[a-z][.\w]*(-[.\w]+)+$/i);var p8=Object.freeze({__proto__:null,ARIA_ATTR:o8,ATTR_WHITESPACE:c8,CUSTOM_ELEMENT:l8,DATA_ATTR:a8,DOCTYPE_NAME:s8,ERB_EXPR:t8,IS_ALLOWED_URI:i8,IS_SCRIPT_OR_DATA:r8,MUSTACHE_EXPR:e8,TMPLIT_EXPR:n8});const u8=1,d8=3,b8=7,M8=8,z8=9,m8=function(){return"undefined"==typeof window?null:window};var h8=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m8();const n=t=>e(t);if(n.version="3.2.6",n.removed=[],!t||!t.document||t.document.nodeType!==z8||!t.Element)return n.isSupported=!1,n;let{document:a}=t;const o=a,i=o.currentScript,{DocumentFragment:r,HTMLTemplateElement:c,Node:s,Element:l,NodeFilter:p,NamedNodeMap:u=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:d,DOMParser:b,trustedTypes:M}=t,z=l.prototype,m=I6(z,"cloneNode"),h=I6(z,"remove"),f=I6(z,"nextSibling"),O=I6(z,"childNodes"),A=I6(z,"parentNode");if("function"==typeof c){const e=a.createElement("template");e.content&&e.content.ownerDocument&&(a=e.content.ownerDocument)}let v,g="";const{implementation:y,createNodeIterator:q,createDocumentFragment:W,getElementsByTagName:w}=a,{importNode:L}=o;let R={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof b6&&"function"==typeof A&&y&&void 0!==y.createHTMLDocument;const{MUSTACHE_EXPR:C,ERB_EXPR:x,TMPLIT_EXPR:k,DATA_ATTR:E,ARIA_ATTR:T,IS_SCRIPT_OR_DATA:S,ATTR_WHITESPACE:N,CUSTOM_ELEMENT:P}=p8;let{IS_ALLOWED_URI:$}=p8,_=null;const B=B6({},[...V6,...X6,...j6,...U6,...Y6]);let H=null;const D=B6({},[...Z6,...K6,...Q6,...J6]);let I=Object.seal(A6(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),V=null,X=null,j=!0,F=!0,U=!1,G=!0,Y=!1,Z=!0,K=!1,Q=!1,J=!1,ee=!1,te=!1,ne=!1,ae=!0,oe=!1,ie=!0,re=!1,ce={},se=null;const le=B6({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let pe=null;const ue=B6({},["audio","video","img","source","image","track"]);let de=null;const be=B6({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Me="http://www.w3.org/1998/Math/MathML",ze="http://www.w3.org/2000/svg",me="http://www.w3.org/1999/xhtml";let he=me,fe=!1,Oe=null;const Ae=B6({},[Me,ze,me],C6);let ve=B6({},["mi","mo","mn","ms","mtext"]),ge=B6({},["annotation-xml"]);const ye=B6({},["title","style","font","a","script"]);let qe=null;const We=["application/xhtml+xml","text/html"];let we=null,Le=null;const Re=a.createElement("form"),Ce=function(e){return e instanceof RegExp||e instanceof Function},xe=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Le||Le!==e){if(e&&"object"==typeof e||(e={}),e=D6(e),qe=-1===We.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,we="application/xhtml+xml"===qe?C6:R6,_=S6(e,"ALLOWED_TAGS")?B6({},e.ALLOWED_TAGS,we):B,H=S6(e,"ALLOWED_ATTR")?B6({},e.ALLOWED_ATTR,we):D,Oe=S6(e,"ALLOWED_NAMESPACES")?B6({},e.ALLOWED_NAMESPACES,C6):Ae,de=S6(e,"ADD_URI_SAFE_ATTR")?B6(D6(be),e.ADD_URI_SAFE_ATTR,we):be,pe=S6(e,"ADD_DATA_URI_TAGS")?B6(D6(ue),e.ADD_DATA_URI_TAGS,we):ue,se=S6(e,"FORBID_CONTENTS")?B6({},e.FORBID_CONTENTS,we):le,V=S6(e,"FORBID_TAGS")?B6({},e.FORBID_TAGS,we):D6({}),X=S6(e,"FORBID_ATTR")?B6({},e.FORBID_ATTR,we):D6({}),ce=!!S6(e,"USE_PROFILES")&&e.USE_PROFILES,j=!1!==e.ALLOW_ARIA_ATTR,F=!1!==e.ALLOW_DATA_ATTR,U=e.ALLOW_UNKNOWN_PROTOCOLS||!1,G=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Y=e.SAFE_FOR_TEMPLATES||!1,Z=!1!==e.SAFE_FOR_XML,K=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,ne=e.RETURN_TRUSTED_TYPE||!1,J=e.FORCE_BODY||!1,ae=!1!==e.SANITIZE_DOM,oe=e.SANITIZE_NAMED_PROPS||!1,ie=!1!==e.KEEP_CONTENT,re=e.IN_PLACE||!1,$=e.ALLOWED_URI_REGEXP||i8,he=e.NAMESPACE||me,ve=e.MATHML_TEXT_INTEGRATION_POINTS||ve,ge=e.HTML_INTEGRATION_POINTS||ge,I=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Ce(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(I.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Ce(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(I.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(I.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Y&&(F=!1),te&&(ee=!0),ce&&(_=B6({},Y6),H=[],!0===ce.html&&(B6(_,V6),B6(H,Z6)),!0===ce.svg&&(B6(_,X6),B6(H,K6),B6(H,J6)),!0===ce.svgFilters&&(B6(_,j6),B6(H,K6),B6(H,J6)),!0===ce.mathMl&&(B6(_,U6),B6(H,Q6),B6(H,J6))),e.ADD_TAGS&&(_===B&&(_=D6(_)),B6(_,e.ADD_TAGS,we)),e.ADD_ATTR&&(H===D&&(H=D6(H)),B6(H,e.ADD_ATTR,we)),e.ADD_URI_SAFE_ATTR&&B6(de,e.ADD_URI_SAFE_ATTR,we),e.FORBID_CONTENTS&&(se===le&&(se=D6(se)),B6(se,e.FORBID_CONTENTS,we)),ie&&(_["#text"]=!0),K&&B6(_,["html","head","body"]),_.table&&(B6(_,["tbody"]),delete V.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw P6('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw P6('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');v=e.TRUSTED_TYPES_POLICY,g=v.createHTML("")}else void 0===v&&(v=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const a="data-tt-policy-suffix";t&&t.hasAttribute(a)&&(n=t.getAttribute(a));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}}(M,i)),null!==v&&"string"==typeof g&&(g=v.createHTML(""));f6&&f6(e),Le=e}},ke=B6({},[...X6,...j6,...F6]),Ee=B6({},[...U6,...G6]),Te=function(e){w6(n.removed,{element:e});try{A(e).removeChild(e)}catch(t){h(e)}},Se=function(e,t){try{w6(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){w6(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ee||te)try{Te(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ne=function(e){let t=null,n=null;if(J)e="<remove></remove>"+e;else{const t=x6(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===qe&&he===me&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=v?v.createHTML(e):e;if(he===me)try{t=(new b).parseFromString(o,qe)}catch(e){}if(!t||!t.documentElement){t=y.createDocument(he,"template",null);try{t.documentElement.innerHTML=fe?g:o}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(a.createTextNode(n),i.childNodes[0]||null),he===me?w.call(t,K?"html":"body")[0]:K?t.documentElement:i},Pe=function(e){return q.call(e.ownerDocument||e,e,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},$e=function(e){return e instanceof d&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof u)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},_e=function(e){return"function"==typeof s&&e instanceof s};function Be(e,t,a){y6(e,(e=>{e.call(n,t,a,Le)}))}const He=function(e){let t=null;if(Be(R.beforeSanitizeElements,e,null),$e(e))return Te(e),!0;const a=we(e.nodeName);if(Be(R.uponSanitizeElement,e,{tagName:a,allowedTags:_}),Z&&e.hasChildNodes()&&!_e(e.firstElementChild)&&N6(/<[/\w!]/g,e.innerHTML)&&N6(/<[/\w!]/g,e.textContent))return Te(e),!0;if(e.nodeType===b8)return Te(e),!0;if(Z&&e.nodeType===M8&&N6(/<[/\w]/g,e.data))return Te(e),!0;if(!_[a]||V[a]){if(!V[a]&&Ie(a)){if(I.tagNameCheck instanceof RegExp&&N6(I.tagNameCheck,a))return!1;if(I.tagNameCheck instanceof Function&&I.tagNameCheck(a))return!1}if(ie&&!se[a]){const t=A(e)||e.parentNode,n=O(e)||e.childNodes;if(n&&t){for(let a=n.length-1;a>=0;--a){const o=m(n[a],!0);o.__removalCount=(e.__removalCount||0)+1,t.insertBefore(o,f(e))}}}return Te(e),!0}return e instanceof l&&!function(e){let t=A(e);t&&t.tagName||(t={namespaceURI:he,tagName:"template"});const n=R6(e.tagName),a=R6(t.tagName);return!!Oe[e.namespaceURI]&&(e.namespaceURI===ze?t.namespaceURI===me?"svg"===n:t.namespaceURI===Me?"svg"===n&&("annotation-xml"===a||ve[a]):Boolean(ke[n]):e.namespaceURI===Me?t.namespaceURI===me?"math"===n:t.namespaceURI===ze?"math"===n&&ge[a]:Boolean(Ee[n]):e.namespaceURI===me?!(t.namespaceURI===ze&&!ge[a])&&!(t.namespaceURI===Me&&!ve[a])&&!Ee[n]&&(ye[n]||!ke[n]):!("application/xhtml+xml"!==qe||!Oe[e.namespaceURI]))}(e)?(Te(e),!0):"noscript"!==a&&"noembed"!==a&&"noframes"!==a||!N6(/<\/no(script|embed|frames)/i,e.innerHTML)?(Y&&e.nodeType===d8&&(t=e.textContent,y6([C,x,k],(e=>{t=k6(t,e," ")})),e.textContent!==t&&(w6(n.removed,{element:e.cloneNode()}),e.textContent=t)),Be(R.afterSanitizeElements,e,null),!1):(Te(e),!0)},De=function(e,t,n){if(ae&&("id"===t||"name"===t)&&(n in a||n in Re))return!1;if(F&&!X[t]&&N6(E,t));else if(j&&N6(T,t));else if(!H[t]||X[t]){if(!(Ie(e)&&(I.tagNameCheck instanceof RegExp&&N6(I.tagNameCheck,e)||I.tagNameCheck instanceof Function&&I.tagNameCheck(e))&&(I.attributeNameCheck instanceof RegExp&&N6(I.attributeNameCheck,t)||I.attributeNameCheck instanceof Function&&I.attributeNameCheck(t))||"is"===t&&I.allowCustomizedBuiltInElements&&(I.tagNameCheck instanceof RegExp&&N6(I.tagNameCheck,n)||I.tagNameCheck instanceof Function&&I.tagNameCheck(n))))return!1}else if(de[t]);else if(N6($,k6(n,N,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==E6(n,"data:")||!pe[e]){if(U&&!N6(S,k6(n,N,"")));else if(n)return!1}else;return!0},Ie=function(e){return"annotation-xml"!==e&&x6(e,P)},Ve=function(e){Be(R.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||$e(e))return;const a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:H,forceKeepAttr:void 0};let o=t.length;for(;o--;){const i=t[o],{name:r,namespaceURI:c,value:s}=i,l=we(r),p=s;let u="value"===r?p:T6(p);if(a.attrName=l,a.attrValue=u,a.keepAttr=!0,a.forceKeepAttr=void 0,Be(R.uponSanitizeAttribute,e,a),u=a.attrValue,!oe||"id"!==l&&"name"!==l||(Se(r,e),u="user-content-"+u),Z&&N6(/((--!?|])>)|<\/(style|title)/i,u)){Se(r,e);continue}if(a.forceKeepAttr)continue;if(!a.keepAttr){Se(r,e);continue}if(!G&&N6(/\/>/i,u)){Se(r,e);continue}Y&&y6([C,x,k],(e=>{u=k6(u,e," ")}));const d=we(e.nodeName);if(De(d,l,u)){if(v&&"object"==typeof M&&"function"==typeof M.getAttributeType)if(c);else switch(M.getAttributeType(d,l)){case"TrustedHTML":u=v.createHTML(u);break;case"TrustedScriptURL":u=v.createScriptURL(u)}if(u!==p)try{c?e.setAttributeNS(c,r,u):e.setAttribute(r,u),$e(e)?Te(e):W6(n.removed)}catch(t){Se(r,e)}}else Se(r,e)}Be(R.afterSanitizeAttributes,e,null)},Xe=function e(t){let n=null;const a=Pe(t);for(Be(R.beforeSanitizeShadowDOM,t,null);n=a.nextNode();)Be(R.uponSanitizeShadowNode,n,null),He(n),Ve(n),n.content instanceof r&&e(n.content);Be(R.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null,i=null,c=null,l=null;if(fe=!e,fe&&(e="\x3c!--\x3e"),"string"!=typeof e&&!_e(e)){if("function"!=typeof e.toString)throw P6("toString is not a function");if("string"!=typeof(e=e.toString()))throw P6("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Q||xe(t),n.removed=[],"string"==typeof e&&(re=!1),re){if(e.nodeName){const t=we(e.nodeName);if(!_[t]||V[t])throw P6("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof s)a=Ne("\x3c!----\x3e"),i=a.ownerDocument.importNode(e,!0),i.nodeType===u8&&"BODY"===i.nodeName||"HTML"===i.nodeName?a=i:a.appendChild(i);else{if(!ee&&!Y&&!K&&-1===e.indexOf("<"))return v&&ne?v.createHTML(e):e;if(a=Ne(e),!a)return ee?null:ne?g:""}a&&J&&Te(a.firstChild);const p=Pe(re?e:a);for(;c=p.nextNode();)He(c),Ve(c),c.content instanceof r&&Xe(c.content);if(re)return e;if(ee){if(te)for(l=W.call(a.ownerDocument);a.firstChild;)l.appendChild(a.firstChild);else l=a;return(H.shadowroot||H.shadowrootmode)&&(l=L.call(o,l,!0)),l}let u=K?a.outerHTML:a.innerHTML;return K&&_["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&N6(s8,a.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+a.ownerDocument.doctype.name+">\n"+u),Y&&y6([C,x,k],(e=>{u=k6(u,e," ")})),v&&ne?v.createHTML(u):u},n.setConfig=function(){xe(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Q=!0},n.clearConfig=function(){Le=null,Q=!1},n.isValidAttribute=function(e,t,n){Le||xe({});const a=we(e),o=we(t);return De(a,o,n)},n.addHook=function(e,t){"function"==typeof t&&w6(R[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=q6(R[e],t);return-1===n?void 0:L6(R[e],n,1)[0]}return W6(R[e])},n.removeHooks=function(e){R[e]=[]},n.removeAllHooks=function(){R={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();const f8=t.memo((e=>{const{meta_image:n,meta_title:a,meta_description:o,meta_host:i,short_url:r,message:c,channel:s}=e;let l="",p="";if(i){let e=i;e.endsWith("/")||(e+="/"),r&&(e+=r),l=e;try{p=new URL(e).hostname}catch(t){console.warn("Invalid URL provided:",e)}}const u=Boolean(n),d=("fsc-link-preview "+("whatsapp"===s?"fsc-link-preview--whatsapp":"")).trim(),b=("fsc-link-preview__meta "+(u?"":"fsc-link-preview__meta--no-logo")).trim(),M=u||p||a||o;return t.createElement("div",{className:d},M&&t.createElement("div",{className:b},u&&t.createElement("div",{className:"fsc-link-preview__meta__logo"},t.createElement("img",{src:n,alt:"page logo",loading:"lazy"})),p&&t.createElement("div",{className:"fsc-link-preview__meta__domain"},p),a&&t.createElement("div",{className:"fsc-link-preview__meta__title"},a),o&&t.createElement("div",{className:"fsc-link-preview__meta__description"},o)),c&&t.createElement("div",{className:"fsc-link-preview__message",dangerouslySetInnerHTML:{__html:h8.sanitize(c)}}),l&&t.createElement("div",{className:"fsc-link-preview__url"},t.createElement("a",{href:l,target:"_blank",rel:"noopener noreferrer","aria-label":`Visit ${p||l}`},l)))}));f8.displayName="LinkPreview";const O8=({block:e,props:n,answers:a,questions:o,pivot:i})=>t.createElement("div",{className:"reply-block"},t.createElement("p",{className:"user"},"Acme.inc"),t.createElement("p",{className:"question",dangerouslySetInnerHTML:{__html:h8.sanitize(Ee({questionText:e.question.text||"",placeholders:n.placeholders,npsRating:Te({theme:"nps",answers:a,questions:o})??"",npsRatingLabel:Se({theme:"nps",answers:a,questions:o}),csatRating:Te({theme:"csat",answers:a,questions:o})??"",csatRatingLabel:Se({theme:"csat",answers:a,questions:o}),cesRating:Te({theme:"ces",answers:a,questions:o})??"",cesRatingLabel:Se({theme:"ces",answers:a,questions:o}),preference:i?.question.type_info?.scale_properties?.labels?.preference,isPreview:!0}))}})),A8=({block:e,activeBlock:n,answers:a,props:o,questions:i,pivot:r,setRedirectToThankYouPage:c})=>{const{type:s="whatsapp"}=o,l=e.question?.type_info?.question_type,p=e.question.type_info?.scale_properties?.labels?.preference,u=e.question.type_info?.scale_properties?.labels?.values||[],d=null!=a.others&&void 0!==a.others[e.question.name];if(e.name===n.name&&!a.commitDirtyValue&&!d||ae.isNil(a.formValues[e.question.name]))return null;if("RESOLUTION"===l||"BOOLEAN"===l){if("RESOLUTION"===l){const e=n?.question?.dependent_blocks?.find((e=>e?.next_block?.includes("TY")));e&&c&&c(e?.choice_id?.includes(a?.formValues?.[n?.question?.name]?.toString()||""))}const p=Number(a.formValues[e.question.name]);return t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},t.createElement(t.Fragment,null,"whatsapp"===s&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},"whatsapp"===s&&"TEXT"!==e.question.type_info?.type_variant&&t.createElement(G4,{rating:p,question:e?.question,type:s}),"instagram"===s&&t.createElement(G4,{rating:p,question:e?.question,type:s})," ","all"===e.question.type_info?.scale_properties?.labels?.preference&&U4(e.question.type_info?.scale_properties?.labels?.values?.[p]||"")))))}if("CONSENT"===l)return t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"whatsapp"===s&&a.formValues[e.question.name]&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},a.formValues[e.question.name]?.toString())));if("RANGE"===l){const{range:n}=e?.question?.type_info?.scale_properties||{},c=Number(n?.[0]?.min),l=Number(n?.[n.length-1]?.max),d=0===c&&1===l&&"THUMBS"!==e.question.type_info?.type_variant,b=Number(a.formValues[e.question.name]),M=U4(0===c?u[b]:u[b-1]),z=e.question.type_info?.type_variant;if(d)return t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"whatsapp"===s&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},"whatsapp"===s&&"TEXT"!==e.question.type_info?.type_variant&&t.createElement(G4,{type:s,rating:Number(a.formValues[e.question.name]),question:e?.question}),"instagram"===s&&t.createElement(G4,{type:s,rating:b,question:e?.question})," ","all"===e.question.type_info?.scale_properties?.labels?.preference&&M)));if("TEXT"===z)return t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"whatsapp"===s&&a.formValues[e.question.name]&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},M)));if("NUMBER"===z){const n=0===c?Number(b)+1:b;return t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"whatsapp"===s&&n&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},t.createElement("div",{className:"star-rating-wrapper"},"instagram"===s&&t.createElement("span",null,Number(a.formValues[e.question.name])),"whatsapp"===s&&t.createElement(G4,{rating:Number(a.formValues[e.question.name]),question:e?.question,type:s})," ","all"===p||"edges"===p&&(1===n||n===u.length)?M:null))))}if("EMOJI"===z&&"instagram"===s)return t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},t.createElement("div",{className:"answer-text"},t.createElement("div",{className:"star-rating-wrapper"},t.createElement("span",null,F4(b,l||10))," ","all"===p||"edges"===p&&(1===a.formValues[e.question.name]||a.formValues[e.question.name]===u.length)?M:null))))}return"DROPDOWN"===l?t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"whatsapp"===s&&a.formValues[e.question.name]&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},e.question.choices?.find((t=>t.id===a.formValues[e.question.name]))?.value?U4(e.question.choices?.find((t=>t.id===a.formValues[e.question.name]))?.value||""):U4(a.formValues[e.question.name]?.toString()||"")))):t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},"THUMBS"===e.question.type_info?.type_variant?t.createElement(t.Fragment,null,"whatsapp"===s&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},t.createElement(G4,{rating:Number(a.formValues[e.question.name]),question:e?.question,type:s}),"all"===e.question.type_info?.scale_properties?.labels?.preference&&U4(e.question.type_info?.scale_properties?.labels?.values?.[Number(a.formValues[e.question.name])]||""))):"EMOJI"===e.question.type_info?.type_variant||"STAR"===e.question.type_info?.type_variant||"NUMBER"===e.question.type_info?.type_variant?t.createElement(t.Fragment,null,"whatsapp"===s&&a.formValues[e.question.name]&&t.createElement(O8,{block:e,props:o,answers:a,questions:i,pivot:r}),t.createElement("div",{className:"answer-text"},t.createElement("div",{className:"star-rating-wrapper"},t.createElement(G4,{rating:Number(a.formValues[e.question.name]),question:e?.question,type:s})," ","all"===p||"edges"===p&&(1===a.formValues[e.question.name]||a.formValues[e.question.name]===u.length)?U4(u[Number(a.formValues[e.question.name])-1]):null))):"DROPDOWN"===e.question.type_info?.question_type||"MULTI_SELECT"===e.question.type_info?.question_type?t.createElement(t.Fragment,null,U4(e.question.choices?.find((t=>t.id===a.formValues[e.question.name]))?.value||"")||U4(a.formValues[e.question.name]?.toString()||"")):t.createElement(t.Fragment,null,a.formValues[e.question.name]?.toString())))},v8=e=>{const{activeBlock:n,activeIndexOfBlocks:a,activeIndexOfRenderedBlocks:o,answers:i,saveFormValues:l,saveOthersValue:p,blocks:u,questions:d,renderedBlocks:b,onSubmitHandler:M,isSurveyCompleted:z,pivot:m}=d$(e),{type:h="whatsapp",title:f="Acme.inc"}=e,{question_type:O}=n?.question.type_info??{},A=t.useMemo((()=>ke(m?.question)),[m?.question]),v=r(null),[g,y]=s(void 0),[q,W]=s(!1),[w,L]=s(!1),[R,C]=s(null),[x,k]=s(null),E=SP({blocks:u,activeIndexOfBlocks:a,renderedBlocks:b,activeIndexOfRenderedBlocks:o,questions:d,answers:i});if(c((()=>{v.current&&v.current.scroll({top:v.current.scrollHeight,behavior:"smooth"})}),[n,i,z]),!n||!n.question)return null;const T=["PARAGRAPH","DATE","DATE_TIME","NUMBER","TEXT"].includes(O||""),S="instagram"===h,N=t.createElement(t.Fragment,null,t.createElement("div",{className:"msg-container"},t.createElement("div",{className:"scroll-wrapper",ref:v},e.survey.prompt_settings?t.createElement(c6,{config:e.survey.prompt_settings,onSelect:e=>{y(1===e)},promptAccepted:g,placeholders:e.placeholders,type:h}):null,!e.survey.prompt_settings||g?b.map(((r,c)=>{const s=w&&R?b.findIndex((e=>e.question.name===R.id)):-1;return-1!==s&&c>s?null:t.createElement(t.Fragment,null,t.createElement("div",{className:"question-container ss-question-container "+(z||c!==b.length-1?"":"PARAGRAPH"===O||"TEXT"===O||"NUMBER"===O?"input-active":"active")},t.createElement(n6,{text:r.question.text,placeholders:e.placeholders,pivot:m,rangeToRender:A}),(!w||R?.id!==r.question.name)&&t.createElement(a6,{language:e.language||"en",block:r,placeholders:e.placeholders,setCurrentOtherChoice:C,setShowOtherInput:L,saveFormValues:(e,t)=>{l(r,e,t),setTimeout((()=>{const n=r.question?.type_info?.question_type,c="BOOLEAN"===n||"RESOLUTION"===n?Boolean(e):e,s={...i,formValues:{...i.formValues,[r.question.name]:c}};!!!r.question.choices?.find((t=>t.id===String(e)&&t.meta?.is_others))&&!0===t&&SP({blocks:u,activeIndexOfBlocks:a,renderedBlocks:b,activeIndexOfRenderedBlocks:o,questions:d,answers:s})&&M("COMPLETE")}))},type:h,answers:i})),t.createElement(A8,{block:r,activeBlock:n,questions:d,answers:i,props:e,pivot:m,setRedirectToThankYouPage:W}),(!w||R&&R.id!==r.question.name)&&r.question.choices?.find((e=>e.id===i.formValues[r.question.name]&&e.meta?.is_others))&&t.createElement("div",{className:"question-container ss-question-container"},t.createElement(n6,{text:r.question.type_info?.comment_placeholder||"Please specify",placeholders:e.placeholders,pivot:m,rangeToRender:A})),i.others&&i.others[r.question.name]&&t.createElement("div",{className:"answers-container"},t.createElement("div",{className:"answers"},i.others[r.question.name])))})):null,w&&R&&t.createElement("div",{className:"question-container ss-question-container active"},t.createElement(n6,{text:R?.placeholder||"",placeholders:e.placeholders,pivot:m,rangeToRender:A})),(z||q)&&t.createElement("div",{className:"question-container ss-question-container",id:"new"},t.createElement(n6,{text:NP({pivotQn:m?.question,pivotQnAnswer:m?.answer,block:e.survey.blocks?.find((e=>e.name?.includes("TY"))),questions:d})?.text,placeholders:e.placeholders,pivot:m,rangeToRender:A})))),t.createElement(e6,{onChange:e=>{w&&R?k(e.target.value):T&&!z&&l(n,e.target.value)},value:z?"":w&&R?i.others?.[R.id]||x||"":i.formValues[n.question.name]?i.formValues[n.question.name]:"",activeBlock:!0,autoFocus:T,onSubmit:()=>{if(w&&R){p(R.id,x),L(!1),k(null);const e=b.findIndex((e=>e.question.name===R.id)),t=-1!==e?u.findIndex((t=>t.name===b[e].name)):-1,n=-1!==t&&SP({blocks:u,activeIndexOfBlocks:t,renderedBlocks:b,activeIndexOfRenderedBlocks:e,questions:d,answers:i});C(null),n&&M("COMPLETE")}else l(n,i?.formValues?.[n.question.name],!0),E&&M("COMPLETE")}}));return S?t.createElement(Z4,{type:"instagram",title:f},t.createElement("div",{className:`${h} whatsapp-container`},N)):t.createElement(Z4,{type:"whatsapp",title:f},t.createElement("div",{className:`${h} whatsapp-container`},N))},g8=e=>"facebook"===e.channel?t.createElement("div",{className:`${e.channel} facebook-container fb-link-preview`},t.createElement(Z4,{type:"facebook"},t.createElement("div",{className:"msg-container"},t.createElement("div",{className:"scroll-wrapper"},t.createElement("div",{className:"question-container ss-question-container active"},t.createElement(f8,{...e})))),t.createElement("div",{className:"fb-input-bar"},t.createElement("div",{className:"fb-input-icons"},t.createElement(Ge,{name:"facebook-actions"}),t.createElement(Ge,{name:"facebook-camera"}),t.createElement(Ge,{name:"facebook-photo"}),t.createElement(Ge,{name:"facebook-mic"})),t.createElement(t6,null)))):"instagram"===e.channel?t.createElement(Z4,{type:"instagram"},t.createElement("div",{className:`${e.channel} instagram-container`},t.createElement("div",{className:"msg-container"},t.createElement("div",{className:"scroll-wrapper"},t.createElement("div",{className:"question-container ss-question-container active"},t.createElement(f8,{...e})))),t.createElement(e6,{onSubmit:e=>{Ie("LinkPreviewChannel","submitted")}}))):t.createElement(Z4,{type:"whatsapp"},t.createElement("div",{className:`${e.channel} whatsapp-container`},t.createElement("div",{className:"msg-container"},t.createElement("div",{className:"scroll-wrapper"},t.createElement("div",{className:"question-container ss-question-container active"},t.createElement(f8,{...e})))),t.createElement(e6,{onSubmit:e=>{Ie("LinkPreviewChannel","submitted")}}))),y8=e=>{const{survey:n,previewConfig:a}=e,[o,i]=s(!1),[r,c]=s(!1),[l,p]=s({others_meta:{}}),{block:u,question:d,agentName:b,userName:M}=t.useMemo((()=>{const e=n.blocks.find((e=>!e.is_deleted)),t=n.question_details?.questions?.find((t=>t.name===e?.question_name||e?.category?.map((e=>e.question_name)).includes(t.name)));return{block:e,question:t,agentName:a?.agent?.firstName||a?.agent?.lastName?`${a?.agent?.firstName??""} ${a?.agent?.lastName??""}`.trim():"John Doe",userName:a?.user?.firstName||a?.user?.lastName?`${a?.user?.firstName??""} ${a?.user?.lastName??""}`.trim():"Hartmann"}}),[a?.agent?.firstName,a?.agent?.lastName,a?.user?.firstName,a?.user?.lastName,n.blocks,n.question_details?.questions]);return u?.name&&d?.name?t.createElement("div",{className:"web-chat-channel"},t.createElement("div",{className:"wc-header"},t.createElement("div",{className:"wc-h-action-button"},t.createElement(Ge,{name:"arrow-left"})),t.createElement("div",{className:"wc-h-info"},t.createElement("div",{className:"wc-h-info-main wc-wrap-text"},a?.topicName??"Instant support"),t.createElement("div",{className:"wc-h-info-sub wc-wrap-text"},a?.topicDescription??"Typically responds in 5 mins")),t.createElement("div",{className:"wc-h-action-button"},t.createElement(Ge,{name:"close"}))),t.createElement("div",{className:"wc-body"},t.createElement("div",{className:"wc-body-scroll-container"},t.createElement("div",{className:"wc-agent-details"},t.createElement("div",{className:"wc-icon"},a?.agent?.imageUrl?t.createElement("img",{src:a?.agent?.imageUrl,alt:b,className:"wc-a-avatar"}):b?.slice(0,1)),t.createElement("div",{className:"wc-a-info"},t.createElement("div",{className:"wc-a-i-name wc-break-text"},b),t.createElement("div",{className:"wc-a-i-designation wc-break-text"},a?.agent?.designation??"Sr. Customer support agent"))),t.createElement("div",{className:"wc-agent-chat-wrapper"},t.createElement("div",{className:"wc-icon"},a?.user?.imageUrl?t.createElement("img",{src:a?.user?.imageUrl,alt:M,className:"wc-a-avatar"}):M?.slice(0,1)),t.createElement("div",{className:"w-a-c-container"},t.createElement("div",{className:"wc-a-s-name wc-break-text"},M),t.createElement("div",{className:"wc-a-survey-wrapper"},t.createElement(I4,{block:u,question:d,surveyStyle:"card",onAnswer:e=>{p({...e.question.name?{[e.question.name]:e.value}:{},others_meta:{}}),i(!0)},isMobile:!0,theme:e.survey.theme??{},language:e.language,surveyServAssetUrl:e.surveyServAssetUrl,translationVariables:e.translationVariables})),t.createElement("div",{className:"wc-a-timestamp wc-break-text"},a?.timeString??(new Date).toLocaleTimeString())))),t.createElement("div",{className:"wc-footer"},t.createElement("div",{className:"w-f-link wc-wrap-text"},a?.actionText??"Continue chat"))),t.createElement("div",{className:"web-chat-survey-preview"},o&&t.createElement(D4,{answers:l,answerStatus:"PARTIAL",language:e.language,surveyServAssetUrl:e.surveyServAssetUrl,translationVariables:e.translationVariables,preview:!0,isSurveyCompleted:r,onAnsweringPrompt:e=>{},onDismiss:()=>{i(!1)},onClose:()=>{i(!1)},onSubmit:(e,t,n)=>{"COMPLETE"===n&&(c(!0),setTimeout((()=>{t()}),0))},isMobile:!0,placeholders:{},survey:e.survey,surveyType:"compact"}))):null},q8=e=>{Ie("ChannelPreview",e);const{survey:n,answers:a}=CP(e.survey,e.answers);return t.useEffect((()=>{const t=document?.documentElement;!qe(e.surveyServAssetUrl)&&t&&setTimeout((()=>{t.style.setProperty("--fsc-whatsapp-chat-background",`url(${e.surveyServAssetUrl}/survey/whatsapp-chat-bg.svg)`)}),0)}),[e.surveyServAssetUrl]),t.useEffect((()=>{n.theme&&Ne(n.theme,e.surveyServAssetUrl??"")}),[n.theme,e.surveyServAssetUrl]),"chat"===e.channel?t.createElement(y8,{...e,survey:n,answers:a}):"facebook"===e.channel?t.createElement(d6,{...e,type:"facebook",survey:n,answers:a}):"whatsapp"===e.channel||"instagram"===e.channel?t.createElement(v8,{type:e.channel,...e,survey:n,answers:a}):(console.error(`Channel ${e.channel} not supported`),null)},W8=e=>{Ie("ChannelLinkPreview",e);return t.useEffect((()=>{const t=document?.documentElement;!qe(e.surveyServAssetUrl)&&t&&setTimeout((()=>{t.style.setProperty("--fsc-whatsapp-chat-background",`url(${e.surveyServAssetUrl}/survey/whatsapp-chat-bg.svg)`)}),0)}),[e.surveyServAssetUrl]),["whatsapp","instagram","facebook"].includes(e.channel)?t.createElement(g8,{...e}):(console.error(`Channel ${e.channel} not supported`),null)};var w8=Object.freeze({__proto__:null,allPathsLoader:function(e,t){return yi(void 0,void 0,void 0,(function(){return qi(this,(function(n){switch(n.label){case 0:return[4,Promise.resolve().then((function(){return kr}))];case 1:return[2,(0,n.sent().getIconPaths)(e,t)]}}))}))}}),L8=Object.freeze({__proto__:null,splitPathsBySizeLoader:function(e,t){return yi(void 0,void 0,void 0,(function(){var n,a;return qi(this,(function(o){switch(o.label){case 0:return n=qr(e),t!==wr.STANDARD?[3,2]:[4,Promise.resolve().then((function(){return Lr}))];case 1:return a=o.sent(),[3,4];case 2:return[4,Promise.resolve().then((function(){return Rr}))];case 3:a=o.sent(),o.label=4;case 4:return[2,a[n]]}}))}))}});export{ge as ALL_FONTS,Qe as Binary,et as Button,W8 as ChannelLinkPreview,q8 as ChannelPreview,Tt as Checkbox,ve as DEFAULT_FONT,Fq as DatePicker,Uq as DateTimePicker,Fa as Dropdown,ye as FONT_SIZE_OPTIONS,ja as Input,Za as Loader,Ka as PhoneNumberInput,Gq as ProgressBar,I4 as QuestionPreview,IE as RadioGroup,jE as Range,LN as RankOrder,qP as Slider,B4 as Survey,Ya as SurveyFooter,WP as SurveyProgress,wP as TextArea,D4 as WebInAppSurvey};