@sapia-ai/chatbot-v3 1.6.0 → 1.7.0

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/dist/index.js CHANGED
@@ -9267,7 +9267,7 @@ var z = /* @__PURE__ */ function(e) {
9267
9267
  });
9268
9268
  return;
9269
9269
  }
9270
- if ((c = t.nextResponse) != null && c.data ? t.nextResponse.id === i.liveId ? this.store.setState({ streamingBubbleId: void 0 }) : s() : i.commitCurrent(), Array.isArray(e) && (this.setPendingBubbleStatus(B.ANSWERED), this.pendingBubbleId = void 0), this.settleAnswerAndStatus(t, r)) return;
9270
+ if ((c = t.nextResponse) != null && c.data ? t.nextResponse.id === i.liveId ? this.store.setState({ streamingBubbleId: void 0 }) : i.baseId && i.metaFor(t.nextResponse.id) ? i.commitCurrent() : s() : i.commitCurrent(), Array.isArray(e) && (this.setPendingBubbleStatus(B.ANSWERED), this.pendingBubbleId = void 0), this.settleAnswerAndStatus(t, r)) return;
9271
9271
  let o = t.nextResponse, u = o ? (l = i.metaFor(o.id)) == null ? o.data ? i.metaFor(o.data._id) : void 0 : l : void 0;
9272
9272
  await this.appendAgentAndContinue(t, u);
9273
9273
  } catch (t) {
@@ -9414,7 +9414,7 @@ var z = /* @__PURE__ */ function(e) {
9414
9414
  fi_label_summaryQuestionCount: "{{totalQuestions}} Questions (~ {{estimatedMinutes}} minutes)",
9415
9415
  fi_label_summaryRowInterview_one: "{{count}} Written question",
9416
9416
  fi_label_summaryRowInterview_other: "{{count}} Written questions",
9417
- fi_label_summaryRowInterviewDescription: "Answer in your own words, and take as long as you need. [Sapia.ai](https://sapia.ai/)'s AI read and scores these.",
9417
+ fi_label_summaryRowInterviewDescription: "Tell us how you work, in up to 200 words each. Sapia.ai's AI reads and scores your answers, and the {{company}} hiring team makes the decisions.",
9418
9418
  fi_label_summaryRowVideo_one: "{{count}} Video question",
9419
9419
  fi_label_summaryRowVideo_other: "{{count}} Video questions",
9420
9420
  fi_label_summaryRowVideoDescription: "You can retry **{{maxRetries}}** times per question and submit when you're ready.",
@@ -9425,7 +9425,6 @@ var z = /* @__PURE__ */ function(e) {
9425
9425
  fi_label_summaryRowDei_other: "{{count}} Diversity questions (optional)",
9426
9426
  fi_label_summaryRowDeiDescription: "A few questions at the end, after you've submitted. They aren't scored, they aren't shown to the hiring team, and they don't affect your application.",
9427
9427
  fi_button_copyLink: "Copy link",
9428
- ci_composer_footer: "Your answers are confidential",
9429
9428
  ci_edit_banner: "Editing your answer",
9430
9429
  ci_video_retry_banner: "Retrying your video answer",
9431
9430
  ci_rich_toolbar: "Lists",
@@ -21967,7 +21966,6 @@ var Ty = (e) => wy.turndown(e).trim(), Ey = (e) => Cy(Cv.parse(e, {
21967
21966
  shortResponseHint: ie === void 0 ? void 0 : a.shortResponseHint(ie),
21968
21967
  goodResponseHint: N ? a.goodResponseHint : void 0,
21969
21968
  maxWordsHint: N ? a.maxWordsHint : void 0,
21970
- footer: a.composerFooter,
21971
21969
  richText: N,
21972
21970
  toolbarLabels: {
21973
21971
  toolbar: a.richToolbar,
@@ -22206,11 +22204,14 @@ var Ty = (e) => wy.turndown(e).trim(), Ey = (e) => Cy(Cv.parse(e, {
22206
22204
  totalQuestions: t,
22207
22205
  estimatedMinutes: n
22208
22206
  }),
22209
- summaryCategory: (t, n) => {
22210
- let r = qb[t];
22211
- return r ? {
22212
- label: e(r.label, { count: n }),
22213
- description: e(r.description, { maxRetries: 5 }),
22207
+ summaryCategory: (t, n, r) => {
22208
+ let i = qb[t];
22209
+ return i ? {
22210
+ label: e(i.label, { count: n }),
22211
+ description: e(i.description, {
22212
+ maxRetries: 5,
22213
+ company: r == null ? "" : r
22214
+ }),
22214
22215
  kind: Kb[t]
22215
22216
  } : {
22216
22217
  label: String(n),
@@ -22218,7 +22219,6 @@ var Ty = (e) => wy.turndown(e).trim(), Ey = (e) => Cy(Cv.parse(e, {
22218
22219
  kind: vf.GENERIC
22219
22220
  };
22220
22221
  },
22221
- composerFooter: e("ci_composer_footer"),
22222
22222
  richToolbar: e("ci_rich_toolbar"),
22223
22223
  richBulletList: e("ci_rich_bullet_list"),
22224
22224
  richNumberList: e("ci_rich_number_list"),
@@ -22851,7 +22851,7 @@ var Ty = (e) => wy.turndown(e).trim(), Ey = (e) => Cy(Cv.parse(e, {
22851
22851
  }) : e === ud.ASSESSMENT_SUMMARY ? k ? /* @__PURE__ */ (0, U.jsx)(bf, {
22852
22852
  totalLabel: V.summaryTotal,
22853
22853
  countLabel: V.summaryCount(k.totalQuestions, k.estimatedMinutes),
22854
- categories: k.breakdown.map(({ category: e, count: t }) => V.summaryCategory(e, t)),
22854
+ categories: k.breakdown.map(({ category: e, count: t }) => V.summaryCategory(e, t, Ce)),
22855
22855
  opensNewTab: V.opensNewTab
22856
22856
  }) : null : /* @__PURE__ */ (0, U.jsx)(rg, {
22857
22857
  url: ee,
@@ -39,16 +39,16 @@ export declare const buildStrings: (t: Translator) => {
39
39
  /**
40
40
  * Label + description + icon for a breakdown row. The label is pluralised on `count` and carries
41
41
  * the number itself. The video description interpolates the retry budget the recorder actually
42
- * enforces, so the card and the recorder can never disagree. A category the widget has no copy
43
- * for — one the backend adds before the widget ships for it — falls back to a generic mark and
44
- * the bare count, so the row still says how many.
42
+ * enforces, so the card and the recorder can never disagree. The written description names the
43
+ * hiring company; without one the placeholder empties and the sentence still reads. A category
44
+ * the widget has no copy for — one the backend adds before the widget ships for it — falls back
45
+ * to a generic mark and the bare count, so the row still says how many.
45
46
  */
46
- summaryCategory: (category: AssessmentSummaryCategory, count: number) => {
47
+ summaryCategory: (category: AssessmentSummaryCategory, count: number, company?: string) => {
47
48
  label: string;
48
49
  description: string;
49
50
  kind: SummaryKind;
50
51
  };
51
- composerFooter: string;
52
52
  richToolbar: string;
53
53
  richBulletList: string;
54
54
  richNumberList: string;
@@ -36,7 +36,7 @@ ${JSON.stringify(l,null,2)}`);o++}return n?{overflow:!0}:{match:!0,matchedChars:
36
36
  ${JSON.stringify(m,null,2)}`)}}return u?{partialMatch:!0}:void 0;case`[]`:for(var h=Kd(t.args),g;!(g=h()).done;){var _=g.value;if(e[0]===_)return e.length===1?{match:!0,matchedChars:e}:n?{overflow:!0}:{match:!0,matchedChars:[_]}}return;default:throw Error(`Unsupported instruction tree: ${t}`)}}var nf,rf=l((()=>{Gd(),nf=function(){function e(t){Xd(this,e),this.matchTree=new Hd().parse(t)}return Qd(e,[{key:`match`,value:function(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).allowOverflow;if(!e)throw Error(`String is required`);var n=tf(e.split(``),this.matchTree,!0);if(n&&n.match&&delete n.matchedChars,!(n&&n.overflow&&!t))return n}}])}()}));function af(e){"@babel/helpers - typeof";return af=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},af(e)}function of(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=sf(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
37
37
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sf(e,t){if(e){if(typeof e==`string`)return cf(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?cf(e,t):void 0}}function cf(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function lf(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function uf(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,ff(r.key),r)}}function df(e,t,n){return t&&uf(e.prototype,t),n&&uf(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function ff(e){var t=pf(e,`string`);return af(t)==`symbol`?t:t+``}function pf(e,t){if(af(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(af(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var mf,hf,gf,_f,vf,yf,bf,xf,Sf,Cf=l((()=>{Dd(),Nd(),rf(),ws(),ro(),Aa(),eo(),mf=`9`,hf=Sd(mf,15),gf=/[- ]/,_f=!0,vf=_f&&function(){return/\[([^\[\]])*\]/g},yf=_f&&function(){return/\d(?=[^,}][^,}])/g},bf=RegExp(`[`+Oa+`]*\\$1[`+Oa+`]*(\\$\\d[`+Oa+`]*)*$`),xf=3,Sf=function(){function e(t){t.state;var n=t.metadata;lf(this,e),this.metadata=n,this.resetFormat()}return df(e,[{key:`resetFormat`,value:function(){this.chosenFormat=void 0,this.template=void 0,this.nationalNumberTemplate=void 0,this.populatedNationalNumberTemplate=void 0,this.populatedNationalNumberTemplatePosition=-1}},{key:`reset`,value:function(e,t){this.resetFormat(),e?(this.isNANP=e.callingCode()===`1`,this.matchingFormats=e.formats(),t.nationalSignificantNumber&&this.narrowDownMatchingFormats(t)):(this.isNANP=void 0,this.matchingFormats=[])}},{key:`format`,value:function(e,t){var n=this;if(kd(t.nationalSignificantNumber,this.metadata))for(var r=of(this.matchingFormats),i;!(i=r()).done;){var o=i.value,c=Od(t,o,{metadata:this.metadata,shouldTryNationalPrefixFormattingRule:function(e){return n.shouldTryNationalPrefixFormattingRule(e,{international:t.international,nationalPrefix:t.nationalPrefix})},getSeparatorAfterNationalPrefix:function(e){return n.getSeparatorAfterNationalPrefix(e)}});if(c)return this.resetFormat(),this.chosenFormat=o,this.setNationalNumberTemplate(c.replace(/\d/g,`x`),t),this.populatedNationalNumberTemplate=c,this.populatedNationalNumberTemplatePosition=this.template.lastIndexOf(`x`),c}return this.formatNationalNumberWithNextDigits(e,t)}},{key:`formatNationalNumberWithNextDigits`,value:function(e,t){var n=this.chosenFormat,r=this.chooseFormat(t);if(r)return r===n?this.formatNextNationalNumberDigits(e):this.formatNextNationalNumberDigits(t.getNationalDigits())}},{key:`narrowDownMatchingFormats`,value:function(e){var t=this,n=e.nationalSignificantNumber,r=e.nationalPrefix,i=e.international,o=n,c=o.length-xf;c<0&&(c=0),this.matchingFormats=this.matchingFormats.filter(function(e){return t.formatSuits(e,i,r)&&t.formatMatches(e,o,c)}),this.chosenFormat&&this.matchingFormats.indexOf(this.chosenFormat)===-1&&this.resetFormat()}},{key:`formatSuits`,value:function(e,t,n){return!(n&&!e.usesNationalPrefix()&&!e.nationalPrefixIsOptionalWhenFormattingInNationalFormat()||!t&&!n&&e.nationalPrefixIsMandatoryWhenFormattingInNationalFormat())}},{key:`formatMatches`,value:function(e,t,n){var r=e.leadingDigitsPatterns().length;if(r===0)return!0;n=Math.min(n,r-1);var i=e.leadingDigitsPatterns()[n];if(t.length<xf)try{return new nf(i).match(t,{allowOverflow:!0})!==void 0}catch(e){return console.error(e),!0}return RegExp(`^(${i})`).test(t)}},{key:`getFormatFormat`,value:function(e,t){return t?e.internationalFormat():e.format()}},{key:`chooseFormat`,value:function(e){for(var t=this,n=function(){var n=o.value;return t.chosenFormat===n?0:bf.test(t.getFormatFormat(n,e.international))?t.createTemplateForFormat(n,e)?(t.chosenFormat=n,0):(t.matchingFormats=t.matchingFormats.filter(function(e){return e!==n}),1):1},r,i=of(this.matchingFormats.slice()),o;!(o=i()).done&&(r=n(),r!==0););return this.chosenFormat||this.resetFormat(),this.chosenFormat}},{key:`createTemplateForFormat`,value:function(e,t){if(!(_f&&e.pattern().indexOf(`|`)>=0)){var n=this.getTemplateForFormat(e,t);if(n)return this.setNationalNumberTemplate(n,t),!0}}},{key:`getSeparatorAfterNationalPrefix`,value:function(e){return this.isNANP||e&&e.nationalPrefixFormattingRule()&&gf.test(e.nationalPrefixFormattingRule())?` `:``}},{key:`getInternationalPrefixBeforeCountryCallingCode`,value:function(e,t){var n=e.IDDPrefix,r=e.missingPlus;return n?t&&t.spacing===!1?n:n+` `:r?``:`+`}},{key:`getTemplate`,value:function(e){if(this.template){for(var t=-1,n=0,r=e.international?this.getInternationalPrefixBeforeCountryCallingCode(e,{spacing:!1}):``;n<r.length+e.getDigitsWithoutInternationalPrefix().length;)t=this.template.indexOf(`x`,t+1),n++;return Cd(this.template,t+1)}}},{key:`setNationalNumberTemplate`,value:function(e,t){this.nationalNumberTemplate=e,this.populatedNationalNumberTemplate=e,this.populatedNationalNumberTemplatePosition=-1,t.international?this.template=this.getInternationalPrefixBeforeCountryCallingCode(t).replace(/[\d\+]/g,`x`)+Sd(`x`,t.callingCode.length)+` `+e:this.template=e}},{key:`getTemplateForFormat`,value:function(e,t){var n=t.nationalSignificantNumber,r=t.international,i=t.nationalPrefix,o=t.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix,c=e.pattern();_f&&(c=c.replace(vf(),`\\d`).replace(yf(),`\\d`));var l=hf.match(c)[0];if(!(n.length>l.length)){var u=RegExp(`^`+c+`$`),d=n.replace(/\d/g,mf);u.test(d)&&(l=d);var f=this.getFormatFormat(e,r),p;if(this.shouldTryNationalPrefixFormattingRule(e,{international:r,nationalPrefix:i})){var m=f.replace(no,e.nationalPrefixFormattingRule());if(Ss(e.nationalPrefixFormattingRule())===(i||``)+Ss(`$1`)&&(f=m,p=!0,i))for(var h=i.length;h>0;)f=f.replace(/\d/,`x`),h--}var g=l.replace(new RegExp(c),f).replace(new RegExp(mf,`g`),`x`);return p||(o?g=Sd(`x`,o.length)+` `+g:i&&(g=Sd(`x`,i.length)+this.getSeparatorAfterNationalPrefix(e)+g)),r&&(g=$a(g)),g}}},{key:`formatNextNationalNumberDigits`,value:function(e){var t=Td(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition,e);if(!t){this.resetFormat();return}return this.populatedNationalNumberTemplate=t[0],this.populatedNationalNumberTemplatePosition=t[1],Cd(this.populatedNationalNumberTemplate,this.populatedNationalNumberTemplatePosition+1)}},{key:`shouldTryNationalPrefixFormattingRule`,value:function(e,t){var n=t.international,r=t.nationalPrefix;if(e.nationalPrefixFormattingRule()){var i=e.usesNationalPrefix();if(i&&r||!i&&!n)return!0}}}])}()}));function wf(e){"@babel/helpers - typeof";return wf=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},wf(e)}function Tf(e,t){return Af(e)||kf(e,t)||Df(e,t)||Ef()}function Ef(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
38
38
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Df(e,t){if(e){if(typeof e==`string`)return Of(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Of(e,t):void 0}}function Of(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function kf(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,o,c,l=[],u=!0,d=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(l.push(r.value),l.length!==t);u=!0);}catch(e){d=!0,i=e}finally{try{if(!u&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(d)throw i}}return l}}function Af(e){if(Array.isArray(e))return e}function jf(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Mf(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,Pf(r.key),r)}}function Nf(e,t,n){return t&&Mf(e.prototype,t),n&&Mf(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pf(e){var t=Ff(e,`string`);return wf(t)==`symbol`?t:t+``}function Ff(e,t){if(wf(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(wf(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function If(e){var t=e.search(Vf);if(!(t<0)){e=e.slice(t);var n;return e[0]===`+`&&(n=!0,e=e.slice(1)),e=e.replace(Hf,``),n&&(e=`+`+e),e}}function Lf(e){var t=If(e)||``;return t[0]===`+`?[t.slice(1),!0]:[t]}function Rf(e){var t=Tf(Lf(e),2),n=t[0],r=t[1];return Bf.test(n)||(n=``),[n,r]}var zf,Bf,Vf,Hf,Uf,Wf,Gf=l((()=>{Qa(),Xa(),Fa(),Na(),ws(),Aa(),zf=`[`+Oa+xa+`]+`,Bf=RegExp(`^`+zf+`$`,`i`),Vf=`(?:[`+ka+`][`+Oa+xa+`]*|[`+Oa+xa+`]+)`,Hf=RegExp(`[^`+Oa+xa+`]+.*$`),Uf=/[^\d\[\]]/,Wf=function(){function e(t){var n=t.defaultCountry,r=t.defaultCallingCode,i=t.metadata,o=t.onNationalSignificantNumberChange;jf(this,e),this.defaultCountry=n,this.defaultCallingCode=r,this.metadata=i,this.onNationalSignificantNumberChange=o}return Nf(e,[{key:`input`,value:function(e,t){var n=Tf(Rf(e),2),r=n[0],i=n[1],o=Ss(r),c;return i&&(t.digits||(t.startInternationalNumber(void 0,void 0),o||(c=!0))),o&&this.inputDigits(o,t),{digits:o,justLeadingPlus:c}}},{key:`inputDigits`,value:function(e,t){var n=t.digits,r=n.length<3&&n.length+e.length>=3;if(t.appendDigits(e),r&&this.extractIddPrefix(t),this.isWaitingForCountryCallingCode(t)){if(!this.extractCountryCallingCode(t))return}else t.appendNationalSignificantNumberDigits(e);t.international||this.hasExtractedNationalSignificantNumber||this.extractNationalSignificantNumber(t.getNationalDigits(),function(e){return t.update(e)})}},{key:`isWaitingForCountryCallingCode`,value:function(e){var t=e.international,n=e.callingCode;return t&&!n}},{key:`extractCountryCallingCode`,value:function(e){var t=Za(`+`+e.getDigitsWithoutInternationalPrefix(),e.country,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata),n=t.countryCallingCode,r=t.number;if(n)return e.setCallingCode(n),e.update({nationalSignificantNumber:r}),!0}},{key:`reset`,value:function(e){if(e){this.hasSelectedNumberingPlan=!0;var t=e._nationalPrefixForParsing();this.couldPossiblyExtractAnotherNationalSignificantNumber=t&&Uf.test(t)}else this.hasSelectedNumberingPlan=void 0,this.couldPossiblyExtractAnotherNationalSignificantNumber=void 0}},{key:`extractNationalSignificantNumber`,value:function(e,t){if(this.hasSelectedNumberingPlan){var n=Pa(e,this.metadata),r=n.nationalPrefix,i=n.nationalNumber,o=n.carrierCode;if(i!==e)return this.onExtractedNationalNumber(r,o,i,e,t),!0}}},{key:`extractAnotherNationalSignificantNumber`,value:function(e,t,n){if(!this.hasExtractedNationalSignificantNumber)return this.extractNationalSignificantNumber(e,n);if(this.couldPossiblyExtractAnotherNationalSignificantNumber){var r=Pa(e,this.metadata),i=r.nationalPrefix,o=r.nationalNumber,c=r.carrierCode;if(o!==t)return this.onExtractedNationalNumber(i,c,o,e,n),!0}}},{key:`onExtractedNationalNumber`,value:function(e,t,n,r,i){var o=!1,c,l=r.lastIndexOf(n);if(l<0||l!==r.length-n.length)o=!0;else{var u=r.slice(0,l);u&&u!==e&&(c=u)}i({nationalPrefix:e,carrierCode:t,nationalSignificantNumber:n,nationalSignificantNumberIsModified:o,prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix:c}),this.hasExtractedNationalSignificantNumber=!0,this.onNationalSignificantNumberChange()}},{key:`reExtractNationalSignificantNumber`,value:function(e){if(this.extractAnotherNationalSignificantNumber(e.getNationalDigits(),e.nationalSignificantNumber,function(t){return e.update(t)}))return!0;if(this.extractIddPrefix(e)||this.fixMissingPlus(e))return this.extractCallingCodeAndNationalSignificantNumber(e),!0}},{key:`extractIddPrefix`,value:function(e){var t=e.international,n=e.IDDPrefix,r=e.digits;if(e.nationalSignificantNumber,!(t||n)){var i=ja(r,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata);if(i!==void 0&&i!==r)return e.update({IDDPrefix:r.slice(0,r.length-i.length)}),this.startInternationalNumber(e,{country:void 0,callingCode:void 0}),!0}}},{key:`fixMissingPlus`,value:function(e){if(!e.international){var t=Ya(e.digits,e.country,this.defaultCountry,this.defaultCallingCode,this.metadata.metadata).countryCallingCode;if(t)return e.update({missingPlus:!0}),this.startInternationalNumber(e,{country:e.country,callingCode:t}),!0}}},{key:`startInternationalNumber`,value:function(e,t){var n=t.country,r=t.callingCode;e.startInternationalNumber(n,r),e.nationalSignificantNumber&&(e.resetNationalSignificantNumber(),this.onNationalSignificantNumberChange(),this.hasExtractedNationalSignificantNumber=void 0)}},{key:`extractCallingCodeAndNationalSignificantNumber`,value:function(e){this.extractCountryCallingCode(e)&&this.extractNationalSignificantNumber(e.getNationalDigits(),function(t){return e.update(t)})}}])}()}));function Kf(e){"@babel/helpers - typeof";return Kf=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Kf(e)}function qf(e,t){return Qf(e)||Zf(e,t)||Yf(e,t)||Jf()}function Jf(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
39
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yf(e,t){if(e){if(typeof e==`string`)return Xf(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Xf(e,t):void 0}}function Xf(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Zf(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,o,c,l=[],u=!0,d=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(l.push(r.value),l.length!==t);u=!0);}catch(e){d=!0,i=e}finally{try{if(!u&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(d)throw i}}return l}}function Qf(e){if(Array.isArray(e))return e}function $f(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ep(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,np(r.key),r)}}function tp(e,t,n){return t&&ep(e.prototype,t),n&&ep(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function np(e){var t=rp(e,`string`);return Kf(t)==`symbol`?t:t+``}function rp(e,t){if(Kf(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Kf(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ip(e,t,n){var r=n.getCountryCodesForCallingCode(e);if(r.length>1)return za(t,r,n.metadata)}var ap,op,sp=l((()=>{Ui(),Xo(),Zi(),vd(),Cf(),Gf(),Ua(),Ba(),vi(),ap=!1,op=function(){function e(t,n){$f(this,e),this.metadata=new Li(n);var r=qf(this.getCountryAndCallingCode(t),2),i=r[0],o=r[1];this.defaultCountry=i,this.defaultCallingCode=o,this.reset()}return tp(e,[{key:`getCountryAndCallingCode`,value:function(e){var t,n;return e&&(gi(e)?(t=e.defaultCountry,n=e.defaultCallingCode):t=e),t&&!this.metadata.hasCountry(t)&&(t=void 0),n&&ap&&this.metadata.isNonGeographicCallingCode(n)&&(t=`001`),[t,n]}},{key:`input`,value:function(e){var t=this.parser.input(e,this.state),n=t.digits;if(t.justLeadingPlus)this.formattedOutput=`+`;else if(n){this.determineTheCountryIfNeeded(),this.state.nationalSignificantNumber&&this.formatter.narrowDownMatchingFormats(this.state);var r;if(this.metadata.hasSelectedNumberingPlan()&&(r=this.formatter.format(n,this.state)),r===void 0&&this.parser.reExtractNationalSignificantNumber(this.state)){this.determineTheCountryIfNeeded();var i=this.state.getNationalDigits();i&&(r=this.formatter.format(i,this.state))}this.formattedOutput=r?this.getFullNumber(r):this.getNonFormattedNumber()}return this.formattedOutput}},{key:`reset`,value:function(){var e=this;return this.state=new _d({onCountryChange:function(t){e.country=t},onCallingCodeChange:function(t,n){e.metadata.selectNumberingPlan(n||t),e.formatter.reset(e.metadata.numberingPlan,e.state),e.parser.reset(e.metadata.numberingPlan)}}),this.formatter=new Sf({state:this.state,metadata:this.metadata}),this.parser=new Wf({defaultCountry:this.defaultCountry,defaultCallingCode:this.defaultCallingCode,metadata:this.metadata,state:this.state,onNationalSignificantNumberChange:function(){e.determineTheCountryIfNeeded(),e.formatter.reset(e.metadata.numberingPlan,e.state)}}),this.state.reset({country:this.defaultCountry,callingCode:this.defaultCallingCode}),this.formattedOutput=``,this}},{key:`isInternational`,value:function(){return this.state.international}},{key:`getCallingCode`,value:function(){if(this.isInternational())return this.state.callingCode}},{key:`getCountryCallingCode`,value:function(){return this.getCallingCode()}},{key:`getCountry`,value:function(){if(this.state.digits)return this._getCountry()}},{key:`_getCountry`,value:function(){var e=this.state.country;if(!(ap&&e===`001`))return e}},{key:`determineTheCountryIfNeeded`,value:function(){(!this.state.country||this.isCountryCallingCodeAmbiguous())&&this.determineTheCountry()}},{key:`getFullNumber`,value:function(e){var t=this;if(this.isInternational()){var n=function(e){return t.formatter.getInternationalPrefixBeforeCountryCallingCode(t.state,{spacing:!!e})+e},r=this.state.callingCode;return n(r?e?`${r} ${e}`:r:`${this.state.getDigitsWithoutInternationalPrefix()}`)}return e}},{key:`getNonFormattedNationalNumberWithPrefix`,value:function(){var e=this.state,t=e.nationalSignificantNumber,n=e.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix,r=e.nationalPrefix,i=t,o=n||r;return o&&(i=o+i),i}},{key:`getNonFormattedNumber`,value:function(){var e=this.state.nationalSignificantNumberIsModified;return this.getFullNumber(e?this.state.getNationalDigits():this.getNonFormattedNationalNumberWithPrefix())}},{key:`getNonFormattedTemplate`,value:function(){var e=this.getNonFormattedNumber();if(e)return e.replace(/[\+\d]/g,`x`)}},{key:`isCountryCallingCodeAmbiguous`,value:function(){var e=this.state.callingCode,t=this.metadata.getCountryCodesForCallingCode(e);return t&&t.length>1}},{key:`determineTheCountry`,value:function(){var e=Va(this.isInternational()?this.state.callingCode:this.defaultCallingCode,{nationalNumber:this.state.nationalSignificantNumber,metadata:this.metadata});e!==this.state.country&&(this.state.setCountry(e),e&&this.metadata.selectNumberingPlan(e))}},{key:`getNumberValue`,value:function(){var e=this.state,t=e.digits,n=e.callingCode,r=e.country,i=e.nationalSignificantNumber;if(t){if(this.isInternational())return n?`+`+n+i:`+`+t;if(r||n)return`+`+(r?this.metadata.countryCallingCode():n)+i}}},{key:`getNumber`,value:function(){var e=this.state,t=e.nationalSignificantNumber,n=e.carrierCode,r=e.callingCode;if(t){var i=this._getCountry();if(!(!i&&!r)){if(i&&i===this.defaultCountry){var o=ip(this.metadata.numberingPlan.callingCode(),t,this.metadata);o&&(i=o)}var c=new Jo(i||r,t,this.metadata.metadata);return n&&(c.carrierCode=n),c}}}},{key:`isPossible`,value:function(){var e=this.getNumber();return e?e.isPossible():!1}},{key:`isValid`,value:function(){var e=this.getNumber();return e?e.isValid():!1}},{key:`validateLength`,value:function(){var e=this.state,t=e.digits,n=e.nationalSignificantNumber;if(!t)return`NOT_A_NUMBER`;if(!this.metadata.numberingPlan)return`INVALID_COUNTRY`;if(!n)return`TOO_SHORT`;var r=Yi(n,void 0,this.metadata);if(r!==`IS_POSSIBLE`)return r}},{key:`getNationalNumber`,value:function(){return this.state.nationalSignificantNumber}},{key:`getChars`,value:function(){return(this.state.international?`+`:``)+this.state.digits}},{key:`getTemplate`,value:function(){return this.formatter.getTemplate(this.state)||this.getNonFormattedTemplate()||``}}])}()}));function cp(e){return new Li(e).getCountries()}var lp=l((()=>{Ui()}));function up(e,t,n){if(t[e])return new Jo(e,t[e],n)}var dp=l((()=>{Xo()}));function fp(e,t,n){return n||(n=t,t=void 0),new op(t,n).input(e)}var pp=l((()=>{sp()})),mp=l((()=>{Xo(),ms(),Ec(),Ic(),Wc(),Qc(),ol(),Hu(),Ju(),nd(),ud(),Bu(),sp(),Cf(),lp(),Ui(),dp(),pp(),As(),ws(),ko()}));function hp(){return fi(Tc,arguments)}var gp=l((()=>{pi(),mp()}));function _p(){return fi(Fc,arguments)}var vp=l((()=>{pi(),mp()}));function yp(){return fi(Uc,arguments)}var bp=l((()=>{pi(),mp()}));function xp(){return fi(Zc,arguments)}var Sp=l((()=>{pi(),mp()}));function Cp(){return fi(al,arguments)}var wp=l((()=>{pi(),mp()}));function Tp(){return fi(Vu,arguments)}var Ep=l((()=>{pi(),mp()}));function Dp(){return fi(qu,arguments)}var Op=l((()=>{pi(),mp()}));function kp(){return fi(td,arguments)}var Ap=l((()=>{pi(),mp()}));function jp(){return fi(ld,arguments)}var Mp=l((()=>{pi(),mp()}));function Np(e,t){return zu.call(this,e,t,ui)}var Pp=l((()=>{di(),mp(),Np.prototype=Object.create(zu.prototype,{}),Np.prototype.constructor=Np}));function Fp(e){return op.call(this,e,ui)}var Ip=l((()=>{di(),mp(),Fp.prototype=Object.create(op.prototype,{}),Fp.prototype.constructor=Fp}));function Lp(){return fi(Mi,arguments)}var Rp=l((()=>{pi(),mp()}));function zp(){return fi(cp,arguments)}var Bp=l((()=>{pi(),mp()}));function Vp(){return fi(ji,arguments)}var Hp=l((()=>{pi(),mp()}));function Up(){return fi(Ai,arguments)}var Wp=l((()=>{pi(),mp()}));function Gp(){return Li.call(this,ui)}var Kp=l((()=>{di(),mp(),Gp.prototype=Object.create(Li.prototype,{}),Gp.prototype.constructor=Gp}));function qp(){return fi(up,arguments)}var Jp=l((()=>{pi(),mp()}));function Yp(){return fi(fp,arguments)}var eee=l((()=>{pi(),mp()}));function Xp(e){return Jo.call(this,e,ui)}var tee=l((()=>{di(),mp(),Xp.prototype=Jo.prototype,Xp.prototype.constructor=Xp})),Zp=d({AsYouType:()=>Fp,DIGIT_PLACEHOLDER:()=>`x`,Metadata:()=>Gp,ParseError:()=>ps,PhoneNumber:()=>Xp,PhoneNumberMatcher:()=>Np,default:()=>_p,findNumbers:()=>Tp,findPhoneNumbersInText:()=>kp,formatIncompletePhoneNumber:()=>Yp,formatRFC3966:()=>Oo,getCountries:()=>zp,getCountryCallingCode:()=>Vp,getExampleNumber:()=>qp,getExtPrefix:()=>Up,isPossiblePhoneNumber:()=>xp,isSupportedCountry:()=>Lp,isValidPhoneNumber:()=>yp,parseDigits:()=>Ss,parseIncompletePhoneNumber:()=>Os,parsePhoneNumber:()=>hp,parsePhoneNumberCharacter:()=>ks,parsePhoneNumberFromString:()=>_p,parsePhoneNumberWithError:()=>hp,parseRFC3966:()=>Do,searchNumbers:()=>Dp,searchPhoneNumbersInText:()=>jp,validatePhoneNumberLength:()=>Cp}),Qp=l((()=>{gp(),vp(),bp(),Sp(),wp(),Ep(),Op(),Ap(),Mp(),Pp(),Ip(),Rp(),Bp(),Hp(),Wp(),Kp(),Jp(),eee(),tee(),mp()})),$p={email:`fi_error_piiEmail`,fullName:`fi_error_piiFullName`,firstName:`fi_error_piiFirstName`,lastName:`fi_error_piiLastName`,phoneNumber:`fi_error_piiPhoneNumber`,location:`ci_error_piiLocation`},em={[xr.FULL_NAME]:100,[xr.FIRST_NAME]:50,[xr.LAST_NAME]:50},nee={[xr.FULL_NAME]:3,[xr.FIRST_NAME]:2,[xr.LAST_NAME]:2},ree={[xr.FULL_NAME]:$p.fullName,[xr.FIRST_NAME]:$p.firstName,[xr.LAST_NAME]:$p.lastName},iee={[xr.FULL_NAME]:`fullName`,[xr.FIRST_NAME]:`firstName`,[xr.LAST_NAME]:`lastName`},tm=e=>e.trim().split(/\s+/).filter(Boolean).length,aee=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,nm=e=>{let t=e.trim();return aee.test(t)?{ok:!0,text:t}:{ok:!1,errorKey:$p.email}},rm=(e,t)=>{let n=t.trim(),r=em[e],i=ree[e];if(r===void 0||i===void 0)return{ok:!0,text:n};let o=tm(n);return o>=1&&o<=r?{ok:!0,text:n}:{ok:!1,errorKey:i}},oee=(e,t)=>{let n=nee[e];return n!==void 0&&tm(t)>n},im=async(e,t)=>{var n;let{parsePhoneNumberFromString:r}=await Promise.resolve().then(()=>(Qp(),Zp)),i=r(e.trim(),t);return i!=null&&i.isValid()?{ok:!0,text:i.number}:{ok:!1,errorKey:$p.phoneNumber,possiblePhoneNumber:(n=i==null?void 0:i.isPossible())==null?!1:n}},am=e=>e!==void 0&&e in em,om=function(e){return e.SUBMITTED=`submitted`,e.INVALID=`invalid`,e.CONFIRM_NAME=`confirm-name`,e}({}),sm=e=>({outcome:{status:`invalid`,errorKey:e}}),cm=e=>{let t=nm(e);return t.ok?{submit:t.text}:sm(t.errorKey)},lm=async(e,t,n)=>{let r=await im(e,t);return r.ok?{submit:r.text}:(r.possiblePhoneNumber&&n(),sm(r.errorKey))},um=async(e,t,n)=>{if(!e)return sm($p.fullName);let r=rm(e,t);if(!r.ok)return sm(r.errorKey);let i=oee(e,r.text)?iee[e]:void 0;if(i){let e=await n(r.text,i);if(e&&e!==r.text)return{outcome:{status:`confirm-name`,suggested:e,original:r.text}}}return{submit:r.text}},dm=`csat-form`,fm=`csat-response`,pm=(e,t)=>({id:e,types:[],contents:[],component:t}),mm=e=>`${dm}-${e}`,hm=e=>`${fm}-${e}`,see=(e,t)=>({id:t,questionId:e,sender:_r.AGENT,status:$r.ANSWERED,types:[vr.FTQ],questionRole:Zr.CUSTOMER_SATISFACTION,data:{messageItems:[pm(e,wr.CUSTOMER_SATISFACTION_INTRO)]}}),gm=e=>({id:mm(e),questionId:e,sender:_r.CANDIDATE,status:$r.ANSWERING,types:[vr.FTQ],questionRole:Zr.CUSTOMER_SATISFACTION,data:{messageItems:[pm(e,wr.CUSTOMER_SATISFACTION_FORM)]}}),_m=({questionId:e,response:t,status:n})=>({id:hm(e),questionId:e,sender:_r.CANDIDATE,status:n,types:[vr.FTQ],questionRole:Zr.CUSTOMER_SATISFACTION,data:{messageItems:[],customerSatisfaction:t}}),cee=(e,t)=>{var n;let r=t==null||(n=t[0])==null?void 0:n.questionId;if(!r)return e;let i=e=>e.sender===_r.AGENT&&e.questionId===r;if(!e.some(i))return e;let o=mm(r),c=hm(r),l=e=>e.sender===_r.CANDIDATE&&e.questionId===r&&e.id!==o&&e.id!==c,u=e.filter(e=>!l(e)).map(e=>i(e)?{...e,questionRole:Zr.CUSTOMER_SATISFACTION,data:{...e.data,messageItems:[pm(e.questionId,wr.CUSTOMER_SATISFACTION_INTRO)]}}:e);return u.some(e=>e.id===o||e.id===c)?u:[...u,gm(r)]},lee=e=>({rating:e.rating,...e.comment.trim()?{comment:e.comment}:{}}),uee=(e,t)=>{if(Rr(e)){let{_id:n}=e.data,r=see(n,e.id);return t&&zr(t)?[r]:[r,gm(n)]}if(zr(e)){var n,r;let{_id:t,responses:i}=e.data,o=new Map(i.map(e=>[e.fieldType,e])),c=(n=o.get(Mr.RATING))==null?void 0:n.value,l=(r=o.get(Mr.COMMENT))==null?void 0:r.answer;return[_m({questionId:t,response:{...c?{rating:Number(c)}:{},...l&&l!==`SAPIA_SKIP_FEEDBACK`?{comment:l}:{}},status:$r.ANSWERED})]}},dee=e=>{let t=e.findIndex(Rr);if(t===-1)return;let n=e[t+1];if(!(n&&zr(n)))return e[t].data.fields},fee=(e,t,n,r)=>{let i=t[0].questionId,o=_m({questionId:i,response:lee(n),status:r}),c=mm(i);return{bubbles:e.map(e=>e.id===c?o:e),responseBubbleId:o.id}},pee=`dei-form`,mee=`dei-details`,vm=(e,t)=>({id:e,types:[],contents:[],component:t}),ym=e=>`${pee}-${e}`,bm=e=>`${mee}-${e}`,xm=e=>({id:ym(e),questionId:e,sender:_r.CANDIDATE,status:$r.ANSWERING,types:[vr.FTQ],questionRole:Zr.DEI,data:{messageItems:[vm(e,wr.DEMOGRAPHIC_FORM)]}}),Sm=({questionId:e,entries:t,status:n})=>({id:bm(e),questionId:e,sender:_r.CANDIDATE,status:n,types:[vr.FTQ],questionRole:Zr.DEI,data:{messageItems:[vm(e,wr.DEMOGRAPHIC_DETAILS)],demographicDetails:t}}),hee=(e,t)=>{var n;let r=t==null||(n=t[0])==null?void 0:n.questionId;if(!r)return e;let i=ym(r),o=bm(r),c=e=>e.questionId===r&&e.id!==i&&e.id!==o;if(!e.some(c))return e;let l=e.filter(e=>!c(e));return l.some(e=>e.id===i||e.id===o)?l:[...l,xm(r)]},Cm=(e,t)=>e.map(e=>{var n;return{field:e,options:((n=e.options)==null?[]:n).filter(n=>{var r;return(r=t[e.questionId])==null?void 0:r.includes(n.id)})}}).filter(({options:e})=>e.length>0),gee=(e,t)=>Cm(e,t).map(({field:e,options:t})=>({questionId:e.questionId,prompt:e.prompt,answer:t.map(e=>e.text).join(` | `)})),_ee=(e,t)=>{if(Br(e))return t&&Vr(t)?[]:[xm(e.data._id)];if(Vr(e)){let{_id:t,responses:n}=e.data;return[Sm({questionId:t,entries:n.filter(e=>e.answer).map(e=>({questionId:e.questionId,prompt:e.prompt,answer:e.answer})),status:$r.ANSWERED})]}},vee=e=>{let t=e.findIndex(Br);if(t===-1)return;let n=e[t+1];if(!(n&&Vr(n)))return e[t].data.fields},yee=(e,t,n,r)=>{let i=t[0].questionId,o=Sm({questionId:i,entries:gee(t,n),status:r}),c=ym(i);return{bubbles:e.map(e=>e.id===c?o:e),detailsBubbleId:o.id}},wm=`pii-details`,Tm=`pii-form`,Em=(e,t)=>({id:e,types:[],contents:[],component:t}),bee=(e,t)=>({id:t,questionId:e,sender:_r.AGENT,status:$r.ANSWERED,types:[vr.FTQ],questionRole:Zr.PII,data:{messageItems:[Em(e,wr.PII_FORM_INTRO)]}}),Dm=e=>({id:`${Tm}-${e}`,questionId:e,sender:_r.CANDIDATE,status:$r.ANSWERING,types:[vr.FTQ],questionRole:Zr.PII,data:{messageItems:[Em(e,wr.PII_FORM)]}}),xee=(e,t)=>{var n;let r=t==null||(n=t[0])==null?void 0:n.questionId;if(!r)return e;let i=e=>e.sender===_r.AGENT&&e.questionId===r;if(!e.some(i))return e;let o=`${Tm}-${r}`,c=`${wm}-${r}`,l=e=>e.sender===_r.CANDIDATE&&e.questionId===r&&e.id!==o&&e.id!==c,u=e.filter(e=>!l(e)).map(e=>i(e)?{...e,data:{...e.data,messageItems:[Em(e.questionId,wr.PII_FORM_INTRO)]}}:e);return u.some(e=>e.id===o||e.id===c)?u:[...u,Dm(r)]},Om=({questionId:e,entries:t,status:n})=>({id:`${wm}-${e}`,questionId:e,sender:_r.CANDIDATE,status:n,types:[vr.FTQ],questionRole:Zr.PII,data:{messageItems:[Em(e,wr.PII_DETAILS)],piiDetails:t}}),See=(e,t)=>{if(Ir(e)){let{_id:n}=e.data,r=bee(n,e.id);return t&&Lr(t)?[r]:[r,Dm(n)]}if(Lr(e)){let{_id:t,responses:n}=e.data;return[Om({questionId:t,entries:n.map(e=>{var t,n;return{questionId:e.questionId,piiType:e.piiType,text:(t=e.answer)==null?``:t,value:(n=e.value)==null?``:n}}),status:$r.ANSWERED})]}},Cee=e=>{let t=e.findIndex(Ir);if(t===-1)return;let n=e[t+1];if(!(n&&Lr(n)))return e[t].data.fields},wee=(e,t,n,r)=>{let i=t[0].questionId,o=new Map(t.map(e=>[e.questionId,e.piiType])),c=Om({questionId:i,entries:n.map(e=>{var t;return{questionId:e.questionId,piiType:(t=o.get(e.questionId))==null?null:t,text:e.text,value:e.value}}),status:r}),l=`${Tm}-${i}`;return{bubbles:e.map(e=>e.id===l?c:e),detailsBubbleId:c.id}},Tee=[vr.SLIDER,vr.MCQ,vr.MSQ,vr.VIDEO,vr.DROPDOWN,vr.BGQ,vr.BREAK],km=[vr.MCQ,vr.MSQ,vr.DROPDOWN,vr.BGQ,vr.BREAK],Eee=[vr.SLIDER,vr.MCQ,vr.MSQ,vr.DROPDOWN,vr.BGQ,vr.BREAK],Am=e=>{if(!e||!Array.isArray(e)||e.length===0)return;let t;return e.forEach(e=>{e.name===`PII_TYPE`&&(t=e.value)}),t},jm=e=>{if(!e||!Array.isArray(e)||e.length===0)return;let t;return e.forEach(e=>{e.name===`VIDEO_TYPE`&&(t=e.value)}),t},Dee=e=>Array.isArray(e)&&e.some(e=>(e==null?void 0:e.name)===`ALLOW_PASTE`&&(e==null?void 0:e.value)===`true`),Mm=e=>Array.isArray(e)&&e.some(e=>(e==null?void 0:e.name)===`PH_BUTTON_TYPE`&&(e==null?void 0:e.value)===`ph_sms_consent`),Oee=e=>Array.isArray(e)&&e.some(e=>(e==null?void 0:e.name)===`PH_BUTTON_TYPE`&&(e==null?void 0:e.value)===`ph_i_accept`),kee=e=>Array.isArray(e)&&e.some(e=>(e==null?void 0:e.name)===`DEMOGRAPHIC_TYPE`),Nm=(e,t)=>{var n;return((n=e==null?void 0:e.options)==null?[]:n).some(e=>{var n;return((n=e.triggers)==null?[]:n).some(e=>(e==null?void 0:e.action)===t)})},Pm=e=>Array.isArray(e==null?void 0:e.types)&&e.types.length>0&&!e.types.includes(vr.HINT),Aee=[Cr.RATING_CUSTOMER_SATISFACTION_QUESTION,Cr.RATING_CUSTOMER_SATISFACTION_ANSWER,Cr.FEEDBACK_CUSTOMER_SATISFACTION_QUESTION,Cr.FEEDBACK_CUSTOMER_SATISFACTION_ANSWER],jee=[Cr.SUBMIT_QUESTION,Cr.SUBMIT_ANSWER],Mee=[Cr.SMS_CONSENT_QUESTION,Cr.SMS_CONSENT_ANSWER],Nee=[Cr.TERMS_CONSENT_QUESTION,Cr.TERMS_CONSENT_ANSWER],Fm=(e,t)=>{var n,r,i;let o=t==null?``:t;return(e==null?void 0:e.kind)===Er.HINT||!Pm(e)?Zr.HINT:!(e==null||(n=e.types)==null)&&n.includes(vr.BREAK)||Nm(e,`continue_dialogue`)?Zr.BREAK:Aee.includes(o)||!(e==null||(r=e.usageWhitelist)==null)&&r.includes(br.CUSTOMER_SATISFACTION)?Zr.CUSTOMER_SATISFACTION:jee.includes(o)||(e==null?void 0:e.masterId)===`ph_submit_assessment`||Nm(e,`submit_assessment`)?Zr.SUBMIT:Mee.includes(o)||Mm(e==null?void 0:e.tags)?Zr.SMS_CONSENT:Nee.includes(o)||(e==null?void 0:e.masterId)===`ph_i_accept`||Oee(e==null?void 0:e.tags)||Nm(e,`continue_assessment_with_consent`)?Zr.TERMS_CONSENT:kee(e==null?void 0:e.tags)?Zr.DEI:!(e==null||(i=e.usageWhitelist)==null)&&i.includes(br.PII)?Zr.PII:Zr.NORMAL},Im=e=>{var t,n,r,i,o,c,l;let u=e==null?void 0:e.data,d=(t=u==null||(n=u.question)==null?void 0:n.types)==null?[]:t,f,p;if(d.some(e=>Tee.includes(e)))if(p={text:u==null?void 0:u.text,value:u==null?void 0:u.value,...u!=null&&u.selections?{selections:u.selections}:{}},d.some(e=>km.includes(e))){var m,h;f=[{id:u==null?void 0:u._id,types:[yr.TEXT],contents:(m=u==null||(h=u.question)==null?void 0:h.options)==null?[]:m}]}else{var g,_;f=[{id:u==null?void 0:u._id,types:[yr.TEXT],contents:[{id:u==null?void 0:u._id,text:u==null||(g=u.question)==null||(g=g.contents)==null||(g=g[0])==null?void 0:g.value,value:u==null||(_=u.question)==null||(_=_.contents)==null||(_=_[0])==null?void 0:_.value}]}]}else f=[{id:u==null?void 0:u._id,types:[yr.TEXT],contents:[{id:u==null?void 0:u._id,text:u==null?void 0:u.text,value:u==null?void 0:u.value}]}];let v={id:e==null?void 0:e.id,questionId:u==null||(r=u.question)==null?void 0:r._id,sender:e==null?void 0:e.sender,messageIdentifier:e==null?void 0:e.messageIdentifier,status:$r.ANSWERED,types:d,usageWhitelist:u==null||(i=u.question)==null?void 0:i.usageWhitelist,masterId:u==null||(o=u.question)==null?void 0:o.masterId,questionRole:Fm(u==null?void 0:u.question,e==null?void 0:e.messageIdentifier),data:{messageItems:f,rules:u==null||(c=u.question)==null?void 0:c.rules,tags:u==null||(l=u.question)==null?void 0:l.tags}};return p&&(v.data.answer=p),v},Lm=(e,t)=>{var n,r;let i=e==null?void 0:e.data;return{id:e==null?void 0:e.id,questionId:i==null?void 0:i._id,sender:e==null?void 0:e.sender,messageIdentifier:e==null?void 0:e.messageIdentifier,status:t||!(i==null||(n=i.types)==null)&&n.includes(vr.HINT)?$r.ANSWERED:$r.ANSWERING,types:i==null?void 0:i.types,usageWhitelist:i==null?void 0:i.usageWhitelist,messageKind:i==null?void 0:i.kind,questionRole:Fm(i,e==null?void 0:e.messageIdentifier),data:{rules:i==null?void 0:i.rules,tags:i==null?void 0:i.tags,messageItems:((r=i==null?void 0:i.contents)==null?[]:r).map(e=>({id:e==null?void 0:e.value,types:e==null?void 0:e.types,component:e==null?void 0:e.component,contents:[{value:e==null?void 0:e.value,text:e==null?void 0:e.value,id:e==null?void 0:e.value}]}))},masterId:i==null?void 0:i.masterId,piiQuestionType:Am(i==null?void 0:i.tags),videoQuestionType:jm(i==null?void 0:i.tags)}},Pee=(e,t)=>{if((e==null?void 0:e.sender)===_r.CANDIDATE)return Im(e);if((e==null?void 0:e.sender)===_r.AGENT)return Lm(e,t)},Rm=e=>{var t,n;let r=e==null?void 0:e.data;if(!(r==null||(t=r.types)==null)&&t.some(e=>km.includes(e))){var i,o;return{id:`${e.id}-candidate`,questionId:r==null?void 0:r._id,sender:_r.CANDIDATE,messageIdentifier:e.messageIdentifier,status:$r.ANSWERING,types:r==null?void 0:r.types,usageWhitelist:r==null?void 0:r.usageWhitelist,masterId:r==null?void 0:r.masterId,questionRole:Fm(r,e.messageIdentifier),data:{messageItems:[{id:r==null||(i=r.contents)==null||(i=i[0])==null?void 0:i.value,types:[yr.TEXT],contents:(o=r==null?void 0:r.options)==null?[]:o}],rules:r==null?void 0:r.rules,tags:r==null?void 0:r.tags,answer:null}}}if(!(r==null||(n=r.types)==null)&&n.includes(vr.SLIDER)){var c;return{id:`${e.id}-candidate`,questionId:r==null?void 0:r._id,masterId:r==null?void 0:r.masterId,sender:_r.CANDIDATE,messageIdentifier:e.messageIdentifier,status:$r.ANSWERING,types:r==null?void 0:r.types,usageWhitelist:r==null?void 0:r.usageWhitelist,questionRole:Fm(r,e.messageIdentifier),data:{messageItems:((c=r==null?void 0:r.contents)==null?[]:c).map(e=>({id:e.value,types:e==null?void 0:e.types,contents:[{value:e==null?void 0:e.value,text:e==null?void 0:e.value,id:e.value}]}))}}}},Fee=e=>{let t=[];return e.forEach((n,r)=>{var i,o;let c=(i=(o=See(n,e[r+1]))==null?uee(n,e[r+1]):o)==null?_ee(n,e[r+1]):i;if(c){t.push(...c);return}let l=Pee(n,r<e.length-1);if(l&&t.push(l),r===e.length-1&&(n==null?void 0:n.sender)===_r.AGENT){var u;let e=n==null?void 0:n.data;if(!(e==null||(u=e.types)==null)&&u.some(e=>Eee.includes(e))){let e=Rm(n);e&&t.push(e)}}}),t},Iee=(e,t,n)=>e.map(e=>e.id===t?{...e,status:n}:e),Lee=(e,t,n)=>t?e.map(e=>e.id===t?n:e):[...e,n],Ree=(e,t,n)=>{let r=e.find(e=>e.id===t),i=n(r);return r?e.map(e=>e.id===t?i:e):[...e,i]},zee=(e,t)=>e.filter(e=>e.id!==t),Bee=(e,t,n)=>{let r=n?[t,n]:[t],i=e.findIndex(e=>e.id===t.id);if(i===-1)return[...e,...r];let o=[...e];return o.splice(i,1,...r),o},Vee=(e,t)=>e.find(e=>e.sender===_r.CANDIDATE&&e.questionId===t&&(e.status===$r.ANSWERING||e.status===$r.FAILED||e.status===$r.EDITING)),zm=e=>e.filter(e=>e.sender===_r.AGENT).at(-1),Bm=(e,t)=>e.find(e=>e.sender===_r.AGENT&&e.questionId===t),Vm=(e,t)=>e.map(e=>t!==void 0&&e.sender===_r.CANDIDATE&&e.questionId===t?{...e,status:$r.EDITING}:e.status===$r.EDITING?{...e,status:$r.ANSWERED}:e),Hee=[`en-GB`,`en-US`,`fr`,`es`,`de`,`fi`,`da`,`nl`,`it`,`sv`,`nb`,`pl`,`ar`],Hm=`en-US`,Uee=[`ar`],Um=e=>Hee.includes(e),Wee=e=>e?e.startsWith(`en`)&&!Um(e)?`en-US`:Um(e)?e:Hm:Hm,Gee=(e,t)=>e&&Um(e)?e:Wee(t),Kee=e=>Uee.includes(e.split(`-`)[0]),qee=e=>Kee(e)?`rtl`:`ltr`,Wm=`sapia-chatbot:v1`,Gm=()=>{try{return typeof window<`u`?window.localStorage:void 0}catch{return}},Km=()=>{let e=Gm();if(!e)return{};try{let t=e.getItem(Wm);return t?JSON.parse(t):{}}catch{return{}}},qm=e=>{let t=Gm();if(t)try{t.setItem(Wm,JSON.stringify(e))}catch{}},Jee=e=>{var t;return(t=Km().fiTokens)==null?void 0:t[e]},Yee=(e,t)=>{let n=Km();qm({...n,fiTokens:{...n.fiTokens,[e]:t}})},Jm=e=>{var t;let n=Km();if(!((t=n.fiTokens)!=null&&t[e]))return;let r={...n.fiTokens};delete r[e],qm({...n,fiTokens:r})},Xee=e=>{var t;return((t=Km().skipShortAnswerWarning)==null?void 0:t[e])===!0},Zee=(e,t)=>{let n=Km();qm({...n,skipShortAnswerWarning:{...n.skipShortAnswerWarning,[e]:t}})},Qee=(e,t)=>{var n;let r=(n=Km().answerDrafts)==null?void 0:n[e];return(r==null?void 0:r.questionId)===t?r.text:void 0},Ym=(e,t,n)=>{let r=Km();qm({...r,answerDrafts:{...r.answerDrafts,[e]:{questionId:t,text:n}}})},Xm=e=>{var t;let n=Km();if(!((t=n.answerDrafts)!=null&&t[e]))return;let r={...n.answerDrafts};delete r[e],qm({...n,answerDrafts:r})},$ee=(e,t)=>{var n,r;return(n=(r=Km().videoTakes)==null||(r=r[e])==null?void 0:r[t])==null?0:n},ete=(e,t)=>{var n,r,i;let o=Km(),c=((n=(r=o.videoTakes)==null||(r=r[e])==null?void 0:r[t])==null?0:n)+1;return qm({...o,videoTakes:{...o.videoTakes,[e]:{...(i=o.videoTakes)==null?void 0:i[e],[t]:c}}}),c},Zm=function(e){return e.IDLE=`idle`,e.VERIFYING=`verifying`,e.ACCESS_REQUIRED=`access-required`,e.STARTING=`starting`,e.WELCOME=`welcome`,e.ACTIVE=`active`,e.COMPLETING=`completing`,e.ENDED=`ended`,e.FAILED=`failed`,e.COHORT_CLOSED=`cohort-closed`,e.NOT_FOUND=`not-found`,e.TERMINAL_MESSAGE=`terminal-message`,e}({}),tte={phase:`idle`,bubbles:[],typing:!1,sendingAnswer:!1,numOfNormalQuestion:0,numOfNormalAnswer:0,featureFlags:{}},nte=()=>E(()=>({...tte})),Qm=`FI_START_ASSESSMENT_FAILED`,rte=`FI_ASSESSMENT_NOT_FOUND`,ite=`FI_LOAD_NEXT_FAILED`,ate=`FI_EXTRACT_HUMAN_NAME_FAILED`,ote=`FI_EDIT_ANSWER_FAILED`,ste=`FI_SUBMIT_VIDEO_ANSWER_FAILED`,cte=`FI_GET_TRANSLATION_FAILED`,lte=`FI_VERIFY_ACCESS_FAILED`,ute=`FI_DETECT_AGC_FAILED`,dte=`FI_UNAUTHENTICATED`,fte=`INVALID_PHONE_NUMBER`,pte=`INVALID_PASTE_ANSWER_ACTION`,mte=`INVALID_REDIRECT_URL`,$m=e=>e instanceof Error?e.message:String(e),eh=(e,t,n,r=!1)=>{var i,o;return{id:e,questionId:(i=n==null?void 0:n._id)==null?e:i,sender:_r.AGENT,status:$r.ANSWERING,types:(o=n==null?void 0:n.types)==null?[]:o,usageWhitelist:n==null?void 0:n.usageWhitelist,masterId:n==null?void 0:n.masterId,messageKind:n==null?void 0:n.kind,questionRole:Fm(n),piiQuestionType:Am(n==null?void 0:n.tags),videoQuestionType:jm(n==null?void 0:n.tags),data:{rules:n==null?void 0:n.rules,tags:n==null?void 0:n.tags,messageItems:t.map((t,i)=>{var o,c,l,u;let d=r?n==null||(o=n.contents)==null?void 0:o[i]:void 0,f=`${e}-${i}`;return{id:f,types:(c=d==null?void 0:d.types)==null?[yr.TEXT]:c,component:(l=d==null?void 0:d.component)==null?n==null||(u=n.contents)==null||(u=u[i])==null?void 0:u.component:l,contents:[{id:f,value:t,text:t}]}})}}},hte=(e,t)=>t?(e.messageKind=t.kind,e.data.messageItems.forEach((e,n)=>{var r;e.component=(r=t.contents)==null||(r=r[n])==null?void 0:r.component}),e):e,th=e=>({text:e.text,value:e.value,...e.triggers?{triggers:e.triggers}:{},...e.style?{style:e.style}:{}}),nh=e=>({text:e.map(e=>e.text).join(` | `),value:e.map(e=>e.value).join(` | `),selections:e.map(({id:e,value:t,text:n})=>({id:e,value:t,text:n}))}),gte=function(e){return e.ALL_THAT_APPLY=`ALL_THAT_APPLY`,e.UP_TO_MAX=`UP_TO_MAX`,e}({}),_te=1,rh=(e,t)=>{var n;let r=e==null||(n=e.find(e=>e.name===t))==null?void 0:n.value;if(r===void 0)return;let i=typeof r==`number`?r:Number(r);return Number.isFinite(i)&&i>0?i:void 0},ih=e=>{var t;return{min:(t=rh(e,gr.MIN_SELECTIONS))==null?1:t,max:rh(e,gr.MAX_SELECTIONS)}},vte=e=>{var t;return((t=e.types)==null?[]:t).includes(vr.MSQ)},ah=e=>{var t;return oh((t=e.types)==null?[]:t,e.data.rules)},oh=(e,t)=>e.includes(vr.MSQ)&&ih(t).max!==_te,sh=(e,t)=>e.max===void 0||e.max>=t?`ALL_THAT_APPLY`:`UP_TO_MAX`,ch=e=>new Promise(t=>setTimeout(t,e)),lh=8,yte=(e,t)=>{let n=/^\s*\S+/.exec(e.slice(t));if(!n)return t;let r=t+n[0].length;return r<e.length?r:t},bte=class{constructor(e,t,n){this.revealMs=e,this.nextSyntheticId=t,this.paint=n,this.received=``,this.revealed=0,this.chunks=[],this.metaById=new Map,this.networkDone=!1,this.placed=!1,this.live=t()}get liveId(){return this.live}get baseId(){return this.currentBaseId}metaFor(e){return this.metaById.get(e)}onMeta(e,t){this.metaById.set(t,e),(this.currentBaseId===void 0||this.currentBaseId===t)&&(this.meta=e,this.placed&&this.writeLive())}onDelta(e,t){var n,r;let[i,o]=t.split(`:`);this.currentBaseId!==void 0&&i!==this.currentBaseId&&this.commit(this.currentBaseId),this.currentBaseId=i,this.live=i,this.meta=(n=this.metaById.get(i))==null?this.meta:n;let c=Number(o),l=Number.isInteger(c)&&c>=0?c:0;this.chunks[l]=((r=this.chunks[l])==null?``:r)+e,this.received=this.chunks.join(``)}commitCurrent(){this.currentBaseId&&this.commit(this.currentBaseId)}finish(){this.networkDone=!0}async run(){if(this.revealMs===void 0){for(;!this.networkDone;)await ch(lh);if(this.received.length===0)return;this.revealed=this.received.length,this.writeLive();return}let e=0;for(;this.revealed<this.received.length||!this.networkDone;){if(this.revealed>=this.received.length){await ch(lh);continue}let t=this.revealed,n=this.revealMs===0?this.received.length:yte(this.received,this.revealed);if(n===this.revealed){if(!this.networkDone&&e<120){e+=lh,await ch(lh);continue}this.revealed=this.received.length}else this.revealed=n;e=0,this.writeLive(),this.revealMs>0&&await ch(this.revealMs*(this.revealed-t))}}revealedTexts(){let e=[],t=this.revealed;for(let r=0;r<this.chunks.length;r++){var n;let i=(n=this.chunks[r])==null?``:n;e.push(i.slice(0,t)),t=Math.max(0,t-i.length)}return e.filter(e=>e.length>0)}writeLive(){this.paint.live(eh(this.live,this.revealedTexts(),this.meta),this.live,this.placed),this.placed=!0}commit(e){var t;this.revealed=this.received.length;let n=eh(e,this.chunks.filter(e=>e.length>0),this.metaById.get(e),!0);n.status=$r.ANSWERED,(t=n.types)!=null&&t.length||(n.types=[vr.HINT]),n.questionRole=Zr.HINT,this.paint.commit(n,this.live,this.placed),this.live=this.nextSyntheticId(),this.received=``,this.revealed=0,this.chunks=[],this.placed=!1,this.meta=void 0}},xte=`video-answer`,Ste=`optimistic-answer`,Cte=`unknown`,wte=`AbortError`,Tte=()=>typeof navigator<`u`?navigator.userAgent:Cte,uh=e=>e===Sr.FI_ASSESSMENT_ENDED,Ete=e=>e===Sr.FI_ASSESSMENT_DUPLICATED,Dte=class{constructor(e){var t,n,r,i,o;this.streamSeq=0,this.sessionExpiring=!1,this.welcomeChatLogs=[],this.client=e.client,this.store=e.store,this.emitter=e.emitter,this.assessmentId=e.assessmentId,this.userAgent=(t=e.userAgent)==null?Tte():t,this.language=(n=e.language)==null?Hm:n,this.welcomeGate=(r=e.welcomeGate)==null?!1:r,this.streamRevealMs=(i=e.streamRevealMs)==null?15:i,this.streamText=(o=e.streamText)==null?!1:o,this.store.setState({language:this.language}),this.client.setOnUnauthorized(e=>void this.expireSession(e)),this.client.setOnLapsedFiToken(()=>this.resolveLapsedFiToken())}async loadTranslations(){try{let e=await this.client.getTranslation(this.language);this.store.setState({translations:e})}catch(e){this.emitter.emit(S.ERROR,{type:cte,message:$m(e)})}}async loadFeatureFlags(){try{let e=await this.client.resolveFeatureFlags(this.assessmentId);this.store.setState({featureFlags:e})}catch{}}async begin(){this.store.setState({phase:Zm.VERIFYING});let e=Jee(this.assessmentId);e&&!pr(e)?Jm(this.assessmentId):this.client.setFiToken(e);let t;try{t=await this.client.getAccessManagement(this.assessmentId)}catch(e){if(lr(e)){this.store.setState({phase:Zm.NOT_FOUND}),this.emitter.emit(S.ERROR,{type:rte,message:$m(e)});return}await this.start();return}if(!t.shouldAuthenticate){await this.start();return}if(this.client.getFiToken()){await this.start();return}t.language&&t.language!==this.language&&(this.language=t.language,this.store.setState({language:t.language}),await this.loadTranslations()),this.store.setState({phase:Zm.ACCESS_REQUIRED,emailHint:t.emailHint})}async verifyAccessEmail(e){let t=e.trim();if(!nm(t).ok){this.store.setState({accessEmailMismatch:!0});return}this.store.setState({verifyingAccess:!0,accessEmailMismatch:!1});try{(await this.client.verifyAccess(this.assessmentId,t)).allowToAccess?(this.persistFiToken(),this.store.setState({verifyingAccess:!1}),await this.start()):this.store.setState({verifyingAccess:!1,accessEmailMismatch:!0})}catch(e){if(this.store.setState({verifyingAccess:!1}),cr(e))return;this.emitter.emit(S.ERROR,{type:lte,message:$m(e)})}}cacheUnsentAnswer(e){var t;if(!e||Array.isArray(e))return;let n=(t=e.answer)==null?void 0:t.text;n&&Ym(this.assessmentId,e.questionId,n)}persistFiToken(){let e=this.client.getFiToken();e&&Yee(this.assessmentId,e)}async expireSession(e,t){if(!this.sessionExpiring){this.sessionExpiring=!0,e&&this.emitter.emit(S.ERROR,{type:dte,message:$m(e)});try{Jm(this.assessmentId),this.client.setFiToken(void 0);let e=t==null?await this.client.getAccessManagement(this.assessmentId).catch(()=>void 0):t;this.store.setState({phase:Zm.ACCESS_REQUIRED,emailHint:e==null?void 0:e.emailHint,accessEmailMismatch:!1})}finally{this.sessionExpiring=!1}}}resolveLapsedFiToken(){return this.lapseResolution||(this.lapseResolution=(async()=>{try{let e=await this.client.getAccessManagement(this.assessmentId).catch(()=>void 0);return e!=null&&e.shouldAuthenticate?(this.expireSession(void 0,e),!0):(Jm(this.assessmentId),this.client.setFiToken(void 0),!1)}finally{this.lapseResolution=void 0}})()),this.lapseResolution}checkSessionExpiry(){this.client.hasLapsedFiToken()&&this.resolveLapsedFiToken()}async start(){this.store.setState({phase:Zm.STARTING}),this.loadTranslations(),this.loadFeatureFlags();try{var e;let t=await this.client.startAts(this.assessmentId);if(this.persistFiToken(),t.isCohortClosed){this.store.setState({phase:Zm.COHORT_CLOSED,branding:t.branding,jobTitle:t.jobTitle,customerName:t.customerName});return}let n=(e=t.chatLogs)==null?[]:e,r=Fee(n),i=uh(t.assessmentStatus),o=this.welcomeGate&&!i&&!n.some(e=>e.sender===_r.CANDIDATE);if(this.store.setState({phase:i?Zm.ENDED:Zm.ACTIVE,assessmentStatus:t.assessmentStatus,bubbles:r,branding:t.branding,candidateName:t.candidateFirstName,jobTitle:t.jobTitle,customerName:t.customerName,numOfNormalQuestion:t.numOfNormalQuestion,numOfNormalAnswer:t.numOfNormalAnswer,candidateCountryCode:t.candidateCountryCode,agcAttempt:t.agcDetectionAttempt,allowNextAgcDetection:t.allowNextAgcDetection,termsAccepted:t.isTermsAndConditionsAccepted,assessmentSummary:t.summary,assessmentLink:t.assessmentLink,piiForm:Cee(n),csatForm:dee(n),deiForm:vee(n)}),this.emitter.emit(S.ASSESSMENT_STARTED,{assessmentId:this.assessmentId}),i){this.emitter.emit(S.ASSESSMENT_ENDED,{assessmentId:this.assessmentId,justCompleted:!1});return}if(this.handleTerminalSignals(t))return;if(o){this.welcomeChatLogs=n,this.store.setState({phase:Zm.WELCOME});return}await this.firstLoad(n)}catch(e){if(cr(e))return;this.store.setState({phase:Zm.FAILED,lastError:{type:Qm,message:$m(e)}}),this.emitter.emit(S.ERROR,{type:Qm,message:$m(e)})}}async confirmWelcome(){this.store.getState().phase===Zm.WELCOME&&(this.store.setState({phase:Zm.ACTIVE}),await this.firstLoad(this.welcomeChatLogs))}acknowledgeCompletion(){this.store.getState().phase===Zm.COMPLETING&&this.store.setState({phase:Zm.ENDED})}async firstLoad(e){var t;if(e.length===0){await this.loadNext();return}let n=this.store.getState().bubbles,r=n[n.length-1];!(r==null||(t=r.types)==null)&&t.includes(vr.HINT)&&await this.loadNext({userAgent:this.userAgent,questionId:r.questionId})}async submitTextAnswer(e){await this.submitFreeText(e)}async submitEmailAnswer(e){return this.submitResolved(cm(e))}async submitPhoneAnswer(e,t){return this.submitResolved(await lm(e,t,()=>this.emitter.emit(S.LOG,{type:fte,message:`Invalid phone number for ${t}: ${e}`})))}async submitNameAnswer(e){let t=this.currentPiiType(),n=await um(t,e,(e,t)=>this.extractName(e,t));return`submit`in n&&this.rememberCandidateName(t,n.submit),this.submitResolved(n)}async extractName(e,t){try{return(await this.client.extractHumanName(this.assessmentId,{userText:e,extractType:t}))[t]}catch(e){cr(e)||this.emitter.emit(S.ERROR,{type:ate,message:$m(e)});return}}async submitResolved(e){return`outcome`in e?e.outcome:(await this.submitFreeText(e.submit),{status:om.SUBMITTED})}async submitNameConfirmed(e){this.rememberCandidateName(this.currentPiiType(),e),await this.submitFreeText(e)}rememberCandidateName(e,t){(e===xr.FIRST_NAME||e===xr.FULL_NAME&&!this.store.getState().candidateName)&&this.store.setState({candidateName:t})}async submitLocationAnswer(e){let t=this.currentEditableQuestionId();!t||this.store.getState().sendingAnswer||await this.dispatchFreshOrEdit(t,{text:e.address,value:JSON.stringify(e)})}async submitPiiForm(e){let t=this.store.getState().piiForm;if(!(t!=null&&t.length)||e.length===0||this.store.getState().sendingAnswer)return;let n=e.map(e=>({userAgent:this.userAgent,questionId:e.questionId,answer:{text:e.text,value:e.value}}));e.forEach(e=>{var n;return this.rememberCandidateName((n=t.find(t=>t.questionId===e.questionId))==null?void 0:n.piiType,e.text)}),this.store.setState({piiFormAnswers:e}),this.replacePiiFormWithDetails(t,e,$r.PENDING),await this.loadNext(n),this.lastFailedInput||this.store.setState({piiForm:void 0})}replacePiiFormWithDetails(e,t,n){this.store.setState(r=>{let{bubbles:i,detailsBubbleId:o}=wee(r.bubbles,e,t,n);return this.pendingBubbleId=o,{bubbles:i}})}async submitCustomerSatisfactionForm(e){let t=this.store.getState().csatForm;if(!(t!=null&&t.length)||this.store.getState().sendingAnswer)return;let n=t.map(t=>{let n=t.fieldType===Mr.RATING?String(e.rating):e.comment.trim()?e.comment:li;return{userAgent:this.userAgent,questionId:t.questionId,answer:{text:n,value:n}}});this.store.setState(n=>{let{bubbles:r,responseBubbleId:i}=fee(n.bubbles,t,e,$r.PENDING);return this.pendingBubbleId=i,{bubbles:r}}),await this.loadNext(n),this.lastFailedInput||this.store.setState({csatForm:void 0})}async submitDemographicForm(e){let t=this.store.getState().deiForm;if(!(t!=null&&t.length)||this.store.getState().sendingAnswer)return;let n=Cm(t,e);if(n.length!==t.length)return;let r=n.map(({field:e,options:t})=>({userAgent:this.userAgent,questionId:e.questionId,answer:e.questionTypes.includes(vr.MSQ)?nh(t):th(t[0])}));this.store.setState(n=>{let{bubbles:r,detailsBubbleId:i}=yee(n.bubbles,t,e,$r.PENDING);return this.pendingBubbleId=i,{bubbles:r}}),await this.loadNext(r),this.lastFailedInput||this.store.setState({deiForm:void 0})}enterEditMode(e){var t,n;if(this.store.getState().sendingAnswer)return;let r=(t=(n=this.store.getState().bubbles.find(t=>t.sender===_r.CANDIDATE&&t.questionId===e))==null||(n=n.data.answer)==null?void 0:n.selections)==null?[]:t;this.store.setState(t=>({editingQuestionId:e,multiSelectDraft:r.length>0?{questionId:e,optionIds:r.map(e=>e.id)}:void 0,bubbles:Vm(t.bubbles,e)}))}cancelEditMode(){this.store.setState(e=>({editingQuestionId:void 0,multiSelectDraft:void 0,bubbles:Vm(e.bubbles)}))}async submitVideoAnswer(e,t){var n;let r=this.currentEditableQuestionId();if(!r||this.store.getState().sendingAnswer)return;let i=this.store.getState().editingQuestionId===r?this.candidateBubbleFor(r):void 0,o=(n=i==null?void 0:i.id)==null?`${xte}-${r}`:n;i||(this.lastVideoAnswer={questionId:r,blob:e,extension:t}),this.upsertVideoBubble(o,r,{status:$r.PENDING,uploadProgress:0,videoBlob:e,videoExtension:t}),this.store.setState({sendingAnswer:!0});try{let{url:n,videoFileName:c}=await this.client.getVideoUploadUrl(this.assessmentId,r,t);await this.client.uploadVideo(n,e,t,n=>{this.upsertVideoBubble(o,r,{status:$r.PENDING,uploadProgress:n,videoBlob:e,videoExtension:t})});let l={text:c,value:c};this.upsertVideoBubble(o,r,{status:$r.PENDING,uploadProgress:void 0,videoBlob:e,videoExtension:t}),i?await this.editExistingAnswer(r,l,{videoBlob:e,videoExtension:t}):(this.pendingBubbleId=o,await this.loadNext({userAgent:this.userAgent,questionId:r,answer:l})),this.lastVideoAnswer=void 0}catch(n){if(i?this.store.setState(e=>({sendingAnswer:!1,editFailedQuestionId:cr(n)?void 0:r,bubbles:e.bubbles.map(e=>e.id===o?{...i,status:$r.EDITING}:e)})):(this.upsertVideoBubble(o,r,{status:$r.FAILED,videoBlob:e,videoExtension:t}),this.store.setState({sendingAnswer:!1})),cr(n))return;this.emitter.emit(S.ERROR,{type:ste,message:$m(n)})}}async retryVideoAnswer(){if(!this.lastVideoAnswer)return;let{blob:e,extension:t}=this.lastVideoAnswer;await this.submitVideoAnswer(e,t)}async getVideoPlaybackUrl(e,t){return(await this.client.getVideoAccessUrl(this.assessmentId,e,t)).url}upsertVideoBubble(e,t,n){this.store.setState(r=>({bubbles:Ree(r.bubbles,e,r=>({id:e,questionId:t,sender:_r.CANDIDATE,status:$r.PENDING,types:[vr.VIDEO],questionRole:this.questionRoleFor(t),data:{messageItems:[]},...r,...n}))}))}candidateBubbleFor(e){return this.store.getState().bubbles.find(t=>t.sender===_r.CANDIDATE&&t.questionId===e)}async submitFreeText(e){let t=this.currentEditableQuestionId();!t||this.store.getState().sendingAnswer||await this.dispatchFreshOrEdit(t,{text:e,value:e})}async dispatchFreshOrEdit(e,t){if(this.store.getState().editingQuestionId===e){await this.editExistingAnswer(e,t);return}let n={userAgent:this.userAgent,questionId:e,answer:t};this.appendOptimisticCandidateBubble(n),await this.loadNext(n)}async editExistingAnswer(e,t,n){this.store.setState(n=>({sendingAnswer:!0,editFailedQuestionId:void 0,bubbles:n.bubbles.map(n=>n.sender===_r.CANDIDATE&&n.questionId===e?{...n,status:$r.PENDING,data:{...n.data,answer:t}}:n)}));try{let r=Im((await this.client.editAnswer(this.assessmentId,{questionId:e,answer:t})).updatedCandidateResponse);this.store.setState(t=>({sendingAnswer:!1,editingQuestionId:void 0,multiSelectDraft:void 0,bubbles:t.bubbles.map(t=>t.sender===_r.CANDIDATE&&t.questionId===e?{...r,...n}:t)})),this.emitter.emit(S.ANSWER_EDITED,{questionId:e})}catch(t){let n=cr(t);if(this.store.setState(t=>({sendingAnswer:!1,editFailedQuestionId:n?void 0:e,bubbles:t.bubbles.map(t=>t.sender===_r.CANDIDATE&&t.questionId===e?{...t,status:$r.EDITING}:t)})),n)return;this.emitter.emit(S.ERROR,{type:ote,message:$m(t)})}}currentEditableQuestionId(){var e;return(e=this.store.getState().editingQuestionId)==null?this.currentQuestionId():e}currentPiiType(){var e,t;let{bubbles:n,editingQuestionId:r}=this.store.getState();return r?(e=Bm(n,r))==null?void 0:e.piiQuestionType:(t=zm(n))==null?void 0:t.piiQuestionType}async submitOptionAnswer(e,t=!1){var n;let r=this.currentEditableQuestionId();if(!r||this.store.getState().sendingAnswer)return;let i=this.inlineCandidateBubble(r),o=i==null||(n=i.data.messageItems)==null||(n=n[0])==null||(n=n.contents)==null?void 0:n.find(t=>t.id===e);if(!(!i||!o)){if(this.setBubbleStatus(i.id,$r.PENDING),!t&&await this.detectedAgc(i)){this.pendingAgcOptionId=e,this.setBubbleStatus(i.id,i.status);return}await this.submitInlineAnswer(i,r,vte(i)?nh([o]):th(o))}}toggleOptionSelection(e){var t,n;let r=this.currentEditableQuestionId();if(!r||this.store.getState().sendingAnswer)return;let i=this.inlineCandidateBubble(r);if(!i||!ah(i)||!((t=(n=i.data.messageItems)==null||(n=n[0])==null?void 0:n.contents)==null?[]:t).some(t=>t.id===e))return;let{max:o}=ih(i.data.rules),c=this.selectedOptionIds(r),l=c.includes(e)?c.filter(t=>t!==e):[...c,e];o!==void 0&&l.length>o||this.store.setState({multiSelectDraft:{questionId:r,optionIds:l}})}async confirmSelections(){var e,t;let n=this.currentEditableQuestionId();if(!n||this.store.getState().sendingAnswer)return;let r=this.inlineCandidateBubble(n);if(!r||!ah(r))return;let i=this.selectedOptionIds(n),o=((e=(t=r.data.messageItems)==null||(t=t[0])==null?void 0:t.contents)==null?[]:e).filter(e=>i.includes(e.id)),{min:c,max:l}=ih(r.data.rules);o.length<c||l!==void 0&&o.length>l||await this.submitInlineAnswer(r,n,nh(o))}selectedOptionIds(e){let{multiSelectDraft:t}=this.store.getState();return(t==null?void 0:t.questionId)===e?t.optionIds:[]}async detectedAgc(e){var t;let n=e.messageIdentifier===Cr.SUBMIT_QUESTION,{allowNextAgcDetection:r,featureFlags:i}=this.store.getState(),o=((t=i[Dr.AGC])==null?void 0:t.enabled)!==!1;if(!n||!r||!o)return!1;try{let e=await this.client.detectAgc(this.assessmentId);if(this.store.setState({agcAttempt:e.attempt,allowNextAgcDetection:e.allowNextAgcDetection}),e.isAgc)return this.store.setState({showAgcWarning:!0}),!0}catch(e){if(cr(e))return!1;this.emitter.emit(S.ERROR,{type:ute,message:$m(e)})}return!1}async continueAfterAgcWarning(){let e=this.pendingAgcOptionId;this.pendingAgcOptionId=void 0,this.store.setState({showAgcWarning:!1}),e&&await this.submitOptionAnswer(e,!0)}dismissAgcWarning(){this.pendingAgcOptionId=void 0,this.store.setState({showAgcWarning:!1})}dismissEditFailure(){this.store.setState({editFailedQuestionId:void 0})}reportPaste(){this.emitter.emit(S.LOG,{type:pte,message:`Candidate pasted an answer`})}async submitSliderAnswer(e){let t=this.currentEditableQuestionId();if(!t||this.store.getState().sendingAnswer)return;let n=this.inlineCandidateBubble(t);n&&await this.submitInlineAnswer(n,t,{text:String(e),value:String(e)})}async submitInlineAnswer(e,t,n){if(this.store.getState().editingQuestionId===t){await this.editExistingAnswer(t,n);return}this.pendingBubbleId=e.id,this.store.setState(t=>({bubbles:t.bubbles.map(t=>t.id===e.id?{...t,status:$r.PENDING,data:{...t.data,answer:n}}:t)})),await this.loadNext({userAgent:this.userAgent,questionId:t,answer:n})}async retryLastAnswer(){if(!this.lastFailedInput)return;let e=this.lastFailedInput;this.lastFailedInput=void 0,this.setPendingBubbleStatus($r.PENDING),await this.loadNext(e)}currentQuestionId(){var e;return(e=zm(this.store.getState().bubbles))==null?void 0:e.questionId}inlineCandidateBubble(e){return Vee(this.store.getState().bubbles,e)}questionRoleFor(e){var t,n;return(t=(n=Bm(this.store.getState().bubbles,e))==null?void 0:n.questionRole)==null?Zr.NORMAL:t}appendOptimisticCandidateBubble(e){var t,n,r,i;let o={id:`${Ste}-${e.questionId}`,questionId:e.questionId,sender:_r.CANDIDATE,status:$r.PENDING,types:[vr.FTQ],questionRole:this.questionRoleFor(e.questionId),data:{messageItems:[{id:e.questionId,types:[],contents:[{id:e.questionId,text:(t=(n=e.answer)==null?void 0:n.text)==null?``:t,value:(r=(i=e.answer)==null?void 0:i.value)==null?``:r}]}],...e.answer?{answer:e.answer}:{}}};this.pendingBubbleId=o.id,this.store.setState(e=>({bubbles:[...e.bubbles,o]}))}setBubbleStatus(e,t){this.store.setState(n=>({bubbles:Iee(n.bubbles,e,t)}))}setPendingBubbleStatus(e){let t=this.pendingBubbleId;t&&this.setBubbleStatus(t,e)}replacePendingBubble(e){this.store.setState(t=>({bubbles:Lee(t.bubbles,this.pendingBubbleId,e)}))}async loadNext(e){var t;(t=this.streamAbort)==null||t.abort();let n=new AbortController;this.streamAbort=n;let r=Array.isArray(e)?void 0:e;this.store.setState({sendingAnswer:!!(r!=null&&r.answer)||Array.isArray(e),typing:!0});let i=new bte(this.streamText?this.streamRevealMs:void 0,()=>`${ii}-${this.streamSeq++}`,{live:(e,t,n)=>this.store.setState(r=>({typing:!1,streamingBubbleId:t,bubbles:n?r.bubbles.map(n=>n.id===t?e:n):[...r.bubbles,e]})),commit:(e,t,n)=>this.store.setState(r=>({streamingBubbleId:void 0,bubbles:n?r.bubbles.map(n=>n.id===t?e:n):[...r.bubbles,e]}))}),o=i.run(),c=()=>this.store.setState(e=>({streamingBubbleId:void 0,bubbles:zee(e.bubbles,i.liveId)}));try{var l,u;let t=await this.client.nextStream(this.assessmentId,e,{signal:n.signal,streamText:this.streamText,onSummary:e=>{this.store.getState().assessmentSummary||this.store.setState({assessmentSummary:e})},onLink:e=>this.store.setState({assessmentLink:e}),onPiiForm:e=>this.store.setState({piiForm:e}),onCustomerSatisfactionForm:e=>this.store.setState({csatForm:e}),onDemographicForm:e=>this.store.setState({deiForm:e}),onMeta:(e,t)=>i.onMeta(e,t),onDelta:(e,t)=>i.onDelta(e,t)});if(i.finish(),this.persistFiToken(),await o,!t){this.store.setState({typing:!1,sendingAnswer:!1});return}if((l=t.nextResponse)!=null&&l.data?t.nextResponse.id===i.liveId?this.store.setState({streamingBubbleId:void 0}):c():i.commitCurrent(),Array.isArray(e)&&(this.setPendingBubbleStatus($r.ANSWERED),this.pendingBubbleId=void 0),this.settleAnswerAndStatus(t,r))return;let d=t.nextResponse,f=d?(u=i.metaFor(d.id))==null?d.data?i.metaFor(d.data._id):void 0:u:void 0;await this.appendAgentAndContinue(t,f)}catch(t){if(i.finish(),await o.catch(()=>{}),t.name===wte)return;if(c(),this.lastFailedInput=e,cr(t)){this.cacheUnsentAnswer(e),this.store.setState({typing:!1,sendingAnswer:!1});return}this.setPendingBubbleStatus($r.FAILED),this.store.setState({typing:!1,sendingAnswer:!1}),this.emitter.emit(S.ERROR,{type:ite,message:$m(t)})}}handleTerminalSignals(e){var t,n;if((Ete(e.assessmentStatus)||e.duplicatedWithAssessmentLink)&&this.store.setState({duplicated:!0}),e.duplicatedWithAssessmentLink&&this.emitter.emit(S.ASSESSMENT_DUPLICATED,{assessmentId:this.assessmentId,duplicatedWithAssessmentLink:e.duplicatedWithAssessmentLink}),e.assessmentStatus&&uh(e.assessmentStatus))return!1;let r=(t=e.cohortIsArchivedMessage)==null?e.assessmentIsReusedMessage:t,i=r==null||(n=r.data)==null||(n=n.contents)==null||(n=n[0])==null?void 0:n.value;return i?(this.store.setState({phase:Zm.TERMINAL_MESSAGE,typing:!1,terminalMessage:i}),this.emitter.emit(S.ASSESSMENT_ENDED,{assessmentId:this.assessmentId,justCompleted:!1}),!0):!1}settleAnswerAndStatus(e,t){var n,r;if(t!=null&&t.answer){var i;let n=e.candidateResponse;n&&((i=n.data)==null||(i=i.question)==null?void 0:i._id)===t.questionId?this.replacePendingBubble(Im(n)):this.setPendingBubbleStatus($r.ANSWERED),this.pendingBubbleId=void 0,this.emitter.emit(S.ANSWER_SAVED,{questionId:t.questionId})}return this.store.setState({sendingAnswer:!1,assessmentStatus:e.assessmentStatus,numOfNormalAnswer:(n=e.numOfNormalAnswer)==null?this.store.getState().numOfNormalAnswer:n,termsAccepted:(r=e.isTermsAndConditionsAccepted)==null?this.store.getState().termsAccepted:r}),this.handleTerminalSignals(e)}async appendAgentAndContinue(e,t){let n=e.nextResponse;if(n!=null&&n.data){var r;let e=hte(Lm(n),t),i=Rm(n);if(this.store.setState(t=>({typing:!1,bubbles:hee(cee(xee(Bee(t.bubbles,e,i),t.piiForm),t.csatForm),t.deiForm)})),(r=n.data.types)!=null&&r.includes(vr.HINT)){await this.loadNext({userAgent:this.userAgent,questionId:n.data._id});return}}else this.store.setState({typing:!1});if(!(n!=null&&n.data)||uh(e.assessmentStatus)){let t=this.store.getState().duplicated!==!0||uh(e.assessmentStatus);t&&this.store.setState({phase:Zm.COMPLETING}),this.emitter.emit(S.ASSESSMENT_ENDED,{assessmentId:this.assessmentId,justCompleted:t})}}},dh=`true`,Ote=()=>{if(typeof window>`u`)return!1;let e=new URLSearchParams(window.location.search);return e.get(`internalUser`)===dh||e.get(`sapian`)===dh},kte=e=>{if(e)try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?e:void 0}catch{return}},Ate={fi_label_typing:`Typing`,fi_button_edit:`Edit`,fi_button_continue:`Continue`,fi_button_retry:`Retry`,fi_button_record:`Record`,fi_button_stop:`Stop`,fi_button_tryAgain:`Try Again`,fi_button_submitRating:`Submit rating`,fi_button_next:`Next`,fi_button_accept:`Accept`,fi_button_readFullBrief:`Read the full brief`,fi_tooltip_copiedUrl:`Link is copied`,fi_button_showMore:`Show more`,fi_button_showLess:`Show less`,fi_label_collectDetailsIntro:`Let's grab a few quick details.`,fi_label_yourDetails:`Your details`,fi_label_reviewDetailsWarning:`Please review your details carefully as you cannot change this later`,fi_label_editing:`Editing`,fi_label_ratingMessage:`Rate your experience!`,fi_label_enterResponse:`Enter your response…`,fi_label_enterOrPasteResponse:`Type or paste your response…`,fi_label_enterOrSkipFeedback:`Leave a comment here if you wish, or click the arrow button to continue`,fi_label_uploading:`Uploading your video`,fi_label_uploadFailed:`Your video failed to upload.`,fi_label_cancelEditDesktop:`Cancel edit`,fi_placeholder_dropdown:`Type to search…`,fi_placeholder_demoEmailInput:`Enter your email`,fi_error_piiEmail:`Please enter a valid email address.`,fi_error_piiFullName:`Please enter a valid full name.`,fi_error_piiFirstName:`Please enter a valid first name.`,fi_error_piiLastName:`Please enter a valid last name.`,fi_error_piiPhoneNumber:`Please enter a valid phone number.`,ci_error_piiLocation:`Please enter your town or city.`,fi_error_sendAnswerFailed:`We could not send your answer. Please try again.`,fi_error_submitVideo:`We could not submit your video. Please try again.`,ci_header_title:`Interview`,ci_widget_label:`Chat interview`,ci_video_badge:`Video`,ci_typing:`Interviewer is typing`,ci_label_loadingNextPrompt:`Loading…`,ci_scroll_to_latest:`Scroll to the latest message`,ci_progress_label:`Interview progress`,ci_written_question_counter:`Written question {{current}} of {{total}}`,ci_quick_additional_question_counter:`Quick additional question {{current}} of {{total}}`,ci_video_question_counter:`Video question {{current}} of {{total}}`,ci_diversity_counter:`Diversity {{current}} of {{total}}`,ci_pause_hint:`Pause anytime — come back with this link`,ci_welcome_greeting:`Hi {{name}}.`,ci_welcome_greeting_generic:`Hi there.`,ci_welcome_title:`Welcome to your Chat Interview`,ci_welcome_eyebrow:`Chat interview`,ci_welcome_copy_resume:`Copy link · resume later`,ci_welcome_intro:`A conversation for the {{role}} role with {{company}} — answered in your own words, read blind to your name, age and background.`,ci_welcome_intro_generic:`A conversation answered in your own words, read blind to your name, age and background.`,ci_welcome_pause:`You can pause and come back later with this link`,ci_welcome_reassurance:`No right or wrong answers. Take your time.`,fi_label_summaryTotal:`Total`,fi_label_summaryQuestionCount:`{{totalQuestions}} Questions (~ {{estimatedMinutes}} minutes)`,fi_label_summaryRowInterview_one:`{{count}} Written question`,fi_label_summaryRowInterview_other:`{{count}} Written questions`,fi_label_summaryRowInterviewDescription:`Answer in your own words, and take as long as you need. [Sapia.ai](https://sapia.ai/)'s AI read and scores these.`,fi_label_summaryRowVideo_one:`{{count}} Video question`,fi_label_summaryRowVideo_other:`{{count}} Video questions`,fi_label_summaryRowVideoDescription:`You can retry **{{maxRetries}}** times per question and submit when you're ready.`,fi_label_summaryRowAdditional_one:`{{count}} Quick additional question`,fi_label_summaryRowAdditional_other:`{{count}} Quick additional questions`,fi_label_summaryRowAdditionalDescription:`These aren't scored, and our AI doesn't read them. They go to the hiring team so they can learn more about your experience and qualifications.`,fi_label_summaryRowDei_one:`{{count}} Diversity question (optional)`,fi_label_summaryRowDei_other:`{{count}} Diversity questions (optional)`,fi_label_summaryRowDeiDescription:`A few questions at the end, after you've submitted. They aren't scored, they aren't shown to the hiring team, and they don't affect your application.`,fi_button_copyLink:`Copy link`,ci_composer_footer:`Your answers are confidential`,ci_edit_banner:`Editing your answer`,ci_video_retry_banner:`Retrying your video answer`,ci_rich_toolbar:`Lists`,ci_rich_bullet_list:`Bulleted list`,ci_rich_number_list:`Numbered list`,ci_composer_expand:`Expand the answer box`,ci_composer_collapse:`Shrink the answer box`,ci_button_send:`Send`,ci_input_label:`Your answer`,ci_options_group:`Answer options`,ci_label_selectAllThatApply:`Select all that apply`,ci_label_selectMax:`Select {{max}}`,ci_label_selectionCount:`{{selected}} of {{max}} selected`,ci_button_confirm:`Confirm`,ci_sender_agent:`Interviewer`,ci_sender_candidate:`You`,ci_opens_new_tab:`opens in a new tab`,ci_dropdown_search_label:`Search options`,fi_label_words_one:`{{count}} word`,fi_label_words_other:`{{count}} words`,fi_alt_shortResponse:`Your response is shorter than the required minimum {{minWordCount}} words`,fi_alt_goodResponse:`Good response length!`,fi_alt_maxWords:`You have reached the maximum words allowed for this question`,fi_error_notEnoughWords:`You have entered less than the recommended **{{minWordCount}} words**`,fi_error_notEnoughWordsMin:`Aim for **at least {{minWordCount}} words per answer** so we can accurately assess you, and give you meaningful feedback.`,fi_error_notEnoughWordsAim:`Aim for **{{minWordCount}} - {{recommendedWordCount}} words per answer** so we can accurately assess you, and give you meaningful feedback.`,fi_error_notEnoughWordsEdit:`You can edit your answers any time during the interview.`,fi_error_notEnoughWordsEditNow:`Do you want to edit your response now?`,fi_check_dontShow:`Don't show me this again`,ci_loading:`Loading your interview…`,ci_preparing:`Preparing your interview…`,ci_done_title:`That's everything.`,ci_done_subtitle:`Thanks for being generous with your answers, {{name}}.`,ci_done_subtitle_generic:`Thanks for being generous with your answers.`,ci_done_ack:`Got it`,ci_done_next_label:`What happens next`,ci_done_step1:`Your written answers are **scored on only what you said.**`,ci_done_step2:`As promised, we'll email you personalised feedback and tips to help you grow, whatever the outcome.`,ci_done_step3:`If it's a match, a member of the hiring team will reach out about next steps.`,ci_start_failed:`We could not load your interview. Please refresh the page to try again.`,fi_error_cohortClosedTitle:`Sorry, it's closed`,fi_error_cohortClosedMessage:`Unfortunately, this job position has been closed and is no longer receiving applications.`,ci_assessment_not_found_title:`We can't find this interview`,ci_assessment_not_found_message:`This link may be incorrect or no longer active. Please check the link in your invitation email.`,ci_phone_country_label:`Country code`,ci_phone_placeholder:`Enter your phone number`,ci_location_input_label:`Town or city`,ci_location_placeholder:`Start typing your town or city`,ci_location_suggestions_label:`Location suggestions`,ci_location_suggestions_found:`{{count}} locations found`,ci_pii_back:`Back`,ci_pii_review_title:`Review details`,ci_pii_label_fullName:`Name`,ci_pii_label_firstName:`First name`,ci_pii_label_lastName:`Last name`,ci_pii_label_email:`Email address`,ci_pii_label_location:`Location`,ci_pii_label_phone:`Phone number`,ci_pii_placeholder_fullName:`Enter your name`,ci_pii_placeholder_firstName:`Enter your first name`,ci_pii_placeholder_lastName:`Enter your last name`,ci_pii_row_name:`Name`,ci_pii_row_firstName:`First name`,ci_pii_row_lastName:`Last name`,ci_pii_row_email:`Email`,ci_pii_row_location:`Location`,ci_pii_row_phone:`Phone`,ci_pii_row_sms:`SMS updates`,ci_pii_sms_consented:`Consented`,ci_pii_sms_declined:`Declined`,ci_csat_intro:`Before you go — how was your experience with this interview today?`,ci_csat_title:`How was your experience?`,ci_csat_subtitle:`This won't affect your application. We share it with the hiring team so they can improve how they hire.`,ci_csat_scale_label:`Rate your experience from {{min}} to {{max}}`,ci_csat_low:`Poor`,ci_csat_high:`Excellent`,ci_csat_comment_label:`Anything you would like to add`,ci_csat_comment_placeholder:`Anything you'd like to add? (optional)`,ci_csat_submit:`Submit feedback`,ci_csat_answer_rating:`Rating: {{rating}}/{{max}}`,ci_csat_answer_comment:`Feedback: {{comment}}`,ci_dei_title:`Diversity & inclusion`,ci_dei_submit:`Continue`,ci_name_confirm_title:`Is this correct?`,ci_name_confirm_body:`We read your name as "{{suggested}}". Use this?`,ci_name_use_suggested:`Use "{{suggested}}"`,ci_name_use_original:`Keep what I typed`,ci_video_open_camera:`Turn on camera`,ci_video_re_record:`Re-record`,ci_video_submit:`Use this answer`,ci_video_keep:`Keep this answer`,ci_video_camera:`Camera`,ci_video_microphone:`Microphone`,ci_video_on:`On`,ci_video_off:`Off`,ci_video_finish_hint:`Tap to finish`,ci_video_camera_off:`Camera is off`,ci_video_recording_started:`Recording started`,ci_video_recording_stopped:`Recording stopped`,ci_video_seconds_remaining:`{{seconds}} seconds remaining`,ci_video_attempts:`{{current}}/{{max}} attempts`,ci_video_camera_error:`We could not access your camera. Please check permissions and try again.`,ci_video_preview:`Camera preview`,ci_video_retry_upload:`Retry upload`,ci_video_play:`Play video`,ci_video_answer:`Your video answer`,ci_video_embed_label:`Embedded video`,ci_access_title:`Verify your identity`,ci_access_description:`Please enter the email address you applied with to continue.`,fi_error_emailDoesNotMatch:`That email does not match our records. Please try again.`,fi_error_agcTitle:`Please answer in your own words`,fi_error_agcFirstMessage:`Your answer looks like it may be AI-generated. Please edit it to be your own words.`,fi_error_agcSecondMessage:`This is your final reminder — please make sure your answer is your own work.`,fi_agc_guidance_header:`Quick Note about AI Usage`,fi_agc_guidance_body:`Every response is checked for AI-generated content.
39
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yf(e,t){if(e){if(typeof e==`string`)return Xf(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Xf(e,t):void 0}}function Xf(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Zf(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,o,c,l=[],u=!0,d=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(l.push(r.value),l.length!==t);u=!0);}catch(e){d=!0,i=e}finally{try{if(!u&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(d)throw i}}return l}}function Qf(e){if(Array.isArray(e))return e}function $f(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ep(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,np(r.key),r)}}function tp(e,t,n){return t&&ep(e.prototype,t),n&&ep(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function np(e){var t=rp(e,`string`);return Kf(t)==`symbol`?t:t+``}function rp(e,t){if(Kf(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Kf(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ip(e,t,n){var r=n.getCountryCodesForCallingCode(e);if(r.length>1)return za(t,r,n.metadata)}var ap,op,sp=l((()=>{Ui(),Xo(),Zi(),vd(),Cf(),Gf(),Ua(),Ba(),vi(),ap=!1,op=function(){function e(t,n){$f(this,e),this.metadata=new Li(n);var r=qf(this.getCountryAndCallingCode(t),2),i=r[0],o=r[1];this.defaultCountry=i,this.defaultCallingCode=o,this.reset()}return tp(e,[{key:`getCountryAndCallingCode`,value:function(e){var t,n;return e&&(gi(e)?(t=e.defaultCountry,n=e.defaultCallingCode):t=e),t&&!this.metadata.hasCountry(t)&&(t=void 0),n&&ap&&this.metadata.isNonGeographicCallingCode(n)&&(t=`001`),[t,n]}},{key:`input`,value:function(e){var t=this.parser.input(e,this.state),n=t.digits;if(t.justLeadingPlus)this.formattedOutput=`+`;else if(n){this.determineTheCountryIfNeeded(),this.state.nationalSignificantNumber&&this.formatter.narrowDownMatchingFormats(this.state);var r;if(this.metadata.hasSelectedNumberingPlan()&&(r=this.formatter.format(n,this.state)),r===void 0&&this.parser.reExtractNationalSignificantNumber(this.state)){this.determineTheCountryIfNeeded();var i=this.state.getNationalDigits();i&&(r=this.formatter.format(i,this.state))}this.formattedOutput=r?this.getFullNumber(r):this.getNonFormattedNumber()}return this.formattedOutput}},{key:`reset`,value:function(){var e=this;return this.state=new _d({onCountryChange:function(t){e.country=t},onCallingCodeChange:function(t,n){e.metadata.selectNumberingPlan(n||t),e.formatter.reset(e.metadata.numberingPlan,e.state),e.parser.reset(e.metadata.numberingPlan)}}),this.formatter=new Sf({state:this.state,metadata:this.metadata}),this.parser=new Wf({defaultCountry:this.defaultCountry,defaultCallingCode:this.defaultCallingCode,metadata:this.metadata,state:this.state,onNationalSignificantNumberChange:function(){e.determineTheCountryIfNeeded(),e.formatter.reset(e.metadata.numberingPlan,e.state)}}),this.state.reset({country:this.defaultCountry,callingCode:this.defaultCallingCode}),this.formattedOutput=``,this}},{key:`isInternational`,value:function(){return this.state.international}},{key:`getCallingCode`,value:function(){if(this.isInternational())return this.state.callingCode}},{key:`getCountryCallingCode`,value:function(){return this.getCallingCode()}},{key:`getCountry`,value:function(){if(this.state.digits)return this._getCountry()}},{key:`_getCountry`,value:function(){var e=this.state.country;if(!(ap&&e===`001`))return e}},{key:`determineTheCountryIfNeeded`,value:function(){(!this.state.country||this.isCountryCallingCodeAmbiguous())&&this.determineTheCountry()}},{key:`getFullNumber`,value:function(e){var t=this;if(this.isInternational()){var n=function(e){return t.formatter.getInternationalPrefixBeforeCountryCallingCode(t.state,{spacing:!!e})+e},r=this.state.callingCode;return n(r?e?`${r} ${e}`:r:`${this.state.getDigitsWithoutInternationalPrefix()}`)}return e}},{key:`getNonFormattedNationalNumberWithPrefix`,value:function(){var e=this.state,t=e.nationalSignificantNumber,n=e.prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix,r=e.nationalPrefix,i=t,o=n||r;return o&&(i=o+i),i}},{key:`getNonFormattedNumber`,value:function(){var e=this.state.nationalSignificantNumberIsModified;return this.getFullNumber(e?this.state.getNationalDigits():this.getNonFormattedNationalNumberWithPrefix())}},{key:`getNonFormattedTemplate`,value:function(){var e=this.getNonFormattedNumber();if(e)return e.replace(/[\+\d]/g,`x`)}},{key:`isCountryCallingCodeAmbiguous`,value:function(){var e=this.state.callingCode,t=this.metadata.getCountryCodesForCallingCode(e);return t&&t.length>1}},{key:`determineTheCountry`,value:function(){var e=Va(this.isInternational()?this.state.callingCode:this.defaultCallingCode,{nationalNumber:this.state.nationalSignificantNumber,metadata:this.metadata});e!==this.state.country&&(this.state.setCountry(e),e&&this.metadata.selectNumberingPlan(e))}},{key:`getNumberValue`,value:function(){var e=this.state,t=e.digits,n=e.callingCode,r=e.country,i=e.nationalSignificantNumber;if(t){if(this.isInternational())return n?`+`+n+i:`+`+t;if(r||n)return`+`+(r?this.metadata.countryCallingCode():n)+i}}},{key:`getNumber`,value:function(){var e=this.state,t=e.nationalSignificantNumber,n=e.carrierCode,r=e.callingCode;if(t){var i=this._getCountry();if(!(!i&&!r)){if(i&&i===this.defaultCountry){var o=ip(this.metadata.numberingPlan.callingCode(),t,this.metadata);o&&(i=o)}var c=new Jo(i||r,t,this.metadata.metadata);return n&&(c.carrierCode=n),c}}}},{key:`isPossible`,value:function(){var e=this.getNumber();return e?e.isPossible():!1}},{key:`isValid`,value:function(){var e=this.getNumber();return e?e.isValid():!1}},{key:`validateLength`,value:function(){var e=this.state,t=e.digits,n=e.nationalSignificantNumber;if(!t)return`NOT_A_NUMBER`;if(!this.metadata.numberingPlan)return`INVALID_COUNTRY`;if(!n)return`TOO_SHORT`;var r=Yi(n,void 0,this.metadata);if(r!==`IS_POSSIBLE`)return r}},{key:`getNationalNumber`,value:function(){return this.state.nationalSignificantNumber}},{key:`getChars`,value:function(){return(this.state.international?`+`:``)+this.state.digits}},{key:`getTemplate`,value:function(){return this.formatter.getTemplate(this.state)||this.getNonFormattedTemplate()||``}}])}()}));function cp(e){return new Li(e).getCountries()}var lp=l((()=>{Ui()}));function up(e,t,n){if(t[e])return new Jo(e,t[e],n)}var dp=l((()=>{Xo()}));function fp(e,t,n){return n||(n=t,t=void 0),new op(t,n).input(e)}var pp=l((()=>{sp()})),mp=l((()=>{Xo(),ms(),Ec(),Ic(),Wc(),Qc(),ol(),Hu(),Ju(),nd(),ud(),Bu(),sp(),Cf(),lp(),Ui(),dp(),pp(),As(),ws(),ko()}));function hp(){return fi(Tc,arguments)}var gp=l((()=>{pi(),mp()}));function _p(){return fi(Fc,arguments)}var vp=l((()=>{pi(),mp()}));function yp(){return fi(Uc,arguments)}var bp=l((()=>{pi(),mp()}));function xp(){return fi(Zc,arguments)}var Sp=l((()=>{pi(),mp()}));function Cp(){return fi(al,arguments)}var wp=l((()=>{pi(),mp()}));function Tp(){return fi(Vu,arguments)}var Ep=l((()=>{pi(),mp()}));function Dp(){return fi(qu,arguments)}var Op=l((()=>{pi(),mp()}));function kp(){return fi(td,arguments)}var Ap=l((()=>{pi(),mp()}));function jp(){return fi(ld,arguments)}var Mp=l((()=>{pi(),mp()}));function Np(e,t){return zu.call(this,e,t,ui)}var Pp=l((()=>{di(),mp(),Np.prototype=Object.create(zu.prototype,{}),Np.prototype.constructor=Np}));function Fp(e){return op.call(this,e,ui)}var Ip=l((()=>{di(),mp(),Fp.prototype=Object.create(op.prototype,{}),Fp.prototype.constructor=Fp}));function Lp(){return fi(Mi,arguments)}var Rp=l((()=>{pi(),mp()}));function zp(){return fi(cp,arguments)}var Bp=l((()=>{pi(),mp()}));function Vp(){return fi(ji,arguments)}var Hp=l((()=>{pi(),mp()}));function Up(){return fi(Ai,arguments)}var Wp=l((()=>{pi(),mp()}));function Gp(){return Li.call(this,ui)}var Kp=l((()=>{di(),mp(),Gp.prototype=Object.create(Li.prototype,{}),Gp.prototype.constructor=Gp}));function qp(){return fi(up,arguments)}var Jp=l((()=>{pi(),mp()}));function Yp(){return fi(fp,arguments)}var eee=l((()=>{pi(),mp()}));function Xp(e){return Jo.call(this,e,ui)}var tee=l((()=>{di(),mp(),Xp.prototype=Jo.prototype,Xp.prototype.constructor=Xp})),Zp=d({AsYouType:()=>Fp,DIGIT_PLACEHOLDER:()=>`x`,Metadata:()=>Gp,ParseError:()=>ps,PhoneNumber:()=>Xp,PhoneNumberMatcher:()=>Np,default:()=>_p,findNumbers:()=>Tp,findPhoneNumbersInText:()=>kp,formatIncompletePhoneNumber:()=>Yp,formatRFC3966:()=>Oo,getCountries:()=>zp,getCountryCallingCode:()=>Vp,getExampleNumber:()=>qp,getExtPrefix:()=>Up,isPossiblePhoneNumber:()=>xp,isSupportedCountry:()=>Lp,isValidPhoneNumber:()=>yp,parseDigits:()=>Ss,parseIncompletePhoneNumber:()=>Os,parsePhoneNumber:()=>hp,parsePhoneNumberCharacter:()=>ks,parsePhoneNumberFromString:()=>_p,parsePhoneNumberWithError:()=>hp,parseRFC3966:()=>Do,searchNumbers:()=>Dp,searchPhoneNumbersInText:()=>jp,validatePhoneNumberLength:()=>Cp}),Qp=l((()=>{gp(),vp(),bp(),Sp(),wp(),Ep(),Op(),Ap(),Mp(),Pp(),Ip(),Rp(),Bp(),Hp(),Wp(),Kp(),Jp(),eee(),tee(),mp()})),$p={email:`fi_error_piiEmail`,fullName:`fi_error_piiFullName`,firstName:`fi_error_piiFirstName`,lastName:`fi_error_piiLastName`,phoneNumber:`fi_error_piiPhoneNumber`,location:`ci_error_piiLocation`},em={[xr.FULL_NAME]:100,[xr.FIRST_NAME]:50,[xr.LAST_NAME]:50},nee={[xr.FULL_NAME]:3,[xr.FIRST_NAME]:2,[xr.LAST_NAME]:2},ree={[xr.FULL_NAME]:$p.fullName,[xr.FIRST_NAME]:$p.firstName,[xr.LAST_NAME]:$p.lastName},iee={[xr.FULL_NAME]:`fullName`,[xr.FIRST_NAME]:`firstName`,[xr.LAST_NAME]:`lastName`},tm=e=>e.trim().split(/\s+/).filter(Boolean).length,aee=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,nm=e=>{let t=e.trim();return aee.test(t)?{ok:!0,text:t}:{ok:!1,errorKey:$p.email}},rm=(e,t)=>{let n=t.trim(),r=em[e],i=ree[e];if(r===void 0||i===void 0)return{ok:!0,text:n};let o=tm(n);return o>=1&&o<=r?{ok:!0,text:n}:{ok:!1,errorKey:i}},oee=(e,t)=>{let n=nee[e];return n!==void 0&&tm(t)>n},im=async(e,t)=>{var n;let{parsePhoneNumberFromString:r}=await Promise.resolve().then(()=>(Qp(),Zp)),i=r(e.trim(),t);return i!=null&&i.isValid()?{ok:!0,text:i.number}:{ok:!1,errorKey:$p.phoneNumber,possiblePhoneNumber:(n=i==null?void 0:i.isPossible())==null?!1:n}},am=e=>e!==void 0&&e in em,om=function(e){return e.SUBMITTED=`submitted`,e.INVALID=`invalid`,e.CONFIRM_NAME=`confirm-name`,e}({}),sm=e=>({outcome:{status:`invalid`,errorKey:e}}),cm=e=>{let t=nm(e);return t.ok?{submit:t.text}:sm(t.errorKey)},lm=async(e,t,n)=>{let r=await im(e,t);return r.ok?{submit:r.text}:(r.possiblePhoneNumber&&n(),sm(r.errorKey))},um=async(e,t,n)=>{if(!e)return sm($p.fullName);let r=rm(e,t);if(!r.ok)return sm(r.errorKey);let i=oee(e,r.text)?iee[e]:void 0;if(i){let e=await n(r.text,i);if(e&&e!==r.text)return{outcome:{status:`confirm-name`,suggested:e,original:r.text}}}return{submit:r.text}},dm=`csat-form`,fm=`csat-response`,pm=(e,t)=>({id:e,types:[],contents:[],component:t}),mm=e=>`${dm}-${e}`,hm=e=>`${fm}-${e}`,see=(e,t)=>({id:t,questionId:e,sender:_r.AGENT,status:$r.ANSWERED,types:[vr.FTQ],questionRole:Zr.CUSTOMER_SATISFACTION,data:{messageItems:[pm(e,wr.CUSTOMER_SATISFACTION_INTRO)]}}),gm=e=>({id:mm(e),questionId:e,sender:_r.CANDIDATE,status:$r.ANSWERING,types:[vr.FTQ],questionRole:Zr.CUSTOMER_SATISFACTION,data:{messageItems:[pm(e,wr.CUSTOMER_SATISFACTION_FORM)]}}),_m=({questionId:e,response:t,status:n})=>({id:hm(e),questionId:e,sender:_r.CANDIDATE,status:n,types:[vr.FTQ],questionRole:Zr.CUSTOMER_SATISFACTION,data:{messageItems:[],customerSatisfaction:t}}),cee=(e,t)=>{var n;let r=t==null||(n=t[0])==null?void 0:n.questionId;if(!r)return e;let i=e=>e.sender===_r.AGENT&&e.questionId===r;if(!e.some(i))return e;let o=mm(r),c=hm(r),l=e=>e.sender===_r.CANDIDATE&&e.questionId===r&&e.id!==o&&e.id!==c,u=e.filter(e=>!l(e)).map(e=>i(e)?{...e,questionRole:Zr.CUSTOMER_SATISFACTION,data:{...e.data,messageItems:[pm(e.questionId,wr.CUSTOMER_SATISFACTION_INTRO)]}}:e);return u.some(e=>e.id===o||e.id===c)?u:[...u,gm(r)]},lee=e=>({rating:e.rating,...e.comment.trim()?{comment:e.comment}:{}}),uee=(e,t)=>{if(Rr(e)){let{_id:n}=e.data,r=see(n,e.id);return t&&zr(t)?[r]:[r,gm(n)]}if(zr(e)){var n,r;let{_id:t,responses:i}=e.data,o=new Map(i.map(e=>[e.fieldType,e])),c=(n=o.get(Mr.RATING))==null?void 0:n.value,l=(r=o.get(Mr.COMMENT))==null?void 0:r.answer;return[_m({questionId:t,response:{...c?{rating:Number(c)}:{},...l&&l!==`SAPIA_SKIP_FEEDBACK`?{comment:l}:{}},status:$r.ANSWERED})]}},dee=e=>{let t=e.findIndex(Rr);if(t===-1)return;let n=e[t+1];if(!(n&&zr(n)))return e[t].data.fields},fee=(e,t,n,r)=>{let i=t[0].questionId,o=_m({questionId:i,response:lee(n),status:r}),c=mm(i);return{bubbles:e.map(e=>e.id===c?o:e),responseBubbleId:o.id}},pee=`dei-form`,mee=`dei-details`,vm=(e,t)=>({id:e,types:[],contents:[],component:t}),ym=e=>`${pee}-${e}`,bm=e=>`${mee}-${e}`,xm=e=>({id:ym(e),questionId:e,sender:_r.CANDIDATE,status:$r.ANSWERING,types:[vr.FTQ],questionRole:Zr.DEI,data:{messageItems:[vm(e,wr.DEMOGRAPHIC_FORM)]}}),Sm=({questionId:e,entries:t,status:n})=>({id:bm(e),questionId:e,sender:_r.CANDIDATE,status:n,types:[vr.FTQ],questionRole:Zr.DEI,data:{messageItems:[vm(e,wr.DEMOGRAPHIC_DETAILS)],demographicDetails:t}}),hee=(e,t)=>{var n;let r=t==null||(n=t[0])==null?void 0:n.questionId;if(!r)return e;let i=ym(r),o=bm(r),c=e=>e.questionId===r&&e.id!==i&&e.id!==o;if(!e.some(c))return e;let l=e.filter(e=>!c(e));return l.some(e=>e.id===i||e.id===o)?l:[...l,xm(r)]},Cm=(e,t)=>e.map(e=>{var n;return{field:e,options:((n=e.options)==null?[]:n).filter(n=>{var r;return(r=t[e.questionId])==null?void 0:r.includes(n.id)})}}).filter(({options:e})=>e.length>0),gee=(e,t)=>Cm(e,t).map(({field:e,options:t})=>({questionId:e.questionId,prompt:e.prompt,answer:t.map(e=>e.text).join(` | `)})),_ee=(e,t)=>{if(Br(e))return t&&Vr(t)?[]:[xm(e.data._id)];if(Vr(e)){let{_id:t,responses:n}=e.data;return[Sm({questionId:t,entries:n.filter(e=>e.answer).map(e=>({questionId:e.questionId,prompt:e.prompt,answer:e.answer})),status:$r.ANSWERED})]}},vee=e=>{let t=e.findIndex(Br);if(t===-1)return;let n=e[t+1];if(!(n&&Vr(n)))return e[t].data.fields},yee=(e,t,n,r)=>{let i=t[0].questionId,o=Sm({questionId:i,entries:gee(t,n),status:r}),c=ym(i);return{bubbles:e.map(e=>e.id===c?o:e),detailsBubbleId:o.id}},wm=`pii-details`,Tm=`pii-form`,Em=(e,t)=>({id:e,types:[],contents:[],component:t}),bee=(e,t)=>({id:t,questionId:e,sender:_r.AGENT,status:$r.ANSWERED,types:[vr.FTQ],questionRole:Zr.PII,data:{messageItems:[Em(e,wr.PII_FORM_INTRO)]}}),Dm=e=>({id:`${Tm}-${e}`,questionId:e,sender:_r.CANDIDATE,status:$r.ANSWERING,types:[vr.FTQ],questionRole:Zr.PII,data:{messageItems:[Em(e,wr.PII_FORM)]}}),xee=(e,t)=>{var n;let r=t==null||(n=t[0])==null?void 0:n.questionId;if(!r)return e;let i=e=>e.sender===_r.AGENT&&e.questionId===r;if(!e.some(i))return e;let o=`${Tm}-${r}`,c=`${wm}-${r}`,l=e=>e.sender===_r.CANDIDATE&&e.questionId===r&&e.id!==o&&e.id!==c,u=e.filter(e=>!l(e)).map(e=>i(e)?{...e,data:{...e.data,messageItems:[Em(e.questionId,wr.PII_FORM_INTRO)]}}:e);return u.some(e=>e.id===o||e.id===c)?u:[...u,Dm(r)]},Om=({questionId:e,entries:t,status:n})=>({id:`${wm}-${e}`,questionId:e,sender:_r.CANDIDATE,status:n,types:[vr.FTQ],questionRole:Zr.PII,data:{messageItems:[Em(e,wr.PII_DETAILS)],piiDetails:t}}),See=(e,t)=>{if(Ir(e)){let{_id:n}=e.data,r=bee(n,e.id);return t&&Lr(t)?[r]:[r,Dm(n)]}if(Lr(e)){let{_id:t,responses:n}=e.data;return[Om({questionId:t,entries:n.map(e=>{var t,n;return{questionId:e.questionId,piiType:e.piiType,text:(t=e.answer)==null?``:t,value:(n=e.value)==null?``:n}}),status:$r.ANSWERED})]}},Cee=e=>{let t=e.findIndex(Ir);if(t===-1)return;let n=e[t+1];if(!(n&&Lr(n)))return e[t].data.fields},wee=(e,t,n,r)=>{let i=t[0].questionId,o=new Map(t.map(e=>[e.questionId,e.piiType])),c=Om({questionId:i,entries:n.map(e=>{var t;return{questionId:e.questionId,piiType:(t=o.get(e.questionId))==null?null:t,text:e.text,value:e.value}}),status:r}),l=`${Tm}-${i}`;return{bubbles:e.map(e=>e.id===l?c:e),detailsBubbleId:c.id}},Tee=[vr.SLIDER,vr.MCQ,vr.MSQ,vr.VIDEO,vr.DROPDOWN,vr.BGQ,vr.BREAK],km=[vr.MCQ,vr.MSQ,vr.DROPDOWN,vr.BGQ,vr.BREAK],Eee=[vr.SLIDER,vr.MCQ,vr.MSQ,vr.DROPDOWN,vr.BGQ,vr.BREAK],Am=e=>{if(!e||!Array.isArray(e)||e.length===0)return;let t;return e.forEach(e=>{e.name===`PII_TYPE`&&(t=e.value)}),t},jm=e=>{if(!e||!Array.isArray(e)||e.length===0)return;let t;return e.forEach(e=>{e.name===`VIDEO_TYPE`&&(t=e.value)}),t},Dee=e=>Array.isArray(e)&&e.some(e=>(e==null?void 0:e.name)===`ALLOW_PASTE`&&(e==null?void 0:e.value)===`true`),Mm=e=>Array.isArray(e)&&e.some(e=>(e==null?void 0:e.name)===`PH_BUTTON_TYPE`&&(e==null?void 0:e.value)===`ph_sms_consent`),Oee=e=>Array.isArray(e)&&e.some(e=>(e==null?void 0:e.name)===`PH_BUTTON_TYPE`&&(e==null?void 0:e.value)===`ph_i_accept`),kee=e=>Array.isArray(e)&&e.some(e=>(e==null?void 0:e.name)===`DEMOGRAPHIC_TYPE`),Nm=(e,t)=>{var n;return((n=e==null?void 0:e.options)==null?[]:n).some(e=>{var n;return((n=e.triggers)==null?[]:n).some(e=>(e==null?void 0:e.action)===t)})},Pm=e=>Array.isArray(e==null?void 0:e.types)&&e.types.length>0&&!e.types.includes(vr.HINT),Aee=[Cr.RATING_CUSTOMER_SATISFACTION_QUESTION,Cr.RATING_CUSTOMER_SATISFACTION_ANSWER,Cr.FEEDBACK_CUSTOMER_SATISFACTION_QUESTION,Cr.FEEDBACK_CUSTOMER_SATISFACTION_ANSWER],jee=[Cr.SUBMIT_QUESTION,Cr.SUBMIT_ANSWER],Mee=[Cr.SMS_CONSENT_QUESTION,Cr.SMS_CONSENT_ANSWER],Nee=[Cr.TERMS_CONSENT_QUESTION,Cr.TERMS_CONSENT_ANSWER],Fm=(e,t)=>{var n,r,i;let o=t==null?``:t;return(e==null?void 0:e.kind)===Er.HINT||!Pm(e)?Zr.HINT:!(e==null||(n=e.types)==null)&&n.includes(vr.BREAK)||Nm(e,`continue_dialogue`)?Zr.BREAK:Aee.includes(o)||!(e==null||(r=e.usageWhitelist)==null)&&r.includes(br.CUSTOMER_SATISFACTION)?Zr.CUSTOMER_SATISFACTION:jee.includes(o)||(e==null?void 0:e.masterId)===`ph_submit_assessment`||Nm(e,`submit_assessment`)?Zr.SUBMIT:Mee.includes(o)||Mm(e==null?void 0:e.tags)?Zr.SMS_CONSENT:Nee.includes(o)||(e==null?void 0:e.masterId)===`ph_i_accept`||Oee(e==null?void 0:e.tags)||Nm(e,`continue_assessment_with_consent`)?Zr.TERMS_CONSENT:kee(e==null?void 0:e.tags)?Zr.DEI:!(e==null||(i=e.usageWhitelist)==null)&&i.includes(br.PII)?Zr.PII:Zr.NORMAL},Im=e=>{var t,n,r,i,o,c,l;let u=e==null?void 0:e.data,d=(t=u==null||(n=u.question)==null?void 0:n.types)==null?[]:t,f,p;if(d.some(e=>Tee.includes(e)))if(p={text:u==null?void 0:u.text,value:u==null?void 0:u.value,...u!=null&&u.selections?{selections:u.selections}:{}},d.some(e=>km.includes(e))){var m,h;f=[{id:u==null?void 0:u._id,types:[yr.TEXT],contents:(m=u==null||(h=u.question)==null?void 0:h.options)==null?[]:m}]}else{var g,_;f=[{id:u==null?void 0:u._id,types:[yr.TEXT],contents:[{id:u==null?void 0:u._id,text:u==null||(g=u.question)==null||(g=g.contents)==null||(g=g[0])==null?void 0:g.value,value:u==null||(_=u.question)==null||(_=_.contents)==null||(_=_[0])==null?void 0:_.value}]}]}else f=[{id:u==null?void 0:u._id,types:[yr.TEXT],contents:[{id:u==null?void 0:u._id,text:u==null?void 0:u.text,value:u==null?void 0:u.value}]}];let v={id:e==null?void 0:e.id,questionId:u==null||(r=u.question)==null?void 0:r._id,sender:e==null?void 0:e.sender,messageIdentifier:e==null?void 0:e.messageIdentifier,status:$r.ANSWERED,types:d,usageWhitelist:u==null||(i=u.question)==null?void 0:i.usageWhitelist,masterId:u==null||(o=u.question)==null?void 0:o.masterId,questionRole:Fm(u==null?void 0:u.question,e==null?void 0:e.messageIdentifier),data:{messageItems:f,rules:u==null||(c=u.question)==null?void 0:c.rules,tags:u==null||(l=u.question)==null?void 0:l.tags}};return p&&(v.data.answer=p),v},Lm=(e,t)=>{var n,r;let i=e==null?void 0:e.data;return{id:e==null?void 0:e.id,questionId:i==null?void 0:i._id,sender:e==null?void 0:e.sender,messageIdentifier:e==null?void 0:e.messageIdentifier,status:t||!(i==null||(n=i.types)==null)&&n.includes(vr.HINT)?$r.ANSWERED:$r.ANSWERING,types:i==null?void 0:i.types,usageWhitelist:i==null?void 0:i.usageWhitelist,messageKind:i==null?void 0:i.kind,questionRole:Fm(i,e==null?void 0:e.messageIdentifier),data:{rules:i==null?void 0:i.rules,tags:i==null?void 0:i.tags,messageItems:((r=i==null?void 0:i.contents)==null?[]:r).map(e=>({id:e==null?void 0:e.value,types:e==null?void 0:e.types,component:e==null?void 0:e.component,contents:[{value:e==null?void 0:e.value,text:e==null?void 0:e.value,id:e==null?void 0:e.value}]}))},masterId:i==null?void 0:i.masterId,piiQuestionType:Am(i==null?void 0:i.tags),videoQuestionType:jm(i==null?void 0:i.tags)}},Pee=(e,t)=>{if((e==null?void 0:e.sender)===_r.CANDIDATE)return Im(e);if((e==null?void 0:e.sender)===_r.AGENT)return Lm(e,t)},Rm=e=>{var t,n;let r=e==null?void 0:e.data;if(!(r==null||(t=r.types)==null)&&t.some(e=>km.includes(e))){var i,o;return{id:`${e.id}-candidate`,questionId:r==null?void 0:r._id,sender:_r.CANDIDATE,messageIdentifier:e.messageIdentifier,status:$r.ANSWERING,types:r==null?void 0:r.types,usageWhitelist:r==null?void 0:r.usageWhitelist,masterId:r==null?void 0:r.masterId,questionRole:Fm(r,e.messageIdentifier),data:{messageItems:[{id:r==null||(i=r.contents)==null||(i=i[0])==null?void 0:i.value,types:[yr.TEXT],contents:(o=r==null?void 0:r.options)==null?[]:o}],rules:r==null?void 0:r.rules,tags:r==null?void 0:r.tags,answer:null}}}if(!(r==null||(n=r.types)==null)&&n.includes(vr.SLIDER)){var c;return{id:`${e.id}-candidate`,questionId:r==null?void 0:r._id,masterId:r==null?void 0:r.masterId,sender:_r.CANDIDATE,messageIdentifier:e.messageIdentifier,status:$r.ANSWERING,types:r==null?void 0:r.types,usageWhitelist:r==null?void 0:r.usageWhitelist,questionRole:Fm(r,e.messageIdentifier),data:{messageItems:((c=r==null?void 0:r.contents)==null?[]:c).map(e=>({id:e.value,types:e==null?void 0:e.types,contents:[{value:e==null?void 0:e.value,text:e==null?void 0:e.value,id:e.value}]}))}}}},Fee=e=>{let t=[];return e.forEach((n,r)=>{var i,o;let c=(i=(o=See(n,e[r+1]))==null?uee(n,e[r+1]):o)==null?_ee(n,e[r+1]):i;if(c){t.push(...c);return}let l=Pee(n,r<e.length-1);if(l&&t.push(l),r===e.length-1&&(n==null?void 0:n.sender)===_r.AGENT){var u;let e=n==null?void 0:n.data;if(!(e==null||(u=e.types)==null)&&u.some(e=>Eee.includes(e))){let e=Rm(n);e&&t.push(e)}}}),t},Iee=(e,t,n)=>e.map(e=>e.id===t?{...e,status:n}:e),Lee=(e,t,n)=>t?e.map(e=>e.id===t?n:e):[...e,n],Ree=(e,t,n)=>{let r=e.find(e=>e.id===t),i=n(r);return r?e.map(e=>e.id===t?i:e):[...e,i]},zee=(e,t)=>e.filter(e=>e.id!==t),Bee=(e,t,n)=>{let r=n?[t,n]:[t],i=e.findIndex(e=>e.id===t.id);if(i===-1)return[...e,...r];let o=[...e];return o.splice(i,1,...r),o},Vee=(e,t)=>e.find(e=>e.sender===_r.CANDIDATE&&e.questionId===t&&(e.status===$r.ANSWERING||e.status===$r.FAILED||e.status===$r.EDITING)),zm=e=>e.filter(e=>e.sender===_r.AGENT).at(-1),Bm=(e,t)=>e.find(e=>e.sender===_r.AGENT&&e.questionId===t),Vm=(e,t)=>e.map(e=>t!==void 0&&e.sender===_r.CANDIDATE&&e.questionId===t?{...e,status:$r.EDITING}:e.status===$r.EDITING?{...e,status:$r.ANSWERED}:e),Hee=[`en-GB`,`en-US`,`fr`,`es`,`de`,`fi`,`da`,`nl`,`it`,`sv`,`nb`,`pl`,`ar`],Hm=`en-US`,Uee=[`ar`],Um=e=>Hee.includes(e),Wee=e=>e?e.startsWith(`en`)&&!Um(e)?`en-US`:Um(e)?e:Hm:Hm,Gee=(e,t)=>e&&Um(e)?e:Wee(t),Kee=e=>Uee.includes(e.split(`-`)[0]),qee=e=>Kee(e)?`rtl`:`ltr`,Wm=`sapia-chatbot:v1`,Gm=()=>{try{return typeof window<`u`?window.localStorage:void 0}catch{return}},Km=()=>{let e=Gm();if(!e)return{};try{let t=e.getItem(Wm);return t?JSON.parse(t):{}}catch{return{}}},qm=e=>{let t=Gm();if(t)try{t.setItem(Wm,JSON.stringify(e))}catch{}},Jee=e=>{var t;return(t=Km().fiTokens)==null?void 0:t[e]},Yee=(e,t)=>{let n=Km();qm({...n,fiTokens:{...n.fiTokens,[e]:t}})},Jm=e=>{var t;let n=Km();if(!((t=n.fiTokens)!=null&&t[e]))return;let r={...n.fiTokens};delete r[e],qm({...n,fiTokens:r})},Xee=e=>{var t;return((t=Km().skipShortAnswerWarning)==null?void 0:t[e])===!0},Zee=(e,t)=>{let n=Km();qm({...n,skipShortAnswerWarning:{...n.skipShortAnswerWarning,[e]:t}})},Qee=(e,t)=>{var n;let r=(n=Km().answerDrafts)==null?void 0:n[e];return(r==null?void 0:r.questionId)===t?r.text:void 0},Ym=(e,t,n)=>{let r=Km();qm({...r,answerDrafts:{...r.answerDrafts,[e]:{questionId:t,text:n}}})},Xm=e=>{var t;let n=Km();if(!((t=n.answerDrafts)!=null&&t[e]))return;let r={...n.answerDrafts};delete r[e],qm({...n,answerDrafts:r})},$ee=(e,t)=>{var n,r;return(n=(r=Km().videoTakes)==null||(r=r[e])==null?void 0:r[t])==null?0:n},ete=(e,t)=>{var n,r,i;let o=Km(),c=((n=(r=o.videoTakes)==null||(r=r[e])==null?void 0:r[t])==null?0:n)+1;return qm({...o,videoTakes:{...o.videoTakes,[e]:{...(i=o.videoTakes)==null?void 0:i[e],[t]:c}}}),c},Zm=function(e){return e.IDLE=`idle`,e.VERIFYING=`verifying`,e.ACCESS_REQUIRED=`access-required`,e.STARTING=`starting`,e.WELCOME=`welcome`,e.ACTIVE=`active`,e.COMPLETING=`completing`,e.ENDED=`ended`,e.FAILED=`failed`,e.COHORT_CLOSED=`cohort-closed`,e.NOT_FOUND=`not-found`,e.TERMINAL_MESSAGE=`terminal-message`,e}({}),tte={phase:`idle`,bubbles:[],typing:!1,sendingAnswer:!1,numOfNormalQuestion:0,numOfNormalAnswer:0,featureFlags:{}},nte=()=>E(()=>({...tte})),Qm=`FI_START_ASSESSMENT_FAILED`,rte=`FI_ASSESSMENT_NOT_FOUND`,ite=`FI_LOAD_NEXT_FAILED`,ate=`FI_EXTRACT_HUMAN_NAME_FAILED`,ote=`FI_EDIT_ANSWER_FAILED`,ste=`FI_SUBMIT_VIDEO_ANSWER_FAILED`,cte=`FI_GET_TRANSLATION_FAILED`,lte=`FI_VERIFY_ACCESS_FAILED`,ute=`FI_DETECT_AGC_FAILED`,dte=`FI_UNAUTHENTICATED`,fte=`INVALID_PHONE_NUMBER`,pte=`INVALID_PASTE_ANSWER_ACTION`,mte=`INVALID_REDIRECT_URL`,$m=e=>e instanceof Error?e.message:String(e),eh=(e,t,n,r=!1)=>{var i,o;return{id:e,questionId:(i=n==null?void 0:n._id)==null?e:i,sender:_r.AGENT,status:$r.ANSWERING,types:(o=n==null?void 0:n.types)==null?[]:o,usageWhitelist:n==null?void 0:n.usageWhitelist,masterId:n==null?void 0:n.masterId,messageKind:n==null?void 0:n.kind,questionRole:Fm(n),piiQuestionType:Am(n==null?void 0:n.tags),videoQuestionType:jm(n==null?void 0:n.tags),data:{rules:n==null?void 0:n.rules,tags:n==null?void 0:n.tags,messageItems:t.map((t,i)=>{var o,c,l,u;let d=r?n==null||(o=n.contents)==null?void 0:o[i]:void 0,f=`${e}-${i}`;return{id:f,types:(c=d==null?void 0:d.types)==null?[yr.TEXT]:c,component:(l=d==null?void 0:d.component)==null?n==null||(u=n.contents)==null||(u=u[i])==null?void 0:u.component:l,contents:[{id:f,value:t,text:t}]}})}}},hte=(e,t)=>t?(e.messageKind=t.kind,e.data.messageItems.forEach((e,n)=>{var r;e.component=(r=t.contents)==null||(r=r[n])==null?void 0:r.component}),e):e,th=e=>({text:e.text,value:e.value,...e.triggers?{triggers:e.triggers}:{},...e.style?{style:e.style}:{}}),nh=e=>({text:e.map(e=>e.text).join(` | `),value:e.map(e=>e.value).join(` | `),selections:e.map(({id:e,value:t,text:n})=>({id:e,value:t,text:n}))}),gte=function(e){return e.ALL_THAT_APPLY=`ALL_THAT_APPLY`,e.UP_TO_MAX=`UP_TO_MAX`,e}({}),_te=1,rh=(e,t)=>{var n;let r=e==null||(n=e.find(e=>e.name===t))==null?void 0:n.value;if(r===void 0)return;let i=typeof r==`number`?r:Number(r);return Number.isFinite(i)&&i>0?i:void 0},ih=e=>{var t;return{min:(t=rh(e,gr.MIN_SELECTIONS))==null?1:t,max:rh(e,gr.MAX_SELECTIONS)}},vte=e=>{var t;return((t=e.types)==null?[]:t).includes(vr.MSQ)},ah=e=>{var t;return oh((t=e.types)==null?[]:t,e.data.rules)},oh=(e,t)=>e.includes(vr.MSQ)&&ih(t).max!==_te,sh=(e,t)=>e.max===void 0||e.max>=t?`ALL_THAT_APPLY`:`UP_TO_MAX`,ch=e=>new Promise(t=>setTimeout(t,e)),lh=8,yte=(e,t)=>{let n=/^\s*\S+/.exec(e.slice(t));if(!n)return t;let r=t+n[0].length;return r<e.length?r:t},bte=class{constructor(e,t,n){this.revealMs=e,this.nextSyntheticId=t,this.paint=n,this.received=``,this.revealed=0,this.chunks=[],this.metaById=new Map,this.networkDone=!1,this.placed=!1,this.live=t()}get liveId(){return this.live}get baseId(){return this.currentBaseId}metaFor(e){return this.metaById.get(e)}onMeta(e,t){this.metaById.set(t,e),(this.currentBaseId===void 0||this.currentBaseId===t)&&(this.meta=e,this.placed&&this.writeLive())}onDelta(e,t){var n,r;let[i,o]=t.split(`:`);this.currentBaseId!==void 0&&i!==this.currentBaseId&&this.commit(this.currentBaseId),this.currentBaseId=i,this.live=i,this.meta=(n=this.metaById.get(i))==null?this.meta:n;let c=Number(o),l=Number.isInteger(c)&&c>=0?c:0;this.chunks[l]=((r=this.chunks[l])==null?``:r)+e,this.received=this.chunks.join(``)}commitCurrent(){this.currentBaseId&&this.commit(this.currentBaseId)}finish(){this.networkDone=!0}async run(){if(this.revealMs===void 0){for(;!this.networkDone;)await ch(lh);if(this.received.length===0)return;this.revealed=this.received.length,this.writeLive();return}let e=0;for(;this.revealed<this.received.length||!this.networkDone;){if(this.revealed>=this.received.length){await ch(lh);continue}let t=this.revealed,n=this.revealMs===0?this.received.length:yte(this.received,this.revealed);if(n===this.revealed){if(!this.networkDone&&e<120){e+=lh,await ch(lh);continue}this.revealed=this.received.length}else this.revealed=n;e=0,this.writeLive(),this.revealMs>0&&await ch(this.revealMs*(this.revealed-t))}}revealedTexts(){let e=[],t=this.revealed;for(let r=0;r<this.chunks.length;r++){var n;let i=(n=this.chunks[r])==null?``:n;e.push(i.slice(0,t)),t=Math.max(0,t-i.length)}return e.filter(e=>e.length>0)}writeLive(){this.paint.live(eh(this.live,this.revealedTexts(),this.meta),this.live,this.placed),this.placed=!0}commit(e){var t;this.revealed=this.received.length;let n=eh(e,this.chunks.filter(e=>e.length>0),this.metaById.get(e),!0);n.status=$r.ANSWERED,(t=n.types)!=null&&t.length||(n.types=[vr.HINT]),n.questionRole=Zr.HINT,this.paint.commit(n,this.live,this.placed),this.live=this.nextSyntheticId(),this.received=``,this.revealed=0,this.chunks=[],this.placed=!1,this.meta=void 0}},xte=`video-answer`,Ste=`optimistic-answer`,Cte=`unknown`,wte=`AbortError`,Tte=()=>typeof navigator<`u`?navigator.userAgent:Cte,uh=e=>e===Sr.FI_ASSESSMENT_ENDED,Ete=e=>e===Sr.FI_ASSESSMENT_DUPLICATED,Dte=class{constructor(e){var t,n,r,i,o;this.streamSeq=0,this.sessionExpiring=!1,this.welcomeChatLogs=[],this.client=e.client,this.store=e.store,this.emitter=e.emitter,this.assessmentId=e.assessmentId,this.userAgent=(t=e.userAgent)==null?Tte():t,this.language=(n=e.language)==null?Hm:n,this.welcomeGate=(r=e.welcomeGate)==null?!1:r,this.streamRevealMs=(i=e.streamRevealMs)==null?15:i,this.streamText=(o=e.streamText)==null?!1:o,this.store.setState({language:this.language}),this.client.setOnUnauthorized(e=>void this.expireSession(e)),this.client.setOnLapsedFiToken(()=>this.resolveLapsedFiToken())}async loadTranslations(){try{let e=await this.client.getTranslation(this.language);this.store.setState({translations:e})}catch(e){this.emitter.emit(S.ERROR,{type:cte,message:$m(e)})}}async loadFeatureFlags(){try{let e=await this.client.resolveFeatureFlags(this.assessmentId);this.store.setState({featureFlags:e})}catch{}}async begin(){this.store.setState({phase:Zm.VERIFYING});let e=Jee(this.assessmentId);e&&!pr(e)?Jm(this.assessmentId):this.client.setFiToken(e);let t;try{t=await this.client.getAccessManagement(this.assessmentId)}catch(e){if(lr(e)){this.store.setState({phase:Zm.NOT_FOUND}),this.emitter.emit(S.ERROR,{type:rte,message:$m(e)});return}await this.start();return}if(!t.shouldAuthenticate){await this.start();return}if(this.client.getFiToken()){await this.start();return}t.language&&t.language!==this.language&&(this.language=t.language,this.store.setState({language:t.language}),await this.loadTranslations()),this.store.setState({phase:Zm.ACCESS_REQUIRED,emailHint:t.emailHint})}async verifyAccessEmail(e){let t=e.trim();if(!nm(t).ok){this.store.setState({accessEmailMismatch:!0});return}this.store.setState({verifyingAccess:!0,accessEmailMismatch:!1});try{(await this.client.verifyAccess(this.assessmentId,t)).allowToAccess?(this.persistFiToken(),this.store.setState({verifyingAccess:!1}),await this.start()):this.store.setState({verifyingAccess:!1,accessEmailMismatch:!0})}catch(e){if(this.store.setState({verifyingAccess:!1}),cr(e))return;this.emitter.emit(S.ERROR,{type:lte,message:$m(e)})}}cacheUnsentAnswer(e){var t;if(!e||Array.isArray(e))return;let n=(t=e.answer)==null?void 0:t.text;n&&Ym(this.assessmentId,e.questionId,n)}persistFiToken(){let e=this.client.getFiToken();e&&Yee(this.assessmentId,e)}async expireSession(e,t){if(!this.sessionExpiring){this.sessionExpiring=!0,e&&this.emitter.emit(S.ERROR,{type:dte,message:$m(e)});try{Jm(this.assessmentId),this.client.setFiToken(void 0);let e=t==null?await this.client.getAccessManagement(this.assessmentId).catch(()=>void 0):t;this.store.setState({phase:Zm.ACCESS_REQUIRED,emailHint:e==null?void 0:e.emailHint,accessEmailMismatch:!1})}finally{this.sessionExpiring=!1}}}resolveLapsedFiToken(){return this.lapseResolution||(this.lapseResolution=(async()=>{try{let e=await this.client.getAccessManagement(this.assessmentId).catch(()=>void 0);return e!=null&&e.shouldAuthenticate?(this.expireSession(void 0,e),!0):(Jm(this.assessmentId),this.client.setFiToken(void 0),!1)}finally{this.lapseResolution=void 0}})()),this.lapseResolution}checkSessionExpiry(){this.client.hasLapsedFiToken()&&this.resolveLapsedFiToken()}async start(){this.store.setState({phase:Zm.STARTING}),this.loadTranslations(),this.loadFeatureFlags();try{var e;let t=await this.client.startAts(this.assessmentId);if(this.persistFiToken(),t.isCohortClosed){this.store.setState({phase:Zm.COHORT_CLOSED,branding:t.branding,jobTitle:t.jobTitle,customerName:t.customerName});return}let n=(e=t.chatLogs)==null?[]:e,r=Fee(n),i=uh(t.assessmentStatus),o=this.welcomeGate&&!i&&!n.some(e=>e.sender===_r.CANDIDATE);if(this.store.setState({phase:i?Zm.ENDED:Zm.ACTIVE,assessmentStatus:t.assessmentStatus,bubbles:r,branding:t.branding,candidateName:t.candidateFirstName,jobTitle:t.jobTitle,customerName:t.customerName,numOfNormalQuestion:t.numOfNormalQuestion,numOfNormalAnswer:t.numOfNormalAnswer,candidateCountryCode:t.candidateCountryCode,agcAttempt:t.agcDetectionAttempt,allowNextAgcDetection:t.allowNextAgcDetection,termsAccepted:t.isTermsAndConditionsAccepted,assessmentSummary:t.summary,assessmentLink:t.assessmentLink,piiForm:Cee(n),csatForm:dee(n),deiForm:vee(n)}),this.emitter.emit(S.ASSESSMENT_STARTED,{assessmentId:this.assessmentId}),i){this.emitter.emit(S.ASSESSMENT_ENDED,{assessmentId:this.assessmentId,justCompleted:!1});return}if(this.handleTerminalSignals(t))return;if(o){this.welcomeChatLogs=n,this.store.setState({phase:Zm.WELCOME});return}await this.firstLoad(n)}catch(e){if(cr(e))return;this.store.setState({phase:Zm.FAILED,lastError:{type:Qm,message:$m(e)}}),this.emitter.emit(S.ERROR,{type:Qm,message:$m(e)})}}async confirmWelcome(){this.store.getState().phase===Zm.WELCOME&&(this.store.setState({phase:Zm.ACTIVE}),await this.firstLoad(this.welcomeChatLogs))}acknowledgeCompletion(){this.store.getState().phase===Zm.COMPLETING&&this.store.setState({phase:Zm.ENDED})}async firstLoad(e){var t;if(e.length===0){await this.loadNext();return}let n=this.store.getState().bubbles,r=n[n.length-1];!(r==null||(t=r.types)==null)&&t.includes(vr.HINT)&&await this.loadNext({userAgent:this.userAgent,questionId:r.questionId})}async submitTextAnswer(e){await this.submitFreeText(e)}async submitEmailAnswer(e){return this.submitResolved(cm(e))}async submitPhoneAnswer(e,t){return this.submitResolved(await lm(e,t,()=>this.emitter.emit(S.LOG,{type:fte,message:`Invalid phone number for ${t}: ${e}`})))}async submitNameAnswer(e){let t=this.currentPiiType(),n=await um(t,e,(e,t)=>this.extractName(e,t));return`submit`in n&&this.rememberCandidateName(t,n.submit),this.submitResolved(n)}async extractName(e,t){try{return(await this.client.extractHumanName(this.assessmentId,{userText:e,extractType:t}))[t]}catch(e){cr(e)||this.emitter.emit(S.ERROR,{type:ate,message:$m(e)});return}}async submitResolved(e){return`outcome`in e?e.outcome:(await this.submitFreeText(e.submit),{status:om.SUBMITTED})}async submitNameConfirmed(e){this.rememberCandidateName(this.currentPiiType(),e),await this.submitFreeText(e)}rememberCandidateName(e,t){(e===xr.FIRST_NAME||e===xr.FULL_NAME&&!this.store.getState().candidateName)&&this.store.setState({candidateName:t})}async submitLocationAnswer(e){let t=this.currentEditableQuestionId();!t||this.store.getState().sendingAnswer||await this.dispatchFreshOrEdit(t,{text:e.address,value:JSON.stringify(e)})}async submitPiiForm(e){let t=this.store.getState().piiForm;if(!(t!=null&&t.length)||e.length===0||this.store.getState().sendingAnswer)return;let n=e.map(e=>({userAgent:this.userAgent,questionId:e.questionId,answer:{text:e.text,value:e.value}}));e.forEach(e=>{var n;return this.rememberCandidateName((n=t.find(t=>t.questionId===e.questionId))==null?void 0:n.piiType,e.text)}),this.store.setState({piiFormAnswers:e}),this.replacePiiFormWithDetails(t,e,$r.PENDING),await this.loadNext(n),this.lastFailedInput||this.store.setState({piiForm:void 0})}replacePiiFormWithDetails(e,t,n){this.store.setState(r=>{let{bubbles:i,detailsBubbleId:o}=wee(r.bubbles,e,t,n);return this.pendingBubbleId=o,{bubbles:i}})}async submitCustomerSatisfactionForm(e){let t=this.store.getState().csatForm;if(!(t!=null&&t.length)||this.store.getState().sendingAnswer)return;let n=t.map(t=>{let n=t.fieldType===Mr.RATING?String(e.rating):e.comment.trim()?e.comment:li;return{userAgent:this.userAgent,questionId:t.questionId,answer:{text:n,value:n}}});this.store.setState(n=>{let{bubbles:r,responseBubbleId:i}=fee(n.bubbles,t,e,$r.PENDING);return this.pendingBubbleId=i,{bubbles:r}}),await this.loadNext(n),this.lastFailedInput||this.store.setState({csatForm:void 0})}async submitDemographicForm(e){let t=this.store.getState().deiForm;if(!(t!=null&&t.length)||this.store.getState().sendingAnswer)return;let n=Cm(t,e);if(n.length!==t.length)return;let r=n.map(({field:e,options:t})=>({userAgent:this.userAgent,questionId:e.questionId,answer:e.questionTypes.includes(vr.MSQ)?nh(t):th(t[0])}));this.store.setState(n=>{let{bubbles:r,detailsBubbleId:i}=yee(n.bubbles,t,e,$r.PENDING);return this.pendingBubbleId=i,{bubbles:r}}),await this.loadNext(r),this.lastFailedInput||this.store.setState({deiForm:void 0})}enterEditMode(e){var t,n;if(this.store.getState().sendingAnswer)return;let r=(t=(n=this.store.getState().bubbles.find(t=>t.sender===_r.CANDIDATE&&t.questionId===e))==null||(n=n.data.answer)==null?void 0:n.selections)==null?[]:t;this.store.setState(t=>({editingQuestionId:e,multiSelectDraft:r.length>0?{questionId:e,optionIds:r.map(e=>e.id)}:void 0,bubbles:Vm(t.bubbles,e)}))}cancelEditMode(){this.store.setState(e=>({editingQuestionId:void 0,multiSelectDraft:void 0,bubbles:Vm(e.bubbles)}))}async submitVideoAnswer(e,t){var n;let r=this.currentEditableQuestionId();if(!r||this.store.getState().sendingAnswer)return;let i=this.store.getState().editingQuestionId===r?this.candidateBubbleFor(r):void 0,o=(n=i==null?void 0:i.id)==null?`${xte}-${r}`:n;i||(this.lastVideoAnswer={questionId:r,blob:e,extension:t}),this.upsertVideoBubble(o,r,{status:$r.PENDING,uploadProgress:0,videoBlob:e,videoExtension:t}),this.store.setState({sendingAnswer:!0});try{let{url:n,videoFileName:c}=await this.client.getVideoUploadUrl(this.assessmentId,r,t);await this.client.uploadVideo(n,e,t,n=>{this.upsertVideoBubble(o,r,{status:$r.PENDING,uploadProgress:n,videoBlob:e,videoExtension:t})});let l={text:c,value:c};this.upsertVideoBubble(o,r,{status:$r.PENDING,uploadProgress:void 0,videoBlob:e,videoExtension:t}),i?await this.editExistingAnswer(r,l,{videoBlob:e,videoExtension:t}):(this.pendingBubbleId=o,await this.loadNext({userAgent:this.userAgent,questionId:r,answer:l})),this.lastVideoAnswer=void 0}catch(n){if(i?this.store.setState(e=>({sendingAnswer:!1,editFailedQuestionId:cr(n)?void 0:r,bubbles:e.bubbles.map(e=>e.id===o?{...i,status:$r.EDITING}:e)})):(this.upsertVideoBubble(o,r,{status:$r.FAILED,videoBlob:e,videoExtension:t}),this.store.setState({sendingAnswer:!1})),cr(n))return;this.emitter.emit(S.ERROR,{type:ste,message:$m(n)})}}async retryVideoAnswer(){if(!this.lastVideoAnswer)return;let{blob:e,extension:t}=this.lastVideoAnswer;await this.submitVideoAnswer(e,t)}async getVideoPlaybackUrl(e,t){return(await this.client.getVideoAccessUrl(this.assessmentId,e,t)).url}upsertVideoBubble(e,t,n){this.store.setState(r=>({bubbles:Ree(r.bubbles,e,r=>({id:e,questionId:t,sender:_r.CANDIDATE,status:$r.PENDING,types:[vr.VIDEO],questionRole:this.questionRoleFor(t),data:{messageItems:[]},...r,...n}))}))}candidateBubbleFor(e){return this.store.getState().bubbles.find(t=>t.sender===_r.CANDIDATE&&t.questionId===e)}async submitFreeText(e){let t=this.currentEditableQuestionId();!t||this.store.getState().sendingAnswer||await this.dispatchFreshOrEdit(t,{text:e,value:e})}async dispatchFreshOrEdit(e,t){if(this.store.getState().editingQuestionId===e){await this.editExistingAnswer(e,t);return}let n={userAgent:this.userAgent,questionId:e,answer:t};this.appendOptimisticCandidateBubble(n),await this.loadNext(n)}async editExistingAnswer(e,t,n){this.store.setState(n=>({sendingAnswer:!0,editFailedQuestionId:void 0,bubbles:n.bubbles.map(n=>n.sender===_r.CANDIDATE&&n.questionId===e?{...n,status:$r.PENDING,data:{...n.data,answer:t}}:n)}));try{let r=Im((await this.client.editAnswer(this.assessmentId,{questionId:e,answer:t})).updatedCandidateResponse);this.store.setState(t=>({sendingAnswer:!1,editingQuestionId:void 0,multiSelectDraft:void 0,bubbles:t.bubbles.map(t=>t.sender===_r.CANDIDATE&&t.questionId===e?{...r,...n}:t)})),this.emitter.emit(S.ANSWER_EDITED,{questionId:e})}catch(t){let n=cr(t);if(this.store.setState(t=>({sendingAnswer:!1,editFailedQuestionId:n?void 0:e,bubbles:t.bubbles.map(t=>t.sender===_r.CANDIDATE&&t.questionId===e?{...t,status:$r.EDITING}:t)})),n)return;this.emitter.emit(S.ERROR,{type:ote,message:$m(t)})}}currentEditableQuestionId(){var e;return(e=this.store.getState().editingQuestionId)==null?this.currentQuestionId():e}currentPiiType(){var e,t;let{bubbles:n,editingQuestionId:r}=this.store.getState();return r?(e=Bm(n,r))==null?void 0:e.piiQuestionType:(t=zm(n))==null?void 0:t.piiQuestionType}async submitOptionAnswer(e,t=!1){var n;let r=this.currentEditableQuestionId();if(!r||this.store.getState().sendingAnswer)return;let i=this.inlineCandidateBubble(r),o=i==null||(n=i.data.messageItems)==null||(n=n[0])==null||(n=n.contents)==null?void 0:n.find(t=>t.id===e);if(!(!i||!o)){if(this.setBubbleStatus(i.id,$r.PENDING),!t&&await this.detectedAgc(i)){this.pendingAgcOptionId=e,this.setBubbleStatus(i.id,i.status);return}await this.submitInlineAnswer(i,r,vte(i)?nh([o]):th(o))}}toggleOptionSelection(e){var t,n;let r=this.currentEditableQuestionId();if(!r||this.store.getState().sendingAnswer)return;let i=this.inlineCandidateBubble(r);if(!i||!ah(i)||!((t=(n=i.data.messageItems)==null||(n=n[0])==null?void 0:n.contents)==null?[]:t).some(t=>t.id===e))return;let{max:o}=ih(i.data.rules),c=this.selectedOptionIds(r),l=c.includes(e)?c.filter(t=>t!==e):[...c,e];o!==void 0&&l.length>o||this.store.setState({multiSelectDraft:{questionId:r,optionIds:l}})}async confirmSelections(){var e,t;let n=this.currentEditableQuestionId();if(!n||this.store.getState().sendingAnswer)return;let r=this.inlineCandidateBubble(n);if(!r||!ah(r))return;let i=this.selectedOptionIds(n),o=((e=(t=r.data.messageItems)==null||(t=t[0])==null?void 0:t.contents)==null?[]:e).filter(e=>i.includes(e.id)),{min:c,max:l}=ih(r.data.rules);o.length<c||l!==void 0&&o.length>l||await this.submitInlineAnswer(r,n,nh(o))}selectedOptionIds(e){let{multiSelectDraft:t}=this.store.getState();return(t==null?void 0:t.questionId)===e?t.optionIds:[]}async detectedAgc(e){var t;let n=e.messageIdentifier===Cr.SUBMIT_QUESTION,{allowNextAgcDetection:r,featureFlags:i}=this.store.getState(),o=((t=i[Dr.AGC])==null?void 0:t.enabled)!==!1;if(!n||!r||!o)return!1;try{let e=await this.client.detectAgc(this.assessmentId);if(this.store.setState({agcAttempt:e.attempt,allowNextAgcDetection:e.allowNextAgcDetection}),e.isAgc)return this.store.setState({showAgcWarning:!0}),!0}catch(e){if(cr(e))return!1;this.emitter.emit(S.ERROR,{type:ute,message:$m(e)})}return!1}async continueAfterAgcWarning(){let e=this.pendingAgcOptionId;this.pendingAgcOptionId=void 0,this.store.setState({showAgcWarning:!1}),e&&await this.submitOptionAnswer(e,!0)}dismissAgcWarning(){this.pendingAgcOptionId=void 0,this.store.setState({showAgcWarning:!1})}dismissEditFailure(){this.store.setState({editFailedQuestionId:void 0})}reportPaste(){this.emitter.emit(S.LOG,{type:pte,message:`Candidate pasted an answer`})}async submitSliderAnswer(e){let t=this.currentEditableQuestionId();if(!t||this.store.getState().sendingAnswer)return;let n=this.inlineCandidateBubble(t);n&&await this.submitInlineAnswer(n,t,{text:String(e),value:String(e)})}async submitInlineAnswer(e,t,n){if(this.store.getState().editingQuestionId===t){await this.editExistingAnswer(t,n);return}this.pendingBubbleId=e.id,this.store.setState(t=>({bubbles:t.bubbles.map(t=>t.id===e.id?{...t,status:$r.PENDING,data:{...t.data,answer:n}}:t)})),await this.loadNext({userAgent:this.userAgent,questionId:t,answer:n})}async retryLastAnswer(){if(!this.lastFailedInput)return;let e=this.lastFailedInput;this.lastFailedInput=void 0,this.setPendingBubbleStatus($r.PENDING),await this.loadNext(e)}currentQuestionId(){var e;return(e=zm(this.store.getState().bubbles))==null?void 0:e.questionId}inlineCandidateBubble(e){return Vee(this.store.getState().bubbles,e)}questionRoleFor(e){var t,n;return(t=(n=Bm(this.store.getState().bubbles,e))==null?void 0:n.questionRole)==null?Zr.NORMAL:t}appendOptimisticCandidateBubble(e){var t,n,r,i;let o={id:`${Ste}-${e.questionId}`,questionId:e.questionId,sender:_r.CANDIDATE,status:$r.PENDING,types:[vr.FTQ],questionRole:this.questionRoleFor(e.questionId),data:{messageItems:[{id:e.questionId,types:[],contents:[{id:e.questionId,text:(t=(n=e.answer)==null?void 0:n.text)==null?``:t,value:(r=(i=e.answer)==null?void 0:i.value)==null?``:r}]}],...e.answer?{answer:e.answer}:{}}};this.pendingBubbleId=o.id,this.store.setState(e=>({bubbles:[...e.bubbles,o]}))}setBubbleStatus(e,t){this.store.setState(n=>({bubbles:Iee(n.bubbles,e,t)}))}setPendingBubbleStatus(e){let t=this.pendingBubbleId;t&&this.setBubbleStatus(t,e)}replacePendingBubble(e){this.store.setState(t=>({bubbles:Lee(t.bubbles,this.pendingBubbleId,e)}))}async loadNext(e){var t;(t=this.streamAbort)==null||t.abort();let n=new AbortController;this.streamAbort=n;let r=Array.isArray(e)?void 0:e;this.store.setState({sendingAnswer:!!(r!=null&&r.answer)||Array.isArray(e),typing:!0});let i=new bte(this.streamText?this.streamRevealMs:void 0,()=>`${ii}-${this.streamSeq++}`,{live:(e,t,n)=>this.store.setState(r=>({typing:!1,streamingBubbleId:t,bubbles:n?r.bubbles.map(n=>n.id===t?e:n):[...r.bubbles,e]})),commit:(e,t,n)=>this.store.setState(r=>({streamingBubbleId:void 0,bubbles:n?r.bubbles.map(n=>n.id===t?e:n):[...r.bubbles,e]}))}),o=i.run(),c=()=>this.store.setState(e=>({streamingBubbleId:void 0,bubbles:zee(e.bubbles,i.liveId)}));try{var l,u;let t=await this.client.nextStream(this.assessmentId,e,{signal:n.signal,streamText:this.streamText,onSummary:e=>{this.store.getState().assessmentSummary||this.store.setState({assessmentSummary:e})},onLink:e=>this.store.setState({assessmentLink:e}),onPiiForm:e=>this.store.setState({piiForm:e}),onCustomerSatisfactionForm:e=>this.store.setState({csatForm:e}),onDemographicForm:e=>this.store.setState({deiForm:e}),onMeta:(e,t)=>i.onMeta(e,t),onDelta:(e,t)=>i.onDelta(e,t)});if(i.finish(),this.persistFiToken(),await o,!t){this.store.setState({typing:!1,sendingAnswer:!1});return}if((l=t.nextResponse)!=null&&l.data?t.nextResponse.id===i.liveId?this.store.setState({streamingBubbleId:void 0}):i.baseId&&i.metaFor(t.nextResponse.id)?i.commitCurrent():c():i.commitCurrent(),Array.isArray(e)&&(this.setPendingBubbleStatus($r.ANSWERED),this.pendingBubbleId=void 0),this.settleAnswerAndStatus(t,r))return;let d=t.nextResponse,f=d?(u=i.metaFor(d.id))==null?d.data?i.metaFor(d.data._id):void 0:u:void 0;await this.appendAgentAndContinue(t,f)}catch(t){if(i.finish(),await o.catch(()=>{}),t.name===wte)return;if(c(),this.lastFailedInput=e,cr(t)){this.cacheUnsentAnswer(e),this.store.setState({typing:!1,sendingAnswer:!1});return}this.setPendingBubbleStatus($r.FAILED),this.store.setState({typing:!1,sendingAnswer:!1}),this.emitter.emit(S.ERROR,{type:ite,message:$m(t)})}}handleTerminalSignals(e){var t,n;if((Ete(e.assessmentStatus)||e.duplicatedWithAssessmentLink)&&this.store.setState({duplicated:!0}),e.duplicatedWithAssessmentLink&&this.emitter.emit(S.ASSESSMENT_DUPLICATED,{assessmentId:this.assessmentId,duplicatedWithAssessmentLink:e.duplicatedWithAssessmentLink}),e.assessmentStatus&&uh(e.assessmentStatus))return!1;let r=(t=e.cohortIsArchivedMessage)==null?e.assessmentIsReusedMessage:t,i=r==null||(n=r.data)==null||(n=n.contents)==null||(n=n[0])==null?void 0:n.value;return i?(this.store.setState({phase:Zm.TERMINAL_MESSAGE,typing:!1,terminalMessage:i}),this.emitter.emit(S.ASSESSMENT_ENDED,{assessmentId:this.assessmentId,justCompleted:!1}),!0):!1}settleAnswerAndStatus(e,t){var n,r;if(t!=null&&t.answer){var i;let n=e.candidateResponse;n&&((i=n.data)==null||(i=i.question)==null?void 0:i._id)===t.questionId?this.replacePendingBubble(Im(n)):this.setPendingBubbleStatus($r.ANSWERED),this.pendingBubbleId=void 0,this.emitter.emit(S.ANSWER_SAVED,{questionId:t.questionId})}return this.store.setState({sendingAnswer:!1,assessmentStatus:e.assessmentStatus,numOfNormalAnswer:(n=e.numOfNormalAnswer)==null?this.store.getState().numOfNormalAnswer:n,termsAccepted:(r=e.isTermsAndConditionsAccepted)==null?this.store.getState().termsAccepted:r}),this.handleTerminalSignals(e)}async appendAgentAndContinue(e,t){let n=e.nextResponse;if(n!=null&&n.data){var r;let e=hte(Lm(n),t),i=Rm(n);if(this.store.setState(t=>({typing:!1,bubbles:hee(cee(xee(Bee(t.bubbles,e,i),t.piiForm),t.csatForm),t.deiForm)})),(r=n.data.types)!=null&&r.includes(vr.HINT)){await this.loadNext({userAgent:this.userAgent,questionId:n.data._id});return}}else this.store.setState({typing:!1});if(!(n!=null&&n.data)||uh(e.assessmentStatus)){let t=this.store.getState().duplicated!==!0||uh(e.assessmentStatus);t&&this.store.setState({phase:Zm.COMPLETING}),this.emitter.emit(S.ASSESSMENT_ENDED,{assessmentId:this.assessmentId,justCompleted:t})}}},dh=`true`,Ote=()=>{if(typeof window>`u`)return!1;let e=new URLSearchParams(window.location.search);return e.get(`internalUser`)===dh||e.get(`sapian`)===dh},kte=e=>{if(e)try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?e:void 0}catch{return}},Ate={fi_label_typing:`Typing`,fi_button_edit:`Edit`,fi_button_continue:`Continue`,fi_button_retry:`Retry`,fi_button_record:`Record`,fi_button_stop:`Stop`,fi_button_tryAgain:`Try Again`,fi_button_submitRating:`Submit rating`,fi_button_next:`Next`,fi_button_accept:`Accept`,fi_button_readFullBrief:`Read the full brief`,fi_tooltip_copiedUrl:`Link is copied`,fi_button_showMore:`Show more`,fi_button_showLess:`Show less`,fi_label_collectDetailsIntro:`Let's grab a few quick details.`,fi_label_yourDetails:`Your details`,fi_label_reviewDetailsWarning:`Please review your details carefully as you cannot change this later`,fi_label_editing:`Editing`,fi_label_ratingMessage:`Rate your experience!`,fi_label_enterResponse:`Enter your response…`,fi_label_enterOrPasteResponse:`Type or paste your response…`,fi_label_enterOrSkipFeedback:`Leave a comment here if you wish, or click the arrow button to continue`,fi_label_uploading:`Uploading your video`,fi_label_uploadFailed:`Your video failed to upload.`,fi_label_cancelEditDesktop:`Cancel edit`,fi_placeholder_dropdown:`Type to search…`,fi_placeholder_demoEmailInput:`Enter your email`,fi_error_piiEmail:`Please enter a valid email address.`,fi_error_piiFullName:`Please enter a valid full name.`,fi_error_piiFirstName:`Please enter a valid first name.`,fi_error_piiLastName:`Please enter a valid last name.`,fi_error_piiPhoneNumber:`Please enter a valid phone number.`,ci_error_piiLocation:`Please enter your town or city.`,fi_error_sendAnswerFailed:`We could not send your answer. Please try again.`,fi_error_submitVideo:`We could not submit your video. Please try again.`,ci_header_title:`Interview`,ci_widget_label:`Chat interview`,ci_video_badge:`Video`,ci_typing:`Interviewer is typing`,ci_label_loadingNextPrompt:`Loading…`,ci_scroll_to_latest:`Scroll to the latest message`,ci_progress_label:`Interview progress`,ci_written_question_counter:`Written question {{current}} of {{total}}`,ci_quick_additional_question_counter:`Quick additional question {{current}} of {{total}}`,ci_video_question_counter:`Video question {{current}} of {{total}}`,ci_diversity_counter:`Diversity {{current}} of {{total}}`,ci_pause_hint:`Pause anytime — come back with this link`,ci_welcome_greeting:`Hi {{name}}.`,ci_welcome_greeting_generic:`Hi there.`,ci_welcome_title:`Welcome to your Chat Interview`,ci_welcome_eyebrow:`Chat interview`,ci_welcome_copy_resume:`Copy link · resume later`,ci_welcome_intro:`A conversation for the {{role}} role with {{company}} — answered in your own words, read blind to your name, age and background.`,ci_welcome_intro_generic:`A conversation answered in your own words, read blind to your name, age and background.`,ci_welcome_pause:`You can pause and come back later with this link`,ci_welcome_reassurance:`No right or wrong answers. Take your time.`,fi_label_summaryTotal:`Total`,fi_label_summaryQuestionCount:`{{totalQuestions}} Questions (~ {{estimatedMinutes}} minutes)`,fi_label_summaryRowInterview_one:`{{count}} Written question`,fi_label_summaryRowInterview_other:`{{count}} Written questions`,fi_label_summaryRowInterviewDescription:`Tell us how you work, in up to 200 words each. Sapia.ai's AI reads and scores your answers, and the {{company}} hiring team makes the decisions.`,fi_label_summaryRowVideo_one:`{{count}} Video question`,fi_label_summaryRowVideo_other:`{{count}} Video questions`,fi_label_summaryRowVideoDescription:`You can retry **{{maxRetries}}** times per question and submit when you're ready.`,fi_label_summaryRowAdditional_one:`{{count}} Quick additional question`,fi_label_summaryRowAdditional_other:`{{count}} Quick additional questions`,fi_label_summaryRowAdditionalDescription:`These aren't scored, and our AI doesn't read them. They go to the hiring team so they can learn more about your experience and qualifications.`,fi_label_summaryRowDei_one:`{{count}} Diversity question (optional)`,fi_label_summaryRowDei_other:`{{count}} Diversity questions (optional)`,fi_label_summaryRowDeiDescription:`A few questions at the end, after you've submitted. They aren't scored, they aren't shown to the hiring team, and they don't affect your application.`,fi_button_copyLink:`Copy link`,ci_edit_banner:`Editing your answer`,ci_video_retry_banner:`Retrying your video answer`,ci_rich_toolbar:`Lists`,ci_rich_bullet_list:`Bulleted list`,ci_rich_number_list:`Numbered list`,ci_composer_expand:`Expand the answer box`,ci_composer_collapse:`Shrink the answer box`,ci_button_send:`Send`,ci_input_label:`Your answer`,ci_options_group:`Answer options`,ci_label_selectAllThatApply:`Select all that apply`,ci_label_selectMax:`Select {{max}}`,ci_label_selectionCount:`{{selected}} of {{max}} selected`,ci_button_confirm:`Confirm`,ci_sender_agent:`Interviewer`,ci_sender_candidate:`You`,ci_opens_new_tab:`opens in a new tab`,ci_dropdown_search_label:`Search options`,fi_label_words_one:`{{count}} word`,fi_label_words_other:`{{count}} words`,fi_alt_shortResponse:`Your response is shorter than the required minimum {{minWordCount}} words`,fi_alt_goodResponse:`Good response length!`,fi_alt_maxWords:`You have reached the maximum words allowed for this question`,fi_error_notEnoughWords:`You have entered less than the recommended **{{minWordCount}} words**`,fi_error_notEnoughWordsMin:`Aim for **at least {{minWordCount}} words per answer** so we can accurately assess you, and give you meaningful feedback.`,fi_error_notEnoughWordsAim:`Aim for **{{minWordCount}} - {{recommendedWordCount}} words per answer** so we can accurately assess you, and give you meaningful feedback.`,fi_error_notEnoughWordsEdit:`You can edit your answers any time during the interview.`,fi_error_notEnoughWordsEditNow:`Do you want to edit your response now?`,fi_check_dontShow:`Don't show me this again`,ci_loading:`Loading your interview…`,ci_preparing:`Preparing your interview…`,ci_done_title:`That's everything.`,ci_done_subtitle:`Thanks for being generous with your answers, {{name}}.`,ci_done_subtitle_generic:`Thanks for being generous with your answers.`,ci_done_ack:`Got it`,ci_done_next_label:`What happens next`,ci_done_step1:`Your written answers are **scored on only what you said.**`,ci_done_step2:`As promised, we'll email you personalised feedback and tips to help you grow, whatever the outcome.`,ci_done_step3:`If it's a match, a member of the hiring team will reach out about next steps.`,ci_start_failed:`We could not load your interview. Please refresh the page to try again.`,fi_error_cohortClosedTitle:`Sorry, it's closed`,fi_error_cohortClosedMessage:`Unfortunately, this job position has been closed and is no longer receiving applications.`,ci_assessment_not_found_title:`We can't find this interview`,ci_assessment_not_found_message:`This link may be incorrect or no longer active. Please check the link in your invitation email.`,ci_phone_country_label:`Country code`,ci_phone_placeholder:`Enter your phone number`,ci_location_input_label:`Town or city`,ci_location_placeholder:`Start typing your town or city`,ci_location_suggestions_label:`Location suggestions`,ci_location_suggestions_found:`{{count}} locations found`,ci_pii_back:`Back`,ci_pii_review_title:`Review details`,ci_pii_label_fullName:`Name`,ci_pii_label_firstName:`First name`,ci_pii_label_lastName:`Last name`,ci_pii_label_email:`Email address`,ci_pii_label_location:`Location`,ci_pii_label_phone:`Phone number`,ci_pii_placeholder_fullName:`Enter your name`,ci_pii_placeholder_firstName:`Enter your first name`,ci_pii_placeholder_lastName:`Enter your last name`,ci_pii_row_name:`Name`,ci_pii_row_firstName:`First name`,ci_pii_row_lastName:`Last name`,ci_pii_row_email:`Email`,ci_pii_row_location:`Location`,ci_pii_row_phone:`Phone`,ci_pii_row_sms:`SMS updates`,ci_pii_sms_consented:`Consented`,ci_pii_sms_declined:`Declined`,ci_csat_intro:`Before you go — how was your experience with this interview today?`,ci_csat_title:`How was your experience?`,ci_csat_subtitle:`This won't affect your application. We share it with the hiring team so they can improve how they hire.`,ci_csat_scale_label:`Rate your experience from {{min}} to {{max}}`,ci_csat_low:`Poor`,ci_csat_high:`Excellent`,ci_csat_comment_label:`Anything you would like to add`,ci_csat_comment_placeholder:`Anything you'd like to add? (optional)`,ci_csat_submit:`Submit feedback`,ci_csat_answer_rating:`Rating: {{rating}}/{{max}}`,ci_csat_answer_comment:`Feedback: {{comment}}`,ci_dei_title:`Diversity & inclusion`,ci_dei_submit:`Continue`,ci_name_confirm_title:`Is this correct?`,ci_name_confirm_body:`We read your name as "{{suggested}}". Use this?`,ci_name_use_suggested:`Use "{{suggested}}"`,ci_name_use_original:`Keep what I typed`,ci_video_open_camera:`Turn on camera`,ci_video_re_record:`Re-record`,ci_video_submit:`Use this answer`,ci_video_keep:`Keep this answer`,ci_video_camera:`Camera`,ci_video_microphone:`Microphone`,ci_video_on:`On`,ci_video_off:`Off`,ci_video_finish_hint:`Tap to finish`,ci_video_camera_off:`Camera is off`,ci_video_recording_started:`Recording started`,ci_video_recording_stopped:`Recording stopped`,ci_video_seconds_remaining:`{{seconds}} seconds remaining`,ci_video_attempts:`{{current}}/{{max}} attempts`,ci_video_camera_error:`We could not access your camera. Please check permissions and try again.`,ci_video_preview:`Camera preview`,ci_video_retry_upload:`Retry upload`,ci_video_play:`Play video`,ci_video_answer:`Your video answer`,ci_video_embed_label:`Embedded video`,ci_access_title:`Verify your identity`,ci_access_description:`Please enter the email address you applied with to continue.`,fi_error_emailDoesNotMatch:`That email does not match our records. Please try again.`,fi_error_agcTitle:`Please answer in your own words`,fi_error_agcFirstMessage:`Your answer looks like it may be AI-generated. Please edit it to be your own words.`,fi_error_agcSecondMessage:`This is your final reminder — please make sure your answer is your own work.`,fi_agc_guidance_header:`Quick Note about AI Usage`,fi_agc_guidance_body:`Every response is checked for AI-generated content.
40
40
 
41
41
  Write your answers from your own experience, in your own words.
42
42
 
@@ -3784,5 +3784,5 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
3784
3784
 
3785
3785
  `)]:[],S9=new WeakMap,C9=[],w9=(e,t)=>{var n;return(t==null||(n=t.draft)==null?void 0:n.questionId)===e.questionId?t.draft.optionIds:C9},wbe=(e,t,n,r,i,o,c)=>{let l=t.get(e.id),u=e.id===r,d=w9(e,o),f=S9.get(e);if(f&&f.card===l&&f.streaming===u&&f.locks.submitted===n.submitted&&f.buildPiiDetails===i&&f.buildCsatLines===c&&f.selectedIds===d)return f.item;let p=Tbe(e,t,n,r,i,o,c);return S9.set(e,{card:l,streaming:u,locks:n,buildPiiDetails:i,buildCsatLines:c,selectedIds:d,item:p}),p},Tbe=(e,t,n,r,i,o,c)=>{let l=vbe(e),u=t.get(e.id),d=u!==void 0,f=x9(e),p={id:e.id,sender:e.sender===_r.AGENT?g6.AGENT:g6.CANDIDATE,paragraphs:e.data.customerSatisfaction&&c?Cbe(c(e.data.customerSatisfaction)):b9(e),pending:e.status===$r.PENDING,failed:e.status===$r.FAILED,editableQuestionId:xbe(e,n),editing:e.status===$r.EDITING,..._be(e)?{isHint:!0}:{},...e.id===`410270a8-73c9-51b8-b6ae-a6effc5e6cda`?{linksOpenInSameTab:!0}:{},...f.length>0?{cards:f}:{},...e.data.piiDetails&&i?{piiDetails:i(e.data.piiDetails)}:{},...e.data.demographicDetails?{demographicDetails:e.data.demographicDetails.map(e=>({label:e.prompt,value:e.answer}))}:{},...l?{embeddedVideo:l}:{},...d?{variant:_6.CARD,questionLabel:u.label,...u.badge?{questionBadge:u.badge}:{}}:{},...r!==void 0&&e.id===r?{streaming:!0}:{}};if(hbe(e)){var m,h,g,_,v;let t=e.data.answer;if(e.status===$r.ANSWERED||e.status===$r.PENDING&&t!=null){var y;let e=!(t==null||(y=t.selections)==null)&&y.length?[t.selections.map(e=>e.text).join(`
3786
3786
  `)]:t?[t.text]:[];return{...p,paragraphs:e}}let n=(m=(h=e.data.messageItems)==null||(h=h[0])==null?void 0:h.contents)==null?[]:m,r=n.map(({id:e,text:t})=>({id:e,text:t})),i=(g=(_=e.types)==null?void 0:_.includes(vr.DROPDOWN))==null?!1:g,c=n.some(e=>h9.includes(e.value)),l=ah(e),u=ih(e.data.rules),d=l?w9(e,o):C9;return{...p,paragraphs:[],options:r,optionsKind:i?v6.DROPDOWN:c?v6.ACTION:v6.LIST,selectedOptionId:(v=n.find(t=>{var n;return t.value===((n=e.data.answer)==null?void 0:n.value)}))==null?void 0:v.id,optionsEnabled:y9(e.status),...l&&o?{selectedOptionIds:d,optionsInstruction:o.labels.instruction(sh(u,r.length),u.max),...u.max===void 0?{}:{optionsCountLabel:o.labels.count(d.length,u.max),optionsCapReached:d.length>=u.max},confirmEnabled:d.length>=u.min}:{}}}if(g9(e)){var b,x,S,C;return{...p,paragraphs:[],video:{uploadProgress:e.uploadProgress,blob:e.videoBlob,questionId:e.questionId,extension:(b=e.videoExtension)==null?v9((x=e.data.answer)==null?void 0:x.value):b,previewUrl:ybe((S=e.data.answer)==null?void 0:S.text)?(C=e.data.answer)==null?void 0:C.text:void 0,failed:e.status===$r.FAILED}}}if(gbe(e)){var w;let t=(w=e.data.answer)==null?void 0:w.value;return{...p,paragraphs:[],slider:{min:1,max:10,defaultValue:8,submittedValue:t===void 0?void 0:Number(t),enabled:y9(e.status)}}}return p},Ebe=e=>e.sender===_r.CANDIDATE&&b9(e)[0]===`SAPIA_SKIP_FEEDBACK`,Dbe=(e,t=new Map,n=bbe,r,i,o,c)=>e.filter(e=>!Ebe(e)).map(e=>wbe(e,t,n,r,i,o,c)).filter(e=>{var t,n,r,i;return e.paragraphs.length>0||((t=(n=e.cards)==null?void 0:n.length)==null?0:t)>0||((r=(i=e.options)==null?void 0:i.length)==null?0:r)>0||e.slider!==void 0||e.video!==void 0||e.embeddedVideo!==void 0}),T9=(e,t)=>{let n=e.filter(e=>e.sender===_r.AGENT);return t?n.find(e=>e.questionId===t):n[n.length-1]},Obe=(e,t)=>{var n;return(n=T9(e,t))==null?void 0:n.questionId},kbe=e=>{let t=e.find(e=>x9(e).includes(y6.AGC_GUIDANCE));return t?!e.some(e=>e.sender===_r.CANDIDATE&&e.questionId===t.questionId&&e.status===$r.ANSWERED):!1},Abe=e=>{if(e.some(e=>x9(e).includes(y6.AGC_GUIDANCE)))return!1;let t=e.find(e=>e.sender===_r.AGENT&&e.questionRole===Zr.TERMS_CONSENT);return t?!e.some(e=>e.sender===_r.CANDIDATE&&e.questionId===t.questionId&&e.status===$r.ANSWERED):!1},jbe=(e,t)=>{var n,r;if(!t)return;let i=e.find(e=>e.sender===_r.CANDIDATE&&e.questionId===t);if(!i)return;let o=(n=(r=i.data.answer)==null?void 0:r.text)==null?b9(i).join(`
3787
- `):n;if(o)return{text:o}},Mbe=(e,t)=>{var n,r;if(!t)return;let i=e.find(e=>g9(e)&&e.questionId===t);if(i)return{questionId:t,blob:i.videoBlob,extension:(n=i.videoExtension)==null?v9((r=i.data.answer)==null?void 0:r.value):n}},Nbe=[vr.FTQ,vr.MCQ,vr.MSQ,vr.BGQ,vr.DROPDOWN,vr.VIDEO],Pbe=e=>{var t;return e.sender===_r.AGENT&&((t=e.types)==null?[]:t).some(e=>Nbe.includes(e))&&ti(e)!==void 0&&!x9(e).includes(y6.PII_FORM_INTRO)},Fbe=(e,t,n)=>{let r=new Map,i=ni(e),o=e=>{let r=i.get(e.id);if(!r)return;let o=t[r.scale];if(!(!o||r.ordinal>o))return n.counter[r.scale](r.ordinal,o)};for(let t of e){var c;if(!Pbe(t))continue;let e=o(t),i=((c=t.types)==null?[]:c).includes(vr.VIDEO)?n.videoBadge:void 0;r.set(t.id,{...e?{label:e}:{},...i?{badge:i}:{}})}return r},Ibe=(e,t)=>{let n=e=>{var t;return((t=e.types)==null?[]:t).includes(vr.VIDEO)};if(t){var r;return(r=e.find(e=>e.sender===_r.AGENT&&e.questionId===t&&n(e)))==null?void 0:r.id}let i=T9(e);if(i)return n(i)?i.id:void 0},Lbe=(e,t)=>{var n;let r=T9(e,t);return!!(!(r==null||(n=r.types)==null)&&n.includes(vr.FTQ))},E9=function(e){return e.TEXT=`text`,e.EMAIL=`email`,e.NAME=`name`,e.PHONE=`phone`,e.LOCATION=`location`,e.VIDEO=`video`,e}({}),Rbe=(e,t)=>{var n;let r=T9(e,t);if(!(r==null||(n=r.types)==null)&&n.includes(vr.VIDEO))return`video`;switch(r==null?void 0:r.piiQuestionType){case xr.EMAIL:return`email`;case xr.PHONE_NUMBER:return`phone`;case xr.LOCATION:return`location`;case xr.FULL_NAME:case xr.FIRST_NAME:case xr.LAST_NAME:return`name`;default:return`text`}},D9=e=>{if(e===void 0)return;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:void 0},zbe=(e,t)=>{var n,r;let i=(n=(r=T9(e,t))==null?void 0:r.data.rules)==null?[]:n,o=e=>{var t;return D9((t=i.find(t=>t.name===e))==null?void 0:t.value)};return{min:o(gr.MIN_TEXT_LENGTH),recommend:o(gr.RECOMMENDED_TEXT_LENGTH),max:o(gr.MAX_TEXT_LENGTH)}},Bbe=(e,t)=>{var n;return Dee((n=T9(e,t))==null?void 0:n.data.tags)},Vbe=(e,t)=>{var n;return((n=T9(e,t))==null?void 0:n.messageIdentifier)===Cr.FEEDBACK_CUSTOMER_SATISFACTION_QUESTION},Hbe=(e,t)=>{var n,r,i;let o=D9((i=((n=(r=T9(e,t))==null?void 0:r.data.rules)==null?[]:n).find(e=>e.name===gr.MAX_VOICE_SECONDS))==null?void 0:i.value);return o==null?60:o},O9=d({fetchPlaceAnswer:()=>H9,fetchPlaceSuggestions:()=>V9}),k9,A9,j9,M9,N9,P9,F9,I9,L9,R9,z9,B9,V9,H9,U9=l((()=>{k9=`AIzaSyCWSAROQu-uLQmQ-fq0ip7aXHpBjPESaQQ`,A9=`https://places.googleapis.com/v1`,j9=`${A9}/places:autocomplete`,M9=`${A9}/places`,N9=`X-Goog-Api-Key`,P9=`X-Goog-FieldMask`,F9=`Content-Type`,I9=`application/json`,L9=[`suggestions.placePrediction.placeId`,`suggestions.placePrediction.text`,`suggestions.placePrediction.structuredFormat.mainText`,`suggestions.placePrediction.structuredFormat.secondaryText`].join(`,`),R9=[`id`,`formattedAddress`,`location`,`displayName`].join(`,`),z9=`en`,B9=async(e,t,{apiKey:n,signal:r,fetchImpl:i},o)=>{let c=await(i==null?globalThis.fetch:i)(e,{method:o?`POST`:`GET`,headers:{[N9]:n==null?k9:n,[P9]:t,...o?{[F9]:I9}:{}},body:o?JSON.stringify(o):void 0,signal:r});if(!c.ok)throw Error(`places request failed: ${c.status}`);return await c.json()},V9=async(e,t={})=>{var n;return e.trim()?((n=(await B9(j9,L9,t,{input:e,languageCode:z9})).suggestions)==null?[]:n).map(({placePrediction:e})=>{var t,n,r,i;return{placeId:e.placeId,description:e.text.text,mainText:(t=(n=e.structuredFormat)==null||(n=n.mainText)==null?void 0:n.text)==null?e.text.text:t,secondaryText:(r=(i=e.structuredFormat)==null||(i=i.secondaryText)==null?void 0:i.text)==null?``:r}}):[]},H9=async(e,t={})=>{let n=await B9(`${M9}/${e.placeId}`,R9,t);return{address:n.formattedAddress||e.description,coordinate:n.location?{lat:n.location.latitude,lng:n.location.longitude}:null}}})),Ube=500,W9=({apiKey:e})=>{let[t,n]=(0,w.useState)([]),[r,i]=(0,w.useState)(!1),o=(0,w.useRef)(null),c=(0,w.useRef)(null),l=(0,w.useRef)(e);return l.current=e,(0,w.useEffect)(()=>()=>{var e;o.current&&clearTimeout(o.current),(e=c.current)==null||e.abort()},[]),{suggestions:t,manualMode:r,search:(0,w.useCallback)(e=>{if(o.current&&clearTimeout(o.current),!e.trim()){n([]);return}o.current=setTimeout(()=>{var t;(t=c.current)==null||t.abort();let r=new AbortController;c.current=r,(async()=>{try{let{fetchPlaceSuggestions:t}=await Promise.resolve().then(()=>(U9(),O9)),i=await t(e,{apiKey:l.current,signal:r.signal});r.signal.aborted||n(i)}catch{if(r.signal.aborted)return;n([]),i(!0)}})()},Ube)},[]),clear:(0,w.useCallback)(()=>n([]),[]),resolve:(0,w.useCallback)(async e=>{try{let{fetchPlaceAnswer:t}=await Promise.resolve().then(()=>(U9(),O9));return await t(e,{apiKey:l.current})}catch{return i(!0),null}},[])}},Wbe=(e,{media:t=kve.VIDEO,takes:n,submittedTake:r}={})=>{let i=(0,w.useRef)(null),o=(0,w.useRef)(null),[c,l]=(0,w.useState)({phase:O5.IDLE,elapsedSeconds:0}),[u,d]=(0,w.useState)(!0),[f,p]=(0,w.useState)(!0),[m,h]=(0,w.useState)(null),[g,_]=(0,w.useState)(()=>Math.max(n?$ee(n.assessmentId,n.questionId):0,+!!r)),[v,y]=(0,w.useState)(null),[b,x]=(0,w.useState)(!!r),[S,C]=(0,w.useState)(null),[T,E]=(0,w.useState)(!1),D=(0,w.useRef)(!1);(0,w.useEffect)(()=>{let n=new Nve({maxSeconds:e,media:t,getStream:e=>navigator.mediaDevices.getUserMedia(e),createRecorder:(e,t)=>new MediaRecorder(e,t),isTypeSupported:e=>MediaRecorder.isTypeSupported(e),onChange:l});return o.current=n,()=>n.dispose()},[e,t]),(0,w.useEffect)(()=>{var e;let t=(e=o.current)==null?void 0:e.getStream();i.current&&t&&(c.phase===O5.PREVIEW||c.phase===O5.RECORDING)&&(i.current.srcObject=t)},[c.phase]),(0,w.useEffect)(()=>{var e;if(c.phase===O5.REVIEW&&(e=c.result)!=null&&e.blob){let e=URL.createObjectURL(c.result.blob);return y(e),()=>URL.revokeObjectURL(e)}y(null)},[c.phase,c.result]),(0,w.useEffect)(()=>{var e;if(!b||!r)return;if(r.blob){let e=URL.createObjectURL(r.blob);return C(e),()=>URL.revokeObjectURL(e)}let t=!1;return(e=r.resolveUrl)==null||e.call(r).then(e=>{t||C(e)},()=>{}),()=>{t=!0}},[b,r]),(0,w.useEffect)(()=>{c.phase!==O5.REVIEW||!c.result||_(n?ete(n.assessmentId,n.questionId):e=>e+1)},[c.phase,c.result,n]),(0,w.useEffect)(()=>{T&&(c.phase===O5.PREVIEW&&D.current?(D.current=!1,h(3)):(c.phase===O5.RECORDING||c.phase===O5.ERROR)&&E(!1))},[T,c.phase]),(0,w.useEffect)(()=>{if(m===null)return;if(m<=0){var e;h(null),(e=o.current)==null||e.startRecording();return}let t=setTimeout(()=>h(e=>(e==null?1:e)-1),1e3);return()=>clearTimeout(t)},[m]);let O=(0,w.useCallback)(()=>{var e;let t=(e=o.current)==null?void 0:e.getStream();d(e=>{let n=!e;return t==null||t.getVideoTracks().forEach(e=>{e.enabled=n}),n})},[]),k=(0,w.useCallback)(()=>{var e;let t=(e=o.current)==null?void 0:e.getStream();p(e=>{let n=!e;return t==null||t.getAudioTracks().forEach(e=>{e.enabled=n}),n})},[]),A=(0,w.useCallback)(()=>{x(!1),E(!0),D.current=!0;let e=o.current;e!=null&&e.getStream()?e.reset():e==null||e.openCamera()},[]);return{state:b?{...c,phase:O5.REVIEW}:c,videoRef:i,camOn:u,micOn:f,countdown:m,takesUsed:g,maxAttempts:5,reviewUrl:b?S:v,reviewingSubmitted:b,retaking:T,openCamera:(0,w.useCallback)(()=>{var e;(e=o.current)==null||e.openCamera()},[]),beginCountdown:(0,w.useCallback)(()=>h(3),[]),stopRecording:(0,w.useCallback)(()=>{var e;return(e=o.current)==null?void 0:e.stopRecording()},[]),reRecord:A,toggleCamera:O,toggleMicrophone:k}},Gbe=({engine:e,assessmentId:t,kind:n,disabled:r,wordCountRule:i,strings:o,candidateCountryCode:c,region:l,placesApiKey:u,maxVideoSeconds:d=60,submittedVideo:f,videoQuestionId:p,draft:m,draftQuestionId:h,allowPaste:g,isFeedbackComment:_,onBlockedPaste:v,focusOnOpen:y,expanded:b,onExpandedChange:x})=>{var S,C;let[T,E]=(0,w.useState)(null),[D,O]=(0,w.useState)(null),[k,A]=(0,w.useState)([]),[j,M]=(0,w.useState)(null),[N,P]=(0,w.useState)(()=>Xee(t)),[F]=(0,w.useState)(()=>h?Qee(t,h):void 0),I=(0,w.useCallback)(e=>{h&&(e.trim().length===0?Xm(t):Ym(t,h,e))},[t,h]),L=W9({apiKey:u});(0,w.useEffect)(()=>{if(n!==E9.PHONE)return;let e=!0;return k5().then(t=>{e&&A(t)}),()=>{e=!1}},[n]);let R=e=>{e.status===om.INVALID?E(e.errorKey):e.status===om.CONFIRM_NAME&&O({suggested:e.suggested,original:e.original})};if(n===E9.VIDEO)return(0,K.jsx)(Kbe,{engine:e,maxSeconds:d,assessmentId:t,questionId:p,submittedTake:f,disabled:r,strings:o});if(n===E9.PHONE)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(zve,{countries:k,defaultCountryCode:A5({candidateCountryCode:c,region:l}),disabled:r||k.length===0,countryLabel:o.phoneCountryLabel,inputLabel:o.phoneInputLabel,placeholder:o.phonePlaceholder,sendLabel:o.sendLabel,onSubmit:(t,n)=>void e.submitPhoneAnswer(t,n).then(R)}),(0,K.jsx)(G9,{errorKey:T,strings:o,onClose:()=>E(null)})]});if(n===E9.LOCATION)return(0,K.jsx)(Rve,{suggestions:L.suggestions.map(e=>({id:e.placeId,label:e.description,mainText:e.mainText,secondaryText:e.secondaryText})),manualMode:L.manualMode,disabled:r,initialText:m==null?void 0:m.text,placeholder:o.locationPlaceholder,inputLabel:o.locationInputLabel,sendLabel:o.sendLabel,suggestionsLabel:o.locationSuggestionsLabel,suggestionsAnnouncement:o.locationSuggestionsFound,onSearch:L.search,onSelectSuggestion:t=>{let n=L.suggestions.find(e=>e.placeId===t.id);n&&(L.clear(),L.resolve(n).then(n=>e.submitLocationAnswer(n==null?{address:t.label,coordinate:null}:n)))},onSubmitText:t=>void e.submitLocationAnswer({address:t,coordinate:null})});let z=n===E9.EMAIL?t=>void e.submitEmailAnswer(t).then(R):n===E9.NAME?t=>void e.submitNameAnswer(t).then(R):n=>{h&&Xm(t),e.submitTextAnswer(_&&n.trim().length===0?li:n)},ee=n===E9.TEXT&&!_,B=ee?i.min:void 0;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cbe,{onSubmit:z,allowPaste:g,allowEmptySubmit:_,onBlockedPaste:v,disabled:r,autoComplete:n===E9.EMAIL?`email`:n===E9.NAME?`name`:void 0,initialText:(S=m==null?void 0:m.text)==null?F:S,initialMarkdown:ee?(C=m==null?void 0:m.text)==null?F:C:void 0,onDraftChange:h?I:void 0,focusOnOpen:y,minWords:B,maxWords:ee?i.max:void 0,recommendedWords:ee?i.recommend:void 0,onBelowMinimum:N?void 0:(e,t)=>M(()=>t),placeholder:n===E9.EMAIL?o.emailPlaceholder:_?o.feedbackCommentPlaceholder:ee&&g?o.inputPlaceholderPaste:o.inputPlaceholder,inputLabel:o.inputLabel,sendLabel:o.sendLabel,wordCountLabel:ee?o.wordCount:void 0,shortResponseHint:B===void 0?void 0:o.shortResponseHint(B),goodResponseHint:ee?o.goodResponseHint:void 0,maxWordsHint:ee?o.maxWordsHint:void 0,footer:o.composerFooter,richText:ee,toolbarLabels:{toolbar:o.richToolbar,bulletList:o.richBulletList,numberList:o.richNumberList,expand:o.composerExpand,collapse:o.composerCollapse},expanded:b,onExpandedChange:x}),(0,K.jsx)(G9,{errorKey:T,strings:o,onClose:()=>E(null)}),j&&B!==void 0?(0,K.jsx)(qbe,{strings:o,minWords:B,recommendedWords:i.recommend,onEdit:()=>M(null),onContinue:()=>{j(),M(null)},onDontShowAgainChange:e=>{P(e),Zee(t,e)}}):null,D?(0,K.jsx)(x5,{open:!0,title:o.nameConfirmTitle,actions:[{label:o.useSuggestedLabel(D.suggested),onClick:()=>{let t=D.suggested;O(null),e.submitNameConfirmed(t)}},{label:o.useOriginalLabel,variant:vh.GHOST,onClick:()=>{let t=D.original;O(null),e.submitNameConfirmed(t)}}],children:o.nameConfirmBody(D.suggested)}):null]})},Kbe=({engine:e,maxSeconds:t,assessmentId:n,questionId:r,submittedTake:i,disabled:o,strings:c})=>{let{state:l,videoRef:u,camOn:d,micOn:f,countdown:p,takesUsed:m,maxAttempts:h,reviewUrl:g,reviewingSubmitted:_,retaking:v,openCamera:y,beginCountdown:b,stopRecording:x,reRecord:S,toggleCamera:C,toggleMicrophone:T}=Wbe(t,{takes:(0,w.useMemo)(()=>r?{assessmentId:n,questionId:r}:void 0,[n,r]),submittedTake:i}),E=l.phase===O5.REVIEW?m:m+1;return(0,K.jsx)(ube,{phase:l.phase,elapsedSeconds:l.elapsedSeconds,maxSeconds:t,hasResult:!!l.result,showPreview:!0,videoRef:u,disabled:o,camOn:d,micOn:f,countdown:p,attemptsLabel:c.videoAttempts(Math.min(E,h),h),canRetake:m<h,reviewingSubmitted:_,retaking:v,reviewUrl:g,labels:{openCamera:c.videoOpenCamera,startRecording:c.videoStartRecording,stopRecording:c.videoStopRecording,reRecord:c.videoReRecord,submit:c.videoSubmit,keep:c.videoKeep,cameraError:c.videoCameraError,preview:c.videoPreview,camera:c.videoCamera,microphone:c.videoMicrophone,on:c.videoOn,off:c.videoOff,finishHint:c.videoFinishHint,cameraOff:c.videoCameraOff,recordingStarted:c.videoRecordingStarted,recordingStopped:c.videoRecordingStopped,secondsRemaining:c.videoSecondsRemaining(t-l.elapsedSeconds)},onOpenCamera:y,onBeginCountdown:b,onStopRecording:x,onReRecord:S,onToggleCamera:C,onToggleMicrophone:T,onSubmit:()=>{_?e.cancelEditMode():l.result&&e.submitVideoAnswer(l.result.blob,l.result.extension)}})},G9=({errorKey:e,strings:t,onClose:n})=>e?(0,K.jsx)(x5,{open:!0,title:t.piiError(e),actions:[{label:t.editLabel,onClick:n}],onClose:n}):null,qbe=({strings:e,minWords:t,recommendedWords:n,onEdit:r,onContinue:i,onDontShowAgainChange:o})=>(0,K.jsxs)(x5,{open:!0,title:e.shortAnswerTitle(t),actions:[{label:e.editLabel,onClick:r},{label:e.continueLabel,variant:vh.GHOST,onClick:i}],children:[(0,K.jsx)(`p`,{children:(0,K.jsx)(rv,{flow:nv.INLINE,children:e.shortAnswerAim(t,n)})}),(0,K.jsx)(`p`,{className:`sc:mt-2`,children:e.shortAnswerEditAnytime}),(0,K.jsx)(`p`,{className:`sc:mt-2`,children:e.shortAnswerEditNow}),(0,K.jsxs)(`label`,{className:`sc:mt-3 sc:flex sc:items-center sc:gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,onChange:e=>o(e.target.checked),className:`sc:size-4 sc:accent-button`}),e.dontShowAgainLabel]})]}),K9={[xr.FULL_NAME]:{label:`ci_pii_label_fullName`,placeholder:`ci_pii_placeholder_fullName`},[xr.FIRST_NAME]:{label:`ci_pii_label_firstName`,placeholder:`ci_pii_placeholder_firstName`},[xr.LAST_NAME]:{label:`ci_pii_label_lastName`,placeholder:`ci_pii_placeholder_lastName`},[xr.EMAIL]:{label:`ci_pii_label_email`,placeholder:`fi_placeholder_demoEmailInput`},[xr.LOCATION]:{label:`ci_pii_label_location`,placeholder:`ci_location_placeholder`},[xr.PHONE_NUMBER]:{label:`ci_pii_label_phone`,placeholder:`ci_phone_placeholder`}},Jbe={[xr.FULL_NAME]:`ci_pii_row_name`,[xr.FIRST_NAME]:`ci_pii_row_firstName`,[xr.LAST_NAME]:`ci_pii_row_lastName`,[xr.EMAIL]:`ci_pii_row_email`,[xr.LOCATION]:`ci_pii_row_location`,[xr.PHONE_NUMBER]:`ci_pii_row_phone`},Ybe={[kr.INTERVIEW]:B6.TEXT,[kr.VIDEO]:B6.VIDEO,[kr.ADDITIONAL]:B6.CHOICE,[kr.DEI]:B6.PEOPLE},Xbe={[kr.INTERVIEW]:{label:`fi_label_summaryRowInterview`,description:`fi_label_summaryRowInterviewDescription`},[kr.VIDEO]:{label:`fi_label_summaryRowVideo`,description:`fi_label_summaryRowVideoDescription`},[kr.ADDITIONAL]:{label:`fi_label_summaryRowAdditional`,description:`fi_label_summaryRowAdditionalDescription`},[kr.DEI]:{label:`fi_label_summaryRowDei`,description:`fi_label_summaryRowDeiDescription`}},Zbe=e=>({headerTitle:e(`ci_header_title`),videoBadge:e(`ci_video_badge`),typingLabel:e(`ci_typing`),typingLoading:e(`ci_label_loadingNextPrompt`),scrollToLatest:e(`ci_scroll_to_latest`),progressLabel:e(`ci_progress_label`),writtenQuestionCounter:(t,n)=>e(`ci_written_question_counter`,{current:t,total:n}),quickAdditionalQuestionCounter:(t,n)=>e(`ci_quick_additional_question_counter`,{current:t,total:n}),videoQuestionCounter:(t,n)=>e(`ci_video_question_counter`,{current:t,total:n}),diversityCounter:(t,n)=>e(`ci_diversity_counter`,{current:t,total:n}),pauseHint:e(`ci_pause_hint`),copyLinkLabel:e(`fi_button_copyLink`),copiedLabel:e(`fi_tooltip_copiedUrl`),welcomeGreeting:t=>t?e(`ci_welcome_greeting`,{name:t}):e(`ci_welcome_greeting_generic`),welcomeTitle:e(`ci_welcome_title`),welcomeEyebrow:e(`ci_welcome_eyebrow`),welcomeCopyResume:e(`ci_welcome_copy_resume`),welcomeIntro:(t,n)=>t&&n?e(`ci_welcome_intro`,{role:t,company:n}):e(`ci_welcome_intro_generic`),welcomePause:e(`ci_welcome_pause`),welcomeNext:e(`fi_button_next`),welcomeReassurance:e(`ci_welcome_reassurance`),summaryTotal:e(`fi_label_summaryTotal`),summaryCount:(t,n)=>e(`fi_label_summaryQuestionCount`,{totalQuestions:t,estimatedMinutes:n}),summaryCategory:(t,n)=>{let r=Xbe[t];return r?{label:e(r.label,{count:n}),description:e(r.description,{maxRetries:5}),kind:Ybe[t]}:{label:String(n),description:``,kind:B6.GENERIC}},composerFooter:e(`ci_composer_footer`),richToolbar:e(`ci_rich_toolbar`),richBulletList:e(`ci_rich_bullet_list`),richNumberList:e(`ci_rich_number_list`),composerExpand:e(`ci_composer_expand`),composerCollapse:e(`ci_composer_collapse`),inputPlaceholder:e(`fi_label_enterResponse`),inputPlaceholderPaste:e(`fi_label_enterOrPasteResponse`),feedbackCommentPlaceholder:e(`fi_label_enterOrSkipFeedback`),inputLabel:e(`ci_input_label`),sendLabel:e(`ci_button_send`),retryLabel:e(`fi_button_retry`),editLabel:e(`fi_button_edit`),cancelEditLabel:e(`fi_label_cancelEditDesktop`),editingLabel:e(`fi_label_editing`),editBannerLabel:e(`ci_edit_banner`),videoRetryBannerLabel:e(`ci_video_retry_banner`),optionsGroupLabel:e(`ci_options_group`),selectionInstruction:(t,n)=>t===gte.UP_TO_MAX?e(`ci_label_selectMax`,{max:String(n)}):e(`ci_label_selectAllThatApply`),selectionCount:(t,n)=>e(`ci_label_selectionCount`,{selected:String(t),max:String(n)}),confirmSelectionsLabel:e(`ci_button_confirm`),hintExpand:e(`fi_button_readFullBrief`),hintCollapse:e(`fi_button_showLess`),showMore:e(`fi_button_showMore`),showLess:e(`fi_button_showLess`),senderAgent:e(`ci_sender_agent`),senderCandidate:e(`ci_sender_candidate`),opensNewTab:e(`ci_opens_new_tab`),widgetLabel:e(`ci_widget_label`),sliderLabel:e(`fi_label_ratingMessage`),submitRatingLabel:e(`fi_button_submitRating`),dropdownSearchPlaceholder:e(`fi_placeholder_dropdown`),dropdownSearchLabel:e(`ci_dropdown_search_label`),emailPlaceholder:e(`fi_placeholder_demoEmailInput`),phoneCountryLabel:e(`ci_phone_country_label`),phoneInputLabel:e(`ci_pii_label_phone`),phonePlaceholder:e(`ci_phone_placeholder`),locationInputLabel:e(`ci_location_input_label`),locationPlaceholder:e(`ci_location_placeholder`),locationSuggestionsLabel:e(`ci_location_suggestions_label`),locationSuggestionsFound:t=>e(`ci_location_suggestions_found`,{count:t}),nameConfirmTitle:e(`ci_name_confirm_title`),nameConfirmBody:t=>e(`ci_name_confirm_body`,{suggested:t}),useSuggestedLabel:t=>e(`ci_name_use_suggested`,{suggested:t}),useOriginalLabel:e(`ci_name_use_original`),wordCount:t=>e(`fi_label_words`,{count:t}),shortResponseHint:t=>e(`fi_alt_shortResponse`,{minWordCount:t}),goodResponseHint:e(`fi_alt_goodResponse`),maxWordsHint:e(`fi_alt_maxWords`),shortAnswerTitle:t=>e(`fi_error_notEnoughWords`,{minWordCount:t}),shortAnswerAim:(t,n)=>n===void 0?e(`fi_error_notEnoughWordsMin`,{minWordCount:t}):e(`fi_error_notEnoughWordsAim`,{minWordCount:t,recommendedWordCount:n}),shortAnswerEditAnytime:e(`fi_error_notEnoughWordsEdit`),shortAnswerEditNow:e(`fi_error_notEnoughWordsEditNow`),dontShowAgainLabel:e(`fi_check_dontShow`),continueLabel:e(`fi_button_continue`),loadingLabel:e(`ci_loading`),preparingLabel:e(`ci_preparing`),doneTitle:e(`ci_done_title`),doneSubtitle:t=>t?e(`ci_done_subtitle`,{name:t}):e(`ci_done_subtitle_generic`),doneNextLabel:e(`ci_done_next_label`),doneSteps:[e(`ci_done_step1`),e(`ci_done_step2`),e(`ci_done_step3`)],doneAck:e(`ci_done_ack`),doneRedirect:e(`fi_button_continue`),startFailedMessage:e(`ci_start_failed`),cohortClosedTitle:e(`fi_error_cohortClosedTitle`),cohortClosedMessage:e(`fi_error_cohortClosedMessage`),notFoundTitle:e(`ci_assessment_not_found_title`),notFoundMessage:e(`ci_assessment_not_found_message`),piiError:t=>e(t),piiIntro:e(`fi_label_collectDetailsIntro`),piiDetailsTitle:e(`fi_label_yourDetails`),piiAnsweredTitle:e(`fi_label_yourDetails`),piiSmsTitle:e(`ci_pii_row_sms`),piiPhoneTitle:e(`ci_pii_label_phone`),piiReviewTitle:e(`ci_pii_review_title`),piiReviewWarning:e(`fi_label_reviewDetailsWarning`),piiBack:e(`ci_pii_back`),piiNext:e(`fi_button_next`),piiContinue:e(`fi_button_continue`),piiAccept:e(`fi_button_accept`),piiSmsRowLabel:e(`ci_pii_row_sms`),piiSmsConsented:e(`ci_pii_sms_consented`),piiSmsDeclined:e(`ci_pii_sms_declined`),piiFieldLabel:t=>{var n,r;return e((n=(r=K9[t])==null?void 0:r.label)==null?t:n)},piiFieldPlaceholder:t=>{var n,r;return e((n=(r=K9[t])==null?void 0:r.placeholder)==null?t:n)},piiRowLabel:t=>{var n;return e((n=Jbe[t])==null?t:n)},csatIntro:e(`ci_csat_intro`),csatTitle:e(`ci_csat_title`),csatSubtitle:e(`ci_csat_subtitle`),csatScaleLabel:(t,n)=>e(`ci_csat_scale_label`,{min:t,max:n}),csatLow:e(`ci_csat_low`),csatHigh:e(`ci_csat_high`),csatCommentLabel:e(`ci_csat_comment_label`),csatCommentPlaceholder:e(`ci_csat_comment_placeholder`),csatSubmit:e(`ci_csat_submit`),csatAnswerRating:(t,n)=>e(`ci_csat_answer_rating`,{rating:t,max:n}),csatAnswerComment:t=>e(`ci_csat_answer_comment`,{comment:t}),deiTitle:e(`ci_dei_title`),deiSubmit:e(`ci_dei_submit`),videoOpenCamera:e(`ci_video_open_camera`),videoStartRecording:e(`fi_button_record`),videoStopRecording:e(`fi_button_stop`),videoReRecord:e(`ci_video_re_record`),videoSubmit:e(`ci_video_submit`),videoKeep:e(`ci_video_keep`),videoCameraError:e(`ci_video_camera_error`),videoPreview:e(`ci_video_preview`),videoCamera:e(`ci_video_camera`),videoMicrophone:e(`ci_video_microphone`),videoOn:e(`ci_video_on`),videoOff:e(`ci_video_off`),videoFinishHint:e(`ci_video_finish_hint`),videoCameraOff:e(`ci_video_camera_off`),videoRecordingStarted:e(`ci_video_recording_started`),videoRecordingStopped:e(`ci_video_recording_stopped`),videoSecondsRemaining:t=>e(`ci_video_seconds_remaining`,{seconds:t}),videoAttempts:(t,n)=>e(`ci_video_attempts`,{current:t,max:n}),videoUploadProgress:e(`fi_label_uploading`),videoUploadFailed:e(`fi_label_uploadFailed`),videoRetryUpload:e(`ci_video_retry_upload`),videoPlay:e(`ci_video_play`),videoAnswer:e(`ci_video_answer`),embeddedVideoLabel:e(`ci_video_embed_label`),accessTitle:e(`ci_access_title`),accessDescription:e(`ci_access_description`),accessInputLabel:e(`ci_pii_label_email`),accessSubmit:e(`fi_button_continue`),accessMismatch:e(`fi_error_emailDoesNotMatch`),agcTitle:e(`fi_error_agcTitle`),agcMessage:t=>e(t>=2?`fi_error_agcSecondMessage`:`fi_error_agcFirstMessage`),agcEdit:e(`fi_button_edit`),agcContinue:e(`fi_button_continue`),agcGuidanceTitle:e(`fi_agc_guidance_header`),agcGuidanceBody:e(`fi_agc_guidance_body`),agcGuidanceCheckbox:e(`fi_agc_guidance_checkbox`),agcGuidanceTip:e(`fi_agc_guidance_tip`),agcGuidanceCta:e(`fi_agc_guidance_cta`),editFailedTitle:e(`fi_error_generalErrorTitle`),editFailedMessage:e(`fi_label_checkInternetCon`),editFailedDismiss:e(`fi_button_ok`)}),Qbe=e=>{(0,w.useEffect)(()=>{if(!e)return;let t=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e])},$be=e=>{(0,w.useEffect)(()=>{let t=()=>{document.visibilityState===`visible`&&e.checkSessionExpiry()};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e])},exe=({engine:e,fields:t,strings:n})=>{var r;let i=(r=t[0])==null?void 0:r.questionId,[o,c]=(0,w.useState)({runId:i,rating:8,comment:``});o.runId!==i&&c({runId:i,rating:8,comment:``});let l=(0,w.useCallback)(e=>c(t=>({...t,rating:e})),[]),u=(0,w.useCallback)(e=>c(t=>({...t,comment:e})),[]),d=(0,w.useCallback)(()=>{e.submitCustomerSatisfactionForm({rating:o.rating,comment:o.comment})},[e,o.rating,o.comment]);return{labels:(0,w.useMemo)(()=>({title:n.csatTitle,subtitle:n.csatSubtitle,scaleLabel:n.csatScaleLabel(1,10),low:n.csatLow,high:n.csatHigh,commentLabel:n.csatCommentLabel,commentPlaceholder:n.csatCommentPlaceholder,submit:n.csatSubmit}),[n]),min:1,max:10,rating:o.rating,comment:o.comment,onRatingChange:l,onCommentChange:u,onSubmit:d}},q9={},txe=(e,t,n)=>{if(!oh(e.questionTypes,e.rules))return[n];if(t.includes(n))return t.filter(e=>e!==n);let{max:r}=ih(e.rules);return r!==void 0&&t.length>=r?t:[...t,n]},nxe=({engine:e,fields:t,strings:n})=>{var r;let i=(r=t[0])==null?void 0:r.questionId,[o,c]=(0,w.useState)({runId:i,answers:q9});o.runId!==i&&c({runId:i,answers:q9});let l=(0,w.useCallback)((e,n)=>{let r=t.find(t=>t.questionId===e);r&&c(t=>{var i;return{...t,answers:{...t.answers,[e]:txe(r,(i=t.answers[e])==null?[]:i,n)}}})},[t]),u=(0,w.useCallback)(()=>{e.submitDemographicForm(o.answers)},[e,o.answers]),d=(0,w.useMemo)(()=>t.map(e=>{var t,r;let i=((t=e.options)==null?[]:t).map(({id:e,text:t})=>({id:e,text:t})),c=(r=o.answers[e.questionId])==null?[]:r;if(!oh(e.questionTypes,e.rules))return{questionId:e.questionId,prompt:e.prompt,options:i,selectedOptionIds:c,multi:!1};let l=ih(e.rules);return{questionId:e.questionId,prompt:e.prompt,options:i,selectedOptionIds:c,multi:!0,instruction:n.selectionInstruction(sh(l,i.length),l.max),...l.max===void 0?{}:{countLabel:n.selectionCount(c.length,l.max),capReached:c.length>=l.max}}}),[t,o.answers,n]),f=t.length>0&&t.every(e=>{var t,n;return((t=(n=o.answers[e.questionId])==null?void 0:n.length)==null?0:t)>=ih(e.rules).min});return{questions:d,title:n.deiTitle,submitLabel:n.deiSubmit,canSubmit:f,onToggle:l,onSubmit:u}},rxe={[xr.FULL_NAME]:h6.NAME,[xr.FIRST_NAME]:h6.NAME,[xr.LAST_NAME]:h6.NAME,[xr.EMAIL]:h6.EMAIL,[xr.LOCATION]:h6.LOCATION,[xr.PHONE_NUMBER]:h6.PHONE},J9=(e,t=null)=>JSON.stringify({address:e,coordinate:t}),ixe=({engine:e,fields:t,strings:n,placesApiKey:r,candidateCountryCode:i,region:o})=>{var c;let l=W9({apiKey:r}),[u,d]=(0,w.useState)([]),f=!!M6(t);(0,w.useEffect)(()=>{if(!f)return;let e=!0;return k5().then(t=>{e&&d(t)}),()=>{e=!1}},[f]);let p=(0,w.useMemo)(()=>Xhe(t),[t]),[m,h]=(0,w.useState)(0),[g,_]=(0,w.useState)({}),[v,y]=(0,w.useState)({}),[b,x]=(0,w.useState)(),[S,C]=(0,w.useState)(()=>A5({candidateCountryCode:i,region:o})),[T,E]=(0,w.useState)(),D=(c=p[m])==null?T6.REVIEW:c,O=(b==null?void 0:b.value)===E6.YES,k=(0,w.useMemo)(()=>p.filter(e=>e!==T6.PHONE||O),[p,O]),A=Yhe((0,w.useMemo)(()=>{if(D===T6.DETAILS)return A6(t).filter(k6);let e=M6(t);return D===T6.PHONE&&e?[e]:[]},[D,t]),g),j=(0,w.useCallback)(e=>h(p.indexOf(e)),[p]),M=(0,w.useCallback)(e=>{var t;j((t=k[k.indexOf(e)+1])==null?T6.REVIEW:t)},[k,j]),N=(0,w.useCallback)((e,t)=>{_(n=>({...n,[e]:t})),y(t=>t[e]?Object.fromEntries(Object.entries(t).filter(([t])=>t!==e)):t)},[]),P=(0,w.useCallback)((e,n)=>{N(e,n);let r=t.find(t=>t.questionId===e);(r==null?void 0:r.piiType)===xr.LOCATION&&(E(void 0),l.search(n))},[t,N,l]),F=(0,w.useCallback)(e=>{let n=t.find(e=>e.piiType===xr.LOCATION),r=l.suggestions.find(t=>t.placeId===e.id);!n||!r||(l.clear(),N(n.questionId,e.label),l.resolve(r).then(t=>{var n,r;return E(J9((n=t==null?void 0:t.address)==null?e.label:n,(r=t==null?void 0:t.coordinate)==null?null:r))}))},[t,l,N]),I=(0,w.useCallback)(async e=>{let t=await Promise.all(e.map(async e=>{var t;return{field:e,result:await Zhe(e,(t=g[e.questionId])==null?``:t,S)}})),r=t.filter(e=>!e.result.ok);return y(Object.fromEntries(r.map(e=>[e.field.questionId,n.piiError(e.result.ok?``:e.result.errorKey)]))),r.length>0?!1:(_(e=>({...e,...Object.fromEntries(t.filter(e=>e.result.ok).map(e=>[e.field.questionId,e.result.ok?e.result.text:``]))})),!0)},[g,S,n]),L=(0,w.useCallback)(()=>{let e=[];for(let r of t){var n;if(r.kind===`SMS_CONSENT`){b&&e.push({questionId:r.questionId,text:b.text,value:b.value});continue}if(r.piiType===xr.PHONE_NUMBER&&!O)continue;let t=((n=g[r.questionId])==null?``:n).trim();t.length!==0&&e.push({questionId:r.questionId,text:t,value:r.piiType===xr.LOCATION?T==null?J9(t):T:t})}return e},[t,g,b,O,T]),R=(0,w.useCallback)(async()=>{if(D===T6.DETAILS){if(!await I(A6(t)))return;M(T6.DETAILS);return}if(D===T6.PHONE){let e=M6(t);if(e&&!await I([e]))return;M(T6.PHONE);return}await e.submitPiiForm(L())},[D,t,I,M,e,L]),z=(0,w.useCallback)(e=>{x(e),j(e.value===E6.YES&&M6(t)?T6.PHONE:T6.REVIEW)},[t,j]),ee=(0,w.useCallback)(()=>{let e=k[k.indexOf(D)-1];e&&j(e)},[k,D,j]),B=(0,w.useMemo)(()=>t.filter(e=>e.piiType!=null).filter(e=>e.piiType!==xr.PHONE_NUMBER||O).map(e=>{var t;return{label:n.piiRowLabel(e.piiType),value:((t=g[e.questionId])==null?``:t).trim()}}).filter(e=>e.value.length>0),[t,g,O,n]),V=(0,w.useMemo)(()=>l.suggestions.map(e=>({id:e.placeId,label:e.description,mainText:e.mainText,secondaryText:e.secondaryText})),[l.suggestions]);return{fields:t,labels:(0,w.useMemo)(()=>({detailsTitle:n.piiDetailsTitle,smsTitle:n.piiSmsTitle,phoneTitle:n.piiPhoneTitle,reviewTitle:n.piiReviewTitle,reviewWarning:n.piiReviewWarning,back:n.piiBack,next:n.piiNext,continue:n.piiContinue,accept:n.piiAccept,phoneCountry:n.phoneCountryLabel,phonePlaceholder:n.phonePlaceholder,locationSuggestions:n.locationSuggestionsLabel,locationSuggestionsFound:n.locationSuggestionsFound,smsRowLabel:n.piiSmsRowLabel,fieldLabel:n.piiFieldLabel,fieldPlaceholder:n.piiFieldPlaceholder,rowLabel:n.piiRowLabel}),[n]),step:D,values:g,errors:v,canAdvance:A,reviewRows:B,phoneCountries:u,phoneCountryCode:S,locationSuggestions:V,locationManualMode:l.manualMode,onChange:P,onPhoneCountryChange:C,onLocationSelect:F,onBack:ee,onAdvance:R,onConsent:z}},axe=({entries:e,strings:t})=>[...e].sort((e,t)=>Number(e.piiType===null)-Number(t.piiType===null)).map(e=>e.piiType?{icon:rxe[e.piiType],label:t.piiRowLabel(e.piiType),value:e.text}:{icon:h6.SMS,label:t.piiSmsRowLabel,value:e.value===E6.YES?t.piiSmsConsented:t.piiSmsDeclined}),oxe=[],sxe=[],cxe=[],lxe=`Escape`,uxe=[Zr.BREAK,Zr.TERMS_CONSENT],dxe=({env:e,region:t,appId:n,assessmentId:r,apiOrigin:i,theme:o,showHeader:c=!0,isInternalUser:l,language:u,redirectUrl:d,placesApiKey:f,onEvent:p,emitter:m,fetchImpl:h})=>{var g,_,v;let[y]=(0,w.useState)(()=>{let o=new Kr({env:e,region:t,appId:n,apiOrigin:i,fetchImpl:h}),c=nte(),l=m==null?new C:m;return{store:c,engine:new Dte({client:o,store:c,emitter:l,assessmentId:r,language:Gee(u,typeof navigator<`u`?navigator.language:void 0),welcomeGate:!1,streamText:!1,streamRevealMs:S6()?0:void 0}),events:l}}),b=(0,w.useRef)(p);b.current=p,(0,w.useEffect)(()=>{let e=Object.values(S).map(e=>y.events.on(e,t=>{var n;return(n=b.current)==null?void 0:n.call(b,e,t)}));return()=>e.forEach(e=>e())},[y]);let x=(0,w.useRef)(!1);(0,w.useEffect)(()=>{x.current||(x.current=!0,y.engine.begin())},[y]),$be(y.engine);let T=(0,w.useMemo)(()=>kte(d),[d]);(0,w.useEffect)(()=>{d&&!T&&y.events.emit(S.LOG,{type:mte,message:`Invalid redirect URL: ${d}`})},[y,d,T]);let E=O(y.store,e=>e.phase),D=O(y.store,e=>e.bubbles),k=O(y.store,e=>e.typing),A=O(y.store,e=>e.streamingBubbleId),j=O(y.store,e=>e.sendingAnswer),M=O(y.store,e=>e.numOfNormalQuestion),N=O(y.store,e=>e.assessmentSummary),P=O(y.store,e=>e.assessmentLink),F=O(y.store,e=>e.piiForm),I=O(y.store,e=>e.csatForm),L=O(y.store,e=>e.deiForm),R=O(y.store,e=>e.candidateCountryCode),z=O(y.store,e=>e.editingQuestionId),ee=O(y.store,e=>e.multiSelectDraft),B=O(y.store,e=>e.translations),V=O(y.store,e=>e.language),H=O(y.store,e=>e.branding),te=O(y.store,e=>e.candidateName),ne=O(y.store,e=>e.jobTitle),re=O(y.store,e=>e.customerName),ie=O(y.store,e=>e.emailHint),ae=O(y.store,e=>e.accessEmailMismatch),oe=O(y.store,e=>e.verifyingAccess),se=O(y.store,e=>e.showAgcWarning),ce=O(y.store,e=>e.editFailedQuestionId),le=O(y.store,e=>e.agcAttempt),ue=O(y.store,e=>e.duplicated===!0||e.assessmentStatus!==void 0&&ci.includes(e.assessmentStatus)),de=O(y.store,e=>e.terminalMessage),U=(0,w.useMemo)(()=>Zbe(Nte(B,Ate)),[B]),fe=qee(V==null?Hm:V),pe=(0,w.useMemo)(()=>{let e=e=>{var t,n;return(t=N==null||(n=N.breakdown.find(t=>t.category===e))==null?void 0:n.count)==null?0:t};return{[Qr.WRITTEN]:e(kr.INTERVIEW),[Qr.QUICK]:e(kr.ADDITIONAL),[Qr.VIDEO]:e(kr.VIDEO),[Qr.DEI]:e(kr.DEI)}},[N]),me=(0,w.useMemo)(()=>Fbe(D,pe,{counter:{[Qr.WRITTEN]:U.writtenQuestionCounter,[Qr.QUICK]:U.quickAdditionalQuestionCounter,[Qr.VIDEO]:U.videoQuestionCounter,[Qr.DEI]:U.diversityCounter},videoBadge:U.videoBadge}),[D,pe,U]),he=(0,w.useMemo)(()=>jbe(D,z),[D,z]),ge=(0,w.useMemo)(()=>{var e;if(!z)return;let t=T9(D,z);return t?(e=me.get(t.id))==null?void 0:e.label:void 0},[D,z,me]);(0,w.useEffect)(()=>{if(!z)return;let e=e=>{e.key!==lxe||e.defaultPrevented||document.querySelector(`[role="dialog"]`)||y.engine.cancelEditMode()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[z,y]);let _e=(0,w.useMemo)(()=>ri(D),[D]),ve=re,ye=(g=(_=ne==null?ve:ne)==null?H==null?void 0:H.title:_)==null?U.headerTitle:g,be=ne?ve:void 0,xe=(0,w.useMemo)(()=>({submitted:ue||E===Zm.COMPLETING}),[ue,E]),Se=ixe({engine:y.engine,fields:F==null?oxe:F,strings:U,placesApiKey:f,candidateCountryCode:R,region:t}),Ce=exe({engine:y.engine,fields:I==null?sxe:I,strings:U}),we=nxe({engine:y.engine,fields:L==null?cxe:L,strings:U}),Te=(0,w.useCallback)(e=>[...e.rating===void 0?[]:[U.csatAnswerRating(e.rating,10)],...e.comment?[U.csatAnswerComment(e.comment)]:[]],[U]),Ee=(0,w.useCallback)(e=>({title:U.piiAnsweredTitle,rows:axe({entries:e,strings:U})}),[U]),De=(0,w.useMemo)(()=>({instruction:U.selectionInstruction,count:U.selectionCount}),[U]),Oe=(0,w.useMemo)(()=>({draft:ee,labels:De}),[ee,De]),ke=(0,w.useMemo)(()=>Dbe(D,me,xe,A,Ee,Oe,Te),[D,me,xe,A,Ee,Oe,Te]),Ae=ke.find(e=>{var t;return e.optionsKind===v6.ACTION&&((t=e.options)==null?void 0:t[0])}),je=(0,w.useMemo)(()=>Ae?ke.filter(e=>e!==Ae):ke,[ke,Ae]),[Me,Ne]=(0,w.useState)(!1),Pe=(0,w.useMemo)(()=>kbe(D),[D]),[Fe,Ie]=(0,w.useState)(!1),Le=(0,w.useMemo)(()=>Abe(D),[D]),[Re,W]=(0,w.useState)(),ze=(0,w.useCallback)(e=>e===y6.PII_FORM_INTRO?U.piiIntro:e===y6.PII_FORM?F?(0,K.jsx)(age,{...Se,submitting:j}):null:e===y6.CUSTOMER_SATISFACTION_INTRO?U.csatIntro:e===y6.CUSTOMER_SATISFACTION_FORM?I?(0,K.jsx)(Whe,{...Ce,submitting:j}):null:e===y6.DEMOGRAPHIC_FORM?L?(0,K.jsx)(Khe,{...we,submitting:j}):null:e===y6.AGC_GUIDANCE?(0,K.jsx)(iv,{body:U.agcGuidanceBody,checkboxLabel:U.agcGuidanceCheckbox,checked:Pe?Me:!0,readOnly:!Pe,onCheckedChange:Ne}):e===y6.ASSESSMENT_SUMMARY?N?(0,K.jsx)(dge,{totalLabel:U.summaryTotal,countLabel:U.summaryCount(N.totalQuestions,N.estimatedMinutes),categories:N.breakdown.map(({category:e,count:t})=>U.summaryCategory(e,t)),opensNewTab:U.opensNewTab}):null:(0,K.jsx)(w5,{url:P,copyLabel:U.copyLinkLabel,copiedLabel:U.copiedLabel,withIcon:!0,className:`sc:w-fit ${ene}`}),[N,P,U,F,Se,I,Ce,L,we,j,Pe,Me]),Be=(0,w.useMemo)(()=>Ibe(D,z),[D,z]),Ve=Mbe(D,z),He=Ve==null?void 0:Ve.questionId,Ue=Ve==null?void 0:Ve.blob,We=Ve==null?void 0:Ve.extension,Ge=(0,w.useMemo)(()=>He?{blob:Ue,resolveUrl:We?()=>y.engine.getVideoPlaybackUrl(He,We):void 0}:void 0,[He,Ue,We,y]),Ke=(0,w.useMemo)(()=>zbe(D,z),[D,z]),qe=(0,w.useMemo)(()=>Rbe(D,z),[D,z]),Je=(0,w.useMemo)(()=>Hbe(D,z),[D,z]),[Ye]=(0,w.useState)(()=>l===!0||Ote()),G=(0,w.useMemo)(()=>qe!==E9.TEXT||Ye||Bbe(D,z),[qe,Ye,D,z]),Xe=(0,w.useMemo)(()=>Vbe(D,z),[D,z]),Ze=Obe(D,z),Qe=`${Ze==null?`none`:Ze}:${ce==null?``:ce}`,$e=qe===E9.TEXT&&!z?Ze:void 0,[et,tt]=(0,w.useState)(!1);(0,w.useEffect)(()=>tt(!1),[Qe]);let nt=(0,w.useMemo)(()=>({retry:U.retryLabel,optionsGroup:U.optionsGroupLabel,confirmSelections:U.confirmSelectionsLabel,edit:U.editLabel,editing:U.editingLabel,senderAgent:U.senderAgent,senderCandidate:U.senderCandidate,opensNewTab:U.opensNewTab,showMore:U.showMore,showLess:U.showLess}),[U]),rt=(0,w.useMemo)(()=>({expand:U.hintExpand,collapse:U.hintCollapse}),[U]),it=(0,w.useMemo)(()=>({label:U.sliderLabel,submitLabel:U.submitRatingLabel}),[U]),at=(0,w.useMemo)(()=>({searchPlaceholder:U.dropdownSearchPlaceholder,searchLabel:U.dropdownSearchLabel}),[U]),ot=(0,w.useMemo)(()=>({uploadProgress:U.videoUploadProgress,uploadFailed:U.videoUploadFailed,retryUpload:U.videoRetryUpload,playVideo:U.videoPlay,videoAnswer:U.videoAnswer,embeddedVideo:U.embeddedVideoLabel}),[U]),st=(0,w.useCallback)(()=>void y.engine.retryLastAnswer(),[y]),ct=(0,w.useCallback)(e=>void y.engine.submitOptionAnswer(e),[y]),lt=(0,w.useCallback)(e=>y.engine.toggleOptionSelection(e),[y]),ut=(0,w.useCallback)(()=>void y.engine.confirmSelections(),[y]),dt=(0,w.useCallback)(e=>void y.engine.submitSliderAnswer(e),[y]),ft=(0,w.useCallback)(e=>y.engine.enterEditMode(e),[y]),pt=(0,w.useCallback)(()=>y.engine.cancelEditMode(),[y]),mt=(0,w.useCallback)(()=>y.engine.reportPaste(),[y]),ht=(0,w.useCallback)(()=>void y.engine.retryVideoAnswer(),[y]),gt=(0,w.useCallback)((e,t)=>y.engine.getVideoPlaybackUrl(e,t),[y]),_t=k||A!==void 0,vt=E===Zm.ACTIVE||E===Zm.COMPLETING,yt=E===Zm.ACTIVE&&!_t&&!F&&!I&&!L&&(Lbe(D,z)||qe===E9.VIDEO),bt=yt&&!j,xt=E===Zm.ACTIVE&&!_t&&qe===E9.VIDEO&&!!Be,St=yt&&!xt,Ct=E===Zm.ACTIVE&&z?(0,K.jsx)(Hhe,{label:xt?U.videoRetryBannerLabel:U.editBannerLabel,questionLabel:ge,cancelLabel:U.cancelEditLabel,onCancel:pt,inline:!St}):null,wt=yt?(0,K.jsx)(Gbe,{expanded:et,onExpandedChange:tt,engine:y.engine,assessmentId:r,kind:qe,disabled:!bt,focusOnOpen:!0,wordCountRule:Ke,strings:U,candidateCountryCode:R,region:t,placesApiKey:f,maxVideoSeconds:Je,submittedVideo:Ge,videoQuestionId:Ze,draft:he,draftQuestionId:$e,allowPaste:G,isFeedbackComment:Xe,onBlockedPaste:mt},Qe):null;return Qbe(j),(0,K.jsxs)(Cve,{themeVariables:(0,w.useMemo)(()=>Qte(Rte(Lte(H,r),o)),[H,r,o]),dir:fe,lang:V==null?Hm:V,label:U.widgetLabel,children:[c&&vt?(0,K.jsx)(vve,{title:ye,subtitle:be,logoUrl:H==null?void 0:H.logoUrl}):null,vt?(0,K.jsx)(bve,{value:_e,max:M,label:U.progressLabel}):null,(0,K.jsxs)(`div`,{className:`sc:relative sc:flex sc:min-h-0 sc:flex-1 sc:flex-col`,children:[(0,K.jsxs)(`div`,{inert:et,className:`sc:flex sc:min-h-0 sc:flex-1 sc:flex-col`,children:[E===Zm.STARTING||E===Zm.IDLE||E===Zm.VERIFYING?(0,K.jsx)(yve,{label:U.preparingLabel}):null,E===Zm.WELCOME?(0,K.jsx)(Sve,{logoUrl:H==null?void 0:H.logoUrl,onNext:()=>void y.engine.confirmWelcome(),labels:{eyebrow:U.welcomeEyebrow,greeting:U.welcomeGreeting(te),intro:U.welcomeIntro(ne,ve),copyLinkResume:U.welcomeCopyResume,copied:U.copiedLabel,next:U.welcomeNext}}):null,E===Zm.ENDED?(0,K.jsx)(mve,{logoUrl:H==null?void 0:H.logoUrl,redirectUrl:T,redirectLabel:U.doneRedirect,labels:{title:U.doneTitle,subtitle:U.doneSubtitle(te),nextLabel:U.doneNextLabel,steps:U.doneSteps}}):null,E===Zm.COHORT_CLOSED?(0,K.jsx)(S5,{labels:{title:U.cohortClosedTitle,message:U.cohortClosedMessage}}):null,E===Zm.NOT_FOUND?(0,K.jsx)(S5,{labels:{title:U.notFoundTitle,message:U.notFoundMessage}}):null,E===Zm.TERMINAL_MESSAGE&&de?(0,K.jsx)(xve,{message:de}):null,E===Zm.ACCESS_REQUIRED?(0,K.jsx)(ove,{emailHint:ie,mismatch:ae,submitting:oe,labels:{title:U.accessTitle,description:U.accessDescription,inputLabel:U.accessInputLabel,submit:U.accessSubmit,mismatchError:U.accessMismatch},onSubmit:e=>void y.engine.verifyAccessEmail(e)}):null,E===Zm.FAILED?(0,K.jsx)(`p`,{role:`alert`,className:`sc:p-4 sc:text-sm sc:text-red-600`,children:U.startFailedMessage}):null,vt?(0,K.jsx)(Bhe,{items:je,typing:k,typingLabel:U.typingLabel,scrollToLatestLabel:U.scrollToLatest,typingLoadingLabel:U.typingLoading,bubbleLabels:nt,hintLabels:rt,sliderLabels:it,dropdownLabels:at,mediaLabels:ot,onRetry:st,onSelectOption:ct,onToggleOption:lt,onConfirmSelections:ut,onSubmitSlider:dt,onEdit:ft,onRetryVideo:ht,onResolveVideoUrl:gt,cardFooter:xt?wt:void 0,cardFooterItemId:xt?Be:void 0,editingFooter:St?void 0:Ct,renderCard:ze}):null,St?Ct:null]}),xt?null:wt,E===Zm.ACTIVE&&Ae&&!z?(0,K.jsx)(Sh,{label:Ae.options[0].text,enabled:!!Ae.optionsEnabled&&(!Pe||Me),pending:Ae.pending,triggerOnEnter:uxe.includes((v=D.find(e=>e.id===Ae.id))==null?void 0:v.questionRole),hint:Pe&&!Me?U.agcGuidanceTip:void 0,onClick:()=>{let e=Ae.options[0].id;Le&&!Fe?W(e):ct(e)}}):null,E===Zm.COMPLETING?T?(0,K.jsx)(Sh,{label:U.doneRedirect,href:T}):(0,K.jsx)(Sh,{label:U.doneAck,enabled:!0,onClick:()=>y.engine.acknowledgeCompletion()}):null]}),Re?(0,K.jsx)(sve,{title:U.agcGuidanceTitle,body:U.agcGuidanceBody,checkboxLabel:U.agcGuidanceCheckbox,ctaLabel:U.agcGuidanceCta,onAcknowledge:()=>{Ie(!0),W(void 0),ct(Re)}}):null,se?(0,K.jsx)(x5,{open:!0,title:U.agcTitle,actions:[{label:U.agcEdit,onClick:()=>y.engine.dismissAgcWarning()},{label:U.agcContinue,variant:vh.GHOST,onClick:()=>void y.engine.continueAfterAgcWarning()}],onClose:()=>y.engine.dismissAgcWarning(),children:U.agcMessage(le==null?0:le)}):null,ce?(0,K.jsx)(x5,{open:!0,title:U.editFailedTitle,actions:[{label:U.editFailedDismiss,onClick:()=>y.engine.dismissEditFailure()}],onClose:()=>y.engine.dismissEditFailure(),children:U.editFailedMessage}):null]})},Y9=`sapia-chatbot`,fxe=e=>{if(e instanceof HTMLElement)return e;let t=e==null?`#${Y9}`:e,n=document.querySelector(t);if(!n)throw Error(`Sapia chatbot container not found for selector "${t}"`);return n},X9=e=>{let t=new C,n=null,r=e.theme,i=()=>{n==null||n.render((0,K.jsx)(dxe,{...e,theme:r,emitter:t}))};return{mount(e){n=(0,x.createRoot)(fxe(e)),i()},unmount(){n==null||n.unmount(),n=null},setTheme(e){r=e,i()},on:(e,n)=>t.on(e,n)}},Z9=`sapiaChatBot`,pxe=2,mxe=500,hxe=`PHChatBot: assessmentId is required (cohortId / jobRequisitionShortcode / applicationShortcode generic links are served by the standalone SPA, not the embeddable widget).`,gxe=function(e){return e.FI_ASSESSMENT_ANSWER_SAVED=`FI_ASSESSMENT_ANSWER_SAVED`,e.FI_ASSESSMENT_ANSWER_EDITED=`FI_ASSESSMENT_ANSWER_EDITED`,e.FI_ASSESSMENT_STARTED=`FI_ASSESSMENT_STARTED`,e.FI_ASSESSMENT_ENDED=`FI_ASSESSMENT_ENDED`,e.FI_ASSESSMENT_DUPLICATED=`FI_ASSESSMENT_DUPLICATED`,e.CHATBOT_ERROR=`CHATBOT_ERROR`,e.CHATBOT_LOG=`CHATBOT_LOG`,e}({}),Q9=e=>e?{backgroundColor:e.backgroundColor,fontColor:e.fontColor}:void 0,$9=e=>({header:Q9(e.header),question:Q9(e.question),response:Q9(e.response),button:Q9(e.button)}),_xe={[S.ANSWER_SAVED]:`FI_ASSESSMENT_ANSWER_SAVED`,[S.ANSWER_EDITED]:`FI_ASSESSMENT_ANSWER_EDITED`,[S.ASSESSMENT_STARTED]:`FI_ASSESSMENT_STARTED`,[S.ASSESSMENT_ENDED]:`FI_ASSESSMENT_ENDED`,[S.ASSESSMENT_DUPLICATED]:`FI_ASSESSMENT_DUPLICATED`,[S.ERROR]:`CHATBOT_ERROR`,[S.LOG]:`CHATBOT_LOG`},vxe=async(e,t=pxe,n=mxe)=>{let r=t,i=e();for(;!i&&r>0;)--r,await new Promise(e=>setTimeout(e,n)),i=e();return i},yxe=class{constructor(e){this.callbacks={},this.theme={},this.chatbot=null,e.assessmentId||console.error(hxe),this.options=e}addCallbackHandler(e){this.callbacks={...this.callbacks,...e}}setTheme({theme:e}){var t;this.theme={...e},(t=this.chatbot)==null||t.setTheme($9(this.theme))}async attachChatBot(){var e;if(!this.options.assessmentId)return;let t=await vxe(()=>document.getElementById(Z9));if(!t){console.error(`PHChatBot: container #${Z9} not found`);return}this.chatbot=X9({env:this.options.env,region:this.options.region,appId:this.options.appId,assessmentId:this.options.assessmentId,apiOrigin:this.options.apiOrigin,showHeader:(e=this.options.showHeader)==null?!1:e,isInternalUser:this.options.isInternalUser,theme:$9(this.theme)});for(let e of Object.values(S))this.chatbot.on(e,t=>this.dispatch(e,t));this.chatbot.mount(t)}stopCallingApiWhenUnmount(){var e;(e=this.chatbot)==null||e.unmount(),this.chatbot=null}dispatch(e,t){let n=this.callbacks[_xe[e]];if(n){if(e===S.ASSESSMENT_DUPLICATED){n==null||n({duplicatedWithAssessmentLink:t.duplicatedWithAssessmentLink});return}n(t)}}};e.CHATBOT_CONTAINER_ID=Z9,e.CHATBOT_EVENTS=S,e.DEFAULT_CONTAINER_ID=Y9,e.PHChatBot=yxe,e.PHChatBotCallbackFunction=gxe,e.createChatbot=X9});
3787
+ `):n;if(o)return{text:o}},Mbe=(e,t)=>{var n,r;if(!t)return;let i=e.find(e=>g9(e)&&e.questionId===t);if(i)return{questionId:t,blob:i.videoBlob,extension:(n=i.videoExtension)==null?v9((r=i.data.answer)==null?void 0:r.value):n}},Nbe=[vr.FTQ,vr.MCQ,vr.MSQ,vr.BGQ,vr.DROPDOWN,vr.VIDEO],Pbe=e=>{var t;return e.sender===_r.AGENT&&((t=e.types)==null?[]:t).some(e=>Nbe.includes(e))&&ti(e)!==void 0&&!x9(e).includes(y6.PII_FORM_INTRO)},Fbe=(e,t,n)=>{let r=new Map,i=ni(e),o=e=>{let r=i.get(e.id);if(!r)return;let o=t[r.scale];if(!(!o||r.ordinal>o))return n.counter[r.scale](r.ordinal,o)};for(let t of e){var c;if(!Pbe(t))continue;let e=o(t),i=((c=t.types)==null?[]:c).includes(vr.VIDEO)?n.videoBadge:void 0;r.set(t.id,{...e?{label:e}:{},...i?{badge:i}:{}})}return r},Ibe=(e,t)=>{let n=e=>{var t;return((t=e.types)==null?[]:t).includes(vr.VIDEO)};if(t){var r;return(r=e.find(e=>e.sender===_r.AGENT&&e.questionId===t&&n(e)))==null?void 0:r.id}let i=T9(e);if(i)return n(i)?i.id:void 0},Lbe=(e,t)=>{var n;let r=T9(e,t);return!!(!(r==null||(n=r.types)==null)&&n.includes(vr.FTQ))},E9=function(e){return e.TEXT=`text`,e.EMAIL=`email`,e.NAME=`name`,e.PHONE=`phone`,e.LOCATION=`location`,e.VIDEO=`video`,e}({}),Rbe=(e,t)=>{var n;let r=T9(e,t);if(!(r==null||(n=r.types)==null)&&n.includes(vr.VIDEO))return`video`;switch(r==null?void 0:r.piiQuestionType){case xr.EMAIL:return`email`;case xr.PHONE_NUMBER:return`phone`;case xr.LOCATION:return`location`;case xr.FULL_NAME:case xr.FIRST_NAME:case xr.LAST_NAME:return`name`;default:return`text`}},D9=e=>{if(e===void 0)return;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:void 0},zbe=(e,t)=>{var n,r;let i=(n=(r=T9(e,t))==null?void 0:r.data.rules)==null?[]:n,o=e=>{var t;return D9((t=i.find(t=>t.name===e))==null?void 0:t.value)};return{min:o(gr.MIN_TEXT_LENGTH),recommend:o(gr.RECOMMENDED_TEXT_LENGTH),max:o(gr.MAX_TEXT_LENGTH)}},Bbe=(e,t)=>{var n;return Dee((n=T9(e,t))==null?void 0:n.data.tags)},Vbe=(e,t)=>{var n;return((n=T9(e,t))==null?void 0:n.messageIdentifier)===Cr.FEEDBACK_CUSTOMER_SATISFACTION_QUESTION},Hbe=(e,t)=>{var n,r,i;let o=D9((i=((n=(r=T9(e,t))==null?void 0:r.data.rules)==null?[]:n).find(e=>e.name===gr.MAX_VOICE_SECONDS))==null?void 0:i.value);return o==null?60:o},O9=d({fetchPlaceAnswer:()=>H9,fetchPlaceSuggestions:()=>V9}),k9,A9,j9,M9,N9,P9,F9,I9,L9,R9,z9,B9,V9,H9,U9=l((()=>{k9=`AIzaSyCWSAROQu-uLQmQ-fq0ip7aXHpBjPESaQQ`,A9=`https://places.googleapis.com/v1`,j9=`${A9}/places:autocomplete`,M9=`${A9}/places`,N9=`X-Goog-Api-Key`,P9=`X-Goog-FieldMask`,F9=`Content-Type`,I9=`application/json`,L9=[`suggestions.placePrediction.placeId`,`suggestions.placePrediction.text`,`suggestions.placePrediction.structuredFormat.mainText`,`suggestions.placePrediction.structuredFormat.secondaryText`].join(`,`),R9=[`id`,`formattedAddress`,`location`,`displayName`].join(`,`),z9=`en`,B9=async(e,t,{apiKey:n,signal:r,fetchImpl:i},o)=>{let c=await(i==null?globalThis.fetch:i)(e,{method:o?`POST`:`GET`,headers:{[N9]:n==null?k9:n,[P9]:t,...o?{[F9]:I9}:{}},body:o?JSON.stringify(o):void 0,signal:r});if(!c.ok)throw Error(`places request failed: ${c.status}`);return await c.json()},V9=async(e,t={})=>{var n;return e.trim()?((n=(await B9(j9,L9,t,{input:e,languageCode:z9})).suggestions)==null?[]:n).map(({placePrediction:e})=>{var t,n,r,i;return{placeId:e.placeId,description:e.text.text,mainText:(t=(n=e.structuredFormat)==null||(n=n.mainText)==null?void 0:n.text)==null?e.text.text:t,secondaryText:(r=(i=e.structuredFormat)==null||(i=i.secondaryText)==null?void 0:i.text)==null?``:r}}):[]},H9=async(e,t={})=>{let n=await B9(`${M9}/${e.placeId}`,R9,t);return{address:n.formattedAddress||e.description,coordinate:n.location?{lat:n.location.latitude,lng:n.location.longitude}:null}}})),Ube=500,W9=({apiKey:e})=>{let[t,n]=(0,w.useState)([]),[r,i]=(0,w.useState)(!1),o=(0,w.useRef)(null),c=(0,w.useRef)(null),l=(0,w.useRef)(e);return l.current=e,(0,w.useEffect)(()=>()=>{var e;o.current&&clearTimeout(o.current),(e=c.current)==null||e.abort()},[]),{suggestions:t,manualMode:r,search:(0,w.useCallback)(e=>{if(o.current&&clearTimeout(o.current),!e.trim()){n([]);return}o.current=setTimeout(()=>{var t;(t=c.current)==null||t.abort();let r=new AbortController;c.current=r,(async()=>{try{let{fetchPlaceSuggestions:t}=await Promise.resolve().then(()=>(U9(),O9)),i=await t(e,{apiKey:l.current,signal:r.signal});r.signal.aborted||n(i)}catch{if(r.signal.aborted)return;n([]),i(!0)}})()},Ube)},[]),clear:(0,w.useCallback)(()=>n([]),[]),resolve:(0,w.useCallback)(async e=>{try{let{fetchPlaceAnswer:t}=await Promise.resolve().then(()=>(U9(),O9));return await t(e,{apiKey:l.current})}catch{return i(!0),null}},[])}},Wbe=(e,{media:t=kve.VIDEO,takes:n,submittedTake:r}={})=>{let i=(0,w.useRef)(null),o=(0,w.useRef)(null),[c,l]=(0,w.useState)({phase:O5.IDLE,elapsedSeconds:0}),[u,d]=(0,w.useState)(!0),[f,p]=(0,w.useState)(!0),[m,h]=(0,w.useState)(null),[g,_]=(0,w.useState)(()=>Math.max(n?$ee(n.assessmentId,n.questionId):0,+!!r)),[v,y]=(0,w.useState)(null),[b,x]=(0,w.useState)(!!r),[S,C]=(0,w.useState)(null),[T,E]=(0,w.useState)(!1),D=(0,w.useRef)(!1);(0,w.useEffect)(()=>{let n=new Nve({maxSeconds:e,media:t,getStream:e=>navigator.mediaDevices.getUserMedia(e),createRecorder:(e,t)=>new MediaRecorder(e,t),isTypeSupported:e=>MediaRecorder.isTypeSupported(e),onChange:l});return o.current=n,()=>n.dispose()},[e,t]),(0,w.useEffect)(()=>{var e;let t=(e=o.current)==null?void 0:e.getStream();i.current&&t&&(c.phase===O5.PREVIEW||c.phase===O5.RECORDING)&&(i.current.srcObject=t)},[c.phase]),(0,w.useEffect)(()=>{var e;if(c.phase===O5.REVIEW&&(e=c.result)!=null&&e.blob){let e=URL.createObjectURL(c.result.blob);return y(e),()=>URL.revokeObjectURL(e)}y(null)},[c.phase,c.result]),(0,w.useEffect)(()=>{var e;if(!b||!r)return;if(r.blob){let e=URL.createObjectURL(r.blob);return C(e),()=>URL.revokeObjectURL(e)}let t=!1;return(e=r.resolveUrl)==null||e.call(r).then(e=>{t||C(e)},()=>{}),()=>{t=!0}},[b,r]),(0,w.useEffect)(()=>{c.phase!==O5.REVIEW||!c.result||_(n?ete(n.assessmentId,n.questionId):e=>e+1)},[c.phase,c.result,n]),(0,w.useEffect)(()=>{T&&(c.phase===O5.PREVIEW&&D.current?(D.current=!1,h(3)):(c.phase===O5.RECORDING||c.phase===O5.ERROR)&&E(!1))},[T,c.phase]),(0,w.useEffect)(()=>{if(m===null)return;if(m<=0){var e;h(null),(e=o.current)==null||e.startRecording();return}let t=setTimeout(()=>h(e=>(e==null?1:e)-1),1e3);return()=>clearTimeout(t)},[m]);let O=(0,w.useCallback)(()=>{var e;let t=(e=o.current)==null?void 0:e.getStream();d(e=>{let n=!e;return t==null||t.getVideoTracks().forEach(e=>{e.enabled=n}),n})},[]),k=(0,w.useCallback)(()=>{var e;let t=(e=o.current)==null?void 0:e.getStream();p(e=>{let n=!e;return t==null||t.getAudioTracks().forEach(e=>{e.enabled=n}),n})},[]),A=(0,w.useCallback)(()=>{x(!1),E(!0),D.current=!0;let e=o.current;e!=null&&e.getStream()?e.reset():e==null||e.openCamera()},[]);return{state:b?{...c,phase:O5.REVIEW}:c,videoRef:i,camOn:u,micOn:f,countdown:m,takesUsed:g,maxAttempts:5,reviewUrl:b?S:v,reviewingSubmitted:b,retaking:T,openCamera:(0,w.useCallback)(()=>{var e;(e=o.current)==null||e.openCamera()},[]),beginCountdown:(0,w.useCallback)(()=>h(3),[]),stopRecording:(0,w.useCallback)(()=>{var e;return(e=o.current)==null?void 0:e.stopRecording()},[]),reRecord:A,toggleCamera:O,toggleMicrophone:k}},Gbe=({engine:e,assessmentId:t,kind:n,disabled:r,wordCountRule:i,strings:o,candidateCountryCode:c,region:l,placesApiKey:u,maxVideoSeconds:d=60,submittedVideo:f,videoQuestionId:p,draft:m,draftQuestionId:h,allowPaste:g,isFeedbackComment:_,onBlockedPaste:v,focusOnOpen:y,expanded:b,onExpandedChange:x})=>{var S,C;let[T,E]=(0,w.useState)(null),[D,O]=(0,w.useState)(null),[k,A]=(0,w.useState)([]),[j,M]=(0,w.useState)(null),[N,P]=(0,w.useState)(()=>Xee(t)),[F]=(0,w.useState)(()=>h?Qee(t,h):void 0),I=(0,w.useCallback)(e=>{h&&(e.trim().length===0?Xm(t):Ym(t,h,e))},[t,h]),L=W9({apiKey:u});(0,w.useEffect)(()=>{if(n!==E9.PHONE)return;let e=!0;return k5().then(t=>{e&&A(t)}),()=>{e=!1}},[n]);let R=e=>{e.status===om.INVALID?E(e.errorKey):e.status===om.CONFIRM_NAME&&O({suggested:e.suggested,original:e.original})};if(n===E9.VIDEO)return(0,K.jsx)(Kbe,{engine:e,maxSeconds:d,assessmentId:t,questionId:p,submittedTake:f,disabled:r,strings:o});if(n===E9.PHONE)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(zve,{countries:k,defaultCountryCode:A5({candidateCountryCode:c,region:l}),disabled:r||k.length===0,countryLabel:o.phoneCountryLabel,inputLabel:o.phoneInputLabel,placeholder:o.phonePlaceholder,sendLabel:o.sendLabel,onSubmit:(t,n)=>void e.submitPhoneAnswer(t,n).then(R)}),(0,K.jsx)(G9,{errorKey:T,strings:o,onClose:()=>E(null)})]});if(n===E9.LOCATION)return(0,K.jsx)(Rve,{suggestions:L.suggestions.map(e=>({id:e.placeId,label:e.description,mainText:e.mainText,secondaryText:e.secondaryText})),manualMode:L.manualMode,disabled:r,initialText:m==null?void 0:m.text,placeholder:o.locationPlaceholder,inputLabel:o.locationInputLabel,sendLabel:o.sendLabel,suggestionsLabel:o.locationSuggestionsLabel,suggestionsAnnouncement:o.locationSuggestionsFound,onSearch:L.search,onSelectSuggestion:t=>{let n=L.suggestions.find(e=>e.placeId===t.id);n&&(L.clear(),L.resolve(n).then(n=>e.submitLocationAnswer(n==null?{address:t.label,coordinate:null}:n)))},onSubmitText:t=>void e.submitLocationAnswer({address:t,coordinate:null})});let z=n===E9.EMAIL?t=>void e.submitEmailAnswer(t).then(R):n===E9.NAME?t=>void e.submitNameAnswer(t).then(R):n=>{h&&Xm(t),e.submitTextAnswer(_&&n.trim().length===0?li:n)},ee=n===E9.TEXT&&!_,B=ee?i.min:void 0;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cbe,{onSubmit:z,allowPaste:g,allowEmptySubmit:_,onBlockedPaste:v,disabled:r,autoComplete:n===E9.EMAIL?`email`:n===E9.NAME?`name`:void 0,initialText:(S=m==null?void 0:m.text)==null?F:S,initialMarkdown:ee?(C=m==null?void 0:m.text)==null?F:C:void 0,onDraftChange:h?I:void 0,focusOnOpen:y,minWords:B,maxWords:ee?i.max:void 0,recommendedWords:ee?i.recommend:void 0,onBelowMinimum:N?void 0:(e,t)=>M(()=>t),placeholder:n===E9.EMAIL?o.emailPlaceholder:_?o.feedbackCommentPlaceholder:ee&&g?o.inputPlaceholderPaste:o.inputPlaceholder,inputLabel:o.inputLabel,sendLabel:o.sendLabel,wordCountLabel:ee?o.wordCount:void 0,shortResponseHint:B===void 0?void 0:o.shortResponseHint(B),goodResponseHint:ee?o.goodResponseHint:void 0,maxWordsHint:ee?o.maxWordsHint:void 0,richText:ee,toolbarLabels:{toolbar:o.richToolbar,bulletList:o.richBulletList,numberList:o.richNumberList,expand:o.composerExpand,collapse:o.composerCollapse},expanded:b,onExpandedChange:x}),(0,K.jsx)(G9,{errorKey:T,strings:o,onClose:()=>E(null)}),j&&B!==void 0?(0,K.jsx)(qbe,{strings:o,minWords:B,recommendedWords:i.recommend,onEdit:()=>M(null),onContinue:()=>{j(),M(null)},onDontShowAgainChange:e=>{P(e),Zee(t,e)}}):null,D?(0,K.jsx)(x5,{open:!0,title:o.nameConfirmTitle,actions:[{label:o.useSuggestedLabel(D.suggested),onClick:()=>{let t=D.suggested;O(null),e.submitNameConfirmed(t)}},{label:o.useOriginalLabel,variant:vh.GHOST,onClick:()=>{let t=D.original;O(null),e.submitNameConfirmed(t)}}],children:o.nameConfirmBody(D.suggested)}):null]})},Kbe=({engine:e,maxSeconds:t,assessmentId:n,questionId:r,submittedTake:i,disabled:o,strings:c})=>{let{state:l,videoRef:u,camOn:d,micOn:f,countdown:p,takesUsed:m,maxAttempts:h,reviewUrl:g,reviewingSubmitted:_,retaking:v,openCamera:y,beginCountdown:b,stopRecording:x,reRecord:S,toggleCamera:C,toggleMicrophone:T}=Wbe(t,{takes:(0,w.useMemo)(()=>r?{assessmentId:n,questionId:r}:void 0,[n,r]),submittedTake:i}),E=l.phase===O5.REVIEW?m:m+1;return(0,K.jsx)(ube,{phase:l.phase,elapsedSeconds:l.elapsedSeconds,maxSeconds:t,hasResult:!!l.result,showPreview:!0,videoRef:u,disabled:o,camOn:d,micOn:f,countdown:p,attemptsLabel:c.videoAttempts(Math.min(E,h),h),canRetake:m<h,reviewingSubmitted:_,retaking:v,reviewUrl:g,labels:{openCamera:c.videoOpenCamera,startRecording:c.videoStartRecording,stopRecording:c.videoStopRecording,reRecord:c.videoReRecord,submit:c.videoSubmit,keep:c.videoKeep,cameraError:c.videoCameraError,preview:c.videoPreview,camera:c.videoCamera,microphone:c.videoMicrophone,on:c.videoOn,off:c.videoOff,finishHint:c.videoFinishHint,cameraOff:c.videoCameraOff,recordingStarted:c.videoRecordingStarted,recordingStopped:c.videoRecordingStopped,secondsRemaining:c.videoSecondsRemaining(t-l.elapsedSeconds)},onOpenCamera:y,onBeginCountdown:b,onStopRecording:x,onReRecord:S,onToggleCamera:C,onToggleMicrophone:T,onSubmit:()=>{_?e.cancelEditMode():l.result&&e.submitVideoAnswer(l.result.blob,l.result.extension)}})},G9=({errorKey:e,strings:t,onClose:n})=>e?(0,K.jsx)(x5,{open:!0,title:t.piiError(e),actions:[{label:t.editLabel,onClick:n}],onClose:n}):null,qbe=({strings:e,minWords:t,recommendedWords:n,onEdit:r,onContinue:i,onDontShowAgainChange:o})=>(0,K.jsxs)(x5,{open:!0,title:e.shortAnswerTitle(t),actions:[{label:e.editLabel,onClick:r},{label:e.continueLabel,variant:vh.GHOST,onClick:i}],children:[(0,K.jsx)(`p`,{children:(0,K.jsx)(rv,{flow:nv.INLINE,children:e.shortAnswerAim(t,n)})}),(0,K.jsx)(`p`,{className:`sc:mt-2`,children:e.shortAnswerEditAnytime}),(0,K.jsx)(`p`,{className:`sc:mt-2`,children:e.shortAnswerEditNow}),(0,K.jsxs)(`label`,{className:`sc:mt-3 sc:flex sc:items-center sc:gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,onChange:e=>o(e.target.checked),className:`sc:size-4 sc:accent-button`}),e.dontShowAgainLabel]})]}),K9={[xr.FULL_NAME]:{label:`ci_pii_label_fullName`,placeholder:`ci_pii_placeholder_fullName`},[xr.FIRST_NAME]:{label:`ci_pii_label_firstName`,placeholder:`ci_pii_placeholder_firstName`},[xr.LAST_NAME]:{label:`ci_pii_label_lastName`,placeholder:`ci_pii_placeholder_lastName`},[xr.EMAIL]:{label:`ci_pii_label_email`,placeholder:`fi_placeholder_demoEmailInput`},[xr.LOCATION]:{label:`ci_pii_label_location`,placeholder:`ci_location_placeholder`},[xr.PHONE_NUMBER]:{label:`ci_pii_label_phone`,placeholder:`ci_phone_placeholder`}},Jbe={[xr.FULL_NAME]:`ci_pii_row_name`,[xr.FIRST_NAME]:`ci_pii_row_firstName`,[xr.LAST_NAME]:`ci_pii_row_lastName`,[xr.EMAIL]:`ci_pii_row_email`,[xr.LOCATION]:`ci_pii_row_location`,[xr.PHONE_NUMBER]:`ci_pii_row_phone`},Ybe={[kr.INTERVIEW]:B6.TEXT,[kr.VIDEO]:B6.VIDEO,[kr.ADDITIONAL]:B6.CHOICE,[kr.DEI]:B6.PEOPLE},Xbe={[kr.INTERVIEW]:{label:`fi_label_summaryRowInterview`,description:`fi_label_summaryRowInterviewDescription`},[kr.VIDEO]:{label:`fi_label_summaryRowVideo`,description:`fi_label_summaryRowVideoDescription`},[kr.ADDITIONAL]:{label:`fi_label_summaryRowAdditional`,description:`fi_label_summaryRowAdditionalDescription`},[kr.DEI]:{label:`fi_label_summaryRowDei`,description:`fi_label_summaryRowDeiDescription`}},Zbe=e=>({headerTitle:e(`ci_header_title`),videoBadge:e(`ci_video_badge`),typingLabel:e(`ci_typing`),typingLoading:e(`ci_label_loadingNextPrompt`),scrollToLatest:e(`ci_scroll_to_latest`),progressLabel:e(`ci_progress_label`),writtenQuestionCounter:(t,n)=>e(`ci_written_question_counter`,{current:t,total:n}),quickAdditionalQuestionCounter:(t,n)=>e(`ci_quick_additional_question_counter`,{current:t,total:n}),videoQuestionCounter:(t,n)=>e(`ci_video_question_counter`,{current:t,total:n}),diversityCounter:(t,n)=>e(`ci_diversity_counter`,{current:t,total:n}),pauseHint:e(`ci_pause_hint`),copyLinkLabel:e(`fi_button_copyLink`),copiedLabel:e(`fi_tooltip_copiedUrl`),welcomeGreeting:t=>t?e(`ci_welcome_greeting`,{name:t}):e(`ci_welcome_greeting_generic`),welcomeTitle:e(`ci_welcome_title`),welcomeEyebrow:e(`ci_welcome_eyebrow`),welcomeCopyResume:e(`ci_welcome_copy_resume`),welcomeIntro:(t,n)=>t&&n?e(`ci_welcome_intro`,{role:t,company:n}):e(`ci_welcome_intro_generic`),welcomePause:e(`ci_welcome_pause`),welcomeNext:e(`fi_button_next`),welcomeReassurance:e(`ci_welcome_reassurance`),summaryTotal:e(`fi_label_summaryTotal`),summaryCount:(t,n)=>e(`fi_label_summaryQuestionCount`,{totalQuestions:t,estimatedMinutes:n}),summaryCategory:(t,n,r)=>{let i=Xbe[t];return i?{label:e(i.label,{count:n}),description:e(i.description,{maxRetries:5,company:r==null?``:r}),kind:Ybe[t]}:{label:String(n),description:``,kind:B6.GENERIC}},richToolbar:e(`ci_rich_toolbar`),richBulletList:e(`ci_rich_bullet_list`),richNumberList:e(`ci_rich_number_list`),composerExpand:e(`ci_composer_expand`),composerCollapse:e(`ci_composer_collapse`),inputPlaceholder:e(`fi_label_enterResponse`),inputPlaceholderPaste:e(`fi_label_enterOrPasteResponse`),feedbackCommentPlaceholder:e(`fi_label_enterOrSkipFeedback`),inputLabel:e(`ci_input_label`),sendLabel:e(`ci_button_send`),retryLabel:e(`fi_button_retry`),editLabel:e(`fi_button_edit`),cancelEditLabel:e(`fi_label_cancelEditDesktop`),editingLabel:e(`fi_label_editing`),editBannerLabel:e(`ci_edit_banner`),videoRetryBannerLabel:e(`ci_video_retry_banner`),optionsGroupLabel:e(`ci_options_group`),selectionInstruction:(t,n)=>t===gte.UP_TO_MAX?e(`ci_label_selectMax`,{max:String(n)}):e(`ci_label_selectAllThatApply`),selectionCount:(t,n)=>e(`ci_label_selectionCount`,{selected:String(t),max:String(n)}),confirmSelectionsLabel:e(`ci_button_confirm`),hintExpand:e(`fi_button_readFullBrief`),hintCollapse:e(`fi_button_showLess`),showMore:e(`fi_button_showMore`),showLess:e(`fi_button_showLess`),senderAgent:e(`ci_sender_agent`),senderCandidate:e(`ci_sender_candidate`),opensNewTab:e(`ci_opens_new_tab`),widgetLabel:e(`ci_widget_label`),sliderLabel:e(`fi_label_ratingMessage`),submitRatingLabel:e(`fi_button_submitRating`),dropdownSearchPlaceholder:e(`fi_placeholder_dropdown`),dropdownSearchLabel:e(`ci_dropdown_search_label`),emailPlaceholder:e(`fi_placeholder_demoEmailInput`),phoneCountryLabel:e(`ci_phone_country_label`),phoneInputLabel:e(`ci_pii_label_phone`),phonePlaceholder:e(`ci_phone_placeholder`),locationInputLabel:e(`ci_location_input_label`),locationPlaceholder:e(`ci_location_placeholder`),locationSuggestionsLabel:e(`ci_location_suggestions_label`),locationSuggestionsFound:t=>e(`ci_location_suggestions_found`,{count:t}),nameConfirmTitle:e(`ci_name_confirm_title`),nameConfirmBody:t=>e(`ci_name_confirm_body`,{suggested:t}),useSuggestedLabel:t=>e(`ci_name_use_suggested`,{suggested:t}),useOriginalLabel:e(`ci_name_use_original`),wordCount:t=>e(`fi_label_words`,{count:t}),shortResponseHint:t=>e(`fi_alt_shortResponse`,{minWordCount:t}),goodResponseHint:e(`fi_alt_goodResponse`),maxWordsHint:e(`fi_alt_maxWords`),shortAnswerTitle:t=>e(`fi_error_notEnoughWords`,{minWordCount:t}),shortAnswerAim:(t,n)=>n===void 0?e(`fi_error_notEnoughWordsMin`,{minWordCount:t}):e(`fi_error_notEnoughWordsAim`,{minWordCount:t,recommendedWordCount:n}),shortAnswerEditAnytime:e(`fi_error_notEnoughWordsEdit`),shortAnswerEditNow:e(`fi_error_notEnoughWordsEditNow`),dontShowAgainLabel:e(`fi_check_dontShow`),continueLabel:e(`fi_button_continue`),loadingLabel:e(`ci_loading`),preparingLabel:e(`ci_preparing`),doneTitle:e(`ci_done_title`),doneSubtitle:t=>t?e(`ci_done_subtitle`,{name:t}):e(`ci_done_subtitle_generic`),doneNextLabel:e(`ci_done_next_label`),doneSteps:[e(`ci_done_step1`),e(`ci_done_step2`),e(`ci_done_step3`)],doneAck:e(`ci_done_ack`),doneRedirect:e(`fi_button_continue`),startFailedMessage:e(`ci_start_failed`),cohortClosedTitle:e(`fi_error_cohortClosedTitle`),cohortClosedMessage:e(`fi_error_cohortClosedMessage`),notFoundTitle:e(`ci_assessment_not_found_title`),notFoundMessage:e(`ci_assessment_not_found_message`),piiError:t=>e(t),piiIntro:e(`fi_label_collectDetailsIntro`),piiDetailsTitle:e(`fi_label_yourDetails`),piiAnsweredTitle:e(`fi_label_yourDetails`),piiSmsTitle:e(`ci_pii_row_sms`),piiPhoneTitle:e(`ci_pii_label_phone`),piiReviewTitle:e(`ci_pii_review_title`),piiReviewWarning:e(`fi_label_reviewDetailsWarning`),piiBack:e(`ci_pii_back`),piiNext:e(`fi_button_next`),piiContinue:e(`fi_button_continue`),piiAccept:e(`fi_button_accept`),piiSmsRowLabel:e(`ci_pii_row_sms`),piiSmsConsented:e(`ci_pii_sms_consented`),piiSmsDeclined:e(`ci_pii_sms_declined`),piiFieldLabel:t=>{var n,r;return e((n=(r=K9[t])==null?void 0:r.label)==null?t:n)},piiFieldPlaceholder:t=>{var n,r;return e((n=(r=K9[t])==null?void 0:r.placeholder)==null?t:n)},piiRowLabel:t=>{var n;return e((n=Jbe[t])==null?t:n)},csatIntro:e(`ci_csat_intro`),csatTitle:e(`ci_csat_title`),csatSubtitle:e(`ci_csat_subtitle`),csatScaleLabel:(t,n)=>e(`ci_csat_scale_label`,{min:t,max:n}),csatLow:e(`ci_csat_low`),csatHigh:e(`ci_csat_high`),csatCommentLabel:e(`ci_csat_comment_label`),csatCommentPlaceholder:e(`ci_csat_comment_placeholder`),csatSubmit:e(`ci_csat_submit`),csatAnswerRating:(t,n)=>e(`ci_csat_answer_rating`,{rating:t,max:n}),csatAnswerComment:t=>e(`ci_csat_answer_comment`,{comment:t}),deiTitle:e(`ci_dei_title`),deiSubmit:e(`ci_dei_submit`),videoOpenCamera:e(`ci_video_open_camera`),videoStartRecording:e(`fi_button_record`),videoStopRecording:e(`fi_button_stop`),videoReRecord:e(`ci_video_re_record`),videoSubmit:e(`ci_video_submit`),videoKeep:e(`ci_video_keep`),videoCameraError:e(`ci_video_camera_error`),videoPreview:e(`ci_video_preview`),videoCamera:e(`ci_video_camera`),videoMicrophone:e(`ci_video_microphone`),videoOn:e(`ci_video_on`),videoOff:e(`ci_video_off`),videoFinishHint:e(`ci_video_finish_hint`),videoCameraOff:e(`ci_video_camera_off`),videoRecordingStarted:e(`ci_video_recording_started`),videoRecordingStopped:e(`ci_video_recording_stopped`),videoSecondsRemaining:t=>e(`ci_video_seconds_remaining`,{seconds:t}),videoAttempts:(t,n)=>e(`ci_video_attempts`,{current:t,max:n}),videoUploadProgress:e(`fi_label_uploading`),videoUploadFailed:e(`fi_label_uploadFailed`),videoRetryUpload:e(`ci_video_retry_upload`),videoPlay:e(`ci_video_play`),videoAnswer:e(`ci_video_answer`),embeddedVideoLabel:e(`ci_video_embed_label`),accessTitle:e(`ci_access_title`),accessDescription:e(`ci_access_description`),accessInputLabel:e(`ci_pii_label_email`),accessSubmit:e(`fi_button_continue`),accessMismatch:e(`fi_error_emailDoesNotMatch`),agcTitle:e(`fi_error_agcTitle`),agcMessage:t=>e(t>=2?`fi_error_agcSecondMessage`:`fi_error_agcFirstMessage`),agcEdit:e(`fi_button_edit`),agcContinue:e(`fi_button_continue`),agcGuidanceTitle:e(`fi_agc_guidance_header`),agcGuidanceBody:e(`fi_agc_guidance_body`),agcGuidanceCheckbox:e(`fi_agc_guidance_checkbox`),agcGuidanceTip:e(`fi_agc_guidance_tip`),agcGuidanceCta:e(`fi_agc_guidance_cta`),editFailedTitle:e(`fi_error_generalErrorTitle`),editFailedMessage:e(`fi_label_checkInternetCon`),editFailedDismiss:e(`fi_button_ok`)}),Qbe=e=>{(0,w.useEffect)(()=>{if(!e)return;let t=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,t),()=>window.removeEventListener(`beforeunload`,t)},[e])},$be=e=>{(0,w.useEffect)(()=>{let t=()=>{document.visibilityState===`visible`&&e.checkSessionExpiry()};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e])},exe=({engine:e,fields:t,strings:n})=>{var r;let i=(r=t[0])==null?void 0:r.questionId,[o,c]=(0,w.useState)({runId:i,rating:8,comment:``});o.runId!==i&&c({runId:i,rating:8,comment:``});let l=(0,w.useCallback)(e=>c(t=>({...t,rating:e})),[]),u=(0,w.useCallback)(e=>c(t=>({...t,comment:e})),[]),d=(0,w.useCallback)(()=>{e.submitCustomerSatisfactionForm({rating:o.rating,comment:o.comment})},[e,o.rating,o.comment]);return{labels:(0,w.useMemo)(()=>({title:n.csatTitle,subtitle:n.csatSubtitle,scaleLabel:n.csatScaleLabel(1,10),low:n.csatLow,high:n.csatHigh,commentLabel:n.csatCommentLabel,commentPlaceholder:n.csatCommentPlaceholder,submit:n.csatSubmit}),[n]),min:1,max:10,rating:o.rating,comment:o.comment,onRatingChange:l,onCommentChange:u,onSubmit:d}},q9={},txe=(e,t,n)=>{if(!oh(e.questionTypes,e.rules))return[n];if(t.includes(n))return t.filter(e=>e!==n);let{max:r}=ih(e.rules);return r!==void 0&&t.length>=r?t:[...t,n]},nxe=({engine:e,fields:t,strings:n})=>{var r;let i=(r=t[0])==null?void 0:r.questionId,[o,c]=(0,w.useState)({runId:i,answers:q9});o.runId!==i&&c({runId:i,answers:q9});let l=(0,w.useCallback)((e,n)=>{let r=t.find(t=>t.questionId===e);r&&c(t=>{var i;return{...t,answers:{...t.answers,[e]:txe(r,(i=t.answers[e])==null?[]:i,n)}}})},[t]),u=(0,w.useCallback)(()=>{e.submitDemographicForm(o.answers)},[e,o.answers]),d=(0,w.useMemo)(()=>t.map(e=>{var t,r;let i=((t=e.options)==null?[]:t).map(({id:e,text:t})=>({id:e,text:t})),c=(r=o.answers[e.questionId])==null?[]:r;if(!oh(e.questionTypes,e.rules))return{questionId:e.questionId,prompt:e.prompt,options:i,selectedOptionIds:c,multi:!1};let l=ih(e.rules);return{questionId:e.questionId,prompt:e.prompt,options:i,selectedOptionIds:c,multi:!0,instruction:n.selectionInstruction(sh(l,i.length),l.max),...l.max===void 0?{}:{countLabel:n.selectionCount(c.length,l.max),capReached:c.length>=l.max}}}),[t,o.answers,n]),f=t.length>0&&t.every(e=>{var t,n;return((t=(n=o.answers[e.questionId])==null?void 0:n.length)==null?0:t)>=ih(e.rules).min});return{questions:d,title:n.deiTitle,submitLabel:n.deiSubmit,canSubmit:f,onToggle:l,onSubmit:u}},rxe={[xr.FULL_NAME]:h6.NAME,[xr.FIRST_NAME]:h6.NAME,[xr.LAST_NAME]:h6.NAME,[xr.EMAIL]:h6.EMAIL,[xr.LOCATION]:h6.LOCATION,[xr.PHONE_NUMBER]:h6.PHONE},J9=(e,t=null)=>JSON.stringify({address:e,coordinate:t}),ixe=({engine:e,fields:t,strings:n,placesApiKey:r,candidateCountryCode:i,region:o})=>{var c;let l=W9({apiKey:r}),[u,d]=(0,w.useState)([]),f=!!M6(t);(0,w.useEffect)(()=>{if(!f)return;let e=!0;return k5().then(t=>{e&&d(t)}),()=>{e=!1}},[f]);let p=(0,w.useMemo)(()=>Xhe(t),[t]),[m,h]=(0,w.useState)(0),[g,_]=(0,w.useState)({}),[v,y]=(0,w.useState)({}),[b,x]=(0,w.useState)(),[S,C]=(0,w.useState)(()=>A5({candidateCountryCode:i,region:o})),[T,E]=(0,w.useState)(),D=(c=p[m])==null?T6.REVIEW:c,O=(b==null?void 0:b.value)===E6.YES,k=(0,w.useMemo)(()=>p.filter(e=>e!==T6.PHONE||O),[p,O]),A=Yhe((0,w.useMemo)(()=>{if(D===T6.DETAILS)return A6(t).filter(k6);let e=M6(t);return D===T6.PHONE&&e?[e]:[]},[D,t]),g),j=(0,w.useCallback)(e=>h(p.indexOf(e)),[p]),M=(0,w.useCallback)(e=>{var t;j((t=k[k.indexOf(e)+1])==null?T6.REVIEW:t)},[k,j]),N=(0,w.useCallback)((e,t)=>{_(n=>({...n,[e]:t})),y(t=>t[e]?Object.fromEntries(Object.entries(t).filter(([t])=>t!==e)):t)},[]),P=(0,w.useCallback)((e,n)=>{N(e,n);let r=t.find(t=>t.questionId===e);(r==null?void 0:r.piiType)===xr.LOCATION&&(E(void 0),l.search(n))},[t,N,l]),F=(0,w.useCallback)(e=>{let n=t.find(e=>e.piiType===xr.LOCATION),r=l.suggestions.find(t=>t.placeId===e.id);!n||!r||(l.clear(),N(n.questionId,e.label),l.resolve(r).then(t=>{var n,r;return E(J9((n=t==null?void 0:t.address)==null?e.label:n,(r=t==null?void 0:t.coordinate)==null?null:r))}))},[t,l,N]),I=(0,w.useCallback)(async e=>{let t=await Promise.all(e.map(async e=>{var t;return{field:e,result:await Zhe(e,(t=g[e.questionId])==null?``:t,S)}})),r=t.filter(e=>!e.result.ok);return y(Object.fromEntries(r.map(e=>[e.field.questionId,n.piiError(e.result.ok?``:e.result.errorKey)]))),r.length>0?!1:(_(e=>({...e,...Object.fromEntries(t.filter(e=>e.result.ok).map(e=>[e.field.questionId,e.result.ok?e.result.text:``]))})),!0)},[g,S,n]),L=(0,w.useCallback)(()=>{let e=[];for(let r of t){var n;if(r.kind===`SMS_CONSENT`){b&&e.push({questionId:r.questionId,text:b.text,value:b.value});continue}if(r.piiType===xr.PHONE_NUMBER&&!O)continue;let t=((n=g[r.questionId])==null?``:n).trim();t.length!==0&&e.push({questionId:r.questionId,text:t,value:r.piiType===xr.LOCATION?T==null?J9(t):T:t})}return e},[t,g,b,O,T]),R=(0,w.useCallback)(async()=>{if(D===T6.DETAILS){if(!await I(A6(t)))return;M(T6.DETAILS);return}if(D===T6.PHONE){let e=M6(t);if(e&&!await I([e]))return;M(T6.PHONE);return}await e.submitPiiForm(L())},[D,t,I,M,e,L]),z=(0,w.useCallback)(e=>{x(e),j(e.value===E6.YES&&M6(t)?T6.PHONE:T6.REVIEW)},[t,j]),ee=(0,w.useCallback)(()=>{let e=k[k.indexOf(D)-1];e&&j(e)},[k,D,j]),B=(0,w.useMemo)(()=>t.filter(e=>e.piiType!=null).filter(e=>e.piiType!==xr.PHONE_NUMBER||O).map(e=>{var t;return{label:n.piiRowLabel(e.piiType),value:((t=g[e.questionId])==null?``:t).trim()}}).filter(e=>e.value.length>0),[t,g,O,n]),V=(0,w.useMemo)(()=>l.suggestions.map(e=>({id:e.placeId,label:e.description,mainText:e.mainText,secondaryText:e.secondaryText})),[l.suggestions]);return{fields:t,labels:(0,w.useMemo)(()=>({detailsTitle:n.piiDetailsTitle,smsTitle:n.piiSmsTitle,phoneTitle:n.piiPhoneTitle,reviewTitle:n.piiReviewTitle,reviewWarning:n.piiReviewWarning,back:n.piiBack,next:n.piiNext,continue:n.piiContinue,accept:n.piiAccept,phoneCountry:n.phoneCountryLabel,phonePlaceholder:n.phonePlaceholder,locationSuggestions:n.locationSuggestionsLabel,locationSuggestionsFound:n.locationSuggestionsFound,smsRowLabel:n.piiSmsRowLabel,fieldLabel:n.piiFieldLabel,fieldPlaceholder:n.piiFieldPlaceholder,rowLabel:n.piiRowLabel}),[n]),step:D,values:g,errors:v,canAdvance:A,reviewRows:B,phoneCountries:u,phoneCountryCode:S,locationSuggestions:V,locationManualMode:l.manualMode,onChange:P,onPhoneCountryChange:C,onLocationSelect:F,onBack:ee,onAdvance:R,onConsent:z}},axe=({entries:e,strings:t})=>[...e].sort((e,t)=>Number(e.piiType===null)-Number(t.piiType===null)).map(e=>e.piiType?{icon:rxe[e.piiType],label:t.piiRowLabel(e.piiType),value:e.text}:{icon:h6.SMS,label:t.piiSmsRowLabel,value:e.value===E6.YES?t.piiSmsConsented:t.piiSmsDeclined}),oxe=[],sxe=[],cxe=[],lxe=`Escape`,uxe=[Zr.BREAK,Zr.TERMS_CONSENT],dxe=({env:e,region:t,appId:n,assessmentId:r,apiOrigin:i,theme:o,showHeader:c=!0,isInternalUser:l,language:u,redirectUrl:d,placesApiKey:f,onEvent:p,emitter:m,fetchImpl:h})=>{var g,_,v;let[y]=(0,w.useState)(()=>{let o=new Kr({env:e,region:t,appId:n,apiOrigin:i,fetchImpl:h}),c=nte(),l=m==null?new C:m;return{store:c,engine:new Dte({client:o,store:c,emitter:l,assessmentId:r,language:Gee(u,typeof navigator<`u`?navigator.language:void 0),welcomeGate:!1,streamText:!1,streamRevealMs:S6()?0:void 0}),events:l}}),b=(0,w.useRef)(p);b.current=p,(0,w.useEffect)(()=>{let e=Object.values(S).map(e=>y.events.on(e,t=>{var n;return(n=b.current)==null?void 0:n.call(b,e,t)}));return()=>e.forEach(e=>e())},[y]);let x=(0,w.useRef)(!1);(0,w.useEffect)(()=>{x.current||(x.current=!0,y.engine.begin())},[y]),$be(y.engine);let T=(0,w.useMemo)(()=>kte(d),[d]);(0,w.useEffect)(()=>{d&&!T&&y.events.emit(S.LOG,{type:mte,message:`Invalid redirect URL: ${d}`})},[y,d,T]);let E=O(y.store,e=>e.phase),D=O(y.store,e=>e.bubbles),k=O(y.store,e=>e.typing),A=O(y.store,e=>e.streamingBubbleId),j=O(y.store,e=>e.sendingAnswer),M=O(y.store,e=>e.numOfNormalQuestion),N=O(y.store,e=>e.assessmentSummary),P=O(y.store,e=>e.assessmentLink),F=O(y.store,e=>e.piiForm),I=O(y.store,e=>e.csatForm),L=O(y.store,e=>e.deiForm),R=O(y.store,e=>e.candidateCountryCode),z=O(y.store,e=>e.editingQuestionId),ee=O(y.store,e=>e.multiSelectDraft),B=O(y.store,e=>e.translations),V=O(y.store,e=>e.language),H=O(y.store,e=>e.branding),te=O(y.store,e=>e.candidateName),ne=O(y.store,e=>e.jobTitle),re=O(y.store,e=>e.customerName),ie=O(y.store,e=>e.emailHint),ae=O(y.store,e=>e.accessEmailMismatch),oe=O(y.store,e=>e.verifyingAccess),se=O(y.store,e=>e.showAgcWarning),ce=O(y.store,e=>e.editFailedQuestionId),le=O(y.store,e=>e.agcAttempt),ue=O(y.store,e=>e.duplicated===!0||e.assessmentStatus!==void 0&&ci.includes(e.assessmentStatus)),de=O(y.store,e=>e.terminalMessage),U=(0,w.useMemo)(()=>Zbe(Nte(B,Ate)),[B]),fe=qee(V==null?Hm:V),pe=(0,w.useMemo)(()=>{let e=e=>{var t,n;return(t=N==null||(n=N.breakdown.find(t=>t.category===e))==null?void 0:n.count)==null?0:t};return{[Qr.WRITTEN]:e(kr.INTERVIEW),[Qr.QUICK]:e(kr.ADDITIONAL),[Qr.VIDEO]:e(kr.VIDEO),[Qr.DEI]:e(kr.DEI)}},[N]),me=(0,w.useMemo)(()=>Fbe(D,pe,{counter:{[Qr.WRITTEN]:U.writtenQuestionCounter,[Qr.QUICK]:U.quickAdditionalQuestionCounter,[Qr.VIDEO]:U.videoQuestionCounter,[Qr.DEI]:U.diversityCounter},videoBadge:U.videoBadge}),[D,pe,U]),he=(0,w.useMemo)(()=>jbe(D,z),[D,z]),ge=(0,w.useMemo)(()=>{var e;if(!z)return;let t=T9(D,z);return t?(e=me.get(t.id))==null?void 0:e.label:void 0},[D,z,me]);(0,w.useEffect)(()=>{if(!z)return;let e=e=>{e.key!==lxe||e.defaultPrevented||document.querySelector(`[role="dialog"]`)||y.engine.cancelEditMode()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[z,y]);let _e=(0,w.useMemo)(()=>ri(D),[D]),ve=re,ye=(g=(_=ne==null?ve:ne)==null?H==null?void 0:H.title:_)==null?U.headerTitle:g,be=ne?ve:void 0,xe=(0,w.useMemo)(()=>({submitted:ue||E===Zm.COMPLETING}),[ue,E]),Se=ixe({engine:y.engine,fields:F==null?oxe:F,strings:U,placesApiKey:f,candidateCountryCode:R,region:t}),Ce=exe({engine:y.engine,fields:I==null?sxe:I,strings:U}),we=nxe({engine:y.engine,fields:L==null?cxe:L,strings:U}),Te=(0,w.useCallback)(e=>[...e.rating===void 0?[]:[U.csatAnswerRating(e.rating,10)],...e.comment?[U.csatAnswerComment(e.comment)]:[]],[U]),Ee=(0,w.useCallback)(e=>({title:U.piiAnsweredTitle,rows:axe({entries:e,strings:U})}),[U]),De=(0,w.useMemo)(()=>({instruction:U.selectionInstruction,count:U.selectionCount}),[U]),Oe=(0,w.useMemo)(()=>({draft:ee,labels:De}),[ee,De]),ke=(0,w.useMemo)(()=>Dbe(D,me,xe,A,Ee,Oe,Te),[D,me,xe,A,Ee,Oe,Te]),Ae=ke.find(e=>{var t;return e.optionsKind===v6.ACTION&&((t=e.options)==null?void 0:t[0])}),je=(0,w.useMemo)(()=>Ae?ke.filter(e=>e!==Ae):ke,[ke,Ae]),[Me,Ne]=(0,w.useState)(!1),Pe=(0,w.useMemo)(()=>kbe(D),[D]),[Fe,Ie]=(0,w.useState)(!1),Le=(0,w.useMemo)(()=>Abe(D),[D]),[Re,W]=(0,w.useState)(),ze=(0,w.useCallback)(e=>e===y6.PII_FORM_INTRO?U.piiIntro:e===y6.PII_FORM?F?(0,K.jsx)(age,{...Se,submitting:j}):null:e===y6.CUSTOMER_SATISFACTION_INTRO?U.csatIntro:e===y6.CUSTOMER_SATISFACTION_FORM?I?(0,K.jsx)(Whe,{...Ce,submitting:j}):null:e===y6.DEMOGRAPHIC_FORM?L?(0,K.jsx)(Khe,{...we,submitting:j}):null:e===y6.AGC_GUIDANCE?(0,K.jsx)(iv,{body:U.agcGuidanceBody,checkboxLabel:U.agcGuidanceCheckbox,checked:Pe?Me:!0,readOnly:!Pe,onCheckedChange:Ne}):e===y6.ASSESSMENT_SUMMARY?N?(0,K.jsx)(dge,{totalLabel:U.summaryTotal,countLabel:U.summaryCount(N.totalQuestions,N.estimatedMinutes),categories:N.breakdown.map(({category:e,count:t})=>U.summaryCategory(e,t,ve)),opensNewTab:U.opensNewTab}):null:(0,K.jsx)(w5,{url:P,copyLabel:U.copyLinkLabel,copiedLabel:U.copiedLabel,withIcon:!0,className:`sc:w-fit ${ene}`}),[N,P,U,F,Se,I,Ce,L,we,j,Pe,Me]),Be=(0,w.useMemo)(()=>Ibe(D,z),[D,z]),Ve=Mbe(D,z),He=Ve==null?void 0:Ve.questionId,Ue=Ve==null?void 0:Ve.blob,We=Ve==null?void 0:Ve.extension,Ge=(0,w.useMemo)(()=>He?{blob:Ue,resolveUrl:We?()=>y.engine.getVideoPlaybackUrl(He,We):void 0}:void 0,[He,Ue,We,y]),Ke=(0,w.useMemo)(()=>zbe(D,z),[D,z]),qe=(0,w.useMemo)(()=>Rbe(D,z),[D,z]),Je=(0,w.useMemo)(()=>Hbe(D,z),[D,z]),[Ye]=(0,w.useState)(()=>l===!0||Ote()),G=(0,w.useMemo)(()=>qe!==E9.TEXT||Ye||Bbe(D,z),[qe,Ye,D,z]),Xe=(0,w.useMemo)(()=>Vbe(D,z),[D,z]),Ze=Obe(D,z),Qe=`${Ze==null?`none`:Ze}:${ce==null?``:ce}`,$e=qe===E9.TEXT&&!z?Ze:void 0,[et,tt]=(0,w.useState)(!1);(0,w.useEffect)(()=>tt(!1),[Qe]);let nt=(0,w.useMemo)(()=>({retry:U.retryLabel,optionsGroup:U.optionsGroupLabel,confirmSelections:U.confirmSelectionsLabel,edit:U.editLabel,editing:U.editingLabel,senderAgent:U.senderAgent,senderCandidate:U.senderCandidate,opensNewTab:U.opensNewTab,showMore:U.showMore,showLess:U.showLess}),[U]),rt=(0,w.useMemo)(()=>({expand:U.hintExpand,collapse:U.hintCollapse}),[U]),it=(0,w.useMemo)(()=>({label:U.sliderLabel,submitLabel:U.submitRatingLabel}),[U]),at=(0,w.useMemo)(()=>({searchPlaceholder:U.dropdownSearchPlaceholder,searchLabel:U.dropdownSearchLabel}),[U]),ot=(0,w.useMemo)(()=>({uploadProgress:U.videoUploadProgress,uploadFailed:U.videoUploadFailed,retryUpload:U.videoRetryUpload,playVideo:U.videoPlay,videoAnswer:U.videoAnswer,embeddedVideo:U.embeddedVideoLabel}),[U]),st=(0,w.useCallback)(()=>void y.engine.retryLastAnswer(),[y]),ct=(0,w.useCallback)(e=>void y.engine.submitOptionAnswer(e),[y]),lt=(0,w.useCallback)(e=>y.engine.toggleOptionSelection(e),[y]),ut=(0,w.useCallback)(()=>void y.engine.confirmSelections(),[y]),dt=(0,w.useCallback)(e=>void y.engine.submitSliderAnswer(e),[y]),ft=(0,w.useCallback)(e=>y.engine.enterEditMode(e),[y]),pt=(0,w.useCallback)(()=>y.engine.cancelEditMode(),[y]),mt=(0,w.useCallback)(()=>y.engine.reportPaste(),[y]),ht=(0,w.useCallback)(()=>void y.engine.retryVideoAnswer(),[y]),gt=(0,w.useCallback)((e,t)=>y.engine.getVideoPlaybackUrl(e,t),[y]),_t=k||A!==void 0,vt=E===Zm.ACTIVE||E===Zm.COMPLETING,yt=E===Zm.ACTIVE&&!_t&&!F&&!I&&!L&&(Lbe(D,z)||qe===E9.VIDEO),bt=yt&&!j,xt=E===Zm.ACTIVE&&!_t&&qe===E9.VIDEO&&!!Be,St=yt&&!xt,Ct=E===Zm.ACTIVE&&z?(0,K.jsx)(Hhe,{label:xt?U.videoRetryBannerLabel:U.editBannerLabel,questionLabel:ge,cancelLabel:U.cancelEditLabel,onCancel:pt,inline:!St}):null,wt=yt?(0,K.jsx)(Gbe,{expanded:et,onExpandedChange:tt,engine:y.engine,assessmentId:r,kind:qe,disabled:!bt,focusOnOpen:!0,wordCountRule:Ke,strings:U,candidateCountryCode:R,region:t,placesApiKey:f,maxVideoSeconds:Je,submittedVideo:Ge,videoQuestionId:Ze,draft:he,draftQuestionId:$e,allowPaste:G,isFeedbackComment:Xe,onBlockedPaste:mt},Qe):null;return Qbe(j),(0,K.jsxs)(Cve,{themeVariables:(0,w.useMemo)(()=>Qte(Rte(Lte(H,r),o)),[H,r,o]),dir:fe,lang:V==null?Hm:V,label:U.widgetLabel,children:[c&&vt?(0,K.jsx)(vve,{title:ye,subtitle:be,logoUrl:H==null?void 0:H.logoUrl}):null,vt?(0,K.jsx)(bve,{value:_e,max:M,label:U.progressLabel}):null,(0,K.jsxs)(`div`,{className:`sc:relative sc:flex sc:min-h-0 sc:flex-1 sc:flex-col`,children:[(0,K.jsxs)(`div`,{inert:et,className:`sc:flex sc:min-h-0 sc:flex-1 sc:flex-col`,children:[E===Zm.STARTING||E===Zm.IDLE||E===Zm.VERIFYING?(0,K.jsx)(yve,{label:U.preparingLabel}):null,E===Zm.WELCOME?(0,K.jsx)(Sve,{logoUrl:H==null?void 0:H.logoUrl,onNext:()=>void y.engine.confirmWelcome(),labels:{eyebrow:U.welcomeEyebrow,greeting:U.welcomeGreeting(te),intro:U.welcomeIntro(ne,ve),copyLinkResume:U.welcomeCopyResume,copied:U.copiedLabel,next:U.welcomeNext}}):null,E===Zm.ENDED?(0,K.jsx)(mve,{logoUrl:H==null?void 0:H.logoUrl,redirectUrl:T,redirectLabel:U.doneRedirect,labels:{title:U.doneTitle,subtitle:U.doneSubtitle(te),nextLabel:U.doneNextLabel,steps:U.doneSteps}}):null,E===Zm.COHORT_CLOSED?(0,K.jsx)(S5,{labels:{title:U.cohortClosedTitle,message:U.cohortClosedMessage}}):null,E===Zm.NOT_FOUND?(0,K.jsx)(S5,{labels:{title:U.notFoundTitle,message:U.notFoundMessage}}):null,E===Zm.TERMINAL_MESSAGE&&de?(0,K.jsx)(xve,{message:de}):null,E===Zm.ACCESS_REQUIRED?(0,K.jsx)(ove,{emailHint:ie,mismatch:ae,submitting:oe,labels:{title:U.accessTitle,description:U.accessDescription,inputLabel:U.accessInputLabel,submit:U.accessSubmit,mismatchError:U.accessMismatch},onSubmit:e=>void y.engine.verifyAccessEmail(e)}):null,E===Zm.FAILED?(0,K.jsx)(`p`,{role:`alert`,className:`sc:p-4 sc:text-sm sc:text-red-600`,children:U.startFailedMessage}):null,vt?(0,K.jsx)(Bhe,{items:je,typing:k,typingLabel:U.typingLabel,scrollToLatestLabel:U.scrollToLatest,typingLoadingLabel:U.typingLoading,bubbleLabels:nt,hintLabels:rt,sliderLabels:it,dropdownLabels:at,mediaLabels:ot,onRetry:st,onSelectOption:ct,onToggleOption:lt,onConfirmSelections:ut,onSubmitSlider:dt,onEdit:ft,onRetryVideo:ht,onResolveVideoUrl:gt,cardFooter:xt?wt:void 0,cardFooterItemId:xt?Be:void 0,editingFooter:St?void 0:Ct,renderCard:ze}):null,St?Ct:null]}),xt?null:wt,E===Zm.ACTIVE&&Ae&&!z?(0,K.jsx)(Sh,{label:Ae.options[0].text,enabled:!!Ae.optionsEnabled&&(!Pe||Me),pending:Ae.pending,triggerOnEnter:uxe.includes((v=D.find(e=>e.id===Ae.id))==null?void 0:v.questionRole),hint:Pe&&!Me?U.agcGuidanceTip:void 0,onClick:()=>{let e=Ae.options[0].id;Le&&!Fe?W(e):ct(e)}}):null,E===Zm.COMPLETING?T?(0,K.jsx)(Sh,{label:U.doneRedirect,href:T}):(0,K.jsx)(Sh,{label:U.doneAck,enabled:!0,onClick:()=>y.engine.acknowledgeCompletion()}):null]}),Re?(0,K.jsx)(sve,{title:U.agcGuidanceTitle,body:U.agcGuidanceBody,checkboxLabel:U.agcGuidanceCheckbox,ctaLabel:U.agcGuidanceCta,onAcknowledge:()=>{Ie(!0),W(void 0),ct(Re)}}):null,se?(0,K.jsx)(x5,{open:!0,title:U.agcTitle,actions:[{label:U.agcEdit,onClick:()=>y.engine.dismissAgcWarning()},{label:U.agcContinue,variant:vh.GHOST,onClick:()=>void y.engine.continueAfterAgcWarning()}],onClose:()=>y.engine.dismissAgcWarning(),children:U.agcMessage(le==null?0:le)}):null,ce?(0,K.jsx)(x5,{open:!0,title:U.editFailedTitle,actions:[{label:U.editFailedDismiss,onClick:()=>y.engine.dismissEditFailure()}],onClose:()=>y.engine.dismissEditFailure(),children:U.editFailedMessage}):null]})},Y9=`sapia-chatbot`,fxe=e=>{if(e instanceof HTMLElement)return e;let t=e==null?`#${Y9}`:e,n=document.querySelector(t);if(!n)throw Error(`Sapia chatbot container not found for selector "${t}"`);return n},X9=e=>{let t=new C,n=null,r=e.theme,i=()=>{n==null||n.render((0,K.jsx)(dxe,{...e,theme:r,emitter:t}))};return{mount(e){n=(0,x.createRoot)(fxe(e)),i()},unmount(){n==null||n.unmount(),n=null},setTheme(e){r=e,i()},on:(e,n)=>t.on(e,n)}},Z9=`sapiaChatBot`,pxe=2,mxe=500,hxe=`PHChatBot: assessmentId is required (cohortId / jobRequisitionShortcode / applicationShortcode generic links are served by the standalone SPA, not the embeddable widget).`,gxe=function(e){return e.FI_ASSESSMENT_ANSWER_SAVED=`FI_ASSESSMENT_ANSWER_SAVED`,e.FI_ASSESSMENT_ANSWER_EDITED=`FI_ASSESSMENT_ANSWER_EDITED`,e.FI_ASSESSMENT_STARTED=`FI_ASSESSMENT_STARTED`,e.FI_ASSESSMENT_ENDED=`FI_ASSESSMENT_ENDED`,e.FI_ASSESSMENT_DUPLICATED=`FI_ASSESSMENT_DUPLICATED`,e.CHATBOT_ERROR=`CHATBOT_ERROR`,e.CHATBOT_LOG=`CHATBOT_LOG`,e}({}),Q9=e=>e?{backgroundColor:e.backgroundColor,fontColor:e.fontColor}:void 0,$9=e=>({header:Q9(e.header),question:Q9(e.question),response:Q9(e.response),button:Q9(e.button)}),_xe={[S.ANSWER_SAVED]:`FI_ASSESSMENT_ANSWER_SAVED`,[S.ANSWER_EDITED]:`FI_ASSESSMENT_ANSWER_EDITED`,[S.ASSESSMENT_STARTED]:`FI_ASSESSMENT_STARTED`,[S.ASSESSMENT_ENDED]:`FI_ASSESSMENT_ENDED`,[S.ASSESSMENT_DUPLICATED]:`FI_ASSESSMENT_DUPLICATED`,[S.ERROR]:`CHATBOT_ERROR`,[S.LOG]:`CHATBOT_LOG`},vxe=async(e,t=pxe,n=mxe)=>{let r=t,i=e();for(;!i&&r>0;)--r,await new Promise(e=>setTimeout(e,n)),i=e();return i},yxe=class{constructor(e){this.callbacks={},this.theme={},this.chatbot=null,e.assessmentId||console.error(hxe),this.options=e}addCallbackHandler(e){this.callbacks={...this.callbacks,...e}}setTheme({theme:e}){var t;this.theme={...e},(t=this.chatbot)==null||t.setTheme($9(this.theme))}async attachChatBot(){var e;if(!this.options.assessmentId)return;let t=await vxe(()=>document.getElementById(Z9));if(!t){console.error(`PHChatBot: container #${Z9} not found`);return}this.chatbot=X9({env:this.options.env,region:this.options.region,appId:this.options.appId,assessmentId:this.options.assessmentId,apiOrigin:this.options.apiOrigin,showHeader:(e=this.options.showHeader)==null?!1:e,isInternalUser:this.options.isInternalUser,theme:$9(this.theme)});for(let e of Object.values(S))this.chatbot.on(e,t=>this.dispatch(e,t));this.chatbot.mount(t)}stopCallingApiWhenUnmount(){var e;(e=this.chatbot)==null||e.unmount(),this.chatbot=null}dispatch(e,t){let n=this.callbacks[_xe[e]];if(n){if(e===S.ASSESSMENT_DUPLICATED){n==null||n({duplicatedWithAssessmentLink:t.duplicatedWithAssessmentLink});return}n(t)}}};e.CHATBOT_CONTAINER_ID=Z9,e.CHATBOT_EVENTS=S,e.DEFAULT_CONTAINER_ID=Y9,e.PHChatBot=yxe,e.PHChatBotCallbackFunction=gxe,e.createChatbot=X9});
3788
3788
  //# sourceMappingURL=sapia-chatbot.umd.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapia-ai/chatbot-v3",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Sapia chat interview widget — embeddable chatbot for candidate interviews",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",