1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7177],{1811:(e,t,r)=>{"use strict";r.d(t,{y:()=>b,p:()=>f});var s=r(95155),a=r(12115),n=r(96648),o=r(611),l=r(39491),i=r(35124);let c="9b15c11ff99747ca1d79288e9e9f501e",d=!1,u=(e,t)=>{if(d)try{o.u4(e,t)}catch(t){console.error("Error tracking Amplitude event:",e,t)}},m=(e,t)=>{if(d)try{if(o.do(e),t){let e=new l.T$;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.set(r,t[r]);o.ls(e)}}catch(t){console.error("Error identifying Amplitude user:",e,t)}},h=()=>{if(d)try{o.cL()}catch(e){console.error("Error resetting Amplitude user:",e)}},p=async function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r="/api/analytics",s=JSON.stringify({eventType:e.eventType,...e.data});if(t&&navigator.sendBeacon)try{let t=new Blob([s],{type:"application/json"});navigator.sendBeacon(r,t)||console.warn("navigator.sendBeacon failed for internal analytics event:",e.eventType)}catch(e){console.error("Error sending beacon for internal analytics:",e)}else try{let e=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0});e.ok||console.error("Failed to log internal analytics event:",e.status,e.statusText)}catch(e){console.error("Error logging internal analytics event:",e)}},g=e=>{let t={...e};for(let e in"details"in t&&delete t.details,t)"object"!=typeof t[e]||null===t[e]||Array.isArray(t[e])||(console.warn("AnalyticsContext: Removing non-primitive property '".concat(e,"' from Amplitude event.")),delete t[e]);return t},x=(0,a.createContext)({trackPageView:e=>console.warn("AnalyticsContext: trackPageView called before provider was ready.",e),trackTimeSpentEvent:(e,t)=>console.warn("AnalyticsContext: trackTimeSpentEvent called before provider was ready.",e,t),trackInteraction:e=>console.warn("AnalyticsContext: trackInteraction called before provider was ready.",e),identifyUser:(e,t)=>console.warn("AnalyticsContext: identifyUser called before provider was ready.",e,t),resetUser:()=>console.warn("AnalyticsContext: resetUser called before provider was ready.")}),f=()=>{let e=(0,a.useContext)(x);if(void 0===e)throw Error("useAnalyticsContext must be used within an AnalyticsProvider");return e},b=e=>{let{children:t}=e,[r]=(0,a.useState)(()=>(0,n.U)()),[l,f]=(0,a.useState)(null);(0,a.useEffect)(()=>{(()=>{if(!c)return console.warn("Amplitude API Key (NEXT_PUBLIC_AMPLITUDE_API_KEY) is not set. Amplitude analytics disabled.");if(!d)try{let e=(0,i.j)({sampleRate:1});o.WQ(e),console.log("Amplitude Session Replay plugin added."),o.Ts(c,void 0,{defaultTracking:!0}),d=!0,console.log("Amplitude SDK initialized.")}catch(e){console.error("Error initializing Amplitude or Session Replay:",e)}})()},[]),(0,a.useEffect)(()=>{(async()=>{try{let{data:{user:e}}=await r.auth.getUser();f(e),e&&(m(e.id),console.log("AnalyticsProvider: Initial user identified",e.id))}catch(e){console.error("AnalyticsProvider: Error fetching initial user",e)}})();let{data:e}=r.auth.onAuthStateChange((e,t)=>{var r;console.log("AnalyticsProvider: Auth event received -",e),f(null!=(r=null==t?void 0:t.user)?r:null),"SIGNED_IN"===e&&(null==t?void 0:t.user)?(m(t.user.id),console.log("AnalyticsProvider: User SIGNED_IN, identified",t.user.id)):"SIGNED_OUT"===e&&(h(),console.log("AnalyticsProvider: User SIGNED_OUT, Amplitude user reset"))});return()=>{null==e||e.subscription.unsubscribe()}},[r]);let b=(0,a.useCallback)(e=>{p({eventType:"pageView",data:e}),u("Page View",g(e))},[]),v=(0,a.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];p({eventType:"timeSpent",data:e},t),t||u("Time Spent",g(e))},[]),y=(0,a.useCallback)(e=>{p({eventType:"interaction",data:e}),u(e.interactionType,g(e))},[]),w=(0,a.useCallback)((e,t)=>{m(e,t)},[]),j=(0,a.useCallback)(()=>{h()},[]);return(0,s.jsx)(x.Provider,{value:{trackPageView:b,trackTimeSpentEvent:v,trackInteraction:y,identifyUser:w,resetUser:j},children:t})}},3998:(e,t,r)=>{"use strict";r.d(t,{$n:()=>c});var s=r(95155),a=r(12115),n=r(32467),o=r(83101),l=r(64269);let i=(0,o.F)("relative inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all duration-300 overflow-hidden focu
1s-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 group",{variants:{variant:{default:"bg-blue-50 text-blue-700 border border-blue-200 hover:bg-blue-100 hover:border-blue-300 hover:shadow-sm",destructive:"bg-red-50 text-red-700 border border-red-200 hover:bg-red-100 hover:border-red-300 hover:shadow-sm",outline:"border border-[0.5px] border-blue-200 text-blue-700 bg-background hover:bg-blue-50 hover:text-blue-700 hover:border-blue-300 hover:shadow-sm",secondary:"bg-gray-50 text-gray-700 border border-gray-200 hover:bg-gray-100 hover:border-gray-300 hover:shadow-sm",ghost:"bg-transparent border border-transparent text-blue-700 hover:bg-blue-50 hover:text-blue-800 hover:border-blue-200 focus-visible:ring-1 focus-visible:ring-blue-300",link:"text-blue-600 underline-offset-4 hover:underline",premium:"relative overflow-hidden rounded-xl bg-gradient-to-r from-blue-600 to-blue-700 text-white font-medium border border-blue-400 shadow-sm hover:shadow-blue-500/25 transition-all","premium-cyan":"relative overflow-hidden rounded-xl bg-gradient-to-r from-premium-cyan-from to-premium-cyan-to text-white border border-cyan-400 shadow-cyan-glow hover:shadow-cyan-glow-lg","premium-gold":"relative overflow-hidden rounded-xl bg-gradient-to-r from-premium-gold-from to-premium-gold-to text-white border border-yellow-400 shadow-gold-glow hover:shadow-gold-glow-lg","premium-slate":"relative overflow-hidden rounded-xl bg-gradient-to-r from-premium-slate-from to-premium-slate-to text-white border border-slate-400 shadow-slate-glow hover:shadow-slate-glow-lg","premium-emerald":"relative overflow-hidden rounded-xl bg-gradient-to-r from-premium-emerald-from to-premium-emerald-to text-white border border-emerald-400 shadow-emerald-glow hover:shadow-emerald-glow-lg","premium-rose":"relative overflow-hidden rounded-xl bg-gradient-to-r from-premium-rose-from to-premium-rose-to text-white border border-rose-400 shadow-rose-glow hover:shadow-rose-glow-lg"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",md:"h-10 rounded-md px-6",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"},animation:{none:"",static:"group",shimmer:"animate-shimmer group",pulse:"animate-pulse-glow group"}},defaultVariants:{variant:"default",size:"default",animation:"static"}}),c=a.forwardRef((e,t)=>{let{className:r,variant:a,size:o,animation:c="static",asChild:x=!1,children:f,...b}=e,v=null==a?void 0:a.toString().includes("premium");if(x){let e=n.DX;return(0,s.jsx)(e,{className:(0,l.cn)(i({variant:a,size:o,animation:c,className:r})),ref:t,...b,children:f})}return(0,s.jsxs)("button",{className:(0,l.cn)(i({variant:a,size:o,animation:c,className:r})),ref:t,...b,children:[v&&"none"!==c&&function(e){switch(e){case"premium-cyan":return(0,s.jsx)(u,{});case"premium-gold":return(0,s.jsx)(m,{});case"premium-slate":return(0,s.jsx)(h,{});case"premium-emerald":return(0,s.jsx)(p,{});case"premium-rose":return(0,s.jsx)(g,{});default:return(0,s.jsx)(d,{})}}(null!=a?a:void 0),!v&&"none"!==c&&(0,s.jsx)("span",{className:"absolute inset-0 opacity-0 bg-white/5 group-hover:opacity-100 transition-opacity duration-300"}),(0,s.jsx)("span",{className:"relative z-10 flex items-center gap-2",children:f})]})});c.displayName="Button";let d=()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"absolute inset-0 w-full h-full opacity-0 group-hover:opacity-100 transition-all duration-500 ease-[cubic-bezier(0.22,1,0.36,1)]",children:(0,s.jsx)("span",{className:"absolute inset-0 w-0 scale-x-0 group-hover:w-full group-hover:scale-x-100 bg-gradient-to-r from-blue-600 via-blue-500 to-blue-600 transition-all duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] origin-left"})}),(0,s.jsx)("span",{className:"absolute inset-[-1px] rounded-xl overflow-hidden pointer-events-none",children:(0,s.jsx)("span",{className:"absolute inset-0 bg-gradient-to-r from-blue-200/60 via-blue-300/80 to-blue-200/60 opacity-0 group-hover:opacity-100 animate-border-shine transition-opacity duration-500"})}),(0,s.jsx)("span",{className:"absolute inset-[1px] rounded-xl overflow-hidden pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-500",children:(0,s.jsx)("span",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"})}),(0,s.jsx)("span",{className:"absolute inset-0 rounded-xl opacity-20 group-hover:opacity-40 blur-[1px] pointer-events-none transition-opacity duration-500",children:(0,s.jsx)("span",{className:"absolute inset-0 bg-blue-500/5 rounded-xl"})})]}),u=()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"absolute inset-0 w-full h-full opacity-0 group-hover:opacity-100 transition-all duration-500 ease-[
1cubic-bezier(0.22,1,0.36,1)]",children:(0,s.jsx)("span",{className:"absolute inset-0 w-0 scale-x-0 group-hover:w-full group-hover:scale-x-100 bg-gradient-to-r from-cyan-600 via-cyan-500 to-cyan-600 transition-all duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] origin-left"})}),(0,s.jsx)("span",{className:"absolute inset-[-1px] rounded-xl overflow-hidden pointer-events-none",children:(0,s.jsx)("span",{className:"absolute inset-0 bg-gradient-to-r from-cyan-200/60 via-cyan-300/80 to-cyan-200/60 opacity-0 group-hover:opacity-100 animate-border-shine transition-opacity duration-500"})}),(0,s.jsx)("span",{className:"absolute inset-[1px] rounded-xl overflow-hidden pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-500",children:(0,s.jsx)("span",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"})}),(0,s.jsx)("span",{className:"absolute inset-0 rounded-xl opacity-20 group-hover:opacity-40 blur-[1px] pointer-events-none transition-opacity duration-500",children:(0,s.jsx)("span",{className:"absolute inset-0 bg-cyan-500/5 rounded-xl"})})]}),m=()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"absolute inset-0 w-full h-full bg-gradient-to-r from-yellow-600 via-yellow-500 to-yellow-400 opacity-0 hover:opacity-100 transition-opacity duration-300"}),(0,s.jsx)("span",{className:"absolute inset-0 w-0 bg-gradient-to-r from-yellow-400 via-yellow-500 to-yellow-600 opacity-0 hover:opacity-100 transition-all duration-500 hover:w-full"}),(0,s.jsx)("span",{className:"absolute inset-0 rounded-xl opacity-0 hover:opacity-100 transition-opacity duration-300 bg-gradient-to-r from-yellow-600/20 via-yellow-500/20 to-yellow-400/20 blur-md"}),(0,s.jsx)("span",{className:"absolute inset-0 -z-10 rounded-xl opacity-50 blur-md bg-gradient-to-r from-yellow-600/20 via-yellow-500/20 to-yellow-400/20"})]}),h=()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"absolute inset-0 w-full h-full bg-gradient-to-r from-slate-700 via-slate-600 to-slate-500 opacity-0 hover:opacity-100 transition-opacity duration-300"}),(0,s.jsx)("span",{className:"absolute inset-0 w-0 bg-gradient-to-r from-slate-500 via-slate-600 to-slate-700 opacity-0 hover:opacity-100 transition-all duration-500 hover:w-full"}),(0,s.jsx)("span",{className:"absolute inset-0 rounded-xl opacity-0 hover:opacity-100 transition-opacity duration-300 bg-gradient-to-r from-slate-700/20 via-slate-600/20 to-slate-500/20 blur-md"}),(0,s.jsx)("span",{className:"absolute inset-0 -z-10 rounded-xl opacity-50 blur-md bg-gradient-to-r from-slate-700/20 via-slate-600/20 to-slate-500/20"})]}),p=()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"absolute inset-0 w-full h-full bg-gradient-to-r from-emerald-600 via-emerald-500 to-emerald-400 opacity-0 hover:opacity-100 transition-opacity duration-300"}),(0,s.jsx)("span",{className:"absolute inset-0 w-0 bg-gradient-to-r from-emerald-400 via-emerald-500 to-emerald-600 opacity-0 hover:opacity-100 transition-all duration-500 hover:w-full"}),(0,s.jsx)("span",{className:"absolute inset-0 rounded-xl opacity-0 hover:opacity-100 transition-opacity duration-300 bg-gradient-to-r from-emerald-600/20 via-emerald-500/20 to-emerald-400/20 blur-md"}),(0,s.jsx)("span",{className:"absolute inset-0 -z-10 rounded-xl opacity-50 blur-md bg-gradient-to-r from-emerald-600/20 via-emerald-500/20 to-emerald-400/20"})]}),g=()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"absolute inset-0 w-full h-full bg-gradient-to-r from-rose-600 via-rose-500 to-rose-400 opacity-0 hover:opacity-100 transition-opacity duration-300"}),(0,s.jsx)("span",{className:"absolute inset-0 w-0 bg-gradient-to-r from-rose-400 via-rose-500 to-rose-600 opacity-0 hover:opacity-100 transition-all duration-500 hover:w-full"}),(0,s.jsx)("span",{className:"absolute inset-0 rounded-xl opacity-0 hover:opacity-100 transition-opacity duration-300 bg-gradient-to-r from-rose-600/20 via-rose-500/20 to-rose-400/20 blur-md"}),(0,s.jsx)("span",{className:"absolute inset-0 -z-10 rounded-xl opacity-50 blur-md bg-gradient-to-r from-rose-600/20 via-rose-500/20 to-rose-400/20"})]})},6259:(e,t,r)=>{"use strict";r.d(t,{Hr:()=>h,Ht:()=>j,SQ:()=>f,_2:()=>v,lp:()=>N,mB:()=>k,rI:()=>u,ty:()=>m});var s=r(95155),a=r(12115),n=r(47971),o=r(27937),l=r(5917),i=r(99051),c=r(83101),d=r(64269);let u=n.bL,m=n.l9;n.YJ,n.ZL,n.Pb;let h=n.z6,p=(0,c.F)("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"data-[state=open]:bg-gray-100 focus:bg-gray-100",premium:"data-[state=open]:bg-blue-50 focus:bg-blue-50 data-[state=open]:text-blue-700 focus:text-blue-700"},inset:{true:"pl-8",false:""}},defaultVariants:{variant:"default",inset:!1}});a.forwardRef((e,t)=>
1{let{className:r,inset:a,variant:l,children:i,...c}=e;return(0,s.jsxs)(n.ZP,{ref:t,className:(0,d.cn)(p({inset:a,variant:l}),r),...c,children:[i,(0,s.jsx)(o.A,{className:"ml-auto"})]})}).displayName=n.ZP.displayName;let g=(0,c.F)("z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",{variants:{variant:{default:"bg-white border-gray-200",premium:"bg-white border-blue-100 shadow-blue-500/5"}},defaultVariants:{variant:"default"}});a.forwardRef((e,t)=>{let{className:r,variant:a,...o}=e;return(0,s.jsx)(n.G5,{ref:t,className:(0,d.cn)(g({variant:a}),r),...o})}).displayName=n.G5.displayName;let x=(0,c.F)("z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",{variants:{variant:{default:"bg-white border-gray-200",premium:"bg-white border-blue-100 shadow-blue-500/5",subtle:"bg-white/80 backdrop-blur-sm border-gray-200/70"}},defaultVariants:{variant:"default"}}),f=a.forwardRef((e,t)=>{let{className:r,variant:a,sideOffset:o=4,...l}=e;return(0,s.jsx)(n.ZL,{children:(0,s.jsx)(n.UC,{ref:t,sideOffset:o,className:(0,d.cn)(x({variant:a}),r),...l})})});f.displayName=n.UC.displayName;let b=(0,c.F)("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"focus:bg-gray-100 focus:text-gray-900",premium:"focus:bg-blue-50 focus:text-blue-700",destructive:"focus:bg-red-50 focus:text-red-700"},inset:{true:"pl-8",false:""}},defaultVariants:{variant:"default",inset:!1}}),v=a.forwardRef((e,t)=>{let{className:r,inset:a,variant:o,...l}=e;return(0,s.jsx)(n.q7,{ref:t,className:(0,d.cn)(b({inset:a,variant:o}),r),...l})});v.displayName=n.q7.displayName;let y=(0,c.F)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",{variants:{variant:{default:"focus:bg-gray-100 focus:text-gray-900",premium:"focus:bg-blue-50 focus:text-blue-700"}},defaultVariants:{variant:"default"}});a.forwardRef((e,t)=>{let{className:r,children:a,checked:o,variant:i,...c}=e;return(0,s.jsxs)(n.H_,{ref:t,className:(0,d.cn)(y({variant:i}),r),checked:o,...c,children:[(0,s.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(n.VF,{children:(0,s.jsx)(l.A,{className:"h-4 w-4"})})}),a]})}).displayName=n.H_.displayName;let w=(0,c.F)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",{variants:{variant:{default:"focus:bg-gray-100 focus:text-gray-900",premium:"focus:bg-blue-50 focus:text-blue-700"}},defaultVariants:{variant:"default"}}),j=a.forwardRef((e,t)=>{let{className:r,children:a,variant:o,...l}=e;return(0,s.jsxs)(n.hN,{ref:t,className:(0,d.cn)(w({variant:o}),r),...l,children:[(0,s.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(n.VF,{children:(0,s.jsx)(i.A,{className:"h-2 w-2 fill-current"})})}),a]})});j.displayName=n.hN.displayName;let N=a.forwardRef((e,t)=>{let{className:r,inset:a,...o}=e;return(0,s.jsx)(n.JU,{ref:t,className:(0,d.cn)("px-2 py-1.5 text-sm font-semibold text-gray-700",a&&"pl-8",r),...o})});N.displayName=n.JU.displayName;let k=a.forwardRef((e,t)=>
1{let{className:r,...a}=e;return(0,s.jsx)(n.wv,{ref:t,className:(0,d.cn)("-mx-1 my-1 h-px bg-gray-100",r),...a})});k.displayName=n.wv.displayName},7599:(e,t,r)=>{"use strict";r.d(t,{QueryProvider:()=>l});var s=r(95155),a=r(12115),n=r(74852),o=r(99776);function l(e){let{children:t}=e,[r]=a.useState(()=>new n.E({defaultOptions:{queries:{staleTime:3e5,gcTime:6e5}}}));return(0,s.jsx)(o.Ht,{client:r,children:t})}},13673:()=>{},39396:(e,t,r)=>{Promise.resolve().then(r.bind(r,37025)),Promise.resolve().then(r.t.bind(r,41402,23)),Promise.resolve().then(r.t.bind(r,82790,23)),Promise.resolve().then(r.t.bind(r,33616,23)),Promise.resolve().then(r.t.bind(r,33944,23)),Promise.resolve().then(r.t.bind(r,13673,23)),Promise.resolve().then(r.bind(r,89589)),Promise.resolve().then(r.bind(r,69126)),Promise.resolve().then(r.bind(r,75936)),Promise.resolve().then(r.bind(r,7599)),Promise.resolve().then(r.bind(r,98169)),Promise.resolve().then(r.bind(r,57532))},63406:(e,t,r)=>{"use strict";r.d(t,{l:()=>s});let s=(0,r(25959).v)(e=>({previousPathname:null,setPreviousPathname:t=>e({previousPathname:t})}))},64269:(e,t,r)=>{"use strict";r.d(t,{Y:()=>o,cn:()=>n});var s=r(2821),a=r(75889);function n(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,a.QP)((0,s.$)(t))}function o(e){return e?e.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}},69126:(e,t,r)=>{"use strict";r.d(t,{MainLayoutClient:()=>eN});var s=r(95155),a=r(20063),n=r(12115),o=r(52619),l=r.n(o),i=r(15239),c=r(3998),d=r(26333),u=r(57532),m=r(65993),h=r(69141),p=r(67733),g=r(46826),x=r(24033),f=r(20508),b=r(84926),v=r(95740),y=r(1811),w=r(6259);function j(){let{user:e,signOut:t}=(0,u.w)(),{profile:r}=(0,u.w)(),n=(0,a.usePathname)(),{trackInteraction:o}=(0,y.p)(),j=e&&(null==r?void 0:r.access_role)&&(null==r?void 0:r.access_role)=="admin",N=e&&(null==r?void 0:r.access_role)&&((null==r?void 0:r.access_role)=="admin"||(null==r?void 0:r.access_role)=="ignite"),k=(null==r?void 0:r.id)===null||(null==r?void 0:r.id)===""||(null==r?void 0:r.email)===null||(null==r?void 0:r.email)===""||(null==r?void 0:r.first_name)===null||(null==r?void 0:r.first_name)===""||(null==r?void 0:r.last_name)===null||(null==r?void 0:r.last_name)===""||(null==r?void 0:r.company)===null||(null==r?void 0:r.company)===""||(null==r?void 0:r.phone_number)===null||(null==r?void 0:r.phone_number)===""||(null==r?void 0:r.role_type)===null||(null==r?void 0:r.role_type)==="Other"&&((null==r?void 0:r.role_description)===null||(null==r?void 0:r.role_description)===""),C="/profile-info"!==n&&e&&r&&k;return(0,s.jsx)("header",{className:"sticky top-0 z-50 w-full border-b border-gray-200 bg-white shadow-sm",children:(0,s.jsxs)("div",{className:"mx-auto flex h-16 max-w-screen-xl items-center justify-between px-4 sm:px-6 lg:px-8",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,s.jsxs)(l(),{href:"/",className:"flex items-center space-x-2",children:[(0,s.jsx)(i.default,{src:"/theus-logo.png",alt:"Theus AI Logo",width:40,height:40,className:"h-10 w-auto"}),(0,s.jsx)("span",{className:"text-xl font-bold text-blue-600",children:"Theus"})]}),(0,s.jsx)("nav",{className:"hidden md:flex items-center space-x-1 text-sm font-medium",children:(0,s.jsx)(c.$n,{asChild:!0,variant:"/"===n?"default":"ghost",className:"h-10 font-medium text-blue-600 border border-transparent",animation:"static",children:(0,s.jsxs)(l(),{href:"/",children:[(0,s.jsx)(m.A,{className:"mr-2 h-4 w-4"}),"Home"]})})})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-4",children:[j&&(0,s.jsxs)(d.AM,{children:[(0,s.jsx)(d.Wv,{asChild:!0,children:(0,s.jsx)(c.$n,{variant:"outline",className:"h-10 bg-green-50 border-green-200 text-green-700 hover:bg-green-50 hover:border-green-300 rounded-lg transition-all",children:"Admin View"})}),(0,s.jsx)(d.hl,{className:"shadow-green-500/20 ring-1 ring-green-200 bg-green-50",children:(0,s.jsxs)("div",{className:"p-4",children:[(0,s.jsx)("h4",{className:"font-medium",children:"You are logged in as an admin"}),(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"You may see elements that are not available to other users."})]})})]}),N&&(0,s.jsx)(l(),{href:"/ignite",children:(0,s.jsxs)(c.$n,{variant:"outline",className:"h-10 bg-red-50 border-blue-200 text-blue-700 hover:bg-green-50 hover:border-blue-300 rounded-lg transition-all",animation:"static",children:[(0,s.jsx)(h.A,{className:"mr-2 h-4 w-4"}),"Ignite"]})}),1===Math.floor(24*Math.random())&&C&&(0,s.jsx)(l(),{href:"/profile-info",children:(0,s.jsxs)(c.$n,{variant:"outline",className:"h-10 bg-green-50 border-blue-200 text-blue-700 hover:bg-green-50 hover:border-blue-300 rounded-lg transition-all",animation:"static",children:[(0,s.jsx)(p.A,{className:"mr-2 h-4 w-4"}),"Complete Your Profile"]})}),(0,s.jsx)(l(),{href:"/listings/create",children:(0,s.jsxs)(c.$n,{variant:"outline",className:"h-10 border-blue-200 text-blue-700 hover:bg-blue-50 hover:border-blue-300 rounded-lg transition-all",animation:"static",onClick:()=>o({interactionType:"nav_click_create_listing",url:n,elementIdentifier:"main_
1nav_create_listing_button"}),children:[(0,s.jsx)(g.A,{className:"mr-2 h-4 w-4"}),"Create Listing"]})}),e?(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(l(),{href:"/broker-dashboard",children:(0,s.jsx)(c.$n,{variant:"premium",className:"hidden sm:flex h-10 text-white",animation:"static",onClick:()=>o({interactionType:"nav_click_dashboard",url:n,elementIdentifier:"main_nav_dashboard_button"}),children:"Dashboard"})}),(0,s.jsxs)(w.rI,{children:[(0,s.jsx)(w.ty,{asChild:!0,children:(0,s.jsxs)("button",{className:"flex items-center space-x-1 p-1 rounded-full hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors",children:[(0,s.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-blue-600 text-white shadow-sm text-sm font-medium",children:(null==e?void 0:e.email)?e.email.charAt(0).toUpperCase():"?"}),(0,s.jsx)(x.A,{className:"h-4 w-4 text-gray-500"}),(0,s.jsx)("span",{className:"sr-only",children:"Open user menu"})]})}),(0,s.jsxs)(w.SQ,{align:"end",className:"w-56",children:[(0,s.jsx)(w.lp,{className:"font-normal text-xs text-gray-500 truncate px-3 pt-2 pb-1",children:"Signed in as"}),(0,s.jsx)(w.lp,{className:"truncate px-3 pb-2 pt-0",children:e.email}),(0,s.jsx)(w.mB,{}),(0,s.jsx)(w._2,{asChild:!0,className:"sm:hidden cursor-pointer",children:(0,s.jsxs)(l(),{href:"/broker-dashboard",onClick:()=>o({interactionType:"nav_click_dashboard",url:n,elementIdentifier:"main_nav_dashboard_dropdown_link"}),children:[(0,s.jsx)(f.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Dashboard"})]})}),(0,s.jsxs)(w._2,{onSelect:()=>(0,a.redirect)("/profile-info"),className:"cursor-pointer",children:[(0,s.jsx)(p.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Update Profile"})]}),(0,s.jsxs)(w._2,{onSelect:()=>t(),className:"cursor-pointer",children:[(0,s.jsx)(b.A,{className:"mr-2 h-4 w-4"}),(0,s.jsx)("span",{children:"Sign out"})]})]})]})]}):(0,s.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,s.jsx)(l(),{href:"/login?redirectUrl=".concat(encodeURIComponent(n)),children:(0,s.jsx)(c.$n,{variant:"outline",size:"sm",className:"hidden sm:flex h-10 border-blue-200 text-blue-700 hover:bg-blue-50 hover:border-blue-300 rounded-lg transition-all",animation:"static",onClick:()=>o({interactionType:"auth_signin_click",url:n,details:{source:"main_nav"},elementIdentifier:"main_nav_login_button"}),children:"Log in"})}),(0,s.jsx)(l(),{href:"/signup?redirectUrl=".concat(encodeURIComponent(n)),children:(0,s.jsxs)(c.$n,{variant:"premium",size:"sm",className:"h-10 text-white font-medium",animation:"static",onClick:()=>o({interactionType:"auth_signup_click",url:n,details:{source:"main_nav"},elementIdentifier:"main_nav_signup_button"}),children:[(0,s.jsx)(v.A,{className:"mr-1 h-3.5 w-3.5"}),"Sign up"]})})]})]})]})})}var N=r(25959),k=r(89863),C=r(74879);let I=(0,N.v)()((0,k.lt)((0,k.Zr)((e,t)=>({isOpen:!1,currentBlockId:null,isProcessing:!1,processBlocks:{},messages:{},messageOrder:[],currentMessageId:null,chats:[],currentChatId:null,receivedTextToken:!1,lastSegmentType:null,lastToolName:null,activeConnections:{},activeChatIds:[],toggleOpen:()=>e(e=>({isOpen:!e.isOpen})),startNewChat:()=>{console.log("Starting new chat..."),e(e=>{let t=e.currentChatId?e.activeConnections[e.currentChatId]:null;t?(console.log("Closing connection for current chat:",e.currentChatId),t.close()):console.log("No active connection to close");let r={...e.activeConnections};e.currentChatId&&delete r[e.currentChatId];let s=e.activeChatIds.filter(t=>t!==e.currentChatId);return console.log("Reset to new chat state"),{currentBlockId:null,isProcessing:!1,currentMessageId:null,currentChatId:null,receivedTextToken:!1,lastSegmentType:null,lastToolName:null,activeConnections:r,activeChatIds:s}})},loadChats:async()=>{try{var t;let r=await fetch("/api/research/chats");if(!r.ok){let e=await r.json();throw 401!==r.status&&403!==r.status&&console.error("Failed to load chats:",e),Error(e.error||"Failed to load chats")}let s=await r.json();console.log("Loaded ".concat((null==(t=s.chats)?void 0:t.length)||0," chats from server"));let a=(s.chats||[]).map(e=>({...e,lastUpdated:e.lastUpdated&&!isNaN(new Date(e.lastUpdated).getTime())?e.lastUpdated:new Date().toISOString(),snippet:e.snippet||"New conversation"}));return e({chats:a}),a}catch(e){return console.error("Error loading chats:",e),[]}},loadChatHistory:async r=>{if(!r)return;let s=t().currentChatId;if(s&&s!==r){let e=t().activeConnections[s];e&&(console.log("[loadChatHistory] Closing connection for previous chat: ".concat(s)),e.close())}try{let a=await fetch("/api/research/chat/".concat(r,"/history"));if(!a.ok){let e=await a.json();throw console.error("Failed to load chat history:",e),Error(e.error||"Failed to load chat history")}let n=await a.json(),o={},l=[],i=n.process_blocks||{},c={};
1Object.entries(i).forEach(e=>{let[t,r]=e;c[t]={id:t,steps:r.steps||[],timestamp:r.timestamp||Date.now()}}),n.messages&&Array.isArray(n.messages)&&n.messages.forEach(e=>{let t=e.id||(0,C.A)(),s=e.timestamp||new Date().toISOString(),a="user"===e.role?"user":"assistant";if(e.segments&&Array.isArray(e.segments)){o[t]={id:t,role:a,segments:e.segments,timestamp:s,isComplete:!0,chatId:r},l.push(t);return}let n=[];e.content&&n.push({type:"text",content:e.content,timestamp:new Date(s).getTime()}),e.process_block_id&&c[e.process_block_id]&&n.push({type:"process",blockId:e.process_block_id,timestamp:c[e.process_block_id].timestamp}),0!==n.length&&(o[t]={id:t,role:a,segments:n,timestamp:s,isComplete:!0,chatId:r},l.push(t))}),console.log("Loaded chat history: ".concat(l.length," messages, ").concat(Object.keys(c).length," process blocks")),e(e=>{let a={...e.activeConnections};s&&s!==r&&a[s]&&delete a[s];let n=e.activeChatIds.filter(e=>e!==s||e===r);return{currentChatId:r,messages:o,messageOrder:l,processBlocks:{...t().processBlocks,...c},isProcessing:!1,currentBlockId:null,currentMessageId:null,receivedTextToken:!1,lastSegmentType:null,lastToolName:null,activeConnections:a,activeChatIds:n}})}catch(t){console.error("Error loading chat history:",t),e({isProcessing:!1})}},sendMessage:async(r,s)=>{console.log("Sending message:",r);let a=t().currentChatId||(0,C.A)(),n=(0,C.A)(),o=(0,C.A)(),l=Date.now();e(e=>({messages:{...e.messages,[n]:{id:n,role:"user",segments:[{type:"text",content:r,timestamp:l}],timestamp:new Date(l).toISOString(),isComplete:!0,chatId:a},[o]:{id:o,role:"assistant",segments:[],timestamp:new Date(l+1).toISOString(),isComplete:!1,chatId:a}},messageOrder:[...e.messageOrder,n,o],currentMessageId:o,isProcessing:!0,currentBlockId:null,receivedTextToken:!1,lastSegmentType:null,lastToolName:null,currentChatId:a}));let i="/api/research/chat?content=".concat(encodeURIComponent(r));i+="&chat_id=".concat(encodeURIComponent(a)),s&&(i+="&page_context=".concat(encodeURIComponent(JSON.stringify(s))));let c=new EventSource(i);e(e=>({activeConnections:{...e.activeConnections,[a]:c},activeChatIds:[...e.activeChatIds,a]})),c.addEventListener("start",e=>{try{if(e.data){let r=JSON.parse(e.data);t().handleStart(r)}}catch(e){console.error("Error parsing start event:",e)}}),c.addEventListener("thinking_start",e=>{try{if(e.data){let r=JSON.parse(e.data);t().handleThinkingStart(r)}}catch(e){console.error("Error parsing thinking_start event:",e)}}),c.addEventListener("thinking",e=>{try{if(e.data){let r=JSON.parse(e.data);t().handleThinkingUpdate(r.thinking||"",r.chat_id)}}catch(e){console.error("Error parsing thinking event:",e)}}),c.addEventListener("thinking_stop",e=>{try{if(e.data){let r=JSON.parse(e.data);t().handleThinkingStop(r.chat_id)}}catch(e){console.error("Error parsing thinking_stop event:",e)}}),c.addEventListener("tool_start",e=>{try{if(e.data){let r=JSON.parse(e.data);t().handleToolStart(r.tool_id,r.tool_name,r.tool_input||{},r.chat_id)}}catch(e){console.error("Error parsing tool_start event:",e)}}),c.addEventListener("tool_response",e=>{try{if(e.data){let r=JSON.parse(e.data);t().handleToolResponse(r.tool_id,r.tool_result||"",r.is_error||!1,r.chat_id)}}catch(e){console.error("Error parsing tool_response event:",e)}}),c.addEventListener("token",e=>{try{if(e.data){let r=JSON.parse(e.data);t().handleToken(r.token||"",r.chat_id)}}catch(e){console.error("Error parsing token event:",e)}}),c.addEventListener("complete",e=>{try{if(e.data){let r=JSON.parse(e.data);t().handleComplete(r),c.close(),t().loadChats()}}catch(e){console.error("Error parsing complete event:",e)}}),c.addEventListener("error",e=>{try{let r="An error occurred",s=null;if(e.data){let t=JSON.parse(e.data);r=t.message||r,s=t.chat_id}t().handleError(r,s)}catch(e){console.error("Error parsing error event:",e),t().handleError("An error occurred",null)}finally{c.close()}}),c.addEventListener("done",()=>{c.close()})},handleStart:t=>{let r=t.chat_id||(0,C.A)();e({currentChatId:r,isProcessing:!0}),console.log("Chat started with ID:",r)},handleThinkingStart:function(){let r,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{currentBlockId:a,lastSegmentType:n,currentMessageId:o,messages:l,processBlocks:i,currentChatId:c}=t(),d=s.chat_id||c;d&&d!==c&&e({currentChatId:d});let u=Date.now(),m=!a||"process"!==n,h=a;r=m?{id:h=(0,C.A)(),steps:[],timestamp:u}:{...i[h]};let p=(0,C.A)();r.steps=[...r.steps,{id:p,type:"thinking",status:"running",isCollapsed:!0,content:"",timestamp:u}],e(e=>{let t={...e.processBlocks,[h]:r};if(o&&l[o]){let r={...l[o]};return m&&(r.segments=[...r.segments,{type:"process",blockId:h,timestamp:u}]),{currentBlockId:h,processBlocks:t,messages:{...e.messages,[o]:r},isProcessing:!0,lastSegmentType:"process",lastToolName:null}}return{currentBlockId:h,processBlocks:t,isProcessing:!0,lastSegmentType:"process",lastToolName:null}})},handleThinkingStop:r=>{let{currentBlockId:s,currentChatId:a}=t();r&&r!==a&&e({currentChatId:r}),s&&e(e=>{let t=e.processBlocks[s];if(!t)return e;let r=t.steps.map(e=>"thinking"===e.type&&"running"===e.status?{...e,status:"complete"}:e),a={...t,steps:r};return{processBlocks:{...e.processBlocks,[s]:a}}})},handleThinkingUpdate:(r,s)=>{let{currentBlockId:a,currentChatId:n}=t();s&&s!==n&&e({currentChatId:s}),a&&r&&e(e=>{let t=e.processBlocks[a];if(!t)return e;let s=t.steps.map(e=>"thinking"===e.type&&"running"===e.status?{...e,content:(e.content||"")+r}:e),n={...t,steps:s};return{processBlocks:{...e.processBlocks,[a]:n}}})},handleToolStart:(r,s,a,n)=>{let o,{currentBlockId:l,lastSegmentType:i,currentMessageId:c,messages:d,processBlocks:u,currentChatId:m}=t();n&&n!==m&&e({currentChatId:n}
1);let h=Date.now(),p=!l||"process"!==i,g=l;o=p?{id:g=(0,C.A)(),steps:[],timestamp:h}:{...u[g]};let x={id:r||(0,C.A)(),type:"tool",status:"running",isCollapsed:!0,toolName:s,toolInput:a,timestamp:h};o.steps=[...o.steps,x],e(e=>{let t={...e.processBlocks,[g]:o};if(c&&d[c]){let r={...d[c]};return p&&(r.segments=[...r.segments,{type:"process",blockId:g,timestamp:h}]),{currentBlockId:g,processBlocks:t,messages:{...e.messages,[c]:r},isProcessing:!0,lastSegmentType:"process",lastToolName:s}}return{currentBlockId:g,processBlocks:t,isProcessing:!0,lastSegmentType:"process",lastToolName:s}})},handleToolResponse:function(r,s){let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3?arguments[3]:void 0,{currentBlockId:o,currentChatId:l}=t();n&&n!==l&&e({currentChatId:n}),o&&e(e=>{let t=e.processBlocks[o];if(!t)return e;let n=t.steps.map(e=>e.id===r?{...e,status:a?"error":"complete",toolResult:s,isError:a}:e),l={...t,steps:n};return{processBlocks:{...e.processBlocks,[o]:l}}})},handleToken:(r,s)=>{let{messages:a,currentBlockId:n,processBlocks:o,lastSegmentType:l,currentChatId:i}=t(),c=s||i;if(!c)return;s&&s!==i&&(e({currentChatId:s}),console.log("Updated chat ID from token event:",s)),console.log("Token received:",r,"lastSegmentType:",l,"currentBlockId:",n,"chatId:",c);let d=Date.now(),u=Object.keys(a).filter(e=>"assistant"===a[e].role&&!a[e].isComplete).find(e=>a[e].chatId===c);if(!u)return void console.warn("No matching message found for chat:",c);n&&"process"===l&&i===c&&(console.log("First text token after process, collapsing steps in block:",n),e(e=>{let t=e.processBlocks[n];if(!t)return e;let r={...t,steps:t.steps.map(e=>({...e,isCollapsed:!0}))};return{processBlocks:{...e.processBlocks,[n]:r}}}),e({lastSegmentType:"text"})),e(e=>{let t=e.messages[u];if(!t)return e;let s={...t},a=s.segments.length>0?s.segments[s.segments.length-1]:null,n=[...s.segments];return a&&"text"===a.type?n[n.length-1]={...a,content:a.content+r}:n.push({type:"text",content:r,timestamp:d}),{messages:{...e.messages,[u]:{...s,segments:n}},receivedTextToken:!0}})},handleComplete:function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{messages:s,currentChatId:a,activeConnections:n,activeChatIds:o}=t(),l=r.chat_id||a;if(!l)return;let i=Object.keys(s).filter(e=>"assistant"===s[e].role&&!s[e].isComplete).find(e=>s[e].chatId===l);i||console.warn("No message found to complete for chat:",l),l&&l!==a&&e({currentChatId:l}),e(e=>{let t={...e.activeConnections};t[l]&&delete t[l];let r=e.activeChatIds.filter(e=>e!==l),s={...e.messages};return i&&s[i]&&(s[i]={...s[i],isComplete:!0}),{messages:s,activeConnections:t,activeChatIds:r,...l===e.currentChatId?{isProcessing:!1,currentMessageId:null,currentBlockId:null,receivedTextToken:!1,lastSegmentType:null,lastToolName:null}:{}}}),setTimeout(()=>{t().loadChats()},500)},handleError:(r,s)=>{console.error("Chat error:",r,s?"(Chat ID: ".concat(s,")"):"");let{currentChatId:a,activeConnections:n,activeChatIds:o}=t();if(!s)return void e({isProcessing:!1,currentMessageId:null,currentBlockId:null,receivedTextToken:!1,lastSegmentType:null,lastToolName:null});s!==a&&e({currentChatId:s}),e(e=>{let t={...e.activeConnections};return t[s]&&delete t[s],{activeConnections:t,activeChatIds:e.activeChatIds.filter(e=>e!==s),...s===e.currentChatId?{isProcessing:!1,currentMessageId:null,currentBlockId:null,receivedTextToken:!1,lastSegmentType:null,lastToolName:null}:{}}})}}),{name:"theus-chat-storage",partialize:e=>({chats:e.chats,currentChatId:e.currentChatId,messages:e.messages,messageOrder:e.messageOrder,processBlocks:e.processBlocks,activeConnections:{},activeChatIds:[]})}))),_=(0,n.createContext)(null);function T(e){let{children:t}=e,r=function(){let e=(0,a.usePathname)(),t=(0,a.useParams)(),r=(0,a.useSearchParams)();return(0,n.useMemo)(()=>JSON.stringify(t),[t]),(0,n.useMemo)(()=>null==r?void 0:r.toString(),[r]),(0,n.useMemo)(()=>{let s={};null==r||r.forEach((e,t)=>{s[t]=e});let a={type:"generic",path:e||"",searchParams:Object.keys(s).length>0?s:void 0};return(null==e?void 0:e.startsWith("/deals/"))&&(null==t?void 0:t.id)?(a.type="deal",a.dealId=t.id):"/deals"===e?a.type="search":(null==e?void 0:e.startsWith("/profile/"))&&(null==t?void 0:t.id)&&(a.type="profile",a.userId=t.id),a},[e,t,r])}();return(0,s.jsx)(_.Provider,{value:r,children:t})}function S(e){let{children:t}=e;return(0,s.jsx)(n.Suspense,{fallback:(0,s.jsx)("div",{children:"Loading page context..."}),children:(0,s.jsx)(T,{children:t})})}var A=r(18085),E=r(83101),P=r(64269);let R=(0,E.F)("inline-flex items-center justify-between gap-2 whitespace-nowrap rounded-full text-sm font-medium transition-all duration-200 focus-visible:outline-none focus-visible:ring-1 focus:ring-blue-400 border border-[0.5px]",{variants:{variant:{default:"bg-white text-gray-700 border-gray-200 hover:bg-gray-50 hover:border-gray-300",subtle:"bg-gray-50 text-gray-700 border-gray-200 hover:bg-gray-100 hover:border-gray-300",blue:"bg-blue-50 text-blue-700 border-blue-200 hover:bg-blue-100 hover:border-blue-300",premium:"bg-gradient-to-r from-blue-50 to-indigo-50 text-blue-700 border-blue-200 hover:from-blue-100 hover:to-indigo-100",ghost:"bg-transparent text-gray-700 border-transparent hover:bg-gray-100 hover:border-gray-200"},size:{sm:"h-7 px-3 py-1 text-xs",md:"h-8 px-4 py-1.5",lg:"h-9 px-5 py-2"}},defaultVariants:{variant:"default",size:"md"}}),L=(0,E.F)("transition-transform duration-200 ease-out ml-1",{variants:{direction:{up:"rotate-0",down:"rotate-180"},size:{sm:"h-3 w-3",md:"h-4 w-4",lg:"h-5 w-5"}},defaultVariants:{direction:"down",size:"md"}}),B=n.forwardRef((e,t)=>
1{let{className:r,variant:a,size:o,isOpen:l=!1,onToggle:i,label:c,iconPosition:d="right",hideIcon:u=!1,...m}=e,[h,p]=n.useState(l),g=m.onClick?l:h,f="sm"===o?"sm":"lg"===o?"lg":"md";return(0,s.jsxs)("button",{type:"button",className:(0,P.cn)(R({variant:a,size:o}),r),onClick:i||(()=>{i?i():p(!h)}),"aria-expanded":g,ref:t,...m,children:[!u&&"left"===d&&(0,s.jsx)("span",{className:(0,P.cn)(L({direction:g?"up":"down",size:f})),children:(0,s.jsx)(x.A,{className:"h-full w-full"})}),(0,s.jsx)("span",{children:c}),!u&&"right"===d&&(0,s.jsx)("span",{className:(0,P.cn)(L({direction:g?"up":"down",size:f})),children:(0,s.jsx)(x.A,{className:"h-full w-full"})})]})});B.displayName="TogglePill";var O=r(54485),z=r(65229);let D=(0,E.F)("relative px-4 py-3 rounded-lg shadow-sm text-sm",{variants:{variant:{default:"bg-white border border-gray-200 text-slate-900",user:"bg-blue-600 text-white font-normal",premium:"bg-white border border-blue-200 shadow-sm shadow-blue-50 text-slate-900",system:"bg-slate-50 border border-slate-200 text-slate-700 italic"},position:{left:"rounded-tl-none ml-2",right:"rounded-tr-none mr-2",standalone:""},size:{sm:"text-xs py-1.5 px-2.5",default:"text-sm py-2.5 px-4",lg:"text-base py-3 px-5"}},defaultVariants:{variant:"default",position:"left",size:"default"}}),U=n.forwardRef((e,t)=>{let{className:r,variant:a,position:n,size:o,...l}=e;return(0,s.jsx)("div",{className:(0,P.cn)(D({variant:a,position:n,size:o}),r),ref:t,...l})});U.displayName="ChatBubble",n.forwardRef((e,t)=>{let{className:r,...a}=e;return(0,s.jsx)("div",{ref:t,className:(0,P.cn)("mb-1 text-xs font-medium text-slate-500",r),...a})}).displayName="ChatBubbleHeader",n.forwardRef((e,t)=>{let{className:r,...a}=e;return(0,s.jsx)("div",{ref:t,className:(0,P.cn)("mt-1 text-xs text-slate-500",r),...a})}).displayName="ChatBubbleFooter";var F=r(26983),M=r(6132),J=r(42529),W=r(27937),V=r(94325);function H(e){let{step:t}=e,[r,a]=(0,n.useState)(!t.isCollapsed),{type:o,status:l,toolName:i,toolInput:c,toolResult:d,content:u,isError:m}=t,h="process-step ".concat("tool"===o?"process-step-tool":"process-step-thinking"," ").concat(m?"process-step-error":""),p=c?(0,V.IB)(c):"",g=d?"string"==typeof d&&(d.startsWith("{")||d.startsWith("[")||d.includes("\n"))?(0,V.IB)(d):d:"",f=()=>"running"===l?(0,s.jsxs)("span",{className:"ml-2 flex items-center text-blue-500",children:[(0,s.jsx)(F.A,{className:"h-2 w-2 mr-1"}),(0,s.jsx)("span",{className:"text-[9px]",children:"Running..."})]}):m?(0,s.jsxs)("span",{className:"ml-2 flex items-center text-red-500",children:[(0,s.jsx)(M.A,{className:"h-2 w-2 mr-1"}),(0,s.jsx)("span",{className:"text-[9px]",children:"Error"})]}):"complete"!==l||m?null:(0,s.jsx)("span",{className:"ml-2 flex items-center text-green-500",children:(0,s.jsx)(J.A,{className:"h-2 w-2 mr-1"})});return"thinking"===o?(0,s.jsxs)("div",{className:h,children:[(0,s.jsxs)("div",{className:"flex items-center text-[10px]",children:[(0,s.jsxs)("button",{onClick:()=>a(!r),className:"flex items-center",children:[r?(0,s.jsx)(x.A,{className:"h-2 w-2 mr-1"}):(0,s.jsx)(W.A,{className:"h-2 w-2 mr-1"}),(0,s.jsx)("span",{className:"font-medium",children:"Thinking"})]}),(0,s.jsx)(f,{})]}),r&&u&&(0,s.jsx)("div",{className:"whitespace-pre-wrap pl-2 mt-1 text-[10px] text-gray-600 border-l border-blue-50 py-1 px-2",children:u})]}):(0,s.jsxs)("div",{className:h,children:[(0,s.jsxs)("div",{className:"flex items-center text-[10px]",children:[(0,s.jsxs)("button",{onClick:()=>a(!r),className:"flex items-center",children:[r?(0,s.jsx)(x.A,{className:"h-2 w-2 mr-1"}):(0,s.jsx)(W.A,{className:"h-2 w-2 mr-1"}),(0,s.jsx)("span",{className:"font-medium",children:i||"Tool"})]}),(0,s.jsx)(f,{})]}
1),r&&(0,s.jsxs)("div",{className:"pl-2 mt-1 border-l border-blue-50 py-1 px-2",children:[c&&(0,s.jsxs)("div",{className:"mb-1",children:[(0,s.jsx)("div",{className:"font-medium mb-0.5 text-[10px] text-blue-700",children:"Input:"}),(0,s.jsx)("pre",{className:"text-[9px] bg-white p-1 rounded overflow-x-auto border border-blue-50 text-gray-600",children:p})]}),(d||"running"===l)&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"font-medium mb-0.5 text-[10px] text-blue-700",children:["Result:","running"===l&&(0,s.jsx)("span",{className:"font-normal ml-1 text-neutral-500 text-[9px]",children:"Processing..."})]}),d&&(0,s.jsx)("pre",{className:"text-[9px] bg-white p-1 rounded overflow-x-auto border border-blue-50 text-gray-600",children:g})]})]})]})}var $=r(52056),Y=r(12108),G=r(1473),q=r(53842);function K(e){let{block:t}=e,[r,a]=(0,n.useState)(!1),{totalSteps:o,thinkingSteps:l,toolSteps:i,hasErrors:c,isRunning:d}=(0,n.useMemo)(()=>{let e=t.steps.filter(e=>"thinking"===e.type),r=t.steps.filter(e=>"tool"===e.type);return{totalSteps:t.steps.length,thinkingSteps:e,toolSteps:r,hasErrors:t.steps.some(e=>"error"===e.status),isRunning:t.steps.some(e=>"running"===e.status)}},[t.steps]);return(0,s.jsxs)("div",{className:"process-block my-1 ml-1 relative",children:[(0,s.jsxs)("button",{className:"flex items-center text-xs py-0.5 px-2 rounded border ".concat(c?"border-red-100 text-red-700 bg-red-50":d?"border-blue-100 text-blue-700 bg-blue-50":"border-gray-100 text-gray-700 bg-gray-50"," \n transition-colors hover:bg-opacity-80 w-[95%]"),onClick:()=>{a(!r)},"aria-expanded":r,children:[r?(0,s.jsx)(Y.A,{className:"w-2.5 h-2.5 mr-1.5 flex-shrink-0"}):(0,s.jsx)(x.A,{className:"w-2.5 h-2.5 mr-1.5 flex-shrink-0"}),(0,s.jsxs)("div",{className:"flex items-center mr-1.5 space-x-0.5",children:[l.length>0&&(0,s.jsx)(G.A,{className:"w-2.5 h-2.5 text-blue-400"}),i.length>0&&(0,s.jsx)(q.A,{className:"w-2.5 h-2.5 text-purple-400"})]}),(0,s.jsx)("span",{className:"truncate text-xs font-medium",children:(()=>{let e=[...new Set(i.map(e=>e.toolName))].filter(Boolean);return 1===i.length&&0===l.length?"".concat(i[0].toolName||"Tool"):i.length>1&&0===l.length?e.length<=2?e.join(" & "):"".concat(e.length," tool types"):0===i.length&&l.length>0?"Research":e.length<=2?"Research with ".concat(e.join(" & ")):"Research (".concat(i.length," tools)")})()}),o>1&&!d&&(0,s.jsxs)("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",o,")"]}),(0,s.jsx)(()=>d?(0,s.jsx)(F.A,{className:"w-2.5 h-2.5 text-blue-500 ml-1.5"}):c?(0,s.jsx)($.A,{className:"w-2.5 h-2.5 text-red-500 ml-1.5"}):(0,s.jsx)(J.A,{className:"w-2.5 h-2.5 text-green-500 ml-1.5"}),{}),d&&(0,s.jsx)("span",{className:"ml-1 text-[9px] text-blue-600",children:"Running..."}),c&&!d&&(0,s.jsx)("span",{className:"ml-1 text-[9px] text-red-600",children:"Error"})]}),r&&(0,s.jsx)("div",{className:"process-block-body",children:(0,s.jsx)("div",{className:"space-y-1.5 text-[10px]",children:[...t.steps].sort((e,t)=>e.timestamp-t.timestamp).map(e=>(0,s.jsx)(H,{step:e},e.id))})})]})}var Q=r(76872);function Z(e){let{message:t,processBlocks:r}=e,a=!t.isComplete,o=t.segments.length>0;if(!o&&!a)return null;if("user"===t.role){let e=t.segments.filter(e=>"text"===e.type).map(e=>"text"===e.type?e.content:"").join("");return(0,s.jsxs)("div",{className:"flex flex-col items-end my-2",children:[(0,s.jsxs)("div",{className:"flex flex-col items-end max-w-[85%]",children:[(0,s.jsx)("span",{className:"text-xs text-gray-500 mb-1 mr-1",children:"You"}),(0,s.jsx)(U,{variant:"user",position:"right",className:"bg-indigo-600 text-white font-normal",children:e})]}),(0,s.jsx)("span",{className:"text-[10px] text-gray-500 mt-1 mr-2",children:new Date(t.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})}return(0,s.jsxs)("div",{className:"flex flex-col w-full",children:[(0,s.jsx)("span",{className:"text-xs text-indigo-600 font-medium mb-1 ml-3",children:"Lex"}),(0,s.jsxs)("div",{className:"flex flex-col ml-3",children:[t.segments.sort((e,t)=>e.timestamp-t.timestamp).map((e,o)=>(0,s.jsxs)(n.Fragment,{children:["text"===e.type&&e.content&&(0,s.jsx)("div",{className:"text-gray-800 max-w-none pl-3 mb-1",children:(0,s.jsx)(Q.A,{content:e.content,isStreaming:a&&o===t.segments.length-1})}),"process"===e.type&&e.blockId&&r&&r[e.blockId]&&r[e.blockId].steps.length>0&&(0,s.jsx)("div",{className:"mb-1 -mt-1",children:(0,s.jsx)(K,{block:r[e.blockId]})})]},"segment-".concat(t.id,"-").concat(o))),a&&!o&&(0,s.jsx)("div",{className:"pl-3",children:(0,s.jsx)("span",{className:"inline-block h-4 w-2 ml-1 bg-indigo-600 animate-pulse"})})]}),(0,s.jsx)("span",{className:"text-[10px] text-gray-500 mt-1 self-end mr-2",children:new Date(t.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})}function X(e){let{messages:t,messageOrder:r,processBlocks:a,pageContext:n,onRecommendationSelect:o}=e,{currentChatId:l}=I();console.log("MessageList render:",{currentChatId:l,messageCount:r.length,hasCurrentChat:!!l});let i=l?r.filter(e=>{var r;return(null==(r=t[e])?void 0:r.chatId)===l}):[];if(console.log("Filtered message IDs:",{count:i.length,ids:i.length<10?i:"".concat(i.length," messages")}),0===i.length){let e=(e=>{if(!e)return["What are the latest CRE market trends?","Compare office vs. retail cap rates","Top performing markets this year"];switch(e.type){case"deal":return["What's the expected cap rate for this property?","Compare this property to similar deals","Analyze the market for this location"];case"search":return["Market analysis by property type","Investment trends in commercial real estate","Compare property performance across markets"];case"profile":return["What other deals has this company worked on?","Company investment strategy analysis","Similar companies in this market"];default:return["What are the latest CRE market trends?","Compare office vs. retail cap rates","Top performing markets this year"]}})(n);return(0,s.jsx)("div",{className:"flex flex-col h-full justify-center items-center p-4 sm:p-6",children:(0,s.jsxs)("div",{className:"max-w-md w-full text-center",children:[(0,s.jsx)("h3",{className:"text-md font-medium text-gray-800 mb
1-4",children:"Ask Lex about commercial real estate"}),(0,s.jsx)("div",{className:"flex flex-col gap-2 mt-4",children:e.map((e,t)=>(0,s.jsx)("button",{className:"text-xs text-left px-3 py-2 bg-indigo-50 text-indigo-700 rounded-lg hover:bg-indigo-100 hover:text-indigo-800 transition-colors",onClick:()=>null==o?void 0:o(e),children:e},t))})]})})}return(0,s.jsx)("div",{className:"px-2 py-4 flex flex-col space-y-3",children:i.map(e=>{let r=t[e];return r?(0,s.jsx)(Z,{message:r,processBlocks:a},e):null})})}let ee=(0,n.memo)(e=>{let{toggleOpen:t,toggleSidebar:r,sidebarOpen:a,pageContext:o}=e,l=I(e=>e.messages),i=I(e=>e.messageOrder),c=I(e=>e.processBlocks),d=I(e=>e.isProcessing),u=I(e=>e.startNewChat),m=I(e=>e.currentChatId),h=I(e=>e.sendMessage),p=I(e=>e.activeChatIds),g=(0,n.useRef)(null),x=(0,n.useRef)(null);(0,n.useEffect)(()=>{f()},[l,c,d]),(0,n.useEffect)(()=>{d&&f()},[d]);let f=()=>{var e;if(!x.current)return;let t=x.current,r=t.scrollHeight-t.scrollTop-t.clientHeight<200;null==(e=g.current)||e.scrollIntoView({behavior:r?"smooth":"auto",block:"end"})},b=(0,n.useCallback)(()=>{console.log("New chat button clicked"),u(),setTimeout(()=>{f()},100)},[u]),v=(0,n.useCallback)(e=>{e&&!d&&h(e,o)},[d,h,o]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 sticky top-0 z-10 bg-gradient-to-r from-indigo-50/80 via-violet-50/50 to-indigo-50/80 shadow-sm",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("h3",{className:"text-sm font-medium text-gray-800",children:"Research Chat"}),m&&(0,s.jsxs)("span",{className:"ml-2 text-xs text-indigo-500/80 hidden sm:inline-block",children:["#",m.substring(0,8)]}),p.length>1&&(0,s.jsxs)("span",{className:"ml-2 text-xs bg-indigo-100 text-indigo-700 px-2 py-0.5 rounded-full hidden sm:inline-flex items-center",children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-indigo-500 mr-1 animate-pulse"}),p.length-1," chat",p.length>2?"s":""," processing"]})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsxs)("button",{onClick:r,className:"py-1 px-2.5 rounded-md transition-colors text-xs font-medium flex items-center ".concat(a?"bg-indigo-100 text-indigo-700":"bg-indigo-50/70 text-indigo-600 hover:bg-indigo-100 hover:text-indigo-700"),"aria-label":"Chat History",children:[(0,s.jsx)(O.A,{className:"h-3.5 w-3.5 mr-1"}),"History"]}),(0,s.jsx)("button",{onClick:b,className:"py-1 px-2.5 text-indigo-600 hover:text-indigo-800 hover:bg-indigo-100/50 rounded-md transition-colors text-xs font-medium","aria-label":"New Chat",children:"New"}),(0,s.jsx)("button",{onClick:t,className:"p-1.5 text-gray-500 hover:text-gray-700 hover:bg-gray-100/60 rounded-full transition-colors","aria-label":"Close chat",children:(0,s.jsx)(z.A,{className:"h-4 w-4"})})]})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto bg-white overscroll-contain pb-32 scroll-pb-32",ref:x,children:[(0,s.jsx)(X,{messages:l,messageOrder:i,processBlocks:c,pageContext:o,onRecommendationSelect:v}),(0,s.jsx)("div",{ref:g,className:"h-4"})]})]})});ee.displayName="ChatWindow";var et=r(16485),er=r(86651),es=r(37586);function ea(e){let{currentChatId:t,onChatSelect:r,onNewChat:a,onClose:o}
1=e,[l,i]=(0,n.useState)(""),[c,d]=(0,n.useState)(!1),{activeChatIds:u,loadChats:m,chats:h,isProcessing:p,currentChatId:x}=I();(0,n.useEffect)(()=>{let e=()=>{d(window.innerWidth<768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,n.useEffect)(()=>{m()},[]);let f=l.trim()?h.filter(e=>{var t,r;return(null==(t=e.title)?void 0:t.toLowerCase().includes(l.toLowerCase()))||(null==(r=e.snippet)?void 0:r.toLowerCase().includes(l.toLowerCase()))}):h;return(0,s.jsxs)("div",{className:"h-full flex flex-col bg-white overflow-hidden\n ".concat(c?"rounded-t-lg shadow-lg":"border-r border-gray-100"),children:[(0,s.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-3 bg-white border-b border-gray-100",children:[(0,s.jsx)("h3",{className:"font-medium text-gray-800",children:"Chat History"}),(0,s.jsx)("button",{className:"p-1.5 rounded-full hover:bg-gray-50 transition-colors",onClick:o,"aria-label":"Close sidebar",children:(0,s.jsx)(z.A,{className:"h-4 w-4 text-gray-500"})})]}),(0,s.jsxs)("div",{className:"flex-shrink-0 flex items-center p-2 gap-2",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)("input",{type:"text",placeholder:"Search...",className:"w-full border border-gray-200 rounded-full pl-8 pr-3 py-1.5 text-xs focus:outline-none focus:ring-1 focus:ring-blue-400 bg-white",value:l,onChange:e=>i(e.target.value)}),(0,s.jsx)(er.A,{className:"absolute left-2.5 top-1/2 transform -translate-y-1/2 text-gray-400 h-3.5 w-3.5"})]}),(0,s.jsx)("button",{className:"flex-shrink-0 p-1.5 rounded-full bg-indigo-50 text-indigo-600 hover:bg-indigo-100 transition-colors",onClick:()=>{a(),c&&o()},"aria-label":"New Chat",children:(0,s.jsx)(g.A,{className:"h-4 w-4"})})]}),(0,s.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto pt-2",children:0===f.length?(0,s.jsx)("div",{className:"p-4 text-center text-gray-500 text-xs",children:(0,s.jsx)("p",{children:l?"No matching chats found":"No chat history yet"})}):(0,s.jsx)("ul",{className:"space-y-1 px-2",children:f.map(e=>{let a=(e=>{try{if(!e||"string"!=typeof e)return console.warn("Invalid date, missing or not a string: ".concat(e)),{text:"Just now",icon:(0,s.jsx)(F.A,{className:"h-3 w-3"})};let t=new Date(e);if(isNaN(t.getTime()))return console.warn("Invalid date format: ".concat(e)),{text:"Just now",icon:(0,s.jsx)(F.A,{className:"h-3 w-3"})};let r=new Date;if(t.getDate()===r.getDate()&&t.getMonth()===r.getMonth()&&t.getFullYear()===r.getFullYear())return{text:t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),icon:(0,s.jsx)(F.A,{className:"h-3 w-3"})};return{text:t.toLocaleDateString([],{month:"short",day:"numeric"}),icon:(0,s.jsx)(et.A,{className:"h-3 w-3"})}}catch(e){return console.error("Error formatting date:",e),{text:"Just now",icon:(0,s.jsx)(F.A,{className:"h-3 w-3"})}}})(e.lastUpdated||new Date().toISOString()),n=u.includes(e.id)&&e.id!==t;return(0,s.jsx)("li",{children:(0,s.jsxs)("button",{className:"w-full text-left px-3 py-2 rounded-lg flex items-start gap-2 transition-colors ".concat(t===e.id?"bg-indigo-50 text-indigo-800":"hover:bg-gray-50 text-gray-700"),onClick:()=>{r(e.id),c&&o()},children:[(0,s.jsx)(es.A,{className:"h-4 w-4 mt-0.5 flex-shrink-0 ".concat(t===e.id?"text-indigo-600":"text-gray-400")}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center gap-1",children:[(0,s.jsx)("h4",{className:"font-medium text-xs truncate",children:e.title||"Untitled Chat"}),(0,s.jsxs)("div",{className:"flex items-center",children:[n&&(0,s.jsx)("span",{className:"mr-1 h-1.5 w-1.5 rounded-full bg-indigo-500 animate-pulse flex-shrink-0"}),(0,s.jsxs)("span",{className:"text-[9px] text-gray-500 flex-shrink-0 flex items-center gap-1",children:[a.icon,a.text]})]})]}),(0,s.jsx)("p",{className:"text-[10px] text-gray-500 truncate mt-0.5",children:e.snippet||"No messages"})]})]})},e.id)})})})]})}let en=(0,n.memo)(()=>{let e=I(e=>e.isOpen),t=I(e=>e.toggleOpen),r=I(e=>e.loadChats),o=I(e=>e.currentChatId),l=I(e=>e.loadChatHistory),i=I(e=>e.startNewChat),c=I(e=>e.sendMessage),d=I(e=>
1e.isProcessing),[u,m]=(0,n.useState)(!1),[h,p]=(0,n.useState)(!1),[g,x]=(0,n.useState)(!1),[f,b]=(0,n.useState)(""),v=(0,n.useRef)(null),w=(0,n.useRef)(null),j=(()=>{let e=(0,n.useContext)(_);if(!e)throw Error("usePageContextFromProvider must be used within a PageContextProvider");return e})(),N=(0,a.usePathname)(),[k,C]=(0,n.useState)(0),[T,S]=(0,n.useState)(0),[E,P]=(0,n.useState)(""),[R,L]=(0,n.useState)(!1),{trackInteraction:O}=(0,y.p)();(0,n.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&v.current&&!v.current.contains(e.target)&&t()};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[w,t]),(0,n.useEffect)(()=>{let e=()=>{m(!!document.querySelector('[role="dialog"][data-state="open"]'))};e();let t=setInterval(e,500);return()=>clearInterval(t)},[]);let z=(0,n.useMemo)(()=>{let e=(e=>{let t="this deal",r="this profile",s=["What are the latest CRE market trends?","Compare office vs. retail cap rates","Top performing markets this year?"];if(!e)return s;switch(e.type){case"deal":return["What's the expected cap rate for ".concat(t,"?"),"Compare ".concat(t," to similar deals nearby"),"Summarize the key risks for ".concat(t),"Analyze the submarket for ".concat(t)];case"search":return["Show me value-add industrial deals in Texas","Which markets have the lowest office vacancy?","Compare retail rent growth in major cities"];case"profile":return["What deals has ".concat(r," been involved in?"),"What is ".concat(r,"'s investment focus?"),"Show me similar profiles"];default:return s}})(j);return e&&e.length>0?e:["What are the latest CRE market trends?","Compare cap rates for Office vs. Industrial...","Which sunbelt markets are growing fastest?","Ask about a specific property address..."]},[j]);(0,n.useEffect)(()=>{let e,t=k%z.length,r=z[t]||"";return e=R?T>0?setTimeout(()=>{P(r.substring(0,T-1)),S(T-1)},45):setTimeout(()=>{C((k+1)%z.length),S(0),L(!1)},1e3):T<r.length?setTimeout(()=>{P(r.substring(0,T+1)),S(T+1)},90):setTimeout(()=>{L(!0)},1e3),()=>clearTimeout(e)},[T,R,k,z,90,45,1e3]),(0,n.useEffect)(()=>{r()},[]),(0,n.useEffect)(()=>{let t=()=>{let t=window.innerWidth<768;x(t),t&&e&&p(!1)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[e]),(0,n.useEffect)(()=>{let e=v.current;if(!e)return;let t=()=>{e.style.height="auto";let t=Math.min(e.scrollHeight,100);e.style.height="".concat(t,"px")};return e.addEventListener("input",t),t(),()=>e.removeEventListener("input",t)},[f]);let D=(0,n.useCallback)(()=>{g&&!h?p(!0):p(!h)},[g,h]),U=(0,n.useCallback)(e=>{l(e),g&&p(!1)},[l,g]),F=(0,n.useCallback)(()=>{i(),g&&p(!1)},[i,g]),M=(0,n.useCallback)(()=>{f.trim()&&!d&&(e||t(),O({interactionType:"chat_query_submit",url:N,elementIdentifier:"chat_input",details:{query:f.trim()}}),c(f.trim(),j),b(""),v.current&&(v.current.style.height="auto"))},[f,d,e,t,c,j,O,N]);return(0,s.jsxs)(s.Fragment,{children:[e&&(0,s.jsx)("div",{className:"fixed inset-x-0 bottom-0 z-50 flex justify-center",style:{height:"calc(100vh - 8rem)"},children:(0,s.jsx)("div",{ref:w,className:"w-full max-w-4xl animate-fade-in-up rounded-t-xl",style:{boxShadow:"0 -4px 15px rgba(99, 102, 241, 0.08)"},children:(0,s.jsx)("div",{className:"h-full bg-white rounded-t-xl overflow-hidden border border-indigo-100/60 after:content-[''] after:absolute after:inset-x-0 after:top-0 after:h-[1px] after:bg-gradient-to-r after:from-indigo-300/30 after:via-violet-400/20 after:to-indigo-300/30",children:(0,s.jsxs)("div",{className:"flex flex-row h-full relative",children:[h&&(0,s.jsx)("div",{className:"h-full transition-all duration-300 ease-in-out overflow-hidden pb-16\n ".concat(g?"absolute inset-0 z-10 w-full":"w-72 md:w-80 flex-shrink-0"),children:(0,s.jsx)(ea,{currentChatId:o,onChatSelect:U,onNewChat:F,onClose:()=>p(!1)})}),(0,s.jsx)("div",{className:"flex-1 flex flex-col h-full transition-all duration-300 ease-in-out\n ".concat(h&&!g?"ml-auto w-[calc(100%-20rem)]":"w-full","\n ").concat(h&&g?"hidden":""),children:(0,s.jsx)(ee,{toggleOpen:t,toggleSidebar:D,sidebarOpen:h,pageContext:j})})]})})})}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)("div",{className:"transition-all duration-300 ease-in-out px-4 ".concat(e?"w-full max-w-4xl":"w-full max-w-2xl"),children:(0,s.jsx)("div",{className:"".concat("fixed inset-x-1/4"," bottom-8 z-[60] transition-opacity duration-300 ").concat(u?"opacity-0 pointer-events-none":"opacity-100"),children:(0,s.jsxs)("div",{className:"w-full bg-white rounded-full flex items-center py-2.5 px-3 border border-indigo-100/60 shadow-[0_0_0_1px_rgba(99,102,241,0.4),0_0_0_6px_rgba(99,102,241,0.5)]",children:[(0,s.jsx)("div",{className:"flex-shrink-0 mr-2",children:(0,s.jsx)(B,{className:"bg-indigo-50 text-indigo-600 hover:bg-indigo-100 data-[state=open]:bg-indigo-100 data-[state=open]:text-indigo-700",size:g?"sm":"md",label:g?"":"Research Assistant",isOpen:e,onToggle:t})}),(0,s.jsx)("div",{className:"flex-1 min-w-0",children:(0,s.jsx)("textarea",{ref:v,className:"w-full bg-transparent border-none outline-none text-gray-800 placeholder-gray-500 text-sm resize-none overflow-y-auto py-0 leading-tight",placeholder:"".concat(E,"|"),value:f,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),M())},rows:1,style:{maxHeight:"100px"}})}),(0,s.jsx)("button",{className:"p-2 rounded-full transition-colors flex-shrink-0 ".concat(f.trim()&&!d?"text-indigo-600 hover:bg-indigo-50":"text-gray-300 cursor-not-allowed"),onClick:M,disabled:!f.trim()||d,"aria-label":"Send message",children:(0,s.jsx)(A.A,{className:"h-4 w-4"})})]})})})})]})});en.displayName="ChatContainerInner";let eo=(0,n.memo)(()=>(0,s.jsxs)(S,{children:[(0,s.jsx)(en,{})," "]}));eo.displayName="ChatContainer";var el=r(15894),ei=r(65476),ec=r(93499);let ed=ei.Kq,eu=n.forwardRef((e,t)=>
1{let{className:r,...a}=e;return(0,s.jsx)(ei.LM,{ref:t,className:(0,P.cn)("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse gap-2 p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",r),...a})});eu.displayName=ei.LM.displayName;let em=(0,E.F)("group pointer-events-auto relative flex w-full flex-col items-center justify-between overflow-hidden rounded-lg border p-5 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full hover:shadow-xl hover:-translate-y-1 hover:duration-200",{variants:{variant:{default:"border-gray-200 bg-white text-gray-900 hover:bg-gray-50/90",info:"border-blue-200 bg-blue-50/70 text-blue-800 hover:bg-blue-50/90",success:"border-emerald-200 bg-emerald-50/70 text-emerald-800 hover:bg-emerald-50/90",warning:"border-amber-200 bg-amber-50/70 text-amber-800 hover:bg-amber-50/90",destructive:"border-red-200 bg-red-50/70 text-red-800 hover:bg-red-50/90",premium:"border-blue-200 bg-gradient-to-r from-blue-50 to-indigo-50 text-blue-900 hover:from-blue-100/90 hover:to-indigo-100/90",deal:"border-indigo-200 bg-gradient-to-r from-indigo-50 to-blue-50 text-indigo-800 shadow-lg hover:from-indigo-100/90 hover:to-blue-100/90"}},defaultVariants:{variant:"default"}}),eh=n.forwardRef((e,t)=>{let{className:r,variant:a,duration:o=5e3,showProgress:l=!0,linkHref:i,linkText:c,onLinkClick:d,children:u,...m}=e,[h,p]=n.useState(100),[g,x]=n.useState(!1),f=Math.max(o,1e3);return n.useEffect(()=>(x(!0),()=>x(!1)),[]),n.useEffect(()=>{if(!g||!l||o===1/0)return;let e=Date.now()+f,t=()=>{let r=Date.now();p(Math.max(e-r,0)/f*100),r<e&&g&&requestAnimationFrame(t)},r=requestAnimationFrame(t);return()=>cancelAnimationFrame(r)},[g,f,o,l]),(0,s.jsxs)(ei.bL,{ref:t,className:(0,P.cn)(em({variant:a}),r),duration:o,...m,children:[(0,s.jsx)("div",{className:"w-full flex items-center justify-between space-x-4",children:(0,s.jsxs)("div",{className:"flex-1",children:[u,i&&c&&(0,s.jsxs)("a",{href:i,onClick:d,className:(0,P.cn)("inline-flex items-center mt-1.5 text-xs font-medium hover:underline","default"===a&&"text-blue-600 hover:text-blue-700","info"===a&&"text-blue-700 hover:text-blue-800","success"===a&&"text-emerald-700 hover:text-emerald-800","warning"===a&&"text-amber-700 hover:text-amber-800","destructive"===a&&"text-red-700 hover:text-red-800","premium"===a&&"text-indigo-700 hover:text-indigo-800","deal"===a&&"text-blue-700 hover:text-blue-800"),children:[c,(0,s.jsx)(ec.A,{className:"ml-1 h-3 w-3"})]})]})}),l&&o!==1/0&&(0,s.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-gray-100/50",children:(0,s.jsx)("div",{className:(0,P.cn)("h-full transition-all ease-linear","default"===a&&"bg-gray-500","info"===a&&"bg-blue-500","success"===a&&"bg-emerald-500","warning"===a&&"bg-amber-500","destructive"===a&&"bg-red-500","premium"===a&&"bg-indigo-500","deal"===a&&"bg-blue-500"),style:{width:"".concat(h,"%")}})})]})});eh.displayName=ei.bL.displayName,n.forwardRef((e,t)=>{let{className:r,...a}=e;return(0,s.jsx)(ei.rc,{ref:t,className:(0,P.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border border-gray-200 bg-transparent px-3 text-sm font-medium text-gray-900 transition-colors hover:bg-gray-100 focus:outline-none focus:ring-1 focus:ring-blue-400 disabled:pointer-events-none disabled:opacity-50",r),...a})}).displayName=ei.rc.displayName;let ep=n.forwardRef((e,t)=>{let{className:r,...a}=e;return(0,s.jsx)(ei.bm,{ref:t,className:(0,P.cn)("absolute right-2 top-2 rounded-full p-1 text-gray-500/80 opacity-0 transition-opacity hover:text-gray-900 hover:bg-gray-100/80 focus:opacity-100 focus:outline-none focus:ring-1 focus:ring-blue-400/20 group-hover:opacity-100",r),"toast-close":"",...a,children:(0,s.jsx)(z.A,{className:"h-4 w-4"})})});ep.displayName=ei.bm.displayName;let eg=n.forwardRef((e,t)=>
1{let{className:r,...a}=e;return(0,s.jsx)(ei.hE,{ref:t,className:(0,P.cn)("text-sm font-semibold group-hover:text-black transition-colors",r),...a})});eg.displayName=ei.hE.displayName;let ex=n.forwardRef((e,t)=>{let{className:r,...a}=e;return(0,s.jsx)(ei.VY,{ref:t,className:(0,P.cn)("text-sm opacity-90 group-hover:opacity-100 transition-opacity",r),...a})});function ef(){let{toasts:e}=(0,el.dj)();return(0,s.jsxs)(ed,{children:[e.map(function(e){let{id:t,title:r,description:a,action:n,...o}=e;return(0,s.jsxs)(eh,{...o,children:[(0,s.jsxs)("div",{className:"grid gap-1",children:[r&&(0,s.jsx)(eg,{children:r}),a&&(0,s.jsx)(ex,{children:a})]}),n,(0,s.jsx)(ep,{})]},t)}),(0,s.jsx)(eu,{})]})}function eb(){let e=new Date().getFullYear();return(0,s.jsx)("footer",{className:"bg-neutral-50 border-t border-neutral-200/80 mt-auto",children:(0,s.jsx)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8 py-6",children:(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row justify-between items-center gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-neutral-500",children:["\xa9 ",e," Theus, Inc. All rights reserved."]}),(0,s.jsxs)("nav",{className:"flex gap-4 sm:gap-6",children:[(0,s.jsx)(l(),{href:"/terms-of-service",className:"text-sm text-neutral-600 hover:text-neutral-900 hover:underline transition-colors",children:"Terms of Service"}),(0,s.jsx)(l(),{href:"/privacy-policy",className:"text-sm text-neutral-600 hover:text-neutral-900 hover:underline transition-colors",children:"Privacy Policy"})]})]})})})}function ev(){return(e=>{let t=(0,a.usePathname)(),{trackPageView:r,trackTimeSpentEvent:s}=(0,y.p)(),o=(0,n.useRef)(e);(0,n.useEffect)(()=>{o.current=e},[e]);let l=(0,n.useRef)(Date.now()),i=(0,n.useRef)(0),c=(0,n.useRef)(!0),d=(0,n.useRef)(t);(0,n.useEffect)(()=>{"undefined"!=typeof document&&(c.current=!document.hidden,c.current&&(l.current=Date.now(),i.current=0))},[]);let u=(0,n.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=Math.round((c.current?i.current+(Date.now()-l.current):i.current)/1e3);t>0&&s({url:d.current,listingId:o.current,durationSeconds:t},e),i.current=0,l.current=Date.now()},[s]);(0,n.useEffect)(()=>{let e=()=>{document.hidden?c.current&&(i.current+=Date.now()-l.current,c.current=!1):c.current||(l.current=Date.now(),c.current=!0)};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[]),(0,n.useEffect)(()=>{d.current=t,r({url:t,listingId:o.current,referrer:document.referrer}),l.current=Date.now(),i.current=0,"undefined"!=typeof document&&(c.current=!document.hidden);let e=()=>u(!0);return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e),u(!1)}},[t,r,u])})(),null}ex.displayName=ei.VY.displayName;let ey=/^\/deals\/[^\/]+(\/.*)?$/,ew=["/broker-dashboard"],ej=["/listings/create","/login","/signup","/listings/sample-splat","/update-password","/purchase","/purchase/spark","/purchase/ignite"];function eN(e){let{children:t}=e,r=(0,a.usePathname)(),n=ew.some(e=>r.startsWith(e)),o=!n&&!ej.includes(r),l=!(n||ey.test(r));return(0,s.jsxs)(y.y,{children:[(0,s.jsx)(ev,{})," ",(0,s.jsxs)("div",{className:"relative flex min-h-screen flex-col",children:[(0,s.jsx)(j,{}),(0,s.jsx)("main",{className:"flex-1 bg-background",children:t}),l&&(0,s.jsx)(eb,{})]}),(0,s.jsx)(ef,{}),o&&(0,s.jsx)(eo,{})]})}},75936:(e,t,r)=>{"use strict";r.d(t,{NavigationTracker:()=>o});var s=r(12115),a=r(20063),n=r(63406);function o(){let e=(0,a.usePathname)(),t=(0,n.l)(e=>e.setPreviousPathname),r=(0,s.useRef)(null);return(0,s.useEffect)(()=>{console.log("Path changed. Previous: ".concat(r.current,", New: ").concat(e)),t(r.current),r.current=e},[e,t]),null}},89589:(e,t,r)=>{"use strict";r.d(t,{CookieCleanup:()=>a});var s=r(12115);function a(){return(0,s.useEffect)(()=>{let e="supabase_cookies_cleaned_v1";if(localStorage.getItem(e))return;console.log("[CookieCleanup] Running one-time Supabase cookie cleanup...");let t=["sb-access-token","sb-refresh-token","session_id"];document.cookie.split(";").forEach(e=>{let r=e.split("=")[0].trim();r.startsWith("sb-")&&!t.includes(r)&&(t.push(r),console.log("[CookieCleanup] Discovered additional cookie
1: ".concat(r)))}),t.forEach(e=>{document.cookie="".concat(e,"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"),document.cookie="".concat(e,"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=theus.ai;"),document.cookie="".concat(e,"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=.theus.ai;"),document.cookie="".concat(e,"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=platform.theus.ai;"),console.log("[CookieCleanup] Deleted cookie: ".concat(e," (all domain variations)"))}),console.log("[CookieCleanup] Cookie cleanup complete. Marking as done."),localStorage.setItem(e,new Date().toISOString())},[]),null}},98169:(e,t,r)=>{"use strict";r.d(t,{GeographicProvider:()=>o,n:()=>l});var s=r(95155),a=r(12115);let n=(0,a.createContext)({location:null,isGeographicLoading:!1,geographicError:null,refreshLocation:()=>{}});function o(e){let{children:t}=e,[r,o]=(0,a.useState)(null),[l,i]=(0,a.useState)(!1),[c,d]=(0,a.useState)(null);return(0,s.jsx)(n.Provider,{value:{location:r,isGeographicLoading:l,geographicError:c,refreshLocation:()=>{if(i(!0),d(null),!navigator.geolocation){d("Geolocation is not supported by your browser"),i(!1);return}navigator.geolocation.getCurrentPosition(e=>{o({latitude:e.coords.latitude,longitude:e.coords.longitude}),i(!1)},e=>{d(e.message),i(!1)},{enableHighAccuracy:!0,timeout:5e3,maximumAge:0})}},children:t})}function l(){let e=(0,a.useContext)(n);if(void 0===e)throw Error("useGeographic must be used within a GeographicProvider");return e}}},e=>{e.O(0,[3608,2978,4545,1386,2619,6630,6093,7150,5746,5239,6743,3464,4993,7330,4297,6578,3872,8441,1255,7358],()=>e(e.s=39396)),_N_E=e.O()}]);
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.