import{h as P,Y as F,_ as L}from"./index.3a834e58.js";/* empty css *//* empty css *//* empty css */import{d as R,r as V,o as A,bD as H,bO as O,C as b,D as w,aI as g,aH as _,G as v,aK as C,aJ as E,F as T,aM as M,aN as $,a$ as U,ba as q,bE as z,bJ as J,be as K,bf as j}from"./arco.b289f6bb.js";import{h as G}from"./vue.e0867ae8.js";import{e as Y,b as Q,g as W}from"./serial.c741fbda.js";import"./chart.7501771f.js";const B=y=>(K("data-v-2d8f1ddd"),y=y(),j(),y),X={class:"container"},Z=B(()=>v("div",{id:"canvasDiv",style:{zoom:"250%",display:"none"}},null,-1)),tt={style:{padding:"0",margin:"0","border-spacing":"0"}},et=["onMousedown","onMouseover"],ot=B(()=>v("br",null,null,-1)),nt={name:"Backup"},at=R({...nt,setup(y){const f=P(),i=V({binaryFile:void 0,loading:!1,matrix:[],mousedown:!1}),I=G();A(()=>{I.query.url&&D(I.query.url)});const S=(e,s)=>{if(i.mousedown){const l=i.matrix;l[s][e]=i.matrix[s][e]=="#fff"?"#000":"#fff",i.matrix=l}},D=e=>{const s=document.createElement("canvas");s.width=128,s.height=64;const l=s.cloneNode(),o=document.getElementById("canvasDiv");o.innerHTML="",o==null||o.append(s,l);const p=new Image;p.src=e,p.onload=()=>{const r=s.getContext("2d");r==null||r.drawImage(p,0,0,128,64);const m=r==null?void 0:r.getImageData(0,0,s.width,s.height).data;function d(t,n){const a=(n*128+t)*4;return m[a]+m[a+1]+m[a+2]>128*3?0:1}const u=[];for(let t=0;t<64;t++){u.push([]),u[t]=[];for(let n=0;n<128;n++){const c=!d(n,t);u[t][n]=c?"#fff":"#000"}}i.matrix=u}},N=()=>{const e=document.createElement("input");e.type="file",e.onchange=async()=>{const s=new Blob([e.files[0]],{type:"application/octet-stream"}),l=URL.createObjectURL(s),o=document.createElement("canvas");o.width=128,o.height=64;const p=o.cloneNode(),r=document.getElementById("canvasDiv");r.innerHTML="",r==null||r.append(o,p);const m=new Image;m.src=l,m.onload=()=>{const d=o.getContext("2d");d==null||d.drawImage(m,0,0,128,64);const u=d==null?void 0:d.getImageData(0,0,o.width,o.height).data;function t(c,a){const x=(a*128+c)*4;return u[x]+u[x+1]+u[x+2]>128*3?0:1}const n=[];for(let c=0;c<64;c++){n.push([]),n[c]=[];for(let a=0;a<128;a++){const h=!t(a,c);n[c][a]=h?"#fff":"#000"}}i.matrix=n}},e.click()},k=async()=>{var p,r,m,d,u;const e=new Uint8Array(1024);let s=0;for(let t=0;t<64;t+=8)for(let n=0;n<128;n++){let c=0;for(let a=0;a<8;a++)c|=(i.matrix[t+a][n]=="#000"?1:0)<{const l=F,o=U,p=q,r=H,m=O,d=z,u=J;return b(),w("div",X,[g(l,{items:[e.$t("menu.list"),e.$t("menu.image")]},null,8,["items"]),g(u,{gutter:20,align:"stretch"},{default:_(()=>[g(d,{span:24},{default:_(()=>[g(m,{loading:i.loading,tip:"\u5199\u5165\u4E2D...",style:{width:"100%"}},{default:_(()=>[g(r,{class:"general-card",title:e.$t("menu.image")+e.$t("global.onStart")},{default:_(()=>[Z,v("div",null,[v("table",tt,[(b(!0),w(C,null,E(i.matrix,(t,n)=>(b(),w("tr",null,[(b(!0),w(C,null,E(t,(c,a)=>(b(),w("td",{onMousedown:h=>{i.mousedown=!0,S(a,n)},onMouseup:s[0]||(s[0]=h=>{i.mousedown=!1}),onMouseover:h=>S(a,n),style:T("background-color: "+c+"; height: 5px; width: 3.5px;")},null,44,et))),256))]))),256))])]),ot,g(p,null,{default:_(()=>[g(o,{onClick:N},{default:_(()=>[M($(e.$t("tool.selectImage")),1)]),_:1}),g(o,{type:"primary",disabled:i.matrix.length<64,onClick:k},{default:_(()=>[M($(e.$t("tool.write")),1)]),_:1},8,["disabled"])]),_:1})]),_:1},8,["title"])]),_:1},8,["loading"])]),_:1})]),_:1})])}}});const pt=L(at,[["__scopeId","data-v-2d8f1ddd"]]);export{pt as default};