PageSourceSearch

https://notestream.ai/assets/Review-ObvBkDXK.js

js notestream.ai collected 2026-10-05 15:41:10 UTC 102,065 bytes, 5 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/VoiceModeOverlay-B2n5mojn.js","assets/index-Rw18IswJ.js","assets/index-BxFU0TJL.css","assets/CancelAiAssignmentButton-4I0XEtT9.js","assets/dropdown-menu-CMxghC7m.js","assets/index-BrIACS_p.js","assets/aiModels-CtfrdmbG.js","assets/useExtensionStatus-BudrPiyI.js","assets/MarkdownRenderer-Br0gxIKK.js","assets/attachmentUrls-ETIfuc5H.js","assets/sanitize-DyEsnR90.js","assets/ReviseTaskModal-NDjtsJu3.js","assets/RichTextEditor-BOgpvz8q.js","assets/toggle-BD1NM9pG.js","assets/index-jtQY2-DT.js","assets/separator-DqghkYDP.js","assets/popover-RFQ7SI4m.js","assets/uploadAttachments-Vkw1Fm2D.js"])))=>i.map(i=>d[i]);
2import{r as u,i as T,j as e,B as E,ak as yn,bI as ht,X as Wt,D as At,l as Et,m as Ot,o as Pt,L as De,k as _,al as $s,ag as Ms,cn as Fs,co as Ls,c0 as bn,aD as zs,a0 as rn,cg as N,bv as Us,bq as Bs,br as qs,bs as Hs,bw as Vs,bx as Ws,I as at,a8 as Ys,aC as Be,T as Vn,aG as Xs,aH as Ks,aI as Gs,aJ as Zs,aK as Qs,aP as Wn,N as nt,aa as Yn,e as Js,p as ea,ab as ta,ac as on,ae as st,af as ln,v as na,bX as cn,c as sa,d as aa,bL as ra,cc as _n,cf as ia,cp as Yt,bT as oa,bU as la,aA as ca,cq as da,aS as pt,cr as jn,R as Xt,V as tt,K as ua,bN as Kt,cs as ma,a9 as kn,ct as fa,cu as Nn,cv as Sn,cw as Cn,cx as ha,aj as pa,aU as Tn,aQ as xa,aR as ga,ai as In,t as wa,cy as va,aW as Rn,bW as Gt,cz as ya,aT as Zt,as as ba,aw as _a,f as ja,a7 as Xn}from"./index-Rw18IswJ.js";import{C as Dt}from"./checkbox-SysNFlAx.js";import{u as ka,P as Na}from"./useCustomStatuses-nrxsc_3i.js";import{P as Kn,a as Gn,b as Zn}from"./popover-RFQ7SI4m.js";import{a as Sa,s as Ca,c as Ta,b as Ia}from"./attachmentUrls-ETIfuc5H.js";import{M as Dn}from"./MarkdownRenderer-Br0gxIKK.js";import{a as Qt}from"./aiModels-CtfrdmbG.js";import{t as dn,a as Ra,l as Jt,A as Qn,b as Da,s as Aa,d as Ea,u as Oa,S as An,C as En}from"./CancelAiAssignmentButton-4I0XEtT9.js";import{d as Pa}from"./dedupeAttachments-Dk_0NPkf.js";import{R as $a}from"./ReminderDialog-DI--jTTJ.js";import{i as Ma,p as Fa,R as La}from"./RichTextEditor-BOgpvz8q.js";import{s as za}from"./sanitize-DyEsnR90.js";const Ue={image:["image/jpeg","image/png","image/gif","image/webp","image/svg+xml"],pdf:["application/pdf"],text:["text/plain","text/markdown","text/csv","text/html","text/css","text/javascript"],code:["application/json","application/xml","application/javascript"],video:["video/mp4","video/webm","video/ogg"],audio:["audio/mpeg","audio/wav","audio/ogg","audio/mp3"]},Ua=n=>Object.values(Ue).some(a=>a.includes(n)),On=n=>Ue.image.includes(n)?"image":Ue.pdf.includes(n)?"pdf":Ue.text.includes(n)||Ue.code.includes(n)?"text":Ue.video.includes(n)?"video":Ue.audio.includes(n)?"audio":"unknown";function Ba({noteId:n,canDelete:a=!1,onViewNote:r,showThumbnails:c=!1}){const[f,h]=u.useState([]),[I,A]=u.useState(!0),[g,x]=u.useState(null),[j,R]=u.useState(null),[w,O]=u.useState(!1),[U,D]=u.useState(null);u.useEffect(()=>{H()},[n]);const H=async()=>{try{const{data:l,error:p}=await T.from("note_attachments").select("*").eq("note_id",n).order("created_at",{ascending:!0});if(p)throw p;const C=new Set,d=(l||[]).filter(M=>C.has(M.id)?!1:(C.add(M.id),!0));h(Pa(d))}catch{}finally{A(!1)}},b=l=>l.startsWith("image/")?e.jsx($s,{className:"h-4 w-4"}):l==="application/pdf"?e.jsx(Ms,{className:"h-4 w-4"}):l.startsWith("text/")||Ue.code.includes(l)?e.jsx(Fs,{className:"h-4 w-4"}):l.includes("spreadsheet")||l==="text/csv"?e.jsx(Ls,{className:"h-4 w-4"}):e.jsx(bn,{className:"h-4 w-4"}),B=async l=>{try{const{data:p,error:C}=await T.storage.from("note-attachments").download(l.file_path);if(C)throw C;const d=URL.createObjectURL(p),M=document.createElement("a");M.href=d,M.download=l.file_name,document.body.appendChild(M),M.click(),document.body.removeChild(M),URL.revokeObjectURL(d)}catch{_.error("Failed to download file")}},L=async l=>{O(!0),R(l),D(null);try{if(On(l.mime_type)==="text"){const{data:C,error:d}=await T.storage.from("note-attachments").download(l.file_path);if(d)throw d;const M=await C.text();D(M),x("text-preview")}else{const{data:C,error:d}=await T.storage.from("note-attachments").createSignedUrl(l.file_path,3600);if(d)throw d;x(C.signedUrl)}}catch{_.error("Failed to preview file"),R(null)}finally{O(!1)}},$=()=>{x(null),R(null),D(null)},Q=async l=>{if(window.confirm(`Delete ${l.file_name}?`))try{const{error:p}=await T.storage.from("note-attachments").remove([l.file_path]);if(p)throw p;const{error:C}=await T.from("note_attachments").delete().eq("id",l.id);if(C)throw C;h(d=>d.filter(M=>M.id!==l.id)),_.success(`Attachment "${l.file_name}" deleted`,{description:r?e.jsx("button",{className:"text-primary underline hover:text-primary/80",onClick:r,children:"View note"}):void 0})}catch{_.error("Failed to delete attachment")}},ie=()=>{if(!j)return null;const l=On(j.mime_type);if(w)return e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(De,{className:"h-8 w-8 animate-spin text-muted-foreground"})});switch(l){case"image":return e.jsx("div",{className:"flex justify-center",children:e.jsx("img",{src:g,alt:j.file_name,className:"max-h-[75vh] rounded-lg object-contain"})});case"pdf":return e.jsx("iframe",{src:g,className:"w-full h-[70vh] rounded-lg border border-border",title:j.file_name});case"text":return e.jsx(zs,{className:"h-[70vh] w-full rounded-lg border border-border bg-muted/30",children:e.jsx("pre",{className:"p-4 text-sm font-mono whitespace-pre-wrap break-words",children:U})});case"video":return e.jsx("video",{src:g,controls:!0,className:"max-h-[75vh] w-full rounded-lg",children:"Your browser does not support video playback."});case"audio":return e.jsxs("div",{className:"flex flex-col items-center gap-4 py-10",children:[e.jsx("div",{className:"h-24 w-24 rounded-full bg-muted flex items-center justify-center",children:e.jsx(bn,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx("audio",{src:g,controls:!0,className:"w-full max-w-md",children:"Your browser does not support audio playback."})]});default:return e.jsxs("div",{className:"flex flex-col items-center gap-4 py-10",children:[e.jsx("p",{className:"text-muted-foreground",children:"Preview not available for this file type"}),e.jsxs(E,{onClick:()=>B(j),children:[e.jsx(ht,{className:"h-4 w-4 mr-2"}),"Download File"]})]})}};if(I||f.length===0)return null;
2const k=({attachment:l,onPreview:p,onDownload:C,onDelete:d})=>{const[M,q]=u.useState(null);return u.useEffect(()=>{let W=!1;return T.storage.from("note-attachments").createSignedUrl(l.file_path,3600).then(({data:te})=>{!W&&te&&q(te.signedUrl)}),()=>{W=!0}},[l.file_path]),e.jsxs("div",{className:"group relative rounded-lg border border-border overflow-hidden cursor-pointer w-28 h-28 bg-muted",onClick:p,children:[M?e.jsx("img",{src:M,alt:l.file_name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(De,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),e.jsxs("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors flex items-center justify-center gap-1 opacity-0 group-hover:opacity-100",children:[e.jsx(E,{type:"button",variant:"secondary",size:"sm",className:"h-7 w-7 p-0",onClick:W=>{W.stopPropagation(),C()},children:e.jsx(ht,{className:"h-3.5 w-3.5"})}),d&&e.jsx(E,{type:"button",variant:"destructive",size:"sm",className:"h-7 w-7 p-0",onClick:W=>{W.stopPropagation(),d()},children:e.jsx(Wt,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 px-1.5 py-0.5",children:e.jsx("p",{className:"text-[10px] text-white truncate",children:l.file_name})})]})};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:f.map(l=>{const p=Ua(l.mime_type),C=l.mime_type.startsWith("image/");return c?C?e.jsx(k,{attachment:l,onPreview:()=>L(l),onDownload:()=>B(l),onDelete:a?()=>Q(l):void 0},l.id):e.jsxs("div",{className:"group relative rounded-lg border border-border overflow-hidden cursor-pointer w-28 h-28 bg-muted/40 flex flex-col items-center justify-center p-2",onClick:()=>p?L(l):B(l),title:l.file_name,children:[e.jsx("div",{className:"h-10 w-10 rounded bg-background flex items-center justify-center mb-1",children:b(l.mime_type)}),e.jsx("p",{className:"text-[10px] text-foreground text-center line-clamp-2 break-all",children:l.file_name}),e.jsxs("p",{className:"text-[9px] text-muted-foreground",children:[(l.file_size/1024).toFixed(1)," KB"]}),e.jsxs("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors flex items-center justify-center gap-1 opacity-0 group-hover:opacity-100",children:[p&&e.jsx(E,{type:"button",variant:"secondary",size:"sm",className:"h-7 w-7 p-0",onClick:d=>{d.stopPropagation(),L(l)},children:e.jsx(yn,{className:"h-3.5 w-3.5"})}),e.jsx(E,{type:"button",variant:"secondary",size:"sm",className:"h-7 w-7 p-0",onClick:d=>{d.stopPropagation(),B(l)},children:e.jsx(ht,{className:"h-3.5 w-3.5"})}),a&&e.jsx(E,{type:"button",variant:"destructive",size:"sm",className:"h-7 w-7 p-0",onClick:d=>{d.stopPropagation(),Q(l)},children:e.jsx(Wt,{className:"h-3.5 w-3.5"})})]})]},l.id):e.jsxs("div",{className:"group relative rounded-lg border border-border bg-card/50 p-2 flex items-center gap-2 max-w-xs hover:bg-card transition-colors cursor-pointer",onClick:()=>p&&L(l),children:[e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:b(l.mime_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:l.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(l.file_size/1024).toFixed(1)," KB"]})]}),e.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[p&&e.jsx(E,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:d=>{d.stopPropagation(),L(l)},title:"Preview",children:e.jsx(yn,{className:"h-3 w-3"})}),e.jsx(E,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:d=>{d.stopPropagation(),B(l)},title:"Download",children:e.jsx(ht,{className:"h-3 w-3"})}),a&&e.jsx(E,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:text-destructive",onClick:d=>{d.stopPropagation(),Q(l)},title:"Delete",children:e.jsx(Wt,{className:"h-3 w-3"})})]})]},l.id)})}),e.jsx(At,{open:!!g,onOpenChange:$,children:e.jsxs(Et,{className:"max-w-4xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(Ot,{className:"flex flex-row items-center justify-between",children:[e.jsx(Pt,{className:"truncate pr-4",children:j==null?void 0:j.file_name}),j&&e.jsxs(E,{variant:"outline",size:"sm",onClick:()=>B(j),className:"flex-shrink-0",children:[e.jsx(ht,{className:"h-4 w-4 mr-2"}),"Download"]})]}),ie()]})})]})}const Pn="hsl(var(--muted-foreground) / 0.4)",$n="hsl(var(--primary))";function qa({isCompleted:n,customStatusId:a,statuses:r,onSelectStatus:c,className:f="",variant:h="checkbox"}){const[I,A]=u.useState(!1);if(r.length===0&&h==="checkbox")return e.jsx(Dt,{checked:n,onCheckedChange:()=>
2c(null,!n),className:`border-muted-foreground/50 data-[state=checked]:border-primary ${f}`});const g=r.filter(b=>b.status_type==="not_done"),x=r.filter(b=>b.status_type==="done"),j=h==="pill",R=a?r.find(b=>b.id===a):null,w=!R&&!j&&r.find(b=>b.is_default)||null,O=R||w,U=O?O.label:n?"Closed":"Open",D=O?O.color:n?$n:Pn,H=(b,B)=>{c(b,B),A(!1)};return e.jsxs(Kn,{open:I,onOpenChange:A,children:[e.jsx(Gn,{asChild:!0,children:e.jsxs("button",{onClick:b=>{b.stopPropagation(),b.preventDefault()},className:j?`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium border border-border bg-card hover:bg-muted transition-colors flex-shrink-0 ${f}`:`flex items-center gap-1.5 rounded-md px-1.5 py-0.5 text-xs hover:bg-muted transition-colors flex-shrink-0 ${f}`,title:U,children:[e.jsx("span",{className:"h-3 w-3 rounded-full flex-shrink-0 border border-border",style:{backgroundColor:D}}),e.jsx("span",{className:j?"truncate max-w-[160px]":"max-w-[80px] truncate hidden sm:inline",children:U})]})}),e.jsx(Zn,{className:"w-48 p-1",align:"start",side:"bottom",onClick:b=>b.stopPropagation(),onPointerDown:b=>b.stopPropagation(),children:r.length===0?e.jsxs(e.Fragment,{children:[e.jsx(Tt,{label:"Open",color:Pn,isSelected:!n,onClick:()=>H(null,!1)}),e.jsx(Tt,{label:"Closed",color:$n,isSelected:n,onClick:()=>H(null,!0)})]}):e.jsxs(e.Fragment,{children:[g.map(b=>e.jsx(Tt,{label:b.label,color:b.color,isSelected:a===b.id,onClick:()=>H(b.id,!1)},b.id)),x.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-2 py-1 mt-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/60 border-t pt-2",children:"Done"}),x.map(b=>e.jsx(Tt,{label:b.label,color:b.color,isSelected:a===b.id,onClick:()=>H(b.id,!0)},b.id))]})]})})]})}function Tt({label:n,color:a,isSelected:r,onClick:c}){return e.jsxs("button",{onClick:c,className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted transition-colors",children:[e.jsx("span",{className:"h-3 w-3 rounded-full flex-shrink-0",style:{backgroundColor:a}}),e.jsx("span",{className:"flex-1 text-left truncate",children:n}),r&&e.jsx(rn,{className:"h-3.5 w-3.5 text-primary flex-shrink-0"})]})}const Mn=/(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,63}\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)/gi,Ha=/[.,;:!?)]+$/;function en({children:n,linkClassName:a}){const r=n??"";if(!r)return e.jsx(e.Fragment,{children:r});const c=[];let f=0,h=0;Mn.lastIndex=0;let I;for(;(I=Mn.exec(r))!==null;){const A=I[0],g=I.index,x=g+A.length,j=A.replace(Ha,"");g+j.length;const R=A.slice(j.length);g>f&&c.push(r.slice(f,g));const w=j.startsWith("http")?j:`https://${j}`;c.push(e.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",onClick:O=>O.stopPropagation(),className:a??"text-primary underline hover:text-primary/80 break-all",children:j},`linkified-${h++}-${g}`)),R&&c.push(R),f=x}return f<r.length&&c.push(r.slice(f)),e.jsx(e.Fragment,{children:c})}function Wr(n){if(!n)return"AI";const a=n.toLowerCase();return a.includes("cowork")?"Claude Cowork":a.includes("claude-code")||a.includes("claude_code")?"Claude Code":a.includes("fable")?"Claude Fable":a.includes("opus")?"Claude Opus":a.includes("sonnet")?"Claude Sonnet":a.includes("haiku")?"Claude Haiku":a.includes("gemini")?"Gemini":n}const Fn="rounded-md border border-emerald-500/25 bg-emerald-500/[0.06] px-2 py-1.5";function Va(n){if(typeof document>"u")return;let a=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",a.appendChild(r),r.styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n))}const Jn=N.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{}
2,direction:"bottom",shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),wt=()=>{const n=N.useContext(Jn);if(!n)throw new Error("useDrawerContext must be used within a Drawer.Root");return n};Va(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,100%,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,-100%,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(-100%,0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(100%,0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
3[data-state=closed]
4){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}
4to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,100%,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,100%,0)}}@keyframes slideFromTop{from{transform:translate3d(0,-100%,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,-100%,0)}}@keyframes slideFromLeft{from{transform:translate3d(-100%,0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(-100%,0,0)}}@keyframes slideFromRight{from{transform:translate3d(100%,0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(100%,0,0)}}`);const Wa=24,Ya=typeof window<"u"?u.useLayoutEffect:u.useEffect;function Ln(...n){return(...a)=>{for(let r of n)typeof r=="function"&&r(...a)}}function Xa(){return hn(/^Mac/)}function Ka(){return hn(/^iPhone/)}function zn(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Ga(){return hn(/^iPad/)||Xa()&&navigator.maxTouchPoints>1}function es(){return Ka()||Ga()}function hn(n){return typeof window<"u"&&window.navigator!=null?n.test(window.navigator.platform):void 0}const tn=typeof document<"u"&&window.visualViewport;function Un(n){let a=window.getComputedStyle(n);return/(auto|scroll)/.test(a.overflow+a.overflowX+a.overflowY)}function ts(n){for(Un(n)&&(n=n.parentElement);n&&!Un(n);)n=n.parentElement;return n||document.scrollingElement||document.documentElement}const Za=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let It=0,nn;function Qa(n={}){let{isDisabled:a}=n;Ya(()=>{if(!a)return It++,It===1&&es()&&(nn=Ja()),()=>{It--,It===0&&(nn==null||nn())}},[a])}function Ja(){let n,a=0,r=R=>{n=ts(R.target),!(n===document.documentElement&&n===document.body)&&(a=R.changedTouches[0].pageY)},c=R=>{if(!n||n===document.documentElement||n===document.body){R.preventDefault();return}let w=R.changedTouches[0].pageY,O=n.scrollTop,U=n.scrollHeight-n.clientHeight;U!==0&&((O<=0&&w>a||O>=U&&w<a)&&R.preventDefault(),a=w)},f=R=>{let w=R.target;un(w)&&w!==document.activeElement&&(R.preventDefault(),w.style.transform="translateY(-2000px)",w.focus(),requestAnimationFrame(()=>{w.style.transform=""}))},h=R=>{let w=R.target;un(w)&&(w.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{w.style.transform="",tn&&(tn.height<window.innerHeight?requestAnimationFrame(()=>{Bn(w)}):tn.addEventListener("resize",()=>Bn(w),{once:!0}))}))},I=()=>{window.scrollTo(0,0)},A=window.pageXOffset,g=window.pageYOffset,x=Ln(er(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let j=Ln(xt(document,"touchstart",r,{passive:!1,capture:!0}),xt(document,"touchmove",c,{passive:!1,capture:!0}),xt(document,"touchend",f,{passive:!1,capture:!0}),xt(document,"focus",h,!0),xt(window,"scroll",I));return()=>{x(),j(),window.scrollTo(A,g)}}function er(n,a,r){let c=n.style[a];return n.style[a]=r,()=>{n.style[a]=c}}function xt(n,a,r,c){return n.addEventListener(a,r,c),()=>{n.removeEventListener(a,r,c)}}function Bn(n){let a=document.scrollingElement||document.documentElement;for(;n&&n!==a;){let r=ts(n);if(r!==document.documentElement&&r!==document.body&&r!==n){let c=r.getBoundingClientRect().top,f=n.getBoundingClientRect().top,h=n.getBoundingClientRect().bottom;const I=r.getBoundingClientRect().bottom+Wa;h>I&&(r.scrollTop+=f-c)}n=r.parentElement}}function un(n){return n instanceof HTMLInputElement&&!Za.has(n.type)||n instanceof HTMLTextAreaElement||n instanceof HTMLElement&&n.isContentEditable}function tr(n,a){typeof n=="function"?n(a):n!=null&&(n.current=a)}function nr(...n){return a=>n.forEach(r=>tr(r,a))}function ns(...n){return u.useCallback(nr(...n),n)}const ss=new WeakMap;function de(n,a,r=!1){if(!n||!(n instanceof HTMLElement))return;let c={};Object.entries(a).forEach(([f,h])=>{if(f.startsWith("--")){n.style.setProperty(f,h);return}c[f]=n.style[f],n.style[f]=h}),!r&&ss.set(n,c)}function sr(n,a){if(!n||!(n instanceof HTMLElement))return;let r=ss.get(n);r&&(n.style[a]=r[a])}const ue=n=>{switch(n){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return n}};function Rt(n,a){if(!n)return null;const r=window.getComputedStyle(n),c=r.transform||r.webkitTransform||r.mozTransform;let f=c.match(/^matrix3d\((.+)\)$/);return f?parseFloat(f[1].split(", ")[ue(a)?13:12]):(f=c.match(/^matrix\((.+)\)$/),f?parseFloat(f[1].split(", ")[ue(a)?5:4]):null)}function ar(n){return 8*(Math.log(n+1)-2)}function sn(n,a){if(!n)return()=>{};const r=n.style.cssText;return Object.assign(n.style,a),()=>{n.style.cssText=r}}function rr(...n){return(...a)=>{for(const r of n)typeof r=="function"&&r(...a)}}const ae={DURATION:.5,EASE:[.32,.72,0,1]},as=.4,ir=.25,or=100,rs=8,Xe=16,mn=26,an="vaul-dragging";function is(n){const a=N.useRef(n);return N.useEffect(()=>{a.current=n}),N.useMemo(()=>(...r)=>a.current==null?void 0:a.current.call(a,...r),[])}function lr({defaultProp:n,onChange:a}){const r=N.useState(n),[c]=r,f=N.useRef(c),h=is(a);return N.useEffect(()=>{f.current!==c&&(h(c),f.current=c)},[c,f,h]),r}function os({prop:n,defaultProp:a,onChange:r=()=>{}}){const[c,f]=lr({defaultProp:a,onChange:r}),h=n!==void 0,I=h?n:c,A=is(r),g=N.useCallback(x=>{if(h){const R=typeof x=="function"?x(n):x;R!==n&&A(R)}else f(x)},[h,n,f,A]);return[I,g]}function cr({activeSnapPointProp:n,setActiveSnapPointProp:a,snapPoints:r,drawerRef:c,overlayRef:f,fadeFromIndex:h,onSnapPointChange:I,direction:A="bottom",container:g,snapToSequentialPoint:x}){const[j,R]=os({prop:n,defaultProp:r==null?void 0:r[0],onChange:a}),[w,O]=N.useState(typeof window<"u"?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);N.useEffect(()=>{function k(){O({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)},[]);const U=N.useMemo(()=>j===(r==null?void 0:r[r.length-1])||null,[r,j]),D=N.useMemo(()=>r==null?void 0:r.findIndex(k=>k===j),[r,j]),H=r&&r.length>0&&(h||h===0)&&!Number.isNaN(h)&&r[h]===j||!r,b=N.useMemo(()=>{const k=g?{width:g.getBoundingClientRect().width,height:g.getBoundingClientRect().height}:typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var l;return(l=r==null?void 0:r.map(p=>{const C=typeof p=="string";let d=0;if(C&&(d=parseInt(p,10)),ue(A)){const q=C?d:w?p*k.height:0;return w?A==="bottom"?k.height-q:-k.height+q:q}const M=C?d:w?p*k.width:0;return w?A==="right"?k.width-M:-k.width+M:M}))!=null?l:[]},[r,w,g]),B=N.useMemo(()=>D!==null?b==null?void 0:b[D]:null,[b,D]),L=N.useCallback(k=>{var l;const p=(l=b==null?void 0:b.findIndex(C=>C===k))!=null?l:null;
4I(p),de(c.current,{transition:`transform ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,transform:ue(A)?`translate3d(0, ${k}px, 0)`:`translate3d(${k}px, 0, 0)`}),b&&p!==b.length-1&&p!==h&&p<h?de(f.current,{transition:`opacity ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,opacity:"0"}):de(f.current,{transition:`opacity ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,opacity:"1"}),R(r==null?void 0:r[Math.max(p,0)])},[c.current,r,b,h,f,R]);N.useEffect(()=>{if(j||n){var k;const l=(k=r==null?void 0:r.findIndex(p=>p===n||p===j))!=null?k:-1;b&&l!==-1&&typeof b[l]=="number"&&L(b[l])}},[j,n,r,b,L]);function $({draggedDistance:k,closeDrawer:l,velocity:p,dismissible:C}){if(h===void 0)return;const d=A==="bottom"||A==="right"?(B??0)-k:(B??0)+k,M=D===h-1,q=D===0,W=k>0;if(M&&de(f.current,{transition:`opacity ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`}),!x&&p>2&&!W){C?l():L(b[0]);return}if(!x&&p>2&&W&&b&&r){L(b[r.length-1]);return}const te=b==null?void 0:b.reduce((ne,he)=>typeof ne!="number"||typeof he!="number"?ne:Math.abs(he-d)<Math.abs(ne-d)?he:ne),fe=ue(A)?window.innerHeight:window.innerWidth;if(p>as&&Math.abs(k)<fe*.4){const ne=W?1:-1;if(ne>0&&U){L(b[r.length-1]);return}if(q&&ne<0&&C&&l(),D===null)return;L(b[D+ne]);return}L(te)}function Q({draggedDistance:k}){if(B===null)return;const l=A==="bottom"||A==="right"?B-k:B+k;(A==="bottom"||A==="right")&&l<b[b.length-1]||(A==="top"||A==="left")&&l>b[b.length-1]||de(c.current,{transform:ue(A)?`translate3d(0, ${l}px, 0)`:`translate3d(${l}px, 0, 0)`})}function ie(k,l){if(!r||typeof D!="number"||!b||h===void 0)return null;const p=D===h-1;if(D>=h&&l)return 0;if(p&&!l)return 1;if(!H&&!p)return null;const d=p?D+1:D-1,M=p?b[d]-b[d-1]:b[d+1]-b[d],q=k/Math.abs(M);return p?1-q:q}return{isLastSnapPoint:U,activeSnapPoint:j,shouldFade:H,getPercentageDragged:ie,setActiveSnapPoint:R,activeSnapPointIndex:D,onRelease:$,onDrag:Q,snapPointsOffset:b}}const dr=()=>()=>{};function ur(){const{direction:n,isOpen:a,shouldScaleBackground:r,setBackgroundColorOnScale:c,noBodyStyles:f}=wt(),h=N.useRef(null),I=u.useMemo(()=>document.body.style.backgroundColor,[]);function A(){return(window.innerWidth-mn)/window.innerWidth}N.useEffect(()=>{if(a&&r){h.current&&clearTimeout(h.current);const g=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!g)return;rr(c&&!f?sn(document.body,{background:"black"}):dr,sn(g,{transformOrigin:ue(n)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${ae.DURATION}s`,transitionTimingFunction:`cubic-bezier(${ae.EASE.join(",")})`}));const x=sn(g,{borderRadius:`${rs}px`,overflow:"hidden",...ue(n)?{transform:`scale(${A()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${A()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{x(),h.current=window.setTimeout(()=>{I?document.body.style.background=I:document.body.style.removeProperty("background")},ae.DURATION*1e3)}}},[a,r,I])}let gt=null;function mr({isOpen:n,modal:a,nested:r,hasBeenOpened:c,preventScrollRestoration:f,noBodyStyles:h}){const[I,A]=N.useState(()=>typeof window<"u"?window.location.href:""),g=N.useRef(0),x=N.useCallback(()=>{if(zn()&&gt===null&&n&&!h){gt={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:R,innerHeight:w}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-g.current}px`,left:`${-R}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const O=w-window.innerHeight;O&&g.current>=w&&(document.body.style.top=`${-(g.current+O)}px`)}),300)}},[n]),j=N.useCallback(()=>{if(zn()&&gt!==null&&!h){const R=-parseInt(document.body.style.top,10),w=-parseInt(document.body.style.left,10);Object.assign(document.body.style,gt),window.requestAnimationFrame(()=>{if(f&&I!==window.location.href){A(window.location.href);return}window.scrollTo(w,R)}),gt=null}},[I]);return N.useEffect(()=>{function R(){g.current=window.scrollY}return R(),window.addEventListener("scroll",R),()=>{window.removeEventListener("scroll",R)}},[]),N.useEffect(()=>{r||!c||(n?(!window.matchMedia("(display-mode: standalone)").matches&&x(),a||window.setTimeout(()=>{j()},500)):j())},[n,c,I,a,r,x,j]),{restorePositionSetting:j}}function fr({open:n,onOpenChange:a,children:r,onDrag:c,onRelease:f,snapPoints:h,shouldScaleBackgroun
4d:I=!1,setBackgroundColorOnScale:A=!0,closeThreshold:g=ir,scrollLockTimeout:x=or,dismissible:j=!0,handleOnly:R=!1,fadeFromIndex:w=h&&h.length-1,activeSnapPoint:O,setActiveSnapPoint:U,fixed:D,modal:H=!0,onClose:b,nested:B,noBodyStyles:L,direction:$="bottom",defaultOpen:Q=!1,disablePreventScroll:ie=!0,snapToSequentialPoint:k=!1,preventScrollRestoration:l=!1,repositionInputs:p=!0,onAnimationEnd:C,container:d,autoFocus:M=!1}){var q,W;const[te=!1,fe]=os({defaultProp:Q,prop:n,onChange:F=>{a==null||a(F),!F&&!B&&yt(),setTimeout(()=>{C==null||C(F)},ae.DURATION*1e3),F&&!H&&typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),F||(document.body.style.pointerEvents="auto")}}),[ne,he]=N.useState(!1),[pe,_e]=N.useState(!1),[$t,Ke]=N.useState(!1),Ae=N.useRef(null),qe=N.useRef(null),Ge=N.useRef(null),Ze=N.useRef(null),He=N.useRef(null),Se=N.useRef(!1),Me=N.useRef(null),Ve=N.useRef(0),Ce=N.useRef(!1),rt=N.useRef(0),P=N.useRef(null),je=N.useRef(((q=P.current)==null?void 0:q.getBoundingClientRect().height)||0),it=N.useRef(((W=P.current)==null?void 0:W.getBoundingClientRect().width)||0),Fe=N.useRef(0),oe=N.useCallback(F=>{h&&F===Oe.length-1&&(qe.current=new Date)},[]),{activeSnapPoint:Ee,activeSnapPointIndex:we,setActiveSnapPoint:Qe,onRelease:vt,snapPointsOffset:Oe,onDrag:Mt,shouldFade:ot,getPercentageDragged:Ft}=cr({snapPoints:h,activeSnapPointProp:O,setActiveSnapPointProp:U,drawerRef:P,fadeFromIndex:w,overlayRef:Ae,onSnapPointChange:oe,direction:$,container:d,snapToSequentialPoint:k});Qa({isDisabled:!te||pe||!H||$t||!ne||!p||!ie});const{restorePositionSetting:yt}=mr({isOpen:te,modal:H,nested:B,hasBeenOpened:ne,preventScrollRestoration:l,noBodyStyles:L});function me(){return(window.innerWidth-mn)/window.innerWidth}function Le(F){var X,s;!j&&!h||P.current&&!P.current.contains(F.target)||(je.current=((X=P.current)==null?void 0:X.getBoundingClientRect().height)||0,it.current=((s=P.current)==null?void 0:s.getBoundingClientRect().width)||0,_e(!0),Ge.current=new Date,es()&&window.addEventListener("touchend",()=>Se.current=!1,{once:!0}),F.target.setPointerCapture(F.pointerId),Ve.current=ue($)?F.pageY:F.pageX)}function We(F,X){var s,J;let K=F;const xe=(s=window.getSelection())==null?void 0:s.toString(),le=P.current?Rt(P.current,$):null,re=new Date;if(K.hasAttribute("data-vaul-no-drag")||K.closest("[data-vaul-no-drag]"))return!1;if($==="right"||$==="left")return!0;if(qe.current&&re.getTime()-qe.current.getTime()<500)return!1;if(le!==null&&($==="bottom"?le>0:le<0))return!0;if(xe&&xe.length>0)return!1;if(re.getTime()-((J=He.current)==null?void 0:J.getTime())<x&&le===0||X)return He.current=re,!1;for(;K;){if(K.scrollHeight>K.clientHeight){if(K.scrollTop!==0)return He.current=new Date,!1;if(K.getAttribute("role")==="dialog")return!0}K=K.parentNode}return!0}function Je(F){if(P.current&&pe){const X=$==="bottom"||$==="right"?1:-1,s=(Ve.current-(ue($)?F.pageY:F.pageX))*X,J=s>0,K=h&&!j&&!J;if(K&&we===0)return;const xe=Math.abs(s),le=document.querySelector("[data-vaul-drawer-wrapper]"),re=$==="bottom"||$==="top"?je.current:it.current;let ge=xe/re;const be=Ft(xe,J);if(be!==null&&(ge=be),K&&ge>=1||!Se.current&&!We(F.target,J))return;if(P.current.classList.add(an),Se.current=!0,de(P.current,{transition:"none"}),de(Ae.current,{transition:"none"}),h&&Mt({draggedDistance:s}),J&&!h){const ve=ar(s),Ie=Math.min(ve*-1,0)*X;de(P.current,{transform:ue($)?`translate3d(0, ${Ie}px, 0)`:`translate3d(${Ie}px, 0, 0)`});return}const ke=1-ge;if((ot||w&&we===w-1)&&(c==null||c(F,ge),de(Ae.current,{opacity:`${ke}`,transition:"none"},!0)),le&&Ae.current&&I){const ve=Math.min(me()+ge*(1-me()),1),Ie=8-ge*8,Pe=Math.max(0,14-ge*14);de(le,{borderRadius:`${Ie}px`,transform:ue($)?`scale(${ve}) translate3d(0, ${Pe}px, 0)`:`scale(${ve}) translate3d(${Pe}px, 0, 0)`,transition:"none"},!0)}if(!h){const ve=xe*X;de(P.current,{transform:ue($)?`translate3d(0, ${ve}px, 0)`:`translate3d(${ve}px, 0, 0)`})}}}N.useEffect(()=>{var F;function X(){if(!P.current||!p)return;const s=document.activeElement;if(un(s)||Ce.current){var J;const K=((J=window.visualViewport)==null?void 0:J.height)||0,xe=window.innerHeight;let le=xe-K;const re=P.current.getBoundingClientRect().height||0,ge=re>xe*.8;Fe.current||(Fe.current=re);const be=P.current.getBoundingClientRect().top;if(Math.abs(rt.current-le)>60&&(Ce.current=!Ce.current),h&&h.length>0&&Oe&&we){const ke=Oe[we]||0;le+=ke}if(rt.current=le,re>K||Ce.current){const ke=P.current.getBoundingClientRect().height;let ve=ke;ke>
4K&&(ve=K-(ge?be:mn)),D?P.current.style.height=`${ke-Math.max(le,0)}px`:P.current.style.height=`${Math.max(ve,K-be)}px`}else P.current.style.height=`${Fe.current}px`;h&&h.length>0&&!Ce.current?P.current.style.bottom="0px":P.current.style.bottom=`${Math.max(le,0)}px`}}return(F=window.visualViewport)==null||F.addEventListener("resize",X),()=>{var s;return(s=window.visualViewport)==null?void 0:s.removeEventListener("resize",X)}},[we,h,Oe]);function Te(F){_t(),b==null||b(),F||fe(!1),setTimeout(()=>{h&&Qe(h[0])},ae.DURATION*1e3)}function bt(){if(!P.current)return;const F=document.querySelector("[data-vaul-drawer-wrapper]"),X=Rt(P.current,$);de(P.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`}),de(Ae.current,{transition:`opacity ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,opacity:"1"}),I&&X&&X>0&&te&&de(F,{borderRadius:`${rs}px`,overflow:"hidden",...ue($)?{transform:`scale(${me()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${me()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${ae.DURATION}s`,transitionTimingFunction:`cubic-bezier(${ae.EASE.join(",")})`},!0)}function _t(){!pe||!P.current||(P.current.classList.remove(an),Se.current=!1,_e(!1),Ze.current=new Date)}function Lt(F){if(!pe||!P.current)return;P.current.classList.remove(an),Se.current=!1,_e(!1),Ze.current=new Date;const X=Rt(P.current,$);
4if(!We(F.target,!1)||!X||Number.isNaN(X)||Ge.current===null)return;const s=Ze.current.getTime()-Ge.current.getTime(),J=Ve.current-(ue($)?F.pageY:F.pageX),K=Math.abs(J)/s;if(K>.05&&(Ke(!0),setTimeout(()=>{Ke(!1)},200)),h){vt({draggedDistance:J*($==="bottom"||$==="right"?1:-1),closeDrawer:Te,velocity:K,dismissible:j}),f==null||f(F,!0);return}if($==="bottom"||$==="right"?J>0:J<0){bt(),f==null||f(F,!0);return}if(K>as){Te(),f==null||f(F,!1);return}var xe;const le=Math.min((xe=P.current.getBoundingClientRect().height)!=null?xe:0,window.innerHeight);var re;const ge=Math.min((re=P.current.getBoundingClientRect().width)!=null?re:0,window.innerWidth),be=$==="left"||$==="right";if(Math.abs(X)>=(be?ge:le)*g){Te(),f==null||f(F,!1);return}f==null||f(F,!0),bt()}N.useEffect(()=>(te&&(de(document.documentElement,{scrollBehavior:"auto"}),qe.current=new Date),()=>{sr(document.documentElement,"scrollBehavior")}),[te]);function jt(F){const X=F?(window.innerWidth-Xe)/window.innerWidth:1,s=F?-Xe:0;Me.current&&window.clearTimeout(Me.current),de(P.current,{transition:`transform ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,transform:`scale(${X}) translate3d(0, ${s}px, 0)`}),!F&&P.current&&(Me.current=setTimeout(()=>{const J=Rt(P.current,$);de(P.current,{transition:"none",transform:ue($)?`translate3d(0, ${J}px, 0)`:`translate3d(${J}px, 0, 0)`})},500))}function lt(F,X){if(X<0)return;const s=(window.innerWidth-Xe)/window.innerWidth,J=s+X*(1-s),K=-Xe+X*Xe;de(P.current,{transform:ue($)?`scale(${J}) translate3d(0, ${K}px, 0)`:`scale(${J}) translate3d(${K}px, 0, 0)`,transition:"none"})}function kt(F,X){const s=ue($)?window.innerHeight:window.innerWidth,J=X?(s-Xe)/s:1,K=X?-Xe:0;X&&de(P.current,{transition:`transform ${ae.DURATION}s cubic-bezier(${ae.EASE.join(",")})`,transform:ue($)?`scale(${J}) translate3d(0, ${K}px, 0)`:`scale(${J}) translate3d(${K}px, 0, 0)`})}return N.createElement(Bs,{defaultOpen:Q,onOpenChange:F=>{!j&&!F||(F?he(!0):Te(!0),fe(F))},open:te},N.createElement(Jn.Provider,{value:{activeSnapPoint:Ee,snapPoints:h,setActiveSnapPoint:Qe,drawerRef:P,overlayRef:Ae,onOpenChange:a,onPress:Le,onRelease:Lt,onDrag:Je,dismissible:j,handleOnly:R,isOpen:te,isDragging:pe,shouldFade:ot,closeDrawer:Te,onNestedDrag:lt,onNestedOpenChange:jt,onNestedRelease:kt,keyboardIsOpen:Ce,modal:H,snapPointsOffset:Oe,direction:$,shouldScaleBackground:I,setBackgroundColorOnScale:A,noBodyStyles:L,container:d,autoFocus:M}},r))}const ls=N.forwardRef(function({...n},a){const{overlayRef:r,snapPoints:c,onRelease:f,shouldFade:h,isOpen:I,modal:A}=wt(),g=ns(a,r),x=c&&c.length>0;return A?N.createElement(Vs,{onMouseUp:f,ref:g,"data-vaul-overlay":"","data-vaul-snap-points":I&&x?"true":"false","data-vaul-snap-points-overlay":I&&h?"true":"false",...n}):(typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),null)});ls.displayName="Drawer.Overlay";const cs=N.forwardRef(function({onPointerDownOutside:n,style:a,onOpenAutoFocus:r,...c},f){const{drawerRef:h,onPress:I,onRelease:A,onDrag:g,keyboardIsOpen:x,snapPointsOffset:j,modal:R,isOpen:w,direction:O,snapPoints:U,container:D,handleOnly:H,autoFocus:b}=wt(),[B,L]=N.useState(!1),$=ns(f,h),Q=N.useRef(null),ie=N.useRef(null),k=N.useRef(!1),l=U&&U.length>0;ur();const p=(d,M,q=0)=>{if(k.current)return!0;const W=Math.abs(d.y),te=Math.abs(d.x),fe=te>W,ne=["bottom","right"].includes(M)?1:-1;if(M==="left"||M==="right"){if(!(d.x*ne<0)&&te>=0&&te<=q)return fe}else if(!(d.y*ne<0)&&W>=0&&W<=q)return!fe;return k.current=!0,!0};N.useEffect(()=>{l&&window.requestAnimationFrame(()=>{L(!0)})},[]);function C(d){Q.current=null,k.current=!1,A(d)}return N.createElement(Hs,{"data-vaul-drawer-direction":O,"data-vaul-drawer":"","data-vaul-delayed-snap-points":B?"true":"false","data-vaul-snap-points":w&&l?"true":"false","data-vaul-custom-container":D?"true":"false",...c,ref:$,style:j&&j.length>0?{"--snap-point-height":`${j[0]}px`,...a}:a,onPointerDown:d=>{H||(c.onPointerDown==null||c.onPointerDown.call(c,d),Q.current={x:d.pageX,y:d.pageY},I(d))},onOpenAutoFocus:d=>{r==null||r(d),b||d.preventDefault()},onPointerDownOutside:d=>{if(n==null||n(d),!R||d.defaultPrevented){d.preventDefault();return}x.current&&(x.current=!1)},onFocusOutside:d=>{if(!R){d.preventDefault();return}},onPointerMove:d=>{if(ie.current=d,H||(c.onPointerMove==null||c.onPointerMove.call(c,d),!Q.current))return;const M=d.pageY-Q.current.y,q=d.pageX-Q.current.x,W=d.pointerType==="touch"?10:2;p({x:q,y:M},O,W)?g(d):(Math.abs(q)>W||Math.abs(M)>W)&&(Q.current=null)},onPointerUp:d=>{c.onPointerUp==null||c.onPointerUp.call(c,d),Q.current=null,k.current=!1,A(d)},onPointerOut:d=>{c.onPointerOut==null||c.onPointerOut.call(c,d),C(ie.current)},onContextMenu:d=>{c.onContextMenu==null||c.onContextMenu.call(c,d),C(ie.current)}})});cs.displayName="Drawer.Content";const hr=250,pr=120,xr=N.forwardRef(function({preventCycle:n=!1,children:a,...r},c){const{closeDrawer:f,isDragging:h,snapPoints:I,activeSnapPoint:A,setActiveSnapPoint:g,dismissible:x,handleOnly:j,isOpen:R,onPress:w,onDrag:O}=wt(),U=N.useRef(null),D=N.useRef(!1);function H(){if(D.current){L();return}window.setTimeout(()=>{b()},pr)}function b(){if(h||n||D.current){L();return}if(L(),(!I||I.length===0)&&x){f();return}if(A===I[I.length-1]&&x){f();return}const Q=I.findIndex(k=>k===A);if(Q===-1)return;const ie=I[Q+1];g(ie)}function B(){U.current=window.setTimeout(()=>{D.current=!0},hr)}function L(){window.clearTimeout(U.current),D.current=!1}return N.createElement("div",{onClick:H,onPointerCancel:L,onPointerDown:$=>{j&&w($),B()},onPointerMove:$=>{j&&O($)},ref:c,"data-vaul-drawer-visible":R?"true":"false","data-vaul-handle":"","aria-hidden":"true",...r},N.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},a))});xr.displayName="Drawer.Handle";function gr(n){const a=wt(),{container:r=a.container,...c}=n;return N.createElement(qs,{container:r,...c})}const $e={Root:fr,Content:cs,Overlay:ls,Portal:gr,Title:Us,Description:Ws}
4,ds=({shouldScaleBackground:n=!0,...a})=>e.jsx($e.Root,{shouldScaleBackground:n,...a});ds.displayName="Drawer";const wr=$e.Portal,us=u.forwardRef(({className:n,...a},r)=>e.jsx($e.Overlay,{ref:r,className:at("fixed inset-0 z-overlay bg-black/80",n),...a}));us.displayName=$e.Overlay.displayName;const ms=u.forwardRef(({className:n,children:a,...r},c)=>e.jsxs(wr,{children:[e.jsx(us,{}),e.jsxs($e.Content,{ref:c,className:at("fixed inset-x-0 bottom-0 z-modal mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",n),...r,children:[e.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted"}),a]})]}));ms.displayName="DrawerContent";const fs=({className:n,...a})=>e.jsx("div",{className:at("grid gap-1.5 p-4 text-center sm:text-left",n),...a});fs.displayName="DrawerHeader";const vr=({className:n,...a})=>e.jsx("div",{className:at("mt-auto flex flex-col gap-2 p-4",n),...a});vr.displayName="DrawerFooter";const hs=u.forwardRef(({className:n,...a},r)=>e.jsx($e.Title,{ref:r,className:at("text-lg font-semibold leading-none tracking-tight",n),...a}));hs.displayName=$e.Title.displayName;const yr=u.forwardRef(({className:n,...a},r)=>e.jsx($e.Description,{ref:r,className:at("text-sm text-muted-foreground",n),...a}));yr.displayName=$e.Description.displayName;function br({open:n,onOpenChange:a,initialContent:r,initialThreadId:c,userId:f,defaultType:h="note",onCreated:I}){var k;const A=Ys(),[g,x]=u.useState(r),[j,R]=u.useState(h),[w,O]=u.useState([]),[U,D]=u.useState(""),[H,b]=u.useState(!1),[B,L]=u.useState(!1);u.useEffect(()=>{n&&(x(r),R(h))},[n,r,h]),u.useEffect(()=>{if(!n||!f)return;let l=!1;return(async()=>{const{data:p}=await T.from("threads").select("id, title, is_default").eq("user_id",f).is("deleted_at",null).eq("is_archived",!1).order("is_default",{ascending:!1}).order("title",{ascending:!0});if(l)return;const C=p||[];if(O(C),c&&C.some(d=>d.id===c))D(c),b(!1);else{const d=C.find(M=>M.is_default);D((d==null?void 0:d.id)??""),b(!!d)}})(),()=>{l=!0}},[n,f,c]);const $=async()=>{if(!f||!g.trim()||!U)return;L(!0);const{data:l,error:p}=await T.from("notes").insert({user_id:f,thread_id:U,content:g.trim(),note_type:j,source:"manual"}).select("id").single();if(L(!1),p){_.error(p.message||"Failed to save note");return}_.success(j==="task"?"Task created":"Note created"),I==null||I(l.id),a(!1)},Q=((k=w.find(l=>l.id===U))==null?void 0:k.title)||"General",ie=e.jsxs("div",{className:"space-y-3 px-4 pb-6 sm:px-0 sm:pb-0",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Be,{className:"text-xs",children:"Content"}),e.jsx(Vn,{value:g,onChange:l=>x(l.target.value),className:"min-h-[140px] text-sm",autoFocus:!A})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Be,{className:"text-xs",children:"Thread"}),e.jsxs(Xs,{value:U,onValueChange:l=>{D(l),b(!1)},children:[e.jsx(Ks,{children:e.jsx(Gs,{placeholder:"Choose a thread"})}),e.jsx(Zs,{children:w.map(l=>e.jsx(Qs,{value:l.id,children:l.title},l.id))})]}),H&&e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Filing in ",Q," (this comment's task has no thread)."]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Be,{className:"text-xs",children:"Type"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(E,{type:"button",size:"sm",variant:j==="note"?"default":"outline",onClick:()=>R("note"),children:"Note"}),e.jsx(E,{type:"button",size:"sm",variant:j==="task"?"default":"outline",onClick:()=>R("task"),children:"Task"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx(E,{variant:"ghost",size:"sm",onClick:()=>a(!1),children:"Cancel"}),e.jsxs(E,{size:"sm",onClick:$,disabled:B||!g.trim()||!U,children:[B&&e.jsx(De,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Save"]})]})]});return A?e.jsx(ds,{open:n,onOpenChange:a,children:e.jsxs(ms,{className:"max-h-[85vh] overflow-y-auto",children:[e.jsx(fs,{children:e.jsx(hs,{children:"Save as note"})}),ie]})}):e.jsx(At,{open:n,onOpenChange:a,children:e.jsxs(Et,{className:"max-w-lg max-h-[75vh] overflow-y-auto",children:[e.jsx(Ot,{children:e.jsx(Pt,{children:"Save as note"})}),ie]})})}
4const qn=6e3,ps=1500,_r=/https?:\/\/[^\s<>"')\]]+/gi;function jr(...n){const a=new Set,r=[];for(const c of n)if(c)for(const f of c.matchAll(_r)){const h=f[0].replace(/[.,;:!?]+$/,"");a.has(h)||(a.add(h),r.push(h))}return r}function fn(n){const a=dn(n.taskText||""),r=dn(n.aiComment||"").slice(0,ps),c=jr(a,r,...n.extraUrlTexts??[]),f=["Verify a completed NoteStream task by checking the live result.","","Task:",a||"(no task text)","","What the AI reported:",r||"(no AI comment recorded)",""];if(c.length>0){f.push("Live URLs to check:");for(const h of c)f.push(`- ${h}`);f.push("")}return f.push("Using Claude in Chrome, open the live URL(s) above and check whether the requested change actually works. Report PASS or FAIL for each requirement in the task, with what you saw as evidence (screenshot if possible). Do not change anything."),f.join(`
5`)}function kr(n){let a=fn(n);if(encodeURIComponent(a).length<=qn)return a;const r=dn(n.aiComment||"");for(let c=Math.min(r.length,ps);c>=0;c-=200)if(a=fn({...n,aiComment:r.slice(0,c)}),encodeURIComponent(a).length<=qn)return a;return a}function Nr(n){return n.kind==="notestream"?{kind:"notestream",endpoint:n.endpoint}:n.kind==="claude-cowork"?{kind:"claude-cowork"}:null}function Sr({note:n,comments:a,thread:r,userId:c,prompt:f,onPromptConsumed:h,suppressReviewFlag:I,onSubmitted:A,onSendStarted:g,onSendSucceeded:x,onSendFailed:j,onCommentOnly:R,registerSend:w,onSubmitExternal:O,onMethodChange:U,disabled:D,contentClassName:H}){const[b,B]=u.useState(!1),[L,$]=u.useState(null),[Q,ie]=u.useState(!1),[k,l]=u.useState(!1),[p,C]=u.useState(null),d=p??Ra((n==null?void 0:n.external_service)??null,a),M=k?"Comment only":Jt(d),q=!!f.trim(),W=ne=>{if(!n||!q)return!1;const he=Nr(ne);if(!he)return!1;const pe=f.trim();return B(!0),g==null||g(Jt(ne)),h(),(async()=>{const _e=await Aa({noteId:n.id,userId:c,prompt:pe,method:he,suppressReviewFlag:I});B(!1),_e.ok?(x==null||x(),_.success(he.kind==="claude-cowork"?"Task queued for Claude Cowork":`Sent to ${Jt(ne)} — response incoming…`)):(j==null||j(),_.error(_e.errorMessage||"Failed to send to AI",{description:pe.length>140?`${pe.slice(0,140)}…`:pe}))})(),!0},te=()=>{if(n){if(k){if(!q)return;R==null||R();return}W(d)||($(d),ie(!0))}};u.useEffect(()=>{w==null||w(te)});const fe=b||!!D;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-shrink-0 self-end gap-1",children:[e.jsx(Qn,{note:n,comments:a,thread:r,userId:c,suppressReviewFlag:I,onSubmitted:A,onSubmitExternal:O,onMethodChange:U,showCommentOnly:!0,commentOnlySelected:k,onPickCommentOnly:()=>{l(!0),C(null)},onPick:ne=>(l(!1),C(ne),!0),contentClassName:H,trigger:e.jsxs(E,{size:"sm",variant:"outline",className:"h-9 px-2 text-xs gap-1",disabled:fe||!n,title:"Choose how this comment is sent","aria-label":"Choose how this comment is sent",children:[k?e.jsx(Wn,{className:"h-3.5 w-3.5"}):e.jsx(nt,{className:"h-3.5 w-3.5"}),M,e.jsx(Yn,{className:"h-3 w-3 opacity-60"})]})}),e.jsx(E,{size:"sm",className:"h-9 w-9 p-0",onClick:te,disabled:fe||!n||k&&!q,title:k?"Post comment":`Send to ${M}`,"aria-label":"Send",children:b?e.jsx(De,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Js,{className:"h-3.5 w-3.5"})})]}),e.jsx(Da,{open:Q,onOpenChange:ie,note:n,comments:a,thread:r,userId:c,method:L,suppressReviewFlag:I,onSubmitted:A,onSubmitExternal:O})]})}const xs=({open:n,onOpenChange:a,noteId:r,noteContent:c,threadId:f,userId:h,onSplitComplete:I})=>{const[A,g]=u.useState(!1),[x,j]=u.useState([]),[R,w]=u.useState(!1),[O,U]=u.useState(!1),[D,H]=u.useState("separate"),b=async()=>{g(!0);try{const{data:p,error:C}=await T.functions.invoke("split-task",{body:{content:c}});if(C)throw C;p!=null&&p.tasks&&Array.isArray(p.tasks)&&p.tasks.length>0?(j(p.tasks),U(!0)):_.error("AI couldn't split this task. Try editing it manually.")}catch{_.error("Failed to generate split tasks")}finally{g(!1)}},B=async()=>{var C;const p=x.filter(d=>d.trim().length>0);if(p.length===0){_.error("Add at least one task");return}w(!0);try{if(D==="subtasks"){const d=p.map((q,W)=>({user_id:h,thread_id:f,content:q.trim(),note_type:"task",is_completed:!1,parent_id:r,position:W})),{error:M}=await T.from("notes").insert(d);if(M)throw M;_.success(`Created ${p.length} sub-tasks`)}else{const{data:d}=await T.from("notes").select("sort_order").eq("thread_id",f).eq("user_id",h).is("deleted_at",null).order("sort_order",{ascending:!1}).limit(1);let M=(((C=d==null?void 0:d[0])==null?void 0:C.sort_order)||0)+1;const q=p.map((fe,ne)=>({user_id:h,thread_id:f,content:fe.trim(),note_type:"task",is_completed:!1,sort_order:M+ne})),{error:W}=await T.from("notes").insert(q);if(W)throw W;const{error:te}=await T.from("notes").update({deleted_at:new Date().toISOString()}).eq("id",r);
5if(te)throw te;_.success(`Split into ${p.length} tasks`)}I(),L()}catch{_.error("Failed to save split tasks")}finally{w(!1)}},L=()=>{j([]),U(!1),g(!1),H("separate"),a(!1)},$=(p,C)=>{j(d=>d.map((M,q)=>q===p?C:M))},Q=p=>{j(C=>C.filter((d,M)=>M!==p))},ie=()=>{j(p=>[...p,""])},k=p=>{p&&!O&&!A&&b(),p?a(p):L()},l=x.filter(p=>p.trim()).length;return e.jsx(At,{open:n,onOpenChange:k,children:e.jsxs(Et,{className:"max-w-md max-h-[80vh] flex flex-col",children:[e.jsxs(Ot,{children:[e.jsx(Pt,{children:"Split Task"}),e.jsx(ea,{children:"AI will break this task into actionable items. Choose whether to create separate tasks or sub-tasks under the original."})]}),e.jsxs("div",{className:"rounded-md border bg-muted/50 p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Original task:"}),e.jsx("p",{className:"text-sm text-foreground line-clamp-3",children:c})]}),O&&e.jsxs("div",{className:"flex gap-1 p-1 rounded-lg bg-muted",children:[e.jsx("button",{onClick:()=>H("separate"),className:`flex-1 text-xs font-medium py-1.5 px-3 rounded-md transition-colors ${D==="separate"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Separate Tasks"}),e.jsx("button",{onClick:()=>H("subtasks"),className:`flex-1 text-xs font-medium py-1.5 px-3 rounded-md transition-colors ${D==="subtasks"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Sub-tasks"})]}),A?e.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[e.jsx(De,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Analyzing task..."})]}):O?e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[l," proposed ",D==="subtasks"?"sub-task":"task",l!==1?"s":"",D==="subtasks"&&e.jsx("span",{className:"text-muted-foreground/70",children:" — original task will be kept as the parent"}),D==="separate"&&e.jsx("span",{className:"text-muted-foreground/70",children:" — original task will be removed"}),":"]}),x.map((p,C)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ta,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(on,{value:p,onChange:d=>$(C,d.target.value),className:"flex-1 text-sm",placeholder:D==="subtasks"?"Sub-task description...":"Task description..."}),e.jsx(E,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:text-destructive flex-shrink-0",onClick:()=>Q(C),children:e.jsx(st,{className:"h-4 w-4"})})]},C)),e.jsxs(E,{variant:"outline",size:"sm",className:"w-full text-xs gap-1",onClick:ie,children:[e.jsx(ln,{className:"h-3 w-3"}),"Add ",D==="subtasks"?"Sub-task":"Task"]})]}):null,e.jsxs(na,{className:"gap-2 sm:gap-0",children:[e.jsx(E,{variant:"outline",onClick:L,disabled:R,children:"Cancel"}),O&&e.jsx(E,{onClick:B,disabled:R||l===0,children:R?e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"h-4 w-4 animate-spin mr-2"}),"Saving..."]}):D==="subtasks"?`Create ${l} Sub-task${l!==1?"s":""}`:`Split into ${l} Task${l!==1?"s":""}`})]})]})})},Yr=Object.freeze(Object.defineProperty({__proto__:null,SplitTaskDialog:xs},Symbol.toStringTag,{value:"Module"})),Cr=4*60*1e3;function Tr(n,a,r,c=Cr){const f=new Set(n.map(x=>x.noteId)),h=[],I=[];for(const x of a)f.has(x.id)&&x.ai_status!=="pending"&&(I.push(x.id),!(x.deleted_at||x.archived_at)&&cn(x)&&h.push(x));const A=new Set(I),g=n.filter(x=>!A.has(x.noteId)&&r-x.since>c);return{returning:h,expired:g,settledIds:I}}function Ir(n,a,r){const c=n.filter(f=>f.id!==r);return c.length===0?{items:c,index:0}:{items:c,index:a>c.length-1?c.length-1:a}}function Rr(n,a,r,c){if(n.some(I=>I.id===r.id))return{items:n,index:c};const f=Math.max(0,Math.min(a,n.length));return{items:[...n.slice(0,f),r,...n.slice(f)],index:f<=c?f:c}}function Dr(n,a){const r=new Set(n.map(f=>f.id)),c=a.filter(f=>!r.has(f.id));return c.length===0?n:[...n,...c]}const Hn=u.lazy(()=>Xn(()=>import("./VoiceModeOverlay-B2n5mojn.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(n=>({default:n.VoiceModeOverlay}))),Ar=u.lazy(()=>Xn(()=>import("./ReviseTaskModal-NDjtsJu3.js"),__vite__mapDeps([11,1,2,9,12,13,14,10,15,16,17,6,3,4,5,7,8])).then(n=>({default:n.ReviseTaskModal})));function Er({embeddedMobile:n=!1}){var vn;const{user:a,loading:r,isReady:c}=sa(),{statuses:f}=ka(a==null?void 0:a.id,null),h=aa(),[I,A]=ra(),[g,x]=u.useState([]),[j,R]=u.useState({}),[w,O]=u.useState(0),U=u.useRef([]),D=u.useRef(0),[H,b]=u.useState(_n),B=u.useRef(_n);u.useEffect(()=>{B.current=H},[H]);const[L,$]=u.useState([]),[Q,ie]=u.useState([]),[k,l]=u.useState(!1),[p,C]=u.useState(!0),[d,M]=u.useState(""),[q,W]=u.useState(""),[te,fe]=u.useState("note"),[ne,he]=u.useState(!1),[pe,_e]=u.useState(""),[$t,Ke]=u.useState(!1),[Ae,qe]=u.useState(!1),[Ge,Ze]=u.useState(!1),[He,Se]=u.useState(!1),[Me,Ve]=u.useState(()=>I.get("voice")==="1"),[Ce,rt]=u.useState(!1),[P,je]=u.useState(new Set),[it,Fe]=u.useState(!1),[oe,Ee]=u.useState(null),[we,Qe]=u.useState([]),[vt,Oe]=u.useState(""),[Mt,ot]=u.useState(!1),[Ft,yt]=u.useState(!1),[me,Le]=u.useState([]),[We,Je]=u.useState(""),Te=u.useRef(null),[bt,_t]=u.useState(!1),[Lt,jt]=u.useState(!1),[lt,kt]=u.useState(null),[F,X]=u.useState(null);u.useEffect(()=>{U.current=g,D.current=w}),u.useEffect(()=>{if(!a)return;let t=!1;return(async()=>{const{data:o}=await T.from("profiles").select("review_sort_order, timezone").eq("id",a.id).maybeSingle();t||(b(ia(o==null?void 0:o.review_sort_order)),X((o==null?void 0:o.timezone)??null))})(),()=>{t=!0}},[a==null?void 0:a.id]),u.useEffect(()=>{var y;const t=U.current;if(t.length===0)return;const o=(y=t[D.current])==null?void 0:y.id,i=Yt(t,H),m=o?i.findIndex(S=>S.id===o):-1,v=m>=0?m:0;U.current=i,D.current=v,x(i),O(v)},[H]);const s=g[w],J=s?s.__share_review===!0:!1,K=g.length-w;Ea("AI");
5const{label:xe,setOverride:le}=Oa((s==null?void 0:s.external_service)??null,me,"Assign to AI"),re=s?Q.find(t=>t.note_id===s.id):void 0,ge=re?{id:re.id,reminder_time:re.reminder_time,reminder_text:re.reminder_text,recurrence_type:re.recurrence_type||"none",recurrence_end_date:re.recurrence_end_date}:void 0;u.useEffect(()=>{c&&a?(St(),Ts(),Ht()):c&&!a&&C(!1)},[a,c]),u.useEffect(()=>{const t=I.get("start");if(!t||g.length===0)return;const o=g.findIndex(m=>m.id===t);o>0?(x(m=>{const v=m.findIndex(y=>y.id===t);return v<=0?m:[...m.slice(v),...m.slice(0,v)]}),O(0)):o===0&&O(0);const i=new URLSearchParams(I);i.delete("start"),A(i,{replace:!0})},[g.length]);const be=u.useCallback(t=>{const{items:o,index:i}=Ir(U.current,D.current,t);U.current=o,D.current=i,x(o),O(i)},[]),ke=u.useCallback(()=>{s&&be(s.id)},[s,be]),ve=u.useCallback((t,o)=>{const i=Rr(U.current,o,t,D.current);U.current=i.items,D.current=i.index,x(i.items),O(i.index)},[]);u.useEffect(()=>{if(s){const t=Ma(s.content)?za(s.content):Fa(s.content);M(t);let o=!1;Sa(t).then(v=>{!o&&v!==t&&M(v)});const i=L.find(v=>v.id===s.thread_id),m=oa(L);return W(i&&la(i)?i.id:m||""),fe(s.note_type==="task"?"task":"note"),()=>{o=!0}}},[s==null?void 0:s.id,s==null?void 0:s.content,s==null?void 0:s.note_type,s==null?void 0:s.thread_id,L]);const Ie=u.useCallback(async()=>{if(!s||s.note_type!=="task"){Qe([]);return}yt(!0);const{data:t}=await T.from("notes").select("*").eq("parent_id",s.id).eq("note_type","task").is("deleted_at",null).order("position",{ascending:!0});Qe(t||[]),yt(!1)},[s==null?void 0:s.id,s==null?void 0:s.note_type]),Pe=u.useRef(null),Ne=u.useCallback(async()=>{if(!s){Le([]);return}const t=s.id;Pe.current=t,jt(!0);const{data:o,error:i}=await T.from("note_comments").select("*").eq("note_id",t).order("created_at",{ascending:!0});if(Pe.current===t){if(!i&&o){const m=[...new Set(o.map(y=>y.user_id))];let v={};if(m.length>0){const{data:y}=await T.from("profiles").select("id, display_name").in("id",m);if(Pe.current!==t)return;y&&(v=Object.fromEntries(y.map(S=>[S.id,S.display_name||"User"])))}Le(o.map(y=>({...y,display_name:v[y.user_id]||"User"})))}else i||Le([]);jt(!1)}},[s==null?void 0:s.id]);u.useEffect(()=>{Pe.current=(s==null?void 0:s.id)??null,Le([]),s?(Ie(),Ne()):Qe([])},[s==null?void 0:s.id,Ie,Ne]);const[Re,ct]=u.useState([]),ye=u.useRef([]);u.useEffect(()=>{ye.current=Re},[Re]);const dt=Re.find(t=>t.noteId===(s==null?void 0:s.id))??null,zt=u.useCallback((t,o,i)=>{if(!t)return;const m={noteId:t.id,since:Date.now(),label:i,item:t,index:o};ct(v=>[...v.filter(y=>y.noteId!==t.id),m]),ye.current=[...ye.current.filter(v=>v.noteId!==t.id),m],be(t.id)},[be]),gs=u.useCallback(t=>{const o=ye.current.find(i=>i.noteId===t);o&&ve(o.item,o.index),ye.current=ye.current.filter(i=>i.noteId!==t),ct(i=>i.filter(m=>m.noteId!==t))},[ve]),[ws,pn]=u.useState(null),vs=u.useCallback(async t=>{pn(t);const{error:o}=await T.rpc("cancel_ai_assignment",{p_note_id:t});if(pn(null),o){_.error("Couldn't stop the AI — try again.");return}const i=ye.current.find(m=>m.noteId===t);i&&ve(i.item,i.index),ye.current=ye.current.filter(m=>m.noteId!==t),ct(m=>m.filter(v=>v.noteId!==t)),_.success("Stopped. The task is back in your queue.")},[ve]),Nt=u.useRef(!1);u.useEffect(()=>{const t=s==null?void 0:s.id;if(!t)return;Nt.current=!1;const o=T.channel(`review-comments-${t}`).on("postgres_changes",{event:"*",schema:"public",table:"note_comments",filter:`note_id=eq.${t}`},i=>{Pe.current===t&&Le(m=>{var se;if(i.eventType==="DELETE"){const Z=(se=i.old)==null?void 0:se.id;return Z?m.filter(ce=>ce.id!==Z):m}const v=i.new;if(!(v!=null&&v.id))return m;const y={...v,display_name:v.author_type==="ai"?"AI":"User"},S=m.findIndex(Z=>Z.id===v.id);if(S===-1)return[...m,y];const V=m.slice();return V[S]={...m[S],...y},V})}).subscribe(i=>{Nt.current=i==="SUBSCRIBED"});return()=>{Nt.current=!1,T.removeChannel(o)}},[s==null?void 0:s.id]),u.useEffect(()=>{const t=s==null?void 0:s.id;if(!t||!Re.some(i=>i.noteId===t))return;const o=setInterval(async()=>{if(Nt.current)return;const{data:i}=await T.from("note_comments").select("*").eq("note_id",t).order("created_at",{ascending:!0});!i||Pe.current!==t||Le(m=>{const v=new Set(m.map(S=>S.id)),y=i.filter(S=>!v.has(S.id));return y.length===0?m:[...m,...y.map(S=>({...S,display_name:S.author_type==="ai"?"AI":"User"}))]})},5e3);return()=>clearInterval(o)},[s==null?void 0:s.id,Re]),u.useEffect(()=>{if(Re.length===0)return;const t=setInterval(async()=>{var Z,ce;const o=ye.current;if(o.length===0)return;const i=o.map(G=>G.noteId),{data:m,error:v}=await T.from("notes").select("*").in("id",i);if(v)return;const{returning:y,expired:S,settledIds:V}=Tr(o,m??[],Date.now());if(y.length>0){const G=U.current,ee=Dr(G,y);if(ee!==G){const z=(Z=G[D.current])==null?void 0:Z.id,Y=Yt(ee,B.current),ze=z?Y.findIndex(ft=>ft.id===z):-1,Ye=ze>=0?ze:Math.min(D.current,Math.max(0,Y.length-1));U.current=Y,D.current=Ye,x(Y),O(Ye)}for(const z of y){const Y=((ce=o.find(ze=>ze.noteId===z.id))==null?void 0:ce.label)??"The AI";_.success(`${Y} answered — back in your review queue.`)}}for(const G of S)_.error(`${G.label} hasn't answered yet. It may still land — reopen this task in a minute.`);const se=new Set([...V,...S.map(G=>G.noteId)]);se.size>0&&(ye.current=ye.current.filter(G=>!se.has(G.noteId)),ct(G=>G.filter(ee=>!se.has(ee.noteId))))},5e3);return()=>clearInterval(t)},[Re.length]);const et=u.useCallback(()=>{s&&zt(s,w,xe||"The AI")},[s,w,xe,zt]),xn=u.useCallback(async t=>{if(!s)return;if(t==="toggle_ai_assignment"){et();return}if(t==="delete_items"){ke();return}const o=s.id;await Ne();const{data:i}=await T.from("notes").select("*").eq("id",o).maybeSingle();i&&x(m=>m.map(v=>v.id===o?{...v,...i}:v))},[s,Ne,et,ke]),ys=async()=>{const t=vt.trim();if(!t||!s)return;ot(!0);const o=we.length>0?Math.max(...we.map(m=>m.position||0))+1:0,{error:i}=await T.from("notes").insert({user_id:s.user_id,thread_id:s.thread_id,content:t,note_type:"task",is_completed:!1,parent_id:s.id,position:o,source:"manual"});i?_.error("Failed to add sub-task"):(Oe(""),Ie()),ot(!1)},bs=async t=>{const{error:o}=await T.from("notes").update({is_completed:!t.is_completed,updated_at:new Date().toISOString()}).eq("id",t.id);o?_.error("Failed to update sub-task"):Ie()},_s=async t=>{const{error:o}=await T.from("notes").update({deleted_at:new Date().toISOString()}).eq("id",t);o?_.error("Failed to delete sub-task"):Ie()},js=async()=>{const t=We.trim();if(!(!t||!s||!a)){if(s.__share_review){_.error("Can't comment on a shared-note notification. Acknowledge it first to open the note.");return}_t(!0);try{const{data:o,error:i}=await T.from("note_comments").insert({note_id:s.id,user_id:a.id,content:t}).select("id").single();if(i){_.error(i.message||"Failed to add comment");return}if(!(o!=null&&o.id)){_.error("Comment was not saved (no row returned)");return}Je(""),await Ne()}finally{_t(!1)}}},gn=async t=>{const o=(t||"").trim();if(!o||!s||!a)return;if(s.__share_review){_.error("Can't comment on a shared-note notification. Acknowledge it first to open the note.");return}const{data:i,error:m}=await T.from("note_comments").insert({note_id:s.id,user_id:a.id,content:o}).select("id").single();if(m){_.error(m.message||"Failed to add comment");return}if(!(i!=null&&i.id)){_.error("Comment was not saved (no row returned)");return}await Ne()},ks=async t=>{const{error:o}=await T.from("note_comments").delete().eq("id",t);o?_.error("Failed to delete comment"):Ne()},Ut=async()=>
5{if(!s||!window.confirm("Delete this item? It will be moved to trash."))return;const t=s,o=w;l(!0);try{const{error:i}=await T.from("notes").update({deleted_at:new Date().toISOString()}).eq("id",s.id);if(i)throw i;Ee({type:"delete",noteId:s.id,previousIndex:o,previousState:{content:t.content,thread_id:t.thread_id,note_type:t.note_type,needs_review:t.needs_review??!0,reviewed_at:t.reviewed_at??null,deleted_at:null},restoredItem:t}),x(m=>m.filter(v=>v.id!==s.id)),w>=g.length-1&&w>0&&O(w-1),_.success("Deleted")}catch(i){_.error((i==null?void 0:i.message)||"Failed to delete")}finally{l(!1)}},Ns=u.useCallback(async t=>{if(!a)throw new Error("Sign in to upload images");if(!t.type.startsWith("image/"))throw new Error("Only image files can be inserted inline");if(t.size>10*1024*1024)throw new Error(`${t.name}: image exceeds 10MB`);const o=t.name.replace(/[^a-zA-Z0-9._-]/g,"_"),i=`${a.id}/inline/${crypto.randomUUID()}-${o}`,{error:m}=await T.storage.from("note-attachments").upload(i,t,{contentType:t.type,upsert:!1});if(m)throw m;return await Ca(i)},[a]),{makePasteHandler:Ss}=ca(),Bt=async()=>{if(!s)return;const t=f.find(S=>S.status_type==="done"),o=new Date().toISOString(),i=s,m=w,v={is_completed:!0,needs_review:!1,reviewed_at:o,updated_at:o,...Rn(s)};t&&(v.custom_status_id=t.id);const{error:y}=await T.from("notes").update(v).eq("id",s.id);if(y){_.error("Failed to mark complete");return}Ee({type:"review",noteId:i.id,previousIndex:m,previousState:{content:i.content,thread_id:i.thread_id,note_type:i.note_type,needs_review:i.needs_review??!0,reviewed_at:i.reviewed_at??null,deleted_at:null},restoredItem:i}),x(S=>S.filter(V=>V.id!==i.id)),w>=g.length-1&&w>0&&O(w-1),_.success(t?`Completed — ${t.label}`:"Marked complete")},Cs=()=>{var S;if(!s)return;const t=me.filter(V=>V.author_type==="ai"),o=t[t.length-1],i={taskText:s.content||"",aiComment:(o==null?void 0:o.content)||s.ai_response||"",extraUrlTexts:me.map(V=>V.content)},m=fn(i),v=kr(i);if(!window.open(`https://claude.ai/new?q=${encodeURIComponent(v)}`,"_blank","noopener,noreferrer")){_.error("Pop-up blocked — allow pop-ups for NoteStream to verify with Claude");return}try{const V=L.find(se=>se.id===s.thread_id);localStorage.setItem("notestream_pending_handoff",JSON.stringify({noteId:s.id,threadName:(V==null?void 0:V.title)||"",destination:"Claude",timestamp:Date.now()})),localStorage.setItem("notestream_claude_handoff",m)}catch{}(S=navigator.clipboard)==null||S.writeText(m).catch(()=>{}),_.success("Verification prompt copied — it's prefilled in Claude; paste it if the box is empty.")},qt=async()=>{if(!s)return;const t=s,o=w,i=new Date().toISOString();l(!0);try{const{error:m}=await T.from("notes").update({archived_at:i,needs_review:!1,updated_at:i}).eq("id",t.id);if(m)throw m;Ee({type:"review",noteId:t.id,previousIndex:o,previousState:{content:t.content,thread_id:t.thread_id,note_type:t.note_type,needs_review:t.needs_review??!0,reviewed_at:t.reviewed_at??null,deleted_at:null},restoredItem:t}),x(v=>v.filter(y=>y.id!==t.id)),w>=g.length-1&&w>0&&O(w-1),_.success("Archived",{duration:8e3,action:{label:"Undo",onClick:async()=>{try{await T.from("notes").update({archived_at:null,needs_review:t.needs_review??!0}).eq("id",t.id),x(v=>{const y=[...v],S=Math.min(o,y.length);return y.splice(S,0,{...t,archived_at:null}),y}),O(o),_.success("Restored")}catch{_.error("Failed to undo")}}}})}catch(m){_.error((m==null?void 0:m.message)||"Failed to archive")}finally{l(!1)}},ut=async t=>{if(!s)return;const o=s,i=o.note_type;if(i===t)return;const m=new Date().toISOString(),{error:v}=await T.from("notes").update({note_type:t,updated_at:m}).eq("id",o.id);if(v){_.error("Failed to convert");return}fe(t),x(y=>y.map(S=>S.id===o.id?{...S,note_type:t}:S)),_.success(t==="task"?"Converted to task":"Converted to note",{duration:8e3,action:{label:"Undo",onClick:async()=>{try{await T.from("notes").update({note_type:i}).eq("id",o.id),fe(i),x(y=>y.map(S=>S.id===o.id?{...S,note_type:i}:S)),_.success("Reverted")}catch{_.error("Failed to undo")}}}})},St=async()=>{var se;if(!a){C(!1);return}C(!0);const{data:t,error:o}=await T.from("notes").select("*").eq("user_id",a.id).is("deleted_at",null).is("ar
5chived_at",null).or(da).order("created_at",{ascending:B.current==="oldest"});if(o){_.error("Failed to load review items"),x([]),C(!1);return}if(!t||t.length===0){x([]),C(!1);return}const i=t.map(Z=>({...Z,note_type:Z.note_type,ai_status:Z.ai_status,source:Z.source})).filter(cn);let m=i;try{const{data:Z,error:ce}=await T.rpc("list_my_share_notifications");ce||Array.isArray(Z)&&Z.length>0&&(m=[...Z.map(ee=>({id:ee.note_id,user_id:ee.note_user_id,content:ee.note_content,note_type:ee.note_type==="task"?"task":"note",thread_id:ee.note_thread_id,created_at:ee.shared_at,updated_at:ee.shared_at,deleted_at:null,is_completed:!1,needs_review:!0,source:"manual",ai_status:null,__share_id:ee.share_id,__share_review:!0})),...i])}catch{}const v=Yt(m,B.current),y=(se=U.current[D.current])==null?void 0:se.id,S=y?v.findIndex(Z=>Z.id===y):-1,V=S>=0?S:0;U.current=v,D.current=V,x(v),O(V),C(!1);try{const Z=m.filter(ce=>pt(ce)==="ai_response"&&!ce.external_service).map(ce=>ce.id);if(Z.length>0){const{data:ce}=await T.from("note_comments").select("note_id, ai_model, created_at, author_type").in("note_id",Z).eq("author_type","ai").order("created_at",{ascending:!1}),G={};(ce||[]).forEach(ee=>{ee.note_id in G||(G[ee.note_id]=ee.ai_model??null)}),R(G)}else R({})}catch{}return v},Ts=async()=>{if(!a)return;const{data:t,error:o}=await T.from("threads").select("*").eq("user_id",a.id).eq("is_system",!1).is("deleted_at",null).order("title");o||$(jn(t||[]))},Ht=async()=>{if(!a)return;const{data:t,error:o}=await T.from("reminders").select("id, note_id, reminder_time, reminder_text, recurrence_type, recurrence_end_date, sent").eq("user_id",a.id);o||ie(t||[])},Is=async(t,o,i)=>{var m,v;if(s)try{const[y,S]=o.split(":").map(Number),V=new Date(t);if(V.setHours(y,S,0,0),ge){const{error:se}=await T.from("reminders").update({reminder_time:V.toISOString(),reminder_text:d.replace(/<[^>]*>/g,"").substring(0,100),recurrence_type:(i==null?void 0:i.type)||"none",recurrence_end_date:((m=i==null?void 0:i.endDate)==null?void 0:m.toISOString())||null,sent:!1}).eq("id",ge.id);if(se)throw se;_.success("Reminder updated")}else{const{error:se}=await T.from("reminders").insert({note_id:s.id,user_id:a.id,reminder_time:V.toISOString(),reminder_text:d.replace(/<[^>]*>/g,"").substring(0,100),recurrence_type:(i==null?void 0:i.type)||"none",recurrence_end_date:((v=i==null?void 0:i.endDate)==null?void 0:v.toISOString())||null});if(se)throw se;_.success("Reminder set")}await Ht(),he(!1)}catch{_.error("Failed to set reminder")}},Rs=async()=>{if(ge)try{const{error:t}=await T.from("reminders").delete().eq("id",ge.id);if(t)throw t;_.success("Reminder deleted"),await Ht(),he(!1)}catch{_.error("Failed to delete reminder")}},Ds=async()=>{if(P.size!==0){Fe(!0);try{const t=Array.from(P),o=new Date().toISOString(),i=g.map((z,Y)=>({item:z,index:Y})).filter(({item:z})=>P.has(z.id)).map(({item:z,index:Y})=>({index:Y,item:z,content:z.content,needs_review:z.needs_review??!0,reviewed_at:z.reviewed_at??null,ai_status:z.ai_status??null,ai_completion_status:z.ai_completion_status??null})),m=i.filter(z=>z.ai_status==="ready_for_review"||z.ai_status==="timed_out"||z.ai_completion_status==="pending"||z.ai_completion_status==="timed_out").map(z=>z.item.id),v=t.filter(z=>!m.includes(z)),y={needs_review:!1,reviewed_at:o},S=[];v.length>0&&S.push(T.from("notes").update(y).in("id",v)),m.length>0&&S.push(T.from("notes").update({...y,ai_status:"complete",ai_completion_status:"complete"}).in("id",m));const se=(await Promise.allSettled(S)).some(z=>{var Y;return z.status==="rejected"||z.status==="fulfilled"&&((Y=z.value)==null?void 0:Y.error)}),{data:Z}=await T.from("notes").select("*").in("id",t),ce=(Z??[]).filter(z=>!z.deleted_at&&!z.archived_at&&cn(z)),G=new Set(ce.map(z=>z.id)),ee=t.filter(z=>!G.has(z));if(x(z=>z.filter(Y=>!ee.includes(Y.id))),je(new Set(G)),(G.size>0||se)&&_.error(`${G.size} of ${t.length} item${t.length>1?"s":""} could not be marked reviewed — still selected, try again`),ee.length>0){const z=i.filter(Y=>!G.has(Y.item.id));_.success(`${ee.length} item${ee.length>1?"s":""} marked as reviewed`,{duration:8e3,action:{label:"Undo",onClick:async()=>{try{await Promise.all(z.map(Y=>T.from("notes").update({content:Y.content,needs_review:!0,reviewed_at:Y.reviewed_at,ai_status:Y.ai_status,ai_completion_status:Y.ai_completion_status}).eq("id",Y.item.id))),x(Y=>{const ze=[...Y];for(const Ye of[...z].sort((ft,Ps)=>
5ft.index-Ps.index)){const ft=Math.min(Ye.index,ze.length);ze.splice(ft,0,{...Ye.item,content:Ye.content,needs_review:!0,reviewed_at:Ye.reviewed_at})}return ze}),_.success("Restored")}catch{_.error("Failed to undo")}}}})}g.length-ee.length===0&&(Gt(),h("/"))}catch{_.error("Bulk review failed")}finally{Fe(!1)}}},As=async()=>{if(P.size!==0){Fe(!0);try{const t=Array.from(P),{error:o}=await T.from("notes").update({deleted_at:new Date().toISOString()}).in("id",t);if(o)throw o;const{data:i}=await T.from("notes").select("id, deleted_at").in("id",t),m=new Set((i??[]).filter(y=>!y.deleted_at).map(y=>y.id)),v=t.filter(y=>!m.has(y));x(y=>y.filter(S=>!v.includes(S.id))),je(new Set(m)),v.length>0&&_.success(`${v.length} item${v.length>1?"s":""} deleted`),m.size>0&&_.error(`${m.size} of ${t.length} item${t.length>1?"s":""} could not be deleted — still selected, try again`),g.length-v.length===0&&(Gt(),h("/"))}catch{_.error("Bulk delete failed")}finally{Fe(!1)}}},wn=u.useCallback(t=>{x(o=>{const i=o.findIndex(m=>m.id===t);return i<=0?o:[...o.slice(i),...o.slice(0,i)]}),O(0),rt(!1),je(new Set)},[]),Es=t=>{je(o=>{const i=new Set(o);return i.has(t)?i.delete(t):i.add(t),i})},Os=()=>{P.size===g.length?je(new Set):je(new Set(g.map(t=>t.id)))},Ct=async()=>{if(oe){if(oe.type==="skip"){oe.previousIndex!==void 0&&O(oe.previousIndex),Ee(null),_.success("Went back");return}l(!0);try{await T.from("notes").update({content:oe.previousState.content,thread_id:oe.previousState.thread_id,note_type:oe.previousState.note_type,needs_review:oe.previousState.needs_review,reviewed_at:oe.previousState.reviewed_at,deleted_at:oe.previousState.deleted_at}).eq("id",oe.noteId);const t=await St(),o=Array.isArray(t)?t.length:null;if(oe.previousIndex!==void 0){const i=(o??g.length+1)-1;O(Math.max(0,Math.min(oe.previousIndex,Math.max(0,i))))}Ee(null),_.success("Undone — item restored to queue")}catch{_.error("Failed to undo")}finally{l(!1)}}},mt=async()=>{if(!s)return;l(!0);const t=s,o=w,i=s.content;s.needs_review;const m=s.reviewed_at??null,v=s.thread_id,y=s.note_type;try{const S=Ia(d),V=S.replace(/<[^>]*>/g,"").trim(),se={content:S,thread_id:q&&q!=="none"?q:null,note_type:te,reviewed_at:new Date().toISOString()};if(s.needs_review&&(se.needs_review=!1),s.__share_review&&s.__share_id)try{await T.rpc("acknowledge_share_notification",{p_share_id:s.__share_id})}catch{}const{error:Z}=await T.from("notes").update(se).eq("id",s.id);if(Z)throw Z;const ce=s.id;Ee({type:"review",noteId:ce,previousIndex:o,previousState:{content:i,thread_id:v,note_type:y,needs_review:!0,reviewed_at:null,deleted_at:null},restoredItem:t}),_.success("Marked as reviewed",{duration:8e3,action:{label:"Undo",onClick:async()=>{try{await T.from("notes").update({content:i,thread_id:v,note_type:y,needs_review:!0,reviewed_at:m}).eq("id",ce),x(G=>{if(G.some(Y=>Y.id===ce))return G.map(Y=>Y.id===ce?{...Y,content:i,thread_id:v,note_type:y,needs_review:!0,reviewed_at:m}:Y);const ee=[...G],z=Math.min(o,ee.length);return ee.splice(z,0,{...t,content:i,needs_review:!0,reviewed_at:m}),ee}),O(o),_.success("Restored")}catch{_.error("Failed to undo")}}}}),w<g.length-1?O(w+1):(Gt(),_.success("All items reviewed"),h("/"))}catch{_.error("Failed to save review")}finally{l(!1)}},Vt=()=>{w<g.length-1?(s&&Ee({type:"skip",noteId:s.id,previousIndex:w,previousState:{content:s.content,thread_id:s.thread_id,note_type:s.note_type,needs_review:s.needs_review??!0,reviewed_at:s.reviewed_at??null,deleted_at:null},restoredItem:s}),O(w+1)):(_.info("Skipped to end"),h("/"))};return r||!c?e.jsx("div",{className:`${n?"h-full":"min-h-screen"} flex items-center justify-center`,children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading your review queue..."})]})}):a&&p?e.jsx("div",{className:`${n?"h-full":"min-h-screen"} flex items-center justify-center`,children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading review items..."})]})}):a?s?e.jsxs("div",{className:`${n?"h-full overflow-y-auto":"min-h-screen"} bg-background p-4 md:p-8 pb-40 md:pb-32`,children:[e.jsxs(ua,{children:[e.jsx("title",{children:"Review | NoteStreamAI"}),e.jsx("meta",{name:"description",content:"Review and manage your NoteStream AI experience."})]}),e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n?e.jsx("div",{className:"w-16"}):e.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>
5h("/"),children:[e.jsx(Kt,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("h1",{className:"text-2xl font-bold",children:[K," remaining"]}),e.jsxs("button",{type:"button",onClick:()=>h("/settings#review-order"),className:"text-xs text-muted-foreground hover:text-primary underline underline-offset-2",title:"Change the review queue order in Settings",children:[H==="oldest"?"Oldest first":"Newest first"," · change"]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[oe&&e.jsxs(E,{variant:"outline",size:"sm",onClick:Ct,disabled:k,title:`Undo last ${oe.type}`,className:"text-primary hover:text-primary hover:bg-primary/10",children:[e.jsx(ma,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-1 text-xs hidden sm:inline",children:"Undo"})]}),e.jsx(E,{variant:"outline",size:"sm",onClick:()=>{rt(t=>!t),je(new Set)},title:Ce?"Back to card view":"View full list",children:Ce?e.jsx(Kt,{className:"h-4 w-4"}):e.jsx(kn,{className:"h-4 w-4"})}),e.jsx(E,{variant:"outline",size:"sm",onClick:()=>Ve(!0),title:"Voice mode — hands-free review",children:e.jsx(fa,{className:"h-4 w-4"})})]})]}),Ce?e.jsxs("div",{className:"space-y-3",children:[P.size>0&&e.jsxs("div",{className:"sticky top-0 z-10 bg-background border border-border rounded-lg p-3 flex items-center gap-3 shadow-sm",children:[e.jsxs("span",{className:"text-sm font-medium",children:[P.size," selected"]}),e.jsxs(E,{size:"sm",onClick:Ds,disabled:it,className:"bg-orange-500 hover:bg-orange-600 text-white text-xs",children:[e.jsx(tt,{className:"h-3.5 w-3.5 mr-1"}),"Mark Reviewed"]}),e.jsxs(E,{size:"sm",variant:"outline",onClick:As,disabled:it,className:"text-destructive hover:text-destructive text-xs",children:[e.jsx(st,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsx(E,{size:"sm",variant:"ghost",onClick:()=>je(new Set),className:"ml-auto text-xs",children:"Clear"})]}),e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx(Dt,{checked:P.size===g.length&&g.length>0,onCheckedChange:Os,id:"select-all"}),e.jsx("label",{htmlFor:"select-all",className:"text-sm text-muted-foreground cursor-pointer",children:P.size>0?`${P.size} of ${g.length} selected`:`${g.length} items`})]}),g.map(t=>{var v;const o=Nn(t),i=Sn(t),m=P.has(t.id);return e.jsxs("div",{className:`flex gap-3 items-start rounded-lg border p-3 cursor-pointer transition-colors ${m?"border-primary bg-primary/5":"border-border hover:bg-muted/50"}`,onClick:()=>wn(t.id),role:"button",tabIndex:0,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),wn(t.id))},children:[e.jsx(Dt,{checked:m,onCheckedChange:()=>Es(t.id),className:"mt-0.5 flex-shrink-0",onClick:y=>y.stopPropagation()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[e.jsx("span",{className:`px-2 py-0.5 ${i} text-xs rounded-full`,children:o}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(t.created_at).toLocaleDateString()}),t.note_type==="task"?e.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/10 text-blue-600 text-xs rounded",children:"Task"}):e.jsx("span",{className:"px-1.5 py-0.5 bg-slate-500/10 text-slate-600 text-xs rounded",children:"Note"}),(()=>{if(pt(t)!=="ai_response")return null;let y=null;if(t.external_service==="claude-cowork")y="Claude Cowork";else if(t.external_service==="claude-code")y="Claude Code";else{const S=j[t.id];y=S?Qt(S):"NoteStream AI"}return e.jsx("span",{className:"px-1.5 py-0.5 bg-emerald-500/10 text-emerald-600 text-xs rounded",children:y})})()]}),e.jsx("p",{className:"text-sm line-clamp-2 text-foreground",children:((v=t.content)==null?void 0:v.replace(/<[^>]*>/g,""))||"(empty)"})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0 flex-wrap justify-end",onClick:y=>y.stopPropagation(),children:[e.jsx(An,{noteId:t.id,compact:!0,variant:"ghost"}),e.jsx(En,{note:t,compact:!0,onCancelled:y=>x(S=>S.map(V=>V.id===y?{...V,ai_status:null,ai_completion_status:null,ai_cancelled_at:new Date().toISOString()}:V))}),e.jsx(E,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs text-orange-500",onClick:async()=>{await T.from("notes").update({needs_review:!1,reviewed_at:new Date().toISOString()}).eq("id",t.id),x(y=>y.filter(S=>S.id!==t.id)),_.success("Reviewed")},children:e.jsx(tt,{className:"h-3.5 w-3.5"})}),e.jsx(E,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs text-destructive",onClick:async()=>{await T.from("notes").update({deleted_at:new Date().toISOString()}).eq("id",t.id),x(y=>y.filter(S=>S.id!==t.id)),_.success("Deleted")},children:e.jsx(st,{className:"h-3.5 w-3.5"})})]})]},t.id)})]}):e.jsxs(Xt,{className:"p-4 sm:p-6 space-y-6 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[(()=>{const t=Nn(s),o=Sn(s),m=s.external_service==="claude-cowork"||s.external_service==="claude-code"||Cn(s)?`AI Response — ${t}`:t;return e.jsx("span",{className:`px-2 py-1 ${o} text-xs rounded-full`,children:m})})(),s.is_completed&&(s.source==="mcp"||s.source==="api")&&e.jsx("span",{className:"px-2 py-1 bg-amber-500/10 text-amber-600 text-xs rounded-full",children:"Closed via MCP"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(s.created_at).toLocaleDateString()}),(()=>{const t=ha(s);return t?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",children:e.jsxs(E,{variant:"outline",size:"sm",className:"h-6 text-xs gap-1",children:[e.jsx(pa,{className:"h-3 w-3"}),t.label]})}):null})(),s.original_text&&s.original_text!==s.content&&!(s.is_completed&&(s.source==="mcp"||s.source==="api"))&&e.jsxs(E,{variant:"outline",size:"sm",className:"h-6 text-xs gap-1",onClick:()=>qe(!0),children:[e.jsx(Tn,{className:"h-3 w-3"}),"Original"]}),e.jsx(An,{noteId:s.id,compact:!0}),e.jsx(En,{note:s,compact:!0,onCancelled:t=>{ye.current=ye.current.filter(o=>o.noteId!==t),ct(o=>o.filter(i=>i.noteId!==t)),x(o=>o.map(i=>i.id===t?{...i,ai_status:null,ai_completion_status:null,ai_cancelled_at:new Date().toISOString()}:i))}})]}),Ae&&s.original_text&&e.jsx(At,{open:Ae,onOpenChange:qe,children:e.jsxs(Et,{className:"max-w-lg",children:[e.jsx(Ot,{children:e.jsxs(Pt,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-4 w-4"})," Original Text"]})}),e.jsx("div",{className:"text-sm whitespace-pre-wrap text-muted-foreground bg-muted/30 rounded-md p-3 max-h-[50vh] overflow-y-auto",children:e.jsx(en,{children:s.original_text})})]})}),s.is_completed&&s.original_text&&(s.source==="mcp"||s.source==="api")&&e.jsxs("div",{className:"p-3 rounded-md bg-amber-500/5 border border-amber-500/20",children:[e.jsx(Be,{className:"text-xs text-muted-foreground",children:"Closure Reason"}),e.jsx("p",{className:"text-sm mt-1",children:e.jsx(en,{children:s.original_text})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{htmlFor:"content",children:"Content"}),e.jsx(La,{value:d,onChange:M,placeholder:"Enter content...",minHeight:"120px",onInlineImageUpload:a?Ns:void 0},s.id)]}),e.jsx(Ba,{noteId:s.id,showThumbnails:!0}),te==="task"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Be,{className:"flex items-center gap-1.5",children:[e.jsx(kn,{className:"h-3.5 w-3.5"}),"Sub-tasks",we.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",we.filter(t=>t.is_completed).length,"/",we.length,")"]})]}),we.length>0&&e.jsx(Na,{value:we.length>0?we.filter(t=>t.is_completed).length/we.length*100:0,className:"h-1.5"}),Ft?e.jsx("div",{className:"flex items-center justify-center py-2",children:e.jsx(De,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-1 ml-1",children:[we.map(t=>e.jsxs("div",{className:"flex items-center gap-2 group/st py-0.5 rounded hover:bg-muted/50",children:[e.jsx(Dt,{checked:t.is_completed,onCheckedChange:()=>bs(t),className:"h-3.5 w-3.5 flex-shrink-0"}),e.jsx("span",{className:`text-sm flex-1 min-w-0 truncate ${t.is_completed?"line-through text-muted-foreground":""}`,children:t.content}),e.jsx(E,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-0 group-hover/st:opacity-100 hover:text-destructive flex-shrink-0",onClick:()=>_s(t.id),children:e.jsx(st,{className:"h-3 w-3"})})]},t.id)),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(ln,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx(on,{value:vt,onChange:t=>Oe(t.target.value),placeholder:"Add sub-task...",className:"h-7 text-xs flex-1",disabled:Mt,onKeyDown:t=>{t.key==="Enter"&&ys(),t.key==="Escape"&&Oe("")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Be,{className:"flex items-center gap-1.5",children:[e.jsx(Wn,{className:"h-3.5 w-3.5"}),"Comments",me.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",me.length,")"]})]}),Lt?e.jsx("div",{className:"flex items-center justify-center py-2",children:e.jsx(De,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-2",children:[me.length===0&&!dt&&e.jsx("p",{className:"text-xs text-muted-foreground py-1",children:"No comments yet"}),me.map(t=>e.jsxs("div",{className:"flex gap-2 group/cmt",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 rounded-full bg-primary/10 text-primary flex items-center justify-center text-[10px] font-semibold mt-0.5",children:t.author_type==="ai"?e.jsx(nt,{className:"h-3.5 w-3.5"}):(t.display_name||"U")[0].toUpperCase()}),e.jsxs("div",{className:t.author_type==="ai"?"flex-1 min-w-0 "+Fn:"flex-1 min-w-0",children:[(()=>{const o=t.source_comment_id?me.find(m=>m.id===t.source_comment_id):null;if(!o)return null;const i=o.author_type==="ai"?Qt(o.ai_model):a&&o.user_id===a.id?"You":o.display_name||"User";return e.jsxs("div",{className:"text-[10px] text-muted-foreground mb-0.5",children:["in reply to ",i]})})(),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium truncate",children:t.author_type==="ai"?Qt(t.ai_model):t.display_name}),t.author_type==="ai"&&e.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wide px-1 py-0.5 rounded bg-primary/10 text-primary flex-shrink-0",children:"AI"}),e.jsx("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:xa(new Date(t.created_at),{addSuffix:!0})}),e.jsx(E,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 ml-auto opacity-0 group-hover/cmt:opacity-100 hover:text-primary",title:"Save as note",onClick:()=>kt(t.content),children:e.jsx(ga,{className:"h-3 w-3"})}),a&&t.user_id===a.id&&e.jsx(E,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-0 group-hover/cmt:opacity-100 hover:text-destructive",onClick:()=>ks(t.id),children:e.jsx(st,{className:"h-3 w-3"})})]}),t.author_type==="ai"?e.jsx("div",{className:"text-xs text-foreground
5/80 break-words [&_a]:text-primary [&_a]:underline [&_pre]:overflow-x-auto [&_pre]:text-[11px]",children:e.jsx(Dn,{content:t.content})}):Ta(t.content)?e.jsx("div",{className:"text-xs text-foreground/80 break-words",children:e.jsx(Dn,{content:t.content})}):e.jsx("p",{className:"text-xs text-foreground/80 whitespace-pre-wrap break-words",children:e.jsx(en,{children:t.content})})]})]},t.id)),dt&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 rounded-full bg-primary/10 text-primary flex items-center justify-center mt-0.5",children:e.jsx(nt,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"flex-1 min-w-0 "+Fn,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium truncate",children:dt.label}),e.jsx(De,{className:"h-3 w-3 animate-spin text-muted-foreground"}),e.jsx(E,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs ml-auto",disabled:ws===dt.noteId,onClick:()=>vs(dt.noteId),"aria-label":"Stop the AI",children:"Stop"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Thinking… the reply will appear here."})]})]}),J?e.jsx("div",{className:"pt-1 border-t border-border/50",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"This note was shared with you. Acknowledge it to open the note before commenting."})}):e.jsx("div",{className:"pt-1 border-t border-border/50 space-y-1.5",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Vn,{value:We,onChange:t=>Je(t.target.value),onPaste:Ss(We,Je),onKeyDown:t=>{var o;t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),(o=Te.current)==null||o.call(Te))},placeholder:"Add a comment, or send it to the AI \\u2192",className:"text-xs min-h-[36px] max-h-[80px] resize-none flex-1"}),s&&a&&e.jsx(Sr,{note:s,comments:me,thread:L.find(t=>t.id===s.thread_id),userId:a.id,prompt:We,onPromptConsumed:()=>Je(""),suppressReviewFlag:!0,disabled:bt,onMethodChange:le,onSubmitted:()=>{Ne(),et()},onSendStarted:t=>zt(s,w,t),onSendFailed:()=>gs(s.id),onCommentOnly:js,registerSend:t=>{Te.current=t}})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{children:"Thread"}),e.jsxs(Kn,{open:$t,onOpenChange:t=>{Ke(t),t||_e("")},children:[e.jsx(Gn,{asChild:!0,children:e.jsxs(E,{variant:"outline",className:"w-full justify-between font-normal",children:[e.jsxs("span",{className:"flex items-center gap-2 truncate",children:[e.jsx(In,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),q&&((vn=L.find(t=>t.id===q))==null?void 0:vn.title)||"Select a thread"]}),e.jsx(Yn,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]})}),e.jsxs(Zn,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:[e.jsx("div",{className:"p-2",children:e.jsx(on,{autoFocus:!0,placeholder:"Search threads...",value:pe,onChange:t=>_e(t.target.value),className:"h-8"})}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto",children:jn(L).filter(t=>!pe||t.title.toLowerCase().includes(pe.toLowerCase())).map(t=>e.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-accent cursor-pointer",onClick:()=>{W(t.id),Ke(!1),_e("")},children:[e.jsx(In,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate flex-1 text-left",children:t.title}),q===t.id&&e.jsx(rn,{className:"h-4 w-4 shrink-0 text-primary"})]},t.id))}),e.jsx("div",{className:"border-t p-1",children:e.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-accent cursor-pointer rounded-sm",onClick:async()=>{const t=pe.trim()||"New Thread";try{const{data:{session:o}}=await T.auth.getSession(),i=await T.functions.invoke("create-thread",{body:{title:t},headers:{Authorization:`Bearer ${o==null?void 0:o.access_token}`}});if(i.error)throw i.error;const m=i.data;$(v=>[...v,{...m,user_id:a.id,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),is_default:!1,is_starred:!1,is_system:!1,is_public:!1,deleted_at:null,url:null,ai_summary:null,ai_summary_updated_at:null,public_token:null,product_context:null,github_repo:null,target_branch:null,lovable_project_url:null}]),W(m.id),Ke(!1),_e(""),_.success(`Thread "${m.title}" created`)}catch{_.error("Failed to create thread")}},children:[e.jsx(ln,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{children:pe.trim()?`Create thread: "${pe.trim()}"`:"Create New Thread"})]})})]})]})]}),s.note_type==="task"&&e.jsx("div",{className:"space-y-2",children:re?e.jsxs(E,{variant:"outline",onClick:()=>he(!0),className:"w-full justify-start gap-2",children:[e.jsx(wa,{className:"h-4 w-4 text-orange-500"}),e.jsxs("span",{children:["Reminder: ",va(new Date(re.reminder_time),"MMM d, yyyy 'at' h:mm a")]})]}):e.jsx(E,{variant:"outline",onClick:()=>he(!0),className:"w-full",children:"Set Reminder"})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[e.jsx(qa,{variant:"pill",isCompleted:!!s.is_completed,customStatusId:s.custom_status_id,statuses:f,onSelectStatus:async(t,o)=>{const i={is_completed:o,custom_status_id:t,updated_at:new Date().toISOString(),...o?Rn(s):{}},{error:m}=await T.from("notes").update(i).eq("id",s.id);if(m){_.error("Failed to update status");return}await St(),await Ne()}}),(()=>{const t=s,o=me.some(v=>(v.content||"").startsWith("AI Builder completed this task"));return!s.is_completed?null:o?e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-violet-100 text-violet-900 dark:bg-violet-500/15 dark:text-violet-300",title:"This task was closed by AI Builder",children:[e.jsx(nt,{className:"h-3 w-3"}),"Closed by AI"]}):t.source==="mcp"||t.source==="api"||t.external_service==="claude-cowork"||t.external_service==="claude-code"?e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-purple-100 text-purple-900 dark:bg-purple-500/15 dark:text-purple-300",title:"This task was closed via automation (MCP / Cowork)",children:[e.jsx(nt,{className:"h-3 w-3"}),"Closed via MCP"]}):null})()]}),(()=>{const t=pt(s),o=t==="ai_response",i=oe&&e.jsx(E,{variant:"outline",onClick:Ct,disabled:k,title:`Undo last ${oe.type}`,className:"text-primary hover:text-primary hover:bg-primary/10 flex-shrink-0",children:e.jsx(Kt,{className:"h-4 w-4"})}),m=e.jsx(E,{variant:"outline",onClick:Ut,disabled:k,title:"Delete item",className:"text-destructive hover:text-destructive hover:bg-destructive/10 flex-shrink-0",children:e.jsx(st,{className:"h-4 w-4"})}),v=e.jsxs(E,{variant:"outline",onClick:Vt,disabled:k,className:"flex-shrink-0",children:[e.jsx(ya,{className:"h-4 w-4 mr-2"}),"Skip for Now"]}),y=s&&a&&!J?e.jsx(Qn,{note:s,comments:me,thread:L.find(se=>se.id===s.thread_id),userId:a.id,suppressReviewFlag:!0,onMethodChange:le,onSubmitted:et,trigger:e.jsxs(E,{variant:"outline",className:"flex-shrink-0",disabled:k,title:`Assign to ${xe}`,children:[e.jsx(nt,{className:"h-4 w-4 mr-2"}),xe]})}):null;if(t==="share")return e.jsx("div",{className:`${n?"sticky bottom-0 -mx-4":"fixed bottom-0 left-0 right-0"} z-40 bg-background border-t border-border px-4 md:px-8 py-3 shadow-[0_-2px_8px_rgba(0,0,0,0.04)]`,style:n?void 0:{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom))"},children:e.jsxs("div",{className:"max-w-3xl mx-auto flex flex-wrap gap-2 sm:gap-3",children:[i,m,v,e.jsxs(E,{onClick:mt,disabled:k,className:"flex-1 min-w-0 bg-orange-500 hover:bg-orange-600 text-white",children:[e.jsx(tt,{className:"h-4 w-4 mr-2"}),"Acknowledge"]})]})});const S=e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t==="email_note"&&e.jsxs(E,{variant:"outline",size:"sm",className:"text-xs text-primary border-primary/40 hover:bg-primary/10",onClick:()=>ut("task"),children:[e.jsx(Zt,{className:"h-3 w-3 mr-1"}),"Convert to Task"]}),t==="email_task"&&e.jsxs(E,{variant:"outline",size:"sm",className:"text-xs text-primary border-primary/40 hover:bg-primary/10",onClick:()=>ut("note"),children:[e.jsx(Zt,{className:"h-3 w-3 mr-1"}),"Convert to Note"]}),o&&e.jsxs(E,{variant:"outline",size:"sm",className:"text-xs text-primary border-primary/40 hover:bg-primary/10",onClick:()=>ut("note"),children:[e.jsx(Zt,{className:"h-3 w-3 mr-1"}),"Convert to Note"]})]});let V;return t==="email_note"?V=e.jsxs("div",{className:"flex flex-wrap gap-2 sm:gap-3 pt-4",children:[i,m,v,y,e.jsxs(E,{variant:"outline",onClick:qt,disabled:k,className:"flex-shrink-0",title:"Archive (removes from queue and thread views)",children:[e.jsx(ba,{className:"h-4 w-4 mr-2"}),"Archive"]}),e.jsxs(E,{onClick:mt,disabled:k,className:"flex-1 min-w-0 bg-orange-500 hover:bg-orange-600 text-white",children:[e.jsx(tt,{className:"h-4 w-4 mr-2"}),k?"Saving...":"Mark Reviewed"]})]}):t==="email_task"?V=e.jsxs("div",{className:"flex flex-wrap gap-2 sm:gap-3 pt-4",children:[i,m,v,y,e.jsxs(E,{onClick:mt,disabled:k,className:"flex-1 min-w-0 bg-orange-500 hover:bg-orange-600 text-white",children:[e.jsx(tt,{className:"h-4 w-4 mr-2"}),k?"Saving...":"Mark Reviewed"]})]}):V=e.jsxs("div",{className:"flex flex-wrap gap-2 sm:gap-3 pt-4",children:[i,m,v,e.jsxs(E,{variant:"outline",onClick:()=>Se(!0),disabled:k,className:"flex-shrink-0",title:"Send back for another AI pass",children:[e.jsx(_a,{className:"h-4 w-4 mr-2"}),"Revise"]}),e.jsxs(E,{variant:"outline",onClick:Cs,disabled:k,className:"flex-shrink-0",title:"Open Claude in a new tab to check this against the live site",children:[e.jsx(ja,{className:"h-4 w-4 mr-2"}),"Verify with Claude"]}),e.jsxs(E,{onClick:Bt,disabled:k,className:"flex-1 min-w-0 bg-green-600 hover:bg-green-700 text-white ml-auto",children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Mark Complete"]})]}),e.jsxs(e.Fragment,{children:[S,e.jsx("div",{className:`${n?"sticky bottom-0 -mx-4":"fixed bottom-0 left-0 right-0"} z-40 bg-background border-t border-border px-4 md:px-8 py-3 shadow-[0_-2px_8px_rgba(0,0,0,0.04)]`,style:n?void 0:{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom))"},children:e.jsx("div",{className:"max-w-3xl mx-auto",children:V})})]})})()]})]}),ne&&e.jsx($a,{open:ne,onOpenChange:he,onSetReminder:Is,existingReminder:ge,onDeleteReminder:Rs}),s&&He&&a&&e.jsx(u.Suspense,{fallback:null,children:e.jsx(Ar,{open:He,onOpenChange:Se,noteId:s.id,userId:a.id,variant:Cn(s)?"notestream":"cowork",onSubmitted:async()=>{await St()}})}),s&&Ge&&a&&e.jsx(xs,{open:Ge,onOpenChange:Ze,noteId:s.id,noteContent:s.content,threadId:s.thread_id,userId:a.id,onSplitComplete:()=>{Ze(!1),x(t=>t.filter(o=>
5o.id!==s.id)),w>0&&O(w-1),_.success("Task split successfully")}}),Me&&a&&e.jsx(u.Suspense,{fallback:null,children:e.jsx(Hn,{open:Me,onClose:()=>Ve(!1),item:s??null,nextItem:g[w+1]??null,kind:s?pt(s):"email_note",comments:me,thread:L.find(t=>t.id===(s==null?void 0:s.thread_id))??null,user:a,index:w,total:g.length,isProcessing:k,lastAction:oe,onUndo:Ct,onDelete:Ut,onSkip:Vt,onMarkReviewed:mt,onMarkComplete:Bt,onArchive:qt,onRevise:()=>Se(!0),onConvertType:ut,onAddComment:gn,suppressReviewFlag:!0,onMethodChange:le,onSubmitted:()=>{Ne(),et()},onAssistantApplied:xn})}),lt!==null&&a&&e.jsx(br,{open:lt!==null,onOpenChange:t=>{t||kt(null)},initialContent:lt,initialThreadId:(s==null?void 0:s.thread_id)??null,userId:a.id})]}):e.jsxs("div",{className:`${n?"h-full":"min-h-screen"} flex items-center justify-center p-4`,children:[e.jsxs(Xt,{className:"p-8 text-center max-w-md",children:[Re.length>0?e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"h-16 w-16 text-primary mx-auto mb-4 animate-spin"}),e.jsx("h2",{className:"text-2xl font-semibold mb-2",children:"Waiting on the AI"}),e.jsxs("p",{className:"text-muted-foreground mb-6",children:[Re.length," ",Re.length===1?"task is":"tasks are"," with the AI. They'll come back here as soon as it answers."]})]}):e.jsxs(e.Fragment,{children:[e.jsx(tt,{className:"h-16 w-16 text-green-500 mx-auto mb-4"}),e.jsx("h2",{className:"text-2xl font-semibold mb-2",children:"All Caught Up!"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"You have no items to review."})]}),!n&&e.jsx(E,{onClick:()=>
5h("/"),children:"Return to Home"})]}),Me&&a&&e.jsx(u.Suspense,{fallback:null,children:e.jsx(Hn,{open:Me,onClose:()=>Ve(!1),item:s??null,nextItem:g[w+1]??null,kind:s?pt(s):"email_note",comments:me,thread:L.find(t=>t.id===(s==null?void 0:s.thread_id))??null,user:a,index:w,total:g.length,isProcessing:k,lastAction:oe,onUndo:Ct,onDelete:Ut,onSkip:Vt,onMarkReviewed:mt,onMarkComplete:Bt,onArchive:qt,onRevise:()=>Se(!0),onConvertType:ut,onAddComment:gn,suppressReviewFlag:!0,onMethodChange:le,onSubmitted:()=>{Ne(),et()},timeZone:F,onAssistantApplied:xn})})]}):e.jsx("div",{className:`${n?"h-full":"min-h-screen"} flex items-center justify-center p-4`,children:e.jsxs(Xt,{className:"p-8 text-center max-w-md",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-2",children:"Sign In Required"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Please sign in to review your items."}),e.jsx(E,{onClick:()=>h("/auth"),children:"Sign In"})]})})}const Xr=Object.freeze(Object.defineProperty({__proto__:null,default:Er},Symbol.toStringTag,{value:"Module"}));export{br as C,ds as D,en as L,Ba as N,Er as R,qa as S,Fn as a,ms as b,fs as c,hs as d,vr as e,Wr as f,Yr as g,Xr as h};

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.