@augmentd-labs/canvas-web 2.21.7 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/EditorOverlay-DqlaCJe7.js +1 -0
- package/dist/assets/LocationTab-BONJQfYM.js +1 -0
- package/dist/assets/{MarkdownEditor-BfEutx88.js → MarkdownEditor-By8nDUtG.js} +28 -28
- package/dist/assets/NextShell-CX994BbA.js +1 -0
- package/dist/assets/{SketchEditor-CzF9XeKc.js → SketchEditor-CCh9_zKT.js} +6 -6
- package/dist/assets/TextDocumentEditor-S5KKs7E_.js +1 -0
- package/dist/assets/alert-dialog-CDKOX-MP.js +1 -0
- package/dist/assets/blobs-NdFfDbao.js +1 -0
- package/dist/assets/{chunk-K2UTITRG-Cao6Wqyg.js → chunk-K2UTITRG-zQFDOW3Q.js} +4 -4
- package/dist/assets/code-editor-BQnKd3jw.js +40 -0
- package/dist/assets/image-GAAHSSAO-BoD-NvEF.js +1 -0
- package/dist/assets/index-CSLSGQD_.js +55 -0
- package/dist/assets/index-DfnR5CZe.css +2 -0
- package/dist/assets/markdown-html-XoABNf32.js +1 -0
- package/dist/assets/react-BzqgEMSQ.js +164 -0
- package/dist/assets/sha256-BhArj2aT.js +1 -0
- package/dist/assets/subtree-transfer-dialog-CSjPDp4d.js +1 -0
- package/dist/assets/text-documents-iLXAAr-8.js +3 -0
- package/dist/assets/ui-NWo4bzrd.js +41 -0
- package/dist/assets/use-theme-Bd8sb5Ox.js +1 -0
- package/dist/assets/workspace-Dh0Dd0r4.js +1 -0
- package/dist/index.html +11 -10
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/dist/assets/EditorOverlay-Br-7EGzk.js +0 -1
- package/dist/assets/LocationTab-BroSH_r9.js +0 -1
- package/dist/assets/NextShell-Df3OcesF.js +0 -1
- package/dist/assets/TextDocumentEditor-xDVkaqaV.js +0 -1
- package/dist/assets/alert-dialog-40DQir92.js +0 -1
- package/dist/assets/blobs-CqeUUk7U.js +0 -1
- package/dist/assets/image-GAAHSSAO-BaCj5pGW.js +0 -1
- package/dist/assets/index-iHzuCz7h.js +0 -94
- package/dist/assets/index-s8bjUo9L.css +0 -2
- package/dist/assets/markdown-html-fTfpAKLc.js +0 -1
- package/dist/assets/react-D6EoYNJu.js +0 -164
- package/dist/assets/sha256-boGwjHW-.js +0 -1
- package/dist/assets/subtree-transfer-dialog-CK4YVdCQ.js +0 -1
- package/dist/assets/text-documents-CDqnP7fW.js +0 -3
- package/dist/assets/ui-Dxn_QQzV.js +0 -41
- package/dist/assets/use-theme-DykbaTyC.js +0 -1
- package/dist/assets/workspace-brIBpeUg.js +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/subset-worker.chunk-D4w07nYk.js","assets/chunk-SRAX5OIU-Dhm3gOdh.js","assets/rolldown-runtime-C0FnF6B9.js","assets/chunk-EIO257PC-CAhBf1ig.js","assets/subset-shared.chunk-CzQ5JF2O.js","assets/image-GAAHSSAO-
|
|
2
|
-
import{o as e,t}from"./rolldown-runtime-C0FnF6B9.js";import{
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/subset-worker.chunk-D4w07nYk.js","assets/chunk-SRAX5OIU-Dhm3gOdh.js","assets/rolldown-runtime-C0FnF6B9.js","assets/chunk-EIO257PC-CAhBf1ig.js","assets/subset-shared.chunk-CzQ5JF2O.js","assets/image-GAAHSSAO-BoD-NvEF.js","assets/pica-XznpCgP2.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e,t}from"./rolldown-runtime-C0FnF6B9.js";import{l as n,u as r}from"./code-editor-BQnKd3jw.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{t as a}from"./utils-BxVxyehK.js";import{i as o}from"./chunk-SRAX5OIU-Dhm3gOdh.js";var s={VITE_APP_BACKEND_V2_GET_URL:`https://json.excalidraw.com/api/v2/`,VITE_APP_BACKEND_V2_POST_URL:`https://json.excalidraw.com/api/v2/post/`,VITE_APP_LIBRARY_URL:`https://libraries.excalidraw.com`,VITE_APP_LIBRARY_BACKEND:`https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries`,VITE_APP_PLUS_LP:`https://plus.excalidraw.com`,VITE_APP_PLUS_APP:`https://app.excalidraw.com`,VITE_APP_AI_BACKEND:`https://oss-ai.excalidraw.com`,VITE_APP_WS_SERVER_URL:`https://oss-collab.excalidraw.com`,VITE_APP_FIREBASE_CONFIG:`{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}`,VITE_APP_ENABLE_TRACKING:`false`,VITE_APP_PLUS_EXPORT_PUBLIC_KEY:`MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApQ0jM9Qz8TdFLzcuAZZX
|
|
3
3
|
/WvuKSOJxiw6AR/ZcE3eFQWM/mbFdhQgyK8eHGkKQifKzH1xUZjCxyXcxW6ZO02t
|
|
4
4
|
kPOPxhz+nxUrIoWCD/V4NGmUA1lxwHuO21HN1gzKrN3xHg5EGjyouR9vibT9VDGF
|
|
5
5
|
gq6+4Ic/kJX+AD2MM7Yre2+FsOdysrmuW2Fu3ahuC1uQE7pOe1j0k7auNP0y1q53
|
|
6
6
|
PrB8Ts2LUpepWC1l7zIXFm4ViDULuyWXTEpUcHSsEH8vpd1tckjypxCwkipfZsXx
|
|
7
7
|
iPszy0o0Dx2iArPfWMXlFAI9mvyFCyFC3+nSvfyAUb2C4uZgCwAuyFh/ydPF4DEE
|
|
8
|
-
PQIDAQAB`,VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX:`false`,VITE_APP_COLLAPSE_OVERLAY:`false`,VITE_APP_ENABLE_ESLINT:`false`,PKG_NAME:`@excalidraw/excalidraw`,PKG_VERSION:`0.18.1`,PROD:!0},c=t((e=>{(function(t){typeof DO_NOT_EXPORT_CRC>`u`?typeof e==`object`?t(e):typeof define==`function`&&define.amd?define(function(){var e={};return t(e),e}):t({}):t({})})(function(e){e.version=`0.3.0`;function t(){for(var e=0,t=Array(256),n=0;n!=256;++n)e=n,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,t[n]=e;return typeof Int32Array<`u`?new Int32Array(t):t}var n=t(),r=typeof Buffer<`u`;function i(e){if(e.length>32768&&r)return o(new Buffer(e));for(var t=-1,i=e.length-1,a=0;a<i;)t=n[(t^e.charCodeAt(a++))&255]^t>>>8,t=n[(t^e.charCodeAt(a++))&255]^t>>>8;return a===i&&(t=t>>>8^n[(t^e.charCodeAt(a))&255]),t^-1}function a(e){if(e.length>1e4)return o(e);for(var t=-1,r=0,i=e.length-3;r<i;)t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255];for(;r<i+3;)t=t>>>8^n[(t^e[r++])&255];return t^-1}function o(e){for(var t=-1,r=0,i=e.length-7;r<i;)t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255];for(;r<i+7;)t=t>>>8^n[(t^e[r++])&255];return t^-1}function s(e){for(var t=-1,r=0,i=e.length,a,o;r<i;)a=e.charCodeAt(r++),a<128?t=t>>>8^n[(t^a)&255]:a<2048?(t=t>>>8^n[(t^(192|a>>6&31))&255],t=t>>>8^n[(t^(128|a&63))&255]):a>=55296&&a<57344?(a=(a&1023)+64,o=e.charCodeAt(r++)&1023,t=t>>>8^n[(t^(240|a>>8&7))&255],t=t>>>8^n[(t^(128|a>>2&63))&255],t=t>>>8^n[(t^(128|o>>6&15|a&3))&255],t=t>>>8^n[(t^(128|o&63))&255]):(t=t>>>8^n[(t^(224|a>>12&15))&255],t=t>>>8^n[(t^(128|a>>6&63))&255],t=t>>>8^n[(t^(128|a&63))&255]);return t^-1}e.table=n,e.bstr=i,e.buf=a,e.str=s})})),l=t(((e,t)=>{var n=c();t.exports=o;var r=new Uint8Array(4),i=new Int32Array(r.buffer),a=new Uint32Array(r.buffer);function o(e){if(e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71)throw Error(`Invalid .png file header`);if(e[4]!==13||e[5]!==10)throw Error(`Invalid .png file header: possibly caused by DOS-Unix line ending conversion?`);if(e[6]!==26)throw Error(`Invalid .png file header`);if(e[7]!==10)throw Error(`Invalid .png file header: possibly caused by DOS-Unix line ending conversion?`);for(var t=!1,o=[],s=8;s<e.length;){r[3]=e[s++],r[2]=e[s++],r[1]=e[s++],r[0]=e[s++];var c=a[0]+4,l=new Uint8Array(c);l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++];var u=String.fromCharCode(l[0])+String.fromCharCode(l[1])+String.fromCharCode(l[2])+String.fromCharCode(l[3]);if(!o.length&&u!==`IHDR`)throw Error(`IHDR header missing`);if(u===`IEND`){t=!0,o.push({name:u,data:new Uint8Array});break}for(var d=4;d<c;d++)l[d]=e[s++];r[3]=e[s++],r[2]=e[s++],r[1]=e[s++],r[0]=e[s++];var f=i[0];if(n.buf(l)!==f)throw Error(`CRC values for `+u+` header do not match, PNG file is likely corrupted`);var p=new Uint8Array(l.buffer.slice(4));o.push({name:u,data:p})}if(!t)throw Error(`.png file ended prematurely: no IEND header was found`);return o}})),u=t(((e,t)=>{t.exports=n;function n(e,t){if(e=String(e),t=String(t),!/^[\x00-\xFF]+$/.test(e)||!/^[\x00-\xFF]+$/.test(t))throw Error(`Only Latin-1 characters are permitted in PNG tEXt chunks. You might want to consider base64 encoding and/or zEXt compression`);if(e.length>=80)throw Error(`Keyword "`+e+`" is longer than the 79-character limit imposed by the PNG specification`);for(var n=e.length+t.length+1,r=new Uint8Array(n),i=0,a,o=0;o<e.length;o++){if(!(a=e.charCodeAt(o)))throw Error(`0x00 character is not permitted in tEXt keywords`);r[i++]=a}r[i++]=0;for(var s=0;s<t.length;s++){if(!(a=t.charCodeAt(s)))throw Error(`0x00 character is not permitted in tEXt content`);r[i++]=a}return{name:`tEXt`,data:r}}})),d=t(((e,t)=>{t.exports=n;function n(e){e.data&&e.name&&(e=e.data);for(var t=!0,n=``,r=``,i=0;i<e.length;i++){var a=e[i];if(t)a?r+=String.fromCharCode(a):t=!1;else if(a)n+=String.fromCharCode(a);else throw Error(`Invalid NULL character found. 0x00 character is not permitted in tEXt content`)}return{keyword:r,text:n}}})),f=t((e=>{e.encode=u(),e.decode=d()})),p=t(((e,t)=>{t.exports=function(e,t,n){var r=[],i=e.length;if(i===0)return r;var a=t<0?Math.max(0,t+i):t||0;for(n!==void 0&&(i=n<0?n+i:n);i-->a;)r[i-a]=e[i];return r}})),m=t(((e,t)=>{var n=p(),r=c();t.exports=s;var i=new Uint8Array(4),a=new Int32Array(i.buffer),o=new Uint32Array(i.buffer);function s(e){var t=8,s=t,c;for(c=0;c<e.length;c++)t+=e[c].data.length,t+=12;var l=new Uint8Array(t);for(l[0]=137,l[1]=80,l[2]=78,l[3]=71,l[4]=13,l[5]=10,l[6]=26,l[7]=10,c=0;c<e.length;c++){var u=e[c],d=u.name,f=u.data,p=f.length,m=[d.charCodeAt(0),d.charCodeAt(1),d.charCodeAt(2),d.charCodeAt(3)];o[0]=p,l[s++]=i[3],l[s++]=i[2],l[s++]=i[1],l[s++]=i[0],l[s++]=m[0],l[s++]=m[1],l[s++]=m[2],l[s++]=m[3];for(var h=0;h<p;)l[s++]=f[h++];var g=m.concat(n(f));a[0]=r.buf(g),l[s++]=i[3],l[s++]=i[2],l[s++]=i[1],l[s++]=i[0]}return l}})),h=e(l(),1),g=e(f(),1),_=e(m(),1),v=4,y=0,b=1,x=2;function S(e){let t=e.length;for(;--t>=0;)e[t]=0}var C=29,w=256,T=286,E=30,D=19,ee=573,te=15,ne=16,re=7,ie=256,ae=16,oe=17,se=18,ce=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]),le=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]),ue=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),de=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fe=512,pe=Array(576);S(pe);var me=Array(60);S(me);var he=Array(fe);S(he);var ge=Array(256);S(ge);var _e=Array(C);S(_e);var ve=Array(E);S(ve);function ye(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}var be,xe,Se;function Ce(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var we=e=>e<256?he[e]:he[256+(e>>>7)],Te=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},Ee=(e,t,n)=>{e.bi_valid>ne-n?(e.bi_buf|=t<<e.bi_valid&65535,Te(e,e.bi_buf),e.bi_buf=t>>ne-e.bi_valid,e.bi_valid+=n-ne):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},De=(e,t,n)=>{Ee(e,n[t*2],n[t*2+1])},Oe=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},ke=e=>{e.bi_valid===16?(Te(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)},Ae=(e,t)=>{let n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,d,f,p,m,h=0;for(f=0;f<=te;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<ee;l++)u=e.heap[l],f=n[n[u*2+1]*2+1]+1,f>c&&(f=c,h++),n[u*2+1]=f,!(u>r)&&(e.bl_count[f]++,p=0,u>=s&&(p=o[u-s]),m=n[u*2],e.opt_len+=m*(f+p),a&&(e.static_len+=m*(i[u*2+1]+p)));if(h!==0){do{for(f=c-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(f=c;f!==0;f--)for(u=e.bl_count[f];u!==0;)d=e.heap[--l],!(d>r)&&(n[d*2+1]!==f&&(e.opt_len+=(f-n[d*2+1])*n[d*2],n[d*2+1]=f),u--)}},je=(e,t,n)=>{let r=Array(16),i=0,a,o;for(a=1;a<=te;a++)r[a]=i=i+n[a-1]<<1;for(o=0;o<=t;o++){let t=e[o*2+1];t!==0&&(e[o*2]=Oe(r[t]++,t))}},Me=()=>{let e,t,n,r,i,a=Array(16);for(n=0,r=0;r<28;r++)for(_e[r]=n,e=0;e<1<<ce[r];e++)ge[n++]=r;for(ge[n-1]=r,i=0,r=0;r<16;r++)for(ve[r]=i,e=0;e<1<<le[r];e++)he[i++]=r;for(i>>=7;r<E;r++)for(ve[r]=i<<7,e=0;e<1<<le[r]-7;e++)he[256+i++]=r;for(t=0;t<=te;t++)a[t]=0;for(e=0;e<=143;)pe[e*2+1]=8,e++,a[8]++;for(;e<=255;)pe[e*2+1]=9,e++,a[9]++;for(;e<=279;)pe[e*2+1]=7,e++,a[7]++;for(;e<=287;)pe[e*2+1]=8,e++,a[8]++;for(je(pe,287,a),e=0;e<E;e++)me[e*2+1]=5,me[e*2]=Oe(e,5);be=new ye(pe,ce,257,T,te),xe=new ye(me,le,0,E,te),Se=new ye([],ue,0,D,re)},Ne=e=>{let t;for(t=0;t<T;t++)e.dyn_ltree[t*2]=0;for(t=0;t<E;t++)e.dyn_dtree[t*2]=0;for(t=0;t<D;t++)e.bl_tree[t*2]=0;e.dyn_ltree[ie*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},Pe=e=>{e.bi_valid>8?Te(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Fe=(e,t,n,r)=>{Pe(e),r&&(Te(e,n),Te(e,~n)),e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},Ie=(e,t,n,r)=>{let i=t*2,a=n*2;return e[i]<e[a]||e[i]===e[a]&&r[t]<=r[n]},Le=(e,t,n)=>{let r=e.heap[n],i=n<<1;for(;i<=e.heap_len&&(i<e.heap_len&&Ie(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!Ie(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r},Re=(e,t,n)=>{let r,i,a=0,o,s;if(e.last_lit!==0)do r=e.pending_buf[e.d_buf+a*2]<<8|e.pending_buf[e.d_buf+a*2+1],i=e.pending_buf[e.l_buf+a],a++,r===0?De(e,i,t):(o=ge[i],De(e,o+w+1,t),s=ce[o],s!==0&&(i-=_e[o],Ee(e,i,s)),r--,o=we(r),De(e,o,n),s=le[o],s!==0&&(r-=ve[o],Ee(e,r,s)));while(a<e.last_lit);De(e,ie,t)},ze=(e,t)=>{let n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,c=-1,l;for(e.heap_len=0,e.heap_max=ee,o=0;o<a;o++)n[o*2]===0?n[o*2+1]=0:(e.heap[++e.heap_len]=c=o,e.depth[o]=0);for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,n[l*2]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=r[l*2+1]);for(t.max_code=c,o=e.heap_len>>1;o>=1;o--)Le(e,n,o);l=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Le(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[l*2]=n[o*2]+n[s*2],e.depth[l]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[o*2+1]=n[s*2+1]=l,e.heap[1]=l++,Le(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Ae(e,t),je(n,c,e.bl_count)},Be=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)&&(s<l?e.bl_tree[a*2]+=s:a===0?s<=10?e.bl_tree[34]++:e.bl_tree[36]++:(a!==i&&e.bl_tree[a*2]++,e.bl_tree[32]++),s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4))},Ve=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),r=0;r<=n;r++)if(a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)){if(s<l)do De(e,a,e.bl_tree);while(--s!==0);else a===0?s<=10?(De(e,oe,e.bl_tree),Ee(e,s-3,3)):(De(e,se,e.bl_tree),Ee(e,s-11,7)):(a!==i&&(De(e,a,e.bl_tree),s--),De(e,ae,e.bl_tree),Ee(e,s-3,2));s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4)}},He=e=>{let t;for(Be(e,e.dyn_ltree,e.l_desc.max_code),Be(e,e.dyn_dtree,e.d_desc.max_code),ze(e,e.bl_desc),t=18;t>=3&&e.bl_tree[de[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},Ue=(e,t,n,r)=>{let i;for(Ee(e,t-257,5),Ee(e,n-1,5),Ee(e,r-4,4),i=0;i<r;i++)Ee(e,e.bl_tree[de[i]*2+1],3);Ve(e,e.dyn_ltree,t-1),Ve(e,e.dyn_dtree,n-1)},We=e=>{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return y;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return b;for(n=32;n<w;n++)if(e.dyn_ltree[n*2]!==0)return b;return y},Ge=!1,Ke=e=>{Ge||=(Me(),!0),e.l_desc=new Ce(e.dyn_ltree,be),e.d_desc=new Ce(e.dyn_dtree,xe),e.bl_desc=new Ce(e.bl_tree,Se),e.bi_buf=0,e.bi_valid=0,Ne(e)},qe=(e,t,n,r)=>{Ee(e,0+ +!!r,3),Fe(e,t,n,!0)},Je={_tr_init:Ke,_tr_stored_block:qe,_tr_flush_block:(e,t,n,r)=>{let i,a,o=0;e.level>0?(e.strm.data_type===x&&(e.strm.data_type=We(e)),ze(e,e.l_desc),ze(e,e.d_desc),o=He(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=n+5,n+4<=i&&t!==-1?qe(e,t,n,r):e.strategy===v||a===i?(Ee(e,2+ +!!r,3),Re(e,pe,me)):(Ee(e,4+ +!!r,3),Ue(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),Re(e,e.dyn_ltree,e.dyn_dtree)),Ne(e),r&&Pe(e)},_tr_tally:(e,t,n)=>(e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(ge[n]+w+1)*2]++,e.dyn_dtree[we(t)*2]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{Ee(e,2,3),De(e,ie,pe),ke(e)}},Ye=(e,t,n,r)=>{let i=e&65535|0,a=e>>>16&65535|0,o=0;for(;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+t[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0},Xe=new Uint32Array((()=>{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})()),Ze=(e,t,n,r)=>{let i=Xe,a=r+n;e^=-1;for(let n=r;n<a;n++)e=e>>>8^i[(e^t[n])&255];return e^-1},Qe={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`},$e={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},{_tr_init:et,_tr_stored_block:tt,_tr_flush_block:nt,_tr_tally:rt,_tr_align:it}=Je,{Z_NO_FLUSH:at,Z_PARTIAL_FLUSH:ot,Z_FULL_FLUSH:st,Z_FINISH:ct,Z_BLOCK:lt,Z_OK:ut,Z_STREAM_END:dt,Z_STREAM_ERROR:ft,Z_DATA_ERROR:pt,Z_BUF_ERROR:mt,Z_DEFAULT_COMPRESSION:ht,Z_FILTERED:gt,Z_HUFFMAN_ONLY:_t,Z_RLE:vt,Z_FIXED:yt,Z_DEFAULT_STRATEGY:bt,Z_UNKNOWN:xt,Z_DEFLATED:St}=$e,Ct=9,wt=15,Tt=8,Et=573,Dt=3,Ot=258,kt=262,At=32,jt=42,Mt=69,Nt=73,Pt=91,Ft=103,It=113,Lt=666,Rt=1,zt=2,Bt=3,Vt=4,Ht=3,Ut=(e,t)=>(e.msg=Qe[t],t),Wt=e=>(e<<1)-(e>4?9:0),Gt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Kt=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask,qt=e=>{let t=e.state,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))},Jt=(e,t)=>{nt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,qt(e.strm)},O=(e,t)=>{e.pending_buf[e.pending++]=t},Yt=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Xt=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=Ye(e.adler,t,i,n):e.state.wrap===2&&(e.adler=Ze(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},Zt=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-kt?e.strstart-(e.w_size-kt):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+Ot,p=l[r+o-1],m=l[r+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do if(i=t,l[i+o]===m&&l[i+o-1]===p&&l[i]===l[r]&&l[++i]===l[r+1]){r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<f);if(a=Ot-(f-r),r=f-Ot,a>o){if(e.match_start=t,o=a,a>=s)break;p=l[r+o-1],m=l[r+o]}}while((t=d[t&u])>c&&--n!==0);return o<=e.lookahead?o:e.lookahead},Qt=e=>{let t=e.w_size,n,r,i,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-kt)){e.window.set(e.window.subarray(t,t+t),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,n=r;do i=e.head[--n],e.head[n]=i>=t?i-t:0;while(--r);r=t,n=r;do i=e.prev[--n],e.prev[n]=i>=t?i-t:0;while(--r);a+=t}if(e.strm.avail_in===0)break;if(r=Xt(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=r,e.lookahead+e.insert>=Dt)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=Kt(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=Kt(e,e.ins_h,e.window[o+Dt-1]),e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<Dt)););}while(e.lookahead<kt&&e.strm.avail_in!==0)},$t=(e,t)=>{let n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Qt(e),e.lookahead===0&&t===at)return Rt;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;let r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,Jt(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-kt&&(Jt(e,!1),e.strm.avail_out===0))return Rt}return e.insert=0,t===ct?(Jt(e,!0),e.strm.avail_out===0?Bt:Vt):(e.strstart>e.block_start&&(Jt(e,!1),e.strm.avail_out),Rt)},en=(e,t)=>{let n,r;for(;;){if(e.lookahead<kt){if(Qt(e),e.lookahead<kt&&t===at)return Rt;if(e.lookahead===0)break}if(n=0,e.lookahead>=Dt&&(e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+Dt-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-kt&&(e.match_length=Zt(e,n)),e.match_length>=Dt){if(r=rt(e,e.strstart-e.match_start,e.match_length-Dt),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Dt){e.match_length--;do e.strstart++,e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+Dt-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=Kt(e,e.ins_h,e.window[e.strstart+1])}else r=rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Jt(e,!1),e.strm.avail_out===0))return Rt}return e.insert=e.strstart<2?e.strstart:2,t===ct?(Jt(e,!0),e.strm.avail_out===0?Bt:Vt):e.last_lit&&(Jt(e,!1),e.strm.avail_out===0)?Rt:zt},tn=(e,t)=>{let n,r,i;for(;;){if(e.lookahead<kt){if(Qt(e),e.lookahead<kt&&t===at)return Rt;if(e.lookahead===0)break}if(n=0,e.lookahead>=Dt&&(e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+Dt-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=2,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-kt&&(e.match_length=Zt(e,n),e.match_length<=5&&(e.strategy===gt||e.match_length===Dt&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=Dt&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-Dt,r=rt(e,e.strstart-1-e.prev_match,e.prev_length-Dt),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+Dt-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=2,e.strstart++,r&&(Jt(e,!1),e.strm.avail_out===0))return Rt}else if(e.match_available){if(r=rt(e,0,e.window[e.strstart-1]),r&&Jt(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Rt}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&=(r=rt(e,0,e.window[e.strstart-1]),0),e.insert=e.strstart<2?e.strstart:2,t===ct?(Jt(e,!0),e.strm.avail_out===0?Bt:Vt):e.last_lit&&(Jt(e,!1),e.strm.avail_out===0)?Rt:zt},nn=(e,t)=>{let n,r,i,a,o=e.window;for(;;){if(e.lookahead<=Ot){if(Qt(e),e.lookahead<=Ot&&t===at)return Rt;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Dt&&e.strstart>0&&(i=e.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){a=e.strstart+Ot;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<a);e.match_length=Ot-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Dt?(n=rt(e,1,e.match_length-Dt),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Jt(e,!1),e.strm.avail_out===0))return Rt}return e.insert=0,t===ct?(Jt(e,!0),e.strm.avail_out===0?Bt:Vt):e.last_lit&&(Jt(e,!1),e.strm.avail_out===0)?Rt:zt},rn=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(Qt(e),e.lookahead===0)){if(t===at)return Rt;break}if(e.match_length=0,n=rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Jt(e,!1),e.strm.avail_out===0))return Rt}return e.insert=0,t===ct?(Jt(e,!0),e.strm.avail_out===0?Bt:Vt):e.last_lit&&(Jt(e,!1),e.strm.avail_out===0)?Rt:zt};function an(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}var on=[new an(0,0,0,0,$t),new an(4,4,8,4,en),new an(4,5,16,8,en),new an(4,6,32,32,en),new an(4,4,16,16,tn),new an(8,16,32,32,tn),new an(8,16,128,128,tn),new an(8,32,128,256,tn),new an(32,128,258,1024,tn),new an(32,258,258,4096,tn)],sn=e=>{e.window_size=2*e.w_size,Gt(e.head),e.max_lazy_match=on[e.level].max_lazy,e.good_match=on[e.level].good_length,e.nice_match=on[e.level].nice_length,e.max_chain_length=on[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0};function cn(){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=St,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(Et*2),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Gt(this.dyn_ltree),Gt(this.dyn_dtree),Gt(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),Gt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Gt(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}var ln=e=>{if(!e||!e.state)return Ut(e,ft);e.total_in=e.total_out=0,e.data_type=xt;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?jt:It,e.adler=t.wrap===2?0:1,t.last_flush=at,et(t),ut},un=e=>{let t=ln(e);return t===ut&&sn(e.state),t},dn=(e,t)=>!e||!e.state||e.state.wrap!==2?ft:(e.state.gzhead=t,ut),fn=(e,t,n,r,i,a)=>{if(!e)return ft;let o=1;if(t===ht&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>Ct||n!==St||r<8||r>15||t<0||t>9||a<0||a>yt)return Ut(e,ft);r===8&&(r=9);let s=new cn;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=r,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+Dt-1)/Dt),s.window=new Uint8Array(s.w_size*2),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Uint8Array(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=a,s.method=n,un(e)},pn={deflateInit:(e,t)=>fn(e,t,St,wt,Tt,bt),deflateInit2:fn,deflateReset:un,deflateResetKeep:ln,deflateSetHeader:dn,deflate:(e,t)=>{let n,r;if(!e||!e.state||t>lt||t<0)return e?Ut(e,ft):ft;let i=e.state;if(!e.output||!e.input&&e.avail_in!==0||i.status===Lt&&t!==ct)return Ut(e,e.avail_out===0?mt:ft);i.strm=e;let a=i.last_flush;if(i.last_flush=t,i.status===jt){if(i.wrap===2)e.adler=0,O(i,31),O(i,139),O(i,8),i.gzhead?(O(i,+!!i.gzhead.text+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),O(i,i.gzhead.time&255),O(i,i.gzhead.time>>8&255),O(i,i.gzhead.time>>16&255),O(i,i.gzhead.time>>24&255),O(i,i.level===9?2:i.strategy>=_t||i.level<2?4:0),O(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(O(i,i.gzhead.extra.length&255),O(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=Ze(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=Mt):(O(i,0),O(i,0),O(i,0),O(i,0),O(i,0),O(i,i.level===9?2:i.strategy>=_t||i.level<2?4:0),O(i,Ht),i.status=It);else{let t=St+(i.w_bits-8<<4)<<8,n=-1;n=i.strategy>=_t||i.level<2?0:i.level<6?1:i.level===6?2:3,t|=n<<6,i.strstart!==0&&(t|=At),t+=31-t%31,i.status=It,Yt(i,t),i.strstart!==0&&(Yt(i,e.adler>>>16),Yt(i,e.adler&65535)),e.adler=1}}if(i.status===Mt){if(i.gzhead.extra){for(n=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ze(e.adler,i.pending_buf,i.pending-n,n)),qt(e),n=i.pending,i.pending===i.pending_buf_size));)O(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(e.adler=Ze(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=Nt)}else i.status=Nt}if(i.status===Nt){if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ze(e.adler,i.pending_buf,i.pending-n,n)),qt(e),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindex<i.gzhead.name.length?i.gzhead.name.charCodeAt(i.gzindex++)&255:0,O(i,r)}while(r!==0);i.gzhead.hcrc&&i.pending>n&&(e.adler=Ze(e.adler,i.pending_buf,i.pending-n,n)),r===0&&(i.gzindex=0,i.status=Pt)}else i.status=Pt}if(i.status===Pt){if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ze(e.adler,i.pending_buf,i.pending-n,n)),qt(e),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindex<i.gzhead.comment.length?i.gzhead.comment.charCodeAt(i.gzindex++)&255:0,O(i,r)}while(r!==0);i.gzhead.hcrc&&i.pending>n&&(e.adler=Ze(e.adler,i.pending_buf,i.pending-n,n)),r===0&&(i.status=Ft)}else i.status=Ft}if(i.status===Ft&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&qt(e),i.pending+2<=i.pending_buf_size&&(O(i,e.adler&255),O(i,e.adler>>8&255),e.adler=0,i.status=It)):i.status=It),i.pending!==0){if(qt(e),e.avail_out===0)return i.last_flush=-1,ut}else if(e.avail_in===0&&Wt(t)<=Wt(a)&&t!==ct)return Ut(e,mt);if(i.status===Lt&&e.avail_in!==0)return Ut(e,mt);if(e.avail_in!==0||i.lookahead!==0||t!==at&&i.status!==Lt){let n=i.strategy===_t?rn(i,t):i.strategy===vt?nn(i,t):on[i.level].func(i,t);if((n===Bt||n===Vt)&&(i.status=Lt),n===Rt||n===Bt)return e.avail_out===0&&(i.last_flush=-1),ut;if(n===zt&&(t===ot?it(i):t!==lt&&(tt(i,0,0,!1),t===st&&(Gt(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),qt(e),e.avail_out===0))return i.last_flush=-1,ut}return t===ct?i.wrap<=0?dt:(i.wrap===2?(O(i,e.adler&255),O(i,e.adler>>8&255),O(i,e.adler>>16&255),O(i,e.adler>>24&255),O(i,e.total_in&255),O(i,e.total_in>>8&255),O(i,e.total_in>>16&255),O(i,e.total_in>>24&255)):(Yt(i,e.adler>>>16),Yt(i,e.adler&65535)),qt(e),i.wrap>0&&(i.wrap=-i.wrap),i.pending===0?dt:ut):ut},deflateEnd:e=>{if(!e||!e.state)return ft;let t=e.state.status;return t!==jt&&t!==Mt&&t!==Nt&&t!==Pt&&t!==Ft&&t!==It&&t!==Lt?Ut(e,ft):(e.state=null,t===It?Ut(e,pt):ut)},deflateSetDictionary:(e,t)=>{let n=t.length;if(!e||!e.state)return ft;let r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==jt||r.lookahead)return ft;if(i===1&&(e.adler=Ye(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(Gt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}let a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Qt(r);r.lookahead>=Dt;){let e=r.strstart,t=r.lookahead-2;do r.ins_h=Kt(r,r.ins_h,r.window[e+Dt-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++;while(--t);r.strstart=e,r.lookahead=2,Qt(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,r.wrap=i,ut},deflateInfo:`pako deflate (from Nodeca project)`},mn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),hn={assign:function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let n=t.shift();if(n){if(typeof n!=`object`)throw TypeError(n+`must be non-object`);for(let t in n)mn(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].length;let n=new Uint8Array(t);for(let t=0,r=0,i=e.length;t<i;t++){let i=e[t];n.set(i,r),r+=i.length}return n}},gn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{gn=!1}var _n=new Uint8Array(256);for(let e=0;e<256;e++)_n[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;_n[254]=_n[254]=1;var vn=e=>{let t,n,r,i,a,o=e.length,s=0;for(i=0;i<o;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(s),a=0,i=0;a<s;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?t[a++]=n:n<2048?(t[a++]=192|n>>>6,t[a++]=128|n&63):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|n&63):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|n&63);return t},yn=(e,t)=>{if(t<65534&&e.subarray&&gn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n=``;for(let r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n},bn={string2buf:vn,buf2string:(e,t)=>{let n,r,i=t||e.length,a=Array(i*2);for(r=0,n=0;n<i;){let t=e[n++];if(t<128){a[r++]=t;continue}let o=_n[t];if(o>4){a[r++]=65533,n+=o-1;continue}for(t&=o===2?31:o===3?15:7;o>1&&n<i;)t=t<<6|e[n++]&63,o--;if(o>1){a[r++]=65533;continue}t<65536?a[r++]=t:(t-=65536,a[r++]=55296|t>>10&1023,a[r++]=56320|t&1023)}return yn(a,r)},utf8border:(e,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+_n[e[n]]>t?n:t}};function xn(){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 Sn=xn,Cn=Object.prototype.toString,{Z_NO_FLUSH:wn,Z_SYNC_FLUSH:Tn,Z_FULL_FLUSH:En,Z_FINISH:Dn,Z_OK:On,Z_STREAM_END:kn,Z_DEFAULT_COMPRESSION:An,Z_DEFAULT_STRATEGY:jn,Z_DEFLATED:Mn}=$e;function Nn(e){this.options=hn.assign({level:An,method:Mn,chunkSize:16384,windowBits:15,memLevel:8,strategy:jn},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 Sn,this.strm.avail_out=0;let n=pn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==On)throw Error(Qe[n]);if(t.header&&pn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e=typeof t.dictionary==`string`?bn.string2buf(t.dictionary):Cn.call(t.dictionary)===`[object ArrayBuffer]`?new Uint8Array(t.dictionary):t.dictionary,n=pn.deflateSetDictionary(this.strm,e),n!==On)throw Error(Qe[n]);this._dict_set=!0}}Nn.prototype.push=function(e,t){let n=this.strm,r=this.options.chunkSize,i,a;if(this.ended)return!1;for(a=t===~~t?t:t===!0?Dn:wn,n.input=typeof e==`string`?bn.string2buf(e):Cn.call(e)===`[object ArrayBuffer]`?new Uint8Array(e):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),(a===Tn||a===En)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=pn.deflate(n,a),i===kn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=pn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===On;if(n.avail_out===0){this.onData(n.output);continue}if(a>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},Nn.prototype.onData=function(e){this.chunks.push(e)},Nn.prototype.onEnd=function(e){e===On&&(this.result=hn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Pn(e,t){let n=new Nn(t);if(n.push(e,!0),n.err)throw n.msg||Qe[n.err];return n.result}function Fn(e,t){return t||={},t.raw=!0,Pn(e,t)}function In(e,t){return t||={},t.gzip=!0,Pn(e,t)}var Ln={Deflate:Nn,deflate:Pn,deflateRaw:Fn,gzip:In,constants:$e},Rn=30,zn=12,Bn=function(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),i=e.next_out,T=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=E.dmax,c=E.wsize,l=E.whave,u=E.wnext,d=E.window,f=E.hold,p=E.bits,m=E.lencode,h=E.distcode,g=(1<<E.lenbits)-1,_=(1<<E.distbits)-1;top:do{p<15&&(f+=w[n++]<<p,p+=8,f+=w[n++]<<p,p+=8),v=m[f&g];dolen:for(;;){if(y=v>>>24,f>>>=y,p-=y,y=v>>>16&255,y===0)T[i++]=v&65535;else if(y&16){b=v&65535,y&=15,y&&(p<y&&(f+=w[n++]<<p,p+=8),b+=f&(1<<y)-1,f>>>=y,p-=y),p<15&&(f+=w[n++]<<p,p+=8,f+=w[n++]<<p,p+=8),v=h[f&_];dodist:for(;;){if(y=v>>>24,f>>>=y,p-=y,y=v>>>16&255,y&16){if(x=v&65535,y&=15,p<y&&(f+=w[n++]<<p,p+=8,p<y&&(f+=w[n++]<<p,p+=8)),x+=f&(1<<y)-1,x>s){e.msg=`invalid distance too far back`,E.mode=Rn;break top}if(f>>>=y,p-=y,y=i-a,x>y){if(y=x-y,y>l&&E.sane){e.msg=`invalid distance too far back`,E.mode=Rn;break top}if(S=0,C=d,u===0){if(S+=c-y,y<b){b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}}else if(u<y){if(S+=c+u-y,y-=u,y<b){b-=y;do T[i++]=d[S++];while(--y);if(S=0,u<b){y=u,b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}}}else if(S+=u-y,y<b){b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}for(;b>2;)T[i++]=C[S++],T[i++]=C[S++],T[i++]=C[S++],b-=3;b&&(T[i++]=C[S++],b>1&&(T[i++]=C[S++]))}else{S=i-x;do T[i++]=T[S++],T[i++]=T[S++],T[i++]=T[S++],b-=3;while(b>2);b&&(T[i++]=T[S++],b>1&&(T[i++]=T[S++]))}}else if(y&64){e.msg=`invalid distance code`,E.mode=Rn;break top}else{v=h[(v&65535)+(f&(1<<y)-1)];continue dodist}break}}else if(!(y&64)){v=m[(v&65535)+(f&(1<<y)-1)];continue dolen}else if(y&32){E.mode=zn;break top}else{e.msg=`invalid literal/length code`,E.mode=Rn;break top}break}}while(n<r&&i<o);b=p>>3,n-=b,p-=b<<3,f&=(1<<p)-1,e.next_in=n,e.next_out=i,e.avail_in=n<r?5+(r-n):5-(n-r),e.avail_out=i<o?257+(o-i):257-(i-o),E.hold=f,E.bits=p},Vn=15,Hn=852,Un=592,Wn=0,Gn=1,Kn=2,qn=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]),Jn=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]),Yn=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]),Xn=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]),Zn=(e,t,n,r,i,a,o,s)=>{let c=s.bits,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y,b,x,S,C,w=null,T=0,E,D=new Uint16Array(16),ee=new Uint16Array(16),te=null,ne=0,re,ie,ae;for(l=0;l<=Vn;l++)D[l]=0;for(u=0;u<r;u++)D[t[n+u]]++;for(p=c,f=Vn;f>=1&&D[f]===0;f--);if(p>f&&(p=f),f===0)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(d=1;d<f&&D[d]===0;d++);for(p<d&&(p=d),g=1,l=1;l<=Vn;l++)if(g<<=1,g-=D[l],g<0)return-1;if(g>0&&(e===Wn||f!==1))return-1;for(ee[1]=0,l=1;l<Vn;l++)ee[l+1]=ee[l]+D[l];for(u=0;u<r;u++)t[n+u]!==0&&(o[ee[t[n+u]]++]=u);if(e===Wn?(w=te=o,E=19):e===Gn?(w=qn,T-=257,te=Jn,ne-=257,E=256):(w=Yn,te=Xn,E=-1),v=0,u=0,l=d,C=a,m=p,h=0,x=-1,_=1<<p,S=_-1,e===Gn&&_>Hn||e===Kn&&_>Un)return 1;for(;;){re=l-h,o[u]<E?(ie=0,ae=o[u]):o[u]>E?(ie=te[ne+o[u]],ae=w[T+o[u]]):(ie=96,ae=0),y=1<<l-h,b=1<<m,d=b;do b-=y,i[C+(v>>h)+b]=re<<24|ie<<16|ae|0;while(b!==0);for(y=1<<l-1;v&y;)y>>=1;if(y===0?v=0:(v&=y-1,v+=y),u++,--D[l]===0){if(l===f)break;l=t[n+o[u]]}if(l>p&&(v&S)!==x){for(h===0&&(h=p),C+=d,m=l-h,g=1<<m;m+h<f&&(g-=D[m+h],!(g<=0));)m++,g<<=1;if(_+=1<<m,e===Gn&&_>Hn||e===Kn&&_>Un)return 1;x=v&S,i[x]=p<<24|m<<16|C-a|0}}return v!==0&&(i[C+v]=l-h<<24|4194304),s.bits=p,0},Qn=0,$n=1,er=2,{Z_FINISH:tr,Z_BLOCK:nr,Z_TREES:rr,Z_OK:ir,Z_STREAM_END:ar,Z_NEED_DICT:or,Z_STREAM_ERROR:sr,Z_DATA_ERROR:cr,Z_MEM_ERROR:lr,Z_BUF_ERROR:ur,Z_DEFLATED:dr}=$e,fr=1,pr=2,mr=3,hr=4,gr=5,_r=6,vr=7,yr=8,br=9,xr=10,Sr=11,Cr=12,wr=13,Tr=14,Er=15,Dr=16,Or=17,kr=18,Ar=19,jr=20,Mr=21,Nr=22,Pr=23,Fr=24,Ir=25,Lr=26,Rr=27,zr=28,Br=29,Vr=30,Hr=31,Ur=32,Wr=852,Gr=592,Kr=15,qr=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function Jr(){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}var Yr=e=>{if(!e||!e.state)return sr;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=``,t.wrap&&(e.adler=t.wrap&1),t.mode=fr,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Wr),t.distcode=t.distdyn=new Int32Array(Gr),t.sane=1,t.back=-1,ir},Xr=e=>{if(!e||!e.state)return sr;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Yr(e)},Zr=(e,t)=>{let n;if(!e||!e.state)return sr;let r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15)?sr:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Xr(e))},Qr=(e,t)=>{if(!e)return sr;let n=new Jr;e.state=n,n.window=null;let r=Zr(e,t);return r!==ir&&(e.state=null),r},$r=e=>Qr(e,Kr),ei=!0,ti,ni,ri=e=>{if(ei){ti=new Int32Array(512),ni=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(Zn($n,e.lens,0,288,ti,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Zn(er,e.lens,0,32,ni,0,e.work,{bits:5}),ei=!1}e.lencode=ti,e.lenbits=9,e.distcode=ni,e.distbits=5},ii=(e,t,n,r)=>{let i,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),r>=a.wsize?(a.window.set(t.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>r&&(i=r),a.window.set(t.subarray(n-r,n-r+i),a.wnext),r-=i,r?(a.window.set(t.subarray(n-r,n),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0},ai={inflateReset:Xr,inflateReset2:Zr,inflateResetKeep:Yr,inflateInit:$r,inflateInit2:Qr,inflate:(e,t)=>{let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g=0,_,v,y,b,x,S,C,w,T=new Uint8Array(4),E,D,ee=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return sr;n=e.state,n.mode===Cr&&(n.mode=wr),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,d=s,f=c,w=ir;inf_leave:for(;;)switch(n.mode){case fr:if(n.wrap===0){n.mode=wr;break}for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&2&&l===35615){n.check=0,T[0]=l&255,T[1]=l>>>8&255,n.check=Ze(n.check,T,2,0),l=0,u=0,n.mode=pr;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg=`incorrect header check`,n.mode=Vr;break}if((l&15)!==dr){e.msg=`unknown compression method`,n.mode=Vr;break}if(l>>>=4,u-=4,C=(l&15)+8,n.wbits===0)n.wbits=C;else if(C>n.wbits){e.msg=`invalid window size`,n.mode=Vr;break}n.dmax=1<<n.wbits,e.adler=n.check=1,n.mode=l&512?xr:Cr,l=0,u=0;break;case pr:for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.flags=l,(n.flags&255)!==dr){e.msg=`unknown compression method`,n.mode=Vr;break}if(n.flags&57344){e.msg=`unknown header flags set`,n.mode=Vr;break}n.head&&(n.head.text=l>>8&1),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=Ze(n.check,T,2,0)),l=0,u=0,n.mode=mr;case mr:for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.head&&(n.head.time=l),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,T[2]=l>>>16&255,T[3]=l>>>24&255,n.check=Ze(n.check,T,4,0)),l=0,u=0,n.mode=hr;case hr:for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.head&&(n.head.xflags=l&255,n.head.os=l>>8),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=Ze(n.check,T,2,0)),l=0,u=0,n.mode=gr;case gr:if(n.flags&1024){for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.length=l,n.head&&(n.head.extra_len=l),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=Ze(n.check,T,2,0)),l=0,u=0}else n.head&&(n.head.extra=null);n.mode=_r;case _r:if(n.flags&1024&&(p=n.length,p>s&&(p=s),p&&(n.head&&(C=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(a,a+p),C)),n.flags&512&&(n.check=Ze(n.check,r,p,a)),s-=p,a+=p,n.length-=p),n.length))break inf_leave;n.length=0,n.mode=vr;case vr:if(n.flags&2048){if(s===0)break inf_leave;p=0;do C=r[a+p++],n.head&&C&&n.length<65536&&(n.head.name+=String.fromCharCode(C));while(C&&p<s);if(n.flags&512&&(n.check=Ze(n.check,r,p,a)),s-=p,a+=p,C)break inf_leave}else n.head&&(n.head.name=null);n.length=0,n.mode=yr;case yr:if(n.flags&4096){if(s===0)break inf_leave;p=0;do C=r[a+p++],n.head&&C&&n.length<65536&&(n.head.comment+=String.fromCharCode(C));while(C&&p<s);if(n.flags&512&&(n.check=Ze(n.check,r,p,a)),s-=p,a+=p,C)break inf_leave}else n.head&&(n.head.comment=null);n.mode=br;case br:if(n.flags&512){for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(l!==(n.check&65535)){e.msg=`header crc mismatch`,n.mode=Vr;break}l=0,u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Cr;break;case xr:for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}e.adler=n.check=qr(l),l=0,u=0,n.mode=Sr;case Sr:if(n.havedict===0)return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,or;e.adler=n.check=1,n.mode=Cr;case Cr:if(t===nr||t===rr)break inf_leave;case wr:if(n.last){l>>>=u&7,u-=u&7,n.mode=Rr;break}for(;u<3;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}switch(n.last=l&1,l>>>=1,--u,l&3){case 0:n.mode=Tr;break;case 1:if(ri(n),n.mode=jr,t===rr){l>>>=2,u-=2;break inf_leave}break;case 2:n.mode=Or;break;case 3:e.msg=`invalid block type`,n.mode=Vr}l>>>=2,u-=2;break;case Tr:for(l>>>=u&7,u-=u&7;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if((l&65535)!=(l>>>16^65535)){e.msg=`invalid stored block lengths`,n.mode=Vr;break}if(n.length=l&65535,l=0,u=0,n.mode=Er,t===rr)break inf_leave;case Er:n.mode=Dr;case Dr:if(p=n.length,p){if(p>s&&(p=s),p>c&&(p=c),p===0)break inf_leave;i.set(r.subarray(a,a+p),o),s-=p,a+=p,c-=p,o+=p,n.length-=p;break}n.mode=Cr;break;case Or:for(;u<14;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.nlen=(l&31)+257,l>>>=5,u-=5,n.ndist=(l&31)+1,l>>>=5,u-=5,n.ncode=(l&15)+4,l>>>=4,u-=4,n.nlen>286||n.ndist>30){e.msg=`too many length or distance symbols`,n.mode=Vr;break}n.have=0,n.mode=kr;case kr:for(;n.have<n.ncode;){for(;u<3;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.lens[ee[n.have++]]=l&7,l>>>=3,u-=3}for(;n.have<19;)n.lens[ee[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},w=Zn(Qn,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,w){e.msg=`invalid code lengths set`,n.mode=Vr;break}n.have=0,n.mode=Ar;case Ar:for(;n.have<n.nlen+n.ndist;){for(;g=n.lencode[l&(1<<n.lenbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(y<16)l>>>=_,u-=_,n.lens[n.have++]=y;else{if(y===16){for(D=_+2;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(l>>>=_,u-=_,n.have===0){e.msg=`invalid bit length repeat`,n.mode=Vr;break}C=n.lens[n.have-1],p=3+(l&3),l>>>=2,u-=2}else if(y===17){for(D=_+3;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,C=0,p=3+(l&7),l>>>=3,u-=3}else{for(D=_+7;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,C=0,p=11+(l&127),l>>>=7,u-=7}if(n.have+p>n.nlen+n.ndist){e.msg=`invalid bit length repeat`,n.mode=Vr;break}for(;p--;)n.lens[n.have++]=C}}if(n.mode===Vr)break;if(n.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,n.mode=Vr;break}if(n.lenbits=9,E={bits:n.lenbits},w=Zn($n,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,w){e.msg=`invalid literal/lengths set`,n.mode=Vr;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},w=Zn(er,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,w){e.msg=`invalid distances set`,n.mode=Vr;break}if(n.mode=jr,t===rr)break inf_leave;case jr:n.mode=Mr;case Mr:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,Bn(e,f),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,n.mode===Cr&&(n.back=-1);break}for(n.back=0;g=n.lencode[l&(1<<n.lenbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(v&&!(v&240)){for(b=_,x=v,S=y;g=n.lencode[S+((l&(1<<b+x)-1)>>b)],_=g>>>24,v=g>>>16&255,y=g&65535,!(b+_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=b,u-=b,n.back+=b}if(l>>>=_,u-=_,n.back+=_,n.length=y,v===0){n.mode=Lr;break}if(v&32){n.back=-1,n.mode=Cr;break}if(v&64){e.msg=`invalid literal/length code`,n.mode=Vr;break}n.extra=v&15,n.mode=Nr;case Nr:if(n.extra){for(D=n.extra;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=Pr;case Pr:for(;g=n.distcode[l&(1<<n.distbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(!(v&240)){for(b=_,x=v,S=y;g=n.distcode[S+((l&(1<<b+x)-1)>>b)],_=g>>>24,v=g>>>16&255,y=g&65535,!(b+_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=b,u-=b,n.back+=b}if(l>>>=_,u-=_,n.back+=_,v&64){e.msg=`invalid distance code`,n.mode=Vr;break}n.offset=y,n.extra=v&15,n.mode=Fr;case Fr:if(n.extra){for(D=n.extra;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg=`invalid distance too far back`,n.mode=Vr;break}n.mode=Ir;case Ir:if(c===0)break inf_leave;if(p=f-c,n.offset>p){if(p=n.offset-p,p>n.whave&&n.sane){e.msg=`invalid distance too far back`,n.mode=Vr;break}p>n.wnext?(p-=n.wnext,m=n.wsize-p):m=n.wnext-p,p>n.length&&(p=n.length),h=n.window}else h=i,m=o-n.offset,p=n.length;p>c&&(p=c),c-=p,n.length-=p;do i[o++]=h[m++];while(--p);n.length===0&&(n.mode=Mr);break;case Lr:if(c===0)break inf_leave;i[o++]=n.length,c--,n.mode=Mr;break;case Rr:if(n.wrap){for(;u<32;){if(s===0)break inf_leave;s--,l|=r[a++]<<u,u+=8}if(f-=c,e.total_out+=f,n.total+=f,f&&(e.adler=n.check=n.flags?Ze(n.check,i,f,o-f):Ye(n.check,i,f,o-f)),f=c,(n.flags?l:qr(l))!==n.check){e.msg=`incorrect data check`,n.mode=Vr;break}l=0,u=0}n.mode=zr;case zr:if(n.wrap&&n.flags){for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(l!==(n.total&4294967295)){e.msg=`incorrect length check`,n.mode=Vr;break}l=0,u=0}n.mode=Br;case Br:w=ar;break inf_leave;case Vr:w=cr;break inf_leave;case Hr:return lr;case Ur:default:return sr}return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,(n.wsize||f!==e.avail_out&&n.mode<Vr&&(n.mode<Rr||t!==tr))&&ii(e,e.output,e.next_out,f-e.avail_out),d-=e.avail_in,f-=e.avail_out,e.total_in+=d,e.total_out+=f,n.total+=f,n.wrap&&f&&(e.adler=n.check=n.flags?Ze(n.check,i,f,e.next_out-f):Ye(n.check,i,f,e.next_out-f)),e.data_type=n.bits+(n.last?64:0)+(n.mode===Cr?128:0)+(n.mode===jr||n.mode===Er?256:0),(d===0&&f===0||t===tr)&&w===ir&&(w=ur),w},inflateEnd:e=>{if(!e||!e.state)return sr;let t=e.state;return t.window&&=null,e.state=null,ir},inflateGetHeader:(e,t)=>{if(!e||!e.state)return sr;let n=e.state;return n.wrap&2?(n.head=t,t.done=!1,ir):sr},inflateSetDictionary:(e,t)=>{let n=t.length,r,i,a;return!e||!e.state||(r=e.state,r.wrap!==0&&r.mode!==Sr)?sr:r.mode===Sr&&(i=1,i=Ye(i,t,n,0),i!==r.check)?cr:(a=ii(e,t,n,n),a?(r.mode=Hr,lr):(r.havedict=1,ir))},inflateInfo:`pako inflate (from Nodeca project)`};function oi(){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 si=oi,ci=Object.prototype.toString,{Z_NO_FLUSH:li,Z_FINISH:ui,Z_OK:di,Z_STREAM_END:fi,Z_NEED_DICT:pi,Z_STREAM_ERROR:mi,Z_DATA_ERROR:hi,Z_MEM_ERROR:gi}=$e;function _i(e){this.options=hn.assign({chunkSize:65536,windowBits:15,to:``},e||{});let 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 Sn,this.strm.avail_out=0;let n=ai.inflateInit2(this.strm,t.windowBits);if(n!==di||(this.header=new si,ai.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary==`string`?t.dictionary=bn.string2buf(t.dictionary):ci.call(t.dictionary)===`[object ArrayBuffer]`&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ai.inflateSetDictionary(this.strm,t.dictionary),n!==di))))throw Error(Qe[n])}_i.prototype.push=function(e,t){let n=this.strm,r=this.options.chunkSize,i=this.options.dictionary,a,o,s;if(this.ended)return!1;for(o=t===~~t?t:t===!0?ui:li,n.input=ci.call(e)===`[object ArrayBuffer]`?new Uint8Array(e):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),a=ai.inflate(n,o),a===pi&&i&&(a=ai.inflateSetDictionary(n,i),a===di?a=ai.inflate(n,o):a===hi&&(a=pi));n.avail_in>0&&a===fi&&n.state.wrap>0&&e[n.next_in]!==0;)ai.inflateReset(n),a=ai.inflate(n,o);switch(a){case mi:case hi:case pi:case gi:return this.onEnd(a),this.ended=!0,!1}if(s=n.avail_out,n.next_out&&(n.avail_out===0||a===fi)){if(this.options.to===`string`){let e=bn.utf8border(n.output,n.next_out),t=n.next_out-e,i=bn.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out))}if(a!==di||s!==0){if(a===fi)return a=ai.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(n.avail_in===0)break}}return!0},_i.prototype.onData=function(e){this.chunks.push(e)},_i.prototype.onEnd=function(e){e===di&&(this.result=this.options.to===`string`?this.chunks.join(``):hn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function vi(e,t){let n=new _i(t);if(n.push(e),n.err)throw n.msg||Qe[n.err];return n.result}function yi(e,t){return t||={},t.raw=!0,vi(e,t)}var bi={Inflate:_i,inflate:vi,inflateRaw:yi,ungzip:vi,constants:$e},{Deflate:xi,deflate:Si,deflateRaw:Ci,gzip:wi}=Ln,{Inflate:Ti,inflate:Ei,inflateRaw:Di,ungzip:Oi}=bi,ki=Si,Ai=Ei,ji={white:`#ffffff`,black:`#000000`,gray:[`#f8f9fa`,`#f1f3f5`,`#e9ecef`,`#dee2e6`,`#ced4da`,`#adb5bd`,`#868e96`,`#495057`,`#343a40`,`#212529`],red:[`#fff5f5`,`#ffe3e3`,`#ffc9c9`,`#ffa8a8`,`#ff8787`,`#ff6b6b`,`#fa5252`,`#f03e3e`,`#e03131`,`#c92a2a`],pink:[`#fff0f6`,`#ffdeeb`,`#fcc2d7`,`#faa2c1`,`#f783ac`,`#f06595`,`#e64980`,`#d6336c`,`#c2255c`,`#a61e4d`],grape:[`#f8f0fc`,`#f3d9fa`,`#eebefa`,`#e599f7`,`#da77f2`,`#cc5de8`,`#be4bdb`,`#ae3ec9`,`#9c36b5`,`#862e9c`],violet:[`#f3f0ff`,`#e5dbff`,`#d0bfff`,`#b197fc`,`#9775fa`,`#845ef7`,`#7950f2`,`#7048e8`,`#6741d9`,`#5f3dc4`],indigo:[`#edf2ff`,`#dbe4ff`,`#bac8ff`,`#91a7ff`,`#748ffc`,`#5c7cfa`,`#4c6ef5`,`#4263eb`,`#3b5bdb`,`#364fc7`],blue:[`#e7f5ff`,`#d0ebff`,`#a5d8ff`,`#74c0fc`,`#4dabf7`,`#339af0`,`#228be6`,`#1c7ed6`,`#1971c2`,`#1864ab`],cyan:[`#e3fafc`,`#c5f6fa`,`#99e9f2`,`#66d9e8`,`#3bc9db`,`#22b8cf`,`#15aabf`,`#1098ad`,`#0c8599`,`#0b7285`],teal:[`#e6fcf5`,`#c3fae8`,`#96f2d7`,`#63e6be`,`#38d9a9`,`#20c997`,`#12b886`,`#0ca678`,`#099268`,`#087f5b`],green:[`#ebfbee`,`#d3f9d8`,`#b2f2bb`,`#8ce99a`,`#69db7c`,`#51cf66`,`#40c057`,`#37b24d`,`#2f9e44`,`#2b8a3e`],lime:[`#f4fce3`,`#e9fac8`,`#d8f5a2`,`#c0eb75`,`#a9e34b`,`#94d82d`,`#82c91e`,`#74b816`,`#66a80f`,`#5c940d`],yellow:[`#fff9db`,`#fff3bf`,`#ffec99`,`#ffe066`,`#ffd43b`,`#fcc419`,`#fab005`,`#f59f00`,`#f08c00`,`#e67700`],orange:[`#fff4e6`,`#ffe8cc`,`#ffd8a8`,`#ffc078`,`#ffa94d`,`#ff922b`,`#fd7e14`,`#f76707`,`#e8590c`,`#d9480f`]},Mi=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((e,t)=>(t&=63,e+=t<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?`-`:`_`,e),``),Ni=t(((e,t)=>{var n=`Expected a function`,r=NaN,i=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,c=parseInt,l=typeof global==`object`&&global&&global.Object===Object&&global,u=typeof self==`object`&&self&&self.Object===Object&&self,d=l||u||Function(`return this`)(),f=Object.prototype.toString,p=Math.max,m=Math.min,h=function(){return d.Date.now()};function g(e,t,r){var i,a,o,s,c,l,u=0,d=!1,f=!1,g=!0;if(typeof e!=`function`)throw TypeError(n);t=x(t)||0,v(r)&&(d=!!r.leading,f=`maxWait`in r,o=f?p(x(r.maxWait)||0,t):o,g=`trailing`in r?!!r.trailing:g);function _(t){var n=i,r=a;return i=a=void 0,u=t,s=e.apply(r,n),s}function y(e){return u=e,c=setTimeout(C,t),d?_(e):s}function b(e){var n=e-l,r=e-u,i=t-n;return f?m(i,o-r):i}function S(e){var n=e-l,r=e-u;return l===void 0||n>=t||n<0||f&&r>=o}function C(){var e=h();if(S(e))return w(e);c=setTimeout(C,b(e))}function w(e){return c=void 0,g&&i?_(e):(i=a=void 0,s)}function T(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function E(){return c===void 0?s:w(h())}function D(){var e=h(),n=S(e);if(i=arguments,a=this,l=e,n){if(c===void 0)return y(l);if(f)return c=setTimeout(C,t),_(l)}return c===void 0&&(c=setTimeout(C,t)),s}return D.cancel=T,D.flush=E,D}function _(e,t,r){var i=!0,a=!0;if(typeof e!=`function`)throw TypeError(n);return v(r)&&(i=`leading`in r?!!r.leading:i,a=`trailing`in r?!!r.trailing:a),g(e,t,{leading:i,maxWait:t,trailing:a})}function v(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function y(e){return!!e&&typeof e==`object`}function b(e){return typeof e==`symbol`||y(e)&&f.call(e)==`[object Symbol]`}function x(e){if(typeof e==`number`)return e;if(b(e))return r;if(v(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=v(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(i,``);var n=o.test(e);return n||s.test(e)?c(e.slice(2),n?2:8):a.test(e)?r:+e}t.exports=_})),Pi=t(((e,t)=>{(function(n,r){typeof define==`function`&&define.amd?define([],r):typeof e==`object`?t.exports=r():(n.PromisePool=r(),n.promisePool=n.PromisePool)})(e,function(){var e=function(){this._listeners={}};e.prototype.addEventListener=function(e,t){this._listeners[e]=this._listeners[e]||[],this._listeners[e].indexOf(t)<0&&this._listeners[e].push(t)},e.prototype.removeEventListener=function(e,t){if(this._listeners[e]){var n=this._listeners[e].indexOf(t);n>=0&&this._listeners[e].splice(n,1)}},e.prototype.dispatchEvent=function(e){if(this._listeners[e.type]&&this._listeners[e.type].length)for(var t=this._listeners[e.type].slice(),n=0,r=t.length;n<r;++n)t[n].call(this,e)};var t=function(e){return typeof e.constructor==`function`&&e.constructor.name===`GeneratorFunction`},n=function(e){return{next:function(){var t=e();return t?{value:t}:{done:!0}}}},r=function(e){var t=!1;return{next:function(){return t?{done:!0}:(t=!0,{value:e})}}},i=function(e,i){var a=typeof e;if(a===`object`){if(typeof e.next==`function`)return e;if(typeof e.then==`function`)return r(e)}return a===`function`?t(e)?e():n(e):r(i.resolve(e))},a=function(e,t,n){this.target=e,this.type=t,this.data=n},o=function(t,n,r){if(e.call(this),typeof n!=`number`||Math.floor(n)!==n||n<1)throw Error(`Invalid concurrency`);this._concurrency=n,this._options=r||{},this._options.promise=this._options.promise||Promise,this._iterator=i(t,this._options.promise),this._done=!1,this._size=0,this._promise=null,this._callbacks=null};return o.prototype=new e,o.prototype.constructor=o,o.prototype.concurrency=function(e){return e!==void 0&&(this._concurrency=e,this.active()&&this._proceed()),this._concurrency},o.prototype.size=function(){return this._size},o.prototype.active=function(){return!!this._promise},o.prototype.promise=function(){return this._promise},o.prototype.start=function(){var e=this,t=this._options.promise;return this._promise=new t(function(t,n){e._callbacks={reject:n,resolve:t},e._proceed()}),this._promise},o.prototype._fireEvent=function(e,t){this.dispatchEvent(new a(this,e,t))},o.prototype._settle=function(e){e?this._callbacks.reject(e):this._callbacks.resolve(),this._promise=null,this._callbacks=null},o.prototype._onPooledPromiseFulfilled=function(e,t){this._size--,this.active()&&(this._fireEvent(`fulfilled`,{promise:e,result:t}),this._proceed())},o.prototype._onPooledPromiseRejected=function(e,t){this._size--,this.active()&&(this._fireEvent(`rejected`,{promise:e,error:t}),this._settle(t||Error(`Unknown error`)))},o.prototype._trackPromise=function(e){var t=this;e.then(function(n){t._onPooledPromiseFulfilled(e,n)},function(n){t._onPooledPromiseRejected(e,n)}).catch(function(e){t._settle(Error(`Promise processing failed: `+e))})},o.prototype._proceed=function(){if(!this._done){for(var e={done:!1};this._size<this._concurrency&&!(e=this._iterator.next()).done;)this._size++,this._trackPromise(e.value);this._done=e===null||!!e.done}this._done&&this._size===0&&this._settle()},o.PromisePoolEvent=a,o.PromisePool=o,o})})),Fi=e(Ni(),1),Ii=e(Pi(),1);function Li(e,t,n){if(e&&e.length){let[r,i]=t,a=Math.PI/180*n,o=Math.cos(a),s=Math.sin(a);for(let t of e){let[e,n]=t;t[0]=(e-r)*o-(n-i)*s+r,t[1]=(e-r)*s+(n-i)*o+i}}}function Ri(e,t,n){let r=[];e.forEach(e=>r.push(...e)),Li(r,t,n)}function zi(e,t){return e[0]===t[0]&&e[1]===t[1]}function Bi(e,t,n,r=1){let i=n,a=Math.max(t,.1),o=e[0]&&e[0][0]&&typeof e[0][0]==`number`?[e]:e,s=[0,0];if(i)for(let e of o)Li(e,s,i);let c=Vi(o,a,r);if(i){for(let e of o)Li(e,s,-i);Ri(c,s,-i)}return c}function Vi(e,t,n){let r=[];for(let t of e){let e=[...t];zi(e[0],e[e.length-1])||e.push([e[0][0],e[0][1]]),e.length>2&&r.push(e)}let i=[];t=Math.max(t,.1);let a=[];for(let e of r)for(let t=0;t<e.length-1;t++){let n=e[t],r=e[t+1];if(n[1]!==r[1]){let e=Math.min(n[1],r[1]);a.push({ymin:e,ymax:Math.max(n[1],r[1]),x:e===n[1]?n[0]:r[0],islope:(r[0]-n[0])/(r[1]-n[1])})}}if(a.sort((e,t)=>e.ymin<t.ymin?-1:e.ymin>t.ymin?1:e.x<t.x?-1:e.x>t.x?1:e.ymax===t.ymax?0:(e.ymax-t.ymax)/Math.abs(e.ymax-t.ymax)),!a.length)return i;let o=[],s=a[0].ymin,c=0;for(;o.length||a.length;){if(a.length){let e=-1;for(let t=0;t<a.length&&!(a[t].ymin>s);t++)e=t;a.splice(0,e+1).forEach(e=>{o.push({s,edge:e})})}if(o=o.filter(e=>!(e.edge.ymax<=s)),o.sort((e,t)=>e.edge.x===t.edge.x?0:(e.edge.x-t.edge.x)/Math.abs(e.edge.x-t.edge.x)),(n!==1||c%t===0)&&o.length>1)for(let e=0;e<o.length;e+=2){let t=e+1;if(t>=o.length)break;let n=o[e].edge,r=o[t].edge;i.push([[Math.round(n.x),s],[Math.round(r.x),s]])}s+=n,o.forEach(e=>{e.edge.x=e.edge.x+n*e.edge.islope}),c++}return i}function Hi(e,t){let n=t.hachureAngle+90,r=t.hachureGap;r<0&&(r=t.strokeWidth*4),r=Math.max(r,.1);let i=1;return t.roughness>=1&&(t.randomizer?.next()||Math.random())>.7&&(i=r),Bi(e,r,n,i||1)}var Ui=class{constructor(e){this.helper=e}fillPolygons(e,t){return this._fillPolygons(e,t)}_fillPolygons(e,t){let n=Hi(e,t);return{type:`fillSketch`,ops:this.renderLines(n,t)}}renderLines(e,t){let n=[];for(let r of e)n.push(...this.helper.doubleLineOps(r[0][0],r[0][1],r[1][0],r[1][1],t));return n}};function Wi(e){let t=e[0],n=e[1];return Math.sqrt((t[0]-n[0])**2+(t[1]-n[1])**2)}var Gi=class extends Ui{fillPolygons(e,t){let n=t.hachureGap;n<0&&(n=t.strokeWidth*4),n=Math.max(n,.1);let r=Hi(e,Object.assign({},t,{hachureGap:n})),i=Math.PI/180*t.hachureAngle,a=[],o=n*.5*Math.cos(i),s=n*.5*Math.sin(i);for(let[e,t]of r)Wi([e,t])&&a.push([[e[0]-o,e[1]+s],[...t]],[[e[0]+o,e[1]-s],[...t]]);return{type:`fillSketch`,ops:this.renderLines(a,t)}}},Ki=class extends Ui{fillPolygons(e,t){let n=this._fillPolygons(e,t),r=Object.assign({},t,{hachureAngle:t.hachureAngle+90}),i=this._fillPolygons(e,r);return n.ops=n.ops.concat(i.ops),n}},qi=class{constructor(e){this.helper=e}fillPolygons(e,t){t=Object.assign({},t,{hachureAngle:0});let n=Hi(e,t);return this.dotsOnLines(n,t)}dotsOnLines(e,t){let n=[],r=t.hachureGap;r<0&&(r=t.strokeWidth*4),r=Math.max(r,.1);let i=t.fillWeight;i<0&&(i=t.strokeWidth/2);let a=r/4;for(let o of e){let e=Wi(o),s=e/r,c=Math.ceil(s)-1,l=e-c*r,u=(o[0][0]+o[1][0])/2-r/4,d=Math.min(o[0][1],o[1][1]);for(let e=0;e<c;e++){let o=d+l+e*r,s=u-a+Math.random()*2*a,c=o-a+Math.random()*2*a,f=this.helper.ellipse(s,c,i,i,t);n.push(...f.ops)}}return{type:`fillSketch`,ops:n}}},Ji=class{constructor(e){this.helper=e}fillPolygons(e,t){let n=Hi(e,t);return{type:`fillSketch`,ops:this.dashedLine(n,t)}}dashedLine(e,t){let n=t.dashOffset<0?t.hachureGap<0?t.strokeWidth*4:t.hachureGap:t.dashOffset,r=t.dashGap<0?t.hachureGap<0?t.strokeWidth*4:t.hachureGap:t.dashGap,i=[];return e.forEach(e=>{let a=Wi(e),o=Math.floor(a/(n+r)),s=(a+r-o*(n+r))/2,c=e[0],l=e[1];c[0]>l[0]&&(c=e[1],l=e[0]);let u=Math.atan((l[1]-c[1])/(l[0]-c[0]));for(let e=0;e<o;e++){let a=e*(n+r),o=a+n,l=[c[0]+a*Math.cos(u)+s*Math.cos(u),c[1]+a*Math.sin(u)+s*Math.sin(u)],d=[c[0]+o*Math.cos(u)+s*Math.cos(u),c[1]+o*Math.sin(u)+s*Math.sin(u)];i.push(...this.helper.doubleLineOps(l[0],l[1],d[0],d[1],t))}}),i}},Yi=class{constructor(e){this.helper=e}fillPolygons(e,t){let n=t.hachureGap<0?t.strokeWidth*4:t.hachureGap,r=t.zigzagOffset<0?n:t.zigzagOffset;t=Object.assign({},t,{hachureGap:n+r});let i=Hi(e,t);return{type:`fillSketch`,ops:this.zigzagLines(i,r,t)}}zigzagLines(e,t,n){let r=[];return e.forEach(e=>{let i=Wi(e),a=Math.round(i/(2*t)),o=e[0],s=e[1];o[0]>s[0]&&(o=e[1],s=e[0]);let c=Math.atan((s[1]-o[1])/(s[0]-o[0]));for(let e=0;e<a;e++){let i=e*2*t,a=(e+1)*2*t,s=Math.sqrt(2*t**2),l=[o[0]+i*Math.cos(c),o[1]+i*Math.sin(c)],u=[o[0]+a*Math.cos(c),o[1]+a*Math.sin(c)],d=[l[0]+s*Math.cos(c+Math.PI/4),l[1]+s*Math.sin(c+Math.PI/4)];r.push(...this.helper.doubleLineOps(l[0],l[1],d[0],d[1],n),...this.helper.doubleLineOps(d[0],d[1],u[0],u[1],n))}}),r}},Xi={};function Zi(e,t){let n=e.fillStyle||`hachure`;if(!Xi[n])switch(n){case`zigzag`:Xi[n]||(Xi[n]=new Gi(t));break;case`cross-hatch`:Xi[n]||(Xi[n]=new Ki(t));break;case`dots`:Xi[n]||(Xi[n]=new qi(t));break;case`dashed`:Xi[n]||(Xi[n]=new Ji(t));break;case`zigzag-line`:Xi[n]||(Xi[n]=new Yi(t));break;default:n=`hachure`,Xi[n]||(Xi[n]=new Ui(t))}return Xi[n]}function Qi(){return Math.floor(Math.random()*2**31)}var $i=class{constructor(e){this.seed=e}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}},ea=0,ta=1,na=2,ra={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function ia(e){let t=[];for(;e!==``;)if(e.match(/^([ \t\r\n,]+)/))e=e.substr(RegExp.$1.length);else if(e.match(/^([aAcChHlLmMqQsStTvVzZ])/))t[t.length]={type:ea,text:RegExp.$1},e=e.substr(RegExp.$1.length);else if(e.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))t[t.length]={type:ta,text:`${parseFloat(RegExp.$1)}`},e=e.substr(RegExp.$1.length);else return[];return t[t.length]={type:na,text:``},t}function aa(e,t){return e.type===t}function oa(e){let t=[],n=ia(e),r=`BOD`,i=0,a=n[i];for(;!aa(a,na);){let o=0,s=[];if(r===`BOD`){if(a.text===`M`||a.text===`m`)i++,o=ra[a.text],r=a.text;else return oa(`M0,0`+e)}else aa(a,ta)?o=ra[r]:(i++,o=ra[a.text],r=a.text);if(i+o<n.length){for(let e=i;e<i+o;e++){let t=n[e];if(aa(t,ta))s[s.length]=+t.text;else throw Error(`Param not a number: `+r+`,`+t.text)}if(typeof ra[r]==`number`){let e={key:r,data:s};t.push(e),i+=o,a=n[i],r===`M`&&(r=`L`),r===`m`&&(r=`l`)}else throw Error(`Bad segment: `+r)}else throw Error(`Path data ended short`)}return t}function sa(e){let t=0,n=0,r=0,i=0,a=[];for(let{key:o,data:s}of e)switch(o){case`M`:a.push({key:`M`,data:[...s]}),[t,n]=s,[r,i]=s;break;case`m`:t+=s[0],n+=s[1],a.push({key:`M`,data:[t,n]}),r=t,i=n;break;case`L`:a.push({key:`L`,data:[...s]}),[t,n]=s;break;case`l`:t+=s[0],n+=s[1],a.push({key:`L`,data:[t,n]});break;case`C`:a.push({key:`C`,data:[...s]}),t=s[4],n=s[5];break;case`c`:{let e=s.map((e,r)=>r%2?e+n:e+t);a.push({key:`C`,data:e}),t=e[4],n=e[5];break}case`Q`:a.push({key:`Q`,data:[...s]}),t=s[2],n=s[3];break;case`q`:{let e=s.map((e,r)=>r%2?e+n:e+t);a.push({key:`Q`,data:e}),t=e[2],n=e[3];break}case`A`:a.push({key:`A`,data:[...s]}),t=s[5],n=s[6];break;case`a`:t+=s[5],n+=s[6],a.push({key:`A`,data:[s[0],s[1],s[2],s[3],s[4],t,n]});break;case`H`:a.push({key:`H`,data:[...s]}),t=s[0];break;case`h`:t+=s[0],a.push({key:`H`,data:[t]});break;case`V`:a.push({key:`V`,data:[...s]}),n=s[0];break;case`v`:n+=s[0],a.push({key:`V`,data:[n]});break;case`S`:a.push({key:`S`,data:[...s]}),t=s[2],n=s[3];break;case`s`:{let e=s.map((e,r)=>r%2?e+n:e+t);a.push({key:`S`,data:e}),t=e[2],n=e[3];break}case`T`:a.push({key:`T`,data:[...s]}),t=s[0],n=s[1];break;case`t`:t+=s[0],n+=s[1],a.push({key:`T`,data:[t,n]});break;case`Z`:case`z`:a.push({key:`Z`,data:[]}),t=r,n=i}return a}function ca(e){let t=[],n=``,r=0,i=0,a=0,o=0,s=0,c=0;for(let{key:l,data:u}of e){switch(l){case`M`:t.push({key:`M`,data:[...u]}),[r,i]=u,[a,o]=u;break;case`C`:t.push({key:`C`,data:[...u]}),r=u[4],i=u[5],s=u[2],c=u[3];break;case`L`:t.push({key:`L`,data:[...u]}),[r,i]=u;break;case`H`:r=u[0],t.push({key:`L`,data:[r,i]});break;case`V`:i=u[0],t.push({key:`L`,data:[r,i]});break;case`S`:{let e=0,a=0;n===`C`||n===`S`?(e=r+(r-s),a=i+(i-c)):(e=r,a=i),t.push({key:`C`,data:[e,a,...u]}),s=u[0],c=u[1],r=u[2],i=u[3];break}case`T`:{let[e,a]=u,o=0,l=0;n===`Q`||n===`T`?(o=r+(r-s),l=i+(i-c)):(o=r,l=i);let d=r+2*(o-r)/3,f=i+2*(l-i)/3,p=e+2*(o-e)/3,m=a+2*(l-a)/3;t.push({key:`C`,data:[d,f,p,m,e,a]}),s=o,c=l,r=e,i=a;break}case`Q`:{let[e,n,a,o]=u,l=r+2*(e-r)/3,d=i+2*(n-i)/3,f=a+2*(e-a)/3,p=o+2*(n-o)/3;t.push({key:`C`,data:[l,d,f,p,a,o]}),s=e,c=n,r=a,i=o;break}case`A`:{let e=Math.abs(u[0]),n=Math.abs(u[1]),a=u[2],o=u[3],s=u[4],c=u[5],l=u[6];e===0||n===0?(t.push({key:`C`,data:[r,i,c,l,c,l]}),r=c,i=l):(r!==c||i!==l)&&(da(r,i,c,l,e,n,a,o,s).forEach(function(e){t.push({key:`C`,data:e})}),r=c,i=l);break}case`Z`:t.push({key:`Z`,data:[]}),r=a,i=o}n=l}return t}function la(e){return Math.PI*e/180}function ua(e,t,n){return[e*Math.cos(n)-t*Math.sin(n),e*Math.sin(n)+t*Math.cos(n)]}function da(e,t,n,r,i,a,o,s,c,l){let u=la(o),d=[],f=0,p=0,m=0,h=0;if(l)[f,p,m,h]=l;else{[e,t]=ua(e,t,-u),[n,r]=ua(n,r,-u);let o=(e-n)/2,l=(t-r)/2,d=o*o/(i*i)+l*l/(a*a);d>1&&(d=Math.sqrt(d),i=d*i,a=d*a);let g=s===c?-1:1,_=i*i,v=a*a,y=_*v-_*l*l-v*o*o,b=_*l*l+v*o*o,x=g*Math.sqrt(Math.abs(y/b));m=x*i*l/a+(e+n)/2,h=x*-a*o/i+(t+r)/2,f=Math.asin(parseFloat(((t-h)/a).toFixed(9))),p=Math.asin(parseFloat(((r-h)/a).toFixed(9))),e<m&&(f=Math.PI-f),n<m&&(p=Math.PI-p),f<0&&(f=Math.PI*2+f),p<0&&(p=Math.PI*2+p),c&&f>p&&(f-=Math.PI*2),!c&&p>f&&(p-=Math.PI*2)}let g=p-f;if(Math.abs(g)>Math.PI*120/180){let e=p,t=n,s=r;p=c&&p>f?f+Math.PI*120/180*1:f+Math.PI*120/180*-1,n=m+i*Math.cos(p),r=h+a*Math.sin(p),d=da(n,r,t,s,i,a,o,0,c,[p,e,m,h])}g=p-f;let _=Math.cos(f),v=Math.sin(f),y=Math.cos(p),b=Math.sin(p),x=Math.tan(g/4),S=4/3*i*x,C=4/3*a*x,w=[e,t],T=[e+S*v,t-C*_],E=[n+S*b,r-C*y],D=[n,r];if(T[0]=2*w[0]-T[0],T[1]=2*w[1]-T[1],l)return[T,E,D].concat(d);{d=[T,E,D].concat(d);let e=[];for(let t=0;t<d.length;t+=3){let n=ua(d[t][0],d[t][1],u),r=ua(d[t+1][0],d[t+1][1],u),i=ua(d[t+2][0],d[t+2][1],u);e.push([n[0],n[1],r[0],r[1],i[0],i[1]])}return e}}var fa={randOffset:Ea,randOffsetWithRange:Da,ellipse:va,doubleLineOps:Oa};function pa(e,t,n,r,i){return{type:`path`,ops:Ma(e,t,n,r,i)}}function ma(e,t,n){let r=(e||[]).length;if(r>2){let i=[];for(let t=0;t<r-1;t++)i.push(...Ma(e[t][0],e[t][1],e[t+1][0],e[t+1][1],n));return t&&i.push(...Ma(e[r-1][0],e[r-1][1],e[0][0],e[0][1],n)),{type:`path`,ops:i}}return r===2?pa(e[0][0],e[0][1],e[1][0],e[1][1],n):{type:`path`,ops:[]}}function ha(e,t){return ma(e,!0,t)}function ga(e,t,n,r,i){return ha([[e,t],[e+n,t],[e+n,t+r],[e,t+r]],i)}function _a(e,t){let n=Pa(e,1*(1+t.roughness*.2),t);if(!t.disableMultiStroke){let r=Pa(e,1.5*(1+t.roughness*.22),ka(t));n=n.concat(r)}return{type:`path`,ops:n}}function va(e,t,n,r,i){return ba(e,t,i,ya(n,r,i)).opset}function ya(e,t,n){let r=Math.sqrt(Math.PI*2*Math.sqrt(((e/2)**2+(t/2)**2)/2)),i=Math.ceil(Math.max(n.curveStepCount,n.curveStepCount/Math.sqrt(200)*r)),a=Math.PI*2/i,o=Math.abs(e/2),s=Math.abs(t/2),c=1-n.curveFitting;return o+=k(o*c,n),s+=k(s*c,n),{increment:a,rx:o,ry:s}}function ba(e,t,n,r){let[i,a]=Ia(r.increment,e,t,r.rx,r.ry,1,r.increment*ja(.1,ja(.4,1,n),n),n),o=Fa(i,null,n);if(!n.disableMultiStroke&&n.roughness!==0){let[i]=Ia(r.increment,e,t,r.rx,r.ry,1.5,0,n),a=Fa(i,null,n);o=o.concat(a)}return{estimatedPoints:a,opset:{type:`path`,ops:o}}}function xa(e,t,n,r,i,a,o,s,c){let l=e,u=t,d=Math.abs(n/2),f=Math.abs(r/2);d+=k(d*.01,c),f+=k(f*.01,c);let p=i,m=a;for(;p<0;)p+=Math.PI*2,m+=Math.PI*2;m-p>Math.PI*2&&(p=0,m=Math.PI*2);let h=Math.PI*2/c.curveStepCount,g=Math.min(h/2,(m-p)/2),_=La(g,l,u,d,f,p,m,1,c);if(!c.disableMultiStroke){let e=La(g,l,u,d,f,p,m,1.5,c);_.push(...e)}return o&&(s?_.push(...Ma(l,u,l+d*Math.cos(p),u+f*Math.sin(p),c),...Ma(l,u,l+d*Math.cos(m),u+f*Math.sin(m),c)):_.push({op:`lineTo`,data:[l,u]},{op:`lineTo`,data:[l+d*Math.cos(p),u+f*Math.sin(p)]})),{type:`path`,ops:_}}function Sa(e,t){let n=ca(sa(oa(e))),r=[],i=[0,0],a=[0,0];for(let{key:e,data:o}of n)switch(e){case`M`:a=[o[0],o[1]],i=[o[0],o[1]];break;case`L`:r.push(...Ma(a[0],a[1],o[0],o[1],t)),a=[o[0],o[1]];break;case`C`:{let[e,n,i,s,c,l]=o;r.push(...Ra(e,n,i,s,c,l,a,t)),a=[c,l];break}case`Z`:r.push(...Ma(a[0],a[1],i[0],i[1],t)),a=[i[0],i[1]]}return{type:`path`,ops:r}}function Ca(e,t){let n=[];for(let r of e)if(r.length){let e=t.maxRandomnessOffset||0,i=r.length;if(i>2){n.push({op:`move`,data:[r[0][0]+k(e,t),r[0][1]+k(e,t)]});for(let a=1;a<i;a++)n.push({op:`lineTo`,data:[r[a][0]+k(e,t),r[a][1]+k(e,t)]})}}return{type:`fillPath`,ops:n}}function wa(e,t){return Zi(t,fa).fillPolygons(e,t)}function Ta(e,t,n,r,i,a,o){let s=e,c=t,l=Math.abs(n/2),u=Math.abs(r/2);l+=k(l*.01,o),u+=k(u*.01,o);let d=i,f=a;for(;d<0;)d+=Math.PI*2,f+=Math.PI*2;f-d>Math.PI*2&&(d=0,f=Math.PI*2);let p=(f-d)/o.curveStepCount,m=[];for(let e=d;e<=f;e+=p)m.push([s+l*Math.cos(e),c+u*Math.sin(e)]);return m.push([s+l*Math.cos(f),c+u*Math.sin(f)]),m.push([s,c]),wa([m],o)}function Ea(e,t){return k(e,t)}function Da(e,t,n){return ja(e,t,n)}function Oa(e,t,n,r,i){return Ma(e,t,n,r,i,!0)}function ka(e){let t=Object.assign({},e);return t.randomizer=void 0,e.seed&&(t.seed=e.seed+1),t}function Aa(e){return e.randomizer||=new $i(e.seed||0),e.randomizer.next()}function ja(e,t,n,r=1){return n.roughness*r*(Aa(n)*(t-e)+e)}function k(e,t,n=1){return ja(-e,e,t,n)}function Ma(e,t,n,r,i,a=!1){let o=a?i.disableMultiStrokeFill:i.disableMultiStroke,s=Na(e,t,n,r,i,!0,!1);if(o)return s;let c=Na(e,t,n,r,i,!0,!0);return s.concat(c)}function Na(e,t,n,r,i,a,o){let s=(e-n)**2+(t-r)**2,c=Math.sqrt(s),l=1;l=c<200?1:c>500?.4:-.0016668*c+1.233334;let u=i.maxRandomnessOffset||0;u*u*100>s&&(u=c/10);let d=u/2,f=.2+Aa(i)*.2,p=i.bowing*i.maxRandomnessOffset*(r-t)/200,m=i.bowing*i.maxRandomnessOffset*(e-n)/200;p=k(p,i,l),m=k(m,i,l);let h=[],g=()=>k(d,i,l),_=()=>k(u,i,l),v=i.preserveVertices;return a&&(o?h.push({op:`move`,data:[e+(v?0:g()),t+(v?0:g())]}):h.push({op:`move`,data:[e+(v?0:k(u,i,l)),t+(v?0:k(u,i,l))]})),o?h.push({op:`bcurveTo`,data:[p+e+(n-e)*f+g(),m+t+(r-t)*f+g(),p+e+2*(n-e)*f+g(),m+t+2*(r-t)*f+g(),n+(v?0:g()),r+(v?0:g())]}):h.push({op:`bcurveTo`,data:[p+e+(n-e)*f+_(),m+t+(r-t)*f+_(),p+e+2*(n-e)*f+_(),m+t+2*(r-t)*f+_(),n+(v?0:_()),r+(v?0:_())]}),h}function Pa(e,t,n){let r=[];r.push([e[0][0]+k(t,n),e[0][1]+k(t,n)]),r.push([e[0][0]+k(t,n),e[0][1]+k(t,n)]);for(let i=1;i<e.length;i++)r.push([e[i][0]+k(t,n),e[i][1]+k(t,n)]),i===e.length-1&&r.push([e[i][0]+k(t,n),e[i][1]+k(t,n)]);return Fa(r,null,n)}function Fa(e,t,n){let r=e.length,i=[];if(r>3){let a=[],o=1-n.curveTightness;i.push({op:`move`,data:[e[1][0],e[1][1]]});for(let t=1;t+2<r;t++){let n=e[t];a[0]=[n[0],n[1]],a[1]=[n[0]+(o*e[t+1][0]-o*e[t-1][0])/6,n[1]+(o*e[t+1][1]-o*e[t-1][1])/6],a[2]=[e[t+1][0]+(o*e[t][0]-o*e[t+2][0])/6,e[t+1][1]+(o*e[t][1]-o*e[t+2][1])/6],a[3]=[e[t+1][0],e[t+1][1]],i.push({op:`bcurveTo`,data:[a[1][0],a[1][1],a[2][0],a[2][1],a[3][0],a[3][1]]})}if(t&&t.length===2){let e=n.maxRandomnessOffset;i.push({op:`lineTo`,data:[t[0]+k(e,n),t[1]+k(e,n)]})}}else r===3?(i.push({op:`move`,data:[e[1][0],e[1][1]]}),i.push({op:`bcurveTo`,data:[e[1][0],e[1][1],e[2][0],e[2][1],e[2][0],e[2][1]]})):r===2&&i.push(...Ma(e[0][0],e[0][1],e[1][0],e[1][1],n));return i}function Ia(e,t,n,r,i,a,o,s){let c=s.roughness===0,l=[],u=[];if(c){e/=4,u.push([t+r*Math.cos(-e),n+i*Math.sin(-e)]);for(let a=0;a<=Math.PI*2;a+=e){let e=[t+r*Math.cos(a),n+i*Math.sin(a)];l.push(e),u.push(e)}u.push([t+r*Math.cos(0),n+i*Math.sin(0)]),u.push([t+r*Math.cos(e),n+i*Math.sin(e)])}else{let c=k(.5,s)-Math.PI/2;u.push([k(a,s)+t+.9*r*Math.cos(c-e),k(a,s)+n+.9*i*Math.sin(c-e)]);let d=Math.PI*2+c-.01;for(let o=c;o<d;o+=e){let e=[k(a,s)+t+r*Math.cos(o),k(a,s)+n+i*Math.sin(o)];l.push(e),u.push(e)}u.push([k(a,s)+t+r*Math.cos(c+Math.PI*2+o*.5),k(a,s)+n+i*Math.sin(c+Math.PI*2+o*.5)]),u.push([k(a,s)+t+.98*r*Math.cos(c+o),k(a,s)+n+.98*i*Math.sin(c+o)]),u.push([k(a,s)+t+.9*r*Math.cos(c+o*.5),k(a,s)+n+.9*i*Math.sin(c+o*.5)])}return[u,l]}function La(e,t,n,r,i,a,o,s,c){let l=a+k(.1,c),u=[];u.push([k(s,c)+t+.9*r*Math.cos(l-e),k(s,c)+n+.9*i*Math.sin(l-e)]);for(let a=l;a<=o;a+=e)u.push([k(s,c)+t+r*Math.cos(a),k(s,c)+n+i*Math.sin(a)]);return u.push([t+r*Math.cos(o),n+i*Math.sin(o)]),u.push([t+r*Math.cos(o),n+i*Math.sin(o)]),Fa(u,null,c)}function Ra(e,t,n,r,i,a,o,s){let c=[],l=[s.maxRandomnessOffset||1,(s.maxRandomnessOffset||1)+.3],u=[0,0],d=s.disableMultiStroke?1:2,f=s.preserveVertices;for(let p=0;p<d;p++)p===0?c.push({op:`move`,data:[o[0],o[1]]}):c.push({op:`move`,data:[o[0]+(f?0:k(l[0],s)),o[1]+(f?0:k(l[0],s))]}),u=f?[i,a]:[i+k(l[p],s),a+k(l[p],s)],c.push({op:`bcurveTo`,data:[e+k(l[p],s),t+k(l[p],s),n+k(l[p],s),r+k(l[p],s),u[0],u[1]]});return c}function za(e){return[...e]}function Ba(e,t=0){let n=e.length;if(n<3)throw Error(`A curve must have at least three points.`);let r=[];if(n===3)r.push(za(e[0]),za(e[1]),za(e[2]),za(e[2]));else{let n=[];n.push(e[0],e[0]);for(let t=1;t<e.length;t++)n.push(e[t]),t===e.length-1&&n.push(e[t]);let i=[],a=1-t;r.push(za(n[0]));for(let e=1;e+2<n.length;e++){let t=n[e];i[0]=[t[0],t[1]],i[1]=[t[0]+(a*n[e+1][0]-a*n[e-1][0])/6,t[1]+(a*n[e+1][1]-a*n[e-1][1])/6],i[2]=[n[e+1][0]+(a*n[e][0]-a*n[e+2][0])/6,n[e+1][1]+(a*n[e][1]-a*n[e+2][1])/6],i[3]=[n[e+1][0],n[e+1][1]],r.push(i[1],i[2],i[3])}}return r}function Va(e,t){return Math.sqrt(Ha(e,t))}function Ha(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2}function Ua(e,t,n){let r=Ha(t,n);if(r===0)return Ha(e,t);let i=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r;return i=Math.max(0,Math.min(1,i)),Ha(e,Wa(t,n,i))}function Wa(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function Ga(e,t){let n=e[t+0],r=e[t+1],i=e[t+2],a=e[t+3],o=3*r[0]-2*n[0]-a[0];o*=o;let s=3*r[1]-2*n[1]-a[1];s*=s;let c=3*i[0]-2*a[0]-n[0];c*=c;let l=3*i[1]-2*a[1]-n[1];return l*=l,o<c&&(o=c),s<l&&(s=l),o+s}function Ka(e,t,n,r){let i=r||[];if(Ga(e,t)<n){let n=e[t+0];i.length?Va(i[i.length-1],n)>1&&i.push(n):i.push(n),i.push(e[t+3])}else{let r=.5,a=e[t+0],o=e[t+1],s=e[t+2],c=e[t+3],l=Wa(a,o,r),u=Wa(o,s,r),d=Wa(s,c,r),f=Wa(l,u,r),p=Wa(u,d,r),m=Wa(f,p,r);Ka([a,l,f,m],0,n,i),Ka([m,p,d,c],0,n,i)}return i}function qa(e,t){return Ja(e,0,e.length,t)}function Ja(e,t,n,r,i){let a=i||[],o=e[t],s=e[n-1],c=0,l=1;for(let r=t+1;r<n-1;++r){let t=Ua(e[r],o,s);t>c&&(c=t,l=r)}return Math.sqrt(c)>r?(Ja(e,t,l+1,r,a),Ja(e,l,n,r,a)):(a.length||a.push(o),a.push(s)),a}function Ya(e,t=.15,n){let r=[],i=(e.length-1)/3;for(let n=0;n<i;n++)Ka(e,n*3,t,r);return n&&n>0?Ja(r,0,r.length,n):r}function Xa(e,t,n){let r=ca(sa(oa(e))),i=[],a=[],o=[0,0],s=[],c=()=>{s.length>=4&&a.push(...Ya(s,t)),s=[]},l=()=>{c(),a.length&&(i.push(a),a=[])};for(let{key:e,data:t}of r)switch(e){case`M`:l(),o=[t[0],t[1]],a.push(o);break;case`L`:c(),a.push([t[0],t[1]]);break;case`C`:if(!s.length){let e=a.length?a[a.length-1]:o;s.push([e[0],e[1]])}s.push([t[0],t[1]]),s.push([t[2],t[3]]),s.push([t[4],t[5]]);break;case`Z`:c(),a.push([o[0],o[1]])}if(l(),!n)return i;let u=[];for(let e of i){let t=qa(e,n);t.length&&u.push(t)}return u}var Za=`none`,Qa=class{constructor(e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:`#000`,strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:`hachure`,fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=e||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Qi()}_o(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_d(e,t,n){return{shape:e,sets:t||[],options:n||this.defaultOptions}}line(e,t,n,r,i){let a=this._o(i);return this._d(`line`,[pa(e,t,n,r,a)],a)}rectangle(e,t,n,r,i){let a=this._o(i),o=[],s=ga(e,t,n,r,a);if(a.fill){let i=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]];a.fillStyle===`solid`?o.push(Ca([i],a)):o.push(wa([i],a))}return a.stroke!==Za&&o.push(s),this._d(`rectangle`,o,a)}ellipse(e,t,n,r,i){let a=this._o(i),o=[],s=ya(n,r,a),c=ba(e,t,a,s);if(a.fill){if(a.fillStyle===`solid`){let n=ba(e,t,a,s).opset;n.type=`fillPath`,o.push(n)}else o.push(wa([c.estimatedPoints],a))}return a.stroke!==Za&&o.push(c.opset),this._d(`ellipse`,o,a)}circle(e,t,n,r){let i=this.ellipse(e,t,n,n,r);return i.shape=`circle`,i}linearPath(e,t){let n=this._o(t);return this._d(`linearPath`,[ma(e,!1,n)],n)}arc(e,t,n,r,i,a,o=!1,s){let c=this._o(s),l=[],u=xa(e,t,n,r,i,a,o,!0,c);if(o&&c.fill){if(c.fillStyle===`solid`){let o=Object.assign({},c);o.disableMultiStroke=!0;let s=xa(e,t,n,r,i,a,!0,!1,o);s.type=`fillPath`,l.push(s)}else l.push(Ta(e,t,n,r,i,a,c))}return c.stroke!==Za&&l.push(u),this._d(`arc`,l,c)}curve(e,t){let n=this._o(t),r=[],i=_a(e,n);if(n.fill&&n.fill!==Za&&e.length>=3){if(n.fillStyle===`solid`){let t=_a(e,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));r.push({type:`fillPath`,ops:this._mergedShape(t.ops)})}else{let t=Ya(Ba(e),10,(1+n.roughness)/2);r.push(wa([t],n))}}return n.stroke!==Za&&r.push(i),this._d(`curve`,r,n)}polygon(e,t){let n=this._o(t),r=[],i=ma(e,!0,n);return n.fill&&(n.fillStyle===`solid`?r.push(Ca([e],n)):r.push(wa([e],n))),n.stroke!==Za&&r.push(i),this._d(`polygon`,r,n)}path(e,t){let n=this._o(t),r=[];if(!e)return this._d(`path`,r,n);e=(e||``).replace(/\n/g,` `).replace(/(-\s)/g,`-`).replace(`/(ss)/g`,` `);let i=n.fill&&n.fill!==`transparent`&&n.fill!==Za,a=n.stroke!==Za,o=!!(n.simplification&&n.simplification<1),s=o?4-4*(n.simplification||1):(1+n.roughness)/2,c=Xa(e,1,s),l=Sa(e,n);if(i){if(n.fillStyle===`solid`){if(c.length===1){let t=Sa(e,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));r.push({type:`fillPath`,ops:this._mergedShape(t.ops)})}else r.push(Ca(c,n))}else r.push(wa(c,n))}return a&&(o?c.forEach(e=>{r.push(ma(e,!1,n))}):r.push(l)),this._d(`path`,r,n)}opsToPath(e,t){let n=``;for(let r of e.ops){let e=typeof t==`number`&&t>=0?r.data.map(e=>+e.toFixed(t)):r.data;switch(r.op){case`move`:n+=`M${e[0]} ${e[1]} `;break;case`bcurveTo`:n+=`C${e[0]} ${e[1]}, ${e[2]} ${e[3]}, ${e[4]} ${e[5]} `;break;case`lineTo`:n+=`L${e[0]} ${e[1]} `}}return n.trim()}toPaths(e){let t=e.sets||[],n=e.options||this.defaultOptions,r=[];for(let e of t){let t=null;switch(e.type){case`path`:t={d:this.opsToPath(e),stroke:n.stroke,strokeWidth:n.strokeWidth,fill:Za};break;case`fillPath`:t={d:this.opsToPath(e),stroke:Za,strokeWidth:0,fill:n.fill||Za};break;case`fillSketch`:t=this.fillSketch(e,n)}t&&r.push(t)}return r}fillSketch(e,t){let n=t.fillWeight;return n<0&&(n=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||Za,strokeWidth:n,fill:Za}}_mergedShape(e){return e.filter((e,t)=>t===0||e.op!==`move`)}},$a=class{constructor(e,t){this.canvas=e,this.ctx=this.canvas.getContext(`2d`),this.gen=new Qa(t)}draw(e){let t=e.sets||[],n=e.options||this.getDefaultOptions(),r=this.ctx,i=e.options.fixedDecimalPlaceDigits;for(let a of t)switch(a.type){case`path`:r.save(),r.strokeStyle=n.stroke===`none`?`transparent`:n.stroke,r.lineWidth=n.strokeWidth,n.strokeLineDash&&r.setLineDash(n.strokeLineDash),n.strokeLineDashOffset&&(r.lineDashOffset=n.strokeLineDashOffset),this._drawToContext(r,a,i),r.restore();break;case`fillPath`:{r.save(),r.fillStyle=n.fill||``;let t=e.shape===`curve`||e.shape===`polygon`||e.shape===`path`?`evenodd`:`nonzero`;this._drawToContext(r,a,i,t),r.restore();break}case`fillSketch`:this.fillSketch(r,a,n)}}fillSketch(e,t,n){let r=n.fillWeight;r<0&&(r=n.strokeWidth/2),e.save(),n.fillLineDash&&e.setLineDash(n.fillLineDash),n.fillLineDashOffset&&(e.lineDashOffset=n.fillLineDashOffset),e.strokeStyle=n.fill||``,e.lineWidth=r,this._drawToContext(e,t,n.fixedDecimalPlaceDigits),e.restore()}_drawToContext(e,t,n,r=`nonzero`){e.beginPath();for(let r of t.ops){let t=typeof n==`number`&&n>=0?r.data.map(e=>+e.toFixed(n)):r.data;switch(r.op){case`move`:e.moveTo(t[0],t[1]);break;case`bcurveTo`:e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]);break;case`lineTo`:e.lineTo(t[0],t[1])}}t.type===`fillPath`?e.fill(r):e.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(e,t,n,r,i){let a=this.gen.line(e,t,n,r,i);return this.draw(a),a}rectangle(e,t,n,r,i){let a=this.gen.rectangle(e,t,n,r,i);return this.draw(a),a}ellipse(e,t,n,r,i){let a=this.gen.ellipse(e,t,n,r,i);return this.draw(a),a}circle(e,t,n,r){let i=this.gen.circle(e,t,n,r);return this.draw(i),i}linearPath(e,t){let n=this.gen.linearPath(e,t);return this.draw(n),n}polygon(e,t){let n=this.gen.polygon(e,t);return this.draw(n),n}arc(e,t,n,r,i,a,o=!1,s){let c=this.gen.arc(e,t,n,r,i,a,o,s);return this.draw(c),c}curve(e,t){let n=this.gen.curve(e,t);return this.draw(n),n}path(e,t){let n=this.gen.path(e,t);return this.draw(n),n}},eo=`http://www.w3.org/2000/svg`,to=class{constructor(e,t){this.svg=e,this.gen=new Qa(t)}draw(e){let t=e.sets||[],n=e.options||this.getDefaultOptions(),r=this.svg.ownerDocument||window.document,i=r.createElementNS(eo,`g`),a=e.options.fixedDecimalPlaceDigits;for(let o of t){let t=null;switch(o.type){case`path`:t=r.createElementNS(eo,`path`),t.setAttribute(`d`,this.opsToPath(o,a)),t.setAttribute(`stroke`,n.stroke),t.setAttribute(`stroke-width`,n.strokeWidth+``),t.setAttribute(`fill`,`none`),n.strokeLineDash&&t.setAttribute(`stroke-dasharray`,n.strokeLineDash.join(` `).trim()),n.strokeLineDashOffset&&t.setAttribute(`stroke-dashoffset`,`${n.strokeLineDashOffset}`);break;case`fillPath`:t=r.createElementNS(eo,`path`),t.setAttribute(`d`,this.opsToPath(o,a)),t.setAttribute(`stroke`,`none`),t.setAttribute(`stroke-width`,`0`),t.setAttribute(`fill`,n.fill||``),(e.shape===`curve`||e.shape===`polygon`)&&t.setAttribute(`fill-rule`,`evenodd`);break;case`fillSketch`:t=this.fillSketch(r,o,n)}t&&i.appendChild(t)}return i}fillSketch(e,t,n){let r=n.fillWeight;r<0&&(r=n.strokeWidth/2);let i=e.createElementNS(eo,`path`);return i.setAttribute(`d`,this.opsToPath(t,n.fixedDecimalPlaceDigits)),i.setAttribute(`stroke`,n.fill||``),i.setAttribute(`stroke-width`,r+``),i.setAttribute(`fill`,`none`),n.fillLineDash&&i.setAttribute(`stroke-dasharray`,n.fillLineDash.join(` `).trim()),n.fillLineDashOffset&&i.setAttribute(`stroke-dashoffset`,`${n.fillLineDashOffset}`),i}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(e,t){return this.gen.opsToPath(e,t)}line(e,t,n,r,i){let a=this.gen.line(e,t,n,r,i);return this.draw(a)}rectangle(e,t,n,r,i){let a=this.gen.rectangle(e,t,n,r,i);return this.draw(a)}ellipse(e,t,n,r,i){let a=this.gen.ellipse(e,t,n,r,i);return this.draw(a)}circle(e,t,n,r){let i=this.gen.circle(e,t,n,r);return this.draw(i)}linearPath(e,t){let n=this.gen.linearPath(e,t);return this.draw(n)}polygon(e,t){let n=this.gen.polygon(e,t);return this.draw(n)}arc(e,t,n,r,i,a,o=!1,s){let c=this.gen.arc(e,t,n,r,i,a,o,s);return this.draw(c)}curve(e,t){let n=this.gen.curve(e,t);return this.draw(n)}path(e,t){let n=this.gen.path(e,t);return this.draw(n)}},no={canvas(e,t){return new $a(e,t)},svg(e,t){return new to(e,t)},generator(e){return new Qa(e)},newSeed(){return Qa.newSeed()}};function ro(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}function io(e){return[-e[0],-e[1]]}function ao(e,t){return[e[0]+t[0],e[1]+t[1]]}function oo(e,t){return[e[0]-t[0],e[1]-t[1]]}function so(e,t){return[e[0]*t,e[1]*t]}function co(e,t){return[e[0]/t,e[1]/t]}function lo(e){return[e[1],-e[0]]}function uo(e,t){return e[0]*t[0]+e[1]*t[1]}function fo(e,t){return e[0]===t[0]&&e[1]===t[1]}function po(e){return Math.hypot(e[0],e[1])}function mo(e){return e[0]*e[0]+e[1]*e[1]}function ho(e,t){return mo(oo(e,t))}function go(e){return co(e,po(e))}function _o(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function vo(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function yo(e,t,n){return ao(e,so(oo(t,e),n))}function bo(e,t,n){return ao(e,so(t,n))}var{min:xo,PI:So}=Math,Co=.275,wo=So+1e-4;function To(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=s.taper===!1?0:s.taper===!0?Math.max(n,m):s.taper,g=c.taper===!1?0:c.taper===!0?Math.max(n,m):c.taper,_=(n*r)**2,v=[],y=[],b=e.slice(0,10).reduce((e,t)=>{let r=t.pressure;if(a){let i=xo(1,t.distance/n);r=xo(1,e+(xo(1,1-i)-e)*(i*Co))}return(e+r)/2},e[0].pressure),x=ro(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,w=e[0].point,T=w,E=w,D=T,ee=!1;for(let t=0;t<e.length;t++){let{pressure:r}=e[t],{point:s,vector:c,distance:l,runningLength:u}=e[t];if(t<e.length-1&&m-u<3)continue;if(i){if(a){let e=xo(1,l/n),t=xo(1,1-e);r=xo(1,b+(t-b)*(e*Co))}x=ro(n,i,r,o)}else x=n/2;S===void 0&&(S=x);let f=u<h?d(u/h):1,te=m-u<g?p((m-u)/g):1;x=Math.max(.01,x*Math.min(f,te));let ne=(t<e.length-1?e[t+1]:e[t]).vector,re=t<e.length-1?uo(c,ne):1,ie=uo(c,C)<0&&!ee,ae=re!==null&&re<0;if(ie||ae){let e=so(lo(C),x);for(let t=0;t<=1;t+=.07692307692307693)E=vo(oo(s,e),s,wo*t),v.push(E),D=vo(ao(s,e),s,wo*-t),y.push(D);w=E,T=D,ae&&(ee=!0);continue}if(ee=!1,t===e.length-1){let e=so(lo(c),x);v.push(oo(s,e)),y.push(ao(s,e));continue}let oe=so(lo(yo(ne,c,re)),x);E=oo(s,oe),(t<=1||ho(w,E)>_)&&(v.push(E),w=E),D=ao(s,oe),(t<=1||ho(T,D)>_)&&(y.push(D),T=D),b=r,C=c}let te=e[0].point.slice(0,2),ne=e.length>1?e[e.length-1].point.slice(0,2):ao(e[0].point,[1,1]),re=[],ie=[];if(e.length===1){if(!(h||g)||l){let e=bo(te,go(lo(oo(te,ne))),-(S||x)),t=[];for(let n=1/13,r=n;r<=1;r+=n)t.push(vo(e,te,wo*2*r));return t}}else{if(!(h||g&&e.length===1)){if(u)for(let e=1/13,t=e;t<=1;t+=e){let e=vo(y[0],te,wo*t);re.push(e)}else{let e=oo(v[0],y[0]),t=so(e,.5),n=so(e,.51);re.push(oo(te,t),oo(te,n),ao(te,n),ao(te,t))}}let t=lo(io(e[e.length-1].vector));if(g||h&&e.length===1)ie.push(ne);else if(f){let e=bo(ne,t,x);for(let t=1/29,n=t;n<1;n+=t)ie.push(vo(e,ne,wo*3*n))}else ie.push(ao(ne,so(t,x)),ao(ne,so(t,x*.99)),oo(ne,so(t,x*.99)),oo(ne,so(t,x)))}return v.concat(ie,y.reverse(),re)}function Eo(e,t={}){let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let a=.15+(1-n)*.85,o=Array.isArray(e[0])?e:e.map(({x:e,y:t,pressure:n=.5})=>[e,t,n]);if(o.length===2){let e=o[1];o=o.slice(0,-1);for(let t=1;t<5;t++)o.push(yo(o[0],e,t/4))}o.length===1&&(o=[...o,[...ao(o[0],[1,1]),...o[0].slice(2)]]);let s=[{point:[o[0][0],o[0][1]],pressure:o[0][2]>=0?o[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],c=!1,l=0,u=s[0],d=o.length-1;for(let e=1;e<o.length;e++){let t=i&&e===d?o[e].slice(0,2):yo(u.point,o[e],a);if(fo(u.point,t))continue;let n=_o(t,u.point);if(l+=n,e<d&&!c){if(l<r)continue;c=!0}u={point:t,pressure:o[e][2]>=0?o[e][2]:.5,vector:go(oo(u.point,t)),distance:n,runningLength:l},s.push(u)}return s[0].vector=s[1]?.vector||[0,0],s}function Do(e,t={}){return To(Eo(e,t),t)}var Oo=e(n(),1),A=r();function ko(e,t){return Math.sqrt(Ao(e,t))}function Ao(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2}function jo(e,t,n){let r=Ao(t,n);if(r===0)return Ao(e,t);let i=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r;return i=Math.max(0,Math.min(1,i)),Ao(e,Mo(t,n,i))}function Mo(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function No(e,t){let n=e[t+0],r=e[t+1],i=e[t+2],a=e[t+3],o=3*r[0]-2*n[0]-a[0];o*=o;let s=3*r[1]-2*n[1]-a[1];s*=s;let c=3*i[0]-2*a[0]-n[0];c*=c;let l=3*i[1]-2*a[1]-n[1];return l*=l,o<c&&(o=c),s<l&&(s=l),o+s}function Po(e,t,n,r){let i=r||[];if(No(e,t)<n){let n=e[t+0];i.length?ko(i[i.length-1],n)>1&&i.push(n):i.push(n),i.push(e[t+3])}else{let r=.5,a=e[t+0],o=e[t+1],s=e[t+2],c=e[t+3],l=Mo(a,o,r),u=Mo(o,s,r),d=Mo(s,c,r),f=Mo(l,u,r),p=Mo(u,d,r),m=Mo(f,p,r);Po([a,l,f,m],0,n,i),Po([m,p,d,c],0,n,i)}return i}function Fo(e,t){return Io(e,0,e.length,t)}function Io(e,t,n,r,i){let a=i||[],o=e[t],s=e[n-1],c=0,l=1;for(let r=t+1;r<n-1;++r){let t=jo(e[r],o,s);t>c&&(c=t,l=r)}return Math.sqrt(c)>r?(Io(e,t,l+1,r,a),Io(e,l,n,r,a)):(a.length||a.push(o),a.push(s)),a}function Lo(e,t=.15,n){let r=[],i=(e.length-1)/3;for(let n=0;n<i;n++)Po(e,n*3,t,r);return n&&n>0?Io(r,0,r.length,n):r}var Ro=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sanitizeUrl=void 0;var t=/^([^\w]*)(javascript|data|vbscript)/im,n=/&#(\w+)(^\w|;)?/g,r=/&(newline|tab);/gi,i=/[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim,a=/^.+(:|:)/gim,o=[`.`,`/`];function s(e){return o.indexOf(e[0])>-1}function c(e){return e.replace(n,function(e,t){return String.fromCharCode(t)})}function l(e){var n=c(e||``).replace(r,``).replace(i,``).trim();if(!n)return`about:blank`;if(s(n))return n;var o=n.match(a);if(!o)return n;var l=o[0];return t.test(l)?`about:blank`:n}e.sanitizeUrl=l}))(),zo=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`;function Bo(e,t,n){let r=n[0];if(t!=null&&e>=t)throw Error(e+` >= `+t);if(e.slice(-1)===r||t&&t.slice(-1)===r)throw Error(`trailing zero`);if(t){let i=0;for(;(e[i]||r)===t[i];)i++;if(i>0)return t.slice(0,i)+Bo(e.slice(i),t.slice(i),n)}let i=e?n.indexOf(e[0]):0,a=t==null?n.length:n.indexOf(t[0]);return a-i>1?n[Math.round(.5*(i+a))]:t&&t.length>1?t.slice(0,1):n[i]+Bo(e.slice(1),null,n)}function Vo(e){if(e.length!==Ho(e[0]))throw Error(`invalid integer part of order key: `+e)}function Ho(e){if(e>=`a`&&e<=`z`)return e.charCodeAt(0)-97+2;if(e>=`A`&&e<=`Z`)return 90-e.charCodeAt(0)+2;throw Error(`invalid order key head: `+e)}function Uo(e){let t=Ho(e[0]);if(t>e.length)throw Error(`invalid order key: `+e);return e.slice(0,t)}function Wo(e,t){if(e===`A`+t[0].repeat(26))throw Error(`invalid order key: `+e);let n=Uo(e);if(e.slice(n.length).slice(-1)===t[0])throw Error(`invalid order key: `+e)}function Go(e,t){Vo(e);let[n,...r]=e.split(``),i=!0;for(let e=r.length-1;i&&e>=0;e--){let n=t.indexOf(r[e])+1;n===t.length?r[e]=t[0]:(r[e]=t[n],i=!1)}if(i){if(n===`Z`)return`a`+t[0];if(n===`z`)return null;let e=String.fromCharCode(n.charCodeAt(0)+1);return e>`a`?r.push(t[0]):r.pop(),e+r.join(``)}return n+r.join(``)}function Ko(e,t){Vo(e);let[n,...r]=e.split(``),i=!0;for(let e=r.length-1;i&&e>=0;e--){let n=t.indexOf(r[e])-1;n===-1?r[e]=t.slice(-1):(r[e]=t[n],i=!1)}if(i){if(n===`a`)return`Z`+t.slice(-1);if(n===`A`)return null;let e=String.fromCharCode(n.charCodeAt(0)-1);return e<`Z`?r.push(t.slice(-1)):r.pop(),e+r.join(``)}return n+r.join(``)}function qo(e,t,n=zo){if(e!=null&&Wo(e,n),t!=null&&Wo(t,n),e!=null&&t!=null&&e>=t)throw Error(e+` >= `+t);if(e==null){if(t==null)return`a`+n[0];let e=Uo(t),r=t.slice(e.length);if(e===`A`+n[0].repeat(26))return e+Bo(``,r,n);if(e<t)return e;let i=Ko(e,n);if(i==null)throw Error(`cannot decrement any more`);return i}if(t==null){let t=Uo(e),r=e.slice(t.length);return Go(t,n)??t+Bo(r,null,n)}let r=Uo(e),i=e.slice(r.length),a=Uo(t),o=t.slice(a.length);if(r===a)return r+Bo(i,o,n);let s=Go(r,n);if(s==null)throw Error(`cannot increment any more`);return s<t?s:r+Bo(i,null,n)}function Jo(e,t,n,r=zo){if(n===0)return[];if(n===1)return[qo(e,t,r)];if(t==null){let i=qo(e,t,r),a=[i];for(let e=0;e<n-1;e++)i=qo(i,t,r),a.push(i);return a}if(e==null){let i=qo(e,t,r),a=[i];for(let t=0;t<n-1;t++)i=qo(e,i,r),a.push(i);return a.reverse(),a}let i=Math.floor(n/2),a=qo(e,t,r);return[...Jo(e,a,i,r),a,...Jo(a,t,n-i-1,r)]}var Yo=typeof self>`u`?!1:!(`top`in self&&self!==top)&&`showOpenFilePicker`in self&&`showOpenFilePicker`,Xo=i(Yo?()=>import(`./file-open-002ab408-BHUWm0Sh.js`):()=>import(`./file-open-7c801643-DZtJT5zp.js`),[]);async function Zo(...e){return(await Xo).default(...e)}i(Yo?()=>import(`./directory-open-4ed118d0-1i309Asm.js`):()=>import(`./directory-open-01563666-D4xXyWb_.js`),[]);var Qo=i(Yo?()=>import(`./file-save-745eba88-Bwdfz6OZ.js`):()=>import(`./file-save-3189631c-CO9S4HFW.js`),[]);async function $o(...e){return(await Qo).default(...e)}var es=(e,t)=>t.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{}),ts=4,ns=[0,2,4,6,8],rs=(e,t)=>t.map(t=>ji[e][t]),j={transparent:`transparent`,black:`#1e1e1e`,white:`#ffffff`,gray:rs(`gray`,ns),red:rs(`red`,ns),pink:rs(`pink`,ns),grape:rs(`grape`,ns),violet:rs(`violet`,ns),blue:rs(`blue`,ns),cyan:rs(`cyan`,ns),teal:rs(`teal`,ns),green:rs(`green`,ns),yellow:rs(`yellow`,ns),orange:rs(`orange`,ns),bronze:[`#f8f1ee`,`#eaddd7`,`#d2bab0`,`#a18072`,`#846358`]},is=es(j,[`cyan`,`blue`,`violet`,`grape`,`pink`,`green`,`teal`,`yellow`,`orange`,`red`]),as=[j.black,j.red[4],j.green[4],j.blue[4],j.yellow[4]],os=[j.transparent,j.red[1],j.green[1],j.blue[1],j.yellow[1]],ss=[j.white,`#f8f9fa`,`#f5faff`,`#fffce8`,`#fdf8f6`],cs={transparent:j.transparent,white:j.white,gray:j.gray,black:j.black,bronze:j.bronze,...is},ls={transparent:j.transparent,white:j.white,gray:j.gray,black:j.black,bronze:j.bronze,...is},us=e=>[j.cyan[e],j.blue[e],j.violet[e],j.grape[e],j.pink[e],j.green[e],j.teal[e],j.yellow[e],j.orange[e],j.red[e]],ds=(e,t,n)=>`#${((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)}`,fs=/Mac|iPod|iPhone|iPad/.test(navigator.platform),ps=/^Win/.test(navigator.platform),ms=/\b(android)\b/i.test(navigator.userAgent),hs=`netscape`in window&&navigator.userAgent.indexOf(`rv:`)>1&&navigator.userAgent.indexOf(`Gecko`)>1,gs=navigator.userAgent.indexOf(`Chrome`)===-1&&navigator.userAgent.indexOf(`Safari`)!==-1,_s=/iPad|iPhone/.test(navigator.platform)||navigator.userAgent.includes(`Mac`)&&`ontouchend`in document,vs=()=>navigator.brave?.isBrave?.name===`isBrave`,ys=typeof window<`u`&&`ResizeObserver`in window,bs=`Excalidraw`,xs=36,Ss=Math.PI/12,Cs={TEXT:`text`,CROSSHAIR:`crosshair`,GRABBING:`grabbing`,GRAB:`grab`,POINTER:`pointer`,MOVE:`move`,AUTO:``},ws={MAIN:0,WHEEL:1,SECONDARY:2,TOUCH:-1,ERASER:5},Ts={enabled:`all`,disabled:`none`,inheritFromUI:`var(--ui-pointerEvents)`},Es={UNSTARTED:-1,ENDED:0,PLAYING:1,PAUSED:2,BUFFERING:3,CUED:5},Ds={TEST:`test`,DEVELOPMENT:`development`},Os={SHAPE_ACTIONS_MENU:`App-menu__left`,ZOOM_ACTIONS:`zoom-actions`,SEARCH_MENU_INPUT_WRAPPER:`layer-ui__search-inputWrapper`},ks=`Xiaolai`,As=`Segoe UI Emoji`,js={Virgil:1,Helvetica:2,Cascadia:3,Excalifont:5,Nunito:6,"Lilita One":7,"Comic Shanns":8,"Liberation Sans":9},Ms={[ks]:100,[As]:1e3},Ns=e=>{switch(e){case js.Excalifont:return[ks,As];default:return[As]}},Ps={LIGHT:`light`,DARK:`dark`},Fs={strokeColor:`#bbb`,strokeWidth:2,strokeStyle:`solid`,fillStyle:`solid`,roughness:0,roundness:null,backgroundColor:`transparent`,radius:8,nameOffsetY:3,nameColorLightTheme:`#999999`,nameColorDarkTheme:`#7a7a7a`,nameFontSize:14,nameLineHeight:1.25},Is=1,Ls=js.Excalifont,Rs=`left`,zs=4,Bs=2*zs-1e-5,Vs=`#ffffff`,Hs=`#1e1e1e`,Us=`#a2f1a6`,Ws=5,Gs={svg:`image/svg+xml`,png:`image/png`,jpg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`,ico:`image/x-icon`,avif:`image/avif`,jfif:`image/jfif`},M={text:`text/plain`,html:`text/html`,json:`application/json`,excalidraw:`application/vnd.excalidraw+json`,excalidrawlib:`application/vnd.excalidrawlib+json`,"excalidraw.svg":`image/svg+xml`,"excalidraw.png":`image/png`,binary:`application/octet-stream`,...Gs},Ks=[M.text,M.html,...Object.values(Gs)],qs={png:`png`,svg:`svg`,clipboard:`clipboard`},Js={excalidraw:`excalidraw`,excalidrawClipboard:`excalidraw/clipboard`,excalidrawLibrary:`excalidrawlib`,excalidrawClipboardWithAPI:`excalidraw-api/clipboard`},Ys=window.EXCALIDRAW_EXPORT_SOURCE||window.location.origin,Xs=.1,Zs=.1,Qs=`invert(93%) hue-rotate(180deg)`,$s={canvasActions:{changeViewBackgroundColor:!0,clearCanvas:!0,export:{saveFileToDisk:!0},loadScene:!0,saveToActiveFile:!0,toggleTheme:null,saveAsImage:!0},tools:{image:!0}},ec=1e3,tc=1229,nc=2,rc=[1,2,3],ic=1440,ac=4194304,N=`http://www.w3.org/2000/svg`,oc={excalidraw:2,excalidrawLibrary:2},sc=.7,cc=11,lc={TOP:`top`,MIDDLE:`middle`,BOTTOM:`bottom`},uc={LEFT:`left`,CENTER:`center`,RIGHT:`right`},dc=20,fc=.25,pc=32,mc={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},hc={architect:0,artist:1,cartoonist:2},gc={thin:1,bold:2,extraBold:4},_c={strokeColor:j.black,backgroundColor:j.transparent,fillStyle:`solid`,strokeWidth:2,strokeStyle:`solid`,roughness:hc.artist,opacity:100,locked:!1},vc=`library`,yc=`search`,bc={name:`default`,defaultTab:vc},xc=new Set([`iframe`,`embeddable`,`image`]),Sc={selection:`selection`,rectangle:`rectangle`,diamond:`diamond`,ellipse:`ellipse`,arrow:`arrow`,line:`line`,freedraw:`freedraw`,text:`text`,image:`image`,eraser:`eraser`,hand:`hand`,frame:`frame`,magicframe:`magicframe`,embeddable:`embeddable`,laser:`laser`},Cc={OAI_API_KEY:`excalidraw-oai-api-key`,MERMAID_TO_EXCALIDRAW:`mermaid-to-excalidraw`,PUBLISH_LIBRARY:`publish-library-data`},wc=`Untitled`,Tc={generalStats:1,elementProperties:2},Ec={sharp:`sharp`,round:`round`,elbow:`elbow`},Dc=.3,Oc=`element`,kc=Symbol.for(`__test__originalId__`),Ac=(e=>(e.ACTIVE=`active`,e.AWAY=`away`,e.IDLE=`idle`,e))(Ac||{}),jc=rc.includes(devicePixelRatio)?devicePixelRatio:1,Mc=()=>({showWelcomeScreen:!1,theme:Ps.LIGHT,collaborators:new Map,currentChartType:`bar`,currentItemBackgroundColor:_c.backgroundColor,currentItemEndArrowhead:`arrow`,currentItemFillStyle:_c.fillStyle,currentItemFontFamily:Ls,currentItemFontSize:20,currentItemOpacity:_c.opacity,currentItemRoughness:_c.roughness,currentItemStartArrowhead:null,currentItemStrokeColor:_c.strokeColor,currentItemRoundness:`round`,currentItemArrowType:Ec.round,currentItemStrokeStyle:_c.strokeStyle,currentItemStrokeWidth:_c.strokeWidth,currentItemTextAlign:Rs,currentHoveredFontFamily:null,cursorButton:`up`,activeEmbeddable:null,newElement:null,editingTextElement:null,editingGroupId:null,editingLinearElement:null,activeTool:{type:`selection`,customType:null,locked:_c.locked,lastActiveTool:null},penMode:!1,penDetected:!1,errorMessage:null,exportBackground:!0,exportScale:jc,exportEmbedScene:!1,exportWithDarkMode:!1,fileHandle:null,gridSize:20,gridStep:Ws,gridModeEnabled:!1,isBindingEnabled:!0,defaultSidebarDockedPreference:!1,isLoading:!1,isResizing:!1,isRotating:!1,lastPointerDownWith:`mouse`,multiElement:null,name:null,contextMenu:null,openMenu:null,openPopup:null,openSidebar:null,openDialog:null,pasteDialog:{shown:!1,data:null},previousSelectedElementIds:{},resizingElement:null,scrolledOutside:!1,scrollX:0,scrollY:0,selectedElementIds:{},hoveredElementIds:{},selectedGroupIds:{},selectedElementsAreBeingDragged:!1,selectionElement:null,shouldCacheIgnoreZoom:!1,stats:{open:!1,panels:Tc.generalStats|Tc.elementProperties},startBoundElement:null,suggestedBindings:[],frameRendering:{enabled:!0,clip:!0,name:!0,outline:!0},frameToHighlight:null,editingFrame:null,elementsToHighlight:null,toast:null,viewBackgroundColor:j.white,zenModeEnabled:!1,zoom:{value:1},viewModeEnabled:!1,pendingImageElementId:null,showHyperlinkPopup:!1,selectedLinearElement:null,snapLines:[],originSnapOffset:{x:0,y:0},objectsSnapModeEnabled:!1,userToFollow:null,followedBy:new Set,isCropping:!1,croppingElementId:null,searchMatches:[]}),Nc=(e=>e)({showWelcomeScreen:{browser:!0,export:!1,server:!1},theme:{browser:!0,export:!1,server:!1},collaborators:{browser:!1,export:!1,server:!1},currentChartType:{browser:!0,export:!1,server:!1},currentItemBackgroundColor:{browser:!0,export:!1,server:!1},currentItemEndArrowhead:{browser:!0,export:!1,server:!1},currentItemFillStyle:{browser:!0,export:!1,server:!1},currentItemFontFamily:{browser:!0,export:!1,server:!1},currentItemFontSize:{browser:!0,export:!1,server:!1},currentItemRoundness:{browser:!0,export:!1,server:!1},currentItemArrowType:{browser:!0,export:!1,server:!1},currentItemOpacity:{browser:!0,export:!1,server:!1},currentItemRoughness:{browser:!0,export:!1,server:!1},currentItemStartArrowhead:{browser:!0,export:!1,server:!1},currentItemStrokeColor:{browser:!0,export:!1,server:!1},currentItemStrokeStyle:{browser:!0,export:!1,server:!1},currentItemStrokeWidth:{browser:!0,export:!1,server:!1},currentItemTextAlign:{browser:!0,export:!1,server:!1},currentHoveredFontFamily:{browser:!1,export:!1,server:!1},cursorButton:{browser:!0,export:!1,server:!1},activeEmbeddable:{browser:!1,export:!1,server:!1},newElement:{browser:!1,export:!1,server:!1},editingTextElement:{browser:!1,export:!1,server:!1},editingGroupId:{browser:!0,export:!1,server:!1},editingLinearElement:{browser:!1,export:!1,server:!1},activeTool:{browser:!0,export:!1,server:!1},penMode:{browser:!0,export:!1,server:!1},penDetected:{browser:!0,export:!1,server:!1},errorMessage:{browser:!1,export:!1,server:!1},exportBackground:{browser:!0,export:!1,server:!1},exportEmbedScene:{browser:!0,export:!1,server:!1},exportScale:{browser:!0,export:!1,server:!1},exportWithDarkMode:{browser:!0,export:!1,server:!1},fileHandle:{browser:!1,export:!1,server:!1},gridSize:{browser:!0,export:!0,server:!0},gridStep:{browser:!0,export:!0,server:!0},gridModeEnabled:{browser:!0,export:!0,server:!0},height:{browser:!1,export:!1,server:!1},isBindingEnabled:{browser:!1,export:!1,server:!1},defaultSidebarDockedPreference:{browser:!0,export:!1,server:!1},isLoading:{browser:!1,export:!1,server:!1},isResizing:{browser:!1,export:!1,server:!1},isRotating:{browser:!1,export:!1,server:!1},lastPointerDownWith:{browser:!0,export:!1,server:!1},multiElement:{browser:!1,export:!1,server:!1},name:{browser:!0,export:!1,server:!1},offsetLeft:{browser:!1,export:!1,server:!1},offsetTop:{browser:!1,export:!1,server:!1},contextMenu:{browser:!1,export:!1,server:!1},openMenu:{browser:!0,export:!1,server:!1},openPopup:{browser:!1,export:!1,server:!1},openSidebar:{browser:!0,export:!1,server:!1},openDialog:{browser:!1,export:!1,server:!1},pasteDialog:{browser:!1,export:!1,server:!1},previousSelectedElementIds:{browser:!0,export:!1,server:!1},resizingElement:{browser:!1,export:!1,server:!1},scrolledOutside:{browser:!0,export:!1,server:!1},scrollX:{browser:!0,export:!1,server:!1},scrollY:{browser:!0,export:!1,server:!1},selectedElementIds:{browser:!0,export:!1,server:!1},hoveredElementIds:{browser:!1,export:!1,server:!1},selectedGroupIds:{browser:!0,export:!1,server:!1},selectedElementsAreBeingDragged:{browser:!1,export:!1,server:!1},selectionElement:{browser:!1,export:!1,server:!1},shouldCacheIgnoreZoom:{browser:!0,export:!1,server:!1},stats:{browser:!0,export:!1,server:!1},startBoundElement:{browser:!1,export:!1,server:!1},suggestedBindings:{browser:!1,export:!1,server:!1},frameRendering:{browser:!1,export:!1,server:!1},frameToHighlight:{browser:!1,export:!1,server:!1},editingFrame:{browser:!1,export:!1,server:!1},elementsToHighlight:{browser:!1,export:!1,server:!1},toast:{browser:!1,export:!1,server:!1},viewBackgroundColor:{browser:!0,export:!0,server:!0},width:{browser:!1,export:!1,server:!1},zenModeEnabled:{browser:!0,export:!1,server:!1},zoom:{browser:!0,export:!1,server:!1},viewModeEnabled:{browser:!1,export:!1,server:!1},pendingImageElementId:{browser:!1,export:!1,server:!1},showHyperlinkPopup:{browser:!1,export:!1,server:!1},selectedLinearElement:{browser:!0,export:!1,server:!1},snapLines:{browser:!1,export:!1,server:!1},originSnapOffset:{browser:!1,export:!1,server:!1},objectsSnapModeEnabled:{browser:!0,export:!1,server:!1},userToFollow:{browser:!1,export:!1,server:!1},followedBy:{browser:!1,export:!1,server:!1},isCropping:{browser:!1,export:!1,server:!1},croppingElementId:{browser:!1,export:!1,server:!1},searchMatches:{browser:!1,export:!1,server:!1}}),Pc=(e,t)=>{let n={};for(let r of Object.keys(e))Nc[r]?.[t]&&(n[r]=e[r]);return n},Fc=e=>Pc(e,`export`),Ic=e=>Pc(e,`server`),Lc=({activeTool:e})=>e.type===`eraser`,Rc=({activeTool:e})=>e.type===`hand`,P=(e,t,n)=>Math.min(Math.max(e,t),n),zc=(e,t,n=`round`)=>{let r=10**t;return Math[n]((e+2**-52)*r)/r},Bc=(e,t,n=`round`)=>{let r=1/t;return Math[n](e*r)/r},Vc=(e,t)=>(e+t)/2,Hc=e=>typeof e==`number`&&Number.isFinite(e),Uc=(e,t,n=1e-4)=>Math.abs(e-t)<n,Wc=e=>e<0?e+2*Math.PI:e>=2*Math.PI?e-2*Math.PI:e;function Gc(e){return e*Math.PI/180}function Kc(e){return e*180/Math.PI}function qc(e){return Math.abs(Math.sin(2*e))<1e-4}function Jc(e,t,n=0,r=0){return[e-n,t-r]}function F(e,t=[0,0]){return Jc(e[0]-t[0],e[1]-t[1])}function Yc(e,t){return e[0]*t[1]-t[0]*e[1]}function Xc(e,t){return e[0]*t[0]+e[1]*t[1]}function Zc(e,t){return[e[0]+t[0],e[1]+t[1]]}function Qc(e,t){return[e[0]-t[0],e[1]-t[1]]}function $c(e,t){return Jc(e[0]*t,e[1]*t)}function el(e){return e[0]*e[0]+e[1]*e[1]}function tl(e){return Math.sqrt(el(e))}var nl=e=>{let t=tl(e);return t===0?Jc(0,0):Jc(e[0]/t,e[1]/t)};function I(e,t){return[e,t]}function rl(e){return e.length===2?I(e[0],e[1]):void 0}function L(e,t=I(0,0)){return I(t[0]+e[0],t[1]+e[1])}function il(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&!isNaN(e[0])&&typeof e[1]==`number`&&!isNaN(e[1])}function al(e,t){let n=Math.abs;return n(e[0]-t[0])<1e-4&&n(e[1]-t[1])<1e-4}function R([e,t],[n,r],i){return I((e-n)*Math.cos(i)-(t-r)*Math.sin(i)+n,(e-n)*Math.sin(i)+(t-r)*Math.cos(i)+r)}function ol(e,t=[0,0]){return I(e[0]+t[0],e[1]+t[1])}function sl(e,t){return I((e[0]+t[0])/2,(e[1]+t[1])/2)}function cl(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}function ll(e,t){let n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}var ul=(e,t,n)=>ol(t,$c(F(e,t),n)),dl=(e,t,n)=>t[0]<=Math.max(e[0],n[0])&&t[0]>=Math.min(e[0],n[0])&&t[1]<=Math.max(e[1],n[1])&&t[1]>=Math.min(e[1],n[1]);function fl(e,t){return[e,t]}function pl(e,t){let n=e[1][1]-e[0][1],r=e[0][0]-e[1][0],i=t[1][1]-t[0][1],a=t[0][0]-t[1][0],o=n*a-i*r;if(o!==0){let s=n*e[0][0]+r*e[0][1],c=i*t[0][0]+a*t[0][1];return I((s*a-c*r)/o,(n*c-i*s)/o)}return null}function z(e,t){return[e,t]}var ml=(e,t,n=1e-4)=>{let r=hl(e,t);return r===0||r<n},hl=(e,t)=>{let[n,r]=e,[[i,a],[o,s]]=t,c=n-i,l=r-a,u=o-i,d=s-a,f=c*u+l*d,p=u*u+d*d,m=-1;p!==0&&(m=f/p);let h,g;m<0?(h=i,g=a):m>1?(h=o,g=s):(h=i+m*u,g=a+m*d);let _=n-h,v=r-g;return Math.sqrt(_*_+v*v)};function gl(e,t){let n=pl(fl(e[0],e[1]),fl(t[0],t[1]));return!n||!ml(n,t)||!ml(n,e)?null:n}function _l(e,t){return[e,t]}function vl(e,t){return[z(e[0],I(e[1][0],e[0][1])),z(I(e[1][0],e[0][1]),e[1]),z(e[1],I(e[0][0],e[1][1])),z(I(e[0][0],e[1][1]),e[0])].map(e=>gl(t,e)).filter(e=>!!e)}function yl(e,t,n,r){return[e,t,n,r]}function bl(e,t,n,r=1e-6){return[(e(t+r,n)-e(t-r,n))/(2*r),(e(t,n+r)-e(t,n-r))/(2*r)]}function xl(e,t,n,r=.001,i=10){let a=1/0,o=0;for(;a>=r;){if(o>=i)return null;let r=e(t,n),s=[bl((t,n)=>e(t,n)[0],t,n),bl((t,n)=>e(t,n)[1],t,n)],c=[[-r[0]],[-r[1]]],l=s[0][0]*s[1][1]-s[0][1]*s[1][0];if(l===0)return null;let u=[[s[1][1]/l,-s[0][1]/l],[-s[1][0]/l,s[0][0]/l]],d=[[u[0][0]*c[0][0]+u[0][1]*c[1][0]],[u[1][0]*c[0][0]+u[1][1]*c[1][0]]];t+=d[0][0],n+=d[1][0];let[f,p]=e(t,n);a=Math.max(Math.abs(f),Math.abs(p)),o+=1}return[t,n]}var Sl=(e,t)=>I((1-t)**3*e[0][0]+3*(1-t)**2*t*e[1][0]+3*(1-t)*t**2*e[2][0]+t**3*e[3][0],(1-t)**3*e[0][1]+3*(1-t)**2*t*e[1][1]+3*(1-t)*t**2*e[2][1]+t**3*e[3][1]);function Cl(e,t){let n=El(e);if(vl(_l(I(n[0],n[1]),I(n[2],n[3])),t).length===0)return[];let r=e=>I(t[0][0]+e*(t[1][0]-t[0][0]),t[0][1]+e*(t[1][1]-t[0][1])),i=[[.5,0],[.2,0],[.8,0]],a=([t,n])=>{let i=xl((t,n)=>{let i=Sl(e,t),a=r(n);return[i[0]-a[0],i[1]-a[1]]},t,n);if(!i)return null;let[a,o]=i;return a<0||a>1||o<0||o>1?null:Sl(e,a)},o=a(i[0]);return o?[o]:(o=a(i[1]),o?[o]:(o=a(i[2]),o?[o]:[]))}function wl(e,t,n=.001){let r=(e,t,r,i=n)=>{let a=e,o=t,s;for(;o-a>i;)s=(o+a)/2,r(s-i)<r(s+i)?o=s:a=s;return s},i=0;for(let n=1/0,r=0;r<30;r++){let a=cl(t,Sl(e,r/30));a<n&&(n=a,i=r)}let a=r(Math.max((i-1)/30,0),Math.min((i+1)/30,1),n=>cl(t,Sl(e,n)));return a?Sl(e,a):null}function Tl(e,t){let n=wl(e,t);return n?cl(t,n):0}function El(e){let[t,n,r,i]=e,a=[t[0],n[0],r[0],i[0]],o=[t[1],n[1],r[1],i[1]];return[Math.min(...a),Math.min(...o),Math.max(...a),Math.max(...o)]}function Dl(...e){return jl(e)}function Ol(e){return jl(e)}var kl=(e,t)=>{let n=e[0],r=e[1],i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e][0],s=t[e][1],c=t[a][0],l=t[a][1];(s>r&&l<=r||s<=r&&l>r)&&n<(c-o)*(r-s)/(l-s)+o&&(i=!i)}return i},Al=(e,t,n=1e-4)=>{let r=!1;for(let i=0,a=t.length-1;i<a;i++)if(ml(e,z(t[i],t[i+1]),n)){r=!0;break}return r};function jl(e){return Ml(e)?e:[...e,e[0]]}function Ml(e){return al(e[0],e[e.length-1])}function Nl(e,t){return Vu([e,t])}var Pl=([e,t],[n,r])=>e<=n?t>=n:e>=n&&r>=e,Fl=([e,t],[n,r])=>{let i=Math.max(e,n),a=Math.min(t,r);return i<=a?Vu([i,a]):null},Il=(e,[t,n])=>e>=t&&e<=n;function Ll([e,t,n],r){let i=(e,t,n)=>(e[0]-n[0])*(t[1]-n[1])-(t[0]-n[0])*(e[1]-n[1]),a=i(r,e,t),o=i(r,t,n),s=i(r,n,e);return!((a<0||o<0||s<0)&&(a>0||o>0||s>0))}var Rl=()=>{let e=new Date;return`${e.getFullYear()}-${`${e.getMonth()+1}`.padStart(2,`0`)}-${`${e.getDate()}`.padStart(2,`0`)}-${`${e.getHours()}`.padStart(2,`0`)}${`${e.getMinutes()}`.padStart(2,`0`)}`},zl=e=>e.charAt(0).toUpperCase()+e.slice(1),Bl=e=>e instanceof HTMLElement&&e.className.includes(`ToolIcon`),Vl=e=>e instanceof HTMLElement&&e.dataset.type===`wysiwyg`||e instanceof HTMLBRElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,Hl=e=>Vl(e)||e instanceof Element&&!!e.closest(`label, button`),Ul=e=>e instanceof HTMLElement&&e.dataset.type===`wysiwyg`||e instanceof HTMLBRElement||e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&(e.type===`text`||e.type===`number`||e.type===`password`),Wl=({fontFamily:e})=>{for(let[t,n]of Object.entries(js))if(n===e)return`${t}${Ns(n).map(e=>`, ${e}`).join(``)}`;return As},Gl=({fontSize:e,fontFamily:t})=>`${e}px ${Wl({fontFamily:t})}`,Kl=(e,t)=>{let n=0,r=null,i=(...i)=>{r=i,clearTimeout(n),n=window.setTimeout(()=>{r=null,e(...i)},t)};return i.flush=()=>{if(clearTimeout(n),r){let t=r;r=null,e(...t)}},i.cancel=()=>{r=null,clearTimeout(n)},i},ql=(e,t)=>{let n=null,r=null,i=null,a=t=>{n=window.requestAnimationFrame(()=>{n=null,e(...t),r=null,i&&(r=i,i=null,a(r))})},o=(...o)=>{if(s.MODE===`test`){e(...o);return}r=o,n===null?a(r):t?.trailing&&(i=o)};return o.flush=()=>{n!==null&&(cancelAnimationFrame(n),n=null),r&&=(e(...i||r),i=null)},o.cancel=()=>{r=i=null,n!==null&&(cancelAnimationFrame(n),n=null)},o},Jl=e=>1-(1-e)**4,Yl=(e,t,n)=>(t-e)*Jl(n)+e,Xl=({fromValues:e,toValues:t,onStep:n,duration:r=250,interpolateValue:i,onStart:a,onEnd:o,onCancel:s})=>{let c=!1,l=0,u;function d(s){if(c)return;u===void 0&&(u=s,a?.());let f=Math.min(s-u,r),p=Jl(f/r),m={};if(Object.keys(e).forEach(n=>{let r=n,i=(t[r]-e[r])*p+e[r];m[r]=i}),n(m),f<r){let a=f/r,o={};Object.keys(e).forEach(n=>{let r=n,s=e[r],c=t[r],l;l=i?i(s,c,a,r):Yl(s,c,a),l??=Yl(s,c,a),o[r]=l}),n(o),l=window.requestAnimationFrame(d)}else n(t),o?.()}return l=window.requestAnimationFrame(d),()=>{s?.(),c=!0,window.cancelAnimationFrame(l)}},Zl=(e,t)=>{if(!e.length||t<1)return[];let n=0,r=0,i=Array(Math.ceil(e.length/t));for(;n<e.length;)i[r++]=e.slice(n,n+=t);return i},Ql=(e,t)=>Math.abs(e-t),$l=(e,t)=>t.type===`custom`?{...e.activeTool,type:`custom`,customType:t.customType,locked:t.locked??e.activeTool.locked}:{...e.activeTool,lastActiveTool:t.lastActiveToolBeforeEraser===void 0?e.activeTool.lastActiveTool:t.lastActiveToolBeforeEraser,type:t.type,customType:null,locked:t.locked??e.activeTool.locked},eu=e=>(e=e.replace(/\bAlt\b/i,`Alt`).replace(/\bShift\b/i,`Shift`).replace(/\b(Enter|Return)\b/i,`Enter`),fs?e.replace(/\bCtrlOrCmd\b/gi,`Cmd`).replace(/\bAlt\b/i,`Option`):e.replace(/\bCtrlOrCmd\b/gi,`Ctrl`)),tu=({clientX:e,clientY:t},{zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:o})=>({x:(e-r)/n.value-a,y:(t-i)/n.value-o}),nu=({sceneX:e,sceneY:t},{zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:o})=>({x:(e+a)*n.value+r,y:(t+o)*n.value+i}),ru=e=>getComputedStyle(document.documentElement).getPropertyValue(`--${e}`),iu=RegExp(`^[^A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-﷾--]*[֑-߿יִ-﷽ﹰ-ﻼ]`),au=e=>iu.test(e),ou=e=>{let[t,n]=e;return{x:t,y:n}},su=e=>{if(e?.name===`AbortError`){console.warn(e);return}throw e},cu=(e,t,n=0)=>{n<0&&(n=e.length+n),n=Math.min(e.length,Math.max(n,0));let r=n-1;for(;++r<e.length;)if(t(e[r],r,e))return r;return-1},lu=(e,t,n=e.length-1)=>{n<0&&(n=e.length+n),n=Math.min(e.length-1,Math.max(n,0));let r=n+1;for(;--r>-1;)if(t(e[r],r,e))return r;return-1},uu=e=>{let t=e.length===5&&e.substr(4,1)===`0`,n=e.length===9&&e.substr(7,2)===`00`;return t||n||e===j.transparent},du=e=>e.fillStyle!==`solid`||uu(e.backgroundColor),fu=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},pu=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;let{overflowY:e}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(e===`auto`||e===`scroll`||e===`overlay`))return t;t=t.parentElement}return document},mu=e=>{let t=e.parentElement;for(;t;){if(t.tabIndex>-1){t.focus();return}t=t.parentElement}},hu=e=>Array.from(e).map(e=>`0${e.toString(16)}`.slice(-2)).join(``),gu=()=>xu()?1:Date.now(),_u=e=>e instanceof Map?e:e.reduce((e,t)=>(e.set(typeof t==`string`?t:t.id,t),e),new Map),vu=e=>e.reduce((e,t,n)=>(e.set(t.id,[t,n]),e),new Map),yu=(e,t)=>e.reduce((e,n)=>(e[t?t(n):String(n)]=n,e),{}),bu=e=>e.reduce((t,n,r)=>{let i={...n,prev:null,next:null};if(r!==0){let n=t[r-1];if(i.prev=n,n.next=i,r===e.length-1){let e=t[0];i.next=e,e.prev=i}}return t.push(i),t},[]),xu=()=>s.MODE===`test`,Su=()=>s.MODE===`development`,Cu=()=>typeof process<`u`&&!0,wu=(e,t)=>new CustomEvent(e,{detail:{nativeEvent:t},cancelable:!0}),Tu=(e,t)=>{let n=!1;for(let r in t){let i=t[r];if(typeof i<`u`){if(e[r]===i&&(typeof i!=`object`||!i))continue;n=!0}}return n?{...e,...t}:e},Eu=()=>{try{return window.self===window.top?`top`:`iframe`}catch{return`iframe`}},Du=e=>!!e&&typeof e==`object`&&`then`in e&&`catch`in e&&`finally`in e,Ou=e=>{let t=e?.querySelectorAll(`button, a, input, select, textarea, div[tabindex], label[tabindex]`);return t?Array.from(t).filter(e=>e.tabIndex>-1&&!e.disabled):[]},ku=(e,t)=>Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t,Au=(e,t,n,r=!1)=>{let i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return r&&console.warn(`%cisShallowEqual: objects don't have same properties ->`,`color: #8B4000`,e,t),!1;if(n&&Array.isArray(n)){for(let i of n)if(!(e[i]===t[i]||ku(e[i],t[i])))return r&&console.warn(`%cisShallowEqual: ${i} not equal ->`,`color: #8B4000`,e[i],t[i]),!1;return!0}return i.every(i=>{let a=n?.[i],o=a?a(e[i],t[i]):e[i]===t[i]||ku(e[i],t[i]);return!o&&r&&console.warn(`%cisShallowEqual: ${i} not equal ->`,`color: #8B4000`,e[i],t[i]),o})},ju=(e,t,{checkForDefaultPrevented:n=!0}={})=>function(r){if(e?.(r),!n||!r?.defaultPrevented)return t?.(r)},Mu=(e,t,n)=>{if(!t)return e;if(n)return console.error(t),e;throw Error(t)};function Nu(e,t){if(!e)throw Error(t)}var Pu=e=>{let t,n,r=function(r){let i=Object.entries(r);if(t){let e=!0;for(let[n,r]of i)if(t.get(n)!==r){e=!1;break}if(e)return n}let a=e(r);return t=new Map(i),n=a,a};return r.clear=()=>{t=void 0,n=void 0},r},Fu=(e,t)=>e instanceof Set||e instanceof Map?e.has(t):`includes`in e?e.includes(t):e.hasOwnProperty(t),Iu=e=>JSON.parse(JSON.stringify(e)),Lu=(e,t)=>Au(e,t)?e:t;function Ru(e,t,n,r){return e?(e?.addEventListener?.(t,n,r),()=>{e?.removeEventListener?.(t,n,r)}):()=>{}}function zu(e,t=!0){let n=e.length;if(n<4)return``;let r=e[0],i=e[1],a=e[2],o=`M${r[0].toFixed(2)},${r[1].toFixed(2)} Q${i[0].toFixed(2)},${i[1].toFixed(2)} ${Vc(i[0],a[0]).toFixed(2)},${Vc(i[1],a[1]).toFixed(2)} T`;for(let t=2,a=n-1;t<a;t++)r=e[t],i=e[t+1],o+=`${Vc(r[0],i[0]).toFixed(2)},${Vc(r[1],i[1]).toFixed(2)} `;return t&&(o+=`Z`),o}var Bu=e=>e.replace(/\r?\n|\r/g,`
|
|
8
|
+
PQIDAQAB`,VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX:`false`,VITE_APP_COLLAPSE_OVERLAY:`false`,VITE_APP_ENABLE_ESLINT:`false`,PKG_NAME:`@excalidraw/excalidraw`,PKG_VERSION:`0.18.1`,PROD:!0},c=t((e=>{(function(t){typeof DO_NOT_EXPORT_CRC>`u`?typeof e==`object`?t(e):typeof define==`function`&&define.amd?define(function(){var e={};return t(e),e}):t({}):t({})})(function(e){e.version=`0.3.0`;function t(){for(var e=0,t=Array(256),n=0;n!=256;++n)e=n,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,e=e&1?-306674912^e>>>1:e>>>1,t[n]=e;return typeof Int32Array<`u`?new Int32Array(t):t}var n=t(),r=typeof Buffer<`u`;function i(e){if(e.length>32768&&r)return o(new Buffer(e));for(var t=-1,i=e.length-1,a=0;a<i;)t=n[(t^e.charCodeAt(a++))&255]^t>>>8,t=n[(t^e.charCodeAt(a++))&255]^t>>>8;return a===i&&(t=t>>>8^n[(t^e.charCodeAt(a))&255]),t^-1}function a(e){if(e.length>1e4)return o(e);for(var t=-1,r=0,i=e.length-3;r<i;)t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255];for(;r<i+3;)t=t>>>8^n[(t^e[r++])&255];return t^-1}function o(e){for(var t=-1,r=0,i=e.length-7;r<i;)t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255],t=t>>>8^n[(t^e[r++])&255];for(;r<i+7;)t=t>>>8^n[(t^e[r++])&255];return t^-1}function s(e){for(var t=-1,r=0,i=e.length,a,o;r<i;)a=e.charCodeAt(r++),a<128?t=t>>>8^n[(t^a)&255]:a<2048?(t=t>>>8^n[(t^(192|a>>6&31))&255],t=t>>>8^n[(t^(128|a&63))&255]):a>=55296&&a<57344?(a=(a&1023)+64,o=e.charCodeAt(r++)&1023,t=t>>>8^n[(t^(240|a>>8&7))&255],t=t>>>8^n[(t^(128|a>>2&63))&255],t=t>>>8^n[(t^(128|o>>6&15|a&3))&255],t=t>>>8^n[(t^(128|o&63))&255]):(t=t>>>8^n[(t^(224|a>>12&15))&255],t=t>>>8^n[(t^(128|a>>6&63))&255],t=t>>>8^n[(t^(128|a&63))&255]);return t^-1}e.table=n,e.bstr=i,e.buf=a,e.str=s})})),l=t(((e,t)=>{var n=c();t.exports=o;var r=new Uint8Array(4),i=new Int32Array(r.buffer),a=new Uint32Array(r.buffer);function o(e){if(e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71)throw Error(`Invalid .png file header`);if(e[4]!==13||e[5]!==10)throw Error(`Invalid .png file header: possibly caused by DOS-Unix line ending conversion?`);if(e[6]!==26)throw Error(`Invalid .png file header`);if(e[7]!==10)throw Error(`Invalid .png file header: possibly caused by DOS-Unix line ending conversion?`);for(var t=!1,o=[],s=8;s<e.length;){r[3]=e[s++],r[2]=e[s++],r[1]=e[s++],r[0]=e[s++];var c=a[0]+4,l=new Uint8Array(c);l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++];var u=String.fromCharCode(l[0])+String.fromCharCode(l[1])+String.fromCharCode(l[2])+String.fromCharCode(l[3]);if(!o.length&&u!==`IHDR`)throw Error(`IHDR header missing`);if(u===`IEND`){t=!0,o.push({name:u,data:new Uint8Array});break}for(var d=4;d<c;d++)l[d]=e[s++];r[3]=e[s++],r[2]=e[s++],r[1]=e[s++],r[0]=e[s++];var f=i[0];if(n.buf(l)!==f)throw Error(`CRC values for `+u+` header do not match, PNG file is likely corrupted`);var p=new Uint8Array(l.buffer.slice(4));o.push({name:u,data:p})}if(!t)throw Error(`.png file ended prematurely: no IEND header was found`);return o}})),u=t(((e,t)=>{t.exports=n;function n(e,t){if(e=String(e),t=String(t),!/^[\x00-\xFF]+$/.test(e)||!/^[\x00-\xFF]+$/.test(t))throw Error(`Only Latin-1 characters are permitted in PNG tEXt chunks. You might want to consider base64 encoding and/or zEXt compression`);if(e.length>=80)throw Error(`Keyword "`+e+`" is longer than the 79-character limit imposed by the PNG specification`);for(var n=e.length+t.length+1,r=new Uint8Array(n),i=0,a,o=0;o<e.length;o++){if(!(a=e.charCodeAt(o)))throw Error(`0x00 character is not permitted in tEXt keywords`);r[i++]=a}r[i++]=0;for(var s=0;s<t.length;s++){if(!(a=t.charCodeAt(s)))throw Error(`0x00 character is not permitted in tEXt content`);r[i++]=a}return{name:`tEXt`,data:r}}})),d=t(((e,t)=>{t.exports=n;function n(e){e.data&&e.name&&(e=e.data);for(var t=!0,n=``,r=``,i=0;i<e.length;i++){var a=e[i];if(t)a?r+=String.fromCharCode(a):t=!1;else if(a)n+=String.fromCharCode(a);else throw Error(`Invalid NULL character found. 0x00 character is not permitted in tEXt content`)}return{keyword:r,text:n}}})),f=t((e=>{e.encode=u(),e.decode=d()})),p=t(((e,t)=>{t.exports=function(e,t,n){var r=[],i=e.length;if(i===0)return r;var a=t<0?Math.max(0,t+i):t||0;for(n!==void 0&&(i=n<0?n+i:n);i-->a;)r[i-a]=e[i];return r}})),m=t(((e,t)=>{var n=p(),r=c();t.exports=s;var i=new Uint8Array(4),a=new Int32Array(i.buffer),o=new Uint32Array(i.buffer);function s(e){var t=8,s=t,c;for(c=0;c<e.length;c++)t+=e[c].data.length,t+=12;var l=new Uint8Array(t);for(l[0]=137,l[1]=80,l[2]=78,l[3]=71,l[4]=13,l[5]=10,l[6]=26,l[7]=10,c=0;c<e.length;c++){var u=e[c],d=u.name,f=u.data,p=f.length,m=[d.charCodeAt(0),d.charCodeAt(1),d.charCodeAt(2),d.charCodeAt(3)];o[0]=p,l[s++]=i[3],l[s++]=i[2],l[s++]=i[1],l[s++]=i[0],l[s++]=m[0],l[s++]=m[1],l[s++]=m[2],l[s++]=m[3];for(var h=0;h<p;)l[s++]=f[h++];var g=m.concat(n(f));a[0]=r.buf(g),l[s++]=i[3],l[s++]=i[2],l[s++]=i[1],l[s++]=i[0]}return l}})),h=e(l(),1),g=e(f(),1),_=e(m(),1),v=4,y=0,b=1,x=2;function S(e){let t=e.length;for(;--t>=0;)e[t]=0}var C=29,w=256,T=286,E=30,D=19,ee=573,te=15,ne=16,re=7,ie=256,ae=16,oe=17,se=18,ce=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]),le=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]),ue=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),de=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fe=512,pe=Array(576);S(pe);var me=Array(60);S(me);var he=Array(fe);S(he);var ge=Array(256);S(ge);var _e=Array(C);S(_e);var ve=Array(E);S(ve);function ye(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}var be,xe,Se;function Ce(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var we=e=>e<256?he[e]:he[256+(e>>>7)],Te=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},Ee=(e,t,n)=>{e.bi_valid>ne-n?(e.bi_buf|=t<<e.bi_valid&65535,Te(e,e.bi_buf),e.bi_buf=t>>ne-e.bi_valid,e.bi_valid+=n-ne):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},De=(e,t,n)=>{Ee(e,n[t*2],n[t*2+1])},Oe=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},ke=e=>{e.bi_valid===16?(Te(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)},Ae=(e,t)=>{let n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,d,f,p,m,h=0;for(f=0;f<=te;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<ee;l++)u=e.heap[l],f=n[n[u*2+1]*2+1]+1,f>c&&(f=c,h++),n[u*2+1]=f,!(u>r)&&(e.bl_count[f]++,p=0,u>=s&&(p=o[u-s]),m=n[u*2],e.opt_len+=m*(f+p),a&&(e.static_len+=m*(i[u*2+1]+p)));if(h!==0){do{for(f=c-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(f=c;f!==0;f--)for(u=e.bl_count[f];u!==0;)d=e.heap[--l],!(d>r)&&(n[d*2+1]!==f&&(e.opt_len+=(f-n[d*2+1])*n[d*2],n[d*2+1]=f),u--)}},je=(e,t,n)=>{let r=Array(16),i=0,a,o;for(a=1;a<=te;a++)r[a]=i=i+n[a-1]<<1;for(o=0;o<=t;o++){let t=e[o*2+1];t!==0&&(e[o*2]=Oe(r[t]++,t))}},Me=()=>{let e,t,n,r,i,a=Array(16);for(n=0,r=0;r<28;r++)for(_e[r]=n,e=0;e<1<<ce[r];e++)ge[n++]=r;for(ge[n-1]=r,i=0,r=0;r<16;r++)for(ve[r]=i,e=0;e<1<<le[r];e++)he[i++]=r;for(i>>=7;r<E;r++)for(ve[r]=i<<7,e=0;e<1<<le[r]-7;e++)he[256+i++]=r;for(t=0;t<=te;t++)a[t]=0;for(e=0;e<=143;)pe[e*2+1]=8,e++,a[8]++;for(;e<=255;)pe[e*2+1]=9,e++,a[9]++;for(;e<=279;)pe[e*2+1]=7,e++,a[7]++;for(;e<=287;)pe[e*2+1]=8,e++,a[8]++;for(je(pe,287,a),e=0;e<E;e++)me[e*2+1]=5,me[e*2]=Oe(e,5);be=new ye(pe,ce,257,T,te),xe=new ye(me,le,0,E,te),Se=new ye([],ue,0,D,re)},Ne=e=>{let t;for(t=0;t<T;t++)e.dyn_ltree[t*2]=0;for(t=0;t<E;t++)e.dyn_dtree[t*2]=0;for(t=0;t<D;t++)e.bl_tree[t*2]=0;e.dyn_ltree[ie*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},Pe=e=>{e.bi_valid>8?Te(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Fe=(e,t,n,r)=>{Pe(e),r&&(Te(e,n),Te(e,~n)),e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},Ie=(e,t,n,r)=>{let i=t*2,a=n*2;return e[i]<e[a]||e[i]===e[a]&&r[t]<=r[n]},Le=(e,t,n)=>{let r=e.heap[n],i=n<<1;for(;i<=e.heap_len&&(i<e.heap_len&&Ie(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!Ie(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r},Re=(e,t,n)=>{let r,i,a=0,o,s;if(e.last_lit!==0)do r=e.pending_buf[e.d_buf+a*2]<<8|e.pending_buf[e.d_buf+a*2+1],i=e.pending_buf[e.l_buf+a],a++,r===0?De(e,i,t):(o=ge[i],De(e,o+w+1,t),s=ce[o],s!==0&&(i-=_e[o],Ee(e,i,s)),r--,o=we(r),De(e,o,n),s=le[o],s!==0&&(r-=ve[o],Ee(e,r,s)));while(a<e.last_lit);De(e,ie,t)},ze=(e,t)=>{let n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,c=-1,l;for(e.heap_len=0,e.heap_max=ee,o=0;o<a;o++)n[o*2]===0?n[o*2+1]=0:(e.heap[++e.heap_len]=c=o,e.depth[o]=0);for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,n[l*2]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=r[l*2+1]);for(t.max_code=c,o=e.heap_len>>1;o>=1;o--)Le(e,n,o);l=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Le(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[l*2]=n[o*2]+n[s*2],e.depth[l]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[o*2+1]=n[s*2+1]=l,e.heap[1]=l++,Le(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Ae(e,t),je(n,c,e.bl_count)},Be=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)&&(s<l?e.bl_tree[a*2]+=s:a===0?s<=10?e.bl_tree[34]++:e.bl_tree[36]++:(a!==i&&e.bl_tree[a*2]++,e.bl_tree[32]++),s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4))},Ve=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),r=0;r<=n;r++)if(a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)){if(s<l)do De(e,a,e.bl_tree);while(--s!==0);else a===0?s<=10?(De(e,oe,e.bl_tree),Ee(e,s-3,3)):(De(e,se,e.bl_tree),Ee(e,s-11,7)):(a!==i&&(De(e,a,e.bl_tree),s--),De(e,ae,e.bl_tree),Ee(e,s-3,2));s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4)}},He=e=>{let t;for(Be(e,e.dyn_ltree,e.l_desc.max_code),Be(e,e.dyn_dtree,e.d_desc.max_code),ze(e,e.bl_desc),t=18;t>=3&&e.bl_tree[de[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},Ue=(e,t,n,r)=>{let i;for(Ee(e,t-257,5),Ee(e,n-1,5),Ee(e,r-4,4),i=0;i<r;i++)Ee(e,e.bl_tree[de[i]*2+1],3);Ve(e,e.dyn_ltree,t-1),Ve(e,e.dyn_dtree,n-1)},We=e=>{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return y;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return b;for(n=32;n<w;n++)if(e.dyn_ltree[n*2]!==0)return b;return y},Ge=!1,Ke=e=>{Ge||=(Me(),!0),e.l_desc=new Ce(e.dyn_ltree,be),e.d_desc=new Ce(e.dyn_dtree,xe),e.bl_desc=new Ce(e.bl_tree,Se),e.bi_buf=0,e.bi_valid=0,Ne(e)},qe=(e,t,n,r)=>{Ee(e,0+ +!!r,3),Fe(e,t,n,!0)},Je={_tr_init:Ke,_tr_stored_block:qe,_tr_flush_block:(e,t,n,r)=>{let i,a,o=0;e.level>0?(e.strm.data_type===x&&(e.strm.data_type=We(e)),ze(e,e.l_desc),ze(e,e.d_desc),o=He(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=n+5,n+4<=i&&t!==-1?qe(e,t,n,r):e.strategy===v||a===i?(Ee(e,2+ +!!r,3),Re(e,pe,me)):(Ee(e,4+ +!!r,3),Ue(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),Re(e,e.dyn_ltree,e.dyn_dtree)),Ne(e),r&&Pe(e)},_tr_tally:(e,t,n)=>(e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(ge[n]+w+1)*2]++,e.dyn_dtree[we(t)*2]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{Ee(e,2,3),De(e,ie,pe),ke(e)}},Ye=(e,t,n,r)=>{let i=e&65535|0,a=e>>>16&65535|0,o=0;for(;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+t[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0},Xe=new Uint32Array((()=>{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})()),Ze=(e,t,n,r)=>{let i=Xe,a=r+n;e^=-1;for(let n=r;n<a;n++)e=e>>>8^i[(e^t[n])&255];return e^-1},Qe={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`},$e={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},{_tr_init:et,_tr_stored_block:tt,_tr_flush_block:nt,_tr_tally:rt,_tr_align:it}=Je,{Z_NO_FLUSH:at,Z_PARTIAL_FLUSH:ot,Z_FULL_FLUSH:st,Z_FINISH:ct,Z_BLOCK:lt,Z_OK:ut,Z_STREAM_END:dt,Z_STREAM_ERROR:ft,Z_DATA_ERROR:pt,Z_BUF_ERROR:mt,Z_DEFAULT_COMPRESSION:ht,Z_FILTERED:gt,Z_HUFFMAN_ONLY:_t,Z_RLE:vt,Z_FIXED:yt,Z_DEFAULT_STRATEGY:bt,Z_UNKNOWN:xt,Z_DEFLATED:St}=$e,Ct=9,wt=15,Tt=8,Et=573,Dt=3,Ot=258,kt=262,At=32,jt=42,Mt=69,Nt=73,Pt=91,Ft=103,It=113,Lt=666,Rt=1,zt=2,Bt=3,Vt=4,Ht=3,Ut=(e,t)=>(e.msg=Qe[t],t),Wt=e=>(e<<1)-(e>4?9:0),Gt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Kt=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask,qt=e=>{let t=e.state,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))},Jt=(e,t)=>{nt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,qt(e.strm)},O=(e,t)=>{e.pending_buf[e.pending++]=t},Yt=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Xt=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=Ye(e.adler,t,i,n):e.state.wrap===2&&(e.adler=Ze(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},Zt=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-kt?e.strstart-(e.w_size-kt):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+Ot,p=l[r+o-1],m=l[r+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do if(i=t,l[i+o]===m&&l[i+o-1]===p&&l[i]===l[r]&&l[++i]===l[r+1]){r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<f);if(a=Ot-(f-r),r=f-Ot,a>o){if(e.match_start=t,o=a,a>=s)break;p=l[r+o-1],m=l[r+o]}}while((t=d[t&u])>c&&--n!==0);return o<=e.lookahead?o:e.lookahead},Qt=e=>{let t=e.w_size,n,r,i,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-kt)){e.window.set(e.window.subarray(t,t+t),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,n=r;do i=e.head[--n],e.head[n]=i>=t?i-t:0;while(--r);r=t,n=r;do i=e.prev[--n],e.prev[n]=i>=t?i-t:0;while(--r);a+=t}if(e.strm.avail_in===0)break;if(r=Xt(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=r,e.lookahead+e.insert>=Dt)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=Kt(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=Kt(e,e.ins_h,e.window[o+Dt-1]),e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<Dt)););}while(e.lookahead<kt&&e.strm.avail_in!==0)},$t=(e,t)=>{let n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Qt(e),e.lookahead===0&&t===at)return Rt;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;let r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,Jt(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-kt&&(Jt(e,!1),e.strm.avail_out===0))return Rt}return e.insert=0,t===ct?(Jt(e,!0),e.strm.avail_out===0?Bt:Vt):(e.strstart>e.block_start&&(Jt(e,!1),e.strm.avail_out),Rt)},en=(e,t)=>{let n,r;for(;;){if(e.lookahead<kt){if(Qt(e),e.lookahead<kt&&t===at)return Rt;if(e.lookahead===0)break}if(n=0,e.lookahead>=Dt&&(e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+Dt-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-kt&&(e.match_length=Zt(e,n)),e.match_length>=Dt){if(r=rt(e,e.strstart-e.match_start,e.match_length-Dt),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Dt){e.match_length--;do e.strstart++,e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+Dt-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=Kt(e,e.ins_h,e.window[e.strstart+1])}else r=rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(Jt(e,!1),e.strm.avail_out===0))return Rt}return e.insert=e.strstart<2?e.strstart:2,t===ct?(Jt(e,!0),e.strm.avail_out===0?Bt:Vt):e.last_lit&&(Jt(e,!1),e.strm.avail_out===0)?Rt:zt},tn=(e,t)=>{let n,r,i;for(;;){if(e.lookahead<kt){if(Qt(e),e.lookahead<kt&&t===at)return Rt;if(e.lookahead===0)break}if(n=0,e.lookahead>=Dt&&(e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+Dt-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=2,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-kt&&(e.match_length=Zt(e,n),e.match_length<=5&&(e.strategy===gt||e.match_length===Dt&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=Dt&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-Dt,r=rt(e,e.strstart-1-e.prev_match,e.prev_length-Dt),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=Kt(e,e.ins_h,e.window[e.strstart+Dt-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=2,e.strstart++,r&&(Jt(e,!1),e.strm.avail_out===0))return Rt}else if(e.match_available){if(r=rt(e,0,e.window[e.strstart-1]),r&&Jt(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Rt}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&=(r=rt(e,0,e.window[e.strstart-1]),0),e.insert=e.strstart<2?e.strstart:2,t===ct?(Jt(e,!0),e.strm.avail_out===0?Bt:Vt):e.last_lit&&(Jt(e,!1),e.strm.avail_out===0)?Rt:zt},nn=(e,t)=>{let n,r,i,a,o=e.window;for(;;){if(e.lookahead<=Ot){if(Qt(e),e.lookahead<=Ot&&t===at)return Rt;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Dt&&e.strstart>0&&(i=e.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){a=e.strstart+Ot;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<a);e.match_length=Ot-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Dt?(n=rt(e,1,e.match_length-Dt),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Jt(e,!1),e.strm.avail_out===0))return Rt}return e.insert=0,t===ct?(Jt(e,!0),e.strm.avail_out===0?Bt:Vt):e.last_lit&&(Jt(e,!1),e.strm.avail_out===0)?Rt:zt},rn=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(Qt(e),e.lookahead===0)){if(t===at)return Rt;break}if(e.match_length=0,n=rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Jt(e,!1),e.strm.avail_out===0))return Rt}return e.insert=0,t===ct?(Jt(e,!0),e.strm.avail_out===0?Bt:Vt):e.last_lit&&(Jt(e,!1),e.strm.avail_out===0)?Rt:zt};function an(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}var on=[new an(0,0,0,0,$t),new an(4,4,8,4,en),new an(4,5,16,8,en),new an(4,6,32,32,en),new an(4,4,16,16,tn),new an(8,16,32,32,tn),new an(8,16,128,128,tn),new an(8,32,128,256,tn),new an(32,128,258,1024,tn),new an(32,258,258,4096,tn)],sn=e=>{e.window_size=2*e.w_size,Gt(e.head),e.max_lazy_match=on[e.level].max_lazy,e.good_match=on[e.level].good_length,e.nice_match=on[e.level].nice_length,e.max_chain_length=on[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0};function cn(){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=St,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(Et*2),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Gt(this.dyn_ltree),Gt(this.dyn_dtree),Gt(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),Gt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Gt(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}var ln=e=>{if(!e||!e.state)return Ut(e,ft);e.total_in=e.total_out=0,e.data_type=xt;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?jt:It,e.adler=t.wrap===2?0:1,t.last_flush=at,et(t),ut},un=e=>{let t=ln(e);return t===ut&&sn(e.state),t},dn=(e,t)=>!e||!e.state||e.state.wrap!==2?ft:(e.state.gzhead=t,ut),fn=(e,t,n,r,i,a)=>{if(!e)return ft;let o=1;if(t===ht&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>Ct||n!==St||r<8||r>15||t<0||t>9||a<0||a>yt)return Ut(e,ft);r===8&&(r=9);let s=new cn;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=r,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+Dt-1)/Dt),s.window=new Uint8Array(s.w_size*2),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Uint8Array(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=a,s.method=n,un(e)},pn={deflateInit:(e,t)=>fn(e,t,St,wt,Tt,bt),deflateInit2:fn,deflateReset:un,deflateResetKeep:ln,deflateSetHeader:dn,deflate:(e,t)=>{let n,r;if(!e||!e.state||t>lt||t<0)return e?Ut(e,ft):ft;let i=e.state;if(!e.output||!e.input&&e.avail_in!==0||i.status===Lt&&t!==ct)return Ut(e,e.avail_out===0?mt:ft);i.strm=e;let a=i.last_flush;if(i.last_flush=t,i.status===jt){if(i.wrap===2)e.adler=0,O(i,31),O(i,139),O(i,8),i.gzhead?(O(i,+!!i.gzhead.text+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),O(i,i.gzhead.time&255),O(i,i.gzhead.time>>8&255),O(i,i.gzhead.time>>16&255),O(i,i.gzhead.time>>24&255),O(i,i.level===9?2:i.strategy>=_t||i.level<2?4:0),O(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(O(i,i.gzhead.extra.length&255),O(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=Ze(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=Mt):(O(i,0),O(i,0),O(i,0),O(i,0),O(i,0),O(i,i.level===9?2:i.strategy>=_t||i.level<2?4:0),O(i,Ht),i.status=It);else{let t=St+(i.w_bits-8<<4)<<8,n=-1;n=i.strategy>=_t||i.level<2?0:i.level<6?1:i.level===6?2:3,t|=n<<6,i.strstart!==0&&(t|=At),t+=31-t%31,i.status=It,Yt(i,t),i.strstart!==0&&(Yt(i,e.adler>>>16),Yt(i,e.adler&65535)),e.adler=1}}if(i.status===Mt){if(i.gzhead.extra){for(n=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ze(e.adler,i.pending_buf,i.pending-n,n)),qt(e),n=i.pending,i.pending===i.pending_buf_size));)O(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(e.adler=Ze(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=Nt)}else i.status=Nt}if(i.status===Nt){if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ze(e.adler,i.pending_buf,i.pending-n,n)),qt(e),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindex<i.gzhead.name.length?i.gzhead.name.charCodeAt(i.gzindex++)&255:0,O(i,r)}while(r!==0);i.gzhead.hcrc&&i.pending>n&&(e.adler=Ze(e.adler,i.pending_buf,i.pending-n,n)),r===0&&(i.gzindex=0,i.status=Pt)}else i.status=Pt}if(i.status===Pt){if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=Ze(e.adler,i.pending_buf,i.pending-n,n)),qt(e),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}r=i.gzindex<i.gzhead.comment.length?i.gzhead.comment.charCodeAt(i.gzindex++)&255:0,O(i,r)}while(r!==0);i.gzhead.hcrc&&i.pending>n&&(e.adler=Ze(e.adler,i.pending_buf,i.pending-n,n)),r===0&&(i.status=Ft)}else i.status=Ft}if(i.status===Ft&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&qt(e),i.pending+2<=i.pending_buf_size&&(O(i,e.adler&255),O(i,e.adler>>8&255),e.adler=0,i.status=It)):i.status=It),i.pending!==0){if(qt(e),e.avail_out===0)return i.last_flush=-1,ut}else if(e.avail_in===0&&Wt(t)<=Wt(a)&&t!==ct)return Ut(e,mt);if(i.status===Lt&&e.avail_in!==0)return Ut(e,mt);if(e.avail_in!==0||i.lookahead!==0||t!==at&&i.status!==Lt){let n=i.strategy===_t?rn(i,t):i.strategy===vt?nn(i,t):on[i.level].func(i,t);if((n===Bt||n===Vt)&&(i.status=Lt),n===Rt||n===Bt)return e.avail_out===0&&(i.last_flush=-1),ut;if(n===zt&&(t===ot?it(i):t!==lt&&(tt(i,0,0,!1),t===st&&(Gt(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),qt(e),e.avail_out===0))return i.last_flush=-1,ut}return t===ct?i.wrap<=0?dt:(i.wrap===2?(O(i,e.adler&255),O(i,e.adler>>8&255),O(i,e.adler>>16&255),O(i,e.adler>>24&255),O(i,e.total_in&255),O(i,e.total_in>>8&255),O(i,e.total_in>>16&255),O(i,e.total_in>>24&255)):(Yt(i,e.adler>>>16),Yt(i,e.adler&65535)),qt(e),i.wrap>0&&(i.wrap=-i.wrap),i.pending===0?dt:ut):ut},deflateEnd:e=>{if(!e||!e.state)return ft;let t=e.state.status;return t!==jt&&t!==Mt&&t!==Nt&&t!==Pt&&t!==Ft&&t!==It&&t!==Lt?Ut(e,ft):(e.state=null,t===It?Ut(e,pt):ut)},deflateSetDictionary:(e,t)=>{let n=t.length;if(!e||!e.state)return ft;let r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==jt||r.lookahead)return ft;if(i===1&&(e.adler=Ye(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(Gt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}let a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Qt(r);r.lookahead>=Dt;){let e=r.strstart,t=r.lookahead-2;do r.ins_h=Kt(r,r.ins_h,r.window[e+Dt-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++;while(--t);r.strstart=e,r.lookahead=2,Qt(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,r.wrap=i,ut},deflateInfo:`pako deflate (from Nodeca project)`},mn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),hn={assign:function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let n=t.shift();if(n){if(typeof n!=`object`)throw TypeError(n+`must be non-object`);for(let t in n)mn(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].length;let n=new Uint8Array(t);for(let t=0,r=0,i=e.length;t<i;t++){let i=e[t];n.set(i,r),r+=i.length}return n}},gn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{gn=!1}var _n=new Uint8Array(256);for(let e=0;e<256;e++)_n[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;_n[254]=_n[254]=1;var vn=e=>{let t,n,r,i,a,o=e.length,s=0;for(i=0;i<o;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(s),a=0,i=0;a<s;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?t[a++]=n:n<2048?(t[a++]=192|n>>>6,t[a++]=128|n&63):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|n&63):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|n&63);return t},yn=(e,t)=>{if(t<65534&&e.subarray&&gn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n=``;for(let r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n},bn={string2buf:vn,buf2string:(e,t)=>{let n,r,i=t||e.length,a=Array(i*2);for(r=0,n=0;n<i;){let t=e[n++];if(t<128){a[r++]=t;continue}let o=_n[t];if(o>4){a[r++]=65533,n+=o-1;continue}for(t&=o===2?31:o===3?15:7;o>1&&n<i;)t=t<<6|e[n++]&63,o--;if(o>1){a[r++]=65533;continue}t<65536?a[r++]=t:(t-=65536,a[r++]=55296|t>>10&1023,a[r++]=56320|t&1023)}return yn(a,r)},utf8border:(e,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+_n[e[n]]>t?n:t}};function xn(){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 Sn=xn,Cn=Object.prototype.toString,{Z_NO_FLUSH:wn,Z_SYNC_FLUSH:Tn,Z_FULL_FLUSH:En,Z_FINISH:Dn,Z_OK:On,Z_STREAM_END:kn,Z_DEFAULT_COMPRESSION:An,Z_DEFAULT_STRATEGY:jn,Z_DEFLATED:Mn}=$e;function Nn(e){this.options=hn.assign({level:An,method:Mn,chunkSize:16384,windowBits:15,memLevel:8,strategy:jn},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 Sn,this.strm.avail_out=0;let n=pn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==On)throw Error(Qe[n]);if(t.header&&pn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e=typeof t.dictionary==`string`?bn.string2buf(t.dictionary):Cn.call(t.dictionary)===`[object ArrayBuffer]`?new Uint8Array(t.dictionary):t.dictionary,n=pn.deflateSetDictionary(this.strm,e),n!==On)throw Error(Qe[n]);this._dict_set=!0}}Nn.prototype.push=function(e,t){let n=this.strm,r=this.options.chunkSize,i,a;if(this.ended)return!1;for(a=t===~~t?t:t===!0?Dn:wn,n.input=typeof e==`string`?bn.string2buf(e):Cn.call(e)===`[object ArrayBuffer]`?new Uint8Array(e):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),(a===Tn||a===En)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=pn.deflate(n,a),i===kn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=pn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===On;if(n.avail_out===0){this.onData(n.output);continue}if(a>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},Nn.prototype.onData=function(e){this.chunks.push(e)},Nn.prototype.onEnd=function(e){e===On&&(this.result=hn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Pn(e,t){let n=new Nn(t);if(n.push(e,!0),n.err)throw n.msg||Qe[n.err];return n.result}function Fn(e,t){return t||={},t.raw=!0,Pn(e,t)}function In(e,t){return t||={},t.gzip=!0,Pn(e,t)}var Ln={Deflate:Nn,deflate:Pn,deflateRaw:Fn,gzip:In,constants:$e},Rn=30,zn=12,Bn=function(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),i=e.next_out,T=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=E.dmax,c=E.wsize,l=E.whave,u=E.wnext,d=E.window,f=E.hold,p=E.bits,m=E.lencode,h=E.distcode,g=(1<<E.lenbits)-1,_=(1<<E.distbits)-1;top:do{p<15&&(f+=w[n++]<<p,p+=8,f+=w[n++]<<p,p+=8),v=m[f&g];dolen:for(;;){if(y=v>>>24,f>>>=y,p-=y,y=v>>>16&255,y===0)T[i++]=v&65535;else if(y&16){b=v&65535,y&=15,y&&(p<y&&(f+=w[n++]<<p,p+=8),b+=f&(1<<y)-1,f>>>=y,p-=y),p<15&&(f+=w[n++]<<p,p+=8,f+=w[n++]<<p,p+=8),v=h[f&_];dodist:for(;;){if(y=v>>>24,f>>>=y,p-=y,y=v>>>16&255,y&16){if(x=v&65535,y&=15,p<y&&(f+=w[n++]<<p,p+=8,p<y&&(f+=w[n++]<<p,p+=8)),x+=f&(1<<y)-1,x>s){e.msg=`invalid distance too far back`,E.mode=Rn;break top}if(f>>>=y,p-=y,y=i-a,x>y){if(y=x-y,y>l&&E.sane){e.msg=`invalid distance too far back`,E.mode=Rn;break top}if(S=0,C=d,u===0){if(S+=c-y,y<b){b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}}else if(u<y){if(S+=c+u-y,y-=u,y<b){b-=y;do T[i++]=d[S++];while(--y);if(S=0,u<b){y=u,b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}}}else if(S+=u-y,y<b){b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}for(;b>2;)T[i++]=C[S++],T[i++]=C[S++],T[i++]=C[S++],b-=3;b&&(T[i++]=C[S++],b>1&&(T[i++]=C[S++]))}else{S=i-x;do T[i++]=T[S++],T[i++]=T[S++],T[i++]=T[S++],b-=3;while(b>2);b&&(T[i++]=T[S++],b>1&&(T[i++]=T[S++]))}}else if(y&64){e.msg=`invalid distance code`,E.mode=Rn;break top}else{v=h[(v&65535)+(f&(1<<y)-1)];continue dodist}break}}else if(!(y&64)){v=m[(v&65535)+(f&(1<<y)-1)];continue dolen}else if(y&32){E.mode=zn;break top}else{e.msg=`invalid literal/length code`,E.mode=Rn;break top}break}}while(n<r&&i<o);b=p>>3,n-=b,p-=b<<3,f&=(1<<p)-1,e.next_in=n,e.next_out=i,e.avail_in=n<r?5+(r-n):5-(n-r),e.avail_out=i<o?257+(o-i):257-(i-o),E.hold=f,E.bits=p},Vn=15,Hn=852,Un=592,Wn=0,Gn=1,Kn=2,qn=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]),Jn=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]),Yn=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]),Xn=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]),Zn=(e,t,n,r,i,a,o,s)=>{let c=s.bits,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y,b,x,S,C,w=null,T=0,E,D=new Uint16Array(16),ee=new Uint16Array(16),te=null,ne=0,re,ie,ae;for(l=0;l<=Vn;l++)D[l]=0;for(u=0;u<r;u++)D[t[n+u]]++;for(p=c,f=Vn;f>=1&&D[f]===0;f--);if(p>f&&(p=f),f===0)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(d=1;d<f&&D[d]===0;d++);for(p<d&&(p=d),g=1,l=1;l<=Vn;l++)if(g<<=1,g-=D[l],g<0)return-1;if(g>0&&(e===Wn||f!==1))return-1;for(ee[1]=0,l=1;l<Vn;l++)ee[l+1]=ee[l]+D[l];for(u=0;u<r;u++)t[n+u]!==0&&(o[ee[t[n+u]]++]=u);if(e===Wn?(w=te=o,E=19):e===Gn?(w=qn,T-=257,te=Jn,ne-=257,E=256):(w=Yn,te=Xn,E=-1),v=0,u=0,l=d,C=a,m=p,h=0,x=-1,_=1<<p,S=_-1,e===Gn&&_>Hn||e===Kn&&_>Un)return 1;for(;;){re=l-h,o[u]<E?(ie=0,ae=o[u]):o[u]>E?(ie=te[ne+o[u]],ae=w[T+o[u]]):(ie=96,ae=0),y=1<<l-h,b=1<<m,d=b;do b-=y,i[C+(v>>h)+b]=re<<24|ie<<16|ae|0;while(b!==0);for(y=1<<l-1;v&y;)y>>=1;if(y===0?v=0:(v&=y-1,v+=y),u++,--D[l]===0){if(l===f)break;l=t[n+o[u]]}if(l>p&&(v&S)!==x){for(h===0&&(h=p),C+=d,m=l-h,g=1<<m;m+h<f&&(g-=D[m+h],!(g<=0));)m++,g<<=1;if(_+=1<<m,e===Gn&&_>Hn||e===Kn&&_>Un)return 1;x=v&S,i[x]=p<<24|m<<16|C-a|0}}return v!==0&&(i[C+v]=l-h<<24|4194304),s.bits=p,0},Qn=0,$n=1,er=2,{Z_FINISH:tr,Z_BLOCK:nr,Z_TREES:rr,Z_OK:ir,Z_STREAM_END:ar,Z_NEED_DICT:or,Z_STREAM_ERROR:sr,Z_DATA_ERROR:cr,Z_MEM_ERROR:lr,Z_BUF_ERROR:ur,Z_DEFLATED:dr}=$e,fr=1,pr=2,mr=3,hr=4,gr=5,_r=6,vr=7,yr=8,br=9,xr=10,Sr=11,Cr=12,wr=13,Tr=14,Er=15,Dr=16,Or=17,kr=18,Ar=19,jr=20,Mr=21,Nr=22,Pr=23,Fr=24,Ir=25,Lr=26,Rr=27,zr=28,Br=29,Vr=30,Hr=31,Ur=32,Wr=852,Gr=592,Kr=15,qr=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function Jr(){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}var Yr=e=>{if(!e||!e.state)return sr;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=``,t.wrap&&(e.adler=t.wrap&1),t.mode=fr,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Wr),t.distcode=t.distdyn=new Int32Array(Gr),t.sane=1,t.back=-1,ir},Xr=e=>{if(!e||!e.state)return sr;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Yr(e)},Zr=(e,t)=>{let n;if(!e||!e.state)return sr;let r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15)?sr:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Xr(e))},Qr=(e,t)=>{if(!e)return sr;let n=new Jr;e.state=n,n.window=null;let r=Zr(e,t);return r!==ir&&(e.state=null),r},$r=e=>Qr(e,Kr),ei=!0,ti,ni,ri=e=>{if(ei){ti=new Int32Array(512),ni=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(Zn($n,e.lens,0,288,ti,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Zn(er,e.lens,0,32,ni,0,e.work,{bits:5}),ei=!1}e.lencode=ti,e.lenbits=9,e.distcode=ni,e.distbits=5},ii=(e,t,n,r)=>{let i,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),r>=a.wsize?(a.window.set(t.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>r&&(i=r),a.window.set(t.subarray(n-r,n-r+i),a.wnext),r-=i,r?(a.window.set(t.subarray(n-r,n),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0},ai={inflateReset:Xr,inflateReset2:Zr,inflateResetKeep:Yr,inflateInit:$r,inflateInit2:Qr,inflate:(e,t)=>{let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g=0,_,v,y,b,x,S,C,w,T=new Uint8Array(4),E,D,ee=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return sr;n=e.state,n.mode===Cr&&(n.mode=wr),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,d=s,f=c,w=ir;inf_leave:for(;;)switch(n.mode){case fr:if(n.wrap===0){n.mode=wr;break}for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&2&&l===35615){n.check=0,T[0]=l&255,T[1]=l>>>8&255,n.check=Ze(n.check,T,2,0),l=0,u=0,n.mode=pr;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg=`incorrect header check`,n.mode=Vr;break}if((l&15)!==dr){e.msg=`unknown compression method`,n.mode=Vr;break}if(l>>>=4,u-=4,C=(l&15)+8,n.wbits===0)n.wbits=C;else if(C>n.wbits){e.msg=`invalid window size`,n.mode=Vr;break}n.dmax=1<<n.wbits,e.adler=n.check=1,n.mode=l&512?xr:Cr,l=0,u=0;break;case pr:for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.flags=l,(n.flags&255)!==dr){e.msg=`unknown compression method`,n.mode=Vr;break}if(n.flags&57344){e.msg=`unknown header flags set`,n.mode=Vr;break}n.head&&(n.head.text=l>>8&1),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=Ze(n.check,T,2,0)),l=0,u=0,n.mode=mr;case mr:for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.head&&(n.head.time=l),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,T[2]=l>>>16&255,T[3]=l>>>24&255,n.check=Ze(n.check,T,4,0)),l=0,u=0,n.mode=hr;case hr:for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.head&&(n.head.xflags=l&255,n.head.os=l>>8),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=Ze(n.check,T,2,0)),l=0,u=0,n.mode=gr;case gr:if(n.flags&1024){for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.length=l,n.head&&(n.head.extra_len=l),n.flags&512&&(T[0]=l&255,T[1]=l>>>8&255,n.check=Ze(n.check,T,2,0)),l=0,u=0}else n.head&&(n.head.extra=null);n.mode=_r;case _r:if(n.flags&1024&&(p=n.length,p>s&&(p=s),p&&(n.head&&(C=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(a,a+p),C)),n.flags&512&&(n.check=Ze(n.check,r,p,a)),s-=p,a+=p,n.length-=p),n.length))break inf_leave;n.length=0,n.mode=vr;case vr:if(n.flags&2048){if(s===0)break inf_leave;p=0;do C=r[a+p++],n.head&&C&&n.length<65536&&(n.head.name+=String.fromCharCode(C));while(C&&p<s);if(n.flags&512&&(n.check=Ze(n.check,r,p,a)),s-=p,a+=p,C)break inf_leave}else n.head&&(n.head.name=null);n.length=0,n.mode=yr;case yr:if(n.flags&4096){if(s===0)break inf_leave;p=0;do C=r[a+p++],n.head&&C&&n.length<65536&&(n.head.comment+=String.fromCharCode(C));while(C&&p<s);if(n.flags&512&&(n.check=Ze(n.check,r,p,a)),s-=p,a+=p,C)break inf_leave}else n.head&&(n.head.comment=null);n.mode=br;case br:if(n.flags&512){for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(l!==(n.check&65535)){e.msg=`header crc mismatch`,n.mode=Vr;break}l=0,u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Cr;break;case xr:for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}e.adler=n.check=qr(l),l=0,u=0,n.mode=Sr;case Sr:if(n.havedict===0)return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,or;e.adler=n.check=1,n.mode=Cr;case Cr:if(t===nr||t===rr)break inf_leave;case wr:if(n.last){l>>>=u&7,u-=u&7,n.mode=Rr;break}for(;u<3;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}switch(n.last=l&1,l>>>=1,--u,l&3){case 0:n.mode=Tr;break;case 1:if(ri(n),n.mode=jr,t===rr){l>>>=2,u-=2;break inf_leave}break;case 2:n.mode=Or;break;case 3:e.msg=`invalid block type`,n.mode=Vr}l>>>=2,u-=2;break;case Tr:for(l>>>=u&7,u-=u&7;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if((l&65535)!=(l>>>16^65535)){e.msg=`invalid stored block lengths`,n.mode=Vr;break}if(n.length=l&65535,l=0,u=0,n.mode=Er,t===rr)break inf_leave;case Er:n.mode=Dr;case Dr:if(p=n.length,p){if(p>s&&(p=s),p>c&&(p=c),p===0)break inf_leave;i.set(r.subarray(a,a+p),o),s-=p,a+=p,c-=p,o+=p,n.length-=p;break}n.mode=Cr;break;case Or:for(;u<14;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.nlen=(l&31)+257,l>>>=5,u-=5,n.ndist=(l&31)+1,l>>>=5,u-=5,n.ncode=(l&15)+4,l>>>=4,u-=4,n.nlen>286||n.ndist>30){e.msg=`too many length or distance symbols`,n.mode=Vr;break}n.have=0,n.mode=kr;case kr:for(;n.have<n.ncode;){for(;u<3;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.lens[ee[n.have++]]=l&7,l>>>=3,u-=3}for(;n.have<19;)n.lens[ee[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},w=Zn(Qn,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,w){e.msg=`invalid code lengths set`,n.mode=Vr;break}n.have=0,n.mode=Ar;case Ar:for(;n.have<n.nlen+n.ndist;){for(;g=n.lencode[l&(1<<n.lenbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(y<16)l>>>=_,u-=_,n.lens[n.have++]=y;else{if(y===16){for(D=_+2;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(l>>>=_,u-=_,n.have===0){e.msg=`invalid bit length repeat`,n.mode=Vr;break}C=n.lens[n.have-1],p=3+(l&3),l>>>=2,u-=2}else if(y===17){for(D=_+3;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,C=0,p=3+(l&7),l>>>=3,u-=3}else{for(D=_+7;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,C=0,p=11+(l&127),l>>>=7,u-=7}if(n.have+p>n.nlen+n.ndist){e.msg=`invalid bit length repeat`,n.mode=Vr;break}for(;p--;)n.lens[n.have++]=C}}if(n.mode===Vr)break;if(n.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,n.mode=Vr;break}if(n.lenbits=9,E={bits:n.lenbits},w=Zn($n,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,w){e.msg=`invalid literal/lengths set`,n.mode=Vr;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},w=Zn(er,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,w){e.msg=`invalid distances set`,n.mode=Vr;break}if(n.mode=jr,t===rr)break inf_leave;case jr:n.mode=Mr;case Mr:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,Bn(e,f),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,n.mode===Cr&&(n.back=-1);break}for(n.back=0;g=n.lencode[l&(1<<n.lenbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(v&&!(v&240)){for(b=_,x=v,S=y;g=n.lencode[S+((l&(1<<b+x)-1)>>b)],_=g>>>24,v=g>>>16&255,y=g&65535,!(b+_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=b,u-=b,n.back+=b}if(l>>>=_,u-=_,n.back+=_,n.length=y,v===0){n.mode=Lr;break}if(v&32){n.back=-1,n.mode=Cr;break}if(v&64){e.msg=`invalid literal/length code`,n.mode=Vr;break}n.extra=v&15,n.mode=Nr;case Nr:if(n.extra){for(D=n.extra;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=Pr;case Pr:for(;g=n.distcode[l&(1<<n.distbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(!(v&240)){for(b=_,x=v,S=y;g=n.distcode[S+((l&(1<<b+x)-1)>>b)],_=g>>>24,v=g>>>16&255,y=g&65535,!(b+_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=b,u-=b,n.back+=b}if(l>>>=_,u-=_,n.back+=_,v&64){e.msg=`invalid distance code`,n.mode=Vr;break}n.offset=y,n.extra=v&15,n.mode=Fr;case Fr:if(n.extra){for(D=n.extra;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg=`invalid distance too far back`,n.mode=Vr;break}n.mode=Ir;case Ir:if(c===0)break inf_leave;if(p=f-c,n.offset>p){if(p=n.offset-p,p>n.whave&&n.sane){e.msg=`invalid distance too far back`,n.mode=Vr;break}p>n.wnext?(p-=n.wnext,m=n.wsize-p):m=n.wnext-p,p>n.length&&(p=n.length),h=n.window}else h=i,m=o-n.offset,p=n.length;p>c&&(p=c),c-=p,n.length-=p;do i[o++]=h[m++];while(--p);n.length===0&&(n.mode=Mr);break;case Lr:if(c===0)break inf_leave;i[o++]=n.length,c--,n.mode=Mr;break;case Rr:if(n.wrap){for(;u<32;){if(s===0)break inf_leave;s--,l|=r[a++]<<u,u+=8}if(f-=c,e.total_out+=f,n.total+=f,f&&(e.adler=n.check=n.flags?Ze(n.check,i,f,o-f):Ye(n.check,i,f,o-f)),f=c,(n.flags?l:qr(l))!==n.check){e.msg=`incorrect data check`,n.mode=Vr;break}l=0,u=0}n.mode=zr;case zr:if(n.wrap&&n.flags){for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(l!==(n.total&4294967295)){e.msg=`incorrect length check`,n.mode=Vr;break}l=0,u=0}n.mode=Br;case Br:w=ar;break inf_leave;case Vr:w=cr;break inf_leave;case Hr:return lr;case Ur:default:return sr}return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,(n.wsize||f!==e.avail_out&&n.mode<Vr&&(n.mode<Rr||t!==tr))&&ii(e,e.output,e.next_out,f-e.avail_out),d-=e.avail_in,f-=e.avail_out,e.total_in+=d,e.total_out+=f,n.total+=f,n.wrap&&f&&(e.adler=n.check=n.flags?Ze(n.check,i,f,e.next_out-f):Ye(n.check,i,f,e.next_out-f)),e.data_type=n.bits+(n.last?64:0)+(n.mode===Cr?128:0)+(n.mode===jr||n.mode===Er?256:0),(d===0&&f===0||t===tr)&&w===ir&&(w=ur),w},inflateEnd:e=>{if(!e||!e.state)return sr;let t=e.state;return t.window&&=null,e.state=null,ir},inflateGetHeader:(e,t)=>{if(!e||!e.state)return sr;let n=e.state;return n.wrap&2?(n.head=t,t.done=!1,ir):sr},inflateSetDictionary:(e,t)=>{let n=t.length,r,i,a;return!e||!e.state||(r=e.state,r.wrap!==0&&r.mode!==Sr)?sr:r.mode===Sr&&(i=1,i=Ye(i,t,n,0),i!==r.check)?cr:(a=ii(e,t,n,n),a?(r.mode=Hr,lr):(r.havedict=1,ir))},inflateInfo:`pako inflate (from Nodeca project)`};function oi(){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 si=oi,ci=Object.prototype.toString,{Z_NO_FLUSH:li,Z_FINISH:ui,Z_OK:di,Z_STREAM_END:fi,Z_NEED_DICT:pi,Z_STREAM_ERROR:mi,Z_DATA_ERROR:hi,Z_MEM_ERROR:gi}=$e;function _i(e){this.options=hn.assign({chunkSize:65536,windowBits:15,to:``},e||{});let 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 Sn,this.strm.avail_out=0;let n=ai.inflateInit2(this.strm,t.windowBits);if(n!==di||(this.header=new si,ai.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary==`string`?t.dictionary=bn.string2buf(t.dictionary):ci.call(t.dictionary)===`[object ArrayBuffer]`&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ai.inflateSetDictionary(this.strm,t.dictionary),n!==di))))throw Error(Qe[n])}_i.prototype.push=function(e,t){let n=this.strm,r=this.options.chunkSize,i=this.options.dictionary,a,o,s;if(this.ended)return!1;for(o=t===~~t?t:t===!0?ui:li,n.input=ci.call(e)===`[object ArrayBuffer]`?new Uint8Array(e):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),a=ai.inflate(n,o),a===pi&&i&&(a=ai.inflateSetDictionary(n,i),a===di?a=ai.inflate(n,o):a===hi&&(a=pi));n.avail_in>0&&a===fi&&n.state.wrap>0&&e[n.next_in]!==0;)ai.inflateReset(n),a=ai.inflate(n,o);switch(a){case mi:case hi:case pi:case gi:return this.onEnd(a),this.ended=!0,!1}if(s=n.avail_out,n.next_out&&(n.avail_out===0||a===fi)){if(this.options.to===`string`){let e=bn.utf8border(n.output,n.next_out),t=n.next_out-e,i=bn.buf2string(n.output,e);n.next_out=t,n.avail_out=r-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out))}if(a!==di||s!==0){if(a===fi)return a=ai.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(n.avail_in===0)break}}return!0},_i.prototype.onData=function(e){this.chunks.push(e)},_i.prototype.onEnd=function(e){e===di&&(this.result=this.options.to===`string`?this.chunks.join(``):hn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function vi(e,t){let n=new _i(t);if(n.push(e),n.err)throw n.msg||Qe[n.err];return n.result}function yi(e,t){return t||={},t.raw=!0,vi(e,t)}var bi={Inflate:_i,inflate:vi,inflateRaw:yi,ungzip:vi,constants:$e},{Deflate:xi,deflate:Si,deflateRaw:Ci,gzip:wi}=Ln,{Inflate:Ti,inflate:Ei,inflateRaw:Di,ungzip:Oi}=bi,ki=Si,Ai=Ei,ji={white:`#ffffff`,black:`#000000`,gray:[`#f8f9fa`,`#f1f3f5`,`#e9ecef`,`#dee2e6`,`#ced4da`,`#adb5bd`,`#868e96`,`#495057`,`#343a40`,`#212529`],red:[`#fff5f5`,`#ffe3e3`,`#ffc9c9`,`#ffa8a8`,`#ff8787`,`#ff6b6b`,`#fa5252`,`#f03e3e`,`#e03131`,`#c92a2a`],pink:[`#fff0f6`,`#ffdeeb`,`#fcc2d7`,`#faa2c1`,`#f783ac`,`#f06595`,`#e64980`,`#d6336c`,`#c2255c`,`#a61e4d`],grape:[`#f8f0fc`,`#f3d9fa`,`#eebefa`,`#e599f7`,`#da77f2`,`#cc5de8`,`#be4bdb`,`#ae3ec9`,`#9c36b5`,`#862e9c`],violet:[`#f3f0ff`,`#e5dbff`,`#d0bfff`,`#b197fc`,`#9775fa`,`#845ef7`,`#7950f2`,`#7048e8`,`#6741d9`,`#5f3dc4`],indigo:[`#edf2ff`,`#dbe4ff`,`#bac8ff`,`#91a7ff`,`#748ffc`,`#5c7cfa`,`#4c6ef5`,`#4263eb`,`#3b5bdb`,`#364fc7`],blue:[`#e7f5ff`,`#d0ebff`,`#a5d8ff`,`#74c0fc`,`#4dabf7`,`#339af0`,`#228be6`,`#1c7ed6`,`#1971c2`,`#1864ab`],cyan:[`#e3fafc`,`#c5f6fa`,`#99e9f2`,`#66d9e8`,`#3bc9db`,`#22b8cf`,`#15aabf`,`#1098ad`,`#0c8599`,`#0b7285`],teal:[`#e6fcf5`,`#c3fae8`,`#96f2d7`,`#63e6be`,`#38d9a9`,`#20c997`,`#12b886`,`#0ca678`,`#099268`,`#087f5b`],green:[`#ebfbee`,`#d3f9d8`,`#b2f2bb`,`#8ce99a`,`#69db7c`,`#51cf66`,`#40c057`,`#37b24d`,`#2f9e44`,`#2b8a3e`],lime:[`#f4fce3`,`#e9fac8`,`#d8f5a2`,`#c0eb75`,`#a9e34b`,`#94d82d`,`#82c91e`,`#74b816`,`#66a80f`,`#5c940d`],yellow:[`#fff9db`,`#fff3bf`,`#ffec99`,`#ffe066`,`#ffd43b`,`#fcc419`,`#fab005`,`#f59f00`,`#f08c00`,`#e67700`],orange:[`#fff4e6`,`#ffe8cc`,`#ffd8a8`,`#ffc078`,`#ffa94d`,`#ff922b`,`#fd7e14`,`#f76707`,`#e8590c`,`#d9480f`]},Mi=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((e,t)=>(t&=63,e+=t<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?`-`:`_`,e),``),Ni=t(((e,t)=>{var n=`Expected a function`,r=NaN,i=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,c=parseInt,l=typeof global==`object`&&global&&global.Object===Object&&global,u=typeof self==`object`&&self&&self.Object===Object&&self,d=l||u||Function(`return this`)(),f=Object.prototype.toString,p=Math.max,m=Math.min,h=function(){return d.Date.now()};function g(e,t,r){var i,a,o,s,c,l,u=0,d=!1,f=!1,g=!0;if(typeof e!=`function`)throw TypeError(n);t=x(t)||0,v(r)&&(d=!!r.leading,f=`maxWait`in r,o=f?p(x(r.maxWait)||0,t):o,g=`trailing`in r?!!r.trailing:g);function _(t){var n=i,r=a;return i=a=void 0,u=t,s=e.apply(r,n),s}function y(e){return u=e,c=setTimeout(C,t),d?_(e):s}function b(e){var n=e-l,r=e-u,i=t-n;return f?m(i,o-r):i}function S(e){var n=e-l,r=e-u;return l===void 0||n>=t||n<0||f&&r>=o}function C(){var e=h();if(S(e))return w(e);c=setTimeout(C,b(e))}function w(e){return c=void 0,g&&i?_(e):(i=a=void 0,s)}function T(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function E(){return c===void 0?s:w(h())}function D(){var e=h(),n=S(e);if(i=arguments,a=this,l=e,n){if(c===void 0)return y(l);if(f)return c=setTimeout(C,t),_(l)}return c===void 0&&(c=setTimeout(C,t)),s}return D.cancel=T,D.flush=E,D}function _(e,t,r){var i=!0,a=!0;if(typeof e!=`function`)throw TypeError(n);return v(r)&&(i=`leading`in r?!!r.leading:i,a=`trailing`in r?!!r.trailing:a),g(e,t,{leading:i,maxWait:t,trailing:a})}function v(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function y(e){return!!e&&typeof e==`object`}function b(e){return typeof e==`symbol`||y(e)&&f.call(e)==`[object Symbol]`}function x(e){if(typeof e==`number`)return e;if(b(e))return r;if(v(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=v(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(i,``);var n=o.test(e);return n||s.test(e)?c(e.slice(2),n?2:8):a.test(e)?r:+e}t.exports=_})),Pi=t(((e,t)=>{(function(n,r){typeof define==`function`&&define.amd?define([],r):typeof e==`object`?t.exports=r():(n.PromisePool=r(),n.promisePool=n.PromisePool)})(e,function(){var e=function(){this._listeners={}};e.prototype.addEventListener=function(e,t){this._listeners[e]=this._listeners[e]||[],this._listeners[e].indexOf(t)<0&&this._listeners[e].push(t)},e.prototype.removeEventListener=function(e,t){if(this._listeners[e]){var n=this._listeners[e].indexOf(t);n>=0&&this._listeners[e].splice(n,1)}},e.prototype.dispatchEvent=function(e){if(this._listeners[e.type]&&this._listeners[e.type].length)for(var t=this._listeners[e.type].slice(),n=0,r=t.length;n<r;++n)t[n].call(this,e)};var t=function(e){return typeof e.constructor==`function`&&e.constructor.name===`GeneratorFunction`},n=function(e){return{next:function(){var t=e();return t?{value:t}:{done:!0}}}},r=function(e){var t=!1;return{next:function(){return t?{done:!0}:(t=!0,{value:e})}}},i=function(e,i){var a=typeof e;if(a===`object`){if(typeof e.next==`function`)return e;if(typeof e.then==`function`)return r(e)}return a===`function`?t(e)?e():n(e):r(i.resolve(e))},a=function(e,t,n){this.target=e,this.type=t,this.data=n},o=function(t,n,r){if(e.call(this),typeof n!=`number`||Math.floor(n)!==n||n<1)throw Error(`Invalid concurrency`);this._concurrency=n,this._options=r||{},this._options.promise=this._options.promise||Promise,this._iterator=i(t,this._options.promise),this._done=!1,this._size=0,this._promise=null,this._callbacks=null};return o.prototype=new e,o.prototype.constructor=o,o.prototype.concurrency=function(e){return e!==void 0&&(this._concurrency=e,this.active()&&this._proceed()),this._concurrency},o.prototype.size=function(){return this._size},o.prototype.active=function(){return!!this._promise},o.prototype.promise=function(){return this._promise},o.prototype.start=function(){var e=this,t=this._options.promise;return this._promise=new t(function(t,n){e._callbacks={reject:n,resolve:t},e._proceed()}),this._promise},o.prototype._fireEvent=function(e,t){this.dispatchEvent(new a(this,e,t))},o.prototype._settle=function(e){e?this._callbacks.reject(e):this._callbacks.resolve(),this._promise=null,this._callbacks=null},o.prototype._onPooledPromiseFulfilled=function(e,t){this._size--,this.active()&&(this._fireEvent(`fulfilled`,{promise:e,result:t}),this._proceed())},o.prototype._onPooledPromiseRejected=function(e,t){this._size--,this.active()&&(this._fireEvent(`rejected`,{promise:e,error:t}),this._settle(t||Error(`Unknown error`)))},o.prototype._trackPromise=function(e){var t=this;e.then(function(n){t._onPooledPromiseFulfilled(e,n)},function(n){t._onPooledPromiseRejected(e,n)}).catch(function(e){t._settle(Error(`Promise processing failed: `+e))})},o.prototype._proceed=function(){if(!this._done){for(var e={done:!1};this._size<this._concurrency&&!(e=this._iterator.next()).done;)this._size++,this._trackPromise(e.value);this._done=e===null||!!e.done}this._done&&this._size===0&&this._settle()},o.PromisePoolEvent=a,o.PromisePool=o,o})})),Fi=e(Ni(),1),Ii=e(Pi(),1);function Li(e,t,n){if(e&&e.length){let[r,i]=t,a=Math.PI/180*n,o=Math.cos(a),s=Math.sin(a);for(let t of e){let[e,n]=t;t[0]=(e-r)*o-(n-i)*s+r,t[1]=(e-r)*s+(n-i)*o+i}}}function Ri(e,t,n){let r=[];e.forEach(e=>r.push(...e)),Li(r,t,n)}function zi(e,t){return e[0]===t[0]&&e[1]===t[1]}function Bi(e,t,n,r=1){let i=n,a=Math.max(t,.1),o=e[0]&&e[0][0]&&typeof e[0][0]==`number`?[e]:e,s=[0,0];if(i)for(let e of o)Li(e,s,i);let c=Vi(o,a,r);if(i){for(let e of o)Li(e,s,-i);Ri(c,s,-i)}return c}function Vi(e,t,n){let r=[];for(let t of e){let e=[...t];zi(e[0],e[e.length-1])||e.push([e[0][0],e[0][1]]),e.length>2&&r.push(e)}let i=[];t=Math.max(t,.1);let a=[];for(let e of r)for(let t=0;t<e.length-1;t++){let n=e[t],r=e[t+1];if(n[1]!==r[1]){let e=Math.min(n[1],r[1]);a.push({ymin:e,ymax:Math.max(n[1],r[1]),x:e===n[1]?n[0]:r[0],islope:(r[0]-n[0])/(r[1]-n[1])})}}if(a.sort((e,t)=>e.ymin<t.ymin?-1:e.ymin>t.ymin?1:e.x<t.x?-1:e.x>t.x?1:e.ymax===t.ymax?0:(e.ymax-t.ymax)/Math.abs(e.ymax-t.ymax)),!a.length)return i;let o=[],s=a[0].ymin,c=0;for(;o.length||a.length;){if(a.length){let e=-1;for(let t=0;t<a.length&&!(a[t].ymin>s);t++)e=t;a.splice(0,e+1).forEach(e=>{o.push({s,edge:e})})}if(o=o.filter(e=>!(e.edge.ymax<=s)),o.sort((e,t)=>e.edge.x===t.edge.x?0:(e.edge.x-t.edge.x)/Math.abs(e.edge.x-t.edge.x)),(n!==1||c%t===0)&&o.length>1)for(let e=0;e<o.length;e+=2){let t=e+1;if(t>=o.length)break;let n=o[e].edge,r=o[t].edge;i.push([[Math.round(n.x),s],[Math.round(r.x),s]])}s+=n,o.forEach(e=>{e.edge.x=e.edge.x+n*e.edge.islope}),c++}return i}function Hi(e,t){let n=t.hachureAngle+90,r=t.hachureGap;r<0&&(r=t.strokeWidth*4),r=Math.max(r,.1);let i=1;return t.roughness>=1&&(t.randomizer?.next()||Math.random())>.7&&(i=r),Bi(e,r,n,i||1)}var Ui=class{constructor(e){this.helper=e}fillPolygons(e,t){return this._fillPolygons(e,t)}_fillPolygons(e,t){let n=Hi(e,t);return{type:`fillSketch`,ops:this.renderLines(n,t)}}renderLines(e,t){let n=[];for(let r of e)n.push(...this.helper.doubleLineOps(r[0][0],r[0][1],r[1][0],r[1][1],t));return n}};function Wi(e){let t=e[0],n=e[1];return Math.sqrt((t[0]-n[0])**2+(t[1]-n[1])**2)}var Gi=class extends Ui{fillPolygons(e,t){let n=t.hachureGap;n<0&&(n=t.strokeWidth*4),n=Math.max(n,.1);let r=Hi(e,Object.assign({},t,{hachureGap:n})),i=Math.PI/180*t.hachureAngle,a=[],o=n*.5*Math.cos(i),s=n*.5*Math.sin(i);for(let[e,t]of r)Wi([e,t])&&a.push([[e[0]-o,e[1]+s],[...t]],[[e[0]+o,e[1]-s],[...t]]);return{type:`fillSketch`,ops:this.renderLines(a,t)}}},Ki=class extends Ui{fillPolygons(e,t){let n=this._fillPolygons(e,t),r=Object.assign({},t,{hachureAngle:t.hachureAngle+90}),i=this._fillPolygons(e,r);return n.ops=n.ops.concat(i.ops),n}},qi=class{constructor(e){this.helper=e}fillPolygons(e,t){t=Object.assign({},t,{hachureAngle:0});let n=Hi(e,t);return this.dotsOnLines(n,t)}dotsOnLines(e,t){let n=[],r=t.hachureGap;r<0&&(r=t.strokeWidth*4),r=Math.max(r,.1);let i=t.fillWeight;i<0&&(i=t.strokeWidth/2);let a=r/4;for(let o of e){let e=Wi(o),s=e/r,c=Math.ceil(s)-1,l=e-c*r,u=(o[0][0]+o[1][0])/2-r/4,d=Math.min(o[0][1],o[1][1]);for(let e=0;e<c;e++){let o=d+l+e*r,s=u-a+Math.random()*2*a,c=o-a+Math.random()*2*a,f=this.helper.ellipse(s,c,i,i,t);n.push(...f.ops)}}return{type:`fillSketch`,ops:n}}},Ji=class{constructor(e){this.helper=e}fillPolygons(e,t){let n=Hi(e,t);return{type:`fillSketch`,ops:this.dashedLine(n,t)}}dashedLine(e,t){let n=t.dashOffset<0?t.hachureGap<0?t.strokeWidth*4:t.hachureGap:t.dashOffset,r=t.dashGap<0?t.hachureGap<0?t.strokeWidth*4:t.hachureGap:t.dashGap,i=[];return e.forEach(e=>{let a=Wi(e),o=Math.floor(a/(n+r)),s=(a+r-o*(n+r))/2,c=e[0],l=e[1];c[0]>l[0]&&(c=e[1],l=e[0]);let u=Math.atan((l[1]-c[1])/(l[0]-c[0]));for(let e=0;e<o;e++){let a=e*(n+r),o=a+n,l=[c[0]+a*Math.cos(u)+s*Math.cos(u),c[1]+a*Math.sin(u)+s*Math.sin(u)],d=[c[0]+o*Math.cos(u)+s*Math.cos(u),c[1]+o*Math.sin(u)+s*Math.sin(u)];i.push(...this.helper.doubleLineOps(l[0],l[1],d[0],d[1],t))}}),i}},Yi=class{constructor(e){this.helper=e}fillPolygons(e,t){let n=t.hachureGap<0?t.strokeWidth*4:t.hachureGap,r=t.zigzagOffset<0?n:t.zigzagOffset;t=Object.assign({},t,{hachureGap:n+r});let i=Hi(e,t);return{type:`fillSketch`,ops:this.zigzagLines(i,r,t)}}zigzagLines(e,t,n){let r=[];return e.forEach(e=>{let i=Wi(e),a=Math.round(i/(2*t)),o=e[0],s=e[1];o[0]>s[0]&&(o=e[1],s=e[0]);let c=Math.atan((s[1]-o[1])/(s[0]-o[0]));for(let e=0;e<a;e++){let i=e*2*t,a=(e+1)*2*t,s=Math.sqrt(2*t**2),l=[o[0]+i*Math.cos(c),o[1]+i*Math.sin(c)],u=[o[0]+a*Math.cos(c),o[1]+a*Math.sin(c)],d=[l[0]+s*Math.cos(c+Math.PI/4),l[1]+s*Math.sin(c+Math.PI/4)];r.push(...this.helper.doubleLineOps(l[0],l[1],d[0],d[1],n),...this.helper.doubleLineOps(d[0],d[1],u[0],u[1],n))}}),r}},Xi={};function Zi(e,t){let n=e.fillStyle||`hachure`;if(!Xi[n])switch(n){case`zigzag`:Xi[n]||(Xi[n]=new Gi(t));break;case`cross-hatch`:Xi[n]||(Xi[n]=new Ki(t));break;case`dots`:Xi[n]||(Xi[n]=new qi(t));break;case`dashed`:Xi[n]||(Xi[n]=new Ji(t));break;case`zigzag-line`:Xi[n]||(Xi[n]=new Yi(t));break;default:n=`hachure`,Xi[n]||(Xi[n]=new Ui(t))}return Xi[n]}function Qi(){return Math.floor(Math.random()*2**31)}var $i=class{constructor(e){this.seed=e}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}},ea=0,ta=1,na=2,ra={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function ia(e){let t=[];for(;e!==``;)if(e.match(/^([ \t\r\n,]+)/))e=e.substr(RegExp.$1.length);else if(e.match(/^([aAcChHlLmMqQsStTvVzZ])/))t[t.length]={type:ea,text:RegExp.$1},e=e.substr(RegExp.$1.length);else if(e.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))t[t.length]={type:ta,text:`${parseFloat(RegExp.$1)}`},e=e.substr(RegExp.$1.length);else return[];return t[t.length]={type:na,text:``},t}function aa(e,t){return e.type===t}function oa(e){let t=[],n=ia(e),r=`BOD`,i=0,a=n[i];for(;!aa(a,na);){let o=0,s=[];if(r===`BOD`){if(a.text===`M`||a.text===`m`)i++,o=ra[a.text],r=a.text;else return oa(`M0,0`+e)}else aa(a,ta)?o=ra[r]:(i++,o=ra[a.text],r=a.text);if(i+o<n.length){for(let e=i;e<i+o;e++){let t=n[e];if(aa(t,ta))s[s.length]=+t.text;else throw Error(`Param not a number: `+r+`,`+t.text)}if(typeof ra[r]==`number`){let e={key:r,data:s};t.push(e),i+=o,a=n[i],r===`M`&&(r=`L`),r===`m`&&(r=`l`)}else throw Error(`Bad segment: `+r)}else throw Error(`Path data ended short`)}return t}function sa(e){let t=0,n=0,r=0,i=0,a=[];for(let{key:o,data:s}of e)switch(o){case`M`:a.push({key:`M`,data:[...s]}),[t,n]=s,[r,i]=s;break;case`m`:t+=s[0],n+=s[1],a.push({key:`M`,data:[t,n]}),r=t,i=n;break;case`L`:a.push({key:`L`,data:[...s]}),[t,n]=s;break;case`l`:t+=s[0],n+=s[1],a.push({key:`L`,data:[t,n]});break;case`C`:a.push({key:`C`,data:[...s]}),t=s[4],n=s[5];break;case`c`:{let e=s.map((e,r)=>r%2?e+n:e+t);a.push({key:`C`,data:e}),t=e[4],n=e[5];break}case`Q`:a.push({key:`Q`,data:[...s]}),t=s[2],n=s[3];break;case`q`:{let e=s.map((e,r)=>r%2?e+n:e+t);a.push({key:`Q`,data:e}),t=e[2],n=e[3];break}case`A`:a.push({key:`A`,data:[...s]}),t=s[5],n=s[6];break;case`a`:t+=s[5],n+=s[6],a.push({key:`A`,data:[s[0],s[1],s[2],s[3],s[4],t,n]});break;case`H`:a.push({key:`H`,data:[...s]}),t=s[0];break;case`h`:t+=s[0],a.push({key:`H`,data:[t]});break;case`V`:a.push({key:`V`,data:[...s]}),n=s[0];break;case`v`:n+=s[0],a.push({key:`V`,data:[n]});break;case`S`:a.push({key:`S`,data:[...s]}),t=s[2],n=s[3];break;case`s`:{let e=s.map((e,r)=>r%2?e+n:e+t);a.push({key:`S`,data:e}),t=e[2],n=e[3];break}case`T`:a.push({key:`T`,data:[...s]}),t=s[0],n=s[1];break;case`t`:t+=s[0],n+=s[1],a.push({key:`T`,data:[t,n]});break;case`Z`:case`z`:a.push({key:`Z`,data:[]}),t=r,n=i}return a}function ca(e){let t=[],n=``,r=0,i=0,a=0,o=0,s=0,c=0;for(let{key:l,data:u}of e){switch(l){case`M`:t.push({key:`M`,data:[...u]}),[r,i]=u,[a,o]=u;break;case`C`:t.push({key:`C`,data:[...u]}),r=u[4],i=u[5],s=u[2],c=u[3];break;case`L`:t.push({key:`L`,data:[...u]}),[r,i]=u;break;case`H`:r=u[0],t.push({key:`L`,data:[r,i]});break;case`V`:i=u[0],t.push({key:`L`,data:[r,i]});break;case`S`:{let e=0,a=0;n===`C`||n===`S`?(e=r+(r-s),a=i+(i-c)):(e=r,a=i),t.push({key:`C`,data:[e,a,...u]}),s=u[0],c=u[1],r=u[2],i=u[3];break}case`T`:{let[e,a]=u,o=0,l=0;n===`Q`||n===`T`?(o=r+(r-s),l=i+(i-c)):(o=r,l=i);let d=r+2*(o-r)/3,f=i+2*(l-i)/3,p=e+2*(o-e)/3,m=a+2*(l-a)/3;t.push({key:`C`,data:[d,f,p,m,e,a]}),s=o,c=l,r=e,i=a;break}case`Q`:{let[e,n,a,o]=u,l=r+2*(e-r)/3,d=i+2*(n-i)/3,f=a+2*(e-a)/3,p=o+2*(n-o)/3;t.push({key:`C`,data:[l,d,f,p,a,o]}),s=e,c=n,r=a,i=o;break}case`A`:{let e=Math.abs(u[0]),n=Math.abs(u[1]),a=u[2],o=u[3],s=u[4],c=u[5],l=u[6];e===0||n===0?(t.push({key:`C`,data:[r,i,c,l,c,l]}),r=c,i=l):(r!==c||i!==l)&&(da(r,i,c,l,e,n,a,o,s).forEach(function(e){t.push({key:`C`,data:e})}),r=c,i=l);break}case`Z`:t.push({key:`Z`,data:[]}),r=a,i=o}n=l}return t}function la(e){return Math.PI*e/180}function ua(e,t,n){return[e*Math.cos(n)-t*Math.sin(n),e*Math.sin(n)+t*Math.cos(n)]}function da(e,t,n,r,i,a,o,s,c,l){let u=la(o),d=[],f=0,p=0,m=0,h=0;if(l)[f,p,m,h]=l;else{[e,t]=ua(e,t,-u),[n,r]=ua(n,r,-u);let o=(e-n)/2,l=(t-r)/2,d=o*o/(i*i)+l*l/(a*a);d>1&&(d=Math.sqrt(d),i=d*i,a=d*a);let g=s===c?-1:1,_=i*i,v=a*a,y=_*v-_*l*l-v*o*o,b=_*l*l+v*o*o,x=g*Math.sqrt(Math.abs(y/b));m=x*i*l/a+(e+n)/2,h=x*-a*o/i+(t+r)/2,f=Math.asin(parseFloat(((t-h)/a).toFixed(9))),p=Math.asin(parseFloat(((r-h)/a).toFixed(9))),e<m&&(f=Math.PI-f),n<m&&(p=Math.PI-p),f<0&&(f=Math.PI*2+f),p<0&&(p=Math.PI*2+p),c&&f>p&&(f-=Math.PI*2),!c&&p>f&&(p-=Math.PI*2)}let g=p-f;if(Math.abs(g)>Math.PI*120/180){let e=p,t=n,s=r;p=c&&p>f?f+Math.PI*120/180*1:f+Math.PI*120/180*-1,n=m+i*Math.cos(p),r=h+a*Math.sin(p),d=da(n,r,t,s,i,a,o,0,c,[p,e,m,h])}g=p-f;let _=Math.cos(f),v=Math.sin(f),y=Math.cos(p),b=Math.sin(p),x=Math.tan(g/4),S=4/3*i*x,C=4/3*a*x,w=[e,t],T=[e+S*v,t-C*_],E=[n+S*b,r-C*y],D=[n,r];if(T[0]=2*w[0]-T[0],T[1]=2*w[1]-T[1],l)return[T,E,D].concat(d);{d=[T,E,D].concat(d);let e=[];for(let t=0;t<d.length;t+=3){let n=ua(d[t][0],d[t][1],u),r=ua(d[t+1][0],d[t+1][1],u),i=ua(d[t+2][0],d[t+2][1],u);e.push([n[0],n[1],r[0],r[1],i[0],i[1]])}return e}}var fa={randOffset:Ea,randOffsetWithRange:Da,ellipse:va,doubleLineOps:Oa};function pa(e,t,n,r,i){return{type:`path`,ops:Ma(e,t,n,r,i)}}function ma(e,t,n){let r=(e||[]).length;if(r>2){let i=[];for(let t=0;t<r-1;t++)i.push(...Ma(e[t][0],e[t][1],e[t+1][0],e[t+1][1],n));return t&&i.push(...Ma(e[r-1][0],e[r-1][1],e[0][0],e[0][1],n)),{type:`path`,ops:i}}return r===2?pa(e[0][0],e[0][1],e[1][0],e[1][1],n):{type:`path`,ops:[]}}function ha(e,t){return ma(e,!0,t)}function ga(e,t,n,r,i){return ha([[e,t],[e+n,t],[e+n,t+r],[e,t+r]],i)}function _a(e,t){let n=Pa(e,1*(1+t.roughness*.2),t);if(!t.disableMultiStroke){let r=Pa(e,1.5*(1+t.roughness*.22),ka(t));n=n.concat(r)}return{type:`path`,ops:n}}function va(e,t,n,r,i){return ba(e,t,i,ya(n,r,i)).opset}function ya(e,t,n){let r=Math.sqrt(Math.PI*2*Math.sqrt(((e/2)**2+(t/2)**2)/2)),i=Math.ceil(Math.max(n.curveStepCount,n.curveStepCount/Math.sqrt(200)*r)),a=Math.PI*2/i,o=Math.abs(e/2),s=Math.abs(t/2),c=1-n.curveFitting;return o+=k(o*c,n),s+=k(s*c,n),{increment:a,rx:o,ry:s}}function ba(e,t,n,r){let[i,a]=Ia(r.increment,e,t,r.rx,r.ry,1,r.increment*ja(.1,ja(.4,1,n),n),n),o=Fa(i,null,n);if(!n.disableMultiStroke&&n.roughness!==0){let[i]=Ia(r.increment,e,t,r.rx,r.ry,1.5,0,n),a=Fa(i,null,n);o=o.concat(a)}return{estimatedPoints:a,opset:{type:`path`,ops:o}}}function xa(e,t,n,r,i,a,o,s,c){let l=e,u=t,d=Math.abs(n/2),f=Math.abs(r/2);d+=k(d*.01,c),f+=k(f*.01,c);let p=i,m=a;for(;p<0;)p+=Math.PI*2,m+=Math.PI*2;m-p>Math.PI*2&&(p=0,m=Math.PI*2);let h=Math.PI*2/c.curveStepCount,g=Math.min(h/2,(m-p)/2),_=La(g,l,u,d,f,p,m,1,c);if(!c.disableMultiStroke){let e=La(g,l,u,d,f,p,m,1.5,c);_.push(...e)}return o&&(s?_.push(...Ma(l,u,l+d*Math.cos(p),u+f*Math.sin(p),c),...Ma(l,u,l+d*Math.cos(m),u+f*Math.sin(m),c)):_.push({op:`lineTo`,data:[l,u]},{op:`lineTo`,data:[l+d*Math.cos(p),u+f*Math.sin(p)]})),{type:`path`,ops:_}}function Sa(e,t){let n=ca(sa(oa(e))),r=[],i=[0,0],a=[0,0];for(let{key:e,data:o}of n)switch(e){case`M`:a=[o[0],o[1]],i=[o[0],o[1]];break;case`L`:r.push(...Ma(a[0],a[1],o[0],o[1],t)),a=[o[0],o[1]];break;case`C`:{let[e,n,i,s,c,l]=o;r.push(...Ra(e,n,i,s,c,l,a,t)),a=[c,l];break}case`Z`:r.push(...Ma(a[0],a[1],i[0],i[1],t)),a=[i[0],i[1]]}return{type:`path`,ops:r}}function Ca(e,t){let n=[];for(let r of e)if(r.length){let e=t.maxRandomnessOffset||0,i=r.length;if(i>2){n.push({op:`move`,data:[r[0][0]+k(e,t),r[0][1]+k(e,t)]});for(let a=1;a<i;a++)n.push({op:`lineTo`,data:[r[a][0]+k(e,t),r[a][1]+k(e,t)]})}}return{type:`fillPath`,ops:n}}function wa(e,t){return Zi(t,fa).fillPolygons(e,t)}function Ta(e,t,n,r,i,a,o){let s=e,c=t,l=Math.abs(n/2),u=Math.abs(r/2);l+=k(l*.01,o),u+=k(u*.01,o);let d=i,f=a;for(;d<0;)d+=Math.PI*2,f+=Math.PI*2;f-d>Math.PI*2&&(d=0,f=Math.PI*2);let p=(f-d)/o.curveStepCount,m=[];for(let e=d;e<=f;e+=p)m.push([s+l*Math.cos(e),c+u*Math.sin(e)]);return m.push([s+l*Math.cos(f),c+u*Math.sin(f)]),m.push([s,c]),wa([m],o)}function Ea(e,t){return k(e,t)}function Da(e,t,n){return ja(e,t,n)}function Oa(e,t,n,r,i){return Ma(e,t,n,r,i,!0)}function ka(e){let t=Object.assign({},e);return t.randomizer=void 0,e.seed&&(t.seed=e.seed+1),t}function Aa(e){return e.randomizer||=new $i(e.seed||0),e.randomizer.next()}function ja(e,t,n,r=1){return n.roughness*r*(Aa(n)*(t-e)+e)}function k(e,t,n=1){return ja(-e,e,t,n)}function Ma(e,t,n,r,i,a=!1){let o=a?i.disableMultiStrokeFill:i.disableMultiStroke,s=Na(e,t,n,r,i,!0,!1);if(o)return s;let c=Na(e,t,n,r,i,!0,!0);return s.concat(c)}function Na(e,t,n,r,i,a,o){let s=(e-n)**2+(t-r)**2,c=Math.sqrt(s),l=1;l=c<200?1:c>500?.4:-.0016668*c+1.233334;let u=i.maxRandomnessOffset||0;u*u*100>s&&(u=c/10);let d=u/2,f=.2+Aa(i)*.2,p=i.bowing*i.maxRandomnessOffset*(r-t)/200,m=i.bowing*i.maxRandomnessOffset*(e-n)/200;p=k(p,i,l),m=k(m,i,l);let h=[],g=()=>k(d,i,l),_=()=>k(u,i,l),v=i.preserveVertices;return a&&(o?h.push({op:`move`,data:[e+(v?0:g()),t+(v?0:g())]}):h.push({op:`move`,data:[e+(v?0:k(u,i,l)),t+(v?0:k(u,i,l))]})),o?h.push({op:`bcurveTo`,data:[p+e+(n-e)*f+g(),m+t+(r-t)*f+g(),p+e+2*(n-e)*f+g(),m+t+2*(r-t)*f+g(),n+(v?0:g()),r+(v?0:g())]}):h.push({op:`bcurveTo`,data:[p+e+(n-e)*f+_(),m+t+(r-t)*f+_(),p+e+2*(n-e)*f+_(),m+t+2*(r-t)*f+_(),n+(v?0:_()),r+(v?0:_())]}),h}function Pa(e,t,n){let r=[];r.push([e[0][0]+k(t,n),e[0][1]+k(t,n)]),r.push([e[0][0]+k(t,n),e[0][1]+k(t,n)]);for(let i=1;i<e.length;i++)r.push([e[i][0]+k(t,n),e[i][1]+k(t,n)]),i===e.length-1&&r.push([e[i][0]+k(t,n),e[i][1]+k(t,n)]);return Fa(r,null,n)}function Fa(e,t,n){let r=e.length,i=[];if(r>3){let a=[],o=1-n.curveTightness;i.push({op:`move`,data:[e[1][0],e[1][1]]});for(let t=1;t+2<r;t++){let n=e[t];a[0]=[n[0],n[1]],a[1]=[n[0]+(o*e[t+1][0]-o*e[t-1][0])/6,n[1]+(o*e[t+1][1]-o*e[t-1][1])/6],a[2]=[e[t+1][0]+(o*e[t][0]-o*e[t+2][0])/6,e[t+1][1]+(o*e[t][1]-o*e[t+2][1])/6],a[3]=[e[t+1][0],e[t+1][1]],i.push({op:`bcurveTo`,data:[a[1][0],a[1][1],a[2][0],a[2][1],a[3][0],a[3][1]]})}if(t&&t.length===2){let e=n.maxRandomnessOffset;i.push({op:`lineTo`,data:[t[0]+k(e,n),t[1]+k(e,n)]})}}else r===3?(i.push({op:`move`,data:[e[1][0],e[1][1]]}),i.push({op:`bcurveTo`,data:[e[1][0],e[1][1],e[2][0],e[2][1],e[2][0],e[2][1]]})):r===2&&i.push(...Ma(e[0][0],e[0][1],e[1][0],e[1][1],n));return i}function Ia(e,t,n,r,i,a,o,s){let c=s.roughness===0,l=[],u=[];if(c){e/=4,u.push([t+r*Math.cos(-e),n+i*Math.sin(-e)]);for(let a=0;a<=Math.PI*2;a+=e){let e=[t+r*Math.cos(a),n+i*Math.sin(a)];l.push(e),u.push(e)}u.push([t+r*Math.cos(0),n+i*Math.sin(0)]),u.push([t+r*Math.cos(e),n+i*Math.sin(e)])}else{let c=k(.5,s)-Math.PI/2;u.push([k(a,s)+t+.9*r*Math.cos(c-e),k(a,s)+n+.9*i*Math.sin(c-e)]);let d=Math.PI*2+c-.01;for(let o=c;o<d;o+=e){let e=[k(a,s)+t+r*Math.cos(o),k(a,s)+n+i*Math.sin(o)];l.push(e),u.push(e)}u.push([k(a,s)+t+r*Math.cos(c+Math.PI*2+o*.5),k(a,s)+n+i*Math.sin(c+Math.PI*2+o*.5)]),u.push([k(a,s)+t+.98*r*Math.cos(c+o),k(a,s)+n+.98*i*Math.sin(c+o)]),u.push([k(a,s)+t+.9*r*Math.cos(c+o*.5),k(a,s)+n+.9*i*Math.sin(c+o*.5)])}return[u,l]}function La(e,t,n,r,i,a,o,s,c){let l=a+k(.1,c),u=[];u.push([k(s,c)+t+.9*r*Math.cos(l-e),k(s,c)+n+.9*i*Math.sin(l-e)]);for(let a=l;a<=o;a+=e)u.push([k(s,c)+t+r*Math.cos(a),k(s,c)+n+i*Math.sin(a)]);return u.push([t+r*Math.cos(o),n+i*Math.sin(o)]),u.push([t+r*Math.cos(o),n+i*Math.sin(o)]),Fa(u,null,c)}function Ra(e,t,n,r,i,a,o,s){let c=[],l=[s.maxRandomnessOffset||1,(s.maxRandomnessOffset||1)+.3],u=[0,0],d=s.disableMultiStroke?1:2,f=s.preserveVertices;for(let p=0;p<d;p++)p===0?c.push({op:`move`,data:[o[0],o[1]]}):c.push({op:`move`,data:[o[0]+(f?0:k(l[0],s)),o[1]+(f?0:k(l[0],s))]}),u=f?[i,a]:[i+k(l[p],s),a+k(l[p],s)],c.push({op:`bcurveTo`,data:[e+k(l[p],s),t+k(l[p],s),n+k(l[p],s),r+k(l[p],s),u[0],u[1]]});return c}function za(e){return[...e]}function Ba(e,t=0){let n=e.length;if(n<3)throw Error(`A curve must have at least three points.`);let r=[];if(n===3)r.push(za(e[0]),za(e[1]),za(e[2]),za(e[2]));else{let n=[];n.push(e[0],e[0]);for(let t=1;t<e.length;t++)n.push(e[t]),t===e.length-1&&n.push(e[t]);let i=[],a=1-t;r.push(za(n[0]));for(let e=1;e+2<n.length;e++){let t=n[e];i[0]=[t[0],t[1]],i[1]=[t[0]+(a*n[e+1][0]-a*n[e-1][0])/6,t[1]+(a*n[e+1][1]-a*n[e-1][1])/6],i[2]=[n[e+1][0]+(a*n[e][0]-a*n[e+2][0])/6,n[e+1][1]+(a*n[e][1]-a*n[e+2][1])/6],i[3]=[n[e+1][0],n[e+1][1]],r.push(i[1],i[2],i[3])}}return r}function Va(e,t){return Math.sqrt(Ha(e,t))}function Ha(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2}function Ua(e,t,n){let r=Ha(t,n);if(r===0)return Ha(e,t);let i=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r;return i=Math.max(0,Math.min(1,i)),Ha(e,Wa(t,n,i))}function Wa(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function Ga(e,t){let n=e[t+0],r=e[t+1],i=e[t+2],a=e[t+3],o=3*r[0]-2*n[0]-a[0];o*=o;let s=3*r[1]-2*n[1]-a[1];s*=s;let c=3*i[0]-2*a[0]-n[0];c*=c;let l=3*i[1]-2*a[1]-n[1];return l*=l,o<c&&(o=c),s<l&&(s=l),o+s}function Ka(e,t,n,r){let i=r||[];if(Ga(e,t)<n){let n=e[t+0];i.length?Va(i[i.length-1],n)>1&&i.push(n):i.push(n),i.push(e[t+3])}else{let r=.5,a=e[t+0],o=e[t+1],s=e[t+2],c=e[t+3],l=Wa(a,o,r),u=Wa(o,s,r),d=Wa(s,c,r),f=Wa(l,u,r),p=Wa(u,d,r),m=Wa(f,p,r);Ka([a,l,f,m],0,n,i),Ka([m,p,d,c],0,n,i)}return i}function qa(e,t){return Ja(e,0,e.length,t)}function Ja(e,t,n,r,i){let a=i||[],o=e[t],s=e[n-1],c=0,l=1;for(let r=t+1;r<n-1;++r){let t=Ua(e[r],o,s);t>c&&(c=t,l=r)}return Math.sqrt(c)>r?(Ja(e,t,l+1,r,a),Ja(e,l,n,r,a)):(a.length||a.push(o),a.push(s)),a}function Ya(e,t=.15,n){let r=[],i=(e.length-1)/3;for(let n=0;n<i;n++)Ka(e,n*3,t,r);return n&&n>0?Ja(r,0,r.length,n):r}function Xa(e,t,n){let r=ca(sa(oa(e))),i=[],a=[],o=[0,0],s=[],c=()=>{s.length>=4&&a.push(...Ya(s,t)),s=[]},l=()=>{c(),a.length&&(i.push(a),a=[])};for(let{key:e,data:t}of r)switch(e){case`M`:l(),o=[t[0],t[1]],a.push(o);break;case`L`:c(),a.push([t[0],t[1]]);break;case`C`:if(!s.length){let e=a.length?a[a.length-1]:o;s.push([e[0],e[1]])}s.push([t[0],t[1]]),s.push([t[2],t[3]]),s.push([t[4],t[5]]);break;case`Z`:c(),a.push([o[0],o[1]])}if(l(),!n)return i;let u=[];for(let e of i){let t=qa(e,n);t.length&&u.push(t)}return u}var Za=`none`,Qa=class{constructor(e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:`#000`,strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:`hachure`,fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=e||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Qi()}_o(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_d(e,t,n){return{shape:e,sets:t||[],options:n||this.defaultOptions}}line(e,t,n,r,i){let a=this._o(i);return this._d(`line`,[pa(e,t,n,r,a)],a)}rectangle(e,t,n,r,i){let a=this._o(i),o=[],s=ga(e,t,n,r,a);if(a.fill){let i=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]];a.fillStyle===`solid`?o.push(Ca([i],a)):o.push(wa([i],a))}return a.stroke!==Za&&o.push(s),this._d(`rectangle`,o,a)}ellipse(e,t,n,r,i){let a=this._o(i),o=[],s=ya(n,r,a),c=ba(e,t,a,s);if(a.fill){if(a.fillStyle===`solid`){let n=ba(e,t,a,s).opset;n.type=`fillPath`,o.push(n)}else o.push(wa([c.estimatedPoints],a))}return a.stroke!==Za&&o.push(c.opset),this._d(`ellipse`,o,a)}circle(e,t,n,r){let i=this.ellipse(e,t,n,n,r);return i.shape=`circle`,i}linearPath(e,t){let n=this._o(t);return this._d(`linearPath`,[ma(e,!1,n)],n)}arc(e,t,n,r,i,a,o=!1,s){let c=this._o(s),l=[],u=xa(e,t,n,r,i,a,o,!0,c);if(o&&c.fill){if(c.fillStyle===`solid`){let o=Object.assign({},c);o.disableMultiStroke=!0;let s=xa(e,t,n,r,i,a,!0,!1,o);s.type=`fillPath`,l.push(s)}else l.push(Ta(e,t,n,r,i,a,c))}return c.stroke!==Za&&l.push(u),this._d(`arc`,l,c)}curve(e,t){let n=this._o(t),r=[],i=_a(e,n);if(n.fill&&n.fill!==Za&&e.length>=3){if(n.fillStyle===`solid`){let t=_a(e,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));r.push({type:`fillPath`,ops:this._mergedShape(t.ops)})}else{let t=Ya(Ba(e),10,(1+n.roughness)/2);r.push(wa([t],n))}}return n.stroke!==Za&&r.push(i),this._d(`curve`,r,n)}polygon(e,t){let n=this._o(t),r=[],i=ma(e,!0,n);return n.fill&&(n.fillStyle===`solid`?r.push(Ca([e],n)):r.push(wa([e],n))),n.stroke!==Za&&r.push(i),this._d(`polygon`,r,n)}path(e,t){let n=this._o(t),r=[];if(!e)return this._d(`path`,r,n);e=(e||``).replace(/\n/g,` `).replace(/(-\s)/g,`-`).replace(`/(ss)/g`,` `);let i=n.fill&&n.fill!==`transparent`&&n.fill!==Za,a=n.stroke!==Za,o=!!(n.simplification&&n.simplification<1),s=o?4-4*(n.simplification||1):(1+n.roughness)/2,c=Xa(e,1,s),l=Sa(e,n);if(i){if(n.fillStyle===`solid`){if(c.length===1){let t=Sa(e,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));r.push({type:`fillPath`,ops:this._mergedShape(t.ops)})}else r.push(Ca(c,n))}else r.push(wa(c,n))}return a&&(o?c.forEach(e=>{r.push(ma(e,!1,n))}):r.push(l)),this._d(`path`,r,n)}opsToPath(e,t){let n=``;for(let r of e.ops){let e=typeof t==`number`&&t>=0?r.data.map(e=>+e.toFixed(t)):r.data;switch(r.op){case`move`:n+=`M${e[0]} ${e[1]} `;break;case`bcurveTo`:n+=`C${e[0]} ${e[1]}, ${e[2]} ${e[3]}, ${e[4]} ${e[5]} `;break;case`lineTo`:n+=`L${e[0]} ${e[1]} `}}return n.trim()}toPaths(e){let t=e.sets||[],n=e.options||this.defaultOptions,r=[];for(let e of t){let t=null;switch(e.type){case`path`:t={d:this.opsToPath(e),stroke:n.stroke,strokeWidth:n.strokeWidth,fill:Za};break;case`fillPath`:t={d:this.opsToPath(e),stroke:Za,strokeWidth:0,fill:n.fill||Za};break;case`fillSketch`:t=this.fillSketch(e,n)}t&&r.push(t)}return r}fillSketch(e,t){let n=t.fillWeight;return n<0&&(n=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||Za,strokeWidth:n,fill:Za}}_mergedShape(e){return e.filter((e,t)=>t===0||e.op!==`move`)}},$a=class{constructor(e,t){this.canvas=e,this.ctx=this.canvas.getContext(`2d`),this.gen=new Qa(t)}draw(e){let t=e.sets||[],n=e.options||this.getDefaultOptions(),r=this.ctx,i=e.options.fixedDecimalPlaceDigits;for(let a of t)switch(a.type){case`path`:r.save(),r.strokeStyle=n.stroke===`none`?`transparent`:n.stroke,r.lineWidth=n.strokeWidth,n.strokeLineDash&&r.setLineDash(n.strokeLineDash),n.strokeLineDashOffset&&(r.lineDashOffset=n.strokeLineDashOffset),this._drawToContext(r,a,i),r.restore();break;case`fillPath`:{r.save(),r.fillStyle=n.fill||``;let t=e.shape===`curve`||e.shape===`polygon`||e.shape===`path`?`evenodd`:`nonzero`;this._drawToContext(r,a,i,t),r.restore();break}case`fillSketch`:this.fillSketch(r,a,n)}}fillSketch(e,t,n){let r=n.fillWeight;r<0&&(r=n.strokeWidth/2),e.save(),n.fillLineDash&&e.setLineDash(n.fillLineDash),n.fillLineDashOffset&&(e.lineDashOffset=n.fillLineDashOffset),e.strokeStyle=n.fill||``,e.lineWidth=r,this._drawToContext(e,t,n.fixedDecimalPlaceDigits),e.restore()}_drawToContext(e,t,n,r=`nonzero`){e.beginPath();for(let r of t.ops){let t=typeof n==`number`&&n>=0?r.data.map(e=>+e.toFixed(n)):r.data;switch(r.op){case`move`:e.moveTo(t[0],t[1]);break;case`bcurveTo`:e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]);break;case`lineTo`:e.lineTo(t[0],t[1])}}t.type===`fillPath`?e.fill(r):e.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(e,t,n,r,i){let a=this.gen.line(e,t,n,r,i);return this.draw(a),a}rectangle(e,t,n,r,i){let a=this.gen.rectangle(e,t,n,r,i);return this.draw(a),a}ellipse(e,t,n,r,i){let a=this.gen.ellipse(e,t,n,r,i);return this.draw(a),a}circle(e,t,n,r){let i=this.gen.circle(e,t,n,r);return this.draw(i),i}linearPath(e,t){let n=this.gen.linearPath(e,t);return this.draw(n),n}polygon(e,t){let n=this.gen.polygon(e,t);return this.draw(n),n}arc(e,t,n,r,i,a,o=!1,s){let c=this.gen.arc(e,t,n,r,i,a,o,s);return this.draw(c),c}curve(e,t){let n=this.gen.curve(e,t);return this.draw(n),n}path(e,t){let n=this.gen.path(e,t);return this.draw(n),n}},eo=`http://www.w3.org/2000/svg`,to=class{constructor(e,t){this.svg=e,this.gen=new Qa(t)}draw(e){let t=e.sets||[],n=e.options||this.getDefaultOptions(),r=this.svg.ownerDocument||window.document,i=r.createElementNS(eo,`g`),a=e.options.fixedDecimalPlaceDigits;for(let o of t){let t=null;switch(o.type){case`path`:t=r.createElementNS(eo,`path`),t.setAttribute(`d`,this.opsToPath(o,a)),t.setAttribute(`stroke`,n.stroke),t.setAttribute(`stroke-width`,n.strokeWidth+``),t.setAttribute(`fill`,`none`),n.strokeLineDash&&t.setAttribute(`stroke-dasharray`,n.strokeLineDash.join(` `).trim()),n.strokeLineDashOffset&&t.setAttribute(`stroke-dashoffset`,`${n.strokeLineDashOffset}`);break;case`fillPath`:t=r.createElementNS(eo,`path`),t.setAttribute(`d`,this.opsToPath(o,a)),t.setAttribute(`stroke`,`none`),t.setAttribute(`stroke-width`,`0`),t.setAttribute(`fill`,n.fill||``),(e.shape===`curve`||e.shape===`polygon`)&&t.setAttribute(`fill-rule`,`evenodd`);break;case`fillSketch`:t=this.fillSketch(r,o,n)}t&&i.appendChild(t)}return i}fillSketch(e,t,n){let r=n.fillWeight;r<0&&(r=n.strokeWidth/2);let i=e.createElementNS(eo,`path`);return i.setAttribute(`d`,this.opsToPath(t,n.fixedDecimalPlaceDigits)),i.setAttribute(`stroke`,n.fill||``),i.setAttribute(`stroke-width`,r+``),i.setAttribute(`fill`,`none`),n.fillLineDash&&i.setAttribute(`stroke-dasharray`,n.fillLineDash.join(` `).trim()),n.fillLineDashOffset&&i.setAttribute(`stroke-dashoffset`,`${n.fillLineDashOffset}`),i}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(e,t){return this.gen.opsToPath(e,t)}line(e,t,n,r,i){let a=this.gen.line(e,t,n,r,i);return this.draw(a)}rectangle(e,t,n,r,i){let a=this.gen.rectangle(e,t,n,r,i);return this.draw(a)}ellipse(e,t,n,r,i){let a=this.gen.ellipse(e,t,n,r,i);return this.draw(a)}circle(e,t,n,r){let i=this.gen.circle(e,t,n,r);return this.draw(i)}linearPath(e,t){let n=this.gen.linearPath(e,t);return this.draw(n)}polygon(e,t){let n=this.gen.polygon(e,t);return this.draw(n)}arc(e,t,n,r,i,a,o=!1,s){let c=this.gen.arc(e,t,n,r,i,a,o,s);return this.draw(c)}curve(e,t){let n=this.gen.curve(e,t);return this.draw(n)}path(e,t){let n=this.gen.path(e,t);return this.draw(n)}},no={canvas(e,t){return new $a(e,t)},svg(e,t){return new to(e,t)},generator(e){return new Qa(e)},newSeed(){return Qa.newSeed()}};function ro(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}function io(e){return[-e[0],-e[1]]}function ao(e,t){return[e[0]+t[0],e[1]+t[1]]}function oo(e,t){return[e[0]-t[0],e[1]-t[1]]}function so(e,t){return[e[0]*t,e[1]*t]}function co(e,t){return[e[0]/t,e[1]/t]}function lo(e){return[e[1],-e[0]]}function uo(e,t){return e[0]*t[0]+e[1]*t[1]}function fo(e,t){return e[0]===t[0]&&e[1]===t[1]}function po(e){return Math.hypot(e[0],e[1])}function mo(e){return e[0]*e[0]+e[1]*e[1]}function ho(e,t){return mo(oo(e,t))}function go(e){return co(e,po(e))}function _o(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function vo(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function yo(e,t,n){return ao(e,so(oo(t,e),n))}function bo(e,t,n){return ao(e,so(t,n))}var{min:xo,PI:So}=Math,Co=.275,wo=So+1e-4;function To(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=s.taper===!1?0:s.taper===!0?Math.max(n,m):s.taper,g=c.taper===!1?0:c.taper===!0?Math.max(n,m):c.taper,_=(n*r)**2,v=[],y=[],b=e.slice(0,10).reduce((e,t)=>{let r=t.pressure;if(a){let i=xo(1,t.distance/n);r=xo(1,e+(xo(1,1-i)-e)*(i*Co))}return(e+r)/2},e[0].pressure),x=ro(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,w=e[0].point,T=w,E=w,D=T,ee=!1;for(let t=0;t<e.length;t++){let{pressure:r}=e[t],{point:s,vector:c,distance:l,runningLength:u}=e[t];if(t<e.length-1&&m-u<3)continue;if(i){if(a){let e=xo(1,l/n),t=xo(1,1-e);r=xo(1,b+(t-b)*(e*Co))}x=ro(n,i,r,o)}else x=n/2;S===void 0&&(S=x);let f=u<h?d(u/h):1,te=m-u<g?p((m-u)/g):1;x=Math.max(.01,x*Math.min(f,te));let ne=(t<e.length-1?e[t+1]:e[t]).vector,re=t<e.length-1?uo(c,ne):1,ie=uo(c,C)<0&&!ee,ae=re!==null&&re<0;if(ie||ae){let e=so(lo(C),x);for(let t=0;t<=1;t+=.07692307692307693)E=vo(oo(s,e),s,wo*t),v.push(E),D=vo(ao(s,e),s,wo*-t),y.push(D);w=E,T=D,ae&&(ee=!0);continue}if(ee=!1,t===e.length-1){let e=so(lo(c),x);v.push(oo(s,e)),y.push(ao(s,e));continue}let oe=so(lo(yo(ne,c,re)),x);E=oo(s,oe),(t<=1||ho(w,E)>_)&&(v.push(E),w=E),D=ao(s,oe),(t<=1||ho(T,D)>_)&&(y.push(D),T=D),b=r,C=c}let te=e[0].point.slice(0,2),ne=e.length>1?e[e.length-1].point.slice(0,2):ao(e[0].point,[1,1]),re=[],ie=[];if(e.length===1){if(!(h||g)||l){let e=bo(te,go(lo(oo(te,ne))),-(S||x)),t=[];for(let n=1/13,r=n;r<=1;r+=n)t.push(vo(e,te,wo*2*r));return t}}else{if(!(h||g&&e.length===1)){if(u)for(let e=1/13,t=e;t<=1;t+=e){let e=vo(y[0],te,wo*t);re.push(e)}else{let e=oo(v[0],y[0]),t=so(e,.5),n=so(e,.51);re.push(oo(te,t),oo(te,n),ao(te,n),ao(te,t))}}let t=lo(io(e[e.length-1].vector));if(g||h&&e.length===1)ie.push(ne);else if(f){let e=bo(ne,t,x);for(let t=1/29,n=t;n<1;n+=t)ie.push(vo(e,ne,wo*3*n))}else ie.push(ao(ne,so(t,x)),ao(ne,so(t,x*.99)),oo(ne,so(t,x*.99)),oo(ne,so(t,x)))}return v.concat(ie,y.reverse(),re)}function Eo(e,t={}){let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let a=.15+(1-n)*.85,o=Array.isArray(e[0])?e:e.map(({x:e,y:t,pressure:n=.5})=>[e,t,n]);if(o.length===2){let e=o[1];o=o.slice(0,-1);for(let t=1;t<5;t++)o.push(yo(o[0],e,t/4))}o.length===1&&(o=[...o,[...ao(o[0],[1,1]),...o[0].slice(2)]]);let s=[{point:[o[0][0],o[0][1]],pressure:o[0][2]>=0?o[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],c=!1,l=0,u=s[0],d=o.length-1;for(let e=1;e<o.length;e++){let t=i&&e===d?o[e].slice(0,2):yo(u.point,o[e],a);if(fo(u.point,t))continue;let n=_o(t,u.point);if(l+=n,e<d&&!c){if(l<r)continue;c=!0}u={point:t,pressure:o[e][2]>=0?o[e][2]:.5,vector:go(oo(u.point,t)),distance:n,runningLength:l},s.push(u)}return s[0].vector=s[1]?.vector||[0,0],s}function Do(e,t={}){return To(Eo(e,t),t)}var Oo=e(r(),1),A=n();function ko(e,t){return Math.sqrt(Ao(e,t))}function Ao(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2}function jo(e,t,n){let r=Ao(t,n);if(r===0)return Ao(e,t);let i=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r;return i=Math.max(0,Math.min(1,i)),Ao(e,Mo(t,n,i))}function Mo(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function No(e,t){let n=e[t+0],r=e[t+1],i=e[t+2],a=e[t+3],o=3*r[0]-2*n[0]-a[0];o*=o;let s=3*r[1]-2*n[1]-a[1];s*=s;let c=3*i[0]-2*a[0]-n[0];c*=c;let l=3*i[1]-2*a[1]-n[1];return l*=l,o<c&&(o=c),s<l&&(s=l),o+s}function Po(e,t,n,r){let i=r||[];if(No(e,t)<n){let n=e[t+0];i.length?ko(i[i.length-1],n)>1&&i.push(n):i.push(n),i.push(e[t+3])}else{let r=.5,a=e[t+0],o=e[t+1],s=e[t+2],c=e[t+3],l=Mo(a,o,r),u=Mo(o,s,r),d=Mo(s,c,r),f=Mo(l,u,r),p=Mo(u,d,r),m=Mo(f,p,r);Po([a,l,f,m],0,n,i),Po([m,p,d,c],0,n,i)}return i}function Fo(e,t){return Io(e,0,e.length,t)}function Io(e,t,n,r,i){let a=i||[],o=e[t],s=e[n-1],c=0,l=1;for(let r=t+1;r<n-1;++r){let t=jo(e[r],o,s);t>c&&(c=t,l=r)}return Math.sqrt(c)>r?(Io(e,t,l+1,r,a),Io(e,l,n,r,a)):(a.length||a.push(o),a.push(s)),a}function Lo(e,t=.15,n){let r=[],i=(e.length-1)/3;for(let n=0;n<i;n++)Po(e,n*3,t,r);return n&&n>0?Io(r,0,r.length,n):r}var Ro=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sanitizeUrl=void 0;var t=/^([^\w]*)(javascript|data|vbscript)/im,n=/&#(\w+)(^\w|;)?/g,r=/&(newline|tab);/gi,i=/[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim,a=/^.+(:|:)/gim,o=[`.`,`/`];function s(e){return o.indexOf(e[0])>-1}function c(e){return e.replace(n,function(e,t){return String.fromCharCode(t)})}function l(e){var n=c(e||``).replace(r,``).replace(i,``).trim();if(!n)return`about:blank`;if(s(n))return n;var o=n.match(a);if(!o)return n;var l=o[0];return t.test(l)?`about:blank`:n}e.sanitizeUrl=l}))(),zo=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`;function Bo(e,t,n){let r=n[0];if(t!=null&&e>=t)throw Error(e+` >= `+t);if(e.slice(-1)===r||t&&t.slice(-1)===r)throw Error(`trailing zero`);if(t){let i=0;for(;(e[i]||r)===t[i];)i++;if(i>0)return t.slice(0,i)+Bo(e.slice(i),t.slice(i),n)}let i=e?n.indexOf(e[0]):0,a=t==null?n.length:n.indexOf(t[0]);return a-i>1?n[Math.round(.5*(i+a))]:t&&t.length>1?t.slice(0,1):n[i]+Bo(e.slice(1),null,n)}function Vo(e){if(e.length!==Ho(e[0]))throw Error(`invalid integer part of order key: `+e)}function Ho(e){if(e>=`a`&&e<=`z`)return e.charCodeAt(0)-97+2;if(e>=`A`&&e<=`Z`)return 90-e.charCodeAt(0)+2;throw Error(`invalid order key head: `+e)}function Uo(e){let t=Ho(e[0]);if(t>e.length)throw Error(`invalid order key: `+e);return e.slice(0,t)}function Wo(e,t){if(e===`A`+t[0].repeat(26))throw Error(`invalid order key: `+e);let n=Uo(e);if(e.slice(n.length).slice(-1)===t[0])throw Error(`invalid order key: `+e)}function Go(e,t){Vo(e);let[n,...r]=e.split(``),i=!0;for(let e=r.length-1;i&&e>=0;e--){let n=t.indexOf(r[e])+1;n===t.length?r[e]=t[0]:(r[e]=t[n],i=!1)}if(i){if(n===`Z`)return`a`+t[0];if(n===`z`)return null;let e=String.fromCharCode(n.charCodeAt(0)+1);return e>`a`?r.push(t[0]):r.pop(),e+r.join(``)}return n+r.join(``)}function Ko(e,t){Vo(e);let[n,...r]=e.split(``),i=!0;for(let e=r.length-1;i&&e>=0;e--){let n=t.indexOf(r[e])-1;n===-1?r[e]=t.slice(-1):(r[e]=t[n],i=!1)}if(i){if(n===`a`)return`Z`+t.slice(-1);if(n===`A`)return null;let e=String.fromCharCode(n.charCodeAt(0)-1);return e<`Z`?r.push(t.slice(-1)):r.pop(),e+r.join(``)}return n+r.join(``)}function qo(e,t,n=zo){if(e!=null&&Wo(e,n),t!=null&&Wo(t,n),e!=null&&t!=null&&e>=t)throw Error(e+` >= `+t);if(e==null){if(t==null)return`a`+n[0];let e=Uo(t),r=t.slice(e.length);if(e===`A`+n[0].repeat(26))return e+Bo(``,r,n);if(e<t)return e;let i=Ko(e,n);if(i==null)throw Error(`cannot decrement any more`);return i}if(t==null){let t=Uo(e),r=e.slice(t.length);return Go(t,n)??t+Bo(r,null,n)}let r=Uo(e),i=e.slice(r.length),a=Uo(t),o=t.slice(a.length);if(r===a)return r+Bo(i,o,n);let s=Go(r,n);if(s==null)throw Error(`cannot increment any more`);return s<t?s:r+Bo(i,null,n)}function Jo(e,t,n,r=zo){if(n===0)return[];if(n===1)return[qo(e,t,r)];if(t==null){let i=qo(e,t,r),a=[i];for(let e=0;e<n-1;e++)i=qo(i,t,r),a.push(i);return a}if(e==null){let i=qo(e,t,r),a=[i];for(let t=0;t<n-1;t++)i=qo(e,i,r),a.push(i);return a.reverse(),a}let i=Math.floor(n/2),a=qo(e,t,r);return[...Jo(e,a,i,r),a,...Jo(a,t,n-i-1,r)]}var Yo=typeof self>`u`?!1:!(`top`in self&&self!==top)&&`showOpenFilePicker`in self&&`showOpenFilePicker`,Xo=i(Yo?()=>import(`./file-open-002ab408-BHUWm0Sh.js`):()=>import(`./file-open-7c801643-DZtJT5zp.js`),[]);async function Zo(...e){return(await Xo).default(...e)}i(Yo?()=>import(`./directory-open-4ed118d0-1i309Asm.js`):()=>import(`./directory-open-01563666-D4xXyWb_.js`),[]);var Qo=i(Yo?()=>import(`./file-save-745eba88-Bwdfz6OZ.js`):()=>import(`./file-save-3189631c-CO9S4HFW.js`),[]);async function $o(...e){return(await Qo).default(...e)}var es=(e,t)=>t.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{}),ts=4,ns=[0,2,4,6,8],rs=(e,t)=>t.map(t=>ji[e][t]),j={transparent:`transparent`,black:`#1e1e1e`,white:`#ffffff`,gray:rs(`gray`,ns),red:rs(`red`,ns),pink:rs(`pink`,ns),grape:rs(`grape`,ns),violet:rs(`violet`,ns),blue:rs(`blue`,ns),cyan:rs(`cyan`,ns),teal:rs(`teal`,ns),green:rs(`green`,ns),yellow:rs(`yellow`,ns),orange:rs(`orange`,ns),bronze:[`#f8f1ee`,`#eaddd7`,`#d2bab0`,`#a18072`,`#846358`]},is=es(j,[`cyan`,`blue`,`violet`,`grape`,`pink`,`green`,`teal`,`yellow`,`orange`,`red`]),as=[j.black,j.red[4],j.green[4],j.blue[4],j.yellow[4]],os=[j.transparent,j.red[1],j.green[1],j.blue[1],j.yellow[1]],ss=[j.white,`#f8f9fa`,`#f5faff`,`#fffce8`,`#fdf8f6`],cs={transparent:j.transparent,white:j.white,gray:j.gray,black:j.black,bronze:j.bronze,...is},ls={transparent:j.transparent,white:j.white,gray:j.gray,black:j.black,bronze:j.bronze,...is},us=e=>[j.cyan[e],j.blue[e],j.violet[e],j.grape[e],j.pink[e],j.green[e],j.teal[e],j.yellow[e],j.orange[e],j.red[e]],ds=(e,t,n)=>`#${((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)}`,fs=/Mac|iPod|iPhone|iPad/.test(navigator.platform),ps=/^Win/.test(navigator.platform),ms=/\b(android)\b/i.test(navigator.userAgent),hs=`netscape`in window&&navigator.userAgent.indexOf(`rv:`)>1&&navigator.userAgent.indexOf(`Gecko`)>1,gs=navigator.userAgent.indexOf(`Chrome`)===-1&&navigator.userAgent.indexOf(`Safari`)!==-1,_s=/iPad|iPhone/.test(navigator.platform)||navigator.userAgent.includes(`Mac`)&&`ontouchend`in document,vs=()=>navigator.brave?.isBrave?.name===`isBrave`,ys=typeof window<`u`&&`ResizeObserver`in window,bs=`Excalidraw`,xs=36,Ss=Math.PI/12,Cs={TEXT:`text`,CROSSHAIR:`crosshair`,GRABBING:`grabbing`,GRAB:`grab`,POINTER:`pointer`,MOVE:`move`,AUTO:``},ws={MAIN:0,WHEEL:1,SECONDARY:2,TOUCH:-1,ERASER:5},Ts={enabled:`all`,disabled:`none`,inheritFromUI:`var(--ui-pointerEvents)`},Es={UNSTARTED:-1,ENDED:0,PLAYING:1,PAUSED:2,BUFFERING:3,CUED:5},Ds={TEST:`test`,DEVELOPMENT:`development`},Os={SHAPE_ACTIONS_MENU:`App-menu__left`,ZOOM_ACTIONS:`zoom-actions`,SEARCH_MENU_INPUT_WRAPPER:`layer-ui__search-inputWrapper`},ks=`Xiaolai`,As=`Segoe UI Emoji`,js={Virgil:1,Helvetica:2,Cascadia:3,Excalifont:5,Nunito:6,"Lilita One":7,"Comic Shanns":8,"Liberation Sans":9},Ms={[ks]:100,[As]:1e3},Ns=e=>{switch(e){case js.Excalifont:return[ks,As];default:return[As]}},Ps={LIGHT:`light`,DARK:`dark`},Fs={strokeColor:`#bbb`,strokeWidth:2,strokeStyle:`solid`,fillStyle:`solid`,roughness:0,roundness:null,backgroundColor:`transparent`,radius:8,nameOffsetY:3,nameColorLightTheme:`#999999`,nameColorDarkTheme:`#7a7a7a`,nameFontSize:14,nameLineHeight:1.25},Is=1,Ls=js.Excalifont,Rs=`left`,zs=4,Bs=2*zs-1e-5,Vs=`#ffffff`,Hs=`#1e1e1e`,Us=`#a2f1a6`,Ws=5,Gs={svg:`image/svg+xml`,png:`image/png`,jpg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`,ico:`image/x-icon`,avif:`image/avif`,jfif:`image/jfif`},M={text:`text/plain`,html:`text/html`,json:`application/json`,excalidraw:`application/vnd.excalidraw+json`,excalidrawlib:`application/vnd.excalidrawlib+json`,"excalidraw.svg":`image/svg+xml`,"excalidraw.png":`image/png`,binary:`application/octet-stream`,...Gs},Ks=[M.text,M.html,...Object.values(Gs)],qs={png:`png`,svg:`svg`,clipboard:`clipboard`},Js={excalidraw:`excalidraw`,excalidrawClipboard:`excalidraw/clipboard`,excalidrawLibrary:`excalidrawlib`,excalidrawClipboardWithAPI:`excalidraw-api/clipboard`},Ys=window.EXCALIDRAW_EXPORT_SOURCE||window.location.origin,Xs=.1,Zs=.1,Qs=`invert(93%) hue-rotate(180deg)`,$s={canvasActions:{changeViewBackgroundColor:!0,clearCanvas:!0,export:{saveFileToDisk:!0},loadScene:!0,saveToActiveFile:!0,toggleTheme:null,saveAsImage:!0},tools:{image:!0}},ec=1e3,tc=1229,nc=2,rc=[1,2,3],ic=1440,ac=4194304,N=`http://www.w3.org/2000/svg`,oc={excalidraw:2,excalidrawLibrary:2},sc=.7,cc=11,lc={TOP:`top`,MIDDLE:`middle`,BOTTOM:`bottom`},uc={LEFT:`left`,CENTER:`center`,RIGHT:`right`},dc=20,fc=.25,pc=32,mc={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},hc={architect:0,artist:1,cartoonist:2},gc={thin:1,bold:2,extraBold:4},_c={strokeColor:j.black,backgroundColor:j.transparent,fillStyle:`solid`,strokeWidth:2,strokeStyle:`solid`,roughness:hc.artist,opacity:100,locked:!1},vc=`library`,yc=`search`,bc={name:`default`,defaultTab:vc},xc=new Set([`iframe`,`embeddable`,`image`]),Sc={selection:`selection`,rectangle:`rectangle`,diamond:`diamond`,ellipse:`ellipse`,arrow:`arrow`,line:`line`,freedraw:`freedraw`,text:`text`,image:`image`,eraser:`eraser`,hand:`hand`,frame:`frame`,magicframe:`magicframe`,embeddable:`embeddable`,laser:`laser`},Cc={OAI_API_KEY:`excalidraw-oai-api-key`,MERMAID_TO_EXCALIDRAW:`mermaid-to-excalidraw`,PUBLISH_LIBRARY:`publish-library-data`},wc=`Untitled`,Tc={generalStats:1,elementProperties:2},Ec={sharp:`sharp`,round:`round`,elbow:`elbow`},Dc=.3,Oc=`element`,kc=Symbol.for(`__test__originalId__`),Ac=(e=>(e.ACTIVE=`active`,e.AWAY=`away`,e.IDLE=`idle`,e))(Ac||{}),jc=rc.includes(devicePixelRatio)?devicePixelRatio:1,Mc=()=>({showWelcomeScreen:!1,theme:Ps.LIGHT,collaborators:new Map,currentChartType:`bar`,currentItemBackgroundColor:_c.backgroundColor,currentItemEndArrowhead:`arrow`,currentItemFillStyle:_c.fillStyle,currentItemFontFamily:Ls,currentItemFontSize:20,currentItemOpacity:_c.opacity,currentItemRoughness:_c.roughness,currentItemStartArrowhead:null,currentItemStrokeColor:_c.strokeColor,currentItemRoundness:`round`,currentItemArrowType:Ec.round,currentItemStrokeStyle:_c.strokeStyle,currentItemStrokeWidth:_c.strokeWidth,currentItemTextAlign:Rs,currentHoveredFontFamily:null,cursorButton:`up`,activeEmbeddable:null,newElement:null,editingTextElement:null,editingGroupId:null,editingLinearElement:null,activeTool:{type:`selection`,customType:null,locked:_c.locked,lastActiveTool:null},penMode:!1,penDetected:!1,errorMessage:null,exportBackground:!0,exportScale:jc,exportEmbedScene:!1,exportWithDarkMode:!1,fileHandle:null,gridSize:20,gridStep:Ws,gridModeEnabled:!1,isBindingEnabled:!0,defaultSidebarDockedPreference:!1,isLoading:!1,isResizing:!1,isRotating:!1,lastPointerDownWith:`mouse`,multiElement:null,name:null,contextMenu:null,openMenu:null,openPopup:null,openSidebar:null,openDialog:null,pasteDialog:{shown:!1,data:null},previousSelectedElementIds:{},resizingElement:null,scrolledOutside:!1,scrollX:0,scrollY:0,selectedElementIds:{},hoveredElementIds:{},selectedGroupIds:{},selectedElementsAreBeingDragged:!1,selectionElement:null,shouldCacheIgnoreZoom:!1,stats:{open:!1,panels:Tc.generalStats|Tc.elementProperties},startBoundElement:null,suggestedBindings:[],frameRendering:{enabled:!0,clip:!0,name:!0,outline:!0},frameToHighlight:null,editingFrame:null,elementsToHighlight:null,toast:null,viewBackgroundColor:j.white,zenModeEnabled:!1,zoom:{value:1},viewModeEnabled:!1,pendingImageElementId:null,showHyperlinkPopup:!1,selectedLinearElement:null,snapLines:[],originSnapOffset:{x:0,y:0},objectsSnapModeEnabled:!1,userToFollow:null,followedBy:new Set,isCropping:!1,croppingElementId:null,searchMatches:[]}),Nc=(e=>e)({showWelcomeScreen:{browser:!0,export:!1,server:!1},theme:{browser:!0,export:!1,server:!1},collaborators:{browser:!1,export:!1,server:!1},currentChartType:{browser:!0,export:!1,server:!1},currentItemBackgroundColor:{browser:!0,export:!1,server:!1},currentItemEndArrowhead:{browser:!0,export:!1,server:!1},currentItemFillStyle:{browser:!0,export:!1,server:!1},currentItemFontFamily:{browser:!0,export:!1,server:!1},currentItemFontSize:{browser:!0,export:!1,server:!1},currentItemRoundness:{browser:!0,export:!1,server:!1},currentItemArrowType:{browser:!0,export:!1,server:!1},currentItemOpacity:{browser:!0,export:!1,server:!1},currentItemRoughness:{browser:!0,export:!1,server:!1},currentItemStartArrowhead:{browser:!0,export:!1,server:!1},currentItemStrokeColor:{browser:!0,export:!1,server:!1},currentItemStrokeStyle:{browser:!0,export:!1,server:!1},currentItemStrokeWidth:{browser:!0,export:!1,server:!1},currentItemTextAlign:{browser:!0,export:!1,server:!1},currentHoveredFontFamily:{browser:!1,export:!1,server:!1},cursorButton:{browser:!0,export:!1,server:!1},activeEmbeddable:{browser:!1,export:!1,server:!1},newElement:{browser:!1,export:!1,server:!1},editingTextElement:{browser:!1,export:!1,server:!1},editingGroupId:{browser:!0,export:!1,server:!1},editingLinearElement:{browser:!1,export:!1,server:!1},activeTool:{browser:!0,export:!1,server:!1},penMode:{browser:!0,export:!1,server:!1},penDetected:{browser:!0,export:!1,server:!1},errorMessage:{browser:!1,export:!1,server:!1},exportBackground:{browser:!0,export:!1,server:!1},exportEmbedScene:{browser:!0,export:!1,server:!1},exportScale:{browser:!0,export:!1,server:!1},exportWithDarkMode:{browser:!0,export:!1,server:!1},fileHandle:{browser:!1,export:!1,server:!1},gridSize:{browser:!0,export:!0,server:!0},gridStep:{browser:!0,export:!0,server:!0},gridModeEnabled:{browser:!0,export:!0,server:!0},height:{browser:!1,export:!1,server:!1},isBindingEnabled:{browser:!1,export:!1,server:!1},defaultSidebarDockedPreference:{browser:!0,export:!1,server:!1},isLoading:{browser:!1,export:!1,server:!1},isResizing:{browser:!1,export:!1,server:!1},isRotating:{browser:!1,export:!1,server:!1},lastPointerDownWith:{browser:!0,export:!1,server:!1},multiElement:{browser:!1,export:!1,server:!1},name:{browser:!0,export:!1,server:!1},offsetLeft:{browser:!1,export:!1,server:!1},offsetTop:{browser:!1,export:!1,server:!1},contextMenu:{browser:!1,export:!1,server:!1},openMenu:{browser:!0,export:!1,server:!1},openPopup:{browser:!1,export:!1,server:!1},openSidebar:{browser:!0,export:!1,server:!1},openDialog:{browser:!1,export:!1,server:!1},pasteDialog:{browser:!1,export:!1,server:!1},previousSelectedElementIds:{browser:!0,export:!1,server:!1},resizingElement:{browser:!1,export:!1,server:!1},scrolledOutside:{browser:!0,export:!1,server:!1},scrollX:{browser:!0,export:!1,server:!1},scrollY:{browser:!0,export:!1,server:!1},selectedElementIds:{browser:!0,export:!1,server:!1},hoveredElementIds:{browser:!1,export:!1,server:!1},selectedGroupIds:{browser:!0,export:!1,server:!1},selectedElementsAreBeingDragged:{browser:!1,export:!1,server:!1},selectionElement:{browser:!1,export:!1,server:!1},shouldCacheIgnoreZoom:{browser:!0,export:!1,server:!1},stats:{browser:!0,export:!1,server:!1},startBoundElement:{browser:!1,export:!1,server:!1},suggestedBindings:{browser:!1,export:!1,server:!1},frameRendering:{browser:!1,export:!1,server:!1},frameToHighlight:{browser:!1,export:!1,server:!1},editingFrame:{browser:!1,export:!1,server:!1},elementsToHighlight:{browser:!1,export:!1,server:!1},toast:{browser:!1,export:!1,server:!1},viewBackgroundColor:{browser:!0,export:!0,server:!0},width:{browser:!1,export:!1,server:!1},zenModeEnabled:{browser:!0,export:!1,server:!1},zoom:{browser:!0,export:!1,server:!1},viewModeEnabled:{browser:!1,export:!1,server:!1},pendingImageElementId:{browser:!1,export:!1,server:!1},showHyperlinkPopup:{browser:!1,export:!1,server:!1},selectedLinearElement:{browser:!0,export:!1,server:!1},snapLines:{browser:!1,export:!1,server:!1},originSnapOffset:{browser:!1,export:!1,server:!1},objectsSnapModeEnabled:{browser:!0,export:!1,server:!1},userToFollow:{browser:!1,export:!1,server:!1},followedBy:{browser:!1,export:!1,server:!1},isCropping:{browser:!1,export:!1,server:!1},croppingElementId:{browser:!1,export:!1,server:!1},searchMatches:{browser:!1,export:!1,server:!1}}),Pc=(e,t)=>{let n={};for(let r of Object.keys(e))Nc[r]?.[t]&&(n[r]=e[r]);return n},Fc=e=>Pc(e,`export`),Ic=e=>Pc(e,`server`),Lc=({activeTool:e})=>e.type===`eraser`,Rc=({activeTool:e})=>e.type===`hand`,P=(e,t,n)=>Math.min(Math.max(e,t),n),zc=(e,t,n=`round`)=>{let r=10**t;return Math[n]((e+2**-52)*r)/r},Bc=(e,t,n=`round`)=>{let r=1/t;return Math[n](e*r)/r},Vc=(e,t)=>(e+t)/2,Hc=e=>typeof e==`number`&&Number.isFinite(e),Uc=(e,t,n=1e-4)=>Math.abs(e-t)<n,Wc=e=>e<0?e+2*Math.PI:e>=2*Math.PI?e-2*Math.PI:e;function Gc(e){return e*Math.PI/180}function Kc(e){return e*180/Math.PI}function qc(e){return Math.abs(Math.sin(2*e))<1e-4}function Jc(e,t,n=0,r=0){return[e-n,t-r]}function F(e,t=[0,0]){return Jc(e[0]-t[0],e[1]-t[1])}function Yc(e,t){return e[0]*t[1]-t[0]*e[1]}function Xc(e,t){return e[0]*t[0]+e[1]*t[1]}function Zc(e,t){return[e[0]+t[0],e[1]+t[1]]}function Qc(e,t){return[e[0]-t[0],e[1]-t[1]]}function $c(e,t){return Jc(e[0]*t,e[1]*t)}function el(e){return e[0]*e[0]+e[1]*e[1]}function tl(e){return Math.sqrt(el(e))}var nl=e=>{let t=tl(e);return t===0?Jc(0,0):Jc(e[0]/t,e[1]/t)};function I(e,t){return[e,t]}function rl(e){return e.length===2?I(e[0],e[1]):void 0}function L(e,t=I(0,0)){return I(t[0]+e[0],t[1]+e[1])}function il(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&!isNaN(e[0])&&typeof e[1]==`number`&&!isNaN(e[1])}function al(e,t){let n=Math.abs;return n(e[0]-t[0])<1e-4&&n(e[1]-t[1])<1e-4}function R([e,t],[n,r],i){return I((e-n)*Math.cos(i)-(t-r)*Math.sin(i)+n,(e-n)*Math.sin(i)+(t-r)*Math.cos(i)+r)}function ol(e,t=[0,0]){return I(e[0]+t[0],e[1]+t[1])}function sl(e,t){return I((e[0]+t[0])/2,(e[1]+t[1])/2)}function cl(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}function ll(e,t){let n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}var ul=(e,t,n)=>ol(t,$c(F(e,t),n)),dl=(e,t,n)=>t[0]<=Math.max(e[0],n[0])&&t[0]>=Math.min(e[0],n[0])&&t[1]<=Math.max(e[1],n[1])&&t[1]>=Math.min(e[1],n[1]);function fl(e,t){return[e,t]}function pl(e,t){let n=e[1][1]-e[0][1],r=e[0][0]-e[1][0],i=t[1][1]-t[0][1],a=t[0][0]-t[1][0],o=n*a-i*r;if(o!==0){let s=n*e[0][0]+r*e[0][1],c=i*t[0][0]+a*t[0][1];return I((s*a-c*r)/o,(n*c-i*s)/o)}return null}function z(e,t){return[e,t]}var ml=(e,t,n=1e-4)=>{let r=hl(e,t);return r===0||r<n},hl=(e,t)=>{let[n,r]=e,[[i,a],[o,s]]=t,c=n-i,l=r-a,u=o-i,d=s-a,f=c*u+l*d,p=u*u+d*d,m=-1;p!==0&&(m=f/p);let h,g;m<0?(h=i,g=a):m>1?(h=o,g=s):(h=i+m*u,g=a+m*d);let _=n-h,v=r-g;return Math.sqrt(_*_+v*v)};function gl(e,t){let n=pl(fl(e[0],e[1]),fl(t[0],t[1]));return!n||!ml(n,t)||!ml(n,e)?null:n}function _l(e,t){return[e,t]}function vl(e,t){return[z(e[0],I(e[1][0],e[0][1])),z(I(e[1][0],e[0][1]),e[1]),z(e[1],I(e[0][0],e[1][1])),z(I(e[0][0],e[1][1]),e[0])].map(e=>gl(t,e)).filter(e=>!!e)}function yl(e,t,n,r){return[e,t,n,r]}function bl(e,t,n,r=1e-6){return[(e(t+r,n)-e(t-r,n))/(2*r),(e(t,n+r)-e(t,n-r))/(2*r)]}function xl(e,t,n,r=.001,i=10){let a=1/0,o=0;for(;a>=r;){if(o>=i)return null;let r=e(t,n),s=[bl((t,n)=>e(t,n)[0],t,n),bl((t,n)=>e(t,n)[1],t,n)],c=[[-r[0]],[-r[1]]],l=s[0][0]*s[1][1]-s[0][1]*s[1][0];if(l===0)return null;let u=[[s[1][1]/l,-s[0][1]/l],[-s[1][0]/l,s[0][0]/l]],d=[[u[0][0]*c[0][0]+u[0][1]*c[1][0]],[u[1][0]*c[0][0]+u[1][1]*c[1][0]]];t+=d[0][0],n+=d[1][0];let[f,p]=e(t,n);a=Math.max(Math.abs(f),Math.abs(p)),o+=1}return[t,n]}var Sl=(e,t)=>I((1-t)**3*e[0][0]+3*(1-t)**2*t*e[1][0]+3*(1-t)*t**2*e[2][0]+t**3*e[3][0],(1-t)**3*e[0][1]+3*(1-t)**2*t*e[1][1]+3*(1-t)*t**2*e[2][1]+t**3*e[3][1]);function Cl(e,t){let n=El(e);if(vl(_l(I(n[0],n[1]),I(n[2],n[3])),t).length===0)return[];let r=e=>I(t[0][0]+e*(t[1][0]-t[0][0]),t[0][1]+e*(t[1][1]-t[0][1])),i=[[.5,0],[.2,0],[.8,0]],a=([t,n])=>{let i=xl((t,n)=>{let i=Sl(e,t),a=r(n);return[i[0]-a[0],i[1]-a[1]]},t,n);if(!i)return null;let[a,o]=i;return a<0||a>1||o<0||o>1?null:Sl(e,a)},o=a(i[0]);return o?[o]:(o=a(i[1]),o?[o]:(o=a(i[2]),o?[o]:[]))}function wl(e,t,n=.001){let r=(e,t,r,i=n)=>{let a=e,o=t,s;for(;o-a>i;)s=(o+a)/2,r(s-i)<r(s+i)?o=s:a=s;return s},i=0;for(let n=1/0,r=0;r<30;r++){let a=cl(t,Sl(e,r/30));a<n&&(n=a,i=r)}let a=r(Math.max((i-1)/30,0),Math.min((i+1)/30,1),n=>cl(t,Sl(e,n)));return a?Sl(e,a):null}function Tl(e,t){let n=wl(e,t);return n?cl(t,n):0}function El(e){let[t,n,r,i]=e,a=[t[0],n[0],r[0],i[0]],o=[t[1],n[1],r[1],i[1]];return[Math.min(...a),Math.min(...o),Math.max(...a),Math.max(...o)]}function Dl(...e){return jl(e)}function Ol(e){return jl(e)}var kl=(e,t)=>{let n=e[0],r=e[1],i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e][0],s=t[e][1],c=t[a][0],l=t[a][1];(s>r&&l<=r||s<=r&&l>r)&&n<(c-o)*(r-s)/(l-s)+o&&(i=!i)}return i},Al=(e,t,n=1e-4)=>{let r=!1;for(let i=0,a=t.length-1;i<a;i++)if(ml(e,z(t[i],t[i+1]),n)){r=!0;break}return r};function jl(e){return Ml(e)?e:[...e,e[0]]}function Ml(e){return al(e[0],e[e.length-1])}function Nl(e,t){return Vu([e,t])}var Pl=([e,t],[n,r])=>e<=n?t>=n:e>=n&&r>=e,Fl=([e,t],[n,r])=>{let i=Math.max(e,n),a=Math.min(t,r);return i<=a?Vu([i,a]):null},Il=(e,[t,n])=>e>=t&&e<=n;function Ll([e,t,n],r){let i=(e,t,n)=>(e[0]-n[0])*(t[1]-n[1])-(t[0]-n[0])*(e[1]-n[1]),a=i(r,e,t),o=i(r,t,n),s=i(r,n,e);return!((a<0||o<0||s<0)&&(a>0||o>0||s>0))}var Rl=()=>{let e=new Date;return`${e.getFullYear()}-${`${e.getMonth()+1}`.padStart(2,`0`)}-${`${e.getDate()}`.padStart(2,`0`)}-${`${e.getHours()}`.padStart(2,`0`)}${`${e.getMinutes()}`.padStart(2,`0`)}`},zl=e=>e.charAt(0).toUpperCase()+e.slice(1),Bl=e=>e instanceof HTMLElement&&e.className.includes(`ToolIcon`),Vl=e=>e instanceof HTMLElement&&e.dataset.type===`wysiwyg`||e instanceof HTMLBRElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,Hl=e=>Vl(e)||e instanceof Element&&!!e.closest(`label, button`),Ul=e=>e instanceof HTMLElement&&e.dataset.type===`wysiwyg`||e instanceof HTMLBRElement||e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&(e.type===`text`||e.type===`number`||e.type===`password`),Wl=({fontFamily:e})=>{for(let[t,n]of Object.entries(js))if(n===e)return`${t}${Ns(n).map(e=>`, ${e}`).join(``)}`;return As},Gl=({fontSize:e,fontFamily:t})=>`${e}px ${Wl({fontFamily:t})}`,Kl=(e,t)=>{let n=0,r=null,i=(...i)=>{r=i,clearTimeout(n),n=window.setTimeout(()=>{r=null,e(...i)},t)};return i.flush=()=>{if(clearTimeout(n),r){let t=r;r=null,e(...t)}},i.cancel=()=>{r=null,clearTimeout(n)},i},ql=(e,t)=>{let n=null,r=null,i=null,a=t=>{n=window.requestAnimationFrame(()=>{n=null,e(...t),r=null,i&&(r=i,i=null,a(r))})},o=(...o)=>{if(s.MODE===`test`){e(...o);return}r=o,n===null?a(r):t?.trailing&&(i=o)};return o.flush=()=>{n!==null&&(cancelAnimationFrame(n),n=null),r&&=(e(...i||r),i=null)},o.cancel=()=>{r=i=null,n!==null&&(cancelAnimationFrame(n),n=null)},o},Jl=e=>1-(1-e)**4,Yl=(e,t,n)=>(t-e)*Jl(n)+e,Xl=({fromValues:e,toValues:t,onStep:n,duration:r=250,interpolateValue:i,onStart:a,onEnd:o,onCancel:s})=>{let c=!1,l=0,u;function d(s){if(c)return;u===void 0&&(u=s,a?.());let f=Math.min(s-u,r),p=Jl(f/r),m={};if(Object.keys(e).forEach(n=>{let r=n,i=(t[r]-e[r])*p+e[r];m[r]=i}),n(m),f<r){let a=f/r,o={};Object.keys(e).forEach(n=>{let r=n,s=e[r],c=t[r],l;l=i?i(s,c,a,r):Yl(s,c,a),l??=Yl(s,c,a),o[r]=l}),n(o),l=window.requestAnimationFrame(d)}else n(t),o?.()}return l=window.requestAnimationFrame(d),()=>{s?.(),c=!0,window.cancelAnimationFrame(l)}},Zl=(e,t)=>{if(!e.length||t<1)return[];let n=0,r=0,i=Array(Math.ceil(e.length/t));for(;n<e.length;)i[r++]=e.slice(n,n+=t);return i},Ql=(e,t)=>Math.abs(e-t),$l=(e,t)=>t.type===`custom`?{...e.activeTool,type:`custom`,customType:t.customType,locked:t.locked??e.activeTool.locked}:{...e.activeTool,lastActiveTool:t.lastActiveToolBeforeEraser===void 0?e.activeTool.lastActiveTool:t.lastActiveToolBeforeEraser,type:t.type,customType:null,locked:t.locked??e.activeTool.locked},eu=e=>(e=e.replace(/\bAlt\b/i,`Alt`).replace(/\bShift\b/i,`Shift`).replace(/\b(Enter|Return)\b/i,`Enter`),fs?e.replace(/\bCtrlOrCmd\b/gi,`Cmd`).replace(/\bAlt\b/i,`Option`):e.replace(/\bCtrlOrCmd\b/gi,`Ctrl`)),tu=({clientX:e,clientY:t},{zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:o})=>({x:(e-r)/n.value-a,y:(t-i)/n.value-o}),nu=({sceneX:e,sceneY:t},{zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:o})=>({x:(e+a)*n.value+r,y:(t+o)*n.value+i}),ru=e=>getComputedStyle(document.documentElement).getPropertyValue(`--${e}`),iu=RegExp(`^[^A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-﷾--]*[֑-߿יִ-﷽ﹰ-ﻼ]`),au=e=>iu.test(e),ou=e=>{let[t,n]=e;return{x:t,y:n}},su=e=>{if(e?.name===`AbortError`){console.warn(e);return}throw e},cu=(e,t,n=0)=>{n<0&&(n=e.length+n),n=Math.min(e.length,Math.max(n,0));let r=n-1;for(;++r<e.length;)if(t(e[r],r,e))return r;return-1},lu=(e,t,n=e.length-1)=>{n<0&&(n=e.length+n),n=Math.min(e.length-1,Math.max(n,0));let r=n+1;for(;--r>-1;)if(t(e[r],r,e))return r;return-1},uu=e=>{let t=e.length===5&&e.substr(4,1)===`0`,n=e.length===9&&e.substr(7,2)===`00`;return t||n||e===j.transparent},du=e=>e.fillStyle!==`solid`||uu(e.backgroundColor),fu=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},pu=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;let{overflowY:e}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(e===`auto`||e===`scroll`||e===`overlay`))return t;t=t.parentElement}return document},mu=e=>{let t=e.parentElement;for(;t;){if(t.tabIndex>-1){t.focus();return}t=t.parentElement}},hu=e=>Array.from(e).map(e=>`0${e.toString(16)}`.slice(-2)).join(``),gu=()=>xu()?1:Date.now(),_u=e=>e instanceof Map?e:e.reduce((e,t)=>(e.set(typeof t==`string`?t:t.id,t),e),new Map),vu=e=>e.reduce((e,t,n)=>(e.set(t.id,[t,n]),e),new Map),yu=(e,t)=>e.reduce((e,n)=>(e[t?t(n):String(n)]=n,e),{}),bu=e=>e.reduce((t,n,r)=>{let i={...n,prev:null,next:null};if(r!==0){let n=t[r-1];if(i.prev=n,n.next=i,r===e.length-1){let e=t[0];i.next=e,e.prev=i}}return t.push(i),t},[]),xu=()=>s.MODE===`test`,Su=()=>s.MODE===`development`,Cu=()=>typeof process<`u`&&!0,wu=(e,t)=>new CustomEvent(e,{detail:{nativeEvent:t},cancelable:!0}),Tu=(e,t)=>{let n=!1;for(let r in t){let i=t[r];if(typeof i<`u`){if(e[r]===i&&(typeof i!=`object`||!i))continue;n=!0}}return n?{...e,...t}:e},Eu=()=>{try{return window.self===window.top?`top`:`iframe`}catch{return`iframe`}},Du=e=>!!e&&typeof e==`object`&&`then`in e&&`catch`in e&&`finally`in e,Ou=e=>{let t=e?.querySelectorAll(`button, a, input, select, textarea, div[tabindex], label[tabindex]`);return t?Array.from(t).filter(e=>e.tabIndex>-1&&!e.disabled):[]},ku=(e,t)=>Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t,Au=(e,t,n,r=!1)=>{let i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return r&&console.warn(`%cisShallowEqual: objects don't have same properties ->`,`color: #8B4000`,e,t),!1;if(n&&Array.isArray(n)){for(let i of n)if(!(e[i]===t[i]||ku(e[i],t[i])))return r&&console.warn(`%cisShallowEqual: ${i} not equal ->`,`color: #8B4000`,e[i],t[i]),!1;return!0}return i.every(i=>{let a=n?.[i],o=a?a(e[i],t[i]):e[i]===t[i]||ku(e[i],t[i]);return!o&&r&&console.warn(`%cisShallowEqual: ${i} not equal ->`,`color: #8B4000`,e[i],t[i]),o})},ju=(e,t,{checkForDefaultPrevented:n=!0}={})=>function(r){if(e?.(r),!n||!r?.defaultPrevented)return t?.(r)},Mu=(e,t,n)=>{if(!t)return e;if(n)return console.error(t),e;throw Error(t)};function Nu(e,t){if(!e)throw Error(t)}var Pu=e=>{let t,n,r=function(r){let i=Object.entries(r);if(t){let e=!0;for(let[n,r]of i)if(t.get(n)!==r){e=!1;break}if(e)return n}let a=e(r);return t=new Map(i),n=a,a};return r.clear=()=>{t=void 0,n=void 0},r},Fu=(e,t)=>e instanceof Set||e instanceof Map?e.has(t):`includes`in e?e.includes(t):e.hasOwnProperty(t),Iu=e=>JSON.parse(JSON.stringify(e)),Lu=(e,t)=>Au(e,t)?e:t;function Ru(e,t,n,r){return e?(e?.addEventListener?.(t,n,r),()=>{e?.removeEventListener?.(t,n,r)}):()=>{}}function zu(e,t=!0){let n=e.length;if(n<4)return``;let r=e[0],i=e[1],a=e[2],o=`M${r[0].toFixed(2)},${r[1].toFixed(2)} Q${i[0].toFixed(2)},${i[1].toFixed(2)} ${Vc(i[0],a[0]).toFixed(2)},${Vc(i[1],a[1]).toFixed(2)} T`;for(let t=2,a=n-1;t<a;t++)r=e[t],i=e[t+1],o+=`${Vc(r[0],i[0]).toFixed(2)},${Vc(r[1],i[1]).toFixed(2)} `;return t&&(o+=`Z`),o}var Bu=e=>e.replace(/\r?\n|\r/g,`
|
|
9
9
|
`),Vu=e=>e,Hu=async(e,...t)=>new Promise(n=>{n(e(...t))}),Uu=(...e)=>Math.max(...e.map(e=>+!!e))>0,Wu=class{constructor(e,t){o(this,`pool`),o(this,`entries`,{}),this.pool=new Ii.default(e,t)}all(){let e=e=>{if(e.data.result){let[t,n]=e.data.result;this.entries[t]=n}};return this.pool.addEventListener(`fulfilled`,e),this.pool.start().then(()=>(setTimeout(()=>{this.pool.removeEventListener(`fulfilled`,e)}),Object.values(this.entries)))}},Gu=e=>e.replace(/"/g,`"`),Ku=e=>Array.isArray(e)?e:[e],qu=e=>!!e&&e.type===`image`&&!!e.fileId,Ju=e=>!!e&&e.type===`image`,Yu=e=>!!e&&e.type===`embeddable`,Xu=e=>!!e&&e.type===`iframe`,Zu=e=>!!e&&(e.type===`iframe`||e.type===`embeddable`),B=e=>e!=null&&e.type===`text`,Qu=e=>e!=null&&e.type===`frame`,$u=e=>e!=null&&e.type===`magicframe`,ed=e=>e!=null&&(e.type===`frame`||e.type===`magicframe`),td=e=>e!=null&&nd(e.type),nd=e=>e===`freedraw`,rd=e=>e!=null&&id(e.type),V=e=>e!=null&&e.type===`arrow`,H=e=>V(e)&&e.elbowed,id=e=>e===`arrow`||e===`line`,ad=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&od(e.type),od=e=>e===`arrow`,sd=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type===`rectangle`||e.type===`diamond`||e.type===`ellipse`||e.type===`image`||e.type===`iframe`||e.type===`embeddable`||e.type===`frame`||e.type===`magicframe`||e.type===`text`&&!e.containerId),cd=e=>e!=null&&(e.type===`rectangle`||e.type===`diamond`||e.type===`image`||e.type===`iframe`||e.type===`embeddable`||e.type===`frame`||e.type===`magicframe`||e.type===`text`&&!e.containerId),ld=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type===`rectangle`||e.type===`diamond`||e.type===`ellipse`||V(e)),ud=e=>{let t=e?.type;if(!t)return!1;switch(t){case`text`:case`diamond`:case`rectangle`:case`iframe`:case`embeddable`:case`ellipse`:case`arrow`:case`freedraw`:case`line`:case`frame`:case`magicframe`:case`image`:case`selection`:return!0;default:return Mu(t,null),!1}},dd=e=>e.type===`rectangle`||e.type===`ellipse`||e.type===`diamond`,fd=e=>ld(e)&&!!e.boundElements?.some(({type:e})=>e===`text`),pd=e=>e!==null&&`containerId`in e&&e.containerId!==null&&B(e),md=e=>e===`rectangle`||e===`embeddable`||e===`iframe`||e===`image`,hd=e=>e===`line`||e===`arrow`||e===`diamond`,gd=(e,t)=>!!((e===mc.ADAPTIVE_RADIUS||e===mc.LEGACY)&&md(t.type)||e===mc.PROPORTIONAL_RADIUS&&hd(t.type)),_d=e=>hd(e.type)?{type:mc.PROPORTIONAL_RADIUS}:md(e.type)?{type:mc.ADAPTIVE_RADIUS}:null,vd=e=>Object.hasOwn(e,`fixedPoint`)&&e.fixedPoint!=null,yd=(e,t,n)=>{let r=e.split(`
|
|
10
10
|
`).map(e=>e||` `).join(`
|
|
11
11
|
`),i=Nd(r,parseFloat(t),n);return{width:Md(r,t),height:i}},bd=`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`.toLocaleUpperCase(),xd=(e,t)=>{let n=Fd(e);return n===0?yd(bd.split(``).join(`
|
|
@@ -38,4 +38,4 @@ PQIDAQAB`,VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX:`false`,VITE_APP_COL
|
|
|
38
38
|
`,w=v.ownerDocument.createElementNS(N,`style`);if(w.classList.add(`style-fonts`),w.appendChild(document.createTextNode(`${C}${S.join(C)}`)),y.appendChild(w),t.exportBackground&&s){let e=v.ownerDocument.createElementNS(N,`rect`);e.setAttribute(`x`,`0`),e.setAttribute(`y`,`0`),e.setAttribute(`width`,`${m}`),e.setAttribute(`height`,`${h}`),e.setAttribute(`fill`,s),v.appendChild(e)}let T=no.svg(v),E=r?.renderEmbeddables??!1;return mS(d,Vu(_u(d)),T,v,n||{},{offsetX:g,offsetY:_,isExporting:!0,exportWithDarkMode:o,renderEmbeddables:E,frameRendering:i,canvasBackgroundColor:s,embedsValidationStatus:E?new Map(d.filter(e=>ed(e)).map(e=>[e.id,!0])):new Map,reuseImages:r?.reuseImages??!0}),v},aC=({payload:e,metadataElement:t})=>{let n=gD(JSON.stringify(vD({text:e})),!0);t.appendChild(rC(`payload-type:${M.excalidraw}`)),t.appendChild(rC(`payload-version:2`)),t.appendChild(rC(`payload-start`)),t.appendChild(document.createTextNode(n)),t.appendChild(rC(`payload-end`))},oC=({svg:e})=>{if(e.includes(`payload-type:${M.excalidraw}`)){let t=e.match(/<!-- payload-start -->\s*(.+?)\s*<!-- payload-end -->/);if(!t)throw Error(`INVALID`);let n=(e.match(/<!-- payload-version:(\d+) -->/)?.[1]||`1`)!==`1`;try{let e=_D(t[1],n),r=JSON.parse(e);if(!(`encoded`in r)){if(`type`in r&&r.type===Js.excalidraw)return e;throw Error(`FAILED`)}return yD(r)}catch(e){throw console.error(e),Error(`FAILED`)}}throw Error(`INVALID`)},sC=(e,t)=>{let[n,r,i,a]=av(e);return[n,r,Ql(n,i)+t*2,Ql(r,a)+t*2]},cC=(e,t,n)=>{let[,,r,i]=sC(e,t).map(e=>Math.trunc(e*n));return[r,i]},lC=class{constructor(e){this.scoreFunction=e,o(this,`content`,[])}sinkDown(e){let t=this.content[e];for(;e>0;){let n=(e+1>>1)-1,r=this.content[n];if(this.scoreFunction(t)<this.scoreFunction(r))this.content[n]=t,this.content[e]=r,e=n;else break}}bubbleUp(e){let t=this.content.length,n=this.content[e],r=this.scoreFunction(n);for(;;){let i=e+1<<1,a=i-1,o=null,s=0;if(a<t){let e=this.content[a];s=this.scoreFunction(e),s<r&&(o=a)}if(i<t){let e=this.content[i];this.scoreFunction(e)<(o===null?r:s)&&(o=i)}if(o!==null)this.content[e]=this.content[o],this.content[o]=n,e=o;else break}}push(e){this.content.push(e),this.sinkDown(this.content.length-1)}pop(){if(this.content.length===0)return null;let e=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.bubbleUp(0)),e}remove(e){if(this.content.length===0)return;let t=this.content.indexOf(e),n=this.content.pop();t<this.content.length&&(this.content[t]=n,this.scoreFunction(n)<this.scoreFunction(e)?this.sinkDown(t):this.bubbleUp(t))}size(){return this.content.length}rescoreElement(e){this.sinkDown(this.content.indexOf(e))}},uC=1,Z=40,dC=(e,t)=>{let n=e.fixedSegments?e.fixedSegments.slice():null;if(n){let r=[];e.points.map(t=>I(e.x+t[0],e.y+t[1])).forEach((t,i,a)=>{if(i<2)return r.push(t);if(k_(D_(t,a[i-1]),D_(a[i-1],a[i-2]))){let t=n?.findIndex(e=>e.index===i-1)??-1,o=n?.findIndex(e=>e.index===i)??-1;o!==-1&&(n[o].start=I(a[i-2][0]-e.x,a[i-2][1]-e.y)),t!==-1&&n.splice(t,1),r.splice(-1,1),n.forEach(e=>{e.index>i-1&&--e.index})}return r.push(t)});let i=[];r.forEach((e,t,r)=>{if(t<3)return i.push(e);if(cl(r[t-2],r[t-1])<uC){let a=n?.findIndex(e=>e.index===t-2)??-1,o=n?.findIndex(e=>e.index===t-1)??-1;o!==-1&&n.splice(o,1),a!==-1&&n.splice(a,1),i.splice(-2,2),n.forEach(e=>{e.index>t-2&&(e.index-=2)});let s=O_(e,r[t-1]);return i.push(I(s?e[0]:r[t-2][0],s?r[t-2][1]:e[1]))}i.push(e)});let a=n.filter(e=>e.index!==1&&e.index!==i.length-1);return a.length===0?jC(MC(NC(_C(e,gC(e,t,i.map(t=>I(t[0]-e.x,t[1]-e.y)),e.startBinding&&AC(e.startBinding.elementId,t),e.endBinding&&AC(e.endBinding.elementId,t)))??[])),a,null,null):(s.DEV&&Nu(zC(i),`Invalid elbow points with fixed segments`),jC(i,a,e.startIsSpecial,e.endIsSpecial))}return{x:e.x,y:e.y,points:e.points,fixedSegments:e.fixedSegments,startIsSpecial:e.startIsSpecial,endIsSpecial:e.endIsSpecial}},fC=(e,t,n)=>{let r=t.map(e=>e.index),i=(e.fixedSegments?.map(e=>e.index)??[]).findIndex(e=>!r.includes(e));if(i===-1||!e.fixedSegments?.[i])return{points:e.points};let a=e.fixedSegments[i].index,o=e.fixedSegments[i-1],s=e.fixedSegments[i+1],c=e.x+(o?o.end[0]:0),l=e.y+(o?o.end[1]:0),u=o?null:e.startBinding,d=s?null:e.endBinding,{startHeading:f,endHeading:p,startGlobalPoint:m,endGlobalPoint:h,hoveredStartElement:g,hoveredEndElement:_,...v}=gC({x:c,y:l,startBinding:u,endBinding:d,startArrowhead:null,endArrowhead:null,points:e.points},n,[I(0,0),I(e.x+(s?.start[0]??e.points[e.points.length-1][0])-c,e.y+(s?.start[1]??e.points[e.points.length-1][1])-l)],u&&AC(u.elementId,n),d&&AC(d.elementId,n),{isDragging:!1}),{points:y}=jC(MC(NC(_C(e,{startHeading:f,endHeading:p,startGlobalPoint:m,endGlobalPoint:h,hoveredStartElement:g,hoveredEndElement:_,...v})??[])),t,null,null),b=[];if(o)for(let t=0;t<o.index;t++)b.push(I(e.x+e.points[t][0],e.y+e.points[t][1]));if(y.forEach(t=>{b.push(I(e.x+(o?o.end[0]:0)+t[0],e.y+(o?o.end[1]:0)+t[1]))}),s)for(let t=s.index;t<e.points.length;t++)b.push(I(e.x+e.points[t][0],e.y+e.points[t][1]));let x=(s?.index??e.points.length)-(o?.index??0)-1,S=t.map(e=>e.index>a?{...e,index:e.index-x+(y.length-1)}:e);return jC(b.flatMap((e,t)=>{let n=b[t-1],r=b[t+1];if(n&&r){let i=D_(e,n),a=D_(r,e);if(k_(i,a))return S.forEach(e=>{e.index>t&&--e.index}),[];if(k_(i,M_(a)))return S.forEach(e=>{e.index>t&&(e.index+=1)}),[e,e]}return[e]}),S,!1,!1)},pC=(e,t,n,r,i,a)=>{let o=t.map((t,n)=>e.fixedSegments==null||e.fixedSegments[n]===void 0||e.fixedSegments[n].index!==t.index||(t.start[0]!==e.fixedSegments[n].start[0]&&t.end[0]!==e.fixedSegments[n].end[0])!=(t.start[1]!==e.fixedSegments[n].start[1]&&t.end[1]!==e.fixedSegments[n].end[1])?n:null).filter(e=>e!==null).shift();if(o==null)return{points:e.points};let s=e.fixedSegments?.findIndex(e=>e.index===1)??-1,c=e.fixedSegments?.findIndex(t=>t.index===e.points.length-1)??-1,l=cl(t[o].start,t[o].end),u=l<Z+5;if(s===-1&&t[o].index===1&&i){let e=A_(n),r=(e?k_(n,x_):k_(n,S_))?u?l/2:Z:u?-l/2:-Z;t[o].start=I(t[o].start[0]+(e?r:0),t[o].start[1]+(e?0:r))}if(c===-1&&t[o].index===e.points.length-1&&a){let e=A_(r),n=(e?k_(r,x_):k_(r,S_))?u?l/2:Z:u?-l/2:-Z;t[o].end=I(t[o].end[0]+(e?n:0),t[o].end[1]+(e?0:n))}let d=t.map(t=>({...t,start:I(e.x+t.start[0],e.y+t.start[1]),end:I(e.x+t.end[0],e.y+t.end[1])})),f=e.points.map((t,n)=>I(e.x+t[0],e.y+t[1])),p=d[o].index-1,m=d[o].index,h=d[o].start,g=d[o].end,_=f[p-1]&&!al(f[p],f[p-1])?O_(f[p-1],f[p]):void 0,v=f[m+1]&&!al(f[m],f[m+1])?O_(f[m+1],f[m]):void 0;if(_!==void 0){let e=+!!_;f[p-1][e]=h[e]}if(f[p]=h,f[m]=g,v!==void 0){let e=+!!v;f[m+1][e]=g[e]}let y=d.findIndex(e=>e.index===p);if(y!==-1){let e=+!!O_(d[y].end,d[y].start);d[y].start[e]=h[e],d[y].end=h}let b=d.findIndex(e=>e.index===m+1);if(b!==-1){let e=+!!O_(d[b].end,d[b].start);d[b].end[e]=g[e],d[b].start=g}if(s===-1&&p===0){let t=i?A_(n):O_(f[1],f[0]);f.unshift(I(t?h[0]:e.x+e.points[0][0],t?e.y+e.points[0][1]:h[1])),i&&f.unshift(I(e.x+e.points[0][0],e.y+e.points[0][1]));for(let e of d)e.index+=i?2:1}if(c===-1&&m===e.points.length-1){let t=A_(r);f.push(I(t?g[0]:e.x+e.points[e.points.length-1][0],t?e.y+e.points[e.points.length-1][1]:g[1])),a&&f.push(I(e.x+e.points[e.points.length-1][0],e.y+e.points[e.points.length-1][1]))}return jC(f,d.map(t=>({...t,start:I(t.start[0]-e.x,t.start[1]-e.y),end:I(t.end[0]-e.x,t.end[1]-e.y)})),!1,!1)},mC=(e,t,n,r,i,a,o,s,c)=>{let l=e.startIsSpecial??null,u=e.endIsSpecial??null,d=t.map((n,r)=>r===0||r===t.length-1?I(e.x+n[0],e.y+n[1]):I(e.x+e.points[r][0],e.y+e.points[r][1])),f=n.map(n=>({...n,start:I(e.x+(n.start[0]-t[0][0]),e.y+(n.start[1]-t[0][1])),end:I(e.x+(n.end[0]-t[0][0]),e.y+(n.end[1]-t[0][1]))})),p=[],m=2+ +!!l,h=2+ +!!u;for(;p.length+m<d.length-h;)p.push(d[p.length+m]);{let e=d[l?2:1],t=d[l?3:2],n=A_(r),i=A_(E_(F(e,t)));if(s&&n===i){let e=n?k_(r,x_):k_(r,S_);if(p.unshift(I(i?a[0]+(e?Z:-Z):t[0],i?t[1]:a[1]+(e?Z:-Z))),p.unshift(I(n?a[0]+(e?Z:-Z):a[0],n?a[1]:a[1]+(e?Z:-Z))),!l){l=!0;for(let e of f)e.index>1&&(e.index+=1)}}else if(p.unshift(I(i?a[0]:e[0],i?e[1]:a[1])),l){l=!1;for(let e of f)e.index>1&&--e.index}p.unshift(a)}{let e=d[d.length-(u?3:2)],t=d[d.length-(u?4:3)],n=A_(i),r=O_(t,e);if(c&&n===r){let e=n?k_(i,x_):k_(i,S_);p.push(I(r?o[0]+(e?Z:-Z):t[0],r?t[1]:o[1]+(e?Z:-Z))),p.push(I(n?o[0]+(e?Z:-Z):o[0],n?o[1]:o[1]+(e?Z:-Z))),u||=!0}else p.push(I(r?o[0]:e[0],r?e[1]:o[1])),u&&=!1}return p.push(o),jC(p,f.map(({index:e})=>({index:e,start:p[e-1],end:p[e]})).map(e=>({...e,start:I(e.start[0]-a[0],e.start[1]-a[1]),end:I(e.end[0]-a[0],e.end[1]-a[1])})),l,u)},Q=1e6,hC=(e,t,n,r)=>{if(e.points.length<2)return{points:n.points??e.points};(e.x<-Q||e.x>Q||e.y<-Q||e.y>Q||e.x+(n?.points?.[n?.points?.length-1]?.[0]??0)<-Q||e.x+(n?.points?.[n?.points?.length-1]?.[0]??0)>Q||e.y+(n?.points?.[n?.points?.length-1]?.[1]??0)<-Q||e.y+(n?.points?.[n?.points?.length-1]?.[1]??0)>Q||e.x+(e?.points?.[e?.points?.length-1]?.[0]??0)<-Q||e.x+(e?.points?.[e?.points?.length-1]?.[0]??0)>Q||e.y+(e?.points?.[e?.points?.length-1]?.[1]??0)<-Q||e.y+(e?.points?.[e?.points?.length-1]?.[1]??0)>Q)&&console.error(`Elbow arrow (or update) is outside reasonable bounds (> 1e6)`,{arrow:e,updates:n}),e.x=P(e.x,-Q,Q),e.y=P(e.y,-Q,Q),n.points&&=n.points.map(([e,t])=>I(P(e,-Q,Q),P(t,-Q,Q))),s.PROD||(Nu(!n.points||n.points.length>=2,`Updated point array length must match the arrow point length, contain exactly the new start and end points or not be specified at all (i.e. you can't add new points between start and end manually to elbow arrows)`),Nu(!e.fixedSegments||e.fixedSegments.map(e=>e.start[0]===e.end[0]||e.start[1]===e.end[1]).every(Boolean),`Fixed segments must be either horizontal or vertical`),Nu(!n.fixedSegments||n.fixedSegments.map(e=>e.start[0]===e.end[0]||e.start[1]===e.end[1]).every(Boolean),`Updates to fixed segments must be either horizontal or vertical`),Nu(e.points.slice(1).map((t,n)=>t[0]===e.points[n][0]||t[1]===e.points[n][1]),`Elbow arrow segments must be either horizontal or vertical`));let i=n.points?n.points&&n.points.length===2?e.points.map((t,r)=>r===0?n.points[0]:r===e.points.length-1?n.points[1]:t):n.points.slice():e.points.slice(),a=typeof n.startBinding<`u`?n.startBinding:e.startBinding,o=typeof n.endBinding<`u`?n.endBinding:e.endBinding,c=a&&AC(a.elementId,t),l=o&&AC(o.elementId,t);if(t.size===0&&zC(i)||c?.id!==a?.elementId||l?.id!==o?.elementId)return jC(i.map(t=>I(e.x+t[0],e.y+t[1])),e.fixedSegments,e.startIsSpecial,e.endIsSpecial);let{startHeading:u,endHeading:d,startGlobalPoint:f,endGlobalPoint:p,hoveredStartElement:m,hoveredEndElement:h,...g}=gC({x:e.x,y:e.y,startBinding:a,endBinding:o,startArrowhead:e.startArrowhead,endArrowhead:e.endArrowhead,points:e.points},t,i,c,l,r),_=n.fixedSegments??e.fixedSegments??[];return!n.points&&!n.fixedSegments&&!n.startBinding&&!n.endBinding?dC(e,t):n.startBinding===e.startBinding&&n.endBinding===e.endBinding&&(n.points??[]).every((t,n)=>al(t,e.points[n]??I(1/0,1/0)))?{}:_.length===0?jC(MC(NC(_C(e,{startHeading:u,endHeading:d,startGlobalPoint:f,endGlobalPoint:p,hoveredStartElement:m,hoveredEndElement:h,...g})??[])),_,null,null):(e.fixedSegments?.length??0)>_.length?fC(e,_,t):n.points?n.points&&n.fixedSegments?n:mC(e,i,_,u,d,f,p,m,h):pC(e,_,u,d,m,h)},gC=(e,t,n,r,i,a)=>{let o=ol(n[0],Jc(e.x,e.y)),s=ol(n[n.length-1],Jc(e.x,e.y)),c=r,l=i;if(a?.isDragging){let e=Array.from(t.values());c=LC(o,t,e,a?.zoom)||r,l=LC(s,t,e,a?.zoom)||i}let u=FC({...e,elbowed:!0,points:n},`start`,e.startBinding?.fixedPoint,o,r,c,a?.isDragging),d=FC({...e,elbowed:!0,points:n},`end`,e.endBinding?.fixedPoint,s,i,l,a?.isDragging),f=IC(u,d,t,c,o),p=IC(d,u,t,l,s),m=[u[0]-2,u[1]-2,u[0]+2,u[1]+2],h=[d[0]-2,d[1]-2,d[0]+2,d[1]+2],g=c?Ng(c,vC(f,e.startArrowhead?Y*6:Y*2,1)):m,_=l?Ng(l,vC(p,e.endArrowhead?Y*6:Y*2,1)):h,v=Pg(u,l?Ng(l,vC(p,Z,Z)):h)||Pg(d,c?Ng(c,vC(f,Z,Z)):m),y=kC(v?[m,h]:[g,_]),b=SC(v?m:g,v?h:_,y,v?vC(f,!c&&!l?0:Z,0):vC(f,!c&&!l?0:Z-(e.startArrowhead?Y*6:Y*2),Z),v?vC(p,!c&&!l?0:Z,0):vC(p,!c&&!l?0:Z-(e.endArrowhead?Y*6:Y*2),Z),v,c&&Ng(c),l&&Ng(l));return{dynamicAABBs:b,startDonglePosition:wC(b[0],f,u),startGlobalPoint:u,startHeading:f,endDonglePosition:wC(b[1],p,d),endGlobalPoint:d,endHeading:p,commonBounds:y,hoveredStartElement:c,hoveredEndElement:l,boundsOverlap:v,startElementBounds:g,endElementBounds:_}},_C=(e,t)=>{let{dynamicAABBs:n,startDonglePosition:r,startGlobalPoint:i,startHeading:a,endDonglePosition:o,endGlobalPoint:s,endHeading:c,commonBounds:l,hoveredEndElement:u}=t,d=CC(n,r||i,a,o||s,c,l),f=r&&OC(r,d),p=o&&OC(o,d),m=OC(s,d);m&&u&&(m.closed=!0);let h=OC(i,d);h&&e.startBinding&&(h.closed=!0);let g=f&&p&&(Pg(f.pos,n[1])||Pg(p.pos,n[0])),_=yC(f||h,p||m,d,a||x_,c||x_,g?[]:n);if(_){let e=_.map(e=>[e.pos[0],e.pos[1]]);return f&&e.unshift(i),p&&e.push(s),e}return null},vC=(e,t,n)=>{switch(e){case w_:return[t,n,n,n];case x_:return[n,t,n,n];case S_:return[n,n,t,n]}return[n,n,n,t]},yC=(e,t,n,r,i,a)=>{let o=xC(e.pos,t.pos),s=new lC(e=>e.f);for(s.push(e);s.size()>0;){let c=s.pop();if(!c||c.closed)continue;if(c===t)return bC(e,c);c.closed=!0;let l=EC(c.addr,n);for(let n=0;n<4;n++){let u=l[n];if(!u||u.closed)continue;let d=ul(u.pos,c.pos,.5);if(Uu(...a.map(e=>Pg(d,e))))continue;let f=PC(n),p=c.parent?E_(F(c.pos,c.parent.pos)):r;if(k_(M_(p),f)||RC(e.addr,u.addr)&&k_(f,r)||RC(t.addr,u.addr)&&k_(f,i))continue;let m=p!==f,h=c.g+xC(u.pos,c.pos)+(m?o**3:0),g=u.visited;if(!g||h<u.g){let e=TC(u,t,f,i);u.visited=!0,u.parent=c,u.h=xC(t.pos,u.pos)+e*o**2,u.g=h,u.f=u.g+u.h,g?s.rescoreElement(u):s.push(u)}}}return null},bC=(e,t)=>{let n=t,r=[];for(;n.parent;)r.unshift(n),n=n.parent;return r.unshift(e),r},xC=(e,t)=>Math.abs(e[0]-t[0])+Math.abs(e[1]-t[1]),SC=(e,t,n,r,i,a,o,s)=>{let c=o??e,l=s??t,[u,d,f,p]=r??[0,0,0,0],[m,h,g,_]=i??[0,0,0,0],v=[e[0]>t[2]?e[1]>t[3]||e[3]<t[1]?Math.min((c[0]+l[2])/2,e[0]-p):(c[0]+l[2])/2:e[0]>t[0]?e[0]-p:n[0]-p,e[1]>t[3]?e[0]>t[2]||e[2]<t[0]?Math.min((c[1]+l[3])/2,e[1]-u):(c[1]+l[3])/2:e[1]>t[1]?e[1]-u:n[1]-u,e[2]<t[0]?e[1]>t[3]||e[3]<t[1]?Math.max((c[2]+l[0])/2,e[2]+d):(c[2]+l[0])/2:e[2]<t[2]?e[2]+d:n[2]+d,e[3]<t[1]?e[0]>t[2]||e[2]<t[0]?Math.max((c[3]+l[1])/2,e[3]+f):(c[3]+l[1])/2:e[3]<t[3]?e[3]+f:n[3]+f],y=[t[0]>e[2]?t[1]>e[3]||t[3]<e[1]?Math.min((l[0]+c[2])/2,t[0]-_):(l[0]+c[2])/2:t[0]>e[0]?t[0]-_:n[0]-_,t[1]>e[3]?t[0]>e[2]||t[2]<e[0]?Math.min((l[1]+c[3])/2,t[1]-m):(l[1]+c[3])/2:t[1]>e[1]?t[1]-m:n[1]-m,t[2]<e[0]?t[1]>e[3]||t[3]<e[1]?Math.max((l[2]+c[0])/2,t[2]+h):(l[2]+c[0])/2:t[2]<e[2]?t[2]+h:n[2]+h,t[3]<e[1]?t[0]>e[2]||t[2]<e[0]?Math.max((l[3]+c[1])/2,t[3]+g):(l[3]+c[1])/2:t[3]<e[3]?t[3]+g:n[3]+g],b=kC([v,y]);if(!a&&v[2]-v[0]+y[2]-y[0]>b[2]-b[0]+1e-11&&v[3]-v[1]+y[3]-y[1]>b[3]-b[1]+1e-11){let[n,r]=[(y[0]+y[2])/2,(y[1]+y[3])/2];if(t[0]>e[2]&&e[1]>t[3]){let t=v[2]+(y[0]-v[2])/2,i=y[3]+(v[1]-y[3])/2;return Yc(Jc(e[2]-n,e[1]-r),Jc(e[0]-n,e[3]-r))>0?[[v[0],v[1],t,v[3]],[t,y[1],y[2],y[3]]]:[[v[0],i,v[2],v[3]],[y[0],y[1],y[2],i]]}if(e[2]<t[0]&&e[3]<t[1]){let t=v[2]+(y[0]-v[2])/2,i=v[3]+(y[1]-v[3])/2;return Yc(Jc(e[0]-n,e[1]-r),Jc(e[2]-n,e[3]-r))>0?[[v[0],v[1],v[2],i],[y[0],i,y[2],y[3]]]:[[v[0],v[1],t,v[3]],[t,y[1],y[2],y[3]]]}if(e[0]>t[2]&&e[3]<t[1]){let t=y[2]+(v[0]-y[2])/2,i=v[3]+(y[1]-v[3])/2;return Yc(Jc(e[2]-n,e[1]-r),Jc(e[0]-n,e[3]-r))>0?[[t,v[1],v[2],v[3]],[y[0],y[1],t,y[3]]]:[[v[0],v[1],v[2],i],[y[0],i,y[2],y[3]]]}if(e[0]>t[2]&&e[1]>t[3]){let t=y[2]+(v[0]-y[2])/2,i=y[3]+(v[1]-y[3])/2;return Yc(Jc(e[0]-n,e[1]-r),Jc(e[2]-n,e[3]-r))>0?[[t,v[1],v[2],v[3]],[y[0],y[1],t,y[3]]]:[[v[0],i,v[2],v[3]],[y[0],y[1],y[2],i]]}}return[v,y]},CC=(e,t,n,r,i,a)=>{let o=new Set,s=new Set;n===C_||n===x_?s.add(t[1]):o.add(t[0]),i===C_||i===x_?s.add(r[1]):o.add(r[0]),e.forEach(e=>{o.add(e[0]),o.add(e[2]),s.add(e[1]),s.add(e[3])}),o.add(a[0]),o.add(a[2]),s.add(a[1]),s.add(a[3]);let c=Array.from(s).sort((e,t)=>e-t),l=Array.from(o).sort((e,t)=>e-t);return{row:c.length,col:l.length,data:c.flatMap((e,t)=>l.map((n,r)=>({f:0,g:0,h:0,closed:!1,visited:!1,parent:null,addr:[r,t],pos:[n,e]})))}},wC=(e,t,n)=>{switch(t){case w_:return I(n[0],e[1]);case x_:return I(e[2],n[1]);case S_:return I(n[0],e[3])}return I(e[0],n[1])},TC=(e,t,n,r)=>{if(r===x_)switch(n){case x_:return e.pos[0]>=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2;case w_:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case S_:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case C_:return e.pos[1]===t.pos[1]?4:2}else if(r===C_)switch(n){case x_:return e.pos[1]===t.pos[1]?4:2;case w_:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case S_:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case C_:return e.pos[0]<=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2}else if(r===w_)switch(n){case x_:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case w_:return e.pos[1]>=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case S_:return e.pos[0]===t.pos[0]?4:2;case C_:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3}else if(r===S_)switch(n){case x_:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case w_:return e.pos[0]===t.pos[0]?4:2;case S_:return e.pos[1]<=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case C_:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3}return 0},EC=([e,t],n)=>[DC([e,t-1],n),DC([e+1,t],n),DC([e,t+1],n),DC([e-1,t],n)],DC=([e,t],n)=>e<0||e>=n.col||t<0||t>=n.row?null:n.data[t*n.col+e]??null,OC=(e,t)=>{for(let n=0;n<t.col;n++)for(let r=0;r<t.row;r++){let i=DC([n,r],t);if(i&&e[0]===i.pos[0]&&e[1]===i.pos[1])return i}return null},kC=e=>[Math.min(...e.map(e=>e[0])),Math.min(...e.map(e=>e[1])),Math.max(...e.map(e=>e[2])),Math.max(...e.map(e=>e[3]))],AC=(e,t)=>{let n=t.get(e);return n&&sd(n)?n:null},jC=(e,t,n,r)=>{let i=e[0][0],a=e[0][1],o=e.map(t=>ol(t,$c(F(e[0]),-1)));return(i<-Q||i>Q||a<-Q||a>Q||i+o[o.length-1][0]<-Q||a+o[o.length-1][0]>Q||i+o[o.length-1][1]<-Q||a+o[o.length-1][1]>Q)&&console.error(`Elbow arrow normalization is outside reasonable bounds (> 1e6)`,{x:i,y:a,points:o,...V_(o)}),o=o.map(([e,t])=>I(P(e,-1e6,1e6),P(t,-1e6,1e6))),{points:o,x:P(i,-1e6,1e6),y:P(a,-1e6,1e6),fixedSegments:(t?.length??0)>0?t:null,...V_(o),startIsSpecial:n,endIsSpecial:r}},MC=e=>{if(e.length>1){let t=Math.abs(e[0][1]-e[1][1])<Math.abs(e[0][0]-e[1][0]);return e.filter((n,r)=>{if(r===0||r===e.length-1)return!0;let i=e[r+1],a=Math.abs(n[1]-i[1])<Math.abs(n[0]-i[0]);return t===a?(t=a,!1):(t=a,!0)})}return e},NC=e=>e.length>=4?e.filter((t,n)=>{if(n===0||n===e.length-1)return!0;let r=e[n-1];return cl(r,t)>uC}):e,PC=e=>{switch(e){case 0:return w_;case 1:return x_;case 2:return S_}return C_},FC=(e,t,n,r,i,a,o)=>{if(o)return a?Jv(a,Gv(e,a,t)):r;if(i){let r=py(n||[0,0],i);return Math.abs(mv(i,r)-Y)>.01?Gv(e,i,t):r}return r},IC=(e,t,n,r,i)=>Uv(e,t,r,r&&Ng(r,[,,,,].fill(mv(r,e))),n,i),LC=(e,t,n,r)=>Iv(ou(e),n,t,r,!0,!0),RC=(e,t)=>e[0]===t[0]&&e[1]===t[1],zC=(e,t=uC)=>e.slice(1).map((n,r)=>Math.abs(n[0]-e[r][0])<t||Math.abs(n[1]-e[r][1])<t).every(Boolean),BC={selection:!0,text:!0,rectangle:!0,diamond:!0,ellipse:!0,line:!0,image:!0,arrow:!0,freedraw:!0,eraser:!1,custom:!0,frame:!0,embeddable:!0,hand:!0,laser:!1,magicframe:!1},VC=e=>Object.keys(js).includes(e)?js[e]:Ls,HC=(e,t)=>{if(!t)return null;let n=t.focus||0;return H(e)?vd(t)?{...t,focus:n,fixedPoint:gy(t.fixedPoint??[0,0])}:null:{...t,focus:n}},UC=(e,t)=>{let n={type:t.type||e.type,version:e.version||1,versionNonce:e.versionNonce??0,index:e.index??null,isDeleted:e.isDeleted??!1,id:e.id||tx(),fillStyle:e.fillStyle||_c.fillStyle,strokeWidth:e.strokeWidth||_c.strokeWidth,strokeStyle:e.strokeStyle??_c.strokeStyle,roughness:e.roughness??_c.roughness,opacity:e.opacity==null?_c.opacity:e.opacity,angle:e.angle||0,x:t.x??e.x??0,y:t.y??e.y??0,strokeColor:e.strokeColor||_c.strokeColor,backgroundColor:e.backgroundColor||_c.backgroundColor,width:e.width||0,height:e.height||0,seed:e.seed??1,groupIds:e.groupIds??[],frameId:e.frameId??null,roundness:e.roundness?e.roundness:e.strokeSharpness===`round`?{type:md(e.type)?mc.LEGACY:mc.PROPORTIONAL_RADIUS}:null,boundElements:e.boundElementIds?e.boundElementIds.map(e=>({type:`arrow`,id:e})):e.boundElements??[],updated:e.updated??gu(),link:e.link?Ib(e.link):null,locked:e.locked??!1};return(`customData`in e||`customData`in t)&&(n.customData=`customData`in t?t.customData:e.customData),{...e,...n,...YT(n),...t}},WC=e=>{switch(e={...e},e.type){case`text`:delete e.rawText;let t=e.fontSize,n=e.fontFamily;if(`font`in e){let[r,i]=e.font.split(` `);t=parseFloat(r),n=VC(i)}let r=typeof e.text==`string`&&e.text||``,i=e.lineHeight||(e.height?Ed(e):Ih(e.fontFamily));return e=UC(e,{fontSize:t,fontFamily:n,text:r,textAlign:e.textAlign||`left`,verticalAlign:e.verticalAlign||`top`,containerId:e.containerId??null,originalText:e.originalText||r,autoResize:e.autoResize??!0,lineHeight:i}),!r&&!e.isDeleted&&(e={...e,originalText:r,isDeleted:!0},e=UT(e)),e;case`freedraw`:return UC(e,{points:e.points,lastCommittedPoint:null,simulatePressure:e.simulatePressure,pressures:e.pressures});case`image`:return UC(e,{status:e.status||`pending`,fileId:e.fileId,scale:e.scale||[1,1],crop:e.crop??null});case`line`:case`draw`:let{startArrowhead:a=null,endArrowhead:o=null}=e,s=e.x,c=e.y,l=!Array.isArray(e.points)||e.points.length<2?[I(0,0),I(e.width,e.height)]:e.points;return(l[0][0]!==0||l[0][1]!==0)&&({points:l,x:s,y:c}=X.getNormalizedPoints(e)),UC(e,{type:e.type===`draw`?`line`:e.type,startBinding:HC(e,e.startBinding),endBinding:HC(e,e.endBinding),lastCommittedPoint:null,startArrowhead:a,endArrowhead:o,points:l,x:s,y:c,...V_(l)});case`arrow`:{let{startArrowhead:t=null,endArrowhead:n=`arrow`}=e,r=e.x,i=e.y,a=!Array.isArray(e.points)||e.points.length<2?[I(0,0),I(e.width,e.height)]:e.points;(a[0][0]!==0||a[0][1]!==0)&&({points:a,x:r,y:i}=X.getNormalizedPoints(e));let o={type:e.type,startBinding:HC(e,e.startBinding),endBinding:HC(e,e.endBinding),lastCommittedPoint:null,startArrowhead:t,endArrowhead:n,points:a,x:r,y:i,elbowed:e.elbowed,...V_(a)};return H(e)?UC(e,{...o,elbowed:!0,startBinding:HC(e,e.startBinding),endBinding:HC(e,e.endBinding),fixedSegments:e.fixedSegments,startIsSpecial:e.startIsSpecial,endIsSpecial:e.endIsSpecial}):UC(e,o)}case`ellipse`:case`rectangle`:case`diamond`:case`iframe`:case`embeddable`:return UC(e,{});case`magicframe`:case`frame`:return UC(e,{name:e.name??null})}return null},GC=(e,t)=>{if(e.boundElements){let n=e.boundElements.slice(),r=new Set;e.boundElements=n.reduce((n,i)=>{let a=t.get(i.id);if(a&&!r.has(i.id)){if(r.add(i.id),a.isDeleted)return n;n.push(i),B(a)&&!a.containerId&&(a.containerId=e.id)}return n},[])}},KC=(e,t)=>{let n=e.containerId?t.get(e.containerId):null;if(!n){e.containerId=null;return}if(!e.isDeleted&&n.boundElements&&!n.boundElements.find(t=>t.id===e.id)){let t=(n.boundElements||=[]).slice();t.push({type:`text`,id:e.id}),n.boundElements=t}},qC=(e,t)=>{e.frameId&&(t.get(e.frameId)||(e.frameId=null))},JC=(e,t,n)=>{let r=new Set,i=t?_u(t):null,a=Ex((e||[]).reduce((e,t)=>{if(t.type!==`selection`&&!WT(t)){let n=WC(t);if(n){let a=i?.get(t.id);a&&a.version>n.version&&(n=UT(n,a.version)),r.has(n.id)&&(n={...n,id:tx()}),r.add(n.id),e.push(n)}}return e},[]));if(!n?.repairBindings)return a;let o=_u(a);for(let e of a)e.frameId&&qC(e,o),B(e)&&e.containerId?KC(e,o):e.boundElements&&GC(e,o),n.refreshDimensions&&B(e)&&Object.assign(e,fx(e,wb(e,o),o)),rd(e)&&(e.startBinding&&(!o.has(e.startBinding.elementId)||!V(e))&&(e.startBinding=null),e.endBinding&&(!o.has(e.endBinding.elementId)||!V(e))&&(e.endBinding=null));return a.map(e=>{if(H(e)&&e.startBinding==null&&e.endBinding==null&&!zC(e.points))return{...e,...hC(e,o,{points:[I(0,0),e.points[e.points.length-1]]}),index:e.index};if(H(e)&&e.startBinding&&e.endBinding&&e.startBinding.elementId===e.endBinding.elementId&&e.points.length>1&&e.points.some(([e,t])=>Math.abs(e)>1e6||Math.abs(t)>1e6)){console.error(`Fixing self-bound elbow arrow`,e.id);let t=o.get(e.startBinding.elementId);return t?{...e,x:t.x+t.width/2,y:t.y-5,width:t.width,height:t.height,points:[I(0,0),I(0,-10),I(t.width/2+5,-10),I(t.width/2+5,t.height/2+5)]}:(console.error(`Bound element not found`,e.startBinding.elementId),e)}return e})},YC=(e,t,n)=>{let r=t[e];return r===void 0?n[e]:r},XC={isSidebarDocked:(e,t)=>[`defaultSidebarDockedPreference`,e.isSidebarDocked??YC(`defaultSidebarDockedPreference`,e,t)]},ZC=(e,t)=>{e||={};let n=Mc(),r={};for(let t of Object.keys(XC))if(t in e){let[i,a]=XC[t](e,n);r[i]=a}for(let[i,a]of Object.entries(n)){let n=e[i],o=t?t[i]:void 0;r[i]=n===void 0?o===void 0?a:o:n}return{...r,cursorButton:t?.cursorButton||`up`,penDetected:t?.penDetected??(e.penMode?e.penDetected??!1:!1),activeTool:{...$l(n,r.activeTool.type&&BC[r.activeTool.type]?r.activeTool:{type:`selection`}),lastActiveTool:null,locked:r.activeTool.locked??!1},zoom:{value:by(Hc(e.zoom)?e.zoom:e.zoom?.value??n.zoom.value)},openSidebar:typeof e.openSidebar==`string`?{name:bc.name}:r.openSidebar,gridSize:xy(Hc(e.gridSize)?e.gridSize:20),gridStep:Sy(Hc(e.gridStep)?e.gridStep:Ws),editingFrame:null}},QC=(e,t,n,r)=>({elements:JC(e?.elements,n,r),appState:ZC(e?.appState,t||null),files:e?.files||{}}),$C=e=>{let t=JC(LE(e.elements),null);return t.length?{...e,elements:t}:null},ew=(e=[],t)=>{let n=[];for(let r of e)if(Array.isArray(r)){let e=$C({status:t,elements:r,id:tx(),created:Date.now()});e&&n.push(e)}else{let e=r,i=$C({...e,id:e.id||tx(),status:e.status||t,created:e.created||Date.now()});i&&n.push(i)}return n},tw=32,nw=12,rw=256,iw=50,aw=`NOT_SPREADSHEET`,ow=`VALID_SPREADSHEET`,sw=e=>{let t=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,``)):null},cw=(e,t)=>e.slice(1).every(e=>sw(e[t])!==null),lw=e=>{let t=e[0].length;if(t>2)return{type:aw,reason:`More than 2 columns`};if(t===1){if(!cw(e,0))return{type:aw,reason:`Value is not numeric`};let t=sw(e[0][0])===null,n=(t?e.slice(1):e).map(e=>sw(e[0]));return n.length<2?{type:aw,reason:`Less than two rows`}:{type:ow,spreadsheet:{title:t?e[0][0]:null,labels:null,values:n}}}let n=cw(e,0),r=cw(e,1);if(!n&&!r)return{type:aw,reason:`Value is not numeric`};let[i,a]=r?[0,1]:[1,0],o=sw(e[0][a])===null,s=o?e.slice(1):e;return s.length<2?{type:aw,reason:`Less than 2 rows`}:{type:ow,spreadsheet:{title:o?e[0][a]:null,labels:s.map(e=>e[i]),values:s.map(e=>sw(e[a]))}}},uw=e=>{let t=[];for(let n=0;n<e[0].length;n++){let r=[];for(let t=0;t<e.length;t++)r.push(e[t][n]);t.push(r)}return t},dw=e=>{let t=e.trim().split(`
|
|
39
39
|
`).map(e=>e.trim().split(` `));if(t.length&&t[0].length!==2&&(t=e.trim().split(`
|
|
40
40
|
`).map(e=>e.trim().split(`,`))),t.length===0)return{type:aw,reason:`No values`};let n=t[0].length;if(!t.every(e=>e.length===n))return{type:aw,reason:`All rows don't have same number of columns`};let r=lw(t);if(r.type!==ow){let e=lw(uw(t));if(e.type===ow)return e}return r},fw=us(ts),pw={fillStyle:`hachure`,fontFamily:Ls,fontSize:20,opacity:100,roughness:1,strokeColor:j.black,roundness:null,strokeStyle:`solid`,strokeWidth:1,verticalAlign:lc.MIDDLE,locked:!1},mw=e=>({chartWidth:(tw+nw)*e.values.length+nw,chartHeight:rw+nw*2}),hw=(e,t,n,r,i)=>e.labels?.map((e,a)=>lx({groupIds:[r],backgroundColor:i,...pw,text:e.length>8?`${e.slice(0,5)}...`:e,x:t+a*(tw+nw)+nw*2,y:n+nw/2,width:tw,angle:5.87,fontSize:16,textAlign:`center`,verticalAlign:`top`}))||[],gw=(e,t,n,r,i)=>{let a=lx({groupIds:[r],backgroundColor:i,...pw,x:t-nw,y:n-nw,text:`0`,textAlign:`right`});return[a,lx({groupIds:[r],backgroundColor:i,...pw,x:t-nw,y:n-rw-a.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:`right`})]},_w=(e,t,n,r,i)=>{let{chartWidth:a,chartHeight:o}=mw(e);return[mx({backgroundColor:i,groupIds:[r],...pw,type:`line`,x:t,y:n,width:a,points:[I(0,0),I(a,0)]}),mx({backgroundColor:i,groupIds:[r],...pw,type:`line`,x:t,y:n,height:o,points:[I(0,0),I(0,-o)]}),mx({backgroundColor:i,groupIds:[r],...pw,type:`line`,x:t,y:n-rw-nw,strokeStyle:`dotted`,width:a,opacity:iw,points:[I(0,0),I(a,0)]})]},vw=(e,t,n,r,i,a)=>{let{chartWidth:o,chartHeight:s}=mw(e),c=e.title?lx({backgroundColor:i,groupIds:[r],...pw,text:e.title,x:t+o/2,y:n-rw-nw*2-20,roundness:null,textAlign:`center`}):null,l=a?rx({backgroundColor:i,groupIds:[r],...pw,type:`rectangle`,x:t,y:n-s,width:o,height:s,strokeColor:j.black,fillStyle:`solid`,opacity:6}):null;return[...l?[l]:[],...c?[c]:[],...hw(e,t,n,r,i),...gw(e,t,n,r,i),..._w(e,t,n,r,i)]},yw=(e,t,n)=>{let r=Math.max(...e.values),i=tx(),a=fw[Math.floor(Math.random()*fw.length)];return[...e.values.map((e,o)=>{let s=e/r*rw;return rx({backgroundColor:a,groupIds:[i],...pw,type:`rectangle`,x:t+o*(tw+nw)+nw,y:n-s-nw,width:tw,height:s})}),...vw(e,t,n,i,a,s.DEV)]},bw=(e,t,n)=>{let r=Math.max(...e.values),i=tx(),a=fw[Math.floor(Math.random()*fw.length)],o=0,c=[];for(let t of e.values){let e=o*(tw+nw),n=-(t/r)*rw;c.push([e,n]),o++}let l=Math.max(...c.map(e=>e[0])),u=Math.max(...c.map(e=>e[1])),d=Math.min(...c.map(e=>e[0])),f=Math.min(...c.map(e=>e[1])),p=mx({backgroundColor:a,groupIds:[i],...pw,type:`line`,x:t+nw+tw/2,y:n-nw,height:u-f,width:l-d,strokeWidth:2,points:c}),m=e.values.map((e,o)=>{let s=o*(tw+nw)+nw/2,c=-(e/r)*rw+nw/2;return rx({backgroundColor:a,groupIds:[i],...pw,fillStyle:`solid`,strokeWidth:2,type:`ellipse`,x:t+s+tw/2,y:n+c-nw*2,width:nw,height:nw})}),h=e.values.map((e,o)=>{let s=o*(tw+nw)+nw/2,c=e/r*rw+nw/2+nw;return mx({backgroundColor:a,groupIds:[i],...pw,type:`line`,x:t+s+tw/2+nw/2,y:n-c,height:c,strokeStyle:`dotted`,opacity:iw,points:[I(0,0),I(0,c)]})});return[...vw(e,t,n,i,a,s.DEV),p,...h,...m]},xw=(e,t,n,r)=>e===`line`?bw(t,n,r):yw(t,n,r);`clipboard`in navigator&&`readText`in navigator.clipboard;var Sw=`clipboard`in navigator&&`writeText`in navigator.clipboard,Cw=`clipboard`in navigator&&`write`in navigator.clipboard&&`ClipboardItem`in window&&`toBlob`in HTMLCanvasElement.prototype,ww=e=>!!([Js.excalidraw,Js.excalidrawClipboard,Js.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Tw=({types:e,files:t})=>{!e&&!t&&console.warn(`createPasteEvent: no types or files provided`);let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});if(e)for(let[r,i]of Object.entries(e)){if(typeof i!=`string`){t||=[],t.push(i);continue}try{if(n.clipboardData?.setData(r,i),n.clipboardData?.getData(r)!==i)throw Error(`Failed to set "${r}" as clipboardData item`)}catch(e){throw Error(e.message)}}if(t){let e=-1;for(let r of t){e++;try{if(n.clipboardData?.items.add(r),n.clipboardData?.files[e]!==r)throw Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(e){throw Error(e.message)}}}return n},Ew=({elements:e,files:t})=>{let n=_u(e),r=new Set(e.filter(e=>ed(e))),i=!1,a=e.reduce((e,n)=>(qu(n)&&(i=!0,t&&t[n.fileId]&&(e[n.fileId]=t[n.fileId])),e),{});i&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let o={type:Js.excalidrawClipboard,elements:e.map(e=>{if(mT(e,n)&&!r.has(mT(e,n))){let t=vx(e);return $(t,{frameId:null}),t}return e}),files:t?a:void 0};return JSON.stringify(o)},Dw=async(e,t,n)=>{await Fw(Ew({elements:e,files:t}),n)},Ow=e=>{let t=dw(e);return t.type===ow?{spreadsheet:t.spreadsheet}:null};function kw(e){let t=[];for(let n of e.childNodes)if(n.nodeType===3){let e=n.textContent?.trim();e&&t.push({type:`text`,value:e})}else if(n instanceof HTMLImageElement){let e=n.getAttribute(`src`);e&&e.startsWith(`http`)&&t.push({type:`imageUrl`,value:e})}else t=t.concat(kw(n));return t}var Aw=e=>{let t=e.clipboardData?.getData(M.html);if(!t)return null;try{let e=kw(new DOMParser().parseFromString(t,M.html).body);if(e.length)return{type:`mixedContent`,value:e}}catch(e){console.error(`error in parseHTMLFromPaste: ${e.message}`)}return null},jw=async()=>{let e={},t;try{t=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let e=await navigator.clipboard?.readText();if(e)return{[M.text]:e}}}catch(t){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);else{if(t.name===`DataError`)return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${t.message}`),e;throw t}}throw t}for(let n of t)for(let t of n.types)if(Fu(Ks,t))try{if(t===M.text||t===M.html)e[t]=await(await n.getType(t)).text();else if(KE(t))e[t]=uD(await n.getType(t),t,void 0);else throw new uh(`Unsupported clipboard type: ${t}`)}catch(e){console.warn(e instanceof uh?e.message:`Cannot retrieve ${t} from clipboardItem: ${e.message}`)}return Object.keys(e).length===0&&console.warn(`No clipboard data found from clipboard.read().`),e},Mw=async(e,t=!1)=>{try{let n=!t&&e&&Aw(e);return n?n.value.every(e=>e.type===`text`)?{type:`text`,value:e.clipboardData?.getData(M.text)||n.value.map(e=>e.value).join(`
|
|
41
|
-
`).trim()}:n:{type:`text`,value:(e.clipboardData?.getData(M.text)||``).trim()}}catch{return{type:`text`,value:``}}},Nw=async(e,t=!1)=>{let n=await Mw(e,t);if(n.type===`mixedContent`)return{mixedContent:n.value};try{let e=!t&&Ow(n.value);if(e)return e}catch(e){console.error(e)}try{let e=JSON.parse(n.value),r=e.type===Js.excalidrawClipboardWithAPI;if(ww(e))return{elements:e.elements,files:e.files,text:t?JSON.stringify(e.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:n.value}},Pw=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[M.png]:e})])}catch(t){if(Du(e))await navigator.clipboard.write([new window.ClipboardItem({[M.png]:await e})]);else throw t}},Fw=async(e,t)=>{if(Sw)try{await navigator.clipboard.writeText(e||``);return}catch(e){console.error(e)}try{if(t){if(t.clipboardData?.setData(M.text,e||``),t.clipboardData?.getData(M.text)!==e)throw Error(`Failed to setData on clipboardEvent`);return}}catch(e){console.error(e)}if(!Iw(e))throw Error(`Error copying to clipboard.`)},Iw=e=>{e||=` `;let t=document.documentElement.getAttribute(`dir`)===`rtl`,n=document.createElement(`textarea`);n.style.border=`0`,n.style.padding=`0`,n.style.margin=`0`,n.style.position=`absolute`,n.style[t?`right`:`left`]=`-9999px`;let r=window.pageYOffset||document.documentElement.scrollTop;n.style.top=`${r}px`,n.style.fontSize=`12pt`,n.setAttribute(`readonly`,``),n.value=e,document.body.appendChild(n);let i=!1;try{n.select(),n.setSelectionRange(0,n.value.length),i=document.execCommand(`copy`)}catch(e){console.error(e)}return n.remove(),i},Lw=({elements:e,appState:t,files:n,maxWidthOrHeight:r,getDimensions:i,exportPadding:a,exportingFrame:o})=>{let{elements:s,appState:c}=QC({elements:e,appState:t},null,null),{exportBackground:l,viewBackgroundColor:u}=c;return nC(s,{...c,offsetTop:0,offsetLeft:0,width:0,height:0},n||{},{exportBackground:l,exportPadding:a,viewBackgroundColor:u,exportingFrame:o},(e,n)=>{let a=document.createElement(`canvas`);if(r){typeof i==`function`&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let o=Math.max(e,n),s=r<o?r/o:t?.exportScale??1;return a.width=e*s,a.height=n*s,{canvas:a,scale:s}}let o=i?.(e,n)||{width:e,height:n};return a.width=o.width,a.height=o.height,{canvas:a,scale:o.scale??1}})},Rw=async e=>{let{mimeType:t=M.png,quality:n}=e;t===M.png&&typeof n==`number`&&console.warn(`"quality" will be ignored for "${M.png}" mimeType`),t===`image/jpg`&&(t=M.jpg),t===M.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${M.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await Lw(e);return n||=/image\/jpe?g/.test(t)?.92:.8,new Promise((i,a)=>{r.toBlob(async n=>{if(!n)return a(Error(`couldn't export to blob`));n&&t===M.png&&e.appState?.exportEmbedScene&&(n=await xD({blob:n,metadata:yS(e.elements,e.appState,e.files||{},`local`)})),i(n)},t,n)})},zw=async({elements:e,appState:t=Mc(),files:n={},exportPadding:r,renderEmbeddables:i,exportingFrame:a,skipInliningFonts:o,reuseImages:s})=>{let{elements:c,appState:l}=QC({elements:e,appState:t},null,null);return iC(c,{...l,exportPadding:r},n,{exportingFrame:a,renderEmbeddables:i,skipInliningFonts:o,reuseImages:s})},Bw=e=>e.type===`diamond`?[I(e.width/2,0),I(e.width,e.height/2),I(e.width/2,e.height),I(0,e.height/2)]:[I(0,0),I(0+e.width,0),I(0+e.width,e.height),I(0,e.height)],Vw=e=>rd(e)||td(e)?e.points:Bw(e),Hw=e=>{let t=e.reduce((e,[t,n])=>(e.minY=Math.min(e.minY,n),e.minX=Math.min(e.minX,t),e.maxX=Math.max(e.maxX,t),e.maxY=Math.max(e.maxY,n),e),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},Uw=e=>{let t=Vw(e),{cx:n,cy:r}=Hw(t),i=I(n,r),{minX:a,minY:o,maxX:s,maxY:c}=Hw(t.map(t=>R(t,i,e.angle)));return[a+e.x,o+e.y,s+e.x,c+e.y]},Ww=(e,t,n=!1)=>{let r=Uw(e),i=t[0]<=r[0]&&t[2]>=r[2]&&t[1]<=r[1]&&t[3]>=r[3];return n?i?!0:r[0]<=t[0]&&r[2]>=t[2]&&r[1]<=t[1]&&r[3]>=t[3]:i},Gw=(e,t)=>{let n=Uw(e);return(Il(n[0],Nl(t[0],t[2]))||Il(t[0],Nl(n[0],n[2])))&&(Il(n[1],Nl(t[1],t[3]))||Il(t[1],Nl(n[1],n[3])))},Kw=({elements:e,bounds:t,type:n,errorMargin:r=0})=>{ud(t)&&(t=iv(t,_u(e)));let i=[t[0]-r,t[1]-r,t[2]+r,t[3]+r],a=new Set;for(let t of e)if(!a.has(t.id)&&(n===`overlap`?Gw(t,i):n===`inside`?Ww(t,i):Ww(t,i,!0))){if(a.add(t.id),t.boundElements)for(let e of t.boundElements)a.add(e.id);B(t)&&t.containerId&&a.add(t.containerId),V(t)&&(t.startBinding&&a.add(t.startBinding.elementId),t.endBinding&&a.add(t.endBinding?.elementId))}return e.filter(e=>a.has(e.id))};function qw(e){return[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])]}function Jw(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}var Yw=1e-6;function Xw(e,t){let n=Yc(F(e[1],e[0]),F(t,e[0]));return Math.abs(n)<Yw}function Zw(e,t){return Yc(F(e[1],e[0]),F(t,e[0]))<0}function Qw(e,t){return Xw(e,t[0])||Xw(e,t[1])||(Zw(e,t[0])?!Zw(e,t[1]):Zw(e,t[1]))}function $w(e,t){return Jw(qw(e),qw(t))&&Qw(e,t)&&Qw(t,e)}var eT=(e,t,n)=>{let r=_u(e);for(let e of t)if(e.frameId){let t=n.get(e.id),i=n.get(e.frameId);if(t){let n=r.get(t);n&&$(n,{frameId:i??e.frameId},!1)}}};function tT(e,t,n){let r=G_(t,n),i=G_(e,n);return r.some(e=>i.some(t=>$w(e,t)))}var nT=(e,t,n)=>xT(kT(e,t,n,!1)).filter(e=>!ed(e)&&!e.frameId||e.frameId===t.id),rT=(e,t,n)=>kT([t],e,n).some(e=>e.id===t.id),iT=(e,t,n)=>{let[r,i,a,o]=J(t,n),[s,c,l,u]=av(e);return r<=s&&i<=c&&a>=l&&o>=u},aT=(e,t,n)=>iT([e],t,n)||tT(e,t,n)||rT(e,t,n),oT=(e,t,n)=>{let[r,i,a,o]=J(t,n);return dl(I(r,i),I(e.x,e.y),I(a,o))},sT=e=>{let t=new Map;for(let n of e){let r=ed(n)?n.id:n.frameId;r&&!t.has(r)&&t.set(r,cT(e,r))}return t},cT=(e,t)=>{let n=[];for(let r of e.values())r.frameId===t&&n.push(r);return n},lT=e=>e.filter(e=>ed(e)),uT=e=>{let t=_u(lT(e));return e.filter(e=>t.has(e.id)||!e.frameId||!t.has(e.frameId))},dT=(e,t,n,r)=>{let i=cT(e,t.id),a=new Set(i),o=new Set([...nT(e,t,r),...i.filter(e=>rT(e,t,r))]),s=i.filter(e=>!o.has(e)),c=new Set(Array.from(o).flatMap(e=>e.groupIds));for(let e of s)if(!tT(e,t,r))e.groupIds.length===0&&a.delete(e);else if(e.groupIds.length>0)for(let t of e.groupIds)c.add(t);for(let e of s)if(e.groupIds.length>0){let t=!0;for(let n of e.groupIds)c.has(n)&&(t=!1);t&&a.delete(e)}let l=Array.from(o).filter(e=>e.groupIds.length===0);for(let e of l)a.add(e);let u=Oy(Array.from(o).filter(e=>e.groupIds.length>0),n);for(let[n,i]of Object.entries(u))if(i){let i=jy(e,n);if(iT(i,t,r))for(let e of i)a.add(e)}return[...a].filter(e=>!(B(e)&&e.containerId))},fT=(e,t,n)=>pT(xT(e,nT(e,t,n)),t,n),pT=(e,t,n)=>{let r=[],i=new Map;for(let a of e){let e=!1;if(a.groupIds.length>0){if(a.groupIds.some(e=>i.get(e)))e=!0;else{let r=new Set(a.groupIds.flatMap(e=>jy(n,e)));e=!iT(Array.from(r),t,n)}a.groupIds.forEach(t=>{i.set(t,e)})}e||r.push(a)}return r},mT=(e,t)=>e.frameId&&t.get(e.frameId)||null,hT=(e,t)=>{let n=new Set,r=_u(e);e=xT(e);for(let r of e)ed(r)&&r.id!==t.id&&n.add(r.id);let i=new Set,a=[];for(let o of e)if(!(ed(o)||o.frameId&&n.has(o.frameId))){if(o.groupIds.length){let n=o.groupIds.at(-1);if(!i.has(n)){i.add(n);let o=jy(e,n);if(o.some(e=>aT(e,t,r)))for(let e of o)a.push(e)}}else aT(o,t,r)&&a.push(o)}return a},gT=(e,t,n,r)=>{let i=_u(e),a=new Map;for(let t of e.values())t.frameId===n.id&&a.set(t.id,!0);let o=new Set(t.map(e=>e.id)),s=[],c=new Set;for(let e of t)ed(e)&&e.id!==n.id&&c.add(e.id);for(let n of xT(e,t)){if(ed(n)||n.frameId&&c.has(n.frameId)||n.frameId&&r.selectedElementIds[n.id]&&r.selectedElementIds[n.frameId])continue;a.has(n.id)||s.push(n);let e=Cb(n,i);e&&!o.has(e.id)&&!a.has(e.id)&&s.push(e)}for(let e of s)$(e,{frameId:n.id},!1);return e},_T=(e,t)=>{let n=new Map,r=new Map;for(let i of e)if(i.frameId){n.set(i.id,i);let e=r.get(i.frameId)||[];e.push(i);let a=Cb(i,t);a&&(n.set(a.id,a),e.push(a)),r.set(i.frameId,e)}for(let[,e]of n)$(e,{frameId:null},!1)},vT=(e,t)=>(_T(cT(e,t.id),_u(e)),e),yT=(e,t,n,r)=>gT(vT(e,n),t,n,r.state).slice(),bT=(e,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),i=new Set(r);if(t.editingGroupId)for(let t of r)t.groupIds.length===0?i.add(t):t.groupIds.flatMap(t=>jy(e,t)).forEach(e=>i.add(e));let a=new Set,o=_u(e);return i.forEach(e=>{e.frameId&&!ed(e)&&!CT(e,o,t)&&a.add(e)}),a.size>0&&_T(a,o),e},xT=(e,t)=>{let n=new Set,r=t||e;for(let e of r.values()){let t=e.groupIds[e.groupIds.length-1];t&&n.add(t)}let i=new Set;for(let t of n)jy(e,t).some(e=>ed(e))&&i.add(t);let a=[];for(let e of r.values())i.has(e.groupIds[e.groupIds.length-1])||a.push(e);return a},ST=(e,t,n)=>{let r=B(e)&&wb(e,t)||e;return r.frameId&&n.selectedElementIds[r.id]&&n.selectedElementIds[r.frameId]?mT(r,t):n.selectedElementIds[r.id]&&n.selectedElementsAreBeingDragged?n.frameToHighlight:mT(r,t)},CT=(e,t,n,r)=>{let i=r?.targetFrame??ST(e,t,n);if(!i)return!1;let a=B(e)&&wb(e,t)||e,o=e=>{r?.checkedGroups&&a.groupIds.forEach(t=>{r.checkedGroups?.set(t,e)})};if(!n.selectedElementIds[a.id]||!n.selectedElementsAreBeingDragged||n.selectedElementIds[a.id]&&n.selectedElementIds[i.id])return!0;if(a.groupIds.length===0)return aT(a,i,t);for(let e of a.groupIds)if(r?.checkedGroups?.has(e))return r.checkedGroups.get(e);let s=new Set(a.groupIds.filter(e=>!r?.checkedGroups||!r.checkedGroups.has(e)).flatMap(e=>jy(t,e)));if(n.editingGroupId&&n.selectedElementsAreBeingDragged){let e=new Set(NT(t,n));if(n.frameToHighlight!==null)return!0;e.forEach(e=>{s.delete(e)})}for(let e of s)if(ed(e))return o(!1),!1;for(let e of s)if(aT(e,i,t))return o(!0),!0;return!1},wT=(e,t,n,r,i)=>{if(!n.frameRendering||!n.frameRendering.clip)return!1;let a=tT(e,t,r)||rT(e,t,r);if(a){for(let t of e.groupIds)i?.set(t,!0);return!0}if(!a&&e.groupIds.length>0&&!iT([e],t,r)){let a=!1;if(n.selectedElementsAreBeingDragged)a=CT(e,r,n,{targetFrame:t,checkedGroups:i});else{a=e.frameId===t.id;for(let t of e.groupIds)i?.set(t,a)}for(let t of e.groupIds)i?.set(t,a);return a}return!1},TT=e=>e.name===null?Qu(e)?`Frame`:`AI Frame`:e.name,ET=(e,t)=>Kw({elements:e,bounds:t,type:`overlap`}).filter(e=>!e.frameId||e.frameId===t.id),DT=e=>{let t=_u(e);return e.length>1&&e.some(e=>e.frameId&&t.has(e.frameId))},OT=e=>{let t=new Set;return e.forEach(e=>{ed(e)&&t.add(e.id)}),e.filter(e=>!(e.frameId&&t.has(e.frameId)))},kT=(e,t,n,r=!0)=>{let[i,a,o,s]=J(t,n),c=e.filter(e=>{let[t,r,c,l]=iv(e,n),u=mT(e,n);if(u){let[e,i,a,o]=iv(u,n);t=Math.max(e,t),r=Math.max(i,r),c=Math.min(a,c),l=Math.min(o,l)}return e.locked===!1&&e.type!==`selection`&&!pd(e)&&i<=t&&a<=r&&o>=c&&s>=l});return c=r?OT(c):c,c=c.filter(e=>{let t=mT(e,n);return!t||aT(e,t,n)}),c},AT=(e,t,n,r)=>{let i=new Set(t.map(e=>e.id));return e.filter(e=>{let t=GT(e,n.width,n.height,n,r);return!i.has(e.id)&&t})},jT=function(){let e=null,t=null,n=null,r=(r,i)=>(n!=null&&r===e&&i.selectedElementIds===t||(n=r.some(e=>i.selectedElementIds[e.id]),e=r,t=i.selectedElementIds),n);return r.clearCache=()=>{e=null,t=null,n=null},r}(),MT=(e,t,n)=>{let r=Array.from(new Set(NT(e,t).map(e=>n(e))));return r.length===1?r[0]:null},NT=(e,t,n)=>{let r=new Set,i=[];for(let a of e.values()){if(t.selectedElementIds[a.id]){i.push(a),r.add(a.id);continue}if(n?.includeBoundTextElement&&pd(a)&&t.selectedElementIds[a?.containerId]){i.push(a),r.add(a.id);continue}}if(n?.includeElementsInFrames){let t=[];return i.forEach(n=>{ed(n)&&cT(e,n.id).forEach(e=>!r.has(e.id)&&t.push(e)),t.push(n)}),t}return i},PT=(e,t)=>t.editingTextElement?[t.editingTextElement]:t.newElement?[t.newElement]:NT(e,t,{includeBoundTextElement:!0}),FT=(e,t)=>Au(t.selectedElementIds,e)?t.selectedElementIds:e,IT=e=>{let t=new Map,n=[];for(let r of e)r.isDeleted||(n.push(r),t.set(r.id,r));return{elementsMap:t,elements:n}},LT=(0,Fi.default)(e=>{(s.DEV||s.MODE===Ds.TEST||window?.DEBUG_FRACTIONAL_INDICES)&&Cx(e,{shouldThrow:s.DEV||s.MODE===Ds.TEST,includeBoundTextValidation:!0})},6e4,{leading:!0,trailing:!1}),RT=e=>{let t=[`includeBoundTextElement`,`includeElementsInFrames`],n=``;for(let r of t)n+=`${r}:${e[r]?`1`:`0`}`;return n},zT=e=>typeof e==`string`,BT=class e{constructor(){o(this,`callbacks`,new Set),o(this,`nonDeletedElements`,[]),o(this,`nonDeletedElementsMap`,Vu(new Map)),o(this,`elements`,[]),o(this,`nonDeletedFramesLikes`,[]),o(this,`frames`,[]),o(this,`elementsMap`,Vu(new Map)),o(this,`selectedElementsCache`,{selectedElementIds:null,elements:null,cache:new Map}),o(this,`sceneNonce`),o(this,`insertElement`,e=>{let t=e.frameId?this.getElementIndex(e.frameId):this.elements.length;this.insertElementAtIndex(e,t)}),o(this,`insertElements`,e=>{if(!e.length)return;let t=e[0]?.frameId?this.getElementIndex(e[0].frameId):this.elements.length;this.insertElementsAtIndex(e,t)}),o(this,`getContainerElement`,e=>e&&e.containerId&&this.getElement(e.containerId)||null),o(this,`getElementsFromId`,e=>{let t=this.getNonDeletedElementsMap(),n=t.get(e);return n?[n]:jy(t,e)})}static mapElementToScene(e,t){zT(e)?this.sceneMapById.set(e,t):(this.sceneMapByElement.set(e,t),this.sceneMapById.set(e.id,t))}static getScene(e){return zT(e)?this.sceneMapById.get(e)||null:this.sceneMapByElement.get(e)||null}getSceneNonce(){return this.sceneNonce}getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}getSelectedElements(e){let t=RT(e),n=e?.elements||this.nonDeletedElements;if(this.selectedElementsCache.elements===n&&this.selectedElementsCache.selectedElementIds===e.selectedElementIds){let e=this.selectedElementsCache.cache.get(t);if(e)return e}else e?.elements??this.selectedElementsCache.cache.clear();let r=NT(n,{selectedElementIds:e.selectedElementIds},e);return e?.elements??(this.selectedElementsCache.selectedElementIds=e.selectedElementIds,this.selectedElementsCache.elements=this.nonDeletedElements,this.selectedElementsCache.cache.set(t,r)),r}getNonDeletedFramesLikes(){return this.nonDeletedFramesLikes}getElement(e){return this.elementsMap.get(e)||null}getNonDeletedElement(e){let t=this.getElement(e);return t&&RE(t)?t:null}mapElements(e){let t=!1,n=this.elements.map(n=>{let r=e(n);return r!==n&&(t=!0),r});return t&&this.replaceAllElements(n),t}replaceAllElements(t){let n=t instanceof Array?t:Array.from(t.values()),r=[];LT(n),this.elements=Ex(n),this.elementsMap.clear(),this.elements.forEach(t=>{ed(t)&&r.push(t),this.elementsMap.set(t.id,t),e.mapElementToScene(t,this)});let i=IT(this.elements);this.nonDeletedElements=i.elements,this.nonDeletedElementsMap=i.elementsMap,this.frames=r,this.nonDeletedFramesLikes=IT(this.frames).elements,this.triggerUpdate()}triggerUpdate(){this.sceneNonce=ex();for(let e of Array.from(this.callbacks))e()}onUpdate(e){if(this.callbacks.has(e))throw Error();return this.callbacks.add(e),()=>{if(!this.callbacks.has(e))throw Error();this.callbacks.delete(e)}}destroy(){this.elements=[],this.nonDeletedElements=[],this.nonDeletedFramesLikes=[],this.frames=[],this.elementsMap.clear(),this.selectedElementsCache.selectedElementIds=null,this.selectedElementsCache.elements=null,this.selectedElementsCache.cache.clear(),e.sceneMapById.forEach((t,n)=>{t===this&&e.sceneMapById.delete(n)}),this.callbacks.clear()}insertElementAtIndex(e,t){if(!Number.isFinite(t)||t<0)throw Error(`insertElementAtIndex can only be called with index >= 0`);let n=[...this.elements.slice(0,t),e,...this.elements.slice(t)];Tx(n,_u([e])),this.replaceAllElements(n)}insertElementsAtIndex(e,t){if(!e.length)return;if(!Number.isFinite(t)||t<0)throw Error(`insertElementAtIndex can only be called with index >= 0`);let n=[...this.elements.slice(0,t),...e,...this.elements.slice(t)];Tx(n,_u(e)),this.replaceAllElements(n)}getElementIndex(e){return this.elements.findIndex(t=>t.id===e)}};o(BT,`sceneMapByElement`,new WeakMap),o(BT,`sceneMapById`,new Map);var VT=BT,$=(e,t,n=!0,r)=>{let i=!1,{points:a,fixedSegments:o,fileId:s,startBinding:c,endBinding:l}=t;if(H(e)&&(Object.keys(t).length===0||typeof a<`u`||typeof o<`u`||typeof c<`u`||typeof l<`u`)){let n=Vu(VT.getScene(e)?.getNonDeletedElementsMap()??new Map);t={...t,angle:0,...hC({...e,x:t.x||e.x,y:t.y||e.y},n,{fixedSegments:o,points:a,startBinding:c,endBinding:l},{isDragging:r?.isDragging})}}else typeof a<`u`&&(t={...V_(a),...t});for(let n in t){let r=t[n];if(typeof r<`u`){if(e[n]===r&&(typeof r!=`object`||!r||n===`groupIds`||n===`scale`))continue;if(n===`scale`){let t=e[n],i=r;if(t[0]===i[0]&&t[1]===i[1])continue}else if(n===`points`){let t=e[n],i=r;if(t.length===i.length){let e=!1,n=t.length;for(;--n;){let r=t[n],a=i[n];if(r[0]!==a[0]||r[1]!==a[1]){e=!0;break}}if(!e)continue}}e[n]=r,i=!0}}return i&&((typeof t.height<`u`||typeof t.width<`u`||typeof s<`u`||typeof a<`u`)&&rf.delete(e),e.version++,e.versionNonce=ex(),e.updated=gu(),n&&VT.getScene(e)?.triggerUpdate()),e},HT=(e,t,n=!1)=>{let r=!1;for(let n in t){let i=t[n];if(typeof i<`u`){if(e[n]===i&&(typeof i!=`object`||!i))continue;r=!0}}return!r&&!n?e:{...e,...t,updated:gu(),version:e.version+1,versionNonce:ex()}},UT=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=ex(),e.updated=gu(),e),WT=e=>rd(e)||td(e)?e.points.length<2:e.width===0&&e.height===0,GT=(e,t,n,r,i)=>{let[a,o,s,c]=iv(e,i),l=tu({clientX:r.offsetLeft,clientY:r.offsetTop},r),u=tu({clientX:r.offsetLeft+t,clientY:r.offsetTop+n},r);return l.x<=s&&l.y<=c&&u.x>=a&&u.y>=o},KT=(e,t,n,r,i,a)=>{let[o,s,c,l]=av(e,i),u=tu({clientX:r.offsetLeft+(a?.left||0),clientY:r.offsetTop+(a?.top||0)},r),d=tu({clientX:r.offsetLeft+t-(a?.right||0),clientY:r.offsetTop+n-(a?.bottom||0)},r);return o>=u.x&&s>=u.y&&c<=d.x&&l<=d.y},qT=(e,t,n)=>{let r=Math.abs(t),i=Math.abs(n);if(e===`line`||e===`arrow`||e===`freedraw`){let e=Math.round(Math.atan(i/r)/Ss)*Ss;e===0?n=0:e===Math.PI/2?t=0:n=r*Math.tan(e)*Math.sign(n)||n}else e!==`selection`&&(n=r*Math.sign(n));return{width:t,height:n}},JT=(e,t,n,r)=>{let i=n-e,a=r-t,o=Math.round(Math.atan(a/i)/Ss)*Ss;if(o===0)a=0;else if(o===Math.PI/2)i=0;else{let s=Math.tan(o),c=t-s*e,l=-1/s,u=r-l*n,d=(-1*u- -1*c)/(s*-1-l*-1),f=(c*l-u*s)/(s*-1-l*-1);i=d-e,a=f-t}return{width:i,height:a}},YT=e=>{let t={width:e.width,height:e.height,x:e.x,y:e.y};if(e.width<0){let n=Math.abs(e.width);t.width=n,t.x=e.x-n}if(e.height<0){let n=Math.abs(e.height);t.height=n,t.y=e.y-n}return t},XT={mouse:8,pen:16,touch:28},ZT=16,QT={e:!0,s:!0,n:!0,w:!0},$T={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},eE={e:!0,s:!0,n:!0,w:!0},tE=(e,t,n,r,i,a,o)=>{let[s,c]=R(I(e+n/2,t+r/2),I(i,a),o);return[s-n/2,c-r/2,n,r]},nE=e=>!(e.viewport.isMobile||e.isTouchScreen&&(ms||_s)),rE=e=>nE(e)?QT:{},iE=([e,t,n,r,i,a],o,s,c,l={},u=4,d=2)=>{let f=XT[c],p=f/s.value,m=f/s.value,h=f/s.value,g=f/s.value,_=n-e,v=r-t,y=u/s.value,b=(f-d*2)/(2*s.value),x={nw:l.nw?void 0:tE(e-y-h+b,t-y-g+b,p,m,i,a,o),ne:l.ne?void 0:tE(n+y-b,t-y-g+b,p,m,i,a,o),sw:l.sw?void 0:tE(e-y-h+b,r+y-b,p,m,i,a,o),se:l.se?void 0:tE(n+y-b,r+y-b,p,m,i,a,o),rotation:l.rotation?void 0:tE(e+_/2-p/2,t-y-g+b-ZT/s.value,p,m,i,a,o)},S=5*XT.mouse/s.value;return Math.abs(_)>S&&(l.n||(x.n=tE(e+_/2-p/2,t-y-g+b,p,m,i,a,o)),l.s||(x.s=tE(e+_/2-p/2,r+y-b,p,m,i,a,o))),Math.abs(v)>S&&(l.w||(x.w=tE(e-y-h+b,t+v/2-m/2,p,m,i,a,o)),l.e||(x.e=tE(n+y-b,t+v/2-m/2,p,m,i,a,o))),x},aE=(e,t,n,r=`mouse`,i=QT)=>{if(e.locked||H(e))return{};if(e.type===`freedraw`||rd(e)){if(e.points.length===2){let[,t]=e.points;t[0]===0||t[1]===0?i=eE:t[0]>0&&t[1]<0?i=$T:t[0]>0&&t[1]>0?i=eE:t[0]<0&&t[1]>0?i=$T:t[0]<0&&t[1]<0&&(i=eE)}}else ed(e)&&(i={...i,rotation:!0});let a=rd(e)?10:Ju(e)?0:2;return iE(J(e,n,!0),e.angle,t,r,i,a,Ju(e)?0:void 0)},oE=(e,t)=>{if(t.editingLinearElement)return!1;if(e.length>1)return!0;let n=e[0];return H(n)?!1:!rd(n)||n.points.length>2},sE=(e,t,n)=>t>=e[0]&&t<=e[0]+e[2]&&n>=e[1]&&n<=e[1]+e[3],cE=(e,t,n,r,i,a,o,s)=>{if(!n.selectedElementIds[e.id])return!1;let{rotation:c,...l}=aE(e,a,t,o,rE(s));if(c&&sE(c,r,i))return`rotation`;let u=Object.keys(l).filter(e=>{let t=l[e];return t?sE(t,r,i):!1});if(u.length>0)return u[0];if(nE(s)){let[n,o,s,c,l,u]=J(e,t);if(!(rd(e)&&e.points.length<=2)){let t=Ju(e)?0:zs/a.value,d=zs/a.value,f=mE(I(n-t,o-t),I(s+t,c+t),I(l,u),e.angle);for(let[e,t]of Object.entries(f))if(ml(I(r,i),t,d))return e}}return!1},lE=(e,t,n,r,i,a,o,s)=>e.reduce((e,c)=>{if(e)return e;let l=cE(c,o,t,n,r,i,a,s);return l?{element:c,transformHandleType:l}:null},null),uE=([e,t,n,r],i,a,o,s,c)=>{let l=iE([e,t,n,r,(e+n)/2,(t+r)/2],0,o,s,rE(c)),u=Object.keys(l).find(e=>{let t=l[e];return t&&sE(t,i,a)});if(u)return u;if(nE(c)){let s=(e+n)/2,c=(t+r)/2,l=zs/o.value,u=mE(I(e-l,t-l),I(n+l,r+l),I(s,c),0);for(let[e,t]of Object.entries(u))if(ml(I(i,a),t,l))return e}return!1},dE=[`ns`,`nesw`,`ew`,`nwse`],fE=(e,t)=>{let n=dE.indexOf(e);return n>=0&&(e=dE[(n+Math.round(t/(Math.PI/4)))%dE.length]),e},pE=e=>{let{element:t,transformHandleType:n}=e,r=t&&Math.sign(t.height)*Math.sign(t.width)===-1,i=null;switch(n){case`n`:case`s`:i=`ns`;break;case`w`:case`e`:i=`ew`;break;case`nw`:case`se`:i=r?`nesw`:`nwse`;break;case`ne`:case`sw`:i=r?`nwse`:`nesw`;break;case`rotation`:return`grab`}return i&&t&&(i=fE(i,t.angle)),i?`${i}-resize`:``},mE=([e,t],[n,r],i,a)=>{let o=R(I(e,t),i,a),s=R(I(n,t),i,a),c=R(I(e,r),i,a),l=R(I(n,r),i,a);return{n:[o,s],e:[s,l],s:[l,c],w:[c,o]}},hE=(e,t,n,r,i,a,o,s,c,l,u,d)=>{if(n.length===1){let[u]=n;if(t===`rotation`)H(u)||(gE(u,r,i,c,l,a),Bv(u,r));else{if(B(u)&&t)return yE(e,u,r,t,o,c,l),Bv(u,r),!0;if(t){let i=n[0].id,a=r.get(i),u=e.get(i);if(a&&u){let{nextWidth:n,nextHeight:i}=EE(a,u,r,e,t,c,l,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:o});TE(n,i,a,u,r,e,t,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:o})}}}return!0}if(n.length>1){if(t===`rotation`)return bE(e,n,r,i,c,l,a,u,d),!0;if(t){let{nextWidth:a,nextHeight:u,flipByX:d,flipByY:f,originalBoundingBox:p}=DE(n,e,r,t,c,l,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:o});return OE(n,r,t,i,e,{shouldResizeFromCenter:o,shouldMaintainAspectRatio:s,flipByX:d,flipByY:f,nextWidth:a,nextHeight:u,originalBoundingBox:p}),!0}}return!1},gE=(e,t,n,r,i,a)=>{let[o,s,c,l]=J(e,t),u=(o+c)/2,d=(s+l)/2,f;ed(e)?f=0:(f=5*Math.PI/2+Math.atan2(i-d,r-u),a&&(f+=Ss/2,f-=f%Ss),f=Wc(f));let p=Sb(e);if($(e,{angle:f}),p){let t=n.getElement(p);t&&!V(e)&&$(t,{angle:f})}},_E=(e,t,n,r)=>rd(e)||td(e)?{points:H_(0,t,H_(1,n,e.points,r),r)}:{},vE=(e,t,n)=>{let r=e.width;if(pd(e)){let n=wb(e,t);n&&(r=Nb(n,e))}let i=e.fontSize*(n/r);return i<Is?null:{size:i}},yE=(e,t,n,r,i,a,o)=>{let[s,c,l,u,d,f]=J(t,n),[p,m]=R(I(a,o),I(d,f),-t.angle),h=0,g=0;r!==`e`&&r!==`w`&&(r.includes(`e`)&&(h=(p-s)/(l-s)),r.includes(`w`)&&(h=(l-p)/(l-s)),r.includes(`n`)&&(g=(u-m)/(u-c)),r.includes(`s`)&&(g=(m-c)/(u-c)));let _=Math.max(h,g);if(_>0){let e=t.width*_,a=t.height*_,o=vE(t,n,e);if(o===null)return;let p=[s,c],m=[l,u],h=[d,f],g=I(s,c);if([`n`,`w`,`nw`].includes(r)&&(g=I(m[0]-Math.abs(e),m[1]-Math.abs(a))),r===`ne`){let e=[p[0],m[1]];g=I(e[0],e[1]-Math.abs(a))}if(r===`sw`){let t=[m[0],p[1]];g=I(t[0]-Math.abs(e),t[1])}[`s`,`n`].includes(r)&&(g[0]=h[0]-e/2),[`e`,`w`].includes(r)&&(g[1]=h[1]-a/2),i&&(g[0]=h[0]-Math.abs(e)/2,g[1]=h[1]-Math.abs(a)/2);let v=t.angle;g=R(R(g,I(d,f),v),R(I(g[0]+Math.abs(e)/2,g[1]+Math.abs(a)/2),I(d,f),v),-v);let[y,b]=g;$(t,{fontSize:o.size,width:e,height:a,x:y,y:b})}if(r===`e`||r===`w`){let n=e.get(t.id),[i,s,c,l]=sv(n,n.width,n.height,!0),u=I(i,s),d=I(c,l),f=sl(u,d),p=R(I(a,o),f,-n.angle),[m,,h]=sv(t,t.width,t.height,!0),g=h-m,_=d[0]-u[0],v=Sd(Gl({fontSize:t.fontSize,fontFamily:t.fontFamily}),t.lineHeight),y=_/g;r.includes(`e`)&&(y=(p[0]-u[0])/g),r.includes(`w`)&&(y=(d[0]-p[0])/g);let b=t.width*y<v?v:t.width*y,x=Xd(t.originalText,Gl(t),Math.abs(b)),S=yd(x,Gl(t),t.lineHeight),C=S.height,[w,T,E,D]=sv(n,b,C,!0),ee=E-w,te=D-T,ne=[...u];[`n`,`w`,`nw`].includes(r)&&(ne=[d[0]-Math.abs(ee),u[1]]);let re=n.angle;ne=R(R(ne,f,re),R(I(ne[0]+Math.abs(ee)/2,ne[1]+Math.abs(te)/2),f,re),-re),$(t,{width:Math.abs(b),height:Math.abs(S.height),x:ne[0],y:ne[1],text:x,autoResize:!1})}},bE=(e,t,n,r,i,a,o,s,c)=>{let l=5*Math.PI/2+Math.atan2(a-c,i-s);o&&(l+=Ss/2,l-=l%Ss);for(let r of t)if(!ed(r)){let[i,a,o,u]=J(r,n),d=(i+o)/2,f=(a+u)/2,p=e.get(r.id)?.angle??r.angle,[m,h]=R(I(d,f),I(s,c),l+p-r.angle);H(r)?$(r,{points:hy(r,n)}):$(r,{x:r.x+(m-d),y:r.y+(h-f),angle:Wc(l+p)},!1),Bv(r,n,{simultaneouslyUpdated:t});let g=Cb(r,n);g&&!V(r)&&$(g,{x:g.x+(m-d),y:g.y+(h-f),angle:Wc(l+p)},!1)}r.triggerUpdate()},xE=(e,t,n,r,i)=>{let[a,o,s,c]=t.length===1?J(t[0],n):av(t),l=(a+s)/2,u=(o+c)/2,d=t.length===1?t[0].angle:0;switch([r,i]=R(I(r,i),I(l,u),-d),e){case`n`:return R(I(r-(a+s)/2,i-o),I(0,0),d);case`s`:return R(I(r-(a+s)/2,i-c),I(0,0),d);case`w`:return R(I(r-a,i-(o+c)/2),I(0,0),d);case`e`:return R(I(r-s,i-(o+c)/2),I(0,0),d);case`nw`:return R(I(r-a,i-o),I(0,0),d);case`ne`:return R(I(r-s,i-o),I(0,0),d);case`sw`:return R(I(r-a,i-c),I(0,0),d);case`se`:return R(I(r-s,i-c),I(0,0),d);default:return[0,0]}},SE=(e,t)=>{let[,[n,r]]=t.points;return e===`nw`&&(n<0||r<0)||e===`ne`&&n>=0||e===`sw`&&n<=0||e===`se`&&(n>0||r>0)?`end`:`origin`},CE=(e,t,n)=>{if(n)return`center`;if(t)switch(e){case`n`:return`south-side`;case`e`:return`west-side`;case`s`:return`north-side`;case`w`:return`east-side`;case`ne`:return`bottom-left`;case`nw`:return`bottom-right`;case`se`:return`top-left`;case`sw`:return`top-right`}return[`e`,`se`,`s`].includes(e)?`top-left`:[`n`,`nw`,`w`].includes(e)?`bottom-right`:e===`ne`?`bottom-left`:`top-right`},wE=(e,t,n,r,i,a,o,s,c)=>{let l=CE(o,s,c),[u,d]=e;switch(l){case`top-left`:return{x:u+(t-r)/2+(r-t)/2*Math.cos(a)+(n-i)/2*Math.sin(a),y:d+(n-i)/2+(r-t)/2*Math.sin(a)+(i-n)/2*Math.cos(a)};case`top-right`:return{x:u+(t-r)/2*(Math.cos(a)+1)+(n-i)/2*Math.sin(a),y:d+(n-i)/2+(t-r)/2*Math.sin(a)+(i-n)/2*Math.cos(a)};case`bottom-left`:return{x:u+(t-r)/2*(1-Math.cos(a))+(i-n)/2*Math.sin(a),y:d+(n-i)/2*(Math.cos(a)+1)+(r-t)/2*Math.sin(a)};case`bottom-right`:return{x:u+(t-r)/2*(Math.cos(a)+1)+(i-n)/2*Math.sin(a),y:d+(n-i)/2*(Math.cos(a)+1)+(t-r)/2*Math.sin(a)};case`center`:return{x:u-(r-t)/2,y:d-(i-n)/2};case`east-side`:return{x:u+(t-r)/2*(Math.cos(a)+1),y:d+(t-r)/2*Math.sin(a)+(n-i)/2};case`west-side`:return{x:u+(t-r)/2*(1-Math.cos(a)),y:d+(r-t)/2*Math.sin(a)+(n-i)/2};case`north-side`:return{x:u+(t-r)/2+(n-i)/2*Math.sin(a),y:d+(i-n)/2*(Math.cos(a)-1)};case`south-side`:return{x:u+(t-r)/2+(i-n)/2*Math.sin(a),y:d+(n-i)/2*(Math.cos(a)+1)}}},TE=(e,t,n,r,i,a,o,{shouldInformMutation:s=!0,shouldMaintainAspectRatio:c=!1,shouldResizeFromCenter:l=!1}={})=>{let u={},d=Cb(n,i);if(d){let r=a.get(d.id);if(r&&(u={fontSize:r.fontSize}),c){let r=vE(d,i,Nb({...n,width:e,height:t},d));if(r===null)return;u={fontSize:r.size}}else{let n=xd(Gl(d),d.lineHeight),r=Od(d.fontSize,d.lineHeight);e=Math.max(e,n),t=Math.max(t,r)}}let f=_E(r,e,t,!0),p=I(r.x,r.y);if(rd(r)){let[e,t]=iv(r,a);p=I(e,t)}let m=wE(p,r.width,r.height,e,t,r.angle,o,c,l);if(rd(r)&&f.points){let e=r.x-p[0],t=r.y-p[1];m.x+=e,m.y+=t;let n=f.points[0][0],i=f.points[0][1];m.x+=n,m.y+=i,f.points=f.points.map(e=>I(e[0]-n,e[1]-i))}if(e<0&&(m.x+=e),t<0&&(m.y+=t),`scale`in n&&`scale`in r&&$(n,{scale:[(Math.sign(e)||r.scale[0])*r.scale[0],(Math.sign(t)||r.scale[1])*r.scale[1]]}),V(n)&&d&&c){let t=e/n.width*d.fontSize;if(t<Is)return;u.fontSize=t}e!==0&&t!==0&&Number.isFinite(m.x)&&Number.isFinite(m.y)&&($(n,{...m,width:Math.abs(e),height:Math.abs(t),...f},s),Bv(n,i,{newSize:{width:e,height:t}}),d&&u!=null&&$(d,{fontSize:u.fontSize}),bb(n,i,o,c))},EE=(e,t,n,r,i,a,o,{shouldMaintainAspectRatio:s=!1,shouldResizeFromCenter:c=!1}={})=>{let[l,u,d,f]=sv(t,t.width,t.height,!0),p=I(l,u),m=I(d,f),h=sl(p,m),g=R(I(a,o),h,-t.angle),[_,v,y,b]=sv(e,e.width,e.height,!0),x=y-_,S=b-v,C=m[0]-p[0],w=m[1]-p[1],T=C/x,E=w/S;i.includes(`e`)&&(T=(g[0]-p[0])/x),i.includes(`s`)&&(E=(g[1]-p[1])/S),i.includes(`w`)&&(T=(m[0]-g[0])/x),i.includes(`n`)&&(E=(m[1]-g[1])/S);let D=e.width*T,ee=e.height*E;if(c&&(D=2*D-t.width,ee=2*ee-t.height),s){let e=Math.abs(D)/t.width,n=Math.abs(ee)/t.height;if(i.length===1&&(ee*=e,D*=n),i.length===2){let r=Math.max(e,n);D=t.width*r*Math.sign(D),ee=t.height*r*Math.sign(ee)}}return{nextWidth:D,nextHeight:ee}},DE=(e,t,n,r,i,a,{shouldMaintainAspectRatio:o=!1,shouldResizeFromCenter:s=!1}={})=>{let c=e.map(e=>t.get(e.id)),l=c.reduce((e,r)=>{if(!rd(r))return e;let i=Sb(r);if(!i)return e;let a=t.get(i)??null;return pd(a)?[...e,{...a,...X.getBoundTextElementPosition(r,a,n)}]:e},[]),u=uv(c.map(e=>e).concat(l)),{minX:d,minY:f,maxX:p,maxY:m,midX:h,midY:g}=u,_=p-d,v=m-f,y={ne:[d,m],se:[d,f],sw:[p,f],nw:[p,m],e:[d,f+v/2],w:[p,f+v/2],n:[d+_/2,m],s:[d+_/2,f]},[b,x]=s?[h,g]:y[r],S=s?2:1,C=Math.max(Math.abs(i-b)/_||0,Math.abs(a-x)/v||0)*S,w=r.includes(`e`)||r.includes(`w`)?Math.abs(i-b)*S:_,T=r.includes(`n`)||r.includes(`s`)?Math.abs(a-x)*S:v;o&&(w=_*C*Math.sign(i-b),T=v*C*Math.sign(a-x));let[E,D]={ne:[i<b,a>x],se:[i<b,a<x],sw:[i>b,a<x],nw:[i>b,a>x],e:[i<b,!1],w:[i>b,!1],n:[!1,a>x],s:[!1,a<x]}[r].map(e=>e);return{originalBoundingBox:u,nextWidth:w,nextHeight:T,flipByX:E,flipByY:D}},OE=(e,t,n,r,i,{shouldMaintainAspectRatio:a=!1,shouldResizeFromCenter:o=!1,flipByX:s=!1,flipByY:c=!1,nextHeight:l,nextWidth:u,originalBoundingBox:d}={})=>{if(u===void 0&&l===void 0&&s===void 0&&c===void 0||l===0||u===0)return;i||=t;let f=e.reduce((e,t)=>{let n=i.get(t.id);return n&&e.push({orig:n,latest:t}),e},[]),p;if(d)p=d;else{let e=f.reduce((e,{orig:n})=>{if(!rd(n))return e;let r=Sb(n);if(!r)return e;let a=i.get(r)??null;return pd(a)?[...e,{...a,...X.getBoundTextElementPosition(n,a,t)}]:e},[]);p=uv(f.map(({orig:e})=>e).concat(e))}let{minX:m,minY:h,maxX:g,maxY:_,midX:v,midY:y}=p,b=g-m,x=_-h;if(u===void 0&&l===void 0&&(u=b,l=x),a&&(u===void 0?u=b/x*l:l===void 0?l=x/b*u:Math.abs(u/l-b/x)>.001&&(u=b/x*l)),u&&l){let e=n.includes(`e`)||n.includes(`w`)?Math.abs(u)/b:1,d=n.includes(`n`)||n.includes(`s`)?Math.abs(l)/x:1,p;p=n.length===1?n.includes(`e`)||n.includes(`w`)?e:d:Math.max(Math.abs(u)/b||0,Math.abs(l)/x||0);let S={ne:[m,_],se:[m,h],sw:[g,h],nw:[g,_],e:[m,h+x/2],w:[g,h+x/2],n:[m+b/2,_],s:[m+b/2,h]},[C,w]=o?[v,y]:S[n],T=a||f.some(e=>e.latest.angle!==0||B(e.latest)||zy(e.latest));T&&(e=p,d=p);let[E,D]=[s?-1:1,c?-1:1],ee=[];for(let{orig:n,latest:r}of f){if(B(n)&&pd(n))continue;let a=n.width*e,o=n.height*d,l=Wc(n.angle*E*D),u=rd(n)||td(n),f=n.x-C,m=n.y-w,h=s&&!u?a:0,g=c&&!u?o:0,_=C+E*(f*e+h),v=w+D*(m*d+g),y=_E(n,a*E,o*D,!1),b={x:_,y:v,width:a,height:o,angle:l,...y};if(H(n)&&(n.startBinding&&(b.startBinding={...n.startBinding,fixedPoint:[s?-n.startBinding.fixedPoint[0]+1:n.startBinding.fixedPoint[0],c?-n.startBinding.fixedPoint[1]+1:n.startBinding.fixedPoint[1]]}),n.endBinding&&(b.endBinding={...n.endBinding,fixedPoint:[s?-n.endBinding.fixedPoint[0]+1:n.endBinding.fixedPoint[0],c?-n.endBinding.fixedPoint[1]+1:n.endBinding.fixedPoint[1]]}),n.fixedSegments&&y.points&&(b.fixedSegments=n.fixedSegments.map(e=>({...e,start:y.points[e.index-1],end:y.points[e.index]})))),Ju(n)&&(b.scale=[n.scale[0]*E,n.scale[1]*D]),B(n)){let e=vE(n,t,a);if(!e)return;b.fontSize=e.size}let x=i.get(Sb(n)??``);if(x){if(T){let e=x.fontSize*p;if(e<Is)return;b.boundTextFontSize=e}else b.boundTextFontSize=x.fontSize}ee.push({element:r,update:b})}let te=ee.map(({element:e})=>e);for(let{element:e,update:{boundTextFontSize:r,...i}}of ee){let{width:a,height:o,angle:s}=i;$(e,i,!1,{isDragging:!0}),Bv(e,t,{simultaneouslyUpdated:te,newSize:{width:a,height:o}});let c=Cb(e,t);c&&r&&($(c,{fontSize:r,angle:rd(e)?void 0:s},!1),bb(e,t,n,!0))}r.triggerUpdate()}},kE=(e,t,n,r,i,a)=>{if(t.length===1&&H(t[0])&&(t[0].startBinding||t[0].endBinding))return;let o=t.filter(e=>{if(H(e)&&e.startBinding&&e.endBinding){let n=t.find(t=>t.id===e.startBinding?.elementId),r=t.find(t=>t.id===e.endBinding?.elementId);return n&&r}return!0}),s=new Set(o),c=o.filter(e=>ed(e)).map(e=>e.id);if(c.length>0)for(let e of r.getNonDeletedElements())e.frameId!==null&&c.includes(e.frameId)&&s.add(e);let l=AE(av(Array.from(s).map(t=>e.originalElements.get(t.id)??t)),n,i,a);s.forEach(t=>{if(jE(e,t,l),!V(t)){let n=Cb(t,r.getNonDeletedElementsMap());n&&jE(e,n,l),Bv(t,r.getElementsMapIncludingDeleted(),{simultaneouslyUpdated:Array.from(s)})}})},AE=(e,t,n,r)=>{let[i,a]=e,o=i+t.x+n.x,s=a+t.y+n.y;if(n.x===0||n.y===0){let[e,c]=ub(i+t.x,a+t.y,r);n.x===0&&(o=e),n.y===0&&(s=c)}return{x:o-i,y:s-a}},jE=(e,t,n)=>{let r=e.originalElements.get(t.id)??t;$(t,{x:r.x+n.x,y:r.y+n.y})},ME=(e,t,n)=>{let[r,i]=av(e);return[t-r,n-i]},NE=({newElement:e,elementType:t,originX:n,originY:r,x:i,y:a,width:o,height:s,shouldMaintainAspectRatio:c,shouldResizeFromCenter:l,zoom:u,widthAspectRatio:d=null,originOffset:f=null,informMutation:p=!0})=>{c&&e.type!==`selection`&&(d?s=o/d:(Math.abs(a-r)>Math.abs(i-n)?{width:o,height:s}=qT(t,s,i<n?-o:o):{width:o,height:s}=qT(t,o,a<r?-s:s),s<0&&(s=-s)));let m=i<n?n-o:n,h=a<r?r-s:r;l&&(o+=o,s+=s,m=n-o/2,h=r-s/2);let g=null;if(B(e)){s=e.height;let t=Sd(Gl({fontSize:e.fontSize,fontFamily:e.fontFamily}),e.lineHeight);o=Math.max(o,t),Math.abs(i-n)>xs/u&&(g={autoResize:!1}),h=r,l&&(m=n-o/2)}if(o!==0&&s!==0){let t=null;Ju(e)&&(t={initialWidth:o,initialHeight:s}),$(e,{x:m+(f?.x??0),y:h+(f?.y??0),width:o,height:s,...g,...t},p)}},PE=(e,t)=>!!(!e.viewModeEnabled&&e.openDialog?.name!==`elementLinkSelector`&&(e.activeTool.type!==`custom`&&(e.editingTextElement||e.activeTool.type!==`selection`&&e.activeTool.type!==`eraser`&&e.activeTool.type!==`hand`&&e.activeTool.type!==`laser`)||NT(t,e).length)),FE=e=>{let t=5381;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)+t+r}return t>>>0},IE=e=>e.filter(e=>!e.isDeleted&&!WT(e)),LE=e=>e.filter(e=>!e.isDeleted),RE=e=>!e.isDeleted,zE=e=>LE(e).map(e=>id(e.type)?{...e,lastCommittedPoint:null}:e),BE=e=>zE(e),VE=e=>zE(e),HE=async e=>{let t;if(e.type===M.png)try{return await(await i(async()=>{let{decodePngMetadata:e}=await import(`./image-GAAHSSAO-BaCj5pGW.js`);return{decodePngMetadata:e}},__vite__mapDeps([5,1,2]))).decodePngMetadata(e)}catch(e){throw e.message===`INVALID`?new oh(`Image doesn't contain scene`,`IMAGE_NOT_CONTAINS_SCENE_DATA`):new oh(`Error: cannot restore image`)}if(t=`text`in Blob?await e.text():await new Promise(t=>{let n=new FileReader;n.readAsText(e,`utf8`),n.onloadend=()=>{n.readyState===FileReader.DONE&&t(n.result)}}),e.type===M.svg)try{return oC({svg:t})}catch(e){throw e.message===`INVALID`?new oh(`Image doesn't contain scene`,`IMAGE_NOT_CONTAINS_SCENE_DATA`):new oh(`Error: cannot restore image`)}return t},UE=e=>e&&e.name.match(/\.(json|excalidraw|png|svg)$/)?.[1]||null,WE=e=>e===`png`||e===`svg`,GE=e=>{let t=UE(e);return t===`png`||t===`svg`},KE=e=>!!e&&Object.values(Gs).includes(e),qE=e=>{let{type:t}=e||{};return KE(t)},JE=async(e,t,n,r)=>{let i=await HE(e),a;try{try{a=JSON.parse(i)}catch(t){throw qE(e)?new oh(`Image doesn't contain scene`,`IMAGE_NOT_CONTAINS_SCENE_DATA`):t}if(SS(a))return{type:M.excalidraw,data:QC({elements:VE(a.elements||[]),appState:{theme:t?.theme,fileHandle:r||e.handle||null,...Fc(a.appState||{}),...t?yy(a.elements||[],t):{}},files:a.files},t,n,{repairBindings:!0,refreshDimensions:!1})};if(CS(a))return{type:M.excalidrawlib,data:a};throw Error(`Error: invalid file`)}catch(e){throw e instanceof oh?e:Error(`Error: invalid file`)}},YE=async(e,t,n,r)=>{let i=await JE(e,t,n,r);if(i.type!==M.excalidraw)throw Error(`Error: invalid file`);return i.data},XE=(e,t=`unpublished`)=>{let n=JSON.parse(e);if(!CS(n))throw Error(`Invalid library`);return ew(n.libraryItems||n.library,t)},ZE=async(e,t=`unpublished`)=>XE(await HE(e),t),QE=async e=>new Promise(async(t,n)=>{try{Du(e)&&(e=await e),e.toBlob(e=>{if(!e)return n(new ih(`Error: Canvas too big`,`CANVAS_POSSIBLY_TOO_BIG`));t(e)})}catch(e){n(e)}}),$E=async e=>{try{let t=await window.crypto.subtle.digest(`SHA-1`,await fD(e));return hu(new Uint8Array(t))}catch(e){return console.error(e),Mi(40)}},eD=async e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;t(e)},r.onerror=e=>n(e),r.readAsDataURL(e)}),tD=(e,t)=>`data:${t};base64,${gD(pD(e),!0)}`,nD=(e,t=``)=>{let n=e.indexOf(`,`),r=atob(e.slice(n+1)),i=e.slice(0,n).split(`:`)[1].split(`;`)[0],a=new ArrayBuffer(r.length),o=new Uint8Array(a);for(let e=0;e<r.length;e++)o[e]=r.charCodeAt(e);return new File([a],t,{type:i})},rD=e=>_D(e.slice(e.indexOf(`,`)+1)),iD=async(t,n)=>{if(t.type===M.svg)return t;let[r,a]=await Promise.all([i(()=>import(`./pica-XznpCgP2.js`).then(t=>e(t.default,1)).then(e=>e.default),__vite__mapDeps([6,2])),i(()=>import(`./image-blob-reduce.esm-Dj7YBvMv.js`).then(e=>e.default),[])]),o=a({pica:r({features:[`js`,`wasm`]})});if(n.outputType){let{outputType:e}=n;o._create_blob=function(t){return this.pica.toBlob(t.out_canvas,e,.8).then(e=>(t.out_blob=e,t))}}if(!qE(t))throw Error(`Error: unsupported file type`,{cause:`UNSUPPORTED`});return new File([await o.toBlob(t,{max:n.maxWidthOrHeight,alpha:!0})],t.name,{type:n.outputType||t.type})},aD=(e,t=``)=>new File([new TextEncoder().encode(e)],t,{type:M.svg}),oD=async(e,t=``)=>{let n;try{n=await fetch(e)}catch{throw Error(`Error: failed to fetch image`,{cause:`FETCH_ERROR`})}if(!n.ok)throw Error(`Error: failed to fetch image`,{cause:`FETCH_ERROR`});let r=await n.blob();if(r.type&&qE(r)){let e=t||r.name||``;return new File([r],e,{type:r.type})}throw Error(`Error: unsupported file type`,{cause:`UNSUPPORTED`})},sD=async e=>{let t=e.dataTransfer.files.item(0),n=await cD(e);return{file:t?await dD(t):null,fileHandle:n}},cD=async e=>{if(Yo)try{return await e.dataTransfer.items[0].getAsFileSystemHandle()||null}catch(e){return console.warn(e.name,e.message),null}return null},lD=e=>{let t=null,n=`${[...new Uint8Array(e).slice(0,8)].join(` `)} `,r={png:`137 80 78 71 13 10 26 10 `,jpg:`255 216 255 `,gif:`71 73 70 56 57 97 `};return n===r.png?t=M.png:n.startsWith(r.jpg)?t=M.jpg:n.startsWith(r.gif)&&(t=M.gif),t},uD=(e,t,n)=>new File([e],n||``,{type:t}),dD=async e=>{if(e.type){if(qE(e)){let t=await fD(e),n=lD(t);n&&n!==e.type&&(e=uD(t,n,e.name))}}else if(e?.name?.endsWith(`.excalidrawlib`))e=uD(await fD(e),M.excalidrawlib,e.name);else if(e?.name?.endsWith(`.excalidraw`))e=uD(await fD(e),M.excalidraw,e.name);else{let t=await fD(e),n=lD(t);n&&(e=uD(t,n,e.name))}return e},fD=e=>`arrayBuffer`in e?e.arrayBuffer():new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{if(!e.target?.result)return n(Error(`Couldn't convert blob to ArrayBuffer`));t(e.target.result)},r.readAsArrayBuffer(e)}),pD=e=>{let t=typeof e==`string`?new TextEncoder().encode(e):e instanceof Uint8Array?e:new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return n},mD=e=>{let t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0,r=e.length;t<r;t++)n[t]=e.charCodeAt(t);return t},hD=e=>new TextDecoder(`utf-8`).decode(mD(e)),gD=(e,t=!1)=>t?window.btoa(e):window.btoa(pD(e)),_D=(e,t=!1)=>t?window.atob(e):hD(window.atob(e)),vD=({text:e,compress:t})=>{let n;if(t!==!1)try{n=pD(ki(e))}catch(e){console.error(`encode: cannot deflate`,e)}return{version:`1`,encoding:`bstring`,compressed:!!n,encoded:n||pD(e)}},yD=e=>{let t;switch(e.encoding){case`bstring`:t=e.compressed?e.encoded:hD(e.encoded);break;default:throw Error(`decode: unknown encoding "${e.encoding}"`)}return e.compressed?Ai(new Uint8Array(mD(t)),{to:`string`}):t},bD=async e=>{let t=(0,h.default)(new Uint8Array(await fD(e))).find(e=>e.name===`tEXt`);return t?g.decode(t.data):null},xD=async({blob:e,metadata:t})=>{let n=(0,h.default)(new Uint8Array(await fD(e))),r=g.encode(M.excalidraw,JSON.stringify(vD({text:t,compress:!0})));return n.splice(-1,0,r),new Blob([(0,_.default)(n)],{type:M.png})},SD=async e=>{let t=await bD(e);if(t?.keyword===M.excalidraw)try{let e=JSON.parse(t.text);if(!(`encoded`in e)){if(`type`in e&&e.type===Js.excalidraw)return t.text;throw Error(`FAILED`)}return yD(e)}catch(e){throw console.error(e),Error(`FAILED`)}throw Error(`INVALID`)};export{tu as $,vc as $a,oc as $c,bD as $i,HT as $l,JC as $n,Sc as $o,Gy as $r,lc as $s,js as $t,Jc as A,NE as Aa,Cb as Ac,Pm as Ai,dD as Al,Eg as An,Bx as Ao,Fs as Ar,wd as As,US as At,YE as Au,Ys as B,Vf as Ba,lu as Bc,Bm as Bi,fp as Bl,Qc as Bn,DS as Bo,Au as Br,Gp as Bs,FT as Bt,no as Bu,Tm as C,hx as Ca,Rc as Cc,em as Ci,nu as Cl,_d as Cn,vs as Co,mx as Cr,Fw as Cs,Dp as Ct,vy as Cu,rD as D,Tx as Da,C_ as Dc,eh as Di,Tg as Dl,Sd as Dn,op as Do,OE as Dr,ps as Ds,zf as Dt,Gc as Du,FS as E,Dd as Ea,LS as Ec,sf as Ei,np as El,g_ as En,Zl as Eo,Hf as Er,SD as Es,Ls as Et,Gs as Eu,Bf as F,Op as Fa,Oy as Fc,Rs as Fi,eT as Fl,AS as Fn,ls as Fo,Lf as Fr,Fg as Fs,Zf as Ft,w_ as Fu,Vl as G,rd as Ga,xg as Gc,mT as Gi,uf as Gl,vm as Gn,OT as Go,PT as Gr,px as Gs,Gf as Gt,rc as H,hs as Ha,ay as Hc,Bc as Hi,ou as Hl,rE as Hn,_S as Ho,xb as Hr,B as Hs,Mp as Ht,Mi as Hu,J as I,bb as Ia,cm as Ic,ub as Ii,xw as Il,Ay as In,Wl as Io,q as Ir,Jm as Is,M as It,Up as Iu,Tw as J,WT as Ja,ax as Jc,Ec as Ji,a_ as Jl,Ey as Jn,oE as Jo,kf as Jr,Tc as Js,Us as Jt,Xs as K,Ul as Ka,j_ as Kc,Hp as Ki,Sm as Kl,SE as Kn,kb as Ko,x_ as Kr,Ps as Ks,hb as Kt,yg as L,Xu as La,wS as Lc,ex as Li,Jl as Ll,Od as Ln,V as Lo,Hm as Lr,Um as Ls,Am as Lt,RE as Lu,Iv as M,Ov as Ma,HS as Mc,JT as Mi,Wm as Ml,ym as Mn,Ql as Mo,hC as Mr,Hl as Ms,zp as Mt,os as Mu,Yu as N,iD as Na,mc as Nc,Cd as Ni,I as Nl,cb as Nn,Zm as No,Jg as Nr,QC as Ns,CT as Nt,aS as Nu,xv as O,wc as Oa,Gm as Oc,bg as Oi,yS as Ol,Ig as On,jv as Oo,$s as Or,KT as Os,Lm as Ot,Sf as Ou,Pw as P,yy as Pa,qm as Pc,Ip as Pi,ES as Pl,Cw as Pn,Kp as Po,ad as Pr,NS as Ps,vx as Pt,xx as Pu,xp as Q,um as Qa,Lp as Qc,Im as Qi,Cp as Ql,Hc as Qn,Gv as Qo,ZE as Qr,bc as Qs,jT as Qt,Nm as R,xD as Ra,jb as Rc,Jf as Ri,$c as Rl,Iu as Rn,tp as Ro,ss as Rr,cs as Rs,JE as Rt,Dc as Ru,Uf as S,Cx as Sa,id as Sc,Hg as Si,ds as Sl,Sy as Sn,yb as So,kp as Sr,aT as Ss,S_ as St,xS as Su,Dv as T,Vp as Ta,oh as Tc,lp as Ti,_u as Tl,iE as Tn,ed as To,xu as Tr,Zp as Ts,Du as Tt,wu as Tu,hg as U,wy as Ua,nC as Uc,_b as Ui,fs as Ul,Mf as Un,Rh as Uo,gm as Ur,Rm as Us,qE as Ut,ji as Uu,ah as V,tm as Va,dp as Vc,as as Vi,kT as Vl,ew as Vn,Bg as Vo,$f as Vr,ep as Vs,Kb as Vt,Ni as Vu,bm as W,Nv as Wa,lf as Wc,gx as Wi,iC as Wl,zb as Wn,sm as Wo,eb as Wr,Sw as Ws,__ as Wt,s as Wu,Md as X,Ym as Xa,Mb as Xc,Qf as Xi,k_ as Xl,yp as Xn,cu as Xo,TE as Xr,GT as Xs,DT as Xt,WE as Y,NT as Ya,zS as Yc,uu as Yi,QE as Yl,Pu as Yn,dv as Yo,xm as Yr,Ih as Ys,Xy as Yt,Lu as Z,Ry as Za,wb as Zc,H as Zi,zu as Zl,Cg as Zn,up as Zo,jw as Zr,UT as Zs,TS as Zt,Ap as _,qf as _a,Cs as _c,Af as _i,ap as _l,UE as _n,ZS as _o,ic as _r,Qu as _s,ec as _t,sd as _u,wp as a,_T as aa,Lg as ac,Rb as ai,zw as al,XE as an,mp as ao,tD as ar,fT as as,VS as at,MT as au,Pb as b,zm as ba,Jp as bc,Ob as bi,qp as bl,IS as bn,Xv as bo,by as br,Ix as bs,nD as bt,Hs as bu,If as c,$ as ca,cp as cc,cC as ci,N as cl,Iy as cn,YT as co,Ep as cr,vu as cs,dT as ct,Of as cu,ac as d,Cc as da,ws as dc,Cy as di,Km as dl,Np as dn,Tb as do,Cf as dr,mf as ds,hp as dt,Bs as du,ox as ea,am as ec,Ru as ei,mb as el,Tu as en,PS as eo,jf as er,cf as es,aE as et,Ff as eu,ey as f,uS as fa,oT as fc,xd as fi,nm as fl,b_ as fn,ys as fo,Rf as fr,Xc as fs,ET as ft,hT as fu,gd as g,Sb as ga,Hu as gc,Nb as gi,Xl as gl,km as gn,cT as go,PE as gr,bS as gs,ld as gt,V_ as gu,Nu as h,Pp as ha,Wy as hc,VT as hi,P as hl,Kf as hn,sp as ho,Dm as hr,yT as hs,wm as ht,sg as hu,Ku as i,uc as ia,My as ic,R as ii,_E as il,jm as in,mu as io,h_ as ir,Os as is,dm as it,Qy as iu,iT as j,tc as ja,Bl as jc,ix as ji,Vu as jl,Bb as jn,lT as jo,Tp as jr,cl as js,fx as jt,Vm as ju,Fb as k,Em as ka,Xp as kc,oS as ki,OS as kl,Wf as kn,Ib as ko,eD as kr,wg as ks,sx as kt,X as ku,lg as l,vg as la,$m as lc,ob as li,zl as ll,qb as ln,ff as lo,Ph as lr,gp as ls,Fu as lt,pm as lu,wf as m,Ju as ma,pp as mc,zc as mi,Ty as ml,Bv as mn,eu as mo,Hx as mr,Vs as ms,pf as mt,_p as mu,$E as n,vb as na,Db as nc,Mu as ni,Yf as nl,Qs as nn,sT as no,od as nr,uE as ns,Nf as nt,hm as nu,Kl as o,rx as oa,$p as oc,_m as oi,ud as ol,xc as on,fd as oo,uv as or,Sg as os,lE as ot,Eu as ou,oD as p,Xb as pa,pu as pc,ju as pi,gs as pl,Zs as pn,ky as po,F as pr,pE as ps,LE as pt,bu as pu,lb as q,jy as qa,Fm as qc,Yh as qi,Nw as ql,sb as qn,Fy as qo,Ou as qr,Bp as qs,mm as qt,av as r,Rp as ra,bs as rc,Pf as ri,Yp as rl,Df as rn,cg as ro,kE as rr,Lb as rs,zy as rt,qs as ru,$l as s,Xf as sa,ru as sc,xE as si,Kc as sl,lS as sn,TT as so,pd as sr,Bu as ss,Es as st,Ng as su,Zb as t,BS as ta,gT as tc,Sp as ti,lx as tl,vp as tn,Ts as to,Cm as tr,fm as ts,tx as tt,gb as tu,Om as u,Mm as ua,lm as uc,v_ as ui,RS as ul,nl as un,im as uo,Dw as ur,Zu as us,Gl as ut,XS as uu,m_ as v,j as va,Mc as vc,om as vi,Ky as vl,gc as vn,uT as vo,kv as vr,rf as vs,vv as vt,hf as vu,ME as w,Js as wa,Rl as wc,su as wi,Lc as wl,jp as wn,Dy as wo,md as wr,yd as ws,o_ as wt,$u as wu,qu as x,Sx as xa,Rw as xc,Py as xi,Lw as xl,sD as xn,rm as xo,dd as xr,ug as xs,yv as xt,bT as xu,Ex as y,gS as ya,df as yc,vT as yi,Xm as yl,ny as yn,Qm as yo,aD as yr,Su as ys,y_ as yt,hE as yu,Fp as z,_s as za,ql as zc,GE as zi,fu as zl,bp as zn,Xd as zo,Wp as zr,Ds as zs,yc as zt,Yo as zu};
|
|
41
|
+
`).trim()}:n:{type:`text`,value:(e.clipboardData?.getData(M.text)||``).trim()}}catch{return{type:`text`,value:``}}},Nw=async(e,t=!1)=>{let n=await Mw(e,t);if(n.type===`mixedContent`)return{mixedContent:n.value};try{let e=!t&&Ow(n.value);if(e)return e}catch(e){console.error(e)}try{let e=JSON.parse(n.value),r=e.type===Js.excalidrawClipboardWithAPI;if(ww(e))return{elements:e.elements,files:e.files,text:t?JSON.stringify(e.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:n.value}},Pw=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[M.png]:e})])}catch(t){if(Du(e))await navigator.clipboard.write([new window.ClipboardItem({[M.png]:await e})]);else throw t}},Fw=async(e,t)=>{if(Sw)try{await navigator.clipboard.writeText(e||``);return}catch(e){console.error(e)}try{if(t){if(t.clipboardData?.setData(M.text,e||``),t.clipboardData?.getData(M.text)!==e)throw Error(`Failed to setData on clipboardEvent`);return}}catch(e){console.error(e)}if(!Iw(e))throw Error(`Error copying to clipboard.`)},Iw=e=>{e||=` `;let t=document.documentElement.getAttribute(`dir`)===`rtl`,n=document.createElement(`textarea`);n.style.border=`0`,n.style.padding=`0`,n.style.margin=`0`,n.style.position=`absolute`,n.style[t?`right`:`left`]=`-9999px`;let r=window.pageYOffset||document.documentElement.scrollTop;n.style.top=`${r}px`,n.style.fontSize=`12pt`,n.setAttribute(`readonly`,``),n.value=e,document.body.appendChild(n);let i=!1;try{n.select(),n.setSelectionRange(0,n.value.length),i=document.execCommand(`copy`)}catch(e){console.error(e)}return n.remove(),i},Lw=({elements:e,appState:t,files:n,maxWidthOrHeight:r,getDimensions:i,exportPadding:a,exportingFrame:o})=>{let{elements:s,appState:c}=QC({elements:e,appState:t},null,null),{exportBackground:l,viewBackgroundColor:u}=c;return nC(s,{...c,offsetTop:0,offsetLeft:0,width:0,height:0},n||{},{exportBackground:l,exportPadding:a,viewBackgroundColor:u,exportingFrame:o},(e,n)=>{let a=document.createElement(`canvas`);if(r){typeof i==`function`&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let o=Math.max(e,n),s=r<o?r/o:t?.exportScale??1;return a.width=e*s,a.height=n*s,{canvas:a,scale:s}}let o=i?.(e,n)||{width:e,height:n};return a.width=o.width,a.height=o.height,{canvas:a,scale:o.scale??1}})},Rw=async e=>{let{mimeType:t=M.png,quality:n}=e;t===M.png&&typeof n==`number`&&console.warn(`"quality" will be ignored for "${M.png}" mimeType`),t===`image/jpg`&&(t=M.jpg),t===M.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${M.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await Lw(e);return n||=/image\/jpe?g/.test(t)?.92:.8,new Promise((i,a)=>{r.toBlob(async n=>{if(!n)return a(Error(`couldn't export to blob`));n&&t===M.png&&e.appState?.exportEmbedScene&&(n=await xD({blob:n,metadata:yS(e.elements,e.appState,e.files||{},`local`)})),i(n)},t,n)})},zw=async({elements:e,appState:t=Mc(),files:n={},exportPadding:r,renderEmbeddables:i,exportingFrame:a,skipInliningFonts:o,reuseImages:s})=>{let{elements:c,appState:l}=QC({elements:e,appState:t},null,null);return iC(c,{...l,exportPadding:r},n,{exportingFrame:a,renderEmbeddables:i,skipInliningFonts:o,reuseImages:s})},Bw=e=>e.type===`diamond`?[I(e.width/2,0),I(e.width,e.height/2),I(e.width/2,e.height),I(0,e.height/2)]:[I(0,0),I(0+e.width,0),I(0+e.width,e.height),I(0,e.height)],Vw=e=>rd(e)||td(e)?e.points:Bw(e),Hw=e=>{let t=e.reduce((e,[t,n])=>(e.minY=Math.min(e.minY,n),e.minX=Math.min(e.minX,t),e.maxX=Math.max(e.maxX,t),e.maxY=Math.max(e.maxY,n),e),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},Uw=e=>{let t=Vw(e),{cx:n,cy:r}=Hw(t),i=I(n,r),{minX:a,minY:o,maxX:s,maxY:c}=Hw(t.map(t=>R(t,i,e.angle)));return[a+e.x,o+e.y,s+e.x,c+e.y]},Ww=(e,t,n=!1)=>{let r=Uw(e),i=t[0]<=r[0]&&t[2]>=r[2]&&t[1]<=r[1]&&t[3]>=r[3];return n?i?!0:r[0]<=t[0]&&r[2]>=t[2]&&r[1]<=t[1]&&r[3]>=t[3]:i},Gw=(e,t)=>{let n=Uw(e);return(Il(n[0],Nl(t[0],t[2]))||Il(t[0],Nl(n[0],n[2])))&&(Il(n[1],Nl(t[1],t[3]))||Il(t[1],Nl(n[1],n[3])))},Kw=({elements:e,bounds:t,type:n,errorMargin:r=0})=>{ud(t)&&(t=iv(t,_u(e)));let i=[t[0]-r,t[1]-r,t[2]+r,t[3]+r],a=new Set;for(let t of e)if(!a.has(t.id)&&(n===`overlap`?Gw(t,i):n===`inside`?Ww(t,i):Ww(t,i,!0))){if(a.add(t.id),t.boundElements)for(let e of t.boundElements)a.add(e.id);B(t)&&t.containerId&&a.add(t.containerId),V(t)&&(t.startBinding&&a.add(t.startBinding.elementId),t.endBinding&&a.add(t.endBinding?.elementId))}return e.filter(e=>a.has(e.id))};function qw(e){return[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])]}function Jw(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}var Yw=1e-6;function Xw(e,t){let n=Yc(F(e[1],e[0]),F(t,e[0]));return Math.abs(n)<Yw}function Zw(e,t){return Yc(F(e[1],e[0]),F(t,e[0]))<0}function Qw(e,t){return Xw(e,t[0])||Xw(e,t[1])||(Zw(e,t[0])?!Zw(e,t[1]):Zw(e,t[1]))}function $w(e,t){return Jw(qw(e),qw(t))&&Qw(e,t)&&Qw(t,e)}var eT=(e,t,n)=>{let r=_u(e);for(let e of t)if(e.frameId){let t=n.get(e.id),i=n.get(e.frameId);if(t){let n=r.get(t);n&&$(n,{frameId:i??e.frameId},!1)}}};function tT(e,t,n){let r=G_(t,n),i=G_(e,n);return r.some(e=>i.some(t=>$w(e,t)))}var nT=(e,t,n)=>xT(kT(e,t,n,!1)).filter(e=>!ed(e)&&!e.frameId||e.frameId===t.id),rT=(e,t,n)=>kT([t],e,n).some(e=>e.id===t.id),iT=(e,t,n)=>{let[r,i,a,o]=J(t,n),[s,c,l,u]=av(e);return r<=s&&i<=c&&a>=l&&o>=u},aT=(e,t,n)=>iT([e],t,n)||tT(e,t,n)||rT(e,t,n),oT=(e,t,n)=>{let[r,i,a,o]=J(t,n);return dl(I(r,i),I(e.x,e.y),I(a,o))},sT=e=>{let t=new Map;for(let n of e){let r=ed(n)?n.id:n.frameId;r&&!t.has(r)&&t.set(r,cT(e,r))}return t},cT=(e,t)=>{let n=[];for(let r of e.values())r.frameId===t&&n.push(r);return n},lT=e=>e.filter(e=>ed(e)),uT=e=>{let t=_u(lT(e));return e.filter(e=>t.has(e.id)||!e.frameId||!t.has(e.frameId))},dT=(e,t,n,r)=>{let i=cT(e,t.id),a=new Set(i),o=new Set([...nT(e,t,r),...i.filter(e=>rT(e,t,r))]),s=i.filter(e=>!o.has(e)),c=new Set(Array.from(o).flatMap(e=>e.groupIds));for(let e of s)if(!tT(e,t,r))e.groupIds.length===0&&a.delete(e);else if(e.groupIds.length>0)for(let t of e.groupIds)c.add(t);for(let e of s)if(e.groupIds.length>0){let t=!0;for(let n of e.groupIds)c.has(n)&&(t=!1);t&&a.delete(e)}let l=Array.from(o).filter(e=>e.groupIds.length===0);for(let e of l)a.add(e);let u=Oy(Array.from(o).filter(e=>e.groupIds.length>0),n);for(let[n,i]of Object.entries(u))if(i){let i=jy(e,n);if(iT(i,t,r))for(let e of i)a.add(e)}return[...a].filter(e=>!(B(e)&&e.containerId))},fT=(e,t,n)=>pT(xT(e,nT(e,t,n)),t,n),pT=(e,t,n)=>{let r=[],i=new Map;for(let a of e){let e=!1;if(a.groupIds.length>0){if(a.groupIds.some(e=>i.get(e)))e=!0;else{let r=new Set(a.groupIds.flatMap(e=>jy(n,e)));e=!iT(Array.from(r),t,n)}a.groupIds.forEach(t=>{i.set(t,e)})}e||r.push(a)}return r},mT=(e,t)=>e.frameId&&t.get(e.frameId)||null,hT=(e,t)=>{let n=new Set,r=_u(e);e=xT(e);for(let r of e)ed(r)&&r.id!==t.id&&n.add(r.id);let i=new Set,a=[];for(let o of e)if(!(ed(o)||o.frameId&&n.has(o.frameId))){if(o.groupIds.length){let n=o.groupIds.at(-1);if(!i.has(n)){i.add(n);let o=jy(e,n);if(o.some(e=>aT(e,t,r)))for(let e of o)a.push(e)}}else aT(o,t,r)&&a.push(o)}return a},gT=(e,t,n,r)=>{let i=_u(e),a=new Map;for(let t of e.values())t.frameId===n.id&&a.set(t.id,!0);let o=new Set(t.map(e=>e.id)),s=[],c=new Set;for(let e of t)ed(e)&&e.id!==n.id&&c.add(e.id);for(let n of xT(e,t)){if(ed(n)||n.frameId&&c.has(n.frameId)||n.frameId&&r.selectedElementIds[n.id]&&r.selectedElementIds[n.frameId])continue;a.has(n.id)||s.push(n);let e=Cb(n,i);e&&!o.has(e.id)&&!a.has(e.id)&&s.push(e)}for(let e of s)$(e,{frameId:n.id},!1);return e},_T=(e,t)=>{let n=new Map,r=new Map;for(let i of e)if(i.frameId){n.set(i.id,i);let e=r.get(i.frameId)||[];e.push(i);let a=Cb(i,t);a&&(n.set(a.id,a),e.push(a)),r.set(i.frameId,e)}for(let[,e]of n)$(e,{frameId:null},!1)},vT=(e,t)=>(_T(cT(e,t.id),_u(e)),e),yT=(e,t,n,r)=>gT(vT(e,n),t,n,r.state).slice(),bT=(e,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),i=new Set(r);if(t.editingGroupId)for(let t of r)t.groupIds.length===0?i.add(t):t.groupIds.flatMap(t=>jy(e,t)).forEach(e=>i.add(e));let a=new Set,o=_u(e);return i.forEach(e=>{e.frameId&&!ed(e)&&!CT(e,o,t)&&a.add(e)}),a.size>0&&_T(a,o),e},xT=(e,t)=>{let n=new Set,r=t||e;for(let e of r.values()){let t=e.groupIds[e.groupIds.length-1];t&&n.add(t)}let i=new Set;for(let t of n)jy(e,t).some(e=>ed(e))&&i.add(t);let a=[];for(let e of r.values())i.has(e.groupIds[e.groupIds.length-1])||a.push(e);return a},ST=(e,t,n)=>{let r=B(e)&&wb(e,t)||e;return r.frameId&&n.selectedElementIds[r.id]&&n.selectedElementIds[r.frameId]?mT(r,t):n.selectedElementIds[r.id]&&n.selectedElementsAreBeingDragged?n.frameToHighlight:mT(r,t)},CT=(e,t,n,r)=>{let i=r?.targetFrame??ST(e,t,n);if(!i)return!1;let a=B(e)&&wb(e,t)||e,o=e=>{r?.checkedGroups&&a.groupIds.forEach(t=>{r.checkedGroups?.set(t,e)})};if(!n.selectedElementIds[a.id]||!n.selectedElementsAreBeingDragged||n.selectedElementIds[a.id]&&n.selectedElementIds[i.id])return!0;if(a.groupIds.length===0)return aT(a,i,t);for(let e of a.groupIds)if(r?.checkedGroups?.has(e))return r.checkedGroups.get(e);let s=new Set(a.groupIds.filter(e=>!r?.checkedGroups||!r.checkedGroups.has(e)).flatMap(e=>jy(t,e)));if(n.editingGroupId&&n.selectedElementsAreBeingDragged){let e=new Set(NT(t,n));if(n.frameToHighlight!==null)return!0;e.forEach(e=>{s.delete(e)})}for(let e of s)if(ed(e))return o(!1),!1;for(let e of s)if(aT(e,i,t))return o(!0),!0;return!1},wT=(e,t,n,r,i)=>{if(!n.frameRendering||!n.frameRendering.clip)return!1;let a=tT(e,t,r)||rT(e,t,r);if(a){for(let t of e.groupIds)i?.set(t,!0);return!0}if(!a&&e.groupIds.length>0&&!iT([e],t,r)){let a=!1;if(n.selectedElementsAreBeingDragged)a=CT(e,r,n,{targetFrame:t,checkedGroups:i});else{a=e.frameId===t.id;for(let t of e.groupIds)i?.set(t,a)}for(let t of e.groupIds)i?.set(t,a);return a}return!1},TT=e=>e.name===null?Qu(e)?`Frame`:`AI Frame`:e.name,ET=(e,t)=>Kw({elements:e,bounds:t,type:`overlap`}).filter(e=>!e.frameId||e.frameId===t.id),DT=e=>{let t=_u(e);return e.length>1&&e.some(e=>e.frameId&&t.has(e.frameId))},OT=e=>{let t=new Set;return e.forEach(e=>{ed(e)&&t.add(e.id)}),e.filter(e=>!(e.frameId&&t.has(e.frameId)))},kT=(e,t,n,r=!0)=>{let[i,a,o,s]=J(t,n),c=e.filter(e=>{let[t,r,c,l]=iv(e,n),u=mT(e,n);if(u){let[e,i,a,o]=iv(u,n);t=Math.max(e,t),r=Math.max(i,r),c=Math.min(a,c),l=Math.min(o,l)}return e.locked===!1&&e.type!==`selection`&&!pd(e)&&i<=t&&a<=r&&o>=c&&s>=l});return c=r?OT(c):c,c=c.filter(e=>{let t=mT(e,n);return!t||aT(e,t,n)}),c},AT=(e,t,n,r)=>{let i=new Set(t.map(e=>e.id));return e.filter(e=>{let t=GT(e,n.width,n.height,n,r);return!i.has(e.id)&&t})},jT=function(){let e=null,t=null,n=null,r=(r,i)=>(n!=null&&r===e&&i.selectedElementIds===t||(n=r.some(e=>i.selectedElementIds[e.id]),e=r,t=i.selectedElementIds),n);return r.clearCache=()=>{e=null,t=null,n=null},r}(),MT=(e,t,n)=>{let r=Array.from(new Set(NT(e,t).map(e=>n(e))));return r.length===1?r[0]:null},NT=(e,t,n)=>{let r=new Set,i=[];for(let a of e.values()){if(t.selectedElementIds[a.id]){i.push(a),r.add(a.id);continue}if(n?.includeBoundTextElement&&pd(a)&&t.selectedElementIds[a?.containerId]){i.push(a),r.add(a.id);continue}}if(n?.includeElementsInFrames){let t=[];return i.forEach(n=>{ed(n)&&cT(e,n.id).forEach(e=>!r.has(e.id)&&t.push(e)),t.push(n)}),t}return i},PT=(e,t)=>t.editingTextElement?[t.editingTextElement]:t.newElement?[t.newElement]:NT(e,t,{includeBoundTextElement:!0}),FT=(e,t)=>Au(t.selectedElementIds,e)?t.selectedElementIds:e,IT=e=>{let t=new Map,n=[];for(let r of e)r.isDeleted||(n.push(r),t.set(r.id,r));return{elementsMap:t,elements:n}},LT=(0,Fi.default)(e=>{(s.DEV||s.MODE===Ds.TEST||window?.DEBUG_FRACTIONAL_INDICES)&&Cx(e,{shouldThrow:s.DEV||s.MODE===Ds.TEST,includeBoundTextValidation:!0})},6e4,{leading:!0,trailing:!1}),RT=e=>{let t=[`includeBoundTextElement`,`includeElementsInFrames`],n=``;for(let r of t)n+=`${r}:${e[r]?`1`:`0`}`;return n},zT=e=>typeof e==`string`,BT=class e{constructor(){o(this,`callbacks`,new Set),o(this,`nonDeletedElements`,[]),o(this,`nonDeletedElementsMap`,Vu(new Map)),o(this,`elements`,[]),o(this,`nonDeletedFramesLikes`,[]),o(this,`frames`,[]),o(this,`elementsMap`,Vu(new Map)),o(this,`selectedElementsCache`,{selectedElementIds:null,elements:null,cache:new Map}),o(this,`sceneNonce`),o(this,`insertElement`,e=>{let t=e.frameId?this.getElementIndex(e.frameId):this.elements.length;this.insertElementAtIndex(e,t)}),o(this,`insertElements`,e=>{if(!e.length)return;let t=e[0]?.frameId?this.getElementIndex(e[0].frameId):this.elements.length;this.insertElementsAtIndex(e,t)}),o(this,`getContainerElement`,e=>e&&e.containerId&&this.getElement(e.containerId)||null),o(this,`getElementsFromId`,e=>{let t=this.getNonDeletedElementsMap(),n=t.get(e);return n?[n]:jy(t,e)})}static mapElementToScene(e,t){zT(e)?this.sceneMapById.set(e,t):(this.sceneMapByElement.set(e,t),this.sceneMapById.set(e.id,t))}static getScene(e){return zT(e)?this.sceneMapById.get(e)||null:this.sceneMapByElement.get(e)||null}getSceneNonce(){return this.sceneNonce}getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}getSelectedElements(e){let t=RT(e),n=e?.elements||this.nonDeletedElements;if(this.selectedElementsCache.elements===n&&this.selectedElementsCache.selectedElementIds===e.selectedElementIds){let e=this.selectedElementsCache.cache.get(t);if(e)return e}else e?.elements??this.selectedElementsCache.cache.clear();let r=NT(n,{selectedElementIds:e.selectedElementIds},e);return e?.elements??(this.selectedElementsCache.selectedElementIds=e.selectedElementIds,this.selectedElementsCache.elements=this.nonDeletedElements,this.selectedElementsCache.cache.set(t,r)),r}getNonDeletedFramesLikes(){return this.nonDeletedFramesLikes}getElement(e){return this.elementsMap.get(e)||null}getNonDeletedElement(e){let t=this.getElement(e);return t&&RE(t)?t:null}mapElements(e){let t=!1,n=this.elements.map(n=>{let r=e(n);return r!==n&&(t=!0),r});return t&&this.replaceAllElements(n),t}replaceAllElements(t){let n=t instanceof Array?t:Array.from(t.values()),r=[];LT(n),this.elements=Ex(n),this.elementsMap.clear(),this.elements.forEach(t=>{ed(t)&&r.push(t),this.elementsMap.set(t.id,t),e.mapElementToScene(t,this)});let i=IT(this.elements);this.nonDeletedElements=i.elements,this.nonDeletedElementsMap=i.elementsMap,this.frames=r,this.nonDeletedFramesLikes=IT(this.frames).elements,this.triggerUpdate()}triggerUpdate(){this.sceneNonce=ex();for(let e of Array.from(this.callbacks))e()}onUpdate(e){if(this.callbacks.has(e))throw Error();return this.callbacks.add(e),()=>{if(!this.callbacks.has(e))throw Error();this.callbacks.delete(e)}}destroy(){this.elements=[],this.nonDeletedElements=[],this.nonDeletedFramesLikes=[],this.frames=[],this.elementsMap.clear(),this.selectedElementsCache.selectedElementIds=null,this.selectedElementsCache.elements=null,this.selectedElementsCache.cache.clear(),e.sceneMapById.forEach((t,n)=>{t===this&&e.sceneMapById.delete(n)}),this.callbacks.clear()}insertElementAtIndex(e,t){if(!Number.isFinite(t)||t<0)throw Error(`insertElementAtIndex can only be called with index >= 0`);let n=[...this.elements.slice(0,t),e,...this.elements.slice(t)];Tx(n,_u([e])),this.replaceAllElements(n)}insertElementsAtIndex(e,t){if(!e.length)return;if(!Number.isFinite(t)||t<0)throw Error(`insertElementAtIndex can only be called with index >= 0`);let n=[...this.elements.slice(0,t),...e,...this.elements.slice(t)];Tx(n,_u(e)),this.replaceAllElements(n)}getElementIndex(e){return this.elements.findIndex(t=>t.id===e)}};o(BT,`sceneMapByElement`,new WeakMap),o(BT,`sceneMapById`,new Map);var VT=BT,$=(e,t,n=!0,r)=>{let i=!1,{points:a,fixedSegments:o,fileId:s,startBinding:c,endBinding:l}=t;if(H(e)&&(Object.keys(t).length===0||typeof a<`u`||typeof o<`u`||typeof c<`u`||typeof l<`u`)){let n=Vu(VT.getScene(e)?.getNonDeletedElementsMap()??new Map);t={...t,angle:0,...hC({...e,x:t.x||e.x,y:t.y||e.y},n,{fixedSegments:o,points:a,startBinding:c,endBinding:l},{isDragging:r?.isDragging})}}else typeof a<`u`&&(t={...V_(a),...t});for(let n in t){let r=t[n];if(typeof r<`u`){if(e[n]===r&&(typeof r!=`object`||!r||n===`groupIds`||n===`scale`))continue;if(n===`scale`){let t=e[n],i=r;if(t[0]===i[0]&&t[1]===i[1])continue}else if(n===`points`){let t=e[n],i=r;if(t.length===i.length){let e=!1,n=t.length;for(;--n;){let r=t[n],a=i[n];if(r[0]!==a[0]||r[1]!==a[1]){e=!0;break}}if(!e)continue}}e[n]=r,i=!0}}return i&&((typeof t.height<`u`||typeof t.width<`u`||typeof s<`u`||typeof a<`u`)&&rf.delete(e),e.version++,e.versionNonce=ex(),e.updated=gu(),n&&VT.getScene(e)?.triggerUpdate()),e},HT=(e,t,n=!1)=>{let r=!1;for(let n in t){let i=t[n];if(typeof i<`u`){if(e[n]===i&&(typeof i!=`object`||!i))continue;r=!0}}return!r&&!n?e:{...e,...t,updated:gu(),version:e.version+1,versionNonce:ex()}},UT=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=ex(),e.updated=gu(),e),WT=e=>rd(e)||td(e)?e.points.length<2:e.width===0&&e.height===0,GT=(e,t,n,r,i)=>{let[a,o,s,c]=iv(e,i),l=tu({clientX:r.offsetLeft,clientY:r.offsetTop},r),u=tu({clientX:r.offsetLeft+t,clientY:r.offsetTop+n},r);return l.x<=s&&l.y<=c&&u.x>=a&&u.y>=o},KT=(e,t,n,r,i,a)=>{let[o,s,c,l]=av(e,i),u=tu({clientX:r.offsetLeft+(a?.left||0),clientY:r.offsetTop+(a?.top||0)},r),d=tu({clientX:r.offsetLeft+t-(a?.right||0),clientY:r.offsetTop+n-(a?.bottom||0)},r);return o>=u.x&&s>=u.y&&c<=d.x&&l<=d.y},qT=(e,t,n)=>{let r=Math.abs(t),i=Math.abs(n);if(e===`line`||e===`arrow`||e===`freedraw`){let e=Math.round(Math.atan(i/r)/Ss)*Ss;e===0?n=0:e===Math.PI/2?t=0:n=r*Math.tan(e)*Math.sign(n)||n}else e!==`selection`&&(n=r*Math.sign(n));return{width:t,height:n}},JT=(e,t,n,r)=>{let i=n-e,a=r-t,o=Math.round(Math.atan(a/i)/Ss)*Ss;if(o===0)a=0;else if(o===Math.PI/2)i=0;else{let s=Math.tan(o),c=t-s*e,l=-1/s,u=r-l*n,d=(-1*u- -1*c)/(s*-1-l*-1),f=(c*l-u*s)/(s*-1-l*-1);i=d-e,a=f-t}return{width:i,height:a}},YT=e=>{let t={width:e.width,height:e.height,x:e.x,y:e.y};if(e.width<0){let n=Math.abs(e.width);t.width=n,t.x=e.x-n}if(e.height<0){let n=Math.abs(e.height);t.height=n,t.y=e.y-n}return t},XT={mouse:8,pen:16,touch:28},ZT=16,QT={e:!0,s:!0,n:!0,w:!0},$T={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},eE={e:!0,s:!0,n:!0,w:!0},tE=(e,t,n,r,i,a,o)=>{let[s,c]=R(I(e+n/2,t+r/2),I(i,a),o);return[s-n/2,c-r/2,n,r]},nE=e=>!(e.viewport.isMobile||e.isTouchScreen&&(ms||_s)),rE=e=>nE(e)?QT:{},iE=([e,t,n,r,i,a],o,s,c,l={},u=4,d=2)=>{let f=XT[c],p=f/s.value,m=f/s.value,h=f/s.value,g=f/s.value,_=n-e,v=r-t,y=u/s.value,b=(f-d*2)/(2*s.value),x={nw:l.nw?void 0:tE(e-y-h+b,t-y-g+b,p,m,i,a,o),ne:l.ne?void 0:tE(n+y-b,t-y-g+b,p,m,i,a,o),sw:l.sw?void 0:tE(e-y-h+b,r+y-b,p,m,i,a,o),se:l.se?void 0:tE(n+y-b,r+y-b,p,m,i,a,o),rotation:l.rotation?void 0:tE(e+_/2-p/2,t-y-g+b-ZT/s.value,p,m,i,a,o)},S=5*XT.mouse/s.value;return Math.abs(_)>S&&(l.n||(x.n=tE(e+_/2-p/2,t-y-g+b,p,m,i,a,o)),l.s||(x.s=tE(e+_/2-p/2,r+y-b,p,m,i,a,o))),Math.abs(v)>S&&(l.w||(x.w=tE(e-y-h+b,t+v/2-m/2,p,m,i,a,o)),l.e||(x.e=tE(n+y-b,t+v/2-m/2,p,m,i,a,o))),x},aE=(e,t,n,r=`mouse`,i=QT)=>{if(e.locked||H(e))return{};if(e.type===`freedraw`||rd(e)){if(e.points.length===2){let[,t]=e.points;t[0]===0||t[1]===0?i=eE:t[0]>0&&t[1]<0?i=$T:t[0]>0&&t[1]>0?i=eE:t[0]<0&&t[1]>0?i=$T:t[0]<0&&t[1]<0&&(i=eE)}}else ed(e)&&(i={...i,rotation:!0});let a=rd(e)?10:Ju(e)?0:2;return iE(J(e,n,!0),e.angle,t,r,i,a,Ju(e)?0:void 0)},oE=(e,t)=>{if(t.editingLinearElement)return!1;if(e.length>1)return!0;let n=e[0];return H(n)?!1:!rd(n)||n.points.length>2},sE=(e,t,n)=>t>=e[0]&&t<=e[0]+e[2]&&n>=e[1]&&n<=e[1]+e[3],cE=(e,t,n,r,i,a,o,s)=>{if(!n.selectedElementIds[e.id])return!1;let{rotation:c,...l}=aE(e,a,t,o,rE(s));if(c&&sE(c,r,i))return`rotation`;let u=Object.keys(l).filter(e=>{let t=l[e];return t?sE(t,r,i):!1});if(u.length>0)return u[0];if(nE(s)){let[n,o,s,c,l,u]=J(e,t);if(!(rd(e)&&e.points.length<=2)){let t=Ju(e)?0:zs/a.value,d=zs/a.value,f=mE(I(n-t,o-t),I(s+t,c+t),I(l,u),e.angle);for(let[e,t]of Object.entries(f))if(ml(I(r,i),t,d))return e}}return!1},lE=(e,t,n,r,i,a,o,s)=>e.reduce((e,c)=>{if(e)return e;let l=cE(c,o,t,n,r,i,a,s);return l?{element:c,transformHandleType:l}:null},null),uE=([e,t,n,r],i,a,o,s,c)=>{let l=iE([e,t,n,r,(e+n)/2,(t+r)/2],0,o,s,rE(c)),u=Object.keys(l).find(e=>{let t=l[e];return t&&sE(t,i,a)});if(u)return u;if(nE(c)){let s=(e+n)/2,c=(t+r)/2,l=zs/o.value,u=mE(I(e-l,t-l),I(n+l,r+l),I(s,c),0);for(let[e,t]of Object.entries(u))if(ml(I(i,a),t,l))return e}return!1},dE=[`ns`,`nesw`,`ew`,`nwse`],fE=(e,t)=>{let n=dE.indexOf(e);return n>=0&&(e=dE[(n+Math.round(t/(Math.PI/4)))%dE.length]),e},pE=e=>{let{element:t,transformHandleType:n}=e,r=t&&Math.sign(t.height)*Math.sign(t.width)===-1,i=null;switch(n){case`n`:case`s`:i=`ns`;break;case`w`:case`e`:i=`ew`;break;case`nw`:case`se`:i=r?`nesw`:`nwse`;break;case`ne`:case`sw`:i=r?`nwse`:`nesw`;break;case`rotation`:return`grab`}return i&&t&&(i=fE(i,t.angle)),i?`${i}-resize`:``},mE=([e,t],[n,r],i,a)=>{let o=R(I(e,t),i,a),s=R(I(n,t),i,a),c=R(I(e,r),i,a),l=R(I(n,r),i,a);return{n:[o,s],e:[s,l],s:[l,c],w:[c,o]}},hE=(e,t,n,r,i,a,o,s,c,l,u,d)=>{if(n.length===1){let[u]=n;if(t===`rotation`)H(u)||(gE(u,r,i,c,l,a),Bv(u,r));else{if(B(u)&&t)return yE(e,u,r,t,o,c,l),Bv(u,r),!0;if(t){let i=n[0].id,a=r.get(i),u=e.get(i);if(a&&u){let{nextWidth:n,nextHeight:i}=EE(a,u,r,e,t,c,l,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:o});TE(n,i,a,u,r,e,t,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:o})}}}return!0}if(n.length>1){if(t===`rotation`)return bE(e,n,r,i,c,l,a,u,d),!0;if(t){let{nextWidth:a,nextHeight:u,flipByX:d,flipByY:f,originalBoundingBox:p}=DE(n,e,r,t,c,l,{shouldMaintainAspectRatio:s,shouldResizeFromCenter:o});return OE(n,r,t,i,e,{shouldResizeFromCenter:o,shouldMaintainAspectRatio:s,flipByX:d,flipByY:f,nextWidth:a,nextHeight:u,originalBoundingBox:p}),!0}}return!1},gE=(e,t,n,r,i,a)=>{let[o,s,c,l]=J(e,t),u=(o+c)/2,d=(s+l)/2,f;ed(e)?f=0:(f=5*Math.PI/2+Math.atan2(i-d,r-u),a&&(f+=Ss/2,f-=f%Ss),f=Wc(f));let p=Sb(e);if($(e,{angle:f}),p){let t=n.getElement(p);t&&!V(e)&&$(t,{angle:f})}},_E=(e,t,n,r)=>rd(e)||td(e)?{points:H_(0,t,H_(1,n,e.points,r),r)}:{},vE=(e,t,n)=>{let r=e.width;if(pd(e)){let n=wb(e,t);n&&(r=Nb(n,e))}let i=e.fontSize*(n/r);return i<Is?null:{size:i}},yE=(e,t,n,r,i,a,o)=>{let[s,c,l,u,d,f]=J(t,n),[p,m]=R(I(a,o),I(d,f),-t.angle),h=0,g=0;r!==`e`&&r!==`w`&&(r.includes(`e`)&&(h=(p-s)/(l-s)),r.includes(`w`)&&(h=(l-p)/(l-s)),r.includes(`n`)&&(g=(u-m)/(u-c)),r.includes(`s`)&&(g=(m-c)/(u-c)));let _=Math.max(h,g);if(_>0){let e=t.width*_,a=t.height*_,o=vE(t,n,e);if(o===null)return;let p=[s,c],m=[l,u],h=[d,f],g=I(s,c);if([`n`,`w`,`nw`].includes(r)&&(g=I(m[0]-Math.abs(e),m[1]-Math.abs(a))),r===`ne`){let e=[p[0],m[1]];g=I(e[0],e[1]-Math.abs(a))}if(r===`sw`){let t=[m[0],p[1]];g=I(t[0]-Math.abs(e),t[1])}[`s`,`n`].includes(r)&&(g[0]=h[0]-e/2),[`e`,`w`].includes(r)&&(g[1]=h[1]-a/2),i&&(g[0]=h[0]-Math.abs(e)/2,g[1]=h[1]-Math.abs(a)/2);let v=t.angle;g=R(R(g,I(d,f),v),R(I(g[0]+Math.abs(e)/2,g[1]+Math.abs(a)/2),I(d,f),v),-v);let[y,b]=g;$(t,{fontSize:o.size,width:e,height:a,x:y,y:b})}if(r===`e`||r===`w`){let n=e.get(t.id),[i,s,c,l]=sv(n,n.width,n.height,!0),u=I(i,s),d=I(c,l),f=sl(u,d),p=R(I(a,o),f,-n.angle),[m,,h]=sv(t,t.width,t.height,!0),g=h-m,_=d[0]-u[0],v=Sd(Gl({fontSize:t.fontSize,fontFamily:t.fontFamily}),t.lineHeight),y=_/g;r.includes(`e`)&&(y=(p[0]-u[0])/g),r.includes(`w`)&&(y=(d[0]-p[0])/g);let b=t.width*y<v?v:t.width*y,x=Xd(t.originalText,Gl(t),Math.abs(b)),S=yd(x,Gl(t),t.lineHeight),C=S.height,[w,T,E,D]=sv(n,b,C,!0),ee=E-w,te=D-T,ne=[...u];[`n`,`w`,`nw`].includes(r)&&(ne=[d[0]-Math.abs(ee),u[1]]);let re=n.angle;ne=R(R(ne,f,re),R(I(ne[0]+Math.abs(ee)/2,ne[1]+Math.abs(te)/2),f,re),-re),$(t,{width:Math.abs(b),height:Math.abs(S.height),x:ne[0],y:ne[1],text:x,autoResize:!1})}},bE=(e,t,n,r,i,a,o,s,c)=>{let l=5*Math.PI/2+Math.atan2(a-c,i-s);o&&(l+=Ss/2,l-=l%Ss);for(let r of t)if(!ed(r)){let[i,a,o,u]=J(r,n),d=(i+o)/2,f=(a+u)/2,p=e.get(r.id)?.angle??r.angle,[m,h]=R(I(d,f),I(s,c),l+p-r.angle);H(r)?$(r,{points:hy(r,n)}):$(r,{x:r.x+(m-d),y:r.y+(h-f),angle:Wc(l+p)},!1),Bv(r,n,{simultaneouslyUpdated:t});let g=Cb(r,n);g&&!V(r)&&$(g,{x:g.x+(m-d),y:g.y+(h-f),angle:Wc(l+p)},!1)}r.triggerUpdate()},xE=(e,t,n,r,i)=>{let[a,o,s,c]=t.length===1?J(t[0],n):av(t),l=(a+s)/2,u=(o+c)/2,d=t.length===1?t[0].angle:0;switch([r,i]=R(I(r,i),I(l,u),-d),e){case`n`:return R(I(r-(a+s)/2,i-o),I(0,0),d);case`s`:return R(I(r-(a+s)/2,i-c),I(0,0),d);case`w`:return R(I(r-a,i-(o+c)/2),I(0,0),d);case`e`:return R(I(r-s,i-(o+c)/2),I(0,0),d);case`nw`:return R(I(r-a,i-o),I(0,0),d);case`ne`:return R(I(r-s,i-o),I(0,0),d);case`sw`:return R(I(r-a,i-c),I(0,0),d);case`se`:return R(I(r-s,i-c),I(0,0),d);default:return[0,0]}},SE=(e,t)=>{let[,[n,r]]=t.points;return e===`nw`&&(n<0||r<0)||e===`ne`&&n>=0||e===`sw`&&n<=0||e===`se`&&(n>0||r>0)?`end`:`origin`},CE=(e,t,n)=>{if(n)return`center`;if(t)switch(e){case`n`:return`south-side`;case`e`:return`west-side`;case`s`:return`north-side`;case`w`:return`east-side`;case`ne`:return`bottom-left`;case`nw`:return`bottom-right`;case`se`:return`top-left`;case`sw`:return`top-right`}return[`e`,`se`,`s`].includes(e)?`top-left`:[`n`,`nw`,`w`].includes(e)?`bottom-right`:e===`ne`?`bottom-left`:`top-right`},wE=(e,t,n,r,i,a,o,s,c)=>{let l=CE(o,s,c),[u,d]=e;switch(l){case`top-left`:return{x:u+(t-r)/2+(r-t)/2*Math.cos(a)+(n-i)/2*Math.sin(a),y:d+(n-i)/2+(r-t)/2*Math.sin(a)+(i-n)/2*Math.cos(a)};case`top-right`:return{x:u+(t-r)/2*(Math.cos(a)+1)+(n-i)/2*Math.sin(a),y:d+(n-i)/2+(t-r)/2*Math.sin(a)+(i-n)/2*Math.cos(a)};case`bottom-left`:return{x:u+(t-r)/2*(1-Math.cos(a))+(i-n)/2*Math.sin(a),y:d+(n-i)/2*(Math.cos(a)+1)+(r-t)/2*Math.sin(a)};case`bottom-right`:return{x:u+(t-r)/2*(Math.cos(a)+1)+(i-n)/2*Math.sin(a),y:d+(n-i)/2*(Math.cos(a)+1)+(t-r)/2*Math.sin(a)};case`center`:return{x:u-(r-t)/2,y:d-(i-n)/2};case`east-side`:return{x:u+(t-r)/2*(Math.cos(a)+1),y:d+(t-r)/2*Math.sin(a)+(n-i)/2};case`west-side`:return{x:u+(t-r)/2*(1-Math.cos(a)),y:d+(r-t)/2*Math.sin(a)+(n-i)/2};case`north-side`:return{x:u+(t-r)/2+(n-i)/2*Math.sin(a),y:d+(i-n)/2*(Math.cos(a)-1)};case`south-side`:return{x:u+(t-r)/2+(i-n)/2*Math.sin(a),y:d+(n-i)/2*(Math.cos(a)+1)}}},TE=(e,t,n,r,i,a,o,{shouldInformMutation:s=!0,shouldMaintainAspectRatio:c=!1,shouldResizeFromCenter:l=!1}={})=>{let u={},d=Cb(n,i);if(d){let r=a.get(d.id);if(r&&(u={fontSize:r.fontSize}),c){let r=vE(d,i,Nb({...n,width:e,height:t},d));if(r===null)return;u={fontSize:r.size}}else{let n=xd(Gl(d),d.lineHeight),r=Od(d.fontSize,d.lineHeight);e=Math.max(e,n),t=Math.max(t,r)}}let f=_E(r,e,t,!0),p=I(r.x,r.y);if(rd(r)){let[e,t]=iv(r,a);p=I(e,t)}let m=wE(p,r.width,r.height,e,t,r.angle,o,c,l);if(rd(r)&&f.points){let e=r.x-p[0],t=r.y-p[1];m.x+=e,m.y+=t;let n=f.points[0][0],i=f.points[0][1];m.x+=n,m.y+=i,f.points=f.points.map(e=>I(e[0]-n,e[1]-i))}if(e<0&&(m.x+=e),t<0&&(m.y+=t),`scale`in n&&`scale`in r&&$(n,{scale:[(Math.sign(e)||r.scale[0])*r.scale[0],(Math.sign(t)||r.scale[1])*r.scale[1]]}),V(n)&&d&&c){let t=e/n.width*d.fontSize;if(t<Is)return;u.fontSize=t}e!==0&&t!==0&&Number.isFinite(m.x)&&Number.isFinite(m.y)&&($(n,{...m,width:Math.abs(e),height:Math.abs(t),...f},s),Bv(n,i,{newSize:{width:e,height:t}}),d&&u!=null&&$(d,{fontSize:u.fontSize}),bb(n,i,o,c))},EE=(e,t,n,r,i,a,o,{shouldMaintainAspectRatio:s=!1,shouldResizeFromCenter:c=!1}={})=>{let[l,u,d,f]=sv(t,t.width,t.height,!0),p=I(l,u),m=I(d,f),h=sl(p,m),g=R(I(a,o),h,-t.angle),[_,v,y,b]=sv(e,e.width,e.height,!0),x=y-_,S=b-v,C=m[0]-p[0],w=m[1]-p[1],T=C/x,E=w/S;i.includes(`e`)&&(T=(g[0]-p[0])/x),i.includes(`s`)&&(E=(g[1]-p[1])/S),i.includes(`w`)&&(T=(m[0]-g[0])/x),i.includes(`n`)&&(E=(m[1]-g[1])/S);let D=e.width*T,ee=e.height*E;if(c&&(D=2*D-t.width,ee=2*ee-t.height),s){let e=Math.abs(D)/t.width,n=Math.abs(ee)/t.height;if(i.length===1&&(ee*=e,D*=n),i.length===2){let r=Math.max(e,n);D=t.width*r*Math.sign(D),ee=t.height*r*Math.sign(ee)}}return{nextWidth:D,nextHeight:ee}},DE=(e,t,n,r,i,a,{shouldMaintainAspectRatio:o=!1,shouldResizeFromCenter:s=!1}={})=>{let c=e.map(e=>t.get(e.id)),l=c.reduce((e,r)=>{if(!rd(r))return e;let i=Sb(r);if(!i)return e;let a=t.get(i)??null;return pd(a)?[...e,{...a,...X.getBoundTextElementPosition(r,a,n)}]:e},[]),u=uv(c.map(e=>e).concat(l)),{minX:d,minY:f,maxX:p,maxY:m,midX:h,midY:g}=u,_=p-d,v=m-f,y={ne:[d,m],se:[d,f],sw:[p,f],nw:[p,m],e:[d,f+v/2],w:[p,f+v/2],n:[d+_/2,m],s:[d+_/2,f]},[b,x]=s?[h,g]:y[r],S=s?2:1,C=Math.max(Math.abs(i-b)/_||0,Math.abs(a-x)/v||0)*S,w=r.includes(`e`)||r.includes(`w`)?Math.abs(i-b)*S:_,T=r.includes(`n`)||r.includes(`s`)?Math.abs(a-x)*S:v;o&&(w=_*C*Math.sign(i-b),T=v*C*Math.sign(a-x));let[E,D]={ne:[i<b,a>x],se:[i<b,a<x],sw:[i>b,a<x],nw:[i>b,a>x],e:[i<b,!1],w:[i>b,!1],n:[!1,a>x],s:[!1,a<x]}[r].map(e=>e);return{originalBoundingBox:u,nextWidth:w,nextHeight:T,flipByX:E,flipByY:D}},OE=(e,t,n,r,i,{shouldMaintainAspectRatio:a=!1,shouldResizeFromCenter:o=!1,flipByX:s=!1,flipByY:c=!1,nextHeight:l,nextWidth:u,originalBoundingBox:d}={})=>{if(u===void 0&&l===void 0&&s===void 0&&c===void 0||l===0||u===0)return;i||=t;let f=e.reduce((e,t)=>{let n=i.get(t.id);return n&&e.push({orig:n,latest:t}),e},[]),p;if(d)p=d;else{let e=f.reduce((e,{orig:n})=>{if(!rd(n))return e;let r=Sb(n);if(!r)return e;let a=i.get(r)??null;return pd(a)?[...e,{...a,...X.getBoundTextElementPosition(n,a,t)}]:e},[]);p=uv(f.map(({orig:e})=>e).concat(e))}let{minX:m,minY:h,maxX:g,maxY:_,midX:v,midY:y}=p,b=g-m,x=_-h;if(u===void 0&&l===void 0&&(u=b,l=x),a&&(u===void 0?u=b/x*l:l===void 0?l=x/b*u:Math.abs(u/l-b/x)>.001&&(u=b/x*l)),u&&l){let e=n.includes(`e`)||n.includes(`w`)?Math.abs(u)/b:1,d=n.includes(`n`)||n.includes(`s`)?Math.abs(l)/x:1,p;p=n.length===1?n.includes(`e`)||n.includes(`w`)?e:d:Math.max(Math.abs(u)/b||0,Math.abs(l)/x||0);let S={ne:[m,_],se:[m,h],sw:[g,h],nw:[g,_],e:[m,h+x/2],w:[g,h+x/2],n:[m+b/2,_],s:[m+b/2,h]},[C,w]=o?[v,y]:S[n],T=a||f.some(e=>e.latest.angle!==0||B(e.latest)||zy(e.latest));T&&(e=p,d=p);let[E,D]=[s?-1:1,c?-1:1],ee=[];for(let{orig:n,latest:r}of f){if(B(n)&&pd(n))continue;let a=n.width*e,o=n.height*d,l=Wc(n.angle*E*D),u=rd(n)||td(n),f=n.x-C,m=n.y-w,h=s&&!u?a:0,g=c&&!u?o:0,_=C+E*(f*e+h),v=w+D*(m*d+g),y=_E(n,a*E,o*D,!1),b={x:_,y:v,width:a,height:o,angle:l,...y};if(H(n)&&(n.startBinding&&(b.startBinding={...n.startBinding,fixedPoint:[s?-n.startBinding.fixedPoint[0]+1:n.startBinding.fixedPoint[0],c?-n.startBinding.fixedPoint[1]+1:n.startBinding.fixedPoint[1]]}),n.endBinding&&(b.endBinding={...n.endBinding,fixedPoint:[s?-n.endBinding.fixedPoint[0]+1:n.endBinding.fixedPoint[0],c?-n.endBinding.fixedPoint[1]+1:n.endBinding.fixedPoint[1]]}),n.fixedSegments&&y.points&&(b.fixedSegments=n.fixedSegments.map(e=>({...e,start:y.points[e.index-1],end:y.points[e.index]})))),Ju(n)&&(b.scale=[n.scale[0]*E,n.scale[1]*D]),B(n)){let e=vE(n,t,a);if(!e)return;b.fontSize=e.size}let x=i.get(Sb(n)??``);if(x){if(T){let e=x.fontSize*p;if(e<Is)return;b.boundTextFontSize=e}else b.boundTextFontSize=x.fontSize}ee.push({element:r,update:b})}let te=ee.map(({element:e})=>e);for(let{element:e,update:{boundTextFontSize:r,...i}}of ee){let{width:a,height:o,angle:s}=i;$(e,i,!1,{isDragging:!0}),Bv(e,t,{simultaneouslyUpdated:te,newSize:{width:a,height:o}});let c=Cb(e,t);c&&r&&($(c,{fontSize:r,angle:rd(e)?void 0:s},!1),bb(e,t,n,!0))}r.triggerUpdate()}},kE=(e,t,n,r,i,a)=>{if(t.length===1&&H(t[0])&&(t[0].startBinding||t[0].endBinding))return;let o=t.filter(e=>{if(H(e)&&e.startBinding&&e.endBinding){let n=t.find(t=>t.id===e.startBinding?.elementId),r=t.find(t=>t.id===e.endBinding?.elementId);return n&&r}return!0}),s=new Set(o),c=o.filter(e=>ed(e)).map(e=>e.id);if(c.length>0)for(let e of r.getNonDeletedElements())e.frameId!==null&&c.includes(e.frameId)&&s.add(e);let l=AE(av(Array.from(s).map(t=>e.originalElements.get(t.id)??t)),n,i,a);s.forEach(t=>{if(jE(e,t,l),!V(t)){let n=Cb(t,r.getNonDeletedElementsMap());n&&jE(e,n,l),Bv(t,r.getElementsMapIncludingDeleted(),{simultaneouslyUpdated:Array.from(s)})}})},AE=(e,t,n,r)=>{let[i,a]=e,o=i+t.x+n.x,s=a+t.y+n.y;if(n.x===0||n.y===0){let[e,c]=ub(i+t.x,a+t.y,r);n.x===0&&(o=e),n.y===0&&(s=c)}return{x:o-i,y:s-a}},jE=(e,t,n)=>{let r=e.originalElements.get(t.id)??t;$(t,{x:r.x+n.x,y:r.y+n.y})},ME=(e,t,n)=>{let[r,i]=av(e);return[t-r,n-i]},NE=({newElement:e,elementType:t,originX:n,originY:r,x:i,y:a,width:o,height:s,shouldMaintainAspectRatio:c,shouldResizeFromCenter:l,zoom:u,widthAspectRatio:d=null,originOffset:f=null,informMutation:p=!0})=>{c&&e.type!==`selection`&&(d?s=o/d:(Math.abs(a-r)>Math.abs(i-n)?{width:o,height:s}=qT(t,s,i<n?-o:o):{width:o,height:s}=qT(t,o,a<r?-s:s),s<0&&(s=-s)));let m=i<n?n-o:n,h=a<r?r-s:r;l&&(o+=o,s+=s,m=n-o/2,h=r-s/2);let g=null;if(B(e)){s=e.height;let t=Sd(Gl({fontSize:e.fontSize,fontFamily:e.fontFamily}),e.lineHeight);o=Math.max(o,t),Math.abs(i-n)>xs/u&&(g={autoResize:!1}),h=r,l&&(m=n-o/2)}if(o!==0&&s!==0){let t=null;Ju(e)&&(t={initialWidth:o,initialHeight:s}),$(e,{x:m+(f?.x??0),y:h+(f?.y??0),width:o,height:s,...g,...t},p)}},PE=(e,t)=>!!(!e.viewModeEnabled&&e.openDialog?.name!==`elementLinkSelector`&&(e.activeTool.type!==`custom`&&(e.editingTextElement||e.activeTool.type!==`selection`&&e.activeTool.type!==`eraser`&&e.activeTool.type!==`hand`&&e.activeTool.type!==`laser`)||NT(t,e).length)),FE=e=>{let t=5381;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)+t+r}return t>>>0},IE=e=>e.filter(e=>!e.isDeleted&&!WT(e)),LE=e=>e.filter(e=>!e.isDeleted),RE=e=>!e.isDeleted,zE=e=>LE(e).map(e=>id(e.type)?{...e,lastCommittedPoint:null}:e),BE=e=>zE(e),VE=e=>zE(e),HE=async e=>{let t;if(e.type===M.png)try{return await(await i(async()=>{let{decodePngMetadata:e}=await import(`./image-GAAHSSAO-BoD-NvEF.js`);return{decodePngMetadata:e}},__vite__mapDeps([5,1,2]))).decodePngMetadata(e)}catch(e){throw e.message===`INVALID`?new oh(`Image doesn't contain scene`,`IMAGE_NOT_CONTAINS_SCENE_DATA`):new oh(`Error: cannot restore image`)}if(t=`text`in Blob?await e.text():await new Promise(t=>{let n=new FileReader;n.readAsText(e,`utf8`),n.onloadend=()=>{n.readyState===FileReader.DONE&&t(n.result)}}),e.type===M.svg)try{return oC({svg:t})}catch(e){throw e.message===`INVALID`?new oh(`Image doesn't contain scene`,`IMAGE_NOT_CONTAINS_SCENE_DATA`):new oh(`Error: cannot restore image`)}return t},UE=e=>e&&e.name.match(/\.(json|excalidraw|png|svg)$/)?.[1]||null,WE=e=>e===`png`||e===`svg`,GE=e=>{let t=UE(e);return t===`png`||t===`svg`},KE=e=>!!e&&Object.values(Gs).includes(e),qE=e=>{let{type:t}=e||{};return KE(t)},JE=async(e,t,n,r)=>{let i=await HE(e),a;try{try{a=JSON.parse(i)}catch(t){throw qE(e)?new oh(`Image doesn't contain scene`,`IMAGE_NOT_CONTAINS_SCENE_DATA`):t}if(SS(a))return{type:M.excalidraw,data:QC({elements:VE(a.elements||[]),appState:{theme:t?.theme,fileHandle:r||e.handle||null,...Fc(a.appState||{}),...t?yy(a.elements||[],t):{}},files:a.files},t,n,{repairBindings:!0,refreshDimensions:!1})};if(CS(a))return{type:M.excalidrawlib,data:a};throw Error(`Error: invalid file`)}catch(e){throw e instanceof oh?e:Error(`Error: invalid file`)}},YE=async(e,t,n,r)=>{let i=await JE(e,t,n,r);if(i.type!==M.excalidraw)throw Error(`Error: invalid file`);return i.data},XE=(e,t=`unpublished`)=>{let n=JSON.parse(e);if(!CS(n))throw Error(`Invalid library`);return ew(n.libraryItems||n.library,t)},ZE=async(e,t=`unpublished`)=>XE(await HE(e),t),QE=async e=>new Promise(async(t,n)=>{try{Du(e)&&(e=await e),e.toBlob(e=>{if(!e)return n(new ih(`Error: Canvas too big`,`CANVAS_POSSIBLY_TOO_BIG`));t(e)})}catch(e){n(e)}}),$E=async e=>{try{let t=await window.crypto.subtle.digest(`SHA-1`,await fD(e));return hu(new Uint8Array(t))}catch(e){return console.error(e),Mi(40)}},eD=async e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;t(e)},r.onerror=e=>n(e),r.readAsDataURL(e)}),tD=(e,t)=>`data:${t};base64,${gD(pD(e),!0)}`,nD=(e,t=``)=>{let n=e.indexOf(`,`),r=atob(e.slice(n+1)),i=e.slice(0,n).split(`:`)[1].split(`;`)[0],a=new ArrayBuffer(r.length),o=new Uint8Array(a);for(let e=0;e<r.length;e++)o[e]=r.charCodeAt(e);return new File([a],t,{type:i})},rD=e=>_D(e.slice(e.indexOf(`,`)+1)),iD=async(t,n)=>{if(t.type===M.svg)return t;let[r,a]=await Promise.all([i(()=>import(`./pica-XznpCgP2.js`).then(t=>e(t.default,1)).then(e=>e.default),__vite__mapDeps([6,2])),i(()=>import(`./image-blob-reduce.esm-Dj7YBvMv.js`).then(e=>e.default),[])]),o=a({pica:r({features:[`js`,`wasm`]})});if(n.outputType){let{outputType:e}=n;o._create_blob=function(t){return this.pica.toBlob(t.out_canvas,e,.8).then(e=>(t.out_blob=e,t))}}if(!qE(t))throw Error(`Error: unsupported file type`,{cause:`UNSUPPORTED`});return new File([await o.toBlob(t,{max:n.maxWidthOrHeight,alpha:!0})],t.name,{type:n.outputType||t.type})},aD=(e,t=``)=>new File([new TextEncoder().encode(e)],t,{type:M.svg}),oD=async(e,t=``)=>{let n;try{n=await fetch(e)}catch{throw Error(`Error: failed to fetch image`,{cause:`FETCH_ERROR`})}if(!n.ok)throw Error(`Error: failed to fetch image`,{cause:`FETCH_ERROR`});let r=await n.blob();if(r.type&&qE(r)){let e=t||r.name||``;return new File([r],e,{type:r.type})}throw Error(`Error: unsupported file type`,{cause:`UNSUPPORTED`})},sD=async e=>{let t=e.dataTransfer.files.item(0),n=await cD(e);return{file:t?await dD(t):null,fileHandle:n}},cD=async e=>{if(Yo)try{return await e.dataTransfer.items[0].getAsFileSystemHandle()||null}catch(e){return console.warn(e.name,e.message),null}return null},lD=e=>{let t=null,n=`${[...new Uint8Array(e).slice(0,8)].join(` `)} `,r={png:`137 80 78 71 13 10 26 10 `,jpg:`255 216 255 `,gif:`71 73 70 56 57 97 `};return n===r.png?t=M.png:n.startsWith(r.jpg)?t=M.jpg:n.startsWith(r.gif)&&(t=M.gif),t},uD=(e,t,n)=>new File([e],n||``,{type:t}),dD=async e=>{if(e.type){if(qE(e)){let t=await fD(e),n=lD(t);n&&n!==e.type&&(e=uD(t,n,e.name))}}else if(e?.name?.endsWith(`.excalidrawlib`))e=uD(await fD(e),M.excalidrawlib,e.name);else if(e?.name?.endsWith(`.excalidraw`))e=uD(await fD(e),M.excalidraw,e.name);else{let t=await fD(e),n=lD(t);n&&(e=uD(t,n,e.name))}return e},fD=e=>`arrayBuffer`in e?e.arrayBuffer():new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{if(!e.target?.result)return n(Error(`Couldn't convert blob to ArrayBuffer`));t(e.target.result)},r.readAsArrayBuffer(e)}),pD=e=>{let t=typeof e==`string`?new TextEncoder().encode(e):e instanceof Uint8Array?e:new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return n},mD=e=>{let t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0,r=e.length;t<r;t++)n[t]=e.charCodeAt(t);return t},hD=e=>new TextDecoder(`utf-8`).decode(mD(e)),gD=(e,t=!1)=>t?window.btoa(e):window.btoa(pD(e)),_D=(e,t=!1)=>t?window.atob(e):hD(window.atob(e)),vD=({text:e,compress:t})=>{let n;if(t!==!1)try{n=pD(ki(e))}catch(e){console.error(`encode: cannot deflate`,e)}return{version:`1`,encoding:`bstring`,compressed:!!n,encoded:n||pD(e)}},yD=e=>{let t;switch(e.encoding){case`bstring`:t=e.compressed?e.encoded:hD(e.encoded);break;default:throw Error(`decode: unknown encoding "${e.encoding}"`)}return e.compressed?Ai(new Uint8Array(mD(t)),{to:`string`}):t},bD=async e=>{let t=(0,h.default)(new Uint8Array(await fD(e))).find(e=>e.name===`tEXt`);return t?g.decode(t.data):null},xD=async({blob:e,metadata:t})=>{let n=(0,h.default)(new Uint8Array(await fD(e))),r=g.encode(M.excalidraw,JSON.stringify(vD({text:t,compress:!0})));return n.splice(-1,0,r),new Blob([(0,_.default)(n)],{type:M.png})},SD=async e=>{let t=await bD(e);if(t?.keyword===M.excalidraw)try{let e=JSON.parse(t.text);if(!(`encoded`in e)){if(`type`in e&&e.type===Js.excalidraw)return t.text;throw Error(`FAILED`)}return yD(e)}catch(e){throw console.error(e),Error(`FAILED`)}throw Error(`INVALID`)};export{tu as $,vc as $a,oc as $c,bD as $i,HT as $l,JC as $n,Sc as $o,Gy as $r,lc as $s,js as $t,Jc as A,NE as Aa,Cb as Ac,Pm as Ai,dD as Al,Eg as An,Bx as Ao,Fs as Ar,wd as As,US as At,YE as Au,Ys as B,Vf as Ba,lu as Bc,Bm as Bi,fp as Bl,Qc as Bn,DS as Bo,Au as Br,Gp as Bs,FT as Bt,no as Bu,Tm as C,hx as Ca,Rc as Cc,em as Ci,nu as Cl,_d as Cn,vs as Co,mx as Cr,Fw as Cs,Dp as Ct,vy as Cu,rD as D,Tx as Da,C_ as Dc,eh as Di,Tg as Dl,Sd as Dn,op as Do,OE as Dr,ps as Ds,zf as Dt,Gc as Du,FS as E,Dd as Ea,LS as Ec,sf as Ei,np as El,g_ as En,Zl as Eo,Hf as Er,SD as Es,Ls as Et,Gs as Eu,Bf as F,Op as Fa,Oy as Fc,Rs as Fi,eT as Fl,AS as Fn,ls as Fo,Lf as Fr,Fg as Fs,Zf as Ft,w_ as Fu,Vl as G,rd as Ga,xg as Gc,mT as Gi,uf as Gl,vm as Gn,OT as Go,PT as Gr,px as Gs,Gf as Gt,rc as H,hs as Ha,ay as Hc,Bc as Hi,ou as Hl,rE as Hn,_S as Ho,xb as Hr,B as Hs,Mp as Ht,Mi as Hu,J as I,bb as Ia,cm as Ic,ub as Ii,xw as Il,Ay as In,Wl as Io,q as Ir,Jm as Is,M as It,Up as Iu,Tw as J,WT as Ja,ax as Jc,Ec as Ji,a_ as Jl,Ey as Jn,oE as Jo,kf as Jr,Tc as Js,Us as Jt,Xs as K,Ul as Ka,j_ as Kc,Hp as Ki,Sm as Kl,SE as Kn,kb as Ko,x_ as Kr,Ps as Ks,hb as Kt,yg as L,Xu as La,wS as Lc,ex as Li,Jl as Ll,Od as Ln,V as Lo,Hm as Lr,Um as Ls,Am as Lt,RE as Lu,Iv as M,Ov as Ma,HS as Mc,JT as Mi,Wm as Ml,ym as Mn,Ql as Mo,hC as Mr,Hl as Ms,zp as Mt,os as Mu,Yu as N,iD as Na,mc as Nc,Cd as Ni,I as Nl,cb as Nn,Zm as No,Jg as Nr,QC as Ns,CT as Nt,aS as Nu,xv as O,wc as Oa,Gm as Oc,bg as Oi,yS as Ol,Ig as On,jv as Oo,$s as Or,KT as Os,Lm as Ot,Sf as Ou,Pw as P,yy as Pa,qm as Pc,Ip as Pi,ES as Pl,Cw as Pn,Kp as Po,ad as Pr,NS as Ps,vx as Pt,xx as Pu,xp as Q,um as Qa,Lp as Qc,Im as Qi,Cp as Ql,Hc as Qn,Gv as Qo,ZE as Qr,bc as Qs,jT as Qt,Nm as R,xD as Ra,jb as Rc,Jf as Ri,$c as Rl,Iu as Rn,tp as Ro,ss as Rr,cs as Rs,JE as Rt,Dc as Ru,Uf as S,Cx as Sa,id as Sc,Hg as Si,ds as Sl,Sy as Sn,yb as So,kp as Sr,aT as Ss,S_ as St,xS as Su,Dv as T,Vp as Ta,oh as Tc,lp as Ti,_u as Tl,iE as Tn,ed as To,xu as Tr,Zp as Ts,Du as Tt,wu as Tu,hg as U,wy as Ua,nC as Uc,_b as Ui,fs as Ul,Mf as Un,Rh as Uo,gm as Ur,Rm as Us,qE as Ut,ji as Uu,ah as V,tm as Va,dp as Vc,as as Vi,kT as Vl,ew as Vn,Bg as Vo,$f as Vr,ep as Vs,Kb as Vt,Ni as Vu,bm as W,Nv as Wa,lf as Wc,gx as Wi,iC as Wl,zb as Wn,sm as Wo,eb as Wr,Sw as Ws,__ as Wt,s as Wu,Md as X,Ym as Xa,Mb as Xc,Qf as Xi,k_ as Xl,yp as Xn,cu as Xo,TE as Xr,GT as Xs,DT as Xt,WE as Y,NT as Ya,zS as Yc,uu as Yi,QE as Yl,Pu as Yn,dv as Yo,xm as Yr,Ih as Ys,Xy as Yt,Lu as Z,Ry as Za,wb as Zc,H as Zi,zu as Zl,Cg as Zn,up as Zo,jw as Zr,UT as Zs,TS as Zt,Ap as _,qf as _a,Cs as _c,Af as _i,ap as _l,UE as _n,ZS as _o,ic as _r,Qu as _s,ec as _t,sd as _u,wp as a,_T as aa,Lg as ac,Rb as ai,zw as al,XE as an,mp as ao,tD as ar,fT as as,VS as at,MT as au,Pb as b,zm as ba,Jp as bc,Ob as bi,qp as bl,IS as bn,Xv as bo,by as br,Ix as bs,nD as bt,Hs as bu,If as c,$ as ca,cp as cc,cC as ci,N as cl,Iy as cn,YT as co,Ep as cr,vu as cs,dT as ct,Of as cu,ac as d,Cc as da,ws as dc,Cy as di,Km as dl,Np as dn,Tb as do,Cf as dr,mf as ds,hp as dt,Bs as du,ox as ea,am as ec,Ru as ei,mb as el,Tu as en,PS as eo,jf as er,cf as es,aE as et,Ff as eu,ey as f,uS as fa,oT as fc,xd as fi,nm as fl,b_ as fn,ys as fo,Rf as fr,Xc as fs,ET as ft,hT as fu,gd as g,Sb as ga,Hu as gc,Nb as gi,Xl as gl,km as gn,cT as go,PE as gr,bS as gs,ld as gt,V_ as gu,Nu as h,Pp as ha,Wy as hc,VT as hi,P as hl,Kf as hn,sp as ho,Dm as hr,yT as hs,wm as ht,sg as hu,Ku as i,uc as ia,My as ic,R as ii,_E as il,jm as in,mu as io,h_ as ir,Os as is,dm as it,Qy as iu,iT as j,tc as ja,Bl as jc,ix as ji,Vu as jl,Bb as jn,lT as jo,Tp as jr,cl as js,fx as jt,Vm as ju,Fb as k,Em as ka,Xp as kc,oS as ki,OS as kl,Wf as kn,Ib as ko,eD as kr,wg as ks,sx as kt,X as ku,lg as l,vg as la,$m as lc,ob as li,zl as ll,qb as ln,ff as lo,Ph as lr,gp as ls,Fu as lt,pm as lu,wf as m,Ju as ma,pp as mc,zc as mi,Ty as ml,Bv as mn,eu as mo,Hx as mr,Vs as ms,pf as mt,_p as mu,$E as n,vb as na,Db as nc,Mu as ni,Yf as nl,Qs as nn,sT as no,od as nr,uE as ns,Nf as nt,hm as nu,Kl as o,rx as oa,$p as oc,_m as oi,ud as ol,xc as on,fd as oo,uv as or,Sg as os,lE as ot,Eu as ou,oD as p,Xb as pa,pu as pc,ju as pi,gs as pl,Zs as pn,ky as po,F as pr,pE as ps,LE as pt,bu as pu,lb as q,jy as qa,Fm as qc,Yh as qi,Nw as ql,sb as qn,Fy as qo,Ou as qr,Bp as qs,mm as qt,av as r,Rp as ra,bs as rc,Pf as ri,Yp as rl,Df as rn,cg as ro,kE as rr,Lb as rs,zy as rt,qs as ru,$l as s,Xf as sa,ru as sc,xE as si,Kc as sl,lS as sn,TT as so,pd as sr,Bu as ss,Es as st,Ng as su,Zb as t,BS as ta,gT as tc,Sp as ti,lx as tl,vp as tn,Ts as to,Cm as tr,fm as ts,tx as tt,gb as tu,Om as u,Mm as ua,lm as uc,v_ as ui,RS as ul,nl as un,im as uo,Dw as ur,Zu as us,Gl as ut,XS as uu,m_ as v,j as va,Mc as vc,om as vi,Ky as vl,gc as vn,uT as vo,kv as vr,rf as vs,vv as vt,hf as vu,ME as w,Js as wa,Rl as wc,su as wi,Lc as wl,jp as wn,Dy as wo,md as wr,yd as ws,o_ as wt,$u as wu,qu as x,Sx as xa,Rw as xc,Py as xi,Lw as xl,sD as xn,rm as xo,dd as xr,ug as xs,yv as xt,bT as xu,Ex as y,gS as ya,df as yc,vT as yi,Xm as yl,ny as yn,Qm as yo,aD as yr,Su as ys,y_ as yt,hE as yu,Fp as z,_s as za,ql as zc,GE as zi,fu as zl,bp as zn,Xd as zo,Wp as zr,Ds as zs,yc as zt,Yo as zu};
|