PageSourceSearch

https://markwise.app/js/UnifiedHomePage-BXG1Q3wZ.js

js markwise.app collected 2026-09-24 13:44:27 UTC 67,885 bytes, 16 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/CopilotMarkdown-7MZfTJKn.js","js/rolldown-runtime-M0oDzQ_3.js","js/index-Cs8jPAIC.js","js/preload-helper-BrnWUoxD.js","js/seo-head-CmlpuRo2.js","js/animation-vendor-BTgXq0V2.js","js/react-vendor-i8kANJnN.js","js/page-title-BWLuSIHU.js","js/public-url-jLO8zHKI.js","js/ui-vendor-BN-A7PSs.js","js/dist-CctFy03Y.js","js/useQuery-C1qKqkvR.js","js/QueryClientProvider-b-brzAC2.js","js/useMutation-CJPpWlc6.js","js/useFetch-hoRfo1C_.js","js/dist-BxD1ziz1.js","js/utils-BebnwCks.js","js/state-vendor-BR8DiALS.js","js/lucide-react-B5Mqw2VM.js","js/mw-events-DL4GPaTJ.js","js/logger-DnBz_6uU.js","js/chunk-EVOBXE3Y-B2g1H80g.js","js/dist-CK74me5t.js","js/BrandMark-CgDyQhOw.js","js/copilot-utils-DpOGymRv.js","js/outbound-url-lbRYxzQZ.js","js/dashboard-provider-EkyrAMoA.js","js/pricing-B3gVT7Ue.js","js/editorial-landing-BuL_lTFG.js","js/editorial-slots-CmBlEhte.js","js/menu-elements-C4oQU9Cd.js","assets/editorial-landing-Dud5XxLF.css","js/ds-CCYRtsuz.js","js/SidebarCard-39Ds9Ra7.js","js/skeleton-BGyNvDPa.js","js/comparisons-C3-Gy6nj.js","js/questions-dAr-48yO.js","js/useAuth-CRhwiLdo.js","js/motif-BJUcmHae.js","js/mw-DzOAJp_6.js","js/queryKeys-DqWJGjSe.js","js/paywallStore-Y_iWwZvw.js","assets/index-C9n02oxE.css","js/SourceTypeIcon-ChZ8utnL.js","js/FindResultCard-DTorWiqu.js","js/HighlightedText-CvZt10KZ.js","js/favicon-image-OgeRu8GN.js","js/FeedPage-D_y8_Fe9.js","js/react-masonry-css.module-C083hn_n.js","js/CategorySelector-D_3W_HUU.js","js/NoteCard-DK5ZlMsg.js","js/preferencesStore-aGPxE_kq.js","js/SpaceCard-BG96z83p.js","js/RestoreSessionDialog-BB-GiuCF.js","js/useSessions-BUgLpVPU.js","js/dynamic-icon-C9q0J6-N.js","js/AddToSpaceDialog-BMsJHqNv.js","js/useOnboardingFlow-CsqxxXjd.js","js/skeletons--PrOT7bt.js","js/useContentCounts-BBD8HBnA.js","js/useTagVocabulary-CL6l4qmy.js","js/magicSpacesStore-Ct8B0M5-.js"])))=>i.map(i=>d[i]);
2import{a as as}from"./rolldown-runtime-M0oDzQ_3.js";import{A as ns,C as os,D as is,E as ls,O as cs,S as ds,T as us,b as ms,f as ps,j as dt,k as hs,m as xs,p as fs,w as gs,x as ut,y as bs}from"./mw-events-DL4GPaTJ.js";import{a as ys,i as Lt,n as Y,o as vs,t as ks}from"./animation-vendor-BTgXq0V2.js";import{A as ws,J as $t,M as mt,S as pt,V as ht,X as Mt,Y as Fe,_ as Pt,d as Ft,i as js,v as Ot}from"./dashboard-provider-EkyrAMoA.js";import{t as Ns}from"./useQuery-C1qKqkvR.js";import{n as Cs}from"./QueryClientProvider-b-brzAC2.js";import{t as v}from"./utils-BebnwCks.js";import{t as Ve}from"./preload-helper-BrnWUoxD.js";import{f as Kt,t as _s,u as Je}from"./chunk-EVOBXE3Y-B2g1H80g.js";import{n as G}from"./dist-CK74me5t.js";import{a as xt,i as Ut,t as Ss}from"./useFetch-hoRfo1C_.js";import{$t as Is,A as As,C as Ie,En as Bt,Fn as qe,Jt as ft,Kt as Es,N as Ae,Nt as Rs,Q as qt,R as Ts,Vt as je,Wt as Ds,at as Ht,bn as ye,h as Ls,ht as Gt,in as zt,kn as Ee,nt as $s,q as gt,r as Ce,st as Ms,vn as He,x as Ps}from"./lucide-react-B5Mqw2VM.js";import{l as Fs}from"./pricing-B3gVT7Ue.js";import{t as Os}from"./outbound-url-lbRYxzQZ.js";import{C as Ks,S as Us,T as bt,_ as yt,a as Bs,b as Ne,c as qs,d as vt,f as Hs,g as Ge,h as kt,i as ze,l as wt,m as Gs,n as zs,o as Ws,p as Oe,r as Qs,t as Vs,u as jt,v as Js,x as Ys,y as Xs}from"./copilot-utils-DpOGymRv.js";import{E as Zs,T as er,f as tr,m as Nt,p as sr,t as rr,w as We}from"./ds-CCYRtsuz.js";import{t as Wt}from"./paywallStore-Y_iWwZvw.js";import{$ as ar,Bt as nr,C as or,D as ir,Et as lr,J as cr,N as Se,Q as dr,St as ur,T as mr,Ut as pr,Xt as Ct,Y as hr,Z as xr,_ as fr,_t as gr,b as br,bt as yr,et as vr,g as kr,gt as wr,h as jr,m as Nr,nt as Cr,q as _r,tt as Sr,v as Ir,w as Ar,x as Er,y as Rr,yt as Tr}from"./index-Cs8jPAIC.js";import{t as ue}from"./SourceTypeIcon-ChZ8utnL.js";import{t as Dr}from"./favicon-image-OgeRu8GN.js";import{i as Lr,t as $r}from"./useNotes-lXDpvKYT.js";import{t as Qt}from"./useContentCounts-BBD8HBnA.js";import{d as Mr,r as Pr}from"./useSessions-BUgLpVPU.js";import{t as Fr}from"./progress-CyGQ1eev.js";import{a as Or,n as Kr,r as Ur,t as Br}from"./useResurface-CJ2KI1bl.js";var a=as(vs(),1),Ye="mw.free_ask",qr=5;function Re(){return new Date().toISOString().slice(0,10)}function Xe(){try{const t=JSON.parse(localStorage.getItem(Ye)||"{}");if(t&&t.date===Re()&&typeof t.count=="number")return t}catch{}return{date:Re(),count:0}}function Vt(){return Math.max(0,qr-Xe().count)}
2function Hr(){try{const t=Xe();localStorage.setItem(Ye,JSON.stringify({date:Re(),count:t.count+1}))}catch{}}function Gr(){try{const t=Xe();localStorage.setItem(Ye,JSON.stringify({date:Re(),count:Math.max(0,t.count-1)}))}catch{}}var e=ys(),zr=t=>({"--type-accent":We(t)}),Wr="border-l-2 border-l-transparent data-[selected=true]:border-l-[color:var(--type-accent)]",Ke=2,ce={space:t=>({id:t.id,type:"space",title:t.name}),session:t=>({id:t.id??"",type:"session",title:Mr(t)}),note:t=>({id:t.id,type:"note",title:t.title||"Untitled Note"}),bookmark:t=>({id:t.id,type:"bookmark",title:t.title||"Untitled",url:t.url,faviconUrl:t.favicon_url})};function _t({open:t,onOpenChange:n,onSelect:i,attachedKeys:m}){const{fetchWithAuth:x}=Ut(),[l,c]=(0,a.useState)(""),[p,f]=(0,a.useState)(""),{data:d,isLoading:u}=Ft(1,20),{data:w,isLoading:N}=lr(1,20),{data:R,isLoading:P}=Lr(1,20),{data:K,isLoading:E}=Pr();(0,a.useEffect)(()=>{t||(c(""),f(""))},[t]),(0,a.useEffect)(()=>{const I=l.trim();if(I.length<Ke){f("");return}const b=setTimeout(()=>f(I),250);return()=>clearTimeout(b)},[l]);const{data:S,isFetching:D}=Ns({queryKey:["context-picker-search",p],queryFn:async()=>(await x({method:"POST",url:"https://api.markwise.app/v1/search",data:{query:p,limit:30}})).data??{results:[],total_count:0},enabled:t&&p.length>=Ke,staleTime:3e4}),g=l.trim().length>=Ke,C=g?D&&!S:u||N||P||E,k=(0,a.useMemo)(()=>{if(g){const I={space:[],session:[],note:[],bookmark:[]};for(const b of S?.results??[])b.type==="space"?I.space.push(ce.space(b.item)):b.type==="session"?I.session.push(ce.session(b.item)):b.type==="note"?I.note.push(ce.note(b.item)):b.type==="bookmark"&&I.bookmark.push(ce.bookmark(b.item));return[{heading:"Spaces",items:I.space},{heading:"Focus Sessions",items:I.session.filter(b=>b.id)},{heading:"Notes",items:I.note},{heading:"Bookmarks",items:I.bookmark}].filter(b=>b.items.length>0)}return[{heading:"Spaces",items:(d?.spaces??[]).map(ce.space)},{heading:"Focus Sessions",items:(K?.sessions??[]).slice(0,20).map(ce.session).filter(I=>I.id)},{heading:"Recent Notes",items:(R?.notes??[]).map(ce.note)},{heading:"Recent Bookmarks",items:(w?.bookmarks??[]).map(ce.bookmark)}].filter(I=>I.items.length>0)},[g,S,d,K,R,w]);return(0,e.jsxs)(_r,{open:t,onOpenChange:n,children:[(0,e.jsx)(hr,{asChild:!0,children:(0,e.jsx)("span",{className:"pointer-events-none absolute bottom-0 left-0"})}),(0,e.jsx)(cr,{className:v("bg-card border-border/60 w-[360px] overflow-hidden rounded-xl border p-0 shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)]","[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:border-border/30 [&_[cmdk-group-heading]]:border-b [&_[cmdk-group-heading]]:px-3 [&_[cmdk-group-heading]]:pt-2 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:text-[10px] [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:tracking-wider [&_[cmdk-group-heading]]:uppercase","[&_[cmdk-item][data-selected=true]]:bg-muted [&_[cmdk-item][data-selected=true]]:text-foreground","[&_[cmdk-input]]:border-border/30 [&_[cmdk-input]]:border-b [&_[cmdk-input]]:text-sm"),align:"start",side:"top",sideOffset:8,children:(0,e.jsxs)(xr,{shouldFilter:!1,children:[(0,e.jsx)(vr,{placeholder:"Search bookmarks, notes, spaces, focus sessions...",value:l,onValueChange:c}),(0,e.jsx)(Cr,{children:C?(0,e.jsxs)("div",{className:"flex items-center justify-center gap-2 py-6",children:[(0,e.jsx)(Ht,{className:"text-muted-foreground h-4 w-4 animate-spin"}),(0,e.jsx)("span",{className:"text-muted-foreground text-sm",children:"Loading…"})]}):(0,e.jsxs)(e.Fragment,{children:[k.length===0&&(0,e.jsx)(dr,{children:g?`Nothing matches “${l.trim()}”.`:"No results found."}),k.map(I=>(0,e.jsx)(ar,{heading:I.heading,children:I.items.map(b=>{const L=ze(b),q=m.has(L);return(0,e.jsxs)(Sr,{value:L,disabled:q,onSelect:()=>{q||(i(b),n(!1))},style:zr(b.type),className:v(Wr,q&&"opacity-40"),children:[b.type==="bookmark"&&b.faviconUrl?(0,e.jsx)(Dr,{url:b.faviconUrl,domain:"",className:"h-4 w-4 shrink-0 rounded-sm"}):(0,e.jsx)(ue,{type:b.type,className:"h-4 w-4 shrink-0"}),(0,e.jsx)("span",{className:"flex-1 truncate",children:b.title}),q&&(0,e.jsx)("span",{className:"text-muted-foreground text-xs",children:"added"})]},L)})},I.heading))]})}),(0,e.jsxs)("div",{className:"text-muted-foreground border-border/30 flex items-center justify-center gap-3 border-t px-3 py-1.5 text-[10px]",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("kbd",{className:"bg-muted rounded px-1 py-0.5 font-mono text-[10px]",children:"↑↓"})," navigate"]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("kbd",{className:"bg-muted rounded px-1 py-0.5 font-mono text-[10px]",children:"↵"})," select"]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("kbd",{className:"bg-muted rounded px-1 py-0.5 font-mono text-[10px]",children:"esc"})," close"]})]})]})})]})}function Ue({items:t,onRemove:n}){return t.length===0?null:(0,e.jsx)("div",{className:"flex flex-wrap gap-1.5 px-1",children:t.map(i=>(0,e.jsxs)("span",{className:"bg-muted border-border flex items-center gap-1 rounded-lg border px-2 py-1 text-xs font-medium",children:[(0,e.jsx)(ue,{type:i.type,className:"h-3 w-3"}),(0,e.jsx)("span",{className:"max-w-[120px] truncate",children:i.title}),n&&(0,e.jsx)("button",{onClick:()=>n(ze(i)),className:"text-muted-foreground hover:text-foreground hover:bg-foreground
2/10 focus-visible:ring-ring relative -mr-1 ml-0.5 flex min-h-[44px] min-w-[44px] items-center justify-center rounded-md p-1 transition-colors after:absolute after:-inset-1.5 after:content-[''] focus-visible:ring-1 focus-visible:outline-none sm:min-h-[24px] sm:min-w-[24px]","aria-label":`Remove ${i.title}`,children:(0,e.jsx)(Ce,{className:"h-3 w-3"})})]},ze(i)))})}function Qr({input:t,setInput:n,inputRef:i}){const m=(0,a.useId)(),[x,l]=(0,a.useState)(0),c=(0,a.useMemo)(()=>{const d=t.trimStart();if(!(d.startsWith("/")&&!d.includes(" ")&&!d.includes(`
3`)))return[];const u=d.toLowerCase();return $t.filter(w=>w.cmd.startsWith(u))},[t]),p=c.length>0&&t.trimStart().startsWith("/");(0,a.useEffect)(()=>{x>=c.length&&l(0)},[c.length,x]);const f=(0,a.useCallback)(d=>{n(d.cmd+" "),l(0),requestAnimationFrame(()=>{const u=i.current;if(!u)return;u.focus();const w=u.value.length;u.setSelectionRange(w,w)})},[n,i]);return{open:p,items:c,selectedIdx:x,onHover:l,onPick:f,onKeyDown:(0,a.useCallback)(d=>{if(!p)return!1;if(d.key==="ArrowDown")return d.preventDefault(),l(u=>(u+1)%c.length),!0;if(d.key==="ArrowUp")return d.preventDefault(),l(u=>(u-1+c.length)%c.length),!0;if(d.key==="Enter"||d.key==="Tab"){d.preventDefault();const u=c[x];return u&&f(u),!0}return d.key==="Escape"?(d.preventDefault(),n(""),!0):!1},[p,c,x,f,n]),onInputChange:(0,a.useCallback)(d=>{},[]),menuId:m}}function Vr(t={}){const n=t.emptyPath??"/",{chatId:i}=Kt(),m=Je(),[x,l]=(0,a.useState)(""),[c,p]=(0,a.useState)([]),[f,d]=(0,a.useState)(null),[u,w]=(0,a.useState)(!1),[N,R]=(0,a.useState)(null),[P,K]=(0,a.useState)(!1),[E,S]=(0,a.useState)([]),[D,g]=(0,a.useState)(!1),[C,k]=(0,a.useState)(null),I=ur(r=>r.setNewChatHandler),b=(0,a.useRef)(null),L=(0,a.useRef)(null),q=(0,a.useRef)(!1),W=(0,a.useRef)(null),o=(0,a.useRef)([]),{streamWithAuth:_}=Ut(),{mutateAsync:F}=$r(),ae=js(),{hasAccess:Q,requireAccess:me}=Pt(),ve=Cs(),{data:Te}=mr(1,50),_e=Te?.conversations??[],{data:X,error:ne}=Ar(i),Z=ir();(0,a.useEffect)(()=>{i&&!Q&&m(n,{replace:!0})},[i,Q,m,n]),(0,a.useEffect)(()=>{if(!(!i||!Q)){if(!or(i)){G.error("Invalid chat link."),m(n,{replace:!0});return}ne instanceof Ss&&ne.status===404&&(G.error("Chat not found."),m(n,{replace:!0}))}},[i,Q,ne,m,n]);const ee=(0,a.useCallback)(()=>{b.current&&(L.current="discard",b.current.abort(),b.current=null)},[]);(0,a.useEffect)(()=>{if(!i){if(N){if(W.current===N)return;ee(),p([]),d(null),R(null),S([]),l(""),k(null),w(!1)}return}W.current===i&&(W.current=null),!(!Q||i===N||!X)&&(ee(),p((X.messages??[]).map(r=>({role:r.role,content:r.content,sources:r.sources,actions:r.actions,webFetched:r.web_fetched,skill:r.skill,timestamp:r.timestamp,...r.attached_items?.length&&{attachedItems:r.attached_items.map(y=>({id:y.id,type:y.type,title:y.title,url:y.url,faviconUrl:y.favicon_url}))}}))),d(X.conversation_id??null),R(X.id),S([]),l(""),k(null),w(!1))},[N,ee,Q,i,X]),(0,a.useEffect)(()=>{if(q.current)return;q.current=!0;const r="mw_copilot_conversations",y="mw_copilot_migrated";if(localStorage.getItem(y))return;const M=localStorage.getItem(r);if(M)try{const T=JSON.parse(M);if(T.length===0){localStorage.removeItem(r);return}Promise.all(T.map(H=>Z.mutateAsync({title:H.title,messages:H.messages.map($=>({role:$.role,content:$.content,sources:$.sources,actions:$.actions,web_fetched:$.webFetched,skill:$.skill,timestamp:$.timestamp})),conversation_id:H.conversationId||void 0}).catch(()=>null))).then(H=>{const $=T.filter((ge,be)=>!H[be]),te=H.length-$.length;if($.length===0){localStorage.removeItem(r),localStorage.setItem(y,"1"),te>0&&G.success("Chat history synced to your account");return}localStorage.setItem(r,JSON.stringify($)),te>0?G.warning(`Synced ${te} chat${te===1?"":"s"}. ${$.length} will retry later.`):G.error("Couldn't sync local chat history. It will retry later.")})}catch{localStorage.removeItem(r),localStorage.setItem(y,"1")}},[Z]);const pe=(0,a.useRef)(null),he=(0,a.useRef)(!0),oe=(0,a.useRef)(null),ke=(0,a.useMemo)(()=>Bs(E),[E]),xe=Qr({input:x,setInput:l,inputRef:oe}),De=(0,a.useMemo)(()=>{if(E.length>0)return"Ask about the attached items…";const{skill:r}=yt(x);switch(r){case"find_anything":return"Type a topic or keyword to find items…";case"ask_library":return"Type a question about your saves…";case"save_link":return"Paste a URL to save…";case"note_from_saves":return"Describe the note to draft from your saves…";case"space_from_saves":return"Describe the space to group your saves into…";default:return"Ask a question, or type / for commands"}},[x,E.length]);(0,a.useEffect)(()=>{const r=pe.current;if(!r||typeof IntersectionObserver>"u")return;const y=new IntersectionObserver(M=>{he.current=M[0]?.isIntersecting??!0},{root:r.closest("main")||null,rootMargin:"0px 0px 160px 0px",threshold:0});return y.observe(r),()=>y.disconnect()},[]),(0,a.useEffect)(()=>{he.current&&pe.current?.scrollIntoView({behavior:"auto"})},[c]),(0,a.useEffect)(()=>{oe.current?.focus()},[]),(0,a.useEffect)(()=>{const r=o.current;return()=>{L.current="discard",b.current?.abort(),r.forEach(clearTimeout)}},[]);const fe=(0,a.useCallback)(async(r,y)=>{const M=(r??x).trim();if(!M||u)return;if(!Q&&Vt()<=0){me("copilot");return}const{skill:T,cleanQuery:H}=yt(M),$=H||M,te=y??c;if(T&&!H){G.error(`Type a query after ${Object.entries(zs).find(([,h])=>h===T)?.[0]||"/"+T}`);return}Q||Hr(),us({skill:T||void 0,has_context:E.length>0,context_count:E.length,is_follow_up:te.length>0,query_length:$.length});const ge=E,be={role:"user",content:M,skill:T,timestamp:Date.now(),...ge.length>0&&{attachedItems:ge}};p(y?[...y,be]:h=>[...h,be]),l(""),S([]),w(!0),k(null),he.current=!0;const de=new AbortController;L.current=null,b.current=de;const Me=Date.now(),Zt=te.length>0,es=setTimeout(()=>{de.signal.aborted||(L.current="timeout",de.abort())},12e4),et=h=>({role:h.role,content:h.content,sources:h.sources,actions:h.actions,web_fetched:h.webFetched,skill:h.skill,timestamp:h.timestamp,...h.attachedItems?.length&&{attached_items:h.attachedItems.map(J=>({id:J.id,type:J.type,title:J.title,url:J.url??void 0,favicon_url:J.faviconUrl??void 0}))}}),tt=h=>!(h.role==="assistant"&&(h.isError||h.content.startsWith("I couldn't process that request."))),st=ge.map(h=>({id:h.id,type:h.type,title:h.title,url:h.url??void 0,favicon_url:h.faviconUrl??void 0})),rt=[...te,be].filter(tt);let at=null;const nt=N?null:Z.mutateAsync({title:vt(rt),messages:rt.map(et),...f&&{conversation_id:f},attached_items:st}).then(h=>{at=h.id,!de.signal.aborted&&(W.current=h.id,R(h.id),m(`/chat/${h.id}`,{replace:!0}),ut({skill:T||void 0,context_count:ge.length}))}).catch(h=>{xt("warn","Copilot early conversation create failed; saving after response instead",h)});try{const h=Ws(E,te,$),J={query:$,...f&&{conversation_id:f},...T&&{skill:T},...h.contextTypes.length>0&&h.spaceIds.length===0&&{types:h.contextTypes},...h.contextIds.length>0&&{context_ids:h.contextIds},...h.spaceIds.length>0&&{space_ids:h.spaceIds},...h.contextLabels.length>0&&{context_labels:h.contextLabels},...h.contextUrls.length>0&&{context_urls:h.contextUrls}},U=Date.now(),V={content:"",placeholderAdded:!1,final:null,error:null,convoId:""},ie=()=>{V.placeholderAdded||(V.placeholderAdded=!0,p(A=>[...A,{role:"assistant",content:"",skill:T,timestamp:U,streaming:!0}]))};let re=null;const ot=()=>{re=null,p(A=>{const O=[...A],le=O[O.length-1];return le?.role==="assistant"&&le.streaming&&(O[O.length-1]={...le,content:V.content}),O})},ts=()=>
3{if(typeof requestAnimationFrame>"u"){ot();return}re==null&&(re=requestAnimationFrame(ot))},ss=()=>{re!=null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(re),re=null};try{await _({url:"https://api.markwise.app/v1/search/converse/stream",data:J,signal:de.signal,onEvent:A=>{switch(A.type){case"meta":A.conversation_id&&(V.convoId=A.conversation_id);break;case"delta":ie(),V.content+=A.delta,ts();break;case"done":V.final=A.response;break;case"error":V.error=A.error;break}}})}finally{ss()}if(V.error)throw new Error(V.error);const z=V.final;if(!z)throw new Error("No response received");const Pe={role:"assistant",content:z.answer,sources:Ne(z.answer,z.sources),actions:z.actions,webFetched:z.web_fetched,skill:T,timestamp:U,streaming:!1},it=[...te,be,Pe],lt=z.conversation_id||V.convoId||f;if(p(A=>{const O=[...A],le=O[O.length-1];return le?.role==="assistant"&&le.streaming?(O[O.length-1]=Pe,O):[...O,Pe]}),d(lt),hs({skill:T||void 0,source_count:z.sources?.length??0,has_actions:(z.actions?.length??0)>0,web_fetched:!!z.web_fetched,duration_ms:Date.now()-Me,is_follow_up:Zt}),z.actions?.length)for(const A of z.actions)bs({type:A.type,success:!!A.success});const ct=qs(z.actions);for(const A of ct)pt(ve,A);if(z.actions?.some(A=>A.type==="save_bookmark"&&A.success))for(const A of[3e3,8e3,15e3]){const O=setTimeout(()=>{for(const le of ct)pt(ve,le)},A);o.current.push(O)}const rs=it.filter(tt).map(et);try{nt&&await nt;const A=N||at,O=await Z.mutateAsync({id:A||void 0,title:vt(it),messages:rs,conversation_id:lt||void 0,attached_items:st});A||(W.current=O.id,R(O.id),m(`/chat/${O.id}`,{replace:!0}),ut({skill:T||void 0,context_count:ge.length}))}catch(A){xt("warn","Copilot conversation save failed",A),G.error("Response shown, but chat history couldn't be saved.")}}catch(h){if(Q||Gr(),de.signal.aborted&&L.current!=="timeout")L.current!=="discard"&&(p(J=>{let U=[...J];return U[U.length-1]?.role==="assistant"&&U[U.length-1]?.streaming&&(U=U.slice(0,-1)),U[U.length-1]?.role==="user"&&(U=U.slice(0,-1)),U}),l(M)),is({skill:T||void 0,duration_ms:Date.now()-Me});else{const J=L.current==="timeout"?"This is taking too long — please try again.":h instanceof Error?h.message:"Couldn't get a response. Check your connection and try again.";k(M);const U={role:"assistant",content:`${Vs} ${J}.`,timestamp:Date.now(),isError:!0};p(V=>{const ie=[...V],re=ie[ie.length-1];return re?.role==="assistant"&&re.streaming?(ie[ie.length-1]=U,ie):[...ie,U]}),cs({skill:T||void 0,reason:J,duration_ms:Date.now()-Me})}}finally{clearTimeout(es),w(!1),b.current===de&&(b.current=null,L.current=null),oe.current?.focus()}},[x,f,u,Q,me,c,N,E,_,m,Z,ve]),Le=r=>{xe.onKeyDown(r)||r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),fe())},we=(0,a.useCallback)(()=>{W.current=null,ee(),w(!1),p([]),d(null),R(null),K(!1),S([]),l(""),k(null),i&&m(n,{replace:!0}),oe.current?.focus()},[ee,m,i,n]),se=(0,a.useCallback)(()=>{const r=c.length>0||E.length>0;if(os({source:"topbar",had_unsaved:r}),r){K(!0);return}we()},[c.length,E.length,we]);return(0,a.useEffect)(()=>(I(se),()=>I(null)),[se,I]),{input:x,setInput:l,messages:c,isLoading:u,isPro:Q,requireAccess:me,attachedItems:E,showContextPicker:D,setShowContextPicker:g,attachedKeys:ke,lastFailedQuery:C,showNewChatConfirm:P,setShowNewChatConfirm:K,savedConversations:_e,inputRef:oe,messagesEndRef:pe,slashMenu:xe,inputPlaceholder:De,handleSend:fe,handleKeyDown:Le,handleInputChange:r=>{const y=r.target.value;l(y),r.target.style.height="auto",r.target.style.height=Math.min(r.target.scrollHeight,128)+"px",y.endsWith("@")&&!D&&(y.length===1||y.charAt(y.length-2)===" ")&&g(!0),xe.onInputChange(y)},handleAttachItem:r=>{const y=Hs(E,r);if(y){G.error(y);return}S(M=>[...M,r]),ms({item_type:r.type,context_count:E.length+1}),l(M=>M.replace(/@$/,"")),oe.current?.focus()},handleRemoveAttachment:r=>{S(y=>Js(y,r))},handleCancel:()=>{L.current="cancel",b.current?.abort()},handleRetry:()=>{C&&fe(C,Xs(c,C))},resetChat:we,handleSaveAsNote:(0,a.useCallback)(async(r,y,M)=>{try{const T=await F({title:r,content:y,tags:["copilot"]}),H=(M??[]).filter($=>$.type==="space");if(T?.id&&H.length>0){for(const $ of H)try{await ae.mutateAsync({spaceId:$.id,noteId:T.id})}catch{}G.success(`Saved to ${H.length===1?H[0].title:`${H.length} spaces`}`)}else G.success("Saved as note")}catch{G.error("Failed to save note")}},[F,ae]),handleNewChat:se}}var Jr={create_space:t=>`/spaces/${t}`,create_note:t=>`/notes/${t}/edit`,save_bookmark:t=>`/bookmarks/${t}`,summarize_to_note:t=>`/notes/${t}/edit`};function Yr(t){const n=t.name?.trim();if(n&&!/^https?:\/\//i.test(n))return n;const i=n||t.url||"";try{return new URL(i).hostname.replace(/^www\./,"")}catch{return i||"link"}}function Xr(t){return t.success?t.id?Jr[t.type](t.id):t.url&&/^https?:\/\//i.test(t.url)?Os(t.url):t.url??null:null}var Zr={create_space:{icon:Ee,label:"Created space"},create_note:{icon:je,label:"Created note"},save_bookmark:{icon:Bt,label:"Saved bookmark"}
3,summarize_to_note:{icon:je,label:"Saved as note"}};function ea({action:t}){const n=Zr[t.type]??{icon:je,label:t.type},i=n.icon,m=Xr(t);return m?(0,e.jsxs)(Se,{href:m,className:"flex items-center gap-2.5 border-l-2 border-l-[rgb(var(--color-success))] bg-[rgb(var(--color-success)/0.08)] px-3 py-2 text-xs transition-colors hover:bg-[rgb(var(--color-success)/0.15)] active:scale-[0.99]",children:[(0,e.jsx)(ye,{className:"h-3.5 w-3.5 shrink-0 text-[rgb(var(--color-success))]"}),(0,e.jsx)(i,{className:"h-3.5 w-3.5 shrink-0 text-[rgb(var(--color-success))]"}),(0,e.jsxs)("span",{className:"min-w-0 flex-1 truncate font-medium",children:[n.label," “",Yr(t),"”"]}),(0,e.jsx)("span",{className:"text-muted-foreground shrink-0 text-[10px] font-medium tracking-wide uppercase",children:"Open"})]}):(0,e.jsxs)("div",{className:"flex items-center gap-2.5 border-l-2 border-l-[rgb(var(--color-danger))] bg-[rgb(var(--color-danger)/0.08)] px-3 py-2 text-xs",children:[(0,e.jsx)(Ce,{className:"h-3.5 w-3.5 shrink-0 text-[rgb(var(--color-danger))]"}),(0,e.jsx)(i,{className:"h-3.5 w-3.5 shrink-0 text-[rgb(var(--color-danger)/0.7)]"}),(0,e.jsx)("span",{className:"text-[rgb(var(--color-danger))]",children:t.error||"Action failed"})]})}function ta({shape:t}){return t?t==="list"?(0,e.jsxs)("div",{className:"flex shrink-0 flex-col gap-[3px]","aria-hidden":"true",children:[(0,e.jsx)("div",{className:"bg-muted-foreground/30 h-1 w-6 rounded-[1px]"}),(0,e.jsx)("div",{className:"bg-muted-foreground/30 h-1 w-6 rounded-[1px]"}),(0,e.jsx)("div",{className:"bg-muted-foreground/30 h-1 w-6 rounded-[1px]"})]}):t==="prose"?(0,e.jsxs)("div",{className:"flex shrink-0 flex-col gap-[2px]","aria-hidden":"true",children:[(0,e.jsx)("div",{className:"bg-muted-foreground/30 h-[2px] w-6 rounded-[1px]"}),(0,e.jsx)("div",{className:"bg-muted-foreground/30 h-[2px] w-6 rounded-[1px]"}),(0,e.jsx)("div",{className:"bg-muted-foreground/30 h-[2px] w-4 rounded-[1px]"})]}):(0,e.jsx)("div",{className:"border-muted-foreground/30 h-3 w-6 shrink-0 rounded-sm border border-dashed","aria-hidden":"true"}):null}function St({open:t,items:n,selectedIdx:i,menuId:m,onPick:x,onHover:l,placement:c="top"}){return(0,e.jsx)(Lt,{children:t&&n.length>0&&(0,e.jsxs)(Y.div,{"data-slash-menu":!0,role:"listbox",id:m,"aria-label":"Copilot skill commands",initial:{opacity:0,y:c==="bottom"?-8:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:c==="bottom"?-4:4,scale:.98},transition:{duration:.15,ease:[.16,1,.3,1]},className:v("bg-card border-border/60 absolute right-0 left-0 z-50 mx-auto max-h-[min(60vh,22rem)] w-full max-w-md overflow-y-auto rounded-xl border shadow-[0_12px_32px_-12px_rgba(0,0,0,0.18)]",c==="bottom"?"top-[calc(100%+8px)]":"bottom-[calc(100%+8px)]"),children:[(0,e.jsx)("div",{className:"text-muted-foreground border-border/30 border-b px-3 pt-2 pb-1 text-[10px] font-medium tracking-wider uppercase",children:"Copilot Skills"}),(0,e.jsx)("ul",{className:"py-1",children:n.map((p,f)=>{const d=p.icon,u=f===i;return(0,e.jsxs)("li",{id:`${m}-opt-${f}`,role:"option","aria-selected":u,onMouseEnter:()=>l(f),onMouseDown:w=>{w.preventDefault(),x(p)},className:v("group/row flex cursor-pointer items-center gap-3 border-l-2 border-l-transparent px-3 py-2 transition-colors",!u&&"hover:bg-muted"),style:u?{borderLeftColor:p.color,background:`rgb(${p.cr} / 0.10)`}:void 0,children:[(0,e.jsx)(d,{className:"h-4 w-4 shrink-0 transition-colors",style:{color:p.color}}),(0,e.jsxs)("div",{className:"flex min-w-0 flex-1 items-baseline gap-2",children:[(0,e.jsx)("span",{className:"text-foreground font-mono text-[13px] font-semibold",children:p.cmd}),(0,e.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:p.description})]}),(0,e.jsx)(ta,{shape:p.previewShape})]},p.cmd)})}),(0,e.jsxs)("div",{className:"text-muted-foreground border-border/30 flex items-center justify-center gap-3 border-t px-3 py-1.5 text-[10px]",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("kbd",{className:"bg-muted rounded px-1 py-0.5 font-mono text-[10px]",children:"↑↓"})," navigate"]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("kbd",{className:"bg-muted rounded px-1 py-0.5 font-mono text-[10px]",children:"↵"})," select"]}),(0,e.jsxs)("span",{children:[(0,e.jsx)("kbd",{className:"bg-muted rounded px-1 py-0.5 font-mono text-[10px]",children:"esc"})," close"]})]})]})})}var sa=(0,a.lazy)(()=>Ve(()=>import("./CopilotMarkdown-7MZfTJKn.js").then(t=>t.n).then(t=>({default:t.CopilotMarkdown})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43]))),ra=(0,a.lazy)(()=>Ve(()=>import("./FindResultCard-DTorWiqu.js").then(t=>({default:t.FindResultCardList})),__vite__mapDeps([44,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,45,46])));function aa({content:t,question:n,sources:i,isError:m,attachedItems:x,onSaveNote:l}){const[c,p]=(0,a.useState)(!1),[f,d]=(0,a.useState)(!1),[u,w]=(0,a.useState)(!1),N=(0,a.useRef)([]);if((0,a.useEffect)(()=>()=>N.current.forEach(clearTimeout),[]),m)return null;const R=D=>{D(!0),N.current.push(setTimeout(()=>D(!1),2e3))},{body:P}=Ge(t),K=async()=>{await wt(P)?(R(p),G.success("Copied as markdown")):G.error("Couldn't copy - try selecting the text manually")},E=async()=>{const D=Ne(t,i)?.map((C,k)=>`[${k+1}] ${C.title}${C.url?` - ${C.url}`:""}`).join(`
4`)||"",g=`${n?`> ${n}
5
6`:""}${P}${D?`
7
8---
9Sources:
10${D}`:""}`;if(navigator.share)try{await navigator.share({title:n||"Markwise insight",text:g}),R(d);return}catch{}await wt(g)?(R(d),G.success("Copied with sources")):G.error("Couldn't copy - try selecting the text manually")},S=()=>{const D=n||"Copilot insight",g=Ne(t,i);l(D,P+(g?.length?`
11
12---
13Sources:
14`+g.map((C,k)=>`[${k+1}] ${C.title}${C.url?` - ${C.url}`:""}`).join(`
15`):""),x),R(w)};return(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[(0,e.jsxs)("button",{onClick:K,className:"text-muted-foreground hover:text-foreground hover:bg-muted flex min-h-[44px] items-center gap-1 rounded-lg px-2 py-1.5 transition-colors sm:min-h-0",title:"Copy as markdown",children:[c?(0,e.jsx)(ye,{className:"h-3.5 w-3.5"}):(0,e.jsx)(Is,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{className:"hidden text-[11px] sm:inline",children:c?"Copied":"Copy"})]}),(0,e.jsxs)("button",{onClick:S,className:"text-muted-foreground hover:text-foreground hover:bg-muted flex min-h-[44px] items-center gap-1 rounded-lg px-2 py-1.5 transition-colors sm:min-h-0",title:"Save as note with sources",children:[u?(0,e.jsx)(ye,{className:"h-3.5 w-3.5"}):(0,e.jsx)(je,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{className:"hidden text-[11px] sm:inline",children:u?"Saved":"Save"})]}),(0,e.jsxs)("button",{onClick:E,className:"text-muted-foreground hover:text-foreground hover:bg-muted flex min-h-[44px] items-center gap-1 rounded-lg px-2 py-1.5 transition-colors sm:min-h-0",title:"Share with sources",children:[f?(0,e.jsx)(ye,{className:"h-3.5 w-3.5"}):(0,e.jsx)(As,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{className:"hidden text-[11px] sm:inline",children:f?"
15Shared":"Share"})]})]})}var It=["What are you working on?","Ask your library anything.","Ready to connect some dots?","What did your bookmarks teach you?","Find meaning across your saves."];function na(){const t=ks(),[n,i]=(0,a.useState)(0),[m,x]=(0,a.useState)(!0);return(0,a.useEffect)(()=>{if(t)return;let l;const c=setInterval(()=>{x(!1),l=setTimeout(()=>{i(p=>(p+1)%It.length),x(!0)},300)},8e3);return()=>{clearInterval(c),clearTimeout(l)}},[t]),{text:It[n],visible:m}}function oa({content:t}){return(0,e.jsx)("p",{className:"leading-relaxed whitespace-pre-wrap",children:Ks(t).replace(/\\n/g,`
16`)})}function ia(t){switch(t){case"find_anything":return"Searching your library…";case"save_link":return"Saving link…";case"note_from_saves":return"Drafting note…";case"space_from_saves":return"Creating space…";default:return"Reading your library…"}}var Jt={accent:"text-blue-500",stripe:"border-l-blue-500/60",hoverBorder:"hover:border-blue-500/50",hoverBg:"hover:bg-blue-500/[0.04]",chevronHover:"group-hover/prompt:text-blue-500"},Yt={accent:"text-violet-500",stripe:"border-l-violet-500/60",hoverBorder:"hover:border-violet-500/50",hoverBg:"hover:bg-violet-500/[0.04]",chevronHover:"group-hover/prompt:text-violet-500"},Xt={accent:"text-emerald-500",stripe:"border-l-emerald-500/60",hoverBorder:"hover:border-emerald-500/50",hoverBg:"hover:bg-emerald-500/[0.04]",chevronHover:"group-hover/prompt:text-emerald-500"},la=[{label:"Ask",icon:qt,...Jt,prompts:["/ask what have I saved about AI?","/ask summarize my most recent bookmarks"]},{label:"Create",icon:Gt,...Yt,prompts:["/note draft a note from my recent saves","/space start a space for React"]},{label:"Find",icon:Ae,...Xt,prompts:["/find my notes on product design","/find articles about AI agents"]}];function ca(t,n){const i=n[0],m=t[0]?.name,x=[];i?x.push(`/ask what have I saved about ${i}?`):x.push("/ask what have I saved about AI?"),m?x.push(`/ask summarize my ${m} space`):x.push("/ask summarize my most recent bookmarks");const l=[];i?l.push(`/note draft a note about ${i}`):l.push("/note draft a note from my recent saves"),i?l.push(`/space start a space for ${i}`):l.push("/space start a space for React");const c=[];return m?c.push(`/find items in my ${m} space`):n[1]?c.push(`/find my notes on ${n[1]}`):c.push("/find my notes on product design"),i?c.push(`/find something I saved about ${i}`):c.push("/find articles about AI agents"),[{label:"Ask",icon:qt,...Jt,prompts:x},{label:"Create",icon:Gt,...Yt,prompts:l},{label:"Find",icon:Ae,...Xt,prompts:c}]}var da=({emptyPath:t="/",embedded:n=!1,belowHero:i,onHeroSubmit:m,onHeroChange:x}={})=>{const l=Je(),{input:c,setInput:p,messages:f,isLoading:d,isPro:u,attachedItems:w,showContextPicker:N,setShowContextPicker:R,attachedKeys:P,lastFailedQuery:K,showNewChatConfirm:E,setShowNewChatConfirm:S,savedConversations:D,inputRef:g,messagesEndRef:C,slashMenu:k,inputPlaceholder:I,handleSend:b,handleKeyDown:L,handleInputChange:q,handleAttachItem:W,handleRemoveAttachment:o,handleCancel:_,handleRetry:F,resetChat:ae,handleSaveAsNote:Q}=Vr({emptyPath:t}),me=Wt(s=>s.openPaywall),{hasTrialedBefore:ve}=Ot(),{data:Te}=Ft(1,10),{data:_e=[]}=nr(),{totalBookmarks:X,totalNotes:ne,totalSpaces:Z,totalSessions:ee}=Qt(),pe=na(),he=Te?.spaces??[],oe=he.length>0||_e.length>0,ke=X+ne+Z+ee,xe=ke>0,De=oe?ca(he,_e):la,fe=()=>{const s=c.trim();!s||d||m?.(s)||b()},Le=()=>{p(""),m?.(""),g.current?.focus()},we=s=>{u&&k.onKeyDown(s)||s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),fe())},se=(0,a.useCallback)(()=>{const s=g.current;s&&(s.focus({preventScroll:!0}),s.scrollIntoView({block:"center"}))},[g]);if((0,a.useEffect)(()=>{if(!n)return;const s=j=>{(j.metaKey||j.ctrlKey)&&j.key==="k"&&(j.preventDefault(),se())},B=j=>{const r=j.detail?.query?.trim()??"";r&&(p(r),m?.(r)),se()};return window.addEventListener("keydown",s),window.addEventListener("markwise:seed-search",B),window.addEventListener("markwise:focus-hero",se),()=>{window.removeEventListener("keydown",s),window.removeEventListener("markwise:seed-search",B),window.removeEventListener("markwise:focus-hero",se)}},[n,p,m,se]),f.length===0)return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:v(n?"relative px-0 pt-2 pb-2 sm:pt-5 sm:pb-4":"hero-vignette relative -mt-[72px] flex min-h-[calc(100dvh-48px)] flex-col items-center justify-center px-4 pt-[calc(72px+3rem)] pb-12 md:min-h-dvh landscape:min-h-dvh"),
16children:(0,e.jsxs)("div",{className:v("relative w-full",n?"mx-auto max-w-[1280px] space-y-3 px-4 sm:space-y-5 sm:px-6":"max-w-3xl space-y-6 sm:space-y-10"),children:[(0,e.jsxs)(Y.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,ease:[.16,1,.3,1]},className:v(n?"flex flex-col gap-3 text-left lg:flex-row lg:items-end lg:justify-between":"space-y-4 text-center"),children:[(0,e.jsxs)("div",{className:v(n?"space-y-2":"space-y-4"),children:[(0,e.jsxs)("p",{className:v("text-primary hidden items-center gap-1.5 text-sm font-medium sm:flex",n?"justify-start":"justify-center"),children:[(0,e.jsx)(Ie,{className:"h-3.5 w-3.5"}),Mt()]}),(0,e.jsx)("h1",{className:v("text-foreground font-heading leading-[1.1] font-bold tracking-tighter",n?"text-2xl sm:text-3xl lg:text-4xl":"text-3xl transition-opacity duration-300 sm:text-5xl",n||pe.visible?"opacity-100":"opacity-0"),children:n?"Ask your library anything.":pe.text})]}),xe?(0,e.jsxs)("div",{className:v("text-muted-foreground hidden flex-wrap items-center gap-x-2 gap-y-1 text-sm leading-relaxed sm:flex",n?"max-w-none justify-start lg:max-w-md lg:justify-end lg:text-right":"mx-auto max-w-lg justify-center"),children:[(0,e.jsx)("span",{children:"Grounded in"}),X>0&&(0,e.jsxs)("span",{className:"text-foreground inline-flex items-center gap-1 font-medium",children:[(0,e.jsx)(ue,{type:"bookmark",className:"h-3.5 w-3.5"}),X.toLocaleString()," bookmark",X===1?"":"s"]}),ne>0&&(0,e.jsxs)("span",{className:"text-foreground inline-flex items-center gap-1 font-medium",children:[(0,e.jsx)(ue,{type:"note",className:"h-3.5 w-3.5"}),ne.toLocaleString()," note",ne===1?"":"s"]}),Z>0&&(0,e.jsxs)("span",{className:"text-foreground inline-flex items-center gap-1 font-medium",children:[(0,e.jsx)(ue,{type:"space",className:"h-3.5 w-3.5"}),Z.toLocaleString()," space",Z===1?"":"s"]}),ee>0&&(0,e.jsxs)("span",{className:"text-foreground inline-flex items-center gap-1 font-medium",children:[(0,e.jsx)(ue,{type:"session",className:"h-3.5 w-3.5"}),ee.toLocaleString()," focus session",ee===1?"":"s"]})]}):(0,e.jsx)("p",{className:v("text-muted-foreground hidden text-sm leading-relaxed sm:block",n?"max-w-xl lg:max-w-sm lg:text-right":"mx-auto max-w-lg"),children:"Save bookmarks, notes, and pages — then ask Markwise anything about them."})]}),(0,e.jsxs)(Y.div,{initial:{opacity:0,y:16,scale:.98},animate:{opacity:1,y:0,scale:1},transition:{duration:.5,delay:.15,ease:[.16,1,.3,1]},className:v("relative w-full",n?"mx-0 max-w-none":"mx-auto max-w-2xl"),children:[u&&(0,e.jsx)(St,{...k,placement:"bottom"}),(0,e.jsxs)("div",{className:v("bg-card w-full overflow-hidden shadow-[0_8px_30px_-12px_rgba(0,0,0,0.12)] transition-[border-color,box-shadow] duration-300",n?"rounded-2xl":"rounded-[24px]","border-border/60 border-2","focus-within:border-primary/50 focus-within:ring-primary/10 focus-within:shadow-[0_8px_30px_-8px_rgb(var(--color-primary)/0.15)] focus-within:ring-4"),children:[u&&w.length>0&&(0,e.jsx)("div",{className:"border-border/30 border-b px-4 pt-3 pb-2",children:(0,e.jsx)(Ue,{items:w,onRemove:o})}),(0,e.jsxs)("div",{className:v("flex items-end gap-3",n?"p-3 sm:p-5":"p-4 sm:p-5"),children:[(0,e.jsxs)("div",{className:"relative flex-1",children:[(0,e.jsx)("textarea",{ref:g,value:c,onChange:s=>{q(s),x?.(s.target.value)},onKeyDown:we,placeholder:u?I:"Search your library, then press Enter…","aria-label":u?"Search your library, ask a question, or run a command":"Search your library",role:"combobox","aria-expanded":u&&k.open,"aria-autocomplete":"list","aria-controls":u&&k.open?k.menuId:void 0,"aria-activedescendant":u&&k.open?`${k.menuId}-opt-${k.selectedIdx}`:void 0,rows:1,enterKeyHint:"send",className:v("text-foreground placeholder:text-muted-foreground max-h-32 w-full resize-none bg-transparent px-1 font-medium tracking-tight outline-none",n?"min-h-[48px] py-2 text-base sm:min-h-[44px] sm:text-lg":"min-h-[52px] py-2.5 text-lg")}),u&&(0,e.jsx)(_t,{open:N,onOpenChange:R,onSelect:W,attachedKeys:P})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[c.trim().length>0&&(0,e.jsx)("button",{onClick:Le,className:"text-muted-foreground hover:text-foreground hover:bg-muted flex h-10 w-10 shrink-0 items-center justify-center rounded-xl transition-colors",title:"Clear","aria-label":"Clear input",children:(0,e.jsx)(Ce,{className:"h-4 w-4"})}),u&&(0,e.jsx)("button",{onClick:()=>R(!0),className:"text-muted-foreground hover:text-foreground hover:bg-muted flex h-10 w-10 shrink-0 items-center justify-center rounded-xl transition-colors",title:"Attach context (@ to search)","aria-label":"Attach context",children:(0,e.jsx)(gt,{className:"h-4 w-4"})}),(0,e.jsx)("button",{onClick:fe,disabled:!c.trim()||d,"aria-label":"Send message",className:v("bg-primary text-primary-foreground flex h-12 w-12 shrink-0 items-center justify-center rounded-2xl transition-all duration-200","shadow-[0_2px_0_0_rgba(0,0,0,0.15)] active:translate-y-[2px] active:shadow-none","hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-30 disabled:shadow-none"),children:d?(0,e.jsx)(Ht,{className:"h-5 w-5 animate-spin"}):(0,e.jsx)(qe,{className:"h-5 w-5"})})]})]}),(0,e.jsxs)("div",{className:v("border-border/20 flex flex-wrap items-center gap-x-1 gap-y-1 border-t px-3 py-2 text-[11px]",n?"justify-start sm:px-4":"justify-center"),children:[$t.filter(s=>s.skill==="find_anything"||s.skill==="ask_library").map(s=>{const B=s.icon;return(0,e.jsxs)("button",{type:"button",title:u?s.description:`${s.description} — Pro`,onClick:()=>
16{if(ns({skill:s.skill}),!u){me("copilot");return}p(j=>{const r=j.replace(/^\/\w+\s*/,"");return`${s.cmd} ${r}`.trimEnd()+(r?"":" ")}),g.current?.focus()},className:v("group/chip text-muted-foreground hover:text-foreground hover:bg-muted relative inline-flex min-h-9 items-center gap-1.5 rounded-md px-2.5 py-1.5 transition-colors"),children:[(0,e.jsx)(B,{className:"group-hover/chip:text-foreground h-3.5 w-3.5 transition-colors"}),(0,e.jsx)("span",{className:"font-medium",children:s.label}),(0,e.jsx)("span",{className:"text-muted-foreground font-mono text-[10px]",children:s.cmd})]},s.cmd)}),(0,e.jsxs)("span",{className:"inline-flex items-center gap-x-1",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"·"}),u?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("span",{className:"text-muted-foreground",children:[(0,e.jsx)("kbd",{className:"bg-muted rounded px-1 py-0.5 font-mono text-[10px]",children:"@"})," attach"]}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:[(0,e.jsx)("kbd",{className:"bg-muted rounded px-1 py-0.5 font-mono text-[10px]",children:"↵"})," send"]})]}):(0,e.jsx)("button",{type:"button",onClick:()=>me("copilot"),className:"text-primary font-medium hover:underline",children:ve?"Upgrade to Pro for Ask & commands":`Ask & commands are Pro — try it for ${Fs}`})]})]})]})]}),u&&!n&&(0,e.jsx)("div",{className:"mx-auto hidden w-full max-w-2xl gap-5 sm:grid sm:grid-cols-3",children:De.map((s,B)=>{const j=s.icon;return(0,e.jsxs)(Y.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4,delay:.3+B*.08,ease:[.16,1,.3,1]},className:"space-y-2.5",children:[(0,e.jsxs)("div",{className:v("flex items-center gap-1.5 text-[10px] font-bold tracking-[0.15em] uppercase",s.accent),children:[(0,e.jsx)(j,{className:"h-3 w-3"}),s.label]}),s.prompts.map((r,y)=>(0,e.jsxs)("button",{onClick:()=>{gs({category:s.label,position:y}),b(r)},className:v("group/prompt bg-card/80 border-border/60 flex w-full items-center gap-2 rounded-xl border border-l-[3px] px-3.5 py-3 text-left text-sm font-medium shadow-[0_1px_2px_rgba(0,0,0,0.03)] transition-all duration-200","hover:-translate-y-[1px] hover:shadow-[0_4px_12px_-6px_rgba(0,0,0,0.08)] active:translate-y-0 active:scale-[0.98]",s.stripe,s.hoverBorder,s.hoverBg),children:[(0,e.jsx)("span",{className:"flex-1 leading-snug",children:r}),(0,e.jsx)(He,{className:v("text-muted-foreground h-3.5 w-3.5 shrink-0 transition-colors",s.chevronHover)})]},r))]},s.label)})}),D.length>0&&u&&!n&&(0,e.jsxs)(Y.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.4,delay:.45},className:"hidden space-y-3 sm:block",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between px-1",children:[(0,e.jsxs)("h3",{className:"text-muted-foreground text-[10px] font-semibold tracking-wider uppercase",children:[(0,e.jsx)(zt,{className:"mr-1 inline h-2.5 w-2.5 -translate-y-px"}),"Recent"]}),D.length>4&&(0,e.jsxs)("button",{type:"button",onClick:()=>l("/ask/history"),className:"text-muted-foreground hover:text-foreground text-[11px] transition-colors",children:["View all ",D.length," →"]})]}),(0,e.jsx)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:D.slice(0,4).map((s,B)=>{const j=new Date(s.updated_at).getTime(),r=s.message_count??s.messages?.length??0;return(0,e.jsxs)("button",{type:"button",onClick:()=>{ls({position:B,age_days:Number.isFinite(j)?Math.max(0,Math.floor((Date.now()-j)/864e5)):0}),l(`/chat/${s.id}`,{replace:!0})},className:v("bg-card/60 border-border/40 hover:border-border hover:bg-card group relative flex flex-col gap-1 overflow-hidden rounded-xl border px-3 py-2.5 text-left transition-colors"),children:[(0,e.jsx)("div",{className:"text-foreground line-clamp-1 text-[13px] font-medium tracking-tight",children:s.title||"Untitled chat"}),(0,e.jsxs)("div",{className:"text-muted-foreground flex items-center gap-1.5 text-[10px]",children:[(0,e.jsx)("span",{children:Number.isFinite(j)?bt(j):""}),r>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"·"}),(0,e.jsxs)("span",{children:[r," message",r!==1?"s":""]})]})]})]},s.id)})})]})]})}),n&&i]});const $e=f[f.length-1],Ze=ia($e?.role==="user"?kt($e):void 0);return(0,e.jsxs)("div",{className:"flex min-h-[calc(100dvh-72px)] flex-col",children:[(0,e.jsx)("div",{className:"flex-1",children:(0,e.jsxs)("div",{className:"mx-auto max-w-3xl space-y-4 px-4 py-6",children:[(0,e.jsxs)("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-1.5 gap-y-1 text-[11px]",children:[(0,e.jsxs)(Se,{href:"/",className:"hover:text-foreground inline-flex items-center gap-1 transition-colors",children:[(0,e.jsx)(Ie,{className:"h-3 w-3"}),"Library"]}),(0,e.jsx)(He,{className:"text-muted-foreground h-3 w-3"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:"Conversation"}),xe&&(0,e.jsxs)("span",{className:"border-border/50 text-muted-foreground ml-1 inline-flex items-center gap-1 rounded-full border px-2 py-0.5",children:[(0,e.jsx)(Ee,{className:"h-2.5 w-2.5"}
16),"Grounded in ",ke.toLocaleString()," item",ke===1?"":"s"]})]}),f.map((s,B)=>(0,e.jsxs)(Y.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.25,ease:[.16,1,.3,1]},className:v("group/msg flex flex-col",s.role==="user"?"items-end":"items-start"),children:[(0,e.jsxs)("div",{className:v("rounded-[18px] text-sm",Oe(s)?"w-full":v("px-4 py-3",s.role==="user"?"bg-foreground text-background max-w-[85%] rounded-br-md sm:max-w-[80%]":"bg-card border-border text-foreground w-full rounded-bl-md border shadow-sm")),children:[(()=>{if(s.role!=="assistant"){const y=kt(s);return(0,e.jsxs)("div",{children:[y&&(0,e.jsx)("span",{className:"bg-background/20 mb-1.5 inline-block rounded px-1.5 py-0.5 text-[10px] font-medium tracking-wider uppercase opacity-70",children:Qs[y]||y}),(0,e.jsx)("p",{className:"leading-relaxed",children:jt(s)}),s.attachedItems&&s.attachedItems.length>0&&(0,e.jsx)("div",{className:"-mx-1 mt-2",children:(0,e.jsx)(Ue,{items:s.attachedItems})})]})}if(Oe(s))return!s.sources||s.sources.length===0?(0,e.jsx)("div",{className:"bg-card border-border/60 text-muted-foreground rounded-xl border px-4 py-3 text-sm shadow-sm",children:s.content}):(0,e.jsx)(a.Suspense,{fallback:(0,e.jsx)("div",{className:"text-muted-foreground bg-card border-border/60 rounded-xl border px-4 py-3 text-sm shadow-sm",children:s.content}),children:(0,e.jsx)(ra,{sources:s.sources})});const{body:j}=Ge(s.content),r=Ne(s.content,s.sources);return(0,e.jsxs)(e.Fragment,{children:[r&&r.length>0&&(0,e.jsxs)("div",{className:"swiss-label mb-1.5",children:["Answer · grounded in ",r.length," source",r.length!==1?"s":""]}),(0,e.jsx)(a.Suspense,{fallback:(0,e.jsx)(oa,{content:j}),children:(0,e.jsx)(sa,{content:j,sources:s.sources})}
16),s.streaming&&(0,e.jsx)("span",{className:"bg-foreground/70 ml-0.5 inline-block h-3.5 w-[2px] translate-y-0.5 animate-pulse rounded-full align-middle","aria-hidden":"true"})]})})(),s.webFetched&&(0,e.jsxs)("div",{className:"bg-primary/10 text-primary mt-2 flex items-center gap-1.5 rounded-md px-2 py-1",children:[(0,e.jsx)(Rs,{className:"h-3 w-3"}),(0,e.jsx)("span",{className:"text-[10px] font-medium",children:"Fetched live content from the web"})]}),(()=>{if(Oe(s))return null;const j=Ne(s.content,s.sources);return!j||j.length===0?null:(0,e.jsxs)("div",{className:"mt-3 border-t border-current/10 pt-2",children:[(0,e.jsx)("p",{className:"text-muted-foreground text-[10px] font-bold tracking-[0.15em] uppercase",children:"Sources"}),(0,e.jsx)("div",{className:"mt-1.5 space-y-1",children:j.map(r=>{const y=Us(r),M=y.startsWith("http"),T=Ys(r);return(0,e.jsxs)("div",{className:"bg-background/30 hover:bg-background/60 flex items-center gap-1 rounded-lg pr-1 transition-colors",children:[(0,e.jsxs)(Se,{href:y,onClick:()=>dt({source_type:r.type,is_external:M}),className:"flex min-w-0 flex-1 items-center gap-2 px-2.5 py-2 text-xs",children:[(0,e.jsx)(ue,{type:r.type,url:r.url,contentType:r.content_type,className:"h-3.5 w-3.5 shrink-0"}),(0,e.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:r.title})]}),T&&(0,e.jsx)(Se,{href:T,external:!0,"aria-label":`Open the original page for ${r.title}`,title:"Open original",onClick:()=>dt({source_type:r.type,is_external:!0}),className:"hover:bg-background/80 shrink-0 rounded-md p-1.5 opacity-40 transition-opacity hover:opacity-80",children:(0,e.jsx)(Es,{className:"h-3 w-3"})})]},`${r.type}-${r.id}`)})})]})})()]}),s.actions&&s.actions.length>0&&(0,e.jsx)("div",{className:"mt-1.5 w-full space-y-1 overflow-hidden rounded-lg",children:s.actions.map((j,r)=>(0,e.jsx)(ea,{action:j},`${j.type}-${r}`))}),s.role==="assistant"&&!s.streaming&&(()=>{const j=s.isError||s.content.startsWith("I couldn't process that request.");return(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground px-1 text-[10px]",children:bt(s.timestamp)}),j?B===f.length-1&&K?(0,e.jsx)("button",{onClick:F,className:"text-primary hover:bg-primary/10 rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors",children:"Retry"}):(0,e.jsx)("span",{className:"text-muted-foreground/40 cursor-not-allowed rounded-md px-2 py-0.5 text-[11px] font-medium","aria-disabled":"true",children:"Retry"}):(0,e.jsx)(aa,{content:s.content,question:f[B-1]?.role==="user"?jt(f[B-1]):void 0,sources:s.sources,attachedItems:f[B-1]?.role==="user"?f[B-1]?.attachedItems:void 0,onSaveNote:Q})]})})(),s.role==="assistant"&&!s.streaming&&(()=>{const{followUps:j}=Ge(s.content);return j.length===0?null:(0,e.jsx)(rr,{items:j,onPick:r=>{ds(),b(r)}})})()]},Gs(s,B))),d&&!(f[f.length-1]?.role==="assistant"&&f[f.length-1]?.streaming)&&(0,e.jsxs)(Y.div,{initial:{opacity:0}
16,animate:{opacity:1},className:"flex items-center gap-2",role:"status","aria-live":"polite",children:[(0,e.jsxs)("div",{className:"bg-card border-border text-muted-foreground flex min-h-[44px] items-center gap-3 rounded-[18px] rounded-bl-md border px-4 py-3 text-sm shadow-sm",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5","aria-hidden":"true",children:[(0,e.jsx)("div",{className:"bg-muted-foreground/30 h-1.5 w-1.5 animate-bounce rounded-full [animation-delay:0ms]"}),(0,e.jsx)("div",{className:"bg-muted-foreground/30 h-1.5 w-1.5 animate-bounce rounded-full [animation-delay:150ms]"}),(0,e.jsx)("div",{className:"bg-muted-foreground/30 h-1.5 w-1.5 animate-bounce rounded-full [animation-delay:300ms]"})]}),(0,e.jsx)("span",{children:Ze})]}),(0,e.jsx)("button",{onClick:_,className:"text-muted-foreground hover:text-foreground hover:bg-muted flex min-h-[44px] items-center rounded-lg px-2 py-1 text-xs font-medium transition-colors",children:"Stop"})]}),(0,e.jsx)("div",{ref:C,className:"h-6 scroll-mb-28"})]})}),(0,e.jsxs)("div",{className:"border-border bg-background/80 supports-[backdrop-filter]:bg-background/60 sticky bottom-0 z-20 border-t backdrop-blur-xl",children:[w.length>0&&(0,e.jsx)("div",{className:"mx-auto max-w-3xl px-4 pt-2",children:(0,e.jsx)(Ue,{items:w,onRemove:o})}),(0,e.jsx)("div",{className:"mx-auto flex max-w-3xl items-end gap-2 px-4 py-3",children:(0,e.jsxs)("div",{className:"bg-card border-border relative flex min-h-[48px] flex-1 items-end rounded-[16px] border px-3 py-2 shadow-sm",children:[(0,e.jsx)("button",{onClick:()=>R(!0),className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring relative mr-1 mb-0.5 flex min-h-[44px] min-w-[44px] shrink-0 items-center justify-center rounded-md transition-colors after:absolute after:-inset-2 after:content-[''] focus-visible:ring-1 focus-visible:outline-none sm:h-7 sm:min-h-[28px] sm:w-7 sm:min-w-[28px]",title:"Attach context (@)","aria-label":"Attach context",children:(0,e.jsx)(gt,{className:"h-3.5 w-3.5"})}),(0,e.jsx)("textarea",{ref:g,value:c,onChange:q,onKeyDown:L,placeholder:w.length>0?"Ask about the attached items...":"Ask a follow-up...",role:"combobox","aria-expanded":k.open,"aria-autocomplete":"list","aria-controls":k.open?k.menuId:void 0,"aria-activedescendant":k.open?`${k.menuId}-opt-${k.selectedIdx}`:void 0,"aria-label":"Ask a follow-up or command",rows:1,enterKeyHint:"send",className:"text-foreground placeholder:text-muted-foreground max-h-32 min-h-[28px] flex-1 resize-none bg-transparent text-base font-medium outline-none sm:text-sm",disabled:d}),d?(0,e.jsx)("button",{onClick:_,className:v("bg-foreground text-background flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-all","active:scale-95"),"aria-label":"Stop generating",children:(0,e.jsx)(Ps,{className:"h-3 w-3 fill-current"})}):(0,e.jsx)("button",{onClick:()=>b(),disabled:!c.trim(),"aria-label":"Send message",className:v("bg-primary text-primary-foreground flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-all","border-b-[2px] border-black/20 active:translate-y-[1px] active:border-b-0","disabled:cursor-not-allowed disabled:opacity-30"),children:(0,e.jsx)(qe,{className:"h-3.5 w-3.5"})}),(0,e.jsx)(_t,{open:N,onOpenChange:R,onSelect:W,attachedKeys:P}),(0,e.jsx)(St,{...k})]})}),(0,e.jsx)("div",{className:"mx-auto max-w-3xl px-4 pb-1"})]}),(0,e.jsx)(Nr,{open:E,onOpenChange:S,children:(0,e.jsxs)(fr,{children:[(0,e.jsxs)(br,{children:[(0,e.jsx)(Er,{children:"Start new conversation?"}),(0,e.jsx)(Ir,{children:"This will clear the current conversation. Your previous messages are saved in history."})]}),(0,e.jsxs)(Rr,{children:[(0,e.jsx)(kr,{children:"Cancel"}),(0,e.jsx)(jr,{onClick:ae,children:"New chat"})]})]})})]})},Be="mw_onboarding_checklist",At="mw_onboarding_checklist_dismissed",Et="https://chromewebstore.google.com/detail/markwise-save-organize-fi/ofigpmieafknbjjjbghngdlijcinbmja",Rt=5;function Tt({bookmarkCount:t=0,spaceCount:n=0,contentCount:i,variant:m="compact",className:x}){const l=Je(),c=mt(o=>o.setSpaceCreatorOpen),p=mt(o=>o.setBookmarkCreatorOpen),{hasAccess:f}=Ot(),[d,u]=(0,a.useState)({}),[w,N]=(0,a.useState)(!1),[R,P]=(0,a.useState)(!0),K=m==="welcome",E=(i??t+n)>0,S=(0,a.useMemo)(()=>
16{if(!E)return[{id:"import",title:"Import your bookmarks",description:"Bring your Pocket, Chrome, or Safari export, then search across it instantly",icon:(0,e.jsx)(ft,{className:"h-5 w-5"}),primary:!0,cta:{label:"Import bookmarks",action:"navigate",target:"/import"}},{id:"first_bookmark",title:"Or save a single link",description:"Paste a URL and Markwise files it for you",icon:(0,e.jsx)(Bt,{className:"h-5 w-5"}),cta:{label:"Add Bookmark",action:"open_bookmark_creator"}},{id:"extension",title:"Install the browser extension",description:"Save any page in one click from any website",icon:(0,e.jsx)(Nt,{className:"h-5 w-5"}),cta:{label:"Install",action:"link",target:Et}}];const o=[];return t<=Rt&&o.push({id:"import",title:"Import your bookmarks",description:"Bring your Pocket, Chrome, or Safari library so search and ask have plenty to work with",icon:(0,e.jsx)(ft,{className:"h-5 w-5"}),primary:!0,cta:{label:"Import bookmarks",action:"navigate",target:"/import"}}),o.push({id:"extension",title:"Install browser extension",description:"Save any page with one click from any website",icon:(0,e.jsx)(Nt,{className:"h-5 w-5"}),cta:{label:"Install",action:"link",target:Et}}),t>0&&o.push({id:"create_space",title:"Create a knowledge space",description:"Group related bookmarks into a space for focused research",icon:(0,e.jsx)(Ee,{className:"h-5 w-5"}),cta:{label:"Create",action:"open_space_creator"}}),o.push({id:"semantic_search",title:"Try semantic search",description:"Search by meaning, not just keywords - find what you're looking for",icon:(0,e.jsx)(Ae,{className:"h-5 w-5"}),cta:{label:"Search",action:"focus"}}),f&&o.push({id:"digest",title:"Enable Weekly Digest",description:"Get AI-curated summaries of your bookmarks in your inbox",icon:(0,e.jsx)($s,{className:"h-5 w-5"}),cta:{label:"Set Up",action:"navigate",target:"/digest"}}),o},[f,t,E]);(0,a.useEffect)(()=>{(()=>{try{if(localStorage.getItem(At)==="true"){N(!0),P(!1);return}const _=localStorage.getItem(Be);if(_)try{const F=JSON.parse(_);F&&typeof F=="object"&&!Array.isArray(F)&&u(F)}catch{localStorage.removeItem(Be)}N(!1)}catch{N(!1)}P(!1)})()},[]);const D=(0,a.useCallback)(o=>{try{localStorage.setItem(Be,JSON.stringify(o))}catch{}},[]),g=(0,a.useCallback)(o=>{u(_=>{if(_[o])return _;const F={..._,[o]:!0};return D(F),xs(o),F})},[D]);(0,a.useEffect)(()=>{t>0&&!d.first_bookmark&&g("first_bookmark")},[t,d.first_bookmark,g]),(0,a.useEffect)(()=>{n>0&&!d.create_space&&g("create_space")},[n,d.create_space,g]);const C=(0,a.useCallback)(o=>{switch(ps(o.id),o.cta.action){case"navigate":o.cta.target&&(l(o.cta.target),g(o.id));break;case"link":o.cta.target&&(window.open(o.cta.target,"_blank","noopener,noreferrer"),g(o.id));break;case"focus":window.dispatchEvent(new CustomEvent("markwise:seed-search")),g(o.id);break;case"open_bookmark_creator":p(!0);break;case"open_space_creator":c(!0);break}},[l,g,c,p]),k=(0,a.useCallback)(o=>{const _=o.currentTarget.dataset.itemId,F=S.find(ae=>ae.id===_);F&&C(F)},[S,C]),I=(0,a.useCallback)(o=>{const _=o.currentTarget.dataset.itemId,F=S.find(ae=>ae.id===_);F&&C(F)},[S,C]),b=()=>{localStorage.setItem(At,"true"),N(!0),fs()},L=S.length,q=S.filter(o=>d[o.id]).length,W=L>0?Math.round(q/L*100):0;return K?(0,e.jsx)("div",{className:v("relative px-4 pt-10 pb-16 sm:pt-16",x),children:(0,e.jsxs)("div",{className:"mx-auto w-full max-w-2xl space-y-10",children:[(0,e.jsxs)(Y.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.5,ease:[.16,1,.3,1]},className:"space-y-3 text-center",children:[(0,e.jsxs)("p",{className:"text-primary/70 flex items-center justify-center gap-1.5 text-sm font-medium",children:[(0,e.jsx)(Ie,{className:"h-3.5 w-3.5"}),Mt()]}),(0,e.jsx)("h1",{className:"text-foreground font-heading text-3xl leading-[1.1] font-bold tracking-tighter sm:text-4xl",children:"Welcome to Markwise"}),(0,e.jsx)("p",{className:"text-muted-foreground mx-auto max-w-md text-base leading-relaxed",children:"Save or import your first bookmark. Then search and ask across everything you keep."})]}),(0,e.jsx)(Y.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.5,delay:.1,ease:[.16,1,.3,1]},className:"space-y-3",children:S.map(o=>{const _=d[o.id];return(0,e.jsxs)("button",{"data-item-id":o.id,onClick:I,className:v("group flex w-full items-center gap-4 roun
16ded-2xl border p-4 text-left transition-all duration-200",o.primary?"border-primary/30 bg-primary/5 hover:border-primary/50 hover:bg-primary/10":"border-border bg-card hover:border-border hover:bg-muted/40"),children:[(0,e.jsx)("div",{className:v("flex h-11 w-11 shrink-0 items-center justify-center rounded-xl",o.primary?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:_?(0,e.jsx)(ye,{className:"h-5 w-5"}):o.icon}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("p",{className:v("text-foreground text-sm font-semibold",_&&"line-through"),children:o.title}),(0,e.jsx)("p",{className:"text-muted-foreground text-xs",children:o.description})]}),(0,e.jsx)(qe,{className:"text-muted-foreground group-hover:text-foreground h-4 w-4 shrink-0 transition-all duration-200 group-hover:translate-x-0.5"})]},o.id)})}),(0,e.jsxs)(Y.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.5,delay:.25},className:"border-border/60 border-t pt-8",children:[(0,e.jsx)("p",{className:"text-muted-foreground mb-4 text-center text-[10px] font-bold tracking-[0.15em] uppercase",children:"Once your library has something in it"}),(0,e.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[{icon:Ae,label:"Search",desc:"Find anything by meaning"},{icon:Ie,label:"Ask",desc:"Answers grounded in your saves"},{icon:Ee,label:"Create",desc:"Turn saves into notes & spaces"}].map(o=>{const _=o.icon;return(0,e.jsxs)("div",{className:"bg-card/60 border-border/40 rounded-xl border p-4 text-center",children:[(0,e.jsx)(_,{className:"text-primary/60 mx-auto mb-2 h-5 w-5"}),(0,e.jsx)("p",{className:"text-foreground text-sm font-semibold",children:o.label}),(0,e.jsx)("p",{className:"text-muted-foreground mt-0.5 text-xs",children:o.desc})]},o.label)})})]})]})}):R||w||q===L||t>Rt?null:(0,e.jsx)(Lt,{children:(0,e.jsx)(Y.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.3},className:v("w-full",x),children:(0,e.jsxs)(wr,{className:"border-primary/10 from-background to-primary/5 bg-gradient-to-br",children:[(0,e.jsxs)(Tr,{className:"pb-3",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)(yr,{className:"text-lg font-semibold",children:"Getting Started"}),(0,e.jsx)("p",{className:"text-muted-foreground text-sm",children:"Complete these steps to get the most out of Markwise"})]}),(0,e.jsx)(Ct,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:b,"aria-label":"Dismiss checklist",children:(0,e.jsx)(Ce,{className:"h-4 w-4"})})]}),(0,e.jsxs)("div",{className:"mt-3 space-y-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:q===0?`${L} steps to go`:`${q} of ${L} complete`}),(0,e.jsxs)("span",{className:"text-foreground font-medium",children:[W,"%"]})]}),(0,e.jsx)(Fr,{value:W,"aria-label":"Onboarding progress","aria-valuetext":`${W}% complete`,className:"h-2"})]})]}),(0,e.jsx)(gr,{className:"pt-0",children:(0,e.jsx)("div",{className:"space-y-2",children:S.map(o=>{const _=d[o.id];return(0,e.jsxs)(Y.div,{initial:!1,animate:{opacity:_?.6:1},className:v("hover:bg-muted/50 group flex items-center gap-3 rounded-lg border p-3 transition-colors",_?"border-primary/20 bg-primary/5":o.id==="extension"&&t>0&&!d.extension?"border-primary/40 bg-primary/5":"border-border"),children:[(0,e.jsx)("div",{className:v("flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-colors",_?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:_?(0,e.jsx)(ye,{className:"h-4 w-4"}):o.icon}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("p",{className:v("text-sm font-medium",_&&"line-through"),children:o.title}),(0,e.jsx)("p",{className:"text-muted-foreground truncate text-xs",children:o.description})]}),!_&&(0,e.jsxs)(Ct,{variant:"ghost",size:"sm",className:"shrink-0","data-item-id":o.id,onClick:k,children:[o.cta.label,(0,e.jsx)(He,{className:"ml-1 h-3 w-3"})]})]},o.id)})})})]})})})}var ua={background:"var(--surface)",borderRadius:16,border:"1px solid rgb(var(--color-border) / 0.6)"};function ma({item:t}){return t.target_type==="note"?(0,e.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-[10px]",style:{background:Zs("note",.16),color:er("note")},children:(0,e.jsx)(je,{className:"h-[18px] w-[18px]"})}):(0,e.jsx)(sr,{source:tr(t.target_url),size:36,radius:10})}var pa={primary:"text-[color:var(--primary)] border-[rgb(var(--color-primary)/0.35)] hover:bg-[rgb(var(--color-primary)/0.08)]",neutral:"text-muted-foreground border-[rgb(var(--color-border))] hover:bg-[rgb(var(--color-bg-muted))] hover:text-foreground",danger:"text-[color:rgb(var(--color-danger))] border-[rgb(var(--color-danger)/0.3)] hover:bg-[rgb(var(--color-danger)/0.1)]"};function Dt({Icon:t,label:n,tone:i,disabled:m,onClick:x}){return(0,e.jsxs)("button",{type:"button",disabled:m,onClick:x,className:`inline-flex touch-manipulation items-center gap-1.5 rounded-lg border bg-transparent px-3 py-1.5 text-[12.5px] font-semibold transition-all duration-150 active:scale-95 disabled:opacity-50 motion-reduce:transition-none ${pa[i]}`,children:[(0,e.jsx)(t,{className:"h-3.5 w-3.5 shrink-0"}),n]})}var ha=[{action:"act",label:"To-Do",Icon:Ms,tone:"primary"},{action:"keep",label:"Keep",Icon:Ds,tone:"neutral"},{action:"let_go",label:"Let go",Icon:Ls,tone:"danger"}];
16function xa({item:t,index:n,onOpen:i,onDismiss:m,onTriage:x,busy:l}){const c=t.target_type==="note",p=c?We("note"):We("bookmark"),f=c?`/notes/${t.target_id}/edit`:`/bookmarks/${t.target_id}`,[d,u]=(0,a.useState)(!1),w=N=>{u(!0),N()};return(0,e.jsxs)("div",{className:`mwds-rise group relative flex flex-col gap-2 py-3 pr-3 pl-4 transition-[opacity,transform,background] duration-200 ease-out hover:bg-[rgb(var(--color-bg-muted)/0.4)] motion-reduce:transition-none ${d?"pointer-events-none -translate-x-3 opacity-0":"opacity-100"}`,style:{animationDelay:`${n*45}ms`},children:[(0,e.jsx)("span",{"aria-hidden":!0,className:"absolute inset-y-2.5 left-0 w-[3px] rounded-full opacity-50 transition-all duration-200 ease-out group-hover:inset-y-1.5 group-hover:opacity-100",style:{background:p}}),(0,e.jsxs)(_s,{to:f,onClick:i,className:"flex min-w-0 items-center gap-3",children:[(0,e.jsx)("span",{className:"transition-transform duration-200 ease-out group-hover:scale-[1.07]",children:(0,e.jsx)(ma,{item:t})}),(0,e.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,e.jsx)("span",{className:"text-foreground block truncate text-sm font-semibold transition-colors duration-150 group-hover:text-[color:var(--primary)]",children:t.target_title||"(untitled)"}),(0,e.jsxs)("span",{className:"text-muted-foreground mt-0.5 flex items-center gap-1 text-xs",children:[(0,e.jsx)(zt,{className:"h-3 w-3 shrink-0 opacity-70"}),(0,e.jsx)("span",{className:"truncate",children:t.reason})]})]})]}),(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-1.5 pl-12",children:c?(0,e.jsx)(Dt,{Icon:Ce,label:"Dismiss",tone:"neutral",disabled:l,onClick:()=>w(m)}):ha.map(({action:N,label:R,Icon:P,tone:K})=>(0,e.jsx)(Dt,{Icon:P,label:R,tone:K,disabled:l,onClick:()=>w(()=>x(N))},N))})]})}function fa(){const{data:t=[],isLoading:n}=Ur(),i=Br(),m=Kr(),x=Or();return n||t.length===0?null:(0,e.jsxs)("section",{className:"mwds-rise mb-6 overflow-hidden",style:ua,children:[(0,e.jsxs)("header",{className:"group/header flex items-center gap-2.5 px-4 pt-4 pb-3",children:[(0,e.jsx)("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg",style:{background:"rgb(var(--color-primary) / 0.12)",color:"var(--primary)"},children:(0,e.jsx)(Ts,{className:"h-[15px] w-[15px] transition-transform duration-500 ease-out group-hover/header:rotate-180"})}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("h2",{className:"text-sm leading-tight font-bold",children:"Worth revisiting"}),(0,e.jsx)("p",{className:"text-muted-foreground text-[11px] leading-tight",children:"Decide what to do with each save"})]}),(0,e.jsx)("span",{className:"ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs font-semibold tabular-nums",style:{background:"rgb(var(--color-primary) / 0.1)",color:"var(--primary)"},children:t.length})]}),(0,e.jsx)("div",{className:"divide-border/50 divide-y",children:t.map((l,c)=>(0,e.jsx)(xa,{item:l,index:c,onOpen:()=>m.mutate(l.id),onDismiss:()=>i.mutate(l.id),onTriage:p=>x.mutate({queueId:l.id,bookmarkId:l.target_id,action:p}),busy:i.isPending||x.isPending},l.id))})]})}var ga=(0,a.lazy)(()=>Ve(()=>import("./FeedPage-D_y8_Fe9.js"),__vite__mapDeps([47,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,48,49,50,45,46,51,52,53,54,55,56,57,58,59,60,61]))),Qe="mx-auto w-full max-w-[1280px] px-4 sm:px-6";function ba(){return(0,e.jsx)("div",{className:Qe,children:(0,e.jsx)("div",{className:"bg-card divide-border/40 divide-y rounded-xl border",children:Array.from({length:6}).map((t,n)=>(0,e.jsx)("div",{className:"h-16 animate-pulse"},n))})})}var Ha=()=>{const{chatId:t}=Kt(),n=!!t,{performSearch:i,resetSearch:m}=pr(),x=ht(g=>g.setSearchQuery),l=ht(g=>g.clearSearch),{totalBookmarks:c,totalNotes:p,totalSpaces:f,totalSessions:d,isLoading:u}=Qt(),w=c+p+f+d,N=w>0,[R]=(0,a.useState)(()=>{const g=ws();return g.isRecent&&g.seeded}),{hasAccess:P}=Pt(),K=Wt(g=>g.openPaywall),E=(0,a.useCallback)(g=>{const C=Fe(g);if(C.lane==="search"){const k=C.query.trim();return x(k),k.length>=2?i(k):(l(),m()),!0}return!P&&Vt()<=0?(K("copilot"),!0):!1},[i,m,x,l,P,K]),S=(0,a.useRef)(void 0),D=(0,a.useCallback)(g=>{if(S.current&&clearTimeout(S.current),Fe(g).lane!=="search"){l(),m();return}S.current=setTimeout(()=>{const C=Fe(g).query.trim();x(C),C.length>=2?i(C):(l(),m())},300)},[i,m,x,l]);return!n&&!u&&!N&&!R?(0,e.jsx)(Tt,{variant:"welcome",bookmarkCount:c,spaceCount:f,contentCount:w}):(0,e.jsx)(da,{emptyPath:"/",embedded:!0,onHeroSubmit:E,onHeroChange:D,belowHero:(0,e.jsxs)("div",{className:"space-y-4",children:[N&&(0,e.jsx)("div",{className:Qe,children:(0,e.jsx)(fa,{})}),N&&(0,e.jsx)("div",{className:Qe,children:(0,e.jsx)(Tt,{bookmarkCount:c,spaceCount:f,contentCount:w})}),(0,e.jsx)(a.Suspense,{fallback:(0,e.jsx)(ba,{}),children:(0,e.jsx)(ga,{embedded:!0,hideSearchBar:!0})})]})})};export{Ha 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.