hassio-conf/www/plugins/valetudo-map-card.js
2024-10-17 21:45:45 +02:00

3 lines
68 KiB
JavaScript

var t=function(){function t(t){this.id=t,this.adjacentVertexIds=new Set,this.color=void 0}return t.prototype.appendVertex=function(t){void 0!==t&&this.adjacentVertexIds.add(t)},t}(),e=function(){function t(t){var e=this;this.vertices=t,this.vertexLookup=new Map,this.vertices.forEach((function(t){e.vertexLookup.set(t.id,t)}))}return t.prototype.connectVertices=function(t,e){void 0!==t&&void 0!==e&&t!==e&&(this.vertexLookup.has(t)&&this.vertexLookup.get(t).appendVertex(e),this.vertexLookup.has(e)&&this.vertexLookup.get(e).appendVertex(t))},t.prototype.colorAllVertices=function(){var t=this;this.vertices.sort((function(t,e){return e.adjacentVertexIds.size-t.adjacentVertexIds.size})),this.vertices.forEach((function(e){if(e.adjacentVertexIds.size<=0)e.color=0;else{var i=t.getAdjacentVertices(e).filter((function(t){return void 0!==t.color})).map((function(t){return t.color}));e.color=t.lowestColor(i)}}))},t.prototype.getAdjacentVertices=function(t){var e=this;return Array.from(t.adjacentVertexIds).map((function(t){return e.getById(t)})).filter((function(t){return void 0!==t}))},t.prototype.getById=function(t){return this.vertices.find((function(e){return e.id===t}))},t.prototype.lowestColor=function(t){if(t.length<=0)return 0;for(var e=0;e<t.length+1;e++)if(!t.includes(e))return e},t}();function i(t,e,i){if(i||2===arguments.length)for(var a,n=0,o=e.length;n<o;n++)!a&&n in e||(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))}var a=function(){function a(t,e){var i=Math.floor(30/e);this.stepFunction=function(t){return t+i};var a=this.preprocessLayers(t);if(void 0!==a){var n=this.createPixelToSegmentMapping(a);this.areaGraph=this.buildGraph(n),this.areaGraph.colorAllVertices()}}return a.prototype.getColor=function(t){if(void 0===this.areaGraph)return 0;var e=this.areaGraph.getById(t);return e&&void 0!==e.color?e.color:0},a.prototype.preprocessLayers=function(t){var e=[],i={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},n=t.filter((function(t){return"segment"===t.type}));if(!(n.length<=0))return n.forEach((function(t){for(var n=[],o=0;o<t.pixels.length-1;o+=2){var s={x:t.pixels[o],y:t.pixels[o+1]};a.setBoundaries(i,s),n.push(s)}void 0!==t.metaData.segmentId&&e.push({segmentId:t.metaData.segmentId,name:t.metaData.name,pixels:n})})),{boundaries:i,segments:e}},a.setBoundaries=function(t,e){e.x<t.minX&&(t.minX=e.x),e.y<t.minY&&(t.minY=e.y),e.x>t.maxX&&(t.maxX=e.x),e.y>t.maxY&&(t.maxY=e.y)},a.prototype.createPixelToSegmentMapping=function(t){var e,a,n=(e=t.boundaries.maxX+1,a=t.boundaries.maxY+1,i([],new Array(e),!0).map((function(t){return i([],new Array(a),!0)}))),o=[];return t.segments.forEach((function(t){o.push(t.segmentId),t.pixels.forEach((function(e){n[e.x][e.y]=t.segmentId}))})),{map:n,segmentIds:o,boundaries:t.boundaries}},a.prototype.buildGraph=function(i){var a=i.segmentIds.map((function(e){return new t(e)})),n=new e(a);return this.traverseMap(i.boundaries,i.map,(function(t,e,i,a){var o=a[t][e];return n.connectVertices(i,o),void 0!==o?o:i})),n},a.prototype.traverseMap=function(t,e,i){for(var a=t.minY;a<=t.maxY;a=this.stepFunction(a))for(var n=void 0,o=t.minX;o<=t.maxX;o=this.stepFunction(o))n=i(o,a,n,e);for(o=t.minX;o<=t.maxX;o=this.stepFunction(o)){var s=void 0;for(a=t.minY;a<=t.maxY;a=this.stepFunction(a))s=i(o,a,s,e)}},a}();
/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */function n(t){let e=t.length;for(;--e>=0;)t[e]=0}const o=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]),s=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]),r=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),l=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),h=new Array(576);n(h);const d=new Array(60);n(d);const c=new Array(512);n(c);const _=new Array(256);n(_);const f=new Array(29);n(f);const u=new Array(30);function p(t,e,i,a,n){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=a,this.max_length=n,this.has_stree=t&&t.length}let g,m,w;function b(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}n(u);const y=t=>t<256?c[t]:c[256+(t>>>7)],v=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},x=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<<t.bi_valid&65535,v(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=i)},k=(t,e,i)=>{x(t,i[2*e],i[2*e+1])},E=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},C=(t,e,i)=>{const a=new Array(16);let n,o,s=0;for(n=1;n<=15;n++)a[n]=s=s+i[n-1]<<1;for(o=0;o<=e;o++){let e=t[2*o+1];0!==e&&(t[2*o]=E(a[e]++,e))}},A=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},z=t=>{t.bi_valid>8?v(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},S=(t,e,i,a)=>{const n=2*e,o=2*i;return t[n]<t[o]||t[n]===t[o]&&a[e]<=a[i]},R=(t,e,i)=>{const a=t.heap[i];let n=i<<1;for(;n<=t.heap_len&&(n<t.heap_len&&S(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!S(e,a,t.heap[n],t.depth));)t.heap[i]=t.heap[n],i=n,n<<=1;t.heap[i]=a},M=(t,e,i)=>{let a,n,r,l,h=0;if(0!==t.last_lit)do{a=t.pending_buf[t.d_buf+2*h]<<8|t.pending_buf[t.d_buf+2*h+1],n=t.pending_buf[t.l_buf+h],h++,0===a?k(t,n,e):(r=_[n],k(t,r+256+1,e),l=o[r],0!==l&&(n-=f[r],x(t,n,l)),a--,r=y(a),k(t,r,i),l=s[r],0!==l&&(a-=u[r],x(t,a,l)))}while(h<t.last_lit);k(t,256,e)},I=(t,e)=>{const i=e.dyn_tree,a=e.stat_desc.static_tree,n=e.stat_desc.has_stree,o=e.stat_desc.elems;let s,r,l,h=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<o;s++)0!==i[2*s]?(t.heap[++t.heap_len]=h=s,t.depth[s]=0):i[2*s+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=h<2?++h:0,i[2*l]=1,t.depth[l]=0,t.opt_len--,n&&(t.static_len-=a[2*l+1]);for(e.max_code=h,s=t.heap_len>>1;s>=1;s--)R(t,i,s);l=o;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],R(t,i,1),r=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=r,i[2*l]=i[2*s]+i[2*r],t.depth[l]=(t.depth[s]>=t.depth[r]?t.depth[s]:t.depth[r])+1,i[2*s+1]=i[2*r+1]=l,t.heap[1]=l++,R(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,a=e.max_code,n=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,r=e.stat_desc.extra_base,l=e.stat_desc.max_length;let h,d,c,_,f,u,p=0;for(_=0;_<=15;_++)t.bl_count[_]=0;for(i[2*t.heap[t.heap_max]+1]=0,h=t.heap_max+1;h<573;h++)d=t.heap[h],_=i[2*i[2*d+1]+1]+1,_>l&&(_=l,p++),i[2*d+1]=_,d>a||(t.bl_count[_]++,f=0,d>=r&&(f=s[d-r]),u=i[2*d],t.opt_len+=u*(_+f),o&&(t.static_len+=u*(n[2*d+1]+f)));if(0!==p){do{for(_=l-1;0===t.bl_count[_];)_--;t.bl_count[_]--,t.bl_count[_+1]+=2,t.bl_count[l]--,p-=2}while(p>0);for(_=l;0!==_;_--)for(d=t.bl_count[_];0!==d;)c=t.heap[--h],c>a||(i[2*c+1]!==_&&(t.opt_len+=(_-i[2*c+1])*i[2*c],i[2*c+1]=_),d--)}})(t,e),C(i,h,t.bl_count)},D=(t,e,i)=>{let a,n,o=-1,s=e[1],r=0,l=7,h=4;for(0===s&&(l=138,h=3),e[2*(i+1)+1]=65535,a=0;a<=i;a++)n=s,s=e[2*(a+1)+1],++r<l&&n===s||(r<h?t.bl_tree[2*n]+=r:0!==n?(n!==o&&t.bl_tree[2*n]++,t.bl_tree[32]++):r<=10?t.bl_tree[34]++:t.bl_tree[36]++,r=0,o=n,0===s?(l=138,h=3):n===s?(l=6,h=3):(l=7,h=4))},U=(t,e,i)=>{let a,n,o=-1,s=e[1],r=0,l=7,h=4;for(0===s&&(l=138,h=3),a=0;a<=i;a++)if(n=s,s=e[2*(a+1)+1],!(++r<l&&n===s)){if(r<h)do{k(t,n,t.bl_tree)}while(0!=--r);else 0!==n?(n!==o&&(k(t,n,t.bl_tree),r--),k(t,16,t.bl_tree),x(t,r-3,2)):r<=10?(k(t,17,t.bl_tree),x(t,r-3,3)):(k(t,18,t.bl_tree),x(t,r-11,7));r=0,o=n,0===s?(l=138,h=3):n===s?(l=6,h=3):(l=7,h=4)}};let B=!1;const T=(t,e,i,a)=>{x(t,0+(a?1:0),3),((t,e,i,a)=>{z(t),a&&(v(t,i),v(t,~i)),t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i})(t,e,i,!0)};var Z=(t,e,i,a)=>{let n,o,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),I(t,t.l_desc),I(t,t.d_desc),s=(t=>{let e;for(D(t,t.dyn_ltree,t.l_desc.max_code),D(t,t.dyn_dtree,t.d_desc.max_code),I(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*l[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),n=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=n&&(n=o)):n=o=i+5,i+4<=n&&-1!==e?T(t,e,i,a):4===t.strategy||o===n?(x(t,2+(a?1:0),3),M(t,h,d)):(x(t,4+(a?1:0),3),((t,e,i,a)=>{let n;for(x(t,e-257,5),x(t,i-1,5),x(t,a-4,4),n=0;n<a;n++)x(t,t.bl_tree[2*l[n]+1],3);U(t,t.dyn_ltree,e-1),U(t,t.dyn_dtree,i-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),M(t,t.dyn_ltree,t.dyn_dtree)),A(t),a&&z(t)},L={_tr_init:t=>{B||((()=>{let t,e,i,a,n;const l=new Array(16);for(i=0,a=0;a<28;a++)for(f[a]=i,t=0;t<1<<o[a];t++)_[i++]=a;for(_[i-1]=a,n=0,a=0;a<16;a++)for(u[a]=n,t=0;t<1<<s[a];t++)c[n++]=a;for(n>>=7;a<30;a++)for(u[a]=n<<7,t=0;t<1<<s[a]-7;t++)c[256+n++]=a;for(e=0;e<=15;e++)l[e]=0;for(t=0;t<=143;)h[2*t+1]=8,t++,l[8]++;for(;t<=255;)h[2*t+1]=9,t++,l[9]++;for(;t<=279;)h[2*t+1]=7,t++,l[7]++;for(;t<=287;)h[2*t+1]=8,t++,l[8]++;for(C(h,287,l),t=0;t<30;t++)d[2*t+1]=5,d[2*t]=E(t,5);g=new p(h,o,257,286,15),m=new p(d,s,0,30,15),w=new p(new Array(0),r,0,19,7)})(),B=!0),t.l_desc=new b(t.dyn_ltree,g),t.d_desc=new b(t.dyn_dtree,m),t.bl_desc=new b(t.bl_tree,w),t.bi_buf=0,t.bi_valid=0,A(t)},_tr_stored_block:T,_tr_flush_block:Z,_tr_tally:(t,e,i)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(_[i]+256+1)]++,t.dyn_dtree[2*y(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{x(t,2,3),k(t,256,h),(t=>{16===t.bi_valid?(v(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var O=(t,e,i,a)=>{let n=65535&t|0,o=t>>>16&65535|0,s=0;for(;0!==i;){s=i>2e3?2e3:i,i-=s;do{n=n+e[a++]|0,o=o+n|0}while(--s);n%=65521,o%=65521}return n|o<<16|0};const F=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var a=0;a<8;a++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var N=(t,e,i,a)=>{const n=F,o=a+i;t^=-1;for(let i=a;i<o;i++)t=t>>>8^n[255&(t^e[i])];return-1^t},P={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"},V={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:W,_tr_stored_block:H,_tr_flush_block:Y,_tr_tally:j,_tr_align:X}=L,{Z_NO_FLUSH:$,Z_PARTIAL_FLUSH:G,Z_FULL_FLUSH:K,Z_FINISH:J,Z_BLOCK:q,Z_OK:Q,Z_STREAM_END:tt,Z_STREAM_ERROR:et,Z_DATA_ERROR:it,Z_BUF_ERROR:at,Z_DEFAULT_COMPRESSION:nt,Z_FILTERED:ot,Z_HUFFMAN_ONLY:st,Z_RLE:rt,Z_FIXED:lt,Z_DEFAULT_STRATEGY:ht,Z_UNKNOWN:dt,Z_DEFLATED:ct}=V,_t=(t,e)=>(t.msg=P[e],e),ft=t=>(t<<1)-(t>4?9:0),ut=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let pt=(t,e,i)=>(e<<t.hash_shift^i)&t.hash_mask;const gt=t=>{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},mt=(t,e)=>{Y(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,gt(t.strm)},wt=(t,e)=>{t.pending_buf[t.pending++]=e},bt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},yt=(t,e,i,a)=>{let n=t.avail_in;return n>a&&(n=a),0===n?0:(t.avail_in-=n,e.set(t.input.subarray(t.next_in,t.next_in+n),i),1===t.state.wrap?t.adler=O(t.adler,e,n,i):2===t.state.wrap&&(t.adler=N(t.adler,e,n,i)),t.next_in+=n,t.total_in+=n,n)},vt=(t,e)=>{let i,a,n=t.max_chain_length,o=t.strstart,s=t.prev_length,r=t.nice_match;const l=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,h=t.window,d=t.w_mask,c=t.prev,_=t.strstart+258;let f=h[o+s-1],u=h[o+s];t.prev_length>=t.good_match&&(n>>=2),r>t.lookahead&&(r=t.lookahead);do{if(i=e,h[i+s]===u&&h[i+s-1]===f&&h[i]===h[o]&&h[++i]===h[o+1]){o+=2,i++;do{}while(h[++o]===h[++i]&&h[++o]===h[++i]&&h[++o]===h[++i]&&h[++o]===h[++i]&&h[++o]===h[++i]&&h[++o]===h[++i]&&h[++o]===h[++i]&&h[++o]===h[++i]&&o<_);if(a=258-(_-o),o=_-258,a>s){if(t.match_start=e,s=a,a>=r)break;f=h[o+s-1],u=h[o+s]}}}while((e=c[e&d])>l&&0!=--n);return s<=t.lookahead?s:t.lookahead},xt=t=>{const e=t.w_size;let i,a,n,o,s;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,a=t.hash_size,i=a;do{n=t.head[--i],t.head[i]=n>=e?n-e:0}while(--a);a=e,i=a;do{n=t.prev[--i],t.prev[i]=n>=e?n-e:0}while(--a);o+=e}if(0===t.strm.avail_in)break;if(a=yt(t.strm,t.window,t.strstart+t.lookahead,o),t.lookahead+=a,t.lookahead+t.insert>=3)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=pt(t,t.ins_h,t.window[s+1]);t.insert&&(t.ins_h=pt(t,t.ins_h,t.window[s+3-1]),t.prev[s&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=s,s++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},kt=(t,e)=>{let i,a;for(;;){if(t.lookahead<262){if(xt(t),t.lookahead<262&&e===$)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-262&&(t.match_length=vt(t,i)),t.match_length>=3)if(a=j(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=pt(t,t.ins_h,t.window[t.strstart+1]);else a=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(a&&(mt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===J?(mt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(mt(t,!1),0===t.strm.avail_out)?1:2},Et=(t,e)=>{let i,a,n;for(;;){if(t.lookahead<262){if(xt(t),t.lookahead<262&&e===$)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length<t.max_lazy_match&&t.strstart-i<=t.w_size-262&&(t.match_length=vt(t,i),t.match_length<=5&&(t.strategy===ot||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,a=j(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,a&&(mt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(a=j(t,0,t.window[t.strstart-1]),a&&mt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(a=j(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===J?(mt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(mt(t,!1),0===t.strm.avail_out)?1:2};function Ct(t,e,i,a,n){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=a,this.func=n}const At=[new Ct(0,0,0,0,((t,e)=>{let i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(xt(t),0===t.lookahead&&e===$)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const a=t.block_start+i;if((0===t.strstart||t.strstart>=a)&&(t.lookahead=t.strstart-a,t.strstart=a,mt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-262&&(mt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===J?(mt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(mt(t,!1),t.strm.avail_out),1)})),new Ct(4,4,8,4,kt),new Ct(4,5,16,8,kt),new Ct(4,6,32,32,kt),new Ct(4,4,16,16,Et),new Ct(8,16,32,32,Et),new Ct(8,16,128,128,Et),new Ct(8,32,128,256,Et),new Ct(32,128,258,1024,Et),new Ct(32,258,258,4096,Et)];function zt(){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=ct,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(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ut(this.dyn_ltree),ut(this.dyn_dtree),ut(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ut(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ut(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const St=t=>{if(!t||!t.state)return _t(t,et);t.total_in=t.total_out=0,t.data_type=dt;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=$,W(e),Q},Rt=t=>{const e=St(t);var i;return e===Q&&((i=t.state).window_size=2*i.w_size,ut(i.head),i.max_lazy_match=At[i.level].max_lazy,i.good_match=At[i.level].good_length,i.nice_match=At[i.level].nice_length,i.max_chain_length=At[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e},Mt=(t,e,i,a,n,o)=>{if(!t)return et;let s=1;if(e===nt&&(e=6),a<0?(s=0,a=-a):a>15&&(s=2,a-=16),n<1||n>9||i!==ct||a<8||a>15||e<0||e>9||o<0||o>lt)return _t(t,et);8===a&&(a=9);const r=new zt;return t.state=r,r.strm=t,r.wrap=s,r.gzhead=null,r.w_bits=a,r.w_size=1<<r.w_bits,r.w_mask=r.w_size-1,r.hash_bits=n+7,r.hash_size=1<<r.hash_bits,r.hash_mask=r.hash_size-1,r.hash_shift=~~((r.hash_bits+3-1)/3),r.window=new Uint8Array(2*r.w_size),r.head=new Uint16Array(r.hash_size),r.prev=new Uint16Array(r.w_size),r.lit_bufsize=1<<n+6,r.pending_buf_size=4*r.lit_bufsize,r.pending_buf=new Uint8Array(r.pending_buf_size),r.d_buf=1*r.lit_bufsize,r.l_buf=3*r.lit_bufsize,r.level=e,r.strategy=o,r.method=i,Rt(t)};var It={deflateInit:(t,e)=>Mt(t,e,ct,15,8,ht),deflateInit2:Mt,deflateReset:Rt,deflateResetKeep:St,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?et:(t.state.gzhead=e,Q):et,deflate:(t,e)=>{let i,a;if(!t||!t.state||e>q||e<0)return t?_t(t,et):et;const n=t.state;if(!t.output||!t.input&&0!==t.avail_in||666===n.status&&e!==J)return _t(t,0===t.avail_out?at:et);n.strm=t;const o=n.last_flush;if(n.last_flush=e,42===n.status)if(2===n.wrap)t.adler=0,wt(n,31),wt(n,139),wt(n,8),n.gzhead?(wt(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)),wt(n,255&n.gzhead.time),wt(n,n.gzhead.time>>8&255),wt(n,n.gzhead.time>>16&255),wt(n,n.gzhead.time>>24&255),wt(n,9===n.level?2:n.strategy>=st||n.level<2?4:0),wt(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(wt(n,255&n.gzhead.extra.length),wt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=N(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(wt(n,0),wt(n,0),wt(n,0),wt(n,0),wt(n,0),wt(n,9===n.level?2:n.strategy>=st||n.level<2?4:0),wt(n,3),n.status=113);else{let e=ct+(n.w_bits-8<<4)<<8,i=-1;i=n.strategy>=st||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=i<<6,0!==n.strstart&&(e|=32),e+=31-e%31,n.status=113,bt(n,e),0!==n.strstart&&(bt(n,t.adler>>>16),bt(n,65535&t.adler)),t.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(t.adler=N(t.adler,n.pending_buf,n.pending-i,i)),gt(t),i=n.pending,n.pending!==n.pending_buf_size));)wt(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(t.adler=N(t.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(t.adler=N(t.adler,n.pending_buf,n.pending-i,i)),gt(t),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}a=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,wt(n,a)}while(0!==a);n.gzhead.hcrc&&n.pending>i&&(t.adler=N(t.adler,n.pending_buf,n.pending-i,i)),0===a&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(t.adler=N(t.adler,n.pending_buf,n.pending-i,i)),gt(t),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}a=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,wt(n,a)}while(0!==a);n.gzhead.hcrc&&n.pending>i&&(t.adler=N(t.adler,n.pending_buf,n.pending-i,i)),0===a&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&gt(t),n.pending+2<=n.pending_buf_size&&(wt(n,255&t.adler),wt(n,t.adler>>8&255),t.adler=0,n.status=113)):n.status=113),0!==n.pending){if(gt(t),0===t.avail_out)return n.last_flush=-1,Q}else if(0===t.avail_in&&ft(e)<=ft(o)&&e!==J)return _t(t,at);if(666===n.status&&0!==t.avail_in)return _t(t,at);if(0!==t.avail_in||0!==n.lookahead||e!==$&&666!==n.status){let i=n.strategy===st?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(xt(t),0===t.lookahead)){if(e===$)return 1;break}if(t.match_length=0,i=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(mt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===J?(mt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(mt(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===rt?((t,e)=>{let i,a,n,o;const s=t.window;for(;;){if(t.lookahead<=258){if(xt(t),t.lookahead<=258&&e===$)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=t.strstart-1,a=s[n],a===s[++n]&&a===s[++n]&&a===s[++n])){o=t.strstart+258;do{}while(a===s[++n]&&a===s[++n]&&a===s[++n]&&a===s[++n]&&a===s[++n]&&a===s[++n]&&a===s[++n]&&a===s[++n]&&n<o);t.match_length=258-(o-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=j(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(mt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===J?(mt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(mt(t,!1),0===t.strm.avail_out)?1:2})(n,e):At[n.level].func(n,e);if(3!==i&&4!==i||(n.status=666),1===i||3===i)return 0===t.avail_out&&(n.last_flush=-1),Q;if(2===i&&(e===G?X(n):e!==q&&(H(n,0,0,!1),e===K&&(ut(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),gt(t),0===t.avail_out))return n.last_flush=-1,Q}return e!==J?Q:n.wrap<=0?tt:(2===n.wrap?(wt(n,255&t.adler),wt(n,t.adler>>8&255),wt(n,t.adler>>16&255),wt(n,t.adler>>24&255),wt(n,255&t.total_in),wt(n,t.total_in>>8&255),wt(n,t.total_in>>16&255),wt(n,t.total_in>>24&255)):(bt(n,t.adler>>>16),bt(n,65535&t.adler)),gt(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Q:tt)},deflateEnd:t=>{if(!t||!t.state)return et;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&103!==e&&113!==e&&666!==e?_t(t,et):(t.state=null,113===e?_t(t,it):Q)},deflateSetDictionary:(t,e)=>{let i=e.length;if(!t||!t.state)return et;const a=t.state,n=a.wrap;if(2===n||1===n&&42!==a.status||a.lookahead)return et;if(1===n&&(t.adler=O(t.adler,e,i,0)),a.wrap=0,i>=a.w_size){0===n&&(ut(a.head),a.strstart=0,a.block_start=0,a.insert=0);let t=new Uint8Array(a.w_size);t.set(e.subarray(i-a.w_size,i),0),e=t,i=a.w_size}const o=t.avail_in,s=t.next_in,r=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,xt(a);a.lookahead>=3;){let t=a.strstart,e=a.lookahead-2;do{a.ins_h=pt(a,a.ins_h,a.window[t+3-1]),a.prev[t&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=t,t++}while(--e);a.strstart=t,a.lookahead=2,xt(a)}return a.strstart+=a.lookahead,a.block_start=a.strstart,a.insert=a.lookahead,a.lookahead=0,a.match_length=a.prev_length=2,a.match_available=0,t.next_in=s,t.input=r,t.avail_in=o,a.wrap=n,Q},deflateInfo:"pako deflate (from Nodeca project)"};const Dt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ut=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)Dt(i,e)&&(t[e]=i[e])}}return t},Bt=t=>{let e=0;for(let i=0,a=t.length;i<a;i++)e+=t[i].length;const i=new Uint8Array(e);for(let e=0,a=0,n=t.length;e<n;e++){let n=t[e];i.set(n,a),a+=n.length}return i};let Tt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Tt=!1}const Zt=new Uint8Array(256);for(let t=0;t<256;t++)Zt[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Zt[254]=Zt[254]=1;var Lt=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,i,a,n,o,s=t.length,r=0;for(n=0;n<s;n++)i=t.charCodeAt(n),55296==(64512&i)&&n+1<s&&(a=t.charCodeAt(n+1),56320==(64512&a)&&(i=65536+(i-55296<<10)+(a-56320),n++)),r+=i<128?1:i<2048?2:i<65536?3:4;for(e=new Uint8Array(r),o=0,n=0;o<r;n++)i=t.charCodeAt(n),55296==(64512&i)&&n+1<s&&(a=t.charCodeAt(n+1),56320==(64512&a)&&(i=65536+(i-55296<<10)+(a-56320),n++)),i<128?e[o++]=i:i<2048?(e[o++]=192|i>>>6,e[o++]=128|63&i):i<65536?(e[o++]=224|i>>>12,e[o++]=128|i>>>6&63,e[o++]=128|63&i):(e[o++]=240|i>>>18,e[o++]=128|i>>>12&63,e[o++]=128|i>>>6&63,e[o++]=128|63&i);return e},Ot=(t,e)=>{const i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let a,n;const o=new Array(2*i);for(n=0,a=0;a<i;){let e=t[a++];if(e<128){o[n++]=e;continue}let s=Zt[e];if(s>4)o[n++]=65533,a+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&a<i;)e=e<<6|63&t[a++],s--;s>1?o[n++]=65533:e<65536?o[n++]=e:(e-=65536,o[n++]=55296|e>>10&1023,o[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Tt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let a=0;a<e;a++)i+=String.fromCharCode(t[a]);return i})(o,n)},Ft=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Zt[t[i]]>e?i:e};var Nt=function(){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};const Pt=Object.prototype.toString,{Z_NO_FLUSH:Vt,Z_SYNC_FLUSH:Wt,Z_FULL_FLUSH:Ht,Z_FINISH:Yt,Z_OK:jt,Z_STREAM_END:Xt,Z_DEFAULT_COMPRESSION:$t,Z_DEFAULT_STRATEGY:Gt,Z_DEFLATED:Kt}=V;function Jt(t){this.options=Ut({level:$t,method:Kt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Gt},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nt,this.strm.avail_out=0;let i=It.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==jt)throw new Error(P[i]);if(e.header&&It.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Lt(e.dictionary):"[object ArrayBuffer]"===Pt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=It.deflateSetDictionary(this.strm,t),i!==jt)throw new Error(P[i]);this._dict_set=!0}}Jt.prototype.push=function(t,e){const i=this.strm,a=this.options.chunkSize;let n,o;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Yt:Vt,"string"==typeof t?i.input=Lt(t):"[object ArrayBuffer]"===Pt.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),(o===Wt||o===Ht)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(n=It.deflate(i,o),n===Xt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),n=It.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===jt;if(0!==i.avail_out){if(o>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Jt.prototype.onData=function(t){this.chunks.push(t)},Jt.prototype.onEnd=function(t){t===jt&&(this.result=Bt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var qt=function(t,e){let i,a,n,o,s,r,l,h,d,c,_,f,u,p,g,m,w,b,y,v,x,k,E,C;const A=t.state;i=t.next_in,E=t.input,a=i+(t.avail_in-5),n=t.next_out,C=t.output,o=n-(e-t.avail_out),s=n+(t.avail_out-257),r=A.dmax,l=A.wsize,h=A.whave,d=A.wnext,c=A.window,_=A.hold,f=A.bits,u=A.lencode,p=A.distcode,g=(1<<A.lenbits)-1,m=(1<<A.distbits)-1;t:do{f<15&&(_+=E[i++]<<f,f+=8,_+=E[i++]<<f,f+=8),w=u[_&g];e:for(;;){if(b=w>>>24,_>>>=b,f-=b,b=w>>>16&255,0===b)C[n++]=65535&w;else{if(!(16&b)){if(0==(64&b)){w=u[(65535&w)+(_&(1<<b)-1)];continue e}if(32&b){A.mode=12;break t}t.msg="invalid literal/length code",A.mode=30;break t}y=65535&w,b&=15,b&&(f<b&&(_+=E[i++]<<f,f+=8),y+=_&(1<<b)-1,_>>>=b,f-=b),f<15&&(_+=E[i++]<<f,f+=8,_+=E[i++]<<f,f+=8),w=p[_&m];i:for(;;){if(b=w>>>24,_>>>=b,f-=b,b=w>>>16&255,!(16&b)){if(0==(64&b)){w=p[(65535&w)+(_&(1<<b)-1)];continue i}t.msg="invalid distance code",A.mode=30;break t}if(v=65535&w,b&=15,f<b&&(_+=E[i++]<<f,f+=8,f<b&&(_+=E[i++]<<f,f+=8)),v+=_&(1<<b)-1,v>r){t.msg="invalid distance too far back",A.mode=30;break t}if(_>>>=b,f-=b,b=n-o,v>b){if(b=v-b,b>h&&A.sane){t.msg="invalid distance too far back",A.mode=30;break t}if(x=0,k=c,0===d){if(x+=l-b,b<y){y-=b;do{C[n++]=c[x++]}while(--b);x=n-v,k=C}}else if(d<b){if(x+=l+d-b,b-=d,b<y){y-=b;do{C[n++]=c[x++]}while(--b);if(x=0,d<y){b=d,y-=b;do{C[n++]=c[x++]}while(--b);x=n-v,k=C}}}else if(x+=d-b,b<y){y-=b;do{C[n++]=c[x++]}while(--b);x=n-v,k=C}for(;y>2;)C[n++]=k[x++],C[n++]=k[x++],C[n++]=k[x++],y-=3;y&&(C[n++]=k[x++],y>1&&(C[n++]=k[x++]))}else{x=n-v;do{C[n++]=C[x++],C[n++]=C[x++],C[n++]=C[x++],y-=3}while(y>2);y&&(C[n++]=C[x++],y>1&&(C[n++]=C[x++]))}break}}break}}while(i<a&&n<s);y=f>>3,i-=y,f-=y<<3,_&=(1<<f)-1,t.next_in=i,t.next_out=n,t.avail_in=i<a?a-i+5:5-(i-a),t.avail_out=n<s?s-n+257:257-(n-s),A.hold=_,A.bits=f};const Qt=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),te=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),ee=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ie=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ae=(t,e,i,a,n,o,s,r)=>{const l=r.bits;let h,d,c,_,f,u,p=0,g=0,m=0,w=0,b=0,y=0,v=0,x=0,k=0,E=0,C=null,A=0;const z=new Uint16Array(16),S=new Uint16Array(16);let R,M,I,D=null,U=0;for(p=0;p<=15;p++)z[p]=0;for(g=0;g<a;g++)z[e[i+g]]++;for(b=l,w=15;w>=1&&0===z[w];w--);if(b>w&&(b=w),0===w)return n[o++]=20971520,n[o++]=20971520,r.bits=1,0;for(m=1;m<w&&0===z[m];m++);for(b<m&&(b=m),x=1,p=1;p<=15;p++)if(x<<=1,x-=z[p],x<0)return-1;if(x>0&&(0===t||1!==w))return-1;for(S[1]=0,p=1;p<15;p++)S[p+1]=S[p]+z[p];for(g=0;g<a;g++)0!==e[i+g]&&(s[S[e[i+g]]++]=g);if(0===t?(C=D=s,u=19):1===t?(C=Qt,A-=257,D=te,U-=257,u=256):(C=ee,D=ie,u=-1),E=0,g=0,p=m,f=o,y=b,v=0,c=-1,k=1<<b,_=k-1,1===t&&k>852||2===t&&k>592)return 1;for(;;){R=p-v,s[g]<u?(M=0,I=s[g]):s[g]>u?(M=D[U+s[g]],I=C[A+s[g]]):(M=96,I=0),h=1<<p-v,d=1<<y,m=d;do{d-=h,n[f+(E>>v)+d]=R<<24|M<<16|I|0}while(0!==d);for(h=1<<p-1;E&h;)h>>=1;if(0!==h?(E&=h-1,E+=h):E=0,g++,0==--z[p]){if(p===w)break;p=e[i+s[g]]}if(p>b&&(E&_)!==c){for(0===v&&(v=b),f+=m,y=p-v,x=1<<y;y+v<w&&(x-=z[y+v],!(x<=0));)y++,x<<=1;if(k+=1<<y,1===t&&k>852||2===t&&k>592)return 1;c=E&_,n[c]=b<<24|y<<16|f-o|0}}return 0!==E&&(n[f+E]=p-v<<24|64<<16|0),r.bits=b,0};const{Z_FINISH:ne,Z_BLOCK:oe,Z_TREES:se,Z_OK:re,Z_STREAM_END:le,Z_NEED_DICT:he,Z_STREAM_ERROR:de,Z_DATA_ERROR:ce,Z_MEM_ERROR:_e,Z_BUF_ERROR:fe,Z_DEFLATED:ue}=V,pe=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ge(){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 me=t=>{if(!t||!t.state)return de;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,re},we=t=>{if(!t||!t.state)return de;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,me(t)},be=(t,e)=>{let i;if(!t||!t.state)return de;const a=t.state;return e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?de:(null!==a.window&&a.wbits!==e&&(a.window=null),a.wrap=i,a.wbits=e,we(t))},ye=(t,e)=>{if(!t)return de;const i=new ge;t.state=i,i.window=null;const a=be(t,e);return a!==re&&(t.state=null),a};let ve,xe,ke=!0;const Ee=t=>{if(ke){ve=new Int32Array(512),xe=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ae(1,t.lens,0,288,ve,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ae(2,t.lens,0,32,xe,0,t.work,{bits:5}),ke=!1}t.lencode=ve,t.lenbits=9,t.distcode=xe,t.distbits=5},Ce=(t,e,i,a)=>{let n;const o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),a>=o.wsize?(o.window.set(e.subarray(i-o.wsize,i),0),o.wnext=0,o.whave=o.wsize):(n=o.wsize-o.wnext,n>a&&(n=a),o.window.set(e.subarray(i-a,i-a+n),o.wnext),(a-=n)?(o.window.set(e.subarray(i-a,i),0),o.wnext=a,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=n))),0};var Ae={inflateReset:we,inflateReset2:be,inflateResetKeep:me,inflateInit:t=>ye(t,15),inflateInit2:ye,inflate:(t,e)=>{let i,a,n,o,s,r,l,h,d,c,_,f,u,p,g,m,w,b,y,v,x,k,E=0;const C=new Uint8Array(4);let A,z;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return de;i=t.state,12===i.mode&&(i.mode=13),s=t.next_out,n=t.output,l=t.avail_out,o=t.next_in,a=t.input,r=t.avail_in,h=i.hold,d=i.bits,c=r,_=l,k=re;t:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;d<16;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}if(2&i.wrap&&35615===h){i.check=0,C[0]=255&h,C[1]=h>>>8&255,i.check=N(i.check,C,2,0),h=0,d=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",i.mode=30;break}if((15&h)!==ue){t.msg="unknown compression method",i.mode=30;break}if(h>>>=4,d-=4,x=8+(15&h),0===i.wbits)i.wbits=x;else if(x>i.wbits){t.msg="invalid window size",i.mode=30;break}i.dmax=1<<i.wbits,t.adler=i.check=1,i.mode=512&h?10:12,h=0,d=0;break;case 2:for(;d<16;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}if(i.flags=h,(255&i.flags)!==ue){t.msg="unknown compression method",i.mode=30;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=30;break}i.head&&(i.head.text=h>>8&1),512&i.flags&&(C[0]=255&h,C[1]=h>>>8&255,i.check=N(i.check,C,2,0)),h=0,d=0,i.mode=3;case 3:for(;d<32;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}i.head&&(i.head.time=h),512&i.flags&&(C[0]=255&h,C[1]=h>>>8&255,C[2]=h>>>16&255,C[3]=h>>>24&255,i.check=N(i.check,C,4,0)),h=0,d=0,i.mode=4;case 4:for(;d<16;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}i.head&&(i.head.xflags=255&h,i.head.os=h>>8),512&i.flags&&(C[0]=255&h,C[1]=h>>>8&255,i.check=N(i.check,C,2,0)),h=0,d=0,i.mode=5;case 5:if(1024&i.flags){for(;d<16;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}i.length=h,i.head&&(i.head.extra_len=h),512&i.flags&&(C[0]=255&h,C[1]=h>>>8&255,i.check=N(i.check,C,2,0)),h=0,d=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(f=i.length,f>r&&(f=r),f&&(i.head&&(x=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(a.subarray(o,o+f),x)),512&i.flags&&(i.check=N(i.check,a,f,o)),r-=f,o+=f,i.length-=f),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===r)break t;f=0;do{x=a[o+f++],i.head&&x&&i.length<65536&&(i.head.name+=String.fromCharCode(x))}while(x&&f<r);if(512&i.flags&&(i.check=N(i.check,a,f,o)),r-=f,o+=f,x)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===r)break t;f=0;do{x=a[o+f++],i.head&&x&&i.length<65536&&(i.head.comment+=String.fromCharCode(x))}while(x&&f<r);if(512&i.flags&&(i.check=N(i.check,a,f,o)),r-=f,o+=f,x)break t}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;d<16;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}if(h!==(65535&i.check)){t.msg="header crc mismatch",i.mode=30;break}h=0,d=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=12;break;case 10:for(;d<32;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}t.adler=i.check=pe(h),h=0,d=0,i.mode=11;case 11:if(0===i.havedict)return t.next_out=s,t.avail_out=l,t.next_in=o,t.avail_in=r,i.hold=h,i.bits=d,he;t.adler=i.check=1,i.mode=12;case 12:if(e===oe||e===se)break t;case 13:if(i.last){h>>>=7&d,d-=7&d,i.mode=27;break}for(;d<3;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}switch(i.last=1&h,h>>>=1,d-=1,3&h){case 0:i.mode=14;break;case 1:if(Ee(i),i.mode=20,e===se){h>>>=2,d-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=30}h>>>=2,d-=2;break;case 14:for(h>>>=7&d,d-=7&d;d<32;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}if((65535&h)!=(h>>>16^65535)){t.msg="invalid stored block lengths",i.mode=30;break}if(i.length=65535&h,h=0,d=0,i.mode=15,e===se)break t;case 15:i.mode=16;case 16:if(f=i.length,f){if(f>r&&(f=r),f>l&&(f=l),0===f)break t;n.set(a.subarray(o,o+f),s),r-=f,o+=f,l-=f,s+=f,i.length-=f;break}i.mode=12;break;case 17:for(;d<14;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}if(i.nlen=257+(31&h),h>>>=5,d-=5,i.ndist=1+(31&h),h>>>=5,d-=5,i.ncode=4+(15&h),h>>>=4,d-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=30;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;d<3;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}i.lens[S[i.have++]]=7&h,h>>>=3,d-=3}for(;i.have<19;)i.lens[S[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},k=ae(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,k){t.msg="invalid code lengths set",i.mode=30;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;E=i.lencode[h&(1<<i.lenbits)-1],g=E>>>24,m=E>>>16&255,w=65535&E,!(g<=d);){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}if(w<16)h>>>=g,d-=g,i.lens[i.have++]=w;else{if(16===w){for(z=g+2;d<z;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}if(h>>>=g,d-=g,0===i.have){t.msg="invalid bit length repeat",i.mode=30;break}x=i.lens[i.have-1],f=3+(3&h),h>>>=2,d-=2}else if(17===w){for(z=g+3;d<z;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}h>>>=g,d-=g,x=0,f=3+(7&h),h>>>=3,d-=3}else{for(z=g+7;d<z;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}h>>>=g,d-=g,x=0,f=11+(127&h),h>>>=7,d-=7}if(i.have+f>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=30;break}for(;f--;)i.lens[i.have++]=x}}if(30===i.mode)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=30;break}if(i.lenbits=9,A={bits:i.lenbits},k=ae(1,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,k){t.msg="invalid literal/lengths set",i.mode=30;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},k=ae(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,k){t.msg="invalid distances set",i.mode=30;break}if(i.mode=20,e===se)break t;case 20:i.mode=21;case 21:if(r>=6&&l>=258){t.next_out=s,t.avail_out=l,t.next_in=o,t.avail_in=r,i.hold=h,i.bits=d,qt(t,_),s=t.next_out,n=t.output,l=t.avail_out,o=t.next_in,a=t.input,r=t.avail_in,h=i.hold,d=i.bits,12===i.mode&&(i.back=-1);break}for(i.back=0;E=i.lencode[h&(1<<i.lenbits)-1],g=E>>>24,m=E>>>16&255,w=65535&E,!(g<=d);){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}if(m&&0==(240&m)){for(b=g,y=m,v=w;E=i.lencode[v+((h&(1<<b+y)-1)>>b)],g=E>>>24,m=E>>>16&255,w=65535&E,!(b+g<=d);){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}h>>>=b,d-=b,i.back+=b}if(h>>>=g,d-=g,i.back+=g,i.length=w,0===m){i.mode=26;break}if(32&m){i.back=-1,i.mode=12;break}if(64&m){t.msg="invalid literal/length code",i.mode=30;break}i.extra=15&m,i.mode=22;case 22:if(i.extra){for(z=i.extra;d<z;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}i.length+=h&(1<<i.extra)-1,h>>>=i.extra,d-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;E=i.distcode[h&(1<<i.distbits)-1],g=E>>>24,m=E>>>16&255,w=65535&E,!(g<=d);){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}if(0==(240&m)){for(b=g,y=m,v=w;E=i.distcode[v+((h&(1<<b+y)-1)>>b)],g=E>>>24,m=E>>>16&255,w=65535&E,!(b+g<=d);){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}h>>>=b,d-=b,i.back+=b}if(h>>>=g,d-=g,i.back+=g,64&m){t.msg="invalid distance code",i.mode=30;break}i.offset=w,i.extra=15&m,i.mode=24;case 24:if(i.extra){for(z=i.extra;d<z;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}i.offset+=h&(1<<i.extra)-1,h>>>=i.extra,d-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=30;break}i.mode=25;case 25:if(0===l)break t;if(f=_-l,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=30;break}f>i.wnext?(f-=i.wnext,u=i.wsize-f):u=i.wnext-f,f>i.length&&(f=i.length),p=i.window}else p=n,u=s-i.offset,f=i.length;f>l&&(f=l),l-=f,i.length-=f;do{n[s++]=p[u++]}while(--f);0===i.length&&(i.mode=21);break;case 26:if(0===l)break t;n[s++]=i.length,l--,i.mode=21;break;case 27:if(i.wrap){for(;d<32;){if(0===r)break t;r--,h|=a[o++]<<d,d+=8}if(_-=l,t.total_out+=_,i.total+=_,_&&(t.adler=i.check=i.flags?N(i.check,n,_,s-_):O(i.check,n,_,s-_)),_=l,(i.flags?h:pe(h))!==i.check){t.msg="incorrect data check",i.mode=30;break}h=0,d=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;d<32;){if(0===r)break t;r--,h+=a[o++]<<d,d+=8}if(h!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=30;break}h=0,d=0}i.mode=29;case 29:k=le;break t;case 30:k=ce;break t;case 31:return _e;default:return de}return t.next_out=s,t.avail_out=l,t.next_in=o,t.avail_in=r,i.hold=h,i.bits=d,(i.wsize||_!==t.avail_out&&i.mode<30&&(i.mode<27||e!==ne))&&Ce(t,t.output,t.next_out,_-t.avail_out),c-=t.avail_in,_-=t.avail_out,t.total_in+=c,t.total_out+=_,i.total+=_,i.wrap&&_&&(t.adler=i.check=i.flags?N(i.check,n,_,t.next_out-_):O(i.check,n,_,t.next_out-_)),t.data_type=i.bits+(i.last?64:0)+(12===i.mode?128:0)+(20===i.mode||15===i.mode?256:0),(0===c&&0===_||e===ne)&&k===re&&(k=fe),k},inflateEnd:t=>{if(!t||!t.state)return de;let e=t.state;return e.window&&(e.window=null),t.state=null,re},inflateGetHeader:(t,e)=>{if(!t||!t.state)return de;const i=t.state;return 0==(2&i.wrap)?de:(i.head=e,e.done=!1,re)},inflateSetDictionary:(t,e)=>{const i=e.length;let a,n,o;return t&&t.state?(a=t.state,0!==a.wrap&&11!==a.mode?de:11===a.mode&&(n=1,n=O(n,e,i,0),n!==a.check)?ce:(o=Ce(t,e,i,i),o?(a.mode=31,_e):(a.havedict=1,re))):de},inflateInfo:"pako inflate (from Nodeca project)"};var ze=function(){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};const Se=Object.prototype.toString,{Z_NO_FLUSH:Re,Z_FINISH:Me,Z_OK:Ie,Z_STREAM_END:De,Z_NEED_DICT:Ue,Z_STREAM_ERROR:Be,Z_DATA_ERROR:Te,Z_MEM_ERROR:Ze}=V;function Le(t){this.options=Ut({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nt,this.strm.avail_out=0;let i=Ae.inflateInit2(this.strm,e.windowBits);if(i!==Ie)throw new Error(P[i]);if(this.header=new ze,Ae.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Lt(e.dictionary):"[object ArrayBuffer]"===Se.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=Ae.inflateSetDictionary(this.strm,e.dictionary),i!==Ie)))throw new Error(P[i])}function Oe(t,e){const i=new Le(e);if(i.push(t),i.err)throw i.msg||P[i.err];return i.result}Le.prototype.push=function(t,e){const i=this.strm,a=this.options.chunkSize,n=this.options.dictionary;let o,s,r;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Me:Re,"[object ArrayBuffer]"===Se.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),o=Ae.inflate(i,s),o===Ue&&n&&(o=Ae.inflateSetDictionary(i,n),o===Ie?o=Ae.inflate(i,s):o===Te&&(o=Ue));i.avail_in>0&&o===De&&i.state.wrap>0&&0!==t[i.next_in];)Ae.inflateReset(i),o=Ae.inflate(i,s);switch(o){case Be:case Te:case Ue:case Ze:return this.onEnd(o),this.ended=!0,!1}if(r=i.avail_out,i.next_out&&(0===i.avail_out||o===De))if("string"===this.options.to){let t=Ft(i.output,i.next_out),e=i.next_out-t,n=Ot(i.output,t);i.next_out=e,i.avail_out=a-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(n)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(o!==Ie||0!==r){if(o===De)return o=Ae.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Le.prototype.onData=function(t){this.chunks.push(t)},Le.prototype.onEnd=function(t){t===Ie&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Bt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Fe={Inflate:Le,inflate:Oe,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Oe(t,e)},ungzip:Oe,constants:V};const{Inflate:Ne,inflate:Pe,inflateRaw:Ve,ungzip:We}=Fe;var He=Pe;const Ye=Object.freeze({title:"Vacuum",show_map:!0,show_floor:!0,show_dock:!0,show_vacuum:!0,show_walls:!0,show_currently_cleaned_zones:!0,show_no_go_areas:!0,show_no_mop_areas:!0,show_virtual_walls:!0,show_path:!0,show_currently_cleaned_zones_border:!0,show_no_go_area_border:!0,show_no_mop_area_border:!0,show_predicted_path:!0,show_goto_target:!0,show_segments:!0,show_status:!0,show_battery_level:!0,show_start_button:!0,show_pause_button:!0,show_stop_button:!0,show_home_button:!0,show_locate_button:!0,virtual_wall_width:1,path_width:1,left_padding:0,map_scale:1,icon_scale:1,floor_opacity:1,segment_opacity:.75,wall_opacity:1,currently_cleaned_zone_opacity:.5,no_go_area_opacity:.5,no_mop_area_opacity:.5,virtual_wall_opacity:1,path_opacity:1,segment_colors:["#19A1A1","#7AC037","#DF5618","#F7C841"],min_height:0}),je=Object.freeze({cleaning:3e3,paused:15e3,idle:12e4,returning:3e3,docked:12e4,error:12e4});console.info("%c Valetudo-Map-Card \n%c Version 2023.04.0 ","color: #0076FF; font-weight: bold; background: #121212","color: #52AEFF; font-weight: bold; background: #1e1e1e");class Xe extends HTMLElement{constructor(){super(),this.drawingMap=!1,this.drawingControls=!1,this.lastUpdatedControls="",this.attachShadow({mode:"open"}),this.lastMapPoll=new Date(0),this.isPollingMap=!1,this.lastRobotState="docked",this.pollInterval=je.cleaning,this.cardContainer=document.createElement("ha-card"),this.cardContainer.id="valetudoMapCard",this.cardContainerStyle=document.createElement("style"),this.shadowRoot.appendChild(this.cardContainer),this.shadowRoot.appendChild(this.cardContainerStyle),this.cardHeader=document.createElement("div"),this.cardHeader.setAttribute("class","card-header"),this.cardTitle=document.createElement("div"),this.cardTitle.setAttribute("class","name"),this.cardHeader.appendChild(this.cardTitle),this.cardContainer.appendChild(this.cardHeader),this.entityWarning1=document.createElement("hui-warning"),this.entityWarning1.id="valetudoMapCardWarning1",this.entityWarning1.style.display="none",this.cardContainer.appendChild(this.entityWarning1),this.entityWarning2=document.createElement("hui-warning"),this.entityWarning2.id="valetudoMapCardWarning2",this.entityWarning2.style.display="none",this.cardContainer.appendChild(this.entityWarning2),this.mapContainer=document.createElement("div"),this.mapContainer.id="valetudoMapCardMapContainer",this.mapContainerStyle=document.createElement("style"),this.cardContainer.appendChild(this.mapContainer),this.cardContainer.appendChild(this.mapContainerStyle),this.controlContainer=document.createElement("div"),this.controlContainer.id="valetudoMapCardControlsContainer",this.controlContainerStyle=document.createElement("style"),this.cardContainer.appendChild(this.controlContainer),this.cardContainer.appendChild(this.controlContainerStyle)}static getStubConfig(){return{vacuum:"valetudo_REPLACEME"}}getMapEntityName(t){return"camera."+t+"_map_data"}getVacuumEntityName(t){return"vacuum."+t}getMapEntity(t){return this._hass.states[this.getMapEntityName(t)]}getVacuumEntity(t){return this._hass.states[this.getVacuumEntityName(t)]}shouldDrawMap(){return!this.drawingMap}shouldDrawControls(t){return!this.drawingControls&&this.lastUpdatedControls!==t.last_updated}calculateColor(t,...e){for(let i of e)if(i){if(i.startsWith("--")){let e=getComputedStyle(t).getPropertyValue(i);if(!e)continue;return e}return i}}isOutsideBounds(t,e,i,a){return t<this._config.crop.left||t>i.width||e<a.crop.top||e>i.height}getLayers(t,e,i){let a=[];for(let n of t.layers)if(n.type===e&&a.push(n),a.length===i)break;return a}getEntities(t,e,i){let a=[];for(let n of t.entities)if(n.type===e&&a.push(n),i&&a.length===i)break;return a}getChargerInfo(t){let e=this.getEntities(t,"charger_location",1)[0];return void 0===e?null:[e.points[0],e.points[1]]}getRobotInfo(t){let e=this.getEntities(t,"robot_position",1)[0];return void 0===e?null:[e.points[0],e.points[1],e.metaData.angle]}getGoToInfo(t){let e=this.getEntities(t,"go_to_target",1)[0];return void 0===e?null:[e.points[0],e.points[1]]}getFloorPoints(t){let e=this.getLayers(t,"floor",1)[0];return void 0===e?null:e.pixels}getSegments(t){return this.getLayers(t,"segment")}getWallPoints(t){let e=this.getLayers(t,"wall",1)[0];return void 0===e?null:e.pixels}getVirtualWallPoints(t){return this.getEntities(t,"virtual_wall")}getPathPoints(t){return this.getEntities(t,"path")}getPredictedPathPoints(t){return this.getEntities(t,"predicted_path")}getActiveZones(t){return this.getEntities(t,"active_zone")}getNoGoAreas(t){return this.getEntities(t,"no_go_area")}getNoMopAreas(t){return this.getEntities(t,"no_mop_area")}drawMap(t,e,i,n){const o=t.pixelSize,s=o/this._config.map_scale,r=o/this._config.map_scale;let l=0,h=0;l=(n.minX-1)*this._config.map_scale,h=(n.minY-1)*this._config.map_scale;const d=document.getElementsByTagName("home-assistant")[0],c=this.calculateColor(d,this._config.floor_color,"--valetudo-map-floor-color","--secondary-background-color"),_=this.calculateColor(d,this._config.wall_color,"--valetudo-map-wall-color","--accent-color"),f=this.calculateColor(d,this._config.currently_cleaned_zone_color,"--valetudo-currently_cleaned_zone_color","--secondary-text-color"),u=this.calculateColor(d,this._config.no_go_area_color,"--valetudo-no-go-area-color","--accent-color"),p=this.calculateColor(d,this._config.no_mop_area_color,"--valetudo-no-mop-area-color","--secondary-text-color"),g=this.calculateColor(d,this._config.virtual_wall_color,"--valetudo-virtual-wall-color","--accent-color"),m=this.calculateColor(d,this._config.path_color,"--valetudo-map-path-color","--primary-text-color"),w=this.calculateColor(d,this._config.dock_color,"green"),b=this.calculateColor(d,this._config.vacuum_color,"--primary-text-color"),y=this.calculateColor(d,this._config.goto_target_color,"blue"),v=document.createElement("div");v.id="lovelaceValetudoCard";const x=document.createElement("div"),k=document.createElement("canvas");k.width=i*this._config.map_scale,k.height=e*this._config.map_scale,x.style.zIndex=1,x.appendChild(k);const E=document.createElement("div"),C=document.createElement("ha-icon");let A=this.getChargerInfo(t);this._config.show_dock&&A&&(C.style.position="absolute",C.icon=this._config.dock_icon||"mdi:flash",C.style.left=Math.floor(A[0]/s)-0-l-12*this._config.icon_scale+"px",C.style.top=Math.floor(A[1]/r)-0-h-12*this._config.icon_scale+"px",C.style.color=w,C.style.transform=`scale(${this._config.icon_scale}, ${this._config.icon_scale}) rotate(-${this._config.rotate})`),E.style.zIndex=2,E.appendChild(C);const z=document.createElement("div"),S=document.createElement("canvas");S.width=i*this._config.map_scale,S.height=e*this._config.map_scale,z.style.zIndex=3,z.appendChild(S);const R=document.createElement("div"),M=document.createElement("ha-icon");let I=this.getRobotInfo(t);I||(I=this.lastValidRobotInfo),this._config.show_vacuum&&I&&(this.lastValidRobotInfo=I,M.style.position="absolute",M.icon=this._config.vacuum_icon||"mdi:robot-vacuum",M.style.color=b,M.style.left=Math.floor(I[0]/s)-0-l-12*this._config.icon_scale+"px",M.style.top=Math.floor(I[1]/r)-0-h-12*this._config.icon_scale+"px",M.style.transform=`scale(${this._config.icon_scale}, ${this._config.icon_scale})`),R.style.zIndex=4,R.appendChild(M);const D=document.createElement("div"),U=document.createElement("ha-icon");let B=this.getGoToInfo(t);this._config.show_goto_target&&B&&(U.style.position="absolute",U.icon=this._config.goto_target_icon||"mdi:pin",U.style.left=Math.floor(B[0]/s)-0-l-12*this._config.icon_scale+"px",U.style.top=Math.floor(B[1]/r)-0-h-22*this._config.icon_scale+"px",U.style.color=y,U.style.transform=`scale(${this._config.icon_scale}, ${this._config.icon_scale})`),D.style.zIndex=5,D.appendChild(U),v.appendChild(x),v.appendChild(E),v.appendChild(z),v.appendChild(R),v.appendChild(D);const T=k.getContext("2d");if(this._config.show_floor){T.globalAlpha=this._config.floor_opacity,T.strokeStyle=c,T.lineWidth=1,T.fillStyle=c,T.beginPath();let e=this.getFloorPoints(t);if(e)for(let t=0;t<e.length;t+=2){let i=e[t]*this._config.map_scale-l,a=e[t+1]*this._config.map_scale-h;this.isOutsideBounds(i,a,k,this._config)||T.fillRect(i,a,this._config.map_scale,this._config.map_scale)}T.globalAlpha=1}let Z=this.getSegments(t);if(Z&&this._config.show_segments){const t=new a(Z,6);T.globalAlpha=this._config.segment_opacity;for(let e of Z){T.strokeStyle=this._config.segment_colors[t.getColor(e.metaData.segmentId)],T.lineWidth=1,T.fillStyle=this._config.segment_colors[t.getColor(e.metaData.segmentId)],T.beginPath();let i=e.pixels;if(i)for(let t=0;t<i.length;t+=2){let e=i[t]*this._config.map_scale-l,a=i[t+1]*this._config.map_scale-h;this.isOutsideBounds(e,a,k,this._config)||T.fillRect(e,a,this._config.map_scale,this._config.map_scale)}}T.globalAlpha=1}if(this._config.show_walls){T.globalAlpha=this._config.wall_opacity,T.strokeStyle=_,T.lineWidth=1,T.fillStyle=_,T.beginPath();let e=this.getWallPoints(t);if(e)for(let t=0;t<e.length;t+=2){let i=e[t]*this._config.map_scale-l,a=e[t+1]*this._config.map_scale-h;this.isOutsideBounds(i,a,k,this._config)||T.fillRect(i,a,this._config.map_scale,this._config.map_scale)}T.globalAlpha=1}let L=this.getActiveZones(t);if(Array.isArray(L)&&L.length>0&&this._config.show_currently_cleaned_zones){T.globalAlpha=this._config.currently_cleaned_zone_opacity,T.strokeStyle=f,T.lineWidth=2,T.fillStyle=f;for(let t of L){T.globalAlpha=this._config.currently_cleaned_zone_opacity,T.beginPath();let e=t.points;for(let t=0;t<e.length;t+=2){let i=Math.floor(e[t]/s)-0-l,a=Math.floor(e[t+1]/r)-0-h;0===t?T.moveTo(i,a):T.lineTo(i,a),this.isOutsideBounds(i,a,k,this._config)}T.fill(),this._config.show_currently_cleaned_zones_border&&(T.closePath(),T.globalAlpha=1,T.stroke())}T.globalAlpha=1}let O=this.getNoGoAreas(t);if(O&&this._config.show_no_go_areas){T.strokeStyle=u,T.lineWidth=2,T.fillStyle=u;for(let t of O){T.globalAlpha=this._config.no_go_area_opacity,T.beginPath();let e=t.points;for(let t=0;t<e.length;t+=2){let i=Math.floor(e[t]/s)-0-l,a=Math.floor(e[t+1]/r)-0-h;0===t?T.moveTo(i,a):T.lineTo(i,a),this.isOutsideBounds(i,a,k,this._config)}T.fill(),this._config.show_no_go_area_border&&(T.closePath(),T.globalAlpha=1,T.stroke())}T.globalAlpha=1}let F=this.getNoMopAreas(t);if(F&&this._config.show_no_mop_areas){T.strokeStyle=p,T.lineWidth=2,T.fillStyle=p;for(let t of F){T.globalAlpha=this._config.no_mop_area_opacity,T.beginPath();let e=t.points;for(let t=0;t<e.length;t+=2){let i=Math.floor(e[t]/s)-0-l,a=Math.floor(e[t+1]/r)-0-h;0===t?T.moveTo(i,a):T.lineTo(i,a),this.isOutsideBounds(i,a,k,this._config)}T.fill(),this._config.show_no_mop_area_border&&(T.closePath(),T.globalAlpha=1,T.stroke())}T.globalAlpha=1}let N=this.getVirtualWallPoints(t);if(N&&this._config.show_virtual_walls&&this._config.virtual_wall_width>0){T.globalAlpha=this._config.virtual_wall_opacity,T.strokeStyle=g,T.lineWidth=this._config.virtual_wall_width,T.beginPath();for(let t of N){let e=Math.floor(t.points[0]/s)-0-l,i=Math.floor(t.points[1]/r)-0-h,a=Math.floor(t.points[2]/s)-0-l,n=Math.floor(t.points[3]/r)-0-h;this.isOutsideBounds(e,i,k,this._config)||(this.isOutsideBounds(a,n,k,this._config)||(T.moveTo(e,i),T.lineTo(a,n),T.stroke()))}T.globalAlpha=1}const P=S.getContext("2d");P.globalAlpha=this._config.path_opacity,P.strokeStyle=m,P.lineWidth=this._config.path_width;let V=this.getPathPoints(t);if(Array.isArray(V)&&V.length>0&&this._config.show_path&&this._config.path_width>0){for(let t of V){let e=0,i=0,a=!0;P.beginPath();for(let n=0;n<t.points.length;n+=2)e=Math.floor(t.points[n]/s)-0-l,i=Math.floor(t.points[n+1]/r)-0-h,this.isOutsideBounds(e,i,k,this._config)||(a?(P.moveTo(e,i),a=!1):P.lineTo(e,i));P.stroke()}M.style.transform=`scale(${this._config.icon_scale}, ${this._config.icon_scale}) rotate(${I[2]}deg)`,P.globalAlpha=1}let W=this.getPredictedPathPoints(t);if(Array.isArray(W)&&W.length>0&&this._config.show_predicted_path&&this._config.path_width>0){P.setLineDash([5,3]);for(let t of W){let e=0,i=0,a=!0;P.beginPath();for(let n=0;n<t.points.length;n+=2)e=Math.floor(t.points[n]/s)-0-l,i=Math.floor(t.points[n+1]/r)-0-h,this.isOutsideBounds(e,i,k,this._config)||(a?(P.moveTo(e,i),a=!1):P.lineTo(e,i));P.stroke()}P.globalAlpha=1}this.clearContainer(this.mapContainer),this.mapContainer.appendChild(v)}clearContainer(t){for(;t.firstChild;)t.firstChild.remove()}drawControls(t){if(this.drawingControls=!0,this.infoBox=document.createElement("div"),this.infoBox.classList.add("flex-box"),t&&t.state&&this._config.show_status){const e=document.createElement("p");e.innerHTML=t.state[0].toUpperCase()+t.state.substring(1),this.infoBox.appendChild(e)}if(t&&t.attributes&&t.attributes.battery_icon&&t.attributes.battery_level&&this._config.show_battery_level){const e=document.createElement("div");e.style.display="flex",e.style.alignItems="center";const i=document.createElement("ha-icon"),a=document.createElement("span");i.icon=t.attributes.battery_icon,a.innerHTML=" "+t.attributes.battery_level+" %",e.appendChild(i),e.appendChild(a),this.infoBox.appendChild(e)}if(this.controlFlexBox=document.createElement("div"),this.controlFlexBox.classList.add("flex-box"),this._config.show_start_button&&this.shouldDisplayButton("start",t.state)){const t=document.createElement("paper-button"),e=document.createElement("ha-icon"),i=document.createElement("paper-ripple");e.icon="mdi:play",t.appendChild(e),t.appendChild(i),t.addEventListener("click",(t=>{this._hass.callService("vacuum","start",{entity_id:this.getVacuumEntityName(this._config.vacuum)}).then()})),this.controlFlexBox.appendChild(t)}if(this._config.show_pause_button&&this.shouldDisplayButton("pause",t.state)){const t=document.createElement("paper-button"),e=document.createElement("ha-icon"),i=document.createElement("paper-ripple");e.icon="mdi:pause",t.appendChild(e),t.appendChild(i),t.addEventListener("click",(t=>{this._hass.callService("vacuum","pause",{entity_id:this.getVacuumEntityName(this._config.vacuum)}).then()})),this.controlFlexBox.appendChild(t)}if(this._config.show_stop_button&&this.shouldDisplayButton("stop",t.state)){const t=document.createElement("paper-button"),e=document.createElement("ha-icon"),i=document.createElement("paper-ripple");e.icon="mdi:stop",t.appendChild(e),t.appendChild(i),t.addEventListener("click",(t=>{this._hass.callService("vacuum","stop",{entity_id:this.getVacuumEntityName(this._config.vacuum)}).then()})),this.controlFlexBox.appendChild(t)}if(this._config.show_home_button&&this.shouldDisplayButton("home",t.state)){const t=document.createElement("paper-button"),e=document.createElement("ha-icon"),i=document.createElement("paper-ripple");e.icon="hass:home-map-marker",t.appendChild(e),t.appendChild(i),t.addEventListener("click",(t=>{this._hass.callService("vacuum","return_to_base",{entity_id:this.getVacuumEntityName(this._config.vacuum)}).then()})),this.controlFlexBox.appendChild(t)}if(this._config.show_locate_button){const t=document.createElement("paper-button"),e=document.createElement("ha-icon"),i=document.createElement("paper-ripple");e.icon="hass:map-marker",t.appendChild(e),t.appendChild(i),t.addEventListener("click",(t=>{this._hass.callService("vacuum","locate",{entity_id:this.getVacuumEntityName(this._config.vacuum)}).then()})),this.controlFlexBox.appendChild(t)}this.customControlFlexBox=document.createElement("div"),this.customControlFlexBox.classList.add("flex-box"),this._config.custom_buttons.forEach((t=>{if(t===Object(t)&&t.service){const e=document.createElement("paper-button"),i=document.createElement("ha-icon"),a=document.createElement("paper-ripple");if(i.icon=t.icon||"mdi:radiobox-blank",e.appendChild(i),t.text){const i=document.createElement("span");i.textContent=t.text,e.appendChild(i)}e.appendChild(a),e.addEventListener("click",(e=>{const i=t.service.split(".");t.service_data?this._hass.callService(i[0],i[1],t.service_data).then():this._hass.callService(i[0],i[1]).then()})),this.customControlFlexBox.appendChild(e)}})),this.clearContainer(this.controlContainer),this.controlContainer.append(this.infoBox),this.controlContainer.append(this.controlFlexBox),this.controlContainer.append(this.customControlFlexBox),this.lastUpdatedControls=t.last_updated,this.drawingControls=!1}setConfig(t){this._config=Object.assign({},Ye,t),"string"==typeof this._config.vacuum&&(this._config.vacuum=this._config.vacuum.toLowerCase()),void 0===this._config.rotate&&(this._config.rotate=0),Number(this._config.rotate)&&(this._config.rotate=`${this._config.rotate}deg`),this._config.crop!==Object(this._config.crop)&&(this._config.crop={}),void 0===this._config.crop.top&&(this._config.crop.top=0),void 0===this._config.crop.bottom&&(this._config.crop.bottom=0),void 0===this._config.crop.left&&(this._config.crop.left=0),void 0===this._config.crop.right&&(this._config.crop.right=0),this.cardHeader.style.display=this._config.title?"block":"none",this.cardTitle.textContent=this._config.title,this.cardContainer.style.background=this._config.background_color??null,Array.isArray(this._config.custom_buttons)||(this._config.custom_buttons=[])}set hass(t){if(void 0===t)return;this._hass=t;let e=this.getMapEntity(this._config.vacuum),i=this.getVacuumEntity(this._config.vacuum),a=!1,n=e?e.attributes:void 0;i&&i.state!==this.lastRobotState&&(this.pollInterval=je[i.state]||1e4,a=!0,this.lastRobotState=i.state),e&&"unavailable"!==e.state&&n?.entity_picture?((new Date).getTime()-this.pollInterval>this.lastMapPoll.getTime()||a)&&this.loadImageAndExtractMapData(n.entity_picture).then((i=>{null!==i&&this.handleDrawing(t,e,i)})).catch((i=>{this.handleDrawing(t,e,{}),console.warn(i)})).finally((()=>{this.lastMapPoll=new Date})):(this.clearContainer(this.mapContainer),this.clearContainer(this.controlContainer),this.entityWarning1.textContent=`Entity not available: ${this.getMapEntityName(this._config.vacuum)}`,this.entityWarning1.style.display="block",this.entityWarning2.style.display="none")}async loadImageAndExtractMapData(t){if(!1===this.isPollingMap){this.isPollingMap=!0;const a=await this._hass.fetchWithAuth(t);let n;if(!a.ok)throw new Error("Got error while fetching image "+a.status+" - "+a.statusText);const o=await a.arrayBuffer(),s=function(t){const e=new Uint8Array(4),i=new Uint32Array(e.buffer);if(137!==t[0])throw new Error("Invalid .png file header");if(80!==t[1])throw new Error("Invalid .png file header");if(78!==t[2])throw new Error("Invalid .png file header");if(71!==t[3])throw new Error("Invalid .png file header");if(13!==t[4])throw new Error("Invalid .png file header: possibly caused by DOS-Unix line ending conversion?");if(10!==t[5])throw new Error("Invalid .png file header: possibly caused by DOS-Unix line ending conversion?");if(26!==t[6])throw new Error("Invalid .png file header");if(10!==t[7])throw new Error("Invalid .png file header: possibly caused by DOS-Unix line ending conversion?");const a=[];let n=!1,o=8;for(;o<t.length;){e[3]=t[o++],e[2]=t[o++],e[1]=t[o++],e[0]=t[o++];const s=i[0]+4,r=new Uint8Array(s);r[0]=t[o++],r[1]=t[o++],r[2]=t[o++],r[3]=t[o++];const l=String.fromCharCode(r[0])+String.fromCharCode(r[1])+String.fromCharCode(r[2])+String.fromCharCode(r[3]);if("IEND"===l){n=!0;break}for(let e=4;e<s;e++)r[e]=t[o++];o+=4;const h=new Uint8Array(r.buffer.slice(4));if("zTXt"===l){let t=0,e="";for(;0!==h[t]&&t<79;)e+=String.fromCharCode(h[t]),t++;a.push({keyword:e,data:new Uint8Array(h.slice(t+2))})}}if(!n)throw new Error(".png file ended prematurely: no IEND header was found");return a}(new Uint8Array(o)).filter((t=>"ValetudoMap"===t.keyword));if(s.length<1)throw new Error("No map data found in image");return n=He(s[0].data,{to:"string"}),n=JSON.parse(n),2===(null===(i=(e=n).metaData)||void 0===i?void 0:i.version)&&Array.isArray(e.layers)&&e.layers.forEach((function(t){if(0===t.pixels.length&&t.compressedPixels&&0!==t.compressedPixels.length){for(var e=0;e<t.compressedPixels.length;e+=3)for(var i=t.compressedPixels[e],a=t.compressedPixels[e+1],n=t.compressedPixels[e+2],o=0;o<n;o++)t.pixels.push(i+o,a);delete t.compressedPixels}})),n=e,this.isPollingMap=!1,n}return null;var e,i}shouldDisplayButton(t,e){switch(e){case"on":case"auto":case"spot":case"edge":case"single_room":case"cleaning":return"pause"===t||"stop"===t||"home"===t;case"returning":return"start"===t||"pause"===t;case"docked":return"start"===t;default:return"start"===t||"home"===t}}handleDrawing(t,e,i){let a=this.getVacuumEntity(this._config.vacuum),n=!1,o=!0;if("ValetudoMap"===i.__class&&(n=!0),a&&"unavailable"!==a.state&&a.attributes||(o=!1,this.lastUpdatedControls=""),this.mapContainer.style.display=n&&this._config.show_map?"block":"none",!n&&this._config.show_map?(this.entityWarning1.textContent=`Entity not available: ${this.getMapEntityName(this._config.vacuum)}`,this.entityWarning1.style.display="block"):this.entityWarning1.style.display="none",o?(this.entityWarning2.style.display="none",this.controlContainer.style.display="block"):(this.controlContainer.style.display="none",this.entityWarning2.textContent=`Entity not available: ${this.getVacuumEntityName(this._config.vacuum)}`,this.entityWarning2.style.display="block"),n){let t,e,a={minX:i.size.x/i.pixelSize,minY:i.size.y/i.pixelSize,maxX:0,maxY:0};i.layers.forEach((t=>{t.dimensions.x.min<a.minX&&(a.minX=t.dimensions.x.min),t.dimensions.y.min<a.minY&&(a.minY=t.dimensions.y.min),t.dimensions.x.max>a.maxX&&(a.maxX=t.dimensions.x.max),t.dimensions.y.max>a.maxY&&(a.maxY=t.dimensions.y.max)})),t=a.maxX-a.minX+2,e=a.maxY-a.minY+2;const n=t-this._config.crop.right,o=e-this._config.crop.bottom;let s=o*this._config.map_scale-this._config.crop.top,r=this._config.min_height;String(this._config.min_height).endsWith("w")&&(r=this._config.min_height.slice(0,-1)*this.mapContainer.offsetWidth);let l=r>s?(r-s)/2:0;this.mapContainerStyle.textContent=`\n #lovelaceValetudoMapCard {\n height: ${s}px;\n padding-top: ${l}px;\n padding-bottom: ${l}px;\n padding-left: ${this._config.left_padding}px;\n overflow: hidden;\n }\n #lovelaceValetudoCard {\n position: relative;\n margin-left: auto;\n margin-right: auto;\n width: ${n*this._config.map_scale}px;\n height: ${o*this._config.map_scale}px;\n transform: rotate(${this._config.rotate});\n top: -${this._config.crop.top}px;\n left: -${this._config.crop.left}px;\n }\n #lovelaceValetudoCard div {\n position: absolute;\n background-color: transparent;\n width: 100%;\n height: 100%;\n }\n `,this.shouldDrawMap()&&this._config.show_map&&(this.drawingMap=!0,this.drawMap(i,o,n,a),this.drawingMap=!1)}if(o){this.controlContainerStyle.textContent="\n .flex-box {\n display: flex;\n justify-content: space-evenly;\n flex-wrap: wrap;\n }\n paper-button {\n cursor: pointer;\n position: relative;\n display: inline-flex;\n align-items: center;\n padding: 8px;\n }\n ha-icon {\n width: 24px;\n height: 24px;\n }\n ";let t=this.getVacuumEntity(this._config.vacuum);this.shouldDrawControls(t)&&this.drawControls(t)}}getCardSize(){return 1}}customElements.define("valetudo-map-card",Xe),window.customCards=window.customCards||[],window.customCards.push({type:"valetudo-map-card",name:"Valetudo Map Card",preview:!1,description:"Display the Map data of your Valetudo-enabled robot"});