PageSourceSearch

https://www.cooperpetcare.app/_next/static/chunks/5937.6f2e528bb5944fab.js

js cooperpetcare.app collected 2026-09-24 13:55:11 UTC 12,473 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5937],{55937:(e,t,a)=>{a.r(t),a.d(t,{default:()=>_});var r=a(95155),s=a(50910),n=a(12115),i=a(5269),c=a(2793),l=a(45572),o=a.n(l),u=a(23799),d=a(82849),m=a(29434),p=a(31821);let h={read:"",send:""};function f(e,t){return"failed"===t.type?{...e,[t.source]:t.message}:"read-success"===t.type?e.read?{...e,read:""}:e:h}let y="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function g(){let e=Date.now(),t="";for(let a=0;a<10;a++)t=y[e%32]+t,e=Math.floor(e/32);return t+Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>y[e%32]).join("")}async function b(e,t,a){let r=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:void 0===a?void 0:JSON.stringify(a)}),s=await r.json();if(!r.ok)throw Object.assign(Error(s.message||"No pudimos conectar"),{status:r.status});return s}async function x(e="GET",t,a){if("POST"===e&&t&&"object"==typeof t){let e=e=>{try{return localStorage.getItem(e)||d.A.get(e)||null}catch{return d.A.get(e)||null}};t={...t,order_draft_proof:function(){if("preprod.cooperpetcare.app"===window.location.hostname)try{let e=localStorage.getItem("order_temporal_data_id");if(!/^temp-order-v2-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e||""))return;let t=localStorage.getItem(`cooper_draft_credential:${e}`);return/^[a-f0-9]{64}$/.test(t||"")?{key:e,token:t}:void 0}catch{return}}(),conversion_metadata:{schema_version:1,attribution:(0,u.o2)(),referral_code:e("referral_code"),visitor_ref:e("devrev_plug_user_ref"),captured_at:new Date().toISOString()}}}return b("/api/coop-chat"+(a?"?before="+encodeURIComponent(a):""),e,t)}function _({open:e,onClose:t}){let a=(0,s.c)("coop-chat"),{isAuthenticated:l,status:u}
1=(0,m.c)(),d=(0,n.useRef)(null),[y,_]=(0,n.useState)([]),[v,j]=(0,n.useState)(!1),[w,N]=(0,n.useState)(!1),[S,T]=(0,n.useState)(!1),C=(0,n.useRef)(null),[R,E]=(0,n.useState)([]),[O,k]=(0,n.useState)(""),[$,A]=(0,n.useState)(null),[I,D]=(0,n.useReducer)(f,h),P=I.send||I.read,[F,U]=(0,n.useState)(!1),[z,G]=(0,n.useState)(""),[M,H]=(0,n.useState)({}),[L,q]=(0,n.useState)(null),[J,K]=(0,n.useState)(!1),[X,Y]=(0,n.useState)(Date.now()),Q=(0,n.useRef)(null),V=(0,n.useRef)(null),B=(0,n.useRef)(!0),W=(0,n.useRef)(null),Z=(0,n.useRef)({conversationId:null,messages:[],before:null,initialized:!1}),ee=(0,n.useRef)(0),et=e=>{var t;let a;t=Z.current,a=t.conversationId!==e.conversation_id,Z.current={conversationId:e.conversation_id,messages:Array.from(new Map([...a?[]:t.messages,e].map(e=>[e.message_id,e])).values()).sort((e,t)=>e.message_id.localeCompare(t.message_id)),before:a?null:t.before,initialized:!a&&t.initialized},E(Z.current.messages),q(Z.current.before)},ea=(e,t=!1)=>{D({type:"read-success"});let a=function(e,t,a=!1){let r=t.conversation?.conversation_id||null,s=e.conversationId!==r;return{conversationId:r,messages:Array.from(new Map([...s?[]:e.messages,...t.messages||[]].map(e=>[e.message_id,e])).values()).sort((e,t)=>e.message_id.localeCompare(t.message_id)),before:s||a||!e.initialized?t.next_before||null:e.before,initialized:!0}}(Z.current,e,t);a.conversationId!==Z.current.conversationId&&(A(null),W.current=null,C.current=null,B.current=!0),Z.current=a,E(a.messages),q(a.before),H(e.conversation?.agent_activity||{}),G(e.user_id||""),!t&&Array.isArray(e.consultations)&&(_(e.consultations),j(!1))},er=async()=>{if(d.current)return d.current;let e=await b("/api/coop-chat/account","POST",{action:"open"}),t=e.conversation?.conversation_id;if(!t)throw Object.assign(Error("No pudimos abrir tu chat"),{status:502});return d.current=t,e.user_id&&G(e.user_id),Array.isArray(e.consultations)&&_(e.consultations),j(!!e.consultations_error),t},es=async(e,t,a)=>{if("PUT"===e)throw Object.assign(Error("No disponible"),{status:405});let r=await er();return"GET"===e?b(`/api/coop-chat/account?conversation_id=${encodeURIComponent(r)}`+(a?"&before="+encodeURIComponent(a):""),"GET"):b("/api/coop-chat/account","POST",{...t,conversation_id:r})},en=async(e="GET",t,a)=>{if(!l)return x(e,t,a);try{return await es(e,t,a)}catch(r){if(401!==r.status)throw r;return d.current=null,await p.RG.refresh(!0),es(e,t,a)}},ei=(e,t="send")=>{401===e.status&&(d.current=null,_([]),j(!1),ea({conversation:null,messages:[]})),D({type:"failed",source:t,message:a(401!==e.status?"connectionFailed":l?"session-expired":"expired")})},ec=async()=>{let e=ee.current,t=await en();e===ee.current&&ea(t)};(0,n.useEffect)(()=>{let t;if(!e||"loading"===u)return;Q.current?.focus();let a=!1,r=async()=>{let e=ee.current;try{if("visible"===document.visibilityState){let t=await en();if(a||e!==ee.current)return;ea(t)}}catch(t){a||e!==ee.current||ei(t,"read")}finally{a||(t=setTimeout(r,3e3))}};return r(),()=>{a=!0,clearTimeout(t)}},[e,u,l]);let el=R.filter(e=>["ai_agent","cooper_team"].includes(e.sender_type)).at(-1)?.message_id,eo=async(e=()=>!0)=>{N(!0);try{let t=await en("POST",{action:"consultations"});if(!Array.isArray(t.consultations))throw Error("Invalid consultations");e()&&(_(t.consultations),j(!1))}catch(t){e()&&(401===t.status&&ei(t,"read"),j(!0))}finally{e()&&N(!1)}};(0,n.useEffect)(()=>{let e=d.current;if(!l||!el||!e)return;let t=!1;return eo(()=>!t),()=>{t=!0}},[l,el]),(0,n.useEffect)(()=>{let e=Math.min(...Object.values(M).filter(e=>"running"===e.phase&&e.expires_at>Date.now()).map(e=>e.expires_at));if(!Number.isFinite(e))return;let t=setTimeout(()=>Y(Date.now()),Math.max(0,e-Date.now()));return()=>clearTimeout(t)},[M,X]);let eu=Object.values(M).some(e=>"running"===e.phase&&e.expires_at>Date.now());(0,n.useEffect)(()=>{B.current&&V.current?.scrollTo({top:V.current.scrollHeight})},[R.length,eu,P]),(0,n.useEffect)(()=>{$&&Q.current?.focus()},[$]);let ed=async e=>{let t=e??O,a=e?null:$;if(t.trim()&&!F){T(!1),U(!0),D({type:"reset"}),ee.current++,W.current&&W.current.text===t.trim()&&W.current.reply_to?.message_id===a?.message_id||(W.current={text:t.trim(),reply_to:a,client_message_id:g()});try{let r=await en("POST",W.current);e||(k(e=>e===t?"":e),A(e=>e===a?null:e)),W.current=null,B.current=!0,ee.current++,et(r.message),await ec().catch(e=>ei(e,"read"))}catch(e){ei(e)}finally{U(!1)}}},em=(0,r.jsxs)("header",{className:o().header,children:[(0,r.jsx)("img",{src:"/coop-launcher/eyes.webp",alt:"",width:40,height:40,className:o().avatar}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("p",{className:o().name,children:"Coop"}),(0,r.jsx)("p",{className:o().subtitle,children:a("assistant")})]}),(l||y.length>0)&&(0,r.jsx)("button",{type:"button","aria-label":a("your-consultations"),"aria-expanded":S,onClick:()=>T(e=>!e),className:o().action,children:(0,r.jsx)(c.gY0,{size:16,"aria-hidden":"true"})}),(0,r.jsx)("button",{type:"button","aria-label":a("close"),onClick:t,className:o().action,children:(0,r.jsx)(c.Qks,{size:16,"aria-hidden":"true"})})]}),ep=(0,r.jsxs)("div",{ref:V,className:o().log,onScroll:e=>{let t=e.currentTarget;B.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:[L&&(0,r.jsx)("button",{disabled:J,className:"text-paragraph-xs",onClick:async()=>{K(!0);let e=ee.current,t=V.current,a=t?.scrollHeight||0;try{let r=await en("GET",void 0,L);if(e!==ee.current)return;ea(r,!0),requestAnimationFrame(()=>{t&&(t.scrollTop+=t.scrollHeight-a)})}catch(e){ei(e,"read")}finally{K(!1)}},children:a("older")}),!R.length&&(0,r.jsxs)("p",{className:`${o().bubble}
1 ${o().coop}`,children:[a("greeting")," ",(0,r.jsxs)("span",{className:o().emoji,children:["\uD83D\uDC15"," ","❤️‍\uD83D\uDD25"]})," ",a("welcomeDetail")]}),R.map(e=>(0,r.jsx)(i.iE,{reply:{message_id:e.message_id,sender_id:e.sender_id,type:e.content.type,text:e.content.text||""},reactions:e.reactions,actions:{reply:$,selectReply:A,currentUserId:z,react:l?void 0:async(e,t)=>{await x("PUT",{message_id:e,emoji:t}),await ec()}},labels:{reply:a("reply"),react:a("react"),failed:a("reactionFailed"),options:a("messageOptions")},children:(0,r.jsxs)("div",{className:`${o().row} ${["guest","customer"].includes(e.sender_type)?o().rowOwn:""}`,children:[["guest","customer"].includes(e.sender_type)&&(0,r.jsx)(i.R2,{own:!0}),(0,r.jsxs)("div",{className:`${o().bubble} ${["guest","customer"].includes(e.sender_type)?o().guest:o().coop} ${"audio"===e.content.type&&!e.content.text?o().mediaOnly:""}`,children:[e.content.reply_to&&(0,r.jsx)(i.FU,{reply:e.content.reply_to,label:a("quote")}),(0,r.jsx)(i.JX,{text:e.content.text||"",quoteLabel:a("quote")}),e.content.attachment_id&&(0,r.jsx)(i.ag,{type:e.content.type,src:e.content.image_url||e.content.audio_url||e.content.video_url,label:a("attachment-image"),audioLabels:{play:a("attachment-play"),pause:a("attachment-pause")}}),["ai_agent","cooper_team"].includes(e.sender_type)&&e.content.consultation&&(0,r.jsx)(i.sY,{...y.find(t=>t.id===e.content.consultation.id)||e.content.consultation,labels:{open:a("attachment-caseOpen"),resolved:a("attachment-caseResolved")}})]}),!["guest","customer"].includes(e.sender_type)&&(0,r.jsx)(i.R2,{})]})},e.message_id)),P&&(0,r.jsxs)("div",{role:"alert",className:`${o().bubble} ${o().coop}`,children:[P," ",(0,r.jsx)("button",{type:"button",className:"underline",onClick:()=>{D({type:"reset"}),ec().catch(e=>ei(e,"read"))},children:a("retry")})]}),eu&&(0,r.jsxs)("div",{role:"status","aria-label":a("typing"),className:`${o().bubble} ${o().coop} ${o().typing}`,children:[(0,r.jsx)("i",{"aria-hidden":"true"}),(0,r.jsx)("i",{"aria-hidden":"true"}),(0,r.jsx)("i",{"aria-hidden":"true"})]})]}),eh=(0,r.jsxs)("footer",{className:"shrink-0",children:[!R.length&&(0,r.jsx)("div",{className:o().chips,children:["walks","training","boarding"].map(e=>(0,r.jsx)("button",{type:"button",disabled:F,className:o().chip,onClick:()=>void ed(a(e)),children:a(e)},e))}),$&&(0,r.jsx)(i.FU,{reply:$,label:a("replying"),cancelLabel:a("cancelReply"),onCancel:()=>A(null)}),(0,r.jsxs)("div",{className:`${o().composer} relative`,children:[(0,r.jsx)(i.et,{className:"contents",micClassName:o().mic,hideMic:!!O.trim(),disabled:F||!e,labels:{attach:a("attachment-attach"),record:a("attachment-record"),stop:a("attachment-stop"),cancel:a("attachment-cancel"),send:a("attachment-send"),failed:a("attachment-failed"),limits:a("attachment-limits"),image:a("attachment-image"),stopReview:a("attachment-stopReview"),play:a("attachment-play"),pause:a("attachment-pause"),discard:a("attachment-discard")},onSend:async e=>{U(!0),D({type:"reset"}),ee.current++;try{let t;if(C.current?.file!==e){let t=await (0,i.vX)(e,e=>en("POST",e));C.current={file:e,body:{...t,text:O.trim(),reply_to:$,client_message_id:g()}}}let a=C.current.body;try{t=await en("POST",a)}catch(e){throw 401===e.status&&(C.current=null),e}C.current=null,k(e=>{var t;return t=String(a.text||""),e===t?"":e}),A(null),B.current=!0,ee.current++,et(t.message),await ec().catch(e=>ei(e,"read"))}finally{U(!1)}}}),(0,r.jsx)(i.dw,{emojiLabel:a("emoji"),onEmoji:e=>{k(t=>t+e),Q.current?.focus()},ref:Q,"aria-label":a("message"),rows:1,maxLength:5e3,value:O,onChange:e=>k(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),ed())},placeholder:a("placeholder"),className:o().input}),!!O.trim()&&(0,r.jsx)("button",{type:"button","aria-label":a("send"),disabled:F,onClick:()=>void ed(),className:o().send,children:(0,r.jsx)(c.avw,{size:17,"aria-hidden":"true"})})]}),!l&&"loading"!==u&&(0,r.jsxs)("p",{className:o().account,children:[a("account")," ",(0,r.jsx)("a",{className:"underline",href:"/auth?redirect=%2Fdashboard%2Fsoporte%2Fchat",children:a("login")}),"."]}),(0,r.jsxs)("div",{className:o().powered,children:[(0,r.jsx)("span",{children:"Powered by"}),(0,r.jsx)("img",{src:"/coop-launcher/wordmark.webp",alt:"Cooper",height:11})]})]});if("loading"===u)return(0,r.jsx)(i.n0,{className:"h-full",header:em,footer
1:(0,r.jsx)("div",{}),children:(0,r.jsx)("p",{className:o().account,children:a("loading")})});let ef=v?(0,r.jsxs)("div",{role:"alert",className:"px-4 py-2 text-sm",children:[(0,r.jsx)("p",{children:a("consultations-error")}),(0,r.jsx)("button",{type:"button",disabled:w,"aria-busy":w,className:"underline",onClick:()=>void eo(),children:a(w?"loading":"retry")})]}):null,ey=(0,r.jsxs)("div",{className:o().cases,children:[(0,r.jsx)("p",{className:o().casesTitle,children:a("your-consultations")}),(y.length>0||!v)&&(0,r.jsx)(i.Ah,{items:y,labels:{empty:a("consultations-empty"),open:a("consultations-open"),resolved:a("consultations-resolved")}})]});return(0,r.jsxs)(i.n0,{className:"h-full",header:em,footer:eh,children:[ef,S?ey:ep]})}}}]);

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.