1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];if(null!=t)for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],{"_sentryBundlerPluginAppKey:notetube-web":!0});var s=(new e.Error).stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="bfb3dfaf-e9b5-49b3-8a7d-73fea7051f28",e._sentryDebugIdIdentifier="sentry-dbid-bfb3dfaf-e9b5-49b3-8a7d-73fea7051f28")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8867],{58867:(e,s,t)=>{t.r(s),t.d(s,{default:()=>ee});var a=t(54568),r=t(7620),n=t(97066),l=t(78227),i=t(6845),o=t(92779),d=t(29464),c=t(12494),u=t(65202),m=t(85846),x=t(34543),h=t(17478),g=t(64751),f=t(38391),p=t(66056),v=t(91926),b=t(19134),w=t(2043),j=t(92068);let N=(0,j.A)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);var y=t(60844);let k=(0,j.A)("trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]]);var E=t(87551),C=t(74624),A=t(75892),T=t(826),S=t(64658);function _(e){let{note:s,viewMode:t,isLoading:l=!1,onClick:o,onEdit:d,onDelete:c,onPin:u,onVisibilityChange:m,isPurchased:x=!1}=e,h=(0,n.c)("notes"),g=(0,p.Ym)(),[f,j]=(0,r.useState)(!1),[_,U]=(0,r.useState)(!1),[M,P]=(0,r.useState)(!1),D=async e=>{e.stopPropagation(),U(!0),P(!0),setTimeout(()=>{null==c||c(e)},300)},F=e=>{let s=new Date(e),t=new Date,a=(t.getTime()-s.getTime())/36e5;return a<24?a<1?h("web.card.minsAgo",{n:Math.floor(60*a)}):h("web.card.hoursAgo",{n:Math.floor(a)}):a<168?h("web.card.daysAgo",{n:Math.floor(a/24)}):s.toLocaleDateString(g,{month:"short",day:"numeric",year:s.getFullYear()!==t.getFullYear()?"numeric":void 0})},L=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:150,t=e.split("\n"),a="";for(let e of t){if(a.length+e.length>s){if(0===a.length)return e.substring(0,s)+"...";break}a+=(a?"\n":"")+e}return a||e.substring(0,s)+(e.length>s?"...":"")},R=x?null:(0,a.jsxs)(v.rI,{open:f,onOpenChange:j,children:[(0,a.jsx)(v.ty,{asChild:!0,onClick:e=>e.stopPropagation(),children:(0,a.jsx)(i.$,{variant:"ghost",size:"icon",className:"h-8 w-8 cursor-pointer md:opacity-0 md:group-hover:opacity-100 transition-all duration-200 hover:bg-foreground
1/5 rounded-lg flex-shrink-0",children:(0,a.jsx)(b.A,{className:"h-4 w-4 text-muted-foreground"})})}),(0,a.jsxs)(v.SQ,{align:"end",className:"w-48 rounded-xl shadow-lg border border-border/60",children:[(0,a.jsxs)(v._2,{onClick:d,className:"cursor-pointer text-sm font-medium py-2.5 rounded-lg",children:[(0,a.jsx)(w.A,{className:"mr-2 h-3.5 w-3.5"}),h("actions.edit")]}),(0,a.jsxs)(v._2,{onClick:u,className:"cursor-pointer text-sm font-medium py-2.5 rounded-lg",children:[(0,a.jsx)(N,{className:"mr-2 h-3.5 w-3.5"}),s.is_pinned?h("actions.unpin"):h("actions.pin")]}),(0,a.jsx)(v.mB,{}),(0,a.jsx)("div",{className:"px-1 py-1",onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,a.jsx)(S.H,{contentType:"notes",rowId:s.id,compact:!0,onVisibilityChange:e=>null==m?void 0:m(s.id,{visibility:e.visibility,slug:e.slug})})}),(0,a.jsx)(v.mB,{}),(0,a.jsx)(v._2,{onClick:D,className:"text-destructive cursor-pointer text-sm font-medium py-2.5 rounded-lg",disabled:_,children:_?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(y.A,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),h("web.card.deleting")]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(k,{className:"mr-2 h-3.5 w-3.5"}),h("actions.delete")]})})]})]});return"list"===t?(0,a.jsxs)("div",{className:(0,T.cn)("group relative rounded-xl bg-card transition-all duration-200 cursor-pointer","border border-border/50 shadow-[var(--shadow-2xs)]","hover:shadow-[var(--shadow-sm)] hover:border-border",M&&"opacity-0 scale-95 translate-x-4",_&&"pointer-events-none",s.is_pinned&&"ring-1 ring-[var(--tab-notes-icon)]/20 bg-[var(--tab-notes-bg)]/30"),onClick:o,children:[l&&(0,a.jsx)("div",{className:"absolute inset-0 bg-background/90 backdrop-blur-sm flex items-center justify-center z-10 rounded-xl",children:(0,a.jsxs)("div",{className:"flex items-center gap-2.5 px-4 py-2 bg-card rounded-lg shadow-[var(--shadow-sm)]",children:[(0,a.jsx)(y.A,{className:"h-4 w-4 animate-spin text-primary"}),(0,a.jsx)("span",{className:"text-sm text-muted-foreground font-medium",children:h("web.card.opening")})]})}),(0,a.jsxs)("div",{className:"p-4 flex items-start gap-3",children:[s.is_pinned&&(0,a.jsx)("div",{className:"w-1 self-stretch -ml-4 mr-2 rounded-l-xl bg-[var(--tab-notes-icon)]/60"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[s.is_pinned&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-semibold bg-[var(--tab-notes-bg)] text-[var(--tab-notes-icon)]",children:[(0,a.jsx)(N,{className:"h-3 w-3 fill-current"}),h("web.card.pinned")]}),!x&&("public"===s.visibility||"unlisted"===s.visibility)&&s.slug&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-semibold bg-emerald-50 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400",children:[(0,a.jsx)(E.A,{className:"h-3 w-3"}),h("web.card.published")]})]}),(0,a.jsx)("h3",{className:"text-[15px] font-semibold text-foreground group-hover:text-primary transition-colors duration-200 mb-1 truncate",children:s.title}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground/80 leading-relaxed line-clamp-2 mb-3",children:L(s.content,120)}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)(C.A,{className:"h-3 w-3"}),F(s.updated_at)]}),(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground bg-foreground
1/[0.03] px-2 py-0.5 rounded-md",children:[(0,a.jsx)(A.A,{className:"h-3 w-3"}),h("card.words",{n:Number(s.word_count)})]})]}),s.tags&&s.tags.length>0&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.tags.slice(0,3).map(e=>(0,a.jsx)("div",{className:"h-2.5 w-2.5 rounded-full ring-2 ring-card",style:{backgroundColor:e.color},title:e.name},e.id)),s.tags.length>3&&(0,a.jsxs)("span",{className:"text-[11px] text-muted-foreground font-medium",children:["+",s.tags.length-3]})]})]})]}),R]})]}):(0,a.jsxs)("div",{className:(0,T.cn)("group relative rounded-xl bg-card h-52 md:h-56 flex flex-col cursor-pointer overflow-hidden","border border-border/50 shadow-[var(--shadow-2xs)]","hover:shadow-[var(--shadow-sm)] hover:border-border transition-all duration-200",M&&"opacity-0 scale-90",_&&"pointer-events-none",s.is_pinned&&"ring-1 ring-[var(--tab-notes-icon)]/20 bg-[var(--tab-notes-bg)]/30"),onClick:o,children:[l&&(0,a.jsx)("div",{className:"absolute inset-0 bg-background/90 backdrop-blur-sm flex items-center justify-center z-10 rounded-xl",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-2.5",children:[(0,a.jsx)(y.A,{className:"h-5 w-5 animate-spin text-primary"}),(0,a.jsx)("span",{className:"text-sm text-muted-foreground font-medium",children:h("web.card.opening")})]})}),s.is_pinned&&(0,a.jsx)("div",{className:"h-1 bg-gradient-to-r from-[var(--tab-notes-icon)]/60 to-[var(--tab-notes-icon)]/20"}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col p-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap min-w-0",children:[s.is_pinned&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-semibold bg-[var(--tab-notes-bg)] text-[var(--tab-notes-icon)]",children:[(0,a.jsx)(N,{className:"h-2.5 w-2.5 fill-current"}),h("web.card.pinned")]}),!x&&("public"===s.visibility||"unlisted"===s.visibility)&&s.slug&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-semibold bg-emerald-50 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400",children:[(0,a.jsx)(E.A,{className:"h-2.5 w-2.5"}),h("web.card.published")]})]}),R]}),(0,a.jsx)("h3",{className:"text-sm font-semibold text-foreground group-hover:text-primary transition-colors duration-200 truncate mb-2",children:s.title}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground/80 flex-1 overflow-hidden line-clamp-3 md:line-clamp-4 leading-relaxed",children:L(s.content,120)}),(0,a.jsx)("div",{className:"mt-auto pt-3 border-t border-border/40",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"flex items-center gap-2",children:s.tags&&s.tags.length>0&&(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[s.tags.slice(0,4).map(e=>(0,a.jsx)("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:e.color},title:e.name},e.id)),s.tags.length>4&&(0,a.jsxs)("span",{className:"text-[10px] text-muted-foreground font-medium ml-0.5",children:["+",s.tags.length-4]})]})}),(0,a.jsxs)("div",{className:"flex items-center gap-2.5 text-[11px] text-muted-foreground",children:[(0,a.jsx)("span",{children:F(s.updated_at)}),(0,a.jsx)("span",{className:"text-border",children:"|"}),(0,a.jsx)("span",{children:h("card.words",{n:Number(s.word_count)})})]})]})})]})]})}var U=t(20488);function M(e){let{children:s,delay:t=0,className:r}=e;return(0,a.jsx)("div",{className:(0,T.cn)("animate-cascade",r),style:{animationDelay:"".concat(t,"ms")},children:s})}function P(e){let{viewMode:s="list",count:t=4,variant:r="list"}=e;return"list"===r?(0,a.jsxs)("div",{className:"h-full",children:[(0,a.jsx)(M,{delay:0,children:(0,a.jsxs)("div",{className:"p-4 md:p-6 bg-background",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4 md:mb-5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(U.EA,{className:"h-9 w-9 rounded-xl"}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,a.jsx)(U.EA,{className:"h-7 w-16"}),(0,a.jsx)(U.EA,{className:"h-5 w-8 rounded-full"})]}),(0,a.jsx)(U.EA,{className:"h-4 w-48 hidden md:block"})]})]}),(0,a.jsx)(U.EA,{className:"h-9 w-28 rounded-xl"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(U.EA,{className:"h-9 flex-1 max-w-md rounded-xl"}),(0,a.jsx)(U.EA,{className:"h-9 w-[72px] rounded-xl"})]})]})}),(0,a.jsx)("div",{className:"h-px bg-border/60 mx-4 md:mx-6"}),(0,a.jsx)("div",{className:"p-4 md:p-6",children:(0,a.jsx)("div",{className:(0,T.cn)("grid"===s?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3":"flex flex-col gap-2"),children:Array.from({length:t},(e,t)=>(0,a.jsx)(M,{delay:200+120*t,children:(0,a.jsx)(D,{viewMode:s})},t))})})]}):"card"===r?(0,a.jsx)("div",{className:(0,T.cn)("grid"===s?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3":"flex flex-col gap-2","p-4 md:p-6"),children:Array.from({length:t},(e,t)=>(0,a.jsx)(M,{delay:100*t,children:(0,a.jsx)(D,{viewMode:s})},t))}):"editor"===r?(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[(0,a.jsx)(M,{delay:0,children:(0,a.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center gap-3 px-4 md:px-5 py-3 border-b border-border/60",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 flex-1",children:[(0,a.jsx)(U.EA,{className:"h-9 flex-1 rounded-xl"}),(0,a.jsx)(U.EA,{className:"h-9 w-9 rounded-xl"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between md:justify-end gap-2.5",children:[(0,a.jsx)(U.EA,{className:"h-9 w-[104px] rounded-xl"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(U.EA,{className:"h-9 w-16 rounded-xl"}),(0,a.jsx)(U.EA,{className:"h-9 w-20 rounded-xl"})]})]})]})}),(0,a.jsx)("div",{className:"flex-1 p-4 md:p-5",children:(0,a.jsx)(M,{delay:100,children:(0,a.jsx)(U.EA,{className:"h-full min-h-[300px] w-full rounded-xl"})})}),(0,a.jsx)(M,{delay:200,children:(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 md:px-5 py-2 border-t border-border/40",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(U.EA,{className:"h-4 w-16"}),(0,a.jsx)(U.EA,{className:"h-4 w-14"})]}),(0,a.jsx)(U.EA,{className:"h-4 w-24"})]})})]}):"viewer"===r?(0,a.jsxs)("div",{className:"h-full relative bg-background",children:[(0,a.jsx)(M,{delay:0,children:(0,a.jsxs)("div",{className:"absolute top-3 left-3 right-3 z-10 flex items-center justify-between gap-2",children:[(0,a.jsx)(U.EA,{className:"h-11 w-48 md:w-64 roun
1ded-xl"}),(0,a.jsx)(U.EA,{className:"h-11 w-36 md:w-48 rounded-xl"})]})}),(0,a.jsx)("div",{className:"pt-16 md:pt-[68px] px-4 md:px-6",children:(0,a.jsxs)("div",{className:"max-w-3xl mx-auto space-y-4",children:[(0,a.jsx)(M,{delay:100,children:(0,a.jsx)(U.EA,{className:"h-9 w-3/5"})}),(0,a.jsx)(M,{delay:150,children:(0,a.jsxs)("div",{className:"flex items-center gap-3 pb-5 border-b border-border/40",children:[(0,a.jsx)(U.EA,{className:"h-4 w-24"}),(0,a.jsx)(U.EA,{className:"h-4 w-20"})]})}),(0,a.jsx)("div",{className:"space-y-3 pt-2",children:[100,95,80,100,88,72,100,65].map((e,s)=>(0,a.jsx)(M,{delay:200+60*s,children:(0,a.jsx)(U.EA,{className:"h-4",style:{width:"".concat(e,"%")}})},s))})]})})]}):null}function D(e){let{viewMode:s}=e;return"list"===s?(0,a.jsx)("div",{className:"rounded-xl border border-border/30 bg-card p-4",children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0 space-y-2.5",children:[(0,a.jsx)(U.EA,{className:"h-[18px] w-40"}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(U.EA,{className:"h-3.5 w-full"}),(0,a.jsx)(U.EA,{className:"h-3.5 w-4/5"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 pt-1",children:[(0,a.jsx)(U.EA,{className:"h-3.5 w-14"}),(0,a.jsx)(U.EA,{className:"h-3.5 w-20 rounded-md"})]})]}),(0,a.jsx)(U.EA,{className:"h-8 w-8 rounded-lg flex-shrink-0"})]})}):(0,a.jsxs)("div",{className:"rounded-xl border border-border/30 bg-card h-52 md:h-56 flex flex-col p-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,a.jsx)(U.EA,{className:"h-5 w-16 rounded-full"}),(0,a.jsx)(U.EA,{className:"h-8 w-8 rounded-lg"})]}),(0,a.jsx)(U.EA,{className:"h-4 w-3/4 mb-2"}),(0,a.jsx)("div",{className:"flex-1 space-y-1.5",children:[90,100,75].map((e,s)=>(0,a.jsx)(U.EA,{className:"h-3",style:{width:"".concat(e,"%")}},s))}),(0,a.jsx)("div",{className:"mt-auto pt-3 border-t border-border/30",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"flex gap-1",children:[1,2,3].map(e=>(0,a.jsx)(U.EA,{className:"h-2 w-2 rounded-full"},e))}),(0,a.jsx)(U.EA,{className:"h-3 w-20"})]})})]})}function F(e){let{isVisible:s,children:t}=e;return(0,a.jsx)("div",{className:(0,T.cn)("absolute inset-0 transition-all duration-500 ease-in-out",s?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:t})}let L=(0,r.memo)(function(e){let{notes:s,loading:t,viewMode:r,loadingNoteId:l,onNoteClick:i,onNoteEdit:o,onNoteDelete:d,onNotePin:c,onNoteVisibilityChange:u,isPurchased:m=!1}=e,x=(0,n.c)("notes"),h=[...s].sort((e,s)=>e.is_pinned&&!s.is_pinned?-1:!e.is_pinned&&s.is_pinned?1:new Date(s.updated_at).getTime()-new Date(e.updated_at).getTime());return t&&0===s.length?(0,a.jsx)(F,{isVisible:!0,children:(0,a.jsx)(P,{viewMode:r,variant:"card",count:4})}):t&&s.length>0?(0,a.jsxs)("div",{className:"relative h-full",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-background/80 backdrop-blur-sm flex items-center justify-center z-10",children:(0,a.jsxs)("div",{className:"flex items-center gap-2.5 px-4 py-2.5 bg-card rounded-xl shadow-[var(--shadow-sm)] border border-border/50",children:[(0,a.jsx)(y.A,{className:"h-4 w-4 animate-spin text-primary"}),(0,a.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:x("web.list.refreshing")})]})}),(0,a.jsx)(R,{notes:h,viewMode:r,loadingNoteId:l,onNoteClick:i,onNoteEdit:o,onNoteDelete:d,onNotePin:c,onNoteVisibilityChange:u,isPurchased:m})]}):(0,a.jsx)(F,{isVisible:!0,children:(0,a.jsx)(R,{notes:h,viewMode:r,loadingNoteId:l,onNoteClick:i,onNoteEdit:o,onNoteDelete:d,onNotePin:c,onNoteVisibilityChange:u,isPurchased:m})})});function R(e){let{notes:s,viewMode:t,loadingNoteId:r,onNoteClick:n,onNoteEdit:l,onNoteDelete:i,onNotePin:o,onNoteVisibilityChange:d,isPurchased:c=!1}=e;return(0,a.jsx)("div",{className:"grid"===t?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3 p-4 md:p-6":"flex flex-col gap-2 p-4 md:p-6",children:s.map(e=>(0,a.jsx)(_,{note:e,viewMode:t,isLoading:r===e.id,onClick:()=>n(e),onEdit:l?s=>{s.stopPropagation(),l(e)}:void 0,onDelete:i?s=>{s.stopPropagation(),i(e)}:void 0,onPin:o?s=>{s.stopPropagation(),o(e)}:void 0,onVisibilityChange:c?void 0:d,isPurchased:c},e.id))})}var z=t(64715),V=t(68350);let O=(0,j.A)("split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]);var I=t(70783),H=t(40590),B=t(66970),$=t(99935),J=t(28653),K=t(65246),Y=t(69885);function q(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",[s,t]=(0,r.useState)(e),[a,n]=(0,r.useState)(!1),l=(0,r.useRef)(e);(0,r.useEffect)(()=>{l.current=e,t(e),n(!1)},[e]);let i=(0,r.useCallback)(e=>{console.log("[useUnsavedChanges] updateValue called",{newLength:e.length,lastSavedLength:l.current.length,isDifferent:e!==l.current}),t(e),n(e!==l.current)},[]),o=(0,r.useCallback)(()=>{console.log("[useUnsavedChanges] markAsSaved called",{currentValue:s.substring(0,50)+"...",valueLength:s.length}),l.current=s,n(!1)},[s]);return{value:s,setValue:i,hasUnsavedChanges:a,markAsSaved:o,reset:(0,r.useCallback)(()=>{t(l.current),n(!1)},[])}}let G=(0,r.forwardRef)((e,s)=>{let{note:t,sessionId:l,onSave:d,onCancel:c}
1=e,u=(0,n.c)("notes"),m=(0,p.Ym)(),x=q((null==t?void 0:t.title)||""),h=q((null==t?void 0:t.content)||""),g=x.value,v=h.value,b=x.setValue,j=h.setValue,[y,k]=(0,r.useState)((null==t?void 0:t.is_pinned)||!1),[E,C]=(0,r.useState)((null==t?void 0:t.tags)||[]),[A,S]=(0,r.useState)("split"),[_,U]=(0,r.useState)(!1),[M,P]=(0,r.useState)(null),D=(0,r.useRef)(""),F=(0,r.useRef)(""),{tags:L}=function(){let[e,s]=(0,r.useState)([]),[t,a]=(0,r.useState)(!1),[n,l]=(0,r.useState)(null),i=(0,r.useCallback)(async()=>{a(!0),l(null);try{let e=await fetch("/api/notes/tags",{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok){let s=await e.json().catch(()=>({}));throw Error(s.error||"HTTP ".concat(e.status,": ").concat(e.statusText))}let t=await e.json();s(t.tags||[])}catch(e){l(e instanceof Error?e:Error("Failed to fetch tags")),console.error("Error fetching tags:",e)}finally{a(!1)}},[]),o=(0,r.useCallback)(async e=>{try{let t=await fetch("/api/notes/tags",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||"HTTP ".concat(t.status,": ").concat(t.statusText))}let a=await t.json();if(a.success)return s(e=>[...e,a.tag]),Y.oR.success("Tag created successfully!"),a.tag;throw Error(a.error||"Failed to create tag")}catch(s){let e=s instanceof Error?s.message:"Failed to create tag";throw Y.oR.error(e),Error(e)}},[]),d=(0,r.useCallback)(async(e,t)=>{try{let a=await fetch("/api/notes/tags/".concat(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error||"HTTP ".concat(a.status,": ").concat(a.statusText))}let r=await a.json();if(r.success)return s(s=>s.map(s=>s.id===e?r.tag:s)),Y.oR.success("Tag updated successfully!"),r.tag;throw Error(r.error||"Failed to update tag")}catch(s){let e=s instanceof Error?s.message:"Failed to update tag";throw Y.oR.error(e),Error(e)}},[]),c=(0,r.useCallback)(async e=>{try{let t=await fetch("/api/notes/tags/".concat(e),{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||"HTTP ".concat(t.status,": ").concat(t.statusText))}let a=await t.json();if(a.success)s(s=>s.filter(s=>s.id!==e)),Y.oR.success("Tag deleted successfully!");else throw Error(a.error||"Failed to delete tag")}catch(s){let e=s instanceof Error?s.message:"Failed to delete tag";throw Y.oR.error(e),Error(e)}},[]);return(0,r.useEffect)(()=>{i()},[i]),{tags:e,loading:t,error:n,createTag:o,updateTag:d,deleteTag:c}}(),R=(null==t?void 0:t.id)||M,{isSaving:G,lastSaved:Q,error:W}=function(e,s){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,a=arguments.length>3?arguments[3]:void 0,[n,l]=(0,r.useState)(!1),[i,o]=(0,r.useState)(null),[d,c]=(0,r.useState)(null),u=(0,r.useRef)(s),m=(0,r.useRef)(a),x=(0,r.useRef)(null);return(0,r.useEffect)(()=>{u.current=s,m.current=a},[s,a]),(0,r.useEffect)(()=>{if(!e||!s)return;x.current&&x.current.abort();let a=setTimeout(async()=>{l(!0),c(null);let s=new AbortController;x.current=s;try{let t={content:u.current};void 0!==m.current&&m.current.trim()&&(t.title=m.current);let a=await fetch("/api/notes/".concat(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:s.signal,keepalive:!0});if(a.ok)await a.json(),o(new Date);else{let e=await a.json().catch(()=>({}));c(e.error||"Auto-save failed")}}catch(e){(e instanceof DOMException?"AbortError"===e.name:e instanceof Error&&"AbortError"===e.name)||c("Auto-save failed")}finally{l(!1),x.current===s&&(x.current=null)}},t);return()=>{clearTimeout(a),x.current&&x.current.abort()}},[e,s,t]),{isSaving:n,lastSaved:i,error:d}}(R,v,5e3,g);(0,r.useEffect)(()=>{G&&(console.log("[NoteEditor] Auto-save started for content",{contentLength:v.length,titleLength:g.length}),D.current=v,F.current=g)},[G,v,g]),(0,r.useEffect)(()=>{console.log("[NoteEditor] Auto-save status effect",{lastSaved:!!Q,isAutoSaving:G,autoSaveError:W,hasUnsavedTitle:x.hasUnsavedChanges,hasUnsavedContent:h.hasUnsavedChanges,currentContent:v.length,savedContent:D.current.length}),!Q||G||W||(v===D.current&&g===F.current?(console.log("[NoteEditor] Auto-save completed and content unchanged, marking as saved"),x.markAsSaved(),h.markAsSaved()):console.log("[NoteEditor] Auto-save completed but content changed, NOT marking as saved",{contentChanged:v!==D.current,titleChanged:g!==F.current}))},[Q,G,W,v,g,x,h]);let X=(0,r.useCallback)(async()=>
1{if(g.trim()&&v.trim()){U(!0);try{let e={id:(null==t?void 0:t.id)||"",user_id:"",study_session_id:l,title:g.trim(),content:v.trim(),is_pinned:y,page_references:[],word_count:v.trim().split(/\s+/).filter(Boolean).length,tags:E,metadata:{},created_at:(null==t?void 0:t.created_at)||new Date().toISOString(),updated_at:new Date().toISOString()},s=await d(e);!(null==t?void 0:t.id)&&(null==s?void 0:s.id)&&P(s.id),x.markAsSaved(),h.markAsSaved()}catch(e){console.error("Error saving note:",e)}finally{U(!1)}}},[g,v,y,E,t,l,d,x,h]),Z=(0,r.useCallback)(async()=>{if(console.log("[NoteEditor] forceSave called",{hasUnsavedTitle:x.hasUnsavedChanges,hasUnsavedContent:h.hasUnsavedChanges,noteIdForAutoSave:R,title:g.trim(),contentLength:v.trim().length}),(x.hasUnsavedChanges||h.hasUnsavedChanges)&&R){console.log("[NoteEditor] Performing force save for existing note");try{let e=await fetch("/api/notes/".concat(R),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:g.trim(),content:v.trim()})});if(console.log("[NoteEditor] Force save response",{ok:e.ok,status:e.status}),e.ok){let s=await e.json();console.log("[NoteEditor] Force save successful",s),x.markAsSaved(),h.markAsSaved()}else console.error("[NoteEditor] Force save failed",{status:e.status,statusText:e.statusText})}catch(e){console.error("[NoteEditor] Error force saving note:",e)}}else!R&&(g.trim()||v.trim())?(console.log("[NoteEditor] Force save for new note - using handleSave"),await X()):console.log("[NoteEditor] Force save skipped - no unsaved changes or no content")},[x,h,R,g,v,X]);(0,r.useImperativeHandle)(s,()=>({hasUnsavedChanges:()=>{let e=x.hasUnsavedChanges||h.hasUnsavedChanges;return console.log("[NoteEditor] hasUnsavedChanges called",{titleUnsaved:x.hasUnsavedChanges,contentUnsaved:h.hasUnsavedChanges,result:e,currentTitle:g,currentContent:v.substring(0,50)+"..."}),e},forceSave:Z}),[x.hasUnsavedChanges,h.hasUnsavedChanges,Z,g,v]);let ee=(0,r.useCallback)(e=>{C(s=>s.some(s=>s.id===e.id)?s.filter(s=>s.id!==e.id):[...s,e])},[]);(0,r.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&(e.preventDefault(),X()),(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),X()),"Escape"===e.key&&(e.preventDefault(),c())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[X,c]),(0,r.useEffect)(()=>{let e=e=>{(x.hasUnsavedChanges||h.hasUnsavedChanges)&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[x.hasUnsavedChanges,h.hasUnsavedChanges]),(0,r.useEffect)(()=>{let e=()=>{window.innerWidth<768&&"split"===A&&S("edit")};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[A]);let es=v.split(/\s+/).filter(Boolean).length,et=v.split("\n").length;return(0,a.jsxs)("div",{className:"h-full flex flex-col bg-background",children:[(0,a.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between px-4 md:px-5 py-3 border-b border-border/60 gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 flex-1",children:[(0,a.jsx)(o.p,{placeholder:u("editor.titlePlaceholder"),value:g,onChange:e=>b(e.target.value),className:"flex-1 h-9 text-sm font-semibold bg-foreground
1/[0.02] border border-border/50 hover:border-border focus:border-primary/40 focus:bg-background transition-all duration-200 rounded-xl shadow-none"}),(0,a.jsx)("button",{onClick:()=>k(!y),className:(0,T.cn)("h-9 w-9 flex items-center justify-center rounded-xl transition-all duration-200 cursor-pointer flex-shrink-0",y?"bg-[var(--tab-notes-bg)] text-[var(--tab-notes-icon)]":"hover:bg-foreground/5 text-muted-foreground"),children:(0,a.jsx)(N,{className:(0,T.cn)("h-4 w-4",y&&"fill-current")})})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between md:justify-end gap-2.5 md:ml-4",children:[(0,a.jsxs)("div",{className:"flex items-center bg-foreground/[0.03] rounded-xl p-0.5",children:[(0,a.jsx)("button",{onClick:()=>S("edit"),className:(0,T.cn)("h-8 w-8 flex items-center justify-center rounded-[10px] transition-all duration-200 cursor-pointer","edit"===A?"bg-card shadow-[var(--shadow-xs)] text-foreground":"text-muted-foreground hover:text-foreground"),title:u("web.editor.editOnly"),children:(0,a.jsx)(w.A,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("button",{onClick:()=>S("split"),className:(0,T.cn)("hidden md:flex h-8 w-8 items-center justify-center rounded-[10px] transition-all duration-200 cursor-pointer","split"===A?"bg-card shadow-[var(--shadow-xs)] text-foreground":"text-muted-foreground hover:text-foreground"),title:u("web.editor.splitView"),children:(0,a.jsx)(O,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("button",{onClick:()=>S("preview"),className:(0,T.cn)("h-8 w-8 flex items-center justify-center rounded-[10px] transition-all duration-200 cursor-pointer","preview"===A?"bg-card shadow-[var(--shadow-xs)] text-foreground":"text-muted-foreground hover:text-foreground"),title:u("web.editor.previewOnly"),children:(0,a.jsx)(f.A,{className:"h-3.5 w-3.5"})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(i.$,{variant:"ghost",size:"sm",onClick:c,disabled:_,className:"h-9 px-3 cursor-pointer hover:bg-foreground
1/5 transition-all duration-200 rounded-xl text-sm",children:u("actions.cancel")}),(0,a.jsx)(i.$,{size:"sm",onClick:X,disabled:_||!g.trim()||!v.trim(),className:"h-9 px-4 cursor-pointer bg-primary text-primary-foreground shadow-[var(--shadow-xs)] hover:shadow-[var(--shadow-sm)] transition-all duration-200 rounded-xl text-sm font-medium",children:_?(0,a.jsx)(a.Fragment,{children:u("actions.saving")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(I.A,{className:"mr-1.5 h-3.5 w-3.5"}),u("actions.save")]})})]})]})]}),L.length>0&&(0,a.jsxs)("div",{className:"flex items-center gap-2.5 px-4 md:px-5 py-2.5 border-b border-border/40 bg-foreground/[0.01] overflow-x-auto",children:[(0,a.jsx)(H.A,{className:"h-3.5 w-3.5 text-muted-foreground/50 flex-shrink-0"}),(0,a.jsx)("div",{className:"flex flex-nowrap md:flex-wrap gap-1.5",children:L.map(e=>(0,a.jsx)(V.E,{variant:E.some(s=>s.id===e.id)?"default":"outline",className:"cursor-pointer text-xs h-6 px-2.5 transition-all duration-200 rounded-md whitespace-nowrap flex-shrink-0 font-medium",style:{backgroundColor:E.some(s=>s.id===e.id)?e.color:"transparent",borderColor:E.some(s=>s.id===e.id)?e.color:e.color+"40",color:E.some(s=>s.id===e.id)?"white":e.color},onClick:()=>ee(e),children:e.name},e.id))})]}),(0,a.jsxs)("div",{className:"relative flex-1 bg-background",children:["edit"===A&&(0,a.jsx)("div",{className:"absolute inset-0 p-4 md:p-5 overflow-auto",children:(0,a.jsx)(z.T,{placeholder:u("web.editor.bodyPlaceholderMd"),value:v,onChange:e=>{console.log("[NoteEditor] Content changed",{newLength:e.target.value.length,preview:e.target.value.substring(0,50)+"..."}),j(e.target.value)},className:"min-h-[300px] md:min-h-[400px] w-full resize-none font-mono text-sm focus-visible:ring-1 focus-visible:ring-primary/20 bg-foreground
1/[0.01] border border-border/40 hover:border-border/60 focus:border-primary/30 transition-all duration-200 rounded-xl p-4 shadow-none leading-relaxed"})}),"preview"===A&&(0,a.jsx)("div",{className:"absolute inset-0 overflow-auto p-4 md:p-5",children:(0,a.jsx)("div",{className:"max-w-3xl mx-auto prose prose-sm dark:prose-invert prose-headings:font-semibold prose-p:leading-relaxed",children:(0,a.jsx)(K.default,{content:v})})}),"split"===A&&(0,a.jsxs)("div",{className:"absolute inset-0 flex",children:[(0,a.jsx)("div",{className:"relative flex-1 border-r border-border/40",children:(0,a.jsx)("div",{className:"absolute inset-0 p-4 overflow-auto",children:(0,a.jsx)(z.T,{placeholder:u("web.editor.bodyPlaceholderMd"),value:v,onChange:e=>{console.log("[NoteEditor] Content changed",{newLength:e.target.value.length,preview:e.target.value.substring(0,50)+"..."}),j(e.target.value)},className:"min-h-[400px] w-full resize-none font-mono text-sm focus-visible:ring-1 focus-visible:ring-primary/20 bg-foreground/[0.01] border border-border/40 hover:border-border/60 focus:border-primary/30 transition-all duration-200 rounded-xl p-4 shadow-none leading-relaxed"})})}),(0,a.jsx)("div",{className:"relative flex-1",children:(0,a.jsx)("div",{className:"absolute inset-0 overflow-auto p-4",children:(0,a.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none prose-headings:font-semibold prose-p:leading-relaxed",children:(0,a.jsx)(K.default,{content:v})})})})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 md:px-5 py-2 border-t border-border/40 bg-foreground
1/[0.01] text-xs",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 text-muted-foreground",children:[(0,a.jsx)("span",{className:"tabular-nums",children:u("card.words",{n:Number(es)})}),(0,a.jsx)("span",{className:"text-border",children:"\xb7"}),(0,a.jsx)("span",{className:"tabular-nums",children:u("web.editor.lines",{n:Number(et)})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[!(null==t?void 0:t.id)&&!M&&(0,a.jsx)("span",{className:"text-muted-foreground/60 text-[11px]",children:u("web.editor.autoSaveHint")}),G&&(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-amber-600 dark:text-amber-400",children:[(0,a.jsx)(B.A,{className:"h-2 w-2 fill-current animate-pulse"}),(0,a.jsx)("span",{className:"text-[11px] font-medium",children:u("actions.saving")})]}),Q&&!G&&!W&&(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-success",children:[(0,a.jsx)($.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{className:"text-[11px] font-medium",children:u("web.editor.savedTime",{time:new Date(Q).toLocaleTimeString(m,{hour:"2-digit",minute:"2-digit"})})})]}),W&&!G&&(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-destructive",children:[(0,a.jsx)(J.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{className:"text-[11px] font-medium",children:u("web.editor.saveFailed")})]})]})]})]})});G.displayName="NoteEditor";var Q=t(52142),W=t(69389),X=t(31734);let Z=async e=>{let s=await fetch(e);if(!s.ok)throw Error("Failed to fetch data");return s.json()};function ee(e){var s,t;let{sessionId:p,autoGenStatus:v=null,isPurchased:b=!1}=e,w=(0,n.c)("notes"),{triggerContextualFeedback:j}=(0,X.j)(),[N,y]=(0,r.useState)("list"),[k,E]=(0,r.useState)(null),[C,A]=(0,r.useState)("list"),[T,S]=(0,r.useState)(""),[_,U]=(0,r.useState)(!1),[M,D]=(0,r.useState)(null),[F,R]=(0,r.useState)(null),z=(0,r.useRef)(null),V=p?"/api/notes/session/".concat(p):null,{data:O,error:I,isLoading:H,isValidating:B,mutate:$}=(0,l.Ay)(V,Z,{revalidateOnFocus:!1,dedupingInterval:3e4,revalidateOnMount:!0,refreshInterval:0}),J=(null==O||null==(s=O.data)?void 0:s.notes)||[],K=(null==O||null==(t=O.data)?void 0:t.total_count)||0;(0,r.useEffect)(()=>{let e=e=>{var s;(null==(s=e.detail)?void 0:s.sessionId)===p&&$()};return window.addEventListener("notes-updated",e),()=>{window.removeEventListener("notes-updated",e)}},[p,$]);let q=(0,r.useCallback)(async e=>{try{var s;let t=await fetch("/api/notes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({study_session_id:p,title:e.title,content:e.content,is_pinned:e.is_pinned,page_references:e.page_references,tag_ids:null==(s=e.tags)?void 0:s.map(e=>e.id),metadata:e.metadata})});if(!t.ok)throw Error("Failed to create note");let a=(await t.json()).data;return E(a),y("view"),Y.oR.success(w("web.tab.createdToast")),$(),j({category:"notes",action:"note_created",sessionId:p}),a}catch(e){return console.error("Error creating note:",e),Y.oR.error(w("web.tab.createFailedToast")),null}},[p,$,j,w]),ee=(0,r.useCallback)(async e=>{try{var s;let t=await fetch("/api/notes/".concat(e.id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title,content:e.content,is_pinned:e.is_pinned,page_references:e.page_references,tag_ids:null==(s=e.tags)?void 0:s.map(e=>e.id),metadata:e.metadata})});if(!t.ok)throw Error("Failed to update note");let a=(await t.json()).data;return E(a),y("view"),Y.oR.success(w("web.tab.updatedToast")),$(),a}catch(e){return console.error("Error updating note:",e),Y.oR.error(w("web.tab.updateFailedToast")),null}},[$,w]),es=(0,r.useCallback)(async e=>{try{if(!(await fetch("/api/notes/".concat(e.id),{method:"DELETE"})).ok)throw Error("Failed to delete note");(null==k?void 0:k.id)===e.id&&(E(null),y("list")),Y.oR.success(w("web.tab.deletedToast")),$()}catch(e){console.error("Error deleting note:",e),Y.oR.error(w("web.tab.deleteFailedToast"))}},[k,$,w]),et=(0,r.useCallback)(async e=>{try{if(!(await fetch("/api/notes/".concat(e.id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_pinned:!e.is_pinned})})).ok)throw Error("Failed to pin note");Y.oR.success(e.is_pinned?w("web.tab.unpinnedToast"):w("web.tab.pinnedToast")),$()}catch(e){console.error("Error pinning note:",e),Y.oR.error(w("web.tab.updateFailedToast"))}},[$,w]),ea=(0,r.useCallback)(async e=>{var s;"edit"===N&&(null==(s=z.current)?void 0:s.hasUnsavedChanges())&&window.confirm(w("web.tab.confirmSwitch"))&&await z.current.forceSave(),U(!0),D(e.id),R("view");try{let s=await fetch("/api/notes/".concat(e.id));if(s.ok){let e=(await s.json()).data;E(e)}else E(e)}catch(s){console.error("[NotesTab] Error fetching fresh note data:",s),E(e)}y("view"),U(!1),D(null),R(null)},[N,w]),er=(0,r.useCallback)(async e=>{var s;"edit"===N&&(null==(s=z.current)?void 0:s.hasUnsavedChanges())&&window.confirm(w("web.tab.confirmEdit"))&&await z.current.forceSave(),U(!0),D(e.id),R("edit");try{let s=await fetch("/api/notes/".concat(e.id));if(s.ok){let e=(await s.json()).data;E(e)}else E(e)}catch(s){console.error("[NotesTab] Error fetching fresh note data:",s),E(e)}y("edit"),U(!1),D(null),R(null)},[N,w]),en=(0,r.useCallback)(async()=>{var e;("edit"===N||"create"===N)&&(null==(e=z.current)?void 0:e.hasUnsavedChanges())&&window.confirm(w("web.tab.confirmNew"))&&await z.current.forceSave(),E(null),y("create")},[N,w]),el=(0,r.useCallback)(async()=>{var e;(null==(e=z.current)?void 0:e.hasUnsavedChanges())&&window.confirm(w("web.tab.confirmLeave"))&&z.current&&await z.current.forceSave(),U(!0),R("list"),await $(),y("list"),U(!1),R(null)},[$,w]),ei=T?J.filter(e=>e.title.toLowerCase().includes(T.toLowerCase())||e.content.toLowerCase().includes(T.toLowerCase())):J,eo=(H||B)&&0===J.length||_;return"list"===N?eo?(0,a.jsx)(P,{viewMode:C,variant:"list",count:4}):(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col",children:[_&&F&&"list"!==F&&(0,a.jsx)("div",{className:"absolute inset-0 bg-background z-50",children:(0,a.jsx)(P,{variant:"edit"===F?"editor":"viewer",count:1})}),(0,a.jsxs)("div",{className:"p-4 md:p-6 bg-background",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4 md:mb-5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"h-9 w-9 rounded-xl bg-[var(--tab-notes-bg)] flex items-center justify-center",children:(0,a.jsx)(d.A,{className:"h-4.5 w-4.5 text-[var(--tab-notes-icon)]"})}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,a.jsx)("h1",{className:"text-xl md:text-2xl font-semibold text-foreground",children:w("title")}),(0,a.jsx)("span",{className:"text-xs font-medium text-muted-foreground bg-foreground
1/[0.04] px-2 py-0.5 rounded-full",children:K})]}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground mt-0.5 hidden md:block",children:w("web.tab.subtitle")})]})]}),(0,a.jsxs)(i.$,{onClick:en,className:"cursor-pointer bg-primary text-primary-foreground shadow-[var(--shadow-xs)] hover:shadow-[var(--shadow-sm)] transition-all duration-200 rounded-xl h-9 px-4 text-sm font-medium",children:[(0,a.jsx)(c.A,{className:"mr-1.5 h-4 w-4"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:w("createTitle")}),(0,a.jsx)("span",{className:"sm:hidden",children:w("web.tab.newShort")})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,a.jsx)(u.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/50"}),(0,a.jsx)(o.p,{placeholder:w("search"),value:T,onChange:e=>S(e.target.value),className:"pl-10 h-9 border border-border/60 bg-foreground/[0.02] hover:bg-foreground/[0.04] focus:bg-background focus:border-primary/40 transition-all duration-200 rounded-xl shadow-none text-sm"})]}
1),(0,a.jsxs)("div",{className:"flex items-center bg-foreground/[0.03] rounded-xl p-0.5",children:[(0,a.jsx)("button",{onClick:()=>A("list"),className:"h-8 w-8 flex items-center justify-center rounded-[10px] transition-all duration-200 cursor-pointer ".concat("list"===C?"bg-card shadow-[var(--shadow-xs)] text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,a.jsx)(m.A,{className:"h-4 w-4"})}),(0,a.jsx)("button",{onClick:()=>A("grid"),className:"h-8 w-8 flex items-center justify-center rounded-[10px] transition-all duration-200 cursor-pointer ".concat("grid"===C?"bg-card shadow-[var(--shadow-xs)] text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,a.jsx)(x.A,{className:"h-4 w-4"})})]})]})]}),(0,a.jsx)("div",{className:"h-px bg-border/60 mx-4 md:mx-6"}),(0,a.jsx)("div",{className:"flex-1 overflow-hidden relative",children:(0,a.jsx)("div",{className:"absolute inset-0 overflow-y-auto",children:I?(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-4 p-4",children:[(0,a.jsx)("p",{className:"text-muted-foreground text-sm",children:w("web.tab.loadFailed")}),(0,a.jsx)(i.$,{onClick:()=>$(),variant:"outline",className:"cursor-pointer rounded-xl h-9 shadow-none",children:w("web.tab.retry")})]}):0!==ei.length||H||B?(0,a.jsx)(L,{notes:ei,loading:H||B,viewMode:C,loadingNoteId:M,onNoteClick:ea,onNoteEdit:b?void 0:er,onNoteDelete:b?void 0:es,onNotePin:b?void 0:et,isPurchased:b,onNoteVisibilityChange:(e,s)=>{$(t=>{var a;return(null==t||null==(a=t.data)?void 0:a.notes)?{...t,data:{...t.data,notes:t.data.notes.map(t=>t.id===e?{...t,visibility:s.visibility,slug:s.slug}:t)}}:t},{revalidate:!1})}}):"generating"===v||"failed"===v?(0,a.jsx)("div",{className:"p-4 md:p-6",children:(0,a.jsx)(W.D,{feature:"notes",status:v,onGenerateManually:en})}):(0,a.jsx)("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8",children:(0,a.jsxs)("div",{className:"max-w-sm text-center",children:[(0,a.jsx)("div",{className:"mx-auto mb-6 h-20 w-20 rounded-2xl bg-[var(--tab-notes-bg)]/50 flex items-center justify-center",children:(0,a.jsx)(h.A,{className:"h-9 w-9 text-[var(--tab-notes-icon)]/70"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-2",children:T?w("web.tab.emptyTitleSearch"):w("web.tab.emptyTitleDefault")}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground leading-relaxed mb-6",children:T?w("web.tab.emptyBodySearch"):w("web.tab.emptyBodyDefault")}),!T&&(0,a.jsxs)(i.$,{onClick:en,className:"cursor-pointer bg-primary text-primary-foreground shadow-[var(--shadow-xs)] hover:shadow-[var(--shadow-sm)] transition-all duration-200 rounded-xl h-10 px-5",children:[(0,a.jsx)(c.A,{className:"mr-2 h-4 w-4"}),w("web.tab.emptyCta")]})]})})})})]}):"create"===N?(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 px-4 md:px-6 py-3 border-b border-border/60 bg-background",children:[(0,a.jsxs)(i.$,{variant:"ghost",size:"sm",onClick:el,className:"cursor-pointer hover:bg-foreground
1/5 transition-all duration-200 rounded-xl h-9 px-3",children:[(0,a.jsx)(g.A,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{className:"hidden md:inline text-sm",children:w("actions.back")})]}),(0,a.jsx)("div",{className:"h-4 w-px bg-border/60"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"h-6 w-6 rounded-lg bg-[var(--tab-notes-bg)] flex items-center justify-center",children:(0,a.jsx)(h.A,{className:"h-3 w-3 text-[var(--tab-notes-icon)]"})}),(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:w("createTitle")})]})]}),(0,a.jsx)("div",{className:"relative flex-1",children:(0,a.jsx)("div",{className:"absolute inset-0",children:(0,a.jsx)(G,{ref:z,sessionId:p,onSave:q,onCancel:el})})})]}):"edit"===N&&k?(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col",children:[_&&F&&(0,a.jsx)("div",{className:"absolute inset-0 bg-background z-50",children:(0,a.jsx)(P,{variant:"list"===F?"list":"view"===F?"viewer":"editor",viewMode:"list"===F?C:void 0,count:"list"===F?4:1})}),(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 md:px-6 py-3 border-b border-border/60 bg-background",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsxs)(i.$,{variant:"ghost",size:"sm",onClick:async()=>{var e;if((null==(e=z.current)?void 0:e.hasUnsavedChanges())&&window.confirm(w("web.tab.confirmBack"))&&await z.current.forceSave(),null==k?void 0:k.id)try{let e=await fetch("/api/notes/".concat(k.id));if(e.ok){let s=(await e.json()).data;E(s)}}catch(e){console.error("[NotesTab] Error fetching fresh note data:",e)}y("view")}
1,className:"cursor-pointer hover:bg-foreground/5 transition-all duration-200 rounded-xl h-9 px-3",children:[(0,a.jsx)(g.A,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{className:"hidden md:inline text-sm",children:w("actions.back")})]}),(0,a.jsx)("div",{className:"h-4 w-px bg-border/60"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"h-6 w-6 rounded-lg bg-amber-50 dark:bg-amber-500/10 flex items-center justify-center",children:(0,a.jsx)(h.A,{className:"h-3 w-3 text-amber-600 dark:text-amber-400"})}),(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:w("web.tab.editing")})]})]}),(0,a.jsxs)(i.$,{variant:"ghost",size:"sm",onClick:async()=>{var e;if((null==(e=z.current)?void 0:e.hasUnsavedChanges())&&window.confirm(w("web.tab.confirmView"))&&await z.current.forceSave(),null==k?void 0:k.id)try{let e=await fetch("/api/notes/".concat(k.id));if(e.ok){let s=(await e.json()).data;E(s)}}catch(e){console.error("Error fetching fresh note data:",e)}y("view")}
1,className:"cursor-pointer hover:bg-foreground/5 transition-all duration-200 rounded-xl h-9 px-3",children:[(0,a.jsx)(f.A,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{className:"hidden md:inline text-sm",children:w("web.tab.preview")})]})]}),(0,a.jsx)("div",{className:"relative flex-1",children:(0,a.jsx)("div",{className:"absolute inset-0",children:(0,a.jsx)(G,{ref:z,note:k,sessionId:p,onSave:ee,onCancel:async()=>{var e;(null==(e=z.current)?void 0:e.hasUnsavedChanges())&&window.confirm(w("web.tab.confirmCancel"))&&await z.current.forceSave(),y("view")}})})})]}):"view"===N&&k?(0,a.jsxs)("div",{className:"absolute inset-0",children:[_&&F&&(0,a.jsx)("div",{className:"absolute inset-0 bg-background z-50",children:(0,a.jsx)(P,{variant:"list"===F?"list":"edit"===F?"editor":"viewer",viewMode:"list"===F?C:void 0,count:"list"===F?4:1})}),(0,a.jsx)(Q.t,{note:k,onEdit:b?void 0:()=>er(k),onDelete:b?void 0:()=>es(k),onBack:el,isPurchased:b,onVisibilityChange:(e,s)=>{$(t=>{var a;return(null==t||null==(a=t.data)?void 0:a.notes)?{...t,data:{...t.data,notes:t.data.notes.map(t=>t.id===e?{...t,visibility:s.visibility,slug:s.slug}:t)}}:t},{revalidate:!1})}})]}):null}}}]);
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.