Files
doc_ai_frontend/app.cloud/assets/index-D6FBTwaJ.js
2026-02-05 18:22:30 +08:00

195 lines
140 KiB
JavaScript
Raw Blame History

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