PageSourceSearch

https://slantapp.ai/assets/Chat-BF8wZtX6.js

js slantapp.ai collected 2026-10-05 15:05:11 UTC 29,968 bytes, 18 lines download raw bytes

1import{aq as Y,f as G,c as R,ap as O,r as d,W as T,j as e,B as $,X as K,a7 as _,u as H,az as X,P as J,O as Q,A as Z,ay as ee,p as W,F as U,Q as z}from"./index-tc5-nNLC.js";import{E as te}from"./ellipsis-vertical-DKxVzYXD.js";import{u as se,R as ae}from"./RecommendationWizard-OoPlwljz.js";import{C as ie}from"./car-1fd8vI3H.js";import{U as ne}from"./utensils-crossed-Bhs6Ah8Z.js";import{H as re}from"./hotel-BRZfVFiM.js";import{E as oe}from"./external-link-wMXh6D17.js";import{M as le}from"./message-square-BbWo1nY5.js";import{S as de}from"./send-B0Xv9vwc.js";import{I as ce}from"./image-CUhS0kqX.js";import{L as E}from"./label-MwGx_WS4.js";import{S as I}from"./slider-C2Y0X2uK.js";import{R as me,a as M}from"./radio-group-DyfPIJZB.js";import{S as F}from"./switch-B37nBmXq.js";import{V as ue}from"./VoiceCommandTrigger-C43pwYgz.js";import"./textarea-DN2rY_yY.js";import"./arrow-left-kYemJdx8.js";import"./index-C-y5wYFI.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const xe=Y("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);function he({isOpen:t,onClose:i,onConversationSelect:n,onNewConversation:o,currentConversationId:c,onUserMenuClick:g}){const{user:r}=G();R(),O();const[f,h]=d.useState(null),{data:m=[],isLoading:y}=T({queryKey:["/api/conversations"],retry:!1}),{data:j=[],isLoading:w}=T({queryKey:["/api/companions"],retry:!1});d.useEffect(()=>{if(j.length>0&&!f){const l=j.find(v=>v.isDefault)||j[0];h(l.id)}},[j,f]);const S=()=>{const l=j.find(v=>v.id===f);l?o(l):j.length>0&&o(j[0])},b=l=>{const v=new Date,C=new Date(l),a=Math.floor((v.getTime()-C.getTime())/(1e3*60));if(a<1)return"now";if(a<60)return`${a}m`;const u=Math.floor(a/60);if(u<24)return`${u}h`;const N=Math.floor(u/24);return N<7?`${N}d`:C.toLocaleDateString()};return e.jsxs("div",{className:`
7      ${t?"mobile-sidebar open":"mobile-sidebar"}
8      md:translate-x-0 fixed md:relative z-50 w-80 bg-card border-r border-border flex flex-col h-full
9    `,children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center",children:e.jsx("i",{className:"fas fa-robot text-primary-foreground text-sm"})}),e.jsx("h1",{className:"text-lg font-semibold",children:"Slant"})]}),e.jsx($,{variant:"ghost",size:"sm",className:"md:hidden",onClick:i,"data-testid":"button-close-sidebar",children:e.jsx(K,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"p-4",children:e.jsxs($,{onClick:S,className:"w-full",disabled:w,"data-testid":"button-new-conversation",children:[e.jsx(_,{className:"h-4 w-4 mr-2"}),"New Conversation"]})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-4",children:y?e.jsx("div",{className:"space-y-3",children:[...Array(3)].map((l,v)=>e.jsx("div",{className:"animate-pulse",children:e.jsxs("div",{className:"flex items-start space-x-3 p-3",children:[e.jsx("div",{className:"w-8 h-8 bg-muted rounded-full"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-20 mb-2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-full"})]})]})},v))}):m.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{className:"text-sm",children:"No conversations yet"}),e.jsx("p",{className:"text-xs mt-1",children:"Start a new conversation to get started"})]}):e.jsx("div",{className:"space-y-2",children:m.map(l=>e.jsx("div",{className:`
10                  conversation-item p-3 rounded-lg cursor-pointer transition-colors
11                  ${c===l.id?"bg-muted":"hover:bg-muted/50"}
12                `,onClick:()=>n(l),"data-testid":`conversation-item-${l.id}`,children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 text-white text-sm font-medium",style:{backgroundColor:l.companion.color||"#8B5CF6"},children:l.companion.name.charAt(0)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm font-medium truncate","data-testid":`text-conversation-title-${l.id}`,children:l.title||l.companion.name}),e.jsx("span",{className:"text-xs text-muted-foreground","data-testid":`text-conversation-time-${l.id}`,children:b(l.lastMessageAt||new Date().toISOString())})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-1","data-testid":`text-conversation-preview-${l.id}`,children:l.lastMessage||"Start a conversation..."})]})]})},l.id))})}),e.jsx("div",{className:"p-4 border-t border-border",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("img",{src:(r==null?void 0:r.profileImageUrl)||"https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-4.0.3&auto=format&fit=crop&w=100&h=100&q=80",alt:"User profile",className:"w-10 h-10 rounded-full object-cover","data-testid":"img-user-avatar"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate","data-testid":"text-user-name",children:r!=null&&r.firstName&&(r!=null&&r.lastName)?`${r.firstName} ${r.lastName}`:(r==null?void 0:r.email)||"User"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate","data-testid":"text-user-email",children:(r==null?void 0:r.email)||"[email protected]"})]}),e.jsx($,{variant:"ghost",size:"sm",onClick:g,"data-testid":"button-user-menu",children:e.jsx(te,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"px-4 pb-3 pt-1 flex gap-3 justify-center",children:[e.jsx("a",{href:"/terms",className:"text-[10px] text-muted-foreground hover:text-teal-600 transition-colors",children:"Terms"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"·"}),e.jsx("a",{href:"/privacy",className:"text-[10px] text-muted-foreground hover:text-teal-600 transition-colors",children:"Privacy"})]})]})}function D(t){return/^401: .*Unauthorized/.test(t.message)}const V={hotel:{label:"Hotels",icon:re,color:"text-blue-500"},flight:{label:"Flights",icon:J,color:"text-violet-500"},experience:{label:"Experiences",icon:X,color:"text-emerald-500"},dining:{label:"Restaurants",icon:ne,color:"text-orange-500"},car:{label:"Car Rentals",icon:ie,color:"text-amber-500"}};function fe(t){if(t.pricePerNight)return`$${t.pricePerNight}/night`;if(t.totalAmount){const i=parseFloat(t.totalAmount);if(!isNaN(i))return`$${i.toFixed(0)} ${t.currency??""}`.trim()}if(t.price){const i=t.price;if(typeof i=="object")return i.formatted??`$${i.amount??""}`;if(typeof i=="number")return`$${i.toFixed(0)}`}return t.priceGuide?t.priceGuide:""}function pe(t,i){if(i==="flight"){const n=t.departureAt?new Date(t.departureAt).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}):"",o=t.arrivalAt?new Date(t.arrivalAt).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}
12):"",c=t.stops===0?"Nonstop":`${t.stops} stop${t.stops>1?"s":""}`;return[n&&o?`${n} → ${o}`:"",c].filter(Boolean).join(" · ")}if(i==="hotel"){const n=t.rating?`★ ${t.rating}`:"",o=t.stars?`${t.stars}★`:"";return[n,o,t.neighborhood].filter(Boolean).join(" · ")}return i==="dining"?[t.cuisineType,t.priceRange,t.rating?`★ ${t.rating}`:""].filter(Boolean).join(" · "):i==="experience"?[t.duration,t.rating?`★ ${t.rating}`:""].filter(Boolean).join(" · "):i==="car"?[t.vehicleType??t.category,t.transmission].filter(Boolean).join(" · "):""}function ge(t){return t.deepLink??t.bookingUrl??t.reservationUrl??t.widgetUrl}function je(t){return t.name??t.airline??t.airlineCode??"Option"}function ve({payload:t}){const[,i]=H(),n=V[t.category]??V.hotel,o=n.icon;return!t.results||t.results.length===0?null:e.jsxs("div",{className:"mt-3 space-y-2","data-testid":"chat-booking-cards",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{className:`w-4 h-4 ${n.color}`}),e.jsxs("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:["Live ",n.label," · ",t.destination]}),t.totalCount>t.results.length&&e.jsxs(Q,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:[t.totalCount," found"]})]}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-1 scrollbar-thin",children:[t.results.map((c,g)=>{const r=je(c),f=fe(c),h=pe(c,t.category),m=ge(c);return e.jsxs("div",{className:"flex-shrink-0 w-44 border border-border/60 rounded-xl p-3 bg-background/80 hover:border-primary/50 transition-colors shadow-sm","data-testid":`chat-booking-card-${g}`,children:[e.jsx("p",{className:"text-xs font-semibold truncate mb-0.5",title:r,children:r}),h&&e.jsx("p",{className:"text-[10px] text-muted-foreground truncate mb-1",children:h}),f&&e.jsx("p",{className:"text-xs font-bold text-primary mb-2",children:f}),m?e.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-[10px] font-medium text-primary hover:underline","data-testid":`chat-booking-book-${g}`,children:["Book ",e.jsx(oe,{className:"w-2.5 h-2.5"})]}):e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"View deal"})]},c.id??g)}),e.jsxs("button",{onClick:()=>i("/booking"),className:"flex-shrink-0 w-36 border border-dashed border-border/60 rounded-xl p-3 flex flex-col items-center justify-center gap-1 hover:border-primary/50 transition-colors text-muted-foreground hover:text-primary","data-testid":"chat-booking-see-all",children:[e.jsx(Z,{className:"w-4 h-4"}),e.jsx("span",{className:"text-[10px] font-medium text-center",children:"See all in Booking Hub"})]})]})]})}function be({payload:t}){var n;const[,i]=H();return(n=t.offers)!=null&&n.length?e.jsxs("div",{className:"mt-3 space-y-2","data-testid":"chat-chain-offer-cards",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4 text-primary"}),e.jsxs("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:["Chain offers",t.destinationCity?` · ${t.destinationCity}`:""]})]}),e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1 scrollbar-thin",children:t.offers.map((o,c)=>e.jsxs("button",{type:"button",onClick:()=>i(`/chains/${t.chainId}`),className:"flex-shrink-0 w-44 text-left border border-border/60 rounded-xl p-3 bg-background/80 hover:border-primary/50 transition-colors shadow-sm","data-testid":`chat-chain-offer-card-${c}`,"data-offer-id":o.offerId,"data-offer-relevance":o.relevance,children:[e.jsx("p",{className:"text-xs font-semibold line-clamp-2 mb-1",title:o.title,children:o.title}),e.jsxs("div",{className:"flex flex-wrap gap-1 items-center",children:[e.jsx(Q,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:o.offerType}),o.discountLabel&&e.jsx("span",{className:"text-[10px] font-medium text-primary",children:o.discountLabel})]})]},o.offerId))})]}):null}function Ne({conversationId:t,companion:i,bookingResultsByMsgId:n={},chainOffersByMsgId:o={},aiMetaByMsgId:c={}}){var C;const{toast:g}
12=R(),r=d.useRef(null),[f,h]=d.useState([]),[m,y]=d.useState(null),{lastMessage:j}=se(t||void 0),{data:w,isLoading:S,error:b}=T({queryKey:["/api/conversations",t],enabled:!!t,retry:!1});d.useEffect(()=>{if(j)switch(j.type){case"message":h(a=>{const u=j.data;return a.find(p=>p.id===u.id)?a:[...a,u]});break;case"typing":y(j.data);break}},[j]),d.useEffect(()=>{h(w?w.messages||[]:[]),y(null)},[w]),d.useEffect(()=>{var a;(a=r.current)==null||a.scrollIntoView({behavior:"smooth"})},[f,m]),d.useEffect(()=>{if(b){if(D(b)){g({title:"Unauthorized",description:"You are logged out. Logging in again...",variant:"destructive"}),setTimeout(()=>{const u=encodeURIComponent(window.location.pathname+window.location.search);window.location.href=`/api/login?returnTo=${u}`},500);return}g({title:"Error",description:"Failed to load conversation",variant:"destructive"})}},[b,g]);const l=a=>new Date(a).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}),v=a=>{const u=new Date(a),N=new Date,p=new Date(N);return p.setDate(p.getDate()-1),u.toDateString()===N.toDateString()?"Today":u.toDateString()===p.toDateString()?"Yesterday":u.toLocaleDateString()};return!t||!i?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("div",{className:"w-16 h-16 bg-primary rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("i",{className:"fas fa-robot text-primary-foreground text-xl"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Welcome to Slant"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Choose an AI companion and start a conversation to experience personalized, intelligent dialogue tailored to your needs."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Click "New Conversation" to get started'})]})}):S?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading conversation..."})]})}):e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4","data-testid":"chat-area",children:[f.length===0&&e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 text-white text-xs font-medium",style:{backgroundColor:i.color||"#8B5CF6"},children:i.name.charAt(0)}),e.jsx("div",{className:"chat-bubble-ai max-w-xs lg:max-w-md xl:max-w-lg p-3 rounded-lg",children:e.jsxs("p",{className:"text-sm","data-testid":"text-welcome-message",children:["Hi! I'm ",i.name,", your ",((C=i.personality)==null?void 0:C.toLowerCase())||"travel"," companion. I'm here to help you with whatever you need. What would you like to talk about today?"]})})]}),f.map((a,u)=>{const N=u===0||v(a.createdAt)!==v(f[u-1].createdAt);return e.jsxs("div",{children:[N&&e.jsx("div",{className:"text-center my-4",children:e.jsx("span",{className:"text-xs text-muted-foreground bg-background px-3 py-1 rounded-full border",children:v(a.createdAt)})}),e.jsxs("div",{className:`flex items-start space-x-3 ${a.role==="user"?"justify-end":""}`,children:[a.role==="assistant"&&e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 text-white text-xs font-medium",style:{backgroundColor:i.color||"#8B5CF6"},children:i.name.charAt(0)}),e.jsxs("div",{className:`
13                p-3 rounded-lg
14                ${a.role==="user"?"max-w-xs lg:max-w-md xl:max-w-lg chat-bubble-user text-primary-foreground":"max-w-xs lg:max-w-lg xl:max-w-2xl chat-bubble-ai"}
15              `,children:[e.jsx("p",{className:"text-sm whitespace-pre-wrap","data-testid":`message-content-${a.id}`,children:a.content}),e.jsx("span",{className:`text-xs mt-2 block ${a.role==="user"?"text-primary-foreground/70":"text-muted-foreground"}`,"data-testid":`message-time-${a.id}`,children:l(a.createdAt)}),a.role==="assistant"&&n[a.id]&&e.jsx(ve,{payload:n[a.id]}),a.role==="assistant"&&o[a.id]&&e.jsx(be,{payload:o[a.id]}),a.role==="assistant"&&c[a.id]&&e.jsxs("span",{className:"sr-only","data-testid":"chat-ai-meta","data-ai-provider":c[a.id].provider,"data-ai-model":c[a.id].model,"data-ai-forced":c[a.id].forced?"true":"false",children:[c[a.id].provider,":",c[a.id].model]})]}),a.role==="user"&&e.jsx("img",{src:"https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-4.0.3&auto=format&fit=crop&w=100&h=100&q=80",alt:"User avatar",className:"w-8 h-8 rounded-full object-cover flex-shrink-0"})]})]},a.id)}),(m==null?void 0:m.isTyping)&&m.companionId===i.id&&e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 text-white text-xs font-medium",style:{backgroundColor:i.color||"#8B5CF6"},children:i.name.charAt(0)}),e.jsx("div",{className:"chat-bubble-ai p-3 rounded-lg",children:e.jsxs("div",{className:"flex space-x-1","data-testid":"typing-indicator",children:[e.jsx("div",{className:"w-2 h-2 bg-muted-foreground rounded-full typing-indicator"}),e.jsx("div",{className:"w-2 h-2 bg-muted-foreground rounded-full typing-indicator",style:{animationDelay:"0.2s"}}),e.jsx("div",{className:"w-2 h-2 bg-muted-foreground rounded-full typing-indicator",style:{animationDelay:"0.4s"}})]})})]}),e.jsx("div",{ref:r})]})}function ye({suggestions:t,disabled:i,onSelect:n}){const{quickReplies:o,topics:c,emojiReactions:g}=t,r=o.length>0||c.length>0,f=g.length>0;return!r&&!f?null:e.jsxs("div",{className:"px-4 pt-3 space-y-2","data-testid":"chat-suggestions",children:[r&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.map((h,m)=>e.jsxs($,{type:"button",variant:"outline",size:"sm",className:"h-auto py-1.5 px-3 rounded-full text-xs font-normal",disabled:i,onClick:()=>n(h),"data-testid":`chip-quick-reply-${m}`,children:[e.jsx(le,{className:"h-3 w-3 mr-1.5 opacity-60"}),h]},`reply-${m}`)),c.map((h,m)=>e.jsxs($,{type:"button",variant:"secondary",size:"sm",className:"h-auto py-1.5 px-3 rounded-full text-xs font-normal",disabled:i,onClick:()=>n(h),"data-testid":`chip-topic-${m}`,children:[e.jsx(W,{className:"h-3 w-3 mr-1.5 opacity-60"}),h]},`topic-${m}`))]}),f&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:g.map((h,m)=>e.jsx("button",{type:"button",disabled:i,onClick:()=>n(h),className:"text-base leading-none px-2 py-1.5 rounded-full border border-border hover:bg-accent active:bg-accent/80 transition-colors disabled:opacity-50 disabled:pointer-events-none","data-testid":`chip-emoji-${m}`,"aria-label":`React with ${h}`,children:h},`emoji-${m}`))})]})}function we({conversationId:t,companion:i,onConversationCreated:n,onBookingResults:o,onChainOffers:c,onAiMeta:g}
15){const[r,f]=d.useState(""),[h,m]=d.useState(!1),[y,j]=d.useState(null),[w,S]=d.useState(!1),b=d.useRef(null),{toast:l}=R(),v=O();d.useEffect(()=>{j(null)},[t]);const C=U({mutationFn:async()=>(await z("POST","/api/conversations",{companionId:i.id})).json(),onSuccess:s=>{n(s.id),v.invalidateQueries({queryKey:["/api/conversations"]})},onError:s=>{if(D(s)){l({title:"Unauthorized",description:"You are logged out. Logging in again...",variant:"destructive"}),setTimeout(()=>{window.location.href=`/api/login?returnTo=${encodeURIComponent(window.location.pathname+window.location.search)}`},500);return}l({title:"Error",description:"Failed to create conversation",variant:"destructive"})}}),a=U({mutationFn:async({conversationId:s,message:x})=>(await z("POST",`/api/conversations/${s}/chat`,{message:x})).json(),onSuccess:s=>{var x,L,P,B,q;f(""),s!=null&&s.bookingResults&&((x=s==null?void 0:s.assistantMessage)!=null&&x.id)&&o&&o(s.assistantMessage.id,s.bookingResults),(P=(L=s==null?void 0:s.chainOffers)==null?void 0:L.offers)!=null&&P.length&&((B=s==null?void 0:s.assistantMessage)!=null&&B.id)&&c&&c(s.assistantMessage.id,s.chainOffers),s!=null&&s.aiMeta&&((q=s==null?void 0:s.assistantMessage)!=null&&q.id)&&g&&g(s.assistantMessage.id,s.aiMeta),j((s==null?void 0:s.suggestions)??null),v.invalidateQueries({queryKey:["/api/conversations"]}),t&&v.invalidateQueries({queryKey:["/api/conversations",t]})},onError:s=>{if(D(s)){l({title:"Unauthorized",description:"You are logged out. Logging in again...",variant:"destructive"}),setTimeout(()=>{window.location.href=`/api/login?returnTo=${encodeURIComponent(window.location.pathname+window.location.search)}`},500);return}l({title:"Error",description:"Failed to send message",variant:"destructive"})}});d.useEffect(()=>{b.current&&(b.current.style.height="auto",b.current.style.height=`${b.current.scrollHeight}px`)},[r]);const u=a.isPending||C.isPending,N=async s=>{const x=s.trim();if(!(!x||u)){j(null);try{if(t)await a.mutateAsync({conversationId:t,message:x});else{const L=await C.mutateAsync();await a.mutateAsync({conversationId:L.id,message:x})}}catch{}}},p=s=>{s.preventDefault(),N(r)},k=s=>{N(s)},A=s=>{s.key==="Enter"&&!s.shiftKey&&!h&&(s.preventDefault(),p(s))};return e.jsxs("div",{className:"bg-card border-t border-border",children:[y&&e.jsx(ye,{suggestions:y,disabled:u,onSelect:k}),e.jsxs("form",{onSubmit:p,className:"flex items-end space-x-3 p-4",children:[e.jsx("div",{className:"flex-1",children:e.jsx("div",{className:"bg-input border border-border rounded-lg p-3 min-h-[48px] max-h-32 overflow-y-auto",children:e.jsx("textarea",{ref:b,value:r,onChange:s=>f(s.target.value),onKeyDown:A,onCompositionStart:()=>m(!0),onCompositionEnd:()=>m(!1),placeholder:"Type your message...",className:"w-full resize-none outline-none bg-transparent text-sm placeholder:text-muted-foreground",rows:1,disabled:u,"data-testid":"textarea-message-input"})})}),e.jsx($,{type:"submit",disabled:!r.trim()||u,"data-testid":"button-send-message",children:u?e.jsx("div",{className:"w-4 h-4 border-2 border-primary-foreground border-t-transparent rounded-full animate-spin"}):e.jsx(de,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center justify-between px-5 pb-3 -mt-1",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-xs text-muted-foreground",children:[e.jsx($,{variant:"ghost",size:"sm",className:"h-auto p-1",disabled:!0,children:e.jsx(xe,{className:"h-3 w-3"})}),e.jsx($,{variant:"ghost",size:"sm",className:"h-auto p-1",disabled:!0,children:e.jsx(ce,{className:"h-3 w-3"})}),e.jsxs($,{variant:"ghost",size:"sm",className:"h-auto py-1 px-2 gap-1",onClick:()=>S(!0),"data-testid":"button-make-recommendation",children:[e.jsx(W,{className:"h-3 w-3"}),"Make Recommendation"]})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Shift + Enter for new line"})]}),e.jsx(ae,{open:w,onOpenChange:S,mode:{type:"companion",conversationId:t}})]})}function Ce({isOpen:t,onClose:i,currentCompanion:n,onCompanionChange:o}){const{toast:c}=R(),g=O(),[r,f]=d.useState([50]),[h,m]=d.useState([50]),[y,j]=d.use
15State([50]),[w,S]=d.useState("creative"),[b,l]=d.useState(!1),[v,C]=d.useState(!0),[a,u]=d.useState(!0),{data:N=[],isLoading:p}=T({queryKey:["/api/companions"],retry:!1}),k=U({mutationFn:async x=>{if(!n)throw new Error("No companion selected");return(await z("PATCH",`/api/companions/${n.id}`,x)).json()},onSuccess:x=>{g.invalidateQueries({queryKey:["/api/companions"]}),o(x),c({title:"Settings Updated",description:"Companion settings have been saved successfully."})},onError:x=>{if(D(x)){c({title:"Unauthorized",description:"You are logged out. Logging in again...",variant:"destructive"}),setTimeout(()=>{window.location.href=`/api/login?returnTo=${encodeURIComponent(window.location.pathname+window.location.search)}`},500);return}c({title:"Error",description:"Failed to update companion settings",variant:"destructive"})}});d.useEffect(()=>{n&&(f([n.formality||50]),m([n.enthusiasm||50]),j([n.detailLevel||50]),S(n.responseStyle||"creative"))},[n]);const A=()=>{n&&k.mutate({formality:r[0],enthusiasm:h[0],detailLevel:y[0],responseStyle:w})},s=x=>{o(x)};return t?e.jsxs("div",{className:`slide-panel ${t?"open":""} fixed right-0 top-0 h-full w-80 bg-card border-l border-border z-40 overflow-y-auto`,children:[e.jsx("div",{className:"p-4 border-b border-border",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Companion Settings"}),e.jsx($,{variant:"ghost",size:"sm",onClick:i,"data-testid":"button-close-settings",children:e.jsx(K,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"Select Companion"}),p?e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[...Array(4)].map((x,L)=>e.jsxs("div",{className:"p-3 bg-muted rounded-lg animate-pulse",children:[e.jsx("div",{className:"w-12 h-12 bg-muted-foreground/20 rounded-full mx-auto mb-2"}),e.jsx("div",{className:"h-4 bg-muted-foreground/20 rounded mx-auto mb-1"}),e.jsx("div",{className:"h-3 bg-muted-foreground/20 rounded mx-auto"})]},L))}):e.jsx("div",{className:"grid grid-cols-2 gap-3",children:N.map(x=>e.jsxs("div",{className:`
16                    p-3 border-2 rounded-lg cursor-pointer transition-colors
17                    ${(n==null?void 0:n.id)===x.id?"bg-primary/10 border-primary":"bg-muted border-border hover:border-primary/50"}
18                  `,onClick:()=>s(x),"data-testid":`companion-option-${x.id}`,children:[e.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center mx-auto mb-2 text-white font-medium",style:{backgroundColor:x.color},children:x.name.charAt(0)}),e.jsx("p",{className:"text-sm font-medium text-center",children:x.name}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:x.personality.split("&")[0].trim()})]},x.id))})]}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"Personality Traits"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(E,{className:"text-sm text-muted-foreground mb-2 block",children:"Formality"}),e.jsx(I,{value:r,onValueChange:f,max:100,step:1,className:"w-full","data-testid":"slider-formality"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mt-1",children:[e.jsx("span",{children:"Casual"}),e.jsx("span",{children:"Professional"})]})]}),e.jsxs("div",{children:[e.jsx(E,{className:"text-sm text-muted-foreground mb-2 block",children:"Enthusiasm"}),e.jsx(I,{value:h,onValueChange:m,max:100,step:1,className:"w-full","data-testid":"slider-enthusiasm"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mt-1",children:[e.jsx("span",{children:"Reserved"}),e.jsx("span",{children:"Energetic"})]})]}),e.jsxs("div",{children:[e.jsx(E,{className:"text-sm text-muted-foreground mb-2 block",children:"Detail Level"}),e.jsx(I,{value:y,onValueChange:j,max:100,step:1,className:"w-full","data-testid":"slider-detail-level"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mt-1",children:[e.jsx("span",{children:"Concise"}),e.jsx("span",{children:"Detailed"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"Response Style"}),e.jsxs(me,{value:w,onValueChange:S,children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(M,{value:"creative",id:"creative","data-testid":"radio-creative"}),e.jsx(E,{htmlFor:"creative",className:"text-sm",children:"Creative & Inspirational"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(M,{value:"analytical",id:"analytical","data-testid":"radio-analytical"}),e.jsx(E,{htmlFor:"analytical",className:"text-sm",children:"Analytical & Logical"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(M,{value:"supportive",id:"supportive","data-testid":"radio-supportive"}),e.jsx(E,{htmlFor:"supportive",className:"text-sm",children:"Supportive & Encouraging"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(M,{value:"direct",id:"direct","data-testid":"radio-direct"}),e.jsx(E,{htmlFor:"direct",className:"text-sm",children:"Direct & Efficient"})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:"Advanced Settings"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(E,{htmlFor:"voice-mode",className:"text-sm",children:"Enable Voice Mode"}),e.jsx(F,{id:"voice-mode",checked:b,onCheckedChange:l,disabled:!0,"data-testid":"switch-voice-mode"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(E,{htmlFor:"auto-save",className:"text-sm",children:"Auto-save 
18Conversations"}),e.jsx(F,{id:"auto-save",checked:v,onCheckedChange:C,"data-testid":"switch-auto-save"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(E,{htmlFor:"smart-suggestions",className:"text-sm",children:"Smart Suggestions"}),e.jsx(F,{id:"smart-suggestions",checked:a,onCheckedChange:u,"data-testid":"switch-smart-suggestions"})]})]})]}),e.jsx($,{onClick:A,disabled:k.isPending,className:"w-full","data-testid":"button-save-changes",children:k.isPending?"Saving...":"Save Changes"})]})]})]}):null}function Ve(){const[t,i]=d.useState(null),[n,o]=d.useState(null),[c,g]=d.useState(!0),[r,f]=d.useState(!1),[h,m]=d.useState({}),[y,j]=d.useState({}),[w,S]=d.useState({}),b=p=>{i(p.id),o(p.companion),g(!1)},l=p=>{i(null),o(p),g(!1)},v=p=>{i(p)},C=(p,k)=>{m(A=>({...A,[p]:k}))},a=(p,k)=>{j(A=>({...A,[p]:k}))},u=(p,k)=>{S(A=>({...A,[p]:k}))},N=()=>{f(!0)};return e.jsxs("div",{className:"h-screen flex overflow-hidden bg-background",children:[e.jsx(he,{isOpen:c,onClose:()=>g(!1),onConversationSelect:b,onNewConversation:l,currentConversationId:t,onUserMenuClick:N}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsx(Ne,{conversationId:t,companion:n,bookingResultsByMsgId:h,chainOffersByMsgId:y,aiMetaByMsgId:w}),n&&e.jsx(we,{conversationId:t,companion:n,onConversationCreated:v,onBookingResults:C,onChainOffers:a,onAiMeta:u})]}),e.jsx(Ce,{isOpen:r,currentCompanion:n,onCompanionChange:o,onClose:()=>f(!1)}),e.jsx("button",{onClick:()=>g(!0),className:"md:hidden fixed bottom-4 left-4 w-12 h-12 bg-primary rounded-full flex items-center justify-center shadow-lg z-40","data-testid":"button-open-sidebar",children:e.jsx("svg",{className:"w-6 h-6 text-primary-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),e.jsx(ue,{variant:"floating",size:"md",className:"bottom-20 right-4"})]})}export{Ve as default};

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.