@eternalheart/react-file-preview 1.3.7 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/FilePreviewContent.d.ts +12 -1
- package/lib/FilePreviewContent.d.ts.map +1 -1
- package/lib/FilePreviewEmbed.d.ts +9 -1
- package/lib/FilePreviewEmbed.d.ts.map +1 -1
- package/lib/FilePreviewModal.d.ts +9 -1
- package/lib/FilePreviewModal.d.ts.map +1 -1
- package/lib/RequestContext.d.ts +24 -0
- package/lib/RequestContext.d.ts.map +1 -0
- package/lib/chunks/{index-BIg3vHQf.mjs → index-B-H9HQiI.mjs} +35 -35
- package/lib/chunks/index-B-H9HQiI.mjs.map +1 -0
- package/lib/chunks/{index-DOMMMe9f.mjs → index-BGeyzo6u.mjs} +2 -2
- package/lib/chunks/{index-DOMMMe9f.mjs.map → index-BGeyzo6u.mjs.map} +1 -1
- package/lib/chunks/{index-zDEwNk3h.mjs → index-BNUiNUWa.mjs} +35 -35
- package/lib/chunks/index-BNUiNUWa.mjs.map +1 -0
- package/lib/chunks/{index-DTH1IvOG.mjs → index-BSD3w5eG.mjs} +72 -72
- package/lib/chunks/index-BSD3w5eG.mjs.map +1 -0
- package/lib/chunks/{index-D_8IHm6o.mjs → index-BcBe6KW7.mjs} +11 -10
- package/lib/chunks/index-BcBe6KW7.mjs.map +1 -0
- package/lib/chunks/index-BdYkTSTt.mjs +51 -0
- package/lib/chunks/index-BdYkTSTt.mjs.map +1 -0
- package/lib/chunks/{index-BWbuffRN.mjs → index-BqEuP_8r.mjs} +8 -8
- package/lib/chunks/index-BqEuP_8r.mjs.map +1 -0
- package/lib/chunks/{index-LNXbKjrI.mjs → index-Bv93wiEK.mjs} +812 -681
- package/lib/chunks/index-Bv93wiEK.mjs.map +1 -0
- package/lib/chunks/{index-xTq9b3vw.mjs → index-CKirCT35.mjs} +13 -13
- package/lib/chunks/index-CKirCT35.mjs.map +1 -0
- package/lib/chunks/{index-BOEtlHD3.mjs → index-CgV8T0G5.mjs} +53 -53
- package/lib/chunks/index-CgV8T0G5.mjs.map +1 -0
- package/lib/chunks/{index-DinKO2op.mjs → index-D8GtNeDn.mjs} +2 -2
- package/lib/chunks/{index-DinKO2op.mjs.map → index-D8GtNeDn.mjs.map} +1 -1
- package/lib/chunks/{index-CQABwGVP.mjs → index-DGuiWJr7.mjs} +18 -18
- package/lib/chunks/index-DGuiWJr7.mjs.map +1 -0
- package/lib/chunks/{index-Yp36heK8.mjs → index-DV5Jd7Qe.mjs} +31 -31
- package/lib/chunks/index-DV5Jd7Qe.mjs.map +1 -0
- package/lib/chunks/{index-qxvk-6P6.mjs → index-DdOEWhrk.mjs} +33 -33
- package/lib/chunks/index-DdOEWhrk.mjs.map +1 -0
- package/lib/chunks/{index-w0tt7Myw.mjs → index-DmepcY31.mjs} +2 -2
- package/lib/chunks/{index-w0tt7Myw.mjs.map → index-DmepcY31.mjs.map} +1 -1
- package/lib/chunks/index-U3w45GW8.mjs +299 -0
- package/lib/chunks/index-U3w45GW8.mjs.map +1 -0
- package/lib/chunks/{index-BsSx9pGx.mjs → index-r3q2xCCI.mjs} +37 -36
- package/lib/chunks/index-r3q2xCCI.mjs.map +1 -0
- package/lib/chunks/{index-BEolw_uv.mjs → index-zEVVgWCH.mjs} +2 -2
- package/lib/chunks/{index-BEolw_uv.mjs.map → index-zEVVgWCH.mjs.map} +1 -1
- package/lib/chunks/{useShikiHighlight-DtWg9b8y.mjs → useShikiHighlight-DzEAK0S7.mjs} +7 -7
- package/lib/chunks/{useShikiHighlight-DtWg9b8y.mjs.map → useShikiHighlight-DzEAK0S7.mjs.map} +1 -1
- package/lib/index.cjs +20 -33
- package/lib/index.cjs.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.mjs +7 -7
- package/lib/renderers/Csv/index.d.ts.map +1 -1
- package/lib/renderers/Docx/index.d.ts.map +1 -1
- package/lib/renderers/Epub/index.d.ts.map +1 -1
- package/lib/renderers/Json/index.d.ts.map +1 -1
- package/lib/renderers/Markdown/index.d.ts.map +1 -1
- package/lib/renderers/Mobi/index.d.ts.map +1 -1
- package/lib/renderers/Msg/index.d.ts.map +1 -1
- package/lib/renderers/Pptx/index.d.ts.map +1 -1
- package/lib/renderers/Subtitle/index.d.ts.map +1 -1
- package/lib/renderers/Text/index.d.ts.map +1 -1
- package/lib/renderers/Xlsx/index.d.ts.map +1 -1
- package/lib/renderers/Xml/index.d.ts.map +1 -1
- package/lib/renderers/Zip/index.d.ts.map +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/lib/chunks/index--zZy1XpK.mjs +0 -299
- package/lib/chunks/index--zZy1XpK.mjs.map +0 -1
- package/lib/chunks/index-B5tBeF0g.mjs +0 -51
- package/lib/chunks/index-B5tBeF0g.mjs.map +0 -1
- package/lib/chunks/index-BIg3vHQf.mjs.map +0 -1
- package/lib/chunks/index-BOEtlHD3.mjs.map +0 -1
- package/lib/chunks/index-BWbuffRN.mjs.map +0 -1
- package/lib/chunks/index-BsSx9pGx.mjs.map +0 -1
- package/lib/chunks/index-CQABwGVP.mjs.map +0 -1
- package/lib/chunks/index-DTH1IvOG.mjs.map +0 -1
- package/lib/chunks/index-D_8IHm6o.mjs.map +0 -1
- package/lib/chunks/index-LNXbKjrI.mjs.map +0 -1
- package/lib/chunks/index-Yp36heK8.mjs.map +0 -1
- package/lib/chunks/index-qxvk-6P6.mjs.map +0 -1
- package/lib/chunks/index-xTq9b3vw.mjs.map +0 -1
- package/lib/chunks/index-zDEwNk3h.mjs.map +0 -1
- package/lib/chunks/xspreadsheet-CyBXARuf.mjs +0 -5215
- package/lib/chunks/xspreadsheet-CyBXARuf.mjs.map +0 -1
package/lib/index.cjs
CHANGED
|
@@ -1,41 +1,28 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`&&(
|
|
3
|
-
`){
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),mr=require("react-dom"),re=require("framer-motion"),_=require("lucide-react"),ve=require("react-pdf"),Or=require("mammoth"),Hr=require("exceljs"),hr=require("x-data-spreadsheet"),He=require("pptx-preview"),Ar=require("@kenjiuno/msgreader"),Br=require("@likecoin/epub-ts");require("foliate-js/view.js");const qr=require("video.js"),Ur=require("react-markdown"),Gr=require("remark-gfm"),Vr=require("remark-math"),Xr=require("rehype-katex"),Zr=require("rehype-raw");require("katex/dist/katex.min.css");const Jr=require("jszip"),Yr=require("shiki"),Kr="1.3.9",Qr={version:Kr};function et(r){try{const t=new URL(r).pathname.split("/").pop()||"file";return decodeURIComponent(t)}catch{const t=r.split("/").pop()||"file";return decodeURIComponent(t)}}function Ee(r){var t;const n=((t=r.split(".").pop())==null?void 0:t.toLowerCase())||"";return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp",ico:"image/x-icon",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska",m4v:"video/x-m4v","3gp":"video/3gpp",flv:"video/x-flv",mp3:"audio/mpeg",wav:"audio/wav",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ppt:"application/vnd.ms-powerpoint",msg:"application/vnd.ms-outlook",mobi:"application/x-mobipocket-ebook",azw:"application/vnd.amazon.ebook",azw3:"application/vnd.amazon.ebook",kf8:"application/vnd.amazon.ebook",txt:"text/plain",md:"text/markdown",markdown:"text/markdown",json:"application/json",xml:"application/xml",html:"text/html",css:"text/css",js:"text/javascript",ts:"text/typescript",jsx:"text/javascript",tsx:"text/typescript",py:"text/x-python",java:"text/x-java",cpp:"text/x-c++src",c:"text/x-csrc",cs:"text/x-csharp",php:"text/x-php",rb:"text/x-ruby",go:"text/x-go",rs:"text/x-rust",yaml:"text/yaml",yml:"text/yaml",toml:"text/toml",ini:"text/plain",env:"text/plain",diff:"text/x-diff",patch:"text/x-diff",log:"text/plain",csv:"text/csv",tsv:"text/tab-separated-values",srt:"application/x-subrip",vtt:"text/vtt",zip:"application/zip"}[n]||"application/octet-stream"}function xr(r,t=0){if(r instanceof File)return{id:`file-${Date.now()}-${t}`,name:r.name,url:URL.createObjectURL(r),type:r.type||Ee(r.name),size:r.size};if(typeof r=="string"){const n=et(r);return{id:`url-${Date.now()}-${t}`,name:n,url:r,type:Ee(n)}}return{id:r.id||`link-${Date.now()}-${t}`,name:r.name,url:r.url,type:r.type||Ee(r.name),size:r.size}}function br(r){return r.map((t,n)=>xr(t,n))}function gr(r){var t;const n=((t=r.name.split(".").pop())==null?void 0:t.toLowerCase())||"",a=r.type.toLowerCase();if(a.startsWith("image/")||["jpg","jpeg","png","gif","webp","svg"].includes(n))return"image";if(a.includes("pdf")||n==="pdf")return"pdf";if(a.includes("wordprocessingml")||n==="docx")return"docx";if(a.includes("spreadsheetml")||n==="xlsx")return"xlsx";if(a.includes("presentationml")||n==="pptx"||n==="ppt")return"pptx";if(a.includes("ms-outlook")||n==="msg")return"msg";if(a.includes("epub")||n==="epub")return"epub";if(["mobi","azw","azw3","kf8"].includes(n)||a==="application/x-mobipocket-ebook"||a==="application/vnd.amazon.ebook")return"mobi";if(["csv","tsv"].includes(n)||a==="text/csv"||a==="text/tab-separated-values")return"csv";if(n==="xml"||a==="application/xml"||a==="text/xml")return"xml";if(["srt","vtt","lrc","elrc","ass","ssa","ttml","dfxp"].includes(n)||a==="text/vtt"||a==="application/x-subrip"||a==="application/ttml+xml")return"subtitle";if(n==="zip"||a==="application/zip"||a==="application/x-zip-compressed")return"zip";if(a.startsWith("video/")||["mp4","webm","ogg","ogv","mov","avi","mkv","m4v","3gp","flv"].includes(n))return"video";if(a.startsWith("audio/")||["mp3","wav","ogg","m4a","flac","aac"].includes(n))return"audio";if(n==="md"||n==="markdown")return"markdown";if(a==="application/json"||n==="json")return"json";const o=["txt","log","lock","js","jsx","ts","tsx","py","java","cpp","c","h","cs","php","rb","go","mod","rs","swift","kt","lua","vim","html","css","scss","sass","less","yaml","yml","toml","ini","conf","env","diff","patch","sh","bash","zsh","sql"];return a.startsWith("text/")||o.includes(n)?"text":"unsupported"}function rt(r){var t;const n=((t=r.split(".").pop())==null?void 0:t.toLowerCase())||"";return{js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",java:"java",cpp:"cpp",c:"c",cs:"csharp",php:"php",rb:"ruby",go:"go",mod:"go",rs:"rust",swift:"swift",kt:"kotlin",lua:"lua",vim:"vim",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",json:"json",xml:"xml",html:"html",css:"css",scss:"scss",sass:"sass",less:"less",sql:"sql",yaml:"yaml",yml:"yaml",toml:"toml",ini:"ini",env:"bash",conf:"nginx",diff:"diff",patch:"diff",log:"log",md:"markdown",txt:"text"}[n]||"text"}function yr(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function tt(r){var t;return(((t=r.split(".").pop())==null?void 0:t.toLowerCase())||"")==="tsv"?" ":","}function st(r,t={}){const n=t.delimiter??",",a=t.firstRowAsHeader??!0,o=[];let i=[],p="",l=!1,f=0;const u=r.length;for(;f<u;){const h=r[f];if(l){if(h==='"'){if(r[f+1]==='"'){p+='"',f+=2;continue}l=!1,f+=1;continue}p+=h,f+=1;continue}if(h==='"'){l=!0,f+=1;continue}if(h===n){i.push(p),p="",f+=1;continue}if(h==="\r"){r[f+1]===`
|
|
2
|
+
`&&(f+=1),i.push(p),o.push(i),i=[],p="",f+=1;continue}if(h===`
|
|
3
|
+
`){i.push(p),o.push(i),i=[],p="",f+=1;continue}p+=h,f+=1}for((p.length>0||i.length>0)&&(i.push(p),o.push(i));o.length>0;){const h=o[o.length-1];if(h.length===1&&h[0]==="")o.pop();else break}let d=[],c=o;a&&o.length>0&&(d=o[0],c=o.slice(1));const m=Math.max(d.length,...c.map(h=>h.length),0);for(const h of c)for(;h.length<m;)h.push("");return{header:d,rows:c,columnCount:m,delimiter:n}}function nt(r){const t=r instanceof Uint8Array?r:new Uint8Array(r);if(t.length>=3&&t[0]===239&&t[1]===187&&t[2]===191)return new TextDecoder("utf-8").decode(t);if(t.length>=2&&t[0]===255&&t[1]===254)return new TextDecoder("utf-16le").decode(t);if(t.length>=2&&t[0]===254&&t[1]===255)return new TextDecoder("utf-16be").decode(t);try{return new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{}try{return new TextDecoder("gbk").decode(t)}catch{}return new TextDecoder("utf-8",{fatal:!1}).decode(t)}async function Me(r,t){const n=!!t&&("fetcher"in t||"init"in t),a=n?t.fetcher??fetch:fetch,o=n?t.init:t,i=await a(r,o);if(!i.ok)throw new Error(`请求失败: ${i.status}`);const p=await i.arrayBuffer();return nt(p)}async function ot(r,t){if(r)return typeof r=="function"?await r(t):r}function at(r,t){if(!r&&!t)return;if(!r)return t;if(!t)return r;const n=new Headers(r.headers||{});return t.headers&&new Headers(t.headers).forEach((a,o)=>{n.set(o,a)}),{...r,...t,headers:n}}function it(r){const t=(r==null?void 0:r.requestHandler)??((a,o)=>fetch(a,o)),n=r==null?void 0:r.requestInit;return async(a,o)=>{const i=await ot(n,a),p=at(i,o);return t(a,p)}}async function lt(r,t=fetch,n){const a=await t(r,n);if(!a.ok)throw new Error(`请求失败: ${a.status}`);const o=await a.blob();return URL.createObjectURL(o)}async function ft(r,t,n=fetch,a){const o=await n(r,a);if(!o.ok)throw new Error(`请求失败: ${o.status}`);const i=await o.blob(),p=URL.createObjectURL(i);try{const l=document.createElement("a");l.href=p,l.download=t,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l)}finally{setTimeout(()=>URL.revokeObjectURL(p),1e3)}}function or(r){const t=r.trim().replace(",","."),n=t.split(":").map(a=>a.trim());if(n.length===3){const[a,o,i]=n;return Number(a)*3600+Number(o)*60+Number(i)}if(n.length===2){const[a,o]=n;return Number(a)*60+Number(o)}return Number(t)||0}function ze(r){if(!isFinite(r)||r<0)return"00:00:00.000";const t=Math.floor(r*1e3),n=t%1e3,a=Math.floor(t/1e3)%60,o=Math.floor(t/6e4)%60,i=Math.floor(t/36e5),p=(l,f=2)=>l.toString().padStart(f,"0");return`${p(i)}:${p(o)}:${p(a)}.${p(n,3)}`}const ar=/(\d{1,2}:)?\d{1,2}:\d{1,2}[.,]\d{1,3}\s*-->\s*(\d{1,2}:)?\d{1,2}:\d{1,2}[.,]\d{1,3}/,ct=/^\s*\[\d{1,2}:\d{1,2}(?:[.:]\d{1,3})?\]/;function pt(r){const t=r.replace(/^\uFEFF/,"").trimStart();return/^WEBVTT/.test(t)?"vtt":/^<\?xml/i.test(t)||/<tt\b[^>]*>/i.test(t)?"ttml":/^\[Script Info\]/im.test(t)||/^Dialogue:/m.test(t)?/ScriptType:\s*v4\.00\s*$/im.test(t)?"ssa":"ass":ct.test(t)||/^\[(ti|ar|al|au|by|length|offset|re|ve):/im.test(t)?/<\d{1,2}:\d{1,2}(?:[.:]\d{1,3})?>/.test(t)?"elrc":"lrc":"srt"}function ir(r,t){const n=r.replace(/\r\n?/g,`
|
|
4
4
|
`).replace(/^\uFEFF/,"").split(`
|
|
5
|
-
`),
|
|
6
|
-
`);n
|
|
7
|
-
`)})}return{format:
|
|
5
|
+
`),a=[];let o,i=0;if(t==="vtt"){const p=[];for(;i<n.length&&n[i].trim()!=="";)p.push(n[i]),i++;for(o=p.join(`
|
|
6
|
+
`);i<n.length&&n[i].trim()==="";)i++}for(;i<n.length;){for(;i<n.length&&n[i].trim()==="";)i++;if(i>=n.length)break;let p,l=null;if(ar.test(n[i]))l=n[i],i++;else if(p=n[i].trim()||void 0,i++,i<n.length&&ar.test(n[i]))l=n[i],i++;else continue;if(!l)continue;const f=l.match(/([\d:.,]+)\s*-->\s*([\d:.,]+)/);if(!f)continue;const u=or(f[1]),d=or(f[2]),c=[];for(;i<n.length&&n[i].trim()!=="";)c.push(n[i]),i++;a.push({id:p,start:u,end:d,text:c.join(`
|
|
7
|
+
`)})}return{format:t,cues:a,header:o}}function Ue(r,t,n){const a=Number(r),o=Number(t);let i=0;if(n){const p=(n+"000").slice(0,3);i=Number(p)}return a*60+o+i/1e3}function wr(r,t){const n=/^\[(ti|ar|al|au|by|length|offset|re|ve):(.*)\]$/i.exec(r.trim());if(!n)return!1;const a=n[1].toLowerCase(),o=n[2].trim();if(t.metadata[a]=o,a==="offset"){const i=Number(o);isNaN(i)||(t.offsetMs=i)}return!0}function dt(r){const t=r.replace(/\r\n?/g,`
|
|
8
8
|
`).replace(/^\uFEFF/,"").split(`
|
|
9
|
-
`),
|
|
9
|
+
`),n={metadata:{},offsetMs:0},a=/\[(\d{1,2}):(\d{1,2})(?:[.:](\d{1,3}))?\]/g,o=[];for(const p of t){const l=p.trim();if(!l||wr(l,n))continue;const f=[];let u=0;a.lastIndex=0;let d;for(;(d=a.exec(l))!==null&&d.index===u;)f.push(Ue(d[1],d[2],d[3])),u=d.index+d[0].length;if(f.length===0)continue;const c=l.slice(u).trim();for(const m of f)o.push({start:m,text:c})}o.sort((p,l)=>p.start-l.start);const i=n.offsetMs/1e3;return{format:"lrc",cues:o.map((p,l)=>{const f=Math.max(0,p.start-i),u=o[l+1],d=u?Math.max(f,u.start-i):f+5;return{start:f,end:d,text:p.text}}),metadata:n.metadata}}function ut(r){const t=r.replace(/\r\n?/g,`
|
|
10
10
|
`).replace(/^\uFEFF/,"").split(`
|
|
11
|
-
`),
|
|
11
|
+
`),n={metadata:{},offsetMs:0},a=/\[(\d{1,2}):(\d{1,2})(?:[.:](\d{1,3}))?\]/g,o=/<(\d{1,2}):(\d{1,2})(?:[.:](\d{1,3}))?>/g,i=[];for(const l of t){const f=l.trim();if(!f||wr(f,n))continue;const u=[];let d=0;a.lastIndex=0;let c;for(;(c=a.exec(f))!==null&&c.index===d;)u.push(Ue(c[1],c[2],c[3])),d=c.index+c[0].length;if(u.length===0)continue;const m=f.slice(d);for(const h of u)i.push({start:h,raw:m})}i.sort((l,f)=>l.start-f.start);const p=n.offsetMs/1e3;return{format:"elrc",cues:i.map((l,f)=>{const u=[];let d="",c=0,m=null;o.lastIndex=0;let h;for(;(h=o.exec(l.raw))!==null;){const g=l.raw.slice(c,h.index);m!==null&&g&&u.push({start:Math.max(0,m-p),text:g}),d+=g,m=Ue(h[1],h[2],h[3]),c=h.index+h[0].length}const y=l.raw.slice(c);m!==null&&y&&u.push({start:Math.max(0,m-p),text:y}),d+=y;const x=Math.max(0,l.start-p),w=i[f+1],b=w?Math.max(x,w.start-p):x+5;return{start:x,end:b,text:d.trim(),words:u.length?u:void 0}}),metadata:n.metadata}}function lr(r){const t=r.trim().split(":");return t.length!==3?0:Number(t[0])*3600+Number(t[1])*60+Number(t[2].replace(",","."))}function fr(r,t){const n=r.replace(/\r\n?/g,`
|
|
12
12
|
`).replace(/^\uFEFF/,"").split(`
|
|
13
|
-
`);let
|
|
13
|
+
`);let a="",o=[];const i=[],p=[];for(const l of n){const f=l.replace(/\s+$/,""),u=f.trim(),d=/^\[([^\]]+)\]\s*$/.exec(u);if(d){a=d[1].toLowerCase(),p.push(f);continue}if(a!=="events"){p.push(f);continue}const c=/^Format:\s*(.+)$/i.exec(u);if(c){o=c[1].split(",").map(S=>S.trim());continue}const m=/^(Dialogue|Comment):\s*(.+)$/i.exec(u);if(!m||m[1].toLowerCase()==="comment"||o.length===0)continue;const h=o.length,y=m[2].split(","),x=y.slice(0,h-1),w=y.slice(h-1).join(","),b={};o.forEach((S,M)=>{b[S]=M===h-1?w:x[M]??""});const g=lr(b.Start||""),v=lr(b.End||""),k=(b.Text||"").replace(/\\N/g,`
|
|
14
14
|
`).replace(/\\n/g,`
|
|
15
|
-
`).replace(/\\h/g," ").replace(/\{[^}]*\}/g,"");
|
|
16
|
-
`).trim()||void 0}}function
|
|
17
|
-
`:
|
|
18
|
-
`).trim();(u||f||d)&&s.push({start:f,end:d,text:u})}return s.sort((i,n)=>i.start-n.start),{format:"ttml",cues:s}}function mi(r,e){switch(e??di(r)){case"lrc":return hi(r);case"elrc":return pi(r);case"ass":return kr(r,"ass");case"ssa":return kr(r,"ssa");case"ttml":return ui(r);case"vtt":return yr(r,"vtt");case"srt":default:return yr(r,"srt")}}async function gi(r){return ti.loadAsync(r)}function xi(r){const e=[];return r.forEach((t,s)=>{var i;const n=s.dir,l=n&&!t.endsWith("/")?t+"/":t,a=n?l.replace(/\/$/,""):l,c=a.lastIndexOf("/"),f=c>=0?a.slice(c+1):a,d=c>=0?a.slice(0,c):"",h=n?0:((i=s._data)==null?void 0:i.uncompressedSize)??0;e.push({path:l,name:f,dir:d,isDir:n,size:h,date:s.date})}),e}function bi(r){const e={name:"",path:"",isDir:!0,children:[],size:0},t=new Map;t.set("",e);const s=n=>{if(t.has(n))return t.get(n);const l=n.split("/").filter(Boolean);let a=e,c="";for(const f of l){c=c?`${c}/${f}`:f;let d=t.get(c);d||(d={name:f,path:c+"/",isDir:!0,children:[],size:0},a.children.push(d),t.set(c,d)),a=d}return a};for(const n of r){if(n.isDir){s(n.path.replace(/\/$/,""));continue}s(n.dir).children.push({name:n.name,path:n.path,isDir:!1,size:n.size})}const i=n=>{if(n.children){n.children.sort((l,a)=>l.isDir!==a.isDir?l.isDir?-1:1:l.name.localeCompare(a.name));for(const l of n.children)i(l)}};return i(e),e}async function wi(r,e,t){const s=r.file(e);if(!s)throw new Error(`ZIP entry not found: ${e}`);const i=await s.async("arraybuffer");return new Blob([i],t?{type:t}:void 0)}function vi(r){return r?r.startsWith("#")?r:r.length===8?"#"+r.substring(2):r.length===6?"#"+r:"#000000":"#000000"}const yi=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],ji=["000000","FFFFFF","FF0000","00FF00","0000FF","FFFF00","FF00FF","00FFFF","000000","FFFFFF","FF0000","00FF00","0000FF","FFFF00","FF00FF","00FFFF","800000","008000","000080","808000","800080","008080","C0C0C0","808080","9999FF","993366","FFFFCC","CCFFFF","660066","FF8080","0066CC","CCCCFF","000080","FF00FF","FFFF00","00FFFF","800080","800000","008080","0000FF","00CCFF","CCFFFF","CCFFCC","FFFF99","99CCFF","FF99CC","CC99FF","FFCC99","3366FF","33CCCC","99CC00","FFCC00","FF9900","FF6600","666699","969696","003366","339966","003300","333300","993300","993366","333399","333333"];function ki(r,e){const t=parseInt(r.substring(0,2),16),s=parseInt(r.substring(2,4),16),i=parseInt(r.substring(4,6),16),n=f=>e<0?Math.round(f*(1+e)):Math.round(f+(255-f)*e),l=Math.min(255,Math.max(0,n(t))),a=Math.min(255,Math.max(0,n(s))),c=Math.min(255,Math.max(0,n(i)));return l.toString(16).padStart(2,"0")+a.toString(16).padStart(2,"0")+c.toString(16).padStart(2,"0")}function Si(r){if(r&&r.type==="pattern"&&r.pattern==="solid"){const e=r.fgColor;if(e)return Kt(e)}}function Kt(r){if(r){if("argb"in r&&typeof r.argb=="string"&&r.argb)return vi(r.argb);if("theme"in r&&typeof r.theme=="number"){const e=yi[r.theme]||"000000",t="tint"in r&&typeof r.tint=="number"?r.tint:0;return"#"+(t!==0?ki(e,t):e)}if("indexed"in r&&typeof r.indexed=="number"){const e=ji[r.indexed];if(e)return"#"+e}}}function Ci(r){if(!r||!r.style)return;const e=Kt(r.color)||"#000000";return[r.style,e]}function Ni(r){const e={};let t=!1;if(r.font){const i=r.font;if((i.name||i.size||i.bold||i.italic)&&(t=!0,e.font={},i.name&&(e.font.name=i.name),i.size&&(e.font.size=i.size),i.bold&&(e.font.bold=!0),i.italic&&(e.font.italic=!0)),i.color){const n=Kt(i.color);n&&(t=!0,e.color=n)}i.underline&&(t=!0,e.underline=!0),i.strike&&(t=!0,e.strike=!0)}const s=Si(r.fill);if(s&&(t=!0,e.bgcolor=s),r.alignment){const i=r.alignment;i.horizontal&&(t=!0,e.align=i.horizontal),i.vertical&&(t=!0,e.valign=i.vertical),i.wrapText&&(t=!0,e.textwrap=!0)}if(r.border){const i={};let n=!1;const l=["top","bottom","left","right"];for(const a of l){const c=Ci(r.border[a]);c&&(i[a]=c,n=!0)}n&&(t=!0,e.border=i)}return t?e:null}function Ei(r){return JSON.stringify(r)}function Ti(r,e,t){const s=Ni(r);if(!s)return-1;const i=Ei(s),n=t.get(i);if(n!==void 0)return n;const l=e.length;return e.push(s),t.set(i,l),l}function Ri(r){const e=r.value;if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(typeof e=="boolean")return e?"TRUE":"FALSE";if(e instanceof Date)return e.toLocaleDateString();if(typeof e=="object"&&"formula"in e){const t=e.result;return t!=null?String(t):""}return typeof e=="object"&&"richText"in e?e.richText.map(t=>t.text).join(""):typeof e=="object"&&"hyperlink"in e?e.text||"":typeof e=="object"&&"error"in e?String(e.error):String(e)}function $i(r){const e=r.split(":"),t=Sr(e[0]),s=e[1]?Sr(e[1]):t;return{top:t.row,left:t.col,bottom:s.row,right:s.col}}function Sr(r){const e=r.match(/^([A-Z]+)(\d+)$/);if(!e)return{row:1,col:1};const t=e[1],s=parseInt(e[2],10);let i=0;for(let n=0;n<t.length;n++)i=i*26+(t.charCodeAt(n)-64);return{row:s,col:i}}function Mi(r){const e=[];return r.eachSheet(t=>{const s=[],i=new Map,n=[],l={},a={},c=t.columnCount;for(let u=1;u<=c;u++){const m=t.getColumn(u);m.width&&(a[String(u-1)]={width:Math.round(m.width*7.5)})}a.len=Math.max(c,26);const f=new Map,d=t.model,h=(d==null?void 0:d.merges)||[];for(const u of h){n.push(u);const{top:m,left:g,bottom:x,right:v}=$i(u),b=x-m,y=v-g;f.set(`${m-1},${g-1}`,[b,y])}t.eachRow({includeEmpty:!0},(u,m)=>{const g=m-1,x={};u.eachCell({includeEmpty:!1},(b,y)=>{const j=y-1;if(b.isMerged&&b.master!==b)return;const k=Ri(b),N=Ti(b,s,i),M={text:k};N!==-1&&(M.style=N);const z=`${g},${j}`;f.has(z)&&(M.merge=f.get(z)),x[String(j)]=M});const v={cells:x};u.height&&(v.height=Math.round(u.height*1.333)),l[String(g)]=v}),e.push({name:t.name,styles:s,merges:n,rows:l,cols:a})}),e}function Fi(r,e,t="Sheet1"){const s=r.length>0,i=s?[{font:{bold:!0}}]:[],n={};if(s){const a={};r.forEach((c,f)=>{a[String(f)]={text:c,style:0}}),n[0]={cells:a}}const l=s?1:0;return e.forEach((a,c)=>{const f={};a.forEach((d,h)=>{d!==void 0&&d!==""&&(f[String(h)]={text:d})}),n[String(c+l)]={cells:f}}),[{name:t,styles:i,rows:n}]}const zi={"common.download":"下载","common.close":"关闭","common.loading":"加载中","common.unknown_error":"未知错误","common.unsupported_preview":"不支持预览此文件类型 ({type})","toolbar.zoom_in":"放大","toolbar.zoom_out":"缩小","toolbar.rotate_left":"向左旋转","toolbar.rotate_right":"向右旋转","toolbar.reset":"复原","toolbar.fit_to_window":"适应窗口","toolbar.original_size":"原始尺寸","toolbar.toc":"目录","toolbar.prev_page":"上一页","toolbar.next_page":"下一页","toolbar.full_width":"全屏宽度","toolbar.normal_width":"正常宽度","toolbar.wrap_on":"自动换行","toolbar.wrap_off":"不换行","toolbar.source":"源码","toolbar.preview":"预览","image.load_failed":"图片加载失败","pdf.load_failed":"PDF 文件加载失败","docx.parse_failed":"Word 文档解析失败","xlsx.loading":"加载 Excel 中...","xlsx.load_failed":"Excel 加载失败","xlsx.parse_failed":"Excel 文件解析失败","xlsx.not_found":"Excel 文件不存在","pptx.loading":"加载 PPT 中...","pptx.load_failed":"PPT 加载失败","pptx.parse_failed":"PPT 文件解析失败","pptx.not_found":"PPT 文件不存在","pptx.invalid_format":"PPT 文件格式错误或已损坏","pptx.no_pages":"PPT 文件无有效页面","pptx.timeout":"加载超时,请检查网络或稍后重试","msg.parse_failed":"Outlook 邮件解析失败","msg.parse_failed_short":"邮件解析失败","msg.empty_body":"(无邮件正文)","epub.load_failed":"EPUB 文件加载失败","mobi.load_failed":"电子书加载失败,文件可能已损坏或带有 DRM 保护","video.loading":"加载视频中...","video.load_failed":"视频加载失败","video.load_failed_with_error":"视频加载失败: {error}","audio.aria.play":"播放","audio.aria.pause":"暂停","audio.aria.forward_10":"前进 10 秒","audio.aria.backward_10":"后退 10 秒","audio.aria.mute":"静音","audio.aria.unmute":"取消静音","audio.aria.loop_on":"开启循环","audio.aria.loop_off":"关闭循环","audio.aria.progress":"播放进度","audio.aria.volume":"音量","markdown.load_failed":"Markdown 文件加载失败","markdown.copy_code":"复制代码","markdown.copied":"已复制","json.load_failed":"JSON 文件加载失败","json.items":"items","json.keys":"keys","csv.loading":"加载 CSV 中...","csv.load_failed":"CSV 文件加载失败","csv.parse_failed":"CSV 解析失败","xml.load_failed":"XML 文件加载失败","subtitle.load_failed":"字幕文件加载失败","subtitle.parse_failed":"字幕解析失败","subtitle.lines":"lines","subtitle.cues":"cues","subtitle.meta.title":"标题","subtitle.meta.artist":"艺术家","subtitle.meta.album":"专辑","subtitle.meta.author":"作者","subtitle.meta.by":"制作","subtitle.meta.length":"时长","subtitle.meta.offset":"偏移","subtitle.meta.editor":"编辑器","subtitle.meta.version":"版本","zip.load_failed":"ZIP 文件加载失败","zip.parse_failed":"ZIP 解析失败","text.load_failed":"文本文件加载失败"},_i={"common.download":"Download","common.close":"Close","common.loading":"Loading","common.unknown_error":"Unknown error","common.unsupported_preview":"Preview not supported for this file type ({type})","toolbar.zoom_in":"Zoom in","toolbar.zoom_out":"Zoom out","toolbar.rotate_left":"Rotate left","toolbar.rotate_right":"Rotate right","toolbar.reset":"Reset","toolbar.fit_to_window":"Fit to window","toolbar.original_size":"Original size","toolbar.toc":"Table of contents","toolbar.prev_page":"Previous page","toolbar.next_page":"Next page","toolbar.full_width":"Full width","toolbar.normal_width":"Normal width","toolbar.wrap_on":"Word wrap","toolbar.wrap_off":"No wrap","toolbar.source":"Source","toolbar.preview":"Preview","image.load_failed":"Failed to load image","pdf.load_failed":"Failed to load PDF","docx.parse_failed":"Failed to parse Word document","xlsx.loading":"Loading Excel...","xlsx.load_failed":"Failed to load Excel","xlsx.parse_failed":"Failed to parse Excel file","xlsx.not_found":"Excel file not found","pptx.loading":"Loading PPT...","pptx.load_failed":"Failed to load PPT","pptx.parse_failed":"Failed to parse PPT file","pptx.not_found":"PPT file not found","pptx.invalid_format":"PPT file format is invalid or corrupted","pptx.no_pages":"PPT file has no valid pages","pptx.timeout":"Loading timed out, please check your network and retry","msg.parse_failed":"Failed to parse Outlook message","msg.parse_failed_short":"Failed to parse message","msg.empty_body":"(No message body)","epub.load_failed":"Failed to load EPUB","mobi.load_failed":"Failed to load ebook — file may be corrupted or DRM-protected","video.loading":"Loading video...","video.load_failed":"Failed to load video","video.load_failed_with_error":"Failed to load video: {error}","audio.aria.play":"Play","audio.aria.pause":"Pause","audio.aria.forward_10":"Forward 10 seconds","audio.aria.backward_10":"Back 10 seconds","audio.aria.mute":"Mute","audio.aria.unmute":"Unmute","audio.aria.loop_on":"Enable loop","audio.aria.loop_off":"Disable loop","audio.aria.progress":"Playback progress","audio.aria.volume":"Volume","markdown.load_failed":"Failed to load Markdown","markdown.copy_code":"Copy code","markdown.copied":"Copied","json.load_failed":"Failed to load JSON","json.items":"items","json.keys":"keys","csv.loading":"Loading CSV...","csv.load_failed":"Failed to load CSV","csv.parse_failed":"Failed to parse CSV","xml.load_failed":"Failed to load XML","subtitle.load_failed":"Failed to load subtitle","subtitle.parse_failed":"Failed to parse subtitle","subtitle.lines":"lines","subtitle.cues":"cues","subtitle.meta.title":"Title","subtitle.meta.artist":"Artist","subtitle.meta.album":"Album","subtitle.meta.author":"Author","subtitle.meta.by":"By","subtitle.meta.length":"Length","subtitle.meta.offset":"Offset","subtitle.meta.editor":"Editor","subtitle.meta.version":"Version","zip.load_failed":"Failed to load ZIP","zip.parse_failed":"Failed to parse ZIP","text.load_failed":"Failed to load text file"},pt={"zh-CN":zi,"en-US":_i},Di=/\{(\w+)\}/g;function Pi(r,e){return e?r.replace(Di,(t,s)=>{const i=e[s];return i===void 0?`{${s}}`:String(i)}):r}function Qt(r){var e;const t=r.fallbackLocale??"zh-CN",s=pt[r.locale]??pt[t]??pt["zh-CN"],i=(e=r.messages)==null?void 0:e[r.locale],n=i?{...s,...i}:s,l=pt["zh-CN"];return(a,c)=>{const f=n[a]??l[a]??a;return Pi(f,c)}}const er=p.createContext(null),os=({locale:r="zh-CN",messages:e,children:t})=>{const s=p.useMemo(()=>{const i=Qt({locale:r,messages:e});return{locale:r,t:i}},[r,e]);return o.jsx(er.Provider,{value:s,children:t})};let Dt=null;function Oi(){return Dt||(Dt=Qt({locale:"zh-CN"})),Dt}function Q(){const r=p.useContext(er);return(r==null?void 0:r.t)??Oi()}function Li(){const r=p.useContext(er);return(r==null?void 0:r.locale)??"zh-CN"}const as=p.createContext(null),Ii=({theme:r,children:e})=>o.jsx(as.Provider,{value:r,children:e});function cs(){return p.useContext(as)??"dark"}const Ai=({className:r})=>o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:r,children:o.jsx("text",{x:"12",y:"17.5",textAnchor:"middle",fontSize:"20",fontWeight:"bold",fill:"currentColor",stroke:"none",children:"1:1"})});function Hi(r){return[{items:[{type:"button",icon:o.jsx(T.ZoomOut,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.zoom_out"),action:r.onZoomOut,disabled:r.zoom<=.01},{type:"text",content:`${Math.round(r.zoom*100)}%`,minWidth:"3rem"},{type:"button",icon:o.jsx(T.ZoomIn,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.zoom_in"),action:r.onZoomIn,disabled:r.zoom>=10}]},{items:[{type:"button",icon:o.jsx(T.Scan,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.fit_to_window"),action:r.onFitToWidth},{type:"button",icon:o.jsx(Ai,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.original_size"),action:r.onOriginalSize}]},{items:[{type:"button",icon:o.jsx(T.RotateCcw,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.rotate_left"),action:r.onRotateLeft},{type:"button",icon:o.jsx(T.RotateCw,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.rotate_right"),action:r.onRotateRight}]},{items:[{type:"button",icon:o.jsx(T.RefreshCw,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.reset"),action:r.onReset}]}]}function Wi(r){return[{items:[{type:"button",icon:o.jsx(T.ZoomOut,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.zoom_out"),action:r.onZoomOut,disabled:r.zoom<=.01},{type:"text",content:`${Math.round(r.zoom*100)}%`,minWidth:"3rem"},{type:"button",icon:o.jsx(T.ZoomIn,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.zoom_in"),action:r.onZoomIn,disabled:r.zoom>=10}]},{items:[{type:"button",icon:o.jsx(T.RefreshCw,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.reset"),action:r.onReset}]}]}function Bi(r){return[{items:[{type:"button",icon:o.jsx(T.List,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.toc"),action:()=>{var e;return(e=r.epubRef.current)==null?void 0:e.toggleToc()}}]},{items:[{type:"button",icon:o.jsx(T.ChevronLeft,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.prev_page"),action:()=>{var e;return(e=r.epubRef.current)==null?void 0:e.prevPage()}},{type:"text",content:`${r.current} / ${r.total}`,minWidth:"4rem"},{type:"button",icon:o.jsx(T.ChevronRight,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.next_page"),action:()=>{var e;return(e=r.epubRef.current)==null?void 0:e.nextPage()}}]},{items:[{type:"button",icon:r.fullWidth?o.jsx(T.Minimize2,{className:"rfp-w-4 rfp-h-4"}):o.jsx(T.Maximize2,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.fullWidth?r.t("toolbar.normal_width"):r.t("toolbar.full_width"),action:()=>{var e;return(e=r.epubRef.current)==null?void 0:e.toggleFullWidth()}}]}]}function Vi(r){return[{items:[{type:"button",icon:o.jsx(T.List,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.toc"),action:()=>{var e;return(e=r.mobiRef.current)==null?void 0:e.toggleToc()}}]},{items:[{type:"button",icon:o.jsx(T.ChevronLeft,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.prev_page"),action:()=>{var e;return(e=r.mobiRef.current)==null?void 0:e.prevPage()}},{type:"text",content:`${r.current} / ${r.total}`,minWidth:"4rem"},{type:"button",icon:o.jsx(T.ChevronRight,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.next_page"),action:()=>{var e;return(e=r.mobiRef.current)==null?void 0:e.nextPage()}}]},{items:[{type:"button",icon:r.fullWidth?o.jsx(T.Minimize2,{className:"rfp-w-4 rfp-h-4"}):o.jsx(T.Maximize2,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.fullWidth?r.t("toolbar.normal_width"):r.t("toolbar.full_width"),action:()=>{var e;return(e=r.mobiRef.current)==null?void 0:e.toggleFullWidth()}}]}]}function qi({stats:r}){return r?[{items:[{type:"text",content:`${r.files} files · ${r.dirs} dirs · ${ns(r.size)}`,minWidth:"10rem"}]}]:[]}function Ui(r){const e=[{items:[{type:"button",icon:o.jsx(T.WrapText,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.wordWrap?r.t("toolbar.wrap_off"):r.t("toolbar.wrap_on"),action:r.onToggleWrap}]}];return r.isHtml&&e.push({items:[{type:"button",icon:r.htmlPreview?o.jsx(T.Code,{className:"rfp-w-4 rfp-h-4"}):o.jsx(T.Eye,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.htmlPreview?r.t("toolbar.source"):r.t("toolbar.preview"),action:r.onToggleHtmlPreview}]}),e}function Gi(r){return[{items:[{type:"button",icon:r.viewMode==="preview"?o.jsx(T.Code,{className:"rfp-w-4 rfp-h-4"}):o.jsx(T.Eye,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.viewMode==="preview"?r.t("toolbar.source"):r.t("toolbar.preview"),action:r.onToggleViewMode}]}]}const Xi=p.lazy(()=>Promise.resolve().then(()=>vn).then(r=>({default:r.ImageRenderer}))),Zi=p.lazy(()=>Promise.resolve().then(()=>jn).then(r=>({default:r.PdfRenderer}))),Yi=p.lazy(()=>Promise.resolve().then(()=>Nn).then(r=>({default:r.DocxRenderer}))),Ji=p.lazy(()=>Promise.resolve().then(()=>ra).then(r=>({default:r.XlsxRenderer}))),Ki=p.lazy(()=>Promise.resolve().then(()=>ia).then(r=>({default:r.PptxRenderer}))),Qi=p.lazy(()=>Promise.resolve().then(()=>aa).then(r=>({default:r.MsgRenderer}))),en=p.lazy(()=>Promise.resolve().then(()=>da).then(r=>({default:r.EpubRenderer}))),tn=p.lazy(()=>Promise.resolve().then(()=>ua).then(r=>({default:r.MobiRenderer}))),rn=p.lazy(()=>Promise.resolve().then(()=>xa).then(r=>({default:r.VideoRenderer}))),sn=p.lazy(()=>Promise.resolve().then(()=>ja).then(r=>({default:r.AudioRenderer}))),nn=p.lazy(()=>Promise.resolve().then(()=>Ea).then(r=>({default:r.MarkdownRenderer}))),ln=p.lazy(()=>Promise.resolve().then(()=>za).then(r=>({default:r.JsonRenderer}))),on=p.lazy(()=>Promise.resolve().then(()=>Da).then(r=>({default:r.CsvRenderer}))),an=p.lazy(()=>Promise.resolve().then(()=>Ia).then(r=>({default:r.XmlRenderer}))),cn=p.lazy(()=>Promise.resolve().then(()=>Ba).then(r=>({default:r.SubtitleRenderer}))),fn=p.lazy(()=>Promise.resolve().then(()=>Xa).then(r=>({default:r.ZipRenderer}))),dn=p.lazy(()=>Promise.resolve().then(()=>Ya).then(r=>({default:r.TextRenderer}))),Cr=({fileName:r,fileType:e,onDownload:t})=>{const s=Q();return o.jsxs("div",{className:"rfp-flex rfp-flex-col rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-p-8 rfp-gap-6",children:[o.jsx("div",{className:"rfp-w-32 rfp-h-32 rfp-rounded-full rfp-bg-surface-2 rfp-flex rfp-items-center rfp-justify-center",children:o.jsx(T.FileQuestion,{className:"rfp-w-16 rfp-h-16 rfp-text-fg-secondary"})}),o.jsxs("div",{className:"rfp-text-fg-primary rfp-text-center",children:[o.jsx("p",{className:"rfp-text-xl rfp-font-medium rfp-mb-2",children:r}),o.jsx("p",{className:"rfp-text-fg-secondary",children:s("common.unsupported_preview",{type:e})})]}),o.jsxs("button",{onClick:t,className:"rfp-flex rfp-items-center rfp-gap-2 rfp-px-6 rfp-py-3 rfp-bg-surface-2 hover:rfp-bg-surface-3 rfp-backdrop-blur-sm rfp-rounded-lg rfp-text-fg-primary rfp-font-medium rfp-transition-all",children:[o.jsx(T.Download,{className:"rfp-w-5 rfp-h-5"}),s("common.download")]})]})},hn=()=>{const r=Q();return o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-text-fg-muted",children:o.jsxs("div",{className:"rfp-flex rfp-flex-col rfp-items-center rfp-gap-3",children:[o.jsx("div",{className:"rfp-w-8 rfp-h-8 rfp-rounded-full rfp-border-2 rfp-border-fg-muted rfp-border-t-transparent rfp-animate-spin"}),o.jsx("span",{className:"rfp-text-sm",children:r("common.loading")??"Loading..."})]})})},pn=3,Rt=({files:r,currentIndex:e,onNavigate:t,customRenderers:s=[],mode:i="modal",onClose:n,zipNestingDepth:l=0,locale:a="zh-CN",messages:c,headless:f=!1,theme:d="dark",onCustomEvent:h})=>{const u=p.useMemo(()=>Qt({locale:a,messages:c}),[a,c]),[m,g]=p.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!0);p.useEffect(()=>{if(d!=="auto")return;const D=window.matchMedia("(prefers-color-scheme: dark)"),K=ve=>g(ve.matches);return D.addEventListener("change",K),()=>D.removeEventListener("change",K)},[d]);const x=d==="auto"?m?"dark":"light":d,[v,b]=p.useState(1),[y,j]=p.useState(0),[k,N]=p.useState(1),[,M]=p.useState(1),[z,P]=p.useState(0),[S,F]=p.useState(0),[L,V]=p.useState(0),H=p.useRef(null),U=p.useRef(null),E=p.useRef(null),[R,$]=p.useState(0),[G,q]=p.useState(0),[Y,_]=p.useState(!1),A=p.useRef(null),[B,ee]=p.useState(0),[X,ne]=p.useState(0),[re,$e]=p.useState(!1),[ie,je]=p.useState(null),[J,he]=p.useState(!0),[pe,Ne]=p.useState(!1),[ze,Be]=p.useState("preview"),[ke,Se]=p.useState(!0),ae=p.useRef(null),Ve=2e3,qe=p.useCallback(()=>{Se(!0),ae.current&&clearTimeout(ae.current),ae.current=window.setTimeout(()=>{Se(!1)},Ve)},[]),Ue=p.useCallback(()=>{qe()},[qe]),ue=p.useMemo(()=>ss(r),[r]),O=ue[e],Ge=p.useMemo(()=>O?s.find(D=>D.test(O)):null,[O,s]),Z=O?is(O):"unsupported",hr=p.useCallback((D,K)=>{O&&(h==null||h({name:D,payload:K,file:O}))},[O,h]),pr=p.useMemo(()=>({emit:hr,t:u,theme:x,locale:a}),[hr,u,x,a]);p.useEffect(()=>{b(1),j(0),N(1),M(1),P(0),F(0),Se(!0),ae.current&&clearTimeout(ae.current)},[e]),p.useEffect(()=>{if(Z==="image"&&z>0&&S>0&&H.current){const D=H.current.clientWidth,K=H.current.clientHeight,ve=D/z,ye=K/S,tt=Math.min(ve,ye);b(Math.max(.01,Math.min(10,tt)))}},[Z,z,S]),p.useEffect(()=>(ue.length>1&&qe(),()=>{ae.current&&clearTimeout(ae.current)}),[ue.length,qe]),p.useEffect(()=>{const D=K=>{K.key==="Escape"&&i==="modal"?n==null||n():K.key==="ArrowLeft"&&e>0?t==null||t(e-1):K.key==="ArrowRight"&&e<ue.length-1&&(t==null||t(e+1))};if(i==="modal")return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D);{const K=U.current;return K?(K.addEventListener("keydown",D),()=>K.removeEventListener("keydown",D)):void 0}},[i,e,ue.length,n,t]);const ur=p.useCallback(()=>{b(D=>Math.min(D+.1,10))},[]),mr=p.useCallback(()=>{b(D=>Math.max(D-.1,.01))},[]),Ps=p.useCallback(()=>{j(D=>D+90)},[]),Os=p.useCallback(()=>{j(D=>D-90)},[]),Ls=p.useCallback(()=>{if(H.current&&z>0&&S>0){const D=H.current.clientWidth,K=H.current.clientHeight,ve=D/z,ye=K/S,tt=Math.min(ve,ye);b(Math.max(.01,Math.min(10,tt)))}else b(1);j(0),V(D=>D+1)},[z,S]),Is=p.useCallback(()=>{b(1),j(0),V(D=>D+1)},[]),As=p.useCallback(D=>{b(D)},[]),gr=p.useCallback(()=>{b(1),j(0),V(D=>D+1)},[]),Ft=p.useCallback(()=>{if(!O)return;const D=document.createElement("a");D.href=O.url,D.download=O.name,D.click()},[O]),Hs=p.useCallback((D,K)=>{$(D),q(K)},[]),Ws=p.useCallback((D,K)=>{ee(D),ne(K)},[]),Bs=p.useCallback(D=>{je(D)},[]);if(!O)return null;const Vs=i==="modal"&&!!n,ft=(()=>{var D,K;if(Ge)return((D=Ge.getToolbarGroups)==null?void 0:D.call(Ge,O,pr))??[];if(Z==="image")return Hi({zoom:v,onZoomIn:ur,onZoomOut:mr,onFitToWidth:Ls,onOriginalSize:Is,onRotateLeft:Os,onRotateRight:Ps,onReset:gr,t:u});if(Z==="pdf")return Wi({zoom:v,onZoomIn:ur,onZoomOut:mr,onReset:gr,t:u});if(Z==="epub")return Bi({epubRef:E,current:R,total:G,fullWidth:Y,t:u});if(Z==="mobi")return Vi({mobiRef:A,current:B,total:X,fullWidth:re,t:u});if(Z==="zip")return qi({stats:ie});if(Z==="text"){const ve=((K=O.name.split(".").pop())==null?void 0:K.toLowerCase())||"";return Ui({wordWrap:J,onToggleWrap:()=>he(ye=>!ye),isHtml:ve==="html"||ve==="htm",htmlPreview:pe,onToggleHtmlPreview:()=>Ne(ye=>!ye),t:u})}return Z==="markdown"?Gi({viewMode:ze,onToggleViewMode:()=>Be(ve=>ve==="preview"?"source":"preview"),t:u}):[]})(),xr=[{items:[{type:"button",icon:o.jsx(T.Download,{className:"rfp-w-4 rfp-h-4"}),tooltip:u("common.download"),action:Ft}]},...Vs?[{items:[{type:"button",icon:o.jsx(T.X,{className:"rfp-w-4 rfp-h-4"}),tooltip:u("common.close"),action:n}]}]:[]],dt=(D,K)=>D.map((ve,ye,tt)=>o.jsxs(p.Fragment,{children:[ve.items.map((Le,br)=>Le.type==="button"?o.jsx(un,{icon:Le.icon,label:Le.tooltip,onClick:Le.action,disabled:Le.disabled},`${ye}-${br}`):o.jsx("span",{className:"rfp-text-xs rfp-text-center rfp-font-medium rfp-tabular-nums rfp-text-fg-tertiary",style:{minWidth:Le.minWidth||"auto"},children:Le.content},`${ye}-${br}`)),ye<tt.length-1&&o.jsx("div",{className:`rfp-w-px rfp-h-4 rfp-bg-divide ${K}`})]},ye));return o.jsx(os,{locale:a,messages:c,children:o.jsx(Ii,{theme:x,children:o.jsxs("div",{ref:U,tabIndex:i==="embed"?0:-1,"data-theme":x,className:"rfp-relative rfp-w-full rfp-h-full rfp-flex rfp-flex-col rfp-overflow-hidden rfp-outline-none",children:[!f&&o.jsxs(le.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"rfp-flex-shrink-0 rfp-z-10 rfp-backdrop-blur-md rfp-border-b rfp-bg-surface-toolbar rfp-border-line",style:{paddingTop:"env(safe-area-inset-top, 0px)"},children:[o.jsxs("div",{className:"rfp-flex rfp-items-center rfp-justify-between rfp-px-3 md:rfp-px-5 rfp-py-1.5 md:rfp-py-2.5",children:[o.jsxs("div",{className:"rfp-flex rfp-items-center rfp-flex-1 rfp-min-w-0 rfp-mr-2 md:rfp-mr-3",children:[o.jsx("h2",{className:"rfp-font-medium rfp-text-xs md:rfp-text-sm rfp-truncate rfp-text-fg-primary",children:O.name}),o.jsxs("span",{className:"rfp-text-xs rfp-ml-2 rfp-flex-shrink-0 rfp-text-fg-muted",children:[e+1,"/",ue.length]})]}),o.jsx("div",{className:"rfp-flex rfp-items-center rfp-gap-1 md:rfp-hidden rfp-flex-shrink-0",children:dt(xr,"rfp-mx-0.5")}),o.jsxs("div",{className:"rfp-hidden md:rfp-flex rfp-items-center rfp-gap-1 rfp-flex-shrink-0",children:[dt(ft,"rfp-mx-1"),ft.length>0&&o.jsx("div",{className:"rfp-w-px rfp-h-4 rfp-mx-1 rfp-bg-divide"}),dt(xr,"rfp-mx-1")]})]}),ft.length>0&&o.jsx("div",{className:"rfp-flex rfp-items-center rfp-gap-1 rfp-px-3 rfp-pb-1.5 rfp-overflow-x-auto scrollbar-hide md:rfp-hidden",children:dt(ft,"rfp-mx-0.5")})]}),o.jsx("div",{ref:H,className:"rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center rfp-overflow-auto",onMouseMove:Ue,children:Ge?Ge.render(O,pr):o.jsxs(p.Suspense,{fallback:o.jsx(hn,{}),children:[Z==="image"&&o.jsx(Xi,{url:O.url,zoom:v,rotation:y,resetKey:L,fileSize:O.size,onZoomChange:As,onNaturalWidthChange:P,onNaturalHeightChange:F}),Z==="pdf"&&o.jsx(Zi,{url:O.url,zoom:v,currentPage:k,onPageChange:N,onTotalPagesChange:M,onPageWidthChange:P}),Z==="docx"&&o.jsx(Yi,{url:O.url}),Z==="xlsx"&&o.jsx(Ji,{url:O.url}),Z==="pptx"&&o.jsx(Ki,{url:O.url}),Z==="msg"&&o.jsx(Qi,{url:O.url}),Z==="epub"&&o.jsx(en,{ref:E,url:O.url,onChapterChange:Hs,onFullWidthChange:_}),Z==="mobi"&&o.jsx(tn,{ref:A,url:O.url,onChapterChange:Ws,onFullWidthChange:$e}),Z==="video"&&o.jsx(rn,{url:O.url}),Z==="audio"&&o.jsx(sn,{url:O.url,fileName:O.name}),Z==="markdown"&&o.jsx(nn,{url:O.url,viewMode:ze}),Z==="json"&&o.jsx(ln,{url:O.url,fileName:O.name}),Z==="csv"&&o.jsx(on,{url:O.url,fileName:O.name}),Z==="xml"&&o.jsx(an,{url:O.url,fileName:O.name}),Z==="subtitle"&&o.jsx(cn,{url:O.url,fileName:O.name}),Z==="zip"&&(l>=pn?o.jsx(Cr,{fileName:O.name,fileType:O.type,onDownload:Ft}):o.jsx(fn,{url:O.url,onStatsChange:Bs,nestingDepth:l})),Z==="text"&&o.jsx(dn,{url:O.url,fileName:O.name,wordWrap:J,htmlPreview:pe}),Z==="unsupported"&&o.jsx(Cr,{fileName:O.name,fileType:O.type,onDownload:Ft})]})}),!f&&ue.length>1&&o.jsxs(o.Fragment,{children:[e>0&&o.jsx(le.motion.button,{initial:{opacity:0},animate:{opacity:ke?1:0,x:ke?0:-20},transition:{duration:.2},onClick:()=>t==null?void 0:t(e-1),onMouseEnter:()=>Se(!0),style:{pointerEvents:ke?"auto":"none"},className:"rfp-absolute rfp-z-20 rfp-left-2 md:rfp-left-4 rfp-top-1/2 -rfp-translate-y-1/2 rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-rounded-full rfp-backdrop-blur-xl rfp-border rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors rfp-shadow-2xl rfp-bg-surface-nav rfp-border-line hover:rfp-bg-surface-nav-hover rfp-text-fg-primary",children:o.jsx(T.ChevronLeft,{className:"rfp-w-5 rfp-h-5 md:rfp-w-6 md:rfp-h-6"})}),e<ue.length-1&&o.jsx(le.motion.button,{initial:{opacity:0},animate:{opacity:ke?1:0,x:ke?0:20},transition:{duration:.2},onClick:()=>t==null?void 0:t(e+1),onMouseEnter:()=>Se(!0),style:{pointerEvents:ke?"auto":"none"},className:"rfp-absolute rfp-z-20 rfp-right-2 md:rfp-right-4 rfp-top-1/2 -rfp-translate-y-1/2 rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-rounded-full rfp-backdrop-blur-xl rfp-border rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors rfp-shadow-2xl rfp-bg-surface-nav rfp-border-line hover:rfp-bg-surface-nav-hover rfp-text-fg-primary",children:o.jsx(T.ChevronRight,{className:"rfp-w-5 rfp-h-5 md:rfp-w-6 md:rfp-h-6"})})]})]})})})},un=({icon:r,label:e,onClick:t,disabled:s})=>o.jsxs("button",{onClick:t,disabled:s,className:`rfp-relative rfp-group rfp-p-2 md:rfp-p-1.5 rfp-rounded-md rfp-transition-all rfp-select-none ${s?"rfp-text-fg-disabled rfp-cursor-not-allowed":"rfp-text-fg-primary hover:rfp-bg-surface-2 active:rfp-bg-surface-3"}`,children:[r,o.jsxs("span",{className:"rfp-absolute rfp-left-1/2 -rfp-translate-x-1/2 rfp-top-full rfp-mt-1.5 rfp-px-2 rfp-py-1 rfp-text-xs rfp-rounded rfp-whitespace-nowrap rfp-pointer-events-none rfp-opacity-0 rfp-invisible group-hover:rfp-opacity-100 group-hover:rfp-visible rfp-transition-opacity rfp-duration-200 rfp-z-50 rfp-bg-fg-primary rfp-text-fg-inverse",children:[o.jsx("span",{className:"rfp-absolute rfp-left-1/2 -rfp-translate-x-1/2 -rfp-top-1 rfp-w-2 rfp-h-2 rfp-rotate-45 rfp-bg-fg-primary"}),o.jsx("span",{className:"rfp-relative",children:e})]})]}),mn=Object.freeze(Object.defineProperty({__proto__:null,FilePreviewContent:Rt},Symbol.toStringTag,{value:"Module"})),gn=({files:r,currentIndex:e,isOpen:t,onClose:s,onNavigate:i,customRenderers:n=[],locale:l,messages:a,headless:c,theme:f="dark",onCustomEvent:d})=>{const[h,u]=p.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!0);p.useEffect(()=>{if(f!=="auto")return;const x=window.matchMedia("(prefers-color-scheme: dark)"),v=b=>u(b.matches);return x.addEventListener("change",v),()=>x.removeEventListener("change",v)},[f]);const m=f==="auto"?h?"dark":"light":f;if(p.useEffect(()=>{if(t){const x=document.body.style.overflow,v=document.body.style.paddingRight,b=window.innerWidth-document.documentElement.clientWidth;return document.body.style.overflow="hidden",b>0&&(document.body.style.paddingRight=`${b}px`),()=>{document.body.style.overflow=x,document.body.style.paddingRight=v}}},[t]),!t)return null;const g=o.jsx("div",{className:"rfp-root","data-theme":m,children:o.jsx(le.AnimatePresence,{children:t&&o.jsx(le.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"rfp-fixed rfp-inset-0 rfp-z-[9999] rfp-flex rfp-items-center rfp-justify-center rfp-backdrop-blur-md rfp-overflow-hidden rfp-bg-surface-overlay",onClick:s,onWheel:x=>x.stopPropagation(),children:o.jsx("div",{className:"rfp-relative rfp-w-full rfp-h-full",onClick:x=>x.stopPropagation(),children:o.jsx(Rt,{mode:"modal",files:r,currentIndex:e,onClose:s,onNavigate:i,customRenderers:n,locale:l,messages:a,headless:c,theme:f,onCustomEvent:d})})})})});return ts.createPortal(g,document.body)},xn=({files:r,currentIndex:e=0,onNavigate:t,customRenderers:s=[],width:i="100%",height:n="100%",className:l,style:a,locale:c,messages:f,headless:d,theme:h="dark",onCustomEvent:u})=>{const[m,g]=p.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!0);p.useEffect(()=>{if(h!=="auto")return;const v=window.matchMedia("(prefers-color-scheme: dark)"),b=y=>g(y.matches);return v.addEventListener("change",b),()=>v.removeEventListener("change",b)},[h]);const x=h==="auto"?m?"dark":"light":h;return o.jsx("div",{className:`rfp-root ${l??""}`,style:{width:i,height:n,...a},"data-theme":x,children:o.jsx("div",{className:"rfp-relative rfp-w-full rfp-h-full rfp-overflow-hidden rfp-bg-surface-overlay",children:o.jsx(Rt,{mode:"embed",files:r,currentIndex:e,onNavigate:t,customRenderers:s,locale:c,messages:f,headless:d,theme:h,onCustomEvent:u})})})};function fs(r){if(typeof window>"u")return;const{workerSrc:e=`https://unpkg.com/pdfjs-dist@${Pe.pdfjs.version}/build/pdf.worker.min.mjs`,cMapUrl:t=`https://unpkg.com/pdfjs-dist@${Pe.pdfjs.version}/cmaps/`,cMapPacked:s=!0}=r||{};Pe.pdfjs.GlobalWorkerOptions.workerSrc=e,Pe.pdfjs.GlobalWorkerOptions.cMapUrl=t,Pe.pdfjs.GlobalWorkerOptions.cMapPacked=s}fs();const bn=ii.version,wn=({url:r,zoom:e,rotation:t,resetKey:s,fileSize:i,onZoomChange:n,onNaturalWidthChange:l,onNaturalHeightChange:a})=>{const c=Q(),[f,d]=p.useState(!1),[h,u]=p.useState(null),[m,g]=p.useState({x:0,y:0}),[x,v]=p.useState(!1),[b,y]=p.useState({x:0,y:0}),[j,k]=p.useState(1),[N,M]=p.useState({width:0,height:0}),z=p.useRef(null),P=p.useRef(null);p.useEffect(()=>{d(!1),u(null),g({x:0,y:0}),k(1)},[r]),p.useEffect(()=>{k(e)},[e]),p.useEffect(()=>{s!==void 0&&g({x:0,y:0})},[s]);const S=R=>{d(!0);const $=R.currentTarget;M({width:$.naturalWidth,height:$.naturalHeight}),l==null||l($.naturalWidth),a==null||a($.naturalHeight)},F=p.useCallback((R,$)=>{const G=P.current;if(!G||N.width===0)return R;const q=G.clientWidth,Y=G.clientHeight,_=N.width*$,A=N.height*$,B=Math.min(80,q*.15,Y*.15),ee=(q+_)/2-B,X=(Y+A)/2-B;return{x:ee>0?Math.max(-ee,Math.min(ee,R.x)):0,y:X>0?Math.max(-X,Math.min(X,R.y)):0}},[N]),L=()=>{u(c("image.load_failed")),d(!0)},V=()=>{g({x:0,y:0}),k(1),n==null||n(1)};p.useEffect(()=>{const R=P.current;if(!R)return;const $=G=>{G.preventDefault(),G.stopPropagation();const q=R.getBoundingClientRect(),Y=G.clientX-q.left-q.width/2,_=G.clientY-q.top-q.height/2,A=G.deltaY>0?-.05:.05;k(B=>{const ee=Math.max(.01,Math.min(10,B+A)),X=ee/B;return g(ne=>F({x:Y-X*(Y-ne.x),y:_-X*(_-ne.y)},ee)),n==null||n(ee),ee})};return R.addEventListener("wheel",$,{passive:!1}),()=>R.removeEventListener("wheel",$)},[n,F]);const H=p.useCallback(R=>{R.button===0&&(v(!0),y({x:R.clientX-m.x,y:R.clientY-m.y}))},[m]),U=p.useCallback(R=>{x&&g(F({x:R.clientX-b.x,y:R.clientY-b.y},j))},[x,b,j,F]),E=p.useCallback(()=>{v(!1)},[]);return o.jsxs("div",{ref:P,className:"rfp-relative rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-overflow-hidden",onMouseDown:H,onMouseMove:U,onMouseUp:E,onMouseLeave:E,style:{cursor:x?"grabbing":"grab"},children:[!f&&!h&&o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center",children:o.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),h&&o.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:o.jsx("p",{className:"rfp-text-lg",children:h})}),o.jsx(le.motion.img,{ref:z,src:r,alt:"Preview",className:`rfp-max-w-none rfp-select-none ${f?"":"rfp-hidden"}`,style:{transform:`translate(${m.x}px, ${m.y}px) scale(${j}) rotate(${t}deg)`,transformOrigin:"center",transition:x?"none":"transform 0.3s ease-out"},onLoad:S,onError:L,onDoubleClick:V,initial:{opacity:0},animate:{opacity:f?1:0},transition:{duration:.3},draggable:!1}),f&&!h&&N.width>0&&o.jsxs("div",{className:"rfp-absolute rfp-bottom-2 rfp-right-3 rfp-text-[10px] rfp-text-fg-disabled hover:rfp-text-fg-secondary rfp-transition-colors rfp-pointer-events-auto rfp-select-none rfp-cursor-default",children:[N.width," × ",N.height,i!=null&&` · ${i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:`${(i/(1024*1024)).toFixed(1)} MB`}`]})]})},vn=Object.freeze(Object.defineProperty({__proto__:null,ImageRenderer:wn},Symbol.toStringTag,{value:"Module"})),yn=({url:r,zoom:e,currentPage:t,onPageChange:s,onTotalPagesChange:i,onPageWidthChange:n})=>{const l=Q(),[a,c]=p.useState(0),[f,d]=p.useState(null),h=p.useRef(null),u=p.useRef(new Map);p.useEffect(()=>{d(null)},[r]);const m=({numPages:b})=>{c(b),i(b),s(1)},g=b=>{console.error("PDF 加载错误:",b),d(l("pdf.load_failed"))},x=p.useCallback(()=>{if(!h.current)return;const b=h.current,y=b.scrollTop,j=b.clientHeight,k=y+j/2;let N=1,M=1/0;u.current.forEach((z,P)=>{const S=z.getBoundingClientRect(),F=b.getBoundingClientRect(),L=S.top-F.top+S.height/2+y,V=Math.abs(L-k);V<M&&(M=V,N=P)}),N!==t&&s(N)},[t,s]);p.useEffect(()=>{const b=h.current;if(b)return b.addEventListener("scroll",x),()=>b.removeEventListener("scroll",x)},[x]);const v=p.useCallback((b,y)=>{y?u.current.set(b,y):u.current.delete(b)},[]);return o.jsxs("div",{ref:h,className:"rfp-flex rfp-flex-col rfp-items-center rfp-w-full rfp-h-full rfp-overflow-auto rfp-py-4 md:rfp-py-8 rfp-px-2 md:rfp-px-4",children:[f&&o.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:o.jsx("p",{className:"rfp-text-lg",children:f})}),!f&&o.jsx(Pe.Document,{file:r,onLoadSuccess:m,onLoadError:g,loading:o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-min-h-screen",children:o.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),children:o.jsx("div",{className:"rfp-flex rfp-flex-col rfp-gap-4",children:Array.from(new Array(a),(b,y)=>{const j=y+1;return o.jsxs("div",{ref:k=>v(j,k),className:"rfp-relative",children:[o.jsx(Pe.Page,{pageNumber:j,scale:e,loading:o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-p-8 rfp-bg-surface-1 rfp-rounded-lg rfp-min-h-[600px]",children:o.jsx("div",{className:"rfp-w-8 rfp-h-8 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),renderTextLayer:!1,renderAnnotationLayer:!1,className:"rfp-shadow-2xl",onRenderSuccess:k=>{j===1&&n&&n(k.originalWidth||k.width/e)}}),o.jsx("div",{className:"rfp-absolute rfp-top-2 rfp-right-2 rfp-bg-surface-nav-hover rfp-backdrop-blur-sm rfp-text-fg-primary rfp-text-xs rfp-px-3 rfp-py-1 rfp-rounded-full",children:j})]},`page_${j}`)})})}),a>0&&o.jsxs("div",{className:"rfp-sticky rfp-bottom-2 md:rfp-bottom-4 rfp-mt-4 md:rfp-mt-8 rfp-bg-surface-nav-hover rfp-backdrop-blur-xl rfp-text-fg-primary rfp-px-4 rfp-py-2 md:rfp-px-6 md:rfp-py-3 rfp-rounded-full rfp-text-xs md:rfp-text-sm rfp-font-medium rfp-shadow-2xl rfp-border rfp-border-line-weak",children:["第 ",t," 页 / 共 ",a," 页"]})]})},jn=Object.freeze(Object.defineProperty({__proto__:null,PdfRenderer:yn},Symbol.toStringTag,{value:"Module"})),ds=1123,hs=60,Nr=50,kn=ds-hs*2,Sn=24,Er={fontFamily:"system-ui, -apple-system, sans-serif",lineHeight:"1.8",color:"#333"},Cn=({url:r})=>{const e=Q(),[t,s]=p.useState(""),[i,n]=p.useState(!0),[l,a]=p.useState(null),[c,f]=p.useState([]),d=p.useRef(null);p.useEffect(()=>{(async()=>{n(!0),a(null),s("");try{const m=await fetch(r);if(!m.ok)throw new Error("文件加载失败");const g=await m.arrayBuffer(),x=await qs.convertToHtml({arrayBuffer:g});s(x.value)}catch(m){console.error("Docx 解析错误:",m),a(e("docx.parse_failed"))}finally{n(!1)}})()},[r]);const h=p.useCallback(()=>{const u=d.current;if(!u||!t)return;const m=Array.from(u.children);if(m.length===0){f([t]);return}const g=[[]];let x=0;for(const v of m){const b=v.offsetHeight;x>0&&x+b>kn&&(g.push([]),x=0),g[g.length-1].push(v.outerHTML),x+=b}g.length===0&&g.push([]),f(g.map(v=>v.join("")))},[t]);return p.useEffect(()=>{!t||!d.current||requestAnimationFrame(()=>{h()})},[t,h]),i?o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}):l?o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:o.jsx("p",{className:"rfp-text-lg",children:l})})}):o.jsxs("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto",style:{background:"rgba(0, 0, 0, 0.15)"},children:[o.jsx("div",{ref:d,dangerouslySetInnerHTML:{__html:t},style:{...Er,position:"absolute",visibility:"hidden",width:`${794-Nr*2}px`,pointerEvents:"none"}}),o.jsx("div",{className:"rfp-py-6 md:rfp-py-10 rfp-flex rfp-flex-col rfp-items-center",style:{gap:`${Sn}px`},children:(c.length>0?c:[""]).map((u,m)=>o.jsx("div",{style:{width:"100%",maxWidth:"794px",minHeight:`${ds}px`,background:"white",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.15)",flexShrink:0,padding:`${hs}px ${Nr}px`},children:o.jsx("div",{dangerouslySetInnerHTML:{__html:u},style:Er})},m))})]})},Nn=Object.freeze(Object.defineProperty({__proto__:null,DocxRenderer:Cn},Symbol.toStringTag,{value:"Module"}));class We{constructor(e,t=""){typeof e=="string"?(this.el=document.createElement(e),this.el.className=t):this.el=e,this.data={}}data(e,t){return t!==void 0?(this.data[e]=t,this):this.data[e]}on(e,t){const[s,...i]=e.split(".");let n=s;return n==="mousewheel"&&/Firefox/i.test(window.navigator.userAgent)&&(n="DOMMouseScroll"),this.el.addEventListener(n,l=>{t(l);for(let a=0;a<i.length;a+=1){const c=i[a];if(c==="left"&&l.button!==0||c==="right"&&l.button!==2)return;c==="stop"&&l.stopPropagation()}}),this}offset(e){if(e!==void 0)return Object.keys(e).forEach(l=>{this.css(l,`${e[l]}px`)}),this;const{offsetTop:t,offsetLeft:s,offsetHeight:i,offsetWidth:n}=this.el;return{top:t,left:s,height:i,width:n}}scroll(e){const{el:t}=this;return e!==void 0&&(e.left!==void 0&&(t.scrollLeft=e.left),e.top!==void 0&&(t.scrollTop=e.top)),{left:t.scrollLeft,top:t.scrollTop}}box(){return this.el.getBoundingClientRect()}parent(){return new We(this.el.parentNode)}children(...e){return arguments.length===0?this.el.childNodes:(e.forEach(t=>this.child(t)),this)}removeChild(e){this.el.removeChild(e)}child(e){let t=e;return typeof e=="string"?t=document.createTextNode(e):e instanceof We&&(t=e.el),this.el.appendChild(t),this}contains(e){return this.el.contains(e)}className(e){return e!==void 0?(this.el.className=e,this):this.el.className}addClass(e){return this.el.classList.add(e),this}hasClass(e){return this.el.classList.contains(e)}removeClass(e){return this.el.classList.remove(e),this}toggle(e="active"){return this.toggleClass(e)}toggleClass(e){return this.el.classList.toggle(e)}active(e=!0,t="active"){return e?this.addClass(t):this.removeClass(t),this}checked(e=!0){return this.active(e,"checked"),this}disabled(e=!0){return e?this.addClass("disabled"):this.removeClass("disabled"),this}attr(e,t){if(t!==void 0)this.el.setAttribute(e,t);else{if(typeof e=="string")return this.el.getAttribute(e);Object.keys(e).forEach(s=>{this.el.setAttribute(s,e[s])})}return this}removeAttr(e){return this.el.removeAttribute(e),this}html(e){return e!==void 0?(this.el.innerHTML=e,this):this.el.innerHTML}val(e){return e!==void 0?(this.el.value=e,this):this.el.value}focus(){this.el.focus()}cssRemoveKeys(...e){return e.forEach(t=>this.el.style.removeProperty(t)),this}css(e,t){return t===void 0&&typeof e!="string"?(Object.keys(e).forEach(s=>{this.el.style[s]=e[s]}),this):t!==void 0?(this.el.style[e]=t,this):this.el.style[e]}computedStyle(){return window.getComputedStyle(this.el,null)}show(){return this.css("display","block"),this}hide(){return this.css("display","none"),this}}const w=(r,e="")=>new We(r,e),De=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function ps(r){let e="",t=r;for(;t>=De.length;)t/=De.length,t-=1,e+=De[parseInt(t,10)%De.length];const s=r%De.length;return e+=De[s],e}function En(r){let e=0;for(let t=0;t<r.length-1;t+=1){const s=r.charCodeAt(t)-65,i=r.length-1-t;e+=De.length**i+De.length*s}return e+=r.charCodeAt(r.length-1)-65,e}function Oe(r){let e="",t="";for(let s=0;s<r.length;s+=1)r.charAt(s)>="0"&&r.charAt(s)<="9"?t+=r.charAt(s):e+=r.charAt(s);return[En(e),parseInt(t,10)-1]}function Me(r,e){return`${ps(r)}${e+1}`}function rt(r,e,t,s=()=>!0){if(e===0&&t===0)return r;const[i,n]=Oe(r);return s(i,n)?Me(i+e,n+t):r}class te{constructor(e,t,s,i,n=0,l=0){this.sri=e,this.sci=t,this.eri=s,this.eci=i,this.w=n,this.h=l}set(e,t,s,i){this.sri=e,this.sci=t,this.eri=s,this.eci=i}multiple(){return this.eri-this.sri>0||this.eci-this.sci>0}includes(...e){let[t,s]=[0,0];e.length===1?[s,t]=Oe(e[0]):e.length===2&&([t,s]=e);const{sri:i,sci:n,eri:l,eci:a}=this;return i<=t&&t<=l&&n<=s&&s<=a}each(e,t=()=>!0){const{sri:s,sci:i,eri:n,eci:l}=this;for(let a=s;a<=n;a+=1)if(t(a))for(let c=i;c<=l;c+=1)e(a,c)}contains(e){return this.sri<=e.sri&&this.sci<=e.sci&&this.eri>=e.eri&&this.eci>=e.eci}within(e){return this.sri>=e.sri&&this.sci>=e.sci&&this.eri<=e.eri&&this.eci<=e.eci}disjoint(e){return this.sri>e.eri||this.sci>e.eci||e.sri>this.eri||e.sci>this.eci}intersects(e){return this.sri<=e.eri&&this.sci<=e.eci&&e.sri<=this.eri&&e.sci<=this.eci}union(e){const{sri:t,sci:s,eri:i,eci:n}=this;return new te(e.sri<t?e.sri:t,e.sci<s?e.sci:s,e.eri>i?e.eri:i,e.eci>n?e.eci:n)}difference(e){const t=[],s=(u,m,g,x)=>{t.push(new te(u,m,g,x))},{sri:i,sci:n,eri:l,eci:a}=this,c=e.sri-i,f=e.sci-n,d=l-e.eri,h=a-e.eci;return c>0?(s(i,n,e.sri-1,a),d>0?(s(e.eri+1,n,l,a),f>0&&s(e.sri,n,e.eri,e.sci-1),h>0&&s(e.sri,e.eci+1,e.eri,a)):(f>0&&s(e.sri,n,l,e.sci-1),h>0&&s(e.sri,e.eci+1,l,a))):d>0&&(s(e.eri+1,n,l,a),f>0&&s(i,n,e.eri,e.sci-1),h>0&&s(i,e.eci+1,e.eri,a)),f>0?(s(i,n,l,e.sci-1),h>0?(s(i,e.eri+1,l,a),c>0&&s(i,e.sci,e.sri-1,e.eci),d>0&&s(e.sri+1,e.sci,l,e.eci)):(c>0&&s(i,e.sci,e.sri-1,a),d>0&&s(e.sri+1,e.sci,l,a))):h>0&&(s(l,e.eci+1,l,a),c>0&&s(i,n,e.sri-1,e.eci),d>0&&s(e.eri+1,n,l,e.eci)),t}size(){return[this.eri-this.sri+1,this.eci-this.sci+1]}toString(){const{sri:e,sci:t,eri:s,eci:i}=this;let n=Me(t,e);return this.multiple()&&(n=`${n}:${Me(i,s)}`),n}clone(){const{sri:e,sci:t,eri:s,eci:i,w:n,h:l}=this;return new te(e,t,s,i,n,l)}equals(e){return this.eri===e.eri&&this.eci===e.eci&&this.sri===e.sri&&this.sci===e.sci}static valueOf(e){const t=e.split(":"),[s,i]=Oe(t[0]);let[n,l]=[i,s];return t.length>1&&([l,n]=Oe(t[1])),new te(i,s,n,l)}}let Tn=class{constructor(){this.range=new te(0,0,0,0),this.ri=0,this.ci=0}multiple(){return this.range.multiple()}setIndexes(e,t){this.ri=e,this.ci=t}size(){return this.range.size()}};class Rn{constructor(){this.x=0,this.y=0,this.ri=0,this.ci=0}}class $n{constructor(){this.undoItems=[],this.redoItems=[]}add(e){this.undoItems.push(JSON.stringify(e)),this.redoItems=[]}canUndo(){return this.undoItems.length>0}canRedo(){return this.redoItems.length>0}undo(e,t){const{undoItems:s,redoItems:i}=this;this.canUndo()&&(i.push(JSON.stringify(e)),t(JSON.parse(s.pop())))}redo(e,t){const{undoItems:s,redoItems:i}=this;this.canRedo()&&(s.push(JSON.stringify(e)),t(JSON.parse(i.pop())))}}class Mn{constructor(){this.range=null,this.state="clear"}copy(e){return this.range=e,this.state="copy",this}cut(e){return this.range=e,this.state="cut",this}isCopy(){return this.state==="copy"}isCut(){return this.state==="cut"}isClear(){return this.state==="clear"}clear(){this.range=null,this.state="clear"}}class Tr{constructor(e,t,s){this.ci=e,this.operator=t,this.value=s}set(e,t){this.operator=e,this.value=t}includes(e){const{operator:t,value:s}=this;return t==="all"?!0:t==="in"?s.includes(e):!1}vlength(){const{operator:e,value:t}=this;return e==="in"?t.length:0}getData(){const{ci:e,operator:t,value:s}=this;return{ci:e,operator:t,value:s}}}class Rr{constructor(e,t){this.ci=e,this.order=t}asc(){return this.order==="asc"}desc(){return this.order==="desc"}}class Fn{constructor(){this.ref=null,this.filters=[],this.sort=null}setData({ref:e,filters:t,sort:s}){e!=null&&(this.ref=e,this.filters=t.map(i=>new Tr(i.ci,i.operator,i.value)),s&&(this.sort=new Rr(s.ci,s.order)))}getData(){if(this.active()){const{ref:e,filters:t,sort:s}=this;return{ref:e,filters:t.map(i=>i.getData()),sort:s}}return{}}addFilter(e,t,s){const i=this.getFilter(e);i==null?this.filters.push(new Tr(e,t,s)):i.set(t,s)}setSort(e,t){this.sort=t?new Rr(e,t):null}includes(e,t){return this.active()?this.hrange().includes(e,t):!1}getSort(e){const{sort:t}=this;return t&&t.ci===e?t:null}getFilter(e){const{filters:t}=this;for(let s=0;s<t.length;s+=1)if(t[s].ci===e)return t[s];return null}filteredRows(e){const t=new Set,s=new Set;if(this.active()){const{sri:i,eri:n}=this.range(),{filters:l}=this;for(let a=i+1;a<=n;a+=1)for(let c=0;c<l.length;c+=1){const f=l[c],d=e(a,f.ci),h=d?d.text:"";if(f.includes(h))s.add(a);else{t.add(a);break}}}return{rset:t,fset:s}}items(e,t){const s={};if(this.active()){const{sri:i,eri:n}=this.range();for(let l=i+1;l<=n;l+=1){const a=t(l,e);if(a!==null&&!/^\s*$/.test(a.text)){const c=a.text,f=(s[c]||0)+1;s[c]=f}else s[""]=(s[""]||0)+1}}return s}range(){return te.valueOf(this.ref)}hrange(){const e=this.range();return e.eri=e.sri,e}clear(){this.ref=null,this.filters=[],this.sort=null}active(){return this.ref!==null}}class tr{constructor(e=[]){this._=e}forEach(e){this._.forEach(e)}deleteWithin(e){this._=this._.filter(t=>!t.within(e))}getFirstIncludes(e,t){for(let s=0;s<this._.length;s+=1){const i=this._[s];if(i.includes(e,t))return i}return null}filterIntersects(e){return new tr(this._.filter(t=>t.intersects(e)))}intersects(e){for(let t=0;t<this._.length;t+=1)if(this._[t].intersects(e))return!0;return!1}union(e){let t=e;return this._.forEach(s=>{s.intersects(t)&&(t=s.union(t))}),t}add(e){this.deleteWithin(e),this._.push(e)}shift(e,t,s,i){this._.forEach(n=>{const{sri:l,sci:a,eri:c,eci:f}=n,d=n;e==="row"?l>=t?(d.sri+=s,d.eri+=s):l<t&&t<=c&&(d.eri+=s,i(l,a,s,0)):e==="column"&&(a>=t?(d.sci+=s,d.eci+=s):a<t&&t<=f&&(d.eci+=s,i(l,a,0,s)))})}move(e,t,s){this._.forEach(i=>{const n=i;n.within(e)&&(n.eri+=t,n.sri+=t,n.sci+=s,n.eci+=s)})}setData(e){return this._=e.map(t=>te.valueOf(t)),this}getData(){return this._.map(e=>e.toString())}}function zn(r){return JSON.parse(JSON.stringify(r))}const us=(r={},...e)=>(e.forEach(t=>{Object.keys(t).forEach(s=>{const i=t[s];typeof i=="string"||typeof i=="number"||typeof i=="boolean"?r[s]=i:typeof i!="function"&&!Array.isArray(i)&&i instanceof Object?(r[s]=r[s]||{},us(r[s],i)):r[s]=i})}),r);function Bt(r,e){const t=Object.keys(r);if(t.length!==Object.keys(e).length)return!1;for(let s=0;s<t.length;s+=1){const i=t[s],n=r[i],l=e[i];if(l===void 0)return!1;if(typeof n=="string"||typeof n=="number"||typeof n=="boolean"){if(n!==l)return!1}else if(Array.isArray(n)){if(n.length!==l.length)return!1;for(let a=0;a<n.length;a+=1)if(!Bt(n[a],l[a]))return!1}else if(typeof n!="function"&&!Array.isArray(n)&&n instanceof Object&&!Bt(n,l))return!1}return!0}const _n=(r,e=t=>t)=>{let t=0,s=0;return Object.keys(r).forEach(i=>{t+=e(r[i],i),s+=1}),[t,s]};function Dn(r,e){const t=r[`${e}`];return delete r[`${e}`],t}function Pn(r,e,t,s,i,n){let l=t,a=s,c=r;for(;c<e&&!(l>i);c+=1)a=n(c),l+=a;return[c,l-a,a]}function On(r,e,t){let s=0;for(let i=r;i<e;i+=1)s+=t(i);return s}function Ln(r,e,t){for(let s=r;s<e;s+=1)t(s)}function In(r,e){if(r.length===e.length){for(let t=0;t<r.length;t+=1)if(r[t]!==e[t])return!1}else return!1;return!0}function Pt(r){const e=`${r}`;let t=0,s=!1;for(let i=0;i<e.length;i+=1)s===!0&&(t+=1),e.charAt(i)==="."&&(s=!0);return t}function Ie(r,e,t){if(Number.isNaN(e)||Number.isNaN(t))return e+r+t;const s=Pt(e),i=Pt(t),n=Number(e),l=Number(t);let a=0;if(r==="-")a=n-l;else if(r==="+")a=n+l;else if(r==="*")a=n*l;else if(r==="/")return a=n/l,Pt(a)>5?a.toFixed(2):a;return a.toFixed(Math.max(s,i))}const ce={cloneDeep:zn,merge:(...r)=>us({},...r),equals:Bt,arrayEquals:In,sum:_n,rangeEach:Ln,rangeSum:On,rangeReduceIf:Pn,deleteProperty:Dn,numberCalc:Ie};class An{constructor({len:e,height:t}){this._={},this.len=e,this.height=t}getHeight(e){if(this.isHide(e))return 0;const t=this.get(e);return t&&t.height?t.height:this.height}setHeight(e,t){const s=this.getOrNew(e);s.height=t}unhide(e){let t=e;for(;t>0&&(t-=1,this.isHide(t));)this.setHide(t,!1)}isHide(e){const t=this.get(e);return t&&t.hide}setHide(e,t){const s=this.getOrNew(e);t===!0?s.hide=!0:delete s.hide}setStyle(e,t){const s=this.getOrNew(e);s.style=t}sumHeight(e,t,s){return ce.rangeSum(e,t,i=>s&&s.has(i)?0:this.getHeight(i))}totalHeight(){return this.sumHeight(0,this.len)}get(e){return this._[e]}getOrNew(e){return this._[e]=this._[e]||{cells:{}},this._[e]}getCell(e,t){const s=this.get(e);return s!==void 0&&s.cells!==void 0&&s.cells[t]!==void 0?s.cells[t]:null}getCellMerge(e,t){const s=this.getCell(e,t);return s&&s.merge?s.merge:[0,0]}getCellOrNew(e,t){const s=this.getOrNew(e);return s.cells[t]=s.cells[t]||{},s.cells[t]}setCell(e,t,s,i="all"){const n=this.getOrNew(e);i==="all"?n.cells[t]=s:i==="text"?(n.cells[t]=n.cells[t]||{},n.cells[t].text=s.text):i==="format"&&(n.cells[t]=n.cells[t]||{},n.cells[t].style=s.style,s.merge&&(n.cells[t].merge=s.merge))}setCellText(e,t,s){const i=this.getCellOrNew(e,t);i.editable!==!1&&(i.text=s)}copyPaste(e,t,s,i=!1,n=()=>{}){const{sri:l,sci:a,eri:c,eci:f}=e,d=t.sri,h=t.sci,u=t.eri,m=t.eci,[g,x]=e.size(),[v,b]=t.size();let y=!0,j=0;(u<l||m<a)&&(y=!1,u<l?j=v:j=b);for(let k=l;k<=c;k+=1)if(this._[k]){for(let N=a;N<=f;N+=1)if(this._[k].cells&&this._[k].cells[N])for(let M=d;M<=u;M+=g)for(let z=h;z<=m;z+=x){const P=M+(k-l),S=z+(N-a),F=ce.cloneDeep(this._[k].cells[N]);if(i&&F&&F.text&&F.text.length>0){const{text:L}=F;let V=z-h+(M-d)+2;if(y||(V-=j+1),L[0]==="=")F.text=L.replace(/[a-zA-Z]{1,3}\d+/g,H=>{let[U,E]=[0,0];return l===d?U=V-1:E=V-1,/^\d+$/.test(H)?H:rt(H,U,E)});else if(g<=1&&x>1&&(d>c||u<l)||x<=1&&g>1&&(h>f||m<a)||g<=1&&x<=1){const H=/[\\.\d]+$/.exec(L);if(H!==null){const U=Number(H[0])+V-1;F.text=L.substring(0,H.index)+U}}}this.setCell(P,S,F,s),n(P,S,F)}}}cutPaste(e,t){const s={};this.each(i=>{this.eachCells(i,n=>{let l=parseInt(i,10),a=parseInt(n,10);e.includes(i,n)&&(l=t.sri+(l-e.sri),a=t.sci+(a-e.sci)),s[l]=s[l]||{cells:{}},s[l].cells[a]=this._[i].cells[n]})}),this._=s}paste(e,t){if(e.length<=0)return;const{sri:s,sci:i}=t;e.forEach((n,l)=>{const a=s+l;n.forEach((c,f)=>{const d=i+f;this.setCellText(a,d,c)})})}insert(e,t=1){const s={};this.each((i,n)=>{let l=parseInt(i,10);l>=e&&(l+=t,this.eachCells(i,(a,c)=>{c.text&&c.text[0]==="="&&(c.text=c.text.replace(/[a-zA-Z]{1,3}\d+/g,f=>rt(f,0,t,(d,h)=>h>=e)))})),s[l]=n}),this._=s,this.len+=t}delete(e,t){const s=t-e+1,i={};this.each((n,l)=>{const a=parseInt(n,10);a<e?i[a]=l:n>t&&(i[a-s]=l,this.eachCells(n,(c,f)=>{f.text&&f.text[0]==="="&&(f.text=f.text.replace(/[a-zA-Z]{1,3}\d+/g,d=>rt(d,0,-s,(h,u)=>u>t)))}))}),this._=i,this.len-=s}insertColumn(e,t=1){this.each((s,i)=>{const n={};this.eachCells(s,(l,a)=>{let c=parseInt(l,10);c>=e&&(c+=t,a.text&&a.text[0]==="="&&(a.text=a.text.replace(/[a-zA-Z]{1,3}\d+/g,f=>rt(f,t,0,d=>d>=e)))),n[c]=a}),i.cells=n})}deleteColumn(e,t){const s=t-e+1;this.each((i,n)=>{const l={};this.eachCells(i,(a,c)=>{const f=parseInt(a,10);f<e?l[f]=c:f>t&&(l[f-s]=c,c.text&&c.text[0]==="="&&(c.text=c.text.replace(/[a-zA-Z]{1,3}\d+/g,d=>rt(d,-s,0,h=>h>t))))}),n.cells=l})}deleteCells(e,t="all"){e.each((s,i)=>{this.deleteCell(s,i,t)})}deleteCell(e,t,s="all"){const i=this.get(e);if(i!==null){const n=this.getCell(e,t);n!==null&&n.editable!==!1&&(s==="all"?delete i.cells[t]:s==="text"?(n.text&&delete n.text,n.value&&delete n.value):s==="format"?(n.style!==void 0&&delete n.style,n.merge&&delete n.merge):s==="merge"&&n.merge&&delete n.merge)}}maxCell(){const e=Object.keys(this._),t=e[e.length-1],s=this._[t];if(s){const{cells:i}=s,n=Object.keys(i),l=n[n.length-1];return[parseInt(t,10),parseInt(l,10)]}return[0,0]}each(e){Object.entries(this._).forEach(([t,s])=>{e(t,s)})}eachCells(e,t){this._[e]&&this._[e].cells&&Object.entries(this._[e].cells).forEach(([s,i])=>{t(s,i)})}setData(e){e.len&&(this.len=e.len,delete e.len),this._=e}getData(){const{len:e}=this;return Object.assign({len:e},this._)}}class Hn{constructor({len:e,width:t,indexWidth:s,minWidth:i}){this._={},this.len=e,this.width=t,this.indexWidth=s,this.minWidth=i}setData(e){e.len&&(this.len=e.len,delete e.len),this._=e}getData(){const{len:e}=this;return Object.assign({len:e},this._)}getWidth(e){if(this.isHide(e))return 0;const t=this._[e];return t&&t.width?t.width:this.width}getOrNew(e){return this._[e]=this._[e]||{},this._[e]}setWidth(e,t){const s=this.getOrNew(e);s.width=t}unhide(e){let t=e;for(;t>0&&(t-=1,this.isHide(t));)this.setHide(t,!1)}isHide(e){const t=this._[e];return t&&t.hide}setHide(e,t){const s=this.getOrNew(e);t===!0?s.hide=!0:delete s.hide}setStyle(e,t){const s=this.getOrNew(e);s.style=t}sumWidth(e,t){return ce.rangeSum(e,t,s=>this.getWidth(s))}totalWidth(){return this.sumWidth(0,this.len)}}const Wn={toolbar:{undo:"Undo",redo:"Redo",print:"Print",paintformat:"Paint format",clearformat:"Clear format",format:"Format",fontName:"Font",fontSize:"Font size",fontBold:"Font bold",fontItalic:"Font italic",underline:"Underline",strike:"Strike",color:"Text color",bgcolor:"Fill color",border:"Borders",merge:"Merge cells",align:"Horizontal align",valign:"Vertical align",textwrap:"Text wrapping",freeze:"Freeze cell",autofilter:"Filter",formula:"Functions",more:"More"},contextmenu:{copy:"Copy",cut:"Cut",paste:"Paste",pasteValue:"Paste values only",pasteFormat:"Paste format only",hide:"Hide",insertRow:"Insert row",insertColumn:"Insert column",deleteSheet:"Delete",deleteRow:"Delete row",deleteColumn:"Delete column",deleteCell:"Delete cell",deleteCellText:"Delete cell text",validation:"Data validations",cellprintable:"Enable export",cellnonprintable:"Disable export",celleditable:"Enable editing",cellnoneditable:"Disable editing"},print:{size:"Paper size",orientation:"Page orientation",orientations:["Landscape","Portrait"]},format:{normal:"Normal",text:"Plain Text",number:"Number",percent:"Percent",rmb:"RMB",usd:"USD",eur:"EUR",date:"Date",time:"Time",datetime:"Date time",duration:"Duration"},formula:{sum:"Sum",average:"Average",max:"Max",min:"Min",_if:"IF",and:"AND",or:"OR",concat:"Concat"},validation:{required:"it must be required",notMatch:"it not match its validation rule",between:"it is between {} and {}",notBetween:"it is not between {} and {}",notIn:"it is not in list",equal:"it equal to {}",notEqual:"it not equal to {}",lessThan:"it less than {}",lessThanEqual:"it less than or equal to {}",greaterThan:"it greater than {}",greaterThanEqual:"it greater than or equal to {}"},error:{pasteForMergedCell:"Unable to do this for merged cells"},calendar:{weeks:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},button:{next:"Next",cancel:"Cancel",remove:"Remove",save:"Save",ok:"OK"},sort:{desc:"Sort Z -> A",asc:"Sort A -> Z"},filter:{empty:"empty"},dataValidation:{mode:"Mode",range:"Cell Range",criteria:"Criteria",modeType:{cell:"Cell",column:"Colun",row:"Row"},type:{list:"List",number:"Number",date:"Date",phone:"Phone",email:"Email"},operator:{be:"between",nbe:"not betwwen",lt:"less than",lte:"less than or equal to",gt:"greater than",gte:"greater than or equal to",eq:"equal to",neq:"not equal to"}}};let Vt=["en"];const ms={en:Wn};function $r(r,e){if(e)for(const t of Vt){if(!e[t])break;let s=e[t];const i=r.match(/(?:\\.|[^.])+/g);for(let n=0;n<i.length;n+=1){const l=i[n],a=s[l];if(!a)break;if(n===i.length-1)return a;s=a}}}function se(r){let e=$r(r,ms);return!e&&window&&window.x_spreadsheet&&window.x_spreadsheet.$messages&&(e=$r(r,window.x_spreadsheet.$messages)),e||""}function W(r){return()=>se(r)}function gs(r,e,t=!1){t?Vt=[r]:Vt.unshift(r),e&&(ms[r]=e)}const Mr={phone:/^[1-9]\d{10}$/,email:/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/};function Ce(r,e,...t){let s="";return r||(s=se(`validation.${e}`,...t)),[r,s]}class xs{constructor(e,t,s,i){this.required=t,this.value=s,this.type=e,this.operator=i,this.message=""}parseValue(e){const{type:t}=this;return t==="date"?new Date(e):t==="number"?Number(e):e}equals(e){let t=this.type===e.type&&this.required===e.required&&this.operator===e.operator;return t&&(Array.isArray(this.value)?t=ce.arrayEquals(this.value,e.value):t=this.value===e.value),t}values(){return this.value.split(",")}validate(e){const{required:t,operator:s,value:i,type:n}=this;if(t&&/^\s*$/.test(e))return Ce(!1,"required");if(/^\s*$/.test(e))return[!0];if(Mr[n]&&!Mr[n].test(e))return Ce(!1,"notMatch");if(n==="list")return Ce(this.values().includes(e),"notIn");if(s){const l=this.parseValue(e);if(s==="be"){const[a,c]=i;return Ce(l>=this.parseValue(a)&&l<=this.parseValue(c),"between",a,c)}if(s==="nbe"){const[a,c]=i;return Ce(l<this.parseValue(a)||l>this.parseValue(c),"notBetween",a,c)}if(s==="eq")return Ce(l===this.parseValue(i),"equal",i);if(s==="neq")return Ce(l!==this.parseValue(i),"notEqual",i);if(s==="lt")return Ce(l<this.parseValue(i),"lessThan",i);if(s==="lte")return Ce(l<=this.parseValue(i),"lessThanEqual",i);if(s==="gt")return Ce(l>this.parseValue(i),"greaterThan",i);if(s==="gte")return Ce(l>=this.parseValue(i),"greaterThanEqual",i)}return[!0]}}class kt{constructor(e,t,s){this.refs=t,this.mode=e,this.validator=s}includes(e,t){const{refs:s}=this;for(let i=0;i<s.length;i+=1)if(te.valueOf(s[i]).includes(e,t))return!0;return!1}addRef(e){this.remove(te.valueOf(e)),this.refs.push(e)}remove(e){const t=[];this.refs.forEach(s=>{const i=te.valueOf(s);i.intersects(e)?i.difference(e).forEach(l=>t.push(l.toString())):t.push(s)}),this.refs=t}getData(){const{refs:e,mode:t,validator:s}=this,{type:i,required:n,operator:l,value:a}=s;return{refs:e,mode:t,type:i,required:n,operator:l,value:a}}static valueOf({refs:e,mode:t,type:s,required:i,operator:n,value:l}){return new kt(t,e,new xs(s,i,l,n))}}class Bn{constructor(){this._=[],this.errors=new Map}getError(e,t){return this.errors.get(`${e}_${t}`)}validate(e,t,s){const i=this.get(e,t),n=`${e}_${t}`,{errors:l}=this;if(i!==null){const[a,c]=i.validator.validate(s);a?l.delete(n):l.set(n,c)}else l.delete(n);return!0}add(e,t,{type:s,required:i,value:n,operator:l}){const a=new xs(s,i,n,l),c=this.getByValidator(a);c!==null?c.addRef(t):this._.push(new kt(e,[t],a))}getByValidator(e){for(let t=0;t<this._.length;t+=1){const s=this._[t];if(s.validator.equals(e))return s}return null}get(e,t){for(let s=0;s<this._.length;s+=1){const i=this._[s];if(i.includes(e,t))return i}return null}remove(e){this.each(t=>{t.remove(e)})}each(e){this._.forEach(t=>e(t))}getData(){return this._.filter(e=>e.refs.length>0).map(e=>e.getData())}setData(e){this._=e.map(t=>kt.valueOf(t))}}const Vn={mode:"edit",view:{height:()=>document.documentElement.clientHeight,width:()=>document.documentElement.clientWidth},showGrid:!0,showToolbar:!0,showContextmenu:!0,showBottomBar:!0,row:{len:100,height:25},col:{len:26,width:100,indexWidth:60,minWidth:60},style:{bgcolor:"#ffffff",align:"left",valign:"middle",textwrap:!1,strike:!1,underline:!1,color:"#0a0a0a",font:{name:"Arial",size:10,bold:!1,italic:!1},format:"normal"}},qn=41,Un=41,Fr=(r,e)=>Object.prototype.hasOwnProperty.call(r,e);function zr(r,e,t=()=>{}){const{merges:s}=this,i=e.clone(),[n,l]=r.size(),[a,c]=e.size();return n>a&&(i.eri=e.sri+n-1),l>c&&(i.eci=e.sci+l-1),s.intersects(i)?(t(se("error.pasteForMergedCell")),!1):!0}function _r(r,e,t,s=!1){const{rows:i,merges:n}=this;(t==="all"||t==="format")&&(i.deleteCells(e,t),n.deleteWithin(e)),i.copyPaste(r,e,t,s,(l,a,c)=>{if(c&&c.merge){const[f,d]=c.merge;if(f<=0&&d<=0)return;n.add(new te(l,a,l+f,a+d))}})}function Gn(r,e){const{clipboard:t,rows:s,merges:i}=this;s.cutPaste(r,e),i.move(r,e.sri-r.sri,e.sci-r.sci),t.clear()}function Xe(r,e,t){const{styles:s,rows:i}=this,n=i.getCellOrNew(r,e);let l={};n.style!==void 0&&(l=ce.cloneDeep(s[n.style])),l=ce.merge(l,{border:t}),n.style=this.addStyle(l)}function Xn({mode:r,style:e,color:t}){const{styles:s,selector:i,rows:n}=this,{sri:l,sci:a,eri:c,eci:f}=i.range,d=!this.isSignleSelected();if(!(!d&&(r==="inside"||r==="horizontal"||r==="vertical"))){if(r==="outside"&&!d)Xe.call(this,l,a,{top:[e,t],bottom:[e,t],left:[e,t],right:[e,t]});else if(r==="none")i.range.each((h,u)=>{const m=n.getCell(h,u);if(m&&m.style!==void 0){const g=ce.cloneDeep(s[m.style]);delete g.border,m.style=this.addStyle(g)}});else if(r==="all"||r==="inside"||r==="outside"||r==="horizontal"||r==="vertical"){const h=[];for(let u=l;u<=c;u+=1)for(let m=a;m<=f;m+=1){const g=[];for(let N=0;N<h.length;N+=1){const[M,z,P,S]=h[N];if(u===M+P+1&&g.push(N),M<=u&&u<=M+P&&m===z){m+=S+1;break}}if(g.forEach(N=>h.splice(N,1)),m>f)break;const x=n.getCell(u,m);let[v,b]=[0,0];x&&x.merge&&([v,b]=x.merge,h.push([u,m,v,b]));const y=v>0&&u+v===c,j=b>0&&m+b===f;let k={};r==="all"?k={bottom:[e,t],top:[e,t],left:[e,t],right:[e,t]}:r==="inside"?(!j&&m<f&&(k.right=[e,t]),!y&&u<c&&(k.bottom=[e,t])):r==="horizontal"?!y&&u<c&&(k.bottom=[e,t]):r==="vertical"?!j&&m<f&&(k.right=[e,t]):r==="outside"&&d&&(l===u&&(k.top=[e,t]),(y||c===u)&&(k.bottom=[e,t]),a===m&&(k.left=[e,t]),(j||f===m)&&(k.right=[e,t])),Object.keys(k).length>0&&Xe.call(this,u,m,k),m+=b}}else if(r==="top"||r==="bottom")for(let h=a;h<=f;h+=1)r==="top"&&(Xe.call(this,l,h,{top:[e,t]}),h+=n.getCellMerge(l,h)[1]),r==="bottom"&&(Xe.call(this,c,h,{bottom:[e,t]}),h+=n.getCellMerge(c,h)[1]);else if(r==="left"||r==="right")for(let h=l;h<=c;h+=1)r==="left"&&(Xe.call(this,h,a,{left:[e,t]}),h+=n.getCellMerge(h,a)[0]),r==="right"&&(Xe.call(this,h,f,{right:[e,t]}),h+=n.getCellMerge(h,f)[0])}}function Zn(r,e){const{rows:t}=this,s=this.freezeTotalHeight();let i=t.height;s+t.height<r&&(i-=e);const n=this.exceptRowSet;let l=0,a=i,{height:c}=t;for(;l<t.len&&!(a>r);l+=1)n.has(l)||(c=t.getHeight(l),a+=c);return a-=c,a<=0?{ri:-1,top:0,height:c}:{ri:l-1,top:a,height:c}}function Yn(r,e){const{cols:t}=this,s=this.freezeTotalWidth();let i=t.indexWidth;s+t.indexWidth<r&&(i-=e);const[n,l,a]=ce.rangeReduceIf(0,t.len,i,t.indexWidth,r,c=>t.getWidth(c));return l<=0?{ci:-1,left:0,width:t.indexWidth}:{ci:n-1,left:l,width:a}}class Jn{constructor(e,t){this.settings=ce.merge(Vn,t||{}),this.name=e||"sheet",this.freeze=[0,0],this.styles=[],this.merges=new tr,this.rows=new An(this.settings.row),this.cols=new Hn(this.settings.col),this.validations=new Bn,this.hyperlinks={},this.comments={},this.selector=new Tn,this.scroll=new Rn,this.history=new $n,this.clipboard=new Mn,this.autoFilter=new Fn,this.change=()=>{},this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map}addValidation(e,t,s){this.changeData(()=>{this.validations.add(e,t,s)})}removeValidation(){const{range:e}=this.selector;this.changeData(()=>{this.validations.remove(e)})}getSelectedValidator(){const{ri:e,ci:t}=this.selector,s=this.validations.get(e,t);return s?s.validator:null}getSelectedValidation(){const{ri:e,ci:t,range:s}=this.selector,i=this.validations.get(e,t),n={ref:s.toString()};return i!==null&&(n.mode=i.mode,n.validator=i.validator),n}canUndo(){return this.history.canUndo()}canRedo(){return this.history.canRedo()}undo(){this.history.undo(this.getData(),e=>{this.setData(e)})}redo(){this.history.redo(this.getData(),e=>{this.setData(e)})}copy(){this.clipboard.copy(this.selector.range)}copyToSystemClipboard(){if(navigator.clipboard===void 0)return;let e="";const t=this.rows.getData();for(let s=this.selector.range.sri;s<=this.selector.range.eri;s+=1){if(Fr(t,s)){for(let i=this.selector.range.sci;i<=this.selector.range.eci;i+=1)if(i>this.selector.range.sci&&(e+=" "),Fr(t[s].cells,i)){const n=String(t[s].cells[i].text);n.indexOf(`
|
|
19
|
-
`)===-1&&n.indexOf(" ")===-1&&n.indexOf('"')===-1?e+=n:e+=`"${n}"`}}else for(let i=this.selector.range.sci;i<=this.selector.range.eci;i+=1)e+=" ";e+=`
|
|
20
|
-
`}navigator.clipboard.writeText(e).then(()=>{},s=>{console.log("text copy to the system clipboard error ",e,s)})}cut(){this.clipboard.cut(this.selector.range)}paste(e="all",t=()=>{}){const{clipboard:s,selector:i}=this;return s.isClear()||!zr.call(this,s.range,i.range,t)?!1:(this.changeData(()=>{s.isCopy()?_r.call(this,s.range,i.range,e):s.isCut()&&Gn.call(this,s.range,i.range)}),!0)}pasteFromText(e){const t=e.split(`\r
|
|
21
|
-
`).map(n=>n.replace(/"/g,"").split(" "));t.length>0&&(t.length-=1);const{rows:s,selector:i}=this;this.changeData(()=>{s.paste(t,i.range)})}autofill(e,t,s=()=>{}){const i=this.selector.range;return zr.call(this,i,e,s)?(this.changeData(()=>{_r.call(this,i,e,t,!0)}),!0):!1}clearClipboard(){this.clipboard.clear()}calSelectedRangeByEnd(e,t){const{selector:s,rows:i,cols:n,merges:l}=this;let{sri:a,sci:c,eri:f,eci:d}=s.range;const h=s.ri,u=s.ci;let[m,g]=[e,t];return e<0&&(m=i.len-1),t<0&&(g=n.len-1),m>h?[a,f]=[h,m]:[a,f]=[m,h],g>u?[c,d]=[u,g]:[c,d]=[g,u],s.range=l.union(new te(a,c,f,d)),s.range=l.union(s.range),s.range}calSelectedRangeByStart(e,t){const{selector:s,rows:i,cols:n,merges:l}=this;let a=l.getFirstIncludes(e,t);return a===null&&(a=new te(e,t,e,t),e===-1&&(a.sri=0,a.eri=i.len-1),t===-1&&(a.sci=0,a.eci=n.len-1)),s.range=a,a}setSelectedCellAttr(e,t){this.changeData(()=>{const{selector:s,styles:i,rows:n}=this;if(e==="merge")t?this.merge():this.unmerge();else if(e==="border")Xn.call(this,t);else if(e==="formula"){const{ri:l,ci:a,range:c}=s;if(s.multiple()){const[f,d]=s.size(),{sri:h,sci:u,eri:m,eci:g}=c;if(f>1)for(let x=u;x<=g;x+=1){const v=n.getCellOrNew(m+1,x);v.text=`=${t}(${Me(x,h)}:${Me(x,m)})`}else if(d>1){const x=n.getCellOrNew(l,g+1);x.text=`=${t}(${Me(u,l)}:${Me(g,l)})`}}else{const f=n.getCellOrNew(l,a);f.text=`=${t}()`}}else s.range.each((l,a)=>{const c=n.getCellOrNew(l,a);let f={};if(c.style!==void 0&&(f=ce.cloneDeep(i[c.style])),e==="format")f.format=t,c.style=this.addStyle(f);else if(e==="font-bold"||e==="font-italic"||e==="font-name"||e==="font-size"){const d={};d[e.split("-")[1]]=t,f.font=Object.assign(f.font||{},d),c.style=this.addStyle(f)}else e==="strike"||e==="textwrap"||e==="underline"||e==="align"||e==="valign"||e==="color"||e==="bgcolor"?(f[e]=t,c.style=this.addStyle(f)):c[e]=t})})}setSelectedCellText(e,t="input"){const{autoFilter:s,selector:i,rows:n}=this,{ri:l,ci:a}=i;let c=l;this.unsortedRowMap.has(l)&&(c=this.unsortedRowMap.get(l));const f=n.getCell(c,a),d=f?f.text:"";if(this.setCellText(c,a,e,t),s.active()){const h=s.getFilter(a);if(h){const u=h.value.findIndex(m=>m===d);u>=0&&h.value.splice(u,1,e)}}}getSelectedCell(){const{ri:e,ci:t}=this.selector;let s=e;return this.unsortedRowMap.has(e)&&(s=this.unsortedRowMap.get(e)),this.rows.getCell(s,t)}xyInSelectedRect(e,t){const{left:s,top:i,width:n,height:l}=this.getSelectedRect(),a=e-this.cols.indexWidth,c=t-this.rows.height;return a>s&&a<s+n&&c>i&&c<i+l}getSelectedRect(){return this.getRect(this.selector.range)}getClipboardRect(){const{clipboard:e}=this;return e.isClear()?{left:-100,top:-100}:this.getRect(e.range)}getRect(e){const{scroll:t,rows:s,cols:i,exceptRowSet:n}=this,{sri:l,sci:a,eri:c,eci:f}=e;if(l<0&&a<0)return{left:0,l:0,top:0,t:0,scroll:t};const d=i.sumWidth(0,a),h=s.sumHeight(0,l,n),u=s.sumHeight(l,c+1,n),m=i.sumWidth(a,f+1);let g=d-t.x,x=h-t.y;const v=this.freezeTotalHeight(),b=this.freezeTotalWidth();return b>0&&b>d&&(g=d),v>0&&v>h&&(x=h),{l:d,t:h,left:g,top:x,height:u,width:m,scroll:t}}getCellRectByXY(e,t){const{scroll:s,merges:i,rows:n,cols:l}=this;let{ri:a,top:c,height:f}=Zn.call(this,t,s.y),{ci:d,left:h,width:u}=Yn.call(this,e,s.x);if(d===-1&&(u=l.totalWidth()),a===-1&&(f=n.totalHeight()),a>=0||d>=0){const m=i.getFirstIncludes(a,d);m&&(a=m.sri,d=m.sci,{left:h,top:c,width:u,height:f}=this.cellRect(a,d))}return{ri:a,ci:d,left:h,top:c,width:u,height:f}}isSignleSelected(){const{sri:e,sci:t,eri:s,eci:i}=this.selector.range,n=this.getCell(e,t);if(n&&n.merge){const[l,a]=n.merge;if(e+l===s&&t+a===i)return!0}return!this.selector.multiple()}canUnmerge(){const{sri:e,sci:t,eri:s,eci:i}=this.selector.range,n=this.getCell(e,t);if(n&&n.merge){const[l,a]=n.merge;if(e+l===s&&t+a===i)return!0}return!1}merge(){const{selector:e,rows:t}=this;if(this.isSignleSelected())return;const[s,i]=e.size();if(s>1||i>1){const{sri:n,sci:l}=e.range;this.changeData(()=>{const a=t.getCellOrNew(n,l);a.merge=[s-1,i-1],this.merges.add(e.range),this.rows.deleteCells(e.range),this.rows.setCell(n,l,a)})}}unmerge(){const{selector:e}=this;if(!this.isSignleSelected())return;const{sri:t,sci:s}=e.range;this.changeData(()=>{this.rows.deleteCell(t,s,"merge"),this.merges.deleteWithin(e.range)})}canAutofilter(){return!this.autoFilter.active()}autofilter(){const{autoFilter:e,selector:t}=this;this.changeData(()=>{e.active()?(e.clear(),this.exceptRowSet=new Set,this.sortedRowMap=new Map,this.unsortedRowMap=new Map):e.ref=t.range.toString()})}setAutoFilter(e,t,s,i){const{autoFilter:n}=this;n.addFilter(e,s,i),n.setSort(e,t),this.resetAutoFilter()}resetAutoFilter(){const{autoFilter:e,rows:t}=this;if(!e.active())return;const{sort:s}=e,{rset:i,fset:n}=e.filteredRows((c,f)=>t.getCell(c,f)),l=Array.from(n),a=Array.from(n);s&&l.sort((c,f)=>s.order==="asc"?c-f:s.order==="desc"?f-c:0),this.exceptRowSet=i,this.sortedRowMap=new Map,this.unsortedRowMap=new Map,l.forEach((c,f)=>{this.sortedRowMap.set(a[f],c),this.unsortedRowMap.set(c,a[f])})}deleteCell(e="all"){const{selector:t}=this;this.changeData(()=>{this.rows.deleteCells(t.range,e),(e==="all"||e==="format")&&this.merges.deleteWithin(t.range)})}insert(e,t=1){this.changeData(()=>{const{sri:s,sci:i}=this.selector.range,{rows:n,merges:l,cols:a}=this;let c=s;e==="row"?n.insert(s,t):e==="column"&&(n.insertColumn(i,t),c=i,a.len+=1),l.shift(e,c,t,(f,d,h,u)=>{const m=n.getCell(f,d);m.merge[0]+=h,m.merge[1]+=u})})}delete(e){this.changeData(()=>{const{rows:t,merges:s,selector:i,cols:n}=this,{range:l}=i,{sri:a,sci:c,eri:f,eci:d}=i.range,[h,u]=i.range.size();let m=a,g=h;e==="row"?t.delete(a,f):e==="column"&&(t.deleteColumn(c,d),m=l.sci,g=u,n.len-=1),s.shift(e,m,-g,(x,v,b,y)=>{const j=t.getCell(x,v);j.merge[0]+=b,j.merge[1]+=y,j.merge[0]===0&&j.merge[1]===0&&delete j.merge})})}scrollx(e,t){const{scroll:s,freeze:i,cols:n}=this,[,l]=i,[a,c,f]=ce.rangeReduceIf(l,n.len,0,0,e,h=>n.getWidth(h));let d=c;e>0&&(d+=f),s.x!==d&&(s.ci=e>0?a:0,s.x=d,t())}scrolly(e,t){const{scroll:s,freeze:i,rows:n}=this,[l]=i,[a,c,f]=ce.rangeReduceIf(l,n.len,0,0,e,h=>n.getHeight(h));let d=c;e>0&&(d+=f),s.y!==d&&(s.ri=e>0?a:0,s.y=d,t())}cellRect(e,t){const{rows:s,cols:i}=this,n=i.sumWidth(0,t),l=s.sumHeight(0,e),a=s.getCell(e,t);let c=i.getWidth(t),f=s.getHeight(e);if(a!==null&&a.merge){const[d,h]=a.merge;if(d>0)for(let u=1;u<=d;u+=1)f+=s.getHeight(e+u);if(h>0)for(let u=1;u<=h;u+=1)c+=i.getWidth(t+u)}return{left:n,top:l,width:c,height:f,cell:a}}getCell(e,t){return this.rows.getCell(e,t)}getCellTextOrDefault(e,t){const s=this.getCell(e,t);return s&&s.text?s.text:""}getCellStyle(e,t){const s=this.getCell(e,t);return s&&s.style!==void 0?this.styles[s.style]:null}getCellStyleOrDefault(e,t){const{styles:s,rows:i}=this,n=i.getCell(e,t),l=n&&n.style!==void 0?s[n.style]:{};return ce.merge(this.defaultStyle(),l)}getSelectedCellStyle(){const{ri:e,ci:t}=this.selector;return this.getCellStyleOrDefault(e,t)}setCellText(e,t,s,i){const{rows:n,history:l,validations:a}=this;i==="finished"?(n.setCellText(e,t,""),l.add(this.getData()),n.setCellText(e,t,s)):(n.setCellText(e,t,s),this.change(this.getData())),a.validate(e,t,s)}freezeIsActive(){const[e,t]=this.freeze;return e>0||t>0}setFreeze(e,t){this.changeData(()=>{this.freeze=[e,t]})}freezeTotalWidth(){return this.cols.sumWidth(0,this.freeze[1])}freezeTotalHeight(){return this.rows.sumHeight(0,this.freeze[0])}setRowHeight(e,t){this.changeData(()=>{this.rows.setHeight(e,t)})}setColWidth(e,t){this.changeData(()=>{this.cols.setWidth(e,t)})}viewHeight(){const{view:e,showToolbar:t,showBottomBar:s}=this.settings;let i=e.height();return s&&(i-=Un),t&&(i-=qn),i}viewWidth(){return this.settings.view.width()}freezeViewRange(){const[e,t]=this.freeze;return new te(0,0,e-1,t-1,this.freezeTotalWidth(),this.freezeTotalHeight())}contentRange(){const{rows:e,cols:t}=this,[s,i]=e.maxCell(),n=e.sumHeight(0,s+1),l=t.sumWidth(0,i+1);return new te(0,0,s,i,l,n)}exceptRowTotalHeight(e,t){const{exceptRowSet:s,rows:i}=this,n=Array.from(s);let l=0;return n.forEach(a=>{if(a<e||a>t){const c=i.getHeight(a);l+=c}}),l}viewRange(){const{scroll:e,rows:t,cols:s,freeze:i,exceptRowSet:n}=this;let{ri:l,ci:a}=e;l<=0&&([l]=i),a<=0&&([,a]=i);let[c,f]=[0,0],[d,h]=[t.len,s.len];for(let u=l;u<t.len&&(n.has(u)||(f+=t.getHeight(u),d=u),!(f>this.viewHeight()));u+=1);for(let u=a;u<s.len&&(c+=s.getWidth(u),h=u,!(c>this.viewWidth()));u+=1);return new te(l,a,d,h,c,f)}eachMergesInView(e,t){this.merges.filterIntersects(e).forEach(s=>t(s))}hideRowsOrCols(){const{rows:e,cols:t,selector:s}=this,[i,n]=s.size(),{sri:l,sci:a,eri:c,eci:f}=s.range;if(i===e.len)for(let d=a;d<=f;d+=1)t.setHide(d,!0);else if(n===t.len)for(let d=l;d<=c;d+=1)e.setHide(d,!0)}unhideRowsOrCols(e,t){this[`${e}s`].unhide(t)}rowEach(e,t,s){let i=0;const{rows:n}=this,l=this.exceptRowSet,a=[...l];let c=0;for(let f=0;f<a.length;f+=1)a[f]<e&&(c+=1);for(let f=e+c;f<=t+c;f+=1)if(l.has(f))c+=1;else{const d=n.getHeight(f);if(d>0&&(s(f,i,d),i+=d,i>this.viewHeight()))break}}colEach(e,t,s){let i=0;const{cols:n}=this;for(let l=e;l<=t;l+=1){const a=n.getWidth(l);if(a>0&&(s(l,i,a),i+=a,i>this.viewWidth()))break}}defaultStyle(){return this.settings.style}addStyle(e){const{styles:t}=this;for(let s=0;s<t.length;s+=1){const i=t[s];if(ce.equals(i,e))return s}return t.push(e),t.length-1}changeData(e){this.history.add(this.getData()),e(),this.change(this.getData())}setData(e){return Object.keys(e).forEach(t=>{if(t==="merges"||t==="rows"||t==="cols"||t==="validations")this[t].setData(e[t]);else if(t==="freeze"){const[s,i]=Oe(e[t]);this.freeze=[i,s]}else t==="autofilter"?this.autoFilter.setData(e[t]):e[t]!==void 0&&(this[t]=e[t])}),this}getData(){const{name:e,freeze:t,styles:s,merges:i,rows:n,cols:l,validations:a,autoFilter:c}=this;return{name:e,freeze:Me(t[1],t[0]),styles:s,merges:i.getData(),rows:n.getData(),cols:l.getData(),validations:a.getData(),autofilter:c.getData()}}}function de(r,e,t){r.addEventListener(e,t)}function St(r,e,t){r.removeEventListener(e,t)}function et(r){r.xclickoutside&&(St(window.document.body,"click",r.xclickoutside),delete r.xclickoutside)}function ot(r,e){r.xclickoutside=t=>{t.detail===2||r.contains(t.target)||(e?e(r):(r.hide(),et(r)))},de(window.document.body,"click",r.xclickoutside)}function bs(r,e,t){de(r,"mousemove",e);const s=r;s.xEvtUp=i=>{St(r,"mousemove",e),St(r,"mouseup",r.xEvtUp),t(i)},de(r,"mouseup",r.xEvtUp)}function Dr(r,e,t,s){let i="";Math.abs(r)>Math.abs(e)?(i=r>0?"right":"left",s(i,r,t)):(i=e>0?"down":"up",s(i,e,t))}function Kn(r,{move:e,end:t}){let s=0,i=0;de(r,"touchstart",n=>{const{pageX:l,pageY:a}=n.touches[0];s=l,i=a}),de(r,"touchmove",n=>{if(!e)return;const{pageX:l,pageY:a}=n.changedTouches[0],c=l-s,f=a-i;(Math.abs(c)>10||Math.abs(f)>10)&&(Dr(c,f,n,e),s=l,i=a),n.preventDefault()}),de(r,"touchend",n=>{if(!t)return;const{pageX:l,pageY:a}=n.changedTouches[0],c=l-s,f=a-i;Dr(c,f,n,t)})}function Qn(){const r=new Map;function e(l,a){const c=()=>{const d=r.get(l);return Array.isArray(d)&&d.push(a)||!1},f=()=>r.set(l,[].concat(a));return r.has(l)&&c()||f()}function t(l,a){const c=()=>{const f=r.get(l);for(const d of f)d.call(null,...a)};return r.has(l)&&c()}function s(l,a){const c=()=>{const f=r.get(l),d=f.indexOf(a);return d>=0&&f.splice(d,1)&&r.get(l).length===0&&r.delete(l)};return r.has(l)&&c()}function i(l,a){const c=(...f)=>{a.call(null,...f),s(l,c)};return e(l,c)}function n(){r.clear()}return{get current(){return r},on:e,once:i,fire:t,removeListener:s,removeAllListeners:n}}const C="x-spreadsheet";class Pr{constructor(e=!1,t){this.moving=!1,this.vertical=e,this.el=w("div",`${C}-resizer ${e?"vertical":"horizontal"}`).children(this.unhideHoverEl=w("div",`${C}-resizer-hover`).on("dblclick.stop",s=>this.mousedblclickHandler(s)).css("position","absolute").hide(),this.hoverEl=w("div",`${C}-resizer-hover`).on("mousedown.stop",s=>this.mousedownHandler(s)),this.lineEl=w("div",`${C}-resizer-line`).hide()).hide(),this.cRect=null,this.finishedFn=null,this.minDistance=t,this.unhideFn=()=>{}}showUnhide(e){this.unhideIndex=e,this.unhideHoverEl.show()}hideUnhide(){this.unhideHoverEl.hide()}show(e,t){const{moving:s,vertical:i,hoverEl:n,lineEl:l,el:a,unhideHoverEl:c}=this;if(s)return;this.cRect=e;const{left:f,top:d,width:h,height:u}=e;a.offset({left:i?f+h-5:f,top:i?d:d+u-5}).show(),n.offset({width:i?5:h,height:i?u:5}),l.offset({width:i?0:t.width,height:i?t.height:0}),c.offset({left:i?5-h:f,top:i?d:5-u,width:i?5:h,height:i?u:5})}hide(){this.el.offset({left:0,top:0}).hide(),this.hideUnhide()}mousedblclickHandler(){this.unhideIndex&&this.unhideFn(this.unhideIndex)}mousedownHandler(e){let t=e;const{el:s,lineEl:i,cRect:n,vertical:l,minDistance:a}=this;let c=l?n.width:n.height;i.show(),bs(window,f=>{this.moving=!0,t!==null&&f.buttons===1&&(l?(c+=f.movementX,c>a&&s.css("left",`${n.left+c}px`)):(c+=f.movementY,c>a&&s.css("top",`${n.top+c}px`)),t=f)},()=>{t=null,i.hide(),this.moving=!1,this.hide(),this.finishedFn&&(c<a&&(c=a),this.finishedFn(n,c))})}}class Or{constructor(e){this.vertical=e,this.moveFn=null,this.el=w("div",`${C}-scrollbar ${e?"vertical":"horizontal"}`).child(this.contentEl=w("div","")).on("mousemove.stop",()=>{}).on("scroll.stop",t=>{const{scrollTop:s,scrollLeft:i}=t.target;this.moveFn&&this.moveFn(this.vertical?s:i,t)})}move(e){return this.el.scroll(e),this}scroll(){return this.el.scroll()}set(e,t){const s=e-1;if(t>s){const i=this.vertical?"height":"width";this.el.css(i,`${s-15}px`).show(),this.contentEl.css(this.vertical?"width":"height","1px").css(i,`${t}px`)}else this.el.hide();return this}}const ut=2*2-1;let qt=10;class mt{constructor(e=!1){this.useHideInput=e,this.inputChange=()=>{},this.cornerEl=w("div",`${C}-selector-corner`),this.areaEl=w("div",`${C}-selector-area`).child(this.cornerEl).hide(),this.clipboardEl=w("div",`${C}-selector-clipboard`).hide(),this.autofillEl=w("div",`${C}-selector-autofill`).hide(),this.el=w("div",`${C}-selector`).css("z-index",`${qt}`).children(this.areaEl,this.clipboardEl,this.autofillEl).hide(),e&&(this.hideInput=w("input","").on("compositionend",t=>{this.inputChange(t.target.value)}),this.el.child(this.hideInputDiv=w("div","hide-input").child(this.hideInput)),this.el.child(this.hideInputDiv=w("div","hide-input").child(this.hideInput))),qt+=1}setOffset(e){return this.el.offset(e).show(),this}hide(){return this.el.hide(),this}setAreaOffset(e){const{left:t,top:s,width:i,height:n}=e,l={width:i-ut+.8,height:n-ut+.8,left:t-.8,top:s-.8};this.areaEl.offset(l).show(),this.useHideInput&&(this.hideInputDiv.offset(l),this.hideInput.val("").focus())}setClipboardOffset(e){const{left:t,top:s,width:i,height:n}=e;this.clipboardEl.offset({left:t,top:s,width:i-5,height:n-5})}showAutofill(e){const{left:t,top:s,width:i,height:n}=e;this.autofillEl.offset({width:i-ut,height:n-ut,left:t,top:s}).show()}hideAutofill(){this.autofillEl.hide()}showClipboard(){this.clipboardEl.show()}hideClipboard(){this.clipboardEl.hide()}}function rr(r){const{data:e}=this,{left:t,top:s,width:i,height:n,scroll:l,l:a,t:c}=r,f=e.freezeTotalWidth(),d=e.freezeTotalHeight();let h=t-f;f>a&&(h-=l.x);let u=s-d;return d>c&&(u-=l.y),{left:h,top:u,width:i,height:n}}function sr(r){const{data:e}=this,{left:t,width:s,height:i,l:n,t:l,scroll:a}=r,c=e.freezeTotalWidth();let f=t-c;return c>n&&(f-=a.x),{left:f,top:l,width:s,height:i}}function ir(r){const{data:e}=this,{top:t,width:s,height:i,l:n,t:l,scroll:a}=r,c=e.freezeTotalHeight();let f=t-c;return c>l&&(f-=a.y),{left:n,top:f,width:s,height:i}}function Ut(r){const{br:e}=this;e.setAreaOffset(rr.call(this,r))}function el(r){const{tl:e}=this;e.setAreaOffset(r)}function ws(r){const{t:e}=this;e.setAreaOffset(sr.call(this,r))}function vs(r){const{l:e}=this;e.setAreaOffset(ir.call(this,r))}function ys(r){const{l:e}=this;e.setClipboardOffset(ir.call(this,r))}function Gt(r){const{br:e}=this;e.setClipboardOffset(rr.call(this,r))}function tl(r){const{tl:e}=this;e.setClipboardOffset(r)}function js(r){const{t:e}=this;e.setClipboardOffset(sr.call(this,r))}function Lr(r){Ut.call(this,r),el.call(this,r),ws.call(this,r),vs.call(this,r)}function Ir(r){Gt.call(this,r),tl.call(this,r),js.call(this,r),ys.call(this,r)}class rl{constructor(e){this.inputChange=()=>{},this.data=e,this.br=new mt(!0),this.t=new mt,this.l=new mt,this.tl=new mt,this.br.inputChange=t=>{this.inputChange(t)},this.br.el.show(),this.offset=null,this.areaOffset=null,this.indexes=null,this.range=null,this.arange=null,this.el=w("div",`${C}-selectors`).children(this.tl.el,this.t.el,this.l.el,this.br.el).hide(),this.lastri=-1,this.lastci=-1,qt+=1}resetData(e){this.data=e,this.range=e.selector.range,this.resetAreaOffset()}hide(){this.el.hide()}resetOffset(){const{data:e,tl:t,t:s,l:i,br:n}=this,l=e.freezeTotalHeight(),a=e.freezeTotalWidth();l>0||a>0?(t.setOffset({width:a,height:l}),s.setOffset({left:a,height:l}),i.setOffset({top:l,width:a}),n.setOffset({left:a,top:l})):(t.hide(),s.hide(),i.hide(),n.setOffset({left:0,top:0}))}resetAreaOffset(){const e=this.data.getSelectedRect(),t=this.data.getClipboardRect();Lr.call(this,e),Ir.call(this,t),this.resetOffset()}resetBRTAreaOffset(){const e=this.data.getSelectedRect(),t=this.data.getClipboardRect();Ut.call(this,e),ws.call(this,e),Gt.call(this,t),js.call(this,t),this.resetOffset()}resetBRLAreaOffset(){const e=this.data.getSelectedRect(),t=this.data.getClipboardRect();Ut.call(this,e),vs.call(this,e),Gt.call(this,t),ys.call(this,t),this.resetOffset()}set(e,t,s=!0){const{data:i}=this,n=i.calSelectedRangeByStart(e,t),{sri:l,sci:a}=n;if(s){let[c,f]=[e,t];e<0&&(c=0),t<0&&(f=0),i.selector.setIndexes(c,f),this.indexes=[c,f]}this.moveIndexes=[l,a],this.range=n,this.resetAreaOffset(),this.el.show()}setEnd(e,t,s=!0){const{data:i,lastri:n,lastci:l}=this;if(s){if(e===n&&t===l)return;this.lastri=e,this.lastci=t}this.range=i.calSelectedRangeByEnd(e,t),Lr.call(this,this.data.getSelectedRect())}reset(){const{eri:e,eci:t}=this.data.selector.range;this.setEnd(e,t)}showAutofill(e,t){if(e===-1&&t===-1)return;const{sri:s,sci:i,eri:n,eci:l}=this.range,[a,c]=[e,t],f=s-e,d=i-t,h=n-e,u=l-t;if(d>0)this.arange=new te(s,c,n,i-1);else if(f>0)this.arange=new te(a,i,s-1,l);else if(u<0)this.arange=new te(s,l+1,n,c);else if(h<0)this.arange=new te(n+1,i,a,l);else{this.arange=null;return}if(this.arange!==null){const m=this.data.getRect(this.arange);m.width+=2,m.height+=2;const{br:g,l:x,t:v,tl:b}=this;g.showAutofill(rr.call(this,m)),x.showAutofill(ir.call(this,m)),v.showAutofill(sr.call(this,m)),b.showAutofill(m)}}hideAutofill(){["br","l","t","tl"].forEach(e=>{this[e].hideAutofill()})}showClipboard(){const e=this.data.getClipboardRect();Ir.call(this,e),["br","l","t","tl"].forEach(t=>{this[t].showClipboard()})}hideClipboard(){["br","l","t","tl"].forEach(e=>{this[e].hideClipboard()})}}function sl(r){r.preventDefault(),r.stopPropagation();const{filterItems:e}=this;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex-=1,this.itemIndex<0&&(this.itemIndex=e.length-1),e[this.itemIndex].toggle())}function il(r){r.stopPropagation();const{filterItems:e}=this;e.length<=0||(this.itemIndex>=0&&e[this.itemIndex].toggle(),this.itemIndex+=1,this.itemIndex>e.length-1&&(this.itemIndex=0),e[this.itemIndex].toggle())}function Ar(r){r.preventDefault();const{filterItems:e}=this;e.length<=0||(r.stopPropagation(),this.itemIndex<0&&(this.itemIndex=0),e[this.itemIndex].el.click(),this.hide())}function nl(r){const{keyCode:e}=r;switch(r.ctrlKey&&r.stopPropagation(),e){case 37:r.stopPropagation();break;case 38:sl.call(this,r);break;case 39:r.stopPropagation();break;case 40:il.call(this,r);break;case 13:Ar.call(this,r);break;case 9:Ar.call(this,r);break;default:r.stopPropagation();break}}class ks{constructor(e,t,s="200px"){this.filterItems=[],this.items=e,this.el=w("div",`${C}-suggest`).css("width",s).hide(),this.itemClick=t,this.itemIndex=-1}setOffset(e){this.el.cssRemoveKeys("top","bottom").offset(e)}hide(){const{el:e}=this;this.filterItems=[],this.itemIndex=-1,e.hide(),et(this.el.parent())}setItems(e){this.items=e}search(e){let{items:t}=this;if(/^\s*$/.test(e)||(t=t.filter(i=>(i.key||i).startsWith(e.toUpperCase()))),t=t.map(i=>{let{title:n}=i;n?typeof n=="function"&&(n=n()):n=i;const l=w("div",`${C}-item`).child(n).on("click.stop",()=>{this.itemClick(i),this.hide()});return i.label&&l.child(w("div","label").html(i.label)),l}),this.filterItems=t,t.length<=0)return;const{el:s}=this;s.html("").children(...t).show(),ot(s.parent(),()=>{this.hide()})}bindInputEvents(e){e.on("keydown",t=>nl.call(this,t))}}class oe extends We{constructor(e){super("div",`${C}-icon`),this.iconNameEl=w("div",`${C}-icon-img ${e}`),this.child(this.iconNameEl)}setName(e){this.iconNameEl.className(`${C}-icon-img ${e}`)}}function Hr(r,e){r.setMonth(r.getMonth()+e)}function ll(r,e){const t=new Date(r);return t.setDate(e-r.getDay()+1),t}function ol(r,e,t){const s=new Date(r,e,1,23,59,59),i=[[],[],[],[],[],[]];for(let n=0;n<6;n+=1)for(let l=0;l<7;l+=1){const a=n*7+l,c=ll(s,a),f=c.getMonth()!==e,d=c.getMonth()===t.getMonth()&&c.getDate()===t.getDate();i[n][l]={d:c,disabled:f,active:d}}return i}class al{constructor(e){this.value=e,this.cvalue=new Date(e),this.headerLeftEl=w("div","calendar-header-left"),this.bodyEl=w("tbody",""),this.buildAll(),this.el=w("div","x-spreadsheet-calendar").children(w("div","calendar-header").children(this.headerLeftEl,w("div","calendar-header-right").children(w("a","calendar-prev").on("click.stop",()=>this.prev()).child(new oe("chevron-left")),w("a","calendar-next").on("click.stop",()=>this.next()).child(new oe("chevron-right")))),w("table","calendar-body").children(w("thead","").child(w("tr","").children(...se("calendar.weeks").map(t=>w("th","cell").child(t)))),this.bodyEl)),this.selectChange=()=>{}}setValue(e){this.value=e,this.cvalue=new Date(e),this.buildAll()}prev(){const{value:e}=this;Hr(e,-1),this.buildAll()}next(){const{value:e}=this;Hr(e,1),this.buildAll()}buildAll(){this.buildHeaderLeft(),this.buildBody()}buildHeaderLeft(){const{value:e}=this;this.headerLeftEl.html(`${se("calendar.months")[e.getMonth()]} ${e.getFullYear()}`)}buildBody(){const{value:e,cvalue:t,bodyEl:s}=this,n=ol(e.getFullYear(),e.getMonth(),t).map(l=>{const a=l.map(c=>{let f="cell";return c.disabled&&(f+=" disabled"),c.active&&(f+=" active"),w("td","").child(w("div",f).on("click.stop",()=>{this.selectChange(c.d)}).child(c.d.getDate().toString()))});return w("tr","").children(...a)});s.html("").children(...n)}}class cl{constructor(){this.calendar=new al(new Date),this.el=w("div",`${C}-datepicker`).child(this.calendar.el).hide()}setValue(e){const{calendar:t}=this;return typeof e=="string"?/^\d{4}-\d{1,2}-\d{1,2}$/.test(e)&&t.setValue(new Date(e.replace(new RegExp("-","g"),"/"))):e instanceof Date&&t.setValue(e),this}change(e){this.calendar.selectChange=t=>{e(t),this.hide()}}show(){this.el.show()}hide(){this.el.hide()}}function Ct(){const{inputText:r}=this;if(!/^\s*$/.test(r)){const{textlineEl:e,textEl:t,areaOffset:s}=this,i=r.split(`
|
|
22
|
-
`),n=Math.max(...i.map(h=>h.length)),a=e.offset().width/r.length,c=(n+1)*a+5,f=this.viewFn().width-s.left-a;let d=i.length;if(c>s.width){let h=c;c>f&&(h=f,d+=parseInt(c/f,10),d+=c%f>0?1:0),t.css("width",`${h}px`)}d*=this.rowHeight,d>s.height&&t.css("height",`${d}px`)}}function fl({target:r},e){const{value:t,selectionEnd:s}=r,i=`${t.slice(0,s)}${e}${t.slice(s)}`;r.value=i,r.setSelectionRange(s+1,s+1),this.inputText=i,this.textlineEl.html(i),Ct.call(this)}function dl(r){const{keyCode:e,altKey:t}=r;e!==13&&e!==9&&r.stopPropagation(),e===13&&t&&(fl.call(this,r,`
|
|
23
|
-
`),r.stopPropagation()),e===13&&!t&&r.preventDefault()}function hl(r){const e=r.target.value,{suggest:t,textlineEl:s,validator:i}=this,{cell:n}=this;if(n!==null)if("editable"in n&&n.editable===!0||n.editable===void 0){if(this.inputText=e,i)i.type==="list"?t.search(e):t.hide();else{const l=e.lastIndexOf("=");l!==-1?t.search(e.substring(l+1)):t.hide()}s.html(e),Ct.call(this),this.change("input",e)}else r.target.value=n.text;else{if(this.inputText=e,i)i.type==="list"?t.search(e):t.hide();else{const l=e.lastIndexOf("=");l!==-1?t.search(e.substring(l+1)):t.hide()}s.html(e),Ct.call(this),this.change("input",e)}}function pl(r){const{el:e}=this.textEl;setTimeout(()=>{e.focus(),e.setSelectionRange(r,r)},0)}function Ss(r,e){const{textEl:t,textlineEl:s}=this;t.el.blur(),t.val(r),s.html(r),pl.call(this,e)}function ul(r){const{inputText:e,validator:t}=this;let s=0;if(t&&t.type==="list")this.inputText=r,s=this.inputText.length;else{const i=e.lastIndexOf("="),n=e.substring(0,i+1);let l=e.substring(i+1);l.indexOf(")")!==-1?l=l.substring(l.indexOf(")")):l="",this.inputText=`${n+r.key}(`,s=this.inputText.length,this.inputText+=`)${l}`}Ss.call(this,this.inputText,s)}function ml(){this.suggest.setItems(this.formulas)}function gl(r){let e=r.getMonth()+1,t=r.getDate();return e<10&&(e=`0${e}`),t<10&&(t=`0${t}`),`${r.getFullYear()}-${e}-${t}`}class xl{constructor(e,t,s){this.viewFn=t,this.rowHeight=s,this.formulas=e,this.suggest=new ks(e,i=>{ul.call(this,i)}),this.datepicker=new cl,this.datepicker.change(i=>{this.setText(gl(i)),this.clear()}),this.areaEl=w("div",`${C}-editor-area`).children(this.textEl=w("textarea","").on("input",i=>hl.call(this,i)).on("paste.stop",()=>{}).on("keydown",i=>dl.call(this,i)),this.textlineEl=w("div","textline"),this.suggest.el,this.datepicker.el).on("mousemove.stop",()=>{}).on("mousedown.stop",()=>{}),this.el=w("div",`${C}-editor`).child(this.areaEl).hide(),this.suggest.bindInputEvents(this.textEl),this.areaOffset=null,this.freeze={w:0,h:0},this.cell=null,this.inputText="",this.change=()=>{}}setFreezeLengths(e,t){this.freeze.w=e,this.freeze.h=t}clear(){this.inputText!==""&&this.change("finished",this.inputText),this.cell=null,this.areaOffset=null,this.inputText="",this.el.hide(),this.textEl.val(""),this.textlineEl.html(""),ml.call(this),this.datepicker.hide()}setOffset(e,t="top"){const{textEl:s,areaEl:i,suggest:n,freeze:l,el:a}=this;if(e){this.areaOffset=e;const{left:c,top:f,width:d,height:h,l:u,t:m}=e,g={left:0,top:0};l.w>u&&l.h>m||(l.w<u&&l.h<m?(g.left=l.w,g.top=l.h):l.w>u?g.top=l.h:l.h>m&&(g.left=l.w)),a.offset(g),i.offset({left:c-g.left-.8,top:f-g.top-.8}),s.offset({width:d-9+.8,height:h-3+.8});const x={left:0};x[t]=h,n.setOffset(x),n.hide()}}setCell(e,t){const{el:s,datepicker:i,suggest:n}=this;s.show(),this.cell=e;const l=e&&e.text||"";if(this.setText(l),this.validator=t,t){const{type:a}=t;a==="date"&&(i.show(),/^\s*$/.test(l)||i.setValue(l)),a==="list"&&(n.setItems(t.values()),n.search(""))}}setText(e){this.inputText=e,Ss.call(this,e,e.length),Ct.call(this)}}class Ae extends We{constructor(e,t=""){super("div",`${C}-button ${t}`),this.child(se(`button.${e}`))}}function Nt(){return window.devicePixelRatio||1}function nr(){return Nt()-.5}function I(r){return parseInt(r*Nt(),10)}function Ze(r){const e=I(r);return e>0?e-.5:.5}class bl{constructor(e,t,s,i,n=0){this.x=e,this.y=t,this.width=s,this.height=i,this.padding=n,this.bgcolor="#ffffff",this.borderTop=null,this.borderRight=null,this.borderBottom=null,this.borderLeft=null}setBorders({top:e,bottom:t,left:s,right:i}){e&&(this.borderTop=e),i&&(this.borderRight=i),t&&(this.borderBottom=t),s&&(this.borderLeft=s)}innerWidth(){return this.width-this.padding*2-2}innerHeight(){return this.height-this.padding*2-2}textx(e){const{width:t,padding:s}=this;let{x:i}=this;return e==="left"?i+=s:e==="center"?i+=t/2:e==="right"&&(i+=t-s),i}texty(e,t){const{height:s,padding:i}=this;let{y:n}=this;return e==="top"?n+=i:e==="middle"?n+=s/2-t/2:e==="bottom"&&(n+=s-i-t),n}topxys(){const{x:e,y:t,width:s}=this;return[[e,t],[e+s,t]]}rightxys(){const{x:e,y:t,width:s,height:i}=this;return[[e+s,t],[e+s,t+i]]}bottomxys(){const{x:e,y:t,width:s,height:i}=this;return[[e,t+i],[e+s,t+i]]}leftxys(){const{x:e,y:t,height:s}=this;return[[e,t],[e,t+s]]}}function Wr(r,e,t,s,i,n,l){const a={x:0,y:0};r==="underline"?i==="bottom"?a.y=0:i==="top"?a.y=-(n+2):a.y=-n/2:r==="strike"&&(i==="bottom"?a.y=n/2:i==="top"&&(a.y=-(n/2+2))),s==="center"?a.x=l/2:s==="right"&&(a.x=l),this.line([e-a.x,t-a.y],[e-a.x+l,t-a.y])}class Cs{constructor(e,t,s){this.el=e,this.ctx=e.getContext("2d"),this.resize(t,s),this.ctx.scale(Nt(),Nt())}resize(e,t){this.el.style.width=`${e}px`,this.el.style.height=`${t}px`,this.el.width=I(e),this.el.height=I(t)}clear(){const{width:e,height:t}=this.el;return this.ctx.clearRect(0,0,e,t),this}attr(e){return Object.assign(this.ctx,e),this}save(){return this.ctx.save(),this.ctx.beginPath(),this}restore(){return this.ctx.restore(),this}beginPath(){return this.ctx.beginPath(),this}translate(e,t){return this.ctx.translate(I(e),I(t)),this}scale(e,t){return this.ctx.scale(e,t),this}clearRect(e,t,s,i){return this.ctx.clearRect(e,t,s,i),this}fillRect(e,t,s,i){return this.ctx.fillRect(I(e)-.5,I(t)-.5,I(s),I(i)),this}fillText(e,t,s){return this.ctx.fillText(e,I(t),I(s)),this}text(e,t,s={},i=!0){const{ctx:n}=this,{align:l,valign:a,font:c,color:f,strike:d,underline:h}=s,u=t.textx(l);n.save(),n.beginPath(),this.attr({textAlign:l,textBaseline:a,font:`${c.italic?"italic":""} ${c.bold?"bold":""} ${I(c.size)}px ${c.name}`,fillStyle:f,strokeStyle:f});const m=`${e}`.split(`
|
|
24
|
-
`),g=t.innerWidth(),x=[];m.forEach(y=>{const j=n.measureText(y).width;if(i&&j>I(g)){let k={w:0,len:0,start:0};for(let N=0;N<y.length;N+=1)k.w>=I(g)&&(x.push(y.substr(k.start,k.len)),k={w:0,len:0,start:N}),k.len+=1,k.w+=n.measureText(y[N]).width+1;k.len>0&&x.push(y.substr(k.start,k.len))}else x.push(y)});const v=(x.length-1)*(c.size+2);let b=t.texty(a,v);return x.forEach(y=>{const j=n.measureText(y).width;this.fillText(y,u,b),d&&Wr.call(this,"strike",u,b,l,a,c.size,j),h&&Wr.call(this,"underline",u,b,l,a,c.size,j),b+=c.size+2}),n.restore(),this}border(e,t){const{ctx:s}=this;return s.lineWidth=nr,s.strokeStyle=t,e==="medium"?s.lineWidth=I(2)-.5:e==="thick"?s.lineWidth=I(3):e==="dashed"?s.setLineDash([I(3),I(2)]):e==="dotted"?s.setLineDash([I(1),I(1)]):e==="double"&&s.setLineDash([I(2),0]),this}line(...e){const{ctx:t}=this;if(e.length>1){t.beginPath();const[s,i]=e[0];t.moveTo(Ze(s),Ze(i));for(let n=1;n<e.length;n+=1){const[l,a]=e[n];t.lineTo(Ze(l),Ze(a))}t.stroke()}return this}strokeBorders(e){const{ctx:t}=this;t.save();const{borderTop:s,borderRight:i,borderBottom:n,borderLeft:l}=e;s&&(this.border(...s),this.line(...e.topxys())),i&&(this.border(...i),this.line(...e.rightxys())),n&&(this.border(...n),this.line(...e.bottomxys())),l&&(this.border(...l),this.line(...e.leftxys())),t.restore()}dropdown(e){const{ctx:t}=this,{x:s,y:i,width:n,height:l}=e,a=s+n-15,c=i+l-15;t.save(),t.beginPath(),t.moveTo(I(a),I(c)),t.lineTo(I(a+8),I(c)),t.lineTo(I(a+4),I(c+6)),t.closePath(),t.fillStyle="rgba(0, 0, 0, .45)",t.fill(),t.restore()}error(e){const{ctx:t}=this,{x:s,y:i,width:n}=e,l=s+n-1;t.save(),t.beginPath(),t.moveTo(I(l-8),I(i-1)),t.lineTo(I(l),I(i-1)),t.lineTo(I(l),I(i+8)),t.closePath(),t.fillStyle="rgba(255, 0, 0, .65)",t.fill(),t.restore()}frozen(e){const{ctx:t}=this,{x:s,y:i,width:n}=e,l=s+n-1;t.save(),t.beginPath(),t.moveTo(I(l-8),I(i-1)),t.lineTo(I(l),I(i-1)),t.lineTo(I(l),I(i+8)),t.closePath(),t.fillStyle="rgba(0, 255, 0, .85)",t.fill(),t.restore()}rect(e,t){const{ctx:s}=this,{x:i,y:n,width:l,height:a,bgcolor:c}=e;s.save(),s.beginPath(),s.fillStyle=c||"#fff",s.rect(Ze(i+1),Ze(n+1),I(l-2),I(a-2)),s.clip(),s.fill(),t(),s.restore()}}const Br=[{key:"Arial",title:"Arial"},{key:"Helvetica",title:"Helvetica"},{key:"Source Sans Pro",title:"Source Sans Pro"},{key:"Comic Sans MS",title:"Comic Sans MS"},{key:"Courier New",title:"Courier New"},{key:"Verdana",title:"Verdana"},{key:"Lato",title:"Lato"}],Xt=[{pt:7.5,px:10},{pt:8,px:11},{pt:9,px:12},{pt:10,px:13},{pt:10.5,px:14},{pt:11,px:15},{pt:12,px:16},{pt:14,px:18.7},{pt:15,px:20},{pt:16,px:21.3},{pt:18,px:24},{pt:22,px:29.3},{pt:24,px:32},{pt:26,px:34.7},{pt:36,px:48},{pt:42,px:56}];function wl(r){for(let e=0;e<Xt.length;e+=1){const t=Xt[e];if(t.pt===r)return t.px}return r}const vl=r=>{const e=[],t=[];let s=[],i=0,n="",l=1,a="";for(let c=0;c<r.length;c+=1){const f=r.charAt(c);if(f!==" "){if(f>="a"&&f<="z")s.push(f.toUpperCase());else if(f>="0"&&f<="9"||f>="A"&&f<="Z"||f===".")s.push(f);else if(f==='"'){for(c+=1;r.charAt(c)!=='"';)s.push(r.charAt(c)),c+=1;t.push(`"${s.join("")}`),s=[]}else if(f==="-"&&/[+\-*/,(]/.test(a))s.push(f);else{if(f!=="("&&s.length>0&&t.push(s.join("")),f===")"){let d=e.pop();if(i===2)try{const[h,u]=Oe(t.pop()),[m,g]=Oe(t.pop());let x=0;for(let v=m;v<=h;v+=1)for(let b=g;b<=u;b+=1)t.push(Me(v,b)),x+=1;t.push([d,x])}catch{}else if(i===1||i===3)i===3&&t.push(n),t.push([d,l]),l=1;else for(;d!=="("&&(t.push(d),!(e.length<=0));)d=e.pop();i=0}else if(f==="="||f===">"||f==="<"){const d=r.charAt(c+1);n=f,(d==="="||d==="-")&&(n+=d,c+=1),i=3}else if(f===":")i=2;else if(f===",")i===3&&t.push(n),i=1,l+=1;else if(f==="("&&s.length>0)e.push(s.join(""));else{if(e.length>0&&(f==="+"||f==="-")){let d=e[e.length-1];if(d!=="("&&t.push(e.pop()),d==="*"||d==="/")for(;e.length>0&&(d=e[e.length-1],d!=="(");)t.push(e.pop())}else if(e.length>0){const d=e[e.length-1];(d==="*"||d==="/")&&t.push(e.pop())}e.push(f)}s=[]}a=f}}for(s.length>0&&t.push(s.join(""));e.length>0;)t.push(e.pop());return t},yl=(r,e)=>{const[t]=r;let s=r;if(t==='"')return r.substring(1);let i=1;if(t==="-"&&(s=r.substring(1),i=-1),s[0]>="0"&&s[0]<="9")return i*Number(s);const[n,l]=Oe(s);return i*e(n,l)},jl=(r,e,t,s)=>{const i=[];for(let n=0;n<r.length;n+=1){const l=r[n],a=l[0];if(l==="+"){const c=i.pop();i.push(Ie("+",i.pop(),c))}else if(l==="-")if(i.length===1){const c=i.pop();i.push(Ie("*",c,-1))}else{const c=i.pop();i.push(Ie("-",i.pop(),c))}else if(l==="*")i.push(Ie("*",i.pop(),i.pop()));else if(l==="/"){const c=i.pop();i.push(Ie("/",i.pop(),c))}else if(a==="="||a===">"||a==="<"){let c=i.pop();Number.isNaN(c)||(c=Number(c));let f=i.pop();Number.isNaN(f)||(f=Number(f));let d=!1;a==="="?d=f===c:l===">"?d=f>c:l===">="?d=f>=c:l==="<"?d=f<c:l==="<="&&(d=f<=c),i.push(d)}else if(Array.isArray(l)){const[c,f]=l,d=[];for(let h=0;h<f;h+=1)d.push(i.pop());i.push(e[c].render(d.reverse()))}else{if(s.includes(l))return 0;(a>="a"&&a<="z"||a>="A"&&a<="Z")&&s.push(l),i.push(yl(l,t)),s.pop()}}return i[0]},Ns=(r,e,t,s=[])=>{if(r[0]==="="){const i=vl(r.substring(1));return i.length<=0?r:jl(i,e,(n,l)=>Ns(t(n,l),e,t,s),s)}return r},kl={render:Ns},lr=[{key:"SUM",title:W("formula.sum"),render:r=>r.reduce((e,t)=>Ie("+",e,t),0)},{key:"AVERAGE",title:W("formula.average"),render:r=>r.reduce((e,t)=>Number(e)+Number(t),0)/r.length},{key:"MAX",title:W("formula.max"),render:r=>Math.max(...r.map(e=>Number(e)))},{key:"MIN",title:W("formula.min"),render:r=>Math.min(...r.map(e=>Number(e)))},{key:"IF",title:W("formula._if"),render:([r,e,t])=>r?e:t},{key:"AND",title:W("formula.and"),render:r=>r.every(e=>e)},{key:"OR",title:W("formula.or"),render:r=>r.some(e=>e)},{key:"CONCAT",title:W("formula.concat"),render:r=>r.join("")}],Sl=lr,Es={};lr.forEach(r=>{Es[r.key]=r});const Ye=r=>r,gt=r=>{if(/^(-?\d*.?\d*)$/.test(r)){const e=Number(r).toFixed(2).toString(),[t,...s]=e.split("\\.");return[t.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"),...s]}return r},st=[{key:"normal",title:W("format.normal"),type:"string",render:Ye},{key:"text",title:W("format.text"),type:"string",render:Ye},{key:"number",title:W("format.number"),type:"number",label:"1,000.12",render:gt},{key:"percent",title:W("format.percent"),type:"number",label:"10.12%",render:r=>`${r}%`},{key:"rmb",title:W("format.rmb"),type:"number",label:"¥10.00",render:r=>`¥${gt(r)}`},{key:"usd",title:W("format.usd"),type:"number",label:"$10.00",render:r=>`$${gt(r)}`},{key:"eur",title:W("format.eur"),type:"number",label:"€10.00",render:r=>`€${gt(r)}`},{key:"date",title:W("format.date"),type:"date",label:"26/09/2008",render:Ye},{key:"time",title:W("format.time"),type:"date",label:"15:59:00",render:Ye},{key:"datetime",title:W("format.datetime"),type:"date",label:"26/09/2008 15:59:00",render:Ye},{key:"duration",title:W("format.duration"),type:"date",label:"24:01:00",render:Ye}],Ts={};st.forEach(r=>{Ts[r.key]=r});const Cl=5,Nl={fillStyle:"#f4f5f8"},El={fillStyle:"#fff",lineWidth:nr,strokeStyle:"#e6e6e6"};function Tl(){return{textAlign:"center",textBaseline:"middle",font:`500 ${I(12)}px Source Sans Pro`,fillStyle:"#585757",lineWidth:nr(),strokeStyle:"#e6e6e6"}}function Rs(r,e,t,s=0){const{left:i,top:n,width:l,height:a}=r.cellRect(e,t);return new bl(i,n+s,l,a,Cl)}function Et(r,e,t,s,i=0){const{sortedRowMap:n,rows:l,cols:a}=e;if(l.isHide(t)||a.isHide(s))return;let c=t;n.has(t)&&(c=n.get(t));const f=e.getCell(c,s);if(f===null)return;let d=!1;"editable"in f&&f.editable===!1&&(d=!0);const h=e.getCellStyleOrDefault(c,s),u=Rs(e,t,s,i);u.bgcolor=h.bgcolor,h.border!==void 0&&(u.setBorders(h.border),r.strokeBorders(u)),r.rect(u,()=>{let m="";e.settings.evalPaused?m=f.text||"":m=kl.render(f.text||"",Es,(v,b)=>e.getCellTextOrDefault(b,v)),h.format&&(m=Ts[h.format].render(m));const g=Object.assign({},h.font);g.size=wl(g.size),r.text(m,u,{align:h.align,valign:h.valign,font:g,color:h.color,strike:h.strike,underline:h.underline},h.textwrap),e.validations.getError(t,s)&&r.error(u),d&&r.frozen(u)})}function Rl(r){const{data:e,draw:t}=this;if(r){const{autoFilter:s}=e;if(!s.active())return;const i=s.hrange();r.intersects(i)&&i.each((n,l)=>{const a=Rs(e,n,l);t.dropdown(a)})}}function xt(r,e,t,s,i){const{draw:n,data:l}=this;n.save(),n.translate(e,t).translate(s,i);const{exceptRowSet:a}=l,c=h=>{const u=a.has(h);if(u){const m=l.rows.getHeight(h);n.translate(0,-m)}return!u},f=l.exceptRowTotalHeight(r.sri,r.eri);n.save(),n.translate(0,-f),r.each((h,u)=>{Et(n,l,h,u)},h=>c(h)),n.restore();const d=new Set;n.save(),n.translate(0,-f),l.eachMergesInView(r,({sri:h,sci:u,eri:m})=>{if(!a.has(h))Et(n,l,h,u);else if(!d.has(h)){d.add(h);const g=l.rows.sumHeight(h,m+1);n.translate(0,-g)}}),n.restore(),Rl.call(this,r),n.restore()}function Vr(r,e,t,s){const{draw:i}=this;i.save(),i.attr({fillStyle:"rgba(75, 137, 255, 0.08)"}).fillRect(r,e,t,s),i.restore()}function bt(r,e,t,s,i,n){const{draw:l,data:a}=this,c=e.h,f=e.w,d=n+s,h=i+t;l.save(),l.attr(Nl),(r==="all"||r==="left")&&l.fillRect(0,d,t,c),(r==="all"||r==="top")&&l.fillRect(h,0,f,s);const{sri:u,sci:m,eri:g,eci:x}=a.selector.range;l.attr(Tl()),(r==="all"||r==="left")&&(a.rowEach(e.sri,e.eri,(v,b,y)=>{const j=d+b,k=v;l.line([0,j],[t,j]),u<=k&&k<g+1&&Vr.call(this,0,j,t,y),l.fillText(k+1,t/2,j+y/2),v>0&&a.rows.isHide(v-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([5,j+5],[t-5,j+5]),l.restore())}),l.line([0,c+d],[t,c+d]),l.line([t,d],[t,c+d])),(r==="all"||r==="top")&&(a.colEach(e.sci,e.eci,(v,b,y)=>{const j=h+b,k=v;l.line([j,0],[j,s]),m<=k&&k<x+1&&Vr.call(this,j,0,y,s),l.fillText(ps(k),j+y/2,s/2),v>0&&a.cols.isHide(v-1)&&(l.save(),l.attr({strokeStyle:"#c6c6c6"}),l.line([j+5,5],[j+5,s-5]),l.restore())}),l.line([f+h,0],[f+h,s]),l.line([0,s],[f+h,s])),l.restore()}function $l(r,e){const{draw:t}=this;t.save(),t.attr({fillStyle:"#f4f5f8"}).fillRect(0,0,r,e),t.restore()}function wt({sri:r,sci:e,eri:t,eci:s,w:i,h:n},l,a,c,f){const{draw:d,data:h}=this,{settings:u}=h;if(d.save(),d.attr(El).translate(l+c,a+f),!u.showGrid){d.restore();return}h.rowEach(r,t,(m,g,x)=>{m!==r&&d.line([0,g],[i,g]),m===t&&d.line([0,g+x],[i,g+x])}),h.colEach(e,s,(m,g,x)=>{m!==e&&d.line([g,0],[g,n]),m===s&&d.line([g+x,0],[g+x,n])}),d.restore()}function Ml(r,e,t,s){const{draw:i,data:n}=this,l=n.viewWidth()-r,a=n.viewHeight()-e;i.save().translate(r,e).attr({strokeStyle:"rgba(75, 137, 255, .6)"}),i.line([0,s],[l,s]),i.line([t,0],[t,a]),i.restore()}class Fl{constructor(e,t){this.el=e,this.draw=new Cs(e,t.viewWidth(),t.viewHeight()),this.data=t}resetData(e){this.data=e,this.render()}render(){const{data:e}=this,{rows:t,cols:s}=e,i=s.indexWidth,n=t.height;this.draw.resize(e.viewWidth(),e.viewHeight()),this.clear();const l=e.viewRange(),a=e.freezeTotalWidth(),c=e.freezeTotalHeight(),{x:f,y:d}=e.scroll;wt.call(this,l,i,n,a,c),xt.call(this,l,i,n,-f,-d),bt.call(this,"all",l,i,n,a,c),$l.call(this,i,n);const[h,u]=e.freeze;if(h>0||u>0){if(h>0){const g=l.clone();g.sri=0,g.eri=h-1,g.h=c,wt.call(this,g,i,n,a,0),xt.call(this,g,i,n,-f,0),bt.call(this,"top",g,i,n,a,0)}if(u>0){const g=l.clone();g.sci=0,g.eci=u-1,g.w=a,wt.call(this,g,i,n,0,c),bt.call(this,"left",g,i,n,0,c),xt.call(this,g,i,n,0,-d)}const m=e.freezeViewRange();wt.call(this,m,i,n,0,0),bt.call(this,"all",m,i,n,0,0),xt.call(this,m,i,n,0,0),Ml.call(this,i,n,a,c)}}clear(){this.draw.clear()}}const yt=[["A3",11.69,16.54],["A4",8.27,11.69],["A5",5.83,8.27],["B4",9.84,13.9],["B5",6.93,9.84]],Zt=["landscape","portrait"];function Tt(r){return parseInt(96*r,10)}function qr(r){r==="cancel"?this.el.hide():this.toPrint()}function zl(r){const{paper:e}=this,{value:t}=r.target,s=yt[t];e.w=Tt(s[1]),e.h=Tt(s[2]),this.preview()}function _l(r){const{paper:e}=this,{value:t}=r.target,s=Zt[t];e.orientation=s,this.preview()}let Dl=class{constructor(e){this.paper={w:Tt(yt[0][1]),h:Tt(yt[0][2]),padding:50,orientation:Zt[0],get width(){return this.orientation==="landscape"?this.h:this.w},get height(){return this.orientation==="landscape"?this.w:this.h}},this.data=e,this.el=w("div",`${C}-print`).children(w("div",`${C}-print-bar`).children(w("div","-title").child("Print settings"),w("div","-right").children(w("div",`${C}-buttons`).children(new Ae("cancel").on("click",qr.bind(this,"cancel")),new Ae("next","primary").on("click",qr.bind(this,"next"))))),w("div",`${C}-print-content`).children(this.contentEl=w("div","-content"),w("div","-sider").child(w("form","").children(w("fieldset","").children(w("label","").child(`${se("print.size")}`),w("select","").children(...yt.map((t,s)=>w("option","").attr("value",s).child(`${t[0]} ( ${t[1]}''x${t[2]}'' )`))).on("change",zl.bind(this))),w("fieldset","").children(w("label","").child(`${se("print.orientation")}`),w("select","").children(...Zt.map((t,s)=>w("option","").attr("value",s).child(`${se("print.orientations")[s]}`))).on("change",_l.bind(this))))))).hide()}resetData(e){this.data=e}preview(){const{data:e,paper:t}=this,{width:s,height:i,padding:n}=t,l=s-n*2,a=i-n*2,c=e.contentRange(),f=parseInt(c.h/a,10)+1,d=l/c.w;let h=n;const u=n;d>1&&(h+=(l-c.w)/2);let m=0,g=0;this.contentEl.html(""),this.canvases=[];const x={sri:0,sci:0,eri:0,eci:0};for(let v=0;v<f;v+=1){let b=0,y=0;const j=w("div",`${C}-canvas-card`),k=w("canvas",`${C}-canvas`);this.canvases.push(k.el);const N=new Cs(k.el,s,i);for(N.save(),N.translate(h,u),d<1&&N.scale(d,d);m<=c.eri;m+=1){const z=e.rows.getHeight(m);if(b+=z,b<a)for(let P=0;P<=c.eci;P+=1)Et(N,e,m,P,g),x.eci=P;else{y=-(b-z);break}}x.eri=m,N.restore(),N.save(),N.translate(h,u),d<1&&N.scale(d,d);const M=g;e.eachMergesInView(x,({sri:z,sci:P})=>{Et(N,e,z,P,M)}),N.restore(),x.sri=x.eri,x.sci=x.eci,g+=y,this.contentEl.child(w("div",`${C}-canvas-card-wraper`).child(j.child(k)))}this.el.show()}toPrint(){this.el.hide();const{paper:e}=this,t=w("iframe","").hide(),{el:s}=t;window.document.body.appendChild(s);const{contentWindow:i}=s,n=i.document,l=document.createElement("style");l.innerHTML=`
|
|
25
|
-
@page { size: ${e.width}px ${e.height}px; };
|
|
26
|
-
canvas {
|
|
27
|
-
page-break-before: auto;
|
|
28
|
-
page-break-after: always;
|
|
29
|
-
image-rendering: pixelated;
|
|
30
|
-
};
|
|
31
|
-
`,n.head.appendChild(l),this.canvases.forEach(a=>{const c=a.cloneNode(!1);c.getContext("2d").drawImage(a,0,0),n.body.appendChild(c)}),i.print()}};const Pl=[{key:"copy",title:W("contextmenu.copy"),label:"Ctrl+C"},{key:"cut",title:W("contextmenu.cut"),label:"Ctrl+X"},{key:"paste",title:W("contextmenu.paste"),label:"Ctrl+V"},{key:"paste-value",title:W("contextmenu.pasteValue"),label:"Ctrl+Shift+V"},{key:"paste-format",title:W("contextmenu.pasteFormat"),label:"Ctrl+Alt+V"},{key:"divider"},{key:"insert-row",title:W("contextmenu.insertRow")},{key:"insert-column",title:W("contextmenu.insertColumn")},{key:"divider"},{key:"delete-row",title:W("contextmenu.deleteRow")},{key:"delete-column",title:W("contextmenu.deleteColumn")},{key:"delete-cell-text",title:W("contextmenu.deleteCellText")},{key:"hide",title:W("contextmenu.hide")},{key:"divider"},{key:"validation",title:W("contextmenu.validation")},{key:"divider"},{key:"cell-printable",title:W("contextmenu.cellprintable")},{key:"cell-non-printable",title:W("contextmenu.cellnonprintable")},{key:"divider"},{key:"cell-editable",title:W("contextmenu.celleditable")},{key:"cell-non-editable",title:W("contextmenu.cellnoneditable")}];function Ol(r){return r.key==="divider"?w("div",`${C}-item divider`):w("div",`${C}-item`).on("click",()=>{this.itemClick(r.key),this.hide()}).children(r.title(),w("div","label").child(r.label||""))}function Ll(){return Pl.map(r=>Ol.call(this,r))}let Il=class{constructor(e,t=!1){this.menuItems=Ll.call(this),this.el=w("div",`${C}-contextmenu`).children(...this.menuItems).hide(),this.viewFn=e,this.itemClick=()=>{},this.isHide=t,this.setMode("range")}setMode(e){const t=this.menuItems[12];e==="row-col"?t.show():t.hide()}hide(){const{el:e}=this;e.hide(),et(e)}setPosition(e,t){if(this.isHide)return;const{el:s}=this,{width:i}=s.show().offset(),n=this.viewFn(),l=n.height/2;let a=e;n.width-e<=i&&(a-=i),s.css("left",`${a}px`),t>l?s.css("bottom",`${n.height-t}px`).css("max-height",`${t}px`).css("top","auto"):s.css("top",`${t}px`).css("max-height",`${n.height-t}px`).css("bottom","auto"),ot(s)}};function Al(r,e){if(e.classList.contains("active"))return;const{left:t,top:s,width:i,height:n}=e.getBoundingClientRect(),l=w("div",`${C}-tooltip`).html(r).show();document.body.appendChild(l.el);const a=l.box();l.css("left",`${t+i/2-a.width/2}px`).css("top",`${s+n+2}px`),de(e,"mouseleave",()=>{document.body.contains(l.el)&&document.body.removeChild(l.el)}),de(e,"click",()=>{document.body.contains(l.el)&&document.body.removeChild(l.el)})}class or{constructor(e,t,s){this.tip=se(`toolbar.${e.replace(/-[a-z]/g,i=>i[1].toUpperCase())}`),t&&(this.tip+=` (${t})`),this.tag=e,this.shortcut=t,this.value=s,this.el=this.element(),this.change=()=>{}}element(){const{tip:e}=this;return w("div",`${C}-toolbar-btn`).on("mouseenter",t=>{Al(e,t.target)}).attr("data-tooltip",e)}setState(){}}class Te extends or{dropdown(){}getValue(e){return e}element(){const{tag:e}=this;return this.dd=this.dropdown(),this.dd.change=t=>this.change(e,this.getValue(t)),super.element().child(this.dd)}setState(e){e&&(this.value=e,this.dd.setTitle(e))}}class Re extends We{constructor(e,t,s,i,...n){super("div",`${C}-dropdown ${i}`),this.title=e,this.change=()=>{},this.headerClick=()=>{},typeof e=="string"?this.title=w("div",`${C}-dropdown-title`).child(e):s&&this.title.addClass("arrow-left"),this.contentEl=w("div",`${C}-dropdown-content`).css("width",t).hide(),this.setContentChildren(...n),this.headerEl=w("div",`${C}-dropdown-header`),this.headerEl.on("click",()=>{this.contentEl.css("display")!=="block"?this.show():this.hide()}).children(this.title,s?w("div",`${C}-icon arrow-right`).child(w("div",`${C}-icon-img arrow-down`)):""),this.children(this.headerEl,this.contentEl)}setContentChildren(...e){this.contentEl.html(""),e.length>0&&this.contentEl.children(...e)}setTitle(e){this.title.html(e),this.hide()}show(){const{contentEl:e}=this;e.show(),this.parent().active(),ot(this.parent(),()=>{this.hide()})}hide(){this.parent().active(!1),this.contentEl.hide(),et(this.parent())}}function Hl(r){return w("div",`${C}-item`).child(new oe(r))}class $s extends Re{constructor(e,t){const s=new oe(`align-${t}`),i=e.map(n=>Hl(`align-${n}`).on("click",()=>{this.setTitle(n),this.change(n)}));super(s,"auto",!0,"bottom-left",...i)}setTitle(e){this.title.setName(`align-${e}`),this.hide()}}class Wl extends Te{constructor(e){super("align","",e)}dropdown(){const{value:e}=this;return new $s(["left","center","right"],e)}}class Bl extends Te{constructor(e){super("valign","",e)}dropdown(){const{value:e}=this;return new $s(["top","middle","bottom"],e)}}class Fe extends or{element(){const{tag:e}=this;return super.element().child(new oe(e)).on("click",()=>this.click())}click(){this.change(this.tag,this.toggle())}setState(e){this.el.active(e)}toggle(){return this.el.toggle()}active(){return this.el.hasClass("active")}}class Vl extends Fe{constructor(){super("autofilter")}setState(){}}class ql extends Fe{constructor(){super("font-bold","Ctrl+B")}}class Ul extends Fe{constructor(){super("font-italic","Ctrl+I")}}class Gl extends Fe{constructor(){super("strike","Ctrl+U")}}class Xl extends Fe{constructor(){super("underline","Ctrl+U")}}const Zl=["#ffffff","#000100","#e7e5e6","#445569","#5b9cd6","#ed7d31","#a5a5a5","#ffc001","#4371c6","#71ae47"],Yl=[["#f2f2f2","#7f7f7f","#d0cecf","#d5dce4","#deeaf6","#fce5d5","#ededed","#fff2cd","#d9e2f3","#e3efd9"],["#d8d8d8","#595959","#afabac","#adb8ca","#bdd7ee","#f7ccac","#dbdbdb","#ffe59a","#b3c6e7","#c5e0b3"],["#bfbfbf","#3f3f3f","#756f6f","#8596b0","#9cc2e6","#f4b184","#c9c9c9","#fed964","#8eaada","#a7d08c"],["#a5a5a5","#262626","#3a3839","#333f4f","#2e75b5","#c45a10","#7b7b7b","#bf8e01","#2f5596","#538136"],["#7f7f7f","#0c0c0c","#171516","#222a35","#1f4e7a","#843c0a","#525252","#7e6000","#203864","#365624"]],Jl=["#c00000","#fe0000","#fdc101","#ffff01","#93d051","#00b04e","#01b0f1","#0170c1","#012060","#7030a0"];function Ot(r){return w("td","").child(w("div",`${C}-color-palette-cell`).on("click.stop",()=>this.change(r)).css("background-color",r))}class Kl{constructor(){this.el=w("div",`${C}-color-palette`),this.change=()=>{};const e=w("table","").children(w("tbody","").children(w("tr",`${C}-theme-color-placeholders`).children(...Zl.map(t=>Ot.call(this,t))),...Yl.map(t=>w("tr",`${C}-theme-colors`).children(...t.map(s=>Ot.call(this,s)))),w("tr",`${C}-standard-colors`).children(...Jl.map(t=>Ot.call(this,t)))));this.el.child(e)}}class ar extends Re{constructor(e,t){const s=new oe(e).css("height","16px").css("border-bottom",`3px solid ${t}`),i=new Kl;i.change=n=>{this.setTitle(n),this.change(n)},super(s,"auto",!1,"bottom-left",i.el)}setTitle(e){this.title.css("border-color",e),this.hide()}}const Ql=[["thin",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" style="user-select: none;"></line></svg>'],["medium",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="2" style="user-select: none;"><line x1="0" y1="1.0" x2="50" y2="1.0" stroke-width="2" stroke="black" style="user-select: none;"></line></svg>'],["thick",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="3" style="user-select: none;"><line x1="0" y1="1.5" x2="50" y2="1.5" stroke-width="3" stroke="black" style="user-select: none;"></line></svg>'],["dashed",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" stroke-dasharray="2" style="user-select: none;"></line></svg>'],["dotted",'<svg xmlns="http://www.w3.org/2000/svg" width="50" height="1" style="user-select: none;"><line x1="0" y1="0.5" x2="50" y2="0.5" stroke-width="1" stroke="black" stroke-dasharray="1" style="user-select: none;"></line></svg>']];class eo extends Re{constructor(e){const t=new oe("line-type");let s=0;const i=Ql.map((n,l)=>w("div",`${C}-item state ${e===n[0]?"checked":""}`).on("click",()=>{i[s].toggle("checked"),i[l].toggle("checked"),s=l,this.hide(),this.change(n)}).child(w("div",`${C}-line-type`).html(n[1])));super(t,"auto",!1,"bottom-left",...i)}}function Ur(...r){return w("table","").child(w("tbody","").children(...r))}function Gr(r){return w("td","").child(w("div",`${C}-border-palette-cell`).child(new oe(`border-${r}`)).on("click",()=>{this.mode=r;const{mode:e,style:t,color:s}=this;this.change({mode:e,style:t,color:s})}))}class to{constructor(){this.color="#000",this.style="thin",this.mode="all",this.change=()=>{},this.ddColor=new ar("line-color",this.color),this.ddColor.change=t=>{this.color=t},this.ddType=new eo(this.style),this.ddType.change=([t])=>{this.style=t},this.el=w("div",`${C}-border-palette`);const e=Ur(w("tr","").children(w("td",`${C}-border-palette-left`).child(Ur(w("tr","").children(...["all","inside","horizontal","vertical","outside"].map(t=>Gr.call(this,t))),w("tr","").children(...["left","top","right","bottom","none"].map(t=>Gr.call(this,t))))),w("td",`${C}-border-palette-right`).children(w("div",`${C}-toolbar-btn`).child(this.ddColor.el),w("div",`${C}-toolbar-btn`).child(this.ddType.el))));this.el.child(e)}}class ro extends Re{constructor(){const e=new oe("border-all"),t=new to;t.change=s=>{this.change(s),this.hide()},super(e,"auto",!1,"bottom-left",t.el)}}class so extends Te{constructor(){super("border")}dropdown(){return new ro}}class $t extends or{element(){return super.element().child(new oe(this.tag)).on("click",()=>this.change(this.tag))}setState(e){this.el.disabled(e)}}class io extends $t{constructor(){super("clearformat")}}class no extends Fe{constructor(){super("paintformat")}setState(){}}class lo extends Te{constructor(e){super("color",void 0,e)}dropdown(){const{tag:e,value:t}=this;return new ar(e,t)}}class oo extends Te{constructor(e){super("bgcolor",void 0,e)}dropdown(){const{tag:e,value:t}=this;return new ar(e,t)}}class ao extends Re{constructor(){const e=Xt.map(t=>w("div",`${C}-item`).on("click",()=>{this.setTitle(`${t.pt}`),this.change(t)}).child(`${t.pt}`));super("10","60px",!0,"bottom-left",...e)}}let co=class extends Te{constructor(){super("font-size")}getValue(e){return e.pt}dropdown(){return new ao}};class fo extends Re{constructor(){const e=Br.map(t=>w("div",`${C}-item`).on("click",()=>{this.setTitle(t.title),this.change(t)}).child(t.title));super(Br[0].title,"160px",!0,"bottom-left",...e)}}class ho extends Te{constructor(){super("font-name")}getValue(e){return e.key}dropdown(){return new fo}}class po extends Re{constructor(){let e=st.slice(0);e.splice(2,0,{key:"divider"}),e.splice(8,0,{key:"divider"}),e=e.map(t=>{const s=w("div",`${C}-item`);return t.key==="divider"?s.addClass("divider"):(s.child(t.title()).on("click",()=>{this.setTitle(t.title()),this.change(t)}),t.label&&s.child(w("div","label").html(t.label))),s}),super("Normal","220px",!0,"bottom-left",...e)}setTitle(e){for(let t=0;t<st.length;t+=1)st[t].key===e&&this.title.html(st[t].title());this.hide()}}let uo=class extends Te{constructor(){super("format")}getValue(e){return e.key}dropdown(){return new po}};class mo extends Re{constructor(){const e=lr.map(t=>w("div",`${C}-item`).on("click",()=>{this.hide(),this.change(t)}).child(t.key));super(new oe("formula"),"180px",!0,"bottom-left",...e)}}class go extends Te{constructor(){super("formula")}getValue(e){return e.key}dropdown(){return new mo}}class xo extends Fe{constructor(){super("freeze")}}class bo extends Fe{constructor(){super("merge")}setState(e,t){this.el.active(e).disabled(t)}}class wo extends $t{constructor(){super("redo","Ctrl+Y")}}class vo extends $t{constructor(){super("undo","Ctrl+Z")}}class yo extends $t{constructor(){super("print","Ctrl+P")}}class jo extends Fe{constructor(){super("textwrap")}}let ko=class extends Re{constructor(){const e=new oe("ellipsis"),t=w("div",`${C}-toolbar-more`);super(e,"auto",!1,"bottom-right",t),this.moreBtns=t,this.contentEl.css("max-width","420px")}};class So extends Te{constructor(){super("more"),this.el.hide()}dropdown(){return new ko}show(){this.el.show()}hide(){this.el.hide()}}function Je(){return w("div",`${C}-toolbar-divider`)}function Co(){this.btns2=[],this.items.forEach(r=>{if(Array.isArray(r))r.forEach(({el:e})=>{const t=e.box(),{marginLeft:s,marginRight:i}=e.computedStyle();this.btns2.push([e,t.width+parseInt(s,10)+parseInt(i,10)])});else{const e=r.box(),{marginLeft:t,marginRight:s}=r.computedStyle();this.btns2.push([r,e.width+parseInt(t,10)+parseInt(s,10)])}})}function Xr(){const{el:r,btns:e,moreEl:t,btns2:s}=this,{moreBtns:i,contentEl:n}=t.dd;r.css("width",`${this.widthFn()-60}px`);const l=r.box();let a=160,c=12;const f=[],d=[];s.forEach(([h,u],m)=>{a+=u,m===s.length-1||a<l.width?f.push(h):(c+=u,d.push(h))}),e.html("").children(...f),i.html("").children(...d),n.css("width",`${c}px`),d.length>0?t.show():t.hide()}class No{constructor(e,t,s=!1){this.data=e,this.change=()=>{},this.widthFn=t,this.isHide=s;const i=e.defaultStyle();this.items=[[this.undoEl=new vo,this.redoEl=new wo,new yo,this.paintformatEl=new no,this.clearformatEl=new io],Je(),[this.formatEl=new uo],Je(),[this.fontEl=new ho,this.fontSizeEl=new co],Je(),[this.boldEl=new ql,this.italicEl=new Ul,this.underlineEl=new Xl,this.strikeEl=new Gl,this.textColorEl=new lo(i.color)],Je(),[this.fillColorEl=new oo(i.bgcolor),this.borderEl=new so,this.mergeEl=new bo],Je(),[this.alignEl=new Wl(i.align),this.valignEl=new Bl(i.valign),this.textwrapEl=new jo],Je(),[this.freezeEl=new xo,this.autofilterEl=new Vl,this.formulaEl=new go,this.moreEl=new So]],this.el=w("div",`${C}-toolbar`),this.btns=w("div",`${C}-toolbar-btns`),this.items.forEach(n=>{Array.isArray(n)?n.forEach(l=>{this.btns.child(l.el),l.change=(...a)=>{this.change(...a)}}):this.btns.child(n.el)}),this.el.child(this.btns),s?this.el.hide():(this.reset(),setTimeout(()=>{Co.call(this),Xr.call(this)},0),de(window,"resize",()=>{Xr.call(this)}))}paintformatActive(){return this.paintformatEl.active()}paintformatToggle(){this.paintformatEl.toggle()}trigger(e){this[`${e}El`].click()}resetData(e){this.data=e,this.reset()}reset(){if(this.isHide)return;const{data:e}=this,t=e.getSelectedCellStyle();this.undoEl.setState(!e.canUndo()),this.redoEl.setState(!e.canRedo()),this.mergeEl.setState(e.canUnmerge(),!e.selector.multiple()),this.autofilterEl.setState(!e.canAutofilter());const{font:s,format:i}=t;this.formatEl.setState(i),this.fontEl.setState(s.name),this.fontSizeEl.setState(s.size),this.boldEl.setState(s.bold),this.italicEl.setState(s.italic),this.underlineEl.setState(t.underline),this.strikeEl.setState(t.strike),this.textColorEl.setState(t.color),this.fillColorEl.setState(t.bgcolor),this.alignEl.setState(t.align),this.valignEl.setState(t.valign),this.textwrapEl.setState(t.textwrap),this.freezeEl.setState(e.freezeIsActive())}}class Eo{constructor(e,t,s="600px"){this.title=e,this.el=w("div",`${C}-modal`).css("width",s).children(w("div",`${C}-modal-header`).children(new oe("close").on("click.stop",()=>this.hide()),this.title),w("div",`${C}-modal-content`).children(...t)).hide()}show(){this.dimmer=w("div",`${C}-dimmer active`),document.body.appendChild(this.dimmer.el);const{width:e,height:t}=this.el.show().box(),{clientHeight:s,clientWidth:i}=document.documentElement;this.el.offset({left:(i-e)/2,top:(s-t)/3}),window.xkeydownEsc=n=>{n.keyCode===27&&this.hide()},de(window,"keydown",window.xkeydownEsc)}hide(){this.el.hide(),document.body.removeChild(this.dimmer.el),St(window,"keydown",window.xkeydownEsc),delete window.xkeydownEsc}}class Ke{constructor(e,t){this.vchange=()=>{},this.el=w("div",`${C}-form-input`),this.input=w("input","").css("width",e).on("input",s=>this.vchange(s)).attr("placeholder",t),this.el.child(this.input)}focus(){setTimeout(()=>{this.input.el.focus()},10)}hint(e){this.input.attr("placeholder",e)}val(e){return this.input.val(e)}}class Lt{constructor(e,t,s,i=l=>l,n=()=>{}){this.key=e,this.getTitle=i,this.vchange=()=>{},this.el=w("div",`${C}-form-select`),this.suggest=new ks(t.map(l=>({key:l,title:this.getTitle(l)})),l=>{this.itemClick(l.key),n(l.key),this.vchange(l.key)},s,this.el),this.el.children(this.itemEl=w("div","input-text").html(this.getTitle(e)),this.suggest.el).on("click",()=>this.show())}show(){this.suggest.search("")}itemClick(e){this.key=e,this.itemEl.html(this.getTitle(e))}val(e){return e!==void 0?(this.key=e,this.itemEl.html(this.getTitle(e)),this):this.key}}const To={number:/(^\d+$)|(^\d+(\.\d{0,4})?$)/,date:/^\d{4}-\d{1,2}-\d{1,2}$/};class _e{constructor(e,t,s,i){this.label="",this.rule=t,s&&(this.label=w("label","label").css("width",`${i}px`).html(s)),this.tip=w("div","tip").child("tip").hide(),this.input=e,this.input.vchange=()=>this.validate(),this.el=w("div",`${C}-form-field`).children(this.label,e.el,this.tip)}isShow(){return this.el.css("display")!=="none"}show(){this.el.show()}hide(){return this.el.hide(),this}val(e){return this.input.val(e)}hint(e){this.input.hint(e)}validate(){const{input:e,rule:t,tip:s,el:i}=this,n=e.val();return t.required&&/^\s*$/.test(n)?(s.html(se("validation.required")),i.addClass("error"),!1):(t.type||t.pattern)&&!(t.pattern||To[t.type]).test(n)?(s.html(se("validation.notMatch")),i.addClass("error"),!1):(i.removeClass("error"),!0)}}const Zr=100;class Ro extends Eo{constructor(){const e=new _e(new Lt("cell",["cell"],"100%",f=>se(`dataValidation.modeType.${f}`)),{required:!0},`${se("dataValidation.range")}:`,Zr),t=new _e(new Ke("120px","E3 or E3:F12"),{required:!0,pattern:/^([A-Z]{1,2}[1-9]\d*)(:[A-Z]{1,2}[1-9]\d*)?$/}),s=new _e(new Lt("list",["list","number","date","phone","email"],"100%",f=>se(`dataValidation.type.${f}`),f=>this.criteriaSelected(f)),{required:!0},`${se("dataValidation.criteria")}:`,Zr),i=new _e(new Lt("be",["be","nbe","eq","neq","lt","lte","gt","gte"],"160px",f=>se(`dataValidation.operator.${f}`),f=>this.criteriaOperatorSelected(f)),{required:!0}).hide(),n=new _e(new Ke("70px","10"),{required:!0}).hide(),l=new _e(new Ke("70px","100"),{required:!0,type:"number"}).hide(),a=new _e(new Ke("120px","a,b,c"),{required:!0}),c=new _e(new Ke("70px","10"),{required:!0,type:"number"}).hide();super(se("contextmenu.validation"),[w("div",`${C}-form-fields`).children(e.el,t.el),w("div",`${C}-form-fields`).children(s.el,i.el,n.el,l.el,c.el,a.el),w("div",`${C}-buttons`).children(new Ae("cancel").on("click",()=>this.btnClick("cancel")),new Ae("remove").on("click",()=>this.btnClick("remove")),new Ae("save","primary").on("click",()=>this.btnClick("save")))]),this.mf=e,this.rf=t,this.cf=s,this.of=i,this.minvf=n,this.maxvf=l,this.vf=c,this.svf=a,this.change=()=>{}}showVf(e){const t=e==="date"?"2018-11-12":"10",{vf:s}=this;s.input.hint(t),s.show()}criteriaSelected(e){const{of:t,minvf:s,maxvf:i,vf:n,svf:l}=this;e==="date"||e==="number"?(t.show(),s.rule.type=e,i.rule.type=e,e==="date"?(s.hint("2018-11-12"),i.hint("2019-11-12")):(s.hint("10"),i.hint("100")),s.show(),i.show(),n.hide(),l.hide()):(e==="list"?l.show():l.hide(),n.hide(),t.hide(),s.hide(),i.hide())}criteriaOperatorSelected(e){if(!e)return;const{minvf:t,maxvf:s,vf:i}=this;if(e==="be"||e==="nbe")t.show(),s.show(),i.hide();else{const n=this.cf.val();i.rule.type=n,n==="date"?i.hint("2018-11-12"):i.hint("10"),i.show(),t.hide(),s.hide()}}btnClick(e){if(e==="cancel")this.hide();else if(e==="remove")this.change("remove"),this.hide();else if(e==="save"){const t=["mf","rf","cf","of","svf","vf","minvf","maxvf"];for(let c=0;c<t.length;c+=1){const f=this[t[c]];if(f.isShow()&&!f.validate())return}const s=this.mf.val(),i=this.rf.val(),n=this.cf.val(),l=this.of.val();let a=this.svf.val();(n==="number"||n==="date")&&(l==="be"||l==="nbe"?a=[this.minvf.val(),this.maxvf.val()]:a=this.vf.val()),this.change("save",s,i,{type:n,operator:l,required:!1,value:a}),this.hide()}}setValue(e){if(e){const{mf:t,rf:s,cf:i,of:n,svf:l,vf:a,minvf:c,maxvf:f}=this,{mode:d,ref:h,validator:u}=e,{type:m,operator:g,value:x}=u||{type:"list"};t.val(d||"cell"),s.val(h),i.val(m),n.val(g),Array.isArray(x)?(c.val(x[0]),f.val(x[1])):(l.val(x||""),a.val(x||"")),this.criteriaSelected(m),this.criteriaOperatorSelected(g)}this.show()}}function Ms(r){return w("div",`${C}-item ${r}`)}function Yr(r){return Ms("state").child(se(`sort.${r}`)).on("click.stop",()=>this.itemClick(r))}function $o(r){const{filterbEl:e,filterValues:t}=this;e.html(""),Object.keys(r).forEach((i,n)=>{const l=r[i],a=t.includes(i)?"checked":"";e.child(w("div",`${C}-item state ${a}`).on("click.stop",()=>this.filterClick(n,i)).children(i===""?se("filter.empty"):i,w("div","label").html(`(${l})`)))})}function Jr(){const{filterhEl:r,filterValues:e,values:t}=this;r.html(`${e.length} / ${t.length}`),r.checked(e.length===t.length)}class Mo{constructor(){this.filterbEl=w("div",`${C}-body`),this.filterhEl=w("div",`${C}-header state`).on("click.stop",()=>this.filterClick(0,"all")),this.el=w("div",`${C}-sort-filter`).children(this.sortAscEl=Yr.call(this,"asc"),this.sortDescEl=Yr.call(this,"desc"),Ms("divider"),w("div",`${C}-filter`).children(this.filterhEl,this.filterbEl),w("div",`${C}-buttons`).children(new Ae("cancel").on("click",()=>this.btnClick("cancel")),new Ae("ok","primary").on("click",()=>this.btnClick("ok")))).hide(),this.ci=null,this.sortDesc=null,this.values=null,this.filterValues=[]}btnClick(e){if(e==="ok"){const{ci:t,sort:s,filterValues:i}=this;this.ok&&this.ok(t,s,"in",i)}this.hide()}itemClick(e){this.sort=e;const{sortAscEl:t,sortDescEl:s}=this;t.checked(e==="asc"),s.checked(e==="desc")}filterClick(e,t){const{filterbEl:s,filterValues:i,values:n}=this,l=s.children();t==="all"?l.length===i.length?(this.filterValues=[],l.forEach(a=>w(a).checked(!1))):(this.filterValues=Array.from(n),l.forEach(a=>w(a).checked(!0))):w(l[e]).toggle("checked")?i.push(t):i.splice(i.findIndex(c=>c===t),1),Jr.call(this)}set(e,t,s,i){this.ci=e;const{sortAscEl:n,sortDescEl:l}=this;i!==null?(this.sort=i.order,n.checked(i.asc()),l.checked(i.desc())):(this.sortDesc=null,n.checked(!1),l.checked(!1)),this.values=Object.keys(t),this.filterValues=s?Array.from(s.value):Object.keys(t),$o.call(this,t,s),Jr.call(this)}setOffset(e){this.el.offset(e).show();let t=1;ot(this.el,()=>{t<=0&&this.hide(),t-=1})}show(){this.el.show()}hide(){this.el.hide(),et(this.el)}}function Fs(r,e){const t=w("div",`${C}-toast`),s=w("div",`${C}-dimmer active`),i=()=>{document.body.removeChild(t.el),document.body.removeChild(s.el)};t.children(w("div",`${C}-toast-header`).children(new oe("close").on("click.stop",()=>i()),r),w("div",`${C}-toast-content`).html(e)),document.body.appendChild(t.el),document.body.appendChild(s.el);const{width:n,height:l}=t.box(),{clientHeight:a,clientWidth:c}=document.documentElement;t.offset({left:(c-n)/2,top:(a-l)/3})}function It(r,e){let t;return(...s)=>{const i=this,n=s;t||(t=setTimeout(()=>{t=null,r.apply(i,n)},e))}}function Fo(){const{data:r,verticalScrollbar:e,horizontalScrollbar:t}=this,{l:s,t:i,left:n,top:l,width:a,height:c}=r.getSelectedRect(),f=this.getTableOffset();if(Math.abs(n)+a>f.width)t.move({left:s+a-f.width});else{const d=r.freezeTotalWidth();n<d&&t.move({left:s-1-d})}if(Math.abs(l)+c>f.height)e.move({top:i+c-f.height-1});else{const d=r.freezeTotalHeight();l<d&&e.move({top:i-1-d})}}function He(r,e,t,s=!0,i=!1){if(e===-1&&t===-1)return;const{table:n,selector:l,toolbar:a,data:c,contextMenu:f}=this;f.setMode(e===-1||t===-1?"row-col":"range");const d=c.getCell(e,t);r?(l.setEnd(e,t,i),this.trigger("cells-selected",d,l.range)):(l.set(e,t,s),this.trigger("cell-selected",d,e,t)),a.reset(),n.render()}function Ee(r,e){const{selector:t,data:s}=this,{rows:i,cols:n}=s;let[l,a]=t.indexes;const{eri:c,eci:f}=t.range;r&&([l,a]=t.moveIndexes),e==="left"?a>0&&(a-=1):e==="right"?(f!==a&&(a=f),a<n.len-1&&(a+=1)):e==="up"?l>0&&(l-=1):e==="down"?(c!==l&&(l=c),l<i.len-1&&(l+=1)):e==="row-first"?a=0:e==="row-last"?a=n.len-1:e==="col-first"?l=0:e==="col-last"&&(l=i.len-1),r&&(t.moveIndexes=[l,a]),He.call(this,r,l,a),Fo.call(this)}function zo(r){if(r.buttons!==0||r.target.className===`${C}-resizer-hover`)return;const{offsetX:e,offsetY:t}=r,{rowResizer:s,colResizer:i,tableEl:n,data:l}=this,{rows:a,cols:c}=l;if(e>c.indexWidth&&t>a.height){s.hide(),i.hide();return}const f=n.box(),d=l.getCellRectByXY(r.offsetX,r.offsetY);d.ri>=0&&d.ci===-1?(d.width=c.indexWidth,s.show(d,{width:f.width}),a.isHide(d.ri-1)?s.showUnhide(d.ri):s.hideUnhide()):s.hide(),d.ri===-1&&d.ci>=0?(d.height=a.height,i.show(d,{height:f.height}),c.isHide(d.ci-1)?i.showUnhide(d.ci):i.hideUnhide()):i.hide()}function _o(r){const{verticalScrollbar:e,horizontalScrollbar:t,data:s}=this,{top:i}=e.scroll(),{left:n}=t.scroll(),{rows:l,cols:a}=s,{deltaY:c,deltaX:f}=r,d=(v,b)=>{let y=v,j=0;do j=b(y),y+=1;while(j<=0);return j},h=v=>{if(v>0){const b=s.scroll.ri+1;if(b<l.len){const y=d(b,j=>l.getHeight(j));e.move({top:i+y-1})}}else{const b=s.scroll.ri-1;if(b>=0){const y=d(b,j=>l.getHeight(j));e.move({top:b===0?0:i-y})}}},u=v=>{if(v>0){const b=s.scroll.ci+1;if(b<a.len){const y=d(b,j=>a.getWidth(j));t.move({left:n+y-1})}}else{const b=s.scroll.ci-1;if(b>=0){const y=d(b,j=>a.getWidth(j));t.move({left:b===0?0:n-y})}}},m=Math.abs(c),g=Math.abs(f),x=Math.max(m,g);/Firefox/i.test(window.navigator.userAgent)&&It(h(r.detail),50),x===g&&It(u(f),50),x===m&&It(h(c),50)}function Do(r,e){const{verticalScrollbar:t,horizontalScrollbar:s}=this,{top:i}=t.scroll(),{left:n}=s.scroll();r==="left"||r==="right"?s.move({left:n-e}):(r==="up"||r==="down")&&t.move({top:i-e})}function cr(){const{data:r,verticalScrollbar:e}=this,{height:t}=this.getTableOffset(),s=r.exceptRowTotalHeight(0,-1);e.set(t,r.rows.totalHeight()-s)}function fr(){const{data:r,horizontalScrollbar:e}=this,{width:t}=this.getTableOffset();r&&e.set(t,r.cols.totalWidth())}function Po(){const{selector:r,data:e,editor:t}=this,[s,i]=e.freeze;if(s>0||i>0){const n=e.freezeTotalWidth(),l=e.freezeTotalHeight();t.setFreezeLengths(n,l)}r.resetAreaOffset()}function fe(){const{tableEl:r,overlayerEl:e,overlayerCEl:t,table:s,toolbar:i,selector:n,el:l}=this,a=this.getTableOffset(),c=this.getRect();r.attr(c),e.offset(c),t.offset(a),l.css("width",`${c.width}px`),cr.call(this),fr.call(this),Po.call(this),s.render(),i.reset(),n.reset()}function at(){const{data:r,selector:e}=this;r.clearClipboard(),e.hideClipboard()}function Yt(){const{data:r,selector:e}=this;r.copy(),r.copyToSystemClipboard(),e.showClipboard()}function Kr(){const{data:r,selector:e}=this;r.cut(),e.showClipboard()}function it(r,e){const{data:t}=this;if(t.settings.mode!=="read"){if(t.paste(r,s=>Fs("Tip",s)))fe.call(this);else if(e){const s=e.clipboardData.getData("text/plain");this.data.pasteFromText(s),fe.call(this)}}}function Oo(){this.data.hideRowsOrCols(),fe.call(this)}function Qr(r,e){this.data.unhideRowsOrCols(r,e),fe.call(this)}function Lo(){const{data:r}=this;r.autofilter(),fe.call(this)}function Io(){const{toolbar:r}=this;r.paintformatActive()&&(it.call(this,"format"),at.call(this),r.paintformatToggle())}function es(r){const{selector:e,data:t,table:s,sortFilter:i}=this,{offsetX:n,offsetY:l}=r,a=r.target.className===`${C}-selector-corner`,c=t.getCellRectByXY(n,l),{left:f,top:d,width:h,height:u}=c;let{ri:m,ci:g}=c;const{autoFilter:x}=t;if(x.includes(m,g)&&f+h-20<n&&d+u-20<l){const v=x.items(g,(b,y)=>t.rows.getCell(b,y));i.hide(),i.set(g,v,x.getFilter(g),x.getSort(g)),i.setOffset({left:f,top:d+u+2});return}r.shiftKey||(a?e.showAutofill(m,g):He.call(this,!1,m,g),bs(window,v=>{({ri:m,ci:g}=t.getCellRectByXY(v.offsetX,v.offsetY)),a?e.showAutofill(m,g):v.buttons===1&&!v.shiftKey&&He.call(this,!0,m,g,!0,!0)},()=>{a&&e.arange&&t.settings.mode!=="read"&&t.autofill(e.arange,"all",v=>Fs("Tip",v))&&s.render(),e.hideAutofill(),Io.call(this)})),!a&&r.buttons===1&&r.shiftKey&&He.call(this,!0,m,g)}function ct(){const{editor:r,data:e}=this,t=e.getSelectedRect(),s=this.getTableOffset();let i="top";t.top>s.height/2&&(i="bottom"),r.setOffset(t,i)}function nt(){const{editor:r,data:e}=this;e.settings.mode!=="read"&&(ct.call(this),r.setCell(e.getSelectedCell(),e.getSelectedValidator()),at.call(this))}function Ao(r){const{data:e,table:t,selector:s}=this;e.scrolly(r,()=>{s.resetBRLAreaOffset(),ct.call(this),t.render()})}function Ho(r){const{data:e,table:t,selector:s}=this;e.scrollx(r,()=>{s.resetBRTAreaOffset(),ct.call(this),t.render()})}function Wo(r,e){const{ri:t}=r,{table:s,selector:i,data:n}=this;n.rows.setHeight(t,e),s.render(),i.resetAreaOffset(),cr.call(this),ct.call(this)}function Bo(r,e){const{ci:t}=r,{table:s,selector:i,data:n}=this;n.cols.setWidth(t,e),s.render(),i.resetAreaOffset(),fr.call(this),ct.call(this)}function At(r,e="finished"){const{data:t,table:s}=this;if(t.settings.mode==="read")return;t.setSelectedCellText(r,e);const{ri:i,ci:n}=t.selector;e==="finished"?s.render():this.trigger("cell-edited",r,i,n)}function jt(r){const{data:e}=this;e.settings.mode!=="read"&&(r==="insert-row"?e.insert("row"):r==="delete-row"?e.delete("row"):r==="insert-column"?e.insert("column"):r==="delete-column"?e.delete("column"):r==="delete-cell"?e.deleteCell():r==="delete-cell-format"?e.deleteCell("format"):r==="delete-cell-text"?e.deleteCell("text"):r==="cell-printable"?e.setSelectedCellAttr("printable",!0):r==="cell-non-printable"?e.setSelectedCellAttr("printable",!1):r==="cell-editable"?e.setSelectedCellAttr("editable",!0):r==="cell-non-editable"&&e.setSelectedCellAttr("editable",!1),at.call(this),fe.call(this))}function Vo(r,e){const{data:t}=this;if(r==="undo")this.undo();else if(r==="redo")this.redo();else if(r==="print")this.print.preview();else if(r==="paintformat")e===!0?Yt.call(this):at.call(this);else if(r==="clearformat")jt.call(this,"delete-cell-format");else if(r!=="link"){if(r!=="chart")if(r==="autofilter")Lo.call(this);else if(r==="freeze")if(e){const{ri:s,ci:i}=t.selector;this.freeze(s,i)}else this.freeze(0,0);else t.setSelectedCellAttr(r,e),r==="formula"&&!t.selector.multiple()&&nt.call(this),fe.call(this)}}function qo(r,e,t,s){this.data.setAutoFilter(r,e,t,s),fe.call(this)}function Uo(){const{selector:r,overlayerEl:e,rowResizer:t,colResizer:s,verticalScrollbar:i,horizontalScrollbar:n,editor:l,contextMenu:a,toolbar:c,modalValidation:f,sortFilter:d}=this;e.on("mousemove",h=>{zo.call(this,h)}).on("mousedown",h=>{l.clear(),a.hide(),h.buttons===2?(this.data.xyInSelectedRect(h.offsetX,h.offsetY)||es.call(this,h),a.setPosition(h.offsetX,h.offsetY),h.stopPropagation()):h.detail===2?nt.call(this):es.call(this,h)}).on("mousewheel.stop",h=>{_o.call(this,h)}).on("mouseout",h=>{const{offsetX:u,offsetY:m}=h;m<=0&&s.hide(),u<=0&&t.hide()}),r.inputChange=h=>{At.call(this,h,"input"),nt.call(this)},Kn(e.el,{move:(h,u)=>{Do.call(this,h,u)}}),c.change=(h,u)=>Vo.call(this,h,u),d.ok=(h,u,m,g)=>qo.call(this,h,u,m,g),t.finishedFn=(h,u)=>{Wo.call(this,h,u)},s.finishedFn=(h,u)=>{Bo.call(this,h,u)},t.unhideFn=h=>{Qr.call(this,"row",h)},s.unhideFn=h=>{Qr.call(this,"col",h)},i.moveFn=(h,u)=>{Ao.call(this,h,u)},n.moveFn=(h,u)=>{Ho.call(this,h,u)},l.change=(h,u)=>{At.call(this,u,h)},f.change=(h,...u)=>{h==="save"?this.data.addValidation(...u):this.data.removeValidation()},a.itemClick=h=>{h==="validation"?f.setValue(this.data.getSelectedValidation()):h==="copy"?Yt.call(this):h==="cut"?Kr.call(this):h==="paste"?it.call(this,"all"):h==="paste-value"?it.call(this,"text"):h==="paste-format"?it.call(this,"format"):h==="hide"?Oo.call(this):jt.call(this,h)},de(window,"resize",()=>{this.reload()}),de(window,"click",h=>{this.focusing=e.contains(h.target)}),de(window,"paste",h=>{this.focusing&&(it.call(this,"all",h),h.preventDefault())}),de(window,"keydown",h=>{if(!this.focusing)return;const u=h.keyCode||h.which,{key:m,ctrlKey:g,shiftKey:x,metaKey:v}=h;if(g||v)switch(u){case 90:this.undo(),h.preventDefault();break;case 89:this.redo(),h.preventDefault();break;case 67:Yt.call(this),h.preventDefault();break;case 88:Kr.call(this),h.preventDefault();break;case 85:c.trigger("underline"),h.preventDefault();break;case 86:break;case 37:Ee.call(this,x,"row-first"),h.preventDefault();break;case 38:Ee.call(this,x,"col-first"),h.preventDefault();break;case 39:Ee.call(this,x,"row-last"),h.preventDefault();break;case 40:Ee.call(this,x,"col-last"),h.preventDefault();break;case 32:He.call(this,!1,-1,this.data.selector.ci,!1),h.preventDefault();break;case 66:c.trigger("bold");break;case 73:c.trigger("italic");break}else{switch(u){case 32:x&&He.call(this,!1,this.data.selector.ri,-1,!1);break;case 27:a.hide(),at.call(this);break;case 37:Ee.call(this,x,"left"),h.preventDefault();break;case 38:Ee.call(this,x,"up"),h.preventDefault();break;case 39:Ee.call(this,x,"right"),h.preventDefault();break;case 40:Ee.call(this,x,"down"),h.preventDefault();break;case 9:l.clear(),Ee.call(this,!1,x?"left":"right"),h.preventDefault();break;case 13:l.clear(),Ee.call(this,!1,x?"up":"down"),h.preventDefault();break;case 8:jt.call(this,"delete-cell-text"),h.preventDefault();break}m==="Delete"?(jt.call(this,"delete-cell-text"),h.preventDefault()):u>=65&&u<=90||u>=48&&u<=57||u>=96&&u<=105||h.key==="="?(At.call(this,h.key,"input"),nt.call(this)):u===113&&nt.call(this)}})}class Go{constructor(e,t){this.eventMap=Qn();const{view:s,showToolbar:i,showContextmenu:n}=t.settings;this.el=w("div",`${C}-sheet`),this.toolbar=new No(t,s.width,!i),this.print=new Dl(t),e.children(this.toolbar.el,this.el,this.print.el),this.data=t,this.tableEl=w("canvas",`${C}-table`),this.rowResizer=new Pr(!1,t.rows.height),this.colResizer=new Pr(!0,t.cols.minWidth),this.verticalScrollbar=new Or(!0),this.horizontalScrollbar=new Or(!1),this.editor=new xl(Sl,()=>this.getTableOffset(),t.rows.height),this.modalValidation=new Ro,this.contextMenu=new Il(()=>this.getRect(),!n),this.selector=new rl(t),this.overlayerCEl=w("div",`${C}-overlayer-content`).children(this.editor.el,this.selector.el),this.overlayerEl=w("div",`${C}-overlayer`).child(this.overlayerCEl),this.sortFilter=new Mo,this.el.children(this.tableEl,this.overlayerEl.el,this.rowResizer.el,this.colResizer.el,this.verticalScrollbar.el,this.horizontalScrollbar.el,this.contextMenu.el,this.modalValidation.el,this.sortFilter.el),this.table=new Fl(this.tableEl.el,t),Uo.call(this),fe.call(this),He.call(this,!1,0,0)}on(e,t){return this.eventMap.on(e,t),this}trigger(e,...t){const{eventMap:s}=this;s.fire(e,t)}resetData(e){this.editor.clear(),this.data=e,cr.call(this),fr.call(this),this.toolbar.resetData(e),this.print.resetData(e),this.selector.resetData(e),this.table.resetData(e)}loadData(e){return this.data.setData(e),fe.call(this),this}freeze(e,t){const{data:s}=this;return s.setFreeze(e,t),fe.call(this),this}undo(){this.data.undo(),fe.call(this)}redo(){this.data.redo(),fe.call(this)}reload(){return fe.call(this),this}getRect(){const{data:e}=this;return{width:e.viewWidth(),height:e.viewHeight()}}getTableOffset(){const{rows:e,cols:t}=this.data,{width:s,height:i}=this.getRect();return{width:s-t.indexWidth,height:i-e.height,left:t.indexWidth,top:e.height}}}class Xo extends Re{constructor(e){const t=new oe("ellipsis");super(t,"auto",!1,"top-left"),this.contentClick=e}reset(e){const t=e.map((s,i)=>w("div",`${C}-item`).css("width","150px").css("font-weight","normal").on("click",()=>{this.contentClick(i),this.hide()}).child(s));this.setContentChildren(...t)}setTitle(){}}const Zo=[{key:"delete",title:W("contextmenu.deleteSheet")}];function Yo(r){return w("div",`${C}-item`).child(r.title()).on("click",()=>{this.itemClick(r.key),this.hide()})}function Jo(){return Zo.map(r=>Yo.call(this,r))}class Ko{constructor(){this.el=w("div",`${C}-contextmenu`).css("width","160px").children(...Jo.call(this)).hide(),this.itemClick=()=>{}}hide(){const{el:e}=this;e.hide(),et(e)}setOffset(e){const{el:t}=this;t.offset(e),t.show(),ot(t)}}class Qo{constructor(e=()=>{},t=()=>{},s=()=>{},i=()=>{}){this.swapFunc=t,this.updateFunc=i,this.dataNames=[],this.activeEl=null,this.deleteEl=null,this.items=[],this.moreEl=new Xo(n=>{this.clickSwap2(this.items[n])}),this.contextMenu=new Ko,this.contextMenu.itemClick=s,this.el=w("div",`${C}-bottombar`).children(this.contextMenu.el,this.menuEl=w("ul",`${C}-menu`).child(w("li","").children(new oe("add").on("click",()=>{e()}),w("span","").child(this.moreEl))))}addItem(e,t){this.dataNames.push(e);const s=w("li",t?"active":"").child(e);s.on("click",()=>{this.clickSwap2(s)}).on("contextmenu",i=>{const{offsetLeft:n,offsetHeight:l}=i.target;this.contextMenu.setOffset({left:n,bottom:l+1}),this.deleteEl=s}).on("dblclick",()=>{const i=s.html(),n=new Ke("auto","");n.val(i),n.input.on("blur",({target:l})=>{const{value:a}=l,c=this.dataNames.findIndex(f=>f===i);this.renameItem(c,a)}),s.html("").child(n.el),n.focus()}),t&&this.clickSwap(s),this.items.push(s),this.menuEl.child(s),this.moreEl.reset(this.dataNames)}renameItem(e,t){this.dataNames.splice(e,1,t),this.moreEl.reset(this.dataNames),this.items[e].html("").child(t),this.updateFunc(e,t)}clear(){this.items.forEach(e=>{this.menuEl.removeChild(e.el)}),this.items=[],this.dataNames=[],this.moreEl.reset(this.dataNames)}deleteItem(){const{activeEl:e,deleteEl:t}=this;if(this.items.length>1){const s=this.items.findIndex(i=>i===t);if(this.items.splice(s,1),this.dataNames.splice(s,1),this.menuEl.removeChild(t.el),this.moreEl.reset(this.dataNames),e===t){const[i]=this.items;return this.activeEl=i,this.activeEl.toggle(),[s,0]}return[s,-1]}return[-1]}clickSwap2(e){const t=this.items.findIndex(s=>s===e);this.clickSwap(e),this.activeEl.toggle(),this.swapFunc(t)}clickSwap(e){this.activeEl!==null&&this.activeEl.toggle(),this.activeEl=e}}class dr{constructor(e,t={}){let s=e;this.options={showBottomBar:!0,...t},this.sheetIndex=1,this.datas=[],typeof e=="string"&&(s=document.querySelector(e)),this.bottombar=this.options.showBottomBar?new Qo(()=>{const n=this.addSheet();this.sheet.resetData(n)},n=>{const l=this.datas[n];this.sheet.resetData(l)},()=>{this.deleteSheet()},(n,l)=>{this.datas[n].name=l}):null,this.data=this.addSheet();const i=w("div",`${C}`).on("contextmenu",n=>n.preventDefault());s.appendChild(i.el),this.sheet=new Go(i,this.data),this.bottombar!==null&&i.child(this.bottombar.el)}addSheet(e,t=!0){const s=e||`sheet${this.sheetIndex}`,i=new Jn(s,this.options);return i.change=(...n)=>{this.sheet.trigger("change",...n)},this.datas.push(i),this.bottombar!==null&&this.bottombar.addItem(s,t),this.sheetIndex+=1,i}deleteSheet(){if(this.bottombar===null)return;const[e,t]=this.bottombar.deleteItem();e>=0&&(this.datas.splice(e,1),t>=0&&this.sheet.resetData(this.datas[t]))}loadData(e){const t=Array.isArray(e)?e:[e];if(this.bottombar!==null&&this.bottombar.clear(),this.datas=[],t.length>0)for(let s=0;s<t.length;s+=1){const i=t[s],n=this.addSheet(i.name,s===0);n.setData(i),s===0&&this.sheet.resetData(n)}return this}getData(){return this.datas.map(e=>e.getData())}cellText(e,t,s,i=0){return this.datas[i].setCellText(e,t,s,"finished"),this}cell(e,t,s=0){return this.datas[s].getCell(e,t)}cellStyle(e,t,s=0){return this.datas[s].getCellStyle(e,t)}reRender(){return this.sheet.table.render(),this}on(e,t){return this.sheet.on(e,t),this}validate(){const{validations:e}=this.data;return e.errors.size<=0}change(e){return this.sheet.on("change",e),this}static locale(e,t){gs(e,t)}}const ea=(r,e={})=>new dr(r,e);window&&(window.x_spreadsheet=ea,window.x_spreadsheet.locale=(r,e)=>gs(r,e));const ta=({url:r})=>{const e=Q(),[t,s]=p.useState(!0),[i,n]=p.useState(null),l=p.useRef(null),a=p.useRef(null),c=p.useRef(null),f=p.useRef(null),d=p.useRef(null),h=p.useRef({width:0,height:0}),u=p.useCallback(()=>{if(!l.current)return{width:800,height:600};const g=l.current.clientWidth,x=l.current.clientHeight,v=g>100?g:800,b=x>100?x:600;return{width:v,height:b}},[]),m=p.useCallback(()=>{if(!l.current||!c.current)return;l.current.innerHTML="",a.current=null;const{width:g,height:x}=u(),v=g<640,b=new dr(l.current,{mode:"read",showToolbar:!1,showContextmenu:!1,showGrid:!0,row:{len:100,height:25},col:{len:26,width:v?80:100,indexWidth:v?40:60,minWidth:v?40:60},view:{height:()=>x,width:()=>g}});b.loadData(c.current),a.current=b},[u]);return p.useEffect(()=>{if(!l.current)return;let g=!0;const x=()=>{if(g){g=!1,h.current=u();return}const v=u(),b=h.current,y=Math.abs(b.width-v.width),j=Math.abs(b.height-v.height);y<10&&j<10||(h.current=v,d.current&&clearTimeout(d.current),d.current=window.setTimeout(()=>{c.current&&m()},500))};return f.current=new ResizeObserver(()=>{x()}),f.current.observe(l.current),()=>{f.current&&f.current.disconnect(),d.current&&clearTimeout(d.current)}},[u,m]),p.useEffect(()=>{let g=!0;const x=async()=>{if(l.current){s(!0),n(null);try{const b=await fetch(r,{mode:"cors",credentials:"omit",redirect:"follow"});if(!b.ok)throw b.status===404?new Error(e("xlsx.not_found")):b.status===403?new Error("无权限访问此文件"):new Error(`文件加载失败 (${b.status})`);const y=await b.arrayBuffer();if(y.byteLength===0)throw new Error("文件为空");const j=new Us.Workbook;await j.xlsx.load(y);const k=Mi(j);if(!g)return;c.current=k,m(),s(!1)}catch(b){if(g){console.error("Excel 解析错误:",b);let y=e("xlsx.parse_failed");b instanceof Error&&(y=b.message),n(y),s(!1)}}}},v=setTimeout(()=>{requestAnimationFrame(()=>{x()})},100);return()=>{g=!1,clearTimeout(v),c.current=null,l.current&&(l.current.innerHTML=""),a.current=null}},[r,m]),o.jsxs("div",{className:"rfp-relative rfp-flex rfp-flex-col rfp-items-center rfp-w-full rfp-h-full",children:[t&&o.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-toolbar rfp-backdrop-blur-sm rfp-z-10",children:o.jsxs("div",{className:"rfp-text-center",children:[o.jsx("div",{className:"rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-mx-auto rfp-mb-3 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"}),o.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-fg-secondary rfp-font-medium",children:e("xlsx.loading")})]})}),i&&!t&&o.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-toolbar rfp-backdrop-blur-sm rfp-z-10",children:o.jsxs("div",{className:"rfp-text-center rfp-max-w-sm md:rfp-max-w-md rfp-px-4",children:[o.jsx("div",{className:"rfp-w-24 rfp-h-24 md:rfp-w-32 md:rfp-h-32 rfp-mx-auto rfp-mb-4 md:rfp-mb-6 rfp-rounded-2xl md:rfp-rounded-3xl rfp-bg-gradient-to-br rfp-from-green-500 rfp-via-emerald-500 rfp-to-teal-500 rfp-flex rfp-items-center rfp-justify-center rfp-shadow-2xl",children:o.jsx(T.FileSpreadsheet,{className:"rfp-w-12 rfp-h-12 md:rfp-w-16 md:rfp-h-16 rfp-text-fg-primary"})}),o.jsx("p",{className:"rfp-text-lg md:rfp-text-xl rfp-text-fg-primary rfp-mb-2 md:rfp-mb-3 rfp-font-medium",children:e("xlsx.load_failed")}),o.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-fg-tertiary rfp-mb-4 md:rfp-mb-6",children:i}),o.jsxs("a",{href:r,download:!0,className:"rfp-inline-flex rfp-items-center rfp-gap-2 rfp-px-4 rfp-py-2 md:rfp-px-6 md:rfp-py-3 rfp-bg-gradient-to-r rfp-from-purple-500 rfp-to-pink-500 rfp-text-fg-primary rfp-text-sm md:rfp-text-base rfp-rounded-lg md:rfp-rounded-xl hover:rfp-scale-105 rfp-transition-all rfp-shadow-lg",children:[o.jsx("svg",{className:"rfp-w-4 rfp-h-4 md:rfp-w-5 md:rfp-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),e("common.download")]}),o.jsx("p",{className:"rfp-text-xs rfp-text-fg-muted rfp-mt-3 md:rfp-mt-4",children:"提示:可以使用 Microsoft Excel 或 WPS 打开"})]})}),!i&&o.jsx("div",{ref:l,className:"xlsx-spreadsheet-container rfp-w-full rfp-h-full",style:{opacity:t?0:1}})]})},ra=Object.freeze(Object.defineProperty({__proto__:null,XlsxRenderer:ta},Symbol.toStringTag,{value:"Module"})),sa=({url:r,tiled:e=!0})=>{const t=Q(),[s,i]=p.useState(!0),[n,l]=p.useState(null),[a,c]=p.useState(0),f=p.useRef(null),d=p.useRef(null),h=p.useRef(null),u=p.useRef(null),m=p.useRef(null),g=p.useRef({width:0,height:0}),x=p.useCallback(()=>{var N;if(!f.current)return{width:960,height:540};const b=f.current.clientWidth,y=((N=f.current.parentElement)==null?void 0:N.clientWidth)||0,j=b>100?b:y>100?y:300,k=Math.floor(j*9/16);return{width:j,height:k}},[]),v=p.useCallback(async()=>{if(!(!f.current||!u.current||a===0))try{if(d.current)try{d.current.destroy()}catch{}f.current.innerHTML="";const b=x(),y=zt.init(f.current,{width:b.width,height:e?b.height*a:b.height,mode:e?"list":"slide"});d.current=y,await y.preview(u.current)}catch{}},[x,e,a]);return p.useEffect(()=>{if(!f.current)return;let b=!0;const y=()=>{if(b){b=!1,g.current=x();return}const j=x(),k=g.current,N=Math.abs(k.width-j.width),M=Math.abs(k.height-j.height);N<10&&M<10||(g.current=j,m.current&&clearTimeout(m.current),m.current=window.setTimeout(()=>{d.current&&u.current&&v()},800))};return h.current=new ResizeObserver(()=>{y()}),h.current.observe(f.current),()=>{h.current&&h.current.disconnect(),m.current&&clearTimeout(m.current)}},[x,v]),p.useEffect(()=>{let b=!0,y=null;const j=async()=>{if(f.current){i(!0),l(null),y=setTimeout(()=>{b&&(l(t("pptx.timeout")),i(!1))},3e4);try{const N=await fetch(r,{mode:"cors",credentials:"omit",redirect:"follow"});if(!N.ok)throw N.status===404?new Error(t("pptx.not_found")):N.status===403?new Error("无权限访问此文件"):N.status>=500?new Error("服务器错误,请稍后重试"):new Error(`文件加载失败 (${N.status})`);const M=await N.arrayBuffer();if(M.byteLength===0)throw new Error("文件为空");if(u.current=M,!b)return;const z=document.createElement("div");z.style.cssText="position:absolute;left:-9999px;top:-9999px;visibility:hidden",document.body.appendChild(z);try{const P=zt.init(z,{width:100,height:100,mode:"slide"});try{await P.preview(M)}catch{throw new Error(t("pptx.invalid_format"))}const S=P.slideCount;if(!S||S===0)throw new Error(t("pptx.no_pages"));if(P.destroy(),!b)return;c(S),f.current&&(f.current.innerHTML="");const F=x(),L=zt.init(f.current,{width:F.width,height:e?F.height*S:F.height,mode:e?"list":"slide"});d.current=L,await L.preview(M),y&&(clearTimeout(y),y=null),b&&i(!1)}finally{document.body.contains(z)&&document.body.removeChild(z)}}catch(N){if(y&&(clearTimeout(y),y=null),b){let M=t("pptx.parse_failed");N instanceof Error?M=N.message:typeof N=="string"&&(M=N),l(M),i(!1)}}}},k=setTimeout(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{j()})})},150);return()=>{if(b=!1,clearTimeout(k),y&&clearTimeout(y),u.current=null,c(0),d.current)try{d.current.destroy()}catch{}d.current=null}},[r,x,e]),o.jsxs("div",{className:"rfp-relative rfp-flex rfp-flex-col rfp-items-center rfp-w-full rfp-h-full",children:[s&&o.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-toolbar rfp-backdrop-blur-sm rfp-z-10",children:o.jsxs("div",{className:"rfp-text-center",children:[o.jsx("div",{className:"rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-mx-auto rfp-mb-3 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"}),o.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-fg-secondary rfp-font-medium",children:t("pptx.loading")})]})}),n&&!s&&o.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-toolbar rfp-backdrop-blur-sm rfp-z-10",children:o.jsxs("div",{className:"rfp-text-center rfp-max-w-sm md:rfp-max-w-md rfp-px-4",children:[o.jsx("div",{className:"rfp-w-24 rfp-h-24 md:rfp-w-32 md:rfp-h-32 rfp-mx-auto rfp-mb-4 md:rfp-mb-6 rfp-rounded-2xl md:rfp-rounded-3xl rfp-bg-gradient-to-br rfp-from-orange-500 rfp-via-red-500 rfp-to-pink-500 rfp-flex rfp-items-center rfp-justify-center rfp-shadow-2xl",children:o.jsx(T.Presentation,{className:"rfp-w-12 rfp-h-12 md:rfp-w-16 md:rfp-h-16 rfp-text-fg-primary"})}),o.jsx("p",{className:"rfp-text-lg md:rfp-text-xl rfp-text-fg-primary rfp-mb-2 md:rfp-mb-3 rfp-font-medium",children:t("pptx.load_failed")}),o.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-fg-tertiary rfp-mb-4 md:rfp-mb-6",children:n}),o.jsxs("a",{href:r,download:!0,className:"rfp-inline-flex rfp-items-center rfp-gap-2 rfp-px-4 rfp-py-2 md:rfp-px-6 md:rfp-py-3 rfp-bg-gradient-to-r rfp-from-purple-500 rfp-to-pink-500 rfp-text-fg-primary rfp-text-sm md:rfp-text-base rfp-rounded-lg md:rfp-rounded-xl hover:rfp-scale-105 rfp-transition-all rfp-shadow-lg",children:[o.jsx("svg",{className:"rfp-w-4 rfp-h-4 md:rfp-w-5 md:rfp-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),t("common.download")]}),o.jsx("p",{className:"rfp-text-xs rfp-text-fg-muted rfp-mt-3 md:rfp-mt-4",children:"提示:可以使用 Microsoft PowerPoint 或 WPS 打开"})]})}),!n&&o.jsx("div",{ref:f,className:"pptx-wrapper rfp-w-full rfp-max-w-full md:rfp-max-w-6xl",style:{opacity:s?0:1}})]})},ia=Object.freeze(Object.defineProperty({__proto__:null,PptxRenderer:sa},Symbol.toStringTag,{value:"Module"}));function Ht(r,e){return r?r.filter(t=>t.recipType===e).map(t=>{const s=t.name||"",i=t.smtpAddress||t.email||"";return s&&i&&s!==i?`${s} <${i}>`:s||i}).filter(Boolean).join("; "):""}function vt(r){if(!r)return"";try{const e=new Date(r);return isNaN(e.getTime())?r:e.toLocaleString()}catch{return r}}function na(r,e){if(r.bodyHtml)return r.bodyHtml;if(r.html)try{return new TextDecoder("utf-8").decode(r.html)}catch{}return r.body?`<pre style="white-space: pre-wrap; word-wrap: break-word; font-family: system-ui, sans-serif;">${r.body.replace(/&/g,"&").replace(/\x3c/g,"<").replace(/>/g,">")}</pre>`:`<p style="color: #999;">${e}</p>`}function la(r){return r?{"IPM.Note":"Email","IPM.Note.SMIME":"Encrypted Email","IPM.Note.SMIME.MultipartSigned":"Signed Email","IPM.Appointment":"Appointment","IPM.Schedule.Meeting.Request":"Meeting Request","IPM.Schedule.Meeting.Canceled":"Meeting Cancellation","IPM.Contact":"Contact","IPM.Task":"Task","IPM.StickyNote":"Sticky Note"}[r]||r:""}const me={flexShrink:0,color:"#6b7280",fontWeight:500,marginRight:"8px",whiteSpace:"nowrap"},ge={display:"flex",alignItems:"flex-start",gap:"8px",padding:"6px 0"},xe={flexShrink:0,display:"flex",alignItems:"center",height:"1.4em"},be={flexShrink:0,color:"#9ca3af"},we={color:"#111827",wordBreak:"break-word",flex:1},oa=({url:r})=>{const e=Q(),[t,s]=p.useState(!0),[i,n]=p.useState(null),[l,a]=p.useState(null);if(p.useEffect(()=>{(async()=>{s(!0),n(null),a(null);try{const U=await fetch(r);if(!U.ok)throw new Error("文件加载失败");const E=await U.arrayBuffer(),$=new Gs(E).getFileData();a($)}catch(U){console.error("MSG 解析错误:",U),n(e("msg.parse_failed"))}finally{s(!1)}})()},[r]),t)return o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})});if(i||!l)return o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:o.jsx("p",{className:"rfp-text-lg",children:i||e("msg.parse_failed_short")})})});const c=Ht(l.recipients,"to"),f=Ht(l.recipients,"cc"),d=Ht(l.recipients,"bcc"),h=l.senderName||"",u=l.senderSmtpAddress||l.senderEmail||"",m=h&&u&&h!==u?`${h} <${u}>`:h||u,g=vt(l.clientSubmitTime),x=vt(l.messageDeliveryTime),v=vt(l.creationTime),b=vt(l.lastModificationTime),y=l.subject||"(无主题)",j=(l.attachments||[]).filter(H=>!H.attachmentHidden),k=na(l,e("msg.empty_body")),N=la(l.messageClass),M=l.messageId||"",z=l,P=typeof z.importance=="number"?z.importance:void 0,S=P===2?"High":P===0?"Low":"",F=typeof z.sensitivity=="number"?z.sensitivity:void 0,V=F!==void 0&&F!==0&&{0:"Normal",1:"Personal",2:"Private",3:"Confidential"}[F]||"";return o.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto",style:{background:"white"},children:o.jsxs("div",{style:{width:"100%",background:"white",minHeight:"100%"},children:[o.jsxs("div",{style:{borderBottom:"1px solid #e5e7eb",padding:"clamp(12px, 3vw, 24px) clamp(16px, 3vw, 28px)",background:"#f9fafb"},children:[o.jsx("h2",{style:{margin:"0 0 16px 0",fontSize:"clamp(16px, 2.5vw, 20px)",fontWeight:600,color:"#111827",lineHeight:1.4},children:y}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",fontSize:"clamp(12px, 1.8vw, 14px)",color:"#4b5563"},children:[m&&o.jsxs("div",{style:ge,children:[o.jsx("span",{style:xe,children:o.jsx(T.User,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"From"}),o.jsx("span",{style:we,children:m})]})]}),c&&o.jsxs("div",{style:ge,children:[o.jsx("span",{style:xe,children:o.jsx(T.Users,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"To"}),o.jsx("span",{style:we,children:c})]})]}),f&&o.jsxs("div",{style:ge,children:[o.jsx("span",{style:xe,children:o.jsx(T.Users,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"Cc"}),o.jsx("span",{style:we,children:f})]})]}),d&&o.jsxs("div",{style:ge,children:[o.jsx("span",{style:xe,children:o.jsx(T.Users,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"Bcc"}),o.jsx("span",{style:we,children:d})]})]}),g&&o.jsxs("div",{style:ge,children:[o.jsx("span",{style:xe,children:o.jsx(T.Calendar,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"Sent"}),o.jsx("span",{style:we,children:g})]})]}),x&&x!==g&&o.jsxs("div",{style:ge,children:[o.jsx("span",{style:xe,children:o.jsx(T.Clock,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"Received"}),o.jsx("span",{style:we,children:x})]})]}),!g&&!x&&v&&o.jsxs("div",{style:ge,children:[o.jsx("span",{style:xe,children:o.jsx(T.Calendar,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"Date"}),o.jsx("span",{style:we,children:v})]})]}),S&&o.jsxs("div",{style:ge,children:[o.jsx("span",{style:xe,children:o.jsx(T.Tag,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"Importance"}),o.jsx("span",{style:{...we,color:P===2?"#dc2626":"#2563eb",fontWeight:500},children:S})]})]}),V&&o.jsxs("div",{style:ge,children:[o.jsx("span",{style:xe,children:o.jsx(T.Tag,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"Sensitivity"}),o.jsx("span",{style:we,children:V})]})]}),N&&N!=="Email"&&o.jsxs("div",{style:ge,children:[o.jsx("span",{style:xe,children:o.jsx(T.Mail,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"Type"}),o.jsx("span",{style:we,children:N})]})]}),j.length>0&&o.jsxs("div",{style:{...ge,borderTop:"1px solid #e5e7eb",marginTop:"4px",paddingTop:"10px"},children:[o.jsx("span",{style:xe,children:o.jsx(T.Paperclip,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"Attachments"}),o.jsx("div",{style:{...we,display:"flex",flexWrap:"wrap",gap:"6px"},children:j.map((H,U)=>{const E=H.fileName||H.name||"未知文件",R=H.contentLength,$=R?R>1048576?`${(R/1048576).toFixed(1)} MB`:R>1024?`${(R/1024).toFixed(0)} KB`:`${R} B`:"";return o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",background:"#f3f4f6",borderRadius:"4px",fontSize:"13px",color:"#374151",border:"1px solid #e5e7eb"},children:[E,$&&o.jsxs("span",{style:{color:"#9ca3af",fontSize:"12px"},children:["(",$,")"]})]},U)})})]})]}),M&&o.jsxs("div",{style:{...ge,borderTop:j.length>0?"none":"1px solid #e5e7eb",marginTop:"4px",paddingTop:"10px"},children:[o.jsx("span",{style:xe,children:o.jsx(T.Hash,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"Message-ID"}),o.jsx("span",{style:{...we,fontSize:"12px",color:"#9ca3af",fontFamily:"monospace"},children:M})]})]}),b&&b!==g&&b!==x&&o.jsxs("div",{style:ge,children:[o.jsx("span",{style:xe,children:o.jsx(T.Clock,{size:16,style:be})}),o.jsxs("div",{style:{display:"flex",flex:1},children:[o.jsx("span",{style:me,children:"Modified"}),o.jsx("span",{style:{...we,fontSize:"12px",color:"#9ca3af"},children:b})]})]})]})]}),o.jsx("div",{style:{padding:"clamp(12px, 3vw, 24px) clamp(16px, 3vw, 28px)",fontFamily:"system-ui, -apple-system, sans-serif",lineHeight:"1.6",color:"#333",overflowX:"auto"},dangerouslySetInnerHTML:{__html:k}})]})})},aa=Object.freeze(Object.defineProperty({__proto__:null,MsgRenderer:oa},Symbol.toStringTag,{value:"Module"}));if(typeof document<"u"&&!document.getElementById("rfp-epub-styles")){const r=document.createElement("style");r.id="rfp-epub-styles",r.textContent=`
|
|
15
|
+
`).replace(/\\h/g," ").replace(/\{[^}]*\}/g,"");i.push({start:g,end:v,text:k,style:b.Style})}return i.sort((l,f)=>l.start-f.start),{format:t,cues:i,header:p.join(`
|
|
16
|
+
`).trim()||void 0}}function Ae(r){const t=r.trim();if(!t)return 0;const n=/^(\d+(?:\.\d+)?)(h|m|s|ms|f|t)$/i.exec(t);if(n){const o=Number(n[1]),i=n[2].toLowerCase();return i==="h"?o*3600:i==="m"?o*60:i==="ms"?o/1e3:o}const a=t.split(":");return a.length===3?Number(a[0])*3600+Number(a[1])*60+Number(a[2]):a.length===2?Number(a[0])*60+Number(a[1]):Number(t)||0}function mt(r){if(typeof DOMParser>"u")throw new Error("TTML parsing requires a DOMParser environment");const t=new DOMParser().parseFromString(r,"application/xml");if(t.getElementsByTagName("parsererror").length>0)throw new Error("TTML XML parse error");const n=t.getElementsByTagName("p"),a=[];for(let o=0;o<n.length;o++){const i=n[o],p=i.getAttribute("begin")||"",l=i.getAttribute("end")||"",f=i.getAttribute("dur")||"",u=Ae(p);let d;l?d=Ae(l):f?d=u+Ae(f):d=u+5;let c="";i.childNodes.forEach(h=>{if(h.nodeType===3)c+=h.nodeValue||"";else if(h.nodeType===1){const y=h;y.tagName.toLowerCase()==="br"?c+=`
|
|
17
|
+
`:c+=y.textContent||""}});const m=c.replace(/[ \t]+/g," ").replace(/\n /g,`
|
|
18
|
+
`).trim();(m||u||d)&&a.push({start:u,end:d,text:m})}return a.sort((o,i)=>o.start-i.start),{format:"ttml",cues:a}}function ht(r,t){switch(t??pt(r)){case"lrc":return dt(r);case"elrc":return ut(r);case"ass":return fr(r,"ass");case"ssa":return fr(r,"ssa");case"ttml":return mt(r);case"vtt":return ir(r,"vtt");case"srt":default:return ir(r,"srt")}}async function xt(r){return Jr.loadAsync(r)}function bt(r){const t=[];return r.forEach((n,a)=>{var o;const i=a.dir,p=i&&!n.endsWith("/")?n+"/":n,l=i?p.replace(/\/$/,""):p,f=l.lastIndexOf("/"),u=f>=0?l.slice(f+1):l,d=f>=0?l.slice(0,f):"",c=i?0:((o=a._data)==null?void 0:o.uncompressedSize)??0;t.push({path:p,name:u,dir:d,isDir:i,size:c,date:a.date})}),t}function gt(r){const t={name:"",path:"",isDir:!0,children:[],size:0},n=new Map;n.set("",t);const a=i=>{if(n.has(i))return n.get(i);const p=i.split("/").filter(Boolean);let l=t,f="";for(const u of p){f=f?`${f}/${u}`:u;let d=n.get(f);d||(d={name:u,path:f+"/",isDir:!0,children:[],size:0},l.children.push(d),n.set(f,d)),l=d}return l};for(const i of r){if(i.isDir){a(i.path.replace(/\/$/,""));continue}a(i.dir).children.push({name:i.name,path:i.path,isDir:!1,size:i.size})}const o=i=>{if(i.children){i.children.sort((p,l)=>p.isDir!==l.isDir?p.isDir?-1:1:p.name.localeCompare(l.name));for(const p of i.children)o(p)}};return o(t),t}async function yt(r,t,n){const a=r.file(t);if(!a)throw new Error(`ZIP entry not found: ${t}`);const o=await a.async("arraybuffer");return new Blob([o],n?{type:n}:void 0)}function wt(r){return r?r.startsWith("#")?r:r.length===8?"#"+r.substring(2):r.length===6?"#"+r:"#000000":"#000000"}const vt=["FFFFFF","000000","E7E6E6","44546A","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47"],jt=["000000","FFFFFF","FF0000","00FF00","0000FF","FFFF00","FF00FF","00FFFF","000000","FFFFFF","FF0000","00FF00","0000FF","FFFF00","FF00FF","00FFFF","800000","008000","000080","808000","800080","008080","C0C0C0","808080","9999FF","993366","FFFFCC","CCFFFF","660066","FF8080","0066CC","CCCCFF","000080","FF00FF","FFFF00","00FFFF","800080","800000","008080","0000FF","00CCFF","CCFFFF","CCFFCC","FFFF99","99CCFF","FF99CC","CC99FF","FFCC99","3366FF","33CCCC","99CC00","FFCC00","FF9900","FF6600","666699","969696","003366","339966","003300","333300","993300","993366","333399","333333"];function Nt(r,t){const n=parseInt(r.substring(0,2),16),a=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16),i=u=>t<0?Math.round(u*(1+t)):Math.round(u+(255-u)*t),p=Math.min(255,Math.max(0,i(n))),l=Math.min(255,Math.max(0,i(a))),f=Math.min(255,Math.max(0,i(o)));return p.toString(16).padStart(2,"0")+l.toString(16).padStart(2,"0")+f.toString(16).padStart(2,"0")}function kt(r){if(r&&r.type==="pattern"&&r.pattern==="solid"){const t=r.fgColor;if(t)return Ve(t)}}function Ve(r){if(r){if("argb"in r&&typeof r.argb=="string"&&r.argb)return wt(r.argb);if("theme"in r&&typeof r.theme=="number"){const t=vt[r.theme]||"000000",n="tint"in r&&typeof r.tint=="number"?r.tint:0;return"#"+(n!==0?Nt(t,n):t)}if("indexed"in r&&typeof r.indexed=="number"){const t=jt[r.indexed];if(t)return"#"+t}}}function St(r){if(!r||!r.style)return;const t=Ve(r.color)||"#000000";return[r.style,t]}function _t(r){const t={};let n=!1;if(r.font){const o=r.font;if((o.name||o.size||o.bold||o.italic)&&(n=!0,t.font={},o.name&&(t.font.name=o.name),o.size&&(t.font.size=o.size),o.bold&&(t.font.bold=!0),o.italic&&(t.font.italic=!0)),o.color){const i=Ve(o.color);i&&(n=!0,t.color=i)}o.underline&&(n=!0,t.underline=!0),o.strike&&(n=!0,t.strike=!0)}const a=kt(r.fill);if(a&&(n=!0,t.bgcolor=a),r.alignment){const o=r.alignment;o.horizontal&&(n=!0,t.align=o.horizontal),o.vertical&&(n=!0,t.valign=o.vertical),o.wrapText&&(n=!0,t.textwrap=!0)}if(r.border){const o={};let i=!1;const p=["top","bottom","left","right"];for(const l of p){const f=St(r.border[l]);f&&(o[l]=f,i=!0)}i&&(n=!0,t.border=o)}return n?t:null}function Rt(r){return JSON.stringify(r)}function Ct(r,t,n){const a=_t(r);if(!a)return-1;const o=Rt(a),i=n.get(o);if(i!==void 0)return i;const p=t.length;return t.push(a),n.set(o,p),p}function Mt(r){const t=r.value;if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number")return String(t);if(typeof t=="boolean")return t?"TRUE":"FALSE";if(t instanceof Date)return t.toLocaleDateString();if(typeof t=="object"&&"formula"in t){const n=t.result;return n!=null?String(n):""}return typeof t=="object"&&"richText"in t?t.richText.map(n=>n.text).join(""):typeof t=="object"&&"hyperlink"in t?t.text||"":typeof t=="object"&&"error"in t?String(t.error):String(t)}function Tt(r){const t=r.split(":"),n=cr(t[0]),a=t[1]?cr(t[1]):n;return{top:n.row,left:n.col,bottom:a.row,right:a.col}}function cr(r){const t=r.match(/^([A-Z]+)(\d+)$/);if(!t)return{row:1,col:1};const n=t[1],a=parseInt(t[2],10);let o=0;for(let i=0;i<n.length;i++)o=o*26+(n.charCodeAt(i)-64);return{row:a,col:o}}function Et(r){const t=[];return r.eachSheet(n=>{const a=[],o=new Map,i=[],p={},l={},f=n.columnCount;for(let m=1;m<=f;m++){const h=n.getColumn(m);h.width&&(l[String(m-1)]={width:Math.round(h.width*7.5)})}l.len=Math.max(f,26);const u=new Map,d=n.model,c=(d==null?void 0:d.merges)||[];for(const m of c){i.push(m);const{top:h,left:y,bottom:x,right:w}=Tt(m),b=x-h,g=w-y;u.set(`${h-1},${y-1}`,[b,g])}n.eachRow({includeEmpty:!0},(m,h)=>{const y=h-1,x={};m.eachCell({includeEmpty:!1},(b,g)=>{const v=g-1;if(b.isMerged&&b.master!==b)return;const k=Mt(b),S=Ct(b,a,o),M={text:k};S!==-1&&(M.style=S);const T=`${y},${v}`;u.has(T)&&(M.merge=u.get(T)),x[String(v)]=M});const w={cells:x};m.height&&(w.height=Math.round(m.height*1.333)),p[String(y)]=w}),t.push({name:n.name,styles:a,merges:i,rows:p,cols:l})}),t}function Ft(r,t,n="Sheet1"){const a=r.length>0,o=a?[{font:{bold:!0}}]:[],i={};if(a){const l={};r.forEach((f,u)=>{l[String(u)]={text:f,style:0}}),i[0]={cells:l}}const p=a?1:0;return t.forEach((l,f)=>{const u={};l.forEach((d,c)=>{d!==void 0&&d!==""&&(u[String(c)]={text:d})}),i[String(f+p)]={cells:u}}),[{name:n,styles:o,rows:i}]}const Lt={"common.download":"下载","common.close":"关闭","common.loading":"加载中","common.unknown_error":"未知错误","common.unsupported_preview":"不支持预览此文件类型 ({type})","toolbar.zoom_in":"放大","toolbar.zoom_out":"缩小","toolbar.rotate_left":"向左旋转","toolbar.rotate_right":"向右旋转","toolbar.reset":"复原","toolbar.fit_to_window":"适应窗口","toolbar.original_size":"原始尺寸","toolbar.toc":"目录","toolbar.prev_page":"上一页","toolbar.next_page":"下一页","toolbar.full_width":"全屏宽度","toolbar.normal_width":"正常宽度","toolbar.wrap_on":"自动换行","toolbar.wrap_off":"不换行","toolbar.source":"源码","toolbar.preview":"预览","image.load_failed":"图片加载失败","pdf.load_failed":"PDF 文件加载失败","docx.parse_failed":"Word 文档解析失败","xlsx.loading":"加载 Excel 中...","xlsx.load_failed":"Excel 加载失败","xlsx.parse_failed":"Excel 文件解析失败","xlsx.not_found":"Excel 文件不存在","pptx.loading":"加载 PPT 中...","pptx.load_failed":"PPT 加载失败","pptx.parse_failed":"PPT 文件解析失败","pptx.not_found":"PPT 文件不存在","pptx.invalid_format":"PPT 文件格式错误或已损坏","pptx.no_pages":"PPT 文件无有效页面","pptx.timeout":"加载超时,请检查网络或稍后重试","msg.parse_failed":"Outlook 邮件解析失败","msg.parse_failed_short":"邮件解析失败","msg.empty_body":"(无邮件正文)","epub.load_failed":"EPUB 文件加载失败","mobi.load_failed":"电子书加载失败,文件可能已损坏或带有 DRM 保护","video.loading":"加载视频中...","video.load_failed":"视频加载失败","video.load_failed_with_error":"视频加载失败: {error}","audio.aria.play":"播放","audio.aria.pause":"暂停","audio.aria.forward_10":"前进 10 秒","audio.aria.backward_10":"后退 10 秒","audio.aria.mute":"静音","audio.aria.unmute":"取消静音","audio.aria.loop_on":"开启循环","audio.aria.loop_off":"关闭循环","audio.aria.progress":"播放进度","audio.aria.volume":"音量","markdown.load_failed":"Markdown 文件加载失败","markdown.copy_code":"复制代码","markdown.copied":"已复制","json.load_failed":"JSON 文件加载失败","json.items":"items","json.keys":"keys","csv.loading":"加载 CSV 中...","csv.load_failed":"CSV 文件加载失败","csv.parse_failed":"CSV 解析失败","xml.load_failed":"XML 文件加载失败","subtitle.load_failed":"字幕文件加载失败","subtitle.parse_failed":"字幕解析失败","subtitle.lines":"lines","subtitle.cues":"cues","subtitle.meta.title":"标题","subtitle.meta.artist":"艺术家","subtitle.meta.album":"专辑","subtitle.meta.author":"作者","subtitle.meta.by":"制作","subtitle.meta.length":"时长","subtitle.meta.offset":"偏移","subtitle.meta.editor":"编辑器","subtitle.meta.version":"版本","zip.load_failed":"ZIP 文件加载失败","zip.parse_failed":"ZIP 解析失败","text.load_failed":"文本文件加载失败"},Pt={"common.download":"Download","common.close":"Close","common.loading":"Loading","common.unknown_error":"Unknown error","common.unsupported_preview":"Preview not supported for this file type ({type})","toolbar.zoom_in":"Zoom in","toolbar.zoom_out":"Zoom out","toolbar.rotate_left":"Rotate left","toolbar.rotate_right":"Rotate right","toolbar.reset":"Reset","toolbar.fit_to_window":"Fit to window","toolbar.original_size":"Original size","toolbar.toc":"Table of contents","toolbar.prev_page":"Previous page","toolbar.next_page":"Next page","toolbar.full_width":"Full width","toolbar.normal_width":"Normal width","toolbar.wrap_on":"Word wrap","toolbar.wrap_off":"No wrap","toolbar.source":"Source","toolbar.preview":"Preview","image.load_failed":"Failed to load image","pdf.load_failed":"Failed to load PDF","docx.parse_failed":"Failed to parse Word document","xlsx.loading":"Loading Excel...","xlsx.load_failed":"Failed to load Excel","xlsx.parse_failed":"Failed to parse Excel file","xlsx.not_found":"Excel file not found","pptx.loading":"Loading PPT...","pptx.load_failed":"Failed to load PPT","pptx.parse_failed":"Failed to parse PPT file","pptx.not_found":"PPT file not found","pptx.invalid_format":"PPT file format is invalid or corrupted","pptx.no_pages":"PPT file has no valid pages","pptx.timeout":"Loading timed out, please check your network and retry","msg.parse_failed":"Failed to parse Outlook message","msg.parse_failed_short":"Failed to parse message","msg.empty_body":"(No message body)","epub.load_failed":"Failed to load EPUB","mobi.load_failed":"Failed to load ebook — file may be corrupted or DRM-protected","video.loading":"Loading video...","video.load_failed":"Failed to load video","video.load_failed_with_error":"Failed to load video: {error}","audio.aria.play":"Play","audio.aria.pause":"Pause","audio.aria.forward_10":"Forward 10 seconds","audio.aria.backward_10":"Back 10 seconds","audio.aria.mute":"Mute","audio.aria.unmute":"Unmute","audio.aria.loop_on":"Enable loop","audio.aria.loop_off":"Disable loop","audio.aria.progress":"Playback progress","audio.aria.volume":"Volume","markdown.load_failed":"Failed to load Markdown","markdown.copy_code":"Copy code","markdown.copied":"Copied","json.load_failed":"Failed to load JSON","json.items":"items","json.keys":"keys","csv.loading":"Loading CSV...","csv.load_failed":"Failed to load CSV","csv.parse_failed":"Failed to parse CSV","xml.load_failed":"Failed to load XML","subtitle.load_failed":"Failed to load subtitle","subtitle.parse_failed":"Failed to parse subtitle","subtitle.lines":"lines","subtitle.cues":"cues","subtitle.meta.title":"Title","subtitle.meta.artist":"Artist","subtitle.meta.album":"Album","subtitle.meta.author":"Author","subtitle.meta.by":"By","subtitle.meta.length":"Length","subtitle.meta.offset":"Offset","subtitle.meta.editor":"Editor","subtitle.meta.version":"Version","zip.load_failed":"Failed to load ZIP","zip.parse_failed":"Failed to parse ZIP","text.load_failed":"Failed to load text file"},$e={"zh-CN":Lt,"en-US":Pt},zt=/\{(\w+)\}/g;function $t(r,t){return t?r.replace(zt,(n,a)=>{const o=t[a];return o===void 0?`{${a}}`:String(o)}):r}function Xe(r){var t;const n=r.fallbackLocale??"zh-CN",a=$e[r.locale]??$e[n]??$e["zh-CN"],o=(t=r.messages)==null?void 0:t[r.locale],i=o?{...a,...o}:a,p=$e["zh-CN"];return(l,f)=>{const u=i[l]??p[l]??l;return $t(u,f)}}const Ze=s.createContext(null),vr=({locale:r="zh-CN",messages:t,children:n})=>{const a=s.useMemo(()=>{const o=Xe({locale:r,messages:t});return{locale:r,t:o}},[r,t]);return e.jsx(Ze.Provider,{value:a,children:n})};let Be=null;function Dt(){return Be||(Be=Xe({locale:"zh-CN"})),Be}function J(){const r=s.useContext(Ze);return(r==null?void 0:r.t)??Dt()}function Wt(){const r=s.useContext(Ze);return(r==null?void 0:r.locale)??"zh-CN"}const jr=s.createContext(null),It=({theme:r,children:t})=>e.jsx(jr.Provider,{value:r,children:t});function Nr(){return s.useContext(jr)??"dark"}const Ot=({className:r})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:r,children:e.jsx("text",{x:"12",y:"17.5",textAnchor:"middle",fontSize:"20",fontWeight:"bold",fill:"currentColor",stroke:"none",children:"1:1"})});function Ht(r){return[{items:[{type:"button",icon:e.jsx(_.ZoomOut,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.zoom_out"),action:r.onZoomOut,disabled:r.zoom<=.01},{type:"text",content:`${Math.round(r.zoom*100)}%`,minWidth:"3rem"},{type:"button",icon:e.jsx(_.ZoomIn,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.zoom_in"),action:r.onZoomIn,disabled:r.zoom>=10}]},{items:[{type:"button",icon:e.jsx(_.Scan,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.fit_to_window"),action:r.onFitToWidth},{type:"button",icon:e.jsx(Ot,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.original_size"),action:r.onOriginalSize}]},{items:[{type:"button",icon:e.jsx(_.RotateCcw,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.rotate_left"),action:r.onRotateLeft},{type:"button",icon:e.jsx(_.RotateCw,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.rotate_right"),action:r.onRotateRight}]},{items:[{type:"button",icon:e.jsx(_.RefreshCw,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.reset"),action:r.onReset}]}]}function At(r){return[{items:[{type:"button",icon:e.jsx(_.ZoomOut,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.zoom_out"),action:r.onZoomOut,disabled:r.zoom<=.01},{type:"text",content:`${Math.round(r.zoom*100)}%`,minWidth:"3rem"},{type:"button",icon:e.jsx(_.ZoomIn,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.zoom_in"),action:r.onZoomIn,disabled:r.zoom>=10}]},{items:[{type:"button",icon:e.jsx(_.RefreshCw,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.reset"),action:r.onReset}]}]}function Bt(r){return[{items:[{type:"button",icon:e.jsx(_.List,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.toc"),action:()=>{var t;return(t=r.epubRef.current)==null?void 0:t.toggleToc()}}]},{items:[{type:"button",icon:e.jsx(_.ChevronLeft,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.prev_page"),action:()=>{var t;return(t=r.epubRef.current)==null?void 0:t.prevPage()}},{type:"text",content:`${r.current} / ${r.total}`,minWidth:"4rem"},{type:"button",icon:e.jsx(_.ChevronRight,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.next_page"),action:()=>{var t;return(t=r.epubRef.current)==null?void 0:t.nextPage()}}]},{items:[{type:"button",icon:r.fullWidth?e.jsx(_.Minimize2,{className:"rfp-w-4 rfp-h-4"}):e.jsx(_.Maximize2,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.fullWidth?r.t("toolbar.normal_width"):r.t("toolbar.full_width"),action:()=>{var t;return(t=r.epubRef.current)==null?void 0:t.toggleFullWidth()}}]}]}function qt(r){return[{items:[{type:"button",icon:e.jsx(_.List,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.toc"),action:()=>{var t;return(t=r.mobiRef.current)==null?void 0:t.toggleToc()}}]},{items:[{type:"button",icon:e.jsx(_.ChevronLeft,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.prev_page"),action:()=>{var t;return(t=r.mobiRef.current)==null?void 0:t.prevPage()}},{type:"text",content:`${r.current} / ${r.total}`,minWidth:"4rem"},{type:"button",icon:e.jsx(_.ChevronRight,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.t("toolbar.next_page"),action:()=>{var t;return(t=r.mobiRef.current)==null?void 0:t.nextPage()}}]},{items:[{type:"button",icon:r.fullWidth?e.jsx(_.Minimize2,{className:"rfp-w-4 rfp-h-4"}):e.jsx(_.Maximize2,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.fullWidth?r.t("toolbar.normal_width"):r.t("toolbar.full_width"),action:()=>{var t;return(t=r.mobiRef.current)==null?void 0:t.toggleFullWidth()}}]}]}function Ut({stats:r}){return r?[{items:[{type:"text",content:`${r.files} files · ${r.dirs} dirs · ${yr(r.size)}`,minWidth:"10rem"}]}]:[]}function Gt(r){const t=[{items:[{type:"button",icon:e.jsx(_.WrapText,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.wordWrap?r.t("toolbar.wrap_off"):r.t("toolbar.wrap_on"),action:r.onToggleWrap}]}];return r.isHtml&&t.push({items:[{type:"button",icon:r.htmlPreview?e.jsx(_.Code,{className:"rfp-w-4 rfp-h-4"}):e.jsx(_.Eye,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.htmlPreview?r.t("toolbar.source"):r.t("toolbar.preview"),action:r.onToggleHtmlPreview}]}),t}function Vt(r){return[{items:[{type:"button",icon:r.viewMode==="preview"?e.jsx(_.Code,{className:"rfp-w-4 rfp-h-4"}):e.jsx(_.Eye,{className:"rfp-w-4 rfp-h-4"}),tooltip:r.viewMode==="preview"?r.t("toolbar.source"):r.t("toolbar.preview"),action:r.onToggleViewMode}]}]}const Xt={fetcher:(r,t)=>fetch(r,t)},Je=s.createContext(Xt),Zt=({requestInit:r,requestHandler:t,shouldFetchAsBlob:n,children:a})=>{const o=s.useMemo(()=>({fetcher:it({requestInit:r,requestHandler:t}),shouldFetchAsBlob:n}),[r,t,n]);return e.jsx(Je.Provider,{value:o,children:a})};function se(){return s.useContext(Je).fetcher}function Jt(r){const{fetcher:t,shouldFetchAsBlob:n}=s.useContext(Je),a=!!(r&&(n!=null&&n(r))),[o,i]=s.useState(()=>r?a?"":r.url:""),p=s.useRef(null);return s.useEffect(()=>{if(!r){i("");return}if(!a){i(r.url);return}let l=!1;return i(""),lt(r.url,t).then(f=>{if(l){URL.revokeObjectURL(f);return}p.current&&URL.revokeObjectURL(p.current),p.current=f,i(f)}).catch(f=>{l||(console.error("[file-preview] resolve blob url failed:",f),i(r.url))}),()=>{l=!0}},[r==null?void 0:r.id,r==null?void 0:r.url,a,t]),s.useEffect(()=>()=>{p.current&&(URL.revokeObjectURL(p.current),p.current=null)},[]),o}const Yt=s.lazy(()=>Promise.resolve().then(()=>Ns).then(r=>({default:r.ImageRenderer}))),Kt=s.lazy(()=>Promise.resolve().then(()=>Ss).then(r=>({default:r.PdfRenderer}))),Qt=s.lazy(()=>Promise.resolve().then(()=>Ms).then(r=>({default:r.DocxRenderer}))),es=s.lazy(()=>Promise.resolve().then(()=>Es).then(r=>({default:r.XlsxRenderer}))),rs=s.lazy(()=>Promise.resolve().then(()=>Ls).then(r=>({default:r.PptxRenderer}))),ts=s.lazy(()=>Promise.resolve().then(()=>Ds).then(r=>({default:r.MsgRenderer}))),ss=s.lazy(()=>Promise.resolve().then(()=>Os).then(r=>({default:r.EpubRenderer}))),ns=s.lazy(()=>Promise.resolve().then(()=>Bs).then(r=>({default:r.MobiRenderer}))),os=s.lazy(()=>Promise.resolve().then(()=>Gs).then(r=>({default:r.VideoRenderer}))),as=s.lazy(()=>Promise.resolve().then(()=>Ys).then(r=>({default:r.AudioRenderer}))),is=s.lazy(()=>Promise.resolve().then(()=>tn).then(r=>({default:r.MarkdownRenderer}))),ls=s.lazy(()=>Promise.resolve().then(()=>fn).then(r=>({default:r.JsonRenderer}))),fs=s.lazy(()=>Promise.resolve().then(()=>pn).then(r=>({default:r.CsvRenderer}))),cs=s.lazy(()=>Promise.resolve().then(()=>hn).then(r=>({default:r.XmlRenderer}))),ps=s.lazy(()=>Promise.resolve().then(()=>yn).then(r=>({default:r.SubtitleRenderer}))),ds=s.lazy(()=>Promise.resolve().then(()=>kn).then(r=>({default:r.ZipRenderer}))),us=s.lazy(()=>Promise.resolve().then(()=>_n).then(r=>({default:r.TextRenderer}))),pr=({fileName:r,fileType:t,onDownload:n})=>{const a=J();return e.jsxs("div",{className:"rfp-flex rfp-flex-col rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-p-8 rfp-gap-6",children:[e.jsx("div",{className:"rfp-w-32 rfp-h-32 rfp-rounded-full rfp-bg-surface-2 rfp-flex rfp-items-center rfp-justify-center",children:e.jsx(_.FileQuestion,{className:"rfp-w-16 rfp-h-16 rfp-text-fg-secondary"})}),e.jsxs("div",{className:"rfp-text-fg-primary rfp-text-center",children:[e.jsx("p",{className:"rfp-text-xl rfp-font-medium rfp-mb-2",children:r}),e.jsx("p",{className:"rfp-text-fg-secondary",children:a("common.unsupported_preview",{type:t})})]}),e.jsxs("button",{onClick:n,className:"rfp-flex rfp-items-center rfp-gap-2 rfp-px-6 rfp-py-3 rfp-bg-surface-2 hover:rfp-bg-surface-3 rfp-backdrop-blur-sm rfp-rounded-lg rfp-text-fg-primary rfp-font-medium rfp-transition-all",children:[e.jsx(_.Download,{className:"rfp-w-5 rfp-h-5"}),a("common.download")]})]})},ms=()=>{const r=J();return e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-text-fg-muted",children:e.jsxs("div",{className:"rfp-flex rfp-flex-col rfp-items-center rfp-gap-3",children:[e.jsx("div",{className:"rfp-w-8 rfp-h-8 rfp-rounded-full rfp-border-2 rfp-border-fg-muted rfp-border-t-transparent rfp-animate-spin"}),e.jsx("span",{className:"rfp-text-sm",children:r("common.loading")??"Loading..."})]})})},hs=3,We=r=>{const{requestInit:t,requestHandler:n,shouldFetchAsBlob:a}=r;return e.jsx(Zt,{requestInit:t,requestHandler:n,shouldFetchAsBlob:a,children:e.jsx(xs,{...r})})},xs=({files:r,currentIndex:t,onNavigate:n,customRenderers:a=[],mode:o="modal",onClose:i,zipNestingDepth:p=0,locale:l="zh-CN",messages:f,headless:u=!1,theme:d="dark",onCustomEvent:c,onDownload:m,requestInit:h,requestHandler:y,shouldFetchAsBlob:x})=>{const w=s.useMemo(()=>Xe({locale:l,messages:f}),[l,f]),[b,g]=s.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!0);s.useEffect(()=>{if(d!=="auto")return;const P=window.matchMedia("(prefers-color-scheme: dark)"),U=de=>g(de.matches);return P.addEventListener("change",U),()=>P.removeEventListener("change",U)},[d]);const v=d==="auto"?b?"dark":"light":d,[k,S]=s.useState(1),[M,T]=s.useState(0),[D,N]=s.useState(1),[,E]=s.useState(1),[F,H]=s.useState(0),[A,Z]=s.useState(0),[G,j]=s.useState(0),R=s.useRef(null),C=s.useRef(null),B=s.useRef(null),[I,q]=s.useState(0),[L,z]=s.useState(0),[$,Y]=s.useState(!1),V=s.useRef(null),[te,K]=s.useState(0),[be,Q]=s.useState(0),[me,X]=s.useState(!1),[ne,ce]=s.useState(null),[he,je]=s.useState(!0),[Ne,_e]=s.useState(!1),[ye,ge]=s.useState("preview"),[xe,ke]=s.useState(!0),pe=s.useRef(null),Re=2e3,Fe=s.useCallback(()=>{ke(!0),pe.current&&clearTimeout(pe.current),pe.current=window.setTimeout(()=>{ke(!1)},Re)},[]),Tr=s.useCallback(()=>{Fe()},[Fe]),we=s.useMemo(()=>br(r),[r]),W=we[t],ee=Jt(W),Ce=s.useMemo(()=>W?a.find(P=>P.test(W)):null,[W,a]),O=W?gr(W):"unsupported",Ye=s.useCallback((P,U)=>{W&&(c==null||c({name:P,payload:U,file:W}))},[W,c]),Ke=s.useMemo(()=>({emit:Ye,t:w,theme:v,locale:l}),[Ye,w,v,l]);s.useEffect(()=>{S(1),T(0),N(1),E(1),H(0),Z(0),ke(!0),pe.current&&clearTimeout(pe.current)},[t]),s.useEffect(()=>{if(O==="image"&&F>0&&A>0&&R.current){const P=R.current.clientWidth,U=R.current.clientHeight,de=P/F,ue=U/A,Te=Math.min(de,ue);S(Math.max(.01,Math.min(10,Te)))}},[O,F,A]),s.useEffect(()=>(we.length>1&&Fe(),()=>{pe.current&&clearTimeout(pe.current)}),[we.length,Fe]),s.useEffect(()=>{const P=U=>{U.key==="Escape"&&o==="modal"?i==null||i():U.key==="ArrowLeft"&&t>0?n==null||n(t-1):U.key==="ArrowRight"&&t<we.length-1&&(n==null||n(t+1))};if(o==="modal")return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P);{const U=C.current;return U?(U.addEventListener("keydown",P),()=>U.removeEventListener("keydown",P)):void 0}},[o,t,we.length,i,n]);const Qe=s.useCallback(()=>{S(P=>Math.min(P+.1,10))},[]),er=s.useCallback(()=>{S(P=>Math.max(P-.1,.01))},[]),Er=s.useCallback(()=>{T(P=>P+90)},[]),Fr=s.useCallback(()=>{T(P=>P-90)},[]),Lr=s.useCallback(()=>{if(R.current&&F>0&&A>0){const P=R.current.clientWidth,U=R.current.clientHeight,de=P/F,ue=U/A,Te=Math.min(de,ue);S(Math.max(.01,Math.min(10,Te)))}else S(1);T(0),j(P=>P+1)},[F,A]),Pr=s.useCallback(()=>{S(1),T(0),j(P=>P+1)},[]),zr=s.useCallback(P=>{S(P)},[]),rr=s.useCallback(()=>{S(1),T(0),j(P=>P+1)},[]),tr=se(),Oe=s.useCallback(async()=>{if(W){if(m){await m(W);return}try{await ft(W.url,W.name,tr)}catch(P){console.error("[file-preview] download failed:",P)}}},[W,m,tr]),$r=s.useCallback((P,U)=>{q(P),z(U)},[]),Dr=s.useCallback((P,U)=>{K(P),Q(U)},[]),Wr=s.useCallback(P=>{ce(P)},[]);if(!W)return null;const Ir=o==="modal"&&!!i,Le=(()=>{var P,U;if(Ce)return((P=Ce.getToolbarGroups)==null?void 0:P.call(Ce,W,Ke))??[];if(O==="image")return Ht({zoom:k,onZoomIn:Qe,onZoomOut:er,onFitToWidth:Lr,onOriginalSize:Pr,onRotateLeft:Fr,onRotateRight:Er,onReset:rr,t:w});if(O==="pdf")return At({zoom:k,onZoomIn:Qe,onZoomOut:er,onReset:rr,t:w});if(O==="epub")return Bt({epubRef:B,current:I,total:L,fullWidth:$,t:w});if(O==="mobi")return qt({mobiRef:V,current:te,total:be,fullWidth:me,t:w});if(O==="zip")return Ut({stats:ne});if(O==="text"){const de=((U=W.name.split(".").pop())==null?void 0:U.toLowerCase())||"";return Gt({wordWrap:he,onToggleWrap:()=>je(ue=>!ue),isHtml:de==="html"||de==="htm",htmlPreview:Ne,onToggleHtmlPreview:()=>_e(ue=>!ue),t:w})}return O==="markdown"?Vt({viewMode:ye,onToggleViewMode:()=>ge(de=>de==="preview"?"source":"preview"),t:w}):[]})(),sr=[{items:[{type:"button",icon:e.jsx(_.Download,{className:"rfp-w-4 rfp-h-4"}),tooltip:w("common.download"),action:Oe}]},...Ir?[{items:[{type:"button",icon:e.jsx(_.X,{className:"rfp-w-4 rfp-h-4"}),tooltip:w("common.close"),action:i}]}]:[]],Pe=(P,U)=>P.map((de,ue,Te)=>e.jsxs(s.Fragment,{children:[de.items.map((Se,nr)=>Se.type==="button"?e.jsx(bs,{icon:Se.icon,label:Se.tooltip,onClick:Se.action,disabled:Se.disabled},`${ue}-${nr}`):e.jsx("span",{className:"rfp-text-xs rfp-text-center rfp-font-medium rfp-tabular-nums rfp-text-fg-tertiary",style:{minWidth:Se.minWidth||"auto"},children:Se.content},`${ue}-${nr}`)),ue<Te.length-1&&e.jsx("div",{className:`rfp-w-px rfp-h-4 rfp-bg-divide ${U}`})]},ue));return e.jsx(vr,{locale:l,messages:f,children:e.jsx(It,{theme:v,children:e.jsxs("div",{ref:C,tabIndex:o==="embed"?0:-1,"data-theme":v,className:"rfp-relative rfp-w-full rfp-h-full rfp-flex rfp-flex-col rfp-overflow-hidden rfp-outline-none",children:[!u&&e.jsxs(re.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"rfp-flex-shrink-0 rfp-z-10 rfp-backdrop-blur-md rfp-border-b rfp-bg-surface-toolbar rfp-border-line",style:{paddingTop:"env(safe-area-inset-top, 0px)"},children:[e.jsxs("div",{className:"rfp-flex rfp-items-center rfp-justify-between rfp-px-3 md:rfp-px-5 rfp-py-1.5 md:rfp-py-2.5",children:[e.jsxs("div",{className:"rfp-flex rfp-items-center rfp-flex-1 rfp-min-w-0 rfp-mr-2 md:rfp-mr-3",children:[e.jsx("h2",{className:"rfp-font-medium rfp-text-xs md:rfp-text-sm rfp-truncate rfp-text-fg-primary",children:W.name}),e.jsxs("span",{className:"rfp-text-xs rfp-ml-2 rfp-flex-shrink-0 rfp-text-fg-muted",children:[t+1,"/",we.length]})]}),e.jsx("div",{className:"rfp-flex rfp-items-center rfp-gap-1 md:rfp-hidden rfp-flex-shrink-0",children:Pe(sr,"rfp-mx-0.5")}),e.jsxs("div",{className:"rfp-hidden md:rfp-flex rfp-items-center rfp-gap-1 rfp-flex-shrink-0",children:[Pe(Le,"rfp-mx-1"),Le.length>0&&e.jsx("div",{className:"rfp-w-px rfp-h-4 rfp-mx-1 rfp-bg-divide"}),Pe(sr,"rfp-mx-1")]})]}),Le.length>0&&e.jsx("div",{className:"rfp-flex rfp-items-center rfp-gap-1 rfp-px-3 rfp-pb-1.5 rfp-overflow-x-auto scrollbar-hide md:rfp-hidden",children:Pe(Le,"rfp-mx-0.5")})]}),e.jsx("div",{ref:R,className:"rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center rfp-overflow-auto",onMouseMove:Tr,children:Ce?Ce.render(W,Ke):e.jsxs(s.Suspense,{fallback:e.jsx(ms,{}),children:[O==="image"&&e.jsx(Yt,{url:ee,zoom:k,rotation:M,resetKey:G,fileSize:W.size,onZoomChange:zr,onNaturalWidthChange:H,onNaturalHeightChange:Z}),O==="pdf"&&e.jsx(Kt,{url:ee,zoom:k,currentPage:D,onPageChange:N,onTotalPagesChange:E,onPageWidthChange:H}),O==="docx"&&e.jsx(Qt,{url:ee}),O==="xlsx"&&e.jsx(es,{url:ee}),O==="pptx"&&e.jsx(rs,{url:ee}),O==="msg"&&e.jsx(ts,{url:ee}),O==="epub"&&e.jsx(ss,{ref:B,url:ee,onChapterChange:$r,onFullWidthChange:Y}),O==="mobi"&&e.jsx(ns,{ref:V,url:ee,onChapterChange:Dr,onFullWidthChange:X}),O==="video"&&e.jsx(os,{url:ee}),O==="audio"&&e.jsx(as,{url:ee,fileName:W.name}),O==="markdown"&&e.jsx(is,{url:ee,viewMode:ye}),O==="json"&&e.jsx(ls,{url:ee,fileName:W.name}),O==="csv"&&e.jsx(fs,{url:ee,fileName:W.name}),O==="xml"&&e.jsx(cs,{url:ee,fileName:W.name}),O==="subtitle"&&e.jsx(ps,{url:ee,fileName:W.name}),O==="zip"&&(p>=hs?e.jsx(pr,{fileName:W.name,fileType:W.type,onDownload:Oe}):e.jsx(ds,{url:ee,onStatsChange:Wr,nestingDepth:p})),O==="text"&&e.jsx(us,{url:ee,fileName:W.name,wordWrap:he,htmlPreview:Ne}),O==="unsupported"&&e.jsx(pr,{fileName:W.name,fileType:W.type,onDownload:Oe})]})}),!u&&we.length>1&&e.jsxs(e.Fragment,{children:[t>0&&e.jsx(re.motion.button,{initial:{opacity:0},animate:{opacity:xe?1:0,x:xe?0:-20},transition:{duration:.2},onClick:()=>n==null?void 0:n(t-1),onMouseEnter:()=>ke(!0),style:{pointerEvents:xe?"auto":"none"},className:"rfp-absolute rfp-z-20 rfp-left-2 md:rfp-left-4 rfp-top-1/2 -rfp-translate-y-1/2 rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-rounded-full rfp-backdrop-blur-xl rfp-border rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors rfp-shadow-2xl rfp-bg-surface-nav rfp-border-line hover:rfp-bg-surface-nav-hover rfp-text-fg-primary",children:e.jsx(_.ChevronLeft,{className:"rfp-w-5 rfp-h-5 md:rfp-w-6 md:rfp-h-6"})}),t<we.length-1&&e.jsx(re.motion.button,{initial:{opacity:0},animate:{opacity:xe?1:0,x:xe?0:20},transition:{duration:.2},onClick:()=>n==null?void 0:n(t+1),onMouseEnter:()=>ke(!0),style:{pointerEvents:xe?"auto":"none"},className:"rfp-absolute rfp-z-20 rfp-right-2 md:rfp-right-4 rfp-top-1/2 -rfp-translate-y-1/2 rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-rounded-full rfp-backdrop-blur-xl rfp-border rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors rfp-shadow-2xl rfp-bg-surface-nav rfp-border-line hover:rfp-bg-surface-nav-hover rfp-text-fg-primary",children:e.jsx(_.ChevronRight,{className:"rfp-w-5 rfp-h-5 md:rfp-w-6 md:rfp-h-6"})})]})]})})})},bs=({icon:r,label:t,onClick:n,disabled:a})=>e.jsxs("button",{onClick:n,disabled:a,className:`rfp-relative rfp-group rfp-p-2 md:rfp-p-1.5 rfp-rounded-md rfp-transition-all rfp-select-none ${a?"rfp-text-fg-disabled rfp-cursor-not-allowed":"rfp-text-fg-primary hover:rfp-bg-surface-2 active:rfp-bg-surface-3"}`,children:[r,e.jsxs("span",{className:"rfp-absolute rfp-left-1/2 -rfp-translate-x-1/2 rfp-top-full rfp-mt-1.5 rfp-px-2 rfp-py-1 rfp-text-xs rfp-rounded rfp-whitespace-nowrap rfp-pointer-events-none rfp-opacity-0 rfp-invisible group-hover:rfp-opacity-100 group-hover:rfp-visible rfp-transition-opacity rfp-duration-200 rfp-z-50 rfp-bg-fg-primary rfp-text-fg-inverse",children:[e.jsx("span",{className:"rfp-absolute rfp-left-1/2 -rfp-translate-x-1/2 -rfp-top-1 rfp-w-2 rfp-h-2 rfp-rotate-45 rfp-bg-fg-primary"}),e.jsx("span",{className:"rfp-relative",children:t})]})]}),gs=Object.freeze(Object.defineProperty({__proto__:null,FilePreviewContent:We},Symbol.toStringTag,{value:"Module"})),ys=({files:r,currentIndex:t,isOpen:n,onClose:a,onNavigate:o,customRenderers:i=[],locale:p,messages:l,headless:f,theme:u="dark",onCustomEvent:d,requestInit:c,requestHandler:m,shouldFetchAsBlob:h,onDownload:y})=>{const[x,w]=s.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!0);s.useEffect(()=>{if(u!=="auto")return;const v=window.matchMedia("(prefers-color-scheme: dark)"),k=S=>w(S.matches);return v.addEventListener("change",k),()=>v.removeEventListener("change",k)},[u]);const b=u==="auto"?x?"dark":"light":u;if(s.useEffect(()=>{if(n){const v=document.body.style.overflow,k=document.body.style.paddingRight,S=window.innerWidth-document.documentElement.clientWidth;return document.body.style.overflow="hidden",S>0&&(document.body.style.paddingRight=`${S}px`),()=>{document.body.style.overflow=v,document.body.style.paddingRight=k}}},[n]),!n)return null;const g=e.jsx("div",{className:"rfp-root","data-theme":b,children:e.jsx(re.AnimatePresence,{children:n&&e.jsx(re.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"rfp-fixed rfp-inset-0 rfp-z-[9999] rfp-flex rfp-items-center rfp-justify-center rfp-backdrop-blur-md rfp-overflow-hidden rfp-bg-surface-overlay",onClick:a,onWheel:v=>v.stopPropagation(),children:e.jsx("div",{className:"rfp-relative rfp-w-full rfp-h-full",onClick:v=>v.stopPropagation(),children:e.jsx(We,{mode:"modal",files:r,currentIndex:t,onClose:a,onNavigate:o,customRenderers:i,locale:p,messages:l,headless:f,theme:u,onCustomEvent:d,requestInit:c,requestHandler:m,shouldFetchAsBlob:h,onDownload:y})})})})});return mr.createPortal(g,document.body)},ws=({files:r,currentIndex:t=0,onNavigate:n,customRenderers:a=[],width:o="100%",height:i="100%",className:p,style:l,locale:f,messages:u,headless:d,theme:c="dark",onCustomEvent:m,requestInit:h,requestHandler:y,shouldFetchAsBlob:x,onDownload:w})=>{const[b,g]=s.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!0);s.useEffect(()=>{if(c!=="auto")return;const k=window.matchMedia("(prefers-color-scheme: dark)"),S=M=>g(M.matches);return k.addEventListener("change",S),()=>k.removeEventListener("change",S)},[c]);const v=c==="auto"?b?"dark":"light":c;return e.jsx("div",{className:`rfp-root ${p??""}`,style:{width:o,height:i,...l},"data-theme":v,children:e.jsx("div",{className:"rfp-relative rfp-w-full rfp-h-full rfp-overflow-hidden rfp-bg-surface-overlay",children:e.jsx(We,{mode:"embed",files:r,currentIndex:t,onNavigate:n,customRenderers:a,locale:f,messages:u,headless:d,theme:c,onCustomEvent:m,requestInit:h,requestHandler:y,shouldFetchAsBlob:x,onDownload:w})})})};function kr(r){if(typeof window>"u")return;const{workerSrc:t=`https://unpkg.com/pdfjs-dist@${ve.pdfjs.version}/build/pdf.worker.min.mjs`,cMapUrl:n=`https://unpkg.com/pdfjs-dist@${ve.pdfjs.version}/cmaps/`,cMapPacked:a=!0}=r||{};ve.pdfjs.GlobalWorkerOptions.workerSrc=t,ve.pdfjs.GlobalWorkerOptions.cMapUrl=n,ve.pdfjs.GlobalWorkerOptions.cMapPacked=a}kr();const vs=Qr.version,js=({url:r,zoom:t,rotation:n,resetKey:a,fileSize:o,onZoomChange:i,onNaturalWidthChange:p,onNaturalHeightChange:l})=>{const f=J(),[u,d]=s.useState(!1),[c,m]=s.useState(null),[h,y]=s.useState({x:0,y:0}),[x,w]=s.useState(!1),[b,g]=s.useState({x:0,y:0}),[v,k]=s.useState(1),[S,M]=s.useState({width:0,height:0}),T=s.useRef(null),D=s.useRef(null);s.useEffect(()=>{d(!1),m(null),y({x:0,y:0}),k(1)},[r]),s.useEffect(()=>{k(t)},[t]),s.useEffect(()=>{a!==void 0&&y({x:0,y:0})},[a]);const N=j=>{d(!0);const R=j.currentTarget;M({width:R.naturalWidth,height:R.naturalHeight}),p==null||p(R.naturalWidth),l==null||l(R.naturalHeight)},E=s.useCallback((j,R)=>{const C=D.current;if(!C||S.width===0)return j;const B=C.clientWidth,I=C.clientHeight,q=S.width*R,L=S.height*R,z=Math.min(80,B*.15,I*.15),$=(B+q)/2-z,Y=(I+L)/2-z;return{x:$>0?Math.max(-$,Math.min($,j.x)):0,y:Y>0?Math.max(-Y,Math.min(Y,j.y)):0}},[S]),F=()=>{m(f("image.load_failed")),d(!0)},H=()=>{y({x:0,y:0}),k(1),i==null||i(1)};s.useEffect(()=>{const j=D.current;if(!j)return;const R=C=>{C.preventDefault(),C.stopPropagation();const B=j.getBoundingClientRect(),I=C.clientX-B.left-B.width/2,q=C.clientY-B.top-B.height/2,L=C.deltaY>0?-.05:.05;k(z=>{const $=Math.max(.01,Math.min(10,z+L)),Y=$/z;return y(V=>E({x:I-Y*(I-V.x),y:q-Y*(q-V.y)},$)),i==null||i($),$})};return j.addEventListener("wheel",R,{passive:!1}),()=>j.removeEventListener("wheel",R)},[i,E]);const A=s.useCallback(j=>{j.button===0&&(w(!0),g({x:j.clientX-h.x,y:j.clientY-h.y}))},[h]),Z=s.useCallback(j=>{x&&y(E({x:j.clientX-b.x,y:j.clientY-b.y},v))},[x,b,v,E]),G=s.useCallback(()=>{w(!1)},[]);return e.jsxs("div",{ref:D,className:"rfp-relative rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-overflow-hidden",onMouseDown:A,onMouseMove:Z,onMouseUp:G,onMouseLeave:G,style:{cursor:x?"grabbing":"grab"},children:[!u&&!c&&e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),c&&e.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:c})}),e.jsx(re.motion.img,{ref:T,src:r,alt:"Preview",className:`rfp-max-w-none rfp-select-none ${u?"":"rfp-hidden"}`,style:{transform:`translate(${h.x}px, ${h.y}px) scale(${v}) rotate(${n}deg)`,transformOrigin:"center",transition:x?"none":"transform 0.3s ease-out"},onLoad:N,onError:F,onDoubleClick:H,initial:{opacity:0},animate:{opacity:u?1:0},transition:{duration:.3},draggable:!1}),u&&!c&&S.width>0&&e.jsxs("div",{className:"rfp-absolute rfp-bottom-2 rfp-right-3 rfp-text-[10px] rfp-text-fg-disabled hover:rfp-text-fg-secondary rfp-transition-colors rfp-pointer-events-auto rfp-select-none rfp-cursor-default",children:[S.width," × ",S.height,o!=null&&` · ${o<1024?`${o} B`:o<1024*1024?`${(o/1024).toFixed(1)} KB`:`${(o/(1024*1024)).toFixed(1)} MB`}`]})]})},Ns=Object.freeze(Object.defineProperty({__proto__:null,ImageRenderer:js},Symbol.toStringTag,{value:"Module"})),ks=({url:r,zoom:t,currentPage:n,onPageChange:a,onTotalPagesChange:o,onPageWidthChange:i})=>{const p=J(),[l,f]=s.useState(0),[u,d]=s.useState(null),c=s.useRef(null),m=s.useRef(new Map);s.useEffect(()=>{d(null)},[r]);const h=({numPages:b})=>{f(b),o(b),a(1)},y=b=>{console.error("PDF 加载错误:",b),d(p("pdf.load_failed"))},x=s.useCallback(()=>{if(!c.current)return;const b=c.current,g=b.scrollTop,v=b.clientHeight,k=g+v/2;let S=1,M=1/0;m.current.forEach((T,D)=>{const N=T.getBoundingClientRect(),E=b.getBoundingClientRect(),F=N.top-E.top+N.height/2+g,H=Math.abs(F-k);H<M&&(M=H,S=D)}),S!==n&&a(S)},[n,a]);s.useEffect(()=>{const b=c.current;if(b)return b.addEventListener("scroll",x),()=>b.removeEventListener("scroll",x)},[x]);const w=s.useCallback((b,g)=>{g?m.current.set(b,g):m.current.delete(b)},[]);return e.jsxs("div",{ref:c,className:"rfp-flex rfp-flex-col rfp-items-center rfp-w-full rfp-h-full rfp-overflow-auto rfp-py-4 md:rfp-py-8 rfp-px-2 md:rfp-px-4",children:[u&&e.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:u})}),!u&&e.jsx(ve.Document,{file:r,onLoadSuccess:h,onLoadError:y,loading:e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-min-h-screen",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),children:e.jsx("div",{className:"rfp-flex rfp-flex-col rfp-gap-4",children:Array.from(new Array(l),(b,g)=>{const v=g+1;return e.jsxs("div",{ref:k=>w(v,k),className:"rfp-relative",children:[e.jsx(ve.Page,{pageNumber:v,scale:t,loading:e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-p-8 rfp-bg-surface-1 rfp-rounded-lg rfp-min-h-[600px]",children:e.jsx("div",{className:"rfp-w-8 rfp-h-8 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),renderTextLayer:!1,renderAnnotationLayer:!1,className:"rfp-shadow-2xl",onRenderSuccess:k=>{v===1&&i&&i(k.originalWidth||k.width/t)}}),e.jsx("div",{className:"rfp-absolute rfp-top-2 rfp-right-2 rfp-bg-surface-nav-hover rfp-backdrop-blur-sm rfp-text-fg-primary rfp-text-xs rfp-px-3 rfp-py-1 rfp-rounded-full",children:v})]},`page_${v}`)})})}),l>0&&e.jsxs("div",{className:"rfp-sticky rfp-bottom-2 md:rfp-bottom-4 rfp-mt-4 md:rfp-mt-8 rfp-bg-surface-nav-hover rfp-backdrop-blur-xl rfp-text-fg-primary rfp-px-4 rfp-py-2 md:rfp-px-6 md:rfp-py-3 rfp-rounded-full rfp-text-xs md:rfp-text-sm rfp-font-medium rfp-shadow-2xl rfp-border rfp-border-line-weak",children:["第 ",n," 页 / 共 ",l," 页"]})]})},Ss=Object.freeze(Object.defineProperty({__proto__:null,PdfRenderer:ks},Symbol.toStringTag,{value:"Module"})),Sr=1123,_r=60,dr=50,_s=Sr-_r*2,Rs=24,ur={fontFamily:"system-ui, -apple-system, sans-serif",lineHeight:"1.8",color:"#333"},Cs=({url:r})=>{const t=J(),n=se(),[a,o]=s.useState(""),[i,p]=s.useState(!0),[l,f]=s.useState(null),[u,d]=s.useState([]),c=s.useRef(null);s.useEffect(()=>{(async()=>{p(!0),f(null),o("");try{const y=await n(r);if(!y.ok)throw new Error("文件加载失败");const x=await y.arrayBuffer(),w=await Or.convertToHtml({arrayBuffer:x});o(w.value)}catch(y){console.error("Docx 解析错误:",y),f(t("docx.parse_failed"))}finally{p(!1)}})()},[r,n,t]);const m=s.useCallback(()=>{const h=c.current;if(!h||!a)return;const y=Array.from(h.children);if(y.length===0){d([a]);return}const x=[[]];let w=0;for(const b of y){const g=b.offsetHeight;w>0&&w+g>_s&&(x.push([]),w=0),x[x.length-1].push(b.outerHTML),w+=g}x.length===0&&x.push([]),d(x.map(b=>b.join("")))},[a]);return s.useEffect(()=>{!a||!c.current||requestAnimationFrame(()=>{m()})},[a,m]),i?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}):l?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:l})})}):e.jsxs("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto",style:{background:"rgba(0, 0, 0, 0.15)"},children:[e.jsx("div",{ref:c,dangerouslySetInnerHTML:{__html:a},style:{...ur,position:"absolute",visibility:"hidden",width:`${794-dr*2}px`,pointerEvents:"none"}}),e.jsx("div",{className:"rfp-py-6 md:rfp-py-10 rfp-flex rfp-flex-col rfp-items-center",style:{gap:`${Rs}px`},children:(u.length>0?u:[""]).map((h,y)=>e.jsx("div",{style:{width:"100%",maxWidth:"794px",minHeight:`${Sr}px`,background:"white",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.15)",flexShrink:0,padding:`${_r}px ${dr}px`},children:e.jsx("div",{dangerouslySetInnerHTML:{__html:h},style:ur})},y))})]})},Ms=Object.freeze(Object.defineProperty({__proto__:null,DocxRenderer:Cs},Symbol.toStringTag,{value:"Module"})),Ts=({url:r})=>{const t=J(),n=se(),[a,o]=s.useState(!0),[i,p]=s.useState(null),l=s.useRef(null),f=s.useRef(null),u=s.useRef(null),d=s.useRef(null),c=s.useRef(null),m=s.useRef({width:0,height:0}),h=s.useCallback(()=>{if(!l.current)return{width:800,height:600};const x=l.current.clientWidth,w=l.current.clientHeight,b=x>100?x:800,g=w>100?w:600;return{width:b,height:g}},[]),y=s.useCallback(()=>{if(!l.current||!u.current)return;l.current.innerHTML="",f.current=null;const{width:x,height:w}=h(),b=x<640,g=new hr(l.current,{mode:"read",showToolbar:!1,showContextmenu:!1,showGrid:!0,row:{len:100,height:25},col:{len:26,width:b?80:100,indexWidth:b?40:60,minWidth:b?40:60},view:{height:()=>w,width:()=>x}});g.loadData(u.current),f.current=g},[h]);return s.useEffect(()=>{if(!l.current)return;let x=!0;const w=()=>{if(x){x=!1,m.current=h();return}const b=h(),g=m.current,v=Math.abs(g.width-b.width),k=Math.abs(g.height-b.height);v<10&&k<10||(m.current=b,c.current&&clearTimeout(c.current),c.current=window.setTimeout(()=>{u.current&&y()},500))};return d.current=new ResizeObserver(()=>{w()}),d.current.observe(l.current),()=>{d.current&&d.current.disconnect(),c.current&&clearTimeout(c.current)}},[h,y]),s.useEffect(()=>{let x=!0;const w=async()=>{if(l.current){o(!0),p(null);try{const g=await n(r,{mode:"cors",credentials:"omit",redirect:"follow"});if(!g.ok)throw g.status===404?new Error(t("xlsx.not_found")):g.status===403?new Error("无权限访问此文件"):new Error(`文件加载失败 (${g.status})`);const v=await g.arrayBuffer();if(v.byteLength===0)throw new Error("文件为空");const k=new Hr.Workbook;await k.xlsx.load(v);const S=Et(k);if(!x)return;u.current=S,y(),o(!1)}catch(g){if(x){console.error("Excel 解析错误:",g);let v=t("xlsx.parse_failed");g instanceof Error&&(v=g.message),p(v),o(!1)}}}},b=setTimeout(()=>{requestAnimationFrame(()=>{w()})},100);return()=>{x=!1,clearTimeout(b),u.current=null,l.current&&(l.current.innerHTML=""),f.current=null}},[r,y]),e.jsxs("div",{className:"rfp-relative rfp-flex rfp-flex-col rfp-items-center rfp-w-full rfp-h-full",children:[a&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-toolbar rfp-backdrop-blur-sm rfp-z-10",children:e.jsxs("div",{className:"rfp-text-center",children:[e.jsx("div",{className:"rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-mx-auto rfp-mb-3 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"}),e.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-fg-secondary rfp-font-medium",children:t("xlsx.loading")})]})}),i&&!a&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-toolbar rfp-backdrop-blur-sm rfp-z-10",children:e.jsxs("div",{className:"rfp-text-center rfp-max-w-sm md:rfp-max-w-md rfp-px-4",children:[e.jsx("div",{className:"rfp-w-24 rfp-h-24 md:rfp-w-32 md:rfp-h-32 rfp-mx-auto rfp-mb-4 md:rfp-mb-6 rfp-rounded-2xl md:rfp-rounded-3xl rfp-bg-gradient-to-br rfp-from-green-500 rfp-via-emerald-500 rfp-to-teal-500 rfp-flex rfp-items-center rfp-justify-center rfp-shadow-2xl",children:e.jsx(_.FileSpreadsheet,{className:"rfp-w-12 rfp-h-12 md:rfp-w-16 md:rfp-h-16 rfp-text-fg-primary"})}),e.jsx("p",{className:"rfp-text-lg md:rfp-text-xl rfp-text-fg-primary rfp-mb-2 md:rfp-mb-3 rfp-font-medium",children:t("xlsx.load_failed")}),e.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-fg-tertiary rfp-mb-4 md:rfp-mb-6",children:i}),e.jsxs("a",{href:r,download:!0,className:"rfp-inline-flex rfp-items-center rfp-gap-2 rfp-px-4 rfp-py-2 md:rfp-px-6 md:rfp-py-3 rfp-bg-gradient-to-r rfp-from-purple-500 rfp-to-pink-500 rfp-text-fg-primary rfp-text-sm md:rfp-text-base rfp-rounded-lg md:rfp-rounded-xl hover:rfp-scale-105 rfp-transition-all rfp-shadow-lg",children:[e.jsx("svg",{className:"rfp-w-4 rfp-h-4 md:rfp-w-5 md:rfp-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),t("common.download")]}),e.jsx("p",{className:"rfp-text-xs rfp-text-fg-muted rfp-mt-3 md:rfp-mt-4",children:"提示:可以使用 Microsoft Excel 或 WPS 打开"})]})}),!i&&e.jsx("div",{ref:l,className:"xlsx-spreadsheet-container rfp-w-full rfp-h-full",style:{opacity:a?0:1}})]})},Es=Object.freeze(Object.defineProperty({__proto__:null,XlsxRenderer:Ts},Symbol.toStringTag,{value:"Module"})),Fs=({url:r,tiled:t=!0})=>{const n=J(),a=se(),[o,i]=s.useState(!0),[p,l]=s.useState(null),[f,u]=s.useState(0),d=s.useRef(null),c=s.useRef(null),m=s.useRef(null),h=s.useRef(null),y=s.useRef(null),x=s.useRef({width:0,height:0}),w=s.useCallback(()=>{var M;if(!d.current)return{width:960,height:540};const g=d.current.clientWidth,v=((M=d.current.parentElement)==null?void 0:M.clientWidth)||0,k=g>100?g:v>100?v:300,S=Math.floor(k*9/16);return{width:k,height:S}},[]),b=s.useCallback(async()=>{if(!(!d.current||!h.current||f===0))try{if(c.current)try{c.current.destroy()}catch{}d.current.innerHTML="";const g=w(),v=He.init(d.current,{width:g.width,height:t?g.height*f:g.height,mode:t?"list":"slide"});c.current=v,await v.preview(h.current)}catch{}},[w,t,f]);return s.useEffect(()=>{if(!d.current)return;let g=!0;const v=()=>{if(g){g=!1,x.current=w();return}const k=w(),S=x.current,M=Math.abs(S.width-k.width),T=Math.abs(S.height-k.height);M<10&&T<10||(x.current=k,y.current&&clearTimeout(y.current),y.current=window.setTimeout(()=>{c.current&&h.current&&b()},800))};return m.current=new ResizeObserver(()=>{v()}),m.current.observe(d.current),()=>{m.current&&m.current.disconnect(),y.current&&clearTimeout(y.current)}},[w,b]),s.useEffect(()=>{let g=!0,v=null;const k=async()=>{if(d.current){i(!0),l(null),v=setTimeout(()=>{g&&(l(n("pptx.timeout")),i(!1))},3e4);try{const M=await a(r,{mode:"cors",credentials:"omit",redirect:"follow"});if(!M.ok)throw M.status===404?new Error(n("pptx.not_found")):M.status===403?new Error("无权限访问此文件"):M.status>=500?new Error("服务器错误,请稍后重试"):new Error(`文件加载失败 (${M.status})`);const T=await M.arrayBuffer();if(T.byteLength===0)throw new Error("文件为空");if(h.current=T,!g)return;const D=document.createElement("div");D.style.cssText="position:absolute;left:-9999px;top:-9999px;visibility:hidden",document.body.appendChild(D);try{const N=He.init(D,{width:100,height:100,mode:"slide"});try{await N.preview(T)}catch{throw new Error(n("pptx.invalid_format"))}const E=N.slideCount;if(!E||E===0)throw new Error(n("pptx.no_pages"));if(N.destroy(),!g)return;u(E),d.current&&(d.current.innerHTML="");const F=w(),H=He.init(d.current,{width:F.width,height:t?F.height*E:F.height,mode:t?"list":"slide"});c.current=H,await H.preview(T),v&&(clearTimeout(v),v=null),g&&i(!1)}finally{document.body.contains(D)&&document.body.removeChild(D)}}catch(M){if(v&&(clearTimeout(v),v=null),g){let T=n("pptx.parse_failed");M instanceof Error?T=M.message:typeof M=="string"&&(T=M),l(T),i(!1)}}}},S=setTimeout(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{k()})})},150);return()=>{if(g=!1,clearTimeout(S),v&&clearTimeout(v),h.current=null,u(0),c.current)try{c.current.destroy()}catch{}c.current=null}},[r,w,t]),e.jsxs("div",{className:"rfp-relative rfp-flex rfp-flex-col rfp-items-center rfp-w-full rfp-h-full",children:[o&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-toolbar rfp-backdrop-blur-sm rfp-z-10",children:e.jsxs("div",{className:"rfp-text-center",children:[e.jsx("div",{className:"rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-mx-auto rfp-mb-3 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"}),e.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-fg-secondary rfp-font-medium",children:n("pptx.loading")})]})}),p&&!o&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-toolbar rfp-backdrop-blur-sm rfp-z-10",children:e.jsxs("div",{className:"rfp-text-center rfp-max-w-sm md:rfp-max-w-md rfp-px-4",children:[e.jsx("div",{className:"rfp-w-24 rfp-h-24 md:rfp-w-32 md:rfp-h-32 rfp-mx-auto rfp-mb-4 md:rfp-mb-6 rfp-rounded-2xl md:rfp-rounded-3xl rfp-bg-gradient-to-br rfp-from-orange-500 rfp-via-red-500 rfp-to-pink-500 rfp-flex rfp-items-center rfp-justify-center rfp-shadow-2xl",children:e.jsx(_.Presentation,{className:"rfp-w-12 rfp-h-12 md:rfp-w-16 md:rfp-h-16 rfp-text-fg-primary"})}),e.jsx("p",{className:"rfp-text-lg md:rfp-text-xl rfp-text-fg-primary rfp-mb-2 md:rfp-mb-3 rfp-font-medium",children:n("pptx.load_failed")}),e.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-fg-tertiary rfp-mb-4 md:rfp-mb-6",children:p}),e.jsxs("a",{href:r,download:!0,className:"rfp-inline-flex rfp-items-center rfp-gap-2 rfp-px-4 rfp-py-2 md:rfp-px-6 md:rfp-py-3 rfp-bg-gradient-to-r rfp-from-purple-500 rfp-to-pink-500 rfp-text-fg-primary rfp-text-sm md:rfp-text-base rfp-rounded-lg md:rfp-rounded-xl hover:rfp-scale-105 rfp-transition-all rfp-shadow-lg",children:[e.jsx("svg",{className:"rfp-w-4 rfp-h-4 md:rfp-w-5 md:rfp-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),n("common.download")]}),e.jsx("p",{className:"rfp-text-xs rfp-text-fg-muted rfp-mt-3 md:rfp-mt-4",children:"提示:可以使用 Microsoft PowerPoint 或 WPS 打开"})]})}),!p&&e.jsx("div",{ref:d,className:"pptx-wrapper rfp-w-full rfp-max-w-full md:rfp-max-w-6xl",style:{opacity:o?0:1}})]})},Ls=Object.freeze(Object.defineProperty({__proto__:null,PptxRenderer:Fs},Symbol.toStringTag,{value:"Module"}));function qe(r,t){return r?r.filter(n=>n.recipType===t).map(n=>{const a=n.name||"",o=n.smtpAddress||n.email||"";return a&&o&&a!==o?`${a} <${o}>`:a||o}).filter(Boolean).join("; "):""}function De(r){if(!r)return"";try{const t=new Date(r);return isNaN(t.getTime())?r:t.toLocaleString()}catch{return r}}function Ps(r,t){if(r.bodyHtml)return r.bodyHtml;if(r.html)try{return new TextDecoder("utf-8").decode(r.html)}catch{}return r.body?`<pre style="white-space: pre-wrap; word-wrap: break-word; font-family: system-ui, sans-serif;">${r.body.replace(/&/g,"&").replace(/\x3c/g,"<").replace(/>/g,">")}</pre>`:`<p style="color: #999;">${t}</p>`}function zs(r){return r?{"IPM.Note":"Email","IPM.Note.SMIME":"Encrypted Email","IPM.Note.SMIME.MultipartSigned":"Signed Email","IPM.Appointment":"Appointment","IPM.Schedule.Meeting.Request":"Meeting Request","IPM.Schedule.Meeting.Canceled":"Meeting Cancellation","IPM.Contact":"Contact","IPM.Task":"Task","IPM.StickyNote":"Sticky Note"}[r]||r:""}const oe={flexShrink:0,color:"#6b7280",fontWeight:500,marginRight:"8px",whiteSpace:"nowrap"},ae={display:"flex",alignItems:"flex-start",gap:"8px",padding:"6px 0"},ie={flexShrink:0,display:"flex",alignItems:"center",height:"1.4em"},le={flexShrink:0,color:"#9ca3af"},fe={color:"#111827",wordBreak:"break-word",flex:1},$s=({url:r})=>{const t=J(),n=se(),[a,o]=s.useState(!0),[i,p]=s.useState(null),[l,f]=s.useState(null);if(s.useEffect(()=>{(async()=>{o(!0),p(null),f(null);try{const G=await n(r);if(!G.ok)throw new Error("文件加载失败");const j=await G.arrayBuffer(),C=new Ar(j).getFileData();f(C)}catch(G){console.error("MSG 解析错误:",G),p(t("msg.parse_failed"))}finally{o(!1)}})()},[r]),a)return e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})});if(i||!l)return e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:i||t("msg.parse_failed_short")})})});const u=qe(l.recipients,"to"),d=qe(l.recipients,"cc"),c=qe(l.recipients,"bcc"),m=l.senderName||"",h=l.senderSmtpAddress||l.senderEmail||"",y=m&&h&&m!==h?`${m} <${h}>`:m||h,x=De(l.clientSubmitTime),w=De(l.messageDeliveryTime),b=De(l.creationTime),g=De(l.lastModificationTime),v=l.subject||"(无主题)",k=(l.attachments||[]).filter(Z=>!Z.attachmentHidden),S=Ps(l,t("msg.empty_body")),M=zs(l.messageClass),T=l.messageId||"",D=l,N=typeof D.importance=="number"?D.importance:void 0,E=N===2?"High":N===0?"Low":"",F=typeof D.sensitivity=="number"?D.sensitivity:void 0,A=F!==void 0&&F!==0&&{0:"Normal",1:"Personal",2:"Private",3:"Confidential"}[F]||"";return e.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto",style:{background:"white"},children:e.jsxs("div",{style:{width:"100%",background:"white",minHeight:"100%"},children:[e.jsxs("div",{style:{borderBottom:"1px solid #e5e7eb",padding:"clamp(12px, 3vw, 24px) clamp(16px, 3vw, 28px)",background:"#f9fafb"},children:[e.jsx("h2",{style:{margin:"0 0 16px 0",fontSize:"clamp(16px, 2.5vw, 20px)",fontWeight:600,color:"#111827",lineHeight:1.4},children:v}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",fontSize:"clamp(12px, 1.8vw, 14px)",color:"#4b5563"},children:[y&&e.jsxs("div",{style:ae,children:[e.jsx("span",{style:ie,children:e.jsx(_.User,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"From"}),e.jsx("span",{style:fe,children:y})]})]}),u&&e.jsxs("div",{style:ae,children:[e.jsx("span",{style:ie,children:e.jsx(_.Users,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"To"}),e.jsx("span",{style:fe,children:u})]})]}),d&&e.jsxs("div",{style:ae,children:[e.jsx("span",{style:ie,children:e.jsx(_.Users,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"Cc"}),e.jsx("span",{style:fe,children:d})]})]}),c&&e.jsxs("div",{style:ae,children:[e.jsx("span",{style:ie,children:e.jsx(_.Users,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"Bcc"}),e.jsx("span",{style:fe,children:c})]})]}),x&&e.jsxs("div",{style:ae,children:[e.jsx("span",{style:ie,children:e.jsx(_.Calendar,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"Sent"}),e.jsx("span",{style:fe,children:x})]})]}),w&&w!==x&&e.jsxs("div",{style:ae,children:[e.jsx("span",{style:ie,children:e.jsx(_.Clock,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"Received"}),e.jsx("span",{style:fe,children:w})]})]}),!x&&!w&&b&&e.jsxs("div",{style:ae,children:[e.jsx("span",{style:ie,children:e.jsx(_.Calendar,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"Date"}),e.jsx("span",{style:fe,children:b})]})]}),E&&e.jsxs("div",{style:ae,children:[e.jsx("span",{style:ie,children:e.jsx(_.Tag,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"Importance"}),e.jsx("span",{style:{...fe,color:N===2?"#dc2626":"#2563eb",fontWeight:500},children:E})]})]}),A&&e.jsxs("div",{style:ae,children:[e.jsx("span",{style:ie,children:e.jsx(_.Tag,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"Sensitivity"}),e.jsx("span",{style:fe,children:A})]})]}),M&&M!=="Email"&&e.jsxs("div",{style:ae,children:[e.jsx("span",{style:ie,children:e.jsx(_.Mail,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"Type"}),e.jsx("span",{style:fe,children:M})]})]}),k.length>0&&e.jsxs("div",{style:{...ae,borderTop:"1px solid #e5e7eb",marginTop:"4px",paddingTop:"10px"},children:[e.jsx("span",{style:ie,children:e.jsx(_.Paperclip,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"Attachments"}),e.jsx("div",{style:{...fe,display:"flex",flexWrap:"wrap",gap:"6px"},children:k.map((Z,G)=>{const j=Z.fileName||Z.name||"未知文件",R=Z.contentLength,C=R?R>1048576?`${(R/1048576).toFixed(1)} MB`:R>1024?`${(R/1024).toFixed(0)} KB`:`${R} B`:"";return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",background:"#f3f4f6",borderRadius:"4px",fontSize:"13px",color:"#374151",border:"1px solid #e5e7eb"},children:[j,C&&e.jsxs("span",{style:{color:"#9ca3af",fontSize:"12px"},children:["(",C,")"]})]},G)})})]})]}),T&&e.jsxs("div",{style:{...ae,borderTop:k.length>0?"none":"1px solid #e5e7eb",marginTop:"4px",paddingTop:"10px"},children:[e.jsx("span",{style:ie,children:e.jsx(_.Hash,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"Message-ID"}),e.jsx("span",{style:{...fe,fontSize:"12px",color:"#9ca3af",fontFamily:"monospace"},children:T})]})]}),g&&g!==x&&g!==w&&e.jsxs("div",{style:ae,children:[e.jsx("span",{style:ie,children:e.jsx(_.Clock,{size:16,style:le})}),e.jsxs("div",{style:{display:"flex",flex:1},children:[e.jsx("span",{style:oe,children:"Modified"}),e.jsx("span",{style:{...fe,fontSize:"12px",color:"#9ca3af"},children:g})]})]})]})]}),e.jsx("div",{style:{padding:"clamp(12px, 3vw, 24px) clamp(16px, 3vw, 28px)",fontFamily:"system-ui, -apple-system, sans-serif",lineHeight:"1.6",color:"#333",overflowX:"auto"},dangerouslySetInnerHTML:{__html:S}})]})})},Ds=Object.freeze(Object.defineProperty({__proto__:null,MsgRenderer:$s},Symbol.toStringTag,{value:"Module"}));if(typeof document<"u"&&!document.getElementById("rfp-epub-styles")){const r=document.createElement("style");r.id="rfp-epub-styles",r.textContent=`
|
|
32
19
|
.epub-container { overflow-y: auto !important; scrollbar-width: thin; }
|
|
33
20
|
.epub-container::-webkit-scrollbar { width: 8px; }
|
|
34
21
|
.epub-container::-webkit-scrollbar-track { background: transparent; }
|
|
35
22
|
.epub-container::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }
|
|
36
23
|
.epub-container::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }
|
|
37
24
|
.epub-view > iframe { background: white; }
|
|
38
|
-
`,document.head.appendChild(r)}const
|
|
25
|
+
`,document.head.appendChild(r)}const Ws=794,Is=s.forwardRef(({url:r,onChapterChange:t,onFullWidthChange:n},a)=>{const o=J(),i=se(),p=s.useRef(null),l=s.useRef(null),f=s.useRef(null),u=s.useRef(t),d=s.useRef(n);u.current=t,d.current=n;const c=s.useRef(0),m=s.useRef(null),h=s.useRef(!1),[y,x]=s.useState(!0),[w,b]=s.useState(null),[g,v]=s.useState(!1),[k,S]=s.useState([]),[M,T]=s.useState(!1),[D,N]=s.useState(""),E=s.useRef([]);E.current=k,h.current=g;const F=s.useCallback(()=>{var L;(L=f.current)==null||L.prev()},[]),H=s.useCallback(()=>{var L;(L=f.current)==null||L.next()},[]),A=s.useRef(null),Z=s.useRef(0),G=s.useRef(L=>{var V,te;const z=A.current;if(!z)return;const $=z;if($.scrollTop+$.clientHeight>=$.scrollHeight-200)try{const K=(V=f.current)==null?void 0:V.manager;(te=K==null?void 0:K.check)==null||te.call(K,500,500)}catch{}}),j=s.useCallback(()=>{A.current&&(A.current.removeEventListener("scroll",G.current),A.current=null),cancelAnimationFrame(Z.current);const L=()=>{var $;const z=(($=p.current)==null?void 0:$.querySelector(".epub-container"))??null;if(!z){Z.current=requestAnimationFrame(L);return}A.current=z,z.addEventListener("scroll",G.current,{passive:!0})};Z.current=requestAnimationFrame(L)},[]),R=s.useCallback(()=>{var z;const L=!h.current;v(L),(z=d.current)==null||z.call(d,L),setTimeout(()=>{const $=p.current,Y=f.current;!$||!Y||(Y.resize($.offsetWidth,$.offsetHeight),m.current&&Y.display(m.current),j())},350)},[j]),C=s.useCallback(()=>{T(L=>!L)},[]),B=s.useCallback(L=>{var z;N(L),(z=f.current)==null||z.display(L),T(!1)},[]);s.useImperativeHandle(a,()=>({prevPage:F,nextPage:H,toggleFullWidth:R,toggleToc:C}),[F,H,R,C]),s.useEffect(()=>{const L=p.current;if(!L)return;x(!0),b(null),S([]),T(!1),L.innerHTML="",m.current=null,c.current=0;let z=!1;const $=window.setTimeout(()=>{z||Y()},0),Y=async()=>{var V;try{let te=r;r.startsWith("blob:")&&(te=await(await i(r)).arrayBuffer());const K=Br(te);l.current=K;const be=K.renderTo(L,{manager:"continuous",flow:"scrolled",width:"100%",height:"100%"});f.current=be,be.themes.register("default",{body:{background:"#ffffff !important",color:"#1a1a1a !important","font-family":'"Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif !important',"font-size":"16px !important","line-height":"2 !important",padding:"40px 60px !important","max-width":"100% !important","box-sizing":"border-box !important","word-break":"break-word !important","overflow-wrap":"break-word !important"},p:{"text-indent":"2em !important",margin:"0.8em 0 !important"},h1:{"text-align":"center !important",margin:"1.5em 0 1em !important"},h2:{margin:"1.2em 0 0.8em !important"},h3:{margin:"1em 0 0.6em !important"},img:{"max-width":"100% !important",height:"auto !important"},a:{color:"#2563eb !important","text-decoration":"none !important"}}),be.themes.select("default"),await K.ready,K.locations.generate(1024).then(()=>{var ne,ce,he;if(z)return;c.current=K.locations.length();const me=(ne=f.current)==null?void 0:ne.currentLocation(),X=((ce=me==null?void 0:me.start)==null?void 0:ce.location)??0;(he=u.current)==null||he.call(u,X+1,c.current)}).catch(()=>{});const Q=await K.loaded.navigation;if(!z&&Array.isArray(Q==null?void 0:Q.toc)&&S(Q.toc),await be.display(),z)return;x(!1),(V=u.current)==null||V.call(u,1,c.current||1),be.on("relocated",me=>{var he,je,Ne,_e;const X=me;if((he=X==null?void 0:X.start)!=null&&he.cfi&&(m.current=X.start.cfi),(je=X==null?void 0:X.start)!=null&&je.href){const ye=X.start.href,ge=[],xe=ke=>{for(const pe of ke){const Re=pe.href.split("#")[0];Re&&(ye===Re||ye.endsWith("/"+Re)||ye.endsWith(Re))&&ge.push(pe.href),pe.subitems&&xe(pe.subitems)}};xe(E.current),ge.length===1&&N(ge[0])}const ne=(Ne=X==null?void 0:X.start)==null?void 0:Ne.location,ce=c.current;typeof ne=="number"&&ce>0&&((_e=u.current)==null||_e.call(u,ne+1,ce))})}catch(te){console.error("EPUB 加载错误:",te),z||(b(o("epub.load_failed")),x(!1))}};return()=>{var V,te,K;z=!0,window.clearTimeout($);try{(te=(V=f.current)==null?void 0:V.destroy)==null||te.call(V)}catch{}try{(K=l.current)==null||K.destroy()}catch{}f.current=null,l.current=null}},[r]),s.useEffect(()=>{const L=()=>{const z=p.current;!z||!f.current||f.current.resize(z.offsetWidth,z.offsetHeight)};return window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[]),s.useEffect(()=>(j(),()=>{var L;cancelAnimationFrame(Z.current),(L=A.current)==null||L.removeEventListener("scroll",G.current)}),[r,j]);const I=s.useCallback(L=>L===D,[D]),q=(L,z=0)=>e.jsx("ul",{style:{marginLeft:z>0?16:0},children:L.map(($,Y)=>{const V=I($.href);return e.jsxs("li",{children:[e.jsx("button",{onClick:()=>B($.href),className:`rfp-w-full rfp-text-left rfp-py-2 rfp-px-3 rfp-text-sm rfp-rounded rfp-transition-all rfp-truncate ${V?"rfp-text-fg-primary rfp-bg-surface-3 rfp-font-medium":"rfp-text-fg-secondary hover:rfp-text-fg-primary hover:rfp-bg-surface-2"}`,title:$.label,children:$.label.trim()}),$.subitems&&$.subitems.length>0&&q($.subitems,z+1)]},`${$.href}-${Y}`)})});return e.jsxs("div",{className:"rfp-relative rfp-w-full rfp-h-full rfp-flex rfp-justify-center rfp-bg-[#f5f5f0] rfp-overflow-hidden",children:[w&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-text-fg-secondary rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:w})}),y&&!w&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-z-10",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),k.length>0&&e.jsxs("div",{className:"rfp-absolute rfp-inset-0 rfp-z-20 rfp-flex rfp-transition-opacity rfp-duration-300",style:{opacity:M?1:0,pointerEvents:M?"auto":"none"},children:[e.jsxs("div",{className:"rfp-w-72 rfp-max-w-[80%] rfp-h-full rfp-bg-surface-overlay rfp-backdrop-blur-xl rfp-border-r rfp-border-line-weak rfp-flex rfp-flex-col rfp-shadow-2xl rfp-transition-transform rfp-duration-300",style:{transform:M?"translateX(0)":"translateX(-100%)"},children:[e.jsxs("div",{className:"rfp-flex rfp-items-center rfp-justify-between rfp-px-4 rfp-py-3 rfp-border-b rfp-border-line-weak rfp-flex-shrink-0",children:[e.jsx("span",{className:"rfp-text-fg-primary rfp-font-medium rfp-text-sm",children:o("toolbar.toc")}),e.jsx("button",{onClick:()=>T(!1),className:"rfp-text-fg-tertiary hover:rfp-text-fg-primary rfp-transition-colors",children:e.jsx(_.X,{className:"rfp-w-4 rfp-h-4"})})]}),e.jsx("div",{className:"rfp-flex-1 rfp-overflow-y-auto rfp-py-4 rfp-px-1",children:q(k)})]}),e.jsx("div",{className:"rfp-flex-1 rfp-transition-opacity rfp-duration-300",style:{background:M?"rgba(0,0,0,0.3)":"transparent"},onClick:()=>T(!1)})]}),!w&&e.jsx("div",{ref:p,className:"rfp-h-full rfp-bg-surface-toolbar rfp-shadow-lg",style:{width:g?"100%":`${Ws}px`,maxWidth:"100%",transition:"width 0.3s ease",overflow:"hidden"}})]})}),Os=Object.freeze(Object.defineProperty({__proto__:null,EpubRenderer:Is},Symbol.toStringTag,{value:"Module"})),Hs=`
|
|
39
26
|
@namespace epub "http://www.idpf.org/2007/ops";
|
|
40
27
|
html { color-scheme: light; }
|
|
41
28
|
body {
|
|
@@ -57,7 +44,7 @@
|
|
|
57
44
|
img { max-width: 100% !important; height: auto !important; }
|
|
58
45
|
a { color: #2563eb; text-decoration: none; }
|
|
59
46
|
pre { white-space: pre-wrap !important; }
|
|
60
|
-
`,pa=794,zs=p.forwardRef(({url:r,onChapterChange:e,onFullWidthChange:t},s)=>{const i=Q(),n=p.useRef(null),l=p.useRef(null),a=p.useRef(e),c=p.useRef(t);a.current=e,c.current=t;const f=p.useRef(1),[d,h]=p.useState(!0),[u,m]=p.useState(null),[g,x]=p.useState([]),[v,b]=p.useState(!1),[y,j]=p.useState(""),[k,N]=p.useState(!1),M=p.useRef(!1);M.current=k;const z=p.useCallback((E,R)=>{var $;R>0&&(f.current=R),($=a.current)==null||$.call(a,Math.max(1,E+1),f.current)},[]),P=p.useCallback(()=>{const E=l.current;E&&E.prev().catch(()=>{})},[]),S=p.useCallback(()=>{const E=l.current;E&&E.next().catch(()=>{})},[]),F=p.useCallback(()=>b(E=>!E),[]),L=p.useCallback(()=>{var G;const E=!M.current;N(E),(G=c.current)==null||G.call(c,E);const R=l.current;if(!R)return;const $=R.renderer;$&&$.setAttribute("max-inline-size",E?"9999":"720")},[]),V=p.useCallback(E=>{var R;j(E),b(!1),(R=l.current)==null||R.goTo(E).catch(()=>{})},[]);p.useImperativeHandle(s,()=>({prevPage:P,nextPage:S,toggleFullWidth:L,toggleToc:F}),[P,S,L,F]),p.useEffect(()=>{const E=n.current;if(!E)return;h(!0),m(null),x([]),b(!1),j(""),E.replaceChildren();let R=!1,$=null;return(async()=>{var q,Y,_,A,B,ee;try{if(R)return;$=document.createElement("foliate-view"),E.appendChild($),l.current=$,$.addEventListener("relocate",je=>{var Ne,ze;const J=je.detail;if(!J)return;const he=J.location;if(he&&typeof he.current=="number"&&typeof he.total=="number")z(he.current,he.total);else{const Be=((ze=(Ne=l.current)==null?void 0:Ne.book)==null?void 0:ze.sections)??[],ke=J.index??0,Se=J.fraction??0,ae=Math.max(Be.length,1),Ve=Math.round((ke+Se)/ae*ae);z(Ve,ae)}const pe=J.tocItem;pe!=null&&pe.href&&j(pe.href)});const X=await fetch(r);if(!X.ok)throw new Error(`请求失败: ${X.status}`);const ne=await X.blob();let re="book.mobi";try{const J=new URL(r,window.location.href).pathname.split("/").pop();J&&(re=decodeURIComponent(J))}catch{}const $e=new File([ne],re);if(await $.open($e),R){(Y=(q=$.book)==null?void 0:q.destroy)==null||Y.call(q);return}const ie=$.renderer;ie&&(ie.setAttribute("animated",""),ie.setAttribute("max-inline-size","720"),ie.setAttribute("margin","48"),ie.setAttribute("gap","5%"),(_=ie.setStyles)==null||_.call(ie,ha),await((A=ie.next)==null?void 0:A.call(ie))),x(((B=$.book)==null?void 0:B.toc)??[]),h(!1),z(0,((ee=$.book)==null?void 0:ee.sections.length)??1)}catch(X){console.error("MOBI/AZW3 加载错误:",X),R||(m(i("mobi.load_failed")),h(!1))}})(),()=>{var q,Y,_;R=!0;try{(_=(Y=(q=l.current)==null?void 0:q.book)==null?void 0:Y.destroy)==null||_.call(Y)}catch{}l.current=null,E.replaceChildren()}},[r,z]);const H=p.useCallback(E=>!!E&&E===y,[y]),U=(E,R=0)=>o.jsx("ul",{style:{listStyle:"none",padding:0,margin:R>0?"0 0 0 16px":0},children:E.map(($,G)=>{var q,Y;return o.jsxs("li",{children:[$.href?o.jsx("button",{onClick:()=>V($.href),className:`rfp-w-full rfp-text-left rfp-py-2 rfp-px-3 rfp-text-sm rfp-rounded rfp-transition-all rfp-truncate ${H($.href)?"rfp-text-fg-primary rfp-bg-surface-3 rfp-font-medium":"rfp-text-fg-secondary hover:rfp-text-fg-primary hover:rfp-bg-surface-2"}`,title:$.label,children:(q=$.label)==null?void 0:q.trim()}):o.jsx("div",{className:"rfp-w-full rfp-py-2 rfp-px-3 rfp-text-sm rfp-text-fg-tertiary rfp-truncate",children:(Y=$.label)==null?void 0:Y.trim()}),$.subitems&&$.subitems.length>0&&U($.subitems,R+1)]},`${$.href??$.label}-${G}`)})});return o.jsxs("div",{className:"rfp-relative rfp-w-full rfp-h-full rfp-flex rfp-justify-center rfp-bg-[#f5f5f0] rfp-overflow-hidden",children:[u&&o.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-text-fg-secondary rfp-text-center rfp-p-6",children:o.jsx("p",{className:"rfp-text-lg",children:u})}),d&&!u&&o.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-z-10",children:o.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),g.length>0&&o.jsxs("div",{className:"rfp-absolute rfp-inset-0 rfp-z-20 rfp-flex rfp-transition-opacity rfp-duration-300",style:{opacity:v?1:0,pointerEvents:v?"auto":"none"},children:[o.jsxs("div",{className:"rfp-w-72 rfp-max-w-[80%] rfp-h-full rfp-bg-surface-overlay rfp-backdrop-blur-xl rfp-border-r rfp-border-line-weak rfp-flex rfp-flex-col rfp-shadow-2xl rfp-transition-transform rfp-duration-300",style:{transform:v?"translateX(0)":"translateX(-100%)"},children:[o.jsxs("div",{className:"rfp-flex rfp-items-center rfp-justify-between rfp-px-4 rfp-py-3 rfp-border-b rfp-border-line-weak rfp-flex-shrink-0",children:[o.jsx("span",{className:"rfp-text-fg-primary rfp-font-medium rfp-text-sm",children:i("toolbar.toc")}),o.jsx("button",{onClick:()=>b(!1),className:"rfp-text-fg-tertiary hover:rfp-text-fg-primary rfp-transition-colors",children:o.jsx(T.X,{className:"rfp-w-4 rfp-h-4"})})]}),o.jsx("div",{className:"rfp-flex-1 rfp-overflow-y-auto rfp-py-4 rfp-px-1",children:U(g)})]}),o.jsx("div",{className:"rfp-flex-1 rfp-transition-opacity rfp-duration-300",style:{background:v?"rgba(0,0,0,0.3)":"transparent"},onClick:()=>b(!1)})]}),!u&&o.jsx("div",{ref:n,className:"rfp-h-full rfp-bg-surface-toolbar rfp-shadow-lg",style:{width:k?"100%":`${pa}px`,maxWidth:"100%",transition:"width 0.3s ease"}})]})});zs.displayName="MobiRenderer";const ua=Object.freeze(Object.defineProperty({__proto__:null,MobiRenderer:zs},Symbol.toStringTag,{value:"Module"})),ma=r=>{var s;const e=((s=r.split(".").pop())==null?void 0:s.toLowerCase().split("?")[0])||"";return{mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska",m4v:"video/mp4","3gp":"video/3gpp",flv:"video/x-flv"}[e]||"video/mp4"},ga=({url:r})=>{const e=Q(),[t,s]=p.useState(null),[i,n]=p.useState(!0),l=p.useRef(null),a=p.useRef(null);return p.useEffect(()=>{if(!a.current&&l.current){const c=document.createElement("video-js");c.classList.add("vjs-big-play-centered","vjs-theme-apple"),l.current.appendChild(c);const f=ma(r),h=Zs(c,{controls:!0,fill:!0,preload:"auto",controlBar:{children:["playToggle","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","remainingTimeDisplay","fullscreenToggle"],volumePanel:{inline:!1}},html5:{vhs:{overrideNative:!0},nativeVideoTracks:!1,nativeAudioTracks:!1,nativeTextTracks:!1},sources:f==="video/quicktime"?[{src:r,type:"video/quicktime"},{src:r,type:"video/mp4"}]:[{src:r,type:f}]}),u=h.el().querySelector("video");u&&(u.style.objectFit="contain"),h.on("loadeddata",()=>{n(!1)}),h.on("error",()=>{const m=h.error();console.error("Video.js error:",m),s(e("video.load_failed_with_error",{error:(m==null?void 0:m.message)||e("common.unknown_error")})),n(!1)}),a.current=h}},[r]),p.useEffect(()=>{const c=a.current;return()=>{c&&!c.isDisposed()&&(c.dispose(),a.current=null)}},[]),t?o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsxs("div",{className:"rfp-text-center",children:[o.jsx("div",{className:"rfp-w-16 rfp-h-16 rfp-mx-auto rfp-mb-4 rfp-rounded-full rfp-bg-red-500/10 rfp-flex rfp-items-center rfp-justify-center",children:o.jsx("svg",{className:"rfp-w-8 rfp-h-8 rfp-text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),o.jsx("p",{className:"rfp-text-lg rfp-font-medium rfp-text-fg-primary rfp-mb-2",children:e("video.load_failed")}),o.jsx("p",{className:"rfp-text-sm rfp-text-fg-tertiary",children:t})]})}):o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsxs("div",{className:"rfp-w-full rfp-h-full rfp-relative",children:[i&&o.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-3 rfp-backdrop-blur-sm rfp-z-10",children:o.jsxs("div",{className:"rfp-text-center",children:[o.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-mx-auto rfp-mb-3 rfp-border-3 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"}),o.jsx("p",{className:"rfp-text-sm rfp-text-fg-secondary rfp-font-medium",children:e("video.loading")})]})}),o.jsx("div",{ref:l,className:"rfp-overflow-hidden rfp-w-full rfp-h-full [&_video]:rfp-object-contain",style:{boxShadow:"0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05)"}})]})})},xa=Object.freeze(Object.defineProperty({__proto__:null,VideoRenderer:ga},Symbol.toStringTag,{value:"Module"}));function ba({url:r}){const e=p.useRef(null),[t,s]=p.useState(!1),[i,n]=p.useState(!0),[l,a]=p.useState(0),[c,f]=p.useState(0),[d,h]=p.useState(1),[u,m]=p.useState(!1),[g,x]=p.useState(!1),[v,b]=p.useState(null);p.useEffect(()=>{const S=e.current;if(!S)return;n(!0),b(null);const F=()=>{isNaN(S.currentTime)||a(S.currentTime)},L=()=>{!isNaN(S.duration)&&isFinite(S.duration)&&f(S.duration)},V=()=>{n(!1),L()},H=()=>n(!0),U=()=>{n(!1),s(!0)},E=()=>s(!0),R=()=>s(!1),$=()=>s(!1),G=()=>{b("音频加载失败"),n(!1)};return S.addEventListener("timeupdate",F),S.addEventListener("loadedmetadata",L),S.addEventListener("durationchange",L),S.addEventListener("canplay",V),S.addEventListener("waiting",H),S.addEventListener("playing",U),S.addEventListener("play",E),S.addEventListener("pause",R),S.addEventListener("ended",$),S.addEventListener("error",G),S.readyState>=3?(n(!1),L()):S.readyState>=1&&L(),()=>{S.removeEventListener("timeupdate",F),S.removeEventListener("loadedmetadata",L),S.removeEventListener("durationchange",L),S.removeEventListener("canplay",V),S.removeEventListener("waiting",H),S.removeEventListener("playing",U),S.removeEventListener("play",E),S.removeEventListener("pause",R),S.removeEventListener("ended",$),S.removeEventListener("error",G)}},[r]);const y=p.useCallback(()=>{const S=e.current;S&&(S.paused?S.play().catch(()=>{}):S.pause())},[]),j=p.useCallback(S=>{const F=e.current;F&&(F.currentTime=S,a(S))},[]),k=p.useCallback(S=>{const F=e.current;F&&(F.currentTime=Math.max(0,Math.min(F.currentTime+S,F.duration||1/0)))},[]),N=p.useCallback(S=>{const F=e.current;if(!F)return;const L=Math.max(0,Math.min(1,S));F.volume=L,h(L),L>0&&(F.muted=!1,m(!1))},[]),M=p.useCallback(()=>{const S=e.current;S&&(S.muted=!S.muted,m(S.muted))},[]),z=p.useCallback(()=>{const S=e.current;if(!S)return;const F=!S.loop;S.loop=F,x(F)},[]),P=p.useCallback(S=>{if(!isFinite(S)||isNaN(S)||S<0)return"0:00";const F=Math.floor(S/60),L=Math.floor(S%60);return`${F}:${L.toString().padStart(2,"0")}`},[]);return{audioRef:e,isPlaying:t,isLoading:i,isLoop:g,currentTime:l,duration:c,volume:d,isMuted:u,error:v,togglePlay:y,seek:j,skip:k,setVolume:N,toggleMute:M,toggleLoop:z,formatTime:P}}const wa=({text:r,className:e="",style:t})=>{const s=p.useRef(null),i=p.useRef(null),[n,l]=p.useState(!1),[a,c]=p.useState(0);p.useEffect(()=>{const u=()=>{const g=s.current,x=i.current;if(!g||!x)return;const v=g.clientWidth,b=x.scrollWidth;l(b>v),c(b)};u();const m=new ResizeObserver(u);return s.current&&m.observe(s.current),()=>m.disconnect()},[r]);const f=60,d=a+f,h=d/40;return o.jsxs("div",{ref:s,className:`rfp-overflow-hidden rfp-whitespace-nowrap ${e}`,style:t,children:[n?o.jsxs(le.motion.div,{className:"rfp-inline-flex rfp-whitespace-nowrap",animate:{x:[0,-d]},transition:{duration:h,repeat:1/0,ease:"linear",repeatDelay:1.5},children:[o.jsx("span",{children:r}),o.jsx("span",{style:{width:f},className:"rfp-inline-block"}),o.jsx("span",{children:r})]}):null,o.jsx("div",{ref:i,className:"rfp-whitespace-nowrap",style:n?{position:"absolute",visibility:"hidden",pointerEvents:"none"}:void 0,children:r})]})},va=({isPlaying:r})=>o.jsx(le.motion.div,{className:"rfp-absolute",style:{top:"-6px",right:"2px",width:"100px",height:"120px",transformOrigin:"76px 16px",zIndex:5},animate:{rotate:r?16:0},transition:{duration:.8,ease:[.4,0,.2,1]},children:o.jsxs("svg",{width:"100",height:"120",viewBox:"0 0 100 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("circle",{cx:"76",cy:"16",r:"13",fill:"rgba(0,0,0,0.3)"}),o.jsx("circle",{cx:"76",cy:"16",r:"11",fill:"url(#baseGrad)"}),o.jsx("circle",{cx:"76",cy:"16",r:"6",fill:"url(#baseInnerGrad)"}),o.jsx("circle",{cx:"76",cy:"16",r:"2.5",fill:"#222",stroke:"#555",strokeWidth:"0.5"}),o.jsx("path",{d:"M74 22 L56 88",stroke:"url(#armGrad)",strokeWidth:"3.5",strokeLinecap:"round"}),o.jsx("path",{d:"M74.8 22 L56.8 88",stroke:"rgba(255,255,255,0.06)",strokeWidth:"1",strokeLinecap:"round"}),o.jsx("rect",{x:"50",y:"86",width:"12",height:"7",rx:"1.5",fill:"url(#headGrad)"}),o.jsx("rect",{x:"52.5",y:"92",width:"7",height:"9",rx:"1",fill:"url(#cartridgeGrad)"}),o.jsx("line",{x1:"56",y1:"101",x2:"56",y2:"105",stroke:"#bbb",strokeWidth:"1.2",strokeLinecap:"round"}),o.jsx("circle",{cx:"56",cy:"105.5",r:"0.8",fill:"#ddd"}),o.jsxs("defs",{children:[o.jsxs("radialGradient",{id:"baseGrad",cx:"40%",cy:"35%",children:[o.jsx("stop",{offset:"0%",stopColor:"#555"}),o.jsx("stop",{offset:"100%",stopColor:"#1a1a1a"})]}),o.jsxs("radialGradient",{id:"baseInnerGrad",cx:"40%",cy:"35%",children:[o.jsx("stop",{offset:"0%",stopColor:"#666"}),o.jsx("stop",{offset:"100%",stopColor:"#333"})]}),o.jsxs("linearGradient",{id:"armGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[o.jsx("stop",{offset:"0%",stopColor:"#555"}),o.jsx("stop",{offset:"50%",stopColor:"#444"}),o.jsx("stop",{offset:"100%",stopColor:"#333"})]}),o.jsxs("linearGradient",{id:"headGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[o.jsx("stop",{offset:"0%",stopColor:"#555"}),o.jsx("stop",{offset:"100%",stopColor:"#333"})]}),o.jsxs("linearGradient",{id:"cartridgeGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[o.jsx("stop",{offset:"0%",stopColor:"#444"}),o.jsx("stop",{offset:"100%",stopColor:"#222"})]})]})]})}),ya=({url:r,fileName:e})=>{const t=Q(),{audioRef:s,isPlaying:i,isLoading:n,isLoop:l,currentTime:a,duration:c,volume:f,isMuted:d,error:h,togglePlay:u,seek:m,skip:g,setVolume:x,toggleMute:v,toggleLoop:b,formatTime:y}=ba({url:r}),[j,k]=p.useState(!1),N=p.useRef(null),M=p.useRef(),z=c>0?a/c:0;p.useEffect(()=>{const L=V=>{N.current&&!N.current.contains(V.target)&&k(!1)};return j&&document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[j]);const P=()=>{clearTimeout(M.current),k(!0)},S=()=>{M.current=setTimeout(()=>k(!1),300)},F=d||f===0?T.VolumeX:f<.5?T.Volume1:T.Volume2;return h?o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:o.jsx("p",{className:"rfp-text-lg",children:h})})}):o.jsxs("div",{className:"rfp-flex rfp-flex-col rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-p-4 md:rfp-p-8 rfp-gap-5 md:rfp-gap-8 rfp-select-none",children:[o.jsxs("div",{className:"rfp-relative",style:{width:"260px",height:"240px"},children:[o.jsx(le.motion.div,{className:"rfp-absolute rfp-rounded-full",style:{width:"220px",height:"220px",top:"18px",left:"8px",background:"radial-gradient(circle, rgba(129,140,248,0.12) 0%, transparent 70%)"},animate:i?{scale:[1,1.08,1],opacity:[.5,1,.5]}:{scale:1,opacity:.2},transition:i?{duration:3,repeat:1/0,ease:"easeInOut"}:{duration:.5}}),o.jsxs("div",{className:"rfp-absolute rfp-rounded-full rfp-overflow-hidden",style:{width:"200px",height:"200px",top:"28px",left:"18px",background:`
|
|
47
|
+
`,As=794,Rr=s.forwardRef(({url:r,onChapterChange:t,onFullWidthChange:n},a)=>{const o=J(),i=se(),p=s.useRef(null),l=s.useRef(null),f=s.useRef(t),u=s.useRef(n);f.current=t,u.current=n;const d=s.useRef(1),[c,m]=s.useState(!0),[h,y]=s.useState(null),[x,w]=s.useState([]),[b,g]=s.useState(!1),[v,k]=s.useState(""),[S,M]=s.useState(!1),T=s.useRef(!1);T.current=S;const D=s.useCallback((j,R)=>{var C;R>0&&(d.current=R),(C=f.current)==null||C.call(f,Math.max(1,j+1),d.current)},[]),N=s.useCallback(()=>{const j=l.current;j&&j.prev().catch(()=>{})},[]),E=s.useCallback(()=>{const j=l.current;j&&j.next().catch(()=>{})},[]),F=s.useCallback(()=>g(j=>!j),[]),H=s.useCallback(()=>{var B;const j=!T.current;M(j),(B=u.current)==null||B.call(u,j);const R=l.current;if(!R)return;const C=R.renderer;C&&C.setAttribute("max-inline-size",j?"9999":"720")},[]),A=s.useCallback(j=>{var R;k(j),g(!1),(R=l.current)==null||R.goTo(j).catch(()=>{})},[]);s.useImperativeHandle(a,()=>({prevPage:N,nextPage:E,toggleFullWidth:H,toggleToc:F}),[N,E,H,F]),s.useEffect(()=>{const j=p.current;if(!j)return;m(!0),y(null),w([]),g(!1),k(""),j.replaceChildren();let R=!1,C=null;return(async()=>{var I,q,L,z,$,Y;try{if(R)return;C=document.createElement("foliate-view"),j.appendChild(C),l.current=C,C.addEventListener("relocate",me=>{var he,je;const X=me.detail;if(!X)return;const ne=X.location;if(ne&&typeof ne.current=="number"&&typeof ne.total=="number")D(ne.current,ne.total);else{const Ne=((je=(he=l.current)==null?void 0:he.book)==null?void 0:je.sections)??[],_e=X.index??0,ye=X.fraction??0,ge=Math.max(Ne.length,1),xe=Math.round((_e+ye)/ge*ge);D(xe,ge)}const ce=X.tocItem;ce!=null&&ce.href&&k(ce.href)});const V=await i(r);if(!V.ok)throw new Error(`请求失败: ${V.status}`);const te=await V.blob();let K="book.mobi";try{const X=new URL(r,window.location.href).pathname.split("/").pop();X&&(K=decodeURIComponent(X))}catch{}const be=new File([te],K);if(await C.open(be),R){(q=(I=C.book)==null?void 0:I.destroy)==null||q.call(I);return}const Q=C.renderer;Q&&(Q.setAttribute("animated",""),Q.setAttribute("max-inline-size","720"),Q.setAttribute("margin","48"),Q.setAttribute("gap","5%"),(L=Q.setStyles)==null||L.call(Q,Hs),await((z=Q.next)==null?void 0:z.call(Q))),w((($=C.book)==null?void 0:$.toc)??[]),m(!1),D(0,((Y=C.book)==null?void 0:Y.sections.length)??1)}catch(V){console.error("MOBI/AZW3 加载错误:",V),R||(y(o("mobi.load_failed")),m(!1))}})(),()=>{var I,q,L;R=!0;try{(L=(q=(I=l.current)==null?void 0:I.book)==null?void 0:q.destroy)==null||L.call(q)}catch{}l.current=null,j.replaceChildren()}},[r,D]);const Z=s.useCallback(j=>!!j&&j===v,[v]),G=(j,R=0)=>e.jsx("ul",{style:{listStyle:"none",padding:0,margin:R>0?"0 0 0 16px":0},children:j.map((C,B)=>{var I,q;return e.jsxs("li",{children:[C.href?e.jsx("button",{onClick:()=>A(C.href),className:`rfp-w-full rfp-text-left rfp-py-2 rfp-px-3 rfp-text-sm rfp-rounded rfp-transition-all rfp-truncate ${Z(C.href)?"rfp-text-fg-primary rfp-bg-surface-3 rfp-font-medium":"rfp-text-fg-secondary hover:rfp-text-fg-primary hover:rfp-bg-surface-2"}`,title:C.label,children:(I=C.label)==null?void 0:I.trim()}):e.jsx("div",{className:"rfp-w-full rfp-py-2 rfp-px-3 rfp-text-sm rfp-text-fg-tertiary rfp-truncate",children:(q=C.label)==null?void 0:q.trim()}),C.subitems&&C.subitems.length>0&&G(C.subitems,R+1)]},`${C.href??C.label}-${B}`)})});return e.jsxs("div",{className:"rfp-relative rfp-w-full rfp-h-full rfp-flex rfp-justify-center rfp-bg-[#f5f5f0] rfp-overflow-hidden",children:[h&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-text-fg-secondary rfp-text-center rfp-p-6",children:e.jsx("p",{className:"rfp-text-lg",children:h})}),c&&!h&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-z-10",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),x.length>0&&e.jsxs("div",{className:"rfp-absolute rfp-inset-0 rfp-z-20 rfp-flex rfp-transition-opacity rfp-duration-300",style:{opacity:b?1:0,pointerEvents:b?"auto":"none"},children:[e.jsxs("div",{className:"rfp-w-72 rfp-max-w-[80%] rfp-h-full rfp-bg-surface-overlay rfp-backdrop-blur-xl rfp-border-r rfp-border-line-weak rfp-flex rfp-flex-col rfp-shadow-2xl rfp-transition-transform rfp-duration-300",style:{transform:b?"translateX(0)":"translateX(-100%)"},children:[e.jsxs("div",{className:"rfp-flex rfp-items-center rfp-justify-between rfp-px-4 rfp-py-3 rfp-border-b rfp-border-line-weak rfp-flex-shrink-0",children:[e.jsx("span",{className:"rfp-text-fg-primary rfp-font-medium rfp-text-sm",children:o("toolbar.toc")}),e.jsx("button",{onClick:()=>g(!1),className:"rfp-text-fg-tertiary hover:rfp-text-fg-primary rfp-transition-colors",children:e.jsx(_.X,{className:"rfp-w-4 rfp-h-4"})})]}),e.jsx("div",{className:"rfp-flex-1 rfp-overflow-y-auto rfp-py-4 rfp-px-1",children:G(x)})]}),e.jsx("div",{className:"rfp-flex-1 rfp-transition-opacity rfp-duration-300",style:{background:b?"rgba(0,0,0,0.3)":"transparent"},onClick:()=>g(!1)})]}),!h&&e.jsx("div",{ref:p,className:"rfp-h-full rfp-bg-surface-toolbar rfp-shadow-lg",style:{width:S?"100%":`${As}px`,maxWidth:"100%",transition:"width 0.3s ease"}})]})});Rr.displayName="MobiRenderer";const Bs=Object.freeze(Object.defineProperty({__proto__:null,MobiRenderer:Rr},Symbol.toStringTag,{value:"Module"})),qs=r=>{var a;const t=((a=r.split(".").pop())==null?void 0:a.toLowerCase().split("?")[0])||"";return{mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska",m4v:"video/mp4","3gp":"video/3gpp",flv:"video/x-flv"}[t]||"video/mp4"},Us=({url:r})=>{const t=J(),[n,a]=s.useState(null),[o,i]=s.useState(!0),p=s.useRef(null),l=s.useRef(null);return s.useEffect(()=>{if(!l.current&&p.current){const f=document.createElement("video-js");f.classList.add("vjs-big-play-centered","vjs-theme-apple"),p.current.appendChild(f);const u=qs(r),c=qr(f,{controls:!0,fill:!0,preload:"auto",controlBar:{children:["playToggle","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","remainingTimeDisplay","fullscreenToggle"],volumePanel:{inline:!1}},html5:{vhs:{overrideNative:!0},nativeVideoTracks:!1,nativeAudioTracks:!1,nativeTextTracks:!1},sources:u==="video/quicktime"?[{src:r,type:"video/quicktime"},{src:r,type:"video/mp4"}]:[{src:r,type:u}]}),m=c.el().querySelector("video");m&&(m.style.objectFit="contain"),c.on("loadeddata",()=>{i(!1)}),c.on("error",()=>{const h=c.error();console.error("Video.js error:",h),a(t("video.load_failed_with_error",{error:(h==null?void 0:h.message)||t("common.unknown_error")})),i(!1)}),l.current=c}},[r]),s.useEffect(()=>{const f=l.current;return()=>{f&&!f.isDisposed()&&(f.dispose(),l.current=null)}},[]),n?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsxs("div",{className:"rfp-text-center",children:[e.jsx("div",{className:"rfp-w-16 rfp-h-16 rfp-mx-auto rfp-mb-4 rfp-rounded-full rfp-bg-red-500/10 rfp-flex rfp-items-center rfp-justify-center",children:e.jsx("svg",{className:"rfp-w-8 rfp-h-8 rfp-text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("p",{className:"rfp-text-lg rfp-font-medium rfp-text-fg-primary rfp-mb-2",children:t("video.load_failed")}),e.jsx("p",{className:"rfp-text-sm rfp-text-fg-tertiary",children:n})]})}):e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsxs("div",{className:"rfp-w-full rfp-h-full rfp-relative",children:[o&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-3 rfp-backdrop-blur-sm rfp-z-10",children:e.jsxs("div",{className:"rfp-text-center",children:[e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-mx-auto rfp-mb-3 rfp-border-3 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"}),e.jsx("p",{className:"rfp-text-sm rfp-text-fg-secondary rfp-font-medium",children:t("video.loading")})]})}),e.jsx("div",{ref:p,className:"rfp-overflow-hidden rfp-w-full rfp-h-full [&_video]:rfp-object-contain",style:{boxShadow:"0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05)"}})]})})},Gs=Object.freeze(Object.defineProperty({__proto__:null,VideoRenderer:Us},Symbol.toStringTag,{value:"Module"}));function Vs({url:r}){const t=s.useRef(null),[n,a]=s.useState(!1),[o,i]=s.useState(!0),[p,l]=s.useState(0),[f,u]=s.useState(0),[d,c]=s.useState(1),[m,h]=s.useState(!1),[y,x]=s.useState(!1),[w,b]=s.useState(null);s.useEffect(()=>{const N=t.current;if(!N)return;i(!0),b(null);const E=()=>{isNaN(N.currentTime)||l(N.currentTime)},F=()=>{!isNaN(N.duration)&&isFinite(N.duration)&&u(N.duration)},H=()=>{i(!1),F()},A=()=>i(!0),Z=()=>{i(!1),a(!0)},G=()=>a(!0),j=()=>a(!1),R=()=>a(!1),C=()=>{b("音频加载失败"),i(!1)};return N.addEventListener("timeupdate",E),N.addEventListener("loadedmetadata",F),N.addEventListener("durationchange",F),N.addEventListener("canplay",H),N.addEventListener("waiting",A),N.addEventListener("playing",Z),N.addEventListener("play",G),N.addEventListener("pause",j),N.addEventListener("ended",R),N.addEventListener("error",C),N.readyState>=3?(i(!1),F()):N.readyState>=1&&F(),()=>{N.removeEventListener("timeupdate",E),N.removeEventListener("loadedmetadata",F),N.removeEventListener("durationchange",F),N.removeEventListener("canplay",H),N.removeEventListener("waiting",A),N.removeEventListener("playing",Z),N.removeEventListener("play",G),N.removeEventListener("pause",j),N.removeEventListener("ended",R),N.removeEventListener("error",C)}},[r]);const g=s.useCallback(()=>{const N=t.current;N&&(N.paused?N.play().catch(()=>{}):N.pause())},[]),v=s.useCallback(N=>{const E=t.current;E&&(E.currentTime=N,l(N))},[]),k=s.useCallback(N=>{const E=t.current;E&&(E.currentTime=Math.max(0,Math.min(E.currentTime+N,E.duration||1/0)))},[]),S=s.useCallback(N=>{const E=t.current;if(!E)return;const F=Math.max(0,Math.min(1,N));E.volume=F,c(F),F>0&&(E.muted=!1,h(!1))},[]),M=s.useCallback(()=>{const N=t.current;N&&(N.muted=!N.muted,h(N.muted))},[]),T=s.useCallback(()=>{const N=t.current;if(!N)return;const E=!N.loop;N.loop=E,x(E)},[]),D=s.useCallback(N=>{if(!isFinite(N)||isNaN(N)||N<0)return"0:00";const E=Math.floor(N/60),F=Math.floor(N%60);return`${E}:${F.toString().padStart(2,"0")}`},[]);return{audioRef:t,isPlaying:n,isLoading:o,isLoop:y,currentTime:p,duration:f,volume:d,isMuted:m,error:w,togglePlay:g,seek:v,skip:k,setVolume:S,toggleMute:M,toggleLoop:T,formatTime:D}}const Xs=({text:r,className:t="",style:n})=>{const a=s.useRef(null),o=s.useRef(null),[i,p]=s.useState(!1),[l,f]=s.useState(0);s.useEffect(()=>{const m=()=>{const y=a.current,x=o.current;if(!y||!x)return;const w=y.clientWidth,b=x.scrollWidth;p(b>w),f(b)};m();const h=new ResizeObserver(m);return a.current&&h.observe(a.current),()=>h.disconnect()},[r]);const u=60,d=l+u,c=d/40;return e.jsxs("div",{ref:a,className:`rfp-overflow-hidden rfp-whitespace-nowrap ${t}`,style:n,children:[i?e.jsxs(re.motion.div,{className:"rfp-inline-flex rfp-whitespace-nowrap",animate:{x:[0,-d]},transition:{duration:c,repeat:1/0,ease:"linear",repeatDelay:1.5},children:[e.jsx("span",{children:r}),e.jsx("span",{style:{width:u},className:"rfp-inline-block"}),e.jsx("span",{children:r})]}):null,e.jsx("div",{ref:o,className:"rfp-whitespace-nowrap",style:i?{position:"absolute",visibility:"hidden",pointerEvents:"none"}:void 0,children:r})]})},Zs=({isPlaying:r})=>e.jsx(re.motion.div,{className:"rfp-absolute",style:{top:"-6px",right:"2px",width:"100px",height:"120px",transformOrigin:"76px 16px",zIndex:5},animate:{rotate:r?16:0},transition:{duration:.8,ease:[.4,0,.2,1]},children:e.jsxs("svg",{width:"100",height:"120",viewBox:"0 0 100 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"76",cy:"16",r:"13",fill:"rgba(0,0,0,0.3)"}),e.jsx("circle",{cx:"76",cy:"16",r:"11",fill:"url(#baseGrad)"}),e.jsx("circle",{cx:"76",cy:"16",r:"6",fill:"url(#baseInnerGrad)"}),e.jsx("circle",{cx:"76",cy:"16",r:"2.5",fill:"#222",stroke:"#555",strokeWidth:"0.5"}),e.jsx("path",{d:"M74 22 L56 88",stroke:"url(#armGrad)",strokeWidth:"3.5",strokeLinecap:"round"}),e.jsx("path",{d:"M74.8 22 L56.8 88",stroke:"rgba(255,255,255,0.06)",strokeWidth:"1",strokeLinecap:"round"}),e.jsx("rect",{x:"50",y:"86",width:"12",height:"7",rx:"1.5",fill:"url(#headGrad)"}),e.jsx("rect",{x:"52.5",y:"92",width:"7",height:"9",rx:"1",fill:"url(#cartridgeGrad)"}),e.jsx("line",{x1:"56",y1:"101",x2:"56",y2:"105",stroke:"#bbb",strokeWidth:"1.2",strokeLinecap:"round"}),e.jsx("circle",{cx:"56",cy:"105.5",r:"0.8",fill:"#ddd"}),e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"baseGrad",cx:"40%",cy:"35%",children:[e.jsx("stop",{offset:"0%",stopColor:"#555"}),e.jsx("stop",{offset:"100%",stopColor:"#1a1a1a"})]}),e.jsxs("radialGradient",{id:"baseInnerGrad",cx:"40%",cy:"35%",children:[e.jsx("stop",{offset:"0%",stopColor:"#666"}),e.jsx("stop",{offset:"100%",stopColor:"#333"})]}),e.jsxs("linearGradient",{id:"armGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#555"}),e.jsx("stop",{offset:"50%",stopColor:"#444"}),e.jsx("stop",{offset:"100%",stopColor:"#333"})]}),e.jsxs("linearGradient",{id:"headGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#555"}),e.jsx("stop",{offset:"100%",stopColor:"#333"})]}),e.jsxs("linearGradient",{id:"cartridgeGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#444"}),e.jsx("stop",{offset:"100%",stopColor:"#222"})]})]})]})}),Js=({url:r,fileName:t})=>{const n=J(),{audioRef:a,isPlaying:o,isLoading:i,isLoop:p,currentTime:l,duration:f,volume:u,isMuted:d,error:c,togglePlay:m,seek:h,skip:y,setVolume:x,toggleMute:w,toggleLoop:b,formatTime:g}=Vs({url:r}),[v,k]=s.useState(!1),S=s.useRef(null),M=s.useRef(),T=f>0?l/f:0;s.useEffect(()=>{const F=H=>{S.current&&!S.current.contains(H.target)&&k(!1)};return v&&document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[v]);const D=()=>{clearTimeout(M.current),k(!0)},N=()=>{M.current=setTimeout(()=>k(!1),300)},E=d||u===0?_.VolumeX:u<.5?_.Volume1:_.Volume2;return c?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:c})})}):e.jsxs("div",{className:"rfp-flex rfp-flex-col rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-p-4 md:rfp-p-8 rfp-gap-5 md:rfp-gap-8 rfp-select-none",children:[e.jsxs("div",{className:"rfp-relative",style:{width:"260px",height:"240px"},children:[e.jsx(re.motion.div,{className:"rfp-absolute rfp-rounded-full",style:{width:"220px",height:"220px",top:"18px",left:"8px",background:"radial-gradient(circle, rgba(129,140,248,0.12) 0%, transparent 70%)"},animate:o?{scale:[1,1.08,1],opacity:[.5,1,.5]}:{scale:1,opacity:.2},transition:o?{duration:3,repeat:1/0,ease:"easeInOut"}:{duration:.5}}),e.jsxs("div",{className:"rfp-absolute rfp-rounded-full rfp-overflow-hidden",style:{width:"200px",height:"200px",top:"28px",left:"18px",background:`
|
|
61
48
|
radial-gradient(circle at center, transparent 95%, rgba(30,30,30,0.8) 95.5%, #111 97%),
|
|
62
49
|
radial-gradient(circle at center, transparent 38%, rgba(50,50,50,0.5) 38.15%, transparent 38.4%),
|
|
63
50
|
radial-gradient(circle at center, transparent 45%, rgba(50,50,50,0.3) 45.15%, transparent 45.4%),
|
|
@@ -68,13 +55,13 @@
|
|
|
68
55
|
radial-gradient(circle at center, transparent 80%, rgba(50,50,50,0.4) 80.15%, transparent 80.4%),
|
|
69
56
|
radial-gradient(circle at center, transparent 87%, rgba(50,50,50,0.3) 87.15%, transparent 87.4%),
|
|
70
57
|
conic-gradient(from 0deg, #1c1c1c, #232323, #1a1a1a, #262626, #1c1c1c, #212121, #1a1a1a, #252525, #1c1c1c, #232323, #1a1a1a, #262626, #1c1c1c)
|
|
71
|
-
`,boxShadow:
|
|
58
|
+
`,boxShadow:o?"0 0 36px rgba(129,140,248,0.1), 0 8px 32px rgba(0,0,0,0.4), inset 0 0 20px rgba(0,0,0,0.4)":"0 8px 32px rgba(0,0,0,0.4), inset 0 0 20px rgba(0,0,0,0.4)",animation:"rfp-vinyl-spin 8s linear infinite",animationPlayState:o?"running":"paused"},children:[e.jsxs("div",{className:"rfp-absolute rfp-rounded-full",style:{width:"34%",height:"34%",top:"33%",left:"33%",background:"radial-gradient(circle at 40% 38%, #818cf8, #6366f1, #4f46e5, #4338ca)",boxShadow:"inset 0 1px 3px rgba(255,255,255,0.25), inset 0 -1px 3px rgba(0,0,0,0.3), 0 0 8px rgba(0,0,0,0.3)"},children:[e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-rounded-full rfp-opacity-20",style:{background:`
|
|
72
59
|
radial-gradient(circle at center, transparent 30%, rgba(0,0,0,0.3) 31%, transparent 32%),
|
|
73
60
|
radial-gradient(circle at center, transparent 50%, rgba(0,0,0,0.2) 51%, transparent 52%),
|
|
74
61
|
radial-gradient(circle at center, transparent 70%, rgba(0,0,0,0.3) 71%, transparent 72%),
|
|
75
62
|
radial-gradient(circle at center, transparent 88%, rgba(0,0,0,0.2) 89%, transparent 90%)
|
|
76
|
-
`}}),o.jsx("div",{className:"rfp-absolute rfp-rounded-full",style:{width:"14%",height:"14%",top:"43%",left:"43%",background:"radial-gradient(circle at 40% 40%, #333, #0d0d0d)",boxShadow:"inset 0 1px 3px rgba(0,0,0,0.9), 0 0 2px rgba(0,0,0,0.5)"}})]}),n&&o.jsx(le.motion.div,{className:"rfp-absolute rfp-inset-0 rfp-rounded-full",style:{border:"2px solid rgba(129,140,248,0.3)"},animate:{scale:[1,1.02,1],opacity:[.3,.6,.3]},transition:{duration:1.5,repeat:1/0}})]}),o.jsx(va,{isPlaying:i})]}),o.jsxs("div",{className:"rfp-text-center rfp-max-w-sm md:rfp-max-w-md rfp-px-4",children:[o.jsx(wa,{text:e,className:"rfp-text-lg md:rfp-text-xl rfp-font-medium rfp-mb-1 rfp-text-fg-primary"}),o.jsx("p",{className:"rfp-text-xs rfp-tracking-widest rfp-uppercase rfp-text-accent",children:"Audio"})]}),o.jsxs("div",{className:"rfp-w-full rfp-max-w-sm md:rfp-max-w-md rfp-rounded-2xl rfp-p-4 md:rfp-p-6 rfp-border rfp-bg-surface-1 rfp-border-line-weak",style:{backdropFilter:"blur(16px)"},children:[o.jsxs("div",{className:"rfp-mb-5",children:[o.jsxs("div",{className:"rfp-relative rfp-h-4 rfp-flex rfp-items-center",children:[o.jsx("div",{className:"rfp-absolute rfp-w-full rfp-h-[5px] rfp-rounded-full rfp-bg-surface-2"}),o.jsx("div",{className:"rfp-absolute rfp-h-[5px] rfp-rounded-full rfp-pointer-events-none",style:{width:`${z*100}%`,background:"linear-gradient(90deg, var(--fp-accent), var(--fp-accent-hover))",boxShadow:i?"0 0 8px rgba(129,140,248,0.4)":"none",transition:"width 0.1s linear"}}),o.jsx("input",{type:"range",min:"0",max:c>0?c:a||100,step:"any",value:a,onChange:L=>m(parseFloat(L.target.value)),disabled:c<=0,"aria-label":t("audio.aria.progress"),className:"audio-slider rfp-absolute rfp-w-full"})]}),o.jsxs("div",{className:"rfp-flex rfp-justify-between rfp-text-xs rfp-mt-2.5 rfp-text-fg-tertiary",children:[o.jsx("span",{style:{fontVariantNumeric:"tabular-nums"},children:y(a)}),o.jsx("span",{style:{fontVariantNumeric:"tabular-nums"},children:c>0?y(c):"--:--"})]})]}),o.jsxs("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-gap-3",children:[o.jsx(le.motion.button,{onClick:b,whileHover:{scale:1.1},whileTap:{scale:.92},"aria-label":t(l?"audio.aria.loop_off":"audio.aria.loop_on"),className:`rfp-w-9 rfp-h-9 rfp-rounded-full rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors ${l?"rfp-bg-accent-soft rfp-text-accent":"rfp-bg-surface-2 rfp-text-fg-tertiary"}`,children:o.jsx(T.Repeat,{className:"rfp-w-4 rfp-h-4"})}),o.jsx(le.motion.button,{onClick:()=>g(-10),whileHover:{scale:1.1},whileTap:{scale:.92},"aria-label":t("audio.aria.backward_10"),className:"rfp-w-10 rfp-h-10 rfp-rounded-full rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors rfp-bg-surface-2 rfp-text-fg-secondary",children:o.jsx(T.SkipBack,{className:"rfp-w-[18px] rfp-h-[18px]"})}),o.jsx(le.motion.button,{onClick:u,whileHover:{scale:1.06},whileTap:{scale:.94},"aria-label":t(i?"audio.aria.pause":"audio.aria.play"),className:"rfp-w-14 rfp-h-14 rfp-rounded-full rfp-flex rfp-items-center rfp-justify-center",style:{background:"linear-gradient(135deg, var(--fp-accent-hover), var(--fp-accent))",color:"#fff",boxShadow:"0 4px 20px rgba(99,102,241,0.35)"},children:i?o.jsx(T.Pause,{className:"rfp-w-6 rfp-h-6"}):o.jsx(T.Play,{className:"rfp-w-6 rfp-h-6 rfp-ml-0.5"})}),o.jsx(le.motion.button,{onClick:()=>g(10),whileHover:{scale:1.1},whileTap:{scale:.92},"aria-label":t("audio.aria.forward_10"),className:"rfp-w-10 rfp-h-10 rfp-rounded-full rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors rfp-bg-surface-2 rfp-text-fg-secondary",children:o.jsx(T.SkipForward,{className:"rfp-w-[18px] rfp-h-[18px]"})}),o.jsxs("div",{ref:N,className:"rfp-relative",onMouseEnter:P,onMouseLeave:S,children:[o.jsx(le.motion.button,{onClick:v,whileHover:{scale:1.1},whileTap:{scale:.92},"aria-label":t(d?"audio.aria.unmute":"audio.aria.mute"),className:`rfp-w-9 rfp-h-9 rfp-rounded-full rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors ${j?"rfp-bg-accent-soft rfp-text-accent":"rfp-bg-surface-2 rfp-text-fg-secondary"}`,children:o.jsx(F,{className:"rfp-w-4 rfp-h-4"})}),o.jsx(le.AnimatePresence,{children:j&&o.jsx(le.motion.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.12},className:"rfp-absolute rfp-bottom-full rfp-mb-2 rfp-rounded-xl rfp-p-3 rfp-border rfp-bg-surface-3 rfp-border-line",style:{left:"50%",marginLeft:"-27px",backdropFilter:"blur(16px)"},onMouseEnter:P,onMouseLeave:S,children:o.jsxs("div",{className:"rfp-flex rfp-flex-col rfp-items-center rfp-gap-2",style:{height:"100px"},children:[o.jsxs("div",{className:"rfp-relative rfp-flex rfp-items-center rfp-justify-center",style:{width:"24px",height:"80px"},children:[o.jsx("div",{className:"rfp-absolute rfp-rounded-full rfp-bg-surface-2",style:{width:"3px",height:"100%"}}),o.jsx("div",{className:"rfp-absolute rfp-bottom-0 rfp-rounded-full rfp-pointer-events-none",style:{width:"3px",height:`${(d?0:f)*100}%`,background:"var(--fp-accent-hover)",transition:"height 0.1s linear"}}),o.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:d?0:f,onChange:L=>x(parseFloat(L.target.value)),"aria-label":t("audio.aria.volume"),className:"volume-slider-vertical rfp-absolute",style:{width:"80px",height:"24px",transform:"rotate(-90deg)",transformOrigin:"center center"}})]}),o.jsx("span",{className:"rfp-text-[10px] rfp-tabular-nums rfp-text-fg-tertiary",children:Math.round((d?0:f)*100)})]})})})]})]})]}),o.jsx("audio",{ref:s,src:r,className:"rfp-hidden"})]})},ja=Object.freeze(Object.defineProperty({__proto__:null,AudioRenderer:ya},Symbol.toStringTag,{value:"Module"}));function Mt(r,e){const t=cs(),[s,i]=p.useState(""),[n,l]=p.useState(!0);return p.useEffect(()=>{let a=!1;return l(!0),ri.codeToHtml(r,{lang:e,theme:t==="light"?"github-light":"dark-plus"}).then(c=>{a||(i(c),l(!1))}).catch(()=>{a||(i(""),l(!1))}),()=>{a=!0}},[r,e,t]),{html:s,loading:n}}const _s=r=>{const[e,t]=p.useState(!1),s=p.useCallback(async()=>{try{await navigator.clipboard.writeText(r)}catch{const i=document.createElement("textarea");i.value=r,document.body.appendChild(i),i.select(),document.execCommand("copy"),document.body.removeChild(i)}t(!0),setTimeout(()=>t(!1),2e3)},[r]);return{copied:e,handleCopy:s}},ka=({text:r})=>{const e=Q(),{copied:t,handleCopy:s}=_s(r);return o.jsx("button",{onClick:s,className:"rfp-p-1 rfp-rounded rfp-text-fg-muted hover:rfp-text-fg-secondary rfp-transition-colors rfp-flex rfp-items-center rfp-gap-1",title:e(t?"markdown.copied":"markdown.copy_code"),children:t?o.jsx(T.Check,{size:13}):o.jsx(T.Copy,{size:13})})},Sa=({text:r})=>{const e=Q(),{copied:t,handleCopy:s}=_s(r);return o.jsx("button",{onClick:s,className:"rfp-absolute rfp-top-2 rfp-right-2 rfp-p-1.5 rfp-rounded-md rfp-bg-surface-2 hover:rfp-bg-surface-3 rfp-text-fg-tertiary hover:rfp-text-fg-secondary rfp-transition-colors rfp-opacity-0 group-hover:rfp-opacity-100 rfp-border rfp-border-line",title:e(t?"markdown.copied":"markdown.copy_code"),children:t?o.jsx(T.Check,{size:14}):o.jsx(T.Copy,{size:14})})},Ca=({code:r,lang:e})=>{const{html:t}=Mt(r,e);return o.jsxs("div",{className:"rfp-relative rfp-group rfp-my-4",children:[o.jsxs("div",{className:"rfp-flex rfp-items-center rfp-justify-between rfp-px-4 rfp-py-1.5 rfp-bg-surface-1 rfp-border rfp-border-line-weak rfp-rounded-t-md rfp-border-b-0",children:[o.jsx("span",{className:"rfp-text-xs rfp-text-fg-secondary rfp-font-mono rfp-select-none",children:e}),o.jsx(ka,{text:r})]}),t?o.jsx("div",{className:"rfp-shiki-wrapper rfp-rounded-b-md rfp-border rfp-border-line-weak rfp-border-t-0 rfp-overflow-x-auto",dangerouslySetInnerHTML:{__html:t}}):o.jsx("pre",{className:"rfp-m-0 rfp-rounded-b-md rfp-border rfp-border-line-weak rfp-border-t-0 rfp-overflow-x-auto rfp-p-4 rfp-bg-code-bg",style:{fontSize:"13px",lineHeight:"1.5"},children:o.jsx("code",{className:"rfp-font-mono rfp-text-code-fg rfp-text-sm",children:r})})]})},Na=({url:r,viewMode:e="preview"})=>{const t=Q(),[s,i]=p.useState(""),[n,l]=p.useState(!0),[a,c]=p.useState(null),{html:f}=Mt(e==="source"?s:"","markdown");return p.useEffect(()=>{(async()=>{try{l(!0),c(null);const h=await Qe(r);i(h)}catch(h){c(t("markdown.load_failed")),console.error(h)}finally{l(!1)}})()},[r]),n?o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}):a?o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:o.jsx("p",{className:"rfp-text-lg",children:a})})}):e==="source"?o.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-bg-code-bg",children:f?o.jsx("div",{className:"rfp-shiki-wrapper with-line-numbers",dangerouslySetInnerHTML:{__html:f}}):o.jsx("pre",{className:"rfp-p-6 rfp-text-fg-primary rfp-font-mono rfp-text-sm rfp-whitespace-pre-wrap rfp-break-words",children:s})}):o.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-p-6 md:rfp-p-10",children:o.jsx("div",{className:"rfp-max-w-full md:rfp-max-w-4xl rfp-mx-auto",children:o.jsx(Ys,{remarkPlugins:[Js,Ks],rehypePlugins:[ei,Qs],components:{code({node:d,inline:h,className:u,children:m,...g}){const x=/language-(\w+)/.exec(u||""),v=String(m).replace(/\n$/,"");return!h&&x?o.jsx(Ca,{code:v,lang:x[1]}):h?o.jsx("code",{className:"rfp-bg-surface-2 rfp-px-1.5 rfp-py-0.5 rfp-rounded rfp-text-sm rfp-font-mono rfp-text-fg-primary rfp-border rfp-border-line-weak",...g,children:m}):o.jsxs("div",{className:"rfp-relative rfp-group rfp-my-4",children:[o.jsx(Sa,{text:v}),o.jsx("pre",{className:"rfp-m-0 rfp-rounded-md rfp-border rfp-border-line-weak rfp-overflow-x-auto rfp-p-4 rfp-bg-code-bg",style:{fontSize:"13px",lineHeight:"1.5"},children:o.jsx("code",{className:"rfp-font-mono rfp-text-code-fg rfp-text-sm",children:m})})]})},h1:({children:d})=>o.jsx("h1",{className:"rfp-text-3xl rfp-font-semibold rfp-mb-4 rfp-mt-6 rfp-text-fg-primary first:rfp-mt-0",children:d}),h2:({children:d})=>o.jsx("h2",{className:"rfp-text-2xl rfp-font-semibold rfp-mb-3 rfp-mt-8 rfp-text-fg-primary",children:d}),h3:({children:d})=>o.jsx("h3",{className:"rfp-text-xl rfp-font-semibold rfp-mb-2 rfp-mt-6 rfp-text-fg-primary",children:d}),h4:({children:d})=>o.jsx("h4",{className:"rfp-text-lg rfp-font-semibold rfp-mb-2 rfp-mt-4 rfp-text-fg-primary",children:d}),p:({children:d})=>o.jsx("p",{className:"rfp-text-fg-secondary rfp-mb-4 rfp-leading-7 rfp-text-base",children:d}),a:({href:d,children:h})=>o.jsx("a",{href:d,className:"rfp-text-indigo-400 hover:rfp-text-indigo-300 rfp-underline rfp-decoration-indigo-600 hover:rfp-decoration-indigo-400",target:"_blank",rel:"noopener noreferrer",children:h}),ul:({children:d})=>o.jsx("ul",{className:"rfp-list-disc rfp-pl-6 rfp-mb-4 rfp-text-fg-secondary rfp-space-y-1",children:d}),ol:({children:d})=>o.jsx("ol",{className:"rfp-list-decimal rfp-pl-6 rfp-mb-4 rfp-text-fg-secondary rfp-space-y-1",children:d}),li:({children:d})=>o.jsx("li",{className:"rfp-leading-7",children:d}),blockquote:({children:d})=>o.jsx("blockquote",{className:"rfp-border-l-4 rfp-border-line-strong rfp-pl-4 rfp-text-fg-tertiary rfp-my-4 rfp-italic",children:d}),table:({children:d})=>o.jsx("div",{className:"rfp-overflow-x-auto rfp-my-4 rfp-rounded-md rfp-border rfp-border-line",children:o.jsx("table",{className:"rfp-min-w-full rfp-divide-y rfp-divide-divide",children:d})}),thead:({children:d})=>o.jsx("thead",{className:"rfp-bg-surface-1",children:d}),tbody:({children:d})=>o.jsx("tbody",{className:"rfp-divide-y rfp-divide-divide rfp-bg-transparent",children:d}),tr:({children:d})=>o.jsx("tr",{className:"hover:rfp-bg-surface-1 rfp-transition-colors",children:d}),th:({children:d})=>o.jsx("th",{className:"rfp-px-4 rfp-py-3 rfp-text-left rfp-text-xs rfp-font-semibold rfp-text-fg-tertiary rfp-uppercase rfp-tracking-wider",children:d}),td:({children:d})=>o.jsx("td",{className:"rfp-px-4 rfp-py-3 rfp-text-sm rfp-text-fg-secondary",children:d}),hr:()=>o.jsx("hr",{className:"rfp-border-line rfp-my-6"}),img:({src:d,alt:h})=>o.jsx("img",{src:d,alt:h,className:"rfp-rounded-md rfp-max-w-full rfp-h-auto rfp-my-4 rfp-mx-auto rfp-block rfp-shadow-sm"}),input:({type:d,checked:h,...u})=>d==="checkbox"?o.jsx("input",{type:"checkbox",checked:h,readOnly:!0,className:"rfp-mr-2 rfp-rounded rfp-border-line",...u}):o.jsx("input",{type:d,...u}),strong:({children:d})=>o.jsx("strong",{className:"rfp-font-semibold rfp-text-fg-primary",children:d}),em:({children:d})=>o.jsx("em",{className:"rfp-italic",children:d}),del:({children:d})=>o.jsx("del",{className:"rfp-text-fg-muted rfp-line-through",children:d})},children:s})})})},Ea=Object.freeze(Object.defineProperty({__proto__:null,MarkdownRenderer:Na},Symbol.toStringTag,{value:"Module"})),Ta={key:"#9cdcfe",string:"#ce9178",number:"#b5cea8",keyword:"#569cd6",bracket:"#d4d4d4",colon:"rgb(255 255 255 / 0.6)",collapsed:"rgb(255 255 255 / 0.4)",arrow:"rgb(255 255 255 / 0.5)"},Ra={key:"#005cc5",string:"#032f62",number:"#005cc5",keyword:"#d73a49",bracket:"#24292e",colon:"rgb(23 23 23 / 0.6)",collapsed:"rgb(23 23 23 / 0.45)",arrow:"rgb(23 23 23 / 0.55)"},Jt=({keyName:r,value:e,depth:t,defaultExpanded:s,colors:i})=>{const n=Q(),[l,a]=p.useState(s),c=t*20,f=p.useCallback(()=>a(x=>!x),[]);if(e==null||typeof e!="object")return o.jsxs("div",{className:"rfp-flex rfp-items-start rfp-py-px rfp-font-mono rfp-text-sm",style:{paddingLeft:`${c}px`},children:[o.jsx("span",{className:"rfp-w-4 rfp-h-5 rfp-flex-shrink-0"}),r!==void 0&&o.jsxs("span",{className:"rfp-flex-shrink-0",style:{color:i.key},children:['"',r,'"',o.jsx("span",{style:{color:i.colon},children:": "})]}),$a(e,i)]});const d=Array.isArray(e),u=(d?e:Object.entries(e)).length,m=d?"[":"{",g=d?"]":"}";return u===0?o.jsxs("div",{className:"rfp-flex rfp-items-start rfp-py-px rfp-font-mono rfp-text-sm",style:{paddingLeft:`${c}px`},children:[o.jsx("span",{className:"rfp-w-4 rfp-h-5 rfp-flex-shrink-0"}),r!==void 0&&o.jsxs("span",{className:"rfp-flex-shrink-0",style:{color:i.key},children:['"',r,'"',o.jsx("span",{style:{color:i.colon},children:": "})]}),o.jsxs("span",{style:{color:i.bracket},children:[m,g]})]}):o.jsxs("div",{children:[o.jsxs("div",{className:"rfp-flex rfp-items-start rfp-py-px rfp-font-mono rfp-text-sm rfp-cursor-pointer hover:rfp-bg-surface-1 rfp-select-none",style:{paddingLeft:`${c}px`},onClick:f,children:[o.jsx("span",{className:"rfp-w-4 rfp-h-5 rfp-flex-shrink-0 rfp-flex rfp-items-center rfp-justify-center",style:{color:i.arrow},children:l?o.jsx(T.ChevronDown,{className:"rfp-w-3.5 rfp-h-3.5"}):o.jsx(T.ChevronRight,{className:"rfp-w-3.5 rfp-h-3.5"})}),r!==void 0&&o.jsxs("span",{className:"rfp-flex-shrink-0",style:{color:i.key},children:['"',r,'"',o.jsx("span",{style:{color:i.colon},children:": "})]}),o.jsx("span",{style:{color:i.bracket},children:m}),!l&&o.jsxs("span",{className:"rfp-ml-1",style:{color:i.collapsed},children:[d?`${u} ${n("json.items")}`:`${u} ${n("json.keys")}`,o.jsxs("span",{style:{color:i.bracket},children:[" ",g]})]})]}),l&&o.jsxs(o.Fragment,{children:[d?e.map((x,v)=>o.jsx(Jt,{value:x,depth:t+1,defaultExpanded:t<1,colors:i},v)):Object.entries(e).map(([x,v])=>o.jsx(Jt,{keyName:x,value:v,depth:t+1,defaultExpanded:t<1,colors:i},x)),o.jsx("div",{className:"rfp-font-mono rfp-text-sm rfp-py-px",style:{paddingLeft:`${c+20}px`,color:i.bracket},children:g})]})]})};function $a(r,e){return r===null?o.jsx("span",{style:{color:e.keyword,fontStyle:"italic"},children:"null"}):r===void 0?o.jsx("span",{style:{color:e.keyword,fontStyle:"italic"},children:"undefined"}):typeof r=="boolean"?o.jsx("span",{style:{color:e.keyword},children:String(r)}):typeof r=="number"?o.jsx("span",{style:{color:e.number},children:String(r)}):typeof r=="string"?o.jsxs("span",{style:{color:e.string},children:['"',r,'"']}):o.jsx("span",{style:{color:e.bracket},children:String(r)})}function Ma(r){return r==="light"?Ra:Ta}const Fa=({url:r})=>{const e=Q(),t=cs(),s=p.useMemo(()=>Ma(t),[t]),[i,n]=p.useState(null),[l,a]=p.useState(!0),[c,f]=p.useState(null);return p.useEffect(()=>{(async()=>{try{a(!0),f(null);const h=await Qe(r);n(JSON.parse(h))}catch(h){f(e("json.load_failed")),console.error(h)}finally{a(!1)}})()},[r]),l?o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}):c?o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:o.jsx("p",{className:"rfp-text-lg",children:c})})}):o.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-bg-code-bg rfp-py-3 rfp-pr-4",children:o.jsx(Jt,{value:i,depth:0,defaultExpanded:!0,colors:s})})},za=Object.freeze(Object.defineProperty({__proto__:null,JsonRenderer:Fa},Symbol.toStringTag,{value:"Module"})),_a=({url:r,fileName:e})=>{const t=Q(),[s,i]=p.useState(!0),[n,l]=p.useState(null),a=p.useRef(null),c=p.useRef(null),f=p.useRef(null),d=p.useRef(null),h=p.useRef(null),u=p.useRef({width:0,height:0}),m=p.useCallback(()=>{if(!a.current)return{width:800,height:600};const x=a.current.clientWidth,v=a.current.clientHeight,b=x>100?x:800,y=v>100?v:600;return{width:b,height:y}},[]),g=p.useCallback(()=>{if(!a.current||!f.current)return;a.current.innerHTML="",c.current=null;const{width:x,height:v}=m(),b=x<640,y=new dr(a.current,{mode:"read",showToolbar:!1,showContextmenu:!1,showGrid:!0,row:{len:100,height:25},col:{len:26,width:b?80:100,indexWidth:b?40:60,minWidth:b?40:60},view:{height:()=>v,width:()=>x}});y.loadData(f.current),c.current=y},[m]);return p.useEffect(()=>{if(!a.current)return;let x=!0;const v=()=>{if(x){x=!1,u.current=m();return}const b=m(),y=u.current,j=Math.abs(y.width-b.width),k=Math.abs(y.height-b.height);j<10&&k<10||(u.current=b,h.current&&clearTimeout(h.current),h.current=window.setTimeout(()=>{f.current&&g()},500))};return d.current=new ResizeObserver(()=>{v()}),d.current.observe(a.current),()=>{d.current&&d.current.disconnect(),h.current&&clearTimeout(h.current)}},[m,g]),p.useEffect(()=>{let x=!0;const v=async()=>{if(a.current){i(!0),l(null);try{const y=await Qe(r),j=ai(y,{delimiter:oi(e)}),k=Fi(j.header,j.rows,e);if(!x)return;f.current=k,g(),i(!1)}catch(y){x&&(console.error("CSV 解析错误:",y),l(t("csv.load_failed")),i(!1))}}},b=setTimeout(()=>{requestAnimationFrame(()=>{v()})},100);return()=>{x=!1,clearTimeout(b),f.current=null,a.current&&(a.current.innerHTML=""),c.current=null}},[r,e,g]),o.jsxs("div",{className:"rfp-relative rfp-flex rfp-flex-col rfp-items-center rfp-w-full rfp-h-full",children:[s&&o.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-toolbar rfp-backdrop-blur-sm rfp-z-10",children:o.jsxs("div",{className:"rfp-text-center",children:[o.jsx("div",{className:"rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-mx-auto rfp-mb-3 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"}),o.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-fg-secondary rfp-font-medium",children:t("csv.loading")})]})}),n&&!s&&o.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-toolbar rfp-backdrop-blur-sm rfp-z-10",children:o.jsxs("div",{className:"rfp-text-center rfp-max-w-sm md:rfp-max-w-md rfp-px-4",children:[o.jsx("div",{className:"rfp-w-24 rfp-h-24 md:rfp-w-32 md:rfp-h-32 rfp-mx-auto rfp-mb-4 md:rfp-mb-6 rfp-rounded-2xl md:rfp-rounded-3xl rfp-bg-gradient-to-br rfp-from-green-500 rfp-via-emerald-500 rfp-to-teal-500 rfp-flex rfp-items-center rfp-justify-center rfp-shadow-2xl",children:o.jsx(T.FileSpreadsheet,{className:"rfp-w-12 rfp-h-12 md:rfp-w-16 md:rfp-h-16 rfp-text-fg-primary"})}),o.jsx("p",{className:"rfp-text-lg md:rfp-text-xl rfp-text-fg-primary rfp-mb-2 md:rfp-mb-3 rfp-font-medium",children:t("csv.load_failed")}),o.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-fg-tertiary rfp-mb-4 md:rfp-mb-6",children:n})]})}),!n&&o.jsx("div",{ref:a,className:"xlsx-spreadsheet-container rfp-w-full rfp-h-full",style:{opacity:s?0:1}})]})},Da=Object.freeze(Object.defineProperty({__proto__:null,CsvRenderer:_a},Symbol.toStringTag,{value:"Module"})),Pa=r=>{try{const t=new DOMParser().parseFromString(r,"application/xml");if(t.querySelector("parsererror"))return r;const n=new XMLSerializer().serializeToString(t);return Oa(n)}catch{return r}},Oa=r=>{const e=" ",t=/(>)(<)(\/*)/g;let s=r.replace(t,`$1
|
|
77
|
-
$2$3`),
|
|
78
|
-
`).map(
|
|
79
|
-
`)},La=({url:r})=>{const e=Q(),[t,s]=p.useState(""),[i,n]=p.useState(!0),[l,a]=p.useState(null),{html:c}=Mt(t,"xml");return p.useEffect(()=>{(async()=>{try{n(!0),a(null);const d=await Qe(r);s(Pa(d))}catch(d){console.error(d),a(e("xml.load_failed"))}finally{n(!1)}})()},[r]),i?o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}):l?o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:o.jsx("p",{className:"rfp-text-lg",children:l})})}):o.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-bg-code-bg",children:c?o.jsx("div",{className:"rfp-shiki-wrapper with-line-numbers",dangerouslySetInnerHTML:{__html:c}}):o.jsx("pre",{className:"rfp-p-6 rfp-text-fg-primary rfp-font-mono rfp-text-sm rfp-whitespace-pre-wrap rfp-break-words",children:t})})},Ia=Object.freeze(Object.defineProperty({__proto__:null,XmlRenderer:La},Symbol.toStringTag,{value:"Module"})),Aa={srt:"srt",vtt:"vtt",lrc:"lrc",elrc:"elrc",ass:"ass",ssa:"ssa",ttml:"ttml",dfxp:"ttml"},Ha=r=>{var t;const e=((t=r.split(".").pop())==null?void 0:t.toLowerCase())||"";return Aa[e]},Wa=({url:r,fileName:e})=>{const t=Q(),[s,i]=p.useState(""),[n,l]=p.useState(!0),[a,c]=p.useState(null);p.useEffect(()=>{(async()=>{try{l(!0),c(null),i(await Qe(r))}catch(g){console.error(g),c(t("subtitle.load_failed"))}finally{l(!1)}})()},[r]);const f=p.useMemo(()=>{if(!s)return null;try{return mi(s,Ha(e))}catch(m){return console.error(m),null}},[s,e]);if(n)return o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-bg-[#0f0f12]",children:o.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})});if(a||!f)return o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-bg-[#0f0f12]",children:o.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:o.jsx("p",{className:"rfp-text-lg",children:a||t("subtitle.parse_failed")})})});const d=f.format==="lrc"||f.format==="elrc",h=f.metadata??{},u=d?"group-hover:rfp-bg-violet-400":"group-hover:rfp-bg-sky-400";return o.jsxs("div",{className:"rfp-relative rfp-w-full rfp-h-full rfp-bg-[#0f0f12]",children:[o.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-px-6 md:rfp-px-10 rfp-pt-6 rfp-pb-16 md:rfp-pb-20",children:o.jsxs("div",{className:"rfp-relative rfp-max-w-5xl rfp-mx-auto",children:[o.jsx("div",{className:"rfp-absolute rfp-left-[5px] md:rfp-left-[7px] rfp-top-2 rfp-bottom-2 rfp-w-px rfp-bg-surface-1"}),o.jsx("ol",{className:"rfp-space-y-5 md:rfp-space-y-6",children:f.cues.map((m,g)=>o.jsxs("li",{className:"rfp-relative rfp-pl-6 md:rfp-pl-8 rfp-group",children:[o.jsx("div",{className:`rfp-absolute rfp-left-0 rfp-top-2 rfp-w-3 rfp-h-3 rfp-rounded-full rfp-bg-surface-3 rfp-border-2 rfp-border-[#0f0f12] rfp-transition-colors ${u}`}),o.jsxs("div",{className:"rfp-flex rfp-flex-wrap rfp-items-baseline rfp-gap-x-3 rfp-gap-y-1 rfp-mb-1.5",children:[o.jsx("span",{className:"rfp-text-[11px] rfp-font-mono rfp-text-fg-muted rfp-tabular-nums",children:ht(m.start)}),o.jsx("span",{className:"rfp-text-[11px] rfp-text-fg-disabled",children:"→"}),o.jsx("span",{className:"rfp-text-[11px] rfp-font-mono rfp-text-fg-muted rfp-tabular-nums",children:ht(m.end)}),o.jsxs("span",{className:"rfp-text-[10px] rfp-font-mono rfp-text-fg-disabled rfp-tabular-nums",children:["#",m.id??g+1]}),m.style&&o.jsx("span",{className:"rfp-text-[9px] rfp-uppercase rfp-tracking-widest rfp-text-fg-tertiary rfp-px-1.5 rfp-py-0.5 rfp-rounded rfp-bg-surface-1 rfp-border rfp-border-line-weak",children:m.style})]}),m.words&&m.words.length>0?o.jsx("div",{className:"rfp-flex rfp-flex-wrap rfp-gap-x-1.5 rfp-gap-y-1 rfp-text-base md:rfp-text-lg rfp-text-fg-primary rfp-leading-relaxed group-hover:rfp-text-fg-primary rfp-transition-colors",children:m.words.map((x,v)=>o.jsxs("span",{className:"rfp-inline-flex rfp-flex-col rfp-items-start",title:ht(x.start),children:[o.jsx("span",{className:"rfp-text-[9px] rfp-text-fg-disabled rfp-font-mono rfp-leading-none rfp-tabular-nums",children:ht(x.start).slice(3,8)}),o.jsx("span",{className:"rfp-leading-snug",children:x.text})]},`w-${v}`))}):o.jsx("p",{className:`rfp-whitespace-pre-wrap rfp-break-words rfp-leading-relaxed group-hover:rfp-text-fg-primary rfp-transition-colors rfp-text-fg-primary ${d?"rfp-text-base md:rfp-text-xl rfp-font-medium":"rfp-text-sm md:rfp-text-base"}`,children:m.text})]},`cue-${g}`))})]})}),o.jsxs("div",{className:"rfp-pointer-events-none rfp-absolute rfp-bottom-3 rfp-right-3 md:rfp-bottom-4 md:rfp-right-4 rfp-flex rfp-items-center rfp-gap-2 rfp-px-2.5 rfp-py-1 rfp-rounded-full rfp-bg-surface-nav rfp-backdrop-blur rfp-border rfp-border-line-weak rfp-text-[10px] rfp-text-fg-tertiary rfp-font-mono rfp-tabular-nums",children:[o.jsxs("span",{children:[f.cues.length," ",t(d?"subtitle.lines":"subtitle.cues")]}),h.length&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"rfp-text-fg-disabled",children:"·"}),o.jsx("span",{children:h.length})]})]})]})},Ba=Object.freeze(Object.defineProperty({__proto__:null,SubtitleRenderer:Wa},Symbol.toStringTag,{value:"Module"})),Va=({left:r,right:e,initialLeftWidth:t=280,minLeftWidth:s=160,maxLeftWidth:i=640,minRightWidth:n=200,storageKey:l,desktopMedia:a="(min-width: 768px)",className:c=""})=>{const f=p.useRef(null),[d,h]=p.useState(()=>{if(l&&typeof window<"u"){const b=Number(window.localStorage.getItem(l));if(!isNaN(b)&&b>0)return b}return t}),[u,m]=p.useState(!1),[g,x]=p.useState(!1);p.useEffect(()=>{if(typeof window>"u")return;const b=window.matchMedia(a),y=()=>x(b.matches);return y(),b.addEventListener("change",y),()=>b.removeEventListener("change",y)},[a]),p.useEffect(()=>{if(!u)return;const b=N=>{if(!f.current)return;const M=f.current.getBoundingClientRect(),z=N.clientX-M.left,P=M.width-n-6,S=Math.min(i,P),F=Math.max(s,Math.min(S,z));h(F)},y=()=>m(!1);window.addEventListener("mousemove",b),window.addEventListener("mouseup",y);const j=document.body.style.cursor,k=document.body.style.userSelect;return document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",y),document.body.style.cursor=j,document.body.style.userSelect=k}},[u,s,i,n]),p.useEffect(()=>{if(!(!l||u))try{window.localStorage.setItem(l,String(d))}catch{}},[d,l,u]);const v=p.useCallback(b=>{b.preventDefault(),m(!0)},[]);return o.jsxs("div",{ref:f,className:`rfp-w-full rfp-h-full rfp-flex rfp-flex-col md:rfp-flex-row rfp-min-h-0 rfp-min-w-0 ${c}`,children:[o.jsx("div",{className:"rfp-min-h-0 rfp-min-w-0 rfp-flex-shrink-0 rfp-w-full rfp-max-h-60 md:rfp-h-full md:rfp-max-h-none",style:g?{width:`${d}px`}:void 0,children:r}),o.jsx("div",{role:"separator","aria-orientation":"vertical",onMouseDown:v,className:`rfp-hidden md:rfp-block rfp-relative rfp-w-1.5 rfp-flex-shrink-0 rfp-cursor-col-resize rfp-transition-colors ${u?"rfp-bg-surface-toolbar":"rfp-bg-surface-2 hover:rfp-bg-surface-3"}`,children:o.jsx("span",{className:"rfp-absolute rfp-inset-y-0 -rfp-left-1 -rfp-right-1"})}),o.jsx("div",{className:"rfp-flex-1 rfp-min-w-0 rfp-min-h-0 rfp-overflow-hidden",children:e})]})},qa=p.lazy(()=>Promise.resolve().then(()=>mn).then(r=>({default:r.FilePreviewContent}))),Ua=r=>{const e=is({name:r,type:""});return e==="image"?T.FileImage:e==="text"||e==="markdown"||e==="json"||e==="csv"||e==="xml"||e==="subtitle"?r.endsWith(".md")||r.endsWith(".markdown")?T.FileText:T.FileCode:T.File},Ds=({node:r,depth:e,selectedPath:t,expanded:s,onToggle:i,onSelect:n,onHover:l,onLeave:a})=>{var m;const c=s.has(r.path),f=t===r.path,d={paddingLeft:`${e*14+10}px`},h=g=>{const x=g.currentTarget.getBoundingClientRect();l(r.name||"/",x)};if(r.isDir)return o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",onClick:()=>i(r.path),onMouseEnter:h,onMouseLeave:a,className:"rfp-w-full rfp-flex rfp-items-center rfp-gap-1.5 rfp-py-1.5 rfp-pr-2 rfp-text-left rfp-text-fg-secondary hover:rfp-bg-surface-1 rfp-text-sm",style:d,children:[o.jsx(T.ChevronRight,{className:`rfp-w-3.5 rfp-h-3.5 rfp-flex-shrink-0 rfp-transition-transform ${c?"rfp-rotate-90":""}`}),c?o.jsx(T.FolderOpen,{className:"rfp-w-4 rfp-h-4 rfp-flex-shrink-0 rfp-text-amber-300/80"}):o.jsx(T.Folder,{className:"rfp-w-4 rfp-h-4 rfp-flex-shrink-0 rfp-text-amber-300/80"}),o.jsx("span",{className:"rfp-truncate rfp-flex-1 rfp-min-w-0",children:r.name||"/"})]}),c&&((m=r.children)==null?void 0:m.map(g=>o.jsx(Ds,{node:g,depth:e+1,selectedPath:t,expanded:s,onToggle:i,onSelect:n,onHover:l,onLeave:a},g.path)))]});const u=Ua(r.name);return o.jsxs("button",{type:"button",onClick:()=>n(r),onMouseEnter:h,onMouseLeave:a,className:`rfp-w-full rfp-flex rfp-items-center rfp-gap-1.5 rfp-py-1.5 rfp-pr-2 rfp-text-left rfp-text-sm ${f?"rfp-bg-surface-2 rfp-text-fg-primary":"rfp-text-fg-secondary hover:rfp-bg-surface-1"}`,style:d,children:[o.jsx("span",{className:"rfp-w-3.5 rfp-h-3.5 rfp-flex-shrink-0"}),o.jsx(u,{className:"rfp-w-4 rfp-h-4 rfp-flex-shrink-0 rfp-text-fg-tertiary"}),o.jsx("span",{className:"rfp-flex-1 rfp-truncate rfp-min-w-0",children:r.name}),o.jsx("span",{className:"rfp-text-xs rfp-text-fg-disabled rfp-flex-shrink-0 rfp-ml-2",children:ns(r.size)})]})},Ga=({url:r,nestingDepth:e=0,onStatsChange:t})=>{var U;const s=Q(),[i,n]=p.useState(null),[l,a]=p.useState(null),[c,f]=p.useState(!0),[d,h]=p.useState(null),[u,m]=p.useState(new Set([""])),[g,x]=p.useState(null),[v,b]=p.useState(!1),[y,j]=p.useState(null),[k,N]=p.useState(null),M=p.useRef(t);p.useEffect(()=>{M.current=t},[t]),p.useEffect(()=>{let E=!1;return(async()=>{try{f(!0),h(null);const $=await fetch(r);if(!$.ok)throw new Error("加载失败");const G=await $.arrayBuffer(),q=await gi(G);if(E)return;const Y=xi(q),_=bi(Y);n(q),a(_);const A=new Set([""]);if(_.children)for(const B of _.children)B.isDir&&A.add(B.path);m(A)}catch($){console.error($),E||h(s("zip.load_failed"))}finally{E||f(!1)}})(),()=>{E=!0}},[r]),p.useEffect(()=>()=>{g!=null&&g.blobUrl&&URL.revokeObjectURL(g.blobUrl)},[g]);const z=p.useMemo(()=>{if(!l)return null;let E=0,R=0,$=0;const G=q=>{var Y;q.isDir?(q.path&&R++,(Y=q.children)==null||Y.forEach(G)):(E++,$+=q.size)};return G(l),{files:E,dirs:R,size:$}},[l]);p.useEffect(()=>{var E;return(E=M.current)==null||E.call(M,z),()=>{var R;(R=M.current)==null||R.call(M,null)}},[z]);const P=p.useCallback(E=>{m(R=>{const $=new Set(R);return $.has(E)?$.delete(E):$.add(E),$})},[]),S=p.useCallback((E,R)=>{N({text:E,x:R.right+8,y:R.top+R.height/2})},[]),F=p.useCallback(()=>{N(null)},[]),L=p.useCallback(async E=>{if(!(!i||E.isDir)){g!=null&&g.blobUrl&&URL.revokeObjectURL(g.blobUrl),b(!0),j(null);try{const R=lt(E.name),$=await wi(i,E.path,R!=="application/octet-stream"?R:void 0),G=URL.createObjectURL($);x({path:E.path,name:E.name,size:E.size,blobUrl:G})}catch(R){console.error(R),j("条目读取失败")}finally{b(!1)}}},[i,g]);if(c)return o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})});if(d||!l)return o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:o.jsx("p",{className:"rfp-text-lg",children:d||s("zip.parse_failed")})})});const V=o.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto",children:(U=l.children)==null?void 0:U.map(E=>o.jsx(Ds,{node:E,depth:0,selectedPath:(g==null?void 0:g.path)??null,expanded:u,onToggle:P,onSelect:L,onHover:S,onLeave:F},E.path))}),H=o.jsxs("div",{className:"rfp-w-full rfp-h-full rfp-flex rfp-flex-col",children:[!g&&o.jsx("div",{className:"rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center rfp-text-fg-muted rfp-text-sm rfp-p-6",children:"从左侧选择一个文件以预览"}),g&&v&&o.jsx("div",{className:"rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center",children:o.jsx("div",{className:"rfp-w-8 rfp-h-8 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),g&&!v&&y&&o.jsx("div",{className:"rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center rfp-text-fg-secondary",children:y}),g&&!v&&!y&&o.jsx(o.Fragment,{children:o.jsx("div",{className:"rfp-flex-1 rfp-min-h-0 rfp-overflow-hidden rfp-flex rfp-relative rfp-z-0",children:o.jsx(p.Suspense,{fallback:o.jsx("div",{className:"rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center",children:o.jsx("div",{className:"rfp-w-8 rfp-h-8 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),children:o.jsx(qa,{mode:"embed",files:[{name:g.name,url:g.blobUrl,type:lt(g.name)}],currentIndex:0,zipNestingDepth:e+1})})})})]});return o.jsxs(o.Fragment,{children:[o.jsx(Va,{left:V,right:H,initialLeftWidth:280,minLeftWidth:180,maxLeftWidth:560,storageKey:"rfp-zip-split-left"}),k&&typeof document<"u"&&ts.createPortal(o.jsx("div",{className:"rfp-fixed rfp-z-[9999] rfp-pointer-events-none rfp-px-2 rfp-py-1 rfp-bg-[rgba(0,0,0,0.85)] rfp-text-fg-primary rfp-text-xs rfp-rounded rfp-whitespace-nowrap rfp-shadow-lg",style:{left:`${k.x}px`,top:`${k.y}px`,transform:"translateY(-50%)"},children:k.text}),document.body)]})},Xa=Object.freeze(Object.defineProperty({__proto__:null,ZipRenderer:Ga},Symbol.toStringTag,{value:"Module"})),Za=({url:r,fileName:e,wordWrap:t=!0,htmlPreview:s=!1})=>{const i=Q(),[n,l]=p.useState(""),[a,c]=p.useState(!0),[f,d]=p.useState(null),h=li(e),{html:u}=Mt(h!=="text"?n:"",h);return p.useEffect(()=>{(async()=>{try{c(!0),d(null);const g=await Qe(r);l(g)}catch(g){d(i("text.load_failed")),console.error(g)}finally{c(!1)}})()},[r]),a?o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}):f?o.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:o.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:o.jsx("p",{className:"rfp-text-lg",children:f})})}):s&&h==="html"?o.jsx("div",{className:"rfp-w-full rfp-h-full rfp-bg-surface-toolbar",children:o.jsx("iframe",{srcDoc:n,sandbox:"allow-same-origin",className:"rfp-w-full rfp-h-full rfp-border-0",title:e})}):o.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-bg-code-bg",children:h==="text"||!u?o.jsx("pre",{className:`rfp-p-6 rfp-text-fg-primary rfp-font-mono rfp-text-sm ${t?"rfp-whitespace-pre-wrap rfp-break-words":"rfp-whitespace-pre"}`,children:n}):o.jsx("div",{className:`rfp-shiki-wrapper with-line-numbers ${t?"":"no-wrap"}`,dangerouslySetInnerHTML:{__html:u}})})},Ya=Object.freeze(Object.defineProperty({__proto__:null,TextRenderer:Za},Symbol.toStringTag,{value:"Module"}));Object.defineProperty(exports,"pdfjs",{enumerable:!0,get:()=>Pe.pdfjs});exports.FilePreviewContent=Rt;exports.FilePreviewEmbed=xn;exports.FilePreviewModal=gn;exports.LocaleProvider=os;exports.VERSION=bn;exports.configurePdfjs=fs;exports.normalizeFile=rs;exports.normalizeFiles=ss;exports.useLocale=Li;exports.useTranslator=Q;
|
|
63
|
+
`}}),e.jsx("div",{className:"rfp-absolute rfp-rounded-full",style:{width:"14%",height:"14%",top:"43%",left:"43%",background:"radial-gradient(circle at 40% 40%, #333, #0d0d0d)",boxShadow:"inset 0 1px 3px rgba(0,0,0,0.9), 0 0 2px rgba(0,0,0,0.5)"}})]}),i&&e.jsx(re.motion.div,{className:"rfp-absolute rfp-inset-0 rfp-rounded-full",style:{border:"2px solid rgba(129,140,248,0.3)"},animate:{scale:[1,1.02,1],opacity:[.3,.6,.3]},transition:{duration:1.5,repeat:1/0}})]}),e.jsx(Zs,{isPlaying:o})]}),e.jsxs("div",{className:"rfp-text-center rfp-max-w-sm md:rfp-max-w-md rfp-px-4",children:[e.jsx(Xs,{text:t,className:"rfp-text-lg md:rfp-text-xl rfp-font-medium rfp-mb-1 rfp-text-fg-primary"}),e.jsx("p",{className:"rfp-text-xs rfp-tracking-widest rfp-uppercase rfp-text-accent",children:"Audio"})]}),e.jsxs("div",{className:"rfp-w-full rfp-max-w-sm md:rfp-max-w-md rfp-rounded-2xl rfp-p-4 md:rfp-p-6 rfp-border rfp-bg-surface-1 rfp-border-line-weak",style:{backdropFilter:"blur(16px)"},children:[e.jsxs("div",{className:"rfp-mb-5",children:[e.jsxs("div",{className:"rfp-relative rfp-h-4 rfp-flex rfp-items-center",children:[e.jsx("div",{className:"rfp-absolute rfp-w-full rfp-h-[5px] rfp-rounded-full rfp-bg-surface-2"}),e.jsx("div",{className:"rfp-absolute rfp-h-[5px] rfp-rounded-full rfp-pointer-events-none",style:{width:`${T*100}%`,background:"linear-gradient(90deg, var(--fp-accent), var(--fp-accent-hover))",boxShadow:o?"0 0 8px rgba(129,140,248,0.4)":"none",transition:"width 0.1s linear"}}),e.jsx("input",{type:"range",min:"0",max:f>0?f:l||100,step:"any",value:l,onChange:F=>h(parseFloat(F.target.value)),disabled:f<=0,"aria-label":n("audio.aria.progress"),className:"audio-slider rfp-absolute rfp-w-full"})]}),e.jsxs("div",{className:"rfp-flex rfp-justify-between rfp-text-xs rfp-mt-2.5 rfp-text-fg-tertiary",children:[e.jsx("span",{style:{fontVariantNumeric:"tabular-nums"},children:g(l)}),e.jsx("span",{style:{fontVariantNumeric:"tabular-nums"},children:f>0?g(f):"--:--"})]})]}),e.jsxs("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-gap-3",children:[e.jsx(re.motion.button,{onClick:b,whileHover:{scale:1.1},whileTap:{scale:.92},"aria-label":n(p?"audio.aria.loop_off":"audio.aria.loop_on"),className:`rfp-w-9 rfp-h-9 rfp-rounded-full rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors ${p?"rfp-bg-accent-soft rfp-text-accent":"rfp-bg-surface-2 rfp-text-fg-tertiary"}`,children:e.jsx(_.Repeat,{className:"rfp-w-4 rfp-h-4"})}),e.jsx(re.motion.button,{onClick:()=>y(-10),whileHover:{scale:1.1},whileTap:{scale:.92},"aria-label":n("audio.aria.backward_10"),className:"rfp-w-10 rfp-h-10 rfp-rounded-full rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors rfp-bg-surface-2 rfp-text-fg-secondary",children:e.jsx(_.SkipBack,{className:"rfp-w-[18px] rfp-h-[18px]"})}),e.jsx(re.motion.button,{onClick:m,whileHover:{scale:1.06},whileTap:{scale:.94},"aria-label":n(o?"audio.aria.pause":"audio.aria.play"),className:"rfp-w-14 rfp-h-14 rfp-rounded-full rfp-flex rfp-items-center rfp-justify-center",style:{background:"linear-gradient(135deg, var(--fp-accent-hover), var(--fp-accent))",color:"#fff",boxShadow:"0 4px 20px rgba(99,102,241,0.35)"},children:o?e.jsx(_.Pause,{className:"rfp-w-6 rfp-h-6"}):e.jsx(_.Play,{className:"rfp-w-6 rfp-h-6 rfp-ml-0.5"})}),e.jsx(re.motion.button,{onClick:()=>y(10),whileHover:{scale:1.1},whileTap:{scale:.92},"aria-label":n("audio.aria.forward_10"),className:"rfp-w-10 rfp-h-10 rfp-rounded-full rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors rfp-bg-surface-2 rfp-text-fg-secondary",children:e.jsx(_.SkipForward,{className:"rfp-w-[18px] rfp-h-[18px]"})}),e.jsxs("div",{ref:S,className:"rfp-relative",onMouseEnter:D,onMouseLeave:N,children:[e.jsx(re.motion.button,{onClick:w,whileHover:{scale:1.1},whileTap:{scale:.92},"aria-label":n(d?"audio.aria.unmute":"audio.aria.mute"),className:`rfp-w-9 rfp-h-9 rfp-rounded-full rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors ${v?"rfp-bg-accent-soft rfp-text-accent":"rfp-bg-surface-2 rfp-text-fg-secondary"}`,children:e.jsx(E,{className:"rfp-w-4 rfp-h-4"})}),e.jsx(re.AnimatePresence,{children:v&&e.jsx(re.motion.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.12},className:"rfp-absolute rfp-bottom-full rfp-mb-2 rfp-rounded-xl rfp-p-3 rfp-border rfp-bg-surface-3 rfp-border-line",style:{left:"50%",marginLeft:"-27px",backdropFilter:"blur(16px)"},onMouseEnter:D,onMouseLeave:N,children:e.jsxs("div",{className:"rfp-flex rfp-flex-col rfp-items-center rfp-gap-2",style:{height:"100px"},children:[e.jsxs("div",{className:"rfp-relative rfp-flex rfp-items-center rfp-justify-center",style:{width:"24px",height:"80px"},children:[e.jsx("div",{className:"rfp-absolute rfp-rounded-full rfp-bg-surface-2",style:{width:"3px",height:"100%"}}),e.jsx("div",{className:"rfp-absolute rfp-bottom-0 rfp-rounded-full rfp-pointer-events-none",style:{width:"3px",height:`${(d?0:u)*100}%`,background:"var(--fp-accent-hover)",transition:"height 0.1s linear"}}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:d?0:u,onChange:F=>x(parseFloat(F.target.value)),"aria-label":n("audio.aria.volume"),className:"volume-slider-vertical rfp-absolute",style:{width:"80px",height:"24px",transform:"rotate(-90deg)",transformOrigin:"center center"}})]}),e.jsx("span",{className:"rfp-text-[10px] rfp-tabular-nums rfp-text-fg-tertiary",children:Math.round((d?0:u)*100)})]})})})]})]})]}),e.jsx("audio",{ref:a,src:r,className:"rfp-hidden"})]})},Ys=Object.freeze(Object.defineProperty({__proto__:null,AudioRenderer:Js},Symbol.toStringTag,{value:"Module"}));function Ie(r,t){const n=Nr(),[a,o]=s.useState(""),[i,p]=s.useState(!0);return s.useEffect(()=>{let l=!1;return p(!0),Yr.codeToHtml(r,{lang:t,theme:n==="light"?"github-light":"dark-plus"}).then(f=>{l||(o(f),p(!1))}).catch(()=>{l||(o(""),p(!1))}),()=>{l=!0}},[r,t,n]),{html:a,loading:i}}const Cr=r=>{const[t,n]=s.useState(!1),a=s.useCallback(async()=>{try{await navigator.clipboard.writeText(r)}catch{const o=document.createElement("textarea");o.value=r,document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o)}n(!0),setTimeout(()=>n(!1),2e3)},[r]);return{copied:t,handleCopy:a}},Ks=({text:r})=>{const t=J(),{copied:n,handleCopy:a}=Cr(r);return e.jsx("button",{onClick:a,className:"rfp-p-1 rfp-rounded rfp-text-fg-muted hover:rfp-text-fg-secondary rfp-transition-colors rfp-flex rfp-items-center rfp-gap-1",title:t(n?"markdown.copied":"markdown.copy_code"),children:n?e.jsx(_.Check,{size:13}):e.jsx(_.Copy,{size:13})})},Qs=({text:r})=>{const t=J(),{copied:n,handleCopy:a}=Cr(r);return e.jsx("button",{onClick:a,className:"rfp-absolute rfp-top-2 rfp-right-2 rfp-p-1.5 rfp-rounded-md rfp-bg-surface-2 hover:rfp-bg-surface-3 rfp-text-fg-tertiary hover:rfp-text-fg-secondary rfp-transition-colors rfp-opacity-0 group-hover:rfp-opacity-100 rfp-border rfp-border-line",title:t(n?"markdown.copied":"markdown.copy_code"),children:n?e.jsx(_.Check,{size:14}):e.jsx(_.Copy,{size:14})})},en=({code:r,lang:t})=>{const{html:n}=Ie(r,t);return e.jsxs("div",{className:"rfp-relative rfp-group rfp-my-4",children:[e.jsxs("div",{className:"rfp-flex rfp-items-center rfp-justify-between rfp-px-4 rfp-py-1.5 rfp-bg-surface-1 rfp-border rfp-border-line-weak rfp-rounded-t-md rfp-border-b-0",children:[e.jsx("span",{className:"rfp-text-xs rfp-text-fg-secondary rfp-font-mono rfp-select-none",children:t}),e.jsx(Ks,{text:r})]}),n?e.jsx("div",{className:"rfp-shiki-wrapper rfp-rounded-b-md rfp-border rfp-border-line-weak rfp-border-t-0 rfp-overflow-x-auto",dangerouslySetInnerHTML:{__html:n}}):e.jsx("pre",{className:"rfp-m-0 rfp-rounded-b-md rfp-border rfp-border-line-weak rfp-border-t-0 rfp-overflow-x-auto rfp-p-4 rfp-bg-code-bg",style:{fontSize:"13px",lineHeight:"1.5"},children:e.jsx("code",{className:"rfp-font-mono rfp-text-code-fg rfp-text-sm",children:r})})]})},rn=({url:r,viewMode:t="preview"})=>{const n=J(),a=se(),[o,i]=s.useState(""),[p,l]=s.useState(!0),[f,u]=s.useState(null),{html:d}=Ie(t==="source"?o:"","markdown");return s.useEffect(()=>{(async()=>{try{l(!0),u(null);const m=await Me(r,{fetcher:a});i(m)}catch(m){u(n("markdown.load_failed")),console.error(m)}finally{l(!1)}})()},[r,a,n]),p?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}):f?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:f})})}):t==="source"?e.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-bg-code-bg",children:d?e.jsx("div",{className:"rfp-shiki-wrapper with-line-numbers",dangerouslySetInnerHTML:{__html:d}}):e.jsx("pre",{className:"rfp-p-6 rfp-text-fg-primary rfp-font-mono rfp-text-sm rfp-whitespace-pre-wrap rfp-break-words",children:o})}):e.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-p-6 md:rfp-p-10",children:e.jsx("div",{className:"rfp-max-w-full md:rfp-max-w-4xl rfp-mx-auto",children:e.jsx(Ur,{remarkPlugins:[Gr,Vr],rehypePlugins:[Zr,Xr],components:{code({node:c,inline:m,className:h,children:y,...x}){const w=/language-(\w+)/.exec(h||""),b=String(y).replace(/\n$/,"");return!m&&w?e.jsx(en,{code:b,lang:w[1]}):m?e.jsx("code",{className:"rfp-bg-surface-2 rfp-px-1.5 rfp-py-0.5 rfp-rounded rfp-text-sm rfp-font-mono rfp-text-fg-primary rfp-border rfp-border-line-weak",...x,children:y}):e.jsxs("div",{className:"rfp-relative rfp-group rfp-my-4",children:[e.jsx(Qs,{text:b}),e.jsx("pre",{className:"rfp-m-0 rfp-rounded-md rfp-border rfp-border-line-weak rfp-overflow-x-auto rfp-p-4 rfp-bg-code-bg",style:{fontSize:"13px",lineHeight:"1.5"},children:e.jsx("code",{className:"rfp-font-mono rfp-text-code-fg rfp-text-sm",children:y})})]})},h1:({children:c})=>e.jsx("h1",{className:"rfp-text-3xl rfp-font-semibold rfp-mb-4 rfp-mt-6 rfp-text-fg-primary first:rfp-mt-0",children:c}),h2:({children:c})=>e.jsx("h2",{className:"rfp-text-2xl rfp-font-semibold rfp-mb-3 rfp-mt-8 rfp-text-fg-primary",children:c}),h3:({children:c})=>e.jsx("h3",{className:"rfp-text-xl rfp-font-semibold rfp-mb-2 rfp-mt-6 rfp-text-fg-primary",children:c}),h4:({children:c})=>e.jsx("h4",{className:"rfp-text-lg rfp-font-semibold rfp-mb-2 rfp-mt-4 rfp-text-fg-primary",children:c}),p:({children:c})=>e.jsx("p",{className:"rfp-text-fg-secondary rfp-mb-4 rfp-leading-7 rfp-text-base",children:c}),a:({href:c,children:m})=>e.jsx("a",{href:c,className:"rfp-text-indigo-400 hover:rfp-text-indigo-300 rfp-underline rfp-decoration-indigo-600 hover:rfp-decoration-indigo-400",target:"_blank",rel:"noopener noreferrer",children:m}),ul:({children:c})=>e.jsx("ul",{className:"rfp-list-disc rfp-pl-6 rfp-mb-4 rfp-text-fg-secondary rfp-space-y-1",children:c}),ol:({children:c})=>e.jsx("ol",{className:"rfp-list-decimal rfp-pl-6 rfp-mb-4 rfp-text-fg-secondary rfp-space-y-1",children:c}),li:({children:c})=>e.jsx("li",{className:"rfp-leading-7",children:c}),blockquote:({children:c})=>e.jsx("blockquote",{className:"rfp-border-l-4 rfp-border-line-strong rfp-pl-4 rfp-text-fg-tertiary rfp-my-4 rfp-italic",children:c}),table:({children:c})=>e.jsx("div",{className:"rfp-overflow-x-auto rfp-my-4 rfp-rounded-md rfp-border rfp-border-line",children:e.jsx("table",{className:"rfp-min-w-full rfp-divide-y rfp-divide-divide",children:c})}),thead:({children:c})=>e.jsx("thead",{className:"rfp-bg-surface-1",children:c}),tbody:({children:c})=>e.jsx("tbody",{className:"rfp-divide-y rfp-divide-divide rfp-bg-transparent",children:c}),tr:({children:c})=>e.jsx("tr",{className:"hover:rfp-bg-surface-1 rfp-transition-colors",children:c}),th:({children:c})=>e.jsx("th",{className:"rfp-px-4 rfp-py-3 rfp-text-left rfp-text-xs rfp-font-semibold rfp-text-fg-tertiary rfp-uppercase rfp-tracking-wider",children:c}),td:({children:c})=>e.jsx("td",{className:"rfp-px-4 rfp-py-3 rfp-text-sm rfp-text-fg-secondary",children:c}),hr:()=>e.jsx("hr",{className:"rfp-border-line rfp-my-6"}),img:({src:c,alt:m})=>e.jsx("img",{src:c,alt:m,className:"rfp-rounded-md rfp-max-w-full rfp-h-auto rfp-my-4 rfp-mx-auto rfp-block rfp-shadow-sm"}),input:({type:c,checked:m,...h})=>c==="checkbox"?e.jsx("input",{type:"checkbox",checked:m,readOnly:!0,className:"rfp-mr-2 rfp-rounded rfp-border-line",...h}):e.jsx("input",{type:c,...h}),strong:({children:c})=>e.jsx("strong",{className:"rfp-font-semibold rfp-text-fg-primary",children:c}),em:({children:c})=>e.jsx("em",{className:"rfp-italic",children:c}),del:({children:c})=>e.jsx("del",{className:"rfp-text-fg-muted rfp-line-through",children:c})},children:o})})})},tn=Object.freeze(Object.defineProperty({__proto__:null,MarkdownRenderer:rn},Symbol.toStringTag,{value:"Module"})),sn={key:"#9cdcfe",string:"#ce9178",number:"#b5cea8",keyword:"#569cd6",bracket:"#d4d4d4",colon:"rgb(255 255 255 / 0.6)",collapsed:"rgb(255 255 255 / 0.4)",arrow:"rgb(255 255 255 / 0.5)"},nn={key:"#005cc5",string:"#032f62",number:"#005cc5",keyword:"#d73a49",bracket:"#24292e",colon:"rgb(23 23 23 / 0.6)",collapsed:"rgb(23 23 23 / 0.45)",arrow:"rgb(23 23 23 / 0.55)"},Ge=({keyName:r,value:t,depth:n,defaultExpanded:a,colors:o})=>{const i=J(),[p,l]=s.useState(a),f=n*20,u=s.useCallback(()=>l(x=>!x),[]);if(t==null||typeof t!="object")return e.jsxs("div",{className:"rfp-flex rfp-items-start rfp-py-px rfp-font-mono rfp-text-sm",style:{paddingLeft:`${f}px`},children:[e.jsx("span",{className:"rfp-w-4 rfp-h-5 rfp-flex-shrink-0"}),r!==void 0&&e.jsxs("span",{className:"rfp-flex-shrink-0",style:{color:o.key},children:['"',r,'"',e.jsx("span",{style:{color:o.colon},children:": "})]}),on(t,o)]});const d=Array.isArray(t),m=(d?t:Object.entries(t)).length,h=d?"[":"{",y=d?"]":"}";return m===0?e.jsxs("div",{className:"rfp-flex rfp-items-start rfp-py-px rfp-font-mono rfp-text-sm",style:{paddingLeft:`${f}px`},children:[e.jsx("span",{className:"rfp-w-4 rfp-h-5 rfp-flex-shrink-0"}),r!==void 0&&e.jsxs("span",{className:"rfp-flex-shrink-0",style:{color:o.key},children:['"',r,'"',e.jsx("span",{style:{color:o.colon},children:": "})]}),e.jsxs("span",{style:{color:o.bracket},children:[h,y]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"rfp-flex rfp-items-start rfp-py-px rfp-font-mono rfp-text-sm rfp-cursor-pointer hover:rfp-bg-surface-1 rfp-select-none",style:{paddingLeft:`${f}px`},onClick:u,children:[e.jsx("span",{className:"rfp-w-4 rfp-h-5 rfp-flex-shrink-0 rfp-flex rfp-items-center rfp-justify-center",style:{color:o.arrow},children:p?e.jsx(_.ChevronDown,{className:"rfp-w-3.5 rfp-h-3.5"}):e.jsx(_.ChevronRight,{className:"rfp-w-3.5 rfp-h-3.5"})}),r!==void 0&&e.jsxs("span",{className:"rfp-flex-shrink-0",style:{color:o.key},children:['"',r,'"',e.jsx("span",{style:{color:o.colon},children:": "})]}),e.jsx("span",{style:{color:o.bracket},children:h}),!p&&e.jsxs("span",{className:"rfp-ml-1",style:{color:o.collapsed},children:[d?`${m} ${i("json.items")}`:`${m} ${i("json.keys")}`,e.jsxs("span",{style:{color:o.bracket},children:[" ",y]})]})]}),p&&e.jsxs(e.Fragment,{children:[d?t.map((x,w)=>e.jsx(Ge,{value:x,depth:n+1,defaultExpanded:n<1,colors:o},w)):Object.entries(t).map(([x,w])=>e.jsx(Ge,{keyName:x,value:w,depth:n+1,defaultExpanded:n<1,colors:o},x)),e.jsx("div",{className:"rfp-font-mono rfp-text-sm rfp-py-px",style:{paddingLeft:`${f+20}px`,color:o.bracket},children:y})]})]})};function on(r,t){return r===null?e.jsx("span",{style:{color:t.keyword,fontStyle:"italic"},children:"null"}):r===void 0?e.jsx("span",{style:{color:t.keyword,fontStyle:"italic"},children:"undefined"}):typeof r=="boolean"?e.jsx("span",{style:{color:t.keyword},children:String(r)}):typeof r=="number"?e.jsx("span",{style:{color:t.number},children:String(r)}):typeof r=="string"?e.jsxs("span",{style:{color:t.string},children:['"',r,'"']}):e.jsx("span",{style:{color:t.bracket},children:String(r)})}function an(r){return r==="light"?nn:sn}const ln=({url:r})=>{const t=J(),n=se(),a=Nr(),o=s.useMemo(()=>an(a),[a]),[i,p]=s.useState(null),[l,f]=s.useState(!0),[u,d]=s.useState(null);return s.useEffect(()=>{(async()=>{try{f(!0),d(null);const m=await Me(r,{fetcher:n});p(JSON.parse(m))}catch(m){d(t("json.load_failed")),console.error(m)}finally{f(!1)}})()},[r]),l?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}):u?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:u})})}):e.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-bg-code-bg rfp-py-3 rfp-pr-4",children:e.jsx(Ge,{value:i,depth:0,defaultExpanded:!0,colors:o})})},fn=Object.freeze(Object.defineProperty({__proto__:null,JsonRenderer:ln},Symbol.toStringTag,{value:"Module"})),cn=({url:r,fileName:t})=>{const n=J(),a=se(),[o,i]=s.useState(!0),[p,l]=s.useState(null),f=s.useRef(null),u=s.useRef(null),d=s.useRef(null),c=s.useRef(null),m=s.useRef(null),h=s.useRef({width:0,height:0}),y=s.useCallback(()=>{if(!f.current)return{width:800,height:600};const w=f.current.clientWidth,b=f.current.clientHeight,g=w>100?w:800,v=b>100?b:600;return{width:g,height:v}},[]),x=s.useCallback(()=>{if(!f.current||!d.current)return;f.current.innerHTML="",u.current=null;const{width:w,height:b}=y(),g=w<640,v=new hr(f.current,{mode:"read",showToolbar:!1,showContextmenu:!1,showGrid:!0,row:{len:100,height:25},col:{len:26,width:g?80:100,indexWidth:g?40:60,minWidth:g?40:60},view:{height:()=>b,width:()=>w}});v.loadData(d.current),u.current=v},[y]);return s.useEffect(()=>{if(!f.current)return;let w=!0;const b=()=>{if(w){w=!1,h.current=y();return}const g=y(),v=h.current,k=Math.abs(v.width-g.width),S=Math.abs(v.height-g.height);k<10&&S<10||(h.current=g,m.current&&clearTimeout(m.current),m.current=window.setTimeout(()=>{d.current&&x()},500))};return c.current=new ResizeObserver(()=>{b()}),c.current.observe(f.current),()=>{c.current&&c.current.disconnect(),m.current&&clearTimeout(m.current)}},[y,x]),s.useEffect(()=>{let w=!0;const b=async()=>{if(f.current){i(!0),l(null);try{const v=await Me(r,{fetcher:a}),k=st(v,{delimiter:tt(t)}),S=Ft(k.header,k.rows,t);if(!w)return;d.current=S,x(),i(!1)}catch(v){w&&(console.error("CSV 解析错误:",v),l(n("csv.load_failed")),i(!1))}}},g=setTimeout(()=>{requestAnimationFrame(()=>{b()})},100);return()=>{w=!1,clearTimeout(g),d.current=null,f.current&&(f.current.innerHTML=""),u.current=null}},[r,t,x]),e.jsxs("div",{className:"rfp-relative rfp-flex rfp-flex-col rfp-items-center rfp-w-full rfp-h-full",children:[o&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-toolbar rfp-backdrop-blur-sm rfp-z-10",children:e.jsxs("div",{className:"rfp-text-center",children:[e.jsx("div",{className:"rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-mx-auto rfp-mb-3 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"}),e.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-fg-secondary rfp-font-medium",children:n("csv.loading")})]})}),p&&!o&&e.jsx("div",{className:"rfp-absolute rfp-inset-0 rfp-flex rfp-items-center rfp-justify-center rfp-bg-surface-toolbar rfp-backdrop-blur-sm rfp-z-10",children:e.jsxs("div",{className:"rfp-text-center rfp-max-w-sm md:rfp-max-w-md rfp-px-4",children:[e.jsx("div",{className:"rfp-w-24 rfp-h-24 md:rfp-w-32 md:rfp-h-32 rfp-mx-auto rfp-mb-4 md:rfp-mb-6 rfp-rounded-2xl md:rfp-rounded-3xl rfp-bg-gradient-to-br rfp-from-green-500 rfp-via-emerald-500 rfp-to-teal-500 rfp-flex rfp-items-center rfp-justify-center rfp-shadow-2xl",children:e.jsx(_.FileSpreadsheet,{className:"rfp-w-12 rfp-h-12 md:rfp-w-16 md:rfp-h-16 rfp-text-fg-primary"})}),e.jsx("p",{className:"rfp-text-lg md:rfp-text-xl rfp-text-fg-primary rfp-mb-2 md:rfp-mb-3 rfp-font-medium",children:n("csv.load_failed")}),e.jsx("p",{className:"rfp-text-xs md:rfp-text-sm rfp-text-fg-tertiary rfp-mb-4 md:rfp-mb-6",children:p})]})}),!p&&e.jsx("div",{ref:f,className:"xlsx-spreadsheet-container rfp-w-full rfp-h-full",style:{opacity:o?0:1}})]})},pn=Object.freeze(Object.defineProperty({__proto__:null,CsvRenderer:cn},Symbol.toStringTag,{value:"Module"})),dn=r=>{try{const n=new DOMParser().parseFromString(r,"application/xml");if(n.querySelector("parsererror"))return r;const i=new XMLSerializer().serializeToString(n);return un(i)}catch{return r}},un=r=>{const t=" ",n=/(>)(<)(\/*)/g;let a=r.replace(n,`$1
|
|
64
|
+
$2$3`),o=0;return a.split(`
|
|
65
|
+
`).map(i=>{let p=0;/^<\/\w/.test(i)?o=Math.max(o-1,0):/^<\w[^>]*[^/]>.*$/.test(i)&&!/<.+<\/.+>$/.test(i)&&(p=1);const l=t.repeat(o)+i;return o+=p,l}).join(`
|
|
66
|
+
`)},mn=({url:r})=>{const t=J(),n=se(),[a,o]=s.useState(""),[i,p]=s.useState(!0),[l,f]=s.useState(null),{html:u}=Ie(a,"xml");return s.useEffect(()=>{(async()=>{try{p(!0),f(null);const c=await Me(r,{fetcher:n});o(dn(c))}catch(c){console.error(c),f(t("xml.load_failed"))}finally{p(!1)}})()},[r]),i?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}):l?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:l})})}):e.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-bg-code-bg",children:u?e.jsx("div",{className:"rfp-shiki-wrapper with-line-numbers",dangerouslySetInnerHTML:{__html:u}}):e.jsx("pre",{className:"rfp-p-6 rfp-text-fg-primary rfp-font-mono rfp-text-sm rfp-whitespace-pre-wrap rfp-break-words",children:a})})},hn=Object.freeze(Object.defineProperty({__proto__:null,XmlRenderer:mn},Symbol.toStringTag,{value:"Module"})),xn={srt:"srt",vtt:"vtt",lrc:"lrc",elrc:"elrc",ass:"ass",ssa:"ssa",ttml:"ttml",dfxp:"ttml"},bn=r=>{var n;const t=((n=r.split(".").pop())==null?void 0:n.toLowerCase())||"";return xn[t]},gn=({url:r,fileName:t})=>{const n=J(),a=se(),[o,i]=s.useState(""),[p,l]=s.useState(!0),[f,u]=s.useState(null);s.useEffect(()=>{(async()=>{try{l(!0),u(null),i(await Me(r,{fetcher:a}))}catch(x){console.error(x),u(n("subtitle.load_failed"))}finally{l(!1)}})()},[r]);const d=s.useMemo(()=>{if(!o)return null;try{return ht(o,bn(t))}catch(y){return console.error(y),null}},[o,t]);if(p)return e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-bg-[#0f0f12]",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})});if(f||!d)return e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-bg-[#0f0f12]",children:e.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:f||n("subtitle.parse_failed")})})});const c=d.format==="lrc"||d.format==="elrc",m=d.metadata??{},h=c?"group-hover:rfp-bg-violet-400":"group-hover:rfp-bg-sky-400";return e.jsxs("div",{className:"rfp-relative rfp-w-full rfp-h-full rfp-bg-[#0f0f12]",children:[e.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-px-6 md:rfp-px-10 rfp-pt-6 rfp-pb-16 md:rfp-pb-20",children:e.jsxs("div",{className:"rfp-relative rfp-max-w-5xl rfp-mx-auto",children:[e.jsx("div",{className:"rfp-absolute rfp-left-[5px] md:rfp-left-[7px] rfp-top-2 rfp-bottom-2 rfp-w-px rfp-bg-surface-1"}),e.jsx("ol",{className:"rfp-space-y-5 md:rfp-space-y-6",children:d.cues.map((y,x)=>e.jsxs("li",{className:"rfp-relative rfp-pl-6 md:rfp-pl-8 rfp-group",children:[e.jsx("div",{className:`rfp-absolute rfp-left-0 rfp-top-2 rfp-w-3 rfp-h-3 rfp-rounded-full rfp-bg-surface-3 rfp-border-2 rfp-border-[#0f0f12] rfp-transition-colors ${h}`}),e.jsxs("div",{className:"rfp-flex rfp-flex-wrap rfp-items-baseline rfp-gap-x-3 rfp-gap-y-1 rfp-mb-1.5",children:[e.jsx("span",{className:"rfp-text-[11px] rfp-font-mono rfp-text-fg-muted rfp-tabular-nums",children:ze(y.start)}),e.jsx("span",{className:"rfp-text-[11px] rfp-text-fg-disabled",children:"→"}),e.jsx("span",{className:"rfp-text-[11px] rfp-font-mono rfp-text-fg-muted rfp-tabular-nums",children:ze(y.end)}),e.jsxs("span",{className:"rfp-text-[10px] rfp-font-mono rfp-text-fg-disabled rfp-tabular-nums",children:["#",y.id??x+1]}),y.style&&e.jsx("span",{className:"rfp-text-[9px] rfp-uppercase rfp-tracking-widest rfp-text-fg-tertiary rfp-px-1.5 rfp-py-0.5 rfp-rounded rfp-bg-surface-1 rfp-border rfp-border-line-weak",children:y.style})]}),y.words&&y.words.length>0?e.jsx("div",{className:"rfp-flex rfp-flex-wrap rfp-gap-x-1.5 rfp-gap-y-1 rfp-text-base md:rfp-text-lg rfp-text-fg-primary rfp-leading-relaxed group-hover:rfp-text-fg-primary rfp-transition-colors",children:y.words.map((w,b)=>e.jsxs("span",{className:"rfp-inline-flex rfp-flex-col rfp-items-start",title:ze(w.start),children:[e.jsx("span",{className:"rfp-text-[9px] rfp-text-fg-disabled rfp-font-mono rfp-leading-none rfp-tabular-nums",children:ze(w.start).slice(3,8)}),e.jsx("span",{className:"rfp-leading-snug",children:w.text})]},`w-${b}`))}):e.jsx("p",{className:`rfp-whitespace-pre-wrap rfp-break-words rfp-leading-relaxed group-hover:rfp-text-fg-primary rfp-transition-colors rfp-text-fg-primary ${c?"rfp-text-base md:rfp-text-xl rfp-font-medium":"rfp-text-sm md:rfp-text-base"}`,children:y.text})]},`cue-${x}`))})]})}),e.jsxs("div",{className:"rfp-pointer-events-none rfp-absolute rfp-bottom-3 rfp-right-3 md:rfp-bottom-4 md:rfp-right-4 rfp-flex rfp-items-center rfp-gap-2 rfp-px-2.5 rfp-py-1 rfp-rounded-full rfp-bg-surface-nav rfp-backdrop-blur rfp-border rfp-border-line-weak rfp-text-[10px] rfp-text-fg-tertiary rfp-font-mono rfp-tabular-nums",children:[e.jsxs("span",{children:[d.cues.length," ",n(c?"subtitle.lines":"subtitle.cues")]}),m.length&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"rfp-text-fg-disabled",children:"·"}),e.jsx("span",{children:m.length})]})]})]})},yn=Object.freeze(Object.defineProperty({__proto__:null,SubtitleRenderer:gn},Symbol.toStringTag,{value:"Module"})),wn=({left:r,right:t,initialLeftWidth:n=280,minLeftWidth:a=160,maxLeftWidth:o=640,minRightWidth:i=200,storageKey:p,desktopMedia:l="(min-width: 768px)",className:f=""})=>{const u=s.useRef(null),[d,c]=s.useState(()=>{if(p&&typeof window<"u"){const b=Number(window.localStorage.getItem(p));if(!isNaN(b)&&b>0)return b}return n}),[m,h]=s.useState(!1),[y,x]=s.useState(!1);s.useEffect(()=>{if(typeof window>"u")return;const b=window.matchMedia(l),g=()=>x(b.matches);return g(),b.addEventListener("change",g),()=>b.removeEventListener("change",g)},[l]),s.useEffect(()=>{if(!m)return;const b=S=>{if(!u.current)return;const M=u.current.getBoundingClientRect(),T=S.clientX-M.left,D=M.width-i-6,N=Math.min(o,D),E=Math.max(a,Math.min(N,T));c(E)},g=()=>h(!1);window.addEventListener("mousemove",b),window.addEventListener("mouseup",g);const v=document.body.style.cursor,k=document.body.style.userSelect;return document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",g),document.body.style.cursor=v,document.body.style.userSelect=k}},[m,a,o,i]),s.useEffect(()=>{if(!(!p||m))try{window.localStorage.setItem(p,String(d))}catch{}},[d,p,m]);const w=s.useCallback(b=>{b.preventDefault(),h(!0)},[]);return e.jsxs("div",{ref:u,className:`rfp-w-full rfp-h-full rfp-flex rfp-flex-col md:rfp-flex-row rfp-min-h-0 rfp-min-w-0 ${f}`,children:[e.jsx("div",{className:"rfp-min-h-0 rfp-min-w-0 rfp-flex-shrink-0 rfp-w-full rfp-max-h-60 md:rfp-h-full md:rfp-max-h-none",style:y?{width:`${d}px`}:void 0,children:r}),e.jsx("div",{role:"separator","aria-orientation":"vertical",onMouseDown:w,className:`rfp-hidden md:rfp-block rfp-relative rfp-w-1.5 rfp-flex-shrink-0 rfp-cursor-col-resize rfp-transition-colors ${m?"rfp-bg-surface-toolbar":"rfp-bg-surface-2 hover:rfp-bg-surface-3"}`,children:e.jsx("span",{className:"rfp-absolute rfp-inset-y-0 -rfp-left-1 -rfp-right-1"})}),e.jsx("div",{className:"rfp-flex-1 rfp-min-w-0 rfp-min-h-0 rfp-overflow-hidden",children:t})]})},vn=s.lazy(()=>Promise.resolve().then(()=>gs).then(r=>({default:r.FilePreviewContent}))),jn=r=>{const t=gr({name:r,type:""});return t==="image"?_.FileImage:t==="text"||t==="markdown"||t==="json"||t==="csv"||t==="xml"||t==="subtitle"?r.endsWith(".md")||r.endsWith(".markdown")?_.FileText:_.FileCode:_.File},Mr=({node:r,depth:t,selectedPath:n,expanded:a,onToggle:o,onSelect:i,onHover:p,onLeave:l})=>{var h;const f=a.has(r.path),u=n===r.path,d={paddingLeft:`${t*14+10}px`},c=y=>{const x=y.currentTarget.getBoundingClientRect();p(r.name||"/",x)};if(r.isDir)return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>o(r.path),onMouseEnter:c,onMouseLeave:l,className:"rfp-w-full rfp-flex rfp-items-center rfp-gap-1.5 rfp-py-1.5 rfp-pr-2 rfp-text-left rfp-text-fg-secondary hover:rfp-bg-surface-1 rfp-text-sm",style:d,children:[e.jsx(_.ChevronRight,{className:`rfp-w-3.5 rfp-h-3.5 rfp-flex-shrink-0 rfp-transition-transform ${f?"rfp-rotate-90":""}`}),f?e.jsx(_.FolderOpen,{className:"rfp-w-4 rfp-h-4 rfp-flex-shrink-0 rfp-text-amber-300/80"}):e.jsx(_.Folder,{className:"rfp-w-4 rfp-h-4 rfp-flex-shrink-0 rfp-text-amber-300/80"}),e.jsx("span",{className:"rfp-truncate rfp-flex-1 rfp-min-w-0",children:r.name||"/"})]}),f&&((h=r.children)==null?void 0:h.map(y=>e.jsx(Mr,{node:y,depth:t+1,selectedPath:n,expanded:a,onToggle:o,onSelect:i,onHover:p,onLeave:l},y.path)))]});const m=jn(r.name);return e.jsxs("button",{type:"button",onClick:()=>i(r),onMouseEnter:c,onMouseLeave:l,className:`rfp-w-full rfp-flex rfp-items-center rfp-gap-1.5 rfp-py-1.5 rfp-pr-2 rfp-text-left rfp-text-sm ${u?"rfp-bg-surface-2 rfp-text-fg-primary":"rfp-text-fg-secondary hover:rfp-bg-surface-1"}`,style:d,children:[e.jsx("span",{className:"rfp-w-3.5 rfp-h-3.5 rfp-flex-shrink-0"}),e.jsx(m,{className:"rfp-w-4 rfp-h-4 rfp-flex-shrink-0 rfp-text-fg-tertiary"}),e.jsx("span",{className:"rfp-flex-1 rfp-truncate rfp-min-w-0",children:r.name}),e.jsx("span",{className:"rfp-text-xs rfp-text-fg-disabled rfp-flex-shrink-0 rfp-ml-2",children:yr(r.size)})]})},Nn=({url:r,nestingDepth:t=0,onStatsChange:n})=>{var G;const a=J(),o=se(),[i,p]=s.useState(null),[l,f]=s.useState(null),[u,d]=s.useState(!0),[c,m]=s.useState(null),[h,y]=s.useState(new Set([""])),[x,w]=s.useState(null),[b,g]=s.useState(!1),[v,k]=s.useState(null),[S,M]=s.useState(null),T=s.useRef(n);s.useEffect(()=>{T.current=n},[n]),s.useEffect(()=>{let j=!1;return(async()=>{try{d(!0),m(null);const C=await o(r);if(!C.ok)throw new Error("加载失败");const B=await C.arrayBuffer(),I=await xt(B);if(j)return;const q=bt(I),L=gt(q);p(I),f(L);const z=new Set([""]);if(L.children)for(const $ of L.children)$.isDir&&z.add($.path);y(z)}catch(C){console.error(C),j||m(a("zip.load_failed"))}finally{j||d(!1)}})(),()=>{j=!0}},[r]),s.useEffect(()=>()=>{x!=null&&x.blobUrl&&URL.revokeObjectURL(x.blobUrl)},[x]);const D=s.useMemo(()=>{if(!l)return null;let j=0,R=0,C=0;const B=I=>{var q;I.isDir?(I.path&&R++,(q=I.children)==null||q.forEach(B)):(j++,C+=I.size)};return B(l),{files:j,dirs:R,size:C}},[l]);s.useEffect(()=>{var j;return(j=T.current)==null||j.call(T,D),()=>{var R;(R=T.current)==null||R.call(T,null)}},[D]);const N=s.useCallback(j=>{y(R=>{const C=new Set(R);return C.has(j)?C.delete(j):C.add(j),C})},[]),E=s.useCallback((j,R)=>{M({text:j,x:R.right+8,y:R.top+R.height/2})},[]),F=s.useCallback(()=>{M(null)},[]),H=s.useCallback(async j=>{if(!(!i||j.isDir)){x!=null&&x.blobUrl&&URL.revokeObjectURL(x.blobUrl),g(!0),k(null);try{const R=Ee(j.name),C=await yt(i,j.path,R!=="application/octet-stream"?R:void 0),B=URL.createObjectURL(C);w({path:j.path,name:j.name,size:j.size,blobUrl:B})}catch(R){console.error(R),k("条目读取失败")}finally{g(!1)}}},[i,x]);if(u)return e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})});if(c||!l)return e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:c||a("zip.parse_failed")})})});const A=e.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto",children:(G=l.children)==null?void 0:G.map(j=>e.jsx(Mr,{node:j,depth:0,selectedPath:(x==null?void 0:x.path)??null,expanded:h,onToggle:N,onSelect:H,onHover:E,onLeave:F},j.path))}),Z=e.jsxs("div",{className:"rfp-w-full rfp-h-full rfp-flex rfp-flex-col",children:[!x&&e.jsx("div",{className:"rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center rfp-text-fg-muted rfp-text-sm rfp-p-6",children:"从左侧选择一个文件以预览"}),x&&b&&e.jsx("div",{className:"rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center",children:e.jsx("div",{className:"rfp-w-8 rfp-h-8 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),x&&!b&&v&&e.jsx("div",{className:"rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center rfp-text-fg-secondary",children:v}),x&&!b&&!v&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"rfp-flex-1 rfp-min-h-0 rfp-overflow-hidden rfp-flex rfp-relative rfp-z-0",children:e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center",children:e.jsx("div",{className:"rfp-w-8 rfp-h-8 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}),children:e.jsx(vn,{mode:"embed",files:[{name:x.name,url:x.blobUrl,type:Ee(x.name)}],currentIndex:0,zipNestingDepth:t+1})})})})]});return e.jsxs(e.Fragment,{children:[e.jsx(wn,{left:A,right:Z,initialLeftWidth:280,minLeftWidth:180,maxLeftWidth:560,storageKey:"rfp-zip-split-left"}),S&&typeof document<"u"&&mr.createPortal(e.jsx("div",{className:"rfp-fixed rfp-z-[9999] rfp-pointer-events-none rfp-px-2 rfp-py-1 rfp-bg-[rgba(0,0,0,0.85)] rfp-text-fg-primary rfp-text-xs rfp-rounded rfp-whitespace-nowrap rfp-shadow-lg",style:{left:`${S.x}px`,top:`${S.y}px`,transform:"translateY(-50%)"},children:S.text}),document.body)]})},kn=Object.freeze(Object.defineProperty({__proto__:null,ZipRenderer:Nn},Symbol.toStringTag,{value:"Module"})),Sn=({url:r,fileName:t,wordWrap:n=!0,htmlPreview:a=!1})=>{const o=J(),i=se(),[p,l]=s.useState(""),[f,u]=s.useState(!0),[d,c]=s.useState(null),m=rt(t),{html:h}=Ie(m!=="text"?p:"",m);return s.useEffect(()=>{(async()=>{try{u(!0),c(null);const x=await Me(r,{fetcher:i});l(x)}catch(x){c(o("text.load_failed")),console.error(x)}finally{u(!1)}})()},[r]),f?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-w-12 rfp-h-12 rfp-border-4 rfp-border-line-strong rfp-border-t-spinner-head rfp-rounded-full rfp-animate-spin"})}):d?e.jsx("div",{className:"rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full",children:e.jsx("div",{className:"rfp-text-fg-secondary rfp-text-center",children:e.jsx("p",{className:"rfp-text-lg",children:d})})}):a&&m==="html"?e.jsx("div",{className:"rfp-w-full rfp-h-full rfp-bg-surface-toolbar",children:e.jsx("iframe",{srcDoc:p,sandbox:"allow-same-origin",className:"rfp-w-full rfp-h-full rfp-border-0",title:t})}):e.jsx("div",{className:"rfp-w-full rfp-h-full rfp-overflow-auto rfp-bg-code-bg",children:m==="text"||!h?e.jsx("pre",{className:`rfp-p-6 rfp-text-fg-primary rfp-font-mono rfp-text-sm ${n?"rfp-whitespace-pre-wrap rfp-break-words":"rfp-whitespace-pre"}`,children:p}):e.jsx("div",{className:`rfp-shiki-wrapper with-line-numbers ${n?"":"no-wrap"}`,dangerouslySetInnerHTML:{__html:h}})})},_n=Object.freeze(Object.defineProperty({__proto__:null,TextRenderer:Sn},Symbol.toStringTag,{value:"Module"}));Object.defineProperty(exports,"pdfjs",{enumerable:!0,get:()=>ve.pdfjs});exports.FilePreviewContent=We;exports.FilePreviewEmbed=ws;exports.FilePreviewModal=ys;exports.LocaleProvider=vr;exports.VERSION=vs;exports.configurePdfjs=kr;exports.normalizeFile=xr;exports.normalizeFiles=br;exports.useLocale=Wt;exports.useTranslator=J;
|
|
80
67
|
//# sourceMappingURL=index.cjs.map
|