
/*@preserve
***Version 2.40.0***
*/

/*@license
 *                       Copyright 2002 - 2018 Qualtrics, LLC.
 *                                All rights reserved.
 *
 * Notice: All code, text, concepts, and other information herein (collectively, the
 * "Materials") are the sole property of Qualtrics, LLC, except to the extent
 * otherwise indicated. The Materials are proprietary to Qualtrics and are protected
 * under all applicable laws, including copyright, patent (as applicable), trade
 * secret, and contract law. Disclosure or reproduction of any Materials is strictly
 * prohibited without the express prior written consent of an authorized signatory
 * of Qualtrics. For disclosure requests, please contact notice@qualtrics.com.
 */

try {
  (window["WAFQualtricsWebpackJsonP-cloud-2.40.0"]=window["WAFQualtricsWebpackJsonP-cloud-2.40.0"]||[]).push([[18],{72:function(e,t,n){"use strict";n.r(t);var o=n(4),r=n(5),a=n(32),i=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(o=a.next()).done;)i.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return i},u=function(e){var t=e.translations,n=e.translationSettings,u=e.question,s=e.recordResponseAndProceed,c=e.isFollowUp,l=e.preloadRendererForQID,d=i(Object(r.useState)(null),2),f=d[0],b=d[1],v=i(Object(r.useState)(null),2),p=v[0],g=v[1],O=i(Object(r.useState)(null),2),y=O[0],m=O[1],S=y;return null!==y&&f===u.QID&&p!==u.Style&&(m(null),S=null),Object(r.useEffect)((function(){var e=u.Format,t=u.Style;Object(a.a)(e,t).then((function(e){m((function(){return e})),b(u.QID),g(u.Style)}))}),[u]),null!==S&&f===u.QID?Object(o.h)(S,{translations:t,translationSettings:n,question:u,recordResponseAndProceed:s,isFollowUp:c,preloadRendererForQID:l}):Object(o.h)("div",null)},s=n(15),c=n(27),l=n(25);var d=n(7),f=n(6),b=Object(r.createContext)(null);var v=n(44),p=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(o=a.next()).done;)i.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return i};function g(e){var t,n,o;switch(e.questionConfiguration.Format){case"embedded-feedback-question-format-open-text":return(t={})[e.questionConfiguration.SurveyQuestionId]=e.recordedResponse,t;case"embedded-feedback-question-format-points":case"embedded-feedback-question-format-yes-no":default:return(n={})[e.questionConfiguration.SurveyQuestionId]=((o={})[e.recordedResponse]={selected:!0},o),n}}var O=function(e){var t,n,i=e.interceptOptions,O=i.id,y=i.surveyId,m=i.targetURLOrigin,S=Object(f.b)(b),j=S.Questions,w=p(Object(r.useState)(0),2),h=w[0],Q=w[1],C=p(Object(r.useState)(!1),2),I=C[0],R=C[1],q=p(Object(r.useState)(!1),2),k=q[0],P=q[1],D=p(Object(r.useState)(!1),2),E=D[0],F=D[1],T=m+"/DX/PostResponse/?SurveyId="+y+"&InterceptId="+O,x=window.QSI.global.featureFlags["DX.EmbeddedFeedback_NewAPIs"],L=(t=j,n=Object(r.useRef)(),Object(r.useEffect)((function(){n.current=t})),n.current);if(i.isPreview&&L)if(L.length!==j.length)Q(0);else if(L[0].Style!==j[0].Style)Q(0);else for(var _=0;_<j.length;_++)if(j[_].QuestionText!==L[_].QuestionText){Q(_);break}var A=Object(d.b)().legacyCreativeVal,U=s.a.getTranslation(S),J=Object(r.useCallback)((function(){var e={},t=s.a.getTranslationCode(S);return null!==t&&(e.Q_Language=t),e}),[S]),M=Object(v.a)(y,O,A.requestId,S.SurveyVersionId,!1,J),N=M.enqueueResponse,W=M.closeSurvey,X=Object(r.useMemo)((function(){return j.map((function(e){return{questionConfiguration:e,recordedResponse:null}}))}),[j]),B=X[h],H=function(e){var t="Q_PostResponse returned error status:  "+e.status+" details: "+e.statusText;Object(l.a)(t)},V=Object(r.useCallback)((function(){var e={};return X.forEach((function(t){t.recordedResponse&&(e[t.questionConfiguration.SurveyQuestionId]=t.recordedResponse)})),JSON.stringify(e)}),[X]),z=Object(r.useCallback)((function(){var e=c.a.getEmbeddedData(O),t=s.a.getTranslationCode(S);return null!==t&&(e.Q_Language=t),"Q_PostResponse="+encodeURIComponent(V())+"&ED="+encodeURIComponent(JSON.stringify(e))}),[]),G=Object(r.useCallback)((function(){if(x)W();else{if(E)return;e="POST",t=T,n=z(),o=H,(r=new XMLHttpRequest).open(e,t,!0),r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.onreadystatechange=function(){try{4===r.readyState&&(200!==r.status?o(r):window.QSI.config.surveyResponseId=r.responseText)}catch(e){Object(l.a)(e)}},r.send(n),F(!0)}var e,t,n,o,r}),[E,T,z]),K=function(){$("",!0)},Y=Object(r.useCallback)((function(){if(!E&&!x)if(navigator&&navigator.sendBeacon){var e=new FormData;e.append("Q_PostResponse",V());var t=c.a.getEmbeddedData(O),n=s.a.getTranslationCode(S);null!==n&&(t.Q_Language=n),e.append("ED",JSON.stringify(t)),navigator.sendBeacon(T,e)}else G()}),[E]);Object(r.useEffect)((function(){if(k&&"embedded-feedback-question-format-display-text"!=B.questionConfiguration.Format){var e=6e5;window.QSI&&window.QSI.config&&window.QSI.config.followupQuestionTimeoutMS&&(e=window.QSI.config.followupQuestionTimeoutMS);var t=window.setTimeout(K,e);return window.addEventListener("beforeunload",Y),function(){window.removeEventListener("beforeunload",Y),window.clearTimeout(t)}}}),[k,E,B]);var Z=function(e){if(!e)return h+1;for(var t=0;t<X.length;t++)if(X[t].questionConfiguration.QID===e)return t;return h+1},$=Object(r.useCallback)((function(e,t,n){if(B.recordedResponse=e,k||i.isPreview||A.clickWithImpression(),!i.isPreview){if(x){var o=c.a.getEmbeddedData(O),r=s.a.getTranslationCode(S);null!==r&&(o.Q_Language=r),N({embeddedData:o,recordedResponse:g(B)})}t&&G()}if("End"!==n){var a=Z(n);a>=X.length?R(!0):(P(!0),Q(a))}else R(!0)}),[X,B,h,E,A]);return I||!B?null:Object(o.h)(u,{translations:U,translationSettings:S.TranslationSettings,question:B.questionConfiguration,recordResponseAndProceed:$,isFollowUp:k,preloadRendererForQID:function(e){if("End"!==e){var t=Z(e);if(!(t>=X.length)){var n=X[t].questionConfiguration,o=n.Format,r=n.Style;Object(a.a)(o,r)}}}})},y=n(43),m=n(13),S=n(42),j=n(8),w=function(e){var t=e.creativeOptions,n=e.interceptOptions,r=t.Insertion,a=r.Selector,i=r.MaxNumberOfInsertions,u=Object(S.a)(t),s=u.Questions[0].Appearance.CustomCSS,c=Object(m.a)(s),l=Object(y.a)(O,n,a,c,i);return Object(o.h)(j.a.Provider,{value:n},Object(o.h)(b.Provider,{value:u},l))},h=n(41);n.d(t,"renderEmbeddedFeedback",(function(){return C}));var Q=function(){return(Q=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function C(e,t,n){var r={interceptOptions:t,creativeOptions:e},a=document.createElement("div");return a.style.display="none",Object(o.k)(Object(o.h)(h.a,{legacyCreative:n},Object(o.h)(w,Q({},r))),document.body.appendChild(a)),{remove:function(){Object(o.k)(null,a),document.body.contains(a)&&document.body.removeChild(a)}}}},8:function(e,t,n){"use strict";n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return i}));var o=n(6),r=n(5),a=Object(r.createContext)(null),i=function(){return Object(o.b)(a)}}}]);
} catch(e) {
  if (typeof QSI !== 'undefined' && QSI.dbg && QSI.dbg.e) {
    QSI.dbg.e(e);
  }
}