PageSourceSearch

https://tubenote-8a1ef.web.app/assets/WorkspacePage-CvSJdjKA.js

js tubenote-8a1ef.web.app collected 2026-10-03 12:38:36 UTC 115,186 bytes, 14 lines download raw bytes

1var gs=Object.defineProperty;var bs=(t,r,n)=>r in t?gs(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n;var tt=(t,r,n)=>bs(t,typeof r!="symbol"?r+"":r,n);import{a as i,j as e,R as dt,M as nt,b as at}from"./markdown-CsXM4Fse.js";import{r as Tt}from"./index-h6mzXfFB.js";import{y as Ke,D as jt,z as Et,B as wr,t as kr,F as jr,p as pe,r as ys,C as dr,H as vs,n as Ue,I as ws}from"./firebase-DesKTKso.js";import{f as ee,h as Ye,F as Lt,u as B,m as Mt,b as ut,a as ye,l as qe,e as ht,k as pt,c as Nr,q as $e,s as ks,v as Cr,E as Sr,r as Tr,P as Nt,w as ot,x as js,j as Ns,i as Cs,y as Er}from"./index-nkgc4SH-.js";import{l as Ne,a as Ss,C as Ts,b as Es}from"./AnalyzeProgressModal-C26A_13e.js";import{u as Rt,r as Ls,C as it,a as lt,b as It}from"./CategoryIcon-BZEby26P.js";import{g as At,m as Ms,s as Rs,T as Ce,a as Is,b as As,C as ur}from"./actionTools-CvOzKU1e.js";import{c as $s}from"./shareService-BqkSoG4s.js";import{r as hr,a as Ds,b as Ct,P as zs}from"./InteractiveResultRenderer-BQxqXLbv.js";import{T as Os,N as Ps}from"./SharedNotePage-CgZS0Ol8.js";import{d as Bs,c as Fs,C as _s}from"./clipService-Bo7dgspx.js";async function Lr(t,r){var l,o,u,d,f,p,g;const n=(l=t.body)==null?void 0:l.getReader();if(!n){(o=r.onError)==null||o.call(r,"No response body");return}const a=new TextDecoder;let s="";try{for(;;){const{done:v,value:S}=await n.read();if(v)break;s+=a.decode(S,{stream:!0});const N=s.split(`
2`);s=N.pop()||"";for(const b of N)if(b.startsWith("data: ")){const x=b.slice(6);if(x==="[DONE]"){(u=r.onComplete)==null||u.call(r,!0);return}try{const j=JSON.parse(x);j.error?(d=r.onError)==null||d.call(r,j.error):j.meta?(f=r.onMeta)==null||f.call(r,j.meta):j.content&&r.onContent(j.content)}catch{r.onContent(x)}}}(p=r.onComplete)==null||p.call(r,s.trim()==="data: [DONE]")}catch(v){(g=r.onError)==null||g.call(r,v instanceof Error?v.message:"Stream error")}finally{n.releaseLock()}}async function Ws(t,r,n,a,s,l){const o=Ye.currentUser;if(!o)throw new Error("로그인이 필요합니다");const u=await o.getIdToken(),d=await fetch(`${Lt}/generateActionFn`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify({videoId:t,noteId:r,toolId:n,toolPrompt:a,responseType:l.responseType??"markdown",toolKind:l.toolKind,forceRegenerate:l.forceRegenerate===!0,...l.promptHash?{promptHash:l.promptHash}:{}})});if(!d.ok){const f=await d.json().catch(()=>null);throw new Error(Ne(f??`HTTP ${d.status}`))}await Lr(d,{onContent:s.onContent,onError:f=>s.onError(Ne(f)),onComplete:s.onComplete})}const Mr="summix.actionHistory.v1",Hs=100;function Rr(){try{if(typeof localStorage>"u")return{};const t=localStorage.getItem(Mr);if(!t)return{};const r=JSON.parse(t);return r&&typeof r=="object"?r:{}}catch{return{}}}function Us(t){try{if(typeof localStorage>"u")return;localStorage.setItem(Mr,JSON.stringify(t))}catch{}}function Vs(t){const r=Rr();return new Set(r[t]||[])}function pr(t,r){const n=Rr(),a=n[t]||[];if(a.includes(r))return;n[t]=[...a,r];const s=Object.keys(n);for(;s.length>Hs;){const l=s.shift();if(l===void 0)break;delete n[l]}Us(n)}const Ks=20,Ir=1440*60*1e3,Ar="summix.actionCache.v1",de=new Map,De=new Map;function $r(t,r){return`${t}:${r}`}function Ys(){try{if(typeof localStorage>"u")return{};const t=localStorage.getItem(Ar);if(!t)return{};const r=JSON.parse(t);return r&&typeof r=="object"?r:{}}catch{return{}}}function Dr(t){try{if(typeof localStorage>"u")return;localStorage.setItem(Ar,JSON.stringify(t))}catch{}}(function(){const r=Ys(),n=Date.now();let a=!1;for(const[s,l]of Object.entries(r)){if(!l||n-l.storedAt>Ir){delete r[s],a=!0;continue}try{de.set(s,new Map(l.map)),De.set(s,l.storedAt)}catch{delete r[s],a=!0}}a&&Dr(r)})();function zr(){const t={};for(const[r,n]of de.entries())t[r]={map:Array.from(n.entries()),storedAt:De.get(r)??Date.now()};Dr(t)}function Or(t,r){const n=$r(t,r),a=de.get(n);if(!a)return;const s=De.get(n)??0;if(Date.now()-s>Ir){de.delete(n),De.delete(n),zr();return}return de.delete(n),de.set(n,a),a}function Pr(t,r,n){const a=$r(t,r);for(de.delete(a),de.set(a,n),De.set(a,Date.now());de.size>Ks;){const s=de.keys().next().value;if(s===void 0)break;de.delete(s),De.delete(s)}zr()}async function qs(t,r,n,a){const s=Ke(ee,`videos/${t}/sharedActions`),l=Ke(ee,`notes/${r}/actions`),[o,u]=await Promise.all([jt(s),jt(l)]),d=new Map;return o.forEach(f=>{const p=f.data();
2p.language===n&&(a&&p.videoUpdatedAt!==a||d.set(p.toolId,{toolId:p.toolId,responseType:p.responseType,result:p.result,language:p.language,createdAt:p.createdAt,source:"shared"}))}),u.forEach(f=>{const p=f.data();p.language===n&&d.set(p.toolId,{toolId:p.toolId,responseType:p.responseType,result:p.result,language:p.language,createdAt:p.createdAt,source:"private"})}),Pr(r,n,d),d}function Xs(t,r,n,a){const s=Or(t,r);s&&(s.set(n,a),Pr(t,r,s))}function Br(t){let r=2166136261;for(let n=0;n<t.length;n++)r^=t.charCodeAt(n),r=r+((r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24))>>>0;return r.toString(16).padStart(8,"0")}function Gs(t){const{t:r}=B(),{contentLanguage:n}=Mt(),a=n,{user:s}=ut(),[l,o]=i.useState([]),[u,d]=i.useState(!0);return i.useEffect(()=>{if(!s){o([]),d(!1);return}d(!0);const p=Et(Ke(ee,"users",s.uid,"tools"),wr("createdAt","asc")),g=kr(p,v=>{const S=v.docs.map(N=>{const b=N.data();return{id:N.id,baseToolId:b.baseToolId,label:b.label,params:b.params||{},extraInstruction:b.extraInstruction,createdAt:b.createdAt||0}});o(S),d(!1)},v=>{console.error("[useCustomTools] snapshot error:",v),d(!1)});return()=>g()},[s]),{customTools:l.map(p=>{const g=At(p.baseToolId,t,r,a)||Js(p.baseToolId,r,a);return g?Ms(g,p.id,p.label,p.params,p.extraInstruction,p.createdAt,r):null}).filter(p=>p!==null),loading:u}}function Js(t,r,n){const a=["general","education","finance","news","review","interview","cooking"];for(const s of a){const l=At(t,s,r,n);if(l)return l}}const xr="summix-recent-tools",Zs=5;function Qs(){const[t,r]=i.useState(()=>{if(typeof window>"u")return[];try{const a=localStorage.getItem(xr);return a?JSON.parse(a):[]}catch{return[]}}),n=i.useCallback(a=>{r(s=>{const l=s.filter(u=>u!==a),o=[a,...l].slice(0,Zs);try{localStorage.setItem(xr,JSON.stringify(o))}catch{}return o})},[]);return{recentIds:t,trackTool:n}}async function en(t){const r=Ye.currentUser;if(!r)throw new Error("로그인이 필요합니다");const n=await r.getIdToken(),a=await fetch(`${Lt}/createCustomToolFn`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify(t)}),s=await a.json().catch(()=>({}));if(!a.ok){const l=new Error(s.error||"커스텀 도구 생성 실패");throw l.code=s.error,l}return s.id}async function tn(t,r){var s;const n=Ye.currentUser;if(!n)throw new Error("로그인이 필요합니다");const a={baseToolId:r.baseToolId,label:r.label,params:r.params};(s=r.extraInstruction)!=null&&s.trim()&&(a.extraInstruction=r.extraInstruction.trim()),await ys(pe(ee,"users",n.uid,"tools",t),a,{merge:!0})}async function rn(t){const r=Ye.currentUser;if(!r)throw new Error("로그인이 필요합니다");await jr(pe(ee,"users",r.uid,"tools",t))}const fr=300;function sn({baseTool:t,editingTool:r,onClose:n,onCreated:a}){const{t:s}=B(),l=t.customizable||[],{theme:o}=ye(),u=o==="dark",{showToast:d}=qe();ht();const[f,p]=i.useState(!1),[g,v]=i.useState((r==null?void 0:r.extraInstruction)??""),[S,N]=i.useState(!!r),[b,x]=i.useState((r==null?void 0:r.label)??""),[j,h]=i.useState(!1),[E,C]=i.useState(()=>{if(r)return{...r.params};const k={};return l.forEach(L=>{k[L.key]=L.default}),k}),T=i.useMemo(()=>{const k=Rs(E,g,s);return`${t.label} · ${k}`},[t.label,E,g,s]);i.useEffect(()=>{S||x(T)},[T,S]),i.useEffect(()=>{requestAnimationFrame(()=>h(!0))},[]),i.useEffect(()=>{const k=L=>{L.key==="Escape"&&n()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[n]);const F=async()=>{if(!f){p(!0);try{const k={baseToolId:t.id,label:b.trim()||T,params:E,extraInstruction:g.trim()||void 0};r?(await tn(r.id,k),d(s("workspace.tools.editedToast"),"success")):(await en(k),d(s("workspace.tools.createdToast"),"success")),a==null||a(),n()}catch(k){d(k instanceof Error?k.message:s("workspace.tools.saveFailedToast"),"error")}finally{p(!1)}}};return e.jsx("div",{className:"fixed inset-0 z-[100] flex items-end justify-center sm:items-center sm:p-4",style:{background:j?"rgba(0,0,0,0.45)":"rgba(0,0,0,0)",backdropFilter:j?"blur(8px)":"blur(0px)",WebkitBackdropFilter:j?"blur(8px)":"blur(0px)",transition:"all 0.3s cubic-bezier(0.16, 1, 0.3, 1)"},onClick:n,children:e.jsxs("div",{className:"flex w-full max-w-[480px] flex-col overflow-hidden rounded-t-[28px] sm:rou
2nded-[28px]",style:{background:u?"rgba(30, 30, 34, 0.92)":"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(40px) saturate(1.8)",WebkitBackdropFilter:"blur(40px) saturate(1.8)",border:`1px solid ${u?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)"}`,boxShadow:u?"0 24px 80px rgba(0,0,0,0.6), 0 0 0 0.5px rgba(255,255,255,0.06) inset":"0 24px 80px rgba(0,0,0,0.18), 0 0 0 0.5px rgba(255,255,255,0.8) inset",maxHeight:"90vh",transform:j?"translateY(0) scale(1)":"translateY(24px) scale(0.97)",opacity:j?1:0,transition:"all 0.35s cubic-bezier(0.16, 1, 0.3, 1)"},onClick:k=>k.stopPropagation(),children:[e.jsx("div",{className:"flex justify-center pt-3 sm:hidden",children:e.jsx("div",{className:"h-1 w-10 rounded-full",style:{background:u?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.12)"}})}),e.jsxs("div",{className:"max-h-[85vh] overflow-y-auto p-6",style:{scrollbarWidth:"thin"},children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3.5",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-2xl transition-transform duration-300",style:{background:`${t.color}15`,color:t.color,boxShadow:`0 4px 16px ${t.color}20`},children:e.jsx(Ce,{id:t.id,className:"h-6 w-6"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:t.color,opacity:.8},children:s(r?"workspace.tools.editTitle":"workspace.tools.createTitle")}),e.jsx("p",{className:"truncate text-[17px] font-bold tracking-tight",style:{color:"var(--text-primary)"},children:t.label})]}),e.jsx("button",{onClick:n,className:"flex h-8 w-8 items-center justify-center rounded-full transition-colors hover:bg-[var(--hover-bg)]",style:{color:"var(--text-tertiary)",background:u?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.04)"},"aria-label":s("actions.close"),children:e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),l.length>0&&e.jsx("div",{className:"space-y-5",children:l.map(k=>e.jsxs("div",{children:[e.jsx("p",{className:"mb-2.5 text-[12px] font-bold uppercase tracking-wide",style:{color:"var(--text-tertiary)"},children:k.label}),e.jsx("div",{className:"flex flex-wrap gap-2",children:k.options.map(L=>{const M=E[k.key]===L.value;return e.jsx("button",{onClick:()=>C(O=>({...O,[k.key]:L.value})),className:"rounded-full px-4 py-2 text-[13px] font-semibold transition-all duration-200",style:{border:`1.5px solid ${M?t.color:u?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)"}`,background:M?`${t.color}15`:u?"rgba(255,255,255,0.03)":"rgba(0,0,0,0.02)",color:M?t.color:"var(--text-secondary)",boxShadow:M?`0 2px 8px ${t.color}18`:"none",transform:M?"scale(1.03)":"scale(1)"},children:L.label},L.value)})})]},k.key))}),e.jsxs("div",{className:l.length>0?"mt-6":"",children:[e.jsxs("div",{className:"mb-2.5 flex items-center justify-between",children:[e.jsxs("p",{className:"text-[12px] font-bold uppercase tracking-wide",style:{color:"var(--text-tertiary)"},children:[s("workspace.tools.extraInstruction")," ",e.jsxs("span",{className:"normal-case tracking-normal",style:{opacity:.6},children:["(",s("workspace.tools.optional"),")"]})]}),e.jsxs("span",{className:"text-[11px] tabular-nums",style:{color:"var(--text-tertiary)",opacity:.5},children:[g.length,"/",fr]})]}),e.jsx("textarea",{value:g,onChange:k=>v(k.target.value.slice(0,fr)),placeholder:t.extraPlaceholder||s("workspace.tools.extraPlaceholderFallback"),rows:3,className:"w-full resize-none rounded-2xl px-4 py-3 text-[13px] leading-relaxed focus:outline-none transition-all duration-200",style:{border:`1.5px solid ${u?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)"}`,background:u?"rgba(255,255,255,0.03)":"rgba(0,0,0,0.02)",color:"var(--text-primary)"},onFocus:k=>{k.currentTarget.style.borderColor=`${t.color}60`,k.currentTarget.style.boxShadow=`0 0 0 3px ${t.color}12`},onBlur:k=>{k.currentTarget.style.borderColor=u?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)",k.currentTarget.style.boxShadow="none"}})]}),e.jsxs("div",{className:"mt-5",children:[e.jsx("p",{className:"mb-2.5 text-[12px] font-bold uppercase tracking-wide",style:{color:"var(--text-tertiary)"},children:s("workspace.tools.toolName")}),e.jsx("input",{value:b,onChange:k=>{x(k.target.value),N(!0)},className:"w-full rounded-2xl px-4 py-3 text-[13px] focus:outline-none transition-all duration-200",style:{border:`1.5px solid ${u?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)"}`,background:u?"rgba(255,255,255,0.03)":"rgba(0,0,0,0.02)",color:"var(--text-primary)"},onFocus:k=>{k.currentTarget.style.borderColor=`${t.color}60`,k.currentTarget.style.boxShadow=`0 0 0 3px ${t.color}12`},onBlur:k=>{k.currentTarget.style.borderColor=u?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)",k.currentTarget.style.boxShadow="none"}})]}),e.jsxs("div",{className:"mt-7 flex gap-2.5",children:[e.jsx("button",{onClick:n,className:"flex-1 rounded-full py-3 text-[14px] font-semibold transition-all duration-200 hover:brightness-95 active:scale-[0.98]",style:{background:u?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.04)",color:"var(--text-secondary)"},children:s("actions.cancel")}),e.jsx("button",{onClick:F,disabled:f,className:"flex-1 rounded-full py-3 text-[14px] font-bold text-white transition-all duration-200 hover:brightness-110 active:scale-[0.98] disabled:opacity-50",style:{background:`linear-gradient(135deg, ${t.color}, ${t.color}cc)`,boxShadow:`0 4px 16px ${t.color}30`},children:s(f?"workspace.tools.saving":r?"actions.edit":"actions.save")})]})]})]})})}function nn({currentCategory:t,onSelect:r,onClose:n}){var j;const{t:a}=B(),{contentLanguage:s}=Mt(),l=i.useMemo(()=>Is(a,s),[a,s]),{theme:o}=ye(),u=o==="dark",[d,f]=i.useState(((j=l[0])==null?void 0:j.category)||"common"),[p,g]=i.useState(!1);ht();const v=i.useRef(null),[S,N]=i.useState({left:0,width:0});i.useEffect(()=>{requestAnimationFrame(()=>g(!0))},[]),i.useEffect(()=>{const h=E=>{E.key==="Escape"&&n()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[n]),i.useEffect(()=>{if(!v.current)return;const h=v.current.querySelector(`[data-tab="${d}"]`);if(h){const E=v.current.getBoundingClientRect(),C=h.getBoundingClientRect();N({left:C.left-E.left,width:C.width})}},[d]);const b=l.find(h=>h.category===d),x=(b==null?void 0:b.tools)||[];return e.jsx("div",{className:"fixed inset-0 z-[100] flex items-end justify-center sm:items-center sm:p-4",style:{background:p?"rgba(0,0,0,0.45)":"rgba(0,0,0,0)",backdropFilter:p?"blur(8px)":"blur(0px)",WebkitBackdropFilter:p?"blur(8px)":"blur(0px)",transition:"all 0.3s cubic-bezier(0.16, 1, 0.3, 1)"},onClick:n,children:e.jsxs("div",{className:"flex w-full max-w-[560px] flex-col overflow-hidden rounded-t-[28px] sm:rou
2nded-[28px]",style:{background:u?"rgba(30, 30, 34, 0.92)":"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(40px) saturate(1.8)",WebkitBackdropFilter:"blur(40px) saturate(1.8)",border:`1px solid ${u?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)"}`,boxShadow:u?"0 24px 80px rgba(0,0,0,0.6), 0 0 0 0.5px rgba(255,255,255,0.06) inset":"0 24px 80px rgba(0,0,0,0.18), 0 0 0 0.5px rgba(255,255,255,0.8) inset",maxHeight:"80vh",transform:p?"translateY(0) scale(1)":"translateY(24px) scale(0.97)",opacity:p?1:0,transition:"all 0.35s cubic-bezier(0.16, 1, 0.3, 1)"},onClick:h=>h.stopPropagation(),children:[e.jsx("div",{className:"flex justify-center pt-3 sm:hidden",children:e.jsx("div",{className:"h-1 w-10 rounded-full",style:{background:u?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.12)"}})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between px-6 pt-4 pb-2 sm:pt-5",children:[e.jsx("h2",{className:"text-[17px] font-bold tracking-tight",style:{color:"var(--text-primary)"},children:a("workspace.tools.pickerTitle")}),e.jsx("button",{onClick:n,className:"flex h-8 w-8 items-center justify-center rounded-full transition-colors hover:bg-[var(--hover-bg)]",style:{color:"var(--text-tertiary)",background:u?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.04)"},"aria-label":a("actions.close"),children:e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"relative shrink-0 px-6 pb-3",children:e.jsxs("div",{ref:v,className:"relative flex gap-1 overflow-x-auto rounded-full p-1",style:{background:u?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.03)",scrollbarWidth:"none"},children:[e.jsx("div",{className:"absolute top-1 bottom-1 rounded-full",style:{left:S.left,width:S.width,background:u?"rgba(255,255,255,0.1)":"#fff",boxShadow:u?"none":"0 1px 3px rgba(0,0,0,0.08)",transition:"left 0.25s cubic-bezier(0.16, 1, 0.3, 1), width 0.25s cubic-bezier(0.16, 1, 0.3, 1)"}}),l.map(h=>{const E=h.category===d;return e.jsx("button",{"data-tab":h.category,onClick:()=>f(h.category),className:"relative z-10 shrink-0 rounded-full px-4 py-2 text-[13.5px] font-semibold transition-colors",style:{color:E?"var(--text-primary)":"var(--text-tertiary)"},children:h.label},h.category)})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden px-5 pb-5 pt-1",style:{scrollbarWidth:"thin"},children:e.jsx("div",{className:"grid grid-cols-2 gap-2",children:x.map((h,E)=>{const C=d!=="common"&&d!==t;return e.jsxs("button",{onClick:()=>r(h,C),className:"group flex items-center gap-3 rounded-2xl p-3 text-left transition-all duration-200 hover:-translate-y-0.5",style:{border:`1px solid ${u?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.05)"}`,background:u?"rgba(255,255,255,0.03)":"rgba(0,0,0,0.015)",animationDelay:`${E*30}ms`},onMouseEnter:T=>{T.currentTarget.style.borderColor=`${h.color}40`,T.currentTarget.style.background=`${h.color}${u?"12":"08"}`,T.currentTarget.style.boxShadow=`0 4px 20px ${h.color}15`},onMouseLeave:T=>{T.currentTarget.style.borderColor=u?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.05)",T.currentTarget.style.background=u?"rgba(255,255,255,0.03)":"rgba(0,0,0,0.015)",T.currentTarget.style.boxShadow="none"},children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl transition-transform duration-200 group-hover:scale-110",style:{background:`${h.color}18`,color:h.color},children:e.jsx(Ce,{id:h.id,className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-[14px] font-bold",style:{color:"var(--text-primary)"},children:h.label}),h.description&&e.jsx("p",{className:"truncate text-[12px] leading-snug",style:{color:"var(--text-tertiary)"},children:h.description})]})]},h.id)})})})]})})}const wt=8;function an({noteId:t,language:r,tools:n,cachedToolIds:a,recentIds:s,onClose:l}){const{t:o}=B(),u=o,{theme:d}=ye(),f=d==="dark",{showToast:p}=qe(),[g,v]=i.useState(!1);ht();const[S,N]=i.useState([]),[b,x]=i.useState({overview:!0,summary:!0,timeline:!0}),[j,h]=i.useState(!1),[E,C]=i.useState(null);i.useEffect(()=>{requestAnimationFrame(()=>v(!0))},[]),i.useEffect(()=>{const R=I=>{I.key==="Escape"&&l()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[l]);const T=i.useMemo(()=>{const R=new Map(s.map((I,_)=>[I,_]));return n.filter(I=>a.has(I.id)).sort((I,_)=>{const te=R.get(I.id),Se=R.get(_.id),Te=te!==void 0,$=Se!==void 0;return Te&&$?te-Se:Te?-1:$?1:0})},[n,a,s]),F=i.useMemo(()=>new Set(s),[s]),k=R=>{N(I=>I.includes(R)?I.filter(_=>_!==R):I.length>=wt?I:[...I,R])},L=async()=>{h(!0);
2try{const R=await $s({noteId:t,toolIds:S,language:r,includeDefaults:b}),I=`${window.location.origin}/s/${R}`;C(I);try{await navigator.clipboard.writeText(I),p(u("workspace.share.linkCopied"),"success")}catch{}}catch(R){p(R instanceof Error?R.message:u("workspace.share.linkFailed"),"error")}finally{h(!1)}},M=async()=>{if(E)try{await navigator.clipboard.writeText(E),p(u("workspace.share.linkCopied"),"success")}catch{p(u("workspace.share.linkFailed"),"error")}},O=async()=>{if(E){if(typeof navigator<"u"&&"share"in navigator){try{await navigator.share({url:E})}catch{}return}M()}},J=typeof navigator<"u"&&"share"in navigator;return e.jsx("div",{onClick:l,className:"fixed inset-0 z-50 flex items-center justify-center px-4",style:{background:g?"rgba(0,0,0,0.45)":"rgba(0,0,0,0)",backdropFilter:g?"blur(8px)":"blur(0px)",WebkitBackdropFilter:g?"blur(8px)":"blur(0px)",transition:"all 0.3s cubic-bezier(0.16, 1, 0.3, 1)"},children:e.jsxs("div",{onClick:R=>R.stopPropagation(),className:"flex w-full max-w-[480px] flex-col overflow-hidden rounded-[24px]",style:{background:f?"rgba(30, 30, 34, 0.95)":"rgba(255, 255, 255, 0.97)",backdropFilter:"blur(40px) saturate(1.8)",WebkitBackdropFilter:"blur(40px) saturate(1.8)",border:`1px solid ${f?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)"}`,boxShadow:f?"0 24px 80px rgba(0,0,0,0.6)":"0 24px 80px rgba(0,0,0,0.18)",transform:g?"translateY(0) scale(1)":"translateY(24px) scale(0.97)",opacity:g?1:0,transition:"all 0.35s cubic-bezier(0.16, 1, 0.3, 1)",maxHeight:"min(80vh, 640px)"},children:[e.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-3 px-6 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-[17px] font-bold",style:{color:"var(--text-primary)"},children:u("workspace.share.dialog.title")}),!E&&e.jsx("p",{className:"mt-1.5 text-[12.5px] leading-relaxed",style:{color:"var(--text-tertiary)"},children:T.length===0?u("workspace.share.dialog.subtitleNoTools"):u("workspace.share.dialog.subtitle")})]}),e.jsx("button",{onClick:l,className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-[var(--hover-bg)]",style:{color:"var(--text-tertiary)"},"aria-label":"close",children:e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 pt-4",children:E?e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wide",style:{color:"var(--text-tertiary)"},children:u("workspace.share.dialog.linkLabel")}),e.jsxs("div",{className:"flex items-center gap-2 rounded-xl border px-3 py-2.5",style:{borderColor:"var(--card-border)",background:"var(--input-bg)"},children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",style:{color:"var(--text-primary)"},children:E}),e.jsx("button",{type:"button",onClick:M,className:"shrink-0 rounded-full px-3 py-1.5 text-[12px] font-bold transition-all active:scale-95",style:{background:"var(--text-primary)",color:"var(--page-bg)"},children:u("workspace.share.dialog.copyBtn")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 rounded-2xl border p-3.5",style:{background:"var(--card-bg)",borderColor:"var(--card-border)"},children:[e.jsx("div",{className:"mb-2.5 text-[11px] font-bold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:u("workspace.share.dialog.includedTitle")}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:[["overview",u("workspace.share.dialog.includedOverview")],["summary",u("workspace.share.dialog.includedSummary")],["timeline",u("workspace.share.dialog.includedTimeline")]].map(([R,I])=>{const _=b[R];return e.jsxs("button",{type:"button",onClick:()=>x(te=>({...te,[R]:!te[R]})),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[12px] font-semibold transition-all active:scale-95",style:{background:_?"var(--input-bg)":"transparent",color:_?"var(--text-primary)":"var(--text-tertiary)",border:`1px solid ${_?"transparent":"var(--card-border)"}`,opacity:_?1:.7},"aria-pressed":_,children:[_?e.jsx("svg",{className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",style:{color:"rgb(34, 197, 94)"},children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsx("span",{className:"inline-block h-3 w-3 rounded-full",style:{border:"1.5px solid var(--text-tertiary)",opacity:.5}}),I]},R)})})]}),T.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between text-[11px]",style:{color:"var(--text-tertiary)"},children:[e.jsx("span",{className:"font-bold uppercase tracking-wider",children:u("workspace.share.dialog.toolsTitle")}),e.jsx("span",{children:u("workspace.share.dialog.selectionCount",{selected:S.length,max:wt})})]}),e.jsx("ul",{className:"flex flex-col gap-2",children:T.map(R=>{const I=S.includes(R.id),_=!I&&S.length>=wt,te=F.has(R.id);return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>k(R.id),disabled:_,className:"flex w-full items-center gap-3 rounded-xl border px-3 py-2.5 text-left transition-all active:scale-[0.99] disabled:cursor-not-allowed disabled:opacity-40",style:{borderColor:I?R.color:"var(--card-border)",background:I?`${R.color}14`:"var(--card-bg)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl",style:{background:`${R.color}20`,color:R.color},children:e.jsx(Ce,{id:R.id,className:"h-[18px] w-[18px]"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:R.label}),te&&e.jsx("span",{className:"shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-bold",style:{background:"var(--input-bg)",color:"var(--text-tertiary)"},children:u("workspace.share.dialog.recentLabel")})]})}),e.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md border-2 transition-colors",style:{borderColor:I?R.color:"var(--card-border)",background:I?R.color:"transparent"},children:I&&e.jsx("svg",{className:"h-3 w-3 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})})]})},R.id)})})]})]})}),e.jsx("div",{className:"shrink-0 px-6 pb-5 pt-4",children:E?e.
2jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{C(null)},className:"flex-1 rounded-full py-3 text-[13px] font-semibold transition-all active:scale-[0.98]",style:{background:f?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.04)",color:"var(--text-secondary)"},children:u("workspace.share.dialog.regenerate")}),e.jsx("button",{type:"button",onClick:O,className:"flex-[1.4] rounded-full py-3 text-[14px] font-bold transition-all active:scale-[0.98]",style:{background:"var(--text-primary)",color:"var(--page-bg)"},children:u(J?"workspace.share.dialog.shareBtn":"workspace.share.dialog.copyBtn")})]}):e.jsx("button",{type:"button",onClick:L,disabled:j,className:"flex w-full items-center justify-center gap-2 rounded-full py-3 text-[14px] font-bold transition-all active:scale-[0.98] disabled:opacity-50",style:{background:"var(--text-primary)",color:"var(--page-bg)"},children:j?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent","aria-hidden":!0}),u("workspace.share.dialog.creating")]}):u("workspace.share.dialog.createBtn")})})]})})}const rt=(t,r,n)=>Math.max(r,Math.min(n,t));function on({left:t,right:r,initialLeftPercent:n=50,minLeftPercent:a=25,maxLeftPercent:s=75,storageKey:l,className:o,gapPx:u=0,panelRadius:d=0}){const{theme:f}=ye(),p=i.useRef(null),[g,v]=i.useState(!1),[S,N]=i.useState(!1),[b,x]=i.useState(()=>{if(l)try{const L=localStorage.getItem(l);if(L){const M=parseFloat(L);if(!Number.isNaN(M))return rt(M,a,s)}}catch{}return rt(n,a,s)});i.useEffect(()=>{if(l)try{localStorage.setItem(l,String(b))}catch{}},[b,l]);const j=i.useCallback(L=>{const M=p.current;if(!M)return;const O=M.getBoundingClientRect(),J=(L-O.left)/O.width*100;x(rt(J,a,s))},[a,s]),h=i.useCallback(L=>{L.preventDefault(),v(!0),j(L.clientX)},[j]),E=i.useCallback(L=>{v(!0),L.touches[0]&&j(L.touches[0].clientX)},[j]);i.useEffect(()=>{const L=J=>{g&&j(J.clientX)},M=J=>{!g||!J.touches[0]||j(J.touches[0].clientX)},O=()=>v(!1);return window.addEventListener("mousemove",L),window.addEventListener("touchmove",M,{passive:!1}),window.addEventListener("mouseup",O),window.addEventListener("touchend",O),()=>{window.removeEventListener("mousemove",L),window.removeEventListener("touchmove",M),window.removeEventListener("mouseup",O),window.removeEventListener("touchend",O)}},[g,j]);const C=i.useCallback(L=>{let M=0;L.key==="ArrowLeft"&&(M=L.shiftKey?-5:-1),L.key==="ArrowRight"&&(M=L.shiftKey?5:1),M!==0&&(L.preventDefault(),x(O=>rt(O+M,a,s)))},[a,s]),T=u>0,F=u/2,k=i.useMemo(()=>{const L=g?"none":"width 300ms cubic-bezier(0.4, 0, 0.2, 1)",M=d>0?`${d}px`:void 0;return{container:{display:"flex",width:"100%",height:"100%",position:"relative",overflow:"hidden",gap:T?`${u}px`:void 0},left:{width:T?`calc(${b}% - ${F}px)`:`${b}%`,height:"100%",overflow:"hidden",transition:L,flexShrink:0,borderRadius:M},right:{width:T?`calc(${100-b}% - ${F}px)`:`${100-b}%`,height:"100%",overflow:"hidden",transition:L,flexShrink:0,borderRadius:M},grabber:{position:"absolute",left:`${b}%`,top:0,transform:"translateX(-50%)",width:T?`${Math.max(u,20)}px`:"20px",height:"100%",cursor:"col-resize",zIndex:10,display:"flex",justifyContent:"center",alignItems:"center",background:"transparent",transition:g?"opacity 150ms ease":"left 300ms cubic-bezier(0.4, 0, 0.2, 1), opacity 150ms ease"},handle:{width:T?g||S?"3px":"0px":g||S?"2px":"1px",borderRadius:"2px",height:T?"48px":"100%",background:f==="dark"?"#555":"#bbb",transition:"width 150ms ease, opacity 150ms ease",opacity:T?g||S?.6:0:1},overlay:{position:"fixed",inset:0,cursor:"col-resize",zIndex:9999}}},[b,f,g,S,T,u,F,d]);return e.jsxs("div",{ref:p,className:o,style:k.container,children:[g&&e.jsx("div",{style:k.overlay}),e.jsx("div",{style:k.left,children:t}),e.jsx("div",{style:k.right,children:r}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panels",tabIndex:0,style:k.grabber,onMouseDown:h,onTouchStart:E,onKeyDown:C,onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1),children:e.jsx("div",{style:k.handle})})]})}function ln(t){const{user:r}=ut(),[n,a]=i.useState(()=>new Map);return i.useEffect(()=>{if(!r||!t){a(new Map);return}const s=Et(Ke(ee,"clips"),dr("userId","==",r.uid),dr("sourceNoteId","==",t));return kr(s,o=>{const u=new Map;o.docs.forEach(d=>{const f=d.data();if(!f.toolId||!f.language)return;const p=`${f.toolId}:${f.language}`,g=u.get(p)||[];
2g.push({clipId:d.id,resultHash:f.resultHash}),u.set(p,g)}),a(u)})},[r,t]),n}function cn({noteId:t,toolId:r,language:n,result:a,disabled:s}){const{t:l}=B(),{showToast:o}=qe(),{showUpgradeModal:u}=pt(),d=Nr(),f=ln(t),[p,g]=i.useState(!1),v=`${r}:${n}`,S=f.get(v)||[],N=i.useMemo(()=>a?Br(a):null,[a]),b=i.useMemo(()=>{if(N)return S.find(C=>C.resultHash===N)},[N,S]),x=!!b,j=S.length-(x?1:0),h=i.useCallback(async()=>{if(!p){g(!0);try{x&&b?(await Bs(b.clipId),$e("light"),o(l("workspace.clip.toast.unsaved"),"info")):(await Fs({noteId:t,toolId:r,language:n}),$e("success"),o(l("workspace.clip.toast.saved"),"success",3e3,()=>{ks("clips")||d("/clips")}))}catch(C){C instanceof _s?C.code==="CLIP_LOCKED"?u("CLIP_LOCKED"):C.code==="CLIP_LIMIT"?u("CLIP_LIMIT"):C.code==="UNAUTHORIZED"?o(l("workspace.clip.toast.loginRequired"),"warning"):o(l("workspace.clip.toast.error"),"error"):o(l("workspace.clip.toast.error"),"error")}finally{g(!1)}}},[p,x,b,t,r,n,o,u,l,d]),E=x?l("workspace.clip.saved"):j>0?`${l("workspace.clip.save")} · ${j}`:l("workspace.clip.save");return e.jsxs("button",{onClick:h,disabled:s||p,className:"flex items-center gap-1.5 rounded-full border font-medium transition-colors hover:bg-[var(--hover-bg)] disabled:opacity-50",style:{height:"var(--btn-height-md)",padding:"0 var(--btn-px-md)",fontSize:"var(--btn-font)",borderColor:x?"rgb(245 158 11)":"var(--card-border)",color:x?"rgb(245 158 11)":"var(--text-secondary)",background:x?"rgba(245 158 11 / 0.10)":void 0},"aria-label":E,"aria-pressed":x,children:[p?e.jsx("span",{className:"h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent","aria-hidden":!0}):e.jsx("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:x?"currentColor":"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M19 21l-7-5-7 5V5a2 2 0 012-2h10a2 2 0 012 2z"})}),E]})}function dn(t){const r=t.split(":").map(n=>parseInt(n,10));return r.length===2?r[0]*60+r[1]:r.length===3?r[0]*3600+r[1]*60+r[2]:0}const Fr=/\s*[([]?\b(\d{1,2}:\d{2}(?::\d{2})?)\b[)\]]?\s*/g;function un(t){return t.replace(Fr," ").replace(/[ \t]{2,}/g," ").replace(/ +\n/g,`
3`).trim()}function hn(t,r){const n=new RegExp(Fr.source,"g");if(!r)return t.replace(n," ").trim();const a=[];let s=0,l,o=0;for(;(l=n.exec(t))!==null;){l.index>s&&a.push(t.slice(s,l.index));const u=dn(l[1]);a.push(e.jsxs("button",{onClick:()=>r(u),className:"timestamp-pill",type:"button",children:[e.jsx("svg",{className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polygon",{points:"5 3 19 12 5 21 5 3",fill:"currentColor"})}),l[1]]},`ts-${o++}`)),s=l.index+l[0].length}return s<t.length&&a.push(t.slice(s)),a.length?a:t}function he(t,r){return dt.Children.map(t,n=>typeof n=="string"?hn(n,r):n)}const Ve=500;class ct extends Error{constructor(n,a,s,l){super(n);tt(this,"code");tt(this,"status");tt(this,"details");this.name="ChatRequestError",this.code=a,this.status=s,this.details=l}}async function pn(t,r,n,a,s,l){const o=Ye.currentUser;if(!o)throw new ct(Ne("UNAUTHORIZED"),"UNAUTHORIZED",401);const u=await o.getIdToken(),d=await fetch(`${Lt}/askVideoFn`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify({noteId:t,question:r.trim().slice(0,Ve),history:n.slice(-6),locale:a}),signal:l});if(!d.ok){const p=await d.json().catch(()=>null),g=(p==null?void 0:p.code)||(p==null?void 0:p.error)||(d.status===429||d.status===503?"AI_UNAVAILABLE":d.status>=500?"INTERNAL_ERROR":"UNKNOWN");throw new ct(Ne(p??g),g,d.status,p==null?void 0:p.details)}let f=!1;await Lr(d,{onMeta:p=>{var v;if(f)return;const g=p;(v=s.onMeta)==null||v.call(s,{remaining:typeof g.remaining=="number"?g.remaining:null,messageId:typeof g.messageId=="string"?g.messageId:null})},onContent:p=>{f||s.onContent(p)},onError:p=>{f||l!=null&&l.aborted||(f=!0,s.onError(p,Ne(p)))},onComplete:p=>{f||l!=null&&l.aborted||(f=!0,p?s.onComplete():s.onError("STREAM_INTERRUPTED",Ne("STREAM_INTERRUPTED")))}})}async function xn(t,r=60){const n=Et(Ke(ee,"notes",t,"chat"),wr("createdAt","asc"),vs(r)),a=await jt(n),s=[];return a.forEach(l=>{const o=l.data();o.role!=="user"&&o.role!=="assistant"||typeof o.content!="string"||s.push({id:l.id,role:o.role,content:o.content,createdAt:typeof o.createdAt=="string"?o.createdAt:""})}),s}const fn=6e3;let mn=0;const mr=t=>`local-${t}-${Date.now().toString(36)}-${(mn++).toString(36)}`;function gn(t){const r=[];for(let n=0;n<t.length;n++){const a=t[n];if(a.role!=="assistant"||a.status!=="done"&&a.status!=="stopped"||!a.content.trim())continue;const s=t[n-1];(s==null?void 0:s.role)==="user"&&r.push({role:"user",content:s.content}),r.push({role:"assistant",content:a.content})}return r.slice(-6)}function gr(t){return/^[A-Z][A-Z0-9_]+$/.test(t)&&Tr.exists(t,{ns:"errors"})}function bn({noteId:t,isOwner:r,locale:n,active:a}){const{t:s}=B(),{user:l,openLogin:o}=ut(),{plan:u,limits:d,chatsLeft:f,usage:p}=pt(),[g,v]=i.useState([]),S=i.useRef([]);i.useEffect(()=>{S.current=g},[g]);const[N,b]=i.useState(null),x=i.useRef(!1),j=i.useRef(null);i.useEffect(()=>(v([]),()=>{var $;($=j.current)==null||$.abort(),j.current=null,x.current=!1}),[t]);const[h,E]=i.useState(!1),C=i.useRef(!1),T=i.useRef(null),F=i.useRef(null),k=(l==null?void 0:l.uid)??null;i.useEffect(()=>{if(!a||!t||!r||!k||T.current===t)return;let $=!1,V=!1;const A=()=>{V||(V=!0,T.current=t,C.current=!1,E(!1))};C.current=!0,E(!0);const X=window.setTimeout(()=>{$||V||(console.warn("[chat] history load timed out"),A())},fn);return xn(t).then(P=>{if($)return;const Z=V;if(A(),Z&&F.current===t)return;const K=P.map(re=>({id:re.id,role:re.role,content:re.content,status:"done"}));v(re=>{const se=new Set(re.map(ue=>ue.id));return[...K.filter(ue=>!se.has(ue.id)),...re]})}).catch(P=>{$||(A(),console.warn("[chat] history load failed:",P))}).finally(()=>{window.clearTimeout(X)}),()=>{$=!0,window.clearTimeout(X),C.current=!1,E(!1)}},[a,t,r,k]);const[L,M]=i.useState(void 0);i.useEffect(()=>{M(void 0)},[f,p==null?void 0:p.todayChatCount,p==null?void 0:p.todayChatDateKST,d.dailyChatLimit]);const O=l?L??f:null,J=O===0,R=i.useRef(O);i.useEffect(()=>{R.current=O},[O]);const I=i.useCallback(async($,V,A,X)=>{var ze;if(!t)return;const P=new AbortController;(ze=j.current)==null||ze.abort(),j.current=P,x.current=!0,b(X);const Z=R.current;typeof Z=="number"&&M(Math.max(0,Z-1));const K=D=>v(U=>U.map(m=>m.id===X?D(m):m)),re=()=>K(D=>D.status==="streaming"?{...D,status:"stopped"}:D);let se=!1,ue=!1;try{await pn(t,$,V,n,{onMeta:D=>{se=!0,typeof D.remaining=="number"&&M(D.remaining)},onContent:D=>{D&&(ue=!0),K(U=>({...U,content:U.content+D}))},onError:(D,U)=>{ue||M(void 0),K(m=>
3({...m,status:"error",errorMessage:gr(D)?U:s("chat.errors.network")})),$e("error")},onComplete:()=>{K(D=>({...D,status:"done"}))}},P.signal),P.signal.aborted?(se||M(void 0),re()):K(D=>D.status!=="streaming"?D:D.content.trim()?{...D,status:"done"}:{...D,status:"error",errorMessage:s("chat.errors.network")})}catch(D){if(P.signal.aborted)se||M(void 0),re();else if(D instanceof ct&&D.code==="CHAT_DAILY_LIMIT")M(0),v(U=>U.filter(m=>m.id!==X&&m.id!==A));else{M(void 0);const U=D instanceof ct?gr(D.code)?D.message:Ne("UNKNOWN"):s("chat.errors.network");K(m=>({...m,status:"error",errorMessage:U})),$e("error")}}finally{j.current===P&&(j.current=null),x.current=j.current!==null,b(D=>D===X?null:D)}},[t,n,s]),_=i.useCallback(($,V)=>{const A=$.trim();if(!A||!t||x.current)return!1;if(!l)return o(),!1;if(R.current===0||C.current)return!1;F.current=t;const X=gn(S.current),P={id:mr("u"),role:"user",content:A,status:"done"},Z={id:mr("a"),role:"assistant",content:"",status:"streaming",question:A};return x.current=!0,v(K=>[...K,P,Z]),
3Cr(Sr.CHAT_ASKED,{plan:u,owner:r,locale:n,suggested:(V==null?void 0:V.suggested)===!0,turn:X.length/2}),I(A,X,P.id,Z.id),!0},[t,l,o,I,u,r,n]),te=i.useCallback(()=>{var $;($=j.current)==null||$.abort()},[]),Se=i.useCallback(()=>{var $;($=j.current)==null||$.abort(),v([])},[]),Te=i.useCallback($=>{const V=S.current,A=V.findIndex(K=>K.id===$),X=V[A];if(!(X!=null&&X.question)||x.current||C.current||R.current===0)return;const P=V[A-1],Z=new Set([$,...(P==null?void 0:P.role)==="user"?[P.id]:[]]);v(K=>K.filter(re=>!Z.has(re.id))),_(X.question)},[_]);return{messages:g,streaming:N!==null,historyLoading:h,signedIn:!!l,quota:{plan:u,limit:d.dailyChatLimit,remaining:O},limitReached:J,send:_,stop:te,reset:Se,retry:Te}}const _r="",Wr="",yn=/([\uE000\uE001])/;function vn(t,r){let n=t.replace(/[\uE000\uE001]/g,"");return n=n.replace(/\*\*([^*\n]+?)\*\*/g,`${_r}$1${Wr}`),r&&(n=n.replace(/\*\*(?=[^*]*$)/,"")),n}function Q(t,r){const n=[];let a=!1,s=0;return i.Children.forEach(t,l=>{if(typeof l=="string"){for(const o of l.split(yn)){if(o===_r){a=!0;continue}if(o===Wr){a=!1;continue}if(!o)continue;const u=he(o,r);n.push(a?e.jsx("strong",{children:u},s++):e.jsx(i.Fragment,{children:u},s++))}return}l==null||typeof l=="boolean"||n.push(a?e.jsx("strong",{children:l},s++):e.jsx(i.Fragment,{children:l},s++))}),n}function wn({content:t,streaming:r=!1,onSeek:n}){const a={p:({children:s})=>e.jsx("p",{children:Q(s,n)}),li:({children:s})=>e.jsx("li",{children:Q(s,n)}),strong:({children:s})=>e.jsx("strong",{children:Q(s,n)}),em:({children:s})=>e.jsx("em",{children:Q(s,n)}),del:({children:s})=>e.jsx("del",{children:Q(s,n)}),td:({children:s})=>e.jsx("td",{children:Q(s,n)}),th:({children:s})=>e.jsx("th",{children:Q(s,n)}),h1:({children:s})=>e.jsx("p",{className:"chat-md-h",children:Q(s,n)}),h2:({children:s})=>e.jsx("p",{className:"chat-md-h",children:Q(s,n)}),h3:({children:s})=>e.jsx("p",{className:"chat-md-h",children:Q(s,n)}),h4:({children:s})=>e.jsx("p",{className:"chat-md-h",children:Q(s,n)}),h5:({children:s})=>e.jsx("p",{className:"chat-md-h",children:Q(s,n)}),h6:({children:s})=>e.jsx("p",{className:"chat-md-h",children:Q(s,n)}),a:({children:s})=>e.jsx("span",{className:"chat-md-link",children:Q(s,n)}),img:()=>null,table:({children:s})=>e.jsx("div",{className:"chat-md-table",children:e.jsx("table",{children:s})})};return e.jsx("div",{className:`chat-md${r?" is-streaming":""}`,children:e.jsx(nt,{remarkPlugins:[at],skipHtml:!0,components:a,children:vn(t,r)})})}const kn=i.memo(wn),jn="M12 2.5c.55 5.2 3.3 8.35 9.5 9.5-6.2 1.15-8.95 4.3-9.5 9.5-.55-5.2-3.3-8.35-9.5-9.5 6.2-1.15 8.95-4.3 9.5-9.5z";function Hr(t){return`${t}${i.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`}function Ur({id:t}){return e.jsx("defs",{children:e.jsxs("linearGradient",{id:t,x1:"0",y1:"0",x2:"1",y2:"1",children:[e.jsx("stop",{offset:"0",style:{stopColor:"var(--chat-spark-a)"}}),e.jsx("stop",{offset:".5",style:{stopColor:"var(--chat-spark-b)"}}),e.jsx("stop",{offset:"1",style:{stopColor:"var(--chat-spark-c)"}})]})})}function be({size:t=14,color:r,className:n,style:a}){const s=Hr("chatspk");return e.jsxs("svg",{className:n,style:{display:"block",flex:"none",...a},width:t,height:t,viewBox:"0 0 24 24","aria-hidden":"true",children:[!r&&e.jsx(Ur,{id:s}),e.jsx("path",{d:jn,fill:r??`url(#${s})`})]})}function Vr({size:t=16,strokeWidth:r=1.9,gradient:n=!1,className:a}
3){const s=Hr("chatask"),l=n?`url(#${s})`:"currentColor";return e.jsxs("svg",{className:a,style:{display:"block",flex:"none"},width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:l,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n&&e.jsx(Ur,{id:s}),e.jsx("path",{d:"M12.25 4H6.5A2.5 2.5 0 0 0 4 6.5v8.75a2.5 2.5 0 0 0 2.5 2.5H8v3.25l4.25-3.25h5.25a2.5 2.5 0 0 0 2.5-2.5V11.5"}),e.jsx("path",{fill:l,stroke:"none",d:"M18.75 1.25c.3 2.5 1.25 3.45 3.75 3.75-2.5.3-3.45 1.25-3.75 3.75-.3-2.5-1.25-3.45-3.75-3.75 2.5-.3 3.45-1.25 3.75-3.75z"})]})}function ve({size:t,strokeWidth:r,children:n}){return e.jsx("svg",{style:{display:"block",flex:"none"},width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:n})}function Nn({size:t=16}){return e.jsxs(ve,{size:t,strokeWidth:1.9,children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1.5"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1.5"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1.5"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1.5"})]})}function Kr({size:t=18}){return e.jsx(ve,{size:t,strokeWidth:2.4,children:e.jsx("path",{d:"M12 19V5.5M5.75 11.5 12 5.25l6.25 6.25"})})}function Cn({size:t=12}){return e.jsx("svg",{style:{display:"block"},width:t,height:t,viewBox:"0 0 12 12","aria-hidden":"true",children:e.jsx("rect",{width:"12",height:"12",rx:"2.5",fill:"currentColor"})})}function Sn({size:t=15}){return e.jsxs(ve,{size:t,strokeWidth:1.9,children:[e.jsx("rect",{x:"9",y:"9",width:"12",height:"12",rx:"2.5"}),e.jsx("path",{d:"M5 15H4.5A2.5 2.5 0 0 1 2 12.5v-8A2.5 2.5 0 0 1 4.5 2h8A2.5 2.5 0 0 1 15 4.5V5"})]})}function Tn({size:t=15}){return e.jsx(ve,{size:t,strokeWidth:2.4,children:e.jsx("path",{d:"M20 6 9 17l-5-5"})})}function $t({size:t=14}){return e.jsxs(ve,{size:t,strokeWidth:2,children:[e.jsx("path",{d:"M3.5 12a8.5 8.5 0 1 0 2.5-6L3.5 8.5"}),e.jsx("path",{d:"M3.5 3.5v5h5"})]})}function En({size:t=20}){return e.jsx(ve,{size:t,strokeWidth:2.2,children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})}function Ln({size:t=16}){return e.jsxs(ve,{size:t,strokeWidth:2,children:[e.jsx("circle",{cx:"12",cy:"12",r:"9.25"}),e.jsx("path",{d:"M12 11v5.5"}),e.jsx("circle",{cx:"12",cy:"7.75",r:".9",fill:"currentColor",stroke:"none"})]})}function Mn({size:t=18}){return e.jsx(ve,{size:t,strokeWidth:2.2,children:e.jsx("path",{d:"M18 15l-6-6-6 6"})})}const br={general:["keyClaims","numbers","counter","beginner"],finance:["keyClaims","stocks","numbers","risks"],news:["whatHappened","numbers","counter","outlook"],education:["concepts","beginner","example","confusing"],interview:["keyClaims","quote","counter","beginner"],review:["prosCons","price","whoFor","verdict"],cooking:["ingredients","steps","tips","substitute"]};function Rn(t){const{t:r}=B(),n=r;return(br[t]??br.general).map(a=>n(`chat.suggest.${a}`))}function In({category:t,onPick:r,disabled:n,align:a="center"}){const s=Rn(t);return e.jsx("div",{className:`chat-sugs${a==="left"?" is-left":""}`,children:s.map(l=>e.jsxs("button",{type:"button",className:"chat-sug",disabled:n,onClick:()=>r(l),children:[e.jsx(be,{size:12}),e.jsx("span",{children:l})]},l))})}function An(t){var r;try{if((r=navigator.clipboard)!=null&&r.writeText)return navigator.clipboard.writeText(t).catch(()=>yr(t)),!0}catch{}return yr(t)}function yr(t){try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();const n=document.execCommand("copy");return document.body.removeChild(r),n}catch{return!1}}function $n(){const{t}=B();return e.jsxs("span",{className:"chat-think",role:"status",children:[t("chat.thread.thinking"),e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{})]})}const Dn=i.memo(function({message:r,onSeek:n,onRetry:a,retryDisabled:s}){const{t:l}=B(),{showToast:o}=qe(),[u,d]=i.useState(!1),{status:f,content:p}=r,g=f==="streaming",v=p.trim().length>0,S=()=>{An(p.replace(/\*\*/g,"").trim())&&(d(!0),o(l("chat.thread.copied"),"success"),window.setTimeout(()=>d(!1),1500))};return e.jsxs("div",{className:"chat-msg is-ai",children:[e.jsx("span",{className:`chat-av${g?" is-busy":""}`,children:e.jsx(be,{size:14})}),e.jsxs("div",{className:"chat-abody",children:[g&&!v&&e.jsx($n,{}),v&&e.jsx(kn,{content:p,streaming:g,onSeek:n}),f==="stopped"&&e.jsx("p",{className:"chat-muted",children:l("chat.thread.stopped")}),f==="error"&&e.jsxs("div",{className:`chat-err${v?" has-content":""}`,role:"alert",children:[e.jsxs("div",{className:"chat-err-h",children:[e.jsx(Ln,{size:16}),e.jsx("span",{children:r.errorMessage||l("chat.errors.network")})]}),r.question&&e.jsxs("button",{type:"button",className:"chat-retr
3y",onClick:()=>a(r.id),disabled:s,children:[e.jsx($t,{size:13}),l("chat.thread.retry")]})]}),!g&&v&&f!=="error"&&e.jsx("div",{className:"chat-acts",children:e.jsx("button",{type:"button",onClick:S,"aria-label":l("chat.thread.copy"),title:l("chat.thread.copy"),children:u?e.jsx(Tn,{size:15}):e.jsx(Sn,{size:15})})})]})]})});function zn({content:t}){return e.jsx("div",{className:"chat-msg is-user",children:e.jsx("div",{className:"chat-bubble",children:t})})}function On({chat:t,category:r,onSeek:n}){const{t:a}=B(),{messages:s,historyLoading:l,limitReached:o,streaming:u,quota:d}=t,f=i.useRef(null),p=i.useRef(!0),g=s.reduce((b,x)=>x.role==="user"?b+1:b,0),v=i.useRef(g),S=s.length===0,N=()=>{const b=f.current;b&&(p.current=b.scrollHeight-b.scrollTop-b.clientHeight<48)};return i.useLayoutEffect(()=>{const b=f.current;b&&(g>v.current&&(p.current=!0),v.current=g,p.current&&(b.scrollTop=b.scrollHeight))},[s,g,o]),i.useEffect(()=>{const b=f.current;if(!b||typeof ResizeObserver>"u")return;const x=new ResizeObserver(()=>{p.current&&(b.scrollTop=b.scrollHeight)});return x.observe(b),()=>x.disconnect()},[]),e.jsx("div",{ref:f,className:`chat-scroll${S?" is-empty":""}`,onScroll:N,role:"log","aria-busy":u,children:S&&l?e.jsx("div",{className:"chat-loading",children:e.jsxs("span",{className:"chat-think",children:[a("chat.thread.loadingHistory"),e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{})]})}):S?e.jsxs("div",{className:"chat-hero",children:[e.jsx("div",{className:"chat-hero-ico grad-ring",children:e.jsx(Vr,{size:26,strokeWidth:1.7,gradient:!0})}),e.jsx("h3",{children:a("chat.empty.title")}),e.jsx("p",{children:a("chat.empty.body")}),!o&&e.jsx(In,{category:r,onPick:b=>t.send(b,{suggested:!0})})]}):e.jsxs(e.Fragment,{children:[s.map(b=>b.role==="user"?e.jsx(zn,{content:b.content},b.id):e.jsx(Dn,{message:b,onSeek:n,onRetry:t.retry,retryDisabled:u||o},b.id)),o&&!u&&e.jsx("div",{className:"chat-sysline",children:d.plan==="free"?a("chat.thread.limitLineFree"):a("chat.thread.limitLine")})]})})}const Pn=Math.floor(Ve*.8),Bn=140;function Fn({streaming:t,onSend:r,onStop:n,submitOnEnter:a,autoFocus:s,onFocus:l,sendDisabled:o}){const{t:u}=B(),[d,f]=i.useState(""),p=i.useRef(null),g=i.useRef(!1);i.useLayoutEffect(()=>{const x=p.current;x&&(x.style.height="0px",x.style.height=`${Math.min(x.scrollHeight,Bn)}px`)},[d]),i.useEffect(()=>{var x;s&&((x=p.current)==null||x.focus({preventScroll:!0}))},[s]),i.useEffect(()=>{var x;!t&&a&&g.current&&((x=p.current)==null||x.focus({preventScroll:!0}),g.current=!1)},[t,a]);const v=d.trim(),S=!t&&!o&&v.length>0,N=()=>{S&&(g.current=document.activeElement===p.current,r(d)&&f(""))},b=x=>{!a||x.key!=="Enter"||x.shiftKey||x.nativeEvent.isComposing||x.keyCode===229||(x.preventDefault(),N())};return e.jsxs("div",{className:`chat-inp grad-ring${t?" is-busy":""}`,children:[e.jsx("textarea",{ref:p,className:"chat-ta",rows:1,value:d,maxLength:Ve,disabled:t,placeholder:u(t?"chat.input.placeholderStreaming":"chat.input.placeholder"),"aria-label":u("chat.input.label"),enterKeyHint:a?"send":"enter",onChange:x=>f(x.target.value),onKeyDown:b,onFocus:l}),d.length>=Pn&&!t&&e.jsxs("span",{className:`chat-len${d.length>=Ve?" is-max":""}`,"aria-live":"polite",children:[d.length,"/",Ve]}),t?e.jsx("button",{type:"button",className:"chat-send is-stop",onClick:n,"aria-label":u("chat.input.stop"),children:e.jsx(Cn,{})}):e.jsx("button",{type:"button",className:`chat-send${S?" is-ready":""}`,onClick:N,disabled:!S,"aria-label":u("chat.input.send"),onMouseDown:x=>x.preventDefault(),children:e.jsx(Kr,{})})]})}const _n=10;function Wn({quota:t}){const{t:r}=B(),{plan:n,limit:a,remaining:s}=t;if(s===null)return null;if(n==="pro"&&s>_n)return e.jsxs("div",{className:"chat-cnt is-pro",children:[e.jsx(be,{size:11,color:"currentColor"}),e.jsx("span",{children:r("chat.quota.pro",{limit:a})})]});const l=a>0?Math.max(0,Math.min(100,s/a*100)):0;return e.jsxs("div",{className:"chat-cnt",children:[e.jsxs("span",{children:[r("chat.quota.remainingLabel")," ",e.jsx("b",{children:s}),"/",a]}),e.jsx("span",{className:"chat-meter","aria-hidden":"true",children:e.jsx("i",{style:{width:`${l}%`}})})]})}function Hn({quota:t,onUpgrade:r}){const{t:n}=B(),{plan:a,limit:s}=t,l=Nt.pro.dailyChatLimit,o=a==="free"?n("chat.limit.titleFree",{limit:s}):n("chat.limit.titlePaid",{limit:s}),u=a==="free"?n("chat.limit.bodyFree",{limit:s,proLimit:l}):a==="lite"?n("chat.limit.bodyLite",{proLimit:l}):n("chat.limit.bodyPro",{limit:s});return e.jsxs("div",{className:"chat-limit",role:"status",children:[e.jsxs("div",{className:"chat-limit-h",children:[e.jsx("span",{className:"chat-limit-ico",children:e.jsx(be,{size:20})}),e.jsxs("div",{children:[e.jsx("b",{children:o}),e.jsx("span",{children:u})]})]}),a!=="pro"&&e.jsxs("button",{type:"button",className:"chat-btn-brand",onClick:r,children:[e.jsx(be,{size:15,color:"#fff"}),n("chat.limit.cta")]})]})}function Un(){try{return typeof window<"u"&&window.matchMedia("(hover: hover) and (pointer: fine)").matches}catch{return!1}}function Yr({chat:t,variant:r,category:n,onSeek:a,autoFocus:s,onInputFocus:l}){const{showUpgradeModal:o}=pt();return e.jsxs("div",{className:`chat chat--${r}`,children:[e.jsx(On,{chat:t,category:n,onSeek:a}),e.jsx("div",{className:"chat-comp",children:t.limitReached&&!t.streaming?e.jsx(Hn,{quota:t.quota,onUpgrade:()=>o("CHAT_DAILY_LIMIT")}):e.jsxs(e.Fragment,{children:[e.jsx(Fn,{streaming:t.streaming,onSend:t.send,onStop:t.stop,submitOnEnter:r==="panel"||Un(),sendDisabled:t.historyLoading,autoFocus:s,onFocus:l}),e.jsx(Wn,{quota:t.quota})]})})]})}const qr="summix.chat.introSeen.v1";function Vn(){try{return localStorage.getItem(qr)==="1"}catch{return!0}}function vr(){try{localStorage.setItem(qr,"1")}catch{}}function Kn({mode:t,onChange:r,showNewChat:n,onNewChat:a,suppressCoach:s}){const{t:l}=B(),[o,u]=i.useState(Vn);i.useEffect(()=>{t==="chat"&&!o&&(u(!0),vr())},[t,o]);const d=()=>{u(!0),vr()};return e.jsxs("div",{className:"chat-rsw",children:[e.jsxs("div",{className:"chat-seg",role:"tablist",children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":t==="tools",className:t==="tools"?"is-on":void 0,onClick:()=>r("tools"),children:[e.jsx(Nn,{size:16}),e.jsx("span",{className:"chat-seg-l",children:l("chat.entry.tabTools")})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":t==="chat",className:t==="chat"?"is-on":void 0,onClick:()=>r("chat"),children:[e.jsx(Vr,{size:16}),e.jsx("span",{className:"chat-seg-l",children:l("chat.entry.tabAsk")}),!o&&t!=="chat"&&e.jsx("i",{className:"chat-ndot","aria-hidden":"true"})]}),!o&&t==="tools"&&!s&&e.jsxs("div",{className:"chat-coach",role:"note",children:[e.jsxs("b",{children:[e.jsx(be,{size:13}),l("chat.entry.coachTitle")]}),l("chat.entry.coachBody"),e.jsx("br",{}),e.jsx("button",{type:"button",className:"chat-coach-ok",onClick:d,children:l("chat.entry.coachOk")})]})]}),n&&e.jsxs("button",{type:"button",className:"chat-newchat",onClick:a,title:l("chat.entry.newChat"),children:[e.jsx($t,{size:14}),e.jsx("span",{children:l("chat.entry.newChat")})]})]})}const Yn=120,qn=6;function Xn({scrollRef:t,onOpen:r}){const{t:n}=B(),[a,s]=i.useState(!1);return i.useEffect(()=>{const l=t.current;if(!l)return;let o=l.scrollTop;const u=()=>{const d=l.scrollTop;if(d<Yn){s(!1),o=d;return}const f=d-o;Math.abs(f)<qn||(s(f>0),o=d)};return l.addEventListener("scroll",u,{passive:!0}),()=>l.removeEventListener("scroll",u)},[t]),e.jsx("div",{className:`chat-askbar print-hide${a?" is-collapsed":""}`,children:e.jsxs("button",{type:"button",className:"chat-askpill",onClick:r,"aria-label":n("chat.entry.askBarAria"),children:[e.jsx(be,{size:18}),e.jsx("span",{className:"chat-askpill-ph",children:n("chat.entry.askBarPlaceholder")}),e.jsx("span",{className:"chat-askpill-send","aria-hidden":"true",children:e.jsx(Kr,{size:18})})]})})}const Gn=110;function Jn(){const[t,r]=i.useState(null);return i.useEffect(()=>
3{const n=typeof window<"u"?window.visualViewport:null;if(!n)return;let a=0;const s=()=>{cancelAnimationFrame(a),a=requestAnimationFrame(()=>{r(l=>l&&l.height===n.height&&l.offsetTop===n.offsetTop?l:{height:n.height,offsetTop:n.offsetTop})})};return s(),n.addEventListener("resize",s),n.addEventListener("scroll",s),()=>{cancelAnimationFrame(a),n.removeEventListener("resize",s),n.removeEventListener("scroll",s)}},[]),t}function Zn({chat:t,category:r,title:n,thumbnail:a,onClose:s,onSeek:l,restoreTabBarOnClose:o=!0}){const{t:u}=B(),[d,f]=i.useState("full"),[p,g]=i.useState(0),v=i.useRef(null),S=Jn();ht(!0),i.useEffect(()=>(ot(!1),()=>{o&&ot(!0)}),[o]);const N=i.useRef(null);i.useEffect(()=>{const T=F=>{if(F.key!=="Escape")return;const k=N.current;if(k){const L=k.getBoundingClientRect(),M=document.elementFromPoint(L.left+L.width/2,L.top+Math.min(L.height/2,120));if(M&&!k.contains(M))return}s()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[s]);const b=i.useCallback(T=>{var F,k;(k=(F=document.activeElement)==null?void 0:F.blur)==null||k.call(F),f("half"),l(T)},[l]),x=T=>{v.current={startY:T.touches[0].clientY,dy:0}},j=T=>{const F=v.current;F&&(F.dy=T.touches[0].clientY-F.startY,g(Math.max(-40,F.dy)))},h=()=>{const T=v.current;v.current=null,g(0),T&&(T.dy>Gn?s():T.dy<-40/2&&d==="half"&&f("full"))},E=S?{top:0,bottom:"auto",height:S.height,transform:`translateY(${S.offsetTop}px)`}:void 0,C=v.current!==null;return Tt.createPortal(e.jsxs("div",{className:"chat-sheet-root print-hide",style:E,children:[e.jsx("div",{className:`chat-scrim sheet-overlay${d==="half"?" is-half":""}`,onClick:s,"aria-hidden":"true"}),e.jsxs("div",{ref:N,className:`chat-sheet sheet-content${d==="half"?" is-half":""}`,role:"dialog","aria-modal":d==="full","aria-label":u("chat.sheet.title"),style:p?{transform:`translateY(${p}px)`,transition:C?"none":void 0}:void 0,children:[e.jsxs("div",{className:"chat-sheet-grip",onTouchStart:x,onTouchMove:j,onTouchEnd:h,onTouchCancel:h,onClick:()=>{d==="half"&&f("full")},children:[e.jsx("i",{className:"chat-grab","aria-hidden":"true"}),e.jsxs("div",{className:"chat-shead",children:[a&&e.jsx("img",{className:"chat-sth",src:a,alt:"",referrerPolicy:"no-referrer"}),e.jsxs("div",{className:"chat-sh-t",children:[e.jsxs("b",{children:[e.jsx(be,{size:14}),u("chat.sheet.title")]}),e.jsx("span",{children:n})]}),t.messages.length>0&&e.jsx("button",{type:"button",className:"chat-icb",onClick:T=>{T.stopPropagation(),t.reset()},"aria-label":u("chat.entry.newChat"),title:u("chat.entry.newChat"),children:e.jsx($t,{size:17})}),d==="half"&&e.jsx("button",{type:"button",className:"chat-icb",onClick:T=>{T.stopPropagation(),f("full")},"aria-label":u("chat.sheet.expand"),children:e.jsx(Mn,{size:20})}),e.jsx("button",{type:"button",className:"chat-icb",onClick:T=>{T.stopPropagation(),s()},"aria-label":u("chat.sheet.close"),children:e.jsx(En,{size:20})})]})]}),e.jsx(Yr,{chat:t,variant:"sheet",category:r,onSeek:b,onInputFocus:()=>f("full")})]})]}),document.body)}const Qn=[];function ja(){var or,ir,lr,cr;const{id:t}=js(),r=Nr(),[n]=Ns(),a=Cs(),s=n.get("videoId"),l=((or=a.state)==null?void 0:or.preloadedVideo)??null,[o,u]=i.useState(null),[d,f]=i.useState(l||null),[p,g]=i.useState("summary"),[v,S]=i.useState(!0),[N,b]=i.useState(!1),[x,j]=i.useState(""),[h,E]=i.useState(null),[C,T]=i.useState(()=>new Map),[F,k]=i.useState(!1),L=i.useRef(null);i.useEffect(()=>(ot(!1),()=>{ot(!0)}),[]);const[M,O]=i.useState(!1),[J,R]=i.useState("tools"),I=!!((ir=a.state)!=null&&ir.chatSheet),_=i.useRef(!1),te=i.useRef(!1),[Se,Te]=i.useState(!1);i.useEffect(()=>(document.body.style.overflow=M?"hidden":"",()=>{document.body.style.overflow=""}),[M]);const[$,V]=i.useState(()=>typeof window>"u"?!1:localStorage.getItem("summix-video-collapsed")==="1");i.useEffect(()=>{typeof window>"u"||localStorage.setItem("summix-video-collapsed",$?"1":"0")},[$]);const[A,X]=i.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 767px)").matches:!1),P=A&&I,Z=i.useRef(null),[K,re]=i.useState(!1);i.useEffect(()=>{if(!A)return;const c=Z.current;if(!c)return;const y=()=>re(c.scrollTop>240);return c.addEventListener("scroll",y,{passive:!0}),()=>c.removeEventListener("scroll",y)},[A,v]),i.useEffect(()=>{const c=window.matchMedia("(max-width: 767px)"),y=w=>X(w.matches);return c.addEventListener("change",y),()=>c.removeEventListener("change",y)},[]);const se=i.useRef(null),ue=i.useRef(null),ze=i.useRef(null),D=i.useRef({}),U=i.useRef(0),{t:m}=B(),Ee=Rt(),{showToast:W}=qe(),Dt=Er(),{contentLanguage:ne}=Mt(),{theme:Le}=ye(),{user:G,openLogin:Oe}=ut(),{plan:xe,isLiteOrPro:we,limits:Xe,showUpgradeModal:ae,summariesLeft:zt}=pt(),[Ot,Ge]=i.useState(null),[Jr,Pt]=i.useState(null),[Zr,xt]=i.useState(!1),[Qr,Bt]=i.useState(!1),[es,Ft]=i.useState(!1),[_t,Wt]=i.useState(null);i.useEffect(()=>{const c=D.current[p],y=ze.current;if(c&&y){const z=c.parentElement.getBoundingClientRect(),H=c.getBoundingClientRect();y.style.left=`${H.left-z.left}
3px`,y.style.width=`${H.width}px`}},[p,v]),i.useEffect(()=>{if(!t)return;let c=!1;s&&Ue(pe(ee,"videos",s)).then(w=>{!c&&w.exists()&&f(w.data())}).catch(()=>{});async function y(w=3){try{const z=await Ue(pe(ee,"notes",t));if(c)return;if(z.exists()){const H={id:z.id,...z.data()};if(H.videoId&&H.videoId!==s&&Ue(pe(ee,"videos",H.videoId)).then(le=>{!c&&le.exists()&&f(le.data())}).catch(()=>{}),!H.summary&&w>0)return w===3&&u(H),await new Promise(le=>setTimeout(le,1200)),c?void 0:y(w-1);u(H)}else if(!s)try{const H=await Ue(pe(ee,"videos",t));!c&&H.exists()&&f(H.data())}catch{}}finally{c||S(!1)}}return y(),()=>{c=!0}},[t,s]);const Y=(o==null?void 0:o.videoId)||s||(d?void 0:t);i.useEffect(()=>{if(!Y||!t||!o||!d)return;let c=!1;const y=o.outputLanguage||ne||"ko",w=d.createdAt||null,z=Or(t,y);z?(T(z),k(!0)):k(!1);const H=qs(Y,t,y,w).catch(()=>new Map);return L.current=H,H.then(le=>{c||(T(le),k(!0))}),()=>{c=!0}},[Y,t,o,d,ne]);const[ts,ft]=i.useState(new Set);i.useEffect(()=>{t&&ft(Vs(t))},[t]);const ke=ts;i.useEffect(()=>{const c=Y;if(!c||!ue.current||v)return;if(window.YT)y(c);else{const w=document.createElement("script");w.src="https://www.youtube.com/iframe_api",document.head.appendChild(w),window.onYouTubeIframeAPIReady=()=>{y(c)}}function y(w){se.current&&se.current.destroy(),se.current=new YT.Player(ue.current,{videoId:w,width:"100%",height:"100%",playerVars:{autoplay:0,modestbranding:1,rel:0,playsinline:1}})}return()=>{var w;(w=se.current)==null||w.destroy(),se.current=null}},[Y,v]);const oe=i.useCallback(c=>{var y,w;(y=se.current)==null||y.seekTo(c,!0),(w=se.current)==null||w.playVideo()},[]),{recentIds:Ht,trackTool:Ut}=Qs(),Je=i.useCallback(async(c,y)=>{const w=Y;if(!w||!t)return;
3const z=c.isCustom===!0,H=z?"custom":"builtin",le=z?Br(c.prompt):void 0,ge=++U.current;E(c),b(!0),j("");let Fe="";try{await Ws(w,t,c.id,c.prompt,{onContent:ie=>{U.current===ge&&(Fe+=ie,j(ce=>ce+ie))},onError:ie=>{U.current===ge&&(W(ie,"error"),b(!1),$e("error"))},onComplete:()=>{if(U.current!==ge)return;b(!1),$e("success");const ie=z||y?"private":"shared",ce=(o==null?void 0:o.outputLanguage)||ne||"ko";Cr(Sr.TOOL_USED,{tool_id:z?c.baseToolId:c.id,is_custom:z,response_type:c.responseType||"markdown",category:(o==null?void 0:o.category)||"unknown",language:ce,regenerate:y});const _e={toolId:c.id,responseType:c.responseType||"markdown",result:Fe,language:ce,createdAt:new Date().toISOString(),source:ie};T(We=>{const He=new Map(We);return He.set(c.id,_e),He}),Xs(t,ce,c.id,_e),pr(t,c.id),ft(We=>{if(We.has(c.id))return We;const He=new Set(We);return He.add(c.id),He})}},{toolKind:H,forceRegenerate:y,promptHash:le,responseType:c.responseType||"markdown"})}catch(ie){if(U.current!==ge)return;W(ie instanceof Error?ie.message:m("workspace.tools.actionFailed"),"error"),b(!1)}},[Y,t,W,m,o,ne]),fe=i.useCallback(async c=>{if(!Y||!t)return;if(!G||(o==null?void 0:o.userId)!==G.uid){Bt(!0);return}if(c.isPro&&!Xe.canUseProTools){ae("PRO_TOOL_LOCKED");return}Ut(c.id);const w=c.isCustom===!0,z=250,H=Date.now(),le=++U.current;E(c),b(!0),j("");let ge=C;if(!F&&L.current){try{ge=await L.current}catch{ge=new Map}if(U.current!==le)return}const Fe=ge.get(c.id);if(Fe&&!w){const ie=Date.now()-H;if(ie<z&&(await new Promise(ce=>setTimeout(ce,z-ie)),U.current!==le))return;b(!1),j(Fe.result),pr(t,c.id),ft(ce=>{if(ce.has(c.id))return ce;const _e=new Set(ce);return _e.add(c.id),_e});return}await Je(c,!1)},[Y,t,Xe.canUseProTools,ae,Ut,C,F,Je,G,o==null?void 0:o.userId]),rs=i.useCallback(async()=>{if(h){if(!we){ae("REGENERATE_PRO_ONLY");return}await Je(h,!0)}},[h,we,ae,Je]),Vt=i.useCallback(c=>{navigator.clipboard.writeText(c),W(m("workspace.tools.copied"),"success")},[W]),[Me,Re]=i.useState(!1),[ss,Ie]=i.useState({phase:"",message:""}),Kt=i.useRef(null),mt=i.useCallback(async()=>{const c=Y;if(!c||!t||Me)return;Re(!0),Ie({phase:"init",message:m("progress.init")});const y=new AbortController;Kt.current=y;try{await Ss(c,t,{onPhase:w=>{w.phase==="transcript"&&w.status==="start"?Ie({phase:"transcript",message:m("progress.transcript")}
3):w.phase==="transcript"&&w.status==="done"?Ie({phase:"transcript_done",message:m("progress.transcriptDone",{count:w.segmentCount||0}),title:w.title}):w.phase==="classify"&&w.status==="done"?Ie(z=>({...z,phase:"classify_done",message:m("progress.classifyDone",{category:Ee[w.category]}),category:w.category})):w.phase==="analyze"&&w.status==="start"?Ie(z=>({...z,phase:"analyze",message:m("progress.analyze")})):w.phase==="analyze"&&w.status==="done"&&Ie(z=>({...z,phase:"analyze_done",message:m("progress.analyzeDone")}))},onContent:()=>{},onMeta:()=>{},onError:w=>{W(w,"error"),Re(!1)},onComplete:async()=>{const w=await Ue(pe(ee,"notes",t));w.exists()&&u({id:w.id,...w.data()}),W(m("workspace.reanalyze.completed"),"success"),Re(!1)}},y.signal,ne)}catch(w){if(y.signal.aborted){Re(!1);return}W(w instanceof Error?w.message:m("workspace.reanalyze.failed"),"error"),Re(!1)}},[Y,t,Me,W,ne,m,Ee]),ns=(o==null?void 0:o.summary)??null,as=(o==null?void 0:o.timeline)??null,q=Ls(o==null?void 0:o.category),os=(Le==="dark"?it[q]:lt[q]).text,Ze=i.useMemo(()=>As(q,m,ne),[q,m,ne]),{customTools:Ae}=Gs(q),gt=Ze.slice(0,ur),Pe=Ze.slice(ur),bt=Ae,Qe=Ht.map(c=>[...Ze,...bt].find(y=>y.id===c)).filter(c=>c!==void 0),Yt=i.useCallback(c=>{if(!G){Oe();return}if(!we){ae("CUSTOM_TOOL_LOCKED");return}const y=Nt[xe].maxCustomTools;if(Number.isFinite(y)&&Ae.length>=y){ae("CUSTOM_TOOL_LIMIT");return}Ge(c)},[G,Oe,we,xe,Ae.length,ae]),qt=i.useCallback(()=>{if(!G){Oe();return}if(!we){ae("CUSTOM_TOOL_LOCKED");return}const c=Nt[xe].maxCustomTools;if(Number.isFinite(c)&&Ae.length>=c){ae("CUSTOM_TOOL_LIMIT");return}xt(!0)},[G,Oe,we,xe,Ae.length,ae]),is=i.useCallback((c,y)=>{xt(!1),y&&W(m("workspace.tools.otherCategoryWarning"),"info"),Ge(c)},[W,m]),Xt=i.useCallback(()=>{if(t){if(!G||(o==null?void 0:o.userId)!==G.uid){W(m("workspace.share.ownerOnly"),"error");return}Ft(!0)}},[t,G,o==null?void 0:o.userId,W,m]),Gt=i.useCallback(()=>{var y,w,z,H;if(typeof window>"u")return;if(!Xe.canExportPdf){ae("PDF_EXPORT_LOCKED");return}const c=[];if(d&&c.push({id:"video",label:m("pages.sharedNote.printDialog.options.video")}),(y=o==null?void 0:o.summary)!=null&&y.overview&&c.push({id:"overview",label:m("pages.sharedNote.printDialog.options.overview")}),(z=(w=o==null?void 0:o.summary)==null?void 0:w.sections)!=null&&z.length&&c.push({id:"summary",label:m("pages.sharedNote.printDialog.options.summary")}),(H=o==null?void 0:o.timeline)!=null&&H.length&&c.push({id:"timeline",label:m("pages.sharedNote.printDialog.options.timeline")}),C.size>0&&c.push({id:"tools",label:m("pages.sharedNote.printDialog.options.tools")}),c.length===0){hr([]);return}Wt(c)},[d,o,C,m,Xe.canExportPdf,ae]),ls=i.useMemo(()=>Array.from(C.values()).map(c=>({toolId:c.toolId,responseType:c.responseType,result:c.result})),[C]),cs=i.useCallback(async c=>{if(!(!t||!o||c===o.category))try{await ws(pe(ee,"notes",t),{category:c}),u(y=>y&&{...y,category:c}),W(m("workspace.category.changed"),"success")}catch(y){console.error("Category update failed:",y),W(m("workspace.category.changeFailed"),"error")}},[t,o,W,m]),ds=i.useCallback(async()=>{if(!(!t||!await Dt({title:m("workspace.deleteNote.title"),body:m("workspace.deleteNote.body"),confirmLabel:m("workspace.deleteNote.confirm"),danger:!0})))try{await jr(pe(ee,"notes",t)),W(m("workspace.deleteNote.deleted"),"success"),a.key&&a.key!=="default"?r(-1):r("/library",{replace:!0})}catch(y){console.error("Delete failed:",y),W(m("workspace.deleteNote.failed"),"error")}},[t,Dt,W,r,m,a.key]),us=i.useCallback(c=>{const y=c,w=At(y.baseToolId,q,m,ne);w&&(Pt(y),Ge(w))},[q,m]),yt=i.useCallback(async c=>{try{await rn(c),W(m("workspace.deleteNote.deleted"),"success")}catch(y){W(y instanceof Error?y.message:m("workspace.deleteNote.failed"),"error")}},[W,m]),hs=!!G&&!!o&&o.userId===G.uid,Be=!!o&&!!t,me=bn({noteId:o?o.id:null,isOwner:hs,locale:ne,active:Se});i.useEffect(()=>{(J==="chat"||P)&&Te(!0)},[J,P]),i.useEffect(()=>{const c=a.state;if(!(c!=null&&c.chatSheet))return;const{chatSheet:y,...w}=c;r({pathname:a.pathname,search:a.search,hash:a.hash},{replace:!0,state:Object.keys(w).length?w:null})},[]);const ps=i.useCallback(()=>{I||(_.current=!0,r({pathname:a.pathname,search:a.search,hash:a.hash},{state:{...a.state??{},chatSheet:!0}}
3))},[I,r,a.pathname,a.search,a.hash,a.state]),xs=i.useCallback(()=>{if(me.stop(),!(!I||te.current))if(te.current=!0,_.current)r(-1);else{const c={...a.state??{}};delete c.chatSheet,r({pathname:a.pathname,search:a.search,hash:a.hash},{replace:!0,state:Object.keys(c).length?c:null})}},[me.stop,I,r,a.pathname,a.search,a.hash,a.state]),Jt=i.useRef(P);i.useEffect(()=>{Jt.current&&!P&&A&&me.stop(),I||(_.current=!1,te.current=!1),Jt.current=P},[P,I,A,me.stop]);const Zt=i.useRef(A);i.useEffect(()=>{Zt.current&&!A&&I&&R("chat"),Zt.current=A},[A,I]);const Qt=i.useCallback(c=>{var y;V(!1),A&&((y=Z.current)==null||y.scrollTo({top:0})),oe(c)},[A,oe]);if(v)return e.jsx("div",{className:"flex h-screen items-center justify-center bg-[var(--page-bg)]",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-gray-900 border-t-transparent dark:border-white dark:border-t-transparent"})});const er=((lr=d==null?void 0:d.title)==null?void 0:lr.trim())||"",vt=!/^video\s*title$/i.test(er)&&er||(v?"":m("workspace.videoFallback")),fs=(d==null?void 0:d.transcript)||Qn,et=!!(x||N),tr=A&&Be&&!P&&!M&&!et&&!Me,rr=e.jsxs("div",{className:"shrink-0 p-4 pb-0",children:[e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 pb-2",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(oa,{video:d,videoId:Y,category:q,hideCategoryBadge:$})}),e.jsxs("button",{onClick:()=>V(c=>!c),className:"flex shrink-0 items-center gap-1.5 rounded-full border px-3.5 py-1.5 text-[13px] font-semibold transition-colors hover:bg-[var(--hover-bg)]",style:{borderColor:"var(--card-border)",color:"var(--text-secondary)"},children:[e.jsx("svg",{className:"h-4 w-4 transition-transform",style:{transform:$?"rotate(180deg)":"rotate(0deg)"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M18 15l-6-6-6 6"})}),m($?"workspace.videoExpand":"workspace.videoCollapse")]})]}),$&&(()=>{const c=Le==="dark"?it[q]:lt[q];return e.jsxs("div",{onClick:()=>V(!1),role:"button",tabIndex:0,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&V(!1)},className:"group flex cursor-pointer items-stretch gap-3 overflow-hidden rounded-2xl p-2 pr-3.5 transition-all duration-200",style:{background:"var(--input-bg)",border:"1px solid var(--card-border)"},onMouseEnter:y=>{y.currentTarget.style.borderColor="var(--text-tertiary)",y.currentTarget.style.boxShadow="0 4px 16px rgba(0,0,0,0.08)"},onMouseLeave:y=>{y.currentTarget.style.borderColor="var(--card-border)",y.currentTarget.style.boxShadow="none"},children:[e.jsxs("div",{className:"relative shrink-0 overflow-hidden rounded-xl bg-black shadow-sm",style:{width:116,aspectRatio:"16 / 9"},children:[(d==null?void 0:d.thumbnail)&&e.jsx("img",{src:d.thumbnail,alt:"",className:"absolute inset-0 h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.04]",referrerPolicy:"no-referrer"}),e.jsx("div",{className:"pointer-events-none absolute inset-0",style:{background:"linear-gradient(to top, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.0) 55%)"}}),e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-full backdrop-blur-sm transition-all duration-200 group-hover:h-9 group-hover:w-9",style:{background:"rgba(0,0,0,0.45)"},children:e.jsx("svg",{className:"h-3.5 w-3.5 translate-x-[1px] text-white",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M8 5v14l11-7z"})})})}),d!=null&&d.duration?e.jsx("span",{className:"absolute bottom-1 right-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold tabular-nums text-white",style:{background:"rgba(0,0,0,0.78)"},children:Xr(d.duration)}):null]}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1 py-0.5",children:[e.jsx("div",{className:"mb-1 flex items-center gap-1.5",children:e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full font-semibold",style:{padding:"2px 8px",fontSize:"11px",background:c.bg,color:c.text},children:[e.jsx(It,{category:q,className:"h-2.5 w-2.5"}),Ee[q]]})}),e.jsx("p",{style:{fontSize:"14px",fontWeight:700,lineHeight:1.35,color:"var(--text-primary)",wordBreak:"keep-all",overflowWrap:"break-word",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:(d==null?void 0:d.title)||m("workspace.videoFallback")}),d!=null&&d.channelName?e.jsx("p",{className:"mt-0.5 truncate",style:{fontSize:"11.5px",color:"var(--text-tertiary)"},children:d.channelName}):null]}),e.jsx("svg",{className:"h-4 w-4 shrink-0 transition-transform duration-200 group-hover:translate-x-0.5",style:{color:"var(--text-tertiary)"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]})]})})(),e.jsx("div",{className:"w-full overflow-hidden rounded-xl bg-black transition-all duration-300 ease-out",style:{maxHeight:$?0:"42vh",marginTop:$?0:"4px",opacity:$?0:1,pointerEvents:$?"none":"auto"},children:e.jsx("div",{className:"aspect-video w-full max-h-[42vh]",children:e.jsx("div",{ref:ue,className:"h-full w-full"})})})]}),sr=e.jsx("div",{className:`shrink-0 pt-3 flex ${A?"":"px-4 justify-center"}`,children:e.jsxs("div",{className:`relative items-center gap-1 rounded-full p-1 ${A?"flex w-full":"inline-flex"}`,style:{background:"var(--input-bg)",border:"1px solid var(--card-border)"},children:[e.jsx("div",{ref:ze,className:"absolute rounded-full",style:{background:Le==="dark"?"var(--tab-active-bg)":"var(--card-bg)",height:"var(--btn-height-md)",transition:"left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:Le==="dark"?"0 1px 3px rgba(0, 0, 0, 0.2)":"0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06)",border:Le==="dark"?"none":"1px solid var(--card-border)",zIndex:0}}),[{id:"summary",label:m("workspace.tabs.summary")}
3,{id:"timeline",label:m("workspace.tabs.timeline")},{id:"transcript",label:m("workspace.tabs.transcript")}].map(c=>e.jsx("button",{ref:y=>{D.current[c.id]=y},onClick:()=>g(c.id),className:`relative z-10 flex items-center justify-center whitespace-nowrap rounded-full font-medium ${A?"flex-1":"shrink-0"}`,style:{height:"var(--btn-height-md)",padding:A?"0 8px":"0 var(--btn-px-md)",fontSize:A?"13px":"var(--btn-font)",color:p===c.id?Le==="dark"?"var(--tab-active-text)":"var(--text-primary)":"var(--text-tertiary)",fontWeight:p===c.id?700:500,transition:"color 0.25s ease, font-weight 0.25s ease"},children:c.label},c.id))]})}),nr=e.jsxs("div",{className:"mx-auto w-full max-w-[720px]",children:[p==="summary"&&e.jsx(ia,{summary:ns,onCopy:Vt,onRetry:mt,retrying:Me}),p==="timeline"&&e.jsx(la,{timeline:as,onSeek:oe,onRetry:mt,retrying:Me}),p==="transcript"&&e.jsx(ca,{segments:fs,onSeek:oe})]}),ms=e.jsxs("div",{className:"mx-auto w-full max-w-[720px] pt-3",children:[Qe.length>0&&e.jsx(st,{title:m("workspace.tools.recentSection"),tools:Qe,loading:N,onAction:fe,cachedToolIds:ke,compact:!0}),e.jsx(st,{title:m("workspace.tools.commonSection"),tools:gt,loading:N,onAction:fe,onCustomize:Yt,onDeleteCustom:yt,cachedToolIds:ke}),Pe.length>0&&e.jsx(st,{title:m("workspace.tools.categorySection",{category:Ee[q]}),tools:Pe,loading:N,onAction:fe,onCustomize:Yt,onDeleteCustom:yt,accentColor:os,cachedToolIds:ke}),e.jsx(st,{title:m("workspace.tools.myToolsSection"),tools:bt,loading:N,onAction:fe,onCustomize:us,onDeleteCustom:yt,accentColor:"#f59e0b",isMyTools:!0,onAdd:qt,cachedToolIds:ke})]}),ar=e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"shrink-0 px-4 pt-4",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-[720px] items-center justify-between",children:[e.jsxs("button",{onClick:()=>{U.current++,j(""),E(null),b(!1)},className:"flex items-center gap-1.5 rounded-full border font-medium transition-colors hover:bg-[var(--hover-bg)]",style:{height:"var(--btn-height-md)",padding:"0 var(--btn-px-md)",fontSize:"var(--btn-font)",borderColor:"var(--card-border)",color:"var(--text-secondary)"},children:[e.jsx("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),m("workspace.back")]}),x&&!N&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:rs,className:"flex items-center gap-1.5 rounded-full border font-medium transition-colors hover:bg-[var(--hover-bg)]",style:{height:"var(--btn-height-md)",padding:"0 var(--btn-px-md)",fontSize:"var(--btn-font)",borderColor:"var(--card-border)",color:"var(--text-secondary)"},"aria-label":m("workspace.regenerate"),children:[we?e.jsxs("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 12a9 9 0 11-3.5-7.1"}),e.jsx("path",{d:"M21 4v5h-5"})]}):e.jsxs("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0110 0v4"})]}),m("workspace.regenerate")]}),t&&h&&e.jsx(cn,{noteId:t,toolId:h.id,language:((cr=C.get(h.id))==null?void 0:cr.language)||(o==null?void 0:o.outputLanguage)||ne||"ko",result:x}),e.jsxs("button",{onClick:()=>{const c=(h==null?void 0:h.id)==="timestamp"?x:un(x);Vt(c)},className:"flex items-center gap-1.5 rounded-full border font-medium transition-colors hover:bg-[var(--hover-bg)]",style:{height:"var(--btn-height-md)",padding:"0 var(--btn-px-md)",fontSize:"var(--btn-font)",borderColor:"var(--card-border)",color:"var(--text-secondary)"},children:[e.jsxs("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),m("workspace.copy")]})]})]})}),h&&e.jsx("div",{className:"shrink-0 px-4 pt-5",children:e.jsx("div",{className:"mx-auto w-full max-w-[720px]",children:e.jsxs("div",{className:`flex items-center gap-3.5 rounded-[20px] px-5 py-4 ${N?"tool-loading-border":"border"}`,style:N?{background:"var(--input-bg)"}:{borderColor:"var(--card-border)",background:"var(--input-bg)"},children:[e.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl",style:{background:`${h.color}20`,color:h.color},children:e.jsx(Ce,{id:h.id,className:"h-[22px] w-[22px]"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-[15px] font-bold",style:{color:"var(--text-primary)"},children:h.label}),h.description&&e.jsx("p",{className:"mt-0.5 truncate text-[12.5px]",style:{color:"var(--text-tertiary)"},children:h.description})]}),N&&e.jsx("div",{className:"h-[18px] w-[18px] shrink-0 animate-spin rounded-full border-2 border-t-transparent",style:{borderColor:h.color,borderTopColor:"transparent"}})]})})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-6",children:e.jsxs("div",{className:"mx-auto w-full max-w-[720px]",children:[(()=>{const c=!!(h!=null&&h.responseType)&&h.responseType!=="markdown";return N&&(!x||c)?e.jsx("div",{className:"space-y-3 pt-2",children:[...Array(5)].map((w,z)=>e.jsx("div",{className:"shimmer-bar h-4 rounded-md",style:{width:`${85-z*12}%`,animationDelay:`${z*.12}s`}},z))}):null})(),(h&&"baseToolId"in h?h.baseToolId:h==null?void 0:h.id)==="three_line"&&x&&!N?e.jsx(Os,{raw:x}):x&&!N&&(h!=null&&h.responseType)&&h.responseType!=="markdown"?Ds(h.responseType,x,h.id):x&&!(N&&(h!=null&&h.responseType)&&h.responseType!=="markdown")?e.jsx("div",{className:"prose prose-base max-w-none dark:prose-invert prose-headings:font-bold prose-p:leading-relaxed prose-li:leading-relaxed",children:e.jsx(nt,{remarkPlugins:[at],rehypePlugins:[Ct],components:{p:({children:c})=>e.jsx("p",{children:he(c,(h==null?void 0:h.id)==="timestamp"?oe:void 0)}),li:({children:c})=>e.jsx("li",{children:he(c,(h==null?void 0:h.id)==="timestamp"?oe:void 0)}),strong:({children:c})=>e.jsx("strong",{children:he(c,(h==null?void 0:h.id)==="timestamp"?oe:void 0)}),em:({children:c})=>e.jsx("em",{children:he(c,(h==null?void 0:h.id)==="timestamp"?oe:void 0)}),h1:({children:c})=>e.jsx("h1",{children:he(c,(h==null?void 0:h.id)==="timestamp"?oe:void 0)}),h2:({children:c})=>e.jsx("h2",{children:he(c,(h==null?void 0:h.id)==="timestamp"?oe:void 0)}),h3:({children:c})=>e.jsx("h3",{children:he(c,(h==null?void 0:h.id)==="timestamp"?oe:void 0)}),h4:({children:c})=>e.jsx("h4",{children:he(c,(h==null?void 0:h.id)==="timestamp"?oe:void 0)})},children:St(x)})}):null]})})]});return e.jsxs("div",{className:"detail-page-transition flex h-screen flex-col bg-[var(--page-bg)] print-hide",children:[Zr&&e.jsx(nn,{currentCategory:q,onSelect:is,onClose:()=>xt(!1)}),Ot&&e.jsx(sn,{baseTool:Ot,editingTool:Jr??void 0,onClose:()=>{Ge(null),Pt(null)}}),es&&t&&e.jsx(an,{noteId:t,language:(o==null?void 0:o.outputLanguage)||ne||"ko",tools:[...Ze,...Ae],cachedToolIds:new Set(C.keys()),recentIds:Ht,onClose:()=>Ft(!1)}),Qr&&Y&&e.jsx(Ts,{videoId:Y,title:(d==null?void 0:d.title)||vt,thumbnail:(d==null?void 0:d.thumbnail)||`https://i.ytimg.com/vi/${Y}/hqdefault.jpg`,channelName:d==null?void 0:d.channelName,onClose:()=>Bt(!1),onConfirm:()=>{if(!G){Oe();return}r(`/?videoId=${encodeURIComponent(Y)}&autoStart=1`)},quotaText:xe==="free"?m("subscription.freeQuotaLifetime",{count:zt??0}):xe==="lite"?m("subscription.liteQuotaDaily",{count:zt??0}):xe==="pro"?m("subscription.proUnlimited"):void 0,showUpgrade:xe==="free"}),_t&&e.jsx(zs,{options:_t,onClose:()=>Wt(null),onConfirm:c=>hr(c)}),o&&Tt.createPortal(e.jsx("div",{className:"print-only",children:e.jsx("div",{className:"mx-auto max-w-3xl px-4 pb-16 pt-6",children:e.jsx(Ps,{note:o,video:d,toolResults:ls})})}),document.body),e.jsxs("header",{className:"sticky top-0 z-30 flex shrink-0 items-center gap-3 px-4 print-hide",style:{height:"52px",background:"var(--page-bg)",WebkitTouchCallout:"none",userSelect:"none"},children:[e.jsxs("button",{onClick:()=>r(I&&_.current?-2:-1),onMouseDown:c=>c.preventDefault(),className:"flex items-center gap-2 rounded-full border font-medium transition-all",style:{height:"var(--btn-height-md)",padding:"0 var(--btn-px-md)",fontSize:"var(--btn-font)",background:"var(--card-bg)",borderColor:"var(--card-border)",color:"var(--text-secondary)"},children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",children:e.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),m("workspace.back")]}),e.jsx("h1",{className:"min-w-0 flex-1 truncate font-semibold",style:{fontSize:"var(--font-md)",color:"var(--text-primary)"},children:vt}),!A&&G&&(o==null?void 0:o.userId)===G.uid&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:Xt,onMouseDown:c=>c.preventDefault(),className:"flex items-center gap-1.5 rounded-full border font-medium transition-all",style:{height:"var(--btn-height-md)",padding:"0 var(--btn-px-md)",fontSize:"var(--btn-font)",background:"var(--card-bg)",borderColor:"var(--card-border)",color:"var(--text-secondary)"},children:[e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),m("workspace.share.buttonLabel")]}),e.jsxs("button",{onClick:Gt,onMouseDown:c=>c.preventDefault(),className:"flex items-center gap-1.5 rounded-full border font-medium transition-all",style:{height:"var(--btn-height-md)",padding:"0 var(--btn-px-md)",fontSize:"var(--btn-font)",background:"var(--card-bg)",borderColor:"var(--card-border)",color:"var(--text-secondary)"},children:[e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 9V2h12v7M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2"}),e.jsx("rect",{x:"6",y:"14",width:"12",height:"8",rx:"1"})]}),m("pages.sharedNote.pdfBtn")]})]}),G&&(o==null?void 0:o.userId)===G.uid&&e.jsx(na,{currentCategory:o.category,onChangeCategory:cs,onShare:Xt,onPrint:Gt,onReanalyze:mt,onDelete:ds})]}),A?e.jsxs("div",{ref:Z,className:"relative flex-1 overflow-x-hidden overflow-y-auto bg-[var(--card-bg)] print-hide",children:[rr,e.jsxs("div",{className:"mx-4 mt-4",children:[e.jsxs("button",{onClick:()=>O(!0),className:"ai-tool-btn group flex w-full items-center gap-3 rounded-[20px] px-4 py-3.5 transition-all active:scale-[0.98]",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",style:{background:"var(--card-border)"},children:e.jsxs("svg",{className:"h-5 w-5",style:{color:"var(--text-primary)"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1.5"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1.5"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1.5"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1.5"})]})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("p",{className:"text-[14px] font-bold",style:{color:"var(--text-primary)"},children:m("workspace.tools.panelTitle")}),e.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:m("workspace.tools.panelSummary",{commonCount:gt.length,category:Ee[q],categoryCount:Pe.length})})]}),e.jsx("svg",{className:"h-4 w-4",style:{color:"var(--text-tertiary)"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",children:e.jsx("path",{d:"M18 15l-6-6-6 6"})})]}),Qe.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1.5 px-1 text-[11px] font-semibold",style:{color:"var(--text-tertiary)"},children:m("workspace.tools.recentToolsLabel")}),e.jsx(ra,{tools:Qe,loading:N,onAction:fe})]})]}),M&&e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col",children:[e.jsx("div",{className:"sheet-overlay flex-1",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>O(!1)}),e.jsxs("div",{className:"sheet-content flex max-h-[85vh] flex-col rounded-t-3xl shadow-2xl",style:{background:"rgba(var(--glass-rgb), 0.65)",backdropFilter:"blur(48px) saturate(1.8)",WebkitBackdropFilter:"blur(48px) saturate(1.8)",borderTop:"1px solid rgba(var(--glass-rgb), 0.2)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-5 pt-4 pb-3",children:[e.jsx("span",{className:"text-[16px] font-bold",style:{color:"var(--text-primary)"},children:m("workspace.tools.panelTitle")}),e.jsx("button",{onClick:()=>O(!1),className:"flex h-8 w-8 items-center justify-center rounded-full hover:bg-[var(--hover-bg)]",style:{color:"var(--text-tertiary)"},children:e.jsx("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-8",style:{WebkitOverflowScrolling:"touch",overscrollBehavior:"contain"},children:e.jsxs("div",{className:"space-y-5",children:[e.jsx(kt,{title:m("workspace.tools.commonSection"),tools:gt,loading:N,onAction:c=>{O(!1),fe(c)},cachedToolIds:ke}),Pe.length>0&&e.jsx(kt,{title:m("workspace.tools.categorySection",{category:Ee[q]}),tools:Pe,loading:N,onAction:c=>{O(!1),fe(c)},cachedToolIds:ke}),e.jsx(kt,{title:m("workspace.tools.myToolsSection"),tools:bt,loading:N,onAction:c=>{O(!1),fe(c)},onAdd:()=>{O(!1),qt()},cachedToolIds:ke})]})})]})]}),e.jsxs("div",{className:"mx-4 mt-4 mb-4 rounded-2xl border bg-neutral-100 dar
3k:bg-white/5",style:{borderColor:"var(--card-border)"},children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 pt-3.5 pb-2.5",children:[e.jsx("div",{className:"flex h-5 w-5 items-center justify-center rounded-md",style:{background:"var(--card-border)"},children:e.jsx("svg",{className:"h-3 w-3",style:{color:"var(--text-primary)"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})})}),e.jsx("span",{className:"text-[13px] font-bold",style:{color:"var(--text-primary)"},children:m("workspace.videoAnalysis")})]}),e.jsxs("div",{className:"px-3 pb-3",children:[sr,e.jsx("div",{className:"mt-3",children:nr})]})]}),Be&&e.jsx("div",{"aria-hidden":"true",className:"h-[76px]"}),et&&e.jsx("div",{className:"fixed inset-0 z-40 bg-[var(--card-bg)]",children:ar})]}):e.jsx(on,{className:"flex-1 overflow-hidden p-2 print-hide",initialLeftPercent:55,minLeftPercent:30,maxLeftPercent:70,storageKey:"summix-split-ratio",gapPx:8,panelRadius:16,left:e.jsxs("div",{className:"flex h-full flex-col bg-[var(--card-bg)]",children:[rr,sr,e.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:nr})]}),right:e.jsxs("div",{className:"flex h-full flex-col bg-[var(--card-bg)]",style:{containerType:"inline-size"},children:[Be&&e.jsx(Kn,{mode:J,onChange:R,showNewChat:J==="chat"&&me.messages.length>0,onNewChat:me.reset,suppressCoach:et}),Be&&J==="chat"?e.jsx(Yr,{chat:me,variant:"panel",category:q,onSeek:Qt,autoFocus:!0}):et?e.jsx("div",{className:"min-h-0 flex-1",children:ar}):e.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:ms})]})}),tr&&e.jsx(Xn,{scrollRef:Z,onOpen:ps}),A&&Be&&P&&e.jsx(Zn,{chat:me,category:q,title:vt,thumbnail:(d==null?void 0:d.thumbnail)||(Y?`https://i.ytimg.com/vi/${Y}/mqdefault.jpg`:void 0),onClose:xs,onSeek:Qt,restoreTabBarOnClose:!1}),Me&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center px-4",style:{background:"rgba(0,0,0,0.6)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:e.jsx(Es,{progress:ss,videoTitle:d==null?void 0:d.title,videoThumbnail:d==null?void 0:d.thumbnail,onCancel:()=>{var c;(c=Kt.current)==null||c.abort(),Re(!1)}})}),A&&e.jsx("button",{type:"button","aria-label":m("workspace.scrollTop"),onClick:()=>{var c;return(c=Z.current)==null?void 0:c.scrollTo({top:0,behavior:"smooth"})},className:"fixed bottom-6 right-4 z-30 flex h-11 w-11 items-center justify-center rounded-full",style:{bottom:tr?"calc(84px + env(safe-area-inset-bottom))":void 0,background:"rgba(var(--glass-rgb), 0.85)",backdropFilter:"blur(20px) saturate(1.5)",WebkitBackdropFilter:"blur(20px) saturate(1.5)",border:"1px solid var(--card-border)",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",color:"var(--text-primary)",opacity:K?1:0,transform:K?"translateY(0)":"translateY(8px)",pointerEvents:K?"auto":"none",transition:"opacity 0.18s ease, transform 0.18s ease"},children:e.jsx("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M18 15l-6-6-6 6"})})})]})}function Xr(t){if(!t)return"";const r=Math.floor(t/3600),n=Math.floor(t%3600/60),a=t%60;return r>0?`${r}:${String(n).padStart(2,"0")}:${String(a).padStart(2,"0")}`:`${n}:${String(a).padStart(2,"0")}`}function ea(t,r){if(!t)return"";const n=r;return(Tr.language||"ko").slice(0,2)==="en"?t>=1e9?n("workspace.video.viewCountFormatted.billion",{n:(t/1e9).toFixed(1)}):t>=1e6?n("workspace.video.viewCountFormatted.million",{n:(t/1e6).toFixed(1)}):t>=1e3?n("workspace.video.viewCountFormatted.thousand",{n:(t/1e3).toFixed(1)}):n("workspace.video.viewCountFormatted.raw",{n:String(t)}):t>=1e8?n("workspace.video.viewCountFormatted.billion",{n:(t/1e8).toFixed(1)}):t>=1e4?n("workspace.video.viewCountFormatted.tenK",{n:(t/1e4).toFixed(1)}):t>=1e3?n("workspace.video.viewCountFormatted.thousand",{n:(t/1e3).toFixed(1)}):n("workspace.video.viewCountFormatted.raw",{n:String(t)})}function ta(t){if(!t)return"";try{return new Date(t).toLocaleDateString("ko-KR",{year:"numeric",month:"long",day:"numeric"})}catch{return t}}function ra({tools:t,loading:r,onAction:n}){return e.jsx("div",{className:"flex gap-1.5 overflow-x-auto",style:{scrollbarWidth:"none"},children:t.map(a=>e.jsxs("button",{onClick:()=>n(a),disabled:r,className:"flex shrink-0 items-center gap-2 rounded-full border px-3.5 py-2 text-[12.5px] font-semibold transition-all active:scale-95 disabled:opacity-50",style:{background:"var(--card-bg)",borderColor:"var(--card-border)",color:"var(--text-primary)",boxShadow:"0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04)"},children:[e.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md",style:{background:`${a.color}20`,color:a.color},children:e.jsx(Ce,{id:a.id,className:"h-3 w-3"})}),e.jsx("span",{className:"whitespace-nowrap",children:a.label})]},a.id))})}function kt({title:t,tools:r,loading:n,onAction:a,onAdd:s,cachedToolIds:l}){const{t:o}=B();return r.length>0||!!s?e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2.5 flex items-center gap-2.5 px-1",children:[e.jsx("span",{className:"inline-block h-3.5 w-[3px] rounded-full",style:{background:"var(--text-tertiary)"}}),e.jsx("span",{className:"text-[13px] font-bold",style:{color:"var(--text-primary)"},children:t}),r.length>0&&e.jsx("span",{className:"inline-flex items-center justify-center rounded-full text-[11px] font-semibold tabular-nums",style:{minWidth:"20px",height:"18px",padding:"0 6px",background:"var(--badge-bg)",color:"var(--text-tertiary)"},children:r.length})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.map(d=>{const p=d.isCustom===!0?d.baseToolId:d.id;return e.jsxs("button",{onClick:()=>a(d),disabled:n,className:"mobile-tool-card flex flex-col items-start gap-2 rounded-2xl border p-3 text-left disabled:opacity-50",style:{borderColor:"var(--card-border)",background:"var(--card-bg)"},children:[e.jsxs("div",{className:"relative flex h-8 w-8 shrink-0 items-center justify-center rounded-lg",style:{background:`${d.color}20`,color:d.color},children:[e.jsx(Ce,{id:p,className:"h-4 w-4"}),(l==null?void 0:l.has(d.id))&&e.jsx("span",{"aria-hidden":"true",className:"absolute -top-0.5 -right-0.5 h-2 w-2 rounded-full",style:{background:d.color,boxShadow:"0 0 0 1.5px var(--card-bg, #ffffff)"}})]}),e.jsxs("div",{className:"w-full min-w-0",children:[e.jsx("p",{className:"text-[12px] font-bold leading-tight",style:{color:"var(--text-primary)",wordBreak:"keep-all",overflowWrap:"break-word"},children:d.label}),d.description&&e.jsx("p",{className:"mt-1 line-clamp-2 text-[11px] leading-snug",style:{color:"var(--text-tertiary)",wordBreak:"keep-all",overflowWrap:"break-word"},children:d.description})]})]},d.id)}),s&&e.jsxs("button",{type:"button",onClick:s,className:"flex flex-col items-center justify-center gap-1.5 rounded-2xl border border-dashed p-3 text-[12px] font-semibold transition-colors",style:{borderColor:"var(--card-border)",color:"var(--text-secondary)",minHeight:"84px"},children:[e.jsx("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 5v14M5 12h14"})}),e.jsx("span",{children:o("workspace.myTools.addCta")})]})]})]}):null}const sa=["education","finance","news","review","interview","cooking","general"];function na({currentCategory:t,onChangeCategory:r,onShare:n,onPrint:a,onReanalyze:s,onDelete:l}){const{t:o}=B(),u=Rt(),{theme:d}=ye(),[f,p]=i.useState(!1),[g,v]=i.useState("main"),S=i.useRef(null),[N,b]=i.useState(null);i.useLayoutEffect(()=>{if(!f||!S.current)return;const h=()=>{const E=S.current.getBoundingClientRect();
3b({top:E.bottom+6,right:window.innerWidth-E.right})};return h(),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[f]);const x=()=>{p(!1),v("main")},j=d==="dark"?it:lt;return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:S,onClick:h=>{h.stopPropagation(),p(E=>!E),v("main")},onMouseDown:h=>h.preventDefault(),"aria-label":o("workspace.moreMenu"),className:"flex items-center justify-center rounded-full border transition-all",style:{height:"var(--btn-height-md)",width:"var(--btn-height-md)",background:f?"var(--hover-bg)":"var(--card-bg)",borderColor:"var(--card-border)",color:"var(--text-primary)"},children:e.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"12",cy:"5",r:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"}),e.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}),f&&N&&Tt.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[100]",onClick:h=>{h.stopPropagation(),x()}}),e.jsx("div",{className:"fixed z-[101] w-52 overflow-hidden py-2.5 shadow-2xl",style:{top:N.top,right:N.right,borderRadius:28,background:"rgba(var(--glass-rgb), 0.55)",backdropFilter:"blur(40px) saturate(1.8)",WebkitBackdropFilter:"blur(40px) saturate(1.8)",border:"1px solid rgba(255,255,255,0.12)",boxShadow:"0 16px 40px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08), inset 0 1px 0 0 rgba(255,255,255,0.18), inset 0 -1px 0 0 rgba(0,0,0,0.04)"},onClick:h=>h.stopPropagation(),children:g==="main"?e.jsxs(e.Fragment,{children:[e.jsx(je,{onClick:()=>v("category"),icon:e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 7h18M3 12h18M3 17h12"})}),label:o("workspace.category.menuLabel"),trailing:e.jsx("svg",{className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",children:e.jsx("path",{d:"M9 18l6-6-6-6"})})}),e.jsx(je,{onClick:()=>{x(),n()},icon:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),label:o("workspace.share.menuLabel")}),e.jsx(je,{onClick:()=>{x(),a()},icon:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 9V2h12v7M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2"}),e.jsx("rect",{x:"6",y:"14",width:"12",height:"8",rx:"1"})]}),label:o("pages.sharedNote.pdfBtn")}),e.jsx(je,{onClick:()=>{x(),s()},icon:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 12a9 9 0 11-3.5-7.1"}),e.jsx("path",{d:"M21 4v5h-5"})]}),label:o("workspace.reanalyze.menuLabel")}),e.jsx(je,{onClick:()=>{x(),l()},danger:!0,icon:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),e.jsx("path",{d:"M10 11v6M14 11v6"})]}),label:o("workspace.deleteNote.menuLabel")})]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{onClick:()=>v("main"),muted:!0,icon:e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})}),label:o("workspace.menu.category")}),sa.map(h=>{const E=h===t;return e.jsx(je,{onClick:()=>{x(),r(h)},icon:e.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center",style:{color:j[h].text},children:e.jsx(It,{category:h,className:"h-3.5 w-3.5"})}),label:u[h],trailing:E?e.jsx("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",children:e.jsx("path",{d:"M5 13l4 4L19 7"})}):null},h)})]})})]}),document.body)]})}function je({onClick:t,icon:r,label:n,trailing:a,danger:s,muted:l}){return e.jsxs("button",{onClick:o=>{o.stopPropagation(),t()},className:"mx-1 flex w-[calc(100%-0.5rem)] items-center gap-2.5 rounded-2xl px-3 py-2.5 text-left text-[13px] font-medium transition-colors hover:bg-[var(--hover-bg)]",style:{color:s?"#ef4444":l?"var(--text-tertiary)":"var(--text-primary)"},children:[e.jsx("span",{className:"shrink-0",children:r}),e.jsx("span",{className:"flex-1",children:n}),a&&e.jsx("span",{className:"shrink-0 opacity-70",children:a})]})}function aa({onEdit:t,onDelete:r}){const{t:n}=B(),[a,s]=i.useState(!1),l=i.useRef(null);return i.useEffect(()=>{if(!a)return;const o=u=>{l.current&&!l.current.contains(u.target)&&s(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[a]),e.jsxs("div",{ref:l,className:"absolute right-2.5 top-2.5",children:[e.jsx("span",{role:"button",tabIndex:0,"aria-label":n("workspace.moreMenu"),onClick:o=>{o.stopPropagation(),s(u=>!u)},onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.stopPropagation(),s(u=>!u))},className:"flex h-7 w-7 items-center justify-center rounded-full hover:bg-[var(--hover-bg)]",style:{color:"var(--text-tertiary)"},children:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"
3currentColor",children:[e.jsx("circle",{cx:"12",cy:"6",r:"1.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),e.jsx("circle",{cx:"12",cy:"18",r:"1.5"})]})}),a&&e.jsxs("div",{className:"absolute right-0 top-8 z-50 min-w-[120px] overflow-hidden rounded-xl border py-1",style:{background:"var(--page-bg)",borderColor:"var(--card-border)",boxShadow:"0 4px 16px rgba(0,0,0,0.15)"},children:[t&&e.jsxs("span",{role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),s(!1),t()},onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.stopPropagation(),s(!1),t())},className:"flex w-full cursor-pointer items-center gap-2 px-3 py-2 text-[13px] hover:bg-[var(--hover-bg)]",style:{color:"var(--text-primary)"},children:[e.jsx("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 20h9M16.5 3.5a2.1 2.1 0 013 3L7 19l-4 1 1-4z"})}),n("actions.edit")]}),r&&e.jsxs("span",{role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),s(!1),r()},onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.stopPropagation(),s(!1),r())},className:"flex w-full cursor-pointer items-center gap-2 px-3 py-2 text-[13px] hover:bg-[var(--hover-bg)]",style:{color:"#ef4444"},children:[e.jsx("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2m3 0v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6h14z"})}),n("actions.delete")]})]})]})}function st({title:t,tools:r,loading:n,onAction:a,onCustomize:s,onDeleteCustom:l,accentColor:o,isMyTools:u,onAdd:d,compact:f,cachedToolIds:p}){const{t:g}=B(),{theme:v}=ye(),S=v==="dark",N=o||"var(--text-tertiary)",b=Er();return e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2.5 px-1",children:[e.jsx("span",{className:"inline-block h-3.5 w-[3px] rounded-full",style:{background:N}}),e.jsx("h3",{className:"text-[13px] font-bold",style:{color:"var(--text-primary)",letterSpacing:"0.01em"},children:t}),r.length>0&&e.jsx("span",{className:"ml-0.5 inline-flex items-center justify-center rounded-full text-[11px] font-semibold tabular-nums",style:{minWidth:"20px",height:"18px",padding:"0 6px",background:"var(--badge-bg)",color:"var(--text-tertiary)"},children:r.length})]}),e.jsxs("div",{className:"tool-grid grid gap-2.5",children:[r.map(x=>{const j=x.isCustom===!0,h=!j&&!!x.customizable&&x.customizable.length>0,E=j?x.baseToolId:x.id;return e.jsxs("button",{onClick:()=>a(x),disabled:n,className:`group relative flex flex-col rounded-2xl text-left transition-all duration-200 hover:-translate-y-0.5 disabled:opacity-50 ${f?"p-3":"p-4"}`,style:S?{background:"var(--input-bg)",border:"1px solid var(--card-border)"}:{background:"#ffffff",boxShadow:"0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04)",border:"1px solid #f0f0f0"},onMouseEnter:C=>{S?(C.currentTarget.style.borderColor=`${x.color}50`,C.currentTarget.style.background=`${x.color}10`):(C.currentTarget.style.borderColor=`${x.color}40`,C.currentTarget.style.boxShadow=`0 4px 16px ${x.color}18`)},onMouseLeave:C=>{S?(C.currentTarget.style.borderColor="var(--card-border)",C.currentTarget.style.background="var(--input-bg)"):(C.currentTarget.style.borderColor="#f0f0f0",C.currentTarget.style.boxShadow="0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04)")},children:[e.jsxs("div",{className:`flex items-center ${f?"gap-2":"gap-3 pr-7"}`,children:[e.jsxs("div",{className:`relative flex shrink-0 items-center justify-center rounded-xl ${f?"h-8 w-8":"h-10 w-10"}`,style:{background:`${x.color}20`,color:x.color},children:[e.jsx(Ce,{id:E,className:f?"h-4 w-4":"h-5 w-5"}),(p==null?void 0:p.has(x.id))&&e.jsx("span",{"aria-hidden":"true",className:"absolute -top-0.5 -right-0.5 h-2 w-2 rounded-full",style:{background:x.color,boxShadow:"0 0 0 1.5px var(--card-bg, #ffffff)"}})]}),e.jsx("p",{className:`min-w-0 flex-1 font-bold line-clamp-2 ${f?"text-[13px]":"text-[14px]"}`,style:{color:"var(--text-primary)",wordBreak:"keep-all",overflowWrap:"break-word"},children:x.label})]}),!f&&x.description&&e.jsx("p",{className:"mt-2.5 text-[12px] leading-relaxed",style:{color:"var(--text-tertiary)",wordBreak:"keep-all",overflowWrap:"break-word"},children:x.description}),!f&&h&&s&&e.jsx("span",{role:"button",tabIndex:0,"aria-label":g("workspace.myTools.addAriaLabel"),onClick:C=>{C.stopPropagation(),s(x)},onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.stopPropagation(),s(x))},className:"absolute right-2.5 top-2.5 flex h-7 w-7 items-center justify-center rounded-full hover:bg-[var(--hover-bg)]",style:{color:"var(--text-tertiary)"},children:e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 11-2.83 2.83l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 11-4 0v-.09A1.65 1.65 0 009 
319.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 11-2.83-2.83l.06-.06a1.65 1.65 0 00.33-1.82 1.65 1.65 0 00-1.51-1H3a2 2 0 110-4h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 112.83-2.83l.06.06a1.65 1.65 0 001.82.33H9a1.65 1.65 0 001-1.51V3a2 2 0 114 0v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 112.83 2.83l-.06.06a1.65 1.65 0 00-.33 1.82V9a1.65 1.65 0 001.51 1H21a2 2 0 110 4h-.09a1.65 1.65 0 00-1.51 1z"})]})}),u&&j&&e.jsx(aa,{onEdit:s?()=>s(x):void 0,onDelete:l?async()=>{await b({title:g("workspace.myTools.deleteConfirm"),confirmLabel:g("actions.delete"),danger:!0})&&l(x.id)}:void 0})]},x.id)}),d&&e.jsxs("button",{onClick:d,className:"flex flex-col items-center justify-center gap-2.5 rounded-2xl border border-dashed p-4 transition-all duration-200 hover:-translate-y-0.5",style:{borderColor:"var(--card-border)",color:"var(--text-secondary)",minHeight:r.length>0?void 0:"100px"},onMouseEnter:x=>{x.currentTarget.style.borderColor="var(--text-tertiary)",x.currentTarget.style.background="var(--hover-bg)"},onMouseLeave:x=>{x.currentTarget.style.borderColor="var(--card-border)",x.currentTarget.style.background="transparent"},children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-xl",style:{background:"var(--badge-bg)"},children:e.jsx("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})}),e.jsx("span",{className:"text-[13px] font-semibold",children:g("workspace.myTools.addCta")})]})]})]})}function oa({video:t,videoId:r,category:n,hideCategoryBadge:a}){const{t:s}=B(),l=Rt(),{theme:o}=ye();if(!t)return null;const u=o==="dark"?it[n]:lt[n],d=[t.duration&&Xr(t.duration),t.viewCount&&s("workspace.video.viewCount",{count:ea(t.viewCount,s)}),t.publishDate&&ta(t.publishDate)].filter(Boolean);return e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("a",{href:t.channelId?`https://www.youtube.com/channel/${t.channelId}`:t.channelName?`https://www.youtube.com/results?search_query=${encodeURIComponent(t.channelName)}`:"#",target:"_blank",rel:"noopener noreferrer",className:"h-10 w-10 shrink-0 overflow-hidden rounded-full transition-opacity hover:opacity-80",style:{background:"var(--badge-bg)"}
3,children:e.jsx("img",{src:t.channelThumbnail||t.thumbnail||`https://i.ytimg.com/vi/${r}/default.jpg`,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("a",{href:t.channelId?`https://www.youtube.com/channel/${t.channelId}`:t.channelName?`https://www.youtube.com/results?search_query=${encodeURIComponent(t.channelName)}`:"#",target:"_blank",rel:"noopener noreferrer",className:"block truncate font-semibold transition-opacity hover:opacity-70",style:{fontSize:"var(--font-md)",color:"var(--text-primary)"},children:t.channelName||s("workspace.video.noChannel")}),d.length>0&&e.jsx("p",{className:"flex items-center gap-2 truncate",style:{fontSize:"var(--font-sm)",color:"var(--text-tertiary)"},children:d.map((f,p)=>e.jsxs("span",{className:"flex items-center gap-1.5",children:[p>0&&e.jsx("span",{children:"·"}),f]},p))})]}),!a&&e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full font-semibold",style:{padding:"6px 12px",fontSize:"12px",background:u.bg,color:u.text,letterSpacing:"0.01em"},children:[e.jsx(It,{category:n,className:"h-3 w-3"}),l[n]]}),r&&e.jsxs("a",{href:`https://www.youtube.com/watch?v=${r}`,target:"_blank",rel:"noopener noreferrer",className:"hidden shrink-0 items-center gap-2 rounded-full border font-medium transition-all hover:shadow-sm md:flex",style:{height:"var(--btn-height-md)",padding:"0 var(--btn-px-md)",fontSize:"var(--btn-font)",borderColor:"var(--card-border)",color:"var(--text-secondary)"},children:[e.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M21.8 8.001a2.75 2.75 0 0 0-1.94-1.93C18.26 5.5 12 5.5 12 5.5s-6.26 0-7.86.57A2.75 2.75 0 0 0 2.2 8.001 28.7 28.7 0 0 0 1.75 12a28.7 28.7 0 0 0 .45 3.999 2.75 2.75 0 0 0 1.94 1.93c1.6.57 7.86.57 7.86.57s6.26 0 7.86-.57a2.75 2.75 0 0 0 1.94-1.93A28.7 28.7 0 0 0 22.25 12a28.7 28.7 0 0 0-.45-3.999Z",fill:"#FF0000"}),e.jsx("path",{d:"M9.75 15.02V8.98L15.5 12l-5.75 3.02Z",fill:"#FFFFFF"})]}),"YouTube"]})]})})}
3function St(t){return t.replace(/\\n/g,`
4`).replace(/\\t/g,"	").replace(/\\\*/g,"*").replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").split(`
5
6`).map(r=>/^(\s*[-*+]|\s*\d+\.|\s*\||\s*```|\s*#)/.test(r)?r:r.replace(/([^\n])\n(?!\n)/g,`$1  
7`)).join(`
8
9`)}function Gr({message:t,onRetry:r,retrying:n}){const{t:a}=B();return e.jsxs("div",{className:"flex h-40 flex-col items-center justify-center gap-3",children:[e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:t}),e.jsx("button",{onClick:r,disabled:n,className:"rounded-lg bg-gray-900 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-gray-800 disabled:opacity-50 dark:bg-white dark:text-gray-900 dark:hover:bg-gray-100",children:a(n?"workspace.reanalyze.running":"workspace.reanalyze.retry")})]})}const ia=dt.memo(function({summary:r,onCopy:n,onRetry:a,retrying:s}){const{t:l}=B();return!r||!Array.isArray(r.sections)||r.sections.length===0?e.jsx(Gr,{message:l("workspace.summary.loadFailed"),onRetry:a,retrying:s}):e.jsxs("div",{children:[r.overview&&e.jsx("div",{className:"mb-5 rounded-xl bg-neutral-100 p-4 dark:bg-white/5",children:e.jsx("div",{className:"prose prose-sm max-w-none text-gray-700 dark:prose-invert dark:text-gray-300",children:e.jsx(nt,{remarkPlugins:[at],rehypePlugins:[Ct],children:St(r.overview)})})}),e.jsx("div",{className:"space-y-4",children:r.sections.filter(o=>o.importance==="high"||o.importance==="medium").map((o,u)=>e.jsxs("div",{className:"rounded-xl bg-neutral-100 p-4 dark:bg-white/5",children:[e.jsx("h3",{className:"mb-2 text-[17px] font-bold text-gray-900 dark:text-white",children:o.title}),e.jsx("div",{className:"prose prose-[15px] prose-gray max-w-none leading-[1.8] dark:prose-invert prose-p:my-1.5 prose-li:my-0.5",children:e.jsx(nt,{remarkPlugins:[at],rehypePlugins:[Ct],children:St(o.content)})})]},u))}),e.jsx("button",{onClick:()=>{const o=(r.overview?r.overview+`
10
11`:"")+r.sections.map(u=>`## ${u.title}
12${u.content}`).join(`
13
14`);n(o)},className:"mt-4 rounded-lg border border-gray-200 px-3 py-1.5 text-xs font-medium text-gray-500 hover:bg-gray-50 dark:border-white/10 dark:text-gray-400 dark:hover:bg-white/5",children:l("workspace.summary.copyAll")})]})}),la=dt.memo(function({timeline:r,onSeek:n,onRetry:a,retrying:s}){const{t:l}=B();return!r||r.length===0?e.jsx(Gr,{message:l("workspace.timeline.empty"),onRetry:a,retrying:s}):e.jsx("div",{className:"space-y-1",children:r.map((o,u)=>{const d=Math.floor(o.time/60),f=Math.floor(o.time%60),p=`${String(d).padStart(2,"0")}:${String(f).padStart(2,"0")}`;return e.jsxs("button",{onClick:()=>n(o.time),className:"flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors hover:bg-gray-50 dark:hover:bg-white/5",children:[e.jsx("span",{className:"shrink-0 rounded bg-gray-900 px-2 py-0.5 font-mono text-[13px] font-semibold text-white dark:bg-white dark:text-gray-900",children:p}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[14px] font-medium text-gray-900 dark:text-white",children:o.title}),e.jsx("p",{className:"mt-0.5 text-[13px] text-gray-500",children:o.summary})]})]},u)})})}),ca=dt.memo(function({segments:r,onSeek:n}){const{t:a}=B();return r.length===0?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:a("workspace.transcript.empty")})}):e.jsx("div",{className:"space-y-0.5",children:r.map((s,l)=>{const o=Math.floor(s.start/60),u=Math.floor(s.start%60),d=`${String(o).padStart(2,"0")}:${String(u).padStart(2,"0")}`;return e.jsxs("div",{className:"group flex items-start gap-3 rounded-lg px-3 py-1.5 transition-colors hover:bg-gray-50 dark:hover:bg-white/5",children:[e.jsx("button",{onClick:()=>n(s.start),className:"shrink-0 font-mono text-[13px] text-gray-400 transition-colors group-hover:text-gray-900 dark:group-hover:text-white",children:d}),e.jsx("p",{className:"text-[14px] leading-relaxed text-gray-600 dark:text-gray-400",children:s.text})]},l)})})});export{ja as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.