(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[11],{2868:function(){},4777:function(){},9830:function(){},209:function(){},43:function(e,t,n){Promise.resolve().then(n.bind(n,7808))},7808:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return eD}});var r=n(7437),o=n(7096),i=n(360),a=n(3980),l=n.n(a);let s=async e=>{try{let t=await fetch("/api/upload-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error("Erro ao fazer upload do arquivo");return await t.json()}catch(e){console.error(e)}},c=async e=>{try{let t=await fetch("/api/get-custom-config/channel-key/".concat(e),{headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Erro ao obter configura\xe7\xf5es do router");let n=await t.json();return await n}catch(e){console.error(e)}};function d(){if(void 0!==window.location.ancestorOrigins)return window.location.ancestorOrigins;let e=[],t=window;for(;t!==window.top;){if(t.document.referrer)try{let n=new URL(t.document.referrer);e.push(n.origin)}catch(e){}t=t.parent}return e}let u=(0,o.sj)({webChatHistory:[],fingerprint:null,isTheDomainSetup:!0,webChatText:"",isBotTyping:!1,socket:null,isLoadingWebChat:!0,isCloseIconVisible:!1,userId:"",historyPage:1,hasNextPage:!1,router:{customizationConfig:{name:"",image:"",domains:[],style:{"components-color":"rgb(14,165,233)","background-color":"rgb(255,255,255)"},actions:{allowAudio:!1,allowFile:!1}},idRouter:""}}),m=()=>(0,i.R)(u),p=e=>{u.webChatText=e},h=(e,t)=>{u.webChatHistory=[...u.webChatHistory,e],u.webChatText="",t()},f=(e,t)=>{u.isBotTyping=!1,u.webChatHistory=[...u.webChatHistory,e],t()},x=e=>{u.isBotTyping=e},g=e=>{u.socket=e?(0,o.iH)(e):e},v=e=>{u.isLoadingWebChat=e},y=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;setTimeout(()=>{e.current&&(e.current.scrollTop=e.current.scrollHeight)},t)},b=e=>{window.parent.postMessage(e,{targetOrigin:"*"})},w=async(e,t,n)=>{if(u.hasNextPage){let r="".concat(u.userId,"@webchat.com.withub.ai"),o=u.router.idRouter,i=u.historyPage,a={message:l().encrypt(JSON.stringify({...u.fingerprint,idLead:r,idRouter:o,page:i}),"s3UrwIOlWhu6fEonblpGNnH1hFPNB2D3"),channelKey:n};u.socket.emit("webchat:on-get-history",a,async n=>{if("OK"===n.data.status){let r=JSON.parse(l().decrypt(n.data.history,"s3UrwIOlWhu6fEonblpGNnH1hFPNB2D3")),o={CLIENT:"HUMAN",HUMAN:"BOT"},i=r.map(e=>({...e,from:o[e.from]||e.from})).reverse();u.webChatHistory=[...i,...u.webChatHistory],u.historyPage=u.historyPage+1,u.hasNextPage=i.length>0,setTimeout(()=>{e.current.scrollTop=e.current.scrollHeight-t},1)}})}},j=(e,t)=>{let n={header:{contentType:null==t?void 0:t.type,sender:{id:u.userId,name:null}},content:{...null==t?void 0:t.content,metadata:null==t?void 0:t.metadata}},r={message:l().encrypt(JSON.stringify(n),"s3UrwIOlWhu6fEonblpGNnH1hFPNB2D3"),channelKey:e};u.socket.emit("webchat:send-message",r,e=>{var n,r;"OK"===e.data.status&&(null==t?void 0:null===(n=t.metadata)||void 0===n?void 0:n.isGreeting)&&b({code:"Mundiale-SetStorage",userId:null==e?void 0:null===(r=e.data)||void 0===r?void 0:r.webchatUserId,expires:1728e5,isGreetingMessageSent:!0})})},k=async(e,t,n)=>{let r=await c(t);if(null==r?void 0:r.data){let e=r.data.customizationConfig.domains,t=d()[0];if(u.router=r.data,document.documentElement.style.setProperty("--primary-color",r.data.customizationConfig.style["components-color"]),document.documentElement.style.setProperty("--background-color",r.data.customizationConfig.style["background-color"]),t&&e.length>0&&!e.includes(t)){u.isTheDomainSetup=!1,console.error("Dom\xednio n\xe3o configurado!");return}}let o=l().encrypt(JSON.stringify(e),"s3UrwIOlWhu6fEonblpGNnH1hFPNB2D3");u.socket.emit("webchat:on-authenticate",{channelKey:t,message:o},async r=>{if("OK"===r.data.status){let o=JSON.parse(l().decrypt(r.data.encryptedResponse,"s3UrwIOlWhu6fEonblpGNnH1hFPNB2D3"));if(b({code:"Mundiale-isChatAuthenticated"}),u.userId=o.userId,o.isNew)b({code:"Mundiale-SetStorage",userId:o.userId,expires:1728e5}),b({code:"Mundiale-SendFirstMessage"});else{let r=o.userId,i="".concat(r,"@webchat.com.withub.ai"),a=u.router.idRouter;u.fingerprint={...e,userId:r};let s={message:l().encrypt(JSON.stringify({...e,userId:r,page:1,idRouter:a,idLead:i}),"s3UrwIOlWhu6fEonblpGNnH1hFPNB2D3"),channelKey:t};u.socket.emit("webchat:on-get-history",s,async e=>{if("OK"===e.data.status){let t=JSON.parse(l().decrypt(e.data.history,"s3UrwIOlWhu6fEonblpGNnH1hFPNB2D3")),r={CLIENT:"HUMAN",HUMAN:"BOT"},o=t.map(e=>({...e,from:r[e.from]||e.from})).reverse();u.webChatHistory=o,u.historyPage=2,u.hasNextPage=o.length>0,y(n,1)}})}u.isLoadingWebChat=!1}})};var C=n(2265),N=n(6373);let M="h-2 w-2 animate-bounce rounded-full bg-primary";function S(){return(0,r.jsx)("div",{className:"ml-5 flex flex-col space-y-2",children:(0,r.jsxs)("div",{className:"box-border flex items-start space-x-2 self-start overflow-hidden rounded-[13px_13px_13px_2px] border border-[#454545] px-2 py-3",children:[(0,r.jsx)("div",{className:"".concat(M," ").concat("[animation-delay:-0.3s]")}),(0,r.jsx)("div",{className:"".concat(M," ").concat("[animation-delay:-0.15s]")}),(0,r.jsx)("div",{className:M})]})})}class T extends C.Component{static getDerivedStateFromError(e){return{hasError:!0}}componentDidCatch(e,t){this.props.sentryDisabled||console.error("sentry")}render(){if(this.state.hasError){var e;return null!==(e=this.props.fallback)&&void 0!==e?e:(0,r.jsx)(r.Fragment,{children:"Ocorreu um erro inesperado"})}return this.props.children}constructor(e){super(e),this.state={hasError:!1}}}var L=(e,t)=>C.forwardRef((n,o)=>(0,r.jsx)(T,{fallback:null==t?void 0:t.fallback,children:(0,r.jsx)(e,{...n,ref:o,displayName:"withErrorBoundary(".concat(e.displayName||e.name||"Unknown",")")})})),_=n(195),R=n.n(_);let H={allowedTags:["div","h1","h2","h3","h4","h5","h6","p","em","i","strong","b","del","ol","ul","li","a","img","br","span","#text","code","pre","hr","table","thead","tbody","th","tr","td","sub","sup","svg","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],allowedAttributes:{"*":["href","src","width","height","alt","accent-height","accumulate","additive","alignment-baseline","allowReorder","alphabetic","amplitude","arabic-form","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baseline-shift","baseProfile","bbox","begin","bias","by","calcMode","cap-height","class","clip","clipPathUnits","clip-path","clipRule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominant-baseline","dur","dx","dy","edgeMode","elevation","enable-background","end","exponent","externalResourcesRequired","fill","fill-opacity","fillRule","filter","filterRes","filterUnits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","format","from","fr","fx","fy","g1","g2","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","glyphRef","gradientTransform","gradientUnits","hanging","height","href","hreflang","horiz-adv-x","horiz-origin-x","id","ideographic","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lang","lengthAdjust","letter-spacing","lighting-color","limitingConeAngle","local","marker-end","marker-mid","marker-start","markerHeight","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","max","media","method","min","mode","name","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overline-position","overline-thickness","panose-1","paint-order","path","pathLength","patternContentUnits","patternTransform","patternUnits","ping","pointer-events","points","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","referrerPolicy","refX","refY","rel","rendering-intent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","scale","seed","shape-rendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","string","s","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","surfaceScale","systemLanguage","tabindex","tableValues","target","targetX","targetY","text-anchor","text-decoration","text-rendering","textLength","to","transform","type","u1","u2","underline-position","underline-thickness","unicode","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","values","vector-effect","version","vert-adv-y","vert-origin-x","vert-origin-y","viewBox","viewTarget","visibility","width","widths","word-spacing","writing-mode","x","x-height","x1","x2","xChannelSelector","y","y1","y2","yChannelSelector","z","zoomAndPan"]},nonTextTags:["style","script","textarea","option"],transformTags:{a:function(e,t){try{new URL(t.href).hostname!==location.hostname&&(t.target="_blank",t.rel="noreferrer nofollow")}catch(e){t.target="_blank",t.rel="noreferrer nofollow"}return{tagName:e,attribs:t}}}},O=e=>{let t=e.replace(/\*([^*]+)\*/g,"$1");return(t=(t=(t=t.replace(/_([^_]+)_/g,"$1")).replace(/~([^~]+)~/g,"$1")).replace(/([^<]+)<\/s>/g,"$1")).replace(/```([^`]+)```/g,"$1")},F=e=>R()(e,H),I=e=>"px-4 py-2.5 cursor-pointer text-primary text-sm border-t-[0.5px] text-center transition-colors duration-300 ".concat(e&&"pointer-events-none opacity-[0.5]");function E(e){var t,n,o;let{message:i,messageOnClick:a,onSelectQuickReplyItem:l,isFirstMessage:s}=e,c=null==i?void 0:i.content,[d,u]=(0,C.useState)([]),m=(e,t)=>{s?!d.includes(String(t))&&(u(e=>[...e,String(t)]),l&&l(e)):!d.includes(String(t))&&(u([String(t)]),l&&l(e)),a&&"function"==typeof a&&a({message:i,indexes:[t],extras:{option:e}})};return(0,r.jsxs)("div",{className:"flex flex-col font-semibold rounded-md break-words overflow-auto",children:[(0,r.jsx)("div",{className:"px-4 py-2.5 text-sm break-normal",dangerouslySetInnerHTML:{__html:F((null==c?void 0:null===(t=c.body)||void 0===t?void 0:t.text)||"Menu")}}),null==c?void 0:null===(o=c.body)||void 0===o?void 0:null===(n=o.options)||void 0===n?void 0:n.map((e,t)=>{let n=d.includes(String(t)),o=!s&&d.length>0&&!n;return(0,r.jsx)("div",{className:n?"cursor-normal border-t-[0.5px] bg-primary px-4 py-2.5 text-center text-sm text-white transition-colors duration-300 rounded-md":I(o),onClick:()=>{o||m(e,t)},children:e.text},"".concat(String(t),"-").concat(e.text))})]})}function D(e){return e.toString().padStart(2,"0")}let U=e=>{var t;return["image","video","audio"].includes(null===(t=e.message.content)||void 0===t?void 0:t.type)},z=e=>{var t;return Object.freeze({SYSTEM:"bg-white text-center self-center",CLIENT:"border border-yellow-500 self-start rounded-[13px_13px_13px_2px] border-[#454545]",BOT:"wpp-pattern"===e.variant?" self-end rounded-[13px_13px_2px_13px] border-[#454545]":" self-start rounded-[13px_13px_13px_2px] border-[#454545]",HUMAN:"bg-primary text-white border ".concat((null===(t=e.message)||void 0===t?void 0:t.status)==="FAILED"&&"border-red-500 bg-red-100 ".concat(U(e)&&"blur-[2px]")," self-end rounded-[13px_13px_2px_13px]")})[e.message.from]},A=e=>"mb-2 space-y-2 flex flex-col relative ".concat(["BOT","CLIENT"].includes(e.message.from)&&"ml-5"),B=e=>"flex flex-col content-center justify-center border max-w-[".concat("text"!==e.message.content.type?"100%":"80%","] box-border mx-2 p-2 overflow-hidden whitespace-pre-wrap break-all text-justify text-sm ").concat(z(e)),P=e=>"flex items-center ".concat(z(e)," bg-transparent border-none filter-none mx-2"),G="flex-grow border-t border-gray-400",V=e=>{let{content:t}=e,n=t.body.name?{address:t.body.address,name:t.body.name,...t.body}:{...t.body};return(0,r.jsx)("div",{className:"flex justify-center min-w-64 text-sm border-none w-full p-1",children:(0,r.jsxs)("div",{className:"w-full flex-col justify-center",children:[(0,r.jsx)("div",{className:"flex text-sm justify-center mb-2",children:(0,r.jsx)("span",{children:"Localiza\xe7\xe3o recebida"})}),Object.entries(n).map(e=>{let[t,n]=e;return(0,r.jsx)(r.Fragment,{children:!!n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative flex items-center",children:[(0,r.jsx)("div",{className:G}),(0,r.jsx)("span",{children:t}),(0,r.jsx)("div",{className:G})]}),(0,r.jsx)("div",{className:"w-full p-2 flex justify-center cursor-pointer hover:bg-gray-200",children:(0,r.jsx)("div",{children:(0,r.jsx)("div",{onClick:()=>{navigator.clipboard.writeText(n)},children:(0,r.jsx)("span",{className:"text-sm",children:n})})})})]})})})]})})},W=e=>{let{children:t,title:n}=e,[o,i]=(0,C.useState)(!1),[a,l]=(0,C.useState)({top:0,left:0}),s=(0,C.useRef)(null),c=(0,C.useRef)(null),d=()=>{if(s.current&&c.current){let e=c.current.getBoundingClientRect(),t=s.current.getBoundingClientRect(),n=e.bottom+8,r=e.left+e.width/2-t.width/2;l({top:n>window.innerHeight?e.top-t.height-8:n,left:r<0?8:t.right>window.innerWidth?window.innerWidth-t.width-8:r})}};return(0,C.useEffect)(()=>{o&&d()},[o]),(0,r.jsxs)("div",{className:"relative",onMouseEnter:()=>{i(!0),d()},onMouseLeave:()=>{i(!1)},ref:c,children:[t,o&&(0,r.jsx)("p",{className:"fixed z-10 truncate rounded-md bg-gray-600 px-2 py-1 text-sm text-white shadow-lg",style:{top:a.top,left:a.left},ref:s,children:n})]})};function q(e){var t,n,o;let{content:i}=e;return(0,r.jsx)(W,{title:K(i),children:(0,r.jsxs)("a",{className:"flex cursor-pointer flex-col rounded-xl px-3 py-4 shadow-[0_-1px_12px_0px_rgba(0,0,0,0.2)]",href:K(i),target:null==i?void 0:null===(t=i.body)||void 0===t?void 0:t.target,children:[(0,r.jsx)("span",{className:"max-w-[250px] overflow-hidden text-ellipsis whitespace-nowrap font-semibold",children:null==i?void 0:null===(n=i.body)||void 0===n?void 0:n.title}),(0,r.jsx)("span",{className:"mt-2 max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap text-sm",children:null==i?void 0:null===(o=i.body)||void 0===o?void 0:o.text}),(0,r.jsx)("span",{className:"mt-7 max-w-[200px] overflow-hidden text-ellipsis whitespace-nowrap text-sm",children:K(i)})]})})}let K=e=>"object"==typeof e.body?e.body.uri:e.uri;var Z=n(8792);let J="text-sm",Y="text-sm text-info-main",Q="rounded-[5px] object-contain",X="gap-1",$="flex flex-col",ee="max-w-[300px]";var et=(0,C.forwardRef)(function(e,t){let{src:n,alt:o,fallbackMessage:i,className:a,onClick:l,onLoad:s}=e,[c,d]=(0,C.useState)(!1);return(0,r.jsx)(r.Fragment,{children:c?(0,r.jsx)("div",{className:"flex h-28 items-center justify-center rounded-t-[8px] bg-slate-100",children:(0,r.jsx)("p",{className:"text-center text-sm font-semibold text-red-400",children:i})}):(0,r.jsx)("img",{ref:t,src:n,alt:o,onError:()=>{d(!0)},onClick:l,className:a,onLoad:s})})});function en(e){let{message:t}=e,{content:n,from:o}=t,i=n.name?n.name:n.body instanceof File&&n.body.name||n.body.name?n.body.name:"",a=(0,C.useMemo)(()=>{var e;let t=(e,t)=>{let n={text:()=>(0,r.jsx)("p",{className:"".concat(J," ").concat("footer"===t?Y:""),dangerouslySetInnerHTML:{__html:O(e.text||"")}},"component-parameter-text-".concat(e.text||"")),image:()=>{var t,n;return(0,r.jsx)(et,{fallbackMessage:"N\xe3o foi poss\xedvel carregar a imagem",className:Q,src:(null===(t=e.image)||void 0===t?void 0:t.link)||"",alt:"Desk template media"},"component-parameter-image-".concat((null===(n=e.image)||void 0===n?void 0:n.link)||""))},media:()=>{var t,n;return(0,r.jsx)(et,{fallbackMessage:"N\xe3o foi poss\xedvel carregar a imagem",className:Q,src:(null===(t=e.media)||void 0===t?void 0:t.link)||"",alt:"Desk template media"},"component-parameter-media-".concat((null===(n=e.media)||void 0===n?void 0:n.link)||""))},sticker:()=>{var t,n;return(0,r.jsx)(et,{fallbackMessage:"N\xe3o foi poss\xedvel carregar a imagem",className:Q,src:null===(t=e.sticker)||void 0===t?void 0:t.link,alt:"Desk template media"},"component-parameter-sticker-".concat((null===(n=e.sticker)||void 0===n?void 0:n.link)||""))},quickReply:()=>(0,r.jsx)("button",{disabled:!0,className:"outline-primary-main w-full outline",children:e.text||""},"component-parameter-quickReply-".concat(e.text||"")),phoneNumber:()=>{var n;return(0,r.jsx)("p",{className:"".concat(J," ").concat("footer"===t?Y:""),dangerouslySetInnerHTML:{__html:O("".concat(e.text,": ").concat(null!==(n=e.phoneNumber)&&void 0!==n?n:"")||"")}},"component-parameter-phoneNumber-".concat(e.phoneNumber||""))},dynamicURL:()=>(0,r.jsx)(Z.default,{href:e.url,target:"_blank",className:"footer"===t?Y:"",children:e.text||""},"component-parameter-dynamicURL-".concat(e.text||"")),video:()=>{var t,n;return(0,r.jsx)("video",{controls:!0,className:"rounded-[5px]",children:(0,r.jsx)("source",{src:(null===(t=e.video)||void 0===t?void 0:t.link)||""})},"component-parameter-video-".concat((null===(n=e.video)||void 0===n?void 0:n.link)||""))},audio:()=>{var t,n;return(0,r.jsx)("audio",{src:null===(t=e.audio)||void 0===t?void 0:t.link,controls:!0,preload:"auto"},"component-parameter-audio-".concat((null===(n=e.audio)||void 0===n?void 0:n.link)||""))},voice:()=>{var t,n;return(0,r.jsx)("audio",{src:null===(t=e.voice)||void 0===t?void 0:t.link,controls:!0,preload:"auto"},"component-parameter-voice-".concat((null===(n=e.voice)||void 0===n?void 0:n.link)||""))},document:()=>{var t,n;return(0,r.jsx)("div",{className:"".concat($," ").concat(X," items-center"),children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("p",{className:"text-sm",children:"Template document"}),(0,r.jsx)("a",{href:null===(t=e.document)||void 0===t?void 0:t.link,download:"".concat(i," document"),target:"_blank",rel:"noreferrer",className:"cursor-pointer"})]})},"component-parameter-document-".concat((null===(n=e.document)||void 0===n?void 0:n.link)||""))}};return"function"==typeof n[e.type]?n[e.type]():(0,r.jsx)(r.Fragment,{})};return null===(e=n.body.components)||void 0===e?void 0:e.map((e,n)=>{var i;return(0,r.jsx)("div",{className:"".concat(X," whitespace-pre-wrap ").concat("justify-start"),style:{justifyContent:"CLIENT"===o?"flex-start":"flex-end"},children:e.parameters.map(n=>t(n,null==e?void 0:e.type))},"".concat(n,"-").concat(null==e?void 0:e.type,"-template-").concat(null==e?void 0:null===(i=e.parameters)||void 0===i?void 0:i.length))})},[n.body.components,o,i]);return n.body.components&&n.body.components.length>0?(0,r.jsx)("div",{className:"group relative cursor-pointer",children:(0,r.jsx)(W,{title:i,children:(0,r.jsx)("div",{className:"".concat($," ").concat(X," ").concat(ee),children:a})})}):(0,r.jsxs)("div",{className:"".concat($," ").concat(ee),children:[(0,r.jsx)("h4",{className:"text-lg",children:"Template"}),(0,r.jsx)("p",{className:"text-sm",dangerouslySetInnerHTML:{__html:F(i)}})]})}var er=n(9359);let eo=e=>"cursor-pointer text-primary w-full py-[10px] whitespace-nowrap border-[#454545] border-t pt-[1] bg-slate-100 mr-[12px] font-[600] [&:last-child]:rounded-b-[8px] transition-colors duration-300 ".concat(e&&"pointer-events-none opacity-[0.5]");function ei(e){var t,n,o,i;let{content:a,onSelectQuickReplyItem:l,isFirstMessage:s}=e,[c,d]=(0,C.useState)([]);if(null==a?void 0:null===(n=a.body)||void 0===n?void 0:null===(t=n.items)||void 0===t?void 0:t.find(e=>"object"!=typeof e))return(0,r.jsx)("div",{style:{fontSize:"12px",color:"red"},children:"Carousel com formato inv\xe1lido"});let u=(e,t,n)=>{s?!c.includes("".concat(t,"-").concat(n))&&(d(e=>[...e,"".concat(t,"-").concat(n)]),l&&l(e)):(d(["".concat(t,"-").concat(n)]),l&&l(e))};return(0,r.jsx)("div",{className:"slick-container",children:(0,r.jsx)(er.Z,{speed:100,slidesToShow:1,slidesToScroll:1,infinite:!1,draggable:!1,dots:!0,centerMode:!0,centerPadding:"4%",children:null==a?void 0:null===(i=a.body)||void 0===i?void 0:null===(o=i.items)||void 0===o?void 0:o.map((e,t)=>{var n,o,i,a,l,d,m,p,h,f,x,g,v,y;return(0,r.jsxs)("div",{className:"flex flex-col",children:[(null==e?void 0:null===(o=e.header)||void 0===o?void 0:null===(n=o.value)||void 0===n?void 0:n.uri)&&(0,r.jsx)(et,{onClick:t=>{var n,r;t.preventDefault(),b({code:"Mundiale-OpenImageModal",url:null==e?void 0:null===(r=e.header)||void 0===r?void 0:null===(n=r.value)||void 0===n?void 0:n.uri})},alt:"imagem-".concat(null==e?void 0:null===(a=e.header)||void 0===a?void 0:null===(i=a.value)||void 0===i?void 0:i.uri),className:"w-full rounded-t-[8px] cursor-pointer ",src:null==e?void 0:null===(d=e.header)||void 0===d?void 0:null===(l=d.value)||void 0===l?void 0:l.uri,fallbackMessage:"N\xe3o foi poss\xedvel carregar a imagem"}),(0,r.jsxs)("div",{className:"flex w-full h-full flex-col text-sm bg-slate-100",children:[(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:F(null==e?void 0:null===(p=e.header)||void 0===p?void 0:null===(m=p.value)||void 0===m?void 0:m.title)},className:"p-[8px] "}),(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:F((null==e?void 0:null===(f=e.header)||void 0===f?void 0:null===(h=f.value)||void 0===h?void 0:h.text).replace(/(\n|(.*?)<\/strike>)/g,(e,t,n)=>"\n"===t?"
":n?"".concat(n,""):e))},className:"font-[600px] p-[8px] mb-[2px]"})]}),(0,r.jsx)("div",{className:"w-full flex text-center flex-col text-sm rounded-b-[5px]",children:(null==e?void 0:null===(x=e.options)||void 0===x?void 0:x.length)>0&&(null==e?void 0:null===(g=e.options)||void 0===g?void 0:g.map((e,n)=>{var o,i,a,l,d,m,p,h;let f=c.includes("".concat(t,"-").concat(n)),x=!s&&c.length>0&&!f;return(0,r.jsx)("div",{onClick:()=>{x||u(e,t,n)},className:f?"cursor-pointer text-white bg-primary w-full py-[10px] whitespace-nowrap border-t pt-[1] mr-[12px] font-[600] [&:last-child]:rounded-b-[8px] transition-colors duration-300":eo(x),children:"object"==typeof(null==e?void 0:null===(o=e.label)||void 0===o?void 0:o.value)?null==e?void 0:null===(a=e.label)||void 0===a?void 0:null===(i=a.value)||void 0===i?void 0:i.text:(null==e?void 0:null===(l=e.label)||void 0===l?void 0:l.value)||""},"".concat(String(n),"-").concat("object"==typeof(null==e?void 0:null===(d=e.label)||void 0===d?void 0:d.value)?null==e?void 0:null===(p=e.label)||void 0===p?void 0:null===(m=p.value)||void 0===m?void 0:m.text:(null==e?void 0:null===(h=e.label)||void 0===h?void 0:h.value)||""))}))})]},"".concat(String(t),"-").concat(null==e?void 0:null===(y=e.header)||void 0===y?void 0:null===(v=y.value)||void 0===v?void 0:v.uri))})})})}function ea(){return(0,r.jsx)("div",{className:"flex size-8 items-center justify-center rounded-xl bg-primary",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"#FFF",width:"28px",height:"28px",viewBox:"0 0 1024 1024",children:(0,r.jsx)("path",{d:"M512 666.5L367.2 521.7l36.2-36.2 83 83V256h51.2v312.5l83-83 36.2 36.2L512 666.5zm-204.8 50.3V768h409.6v-51.2H307.2z"})})})}function el(){return(0,r.jsx)("div",{className:"size-10 ",children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"40px",height:"40px",viewBox:"0 0 24 24",fill:"none",children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13 4H7.5C6.67157 4 6 4.67157 6 5.5V18.5C6 19.3284 6.67157 20 7.5 20H16.5C17.3284 20 18 19.3284 18 18.5V9.00001H17.9959L13 4ZM12.0001 5.60357V9.75001C12.0001 9.88809 12.112 10 12.2501 10H16.3965C16.6192 10 16.7308 9.73073 16.5733 9.57324L12.4268 5.42679C12.2693 5.2693 12.0001 5.38084 12.0001 5.60357Z",fill:"#000000"})})})}function es(e){var t,n,o,i;let{content:a,isMessageBox:l}=e,s=(null===(t=a.body)||void 0===t?void 0:t.url)||(null===(n=a.body)||void 0===n?void 0:n.uri)||"",c=()=>{let e=null==s?void 0:s.lastIndexOf("/");return(null==s?void 0:s.substring(e+1))||""};return(0,r.jsxs)("div",{className:"relative flex flex-row items-center",children:[(0,r.jsx)(el,{}),(0,r.jsxs)("div",{className:"flex w-full items-center justify-start text-center gap-6",children:[(0,r.jsx)("div",{className:"flex max-w-[100%] pr-10",children:(0,r.jsx)("span",{className:"truncate pr-10",children:a.name||(null===(o=a.body)||void 0===o?void 0:o.title)||(null===(i=a.body)||void 0===i?void 0:i.text)||c()||"Nome n\xe3o informado"})}),!!l&&(0,r.jsx)("div",{className:"absolute right-0 ml-10",children:(0,r.jsx)(W,{title:"Baixar arquivo",children:(0,r.jsx)("a",{href:s,download:c(),target:"_blank",rel:"noreferrer",children:(0,r.jsx)(ea,{})})})})]})]})}n(5768),n(8694);let ec={allowedTags:["div","h1","h2","h3","h4","h5","h6","p","em","i","strong","b","del","ol","ul","li","a","img","br","span","#text","code","pre","hr","table","thead","tbody","th","tr","td","sub","sup","svg","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],allowedAttributes:{"*":["href","src","width","height","alt","accent-height","accumulate","additive","alignment-baseline","allowReorder","alphabetic","amplitude","arabic-form","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baseline-shift","baseProfile","bbox","begin","bias","by","calcMode","cap-height","class","clip","clipPathUnits","clip-path","clipRule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominant-baseline","dur","dx","dy","edgeMode","elevation","enable-background","end","exponent","externalResourcesRequired","fill","fill-opacity","fillRule","filter","filterRes","filterUnits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","format","from","fr","fx","fy","g1","g2","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","glyphRef","gradientTransform","gradientUnits","hanging","height","href","hreflang","horiz-adv-x","horiz-origin-x","id","ideographic","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lang","lengthAdjust","letter-spacing","lighting-color","limitingConeAngle","local","marker-end","marker-mid","marker-start","markerHeight","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","max","media","method","min","mode","name","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overline-position","overline-thickness","panose-1","paint-order","path","pathLength","patternContentUnits","patternTransform","patternUnits","ping","pointer-events","points","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","referrerPolicy","refX","refY","rel","rendering-intent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","scale","seed","shape-rendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","string","s","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","surfaceScale","systemLanguage","tabindex","tableValues","target","targetX","targetY","text-anchor","text-decoration","text-rendering","textLength","to","transform","type","u1","u2","underline-position","underline-thickness","unicode","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","values","vector-effect","version","vert-adv-y","vert-origin-x","vert-origin-y","viewBox","viewTarget","visibility","width","widths","word-spacing","writing-mode","x","x-height","x1","x2","xChannelSelector","y","y1","y2","yChannelSelector","z","zoomAndPan"]},nonTextTags:["style","script","textarea","option"],transformTags:{a:function(e,t){try{new URL(t.href).hostname!==location.hostname&&(t.target="_blank",t.rel="noreferrer nofollow")}catch(e){t.target="_blank",t.rel="noreferrer nofollow"}return{tagName:e,attribs:t}}}},ed=e=>e.uri||e.url?e.uri||e.url||"":"object"==typeof e.body?e.body.uri||e.body.url||"":void 0,eu=e=>R()(e,ec),em=e=>{var t,n,o;let{content:i,messagesContainer:a}=e,l=(0,C.useRef)(null),s=(0,C.useRef)(null);return(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)(et,{ref:l,fallbackMessage:"N\xe3o foi poss\xedvel carregar a imagem",onLoad:()=>{l.current&&s.current&&(s.current.style.width="".concat(l.current.clientWidth,"px"))},className:"cursor-pointer h-auto max-w-full object-contain",src:ed(i),alt:(null===(t=i.body)||void 0===t?void 0:t.title)||"Mensagem de m\xeddia - Webchat",onClick:()=>{b({code:"Mundiale-OpenImageModal",url:ed(i)})}}),(0,r.jsxs)("div",{ref:s,className:"flex flex-col text-justify mt-1 w-full",children:[(null==i?void 0:null===(n=i.body)||void 0===n?void 0:n.title)&&(0,r.jsx)("span",{className:"text-base",dangerouslySetInnerHTML:{__html:eu(i.body.title||"")}}),(null==i?void 0:null===(o=i.body)||void 0===o?void 0:o.text)&&(0,r.jsx)("span",{className:"text-sm",dangerouslySetInnerHTML:{__html:eu(i.body.text||"")}})]})]})},ep=e=>{let{content:t}=e,n=ed(t);return(0,r.jsx)("div",{className:"items-center justify-center flex-wrap gap-1 h-[40px]",children:(0,r.jsx)("audio",{className:"h-10",src:n,controls:!0,preload:"auto"})})},eh=e=>{let t=Object.freeze({audio:(0,r.jsx)(ep,{content:e.content}),voice:(0,r.jsx)(ep,{content:e.content}),image:(0,r.jsx)(em,{messagesContainer:e.messagesContainer,isFailed:e.isFailed,content:e.content}),media:(0,r.jsx)(em,{messagesContainer:e.messagesContainer,isFailed:e.isFailed,content:e.content}),sticker:(0,r.jsx)(em,{isFailed:e.isFailed,content:e.content}),video:(0,r.jsx)("video",{controls:!0,children:(0,r.jsx)("source",{src:ed(e.content)})})});return(0,r.jsx)("div",{children:t[e.content.type]})},ef=e=>"".concat(e>2||1===e?"grid grid-cols-1 ":"grid grid-cols-2 "," mt-1 gap-1 "),ex=e=>"w-full rounded-[20px] border border-primary p-2 text-primary text-sm font-medium mt-2 overflow-hidden whitespace-nowrap text-ellipsis transition-colors duration-300 ".concat(e&&"pointer-events-none opacity-[0.5]");function eg(e){var t,n,o,i,a;let{message:l,onSelectQuickReplyItem:s,messageOnClick:c,isFirstMessage:d}=e,u=null==l?void 0:l.content,[m,p]=(0,C.useState)([]);if("object"!=typeof u)return(0,r.jsx)("div",{className:"bg-white text-red-500 text-sm",children:"QuickReply com formato inv\xe1lido"});let h=null==u?void 0:null===(n=u.body)||void 0===n?void 0:null===(t=n.options)||void 0===t?void 0:t.length,f=(e,t)=>{d?p(e=>{let n="".concat(t);return e.includes(n)?e.filter(e=>e!==n):[...e,n]}):p(["".concat(t)]),s&&s(e),c&&"function"==typeof c&&c({message:l,extras:{option:e}})};return(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-black text-sm ",dangerouslySetInnerHTML:{__html:O(F((null==u?void 0:null===(o=u.body)||void 0===o?void 0:o.text)||""))}}),(0,r.jsx)("div",{className:"".concat(ef(h)),children:null==u?void 0:null===(a=u.body)||void 0===a?void 0:null===(i=a.options)||void 0===i?void 0:i.map((e,t)=>{let n=m.includes(String(t)),o=!d&&m.length>0&&!n;return(0,r.jsx)("button",{name:"quick-reply-button",className:n?"w-full rounded-[20px] border border-primary p-2 text-white bg-primary text-sm font-medium mt-2 overflow-hidden whitespace-nowrap text-ellipsis pointer-events-none transition-colors duration-300":ex(o),onClick:()=>{o||f(e,t)},children:null==e?void 0:e.text},t)})})]})}let ev=e=>{let{text:t}=e,[n,o]=(0,C.useState)(!0),i=n?"".concat(t.slice(0,500)).concat(t.length>500?"...":""):t,a=O((e=>{let t=RegExp('(?'').concat(e,""))})(i));return(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{style:{wordBreak:!function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:29;return new RegExp("\\S{".concat(t,",}")).test(e)}(i)?"break-word":"break-all",overflowWrap:"break-word"},dangerouslySetInnerHTML:{__html:a}}),t.length>500&&n&&(0,r.jsx)("button",{className:"select-none text-sm underline",onClick:()=>{o(!n)},children:"Ler mais"})]})},ey=()=>(0,r.jsx)("span",{className:"m-1 text-sm text-red-500",children:"Conte\xfado da mensagem inv\xe1lido"}),eb=L(e=>{var t;let n=null===(t=e.message.content)||void 0===t?void 0:t.type,o=["menu","quick-reply","carousel"].includes(n)&&0===e.messageIdx,i={text:()=>(0,r.jsx)(ev,{text:e.message.content.body||""}),image:()=>(0,r.jsx)(eh,{messagesContainer:e.messagesContainer,content:e.message.content,isFailed:"FAILED"===e.message.status}),media:()=>(0,r.jsx)(eh,{messagesContainer:e.messagesContainer,content:e.message.content,isFailed:"FAILED"===e.message.status}),audio:()=>(0,r.jsx)(eh,{content:e.message.content}),voice:()=>(0,r.jsx)(eh,{content:e.message.content}),video:()=>(0,r.jsx)(eh,{content:e.message.content}),sticker:()=>(0,r.jsx)(eh,{content:e.message.content}),webLink:()=>(0,r.jsx)(q,{content:e.message.content}),template:()=>(0,r.jsx)(en,{message:e.message}),"quick-reply":()=>(0,r.jsx)(eg,{onSelectQuickReplyItem:null==e?void 0:e.onSelectQuickReplyItem,message:e.message,messageOnClick:null==e?void 0:e.messageOnClick,isFirstMessage:o}),menu:()=>(0,r.jsx)(E,{onSelectQuickReplyItem:null==e?void 0:e.onSelectQuickReplyItem,message:e.message,messageOnClick:null==e?void 0:e.messageOnClick,isFirstMessage:o}),location:()=>(0,r.jsx)(V,{content:e.message.content}),carousel:()=>(0,r.jsx)(ei,{onSelectQuickReplyItem:null==e?void 0:e.onSelectQuickReplyItem,content:e.message.content,isFirstMessage:o}),document:()=>(0,r.jsx)(es,{content:e.message.content,isMessageBox:!0}),file:()=>(0,r.jsx)(es,{content:e.message.content,isMessageBox:!0})};return i[n]?i[n]():(0,r.jsx)(ey,{})},{fallback:(0,r.jsx)(ey,{})}),ew=L(C.forwardRef(function(e,t){var n,o;let{router:i}=m();return(0,r.jsxs)("div",{className:A(e),ref:t,children:[["BOT","CLIENT"].includes(e.message.from)&&(0,r.jsx)("img",{alt:"icon",className:"absolute bottom-7 left-[-28px] size-6 rounded-full",src:i.customizationConfig.image}),(0,r.jsx)("div",{className:(null===(n=e.message.content)||void 0===n?void 0:n.type)==="carousel"?"":B(e),children:(0,r.jsx)(eb,{...e})}),(0,r.jsx)("div",{className:P(e),children:e.message.receivedAt&&(0,r.jsx)("span",{className:(null===(o=e.message.content)||void 0===o?void 0:o.type)==="carousel"?"text-[10px] mt-[-14px] text-[#636363]":"text-[10px] mt-[-4px] text-[#636363]",children:function(e){let t=new Date(e);if(isNaN(t.getTime()))return"";let n=function(e){let t=new Date(e),n=t.getDate(),r=t.getMonth()+1,o=t.getFullYear();return"".concat(D(n),"/").concat(D(r),"/").concat(o)}(t),r=function(e){let t=new Date(e),n=t.getHours(),r=t.getMinutes();return"".concat(D(n),":").concat(D(r))}(t);return!function(e){let t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}(t)?"".concat(n," ").concat(r):r}(e.message.receivedAt)})})]})}),{fallback:(0,r.jsx)(()=>(0,r.jsx)("div",{className:"mb-2 space-y-2",children:(0,r.jsx)("div",{className:"mx-2 flex flex-col content-center items-center justify-center bg-white p-1 text-justify",children:(0,r.jsx)("p",{className:"text-sm text-red-500",children:"Erro ao exibir uma mensagem"})})}),{})});function ej(e){let{messagesContainer:t,channelKey:n}=e,{webChatHistory:o,isBotTyping:i,socket:a,userId:s}=m(),c=(0,C.useCallback)(e=>{var r,o,i,c,d,u,m,p,f;if("object"==typeof(null===(r=e.label)||void 0===r?void 0:r.value)&&(null===(i=e.label)||void 0===i?void 0:null===(o=i.value)||void 0===o?void 0:o.target)){window.open(null===(u=e.label)||void 0===u?void 0:null===(d=u.value)||void 0===d?void 0:d.uri,"_".concat(null===(p=e.label)||void 0===p?void 0:null===(m=p.value)||void 0===m?void 0:m.target));return}let x=e.label?{text:e.label.value,value:null!==(f=null==e?void 0:null===(c=e.value)||void 0===c?void 0:c.value)&&void 0!==f?f:e.label.value}:e,g={header:{contentType:"interactive",sender:{id:s,name:"test witcom"}},content:{postback:{type:"button",payload:{text:null==x?void 0:x.text,value:null==x?void 0:x.value}}}},v={message:l().encrypt(JSON.stringify(g),"s3UrwIOlWhu6fEonblpGNnH1hFPNB2D3"),channelKey:n};a.emit("webchat:send-message",v,e=>{let n=()=>{setTimeout(()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)},100)};"OK"===e.data.status&&h({from:"HUMAN",content:{type:"text",body:null==x?void 0:x.text},receivedAt:new Date,status:"SENT"},n),"OK"!==e.data.status&&h({from:"HUMAN",content:{type:"text",body:null==x?void 0:x.text},status:"FAILED"},n)})},[a]);return(0,r.jsx)("div",{className:"flex h-[calc(100vh_-124px)] flex-[1] flex-col",children:(0,r.jsxs)("div",{ref:t,className:"relative bg-backgroundPrimary w-full flex-[1] flex-nowrap gap-2 overflow-auto px-4 py-2",onScroll:e=>{let{currentTarget:r}=e;0===r.scrollTop&&w(t,r.scrollHeight,n)},children:[o.map((e,n)=>(0,r.jsx)(ew,{messagesContainer:t,onSelectQuickReplyItem:c,message:e,messageIdx:n},String(n))),i&&(0,r.jsx)(S,{})]})})}function ek(e){let{onClick:t}=e;return(0,r.jsx)("div",{onClick:t,className:"bg-primary flex size-8 cursor-pointer items-center justify-center rounded-full shadow-[0_-1px_7px_0px_rgba(0,0,0,0.1)] sm:size-12 ",children:(0,r.jsx)("div",{className:"size-4 sm:size-7",children:(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"#FFF",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{d:"M20.3998 10.2L5.39979 3.00005C4.69979 2.70005 3.89979 2.80005 3.29979 3.30005C2.69979 3.80005 2.39979 4.50005 2.59979 5.30005L3.69979 11H12.9998C13.5998 11 13.9998 11.4 13.9998 12C13.9998 12.6 13.5998 13 12.9998 13H3.69979L3.49979 14.8L2.59979 18.7C2.39979 19.5 2.69979 20.2001 3.29979 20.7001C3.69979 21.0001 4.09979 21.1 4.49979 21.1C4.79979 21.1 5.09979 21 5.39979 20.9L20.3998 13.7C21.0998 13.4 21.4998 12.7 21.4998 11.9C21.4998 11.2 21.0998 10.5 20.3998 10.2Z",fill:"#FFF"}),(0,r.jsx)("path",{d:"M21.3301 11.81C21.3053 11.3592 21.163 10.9227 20.9174 10.5438C20.6719 10.1649 20.3315 9.85681 19.9301 9.65004L13.5501 6.34004L7.3101 3.11004C6.80411 2.86363 6.2428 2.75284 5.68113 2.78852C5.11947 2.8242 4.57669 3.00512 4.10594 3.31358C3.6352 3.62203 3.25262 4.04744 2.99567 4.54816C2.73872 5.04888 2.6162 5.60775 2.6401 6.17004L3.2401 9.47004C3.35321 9.98213 3.64014 10.4393 4.05213 10.7638C4.46413 11.0882 4.97576 11.2601 5.5001 11.25H13.0001C13.199 11.25 13.3898 11.3291 13.5304 11.4697C13.6711 11.6104 13.7501 11.8011 13.7501 12C13.7501 12.199 13.6711 12.3897 13.5304 12.5304C13.3898 12.671 13.199 12.75 13.0001 12.75H5.1301C4.69652 12.7382 4.27204 12.8758 3.92791 13.1398C3.58377 13.4038 3.34092 13.7782 3.2401 14.2V14.2L2.6401 17.49C2.61439 18.0532 2.73558 18.6133 2.99178 19.1154C3.24798 19.6175 3.63038 20.0444 4.10143 20.3541C4.57247 20.6637 5.11596 20.8455 5.67851 20.8816C6.24106 20.9178 6.80333 20.8069 7.3101 20.56L13.5501 17.32L19.9201 14C20.3229 13.7924 20.6642 13.4828 20.9098 13.102C21.1555 12.7212 21.297 12.2826 21.3201 11.83V11.77L21.3301 11.81Z",fill:"#FFF"})]})})})}function eC(e){let{onClick:t}=e;return(0,r.jsx)("div",{onClick:t,className:"flex size-7 cursor-pointer items-center justify-center",children:(0,r.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"#454545",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("path",{d:"M12.0002 22C10.3301 21.9974 8.72925 21.3328 7.54834 20.1519C6.36744 18.9709 5.70284 17.3701 5.7002 15.7V6.38C5.7002 6.18109 5.77921 5.99032 5.91987 5.84967C6.06052 5.70902 6.25128 5.63 6.4502 5.63C6.64911 5.63 6.83987 5.70902 6.98053 5.84967C7.12118 5.99032 7.2002 6.18109 7.2002 6.38V15.69C7.2002 16.963 7.70591 18.1839 8.60608 19.0841C9.50626 19.9843 10.7272 20.49 12.0002 20.49C13.2732 20.49 14.4941 19.9843 15.3943 19.0841C16.2945 18.1839 16.8002 16.963 16.8002 15.69V6.37C16.7975 5.61056 16.494 4.88313 15.9561 4.34706C15.4181 3.811 14.6896 3.51 13.9302 3.51H13.5202C12.7608 3.51 12.0323 3.811 11.4943 4.34706C10.9564 4.88313 10.6528 5.61056 10.6502 6.37V14.75C10.6877 15.1075 10.8585 15.4378 11.1286 15.6751C11.3986 15.9123 11.7481 16.0392 12.1075 16.0304C12.4669 16.0215 12.8097 15.8777 13.0678 15.6274C13.3259 15.3772 13.4803 15.0389 13.5002 14.68V6.47C13.5002 6.27109 13.5792 6.08032 13.7199 5.93967C13.8605 5.79902 14.0513 5.72 14.2502 5.72C14.4491 5.72 14.6399 5.79902 14.7805 5.93967C14.9212 6.08032 15.0002 6.27109 15.0002 6.47V14.68C14.9664 15.4273 14.648 16.1334 14.1103 16.6535C13.5726 17.1736 12.8563 17.4684 12.1082 17.4773C11.3602 17.4863 10.6371 17.2088 10.0871 16.7017C9.53709 16.1946 9.20189 15.4963 9.1502 14.75V6.37C9.1502 5.211 9.6106 4.09948 10.4301 3.27994C11.2497 2.46041 12.3612 2 13.5202 2H13.9302C15.0892 2 16.2007 2.46041 17.0203 3.27994C17.8398 4.09948 18.3002 5.211 18.3002 6.37V15.69C18.3002 17.3618 17.6368 18.9652 16.4556 20.1483C15.2744 21.3314 13.672 21.9974 12.0002 22Z",fill:"#454545"})})})}let eN=e=>{let t=e.type.toLowerCase();return t.includes("application")||t.includes("text")?"document":t.includes("audio")?"audio":t.includes("video")?"video":t.includes("image")?"image":""},eM=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{var n;let r=null==e?void 0:null===(n=e.target)||void 0===n?void 0:n.result;t(null==r?void 0:r.replace(/^data:[^;]+;base64,/,""))},r.onerror=e=>n(e),r.readAsDataURL(e)});function eS(e){let{onClick:t}=e;return(0,r.jsx)("div",{onClick:t,className:"flex size-7 cursor-pointer items-center justify-center",children:(0,r.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("g",{id:"SVGRepo_bgCarrier","stroke-width":"0"}),(0,r.jsx)("g",{id:"SVGRepo_tracerCarrier","stroke-linecap":"round","stroke-linejoin":"round"}),(0,r.jsxs)("g",{id:"SVGRepo_iconCarrier",children:[(0,r.jsx)("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3",stroke:"#222222","stroke-linejoin":"round"}),(0,r.jsx)("path",{d:"M5.5 11C5.5 12.7239 6.18482 14.3772 7.40381 15.5962C8.62279 16.8152 10.2761 17.5 12 17.5C13.7239 17.5 15.3772 16.8152 16.5962 15.5962C17.8152 14.3772 18.5 12.7239 18.5 11",stroke:"#222222","stroke-linecap":"round","stroke-linejoin":"round"}),(0,r.jsx)("path",{d:"M12 21V19",stroke:"#222222","stroke-linecap":"round","stroke-linejoin":"round"})]})]})})}function eT(e){let{isRecording:t}=e,[n,o]=(0,C.useState)(0),i=(0,C.useRef)(null);return(0,C.useEffect)(()=>(t?i.current=setInterval(()=>{o(e=>e+1)},1e3):(i.current&&(clearInterval(i.current),i.current=null),o(0)),()=>{i.current&&clearInterval(i.current)}),[t]),(0,r.jsx)("div",{className:"w-11 overflow-auto text-[14px]",children:(e=>{let t=Math.floor(e/60).toString().padStart(2,"0"),n=(e%60).toString().padStart(2,"0");return"".concat(t,":").concat(n)})(n)})}function eL(e){let{onClick:t}=e;return(0,r.jsx)("div",{onClick:t,className:"flex size-7 cursor-pointer items-center justify-center",children:(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"#000000",children:[(0,r.jsx)("g",{id:"SVGRepo_bgCarrier","stroke-width":"0"}),(0,r.jsx)("g",{id:"SVGRepo_tracerCarrier","stroke-linecap":"round","stroke-linejoin":"round"}),(0,r.jsx)("g",{id:"SVGRepo_iconCarrier",children:(0,r.jsx)("path",{d:"M6 5H18M9 5V5C10.5769 3.16026 13.4231 3.16026 15 5V5M9 20H15C16.1046 20 17 19.1046 17 18V9C17 8.44772 16.5523 8 16 8H8C7.44772 8 7 8.44772 7 9V18C7 19.1046 7.89543 20 9 20Z",stroke:"#d82c2c","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})})]})})}function e_(e){let{clearAudio:t,isRecording:n}=e;return(0,r.jsxs)("div",{className:"ml-auto flex w-full items-center justify-around rounded border p-1",children:[(0,r.jsx)(eT,{isRecording:n}),(0,r.jsx)(eL,{onClick:t})]})}function eR(){return(0,r.jsx)("div",{className:"flex size-5 cursor-pointer items-center justify-center",children:(0,r.jsxs)("svg",{width:"30",height:"26",viewBox:"0 0 30 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{d:"M15 5.44091L25.2682 23.1818H4.73182L15 5.44091ZM15 0L0 25.9091H30L15 0Z",fill:"white"}),(0,r.jsx)("path",{d:"M16.3636 19.0911H13.6364V21.8183H16.3636V19.0911Z",fill:"white"}),(0,r.jsx)("path",{d:"M16.3636 10.9089H13.6364V17.7271H16.3636V10.9089Z",fill:"white"})]})})}function eH(e){let{channelKey:t,messagesContainer:n}=e,[o,i]=(0,C.useState)([]),[a,c]=(0,C.useState)(!1),[d,u]=(0,C.useState)(""),f=(0,C.useRef)(null),x=(0,C.useRef)(null),g=(0,C.useRef)(null),{socket:v,webChatText:y,userId:b,router:w}=m(),j=async()=>{let e=await navigator.mediaDevices.getUserMedia({audio:!0});g.current=e;let t=new MediaRecorder(e);x.current=t,t.ondataavailable=e=>{i(t=>[...t,e.data])},t.start(),c(!0)},k=()=>{u("O arquivo excede o limite de 1 MB."),setTimeout(()=>{u("")},7e3)},N=()=>{let e=new Blob(o,{type:"audio/wav"});if(e.size>1048576){k(),M();return}x.current.isToDelete||_([e]),M()},M=()=>{i([]),x.current=null,g.current=null},S=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];x.current&&(e&&(x.current.isToDelete=!0),x.current.stop(),g.current.getTracks().forEach(e=>e.stop())),c(!1)},T=()=>{""===f.current.value?(f.current.style.height="".concat(19,"px"),f.current.style.overflowY="hidden"):(f.current.style.height="".concat(f.current.scrollHeight,"px"),f.current.style.overflowY="auto")},L=(0,C.useCallback)(e=>{let r={message:l().encrypt(JSON.stringify({header:{contentType:"text",sender:{id:b,name:null}},content:{text:e}}),"s3UrwIOlWhu6fEonblpGNnH1hFPNB2D3"),channelKey:t};v.emit("webchat:send-message",r,t=>{"OK"===t.data.status&&h({from:"HUMAN",content:{type:"text",body:e},receivedAt:new Date,status:"SENT"},()=>{setTimeout(()=>{n.current&&(f.current.style.height="".concat(19,"px"),f.current.value="",n.current.scrollTop=n.current.scrollHeight)},100)}),"OK"!==t.data.status&&h({from:"HUMAN",content:{type:"text",body:e},status:"FAILED"},()=>{setTimeout(()=>{n.current&&(f.current.style.height="".concat(19,"px"),f.current.value="",n.current.scrollTop=n.current.scrollHeight)},100)})})},[v]),_=(0,C.useCallback)(async e=>{let r=Array.from(e||[]);null==r||r.forEach(async e=>{try{var r,o,i;let a=await eM(e),c={isBase64:!0,resource:{data:a},resourceType:"binary",options:JSON.stringify({context:"router",idContext:w.idRouter,type:eN(e),body:{title:e.name||"".concat(b,"-file"),mimeType:e.type.toLowerCase()}})},d=await s(c),u={from:"HUMAN",content:{type:eN(e),body:e,path:URL.createObjectURL(e),name:e.name},status:"SENT",receivedAt:new Date};(null==d?void 0:null===(r=d.data)||void 0===r?void 0:r.path)&&(u.content.body.uri=null==d?void 0:null===(i=d.data)||void 0===i?void 0:i.path);let m={header:{contentType:eN(e),sender:{id:b,name:null}},content:{[eN(e)]:{url:null===(o=u.content.body)||void 0===o?void 0:o.uri,mimeType:e.type,caption:e.name}}},p={message:l().encrypt(JSON.stringify(m),"s3UrwIOlWhu6fEonblpGNnH1hFPNB2D3"),channelKey:t};v.emit("webchat:send-message",p,e=>{let t=()=>{setTimeout(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight)},100)};"OK"===e.data.status&&h(u,t),"OK"!==e.data.status&&(u.status="FAILED",h(u,t))})}catch(e){console.error("Erro ao fazer upload de arquivo")}})},[v]);return(0,C.useEffect)(()=>{o.length>0&&N()},[o]),(0,C.useEffect)(()=>{let e=f.current;return e.addEventListener("input",T),()=>{e.removeEventListener("input",T)}},[]),(0,r.jsxs)("footer",{className:"absolute bottom-0 right-0 flex h-16 w-full items-center gap-3 px-4 shadow-[0_-1px_12px_0px_rgba(0,0,0,0.2)]",children:[d&&(0,r.jsxs)("div",{className:"absolute bottom-14 right-0 flex w-full items-center gap-1 whitespace-normal break-words bg-red-400 p-1 px-2 text-sm text-white",children:[(0,r.jsx)(eR,{}),(0,r.jsx)("span",{children:d})]}),(0,r.jsx)("input",{style:{display:"none",backgroundColor:"transparent"},id:"file-input-webchat",type:"file",name:"file",accept:"application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, image/*, text/plain, application/pdf, video/mp4, audio/x-m4a, audio/mp3",onClick:e=>{e.currentTarget.value=""},onChange:e=>{let t=e.target.files;if(t){let e=Array.from(t).filter(e=>!(e.size>1048576)||(k(),!1));e.length>0&&_(e)}},className:"hidden"}),a?(0,r.jsx)(e_,{isRecording:a,clearAudio:()=>{S(!0)}}):(0,r.jsx)("textarea",{maxLength:1024,value:y,ref:f,className:"h-5 max-h-14 w-full resize-none pr-1 text-sm leading-4 outline-none bg-transparent",placeholder:"Digite sua mensagem aqui",onChange:e=>p(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||y.trim()&&(e.preventDefault(),L(y),p("")))}}),(0,r.jsxs)("div",{className:"flex w-auto items-center justify-end gap-2 sm:gap-3",children:[(0,r.jsx)(ek,{onClick:()=>{if(a){S();return}y.trim()&&L(y)}}),w.customizationConfig.actions.allowFile&&!a&&(0,r.jsx)(eC,{onClick:()=>{var e,t;return null===(t=document)||void 0===t?void 0:null===(e=t.getElementById("file-input-webchat"))||void 0===e?void 0:e.click()}}),w.customizationConfig.actions.allowAudio&&!a&&(0,r.jsx)(eS,{onClick:j})]})]})}function eO(e){let{iconColor:t}=e;return(0,r.jsx)("div",{className:"size-10",children:(0,r.jsx)("svg",{viewBox:"0 0 40 40",fill:"black"===t?"#000000":"#fff",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("g",{transform:"translate(14.000000, 14.000000)",children:(0,r.jsx)("path",{d:"M7.62601627,5.78918918 L11.8536585,1.54054054 C12.0487805,1.34594595 12.0487805,1.05405406 11.8536585,0.859459461 L11.203252,0.178378378 C11.00813,-0.0162162161 10.7154471,-0.0162162161 10.5203252,0.178378378 L6.26016258,4.42702704 C6.13008127,4.55675677 5.93495933,4.55675677 5.80487802,4.42702704 L1.54471545,0.145945946 C1.34959349,-0.0486486486 1.05691057,-0.0486486486 0.861788617,0.145945946 L0.178861788,0.827027029 C-0.0162601625,1.02162162 -0.0162601625,1.31351352 0.178861788,1.50810811 L4.43902439,5.75675678 C4.56910569,5.88648652 4.56910569,6.08108111 4.43902439,6.21081085 L0.146341463,10.4918919 C-0.0487804876,10.6864865 -0.0487804876,10.9783784 0.146341463,11.172973 L0.829268292,11.8540541 C1.02439024,12.0486486 1.31707317,12.0486486 1.51219512,11.8540541 L5.77235773,7.60540544 C5.90243904,7.4756757 6.09756098,7.4756757 6.22764229,7.60540544 L10.4878049,11.8540541 C10.6829268,12.0486486 10.9756098,12.0486486 11.1707317,11.8540541 L11.8536585,11.172973 C12.0487805,10.9783784 12.0487805,10.6864865 11.8536585,10.4918919 L7.62601627,6.24324324 C7.49593496,6.1135135 7.49593496,5.91891892 7.62601627,5.78918918 Z",id:"path-1"})})})})}function eF(){let{router:e}=m();return(0,r.jsx)("header",{className:"bg-primary p-2 shadow-[0_-1px_12px_0px_rgba(0,0,0,0.4)]",children:(0,r.jsxs)("div",{className:"ml-2 flex h-full w-full items-center",children:[(0,r.jsx)("img",{alt:"icon",className:"size-9 rounded-full",src:e.customizationConfig.image}),(0,r.jsxs)("div",{className:"ml-4 flex flex-col text-white",children:[(0,r.jsx)("span",{children:e.customizationConfig.name}),(0,r.jsx)("span",{className:"text-sm",children:"online"})]}),(0,r.jsx)("div",{onClick:()=>{b({code:"Mundiale-CloseWidget"})},className:"ml-auto mr-2 cursor-pointer",children:(0,r.jsx)(eO,{iconColor:"white"})})]})})}function eI(){let{isTheDomainSetup:e}=m();return(0,r.jsxs)("div",{className:"h-full w-full animate-pulse bg-slate-300",children:[(0,r.jsx)("header",{className:"bg-slate-200 p-2 shadow-[0_-1px_12px_0px_rgba(0,0,0,0.4)]",children:(0,r.jsxs)("div",{className:"ml-2 flex h-full w-full items-center",children:[(0,r.jsx)("div",{className:"size-9 rounded-full bg-slate-300"}),(0,r.jsxs)("div",{className:"ml-4 flex flex-col text-white",children:[(0,r.jsx)("div",{className:"h-4 w-40 rounded-lg bg-slate-300"}),(0,r.jsx)("div",{className:"mt-2 h-2 w-20 rounded-lg bg-slate-100"})]}),(0,r.jsx)("div",{onClick:()=>{b({code:"Mundiale-CloseWidget"})},className:"ml-auto mr-2 cursor-pointer",children:(0,r.jsx)(eO,{iconColor:"black"})})]})}),!e&&(0,r.jsx)("div",{className:"flex h-4/6 items-center justify-center",children:(0,r.jsx)("span",{className:"text-red-500",children:"DOM\xcdNIO N\xc3O CONFIGURADO."})}),(0,r.jsxs)("footer",{className:"absolute bottom-0 right-0 flex h-16 w-full items-center gap-3 bg-slate-200 px-4 shadow-[0_-1px_12px_0px_rgba(0,0,0,0.2)]",children:[(0,r.jsx)("div",{className:"h-4 max-h-14 w-full rounded-lg overflow-hidden pr-1 text-sm leading-5 outline-none bg-slate-300"}),(0,r.jsxs)("div",{className:"flex w-auto items-center justify-end gap-2 sm:gap-3",children:[(0,r.jsx)("div",{className:"size-7 rounded-full bg-slate-300"}),(0,r.jsx)("div",{className:"size-7 rounded-full bg-slate-100"})]})]})]})}function eE(e){let{messagesContainer:t,channelKey:n}=e,{isLoadingWebChat:o}=m();return o?(0,r.jsx)(eI,{}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eF,{}),(0,r.jsx)(ej,{messagesContainer:t,channelKey:n}),(0,r.jsx)(eH,{channelKey:n,messagesContainer:t})]})}function eD(e){let{params:t,searchParams:n}=e,o=t.slug,i=(0,C.useRef)(null),a=o&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(o);return(0,C.useEffect)(()=>{let e=null,t=e=>{var t;"Mundiale-StartAuthenticate"===e.data.code&&a&&(null===(t=e.data)||void 0===t?void 0:t.userData)&&k(e.data.userData,o,i),"Mundiale-SendMessage"===e.data.code&&j(o,e.data.payload)};return a&&(g(e=(0,N.io)("https://com.withub.ai",{path:"/socket/webchat/socket.io",transports:["websocket","polling"]})),e.on("webchat:receive-message",e=>{let t=JSON.parse(l().decrypt(e,"s3UrwIOlWhu6fEonblpGNnH1hFPNB2D3"));if(t.contentToSend.interval){x(!0),y(i);return}f({content:{...t.contentToSend},receivedAt:new Date,from:"BOT"},()=>y(i)),b({code:"Mundiale-NewBotMessage",messageData:{botName:"Router",message:t}})}),e.on("error",e=>{console.log(e)}),e.on("disconnect",e=>{console.log("disconnect ".concat(e)),v(!0)}),e.on("connection",e=>{b({code:"Mundiale-RequestStorage"}),console.log("connection + ".concat(e))}),e.on("connect_error",e=>{console.log("connect_error ",e),x(!1)})),window.addEventListener("message",t),!d().length&&a&&(null==n?void 0:n.guest)==="true"&&k({userId:"guest",logicalProcessors:8,deviceMemory:8,gpuInfo:"guest-gpuInfo"},o,i),()=>{e&&(e.disconnect(),e=null,g(null)),window.removeEventListener("message",t)}},[a,o]),(0,r.jsx)("div",{className:"relative h-screen",children:(0,r.jsx)(eE,{channelKey:o,messagesContainer:i})})}}},function(e){e.O(0,[218,652,971,69,744],function(){return e(e.s=43)}),_N_E=e.O()}]);