PageSourceSearch

https://www.raixer.com/assets/ChatBubble-kGWaGnp1.js

js raixer.com collected 2026-10-02 20:09:20 UTC 7,033 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/button-2kgo6WVR.js","assets/utils-BGkA_7jJ.js","assets/index-ClFcW42D.js","assets/react-query-D7GX_s2z.js","assets/helmet-_v06W0yj.js","assets/createLucideIcon-C621SLsM.js","assets/index-DkYche_m.css"])))=>i.map(i=>d[i]);
2import{n as D,a as R,b as U,_ as T,u as V}from"./index-ClFcW42D.js";import{r,j as t}from"./react-vendor-DL_jcNr5.js";import{B as $}from"./button-2kgo6WVR.js";import{B as W}from"./badge-BnwT9Ldl.js";import{c as L}from"./utils-BGkA_7jJ.js";import{R as K}from"./raixer-isotipo-ZbXC9h3B.js";import{X as P}from"./x-h9zEmomr.js";import{supabase as I}from"./client-CuOizFn0.js";import{u as X}from"./use-mobile-DLxQZ8SG.js";import{n as Y}from"./tracking-DO_W2PNK.js";import{M as q}from"./message-circle-foJe5z6b.js";const J=({message:e,delay:o,onDismiss:i,onOpenChat:c})=>{const[w,u]=r.useState(!1),[s,l]=r.useState(!1);r.useEffect(()=>{const a=setTimeout(()=>{u(!0)},o*1e3);return()=>clearTimeout(a)},[o]);const p=a=>{a.stopPropagation(),l(!0),setTimeout(()=>{i()},200)},m=()=>{l(!0),setTimeout(()=>{c()},200)};return w?t.jsx("div",{className:L("fixed bottom-24 right-6 z-40 max-w-[300px] sm:max-w-[320px] cursor-pointer","animate-in slide-in-from-bottom-2 fade-in duration-300",s&&"animate-out slide-out-to-bottom-2 fade-out duration-200"),onClick:m,children:t.jsxs("div",{className:"bg-background border border-border rounded-2xl shadow-lg p-4 relative",children:[t.jsx($,{variant:"ghost",size:"icon","aria-label":"Close",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-foreground hover:bg-muted/50",onClick:p,children:t.jsx(P,{className:"h-3.5 w-3.5"})}),t.jsxs("div",{className:"flex gap-3 pr-6",children:[t.jsx("div",{className:"h-10 w-10 rounded-full bg-white border border-gray-300 flex items-center justify-center shrink-0 p-2",children:t.jsx("img",{src:K,alt:"Raixer",className:"h-full w-full"})}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"text-sm text-foreground leading-relaxed",children:e})})]}),t.jsx("div",{className:"absolute -bottom-2 right-8 w-4 h-4 bg-background border-b border-r border-border rotate-45",style:{transform:"rotate(45deg)"}})]})}):null};function F(){const e=D();return e?.token?{Authorization:`Bearer ${e.token}`,"X-Raixer-User-Id":e.userId,"X-Raixer-Refresh-Token":e.refreshToken}:{}}const H=()=>T(()=>import("./public-supabase-DgsjrF1X.js"),[]).then(e=>e.publicSupabase),A="raixer_proactive_dismissed",z=()=>{try{const e=sessionStorage.getItem(A);return e?JSON.parse(e):{}}catch{return{}}},G=e=>{try{const o=z();o[e]=Date.now(),sessionStorage.setItem(A,JSON.stringify(o))}catch{}},Q=e=>!!z()[e],Z=()=>{const{pathname:e}=R(),{language:o}=U(),[i,c]=r.useState(null),[w,u]=r.useState(!0);return r.useEffect(()=>{let l=!1;const p=async()=>{if(!l){try{const b=await H(),{data:_,error:C}=await b.from("chat_proactive_messages").select("*").eq("is_active",!0).order("priority",{ascending:!1});if(C){c(null),u(!1);return}if(!_||_.length===0){c(null),u(!1);return}const n=e.replace(/\/$/,"")||"/",g=_.find(x=>{const h=x.route_pattern;switch(x.route_match_type){case"exact":return n===h||n===`/${o}${h}`||h==="/"&&(n===""||n===`/${o}`);case"contains":return n.includes(h);case"starts_with":return n.startsWith(h)||n.startsWith(`/${o}${h}`);default:return!1}});if(g&&!Q(g.id)){const x=`message_${o}`,h=g[x]||g.message_es;c({message:h,delay:g.delay_seconds,id:g.id})}else c(null)}catch{c(null)}u(!1)}};let m=!1;const a=()=>{m||(m=!0,v(),window.setTimeout(()=>p(),1500))},v=()=>{window.removeEventListener("pointerdown",a),window.removeEventListener("keydown",a),window.removeEventListener("scroll",a),window.removeEventListener("touchstart",a)};return window.addEventListener("pointerdown",a,{passive:!0,once:!0}),window.addEventListener("keydown",a,{once:!0}),window.addEventListener("scroll",a,{passive:!0,once:!0}),window.addEventListener("touchstart",a,{passive:!0,once:!0}),()=>{l=!0,v()}},[e,o]),{proactiveMessage:i,isLoading:w,dismissMessage:l=>{G(l),c(null)}}},ee=r.lazy(()=>T(()=>import("./ChatWindow-dnq_Ilrg.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),te=["/admin","/blog/admin","/recursos/admin","/account"],N="raixer_chat_visitor_id",y="raixer_chat_conversation_id",se=()=>`visitor_${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}`,re=()=>{let e=localStorage.getItem(N);return e||(e=se(),localStorage.setItem(N,e)),e},k=()=>localStorage.getItem(y),O=e=>{localStorage.setItem(y,e)},ae=()=>{const{isAuthenticated:e,user:o}=V(),{proactiveMessage:i,dismissMessage:c}=Z(),w=X(),u=R(),[s,l]=r.useState(!1),[p]=r.useState(re),[m,a]=r.useState(0),[v,b]=r.useState(k),[_,C]=r.useState(null),n=te.some(f=>u.pathname===f||u.pathname.startsWith(`${f}/`)),g=r.useCallback(async()=>
2{if(n||u.pathname.startsWith("/admin"))return;const f=D(),{data:{session:E}}=await I.auth.getSession(),M=E?.user?.email||f?.user?.email,S=F();if(M){const{data:d}=await I.functions.invoke("chat-messages",{body:{visitorId:p,findByEmail:!0},headers:S});if(d?.success&&d?.conversationId){b(d.conversationId),O(d.conversationId);return}}const j=k();if(j)try{const d=await I.functions.invoke("chat-messages",{body:{conversationId:j,visitorId:p},headers:S}),oe=d.error?.message||d.data?.error;if(!!d.error||d.data?.error==="Unauthorized"||d.data?.error==="Conversation not found"||!d.data?.success){localStorage.removeItem(y),b(null);return}b(j);return}catch{localStorage.removeItem(y),b(null);return}},[p,n,u.pathname,o?.email]);r.useEffect(()=>{n||g()},[g,n]),r.useEffect(()=>{if(!v||s||n)return;const f=I.channel(`chat_bubble_${v}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"chat_messages",filter:`conversation_id=eq.${v}`},E=>{E.new.sender_type!=="visitor"&&a(S=>S+1)}).subscribe();return()=>{I.removeChannel(f)}},[v,s]),r.useEffect(()=>{s&&a(0)},[s]);const x=()=>{s||Y(),l(!s)},h=f=>{b(f),O(f)},B=()=>{i&&(C(i.message),c(i.id)),l(!0)};return n?null:t.jsxs(t.Fragment,{children:[!s&&i&&t.jsx(J,{message:i.message,delay:i.delay,onDismiss:()=>c(i.id),onOpenChat:B}),s&&t.jsx(r.Suspense,{fallback:null,children:t.jsx(ee,{visitorId:p,conversationId:v,onClose:()=>l(!1),onConversationCreated:h,initialProactiveMessage:_})}),(!s||!w)&&t.jsxs("div",{className:"fixed bottom-6 right-6 z-50",children:[t.jsx($,{onClick:x,size:"icon","aria-label":s?"Close chat":"Open chat",className:L("h-14 w-14 rounded-full shadow-lg bg-raixer hover:bg-raixer/90 transition-all duration-300",!s&&m>0&&"animate-bubble-breathe"),style:!s&&m>0?{boxShadow:"0 0 0 4px hsla(346, 85%, 49%, 0.3)"}:void 0,children:s?t.jsx(P,{className:"h-6 w-6 text-white"}):t.jsx(q,{className:"h-7 w-7 text-white"})}),!s&&m>0&&t.jsx(W,{className:"absolute -top-1 -right-1 h-5 w-5 flex items-center justify-center p-0 text-xs bg-white text-black border border-gray-200 shadow-sm font-semibold",children:m>9?"9+":m})]})]})},be=Object.freeze(Object.defineProperty({__proto__:null,default:ae},Symbol.toStringTag,{value:"Module"}));export{be as C,F as g};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.