var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,D());else{var t=n(l);t!==null&&O(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function ee(){return g?!0:!(e.unstable_now()-Tt&&ee());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&O(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?D():S=!1}}}var D;if(typeof y==`function`)D=function(){y(E)};else if(typeof MessageChannel<`u`){var te=new MessageChannel,ne=te.port2;te.port1.onmessage=E,D=function(){ne.postMessage(null)}}else D=function(){_(E,0)};function O(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,O(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,D()))),r},e.unstable_shouldYield=ee,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},ee=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function te(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ne(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var O=/\/+/g;function re(e,t){return typeof e==`object`&&e&&e.key!=null?ne(``+e.key):t.toString(36)}function k(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function A(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,A(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+re(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(O,`$&/`)+`/`),A(o,r,i,``,function(e){return e})):o!=null&&(te(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(O,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u{t.exports=f()})),m=o((e=>{var t=p();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=d(),n=p(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1xe||(e.current=be[xe],be[xe]=null,xe--)}function P(e,t){xe++,be[xe]=e.current,e.current=t}var we=Se(null),Te=Se(null),Ee=Se(null),De=Se(null);function Oe(e,t){switch(P(Ee,t),P(Te,e),P(we,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Ce(we),P(we,e)}function ke(){Ce(we),Ce(Te),Ce(Ee)}function Ae(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,P(De,e)),t=we.current;var n=dp(t,e.type);t!==n&&(P(Te,e),P(we,n))}function je(e){Te.current===e&&(Ce(we),Ce(Te)),De.current===e&&(Ce(De),sh._currentValue=ye)}var Me,F;function Ne(e){if(Me===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Me=t&&t[1]||``,F=-1)`:-1i||c[r]!==l[i]){var u=` `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Pe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Ne(n):``}function Ie(e,t){switch(e.tag){case 26:case 27:case 5:return Ne(e.type);case 16:return Ne(`Lazy`);case 13:return e.child!==t&&t!==null?Ne(`Suspense Fallback`):Ne(`Suspense`);case 19:return Ne(`SuspenseList`);case 0:case 15:return Fe(e.type,!1);case 11:return Fe(e.type.render,!1);case 1:return Fe(e.type,!0);case 31:return Ne(`Activity`);case 30:return Ne(`ViewTransition`);default:return``}}function Le(e){try{var t=``,n=null;do t+=Ie(e,n),n=e,e=e.return;while(e);return t}catch(e){return` Error generating stack: `+e.message+` `+e.stack}}var Re=Object.prototype.hasOwnProperty,ze=t.unstable_scheduleCallback,Be=t.unstable_cancelCallback,Ve=t.unstable_shouldYield,He=t.unstable_requestPaint,Ue=t.unstable_now,We=t.unstable_getCurrentPriorityLevel,Ge=t.unstable_ImmediatePriority,Ke=t.unstable_UserBlockingPriority,I=t.unstable_NormalPriority,qe=t.unstable_LowPriority,Je=t.unstable_IdlePriority,Ye=t.log,Xe=t.unstable_setDisableYieldValue,Ze=null,Qe=null;function $e(e){if(typeof Ye==`function`&&Xe(e),Qe&&typeof Qe.setStrictMode==`function`)try{Qe.setStrictMode(Ze,e)}catch{}}var et=Math.clz32?Math.clz32:rt,tt=Math.log,nt=Math.LN2;function rt(e){return e>>>=0,e===0?32:31-(tt(e)/nt|0)|0}var it=256,at=262144,ot=4194304;function st(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ct(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=st(n))):i=st(o):i=st(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=st(n))):i=st(o)):i=st(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function lt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ut(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function mt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ht(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=lr),fr=` `,pr=!1;function mr(e,t){switch(e){case`keyup`:return sr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function hr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var gr=!1;function _r(e,t){switch(e){case`compositionend`:return hr(t);case`keypress`:return t.which===32?(pr=!0,fr):null;case`textInput`:return e=t.data,e===fr&&pr?null:e;default:return null}}function vr(e,t){if(gr)return e===`compositionend`||!cr&&mr(e,t)?(e=An(),kn=On=Dn=null,gr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Br(n)}}function Hr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Hr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ur(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=zr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=zr(e.document)}return t}function Wr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Gr=wn&&`documentMode`in document&&11>=document.documentMode,Kr=null,qr=null,Jr=null,Yr=!1;function Xr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Yr||Kr==null||Kr!==zr(r)||(r=Kr,`selectionStart`in r&&Wr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Jr&&Rr(Jr,r)||(Jr=r,r=qf(qr,`onSelect`),0>=o,i-=o,Ki=1<<32-et(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),G&&Ji(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),G&&Ji(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return G&&Ji(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),G&&Ji(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===O&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case te:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===O){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),to(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===M&&Ja(l)===r.type){n(e,r.sibling),c=a(r,o.props),to(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===O?(c=Ni(o.props.children,e.mode,c,o.key),to(c,o),c.return=e,e=c):(c=Mi(o.type,o.key,o.props,null,e.mode,c),to(c,o),c.return=e,e=c)}return s(e);case ne:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Ii(o,e.mode,c),c.return=e,e=c}return s(e);case M:return o=Ja(o),_(e,r,o,c)}if(_e(o))return h(e,r,o,c);if(me(o)){if(l=me(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,eo(o),c);if(o.$$typeof===ie)return _(e,r,ba(e,o),c);no(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Pi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{$a=0;var i=_(e,t,n,r);return Qa=null,i}catch(t){if(t===Ha||t===Wa)throw t;var a=Oi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var io=ro(!0),ao=ro(!1),oo=!1;function so(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function co(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function lo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function uo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Yu&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Ti(e),wi(e,null,n),t}return xi(e,r,t,n),Ti(e)}function fo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_t(e,n)}}function po(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var mo=!1;function J(){if(mo){var e=Na;if(e!==null)throw e}}function ho(e,t,n,r){mo=!1;var i=e.updateQueue;oo=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Z&f)===f:(r&f)===f){f!==0&&f===Ma&&(mo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=E({},d,f);break a;case 2:oo=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),rd|=o,e.lanes=o,e.memoizedState=d}}function go(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function _o(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=N.T,s={};s.types=o===null?null:o.types,N.T=s,rc(e,!1,t,n);try{var c=i(),l=N.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?nc(e,t,Ia(c,r),Od(e)):nc(e,t,r,Od(e))}catch(n){nc(e,t,{then:function(){},status:`rejected`,reason:n},Od())}finally{ve.p=a,o!==null&&s.types!==null&&(o.types=s.types),N.T=o}}function Ks(){}function qs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Js(e).queue;Gs(e,a,t,ye,n===null?Ks:function(){return Ys(e),n(r)})}function Js(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ye,baseState:ye,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:is,lastRenderedState:ye},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:is,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ys(e){var t=Js(e);t.next===null&&(t=e.alternate.memoizedState),nc(e,t.next.queue,{},Od())}function Xs(){return ya(sh)}function Zs(){return $o().memoizedState}function Qs(){return $o().memoizedState}function $s(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Od();e=lo(n);var r=uo(t,e,n);r!==null&&(jd(r,t,n),fo(r,t,n)),t={cache:Ea()},e.payload=t;return}t=t.return}}function ec(e,t,n){var r=Od();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},ic(e)?ac(t,n):(n=Si(e,t,n,r),n!==null&&(jd(n,e,r),oc(n,t,r)))}function tc(e,t,n){nc(e,t,n,Od())}function nc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(ic(e))ac(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Lr(s,o))return xi(e,t,i,0),Xu===null&&bi(),!1}catch{}if(n=Si(e,t,i,r),n!==null)return jd(n,e,r),oc(n,t,r),!0}return!1}function rc(e,t,n,r){if(r={lane:2,revertLane:Mf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},ic(e)){if(t)throw Error(i(479))}else t=Si(e,n,r,2),t!==null&&jd(t,e,2)}function ic(e){var t=e.alternate;return e===Y||t!==null&&t===Y}function ac(e,t){Ro=Lo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function oc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_t(e,n)}}var sc={readContext:ya,use:ns,useCallback:Uo,useContext:Uo,useEffect:Uo,useImperativeHandle:Uo,useLayoutEffect:Uo,useInsertionEffect:Uo,useMemo:Uo,useReducer:Uo,useRef:Uo,useState:Uo,useDebugValue:Uo,useDeferredValue:Uo,useTransition:Uo,useSyncExternalStore:Uo,useId:Uo,useHostTransitionStatus:Uo,useFormState:Uo,useActionState:Uo,useOptimistic:Uo,useMemoCache:Uo,useCacheRefresh:Uo,useEffectEvent:Uo},cc={readContext:ya,use:ns,useCallback:function(e,t){return Qo().memoizedState=[e,t===void 0?null:t],e},useContext:ya,useEffect:Ms,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),As(4194308,4,Rs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return As(4194308,4,e,t)},useInsertionEffect:function(e,t){As(4,2,e,t)},useMemo:function(e,t){var n=Qo();t=t===void 0?null:t;var r=e();if(X){$e(!0);try{e()}finally{$e(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Qo();if(n!==void 0){var i=n(t);if(X){$e(!0);try{n(t)}finally{$e(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=ec.bind(null,Y,e),[r.memoizedState,e]},useRef:function(e){var t=Qo();return e={current:e},t.memoizedState=e},useState:function(e){e=ms(e);var t=e.queue,n=tc.bind(null,Y,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Bs,useDeferredValue:function(e,t){return Us(Qo(),e,t)},useTransition:function(){var e=ms(!1);return e=Gs.bind(null,Y,e.queue,!0,!1),Qo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Y,a=Qo();if(G){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Xu===null)throw Error(i(349));Z&127||ls(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Ms(ds.bind(null,r,o,e),[e]),r.flags|=2048,Os(9,{destroy:void 0},us.bind(null,r,o,n,t),null),n},useId:function(){var e=Qo(),t=Xu.identifierPrefix;if(G){var n=qi,r=Ki;n=(r&~(1<<32-et(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=zo++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[L]=t,o[wt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(np(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&ol(t)}}return dl(t),t.subtreeFlags&=-33554433,sl(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&ol(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=Ee.current,oa(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Qi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[L]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||$f(e.nodeValue,n)),e||ra(t,!0)}else e=lp(e).createTextNode(r),e[L]=t,t.stateNode=e}return dl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=oa(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[L]=t}else sa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;dl(t),e=!1}else n=ca(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(ko(t),t):(ko(t),null);if(t.flags&128)throw Error(i(558))}return dl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=oa(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[L]=t}else sa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;dl(t),a=!1}else a=ca(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(ko(t),t):(ko(t),null)}return ko(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),ll(t,t.updateQueue),dl(t),null);case 4:return ke(),e===null&&Uf(t.stateNode.containerInfo),t.flags|=67108864,dl(t),null;case 10:return K(t.type),dl(t),null;case 19:if(Mo(t),r=t.memoizedState,r===null)return dl(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)ul(r,!1);else{if(nd!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=No(e),o!==null){for(t.flags|=128,ul(r,!1),e=o.updateQueue,t.updateQueue=e,ll(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ji(n,e),n=n.sibling;return jo(t,Ao.current&1|2),G&&Ji(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ue()>pd&&(t.flags|=128,a=!0,ul(r,!1),t.lanes=4194304)}}else{if(!a){if(e=No(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,ll(t,e),ul(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!G)return dl(t),null}else 2*Ue()-r.renderingStartTime>pd&&n!==536870912&&(t.flags|=128,a=!0,ul(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ue(),e.sibling=null,o=Ao.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||G?jo(t,o):(n=o,P(Co,t),P(Ao,n),wo===null&&(wo=t)),G&&Ji(t,r.treeForkCount),e}return dl(t),null;case 22:case 23:return ko(t),So(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(dl(t),t.subtreeFlags&6&&(t.flags|=8192)):dl(t),n=t.updateQueue,n!==null&&ll(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&Ce(Ra),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),K(Ta),dl(t),null;case 25:return null;case 30:return t.flags|=33554432,dl(t),null}throw Error(i(156,t.tag))}function pl(e,t){switch(W(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return K(Ta),ke(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return je(t),null;case 31:if(t.memoizedState!==null){if(ko(t),t.alternate===null)throw Error(i(340));sa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(ko(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));sa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Mo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return ke(),null;case 10:return K(t.type),null;case 22:case 23:return ko(t),So(),e!==null&&Ce(Ra),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return K(Ta),null;case 25:return null;default:return null}}function ml(e,t){switch(W(t),t.tag){case 3:K(Ta),ke();break;case 26:case 27:case 5:je(t);break;case 4:ke();break;case 31:t.memoizedState!==null&&ko(t);break;case 13:ko(t);break;case 19:Mo(t);break;case 10:K(t.type);break;case 22:case 23:ko(t),So(),e!==null&&Ce(Ra);break;case 24:K(Ta)}}function hl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){df(t,t.return,e)}}function gl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){df(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){df(t,t.return,e)}}function _l(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{_o(t,n)}catch(t){df(e,e.return,t)}}}function vl(e,t,n){n.props=hc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){df(e,t,n)}}function yl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=pi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);m(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){df(e,t,n)}}function bl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){df(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){df(e,t,n)}else n.current=null}}function xl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),np(r,t,n),r[L]=e,Lt(r),t=r;break a;case`link`:if(o=Gm(`link`,`href`,a).get(t+(n.href||``))){for(s=0;sg&&(o=g,g=h,h=o);var _=Vr(s,h),v=Vr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,N.T=null,n=xd,xd=null;var o=_d,s=yd;if(gd=0,vd=_d=null,yd=0,Yu&6)throw Error(i(331));var c=Yu;if(Yu|=4,Wu(o.current),Iu(o,o.current,s,n),Yu=c,Tf(0,!1),Qe&&typeof Qe.onPostCommitFiberRoot==`function`)try{Qe.onPostCommitFiberRoot(Ze,o)}catch{}return!0}finally{ve.p=a,N.T=r,sf(e,t)}}function uf(e,t,n){t=Ri(n,t),t=xc(e.stateNode,t,2),e=uo(e,t,2),e!==null&&(mt(e,2),wf(e))}function df(e,t,n){if(e.tag===3)uf(e,e,n);else for(;t!==null;){if(t.tag===3){uf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(hd===null||!hd.has(r))){e=Ri(n,e),n=Sc(2),r=uo(t,n,2),r!==null&&(Cc(n,r,t,e),mt(r,2),wf(r));break}}t=t.return}}function ff(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ju;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(ed=!0,i.add(n),e=pf.bind(null,e,t,n),t.then(e,e))}function pf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Xu===e&&(Z&n)===n&&(nd===4||nd===3&&(Z&62914560)===Z&&300>Ue()-dd?Yu&2?ad|=n:Rd(e,0):ad|=n,sd===Z&&(sd=0)),wf(e)}function mf(e,t){t===0&&(t=ft()),e=Ci(e,t),e!==null&&(mt(e,t),wf(e))}function hf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),mf(e,n)}function gf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),mf(e,n)}function _f(e,t){return ze(e,t)}var vf=null,yf=null,bf=!1,xf=!1,Sf=!1,Cf=0;function wf(e){e!==yf&&e.next===null&&(yf===null?vf=yf=e:yf=yf.next=e),xf=!0,bf||(bf=!0,jf())}function Tf(e,t){if(!Sf&&xf){Sf=!0;do for(var n=!1,r=vf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-et(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Af(r,a))}else a=Z,a=ct(r,r===Xu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||lt(r,a)||(n=!0,Af(r,a))}r=r.next}while(n);Sf=!1}}function Ef(){Df()}function Df(){xf=bf=!1;var e=0;Cf!==0&&hp()&&(e=Cf);for(var t=Ue(),n=null,r=vf;r!==null;){var i=r.next,a=Of(r,t);a===0?(r.next=null,n===null?vf=i:n.next=i,i===null&&(yf=n)):(n=r,(e!==0||a&3)&&(xf=!0)),r=i}gd!==0&&gd!==5||Tf(e,!1),Cf!==0&&(Cf=0)}function Of(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=tn(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Lt(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+tn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+tn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+tn(n.imageSizes)+`"]`)):i+=`[href="`+tn(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=E({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[jt]=!0,o.onload=o.onerror=function(){Rt(o)}),Lt(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+tn(r)+`"][href="`+tn(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=E({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Lt(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=It(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=E({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Lt(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=It(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=E({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Lt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=It(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=E({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Lt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var a=(a=Ee.current)?bm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=It(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=It(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=It(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pm(e){return`href="`+tn(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return E({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[jt]){r.loading=1;return}}else t=e.createElement(`link`),t[jt]=!0,t.onload=t.onerror=Rt.bind(null,t),np(t,`link`,n),Lt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+tn(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+tn(n.href)+`"]`);if(r)return t.instance=r,Lt(r),r;var a=E({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Lt(r),np(r,`style`,a),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pm(n.href);var o=e.querySelector(Fm(a));if(o)return t.state.loading|=4,t.instance=o,Lt(o),o;r=Im(n),(a=vm.get(a))&&Hm(r,a),o=(e.ownerDocument||e).createElement(`link`),Lt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(a=e.querySelector(zm(o)))?(t.instance=a,Lt(a),a):(r=n,(a=vm.get(o))&&(r=E({},n),Um(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Lt(a),np(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Lt(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Lt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=g()})),v=l(p(),1),y=_(),b=(e,t,n)=>Math.max(1,Math.min(t/e.width,n/e.height)),x=1.2,S={width:10,height:8,doors:[{id:`door-1`,wall:`bottom`,offset:8.8/2,width:x,isLoading:!1}],screens:[],obstacles:[]},C={min:3,max:60},w={min:.7,max:4},T={min:1,max:12},ee={min:.2,max:10},E=.6,D=.3,te=1e-6,ne=[`top`,`bottom`,`left`,`right`],O=(e,t)=>t===`top`||t===`bottom`?e.width:e.height;function re(e,t,n,r,i){switch(t){case`top`:return{x:n,y:0,width:r,height:i};case`bottom`:return{x:n,y:e.height-i,width:r,height:i};case`left`:return{x:0,y:n,width:i,height:r};case`right`:return{x:e.width-i,y:n,width:i,height:r}}}var k=(e,t)=>re(e,t.wall,t.offset,t.width,t.width),A=(e,t)=>[re(e,t.wall,t.offset,t.width,E),k(e,t)],ie=(e,t)=>re(e,t.wall,t.offset,t.width,D);function ae(e){return[...e.doors.flatMap(t=>A(e,t)),...e.screens.map(t=>ie(e,t)),...e.obstacles]}var j=(e,t,n)=>Math.min(Math.max(e,t),n);function oe(e){let t=(e.rotation??0)*Math.PI/180,n=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t)),i=e.width*n+e.height*r,a=e.width*r+e.height*n,o=e.x+e.width/2,s=e.y+e.height/2;return{x:o-i/2,y:s-a/2,width:i,height:a}}function se(e,t){let n=oe(e),r=j(n.x,0,t.width-n.width)-n.x,i=j(n.y,0,t.height-n.height)-n.y;return{...e,x:e.x+r,y:e.y+i}}function M(e,t){let n=1e-9;return e.xt.x+n&&e.yt.y+n}function ce(e,t){let n=1e-9;return e.x>=-1e-9&&e.y>=-1e-9&&e.x+e.width<=t.width+n&&e.y+e.height<=t.height+n}function le(e,t,n,r){let i=oe(e);return ce(i,n)&&!t.some(e=>e.id!==r&&M(i,oe(e)))&&!ae(n).some(e=>M(i,e))}function ue(e,t,n,r){let i={...e,...t};return t.x===void 0&&t.y===void 0&&(i.x=e.x+e.width/2-i.width/2,i.y=e.y+e.height/2-i.height/2),i=se(i,r),le(i,n,r,e.id)?i:null}var de=(e,t)=>t.kind===`door`?A(e,{id:t.id,wall:t.wall,offset:t.offset,width:t.width,isLoading:!1}):[re(e,t.wall,t.offset,t.width,D)];function fe(e,t,n){if(n.offset<-1e-6||n.offset+n.width>O(e,n.wall)+te||[...e.doors.filter(e=>e.id!==n.id),...e.screens.filter(e=>e.id!==n.id)].some(e=>e.wall===n.wall&&n.offsete.offset+te))return!1;let r=t.map(oe);return de(e,n).every(t=>ce(t,e)&&!r.some(e=>M(t,e))&&!e.obstacles.some(e=>M(t,e)))}function pe(e,t,n){return!ce(n,e)||t.some(e=>M(n,oe(e)))||e.obstacles.some(e=>e.id!==n.id&&M(n,e))?!1:![...e.doors.flatMap(t=>A(e,t)),...e.screens.map(t=>ie(e,t))].some(e=>M(n,e))}function me(e,t){return e.doors.length<1||e.screens.length>2?!1:[...e.doors.map(e=>({...e,kind:`door`})),...e.screens.map(e=>({...e,kind:`screen`}))].every(n=>fe(e,t,n))&&e.obstacles.every(n=>pe(e,t,n))&&t.every(n=>le(n,t,e,n.id))}var he=e=>Math.ceil(e*10-1e-6)/10;function ge(e,t){let n=C.min,r=C.min,i=e=>{n=Math.max(n,e.x+e.width),r=Math.max(r,e.y+e.height)};t.map(oe).forEach(i),e.obstacles.forEach(i);let a=e=>{e.wall===`top`||e.wall===`bottom`?n=Math.max(n,e.offset+e.width):r=Math.max(r,e.offset+e.width)};e.screens.forEach(a);for(let t of e.doors)a(t),t.wall===`top`||t.wall===`bottom`?r=Math.max(r,t.width):n=Math.max(n,t.width);return{width:he(n),height:he(r)}}function _e(e,t,n){let r={...e,...n};return r.widthe.d-t.d),pe(e,t,{x:i,y:a,width:n,height:r,id:`__new`}))return{x:i,y:a};for(let i of s)if(pe(e,t,{id:`__new`,x:i.x,y:i.y,width:n,height:r}))return{x:i.x,y:i.y};return null}var ye=.5;function be(e,t,n,r){if(t===`right`)return{...e,width:j(n-e.x,ye,r.width-e.x)};let i=e.x+e.width,a=j(n,0,i-ye);return{...e,x:a,width:i-a}}var xe=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Se=e=>typeof e==`number`&&Number.isFinite(e),Ce=(e,t)=>e>=t.min-1e-6&&e<=t.max+1e-6,P=e=>Math.round(e*10)/10;function we(e){let{width:t,height:n,doors:r,screens:i,obstacles:a}=e;return JSON.stringify({width:t,height:n,doors:r,screens:i,obstacles:a},null,2)}function Te(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:`Not valid JSON.`}}if(!xe(t))return{ok:!1,error:`Expected a JSON object with width, height, doors, screens and obstacles.`};let n=e=>({ok:!1,error:e});if(!Se(t.width)||!Se(t.height))return n(`width and height must be numbers.`);if(!Ce(t.width,C)||!Ce(t.height,C))return n(`Room width and height must be between ${C.min} and ${C.max} m.`);if(!Array.isArray(t.doors)||!Array.isArray(t.screens)||!Array.isArray(t.obstacles))return n(`doors, screens and obstacles must all be arrays.`);let r=new Set,i=(e,t)=>typeof e!=`string`||!e?`${t}: id must be a non-empty string.`:r.has(e)?`${t}: duplicate id "${e}".`:(r.add(e),null),a=e=>typeof e==`string`&&ne.includes(e),o=[];for(let[e,r]of t.doors.entries()){let t=`Door ${e+1}`;if(!xe(r))return n(`${t} must be an object.`);let s=i(r.id,t);if(s)return n(s);if(!a(r.wall))return n(`${t}: wall must be top, bottom, left or right.`);if(!Se(r.offset)||!Se(r.width))return n(`${t}: offset and width must be numbers.`);if(!Ce(r.width,w))return n(`${t}: width must be ${w.min}-${w.max} m.`);if(typeof r.isLoading!=`boolean`)return n(`${t}: isLoading must be true or false.`);o.push({id:r.id,wall:r.wall,offset:r.offset,width:r.width,isLoading:r.isLoading})}if(o.length<1)return n(`A room needs at least one door.`);if(t.screens.length>2)return n(`At most 2 screens are allowed.`);let s=[];for(let[e,r]of t.screens.entries()){let t=`Screen ${e+1}`;if(!xe(r))return n(`${t} must be an object.`);let o=i(r.id,t);if(o)return n(o);if(!a(r.wall))return n(`${t}: wall must be top, bottom, left or right.`);if(!Se(r.offset)||!Se(r.width))return n(`${t}: offset and width must be numbers.`);if(!Ce(r.width,T))return n(`${t}: width must be ${T.min}-${T.max} m.`);s.push({id:r.id,wall:r.wall,offset:r.offset,width:r.width})}let c=[];for(let[e,r]of t.obstacles.entries()){let t=`Obstacle ${e+1}`;if(!xe(r))return n(`${t} must be an object.`);let a=i(r.id,t);if(a)return n(a);if(!Se(r.x)||!Se(r.y)||!Se(r.width)||!Se(r.height))return n(`${t}: x, y, width and height must be numbers.`);if(!Ce(r.width,ee)||!Ce(r.height,ee))return n(`${t}: size must be ${ee.min}-${ee.max} m.`);c.push({id:r.id,x:r.x,y:r.y,width:r.width,height:r.height})}let l={width:P(t.width),height:P(t.height),doors:o,screens:s,obstacles:c};return me(l,[])?{ok:!0,room:l}:n(`The doors, screens and obstacles don't fit together (overlap or outside the room).`)}var Ee=[{id:`chair`,name:`Chair`,shape:`chair`,defaultWidth:.5,defaultHeight:.5,isTable:!1,rotatable:!1,available:20},{id:`table`,name:`Table`,shape:`table`,defaultWidth:1.8,defaultHeight:.8,isTable:!0,rotatable:!0,available:6,seatsPerUnit:8},{id:`screen`,name:`Screen`,shape:`screen`,defaultWidth:2,defaultHeight:.2,isTable:!1,rotatable:!0,available:2}],De={room:S,items:[],configs:Object.fromEntries(Ee.map(e=>[e.id,e])),typeOrder:Ee.map(e=>e.id)};function Oe(e,t){switch(t.kind){case`add`:{let n=e.configs[t.type],r={id:t.id,type:t.type,x:t.x,y:t.y,width:n.defaultWidth,height:n.defaultHeight,rotation:0,locked:!1};return{...e,items:[...e.items,r]}}case`move`:return{...e,items:e.items.map(e=>e.id===t.id?{...e,x:t.x,y:t.y}:e)};case`update`:return{...e,items:e.items.map(e=>e.id===t.id?{...e,...t.patch}:e)};case`setRoom`:return{...e,room:t.room,items:t.clearItems?[]:e.items};case`remove`:return{...e,items:e.items.filter(e=>e.id!==t.id)};case`setAvailable`:return{...e,configs:{...e.configs,[t.type]:{...e.configs[t.type],available:t.value}}};case`setSeats`:return{...e,configs:{...e.configs,[t.type]:{...e.configs[t.type],seatsPerUnit:t.value}}};case`addConfig`:return{...e,configs:{...e.configs,[t.config.id]:t.config},typeOrder:[...e.typeOrder,t.config.id]}}}var ke=(e,t)=>e.filter(e=>e.type===t).length,Ae=(e,t,n)=>n-ke(e,t),je=(e,t)=>e.seatsOverride??t.seatsPerUnit,Me=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),F=o(((e,t)=>{t.exports=Me()}))();function Ne({size:e=36}){return(0,F.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 36 36`,children:[(0,F.jsx)(`rect`,{x:`4`,y:`4`,width:`28`,height:`28`,rx:`3`,fill:`#8fb4d9`,stroke:`#3b3b3b`,strokeWidth:`1.5`}),(0,F.jsx)(`rect`,{x:`4`,y:`4`,width:`28`,height:`8`,rx:`3`,fill:`#4a6f96`})]})}function Pe({size:e=36}){return(0,F.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 36 36`,children:(0,F.jsx)(`rect`,{x:`2`,y:`9`,width:`32`,height:`18`,rx:`3`,fill:`#d9b382`,stroke:`#3b3b3b`,strokeWidth:`1.5`})})}function Fe({size:e=36}){return(0,F.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 36 36`,children:[(0,F.jsx)(`rect`,{x:`2`,y:`14`,width:`32`,height:`8`,rx:`2`,fill:`#2d3748`,stroke:`#3b3b3b`,strokeWidth:`1.5`}),(0,F.jsx)(`rect`,{x:`4`,y:`16`,width:`28`,height:`4`,fill:`#63b3ed`})]})}function Ie({shape:e,size:t}){return e===`table`?(0,F.jsx)(Pe,{size:t}):e===`screen`?(0,F.jsx)(Fe,{size:t}):(0,F.jsx)(Ne,{size:t})}var Le=5,Re={width:`100%`,height:84,boxSizing:`border-box`,background:`#fff`,border:`1px solid #cfcfcf`,borderRadius:8,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:6,cursor:`grab`,userSelect:`none`,touchAction:`none`,font:`12px system-ui, sans-serif`,color:`#444`},ze=152,Be=600;function Ve({config:e,remaining:t,onStartDrag:n,onOpenMenu:r}){let i=e.id,a=t<=0,o=e=>{e.preventDefault();let{clientX:t,clientY:o}=e,s=!1,c=e=>{s||a||Math.hypot(e.clientX-t,e.clientY-o)>=Le&&(s=!0,u(),n(i,e.clientX,e.clientY))},l=e=>{u(),(Math.hypot(e.clientX-t,e.clientY-o){window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l)};return(0,F.jsxs)(`div`,{role:`button`,"aria-label":`${e.name} (${t} remaining)`,style:{...Re,position:`relative`,opacity:a?.45:1,filter:a?`grayscale(1)`:void 0,cursor:a?`pointer`:`grab`},onPointerDown:o,children:[(0,F.jsx)(`span`,{style:{position:`absolute`,top:6,right:6,minWidth:20,height:20,padding:`0 6px`,boxSizing:`border-box`,borderRadius:10,background:a?`#888`:`#2b2b2b`,color:`#fff`,font:`600 11px/20px system-ui, sans-serif`,textAlign:`center`},children:t}),(0,F.jsx)(Ie,{shape:e.shape}),e.name]})}function He({onClick:e}){return(0,F.jsxs)(`div`,{role:`button`,"aria-label":`New custom furniture`,onClick:e,style:{...Re,border:`1.5px dashed #9a9a9a`,background:`transparent`,cursor:`pointer`},children:[(0,F.jsx)(`span`,{style:{font:`300 30px/30px system-ui, sans-serif`,color:`#666`},children:`+`}),`Custom`]})}function Ue({types:e,remaining:t,onStartDrag:n,onOpenMenu:r,onNewCustom:i,header:a,panel:o}){let[s,c]=(0,v.useState)(264);return(0,F.jsxs)(`aside`,{style:{position:`relative`,width:s,flexShrink:0,borderRight:`1px solid #d4d4d4`,background:`#ececec`},children:[(0,F.jsxs)(`div`,{style:{height:`100%`,boxSizing:`border-box`,overflowY:`auto`,padding:16,display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(84px, 1fr))`,alignContent:`start`,gap:12},children:[a,o??(0,F.jsxs)(F.Fragment,{children:[e.map(e=>(0,F.jsx)(Ve,{config:e,remaining:t[e.id],onStartDrag:n,onOpenMenu:r},e.id)),(0,F.jsx)(He,{onClick:i})]})]}),(0,F.jsx)(`div`,{onPointerDown:e=>{e.preventDefault();let t=e.clientX,n=s,r=e=>c(Math.min(Be,Math.max(ze,n+e.clientX-t))),i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i)},style:{position:`absolute`,top:0,right:-3,width:6,height:`100%`,cursor:`col-resize`,touchAction:`none`}})]})}var We=Math.PI/180;function Ge(){return typeof window<`u`&&({}.toString.call(window)===`[object Window]`||{}.toString.call(window)===`[object global]`)}var Ke=typeof global<`u`?global:typeof window<`u`?window:typeof WorkerGlobalScope<`u`?self:{},I={_global:Ke,version:`10.9.0`,isBrowser:Ge(),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle(e){return I.angleDeg?e*We:e},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_renderBackend:`web`,legacyTextRendering:!1,pixelRatio:typeof window<`u`&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return I.DD.isDragging},isTransforming(){return I.Transformer?.isTransforming()??!1},isDragReady(){return!!I.DD.node},releaseCanvasOnDestroy:!0,document:Ke.document,_injectGlobal(e){Ke.Konva!==void 0&&console.error(`Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.`),Ke.Konva=e}},qe=new Set,Je=(e,t=!1)=>{I[e.prototype.getClassName()]=e,t&&qe.add(e)};I._injectGlobal(I);var Ye=`Konva.js unsupported environment. Looks like you are trying to use Konva.js in Node.js environment (or in a Web Worker), because "document" object is undefined. To use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module. bash: npm install canvas js: import "konva/canvas-backend"; or bash: npm install skia-canvas js: import "konva/skia-backend"; `,Xe=()=>{if(typeof document>`u`)throw Error(Ye)},Ze=class e{constructor(e){this.dirty=!1,this.m=e?e.slice():[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new e(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){let t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}_getTransformedRect(e){let[t,n,r,i,a,o]=this.m,s=e.x,c=e.y,l=e.x+e.width,u=e.y+e.height,d=[t*s+r*c+a,t*l+r*c+a,t*l+r*u+a,t*s+r*u+a],f=[n*s+i*c+o,n*l+i*c+o,n*l+i*u+o,n*s+i*u+o],p=Math.min(d[0],d[1],d[2],d[3]),m=Math.min(f[0],f[1],f[2],f[3]);return{x:p,y:m,width:Math.max(d[0],d[1],d[2],d[3])-p,height:Math.max(f[0],f[1],f[2],f[3])-m}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.m[0]*t+this.m[2]*n,i=this.m[1]*t+this.m[3]*n,a=this.m[0]*-n+this.m[2]*t,o=this.m[1]*-n+this.m[3]*t;return this.m[0]=r,this.m[1]=i,this.m[2]=a,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){let n=this.m[0]+this.m[2]*t,r=this.m[1]+this.m[3]*t,i=this.m[2]+this.m[0]*e,a=this.m[3]+this.m[1]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=a,this}multiply(e){let t=this.m[0]*e.m[0]+this.m[2]*e.m[1],n=this.m[1]*e.m[0]+this.m[3]*e.m[1],r=this.m[0]*e.m[2]+this.m[2]*e.m[3],i=this.m[1]*e.m[2]+this.m[3]*e.m[3],a=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],o=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}isInvertible(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]!==0}invert(){let e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,n=-this.m[1]*e,r=-this.m[2]*e,i=this.m[0]*e,a=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}getMatrix(){return this.m}decompose(){let e=this.m[0],t=this.m[1],n=this.m[2],r=this.m[3],i=this.m[4],a=this.m[5],o=e*r-t*n,s={x:i,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){let i=Math.sqrt(e*e+t*t);s.rotation=t>0?Math.acos(e/i):-Math.acos(e/i),s.scaleX=i,s.scaleY=o/i,s.skewX=o&&(e*n+t*r)/o,s.skewY=0}else if(n!=0||r!=0){let i=Math.sqrt(n*n+r*r);s.rotation=Math.PI/2-(r>0?Math.acos(-n/i):-Math.acos(n/i)),s.scaleX=o/i,s.scaleY=i,s.skewX=0,s.skewY=o&&(e*n+t*r)/o}return s.rotation=L._getRotation(s.rotation),s}},Qe=`[object Array]`,$e=`[object Number]`,et=`[object String]`,tt=`[object Boolean]`,nt=Math.PI/180,rt=180/Math.PI,it=`#`,at=``,ot=`0`,st=`Konva warning: `,ct=`Konva error: `,lt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[0,0,0,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},ut=null,dt=typeof window<`u`?window:{},ft=new WeakMap,pt=(e,t)=>{typeof e.requestAnimationFrame==`function`?e.requestAnimationFrame(t):typeof requestAnimationFrame<`u`?requestAnimationFrame(t):setTimeout(t,16)},mt=new Map,ht=Object.getPrototypeOf(Int8Array),gt=e=>{let t=e.trim();return t.indexOf(`,`)===-1?t.split(/\s*\/\s*|\s+/):t.split(/\s*,\s*/)},_t=`[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?`,vt=RegExp(`^(${_t})(%?)$`,`i`),yt=(e,t)=>{let n=vt.exec(e);if(!n)return NaN;let r=n[2]?Number(n[1])/100*t:Number(n[1]);return Math.min(Math.max(r,0),t)},bt=/^#[0-9a-f]+$/i,xt=RegExp(`^(${_t})(deg|grad|rad|turn)?$`,`i`),St={deg:1,grad:.9,rad:rt,turn:360};function Ct(e,t){return Math.min(Math.max(e||0,0),t)}var L={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===Qe},_isNumber(e){return Object.prototype.toString.call(e)===$e&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===et},_isBoolean(e){return Object.prototype.toString.call(e)===tt},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!=`string`)return!1;let t=e[0];return t===`#`||t===`.`||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e,t){let n=t&&!t.closed&&t||dt,r=ft.get(n);r||(r=[],ft.set(n,r),pt(n,function(){ft.delete(n),r.forEach(function(e){e()})})),r.push(e)},createCanvasElement(){Xe();let e=document.createElement(`canvas`);try{e.style=e.style||{}}catch{}return e},createImageElement(){return Xe(),document.createElement(`img`)},_urlToImage(e,t,n){let r=L.createImageElement();r.onload=function(){t(r)},r.onerror=e=>{n?.(e instanceof Error?e:Error(`Unable to load image.`))},r.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(it,at);let t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215|0).toString(16);for(;e.length<6;)e=ot+e;return it+e},isCanvasFarblingActive(){if(ut!==null)return ut;if(typeof document>`u`)return ut=!1,!1;let e=this.createCanvasElement();e.width=10,e.height=10;let t=e.getContext(`2d`,{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle=`#282828`,t.fillRect(0,0,10,10);let n=t.getImageData(0,0,10,10).data,r=!1;for(let e=0;e<100;e++)if(n[e*4]!==40||n[e*4+1]!==40||n[e*4+2]!==40||n[e*4+3]!==255){r=!0;break}return ut=r,this.releaseCanvas(e),ut},getHitColor(){let e=()=>Math.random()*256|0;return this.getHitColorKey(e(),e(),e())},getHitColorKey(e,t,n){let r=this.isCanvasFarblingActive()?5:3,i=e=>Math.round(e/r)*r;return it+this._rgbToHex(i(e),i(t),i(n))},getSnappedHexColor(e){let{r:t,g:n,b:r}=this._hexToRgb(e);return this.getHitColorKey(t,n,r)},getRGB(e){let{r:t=0,g:n=0,b:r=0}=L.colorToRGBA(e)??{};return{r:t,g:n,b:r}},colorToRGBA(e){e=(e||``).trim()||`black`;let t=L._namedColorToRBA(e)||L._hex3ColorToRGBA(e)||L._hex4ColorToRGBA(e)||L._hex6ColorToRGBA(e)||L._hex8ColorToRGBA(e)||L._rgbColorToRGBA(e)||L._hslColorToRGBA(e);if(t&&[t.r,t.g,t.b,t.a].every(L._isNumber))return t},_namedColorToRBA(e){let t=lt[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:t.length>3?t[3]:1}:null},_rgbColorToRGBA(e){let t=/^rgba?\(([^)]*)\)$/i.exec(e);if(!t)return;let n=gt(t[1]);if(!(n.length<3||n.length>4))return{r:yt(n[0],255),g:yt(n[1],255),b:yt(n[2],255),a:n.length>3?yt(n[3],1):1}},_hex8ColorToRGBA(e){if(e.length===9&&bt.test(e))return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e.length===7&&bt.test(e))return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e.length===5&&bt.test(e))return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e.length===4&&bt.test(e))return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){let t=/^hsla?\(([^)]*)\)$/i.exec(e);if(!t)return;let n=gt(t[1]);if(n.length<3||n.length>4)return;let r=xt.exec(n[0]);if(!r)return;let i=r[2],a=Number(r[1])*(i?St[i.toLowerCase()]:1);if(!isFinite(a))return;let o=(a%360+360)%360/360,s=yt(n[1],100)/100,c=yt(n[2],100)/100,l=n.length>3?yt(n[3],1):1,u=c<.5?c*(1+s):c+s-c*s,d=2*c-u,f=[0,0,0];for(let e=0;e<3;e++){let t=o+1/3*-(e-1);t<0&&t++,t>1&&t--;let n;n=6*t<1?d+(u-d)*6*t:2*t<1?u:3*t<2?d+(u-d)*(2/3-t)*6:d,f[e]=n*255}return{r:Math.round(f[0]),g:Math.round(f[1]),b:Math.round(f[2]),a:l}},_getPointsRect(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a=0;ae.x+e.width||t.x+t.widthe.y+e.height||t.y+t.heighttypeof e==`object`)?e.map(L._cloneValue):e.slice():L._isPlainObject(e)?L.cloneObject(e):e instanceof ht?e.slice():e},cloneArray(e){return e.slice(0)},degToRad(e){return e*nt},radToDeg(e){return e*rt},_getRotation(e){return I.angleDeg?L.radToDeg(e):e},_capitalize(e){let t=mt.get(e);if(t!==void 0)return t;let n=e.charAt(0).toUpperCase()+e.slice(1);return mt.set(e,n),n},throw(e){throw Error(ct+e)},error(e){console.error(ct+e)},warn(e){I.showWarnings&&console.warn(st+e)},_batchEvents(e,t){if(!e)return t();let n=!1,r=!0;try{e(()=>{n||!r?L.warn(`eventBatchFunc must call its argument exactly once, synchronously.`):(n=!0,t())})}finally{r=!1,n||L.warn(`eventBatchFunc must call its argument synchronously.`)}},each(e,t){for(let n in e)t(n,e[n])},_inRange(e,t,n){return t<=e&&e1?(o=n,s=r,c=(n-i)*(n-i)+(r-a)*(r-a)):(o=e+u*(n-e),s=t+u*(r-t),c=(o-i)*(o-i)+(s-a)*(s-a))}return[o,s,c]},_getProjectionToLine(e,t,n){let r=L.cloneObject(e),i=Number.MAX_VALUE;return t.forEach(function(a,o){if(!n&&o===t.length-1)return;let s=t[(o+1)%t.length],c=L._getProjectionToSegment(a.x,a.y,s.x,s.y,e.x,e.y),l=c[0],u=c[1],d=c[2];dt.length){let n=t;t=e,e=n}for(let t=0;t=0?`pointer`:e.indexOf(`touch`)>=0?`touch`:`mouse`},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId??999},releaseCanvas(...e){I.releaseCanvasOnDestroy&&e.forEach(e=>{e.width=0,e.height=0})},_cornerRadii(e,t,n){let r=Math.min(t,n)/2;if(typeof e==`number`){let t=Ct(e,r);return[t,t,t,t]}return[Ct(e[0],r),Ct(e[1],r),Ct(e[2],r),Ct(e[3],r)]},drawRoundedRectPath(e,t,n,r){let i=t<0?t:0,a=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let[o,s,c,l]=L._cornerRadii(r,t,n);e.moveTo(i+o,a),e.lineTo(i+t-s,a),e.arc(i+t-s,a+s,s,Math.PI*3/2,0,!1),e.lineTo(i+t,a+n-c),e.arc(i+t-c,a+n-c,c,0,Math.PI/2,!1),e.lineTo(i+l,a+n),e.arc(i+l,a+n-l,l,Math.PI/2,Math.PI,!1),e.lineTo(i,a+o),e.arc(i+o,a+o,o,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,i){r=Math.abs(r);for(let a=0;atypeof e==`number`?Math.floor(e):e)),i+=Et+c.join(Tt)+Dt)):(i+=o.property,e||(i+=At+o.val)),i+=Ot;return i}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=Nt&&t.shift()}reset(){let e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){let t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_drawDeviceBuffer(e){let{x:t,y:n,width:r,height:i}=e._isolationRect;this.setTransform(1,0,0,1,0,0),this.imageSmoothingEnabled=!1,this.drawImage(e._canvas,0,0,r,i,t,n,r,i)}_applyLineCap(e){let t=e.attrs.lineCap;t&&this.setAttr(`lineCap`,t)}_getOpacity(e){if(!this._opacityRoot)return e.getAbsoluteOpacity();let t=e.opacity(),n=e.parent;for(;n&&n!==this._opacityRoot;)t*=n.opacity(),n=n.parent;return t}_applyOpacity(e){let t=this._getOpacity(e);t!==1&&this.setAttr(`globalAlpha`,t)}_applyLineJoin(e){let t=e.attrs.lineJoin;t&&this.setAttr(`lineJoin`,t)}_applyMiterLimit(e){let t=e.attrs.miterLimit;t!=null&&this.setAttr(`miterLimit`,t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,i,a){this._context.arc(e,t,n,r,i,a)}arcTo(e,t,n,r,i){this._context.arcTo(e,t,n,r,i)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,i,a){this._context.bezierCurveTo(e,t,n,r,i,a)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){let n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,i,a){return this._context.createRadialGradient(e,t,n,r,i,a)}drawImage(e,t,n,r,i,a,o,s,c){let l=arguments,u=this._context;l.length===3?u.drawImage(e,t,n):l.length===5?u.drawImage(e,t,n,r,i):l.length===9&&u.drawImage(e,t,n,r,i,a,o,s,c)}ellipse(e,t,n,r,i,a,o,s){this._context.ellipse(e,t,n,r,i,a,o,s)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,i){this._context.roundRect(e,t,n,r,i)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash(e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,i,a){this._context.setTransform(e,t,n,r,i,a)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,i,a){this._context.transform(e,t,n,r,i,a)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=jt.length,n=this.setAttr,r,i,a=function(t){let n=e[t],r;e[t]=function(){return i=wt(Array.prototype.slice.call(arguments,0)),r=n.apply(e,arguments),e._trace({method:t,args:i}),r}};for(r=0;r0&&f>0||(l=u=0,d=f=1);let p=this._isolationCanvas||=new e({width:0,height:0,pixelRatio:this.pixelRatio});if(p.widthMath.min(r,Math.ceil((n4*t.width*t.height?e._isolationLowFrames+1:0,e._isolationLowFrames>=10?this._releaseIsolationCanvas():(t.width=t.height=0,e._trimIsolationCanvas())}_releaseIsolationCanvas(){let e=this._isolationCanvas;e&&(e._releaseIsolationCanvas(),L.releaseCanvas(e._canvas),this._isolationCanvas=void 0)}setSize(e,t){this._releaseIsolationCanvas(),super.setSize(e,t)}constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this._isolationPeak={width:0,height:0},this._isolationLowFrames=0,this.context=new Lt(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},Vt=class extends zt{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new Rt(this),this.context.imageSmoothingEnabled=!1,this.setSize(e.width,e.height)}},R={get isDragging(){let e=!1;return R._dragElements.forEach(t=>{t.dragStatus===`dragging`&&(e=!0)}),e},get node(){let e;for(let t of R._dragElements.values()){if(t.dragStatus===`dragging`)return t.node;e=t.node}return e},_dragElements:new Map,_listenToWindow(e){let t=t=>R._endDragBefore(t,e),n=t=>R._batchEvents(()=>R._drag(t,e),e),r=e=>R._batchEvents(()=>R._endDragAfter(e));e.addEventListener(`mouseup`,t,!0),e.addEventListener(`touchend`,t,!0),e.addEventListener(`touchcancel`,t,!0),e.addEventListener(`mousemove`,n),e.addEventListener(`touchmove`,n),e.addEventListener(`mouseup`,r,!1),e.addEventListener(`touchend`,r,!1),e.addEventListener(`touchcancel`,r,!1)},_batchEvents(e,t){if(!R._dragElements.size)return;let n=new Set;for(let{node:e}of R._dragElements.values()){let r=e.getStage();if(!r||t&&r._getOwnerWindow()!==t)continue;let i=r.eventBatchFunc();i&&n.add(i)}let r=e;for(let e of n){let t=r;r=()=>L._batchEvents(e,t)}r()},_drag(e,t){let n=[],r=new Set;R._dragElements.forEach((i,a)=>{let{node:o}=i,s=o.getStage();if(t&&s._getOwnerWindow()!==t||(r.has(s)||(s.setPointersPositions(e),r.add(s)),i.pointerEventType&&i.pointerEventType!==s._pointerEventType))return;i.pointerId===void 0&&(i.pointerId=L._getFirstPointerId(e),i.pointerEventType=s._pointerEventType,i.dragStatus===`dragging`&&s._cancelClick(i.pointerId,i.pointerEventType));let c=s._changedPointerPositions.find(e=>e.id===i.pointerId);if(c){if(i.dragStatus!==`dragging`){let t=o.dragDistance();if(Math.max(Math.abs(c.x-i.startPointerPos.x),Math.abs(c.y-i.startPointerPos.y)){t.getStage()&&t.fire(`dragmove`,{type:`dragmove`,target:t,evt:e},!0)})},_endDragBefore(e,t,n){let r=[],i=new Set;R._dragElements.forEach((a,o)=>{let{node:s}=a;if(n&&a!==n&&a.pointerId!==n.pointerId)return;let c=s.getStage();if(e&&!i.has(c)&&(!t||c._getOwnerWindow()===t)&&(c.setPointersPositions(e),i.add(c)),n||(!e||!a.pointerEventType||a.pointerEventType===L._getEventType(e.type))&&(a.pointerId===void 0||c._changedPointerPositions.some(e=>e.id===a.pointerId))){if(a.dragStatus===`ready`)R._dragElements.delete(o);else{c._cancelClick(a.pointerId,a.pointerEventType),a.dragStatus=`stopped`;let e=s.getLayer()||c;e&&r.indexOf(e)===-1&&r.push(e)}}}),r.forEach(e=>{e.draw()})},_endDragAfter(e,t){R._dragElements.forEach((n,r)=>{n.dragStatus!==`stopped`||t&&n!==t&&n.pointerId!==t.pointerId||(n.node.fire(`dragend`,{type:`dragend`,target:n.node,evt:e},!0),n.dragStatus!==`dragging`&&R._dragElements.delete(r))})}},Ht=new Map,Ut=I._global.PointerEvent!==void 0;function Wt(e,t){let n=Ht.get(e);return n&&(!t||n.stage===t)?n.shape:void 0}function Gt(e,t,n){e._fire(t,{evt:new PointerEvent(t,{pointerId:n}),pointerId:n})}function z(e,t){return Ht.get(e)?.shape===t}function Kt(e,t){var n;Jt(e);let r=t.getStage();if(r&&(Ht.set(e,{shape:t,stage:r}),Ut)){try{(n=r.content)==null||n.setPointerCapture(e)}catch{}Gt(t,`gotpointercapture`,e)}}function qt(e){Ht.forEach(({shape:t,stage:n},r)=>{(t===e||n===e)&&Jt(r)})}function Jt(e,t){var n;let r=Ht.get(e);if(!r||t&&r.shape!==t)return;let{shape:i,stage:a}=r;if(Ht.delete(e),Ut){try{(n=a.content)==null||n.releasePointerCapture(e)}catch{}Gt(i,`lostpointercapture`,e)}}function Yt(e){return L._isString(e)?`"`+e+`"`:Object.prototype.toString.call(e)===`[object Number]`||L._isBoolean(e)?e:Object.prototype.toString.call(e)}function Xt(e){return e>255?255:e<0?0:Math.round(e)}function B(){if(I.isUnminified)return function(e,t){return L._isNumber(e)||L.warn(Yt(e)+` is a not valid value for "`+t+`" attribute. The value should be a number.`),e}}function Zt(e){if(I.isUnminified)return function(t,n){let r=L._isNumber(t),i=L._isArray(t)&&t.length==e;return!r&&!i&&L.warn(Yt(t)+` is a not valid value for "`+n+`" attribute. The value should be a number or Array(`+e+`)`),t}}function Qt(){if(I.isUnminified)return function(e,t){return L._isNumber(e)||e===`auto`||L.warn(Yt(e)+` is a not valid value for "`+t+`" attribute. The value should be a number or "auto".`),e}}function $t(){if(I.isUnminified)return function(e,t){return L._isString(e)||L.warn(Yt(e)+` is a not valid value for "`+t+`" attribute. The value should be a string.`),e}}function en(){if(I.isUnminified)return function(e,t){let n=L._isString(e),r=Object.prototype.toString.call(e)===`[object CanvasGradient]`||e&&e.addColorStop;return n||r||L.warn(Yt(e)+` is a not valid value for "`+t+`" attribute. The value should be a string or a native gradient.`),e}}function tn(){if(I.isUnminified)return function(e,t){return e instanceof ht||(L._isArray(e)?e.forEach(function(e){L._isNumber(e)||L.warn(`"`+t+`" attribute has non numeric element `+e+`. Make sure that all elements are numbers.`)}):L.warn(Yt(e)+` is a not valid value for "`+t+`" attribute. The value should be a array of numbers.`)),e}}function nn(){if(I.isUnminified)return function(e,t){return e!==!0&&e!==!1&&L.warn(Yt(e)+` is a not valid value for "`+t+`" attribute. The value should be a boolean.`),e}}function rn(e){if(I.isUnminified)return function(t,n){return t==null||L.isObject(t)||L.warn(Yt(t)+` is a not valid value for "`+n+`" attribute. The value should be an object with properties `+e),t}}var an=`get`,on=`set`,V={addGetterSetter(e,t,n,r,i){V.addGetter(e,t,n),V.addSetter(e,t,r,i),V.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){let r=an+L._capitalize(t),i=Array.isArray(n),a=function(){let e=this.attrs[t];return e===void 0?i?n.slice():n:e};a._def=n,e.prototype[r]=e.prototype[r]||a},addSetter(e,t,n,r){let i=on+L._capitalize(t);e.prototype[i]||V.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){let i=on+L._capitalize(t);e.prototype[i]=function(e){return n&&e!=null&&(e=n.call(this,e,t)),this._setAttr(t,e),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,i){let a=n.length,o=L._capitalize,s=an+o(t),c=on+o(t),l=n.map(e=>t+o(e)),u=l.map(e=>an+o(e));e.prototype[s]=function(){let e={};for(let t=0;t{this._setAttr(t+o(e),void 0)}),this._fireChangeEvent(t,a,e),i&&i.call(this),this},V.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){let n=L._capitalize(t),r=on+n,i=an+n,a=function(){return arguments.length?(this[r](arguments[0]),this):this[i]()};e.prototype[t]=a},backCompat(e,t){L.each(t,function(t,n){let r=e.prototype[n],i=an+L._capitalize(t),a=on+L._capitalize(t);function o(){return L.error(`"`+t+`" method is deprecated and will be removed soon. Use ""`+n+`" instead.`),r.apply(this,arguments)}e.prototype[t]=o,e.prototype[i]=o,e.prototype[a]=o})},afterSetFilter(){this._filterUpToDate=!1}};function sn(e){let t=[],n=/(\w+)\(([^)]*)\)/g,r;for(;(r=n.exec(e))!==null;){let[,e,n]=r;if(![`blur`,`brightness`,`contrast`,`grayscale`,`sepia`,`invert`].includes(e)){L.warn(`CSS filter "${e}" is not supported in fallback mode. Consider using function filters for better compatibility.`);continue}let i=n.trim()===``?e===`blur`?0:1:parseFloat(n)/(n.includes(`%`)?100:1);t.push({name:e,value:i})}return function(e,n=1){for(let{name:r,value:i}of t){if([`grayscale`,`sepia`,`invert`].includes(r)){let t=Math.min(1,Math.max(0,i)),n=e.data;for(let e=0;e0?e._pendingUpdates.add(t):t()}static _flushUpdateBatch(){if(e._updateBatchDepth>0)return;let t=e._pendingUpdates;t.size&&(e._pendingUpdates=new Set,t.forEach(e=>e()))}static _updateBatch(t){e._updateBatchDepth++;try{return t()}finally{e._updateBatchDepth--,e._flushUpdateBatch()}}static _beginUpdateBatch(){e._updateBatchDepth++;let t=!1;return()=>{t||(t=!0,e._updateBatchDepth--,e._flushUpdateBatch())}}clearCache(){return this._releaseCanvasCache(),this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){let t=e||{},n={};if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0){let e=this._isUnderCache;this._isUnderCache=!0,n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}),this._isUnderCache=e}let r=t.x===void 0?Math.floor(n.x):t.x,i=t.y===void 0?Math.floor(n.y):t.y,a=Math.ceil(t.width||n.x+n.width-r),o=Math.ceil(t.height||n.y+n.height-i),s=t.pixelRatio,c=t.offset||0,l=t.drawBorder||!1,u=t.hitCanvasPixelRatio||1;if(a<=0||o<=0||!isFinite(r+i+a+o))return L.error(`Can not cache the node. Its size is 0 or its bounds are not finite numbers (${r}, ${i}, ${a}x${o}). Caching is skipped.`),this;a+=c*2,o+=c*2,r-=c,i-=c;let d=new Bt({pixelRatio:s,width:a,height:o}),f=new Bt({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),p=d.getContext();d.isCache=!0,this._releaseCanvasCache(),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(d.getContext()._context.imageSmoothingEnabled=!1,f.getContext()._context.imageSmoothingEnabled=!1),p.save(),p.translate(-r,-i),this._isUnderCache=!0,this._clearSelfAndDescendantCache(cn);try{this.drawScene(d,this)}catch(e){throw L.releaseCanvas(d._canvas),e}finally{this._isUnderCache=!1,this._clearSelfAndDescendantCache(cn),p.restore(),d._releaseIsolationCanvas()}return l&&(p.save(),p.beginPath(),p.rect(0,0,a,o),p.closePath(),p.setAttr(`strokeStyle`,`red`),p.setAttr(`lineWidth`,5),p.stroke(),p.restore()),this._canvasCache={scene:d,filter:f,hit:null,hitConfig:{pixelRatio:u,width:a,height:o},x:r,y:i},this._clearSelfAndDescendantCache(),this._requestDraw(),this}_getCachedHitCanvas(e){if(e===this)return null;let t=this._getCanvasCache();if(!t)return null;if(t.hit)return t.hit;let n=new Vt(t.hitConfig);n.isCache=!0;let r=n.getContext();return r.save(),r.translate(-t.x,-t.y),this.drawHit(n,this),r.restore(),t.hit=n,n}isCached(){return!!this._canvasCache}getClientRect(e){throw Error(`abstract "getClientRect" method call`)}_getCachedSceneRect(e){let t=e._forDrawing&&!this._isUnderCache&&this._getCanvasCache();if(!t)return;let n={x:t.x,y:t.y,width:t.scene.width/t.scene.pixelRatio,height:t.scene.height/t.scene.pixelRatio};return e.skipTransform?n:this._transformedRect(n,e.relativeTo)}_transformedRect(e,t){return this.getAbsoluteTransform(t)._getTransformedRect(e)}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);let t=this._getCanvasCache();e.translate(t.x,t.y);let n=this._getCachedSceneCanvas(),r=n.pixelRatio;e.drawImage(n._canvas,0,0,n.width/r,n.height/r),e.restore()}_drawCachedHitCanvas(e,t){let n=this._getCanvasCache();e.save(),e.translate(n.x,n.y),e.drawImage(t._canvas,0,0,t.width/t.pixelRatio,t.height/t.pixelRatio),e.restore()}_getCachedSceneCanvas(){let e=this.filters(),t=this._getCanvasCache(),n=t.scene,r=t.filter,i=r.getContext(),a,o,s,c;if(!e||e.length===0)return n;if(this._filterUpToDate)return r;let l=!0;for(let t=0;tt===void 0?e:`${Number(t)*u}${n}`);return i.clear(),i.save(),i.setAttr(`filter`,t),i.drawImage(n._canvas,0,0,n.getWidth()/u,n.getHeight()/u),i.restore(),this._filterUpToDate=!0,r}try{for(a=e.length,i.clear(),i.drawImage(n._canvas,0,0,n.getWidth()/u,n.getHeight()/u),o=i.getImageData(0,0,r.getWidth(),r.getHeight()),s=0;s{this.isAncestorOf(e.node)&&R._dragElements.delete(t)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(ln),this._clearSelfAndDescendantCache(cn),this._clearSelfAndDescendantCache(vn),this._clearSelfAndDescendantCache(xn),this._clearSelfAndDescendantCache(pn)}_remove(){let e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null),this._clearCaches()}destroy(){return this._fire(`destroy`,{target:this}),qt(this),this.remove(),this.clearCache(),this}getAttr(e){let t=`get`+L._capitalize(e);return L._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){let e=this.getParent(),t=[];for(;e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{let t,n;if(!e)return this;for(t in e)t!==dn&&(n=hn+L._capitalize(t),L._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(pn,this._isListening)}_isListening(e){if(!this.listening())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isListening(e):!0}isVisible(){return this._getCache(xn,this._isVisible)}_isVisible(e){if(!this.visible())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isVisible(e):!0}shouldDrawHit(e){return e?this._isVisible(e)&&this._isListening(e):this.isListening()&&this.isVisible()}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let e=this.getDepth(),t=this,n=0,r,i,a,o;function s(c){for(r=[],i=c.length,a=0;a0&&r[0].getDepth()<=e&&s(r)}let c=this.getStage();return t.nodeType!==bn&&c&&s(c.children),n}getDepth(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}_batchTransformChanges(t){this._batchingTransformChange?t():e._updateBatch(()=>{this._batchingTransformChange=!0;try{t()}finally{this._batchingTransformChange=!1,this._needClearTransformCache&&(this._needClearTransformCache=!1,this._clearCache(yn),this._clearSelfAndDescendantCache(ln))}})}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){let e=this.getStage();if(!e)return null;let t=e.getPointerPosition();if(!t)return null;let n=this.getAbsoluteTransform().copy();return n.invert(),n.point(t)}getAbsolutePosition(e){let t=this.getAbsoluteTransform(e).getMatrix(),n=new Ze,r=this.offset();return n.m=t.slice(),n.translate(r.x,r.y),n.getTranslation()}setAbsolutePosition(e){let{x:t,y:n,...r}=this._clearTransform();this.attrs.x=t,this.attrs.y=n,this._clearCache(yn);let i=this._getAbsoluteTransform().copy(),a=i.isInvertible();i.invert(),i.translate(e.x,e.y);let{x:o,y:s}=i.getTranslation();return this._setTransform(r),a?this.setPosition({x:this.attrs.x+o,y:this.attrs.y+s}):L.warn(`Cannot set the absolute position: the absolute transform is not invertible (an ancestor has a zero scale).`),this._clearCache(yn),this._clearSelfAndDescendantCache(ln),this}_setTransform(e){let t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){let e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){let t=e.x,n=e.y,r=this.x(),i=this.y();return t!==void 0&&(r+=t),n!==void 0&&(i+=n),this.setPosition({x:r,y:i}),this}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return L.warn(`Node has no parent. moveToTop function is ignored.`),!1;let e=this.index;return e0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return L.warn(`Node has no parent. moveToBottom function is ignored.`),!1;let e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return L.warn(`Node has no parent. zIndex parameter is ignored.`),this;(e<0||e>=this.parent.children.length)&&L.warn(`Unexpected value `+e+` for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to `+(this.parent.children.length-1)+`.`);let t=this.index;return this.parent.children.splice(t,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(cn,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let e=this.opacity(),t=this.getParent();return t&&!t._isUnderCache&&(e*=t.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){let e=this.getAttrs(),t,n,r,i={attrs:{},className:this.getClassName()};for(t in e)n=e[t],n instanceof ht&&(n=Array.from(n)),r=L.isObject(n)&&!L._isPlainObject(n)&&!L._isArray(n),!r&&(this[`get`+L._capitalize(t)]?._def!==n||t===`brightness`||t===`threshold`)&&(i.attrs[t]=t===`filters`&&L._isArray(n)?n.filter(e=>typeof e==`string`):L.isObject(n)?L._prepareToStringify(n):n);return i}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,n){let r=[];t&&this._isMatch(e)&&r.push(this);let i=this.parent;for(;i;){if(i===n)return r;i._isMatch(e)&&r.push(i),i=i.parent}return r}isAncestorOf(e){return!1}findAncestor(e,t,n){return this.findAncestors(e,t,n)[0]}_isMatch(e){if(!e)return!1;if(typeof e==`function`)return e(this);let t=e.replace(/ /g,``).split(`,`),n=t.length,r,i;for(r=0;r{try{let{callback:r,...i}=e||{};L._urlToImage(this.toDataURL(i),function(e){t(e),r?.(e)},n)}catch(e){n(e)}})}toBlob(e){return new Promise((t,n)=>{try{this.toCanvas(e).toBlob(r=>{var i;r?(t(r),(i=e?.callback)==null||i.call(e,r)):n(Error(`Konva: toBlob() failed, the canvas was not encoded`))},e?.mimeType,e?.quality)}catch(e){n(e)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance===void 0?this.parent?this.parent.getDragDistance():I.dragDistance:this.attrs.dragDistance}_off(e,t,n){let r=this.eventListeners[e],i,a,o;for(i=0;i=0)||R._dragElements.has(this._id))return;let t=!1;R._dragElements.forEach(e=>{this.isAncestorOf(e.node)&&(t=!0)}),t||this._createDragElement(e)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;let e=R._dragElements.get(this._id),t=e&&e.dragStatus===`dragging`,n=e&&e.dragStatus===`ready`;t?this.stopDrag():n&&R._dragElements.delete(this._id)}}_dragCleanup(){this.off(`mousedown.konva`),this.off(`touchstart.konva`)}isClientRectOnScreen(e={x:0,y:0}){let t=this.getStage();if(!t)return!1;let n={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return L.haveIntersection(n,this.getClientRect())}static create(e,t){return L._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(t,n){let r=e.prototype.getClassName.call(t),i=t.children,a,o,s;if(n&&(t.attrs.container=n),!I[r]){let e=i?`Group`:`Shape`;L.warn(`Can not find a node with class name "`+r+`". Fallback to "${e}".`),r=e}let c=I[r];if(a=new c(t.attrs),i)for(o=i.length,s=0;s0}removeChildren(){return this._clearChildren(`remove`)}destroyChildren(){return this._clearChildren(`destroy`)}_clearChildren(e){return H._updateBatch(()=>(this.children.forEach(t=>{t.parent=null,t.index=0,t[e]()}),this.children=[],this._notifySubtreeChange(),this._requestDraw(),this))}add(...e){if(e.length===0)return this;if(e.length>1){for(let t=0;t0?t[0]:void 0}_generalFind(e,t){let n=[];return this._descendants(r=>{let i=r._isMatch(e);return i&&n.push(r),!!(i&&t)}),n}_descendants(e){let t=!1;for(let n of this.children)if(t=e(n),t||n.hasChildren()&&(t=n._descendants(e),t))return!0;return!1}toObject(){let e=H.prototype.toObject.call(this);return e.children=[],this.children.forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){let t=H.prototype.clone.call(this,e);return this.children.forEach(function(e){t.add(e.clone())}),t}getAllIntersections(e){let t=[];return this.find(`Shape`).forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;let n=e===void 0||e===`absoluteTransform`;n&&H._updateBatchDepth++;try{if(super._clearSelfAndDescendantCache(e),e===`absoluteTransform`&&this.isCached())return;(t=this.children)==null||t.forEach(function(t){t._clearSelfAndDescendantCache(e)})}finally{n&&--H._updateBatchDepth===0&&H._flushUpdateBatch()}}_setChildrenIndices(){var e;(e=this.children)==null||e.forEach(function(e,t){e.index=t}),this._notifySubtreeChange(),this._requestDraw()}drawScene(e,t){let n=this.getLayer(),r=e||n&&n.getCanvas(),i=r&&r.getContext(),a=this._getCanvasCache(),o=a&&a.scene,s=t===this;if(!(t?this._isVisible(t):this.isVisible())&&!s)return this;if(o){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(i),i.restore()}else this._drawChildren(`drawScene`,r,t);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n&&n.hitCanvas,i=r&&r.getContext(),a=this._getCachedHitCanvas(t);if(a){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i,a),i.restore()}else this._drawChildren(`drawHit`,r,t);return this}_drawChildren(e,t,n){let r=t&&t.getContext(),i=this.clipWidth(),a=this.clipHeight(),o=this.clipFunc(),s=typeof i==`number`&&typeof a==`number`||o,c=n===this;if(s){r.save();let e=this.getAbsoluteTransform(n),t=e.getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),r.beginPath();let s;if(o)s=o.call(this,r,this);else{let e=this.clipX(),t=this.clipY();r.rect(e||0,t||0,i,a)}r.clip.apply(r,s),t=e.copy().invert().getMatrix(),r.transform(t[0],t[1],t[2],t[3],t[4],t[5])}let l=!c&&this.globalCompositeOperation()!==`source-over`&&e===`drawScene`;l&&(r.save(),r._applyGlobalCompositeOperation(this));try{this._drawChildNodes(e,t,n)}finally{l&&r.restore(),s&&r.restore()}}_drawChildNodes(e,t,n){var r;(r=this.children)==null||r.forEach(function(r){r[e](t,n)})}getClientRect(e={}){var t;let n=this._getCachedSceneRect(e);if(n)return n;let r=e.skipTransform,i=e.relativeTo,[a,o,s,c]=this.getAbsoluteTransform().getMatrix(),l=!r&&(e._forDrawing||a*c-o*s===0),u,d,f,p,m={x:1/0,y:1/0,width:0,height:0},h=this;return(t=this.children)==null||t.forEach(function(t){if(!t.visible())return;let n=t.getClientRect({relativeTo:l?i:h,_forDrawing:e._forDrawing,skipShadow:e.skipShadow,skipStroke:e.skipStroke});n.width===0&&n.height===0||!isFinite(n.x+n.y+n.width+n.height)||(u===void 0?(u=n.x,d=n.y,f=n.x+n.width,p=n.y+n.height):(u=Math.min(u,n.x),d=Math.min(d,n.y),f=Math.max(f,n.x+n.width),p=Math.max(p,n.y+n.height)))}),m=u===void 0?{x:0,y:0,width:0,height:0}:{x:u,y:d,width:f-u,height:p-d},!r&&!l?this._transformedRect(m,i):m}};V.addComponentsGetterSetter(Tn,`clip`,[`x`,`y`,`width`,`height`]),V.addGetterSetter(Tn,`clipX`,void 0,B()),V.addGetterSetter(Tn,`clipY`,void 0,B()),V.addGetterSetter(Tn,`clipWidth`,void 0,B()),V.addGetterSetter(Tn,`clipHeight`,void 0,B()),V.addGetterSetter(Tn,`clipFunc`);var En=`Stage`,Dn=`string`,On=`px`,kn=`mouseout`,An=`mouseleave`,jn=`mouseover`,Mn=`mouseenter`,Nn=`mousemove`,Pn=`mousedown`,Fn=`mouseup`,In=`pointermove`,Ln=`pointerdown`,Rn=`pointerup`,zn=`pointercancel`,Bn=`lostpointercapture`,Vn=`pointerout`,Hn=`pointerleave`,Un=`pointerover`,Wn=`pointerenter`,Gn=`contextmenu`,Kn=`touchstart`,qn=`touchend`,Jn=`touchmove`,Yn=`touchcancel`,Xn=`wheel`,Zn=5,Qn=[[Mn,`_pointerenter`],[Pn,`_pointerdown`],[Nn,`_pointermove`],[Fn,`_pointerup`],[An,`_pointerleave`],[Kn,`_pointerdown`],[Jn,`_pointermove`],[qn,`_pointerup`],[Yn,`_pointercancel`],[jn,`_pointerover`],[Xn,`_wheel`],[Gn,`_contextmenu`],[Ln,`_pointerdown`],[In,`_pointermove`],[Rn,`_pointerup`],[zn,`_pointercancel`],[Hn,`_pointerleave`],[Bn,`_lostpointercapture`]],$n={mouse:{[Vn]:kn,[Hn]:An,[Un]:jn,[Wn]:Mn,[In]:Nn,[Ln]:Pn,[Rn]:Fn,[zn]:`mousecancel`,pointerclick:`click`,pointerdblclick:`dblclick`},touch:{[Vn]:`touchout`,[Hn]:`touchleave`,[Un]:`touchover`,[Wn]:`touchenter`,[In]:Jn,[Ln]:Kn,[Rn]:qn,[zn]:Yn,pointerclick:`tap`,pointerdblclick:`dbltap`},pointer:{[Vn]:Vn,[Hn]:Hn,[Un]:Un,[Wn]:Wn,[In]:In,[Ln]:Ln,[Rn]:Rn,[zn]:zn,pointerclick:`pointerclick`,pointerdblclick:`pointerdblclick`}},er=e=>{let t=L._getEventType(e);if(t===`pointer`)return I.pointerEventsEnabled&&$n.pointer;if(t===`touch`)return $n.touch;if(t===`mouse`)return $n.mouse};function tr(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&L.warn(`Stage does not support clipping. Please use clip for Layers or Groups.`),e}var nr=`Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);`,rr=[],ir=new WeakSet,ar=e=>{e&&!ir.has(e)&&(ir.add(e),R._listenToWindow(e),e.document.addEventListener(`visibilitychange`,()=>{rr.forEach(e=>{e.batchDraw()})}))},or=class extends Tn{constructor(e){super(tr(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._pointerStates=new Map,this._lastClicks={},this._buildDOM(),this._bindContentEvents(),rr.push(this),this.on(`widthChange.konva heightChange.konva`,this._resizeDOM),this.on(`visibleChange.konva`,this._checkVisibility),this.on(`clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva`,()=>{tr(this.attrs)}),this._checkVisibility()}_validateAdd(e){let t=e.getType()===`Layer`,n=e.getType()===`FastLayer`;t||n||L.throw(`You may only add layers to the stage.`)}_checkVisibility(){if(!this.content)return;let e=this.visible()?``:`none`;this.content.style.display=e}_getOwnerWindow(){return(this.content||this.container())?.ownerDocument?.defaultView||(I.isBrowser?window:null)}setContainer(e){if(typeof e===Dn){let t;if(e.charAt(0)===`.`){let t=e.slice(1);e=document.getElementsByClassName(t)[0]}else t=e.charAt(0)===`#`?e.slice(1):e,e=document.getElementById(t);if(!e)throw`Can not find container in document with id `+t}return this._setAttr(`container`,e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content),ar(this._getOwnerWindow())),this}shouldDrawHit(){return!0}clear(){let e=this.children,t=e.length;for(let n=0;n-1&&rr.splice(n,1),L.releaseCanvas(this.bufferHitCanvas._canvas),this}getPointerPosition(){let e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(L.warn(nr),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();let t=new Bt({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(t){if(!t.isVisible())return;let r=t._toKonvaCanvas(e);n.drawImage(r._canvas,e.x,e.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio()),L.releaseCanvas(r._canvas)}),t}getIntersection(e){if(!e)return null;let t=this.children,n=t.length-1;for(let r=n;r>=0;r--){let n=t[r].getIntersection(e);if(n)return n}return null}_resizeDOM(){let e=this.width(),t=this.height();this.content&&(this.content.style.width=e+On,this.content.style.height=t+On),this.children.forEach(n=>{n._setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let e=0;eZn&&L.warn(`The stage has `+n+` layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.`),e._setSize({width:this.width(),height:this.height()}),e.draw(),I.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return z(e,this)}setPointerCapture(e){Kt(e,this)}releaseCapture(e){Jt(e,this)}getLayers(){return this.getChildren()}_bindContentEvents(){I.isBrowser&&Qn.forEach(([e,t])=>{this.content.addEventListener(e,e=>{this._batchEvents(()=>this[t](e))},{passive:!1})})}_batchEvents(e){L._batchEvents(this.eventBatchFunc(),e)}_pointerenter(e){this.setPointersPositions(e);let t=er(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);let t=er(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_pointerEventsEnabled(){if(I.hitOnDragEnabled)return!0;for(let{node:e,dragStatus:t}of R._dragElements.values())if(t===`dragging`&&e.getStage()===this)return!1;return!this.getLayers().some(e=>I.Transformer?._isLayerTransforming(e))}_cancelClick(e,t){let n=t?[t]:[`mouse`,`touch`,`pointer`];for(let t of n){let n=this._pointerStates.get(`${t}:${e}`);n&&(n.clickStartShape=void 0,n.relatedPointer&&(n.relatedPointer.clickStartShape=void 0))}}_pointerleave(e){let t=er(e.type),n=L._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r=this._changedPointerPositions[0]?.id,i=`${n}:${r}`,a=this._pointerStates.get(i),o=(a?.targetShape)?.getStage()===this?a.targetShape:void 0,s=this._pointerEventsEnabled()||e.pointerType===`touch`&&!a?.downPosition;s&&(a?.clickStartShape===void 0?this._pointerStates.delete(i):a.targetShape=void 0),o&&s?(o._fireAndBubble(t.pointerout,{evt:e,pointerId:r}),o._fireAndBubble(t.pointerleave,{evt:e,pointerId:r}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this})):s&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[],this._changedPointerPositions=[],this._pointerEventType=void 0}_pointerdown(e){let t=er(e.type),n=L._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(i=>{let a=this.getIntersection(i),o=`${n}:${i.id}`,s={targetShape:this._pointerStates.get(o)?.targetShape,clickStartShape:a&&a.isListening()?a:null,lastClick:this._lastClicks[n],downPosition:i,pointerType:e.pointerType};if(this._pointerStates.delete(o),n!==`pointer`){for(let[e,t]of[...this._pointerStates].reverse())if(!(!e.startsWith(`pointer:`)||!t.downPosition||n===`touch`&&t.relatedPointer)&&(n===`mouse`?t.pointerType!==`touch`:t.pointerType===`touch`&&t.downPosition.x===i.x&&t.downPosition.y===i.y)){s.relatedPointer=t,t.relatedPointer=s,t.clickStartShape===void 0&&(s.clickStartShape=void 0);break}}this._pointerStates.set(o,s);for(let e of R._dragElements.values())e.dragStatus===`dragging`&&(e.pointerId===void 0||e.pointerEventType===n&&e.pointerId===i.id||e.pointerEventType===`mouse`&&n===`pointer`&&s.pointerType!==`touch`)&&e.node.getStage()===this&&(e.pointerId===void 0&&n!==`pointer`&&(e.pointerId=i.id,e.pointerEventType=n),this._cancelClick(i.id,n));if(!a||!a.isListening())return;I.capturePointerEventsEnabled&&a.setPointerCapture(i.id),a._fireAndBubble(t.pointerdown,{evt:e,pointerId:i.id}),r=!0;let c=e.type.indexOf(`touch`)>=0;a.preventDefault()&&e.cancelable&&c&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointermove(e){let t=er(e.type),n=L._getEventType(e.type);if(!t)return;let r=e.type.indexOf(`touch`)>=0||e.pointerType===`touch`;if(e.cancelable&&r){for(let{node:t,dragStatus:n}of R._dragElements.values())if(n===`dragging`&&t.getStage()===this&&t.preventDefault()){e.preventDefault();break}}if(this.setPointersPositions(e),!this._pointerEventsEnabled())return;let i={},a=!1;this._changedPointerPositions.forEach(r=>{let o=`${n}:${r.id}`,s=this._pointerStates.get(o);s||(s={},this._pointerStates.set(o,s));let c=Wt(r.id)||this.getIntersection(r),l=s.targetShape===c||s.targetShape?.getStage()===this?s.targetShape:void 0,u=r.id,d={evt:e,pointerId:u},f=l!==c;s.targetShape=c&&c.isListening()?c:void 0,f&&l&&(l._fireAndBubble(t.pointerout,{...d},c),l._fireAndBubble(t.pointerleave,{...d},c)),c&&c.isListening()?(a=!0,f&&(c._fireAndBubble(t.pointerover,{...d},l),c._fireAndBubble(t.pointerenter,{...d},l)),i[c._id]||(i[c._id]=!0,c._fireAndBubble(t.pointermove,{...d}))):l&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:u})}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){let t=er(e.type),n=L._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r={},i=!1;this._changedPointerPositions.forEach(a=>{let o=`${n}:${a.id}`,s=this._pointerStates.get(o),c=s?.clickStartShape!==void 0,l=s?.clickStartShape;s?.targetShape&&n!==`touch`?this._pointerStates.set(o,{targetShape:s.targetShape}):this._pointerStates.delete(o);let u=Wt(a.id)||this.getIntersection(a),d=u&&r[u._id];u&&(u.releaseCapture(a.id),r[u._id]=!0);let f=a.id,p={evt:e,pointerId:f},m=u&&u.isListening()?u:null,h=this._lastClicks[n],g=c&&(!m||l===m),_=g&&h&&s?.lastClick===h&&h.shape===m&&Date.now()-h.time{let r=L._getEventType(e.type),i=`${r}:${n.id}`;this._cancelClick(n.id,r);let a=this._pointerStates.get(i)?.targetShape;a&&r!==`touch`?this._pointerStates.set(i,{targetShape:a}):this._pointerStates.delete(i);let o=Wt(n.id)||this.getIntersection(n),s={evt:e,pointerId:n.id};o?(t&&o._fireAndBubble(t.pointercancel,{...s}),o._fireAndBubble(Rn,{...s})):t&&this._fire(t.pointercancel,{...s,target:this,currentTarget:this}),Jt(n.id),t&&r===`touch`&&a?.getStage()===this&&(a._fireAndBubble(t.pointerout,{...s}),a._fireAndBubble(t.pointerleave,{...s}))})}_lostpointercapture(e){Wt(e.pointerId,this)&&Jt(e.pointerId)}setPointersPositions(e){let t=this._getContentPosition(),n=null,r=null;e||=window.event,e.touches===void 0?(this._pointerEventType=e.pointerId===void 0?`mouse`:`pointer`,n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:L._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:L._getFirstPointerId(e)}]):(this._pointerEventType=`touch`,this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,e=>{this._pointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,e=>{this._changedPointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}))}_setPointerPosition(e){L.warn(`Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.`),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};let e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferHitCanvas=new Vt({pixelRatio:1,width:0,height:0}),!I.isBrowser)return;let e=this.container();if(!e)throw`Stage has no container. A container is required.`;e.innerHTML=``,this.content=e.ownerDocument.createElement(`div`),this.content.style.position=`relative`,this.content.style.userSelect=`none`,this.content.className=`konvajs-content`,this.content.setAttribute(`role`,`presentation`),e.appendChild(this.content),ar(this._getOwnerWindow()),this._resizeDOM()}cache(){return L.warn(`Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.`),this}clearCache(){return this}batchDraw(){var e;return(e=this.children)==null||e.forEach(function(e){e.batchDraw()}),this}};or.prototype.nodeType=En,Je(or),V.addGetterSetter(or,`container`),V.addGetterSetter(or,`eventBatchFunc`);var sr=`hasShadow`,cr=`hasFill`,lr=`hasStroke`,ur=`shadowRGBA`,dr=`patternImage`,fr=`linearGradient`,pr=`radialGradient`,mr;function hr(){return mr||(mr=L.createCanvasElement().getContext(`2d`),mr)}var gr={};function _r(e){let t=this.attrs.fillRule;t?e.fill(t):e.fill()}function vr(e){e.stroke()}function yr(){this._clearCache(sr)}function br(){this._clearCache(cr)}function xr(){this._clearCache(lr)}function Sr(){this._clearCache(ur)}function Cr(){this._clearCache(dr)}function wr(){this._clearCache(fr)}function Tr(){this._clearCache(pr)}var U=class e extends H{constructor(e){super(e);let t,n=0;for(;t=L.getHitColor(),!t||t in gr;)if(n++,n>=1e4){L.warn(`Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it.`),t=L.getRandomColor();break}this.colorKey=t,gr[t]=this}getContext(){return L.warn(`shape.getContext() method is deprecated. Please do not use it.`),this.getLayer().getContext()}getCanvas(){return L.warn(`shape.getCanvas() method is deprecated. Please do not use it.`),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(sr,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(dr,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){let e=hr().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||`repeat`);if(e&&e.setTransform){let t=new Ze;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(I.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());let n=t.getMatrix(),r=typeof DOMMatrix>`u`?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(fr,this.__getLinearGradient)}__getLinearGradient(){let e=this.fillLinearGradientColorStops();if(e){let t=hr(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),i=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let t=0;t0}destroy(){return H.prototype.destroy.call(this),delete gr[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(!(this.attrs.perfectDrawEnabled??!0))return!1;let n=e||this.hasFill(),r=this.hasStroke(),i=!this._isUnderCache&&t!==1;if(n&&r&&i)return!0;let a=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(n&&r&&a&&o)}setStrokeHitEnabled(e){L.warn(`strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.`),e?this.hitStrokeWidth(`auto`):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){let e=this.attrs.selfRectFunc;if(e)return{...e.call(this,this)};let t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}_getSelfRectForDrawing(){return this.getSelfRect()}getClientRect(e={}){let t=this._getCachedSceneRect(e);if(t)return t;let n=e.skipTransform,r=e.relativeTo,i=e._forDrawing,a=i?this._getSelfRectForDrawing():this.getSelfRect();i&&!this.strokeScaleEnabled()?a=this._transformedRect(a,r):(a.width<0||a.height<0)&&(a=new Ze()._getTransformedRect(a));let o=!e.skipStroke&&this.hasStroke()?i?this._getStrokePadding()*2:this.strokeWidth():0,s=o,c=o,l;if(!i&&o&&!this.strokeScaleEnabled()){let e=this;for(;e&&!e.isCached()&&!e._isUnderCache;)e=e.parent;let[t,i,a,o]=this.getAbsoluteTransform(e).getMatrix(),u=Math.abs(t*o-i*a);if(u)s*=Math.hypot(a,o)/u,c*=Math.hypot(t,i)/u;else if(!n&&(s=c=0,l=e?e.getAbsoluteTransform().copy():new Ze,r)){let e=r.getAbsoluteTransform(),[t,n,i,a]=e.getMatrix();l=t*a-n*i?e.copy().invert().multiply(l):new Ze}}let u={x:a.x-s/2,y:a.y-c/2,width:a.width+s,height:a.height+c};if(i&&this.strokeScaleEnabled()&&(u=this._transformedRect(u,r)),!e.skipShadow&&this.hasShadow()){let e=i?this.getAbsoluteScale():{x:1,y:1},t=this.shadowOffsetX()*e.x,n=this.shadowOffsetY()*e.y,r=this.shadowBlur()*(i?2*Math.min(Math.abs(e.x),Math.abs(e.y)):1);u.x+=Math.min(0,t)-r,u.y+=Math.min(0,n)-r,u.width+=Math.abs(t)+r*2,u.height+=Math.abs(n)+r*2}if(i)return u;if(!n){let e=this._transformedRect(u,r);if(l){let[t,n,r,i]=l.getMatrix(),a=o*Math.hypot(t,r)/2,s=o*Math.hypot(n,i)/2;e.x-=a,e.y-=s,e.width+=a*2,e.height+=s*2}return e}return u}_getStrokePadding(e=this.miterLimit()||10){return this.attrs.sceneFunc&&(e=this.miterLimit()||10),Math.abs(this.strokeWidth())/2*Math.max(this.lineCap()===`square`?Math.SQRT2:1,(this.lineJoin()||`miter`)===`miter`?e:1)}drawScene(t,n){let r=this.getLayer(),i=t||r.getCanvas(),a=i.getContext(),o=this._getCanvasCache(),s=this.getSceneFunc(),c=this.hasShadow(),l=n===this;if(!(n?this._isVisible(n):this.isVisible())&&!l)return this;if(o){a.save();let e=this.getAbsoluteTransform(n).getMatrix();return a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(a),a.restore(),this}if(!s)return this;a.save();try{if(i.width&&i.height&&this._useBufferCanvas(void 0,a._getOpacity(this))){let t=!!a._opacityRoot||!!this.attrs.selfRectFunc&&this.getSelfRect===e.prototype.getSelfRect||!this.attrs.sceneFunc&&!this.attrs.charRenderFunc&&qe.has(this.constructor),r=i._prepareIsolationCanvas(t?this.getClientRect({_forDrawing:!0,relativeTo:n,skipShadow:!0}):void 0),o=r.getContext();o.save(),o._applyLineJoin(this),o._applyMiterLimit(this);let u=this.getAbsoluteTransform(n).getMatrix();o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),s.call(this,o,this),o.restore(),c&&a._applyShadow(this),l||(a._applyOpacity(this),a._applyGlobalCompositeOperation(this)),a._drawDeviceBuffer(r)}else{if(a._applyLineJoin(this),a._applyMiterLimit(this),!l){let e=this.getAbsoluteTransform(n).getMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),a._applyOpacity(this),a._applyGlobalCompositeOperation(this)}c&&a._applyShadow(this),s.call(this,a,this)}}catch(e){throw i._releaseIsolationCanvas(),e}finally{a.restore()}return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n.hitCanvas,i=r&&r.getContext(),a=this.hitFunc()||this.sceneFunc(),o=this._getCachedHitCanvas(t);if(this.colorKey||L.warn(`Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()`),o){i.save();let e=this.getAbsoluteTransform(t).getMatrix();return i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i,o),i.restore(),this}if(!a)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5])}try{a.call(this,i,this)}finally{i.restore()}return this}drawHitFromCache(e=0){let t=this._getCachedSceneCanvas(),n=this._getCachedHitCanvas(),r=n.getContext(),i=n.getWidth(),a=n.getHeight();r.clear(),r.drawImage(t._canvas,0,0,i/n.pixelRatio,a/n.pixelRatio);try{let t=r.getImageData(0,0,i,a),n=t.data,o=n.length,s=L._hexToRgb(this.colorKey);for(let t=0;te?(n[t]=s.r,n[t+1]=s.g,n[t+2]=s.b,n[t+3]=255):n[t+3]=0;r.putImageData(t,0,0)}catch(e){L.error(`Unable to draw hit graph from cached scene canvas. `+e.message)}return this}hasPointerCapture(e){return z(e,this)}setPointerCapture(e){Kt(e,this)}releaseCapture(e){Jt(e,this)}};U.prototype._fillFunc=_r,U.prototype._strokeFunc=vr,U.prototype._fillFuncHit=_r,U.prototype._strokeFuncHit=vr,U.prototype._centroid=!1,U.prototype.nodeType=`Shape`,Je(U),U.prototype.on(`shadowColorChange.konva shadowBlurChange.konva shadowOffsetXChange.konva shadowOffsetYChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,yr),U.prototype.on(`shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,Sr),U.prototype.on(`fillEnabledChange.konva fillChange.konva fillPatternImageChange.konva fillLinearGradientColorStopsChange.konva fillRadialGradientColorStopsChange.konva`,br),U.prototype.on(`strokeEnabledChange.konva strokeWidthChange.konva strokeChange.konva strokeLinearGradientColorStopsChange.konva`,xr),U.prototype.on(`fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva`,Cr),U.prototype.on(`fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva`,wr),U.prototype.on(`fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva`,Tr),V.addGetterSetter(U,`stroke`,void 0,en()),V.addGetterSetter(U,`strokeWidth`,2,B()),V.addGetterSetter(U,`fillAfterStrokeEnabled`,!1),V.addGetterSetter(U,`hitStrokeWidth`,`auto`,Qt()),V.addGetterSetter(U,`strokeHitEnabled`,!0,nn()),V.addGetterSetter(U,`perfectDrawEnabled`,!0,nn()),V.addGetterSetter(U,`shadowForStrokeEnabled`,!0,nn()),V.addGetterSetter(U,`lineJoin`),V.addGetterSetter(U,`lineCap`),V.addGetterSetter(U,`miterLimit`),V.addGetterSetter(U,`sceneFunc`),V.addGetterSetter(U,`hitFunc`),V.addGetterSetter(U,`selfRectFunc`),V.addGetterSetter(U,`dash`),V.addGetterSetter(U,`dashOffset`,0,B()),V.addGetterSetter(U,`shadowColor`,void 0,$t()),V.addGetterSetter(U,`shadowBlur`,0,B()),V.addGetterSetter(U,`shadowOpacity`,1,B()),V.addComponentsGetterSetter(U,`shadowOffset`,[`x`,`y`]),V.addGetterSetter(U,`shadowOffsetX`,0,B()),V.addGetterSetter(U,`shadowOffsetY`,0,B()),V.addGetterSetter(U,`fillPatternImage`),V.addGetterSetter(U,`fill`,void 0,en()),V.addGetterSetter(U,`fillPatternX`,0,B()),V.addGetterSetter(U,`fillPatternY`,0,B()),V.addGetterSetter(U,`fillLinearGradientColorStops`),V.addGetterSetter(U,`strokeLinearGradientColorStops`),V.addGetterSetter(U,`fillRadialGradientStartRadius`,0),V.addGetterSetter(U,`fillRadialGradientEndRadius`,0),V.addGetterSetter(U,`fillRadialGradientColorStops`),V.addGetterSetter(U,`fillPatternRepeat`,`repeat`),V.addGetterSetter(U,`fillEnabled`,!0),V.addGetterSetter(U,`strokeEnabled`,!0),V.addGetterSetter(U,`shadowEnabled`,!0),V.addGetterSetter(U,`dashEnabled`,!0),V.addGetterSetter(U,`strokeScaleEnabled`,!0),V.addGetterSetter(U,`fillPriority`,`color`),V.addComponentsGetterSetter(U,`fillPatternOffset`,[`x`,`y`]),V.addGetterSetter(U,`fillPatternOffsetX`,0,B()),V.addGetterSetter(U,`fillPatternOffsetY`,0,B()),V.addComponentsGetterSetter(U,`fillPatternScale`,[`x`,`y`]),V.addGetterSetter(U,`fillPatternScaleX`,1,B()),V.addGetterSetter(U,`fillPatternScaleY`,1,B()),V.addComponentsGetterSetter(U,`fillLinearGradientStartPoint`,[`x`,`y`]),V.addComponentsGetterSetter(U,`strokeLinearGradientStartPoint`,[`x`,`y`]),V.addGetterSetter(U,`fillLinearGradientStartPointX`,0),V.addGetterSetter(U,`strokeLinearGradientStartPointX`,0),V.addGetterSetter(U,`fillLinearGradientStartPointY`,0),V.addGetterSetter(U,`strokeLinearGradientStartPointY`,0),V.addComponentsGetterSetter(U,`fillLinearGradientEndPoint`,[`x`,`y`]),V.addComponentsGetterSetter(U,`strokeLinearGradientEndPoint`,[`x`,`y`]),V.addGetterSetter(U,`fillLinearGradientEndPointX`,0),V.addGetterSetter(U,`strokeLinearGradientEndPointX`,0),V.addGetterSetter(U,`fillLinearGradientEndPointY`,0),V.addGetterSetter(U,`strokeLinearGradientEndPointY`,0),V.addComponentsGetterSetter(U,`fillRadialGradientStartPoint`,[`x`,`y`]),V.addGetterSetter(U,`fillRadialGradientStartPointX`,0),V.addGetterSetter(U,`fillRadialGradientStartPointY`,0),V.addComponentsGetterSetter(U,`fillRadialGradientEndPoint`,[`x`,`y`]),V.addGetterSetter(U,`fillRadialGradientEndPointX`,0),V.addGetterSetter(U,`fillRadialGradientEndPointY`,0),V.addGetterSetter(U,`fillPatternRotation`,0),V.addGetterSetter(U,`fillRule`,void 0,$t()),V.backCompat(U,{dashArray:`dash`,getDashArray:`getDash`,setDashArray:`setDash`,drawFunc:`sceneFunc`,getDrawFunc:`getSceneFunc`,setDrawFunc:`setSceneFunc`,drawHitFunc:`hitFunc`,getDrawHitFunc:`getHitFunc`,setDrawHitFunc:`setHitFunc`});var Er=`beforeDraw`,Dr=`draw`,Or=10,kr=256;function Ar(e,t){return e[t+3]>=128?gr[L.getHitColorKey(e[t],e[t+1],e[t+2])]:void 0}var jr=class extends Tn{constructor(e){super(e),this.canvas=new Bt,this.hitCanvas=new Vt({pixelRatio:1}),this._waitingForDraw=!1,this.on(`visibleChange.konva`,this._checkVisibility),this._checkVisibility(),this.on(`imageSmoothingEnabledChange.konva`,this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);let t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e{this._waitingForDraw=!1,this.draw()},this.getStage()?._getOwnerWindow())),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=this._getIntersection(e);if(t.shape)return t.shape;if(!t.antialiased)return null;let n=this.hitCanvas.pixelRatio,r=Math.floor(e.x*n),i=Math.floor(e.y*n),a=e=>this.hitCanvas.context.getImageData(r-e,i-e,e*2+1,e*2+1).data,o=Or,s=o*2+1,c=a(o),l=c[(o*s+o)*4+3];for(let e=1;e<=kr;e++){e>o&&(o=Math.min(kr,o*2),s=o*2+1,c=a(o));let t=0;for(let n=-e;n<=e;n++){let r=Math.abs(n)===e?1:e*2;for(let i=-e;i<=e;i+=r){let e=((n+o)*s+i+o)*4,r=Ar(c,e);if(r)return r;t=Math.max(t,c[e+3])}}if(t<=l&&t!==255)return null;l=t}return null}_getIntersection(e){if(!this.hitCanvas.width||!this.hitCanvas.height)return{};let t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.floor(e.x*t),Math.floor(e.y*t),1,1).data,r=Ar(n,0);return r?{shape:r}:n[3]>0?{antialiased:!0}:{}}drawScene(e,t){let n=this.getLayer(),r=e||n&&n.getCanvas();return this._fire(Er,{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),Tn.prototype.drawScene.call(this,r,t),r._trimIsolationCanvas(),this._fire(Dr,{node:this}),this}shouldDrawHit(e){if(!super.shouldDrawHit(e))return!1;if(e||I.hitOnDragEnabled)return!0;let t=!1;return R._dragElements.forEach(e=>{e.dragStatus===`dragging`&&(e.node===this.getStage()||e.node.getLayer()===this)&&(t=!0)}),!t&&!I.Transformer?._isLayerTransforming(this)}drawHit(e,t){let n=this.getLayer(),r=e||n&&n.hitCanvas;return!e&&n&&(n._syncHitCanvasSize(),n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear()),Tn.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){L.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening(e)}getHitGraphEnabled(e){return L.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;let e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return this.getCanvas()._releaseIsolationCanvas(),L.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};jr.prototype.nodeType=`Layer`,Je(jr),V.addGetterSetter(jr,`imageSmoothingEnabled`,!0),V.addGetterSetter(jr,`clearBeforeDraw`,!0),V.addOverloadedGetterSetter(jr,`hitGraphEnabled`);var Mr=class extends jr{constructor(e){super(e),this.listening(!1),L.warn(`Konva.FastLayer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.`)}};Mr.prototype.nodeType=`FastLayer`,Je(Mr);var Nr=class extends Tn{_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&L.throw(`You may only add groups and shapes to groups.`)}_drawChildNodes(e,t,n){if(e!==`drawScene`||!this.isolated()||n===this)return super._drawChildNodes(e,t,n);if(!t.width||!t.height)return;let r=t.getContext(),i=t._prepareIsolationCanvas(this.getClientRect({_forDrawing:!0,relativeTo:n})),a=i.getContext();a._opacityRoot=this,r.save();try{super._drawChildNodes(e,i,n),r._applyOpacity(this),r._drawDeviceBuffer(i)}catch(e){throw t._releaseIsolationCanvas(),e}finally{r.restore(),a._opacityRoot=void 0}}};V.addGetterSetter(Nr,`isolated`,!1,nn()),Nr.prototype.nodeType=`Group`,Je(Nr);var Pr=Ke.performance?.now?()=>Ke.performance.now():Date.now,Fr=class e{constructor(t,n){this.id=e.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Pr(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(e){return this.layers=e?[].concat(e):[],this}getLayers(){return this.layers}addLayer(e){let t=this.layers,n=t.length;for(let r=0;r{Array.from(this.animations).forEach(t=>{this.animations.has(t)&&(t._updateFrameObject(Pr()),!(t.func&&t.func.call(t,t.frame)===!1)&&t.layers.forEach(t=>t&&e.add(t)))})}),e.forEach(e=>e.batchDraw())}static _animationLoop(){let t=e;t.animations.size?(t._runFrames(),L.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,L.requestAnimFrame(this._animationLoop))}};Fr.animations=new Set,Fr.animIdCounter=0,Fr.animRunning=!1;var Ir={node:1,duration:1,easing:1,onFinish:1,onUpdate:1,onReset:1,yoyo:1},Lr=1,Rr=2,zr=3,Br=[`fill`,`stroke`,`shadowColor`],Vr=0;function Hr(e){return L.colorToRGBA(e)||L.throw(`can not tween the color "`+e+`", because it is not a valid color.`)}function Ur(e,t){return{r:t.r-e.r,g:t.g-e.g,b:t.b-e.b,a:t.a-e.a}}function Wr(e,t,n){return`rgba(`+Math.round(e.r+t.r*n)+`,`+Math.round(e.g+t.g*n)+`,`+Math.round(e.b+t.b*n)+`,`+(e.a+t.a*n)+`)`}var Gr=class{constructor(e,t,n,r,i,a,o){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=a,this._change=0,this.prevPos=0,this.yoyo=o,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=i-this.begin,this.pause()}fire(e){let t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=Rr,this._startTime=this.getTimer()-this._time,this.fire(`onPlay`),this.onEnterFrame()}reverse(){this.state=zr,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.fire(`onReverse`),this.onEnterFrame()}seek(e){this.pause(),this._time=e,this.update(),this.fire(`onSeek`)}reset(){this.pause(),this._time=0,this.update(),this.fire(`onReset`)}finish(){this.pause(),this._time=this.duration,this.update(),this.fire(`onFinish`)}update(){this.setPosition(this.getPosition(this._time)),this.fire(`onUpdate`)}onEnterFrame(){let e=this.getTimer()-this._startTime;this.state===Rr?this.setTime(e):this.state===zr&&this.setTime(this.duration-e)}pause(){this.state=Lr,this.fire(`onPause`)}getTimer(){return Date.now()}},Kr=class e{constructor(t){let n=this,r=t.node,i=r._id,a=t.easing||qr.Linear,o=!!t.yoyo,s,c;s=t.duration===void 0?.3:t.duration===0?.001:t.duration,this.node=r,this._id=Vr++;let l=r.getLayer()||(r instanceof I.Stage?r.getLayers():null);for(c in l||L.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Fr(function(){n.tween.onEnterFrame()},l),this.tween=new Gr(c,function(e){n._tweenFunc(e)},a,0,1,s*1e3,o),this._addListeners(),e.attrs[i]||(e.attrs[i]={}),e.attrs[i][this._id]||(e.attrs[i][this._id]={}),e.tweens[i]||(e.tweens[i]={}),t)Ir[c]===void 0&&this._addAttr(c,t[c]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){if(L._isPlainObject(n)){for(let e in n)this._addAttr(t+L._capitalize(e),n[e]);return}let r=this.node,i=r._id,a,o,s,c,l=e.tweens[i][t];l!==void 0&&delete e.attrs[i][l][t];let u=r.getAttr(t);if(L._isArray(n)||L._isArray(u)){if(a=[],c=u,s=n,u=L._isArray(u)?u.slice():Array(n.length).fill(u||0),L._isArray(n)||(n=Array(u.length).fill(n)),o=Math.max(n.length,u.length),t===`points`&&n.length!==u.length&&(n.length>u.length?u=L._prepareArrayForTween(u,n,r.closed()):n=L._prepareArrayForTween(n,u,r.closed())),t.endsWith(`ColorStops`))for(let e=0;ethis.destroy(),r=()=>{this.node.off(t).on(t,n),this.anim.start()};this.tween.onPlay=r,this.tween.onReverse=r,this.tween.onPause=()=>{this.node.off(t),this.anim.stop()};let i=(t,n)=>{let r=e.attrs[this.node._id]?.[this._id];if(r){for(let e in r)r[e][t]!==void 0&&this.node.setAttr(e,r[e][t]);n?.call(this)}};this.tween.onFinish=()=>i(`trueEnd`,this.onFinish),this.tween.onReset=()=>i(`trueStart`,this.onReset),this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(e*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){let t=this.node._id,n=this._id,r=e.attrs[t]?.[n],i=e.tweens[t];if(this.pause(),this.anim&&this.anim.stop(),r){if(i){for(let e in r)delete i[e];Object.keys(i).length===0&&delete e.tweens[t]}delete e.attrs[t][n],Object.keys(e.attrs[t]).length===0&&delete e.attrs[t]}}};Kr.attrs={},Kr.tweens={},H.prototype.to=function(e){let t=e.onFinish,n=new Kr({...e,node:this,onFinish(){n.destroy(),t&&t()}});return n.play(),n};var qr={BackEaseIn(e,t,n,r){return n*(e/=r)*e*(2.70158*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*(2.70158*e+1.70158)+1)+t},BackEaseInOut(e,t,n,r){let i=1.70158;return(e/=r/2)<1?n/2*(e*e*(((i*=1.525)+1)*e-i))+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t},ElasticEaseIn(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,!i||i=o?o:(s%o+o)%o,l=Math.cos(Math.min(c,Math.PI)),u=Math.sin(Math.min(Math.max(Math.PI,c),3*Math.PI/2)),d=Math.sin(Math.min(c,Math.PI/2)),f=l*(l>0?n:r),p=1*r,m=u*(u>0?n:r),h=d*(d>0?r:n);return{x:f,y:i?-1*h:m,width:p-f,height:h-m}}};Yr.prototype._centroid=!0,Yr.prototype.className=`Arc`,Yr.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`,`angle`,`clockwise`],Je(Yr,!0),V.addGetterSetter(Yr,`innerRadius`,0,B()),V.addGetterSetter(Yr,`outerRadius`,0,B()),V.addGetterSetter(Yr,`angle`,0,B()),V.addGetterSetter(Yr,`clockwise`,!1,nn());var Xr=[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],Zr=[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],Qr=(e,t,n)=>{let r=n/2,i=0;for(let n=0;nQr([e[0],e[0]+2/3*(e[1]-e[0]),e[2]+2/3*(e[1]-e[2]),e[2]],[t[0],t[0]+2/3*(t[1]-t[0]),t[2]+2/3*(t[1]-t[2]),t[2]],n);function ei(e,t,n){let r=1-n,i=r*r,a=2*r*n,o=n*n,s=i*(3*(e[1]-e[0]))+a*(3*(e[2]-e[1]))+o*(3*(e[3]-e[2])),c=i*(3*(t[1]-t[0]))+a*(3*(t[2]-t[1]))+o*(3*(t[3]-t[2]));return Math.sqrt(s*s+c*c)}var ti=(e,t,n)=>{let r=1,i=e/t,a=(e-n(i))/t,o=0;for(;r>.001;){let s=n(i+a),c=Math.abs(e-s)/t;if(c500)break}return i},ni=(e,t,n,r)=>{let i=1-r;return i*i*e+2*i*r*t+r*r*n},ri=(e,t,n,r,i,a)=>{let o=[];for(let s of[[e,n,i],[t,r,a]]){let c=(s[0]-s[1])/(s[0]-2*s[1]+s[2]);c>0&&c<1&&o.push(ni(e,n,i,c),ni(t,r,a,c))}return o},ii=(e,t,n,r,i)=>{let a=1-i;return a*a*a*e+3*a*a*i*t+3*a*i*i*n+i*i*i*r},ai=(e,t,n,r,i,a,o,s)=>{let c=[];for(let l of[[e,n,i,o],[t,r,a,s]]){let u=-3*l[0]+9*l[1]-9*l[2]+3*l[3],d=6*l[0]-12*l[1]+6*l[2],f=-3*l[0]+3*l[1],p=d*d-4*u*f;if(p<0)continue;let m=-(d+(d<0?-1:1)*Math.sqrt(p))/2;for(let l of[m/u,f/m])l>0&&l<1&&c.push(ii(e,n,i,o,l),ii(t,r,a,s,l))}return c};function oi(e,t,n,r,i,a,o){let s=Math.sqrt((n-e)**2+(r-t)**2),c=Math.sqrt((i-n)**2+(a-r)**2),l=s+c;if(l===0)return[n,r,n,r];let u=o*s/l,d=o*c/l;return[n-u*(i-e),r-u*(a-t),n+d*(i-e),r+d*(a-t)]}function si(e,t){let n=e.length,r=[];for(let i=2;i4}_eachTensionSegment(e,t){let n=this.points(),r=n.length,i=this.closed(),a=this.getTensionPoints(),o=a.length,s=n[0],c=n[1],l=i?0:4;for(i||(e(s,c,a[0],a[1],a[2],a[3]),s=a[2],c=a[3]);le.quadraticCurveTo(r,i,a,o),(t,n,r,i,a,o,s,c)=>e.bezierCurveTo(r,i,a,o,s,c));else if(i)for(a=2;at.push(a,o,...ri(e,n,r,i,a,o)),(e,n,r,i,a,o,s,c)=>t.push(s,c,...ai(e,n,r,i,a,o,s,c))),e=t}else this.bezier()&&(e=[e[0],e[1],...ci(e)]);return L._getPointsRect(e)}};li.prototype.className=`Line`,li.prototype._attrsAffectingSize=[`points`,`bezier`,`tension`,`closed`],Je(li,!0),V.addGetterSetter(li,`closed`,!1),V.addGetterSetter(li,`bezier`,!1),V.addGetterSetter(li,`tension`,0,B()),V.addGetterSetter(li,`points`,[],tn());var ui={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7,z:0},di=Math.PI*2,fi=class e extends U{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on(`dataChange.konva`,function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=e.parsePathData(this.data()),this.pathLength=e.getPathLength(this.dataArray)}_sceneFunc(e){let t=this.dataArray;e.beginPath();let n=!1;for(let r=0;r{if(((n-s)*Math.sign(c)%di+di)%di0&&t<=o;)o-=n[--a].pathLength;for(t-=o;an[a].pathLength;){let e=n[a].pathLength;t-=e,o+=e,++a}if(r&&aQr([c.start.x,l[0],l[2],l[4]],[c.start.y,l[1],l[3],l[5]],e)),c.start.x,c.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case`Q`:return e.getPointOnQuadraticBezier(ti(t,c.pathLength,e=>$r([c.start.x,l[0],l[2]],[c.start.y,l[1],l[3]],e)),c.start.x,c.start.y,l[0],l[1],l[2],l[3]);case`A`:return e.getPointOnEllipticalArc(l[0],l[1],l[2],l[3],l[2]===l[3]?l[4]+l[5]*t/c.pathLength:e._walkArc(l,t).theta,l[6])}return null}static getPointOnLine(e,t,n,r,i,a,o){a??=t,o??=n;let s=this.getLineLength(t,n,r,i);if(s<1e-10)return{x:t,y:n};if(r===t)return{x:a,y:o+(i>n?e:-e)};let c=(i-n)/(r-t),l=Math.sqrt(e*e/(1+c*c))*(r1&&(t[0]===`0`||t[0]===`1`);)f.push(+t[0]),p++,t=t.slice(1);let n=parseFloat(t);f.push(isNaN(n)?0:n),p>=0&&(p=(p+1)%7)}let m=0;for(;m=n)return{theta:d+(p-d)*((n-f)/h),length:n};f+=h,u=m,d=p}return{theta:d,length:f}}static calcLength(t,n,r,i){let a=e;switch(r){case`L`:return a.getLineLength(t,n,i[0],i[1]);case`C`:return Qr([t,i[0],i[2],i[4]],[n,i[1],i[3],i[5]],1);case`Q`:return $r([t,i[0],i[2]],[n,i[1],i[3]],1);case`A`:return a._walkArc(i,1/0).length}return 0}static convertEndpointToCenterParameterization(e,t,n,r,i,a,o,s,c){let l=Math.PI/180*c,u=Math.cos(l)*(e-n)/2+Math.sin(l)*(t-r)/2,d=-1*Math.sin(l)*(e-n)/2+Math.cos(l)*(t-r)/2,f=u*u/(o*o)+d*d/(s*s);f>1&&(o*=Math.sqrt(f),s*=Math.sqrt(f));let p=Math.sqrt((o*o*(s*s)-o*o*(d*d)-s*s*(u*u))/(o*o*(d*d)+s*s*(u*u)));i===a&&(p*=-1),isNaN(p)&&(p=0);let m=p*o*d/s,h=p*-s*u/o,g=(e+n)/2+Math.cos(l)*m-Math.sin(l)*h,_=(t+r)/2+Math.sin(l)*m+Math.cos(l)*h,v=function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])},y=function(e,t){return(e[0]*t[0]+e[1]*t[1])/(v(e)*v(t))},b=function(e,t){return(e[0]*t[1]=1&&(w=0),a===0&&w>0&&(w-=2*Math.PI),a===1&&w<0&&(w+=2*Math.PI),[g,_,o,s,x,w,l,a]}};fi.prototype.className=`Path`,fi.prototype._attrsAffectingSize=[`data`],Je(fi,!0),V.addGetterSetter(fi,`data`);var pi=class extends li{_getStrokePadding(){return super._getStrokePadding(this.pointerAtBeginning()||this.pointerAtEnding()?this.miterLimit()||10:void 0)}_sceneFunc(e){super._sceneFunc(e);let t=this.points(),n=t.length;if(n<4)return;let r=this.pointerLength(),i=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(t[n-2],t[n-1]),e.rotate(this._getPointerAngle(!1)),e.moveTo(0,0),e.lineTo(-r,i/2),e.lineTo(-r,-i/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(t[0],t[1]),e.rotate(this._getPointerAngle(!0)),e.moveTo(0,0),e.lineTo(-r,i/2),e.lineTo(-r,-i/2),e.closePath(),e.restore(),this.__fillStroke(e))}_getPointerAngle(e){let t=this.points(),n=t.length,r=this.tension()!==0&&n>4,i=r?this.getTensionPoints():t,a=e?t[0]:t[n-2],o=e?t[1]:t[n-1],s=0,c=0;if(r&&e)s=a-(i[0]+i[2])/2,c=o-(i[1]+i[3])/2;else if(r){let e=i[i.length-4],t=i[i.length-3],n=i[i.length-2],r=i[i.length-1],l=fi.calcLength(e,t,`Q`,[n,r,a,o]),u=fi.getPointOnQuadraticBezier(l?Math.max(0,1-this.pointerLength()/l):0,e,t,n,r,a,o);s=a-u.x,c=o-u.y}for(let t=e?0:i.length-2;!s&&!c&&t>=0&&t{this._requestDraw()},this.on(`imageChange.konva`,e=>{this._removeImageLoad(e.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){var e;let t=this.image();t?.complete&&t.src||t?.readyState>=2||(e=t?.addEventListener)==null||e.call(t,`videoWidth`in t?`loadeddata`:`load`,this._loadListener)}_removeImageLoad(e){var t;(t=e?.removeEventListener)==null||t.call(e,`videoWidth`in e?`loadeddata`:`load`,this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=!!this.cornerRadius(),r=this.hasShadow();return n&&r?!0:super._useBufferCanvas(!0,t)}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),i=this.attrs.image;if((this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?L.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),i){r&&e.clip();let a=this.attrs.cropWidth,o=this.attrs.cropHeight;a&&o?e.drawImage(i,this.cropX(),this.cropY(),a,o,0,0,t,n):e.drawImage(i,0,0,t,n)}}_hitFunc(e){let t=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?L.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){let e=this.image();return this.attrs.width??e?.videoWidth??e?.width??0}getHeight(){let e=this.image();return this.attrs.height??e?.videoHeight??e?.height??0}static fromURL(t,n,r=null){let i=L.createImageElement();i.onload=()=>{i.onload=i.onerror=null,n(new e({image:i}))},i.onerror=r,i.crossOrigin=`Anonymous`,i.src=t}};gi.prototype.className=`Image`,gi.prototype._attrsAffectingSize=[`image`],Je(gi,!0),V.addGetterSetter(gi,`cornerRadius`,0,Zt(4)),V.addGetterSetter(gi,`image`),V.addComponentsGetterSetter(gi,`crop`,[`x`,`y`,`width`,`height`]),V.addGetterSetter(gi,`cropX`,0,B()),V.addGetterSetter(gi,`cropY`,0,B()),V.addGetterSetter(gi,`cropWidth`,0,B()),V.addGetterSetter(gi,`cropHeight`,0,B());var _i=typeof Intl<`u`&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:`grapheme`}):null;function vi(e){return e/15}function yi(e){return _i?Array.from(_i.segment(e),e=>e.segment):e.match(/\p{RI}\p{RI}|\P{M}(?:\p{M}|\p{Emoji_Modifier}|\uFE0F|\u200D\P{M})*|\p{M}+/gu)||[]}var bi=`auto`,xi=`center`,Si=`inherit`,Ci=`justify`,wi=`Change.konva`,Ti=`2d`,Ei=`-`,Di=`left`,Oi=`text`,ki=`Text`,Ai=`top`,ji=`bottom`,Mi=`middle`,Ni=`normal`,Pi=`px `,Fi=` `,Ii=`right`,Li=`rtl`,Ri=`word`,zi=`char`,Bi=`none`,Vi=`…`,Hi=[`direction`,`fontFamily`,`fontSize`,`fontStyle`,`fontVariant`,`padding`,`align`,`verticalAlign`,`lineHeight`,`text`,`width`,`height`,`wrap`,`ellipsis`,`letterSpacing`],Ui=null;function Wi(){if(Ui!==null)return Ui;Ui=!1;let e;try{e=L.createCanvasElement(),e.width=10,e.height=10;let t=e.getContext(Ti);if(t){t.globalAlpha=0,t.shadowColor=`black`,t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle=`black`,t.font=`10px Arial`,t.fillText(`X`,0,10);let e=t.getImageData(0,0,10,10).data;for(let t=3;t0){Ui=!0;break}}}catch{}finally{e&&L.releaseCanvas(e)}return Ui}function Gi(e){return e.split(`,`).map(e=>{e=e.trim();let t=e.indexOf(` `)>=0,n=e.indexOf(`"`)>=0||e.indexOf(`'`)>=0;return t&&!n&&(e=`"${e}"`),e}).join(`, `)}var Ki;function qi(){return Ki||(Ki=L.createCanvasElement().getContext(Ti),Ki)}function Ji(e){this._partialFillStyle&&e.setAttr(`fillStyle`,this._partialFillStyle),e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function Yi(e){e.setAttr(`miterLimit`,2),this._partialStrokeStyle&&e.setAttr(`strokeStyle`,this._partialStrokeStyle),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function Xi(e){return e||={},e.fill||e.fillLinearGradientColorStops||e.fillRadialGradientColorStops||e.fillPatternImage?e:{...e,fill:`black`}}var W=class extends U{constructor(e){super(Xi(e)),this._partialTextX=0,this._partialTextY=0,this._baselineShift=0,this._setTextData()}_sceneFunc(e){let t=this.textArr,n=t.length;if(!this.text())return;let r=this.padding(),i=this.fontSize(),a=this.lineHeight()*i,o=this.direction(),s=this.align(),c=this.getWidth(),l=this.letterSpacing(),u=this.charRenderFunc(),d=this.textDecoration(),f=d.indexOf(`underline`)!==-1,p=d.indexOf(`line-through`)!==-1,m,h=a/2,g=Mi;if(!I.legacyTextRendering){let e=this.measureSize(`M`);g=`alphabetic`,h=((e.fontBoundingBoxAscent??e.actualBoundingBoxAscent)-(e.fontBoundingBoxDescent??e.actualBoundingBoxDescent))/2+a/2}if(o===Si?o=e.direction:e.setAttr(`direction`,o),e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,g),e.setAttr(`textAlign`,Di),e.translate(r,this._getTextTop()),u){let t=e._getFillStyle(this);t!==void 0&&(e.fillStyle=t),this.hasStroke()&&e._applyStrokeStyle(this)}let _=u?e.fillStyle:void 0,v=u?e.strokeStyle:void 0,y=0;for(m=0;m1&&(h+=a)}}_getTextTop(){let e=this.padding(),t=this.getHeight()-this.textArr.length*this.lineHeight()*this.fontSize()-e*2,n=this.verticalAlign();return n===Mi?e+t/2:n===ji?e+t:e}_getUnderlineOffset(){return this.underlineOffset()??Math.round(this.fontSize()/(I.legacyTextRendering?2:4))}getSelfRect(){let e=super.getSelfRect(),t=this.textArr.length;if(!t||this.textDecoration().indexOf(`underline`)===-1)return e;let n=this.fontSize(),r=this.lineHeight()*n,i=this._getTextTop()+t*r-r/2;return I.legacyTextRendering||(i+=this._baselineShift),i+=this._getUnderlineOffset()+vi(n)/2,e.height=Math.max(e.y+e.height,i)-e.y,e}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize(),n=this.padding(),r=this.lineHeight()*t,i=this.getWidth()-n*2,a=this.align(),o=this.textArr.length*r,s=this._getTextTop(),c=e.x,l=e.x+e.width;for(let{text:e,width:t}of this.textArr){let r=n+(a===Ii?i-t:a===xi?(i-t)/2:0),o=Math.min(0,this.letterSpacing())*e.length;c=Math.min(c,r+o),l=Math.max(l,r+t-o)}let u=this.textDecoration().includes(`underline`),d=Math.min(e.y,s+(u?Math.min(0,this._getUnderlineOffset()):0));return{x:c-t,y:d-t,width:l-c+t*2,height:Math.max(e.y+e.height,s+o)-d+t*2}}_hitFunc(e){let t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){let t=L._isString(e)?e:e==null?``:e+``;return this._setAttr(Oi,t),this}getWidth(){return this.attrs.width===bi||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===bi||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return L.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}measureSize(e){let t=qi(),n=this.fontSize(),r;t.save(),t.font=this._getContextFont(),r=t.measureText(e),t.restore();let i=n/100;return{actualBoundingBoxAscent:r.actualBoundingBoxAscent??71.58203125*i,actualBoundingBoxDescent:r.actualBoundingBoxDescent??0,actualBoundingBoxLeft:r.actualBoundingBoxLeft??-7.421875*i,actualBoundingBoxRight:r.actualBoundingBoxRight??75.732421875*i,alphabeticBaseline:r.alphabeticBaseline??0,emHeightAscent:r.emHeightAscent??100*i,emHeightDescent:r.emHeightDescent??-20*i,fontBoundingBoxAscent:r.fontBoundingBoxAscent??91*i,fontBoundingBoxDescent:r.fontBoundingBoxDescent??21*i,hangingBaseline:r.hangingBaseline??72.80000305175781*i,ideographicBaseline:r.ideographicBaseline??-21*i,width:r.width,height:n}}_getContextFont(){return this.fontStyle()+Fi+this.fontVariant()+Fi+(this.fontSize()+Pi)+Gi(this.fontFamily())}_addTextLine(e){this.align()===Ci&&(e=e.trim());let t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e,t){let n=this.letterSpacing(),r=n?n*(t??yi(e).length):0;return qi().measureText(e).width+r}_setTextData(){let e=this.text().split(` `),t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.width,i=this.attrs.height,a=r!==bi&&r!==void 0,o=i!==bi&&i!==void 0,s=this.padding(),c=r-s*2,l=i-s*2,u=0,d=this.wrap(),f=d!==zi&&d!==Bi,p=this.ellipsis(),m=this.measureSize(`M`);this._baselineShift=(m.fontBoundingBoxAscent-m.fontBoundingBoxDescent)/2,this.textArr=[];let h=qi();h.font=this._getContextFont(),h.fontKerning=this.direction()!==Li&&(this.letterSpacing()!==0||this.align()===Ci||this.charRenderFunc())?`none`:`auto`;let g=p?this._getTextWidth(Vi):0;for(let t=0,r=e.length;tc){let e=yi(i),a=e.length,d=0,m=t=>e.slice(d,t).join(``),h=e=>e===Fi||e===Ei,_=Math.max(1,Math.ceil(a*c/s));for(;dl?g:0,s=e=>!(this._getTextWidth(m(e),e-d)+i>c),v=d,y=Math.min(a,d+_);for(;s(y)&&(v=y,y!==a);)y=Math.min(a,y+(y-d));for(;y-v>1;){let e=v+y>>>1;s(e)?v=e:y=e}if(v===d)break;if(v===a){this._addTextLine(m(a)),u+=n,o&&u+n>l&&t=d&&!h(e[t]);)t--;t>=d&&(v=t+1)}if(this._addTextLine(m(v).trimRight()),u+=n,this._shouldHandleEllipsis(u)){this._tryToAddEllipsisToLastLine();break}for(d=v;dl&&tl)break}this.textHeight=t,this.textWidth=this.textArr.reduce((e,t)=>Math.max(e,t.width),0)}_shouldHandleEllipsis(e){let t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==bi&&r!==void 0,a=r-this.padding()*2;return this.wrap()===Bi||i&&e+n>a}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==bi&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];if(!i||!r)return;let a=i.text+Vi;if(t){let e=yi(i.text);for(;e.length&&this._getTextWidth(a)>n;)e.pop(),a=e.join(``)+Vi;this._getTextWidth(a)>n&&(a=``)}i.text=a,i.width=this._getTextWidth(a)}getStrokeScaleEnabled(){return!0}_getStrokePadding(){return super._getStrokePadding(2)}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=this.textDecoration().indexOf(`underline`)!==-1||this.textDecoration().indexOf(`line-through`)!==-1,r=this.hasShadow();return n&&r||r&&t!==1&&Wi()?!0:super._useBufferCanvas(e,t)}};W.prototype._fillFunc=Ji,W.prototype._strokeFunc=Yi,W.prototype.className=ki,W.prototype._attrsAffectingSize=Hi.filter(e=>e!==`width`&&e!==`height`).concat([`textDecoration`,`underlineOffset`]),Je(W,!0),W.prototype.on(Hi.map(e=>e+wi).join(` `),function(){this._setTextData()}),V.overWriteSetter(W,`width`,Qt()),V.overWriteSetter(W,`height`,Qt()),V.addGetterSetter(W,`direction`,Si),V.addGetterSetter(W,`fontFamily`,`Arial`),V.addGetterSetter(W,`fontSize`,12,B()),V.addGetterSetter(W,`fontStyle`,Ni),V.addGetterSetter(W,`fontVariant`,Ni),V.addGetterSetter(W,`padding`,0,B()),V.addGetterSetter(W,`align`,Di),V.addGetterSetter(W,`verticalAlign`,Ai),V.addGetterSetter(W,`lineHeight`,1,B()),V.addGetterSetter(W,`wrap`,Ri),V.addGetterSetter(W,`ellipsis`,!1,nn()),V.addGetterSetter(W,`letterSpacing`,0,B()),V.addGetterSetter(W,`text`,``,$t()),V.addGetterSetter(W,`textDecoration`,``),V.addGetterSetter(W,`underlineOffset`,void 0,B()),V.addGetterSetter(W,`charRenderFunc`,void 0);var Zi=[...W.prototype._attrsAffectingSize,`width`,`height`,`pointerDirection`,`pointerWidth`,`pointerHeight`].map(e=>e+`Change.konva`).join(` `),Qi=`none`,$i=`up`,G=`right`,ea=`down`,ta=`left`,na=class extends Nr{constructor(e){super(e),this._sync=this._sync.bind(this),this.on(`add.konva`,function(e){e.child.off(Zi,this._sync).on(Zi,this._sync),this._sync()})}getText(){return this.find(`Text`)[0]}getTag(){return this.find(`Tag`)[0]}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,i,a,o,s,c;if(e&&t){switch(n=e.width(),r=e.height(),i=t.pointerDirection(),a=t.pointerWidth(),c=t.pointerHeight(),o=0,s=0,i){case $i:o=n/2,s=-1*c;break;case G:o=n+a,s=r/2;break;case ea:o=n/2,s=r+c;break;case ta:o=-1*a,s=r/2}t.setAttrs({x:-1*o,y:-1*s,width:n,height:r}),e.setAttrs({x:-1*o,y:-1*s})}}};na.prototype.className=`Label`,Je(na);var ra=class extends U{_sceneFunc(e){let t=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius(),[s,c,l,u]=L._cornerRadii(o,t,n);e.beginPath(),e.moveTo(s,0),r===$i&&(e.lineTo((t-i)/2,0),e.lineTo(t/2,-1*a),e.lineTo((t+i)/2,0)),e.lineTo(t-c,0),e.arc(t-c,c,c,Math.PI*3/2,0,!1),r===G&&(e.lineTo(t,(n-a)/2),e.lineTo(t+i,n/2),e.lineTo(t,(n+a)/2)),e.lineTo(t,n-l),e.arc(t-l,n-l,l,0,Math.PI/2,!1),r===ea&&(e.lineTo((t+i)/2,n),e.lineTo(t/2,n+a),e.lineTo((t-i)/2,n)),e.lineTo(u,n),e.arc(u,n-u,u,Math.PI/2,Math.PI,!1),r===ta&&(e.lineTo(0,(n+a)/2),e.lineTo(-1*i,n/2),e.lineTo(0,(n-a)/2)),e.lineTo(0,s),e.arc(s,s,s,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=this.pointerWidth(),t=this.pointerHeight(),n=this.pointerDirection(),r=this.width(),i=this.height();return n===$i||n===ea?{x:Math.min(0,(r-e)/2),y:n===$i?-t:0,width:Math.max(r,e),height:i+t}:n===ta||n===G?{x:n===ta?-e:0,y:Math.min(0,(i-t)/2),width:r+e,height:Math.max(i,t)}:{x:0,y:0,width:r,height:i}}};ra.prototype.className=`Tag`,Je(ra,!0),V.addGetterSetter(ra,`pointerDirection`,Qi),V.addGetterSetter(ra,`pointerWidth`,0,B()),V.addGetterSetter(ra,`pointerHeight`,0,B()),V.addGetterSetter(ra,`cornerRadius`,0,Zt(4));var ia=class extends U{_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?L.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};ia.prototype.className=`Rect`,Je(ia,!0),V.addGetterSetter(ia,`cornerRadius`,0,Zt(4));var aa=class extends U{_sceneFunc(e){let t=this._getPoints(),n=this.radius(),r=this.sides(),i=this.cornerRadius();if(t.length){if(e.beginPath(),i)L.drawRoundedPolygonPath(e,t,r,n,i);else{e.moveTo(t[0].x,t[0].y);for(let n=1;n{t=Math.min(t,e.x),n=Math.max(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.y)}),{x:t,y:r,width:n-t,height:i-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};aa.prototype.className=`RegularPolygon`,aa.prototype._centroid=!0,aa.prototype._attrsAffectingSize=[`radius`,`sides`],Je(aa,!0),V.addGetterSetter(aa,`radius`,0,B()),V.addGetterSetter(aa,`sides`,0,B()),V.addGetterSetter(aa,`cornerRadius`,0,Zt(4));var oa=Math.PI*2,sa=class extends U{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){let t=Math.abs(this.innerRadius()),n=Math.abs(this.outerRadius());e.beginPath(),e.arc(0,0,t,0,oa,!1),e.moveTo(n,0),e.arc(0,0,n,oa,0,!0),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=Math.max(Math.abs(this.innerRadius()),Math.abs(this.outerRadius()));return{x:-e,y:-e,width:e*2,height:e*2}}getWidth(){return Math.abs(this.outerRadius())*2}getHeight(){return Math.abs(this.outerRadius())*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};sa.prototype.className=`Ring`,sa.prototype._centroid=!0,sa.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],Je(sa,!0),V.addGetterSetter(sa,`innerRadius`,0,B()),V.addGetterSetter(sa,`outerRadius`,0,B());var ca=class extends U{constructor(e){super(e),this._updated=!0,this.anim=new Fr(()=>{let e=this._updated;return this._updated=!1,e}),this.on(`animationChange.konva`,function(){this.frameIndex(0)}),this.on(`frameIndexChange.konva`,function(){this._updated=!0}),this.on(`frameRateChange.konva`,function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_getFrame(){let e=this.animation(),t=this.animations()?.[e],n=this.frameIndex(),r=n*4;if(!t||!Number.isInteger(n)||r<0||r+4>t.length)return;let i=this.frameOffsets()?.[e]||[];return{x:t[r],y:t[r+1],width:t[r+2],height:t[r+3],offsetX:i[n*2]||0,offsetY:i[n*2+1]||0}}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this._getFrame();if(!t)return;let{x:n,y:r,width:i,height:a,offsetX:o,offsetY:s}=t,c=this.image();(this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(o,s,i,a),e.closePath(),e.fillStrokeShape(this)),c&&e.drawImage(c,n,r,i,a,o,s,i,a)}_hitFunc(e){let{x:t,y:n,width:r,height:i}=this.getSelfRect();e.beginPath(),e.rect(t,n,r,i),e.closePath(),e.fillShape(this)}getSelfRect(){let e=this._getFrame();return e?{x:e.offsetX,y:e.offsetY,width:e.width,height:e.height}:{x:0,y:0,width:0,height:0}}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){return super._useBufferCanvas(!0,t)}_setInterval(){let e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;let e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}destroy(){return this.stop(),super.destroy()}isRunning(){return this.anim.isRunning()}_updateIndex(){let e=this.frameIndex(),t=this.animations()?.[this.animation()],n=t?t.length/4:0;this.frameIndex(ethis.pathLength?null:fi.getPointAtLengthOfDataArray(e,this.dataArray,t)}_readDataAttribute(){this.dataArray=fi.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,this.textBaseline()),e.setAttr(`textAlign`,`left`),e.save();let t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,a=t.indexOf(`underline`)!==-1,o=t.indexOf(`line-through`)!==-1;a&&e.beginPath();for(let t=0;t=1){let n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n0)try{a=t(e[i-1],e[i])*this.fontSize()}catch{}n.push({char:e[i],width:this._getTextSize(e[i]).width,kern:a}),r+=n[i].width+a}let{width:i,height:a}=this._getTextSize(this.attrs.text);if(this.textWidth=r,this.textHeight=a,this.glyphInfo=[],!this.attrs.data)return null;let o=this.letterSpacing(),s=this.align(),c=s===`justify`?this.text().split(` `).length-1:0,l=Math.max(0,r-i),u=Math.max(this.textWidth+(e.length-1)*o,0),d=0;s===`center`&&(d=Math.max(0,this.pathLength/2-u/2)),s===`right`&&(d=Math.max(0,this.pathLength-u));let f=d,p=this.dataArray.some((e,t)=>t>0&&e.command===`M`)?void 0:{index:0,offset:0};for(let t=0;tthis.pathLength&&d-this.pathLength<=l?this.pathLength:d,p);if(!m)return;let h=fi.getLineLength(r.x,r.y,m.x,m.y),g=Math.atan2(m.y-r.y,m.x-r.x);this.glyphInfo.push({text:e[t],rotation:g,p0:r,p1:m,width:h}),f+=a}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};let e=[];this.glyphInfo.forEach(function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)});let t=L._getPointsRect(e),n=this.fontSize();return{x:t.x-n/2,y:t.y-n/2,width:t.width+n,height:t.height+n}}getStrokeScaleEnabled(){return!0}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize();return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}};K.prototype._fillFunc=fa,K.prototype._strokeFunc=pa,K.prototype._fillFuncHit=fa,K.prototype._strokeFuncHit=pa,K.prototype.className=`TextPath`,K.prototype._attrsAffectingSize=[`text`,`fontSize`,`data`,`align`,`letterSpacing`,`kerningFunc`,`fontFamily`,`fontStyle`,`fontVariant`,`direction`],Je(K,!0),K.prototype.on(`dataChange.konva`,function(){this._readDataAttribute(),this._setTextData()}),K.prototype.on(K.prototype._attrsAffectingSize.filter(e=>e!==`data`).map(e=>e+`Change.konva`).join(` `),function(){this._setTextData()}),V.addGetterSetter(K,`data`),V.addGetterSetter(K,`fontFamily`,`Arial`),V.addGetterSetter(K,`fontSize`,12,B()),V.addGetterSetter(K,`fontStyle`,da),V.addGetterSetter(K,`align`,`left`),V.addGetterSetter(K,`letterSpacing`,0,B()),V.addGetterSetter(K,`textBaseline`,`middle`),V.addGetterSetter(K,`fontVariant`,da),V.addGetterSetter(K,`text`,ua),V.addGetterSetter(K,`textDecoration`,``),V.addGetterSetter(K,`kerningFunc`,void 0),V.addGetterSetter(K,`direction`,`inherit`);var ma=`tr-konva`,ha=[`resizeEnabledChange`,`rotateAnchorOffsetChange`,`rotateAnchorAngleChange`,`rotateEnabledChange`,`rotateModeChange`,`enabledAnchorsChange`,`anchorSizeChange`,`borderEnabledChange`,`shouldOverdrawWholeAreaChange`,`borderStrokeChange`,`borderStrokeWidthChange`,`borderDashChange`,`anchorStrokeChange`,`anchorStrokeWidthChange`,`anchorFillChange`,`anchorCornerRadiusChange`,`ignoreStrokeChange`,`anchorStyleFuncChange`,`paddingChange`].map(e=>e+`.${ma}`).join(` `),ga=`nodesRect`,_a=[`widthChange`,`heightChange`,`scaleXChange`,`scaleYChange`,`skewXChange`,`skewYChange`,`rotationChange`,`offsetXChange`,`offsetYChange`,`transformsEnabledChange`,`strokeWidthChange`,`strokeChange`,`selfRectFuncChange`,`strokeLinearGradientColorStopsChange`,`strokeScaleEnabledChange`,`strokeEnabledChange`,`draggableChange`],va={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},ya=`ontouchstart`in I._global,ba=[`rotater-top-left`,`rotater-top-right`,`rotater-bottom-left`,`rotater-bottom-right`];function xa(e){return e.startsWith(`rotater`)}var Sa=Math.PI/12;function Ca(e,t){let n=``;return`url("data:image/svg+xml,${encodeURIComponent(n)}") 12 12, ${t}`}function wa(e,t,n){if(e===`rotater`)return n;if(xa(e)){let r=e.slice(8);return Ca(Math.round(L.radToDeg(t)+va[r]-45),n)}t+=L.degToRad(va[e]||0);let r=(L.radToDeg(t)%360+360)%360;return L._inRange(r,337.5,360)||L._inRange(r,0,22.5)?`ns-resize`:L._inRange(r,22.5,67.5)?`nesw-resize`:L._inRange(r,67.5,112.5)?`ew-resize`:L._inRange(r,112.5,157.5)?`nwse-resize`:L._inRange(r,157.5,202.5)?`ns-resize`:L._inRange(r,202.5,247.5)?`nesw-resize`:L._inRange(r,247.5,292.5)?`ew-resize`:L._inRange(r,292.5,337.5)?`nwse-resize`:(L.error(`Transformer has unknown angle for cursor detection: `+r),`pointer`)}var Ta=[`top-left`,`top-center`,`top-right`,`middle-right`,`middle-left`,`bottom-left`,`bottom-center`,`bottom-right`];function Ea(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function Da(e,t,n){let r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function Oa(e,t){return Da(e,t,Ea(e))}function ka(e,t,n){let r=t,i=n;for(let n=0;n0&&(c=Math.min(c,(n-s)/a)),i<0?c=Math.min(c,-o/i):i>0&&(c=Math.min(c,(t-o)/i));let l=o+i*c,u=s+a*c,d=e.rotateAnchorOffset()+e.padding();return{edgeX:l,edgeY:u,endX:l+i*d,endY:u+a*d}}var ja=new Set,q=class extends Nr{static _isLayerTransforming(e){for(let t of ja)if(t.getLayer()===e||t._nodes.some(t=>t.getLayer()===e))return!0;return!1}constructor(e){super(e),this._movingAnchorName=null,this._anchors={},this._transforming=!1,this._fitting=!1,this._transformWindow=null,this._elementsCreated=!1,this._updatePending=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this._syncUpdate=this._syncUpdate.bind(this),this.on(ha,e=>{e.type===`ignoreStrokeChange`&&this._resetTransformCache(),this.update()}),this.on(`rotationChange.${ma}`,()=>this._clearCache(ga)),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return L.warn(`tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead.`),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return ma+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();let t=new Set(e);for(let e of t)e.isAncestorOf(this)&&(L.error(`Konva.Transformer cannot be an a child of the node you are trying to attach`),t.delete(e));let n=Array.from(t).filter(e=>{for(let n=e.getParent();n;n=n.getParent())if(t.has(n))return!1;return!0});return this._nodes=e=n,this._resetRotation(),this._nodes.forEach(e=>{let t=()=>{var t;this._fitting?(t=this._nodeRectCache)==null||t.delete(e):(this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(e),this.isDragging()||this._scheduleUpdate())};if(e._attrsAffectingSize.length){let n=e._attrsAffectingSize.map(e=>e+`Change.`+this._getEventNamespace()).join(` `);e.on(n,t)}e.on(_a.map(e=>e+`.${this._getEventNamespace()}`).join(` `),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),e instanceof Tn&&e._addSubtreeObserver(this),e.on(`destroy.${this._getEventNamespace()}`,()=>{this._removeNode(e)}),this._proxyDrag(e)}),this._resetTransformCache(),this._elementsCreated&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this._back&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;let r=e.getAbsolutePosition(),i=r.x-t.x,a=r.y-t.y;this.nodes().forEach(t=>{if(t===e||t.isDragging())return;let r=t.getAbsolutePosition();t.setAbsolutePosition({x:r.x+i,y:r.y+a}),t.startDrag(n)}),t=null})}_detachNode(e){e.off(`.`+this._getEventNamespace()),e._removeSubtreeObserver(this)}_resetRotation(){let e=this._nodes.length===1&&this.useSingleNodeRotation();this.rotation(e?this._nodes[0].getAbsoluteRotation():0)}_removeNode(e){this._detachNode(e),this._nodes=this._nodes.filter(t=>t!==e),this._resetRotation(),this._resetTransformCache(e),this._scheduleUpdate()}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){var e,t;(e=this._nodes)==null||e.forEach(e=>this._detachNode(e)),this._nodes=[],this._updatePending=!1,this._resetTransformCache(),(t=this.getLayer())==null||t.batchDraw()}_resetTransformCache(e){var t,n;e?(t=this._nodeRectCache)==null||t.delete(e):(n=this._nodeRectCache)==null||n.clear(),this._clearCache(ga),this._clearCache(`transform`),this._clearSelfAndDescendantCache(`absoluteTransform`)}_onSubtreeChange(e){var t;this._fitting||((!this._updatePending||this._cache[ga])&&this._resetTransformCache(e),H._updateBatchDepth>0?this._scheduleUpdate():this._updatePending||(this._updatePending=!0,L.requestAnimFrame(this._syncUpdate,this.getStage()?._getOwnerWindow()),(t=this.getLayer())==null||t.batchDraw()))}_syncUpdate(){this._updatePending&&!this._fitting&&!this.isDragging()&&this._update()}drawScene(e,t){return this._syncUpdate(),super.drawScene(e,t)}drawHit(e,t){return this._syncUpdate(),super.drawHit(e,t)}_getNodeRect(){return this._getCache(ga,this.__getNodeRect)}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};let e=I.getAngle(this.rotation()),t=this.ignoreStroke(),n=new Ze;n.rotate(-e);let r=this._nodeRectCache||=new Map,i=1/0,a=1/0,o=-1/0,s=-1/0;for(let c of this.nodes()){let l=c instanceof U&&c.getSelfRect===U.prototype.getSelfRect&&!c.attrs.selfRectFunc&&!c._hasCachedAncestor(),u=l?c.width():0,d=l?c.height():0;l&&(c._attrsVersion??=0);let f=l?r.get(c):void 0;if(!f||f.rotation!==e||f.ignoreStroke!==t||f.version!==c._attrsVersion||f.width!==u||f.height!==d){let i=c.getAbsoluteTransform(),[a,o,s,p]=i.getMatrix(),m=a*p-o*s===0,h=c.getClientRect({skipTransform:!m,skipShadow:!0,skipStroke:t}),g=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}];m&&(i=new Ze),f={rotation:e,ignoreStroke:t,width:u,height:d,version:c._attrsVersion||0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(let e of g){let t=n.point(i.point(e));f.minX=Math.min(f.minX,t.x),f.minY=Math.min(f.minY,t.y),f.maxX=Math.max(f.maxX,t.x),f.maxY=Math.max(f.maxY,t.y)}l&&r.set(c,f)}i=Math.min(i,f.minX),a=Math.min(a,f.minY),o=Math.max(o,f.maxX),s=Math.max(s,f.maxY)}n.invert();let c=n.point({x:i,y:a});return{x:c.x,y:c.y,width:o-i,height:s-a,rotation:I.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),ba.forEach(e=>{this._createAnchor(e,`_rotate-zone`).setAttrs({fill:`transparent`,strokeEnabled:!1,visible:!1})}),Ta.forEach(e=>{this._createAnchor(e)}),this._createAnchor(`rotater`),this._elementsCreated=!0}_createAnchor(e,t=`_anchor`){let n=new ia({stroke:`rgb(0, 161, 255)`,fill:`white`,strokeWidth:1,name:e+` `+t,dragDistance:0,draggable:!0,hitStrokeWidth:ya?10:`auto`});this._anchors[e]=n;let r=this;return n.on(`mousedown touchstart`,function(e){r._handleMouseDown(e)}),n.on(`dragstart`,e=>{n.stopDrag(),e.cancelBubble=!0}),n.on(`dragend`,e=>{e.cancelBubble=!0}),n.on(`mouseenter`,()=>{this.isTransforming()||(this._setAnchorCursor(e),this._cursorChange=!0)}),n.on(`mouseout`,()=>{this._cursorChange=!1,!this.isTransforming()&&n.getStage().content&&(n.getStage().content.style.cursor=``)}),this.add(n),n}_setAnchorCursor(e,t=I.getAngle(this.rotation())){let n=this.getStage()?.content;n&&(n.style.cursor=wa(e,t,this.rotateAnchorCursor()))}_createBack(){let e=new U({name:`back`,width:0,height:0,sceneFunc(e,t){let n=t.getParent();if(!n.borderEnabled())return;let r=n.padding(),i=t.width(),a=t.height();if(e.beginPath(),e.rect(-r,-r,i+r*2,a+r*2),n.rotateEnabled()&&n.rotateLineVisible()&&n.rotateMode()!==`corners`){let t=Aa(n,i,a);e.moveTo(t.edgeX,t.edgeY),e.lineTo(t.endX,t.endY)}e.fillStrokeShape(t)},hitFunc:(e,t)=>{if(!this.shouldOverdrawWholeArea())return;let n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+n*2,t.height()+n*2),e.fillStrokeShape(t)}});this._back=e,this.add(e),this._proxyDrag(e),e.on(`dragstart`,e=>{e.cancelBubble=!0}),e.on(`dragmove`,e=>{e.cancelBubble=!0}),e.on(`dragend`,e=>{e.cancelBubble=!0}),this.on(`dragmove`,e=>{this.update()})}_handleMouseDown(e){if(e.evt.button!==void 0&&!I.dragButtons.includes(e.evt.button)||this._transforming)return;this._movingAnchorName=e.target.name().split(` `)[0];let t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(n**2+r**2);this.sin=Math.abs(r/i),this.cos=Math.abs(n/i);let a=this.getStage()?._getOwnerWindow();this._transformWindow=a||null,a&&(a.addEventListener(`mousemove`,this._handleMouseMove),a.addEventListener(`touchmove`,this._handleMouseMove),a.addEventListener(`mouseup`,this._handleMouseUp,!0),a.addEventListener(`touchend`,this._handleMouseUp,!0),a.addEventListener(`touchcancel`,this._handleMouseUp,!0)),this._transforming=!0,this._pointerId=e.pointerId??L._getFirstPointerId(e.evt);let o=e.target.getAbsolutePosition(),s=e.target.getStage()._getPointerById(this._pointerId);if(this._anchorDragOffset={x:s.x-o.x,y:s.y-o.y},xa(this._movingAnchorName)){let e=Ea(t);this._rotateStart={pointerAngle:Math.atan2(s.y-e.y,s.x-e.x),rotation:t.rotation}}ja.add(this),this._fire(`transformstart`,{evt:e.evt,target:this.getNode()}),this._nodes.forEach(t=>{t._fire(`transformstart`,{evt:e.evt,target:t})})}_handleMouseMove(e){var t;(t=this.getStage())==null||t._batchEvents(()=>this._moveTransform(e))}_moveTransform(e){this._syncUpdate();let t,n,r,i=this._anchors[this._movingAnchorName],a=i.getStage();a.setPointersPositions(e);let o=a._getPointerById(this._pointerId);if(!o)return;let s={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y},c=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(c,s,e)),i.setAbsolutePosition(s);let l=i.getAbsolutePosition();if(c.x===l.x&&c.y===l.y)return;if(xa(this._movingAnchorName)){let t=this._getNodeRect(),n=Ea(t),r=this._rotateStart,i={x:l.x+this._anchorDragOffset.x,y:l.y+this._anchorDragOffset.y},a=Math.atan2(i.y-n.y,i.x-n.x),o=r.rotation+a-r.pointerAngle,s;if(e.shiftKey&&this.shiftBehavior()!==`none`)s=Math.round(o/Sa)*Sa;else{let e=I.getAngle(this.rotationSnapTolerance());s=ka(this.rotationSnaps(),o,e)}this._movingAnchorName!==`rotater`&&this._setAnchorCursor(this._movingAnchorName,s);let c=Oa(t,s-t.rotation);this._fitNodesInto(c,e);return}let u=this.shiftBehavior(),d;d=u===`inverted`?this.keepRatio()&&!e.shiftKey:u===`none`?this.keepRatio():this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey,p=!1;if(this._movingAnchorName===`top-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-right`].x(),y:this._anchors[`bottom-right`].y()};r=Math.sqrt((e.x-i.x())**2+(e.y-i.y())**2);let a=this._anchors[`top-left`].x()>e.x?-1:1,o=this._anchors[`top-left`].y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-left`].x(e.x-t),this._anchors[`top-left`].y(e.y-n)}}else if(this._movingAnchorName===`top-center`)this._anchors[`top-left`].y(i.y());else if(this._movingAnchorName===`top-right`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-left`].x(),y:this._anchors[`bottom-left`].y()};r=Math.sqrt((i.x()-e.x)**2+(e.y-i.y())**2);let a=this._anchors[`top-right`].x()e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-right`].x(e.x+t),this._anchors[`top-right`].y(e.y-n)}var m=i.position();this._anchors[`top-left`].y(m.y),this._anchors[`bottom-right`].x(m.x)}else if(this._movingAnchorName===`middle-left`)this._anchors[`top-left`].x(i.x());else if(this._movingAnchorName===`middle-right`)this._anchors[`bottom-right`].x(i.x());else if(this._movingAnchorName===`bottom-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`top-right`].x(),y:this._anchors[`top-right`].y()};r=Math.sqrt((e.x-i.x())**2+(i.y()-e.y)**2);let a=e.xe.id===this._pointerId))||(t?t._batchEvents(()=>this._removeEvents(e)):this._removeEvents(e))}getAbsoluteTransform(e){let t=this.getTransform();return e?e.getAbsoluteTransform().copy().invert().multiply(t):t}_removeEvents(e){var t;if(this._transforming){this._transforming=!1;let n=this.getStage()?.content;n&&!this._cursorChange&&(n.style.cursor=``);let r=this._transformWindow;this._transformWindow=null,r&&(r.removeEventListener(`mousemove`,this._handleMouseMove),r.removeEventListener(`touchmove`,this._handleMouseMove),r.removeEventListener(`mouseup`,this._handleMouseUp,!0),r.removeEventListener(`touchend`,this._handleMouseUp,!0),r.removeEventListener(`touchcancel`,this._handleMouseUp,!0));let i=this.getNode();ja.delete(this),this._fire(`transformend`,{evt:e,target:i}),(t=this.getLayer())==null||t.batchDraw(),i&&this._nodes.forEach(t=>{var n;t._fire(`transformend`,{evt:e,target:t}),(n=t.getLayer())==null||n.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t,n=!1){this._fitting=!0;try{return this._doFitNodesInto(e,t,n)}finally{this._fitting=!1}}_doFitNodesInto(e,t,n=!1){let r=this._getNodeRect();if(!r.width||!r.height||L._inRange(e.width,-this.padding()*2-1,1)||L._inRange(e.height,-this.padding()*2-1,1)){this.update();return}let i=new Ze;i.rotate(I.getAngle(this.rotation()));let a=n?0:this.padding()*2,o=null,s=null;if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`left`)>=0){let t=i.point({x:-a,y:0});e.x+=t.x,e.y+=t.y,e.width+=a,o={axis:`width`,from:`left`,to:`right`,offset:t}}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`right`)>=0){let t=i.point({x:a,y:0});e.width+=a,o={axis:`width`,from:`right`,to:`left`,offset:t}}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`top`)>=0){let t=i.point({x:0,y:-a});e.x+=t.x,e.y+=t.y,e.height+=a,s={axis:`height`,from:`top`,to:`bottom`,offset:t}}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`bottom`)>=0){let t=i.point({x:0,y:a});e.height+=a,s={axis:`height`,from:`bottom`,to:`top`,offset:t}}if(this.boundBoxFunc()){let t=this.boundBoxFunc()(r,e);t?e=t:L.warn(`boundBoxFunc returned falsy. You should return new bound rect from it!`)}for(let t of[o,s])t&&e[t.axis]<0&&this._movingAnchorName&&(this._movingAnchorName=this._movingAnchorName.replace(t.from,t.to),this._anchorDragOffset.x-=t.offset.x,this._anchorDragOffset.y-=t.offset.y);let c=1e7,l=new Ze;l.translate(r.x,r.y),l.rotate(r.rotation),l.scale(r.width/c,r.height/c);let u=new Ze,d=e.width/c,f=e.height/c;this.flipEnabled()===!1?(u.translate(e.x,e.y),u.rotate(e.rotation),u.translate(e.width<0?e.width:0,e.height<0?e.height:0),u.scale(Math.abs(d),Math.abs(f))):(u.translate(e.x,e.y),u.rotate(e.rotation),u.scale(d,f));let p=u.multiply(l.invert()),m=new Set;this._nodes.forEach(e=>{if(!e.getStage())return;let t=e.getParent().getAbsoluteTransform(),n=e.getTransform().copy();n.translate(e.offsetX(),e.offsetY());let r=new Ze;r.multiply(t.copy().invert()).multiply(p).multiply(t).multiply(n);let i=r.decompose();e.setAttrs(i);let a=e.getLayer();a&&m.add(a)}),this.rotation(L._getRotation(e.rotation)),this._nodes.forEach(e=>{this._fire(`transform`,{evt:t,target:e}),e._fire(`transform`,{evt:t,target:e})}),this._resetTransformCache(),this.update(),m.add(this.getLayer()),m.forEach(e=>e&&e.batchDraw())}_scheduleUpdate(){this._updatePending=!0,H._runAfterUpdateBatch(this._syncUpdate)}forceUpdate(){this._resetTransformCache(),this.update()}update(){this._lastNodeRect=void 0,this._update()}_update(){var e;this._updatePending=!1;let t=this._getNodeRect();this._updateElements(t);let n=this.nodes().some(e=>e.draggable());this._back.draggable()!==n&&this._back.draggable(n);let r=this.anchorStyleFunc();r&&Object.values(this._anchors).forEach(e=>e.hasName(`_anchor`)&&r(e)),(e=this.getLayer())==null||e.batchDraw()}_updateElements(e){let t=this._lastNodeRect;if(t&&!this.anchorStyleFunc()&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height&&e.rotation===t.rotation)return;this._lastNodeRect={...e};let n=e.width,r=e.height,i=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),s=this.anchorSize();Object.values(this._anchors).filter(e=>e.hasName(`_anchor`)).forEach(e=>{e.setAttrs({width:s,height:s,offsetX:s/2,offsetY:s/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._anchors[`top-left`].setAttrs({x:0,y:0,offsetX:s/2+o,offsetY:s/2+o,visible:a&&i.indexOf(`top-left`)>=0}),this._anchors[`top-center`].setAttrs({x:n/2,y:0,offsetY:s/2+o,visible:a&&i.indexOf(`top-center`)>=0}),this._anchors[`top-right`].setAttrs({x:n,y:0,offsetX:s/2-o,offsetY:s/2+o,visible:a&&i.indexOf(`top-right`)>=0}),this._anchors[`middle-left`].setAttrs({x:0,y:r/2,offsetX:s/2+o,visible:a&&i.indexOf(`middle-left`)>=0}),this._anchors[`middle-right`].setAttrs({x:n,y:r/2,offsetX:s/2-o,visible:a&&i.indexOf(`middle-right`)>=0}),this._anchors[`bottom-left`].setAttrs({x:0,y:r,offsetX:s/2+o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-left`)>=0}),this._anchors[`bottom-center`].setAttrs({x:n/2,y:r,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-center`)>=0}),this._anchors[`bottom-right`].setAttrs({x:n,y:r,offsetX:s/2-o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-right`)>=0});let c=this.rotateMode(),l=Aa(this,n,r);this._anchors.rotater.setAttrs({x:l.endX,y:l.endY,visible:this.rotateEnabled()&&c!==`corners`});let u=s*2,d=this.rotateEnabled()&&c!==`handle`,f=-o-u;ba.forEach(e=>{this._anchors[e].setAttrs({x:e.includes(`left`)?f:n+o,y:e.includes(`top`)?f:r+o,width:u,height:u,visible:d})}),this._back.setAttrs({width:n,height:r,visible:this.borderEnabled()||this.shouldOverdrawWholeArea(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0})}isTransforming(){return this._transforming}stopTransform(){this._transforming&&this._removeEvents()}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=``),Nr.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(L.error(`You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.`),this):super.add(...e)}toObject(){return H.prototype.toObject.call(this)}clone(e){return H.prototype.clone.call(this,e)}getClientRect(e){return this._syncUpdate(),this.nodes().length>0?super.getClientRect(e):{x:0,y:0,width:0,height:0}}};q.isTransforming=()=>ja.size>0;function Ma(e){return e instanceof Array||L.warn(`enabledAnchors value should be an array`),e instanceof Array&&e.forEach(function(e){Ta.indexOf(e)===-1&&L.warn(`Unknown anchor name: `+e+`. Available names are: `+Ta.join(`, `))}),e||[]}q.prototype.className=`Transformer`,Je(q),V.addGetterSetter(q,`enabledAnchors`,Ta,Ma),V.addGetterSetter(q,`flipEnabled`,!0,nn()),V.addGetterSetter(q,`resizeEnabled`,!0),V.addGetterSetter(q,`anchorSize`,10,B()),V.addGetterSetter(q,`rotateEnabled`,!0),V.addGetterSetter(q,`rotateLineVisible`,!0),V.addGetterSetter(q,`rotationSnaps`,[]),V.addGetterSetter(q,`rotateAnchorOffset`,50,B()),V.addGetterSetter(q,`rotateAnchorAngle`,0,B()),V.addGetterSetter(q,`rotateAnchorCursor`,`crosshair`),V.addGetterSetter(q,`rotateMode`,`handle`),V.addGetterSetter(q,`rotationSnapTolerance`,5,B()),V.addGetterSetter(q,`borderEnabled`,!0),V.addGetterSetter(q,`anchorStroke`,`rgb(0, 161, 255)`),V.addGetterSetter(q,`anchorStrokeWidth`,1,B()),V.addGetterSetter(q,`anchorFill`,`white`),V.addGetterSetter(q,`anchorCornerRadius`,0,B()),V.addGetterSetter(q,`borderStroke`,`rgb(0, 161, 255)`),V.addGetterSetter(q,`borderStrokeWidth`,1,B()),V.addGetterSetter(q,`borderDash`),V.addGetterSetter(q,`keepRatio`,!0),V.addGetterSetter(q,`shiftBehavior`,`default`),V.addGetterSetter(q,`centeredScaling`,!1),V.addGetterSetter(q,`ignoreStroke`,!1),V.addGetterSetter(q,`padding`,0,B()),V.addGetterSetter(q,`nodes`),V.addGetterSetter(q,`node`),V.addGetterSetter(q,`boundBoxFunc`),V.addGetterSetter(q,`anchorDragBoundFunc`),V.addGetterSetter(q,`anchorStyleFunc`),V.addGetterSetter(q,`shouldOverdrawWholeArea`,!1),V.addGetterSetter(q,`useSingleNodeRotation`,!0),V.backCompat(q,{lineEnabled:`borderEnabled`,rotateHandlerOffset:`rotateAnchorOffset`,enabledHandlers:`enabledAnchors`});var Na=class extends U{_sceneFunc(e){e.beginPath(),e.arc(0,0,Math.abs(this.radius()),0,I.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radius())*2}getHeight(){return Math.abs(this.radius())*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Na.prototype.className=`Wedge`,Na.prototype._centroid=!0,Na.prototype._attrsAffectingSize=[`radius`],Je(Na,!0),V.addGetterSetter(Na,`radius`,0,B()),V.addGetterSetter(Na,`angle`,0,B()),V.addGetterSetter(Na,`clockwise`,!1),V.backCompat(Na,{angleDeg:`angle`,getAngleDeg:`getAngle`,setAngleDeg:`setAngle`});function Pa(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var Fa=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],Ia=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function La(e,t){return t===255?e:e*t/255}var Ra=180;function za(e,t){let n=e.data,r=e.width,i=e.height,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=t+t+1,ee=r-1,E=i-1,D=t+1,te=D*(D+1)/2,ne=new Pa,O=t<=Ra?Fa[t]/2**Ia[t]:1/(D*D),re=null,k=ne,A=null,ie=null;for(let e=1;e0?(C=255/C,n[a]=Math.floor(c*O)*C,n[a+1]=Math.floor(l*O)*C,n[a+2]=Math.floor(u*O)*C):n[a]=n[a+1]=n[a+2]=0,c-=f,l-=p,u-=m,d-=h,f-=A.r,p-=A.g,m-=A.b,h-=A.a,a=e+((a=t+D)0&&za(e,n)};V.addGetterSetter(H,`blurRadius`,0,B(),V.afterSetFilter);var Va=function(e){let t=this.brightness()*255,n=e.data,r=n.length;for(let e=0;e255?255:i,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,n[e]=i,n[e+1]=a,n[e+2]=o};V.addGetterSetter(H,`contrast`,0,B(),V.afterSetFilter);var Wa=function(e){let t=e.data,n=e.width,r=e.height,i=Math.min(1,Math.max(0,this.embossStrength?.call(this)??.5)),a=Math.min(1,Math.max(0,this.embossWhiteLevel?.call(this)??.5)),o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[this.embossDirection?.call(this)??`top-left`]??315,s=!!(this.embossBlend?.call(this)??!1),c=i*10,l=a*255,u=o*Math.PI/180,d=Math.cos(u),f=Math.sin(u),p=128/1020*c,m=new Float32Array(n*r);for(let e=0,n=0;ne<0?0:e>255?255:e;for(let e=0;ei&&(i=a),c=t[e+1],cs&&(s=c),d=t[e+2],du&&(u=d);i===r&&(i=255,r=0),s===o&&(s=255,o=0),u===l&&(u=255,l=0);let p,m,h,g,_,v;if(f>0)p=i+f*(255-i),m=r-f*(r-0),h=s+f*(255-s),g=o-f*(o-0),_=u+f*(255-u),v=l-f*(l-0);else{let e=(i+r)*.5;p=i+f*(i-e),m=r+f*(r-e);let t=(s+o)*.5;h=s+f*(s-t),g=o+f*(o-t);let n=(u+l)*.5;_=u+f*(u-n),v=l+f*(l-n)}for(let e=0;el?f:l;let p=o,m=a,h=360/m*Math.PI/180;for(let e=0;el?f:l;let p=o,m=a,h=n.polarRotation||0,g,_;for(u=0;ut&&(y=v,b=0,x=-1),i=0;i=0&&d=0&&f=0&&d=0&&f=1020?255:0}return o}function so(e,t,n){let r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s=0&&d=0&&fMath.min(1,Math.max(0,e)),V.afterSetFilter),V.addGetterSetter(H,`threshold`,.5,B(),V.afterSetFilter),Jr.Util._assign(Jr,{Arc:Yr,Arrow:pi,Circle:mi,Ellipse:hi,Image:gi,Label:na,Tag:ra,Line:li,Path:fi,Rect:ia,RegularPolygon:aa,Ring:sa,Sprite:ca,Star:la,Text:W,TextPath:K,Transformer:q,Wedge:Na,Filters:{Blur:Ba,Brightness:Ha,Brighten:Va,Contrast:Ua,Emboss:Wa,Enhance:Ka,Grayscale:qa,HSL:Ja,HSV:Ya,Invert:Xa,Kaleidoscope:$a,Mask:function(e){let t=ro(e,this.attrs.threshold??10);return t&&(t=ao(t,e.width,e.height),t=oo(t,e.width,e.height),t=so(t,e.width,e.height),io(e,t)),e},Noise:function(e){let t=this.noise()*255,n=e.data,r=n.length,i=t/2;for(let e=0;e=128&&(t[e]=255-n,t[e+1]=255-r,t[e+2]=255-i)}return e},Threshold:function(e){let t=this.threshold()*255,n=e.data,r=n.length;for(let e=0;e{t.exports=function(e){function t(e,t,n,r){return new Qa(e,t,n,r)}function n(){}function r(e){var t=`https://react.dev/errors/`+e;if(1Sl||(e.current=xl[Sl],xl[Sl]=null,Sl--)}function h(e,t){Sl++,xl[Sl]=e.current,e.current=t}function g(e){return e>>>=0,e===0?32:31-(Tl(e)/El|0)|0}function _(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function v(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=_(n))):i=_(o):i=_(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=_(n))):i=_(o)):i=_(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function y(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function b(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function w(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function T(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0)`:-1i||c[r]!==l[i]){var u=` `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Yl=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ae(n):``}function oe(e,t){switch(e.tag){case 26:case 27:case 5:return ae(e.type);case 16:return ae(`Lazy`);case 13:return e.child!==t&&t!==null?ae(`Suspense Fallback`):ae(`Suspense`);case 19:return ae(`SuspenseList`);case 0:case 15:return j(e.type,!1);case 11:return j(e.type.render,!1);case 1:return j(e.type,!0);case 31:return ae(`Activity`);case 30:return ae(`ViewTransition`);default:return``}}function se(e){try{var t=``,n=null;do t+=oe(e,n),n=e,e=e.return;while(e);return t}catch(e){return` Error generating stack: `+e.message+` `+e.stack}}function M(e,t){if(typeof e==`object`&&e){var n=Xl.get(e);return n===void 0?(t={value:e,source:t,stack:se(t)},Xl.set(e,t),t):n}return{value:e,source:t,stack:se(t)}}function ce(e,t){Zl[Ql++]=eu,Zl[Ql++]=$l,$l=e,eu=t}function le(e,t,n){tu[nu++]=iu,tu[nu++]=au,tu[nu++]=ru,ru=e;var r=iu;e=au;var i=32-wl(r)-1;r&=~(1<>=o,i-=o,iu=1<<32-wl(t)+i|n<f?(p=d,d=null):p=d.sibling;var _=h(t,d,o[f],c);if(_===null){d===null&&(d=p);break}e&&d&&_.alternate===null&&n(t,d),r=s(_,r,f),u===null?l=_:u.sibling=_,u=_,d=p}if(f===o.length)return i(t,d),fu&&ce(t,f),l;if(d===null){for(;fp?(_=f,f=null):_=f.sibling;var y=h(t,f,v.value,l);if(y===null){f===null&&(f=_);break}e&&f&&y.alternate===null&&n(t,f),o=s(y,o,p),d===null?u=y:d.sibling=y,d=y,f=_}if(v.done)return i(t,f),fu&&ce(t,p),u;if(f===null){for(;!v.done;p++,v=c.next())v=m(t,v.value,l),v!==null&&(o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return fu&&ce(t,p),u}for(f=a(f);!v.done;p++,v=c.next())v=g(f,t,p,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&f.delete(_.key===null?p:_.key)),o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return e&&f.forEach(function(e){return n(t,e)}),fu&&ce(t,p),u}function y(e,t,a,s){if(typeof a==`object`&&a&&a.type===xo&&a.key===null&&a.props.ref===void 0&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case yo:a:{for(var u=a.key;t!==null;){if(t.key===u){if(u=a.type,u===xo){if(t.tag===7){i(e,t.sibling),s=o(t,a.props.children),rt(s,a),s.return=e,e=s;break a}}else if(t.elementType===u||typeof u==`object`&&u&&u.$$typeof===Ao&&$e(u)===t.type){i(e,t.sibling),s=o(t,a.props),rt(s,a),s.return=e,e=s;break a}i(e,t);break}n(e,t),t=t.sibling}a.type===xo?(s=ro(a.props.children,e.mode,s,a.key),rt(s,a),s.return=e,e=s):(s=no(a.type,a.key,a.props,null,e.mode,s),rt(s,a),s.return=e,e=s)}return c(e);case bo:a:{for(u=a.key;t!==null;){if(t.key===u){if(t.tag===4&&t.stateNode.containerInfo===a.containerInfo&&t.stateNode.implementation===a.implementation){i(e,t.sibling),s=o(t,a.children||[]),s.return=e,e=s;break a}i(e,t);break}n(e,t),t=t.sibling}s=oo(a,e.mode,s),s.return=e,e=s}return c(e);case Ao:return a=$e(a),y(e,t,a,s)}if(Ro(a))return _(e,t,a,s);if(l(a)){if(u=l(a),typeof u!=`function`)throw Error(r(150));return a=u.call(a),v(e,t,a,s)}if(typeof a.then==`function`)return y(e,t,nt(a),s);if(a.$$typeof===To)return y(e,t,Ae(e,a),s);it(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,t!==null&&t.tag===6?(i(e,t.sibling),s=o(t,a),s.return=e,e=s):(i(e,t),s=io(a,e.mode,s),s.return=e,e=s),c(e)):i(e,t)}return function(e,n,r,i){try{Hu=0;var a=y(e,n,r,i);return Vu=null,a}catch(n){if(n===Iu||n===Ru)throw n;var o=t(29,n,null,e.mode);return o.lanes=i,o.return=e,o}}}function ot(){for(var e=Ku,t=qu=Ku=0;ta?a:8);var o=X.T,s={};s.types=o===null?null:o.types,X.T=s,zn(e,!1,t,n);try{var c=i(),l=X.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Rn(e,t,I(c,r),da(e)):Rn(e,t,r,da(e))}catch(n){Rn(e,t,{then:function(){},status:`rejected`,reason:n},da())}finally{ss(a),o!==null&&s.types!==null&&(o.types=s.types),X.T=o}}function jn(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:bs,baseState:bs,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:z,lastRenderedState:bs},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:z,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Mn(){return ke(xs)}function Nn(){return R().memoizedState}function Pn(){return R().memoizedState}function Fn(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=da();e=mt(n);var r=ht(t,e,n);r!==null&&(K(r,t,n),gt(r,t,n)),t={cache:Me()},e.payload=t;return}t=t.return}}function In(e,t,n){var r=da();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Bn(e)?Vn(t,n):(n=ct(e,t,n,r),n!==null&&(K(n,e,r),Hn(n,t,r)))}function Ln(e,t,n){Rn(e,t,n,da())}function Rn(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Bn(e))Vn(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Wl(s,o))return st(e,t,i,0),Gd===null&&ot(),!1}catch{}if(n=ct(e,t,i,r),n!==null)return K(n,e,r),Hn(n,t,r),!0}return!1}function zn(e,t,n,i){if(i={lane:2,revertLane:We(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Bn(e)){if(t)throw Error(r(479))}else t=ct(e,n,i,2),t!==null&&K(t,e,2)}function Bn(e){var t=e.alternate;return e===$||t!==null&&t===$}function Vn(e,t){rd=nd=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Hn(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,E(e,n)}}function Un(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:_o({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}function Wn(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Xe(n,r)||!Xe(i,a):!0}function Gn(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&pd.enqueueReplaceState(t,t.state,null)}function Kn(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=_o({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function qn(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Jn(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Yn(e,t,n){return n=mt(n),n.tag=3,n.payload={element:null},n.callback=function(){qn(e,t)},n}function Xn(e){return e=mt(e),e.tag=3,e}function Zn(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Jn(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Jn(t,n,r),typeof i!=`function`&&(mf===null?mf=new Set([this]):mf.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Qn(e,t,n,i,a){if(n.flags|=32768,typeof i==`object`&&i&&typeof i.then==`function`){if(t=n.alternate,t!==null&&Ee(t,n,a,!0),n=Z.current,n!==null){switch(n.tag){case 31:case 13:case 19:return Q===null?Ta():n.alternate===null&&ef===0&&(ef=3),n.flags&=-257,n.flags|=65536,n.lanes=a,i===zu?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([i]):t.add(i),Ka(e,i,a)),!1;case 22:return n.flags|=65536,i===zu?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([i]):n.add(i)),Ka(e,i,a)),!1}throw Error(r(435,n.tag))}return Ka(e,i,a),Ta(),!1}if(fu)return t=Z.current,t===null?(i!==hu&&(t=Error(r(423),{cause:i}),Se(M(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,i=M(i,n),a=Yn(e.stateNode,i,a),_t(e,a),ef!==4&&(ef=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,i!==hu&&(e=Error(r(422),{cause:i}),Se(M(e,n)))),!1;var o=Error(r(520),{cause:i});if(o=M(o,n),sf===null?sf=[o]:sf.push(o),ef!==4&&(ef=2),t===null)return!0;i=M(i,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Yn(n.stateNode,i,e),_t(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(mf===null||!mf.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Xn(a),Zn(a,e,n,i),_t(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}function $n(e,t,n,r){t.child=e===null?Wu(t,null,n,r):Uu(t,e.child,n,r)}function er(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Oe(t),r=Pt(e,t,n,o,a,i),s=Rt(),e!==null&&!hd?(zt(e,t,i),Er(e,t,i)):(fu&&s&&ue(t),t.flags|=1,$n(e,t,r,i),t.child)}function tr(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!$a(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,nr(e,t,a,r,i)):(e=no(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Dr(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Xe:n,n(o,r)&&e.ref===t.ref)return Er(e,t,i)}return t.flags|=1,e=eo(a,r),e.ref=t.ref,e.return=t,t.child=e}function nr(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Xe(a,r)&&e.ref===t.ref){if(hd=!1,t.pendingProps=r=a,Dr(e,i))e.flags&131072&&(hd=!0);else return t.lanes=e.lanes,Er(e,t,i)}}return ur(e,t,n,r,i)}function rr(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return ar(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Je(t,a===null?null:a.cachePool),a===null?Ct():St(t,a),Et(t);else return r=t.lanes=536870912,ar(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Je(t,null),Ct(),Dt()):(Je(t,a.cachePool),St(t,a),Dt(),t.memoizedState=null);return $n(e,t,i,n),t.child}function ir(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function ar(e,t,n,r,i){var a=qe();return a=a===null?null:{parent:ts?Su._currentValue:Su._currentValue2,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Je(t,null),Ct(),Et(t),e!==null&&Ee(e,t,r,!0),t.childLanes=i,null}function or(e,t){return t=vr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function sr(e,t,n){return Uu(t,e.child,null,n),e=or(t,t.pendingProps),e.flags|=2,Ot(t),t.memoizedState=null,e}function cr(e,t,n){var i=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(fu){if(i.mode===`hidden`)return e=or(t,i),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},ir(null,e);if(Tt(t),(e=du)?(e=Pc(e,mu),e!==null&&(t.memoizedState={dehydrated:e,treeContext:ru===null?null:{id:iu,overflow:au},retryLane:536870912,hydrationErrors:null},n=ao(e),n.return=t,t.child=n,uu=t,du=null)):e=null,e===null)throw _e(t);return t.lanes=536870912,null}return or(t,i)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Tt(t),a){if(t.flags&256)t.flags&=-257,t=sr(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558))}else if(hd||Ee(e,t,n,!1),a=(n&e.childLanes)!==0,hd||a){if(Xu.current===null){if(i=Gd,i!==null&&(s=D(i,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,lt(e,s),K(i,e,s),md;Ta()}t=sr(e,t,n)}else e=o.treeContext,is&&(du=kc(s),uu=t,fu=!0,pu=null,mu=!1,e!==null&&fe(t,e)),t=or(t,i),t.flags|=134221824;return t}return e=eo(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function lr(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(r(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function ur(e,t,n,r,i){return Oe(t),n=Pt(e,t,n,r,void 0,i),r=Rt(),e!==null&&!hd?(zt(e,t,i),Er(e,t,i)):(fu&&r&&ue(t),t.flags|=1,$n(e,t,n,i),t.child)}function dr(e,t,n,r,i,a){return Oe(t),t.updateQueue=null,n=It(t,r,n,i),Ft(e),r=Rt(),e!==null&&!hd?(zt(e,t,a),Er(e,t,a)):(fu&&r&&ue(t),t.flags|=1,$n(e,t,n,a),t.child)}function fr(e,t,n,r,i){if(Oe(t),t.stateNode===null){var a=Cl,o=n.contextType;typeof o==`object`&&o&&(a=ke(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=pd,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},ft(t),o=n.contextType,a.context=typeof o==`object`&&o?ke(o):Cl,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Un(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&pd.enqueueReplaceState(a,a.state,null),yt(t,r,a,i),vt(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Kn(n,s);a.props=c;var l=a.context,u=n.contextType;o=Cl,typeof u==`object`&&u&&(o=ke(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Gn(t,a,r,o),Ju=!1;var f=t.memoizedState;a.state=f,yt(t,r,a,i),vt(),l=t.memoizedState,s||f!==l||Ju?(typeof d==`function`&&(Un(t,n,d,r),l=t.memoizedState),(c=Ju||Wn(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,pt(e,t),o=t.memoizedProps,u=Kn(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Cl,typeof l==`object`&&l&&(c=ke(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Gn(t,a,r,c),Ju=!1,f=t.memoizedState,a.state=f,yt(t,r,a,i),vt();var p=t.memoizedState;o!==d||f!==p||Ju||e!==null&&e.dependencies!==null&&De(e.dependencies)?(typeof s==`function`&&(Un(t,n,s,r),p=t.memoizedState),(u=Ju||Wn(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&De(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,lr(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Uu(t,e.child,null,i),t.child=Uu(t,null,n,i)):$n(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Er(e,t,i),e}function pr(e,t,n,r){return be(),t.flags|=256,$n(e,t,n,r),t.child}function mr(e){return{baseLanes:e,cachePool:Ye()}}function hr(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=af),e}function gr(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(Qu.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(fu){if(i?wt(t):Dt(),(e=du)?(e=Fc(e,mu),e!==null&&(t.memoizedState={dehydrated:e,treeContext:ru===null?null:{id:iu,overflow:au},retryLane:536870912,hydrationErrors:null},n=ao(e),n.return=t,t.child=n,uu=t,du=null)):e=null,e===null)throw _e(t);return t.lanes=bc(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(Dt(),i=t.mode,a=vr({mode:`hidden`,children:a},i),r=ro(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=mr(n),r.childLanes=hr(e,o,n),t.memoizedState=gd,ir(null,r)):(wt(t),_r(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return br(e,t,a,o,r,c,s,n)}return i?(Dt(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=eo(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=ro(i,a,n,null),i.flags|=2):i=eo(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,ir(null,r),r=t.child,i=e.child.memoizedState,i===null?i=mr(n):(a=i.cachePool,a===null?a=Ye():(s=ts?Su._currentValue:Su._currentValue2,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=hr(e,o,n),t.memoizedState=gd,ir(e.child,r)):(wt(t),n=e.child,e=n.sibling,n=eo(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function _r(e,t){return t=vr({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function vr(e,n){return e=t(22,e,null,n),e.lanes=0,e}function yr(e,t,n){return Uu(t,e.child,null,n),e=_r(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function br(e,t,n,i,a,o,s,c){if(n)return t.flags&256?(wt(t),t.flags&=-257,yr(e,t,c)):t.memoizedState===null?(Dt(),o=a.fallback,s=t.mode,a=vr({mode:`visible`,children:a.children},s),o=ro(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,Uu(t,e.child,null,c),a=t.child,a.memoizedState=mr(c),a.childLanes=hr(e,i,c),t.memoizedState=gd,ir(null,a)):(Dt(),t.child=e.child,t.flags|=128,null);if(wt(t),bc(o))return i=xc(o).digest,i!==``&&(a=Error(r(419)),a.stack=``,a.digest=i,Se({value:a,source:null,stack:null})),yr(e,t,c);if(hd||Ee(e,t,c,!1),i=(c&e.childLanes)!==0,hd||i){if(Xu.current!==null)return yr(e,t,c);if(i=Gd,i!==null&&(a=D(i,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,lt(e,a),K(i,e,a),md;return yc(o)||Ta(),yr(e,t,c)}return yc(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,is&&(du=Ac(o),uu=t,fu=!0,pu=null,mu=!1,e!==null&&fe(t,e)),t=_r(t,a.children),t.flags|=134221824,t)}function xr(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),we(e.return,t,n)}function Sr(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&jt(n)===null&&(t=e),e=e.sibling}return t}function Cr(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function wr(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function Tr(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Qu.current;if(t.flags&128)return kt(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,kt(t,o),i===`backwards`&&e!==null?(wr(e),$n(e,t,r,n),wr(e)):$n(e,t,r,n),r=fu?eu:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&xr(e,n,t);else if(e.tag===19)xr(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=Sr(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,wr(t)),Cr(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&jt(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Cr(t,!0,n,null,a,r);break;case`together`:Cr(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=Sr(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Cr(t,!1,i,n,a,r)}return t.child}function U(e,t,n){var r=t.pendingProps;return Ce(t,t.type,r.value),$n(e,t,r.children,n),t.child}function Er(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),tf|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(Ee(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=eo(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=eo(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Dr(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&De(e)))}function Or(e,t,n){switch(t.tag){case 3:pe(t,t.stateNode.containerInfo),Ce(t,Su,e.memoizedState.cache),be();break;case 27:case 5:he(t);break;case 4:pe(t,t.stateNode.containerInfo);break;case 10:Ce(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Tt(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return wt(t),t.flags|=128,null;r=Ee(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?gr(e,t,n):(wt(t),e=Er(e,t,n),e===null?null:e.sibling)}wt(t);break;case 19:if(t.flags&128)return Tr(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(Ee(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Tr(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),kt(t,Qu.current),r)break;return null;case 22:return t.lanes=0,rr(e,t,n,t.pendingProps);case 24:Ce(t,Su,e.memoizedState.cache)}return Er(e,t,n)}function kr(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)hd=!0;else{if(!Dr(e,n)&&!(t.flags&128))return hd=!1,Or(e,t,n);hd=!!(e.flags&131072)}}else hd=!1,fu&&t.flags&1048576&&le(t,eu,t.index);switch(t.lanes=0,t.tag){case 16:a:{var i=t.pendingProps;if(e=$e(t.elementType),t.type=e,typeof e==`function`)$a(e)?(i=Kn(e,i),t.tag=1,t=fr(null,t,e,i,n)):(t.tag=0,t=ur(null,t,e,i,n));else{if(e!=null){var a=e.$$typeof;if(a===Eo){t.tag=11,t=er(null,t,e,i,n);break a}if(a===ko){t.tag=14,t=tr(null,t,e,i,n);break a}if(a===To){t.tag=10,t.type=e,t=U(null,t,n);break a}}throw t=u(e)||e,Error(r(306,t,``))}}return t;case 0:return ur(e,t,t.type,t.pendingProps,n);case 1:return i=t.type,a=Kn(i,t.pendingProps),fr(e,t,i,a,n);case 3:a:{if(pe(t,t.stateNode.containerInfo),e===null)throw Error(r(387));var o=t.pendingProps;a=t.memoizedState,i=a.element,pt(e,t),yt(t,o,null,n);var s=t.memoizedState;if(o=s.cache,Ce(t,Su,o),o!==a.cache&&Te(t,[Su],n,!0),vt(),o=s.element,is&&a.isDehydrated){if(a={element:o,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=pr(e,t,o,n);break a}if(o!==i){i=M(Error(r(424)),t),Se(i),t=pr(e,t,o,n);break a}for(is&&(du=Oc(t.stateNode.containerInfo),uu=t,fu=!0,pu=null,mu=!0),n=Wu(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(be(),o===i){t=Er(e,t,n);break a}$n(e,t,o,n)}t=t.child}return t;case 26:if(tl)return lr(e,t),e===null?(n=il(t.type,null,t.pendingProps,null))?t.memoizedState=n:fu||(t.stateNode=ul(t.type,t.pendingProps,cu.current,t)):t.memoizedState=il(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:if(hl)return he(t),e===null&&hl&&fu&&(i=t.stateNode=gl(t.type,t.pendingProps,cu.current,ou.current,!1),uu=t,mu=!0,du=jc(t.type,i,du)),$n(e,t,t.pendingProps.children,n),lr(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&fu&&($c(t.type,t.pendingProps,ou.current),(a=i=du)&&(i=Mc(i,t.type,t.pendingProps,mu),i===null?a=!1:(t.stateNode=i,uu=t,du=Dc(i),mu=!1,a=!0)),a||_e(t)),he(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,i=o.children,Xo(a,o)?i=null:s!==null&&Xo(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=Pt(e,t,Lt,null,null,n),ts?xs._currentValue=a:xs._currentValue2=a),lr(e,t),$n(e,t,i,n),t.child;case 6:return e===null&&fu&&(el(t.pendingProps,ou.current),(e=n=du)&&(n=Nc(n,t.pendingProps,mu),n===null?e=!1:(t.stateNode=n,uu=t,du=null,e=!0)),e||_e(t)),null;case 13:return gr(e,t,n);case 4:return pe(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Uu(t,null,i,n):$n(e,t,i,n),t.child;case 11:return er(e,t,t.type,t.pendingProps,n);case 7:return i=t.pendingProps,lr(e,t),$n(e,t,i,n),t.child;case 8:return $n(e,t,t.pendingProps.children,n),t.child;case 12:return $n(e,t,t.pendingProps.children,n),t.child;case 10:return U(e,t,n);case 9:return a=t.type._context,i=t.pendingProps.children,Oe(t),a=ke(a),i=i(a),t.flags|=1,$n(e,t,i,n),t.child;case 14:return tr(e,t,t.type,t.pendingProps,n);case 15:return nr(e,t,t.type,t.pendingProps,n);case 19:return Tr(e,t,n);case 31:return cr(e,t,n);case 22:return rr(e,t,n,t.pendingProps);case 24:return Oe(t),i=ke(Su),e===null?(a=qe(),a===null&&(a=Gd,o=Me(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:i,cache:a},ft(t),Ce(t,Su,a)):((e.lanes&n)!==0&&(pt(e,t),yt(t,null,null,n),vt()),a=e.memoizedState,o=t.memoizedState,a.parent===i?(i=o.cache,Ce(t,Su,i),i!==a.cache&&Te(t,[Su],n,!0)):(a={parent:i,cache:i},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ce(t,Su,i))),$n(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),i=t.pendingProps,i.name!=null&&i.name!==`auto`?t.flags|=e===null?18882560:18874368:fu&&ue(t),e!==null&&e.memoizedProps.name!==i.name?t.flags|=4194816:lr(e,t),$n(e,t,i.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function Ar(e){e.flags|=4}function jr(e){rs&&(e.flags|=8)}function Mr(e,t){if(e!==null&&e.child===t.child)return!1;if(t.flags&16)return!0;for(e=t.child;e!==null;){if(e.flags&8218||e.subtreeFlags&8218)return!0;e=e.sibling}return!1}function Nr(e,t,n,r){if(ns)for(n=t.child;n!==null;){if(n.tag===5||n.tag===6)Jo(e,n.stateNode);else if(!(n.tag===4||hl&&n.tag===27)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}else if(rs)for(var i=t.child;i!==null;){if(i.tag===5){var a=i.stateNode;n&&r&&(a=_c(a,i.type,i.memoizedProps)),Jo(e,a)}else if(i.tag===6)a=i.stateNode,n&&r&&(a=vc(a,i.memoizedProps)),Jo(e,a);else if(i.tag!==4){if(i.tag===22&&i.memoizedState!==null)a=i.child,a!==null&&(a.return=i),Nr(e,i,!0,!0);else if(i.child!==null){i.child.return=i,i=i.child;continue}}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return;i=i.return}i.sibling.return=i.return,i=i.sibling}}function Pr(e,t,n,r){var i=!1;if(rs)for(var a=t.child;a!==null;){if(a.tag===5){var o=a.stateNode;n&&r&&(o=_c(o,a.type,a.memoizedProps)),mc(e,o)}else if(a.tag===6)o=a.stateNode,n&&r&&(o=vc(o,a.memoizedProps)),mc(e,o);else if(a.tag!==4){if(a.tag===22&&a.memoizedState!==null)i=a.child,i!==null&&(i.return=a),Pr(e,a,!0,!0),i=!0;else if(a.child!==null){a.child.return=a,a=a.child;continue}}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return i;a=a.return}a.sibling.return=a.return,a=a.sibling}return i}function Fr(e,t){if(rs&&Mr(e,t)){e=t.stateNode;var n=e.containerInfo,r=pc();Pr(r,t,!1,!1),e.pendingChildren=r,Ar(t),hc(n,r)}}function Ir(e,t,n,r){if(ns)e.memoizedProps!==r&&Ar(t);else if(rs){var i=e.stateNode,a=e.memoizedProps;if((e=Mr(e,t))||a!==r){var o=ou.current;a=fc(i,n,a,r,!e,null),a===i?t.stateNode=i:(jr(t),Yo(a,n,r,o)&&Ar(t),t.stateNode=a,e&&Nr(a,t,!1,!1))}else t.stateNode=i}}function Lr(e,t,n,r,i){if(e.mode&32&&(n===null?fs(t,r):ps(t,n,r))){if(e.flags|=16777216,(i&335544128)===i||ms(t,r)){if(hs(e.stateNode,t,r))e.flags|=8192;else if(Sa())e.flags|=8192;else throw Bu=zu,Lu}}else e.flags&=-16777217}function Rr(e,t){if(fl(t)){if(e.flags|=16777216,!pl(t)){if(Sa())e.flags|=8192;else throw Bu=zu,Lu}}else e.flags&=-16777217}function zr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:S(),e.lanes|=t,of|=t)}function Br(e,t){if(!fu)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function Vr(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Hr(e,t,n){var i=t.pendingProps;switch(de(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Vr(t),null;case 1:return Vr(t),null;case 3:return n=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),P(Su),me(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ye(t)?Ar(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,xe())),Fr(e,t),Vr(t),null;case 26:if(tl){var a=t.type,o=t.memoizedState;return e===null?(Ar(t),o===null?(Vr(t),Lr(t,a,null,i,n)):(Vr(t),Rr(t,o))):o?o===e.memoizedState?(Vr(t),t.flags&=-16777217):(Ar(t),Vr(t),Rr(t,o)):(o=e.memoizedProps,ns?o!==i&&Ar(t):Ir(e,t,a,i),Vr(t),Lr(t,a,o,i,n)),null}case 27:if(hl){if(ge(t),n=cu.current,a=t.type,e!==null&&t.stateNode!=null)ns?e.memoizedProps!==i&&Ar(t):Ir(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Vr(t),t.subtreeFlags&=-33554433,null}e=ou.current,ye(t)?N(t,e):(e=gl(a,i,n,e,!0),t.stateNode=e,Ar(t))}return Vr(t),t.subtreeFlags&=-33554433,null}case 5:if(ge(t),a=t.type,e!==null&&t.stateNode!=null)Ir(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Vr(t),t.subtreeFlags&=-33554433,null}if(o=ou.current,ye(t))N(t,o),Kc(t.stateNode,a,i,o)&&(t.flags|=64);else{var s=qo(a,i,cu.current,o,t);jr(t),Nr(s,t,!1,!1),t.stateNode=s,Yo(s,a,i,o)&&Ar(t)}}return Vr(t),t.subtreeFlags&=-33554433,Lr(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)n=e.memoizedProps,ns?n!==i&&Ar(t):rs&&(n===i?t.stateNode=e.stateNode:(e=cu.current,n=ou.current,jr(t),t.stateNode=Zo(i,e,n,t)));else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(e=cu.current,n=ou.current,ye(t)){if(!is)throw Error(r(176));if(e=t.stateNode,n=t.memoizedProps,i=null,a=uu,a!==null)switch(a.tag){case 27:case 5:i=a.memoizedProps}Lc(e,n,t,i)||_e(t,!0)}else jr(t),t.stateNode=Zo(i,e,n,t)}return Vr(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(i=ye(t),n!==null){if(e===null){if(!i)throw Error(r(318));if(!is)throw Error(r(556));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(557));Rc(e,t)}else be(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Vr(t),e=!1}else n=xe(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Ot(t),t):(Ot(t),null);if(t.flags&128)throw Error(r(558))}return Vr(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ye(t),i!==null&&i.dehydrated!==null){if(e===null){if(!a)throw Error(r(318));if(!is)throw Error(r(344));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(r(317));zc(a,t)}else be(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Vr(t),a=!1}else a=xe(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Ot(t),t):(Ot(t),null)}return Ot(t),t.flags&128?(t.lanes=n,t):(n=i!==null,e=e!==null&&e.memoizedState!==null,n&&(i=t.child,a=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(a=i.alternate.memoizedState.cachePool.pool),o=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),o!==a&&(i.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),zr(t,t.updateQueue),Vr(t),null);case 4:return me(),Fr(e,t),e===null&&os(t.stateNode.containerInfo),t.flags|=67108864,Vr(t),null;case 10:return P(t.type),Vr(t),null;case 19:if(At(t),i=t.memoizedState,i===null)return Vr(t),null;if(a=!!(t.flags&128),o=i.rendering,o===null){if(a)Br(i,!1);else{if(ef!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=jt(e),o!==null){for(t.flags|=128,Br(i,!1),e=o.updateQueue,t.updateQueue=e,zr(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)to(n,e),n=n.sibling;return kt(t,Qu.current&1|2),fu&&ce(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&Pl()>ff&&(t.flags|=128,a=!0,Br(i,!1),t.lanes=4194304)}}else{if(!a){if(e=jt(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,zr(t,e),Br(i,!0),i.tail===null&&i.tailMode!==`collapsed`&&i.tailMode!==`visible`&&!o.alternate&&!fu)return Vr(t),null}else 2*Pl()-i.renderingStartTime>ff&&n!==536870912&&(t.flags|=128,a=!0,Br(i,!1),t.lanes=4194304)}i.isBackwards?(o.sibling=t.child,t.child=o):(e=i.last,e===null?t.child=o:e.sibling=o,i.last=o)}if(i.tail!==null){e=i.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Pl(),e.sibling=null,o=Qu.current,o=a?o&1|2:o&1,i.tailMode===`visible`||i.tailMode===`collapsed`||!n||fu?kt(t,o):(n=o,h(Z,t),h(Qu,n),Q===null&&(Q=t)),fu&&ce(t,i.treeForkCount),e}return Vr(t),null;case 22:case 23:return Ot(t),L(),i=t.memoizedState!==null,e===null?i&&(t.flags|=8192):e.memoizedState!==null!==i&&(t.flags|=8192),i?n&536870912&&!(t.flags&128)&&(Vr(t),t.subtreeFlags&6&&(t.flags|=8192)):Vr(t),n=t.updateQueue,n!==null&&zr(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==n&&(t.flags|=2048),e!==null&&m(Fu),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),P(Su),Vr(t),null;case 25:return null;case 30:return t.flags|=33554432,Vr(t),null}throw Error(r(156,t.tag))}function Ur(e,t){switch(de(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return P(Su),me(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ge(t),null;case 31:if(t.memoizedState!==null){if(Ot(t),t.alternate===null)throw Error(r(340));be()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Ot(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));be()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return At(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return me(),null;case 10:return P(t.type),null;case 22:case 23:return Ot(t),L(),e!==null&&m(Fu),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return P(Su),null;case 25:return null;default:return null}}function Wr(e,t){switch(de(t),t.tag){case 3:P(Su),me();break;case 26:case 27:case 5:ge(t);break;case 4:me();break;case 31:t.memoizedState!==null&&Ot(t);break;case 13:Ot(t);break;case 19:At(t);break;case 10:P(t.type);break;case 22:case 23:Ot(t),L(),e!==null&&m(Fu);break;case 24:P(Su)}}function Gr(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Ga(t,t.return,e)}}function Kr(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Ga(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Ga(t,t.return,e)}}function qr(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{xt(t,n)}catch(t){Ga(e,e.return,t)}}}function Jr(e,t,n){n.props=Kn(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Ga(e,t,n)}}function Yr(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=Ho(e.stateNode);break;case 30:var i=e.stateNode,a=re(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=oc(a)),r=i.ref;break;case 7:e.stateNode===null&&(e.stateNode=cc(e)),r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Ga(e,t,n)}}function Xr(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Ga(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Ga(e,t,n)}else n.current=null}}function Zr(){var e=_d;return _d=!1,e}function Qr(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n`;case Rd:return`:has(`+(ca(e)||``)+`)`;case zd:return`[role="`+e.value+`"]`;case Vd:return`"`+e.value+`"`;case Bd:return`[data-testname="`+e.value+`"]`;default:throw Error(r(365))}}function la(e,t){var n=[];e=[e,0];for(var r=0;rn?32:n;n=X.T;var a=cs();try{ss(i),X.T=null,i=bf,bf=null;var o=gf,s=vf;if(hf=0,_f=gf=null,vf=0,Wd&6)throw Error(r(331));var c=Wd;if(Wd|=4,ra(o.current),Zi(o,o.current,s,i),Wd=c,Le(0,!1),Hl&&typeof Hl.onPostCommitFiberRoot==`function`)try{Hl.onPostCommitFiberRoot(Vl,o)}catch{}return!0}finally{ss(a),X.T=n,Va(e,t)}}function Wa(e,t,n){t=M(n,t),t=Yn(e.stateNode,t,2),e=ht(e,t,2),e!==null&&(w(e,2),Ie(e))}function Ga(e,t,n){if(e.tag===3)Wa(e,e,n);else for(;t!==null;){if(t.tag===3){Wa(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(mf===null||!mf.has(r))){e=M(n,e),n=Xn(2),r=ht(t,n,2),r!==null&&(Zn(n,r,t,e),w(r,2),Ie(r));break}}t=t.return}}function Ka(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ud;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Qd=!0,i.add(n),e=qa.bind(null,e,t,n),t.then(e,e))}function qa(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Gd===e&&(qd&n)===n&&(ef===4||ef===3&&(qd&62914560)===qd&&300>Pl()-uf?Wd&2?rf|=n:ba(e,0):rf|=n,of===qd&&(of=0)),Ie(e)}function Ja(e,t){t===0&&(t=S()),e=lt(e,t),e!==null&&(w(e,t),Ie(e))}function Ya(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ja(e,n)}function Xa(e,t){var n=0;switch(e.tag){case 31:case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(r(314))}i!==null&&i.delete(t),Ja(e,n)}function Za(e,t){return Al(e,t)}function Qa(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function $a(e){return e=e.prototype,!(!e||!e.isReactComponent)}function eo(e,n){var r=e.alternate;return r===null?(r=t(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&1206910976,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function to(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function no(e,n,i,a,o,s){var c=0;if(a=e,typeof a==`function`)$a(a)&&(c=1);else if(typeof a==`string`)c=tl&&hl?nl(e,i,ou.current)?26:yl(e)?27:5:tl?nl(e,i,ou.current)?26:5:hl&&yl(e)?27:5;else a:switch(a){case jo:return e=t(31,i,n,o),e.elementType=jo,e.lanes=s,e;case xo:return ro(i.children,o,s,n);case So:c=8,o|=24;break;case Co:return e=t(12,i,n,o|2),e.elementType=Co,e.lanes=s,e;case Do:return e=t(13,i,n,o),e.elementType=Do,e.lanes=s,e;case Oo:return e=t(19,i,n,o),e.elementType=Oo,e.lanes=s,e;case Mo:case Po:return e=o|32,e=t(30,i,n,e),e.elementType=Po,e.lanes=s,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof a==`object`&&a)switch(a.$$typeof){case To:c=10;break a;case wo:c=9;break a;case Eo:c=11;break a;case ko:c=14;break a;case Ao:c=16,a=null;break a}c=29,i=Error(r(130,e===null?`null`:typeof e,``)),a=null}return n=t(c,i,n,o),n.elementType=e,n.type=a,n.lanes=s,n}function ro(e,n,r,i){return e=t(7,e,i,n),e.lanes=r,e}function io(e,n,r){return e=t(6,e,null,n),e.lanes=r,e}function ao(e){var n=t(18,null,null,0);return n.stateNode=e,n}function oo(e,n,r){return n=t(4,e.children===null?[]:e.children,e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function so(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=es,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=C(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=C(0),this.hiddenUpdates=C(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function co(e,n,r,i,a,o,s,c,l,u,d,f){return e=new so(e,n,r,s,l,u,d,f,c),n=1,!0===o&&(n|=24),o=t(3,null,null,n),e.current=o,o.stateNode=e,n=Me(),n.refCount++,e.pooledCache=n,n.refCount++,o.memoizedState={element:i,isDehydrated:r,cache:n},ft(o),e}function lo(e){return e?(e=Cl,e):Cl}function uo(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=o(t),e=e===null?null:s(e),e===null?null:Ho(e.stateNode)}function fo(e,t,n,r,i,a){i=lo(i),r.context===null?r.context=i:r.pendingContext=i,r=mt(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=ht(e,r,t),n!==null&&(K(n,e,t),gt(n,e,t))}function po(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n=u&&o>=f&&a<=d&&s<=p){e.splice(t,1);break}if(!(i!==u||n.width!==l.width||ps)){f>o&&(l.height+=f-o,l.y=o),pa)){u>i&&(l.width+=u-i,l.x=i),dn&&(n=c)),c `)+` No matching component was found for: `)+e.join(` > `)}return null},J.getPublicRootInstance=function(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 27:case 5:return Ho(e.child.stateNode);default:return e.child.stateNode}},J.injectIntoDevTools=function(){var e={bundleType:0,version:zo,rendererPackageName:Bo,currentDispatcherRef:X,reconcilerVersion:`19.3.0`};if(Vo!==null&&(e.rendererConfig=Vo),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`)e=!1;else{var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)e=!0;else{try{Vl=t.inject(e),Hl=t}catch{}e=!!t.checkDCE}}return e},J.isAlreadyRendering=function(){return!!(Wd&6)},J.observeVisibleRects=function(e,t,n,i){if(!Ts)throw Error(r(363));e=ua(e,t);var a=Ms(e,n,i).disconnect;return{disconnect:function(){a()}}},J.shouldError=function(){return null},J.shouldSuspend=function(){return!1},J.startHostTransition=function(e,t,i,a){if(e.tag!==5)throw Error(r(476));var o=jn(e).queue;An(e,o,t,bs,i===null?n:function(){var t=jn(e);return t.next===null&&(t=e.alternate.memoizedState),Rn(e,t.next.queue,{},da()),i(a)})},J.updateContainer=function(e,t,n,r){var i=t.current,a=da();return fo(i,a,e,t,n,r),a},J.updateContainerSync=function(e,t,n,r){return fo(t.current,2,e,t,n,r),2},J},t.exports.default=t.exports,Object.defineProperty(t.exports,"__esModule",{value:!0})})),fo=o(((e,t)=>{t.exports=uo()})),po=o((e=>{e.ConcurrentRoot=1,e.DefaultEventPriority=32,e.DiscreteEventPriority=2})),mo=o(((e,t)=>{t.exports=po()})),J=l(fo()),ho=mo(),go={children:!0,ref:!0,key:!0,style:!0,forwardedRef:!0,eventBatchFunc:!0,unstable_applyCache:!0,unstable_applyDrawHitFromCache:!0},_o=!1,vo=!1,yo=`.react-konva-event`,bo=!1,xo=`ReactKonva: You have a Konva node with draggable = true and position defined but no onDragMove or onDragEnd events are handled. Position of a node will be changed during drag&drop, so you should update state of the react app as well. Consider to add onDragMove or onDragEnd events. For more info see: https://github.com/konvajs/react-konva/issues/256 `,So=`ReactKonva: You are using "zIndex" attribute for a Konva node. react-konva may get confused with ordering. Just define correct order of elements in your render function of a component. For more info see: https://github.com/konvajs/react-konva/issues/194 `,Co={};function wo(e,t,n=Co){if(!_o&&`zIndex`in t&&(console.warn(So),_o=!0),!vo&&t.draggable){var r=t.x!==void 0||t.y!==void 0,i=t.onDragEnd||t.onDragMove;r&&!i&&(console.warn(xo),vo=!0)}var a={},o=!1;for(var s in n)if(!go[s]){var c=s.slice(0,2)===`on`,l=n[s]!==t[s];if(c&&l){var u=s.substr(2).toLowerCase();u.substr(0,7)===`content`&&(u=`content`+u.substr(7,1).toUpperCase()+u.substr(8)),e.off(u+yo)}var d=!t.hasOwnProperty(s);!c&&d&&(a[s]=void 0,o=!0)}var f=bo||t._useStrictMode;let p={};for(var s in t)if(!go[s]){var c=s.slice(0,2)===`on`,m=n[s]!==t[s];if(c&&m){var u=s.substr(2).toLowerCase();u.substr(0,7)===`content`&&(u=`content`+u.substr(7,1).toUpperCase()+u.substr(8)),t[s]&&(p[u]=t[s])}!c&&(t[s]!==n[s]||f&&t[s]!==e.getAttr(s))&&(o=!0,a[s]=t[s])}for(var u in o&&(e.setAttrs(a),To(e)),p)e.off(u+yo),e.on(u+yo,p[u])}function To(e){if(!I.autoDrawEnabled){var t=e.getLayer()||e.getStage();t&&t.batchDraw()}}var Eo=d(),Do=new Set,Oo=new Set,ko=typeof queueMicrotask==`function`?queueMicrotask:e=>Promise.resolve().then(e),Ao=0,jo=new WeakMap;function Mo(e){return Oo.add(e),()=>{Oo.delete(e)}}function No(){for(let e of Oo)e()}function Po(e){if(!e)return Fo;let t=jo.get(e);return t||(t=t=>Fo(()=>e(t)),jo.set(e,t)),t}function Y(e){let t=()=>{Do.delete(t)&&(No(),e())};Do.add(t),ko(t)}function Fo(e){if(Ao)return e();Ao++;try{(0,co.flushSync)(e)}finally{try{for(;Do.size;)(0,co.flushSync)(()=>{for(let e of Do)e()})}finally{Ao--}}}var Io=s({HostTransitionContext:()=>Ws,NotPendingTransition:()=>Us,afterActiveInstanceBlur:()=>xs,appendChild:()=>rs,appendChildToContainer:()=>is,appendInitialChild:()=>X,beforeActiveInstanceBlur:()=>bs,bindToConsole:()=>ys,cancelTimeout:()=>ts,clearContainer:()=>gs,commitMount:()=>us,commitNewChildToFragmentInstance:()=>Go,commitTextUpdate:()=>ls,commitUpdate:()=>ds,createFragmentInstance:()=>Uo,createInstance:()=>zo,createTextInstance:()=>Bo,createViewTransitionInstance:()=>Ns,deleteChildFromFragmentInstance:()=>Ko,detachDeletedInstance:()=>_s,finalizeInitialChildren:()=>Vo,getChildHostContext:()=>$o,getCurrentUpdatePriority:()=>Ts,getInstanceFromNode:()=>vs,getInstanceFromScope:()=>Cs,getPublicInstance:()=>Ho,getRootHostContext:()=>Qo,getSuspendedCommitReason:()=>Hs,hideInstance:()=>fs,hideTextInstance:()=>ps,idlePriority:()=>Eo.unstable_IdlePriority,insertBefore:()=>as,insertInContainerBefore:()=>os,isPrimaryRenderer:()=>!1,maySuspendCommit:()=>Ms,maySuspendCommitInSyncRender:()=>Fs,maySuspendCommitOnUpdate:()=>Ps,noTimeout:()=>-1,now:()=>Eo.unstable_now,preloadInstance:()=>Ls,prepareForCommit:()=>Jo,preparePortalMount:()=>Yo,prepareScopeUpdate:()=>Ss,removeChild:()=>ss,removeChildFromContainer:()=>cs,requestPostPaintCallback:()=>js,resetAfterCommit:()=>Xo,resetFormInstance:()=>Gs,resetTextContent:()=>Zo,resolveEventTimeStamp:()=>As,resolveEventType:()=>ks,resolveUpdatePriority:()=>Es,run:()=>Eo.unstable_runWithPriority,scheduleMicrotask:()=>Y,scheduleTimeout:()=>es,setCurrentUpdatePriority:()=>ws,shouldAttemptEagerTransition:()=>Ds,shouldSetTextContent:()=>ns,startSuspendingCommit:()=>Rs,startViewTransition:()=>Is,supportsHydration:()=>!1,supportsMicrotasks:()=>!0,supportsMutation:()=>!0,supportsPersistence:()=>!1,suspendInstance:()=>zs,suspendOnActiveViewTransition:()=>Bs,trackSchedulerEvent:()=>Os,unhideInstance:()=>ms,unhideTextInstance:()=>hs,updateFragmentInstanceFiber:()=>Wo,waitForCommitToBeReady:()=>Vs,warnsIfNotActing:()=>!1}),Lo={};lo.Node.prototype._applyProps=wo;var Ro=ho.DefaultEventPriority;function X(e,t){typeof t==`string`?console.error(`Do not use plain text as child of Konva.Node. You are using text: ${t}`):(e.add(t),To(e))}function zo(e,t,n){let r=lo[e];r||=(console.error(`Konva has no node with the type ${e}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${e}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),lo.Group);let i={},a={};for(var o in t)o!==`ref`&&(o.slice(0,2)===`on`?a[o]=t[o]:i[o]=t[o]);let s=new r(i);return wo(s,a),s}function Bo(e,t,n){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${e}"`)}function Vo(e,t,n){return!1}function Ho(e){return e}function Uo(){return null}function Wo(){}function Go(){}function Ko(){}var qo;function Jo(){return qo=lo.beginUpdateBatch?.(),null}function Yo(){return null}function Xo(){let e=qo;qo=void 0,e?.()}function Zo(e){}function Qo(){return Lo}function $o(){return Lo}var es=setTimeout,ts=clearTimeout;function ns(e,t){return!1}function rs(e,t){t.parent===e?t.moveToTop():e.add(t),To(e)}var is=rs;function as(e,t,n){t._remove(),e.add(t),t.setZIndex(n.getZIndex()),To(e)}var os=as;function ss(e,t){t.destroy(),t.off(yo),To(e)}var cs=ss;function ls(e,t,n){console.error(`Text components are not yet supported in ReactKonva. You text is: "${n}"`)}function us(e,t,n){}function ds(e,t,n,r){wo(e,r,n)}function fs(e){e.hide(),To(e)}function ps(e){}function ms(e,t){(t.visible==null||t.visible)&&(e.show(),To(e))}function hs(e,t){}function gs(e){}function _s(e){e.off(yo)}function vs(){return null}function ys(e,t){return console[e].bind(console,...t)}function bs(){}function xs(){}function Ss(){}function Cs(){return null}function ws(e){Ro=e}function Ts(){return Ro}function Es(){return ho.DiscreteEventPriority}function Ds(){return!1}function Os(){}function ks(){return null}function As(){return-1.1}function js(){}function Ms(){throw Error(`ViewTransition is not supported inside a Stage. Place ViewTransition around Stage to animate its DOM container.`)}var Ns=Ms,Ps=Ms,Fs=Ms;function Is(e,t,n,r,i,a,o,s,c,l,u){return r(),i(),u?.(),o(),null}function Ls(){return!0}function Rs(){}function zs(){}function Bs(){}function Vs(){return null}function Hs(){return null}var Us=Object.freeze({pending:!1,data:null,method:null,action:null}),Ws=v.createContext(Us);function Gs(){}typeof window<`u`&&(window.document?.createElement||window.navigator?.product===`ReactNative`)?v.useLayoutEffect:v.useEffect;function Ks(e,t,n){if(!e)return;if(n(e)===!0)return e;let r=t?e.return:e.child;for(;r;){let e=Ks(r,t,n);if(e)return e;r=t?null:r.sibling}}function qs(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return e}}var Js=qs(v.createContext(null)),Ys=class extends v.Component{render(){return v.createElement(Js.Provider,{value:this._reactInternals},this.props.children)}};function Xs(){let e=v.useContext(Js);if(e===null)throw Error(`its-fine: useFiber must be called within a !`);let t=v.useId();return v.useMemo(()=>{for(let n of[e,e?.alternate]){if(!n)continue;let e=Ks(n,!1,e=>{let n=e.memoizedState;for(;n;){if(n.memoizedState===t)return!0;n=n.next}});if(e)return e}},[e,t])}var Zs=Symbol.for(`react.context`),Qs=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Zs;function $s(){let e=Xs(),[t]=v.useState(()=>new Map);t.clear();let n=e;for(;n;){let e=n.type;Qs(e)&&e!==Js&&!t.has(e)&&t.set(e,v.use(qs(e))),n=n.return}return t}function ec(){let e=$s();return v.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>r=>v.createElement(t,null,v.createElement(n.Provider,{...r,value:e.get(n)})),e=>v.createElement(Ys,{...e})),[e])}var[tc,nc]=`19.3.1`.split(`.`).map(Number);if(tc!==19||nc<3)throw Error(`react-konva requires React 19.3 or later within React 19. Install matching versions of react and react-dom. For React 19.2, use react-konva 19.2. For React 18, use react-konva 18.`);function rc({promise:e}){throw e}var ic=e=>{let t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),i=v.useRef(null),a=v.useRef(null),o=v.useId(),s=(0,co.useFormStatus)(),c=v.useRef({}),l=c.current,u=ec(),d=!!Ks(Xs(),!0,e=>e.type===v.StrictMode),f=v.useRef(!1),p=v.useRef(!1),m=v.useRef(null);v.useInsertionEffect(()=>(p.current=!1,()=>{p.current=!0,f.current&&n.current&&h()}),[]);let h=()=>{m.current?.(),m.current=null,No(),pc.flushSyncFromReconciler(()=>{pc.updateContainer(null,r.current,null)}),n.current?.destroy(),n.current?.off(yo),n.current=null,a.current?.resolve(),a.current=null},g=e=>{if(e===`suspended`){if(!a.current){let e,t=new Promise(t=>{e=t});a.current={promise:t,resolve:e}}}else a.current?.resolve(),a.current=null;pc.updateContainer(v.createElement(v.Activity,{mode:e===`hidden`?`hidden`:`visible`,children:v.createElement(v.Suspense,{fallback:null},i.current,a.current&&v.createElement(rc,{promise:a.current.promise}))}),r.current,null),No(),pc.flushSyncWork()};return v.useLayoutEffect(()=>(m.current?.(),m.current=null,n.current||(n.current=new lo.Stage({width:e.width,height:e.height,container:t.current}),r.current=pc.createContainer(n.current,ho.ConcurrentRoot,null,d,null,o,console.error,console.error,console.error,null,null)),()=>{p.current?h():(m.current=Mo(()=>{p.current&&(m.current?.(),m.current=null,pc.updateContainer(null,r.current,null))}),g(`suspended`))}),[]),v.useEffect(()=>(f.current=!1,()=>{f.current=!0,n.current&&(p.current?h():g(`hidden`))}),[]),v.useLayoutEffect(()=>{typeof n.current.eventBatchFunc==`function`&&n.current.eventBatchFunc(Po(e.eventBatchFunc))},[e.eventBatchFunc]),v.useImperativeHandle(e.forwardedRef,()=>n.current,[]),v.useLayoutEffect(()=>{c.current=e,wo(n.current,e,l),i.current=v.createElement(Ws.Provider,{value:s},v.createElement(u,{},e.children)),g(`visible`)}),v.createElement(`div`,{ref:t,id:e.id,accessKey:e.accessKey,className:e.className,role:e.role,style:e.style,tabIndex:e.tabIndex,title:e.title})},ac=`Layer`,oc=`Group`,sc=`Rect`,cc=`Line`,lc=`Path`,uc=`RegularPolygon`,dc=`19.3.2`,fc={...Io,HostTransitionContext:Ws,rendererVersion:dc,rendererPackageName:`react-konva`,extraDevToolsConfig:null},pc=(0,J.default)(fc);pc.injectIntoDevTools();var mc=v.forwardRef((e,t)=>v.createElement(Ys,{},v.createElement(ic,{...e,forwardedRef:t}))),hc={normal:`#3b3b3b`,selected:`#1c7ed6`,valid:`#2f9e44`,invalid:`#e03131`};function gc({shape:e,width:t,height:n,pxPerM:r,outline:i,opacity:a=1}){let o=t*r,s=n*r,c=hc[i],l=i===`normal`?1.5:3;if(e===`screen`){let e=Math.min(3,s/4);return(0,F.jsxs)(oc,{opacity:a,children:[(0,F.jsx)(sc,{width:o,height:s,fill:`#2d3748`,stroke:c,strokeWidth:l,cornerRadius:2}),(0,F.jsx)(sc,{x:e,y:e,width:Math.max(0,o-e*2),height:Math.max(0,s-e*2),fill:`#63b3ed`,listening:!1})]})}if(e===`table`)return(0,F.jsx)(oc,{opacity:a,children:(0,F.jsx)(sc,{width:o,height:s,fill:`#d9b382`,stroke:c,strokeWidth:l,cornerRadius:3})});let u=Math.max(4,s*.2);return(0,F.jsxs)(oc,{opacity:a,children:[(0,F.jsx)(sc,{width:o,height:s,fill:`#8fb4d9`,stroke:c,strokeWidth:l,cornerRadius:3}),(0,F.jsx)(sc,{width:o,height:u,fill:`#4a6f96`,cornerRadius:[3,3,0,0],listening:!1})]})}var _c=10,vc=6,yc=`#2b2b2b`,bc=`#1c7ed6`,xc=`#e03131`,Sc=`#2f9e44`;function Cc(e){let t=[];for(let n of[`top`,`bottom`,`left`,`right`]){let r=O(e,n),i=e.doors.filter(e=>e.wall===n).sort((e,t)=>e.offset-t.offset),a=0;for(let e of i)e.offset>a+1e-6&&t.push({wall:n,a,b:e.offset}),a=Math.max(a,e.offset+e.width);ase({...e,x:t.x()/l-e.width/2,y:t.y()/l-e.height/2},a),ne=E+12,A=D+12,ie=(e,t)=>((e===`top`||e===`bottom`?t.x:t.y)-vc)/l,ae=(e,t,i,s,c,u)=>(0,F.jsx)(sc,{x:u.x*l,y:u.y*l,width:u.width*l,height:u.height*l,fill:`transparent`,draggable:!0,dragBoundFunc:function(){return this.absolutePosition()},onMouseDown:()=>n({kind:e,id:t}),onTouchStart:()=>n({kind:e,id:t}),onDragStart:e=>{e.cancelBubble=!0;let t=e.target.getStage()?.getPointerPosition();t&&(w.current={along:ie(i,t),offset:s})},onDragMove:n=>{let r=n.target.getStage()?.getPointerPosition(),s=w.current;if(!r||!s)return;let l=Math.min(Math.max(s.offset+ie(i,r)-s.along,0),O(a,i)-c);C({kind:e,id:t,offset:l,valid:fe(a,o,{id:t,kind:e,wall:i,offset:l,width:c})})},onDragEnd:()=>{S?.valid&&r(e,t,S.offset),C(null),w.current=null},onMouseEnter:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=i===`top`||i===`bottom`?`ew-resize`:`ns-resize`)},onMouseLeave:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=``)}},`hit-${t}`),j=(e,n,r)=>S?.kind===e&&S.id===n?S.valid?Sc:xc:t?.kind===e&&t.id===n?bc:r;return(0,F.jsx)(`div`,{style:{width:ne,height:A,background:`#fff`,boxShadow:`0 4px 18px rgba(0,0,0,0.12)`,touchAction:`none`},ref:u,children:(0,F.jsx)(mc,{width:ne,height:A,onMouseDown:e=>{e.target===e.target.getStage()&&(h?f(null):n(null))},onTouchStart:e=>{e.target===e.target.getStage()&&(h?f(null):n(null))},children:(0,F.jsxs)(ac,{x:vc,y:vc,children:[(0,F.jsx)(sc,{width:E,height:D,fill:`#fff`,listening:!1}),Cc(a).map((e,t)=>{let n=e.a*l,r=(e.b-e.a)*l,i=e.wall===`top`?{x:n,y:-6,width:r,height:vc}:e.wall===`bottom`?{x:n,y:D,width:r,height:vc}:e.wall===`left`?{x:-6,y:n,width:vc,height:r}:{x:E,y:n,width:vc,height:r};return(0,F.jsx)(sc,{...i,fill:yc,listening:!1},t)}),[[-6,-6],[E,-6],[-6,D],[E,D]].map(([e,t])=>(0,F.jsx)(sc,{x:e,y:t,width:vc,height:vc,fill:yc,listening:!1},`${e},${t}`)),a.doors.map(e=>{let t=S?.kind===`door`&&S.id===e.id?{...e,offset:S.offset}:e;return(0,F.jsx)(Ec,{room:a,door:t,px:l,color:j(`door`,e.id,e.isLoading?`#c05621`:`#4a5568`)},e.id)}),a.screens.map(e=>{let t=S?.kind===`screen`&&S.id===e.id?{...e,offset:S.offset}:e;return(0,F.jsx)(Oc,{room:a,screen:t,px:l,outline:j(`screen`,e.id,yc)},e.id)}),a.obstacles.map(e=>{let r=T?.id===e.id?T.valid?Sc:xc:t?.kind===`obstacle`&&t.id===e.id?bc:`#4a4a4a`;return(0,F.jsx)(sc,{x:e.x*l,y:e.y*l,width:e.width*l,height:e.height*l,fill:`#9aa0a6`,stroke:r,strokeWidth:r===`#4a4a4a`?1.5:3,cornerRadius:2,listening:!h,draggable:!h,onMouseDown:()=>n({kind:`obstacle`,id:e.id}),onTouchStart:()=>n({kind:`obstacle`,id:e.id}),dragBoundFunc:t=>({x:Math.min(Math.max(t.x,vc),vc+E-e.width*l),y:Math.min(Math.max(t.y,vc),vc+D-e.height*l)}),onDragMove:t=>ee({id:e.id,valid:pe(a,o,{...e,x:t.target.x()/l,y:t.target.y()/l})}),onDragEnd:t=>{let n=t.target.x()/l,r=t.target.y()/l,s=pe(a,o,{...e,x:n,y:r});t.target.position({x:(s?n:e.x)*l,y:(s?r:e.y)*l}),s&&i(e.id,n,r),ee(null)},onMouseEnter:e=>{let t=e.target.getStage()?.container();t&&!h&&(t.style.cursor=`grab`)},onMouseLeave:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=``)}},e.id)}),o.map(e=>{let t=s[e.type]?.shape??`chair`,n=y?.id===e.id,r=n?y.rect:e,i=n?y.valid?`valid`:`invalid`:g?.id===e.id?g.valid?`valid`:`invalid`:d===e.id?`selected`:`normal`,c=oe({...r,rotation:e.rotation}),u=r.width*l,m=r.height*l;return(0,F.jsxs)(oc,{x:(r.x+r.width/2)*l,y:(r.y+r.height/2)*l,offsetX:u/2,offsetY:m/2,rotation:e.rotation,listening:h,draggable:h&&!e.locked,onMouseDown:()=>f(e.id),onTouchStart:()=>f(e.id),dragBoundFunc:e=>{let t=c.width/2*l,n=c.height/2*l;return{x:Math.min(Math.max(e.x,vc+t),vc+E-t),y:Math.min(Math.max(e.y,vc+n),vc+D-n)}},onDragStart:e=>{e.target.moveToTop()},onDragMove:t=>{let n=te(e,t.target);_({id:e.id,valid:le(n,o,a,e.id)})},onDragEnd:t=>{let n=t.target,r=te(e,n),i=le(r,o,a,e.id),s=i?r:e;n.position({x:(s.x+e.width/2)*l,y:(s.y+e.height/2)*l}),i&&p(e.id,r.x,r.y),_(null)},onMouseEnter:t=>{let n=t.target.getStage()?.container();n&&(n.style.cursor=e.locked?`not-allowed`:`grab`)},onMouseLeave:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=``)},children:[(0,F.jsx)(gc,{shape:t,width:r.width,height:r.height,pxPerM:l,outline:i}),e.locked&&(0,F.jsx)(Ac,{w:u,h:m,rotation:e.rotation})]},e.id)}),o.map(e=>{let t=s[e.type]?.shape===`screen`;if(!h||e.id!==d||!t||e.locked||e.rotation!==0||g?.id===e.id)return null;let n=y?.id===e.id?y.rect:e,r={left:[n.x,n.y+n.height/2],right:[n.x+n.width,n.y+n.height/2]};return kc.map(t=>(0,F.jsx)(sc,{x:r[t][0]*l,y:r[t][1]*l,offsetX:_c/2,offsetY:_c/2,width:_c,height:_c,fill:`#fff`,stroke:`#1c7ed6`,strokeWidth:2,cornerRadius:2,hitStrokeWidth:12,draggable:!0,dragBoundFunc:function(){return this.absolutePosition()},onDragStart:t=>{t.cancelBubble=!0,x.current={x:e.x,y:e.y,width:e.width,height:e.height}},onDragMove:n=>{let r=n.target.getStage()?.getPointerPosition(),i=x.current;if(!r||!i)return;let s=be(i,t,(r.x-vc)/l,a);b({id:e.id,rect:s,valid:le({...e,...s},o,a,e.id)})},onDragEnd:()=>{y?.valid&&m(e.id,y.rect),b(null),x.current=null},onMouseEnter:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=`ew-resize`)},onMouseLeave:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=``)}},`${e.id}-${t}`))}),!h&&a.doors.map(e=>{let t=S?.kind===`door`&&S.id===e.id?S.offset:e.offset;return ae(`door`,e.id,e.wall,t,e.width,k(a,{...e,offset:t}))}),!h&&a.screens.map(e=>{let t=S?.kind===`screen`&&S.id===e.id?S.offset:e.offset;return ae(`screen`,e.id,e.wall,t,e.width,re(a,e.wall,t,e.width,.3))}),c&&(0,F.jsx)(`Group`,{x:c.x*l,y:c.y*l,listening:!1,children:(0,F.jsx)(gc,{shape:c.shape,width:c.width,height:c.height,pxPerM:l,outline:c.valid?`valid`:`invalid`,opacity:.85})})]})})})}function Mc({mode:e,onChange:t}){let n=t=>({flex:1,height:30,border:`none`,borderRadius:6,cursor:`pointer`,font:`600 13px system-ui, sans-serif`,background:e===t?`#fff`:`transparent`,color:e===t?`#222`:`#666`,boxShadow:e===t?`0 1px 3px rgba(0,0,0,0.15)`:`none`});return(0,F.jsxs)(`div`,{style:{gridColumn:`1 / -1`,display:`flex`,gap:2,padding:3,background:`#d9d9d9`,borderRadius:9},children:[(0,F.jsx)(`button`,{style:n(`layout`),onClick:()=>t(`layout`),children:`Layout`}),(0,F.jsx)(`button`,{style:n(`room`),onClick:()=>t(`room`),children:`Room`})]})}var Nc=34,Pc=4,Fc=7,Ic=12,Lc=4,Rc=40,zc=40;function Bc({value:e,min:t,max:n=999,step:r=1,wrap:i=!1,rows:a=5,disabled:o=!1,format:s,onChange:c}){let l=e=>Math.round(e/r),u=(String(r).split(`.`)[1]??``).length,[d,f]=(0,v.useState)(l(e)),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),b=(0,v.useRef)(l(e)),x=(0,v.useRef)(l(e)),S=(0,v.useRef)(0),C=(0,v.useRef)(0),w=(0,v.useRef)(l(e)),T=(0,v.useRef)(null),ee=(0,v.useRef)(null),E=(0,v.useRef)([]),D=l(t),te=l(n),ne=te-D+1,O=(0,v.useRef)({imin:D,imax:te,n:ne,wrap:i,step:r,onChange:c,valueIdx:l(e)});O.current={imin:D,imax:te,n:ne,wrap:i,step:r,onChange:c,valueIdx:l(e)};let re=e=>O.current.imin+((e-O.current.imin)%O.current.n+O.current.n)%O.current.n,k=e=>O.current.wrap?re(e):e,A=e=>O.current.wrap?e:Math.min(O.current.imax,Math.max(O.current.imin,e)),ie=e=>{let t=A(e);b.current=t,f(t);let n=k(Math.round(t));return n!==x.current&&(x.current=n,O.current.onChange(Math.round(n*O.current.step*1e3)/1e3)),t},ae=()=>{cancelAnimationFrame(S.current),S.current=0,window.clearTimeout(C.current),C.current=0},j=()=>{let e=Math.round(b.current);if(!O.current.wrap)return O.current.valueIdx;let t=re(O.current.valueIdx-e+O.current.imin)-O.current.imin;return e+(t>O.current.n/2?t-O.current.n:t)},oe=()=>{S.current=requestAnimationFrame(()=>{S.current=0,!ee.current&&k(Math.round(b.current))!==O.current.valueIdx&&(x.current=O.current.valueIdx,M(j(),0))})},se=e=>{ae();let t=A(Math.round(e));w.current=t;let n=performance.now(),r=e=>{let i=Math.min(.05,(e-n)/1e3);n=e;let a=b.current+(t-b.current)*(1-Math.exp(-7*i));Math.abs(t-a)<.003?(ie(t),S.current=0,oe()):(ie(a),S.current=requestAnimationFrame(r))};S.current=requestAnimationFrame(r)};function M(e,t){ae();let n=A(Math.round(e));w.current=n;let r=b.current-n,i=Math.abs(r),a=i>0&&Math.sign(t)===-Math.sign(r)?Math.max(Ic,Math.abs(t)/i):Ic,o=t+a*r,s=performance.now(),c=e=>{let t=(e-s)/1e3,i=Math.exp(-a*t),l=n+(r+o*t)*i,u=(o-a*(r+o*t))*i;Math.abs(l-n)<.003&&Math.abs(u)<.05||t>1.5?(ie(n),S.current=0,oe()):(ie(l),S.current=requestAnimationFrame(c))};S.current=requestAnimationFrame(c)}(0,v.useEffect)(()=>{if(ee.current||S.current)return;let e=j();b.current=e,x.current=k(Math.round(e)),f(e)},[e]),(0,v.useEffect)(()=>ae,[]);let ce=(0,v.useRef)(``),le=(0,v.useRef)(0),ue=()=>{window.clearTimeout(le.current);let e=ce.current;ce.current=``,y(``);let t=parseFloat(e);if(Number.isNaN(t))return;let n=O.current,r=Math.round(t/n.step);if(n.wrap){let e=re(r)-re(Math.round(b.current));r=Math.round(b.current)+(Math.abs(e)>n.n/2?e-Math.sign(e)*n.n:e)}else r=Math.min(n.imax,Math.max(n.imin,r));se(r)},de=e=>{ce.current=e,y(e),window.clearTimeout(le.current),e&&(le.current=window.setTimeout(ue,1500))};(0,v.useEffect)(()=>{if(!h||o)return;let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=ce.current,n=()=>{e.preventDefault(),e.stopImmediatePropagation()};/^[0-9]$/.test(e.key)||e.key===`.`&&u>0&&!t.includes(`.`)?(n(),t.length<6&&(ae(),de(t+e.key))):e.key===`Backspace`||e.key===`Delete`?(n(),de(t.slice(0,-1))):e.key===`Enter`&&t?(n(),ue()):e.key===`Escape`&&t&&(n(),de(``))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[h,o,u]),(0,v.useEffect)(()=>()=>window.clearTimeout(le.current),[]);let fe=e=>{if(o)return;e.currentTarget.setPointerCapture(e.pointerId);let t=S.current!==0||C.current!==0;ae(),ee.current={y0:e.clientY,pos0:b.current,moved:!1,wasMoving:t},E.current=[{t:performance.now(),pos:b.current}],m(!0)},pe=e=>{let t=ee.current;if(!t)return;let n=e.clientY-t.y0;Math.abs(n)>Pc&&(t.moved=!0);let r=ie(t.pos0-n/Nc),i=performance.now();E.current.push({t:i,pos:r}),E.current=E.current.filter(e=>i-e.t<100)},me=e=>{let t=ee.current;if(ee.current=null,m(!1),!t)return;if(!t.moved){if(t.wasMoving)M(b.current,0);else{let n=T.current.getBoundingClientRect(),r=Math.round((e.clientY-n.top-a*Nc/2)/Nc);b.current=t.pos0,se(Math.round(t.pos0)+r)}return}let n=performance.now(),r=E.current,i=0;if(r.length>1&&n-r[r.length-1].t<80){let e=r[0],t=(r[r.length-1].t-e.t)/1e3;t>.005&&(i=(r[r.length-1].pos-e.pos)/t)}i=Math.max(-40,Math.min(Rc,i)),Math.abs(i){if(!o){if(Math.abs(e.deltaY)>=zc){let t=S.current?w.current:Math.round(b.current);se(t+Math.sign(e.deltaY))}else ae(),ie(b.current+e.deltaY/(Nc*1.5)),C.current=window.setTimeout(()=>{C.current=0,M(b.current,0)},120)}},ge=e=>{if(!o){if(e.key===`ArrowUp`)se(Math.round(b.current)+1);else if(e.key===`ArrowDown`)se(Math.round(b.current)-1);else return;e.preventDefault()}},_e=Math.floor(a/2)+1,N=Math.round(d),ve=i?N-_e:Math.max(D,N-_e),ye=i?N+_e:Math.min(te,N+_e),be=[];for(let e=ve;e<=ye;e++){let t=e-d,n=(i?re(e):e)*r;be.push((0,F.jsx)(`div`,{style:{position:`absolute`,left:0,right:0,height:Nc,display:`flex`,alignItems:`center`,justifyContent:`center`,font:`600 20px system-ui, sans-serif`,color:`#222`,opacity:Math.max(0,1-Math.abs(t)*(a<=3?.55:.38)),transform:`translateY(${((a-1)/2+t)*Nc}px) scale(${1-Math.min(1,Math.abs(t))*.12})`,pointerEvents:`none`},children:s?s(n):n.toFixed(u)},e))}return(0,F.jsxs)(`div`,{ref:T,tabIndex:o?-1:0,role:`spinbutton`,"aria-valuenow":e,"aria-valuemin":t,"aria-valuemax":n,"aria-disabled":o,onPointerDown:fe,onPointerMove:pe,onPointerUp:me,onPointerCancel:me,onWheel:he,onKeyDown:ge,onMouseEnter:()=>g(!0),onMouseLeave:()=>{g(!1),ce.current&&ue()},title:o?void 0:`Scroll, drag, or hover and type a number`,style:{position:`relative`,width:`100%`,height:a*Nc,overflow:`hidden`,background:`#f4f4f4`,borderRadius:10,cursor:o?`not-allowed`:p?`grabbing`:`ns-resize`,opacity:o?.45:1,userSelect:`none`,touchAction:`none`,outline:`none`},children:[(0,F.jsx)(`div`,{style:{position:`absolute`,left:6,right:6,top:(a-1)/2*Nc,height:Nc,background:`rgba(0,0,0,0.08)`,borderRadius:8,pointerEvents:`none`}}),be,_&&(0,F.jsxs)(`div`,{style:{position:`absolute`,left:6,right:6,top:(a-1)/2*Nc,height:Nc,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`#fff`,border:`1.5px solid #1c7ed6`,borderRadius:8,boxSizing:`border-box`,font:`600 20px system-ui, sans-serif`,color:`#1c7ed6`,pointerEvents:`none`},children:[_,(0,F.jsx)(`span`,{style:{width:1.5,height:20,background:`#1c7ed6`,marginLeft:2}})]})]})}var Vc={gridColumn:`1 / -1`,display:`flex`,flexDirection:`column`,gap:14},Hc={font:`600 12px system-ui, sans-serif`,color:`#555`,marginBottom:4},Uc={font:`12px system-ui, sans-serif`,color:`#888`,marginTop:4},Wc={font:`600 15px system-ui, sans-serif`,color:`#222`},Gc={alignSelf:`flex-start`,border:`none`,background:`none`,padding:0,cursor:`pointer`,font:`13px system-ui, sans-serif`,color:`#555`},Kc={height:32,padding:`0 12px`,border:`1px solid #c4c4c4`,background:`#fff`,borderRadius:8,cursor:`pointer`,font:`13px system-ui, sans-serif`,color:`#222`},qc={display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(96px, 1fr))`,gap:12},Jc=e=>e.toFixed(1);function Yc(e){(0,v.useEffect)(()=>{let t=t=>t.key===`Escape`&&e();return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}var Xc={...Kc,color:`#e03131`,borderColor:`#e8a8a8`};function Zc({room:e,minSize:t,notice:n,onResize:r,onAddDoor:i,onAddScreen:a,onAddObstacle:o,onExport:s,onImport:c}){let l=(0,v.useRef)(null),u=t.width>C.min||t.height>C.min;return(0,F.jsxs)(`div`,{style:Vc,children:[(0,F.jsx)(`div`,{style:Wc,children:`Room`}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Size (m)`}),(0,F.jsxs)(`div`,{style:qc,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Uc,children:`Width`}),(0,F.jsx)(Bc,{value:e.width,min:t.width,max:C.max,step:.1,rows:3,format:Jc,onChange:e=>r({width:e})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Uc,children:`Length`}),(0,F.jsx)(Bc,{value:e.height,min:t.height,max:C.max,step:.1,rows:3,format:Jc,onChange:e=>r({height:e})})]})]}),u&&(0,F.jsxs)(`div`,{style:Uc,children:[`The room can't shrink past what's placed in it (min `,Jc(t.width),` × `,Jc(t.height),` m).`]})]}),(0,F.jsxs)(`div`,{style:{display:`grid`,gap:8},children:[(0,F.jsx)(`button`,{style:Kc,onClick:i,children:`Add door`}),(0,F.jsx)(`button`,{style:{...Kc,opacity:e.screens.length>=2?.45:1},disabled:e.screens.length>=2,onClick:a,children:`Add screen`}),e.screens.length>=2&&(0,F.jsxs)(`div`,{style:{...Uc,marginTop:-4},children:[`Maximum of `,2,` screens.`]}),(0,F.jsx)(`button`,{style:Kc,onClick:o,children:`Add obstacle`})]}),n&&(0,F.jsx)(`div`,{style:{...Uc,color:`#e03131`,marginTop:0},children:n}),(0,F.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,F.jsx)(`button`,{style:{...Kc,flex:1},onClick:s,children:`Export room`}),(0,F.jsx)(`button`,{style:{...Kc,flex:1},onClick:()=>l.current?.click(),children:`Import room`}),(0,F.jsx)(`input`,{ref:l,type:`file`,accept:`application/json,.json`,style:{display:`none`},onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&c(t)}})]}),(0,F.jsx)(`div`,{style:Uc,children:`Furniture isn't included in room.json.`})]})}function Qc({door:e,isLast:t,notice:n,onPatch:r,onDelete:i,onClose:a}){return Yc(a),(0,F.jsxs)(`div`,{style:Vc,children:[(0,F.jsx)(`button`,{onClick:a,style:Gc,children:`← Done`}),(0,F.jsx)(`div`,{style:Wc,children:`Door`}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Width (m)`}),(0,F.jsx)(Bc,{value:e.width,min:w.min,max:w.max,step:.1,rows:3,format:Jc,onChange:e=>r({width:e})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{style:{...Kc,width:`100%`,background:e.isLoading?`#2b2b2b`:`#fff`,color:e.isLoading?`#fff`:`#222`},onClick:()=>r({isLoading:!e.isLoading}),children:[`Loading door: `,e.isLoading?`on`:`off`]}),(0,F.jsx)(`div`,{style:Uc,children:`Furniture is carried through a loading door.`})]}),(0,F.jsx)(`div`,{style:Uc,children:`The swing area and 0.6 m inside the opening stay clear of furniture.`}),n&&(0,F.jsx)(`div`,{style:{...Uc,color:`#e03131`,marginTop:0},children:n}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`button`,{style:{...Xc,width:`100%`,opacity:t?.45:1,cursor:t?`not-allowed`:`pointer`},disabled:t,onClick:i,children:`Delete door`}),t&&(0,F.jsx)(`div`,{style:Uc,children:`A room needs at least one door.`})]})]})}function $c({screen:e,notice:t,onPatch:n,onDelete:r,onClose:i}){return Yc(i),(0,F.jsxs)(`div`,{style:Vc,children:[(0,F.jsx)(`button`,{onClick:i,style:Gc,children:`← Done`}),(0,F.jsx)(`div`,{style:Wc,children:`Screen`}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Width (m)`}),(0,F.jsx)(Bc,{value:e.width,min:T.min,max:T.max,step:.1,rows:3,format:Jc,onChange:e=>n({width:e})})]}),(0,F.jsx)(`div`,{style:Uc,children:`Drag it along its wall. A 0.3 m strip in front of the wall stays clear.`}),t&&(0,F.jsx)(`div`,{style:{...Uc,color:`#e03131`,marginTop:0},children:t}),(0,F.jsx)(`button`,{style:Xc,onClick:r,children:`Delete screen`})]})}function el({obstacle:e,notice:t,onPatch:n,onDelete:r,onClose:i}){return Yc(i),(0,F.jsxs)(`div`,{style:Vc,children:[(0,F.jsx)(`button`,{onClick:i,style:Gc,children:`← Done`}),(0,F.jsx)(`div`,{style:Wc,children:`Obstacle`}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Size (m)`}),(0,F.jsxs)(`div`,{style:qc,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Uc,children:`Width`}),(0,F.jsx)(Bc,{value:e.width,min:ee.min,max:ee.max,step:.1,rows:3,format:Jc,onChange:e=>n({width:e})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Uc,children:`Length`}),(0,F.jsx)(Bc,{value:e.height,min:ee.min,max:ee.max,step:.1,rows:3,format:Jc,onChange:e=>n({height:e})})]})]})]}),t&&(0,F.jsx)(`div`,{style:{...Uc,color:`#e03131`,marginTop:0},children:t}),(0,F.jsx)(`button`,{style:Xc,onClick:r,children:`Delete obstacle`})]})}function tl({pxPerM:e,roomWidthPx:t}){return(0,F.jsx)(`div`,{style:{width:t,height:40,display:`flex`,alignItems:`flex-end`,paddingBottom:4,boxSizing:`border-box`},children:(0,F.jsxs)(`div`,{style:{font:`12px system-ui, sans-serif`,color:`#555`},children:[(0,F.jsx)(`div`,{style:{width:e,height:6,borderBottom:`2px solid #555`,borderLeft:`2px solid #555`,borderRight:`2px solid #555`,boxSizing:`border-box`,marginBottom:2}}),`1 m`]})})}function nl({config:e,placed:t,onSetAvailable:n,onSetSeats:r,onClose:i}){return(0,v.useEffect)(()=>{let e=e=>e.key===`Escape`&&i();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,F.jsxs)(`div`,{style:Vc,children:[(0,F.jsx)(`button`,{onClick:i,style:Gc,children:`← Back`}),(0,F.jsx)(`div`,{style:Wc,children:e.name}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Available`}),(0,F.jsx)(Bc,{value:e.available,min:t,onChange:n}),(0,F.jsxs)(`div`,{style:Uc,children:[t,` placed`]})]}),e.shape===`screen`&&(0,F.jsx)(`div`,{style:Uc,children:`Click a placed screen, then drag an end handle (or use the Length wheel) to change its length.`}),e.seatsPerUnit!==void 0&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:e.isTable?`Seats per table`:`Seats each`}),(0,F.jsx)(Bc,{value:e.seatsPerUnit,min:1,onChange:r})]})]})}var rl=120,il=46;function al({value:e,disabled:t=!1,onChange:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(!1),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),l=(0,v.useRef)(``),u=(0,v.useRef)(0),d=(0,v.useRef)({onChange:n});d.current={onChange:n};let f=e=>{l.current=e,c(e),window.clearTimeout(u.current),e&&(u.current=window.setTimeout(p,1500))};function p(){window.clearTimeout(u.current);let e=parseInt(l.current,10);l.current=``,c(``),Number.isNaN(e)||d.current.onChange((e%360+360)%360)}(0,v.useEffect)(()=>{if(!a||t)return;let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=l.current,n=()=>{e.preventDefault(),e.stopImmediatePropagation()};/^[0-9]$/.test(e.key)?(n(),t.length<3&&f(t+e.key)):e.key===`Backspace`||e.key===`Delete`?(n(),f(t.slice(0,-1))):e.key===`Enter`&&t?(n(),p()):e.key===`Escape`&&t&&(n(),f(``))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[a,t]),(0,v.useEffect)(()=>()=>window.clearTimeout(u.current),[]);let m=e=>(Math.round(e)%360+360)%360,h=e=>{let t=r.current.getBoundingClientRect(),n=e.clientX-(t.left+t.width/2),i=e.clientY-(t.top+t.height/2),a=Math.atan2(n,-i)*180/Math.PI;return e.shiftKey&&(a=Math.round(a/15)*15),m(a)},g=e=>{t||(e.currentTarget.setPointerCapture(e.pointerId),i.current=!0,n(h(e)))},_=e=>{i.current&&n(h(e))},y=()=>{i.current=!1},b=e*Math.PI/180,x=rl/2,S=x+il*Math.sin(b),C=x-il*Math.cos(b);return(0,F.jsxs)(`svg`,{ref:r,width:`100%`,viewBox:`0 0 ${rl} ${rl}`,style:{maxWidth:160,display:`block`,margin:`0 auto`,touchAction:`none`,userSelect:`none`,opacity:t?.45:1,cursor:t?`not-allowed`:`pointer`,outline:`none`},tabIndex:t?-1:0,role:`slider`,"aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":359,onMouseEnter:()=>o(!0),onMouseLeave:()=>{o(!1),l.current&&p()},onPointerDown:g,onPointerMove:_,onPointerUp:y,onPointerCancel:y,onWheel:r=>!t&&n(m(e+Math.sign(r.deltaY))),onKeyDown:r=>{if(!t){if(r.key===`ArrowRight`||r.key===`ArrowUp`)n(m(e+1));else if(r.key===`ArrowLeft`||r.key===`ArrowDown`)n(m(e-1));else return;r.preventDefault()}},children:[(0,F.jsx)(`circle`,{cx:x,cy:x,r:56,fill:`#f4f4f4`}),(0,F.jsx)(`circle`,{cx:x,cy:x,r:il,fill:`#fff`,stroke:`#bbb`,strokeWidth:2}),[0,90,180,270].map(e=>{let t=e*Math.PI/180;return(0,F.jsx)(`line`,{x1:x+40*Math.sin(t),y1:x-40*Math.cos(t),x2:x+il*Math.sin(t),y2:x-il*Math.cos(t),stroke:`#bbb`,strokeWidth:2},e)}),(0,F.jsx)(`line`,{x1:x,y1:x,x2:S,y2:C,stroke:`#1c7ed6`,strokeWidth:2,opacity:.5}),(0,F.jsx)(`circle`,{cx:S,cy:C,r:9,fill:`#1c7ed6`,stroke:`#fff`,strokeWidth:2}),(0,F.jsx)(`text`,{x,y:66,textAnchor:`middle`,style:{font:`600 18px system-ui, sans-serif`,fill:s?`#1c7ed6`:`#222`},children:s?`${s}|`:`${e}°`})]})}var ol=.3,sl=6,cl=e=>e.toFixed(1);function ll({item:e,config:t,onPatch:n,onDelete:r,onClose:i}){let[a,o]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=e=>e.key===`Escape`&&i();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]);let s=e=>{let t=n(e);o(t?``:`No room for that change.`)},c=t.shape===`screen`,l=je(e,t)??1,u=e.seatsOverride!==void 0,d=(e,t)=>Math.min(t,e);return(0,F.jsxs)(`div`,{style:Vc,children:[(0,F.jsx)(`button`,{onClick:i,style:Gc,children:`← Done`}),(0,F.jsxs)(`div`,{style:Wc,children:[t.name,e.locked?` 🔒`:``]}),t.rotatable&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Rotation`}),(0,F.jsx)(al,{value:e.rotation,disabled:e.locked,onChange:e=>s({rotation:e})})]}),t.isTable&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Seats at this table`}),(0,F.jsx)(Bc,{value:l,min:1,max:99,rows:3,format:e=>String(e),onChange:e=>s({seatsOverride:e})}),u&&(0,F.jsxs)(`button`,{onClick:()=>s({seatsOverride:void 0}),style:{...Uc,border:`none`,background:`none`,padding:0,cursor:`pointer`,color:`#1c7ed6`,textDecoration:`underline`},children:[`Reset to default (`,t.seatsPerUnit??1,`)`]})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Size (m)`}),(0,F.jsx)(`div`,{style:qc,children:c?(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Uc,children:`Length`}),(0,F.jsx)(Bc,{value:e.width,min:.5,max:sl,step:.1,rows:3,format:cl,onChange:e=>s({width:e})})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Uc,children:`Width`}),(0,F.jsx)(Bc,{value:e.width,min:d(e.width,ol),max:sl,step:.1,rows:3,format:cl,onChange:e=>s({width:e})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Uc,children:`Length`}),(0,F.jsx)(Bc,{value:e.height,min:d(e.height,ol),max:sl,step:.1,rows:3,format:cl,onChange:e=>s({height:e})})]})]})})]}),a&&(0,F.jsx)(`div`,{style:{...Uc,color:`#e03131`,marginTop:0},children:a}),(0,F.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,F.jsx)(`button`,{style:{...Kc,flex:1},onClick:()=>s({locked:!e.locked}),children:e.locked?`Unlock`:`Lock`}),(0,F.jsx)(`button`,{style:{...Kc,flex:1,color:`#e03131`,borderColor:`#e8a8a8`},onClick:r,children:`Delete`})]})]})}var ul=e=>e.toFixed(1),dl={width:.5,height:.5,seats:1},fl={width:1.8,height:.8,seats:8};function pl({onSave:e,onCancel:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(dl.width),[c,l]=(0,v.useState)(dl.height),[u,d]=(0,v.useState)(dl.seats),[f,p]=(0,v.useState)(10);(0,v.useEffect)(()=>{let e=e=>e.key===`Escape`&&t();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let m=e=>{a(e);let t=e?fl:dl;s(t.width),l(t.height),d(t.seats)},h=n.trim().length>0,g=e=>({...Kc,flex:1,background:e?`#2b2b2b`:`#fff`,color:e?`#fff`:`#222`});return(0,F.jsxs)(`div`,{style:Vc,children:[(0,F.jsx)(`button`,{onClick:t,style:Gc,children:`← Cancel`}),(0,F.jsx)(`div`,{style:Wc,children:`New furniture`}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Name`}),(0,F.jsx)(`input`,{value:n,autoFocus:!0,maxLength:24,placeholder:`e.g. Couch`,onChange:e=>r(e.target.value),style:{width:`100%`,boxSizing:`border-box`,height:32,padding:`0 10px`,border:`1px solid #c4c4c4`,borderRadius:8,font:`14px system-ui, sans-serif`}})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Type`}),(0,F.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,F.jsx)(`button`,{style:g(!i),onClick:()=>m(!1),children:`Seating`}),(0,F.jsx)(`button`,{style:g(i),onClick:()=>m(!0),children:`Table`})]})]}),(0,F.jsxs)(`div`,{style:qc,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Width (m)`}),(0,F.jsx)(Bc,{value:o,min:.3,max:6,step:.1,rows:3,format:ul,onChange:s})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Length (m)`}),(0,F.jsx)(Bc,{value:c,min:.3,max:6,step:.1,rows:3,format:ul,onChange:l})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Seats`}),(0,F.jsx)(Bc,{value:u,min:1,max:99,rows:3,onChange:d})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{style:Hc,children:`Available`}),(0,F.jsx)(Bc,{value:f,min:1,max:999,rows:3,onChange:p})]})]}),!h&&(0,F.jsx)(`div`,{style:Uc,children:`Enter a name to save.`}),(0,F.jsx)(`button`,{style:{...Kc,background:h?`#2b2b2b`:`#ddd`,color:h?`#fff`:`#999`,cursor:h?`pointer`:`not-allowed`},disabled:!h,onClick:()=>e({name:n.trim(),isTable:i,width:o,height:c,seats:u,available:f}),children:`Save`})]})}var ml=40;function hl(){let[e,t]=(0,v.useReducer)(Oe,De),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)({kind:`tiles`}),[o,s]=(0,v.useState)(null),c=(0,v.useRef)(null),l=(0,v.useRef)(null),u=(0,v.useRef)(e.room);u.current=e.room;let[d,f]=(0,v.useState)(60),[p,m]=(0,v.useState)(`layout`),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(``),S=(0,v.useRef)(1),C=(0,v.useRef)(1),w=e.items.find(e=>e.id===o)??null,T=(0,v.useCallback)(e=>{s(e),e&&a({kind:`tiles`})},[]),ee=e=>{s(null),a(e)},E=(0,v.useCallback)(()=>a({kind:`tiles`}),[]),D=(0,v.useCallback)(()=>s(null),[]),te=e=>{m(e),s(null),g(null),y(``),a({kind:`tiles`})},ne=(0,v.useCallback)(()=>{g(null),y(``)},[]),re=(0,v.useCallback)(()=>{o&&(t({kind:`remove`,id:o}),s(null))},[o]);(0,v.useEffect)(()=>{let e=e=>{if(e.key!==`Delete`&&e.key!==`Backspace`)return;let t=e.target;(!t||t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&!t.isContentEditable)&&(h?(e.preventDefault(),P()):o&&(e.preventDefault(),re()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o,re,h,e.room]),(0,v.useEffect)(()=>{let e=l.current;if(!e)return;let t=new ResizeObserver(([e])=>{let{width:t,height:n}=e.contentRect;f(b(u.current,t-12,n-12-ml))});return t.observe(e),()=>t.disconnect()},[e.room.width,e.room.height]);let k=t=>{let n=c.current?.getBoundingClientRect();if(!n)return null;let r=(n.width-e.room.width*d)/2,i=t.clientX-n.left-r,a=t.clientY-n.top-r;if(i<0||a<0||i>e.room.width*d||a>e.room.height*d)return null;let{defaultWidth:o,defaultHeight:s}=e.configs[t.type];return se({x:i/d-o/2,y:a/d-s/2,width:o,height:s},e.room)};(0,v.useEffect)(()=>{if(!n)return;let i=n.type,a=e=>r({type:i,clientX:e.clientX,clientY:e.clientY}),o=n=>{let a=k({type:i,clientX:n.clientX,clientY:n.clientY});a&&Ae(e.items,i,e.configs[i].available)>0&&le(a,e.items,e.room)&&t({kind:`add`,id:`item-${S.current++}`,type:i,x:a.x,y:a.y}),r(null)},s=()=>r(null);return window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,s),()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,s)}},[n?.type,e.items,e.room,e.configs,d]);let A=(0,v.useMemo)(()=>{if(!n)return null;let t=k(n);return t?{shape:e.configs[n.type].shape,...t,valid:le(t,e.items,e.room)}:null},[n,e.items,e.room,d]),ie=(e,t,n)=>{a({kind:`tiles`}),r({type:e,clientX:t,clientY:n})},ae=(n,r)=>{if(!(`rotation`in r||`width`in r||`height`in r))return t({kind:`update`,id:n.id,patch:r}),!0;let i=ue(n,r,e.items,e.room);return i?(t({kind:`update`,id:n.id,patch:{...r,x:i.x,y:i.y}}),!0):!1},j=e.room,oe=e=>{t({kind:`setRoom`,room:e}),y(``)},M=e=>y(e),ce=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,de=t=>{let n=_e(j,e.items,t);n?oe(n):M(`Can't shrink past what's placed in the room.`)},he=()=>{for(let t of[`bottom`,`right`,`left`,`top`]){let n=N(j,e.items,`door`,t,x);if(n===null)continue;let r={id:ce(`door`),wall:t,offset:n,width:x,isLoading:!1};oe({...j,doors:[...j.doors,r]}),g({kind:`door`,id:r.id});return}M(`No free space on any wall for a door.`)},ye=()=>{if(!(j.screens.length>=2)){for(let t of[`top`,`left`,`right`,`bottom`]){let n=Math.min(4,O(j,t)),r=N(j,e.items,`screen`,t,n);if(r===null)continue;let i={id:ce(`screen`),wall:t,offset:r,width:n};oe({...j,screens:[...j.screens,i]}),g({kind:`screen`,id:i.id});return}M(`No free space on any wall for a screen.`)}},be=()=>{let t=ve(j,e.items,.6,.6);if(!t)return M(`No free space for an obstacle.`);let n={id:ce(`obstacle`),...t,width:.6,height:.6};oe({...j,obstacles:[...j.obstacles,n]}),g({kind:`obstacle`,id:n.id})},xe=(t,n)=>{let r=j.doors.find(e=>e.id===t);if(!r)return;let i={...r,...n};if(i.offset=Math.max(0,Math.min(i.offset,O(j,i.wall)-i.width)),!fe(j,e.items,{id:t,kind:`door`,wall:i.wall,offset:i.offset,width:i.width}))return M(`No room for that change.`);oe({...j,doors:j.doors.map(e=>e.id===t?i:e)})},Se=(t,n)=>{let r=j.screens.find(e=>e.id===t);if(!r)return;let i={...r,...n};if(i.offset=Math.max(0,Math.min(i.offset,O(j,i.wall)-i.width)),!fe(j,e.items,{id:t,kind:`screen`,wall:i.wall,offset:i.offset,width:i.width}))return M(`No room for that change.`);oe({...j,screens:j.screens.map(e=>e.id===t?i:e)})},Ce=(t,n)=>{let r=j.obstacles.find(e=>e.id===t);if(!r)return;let i=se({...r,...n},j);if(!pe(j,e.items,i))return M(`No room for that change.`);oe({...j,obstacles:j.obstacles.map(e=>e.id===t?i:e)})},P=()=>{if(h){if(h.kind===`door`){if(j.doors.length<=1)return M(`A room needs at least one door.`);oe({...j,doors:j.doors.filter(e=>e.id!==h.id)})}else h.kind===`screen`?oe({...j,screens:j.screens.filter(e=>e.id!==h.id)}):oe({...j,obstacles:j.obstacles.filter(e=>e.id!==h.id)});g(null)}},Ee=()=>{let e=URL.createObjectURL(new Blob([we(j)],{type:`application/json`})),t=document.createElement(`a`);t.href=e,t.download=`room.json`,t.click(),URL.revokeObjectURL(e)},je=async n=>{let r=Te(await n.text());if(!r.ok)return M(`Import failed: ${r.error}`);if(e.items.length>0&&!window.confirm(`Importing replaces the current room. Continue?`))return;let i=e.items.length>0&&!me(r.room,e.items);t({kind:`setRoom`,room:r.room,clearItems:i}),s(null),g(null),y(i?`Furniture was cleared because it didn't fit the imported room.`:``)},Me=e=>{let n=`custom-${C.current++}`;t({kind:`addConfig`,config:{id:n,name:e.name,shape:e.isTable?`table`:`chair`,defaultWidth:e.width,defaultHeight:e.height,isTable:e.isTable,rotatable:!0,available:e.available,seatsPerUnit:e.seats}}),a({kind:`tiles`})},Ne=Object.fromEntries(e.typeOrder.map(t=>[t,Ae(e.items,t,e.configs[t].available)])),Pe=null;if(p===`room`){let t=h?.kind===`door`?j.doors.find(e=>e.id===h.id):void 0,n=h?.kind===`screen`?j.screens.find(e=>e.id===h.id):void 0,r=h?.kind===`obstacle`?j.obstacles.find(e=>e.id===h.id):void 0;Pe=t?(0,F.jsx)(Qc,{door:t,isLast:j.doors.length<=1,notice:_,onPatch:e=>xe(t.id,e),onDelete:P,onClose:ne},t.id):n?(0,F.jsx)($c,{screen:n,notice:_,onPatch:e=>Se(n.id,e),onDelete:P,onClose:ne},n.id):r?(0,F.jsx)(el,{obstacle:r,notice:_,onPatch:e=>Ce(r.id,e),onDelete:P,onClose:ne},r.id):(0,F.jsx)(Zc,{room:j,minSize:ge(j,e.items),notice:_,onResize:de,onAddDoor:he,onAddScreen:ye,onAddObstacle:be,onExport:Ee,onImport:je})}else if(w)Pe=(0,F.jsx)(ll,{item:w,config:e.configs[w.type],onPatch:e=>ae(w,e),onDelete:re,onClose:D},w.id);else if(i.kind===`type`){let n=i.id;Pe=(0,F.jsx)(nl,{config:e.configs[n],placed:ke(e.items,n),onSetAvailable:e=>t({kind:`setAvailable`,type:n,value:e}),onSetSeats:e=>t({kind:`setSeats`,type:n,value:e}),onClose:E})}else i.kind===`custom`&&(Pe=(0,F.jsx)(pl,{onSave:Me,onCancel:E}));return(0,F.jsxs)(`div`,{style:{display:`flex`,height:`100vh`,background:`#e9e9e9`,cursor:n?`grabbing`:void 0},children:[(0,F.jsx)(Ue,{types:e.typeOrder.map(t=>e.configs[t]),remaining:Ne,onStartDrag:ie,onOpenMenu:e=>ee({kind:`type`,id:e}),onNewCustom:()=>ee({kind:`custom`}),header:(0,F.jsx)(Mc,{mode:p,onChange:te}),panel:Pe}),(0,F.jsxs)(`main`,{ref:l,style:{flex:1,minWidth:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,overflow:`hidden`,padding:24},children:[(0,F.jsx)(jc,{mode:p,roomSel:h,onSelectRoom:e=>{g(e),y(``)},onMoveWallItem:(e,t,n)=>e===`door`?xe(t,{offset:n}):Se(t,{offset:n}),onMoveObstacle:(e,t,n)=>Ce(e,{x:t,y:n}),pxPerM:d,room:e.room,items:e.items,configs:e.configs,preview:A,floorRef:c,selectedId:o,onSelect:T,onMove:(e,n,r)=>t({kind:`move`,id:e,x:n,y:r}),onResize:(e,n)=>t({kind:`update`,id:e,patch:{...n}})}),(0,F.jsx)(tl,{pxPerM:d,roomWidthPx:e.room.width*d+12})]}),n&&!A&&(0,F.jsx)(`div`,{style:{position:`fixed`,left:n.clientX,top:n.clientY,transform:`translate(-50%, -50%)`,pointerEvents:`none`,opacity:.8},children:(0,F.jsx)(Ie,{shape:e.configs[n.type].shape})})]})}document.body.style.margin=`0`,(0,y.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(hl,{}));