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,{})})})}));