"use strict";(this.webpackChunk_gorgias_chat_client=this.webpackChunk_gorgias_chat_client||[]).push([[265],{67322:(e,n,t)=>{t.r(n),t.d(n,{default:()=>Se});var a,r=t(21253),i=t(40637),o=t(97537),l=t(57970),c=t(32663),d=t(87383),s=t(96859),u=t(49049),p=t(41994),h=t(75018),f=t(42188),v=t(77637),g=t(52153),m=t(86634),x=t(83593),A=t(41843),b=t(54171),y=t(96250),w=t(82885),E=t(5603),C=t(92542),Y=t(74581),j=t(70515),I=t(68233),S=t(88830),_=t(8206),O=t(28730),k=t(59181),P=t(48659),R=t(37680),T=t(893),M=t(39283),F=t(27413),D=t(62494),H=["title","titleId"];function L(){return L=Object.assign?Object.assign.bind():function(e){for(var n=1;n{var n=e.onExit;return(0,W.FD)(Z,{"data-testid":"preview-mode-banner-component",children:[(0,W.FD)("div",{children:[(0,W.Y)(N,{}),(0,W.Y)("span",{children:"You won't generate any tickets."})]}),(0,W.Y)(J,{type:"button",onClick:n,"data-testid":"preview-mode-banner-button",children:"Exit"})]})},$=t(61199),q=t(22453),U=t(81515),Q=t(9866),X=t(52685),ee=t(57554);var ne,te=t(22182),ae=t(51525),re=t(47949),ie=t(84126),oe=t(79062),le=t(83271),ce=t(40909),de=t(74789),se=t(79218),ue=t(41191),pe=t(94177),he=D.A.div(ne||(ne=(0,F.A)(["\n height: 100%;\n overflow: auto;\n display: flex;\n flex-direction: column;\n\n ","\n"])),e=>e.isHomeSSPPage&&"\n position: fixed;\n width: 100%;\n ");const fe=e=>{var n=e.isArticleRecommendationEnabled,t=void 0!==n&&n,a=(0,i.zy)(),o=(0,oe.ng)().variant,l=(0,O.o)(),c=a.pathname===se.y.SELF_SERVICE_PORTAL__HOME,d=(0,r.useMemo)(()=>o!==oe.Tx.CHAT?null:l?a.pathname===se.y.SELF_SERVICE_PORTAL__HOME?null:(0,pe.jsx)(te.c,{}):(0,pe.jsx)(le.A,{}),[o,l,a.pathname]);return(0,pe.jsxs)(he,{isHomeSSPPage:c,children:[(0,pe.jsx)(ae.z,{children:(0,pe.jsxs)(ue.A,{children:[d,(0,pe.jsx)(de.A,{}),l&&(0,pe.jsx)(re.g,{}),l&&(0,pe.jsx)(ie.V,{})]})}),t&&(0,pe.jsx)(ce.$,{})]})};var ve=t(80039),ge=t(3250);const me=e=>{var n=e.children,t=(0,oe.ng)().variant;return(0,pe.jsx)(ve.default,{fallbackComponent:()=>(0,pe.jsxs)(pe.Fragment,{children:[t===oe.Tx.CHAT&&(0,pe.jsx)(le.A,{}),(0,pe.jsx)(ge.A,{})]}),children:n})};var xe,Ae=t(76599),be=t(44941),ye=D.A.div(xe||(xe=(0,F.A)(["\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 12px 16px;\n gap: 16px;\n font-size: 14px;\n line-height: 16px;\n color: ",";\n background-color: ",";\n border-bottom: 1px solid ",";\n\n svg {\n flex-shrink: 0;\n margin-right: 20px;\n width: 18px;\n height: 18px;\n\n path {\n fill: ",";\n }\n }\n"])),B.nY.neutral10,B.nY.supportingYellow0,B.nY.supportingYellow3,B.nY.supportingYellow6),we=()=>{var e=(0,Ae.yC)(),n=be.A.getCustomerEmail();return(0,W.Y)(ye,{"data-testid":"impersonating-mode-banner-component",children:(0,W.FD)("div",{children:[(0,W.Y)(N,{}),(0,W.FD)("span",{children:["You are impersonating ",n||e]})]})})},Ee=(e,n,t)=>{e&&!n&&t()},Ce=e=>{var n=e.isOpen,t=e.hideIframe,a=e.reconnectWs,i=void 0===a?Ee:a;(()=>{var e=(0,b.d)(e=>e.application.credentials.conversationId),n=(0,b.d)(e=>e.application.credentials.appKey),t=(0,b.d)(j.PU),a=(0,u.j$)().window;(0,r.useEffect)(()=>{var r,i;e&&(null===a||void 0===a||null===(r=a.heap)||void 0===r||r.identify("".concat(t,"_").concat(e)),null===a||void 0===a||null===(i=a.heap)||void 0===i||i.addEventProperties({AccountId:String(t),ChatAppKey:n||"unknown",Role:"shopper"}))},[e,t,n,null===a||void 0===a?void 0:a.heap])})();var o=(0,P.z)().track,l=(0,E.jm)(),d=l.messageWindow,s=l.widgetSize,p=(0,b.w)(),h=(0,r.useRef)(null);(0,_.eb)();var v=(0,r.useRef)(!1),g=(0,b.d)(e=>[e.application.status.isConnected,e.application.credentials.accessToken]),w=(0,c.A)(g,2),I=w[0],T=w[1],M=(0,b.d)(A.uE).enabled,F=(0,b.d)(e=>[e.application.status.isMinimizedWindow]),D=(0,c.A)(F,1)[0],H=(()=>{var e=(0,r.useState)((0,Y.xs)()),n=(0,c.A)(e,2),t=n[0],a=n[1],i=(0,r.useCallback)(()=>{a(!1),(0,C.ay)(),(0,Y.aH)()},[]);return(0,r.useMemo)(()=>({exitPreviewMode:i,inPreviewMode:t}),[i,t])})(),L=H.inPreviewMode,V=H.exitPreviewMode,N=(0,b.d)(e=>e.application.settings.preferences.liveChatAvailability),G=(0,b.d)(e=>e.application.status.isChatOnline),z=(0,b.d)(e=>e.application.status.isDuringBusinessHours),B=(0,b.d)(k.Sg),Z=!z&&(N===f.c7.OFFLINE||!G),J=(0,b.d)(e=>e.application.settings.decoration.backgroundColorStyle),q=(0,b.d)(e=>e.flows.previewMode),U=(0,O.o)(),Q=(0,r.useCallback)(e=>{if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),p((0,x.UG)(!1));try{var n=document.getElementById("gorgias-chat-messenger-button");n&&n.focus()}catch(t){console.error("Error focusing on chat messenger button",t)}}},[p]);return(0,r.useEffect)(()=>{n&&!T&&p((0,m.LA)())},[p,T,n]),(0,r.useEffect)(()=>{n&&o({event:R.TZ.SESSION_START})},[n]),(0,r.useEffect)(()=>{!v.current&&I&&(v.current=!0)},[I]),(0,r.useEffect)(()=>{i(v.current,I,()=>p((0,x.we)()))},[p,i,I]),(0,W.Y)(y.J_,{children:(0,W.FD)($.Bv,{$position:B,ref:h,className:"widget-".concat(s," ").concat(D?"at-60":""," ").concat(Z?"offline-mode":"","\n "),dimensions:d,isOpen:n,$isRedesign:U,onAnimationEnd:t,tabIndex:0,"aria-labelledby":"chat-title",role:"dialog",onKeyDown:Q,children:[!U&&J!==f.ZZ.SOLID&&(0,W.Y)($.Hf,{"data-testid":"background-color-style-gradient",className:"".concat(Z?"offline-mode":"")}),(0,W.Y)($.i,{}),(0,W.FD)(me,{children:[L&&!q&&(0,W.Y)(K,{onExit:V}),(0,S.l2)()&&(0,W.Y)(we,{}),(0,W.Y)(fe,{isArticleRecommendationEnabled:M})]})]})})},Ye=e=>{var n=(0,w.V)().injectRecaptcha,t=(0,r.useContext)(u.tW).document,a=(0,r.useState)(null),i=(0,c.A)(a,2),o=i[0],f=i[1];return(0,r.useEffect)(()=>{!o&&t&&(f((0,p.default)((0,l.A)({key:"message-window-iframe",container:t.head},I.default.getDisableEmotionSpeedyMode()?{speedy:!1}:{}))),function(e){var n=q.A.replace(/aria-label/g,"data-balloon-content"),t=e.createElement("style");t.setAttribute("data-testid","balloon-styles"),t.innerHTML="".concat(v.$m," ").concat(n," ").concat(U.A," ").concat(Q.A," ").concat((0,B.bt)()," ").concat((0,B.jo)()," ").concat(v.qy);var a=e.createElement("style");a.setAttribute("data-testid","gorgias-ds-styles"),a.innerHTML="".concat(X.A," ").concat(ee.A),e.head.appendChild(t),e.head.appendChild(a)}(t))},[o,t]),(0,h.A)(()=>{n()}),o&&(0,W.FD)(d.C,{value:o,children:[(0,W.Y)(g.A,{}),(0,W.Y)(s.Global,{styles:v._D}),(0,W.Y)(T.h,{children:(0,W.Y)(M.P,{children:(0,W.Y)(_.lm,{children:(0,W.Y)(Ce,(0,l.A)({},e))})})})]})};const je=(0,r.memo)(Ye);var Ie=e=>{var n=e.isOpen,t=e.hideIframe;return(0,pe.jsx)(i.Ix,{history:o.A,children:(0,pe.jsx)(je,{isOpen:n,hideIframe:t})})};const Se=(0,r.memo)(Ie)},82885:(e,n,t)=>{t.d(n,{V:()=>c});var a=t(68831),r=t(47420),i=t(68233),o=t(49195),l=window,c=()=>{var e=()=>{if(!document.querySelector(".grecaptcha-badge")){var e=document.createElement("style");document.head.appendChild(e);var n=e.sheet;n&&n.insertRule(".grecaptcha-badge { visibility: hidden; }",n.cssRules.length)}};return{injectRecaptcha:()=>{var n;if(i.default.recaptcha.enabled){var t="https://www.google.com/recaptcha/api.js?render=".concat(i.default.recaptcha.siteKey);if(!document.querySelector('script[src="'.concat(t,'"]'))){e();var a=document.createElement("script");a.src=t,a.async=!0,a.defer=!0,(null!==(n=document.getElementById("gorgias-chat-container"))&&void 0!==n?n:document.body).appendChild(a)}}},requestRecaptchaToken:function(){var e=(0,r.A)((0,a.A)().m(function e(){var n,t,r,c,d,s;return(0,a.A)().w(function(e){for(;;)switch(e.n){case 0:if(i.default.recaptcha.enabled){e.n=1;break}return e.a(2,null);case 1:return e.n=2,null===(t=l[i.WindowVariable.GOOGLE_RECAPTCHA_GRECAPTCHA])||void 0===t?void 0:t.execute(i.default.recaptcha.siteKey);case 2:if(d=n=e.v,!(c=null!==d)){e.n=3;break}c=void 0!==n;case 3:if(!c){e.n=4;break}s=n,e.n=5;break;case 4:s=null;case 5:return(r=s)||o.Ay.error(new Error("grecaptcha.execute() could not generate a token.")),e.a(2,r)}},e)}));return function(){return e.apply(this,arguments)}}()}}},96250:(e,n,t)=>{t.d(n,{J_:()=>C,_g:()=>y,os:()=>m});var a=t(32663),r=t(21253),i=t(17185),o=t(54171),l=t(34582),c=t(96716),d=t(85002),s=t(75412),u=t(77644),p=t(65597),h=t(68233),f=t(94177),v=(0,i.A)(d.hJ.INITIAL),g=(0,a.A)(v,2),m=g[0],x=g[1],A=(0,i.A)([]),b=(0,a.A)(A,2),y=b[0],w=b[1],E=e=>{var n=e.children,t=m(),i=(0,a.A)(t,2),v=i[0],g=i[1],x=(0,o.w)(),A=(0,o.d)(e=>(0,l.Gh)(e,-1)),b=(0,o.d)(e=>(0,l.Gh)(e,-2)),y=(0,r.useMemo)(()=>{if(!A)return!1;var e=(0,c.YP)(),n=(0,c.YP)(A.createdDatetime);return e.diff(n,"hour")<72},[A]);return(0,r.useEffect)(()=>{var e,n,t;v===d.hJ.INITIAL&&(null===b||void 0===b?void 0:b.content.type)!==s.ln.FIELD_CAPTURE_FORM&&((null===A||void 0===A?void 0:A.type)!==u.Go.CONVERSATION_MESSAGE||(null===A||void 0===A||null===(e=A.content)||void 0===e?void 0:e.type)===s.ln.FIELD_CAPTURE_FORM||null!==A&&void 0!==A&&null!==(n=A.content)&&void 0!==n&&null!==(t=n.metadata)&&void 0!==t&&t.campaigns||!y||g(d.hJ.FINISHED_LIVE_CHAT))},[v,y,A,b]),(0,r.useEffect)(()=>{if(y){var e=localStorage.getItem(h.default.localStorageLastWaitTime);e&&x((0,p.ML)(Number(e)))}},[y]),(0,f.jsx)(f.Fragment,{children:n})},C=e=>{var n=e.children;return(0,f.jsx)(x,{children:(0,f.jsx)(w,{children:(0,f.jsx)(E,{children:n})})})}}}]); //# sourceMappingURL=gcmw.6f9ac562e24c5a2e.js.map