From 39b2f89bb0c4f7e40cea0efdced012c5715c1f59 Mon Sep 17 00:00:00 2001 From: SciLor Date: Mon, 6 Jan 2025 08:31:53 +0000 Subject: [PATCH] Update frontend (make web) --- .../www/web/assets/{index-BWOSK_Vl.js => index-DuKEIM2E.js} | 2 +- contrib/data/www/web/index.html | 2 +- contrib/data/www/web/translations/de.json | 2 +- contrib/data/www/web/translations/en.json | 2 +- contrib/data/www/web/translations/es.json | 2 +- contrib/data/www/web/translations/fr.json | 2 +- contrib/data/www/web/web_version.json | 6 +++--- teddycloud_web | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) rename contrib/data/www/web/assets/{index-BWOSK_Vl.js => index-DuKEIM2E.js} (99%) diff --git a/contrib/data/www/web/assets/index-BWOSK_Vl.js b/contrib/data/www/web/assets/index-DuKEIM2E.js similarity index 99% rename from contrib/data/www/web/assets/index-BWOSK_Vl.js rename to contrib/data/www/web/assets/index-DuKEIM2E.js index 1b3476a9..c6662ba5 100644 --- a/contrib/data/www/web/assets/index-BWOSK_Vl.js +++ b/contrib/data/www/web/assets/index-DuKEIM2E.js @@ -660,7 +660,7 @@ Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub`})]})]}),f.jsx(Tn diff cc32xx-flash.bin cc32xx-flash.2.bin #no output = equal`})}),f.jsx("h5",{children:e("tonieboxes.cc3235BoxFlashing.extractCertificates")}),f.jsx(Tn,{children:e("tonieboxes.cc3235BoxFlashing.useCC3200ToolToExtract")}),f.jsx(Tn,{children:f.jsx(gn,{language:"shell",code:"cc3200tool -if cc32xx-flash.bin -d cc32xx read_all_files extract/"})}),f.jsx(Z_,{}),b,f.jsx(Tn,{children:f.jsx(gn,{language:"shell",code:"cc3200tool -if cc32xx-flash.bin -of cc32xx-flash.customca.bin -d cc32xx write_file ca.der /cert/ca.der"})}),f.jsx("h5",{children:e("tonieboxes.cc3235BoxFlashing.pico.writingFlash")}),f.jsx(Tn,{children:f.jsx(gn,{language:"shell",code:"flashrom -p serprog:dev=/dev/ttyACM0:921600 -w cc32xx-flash.customca.bin --progress"})})]}),S=f.jsxs(f.Fragment,{children:[f.jsx("h5",{children:e("tonieboxes.cc3235BoxFlashing.CH341AProgrammer.readingFlash")}),f.jsx(Tn,{children:e("tonieboxes.cc3235BoxFlashing.CH341AProgrammer.flashMemoryDumpText1")}),f.jsx(Tn,{children:e("tonieboxes.cc3235BoxFlashing.CH341AProgrammer.flashMemoryDumpText2")}),f.jsx(Tn,{children:e("tonieboxes.cc3235BoxFlashing.CH341AProgrammer.flashMemoryDumpText3")}),f.jsx(Tn,{children:e("tonieboxes.cc3235BoxFlashing.CH341AProgrammer.flashMemoryDumpText4")}),f.jsx(gn,{language:"shell",code:"flashrom -p ch341a_spi -r backupCC3235-1.bin"}),f.jsx(Tn,{children:e("tonieboxes.cc3235BoxFlashing.CH341AProgrammer.flashMemoryDumpText5")}),f.jsx(gn,{language:"shell",code:"flashrom -p ch341a_spi -r backupCC3235-2.bin"}),f.jsx(Tn,{children:e("tonieboxes.cc3235BoxFlashing.CH341AProgrammer.flashMemoryDumpText6")}),f.jsx(gn,{language:"shell",code:"diff backupCC3235-1.bin backupCC3235-2.bin #no output = equal"}),f.jsx(Tn,{children:e("tonieboxes.cc3235BoxFlashing.CH341AProgrammer.flashMemoryDumpText7")}),f.jsx(Tn,{children:e("tonieboxes.cc3235BoxFlashing.CH341AProgrammer.flashMemoryDumpText8")}),f.jsx("h5",{children:e("tonieboxes.cc3235BoxFlashing.extractCertificates")}),f.jsx(Tn,{children:e("tonieboxes.cc3235BoxFlashing.useCC3200ToolToExtract")}),f.jsx(Tn,{children:f.jsx(gn,{language:"shell",code:"cc3200tool -if backupCC3235-1.bin -d cc32xx read_all_files extract/"})}),f.jsx(Z_,{}),b,f.jsx(Tn,{children:f.jsx(gn,{language:"shell",code:"cc3200tool -if backupCC3235-1.bin -of cc32xx-flash.customca.bin -d cc32xx write_file ca.der /cert/ca.der"})}),f.jsx("h5",{children:e("tonieboxes.cc3235BoxFlashing.CH341AProgrammer.writingFlash")}),f.jsx(Tn,{children:f.jsx(gn,{language:"shell",code:"flashrom -p ch341a_spi -w cc32xx-flash.customca.bin --progress"})})]}),v=[{key:"picoCE",label:"Raspberry Pi Pico",children:x},{key:"ch341aCE",label:"CH341A Programmer",children:S}],y=f.jsxs(f.Fragment,{children:[f.jsx("h3",{children:e("tonieboxes.boxFlashingCommon.certificates")}),e3(!1),f.jsx("h4",{children:"CC3235"}),f.jsx(Tn,{children:e("tonieboxes.cc3235BoxFlashing.dumpCertificatesCC3235")}),f.jsx(Ld,{onChange:N=>s(N),activeKey:c+"CE",items:v,indicator:{size:N=>N-20,align:"center"}}),f.jsx(Tn,{children:e("tonieboxes.cc3235BoxFlashing.flashCAreplacementText2")})]}),w=wZ(),C=f.jsxs(f.Fragment,{children:[f.jsx("h3",{children:e("tonieboxes.boxFlashingCommon.dns")}),w]}),[E,I]=l.useState([h,y,C]),T=(N,A)=>{I(L=>{const j=[...L];return j[N]=A,j})};l.useEffect(()=>{T(n,(()=>{switch(n){case 0:return h;case 1:return y;case 2:return C;default:return f.jsx("div",{})}})())},[n,t,Cs(),c]);const R=()=>{r(n-1)},_=()=>{r(n+1)},$=f.jsx(tt,{icon:f.jsx(ks,{}),onClick:()=>R(),children:e("tonieboxes.cc3235BoxFlashing.previous")}),M=N=>{r(N)},P=()=>{D()},D=()=>{o(!0)},O=()=>{o(!1)},k=f.jsx(hx,{boxVersion:qo.cc3235,isOpen:a,onClose:O});return f.jsxs(f.Fragment,{children:[f.jsx(jn,{children:f.jsx(as,{})}),f.jsxs(Fn,{children:[f.jsx(Bn,{items:[{title:e("home.navigationTitle")},{title:e("tonieboxes.navigationTitle")},{title:e("tonieboxes.cc3235BoxFlashing.navigationTitle")}]}),f.jsxs(Pn,{children:[f.jsx("h1",{children:e("tonieboxes.cc3235BoxFlashing.title")}),f.jsx(Wn,{children:e("tonieboxes.cc3235BoxFlashing.title")}),f.jsxs(Tn,{style:{marginTop:16},children:[f.jsx(js,{current:n,onChange:M,children:d.map((N,A)=>f.jsx(W9e,{title:N.title,status:A===n&&A===d.length?"finish":A===n?"process":A=0;)e[t]=0}const Y9e=0,CZ=1,X9e=2,Z9e=3,Q9e=258,t3=29,Vm=256,Ug=Vm+1+t3,vd=30,n3=19,EZ=2*Ug+1,hc=15,kI=16,J9e=7,r3=256,IZ=16,TZ=17,RZ=18,Q_=new Uint8Array([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]),Kv=new Uint8Array([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]),eHe=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),_Z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),tHe=512,ms=new Array((Ug+2)*2);If(ms);const Wp=new Array(vd*2);If(Wp);const Vg=new Array(tHe);If(Vg);const Wg=new Array(Q9e-Z9e+1);If(Wg);const a3=new Array(t3);If(a3);const s0=new Array(vd);If(s0);function AI(e,t,n,r,a){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=a,this.has_stree=e&&e.length}let $Z,OZ,NZ;function MI(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const kZ=e=>e<256?Vg[e]:Vg[256+(e>>>7)],Gg=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},no=(e,t,n)=>{e.bi_valid>kI-n?(e.bi_buf|=t<>kI-e.bi_valid,e.bi_valid+=n-kI):(e.bi_buf|=t<{no(e,n[t*2],n[t*2+1])},AZ=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},nHe=e=>{e.bi_valid===16?(Gg(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},rHe=(e,t)=>{const n=t.dyn_tree,r=t.max_code,a=t.stat_desc.static_tree,o=t.stat_desc.has_stree,i=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,d,p,g,m,h,b=0;for(g=0;g<=hc;g++)e.bl_count[g]=0;for(n[e.heap[e.heap_max]*2+1]=0,u=e.heap_max+1;uc&&(g=c,b++),n[d*2+1]=g,!(d>r)&&(e.bl_count[g]++,m=0,d>=s&&(m=i[d-s]),h=n[d*2],e.opt_len+=h*(g+m),o&&(e.static_len+=h*(a[d*2+1]+m)));if(b!==0){do{for(g=c-1;e.bl_count[g]===0;)g--;e.bl_count[g]--,e.bl_count[g+1]+=2,e.bl_count[c]--,b-=2}while(b>0);for(g=c;g!==0;g--)for(d=e.bl_count[g];d!==0;)p=e.heap[--u],!(p>r)&&(n[p*2+1]!==g&&(e.opt_len+=(g-n[p*2+1])*n[p*2],n[p*2+1]=g),d--)}},MZ=(e,t,n)=>{const r=new Array(hc+1);let a=0,o,i;for(o=1;o<=hc;o++)a=a+n[o-1]<<1,r[o]=a;for(i=0;i<=t;i++){let s=e[i*2+1];s!==0&&(e[i*2]=AZ(r[s]++,s))}},aHe=()=>{let e,t,n,r,a;const o=new Array(hc+1);for(n=0,r=0;r>=7;r{let t;for(t=0;t{e.bi_valid>8?Gg(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},qB=(e,t,n,r)=>{const a=t*2,o=n*2;return e[a]{const r=e.heap[n];let a=n<<1;for(;a<=e.heap_len&&(a{let r,a,o=0,i,s;if(e.sym_next!==0)do r=e.pending_buf[e.sym_buf+o++]&255,r+=(e.pending_buf[e.sym_buf+o++]&255)<<8,a=e.pending_buf[e.sym_buf+o++],r===0?Wi(e,a,t):(i=Wg[a],Wi(e,i+Vm+1,t),s=Q_[i],s!==0&&(a-=a3[i],no(e,a,s)),r--,i=kZ(r),Wi(e,i,n),s=Kv[i],s!==0&&(r-=s0[i],no(e,r,s)));while(o{const n=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.elems;let i,s,c=-1,u;for(e.heap_len=0,e.heap_max=EZ,i=0;i>1;i>=1;i--)DI(e,n,i);u=o;do i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],DI(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=s,n[u*2]=n[i*2]+n[s*2],e.depth[u]=(e.depth[i]>=e.depth[s]?e.depth[i]:e.depth[s])+1,n[i*2+1]=n[s*2+1]=u,e.heap[1]=u++,DI(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],rHe(e,t),MZ(n,c,e.bl_count)},YB=(e,t,n)=>{let r,a=-1,o,i=t[0*2+1],s=0,c=7,u=4;for(i===0&&(c=138,u=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)o=i,i=t[(r+1)*2+1],!(++s{let r,a=-1,o,i=t[0*2+1],s=0,c=7,u=4;for(i===0&&(c=138,u=3),r=0;r<=n;r++)if(o=i,i=t[(r+1)*2+1],!(++s{let t;for(YB(e,e.dyn_ltree,e.l_desc.max_code),YB(e,e.dyn_dtree,e.d_desc.max_code),J_(e,e.bl_desc),t=n3-1;t>=3&&e.bl_tree[_Z[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},iHe=(e,t,n,r)=>{let a;for(no(e,t-257,5),no(e,n-1,5),no(e,r-4,4),a=0;a{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return WB;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return GB;for(n=32;n{ZB||(aHe(),ZB=!0),e.l_desc=new MI(e.dyn_ltree,$Z),e.d_desc=new MI(e.dyn_dtree,OZ),e.bl_desc=new MI(e.bl_tree,NZ),e.bi_buf=0,e.bi_valid=0,DZ(e)},LZ=(e,t,n,r)=>{no(e,(Y9e<<1)+(r?1:0),3),PZ(e),Gg(e,n),Gg(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},cHe=e=>{no(e,CZ<<1,3),Wi(e,r3,ms),nHe(e)},uHe=(e,t,n,r)=>{let a,o,i=0;e.level>0?(e.strm.data_type===K9e&&(e.strm.data_type=sHe(e)),J_(e,e.l_desc),J_(e,e.d_desc),i=oHe(e),a=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=a&&(a=o)):a=o=n+5,n+4<=a&&t!==-1?LZ(e,t,n,r):e.strategy===q9e||o===a?(no(e,(CZ<<1)+(r?1:0),3),KB(e,ms,Wp)):(no(e,(X9e<<1)+(r?1:0),3),iHe(e,e.l_desc.max_code+1,e.d_desc.max_code+1,i+1),KB(e,e.dyn_ltree,e.dyn_dtree)),DZ(e),r&&PZ(e)},dHe=(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(Wg[n]+Vm+1)*2]++,e.dyn_dtree[kZ(t)*2]++),e.sym_next===e.sym_end);var fHe=lHe,pHe=LZ,gHe=uHe,mHe=dHe,hHe=cHe,vHe={_tr_init:fHe,_tr_stored_block:pHe,_tr_flush_block:gHe,_tr_tally:mHe,_tr_align:hHe};const bHe=(e,t,n,r)=>{let a=e&65535|0,o=e>>>16&65535|0,i=0;for(;n!==0;){i=n>2e3?2e3:n,n-=i;do a=a+t[r++]|0,o=o+a|0;while(--i);a%=65521,o%=65521}return a|o<<16|0};var qg=bHe;const yHe=()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t},xHe=new Uint32Array(yHe()),SHe=(e,t,n,r)=>{const a=xHe,o=r+n;e^=-1;for(let i=r;i>>8^a[(e^t[i])&255];return e^-1};var ia=SHe,Vc={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Tf={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:wHe,_tr_stored_block:e$,_tr_flush_block:CHe,_tr_tally:Rl,_tr_align:EHe}=vHe,{Z_NO_FLUSH:_l,Z_PARTIAL_FLUSH:IHe,Z_FULL_FLUSH:THe,Z_FINISH:Ko,Z_BLOCK:QB,Z_OK:ya,Z_STREAM_END:JB,Z_STREAM_ERROR:Xi,Z_DATA_ERROR:RHe,Z_BUF_ERROR:PI,Z_DEFAULT_COMPRESSION:_He,Z_FILTERED:$He,Z_HUFFMAN_ONLY:av,Z_RLE:OHe,Z_FIXED:NHe,Z_DEFAULT_STRATEGY:kHe,Z_UNKNOWN:AHe,Z_DEFLATED:vx}=Tf,MHe=9,DHe=15,PHe=8,LHe=29,jHe=256,t$=jHe+1+LHe,FHe=30,BHe=19,zHe=2*t$+1,HHe=15,Rn=3,ml=258,Zi=ml+Rn+1,UHe=32,Yd=42,o3=57,n$=69,r$=73,a$=91,o$=103,vc=113,yp=666,Ua=1,Rf=2,Wc=3,_f=4,VHe=3,bc=(e,t)=>(e.msg=Vc[t],t),e7=e=>e*2-(e>4?9:0),il=e=>{let t=e.length;for(;--t>=0;)e[t]=0},WHe=e=>{let t,n,r,a=e.w_size;t=e.hash_size,r=t;do n=e.head[--r],e.head[r]=n>=a?n-a:0;while(--t);t=a,r=t;do n=e.prev[--r],e.prev[r]=n>=a?n-a:0;while(--t)};let GHe=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},Io=(e,t)=>{CHe(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,vo(e.strm)},Ln=(e,t)=>{e.pending_buf[e.pending++]=t},rp=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},i$=(e,t,n,r)=>{let a=e.avail_in;return a>r&&(a=r),a===0?0:(e.avail_in-=a,t.set(e.input.subarray(e.next_in,e.next_in+a),n),e.state.wrap===1?e.adler=qg(e.adler,t,a,n):e.state.wrap===2&&(e.adler=ia(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},jZ=(e,t)=>{let n=e.max_chain_length,r=e.strstart,a,o,i=e.prev_length,s=e.nice_match;const c=e.strstart>e.w_size-Zi?e.strstart-(e.w_size-Zi):0,u=e.window,d=e.w_mask,p=e.prev,g=e.strstart+ml;let m=u[r+i-1],h=u[r+i];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do if(a=t,!(u[a+i]!==h||u[a+i-1]!==m||u[a]!==u[r]||u[++a]!==u[r+1])){r+=2,a++;do;while(u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&u[++r]===u[++a]&&ri){if(e.match_start=t,i=o,o>=s)break;m=u[r+i-1],h=u[r+i]}}while((t=p[t&d])>c&&--n!==0);return i<=e.lookahead?i:e.lookahead},Xd=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Zi)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),WHe(e),r+=t),e.strm.avail_in===0)break;if(n=i$(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=Rn)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=$l(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=$l(e,e.ins_h,e.window[a+Rn-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r,a,o,i=0,s=e.strm.avail_in;do{if(r=65535,o=e.bi_valid+42>>3,e.strm.avail_outa+e.strm.avail_in&&(r=a+e.strm.avail_in),r>o&&(r=o),r>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,vo(e.strm),a&&(a>r&&(a=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+a),e.strm.next_out),e.strm.next_out+=a,e.strm.avail_out-=a,e.strm.total_out+=a,e.block_start+=a,r-=a),r&&(i$(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(i===0);return s-=e.strm.avail_in,s&&(s>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=s&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-s,e.strm.next_in),e.strstart),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s),e.block_start=e.strstart),e.high_watero&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,o+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),o>e.strm.avail_in&&(o=e.strm.avail_in),o&&(i$(e.strm,e.window,e.strstart,o),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.high_water>3,o=e.pending_buf_size-o>65535?65535:e.pending_buf_size-o,n=o>e.w_size?e.w_size:o,a=e.strstart-e.block_start,(a>=n||(a||t===Ko)&&t!==_l&&e.strm.avail_in===0&&a<=o)&&(r=a>o?o:a,i=t===Ko&&e.strm.avail_in===0&&r===a?1:0,e$(e,e.block_start,r,i),e.block_start+=r,vo(e.strm)),i?Wc:Ua)},LI=(e,t)=>{let n,r;for(;;){if(e.lookahead=Rn&&(e.ins_h=$l(e,e.ins_h,e.window[e.strstart+Rn-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-Zi&&(e.match_length=jZ(e,n)),e.match_length>=Rn)if(r=Rl(e,e.strstart-e.match_start,e.match_length-Rn),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Rn){e.match_length--;do e.strstart++,e.ins_h=$l(e,e.ins_h,e.window[e.strstart+Rn-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=$l(e,e.ins_h,e.window[e.strstart+1]);else r=Rl(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Io(e,!1),e.strm.avail_out===0))return Ua}return e.insert=e.strstart{let n,r,a;for(;;){if(e.lookahead=Rn&&(e.ins_h=$l(e,e.ins_h,e.window[e.strstart+Rn-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Rn-1,n!==0&&e.prev_length4096)&&(e.match_length=Rn-1)),e.prev_length>=Rn&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-Rn,r=Rl(e,e.strstart-1-e.prev_match,e.prev_length-Rn),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=a&&(e.ins_h=$l(e,e.ins_h,e.window[e.strstart+Rn-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Rn-1,e.strstart++,r&&(Io(e,!1),e.strm.avail_out===0))return Ua}else if(e.match_available){if(r=Rl(e,0,e.window[e.strstart-1]),r&&Io(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Ua}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Rl(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let n,r,a,o;const i=e.window;for(;;){if(e.lookahead<=ml){if(Xd(e),e.lookahead<=ml&&t===_l)return Ua;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Rn&&e.strstart>0&&(a=e.strstart-1,r=i[a],r===i[++a]&&r===i[++a]&&r===i[++a])){o=e.strstart+ml;do;while(r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&r===i[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Rn?(n=Rl(e,1,e.match_length-Rn),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Rl(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Io(e,!1),e.strm.avail_out===0))return Ua}return e.insert=0,t===Ko?(Io(e,!0),e.strm.avail_out===0?Wc:_f):e.sym_next&&(Io(e,!1),e.strm.avail_out===0)?Ua:Rf},KHe=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(Xd(e),e.lookahead===0)){if(t===_l)return Ua;break}if(e.match_length=0,n=Rl(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Io(e,!1),e.strm.avail_out===0))return Ua}return e.insert=0,t===Ko?(Io(e,!0),e.strm.avail_out===0?Wc:_f):e.sym_next&&(Io(e,!1),e.strm.avail_out===0)?Ua:Rf};function Li(e,t,n,r,a){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=a}const xp=[new Li(0,0,0,0,FZ),new Li(4,4,8,4,LI),new Li(4,5,16,8,LI),new Li(4,6,32,32,LI),new Li(4,4,16,16,ku),new Li(8,16,32,32,ku),new Li(8,16,128,128,ku),new Li(8,32,128,256,ku),new Li(32,128,258,1024,ku),new Li(32,258,258,4096,ku)],YHe=e=>{e.window_size=2*e.w_size,il(e.head),e.max_lazy_match=xp[e.level].max_lazy,e.good_match=xp[e.level].good_length,e.nice_match=xp[e.level].nice_length,e.max_chain_length=xp[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Rn-1,e.match_available=0,e.ins_h=0};function XHe(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=vx,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(zHe*2),this.dyn_dtree=new Uint16Array((2*FHe+1)*2),this.bl_tree=new Uint16Array((2*BHe+1)*2),il(this.dyn_ltree),il(this.dyn_dtree),il(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(HHe+1),this.heap=new Uint16Array(2*t$+1),il(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*t$+1),il(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Wm=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Yd&&t.status!==o3&&t.status!==n$&&t.status!==r$&&t.status!==a$&&t.status!==o$&&t.status!==vc&&t.status!==yp?1:0},BZ=e=>{if(Wm(e))return bc(e,Xi);e.total_in=e.total_out=0,e.data_type=AHe;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?o3:t.wrap?Yd:vc,e.adler=t.wrap===2?0:1,t.last_flush=-2,wHe(t),ya},zZ=e=>{const t=BZ(e);return t===ya&&YHe(e.state),t},ZHe=(e,t)=>Wm(e)||e.state.wrap!==2?Xi:(e.state.gzhead=t,ya),HZ=(e,t,n,r,a,o)=>{if(!e)return Xi;let i=1;if(t===_He&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),a<1||a>MHe||n!==vx||r<8||r>15||t<0||t>9||o<0||o>NHe||r===8&&i!==1)return bc(e,Xi);r===8&&(r=9);const s=new XHe;return e.state=s,s.strm=e,s.status=Yd,s.wrap=i,s.gzhead=null,s.w_bits=r,s.w_size=1<HZ(e,t,vx,DHe,PHe,kHe),JHe=(e,t)=>{if(Wm(e)||t>QB||t<0)return e?bc(e,Xi):Xi;const n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===yp&&t!==Ko)return bc(e,e.avail_out===0?PI:Xi);const r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(vo(e),e.avail_out===0)return n.last_flush=-1,ya}else if(e.avail_in===0&&e7(t)<=e7(r)&&t!==Ko)return bc(e,PI);if(n.status===yp&&e.avail_in!==0)return bc(e,PI);if(n.status===Yd&&n.wrap===0&&(n.status=vc),n.status===Yd){let a=vx+(n.w_bits-8<<4)<<8,o=-1;if(n.strategy>=av||n.level<2?o=0:n.level<6?o=1:n.level===6?o=2:o=3,a|=o<<6,n.strstart!==0&&(a|=UHe),a+=31-a%31,rp(n,a),n.strstart!==0&&(rp(n,e.adler>>>16),rp(n,e.adler&65535)),e.adler=1,n.status=vc,vo(e),n.pending!==0)return n.last_flush=-1,ya}if(n.status===o3){if(e.adler=0,Ln(n,31),Ln(n,139),Ln(n,8),n.gzhead)Ln(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Ln(n,n.gzhead.time&255),Ln(n,n.gzhead.time>>8&255),Ln(n,n.gzhead.time>>16&255),Ln(n,n.gzhead.time>>24&255),Ln(n,n.level===9?2:n.strategy>=av||n.level<2?4:0),Ln(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(Ln(n,n.gzhead.extra.length&255),Ln(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=ia(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=n$;else if(Ln(n,0),Ln(n,0),Ln(n,0),Ln(n,0),Ln(n,0),Ln(n,n.level===9?2:n.strategy>=av||n.level<2?4:0),Ln(n,VHe),n.status=vc,vo(e),n.pending!==0)return n.last_flush=-1,ya}if(n.status===n$){if(n.gzhead.extra){let a=n.pending,o=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+o>n.pending_buf_size;){let s=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+s),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>a&&(e.adler=ia(e.adler,n.pending_buf,n.pending-a,a)),n.gzindex+=s,vo(e),n.pending!==0)return n.last_flush=-1,ya;a=0,o-=s}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+o),n.pending),n.pending+=o,n.gzhead.hcrc&&n.pending>a&&(e.adler=ia(e.adler,n.pending_buf,n.pending-a,a)),n.gzindex=0}n.status=r$}if(n.status===r$){if(n.gzhead.name){let a=n.pending,o;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>a&&(e.adler=ia(e.adler,n.pending_buf,n.pending-a,a)),vo(e),n.pending!==0)return n.last_flush=-1,ya;a=0}n.gzindexa&&(e.adler=ia(e.adler,n.pending_buf,n.pending-a,a)),n.gzindex=0}n.status=a$}if(n.status===a$){if(n.gzhead.comment){let a=n.pending,o;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>a&&(e.adler=ia(e.adler,n.pending_buf,n.pending-a,a)),vo(e),n.pending!==0)return n.last_flush=-1,ya;a=0}n.gzindexa&&(e.adler=ia(e.adler,n.pending_buf,n.pending-a,a))}n.status=o$}if(n.status===o$){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(vo(e),n.pending!==0))return n.last_flush=-1,ya;Ln(n,e.adler&255),Ln(n,e.adler>>8&255),e.adler=0}if(n.status=vc,vo(e),n.pending!==0)return n.last_flush=-1,ya}if(e.avail_in!==0||n.lookahead!==0||t!==_l&&n.status!==yp){let a=n.level===0?FZ(n,t):n.strategy===av?KHe(n,t):n.strategy===OHe?qHe(n,t):xp[n.level].func(n,t);if((a===Wc||a===_f)&&(n.status=yp),a===Ua||a===Wc)return e.avail_out===0&&(n.last_flush=-1),ya;if(a===Rf&&(t===IHe?EHe(n):t!==QB&&(e$(n,0,0,!1),t===THe&&(il(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),vo(e),e.avail_out===0))return n.last_flush=-1,ya}return t!==Ko?ya:n.wrap<=0?JB:(n.wrap===2?(Ln(n,e.adler&255),Ln(n,e.adler>>8&255),Ln(n,e.adler>>16&255),Ln(n,e.adler>>24&255),Ln(n,e.total_in&255),Ln(n,e.total_in>>8&255),Ln(n,e.total_in>>16&255),Ln(n,e.total_in>>24&255)):(rp(n,e.adler>>>16),rp(n,e.adler&65535)),vo(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?ya:JB)},eUe=e=>{if(Wm(e))return Xi;const t=e.state.status;return e.state=null,t===vc?bc(e,RHe):ya},tUe=(e,t)=>{let n=t.length;if(Wm(e))return Xi;const r=e.state,a=r.wrap;if(a===2||a===1&&r.status!==Yd||r.lookahead)return Xi;if(a===1&&(e.adler=qg(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){a===0&&(il(r.head),r.strstart=0,r.block_start=0,r.insert=0);let c=new Uint8Array(r.w_size);c.set(t.subarray(n-r.w_size,n),0),t=c,n=r.w_size}const o=e.avail_in,i=e.next_in,s=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Xd(r);r.lookahead>=Rn;){let c=r.strstart,u=r.lookahead-(Rn-1);do r.ins_h=$l(r,r.ins_h,r.window[c+Rn-1]),r.prev[c&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=c,c++;while(--u);r.strstart=c,r.lookahead=Rn-1,Xd(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=Rn-1,r.match_available=0,e.next_in=i,e.input=s,e.avail_in=o,r.wrap=a,ya};var nUe=QHe,rUe=HZ,aUe=zZ,oUe=BZ,iUe=ZHe,sUe=JHe,lUe=eUe,cUe=tUe,uUe="pako deflate (from Nodeca project)",Gp={deflateInit:nUe,deflateInit2:rUe,deflateReset:aUe,deflateResetKeep:oUe,deflateSetHeader:iUe,deflate:sUe,deflateEnd:lUe,deflateSetDictionary:cUe,deflateInfo:uUe};const dUe=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var fUe=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(const r in n)dUe(n,r)&&(e[r]=n[r])}}return e},pUe=e=>{let t=0;for(let r=0,a=e.length;r=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Kg[254]=Kg[254]=1;var gUe=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,a,o,i=e.length,s=0;for(a=0;a>>6,t[o++]=128|n&63):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|n&63):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|n&63);return t};const mUe=(e,t)=>{if(t<65534&&e.subarray&&UZ)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{const n=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let r,a;const o=new Array(n*2);for(a=0,r=0;r4){o[a++]=65533,r+=s-1;continue}for(i&=s===2?31:s===3?15:7;s>1&&r1){o[a++]=65533;continue}i<65536?o[a++]=i:(i-=65536,o[a++]=55296|i>>10&1023,o[a++]=56320|i&1023)}return mUe(o,a)},vUe=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+Kg[e[n]]>t?n:t},Yg={string2buf:gUe,buf2string:hUe,utf8border:vUe};function bUe(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var VZ=bUe;const WZ=Object.prototype.toString,{Z_NO_FLUSH:yUe,Z_SYNC_FLUSH:xUe,Z_FULL_FLUSH:SUe,Z_FINISH:wUe,Z_OK:l0,Z_STREAM_END:CUe,Z_DEFAULT_COMPRESSION:EUe,Z_DEFAULT_STRATEGY:IUe,Z_DEFLATED:TUe}=Tf;function Gm(e){this.options=bx.assign({level:EUe,method:TUe,chunkSize:16384,windowBits:15,memLevel:8,strategy:IUe},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new VZ,this.strm.avail_out=0;let n=Gp.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==l0)throw new Error(Vc[n]);if(t.header&&Gp.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=Yg.string2buf(t.dictionary):WZ.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=Gp.deflateSetDictionary(this.strm,r),n!==l0)throw new Error(Vc[n]);this._dict_set=!0}}Gm.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let a,o;if(this.ended)return!1;for(t===~~t?o=t:o=t===!0?wUe:yUe,typeof e=="string"?n.input=Yg.string2buf(e):WZ.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(o===xUe||o===SUe)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(a=Gp.deflate(n,o),a===CUe)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=Gp.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===l0;if(n.avail_out===0){this.onData(n.output);continue}if(o>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0};Gm.prototype.onData=function(e){this.chunks.push(e)};Gm.prototype.onEnd=function(e){e===l0&&(this.result=bx.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function i3(e,t){const n=new Gm(t);if(n.push(e,!0),n.err)throw n.msg||Vc[n.err];return n.result}function RUe(e,t){return t=t||{},t.raw=!0,i3(e,t)}function _Ue(e,t){return t=t||{},t.gzip=!0,i3(e,t)}var $Ue=Gm,OUe=i3,NUe=RUe,kUe=_Ue,AUe=Tf,MUe={Deflate:$Ue,deflate:OUe,deflateRaw:NUe,gzip:kUe,constants:AUe};const ov=16209,DUe=16191;var PUe=function(t,n){let r,a,o,i,s,c,u,d,p,g,m,h,b,x,S,v,y,w,C,E,I,T,R,_;const $=t.state;r=t.next_in,R=t.input,a=r+(t.avail_in-5),o=t.next_out,_=t.output,i=o-(n-t.avail_out),s=o+(t.avail_out-257),c=$.dmax,u=$.wsize,d=$.whave,p=$.wnext,g=$.window,m=$.hold,h=$.bits,b=$.lencode,x=$.distcode,S=(1<<$.lenbits)-1,v=(1<<$.distbits)-1;e:do{h<15&&(m+=R[r++]<>>24,m>>>=w,h-=w,w=y>>>16&255,w===0)_[o++]=y&65535;else if(w&16){C=y&65535,w&=15,w&&(h>>=w,h-=w),h<15&&(m+=R[r++]<>>24,m>>>=w,h-=w,w=y>>>16&255,w&16){if(E=y&65535,w&=15,hc){t.msg="invalid distance too far back",$.mode=ov;break e}if(m>>>=w,h-=w,w=o-i,E>w){if(w=E-w,w>d&&$.sane){t.msg="invalid distance too far back",$.mode=ov;break e}if(I=0,T=g,p===0){if(I+=u-w,w2;)_[o++]=T[I++],_[o++]=T[I++],_[o++]=T[I++],C-=3;C&&(_[o++]=T[I++],C>1&&(_[o++]=T[I++]))}else{I=o-E;do _[o++]=_[I++],_[o++]=_[I++],_[o++]=_[I++],C-=3;while(C>2);C&&(_[o++]=_[I++],C>1&&(_[o++]=_[I++]))}}else if(w&64){t.msg="invalid distance code",$.mode=ov;break e}else{y=x[(y&65535)+(m&(1<>3,r-=C,h-=C<<3,m&=(1<{const c=s.bits;let u=0,d=0,p=0,g=0,m=0,h=0,b=0,x=0,S=0,v=0,y,w,C,E,I,T=null,R;const _=new Uint16Array(Au+1),$=new Uint16Array(Au+1);let M=null,P,D,O;for(u=0;u<=Au;u++)_[u]=0;for(d=0;d=1&&_[g]===0;g--);if(m>g&&(m=g),g===0)return a[o++]=1<<24|64<<16|0,a[o++]=1<<24|64<<16|0,s.bits=1,0;for(p=1;p0&&(e===r7||g!==1))return-1;for($[1]=0,u=1;ut7||e===a7&&S>n7)return 1;for(;;){P=u-b,i[d]+1=R?(D=M[i[d]-R],O=T[i[d]-R]):(D=96,O=0),y=1<>b)+w]=P<<24|D<<16|O|0;while(w!==0);for(y=1<>=1;if(y!==0?(v&=y-1,v+=y):v=0,d++,--_[u]===0){if(u===g)break;u=t[n+i[d]]}if(u>m&&(v&E)!==C){for(b===0&&(b=m),I+=p,h=u-b,x=1<t7||e===a7&&S>n7)return 1;C=v&E,a[C]=m<<24|h<<16|I-o|0}}return v!==0&&(a[I+v]=u-b<<24|64<<16|0),s.bits=m,0};var qp=zUe;const HUe=0,GZ=1,qZ=2,{Z_FINISH:o7,Z_BLOCK:UUe,Z_TREES:iv,Z_OK:Gc,Z_STREAM_END:VUe,Z_NEED_DICT:WUe,Z_STREAM_ERROR:oi,Z_DATA_ERROR:KZ,Z_MEM_ERROR:YZ,Z_BUF_ERROR:GUe,Z_DEFLATED:i7}=Tf,yx=16180,s7=16181,l7=16182,c7=16183,u7=16184,d7=16185,f7=16186,p7=16187,g7=16188,m7=16189,c0=16190,ls=16191,FI=16192,h7=16193,BI=16194,v7=16195,b7=16196,y7=16197,x7=16198,sv=16199,lv=16200,S7=16201,w7=16202,C7=16203,E7=16204,I7=16205,zI=16206,T7=16207,R7=16208,yr=16209,XZ=16210,ZZ=16211,qUe=852,KUe=592,YUe=15,XUe=YUe,_7=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function ZUe(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const fu=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.modeZZ?1:0},QZ=e=>{if(fu(e))return oi;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=yx,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(qUe),t.distcode=t.distdyn=new Int32Array(KUe),t.sane=1,t.back=-1,Gc},JZ=e=>{if(fu(e))return oi;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,QZ(e)},eQ=(e,t)=>{let n;if(fu(e))return oi;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?oi:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,JZ(e))},tQ=(e,t)=>{if(!e)return oi;const n=new ZUe;e.state=n,n.strm=e,n.window=null,n.mode=yx;const r=eQ(e,t);return r!==Gc&&(e.state=null),r},QUe=e=>tQ(e,XUe);let $7=!0,HI,UI;const JUe=e=>{if($7){HI=new Int32Array(512),UI=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(qp(GZ,e.lens,0,288,HI,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;qp(qZ,e.lens,0,32,UI,0,e.work,{bits:5}),$7=!1}e.lencode=HI,e.lenbits=9,e.distcode=UI,e.distbits=5},nQ=(e,t,n,r)=>{let a;const o=e.state;return o.window===null&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(n-o.wsize,n),0),o.wnext=0,o.whave=o.wsize):(a=o.wsize-o.wnext,a>r&&(a=r),o.window.set(t.subarray(n-r,n-r+a),o.wnext),r-=a,r?(o.window.set(t.subarray(n-r,n),0),o.wnext=r,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave{let n,r,a,o,i,s,c,u,d,p,g,m,h,b,x=0,S,v,y,w,C,E,I,T;const R=new Uint8Array(4);let _,$;const M=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(fu(e)||!e.output||!e.input&&e.avail_in!==0)return oi;n=e.state,n.mode===ls&&(n.mode=FI),i=e.next_out,a=e.output,c=e.avail_out,o=e.next_in,r=e.input,s=e.avail_in,u=n.hold,d=n.bits,p=s,g=c,T=Gc;e:for(;;)switch(n.mode){case yx:if(n.wrap===0){n.mode=FI;break}for(;d<16;){if(s===0)break e;s--,u+=r[o++]<>>8&255,n.check=ia(n.check,R,2,0),u=0,d=0,n.mode=s7;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((u&255)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=yr;break}if((u&15)!==i7){e.msg="unknown compression method",n.mode=yr;break}if(u>>>=4,d-=4,I=(u&15)+8,n.wbits===0&&(n.wbits=I),I>15||I>n.wbits){e.msg="invalid window size",n.mode=yr;break}n.dmax=1<>8&1),n.flags&512&&n.wrap&4&&(R[0]=u&255,R[1]=u>>>8&255,n.check=ia(n.check,R,2,0)),u=0,d=0,n.mode=l7;case l7:for(;d<32;){if(s===0)break e;s--,u+=r[o++]<>>8&255,R[2]=u>>>16&255,R[3]=u>>>24&255,n.check=ia(n.check,R,4,0)),u=0,d=0,n.mode=c7;case c7:for(;d<16;){if(s===0)break e;s--,u+=r[o++]<>8),n.flags&512&&n.wrap&4&&(R[0]=u&255,R[1]=u>>>8&255,n.check=ia(n.check,R,2,0)),u=0,d=0,n.mode=u7;case u7:if(n.flags&1024){for(;d<16;){if(s===0)break e;s--,u+=r[o++]<>>8&255,n.check=ia(n.check,R,2,0)),u=0,d=0}else n.head&&(n.head.extra=null);n.mode=d7;case d7:if(n.flags&1024&&(m=n.length,m>s&&(m=s),m&&(n.head&&(I=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(o,o+m),I)),n.flags&512&&n.wrap&4&&(n.check=ia(n.check,r,m,o)),s-=m,o+=m,n.length-=m),n.length))break e;n.length=0,n.mode=f7;case f7:if(n.flags&2048){if(s===0)break e;m=0;do I=r[o+m++],n.head&&I&&n.length<65536&&(n.head.name+=String.fromCharCode(I));while(I&&m>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=ls;break;case m7:for(;d<32;){if(s===0)break e;s--,u+=r[o++]<>>=d&7,d-=d&7,n.mode=zI;break}for(;d<3;){if(s===0)break e;s--,u+=r[o++]<>>=1,d-=1,u&3){case 0:n.mode=h7;break;case 1:if(JUe(n),n.mode=sv,t===iv){u>>>=2,d-=2;break e}break;case 2:n.mode=b7;break;case 3:e.msg="invalid block type",n.mode=yr}u>>>=2,d-=2;break;case h7:for(u>>>=d&7,d-=d&7;d<32;){if(s===0)break e;s--,u+=r[o++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=yr;break}if(n.length=u&65535,u=0,d=0,n.mode=BI,t===iv)break e;case BI:n.mode=v7;case v7:if(m=n.length,m){if(m>s&&(m=s),m>c&&(m=c),m===0)break e;a.set(r.subarray(o,o+m),i),s-=m,o+=m,c-=m,i+=m,n.length-=m;break}n.mode=ls;break;case b7:for(;d<14;){if(s===0)break e;s--,u+=r[o++]<>>=5,d-=5,n.ndist=(u&31)+1,u>>>=5,d-=5,n.ncode=(u&15)+4,u>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=yr;break}n.have=0,n.mode=y7;case y7:for(;n.have>>=3,d-=3}for(;n.have<19;)n.lens[M[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,_={bits:n.lenbits},T=qp(HUe,n.lens,0,19,n.lencode,0,n.work,_),n.lenbits=_.bits,T){e.msg="invalid code lengths set",n.mode=yr;break}n.have=0,n.mode=x7;case x7:for(;n.have>>24,v=x>>>16&255,y=x&65535,!(S<=d);){if(s===0)break e;s--,u+=r[o++]<>>=S,d-=S,n.lens[n.have++]=y;else{if(y===16){for($=S+2;d<$;){if(s===0)break e;s--,u+=r[o++]<>>=S,d-=S,n.have===0){e.msg="invalid bit length repeat",n.mode=yr;break}I=n.lens[n.have-1],m=3+(u&3),u>>>=2,d-=2}else if(y===17){for($=S+3;d<$;){if(s===0)break e;s--,u+=r[o++]<>>=S,d-=S,I=0,m=3+(u&7),u>>>=3,d-=3}else{for($=S+7;d<$;){if(s===0)break e;s--,u+=r[o++]<>>=S,d-=S,I=0,m=11+(u&127),u>>>=7,d-=7}if(n.have+m>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=yr;break}for(;m--;)n.lens[n.have++]=I}}if(n.mode===yr)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=yr;break}if(n.lenbits=9,_={bits:n.lenbits},T=qp(GZ,n.lens,0,n.nlen,n.lencode,0,n.work,_),n.lenbits=_.bits,T){e.msg="invalid literal/lengths set",n.mode=yr;break}if(n.distbits=6,n.distcode=n.distdyn,_={bits:n.distbits},T=qp(qZ,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,_),n.distbits=_.bits,T){e.msg="invalid distances set",n.mode=yr;break}if(n.mode=sv,t===iv)break e;case sv:n.mode=lv;case lv:if(s>=6&&c>=258){e.next_out=i,e.avail_out=c,e.next_in=o,e.avail_in=s,n.hold=u,n.bits=d,PUe(e,g),i=e.next_out,a=e.output,c=e.avail_out,o=e.next_in,r=e.input,s=e.avail_in,u=n.hold,d=n.bits,n.mode===ls&&(n.back=-1);break}for(n.back=0;x=n.lencode[u&(1<>>24,v=x>>>16&255,y=x&65535,!(S<=d);){if(s===0)break e;s--,u+=r[o++]<>w)],S=x>>>24,v=x>>>16&255,y=x&65535,!(w+S<=d);){if(s===0)break e;s--,u+=r[o++]<>>=w,d-=w,n.back+=w}if(u>>>=S,d-=S,n.back+=S,n.length=y,v===0){n.mode=I7;break}if(v&32){n.back=-1,n.mode=ls;break}if(v&64){e.msg="invalid literal/length code",n.mode=yr;break}n.extra=v&15,n.mode=S7;case S7:if(n.extra){for($=n.extra;d<$;){if(s===0)break e;s--,u+=r[o++]<>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=w7;case w7:for(;x=n.distcode[u&(1<>>24,v=x>>>16&255,y=x&65535,!(S<=d);){if(s===0)break e;s--,u+=r[o++]<>w)],S=x>>>24,v=x>>>16&255,y=x&65535,!(w+S<=d);){if(s===0)break e;s--,u+=r[o++]<>>=w,d-=w,n.back+=w}if(u>>>=S,d-=S,n.back+=S,v&64){e.msg="invalid distance code",n.mode=yr;break}n.offset=y,n.extra=v&15,n.mode=C7;case C7:if(n.extra){for($=n.extra;d<$;){if(s===0)break e;s--,u+=r[o++]<>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=yr;break}n.mode=E7;case E7:if(c===0)break e;if(m=g-c,n.offset>m){if(m=n.offset-m,m>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=yr;break}m>n.wnext?(m-=n.wnext,h=n.wsize-m):h=n.wnext-m,m>n.length&&(m=n.length),b=n.window}else b=a,h=i-n.offset,m=n.length;m>c&&(m=c),c-=m,n.length-=m;do a[i++]=b[h++];while(--m);n.length===0&&(n.mode=lv);break;case I7:if(c===0)break e;a[i++]=n.length,c--,n.mode=lv;break;case zI:if(n.wrap){for(;d<32;){if(s===0)break e;s--,u|=r[o++]<{if(fu(e))return oi;let t=e.state;return t.window&&(t.window=null),e.state=null,Gc},nVe=(e,t)=>{if(fu(e))return oi;const n=e.state;return n.wrap&2?(n.head=t,t.done=!1,Gc):oi},rVe=(e,t)=>{const n=t.length;let r,a,o;return fu(e)||(r=e.state,r.wrap!==0&&r.mode!==c0)?oi:r.mode===c0&&(a=1,a=qg(a,t,n,0),a!==r.check)?KZ:(o=nQ(e,t,n,n),o?(r.mode=XZ,YZ):(r.havedict=1,Gc))};var aVe=JZ,oVe=eQ,iVe=QZ,sVe=QUe,lVe=tQ,cVe=eVe,uVe=tVe,dVe=nVe,fVe=rVe,pVe="pako inflate (from Nodeca project)",hs={inflateReset:aVe,inflateReset2:oVe,inflateResetKeep:iVe,inflateInit:sVe,inflateInit2:lVe,inflate:cVe,inflateEnd:uVe,inflateGetHeader:dVe,inflateSetDictionary:fVe,inflateInfo:pVe};function gVe(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var mVe=gVe;const rQ=Object.prototype.toString,{Z_NO_FLUSH:hVe,Z_FINISH:vVe,Z_OK:Xg,Z_STREAM_END:VI,Z_NEED_DICT:WI,Z_STREAM_ERROR:bVe,Z_DATA_ERROR:O7,Z_MEM_ERROR:yVe}=Tf;function qm(e){this.options=bx.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new VZ,this.strm.avail_out=0;let n=hs.inflateInit2(this.strm,t.windowBits);if(n!==Xg)throw new Error(Vc[n]);if(this.header=new mVe,hs.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Yg.string2buf(t.dictionary):rQ.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=hs.inflateSetDictionary(this.strm,t.dictionary),n!==Xg)))throw new Error(Vc[n])}qm.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,a=this.options.dictionary;let o,i,s;if(this.ended)return!1;for(t===~~t?i=t:i=t===!0?vVe:hVe,rQ.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),o=hs.inflate(n,i),o===WI&&a&&(o=hs.inflateSetDictionary(n,a),o===Xg?o=hs.inflate(n,i):o===O7&&(o=WI));n.avail_in>0&&o===VI&&n.state.wrap>0&&e[n.next_in]!==0;)hs.inflateReset(n),o=hs.inflate(n,i);switch(o){case bVe:case O7:case WI:case yVe:return this.onEnd(o),this.ended=!0,!1}if(s=n.avail_out,n.next_out&&(n.avail_out===0||o===VI))if(this.options.to==="string"){let c=Yg.utf8border(n.output,n.next_out),u=n.next_out-c,d=Yg.buf2string(n.output,c);n.next_out=u,n.avail_out=r-u,u&&n.output.set(n.output.subarray(c,c+u),0),this.onData(d)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(o===Xg&&s===0)){if(o===VI)return o=hs.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};qm.prototype.onData=function(e){this.chunks.push(e)};qm.prototype.onEnd=function(e){e===Xg&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=bx.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function s3(e,t){const n=new qm(t);if(n.push(e),n.err)throw n.msg||Vc[n.err];return n.result}function xVe(e,t){return t=t||{},t.raw=!0,s3(e,t)}var SVe=qm,wVe=s3,CVe=xVe,EVe=s3,IVe=Tf,TVe={Inflate:SVe,inflate:wVe,inflateRaw:CVe,ungzip:EVe,constants:IVe};const{Deflate:tqe,deflate:RVe,deflateRaw:nqe,gzip:rqe}=MUe,{Inflate:_Ve,inflate:aqe,inflateRaw:oqe,ungzip:iqe}=TVe;var $Ve=RVe,OVe=_Ve;class Sp{constructor(t,n=!1,r=!0){this.device=t,this.tracing=n,this.slipReaderEnabled=!1,this.leftOver=new Uint8Array(0),this.baudrate=0,this.traceLog="",this.lastTraceTime=Date.now(),this._DTR_state=!1,this.slipReaderEnabled=r}getInfo(){const t=this.device.getInfo();return t.usbVendorId&&t.usbProductId?`WebSerial VendorID 0x${t.usbVendorId.toString(16)} ProductID 0x${t.usbProductId.toString(16)}`:""}getPid(){return this.device.getInfo().usbProductId}trace(t){const a=`${`TRACE ${(Date.now()-this.lastTraceTime).toFixed(3)}`} ${t}`;console.log(a),this.traceLog+=a+` `}async returnTrace(){try{await navigator.clipboard.writeText(this.traceLog),console.log("Text copied to clipboard!")}catch(t){console.error("Failed to copy text:",t)}}hexify(t){return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("").padEnd(16," ")}hexConvert(t,n=!0){if(n&&t.length>16){let r="",a=t;for(;a.length>0;){const o=a.slice(0,16),i=String.fromCharCode(...o).split("").map(s=>s===" "||s>=" "&&s<="~"&&s!==" "?s:".").join("");a=a.slice(16),r+=` ${this.hexify(o.slice(0,8))} ${this.hexify(o.slice(8))} | ${i}`}return r}else return this.hexify(t)}slipWriter(t){const n=[];n.push(192);for(let r=0;r0)return o;a=this.leftOver,this.leftOver=new Uint8Array(0)}if(this.device.readable==null)return this.leftOver;this.reader=this.device.readable.getReader();try{t>0&&(r=setTimeout(()=>{this.reader&&this.reader.cancel()},t));do{const{value:o,done:i}=await this.reader.read();if(i)throw this.leftOver=a,new Error("Timeout");a=new Uint8Array(this._appendBuffer(a.buffer,o.buffer))}while(a.length0&&clearTimeout(r),this.reader.releaseLock()}if(this.tracing&&(console.log("Read bytes"),this.trace(`Read ${a.length} bytes: ${this.hexConvert(a)}`)),this.slipReaderEnabled){const o=this.slipReader(a);return this.tracing&&(console.log("Slip reader results"),this.trace(`Read ${o.length} bytes: ${this.hexConvert(o)}`)),o}return a}async rawRead(t=0){if(this.leftOver.length!=0){const r=this.leftOver;return this.leftOver=new Uint8Array(0),r}if(!this.device.readable)return this.leftOver;this.reader=this.device.readable.getReader();let n;try{t>0&&(n=setTimeout(()=>{this.reader&&this.reader.cancel()},t));const{value:r,done:a}=await this.reader.read();return a||this.tracing&&(console.log("Raw Read bytes"),this.trace(`Read ${r.length} bytes: ${this.hexConvert(r)}`)),r}finally{t>0&&clearTimeout(n),this.reader.releaseLock()}}async setRTS(t){await this.device.setSignals({requestToSend:t}),await this.setDTR(this._DTR_state)}async setDTR(t){this._DTR_state=t,await this.device.setSignals({dataTerminalReady:t})}async connect(t=115200,n={}){await this.device.open({baudRate:t,dataBits:n==null?void 0:n.dataBits,stopBits:n==null?void 0:n.stopBits,bufferSize:n==null?void 0:n.bufferSize,parity:n==null?void 0:n.parity,flowControl:n==null?void 0:n.flowControl}),this.baudrate=t,this.leftOver=new Uint8Array(0)}async sleep(t){return new Promise(n=>setTimeout(n,t))}async waitForUnlock(t){for(;this.device.readable&&this.device.readable.locked||this.device.writable&&this.device.writable.locked;)await this.sleep(t)}async disconnect(){var t,n;!((t=this.device.readable)===null||t===void 0)&&t.locked&&await((n=this.reader)===null||n===void 0?void 0:n.cancel()),await this.waitForUnlock(400),this.reader=void 0,await this.device.close()}}function Yv(e){return new Promise(t=>setTimeout(t,e))}async function NVe(e){await e.setRTS(!1),await e.setDTR(!1),await Yv(100),await e.setDTR(!0),await e.setRTS(!1),await Yv(100),await e.setRTS(!0),await e.setDTR(!1),await e.setRTS(!0),await Yv(100),await e.setRTS(!1),await e.setDTR(!1)}function kVe(e){const t=["D","R","W"],n=e.split("|");for(const r of n){const a=r[0],o=r.slice(1);if(!t.includes(a))return!1;if(a==="D"||a==="R"){if(o!=="0"&&o!=="1")return!1}else if(a==="W"){const i=parseInt(o);if(isNaN(i)||i<=0)return!1}}return!0}async function AVe(e,t){const n={D:async r=>await e.setDTR(r),R:async r=>await e.setRTS(r),W:async r=>await Yv(r)};try{if(!kVe(t))return;const a=t.split("|");for(const o of a){const i=o[0],s=o.slice(1);i==="W"?await n.W(Number(s)):(i==="D"||i==="R")&&await n[i](s==="1")}}catch{throw new Error("Invalid custom reset sequence")}}var MVe=function(t){return atob(t)};const N7=Wa(MVe);async function DVe(e){switch(e){case 15736195:{const{ESP32ROM:t}=await ui(async()=>{const{ESP32ROM:n}=await import("./esp32-BPYaDt9v.js");return{ESP32ROM:n}},__vite__mapDeps([0,1]));return new t}case 1867591791:case 2084675695:{const{ESP32C2ROM:t}=await ui(async()=>{const{ESP32C2ROM:n}=await import("./esp32c2-CVPL8n1g.js");return{ESP32C2ROM:n}},__vite__mapDeps([2,3,1]));return new t}case 1763790959:case 456216687:case 1216438383:case 1130455151:{const{ESP32C3ROM:t}=await ui(async()=>{const{ESP32C3ROM:n}=await import("./esp32c3-I3vXmsVg.js");return{ESP32C3ROM:n}},__vite__mapDeps([3,1]));return new t}case 752910447:{const{ESP32C6ROM:t}=await ui(async()=>{const{ESP32C6ROM:n}=await import("./esp32c6-C93uIFil.js");return{ESP32C6ROM:n}},__vite__mapDeps([4,1]));return new t}case 871374959:case 606167151:{const{ESP32C61ROM:t}=await ui(async()=>{const{ESP32C61ROM:n}=await import("./esp32c61-Qo5S0GG2.js");return{ESP32C61ROM:n}},__vite__mapDeps([5,4,1]));return new t}case 285294703:case 1675706479:{const{ESP32C5ROM:t}=await ui(async()=>{const{ESP32C5ROM:n}=await import("./esp32c5-CAGCiNY4.js");return{ESP32C5ROM:n}},__vite__mapDeps([6,4,1]));return new t}case 3619110528:{const{ESP32H2ROM:t}=await ui(async()=>{const{ESP32H2ROM:n}=await import("./esp32h2-Cf8JbGZQ.js");return{ESP32H2ROM:n}},__vite__mapDeps([7,1]));return new t}case 9:{const{ESP32S3ROM:t}=await ui(async()=>{const{ESP32S3ROM:n}=await import("./esp32s3-mu2zzjDN.js");return{ESP32S3ROM:n}},__vite__mapDeps([8,1]));return new t}case 1990:{const{ESP32S2ROM:t}=await ui(async()=>{const{ESP32S2ROM:n}=await import("./esp32s2-3nCAg6Ct.js");return{ESP32S2ROM:n}},__vite__mapDeps([9,1]));return new t}case 4293968129:{const{ESP8266ROM:t}=await ui(async()=>{const{ESP8266ROM:n}=await import("./esp8266-8VKmCx7J.js");return{ESP8266ROM:n}},__vite__mapDeps([10,1]));return new t}case 0:case 182303440:case 117676761:{const{ESP32P4ROM:t}=await ui(async()=>{const{ESP32P4ROM:n}=await import("./esp32p4-DfBdIAkh.js");return{ESP32P4ROM:n}},__vite__mapDeps([11,0,1]));return new t}default:return null}}class cv{constructor(t){this.ESP_RAM_BLOCK=6144,this.ESP_FLASH_BEGIN=2,this.ESP_FLASH_DATA=3,this.ESP_FLASH_END=4,this.ESP_MEM_BEGIN=5,this.ESP_MEM_END=6,this.ESP_MEM_DATA=7,this.ESP_WRITE_REG=9,this.ESP_READ_REG=10,this.ESP_SPI_ATTACH=13,this.ESP_CHANGE_BAUDRATE=15,this.ESP_FLASH_DEFL_BEGIN=16,this.ESP_FLASH_DEFL_DATA=17,this.ESP_FLASH_DEFL_END=18,this.ESP_SPI_FLASH_MD5=19,this.ESP_ERASE_FLASH=208,this.ESP_ERASE_REGION=209,this.ESP_READ_FLASH=210,this.ESP_RUN_USER_CODE=211,this.ESP_IMAGE_MAGIC=233,this.ESP_CHECKSUM_MAGIC=239,this.ROM_INVALID_RECV_MSG=5,this.ERASE_REGION_TIMEOUT_PER_MB=3e4,this.ERASE_WRITE_TIMEOUT_PER_MB=4e4,this.MD5_TIMEOUT_PER_MB=8e3,this.CHIP_ERASE_TIMEOUT=12e4,this.FLASH_READ_TIMEOUT=1e5,this.MAX_TIMEOUT=this.CHIP_ERASE_TIMEOUT*2,this.CHIP_DETECT_MAGIC_REG_ADDR=1073745920,this.DETECTED_FLASH_SIZES={18:"256KB",19:"512KB",20:"1MB",21:"2MB",22:"4MB",23:"8MB",24:"16MB"},this.DETECTED_FLASH_SIZES_NUM={18:256,19:512,20:1024,21:2048,22:4096,23:8192,24:16384},this.USB_JTAG_SERIAL_PID=4097,this.romBaudrate=115200,this.debugLogging=!1,this.syncStubDetected=!1,this.checksum=function(n){let r,a=239;for(r=0;rsetTimeout(n,t))}write(t,n=!0){this.terminal?n?this.terminal.writeLine(t):this.terminal.write(t):console.log(t)}error(t,n=!0){this.write(`Error: ${t}`,n)}info(t,n=!0){this.write(t,n)}debug(t,n=!0){this.debugLogging&&this.write(`Debug: ${t}`,n)}_shortToBytearray(t){return new Uint8Array([t&255,t>>8&255])}_intToByteArray(t){return new Uint8Array([t&255,t>>8&255,t>>16&255,t>>24&255])}_byteArrayToShort(t,n){return t|n>>8}_byteArrayToInt(t,n,r,a){return t|n<<8|r<<16|a<<24}_appendBuffer(t,n){const r=new Uint8Array(t.byteLength+n.byteLength);return r.set(new Uint8Array(t),0),r.set(new Uint8Array(n),t.byteLength),r.buffer}_appendArray(t,n){const r=new Uint8Array(t.length+n.length);return r.set(t,0),r.set(n,t.length),r}ui8ToBstr(t){let n="";for(let r=0;r0&&(i=this._appendArray(i,this._intToByteArray(this.chip.UART_DATE_REG_ADDR)),i=this._appendArray(i,this._intToByteArray(0)),i=this._appendArray(i,this._intToByteArray(0)),i=this._appendArray(i,this._intToByteArray(o))),await this.checkCommand("write target memory",this.ESP_WRITE_REG,i)}async sync(){this.debug("Sync");const t=new Uint8Array(36);let n;for(t[0]=7,t[1]=7,t[2]=18,t[3]=32,n=0;n<32;n++)t[4+n]=85;try{const r=await this.command(8,t,void 0,void 0,100);return this.syncStubDetected=this.syncStubDetected&&r[0]===0,r}catch(r){throw this.debug("Sync err "+r),r}}async _connectAttempt(t="default_reset",n=!1){if(this.debug("_connect_attempt "+t+" "+n),t!=="no_reset")if(this.transport.getPid()===this.USB_JTAG_SERIAL_PID)await NVe(this.transport);else{const o=n?"D0|R1|W100|W2000|D1|R0|W50|D0":"D0|R1|W100|D1|R0|W50|D0";await AVe(this.transport,o)}let r=0,a=!0;for(;a;){try{const o=await this.transport.read(1e3);r+=o.length}catch(o){if(this.debug(o.message),o instanceof Error){a=!1;break}}await this._sleep(50)}for(this.transport.slipReaderEnabled=!0,this.syncStubDetected=!0,r=7;r--;){try{const o=await this.sync();return this.debug(o[0].toString()),"success"}catch(o){o instanceof Error&&(n?this.info("_",!1):this.info(".",!1))}await this._sleep(50)}return"error"}async connect(t="default_reset",n=7,r=!1){let a,o;for(this.info("Connecting...",!1),await this.transport.connect(this.romBaudrate,this.serialOptions),a=0;a>>0;this.debug("Chip Magic "+i.toString(16));const s=await DVe(i);if(this.chip===null)throw new Ba(`Unexpected CHIP magic value ${i}. Failed to autodetect chip type.`);this.chip=s}}async detectChip(t="default_reset"){await this.connect(t),this.info("Detecting chip type... ",!1),this.chip!=null?this.info(this.chip.CHIP_NAME):this.info("unknown!")}async checkCommand(t="",n=null,r=new Uint8Array(0),a=0,o=3e3){this.debug("check_command "+t);const i=await this.command(n,r,a,void 0,o);return i[1].length>4?i[1]:i[0]}async memBegin(t,n,r,a){this.debug("mem_begin "+t+" "+n+" "+r+" "+a.toString(16));let o=this._appendArray(this._intToByteArray(t),this._intToByteArray(n));o=this._appendArray(o,this._intToByteArray(r)),o=this._appendArray(o,this._intToByteArray(a)),await this.checkCommand("enter RAM download mode",this.ESP_MEM_BEGIN,o)}async memBlock(t,n){let r=this._appendArray(this._intToByteArray(t.length),this._intToByteArray(n));r=this._appendArray(r,this._intToByteArray(0)),r=this._appendArray(r,this._intToByteArray(0)),r=this._appendArray(r,t);const a=this.checksum(t);await this.checkCommand("write to target RAM",this.ESP_MEM_DATA,r,a)}async memFinish(t){const n=t===0?1:0,r=this._appendArray(this._intToByteArray(n),this._intToByteArray(t));await this.checkCommand("leave RAM download mode",this.ESP_MEM_END,r,void 0,50)}async flashSpiAttach(t){const n=this._intToByteArray(t);await this.checkCommand("configure SPI flash pins",this.ESP_SPI_ATTACH,n)}async flashBegin(t,n){const r=Math.floor((t+this.FLASH_WRITE_SIZE-1)/this.FLASH_WRITE_SIZE),a=this.chip.getEraseSize(n,t),o=new Date,i=o.getTime();let s=3e3;this.IS_STUB==!1&&(s=this.timeoutPerMb(this.ERASE_REGION_TIMEOUT_PER_MB,t)),this.debug("flash begin "+a+" "+r+" "+this.FLASH_WRITE_SIZE+" "+n+" "+t);let c=this._appendArray(this._intToByteArray(a),this._intToByteArray(r));c=this._appendArray(c,this._intToByteArray(this.FLASH_WRITE_SIZE)),c=this._appendArray(c,this._intToByteArray(n)),this.IS_STUB==!1&&(c=this._appendArray(c,this._intToByteArray(0))),await this.checkCommand("enter Flash download mode",this.ESP_FLASH_BEGIN,c,void 0,s);const u=o.getTime();return t!=0&&this.IS_STUB==!1&&this.info("Took "+(u-i)/1e3+"."+(u-i)%1e3+"s to erase flash block"),r}async flashDeflBegin(t,n,r){const a=Math.floor((n+this.FLASH_WRITE_SIZE-1)/this.FLASH_WRITE_SIZE),o=Math.floor((t+this.FLASH_WRITE_SIZE-1)/this.FLASH_WRITE_SIZE),i=new Date,s=i.getTime();let c,u;this.IS_STUB?(c=t,u=3e3):(c=o*this.FLASH_WRITE_SIZE,u=this.timeoutPerMb(this.ERASE_REGION_TIMEOUT_PER_MB,c)),this.info("Compressed "+t+" bytes to "+n+"...");let d=this._appendArray(this._intToByteArray(c),this._intToByteArray(a));d=this._appendArray(d,this._intToByteArray(this.FLASH_WRITE_SIZE)),d=this._appendArray(d,this._intToByteArray(r)),(this.chip.CHIP_NAME==="ESP32-S2"||this.chip.CHIP_NAME==="ESP32-S3"||this.chip.CHIP_NAME==="ESP32-C3"||this.chip.CHIP_NAME==="ESP32-C2")&&this.IS_STUB===!1&&(d=this._appendArray(d,this._intToByteArray(0))),await this.checkCommand("enter compressed flash mode",this.ESP_FLASH_DEFL_BEGIN,d,void 0,u);const p=i.getTime();return t!=0&&this.IS_STUB===!1&&this.info("Took "+(p-s)/1e3+"."+(p-s)%1e3+"s to erase flash block"),a}async flashBlock(t,n,r){let a=this._appendArray(this._intToByteArray(t.length),this._intToByteArray(n));a=this._appendArray(a,this._intToByteArray(0)),a=this._appendArray(a,this._intToByteArray(0)),a=this._appendArray(a,t);const o=this.checksum(t);await this.checkCommand("write to target Flash after seq "+n,this.ESP_FLASH_DATA,a,o,r)}async flashDeflBlock(t,n,r){let a=this._appendArray(this._intToByteArray(t.length),this._intToByteArray(n));a=this._appendArray(a,this._intToByteArray(0)),a=this._appendArray(a,this._intToByteArray(0)),a=this._appendArray(a,t);const o=this.checksum(t);this.debug("flash_defl_block "+t[0].toString(16)+" "+t[1].toString(16)),await this.checkCommand("write compressed data to flash after seq "+n,this.ESP_FLASH_DEFL_DATA,a,o,r)}async flashFinish(t=!1){const n=t?0:1,r=this._intToByteArray(n);await this.checkCommand("leave Flash mode",this.ESP_FLASH_END,r)}async flashDeflFinish(t=!1){const n=t?0:1,r=this._intToByteArray(n);await this.checkCommand("leave compressed flash mode",this.ESP_FLASH_DEFL_END,r)}async runSpiflashCommand(t,n,r){const s=this.chip.SPI_REG_BASE,c=s+0,u=s+this.chip.SPI_USR_OFFS,d=s+this.chip.SPI_USR1_OFFS,p=s+this.chip.SPI_USR2_OFFS,g=s+this.chip.SPI_W0_OFFS;let m;this.chip.SPI_MOSI_DLEN_OFFS!=null?m=async(I,T)=>{const R=s+this.chip.SPI_MOSI_DLEN_OFFS,_=s+this.chip.SPI_MISO_DLEN_OFFS;I>0&&await this.writeReg(R,I-1),T>0&&await this.writeReg(_,T-1)}:m=async(I,T)=>{const R=d,_=17,$=8,M=I===0?0:I-1,D=(T===0?0:T-1)<<$|M<<_;await this.writeReg(R,D)};const h=1<<18,b=28;if(r>32)throw new Ba("Reading more than 32 bits back from a SPI flash operation is unsupported");if(n.length>64)throw new Ba("Writing more than 64 bytes of data with one SPI command is unsupported");const x=n.length*8,S=await this.readReg(u),v=await this.readReg(p);let y=-2147483648,w;r>0&&(y|=268435456),x>0&&(y|=134217728),await m(x,r),await this.writeReg(u,y);let C=7<("00"+n.toString(16)).slice(-2)).join("")}async flashMd5sum(t,n){const r=this.timeoutPerMb(this.MD5_TIMEOUT_PER_MB,n);let a=this._appendArray(this._intToByteArray(t),this._intToByteArray(n));a=this._appendArray(a,this._intToByteArray(0)),a=this._appendArray(a,this._intToByteArray(0));let o=await this.checkCommand("calculate md5sum",this.ESP_SPI_FLASH_MD5,a,void 0,r);return o instanceof Uint8Array&&o.length>16&&(o=o.slice(0,16)),this.toHex(o)}async readFlash(t,n,r=null){let a=this._appendArray(this._intToByteArray(t),this._intToByteArray(n));a=this._appendArray(a,this._intToByteArray(4096)),a=this._appendArray(a,this._intToByteArray(1024));const o=await this.checkCommand("read flash",this.ESP_READ_FLASH,a);if(o!=0)throw new Ba("Failed to read memory: "+o);let i=new Uint8Array(0);for(;i.length0&&(i=this._appendArray(i,s),await this.transport.write(this._intToByteArray(i.length)),r&&r(s,i.length,n));else throw new Ba("Failed to read memory: "+s)}return i}async runStub(){if(this.syncStubDetected)return this.info("Stub is already running. No upload is necessary."),this.chip;this.info("Uploading stub...");let t=N7(this.chip.ROM_TEXT),n=t.split("").map(function(s){return s.charCodeAt(0)});const r=new Uint8Array(n);t=N7(this.chip.ROM_DATA),n=t.split("").map(function(s){return s.charCodeAt(0)});const a=new Uint8Array(n);let o=Math.floor((r.length+this.ESP_RAM_BLOCK-1)/this.ESP_RAM_BLOCK),i;for(await this.memBegin(r.length,o,this.ESP_RAM_BLOCK,this.chip.TEXT_START),i=0;i"u")throw new Ba("Flash size "+t+" is not supported by this chip type. Supported sizes: "+this.chip.FLASH_SIZES);return this.chip.FLASH_SIZES[t]}_updateImageFlashParams(t,n,r,a,o){if(this.debug("_update_image_flash_params "+r+" "+a+" "+o),t.length<8||n!=this.chip.BOOTLOADER_FLASH_OFFSET)return t;if(r==="keep"&&a==="keep"&&o==="keep")return this.info("Not changing the image"),t;const i=parseInt(t[0]);let s=parseInt(t[2]);const c=parseInt(t[3]);if(i!==this.ESP_IMAGE_MAGIC)return this.info("Warning: Image file at 0x"+n.toString(16)+" doesn't look like an image file, so not changing any flash settings."),t;a!=="keep"&&(s={qio:0,qout:1,dio:2,dout:3}[a]);let u=c&15;o!=="keep"&&(u={"40m":0,"26m":1,"20m":2,"80m":15}[o]);let d=c&240;r!=="keep"&&(d=this.parseFlashSizeArg(r));const p=s<<8|u+d;return this.info("Flash params set to "+p.toString(16)),parseInt(t[2])!==s<<8&&(t=t.substring(0,2)+(s<<8).toString()+t.substring(3)),parseInt(t[3])!==u+d&&(t=t.substring(0,3)+(u+d).toString()+t.substring(4)),t}async writeFlash(t){if(this.debug("EspLoader program"),t.flashSize!=="keep"){const a=this.flashSizeBytes(t.flashSize);for(let o=0;oa)throw new Ba(`File ${o+1} doesn't fit in the available flash`)}this.IS_STUB===!0&&t.eraseAll===!0&&await this.eraseFlash();let n,r;for(let a=0;a0&&(n+="ÿÿÿÿ".substring(4-o)),r=t.fileArray[a].address,this.debug("Image Length "+n.length),n.length===0){this.debug("Warning: File is empty");continue}n=this._updateImageFlashParams(n,r,t.flashSize,t.flashMode,t.flashFreq);let i=null;t.calculateMD5Hash&&(i=t.calculateMD5Hash(n),this.debug("Image MD5 "+i));const s=n.length;let c;if(t.compress){const v=this.bstrToUi8(n);n=this.ui8ToBstr($Ve(v,{level:9})),c=await this.flashDeflBegin(s,n.length,r)}else c=await this.flashBegin(s,r);let u=0,d=0;const p=n.length;t.reportProgress&&t.reportProgress(a,0,p);let g=new Date;const m=g.getTime();let h=5e3;const b=new OVe({chunkSize:1});let x=0;for(b.onData=function(v){x+=v.byteLength};n.length>0;){this.debug("Write loop "+r+" "+u+" "+c),this.info("Writing at 0x"+(r+x).toString(16)+"... ("+Math.floor(100*(u+1)/c)+"%)");const v=this.bstrToUi8(n.slice(0,this.FLASH_WRITE_SIZE));if(t.compress){const y=x;b.push(v,!1);const w=x-y;let C=3e3;this.timeoutPerMb(this.ERASE_WRITE_TIMEOUT_PER_MB,w)>3e3&&(C=this.timeoutPerMb(this.ERASE_WRITE_TIMEOUT_PER_MB,w)),this.IS_STUB===!1&&(h=C),await this.flashDeflBlock(v,u,h),this.IS_STUB&&(h=C)}else throw new Ba("Yet to handle Non Compressed writes");d+=v.length,n=n.slice(this.FLASH_WRITE_SIZE,n.length),u++,t.reportProgress&&t.reportProgress(a,d,p)}this.IS_STUB&&await this.readReg(this.CHIP_DETECT_MAGIC_REG_ADDR,h),g=new Date;const S=g.getTime()-m;if(t.compress&&this.info("Wrote "+s+" bytes ("+d+" compressed) at 0x"+r.toString(16)+" in "+S/1e3+" seconds."),i){const v=await this.flashMd5sum(r,s);if(new String(v).valueOf()!=new String(i).valueOf())throw this.info("File md5: "+i),this.info("Flash md5: "+v),new Ba("MD5 of file does not match data in flash!");this.info("Hash of data verified.")}}this.info("Leaving..."),this.IS_STUB&&(await this.flashBegin(0,0),t.compress?await this.flashDeflFinish():await this.flashFinish())}async flashId(){this.debug("flash_id");const t=await this.readFlashId();this.info("Manufacturer: "+(t&255).toString(16));const n=t>>16&255;this.info("Device: "+(t>>8&255).toString(16)+n.toString(16)),this.info("Detected flash size: "+this.DETECTED_FLASH_SIZES[n])}async getFlashSize(){this.debug("flash_id");const n=await this.readFlashId()>>16&255;return this.DETECTED_FLASH_SIZES_NUM[n]}async hardReset(){await this.transport.setRTS(!0),await this._sleep(100),await this.transport.setRTS(!1)}async softReset(){if(!this.IS_STUB)await this.flashBegin(0,0),await this.flashFinish(!1);else{if(this.chip.CHIP_NAME!="ESP8266")throw new Ba("Soft resetting is currently only supported on ESP8266");await this.command(this.ESP_RUN_USER_CODE,void 0,void 0,!1)}}}const PVe=()=>{const[e,t]=l.useState(0),n=["",".","..","...","....","....."];return l.useEffect(()=>{const r=setInterval(()=>{t(a=>(a+1)%n.length)},666);return()=>clearInterval(r)},[]),f.jsx(f.Fragment,{children:n[e]})},LVe=()=>"serial"in navigator,Mu=new Dn(On()),{Paragraph:Hn,Text:jVe}=xn,{Step:FVe}=js,{Option:BVe}=cr,zVe=()=>{const{t:e}=Nt(),{setFetchCloudStatus:t,addNotification:n,addLoadingNotification:r,closeLoadingNotification:a}=Qn(),o=Zc(),i=dr.language,s=l.useRef(null),[c,u]=l.useState(!1),[d,p]=l.useState(""),[g,m]=l.useState(!1),[h,b]=l.useState(!1),[x,S]=l.useState(!1),[v,y]=l.useState("certs/client"),[w,C]=l.useState(""),[E,I]=l.useState(0),[T,R]=l.useState(!1),[_,$]=l.useState({progress:0,chipMac:"",chipType:"",flashId:"",flashManuf:"",flashDevice:"",flashSize:"",state:"",filename:"",flashName:"",port:null,originalFlash:null,patchedFlash:null,showStatus:!1,showProgress:!1,showDownload:!1,showFlash:!1,connected:!1,flagPreviousHostname:!1,previousHostname:"",hostname:window.location.hostname,wifi_ssid:"",wifi_pass:"",proceed:!1,actionInProgress:!1,warningTextHostname:"",warningTextWifi:"",downloadLink:"",downloadLinkPatched:"",error:!1,resetBox:!1}),[M,P]=l.useState(!1),[D,O]=l.useState(921600),k=[300,1200,2400,4800,9600,14400,19200,38400,57600,115200,230400,460800,921600],N=115200,A=ge=>{O(ge)};function L(ge){const ne=new Uint8Array(ge);let ve="";for(let _e=0;_e{(async()=>{const ve=await(await Mu.apiGetTeddyCloudSettingRaw("core.certdir")).text();y(ve)})()},[]),l.useEffect(()=>{P(LVe())},[]),l.useEffect(()=>{if(window.location.protocol!=="https:"){u(!1);const ge=async()=>{try{return await(await Mu.apiGetTeddyCloudSettingRaw("core.server.https_web_port")).text()}catch(_e){console.error("Error fetching https port: ",_e)}},ne=async()=>{try{return await(await Mu.apiGetTeddyCloudSettingRaw("core.server.http_port")).text()}catch(_e){console.error("Error fetching http port: ",_e)}};(async()=>{const _e=await ge()||"",ze=await ne()||"",Ue=new URL(window.location.href);Ue.protocol="https:",Ue.port?Ue.port=Ue.port===ze?_e:Ue.port:Ue.port=_e,p(Ue.toString())})()}else u(!0)},[]),l.useEffect(()=>{_.resetBox&&_.patchedFlash&&K()},[_.resetBox,_.patchedFlash]),l.useEffect(()=>{me(E,(()=>{switch(E){case 0:return le;case 1:return fe;case 2:return te;case 3:return _.resetBox?he:pe;default:return f.jsx("div",{})}})())},[_,i]),l.useEffect(()=>{!_.resetBox&&_.proceed&&He()},[_.proceed]),l.useEffect(()=>{m(_.actionInProgress)},[_.actionInProgress]);const j=()=>{d&&(window.location.href=d)},F=async ge=>{if(_.port)return console.log(_.port.getInfo),_.port;$(ve=>({...ve,showStatus:!0,showProgress:!1,progress:0,state:ge||"Open serial port"}));let ne=null;try{ne=await navigator.serial.requestPort(),await ne.open({baudRate:115200}),await ne.close()}catch(ve){return ve==="NetworkError"?($(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.portOpenFailedInUse"),error:!0})),alert(e("tonieboxes.esp32BoxFlashing.esp32flasher.portOpenFailedInUse"))):ve==="NotFoundError"?$(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.noPortAvailable"),error:!0})):($(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.error")+ve,error:!0})),alert(e("tonieboxes.esp32BoxFlashing.esp32flasher.error")+` ${ve}`)),null}return ne?(console.log("port done"),$(ve=>({...ve,port:ne})),ne):($(ve=>({...ve,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.invalidSerialPort"),error:!0})),null)},B=async ge=>{if(console.log("loadFlashFile"),!ge.target.files)return;const ne=ge.target.files[0];if(!ne)return;$(_e=>({..._e,state:"",chipMac:"",chipType:"",flashId:"",flashManuf:"",flashDevice:"",flashSize:"",error:!1,actionInProgress:!0}));const ve=new FileReader;_.resetBox?(console.log("Read file '"+ne+"' for reset"),ve.onload=async _e=>{var ze;console.log("Loading file for reset"),(ze=_e.target)==null||ze.result,_e.target&&$(Ue=>{var Ae;return{...Ue,patchedFlash:(Ae=_e.target)==null?void 0:Ae.result,showFlash:!0,connected:!1,flashName:"from file"}}),console.log("Load file done")}):(console.log("Read file '"+ne+"'"),ve.onload=async _e=>{var Ae;console.log("Connecting to ESP32");const ze=await F(e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingReadMac"));if(ze===null||_.connected){$(Oe=>({...Oe,actionInProgress:!1}));return}$(Oe=>({...Oe,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingTo")+` ${_.port}`,showFlash:!1,connected:!0}));let Ue=null;try{const Oe=new Sp(ze);Ue=new cv({transport:Oe,baudrate:D,romBaudrate:N})}catch(Oe){$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToConnect")+` ${Oe}`,connected:!1,actionInProgress:!1,error:!0})),alert(Oe),await ze.close();return}try{$(Qe=>({...Qe,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.retrievingMac"),actionInProgress:!0})),await Ue.main();let Oe=await Ue.chip.readMac(Ue);$(Qe=>({...Qe,chipMac:Oe})),console.log("Chip MAC: "+Oe),await ze.close();const Re=(Ae=_e.target)==null?void 0:Ae.result,at=new Uint8Array(Re),Ye=`ESP32_${Oe.replace(/:/g,"")}`,We=new Blob([at],{type:"application/octet-stream"}),qe=URL.createObjectURL(We);await U(at,Ye),_e.target&&$(Qe=>{var ot;return{...Qe,patchedFlash:(ot=_e.target)==null?void 0:ot.result,showFlash:!0,connected:!1,flashName:"from file",downloadLink:qe}}),console.log("Done")}catch(Oe){$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToCommunicate")+` ${Oe}`,connected:!1,actionInProgress:!1,error:!0})),console.error(Oe),alert(Oe),await ze.close();return}}),ve.readAsArrayBuffer(ne),$(_e=>({..._e,actionInProgress:!1})),ge.target.value=""},z=async()=>{let ge=null,ne=null,ve="";ne=new Uint8Array(1024);const _e=await F(e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingReadFlash"));if(_e===null||_.connected)return;$(Oe=>({...Oe,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingTo")+` ${_e.getInfo()}`,chipMac:"",chipType:"",flashId:"",flashManuf:"",flashDevice:"",flashSize:"",showFlash:!1,connected:!0,actionInProgress:!0,error:!1}));try{const Oe=new Sp(_e);ge=new cv({transport:Oe,baudrate:D,romBaudrate:N})}catch(Oe){$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToConnect")+` ${Oe}`,connected:!1,actionInProgress:!1,error:!0})),alert(Oe),await _e.close();return}try{$(Ye=>({...Ye,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingToESP")})),await ge.main(),$(Ye=>({...Ye,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connected")})),ve=await ge.chip.readMac(ge),$(Ye=>({...Ye,chipMac:ve})),console.log("Chip MAC: "+ve);const Oe=await ge.chip.getChipDescription(ge);$(Ye=>({...Ye,chipType:Oe}));let Re=await ge.readFlashId();$(Ye=>({...Ye,flashId:""+Re,flashManuf:""+(Re&255),flashDevice:""+(Re>>8&255)}));let at=await ge.getFlashSize();if($(Ye=>({...Ye,flashSize:""+at})),at<0||at>16384){$(Ye=>({...Ye,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashSizeError"),connected:!1,actionInProgress:!1,error:!0})),await _e.close();return}$(Ye=>({...Ye,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.readingFlash"),showProgress:!0,progress:0})),ne=await ge.readFlash(0,at*1024,(Ye,We,qe)=>{const Qe=100*We/qe;$(ot=>({...ot,progress:Qe}))}),await _e.close(),$(Ye=>({...Ye,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.readingFinished"),progress:100,originalFlash:ne,connected:!1}))}catch(Oe){$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToCommunicate")+` ${Oe}`,connected:!1,actionInProgress:!1,error:!0})),console.error(Oe),alert(Oe),await _e.close();return}const ze=`ESP32_${ve.replace(/:/g,"")}`,Ue=new Blob([ne],{type:"application/octet-stream"}),Ae=URL.createObjectURL(Ue);$(Oe=>({...Oe,downloadLink:Ae,showProgress:!1})),await U(ne,ze),console.log("Done")},U=async(ge,ne)=>{try{$(ze=>({...ze,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.uploading"),error:!1}));const ve=new FormData;ve.append(ne,new Blob([ge.buffer]),ne);const _e=await Mu.apiPostTeddyCloudFormDataRaw("/api/esp32/uploadFirmware",ve);if(_e.ok&&_e.status===200){const ze=await _e.text();$(Ue=>({...Ue,showDownload:!0,filename:ze,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.uploadSuccessful")+` ${ze}`+e("tonieboxes.esp32BoxFlashing.esp32flasher.readyToProceed"),proceed:!0,actionInProgress:!1}))}else $(ze=>({...ze,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.uploadFailed"),actionInProgress:!1,error:!0}))}catch(ve){console.error("There was an error when uploading!",ve),$(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.uploadFailed"),actionInProgress:!1,error:!0}))}},H=async()=>{if(_.wifi_ssid&&!_.wifi_pass||!_.wifi_ssid&&_.wifi_pass){$(ne=>({...ne,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiCredentialsIncomplete"),showStatus:!0,warningTextWifi:e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiCredentialsIncomplete"),error:!0}));return}$(ne=>({...ne,actionInProgress:!0})),$(ne=>({...ne,showProgress:!1,showFlash:!1,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.patchingFlashImage"),error:!1}));const ge=await Mu.apiGetTeddyCloudApiRaw(`/api/esp32/patchFirmware?filename=${_.filename}&hostname=${encodeURIComponent(_.hostname)}`+(_.wifi_ssid&&_.wifi_pass?`&wifi_ssid=${encodeURIComponent(_.wifi_ssid)}&wifi_pass=${encodeURIComponent(_.wifi_pass)}`:""));if($(ne=>({...ne,showProgress:!1,showFlash:!1,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.patchingFlashImage")})),ge.ok&&ge.status===200){const ne=await ge.arrayBuffer();$(ze=>({...ze,patchedFlash:ne,showFlash:!0,flashName:"patched"}));const ve=new Blob([ne],{type:"application/octet-stream"}),_e=URL.createObjectURL(ve);$(ze=>({...ze,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.patchingSuccessful",{size:(ne.byteLength/1024/1024).toFixed(0)}),downloadLinkPatched:_e})),He()}else $(ne=>({...ne,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.patchingFailed"),error:!0}));$(ne=>({...ne,actionInProgress:!1}))},K=async()=>{I(2);const ge=await F(e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingWriteFlash"));if(ge===null||_.connected)return;$(ve=>({...ve,actionInProgress:!0,error:!1})),$(ve=>({...ve,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingTo")+` ${ge.getInfo()}`,connected:!0}));let ne=null;try{const ve=new Sp(ge);ne=new cv({transport:ve,baudrate:D,romBaudrate:N})}catch(ve){$(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToConnect")+` ${ve}`,connected:!1,actionInProgress:!1,error:!0})),alert(ve),await ge.close();return}try{$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingToESP")})),await ne.main(),$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connected"),progress:0,showProgress:!0}));let ve=await ne.chip.readMac(ne);$(Re=>({...Re,chipMac:ve})),console.log("Chip MAC: "+ve);const _e=await ne.chip.getChipDescription(ne);$(Re=>({...Re,chipType:_e}));let ze=await ne.readFlashId();$(Re=>({...Re,flashId:""+ze,flashManuf:""+(ze&255),flashDevice:""+(ze>>8&255)}));let Ue=await ne.getFlashSize();if($(Re=>({...Re,flashSize:""+Ue})),Ue<0||Ue>16384){$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashSizeError"),connected:!1,actionInProgress:!1,error:!0})),await ge.close();return}$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.preparingFlash",{size:(_.patchedFlash.byteLength/1024/1024).toFixed(0)})}));let Ae=[];Ae.push({data:L(_.patchedFlash),address:0});let Oe={fileArray:Ae,flashSize:"keep",flashMode:"keep",flashFreq:"keep",eraseAll:!1,compress:!0,reportProgress:(Re,at,Ye)=>{const We=100*at/Ye;$(qe=>({...qe,progress:We}))}};$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.writingFlash",{size:(_.patchedFlash.byteLength/1024/1024).toFixed(0)})})),await ne.writeFlash(Oe),await ge.close(),$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.writingFinished"),connected:!1,actionInProgress:!1})),I(3)}catch(ve){$(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToCommunicate")+` ${ve}`,connected:!1,actionInProgress:!1,error:!0})),console.error(ve),alert(ve),await ge.close();return}},Y=async()=>{const ge=await F(e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingWriteFlash"));if(ge===null||_.connected)return;$(ve=>({...ve,actionInProgress:!0,error:!1})),$(ve=>({...ve,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingTo")+` ${ge.getInfo()}`,connected:!0}));let ne=null;try{const ve=new Sp(ge);ne=new cv({transport:ve,baudrate:D,romBaudrate:N})}catch(ve){$(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToConnect")+` ${ve}`,connected:!1,actionInProgress:!1,error:!0})),alert(ve),await ge.close();return}try{$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingToESP")})),await ne.main(),$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connected"),progress:0,showProgress:!0}));let ve=await ne.chip.readMac(ne);$(Re=>({...Re,chipMac:ve})),console.log("Chip MAC: "+ve);const _e=await ne.chip.getChipDescription(ne);$(Re=>({...Re,chipType:_e}));let ze=await ne.readFlashId();$(Re=>({...Re,flashId:""+ze,flashManuf:""+(ze&255),flashDevice:""+(ze>>8&255)}));let Ue=await ne.getFlashSize();if($(Re=>({...Re,flashSize:""+Ue})),Ue<0||Ue>16384){$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashSizeError"),connected:!1,actionInProgress:!1,error:!0})),await ge.close();return}$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.preparingFlash",{size:(_.patchedFlash.byteLength/1024/1024).toFixed(0)})}));let Ae=[];Ae.push({data:L(_.patchedFlash),address:0});let Oe={fileArray:Ae,flashSize:"keep",flashMode:"keep",flashFreq:"keep",eraseAll:!1,compress:!0,reportProgress:(Re,at,Ye)=>{const We=100*at/Ye;$(qe=>({...qe,progress:We}))}};$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.writingFlash",{size:(_.patchedFlash.byteLength/1024/1024).toFixed(0)})})),await ne.writeFlash(Oe),await ge.close(),$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.writingFinished"),connected:!1,actionInProgress:!1,proceed:!0}))}catch(ve){$(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToCommunicate")+` ${ve}`,connected:!1,actionInProgress:!1,error:!0})),console.error(ve),alert(ve),await ge.close();return}},ee=async ge=>{const ne="extractStoreCerts";r(ne,e("tonieboxes.esp32BoxFlashing.processing"),e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificates")),ge&&S(!1);try{const ve=await Mu.apiPostTeddyCloudRaw(`/api/esp32/extractCerts?filename=${_.filename}`+(ge?"&overwrite=true":""));if(a(ne),ve.ok&&ve.status===200)n(dt.Success,e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesSuccessful"),e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesSuccessfulDetails",{file:_.filename}),e("tonieboxes.esp32BoxFlashing.title")),t(_e=>!_e);else if(!ve.ok&&ve.status===409){const _e=await ve.text();n(dt.Error,e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesFailed"),e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesFailedDetails",{file:_.filename})+": "+_e,e("tonieboxes.esp32BoxFlashing.title")),C(_e),S(!0)}else n(dt.Error,e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesFailed"),e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesFailedDetails",{file:_.filename})+": "+await ve.text(),e("tonieboxes.esp32BoxFlashing.title"))}catch(ve){n(dt.Error,e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesFailed"),e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesFailedDetails",{file:_.filename})+": "+ve,e("tonieboxes.esp32BoxFlashing.title"))}},ae=[{title:e("tonieboxes.esp32BoxFlashing.esp32flasher.titleReadESP32ImportFlash")},{title:e("tonieboxes.esp32BoxFlashing.esp32flasher.titlePatchFlash")},{title:e("tonieboxes.esp32BoxFlashing.esp32flasher.titleFlashESP32")},{title:e("tonieboxes.esp32BoxFlashing.esp32flasher.titleESP32FirmwareFlashed")}],W=f.jsx(f.Fragment,{children:_.showProgress&&f.jsx("div",{children:f.jsx("div",{children:f.jsx(Py,{percent:_.progress||0,format:ge=>`${(ge??0).toFixed(2)}%`})})})}),q=f.jsx(f.Fragment,{children:(_.chipType||_.chipMac)&&f.jsxs("div",{children:[f.jsx(Wn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.infoTable")}),f.jsx("table",{className:"info-table",children:f.jsxs("tbody",{children:[_.chipType&&f.jsxs("tr",{children:[f.jsx("td",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.chipType")}),f.jsx("td",{children:_.chipType})]}),_.chipMac&&f.jsxs("tr",{children:[f.jsx("td",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.chipMAC")}),f.jsx("td",{children:_.chipMac})]}),_.flashId&&f.jsxs("tr",{children:[f.jsx("td",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashId")}),f.jsxs("td",{children:["0x",_.flashId.toString()]})]}),_.flashManuf&&f.jsxs("tr",{children:[f.jsx("td",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashManuf")}),f.jsxs("td",{children:["0x",_.flashManuf.toString()]})]}),_.flashDevice&&f.jsxs("tr",{children:[f.jsx("td",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashDevice")}),f.jsxs("td",{children:["0x",_.flashDevice.toString()]})]}),_.flashSize&&f.jsxs("tr",{children:[f.jsx("td",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashSize")}),f.jsxs("td",{children:[_.flashSize," KiB"]})]})]})})]})}),Z=ge=>ge.replace(/[^a-zA-Z0-9-.]/g,"").trim(),Q=ge=>{if(ge.endsWith("...")){const ne=ge.slice(0,-3);return f.jsxs("div",{style:{display:"flex"},children:[ne,f.jsx(PVe,{})]})}return ge},J=_.showStatus&&f.jsx("div",{className:"status",style:{marginBottom:16,color:_.error?"#CC3010":"unset"},children:f.jsx("i",{children:Q(_.state)})}),ie=xZ(),le=f.jsxs(f.Fragment,{children:[f.jsx("h3",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.titleReadESP32ImportFlash")}),!_.actionInProgress&&f.jsxs(f.Fragment,{children:[f.jsx(Hn,{children:f.jsx(Sn,{type:"warning",closeIcon:!0,showIcon:!0,message:e("tonieboxes.hintLatestFirmwareTitle"),description:e("tonieboxes.hintLatestFirmware")})}),f.jsx(Hn,{children:f.jsx(Sn,{type:"info",closeIcon:!0,showIcon:!0,message:e("tonieboxes.esp32BoxFlashing.adaptBaudrateOnProblems"),description:e("tonieboxes.esp32BoxFlashing.adaptBaudrateOnProblemsText")})}),f.jsx(Hn,{style:{marginTop:16},children:f.jsx(Sn,{type:"info",description:e("tonieboxes.esp32BoxFlashing.esp32flasher.hintReadESP32ImportFlash")})}),f.jsx($s,{size:"small",style:{marginBottom:16},items:[{key:"1",label:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectESPCollapseTitle"),children:ie}]})]}),J,f.jsx("input",{type:"file",style:{display:"none"},ref:s,onChange:B}),W]}),fe=f.jsxs(f.Fragment,{children:[f.jsx("h3",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.titlePatchFlash")}),f.jsxs("div",{children:[!_.actionInProgress&&f.jsx(Hn,{children:f.jsx(Sn,{type:"info",description:e("tonieboxes.esp32BoxFlashing.esp32flasher.hintPatchFlash")})}),J,!_.actionInProgress&&_.downloadLink?f.jsxs("div",{style:{marginBottom:16},children:[" ",f.jsx("a",{href:_.downloadLink,download:_.filename,title:_.filename,children:e("tonieboxes.esp32BoxFlashing.esp32flasher.downloadLink")})]}):"",f.jsxs(Gt,{children:[f.jsx(Wn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.hostnameSettings")}),f.jsx(Hn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.hintPatchHost")}),f.jsx(Gt.Item,{children:f.jsx(la,{align:"middle",style:{display:"flex",alignItems:"center"},children:f.jsx(Cn,{children:f.jsx(ts,{checked:_.flagPreviousHostname,onChange:ge=>{$(ne=>({...ne,flagPreviousHostname:ge.target.checked}))},children:e("tonieboxes.esp32BoxFlashing.esp32flasher.flagPreviousHostname")})})})}),_.flagPreviousHostname&&f.jsxs(Gt.Item,{children:[f.jsxs(la,{align:"middle",style:{display:"flex",alignItems:"center"},children:[f.jsx(Cn,{style:{flex:"0 0 200px"},children:f.jsx("label",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.previousHostname")})}),f.jsx(Cn,{style:{flex:"1 1 auto"},children:f.jsx(Jt,{type:"text",value:_.previousHostname,onChange:ge=>{let ne=Z(ge.target.value);$(ve=>({...ve,previousHostname:ne}))}})})]}),_.warningTextHostname&&f.jsx("p",{style:{color:"#CC3010"},children:e("tonieboxes.esp32BoxFlashing.esp32flasher.hostnameTooLong")})]}),f.jsxs(Gt.Item,{children:[f.jsxs(la,{align:"middle",style:{display:"flex",alignItems:"center"},children:[f.jsx(Cn,{style:{flex:"0 0 200px",color:_.warningTextHostname?"#CC3010":"unset"},children:f.jsx("label",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.hostname")})}),f.jsx(Cn,{style:{flex:"1 1 auto"},children:f.jsx(Jt,{type:"text",value:_.hostname,onChange:ge=>{let ne=Z(ge.target.value),ve="";ne.length>12?ve=e("tonieboxes.esp32BoxFlashing.esp32flasher.hostnameTooLong"):ve="",$(_e=>({..._e,hostname:ne,warningTextHostname:ve}))}})})]}),_.warningTextHostname&&f.jsx("p",{style:{color:"#CC3010"},children:e("tonieboxes.esp32BoxFlashing.esp32flasher.hostnameTooLong")})]}),f.jsx(Wn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiSettings")}),f.jsx(Hn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.hintPatchWifi")}),f.jsx(Gt.Item,{children:f.jsxs(la,{align:"middle",style:{display:"flex",alignItems:"center"},children:[f.jsx(Cn,{style:{flex:"0 0 200px",color:_.warningTextWifi?"#CC3010":"unset"},children:f.jsx("label",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiSSID")})}),f.jsx(Cn,{style:{flex:"1 1 auto"},children:f.jsx(Jt,{type:"text",defaultValue:_.wifi_ssid,onChange:ge=>{let ne=ge.target.value;$(ve=>({...ve,wifi_ssid:ne,warningTextWifi:ge.target.value&&_.wifi_pass||!ge.target.value&&!_.wifi_pass?"":e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiCredentialsIncomplete")}))}})})]})}),f.jsxs(Gt.Item,{children:[f.jsxs(la,{align:"middle",style:{display:"flex",alignItems:"center"},children:[f.jsx(Cn,{style:{flex:"0 0 200px",color:_.warningTextWifi?"#CC3010":"unset"},children:f.jsx("label",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiPassword")})}),f.jsx(Cn,{style:{flex:"1 1 auto"},children:f.jsx(Jt.Password,{defaultValue:_.wifi_pass,onChange:ge=>{let ne=ge.target.value;$(ve=>({...ve,wifi_pass:ne,warningTextWifi:ge.target.value&&_.wifi_ssid||!ge.target.value&&!_.wifi_ssid?"":e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiCredentialsIncomplete")}))}})})]}),_.warningTextWifi&&f.jsx("p",{style:{color:"#CC3010"},children:e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiCredentialsIncomplete")})]})]})]}),W]}),te=f.jsxs(f.Fragment,{children:[f.jsx("h3",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.titleFlashESP32")}),!_.actionInProgress&&f.jsxs(Hn,{children:[" ",f.jsx(Sn,{type:"info",description:e("tonieboxes.esp32BoxFlashing.esp32flasher.hintFlashESP32")})]}),J,!_.actionInProgress&&_.downloadLinkPatched?f.jsxs("div",{style:{marginBottom:16},children:[" ",f.jsx("a",{href:_.downloadLinkPatched,download:"patched_"+_.filename,title:"patched_"+_.filename,children:e("tonieboxes.esp32BoxFlashing.esp32flasher.downloadLinkPatched")})]}):"",W]}),se=`${v}/${_.chipMac?_.chipMac.replaceAll(":","").toLowerCase():""}`,pe=f.jsxs(f.Fragment,{children:[f.jsx("h3",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.titleESP32FirmwareFlashed")}),f.jsx(Hn,{children:f.jsx(Sn,{type:"success",description:e("tonieboxes.esp32BoxFlashing.esp32flasher.hintESP32FirmwareFlashed")})}),J,W,(_.downloadLink||_.downloadLinkPatched)&&f.jsxs(f.Fragment,{children:[f.jsx(Sn,{type:"info",style:{marginTop:16},showIcon:!0,message:e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificates"),description:f.jsxs("div",{children:[f.jsxs(xn,{children:[f.jsx(Wn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.automatically")}),f.jsx(Hn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificatesAutomaticallyHint")}),f.jsx(tt,{icon:f.jsx(BN,{}),disabled:g,type:"primary",onClick:()=>je(),style:{marginBottom:8},children:e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificates")}),f.jsx(Hn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificatesAutomaticallyHint2",{certDir:v,mac:_.chipMac.replaceAll(":","").toLocaleLowerCase()})})]}),f.jsx(Wn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.manually")}),f.jsx(xn,{style:{marginBottom:8},children:e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificatesManuallyHint")}),f.jsx(xn,{children:f.jsx($s,{size:"small",items:[{key:"1",label:e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificatesManually"),children:f.jsxs(xn,{children:[f.jsxs(Hn,{children:[e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificatesManuallyHintP1")," ",f.jsx(jVe,{code:!0,children:"docker exec -it bash"}),"."]}),f.jsx(Hn,{children:f.jsx("pre",{style:{fontSize:12},children:`# Please check the filename of your backup +\r`,!1),!r){const i=await this.readReg(this.CHIP_DETECT_MAGIC_REG_ADDR)>>>0;this.debug("Chip Magic "+i.toString(16));const s=await DVe(i);if(this.chip===null)throw new Ba(`Unexpected CHIP magic value ${i}. Failed to autodetect chip type.`);this.chip=s}}async detectChip(t="default_reset"){await this.connect(t),this.info("Detecting chip type... ",!1),this.chip!=null?this.info(this.chip.CHIP_NAME):this.info("unknown!")}async checkCommand(t="",n=null,r=new Uint8Array(0),a=0,o=3e3){this.debug("check_command "+t);const i=await this.command(n,r,a,void 0,o);return i[1].length>4?i[1]:i[0]}async memBegin(t,n,r,a){this.debug("mem_begin "+t+" "+n+" "+r+" "+a.toString(16));let o=this._appendArray(this._intToByteArray(t),this._intToByteArray(n));o=this._appendArray(o,this._intToByteArray(r)),o=this._appendArray(o,this._intToByteArray(a)),await this.checkCommand("enter RAM download mode",this.ESP_MEM_BEGIN,o)}async memBlock(t,n){let r=this._appendArray(this._intToByteArray(t.length),this._intToByteArray(n));r=this._appendArray(r,this._intToByteArray(0)),r=this._appendArray(r,this._intToByteArray(0)),r=this._appendArray(r,t);const a=this.checksum(t);await this.checkCommand("write to target RAM",this.ESP_MEM_DATA,r,a)}async memFinish(t){const n=t===0?1:0,r=this._appendArray(this._intToByteArray(n),this._intToByteArray(t));await this.checkCommand("leave RAM download mode",this.ESP_MEM_END,r,void 0,50)}async flashSpiAttach(t){const n=this._intToByteArray(t);await this.checkCommand("configure SPI flash pins",this.ESP_SPI_ATTACH,n)}async flashBegin(t,n){const r=Math.floor((t+this.FLASH_WRITE_SIZE-1)/this.FLASH_WRITE_SIZE),a=this.chip.getEraseSize(n,t),o=new Date,i=o.getTime();let s=3e3;this.IS_STUB==!1&&(s=this.timeoutPerMb(this.ERASE_REGION_TIMEOUT_PER_MB,t)),this.debug("flash begin "+a+" "+r+" "+this.FLASH_WRITE_SIZE+" "+n+" "+t);let c=this._appendArray(this._intToByteArray(a),this._intToByteArray(r));c=this._appendArray(c,this._intToByteArray(this.FLASH_WRITE_SIZE)),c=this._appendArray(c,this._intToByteArray(n)),this.IS_STUB==!1&&(c=this._appendArray(c,this._intToByteArray(0))),await this.checkCommand("enter Flash download mode",this.ESP_FLASH_BEGIN,c,void 0,s);const u=o.getTime();return t!=0&&this.IS_STUB==!1&&this.info("Took "+(u-i)/1e3+"."+(u-i)%1e3+"s to erase flash block"),r}async flashDeflBegin(t,n,r){const a=Math.floor((n+this.FLASH_WRITE_SIZE-1)/this.FLASH_WRITE_SIZE),o=Math.floor((t+this.FLASH_WRITE_SIZE-1)/this.FLASH_WRITE_SIZE),i=new Date,s=i.getTime();let c,u;this.IS_STUB?(c=t,u=3e3):(c=o*this.FLASH_WRITE_SIZE,u=this.timeoutPerMb(this.ERASE_REGION_TIMEOUT_PER_MB,c)),this.info("Compressed "+t+" bytes to "+n+"...");let d=this._appendArray(this._intToByteArray(c),this._intToByteArray(a));d=this._appendArray(d,this._intToByteArray(this.FLASH_WRITE_SIZE)),d=this._appendArray(d,this._intToByteArray(r)),(this.chip.CHIP_NAME==="ESP32-S2"||this.chip.CHIP_NAME==="ESP32-S3"||this.chip.CHIP_NAME==="ESP32-C3"||this.chip.CHIP_NAME==="ESP32-C2")&&this.IS_STUB===!1&&(d=this._appendArray(d,this._intToByteArray(0))),await this.checkCommand("enter compressed flash mode",this.ESP_FLASH_DEFL_BEGIN,d,void 0,u);const p=i.getTime();return t!=0&&this.IS_STUB===!1&&this.info("Took "+(p-s)/1e3+"."+(p-s)%1e3+"s to erase flash block"),a}async flashBlock(t,n,r){let a=this._appendArray(this._intToByteArray(t.length),this._intToByteArray(n));a=this._appendArray(a,this._intToByteArray(0)),a=this._appendArray(a,this._intToByteArray(0)),a=this._appendArray(a,t);const o=this.checksum(t);await this.checkCommand("write to target Flash after seq "+n,this.ESP_FLASH_DATA,a,o,r)}async flashDeflBlock(t,n,r){let a=this._appendArray(this._intToByteArray(t.length),this._intToByteArray(n));a=this._appendArray(a,this._intToByteArray(0)),a=this._appendArray(a,this._intToByteArray(0)),a=this._appendArray(a,t);const o=this.checksum(t);this.debug("flash_defl_block "+t[0].toString(16)+" "+t[1].toString(16)),await this.checkCommand("write compressed data to flash after seq "+n,this.ESP_FLASH_DEFL_DATA,a,o,r)}async flashFinish(t=!1){const n=t?0:1,r=this._intToByteArray(n);await this.checkCommand("leave Flash mode",this.ESP_FLASH_END,r)}async flashDeflFinish(t=!1){const n=t?0:1,r=this._intToByteArray(n);await this.checkCommand("leave compressed flash mode",this.ESP_FLASH_DEFL_END,r)}async runSpiflashCommand(t,n,r){const s=this.chip.SPI_REG_BASE,c=s+0,u=s+this.chip.SPI_USR_OFFS,d=s+this.chip.SPI_USR1_OFFS,p=s+this.chip.SPI_USR2_OFFS,g=s+this.chip.SPI_W0_OFFS;let m;this.chip.SPI_MOSI_DLEN_OFFS!=null?m=async(I,T)=>{const R=s+this.chip.SPI_MOSI_DLEN_OFFS,_=s+this.chip.SPI_MISO_DLEN_OFFS;I>0&&await this.writeReg(R,I-1),T>0&&await this.writeReg(_,T-1)}:m=async(I,T)=>{const R=d,_=17,$=8,M=I===0?0:I-1,D=(T===0?0:T-1)<<$|M<<_;await this.writeReg(R,D)};const h=1<<18,b=28;if(r>32)throw new Ba("Reading more than 32 bits back from a SPI flash operation is unsupported");if(n.length>64)throw new Ba("Writing more than 64 bytes of data with one SPI command is unsupported");const x=n.length*8,S=await this.readReg(u),v=await this.readReg(p);let y=-2147483648,w;r>0&&(y|=268435456),x>0&&(y|=134217728),await m(x,r),await this.writeReg(u,y);let C=7<("00"+n.toString(16)).slice(-2)).join("")}async flashMd5sum(t,n){const r=this.timeoutPerMb(this.MD5_TIMEOUT_PER_MB,n);let a=this._appendArray(this._intToByteArray(t),this._intToByteArray(n));a=this._appendArray(a,this._intToByteArray(0)),a=this._appendArray(a,this._intToByteArray(0));let o=await this.checkCommand("calculate md5sum",this.ESP_SPI_FLASH_MD5,a,void 0,r);return o instanceof Uint8Array&&o.length>16&&(o=o.slice(0,16)),this.toHex(o)}async readFlash(t,n,r=null){let a=this._appendArray(this._intToByteArray(t),this._intToByteArray(n));a=this._appendArray(a,this._intToByteArray(4096)),a=this._appendArray(a,this._intToByteArray(1024));const o=await this.checkCommand("read flash",this.ESP_READ_FLASH,a);if(o!=0)throw new Ba("Failed to read memory: "+o);let i=new Uint8Array(0);for(;i.length0&&(i=this._appendArray(i,s),await this.transport.write(this._intToByteArray(i.length)),r&&r(s,i.length,n));else throw new Ba("Failed to read memory: "+s)}return i}async runStub(){if(this.syncStubDetected)return this.info("Stub is already running. No upload is necessary."),this.chip;this.info("Uploading stub...");let t=N7(this.chip.ROM_TEXT),n=t.split("").map(function(s){return s.charCodeAt(0)});const r=new Uint8Array(n);t=N7(this.chip.ROM_DATA),n=t.split("").map(function(s){return s.charCodeAt(0)});const a=new Uint8Array(n);let o=Math.floor((r.length+this.ESP_RAM_BLOCK-1)/this.ESP_RAM_BLOCK),i;for(await this.memBegin(r.length,o,this.ESP_RAM_BLOCK,this.chip.TEXT_START),i=0;i"u")throw new Ba("Flash size "+t+" is not supported by this chip type. Supported sizes: "+this.chip.FLASH_SIZES);return this.chip.FLASH_SIZES[t]}_updateImageFlashParams(t,n,r,a,o){if(this.debug("_update_image_flash_params "+r+" "+a+" "+o),t.length<8||n!=this.chip.BOOTLOADER_FLASH_OFFSET)return t;if(r==="keep"&&a==="keep"&&o==="keep")return this.info("Not changing the image"),t;const i=parseInt(t[0]);let s=parseInt(t[2]);const c=parseInt(t[3]);if(i!==this.ESP_IMAGE_MAGIC)return this.info("Warning: Image file at 0x"+n.toString(16)+" doesn't look like an image file, so not changing any flash settings."),t;a!=="keep"&&(s={qio:0,qout:1,dio:2,dout:3}[a]);let u=c&15;o!=="keep"&&(u={"40m":0,"26m":1,"20m":2,"80m":15}[o]);let d=c&240;r!=="keep"&&(d=this.parseFlashSizeArg(r));const p=s<<8|u+d;return this.info("Flash params set to "+p.toString(16)),parseInt(t[2])!==s<<8&&(t=t.substring(0,2)+(s<<8).toString()+t.substring(3)),parseInt(t[3])!==u+d&&(t=t.substring(0,3)+(u+d).toString()+t.substring(4)),t}async writeFlash(t){if(this.debug("EspLoader program"),t.flashSize!=="keep"){const a=this.flashSizeBytes(t.flashSize);for(let o=0;oa)throw new Ba(`File ${o+1} doesn't fit in the available flash`)}this.IS_STUB===!0&&t.eraseAll===!0&&await this.eraseFlash();let n,r;for(let a=0;a0&&(n+="ÿÿÿÿ".substring(4-o)),r=t.fileArray[a].address,this.debug("Image Length "+n.length),n.length===0){this.debug("Warning: File is empty");continue}n=this._updateImageFlashParams(n,r,t.flashSize,t.flashMode,t.flashFreq);let i=null;t.calculateMD5Hash&&(i=t.calculateMD5Hash(n),this.debug("Image MD5 "+i));const s=n.length;let c;if(t.compress){const v=this.bstrToUi8(n);n=this.ui8ToBstr($Ve(v,{level:9})),c=await this.flashDeflBegin(s,n.length,r)}else c=await this.flashBegin(s,r);let u=0,d=0;const p=n.length;t.reportProgress&&t.reportProgress(a,0,p);let g=new Date;const m=g.getTime();let h=5e3;const b=new OVe({chunkSize:1});let x=0;for(b.onData=function(v){x+=v.byteLength};n.length>0;){this.debug("Write loop "+r+" "+u+" "+c),this.info("Writing at 0x"+(r+x).toString(16)+"... ("+Math.floor(100*(u+1)/c)+"%)");const v=this.bstrToUi8(n.slice(0,this.FLASH_WRITE_SIZE));if(t.compress){const y=x;b.push(v,!1);const w=x-y;let C=3e3;this.timeoutPerMb(this.ERASE_WRITE_TIMEOUT_PER_MB,w)>3e3&&(C=this.timeoutPerMb(this.ERASE_WRITE_TIMEOUT_PER_MB,w)),this.IS_STUB===!1&&(h=C),await this.flashDeflBlock(v,u,h),this.IS_STUB&&(h=C)}else throw new Ba("Yet to handle Non Compressed writes");d+=v.length,n=n.slice(this.FLASH_WRITE_SIZE,n.length),u++,t.reportProgress&&t.reportProgress(a,d,p)}this.IS_STUB&&await this.readReg(this.CHIP_DETECT_MAGIC_REG_ADDR,h),g=new Date;const S=g.getTime()-m;if(t.compress&&this.info("Wrote "+s+" bytes ("+d+" compressed) at 0x"+r.toString(16)+" in "+S/1e3+" seconds."),i){const v=await this.flashMd5sum(r,s);if(new String(v).valueOf()!=new String(i).valueOf())throw this.info("File md5: "+i),this.info("Flash md5: "+v),new Ba("MD5 of file does not match data in flash!");this.info("Hash of data verified.")}}this.info("Leaving..."),this.IS_STUB&&(await this.flashBegin(0,0),t.compress?await this.flashDeflFinish():await this.flashFinish())}async flashId(){this.debug("flash_id");const t=await this.readFlashId();this.info("Manufacturer: "+(t&255).toString(16));const n=t>>16&255;this.info("Device: "+(t>>8&255).toString(16)+n.toString(16)),this.info("Detected flash size: "+this.DETECTED_FLASH_SIZES[n])}async getFlashSize(){this.debug("flash_id");const n=await this.readFlashId()>>16&255;return this.DETECTED_FLASH_SIZES_NUM[n]}async hardReset(){await this.transport.setRTS(!0),await this._sleep(100),await this.transport.setRTS(!1)}async softReset(){if(!this.IS_STUB)await this.flashBegin(0,0),await this.flashFinish(!1);else{if(this.chip.CHIP_NAME!="ESP8266")throw new Ba("Soft resetting is currently only supported on ESP8266");await this.command(this.ESP_RUN_USER_CODE,void 0,void 0,!1)}}}const PVe=()=>{const[e,t]=l.useState(0),n=["",".","..","...","....","....."];return l.useEffect(()=>{const r=setInterval(()=>{t(a=>(a+1)%n.length)},666);return()=>clearInterval(r)},[]),f.jsx(f.Fragment,{children:n[e]})},LVe=()=>"serial"in navigator,Mu=new Dn(On()),{Paragraph:Hn,Text:jVe}=xn,{Step:FVe}=js,{Option:BVe}=cr,zVe=()=>{const{t:e}=Nt(),{setFetchCloudStatus:t,addNotification:n,addLoadingNotification:r,closeLoadingNotification:a}=Qn(),o=Zc(),i=dr.language,s=l.useRef(null),[c,u]=l.useState(!1),[d,p]=l.useState(""),[g,m]=l.useState(!1),[h,b]=l.useState(!1),[x,S]=l.useState(!1),[v,y]=l.useState("certs/client"),[w,C]=l.useState(""),[E,I]=l.useState(0),[T,R]=l.useState(!1),[_,$]=l.useState({progress:0,chipMac:"",chipType:"",flashId:"",flashManuf:"",flashDevice:"",flashSize:"",state:"",filename:"",flashName:"",port:null,originalFlash:null,patchedFlash:null,showStatus:!1,showProgress:!1,showDownload:!1,showFlash:!1,connected:!1,flagPreviousHostname:!1,previousHostname:"",hostname:window.location.hostname!=="localhost"&&window.location.hostname!=="127.0.0.1"?window.location.hostname:"",wifi_ssid:"",wifi_pass:"",proceed:!1,actionInProgress:!1,warningTextHostname:"",warningTextWifi:"",downloadLink:"",downloadLinkPatched:"",error:!1,resetBox:!1}),[M,P]=l.useState(!1),[D,O]=l.useState(921600),k=[300,1200,2400,4800,9600,14400,19200,38400,57600,115200,230400,460800,921600],N=115200,A=ge=>{O(ge)};function L(ge){const ne=new Uint8Array(ge);let ve="";for(let _e=0;_e{(async()=>{const ve=await(await Mu.apiGetTeddyCloudSettingRaw("core.certdir")).text();y(ve)})()},[]),l.useEffect(()=>{P(LVe())},[]),l.useEffect(()=>{if(window.location.protocol!=="https:"){u(!1);const ge=async()=>{try{return await(await Mu.apiGetTeddyCloudSettingRaw("core.server.https_web_port")).text()}catch(_e){console.error("Error fetching https port: ",_e)}},ne=async()=>{try{return await(await Mu.apiGetTeddyCloudSettingRaw("core.server.http_port")).text()}catch(_e){console.error("Error fetching http port: ",_e)}};(async()=>{const _e=await ge()||"",ze=await ne()||"",Ue=new URL(window.location.href);Ue.protocol="https:",Ue.port?Ue.port=Ue.port===ze?_e:Ue.port:Ue.port=_e,p(Ue.toString())})()}else u(!0)},[]),l.useEffect(()=>{_.resetBox&&_.patchedFlash&&K()},[_.resetBox,_.patchedFlash]),l.useEffect(()=>{me(E,(()=>{switch(E){case 0:return le;case 1:return fe;case 2:return te;case 3:return _.resetBox?he:pe;default:return f.jsx("div",{})}})())},[_,i]),l.useEffect(()=>{!_.resetBox&&_.proceed&&He()},[_.proceed]),l.useEffect(()=>{m(_.actionInProgress)},[_.actionInProgress]);const j=()=>{d&&(window.location.href=d)},F=async ge=>{if(_.port)return console.log(_.port.getInfo),_.port;$(ve=>({...ve,showStatus:!0,showProgress:!1,progress:0,state:ge||"Open serial port"}));let ne=null;try{ne=await navigator.serial.requestPort(),await ne.open({baudRate:115200}),await ne.close()}catch(ve){return ve==="NetworkError"?($(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.portOpenFailedInUse"),error:!0})),alert(e("tonieboxes.esp32BoxFlashing.esp32flasher.portOpenFailedInUse"))):ve==="NotFoundError"?$(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.noPortAvailable"),error:!0})):($(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.error")+ve,error:!0})),alert(e("tonieboxes.esp32BoxFlashing.esp32flasher.error")+` ${ve}`)),null}return ne?(console.log("port done"),$(ve=>({...ve,port:ne})),ne):($(ve=>({...ve,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.invalidSerialPort"),error:!0})),null)},B=async ge=>{if(console.log("loadFlashFile"),!ge.target.files)return;const ne=ge.target.files[0];if(!ne)return;$(_e=>({..._e,state:"",chipMac:"",chipType:"",flashId:"",flashManuf:"",flashDevice:"",flashSize:"",error:!1,actionInProgress:!0}));const ve=new FileReader;_.resetBox?(console.log("Read file '"+ne+"' for reset"),ve.onload=async _e=>{var ze;console.log("Loading file for reset"),(ze=_e.target)==null||ze.result,_e.target&&$(Ue=>{var Ae;return{...Ue,patchedFlash:(Ae=_e.target)==null?void 0:Ae.result,showFlash:!0,connected:!1,flashName:"from file"}}),console.log("Load file done")}):(console.log("Read file '"+ne+"'"),ve.onload=async _e=>{var Ae;console.log("Connecting to ESP32");const ze=await F(e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingReadMac"));if(ze===null||_.connected){$(Oe=>({...Oe,actionInProgress:!1}));return}$(Oe=>({...Oe,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingTo")+` ${_.port}`,showFlash:!1,connected:!0}));let Ue=null;try{const Oe=new Sp(ze);Ue=new cv({transport:Oe,baudrate:D,romBaudrate:N})}catch(Oe){$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToConnect")+` ${Oe}`,connected:!1,actionInProgress:!1,error:!0})),alert(Oe),await ze.close();return}try{$(Qe=>({...Qe,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.retrievingMac"),actionInProgress:!0})),await Ue.main();let Oe=await Ue.chip.readMac(Ue);$(Qe=>({...Qe,chipMac:Oe})),console.log("Chip MAC: "+Oe),await ze.close();const Re=(Ae=_e.target)==null?void 0:Ae.result,at=new Uint8Array(Re),Ye=`ESP32_${Oe.replace(/:/g,"")}`,We=new Blob([at],{type:"application/octet-stream"}),qe=URL.createObjectURL(We);await U(at,Ye),_e.target&&$(Qe=>{var ot;return{...Qe,patchedFlash:(ot=_e.target)==null?void 0:ot.result,showFlash:!0,connected:!1,flashName:"from file",downloadLink:qe}}),console.log("Done")}catch(Oe){$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToCommunicate")+` ${Oe}`,connected:!1,actionInProgress:!1,error:!0})),console.error(Oe),alert(Oe),await ze.close();return}}),ve.readAsArrayBuffer(ne),$(_e=>({..._e,actionInProgress:!1})),ge.target.value=""},z=async()=>{let ge=null,ne=null,ve="";ne=new Uint8Array(1024);const _e=await F(e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingReadFlash"));if(_e===null||_.connected)return;$(Oe=>({...Oe,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingTo")+` ${_e.getInfo()}`,chipMac:"",chipType:"",flashId:"",flashManuf:"",flashDevice:"",flashSize:"",showFlash:!1,connected:!0,actionInProgress:!0,error:!1}));try{const Oe=new Sp(_e);ge=new cv({transport:Oe,baudrate:D,romBaudrate:N})}catch(Oe){$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToConnect")+` ${Oe}`,connected:!1,actionInProgress:!1,error:!0})),alert(Oe),await _e.close();return}try{$(Ye=>({...Ye,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingToESP")})),await ge.main(),$(Ye=>({...Ye,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connected")})),ve=await ge.chip.readMac(ge),$(Ye=>({...Ye,chipMac:ve})),console.log("Chip MAC: "+ve);const Oe=await ge.chip.getChipDescription(ge);$(Ye=>({...Ye,chipType:Oe}));let Re=await ge.readFlashId();$(Ye=>({...Ye,flashId:""+Re,flashManuf:""+(Re&255),flashDevice:""+(Re>>8&255)}));let at=await ge.getFlashSize();if($(Ye=>({...Ye,flashSize:""+at})),at<0||at>16384){$(Ye=>({...Ye,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashSizeError"),connected:!1,actionInProgress:!1,error:!0})),await _e.close();return}$(Ye=>({...Ye,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.readingFlash"),showProgress:!0,progress:0})),ne=await ge.readFlash(0,at*1024,(Ye,We,qe)=>{const Qe=100*We/qe;$(ot=>({...ot,progress:Qe}))}),await _e.close(),$(Ye=>({...Ye,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.readingFinished"),progress:100,originalFlash:ne,connected:!1}))}catch(Oe){$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToCommunicate")+` ${Oe}`,connected:!1,actionInProgress:!1,error:!0})),console.error(Oe),alert(Oe),await _e.close();return}const ze=`ESP32_${ve.replace(/:/g,"")}`,Ue=new Blob([ne],{type:"application/octet-stream"}),Ae=URL.createObjectURL(Ue);$(Oe=>({...Oe,downloadLink:Ae,showProgress:!1})),await U(ne,ze),console.log("Done")},U=async(ge,ne)=>{try{$(ze=>({...ze,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.uploading"),error:!1}));const ve=new FormData;ve.append(ne,new Blob([ge]),ne);const _e=await Mu.apiPostTeddyCloudFormDataRaw("/api/esp32/uploadFirmware",ve);if(_e.ok&&_e.status===200){const ze=await _e.text();$(Ue=>({...Ue,showDownload:!0,filename:ze,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.uploadSuccessful")+` ${ze}`+e("tonieboxes.esp32BoxFlashing.esp32flasher.readyToProceed"),proceed:!0,actionInProgress:!1}))}else $(ze=>({...ze,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.uploadFailed"),actionInProgress:!1,error:!0}))}catch(ve){console.error("There was an error when uploading!",ve),$(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.uploadFailed"),actionInProgress:!1,error:!0}))}},H=async()=>{if(_.wifi_ssid&&!_.wifi_pass||!_.wifi_ssid&&_.wifi_pass){$(ne=>({...ne,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiCredentialsIncomplete"),showStatus:!0,warningTextWifi:e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiCredentialsIncomplete"),error:!0}));return}$(ne=>({...ne,actionInProgress:!0})),$(ne=>({...ne,showProgress:!1,showFlash:!1,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.patchingFlashImage"),error:!1}));const ge=await Mu.apiGetTeddyCloudApiRaw(`/api/esp32/patchFirmware?filename=${_.filename}&hostname=${encodeURIComponent(_.hostname)}`+(_.wifi_ssid&&_.wifi_pass?`&wifi_ssid=${encodeURIComponent(_.wifi_ssid)}&wifi_pass=${encodeURIComponent(_.wifi_pass)}`:""));if($(ne=>({...ne,showProgress:!1,showFlash:!1,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.patchingFlashImage")})),ge.ok&&ge.status===200){const ne=await ge.arrayBuffer();$(ze=>({...ze,patchedFlash:ne,showFlash:!0,flashName:"patched"}));const ve=new Blob([ne],{type:"application/octet-stream"}),_e=URL.createObjectURL(ve);$(ze=>({...ze,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.patchingSuccessful",{size:(ne.byteLength/1024/1024).toFixed(0)}),downloadLinkPatched:_e})),He()}else $(ne=>({...ne,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.patchingFailed"),error:!0}));$(ne=>({...ne,actionInProgress:!1}))},K=async()=>{I(2);const ge=await F(e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingWriteFlash"));if(ge===null||_.connected)return;$(ve=>({...ve,actionInProgress:!0,error:!1})),$(ve=>({...ve,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingTo")+` ${ge.getInfo()}`,connected:!0}));let ne=null;try{const ve=new Sp(ge);ne=new cv({transport:ve,baudrate:D,romBaudrate:N})}catch(ve){$(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToConnect")+` ${ve}`,connected:!1,actionInProgress:!1,error:!0})),alert(ve),await ge.close();return}try{$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingToESP")})),await ne.main(),$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connected"),progress:0,showProgress:!0}));let ve=await ne.chip.readMac(ne);$(Re=>({...Re,chipMac:ve})),console.log("Chip MAC: "+ve);const _e=await ne.chip.getChipDescription(ne);$(Re=>({...Re,chipType:_e}));let ze=await ne.readFlashId();$(Re=>({...Re,flashId:""+ze,flashManuf:""+(ze&255),flashDevice:""+(ze>>8&255)}));let Ue=await ne.getFlashSize();if($(Re=>({...Re,flashSize:""+Ue})),Ue<0||Ue>16384){$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashSizeError"),connected:!1,actionInProgress:!1,error:!0})),await ge.close();return}$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.preparingFlash",{size:(_.patchedFlash.byteLength/1024/1024).toFixed(0)})}));let Ae=[];Ae.push({data:L(_.patchedFlash),address:0});let Oe={fileArray:Ae,flashSize:"keep",flashMode:"keep",flashFreq:"keep",eraseAll:!1,compress:!0,reportProgress:(Re,at,Ye)=>{const We=100*at/Ye;$(qe=>({...qe,progress:We}))}};$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.writingFlash",{size:(_.patchedFlash.byteLength/1024/1024).toFixed(0)})})),await ne.writeFlash(Oe),await ge.close(),$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.writingFinished"),connected:!1,actionInProgress:!1})),I(3)}catch(ve){$(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToCommunicate")+` ${ve}`,connected:!1,actionInProgress:!1,error:!0})),console.error(ve),alert(ve),await ge.close();return}},Y=async()=>{const ge=await F(e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingWriteFlash"));if(ge===null||_.connected)return;$(ve=>({...ve,actionInProgress:!0,error:!1})),$(ve=>({...ve,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingTo")+` ${ge.getInfo()}`,connected:!0}));let ne=null;try{const ve=new Sp(ge);ne=new cv({transport:ve,baudrate:D,romBaudrate:N})}catch(ve){$(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToConnect")+` ${ve}`,connected:!1,actionInProgress:!1,error:!0})),alert(ve),await ge.close();return}try{$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectingToESP")})),await ne.main(),$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.connected"),progress:0,showProgress:!0}));let ve=await ne.chip.readMac(ne);$(Re=>({...Re,chipMac:ve})),console.log("Chip MAC: "+ve);const _e=await ne.chip.getChipDescription(ne);$(Re=>({...Re,chipType:_e}));let ze=await ne.readFlashId();$(Re=>({...Re,flashId:""+ze,flashManuf:""+(ze&255),flashDevice:""+(ze>>8&255)}));let Ue=await ne.getFlashSize();if($(Re=>({...Re,flashSize:""+Ue})),Ue<0||Ue>16384){$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashSizeError"),connected:!1,actionInProgress:!1,error:!0})),await ge.close();return}$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.preparingFlash",{size:(_.patchedFlash.byteLength/1024/1024).toFixed(0)})}));let Ae=[];Ae.push({data:L(_.patchedFlash),address:0});let Oe={fileArray:Ae,flashSize:"keep",flashMode:"keep",flashFreq:"keep",eraseAll:!1,compress:!0,reportProgress:(Re,at,Ye)=>{const We=100*at/Ye;$(qe=>({...qe,progress:We}))}};$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.writingFlash",{size:(_.patchedFlash.byteLength/1024/1024).toFixed(0)})})),await ne.writeFlash(Oe),await ge.close(),$(Re=>({...Re,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.writingFinished"),connected:!1,actionInProgress:!1,proceed:!0}))}catch(ve){$(_e=>({..._e,state:e("tonieboxes.esp32BoxFlashing.esp32flasher.failedToCommunicate")+` ${ve}`,connected:!1,actionInProgress:!1,error:!0})),console.error(ve),alert(ve),await ge.close();return}},ee=async ge=>{const ne="extractStoreCerts";r(ne,e("tonieboxes.esp32BoxFlashing.processing"),e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificates")),ge&&S(!1);try{const ve=await Mu.apiPostTeddyCloudRaw(`/api/esp32/extractCerts?filename=${_.filename}`+(ge?"&overwrite=true":""));if(a(ne),ve.ok&&ve.status===200)n(dt.Success,e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesSuccessful"),e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesSuccessfulDetails",{file:_.filename}),e("tonieboxes.esp32BoxFlashing.title")),t(_e=>!_e);else if(!ve.ok&&ve.status===409){const _e=await ve.text();n(dt.Error,e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesFailed"),e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesFailedDetails",{file:_.filename})+": "+_e,e("tonieboxes.esp32BoxFlashing.title")),C(_e),S(!0)}else n(dt.Error,e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesFailed"),e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesFailedDetails",{file:_.filename})+": "+await ve.text(),e("tonieboxes.esp32BoxFlashing.title"))}catch(ve){n(dt.Error,e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesFailed"),e("tonieboxes.esp32BoxFlashing.esp32flasher.extractingCertificatesFailedDetails",{file:_.filename})+": "+ve,e("tonieboxes.esp32BoxFlashing.title"))}},ae=[{title:e("tonieboxes.esp32BoxFlashing.esp32flasher.titleReadESP32ImportFlash")},{title:e("tonieboxes.esp32BoxFlashing.esp32flasher.titlePatchFlash")},{title:e("tonieboxes.esp32BoxFlashing.esp32flasher.titleFlashESP32")},{title:e("tonieboxes.esp32BoxFlashing.esp32flasher.titleESP32FirmwareFlashed")}],W=f.jsx(f.Fragment,{children:_.showProgress&&f.jsx("div",{children:f.jsx("div",{children:f.jsx(Py,{percent:_.progress||0,format:ge=>`${(ge??0).toFixed(2)}%`})})})}),q=f.jsx(f.Fragment,{children:(_.chipType||_.chipMac)&&f.jsxs("div",{children:[f.jsx(Wn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.infoTable")}),f.jsx("table",{className:"info-table",children:f.jsxs("tbody",{children:[_.chipType&&f.jsxs("tr",{children:[f.jsx("td",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.chipType")}),f.jsx("td",{children:_.chipType})]}),_.chipMac&&f.jsxs("tr",{children:[f.jsx("td",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.chipMAC")}),f.jsx("td",{children:_.chipMac})]}),_.flashId&&f.jsxs("tr",{children:[f.jsx("td",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashId")}),f.jsxs("td",{children:["0x",_.flashId.toString()]})]}),_.flashManuf&&f.jsxs("tr",{children:[f.jsx("td",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashManuf")}),f.jsxs("td",{children:["0x",_.flashManuf.toString()]})]}),_.flashDevice&&f.jsxs("tr",{children:[f.jsx("td",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashDevice")}),f.jsxs("td",{children:["0x",_.flashDevice.toString()]})]}),_.flashSize&&f.jsxs("tr",{children:[f.jsx("td",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.flashSize")}),f.jsxs("td",{children:[_.flashSize," KiB"]})]})]})})]})}),Z=ge=>ge.replace(/[^a-zA-Z0-9-.]/g,"").trim(),Q=ge=>{if(ge.endsWith("...")){const ne=ge.slice(0,-3);return f.jsxs("div",{style:{display:"flex"},children:[ne,f.jsx(PVe,{})]})}return ge},J=_.showStatus&&f.jsx("div",{className:"status",style:{marginBottom:16,color:_.error?"#CC3010":"unset"},children:f.jsx("i",{children:Q(_.state)})}),ie=xZ(),le=f.jsxs(f.Fragment,{children:[f.jsx("h3",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.titleReadESP32ImportFlash")}),!_.actionInProgress&&f.jsxs(f.Fragment,{children:[f.jsx(Hn,{children:f.jsx(Sn,{type:"warning",closeIcon:!0,showIcon:!0,message:e("tonieboxes.hintLatestFirmwareTitle"),description:e("tonieboxes.hintLatestFirmware")})}),f.jsx(Hn,{children:f.jsx(Sn,{type:"info",closeIcon:!0,showIcon:!0,message:e("tonieboxes.esp32BoxFlashing.adaptBaudrateOnProblems"),description:e("tonieboxes.esp32BoxFlashing.adaptBaudrateOnProblemsText")})}),f.jsx(Hn,{style:{marginTop:16},children:f.jsx(Sn,{type:"info",description:e("tonieboxes.esp32BoxFlashing.esp32flasher.hintReadESP32ImportFlash")})}),f.jsx($s,{size:"small",style:{marginBottom:16},items:[{key:"1",label:e("tonieboxes.esp32BoxFlashing.esp32flasher.connectESPCollapseTitle"),children:ie}]})]}),J,f.jsx("input",{type:"file",style:{display:"none"},ref:s,onChange:B}),W]}),fe=f.jsxs(f.Fragment,{children:[f.jsx("h3",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.titlePatchFlash")}),f.jsxs("div",{children:[!_.actionInProgress&&f.jsx(Hn,{children:f.jsx(Sn,{type:"info",description:e("tonieboxes.esp32BoxFlashing.esp32flasher.hintPatchFlash")})}),J,!_.actionInProgress&&_.downloadLink?f.jsxs("div",{style:{marginBottom:16},children:[" ",f.jsx("a",{href:_.downloadLink,download:_.filename,title:_.filename,children:e("tonieboxes.esp32BoxFlashing.esp32flasher.downloadLink")})]}):"",f.jsxs(Gt,{children:[f.jsx(Wn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.hostnameSettings")}),f.jsx(Hn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.hintPatchHost")}),f.jsx(Gt.Item,{children:f.jsx(la,{align:"middle",style:{display:"flex",alignItems:"center"},children:f.jsx(Cn,{children:f.jsx(ts,{checked:_.flagPreviousHostname,onChange:ge=>{$(ne=>({...ne,flagPreviousHostname:ge.target.checked}))},children:e("tonieboxes.esp32BoxFlashing.esp32flasher.flagPreviousHostname")})})})}),_.flagPreviousHostname&&f.jsxs(Gt.Item,{children:[f.jsxs(la,{align:"middle",style:{display:"flex",alignItems:"center"},children:[f.jsx(Cn,{style:{flex:"0 0 200px"},children:f.jsx("label",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.previousHostname")})}),f.jsx(Cn,{style:{flex:"1 1 auto"},children:f.jsx(Jt,{type:"text",value:_.previousHostname,onChange:ge=>{let ne=Z(ge.target.value);$(ve=>({...ve,previousHostname:ne}))}})})]}),_.warningTextHostname&&f.jsx("p",{style:{color:"#CC3010"},children:e("tonieboxes.esp32BoxFlashing.esp32flasher.hostnameTooLong")})]}),f.jsxs(Gt.Item,{children:[f.jsxs(la,{align:"middle",style:{display:"flex",alignItems:"center"},children:[f.jsx(Cn,{style:{flex:"0 0 200px",color:_.warningTextHostname?"#CC3010":"unset"},children:f.jsx("label",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.hostname")})}),f.jsx(Cn,{style:{flex:"1 1 auto"},children:f.jsx(Jt,{type:"text",value:_.hostname,onChange:ge=>{let ne=Z(ge.target.value),ve="";ne.length>12?ve=e("tonieboxes.esp32BoxFlashing.esp32flasher.hostnameTooLong"):ve="",$(_e=>({..._e,hostname:ne,warningTextHostname:ve}))}})})]}),_.warningTextHostname&&f.jsx("p",{style:{color:"#CC3010"},children:e("tonieboxes.esp32BoxFlashing.esp32flasher.hostnameTooLong")})]}),f.jsx(Wn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiSettings")}),f.jsx(Hn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.hintPatchWifi")}),f.jsx(Gt.Item,{children:f.jsxs(la,{align:"middle",style:{display:"flex",alignItems:"center"},children:[f.jsx(Cn,{style:{flex:"0 0 200px",color:_.warningTextWifi?"#CC3010":"unset"},children:f.jsx("label",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiSSID")})}),f.jsx(Cn,{style:{flex:"1 1 auto"},children:f.jsx(Jt,{type:"text",defaultValue:_.wifi_ssid,onChange:ge=>{let ne=ge.target.value;$(ve=>({...ve,wifi_ssid:ne,warningTextWifi:ge.target.value&&_.wifi_pass||!ge.target.value&&!_.wifi_pass?"":e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiCredentialsIncomplete")}))}})})]})}),f.jsxs(Gt.Item,{children:[f.jsxs(la,{align:"middle",style:{display:"flex",alignItems:"center"},children:[f.jsx(Cn,{style:{flex:"0 0 200px",color:_.warningTextWifi?"#CC3010":"unset"},children:f.jsx("label",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiPassword")})}),f.jsx(Cn,{style:{flex:"1 1 auto"},children:f.jsx(Jt.Password,{defaultValue:_.wifi_pass,onChange:ge=>{let ne=ge.target.value;$(ve=>({...ve,wifi_pass:ne,warningTextWifi:ge.target.value&&_.wifi_ssid||!ge.target.value&&!_.wifi_ssid?"":e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiCredentialsIncomplete")}))}})})]}),_.warningTextWifi&&f.jsx("p",{style:{color:"#CC3010"},children:e("tonieboxes.esp32BoxFlashing.esp32flasher.wifiCredentialsIncomplete")})]})]})]}),W]}),te=f.jsxs(f.Fragment,{children:[f.jsx("h3",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.titleFlashESP32")}),!_.actionInProgress&&f.jsxs(Hn,{children:[" ",f.jsx(Sn,{type:"info",description:e("tonieboxes.esp32BoxFlashing.esp32flasher.hintFlashESP32")})]}),J,!_.actionInProgress&&_.downloadLinkPatched?f.jsxs("div",{style:{marginBottom:16},children:[" ",f.jsx("a",{href:_.downloadLinkPatched,download:"patched_"+_.filename,title:"patched_"+_.filename,children:e("tonieboxes.esp32BoxFlashing.esp32flasher.downloadLinkPatched")})]}):"",W]}),se=`${v}/${_.chipMac?_.chipMac.replaceAll(":","").toLowerCase():""}`,pe=f.jsxs(f.Fragment,{children:[f.jsx("h3",{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.titleESP32FirmwareFlashed")}),f.jsx(Hn,{children:f.jsx(Sn,{type:"success",description:e("tonieboxes.esp32BoxFlashing.esp32flasher.hintESP32FirmwareFlashed")})}),J,W,(_.downloadLink||_.downloadLinkPatched)&&f.jsxs(f.Fragment,{children:[f.jsx(Sn,{type:"info",style:{marginTop:16},showIcon:!0,message:e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificates"),description:f.jsxs("div",{children:[f.jsxs(xn,{children:[f.jsx(Wn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.automatically")}),f.jsx(Hn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificatesAutomaticallyHint")}),f.jsx(tt,{icon:f.jsx(BN,{}),disabled:g,type:"primary",onClick:()=>je(),style:{marginBottom:8},children:e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificates")}),f.jsx(Hn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificatesAutomaticallyHint2",{certDir:v,mac:_.chipMac.replaceAll(":","").toLocaleLowerCase()})})]}),f.jsx(Wn,{children:e("tonieboxes.esp32BoxFlashing.esp32flasher.manually")}),f.jsx(xn,{style:{marginBottom:8},children:e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificatesManuallyHint")}),f.jsx(xn,{children:f.jsx($s,{size:"small",items:[{key:"1",label:e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificatesManually"),children:f.jsxs(xn,{children:[f.jsxs(Hn,{children:[e("tonieboxes.esp32BoxFlashing.esp32flasher.extractCertificatesManuallyHintP1")," ",f.jsx(jVe,{code:!0,children:"docker exec -it bash"}),"."]}),f.jsx(Hn,{children:f.jsx("pre",{style:{fontSize:12},children:`# Please check the filename of your backup # Be sure you are in the TeddyCloud directory # cd /teddycloud/ # just for docker mkdir ${se} diff --git a/contrib/data/www/web/index.html b/contrib/data/www/web/index.html index 656add85..980d4709 100644 --- a/contrib/data/www/web/index.html +++ b/contrib/data/www/web/index.html @@ -12,7 +12,7 @@ --> TeddyCloud - + diff --git a/contrib/data/www/web/translations/de.json b/contrib/data/www/web/translations/de.json index f3afb535..32e046f0 100644 --- a/contrib/data/www/web/translations/de.json +++ b/contrib/data/www/web/translations/de.json @@ -971,7 +971,7 @@ "intro": "Die Installation des neuen Bootloaders ist in zwei Stufen unterteilt und unterscheidet sich je nachdem, ob es sich um eine Erstinstallation oder ein Update einer vorhandenen Installation handelt:", "title": "Vorwort" }, - "resetCommand": "Wenn dein UART-Programmer einen DTR-Pin hat, benutze `--reset dtr` vor jedem Befehl (z. B. `cc3200tool -p COM3 --reset dtr ...`). Andernfalls musst du den RTS-Pin kurz mit GND verbinden, bevor du jeden Befehl ausführst. Wenn du diesen Schritt auslässt, zeigt die Konsole \"timed out while waiting for ack\" an und bricht die Operation ab.", + "resetCommand": "Wenn dein UART-Programmer einen DTR-Pin hat, benutze `--reset dtr` vor jedem Befehl (z. B. `cc3200tool -p COM3 --reset dtr ...`). Andernfalls musst du den RST-Pin (Toniebox) kurz mit GND verbinden, bevor du jeden Befehl ausführst. Wenn du diesen Schritt auslässt, zeigt die Konsole \"timed out while waiting for ack\" an und bricht die Operation ab.", "stage1": "Stufe 1: Installation des Preloaders", "stage2": "Stufe 2: Installation des Bootloaders", "verifyBackup": "Stelle sicher, dass die backup.bin deutlich größer als 0 KB ist. Überprüfe, ob das Dump und die gesicherten Dateien alle wichtigen Toniebox-Dateien enthalten:" diff --git a/contrib/data/www/web/translations/en.json b/contrib/data/www/web/translations/en.json index 3cc3c333..15d9cb36 100644 --- a/contrib/data/www/web/translations/en.json +++ b/contrib/data/www/web/translations/en.json @@ -971,7 +971,7 @@ "intro": "Installing the new bootloader is split into two stages and differs whether it's a first install or and update to an existing installation: ", "title": "Preface" }, - "resetCommand": "If your UART programmer has a DTR pin, use `--reset dtr` before each command (e.g., `cc3200tool -p COM3 --reset dtr ...`). Otherwise, you'll need to briefly connect the RTS pin to GND before each command. If you skip this step, the console will display \"timed out while waiting for ack\" and abort the operation.", + "resetCommand": "If your UART programmer has a DTR pin, use `--reset dtr` before each command (e.g., `cc3200tool -p COM3 --reset dtr ...`). Otherwise, you'll need to briefly connect the RST Pin (Toniebox) to GND before each command. If you skip this step, the console will display \"timed out while waiting for ack\" and abort the operation.", "stage1": "Stage 1: Installing the Preloader", "stage2": "Stage 2: Installing the Bootloader", "verifyBackup": "Ensure the backup.bin is a way bigger than 0 kb. Please check if the dump and the dumped files contain all important Toniebox files:" diff --git a/contrib/data/www/web/translations/es.json b/contrib/data/www/web/translations/es.json index 2d705ac0..4cfa7b70 100644 --- a/contrib/data/www/web/translations/es.json +++ b/contrib/data/www/web/translations/es.json @@ -971,7 +971,7 @@ "intro": "La instalación del nuevo bootloader se divide en dos etapas y varía dependiendo de si es una instalación inicial o una actualización de una instalación existente:", "title": "Prefacio" }, - "resetCommand": "Si tu programador UART tiene un pin DTR, usa `--reset dtr` antes de cada comando (por ejemplo, `cc3200tool -p COM3 --reset dtr ...`). De lo contrario, tendrás que conectar brevemente el pin RTS a GND antes de cada comando. Si te saltas este paso, la consola mostrará \"timed out while waiting for ack\" y abortará la operación.", + "resetCommand": "Si tu programador UART tiene un pin DTR, usa `--reset dtr` antes de cada comando (por ejemplo, `cc3200tool -p COM3 --reset dtr ...`). De lo contrario, tendrás que conectar brevemente el pin RST (Toniebox) a GND antes de cada comando. Si te saltas este paso, la consola mostrará \"timed out while waiting for ack\" y abortará la operación.", "stage1": "Etapa 1: Instalación del Preloader", "stage2": "Etapa 2: Instalación del Bootloader", "verifyBackup": "Asegúrate de que backup.bin sea significativamente mayor que 0 KB. Verifica que el volcado y los archivos extraídos contengan todos los archivos importantes de Toniebox:" diff --git a/contrib/data/www/web/translations/fr.json b/contrib/data/www/web/translations/fr.json index 2894c970..a0d27640 100644 --- a/contrib/data/www/web/translations/fr.json +++ b/contrib/data/www/web/translations/fr.json @@ -971,7 +971,7 @@ "intro": "L'installation du nouveau bootloader est divisée en deux étapes et diffère selon qu'il s'agit d'une première installation ou d'une mise à jour d'une installation existante :", "title": "Préface" }, - "resetCommand": "Si ton programmeur UART a une broche DTR, utilise `--reset dtr` avant chaque commande (par exemple, `cc3200tool -p COM3 --reset dtr ...`). Sinon, tu devras brièvement connecter la broche RTS à GND avant chaque commande. Si tu sautes cette étape, la console affichera « timed out while waiting for ack » et l’opération sera annulée.", + "resetCommand": "Si ton programmeur UART a une broche DTR, utilise `--reset dtr` avant chaque commande (par exemple, `cc3200tool -p COM3 --reset dtr ...`). Sinon, tu devras brièvement connecter la broche RST (Toniebox) à GND avant chaque commande. Si tu sautes cette étape, la console affichera « timed out while waiting for ack » et l’opération sera annulée.", "stage1": "Étape 1 : Installation du Preloader", "stage2": "Étape 2 : Installation du Bootloader", "verifyBackup": "Assure-toi que le fichier backup.bin est bien plus grand que 0 KB. Vérifie que le dump et les fichiers extraits contiennent tous les fichiers importants de la Toniebox :" diff --git a/contrib/data/www/web/web_version.json b/contrib/data/www/web/web_version.json index 642c7d18..2b0a375c 100644 --- a/contrib/data/www/web/web_version.json +++ b/contrib/data/www/web/web_version.json @@ -2,9 +2,9 @@ "web_version": "vX.X.X", "web_gitDirty": "0", "web_gitTag": "undefined", - "web_gitDateTime": "2024-12-25 11:41:35 +0100", - "web_gitSha": "dfb0cc78e734259302f075ce8f0d38c4cf62f504", + "web_gitDateTime": "2025-01-06 09:28:23 +0100", + "web_gitSha": "514140d169f5e821299a452fa33dac155eef3a85", "web_gitTagPrefix": "undefined", - "web_gitShortSha": "dfb0cc7", + "web_gitShortSha": "514140d", "_eof":"" } diff --git a/teddycloud_web b/teddycloud_web index dfb0cc78..514140d1 160000 --- a/teddycloud_web +++ b/teddycloud_web @@ -1 +1 @@ -Subproject commit dfb0cc78e734259302f075ce8f0d38c4cf62f504 +Subproject commit 514140d169f5e821299a452fa33dac155eef3a85