192 lines
165 KiB
JavaScript
192 lines
165 KiB
JavaScript
|
|
import{j as E,c as Fr,v as Pr,M as $r,r as zr,a as Or}from"./vendor-markdown-C0b4qDwm.js";import{a as Dr,r as H,g as Hr}from"./vendor-react-C6WG4Va-.js";import"./vendor-katex-p018AHG0.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))i(t);new MutationObserver(t=>{for(const n of t)if(n.type==="childList")for(const s of n.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&i(s)}).observe(document,{childList:!0,subtree:!0});function a(t){const n={};return t.integrity&&(n.integrity=t.integrity),t.referrerPolicy&&(n.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?n.credentials="include":t.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(t){if(t.ep)return;t.ep=!0;const n=a(t);fetch(t.href,n)}})();var Jt,It=Dr;Jt=It.createRoot,It.hydrateRoot;const Ft={development:{apiBaseUrl:"https://cloud.texpixel.com:10443/doc_ai/v1",env:"development"},production:{apiBaseUrl:"https://api.texpixel.com/doc_ai/v1",env:"production"}},Br="development",Wr=Ft[Br]||Ft.development,er=Wr.apiBaseUrl,yt="texpixel_token",rt="texpixel_token_expires",bt="texpixel_user_email",ve={getToken(){return localStorage.getItem(yt)},setToken(e,r,a){localStorage.setItem(yt,e),localStorage.setItem(rt,r.toString()),a&&localStorage.setItem(bt,a)},removeToken(){localStorage.removeItem(yt),localStorage.removeItem(rt),localStorage.removeItem(bt)},getEmail(){return localStorage.getItem(bt)},isTokenValid(){const e=this.getToken(),r=localStorage.getItem(rt);if(!e||!r)return!1;const a=parseInt(r,10)*1e3;return Date.now()<a-5*60*1e3},getExpiresAt(){const e=localStorage.getItem(rt);return e?parseInt(e,10):null}};class Oe extends Error{constructor(r,a,i){super(a),this.code=r,this.requestId=i,this.name="ApiError"}}async function nt(e,r={}){const{skipAuth:a=!1,headers:i,...t}=r,n={"Content-Type":"application/json",...i};if(!a){const l=ve.getToken();l&&(n.Authorization=l)}const s=`${er}${e}`;try{const m=await(await fetch(s,{...t,headers:n})).json();if(m.code!==200)throw new Oe(m.code,m.message,m.request_id);return m}catch(l){throw l instanceof Oe?l:new Oe(-1,"网络错误,请检查网络连接")}}const De={get(e,r){return nt(e,{...r,method:"GET"})},post(e,r,a){return nt(e,{...a,method:"POST",body:r?JSON.stringify(r):void 0})},put(e,r,a){return nt(e,{...a,method:"PUT",body:r?JSON.stringify(r):void 0})},delete(e,r){return nt(e,{...r,method:"DELETE"})}};var we=(e=>(e[e.Pending=0]="Pending",e[e.Processing=1]="Processing",e[e.Completed=2]="Completed",e[e.Failed=3]="Failed",e))(we||{});const qr={200:"操作成功",400:"参数错误",401:"未授权,请先登录",403:"无权限访问",404:"资源不存在",405:"状态无效",500:"服务器错误,请稍后重试",501:"系统错误,请稍后重试",1001:"任务未完成",1002:"记录重复",1003:"验证码错误",1004:"该邮箱已注册",1005:"该邮箱未注册",1006:"密码错误"};function xt(e){try{const a=e.replace("Bearer ","").split(".")[1];return JSON.parse(atob(a))}catch{return null}}const Xe={async login(e){const r=await De.post("/user/login",e,{skipAuth:!0});if(!r.data)throw new Oe(-1,"登录失败,请重试");const{token:a,expires_at:i}=r.data;ve.setToken(a,i,e.email);const t=xt(a);if(!t)throw new Oe(-1,"Token 解析失败");return{user:{...t,email:e.email,id:String(t.user_id)},token:a,expiresAt:i}},async register(e){const r=await De.post("/user/register",e,{skipAuth:!0});if(!r.data)throw new Oe(-1,"注册失败,请重试");const{token:a,expires_at:i}=r.data;ve.setToken(a,i,e.email);const t=xt(a);if(!t)throw new Oe(-1,"Token 解析失败");return{user:{...t,email:e.email,id:String(t.user_id)},token:a,expiresAt:i}},logout(){ve.removeToken()},isAuthenticated(){return ve.isTokenValid()},getToken(){return ve.getToken()},restoreSession(){const e=ve.getToken(),r=ve.getExpiresAt(),a=ve.getEmail();if(!e||!r||!ve.isTokenValid())return ve.removeToken(),null;const i=xt(e);return i?{user:{...i,email:a||"",id:String(i.user_id)},token:e,e
|
||
|
|
let scriptImported = false
|
||
|
|
self.addEventListener('message', async (e) => {
|
||
|
|
const { file, id, imageCompressionLibUrl, options } = e.data
|
||
|
|
options.onProgress = (progress) => self.postMessage({ progress, id })
|
||
|
|
try {
|
||
|
|
if (!scriptImported) {
|
||
|
|
// console.log('[worker] importScripts', imageCompressionLibUrl)
|
||
|
|
self.importScripts(imageCompressionLibUrl)
|
||
|
|
scriptImported = true
|
||
|
|
}
|
||
|
|
// console.log('[worker] self', self)
|
||
|
|
const compressedFile = await imageCompression(file, options)
|
||
|
|
self.postMessage({ file: compressedFile, id })
|
||
|
|
} catch (e) {
|
||
|
|
// console.error('[worker] error', e)
|
||
|
|
self.postMessage({ error: e.message + '\\n' + e.stack, id })
|
||
|
|
}
|
||
|
|
})
|
||
|
|
`;let wt;function sn(e,r){return new Promise((a,i)=>{wt||(wt=function(s){const l=[];return l.push(s),URL.createObjectURL(new Blob(l))}(an));const t=new Worker(wt);t.addEventListener("message",function(s){if(r.signal&&r.signal.aborted)t.terminate();else if(s.data.progress===void 0){if(s.data.error)return i(new Error(s.data.error)),void t.terminate();a(s.data.file),t.terminate()}else r.onProgress(s.data.progress)}),t.addEventListener("error",i),r.signal&&r.signal.addEventListener("abort",()=>{i(r.signal.reason),t.terminate()}),t.postMessage({file:e,imageCompressionLibUrl:r.libURL,options:{...r,onProgress:void 0,signal:void 0}})})}function he(e,r){return new Promise(function(a,i){let t,n,s,l,m,p;if(t={...r},s=0,{onProgress:l}=t,t.maxSizeMB=t.maxSizeMB||Number.POSITIVE_INFINITY,m=typeof t.useWebWorker!="boolean"||t.useWebWorker,delete t.useWebWorker,t.onProgress=f=>{s=f,typeof l=="function"&&l(s)},!(e instanceof Blob||e instanceof nn))return i(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(e.type))return i(new Error("The file given is not an image"));if(p=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!m||typeof Worker!="function"||p)return Pt(e,t).then((function(f){try{return n=f,c.call(this)}catch(y){return i(y)}}).bind(this),i);var o=(function(){try{return c.call(this)}catch(f){return i(f)}}).bind(this),u=function(f){try{return Pt(e,t).then(function(y){try{return n=y,o()}catch(C){return i(C)}},i)}catch(y){return i(y)}};try{return t.libURL=t.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",sn(e,t).then(function(f){try{return n=f,o()}catch{return u()}},u)}catch{u()}function c(){try{n.name=e.name,n.lastModified=e.lastModified}catch{}try{t.preserveExif&&e.type==="image/jpeg"&&(!t.fileType||t.fileType&&t.fileType===e.type)&&(n=nr(e,n))}catch{}return a(n)}})}he.getDataUrlFromFile=or,he.getFilefromDataUrl=_t,he.loadImage=lr,he.drawImageInCanvas=ur,he.drawFileInCanvas=ct,he.canvasToFile=ut,he.getExifOrientation=dr,he.handleMaxWidthOrHeight=hr,he.followExifOrientation=fr,he.cleanupCanvasMemory=Ce,he.isAutoOrientationInBrowser=Ge,he.approximateBelowMaximumCanvasSizeOfBrowser=cr,he.copyExifWithoutOrientation=nr,he.getBrowserName=He,he.version="2.0.2";var mr={exports:{}};(function(e,r){(function(a){e.exports=a()})(function(a){var i=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function t(b,w){var g=b[0],h=b[1],S=b[2],d=b[3];g+=(h&S|~h&d)+w[0]-680876936|0,g=(g<<7|g>>>25)+h|0,d+=(g&h|~g&S)+w[1]-389564586|0,d=(d<<12|d>>>20)+g|0,S+=(d&g|~d&h)+w[2]+606105819|0,S=(S<<17|S>>>15)+d|0,h+=(S&d|~S&g)+w[3]-1044525330|0,h=(h<<22|h>>>10)+S|0,g+=(h&S|~h&d)+w[4]-176418897|0,g=(g<<7|g>>>25)+h|0,d+=(g&h|~g&S)+w[5]+1200080426|0,d=(d<<12|d>>>20)+g|0,S+=(d&g|~d&h)+w[6]-1473231341|0,S=(S<<17|S>>>15)+d|0,h+=(S&d|~S&g)+w[7]-45705983|0,h=(h<<22|h>>>10)+S|0,g+=(h&S|~h&d)+w[8]+1770035416|0,g=(g<<7|g>>>25)+h|0,d+=(g&h|~g&S)+w[9]-1958414417|0,d=(d<<12|d>>>20)+g|0,S+=(d&g|~d&h)+w[10]-42063|0,S=(S<<17|S>>>15)+d|0,h+=(S&d|~S&g)+w[11]-1990404162|0,h=(h<<22|h>>>10)+S|0,g+=(h&S|~h&d)+w[12]+1804603682|0,g=(g<<7|g>>>25)+h|0,d+=(g&h|~g&S)+w[13]-40341101|0,d=(d<<12|d>>>20)+g|0,S+=(d&g|~d&h)+w[14]-1502002290|0,S=(S<<17|S>>>15)+d|0,h+=(S&d|~S&g)+w[15]+1236535329|0,h=(h<<22|h>>>10)+S|0,g+=(h&d|S&~d)+w[1]-165796510|0,g=(g<<5|g>>>27)+h|0,d+=(g&S|h&~S)+w[6]-1069501632|0,d=(d<<9|d>>>23)+g|0,S+=(d&h|g&~h)+w[11]+643717713|0,S=(S<<14|S>>>18)+d|0,h+=(S&g|d&~g)+w[0]-373897302|0,h=(h<<20|h>>>12)+S|0,g+=(h&d|S&~d)+w[5]-701558691|0,g=(g<<5|g>>>27)+h|0,d+=(g&S|h&~S)+w[10]+38016083|0,d=(d<<9|d>>>23)+g|0,S+=(d&h|g&~h)+w[15]-660478335|0,S=(S<<14|S>>>18)+d|0,h+=(S&g|d&~g)+w[4]-405537848|0,h=(h<<20|h>>>12)+S|0,g+=(h&d|S&~d)+w[9]+568446438|0,g=(g<<5|g>>>27)+h|0,d+=(g&S|h&~S)+w[14]-1019803690|0,d=(d<<9|d>>>23)+g|0,S+=(d&h|g&~h)+w[3]-187363961|0,S=(S<<14|S>>>18)+d|0,h+=(S&g|d&~g)+w[8]+1163531501|0,h=(h<<20|h>>>12)+S|0,g+=(h&d|S&~d)+w[13]-1444681467|0,g=(g<<5|g>>>27)+h|0,d+=(g&S|h&~S)+w[2]-51403784|0,d=(d<<9|d>>>23)+g|0,S+=(d&h|g&~h)+w[7]+1735328473|0,S=(S<<14|S>>>18)+d
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/var cn={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const un=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),Y=(e,r)=>{const a=H.forwardRef(({color:i="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:l="",children:m,...p},o)=>H.createElement("svg",{ref:o,...cn,width:t,height:t,stroke:i,strokeWidth:s?Number(n)*24/Number(t):n,className:["lucide",`lucide-${un(e)}`,l].join(" "),...p},[...r.map(([u,c])=>H.createElement(u,c)),...Array.isArray(m)?m:[m]]));return a.displayName=`${e}`,a};/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const at=Y("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const $t=Y("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Nt=Y("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Tt=Y("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const gr=Y("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const dn=Y("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const pr=Y("Code2",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const hn=Y("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const yr=Y("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const st=Y("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const br=Y("FileUp",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const zt=Y("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const fn=Y("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const mn=Y("HelpCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const gn=Y("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const pn=Y("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const yn=Y("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const xr=Y("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Ot=Y("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const bn=Y("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const xn=Y("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const wn=Y("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const vn=Y("MinusCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const wr=Y("MousePointerClick",[["path",{d:"m9 9 5 12 1.8-5.2L21 14Z",key:"1b76lo"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const En=Y("PlusCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const At=Y("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const An=Y("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Ze=Y("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Sn({onClose:e}){const{signIn:r,signUp:a}=Ct(),{t:i}=_e(),[t,n]=H.useState(!1),[s,l]=H.useState(""),[m,p]=H.useState(""),[o,u]=H.useState(!1),[c,f]=H.useState(""),y=async C=>{C.preventDefault(),f(""),u(!0);try{const{error:k}=t?await a(s,m):await r(s,m);k?f(k.message):e()}catch{f("发生错误,请重试")}finally{u(!1)}};return E.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:E.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-md w-full p-6",children:[E.jsxs("div",{className:"flex justify-between items-center mb-6",children:[E.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:t?i.auth.signUpTitle:i.auth.signInTitle}),E.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:E.jsx(Ze,{size:20})})]}),E.jsxs("form",{onSubmit:y,className:"space-y-4",children:[E.jsxs("div",{children:[E.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:i.auth.email}),E.jsx("input",{type:"email",value:s,onChange:C=>l(C.target.value),className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"your@email.com",required:!0})]}),E.jsxs("div",{children:[E.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:i.auth.password}),E.jsx("input",{type:"password",value:m,onChange:C=>p(C.target.value),className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"••••••••",required:!0,minLength:6})]}),c&&E.jsxs("div",{className:"p-3 bg-red-100 border border-red-400 text-red-700 rounded-lg text-sm font-medium animate-pulse",children:[i.auth.error,": ",c]}),E.jsx("button",{type:"submit",disabled:o,className:"w-full py-3 px-4 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors font-medium disabled:opacity-80 disabled:cursor-wait",children:t?i.auth.signUp:i.auth.signIn})]}),E.jsx("div",{className:"mt-4 text-center",children:E.jsx("button",{onClick:()=>n(!t),className:"text-sm text-blue-600 hover:text-blue-700",children:t?i.auth.hasAccount:i.auth.noAccount})})]})})}function jn({files:e,selectedFileId:r,onFileSelect:a,onUploadClick:i,isCollapsed:t,onToggleCollapse:n,onUploadFiles:s,hasMore:l,loadingMore:m,onLoadMore:p}){const{user:o,signOut:u}=Ct(),{t:c}=_e(),[f,y]=H.useState(!1),[C,k]=H.useState(!1),b=H.useRef(null),w=H.useRef(null),g=H.useCallback(()=>{if(!w.current||m||!l)return;const{scrollTop:x,scrollHeight:A,clientHeight:_}=w.current;A-x-_<50&&p()},[m,l,p]);H.useEffect(()=>{if(!l||m||!o||e.length===0)return;const A=setTimeout(()=>{requestAnimationFrame(()=>{if(!w.current)return;const{scrollHeight:_,clientHeight:R}=w.current;_<=R&&l&&!m&&p()})},100);return()=>clearTimeout(A)},[e.length,l,m,p,o]);const h=x=>{x.preventDefault(),k(!0)},S=x=>{x.preventDefault(),k(!1)},d=x=>{x.preventDefault(),k(!1);const _=Array.from(x.dataTransfer.files).filter(R=>R.type.startsWith("image/")||R.type==="application/pdf");_.length>0&&s(_)},I=x=>{x.target.files&&x.target.files.length>0&&s(Array.from(x.target.files)),b.current&&(b.current.value="")};return t?E.jsxs("div",{className:"h-full flex flex-col items-center py-4 bg-gray-50/50",children:[E.jsx("button",{onClick:n,className:"p-2 mb-6 text-gray-500 hover:text-gray-900 hover:bg-gray-200 rounded-md transition-colors",children:E.jsx(Tt,{size:20})}),E.jsx("button",{onClick:i,className:"p-3 rounded-xl bg-blue-600 text-white hover:bg-blue-700 shadow-lg shadow-blue-600/20 transition-all mb-6",title:c.common.upload,children:E.jsx(At,{size:20})}),E.jsx("div",{className:"flex-1 w-full flex flex-col items-center gap-4",children:E.jsx("button",{className:"p-2 text-gray-400 hover:text-gray-900 transition-colors",title:c.common.history,children:E.jsx(gn,{size:20})})}),E.jsx("button",{onClick:()=>!o&&y(!0),className:"p-3 rounded-lg text-gray-600 hover:bg-gray-200 transition-colors
|
||
|
|
border-2 border-dashed rounded-xl p-6 text-center cursor-pointer transition-all duration-200 group
|
||
|
|
${C?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-blue-400 hover:bg-gray-50"}
|
||
|
|
`,children:[E.jsx("input",{type:"file",ref:b,className:"hidden",onChange:I,accept:"image/*",multiple:!0}),E.jsx("div",{className:"w-12 h-12 bg-gray-100 text-gray-600 rounded-full flex items-center justify-center mx-auto mb-3 group-hover:scale-110 transition-transform",children:E.jsx(At,{size:24})}),E.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.sidebar.uploadInstruction}),E.jsxs("div",{className:"flex items-center justify-center gap-4 text-xs text-gray-400",children:[E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(wr,{className:"w-3.5 h-3.5"}),E.jsx("span",{children:c.common.click})]}),E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(br,{className:"w-3.5 h-3.5"}),E.jsx("span",{children:c.common.drop})]}),E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(gr,{className:"w-3.5 h-3.5"}),E.jsx("span",{children:c.common.paste})]})]})]})})]}),E.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col px-4",id:"sidebar-history",children:[E.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3 px-2",children:[E.jsx(dn,{size:14}),E.jsx("span",{children:c.sidebar.historyHeader})]}),E.jsx("div",{ref:w,onScroll:g,className:"flex-1 overflow-y-auto space-y-1 pr-2 -mr-2 custom-scrollbar",children:o?e.length===0?E.jsxs("div",{className:"text-center py-12 text-gray-400 text-sm",children:[E.jsx("div",{className:"mb-2 opacity-50",children:E.jsx(st,{size:40,className:"mx-auto"})}),c.sidebar.noHistory]}):E.jsxs(E.Fragment,{children:[e.map(x=>E.jsx("button",{onClick:()=>a(x.id),className:`w-full p-3 rounded-lg text-left transition-all border group relative ${r===x.id?"bg-blue-50 border-blue-200 shadow-sm":"bg-white border-transparent hover:bg-gray-50 hover:border-gray-100"}`,children:E.jsxs("div",{className:"flex items-start gap-3",children:[E.jsx("div",{className:`p-2 rounded-lg ${r===x.id?"bg-blue-100 text-blue-600":"bg-gray-100 text-gray-500 group-hover:bg-gray-200"}`,children:E.jsx(st,{size:18})}),E.jsxs("div",{className:"flex-1 min-w-0",children:[E.jsx("p",{className:`text-sm font-medium truncate ${r===x.id?"text-blue-900":"text-gray-700"}`,children:x.filename}),E.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[E.jsx("span",{className:"text-xs text-gray-400",children:new Date(x.created_at).toLocaleDateString()}),E.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${x.status==="completed"?"bg-green-500":x.status==="processing"?"bg-yellow-500":"bg-red-500"}`})]})]})]})},x.id)),m&&E.jsxs("div",{className:"flex items-center justify-center py-3 text-gray-400",children:[E.jsx(xr,{size:18,className:"animate-spin"}),E.jsx("span",{className:"ml-2 text-xs",children:c.common.loading})]}),!l&&e.length>0&&E.jsx("div",{className:"text-center py-3 text-xs text-gray-400",children:c.sidebar.noMore})]}):E.jsxs("div",{className:"text-center py-12 text-gray-400 text-sm",children:[E.jsx("div",{className:"mb-2 opacity-50",children:E.jsx(st,{size:40,className:"mx-auto"})}),c.sidebar.pleaseLogin]})})]}),E.jsx("div",{className:"p-4 border-t border-gray-100 bg-gray-50/30",children:o?E.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-white border border-gray-100 shadow-sm",children:[E.jsx("div",{className:"w-8 h-8 bg-gray-900 rounded-full flex items-center justify-center flex-shrink-0",children:E.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:E.jsx("path",{d:"M12 12C14.21 12 16 10.21 16 8C16 5.79 14.21 4 12 4C9.79 4 8 5.79 8 8C8 10.21 9.79 12 12 12ZM12 14C9.33 14 4 15.34 4 18V20H20V18C20 15.34 14.67 14 12 14Z",fill:"white"})})}),E.jsx("div",{className:"flex-1 min-w-0",children:E.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",children:o.email})}),E.jsx("button",{onClick:()=>u(),className:"p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-md transition-colors",title:c.common.logout,children:E.jsx(bn,{size:16})})]}):E.jsxs("button",{onClick:()=>y(!0),className:"w-full py-2.5 px-4 bg-gray-900 text-white roun
|
||
|
|
<m:oMath xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
||
|
|
${e.replace(/<m:oMath[^>]*>/g,"").replace(/<\/m:oMath>/g,"")}
|
||
|
|
</m:oMath>`}function Pi(e,r){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const a=document.implementation.createHTMLDocument(),i=a.createElement("base"),t=a.createElement("a");return a.head.appendChild(i),a.body.appendChild(t),r&&(i.href=r),t.href=e,t.href}const $i=(()=>{let e=0;const r=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${r()}${e}`)})();function Ue(e){const r=[];for(let a=0,i=e.length;a<i;a++)r.push(e[a]);return r}let We=null;function Ar(e={}){return We||(e.includeStyleProperties?(We=e.includeStyleProperties,We):(We=Ue(window.getComputedStyle(document.documentElement)),We))}function dt(e,r){const i=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(r);return i?parseFloat(i.replace("px","")):0}function zi(e){const r=dt(e,"border-left-width"),a=dt(e,"border-right-width");return e.clientWidth+r+a}function Oi(e){const r=dt(e,"border-top-width"),a=dt(e,"border-bottom-width");return e.clientHeight+r+a}function Sr(e,r={}){const a=r.width||zi(e),i=r.height||Oi(e);return{width:a,height:i}}function Di(){let e,r;try{r=process}catch{}const a=r&&r.env?r.env.devicePixelRatio:null;return a&&(e=parseInt(a,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const xe=16384;function Hi(e){(e.width>xe||e.height>xe)&&(e.width>xe&&e.height>xe?e.width>e.height?(e.height*=xe/e.width,e.width=xe):(e.width*=xe/e.height,e.height=xe):e.width>xe?(e.height*=xe/e.width,e.width=xe):(e.width*=xe/e.height,e.height=xe))}function Bi(e,r={}){return e.toBlob?new Promise(a=>{e.toBlob(a,r.type?r.type:"image/png",r.quality?r.quality:1)}):new Promise(a=>{const i=window.atob(e.toDataURL(r.type?r.type:void 0,r.quality?r.quality:void 0).split(",")[1]),t=i.length,n=new Uint8Array(t);for(let s=0;s<t;s+=1)n[s]=i.charCodeAt(s);a(new Blob([n],{type:r.type?r.type:"image/png"}))})}function ht(e){return new Promise((r,a)=>{const i=new Image;i.onload=()=>{i.decode().then(()=>{requestAnimationFrame(()=>r(i))})},i.onerror=a,i.crossOrigin="anonymous",i.decoding="async",i.src=e})}async function Wi(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(r=>`data:image/svg+xml;charset=utf-8,${r}`)}async function qi(e,r,a){const i="http://www.w3.org/2000/svg",t=document.createElementNS(i,"svg"),n=document.createElementNS(i,"foreignObject");return t.setAttribute("width",`${r}`),t.setAttribute("height",`${a}`),t.setAttribute("viewBox",`0 0 ${r} ${a}`),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("externalResourcesRequired","true"),t.appendChild(n),n.appendChild(e),Wi(t)}const pe=(e,r)=>{if(e instanceof r)return!0;const a=Object.getPrototypeOf(e);return a===null?!1:a.constructor.name===r.name||pe(a,r)};function Gi(e){const r=e.getPropertyValue("content");return`${e.cssText} content: '${r.replace(/'|"/g,"")}';`}function Vi(e,r){return Ar(r).map(a=>{const i=e.getPropertyValue(a),t=e.getPropertyPriority(a);return`${a}: ${i}${t?" !important":""};`}).join(" ")}function Qi(e,r,a,i){const t=`.${e}:${r}`,n=a.cssText?Gi(a):Vi(a,i);return document.createTextNode(`${t}{${n}}`)}function qt(e,r,a,i){const t=window.getComputedStyle(e,a),n=t.getPropertyValue("content");if(n===""||n==="none")return;const s=$i();try{r.className=`${r.className} ${s}`}catch{return}const l=document.createElement("style");l.appendChild(Qi(s,a,t,i)),r.appendChild(l)}function Xi(e,r,a){qt(e,r,":before",a),qt(e,r,":after",a)}const Gt="application/font-woff",Vt="image/jpeg",Zi={woff:Gt,woff2:Gt,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Vt,jpeg:Vt,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Ki(e){const r=/\.([^./]*?)$/g.exec(e);return r?r[1]:""}function Rt(e){const r=Ki(e).toLowerCase();return Zi[r]||""}function Yi(e){return e.split(/,/)[1]}function jt(e){return e.search(/^(data:)/)!==-1}function Ji(e,r){return`data:${r};base64,${e}`}async function jr(e,r,a){co
|
||
|
|
`)}async function ka(e,r){const a=r.fontEmbedCSS!=null?r.fontEmbedCSS:r.skipFonts?null:await Ca(e,r);if(a){const i=document.createElement("style"),t=document.createTextNode(a);i.appendChild(t),e.firstChild?e.insertBefore(i,e.firstChild):e.appendChild(i)}}async function Mr(e,r={}){const{width:a,height:i}=Sr(e,r),t=await mt(e,r,!0);return await ka(t,r),await Tr(t,r),va(t,r),await qi(t,a,i)}async function Lr(e,r={}){const{width:a,height:i}=Sr(e,r),t=await Mr(e,r),n=await ht(t),s=document.createElement("canvas"),l=s.getContext("2d"),m=r.pixelRatio||Di(),p=r.canvasWidth||a,o=r.canvasHeight||i;return s.width=p*m,s.height=o*m,r.skipAutoScale||Hi(s),s.style.width=`${p}`,s.style.height=`${o}`,r.backgroundColor&&(l.fillStyle=r.backgroundColor,l.fillRect(0,0,s.width,s.height)),l.drawImage(n,0,0,s.width,s.height),s}async function _a(e,r={}){return(await Lr(e,r)).toDataURL()}async function Na(e,r={}){const a=await Lr(e,r);return await Bi(a)}const Ta={backgroundColor:"#ffffff",padding:20,fontSize:20,scale:2,format:"png"};async function Ra(){const e=["KaTeX_Main","KaTeX_Math","KaTeX_Size1","KaTeX_Size2","KaTeX_Size3","KaTeX_Size4"];await document.fonts.ready;const r=()=>e.some(i=>{try{return document.fonts.check(`16px ${i}`)}catch{return!1}}),a=20;for(let i=0;i<a;i++){if(r())return;await new Promise(t=>setTimeout(t,100))}}async function Ma(e,r={}){const a=document.getElementById(e);if(!a)throw new Error(`Element with ID "${e}" not found`);const i={...Ta,...r};await Ra(),await new Promise(s=>setTimeout(s,100));const t={backgroundColor:i.backgroundColor,pixelRatio:i.scale,cacheBust:!0,width:a.scrollWidth+i.padding*2,height:a.scrollHeight+i.padding*2,style:{padding:`${i.padding}px`,transform:"none",overflow:"visible",visibility:"visible",display:"block",height:"auto",maxHeight:"none"},skipFonts:!1};let n;try{switch(i.format){case"svg":n=await Mr(a,t);break;case"blob":n=await Na(a,t);break;case"png":default:n=await _a(a,t);break}return n}catch(s){throw console.error("Element image generation failed:",s),s}}async function La(e){let r;typeof e=="string"?r=await(await fetch(e)).blob():r=e,await navigator.clipboard.write([new ClipboardItem({[r.type]:r})])}const Ua=(e,r,a)=>{try{const i={task_no:e,event_name:"export_selected_event",properties:{option:a,selected:r},meta_data:{task_no:e},device_info:{ip:"","use-agent":navigator.userAgent,browser:Ia()}};De.post("/analytics/track",i).catch(t=>{console.debug("Analytics tracking failed:",t)})}catch(i){console.debug("Analytics error:",i)}};function Ia(){const e=navigator.userAgent;return e.match(/chrome|chromium|crios/i)?"Chrome":e.match(/firefox|fxios/i)?"Firefox":e.match(/safari/i)?"Safari":e.match(/opr\//i)?"Opera":e.match(/edg/i)?"Edge":"Unknown"}const Fa=e=>{try{const a=new DOMParser().parseFromString(e,"application/xml");if(a.getElementsByTagName("parsererror").length>0)return null;const t=document.implementation.createDocument("http://www.w3.org/1998/Math/MathML","mml:math",null),n=t.documentElement,s=a.documentElement.getAttribute("display");s&&n.setAttribute("display",s);const l=(o,u)=>{if(o.nodeType===Node.ELEMENT_NODE){const c=o,f=t.createElementNS("http://www.w3.org/1998/Math/MathML","mml:"+c.localName);for(let y=0;y<c.attributes.length;y++){const C=c.attributes[y];C.name.startsWith("xmlns")||f.setAttributeNS(C.namespaceURI,C.name,C.value)}Array.from(c.childNodes).forEach(y=>{l(y,f)}),u.appendChild(f)}else o.nodeType===Node.TEXT_NODE&&u.appendChild(t.createTextNode(o.nodeValue||""))};Array.from(a.documentElement.childNodes).forEach(o=>{l(o,n)});let p=new XMLSerializer().serializeToString(t);return p=p.replace(/ xmlns(:mml)?="[^"]*"/g,""),p=p.replace(/<mml:math>/,'<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML">'),p}catch(r){return console.error("Failed to process MathML:",r),null}};function Pa({isOpen:e,onClose:r,result:a}){const{t:i}=_e(),[t,n]=H.useState(null),[s,l]=H.useState(null);if(!a)return null;const m=[{id:"markdown",label:"Markdown",category:"Code",getContent:f=>f.markdown_content},{id:"latex_inline",label:"LaTeX (Inline)",category:"Code",getContent:f=>f.latex_content?`
|
||
|
|
absolute top-0 right-0 bottom-0 w-80 bg-white shadow-2xl z-50 transform transition-transform duration-300 ease-in-out border-l border-gray-100 flex flex-col
|
||
|
|
${e?"translate-x-0":"translate-x-full"}
|
||
|
|
`,children:[E.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-gray-100 shrink-0",children:[E.jsx("h2",{className:"text-lg font-bold text-gray-900",children:i.export.title}),E.jsx("button",{onClick:r,className:"p-2 hover:bg-gray-100 rounded-full transition-colors",children:E.jsx(Ze,{size:20,className:"text-gray-500"})})]}),E.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-8",children:c.map(f=>E.jsxs("div",{className:"space-y-3",children:[E.jsxs("div",{className:"flex items-center gap-2 text-gray-400 px-1",children:[E.jsx(f.icon,{size:16}),E.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",children:f.label})]}),E.jsx("div",{className:"space-y-2",children:m.filter(y=>y.category===f.id).map(y=>E.jsxs("button",{onClick:()=>u(y),className:"w-full flex items-center justify-between p-3 bg-gray-50 hover:bg-blue-50 hover:text-blue-600 border border-transparent hover:border-blue-200 rounded-lg group transition-all text-left",children:[E.jsx("span",{className:"text-sm font-medium text-gray-700 group-hover:text-blue-700",children:y.label}),E.jsx("div",{className:"text-gray-400 group-hover:text-blue-600",children:s===y.id?E.jsx(xr,{size:16,className:"animate-spin text-blue-500"}):t===y.id?E.jsx(at,{size:16,className:"text-green-500"}):y.isDownload?E.jsx(yr,{size:16}):E.jsx(hn,{size:16,className:"opacity-0 group-hover:opacity-100 transition-opacity"})})]},y.id))})]},f.id))})]})]})}function $a(e){if(!e)return"";let r=e;return r=r.replace(/\$\$\s*\\\[/g,"$$$$"),r=r.replace(/\\\]\s*\$\$/g,"$$$$"),r=r.replace(new RegExp("(?<!\\$)\\\\\\[(?!\\$)","g"),"$$$$"),r=r.replace(new RegExp("(?<!\\$)\\\\\\](?!\\$)","g"),"$$$$"),r=r.replace(/\$\$([^\n$])/g,`$$$$
|
||
|
|
$1`),r=r.replace(/([^\n$])\$\$/g,`$1
|
||
|
|
$$$$`),r=r.replace(/\\left\s+\\/g,"\\left\\"),r=r.replace(/\\left\s+\{/g,"\\left\\{"),r=r.replace(/\\left\s+\[/g,"\\left["),r=r.replace(/\\left\s+\(/g,"\\left("),r=r.replace(/\\right\s+\\/g,"\\right\\"),r=r.replace(/\\right\s+\}/g,"\\right\\}"),r=r.replace(/\\right\s+\]/g,"\\right]"),r=r.replace(/\\right\s+\)/g,"\\right)"),r=r.replace(/\\left\(([^)]*?)\\right\.\s*(\\text\{[^}]*\})\s*\\right\)/g,"($1\\right. $2)"),r}function za({result:e,fileStatus:r}){const{t:a}=_e(),[i,t]=H.useState(!1);return e?E.jsxs("div",{className:"flex flex-col h-full bg-white relative overflow-hidden",id:"result-panel-content",children:[E.jsxs("div",{className:"h-16 px-6 border-b border-gray-200 flex items-center justify-between bg-white shrink-0 z-10",children:[E.jsx("div",{className:"flex items-center gap-4",children:E.jsx("h2",{className:"text-lg font-bold text-gray-900",children:a.resultPanel.markdown})}),E.jsxs("button",{id:"export-button",onClick:()=>t(!0),className:`px-4 py-2 bg-gray-900 text-white text-sm font-medium rounded-lg hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-sm ${i?"opacity-0 pointer-events-none":""}`,children:[E.jsx(yr,{size:16}),a.common.export]})]}),E.jsx("div",{className:"flex-1 overflow-auto p-8 custom-scrollbar flex justify-center",children:E.jsx("div",{id:"markdown-preview-content",className:"prose prose-blue max-w-3xl w-full prose-headings:font-bold prose-h1:text-2xl prose-h2:text-xl prose-p:leading-relaxed prose-pre:bg-gray-50 prose-pre:border prose-pre:border-gray-100 [&_.katex-display]:text-center bg-white p-4",children:E.jsx($r,{remarkPlugins:[zr,In],rehypePlugins:[[Or,{throwOnError:!1,errorColor:"#cc0000",strict:!1}]],children:$a(e.markdown_content||"")})})}),E.jsx(Pa,{isOpen:i,onClose:()=>t(!1),result:e})]}):r==="processing"||r==="pending"?E.jsxs("div",{className:"h-full flex flex-col items-center justify-center bg-white text-center p-8",children:[E.jsx("div",{className:"w-16 h-16 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mb-6"}),E.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:r==="pending"?a.resultPanel.waitingQueue:a.resultPanel.analyzing}),E.jsx("p",{className:"text-gray-500 max-w-sm",children:r==="pending"?a.resultPanel.queueSubtitle:a.resultPanel.processingSubtitle})]}):E.jsxs("div",{className:"h-full flex flex-col items-center justify-center bg-white text-center p-8",id:"result-empty-state",children:[E.jsx("div",{className:"w-32 h-32 bg-gray-100 rounded-full flex items-center justify-center mb-6 shadow-inner",children:E.jsx(pr,{size:48,className:"text-gray-900"})}),E.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:a.resultPanel.waitingTitle}),E.jsx("p",{className:"text-gray-500 max-w-sm",children:a.resultPanel.waitingSubtitle})]})}function Oa({onClose:e,onUpload:r}){const{t:a}=_e(),[i,t]=H.useState(!1),n=H.useRef(null);H.useEffect(()=>{const p=o=>{var f;const u=(f=o.clipboardData)==null?void 0:f.items;if(!u)return;const c=[];for(let y=0;y<u.length;y++)if(u[y].type.startsWith("image/")||u[y].type==="application/pdf"){const C=u[y].getAsFile();C&&c.push(C)}c.length>0&&(r(c),e())};return document.addEventListener("paste",p),()=>document.removeEventListener("paste",p)},[r,e]);const s=H.useCallback(p=>{p.preventDefault(),p.stopPropagation(),p.type==="dragenter"||p.type==="dragover"?t(!0):p.type==="dragleave"&&t(!1)},[]),l=H.useCallback(p=>{p.preventDefault(),p.stopPropagation(),t(!1);const o=Array.from(p.dataTransfer.files).filter(u=>u.type.startsWith("image/")||u.type==="application/pdf");o.length>0&&(r(o),e())},[r,e]),m=p=>{if(p.target.files){const o=Array.from(p.target.files).filter(u=>u.type.startsWith("image/")||u.type==="application/pdf");o.length>0&&(r(o),e())}};return E.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:E.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-2xl w-full p-6",children:[E.jsxs("div",{className:"flex justify-between items-center mb-6",children:[E.jsx("h2",{className:"text-2xl font-bold text-gray-900",children
|
||
|
|
0% 0%, 0% 100%,
|
||
|
|
${n.left}px 100%,
|
||
|
|
${n.left}px ${n.top}px,
|
||
|
|
${n.left+n.width}px ${n.top}px,
|
||
|
|
${n.left+n.width}px ${n.top+n.height}px,
|
||
|
|
${n.left}px ${n.top+n.height}px,
|
||
|
|
${n.left}px 100%,
|
||
|
|
100% 100%, 100% 0%
|
||
|
|
)`:"none"}}),E.jsx("div",{className:"absolute border-2 border-blue-500 rounded-xl transition-all duration-300 shadow-[0_0_0_9999px_rgba(0,0,0,0.5)]",style:n}),E.jsxs("div",{className:"absolute pointer-events-auto bg-white rounded-xl shadow-2xl p-6 w-80 transition-all duration-300 animate-in fade-in zoom-in-95",style:n.top!==void 0?{top:l[i].position==="bottom"?n.top+n.height+16:l[i].position==="top"?n.top-200:n.top,left:l[i].position==="right"?n.left+n.width+16:l[i].position==="left"?n.left-336:n.left}:{top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:[E.jsx("button",{onClick:r,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600",children:E.jsx(Ze,{size:18})}),E.jsxs("div",{className:"mb-4",children:[E.jsxs("span",{className:"text-xs font-bold text-blue-600 uppercase tracking-wider",children:["Step ",i+1," of ",l.length]}),E.jsx("h3",{className:"text-lg font-bold text-gray-900 mt-1",children:l[i].title}),E.jsx("p",{className:"text-sm text-gray-600 mt-2 leading-relaxed",children:l[i].content})]}),E.jsxs("div",{className:"flex items-center justify-between mt-6",children:[E.jsxs("button",{onClick:o,disabled:i===0,className:`flex items-center gap-1 text-sm font-medium ${i===0?"text-gray-300 cursor-not-allowed":"text-gray-600 hover:text-gray-900"}`,children:[E.jsx(Nt,{size:16}),a.guide.prev]}),E.jsxs("button",{onClick:p,className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors flex items-center gap-1",children:[i===l.length-1?a.guide.finish:a.guide.next,i<l.length-1&&E.jsx(Tt,{size:16})]})]})]})]})}const Yt=6;function Ha(){const{user:e,initializing:r}=Ct(),{t:a}=_e(),[i,t]=H.useState([]),[n,s]=H.useState(null),[l,m]=H.useState(null),[p,o]=H.useState(!1),[u,c]=H.useState(!1),[f,y]=H.useState(!1),[C,k]=H.useState(1),[b,w]=H.useState(!1),[g,h]=H.useState(!1),[S,d]=H.useState(320),[I,x]=H.useState(!1),[A,_]=H.useState(!1),R=H.useRef(null),T=H.useRef({}),M=H.useRef(null),N=H.useRef({}),U=H.useRef(!1),j=i.find(O=>O.id===n)||null;H.useEffect(()=>{const O=()=>c(!0);return window.addEventListener("start-user-guide",O),localStorage.getItem("hasSeenGuide")||(setTimeout(()=>c(!0),1500),localStorage.setItem("hasSeenGuide","true")),()=>window.removeEventListener("start-user-guide",O)},[]),H.useEffect(()=>{!r&&e&&!U.current&&(U.current=!0,D()),e||(U.current=!1,t([]),s(null),k(1),w(!1))},[r,e]),H.useEffect(()=>{M.current=n,n?z(n):m(null)},[n]),H.useEffect(()=>()=>{Object.values(T.current).forEach(clearInterval),T.current={}},[]),H.useEffect(()=>{const O=B=>{var Q;if(p)return;const G=(Q=B.clipboardData)==null?void 0:Q.items;if(!G)return;const Z=[];for(let X=0;X<G.length;X++)if(G[X].type.startsWith("image/")||G[X].type==="application/pdf"){const K=G[X].getAsFile();K&&Z.push(K)}Z.length>0&&V(Z)};return document.addEventListener("paste",O),()=>document.removeEventListener("paste",O)},[e,p]);const v=H.useCallback(O=>{O.preventDefault(),x(!0)},[]),P=H.useCallback(()=>{x(!1)},[]),L=H.useCallback(O=>{if(I){const B=O.clientX;B>=280&&B<=400&&d(B)}},[I]);H.useEffect(()=>(window.addEventListener("mousemove",L),window.addEventListener("mouseup",P),()=>{window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",P)}),[L,P]);const $=O=>{const B={[we.Pending]:"pending",[we.Processing]:"processing",[we.Completed]:"completed",[we.Failed]:"failed"};return{id:O.task_id,user_id:(e==null?void 0:e.id)||null,filename:O.file_name,file_path:O.origin_url,file_type:"image/jpeg",file_size:0,thumbnail_path:null,status:B[O.status]||"pending",created_at:O.created_at,updated_at:O.created_at}},q=O=>({id:O.task_id,file_id:O.task_id,markdown_content:O.markdown,latex_content:O.latex,mathml_content:O.mathml,mathml_word_content:O.mathml_mw,rendered_image_path:O.image_blob||null,created_at:O.created_at}),D=async()=>{if(e){y(!0);try{const O=await ze.getTaskList("FORMULA",1,Yt),B=O.task_list||[],G=O.total||0;if(k(1),w(B.length<G),B.length>0){const Z=B.map($);t(Z),B.forEach(Q=>{Q.status===we.Completed&&(N.current[Q.task_id]=q(Q))}),n||s(Z[0].id)}else t([])}catch(O){console
|