1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./savePptExportClient-B6DFGzO5.js","./main-Dck1T9BT.js","./react-vendor-CHQL15iE.js","./lucide-BFLOpGdB.js","./pdfjs-ji3DqnKJ.js","./markdown-W-rE_H7s.js","./katex-math-BxKHCrdI.js","./katex-math-CS4LK5N6.css","./main-IX1VYBlc.css","./Tooltip-Bx_S1cbE-BOMbSZw3.js","./characterPerformance-Dba8tDt6.js","./BlackboardMarkdown-Cizre-1w.js"])))=>i.map(i=>d[i]); 2import{u as tr,f as rr,g as sr,H as de,I as ar,J as D,K as nr,L as ir,M as dt,T as lr,h as xt,N as mt,O as Ee,P as ht,Q as or,U as cr,W as Le,X as pt,Y as ut,_ as dr,Z as ft,$ as xr,a0 as mr}from"./main-Dck1T9BT.js";import{r as p,j as e}from"./react-vendor-CHQL15iE.js";import{am as hr,B as bt,D as ee,c as Re,d as pr,aO as xe,X as qe,P as wt,aK as Me,ac as me,J as he,N as gt,i as ur,a4 as fr,aq as br,ab as vt,aP as yt,v as kt,o as wr,aQ as gr,b as jt,T as vr,aR as yr,aS as _e}from"./lucide-BFLOpGdB.js";import"./pdfjs-ji3DqnKJ.js";import"./markdown-W-rE_H7s.js";import"./katex-math-BxKHCrdI.js";const kr="p2g-seen-voice-completions-v1",jr="p2g-seen-voice-completions-v2",St=y=>`${jr}:${y}`,Ct=y=>String(y.voiceCompletedAt||y.completedAt||"voice-ready"),pe=(y,C)=>{try{const c=JSON.parse(y.getItem(St(C))||"{}");return!c||typeof c!="object"||Array.isArray(c)?{}:Object.fromEntries(Object.entries(c).filter(h=>typeof h[1]=="string"))}catch{return{}}},Nt=(y,C,c)=>{try{y.setItem(St(C),JSON.stringify(c))}catch{}},Nr=y=>{try{y.removeItem(kr)}catch{}},Sr=(y,C)=>y[C.id]===Ct(C),Cr=(y,C)=>({...y,[C.id]:Ct(C)}),zr=(y,C)=>{if(!(C in y))return y;const c={...y};return delete c[C],c},$r=10,Rr=({onBack:y,onLoadSave:C,userId:c,language:h,customCharacters:De,onLogout:B,researchSessions:zt=[],researchSessionsLoading:Or=!1,researchSessionsError:$t=null,onLoadResearchSessions:te,onLoadResearchSession:Be,onUpdateResearchSessionMetadata:ue,onDeleteResearchSession:fe})=>{var ct;const s=tr(),{chars:be}=rr(),[Ot,T]=p.useState([]),[Pt,we]=p.useState(!0),[Ue,re]=p.useState(null),[U,ge]=p.useState(!1),[Ve,se]=p.useState(100),[It,ae]=p.useState({}),[Ge,V]=p.useState(null),[Fe,G]=p.useState(null),[ve,R]=p.useState({}),[F,Je]=p.useState(null),[ye,ke]=p.useState({current:0,total:0}),[Tt,je]=p.useState(()=>pe(window.localStorage,c)),[At,ne]=p.useState(!1),[ie,Qe]=p.useState(""),[Ke,We]=p.useState(!1),[J,Q]=p.useState(null),[Ne,Et]=p.useState(""),[I,q]=p.useState("ALL"),[le,K]=p.useState([]),[He,Ye]=p.useState(c),u=p.useRef(c),b=p.useRef(0),k=p.useRef(!0),$=u.current===c?Ot:[],A=He===c&&u.current===c?zt:[],Se=He===c&&u.current===c?$t:null,d=lr[h],{showAlert:z,showPrompt:oe,showConfirm:Lt}=sr(),[S,W]=p.useState(null),Rt=s?{paddingTop:"max(0px, env(safe-area-inset-top))",paddingRight:"max(0px, env(safe-area-inset-right))",paddingBottom:"max(0px, env(safe-area-inset-bottom))",paddingLeft:"max(0px, env(safe-area-inset-left))"}:void 0,H=s?{paddingTop:"max(0.5rem, env(safe-area-inset-top))",paddingRight:"max(0.5rem, env(safe-area-inset-right))",paddingBottom:"max(0.5rem, env(safe-area-inset-bottom))",paddingLeft:"max(0.5rem, env(safe-area-inset-left))"}:void 0,O={zh:{ready:"å¯ç¦»çº¿æ¸¸ç©",partial:"ç¦»çº¿èµæºæªå®æ´",download:"ä¸è½½ç¦»çº¿èµæº",offline:"å½åæ¾ç¤ºæ¬å°åæ¡£"},en:{ready:"Available offline",partial:"Offline download incomplete",download:"Download for offline play",offline:"Showing local saves"},ja:{ready:"ãªãã©ã¤ã³åçå¯è½",partial:"ãªãã©ã¤ã³ç´ æãæªå®äº",download:"ãªãã©ã¤ã³ç¨ã«ãã¦ã³ãã¼ã",offline:"ãã¼ã«ã«ã»ã¼ãã表示ä¸"},ru:{ready:"ÐоÑÑÑпно оÑлайн",partial:"ÐагÑÑзка не завеÑÑена",download:"СкаÑаÑÑ Ð´Ð»Ñ Ð¾Ñлайн-игÑÑ",offline:"ÐÐ¾ÐºÐ°Ð·Ð°Ð½Ñ Ð»Ð¾ÐºÐ°Ð»ÑнÑе ÑÐ¾Ñ ÑанениÑ"}}[h],Y={zh:{export:"å¯¼åº PPT",failed:"PPT 导åºå¤±è´¥"},en:{export:"Export PPT",failed:"PPT export failed"},ja:{export:"PPT ãæ¸ãåºã",failed:"PPT ã®æ¸ãåºãã«å¤±æãã¾ãã"},ru:{export:"ÐкÑпоÑÑ PPT",failed:"Ðе ÑдалоÑÑ ÑкÑпоÑÑиÑоваÑÑ PPT"}}[h],qt={zh:t=>`æå¤å¯ä¿å ${t} ä¸ªå§æ¬`,en:t=>`Up to ${t} scripts`,ja:t=>`æå¤§ ${t} ä»¶ã®èæ¬ãä¿åå¯è½`,ru:t=>`Ðожно ÑÐ¾Ñ ÑаниÑÑ Ð´Ð¾ ${t} ÑÑенаÑиев`}[h],Xe=Ve===null?"â":String(Ve),Ce=p.useCallback(async(t,r)=>{if(!de())return;const l=(r==null?void 0:r.ownerId)||u.current,a=(r==null?void 0:r.ownerEpoch)??b.current,n=()=>k.current&&u.current===l&&b.current===a,i=await Promise.all(t.map(async o=>[o.id,await ar(o.id)]));n()&&ae(Object.fromEntries(i))},[]);p.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]),p.useLayoutEffect(()=>{b.current+=1,u.current=c,Ye(null),T([]),K([]),ae({}),ge(!1),we(!0),se(100),V(null),G(null),Q(null),W(null),R({}),re(null),q("ALL")},[c]),p.useEffect(()=>{Nr(window.localStorage),je(pe(window.localStorage,c))},[c]),p.useEffect(()=>{const t=localStorage.getItem("p2g_token");if(!t)return;let r=!1;return fetch("/api/membership/status",{headers:{Authorization:`Bearer ${t}`}}).then(async l=>{if(!l.ok)throw new Error("Failed to fetch save limit");return l.json()}).then(l=>{if(r||u.current!==c)return;const a=l==null?void 0:l.membership;if((a==null?void 0:a.unlimitedAll)===!0){se(null);return}const n=Number(a==null?void 0:a.saveLimit);se(Number.isFinite(n)&&n>0?n:100)}).catch(()=>{!r&&u.current===c&&se(100)}),()=>{r=!0}},[c]);const X=p.useCallback(async t=>{var o,x,w;const r=c,l=b.current,a=D();let n=!1;const i=()=>k.current&&u.current===r&&b.current===l&&(t!=null&&t.shouldApply?t.shouldApply():!0);!(t!=null&&t.silent)&&i()&&re(null);try{const m=localStorage.getItem("p2g_token"),f=await fetch("/api/saves",{headers:{Authorization:`Bearer ${m}`}});if(f.status===401){(o=a.release)==null||o.call(a),i()&&B();return}if(!f.ok)throw new Error("Failed to fetch saves");const N=await f.json();return i()?(T(N),ge(!1),n=!0,nr(N,c,{cacheEpoch:a,shouldCommit:i}).finally(()=>{var g;return(g=a.release)==null?void 0:g.call(a)}),Ce(N,{ownerId:r,ownerEpoch:l})):(x=a.release)==null||x.call(a),N}catch(m){n||(w=a.release)==null||w.call(a);const f=await ir({ownerId:c});return f.length>0&&i()?(T(f),ge(!0),re(null),Ce(f,{ownerId:r,ownerEpoch:l}),f):(!(t!=null&&t.silent)&&i()&&re(m.message),null)}},[B,Ce,c]),Mt=async()=>{const t=c,r=b.current,l=()=>k.current&&u.current===t&&b.current===r;try{const a=localStorage.getItem("p2g_token"),n=await fetch("/api/categories",{headers:{Authorization:`Bearer ${a}`}});if(n.status===401){l()&&B();return}if(n.ok){const i=await n.json();l()&&K(i)}}catch(a){console.error("Fetch categories failed",a)}},_t=async()=>{const t=c,r=b.current;we(!0),await Promise.all([X(),Mt()]),await(te==null?void 0:te()),k.current&&u.current===t&&b.current===r&&(Ye(t),we(!1))};p.useEffect(()=>{_t()},[te,c]);const ze=p.useMemo(()=>U?"":$.filter(dt).map(t=>
2t.id).sort().join("|"),[$,U]);p.useEffect(()=>{if(!ze)return;const t=ze.split("|").filter(Boolean),r=c,l=b.current,a=or({ids:t,getToken:()=>localStorage.getItem("p2g_token"),fetchStatus:async(n,i)=>{const o=await fetch(`/api/saves/${encodeURIComponent(n)}/status`,{headers:{Authorization:`Bearer ${i}`}});return o.status===401?"unauthorized":o.ok?await o.json():null},onStatuses:n=>{if(!k.current||u.current!==r||b.current!==l)return;const i=new Map(n.map(o=>[o.id,o]));i.size!==0&&T(o=>{let x=!1;const w=o.map(m=>{const f=i.get(m.id);if(!f)return m;const N=mr(m,f);return N!==m&&(x=!0),N});return x?w:o})},onSucceeded:async()=>{await X({silent:!0,shouldApply:()=>a.isRunning()})},onUnauthorized:()=>{k.current&&u.current===r&&b.current===l&&B()},onError:n=>console.error("Poll save status failed",n)});return a.start(),()=>{a.stop()}},[X,B,ze,c]);const Ze=async(t,r)=>{var o,x;const l=c,a=b.current,n=D(),i=()=>k.current&&u.current===l&&b.current===a;if(!i()){(o=n.release)==null||o.call(n);return}try{const w=localStorage.getItem("p2g_token"),m=await fetch(`/api/saves/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${w}`},body:JSON.stringify(r)}),f=await m.json();if(!m.ok)throw new Error(f.error||"Failed to update save");if(!i())return;T(N=>N.map(g=>g.id===t?f:g)),await Le(f,l,{cacheEpoch:n,shouldCommit:i})}catch(w){console.error(w),i()&&await z(w.message||"æ´æ°å¤±è´¥",{variant:"error"})}finally{(x=n.release)==null||x.call(n)}},et=async t=>{const r=(t.displayTitle||t.chapterTitle||"").toString(),l=await oe(h==="zh"?"请è¾å
¥æ°çåæ¡£åç§°ï¼":"Enter new save name:",{defaultValue:r,placeholder:h==="zh"?"åæ¡£åç§°":"Save Name"});if(l===null||u.current!==c)return;const a=l.trim();!a||a===r||await Ze(t.id,{displayTitle:a})},tt=async(t,r)=>{const l=c,a=b.current,n=()=>k.current&&u.current===l&&b.current===a,i=t.sessionId;if(!n())return!1;if(t.offline)return R(m=>({...m,[i]:{phase:"offline",message:h==="zh"?"离线ç ç©¶åæ¡£ä¸ºåªè¯»ï¼æ æ³ä¿®æ¹ã":"Offline research saves are read-only."}})),!1;if(!ue)return R(m=>({...m,[i]:{phase:"error",message:h==="zh"?"ç ç©¶åæ¡£ä¿®æ¹æä¸å¯ç¨ã":"Research save editing is unavailable."}})),!1;R(m=>({...m,[i]:{phase:"saving"}}));let o=!1,x=null;try{o=await ue(t,r)}catch(m){x=m instanceof Error?m.message:String(m)}if(!n())return!1;if(o)return R(m=>{const f={...m};return delete f[i],f}),!0;const w=x||Se||(h==="zh"?"ç ç©¶åæ¡£ä¿®æ¹å¤±è´¥ï¼è¯·éè¯ã":"Research save update failed. Please try again.");return R(m=>({...m,[i]:{phase:/çæ¬|version|conflict|å²çª/i.test(w)?"conflict":"error",message:w}})),!1},Dt=async t=>{var o,x;const r=c,l=b.current,a=((x=(o=t.presentation)==null?void 0:o.title)==null?void 0:x.trim())||t.label||"Research session",n=await oe(h==="zh"?"请è¾å
¥æ°çç ç©¶åæ¡£åç§°ï¼":"Enter new research save name:",{defaultValue:a,placeholder:h==="zh"?"ç ç©¶åæ¡£åç§°":"Research save name"});if(n===null||u.current!==r||b.current!==l)return;const i=n.trim();!i||i===a||await tt(t,{title:i})},rt=t=>{W(t)},Z=(S==null?void 0:S.kind)==="story"?S.save.category||null:((ct=S==null?void 0:S.session.presentation)==null?void 0:ct.category)||null;(S==null?void 0:S.kind)==="research"&&S.session.sessionId;const $e=async(t,r)=>{const l=c,a=b.current;t.kind==="story"?await Ze(t.save.id,{category:r}):await tt(t.session,{category:r}),k.current&&u.current===l&&b.current===a&&W(null)},st=p.useMemo(()=>Array.from(new Set($.map(t=>t.category).filter(Boolean))),[$]),at=p.useMemo(()=>Array.from(new Set(A.map(t=>{var r;return(r=t.presentation)==null?void 0:r.category}).filter(Boolean))),[A]),nt=p.useMemo(()=>{var t;return((t=Object.values(ve).find(r=>r.phase==="error"||r.phase==="conflict"))==null?void 0:t.message)||null},[ve]),Oe=p.useMemo(()=>{const t=le.map(r=>r.name);return Array.from(new Set([...t,...st,...at])).sort()},[le,st,at]),Bt=async()=>{const t=c,r=await oe(h==="zh"?"请è¾å
¥æ°çåç±»åç§°ï¼":"Enter new category name:",{placeholder:h==="zh"?"åç±»åç§°":"Category Name"});if(r===null||u.current!==t)return;const l=r.trim();if(l)try{const a=localStorage.getItem("p2g_token"),n=await fetch("/api/categories",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({name:l})}),i=await n.json();if(n.ok&&u.current===t)K(o=>[...o,i]),q(l);else if(i.error==="Category already exists"&&u.current===t)q(l);else throw new Error(i.error)}catch(a){u.current===t&&await z(a.message||"æ·»å 失败")}},Ut=async(t,r)=>{t.stopPropagation();const l=c;if(!(!await Lt(h==="zh"?`ç¡®å®è¦ç§»é¤ååº "${r}" åï¼`:`Delete partition "${r}"?`,{variant:"warning"})||u.current!==l))try{const n=localStorage.getItem("p2g_token"),i=le.find(o=>o.name===r);if(i&&(await fetch(`/api/categories/${i.id}`,{method:"DELETE",headers:{Authorization:`Bearer ${n}`}}),u.current===l&&K(o=>
2o.filter(x=>x.id!==i.id))),u.current!==l)return;I===r&&q("ALL"),await X()}catch(n){u.current===l&&console.error(n)}},Vt=p.useMemo(()=>{const t=Ne.trim().toLowerCase(),r=$.filter(a=>{if(I!=="ALL"&&a.category!==I)return!1;if(!t)return!0;const n=(a.displayTitle||a.chapterTitle||"").toLowerCase(),i=(a.previewText||"").toLowerCase(),o=(a.category||"").toLowerCase(),x=a.id.toLowerCase();return n.includes(t)||i.includes(t)||o.includes(t)||x.includes(t)}),l=A.filter(a=>{const n=a.presentation;return I!=="ALL"&&(n==null?void 0:n.category)!==I?!1:t?[n==null?void 0:n.title,n==null?void 0:n.category,n==null?void 0:n.preview].filter(i=>!!i).some(i=>i.toLowerCase().includes(t)):!0});return[...r.map(a=>({kind:"story",save:a})),...l.map(a=>({kind:"research",session:a}))]},[$,A,Ne,I]),E=p.useMemo(()=>J?$.find(t=>t.id===J):null,[J,$]),Gt=async t=>{const r=c,l=b.current,a=()=>k.current&&u.current===r&&b.current===l,n=A.find(i=>i.sessionId===t);!n||!fe||!a()||(await fe(n),a()&&G(null))},Ft=async t=>{const r=c,l=b.current,a=()=>k.current&&u.current===r&&b.current===l;if(a())try{const n=localStorage.getItem("p2g_token");if((await fetch(`/api/saves/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${n}`}})).ok){if(cr(t,r),!a())return;T(w=>w.filter(m=>m.id!==t));const o=pe(window.localStorage,c),x=zr(o,t);x!==o&&(Nt(window.localStorage,c,x),je(x)),V(null)}}catch(n){console.error(n)}},it=async(t,r,l=!1)=>{var x,w,m;const a=c,n=b.current,i=D(),o=()=>k.current&&u.current===a&&b.current===n;if(!o()){(x=i.release)==null||x.call(i);return}if(!r&&!l){Q(t),(w=i.release)==null||w.call(i);return}try{const f=localStorage.getItem("p2g_token"),N=await fetch(`/api/saves/${t}/share`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${f}`},body:JSON.stringify({isShared:!r})});if(N.ok){const g=await N.json();if(!o())return;T(j=>j.map(v=>v.id===t?g:v)),await Le(g,a,{cacheEpoch:i,shouldCommit:o}),Q(null)}}catch(f){console.error(f)}finally{(m=i.release)==null||m.call(i)}},Jt=async()=>{var n,i;const t=c,r=b.current,l=D(),a=()=>k.current&&u.current===t&&b.current===r;if(!a()||!ie.trim()){(n=l.release)==null||n.call(l);return}We(!0);try{const o=localStorage.getItem("p2g_token"),x=await fetch("/api/saves/import",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({uuid:ie.trim()})}),w=await x.json();if(!x.ok)throw new Error(w.error||"Import failed");if(!a())return;T(m=>[w,...m]),await Le(w,t,{cacheEpoch:l,shouldCommit:a}),ne(!1),Qe(""),await z(d.importSuccess||"Import successful!",{variant:"success"})}catch(o){a()&&await z(o.message,{variant:"error"})}finally{(i=l.release)==null||i.call(l),a()&&We(!1)}},Qt=async t=>{var w;const r=c,l=b.current,a=()=>k.current&&u.current===r&&b.current===l;if(!a())return;const n=D();let i=!1;const o=t,x=t.userId===r&&xr(o.storyQuestionArchive)&&Number.isInteger(o.storyQuestionRevision)&&o.storyQuestionRevision>=0?{archive:o.storyQuestionArchive,revision:o.storyQuestionRevision}:null;try{if(Ee(t)){const f=await ut(t,{ownerId:r,visibility:"owner"});if(!a()||!await C(f,{archiveFallback:x})||!a()||(de()&&navigator.onLine&&(i=!0,ft(t,v=>{a()&&ae(P=>({...P,[t.id]:v}))},{ownerId:r,cacheEpoch:n,shouldCommit:a}).finally(()=>{var v;return(v=n.release)==null?void 0:v.call(n)})),!a()||!ht(t)))return;const g=pe(window.localStorage,c),j=Cr(g,t);Nt(window.localStorage,c,j),je(j);return}const m=mt(t);await z(pt(t),{variant:m.kind==="failed"||m.kind==="cancelled"?"error":"info"})}finally{i||(w=n.release)==null||w.call(n)}},Kt=async t=>{const r=c;if(!(u.current!==r||F)){if(!Ee(t)){await z(pt(t),{variant:"info"});return}Je(t.id),ke({current:0,total:0});try{const l=await ut(t,{visibility:"public"});if(u.current!==r)return;const{exportSaveToPpt:a}=await dr(async()=>{const{exportSaveToPpt:n}=await import("./savePptExportClient-B6DFGzO5.js");return{exportSaveToPpt:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url);await a({save:l,defaultCharacters:be,onProgress:ke})}catch(l){console.error("Export PPT failed",l),u.current===r&&await z(l instanceof Error?l.message:Y.failed,{title:Y.failed,variant:"error"})}finally{u.current===r&&(Je(null),ke({current:0,total:0}))}}},Wt=async t=>{var i;const r=c,l=b.current,a=()=>k.current&&u.current===r&&b.current===l;
2if(!a()||!de())return;if(!navigator.onLine){await z(O.partial,{variant:"info"});return}const n=D();try{const o=await ft(t,x=>{a()&&ae(w=>({...w,[t.id]:x}))},{ownerId:r,cacheEpoch:n,shouldCommit:a});if(!a())return;o.state==="ready"?await z(O.ready,{variant:"success"}):await z(O.partial,{variant:"info"})}catch(o){console.error("[OfflineSave] Download failed",o),a()&&await z(O.partial,{variant:"error"})}finally{(i=n.release)==null||i.call(n)}},Pe=t=>new Date(t).toLocaleString(h==="zh"?"zh-CN":"en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),Ht=t=>{var r,l;try{const a=JSON.parse(t),n=a.characterId,i=be.find(x=>x.id===n);if(i){const x=(r=i.names)==null?void 0:r[h],w=typeof i.name=="string"?i.name.trim():"",m=xt(i,a.defaultCharacterSkinId||((l=a.charMetadata)==null?void 0:l.defaultSkinId));return{name:typeof x=="string"&&x.trim()?x:w||d[i.nameKey]||i.id,avatar:(m==null?void 0:m.avatarUrl)||i.avatarUrl}}const o=De.find(x=>x.id===n);return o?{name:o.name,avatar:o.avatarUrl}:a.charMetadata?{name:a.charMetadata.name,avatar:a.charMetadata.avatarUrl}:{name:n||"Unknown",avatar:null}}catch{return{name:"Unknown",avatar:null}}},lt=s?"min-h-[45vh]":"h-full",ot=s?"grid min-w-0 grid-cols-1 min-[480px]:grid-cols-2 min-[700px]:grid-cols-3 gap-2":"grid min-w-0 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-4 md:gap-6",Yt={neutral:"bg-slate-100 text-slate-500 border-slate-200",info:"bg-blue-50 text-blue-600 border-blue-100",success:"bg-emerald-50 text-emerald-600 border-emerald-100",warning:"bg-amber-50 text-amber-600 border-amber-100",danger:"bg-red-50 text-red-600 border-red-100"};return e.jsxs("div",{"data-testid":"save-manager",className:`fixed inset-0 z-50 bg-[#fff0f5] flex flex-col animate-fade-in ${s?"overflow-y-auto overscroll-y-contain":"overflow-hidden"} box-border`,style:Rt,children:[e.jsx("style",{children:` 3 @keyframes pulse-gentle { 4 0%, 100% { opacity: 1; transform: scale(1); } 5 50% { opacity: 0.85; transform: scale(0.98); } 6 } 7 .animate-pulse-gentle { 8 animation: pulse-gentle 2s ease-in-out infinite; 9 } 10 .save-card-text-scrollbar {
11 scrollbar-width: thin; 12 scrollbar-color: #f9a8d4 transparent; 13 } 14 .save-card-text-scrollbar::-webkit-scrollbar { 15 width: 4px; 16 height: 4px; 17 } 18 .save-card-text-scrollbar::-webkit-scrollbar-track { 19 background: transparent; 20 } 21 .save-card-text-scrollbar::-webkit-scrollbar-thumb { 22 background: #f9a8d4; 23 border-radius: 9999px; 24 } 25 .save-card-text-scrollbar::-webkit-scrollbar-thumb:hover { 26 background: #ec4899; 27 } 28 `}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03] pointer-events-none",style:{backgroundImage:"linear-gradient(45deg, #f472b6 25%, transparent 25%, transparent 50%, #f472b6 50%, #f472b6 75%, transparent 75%, transparent)",backgroundSize:"100px 100px"}}),e.jsx("div",{className:"absolute top-[-20%] left-[-10%] w-[60%] h-[60%] rounded-full border-[40px] border-white/40 animate-spin-slow pointer-events-none"}),e.jsxs("header",{"data-testid":"save-manager-header",className:`relative z-20 shrink-0 flex justify-between ${s?"flex-row items-start gap-2 px-3 py-1.5":"flex-row items-center gap-3 px-8 py-5"}`,children:[e.jsxs("div",{className:`flex max-w-full min-w-0 items-center overflow-hidden ${s?"gap-2":"gap-6"}`,children:[e.jsx("button",{onClick:y,className:`${s?"p-1.5":"p-3"} bg-white/80 backdrop-blur-md rounded-xl text-slate-400 hover:text-pink-500 hover:shadow-lg transition-all border border-white group shrink-0`,children:e.jsx(hr,{size:s?20:24,className:"group-hover:-translate-x-1 transition-transform"})}),e.jsxs("div",{className:"min-w-0 overflow-hidden pb-0.5",children:[e.jsxs("h1",{"data-testid":"save-manager-title",className:`${s?"text-lg gap-1.5":"text-4xl gap-3"} font-black text-slate-800 tracking-tighter flex min-w-0 items-center leading-tight overflow-hidden`,children:[e.jsx(bt,{className:`text-pink-500 shrink-0 ${s?"h-5 w-5":"h-8 w-8"}`}),e.jsx("span",{className:"block min-w-0 truncate pb-0.5 pr-1",children:d.saveManagerTitle})]}),e.jsxs("p",{className:`truncate text-slate-400 font-bold uppercase tracking-[0.2em] mt-0.5 ml-0.5 opacity-70 ${s?"text-[7px]":"text-[10px]"}`,children:[d.scriptLibrary," / ",d.scriptLibraryEn||"Script Library"]})]})]}),e.jsxs("div",{className:`flex min-w-0 shrink-0 flex-col items-stretch ${s?"w-[54%] max-w-[28rem] gap-1.5":"gap-3 items-end"}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 bg-white/50 backdrop-blur-md p-1.5 rounded-2xl border border-white/50 shadow-sm self-start md:self-auto",children:[e.jsxs("button",{onClick:()=>ne(!0),className:"flex items-center gap-2 px-4 py-2 bg-gradient-to-r from-pink-500 to-rose-600 text-white rounded-xl font-black text-xs hover:scale-105 active:scale-95 transition-all shadow-md group",children:[e.jsx(ee,{size:14,className:"group-hover:-translate-y-0.5 transition-transform"}),e.jsx("span",{children:d.importSaveBtn||"å¯¼å ¥åæ¡£"})]}),e.jsx("div",{className:"h-8 w-px bg-slate-200 hidden sm:block"}),e.jsxs("div",{className:"px-4 py-1",children:[e.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest mb-0.5",children:d.scripts}),e.jsxs("p",{className:"text-lg font-black text-slate-700 leading-none",children:[$.length," / ",Xe]})]}),e.jsx("div",{className:"h-8 w-px bg-slate-200"}),e.jsxs("div",{className:"px-4 py-1",children:[e.jsx("p",{className:"text-[9px] font-black text-slate-400 uppercase tracking-widest mb-0.5",children:d.status}),e.jsxs("p",{className:`text-xs font-black leading-none flex items-center gap-1.5 ${U?"text-amber-500":"text-green-500"}`,children:[U?e.jsx(ee,{size:10}):e.jsx(Re,{size:10}),U?O.offline:d.healthy]})]})]}),e.jsxs("div",{className:"relative w-full md:w-80",children:[e.jsx("input",{type:"text",value:Ne,onChange:t=>Et(t.target.value),placeholder:"æç´¢æ é¢ / æè¦ / åç±»",className:"w-full pl-9 pr-3 py-2 bg-white/80 border border-slate-200 rounded-xl text-xs text-slate-700 placeholder:text-slate-300 focus:outline-none focus:ring-2 focus:ring-pink-200"}),e.jsx(pr,{size:14,className:"absolute left-3 top-2.5 text-slate-300"})]})]})]}),e.jsxs("div",{className:"relative z-20 shrink-0 px-4 md:px-12 py-4 md:py-3 min-h-[64px] flex items-center gap-3 overflow-x-auto no-scrollbar scroll-smooth",children:[e.jsx("style",{children:` 29 .no-scrollbar::-webkit-scrollbar { display: none; } 30 .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; } 31 `}),e.jsxs("div",{className:"flex items-center gap-2 pr-8",children:[e.jsx("button",{onClick:()=>q("ALL"),className:`px-5 py-2.5 rounded-2xl text-[11px] font-black transition-all border shadow-sm shrink-0 flex items-center gap-2 ${I==="ALL"?"bg-pink-500 text-white border-pink-500 shadow-pink-200/50 scale-105":"bg-white/90 text-slate-500 border-white hover:bg-pink-50 hover:text-pink-600 hover:border-pink-100"}`,children:d.allCategories||"å ¨é¨ååº"}),Oe.map(t=>e.jsxs("div",{className:"group/cat relative shrink-0",children:[e.jsxs("button",{onClick:()=>q(t),className:`px-5 py-2.5 rounded-2xl text-[11px] font-black transition-all border shadow-sm flex items-center gap-2 ${I===t?"bg-pink-500 text-white border-pink-500 shadow-pink-200/50 scale-105":"bg-white/90 text-slate-500 border-white hover:bg-pink-50 hover:text-pink-600 hover:border-pink-100"}`,children:[e.jsx(xe,{size:12,className:I===t?"text-pink-200":"text-slate-300"}),e.jsx("span",{children:t})]}),le.some(r=>r.name===t)&&e.jsx("button",{onClick:r=>Ut(r,t),className:"absolute -top-1 -right-1 w-5 h-5 bg-white shadow-md rounded-full flex items-center justify-center text-slate-300 hover:text-red-500 opacity-0 group-hover/cat:opacity-100 transition-all border border-slate-100 hover:scale-110",children:e.jsx(qe,{size:10,strokeWidth:3})})]},t)),e.jsx("button",{onClick:Bt,className:"w-10 h-10 shrink-0 flex items-center justify-center rounded-2xl bg-white/60 text-slate-400 border-2 border-dashed border-slate-200 hover:bg-white hover:text-pink-500 hover:border-pink-300 hover:scale-110 transition-all group/add",title:"æ·»å æ°åç±»",children:e.jsx(wt,{size:20,strokeWidth:3,className:"group-hover/add:rotate-90 transition-transform duration-300"})})]})]}),e.jsxs("main",{className:`relative z-10 px-4 pb-8 md:px-12 md:pb-16 custom-scrollbar ${s?"":"flex-1 min-h-0 overflow-y-auto"}`,children:[Se&&e.jsx("p",{"data-testid":"research-sessions-error",role:"alert",className:"mb-4 text-rose-500 font-bold",children:Se}),nt&&e.jsx("p",{"data-testid":"research-save-meta-global-error",role:"alert",className:"mb-4 text-rose-500 font-bold",children:nt}),Pt?e.jsxs("div",{role:"status","aria-label":d.checking,children:[e.jsx("p",{className:"sr-only",children:d.checking}),e.jsx("div",{"aria-hidden":"true",className:ot,children:Array.from({length:$r},(t,r)=>e.jsxs("div",{"data-save-skeleton":!0,className:`min-w-0 overflow-hidden flex flex-col rounded-[12px] md:rounded-[24px] border-[2px] md:border-[3px] border-white bg-white shadow-sm animate-pulse motion-reduce:animate-none ${s?"h-[200px]":"h-[380px]"}`,children:[e.jsxs("div",{className:`${s?"h-20":"h-32"} shrink-0 bg-gradient-to-br from-slate-200 via-slate-100 to-pink-50 flex flex-col justify-end gap-2 ${s?"p-2":"p-5"}`,children:[e.jsx("div",{className:"h-3 md:h-4 w-4/5 rounded-full bg-slate-200"}),e.jsx("div",{className:"h-2 md:h-3 w-3/5 rounded-full bg-slate-200"})]}),e.jsxs("div",{className:`min-h-0 flex-1 flex flex-col border-t border-white bg-slate-50/50 ${s?"p-2 gap-2":"p-5 gap-4"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`${s?"w-5 h-5":"w-8 h-8"} shrink-0 rounded-lg bg-slate-200`}),e.jsx("div",{className:"h-2 md:h-3 w-1/3 rounded-full bg-slate-200"}),e.jsx("div",{className:"ml-auto h-3 md:h-5 w-1/4 rounded-lg bg-pink-50"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-2 md:h-3 w-full rounded-full bg-slate-200"}),e.jsx("div",{className:"h-2 md:h-3 w-2/3 rounded-full bg-slate-100"})]}),e.jsxs("div",{className:"mt-auto flex items-center justify-between gap-2",children:[e.jsx("div",{className:"h-2 w-1/3 rounded-full bg-slate-200"}),e.jsx("div",{className:`${s?"h-7":"h-11"} w-2/5 rounded-xl bg-pink-50`})]})]})]},r))})]}):Ue?$.length===0&&A.length===0?e.jsx("div",{className:`${lt} flex flex-col items-center justify-center gap-6 text-center`,children:e.jsxs("div",{className:"p-8 bg-white/80 backdrop-blur-md rounded-[40px] border-4 border-white shadow-xl max-w-md",children:[e.jsx("div",{className:"w-20 h-20 bg-red-50 rounded-3xl flex items-center justify-center text-red-400 mx-auto mb-6 transform rotate-6",children:e.jsx(Me,{size:40})}),e.jsx("p",{className:"text-red-500 font-black text-lg mb-8",children:Ue}),e.jsx("button",{onClick:()=>{X()},className:"w-full py-4 bg-gradient-to-r from-pink-500 to-rose-600 text-white rounded-2xl font-black shadow-lg hover:scale-105 active:scale-95 transition-all",children:d.retry})]})}):Ie():$.length===0&&A.length===0?e.jsxs("div",{className:`${lt} flex flex-col items-center justify-center gap-8 opacity-40`,children:[e.jsxs("div",{className:"relative",children:[e.jsx(bt,{size:120,className:"text-slate-300"}),e.jsx(qe,{className:"absolute inset-0 m-auto text-slate-100",size:48})]}),e.jsx("p",{className:"text-3xl font-black text-slate-400 tracking-tighter",children:d.noSaves})]}):Ie()]}),e.jsxs("footer",{className:"relative z-20 px-12 py-6 border-t border-white hidden md:flex items-center justify-between pointer-events-none",children:[e.jsx("div",{className:"text-slate-400 text-[10px] font-black uppercase tracking-[0.2em]",children:"Copyright © 2026 Paper2Gal ⢠Visual Novel Hub"}),e.jsx("div",{className:"flex items-center gap-8",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),e.jsx("span",{className:"text-slate-300 text-[10px] font-black uppercase tracking-widest",children:qt(Xe)})]})})]}),Ge&&e.jsx("div",{className:`fixed inset-0 z-[100] flex items-center justify-center bg-pink-900/40 backdrop-blur-md animate-fade-in ${s?"p-3":"p-6"}`,style:H,onClick:()=>V(null),children:e.jsxs("div",{className:`bg-white shadow-2xl border-white ring-pink-100 max-w-sm w-full text-center animate-bounce-in ${s?"rounded-[24px] border-[2px] ring-2 p-5 max-w-[min(92vw,400px)] max-h-[min(85dvh,90%)] overflow-y-auto":"rounded-[40px] border-[6px] ring-4 p-10"}`,onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"w-20 h-20 bg-red-50 text-red-500 rounded-3xl flex items-center justify-center mx-auto mb-8 transform -rotate-6",children:e.jsx(me,{size:40})}),e.jsx("h3",{className:"text-2xl font-black text-slate-800 mb-2 tracking-tighter",children:d.deleteSaveConfirm||"Delete Script?"}),e.jsx("p",{className:"text-slate-500 font-bold mb-10 text-sm leading-relaxed italic",children:d.deleteSaveConfirmSub||"Is this story no longer needed? This action cannot be reversed."}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("button",{onClick:()=>V(null),className:"flex-1 py-4 bg-slate-100 hover:bg-slate-200 text-slate-500 rounded-2xl font-black transition-all",children:d.cancel}),e.jsx("button",{onClick:()=>Ft(Ge),className:"flex-1 py-4 bg-red-500 hover:bg-red-600 text-white rounded-2xl font-black shadow-lg shadow-red-100 transition-all hover:-translate-y-1",children:d.delete})]})]})}),Fe&&e.jsx("div",{className:`fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/60 backdrop-blur-md animate-fade-in ${s?"p-3":"p-6"}`,style:H,onClick:()=>G(null),children:e.jsxs("div",{className:`bg-white shadow-2xl border-white ring-cyan-100 max-w-sm w-full text-center animate-bounce-in ${s?"rounded-[24px] border-[2px] ring-2 p-5 max-w-[min(92vw,400px)] max-h-[min(85dvh,90%)] overflow-y-auto":"rounded-[40px] border-[6px] ring-4 p-10"}`,onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"w-20 h-20 bg-cyan-50 text-cyan-600 rounded-3xl flex items-center justify-center mx-auto mb-8 transform -rotate-6",children:e.jsx(me,{size:40})}),e.jsx("h3",{className:"text-2xl font-black text-slate-800 mb-2 tracking-tighter",children:h==="zh"?"å é¤ç§æç ç©¶ä¼è¯ï¼":"Delete private research session?"}),e.jsx("p",{className:"text-slate-500 font-bold mb-10 text-sm leading-relaxed italic",children:h==="zh"?"该ä¼è¯åå ¶æ¬æºç¼åå°è¢«å é¤ï¼ä¸è½æ¢å¤ã":"This session and its local cache will be deleted and cannot be restored."}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("button",{type:"button",onClick:()=>G(null),className:"flex-1 py-4 bg-slate-100 hover:bg-slate-200 text-slate-500 rounded-2xl font-black transition-all",children:d.cancel}),e.jsx("button",{type:"button",onClick:()=>void Gt(Fe),className:"flex-1 py-4 bg-red-500 hover:bg-red-600 text-white rounded-2xl font-black shadow-lg shadow-red-100 transition-all hover:-translate-y-1",children:d.delete})]})]})}),At&&e.jsx("div",{className:`fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/40 backdrop-blur-md animate-fade-in ${s?"p-3":"p-6"}`,style:H,onClick:()=>ne(!1),children:e.jsxs("div",{className:`bg-white shadow-2xl border-white ring-pink-100 max-w-md w-full animate-bounce-in ${s?"rounded-[24px] border-[2px] ring-2 p-5 max-w-[min(92vw,400px)] max-h-[min(85dvh,90%)] overflow-y-auto custom-scrollbar touch-p
31an-y":"rounded-[40px] border-[6px] ring-4 p-8 md:p-10"}`,onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"w-16 h-16 bg-pink-50 text-pink-500 rounded-2xl flex items-center justify-center mx-auto mb-6",children:e.jsx(ee,{size:32})}),e.jsx("h3",{className:"text-2xl font-black text-slate-800 mb-2 text-center tracking-tighter",children:d.importSaveTitle||"å¯¼å ¥å§æ¬åæ¡£"}),e.jsx("p",{className:"text-slate-500 font-bold mb-8 text-center text-sm italic",children:d.importSaveHint||"请è¾å ¥å享è çåæ¡£ ID (UUID) æ¥è½½å ¥å§æ¬ã"}),e.jsxs("div",{className:"space-y-4 mb-8",children:[e.jsx("input",{type:"text",value:ie,onChange:t=>Qe(t.target.value),placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",className:`w-full px-5 py-4 bg-slate-50 border-2 border-slate-100 rounded-2xl font-bold text-slate-700 outline-none focus:border-pink-300 transition-all text-center tracking-wider text-sm ${s?"touch-pan-y":""}`,style:s?{touchAction:"pan-y"}:void 0}),e.jsx("div",{className:"p-4 bg-amber-50 rounded-2xl border border-amber-100",children:e.jsxs("p",{className:"text-[10px] text-amber-700 font-black leading-relaxed",children:[e.jsx(Me,{size:12,className:"inline mr-1 mb-0.5"}),d.importSaveWarning||"注æï¼å¯¼å ¥ä»äººåæ¡£ä¼æºå¸¦å¯¹æ¹èªå®ä¹è§è²çç«ç»å¾çï¼ä½ä¸ä¼å°å ¶è§è²æ·»å å°æ¨çå表ä¸ã"]})})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("button",{onClick:()=>ne(!1),className:"flex-1 py-4 bg-slate-100 hover:bg-slate-200 text-slate-500 rounded-2xl font-black transition-all",children:d.cancel}),e.jsxs("button",{onClick:Jt,disabled:Ke||!ie.trim(),className:"flex-1 py-4 bg-gradient-to-r from-pink-500 to-rose-600 text-white rounded-2xl font-black shadow-lg shadow-pink-100 transition-all hover:-translate-y-1 active:scale-95 disabled:opacity-50 disabled:pointer-events-none flex items-center justify-center gap-2",children:[Ke?e.jsx(he,{size:18,className:"animate-spin"}):e.jsx(ee,{size:18}),d.importSaveBtn||d.import||"å¯¼å ¥"]})]})]})}),J&&e.jsx("div",{className:`fixed inset-0 z-[110] flex items-center justify-center bg-slate-900/60 backdrop-blur-md animate-fade-in ${s?"p-3":"p-6"}`,style:H,onClick:()=>Q(null),children:e.jsxs("div",{className:`bg-white shadow-2xl border-white ring-blue-100 max-w-md w-full animate-bounce-in ${s?"rounded-[24px] border-[2px] ring-2 p-5 max-w-[min(92vw,400px)] max-h-[min(85dvh,90%)] overflow-y-auto":"rounded-[40px] border-[6px] ring-4 p-8 md:p-10"}`,onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"w-16 h-16 bg-blue-50 text-blue-500 rounded-2xl flex items-center justify-center mx-auto mb-6",children:e.jsx(gt,{size:32})}),e.jsx("h3",{className:"text-2xl font-black text-slate-800 mb-2 text-center tracking-tighter",children:d.shareConfirmTitle||"ç¡®å®è¦å享è¿ä¸ªåæ¡£åï¼"}),e.jsx("div",{className:"p-5 bg-blue-50 rounded-2xl border border-blue-100 mb-8",children:e.jsx("p",{className:"text-xs text-blue-700 font-bold leading-relaxed whitespace-pre-wrap",children:d.shareConfirmText||`注æï¼ 321. 确认å享åï¼è¯·è®°å¾ç¹å»å¡çå·¦ä¸è§çâIDâå¤å¶åæ¡£ UUID å享ç»ä»äººã 332. å³ä½¿æ¨ç¨ååæ¶å享ï¼ä¹æ æ³å é¤ä»äººå·²ç»è½¬åç坿¬ã 343. æ¨çèªå®ä¹è§è²ç«ç»å¾çå°è¢«å å«å¨åæ¡£ä¸ä¾ä»äººæ¥çã`})}),e.jsxs("div",{className:"bg-gradient-to-r from-pink-50 to-blue-50 p-4 rounded-2xl border-2 border-pink-200 mb-8 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Me,{size:18,className:"text-pink-600 flex-shrink-0"}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{className:"text-[11px] text-pink-700 font-black leading-snug mb-1",children:d.shareUuidLabel||"å享 UUID"}),e.jsx("span",{className:"text-xs font-mono font-bold text-slate-800 break-all",children:(E==null?void 0:E.id)||"â"})]})]}),e.jsxs("button",{onClick:async()=>{if(E!=null&&E.id)try{await navigator.clipboard.writeText(E.id),await z(d.idCopied||"ID Copied!",{variant:"success"})}catch(t){console.error(t),await z(d.copyFailed||"å¤å¶å¤±è´¥ï¼è¯·æå¨éæ©å¤å¶ã",{variant:"error"})}},className:"shrink-0 inline-flex items-center gap-1.5 px-3 py-2 rounded-xl bg-white text-pink-600 border border-pink-200 hover:bg-pink-50 hover:border-pink-300 text-xs font-black shadow-sm transition-all",children:[e.jsx(ur,{size:14}),e.jsx("span",{children:d.copyUuid||"å¤å¶"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("button",{onClick:()=>Q(null),className:"flex-1 py-4 bg-slate-100 hover:bg-slate-200 text-slate-500 rounded-2xl font-black transition-all",children:d.cancel}),e.jsxs("button",{onClick:()=>it(J,!1,!0),className:"flex-1 py-4 bg-gradient-to-r from-blue-500 to-indigo-600 text-white rounded-2xl font-black shadow-lg shadow-blue-100 transition-all hover:-translate-y-1 active:scale-95 flex items-center justify-center gap-2",children:[e.jsx(fr,{size:18}),d.confirmShare||"确认å享"]})]})]})}),S&&e.jsx("div",{className:`fixed inset-0 z-[120] flex items-center justify-center bg-slate-900/40 backdrop-blur-md animate-fade-in ${s?"p-3":"p-6"}`,style:H,onClick:()=>W(null),children:e.jsxs("div",{className:`bg-white shadow-2xl border-white ring-pink-100 max-w-sm w-full animate-bounce-in flex flex-col ${s?"rounded-[24px] border-[2px] ring-2 p-5 max-h-[min(85dvh,90%)] overflow-y-auto":"rounded-[40px] border-[6px] ring-4 p-8 md:p-10 max-h-[80vh]"}`,onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"text-xl font-black text-slate-800 tracking-tighter",children:h==="zh"?"ç§»å¨å°ååº":"Move to Partition"}),e.jsx("button",{onClick:()=>W(null),className:"p-2 hover:bg-slate-100 rounded-full text-slate-400 transition-colors",children:e.jsx(qe,{size:20})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto no-scrollbar space-y-2 mb-6",children:[e.jsxs("button",{onClick:async()=>{await $e(S,null)},className:`w-full px-5 py-4 rounded-2xl font-bold transition-all text-left flex items-center justify-between group ${Z?"bg-slate-50 text-slate-600 hover:bg-pink-50 hover:text-pink-600":"bg-pink-500 text-white shadow-lg"}`,children:[e.jsx("span",{children:h==="zh"?"æªååº":"Uncategorized"}),!Z&&e.jsx(Re,{size:14,className:"text-pink-200"})]}),Oe.map(t=>e.jsxs("button",{onClick:async()=>{await $e(S,t)},className:`w-full px-5 py-4 rounded-2xl font-bold transition-all text-left flex items-center justify-between group ${Z===t?"bg-pink-500 text-white shadow-lg":"bg-slate-50 text-slate-600 hover:bg-pink-50 hover:text-pink-600"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{size:16,className:Z===t?"text-pink-200":"text-slate-300"}),e.jsx("span",{children:t})]}),Z===t&&e.jsx(Re,{size:14,className:"text-pink-200"})]},t))]}),e.jsxs("button",{onClick:async()=>{const t=await oe(h==="zh"?"æ°å»ºå¹¶ç§»å¨å°ååº":"Create & Move to Partition",{placeholder:h==="zh"?"åç±»åç§°":"Category Name"});if(t&&t.trim()){const r=t.trim();
34if(await $e(S,r),!Oe.includes(r))try{const l=localStorage.getItem("p2g_token"),a=await fetch("/api/categories",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({name:r})});if(a.ok){const n=await a.json();K(i=>[...i,n])}}catch(l){console.error(l)}}},className:"w-full py-4 bg-gradient-to-r from-slate-700 to-slate-800 text-white rounded-2xl font-black shadow-lg hover:scale-[1.02] active:scale-95 transition-all flex items-center justify-center gap-2",children:[e.jsx(wt,{size:18}),h==="zh"?"æ°å»ºååº":"New Partition"]})]})})]});function Ie(){return e.jsx("div",{"data-testid":"save-card-grid",className:ot,children:Vt.map(t=>{var N;if(t.kind==="research"){const g=t.session,j=g.presentation,v=j==null?void 0:j.character,P=(v==null?void 0:v.kind)==="default"?be.find(_=>_.id===v.id):void 0,M=(v==null?void 0:v.kind)==="cloud"?De.find(_=>_.dbId===v.id||_.id===v.id):void 0,Te=P&&v?xt(P,v.skinId):void 0,ce=(Te==null?void 0:Te.avatarUrl)||(M==null?void 0:M.avatarUrl)||null,Xt=(v==null?void 0:v.name)||((N=P==null?void 0:P.names)==null?void 0:N[h])||(P==null?void 0:P.name)||(M==null?void 0:M.name)||(h==="zh"?"ç ç©¶è§è²":"Research character"),Ae=(j==null?void 0:j.title)||g.label||(h==="zh"?"ç ç©¶åæ¡£":"Research save"),Zt=(j==null?void 0:j.preview)||(h==="zh"?"ä»
æ¬äººå¯è§çç ç©¶è®°å½ï¼å¯ä»åæ¡£å表æ¢å¤ã":"Private research record, restorable from the save list."),er=(j==null?void 0:j.category)||null,L=ve[g.sessionId];return e.jsxs("div",{"data-testid":"research-save-card","data-save-kind":"research",className:`group relative min-w-0 bg-white rounded-[12px] md:rounded-[24px] border-[2px] md:border-[3px] border-white shadow-lg hover:shadow-xl hover:-translate-y-1 transition-all duration-300 overflow-hidden flex flex-col ${s?"h-[200px]":"h-[380px]"}`,children:[e.jsxs("div",{"data-testid":"research-save-card-preview",className:`${s?"h-20":"h-32"} shrink-0 bg-gradient-to-br from-slate-100 to-slate-50 relative overflow-hidden`,children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(#ec4899 1px, transparent 1px)",backgroundSize:"15px 15px"}}),ce&&e.jsx("img",{src:ce,className:`absolute -right-2 -bottom-2 ${s?"h-16":"h-28"} opacity-10 group-hover:opacity-20 transition-opacity grayscale group-hover:grayscale-0 duration-500`,alt:""}),e.jsxs("div",{className:`absolute inset-0 flex flex-col ${s?"p-2":"p-5"}`,children:[e.jsx("div",{className:"flex min-w-0 shrink-0 items-start justify-between gap-2",children:e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-xl border border-pink-100 bg-white/95 font-black text-pink-500 shadow-sm ${s?"px-1.5 py-1 text-[8px]":"px-2.5 py-1.5 text-[10px]"}`,children:[e.jsx(br,{size:s?10:12}),h==="zh"?"ç§æç ç©¶":"Private research"]})}),e.jsx("div",{className:"mt-auto min-w-0 overflow-hidden",children:e.jsx("h3",{"data-testid":"research-save-card-title",className:`${s?"text-xs":"text-lg"} min-w-0 overflow-hidden font-black text-slate-700 leading-tight tracking-tight`,children:e.jsx("span",{className:"block min-w-0 break-words line-clamp-2",children:Ae})})})]})]}),e.jsxs("div",{"data-testid":"research-save-card-content",className:`min-h-0 flex-1 overflow-hidden ${s?"p-2":"p-5"} flex flex-col bg-slate-50/50 border-t border-white`,children:[e.jsxs("div",{className:`flex shrink-0 items-center gap-1 w-full ${s?"mb-1.5":"mb-4"}`,children:[e.jsxs("div",{className:`flex items-center gap-1 bg-white/80 ${s?"p-0.5":"p-1.5 pl-1.5 pr-3"} rounded-lg md:rounded-xl border border-white shadow-sm shrink-0 min-w-0`,children:[ce?e.jsx("div",{className:`${s?"w-5 h-5":"w-8 h-8"} rounded bg-pink-50 overflow-hidden border border-white shadow-inner flex-shrink-0`,children:e.jsx("img",{src:ce,className:"w-full h-full object-cover",alt:""})}):e.jsx("div",{className:`${s?"w-5 h-5":"w-8 h-8"} rounded bg-slate-200 flex items-center justify-center text-slate-400 flex-shrink-0`,children:e.jsx(vt,{size:s?10:16})}),e.jsx("span",{className:`font-black text-slate-600 leading-none truncate ${s?"text-[9px]":"text-xs"}`,children:Xt})]}),e.jsxs("button",{type:"button","data-testid":"research-save-card-category",onClick:_=>{_.stopPropagation(),rt({kind:"research",session:g})},className:`shrink-0 inline-flex items-center gap-1.5 rounded-xl bg-white/80 border border-white text-slate-400 hover:bg-pink-50 hover:text-pink-600 hover:border-pink-300 transition-all shadow-sm ml-auto ${s?"px-1.5 py-0.5 text-[8px] font-bold text-pink-500 bg-pink-100/50 border-pink-200 max-w-[80px]":"px-3 py-1.5 text-[10px] font-black"}`,title:h==="zh"?"ç¹å»éæ©åç±»":"Select category",children:[e.jsx(xe,{size:s?10:12,className:"text-pink-400"}),e.jsx("span",{className:"max-w-[80px] truncate",children:er||d.uncategorized||"Uncategorized"})]})]}),e.jsxs("div",{"data-testid":"research-save-card-summary",className:`min-h-0 flex-1 overflow-y-auto break-words italic text-slate-500 ${s?"mb-1 text-[9px]":"mb-4 text-[11px]"} leading-tight save-card-text-scrollbar`,children:[(L==null?void 0:L.phase)==="saving"&&e.jsx("p",{"data-testid":"research-save-meta-saving",className:"mb-2 not-italic font-bold text-pink-500",children:h==="zh"?"æ£å¨ä¿åâ¦":"Savingâ¦"}),(L==null?void 0:L.message)&&e.jsx("p",{"data-testid":"research-save-meta-error",role:"alert",className:"mb-2 not-italic font-bold text-rose-500",children:L.message}),g.offline&&e.jsx("p",{className:"mb-2 not-italic font-bold text-amber-600",children:h==="zh"?"离线åªè¯»":"Offline read-only"}),e.jsx("p",{children:Zt})]}),e.jsxs("div",{className:"flex min-w-0 shrink-0 items-center justify-between gap-1 mt-auto pt-1",children:[e.jsx("span",{className:`${s?"text-[8px]":"text-[10px]"} min-w-0 truncate font-bold text-slate-400`,children:g.updatedAt?Pe(g.updatedAt):""}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[fe&&e.jsx("button",{type:"button",onClick:()=>G(g.sessionId),className:`${s?"w-7 h-7":"w-9 h-9"} bg-white/80 border border-slate-200 rounded-lg flex items-center justify-center text-slate-400 hover:text-red-500 hover:border-red-300 hover:bg-red-50 shadow-sm transition-all`,title:h==="zh"?"å é¤ç ç©¶ä¼è¯":"Delete research session","aria-label":`${h==="zh"?"å é¤":"Delete"} ${Ae}`,children:e.jsx(me,{size:s?12:14})}),ue&&e.jsx("button",{type:"button",onClick:()=>void Dt(g),className:`${s?"w-7 h-7":"w-9 h-9"} bg-white/80 border border-slate-200 rounded-lg flex items-center justify-center text-slate-400 hover:text-pink-500 hover:border-pink-300 hover:bg-pink-50 shadow-sm transition-all`,title:h==="zh"?"éå½å":"Rename","aria-label":`${h==="zh"?"éå½å":"Rename"} ${Ae}`,children:e.jsx(yt,{size:s?12:14})}),Be&&e.jsx("button",{type:"button","data-testid":"research-save-card-restore",onClick:()=>Be(g.sessionId),className:`${s?"w-8 h-8":"w-11 h-11"} rounded-xl flex items-center justify-center bg-gradient-to-br from-pink-500 to-rose-600 text-white shadow-lg shadow-pink-100/50 hover:scale-105 active:scale-95 transition-all`,title:h==="zh"?"æ¢å¤ç ç©¶ä¼è¯":"Restore research session","aria-label":h==="zh"?"æ¢å¤ç ç©¶ä¼è¯":"Restore research session",children:e.jsx(kt,{size:s?14:20,fill:"currentColor",className:"ml-0.5"})})]})]})]})]},g.sessionId)}const r=t.save,l=Ht(r.gameState),a=r.displayTitle||r.chapterTitle,n=mt(r),i=dt(r),o=Ee(r),x=ht(r),w=Sr(Tt,r),m=n.kind!=="succeeded"||x&&!w,f=It[r.id]||{state:"none",completed:0,total:0};return e.jsxs("div",{"data-testid":"save-card","data-save-kind":"story",className:`group relative min-w-0 bg-white rounded-[12px] md:rounded-[24px] border-[2px] md:border-[3px] border-white shadow-lg hover:shadow-xl hover:-translate-y-1 transition-all duration-300 overflow-hidden flex flex-col ${s?"h-[200px]":"h-[380px]"}`,children:[e.jsxs("div",{"data-testid":"save-card-preview",className:`${s?"h-20":"h-32"} shrink-0 bg-gradient-to-br from-slate-100 to-slate-50 relative overflow-hidden`,children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(#ec4899 1px, transparent 1px)",backgroundSize:"15px 15px"}}),l.avatar&&e.jsx("img",{src:l.avatar,className:`absolute -right-2 -bottom-2 ${s?"h-16":"h-28"} opacity-10 group-hover:opacity-20 transition-opacity grayscale group-hover:grayscale-0 duration-500`,alt:""}),e.jsxs("div",{className:`absolute inset-0 flex flex-col ${s?"p-2":"p-5"}`,children:[e.jsxs("div",{className:"flex min-w-0 shrink-0 justify-between items-start mb-1",children:[e.jsx("div",{children:x&&!w&&e.jsxs("span",{className:`inline-flex items-center rounded-xl border border-violet-100 bg-white/95 font-black text-violet-500 shadow-sm ${s?"p-1":"gap-1.5 px-2.5 py-1.5 text-[10px]"}`,title:d.voiceMode||"è¯é³","aria-label":d.voiceMode||"è¯é³",children:[e.jsx(wr,{size:s?11:12}),!s&&e.jsx("span",{children:d.voiceMode||"è¯é³"})]})}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),Kt(r)},disabled:!o||!!F,className:`inline-flex items-center justify-center rounded-lg border shadow-sm transition ${s?"h-6 w-6":"h-7 w-7"} ${F===r.id?"border-pink-200 bg-pink-50 text-pink-500":"border-slate-200 bg-white/90 text-slate-400 hover:border-pink-200 hover:text-pink-500"} disabled:cursor-not-allowed disabled:opacity-50`,title:F===r.id&&ye.total>0?`${Y.export} ${ye.current}/${ye.total}`:Y.export,"aria-label":Y.export,children:F===r.id?e.jsx(he,{size:s?11:13,className:"animate-spin"}):e.jsx(gr,{size:s?11:13})}),de()&&e.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),Wt(r)},disabled:f.state==="downloading",className:`inline-flex items-center justify-center rounded-lg border shadow-sm transition ${s?"h-6 w-6":"h-7 w-7"} ${f.state==="ready"?"border-emerald-200 bg-emerald-50 text-emerald-600":f.state==="partial"?"border-amber-200 bg-amber-50 text-amber-600":"border-slate-200 bg-white/90 text-slate-400 hover:border-pink-200 hover:text-pink-500"}`,title:f.state==="ready"?O.ready:f.state==="partial"?`${O.partial} (${f.completed}/${f.total})`:O.download,"aria-label":f.state==="ready"?O.ready:O.download,children:f.state==="downloading"?e.jsx(he,{size:s?11:13,className:"animate-spin"}):f.state==="ready"?e.jsx(jt,{size:s?11:13}):e.jsx(ee,{size:s?11:13})}),!s&&r.isShared&&e.jsx("span",{className:"px-2 py-1 rounded-lg bg-blue-500/90 text-white text-[10px] font-black uppercase tracking-tighter shadow-sm border border-blue-400",children:d.saveSharedLabel||"Public"})]})]}),e.jsx("div",{className:"mt-auto min-w-0 overflow-hidden",children:e.jsx("h3",{"data-testid":"save-card-title",className:`${s?"text-xs":"text-lg"} min-w-0 overflow-hidden font-black text-slate-700 leading-tight tracking-tight`,children:e.jsx("span",{className:"block min-w-0 cursor-text break-words line-clamp-2",onDoubleClick:()=>et(r),children:a})})})]})]}),e.jsxs("div",{"data-testid":"save-card-content",className:`min-h-0 flex-1 overflow-hidden ${s?"p-2":"p-5"} flex flex-col bg-slate-50/50 border-t border-white`,children:[e.jsxs("div",{className:`flex shrink-0 items-center gap-1 w-full ${s?"mb-1.5":"mb-4"}`,children:[e.jsxs("div",{className:`flex items-center gap-1 bg-white/80 ${s?"p-0.5":"p-1.5 pl-1.5 pr-3"} rounded-lg md:rounded-xl border border-white shadow-sm shrink-0 min-w-0`,children:[l.avatar?e.jsx("div",{className:`${s?"w-5 h-5":"w-8 h-8"} rounded bg-pink-50 overflow-hidden border border-white shadow-inner flex-shrink-0`,children:e.jsx("img",{src:l.avatar,className:"w-full h-full object-cover"})}):e.jsx("div",{className:`${s?"w-5 h-5":"w-8 h-8"} rounded bg-slate-200 flex items-center justify-center text-slate-400 flex-shrink-0`,children:e.jsx(vt,{size:s?10:16})}),e.jsxs("div",{className:`flex flex-col min-w-0 ${s?"flex-1":""}`,children:[!s&&e.jsx("span",{className:"text-[8px] font-black text-slate-400 uppercase tracking-widest leading-none mb-0.5",children:d.companion}),e.jsx("span",{className:`font-black text-slate-600 leading-none truncate ${s?"text-[9px]":"text-xs"}`,children:l.name})]})]}),e.jsx("div",{className:"flex-1 min-w-0 flex justify-end items-center shrink-0",children:e.jsxs("button",{onClick:g=>{g.stopPropagation(),rt({kind:"story",save:r})},className:`shrink-0 inline-flex items-center gap-1.5 rounded-xl bg-white/80 border border-white text-slate-400 hover:bg-pink-50 hover:text-pink-600 hover:border-pink-300 transition-all shadow-sm ${s?"px-1.5 py-0.5 text-[8px] font-bold text-pink-500 bg-pink-100/50 border-pink-200 max-w-[80px]":"px-3 py-1.5 text-[10px] font-black"}`,title:h==="zh"?"ç¹å»éæ©åç±»":"Select category",children:[e.jsx(xe,{size:s?10:12,className:"text-pink-400"}),e.jsx("span",{className:"max-w-[80px] truncate",children:r.category||d.uncategorized||"æªååº"})]})})]}),e.jsxs("div",{"data-testid":"save-card-text-scroll",className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-y-contain bg-transparent save-card-text-scrollbar touch-p
34an-y focus:outline-none focus-visible:ring-2 focus-visible:ring-pink-200 ${s?"mb-1 pr-1":"mb-4 pr-2"}`,tabIndex:0,children:[m&&e.jsxs("div",{"data-testid":"save-card-status",className:`${s?"mb-1":"mb-2"} min-w-0`,children:[e.jsxs("div",{className:`inline-flex max-w-full min-w-0 items-center gap-1 rounded-full border font-black ${Yt[n.tone]} ${s?"px-1.5 py-0.5 text-[8px]":"px-2.5 py-1 text-[10px]"}`,children:[n.kind==="succeeded"?e.jsx(jt,{size:s?10:12,className:"shrink-0"}):n.kind==="failed"?e.jsx(vr,{size:s?10:12,className:"shrink-0"}):n.kind==="cancelled"?e.jsx(yr,{size:s?10:12,className:"shrink-0"}):i?e.jsx(he,{size:s?10:12,className:"shrink-0 animate-spin"}):e.jsx(_e,{size:s?10:12,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 break-words",children:n.kind==="succeeded"&&x?d.voiceGenerationComplete||"è¯é³å·²çæå®æ¯":n.label})]}),!s&&n.detail&&e.jsx("p",{className:"mt-1 text-[10px] font-bold text-slate-400 leading-snug break-words",children:n.detail})]}),e.jsxs("p",{"data-testid":"save-card-summary",className:`break-words italic text-slate-500 ${s?"text-[9px]":"text-[11px]"} leading-tight`,children:['"',r.previewText,'"']})]}),e.jsxs("div",{className:"flex min-w-0 shrink-0 items-center justify-between gap-1 mt-auto pt-1",children:[e.jsxs("div",{className:"flex min-w-0 flex-col overflow-hidden",children:[!s&&e.jsxs("span",{className:"text-[8px] font-black text-slate-400 uppercase tracking-widest leading-none mb-0.5 flex items-center gap-1",children:[e.jsx(_e,{size:8})," ",d.lastPlayed]}),e.jsx("span",{className:`${s?"text-[8px]":"text-[10px]"} block min-w-0 truncate whitespace-nowrap font-bold text-slate-400`,children:s?Pe(r.updatedAt).split(" ")[0]:Pe(r.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>V(r.id),className:`${s?"w-7 h-7":"w-9 h-9"} bg-white/80 border border-slate-200 rounded-lg flex items-center justify-center text-slate-400 hover:text-red-500 hover:border-red-300 hover:bg-red-50 shadow-sm transition-all`,title:d.deleteSave||d.delete||"å é¤",children:e.jsx(me,{size:s?12:14})}),e.jsx("button",{onClick:()=>it(r.id,!!r.isShared),className:`${s?"w-7 h-7":"w-9 h-9"} rounded-lg flex items-center justify-center shadow-sm border transition-all ${r.isShared?"bg-blue-500 border-blue-400 text-white":"bg-white/80 border-slate-200 text-slate-400 hover:text-blue-500 hover:border-blue-300 hover:bg-blue-50"}`,title:r.isShared?d.saveSharedLabel||"å·²å享":d.shareSave||"åäº«åæ¡£",children:e.jsx(gt,{size:s?12:14})}),e.jsx("button",{onClick:()=>et(r),className:`${s?"w-7 h-7":"w-9 h-9"} bg-white/80 border border-slate-200 rounded-lg flex items-center justify-center text-slate-400 hover:text-pink-500 hover:border-pink-300 hover:bg-pink-50 shadow-sm transition-all`,title:d.renameSave||"éå½å",children:e.jsx(yt,{size:s?12:14})}),e.jsx("button",{onClick:()=>
34Qt(r),className:`${s?"w-8 h-8":"w-11 h-11"} rounded-xl flex items-center justify-center text-white shadow-lg transition-all group/play ${o?"bg-gradient-to-br from-pink-500 to-rose-600 shadow-pink-100/50 hover:scale-110 active:scale-95":n.kind==="failed"||n.kind==="cancelled"?"bg-gradient-to-br from-red-400 to-rose-500 shadow-red-100/50 hover:scale-105 active:scale-95":"bg-gradient-to-br from-slate-300 to-slate-400 shadow-slate-100/50 hover:scale-105 active:scale-95"}`,title:o?d.startGame||"å¼å§æ¸¸æ":n.detail,children:o?e.jsx(kt,{size:s?14:20,fill:"currentColor",className:"ml-0.5 transition-transform"}):e.jsx(_e,{size:s?14:18,className:i?"animate-pulse":""})})]})]})]})]},r.id)})})}};export{Rr 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.