diff --git a/app.cloud/assets/index-D6FBTwaJ.js b/app.cloud/assets/index-D6FBTwaJ.js new file mode 100644 index 0000000..ea5580d --- /dev/null +++ b/app.cloud/assets/index-D6FBTwaJ.js @@ -0,0 +1,194 @@ +import{j as b,c as vr,v as Ar,M as jr,r as Cr,a as kr}from"./vendor-markdown-C0b4qDwm.js";import{a as Sr,r as H,g as Er}from"./vendor-react-C6WG4Va-.js";import"./vendor-katex-p018AHG0.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))s(e);new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function f(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?r.credentials="include":e.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(e){if(e.ep)return;e.ep=!0;const r=f(e);fetch(e.href,r)}})();var Dt,St=Sr;Dt=St.createRoot,St.hydrateRoot;const Et={development:{apiBaseUrl:"https://cloud.texpixel.com:10443/doc_ai/v1",env:"development"},production:{apiBaseUrl:"https://api.texpixel.com/doc_ai/v1",env:"production"}},_r="development",Tr=Et[_r]||Et.development,Ot=Tr.apiBaseUrl,ct="texpixel_token",Qe="texpixel_token_expires",ut="texpixel_user_email",ye={getToken(){return localStorage.getItem(ct)},setToken(t,n,f){localStorage.setItem(ct,t),localStorage.setItem(Qe,n.toString()),f&&localStorage.setItem(ut,f)},removeToken(){localStorage.removeItem(ct),localStorage.removeItem(Qe),localStorage.removeItem(ut)},getEmail(){return localStorage.getItem(ut)},isTokenValid(){const t=this.getToken(),n=localStorage.getItem(Qe);if(!t||!n)return!1;const f=parseInt(n,10)*1e3;return Date.now()(t[t.Pending=0]="Pending",t[t.Processing=1]="Processing",t[t.Completed=2]="Completed",t[t.Failed=3]="Failed",t))(xe||{});const Ur={200:"操作成功",400:"参数错误",401:"未授权,请先登录",403:"无权限访问",404:"资源不存在",405:"状态无效",500:"服务器错误,请稍后重试",501:"系统错误,请稍后重试",1001:"任务未完成",1002:"记录重复",1003:"验证码错误",1004:"该邮箱已注册",1005:"该邮箱未注册",1006:"密码错误"};function dt(t){try{const f=t.replace("Bearer ","").split(".")[1];return JSON.parse(atob(f))}catch{return null}}const qe={async login(t){const n=await Pe.post("/user/login",t,{skipAuth:!0});if(!n.data)throw new Me(-1,"登录失败,请重试");const{token:f,expires_at:s}=n.data;ye.setToken(f,s,t.email);const e=dt(f);if(!e)throw new Me(-1,"Token 解析失败");return{user:{...e,email:t.email,id:String(e.user_id)},token:f,expiresAt:s}},async register(t){const n=await Pe.post("/user/register",t,{skipAuth:!0});if(!n.data)throw new Me(-1,"注册失败,请重试");const{token:f,expires_at:s}=n.data;ye.setToken(f,s,t.email);const e=dt(f);if(!e)throw new Me(-1,"Token 解析失败");return{user:{...e,email:t.email,id:String(e.user_id)},token:f,expiresAt:s}},logout(){ye.removeToken()},isAuthenticated(){return ye.isTokenValid()},getToken(){return ye.getToken()},restoreSession(){const t=ye.getToken(),n=ye.getExpiresAt(),f=ye.getEmail();if(!t||!n||!ye.isTokenValid())return ye.removeToken(),null;const s=dt(t);return s?{user:{...s,email:f||"",id:String(s.user_id)},token:t,expiresAt:n}:(ye.removeToken(),null)}},Ht=H.createContext(void 0);function Nr({children:t}){const[n,f]=H.useState(()=>{try{const x=qe.restoreSession();return x?x.user:null}catch{return null}}),[s,e]=H.useState(()=>{try{const x=qe.restoreSession();return x?x.token:null}catch{return null}}),[r,o]=H.useState(!1),[c,w]=H.useState(!1),C=(x,S)=>{if(x&&typeof x=="object"&&"code"in x){const E=x;return Ur[E.code]||E.message||S}return x instanceof Error?x.message:S},a=H.useCallback(async(x,S)=>{o(!0);try{const E=await qe.login({email:x,password:S});return f(E.user),e(E.token),{error:null}}catch(E){const m=C(E,"登录失败");return{error:new Error(m)}}finally{o(!1)}},[]),u=H.useCallback(async(x,S)=>{o(!0);try{const E=await qe.register({email:x,password:S});return f(E.user),e(E.token),{error:null}}catch(E){const m=C(E,"注册失败");return{error:new Error(m)}}finally{o(!1)}},[]),i=H.useCallback(async()=>{o(!0);try{qe.logout(),f(null),e(null)}finally{o(!1)}},[]),g={user:n,token:s,loading:r,initializing:c,signIn:a,signUp:u,signOut:i,isAuthenticated:!!n&&!!s};return b.jsx(Ht.Provider,{value:g,children:t})}function xt(){const t=H.useContext(Ht);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const Fr={en:{common:{upload:"Upload",history:"History",login:"Login / Register",logout:"Logout",loading:"Loading...",processing:"Processing...",cancel:"Cancel",copy:"Copy",copied:"Copied!",download:"Download",export:"Export",preview:"Preview",email:"Email",contactUs:"Contact Us",reward:"Reward",qqGroup:"QQ Group (Click to Copy)",guide:"User Guide",click:"Click",drop:"Drop",paste:"Paste"},navbar:{rewardTitle:"WeChat Reward",rewardThanks:"Thank you for your support and encouragement ❤️",rewardSubtitle:"Your support is our motivation for continuous updates"},sidebar:{title:"Formula Recognize",subtitle:"Support handwriting and printed formulas",uploadInstruction:"Click, Drop, or Paste a file to start parsing",pleaseLogin:"Please login to view history",noHistory:"No history records",noMore:"No more records",historyHeader:"History"},uploadModal:{title:"Upload File",supportFormats:"Support JPG, PNG, PDF format"},resultPanel:{waitingTitle:"Waiting for recognition result",waitingSubtitle:"After uploading the file, Texpixel will automatically recognize and display the result here",analyzing:"Analyzing...",waitingQueue:"Waiting in queue...",queueSubtitle:"Your file is in the queue, please wait.",processingSubtitle:"Texpixel is processing your file, this may take a moment.",markdown:"Markdown"},auth:{signIn:"Login",signUp:"Register",signInTitle:"Login Account",signUpTitle:"Register Account",email:"Email",password:"Password",error:"Error",genericError:"An error occurred, please try again",hasAccount:"Already have an account? Login",noAccount:"No account? Register"},export:{title:"Export",categories:{code:"Code",image:"Image",file:"File"},failed:"Export failed, please try again",imageFailed:"Failed to generate image"},guide:{next:"Next",prev:"Back",finish:"Finish",skip:"Skip",step1Title:"Upload Area",step1Content:"Click or drag and drop your formula images/PDFs here to start recognition.",step2Title:"File History",step2Content:"Your recognized files will appear here. Login to sync across devices.",step3Title:"Preview Area",step3Content:"The original file you uploaded will be displayed here for comparison.",step4Title:"Recognition Result",step4Content:"The recognition results (Markdown/LaTeX) will be shown here.",stepExportTitle:"Export Result",stepExportContent:"You can export the recognition results to various formats such as Markdown, LaTeX, Word, or Image."},alerts:{taskTimeout:"Task timeout: Recognition took too long.",networkError:"Task timeout or network error.",uploadFailed:"Upload failed"}},zh:{common:{upload:"上传",history:"历史记录",login:"登录 / 注册",logout:"退出登录",loading:"加载中...",processing:"处理中...",cancel:"取消",copy:"复制",copied:"已复制!",download:"下载",export:"导出",preview:"预览",email:"邮箱",contactUs:"联系我们",reward:"赞赏",qqGroup:"QQ 群 (点击复制)",guide:"使用引导",click:"点击",drop:"拖拽",paste:"粘贴"},navbar:{rewardTitle:"微信赞赏码",rewardThanks:"感谢您的支持与鼓励 ❤️",rewardSubtitle:"您的支持是我们持续更新的动力"},sidebar:{title:"文档识别",subtitle:"支持手写和印刷体文档识别",uploadInstruction:"点击、拖拽或粘贴文件开始解析",pleaseLogin:"请登录后查看历史记录",noHistory:"暂无历史记录",noMore:"没有更多记录了",historyHeader:"历史记录"},uploadModal:{title:"上传文件",supportFormats:"支持 JPG, PNG 格式"},resultPanel:{waitingTitle:"等待识别结果",waitingSubtitle:"上传文件后,TexPixel 将自动识别并在此显示结果",analyzing:"解析中...",waitingQueue:"排队中...",queueSubtitle:"您的文件正在排队,请稍候。",processingSubtitle:"TexPixel 正在处理您的文件,请稍候。",markdown:"Markdown"},auth:{signIn:"登录",signUp:"注册",signInTitle:"登录账号",signUpTitle:"注册账号",email:"邮箱",password:"密码",error:"错误",genericError:"发生错误,请重试",hasAccount:"已有账号?去登录",noAccount:"没有账号?去注册"},export:{title:"导出",categories:{code:"代码",image:"图片",file:"文件"},failed:"导出失败,请重试",imageFailed:"生成图片失败"},guide:{next:"下一步",prev:"上一步",finish:"完成",skip:"跳过",step1Title:"上传区域",step1Content:"点击此处或将公式/文档图片 粘贴或者拖拽到这里开始识别。",step2Title:"历史记录",step2Content:"识别过的文件会显示在这里。登录后可以跨设备同步。",step3Title:"预览区域",step3Content:"这里会显示您上传的原始文件,方便对比。",step4Title:"识别结果",step4Content:"这里会显示识别出的 Markdown/LaTeX 结果。",stepExportTitle:"导出结果",stepExportContent:"您可以将识别结果导出为多种格式,如 Markdown、LaTeX、Word 或图片。"},alerts:{taskTimeout:"任务超时:识别时间过长。",networkError:"任务超时或网络错误。",uploadFailed:"上传失败"}}};async function Rr(){try{const t=await fetch("https://ipapi.co/json/",{method:"GET",headers:{Accept:"application/json"}});if(!t.ok)return console.warn("IP location detection failed:",t.status),null;const n=await t.json();return n.error||!n.country_code?null:n.country_code.toUpperCase()}catch(t){return console.warn("IP location detection error:",t),null}}function Ir(t){return t&&["CN","TW","HK","MO","SG"].includes(t)?"zh":"en"}async function Mr(){const t=await Rr();return Ir(t)}const Pr={zh:{title:"⚡️ TexPixel - 公式识别工具",description:"在线公式识别工具,支持印刷体和手写体数学公式识别,快速准确地将图片中的数学公式转换为可编辑文本。",keywords:"公式识别,数学公式,OCR,手写公式识别,印刷体识别,AI识别,数学工具,免费,混合文字识别,texpixel,TexPixel"},en:{title:"⚡️ TexPixel - Formula Recognition Tool",description:"Online formula recognition tool supporting printed and handwritten math formulas. Convert images to LaTeX, MathML, and Markdown quickly and accurately.",keywords:"formula recognition,math formula,OCR,handwriting recognition,latex,mathml,markdown,AI recognition,math tool,free,texpixel,TexPixel,document recognition"}};function Ke(t){const n=Pr[t];document.title=n.title,document.documentElement.lang=t==="zh"?"zh-CN":"en";const f=document.querySelector('meta[name="description"]');f&&f.setAttribute("content",n.description);const s=document.querySelector('meta[name="keywords"]');s&&s.setAttribute("content",n.keywords);const e=document.querySelector('meta[property="og:title"]');e&&e.setAttribute("content",n.title);const r=document.querySelector('meta[property="og:description"]');r&&r.setAttribute("content",n.description);const o=document.querySelector('meta[name="twitter:title"]');o&&o.setAttribute("content",n.title);const c=document.querySelector('meta[name="twitter:description"]');c&&c.setAttribute("content",n.description);const w=document.querySelector('meta[property="og:locale"]');w&&w.setAttribute("content",t==="zh"?"zh_CN":"en_US")}const Bt=H.createContext(void 0),Lr=({children:t})=>{const[n,f]=H.useState(()=>{const r=localStorage.getItem("language");return r==="en"||r==="zh"?r:navigator.language.startsWith("zh")?"zh":"en"});H.useEffect(()=>{const r=localStorage.getItem("language");if(r==="en"||r==="zh"){Ke(r);return}Mr().then(o=>{f(o),Ke(o)}).catch(o=>{console.warn("Failed to detect language by IP:",o),Ke(n)})},[]);const s=r=>{f(r),localStorage.setItem("language",r),Ke(r)},e=Fr[n];return b.jsx(Bt.Provider,{value:{language:n,setLanguage:s,t:e},children:t})},ke=()=>{const t=H.useContext(Bt);if(t===void 0)throw new Error("useLanguage must be used within a LanguageProvider");return t};function zr(t,n){return n.forEach(function(f){f&&typeof f!="string"&&!Array.isArray(f)&&Object.keys(f).forEach(function(s){if(s!=="default"&&!(s in t)){var e=Object.getOwnPropertyDescriptor(f,s);Object.defineProperty(t,s,e.get?e:{enumerable:!0,get:function(){return f[s]}})}})}),Object.freeze(t)}function qt(t,n){return new Promise(function(f,s){let e;return $r(t).then(function(r){try{return e=r,f(new Blob([n.slice(0,2),e,n.slice(2)],{type:"image/jpeg"}))}catch(o){return s(o)}},s)})}const $r=t=>new Promise((n,f)=>{const s=new FileReader;s.addEventListener("load",({target:{result:e}})=>{const r=new DataView(e);let o=0;if(r.getUint16(o)!==65496)return f("not a valid JPEG");for(o+=2;;){const c=r.getUint16(o);if(c===65498)break;const w=r.getUint16(o+2);if(c===65505&&r.getUint32(o+4)===1165519206){const C=o+10;let a;switch(r.getUint16(C)){case 18761:a=!0;break;case 19789:a=!1;break;default:return f("TIFF header contains invalid endian")}if(r.getUint16(C+2,a)!==42)return f("TIFF header contains invalid version");const u=r.getUint32(C+4,a),i=C+u+2+12*r.getUint16(C+u,a);for(let g=C+u+2;g>>24&255,c[o+1]=w>>>16&255,c[o+2]=w>>>8&255,c[o+3]=w>>>0&255,new Uint8Array(c.buffer,0,o+4)},s.deflateRaw=function(e,r){r==null&&(r={level:6});var o=new Uint8Array(50+Math.floor(1.1*e.length)),c=s.F.deflateRaw(e,o,c,r.level);return new Uint8Array(o.buffer,0,c)},s.encode=function(e,r){r==null&&(r=!1);var o=0,c=s.bin.writeUint,w=s.bin.writeUshort,C={};for(var a in e){var u=!s._noNeed(a)&&!r,i=e[a],g=s.crc.crc(i,0,i.length);C[a]={cpr:u,usize:i.length,crc:g,file:u?s.deflateRaw(i):i}}for(var a in C)o+=C[a].file.length+30+46+2*s.bin.sizeUTF8(a);o+=22;var x=new Uint8Array(o),S=0,E=[];for(var a in C){var m=C[a];E.push(S),S=s._writeHeader(x,S,a,m,0)}var k=0,h=S;for(var a in C)m=C[a],E.push(S),S=s._writeHeader(x,S,a,m,1,E[k++]);var d=S-h;return c(x,S,101010256),S+=4,w(x,S+=4,k),w(x,S+=2,k),c(x,S+=2,d),c(x,S+=4,h),S+=4,S+=2,x.buffer},s._noNeed=function(e){var r=e.split(".").pop().toLowerCase();return"png,jpg,jpeg,zip".indexOf(r)!=-1},s._writeHeader=function(e,r,o,c,w,C){var a=s.bin.writeUint,u=s.bin.writeUshort,i=c.file;return a(e,r,w==0?67324752:33639248),r+=4,w==1&&(r+=2),u(e,r,20),u(e,r+=2,0),u(e,r+=2,c.cpr?8:0),a(e,r+=2,0),a(e,r+=4,c.crc),a(e,r+=4,i.length),a(e,r+=4,c.usize),u(e,r+=4,s.bin.sizeUTF8(o)),u(e,r+=2,0),r+=2,w==1&&(r+=2,r+=2,a(e,r+=6,C),r+=4),r+=s.bin.writeUTF8(e,r,o),w==0&&(e.set(i,r),r+=i.length),r},s.crc={table:function(){for(var e=new Uint32Array(256),r=0;r<256;r++){for(var o=r,c=0;c<8;c++)1&o?o=3988292384^o>>>1:o>>>=1;e[r]=o}return e}(),update:function(e,r,o,c){for(var w=0;w>>8;return e},crc:function(e,r,o){return 4294967295^s.crc.update(4294967295,e,r,o)}},s.adler=function(e,r,o){for(var c=1,w=0,C=r,a=r+o;C>8&255},readUint:function(e,r){return 16777216*e[r+3]+(e[r+2]<<16|e[r+1]<<8|e[r])},writeUint:function(e,r,o){e[r]=255&o,e[r+1]=o>>8&255,e[r+2]=o>>16&255,e[r+3]=o>>24&255},readASCII:function(e,r,o){for(var c="",w=0;w>6,e[r+w+1]=128|a>>0&63,w+=2;else if(!(4294901760&a))e[r+w]=224|a>>12,e[r+w+1]=128|a>>6&63,e[r+w+2]=128|a>>0&63,w+=3;else{if(4292870144&a)throw"e";e[r+w]=240|a>>18,e[r+w+1]=128|a>>12&63,e[r+w+2]=128|a>>6&63,e[r+w+3]=128|a>>0&63,w+=4}}return w},sizeUTF8:function(e){for(var r=e.length,o=0,c=0;c>>3}var E=C.lits,m=C.strt,k=C.prev,h=0,d=0,A=0,l=0,M=0,p=0;for(S>2&&(m[p=s.F._hash(e,0)]=0),i=0;i14e3||d>26697)&&S-i>100&&(x>>16,U=65535&_;if(_!=0){U=65535&_;var F=a(N=_>>>16,C.of0);C.lhst[257+F]++;var T=a(U,C.df0);C.dhst[T]++,l+=C.exb[F]+C.dxb[T],E[h]=N<<23|i-x,E[h+1]=U<<16|F<<8|T,h+=2,x=i+N}else C.lhst[e[i]]++;d++}}for(A==i&&e.length!=0||(x>>3},s.F._bestMatch=function(e,r,o,c,w,C){var a=32767&r,u=o[a],i=a-u+32768&32767;if(u==a||c!=s.F._hash(e,r-i))return 0;for(var g=0,x=0,S=Math.min(32767,r);i<=S&&--C!=0&&u!=a;){if(g==0||e[r+g]==e[r+g-i]){var E=s.F._howLong(e,r,i);if(E>g){if(x=i,(g=E)>=w)break;i+2m&&(m=d,u=h)}}}i+=(a=u)-(u=o[a])+32768&32767}return g<<16|x},s.F._howLong=function(e,r,o){if(e[r]!=e[r-o]||e[r+1]!=e[r+1-o]||e[r+2]!=e[r+2-o])return 0;var c=r,w=Math.min(e.length,r+258);for(r+=3;r>>23,W=y+(8388607&R);y>16,$=O>>8&255,P=255&O;p(u,i=s.F._writeLit(257+$,T,u,i),z-l.of0[$]),i+=l.exb[$],M(u,i=s.F._writeLit(P,I,u,i),q-l.df0[P]),i+=l.dxb[P],y+=z}}i=s.F._writeLit(256,T,u,i)}return i},s.F._copyExact=function(e,r,o,c,w){var C=w>>>3;return c[C]=o,c[C+1]=o>>>8,c[C+2]=255-c[C],c[C+3]=255-c[C+1],C+=4,c.set(new Uint8Array(e.buffer,r,o),C),w+(o+4<<3)},s.F.getTrees=function(){for(var e=s.F.U,r=s.F._hufTree(e.lhst,e.ltree,15),o=s.F._hufTree(e.dhst,e.dtree,15),c=[],w=s.F._lenCodes(e.ltree,c),C=[],a=s.F._lenCodes(e.dtree,C),u=0;u4&&e.itree[1+(e.ordr[g-1]<<1)]==0;)g--;return[r,o,i,w,a,g,c,C]},s.F.getSecond=function(e){for(var r=[],o=0;o>1)+",");return r},s.F.contSize=function(e,r){for(var o=0,c=0;c15&&(s.F._putsE(o,c,a,u),c+=u)}return c},s.F._lenCodes=function(e,r){for(var o=e.length;o!=2&&e[o-1]==0;)o-=2;for(var c=0;c>>1,138))<11?r.push(17,g-3):r.push(18,g-11),c+=2*g-2}else if(w==u&&C==w&&a==w){for(i=c+5;i+2>>1,6);r.push(16,g-3),c+=2*g-2}else r.push(w,0)}return o>>>1},s.F._hufTree=function(e,r,o){var c=[],w=e.length,C=r.length,a=0;for(a=0;ao&&(s.F.restrictDepth(i,o,h),h=o),a=0;ar;c++){var a=e[c].d;e[c].d=r,C+=w-(1<>>=o-r;C>0;)(a=e[c].d)=0;c--)e[c].d==r&&C<0&&(e[c].d--,C++);C!=0&&console.log("debt left")},s.F._goodIndex=function(e,r){var o=0;return r[16|o]<=e&&(o|=16),r[8|o]<=e&&(o|=8),r[4|o]<=e&&(o|=4),r[2|o]<=e&&(o|=2),r[1|o]<=e&&(o|=1),o},s.F._writeLit=function(e,r,o,c){return s.F._putsF(o,c,r[e<<1]),c+r[1+(e<<1)]},s.F.inflate=function(e,r){var o=Uint8Array;if(e[0]==3&&e[1]==0)return r||new o(0);var c=s.F,w=c._bitsF,C=c._bitsE,a=c._decodeTiny,u=c.makeCodes,i=c.codes2map,g=c._get17,x=c.U,S=r==null;S&&(r=new o(e.length>>>2<<3));for(var E,m,k=0,h=0,d=0,A=0,l=0,M=0,p=0,v=0,_=0;k==0;)if(k=w(e,_,1),h=w(e,_+1,2),_+=3,h!=0){if(S&&(r=s.F._check(r,v+(1<<17))),h==1&&(E=x.flmap,m=x.fdmap,M=511,p=31),h==2){d=C(e,_,5)+257,A=C(e,_+5,5)+1,l=C(e,_+10,4)+4,_+=14;for(var N=0;N<38;N+=2)x.itree[N]=0,x.itree[N+1]=0;var U=1;for(N=0;NU&&(U=F)}_+=3*l,u(x.itree,U),i(x.itree,U,x.imap),E=x.lmap,m=x.dmap,_=a(x.imap,(1<>>4;if(!(y>>>8))r[v++]=y;else{if(y==256)break;var L=v+y-254;if(y>264){var R=x.ldef[y-257];L=v+(R>>>3)+C(e,_,7&R),_+=7&R}var z=m[g(e,_)&p];_+=15&z;var W=z>>>4,O=x.ddef[W],q=(O>>>4)+w(e,_,15&O);for(_+=15&O,S&&(r=s.F._check(r,v+(1<<17)));v>>3),P=e[$-4]|e[$-3]<<8;S&&(r=s.F._check(r,v+P)),r.set(new o(e.buffer,e.byteOffset+$,P),v),_=$+P<<3,v+=P}return r.length==v?r:r.slice(0,v)},s.F._check=function(e,r){var o=e.length;if(r<=o)return e;var c=new Uint8Array(Math.max(o<<1,r));return c.set(e,0),c},s.F._decodeTiny=function(e,r,o,c,w,C){for(var a=s.F._bitsE,u=s.F._get17,i=0;i>>4;if(x<=15)C[i]=x,i++;else{var S=0,E=0;x==16?(E=3+a(c,w,2),w+=2,S=C[i-1]):x==17?(E=3+a(c,w,3),w+=3):x==18&&(E=11+a(c,w,7),w+=7);for(var m=i+E;i>>1;Cw&&(w=u),C++}for(;C>1,u=e[C+1],i=a<<4|u,g=r-u,x=e[C]<>>15-r]=i,x++},s.F.revCodes=function(e,r){for(var o=s.F.U.rev15,c=15-r,w=0;w>>c}},s.F._putsE=function(e,r,o){o<<=7&r;var c=r>>>3;e[c]|=o,e[c+1]|=o>>>8},s.F._putsF=function(e,r,o){o<<=7&r;var c=r>>>3;e[c]|=o,e[c+1]|=o>>>8,e[c+2]|=o>>>16},s.F._bitsE=function(e,r,o){return(e[r>>>3]|e[1+(r>>>3)]<<8)>>>(7&r)&(1<>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16)>>>(7&r)&(1<>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16)>>>(7&r)},s.F._get25=function(e,r){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16|e[3+(r>>>3)]<<24)>>>(7&r)},s.F.U=(n=Uint16Array,f=Uint32Array,{next_code:new n(16),bl_count:new n(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new n(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new f(32),flmap:new n(512),fltree:[],fdmap:new n(32),fdtree:[],lmap:new n(32768),ltree:[],ttree:[],dmap:new n(32768),dtree:[],imap:new n(512),itree:[],rev15:new n(32768),lhst:new f(286),dhst:new f(30),ihst:new f(19),lits:new f(15e3),strt:new n(65536),prev:new n(32768)}),function(){for(var e=s.F.U,r=0;r<32768;r++){var o=r;o=(4278255360&(o=(4042322160&(o=(3435973836&(o=(2863311530&o)>>>1|(1431655765&o)<<1))>>>2|(858993459&o)<<2))>>>4|(252645135&o)<<4))>>>8|(16711935&o)<<8,e.rev15[r]=(o>>>16|o<<16)>>>17}function c(w,C,a){for(;C--!=0;)w.push(0,a)}for(r=0;r<32;r++)e.ldef[r]=e.of0[r]<<3|e.exb[r],e.ddef[r]=e.df0[r]<<4|e.dxb[r];c(e.fltree,144,8),c(e.fltree,112,9),c(e.fltree,24,7),c(e.fltree,8,8),s.F.makeCodes(e.fltree,9),s.F.codes2map(e.fltree,9,e.flmap),s.F.revCodes(e.fltree,9),c(e.fdtree,32,5),s.F.makeCodes(e.fdtree,5),s.F.codes2map(e.fdtree,5,e.fdmap),s.F.revCodes(e.fdtree,5),c(e.itree,19,0),c(e.ltree,286,0),c(e.dtree,30,0),c(e.ttree,320,0)}()})();var Or=zr({__proto__:null,default:Je},[Je]);const ve=function(){var t={nextZero(a,u){for(;a[u]!=0;)u++;return u},readUshort:(a,u)=>a[u]<<8|a[u+1],writeUshort(a,u,i){a[u]=i>>8&255,a[u+1]=255&i},readUint:(a,u)=>16777216*a[u]+(a[u+1]<<16|a[u+2]<<8|a[u+3]),writeUint(a,u,i){a[u]=i>>24&255,a[u+1]=i>>16&255,a[u+2]=i>>8&255,a[u+3]=255&i},readASCII(a,u,i){let g="";for(let x=0;xa.length<2?`0${a}`:a,readUTF8(a,u,i){let g,x="";for(let S=0;S>3)]>>7-((7&l)<<0)&1);m[v]=R[F],m[v+1]=R[F+1],m[v+2]=R[F+2],m[v+3]=T>2)]>>6-((3&l)<<1)&3),m[v]=R[F],m[v+1]=R[F+1],m[v+2]=R[F+2],m[v+3]=T>1)]>>4-((1&l)<<2)&15),m[v]=R[F],m[v+1]=R[F+1],m[v+2]=R[F+2],m[v+3]=T>>3)]>>>7-(7&y)&1))==255*p?0:255;k[z+y]=L<<24|I<<16|I<<8|I}else if(d==2)for(y=0;y>>2)]>>>6-((3&y)<<1)&3))==85*p?0:255,k[z+y]=L<<24|I<<16|I<<8|I;else if(d==4)for(y=0;y>>1)]>>>4-((1&y)<<2)&15))==17*p?0:255,k[z+y]=L<<24|I<<16|I<<8|I;else if(d==8)for(y=0;y>3,p=Math.ceil(d*l/8),v=new Uint8Array(A*p);let _=0;const N=[0,0,4,0,2,0,1],U=[0,4,0,2,0,1,0],F=[8,8,8,4,4,2,2],T=[8,8,4,4,2,2,1];let I=0;for(;I<7;){const y=F[I],L=T[I];let R=0,z=0,W=N[I];for(;W>3])>>7-(7&D)&1,v[P*p+(Q>>3)]|=j<<7-((7&Q)<<0)),l==2&&(j=(j=k[D>>3])>>6-(7&D)&3,v[P*p+(Q>>2)]|=j<<6-((3&Q)<<1)),l==4&&(j=(j=k[D>>3])>>4-(7&D)&15,v[P*p+(Q>>1)]|=j<<4-((1&Q)<<2)),l>=8){const B=P*p+Q*M;for(let G=0;G>3)+G]}D+=l,Q+=L}$++,P+=y}R*z!=0&&(_+=z*(1+q)),I+=1}return v}(u,a)),u}function s(a,u){return e(new Uint8Array(a.buffer,2,a.length-6),u)}var e=function(){const a={H:{}};return a.H.N=function(u,i){const g=Uint8Array;let x,S,E=0,m=0,k=0,h=0,d=0,A=0,l=0,M=0,p=0;if(u[0]==3&&u[1]==0)return i||new g(0);const v=a.H,_=v.b,N=v.e,U=v.R,F=v.n,T=v.A,I=v.Z,j=v.m,y=i==null;for(y&&(i=new g(u.length>>>2<<5));E==0;)if(E=_(u,p,1),m=_(u,p+1,2),p+=3,m!=0){if(y&&(i=a.H.W(i,M+(1<<17))),m==1&&(x=j.J,S=j.h,A=511,l=31),m==2){k=N(u,p,5)+257,h=N(u,p+5,5)+1,d=N(u,p+10,4)+4,p+=14;let R=1;for(var L=0;L<38;L+=2)j.Q[L]=0,j.Q[L+1]=0;for(L=0;LR&&(R=O)}p+=3*d,F(j.Q,R),T(j.Q,R,j.u),x=j.w,S=j.d,p=U(j.u,(1<>>4;if(!(z>>>8))i[M++]=z;else{if(z==256)break;{let W=M+z-254;if(z>264){const Q=j.q[z-257];W=M+(Q>>>3)+N(u,p,7&Q),p+=7&Q}const O=S[I(u,p)&l];p+=15&O;const q=O>>>4,$=j.c[q],P=($>>>4)+_(u,p,15&$);for(p+=15&$;M>>3),z=u[R-4]|u[R-3]<<8;y&&(i=a.H.W(i,M+z)),i.set(new g(u.buffer,u.byteOffset+R,z),M),p=R+z<<3,M+=z}return i.length==M?i:i.slice(0,M)},a.H.W=function(u,i){const g=u.length;if(i<=g)return u;const x=new Uint8Array(g<<1);return x.set(u,0),x},a.H.R=function(u,i,g,x,S,E){const m=a.H.e,k=a.H.Z;let h=0;for(;h>>4;if(A<=15)E[h]=A,h++;else{let l=0,M=0;A==16?(M=3+m(x,S,2),S+=2,l=E[h-1]):A==17?(M=3+m(x,S,3),S+=3):A==18&&(M=11+m(x,S,7),S+=7);const p=h+M;for(;h>>1;for(;ES&&(S=k),E++}for(;E>1,k=u[E+1],h=m<<4|k,d=i-k;let A=u[E]<>>15-i]=h,A++}},a.H.l=function(u,i){const g=a.H.m.r,x=15-i;for(let S=0;S>>x}},a.H.M=function(u,i,g){g<<=7&i;const x=i>>>3;u[x]|=g,u[x+1]|=g>>>8},a.H.I=function(u,i,g){g<<=7&i;const x=i>>>3;u[x]|=g,u[x+1]|=g>>>8,u[x+2]|=g>>>16},a.H.e=function(u,i,g){return(u[i>>>3]|u[1+(i>>>3)]<<8)>>>(7&i)&(1<>>3]|u[1+(i>>>3)]<<8|u[2+(i>>>3)]<<16)>>>(7&i)&(1<>>3]|u[1+(i>>>3)]<<8|u[2+(i>>>3)]<<16)>>>(7&i)},a.H.i=function(u,i){return(u[i>>>3]|u[1+(i>>>3)]<<8|u[2+(i>>>3)]<<16|u[3+(i>>>3)]<<24)>>>(7&i)},a.H.m=function(){const u=Uint16Array,i=Uint32Array;return{K:new u(16),j:new u(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new u(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new i(32),J:new u(512),_:[],h:new u(32),$:[],w:new u(32768),C:[],v:[],d:new u(32768),D:[],u:new u(512),Q:[],r:new u(32768),s:new i(286),Y:new i(30),a:new i(19),t:new i(15e3),k:new u(65536),g:new u(32768)}}(),function(){const u=a.H.m;for(var i=0;i<32768;i++){let x=i;x=(2863311530&x)>>>1|(1431655765&x)<<1,x=(3435973836&x)>>>2|(858993459&x)<<2,x=(4042322160&x)>>>4|(252645135&x)<<4,x=(4278255360&x)>>>8|(16711935&x)<<8,u.r[i]=(x>>>16|x<<16)>>>17}function g(x,S,E){for(;S--!=0;)x.push(0,E)}for(i=0;i<32;i++)u.q[i]=u.S[i]<<3|u.T[i],u.c[i]=u.p[i]<<4|u.z[i];g(u._,144,8),g(u._,112,9),g(u._,24,7),g(u._,8,8),a.H.n(u._,9),a.H.A(u._,9,u.J),a.H.l(u._,9),g(u.$,32,5),a.H.n(u.$,5),a.H.A(u.$,5,u.h),a.H.l(u.$,5),g(u.Q,19,0),g(u.C,286,0),g(u.D,30,0),g(u.v,320,0)}(),a.H.N}();function r(a){return[1,null,3,1,2,null,4][a.ctype]*a.depth}function o(a,u,i,g,x){let S=r(u);const E=Math.ceil(g*S/8);let m,k;S=Math.ceil(S/8);let h=a[i],d=0;if(h>1&&(a[i]=[0,0,1][h-2]),h==3)for(d=S;d>>1)&255;for(let A=0;A>>1);for(;d>>1)}else{for(;d=0&&m>=0?(A=I*u+j<<2,l=(m+I)*x+E+j<<2):(A=(-m+I)*u-E+j<<2,l=I*x+j<<2),k==0)g[l]=a[A],g[l+1]=a[A+1],g[l+2]=a[A+2],g[l+3]=a[A+3];else if(k==1){var M=a[A+3]*.00392156862745098,p=a[A]*M,v=a[A+1]*M,_=a[A+2]*M,N=g[l+3]*(1/255),U=g[l]*N,F=g[l+1]*N,T=g[l+2]*N;const y=1-M,L=M+N*y,R=L==0?0:1/L;g[l+3]=255*L,g[l+0]=(p+U*y)*R,g[l+1]=(v+F*y)*R,g[l+2]=(_+T*y)*R}else if(k==2)M=a[A+3],p=a[A],v=a[A+1],_=a[A+2],N=g[l+3],U=g[l],F=g[l+1],T=g[l+2],M==N&&p==U&&v==F&&_==T?(g[l]=0,g[l+1]=0,g[l+2]=0,g[l+3]=0):(g[l]=p,g[l+1]=v,g[l+2]=_,g[l+3]=M);else if(k==3){if(M=a[A+3],p=a[A],v=a[A+1],_=a[A+2],N=g[l+3],U=g[l],F=g[l+1],T=g[l+2],M==N&&p==U&&v==F&&_==T)continue;if(M<220&&N>20)return!1}return!0}return{decode:function(u){const i=new Uint8Array(u);let g=8;const x=t,S=x.readUshort,E=x.readUint,m={tabs:{},frames:[]},k=new Uint8Array(i.length);let h,d=0,A=0;const l=[137,80,78,71,13,10,26,10];for(var M=0;M<8;M++)if(i[M]!=l[M])throw"The input is not a PNG file!";for(;g>>1:_>>>=1;p[v]=_}return p}(),update(p,v,_,N){for(let U=0;U>>8;return p},crc:(p,v,_)=>4294967295^s.update(4294967295,p,v,_)};function e(p,v,_,N){v[_]+=p[0]*N>>4,v[_+1]+=p[1]*N>>4,v[_+2]+=p[2]*N>>4,v[_+3]+=p[3]*N>>4}function r(p){return Math.max(0,Math.min(255,p))}function o(p,v){const _=p[0]-v[0],N=p[1]-v[1],U=p[2]-v[2],F=p[3]-v[3];return _*_+N*N+U*U+F*F}function c(p,v,_,N,U,F,T){T==null&&(T=1);const I=N.length,j=[];for(var y=0;y>>0&255,P>>>8&255,P>>>16&255,P>>>24&255])}for(y=0;y>2]=L,W[y>>2]=N[L]}}function w(p,v,_,N,U){U==null&&(U={});const{crc:F}=s,T=n.writeUint,I=n.writeUshort,j=n.writeASCII;let y=8;const L=p.frames.length>1;let R,z=!1,W=33+(L?20:0);if(U.sRGB!=null&&(W+=13),U.pHYs!=null&&(W+=21),U.iCCP!=null&&(R=pako.deflate(U.iCCP),W+=21+R.length+4),p.ctype==3){for(var O=p.plte.length,q=0;q>>24!=255&&(z=!0);W+=8+3*O+4+(z?8+1*O+4:0)}for(var $=0;$>>8&255,Z=X>>>16&255;P[y+G+0]=V,P[y+G+1]=K,P[y+G+2]=Z}if(y+=3*O,T(P,y,F(P,y-3*O-4,3*O+4)),y+=4,z){for(T(P,y,O),y+=4,j(P,y,"tRNS"),y+=4,q=0;q>>24&255;y+=O,T(P,y,F(P,y-O-4,O+4)),y+=4}}let D=0;for($=0;$ze&&(ze=Re),Fe<_e&&(_e=Fe),Fe>Be&&(Be=Fe));ze==-1&&(Ee=_e=ze=Be=0),ne&&((1&Ee)==1&&Ee--,(1&_e)==1&&_e--);const kt=(ze-Ee+1)*(Be-_e+1);kt>2,ue>>2);G.push(X);const ne=new Uint8Array(J.abuf,ie,ue);L&&c(V.img,V.rect.width,V.rect.height,B,ne,X),V.img.set(ne),ie+=ue}}else for(O=0;OK&&te==oe[$-K])X[$]=X[$-K];else{let J=D[te];if(J==null&&(D[te]=J=B.length,B.push(te),B.length>=300))break;X[$]=J}}}const Z=B.length;for(Z<=256&&y==0&&(z=Z<=2?1:Z<=4?2:Z<=16?4:8,z=Math.max(z,j)),O=0;O>1)]|=ue[ge+re]<<4-4*(1&re);else if(z==2)for(re=0;re>2)]|=ue[ge+re]<<6-2*(3&re);else if(z==1)for(re=0;re>3)]|=ue[ge+re]<<7-1*(7&re)}te=ae,R=3,ie=1}else if(P==0&&Q.length==1){ae=new Uint8Array(K*oe*3);const ue=K*oe;for($=0;$$&&($=G),XP&&(P=X))}$==-1&&(O=q=$=P=0),T&&((1&O)==1&&O--,(1&q)==1&&q--),F={x:O,y:q,width:$-O+1,height:P-q+1};const Q=N[U];Q.rect=F,Q.blend=1,Q.img=new Uint8Array(F.width*F.height*4),N[U-1].dispose==0?(t(y,v,_,Q.img,F.width,F.height,-F.x,-F.y,0),i(z,v,_,Q.img,F)):t(z,v,_,Q.img,F.width,F.height,-F.x,-F.y,0)}function i(p,v,_,N,U){t(p,v,_,N,U.width,U.height,-U.x,-U.y,2)}function g(p,v,_,N,U,F,T){const I=[];let j,y=[0,1,2,3,4];F!=-1?y=[F]:(v*N>5e5||_==1)&&(y=[0]),T&&(j={level:0});const L=Or;for(var R=0;R>1)+256&255;if(F==4)for(j=U;j>1)&255;for(j=U;j>1)&255}if(F==4){for(j=0;j>2);let L;if(_.length<2e7)for(var R=0;R>2]=L.ind,U[R>>2]=L.est.rgba;else for(R=0;R>2]=L.ind,U[R>>2]=L.est.rgba}return{abuf:N.buffer,inds:y,plte:I}}function E(p,v,_){_==null&&(_=1e-4);const N=new Uint32Array(p.buffer),U={i0:0,i1:p.length,bst:null,est:null,tdst:0,left:null,right:null};U.bst=A(p,U.i0,U.i1),U.est=l(U.bst);const F=[U];for(;F.lengthI&&(I=F[T].est.L,j=T);if(I<_)break;const y=F[j],L=h(p,N,y.i0,y.i1,y.est.e,y.est.eMq255);if(y.i0>=L||y.i1<=L){y.est.L=0;continue}const R={i0:y.i0,i1:L,bst:null,est:null,tdst:0,left:null,right:null};R.bst=A(p,R.i0,R.i1),R.est=l(R.bst);const z={i0:L,i1:y.i1,bst:null,est:null,tdst:0,left:null,right:null};for(z.bst={R:[],m:[],N:y.bst.N-R.bst.N},T=0;T<16;T++)z.bst.R[T]=y.bst.R[T]-R.bst.R[T];for(T=0;T<4;T++)z.bst.m[T]=y.bst.m[T]-R.bst.m[T];z.est=l(z.bst),y.left=R,y.right=z,F[j]=R,F.push(z)}for(F.sort((I,j)=>j.bst.N-I.bst.N),T=0;T0&&(T=p.right,I=p.left);const j=m(T,v,_,N,U);if(j.tdst<=F*F)return j;const y=m(I,v,_,N,U);return y.tdstF;)N-=4;if(_>=N)break;const T=v[_>>2];v[_>>2]=v[N>>2],v[N>>2]=T,_+=4,N-=4}for(;d(p,_,U)>F;)_-=4;return _+4}function d(p,v,_){return p[v]*_[0]+p[v+1]*_[1]+p[v+2]*_[2]+p[v+3]*_[3]}function A(p,v,_){const N=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],U=[0,0,0,0],F=_-v>>2;for(let T=v;T<_;T+=4){const I=p[T]*.00392156862745098,j=p[T+1]*(1/255),y=p[T+2]*(1/255),L=p[T+3]*(1/255);U[0]+=I,U[1]+=j,U[2]+=y,U[3]+=L,N[0]+=I*I,N[1]+=I*j,N[2]+=I*y,N[3]+=I*L,N[5]+=j*j,N[6]+=j*y,N[7]+=j*L,N[10]+=y*y,N[11]+=y*L,N[15]+=L*L}return N[4]=N[1],N[8]=N[2],N[9]=N[6],N[12]=N[3],N[13]=N[7],N[14]=N[11],{R:N,m:U,N:F}}function l(p){const{R:v}=p,{m:_}=p,{N}=p,U=_[0],F=_[1],T=_[2],I=_[3],j=N==0?0:1/N,y=[v[0]-U*U*j,v[1]-U*F*j,v[2]-U*T*j,v[3]-U*I*j,v[4]-F*U*j,v[5]-F*F*j,v[6]-F*T*j,v[7]-F*I*j,v[8]-T*U*j,v[9]-T*F*j,v[10]-T*T*j,v[11]-T*I*j,v[12]-I*U*j,v[13]-I*F*j,v[14]-I*T*j,v[15]-I*I*j],L=y,R=M;let z=[Math.random(),Math.random(),Math.random(),Math.random()],W=0,O=0;if(N!=0)for(let $=0;$<16&&(z=R.multVec(L,z),O=Math.sqrt(R.dot(z,z)),z=R.sml(1/O,z),!($!=0&&Math.abs(O-W)<1e-9));$++)W=O;const q=[U*j,F*j,T*j,I*j];return{Cov:y,q,e:z,L:W,eMq255:R.dot(R.sml(255,q),z),eMq:R.dot(z,q),rgba:(Math.round(255*q[3])<<24|Math.round(255*q[2])<<16|Math.round(255*q[1])<<8|Math.round(255*q[0])<<0)>>>0}}var M={multVec:(p,v)=>[p[0]*v[0]+p[1]*v[1]+p[2]*v[2]+p[3]*v[3],p[4]*v[0]+p[5]*v[1]+p[6]*v[2]+p[7]*v[3],p[8]*v[0]+p[9]*v[1]+p[10]*v[2]+p[11]*v[3],p[12]*v[0]+p[13]*v[1]+p[14]*v[2]+p[15]*v[3]],dot:(p,v)=>p[0]*v[0]+p[1]*v[1]+p[2]*v[2]+p[3]*v[3],sml:(p,v)=>[p*v[0],p*v[1],p*v[2],p*v[3]]};ve.encode=function(v,_,N,U,F,T,I){U==null&&(U=0),I==null&&(I=!1);const j=a(v,_,N,U,[!1,!1,!1,0,I,!1]);return C(j,-1),w(j,_,N,F,T)},ve.encodeLL=function(v,_,N,U,F,T,I,j){const y={ctype:0+(U==1?0:2)+(F==0?0:4),depth:T,frames:[]},L=(U+F)*T,R=L*_;for(let z=0;z>>0),A(1),A(32),l(3),l(w),l(2835),l(2835),M(8),l(16711680),l(65280),l(255),l(4278190080),l(1466527264),function p(){for(;k0;){for(E=122+k*c,g=0;g>>24,u.setUint32(E+g,x<<8|S),g+=4;k++}d{n(new Blob([f],{type:"image/bmp"}))})},_dly:9};var fe={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},Hr={[fe.CHROME]:16384,[fe.FIREFOX]:11180,[fe.DESKTOP_SAFARI]:16384,[fe.IE]:8192,[fe.IOS]:4096,[fe.ETC]:8192};const yt=typeof window<"u",Gt=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,et=yt&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),Br=(yt||Gt)&&(et&&et.getOriginalSymbol(window,"File")||typeof File<"u"&&File),Qt=(yt||Gt)&&(et&&et.getOriginalSymbol(window,"FileReader")||typeof FileReader<"u"&&FileReader);function bt(t,n,f=Date.now()){return new Promise(s=>{const e=t.split(","),r=e[0].match(/:(.*?);/)[1],o=globalThis.atob(e[1]);let c=o.length;const w=new Uint8Array(c);for(;c--;)w[c]=o.charCodeAt(c);const C=new Blob([w],{type:r});C.name=n,C.lastModified=f,s(C)})}function Vt(t){return new Promise((n,f)=>{const s=new Qt;s.onload=()=>n(s.result),s.onerror=e=>f(e),s.readAsDataURL(t)})}function Kt(t){return new Promise((n,f)=>{const s=new Image;s.onload=()=>n(s),s.onerror=e=>f(e),s.src=t})}function Le(){if(Le.cachedResult!==void 0)return Le.cachedResult;let t=fe.ETC;const{userAgent:n}=navigator;return/Chrom(e|ium)/i.test(n)?t=fe.CHROME:/iP(ad|od|hone)/i.test(n)&&/WebKit/i.test(n)?t=fe.IOS:/Safari/i.test(n)?t=fe.DESKTOP_SAFARI:/Firefox/i.test(n)?t=fe.FIREFOX:(/MSIE/i.test(n)||document.documentMode)&&(t=fe.IE),Le.cachedResult=t,Le.cachedResult}function Xt(t,n){const f=Le(),s=Hr[f];let e=t,r=n,o=e*r;const c=e>r?r/e:e/r;for(;o>s*s;){const w=(s+e)/2,C=(s+r)/2;wWt.toBlob(t,a)).then((function(a){try{return c=a,c.name=f,c.lastModified=s,C.call(this)}catch(u){return o(u)}}).bind(this),o);{let a=function(){return C.call(this)};if(typeof OffscreenCanvas=="function"&&t instanceof OffscreenCanvas)return t.convertToBlob({type:n,quality:e}).then((function(u){try{return c=u,c.name=f,c.lastModified=s,a.call(this)}catch(i){return o(i)}}).bind(this),o);{let u;return u=t.toDataURL(n,e),bt(u,f,s).then((function(i){try{return c=i,a.call(this)}catch(g){return o(g)}}).bind(this),o)}}}function w(){return r(c)}})}function je(t){t.width=0,t.height=0}function Oe(){return new Promise(function(t,n){let f,s,e,r;return Oe.cachedResult!==void 0?t(Oe.cachedResult):bt("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then(function(o){try{return f=o,tt(f).then(function(c){try{return s=c[1],rt(s,f.type,f.name,f.lastModified).then(function(w){try{return e=w,je(s),tt(e).then(function(C){try{return r=C[0],Oe.cachedResult=r.width===1&&r.height===2,t(Oe.cachedResult)}catch(a){return n(a)}},n)}catch(C){return n(C)}},n)}catch(w){return n(w)}},n)}catch(c){return n(c)}},n)})}function Yt(t){return new Promise((n,f)=>{const s=new Qt;s.onload=e=>{const r=new DataView(e.target.result);if(r.getUint16(0,!1)!=65496)return n(-2);const o=r.byteLength;let c=2;for(;cf(e),s.readAsArrayBuffer(t)})}function Jt(t,n){const{width:f}=t,{height:s}=t,{maxWidthOrHeight:e}=n;let r,o=t;return isFinite(e)&&(f>e||s>e)&&([o,r]=it(f,s),f>s?(o.width=e,o.height=s/f*e):(o.width=f/s*e,o.height=e),r.drawImage(t,0,0,o.width,o.height),je(t)),o}function er(t,n){const{width:f}=t,{height:s}=t,[e,r]=it(f,s);switch(n>4&&n<9?(e.width=s,e.height=f):(e.width=f,e.height=s),n){case 2:r.transform(-1,0,0,1,f,0);break;case 3:r.transform(-1,0,0,-1,f,s);break;case 4:r.transform(1,0,0,-1,0,s);break;case 5:r.transform(0,1,1,0,0,0);break;case 6:r.transform(0,1,-1,0,s,0);break;case 7:r.transform(0,-1,-1,0,s,f);break;case 8:r.transform(0,-1,1,0,0,f)}return r.drawImage(t,0,0,f,s),je(t),e}function _t(t,n,f=0){return new Promise(function(s,e){let r,o,c,w,C,a,u,i,g,x,S,E,m,k,h,d,A,l,M,p;function v(N=5){if(n.signal&&n.signal.aborted)throw n.signal.reason;r+=N,n.onProgress(Math.min(r,100))}function _(N){if(n.signal&&n.signal.aborted)throw n.signal.reason;r=Math.min(Math.max(N,r),100),n.onProgress(r)}return r=f,o=n.maxIteration||10,c=1024*n.maxSizeMB*1024,v(),tt(t,n).then((function(N){try{return[,w]=N,v(),C=Jt(w,n),v(),new Promise(function(U,F){var T;if(!(T=n.exifOrientation))return Yt(t).then((function(j){try{return T=j,I.call(this)}catch(y){return F(y)}}).bind(this),F);function I(){return U(T)}return I.call(this)}).then((function(U){try{return a=U,v(),Oe().then((function(F){try{return u=F?C:er(C,a),v(),i=n.initialQuality||1,g=n.fileType||t.type,rt(u,g,t.name,t.lastModified,i).then((function(T){try{{let j=function(){if(o--&&(h>c||h>m)){let L,R;return L=p?.95*M.width:M.width,R=p?.95*M.height:M.height,[A,l]=it(L,R),l.drawImage(M,0,0,L,R),i*=g==="image/png"?.85:.95,rt(A,g,t.name,t.lastModified,i).then(function(z){try{return d=z,je(M),M=A,h=d.size,_(Math.min(99,Math.floor((k-h)/(k-c)*100))),j}catch(W){return e(W)}},e)}return[1]},y=function(){return je(M),je(A),je(C),je(u),je(w),_(100),s(d)};if(x=T,v(),S=x.size>c,E=x.size>t.size,!S&&!E)return _(100),s(x);var I;return m=t.size,k=x.size,h=k,M=u,p=!n.alwaysKeepResolution&&S,(I=(function(L){for(;L;){if(L.then)return void L.then(I,e);try{if(L.pop){if(L.length)return L.pop()?y.call(this):L;L=j}else L=L.call(this)}catch(R){return e(R)}}}).bind(this))(j)}}catch(j){return e(j)}}).bind(this),e)}catch(T){return e(T)}}).bind(this),e)}catch(F){return e(F)}}).bind(this),e)}catch(U){return e(U)}}).bind(this),e)})}const qr=` +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 ft;function Wr(t,n){return new Promise((f,s)=>{ft||(ft=function(o){const c=[];return c.push(o),URL.createObjectURL(new Blob(c))}(qr));const e=new Worker(ft);e.addEventListener("message",function(o){if(n.signal&&n.signal.aborted)e.terminate();else if(o.data.progress===void 0){if(o.data.error)return s(new Error(o.data.error)),void e.terminate();f(o.data.file),e.terminate()}else n.onProgress(o.data.progress)}),e.addEventListener("error",s),n.signal&&n.signal.addEventListener("abort",()=>{s(n.signal.reason),e.terminate()}),e.postMessage({file:t,imageCompressionLibUrl:n.libURL,options:{...n,onProgress:void 0,signal:void 0}})})}function ce(t,n){return new Promise(function(f,s){let e,r,o,c,w,C;if(e={...n},o=0,{onProgress:c}=e,e.maxSizeMB=e.maxSizeMB||Number.POSITIVE_INFINITY,w=typeof e.useWebWorker!="boolean"||e.useWebWorker,delete e.useWebWorker,e.onProgress=g=>{o=g,typeof c=="function"&&c(o)},!(t instanceof Blob||t instanceof Br))return s(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(t.type))return s(new Error("The file given is not an image"));if(C=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!w||typeof Worker!="function"||C)return _t(t,e).then((function(g){try{return r=g,i.call(this)}catch(x){return s(x)}}).bind(this),s);var a=(function(){try{return i.call(this)}catch(g){return s(g)}}).bind(this),u=function(g){try{return _t(t,e).then(function(x){try{return r=x,a()}catch(S){return s(S)}},s)}catch(x){return s(x)}};try{return e.libURL=e.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",Wr(t,e).then(function(g){try{return r=g,a()}catch{return u()}},u)}catch{u()}function i(){try{r.name=t.name,r.lastModified=t.lastModified}catch{}try{e.preserveExif&&t.type==="image/jpeg"&&(!e.fileType||e.fileType&&e.fileType===t.type)&&(r=qt(t,r))}catch{}return f(r)}})}ce.getDataUrlFromFile=Vt,ce.getFilefromDataUrl=bt,ce.loadImage=Kt,ce.drawImageInCanvas=Zt,ce.drawFileInCanvas=tt,ce.canvasToFile=rt,ce.getExifOrientation=Yt,ce.handleMaxWidthOrHeight=Jt,ce.followExifOrientation=er,ce.cleanupCanvasMemory=je,ce.isAutoOrientationInBrowser=Oe,ce.approximateBelowMaximumCanvasSizeOfBrowser=Xt,ce.copyExifWithoutOrientation=qt,ce.getBrowserName=Le,ce.version="2.0.2";var tr={exports:{}};(function(t,n){(function(f){t.exports=f()})(function(f){var s=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function e(m,k){var h=m[0],d=m[1],A=m[2],l=m[3];h+=(d&A|~d&l)+k[0]-680876936|0,h=(h<<7|h>>>25)+d|0,l+=(h&d|~h&A)+k[1]-389564586|0,l=(l<<12|l>>>20)+h|0,A+=(l&h|~l&d)+k[2]+606105819|0,A=(A<<17|A>>>15)+l|0,d+=(A&l|~A&h)+k[3]-1044525330|0,d=(d<<22|d>>>10)+A|0,h+=(d&A|~d&l)+k[4]-176418897|0,h=(h<<7|h>>>25)+d|0,l+=(h&d|~h&A)+k[5]+1200080426|0,l=(l<<12|l>>>20)+h|0,A+=(l&h|~l&d)+k[6]-1473231341|0,A=(A<<17|A>>>15)+l|0,d+=(A&l|~A&h)+k[7]-45705983|0,d=(d<<22|d>>>10)+A|0,h+=(d&A|~d&l)+k[8]+1770035416|0,h=(h<<7|h>>>25)+d|0,l+=(h&d|~h&A)+k[9]-1958414417|0,l=(l<<12|l>>>20)+h|0,A+=(l&h|~l&d)+k[10]-42063|0,A=(A<<17|A>>>15)+l|0,d+=(A&l|~A&h)+k[11]-1990404162|0,d=(d<<22|d>>>10)+A|0,h+=(d&A|~d&l)+k[12]+1804603682|0,h=(h<<7|h>>>25)+d|0,l+=(h&d|~h&A)+k[13]-40341101|0,l=(l<<12|l>>>20)+h|0,A+=(l&h|~l&d)+k[14]-1502002290|0,A=(A<<17|A>>>15)+l|0,d+=(A&l|~A&h)+k[15]+1236535329|0,d=(d<<22|d>>>10)+A|0,h+=(d&l|A&~l)+k[1]-165796510|0,h=(h<<5|h>>>27)+d|0,l+=(h&A|d&~A)+k[6]-1069501632|0,l=(l<<9|l>>>23)+h|0,A+=(l&d|h&~d)+k[11]+643717713|0,A=(A<<14|A>>>18)+l|0,d+=(A&h|l&~h)+k[0]-373897302|0,d=(d<<20|d>>>12)+A|0,h+=(d&l|A&~l)+k[5]-701558691|0,h=(h<<5|h>>>27)+d|0,l+=(h&A|d&~A)+k[10]+38016083|0,l=(l<<9|l>>>23)+h|0,A+=(l&d|h&~d)+k[15]-660478335|0,A=(A<<14|A>>>18)+l|0,d+=(A&h|l&~h)+k[4]-405537848|0,d=(d<<20|d>>>12)+A|0,h+=(d&l|A&~l)+k[9]+568446438|0,h=(h<<5|h>>>27)+d|0,l+=(h&A|d&~A)+k[14]-1019803690|0,l=(l<<9|l>>>23)+h|0,A+=(l&d|h&~d)+k[3]-187363961|0,A=(A<<14|A>>>18)+l|0,d+=(A&h|l&~h)+k[8]+1163531501|0,d=(d<<20|d>>>12)+A|0,h+=(d&l|A&~l)+k[13]-1444681467|0,h=(h<<5|h>>>27)+d|0,l+=(h&A|d&~A)+k[2]-51403784|0,l=(l<<9|l>>>23)+h|0,A+=(l&d|h&~d)+k[7]+1735328473|0,A=(A<<14|A>>>18)+l|0,d+=(A&h|l&~h)+k[12]-1926607734|0,d=(d<<20|d>>>12)+A|0,h+=(d^A^l)+k[5]-378558|0,h=(h<<4|h>>>28)+d|0,l+=(h^d^A)+k[8]-2022574463|0,l=(l<<11|l>>>21)+h|0,A+=(l^h^d)+k[11]+1839030562|0,A=(A<<16|A>>>16)+l|0,d+=(A^l^h)+k[14]-35309556|0,d=(d<<23|d>>>9)+A|0,h+=(d^A^l)+k[1]-1530992060|0,h=(h<<4|h>>>28)+d|0,l+=(h^d^A)+k[4]+1272893353|0,l=(l<<11|l>>>21)+h|0,A+=(l^h^d)+k[7]-155497632|0,A=(A<<16|A>>>16)+l|0,d+=(A^l^h)+k[10]-1094730640|0,d=(d<<23|d>>>9)+A|0,h+=(d^A^l)+k[13]+681279174|0,h=(h<<4|h>>>28)+d|0,l+=(h^d^A)+k[0]-358537222|0,l=(l<<11|l>>>21)+h|0,A+=(l^h^d)+k[3]-722521979|0,A=(A<<16|A>>>16)+l|0,d+=(A^l^h)+k[6]+76029189|0,d=(d<<23|d>>>9)+A|0,h+=(d^A^l)+k[9]-640364487|0,h=(h<<4|h>>>28)+d|0,l+=(h^d^A)+k[12]-421815835|0,l=(l<<11|l>>>21)+h|0,A+=(l^h^d)+k[15]+530742520|0,A=(A<<16|A>>>16)+l|0,d+=(A^l^h)+k[2]-995338651|0,d=(d<<23|d>>>9)+A|0,h+=(A^(d|~l))+k[0]-198630844|0,h=(h<<6|h>>>26)+d|0,l+=(d^(h|~A))+k[7]+1126891415|0,l=(l<<10|l>>>22)+h|0,A+=(h^(l|~d))+k[14]-1416354905|0,A=(A<<15|A>>>17)+l|0,d+=(l^(A|~h))+k[5]-57434055|0,d=(d<<21|d>>>11)+A|0,h+=(A^(d|~l))+k[12]+1700485571|0,h=(h<<6|h>>>26)+d|0,l+=(d^(h|~A))+k[3]-1894986606|0,l=(l<<10|l>>>22)+h|0,A+=(h^(l|~d))+k[10]-1051523|0,A=(A<<15|A>>>17)+l|0,d+=(l^(A|~h))+k[1]-2054922799|0,d=(d<<21|d>>>11)+A|0,h+=(A^(d|~l))+k[8]+1873313359|0,h=(h<<6|h>>>26)+d|0,l+=(d^(h|~A))+k[15]-30611744|0,l=(l<<10|l>>>22)+h|0,A+=(h^(l|~d))+k[6]-1560198380|0,A=(A<<15|A>>>17)+l|0,d+=(l^(A|~h))+k[13]+1309151649|0,d=(d<<21|d>>>11)+A|0,h+=(A^(d|~l))+k[4]-145523070|0,h=(h<<6|h>>>26)+d|0,l+=(d^(h|~A))+k[11]-1120210379|0,l=(l<<10|l>>>22)+h|0,A+=(h^(l|~d))+k[2]+718787259|0,A=(A<<15|A>>>17)+l|0,d+=(l^(A|~h))+k[9]-343485551|0,d=(d<<21|d>>>11)+A|0,m[0]=h+m[0]|0,m[1]=d+m[1]|0,m[2]=A+m[2]|0,m[3]=l+m[3]|0}function r(m){var k=[],h;for(h=0;h<64;h+=4)k[h>>2]=m.charCodeAt(h)+(m.charCodeAt(h+1)<<8)+(m.charCodeAt(h+2)<<16)+(m.charCodeAt(h+3)<<24);return k}function o(m){var k=[],h;for(h=0;h<64;h+=4)k[h>>2]=m[h]+(m[h+1]<<8)+(m[h+2]<<16)+(m[h+3]<<24);return k}function c(m){var k=m.length,h=[1732584193,-271733879,-1732584194,271733878],d,A,l,M,p,v;for(d=64;d<=k;d+=64)e(h,r(m.substring(d-64,d)));for(m=m.substring(d-64),A=m.length,l=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],d=0;d>2]|=m.charCodeAt(d)<<(d%4<<3);if(l[d>>2]|=128<<(d%4<<3),d>55)for(e(h,l),d=0;d<16;d+=1)l[d]=0;return M=k*8,M=M.toString(16).match(/(.*?)(.{0,8})$/),p=parseInt(M[2],16),v=parseInt(M[1],16)||0,l[14]=p,l[15]=v,e(h,l),h}function w(m){var k=m.length,h=[1732584193,-271733879,-1732584194,271733878],d,A,l,M,p,v;for(d=64;d<=k;d+=64)e(h,o(m.subarray(d-64,d)));for(m=d-64>2]|=m[d]<<(d%4<<3);if(l[d>>2]|=128<<(d%4<<3),d>55)for(e(h,l),d=0;d<16;d+=1)l[d]=0;return M=k*8,M=M.toString(16).match(/(.*?)(.{0,8})$/),p=parseInt(M[2],16),v=parseInt(M[1],16)||0,l[14]=p,l[15]=v,e(h,l),h}function C(m){var k="",h;for(h=0;h<4;h+=1)k+=s[m>>h*8+4&15]+s[m>>h*8&15];return k}function a(m){var k;for(k=0;kl?new ArrayBuffer(0):(M=l-A,p=new ArrayBuffer(M),v=new Uint8Array(p),_=new Uint8Array(this,A,M),v.set(_),p)}}();function u(m){return/[\u0080-\uFFFF]/.test(m)&&(m=unescape(encodeURIComponent(m))),m}function i(m,k){var h=m.length,d=new ArrayBuffer(h),A=new Uint8Array(d),l;for(l=0;l>2]|=k.charCodeAt(d)<<(d%4<<3);return this._finish(A,h),l=a(this._hash),m&&(l=S(l)),this.reset(),l},E.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},E.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},E.prototype.setState=function(m){return this._buff=m.buff,this._length=m.length,this._hash=m.hash,this},E.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},E.prototype._finish=function(m,k){var h=k,d,A,l;if(m[h>>2]|=128<<(h%4<<3),h>55)for(e(this._hash,m),h=0;h<16;h+=1)m[h]=0;d=this._length*8,d=d.toString(16).match(/(.*?)(.{0,8})$/),A=parseInt(d[2],16),l=parseInt(d[1],16)||0,m[14]=A,m[15]=l,e(this._hash,m)},E.hash=function(m,k){return E.hashBinary(u(m),k)},E.hashBinary=function(m,k){var h=c(m),d=a(h);return k?S(d):d},E.ArrayBuffer=function(){this.reset()},E.ArrayBuffer.prototype.append=function(m){var k=x(this._buff.buffer,m),h=k.length,d;for(this._length+=m.byteLength,d=64;d<=h;d+=64)e(this._hash,o(k.subarray(d-64,d)));return this._buff=d-64>2]|=k[A]<<(A%4<<3);return this._finish(d,h),l=a(this._hash),m&&(l=S(l)),this.reset(),l},E.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},E.ArrayBuffer.prototype.getState=function(){var m=E.prototype.getState.call(this);return m.buff=g(m.buff),m},E.ArrayBuffer.prototype.setState=function(m){return m.buff=i(m.buff,!0),E.prototype.setState.call(this,m)},E.ArrayBuffer.prototype.destroy=E.prototype.destroy,E.ArrayBuffer.prototype._finish=E.prototype._finish,E.ArrayBuffer.hash=function(m,k){var h=w(new Uint8Array(m)),d=a(h);return k?S(d):d},E})})(tr);var Gr=tr.exports;const Qr=Er(Gr),Ie={async uploadFile(t){var e,r;if(!this.validateFile(t))throw new Error("不支持的文件类型或文件大小超过限制");const n=await this.calculateMD5(t);let f=t;if(t.type.startsWith("image/"))try{f=await this.compressImage(t)}catch(o){console.warn("图片压缩失败,尝试使用原文件上传",o)}const s=await this.getOssSignature({file_hash:n,file_name:f.name});if(!((e=s.data)!=null&&e.repeat)&&((r=s.data)!=null&&r.sign_url)&&await this.uploadToOss(s.data.sign_url,f),!s.data)throw new Error("获取上传签名失败");return s.data},async createRecognitionTask(t,n,f){const s={file_url:t,file_hash:n,file_name:f,task_type:"FORMULA"};return Pe.post("/formula/recognition",s).then(e=>{if(!e.data)throw new Error("创建任务失败: 无返回数据");return e.data})},async getTaskResult(t){return Pe.get(`/formula/recognition/${t}`).then(n=>{if(!n.data)throw new Error("获取结果失败: 无返回数据");return n.data})},async getTaskList(t="FORMULA",n=1,f=5){return Pe.get(`/task/list?task_type=${t}&page=${n}&page_size=${f}`).then(s=>{if(!s.data)throw new Error("获取历史记录失败: 无返回数据");return s.data})},validateFile(t){const n=["image/jpeg","image/png","image/jpg"];return!(!t.type.startsWith("image/")&&n.indexOf(t.type)===-1&&!t.name.match(/\.(jpg|jpeg|png)$/i))},async compressImage(t){const n={maxSizeMB:5,maxWidthOrHeight:1920,useWebWorker:!0,initialQuality:.8};try{return await ce(t,n)}catch(f){throw console.error("Image compression error:",f),f}},calculateMD5(t){return new Promise((n,f)=>{const s=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,e=2097152,r=Math.ceil(t.size/e);let o=0;const c=new Qr.ArrayBuffer,w=new FileReader;w.onload=function(a){var u;(u=a.target)!=null&&u.result&&c.append(a.target.result),o++,o=t.size?t.size:a+e;w.readAsArrayBuffer(s.call(t,a,u))}C()})},async getOssSignature(t){return Pe.post("/oss/signature_url",t)},async uploadToOss(t,n){try{await fetch(t,{method:"PUT",body:n,headers:{"Content-Type":n.type||"application/octet-stream"}})}catch(f){throw console.error("Upload to OSS failed:",f),new Error("文件上传失败")}}};/** + * @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 Vr={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 Kr=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),Y=(t,n)=>{const f=H.forwardRef(({color:s="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:c="",children:w,...C},a)=>H.createElement("svg",{ref:a,...Vr,width:e,height:e,stroke:s,strokeWidth:o?Number(r)*24/Number(e):r,className:["lucide",`lucide-${Kr(t)}`,c].join(" "),...C},[...n.map(([u,i])=>H.createElement(u,i)),...Array.isArray(w)?w:[w]]));return f.displayName=`${t}`,f};/** + * @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("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 Tt=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 wt=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 vt=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 rr=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 Xr=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 nr=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 Zr=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 sr=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 Ye=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 ir=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 Ut=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 Yr=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 Jr=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 en=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 tn=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 rn=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 ar=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 Nt=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 nn=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 sn=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 an=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 on=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 or=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 ln=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 gt=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 cn=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 We=Y("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function un({onClose:t}){const{signIn:n,signUp:f}=xt(),{t:s}=ke(),[e,r]=H.useState(!1),[o,c]=H.useState(""),[w,C]=H.useState(""),[a,u]=H.useState(!1),[i,g]=H.useState(""),x=async S=>{S.preventDefault(),g(""),u(!0);try{const{error:E}=e?await f(o,w):await n(o,w);E?g(E.message):t()}catch{g("发生错误,请重试")}finally{u(!1)}};return b.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:b.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-md w-full p-6",children:[b.jsxs("div",{className:"flex justify-between items-center mb-6",children:[b.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:e?s.auth.signUpTitle:s.auth.signInTitle}),b.jsx("button",{onClick:t,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:b.jsx(We,{size:20})})]}),b.jsxs("form",{onSubmit:x,className:"space-y-4",children:[b.jsxs("div",{children:[b.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s.auth.email}),b.jsx("input",{type:"email",value:o,onChange:S=>c(S.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})]}),b.jsxs("div",{children:[b.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s.auth.password}),b.jsx("input",{type:"password",value:w,onChange:S=>C(S.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})]}),i&&b.jsxs("div",{className:"p-3 bg-red-100 border border-red-400 text-red-700 rounded-lg text-sm font-medium animate-pulse",children:[s.auth.error,": ",i]}),b.jsx("button",{type:"submit",disabled:a,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:e?s.auth.signUp:s.auth.signIn})]}),b.jsx("div",{className:"mt-4 text-center",children:b.jsx("button",{onClick:()=>r(!e),className:"text-sm text-blue-600 hover:text-blue-700",children:e?s.auth.hasAccount:s.auth.noAccount})})]})})}function dn({files:t,selectedFileId:n,onFileSelect:f,onUploadClick:s,isCollapsed:e,onToggleCollapse:r,onUploadFiles:o,hasMore:c,loadingMore:w,onLoadMore:C}){const{user:a,signOut:u}=xt(),{t:i}=ke(),[g,x]=H.useState(!1),[S,E]=H.useState(!1),m=H.useRef(null),k=H.useRef(null),h=H.useCallback(()=>{if(!k.current||w||!c)return;const{scrollTop:p,scrollHeight:v,clientHeight:_}=k.current;v-p-_<50&&C()},[w,c,C]);H.useEffect(()=>{if(!c||w||!a||t.length===0)return;const v=setTimeout(()=>{requestAnimationFrame(()=>{if(!k.current)return;const{scrollHeight:_,clientHeight:N}=k.current;_<=N&&c&&!w&&C()})},100);return()=>clearTimeout(v)},[t.length,c,w,C,a]);const d=p=>{p.preventDefault(),E(!0)},A=p=>{p.preventDefault(),E(!1)},l=p=>{p.preventDefault(),E(!1);const _=Array.from(p.dataTransfer.files).filter(N=>N.type.startsWith("image/")||N.type==="application/pdf");_.length>0&&o(_)},M=p=>{p.target.files&&p.target.files.length>0&&o(Array.from(p.target.files)),m.current&&(m.current.value="")};return e?b.jsxs("div",{className:"h-full flex flex-col items-center py-4 bg-gray-50/50",children:[b.jsx("button",{onClick:r,className:"p-2 mb-6 text-gray-500 hover:text-gray-900 hover:bg-gray-200 rounded-md transition-colors",children:b.jsx(vt,{size:20})}),b.jsx("button",{onClick:s,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:i.common.upload,children:b.jsx(gt,{size:20})}),b.jsx("div",{className:"flex-1 w-full flex flex-col items-center gap-4",children:b.jsx("button",{className:"p-2 text-gray-400 hover:text-gray-900 transition-colors",title:i.common.history,children:b.jsx(en,{size:20})})}),b.jsx("button",{onClick:()=>!a&&x(!0),className:"p-3 rounded-lg text-gray-600 hover:bg-gray-200 transition-colors mt-auto",title:a?"Signed In":i.common.login,children:b.jsx(Nt,{size:20})})]}):b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"flex flex-col h-full bg-white",children:[b.jsxs("div",{className:"p-6 pb-4",children:[b.jsxs("div",{className:"flex items-start justify-between mb-6",children:[b.jsxs("div",{children:[b.jsx("h2",{className:"text-lg font-bold text-gray-900 leading-tight",children:i.sidebar.title}),b.jsx("p",{className:"text-xs text-gray-500 mt-1",children:i.sidebar.subtitle})]}),b.jsx("button",{onClick:r,className:"p-1.5 -mr-1.5 text-gray-400 hover:text-gray-900 hover:bg-gray-100 rounded-md transition-colors",children:b.jsx(wt,{size:18})})]}),b.jsx("div",{className:"mb-2",id:"sidebar-upload-area",children:b.jsxs("div",{onDragOver:d,onDragLeave:A,onDrop:l,onClick:()=>{var p;return(p=m.current)==null?void 0:p.click()},className:` + border-2 border-dashed rounded-xl p-6 text-center cursor-pointer transition-all duration-200 group + ${S?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-blue-400 hover:bg-gray-50"} + `,children:[b.jsx("input",{type:"file",ref:m,className:"hidden",onChange:M,accept:"image/*",multiple:!0}),b.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:b.jsx(gt,{size:24})}),b.jsx("p",{className:"text-xs text-gray-500 mb-2",children:i.sidebar.uploadInstruction}),b.jsxs("div",{className:"flex items-center justify-center gap-4 text-xs text-gray-400",children:[b.jsxs("div",{className:"flex items-center gap-1",children:[b.jsx(or,{className:"w-3.5 h-3.5"}),b.jsx("span",{children:i.common.click})]}),b.jsxs("div",{className:"flex items-center gap-1",children:[b.jsx(ir,{className:"w-3.5 h-3.5"}),b.jsx("span",{children:i.common.drop})]}),b.jsxs("div",{className:"flex items-center gap-1",children:[b.jsx(rr,{className:"w-3.5 h-3.5"}),b.jsx("span",{children:i.common.paste})]})]})]})})]}),b.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col px-4",id:"sidebar-history",children:[b.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3 px-2",children:[b.jsx(Xr,{size:14}),b.jsx("span",{children:i.sidebar.historyHeader})]}),b.jsx("div",{ref:k,onScroll:h,className:"flex-1 overflow-y-auto space-y-1 pr-2 -mr-2 custom-scrollbar",children:a?t.length===0?b.jsxs("div",{className:"text-center py-12 text-gray-400 text-sm",children:[b.jsx("div",{className:"mb-2 opacity-50",children:b.jsx(Ye,{size:40,className:"mx-auto"})}),i.sidebar.noHistory]}):b.jsxs(b.Fragment,{children:[t.map(p=>b.jsx("button",{onClick:()=>f(p.id),className:`w-full p-3 rounded-lg text-left transition-all border group relative ${n===p.id?"bg-blue-50 border-blue-200 shadow-sm":"bg-white border-transparent hover:bg-gray-50 hover:border-gray-100"}`,children:b.jsxs("div",{className:"flex items-start gap-3",children:[b.jsx("div",{className:`p-2 rounded-lg ${n===p.id?"bg-blue-100 text-blue-600":"bg-gray-100 text-gray-500 group-hover:bg-gray-200"}`,children:b.jsx(Ye,{size:18})}),b.jsxs("div",{className:"flex-1 min-w-0",children:[b.jsx("p",{className:`text-sm font-medium truncate ${n===p.id?"text-blue-900":"text-gray-700"}`,children:p.filename}),b.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[b.jsx("span",{className:"text-xs text-gray-400",children:new Date(p.created_at).toLocaleDateString()}),b.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${p.status==="completed"?"bg-green-500":p.status==="processing"?"bg-yellow-500":"bg-red-500"}`})]})]})]})},p.id)),w&&b.jsxs("div",{className:"flex items-center justify-center py-3 text-gray-400",children:[b.jsx(ar,{size:18,className:"animate-spin"}),b.jsx("span",{className:"ml-2 text-xs",children:i.common.loading})]}),!c&&t.length>0&&b.jsx("div",{className:"text-center py-3 text-xs text-gray-400",children:i.sidebar.noMore})]}):b.jsxs("div",{className:"text-center py-12 text-gray-400 text-sm",children:[b.jsx("div",{className:"mb-2 opacity-50",children:b.jsx(Ye,{size:40,className:"mx-auto"})}),i.sidebar.pleaseLogin]})})]}),b.jsx("div",{className:"p-4 border-t border-gray-100 bg-gray-50/30",children:a?b.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-white border border-gray-100 shadow-sm",children:[b.jsx("div",{className:"w-8 h-8 bg-gray-900 rounded-full flex items-center justify-center flex-shrink-0",children:b.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.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"})})}),b.jsx("div",{className:"flex-1 min-w-0",children:b.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",children:a.email})}),b.jsx("button",{onClick:()=>u(),className:"p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-md transition-colors",title:i.common.logout,children:b.jsx(nn,{size:16})})]}):b.jsxs("button",{onClick:()=>x(!0),className:"w-full py-2.5 px-4 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors flex items-center justify-center gap-2 text-sm font-medium shadow-lg shadow-gray-900/10",children:[b.jsx(Nt,{size:18}),i.common.login]})})]}),g&&b.jsx(un,{onClose:()=>x(!1)})]})}function fn(){const{language:t,setLanguage:n,t:f}=ke(),[s,e]=H.useState(!1),[r,o]=H.useState(!1),[c,w]=H.useState(!1),[C,a]=H.useState(!1),u=H.useRef(null),i=H.useRef(null),g=async()=>{await navigator.clipboard.writeText("1018282100"),a(!0),setTimeout(()=>a(!1),2e3)};return H.useEffect(()=>{const x=S=>{u.current&&!u.current.contains(S.target)&&e(!1),i.current&&!i.current.contains(S.target)&&w(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]),b.jsxs("div",{className:"h-16 bg-white border-b border-gray-200 flex items-center justify-between px-6 flex-shrink-0 z-[60] relative",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("span",{className:"w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center text-white font-serif italic text-lg shadow-blue-600/30 shadow-md",children:"T"}),b.jsx("span",{className:"text-xl font-bold text-gray-900 tracking-tight",children:"TexPixel"})]}),b.jsxs("div",{className:"flex items-center gap-3",children:[b.jsxs("div",{className:"relative",ref:i,children:[b.jsxs("button",{onClick:()=>w(!c),className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 rounded-lg text-gray-700 text-sm font-medium transition-colors",title:"Switch Language",children:[b.jsx(rn,{size:18}),b.jsx("span",{className:"hidden sm:inline",children:t==="en"?"English":"简体中文"}),b.jsx(Tt,{size:14,className:`transition-transform duration-200 ${c?"rotate-180":""}`})]}),c&&b.jsxs("div",{className:"absolute right-0 top-full mt-2 w-32 bg-white rounded-xl shadow-lg border border-gray-200 py-1 z-50 animate-in fade-in slide-in-from-top-2 duration-200",children:[b.jsxs("button",{onClick:()=>{n("en"),w(!1)},className:`w-full flex items-center justify-between px-4 py-2 text-sm transition-colors hover:bg-gray-50 ${t==="en"?"text-blue-600 font-medium":"text-gray-700"}`,children:["English",t==="en"&&b.jsx(Ze,{size:14})]}),b.jsxs("button",{onClick:()=>{n("zh"),w(!1)},className:`w-full flex items-center justify-between px-4 py-2 text-sm transition-colors hover:bg-gray-50 ${t==="zh"?"text-blue-600 font-medium":"text-gray-700"}`,children:["简体中文",t==="zh"&&b.jsx(Ze,{size:14})]})]})]}),b.jsxs("button",{id:"guide-button",className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 rounded-lg text-gray-700 text-sm font-medium transition-colors",onClick:()=>{window.dispatchEvent(new CustomEvent("start-user-guide"))},children:[b.jsx(Jr,{size:18}),b.jsx("span",{className:"hidden sm:inline",children:f.common.guide})]}),b.jsxs("div",{className:"relative",children:[b.jsxs("button",{onClick:()=>o(!r),className:"flex items-center gap-2 px-4 py-2 bg-gradient-to-r from-rose-500 to-pink-500 hover:from-rose-600 hover:to-pink-600 rounded-lg text-white text-sm font-medium transition-all shadow-sm hover:shadow-md",children:[b.jsx(Yr,{size:14,className:"fill-white"}),b.jsx("span",{children:f.common.reward})]}),r&&b.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[70] p-4",onClick:()=>o(!1),children:b.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-sm w-full p-6 animate-in fade-in zoom-in-95 duration-200",onClick:x=>x.stopPropagation(),children:[b.jsxs("div",{className:"flex items-center justify-between mb-4",children:[b.jsx("span",{className:"text-lg font-bold text-gray-900",children:f.navbar.rewardTitle}),b.jsx("button",{onClick:()=>o(!1),className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:b.jsx(We,{size:20,className:"text-gray-500"})})]}),b.jsxs("div",{className:"flex flex-col items-center",children:[b.jsx("img",{src:"https://cdn.texpixel.com/public/rewardcode.png",alt:f.navbar.rewardTitle,className:"w-64 h-64 object-contain rounded-lg shadow-sm"}),b.jsxs("p",{className:"text-sm text-gray-500 text-center mt-4",children:[f.navbar.rewardThanks,b.jsx("br",{}),b.jsx("span",{className:"text-xs text-gray-400 mt-1 block",children:f.navbar.rewardSubtitle})]})]})]})})]}),b.jsxs("div",{className:"relative",ref:u,children:[b.jsxs("button",{onClick:()=>e(!s),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg text-gray-700 text-sm font-medium transition-colors",children:[b.jsx(an,{size:14}),b.jsx("span",{children:f.common.contactUs}),b.jsx(Tt,{size:14,className:`transition-transform duration-200 ${s?"rotate-180":""}`})]}),s&&b.jsxs("div",{className:"absolute right-0 top-full mt-2 w-64 bg-white rounded-xl shadow-lg border border-gray-200 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-200",children:[b.jsxs("a",{href:"mailto:yogecoder@gmail.com",className:"flex items-center gap-3 px-4 py-3 hover:bg-gray-50 transition-colors",children:[b.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center",children:b.jsx(sn,{size:16,className:"text-blue-600"})}),b.jsxs("div",{children:[b.jsx("div",{className:"text-xs text-gray-500",children:f.common.email}),b.jsx("div",{className:"text-sm font-medium text-gray-900",children:"yogecoder@gmail.com"})]})]}),b.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 hover:bg-gray-50 transition-all cursor-pointer ${C?"bg-green-50":""}`,onClick:g,children:[b.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center transition-colors ${C?"bg-green-500":"bg-green-100"}`,children:C?b.jsx(Ze,{size:16,className:"text-white"}):b.jsx(cn,{size:16,className:"text-green-600"})}),b.jsxs("div",{children:[b.jsx("div",{className:`text-xs transition-colors ${C?"text-green-600 font-medium":"text-gray-500"}`,children:C?f.common.copied:f.common.qqGroup}),b.jsx("div",{className:"text-sm font-medium text-gray-900",children:"1018282100"})]})]})]})]})]})]})}function hn({file:t}){const{t:n}=ke(),[f,s]=H.useState(100),[e,r]=H.useState(1),o=1,c=()=>s(C=>Math.min(C+10,200)),w=()=>s(C=>Math.max(C-10,50));return t?b.jsxs("div",{className:"flex flex-col h-full bg-gray-100/50",children:[b.jsxs("div",{className:"h-16 flex items-center justify-between px-6 bg-white border-b border-gray-200 z-10 relative",children:[b.jsxs("div",{className:"flex items-center gap-3 overflow-hidden z-20",children:[b.jsx("div",{className:"p-2 bg-blue-50 text-blue-600 rounded-lg",children:b.jsx(Ut,{size:18})}),b.jsx("h2",{className:"text-sm font-semibold text-gray-900 truncate max-w-[200px]",title:t.filename,children:t.filename})]}),b.jsxs("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 flex items-center gap-4 z-10",children:[b.jsxs("div",{className:"flex items-center gap-1",children:[b.jsx("button",{onClick:()=>r(C=>Math.max(1,C-1)),disabled:e===1,className:"p-1 hover:bg-white hover:shadow-sm rounded-md text-gray-500 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:shadow-none transition-all",children:b.jsx(wt,{size:16})}),b.jsxs("span",{className:"text-xs font-medium text-gray-600 px-1 select-none min-w-[3rem] text-center",children:[e," / ",o]}),b.jsx("button",{onClick:()=>r(C=>Math.min(o,C+1)),disabled:e===o,className:"p-1 hover:bg-white hover:shadow-sm rounded-md text-gray-500 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:shadow-none transition-all",children:b.jsx(vt,{size:16})})]}),b.jsxs("div",{className:"flex items-center gap-1",children:[b.jsx("button",{onClick:w,className:"p-1 hover:bg-white hover:shadow-sm rounded-md text-gray-500 transition-all",title:n.common.preview,children:b.jsx(on,{size:16})}),b.jsxs("span",{className:"text-xs font-medium text-gray-600 min-w-[2.5rem] text-center select-none",children:[f,"%"]}),b.jsx("button",{onClick:c,className:"p-1 hover:bg-white hover:shadow-sm rounded-md text-gray-500 transition-all",title:n.common.preview,children:b.jsx(ln,{size:16})})]})]})]}),b.jsx("div",{className:"flex-1 overflow-auto p-8 relative custom-scrollbar flex items-center justify-center border-r border-gray-200",children:b.jsx("div",{className:"bg-white shadow-2xl shadow-gray-200/50 transition-transform duration-200 ease-out origin-center max-w-full max-h-full flex items-center justify-center",style:{transform:`scale(${f/100})`},children:t.file_type==="application/pdf"?b.jsx("div",{className:"w-[595px] h-[842px] flex items-center justify-center bg-gray-50 border border-gray-100",children:b.jsx("p",{className:"text-gray-400",children:"PDF Preview Not Implemented"})}):b.jsx("img",{src:t.file_path||"https://images.pexels.com/photos/326514/pexels-photo-326514.jpeg?auto=compress&cs=tinysrgb&w=800",alt:t.filename,className:"max-w-full max-h-full object-contain block",draggable:!1})})})]}):b.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-white p-8 text-center border border-white border-solid",id:"file-preview-empty",children:[b.jsx("div",{className:"w-32 h-32 bg-gray-100 rounded-full flex items-center justify-center mb-6 shadow-inner",children:b.jsx(Ut,{size:48,className:"text-gray-900"})}),b.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:n.common.upload}),b.jsx("p",{className:"text-gray-500 max-w-xs",children:n.sidebar.uploadInstruction})]})}function gn(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function mn(t,n,f){const e=vr({}.ignore||[]),r=pn(n);let o=-1;for(;++o0?{type:"text",value:l}:void 0),l===!1?i.lastIndex=d+1:(x!==d&&k.push({type:"text",value:C.value.slice(x,d)}),Array.isArray(l)?k.push(...l):l&&k.push(l),x=d+h[0].length,m=!0),!i.global)break;h=i.exec(C.value)}return m?(x{let t=0;const n=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${n()}${t}`)})();function Te(t){const n=[];for(let f=0,s=t.length;fpe||t.height>pe)&&(t.width>pe&&t.height>pe?t.width>t.height?(t.height*=pe/t.width,t.width=pe):(t.width*=pe/t.height,t.height=pe):t.width>pe?(t.height*=pe/t.width,t.width=pe):(t.width*=pe/t.height,t.height=pe))}function _n(t,n={}){return t.toBlob?new Promise(f=>{t.toBlob(f,n.type?n.type:"image/png",n.quality?n.quality:1)}):new Promise(f=>{const s=window.atob(t.toDataURL(n.type?n.type:void 0,n.quality?n.quality:void 0).split(",")[1]),e=s.length,r=new Uint8Array(e);for(let o=0;o{const s=new Image;s.onload=()=>{s.decode().then(()=>{requestAnimationFrame(()=>n(s))})},s.onerror=f,s.crossOrigin="anonymous",s.decoding="async",s.src=t})}async function Tn(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(n=>`data:image/svg+xml;charset=utf-8,${n}`)}async function Un(t,n,f){const s="http://www.w3.org/2000/svg",e=document.createElementNS(s,"svg"),r=document.createElementNS(s,"foreignObject");return e.setAttribute("width",`${n}`),e.setAttribute("height",`${f}`),e.setAttribute("viewBox",`0 0 ${n} ${f}`),r.setAttribute("width","100%"),r.setAttribute("height","100%"),r.setAttribute("x","0"),r.setAttribute("y","0"),r.setAttribute("externalResourcesRequired","true"),e.appendChild(r),r.appendChild(t),Tn(e)}const he=(t,n)=>{if(t instanceof n)return!0;const f=Object.getPrototypeOf(t);return f===null?!1:f.constructor.name===n.name||he(f,n)};function Nn(t){const n=t.getPropertyValue("content");return`${t.cssText} content: '${n.replace(/'|"/g,"")}';`}function Fn(t,n){return lr(n).map(f=>{const s=t.getPropertyValue(f),e=t.getPropertyPriority(f);return`${f}: ${s}${e?" !important":""};`}).join(" ")}function Rn(t,n,f,s){const e=`.${t}:${n}`,r=f.cssText?Nn(f):Fn(f,s);return document.createTextNode(`${e}{${r}}`)}function Ft(t,n,f,s){const e=window.getComputedStyle(t,f),r=e.getPropertyValue("content");if(r===""||r==="none")return;const o=jn();try{n.className=`${n.className} ${o}`}catch{return}const c=document.createElement("style");c.appendChild(Rn(o,f,e,s)),n.appendChild(c)}function In(t,n,f){Ft(t,n,":before",f),Ft(t,n,":after",f)}const Rt="application/font-woff",It="image/jpeg",Mn={woff:Rt,woff2:Rt,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:It,jpeg:It,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Pn(t){const n=/\.([^./]*?)$/g.exec(t);return n?n[1]:""}function At(t){const n=Pn(t).toLowerCase();return Mn[n]||""}function Ln(t){return t.split(/,/)[1]}function mt(t){return t.search(/^(data:)/)!==-1}function zn(t,n){return`data:${n};base64,${t}`}async function ur(t,n,f){const s=await fetch(t,n);if(s.status===404)throw new Error(`Resource "${s.url}" not found`);const e=await s.blob();return new Promise((r,o)=>{const c=new FileReader;c.onerror=o,c.onloadend=()=>{try{r(f({res:s,result:c.result}))}catch(w){o(w)}},c.readAsDataURL(e)})}const ht={};function $n(t,n,f){let s=t.replace(/\?.*/,"");return f&&(s=t),/ttf|otf|eot|woff2?/i.test(s)&&(s=s.replace(/.*\//,"")),n?`[${n}]${s}`:s}async function jt(t,n,f){const s=$n(t,n,f.includeQueryParams);if(ht[s]!=null)return ht[s];f.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let e;try{const r=await ur(t,f.fetchRequestInit,({res:o,result:c})=>(n||(n=o.headers.get("Content-Type")||""),Ln(c)));e=zn(r,n)}catch(r){e=f.imagePlaceholder||"";let o=`Failed to fetch resource: ${t}`;r&&(o=typeof r=="string"?r:r.message),o&&console.warn(o)}return ht[s]=e,e}async function Dn(t){const n=t.toDataURL();return n==="data:,"?t.cloneNode(!1):st(n)}async function On(t,n){if(t.currentSrc){const r=document.createElement("canvas"),o=r.getContext("2d");r.width=t.clientWidth,r.height=t.clientHeight,o==null||o.drawImage(t,0,0,r.width,r.height);const c=r.toDataURL();return st(c)}const f=t.poster,s=At(f),e=await jt(f,s,n);return st(e)}async function Hn(t,n){var f;try{if(!((f=t==null?void 0:t.contentDocument)===null||f===void 0)&&f.body)return await at(t.contentDocument.body,n,!0)}catch{}return t.cloneNode(!1)}async function Bn(t,n){return he(t,HTMLCanvasElement)?Dn(t):he(t,HTMLVideoElement)?On(t,n):he(t,HTMLIFrameElement)?Hn(t,n):t.cloneNode(dr(t))}const qn=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",dr=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function Wn(t,n,f){var s,e;if(dr(n))return n;let r=[];return qn(t)&&t.assignedNodes?r=Te(t.assignedNodes()):he(t,HTMLIFrameElement)&&(!((s=t.contentDocument)===null||s===void 0)&&s.body)?r=Te(t.contentDocument.body.childNodes):r=Te(((e=t.shadowRoot)!==null&&e!==void 0?e:t).childNodes),r.length===0||he(t,HTMLVideoElement)||await r.reduce((o,c)=>o.then(()=>at(c,f)).then(w=>{w&&n.appendChild(w)}),Promise.resolve()),n}function Gn(t,n,f){const s=n.style;if(!s)return;const e=window.getComputedStyle(t);e.cssText?(s.cssText=e.cssText,s.transformOrigin=e.transformOrigin):lr(f).forEach(r=>{let o=e.getPropertyValue(r);r==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),he(t,HTMLIFrameElement)&&r==="display"&&o==="inline"&&(o="block"),r==="d"&&n.getAttribute("d")&&(o=`path(${n.getAttribute("d")})`),s.setProperty(r,o,e.getPropertyPriority(r))})}function Qn(t,n){he(t,HTMLTextAreaElement)&&(n.innerHTML=t.value),he(t,HTMLInputElement)&&n.setAttribute("value",t.value)}function Vn(t,n){if(he(t,HTMLSelectElement)){const f=n,s=Array.from(f.children).find(e=>t.value===e.getAttribute("value"));s&&s.setAttribute("selected","")}}function Kn(t,n,f){return he(n,Element)&&(Gn(t,n,f),In(t,n,f),Qn(t,n),Vn(t,n)),n}async function Xn(t,n){const f=t.querySelectorAll?t.querySelectorAll("use"):[];if(f.length===0)return t;const s={};for(let r=0;rBn(s,n)).then(s=>Wn(t,s,n)).then(s=>Kn(t,s,n)).then(s=>Xn(s,n))}const fr=/url\((['"]?)([^'"]+?)\1\)/g,Zn=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Yn=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Jn(t){const n=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${n})(['"]?\\))`,"g")}function es(t){const n=[];return t.replace(fr,(f,s,e)=>(n.push(e),f)),n.filter(f=>!mt(f))}async function ts(t,n,f,s,e){try{const r=f?An(n,f):n,o=At(n);let c;return e||(c=await jt(r,o,s)),t.replace(Jn(n),`$1${c}$3`)}catch{}return t}function rs(t,{preferredFontFormat:n}){return n?t.replace(Yn,f=>{for(;;){const[s,,e]=Zn.exec(f)||[];if(!e)return"";if(e===n)return`src: ${s};`}}):t}function hr(t){return t.search(fr)!==-1}async function gr(t,n,f){if(!hr(t))return t;const s=rs(t,f);return es(s).reduce((r,o)=>r.then(c=>ts(c,o,n,f)),Promise.resolve(s))}async function De(t,n,f){var s;const e=(s=n.style)===null||s===void 0?void 0:s.getPropertyValue(t);if(e){const r=await gr(e,null,f);return n.style.setProperty(t,r,n.style.getPropertyPriority(t)),!0}return!1}async function ns(t,n){await De("background",t,n)||await De("background-image",t,n),await De("mask",t,n)||await De("-webkit-mask",t,n)||await De("mask-image",t,n)||await De("-webkit-mask-image",t,n)}async function ss(t,n){const f=he(t,HTMLImageElement);if(!(f&&!mt(t.src))&&!(he(t,SVGImageElement)&&!mt(t.href.baseVal)))return;const s=f?t.src:t.href.baseVal,e=await jt(s,At(s),n);await new Promise((r,o)=>{t.onload=r,t.onerror=n.onImageErrorHandler?(...w)=>{try{r(n.onImageErrorHandler(...w))}catch(C){o(C)}}:o;const c=t;c.decode&&(c.decode=r),c.loading==="lazy"&&(c.loading="eager"),f?(t.srcset="",t.src=e):t.href.baseVal=e})}async function is(t,n){const s=Te(t.childNodes).map(e=>mr(e,n));await Promise.all(s).then(()=>t)}async function mr(t,n){he(t,Element)&&(await ns(t,n),await ss(t,n),await is(t,n))}function as(t,n){const{style:f}=t;n.backgroundColor&&(f.backgroundColor=n.backgroundColor),n.width&&(f.width=`${n.width}px`),n.height&&(f.height=`${n.height}px`);const s=n.style;return s!=null&&Object.keys(s).forEach(e=>{f[e]=s[e]}),t}const Mt={};async function Pt(t){let n=Mt[t];if(n!=null)return n;const s=await(await fetch(t)).text();return n={url:t,cssText:s},Mt[t]=n,n}async function Lt(t,n){let f=t.cssText;const s=/url\(["']?([^"')]+)["']?\)/g,r=(f.match(/url\([^)]+\)/g)||[]).map(async o=>{let c=o.replace(s,"$1");return c.startsWith("https://")||(c=new URL(c,t.url).href),ur(c,n.fetchRequestInit,({result:w})=>(f=f.replace(o,`url(${w})`),[o,w]))});return Promise.all(r).then(()=>f)}function zt(t){if(t==null)return[];const n=[],f=/(\/\*[\s\S]*?\*\/)/gi;let s=t.replace(f,"");const e=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const w=e.exec(s);if(w===null)break;n.push(w[0])}s=s.replace(e,"");const r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(o,"gi");for(;;){let w=r.exec(s);if(w===null){if(w=c.exec(s),w===null)break;r.lastIndex=c.lastIndex}else c.lastIndex=r.lastIndex;n.push(w[0])}return n}async function os(t,n){const f=[],s=[];return t.forEach(e=>{if("cssRules"in e)try{Te(e.cssRules||[]).forEach((r,o)=>{if(r.type===CSSRule.IMPORT_RULE){let c=o+1;const w=r.href,C=Pt(w).then(a=>Lt(a,n)).then(a=>zt(a).forEach(u=>{try{e.insertRule(u,u.startsWith("@import")?c+=1:e.cssRules.length)}catch(i){console.error("Error inserting rule from remote css",{rule:u,error:i})}})).catch(a=>{console.error("Error loading remote css",a.toString())});s.push(C)}})}catch(r){const o=t.find(c=>c.href==null)||document.styleSheets[0];e.href!=null&&s.push(Pt(e.href).then(c=>Lt(c,n)).then(c=>zt(c).forEach(w=>{o.insertRule(w,o.cssRules.length)})).catch(c=>{console.error("Error loading remote stylesheet",c)})),console.error("Error inlining remote css file",r)}}),Promise.all(s).then(()=>(t.forEach(e=>{if("cssRules"in e)try{Te(e.cssRules||[]).forEach(r=>{f.push(r)})}catch(r){console.error(`Error while reading CSS rules from ${e.href}`,r)}}),f))}function ls(t){return t.filter(n=>n.type===CSSRule.FONT_FACE_RULE).filter(n=>hr(n.style.getPropertyValue("src")))}async function cs(t,n){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const f=Te(t.ownerDocument.styleSheets),s=await os(f,n);return ls(s)}function pr(t){return t.trim().replace(/["']/g,"")}function us(t){const n=new Set;function f(s){(s.style.fontFamily||getComputedStyle(s).fontFamily).split(",").forEach(r=>{n.add(pr(r))}),Array.from(s.children).forEach(r=>{r instanceof HTMLElement&&f(r)})}return f(t),n}async function ds(t,n){const f=await cs(t,n),s=us(t);return(await Promise.all(f.filter(r=>s.has(pr(r.style.fontFamily))).map(r=>{const o=r.parentStyleSheet?r.parentStyleSheet.href:null;return gr(r.cssText,o,n)}))).join(` +`)}async function fs(t,n){const f=n.fontEmbedCSS!=null?n.fontEmbedCSS:n.skipFonts?null:await ds(t,n);if(f){const s=document.createElement("style"),e=document.createTextNode(f);s.appendChild(e),t.firstChild?t.insertBefore(s,t.firstChild):t.appendChild(s)}}async function xr(t,n={}){const{width:f,height:s}=cr(t,n),e=await at(t,n,!0);return await fs(e,n),await mr(e,n),as(e,n),await Un(e,f,s)}async function yr(t,n={}){const{width:f,height:s}=cr(t,n),e=await xr(t,n),r=await st(e),o=document.createElement("canvas"),c=o.getContext("2d"),w=n.pixelRatio||Sn(),C=n.canvasWidth||f,a=n.canvasHeight||s;return o.width=C*w,o.height=a*w,n.skipAutoScale||En(o),o.style.width=`${C}`,o.style.height=`${a}`,n.backgroundColor&&(c.fillStyle=n.backgroundColor,c.fillRect(0,0,o.width,o.height)),c.drawImage(r,0,0,o.width,o.height),o}async function hs(t,n={}){return(await yr(t,n)).toDataURL()}async function gs(t,n={}){const f=await yr(t,n);return await _n(f)}const ms={backgroundColor:"#ffffff",padding:20,fontSize:20,scale:2,format:"png"};async function ps(){const t=["KaTeX_Main","KaTeX_Math","KaTeX_Size1","KaTeX_Size2","KaTeX_Size3","KaTeX_Size4"];await document.fonts.ready;const n=()=>t.some(s=>{try{return document.fonts.check(`16px ${s}`)}catch{return!1}}),f=20;for(let s=0;ssetTimeout(e,100))}}async function xs(t,n={}){const f=document.getElementById(t);if(!f)throw new Error(`Element with ID "${t}" not found`);const s={...ms,...n};await ps(),await new Promise(o=>setTimeout(o,100));const e={backgroundColor:s.backgroundColor,pixelRatio:s.scale,cacheBust:!0,width:f.scrollWidth+s.padding*2,height:f.scrollHeight+s.padding*2,style:{padding:`${s.padding}px`,transform:"none",overflow:"visible",visibility:"visible",display:"block",height:"auto",maxHeight:"none"},skipFonts:!1};let r;try{switch(s.format){case"svg":r=await xr(f,e);break;case"blob":r=await gs(f,e);break;case"png":default:r=await hs(f,e);break}return r}catch(o){throw console.error("Element image generation failed:",o),o}}async function ys(t){let n;typeof t=="string"?n=await(await fetch(t)).blob():n=t,await navigator.clipboard.write([new ClipboardItem({[n.type]:n})])}const bs=(t,n,f)=>{try{const s={task_no:t,event_name:"export_selected_event",properties:{option:f,selected:n},meta_data:{task_no:t},device_info:{ip:"","use-agent":navigator.userAgent,browser:ws()}};Pe.post("/analytics/track",s).catch(e=>{console.debug("Analytics tracking failed:",e)})}catch(s){console.debug("Analytics error:",s)}};function ws(){const t=navigator.userAgent;return t.match(/chrome|chromium|crios/i)?"Chrome":t.match(/firefox|fxios/i)?"Firefox":t.match(/safari/i)?"Safari":t.match(/opr\//i)?"Opera":t.match(/edg/i)?"Edge":"Unknown"}function vs({isOpen:t,onClose:n,result:f}){const{t:s}=ke(),[e,r]=H.useState(null),[o,c]=H.useState(null);if(!f)return null;const w=[{id:"markdown",label:"Markdown",category:"Code",getContent:g=>g.markdown_content},{id:"latex_inline",label:"LaTeX (Inline)",category:"Code",getContent:g=>g.latex_content?`\\(${g.latex_content.replace(/^\\\[/,"").replace(/\\\]$/,"").trim()}\\)`:null},{id:"latex_display",label:"LaTeX (Display)",category:"Code",getContent:g=>g.latex_content},{id:"mathml",label:"MathML",category:"Code",getContent:g=>g.mathml_content},{id:"mathml_mml",label:"MathML (MML)",category:"Code",getContent:g=>g.mml},{id:"rendered_image",label:"Rendered Image",category:"Image",getContent:g=>g.markdown_content},{id:"docx",label:"DOCX",category:"File",getContent:g=>g.markdown_content,isDownload:!0,extension:"docx"}],C=async g=>{if(f!=null&&f.id){c(g);try{const x=ye.getToken(),S=await fetch(`${Ot}/task/export`,{method:"POST",headers:{"Content-Type":"application/json",...x?{Authorization:x}:{}},body:JSON.stringify({task_no:f.id,type:g})});if(!S.ok)throw new Error(`Export failed: ${S.statusText}`);const E=await S.blob(),m=URL.createObjectURL(E),k=document.createElement("a");k.href=m,k.download=`export.${g}`,document.body.appendChild(k),k.click(),document.body.removeChild(k),URL.revokeObjectURL(m),r(g),setTimeout(()=>{r(null),n()},1e3)}catch(x){console.error("Export failed:",x),alert(s.export.failed)}finally{c(null)}}},a=async g=>{const x="markdown-preview-content";c("rendered_image");try{const S=await xs(x,{format:"png",scale:2,padding:24});g==="copy"&&await ys(S),r("rendered_image"),setTimeout(()=>{r(null),n()},1e3)}catch(S){console.error("Failed to generate image:",S),alert(`${s.export.imageFailed}: ${S}`)}finally{c(null)}},u=async g=>{if(f!=null&&f.id&&bs(f.id,g.id,w.map(S=>S.id)),g.id==="docx"){await C("docx");return}if(g.id==="rendered_image"){await a("copy");return}const x=g.getContent(f);if(x){c(g.id);try{if(g.isDownload){const S=new Blob([x],{type:"text/plain"}),E=URL.createObjectURL(S),m=document.createElement("a");m.href=E,m.download=`export.${g.extension}`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(E)}else await navigator.clipboard.writeText(x);r(g.id),setTimeout(()=>{r(null),n()},1e3)}catch(S){console.error("Action failed:",S)}finally{c(null)}}},i=[{id:"Code",icon:nr,label:s.export.categories.code},{id:"Image",icon:tn,label:s.export.categories.image},{id:"File",icon:Ye,label:s.export.categories.file}];return b.jsxs(b.Fragment,{children:[t&&b.jsx("div",{className:"absolute inset-0 bg-black/20 backdrop-blur-[1px] z-40 transition-opacity",onClick:n}),b.jsxs("div",{className:` + 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 + ${t?"translate-x-0":"translate-x-full"} + `,children:[b.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-gray-100 shrink-0",children:[b.jsx("h2",{className:"text-lg font-bold text-gray-900",children:s.export.title}),b.jsx("button",{onClick:n,className:"p-2 hover:bg-gray-100 rounded-full transition-colors",children:b.jsx(We,{size:20,className:"text-gray-500"})})]}),b.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-8",children:i.map(g=>b.jsxs("div",{className:"space-y-3",children:[b.jsxs("div",{className:"flex items-center gap-2 text-gray-400 px-1",children:[b.jsx(g.icon,{size:16}),b.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",children:g.label})]}),b.jsx("div",{className:"space-y-2",children:w.filter(x=>x.category===g.id).map(x=>b.jsxs("button",{onClick:()=>u(x),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:[b.jsx("span",{className:"text-sm font-medium text-gray-700 group-hover:text-blue-700",children:x.label}),b.jsx("div",{className:"text-gray-400 group-hover:text-blue-600",children:o===x.id?b.jsx(ar,{size:16,className:"animate-spin text-blue-500"}):e===x.id?b.jsx(Ze,{size:16,className:"text-green-500"}):x.isDownload?b.jsx(sr,{size:16}):b.jsx(Zr,{size:16,className:"opacity-0 group-hover:opacity-100 transition-opacity"})})]},x.id))})]},g.id))})]})]})}function As(t){if(!t)return"";let n=t;return n=n.replace(/\$\$\s*\\\[/g,"$$$$"),n=n.replace(/\\\]\s*\$\$/g,"$$$$"),n=n.replace(new RegExp("(?e(!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 ${s?"opacity-0 pointer-events-none":""}`,children:[b.jsx(sr,{size:16}),f.common.export]})]}),b.jsx("div",{className:"flex-1 overflow-auto p-8 custom-scrollbar flex justify-center",children:b.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:b.jsx(jr,{remarkPlugins:[Cr,vn],rehypePlugins:[[kr,{throwOnError:!1,errorColor:"#cc0000",strict:!1}]],children:As(t.markdown_content||"")})})}),b.jsx(vs,{isOpen:s,onClose:()=>e(!1),result:t})]}):n==="processing"||n==="pending"?b.jsxs("div",{className:"h-full flex flex-col items-center justify-center bg-white text-center p-8",children:[b.jsx("div",{className:"w-16 h-16 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mb-6"}),b.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:n==="pending"?f.resultPanel.waitingQueue:f.resultPanel.analyzing}),b.jsx("p",{className:"text-gray-500 max-w-sm",children:n==="pending"?f.resultPanel.queueSubtitle:f.resultPanel.processingSubtitle})]}):b.jsxs("div",{className:"h-full flex flex-col items-center justify-center bg-white text-center p-8",id:"result-empty-state",children:[b.jsx("div",{className:"w-32 h-32 bg-gray-100 rounded-full flex items-center justify-center mb-6 shadow-inner",children:b.jsx(nr,{size:48,className:"text-gray-900"})}),b.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:f.resultPanel.waitingTitle}),b.jsx("p",{className:"text-gray-500 max-w-sm",children:f.resultPanel.waitingSubtitle})]})}function Cs({onClose:t,onUpload:n}){const{t:f}=ke(),[s,e]=H.useState(!1),r=H.useRef(null);H.useEffect(()=>{const C=a=>{var g;const u=(g=a.clipboardData)==null?void 0:g.items;if(!u)return;const i=[];for(let x=0;x0&&(n(i),t())};return document.addEventListener("paste",C),()=>document.removeEventListener("paste",C)},[n,t]);const o=H.useCallback(C=>{C.preventDefault(),C.stopPropagation(),C.type==="dragenter"||C.type==="dragover"?e(!0):C.type==="dragleave"&&e(!1)},[]),c=H.useCallback(C=>{C.preventDefault(),C.stopPropagation(),e(!1);const a=Array.from(C.dataTransfer.files).filter(u=>u.type.startsWith("image/")||u.type==="application/pdf");a.length>0&&(n(a),t())},[n,t]),w=C=>{if(C.target.files){const a=Array.from(C.target.files).filter(u=>u.type.startsWith("image/")||u.type==="application/pdf");a.length>0&&(n(a),t())}};return b.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:b.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-2xl w-full p-6",children:[b.jsxs("div",{className:"flex justify-between items-center mb-6",children:[b.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:f.uploadModal.title}),b.jsx("button",{onClick:t,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:b.jsx(We,{size:20})})]}),b.jsxs("div",{onDragEnter:o,onDragLeave:o,onDragOver:o,onDrop:c,onClick:()=>{var C;return(C=r.current)==null?void 0:C.click()},className:`border-2 border-dashed rounded-xl p-12 text-center transition-colors cursor-pointer group ${s?"border-blue-500 bg-blue-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"}`,children:[b.jsx("div",{className:"w-16 h-16 bg-gray-100 text-gray-600 rounded-full flex items-center justify-center mx-auto mb-4 group-hover:scale-110 transition-transform",children:b.jsx(gt,{size:32})}),b.jsx("p",{className:"text-sm text-gray-600 mb-1",children:f.sidebar.uploadInstruction}),b.jsx("input",{ref:r,type:"file",multiple:!0,accept:"image/*,application/pdf",onChange:w,className:"hidden"}),b.jsx("p",{className:"text-xs text-gray-500 mb-4",children:f.uploadModal.supportFormats}),b.jsxs("div",{className:"flex items-center justify-center gap-4 mt-6 text-xs text-gray-400",children:[b.jsxs("div",{className:"flex items-center gap-1",children:[b.jsx(or,{className:"w-3.5 h-3.5"}),b.jsx("span",{children:f.common.click})]}),b.jsxs("div",{className:"flex items-center gap-1",children:[b.jsx(ir,{className:"w-3.5 h-3.5"}),b.jsx("span",{children:f.common.drop})]}),b.jsxs("div",{className:"flex items-center gap-1",children:[b.jsx(rr,{className:"w-3.5 h-3.5"}),b.jsx("span",{children:f.common.paste})]})]})]})]})})}function ks({isOpen:t,onClose:n}){const{t:f}=ke(),[s,e]=H.useState(0),[r,o]=H.useState({}),c=[{id:"sidebar-upload-area",title:f.guide.step1Title,content:f.guide.step1Content,position:"right"},{id:"sidebar-history",title:f.guide.step2Title,content:f.guide.step2Content,position:"right"},{id:"file-preview-empty",title:f.guide.step3Title,content:f.guide.step3Content,position:"right"},{id:"result-empty-state",title:f.guide.step4Title,content:f.guide.step4Content,position:"left"},{id:"export-button",title:f.guide.stepExportTitle,content:f.guide.stepExportContent,position:"left"}],w=H.useCallback(()=>{if(!t||c.length===0)return;const u=document.getElementById(c[s].id);if(u){const i=u.getBoundingClientRect();o({top:i.top-8,left:i.left-8,width:i.width+16,height:i.height+16,opacity:1}),u.scrollIntoView({behavior:"smooth",block:"center"})}else o({opacity:0})},[s,t,c,f.guide]);if(H.useEffect(()=>(t&&(w(),window.addEventListener("resize",w)),()=>window.removeEventListener("resize",w)),[t,w]),!t)return null;const C=()=>{s{s>0&&e(s-1)};return b.jsxs("div",{className:"fixed inset-0 z-[100] pointer-events-none",children:[b.jsx("div",{className:"absolute inset-0 bg-black/60 pointer-events-auto",onClick:n,style:{clipPath:r.top!==void 0?`polygon( + 0% 0%, 0% 100%, + ${r.left}px 100%, + ${r.left}px ${r.top}px, + ${r.left+r.width}px ${r.top}px, + ${r.left+r.width}px ${r.top+r.height}px, + ${r.left}px ${r.top+r.height}px, + ${r.left}px 100%, + 100% 100%, 100% 0% + )`:"none"}}),b.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:r}),b.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:r.top!==void 0?{top:c[s].position==="bottom"?r.top+r.height+16:c[s].position==="top"?r.top-200:r.top,left:c[s].position==="right"?r.left+r.width+16:c[s].position==="left"?r.left-336:r.left}:{top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:[b.jsx("button",{onClick:n,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600",children:b.jsx(We,{size:18})}),b.jsxs("div",{className:"mb-4",children:[b.jsxs("span",{className:"text-xs font-bold text-blue-600 uppercase tracking-wider",children:["Step ",s+1," of ",c.length]}),b.jsx("h3",{className:"text-lg font-bold text-gray-900 mt-1",children:c[s].title}),b.jsx("p",{className:"text-sm text-gray-600 mt-2 leading-relaxed",children:c[s].content})]}),b.jsxs("div",{className:"flex items-center justify-between mt-6",children:[b.jsxs("button",{onClick:a,disabled:s===0,className:`flex items-center gap-1 text-sm font-medium ${s===0?"text-gray-300 cursor-not-allowed":"text-gray-600 hover:text-gray-900"}`,children:[b.jsx(wt,{size:16}),f.guide.prev]}),b.jsxs("button",{onClick:C,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:[s===c.length-1?f.guide.finish:f.guide.next,sD.id===r)||null;H.useEffect(()=>{const D=()=>i(!0);return window.addEventListener("start-user-guide",D),localStorage.getItem("hasSeenGuide")||(setTimeout(()=>i(!0),1500),localStorage.setItem("hasSeenGuide","true")),()=>window.removeEventListener("start-user-guide",D)},[]),H.useEffect(()=>{!n&&t&&!I.current&&(I.current=!0,O()),t||(I.current=!1,e([]),o(null),E(1),k(!1))},[n,t]),H.useEffect(()=>{F.current=r,r?$(r):w(null)},[r]),H.useEffect(()=>()=>{Object.values(U.current).forEach(clearInterval),U.current={}},[]),H.useEffect(()=>{const D=B=>{var V;if(C)return;const G=(V=B.clipboardData)==null?void 0:V.items;if(!G)return;const X=[];for(let K=0;K0&&Q(X)};return document.addEventListener("paste",D),()=>document.removeEventListener("paste",D)},[t,C]);const y=H.useCallback(D=>{D.preventDefault(),p(!0)},[]),L=H.useCallback(()=>{p(!1)},[]),R=H.useCallback(D=>{if(M){const B=D.clientX;B>=280&&B<=400&&l(B)}},[M]);H.useEffect(()=>(window.addEventListener("mousemove",R),window.addEventListener("mouseup",L),()=>{window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",L)}),[R,L]);const z=D=>{const B={[xe.Pending]:"pending",[xe.Processing]:"processing",[xe.Completed]:"completed",[xe.Failed]:"failed"};return{id:D.task_id,user_id:(t==null?void 0:t.id)||null,filename:D.file_name,file_path:D.origin_url,file_type:"image/jpeg",file_size:0,thumbnail_path:null,status:B[D.status]||"pending",created_at:D.created_at,updated_at:D.created_at}},W=D=>({id:D.task_id,file_id:D.task_id,markdown_content:D.markdown,latex_content:D.latex,mathml_content:D.mathml,mml:D.mml,rendered_image_path:D.image_blob||null,created_at:D.created_at}),O=async()=>{if(t){x(!0);try{const D=await Ie.getTaskList("FORMULA",1,$t),B=D.task_list||[],G=D.total||0;if(E(1),k(B.length0){const X=B.map(z);e(X),B.forEach(V=>{V.status===xe.Completed&&(T.current[V.task_id]=W(V))}),r||o(X[0].id)}else e([])}catch(D){console.error("Error loading files:",D),e([])}finally{x(!1)}}},q=async()=>{if(!(!t||h||!m)){d(!0);try{const D=S+1,B=await Ie.getTaskList("FORMULA",D,$t),G=B.task_list||[],X=B.total||0;if(G.length>0){const V=G.map(z);e(K=>{const Z=[...K,...V];return k(Z.length{K.status===xe.Completed&&(T.current[K.task_id]=W(K))}),E(D)}else k(!1)}catch(D){console.error("Error loading more files:",D)}finally{d(!1)}}},$=async D=>{try{const B=T.current[D];if(B){w(B);return}try{const G=await Ie.getTaskResult(D);if(G.status===xe.Completed){const X={id:D,file_id:D,markdown_content:G.markdown,latex_content:G.latex,mathml_content:G.mathml,mml:G.mml,rendered_image_path:G.image_blob||null,created_at:new Date().toISOString()};T.current[D]=X,w(X)}else w(null)}catch{w(null)}}catch(B){console.error("Error loading result:",B),w(null)}},P=(D,B)=>{if(U.current[D])return;let G=0;const X=30;U.current[D]=setInterval(async()=>{G++;try{const V=await Ie.getTaskResult(D);if(e(K=>K.map(Z=>{if(Z.id===B){let ae="processing";return V.status===xe.Completed?ae="completed":V.status===xe.Failed&&(ae="failed"),{...Z,status:ae}}return Z})),V.status===xe.Completed||V.status===xe.Failed){if(clearInterval(U.current[D]),delete U.current[D],V.status===xe.Completed){const K={id:B,file_id:B,markdown_content:V.markdown,latex_content:V.latex,mathml_content:V.mathml,mml:V.mml,rendered_image_path:V.image_blob||null,created_at:new Date().toISOString()};T.current[B]=K,F.current===B&&w(K)}}else G>=X&&(clearInterval(U.current[D]),delete U.current[D],e(K=>K.map(Z=>Z.id===B?{...Z,status:"failed"}:Z)),alert(f.alerts.taskTimeout))}catch(V){console.error("Polling error:",V),G>=X&&(clearInterval(U.current[D]),delete U.current[D],e(K=>K.map(Z=>Z.id===B?{...Z,status:"failed"}:Z)),alert(f.alerts.networkError))}},2e3)},Q=async D=>{x(!0);try{for(const B of D){const G=await Ie.calculateMD5(B),X=await Ie.uploadFile(B),V=await Ie.createRecognitionTask(X.path,G,B.name),K=V.task_no||crypto.randomUUID(),Z={id:K,user_id:(t==null?void 0:t.id)||null,filename:B.name,file_path:URL.createObjectURL(B),file_type:B.type,file_size:B.size,thumbnail_path:null,status:"processing",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};e(ae=>[Z,...ae]),o(Z.id),V.task_no&&P(V.task_no,K)}}catch(B){console.error("Error uploading files:",B),alert(`${f.alerts.uploadFailed}: `+(B instanceof Error?B.message:"Unknown error"))}finally{x(!1)}};return n?b.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:b.jsxs("div",{className:"text-center",children:[b.jsx("div",{className:"w-16 h-16 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mx-auto mb-4"}),b.jsx("p",{className:"text-gray-600",children:f.common.loading})]})}):b.jsxs("div",{className:"h-screen flex flex-col bg-gray-50 font-sans text-gray-900 overflow-hidden",children:[b.jsx(fn,{}),b.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[b.jsxs("div",{ref:N,className:"flex-shrink-0 bg-white border-r border-gray-200 relative transition-all duration-300 ease-in-out",style:{width:v?64:A},children:[b.jsx(dn,{files:s,selectedFileId:r,onFileSelect:o,onUploadClick:()=>a(!0),isCollapsed:v,onToggleCollapse:()=>_(!v),onUploadFiles:Q,hasMore:m,loadingMore:h,onLoadMore:q}),!v&&b.jsx("div",{className:"absolute right-0 top-0 w-1 h-full cursor-col-resize hover:bg-blue-400 z-50 opacity-0 hover:opacity-100 transition-opacity",onMouseDown:y})]}),b.jsx("div",{className:"flex-1 flex min-w-0 flex-col bg-gray-100/50",children:b.jsx(hn,{file:j})}),b.jsx("div",{className:"flex-1 flex min-w-0 flex-col bg-white",children:b.jsx(js,{result:c,fileStatus:j==null?void 0:j.status})}),C&&b.jsx(Cs,{onClose:()=>a(!1),onUpload:Q}),b.jsx(ks,{isOpen:u,onClose:()=>i(!1)}),g&&b.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-30 flex items-center justify-center z-50",children:b.jsxs("div",{className:"bg-white rounded-xl shadow-xl p-8",children:[b.jsx("div",{className:"w-16 h-16 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mx-auto mb-4"}),b.jsx("p",{className:"text-gray-900 font-medium",children:f.common.processing})]})})]}),b.jsx("div",{className:"flex-shrink-0 bg-white border-t border-gray-200 py-2 px-4 text-center",children:b.jsx("a",{href:"https://beian.miit.gov.cn",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-gray-500 hover:text-gray-700 transition-colors",children:"京ICP备2025152973号"})})]})}window.addEventListener("error",t=>{console.error("Global error:",t.error)});window.addEventListener("unhandledrejection",t=>{console.error("Unhandled promise rejection:",t.reason)});const pt=document.getElementById("root");if(!pt)throw new Error("Root element not found");try{Dt(pt).render(b.jsx(H.StrictMode,{children:b.jsx(Nr,{children:b.jsx(Lr,{children:b.jsx(Ss,{})})})}))}catch(t){console.error("Failed to render app:",t),pt.innerHTML=` +
+

应用启动失败

+

错误信息: ${t instanceof Error?t.message:String(t)}

+

请检查浏览器控制台获取更多信息。

+
+ `} diff --git a/app.cloud/assets/index-NjWMZQkP.js b/app.cloud/assets/index-NjWMZQkP.js deleted file mode 100644 index 117ef6b..0000000 --- a/app.cloud/assets/index-NjWMZQkP.js +++ /dev/null @@ -1,191 +0,0 @@ -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()(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,expiresAt:r}:(ve.removeToken(),null)}},tr=H.createContext(void 0);function Gr({children:e}){const[r,a]=H.useState(()=>{try{const y=Xe.restoreSession();return y?y.user:null}catch{return null}}),[i,t]=H.useState(()=>{try{const y=Xe.restoreSession();return y?y.token:null}catch{return null}}),[n,s]=H.useState(!1),[l,m]=H.useState(!1),p=(y,C)=>{if(y&&typeof y=="object"&&"code"in y){const k=y;return qr[k.code]||k.message||C}return y instanceof Error?y.message:C},o=H.useCallback(async(y,C)=>{s(!0);try{const k=await Xe.login({email:y,password:C});return a(k.user),t(k.token),{error:null}}catch(k){const b=p(k,"登录失败");return{error:new Error(b)}}finally{s(!1)}},[]),u=H.useCallback(async(y,C)=>{s(!0);try{const k=await Xe.register({email:y,password:C});return a(k.user),t(k.token),{error:null}}catch(k){const b=p(k,"注册失败");return{error:new Error(b)}}finally{s(!1)}},[]),c=H.useCallback(async()=>{s(!0);try{Xe.logout(),a(null),t(null)}finally{s(!1)}},[]),f={user:r,token:i,loading:n,initializing:l,signIn:o,signUp:u,signOut:c,isAuthenticated:!!r&&!!i};return E.jsx(tr.Provider,{value:f,children:e})}function Ct(){const e=H.useContext(tr);if(e===void 0)throw new Error("useAuth must be used within an AuthProvider");return e}const Vr={en:{common:{upload:"Upload",history:"History",login:"Login / Register",logout:"Logout",loading:"Loading...",processing:"Processing...",cancel:"Cancel",copy:"Copy",copied:"Copied!",download:"Download",export:"Export",preview:"Preview",email:"Email",contactUs:"Contact Us",reward:"Reward",qqGroup:"QQ Group (Click to Copy)",guide:"User Guide",click:"Click",drop:"Drop",paste:"Paste"},navbar:{rewardTitle:"WeChat Reward",rewardThanks:"Thank you for your support and encouragement ❤️",rewardSubtitle:"Your support is our motivation for continuous updates"},sidebar:{title:"Formula Recognize",subtitle:"Support handwriting and printed formulas",uploadInstruction:"Click, Drop, or Paste a file to start parsing",pleaseLogin:"Please login to view history",noHistory:"No history records",noMore:"No more records",historyHeader:"History"},uploadModal:{title:"Upload File",supportFormats:"Support JPG, PNG, PDF format"},resultPanel:{waitingTitle:"Waiting for recognition result",waitingSubtitle:"After uploading the file, Texpixel will automatically recognize and display the result here",analyzing:"Analyzing...",waitingQueue:"Waiting in queue...",queueSubtitle:"Your file is in the queue, please wait.",processingSubtitle:"Texpixel is processing your file, this may take a moment.",markdown:"Markdown"},auth:{signIn:"Login",signUp:"Register",signInTitle:"Login Account",signUpTitle:"Register Account",email:"Email",password:"Password",error:"Error",genericError:"An error occurred, please try again",hasAccount:"Already have an account? Login",noAccount:"No account? Register"},export:{title:"Export",categories:{code:"Code",image:"Image",file:"File"},failed:"Export failed, please try again",imageFailed:"Failed to generate image"},guide:{next:"Next",prev:"Back",finish:"Finish",skip:"Skip",step1Title:"Upload Area",step1Content:"Click or drag and drop your formula images/PDFs here to start recognition.",step2Title:"File History",step2Content:"Your recognized files will appear here. Login to sync across devices.",step3Title:"Preview Area",step3Content:"The original file you uploaded will be displayed here for comparison.",step4Title:"Recognition Result",step4Content:"The recognition results (Markdown/LaTeX) will be shown here.",stepExportTitle:"Export Result",stepExportContent:"You can export the recognition results to various formats such as Markdown, LaTeX, Word, or Image."},alerts:{taskTimeout:"Task timeout: Recognition took too long.",networkError:"Task timeout or network error.",uploadFailed:"Upload failed"}},zh:{common:{upload:"上传",history:"历史记录",login:"登录 / 注册",logout:"退出登录",loading:"加载中...",processing:"处理中...",cancel:"取消",copy:"复制",copied:"已复制!",download:"下载",export:"导出",preview:"预览",email:"邮箱",contactUs:"联系我们",reward:"赞赏",qqGroup:"QQ 群 (点击复制)",guide:"使用引导",click:"点击",drop:"拖拽",paste:"粘贴"},navbar:{rewardTitle:"微信赞赏码",rewardThanks:"感谢您的支持与鼓励 ❤️",rewardSubtitle:"您的支持是我们持续更新的动力"},sidebar:{title:"文档识别",subtitle:"支持手写和印刷体文档识别",uploadInstruction:"点击、拖拽或粘贴文件开始解析",pleaseLogin:"请登录后查看历史记录",noHistory:"暂无历史记录",noMore:"没有更多记录了",historyHeader:"历史记录"},uploadModal:{title:"上传文件",supportFormats:"支持 JPG, PNG 格式"},resultPanel:{waitingTitle:"等待识别结果",waitingSubtitle:"上传文件后,TexPixel 将自动识别并在此显示结果",analyzing:"解析中...",waitingQueue:"排队中...",queueSubtitle:"您的文件正在排队,请稍候。",processingSubtitle:"TexPixel 正在处理您的文件,请稍候。",markdown:"Markdown"},auth:{signIn:"登录",signUp:"注册",signInTitle:"登录账号",signUpTitle:"注册账号",email:"邮箱",password:"密码",error:"错误",genericError:"发生错误,请重试",hasAccount:"已有账号?去登录",noAccount:"没有账号?去注册"},export:{title:"导出",categories:{code:"代码",image:"图片",file:"文件"},failed:"导出失败,请重试",imageFailed:"生成图片失败"},guide:{next:"下一步",prev:"上一步",finish:"完成",skip:"跳过",step1Title:"上传区域",step1Content:"点击此处或将公式/文档图片 粘贴或者拖拽到这里开始识别。",step2Title:"历史记录",step2Content:"识别过的文件会显示在这里。登录后可以跨设备同步。",step3Title:"预览区域",step3Content:"这里会显示您上传的原始文件,方便对比。",step4Title:"识别结果",step4Content:"这里会显示识别出的 Markdown/LaTeX 结果。",stepExportTitle:"导出结果",stepExportContent:"您可以将识别结果导出为多种格式,如 Markdown、LaTeX、Word 或图片。"},alerts:{taskTimeout:"任务超时:识别时间过长。",networkError:"任务超时或网络错误。",uploadFailed:"上传失败"}}};async function Qr(){try{const e=await fetch("https://ipapi.co/json/",{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)return console.warn("IP location detection failed:",e.status),null;const r=await e.json();return r.error||!r.country_code?null:r.country_code.toUpperCase()}catch(e){return console.warn("IP location detection error:",e),null}}function Xr(e){return e&&["CN","TW","HK","MO","SG"].includes(e)?"zh":"en"}async function Zr(){const e=await Qr();return Xr(e)}const rr=H.createContext(void 0),Kr=({children:e})=>{const[r,a]=H.useState(()=>{const n=localStorage.getItem("language");return n==="en"||n==="zh"?n:navigator.language.startsWith("zh")?"zh":"en"});H.useEffect(()=>{const n=localStorage.getItem("language");n==="en"||n==="zh"||Zr().then(s=>{a(s)}).catch(s=>{console.warn("Failed to detect language by IP:",s)})},[]);const i=n=>{a(n),localStorage.setItem("language",n)},t=Vr[r];return E.jsx(rr.Provider,{value:{language:r,setLanguage:i,t},children:e})},_e=()=>{const e=H.useContext(rr);if(e===void 0)throw new Error("useLanguage must be used within a LanguageProvider");return e};function Yr(e,r){return r.forEach(function(a){a&&typeof a!="string"&&!Array.isArray(a)&&Object.keys(a).forEach(function(i){if(i!=="default"&&!(i in e)){var t=Object.getOwnPropertyDescriptor(a,i);Object.defineProperty(e,i,t.get?t:{enumerable:!0,get:function(){return a[i]}})}})}),Object.freeze(e)}function nr(e,r){return new Promise(function(a,i){let t;return Jr(e).then(function(n){try{return t=n,a(new Blob([r.slice(0,2),t,r.slice(2)],{type:"image/jpeg"}))}catch(s){return i(s)}},i)})}const Jr=e=>new Promise((r,a)=>{const i=new FileReader;i.addEventListener("load",({target:{result:t}})=>{const n=new DataView(t);let s=0;if(n.getUint16(s)!==65496)return a("not a valid JPEG");for(s+=2;;){const l=n.getUint16(s);if(l===65498)break;const m=n.getUint16(s+2);if(l===65505&&n.getUint32(s+4)===1165519206){const p=s+10;let o;switch(n.getUint16(p)){case 18761:o=!0;break;case 19789:o=!1;break;default:return a("TIFF header contains invalid endian")}if(n.getUint16(p+2,o)!==42)return a("TIFF header contains invalid version");const u=n.getUint32(p+4,o),c=p+u+2+12*n.getUint16(p+u,o);for(let f=p+u+2;f>>24&255,l[s+1]=m>>>16&255,l[s+2]=m>>>8&255,l[s+3]=m>>>0&255,new Uint8Array(l.buffer,0,s+4)},i.deflateRaw=function(t,n){n==null&&(n={level:6});var s=new Uint8Array(50+Math.floor(1.1*t.length)),l=i.F.deflateRaw(t,s,l,n.level);return new Uint8Array(s.buffer,0,l)},i.encode=function(t,n){n==null&&(n=!1);var s=0,l=i.bin.writeUint,m=i.bin.writeUshort,p={};for(var o in t){var u=!i._noNeed(o)&&!n,c=t[o],f=i.crc.crc(c,0,c.length);p[o]={cpr:u,usize:c.length,crc:f,file:u?i.deflateRaw(c):c}}for(var o in p)s+=p[o].file.length+30+46+2*i.bin.sizeUTF8(o);s+=22;var y=new Uint8Array(s),C=0,k=[];for(var o in p){var b=p[o];k.push(C),C=i._writeHeader(y,C,o,b,0)}var w=0,g=C;for(var o in p)b=p[o],k.push(C),C=i._writeHeader(y,C,o,b,1,k[w++]);var h=C-g;return l(y,C,101010256),C+=4,m(y,C+=4,w),m(y,C+=2,w),l(y,C+=2,h),l(y,C+=4,g),C+=4,C+=2,y.buffer},i._noNeed=function(t){var n=t.split(".").pop().toLowerCase();return"png,jpg,jpeg,zip".indexOf(n)!=-1},i._writeHeader=function(t,n,s,l,m,p){var o=i.bin.writeUint,u=i.bin.writeUshort,c=l.file;return o(t,n,m==0?67324752:33639248),n+=4,m==1&&(n+=2),u(t,n,20),u(t,n+=2,0),u(t,n+=2,l.cpr?8:0),o(t,n+=2,0),o(t,n+=4,l.crc),o(t,n+=4,c.length),o(t,n+=4,l.usize),u(t,n+=4,i.bin.sizeUTF8(s)),u(t,n+=2,0),n+=2,m==1&&(n+=2,n+=2,o(t,n+=6,p),n+=4),n+=i.bin.writeUTF8(t,n,s),m==0&&(t.set(c,n),n+=c.length),n},i.crc={table:function(){for(var t=new Uint32Array(256),n=0;n<256;n++){for(var s=n,l=0;l<8;l++)1&s?s=3988292384^s>>>1:s>>>=1;t[n]=s}return t}(),update:function(t,n,s,l){for(var m=0;m>>8;return t},crc:function(t,n,s){return 4294967295^i.crc.update(4294967295,t,n,s)}},i.adler=function(t,n,s){for(var l=1,m=0,p=n,o=n+s;p>8&255},readUint:function(t,n){return 16777216*t[n+3]+(t[n+2]<<16|t[n+1]<<8|t[n])},writeUint:function(t,n,s){t[n]=255&s,t[n+1]=s>>8&255,t[n+2]=s>>16&255,t[n+3]=s>>24&255},readASCII:function(t,n,s){for(var l="",m=0;m>6,t[n+m+1]=128|o>>0&63,m+=2;else if(!(4294901760&o))t[n+m]=224|o>>12,t[n+m+1]=128|o>>6&63,t[n+m+2]=128|o>>0&63,m+=3;else{if(4292870144&o)throw"e";t[n+m]=240|o>>18,t[n+m+1]=128|o>>12&63,t[n+m+2]=128|o>>6&63,t[n+m+3]=128|o>>0&63,m+=4}}return m},sizeUTF8:function(t){for(var n=t.length,s=0,l=0;l>>3}var k=p.lits,b=p.strt,w=p.prev,g=0,h=0,S=0,d=0,I=0,x=0;for(C>2&&(b[x=i.F._hash(t,0)]=0),c=0;c14e3||h>26697)&&C-c>100&&(y>>16,T=65535&_;if(_!=0){T=65535&_;var M=o(R=_>>>16,p.of0);p.lhst[257+M]++;var N=o(T,p.df0);p.dhst[N]++,d+=p.exb[M]+p.dxb[N],k[g]=R<<23|c-y,k[g+1]=T<<16|M<<8|N,g+=2,y=c+R}else p.lhst[t[c]]++;h++}}for(S==c&&t.length!=0||(y>>3},i.F._bestMatch=function(t,n,s,l,m,p){var o=32767&n,u=s[o],c=o-u+32768&32767;if(u==o||l!=i.F._hash(t,n-c))return 0;for(var f=0,y=0,C=Math.min(32767,n);c<=C&&--p!=0&&u!=o;){if(f==0||t[n+f]==t[n+f-c]){var k=i.F._howLong(t,n,c);if(k>f){if(y=c,(f=k)>=m)break;c+2b&&(b=h,u=g)}}}c+=(o=u)-(u=s[o])+32768&32767}return f<<16|y},i.F._howLong=function(t,n,s){if(t[n]!=t[n-s]||t[n+1]!=t[n+1-s]||t[n+2]!=t[n+2-s])return 0;var l=n,m=Math.min(t.length,n+258);for(n+=3;n>>23,q=v+(8388607&L);v>16,z=D>>8&255,F=255&D;x(u,c=i.F._writeLit(257+z,N,u,c),$-d.of0[z]),c+=d.exb[z],I(u,c=i.F._writeLit(F,U,u,c),W-d.df0[F]),c+=d.dxb[F],v+=$}}c=i.F._writeLit(256,N,u,c)}return c},i.F._copyExact=function(t,n,s,l,m){var p=m>>>3;return l[p]=s,l[p+1]=s>>>8,l[p+2]=255-l[p],l[p+3]=255-l[p+1],p+=4,l.set(new Uint8Array(t.buffer,n,s),p),m+(s+4<<3)},i.F.getTrees=function(){for(var t=i.F.U,n=i.F._hufTree(t.lhst,t.ltree,15),s=i.F._hufTree(t.dhst,t.dtree,15),l=[],m=i.F._lenCodes(t.ltree,l),p=[],o=i.F._lenCodes(t.dtree,p),u=0;u4&&t.itree[1+(t.ordr[f-1]<<1)]==0;)f--;return[n,s,c,m,o,f,l,p]},i.F.getSecond=function(t){for(var n=[],s=0;s>1)+",");return n},i.F.contSize=function(t,n){for(var s=0,l=0;l15&&(i.F._putsE(s,l,o,u),l+=u)}return l},i.F._lenCodes=function(t,n){for(var s=t.length;s!=2&&t[s-1]==0;)s-=2;for(var l=0;l>>1,138))<11?n.push(17,f-3):n.push(18,f-11),l+=2*f-2}else if(m==u&&p==m&&o==m){for(c=l+5;c+2>>1,6);n.push(16,f-3),l+=2*f-2}else n.push(m,0)}return s>>>1},i.F._hufTree=function(t,n,s){var l=[],m=t.length,p=n.length,o=0;for(o=0;os&&(i.F.restrictDepth(c,s,g),g=s),o=0;on;l++){var o=t[l].d;t[l].d=n,p+=m-(1<>>=s-n;p>0;)(o=t[l].d)=0;l--)t[l].d==n&&p<0&&(t[l].d--,p++);p!=0&&console.log("debt left")},i.F._goodIndex=function(t,n){var s=0;return n[16|s]<=t&&(s|=16),n[8|s]<=t&&(s|=8),n[4|s]<=t&&(s|=4),n[2|s]<=t&&(s|=2),n[1|s]<=t&&(s|=1),s},i.F._writeLit=function(t,n,s,l){return i.F._putsF(s,l,n[t<<1]),l+n[1+(t<<1)]},i.F.inflate=function(t,n){var s=Uint8Array;if(t[0]==3&&t[1]==0)return n||new s(0);var l=i.F,m=l._bitsF,p=l._bitsE,o=l._decodeTiny,u=l.makeCodes,c=l.codes2map,f=l._get17,y=l.U,C=n==null;C&&(n=new s(t.length>>>2<<3));for(var k,b,w=0,g=0,h=0,S=0,d=0,I=0,x=0,A=0,_=0;w==0;)if(w=m(t,_,1),g=m(t,_+1,2),_+=3,g!=0){if(C&&(n=i.F._check(n,A+(1<<17))),g==1&&(k=y.flmap,b=y.fdmap,I=511,x=31),g==2){h=p(t,_,5)+257,S=p(t,_+5,5)+1,d=p(t,_+10,4)+4,_+=14;for(var R=0;R<38;R+=2)y.itree[R]=0,y.itree[R+1]=0;var T=1;for(R=0;RT&&(T=M)}_+=3*d,u(y.itree,T),c(y.itree,T,y.imap),k=y.lmap,b=y.dmap,_=o(y.imap,(1<>>4;if(!(v>>>8))n[A++]=v;else{if(v==256)break;var P=A+v-254;if(v>264){var L=y.ldef[v-257];P=A+(L>>>3)+p(t,_,7&L),_+=7&L}var $=b[f(t,_)&x];_+=15&$;var q=$>>>4,D=y.ddef[q],W=(D>>>4)+m(t,_,15&D);for(_+=15&D,C&&(n=i.F._check(n,A+(1<<17)));A>>3),F=t[z-4]|t[z-3]<<8;C&&(n=i.F._check(n,A+F)),n.set(new s(t.buffer,t.byteOffset+z,F),A),_=z+F<<3,A+=F}return n.length==A?n:n.slice(0,A)},i.F._check=function(t,n){var s=t.length;if(n<=s)return t;var l=new Uint8Array(Math.max(s<<1,n));return l.set(t,0),l},i.F._decodeTiny=function(t,n,s,l,m,p){for(var o=i.F._bitsE,u=i.F._get17,c=0;c>>4;if(y<=15)p[c]=y,c++;else{var C=0,k=0;y==16?(k=3+o(l,m,2),m+=2,C=p[c-1]):y==17?(k=3+o(l,m,3),m+=3):y==18&&(k=11+o(l,m,7),m+=7);for(var b=c+k;c>>1;pm&&(m=u),p++}for(;p>1,u=t[p+1],c=o<<4|u,f=n-u,y=t[p]<>>15-n]=c,y++},i.F.revCodes=function(t,n){for(var s=i.F.U.rev15,l=15-n,m=0;m>>l}},i.F._putsE=function(t,n,s){s<<=7&n;var l=n>>>3;t[l]|=s,t[l+1]|=s>>>8},i.F._putsF=function(t,n,s){s<<=7&n;var l=n>>>3;t[l]|=s,t[l+1]|=s>>>8,t[l+2]|=s>>>16},i.F._bitsE=function(t,n,s){return(t[n>>>3]|t[1+(n>>>3)]<<8)>>>(7&n)&(1<>>3]|t[1+(n>>>3)]<<8|t[2+(n>>>3)]<<16)>>>(7&n)&(1<>>3]|t[1+(n>>>3)]<<8|t[2+(n>>>3)]<<16)>>>(7&n)},i.F._get25=function(t,n){return(t[n>>>3]|t[1+(n>>>3)]<<8|t[2+(n>>>3)]<<16|t[3+(n>>>3)]<<24)>>>(7&n)},i.F.U=(r=Uint16Array,a=Uint32Array,{next_code:new r(16),bl_count:new r(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new r(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new a(32),flmap:new r(512),fltree:[],fdmap:new r(32),fdtree:[],lmap:new r(32768),ltree:[],ttree:[],dmap:new r(32768),dtree:[],imap:new r(512),itree:[],rev15:new r(32768),lhst:new a(286),dhst:new a(30),ihst:new a(19),lits:new a(15e3),strt:new r(65536),prev:new r(32768)}),function(){for(var t=i.F.U,n=0;n<32768;n++){var s=n;s=(4278255360&(s=(4042322160&(s=(3435973836&(s=(2863311530&s)>>>1|(1431655765&s)<<1))>>>2|(858993459&s)<<2))>>>4|(252645135&s)<<4))>>>8|(16711935&s)<<8,t.rev15[n]=(s>>>16|s<<16)>>>17}function l(m,p,o){for(;p--!=0;)m.push(0,o)}for(n=0;n<32;n++)t.ldef[n]=t.of0[n]<<3|t.exb[n],t.ddef[n]=t.df0[n]<<4|t.dxb[n];l(t.fltree,144,8),l(t.fltree,112,9),l(t.fltree,24,7),l(t.fltree,8,8),i.F.makeCodes(t.fltree,9),i.F.codes2map(t.fltree,9,t.flmap),i.F.revCodes(t.fltree,9),l(t.fdtree,32,5),i.F.makeCodes(t.fdtree,5),i.F.codes2map(t.fdtree,5,t.fdmap),i.F.revCodes(t.fdtree,5),l(t.itree,19,0),l(t.ltree,286,0),l(t.dtree,30,0),l(t.ttree,320,0)}()})();var tn=Yr({__proto__:null,default:ot},[ot]);const Se=function(){var e={nextZero(o,u){for(;o[u]!=0;)u++;return u},readUshort:(o,u)=>o[u]<<8|o[u+1],writeUshort(o,u,c){o[u]=c>>8&255,o[u+1]=255&c},readUint:(o,u)=>16777216*o[u]+(o[u+1]<<16|o[u+2]<<8|o[u+3]),writeUint(o,u,c){o[u]=c>>24&255,o[u+1]=c>>16&255,o[u+2]=c>>8&255,o[u+3]=255&c},readASCII(o,u,c){let f="";for(let y=0;yo.length<2?`0${o}`:o,readUTF8(o,u,c){let f,y="";for(let C=0;C>3)]>>7-((7&d)<<0)&1);b[A]=L[M],b[A+1]=L[M+1],b[A+2]=L[M+2],b[A+3]=N>2)]>>6-((3&d)<<1)&3),b[A]=L[M],b[A+1]=L[M+1],b[A+2]=L[M+2],b[A+3]=N>1)]>>4-((1&d)<<2)&15),b[A]=L[M],b[A+1]=L[M+1],b[A+2]=L[M+2],b[A+3]=N>>3)]>>>7-(7&v)&1))==255*x?0:255;w[$+v]=P<<24|U<<16|U<<8|U}else if(h==2)for(v=0;v>>2)]>>>6-((3&v)<<1)&3))==85*x?0:255,w[$+v]=P<<24|U<<16|U<<8|U;else if(h==4)for(v=0;v>>1)]>>>4-((1&v)<<2)&15))==17*x?0:255,w[$+v]=P<<24|U<<16|U<<8|U;else if(h==8)for(v=0;v>3,x=Math.ceil(h*d/8),A=new Uint8Array(S*x);let _=0;const R=[0,0,4,0,2,0,1],T=[0,4,0,2,0,1,0],M=[8,8,8,4,4,2,2],N=[8,8,4,4,2,2,1];let U=0;for(;U<7;){const v=M[U],P=N[U];let L=0,$=0,q=R[U];for(;q>3])>>7-(7&O)&1,A[F*x+(V>>3)]|=j<<7-((7&V)<<0)),d==2&&(j=(j=w[O>>3])>>6-(7&O)&3,A[F*x+(V>>2)]|=j<<6-((3&V)<<1)),d==4&&(j=(j=w[O>>3])>>4-(7&O)&15,A[F*x+(V>>1)]|=j<<4-((1&V)<<2)),d>=8){const B=F*x+V*I;for(let G=0;G>3)+G]}O+=d,V+=P}z++,F+=v}L*$!=0&&(_+=$*(1+W)),U+=1}return A}(u,o)),u}function i(o,u){return t(new Uint8Array(o.buffer,2,o.length-6),u)}var t=function(){const o={H:{}};return o.H.N=function(u,c){const f=Uint8Array;let y,C,k=0,b=0,w=0,g=0,h=0,S=0,d=0,I=0,x=0;if(u[0]==3&&u[1]==0)return c||new f(0);const A=o.H,_=A.b,R=A.e,T=A.R,M=A.n,N=A.A,U=A.Z,j=A.m,v=c==null;for(v&&(c=new f(u.length>>>2<<5));k==0;)if(k=_(u,x,1),b=_(u,x+1,2),x+=3,b!=0){if(v&&(c=o.H.W(c,I+(1<<17))),b==1&&(y=j.J,C=j.h,S=511,d=31),b==2){w=R(u,x,5)+257,g=R(u,x+5,5)+1,h=R(u,x+10,4)+4,x+=14;let L=1;for(var P=0;P<38;P+=2)j.Q[P]=0,j.Q[P+1]=0;for(P=0;PL&&(L=D)}x+=3*h,M(j.Q,L),N(j.Q,L,j.u),y=j.w,C=j.d,x=T(j.u,(1<>>4;if(!($>>>8))c[I++]=$;else{if($==256)break;{let q=I+$-254;if($>264){const V=j.q[$-257];q=I+(V>>>3)+R(u,x,7&V),x+=7&V}const D=C[U(u,x)&d];x+=15&D;const W=D>>>4,z=j.c[W],F=(z>>>4)+_(u,x,15&z);for(x+=15&z;I>>3),$=u[L-4]|u[L-3]<<8;v&&(c=o.H.W(c,I+$)),c.set(new f(u.buffer,u.byteOffset+L,$),I),x=L+$<<3,I+=$}return c.length==I?c:c.slice(0,I)},o.H.W=function(u,c){const f=u.length;if(c<=f)return u;const y=new Uint8Array(f<<1);return y.set(u,0),y},o.H.R=function(u,c,f,y,C,k){const b=o.H.e,w=o.H.Z;let g=0;for(;g>>4;if(S<=15)k[g]=S,g++;else{let d=0,I=0;S==16?(I=3+b(y,C,2),C+=2,d=k[g-1]):S==17?(I=3+b(y,C,3),C+=3):S==18&&(I=11+b(y,C,7),C+=7);const x=g+I;for(;g>>1;for(;kC&&(C=w),k++}for(;k>1,w=u[k+1],g=b<<4|w,h=c-w;let S=u[k]<>>15-c]=g,S++}},o.H.l=function(u,c){const f=o.H.m.r,y=15-c;for(let C=0;C>>y}},o.H.M=function(u,c,f){f<<=7&c;const y=c>>>3;u[y]|=f,u[y+1]|=f>>>8},o.H.I=function(u,c,f){f<<=7&c;const y=c>>>3;u[y]|=f,u[y+1]|=f>>>8,u[y+2]|=f>>>16},o.H.e=function(u,c,f){return(u[c>>>3]|u[1+(c>>>3)]<<8)>>>(7&c)&(1<>>3]|u[1+(c>>>3)]<<8|u[2+(c>>>3)]<<16)>>>(7&c)&(1<>>3]|u[1+(c>>>3)]<<8|u[2+(c>>>3)]<<16)>>>(7&c)},o.H.i=function(u,c){return(u[c>>>3]|u[1+(c>>>3)]<<8|u[2+(c>>>3)]<<16|u[3+(c>>>3)]<<24)>>>(7&c)},o.H.m=function(){const u=Uint16Array,c=Uint32Array;return{K:new u(16),j:new u(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new u(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new c(32),J:new u(512),_:[],h:new u(32),$:[],w:new u(32768),C:[],v:[],d:new u(32768),D:[],u:new u(512),Q:[],r:new u(32768),s:new c(286),Y:new c(30),a:new c(19),t:new c(15e3),k:new u(65536),g:new u(32768)}}(),function(){const u=o.H.m;for(var c=0;c<32768;c++){let y=c;y=(2863311530&y)>>>1|(1431655765&y)<<1,y=(3435973836&y)>>>2|(858993459&y)<<2,y=(4042322160&y)>>>4|(252645135&y)<<4,y=(4278255360&y)>>>8|(16711935&y)<<8,u.r[c]=(y>>>16|y<<16)>>>17}function f(y,C,k){for(;C--!=0;)y.push(0,k)}for(c=0;c<32;c++)u.q[c]=u.S[c]<<3|u.T[c],u.c[c]=u.p[c]<<4|u.z[c];f(u._,144,8),f(u._,112,9),f(u._,24,7),f(u._,8,8),o.H.n(u._,9),o.H.A(u._,9,u.J),o.H.l(u._,9),f(u.$,32,5),o.H.n(u.$,5),o.H.A(u.$,5,u.h),o.H.l(u.$,5),f(u.Q,19,0),f(u.C,286,0),f(u.D,30,0),f(u.v,320,0)}(),o.H.N}();function n(o){return[1,null,3,1,2,null,4][o.ctype]*o.depth}function s(o,u,c,f,y){let C=n(u);const k=Math.ceil(f*C/8);let b,w;C=Math.ceil(C/8);let g=o[c],h=0;if(g>1&&(o[c]=[0,0,1][g-2]),g==3)for(h=C;h>>1)&255;for(let S=0;S>>1);for(;h>>1)}else{for(;h=0&&b>=0?(S=U*u+j<<2,d=(b+U)*y+k+j<<2):(S=(-b+U)*u-k+j<<2,d=U*y+j<<2),w==0)f[d]=o[S],f[d+1]=o[S+1],f[d+2]=o[S+2],f[d+3]=o[S+3];else if(w==1){var I=o[S+3]*.00392156862745098,x=o[S]*I,A=o[S+1]*I,_=o[S+2]*I,R=f[d+3]*(1/255),T=f[d]*R,M=f[d+1]*R,N=f[d+2]*R;const v=1-I,P=I+R*v,L=P==0?0:1/P;f[d+3]=255*P,f[d+0]=(x+T*v)*L,f[d+1]=(A+M*v)*L,f[d+2]=(_+N*v)*L}else if(w==2)I=o[S+3],x=o[S],A=o[S+1],_=o[S+2],R=f[d+3],T=f[d],M=f[d+1],N=f[d+2],I==R&&x==T&&A==M&&_==N?(f[d]=0,f[d+1]=0,f[d+2]=0,f[d+3]=0):(f[d]=x,f[d+1]=A,f[d+2]=_,f[d+3]=I);else if(w==3){if(I=o[S+3],x=o[S],A=o[S+1],_=o[S+2],R=f[d+3],T=f[d],M=f[d+1],N=f[d+2],I==R&&x==T&&A==M&&_==N)continue;if(I<220&&R>20)return!1}return!0}return{decode:function(u){const c=new Uint8Array(u);let f=8;const y=e,C=y.readUshort,k=y.readUint,b={tabs:{},frames:[]},w=new Uint8Array(c.length);let g,h=0,S=0;const d=[137,80,78,71,13,10,26,10];for(var I=0;I<8;I++)if(c[I]!=d[I])throw"The input is not a PNG file!";for(;f>>1:_>>>=1;x[A]=_}return x}(),update(x,A,_,R){for(let T=0;T>>8;return x},crc:(x,A,_)=>4294967295^i.update(4294967295,x,A,_)};function t(x,A,_,R){A[_]+=x[0]*R>>4,A[_+1]+=x[1]*R>>4,A[_+2]+=x[2]*R>>4,A[_+3]+=x[3]*R>>4}function n(x){return Math.max(0,Math.min(255,x))}function s(x,A){const _=x[0]-A[0],R=x[1]-A[1],T=x[2]-A[2],M=x[3]-A[3];return _*_+R*R+T*T+M*M}function l(x,A,_,R,T,M,N){N==null&&(N=1);const U=R.length,j=[];for(var v=0;v>>0&255,F>>>8&255,F>>>16&255,F>>>24&255])}for(v=0;v>2]=P,q[v>>2]=R[P]}}function m(x,A,_,R,T){T==null&&(T={});const{crc:M}=i,N=r.writeUint,U=r.writeUshort,j=r.writeASCII;let v=8;const P=x.frames.length>1;let L,$=!1,q=33+(P?20:0);if(T.sRGB!=null&&(q+=13),T.pHYs!=null&&(q+=21),T.iCCP!=null&&(L=pako.deflate(T.iCCP),q+=21+L.length+4),x.ctype==3){for(var D=x.plte.length,W=0;W>>24!=255&&($=!0);q+=8+3*D+4+($?8+1*D+4:0)}for(var z=0;z>>8&255,K=Z>>>16&255;F[v+G+0]=Q,F[v+G+1]=X,F[v+G+2]=K}if(v+=3*D,N(F,v,M(F,v-3*D-4,3*D+4)),v+=4,$){for(N(F,v,D),v+=4,j(F,v,"tRNS"),v+=4,W=0;W>>24&255;v+=D,N(F,v,M(F,v-D-4,D+4)),v+=4}}let O=0;for(z=0;zBe&&(Be=$e),PeQe&&(Qe=Pe));Be==-1&&(Te=Re=Be=Qe=0),ie&&((1&Te)==1&&Te--,(1&Re)==1&&Re--);const Ut=(Be-Te+1)*(Qe-Re+1);Ut>2,fe>>2);G.push(Z);const ie=new Uint8Array(ee.abuf,le,fe);P&&l(Q.img,Q.rect.width,Q.rect.height,B,ie,Z),Q.img.set(ie),le+=fe}}else for(D=0;DX&&re==ue[z-X])Z[z]=Z[z-X];else{let ee=O[re];if(ee==null&&(O[re]=ee=B.length,B.push(re),B.length>=300))break;Z[z]=ee}}}const K=B.length;for(K<=256&&v==0&&($=K<=2?1:K<=4?2:K<=16?4:8,$=Math.max($,j)),D=0;D>1)]|=fe[ye+ne]<<4-4*(1&ne);else if($==2)for(ne=0;ne>2)]|=fe[ye+ne]<<6-2*(3&ne);else if($==1)for(ne=0;ne>3)]|=fe[ye+ne]<<7-1*(7&ne)}re=ce,L=3,le=1}else if(F==0&&V.length==1){ce=new Uint8Array(X*ue*3);const fe=X*ue;for(z=0;zz&&(z=G),ZF&&(F=Z))}z==-1&&(D=W=z=F=0),N&&((1&D)==1&&D--,(1&W)==1&&W--),M={x:D,y:W,width:z-D+1,height:F-W+1};const V=R[T];V.rect=M,V.blend=1,V.img=new Uint8Array(M.width*M.height*4),R[T-1].dispose==0?(e(v,A,_,V.img,M.width,M.height,-M.x,-M.y,0),c($,A,_,V.img,M)):e($,A,_,V.img,M.width,M.height,-M.x,-M.y,0)}function c(x,A,_,R,T){e(x,A,_,R,T.width,T.height,-T.x,-T.y,2)}function f(x,A,_,R,T,M,N){const U=[];let j,v=[0,1,2,3,4];M!=-1?v=[M]:(A*R>5e5||_==1)&&(v=[0]),N&&(j={level:0});const P=tn;for(var L=0;L>1)+256&255;if(M==4)for(j=T;j>1)&255;for(j=T;j>1)&255}if(M==4){for(j=0;j>2);let P;if(_.length<2e7)for(var L=0;L>2]=P.ind,T[L>>2]=P.est.rgba;else for(L=0;L>2]=P.ind,T[L>>2]=P.est.rgba}return{abuf:R.buffer,inds:v,plte:U}}function k(x,A,_){_==null&&(_=1e-4);const R=new Uint32Array(x.buffer),T={i0:0,i1:x.length,bst:null,est:null,tdst:0,left:null,right:null};T.bst=S(x,T.i0,T.i1),T.est=d(T.bst);const M=[T];for(;M.lengthU&&(U=M[N].est.L,j=N);if(U<_)break;const v=M[j],P=g(x,R,v.i0,v.i1,v.est.e,v.est.eMq255);if(v.i0>=P||v.i1<=P){v.est.L=0;continue}const L={i0:v.i0,i1:P,bst:null,est:null,tdst:0,left:null,right:null};L.bst=S(x,L.i0,L.i1),L.est=d(L.bst);const $={i0:P,i1:v.i1,bst:null,est:null,tdst:0,left:null,right:null};for($.bst={R:[],m:[],N:v.bst.N-L.bst.N},N=0;N<16;N++)$.bst.R[N]=v.bst.R[N]-L.bst.R[N];for(N=0;N<4;N++)$.bst.m[N]=v.bst.m[N]-L.bst.m[N];$.est=d($.bst),v.left=L,v.right=$,M[j]=L,M.push($)}for(M.sort((U,j)=>j.bst.N-U.bst.N),N=0;N0&&(N=x.right,U=x.left);const j=b(N,A,_,R,T);if(j.tdst<=M*M)return j;const v=b(U,A,_,R,T);return v.tdstM;)R-=4;if(_>=R)break;const N=A[_>>2];A[_>>2]=A[R>>2],A[R>>2]=N,_+=4,R-=4}for(;h(x,_,T)>M;)_-=4;return _+4}function h(x,A,_){return x[A]*_[0]+x[A+1]*_[1]+x[A+2]*_[2]+x[A+3]*_[3]}function S(x,A,_){const R=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],T=[0,0,0,0],M=_-A>>2;for(let N=A;N<_;N+=4){const U=x[N]*.00392156862745098,j=x[N+1]*(1/255),v=x[N+2]*(1/255),P=x[N+3]*(1/255);T[0]+=U,T[1]+=j,T[2]+=v,T[3]+=P,R[0]+=U*U,R[1]+=U*j,R[2]+=U*v,R[3]+=U*P,R[5]+=j*j,R[6]+=j*v,R[7]+=j*P,R[10]+=v*v,R[11]+=v*P,R[15]+=P*P}return R[4]=R[1],R[8]=R[2],R[9]=R[6],R[12]=R[3],R[13]=R[7],R[14]=R[11],{R,m:T,N:M}}function d(x){const{R:A}=x,{m:_}=x,{N:R}=x,T=_[0],M=_[1],N=_[2],U=_[3],j=R==0?0:1/R,v=[A[0]-T*T*j,A[1]-T*M*j,A[2]-T*N*j,A[3]-T*U*j,A[4]-M*T*j,A[5]-M*M*j,A[6]-M*N*j,A[7]-M*U*j,A[8]-N*T*j,A[9]-N*M*j,A[10]-N*N*j,A[11]-N*U*j,A[12]-U*T*j,A[13]-U*M*j,A[14]-U*N*j,A[15]-U*U*j],P=v,L=I;let $=[Math.random(),Math.random(),Math.random(),Math.random()],q=0,D=0;if(R!=0)for(let z=0;z<16&&($=L.multVec(P,$),D=Math.sqrt(L.dot($,$)),$=L.sml(1/D,$),!(z!=0&&Math.abs(D-q)<1e-9));z++)q=D;const W=[T*j,M*j,N*j,U*j];return{Cov:v,q:W,e:$,L:q,eMq255:L.dot(L.sml(255,W),$),eMq:L.dot($,W),rgba:(Math.round(255*W[3])<<24|Math.round(255*W[2])<<16|Math.round(255*W[1])<<8|Math.round(255*W[0])<<0)>>>0}}var I={multVec:(x,A)=>[x[0]*A[0]+x[1]*A[1]+x[2]*A[2]+x[3]*A[3],x[4]*A[0]+x[5]*A[1]+x[6]*A[2]+x[7]*A[3],x[8]*A[0]+x[9]*A[1]+x[10]*A[2]+x[11]*A[3],x[12]*A[0]+x[13]*A[1]+x[14]*A[2]+x[15]*A[3]],dot:(x,A)=>x[0]*A[0]+x[1]*A[1]+x[2]*A[2]+x[3]*A[3],sml:(x,A)=>[x*A[0],x*A[1],x*A[2],x*A[3]]};Se.encode=function(A,_,R,T,M,N,U){T==null&&(T=0),U==null&&(U=!1);const j=o(A,_,R,T,[!1,!1,!1,0,U,!1]);return p(j,-1),m(j,_,R,M,N)},Se.encodeLL=function(A,_,R,T,M,N,U,j){const v={ctype:0+(T==1?0:2)+(M==0?0:4),depth:N,frames:[]},P=(T+M)*N,L=P*_;for(let $=0;$>>0),S(1),S(32),d(3),d(m),d(2835),d(2835),I(8),d(16711680),d(65280),d(255),d(4278190080),d(1466527264),function x(){for(;w0;){for(k=122+w*l,f=0;f>>24,u.setUint32(k+f,y<<8|C),f+=4;w++}h{r(new Blob([a],{type:"image/bmp"}))})},_dly:9};var ge={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},rn={[ge.CHROME]:16384,[ge.FIREFOX]:11180,[ge.DESKTOP_SAFARI]:16384,[ge.IE]:8192,[ge.IOS]:4096,[ge.ETC]:8192};const kt=typeof window<"u",ar=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,lt=kt&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),nn=(kt||ar)&&(lt&<.getOriginalSymbol(window,"File")||typeof File<"u"&&File),sr=(kt||ar)&&(lt&<.getOriginalSymbol(window,"FileReader")||typeof FileReader<"u"&&FileReader);function _t(e,r,a=Date.now()){return new Promise(i=>{const t=e.split(","),n=t[0].match(/:(.*?);/)[1],s=globalThis.atob(t[1]);let l=s.length;const m=new Uint8Array(l);for(;l--;)m[l]=s.charCodeAt(l);const p=new Blob([m],{type:n});p.name=r,p.lastModified=a,i(p)})}function or(e){return new Promise((r,a)=>{const i=new sr;i.onload=()=>r(i.result),i.onerror=t=>a(t),i.readAsDataURL(e)})}function lr(e){return new Promise((r,a)=>{const i=new Image;i.onload=()=>r(i),i.onerror=t=>a(t),i.src=e})}function He(){if(He.cachedResult!==void 0)return He.cachedResult;let e=ge.ETC;const{userAgent:r}=navigator;return/Chrom(e|ium)/i.test(r)?e=ge.CHROME:/iP(ad|od|hone)/i.test(r)&&/WebKit/i.test(r)?e=ge.IOS:/Safari/i.test(r)?e=ge.DESKTOP_SAFARI:/Firefox/i.test(r)?e=ge.FIREFOX:(/MSIE/i.test(r)||document.documentMode)&&(e=ge.IE),He.cachedResult=e,He.cachedResult}function cr(e,r){const a=He(),i=rn[a];let t=e,n=r,s=t*n;const l=t>n?n/t:t/n;for(;s>i*i;){const m=(i+t)/2,p=(i+n)/2;mir.toBlob(e,o)).then((function(o){try{return l=o,l.name=a,l.lastModified=i,p.call(this)}catch(u){return s(u)}}).bind(this),s);{let o=function(){return p.call(this)};if(typeof OffscreenCanvas=="function"&&e instanceof OffscreenCanvas)return e.convertToBlob({type:r,quality:t}).then((function(u){try{return l=u,l.name=a,l.lastModified=i,o.call(this)}catch(c){return s(c)}}).bind(this),s);{let u;return u=e.toDataURL(r,t),_t(u,a,i).then((function(c){try{return l=c,o.call(this)}catch(f){return s(f)}}).bind(this),s)}}}function m(){return n(l)}})}function Ce(e){e.width=0,e.height=0}function Ge(){return new Promise(function(e,r){let a,i,t,n;return Ge.cachedResult!==void 0?e(Ge.cachedResult):_t("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then(function(s){try{return a=s,ct(a).then(function(l){try{return i=l[1],ut(i,a.type,a.name,a.lastModified).then(function(m){try{return t=m,Ce(i),ct(t).then(function(p){try{return n=p[0],Ge.cachedResult=n.width===1&&n.height===2,e(Ge.cachedResult)}catch(o){return r(o)}},r)}catch(p){return r(p)}},r)}catch(m){return r(m)}},r)}catch(l){return r(l)}},r)})}function dr(e){return new Promise((r,a)=>{const i=new sr;i.onload=t=>{const n=new DataView(t.target.result);if(n.getUint16(0,!1)!=65496)return r(-2);const s=n.byteLength;let l=2;for(;la(t),i.readAsArrayBuffer(e)})}function hr(e,r){const{width:a}=e,{height:i}=e,{maxWidthOrHeight:t}=r;let n,s=e;return isFinite(t)&&(a>t||i>t)&&([s,n]=ft(a,i),a>i?(s.width=t,s.height=i/a*t):(s.width=a/i*t,s.height=t),n.drawImage(e,0,0,s.width,s.height),Ce(e)),s}function fr(e,r){const{width:a}=e,{height:i}=e,[t,n]=ft(a,i);switch(r>4&&r<9?(t.width=i,t.height=a):(t.width=a,t.height=i),r){case 2:n.transform(-1,0,0,1,a,0);break;case 3:n.transform(-1,0,0,-1,a,i);break;case 4:n.transform(1,0,0,-1,0,i);break;case 5:n.transform(0,1,1,0,0,0);break;case 6:n.transform(0,1,-1,0,i,0);break;case 7:n.transform(0,-1,-1,0,i,a);break;case 8:n.transform(0,-1,1,0,0,a)}return n.drawImage(e,0,0,a,i),Ce(e),t}function Pt(e,r,a=0){return new Promise(function(i,t){let n,s,l,m,p,o,u,c,f,y,C,k,b,w,g,h,S,d,I,x;function A(R=5){if(r.signal&&r.signal.aborted)throw r.signal.reason;n+=R,r.onProgress(Math.min(n,100))}function _(R){if(r.signal&&r.signal.aborted)throw r.signal.reason;n=Math.min(Math.max(R,n),100),r.onProgress(n)}return n=a,s=r.maxIteration||10,l=1024*r.maxSizeMB*1024,A(),ct(e,r).then((function(R){try{return[,m]=R,A(),p=hr(m,r),A(),new Promise(function(T,M){var N;if(!(N=r.exifOrientation))return dr(e).then((function(j){try{return N=j,U.call(this)}catch(v){return M(v)}}).bind(this),M);function U(){return T(N)}return U.call(this)}).then((function(T){try{return o=T,A(),Ge().then((function(M){try{return u=M?p:fr(p,o),A(),c=r.initialQuality||1,f=r.fileType||e.type,ut(u,f,e.name,e.lastModified,c).then((function(N){try{{let j=function(){if(s--&&(g>l||g>b)){let P,L;return P=x?.95*I.width:I.width,L=x?.95*I.height:I.height,[S,d]=ft(P,L),d.drawImage(I,0,0,P,L),c*=f==="image/png"?.85:.95,ut(S,f,e.name,e.lastModified,c).then(function($){try{return h=$,Ce(I),I=S,g=h.size,_(Math.min(99,Math.floor((w-g)/(w-l)*100))),j}catch(q){return t(q)}},t)}return[1]},v=function(){return Ce(I),Ce(S),Ce(p),Ce(u),Ce(m),_(100),i(h)};if(y=N,A(),C=y.size>l,k=y.size>e.size,!C&&!k)return _(100),i(y);var U;return b=e.size,w=y.size,g=w,I=u,x=!r.alwaysKeepResolution&&C,(U=(function(P){for(;P;){if(P.then)return void P.then(U,t);try{if(P.pop){if(P.length)return P.pop()?v.call(this):P;P=j}else P=P.call(this)}catch(L){return t(L)}}}).bind(this))(j)}}catch(j){return t(j)}}).bind(this),t)}catch(N){return t(N)}}).bind(this),t)}catch(M){return t(M)}}).bind(this),t)}catch(T){return t(T)}}).bind(this),t)})}const an=` -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|0,h+=(S&g|d&~g)+w[12]-1926607734|0,h=(h<<20|h>>>12)+S|0,g+=(h^S^d)+w[5]-378558|0,g=(g<<4|g>>>28)+h|0,d+=(g^h^S)+w[8]-2022574463|0,d=(d<<11|d>>>21)+g|0,S+=(d^g^h)+w[11]+1839030562|0,S=(S<<16|S>>>16)+d|0,h+=(S^d^g)+w[14]-35309556|0,h=(h<<23|h>>>9)+S|0,g+=(h^S^d)+w[1]-1530992060|0,g=(g<<4|g>>>28)+h|0,d+=(g^h^S)+w[4]+1272893353|0,d=(d<<11|d>>>21)+g|0,S+=(d^g^h)+w[7]-155497632|0,S=(S<<16|S>>>16)+d|0,h+=(S^d^g)+w[10]-1094730640|0,h=(h<<23|h>>>9)+S|0,g+=(h^S^d)+w[13]+681279174|0,g=(g<<4|g>>>28)+h|0,d+=(g^h^S)+w[0]-358537222|0,d=(d<<11|d>>>21)+g|0,S+=(d^g^h)+w[3]-722521979|0,S=(S<<16|S>>>16)+d|0,h+=(S^d^g)+w[6]+76029189|0,h=(h<<23|h>>>9)+S|0,g+=(h^S^d)+w[9]-640364487|0,g=(g<<4|g>>>28)+h|0,d+=(g^h^S)+w[12]-421815835|0,d=(d<<11|d>>>21)+g|0,S+=(d^g^h)+w[15]+530742520|0,S=(S<<16|S>>>16)+d|0,h+=(S^d^g)+w[2]-995338651|0,h=(h<<23|h>>>9)+S|0,g+=(S^(h|~d))+w[0]-198630844|0,g=(g<<6|g>>>26)+h|0,d+=(h^(g|~S))+w[7]+1126891415|0,d=(d<<10|d>>>22)+g|0,S+=(g^(d|~h))+w[14]-1416354905|0,S=(S<<15|S>>>17)+d|0,h+=(d^(S|~g))+w[5]-57434055|0,h=(h<<21|h>>>11)+S|0,g+=(S^(h|~d))+w[12]+1700485571|0,g=(g<<6|g>>>26)+h|0,d+=(h^(g|~S))+w[3]-1894986606|0,d=(d<<10|d>>>22)+g|0,S+=(g^(d|~h))+w[10]-1051523|0,S=(S<<15|S>>>17)+d|0,h+=(d^(S|~g))+w[1]-2054922799|0,h=(h<<21|h>>>11)+S|0,g+=(S^(h|~d))+w[8]+1873313359|0,g=(g<<6|g>>>26)+h|0,d+=(h^(g|~S))+w[15]-30611744|0,d=(d<<10|d>>>22)+g|0,S+=(g^(d|~h))+w[6]-1560198380|0,S=(S<<15|S>>>17)+d|0,h+=(d^(S|~g))+w[13]+1309151649|0,h=(h<<21|h>>>11)+S|0,g+=(S^(h|~d))+w[4]-145523070|0,g=(g<<6|g>>>26)+h|0,d+=(h^(g|~S))+w[11]-1120210379|0,d=(d<<10|d>>>22)+g|0,S+=(g^(d|~h))+w[2]+718787259|0,S=(S<<15|S>>>17)+d|0,h+=(d^(S|~g))+w[9]-343485551|0,h=(h<<21|h>>>11)+S|0,b[0]=g+b[0]|0,b[1]=h+b[1]|0,b[2]=S+b[2]|0,b[3]=d+b[3]|0}function n(b){var w=[],g;for(g=0;g<64;g+=4)w[g>>2]=b.charCodeAt(g)+(b.charCodeAt(g+1)<<8)+(b.charCodeAt(g+2)<<16)+(b.charCodeAt(g+3)<<24);return w}function s(b){var w=[],g;for(g=0;g<64;g+=4)w[g>>2]=b[g]+(b[g+1]<<8)+(b[g+2]<<16)+(b[g+3]<<24);return w}function l(b){var w=b.length,g=[1732584193,-271733879,-1732584194,271733878],h,S,d,I,x,A;for(h=64;h<=w;h+=64)t(g,n(b.substring(h-64,h)));for(b=b.substring(h-64),S=b.length,d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],h=0;h>2]|=b.charCodeAt(h)<<(h%4<<3);if(d[h>>2]|=128<<(h%4<<3),h>55)for(t(g,d),h=0;h<16;h+=1)d[h]=0;return I=w*8,I=I.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(I[2],16),A=parseInt(I[1],16)||0,d[14]=x,d[15]=A,t(g,d),g}function m(b){var w=b.length,g=[1732584193,-271733879,-1732584194,271733878],h,S,d,I,x,A;for(h=64;h<=w;h+=64)t(g,s(b.subarray(h-64,h)));for(b=h-64>2]|=b[h]<<(h%4<<3);if(d[h>>2]|=128<<(h%4<<3),h>55)for(t(g,d),h=0;h<16;h+=1)d[h]=0;return I=w*8,I=I.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(I[2],16),A=parseInt(I[1],16)||0,d[14]=x,d[15]=A,t(g,d),g}function p(b){var w="",g;for(g=0;g<4;g+=1)w+=i[b>>g*8+4&15]+i[b>>g*8&15];return w}function o(b){var w;for(w=0;wd?new ArrayBuffer(0):(I=d-S,x=new ArrayBuffer(I),A=new Uint8Array(x),_=new Uint8Array(this,S,I),A.set(_),x)}}();function u(b){return/[\u0080-\uFFFF]/.test(b)&&(b=unescape(encodeURIComponent(b))),b}function c(b,w){var g=b.length,h=new ArrayBuffer(g),S=new Uint8Array(h),d;for(d=0;d>2]|=w.charCodeAt(h)<<(h%4<<3);return this._finish(S,g),d=o(this._hash),b&&(d=C(d)),this.reset(),d},k.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},k.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},k.prototype.setState=function(b){return this._buff=b.buff,this._length=b.length,this._hash=b.hash,this},k.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},k.prototype._finish=function(b,w){var g=w,h,S,d;if(b[g>>2]|=128<<(g%4<<3),g>55)for(t(this._hash,b),g=0;g<16;g+=1)b[g]=0;h=this._length*8,h=h.toString(16).match(/(.*?)(.{0,8})$/),S=parseInt(h[2],16),d=parseInt(h[1],16)||0,b[14]=S,b[15]=d,t(this._hash,b)},k.hash=function(b,w){return k.hashBinary(u(b),w)},k.hashBinary=function(b,w){var g=l(b),h=o(g);return w?C(h):h},k.ArrayBuffer=function(){this.reset()},k.ArrayBuffer.prototype.append=function(b){var w=y(this._buff.buffer,b),g=w.length,h;for(this._length+=b.byteLength,h=64;h<=g;h+=64)t(this._hash,s(w.subarray(h-64,h)));return this._buff=h-64>2]|=w[S]<<(S%4<<3);return this._finish(h,g),d=o(this._hash),b&&(d=C(d)),this.reset(),d},k.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},k.ArrayBuffer.prototype.getState=function(){var b=k.prototype.getState.call(this);return b.buff=f(b.buff),b},k.ArrayBuffer.prototype.setState=function(b){return b.buff=c(b.buff,!0),k.prototype.setState.call(this,b)},k.ArrayBuffer.prototype.destroy=k.prototype.destroy,k.ArrayBuffer.prototype._finish=k.prototype._finish,k.ArrayBuffer.hash=function(b,w){var g=m(new Uint8Array(b)),h=o(g);return w?C(h):h},k})})(mr);var on=mr.exports;const ln=Hr(on),ze={async uploadFile(e){var t,n;if(!this.validateFile(e))throw new Error("不支持的文件类型或文件大小超过限制");const r=await this.calculateMD5(e);let a=e;if(e.type.startsWith("image/"))try{a=await this.compressImage(e)}catch(s){console.warn("图片压缩失败,尝试使用原文件上传",s)}const i=await this.getOssSignature({file_hash:r,file_name:a.name});if(!((t=i.data)!=null&&t.repeat)&&((n=i.data)!=null&&n.sign_url)&&await this.uploadToOss(i.data.sign_url,a),!i.data)throw new Error("获取上传签名失败");return i.data},async createRecognitionTask(e,r,a){const i={file_url:e,file_hash:r,file_name:a,task_type:"FORMULA"};return De.post("/formula/recognition",i).then(t=>{if(!t.data)throw new Error("创建任务失败: 无返回数据");return t.data})},async getTaskResult(e){return De.get(`/formula/recognition/${e}`).then(r=>{if(!r.data)throw new Error("获取结果失败: 无返回数据");return r.data})},async getTaskList(e="FORMULA",r=1,a=5){return De.get(`/task/list?task_type=${e}&page=${r}&page_size=${a}`).then(i=>{if(!i.data)throw new Error("获取历史记录失败: 无返回数据");return i.data})},validateFile(e){const r=["image/jpeg","image/png","image/jpg"];return!(!e.type.startsWith("image/")&&r.indexOf(e.type)===-1&&!e.name.match(/\.(jpg|jpeg|png)$/i))},async compressImage(e){const r={maxSizeMB:5,maxWidthOrHeight:1920,useWebWorker:!0,initialQuality:.8};try{return await he(e,r)}catch(a){throw console.error("Image compression error:",a),a}},calculateMD5(e){return new Promise((r,a)=>{const i=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,t=2097152,n=Math.ceil(e.size/t);let s=0;const l=new ln.ArrayBuffer,m=new FileReader;m.onload=function(o){var u;(u=o.target)!=null&&u.result&&l.append(o.target.result),s++,s=e.size?e.size:o+t;m.readAsArrayBuffer(i.call(e,o,u))}p()})},async getOssSignature(e){return De.post("/oss/signature_url",e)},async uploadToOss(e,r){try{await fetch(e,{method:"PUT",body:r,headers:{"Content-Type":r.type||"application/octet-stream"}})}catch(a){throw console.error("Upload to OSS failed:",a),new Error("文件上传失败")}}};/** - * @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 mt-auto",title:o?"Signed In":c.common.login,children:E.jsx(Ot,{size:20})})]}):E.jsxs(E.Fragment,{children:[E.jsxs("div",{className:"flex flex-col h-full bg-white",children:[E.jsxs("div",{className:"p-6 pb-4",children:[E.jsxs("div",{className:"flex items-start justify-between mb-6",children:[E.jsxs("div",{children:[E.jsx("h2",{className:"text-lg font-bold text-gray-900 leading-tight",children:c.sidebar.title}),E.jsx("p",{className:"text-xs text-gray-500 mt-1",children:c.sidebar.subtitle})]}),E.jsx("button",{onClick:n,className:"p-1.5 -mr-1.5 text-gray-400 hover:text-gray-900 hover:bg-gray-100 rounded-md transition-colors",children:E.jsx(Nt,{size:18})})]}),E.jsx("div",{className:"mb-2",id:"sidebar-upload-area",children:E.jsxs("div",{onDragOver:h,onDragLeave:S,onDrop:d,onClick:()=>{var x;return(x=b.current)==null?void 0:x.click()},className:` - 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 rounded-lg hover:bg-gray-800 transition-colors flex items-center justify-center gap-2 text-sm font-medium shadow-lg shadow-gray-900/10",children:[E.jsx(Ot,{size:18}),c.common.login]})})]}),f&&E.jsx(Sn,{onClose:()=>y(!1)})]})}function Cn(){const{language:e,setLanguage:r,t:a}=_e(),[i,t]=H.useState(!1),[n,s]=H.useState(!1),[l,m]=H.useState(!1),[p,o]=H.useState(!1),u=H.useRef(null),c=H.useRef(null),f=async()=>{await navigator.clipboard.writeText("1018282100"),o(!0),setTimeout(()=>o(!1),2e3)};return H.useEffect(()=>{const y=C=>{u.current&&!u.current.contains(C.target)&&t(!1),c.current&&!c.current.contains(C.target)&&m(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]),E.jsxs("div",{className:"h-16 bg-white border-b border-gray-200 flex items-center justify-between px-6 flex-shrink-0 z-[60] relative",children:[E.jsxs("div",{className:"flex items-center gap-2",children:[E.jsx("span",{className:"w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center text-white font-serif italic text-lg shadow-blue-600/30 shadow-md",children:"T"}),E.jsx("span",{className:"text-xl font-bold text-gray-900 tracking-tight",children:"TexPixel"})]}),E.jsxs("div",{className:"flex items-center gap-3",children:[E.jsxs("div",{className:"relative",ref:c,children:[E.jsxs("button",{onClick:()=>m(!l),className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 rounded-lg text-gray-700 text-sm font-medium transition-colors",title:"Switch Language",children:[E.jsx(yn,{size:18}),E.jsx("span",{className:"hidden sm:inline",children:e==="en"?"English":"简体中文"}),E.jsx($t,{size:14,className:`transition-transform duration-200 ${l?"rotate-180":""}`})]}),l&&E.jsxs("div",{className:"absolute right-0 top-full mt-2 w-32 bg-white rounded-xl shadow-lg border border-gray-200 py-1 z-50 animate-in fade-in slide-in-from-top-2 duration-200",children:[E.jsxs("button",{onClick:()=>{r("en"),m(!1)},className:`w-full flex items-center justify-between px-4 py-2 text-sm transition-colors hover:bg-gray-50 ${e==="en"?"text-blue-600 font-medium":"text-gray-700"}`,children:["English",e==="en"&&E.jsx(at,{size:14})]}),E.jsxs("button",{onClick:()=>{r("zh"),m(!1)},className:`w-full flex items-center justify-between px-4 py-2 text-sm transition-colors hover:bg-gray-50 ${e==="zh"?"text-blue-600 font-medium":"text-gray-700"}`,children:["简体中文",e==="zh"&&E.jsx(at,{size:14})]})]})]}),E.jsxs("button",{id:"guide-button",className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 rounded-lg text-gray-700 text-sm font-medium transition-colors",onClick:()=>{window.dispatchEvent(new CustomEvent("start-user-guide"))},children:[E.jsx(mn,{size:18}),E.jsx("span",{className:"hidden sm:inline",children:a.common.guide})]}),E.jsxs("div",{className:"relative",children:[E.jsxs("button",{onClick:()=>s(!n),className:"flex items-center gap-2 px-4 py-2 bg-gradient-to-r from-rose-500 to-pink-500 hover:from-rose-600 hover:to-pink-600 rounded-lg text-white text-sm font-medium transition-all shadow-sm hover:shadow-md",children:[E.jsx(fn,{size:14,className:"fill-white"}),E.jsx("span",{children:a.common.reward})]}),n&&E.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[70] p-4",onClick:()=>s(!1),children:E.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-sm w-full p-6 animate-in fade-in zoom-in-95 duration-200",onClick:y=>y.stopPropagation(),children:[E.jsxs("div",{className:"flex items-center justify-between mb-4",children:[E.jsx("span",{className:"text-lg font-bold text-gray-900",children:a.navbar.rewardTitle}),E.jsx("button",{onClick:()=>s(!1),className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:E.jsx(Ze,{size:20,className:"text-gray-500"})})]}),E.jsxs("div",{className:"flex flex-col items-center",children:[E.jsx("img",{src:"https://cdn.texpixel.com/public/rewardcode.png",alt:a.navbar.rewardTitle,className:"w-64 h-64 object-contain rounded-lg shadow-sm"}),E.jsxs("p",{className:"text-sm text-gray-500 text-center mt-4",children:[a.navbar.rewardThanks,E.jsx("br",{}),E.jsx("span",{className:"text-xs text-gray-400 mt-1 block",children:a.navbar.rewardSubtitle})]})]})]})})]}),E.jsxs("div",{className:"relative",ref:u,children:[E.jsxs("button",{onClick:()=>t(!i),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg text-gray-700 text-sm font-medium transition-colors",children:[E.jsx(wn,{size:14}),E.jsx("span",{children:a.common.contactUs}),E.jsx($t,{size:14,className:`transition-transform duration-200 ${i?"rotate-180":""}`})]}),i&&E.jsxs("div",{className:"absolute right-0 top-full mt-2 w-64 bg-white rounded-xl shadow-lg border border-gray-200 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-200",children:[E.jsxs("a",{href:"mailto:yogecoder@gmail.com",className:"flex items-center gap-3 px-4 py-3 hover:bg-gray-50 transition-colors",children:[E.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center",children:E.jsx(xn,{size:16,className:"text-blue-600"})}),E.jsxs("div",{children:[E.jsx("div",{className:"text-xs text-gray-500",children:a.common.email}),E.jsx("div",{className:"text-sm font-medium text-gray-900",children:"yogecoder@gmail.com"})]})]}),E.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 hover:bg-gray-50 transition-all cursor-pointer ${p?"bg-green-50":""}`,onClick:f,children:[E.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center transition-colors ${p?"bg-green-500":"bg-green-100"}`,children:p?E.jsx(at,{size:16,className:"text-white"}):E.jsx(An,{size:16,className:"text-green-600"})}),E.jsxs("div",{children:[E.jsx("div",{className:`text-xs transition-colors ${p?"text-green-600 font-medium":"text-gray-500"}`,children:p?a.common.copied:a.common.qqGroup}),E.jsx("div",{className:"text-sm font-medium text-gray-900",children:"1018282100"})]})]})]})]})]})]})}function kn({file:e}){const{t:r}=_e(),[a,i]=H.useState(100),[t,n]=H.useState(1),s=1,l=()=>i(p=>Math.min(p+10,200)),m=()=>i(p=>Math.max(p-10,50));return e?E.jsxs("div",{className:"flex flex-col h-full bg-gray-100/50",children:[E.jsxs("div",{className:"h-16 flex items-center justify-between px-6 bg-white border-b border-gray-200 z-10 relative",children:[E.jsxs("div",{className:"flex items-center gap-3 overflow-hidden z-20",children:[E.jsx("div",{className:"p-2 bg-blue-50 text-blue-600 rounded-lg",children:E.jsx(zt,{size:18})}),E.jsx("h2",{className:"text-sm font-semibold text-gray-900 truncate max-w-[200px]",title:e.filename,children:e.filename})]}),E.jsxs("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 flex items-center gap-4 z-10",children:[E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx("button",{onClick:()=>n(p=>Math.max(1,p-1)),disabled:t===1,className:"p-1 hover:bg-white hover:shadow-sm rounded-md text-gray-500 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:shadow-none transition-all",children:E.jsx(Nt,{size:16})}),E.jsxs("span",{className:"text-xs font-medium text-gray-600 px-1 select-none min-w-[3rem] text-center",children:[t," / ",s]}),E.jsx("button",{onClick:()=>n(p=>Math.min(s,p+1)),disabled:t===s,className:"p-1 hover:bg-white hover:shadow-sm rounded-md text-gray-500 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:shadow-none transition-all",children:E.jsx(Tt,{size:16})})]}),E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx("button",{onClick:m,className:"p-1 hover:bg-white hover:shadow-sm rounded-md text-gray-500 transition-all",title:r.common.preview,children:E.jsx(vn,{size:16})}),E.jsxs("span",{className:"text-xs font-medium text-gray-600 min-w-[2.5rem] text-center select-none",children:[a,"%"]}),E.jsx("button",{onClick:l,className:"p-1 hover:bg-white hover:shadow-sm rounded-md text-gray-500 transition-all",title:r.common.preview,children:E.jsx(En,{size:16})})]})]})]}),E.jsx("div",{className:"flex-1 overflow-auto p-8 relative custom-scrollbar flex items-center justify-center border-r border-gray-200",children:E.jsx("div",{className:"bg-white shadow-2xl shadow-gray-200/50 transition-transform duration-200 ease-out origin-center max-w-full max-h-full flex items-center justify-center",style:{transform:`scale(${a/100})`},children:e.file_type==="application/pdf"?E.jsx("div",{className:"w-[595px] h-[842px] flex items-center justify-center bg-gray-50 border border-gray-100",children:E.jsx("p",{className:"text-gray-400",children:"PDF Preview Not Implemented"})}):E.jsx("img",{src:e.file_path||"https://images.pexels.com/photos/326514/pexels-photo-326514.jpeg?auto=compress&cs=tinysrgb&w=800",alt:e.filename,className:"max-w-full max-h-full object-contain block",draggable:!1})})})]}):E.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-white p-8 text-center border border-white border-solid",id:"file-preview-empty",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(zt,{size:48,className:"text-gray-900"})}),E.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:r.common.upload}),E.jsx("p",{className:"text-gray-500 max-w-xs",children:r.sidebar.uploadInstruction})]})}function _n(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Nn(e,r,a){const t=Fr({}.ignore||[]),n=Tn(r);let s=-1;for(;++s0?{type:"text",value:d}:void 0),d===!1?c.lastIndex=h+1:(y!==h&&w.push({type:"text",value:p.value.slice(y,h)}),Array.isArray(d)?w.push(...d):d&&w.push(d),y=h+g[0].length,b=!0),!c.global)break;g=c.exec(p.value)}return b?(ye.charCodeAt(0)));var vt;const Pn=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),$n=(vt=String.fromCodePoint)!==null&&vt!==void 0?vt:function(e){let r="";return e>65535&&(e-=65536,r+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),r+=String.fromCharCode(e),r};function zn(e){var r;return e>=55296&&e<=57343||e>1114111?65533:(r=Pn.get(e))!==null&&r!==void 0?r:e}var oe;(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(oe||(oe={}));const On=32;var Le;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(Le||(Le={}));function St(e){return e>=oe.ZERO&&e<=oe.NINE}function Dn(e){return e>=oe.UPPER_A&&e<=oe.UPPER_F||e>=oe.LOWER_A&&e<=oe.LOWER_F}function Hn(e){return e>=oe.UPPER_A&&e<=oe.UPPER_Z||e>=oe.LOWER_A&&e<=oe.LOWER_Z||St(e)}function Bn(e){return e===oe.EQUALS||Hn(e)}var se;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(se||(se={}));var Me;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(Me||(Me={}));class Wn{constructor(r,a,i){this.decodeTree=r,this.emitCodePoint=a,this.errors=i,this.state=se.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Me.Strict}startEntity(r){this.decodeMode=r,this.state=se.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(r,a){switch(this.state){case se.EntityStart:return r.charCodeAt(a)===oe.NUM?(this.state=se.NumericStart,this.consumed+=1,this.stateNumericStart(r,a+1)):(this.state=se.NamedEntity,this.stateNamedEntity(r,a));case se.NumericStart:return this.stateNumericStart(r,a);case se.NumericDecimal:return this.stateNumericDecimal(r,a);case se.NumericHex:return this.stateNumericHex(r,a);case se.NamedEntity:return this.stateNamedEntity(r,a)}}stateNumericStart(r,a){return a>=r.length?-1:(r.charCodeAt(a)|On)===oe.LOWER_X?(this.state=se.NumericHex,this.consumed+=1,this.stateNumericHex(r,a+1)):(this.state=se.NumericDecimal,this.stateNumericDecimal(r,a))}addToNumericResult(r,a,i,t){if(a!==i){const n=i-a;this.result=this.result*Math.pow(t,n)+Number.parseInt(r.substr(a,n),t),this.consumed+=n}}stateNumericHex(r,a){const i=a;for(;a>14;for(;a>14,n!==0){if(s===oe.SEMI)return this.emitNamedEntityData(this.treeIndex,n,this.consumed+this.excess);this.decodeMode!==Me.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var r;const{result:a,decodeTree:i}=this,t=(i[a]&Le.VALUE_LENGTH)>>14;return this.emitNamedEntityData(a,t,this.consumed),(r=this.errors)===null||r===void 0||r.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(r,a,i){const{decodeTree:t}=this;return this.emitCodePoint(a===1?t[r]&~Le.VALUE_LENGTH:t[r+1],i),a===3&&this.emitCodePoint(t[r+2],i),i}end(){var r;switch(this.state){case se.NamedEntity:return this.result!==0&&(this.decodeMode!==Me.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case se.NumericDecimal:return this.emitNumericEntity(0,2);case se.NumericHex:return this.emitNumericEntity(0,3);case se.NumericStart:return(r=this.errors)===null||r===void 0||r.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case se.EntityStart:return 0}}}function qn(e){let r="";const a=new Wn(e,i=>r+=$n(i));return function(t,n){let s=0,l=0;for(;(l=t.indexOf("&",l))>=0;){r+=t.slice(s,l),a.startEntity(n);const p=a.write(t,l+1);if(p<0){s=l+a.end();break}s=l+p,l=p===0?s+1:s}const m=r+t.slice(s);return r="",m}}function Gn(e,r,a,i){const t=(r&Le.BRANCH_LENGTH)>>7,n=r&Le.JUMP_TABLE;if(t===0)return n!==0&&i===n?a:-1;if(n){const m=i-n;return m<0||m>=t?-1:e[a+m]-1}let s=a,l=s+t-1;for(;s<=l;){const m=s+l>>>1,p=e[m];if(pi)l=m-1;else return e[m+t]}return-1}const Vn=qn(Fn);function Dt(e){return Vn(e,Me.Strict)}const Qn=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function Ht(e){const r={type:"tag",name:"",voidElement:!1,attribs:{},children:[]},a=e.match(/<\/?([^\s]+?)[/\s>]/);if(a&&(r.name=a[1],e.charAt(e.length-2)==="/"&&(r.voidElement=!0),r.name.startsWith("!--"))){const n=e.indexOf("-->");return{type:"comment",comment:n!==-1?e.slice(4,n):""}}const i=new RegExp(Qn);let t=null;for(;t=i.exec(e),t!==null;)if(t[0].trim())if(t[1]){const n=t[1].trim();let s=[n,""];n.indexOf("=")>-1&&(s=n.split("=")),r.attribs[s[0]]=s[1],i.lastIndex--}else t[2]&&(r.attribs[t[2]]=t[3].trim().substring(1,t[3].length-1));return r}const Xn=/<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Zn=/^\s*$/,Bt=["mtext","mi","mn","mo","ms"];function Kn(e,r={}){const a=[],i=[];let t,n=-1;return e.replace(Xn,(s,l)=>{var f;const m=s.charAt(1)!=="/",p=s.startsWith("`,e}}function Jn(e){return e.reduce((r,a)=>r+vr("",a),"")}function ei(e,r,a,i,t){return r.name="m:oMath",r.attribs={"xmlns:m":"http://schemas.openxmlformats.org/officeDocument/2006/math","xmlns:w":"http://schemas.openxmlformats.org/wordprocessingml/2006/main"},r.type="tag",r.children=[],r}function ti(e,r,a,i,t){return r}function ri(e,r,a,i,t){var l,m;const n=((m=(l=e.attribs)==null?void 0:l.notation)==null?void 0:m.split(" ")[0])||"longdiv",s={type:"tag",name:"m:e",attribs:{},children:[]};if(n==="longdiv")r.children.push({type:"tag",name:"m:rad",attribs:{},children:[{type:"tag",name:"m:radPr",attribs:{},children:[{type:"tag",name:"m:degHide",attribs:{"m:val":"on"},children:[]}]},{type:"tag",name:"m:deg",attribs:{},children:[]},s]});else{const p={t:{type:"tag",name:"m:hideTop",attribs:{"m:val":"on"},children:[]},b:{type:"tag",name:"m:hideBot",attribs:{"m:val":"on"},children:[]},l:{type:"tag",name:"m:hideLeft",attribs:{"m:val":"on"},children:[]},r:{type:"tag",name:"m:hideRight",attribs:{"m:val":"on"},children:[]}},o={type:"tag",name:"m:borderBoxPr",attribs:{},children:[]},u={type:"tag",name:"m:borderBox",attribs:{},children:[]};switch(n){case"actuarial":case"radical":case"box":u.children=[s];break;case"left":case"roundedbox":o.children=[p.t,p.b,p.r],u.children=[o,s];break;case"right":case"circle":o.children=[p.t,p.b,p.l],u.children=[o,s];break;case"top":o.children=[p.b,p.l,p.r],u.children=[o,s];break;case"bottom":o.children=[p.t,p.l,p.r],u.children=[o,s];break;case"updiagonalstrike":o.children=[p.t,p.b,p.l,p.r,{type:"tag",name:"m:strikeBLTR",attribs:{"m:val":"on"},children:[]}],u.children=[o,s];break;case"downdiagonalstrike":o.children=[p.t,p.b,p.l,p.r,{type:"tag",name:"m:strikeTLBR",attribs:{"m:val":"on"},children:[]}],u.children=[o,s];break;case"verticalstrike":o.children=[p.t,p.b,p.l,p.r,{type:"tag",name:"m:strikeV",attribs:{"m:val":"on"},children:[]}],u.children=[o,s];break;case"horizontalstrike":o.children=[p.t,p.b,p.l,p.r,{type:"tag",name:"m:strikeH",attribs:{"m:val":"on"},children:[]}],u.children=[o,s];break;default:o.children=[p.t,p.b,p.l,p.r],u.children=[o,s];break}r.children.push(u)}return s}function ni(e,r,a,i,t){var o;if(e.children.length!==2)return r;const n=e.children[0],s=e.children[1],l={name:"m:num",type:"tag",attribs:{},children:[]},m={name:"m:den",type:"tag",attribs:{},children:[]};t=[...t],t.unshift(e),J(n,l,!1,!1,t),J(s,m,!1,!1,t);const p=((o=e.attribs)==null?void 0:o.linethickness)==="0"?"noBar":"bar";r.children.push({type:"tag",name:"m:f",attribs:{},children:[{type:"tag",name:"m:fPr",attribs:{},children:[{type:"tag",name:"m:type",attribs:{"m:val":p},children:[]}]},l,m]})}function ii(e,r,a,i,t){var n;(n=e.attribs)!=null&&n.alt&&r.children.push({type:"text",data:e.attribs.alt})}function ai(e,r,a,i,t){if(e.children.length===0)return;const n=e.children[0],s=[],l=[],m=[],p=[],o=e.children.slice(1);let u=!1;o.forEach((y,C)=>{y.name==="mprescripts"?u=!0:y.name!=="none"&&(C%2?u?m.push(y):l.push(y):u?p.push(y):s.push(y))}),t=[...t],t.unshift(e);const c={children:[]};J(n,c,!1,!1,t);let f=c.children[0];if(s.length||l.length){const y={name:"m:sub",type:"tag",attribs:{},children:[]};s.forEach(b=>J(b,y,!1,!1,t));const C={name:"m:sup",type:"tag",attribs:{},children:[]};l.forEach(b=>J(b,C,!1,!1,t));const k={type:"tag",attribs:{},children:[{type:"tag",name:"m:e",attribs:{},children:[f]}]};s.length&&l.length?(k.name="m:sSubSup",k.children.push(y),k.children.push(C)):s.length?(k.name="m:sSub",k.children.push(y)):(k.name="m:sSup",k.children.push(C)),f=k}if(m.length||p.length){const y={name:"m:sub",type:"tag",attribs:{},children:[]};m.forEach(b=>J(b,y,!1,!1,t));const C={name:"m:sup",type:"tag",attribs:{},children:[]};p.forEach(b=>J(b,C,!1,!1,t)),f={name:"m:sPre",type:"tag",attribs:{},children:[{name:"m:e",type:"tag",attribs:{},children:[f]},y,C]}}r.children.push(f)}function si(e,r,a,i,t){if(a.isNary){const n=r.children[r.children.length-1];return n.children[n.children.length-1]}return r}function oi(e,r,a,i,t){r.children.push({name:"m:r",type:"tag",attribs:{},children:[{name:"m:t",type:"tag",attribs:{"xml:space":"preserve"},children:[{type:"text",data:" "}]}]})}function li(e,r,a,i,t){const n={name:"m:e",type:"tag",attribs:{},children:[]};return r.children.push({name:"m:rad",type:"tag",attribs:{},children:[{name:"m:radPr",type:"tag",attribs:{},children:[{name:"m:degHide",type:"tag",attribs:{"m:val":"on"},children:[]}]},{name:"m:deg",type:"tag",attribs:{},children:[]},n]}),n}function ci(e,r,a,i,t){return r}function Ke(e,r=!0){let a="";if(e.type==="text"){let i=e.data.replace(/[\u2062]|[\u200B]/g,"");r&&(i=i.trim()),a+=i}else e.children&&e.children.forEach(i=>{a+=Ke(i,r)});return a}const ui=/^[\u220f-\u2211]|[\u2229-\u2233]|[\u22c0-\u22c3]$/,di=/^\u220f|\u2211|[\u2229-\u222b]|\u222e|\u222f|\u2232|\u2233|[\u22c0-\u22c3]$/;function Ye(e){const r=Ke(e);return ui.test(r)?r:!1}function Je(e,r,a,i=!1,t=!1){var l;const n=(l=r.attribs)==null?void 0:l.stretchy,s=n==="true"?"1":n==="false"?"0":di.test(e)?"1":"0";return{type:"tag",name:"m:nary",attribs:{},children:[{type:"tag",name:"m:naryPr",attribs:{},children:[{type:"tag",name:"m:chr",attribs:{"m:val":e},children:[]},{type:"tag",name:"m:limLoc",attribs:{"m:val":a},children:[]},{type:"tag",name:"m:grow",attribs:{"m:val":s},children:[]},{type:"tag",name:"m:subHide",attribs:{"m:val":i?"on":"off"},children:[]},{type:"tag",name:"m:supHide",attribs:{"m:val":t?"on":"off"},children:[]}]}]}}function hi(e,r){var i,t;const a=(t=(i=r.find(n=>{var s;return(s=n.attribs)==null?void 0:s.scriptlevel}))==null?void 0:i.attribs)==null?void 0:t.scriptlevel;["0","1","2"].includes(a)&&e.children.unshift({type:"tag",name:"m:argPr",attribs:{},children:[{type:"tag",name:"m:scrLvl",attribs:{"m:val":a},children:[]}]})}function fi(e,r,a,i,t){var o,u,c,f;if(e.children.length!==2)return r;t=[...t],t.unshift(e);const n=e.children[0],s=e.children[1];let l;const m=Ye(n);if(m&&((u=(o=e.attribs)==null?void 0:o.accent)==null?void 0:u.toLowerCase())!=="true"&&((f=(c=e.attribs)==null?void 0:c.accentunder)==null?void 0:f.toLowerCase())!=="true")l=Je(m,e,"subSup",!1,!0),e.isNary=!0;else{const y={name:"m:e",type:"tag",attribs:{},children:[]};J(n,y,!1,!1,t),l={type:"tag",name:"m:sSub",attribs:{},children:[{type:"tag",name:"m:sSubPr",attribs:{},children:[{type:"tag",name:"m:ctrlPr",attribs:{},children:[]}]},y]}}const p={name:"m:sub",type:"tag",attribs:{},children:[]};J(s,p,!1,!1,t),l.children.push(p),e.isNary&&(l.children.push({type:"tag",name:"m:sup",attribs:{},children:[]}),l.children.push({type:"tag",name:"m:e",attribs:{},children:[]})),r.children.push(l)}function mi(e,r,a,i,t){var c,f,y,C;if(e.children.length!==3)return r;t=[...t],t.unshift(e);const n=e.children[0],s=e.children[1],l=e.children[2];let m;const p=Ye(n);if(p&&((f=(c=e.attribs)==null?void 0:c.accent)==null?void 0:f.toLowerCase())!=="true"&&((C=(y=e.attribs)==null?void 0:y.accentunder)==null?void 0:C.toLowerCase())!=="true")m=Je(p,e,"subSup"),e.isNary=!0;else{const k={name:"m:e",type:"tag",attribs:{},children:[]};J(n,k,!1,!1,t),m={type:"tag",name:"m:sSubSup",attribs:{},children:[{type:"tag",name:"m:sSubSupPr",attribs:{},children:[{type:"tag",name:"m:ctrlPr",attribs:{},children:[]}]},k]}}const o={name:"m:sub",type:"tag",attribs:{},children:[]},u={name:"m:sup",type:"tag",attribs:{},children:[]};J(s,o,!1,!1,t),J(l,u,!1,!1,t),m.children.push(o),m.children.push(u),e.isNary&&m.children.push({type:"tag",name:"m:e",attribs:{},children:[]}),r.children.push(m)}function gi(e,r,a,i,t){var o,u,c,f;if(e.children.length!==2)return r;t=[...t],t.unshift(e);const n=e.children[0],s=e.children[1];let l;const m=Ye(n);if(m&&((u=(o=e.attribs)==null?void 0:o.accent)==null?void 0:u.toLowerCase())!=="true"&&((f=(c=e.attribs)==null?void 0:c.accentunder)==null?void 0:f.toLowerCase())!=="true")l=Je(m,e,"subSup",!0),e.isNary=!0,l.children.push({type:"tag",name:"m:sub"});else{const y={name:"m:e",type:"tag",attribs:{},children:[]};J(n,y,!1,!1,t),l={type:"tag",name:"m:sSup",attribs:{},children:[{type:"tag",name:"m:sSupPr",attribs:{},children:[{type:"tag",name:"m:ctrlPr",attribs:{},children:[]}]},y]}}const p={name:"m:sup",type:"tag",attribs:{},children:[]};J(s,p,!1,!1,t),l.children.push(p),e.isNary&&l.children.push({type:"tag",name:"m:e",attribs:{},children:[]}),r.children.push(l)}function pi(e,r,a,i,t){const n=Math.max(...e.children.map(l=>l.children.length)),s={name:"m:m",type:"tag",attribs:{},children:[{name:"m:mPr",type:"tag",attribs:{},children:[{name:"m:baseJc",type:"tag",attribs:{"m:val":"center"},children:[]},{name:"m:plcHide",type:"tag",attribs:{"m:val":"on"},children:[]},{name:"m:mcs",type:"tag",attribs:{},children:[{name:"m:mc",type:"tag",attribs:{},children:[{name:"m:mcPr",type:"tag",attribs:{},children:[{name:"m:count",type:"tag",attribs:{"m:val":n.toString()},children:[]},{name:"m:mcJc",type:"tag",attribs:{"m:val":"center"},children:[]}]}]}]}]}]};return r.children.push(s),s}function yi(e,r,a,i,t){const n={name:"m:e",type:"tag",attribs:{},children:[]};return r.children.push(n),n}function bi(e,r,a,i,t){const n={name:"m:mr",type:"tag",attribs:{},children:[]};return r.children.push(n),n}function xi(e,r,a,i,t){var c,f,y,C;if(e.children.length!==3)return r;t=[...t],t.unshift(e);const n=e.children[0],s=e.children[1],l=e.children[2],m=Ye(n);if(m&&((f=(c=e.attributes)==null?void 0:c.accent)==null?void 0:f.toLowerCase())!=="true"&&((C=(y=e.attributes)==null?void 0:y.accentunder)==null?void 0:C.toLowerCase())!=="true"){const k=Je(m,e,"undOvr");e.isNary=!0;const b={name:"m:sub",type:"tag",attribs:{},children:[]},w={name:"m:sup",type:"tag",attribs:{},children:[]};J(s,b,!1,!1,t),J(l,w,!1,!1,t),k.children.push(b),k.children.push(w),k.children.push({type:"tag",name:"m:e",attribs:{},children:[]}),r.children.push(k);return}const p={name:"m:e",type:"tag",attribs:{},children:[]};J(n,p,!1,!1,t);const o={name:"m:lim",type:"tag",attribs:{},children:[]},u={name:"m:lim",type:"tag",attribs:{},children:[]};J(s,o,!1,!1,t),J(l,u,!1,!1,t),r.children.push({type:"tag",name:"m:limUpp",attribs:{},children:[{type:"tag",name:"m:e",attribs:{},children:[{type:"tag",name:"m:limLow",attribs:{},children:[p,o]}]},u]})}function wi(e,r,a={}){var u,c,f,y,C,k,b;const i=e.attribs||{},t=i.mathcolor||((u=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.color))==null?void 0:u.attribs.color)||"",n=i.mathsize||((c=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.mathsize))==null?void 0:c.attribs.mathsize)||"",s=i.scriptlevel||((f=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.scriptlevel))==null?void 0:f.attribs.scriptlevel)||"",l=i.mathbackground||((y=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.mathbackground))==null?void 0:y.attribs.mathbackground)||"";let m=i.mathvariant||((C=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.mathvariant))==null?void 0:C.attribs.mathvariant)||"";m==="b-i"&&(m="bold-italic");const p=i.fontweight||((k=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.fontweight))==null?void 0:k.attribs.fontweight)||"";p==="bold"&&!["bold","bold-italic"].includes(m)?m.includes("italic")?m="bold-italic":m="bold":p==="normal"&&["bold","bold-italic"].includes(m)&&(m.includes("italic")?m="italic":m="");const o=i.fontstyle||((b=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.fontstyle))==null?void 0:b.attribs.fontstyle)||"";if(o==="italic"&&!["italic","bold-italic"].includes(m)?m.includes("bold")?m="bold-italic":m="italic":o==="normal"&&["italic","bold-italic"].includes(m)&&(m.includes("bold")?m="bold":m=""),!i.mathvariant){const w=Ke(e);a.variant===""&&(e.name==="mi"&&w.length>1||e.name==="mn"&&!/^\d+\.\d+$/.test(w))?m="":["mi","mn","mo"].includes(e.name)&&["italic","bold-italic"].includes(a.variant)&&(p==="bold"?m="bold-italic":m="italic")}return{color:t,variant:m,size:n,scriptlevel:s,background:l,fontstyle:o}}const vi={bold:"b",italic:"i","bold-italic":"bi"};function et(e,r,a,i,t,n){var u;if(a.isNary){const c=r.children[r.children.length-1];r=c.children[c.children.length-1]}const s=(u=e.children)==null?void 0:u.find(c=>c.name==="mglyph"),l=wi(e,t,a==null?void 0:a.style);e.style=l,e.hasMglyphChild=s;const m=Object.keys(l).every(c=>{const f=a==null?void 0:a.style;return f&&l[c]===f[c]})&&(a==null?void 0:a.hasMglyphChild)===s,p=n===(a==null?void 0:a.name)||["mi","mn","mo"].includes(n)&&["mi","mn","mo"].includes(a==null?void 0:a.name);let o;if(p&&m&&!s){const c=r.children[r.children.length-1];o=c.children[c.children.length-1]}else{const c={name:"m:r",type:"tag",attribs:{},children:[]};if(l.variant){const f={name:"w:rPr",type:"tag",attribs:{},children:[]};l.variant.includes("bold")&&f.children.push({name:"w:b",type:"tag",attribs:{},children:[]}),l.variant.includes("italic")&&f.children.push({name:"w:i",type:"tag",attribs:{},children:[]}),c.children.push(f);const y={name:"m:rPr",type:"tag",attribs:{},children:[{name:"m:nor",type:"tag",attribs:{},children:[]}]};l.variant!=="italic"&&y.children.push({name:"m:sty",type:"tag",attribs:{"m:val":vi[l.variant]},children:[]}),c.children.push(y)}else s||n==="mtext"?c.children.push({name:"m:rPr",type:"tag",attribs:{},children:[{name:"m:nor",type:"tag",attribs:{},children:[]}]}):(l.fontstyle==="normal"||n==="ms"&&l.fontstyle==="")&&c.children.push({name:"m:rPr",type:"tag",attribs:{},children:[{name:"m:sty",type:"tag",attribs:{"m:val":"p"},children:[]}]});o={name:"m:t",type:"tag",attribs:{"xml:space":"preserve"},children:[]},c.children.push(o),r.children.push(c)}return o}function Ei(e,r,a,i,t){return et(e,r,a,i,t,"mtext")}function Ai(e,r,a,i,t){return et(e,r,a,i,t,"mi")}function Si(e,r,a,i,t){return et(e,r,a,i,t,"mn")}function ji(e,r,a,i,t){return et(e,r,a,i,t,"mo")}function Ci(e,r,a,i,t){return et(e,r,a,i,t,"ms")}const ki={"←":"⃖","⟵":"⃖","→":"⃗","⟶":"⃗","´":"́","˝":"̋","˘":"̆","ˇ":"̌","¸":"̒","^":"̂","¨":"̈","˙":"̇","`":"̀","-":"̅","¯":"̅","−":"̅",".":"̇","~":"̃","˜":"̃"};function Er(e,r,a,i,t,n){var c,f,y,C,k,b,w,g,h,S,d,I;if(e.children.length!==2)return r;t=[...t],t.unshift(e);const s=e.children[0],l=e.children[1],m=Ye(s);if(m&&((f=(c=e.attribs)==null?void 0:c.accent)==null?void 0:f.toLowerCase())!=="true"&&((C=(y=e.attribs)==null?void 0:y.accentunder)==null?void 0:C.toLowerCase())!=="true"){const x=Je(m,e,"undOvr",n==="over",n==="under");e.isNary=!0;const A={name:"m:sub",type:"tag",attribs:{},children:[]},_={name:"m:sup",type:"tag",attribs:{},children:[]};J(l,n==="under"?A:_,!1,!1,t),x.children.push(A),x.children.push(_),x.children.push({type:"tag",name:"m:e",attribs:{},children:[]}),r.children.push(x);return}const p=Ke(l),o={name:"m:e",type:"tag",attribs:{},children:[]};if(J(s,o,!1,!1,t),n==="under"&&l.name==="mo"&&["̲","_"].includes(p)||n==="over"&&l.name==="mo"&&["̅","¯"].includes(p)){r.children.push({type:"tag",name:"m:bar",attribs:{},children:[{type:"tag",name:"m:barPr",attribs:{},children:[{type:"tag",name:"m:pos",attribs:{"m:val":n==="under"?"bot":"top"},children:[]}]},{type:"tag",name:"m:e",attribs:{},children:[{type:"tag",name:n==="under"?"m:sSub":"m:sSup",attribs:{},children:[{type:"tag",name:n==="under"?"m:sSubPr":"m:sSupPr",attribs:{},children:[{type:"tag",name:"m:ctrlPr",attribs:{},children:[]}]},o,{type:"tag",name:"m:sub",attribs:{},children:[]}]}]}]});return}if(n==="under"&&((b=(k=e.attribs)==null?void 0:k.accentunder)==null?void 0:b.toLowerCase())==="true"&&l.name==="mo"&&p.length<2||n==="over"&&((g=(w=e.attribs)==null?void 0:w.accent)==null?void 0:g.toLowerCase())==="true"&&l.name==="mo"&&p.length<2){r.children.push({type:"tag",name:"m:acc",attribs:{},children:[{type:"tag",name:"m:accPr",attribs:{},children:[{type:"tag",name:"m:chr",attribs:{"m:val":ki[p]||p},children:[]}]},o]});return}if(((S=(h=e.attribs)==null?void 0:h.accent)==null?void 0:S.toLowerCase())!=="true"&&((I=(d=e.attribs)==null?void 0:d.accentunder)==null?void 0:I.toLowerCase())!=="true"&&l.name==="mo"&&s.name==="mrow"&&p.length===1){r.children.push({type:"tag",name:"m:groupChr",attribs:{},children:[{type:"tag",name:"m:groupChrPr",attribs:{},children:[{type:"tag",name:"m:chr",attribs:{"m:val":p,"m:pos":n==="under"?"bot":"top"},children:[]}]},o]});return}const u={name:"m:lim",type:"tag",attribs:{},children:[]};J(l,u,!1,!1,t),r.children.push({type:"tag",name:n==="under"?"m:limLow":"m:limUpp",attribs:{},children:[o,u]})}function _i(e,r,a,i,t){return Er(e,r,a,i,t,"under")}function Ni(e,r,a,i,t){return Er(e,r,a,i,t,"over")}function Ti(e,r,a,i,t){if(e.children.length!==2)return r;t=[...t],t.unshift(e);const n=e.children[0],s=e.children[1],l={type:"tag",name:"m:e",attribs:{},children:[]};J(n,l,!1,!1,t);const m={type:"tag",name:"m:deg",attribs:{},children:[]};J(s,m,!1,!1,t);const p=Ke(s);r.children.push({type:"tag",name:"m:rad",attribs:{},children:[{type:"tag",name:"m:radPr",attribs:{},children:[{type:"tag",name:"m:degHide",attribs:{"m:val":p.length?"off":"on"},children:[]}]},m,l]})}function Ri(e,r,a,i,t){var s,l;let n=e.data.replace(/[\u2062]|[\u200B]/g,"");if(t.find(m=>["mi","mn","mo"].includes(m.name)))n=n.replace(/\s/g,"");else{const m=t.find(p=>p.name==="ms");m&&(n=(((s=m.attribs)==null?void 0:s.lquote)||'"')+n+(((l=m.attribs)==null?void 0:l.rquote)||'"'))}return n.length&&(r.children.length&&r.children[r.children.length-1].type==="text"?r.children[r.children.length-1].data+=n:r.children.push({type:"text",data:n})),r}var Wt=Object.freeze({__proto__:null,math:ei,menclose:ri,mfrac:ni,mglyph:ii,mi:Ai,mmultiscripts:ai,mn:Si,mo:ji,mover:Ni,mroot:Ti,mrow:si,ms:Ci,mspace:oi,msqrt:li,mstyle:ci,msub:fi,msubsup:mi,msup:gi,mtable:pi,mtd:yi,mtext:Ei,mtr:bi,munder:_i,munderover:xi,semantics:ti,text:Ri});function J(e,r,a=!1,i=!1,t=[]){var l;!a&&["m:deg","m:den","m:e","m:fName","m:lim","m:num","m:sub","m:sup"].includes(r.name)&&hi(r,t);let n;const s=e.name||e.type;if(Wt[s]?n=Wt[s](e,r,a,i,t):(s&&s!=="root"&&console.warn(`Type not supported: ${s}`),n=r),!!n&&(l=e.children)!=null&&l.length){t=[...t],t.unshift(e);for(let m=0;m{const a=new Mi(e,r);return a.run(),a.getResult()};function Ui(e){return e.replace(//g,"").replace(//g,"").replace(//g,"").replace(/ xmlns:m="[^"]*"/g,"").replace(/ xmlns:w="[^"]*"/g,"")}async function Ii(e){try{const r=Li(e);return Ui(r)}catch(r){return console.error("MathML to OMML conversion failed:",r),""}}function Fi(e){return` - -${e.replace(/]*>/g,"").replace(/<\/m:oMath>/g,"")} -`}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;axe||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{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){const i=await fetch(e,r);if(i.status===404)throw new Error(`Resource "${i.url}" not found`);const t=await i.blob();return new Promise((n,s)=>{const l=new FileReader;l.onerror=s,l.onloadend=()=>{try{n(a({res:i,result:l.result}))}catch(m){s(m)}},l.readAsDataURL(t)})}const Et={};function ea(e,r,a){let i=e.replace(/\?.*/,"");return a&&(i=e),/ttf|otf|eot|woff2?/i.test(i)&&(i=i.replace(/.*\//,"")),r?`[${r}]${i}`:i}async function Mt(e,r,a){const i=ea(e,r,a.includeQueryParams);if(Et[i]!=null)return Et[i];a.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let t;try{const n=await jr(e,a.fetchRequestInit,({res:s,result:l})=>(r||(r=s.headers.get("Content-Type")||""),Yi(l)));t=Ji(n,r)}catch(n){t=a.imagePlaceholder||"";let s=`Failed to fetch resource: ${e}`;n&&(s=typeof n=="string"?n:n.message),s&&console.warn(s)}return Et[i]=t,t}async function ta(e){const r=e.toDataURL();return r==="data:,"?e.cloneNode(!1):ht(r)}async function ra(e,r){if(e.currentSrc){const n=document.createElement("canvas"),s=n.getContext("2d");n.width=e.clientWidth,n.height=e.clientHeight,s==null||s.drawImage(e,0,0,n.width,n.height);const l=n.toDataURL();return ht(l)}const a=e.poster,i=Rt(a),t=await Mt(a,i,r);return ht(t)}async function na(e,r){var a;try{if(!((a=e==null?void 0:e.contentDocument)===null||a===void 0)&&a.body)return await mt(e.contentDocument.body,r,!0)}catch{}return e.cloneNode(!1)}async function ia(e,r){return pe(e,HTMLCanvasElement)?ta(e):pe(e,HTMLVideoElement)?ra(e,r):pe(e,HTMLIFrameElement)?na(e,r):e.cloneNode(Cr(e))}const aa=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",Cr=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function sa(e,r,a){var i,t;if(Cr(r))return r;let n=[];return aa(e)&&e.assignedNodes?n=Ue(e.assignedNodes()):pe(e,HTMLIFrameElement)&&(!((i=e.contentDocument)===null||i===void 0)&&i.body)?n=Ue(e.contentDocument.body.childNodes):n=Ue(((t=e.shadowRoot)!==null&&t!==void 0?t:e).childNodes),n.length===0||pe(e,HTMLVideoElement)||await n.reduce((s,l)=>s.then(()=>mt(l,a)).then(m=>{m&&r.appendChild(m)}),Promise.resolve()),r}function oa(e,r,a){const i=r.style;if(!i)return;const t=window.getComputedStyle(e);t.cssText?(i.cssText=t.cssText,i.transformOrigin=t.transformOrigin):Ar(a).forEach(n=>{let s=t.getPropertyValue(n);n==="font-size"&&s.endsWith("px")&&(s=`${Math.floor(parseFloat(s.substring(0,s.length-2)))-.1}px`),pe(e,HTMLIFrameElement)&&n==="display"&&s==="inline"&&(s="block"),n==="d"&&r.getAttribute("d")&&(s=`path(${r.getAttribute("d")})`),i.setProperty(n,s,t.getPropertyPriority(n))})}function la(e,r){pe(e,HTMLTextAreaElement)&&(r.innerHTML=e.value),pe(e,HTMLInputElement)&&r.setAttribute("value",e.value)}function ca(e,r){if(pe(e,HTMLSelectElement)){const a=r,i=Array.from(a.children).find(t=>e.value===t.getAttribute("value"));i&&i.setAttribute("selected","")}}function ua(e,r,a){return pe(r,Element)&&(oa(e,r,a),Xi(e,r,a),la(e,r),ca(e,r)),r}async function da(e,r){const a=e.querySelectorAll?e.querySelectorAll("use"):[];if(a.length===0)return e;const i={};for(let n=0;nia(i,r)).then(i=>sa(e,i,r)).then(i=>ua(e,i,r)).then(i=>da(i,r))}const kr=/url\((['"]?)([^'"]+?)\1\)/g,ha=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,fa=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function ma(e){const r=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${r})(['"]?\\))`,"g")}function ga(e){const r=[];return e.replace(kr,(a,i,t)=>(r.push(t),a)),r.filter(a=>!jt(a))}async function pa(e,r,a,i,t){try{const n=a?Pi(r,a):r,s=Rt(r);let l;return t||(l=await Mt(n,s,i)),e.replace(ma(r),`$1${l}$3`)}catch{}return e}function ya(e,{preferredFontFormat:r}){return r?e.replace(fa,a=>{for(;;){const[i,,t]=ha.exec(a)||[];if(!t)return"";if(t===r)return`src: ${i};`}}):e}function _r(e){return e.search(kr)!==-1}async function Nr(e,r,a){if(!_r(e))return e;const i=ya(e,a);return ga(i).reduce((n,s)=>n.then(l=>pa(l,s,r,a)),Promise.resolve(i))}async function qe(e,r,a){var i;const t=(i=r.style)===null||i===void 0?void 0:i.getPropertyValue(e);if(t){const n=await Nr(t,null,a);return r.style.setProperty(e,n,r.style.getPropertyPriority(e)),!0}return!1}async function ba(e,r){await qe("background",e,r)||await qe("background-image",e,r),await qe("mask",e,r)||await qe("-webkit-mask",e,r)||await qe("mask-image",e,r)||await qe("-webkit-mask-image",e,r)}async function xa(e,r){const a=pe(e,HTMLImageElement);if(!(a&&!jt(e.src))&&!(pe(e,SVGImageElement)&&!jt(e.href.baseVal)))return;const i=a?e.src:e.href.baseVal,t=await Mt(i,Rt(i),r);await new Promise((n,s)=>{e.onload=n,e.onerror=r.onImageErrorHandler?(...m)=>{try{n(r.onImageErrorHandler(...m))}catch(p){s(p)}}:s;const l=e;l.decode&&(l.decode=n),l.loading==="lazy"&&(l.loading="eager"),a?(e.srcset="",e.src=t):e.href.baseVal=t})}async function wa(e,r){const i=Ue(e.childNodes).map(t=>Tr(t,r));await Promise.all(i).then(()=>e)}async function Tr(e,r){pe(e,Element)&&(await ba(e,r),await xa(e,r),await wa(e,r))}function va(e,r){const{style:a}=e;r.backgroundColor&&(a.backgroundColor=r.backgroundColor),r.width&&(a.width=`${r.width}px`),r.height&&(a.height=`${r.height}px`);const i=r.style;return i!=null&&Object.keys(i).forEach(t=>{a[t]=i[t]}),e}const Qt={};async function Xt(e){let r=Qt[e];if(r!=null)return r;const i=await(await fetch(e)).text();return r={url:e,cssText:i},Qt[e]=r,r}async function Zt(e,r){let a=e.cssText;const i=/url\(["']?([^"')]+)["']?\)/g,n=(a.match(/url\([^)]+\)/g)||[]).map(async s=>{let l=s.replace(i,"$1");return l.startsWith("https://")||(l=new URL(l,e.url).href),jr(l,r.fetchRequestInit,({result:m})=>(a=a.replace(s,`url(${m})`),[s,m]))});return Promise.all(n).then(()=>a)}function Kt(e){if(e==null)return[];const r=[],a=/(\/\*[\s\S]*?\*\/)/gi;let i=e.replace(a,"");const t=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const m=t.exec(i);if(m===null)break;r.push(m[0])}i=i.replace(t,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",l=new RegExp(s,"gi");for(;;){let m=n.exec(i);if(m===null){if(m=l.exec(i),m===null)break;n.lastIndex=l.lastIndex}else l.lastIndex=n.lastIndex;r.push(m[0])}return r}async function Ea(e,r){const a=[],i=[];return e.forEach(t=>{if("cssRules"in t)try{Ue(t.cssRules||[]).forEach((n,s)=>{if(n.type===CSSRule.IMPORT_RULE){let l=s+1;const m=n.href,p=Xt(m).then(o=>Zt(o,r)).then(o=>Kt(o).forEach(u=>{try{t.insertRule(u,u.startsWith("@import")?l+=1:t.cssRules.length)}catch(c){console.error("Error inserting rule from remote css",{rule:u,error:c})}})).catch(o=>{console.error("Error loading remote css",o.toString())});i.push(p)}})}catch(n){const s=e.find(l=>l.href==null)||document.styleSheets[0];t.href!=null&&i.push(Xt(t.href).then(l=>Zt(l,r)).then(l=>Kt(l).forEach(m=>{s.insertRule(m,s.cssRules.length)})).catch(l=>{console.error("Error loading remote stylesheet",l)})),console.error("Error inlining remote css file",n)}}),Promise.all(i).then(()=>(e.forEach(t=>{if("cssRules"in t)try{Ue(t.cssRules||[]).forEach(n=>{a.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${t.href}`,n)}}),a))}function Aa(e){return e.filter(r=>r.type===CSSRule.FONT_FACE_RULE).filter(r=>_r(r.style.getPropertyValue("src")))}async function Sa(e,r){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const a=Ue(e.ownerDocument.styleSheets),i=await Ea(a,r);return Aa(i)}function Rr(e){return e.trim().replace(/["']/g,"")}function ja(e){const r=new Set;function a(i){(i.style.fontFamily||getComputedStyle(i).fontFamily).split(",").forEach(n=>{r.add(Rr(n))}),Array.from(i.children).forEach(n=>{n instanceof HTMLElement&&a(n)})}return a(e),r}async function Ca(e,r){const a=await Sa(e,r),i=ja(e);return(await Promise.all(a.filter(n=>i.has(Rr(n.style.fontFamily))).map(n=>{const s=n.parentStyleSheet?n.parentStyleSheet.href:null;return Nr(n.cssText,s,r)}))).join(` -`)}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;isetTimeout(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{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(//,''),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?`\\(${f.latex_content.replace(/^\\\[/,"").replace(/\\\]$/,"").trim()}\\)`:null},{id:"latex_display",label:"LaTeX (Display)",category:"Code",getContent:f=>f.latex_content},{id:"mathml",label:"MathML",category:"Code",getContent:f=>f.mathml_content},{id:"mathml_mml",label:"MathML (MML)",category:"Code",getContent:f=>f.mathml_content?Fa(f.mathml_content):null},{id:"mathml_word",label:"Word MathML",category:"Code",getContent:f=>f.mathml_word_content},{id:"rendered_image",label:"Rendered Image",category:"Image",getContent:f=>f.markdown_content},{id:"docx",label:"DOCX",category:"File",getContent:f=>f.markdown_content,isDownload:!0,extension:"docx"}],p=async f=>{if(a!=null&&a.id){l(f);try{const y=ve.getToken(),C=await fetch(`${er}/task/export`,{method:"POST",headers:{"Content-Type":"application/json",...y?{Authorization:y}:{}},body:JSON.stringify({task_no:a.id,type:f})});if(!C.ok)throw new Error(`Export failed: ${C.statusText}`);const k=await C.blob(),b=URL.createObjectURL(k),w=document.createElement("a");w.href=b,w.download=`export.${f}`,document.body.appendChild(w),w.click(),document.body.removeChild(w),URL.revokeObjectURL(b),n(f),setTimeout(()=>{n(null),r()},1e3)}catch(y){console.error("Export failed:",y),alert(i.export.failed)}finally{l(null)}}},o=async f=>{const y="markdown-preview-content";l("rendered_image");try{const C=await Ma(y,{format:"png",scale:2,padding:24});f==="copy"&&await La(C),n("rendered_image"),setTimeout(()=>{n(null),r()},1e3)}catch(C){console.error("Failed to generate image:",C),alert(`${i.export.imageFailed}: ${C}`)}finally{l(null)}},u=async f=>{if(a!=null&&a.id&&Ua(a.id,f.id,m.map(C=>C.id)),f.id==="docx"){await p("docx");return}if(f.id==="rendered_image"){await o("copy");return}let y=f.getContent(a);if(f.id==="mathml_word"&&!y&&a.mathml_content)try{const C=await Ii(a.mathml_content);C&&(y=Fi(C))}catch(C){console.error("Failed to convert MathML to OMML:",C)}if(y){l(f.id);try{if(f.isDownload){const C=new Blob([y],{type:"text/plain"}),k=URL.createObjectURL(C),b=document.createElement("a");b.href=k,b.download=`export.${f.extension}`,document.body.appendChild(b),b.click(),document.body.removeChild(b),URL.revokeObjectURL(k)}else await navigator.clipboard.writeText(y);n(f.id),setTimeout(()=>{n(null),r()},1e3)}catch(C){console.error("Action failed:",C)}finally{l(null)}}},c=[{id:"Code",icon:pr,label:i.export.categories.code},{id:"Image",icon:pn,label:i.export.categories.image},{id:"File",icon:st,label:i.export.categories.file}];return E.jsxs(E.Fragment,{children:[e&&E.jsx("div",{className:"absolute inset-0 bg-black/20 backdrop-blur-[1px] z-40 transition-opacity",onClick:r}),E.jsxs("div",{className:` - 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("(?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;y0&&(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:a.uploadModal.title}),E.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:E.jsx(Ze,{size:20})})]}),E.jsxs("div",{onDragEnter:s,onDragLeave:s,onDragOver:s,onDrop:l,onClick:()=>{var p;return(p=n.current)==null?void 0:p.click()},className:`border-2 border-dashed rounded-xl p-12 text-center transition-colors cursor-pointer group ${i?"border-blue-500 bg-blue-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"}`,children:[E.jsx("div",{className:"w-16 h-16 bg-gray-100 text-gray-600 rounded-full flex items-center justify-center mx-auto mb-4 group-hover:scale-110 transition-transform",children:E.jsx(At,{size:32})}),E.jsx("p",{className:"text-sm text-gray-600 mb-1",children:a.sidebar.uploadInstruction}),E.jsx("input",{ref:n,type:"file",multiple:!0,accept:"image/*,application/pdf",onChange:m,className:"hidden"}),E.jsx("p",{className:"text-xs text-gray-500 mb-4",children:a.uploadModal.supportFormats}),E.jsxs("div",{className:"flex items-center justify-center gap-4 mt-6 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:a.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:a.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:a.common.paste})]})]})]})]})})}function Da({isOpen:e,onClose:r}){const{t:a}=_e(),[i,t]=H.useState(0),[n,s]=H.useState({}),l=[{id:"sidebar-upload-area",title:a.guide.step1Title,content:a.guide.step1Content,position:"right"},{id:"sidebar-history",title:a.guide.step2Title,content:a.guide.step2Content,position:"right"},{id:"file-preview-empty",title:a.guide.step3Title,content:a.guide.step3Content,position:"right"},{id:"result-empty-state",title:a.guide.step4Title,content:a.guide.step4Content,position:"left"},{id:"export-button",title:a.guide.stepExportTitle,content:a.guide.stepExportContent,position:"left"}],m=H.useCallback(()=>{if(!e||l.length===0)return;const u=document.getElementById(l[i].id);if(u){const c=u.getBoundingClientRect();s({top:c.top-8,left:c.left-8,width:c.width+16,height:c.height+16,opacity:1}),u.scrollIntoView({behavior:"smooth",block:"center"})}else s({opacity:0})},[i,e,l,a.guide]);if(H.useEffect(()=>(e&&(m(),window.addEventListener("resize",m)),()=>window.removeEventListener("resize",m)),[e,m]),!e)return null;const p=()=>{i{i>0&&t(i-1)};return E.jsxs("div",{className:"fixed inset-0 z-[100] pointer-events-none",children:[E.jsx("div",{className:"absolute inset-0 bg-black/60 pointer-events-auto",onClick:r,style:{clipPath:n.top!==void 0?`polygon( - 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,iO.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;X0&&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.length0){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.error("Error loading files:",O),t([])}finally{y(!1)}}},W=async()=>{if(!(!e||g||!b)){h(!0);try{const O=C+1,B=await ze.getTaskList("FORMULA",O,Yt),G=B.task_list||[],Z=B.total||0;if(G.length>0){const Q=G.map($);t(X=>{const K=[...X,...Q];return w(K.length{X.status===we.Completed&&(N.current[X.task_id]=q(X))}),k(O)}else w(!1)}catch(O){console.error("Error loading more files:",O)}finally{h(!1)}}},z=async O=>{try{const B=N.current[O];if(B){m(B);return}try{const G=await ze.getTaskResult(O);if(G.status===we.Completed){const Z={id:O,file_id:O,markdown_content:G.markdown,latex_content:G.latex,mathml_content:G.mathml,mathml_word_content:G.mathml_mw,rendered_image_path:G.image_blob||null,created_at:new Date().toISOString()};N.current[O]=Z,m(Z)}else m(null)}catch{m(null)}}catch(B){console.error("Error loading result:",B),m(null)}},F=(O,B)=>{if(T.current[O])return;let G=0;const Z=30;T.current[O]=setInterval(async()=>{G++;try{const Q=await ze.getTaskResult(O);if(t(X=>X.map(K=>{if(K.id===B){let ce="processing";return Q.status===we.Completed?ce="completed":Q.status===we.Failed&&(ce="failed"),{...K,status:ce}}return K})),Q.status===we.Completed||Q.status===we.Failed){if(clearInterval(T.current[O]),delete T.current[O],Q.status===we.Completed){const X={id:B,file_id:B,markdown_content:Q.markdown,latex_content:Q.latex,mathml_content:Q.mathml,mathml_word_content:Q.mathml_mw,rendered_image_path:Q.image_blob||null,created_at:new Date().toISOString()};N.current[B]=X,M.current===B&&m(X)}}else G>=Z&&(clearInterval(T.current[O]),delete T.current[O],t(X=>X.map(K=>K.id===B?{...K,status:"failed"}:K)),alert(a.alerts.taskTimeout))}catch(Q){console.error("Polling error:",Q),G>=Z&&(clearInterval(T.current[O]),delete T.current[O],t(X=>X.map(K=>K.id===B?{...K,status:"failed"}:K)),alert(a.alerts.networkError))}},2e3)},V=async O=>{y(!0);try{for(const B of O){const G=await ze.calculateMD5(B),Z=await ze.uploadFile(B),Q=await ze.createRecognitionTask(Z.path,G,B.name),X=Q.task_no||crypto.randomUUID(),K={id:X,user_id:(e==null?void 0:e.id)||null,filename:B.name,file_path:URL.createObjectURL(B),file_type:B.type,file_size:B.size,thumbnail_path:null,status:"processing",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};t(ce=>[K,...ce]),s(K.id),Q.task_no&&F(Q.task_no,X)}}catch(B){console.error("Error uploading files:",B),alert(`${a.alerts.uploadFailed}: `+(B instanceof Error?B.message:"Unknown error"))}finally{y(!1)}};return r?E.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:E.jsxs("div",{className:"text-center",children:[E.jsx("div",{className:"w-16 h-16 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mx-auto mb-4"}),E.jsx("p",{className:"text-gray-600",children:a.common.loading})]})}):E.jsxs("div",{className:"h-screen flex flex-col bg-gray-50 font-sans text-gray-900 overflow-hidden",children:[E.jsx(Cn,{}),E.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[E.jsxs("div",{ref:R,className:"flex-shrink-0 bg-white border-r border-gray-200 relative transition-all duration-300 ease-in-out",style:{width:A?64:S},children:[E.jsx(jn,{files:i,selectedFileId:n,onFileSelect:s,onUploadClick:()=>o(!0),isCollapsed:A,onToggleCollapse:()=>_(!A),onUploadFiles:V,hasMore:b,loadingMore:g,onLoadMore:W}),!A&&E.jsx("div",{className:"absolute right-0 top-0 w-1 h-full cursor-col-resize hover:bg-blue-400 z-50 opacity-0 hover:opacity-100 transition-opacity",onMouseDown:v})]}),E.jsx("div",{className:"flex-1 flex min-w-0 flex-col bg-gray-100/50",children:E.jsx(kn,{file:j})}),E.jsx("div",{className:"flex-1 flex min-w-0 flex-col bg-white",children:E.jsx(za,{result:l,fileStatus:j==null?void 0:j.status})}),p&&E.jsx(Oa,{onClose:()=>o(!1),onUpload:V}),E.jsx(Da,{isOpen:u,onClose:()=>c(!1)}),f&&E.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-30 flex items-center justify-center z-50",children:E.jsxs("div",{className:"bg-white rounded-xl shadow-xl p-8",children:[E.jsx("div",{className:"w-16 h-16 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mx-auto mb-4"}),E.jsx("p",{className:"text-gray-900 font-medium",children:a.common.processing})]})})]}),E.jsx("div",{className:"flex-shrink-0 bg-white border-t border-gray-200 py-2 px-4 text-center",children:E.jsx("a",{href:"https://beian.miit.gov.cn",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-gray-500 hover:text-gray-700 transition-colors",children:"京ICP备2025152973号"})})]})}Jt(document.getElementById("root")).render(E.jsx(H.StrictMode,{children:E.jsx(Gr,{children:E.jsx(Kr,{children:E.jsx(Ha,{})})})})); diff --git a/app.cloud/index.html b/app.cloud/index.html index 4b9af96..450f235 100644 --- a/app.cloud/index.html +++ b/app.cloud/index.html @@ -1,36 +1,63 @@ - + - ⚡️ TexPixel - 公式识别工具 + + + + + + + + ⚡️ TexPixel - 公式识别工具 | Formula Recognition Tool - - + + + content="公式识别,数学公式,OCR,手写公式识别,印刷体识别,AI识别,数学工具,免费,formula recognition,math formula,handwriting recognition,latex,mathml,markdown,texpixel,TexPixel,混合文字识别,document recognition" /> - - - + + + + + + - + - - + + + - + - + + + + diff --git a/docs/MULTILANG_IMPLEMENTATION.md b/docs/MULTILANG_IMPLEMENTATION.md new file mode 100644 index 0000000..5a1be99 --- /dev/null +++ b/docs/MULTILANG_IMPLEMENTATION.md @@ -0,0 +1,140 @@ +# 多语言功能实现总结 + +## 📋 实现内容 + +### 1. HTML 文档改进 (`index.html`) +- ✅ 添加 `hreflang` 标签支持多语言 SEO +- ✅ 添加双语 meta 标签(description, keywords) +- ✅ 添加 Open Graph 和 Twitter Cards 多语言支持 +- ✅ 添加动态语言检测脚本 +- ✅ 优化 `og:locale` 和 `og:locale:alternate` 标签 + +### 2. SEO 辅助工具 (`src/lib/seoHelper.ts`) +- ✅ 创建 `updatePageMeta()` 函数动态更新 meta 标签 +- ✅ 创建 `getSEOContent()` 函数获取语言特定的 SEO 内容 +- ✅ 支持更新标题、描述、关键词、OG 标签等 + +### 3. 语言上下文增强 (`src/contexts/LanguageContext.tsx`) +- ✅ 集成 `updatePageMeta()` 在语言切换时自动更新页面 +- ✅ 在初始加载时根据用户偏好更新 meta 标签 +- ✅ 在 IP 检测后更新 meta 标签 + +### 4. 文档和测试 +- ✅ 创建详细的多语言支持文档 (`MULTILANG_README.md`) +- ✅ 创建浏览器测试脚本 (`test-multilang.js`) +- ✅ 包含最佳实践和使用示例 + +## 🎯 功能特性 + +### 自动语言检测优先级 +1. 用户在 localStorage 中保存的选择(最高优先级) +2. IP 地理位置检测 +3. 浏览器语言设置(回退) + +### SEO 优化 +- **搜索引擎**: 完整的 hreflang 支持 +- **社交媒体**: Open Graph 和 Twitter Cards +- **元数据**: 动态更新标题、描述、关键词 + +### 用户体验 +- 一键语言切换(在导航栏) +- 无刷新页面更新 +- 保持用户选择跨会话 + +## 📝 使用示例 + +### 切换语言 +```typescript +import { useLanguage } from './contexts/LanguageContext'; + +function Component() { + const { language, setLanguage, t } = useLanguage(); + + return ( + + ); +} +``` + +### 添加新翻译 +在 `src/lib/translations.ts` 中: +```typescript +export const translations = { + en: { + newFeature: { + title: 'New Feature', + } + }, + zh: { + newFeature: { + title: '新功能', + } + } +}; +``` + +### 更新 SEO 内容 +在 `src/lib/seoHelper.ts` 中: +```typescript +const seoContent: Record = { + en: { + title: 'Your English Title', + description: 'Your English description', + keywords: 'english, keywords', + }, + zh: { + title: '您的中文标题', + description: '您的中文描述', + keywords: '中文,关键词', + }, +}; +``` + +## 🧪 测试清单 + +- [ ] 页面首次加载时语言检测正确 +- [ ] 切换语言时标题更新 +- [ ] 切换语言时 meta 标签更新 +- [ ] HTML lang 属性同步更新 +- [ ] localStorage 正确保存用户选择 +- [ ] 所有 UI 文本正确翻译 +- [ ] Open Graph 预览正确显示(使用 [Facebook Sharing Debugger](https://developers.facebook.com/tools/debug/)) +- [ ] Twitter Card 预览正确显示(使用 [Twitter Card Validator](https://cards-dev.twitter.com/validator)) + +## 🚀 部署注意事项 + +### 服务器配置 +如果使用基于 URL 的语言路由(如 `/en`, `/zh`),需要配置服务器重写规则: + +**Nginx 示例**: +```nginx +location ~ ^/(en|zh) { + try_files $uri $uri/ /index.html; +} +``` + +**Apache 示例**: +```apache +RewriteEngine On +RewriteRule ^(en|zh)/ /index.html [L] +``` + +### CDN 缓存 +确保 CDN 不会缓存带有错误语言的页面: +- 使用 `Vary: Accept-Language` 头 +- 或在 URL 中包含语言参数 + +## 🔗 相关资源 + +- [Google 国际化指南](https://developers.google.com/search/docs/specialty/international/localized-versions) +- [Open Graph Protocol](https://ogp.me/) +- [Twitter Cards 文档](https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/abouts-cards) +- [hreflang 最佳实践](https://support.google.com/webmasters/answer/189077) + +## 📞 支持 + +如有问题或建议,请联系: +- Email: yogecoder@gmail.com +- QQ 群: 1018282100 diff --git a/docs/MULTILANG_README.md b/docs/MULTILANG_README.md new file mode 100644 index 0000000..f8bddb1 --- /dev/null +++ b/docs/MULTILANG_README.md @@ -0,0 +1,174 @@ +# 多语言支持说明 / Multi-language Support + +## 概述 / Overview + +TexPixel 现在支持完整的中英文双语切换,包括: +- 动态页面标题和 meta 标签更新 +- SEO 优化的多语言支持 +- 智能语言检测(基于 IP 和浏览器偏好) + +TexPixel now supports complete bilingual switching between Chinese and English, including: +- Dynamic page title and meta tag updates +- SEO-optimized multi-language support +- Intelligent language detection (based on IP and browser preferences) + +--- + +## 功能特性 / Features + +### 1. 自动语言检测 / Automatic Language Detection + +应用会按以下优先级检测用户语言: +1. localStorage 中保存的用户选择 +2. IP 地理位置检测 +3. 浏览器语言设置 + +The app detects user language in the following order of priority: +1. User's saved preference in localStorage +2. IP geolocation detection +3. Browser language settings + +### 2. SEO 优化 / SEO Optimization + +- **hreflang 标签**:告知搜索引擎不同语言版本的页面 +- **多语言 meta 标签**:description、keywords、og:locale 等 +- **动态标题更新**:切换语言时自动更新页面标题 + +Features include: +- **hreflang tags**: Inform search engines about different language versions +- **Multilingual meta tags**: description, keywords, og:locale, etc. +- **Dynamic title updates**: Automatically update page title when switching languages + +### 3. Open Graph 和 Twitter Cards + +支持社交媒体分享的多语言 meta 标签: +- Facebook (Open Graph) +- Twitter Cards +- 其他支持 OG 协议的平台 + +Multilingual meta tags for social media sharing: +- Facebook (Open Graph) +- Twitter Cards +- Other platforms supporting OG protocol + +--- + +## 技术实现 / Technical Implementation + +### 文件结构 / File Structure + +``` +src/ +├── lib/ +│ ├── seoHelper.ts # SEO 元数据管理 / SEO metadata management +│ ├── translations.ts # 翻译文本 / Translation texts +│ └── ipLocation.ts # IP 定位 / IP location detection +├── contexts/ +│ └── LanguageContext.tsx # 语言上下文 / Language context +└── components/ + └── Navbar.tsx # 语言切换器 / Language switcher +``` + +### 核心函数 / Core Functions + +#### `updatePageMeta(language: Language)` +更新页面的所有 SEO 相关元数据,包括: +- document.title +- HTML lang 属性 +- meta description +- meta keywords +- Open Graph 标签 +- Twitter Card 标签 + +Updates all SEO-related metadata on the page, including: +- document.title +- HTML lang attribute +- meta description +- meta keywords +- Open Graph tags +- Twitter Card tags + +#### `getSEOContent(language: Language)` +获取指定语言的 SEO 内容(标题、描述、关键词) + +Get SEO content for a specific language (title, description, keywords) + +--- + +## 使用方法 / Usage + +### 在组件中使用语言功能 / Using Language Features in Components + +```typescript +import { useLanguage } from '../contexts/LanguageContext'; + +function MyComponent() { + const { language, setLanguage, t } = useLanguage(); + + return ( +
+

{t.common.title}

+ + +
+ ); +} +``` + +### 添加新的翻译文本 / Adding New Translation Texts + +在 `src/lib/translations.ts` 中添加: + +```typescript +export const translations = { + en: { + myFeature: { + title: 'My Feature', + description: 'Feature description', + } + }, + zh: { + myFeature: { + title: '我的功能', + description: '功能描述', + } + } +}; +``` + +--- + +## 最佳实践 / Best Practices + +1. **始终提供双语内容** / Always provide bilingual content + - 确保所有用户可见的文本都有中英文翻译 + - Ensure all user-visible text has Chinese and English translations + +2. **保持 SEO 元数据最新** / Keep SEO metadata up-to-date + - 在 `seoHelper.ts` 中维护准确的页面描述和关键词 + - Maintain accurate page descriptions and keywords in `seoHelper.ts` + +3. **测试语言切换** / Test language switching + - 确保切换语言时页面标题和 meta 标签正确更新 + - Ensure page title and meta tags update correctly when switching languages + +4. **考虑 RTL 语言** / Consider RTL languages + - 虽然目前只支持中英文,但代码架构支持未来添加其他语言 + - While currently supporting only Chinese and English, the architecture supports adding other languages in the future + +--- + +## 路线图 / Roadmap + +- [ ] 添加更多语言支持(日语、韩语等)/ Add more language support (Japanese, Korean, etc.) +- [ ] 实现 URL 路由多语言 (/en, /zh) / Implement URL routing for languages +- [ ] 服务端渲染 (SSR) 支持 / Server-side rendering (SSR) support +- [ ] 语言特定的日期和数字格式化 / Language-specific date and number formatting + +--- + +## 相关链接 / Related Links + +- [hreflang 标签最佳实践](https://developers.google.com/search/docs/specialty/international/localized-versions) +- [Open Graph Protocol](https://ogp.me/) +- [Twitter Cards Documentation](https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/abouts-cards) diff --git a/index.html b/index.html index 1c87d40..8c623d6 100644 --- a/index.html +++ b/index.html @@ -1,35 +1,62 @@ - + - ⚡️ TexPixel - 公式识别工具 + + + + + + + + ⚡️ TexPixel - 公式识别工具 | Formula Recognition Tool - - + + + content="公式识别,数学公式,OCR,手写公式识别,印刷体识别,AI识别,数学工具,免费,formula recognition,math formula,handwriting recognition,latex,mathml,markdown,texpixel,TexPixel,混合文字识别,document recognition" /> - - - + + + + + + - + - - + + + - + + + + diff --git a/package-lock.json b/package-lock.json index 4a3ff38..56ad008 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "mathml2omml": "^0.5.0", "react": "^18.3.1", "react-dom": "^18.3.1", + "react-hot-toast": "^2.6.0", "react-markdown": "^10.1.0", "rehype-katex": "^7.0.1", "remark-breaks": "^4.0.0", @@ -2804,6 +2805,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/goober": { + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/goober/-/goober-2.1.18.tgz", + "integrity": "sha512-2vFqsaDVIT9Gz7N6kAL++pLpp41l3PfDuusHcjnGLfR6+huZkl6ziX+zgVC3ZxpqWhzH6pyDdGrCeDhMIvwaxw==", + "license": "MIT", + "peerDependencies": { + "csstype": "^3.0.10" + } + }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -4575,6 +4585,23 @@ "react": "^18.3.1" } }, + "node_modules/react-hot-toast": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/react-hot-toast/-/react-hot-toast-2.6.0.tgz", + "integrity": "sha512-bH+2EBMZ4sdyou/DPrfgIouFpcRLCJ+HoCA32UoAYHn6T3Ur5yfcDCeSr5mwldl6pFOsiocmrXMuoCJ1vV8bWg==", + "license": "MIT", + "dependencies": { + "csstype": "^3.1.3", + "goober": "^2.1.16" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": ">=16", + "react-dom": ">=16" + } + }, "node_modules/react-markdown": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-10.1.0.tgz", diff --git a/package.json b/package.json index 4f7911f..877f2be 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "mathml2omml": "^0.5.0", "react": "^18.3.1", "react-dom": "^18.3.1", + "react-hot-toast": "^2.6.0", "react-markdown": "^10.1.0", "rehype-katex": "^7.0.1", "remark-breaks": "^4.0.0", diff --git a/src/App.tsx b/src/App.tsx index d7ab87c..3b1ce93 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -180,7 +180,7 @@ function App() { markdown_content: item.markdown, latex_content: item.latex, mathml_content: item.mathml, - mathml_word_content: item.mathml_mw, + mml: item.mml, rendered_image_path: item.image_blob || null, created_at: item.created_at, }; @@ -287,7 +287,7 @@ function App() { markdown_content: result.markdown, latex_content: result.latex, mathml_content: result.mathml, - mathml_word_content: result.mathml_mw, + mml: result.mml, rendered_image_path: result.image_blob || null, created_at: new Date().toISOString(), }; @@ -344,7 +344,7 @@ function App() { markdown_content: result.markdown, latex_content: result.latex, mathml_content: result.mathml, - mathml_word_content: result.mathml_mw, + mml: result.mml, rendered_image_path: result.image_blob || null, created_at: new Date().toISOString() }; diff --git a/src/components/ExportSidebar.tsx b/src/components/ExportSidebar.tsx index eb6f9c1..8fed94b 100644 --- a/src/components/ExportSidebar.tsx +++ b/src/components/ExportSidebar.tsx @@ -1,12 +1,12 @@ import { useState } from 'react'; import { X, Check, Copy, Download, Code2, Image as ImageIcon, FileText, Loader2, LucideIcon } from 'lucide-react'; import { RecognitionResult } from '../types'; -import { convertMathmlToOmml, wrapOmmlForClipboard } from '../lib/ommlConverter'; import { generateImageFromElement, copyImageToClipboard, downloadImage } from '../lib/imageGenerator'; import { API_BASE_URL } from '../config/env'; import { tokenManager } from '../lib/api'; import { trackExportEvent } from '../lib/analytics'; import { useLanguage } from '../contexts/LanguageContext'; +import toast, { Toaster } from 'react-hot-toast'; interface ExportSidebarProps { isOpen: boolean; @@ -25,87 +25,6 @@ interface ExportOption { extension?: string; } -// Helper function to add mml: prefix to MathML -const addMMLPrefix = (mathml: string): string | null => { - try { - const parser = new DOMParser(); - const xmlDoc = parser.parseFromString(mathml, 'application/xml'); - - // Check for parse errors - const parseError = xmlDoc.getElementsByTagName("parsererror"); - if (parseError.length > 0) { - return null; - } - - // Create new document with mml namespace - const newDoc = document.implementation.createDocument( - 'http://www.w3.org/1998/Math/MathML', - 'mml:math', - null - ); - - const newMathElement = newDoc.documentElement; - - // Copy display attribute if present - const displayAttr = xmlDoc.documentElement.getAttribute('display'); - if (displayAttr) { - newMathElement.setAttribute('display', displayAttr); - } - - // Recursive function to process nodes - const processNode = (node: Node, newParent: Element) => { - if (node.nodeType === Node.ELEMENT_NODE) { - const element = node as Element; - // Create new element with mml: prefix in the target document - const newElement = newDoc.createElementNS( - 'http://www.w3.org/1998/Math/MathML', - 'mml:' + element.localName - ); - - // Copy attributes - for (let i = 0; i < element.attributes.length; i++) { - const attr = element.attributes[i]; - // Skip xmlns attributes as we handle them explicitly - if (attr.name.startsWith('xmlns')) continue; - - newElement.setAttributeNS( - attr.namespaceURI, - attr.name, - attr.value - ); - } - - // Process children - Array.from(element.childNodes).forEach(child => { - processNode(child, newElement); - }); - - newParent.appendChild(newElement); - } else if (node.nodeType === Node.TEXT_NODE) { - newParent.appendChild(newDoc.createTextNode(node.nodeValue || '')); - } - }; - - // Process all children of the root math element - Array.from(xmlDoc.documentElement.childNodes).forEach(child => { - processNode(child, newMathElement); - }); - - // Serialize - const serializer = new XMLSerializer(); - let prefixedMathML = serializer.serializeToString(newDoc); - - // Clean up xmlns - prefixedMathML = prefixedMathML.replace(/ xmlns(:mml)?="[^"]*"/g, ''); - prefixedMathML = prefixedMathML.replace(//, ''); - - return prefixedMathML; - } catch (err) { - console.error('Failed to process MathML:', err); - return null; - } -}; - export default function ExportSidebar({ isOpen, onClose, result }: ExportSidebarProps) { const { t } = useLanguage(); const [copiedId, setCopiedId] = useState(null); @@ -121,14 +40,25 @@ export default function ExportSidebar({ isOpen, onClose, result }: ExportSidebar category: 'Code', getContent: (r) => r.markdown_content }, + { + id: 'latex', + label: 'LaTeX', + category: 'Code', + getContent: (r) => r.latex_content + }, { id: 'latex_inline', label: 'LaTeX (Inline)', category: 'Code', getContent: (r) => { if (!r.latex_content) return null; - // Remove existing \[ \] and wrap with \( \) - const content = r.latex_content.replace(/^\\\[/, '').replace(/\\\]$/, '').trim(); + // Remove existing delimiters like \[ \], \( \), $$, or $ + let content = r.latex_content.trim(); + content = content.replace(/^\\\[/, '').replace(/\\\]$/, ''); + content = content.replace(/^\\\(/, '').replace(/\\\)$/, ''); + content = content.replace(/^\$\$/, '').replace(/\$\$$/, ''); + content = content.replace(/^\$/, '').replace(/\$$/, ''); + content = content.trim(); return `\\(${content}\\)`; } }, @@ -136,7 +66,17 @@ export default function ExportSidebar({ isOpen, onClose, result }: ExportSidebar id: 'latex_display', label: 'LaTeX (Display)', category: 'Code', - getContent: (r) => r.latex_content + getContent: (r) => { + if (!r.latex_content) return null; + // Remove existing delimiters like \[ \], \( \), $$, or $ + let content = r.latex_content.trim(); + content = content.replace(/^\\\[/, '').replace(/\\\]$/, ''); + content = content.replace(/^\\\(/, '').replace(/\\\)$/, ''); + content = content.replace(/^\$\$/, '').replace(/\$\$$/, ''); + content = content.replace(/^\$/, '').replace(/\$$/, ''); + content = content.trim(); + return `\\[${content}\\]`; + } }, { id: 'mathml', @@ -148,13 +88,7 @@ export default function ExportSidebar({ isOpen, onClose, result }: ExportSidebar id: 'mathml_mml', label: 'MathML (MML)', category: 'Code', - getContent: (r) => r.mathml_content ? addMMLPrefix(r.mathml_content) : null - }, - { - id: 'mathml_word', - label: 'Word MathML', - category: 'Code', - getContent: (r) => r.mathml_word_content + getContent: (r) => r.mml }, // Image Category { @@ -278,22 +212,33 @@ export default function ExportSidebar({ isOpen, onClose, result }: ExportSidebar return; } - let content = option.getContent(result); + const content = option.getContent(result); - // Fallback: If Word MathML is missing, try to convert from MathML - if (option.id === 'mathml_word' && !content && result.mathml_content) { - try { - const omml = await convertMathmlToOmml(result.mathml_content); - if (omml) { - content = wrapOmmlForClipboard(omml); - } - } catch (err) { - console.error('Failed to convert MathML to OMML:', err); - } + // Check if content is empty and show toast + if (!content) { + toast.error(t.export.noContent, { + duration: 2000, + position: 'top-center', + style: { + background: '#fff', + color: '#1f2937', + padding: '16px 20px', + borderRadius: '12px', + boxShadow: '0 10px 40px rgba(59, 130, 246, 0.15), 0 2px 8px rgba(59, 130, 246, 0.1)', + border: '1px solid #dbeafe', + fontSize: '14px', + fontWeight: '500', + maxWidth: '900px', + lineHeight: '1.5', + }, + iconTheme: { + primary: '#ef4444', + secondary: '#ffffff', + }, + }); + return; } - if (!content) return; - setExportingId(option.id); try { @@ -321,6 +266,10 @@ export default function ExportSidebar({ isOpen, onClose, result }: ExportSidebar } catch (err) { console.error('Action failed:', err); + toast.error(t.export.failed, { + duration: 3000, + position: 'top-center', + }); } finally { setExportingId(null); } @@ -334,6 +283,41 @@ export default function ExportSidebar({ isOpen, onClose, result }: ExportSidebar return ( <> + {/* Toast Container with custom configuration */} + + {/* Backdrop */} {isOpen && (
= ({ chil // 如果用户已经手动选择过语言,则不进行IP检测 if (saved === 'en' || saved === 'zh') { + updatePageMeta(saved); // Update meta tags on initial load return; } @@ -32,18 +34,21 @@ export const LanguageProvider: React.FC<{ children: React.ReactNode }> = ({ chil detectLanguageByIP() .then((detectedLang) => { setLanguageState(detectedLang); + updatePageMeta(detectedLang); // Update meta tags after detection // 注意:这里不保存到 localStorage,让用户首次访问时使用IP检测的结果 // 如果用户手动切换语言,才会保存到 localStorage }) .catch((error) => { // IP检测失败时,保持使用浏览器语言检测的结果 console.warn('Failed to detect language by IP:', error); + updatePageMeta(language); // Update with fallback language }); }, []); // 仅在组件挂载时执行一次 const setLanguage = (lang: Language) => { setLanguageState(lang); localStorage.setItem('language', lang); + updatePageMeta(lang); // Update page metadata when language changes }; const t = translations[language]; diff --git a/src/lib/imageGenerator.ts b/src/lib/imageGenerator.ts index ea61fcc..b5ee543 100644 --- a/src/lib/imageGenerator.ts +++ b/src/lib/imageGenerator.ts @@ -63,54 +63,6 @@ function renderLatexToHtml(latex: string, fontSize: number): string { } } -/** - * Renders Markdown with LaTeX to HTML - * For complex Markdown, we extract and render math blocks separately - */ -function renderMarkdownToHtml(markdown: string, fontSize: number): string { - // Simple approach: extract LaTeX blocks and render them - // For full Markdown support, you'd use a Markdown parser - - let html = markdown; - - // Replace display math $$ ... $$ - html = html.replace(/\$\$([\s\S]*?)\$\$/g, (_, latex) => { - try { - return `
${katex.renderToString(latex.trim(), { - throwOnError: false, - displayMode: true, - output: 'html', - strict: false, - })}
`; - } catch { - return `
Error: ${latex}
`; - } - }); - - // Replace inline math $ ... $ - html = html.replace(/\$([^$\n]+)\$/g, (_, latex) => { - try { - return katex.renderToString(latex.trim(), { - throwOnError: false, - displayMode: false, - output: 'html', - strict: false, - }); - } catch { - return `Error: ${latex}`; - } - }); - - // Basic Markdown: newlines to
- html = html.replace(/\n/g, '
'); - - return ` -
- ${html} -
- `; -} - /** * Waits for all KaTeX fonts to be loaded */ diff --git a/src/lib/mockService.ts b/src/lib/mockService.ts index fe0d0ac..64a4329 100644 --- a/src/lib/mockService.ts +++ b/src/lib/mockService.ts @@ -93,16 +93,35 @@ Where: `, - mathml_word_content: ` - - - -b ± √(b²-4ac) - - - 2a - - -`, + mml: ` + + x + = + + + - + b + ± + + + + b + 2 + + - + 4 + a + c + + + + + 2 + a + + + +`, rendered_image_path: 'https://images.pexels.com/photos/3729557/pexels-photo-3729557.jpeg?auto=compress&cs=tinysrgb&w=800', created_at: new Date().toISOString(), }; @@ -161,7 +180,7 @@ Where: markdown_content: `# Analysis for ${filename}\n\nThis is a mock analysis result generated for the uploaded file.\n\n$$ E = mc^2 $$\n\nDetected content matches widely known physics formulas.`, latex_content: `\\documentclass{article}\n\\begin{document}\nSection{${filename}}\n\n\\[ E = mc^2 \\]\n\n\\end{document}`, mathml_content: `E=mc2`, - mathml_word_content: `E=mc^2`, + mml: `E=mc2`, rendered_image_path: 'https://images.pexels.com/photos/3729557/pexels-photo-3729557.jpeg?auto=compress&cs=tinysrgb&w=800', // Placeholder created_at: new Date().toISOString(), }; diff --git a/src/lib/seoHelper.ts b/src/lib/seoHelper.ts new file mode 100644 index 0000000..65392a4 --- /dev/null +++ b/src/lib/seoHelper.ts @@ -0,0 +1,80 @@ +import { Language } from './translations'; + +interface SEOContent { + title: string; + description: string; + keywords: string; +} + +const seoContent: Record = { + zh: { + title: '⚡️ TexPixel - 公式识别工具', + description: '在线公式识别工具,支持印刷体和手写体数学公式识别,快速准确地将图片中的数学公式转换为可编辑文本。', + keywords: '公式识别,数学公式,OCR,手写公式识别,印刷体识别,AI识别,数学工具,免费,混合文字识别,texpixel,TexPixel', + }, + en: { + title: '⚡️ TexPixel - Formula Recognition Tool', + description: 'Online formula recognition tool supporting printed and handwritten math formulas. Convert images to LaTeX, MathML, and Markdown quickly and accurately.', + keywords: 'formula recognition,math formula,OCR,handwriting recognition,latex,mathml,markdown,AI recognition,math tool,free,texpixel,TexPixel,document recognition', + }, +}; + +/** + * Update document metadata based on current language + */ +export function updatePageMeta(language: Language): void { + const content = seoContent[language]; + + // Update title + document.title = content.title; + + // Update HTML lang attribute + document.documentElement.lang = language === 'zh' ? 'zh-CN' : 'en'; + + // Update meta description + const metaDescription = document.querySelector('meta[name="description"]'); + if (metaDescription) { + metaDescription.setAttribute('content', content.description); + } + + // Update meta keywords + const metaKeywords = document.querySelector('meta[name="keywords"]'); + if (metaKeywords) { + metaKeywords.setAttribute('content', content.keywords); + } + + // Update Open Graph meta tags + const ogTitle = document.querySelector('meta[property="og:title"]'); + if (ogTitle) { + ogTitle.setAttribute('content', content.title); + } + + const ogDescription = document.querySelector('meta[property="og:description"]'); + if (ogDescription) { + ogDescription.setAttribute('content', content.description); + } + + // Update Twitter Card meta tags + const twitterTitle = document.querySelector('meta[name="twitter:title"]'); + if (twitterTitle) { + twitterTitle.setAttribute('content', content.title); + } + + const twitterDescription = document.querySelector('meta[name="twitter:description"]'); + if (twitterDescription) { + twitterDescription.setAttribute('content', content.description); + } + + // Update og:locale + const ogLocale = document.querySelector('meta[property="og:locale"]'); + if (ogLocale) { + ogLocale.setAttribute('content', language === 'zh' ? 'zh_CN' : 'en_US'); + } +} + +/** + * Get SEO content for a specific language + */ +export function getSEOContent(language: Language): SEOContent { + return seoContent[language]; +} diff --git a/src/lib/supabase.ts b/src/lib/supabase.ts index 2ee501c..44f8f21 100644 --- a/src/lib/supabase.ts +++ b/src/lib/supabase.ts @@ -61,7 +61,7 @@ export type Database = { markdown_content: string | null; latex_content: string | null; mathml_content: string | null; - mathml_word_content: string | null; + mml: string | null; rendered_image_path: string | null; created_at: string; }; @@ -71,7 +71,7 @@ export type Database = { markdown_content?: string | null; latex_content?: string | null; mathml_content?: string | null; - mathml_word_content?: string | null; + mml?: string | null; rendered_image_path?: string | null; created_at?: string; }; @@ -81,7 +81,7 @@ export type Database = { markdown_content?: string | null; latex_content?: string | null; mathml_content?: string | null; - mathml_word_content?: string | null; + mml?: string | null; rendered_image_path?: string | null; created_at?: string; }; diff --git a/src/lib/translations.ts b/src/lib/translations.ts index b5564fd..c237125 100644 --- a/src/lib/translations.ts +++ b/src/lib/translations.ts @@ -70,6 +70,8 @@ export const translations = { }, failed: 'Export failed, please try again', imageFailed: 'Failed to generate image', + noContent: 'Mixed text and formulas do not support LaTeX/MathML export. Please download DOCX format instead.', + noContentShort: 'Not supported for mixed content', }, guide: { next: 'Next', @@ -164,6 +166,8 @@ export const translations = { }, failed: '导出失败,请重试', imageFailed: '生成图片失败', + noContent: '混合文字内容不支持 LaTeX/MathML 导出,请下载 DOCX 文件。', + noContentShort: '混合内容不支持', }, guide: { next: '下一步', diff --git a/src/types/api.ts b/src/types/api.ts index 62e7b73..13f7db3 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -79,7 +79,7 @@ export interface RecognitionResultData { latex: string; markdown: string; mathml: string; - mathml_mw: string; // MathML for Word + mml: string; // MathML with mml: prefix image_blob: string; // Base64 or URL? assuming string content docx_url: string; pdf_url: string; @@ -96,7 +96,7 @@ export interface TaskHistoryItem { latex: string; markdown: string; mathml: string; - mathml_mw: string; + mml: string; image_blob: string; docx_url: string; pdf_url: string; diff --git a/src/types/index.ts b/src/types/index.ts index 1b52522..7a162a6 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -17,7 +17,7 @@ export interface RecognitionResult { markdown_content: string | null; latex_content: string | null; mathml_content: string | null; - mathml_word_content: string | null; + mml: string | null; rendered_image_path: string | null; created_at: string; } @@ -26,7 +26,6 @@ export type ExportFormat = | 'markdown' | 'latex' | 'mathml' - | 'mathml-word' | 'image' | 'docx' | 'pdf'