From c055960b743afa61ae8d6ae4a710e9dd6f21f411 Mon Sep 17 00:00:00 2001 From: Sia Date: Sat, 30 May 2026 15:29:52 +0200 Subject: [PATCH] fix: send text alignment command values --- .../{index-BChN-qVl.js => index-DrD1_fGU.js} | 2 +- docs/index.html | 2 +- src/features/ribbon/FormatControls.tsx | 26 ++++++++++++------- src/features/ribbon/RibbonMenu.test.tsx | 10 +++++++ 4 files changed, 28 insertions(+), 12 deletions(-) rename docs/assets/{index-BChN-qVl.js => index-DrD1_fGU.js} (69%) diff --git a/docs/assets/index-BChN-qVl.js b/docs/assets/index-DrD1_fGU.js similarity index 69% rename from docs/assets/index-BChN-qVl.js rename to docs/assets/index-DrD1_fGU.js index 7816131..aca085b 100644 --- a/docs/assets/index-BChN-qVl.js +++ b/docs/assets/index-DrD1_fGU.js @@ -5,5 +5,5 @@ var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Obje `+i[o].replace(` at new `,` at `);return e.displayName&&c.includes(``)&&(c=c.replace(``,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{he=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?me(e):``}function _e(e){switch(e.tag){case 5:return me(e.type);case 16:return me(`Lazy`);case 13:return me(`Suspense`);case 19:return me(`SuspenseList`);case 0:case 2:case 15:return e=ge(e.type,!1),e;case 11:return e=ge(e.type.render,!1),e;case 1:return e=ge(e.type,!0),e;default:return``}}function ve(e){if(e==null)return null;if(typeof e==`function`)return e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case te:return`Fragment`;case S:return`Portal`;case re:return`Profiler`;case ne:return`StrictMode`;case se:return`Suspense`;case ce:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case ae:return(e.displayName||`Context`)+`.Consumer`;case ie:return(e._context.displayName||`Context`)+`.Provider`;case oe:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case le:return t=e.displayName||null,t===null?ve(e.type)||`Memo`:t;case ue:t=e._payload,e=e._init;try{return ve(e(t))}catch{}}return null}function ye(e){var t=e.type;switch(e.tag){case 24:return`Cache`;case 9:return(t.displayName||`Context`)+`.Consumer`;case 10:return(t._context.displayName||`Context`)+`.Provider`;case 18:return`DehydratedFragment`;case 11:return e=t.render,e=e.displayName||e.name||``,t.displayName||(e===``?`ForwardRef`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return ve(t);case 8:return t===ne?`StrictMode`:`Mode`;case 22:return`Offscreen`;case 12:return`Profiler`;case 21:return`Scope`;case 13:return`Suspense`;case 19:return`SuspenseList`;case 25:return`TracingMarker`;case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t==`function`)return t.displayName||t.name||null;if(typeof t==`string`)return t}return null}function be(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function xe(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Se(e){var t=xe(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ce(e){e._valueTracker||=Se(e)}function we(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=xe(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Te(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Ee(e,t){var n=t.checked;return w({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function De(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=be(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function Oe(e,t){t=t.checked,t!=null&&b(e,`checked`,t,!1)}function ke(e,t){Oe(e,t);var n=be(t.value),r=t.type;if(n!=null)r===`number`?(n===0&&e.value===``||e.value!=n)&&(e.value=``+n):e.value!==``+n&&(e.value=``+n);else if(r===`submit`||r===`reset`){e.removeAttribute(`value`);return}t.hasOwnProperty(`value`)?je(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&je(e,t.type,be(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Ae(e,t,n){if(t.hasOwnProperty(`value`)||t.hasOwnProperty(`defaultValue`)){var r=t.type;if(!(r!==`submit`&&r!==`reset`||t.value!==void 0&&t.value!==null))return;t=``+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==``&&(e.name=``),e.defaultChecked=!!e._wrapperState.initialChecked,n!==``&&(e.name=n)}function je(e,t,n){(t!==`number`||Te(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var Me=Array.isArray;function Ne(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i`+t.valueOf().toString()+``,t=Be.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function He(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ue={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},We=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(Ue).forEach(function(e){We.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ue[t]=Ue[e]})});function Ge(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||Ue.hasOwnProperty(e)&&Ue[e]?(``+t).trim():t+`px`}function Ke(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=Ge(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var qe=w({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Je(e,t){if(t){if(qe[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(r(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(r(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(r(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(r(62))}}function Ye(e,t){if(e.indexOf(`-`)===-1)return typeof t.is==`string`;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Xe=null;function Ze(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Qe=null,$e=null,et=null;function tt(e){if(e=$i(e)){if(typeof Qe!=`function`)throw Error(r(280));var t=e.stateNode;t&&(t=ta(t),Qe(e.stateNode,e.type,t))}}function nt(e){$e?et?et.push(e):et=[e]:$e=e}function rt(){if($e){var e=$e,t=et;if(et=$e=null,tt(e),t)for(e=0;e>>=0,e===0?32:31-(zt(e)/Bt|0)|0}var Ht=64,Ut=4194304;function Wt(e){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:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Gt(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=Wt(a))):r=Wt(s)}else o=n&~i,o===0?a!==0&&(r=Wt(a)):r=Wt(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Zt(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Rt(t),e[t]=n}function Qt(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=pr),gr=` `,_r=!1;function vr(e,t){switch(e){case`keyup`:return dr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function yr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var br=!1;function xr(e,t){switch(e){case`compositionend`:return yr(t);case`keypress`:return t.which===32?(_r=!0,gr):null;case`textInput`:return e=t.data,e===gr&&_r?null:e;default:return null}}function Sr(e,t){if(br)return e===`compositionend`||!fr&&vr(e,t)?(e=In(),Fn=Pn=Nn=null,br=!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=Wr(n)}}function Kr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Kr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qr(){for(var e=window,t=Te();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Te(e.document)}return t}function Jr(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`)}function Yr(e){var t=qr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Kr(n.ownerDocument.documentElement,n)){if(r!==null&&Jr(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),`selectionStart`in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=Gr(n,a);var o=Gr(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus==`function`&&n.focus(),n=0;n=document.documentMode,Zr=null,Qr=null,$r=null,ei=!1;function ti(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ei||Zr==null||Zr!==Te(r)||(r=Zr,`selectionStart`in r&&Jr(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}),$r&&Ur($r,r)||($r=r,r=Ei(Qr,`onSelect`),0ra||(e.current=na[ra],na[ra]=null,ra--)}function A(e,t){ra++,na[ra]=e.current,e.current=t}var aa={},j=ia(aa),M=ia(!1),oa=aa;function sa(e,t){var n=e.type.contextTypes;if(!n)return aa;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function N(e){return e=e.childContextTypes,e!=null}function ca(){k(M),k(j)}function la(e,t,n){if(j.current!==aa)throw Error(r(168));A(j,t),A(M,n)}function ua(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,ye(e)||`Unknown`,a));return w({},n,i)}function da(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||aa,oa=j.current,A(j,e),A(M,M.current),!0}function fa(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=ua(e,t,oa),i.__reactInternalMemoizedMergedChildContext=e,k(M),k(j),A(j,e)):k(M),A(M,n)}var pa=null,ma=!1,ha=!1;function ga(e){pa===null?pa=[e]:pa.push(e)}function _a(e){ma=!0,ga(e)}function va(){if(!ha&&pa!==null){ha=!0;var e=0,t=D;try{var n=pa;for(D=1;e>=o,i-=o,Ea=1<<32-Rt(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),P&&Oa(r,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),P&&Oa(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 P&&Oa(a,g),u}for(h=i(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.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)}),P&&Oa(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===te&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case ee:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===te){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===ue&&qa(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=Ga(e,l,i),r.return=e,e=r;break a}n(e,l);break}else t(e,l);l=l.sibling}i.type===te?(r=Xl(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=Yl(i.type,i.key,i.props,null,e.mode,o),o.ref=Ga(e,r,i),o.return=e,e=o)}return s(e);case S:a:{for(l=i.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}else{n(e,r);break}else t(e,r);r=r.sibling}r=$l(i,e.mode,o),r.return=e,e=r}return s(e);case ue:return l=i._init,_(e,r,l(i._payload),o)}if(Me(i))return h(e,r,i,o);if(fe(i))return g(e,r,i,o);Ka(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=Ql(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Ya=Ja(!0),Xa=Ja(!1),Za=ia(null),Qa=null,$a=null,eo=null;function to(){eo=$a=Qa=null}function no(e){var t=Za.current;k(Za),e._currentValue=t}function ro(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function io(e,t){Qa=e,eo=$a=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Us=!0),e.firstContext=null)}function ao(e){var t=e._currentValue;if(eo!==e)if(e={context:e,memoizedValue:t,next:null},$a===null){if(Qa===null)throw Error(r(308));$a=e,Qa.dependencies={lanes:0,firstContext:e}}else $a=$a.next=e;return t}var oo=null;function so(e){oo===null?oo=[e]:oo.push(e)}function co(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,so(t)):(n.next=i.next,i.next=n),t.interleaved=n,lo(e,r)}function lo(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var uo=!1;function fo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function po(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function mo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ho(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,G&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,lo(e,n)}return i=r.interleaved,i===null?(t.next=t,so(r)):(t.next=i.next,i.next=t),r.interleaved=t,lo(e,n)}function go(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,$t(e,n)}}function _o(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={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,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,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function vo(e,t,n,r){var i=e.updateQueue;uo=!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,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,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(p,d,f):m,f==null)break a;d=w({},d,f);break a;case 2:uo=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime: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;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Zc|=o,e.lanes=o,e.memoizedState=d}}function yo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=No.transition;No.transition={};try{e(!1),t()}finally{D=n,No.transition=r}}function gs(){return Uo().memoizedState}function _s(e,t,n){var r=ml(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ys(e))bs(t,n);else if(n=co(e,t,n,r),n!==null){var i=Z();hl(n,e,r,i),xs(n,t,r)}}function vs(e,t,n){var r=ml(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ys(e))bs(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,Hr(s,o)){var c=t.interleaved;c===null?(i.next=i,so(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=co(e,t,i,r),n!==null&&(i=Z(),hl(n,e,r,i),xs(n,t,r))}}function ys(e){var t=e.alternate;return e===I||t!==null&&t===I}function bs(e,t){Io=Fo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function xs(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,$t(e,n)}}var Ss={readContext:ao,useCallback:z,useContext:z,useEffect:z,useImperativeHandle:z,useInsertionEffect:z,useLayoutEffect:z,useMemo:z,useReducer:z,useRef:z,useState:z,useDebugValue:z,useDeferredValue:z,useTransition:z,useMutableSource:z,useSyncExternalStore:z,useId:z,unstable_isNewReconciler:!1},Cs={readContext:ao,useCallback:function(e,t){return Ho().memoizedState=[e,t===void 0?null:t],e},useContext:ao,useEffect:as,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),rs(4194308,4,ls.bind(null,t,e),n)},useLayoutEffect:function(e,t){return rs(4194308,4,e,t)},useInsertionEffect:function(e,t){return rs(4,2,e,t)},useMemo:function(e,t){var n=Ho();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ho();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=_s.bind(null,I,e),[r.memoizedState,e]},useRef:function(e){var t=Ho();return e={current:e},t.memoizedState=e},useState:es,useDebugValue:ds,useDeferredValue:function(e){return Ho().memoizedState=e},useTransition:function(){var e=es(!1),t=e[0];return e=hs.bind(null,e[1]),Ho().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=I,a=Ho();if(P){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),K===null)throw Error(r(349));Po&30||Yo(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,as(Zo.bind(null,i,o,e),[e]),i.flags|=2048,ts(9,Xo.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=Ho(),t=K.identifierPrefix;if(P){var n=Da,r=Ea;n=(r&~(1<<32-Rt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=Lo++,0<\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[Ki]=t,e[qi]=i,fc(e,t,!1,!1),t.stateNode=e;a:{switch(c=Ye(n,i),n){case`dialog`:O(`cancel`,e),O(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:O(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;onl&&(t.flags|=128,i=!0,hc(s,!1),t.lanes=4194304)}else{if(!i)if(e=ko(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),hc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!P)return V(t),null}else 2*T()-s.renderingStartTime>nl&&n!==1073741824&&(t.flags|=128,i=!0,hc(s,!1),t.lanes=4194304);s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(V(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=T(),t.sibling=null,n=F.current,A(F,i?n&1|2:n&1),t);case 22:case 23:return wl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?Jc&1073741824&&(V(t),t.subtreeFlags&6&&(t.flags|=8192)):V(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function _c(e,t){switch(ja(t),t.tag){case 1:return N(t.type)&&ca(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Eo(),k(M),k(j),jo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Oo(t),null;case 13:if(k(F),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Ha()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return k(F),null;case 4:return Eo(),null;case 10:return no(t.type._context),null;case 22:case 23:return wl(),null;case 24:return null;default:return null}}var vc=!1,H=!1,yc=typeof WeakSet==`function`?WeakSet:Set,U=null;function bc(e,t){var n=e.ref;if(n!==null)if(typeof n==`function`)try{n(null)}catch(n){$(e,t,n)}else n.current=null}function xc(e,t,n){try{n()}catch(n){$(e,t,n)}}var Sc=!1;function Cc(e,t){if(Pi=En,e=qr(),Jr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Fi={focusedElem:e,selectionRange:n},En=!1,U=t;U!==null;)if(t=U,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,U=e;else for(;U!==null;){t=U;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:Es(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){$(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,U=e;break}U=t.return}return h=Sc,Sc=!1,h}function wc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&xc(t,n,a)}i=i.next}while(i!==r)}}function Tc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Ec(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function Dc(e){var t=e.alternate;t!==null&&(e.alternate=null,Dc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ki],delete t[qi],delete t[Yi],delete t[Xi],delete t[Zi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Oc(e){return e.tag===5||e.tag===3||e.tag===4}function kc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Oc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ac(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ni));else if(r!==4&&(e=e.child,e!==null))for(Ac(e,t,n),e=e.sibling;e!==null;)Ac(e,t,n),e=e.sibling}function jc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(jc(e,t,n),e=e.sibling;e!==null;)jc(e,t,n),e=e.sibling}var W=null,Mc=!1;function Nc(e,t,n){for(n=n.child;n!==null;)Pc(e,t,n),n=n.sibling}function Pc(e,t,n){if(It&&typeof It.onCommitFiberUnmount==`function`)try{It.onCommitFiberUnmount(Ft,n)}catch{}switch(n.tag){case 5:H||bc(n,t);case 6:var r=W,i=Mc;W=null,Nc(e,t,n),W=r,Mc=i,W!==null&&(Mc?(e=W,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):W.removeChild(n.stateNode));break;case 18:W!==null&&(Mc?(e=W,n=n.stateNode,e.nodeType===8?Hi(e.parentNode,n):e.nodeType===1&&Hi(e,n),wn(e)):Hi(W,n.stateNode));break;case 4:r=W,i=Mc,W=n.stateNode.containerInfo,Mc=!0,Nc(e,t,n),W=r,Mc=i;break;case 0:case 11:case 14:case 15:if(!H&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&xc(n,t,o),i=i.next}while(i!==r)}Nc(e,t,n);break;case 1:if(!H&&(bc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){$(n,t,e)}Nc(e,t,n);break;case 21:Nc(e,t,n);break;case 22:n.mode&1?(H=(r=H)||n.memoizedState!==null,Nc(e,t,n),H=r):Nc(e,t,n);break;default:Nc(e,t,n)}}function Fc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new yc),t.forEach(function(t){var r=Vl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function Ic(e,t){var n=t.deletions;if(n!==null)for(var i=0;ia&&(a=s),i&=~o}if(i=a,i=T()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*Wc(i/1960))-i,10e?16:e,cl===null)var i=!1;else{if(e=cl,cl=null,ll=0,G&6)throw Error(r(331));var a=G;for(G|=4,U=e.current;U!==null;){var o=U,s=o.child;if(U.flags&16){var c=o.deletions;if(c!==null){for(var l=0;lT()-tl?Tl(e,0):$c|=n),Q(e,t)}function zl(e,t){t===0&&(e.mode&1?(t=Ut,Ut<<=1,!(Ut&130023424)&&(Ut=4194304)):t=1);var n=Z();e=lo(e,t),e!==null&&(Zt(e,t,n),Q(e,n))}function Bl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),zl(e,n)}function Vl(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),zl(e,n)}var Hl=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||M.current)Us=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Us=!1,dc(e,t,n);Us=!!(e.flags&131072)}else Us=!1,P&&t.flags&1048576&&ka(t,Sa,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;lc(e,t),e=t.pendingProps;var a=sa(t,j.current);io(t,n),a=Bo(null,t,i,e,a,n);var o=Vo();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,N(i)?(o=!0,da(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,fo(t),a.updater=Os,t.stateNode=a,a._reactInternals=t,Ms(t,i,e,n),t=Zs(null,t,i,!0,o,n)):(t.tag=0,P&&o&&Aa(t),B(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(lc(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=ql(i),e=Es(i,e),a){case 0:t=Ys(null,t,i,e,n);break a;case 1:t=Xs(null,t,i,e,n);break a;case 11:t=Ws(null,t,i,e,n);break a;case 14:t=Gs(null,t,i,Es(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Es(i,a),Ys(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Es(i,a),Xs(e,t,i,a,n);case 3:a:{if(Qs(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,po(e,t),vo(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated)if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ns(Error(r(423)),t),t=$s(e,t,i,n,a);break a}else if(i!==a){a=Ns(Error(r(424)),t),t=$s(e,t,i,n,a);break a}else for(Na=Ui(t.stateNode.containerInfo.firstChild),Ma=t,P=!0,Pa=null,n=Xa(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ha(),i===a){t=uc(e,t,n);break a}B(e,t,i,n)}t=t.child}return t;case 5:return Do(t),e===null&&Ra(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,Ii(i,a)?s=null:o!==null&&Ii(i,o)&&(t.flags|=32),Js(e,t),B(e,t,s,n),t.child;case 6:return e===null&&Ra(t),null;case 13:return nc(e,t,n);case 4:return To(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Ya(t,null,i,n):B(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Es(i,a),Ws(e,t,i,a,n);case 7:return B(e,t,t.pendingProps,n),t.child;case 8:return B(e,t,t.pendingProps.children,n),t.child;case 12:return B(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,A(Za,i._currentValue),i._currentValue=s,o!==null)if(Hr(o.value,s)){if(o.children===a.children&&!M.current){t=uc(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=mo(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),ro(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),ro(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}B(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,io(t,n),a=ao(a),i=i(a),t.flags|=1,B(e,t,i,n),t.child;case 14:return i=t.type,a=Es(i,t.pendingProps),a=Es(i.type,a),Gs(e,t,i,a,n);case 15:return Ks(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Es(i,a),lc(e,t),t.tag=1,N(i)?(e=!0,da(t)):e=!1,io(t,n),As(t,i,a),Ms(t,i,a,n),Zs(null,t,i,!0,e,n);case 19:return cc(e,t,n);case 22:return qs(e,t,n)}throw Error(r(156,t.tag))};function Ul(e,t){return Tt(e,t)}function Wl(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.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 Gl(e,t,n,r){return new Wl(e,t,n,r)}function Kl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ql(e){if(typeof e==`function`)return+!!Kl(e);if(e!=null){if(e=e.$$typeof,e===oe)return 11;if(e===le)return 14}return 2}function Jl(e,t){var n=e.alternate;return n===null?(n=Gl(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Yl(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)Kl(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case te:return Xl(n.children,a,o,t);case ne:s=8,a|=8;break;case re:return e=Gl(12,n,t,a|2),e.elementType=re,e.lanes=o,e;case se:return e=Gl(13,n,t,a),e.elementType=se,e.lanes=o,e;case ce:return e=Gl(19,n,t,a),e.elementType=ce,e.lanes=o,e;case C:return Zl(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case ie:s=10;break a;case ae:s=9;break a;case oe:s=11;break a;case le:s=14;break a;case ue:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=Gl(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function Xl(e,t,n,r){return e=Gl(7,e,r,t),e.lanes=n,e}function Zl(e,t,n,r){return e=Gl(22,e,r,t),e.elementType=C,e.lanes=n,e.stateNode={isHidden:!1},e}function Ql(e,t,n){return e=Gl(6,e,null,t),e.lanes=n,e}function $l(e,t,n){return t=Gl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function eu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Xt(0),this.expirationTimes=Xt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function tu(e,t,n,r,i,a,o,s,c){return e=new eu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Gl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},fo(a),e}function nu(e,t,n){var r=3{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=require_react_dom_production_min()})),require_client=__commonJSMin((e=>{var t=require_react_dom();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),import_react=__toESM(require_react()),import_client=require_client(),TextAlign=function(e){return e[e.Left=0]=`Left`,e[e.Right=1]=`Right`,e[e.Center=2]=`Center`,e}({}),Border=class e{color;static from(t){let n=new e;return n.style=t.style,n.color=t.color,n}style=0;constructor(e=null){this.color=e}},Appearance=class e{get bold(){return!!(this.textStyle&&this.textStyle.indexOf(`bold`)!=-1)}set bold(e){this.ensureTextStyle(),this.bold!=e&&(e?this.textStyle=`${this.textStyle} bold`:this.textStyle=this.textStyle.replace(`bold`,``))}get italic(){return!!(this.textStyle&&this.textStyle.indexOf(`italic`)!=-1)}set italic(e){this.ensureTextStyle(),this.italic!=e&&(e?this.textStyle=`${this.textStyle} italic`:this.textStyle=this.textStyle.replace(`italic`,``))}get underline(){return!!(this.textStyle&&this.textStyle.indexOf(`underline`)!=-1)}set underline(e){this.ensureTextStyle(),!(this.italic==e||!this.textStyle)&&(e?this.textStyle=`${this.textStyle} underline`:this.textStyle=this.textStyle.replace(`underline`,``))}static from(t){let n=new e;return n.textAlign=t.textAlign,n.textStyle=t.textStyle,n.fontName=t.fontName,n.fontSize=t.fontSize,n.text=t.text,n.background=t.background,n.horizontalBorder=t.horizontalBorder&&Border.from(t.horizontalBorder),n.verticalBorder=t.verticalBorder&&Border.from(t.verticalBorder),n}textAlign=0;fontName=`Lato`;fontSize=12;textStyle;text;background;horizontalBorder;verticalBorder;alignTextTo(e){if(e.toLowerCase()==`right`)this.textAlign=1;else if(e.toLowerCase()==`center`)this.textAlign=2;else if(e.toLowerCase()==`left`)this.textAlign=0;else throw Error(`invalid text-align '${e}'`)}setHorizontal(e){this.horizontalBorder=new Border,this.horizontalBorder.style=0,this.horizontalBorder.color=e}setVertical(e){this.verticalBorder=new Border,this.verticalBorder.style=0,this.verticalBorder.color=e}ensureTextStyle(){this.textStyle||=``}};function saveDocument(e){if(!e)return;let t=document.createElement(`a`);t.download=`document.ows`,t.href=`data:application/octet-stream,`+encodeURIComponent(e.save()),t.target=`_blank`,t.click()}function loadDocument(e){if(!e)return;let t=document.createElement(`input`);t.accept=`.ows`,t.type=`file`,t.addEventListener(`change`,()=>readSelectedFile(t,e)),t.click()}function readSelectedFile(e,t){let n=e.files&&e.files[0];if(!n)return;let r=new FileReader;r.addEventListener(`load`,()=>t.load(r.result)),r.readAsText(n,`utf8`)}function FormulaBar(e){let[t,n]=import_react.useState(!1);return import_react.createElement(`div`,{className:t?`ows-formula-bar ows-formula-active`:`ows-formula-bar`},import_react.createElement(`input`,{className:`ows-cell-name`,readOnly:!0,value:e.label}),import_react.createElement(`div`,{className:`ows-formula-actions`},import_react.createElement(`button`,{onClick:e.onAbort,title:`Cancel`,type:`button`},`x`),import_react.createElement(`button`,{onClick:e.onCommit,title:`Apply`,type:`button`},`✓`),import_react.createElement(`strong`,null,`fx`)),import_react.createElement(`input`,{className:`ows-formula-input`,onBlur:()=>n(!1),onChange:t=>e.onValueChange(t.target.value),onFocus:()=>n(!0),value:e.value||``}))}function ControlGroup(e){return import_react.createElement(`section`,{className:e.wide?`ows-control-group ows-control-group-wide`:`ows-control-group`},import_react.createElement(`div`,{className:`ows-control-label`},e.label),import_react.createElement(`div`,{className:`ows-control-content`},e.children))}function AboutRibbon(){return import_react.createElement(`div`,{className:`ows-ribbon-panel`},import_react.createElement(ControlGroup,{label:`OSI`},import_react.createElement(`i`,{className:`fab fa-osi ows-large-icon`,title:`Open Source Initiative`})),import_react.createElement(ControlGroup,{label:`About Open Web Sheet Project`,wide:!0},import_react.createElement(`div`,{className:`ows-about`},import_react.createElement(`strong`,null,`Open Web Sheet Project`),import_react.createElement(`span`,null,`Designed and developed by Siamand`),import_react.createElement(`span`,null,`3rd Parties: FontAwesome Icons & Google noto web font`),import_react.createElement(`span`,null,`MIT Licence`),import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(`a`,{href:`https://siamand.cc`},`Developer Site`),import_react.createElement(`a`,{href:`https://github.com/code-by-sia/OpenWebSheet`},`Source Code`)))))}function Button(e){let t=e.active?`ows-button ows-button-active`:`ows-button`;return import_react.createElement(`button`,{className:t,onClick:e.onClick,title:e.title||e.label,type:`button`},e.icon&&import_react.createElement(`i`,{className:e.icon}),e.children)}function ImportExportGroup({label:e}){return import_react.createElement(ControlGroup,{label:e,wide:!0},import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(Button,{title:`${e} import`},`Import`),import_react.createElement(Button,{title:`${e} export`},`Export`)))}function DataRibbon(){return import_react.createElement(`div`,{className:`ows-ribbon-panel`},import_react.createElement(ControlGroup,{label:`File`},import_react.createElement(`i`,{className:`fa fa-file-excel ows-large-icon`,title:`Spreadsheet file`})),import_react.createElement(ImportExportGroup,{label:`Open Office`}),import_react.createElement(ImportExportGroup,{label:`MS Excel`}),import_react.createElement(ControlGroup,{label:`3rd Parties`,wide:!0},import_react.createElement(`span`,{className:`ows-muted`},`External data sources`)))}function FormulaFunctionGroup(e){return import_react.createElement(ControlGroup,{label:e.label,wide:!0},import_react.createElement(`div`,{className:`ows-formula-tools`},e.functions.map(t=>import_react.createElement(Button,{icon:t.icon,key:t.label,onClick:()=>e.onAction({actionName:`formula-template`,args:t.template}),title:`Insert ${t.label}`},t.label))))}var statistics=[{icon:`fa fa-plus`,label:`SUM`,template:`=SUM(`},{icon:`fa fa-arrow-down`,label:`MIN`,template:`=MIN(`},{icon:`fa fa-arrow-up`,label:`MAX`,template:`=MAX(`}],mathematical=[{icon:`fa fa-square-root-alt`,label:`SQRT`,template:`=SQRT(`},{icon:`fa fa-plus-circle`,label:`ABS`,template:`=ABS(`},{icon:`fa fa-chart-line`,label:`LOG`,template:`=LOG(`},{icon:`fa fa-superscript`,label:`EXP`,template:`=EXP(`}],trigonometry=[{icon:`fa fa-wave-square`,label:`SIN`,template:`=SIN(`},{icon:`fa fa-wave-square`,label:`COS`,template:`=COS(`},{icon:`fa fa-wave-square`,label:`TAN`,template:`=TAN(`}],constants=[{icon:`fa fa-circle-notch`,label:`PI`,template:`=PI`},{icon:`fa fa-italic`,label:`E`,template:`=E`}];function FormulaRibbon(e){return import_react.createElement(`div`,{className:`ows-ribbon-panel`},import_react.createElement(FormulaFunctionGroup,{functions:statistics,label:`Statistics`,onAction:e.onAction}),import_react.createElement(FormulaFunctionGroup,{functions:mathematical,label:`Mathematical`,onAction:e.onAction}),import_react.createElement(FormulaFunctionGroup,{functions:trigonometry,label:`Trigonometry`,onAction:e.onAction}),import_react.createElement(FormulaFunctionGroup,{functions:constants,label:`Constants`,onAction:e.onAction}),import_react.createElement(ControlGroup,{label:`User Defined Functions`,wide:!0},import_react.createElement(`span`,{className:`ows-muted`},`Custom functions are planned`)))}function CellControls(e){let t=(t,n)=>e.onAction({actionName:t,args:n});return import_react.createElement(ControlGroup,{label:`Cell`},import_react.createElement(Button,{active:e.state.isMerged,icon:`fa fa-th`,onClick:()=>t(e.state.isMerged?`unmerge`:`merge`)},e.state.isMerged?`Split`:`Merge`))}function DocumentControls(e){let t=t=>e.onAction({actionName:t});return e.fileMode===`local`?import_react.createElement(ControlGroup,{label:`Local Storage`},import_react.createElement(Button,{icon:`far fa-times-circle`,onClick:()=>e.onModeChanged(`file`)},`File mode`)):import_react.createElement(ControlGroup,{label:`Document`},import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(Button,{icon:`fas fa-save`,onClick:()=>t(`save-ows`),title:`Save`}),import_react.createElement(Button,{icon:`fas fa-folder`,onClick:()=>t(`load-ows`),title:`Load`}),import_react.createElement(Button,{icon:`fas fa-warehouse`,onClick:()=>e.onModeChanged(`local`),title:`Local storage`})))}function Field(e){return import_react.createElement(`label`,{className:`ows-field`},e.label&&import_react.createElement(`span`,null,e.label),e.children)}var fonts=[`Arial`,`Tahoma`,`Times New Roman`,`Courier New`],sizes=[8,9,10,11,12,14,16,18,24];function FontControls(e){let t=(t,n)=>e.onAction({actionName:t,args:n});return import_react.createElement(ControlGroup,{label:`Font`},import_react.createElement(`div`,{className:`ows-stack`},import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(Field,null,import_react.createElement(`select`,{onChange:e=>t(`font-name`,e.target.value),value:e.appearance.fontName},fonts.map(e=>import_react.createElement(`option`,{key:e},e)))),import_react.createElement(Field,null,import_react.createElement(`select`,{onChange:e=>t(`font-size`,Number(e.target.value)),value:e.appearance.fontSize},sizes.map(e=>import_react.createElement(`option`,{key:e},e))))),import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(Button,{active:e.appearance.bold,icon:`fa fa-bold`,onClick:()=>t(`bold`)}),import_react.createElement(Button,{active:e.appearance.italic,icon:`fa fa-italic`,onClick:()=>t(`italic`)}),import_react.createElement(Button,{active:e.appearance.underline,icon:`fa fa-underline`,onClick:()=>t(`underline`)}))))}function FormatControls(e){let t=(t,n)=>e.onAction({actionName:t,args:n});return import_react.createElement(ControlGroup,{label:`Format`},import_react.createElement(`div`,{className:`ows-stack`},import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(Field,{label:`Text`},import_react.createElement(`input`,{onChange:e=>t(`fg-color`,e.target.value),type:`color`,value:e.appearance.text})),import_react.createElement(Field,{label:`Fill`},import_react.createElement(`input`,{onChange:e=>t(`bg-color`,e.target.value),type:`color`,value:e.appearance.background}))),import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(AlignButton,{action:t,alignment:TextAlign.Left,appearance:e.appearance}),import_react.createElement(AlignButton,{action:t,alignment:TextAlign.Center,appearance:e.appearance}),import_react.createElement(AlignButton,{action:t,alignment:TextAlign.Right,appearance:e.appearance}))))}function AlignButton({action:e,alignment:t,appearance:n}){let r=t===TextAlign.Left?`fa fa-align-left`:t===TextAlign.Center?`fa fa-align-center`:`fa fa-align-right`;return import_react.createElement(Button,{active:n.textAlign===t,icon:r,onClick:()=>e(`align`,t)})}var borders=[[`full-border`,`all`,`All borders`],[`cross-border`,`inside`,`Inside borders`],[`horizontal-border`,`horizontal`,`Horizontal borders`],[`vertical-border`,`vertical`,`Vertical borders`],[`outside-border`,`outside`,`Outside borders`],[`left-border`,`left`,`Left border`],[`top-border`,`top`,`Top border`],[`right-border`,`right`,`Right border`],[`bottom-border`,`bottom`,`Bottom border`],[`no-border`,`none`,`No border`]];function BorderControls(e){let[t,n]=import_react.useState(`#000000`),r=n=>e.onAction({actionName:n,args:t});return import_react.createElement(ControlGroup,{label:`Borders`},import_react.createElement(`div`,{className:`ows-stack`},import_react.createElement(Field,{label:`Color`},import_react.createElement(`input`,{onChange:e=>n(e.target.value),type:`color`,value:t})),import_react.createElement(`div`,{className:`ows-border-grid`},borders.map(([e,t,n])=>import_react.createElement(BorderButton,{key:e,label:n,onClick:()=>r(e),variant:t})))))}function BorderButton({label:e,onClick:t,variant:n}){return import_react.createElement(`button`,{className:`ows-border-tile ows-border-${n}`,onClick:t,title:e,type:`button`},import_react.createElement(`span`),import_react.createElement(`span`),import_react.createElement(`span`),import_react.createElement(`span`))}function HomeRibbon(e){return import_react.createElement(`div`,{className:`ows-ribbon-panel`},import_react.createElement(DocumentControls,{fileMode:e.fileMode,onAction:e.onAction,onModeChanged:e.onModeChanged}),import_react.createElement(FontControls,{appearance:e.appearance,onAction:e.onAction}),import_react.createElement(FormatControls,{appearance:e.appearance,onAction:e.onAction}),import_react.createElement(CellControls,{onAction:e.onAction,state:e.state}),import_react.createElement(BorderControls,{onAction:e.onAction}))}var layoutModes=[{id:`normal`,icon:`fa fa-table`,label:`Normal`},{id:`page-layout`,icon:`far fa-file-alt`,label:`Page layout`},{id:`page-break`,icon:`fa fa-columns`,label:`Page break`}],displayOptions=[{id:`gridlines`,icon:`fa fa-th`,label:`Gridlines`},{id:`headings`,icon:`fa fa-heading`,label:`Headings`},{id:`formula-bar`,icon:`fa fa-equals`,label:`Formula bar`}];function LayoutControls(){let[e,t]=import_react.useState(`normal`),[n,r]=import_react.useState(()=>new Set(displayOptions.map(e=>e.id))),i=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)};return import_react.createElement(ControlGroup,{label:`Layout`,wide:!0},import_react.createElement(`div`,{className:`ows-layout-controls`},import_react.createElement(`div`,{className:`ows-button-row`},layoutModes.map(n=>import_react.createElement(Button,{active:e===n.id,icon:n.icon,key:n.id,onClick:()=>t(n.id),title:n.label},n.label))),import_react.createElement(`div`,{className:`ows-button-row`},displayOptions.map(e=>import_react.createElement(Button,{active:n.has(e.id),icon:e.icon,key:e.id,onClick:()=>i(e.id),title:e.label},e.label)))))}function PrintControls(){return import_react.createElement(ControlGroup,{label:`Print`},import_react.createElement(Button,{icon:`fa fa-print`,onClick:()=>window.print(),title:`Print sheet`}))}function ViewRibbon(){return import_react.createElement(`div`,{className:`ows-ribbon-panel`},import_react.createElement(PrintControls),import_react.createElement(LayoutControls))}var canUseDOM=!!(typeof window<`u`&&window.document&&window.document.createElement);function composeEventHandlers(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var require_react_jsx_runtime_production_min=__commonJSMin((e=>{var t=require_react(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.jsx=s})),require_jsx_runtime=__commonJSMin(((e,t)=>{t.exports=require_react_jsx_runtime_production_min()})),import_jsx_runtime=require_jsx_runtime();function createContextScope(e,t=[]){let n=[];function r(t,r){let i=import_react.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=import_react.useMemo(()=>o,Object.values(o));return(0,import_jsx_runtime.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=import_react.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>import_react.createContext(e));return function(n){let r=n?.[e]||t;return import_react.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,composeContextScopes(i,...t)]}function composeContextScopes(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return import_react.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function setRef(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function composeRefs(...e){return t=>{let n=!1,r=e.map(e=>{let r=setRef(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t{let{children:r,...i}=e,a=import_react.Children.toArray(r),o=a.find(isSlottable);if(o){let e=o.props.children,r=a.map(t=>t===o?import_react.Children.count(e)>1?import_react.Children.only(null):import_react.isValidElement(e)?e.props.children:null:t);return(0,import_jsx_runtime.jsx)(t,{...i,ref:n,children:import_react.isValidElement(e)?import_react.cloneElement(e,void 0,r):null})}return(0,import_jsx_runtime.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function createSlotClone(e){let t=import_react.forwardRef((e,t)=>{let{children:n,...r}=e;if(import_react.isValidElement(n)){let e=getElementRef$1(n),i=mergeProps(r,n.props);return n.type!==import_react.Fragment&&(i.ref=t?composeRefs(t,e):e),import_react.cloneElement(n,i)}return import_react.Children.count(n)>1?import_react.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SLOTTABLE_IDENTIFIER=Symbol(`radix.slottable`);function isSlottable(e){return import_react.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER}function mergeProps(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function getElementRef$1(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function createCollection(e){let t=e+`CollectionProvider`,[n,r]=createContextScope(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=import_react.useRef(null),a=import_react.useRef(new Map).current;return(0,import_jsx_runtime.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=createSlot(s),l=import_react.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,import_jsx_runtime.jsx)(c,{ref:useComposedRefs(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=createSlot(u),p=import_react.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=import_react.useRef(null),s=useComposedRefs(t,o),c=a(u,n);return import_react.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,import_jsx_runtime.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return import_react.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var useLayoutEffect2=globalThis?.document?import_react.useLayoutEffect:()=>{},useReactId=import_react.useId||(()=>void 0),count=0;function useId(e){let[t,n]=import_react.useState(useReactId());return useLayoutEffect2(()=>{e||n(e=>e??String(count++))},[e]),e||(t?`radix-${t}`:``)}var import_react_dom=__toESM(require_react_dom(),1),Primitive=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=createSlot(`Primitive.${t}`),r=import_react.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,import_jsx_runtime.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function useCallbackRef(e){let t=import_react.useRef(e);return import_react.useEffect(()=>{t.current=e}),import_react.useMemo(()=>(...e)=>t.current?.(...e),[])}var useInsertionEffect=import_react.useInsertionEffect||useLayoutEffect2;function useControllableState({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=useUncontrolledState({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=import_react.useRef(e!==void 0);import_react.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,import_react.useCallback(t=>{if(s){let n=isFunction(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function useUncontrolledState({defaultProp:e,onChange:t}){let[n,r]=import_react.useState(e),i=import_react.useRef(n),a=import_react.useRef(t);return useInsertionEffect(()=>{a.current=t},[t]),import_react.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function isFunction(e){return typeof e==`function`}var DirectionContext=import_react.createContext(void 0);function useDirection(e){let t=import_react.useContext(DirectionContext);return e||t||`ltr`}var ENTRY_FOCUS=`rovingFocusGroup.onEntryFocus`,EVENT_OPTIONS={bubbles:!1,cancelable:!0},GROUP_NAME=`RovingFocusGroup`,[Collection,useCollection,createCollectionScope]=createCollection(GROUP_NAME),[createRovingFocusGroupContext,createRovingFocusGroupScope]=createContextScope(GROUP_NAME,[createCollectionScope]),[RovingFocusProvider,useRovingFocusContext]=createRovingFocusGroupContext(GROUP_NAME),RovingFocusGroup=import_react.forwardRef((e,t)=>(0,import_jsx_runtime.jsx)(Collection.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,import_jsx_runtime.jsx)(Collection.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,import_jsx_runtime.jsx)(RovingFocusGroupImpl,{...e,ref:t})})}));RovingFocusGroup.displayName=GROUP_NAME;var RovingFocusGroupImpl=import_react.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=import_react.useRef(null),p=useComposedRefs(t,f),m=useDirection(a),[h,g]=useControllableState({prop:o,defaultProp:s??null,onChange:c,caller:GROUP_NAME}),[_,v]=import_react.useState(!1),y=useCallbackRef(l),b=useCollection(n),x=import_react.useRef(!1),[ee,S]=import_react.useState(0);return import_react.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(ENTRY_FOCUS,y),()=>e.removeEventListener(ENTRY_FOCUS,y)},[y]),(0,import_jsx_runtime.jsx)(RovingFocusProvider,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:import_react.useCallback(e=>g(e),[g]),onItemShiftTab:import_react.useCallback(()=>v(!0),[]),onFocusableItemAdd:import_react.useCallback(()=>S(e=>e+1),[]),onFocusableItemRemove:import_react.useCallback(()=>S(e=>e-1),[]),children:(0,import_jsx_runtime.jsx)(Primitive.div,{tabIndex:_||ee===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:composeEventHandlers(e.onMouseDown,()=>{x.current=!0}),onFocus:composeEventHandlers(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(ENTRY_FOCUS,EVENT_OPTIONS);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);focusFirst([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:composeEventHandlers(e.onBlur,()=>v(!1))})})}),ITEM_NAME=`RovingFocusGroupItem`,RovingFocusGroupItem=import_react.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=useId(),l=a||c,u=useRovingFocusContext(ITEM_NAME,n),d=u.currentTabStopId===l,f=useCollection(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return import_react.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,import_jsx_runtime.jsx)(Collection.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,import_jsx_runtime.jsx)(Primitive.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:composeEventHandlers(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:composeEventHandlers(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:composeEventHandlers(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=getFocusIntent(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?wrapArray(n,r+1):n.slice(r+1)}setTimeout(()=>focusFirst(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});RovingFocusGroupItem.displayName=ITEM_NAME;var MAP_KEY_TO_FOCUS_INTENT={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function getDirectionAwareKey(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function getFocusIntent(e,t,n){let r=getDirectionAwareKey(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return MAP_KEY_TO_FOCUS_INTENT[r]}function focusFirst(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function wrapArray(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Root=RovingFocusGroup,Item=RovingFocusGroupItem;function useStateMachine(e,t){return import_react.useReducer((e,n)=>t[e][n]??e,e)}var Presence=e=>{let{present:t,children:n}=e,r=usePresence(t),i=typeof n==`function`?n({present:r.isPresent}):import_react.Children.only(n),a=useComposedRefs(r.ref,getElementRef(i));return typeof n==`function`||r.isPresent?import_react.cloneElement(i,{ref:a}):null};Presence.displayName=`Presence`;function usePresence(e){let[t,n]=import_react.useState(),r=import_react.useRef(null),i=import_react.useRef(e),a=import_react.useRef(`none`),[o,s]=useStateMachine(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return import_react.useEffect(()=>{let e=getAnimationName(r.current);a.current=o===`mounted`?e:`none`},[o]),useLayoutEffect2(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=getAnimationName(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),useLayoutEffect2(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=getAnimationName(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=getAnimationName(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:import_react.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function getAnimationName(e){return e?.animationName||`none`}function getElementRef(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var TABS_NAME=`Tabs`,[createTabsContext,createTabsScope]=createContextScope(TABS_NAME,[createRovingFocusGroupScope]),useRovingFocusGroupScope=createRovingFocusGroupScope(),[TabsProvider,useTabsContext]=createTabsContext(TABS_NAME),Tabs$1=import_react.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=useDirection(s),[d,f]=useControllableState({prop:r,onChange:i,defaultProp:a??``,caller:TABS_NAME});return(0,import_jsx_runtime.jsx)(TabsProvider,{scope:n,baseId:useId(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,import_jsx_runtime.jsx)(Primitive.div,{dir:u,"data-orientation":o,...l,ref:t})})});Tabs$1.displayName=TABS_NAME;var TAB_LIST_NAME=`TabsList`,TabsList$1=import_react.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=useTabsContext(TAB_LIST_NAME,n),o=useRovingFocusGroupScope(n);return(0,import_jsx_runtime.jsx)(Root,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,import_jsx_runtime.jsx)(Primitive.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});TabsList$1.displayName=TAB_LIST_NAME;var TRIGGER_NAME=`TabsTrigger`,TabsTrigger$1=import_react.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=useTabsContext(TRIGGER_NAME,n),s=useRovingFocusGroupScope(n),c=makeTriggerId(o.baseId,r),l=makeContentId(o.baseId,r),u=r===o.value;return(0,import_jsx_runtime.jsx)(Item,{asChild:!0,...s,focusable:!i,active:u,children:(0,import_jsx_runtime.jsx)(Primitive.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:composeEventHandlers(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:composeEventHandlers(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:composeEventHandlers(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});TabsTrigger$1.displayName=TRIGGER_NAME;var CONTENT_NAME=`TabsContent`,TabsContent$1=import_react.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=useTabsContext(CONTENT_NAME,n),c=makeTriggerId(s.baseId,r),l=makeContentId(s.baseId,r),u=r===s.value,d=import_react.useRef(u);return import_react.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,import_jsx_runtime.jsx)(Presence,{present:i||u,children:({present:n})=>(0,import_jsx_runtime.jsx)(Primitive.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});TabsContent$1.displayName=CONTENT_NAME;function makeTriggerId(e,t){return`${e}-trigger-${t}`}function makeContentId(e,t){return`${e}-content-${t}`}var Root2=Tabs$1,List=TabsList$1,Trigger=TabsTrigger$1,Content=TabsContent$1;function Tabs(e){return import_react.createElement(Root2,{className:`ows-tabs`,defaultValue:e.defaultValue},e.children)}function TabsList(e){return import_react.createElement(List,{className:`ows-tabs-list`},e.children)}function TabsTrigger(e){return import_react.createElement(Trigger,{className:`ows-tabs-trigger`,value:e.value},e.children)}function TabsContent(e){return import_react.createElement(Content,{className:`ows-tabs-content`,value:e.value},e.children)}var tabs=[{id:`home`,icon:`fa fa-home`,label:`Home`},{id:`formulas`,icon:`fa fa-square-root-alt`,label:`Formulas`},{id:`data`,icon:`fa fa-database`,label:`Data`},{id:`view`,icon:`fa fa-eye`,label:`View`},{id:`about`,icon:`fa fa-info-circle`,label:`About`}];function RibbonMenu(e){return import_react.createElement(`header`,{className:`ows-ribbon`},import_react.createElement(Tabs,{defaultValue:`home`},import_react.createElement(TabsList,null,tabs.map(e=>import_react.createElement(TabsTrigger,{key:e.id,value:e.id},import_react.createElement(`span`,{className:`ows-tab-label`},import_react.createElement(`i`,{className:e.icon}),e.label)))),import_react.createElement(TabsContent,{value:`home`},import_react.createElement(HomeRibbon,e)),import_react.createElement(TabsContent,{value:`formulas`},import_react.createElement(FormulaRibbon,{onAction:e.onAction})),import_react.createElement(TabsContent,{value:`data`},import_react.createElement(DataRibbon)),import_react.createElement(TabsContent,{value:`view`},import_react.createElement(ViewRibbon)),import_react.createElement(TabsContent,{value:`about`},import_react.createElement(AboutRibbon))))}var Cell=class e{get isMerged(){return this.reference!==null}get columnId(){return this._columnId}get rowId(){return this._rowId}get label(){return this.formattedValue}get value(){return this._value}set value(e){this.update(e,e)}get top(){return this.isMerged&&this.reference?this.reference.top:this.rowId}get left(){return this.isMerged&&this.reference?this.reference.left:this.columnId}get bottom(){return this.isMerged&&this.reference?this.reference.bottom:this.rowId+this.rowSpan}get right(){return this.isMerged&&this.reference?this.reference.right:this.columnId+this.colSpan}static from(t){let n=new e(t.columnId,t.rowId);return n.colSpan=t.colSpan,n.rowSpan=t.rowSpan,n.formattedValue=t.formattedValue,n.evaluatedValue=t.evaluatedValue,n._columnId=t._columnId,n._rowId=t._rowId,n._value=t._value,n.reference=t.reference&&this.from(t.reference),n}colSpan=1;rowSpan=1;reference=null;formattedValue;evaluatedValue;_columnId;_rowId;_value=null;constructor(e,t){this._columnId=e,this._rowId=t}update(e,t){this._value=e,this.evaluatedValue=t,this.format()}to(){return{colSpan:this.colSpan,rowSpan:this.rowSpan,formattedValue:this.formattedValue,evaluatedValue:this.evaluatedValue,_columnId:this._columnId,_rowId:this._rowId,_value:this._value,reference:this.reference&&this.reference.to()}}format(){this.formattedValue=this.evaluatedValue}},COLOR_LIGHT=`#fff`,COLOR_1=`#00897b`,COLOR_2=`#00796b`,COLOR_3=`#00454d`,Env=class{ranges;dataProvider;constructor(e,t){this.ranges=e,this.dataProvider=t}Eval(txt){const _M_E_=this,_R_A_N_G_E_=this.ranges,PI=Math.PI,E=Math.E;function SUM(e){return _M_E_.data(e).reduce((e,t)=>e*1+t*1,0)}function MIN(e){return _M_E_.data(e).reduce((e,t)=>Math.min(e*1,t*1),0)}function MAX(e){return _M_E_.data(e).reduce((e,t)=>Math.max(e*1,t*1),0)}function SIN(e){return Math.sin(e)}function COS(e){return Math.cos(e)}function TAN(e){return Math.tan(e)}function ASIN(e){return Math.asin(e)}function ACOS(e){return Math.acos(e)}function ATAN(e){return Math.atan(e)}function ASINH(e){return Math.asinh(e)}function ACOSH(e){return Math.acosh(e)}function ATANH(e){return Math.atanh(e)}function ABS(e){return Math.abs(e)}function SQRT(e){return Math.sqrt(e)}function CBRT(e){return Math.cbrt(e)}function LOG(e){return Math.log(e)}function EXP(e){return Math.exp(e)}function TRUNC(e){return Math.trunc(e)}function CEIL(e){return Math.ceil(e)}function FLOOR(e){return Math.floor(e)}return eval(txt)}data(e){return this.dataProvider.getEvaluatedValue(e)}},Evaluator=class{static Eval(e,t){if(t.length<1||t[0]!=`=`)return t;let n,r=this.valueRegex,i=t,a=[],o=0;for(;(n=r.exec(t))!==null;)n.index===r.lastIndex&&r.lastIndex++,n.forEach((t,n)=>{if(t&&t.indexOf(`:`)!=-1)a.push(t),i=i.replace(t+``,`_R_A_N_G_E_[${o++}]`);else if(n==0){let n=e.getEvaluatedValue(t);i=i.replace(t,n)}});try{return new Env(a,e).Eval(i.substr(1))}catch{return`#ERR`}}static valueRegex=/(([a-zA-Z]+[0-9])+\:?([a-zA-Z]+[0-9]+)?)/g},CellSelection=class{left=0;top=0;right=0;bottom=0;rowId=0;columnId=0;get single(){return this.right==this.left&&this.top==this.bottom}toString(){return`${this.top} ${this.left} - ${this.bottom} ${this.right}`}},Sheet=class e{title;get SelectionLabel(){return this.getCellName(this.selection.columnId,this.selection.rowId)}get SelectedValue(){return this.selectedCell&&this.selectedCell.value}get SelectedAppearance(){return this.getAppearance(this.selection.columnId,this.selection.rowId)}get selectedCell(){return this.getCell(this.selection.columnId,this.selection.rowId)}get invalidSelection(){return this.selectedCell&&this.selectedCell.isMerged}get scrollColumn(){return this.scrollX}get scrollRow(){return this.scrollY}static get_columnName(e){let t=`ABCDEFGHIJKLMNOPQRSTUVWXYZ`,n=``,r=e+1;for(;r>0;){let e=(r-1)%26;n=`ABCDEFGHIJKLMNOPQRSTUVWXYZ`[e]+n,r=(r-(e+1))/26}return n}static load(t){let n=new e(t.title);return n.fill(t.data),n.style(t.appearance),n.columnAppearance=t.columnAppearance,n.rowAppearance=t.rowAppearance,n.columnWidth=t.columnWidth,n.rowHeight=t.rowHeight,n.scrollX=t.scrollX,n.scrollY=t.scrollY,n.selection=t.selection,n}defaultAppearance=new Appearance;defaultRowHeight=30;defaultColumnWidth=100;selection;data=[];appearance=[];columnAppearance=[];rowAppearance=[];rowHeight=[];columnWidth=[];scrollX=0;scrollY=0;change_listeners=[];constructor(e){this.title=e,this.defaultAppearance.background=null,this.defaultAppearance.fontName=`Lato`,this.defaultAppearance.fontSize=12,this.defaultAppearance.horizontalBorder=null,this.defaultAppearance.verticalBorder=null,this.defaultAppearance.text=`#333333`,this.selection=new CellSelection,this.selection.top=0,this.selection.left=0,this.selection.right=0,this.selection.bottom=0,this.selection.rowId=0,this.selection.columnId=0}selectNextColumnCell(){if(this.selection.columnId++,this.selection.single){this.selection.right=this.selection.columnId,this.selection.left=this.selection.columnId,this.onChange();return}this.selection.columnId>this.selection.right&&(this.selection.columnId=this.selection.left,this.selection.rowId==this.selection.bottom?this.selection.rowId=this.selection.top:this.selectNextRowCell()),this.invalidSelection&&this.selectNextColumnCell(),this.onChange()}selectPreviousColumnCell(){if(this.selection.columnId!=0){if(this.selection.columnId--,this.selection.single){this.selection.right=this.selection.columnId,this.selection.left=this.selection.columnId,this.onChange();return}this.selection.columnIdthis.selection.bottom&&(this.selection.rowId=this.selection.top,this.selection.columnId==this.selection.right?this.selection.columnId=this.selection.left:this.selectNextColumnCell()),this.invalidSelection&&this.selectNextRowCell(),this.onChange()}selectPreviousRowCell(){if(this.selection.rowId!=0){if(this.selection.rowId--,this.selection.single){this.selection.top=this.selection.rowId,this.selection.bottom=this.selection.rowId,this.onChange();return}this.selection.rowIdthis.scrollColumn+100)return 0;let r=this.getColumnWidth(n);if(e>t&&e=0&&this.change_listeners.splice(t,1)}getWidth(e){return 110}save(){return{title:this.title,data:this.data,appearance:this.appearance,columnAppearance:this.columnAppearance,rowAppearance:this.rowAppearance,rowHeight:this.rowHeight,columnWidth:this.columnWidth,scrollX:this.scrollX,scrollY:this.scrollY,selection:this.selection}}getCellName(t,n){return`${e.get_columnName(t)}${n+1}`}getCellPos(e){let t=/([a-zA-z]+)([0-9]+)/g;if(!/([a-zA-z]+)([0-9]+)/g.test(e))throw Error(`invalid cell name `+e);let n=t.exec(e),r=this.getColumnIndex(n[1]);return{rowId:parseInt(n[2])-1,columnId:r}}getColumnIndex(e){let t=0,n=1,r=65;for(let i=e.length-1;i>=0;i--){let a=e.charCodeAt(i)-r;t+=a*n,n*=26,r=64}return t}getCellEvaluatedValue(e,t){let n=this.getCell(e,t);return n==null?null:Evaluator.Eval(this,n.value)}updateDependees(e,t){for(let e of this.data)if(e)for(let t of e)!t||!t.value||t.value.length&&t.value[0]==`=`&&this.setCellValue(t.columnId,t.rowId,t.value,!0)}onChange(){this.change_listeners.forEach(e=>e())}fill(e){this.data=[];for(let t of e)if(t)for(let e of t){if(!e)continue;let t=Cell.from(e);this.setCell(t.columnId,t.rowId,t,!0)}}style(e){if(this.appearance=[],e){for(let t of e)if(t)for(let n of t){if(!n)continue;let r=Appearance.from(n),i=e.indexOf(t),a=t.indexOf(n);this.setCellAppearance(i,a,r,!0)}}}};function clone(e){return JSON.parse(JSON.stringify(e))}var Commander=class{doc;get ActiveSheet(){return this.doc.ActiveSheet}get Selection(){return this.ActiveSheet.selection}get SelectedAppearance(){let e=this.Selection,t=this.doc.ActiveSheet,n=[];for(let r=e.top;r<=e.bottom;r++)for(let r=e.left;r<=e.right;r++){let r=t.getCellAppearance(e.columnId,e.rowId);r&&n.push(clone(r))}return n}get SelectionData(){let e=this.Selection,t=this.doc.ActiveSheet,n=[];for(let r=e.left;r<=e.right;r++)for(let i=e.top;i<=e.bottom;i++){let e=t.getCell(r,i);n.push(clone(e))}return n}history=[];commands={};constructor(e){this.doc=e,this.commands.bold=()=>this.appearance(e=>e.bold=!e.bold),this.commands.italic=()=>this.appearance(e=>e.italic=!e.italic),this.commands.underline=()=>this.appearance(e=>e.underline=!e.underline),this.commands[`font-size`]=e=>this.appearance(t=>t.fontSize=e),this.commands[`font-name`]=e=>this.appearance(t=>t.fontName=e),this.commands[`bg-color`]=e=>this.appearance(t=>t.background=e),this.commands[`fg-color`]=e=>this.appearance(t=>t.text=e),this.commands[`top-border`]=e=>this.topBorder(e),this.commands[`no-border`]=()=>this.noBorder(),this.commands[`left-border`]=e=>this.leftBorder(e),this.commands[`right-border`]=e=>this.rightBorder(e),this.commands[`bottom-border`]=e=>this.bottomBorder(e),this.commands[`outside-border`]=e=>this.outsideBorder(e),this.commands[`horizontal-border`]=e=>this.horizontalBorder(e),this.commands[`vertical-border`]=e=>this.verticalBorder(e),this.commands[`cross-border`]=e=>this.crossBorder(e),this.commands[`full-border`]=e=>{this.topBorder(e,!1),this.leftBorder(e,!1),this.bottomBorder(e,!1),this.rightBorder(e,!1),this.appearance(t=>{t.setVertical(e),t.setHorizontal(e)})},this.commands.merge=()=>this.merge(),this.commands.unmerge=()=>this.unmerge(),this.commands.align=e=>this.appearance(t=>t.alignTextTo(e)),this.commands[`change-value`]=(e,t,n)=>this.changeValue(e,t,n),this.commands[`alter-column`]=(e,t)=>this.alterColumn(e,t),this.commands[`alter-row`]=(e,t)=>this.alterRow(e,t)}do(e,...t){this.has(e)||console.warn(`command ${e} does not exsits!`),this.commands[e](...t)}undo(){throw Error(`undo has not been implemented`)}redo(){throw Error(`redo has not been implemented`)}has(e){return!!this.commands[e]}outsideBorder(e){this.logAppearanceOnlyCommand(),this.topBorder(e,!1),this.rightBorder(e,!1),this.bottomBorder(e,!1),this.leftBorder(e,!1)}horizontalBorder(e){this.crossBorder(e,!0,!1)}verticalBorder(e){this.crossBorder(e,!1,!0)}crossBorder(e,t=!0,n=!0){this.logAppearanceOnlyCommand();let r=this.Selection;this.doc.ActiveSheet;for(let i=r.left;i<=r.right;i++)for(let a=r.top;a<=r.bottom;a++){let o=this.ActiveSheet.getCellAppearance(i,a)||new Appearance;t&&a{e.setVertical(null),e.setHorizontal(null)})}topBorder(e,t=!0){t&&this.logAppearanceOnlyCommand();let n=this.Selection;this.doc.ActiveSheet;let r=n.top-1;for(let t=n.left;t<=n.right;t++){let n=this.ActiveSheet.getCellAppearance(t,r)||new Appearance;n.setHorizontal(e),this.ActiveSheet.setCellAppearance(t,r,n,!1)}}leftBorder(e,t=!0){t&&this.logAppearanceOnlyCommand();let n=this.Selection;this.doc.ActiveSheet;let r=n.left-1;for(let t=n.top;t<=n.bottom;t++){let n=this.ActiveSheet.getCellAppearance(r,t)||new Appearance;n.setVertical(e),this.ActiveSheet.setCellAppearance(r,t,n,!1)}}rightBorder(e,t=!0){t&&this.logAppearanceOnlyCommand();let n=this.Selection;this.doc.ActiveSheet;let r=n.right;for(let t=n.top;t<=n.bottom;t++){let n=this.ActiveSheet.getCellAppearance(r,t)||new Appearance;n.setVertical(e),this.ActiveSheet.setCellAppearance(r,t,n,!1)}}bottomBorder(e,t=!0){t&&this.logAppearanceOnlyCommand();let n=this.Selection,r=this.doc.ActiveSheet;for(let t=n.left;t<=n.right;t++){let i=r.getCellAppearance(t,n.bottom)||new Appearance;i.setHorizontal(e),r.setCellAppearance(t,n.bottom,i,!1)}}logAppearanceOnlyCommand(){let e={selection:this.Selection,appearance:this.SelectedAppearance};this.history.push(e)}logDataOnlyCommand(){let e={selection:this.Selection,data:this.SelectionData};this.history.push(e)}alterColumn(e,t){let n=this.doc.ActiveSheet.getColumnWidth(e);this.history.push({selection:e,data:n,meta:`COLUMN`}),this.doc.ActiveSheet.setColumnWidth(e,n+t)}alterRow(e,t){let n=this.doc.ActiveSheet.getRowHeight(e);this.history.push({selection:e,data:n,meta:`ROW`}),this.doc.ActiveSheet.setRowHeight(e,n+t)}changeValue(e,t,n){this.logDataOnlyCommand(),e??=this.Selection.columnId,t??=this.Selection.rowId,this.ActiveSheet.setCellValue(e,t,n)}merge(){this.logDataOnlyCommand();let e=this.Selection,t=Math.min(e.right,e.left),n=Math.min(e.top,e.bottom),r=Math.abs(e.right-e.left)+1,i=Math.abs(e.top-e.bottom)+1;this.ActiveSheet.merge(t,n,r,i)}unmerge(){this.logDataOnlyCommand();let e=this.Selection;this.ActiveSheet.unmerge(e.columnId,e.rowId)}appearance(e){this.logAppearanceOnlyCommand();let t=this.Selection;for(let n=t.top;n<=t.bottom;n++)for(let r=t.left;r<=t.right;r++){let t=this.ActiveSheet.getCellAppearance(r,n)||new Appearance;e(t),this.ActiveSheet.setCellAppearance(r,n,t)}}},OpenDocument=class{get ActiveSheet(){return this.sheets[this.activeSheetIndex]}get ActiveSheetIndex(){return this.activeSheetIndex}set ActiveSheetIndex(e){if(e<0||e>=this.sheets.length)throw Error(`invalid sheet index`);this.activeSheetIndex=e,this.onChange()}get Sheets(){return this.sheets}sheets=[];activeSheetIndex=0;commander;change_listeners=[];constructor(){this.init(),this.commander=new Commander(this)}addSheet(e){let t=new Sheet(e);t.addOnChange(()=>this.onChange()),this.sheets.push(t),this.onChange()}addOnChange(e){this.change_listeners.push(e)}removeOnChange(e){let t=this.change_listeners.indexOf(e);t>=0&&this.change_listeners.splice(t,1)}onChange(){this.change_listeners.forEach(e=>e())}execCommand(e,...t){this.commander.do(e,...t)}save(){return{sheets:this.sheets.map(e=>e.save()),activeSheetIndex:this.activeSheetIndex}}load(e){this.sheets=e.sheets.map(e=>Sheet.load(e)),this.activeSheetIndex=e.activeSheetIndex,this.onChange()}init(){this.addSheet(`Sheet1`),this.addSheet(`Sheet2`),this.addSheet(`Sheet3`)}},LayoutDirection=function(e){return e[e.LeftToRight=1]=`LeftToRight`,e[e.RightToLeft=2]=`RightToLeft`,e}({}),ContextMask=class e{x=0;y=0;width=0;height=0;constructor(e,t,n,r){this.x=e,this.y=t,this.width=n,this.height=r}get_left(){return this.x}set_left(e){this.x=e}get_top(){return this.y}get_right(){return this.x+this.width}get_bottom(){return this.y+this.height}set_top(e){this.y=e}get_width(){return this.width}set_width(e){this.width=e}get_height(){return this.height}set_height(e){this.height=e}set_value(e,t,n,r){this.x=e,this.y=t,this.width=n,this.height=r}get_combinedMask(t,n,r,i){let a=Math.min(t+r,this.get_right()),o=Math.min(n+i,this.get_bottom());return r=Math.min(a-t,this.get_width()),i=Math.min(o-n,this.get_height()),t=Math.max(t,this.get_left()),n=Math.max(n,this.get_top()),new e(t,n,r,i)}},Context=class{direction=LayoutDirection.LeftToRight;textAlign=TextAlign.Left;fillStyle=`#fff`;strokeStyle=`#000`;strokeSize=1;contentFillStyle=`#000`;fontStyle=``;fontSize=12;fontName=`Tahoma`;context2d;width;height;currentMask;maskStack=[];constructor(e,t,n){this.context2d=e,this.width=t,this.height=n}get_directed_x(e,t=0){return this.direction===LayoutDirection.LeftToRight?e:this.width-e-t}get_textWidth(e){return this.context2d.measureText(e).width}save(){if(this.context2d.save(),this.context2d.translate(-.5,-.5),this.currentMask){let e=this.currentMask;this.context2d.rect(e.get_left(),e.get_top(),e.get_width(),e.get_height()),this.context2d.clip()}}restore(){this.context2d.restore()}setMask(e,t,n,r,i=!1){e=this.get_directed_x(e,n),this.currentMask&&this.maskStack.push(this.currentMask),i&&this.currentMask?this.currentMask=this.currentMask.get_combinedMask(e,t,n,r):this.currentMask=new ContextMask(e,t,n,r)}unmask(){this.maskStack.length>0?this.currentMask=this.maskStack.pop():this.currentMask=null}clearRect(e,t,n,r){e=this.get_directed_x(e,n),this.save(),this.context2d.clearRect(e,t,n,r),this.restore()}fillRect(e,t,n,r){e=this.get_directed_x(e,n),this.save(),this.applyFill(),this.context2d.beginPath(),this.context2d.fillRect(e,t,n,r),this.context2d.fill(),this.restore()}strokeRect(e,t,n,r){e=this.get_directed_x(e,n),this.save(),this.applyStroke(),this.context2d.beginPath(),this.context2d.strokeRect(e,t,n,r),this.context2d.stroke(),this.restore()}line(e,t,n,r){e=this.get_directed_x(e),n=this.get_directed_x(n),this.save(),this.applyStroke(),this.context2d.beginPath(),this.context2d.moveTo(e,t),this.context2d.lineTo(n,r),this.context2d.stroke(),this.restore()}path(e,t,n,...r){this.save(),this.applyStroke(),this.applyFill(),this.context2d.beginPath();let i=r[0],a=this.get_directed_x(i.x);this.context2d.moveTo(a,i.y);for(let e=1;ethis.render())}initialize(){this.createElements(),this.resize(),this.render()}createElements(){this.canvas=document.createElement(`canvas`),this.container.appendChild(this.canvas)}resize(){let e=window.devicePixelRatio;this.width=this.container.clientWidth,this.height=this.container.clientHeight,e>1?(this.canvas.width=this.width*e,this.canvas.height=this.height*e,this.canvas.style.width=this.width+`px`,this.canvas.style.height=this.height+`px`):(this.canvas.width=this.width,this.canvas.height=this.height),this.render()}get_context2D(){let e=window.devicePixelRatio;this.canvas.width=this.canvas.width;let t=this.canvas.getContext(`2d`);return t.scale(e,e),t}render(){this.rendering||(this.rendering=!0,setTimeout(()=>{this.doRender(),this.rendering=!1},1e3/this.renderFrameRate))}doRender(){console.log(`%cRender`,`color:${COLOR_1}`);let e=this.get_context2D();this.context=new Context(e,this.width,this.height),this.renderSheetTitles(),this.renderSheet()}renderTopCorner(){this.context.fillStyle=`#ececec`,this.context.fontSize=12;let e=28;this.context.fillClosePath(new Point(2,28),new Point(28,28),new Point(28,1))}renderSheetTitles(){this.renderTopCorner(),this.context.strokeSize=1;let e=0,t=this.height-30-.5,n=35,r=this.height-30-.5;this.context.rect(0,t,this.width,35),this.context.fillStyle=this.context.createGradient(0,r,0,30/3,[0,`#f0f0f0`],[1,`#fff`]),this.context.fillRect(0,t,this.width,35),this.context.textAlign=TextAlign.Center;let i=30,a=this.document.ActiveSheet,o=5;for(let e of this.document.Sheets){let t=e.getWidth(e=>this.context.get_textWidth(e));this.context.strokeStyle=`#aaa`,this.context.fillStyle=`#fafafa`,this.context.fontStyle=`italic`,e===a&&(this.context.fillStyle=`#fff`,this.context.fontStyle=`bold`),this.context.rect(i,r,t,25),this.context.fillText(e.title,i,r+5,t),e===a&&(this.context.fillStyle=COLOR_3,this.context.fillRect(i,r+30-5,t,2),this.context.strokeStyle=COLOR_LIGHT),this.context.line(i,r,i+t,r),i+=t+5}this.context.fontStyle=``}renderSheet(){let e=this.width,t=this.height,n=30,r=t-30,i=this.context;i.setMask(0,0,e,t-31.5);let a=this.renderRows(),o=this.renderColumns();i.unmask(),i.setMask(30.5,30,e,r-30-.5),this.renderCells(o,a),i.unmask()}renderRows(){this.context;let e=this.height-30-30,t=30,n=this.document.ActiveSheet,r=n.scrollRow;for(;t0&&(!s||!s.isMerged)){let e=u.horizontalBorder,t=u.verticalBorder;a.strokeStyle=e&&e.color||`#eeeeee`,(u.background==null||e!=null)&&a.line(n+30,r+c,n+30+l,r+c),a.strokeStyle=t&&t.color||`#eeeeee`,(u.background==null||t!=null)&&a.line(n+30+l,r,n+30+l,r+c)}n+=e}r+=t}}paintCell(e,t,n,r){let i=this.context,a=this.document.ActiveSheet,o=a.getCell(e,t);if(o&&o.isMerged)return;let s=a.getAppearance(e,t),c=n+30;if(r<30)return;s.fontSize&&(i.fontSize=parseInt(s.fontSize+``)),s.fontName&&(i.fontName=s.fontName),i.fontStyle=s.textStyle?s.textStyle:``;let l=o?a.getCellWidth(o):a.getColumnWidth(e),u=o?a.getCellHeight(o):a.getRowHeight(t);i.setMask(c,r,l,u),s.background&&(i.fillStyle=s.background,i.fillRect(c,r,l,u)),o&&o.label&&(i.contentFillStyle=s.text,i.strokeStyle=s.text,i.textAlign=s.textAlign,i.fillText(o.label,n+30+5,r+7,l)),i.unmask()}},CellEditor=class{controler;get Value(){return this.editorElement.value==``?null:this.editorElement.value}set Value(e){this.editorElement&&(this.editorElement.value=e?e+``:``)}get IsDirty(){return this.getCurrentCell().value!=this.Value}get EditMode(){return this.editMode}set EditMode(e){this.editMode=e,e?this.editorElement.readOnly=!1:this.editorElement.readOnly=!0,this.editorElement.focus()}websheet;editorArea;selectionElement;editorElement;anchorElement;editMode=!1;constructor(e){this.controler=e,this.websheet=e.websheet,this.initialize(),this.select()}initialize(){this.editorArea=document.createElement(`div`),this.editorArea.style.position=`absolute`,this.editorArea.style.top=`30px`,this.editorArea.style.left=`30px`,this.editorArea.style.bottom=`30px`,this.editorArea.style.right=`0px`,this.editorArea.style.overflow=`visible`,this.controler.renderer.Element.appendChild(this.editorArea),this.selectionElement=document.createElement(`div`),this.selectionElement.style.position=`absolute`,this.selectionElement.style.border=`solid 2px ${COLOR_1}`,this.selectionElement.style.overflow=`hidden`,this.selectionElement.style.background=`rgba(0,0,0,.1)`,this.selectionElement.style.transitionDuration=`.1s`,this.editorArea.appendChild(this.selectionElement),this.editorElement=document.createElement(`input`),this.editorElement.type=`text`,this.editorElement.style.display=`block`,this.editorElement.style.zIndex=`10000`,this.editorElement.style.position=`absolute`,this.editorElement.style.background=`#fff`,this.editorElement.style.textIndent=`3px`,this.editorElement.style.border=`none`;let e=()=>{this.EditMode||=!0};this.editorElement.addEventListener(`click`,e),this.editorElement.addEventListener(`change`,e),this.editorElement.addEventListener(`touchstart`,e),this.selectionElement.appendChild(this.editorElement),this.anchorElement=document.createElement(`span`),this.anchorElement.style.position=`absolute`,this.anchorElement.style.right=`0`,this.anchorElement.style.bottom=`0`,this.anchorElement.style.width=`6px`,this.anchorElement.style.height=`6px`,this.anchorElement.style.borderRadius=`2px`,this.anchorElement.style.border=`solid 1px #fff`,this.anchorElement.style.background=COLOR_2,this.anchorElement.style.zIndex=`10000`,this.anchorElement.style.cursor=`cell`,this.editorArea.appendChild(this.anchorElement),this.websheet.addOnChange(()=>{let e=this.websheet.ActiveSheet.SelectedValue;e!=this.Value&&(this.Value=e),this.updateEditorAppearance(),this.select(!0)})}disableAnimation(){this.selectionElement.style.transitionDuration=``,this.anchorElement.style.transitionDuration=``}enableAnimation(){this.selectionElement.style.transitionDuration=`.1s`,this.anchorElement.style.transitionDuration=`.1s`}deselect(){let e=this.getCurrentCell();this.IsDirty&&this.controler.websheet.execCommand(`change-value`,e.columnId,e.rowId,this.Value)}updateEditorAppearance(){let e=this.getCurrentAppearance();this.editorElement.style.textAlign=this.getTextAlign(e.textAlign),this.editorElement.style.fontStyle=e.italic?`italic`:``,this.editorElement.style.fontWeight=e.bold?`bold`:``,this.editorElement.style.background=e.background,this.editorElement.style.fontFamily=e.fontName,this.editorElement.style.fontSize=`${e.fontSize}px`,this.editorElement.style.color=e.text,this.editorElement.style.textDecoration=e.underline?`underline`:``}select(e=!0){e?this.enableAnimation():this.disableAnimation(),this.updateEditorAppearance();let t=this.controler.websheet.ActiveSheet,n=t.selection,r=t.getColumnLeft(n.left),i=t.getRowTop(n.top),a=t.getColumnRight(n.right),o=t.getRowBottom(n.bottom),s=a-r,c=o-i;this.selectionElement.style.left=r-2+`px`,this.selectionElement.style.top=i-2+`px`,this.selectionElement.style.width=s-2+`px`,this.selectionElement.style.height=c-2+`px`;let l=this.getCurrentCell(),u=t.getRowTop(n.rowId),d=t.getColumnLeft(n.columnId);this.editorElement.style.left=d-r+`px`,this.editorElement.style.top=u-i+`px`,this.editorElement.style.width=t.getCellWidth(l)-3+`px`,this.editorElement.style.height=t.getCellHeight(l)-3+`px`,this.editorElement.focus(),this.anchorElement.style.left=`${a-5}px`,this.anchorElement.style.top=`${o-5}px`}getCurrentCell(){let e=this.controler.websheet.ActiveSheet,t=e.selection;return e.getCell(t.columnId,t.rowId)||new Cell(t.columnId,t.rowId)}getCurrentAppearance(){let e=this.controler.websheet.ActiveSheet,t=e.selection;return e.getAppearance(t.columnId,t.rowId)}getTextAlign(e){return e==TextAlign.Center?`center`:e==TextAlign.Left?`left`:e==TextAlign.Right?`right`:``}},UIHandler=class{controller;constructor(e){this.controller=e}click(){}dblClick(){}mouseDown(e,t){}mouseMove(e,t){}mouseUp(e,t){}mouseWheel(e,t){}keyDown(e){}keyPress(e){}keyUp(e){}get locked(){return this.controller.locked}lock(){this.controller.lock(this)}unlock(){this.controller.unlock()}},WebSheetUIHandler=class extends UIHandler{mouseUp(e,t){if(t120?(n.scrollRight(),this.wheelDeltaX=0):this.wheelDeltaX<-120&&(n.scrollLeft(),this.wheelDeltaX=0),this.wheelDeltaY>120?(n.scrollUp(),this.wheelDeltaY=0):this.wheelDeltaY<-120&&(n.scrollDown(),this.wheelDeltaY=0),this.controller.renderer.render(),this.controller.select()}mouseDown(e,t){this.oldX=e,this.oldY=t}mouseUp(e,t){this.selectCell(e,t)}keyPress(e){if(e.key==`Enter`){if(this.controller.EditMode)this.controller.commit(),this.controller.EditMode=!1;else{this.controller.EditMode=!0;return}e.shiftKey?this.sheet.selectPreviousRowCell():this.sheet.selectNextRowCell()}}keyDown(e){e.key==`Tab`&&(this.controller.deselect(),e.shiftKey?this.sheet.selectPreviousColumnCell():this.sheet.selectNextColumnCell(),e.preventDefault(),this.controller.select(!0)),!this.controller.EditMode&&(e.key==`ArrowRight`||e.key==`ArrowLeft`||e.key==`ArrowUp`||e.key==`ArrowDown`)&&(this.controller.deselect(),e.key==`ArrowRight`?this.sheet.selectNextColumnCell():e.key==`ArrowLeft`?this.sheet.selectPreviousColumnCell():e.key==`ArrowUp`?this.sheet.selectPreviousRowCell():e.key==`ArrowDown`&&this.sheet.selectNextRowCell(),e.preventDefault(),this.controller.select(!0))}dblClick(){this.controller.EditMode||(this.controller.EditMode=!0)}selectCell(e,t){if(t<30||e<30||t>this.controller.renderer.Element.clientHeight-30)return;let n=this.controller.websheet.ActiveSheet,r=this.oldX-30,i=this.oldY-30,a=e-30,o=t-30;this.controller.deselect(),n.selectByXY(r,i,a,o),this.controller.select(!0)}},delta=4,ResizeHandler=class extends UIHandler{col;row;oldX;oldY;engaged=!1;mouseMove(e,t){let n=this.hitColumn(e-30,t),r=this.hitRow(e,t-30);n===!1?r===!1?this.engaged||this.controller.resetCursor():this.controller.changeCursor(`row-resize`):this.controller.changeCursor(`col-resize`)}mouseDown(e,t){this.col=this.hitColumn(e-30,t),this.row=this.hitRow(e,t-30),this.oldX=e,this.oldY=t,this.col!==!1||this.row!==!1?(this.lock(),this.col===!1?this.row!==!1&&this.controller.changeCursor(`row-resize`):this.controller.changeCursor(`col-resize`),this.engaged=!0):this.engaged=!1}mouseUp(e,t){this.engaged&&(this.col!==!1&&(this.controller.alterColumn(this.col,e-this.oldX),this.controller.resetCursor()),this.row!==!1&&(this.controller.alterRow(this.row,t-this.oldY),this.controller.resetCursor()),this.unlock())}hitRow(e,t){if(e>30)return!1;let n=e=>this.controller.websheet.ActiveSheet.getRowHeight(e),r=0;for(let e=n(r++);ee-delta&&t30)return!1;let n=e=>this.controller.websheet.ActiveSheet.getColumnWidth(e),r=0;for(let t=n(r++);tt-delta&&ethis.cellEditor.updateEditorAppearance())}select(e=!0){this.cellEditor.select(e)}deselect(){this.cellEditor.deselect()}alterColumn(e,t){this.websheet.execCommand(`alter-column`,e,t)}alterRow(e,t){this.websheet.execCommand(`alter-row`,e,t)}lock(e){this.lockedOn=e}unlock(){this.lockedOn=null}resetCursor(){this.renderer.Element.style.cursor=``}changeCursor(e){this.renderer.Element.style.cursor=e}attachEvents(){let e=this.renderer.Element,t=document.createElement(`div`);t.style.position=`absolute`,t.style.top=`0`,t.style.left=`0`,t.style.right=`0`,t.style.bottom=`0`,t.style.zIndex=`9999`,e.appendChild(t);let n=this,r=function(t){return{x:t.offsetX||t.layerX||t.clientX-e.offsetLeft,y:t.offsetY||t.layerY||t.clientY-e.offsetTop}},i=function(t){let n=t.touches.length?t.touches[0]:t.changedTouches[0];return{x:n.clientX-e.offsetLeft,y:n.clientY-e.offsetTop}};t.addEventListener(`touchstart`,e=>{if(e.touches.length==1){let t=i(e);n.mouseDown(t.x,t.y),e.preventDefault()}}),t.addEventListener(`touchmove`,e=>{let t=i(e);n.mouseMove(t.x,t.y)}),t.addEventListener(`touchend`,e=>{let t=i(e);n.mouseUp(t.x,t.y)}),t.addEventListener(`touchcancel`,e=>{let t=i(e);n.mouseUp(t.x,t.y)}),t.addEventListener(`mousedown`,e=>{let t=r(e);n.mouseDown(t.x,t.y)}),t.addEventListener(`mousemove`,e=>{let t=r(e);n.mouseMove(t.x,t.y)}),t.addEventListener(`mouseup`,e=>{let t=r(e);n.mouseUp(t.x,t.y)}),t.addEventListener(`click`,e=>n.click()),t.addEventListener(`dblclick`,e=>n.dblClick()),t.addEventListener(`mousewheel`,e=>{let t=e.wheelDeltaX,r=e.wheelDeltaY;return n.mouseWheel(t,r),e.preventDefault(),e.stopPropagation(),!1}),window.addEventListener(`keydown`,e=>n.keyDown(e)),window.addEventListener(`keypress`,e=>n.keyPress(e)),window.addEventListener(`keyup`,e=>n.keyUp(e)),window.addEventListener(`resize`,()=>this.renderer.resize())}click(){if(this.lockedOn){this.lockedOn.click();return}for(let e=0;e1||e.rowSpan>1:!1}get selectedCell(){return this.document.ActiveSheet.selectedCell}get SelectedCellLabel(){return this.document.ActiveSheet.SelectionLabel}get SelectedValue(){return this.document.ActiveSheet.SelectedValue}get SelectedAppearance(){return this.document.ActiveSheet.SelectedAppearance}handlers=[];document=new OpenDocument;render=null;uiController;constructor(e){this.element=e,this.render=new CanvasRenderer(e,this.document),this.uiController=new UIHandlerController(this.document,this.render),this.document.addOnChange(()=>this.raiseOnChangeEventListener()),this.render.render(),e.openDocument=this.document}execCmd(e,...t){console.log(`the command _${e}_ executed.`),this.uiController.commit(),this.document.execCommand(e,...t)}addOnChangeEventListener(e){this.handlers.push(e)}removeOnChangeEventListener(e){let t=this.handlers.indexOf(e);t!=-1&&this.handlers.splice(t,1)}save(){return JSON.stringify(this.document.save())}load(e){let t=JSON.parse(e);this.document.load(t)}raiseOnChangeEventListener(){this.handlers.forEach(e=>e(this.document))}};function SpreadsheetSurface(e){let t=import_react.useRef(null);return import_react.useEffect(()=>{if(!t.current)return;let n=new UI(t.current),r=t=>e.onChange(t);return n.addOnChangeEventListener(r),e.onReady(n),e.registerLoad(e=>n.load(e)),()=>{n.removeOnChangeEventListener(r),e.registerLoad(null)}},[]),import_react.createElement(`div`,{className:`ows-sheet-surface`,ref:t})}var defaultState={isMerged:!1,label:`A1`,originalValue:``,value:``};function App(){let[e,t]=import_react.useState(new Appearance),[n,r]=import_react.useState(`file`),[i,a]=import_react.useState(defaultState),o=import_react.useRef(n),s=import_react.useRef(null),c=import_react.useRef(null);return import_react.createElement(`div`,{className:`ows-app`},import_react.createElement(RibbonMenu,{appearance:e,fileMode:n,onAction:e=>e.actionName===`save-ows`?saveDocument(c.current):e.actionName===`load-ows`?loadDocument(c.current):e.actionName===`formula-template`?a({...i,value:e.args}):c.current&&c.current.execCmd(e.actionName,e.args),onModeChanged:e=>{o.current===`file`&&e===`local`&&localStorage.getItem(`data`)&&s.current&&s.current(localStorage.getItem(`data`)),o.current=e,r(e)},state:i}),import_react.createElement(FormulaBar,{label:i.label,onAbort:()=>a({...i,value:i.originalValue}),onCommit:()=>commitFormula(c.current,i),onValueChange:e=>a({...i,value:e}),value:i.value}),import_react.createElement(SpreadsheetSurface,{onChange:e=>{t(e.ActiveSheet.SelectedAppearance),a({isMerged:c.current?c.current.isMerged:!1,label:e.ActiveSheet.SelectionLabel,originalValue:e.ActiveSheet.SelectedValue||``,value:e.ActiveSheet.SelectedValue||``}),o.current===`local`&&localStorage.setItem(`data`,JSON.stringify(e.save()))},onReady:e=>c.current=e,registerLoad:e=>s.current=e}),import_react.createElement(`footer`,{className:`ows-status-bar`},`Ready`))}function commitFormula(e,t){e&&t.value!==t.originalValue&&e.execCmd(`change-value`,null,null,t.value)}var isLocalhost=function(){return!!(window.location.hostname===`localhost`||window.location.hostname===`[::1]`||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/))},waitWindowLoad;typeof window<`u`&&(waitWindowLoad=typeof Promise<`u`?new Promise(function(e){return window.addEventListener(`load`,e)}):{then:function(e){return window.addEventListener(`load`,e)}});function register(e,t){t===void 0&&(t={});var n=t.registrationOptions;n===void 0&&(n={}),delete t.registrationOptions;var r=function(e){for(var n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];t&&t[e]&&t[e].apply(t,n)};`serviceWorker`in navigator&&waitWindowLoad.then(function(){isLocalhost()?(checkValidServiceWorker(e,r,n),navigator.serviceWorker.ready.then(function(e){r(`ready`,e)}).catch(function(e){return handleError(r,e)})):(registerValidSW(e,r,n),navigator.serviceWorker.ready.then(function(e){r(`ready`,e)}).catch(function(e){return handleError(r,e)}))})}function handleError(e,t){navigator.onLine||e(`offline`),e(`error`,t)}function registerValidSW(e,t,n){navigator.serviceWorker.register(e,n).then(function(e){if(t(`registered`,e),e.waiting){t(`updated`,e);return}e.onupdatefound=function(){t(`updatefound`,e);var n=e.installing;n.onstatechange=function(){n.state===`installed`&&(navigator.serviceWorker.controller?t(`updated`,e):t(`cached`,e))}}}).catch(function(e){return handleError(t,e)})}function checkValidServiceWorker(e,t,n){fetch(e).then(function(r){r.status===404?(t(`error`,Error(`Service worker not found at `+e)),unregister()):r.headers.get(`content-type`).indexOf(`javascript`)===-1?(t(`error`,Error(`Expected `+e+` to have javascript content-type, but received `+r.headers.get(`content-type`))),unregister()):registerValidSW(e,t,n)}).catch(function(e){return handleError(t,e)})}function unregister(){`serviceWorker`in navigator&&navigator.serviceWorker.ready.then(function(e){e.unregister()}).catch(function(e){return handleError(emit,e)})}register(`service-worker.js`,{ready(){console.log(`App is being served from cache by a service worker. +`+e.stack}return{value:e,source:t,stack:i,digest:null}}function Ps(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Fs(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var Is=typeof WeakMap==`function`?WeakMap:Map;function Ls(e,t,n){n=mo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){il||(il=!0,al=r),Fs(e,t)},n}function Rs(e,t,n){n=mo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r==`function`){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Fs(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch==`function`&&(n.callback=function(){Fs(e,t),typeof r!=`function`&&(ol===null?ol=new Set([this]):ol.add(this));var n=t.stack;this.componentDidCatch(t.value,{componentStack:n===null?``:n})}),n}function zs(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Is;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)||(i.add(n),e=Rl.bind(null,e,t,n),t.then(e,e))}function Bs(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t===null?!0:t.dehydrated!==null),t)return e;e=e.return}while(e!==null);return null}function Vs(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=mo(-1,1),t.tag=2,ho(n,t,1))),n.lanes|=1),e)}var Hs=x.ReactCurrentOwner,Us=!1;function B(e,t,n,r){t.child=e===null?Xa(t,null,n,r):Ya(t,e.child,n,r)}function Ws(e,t,n,r,i){n=n.render;var a=t.ref;return io(t,i),r=Bo(e,t,n,r,a,i),n=Vo(),e!==null&&!Us?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,uc(e,t,i)):(P&&n&&Aa(t),t.flags|=1,B(e,t,r,i),t.child)}function Gs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Kl(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,Ks(e,t,a,r,i)):(e=Yl(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,(e.lanes&i)===0){var o=a.memoizedProps;if(n=n.compare,n=n===null?Ur:n,n(o,r)&&e.ref===t.ref)return uc(e,t,i)}return t.flags|=1,e=Jl(a,r),e.ref=t.ref,e.return=t,t.child=e}function Ks(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Ur(a,r)&&e.ref===t.ref)if(Us=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(Us=!0);else return t.lanes=e.lanes,uc(e,t,i)}return Ys(e,t,n,r,i)}function qs(e,t,n){var r=t.pendingProps,i=r.children,a=e===null?null:e.memoizedState;if(r.mode===`hidden`)if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},A(Yc,Jc),Jc|=n;else{if(!(n&1073741824))return e=a===null?n:a.baseLanes|n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,A(Yc,Jc),Jc|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a===null?n:a.baseLanes,A(Yc,Jc),Jc|=r}else a===null?r=n:(r=a.baseLanes|n,t.memoizedState=null),A(Yc,Jc),Jc|=r;return B(e,t,i,n),t.child}function Js(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ys(e,t,n,r,i){var a=N(n)?oa:j.current;return a=sa(t,a),io(t,i),n=Bo(e,t,n,r,a,i),r=Vo(),e!==null&&!Us?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,uc(e,t,i)):(P&&r&&Aa(t),t.flags|=1,B(e,t,n,i),t.child)}function Xs(e,t,n,r,i){if(N(n)){var a=!0;da(t)}else a=!1;if(io(t,i),t.stateNode===null)lc(e,t),As(t,n,r),Ms(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,s=t.memoizedProps;o.props=s;var c=o.context,l=n.contextType;typeof l==`object`&&l?l=ao(l):(l=N(n)?oa:j.current,l=sa(t,l));var u=n.getDerivedStateFromProps,d=typeof u==`function`||typeof o.getSnapshotBeforeUpdate==`function`;d||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==r||c!==l)&&js(t,o,r,l),uo=!1;var f=t.memoizedState;o.state=f,vo(t,r,o,i),c=t.memoizedState,s!==r||f!==c||M.current||uo?(typeof u==`function`&&(Ds(t,n,u,r),c=t.memoizedState),(s=uo||ks(t,n,s,r,f,c,l))?(d||typeof o.UNSAFE_componentWillMount!=`function`&&typeof o.componentWillMount!=`function`||(typeof o.componentWillMount==`function`&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount==`function`&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount==`function`&&(t.flags|=4194308)):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=l,r=s):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,po(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:Es(t.type,s),o.props=l,d=t.pendingProps,f=o.context,c=n.contextType,typeof c==`object`&&c?c=ao(c):(c=N(n)?oa:j.current,c=sa(t,c));var p=n.getDerivedStateFromProps;(u=typeof p==`function`||typeof o.getSnapshotBeforeUpdate==`function`)||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==d||f!==c)&&js(t,o,r,c),uo=!1,f=t.memoizedState,o.state=f,vo(t,r,o,i);var m=t.memoizedState;s!==d||f!==m||M.current||uo?(typeof p==`function`&&(Ds(t,n,p,r),m=t.memoizedState),(l=uo||ks(t,n,l,r,f,m,c)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!=`function`&&typeof o.componentWillUpdate!=`function`||(typeof o.componentWillUpdate==`function`&&o.componentWillUpdate(r,m,c),typeof o.UNSAFE_componentWillUpdate==`function`&&o.UNSAFE_componentWillUpdate(r,m,c)),typeof o.componentDidUpdate==`function`&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=c,r=l):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return Zs(e,t,n,r,a,i)}function Zs(e,t,n,r,i,a){Js(e,t);var o=(t.flags&128)!=0;if(!r&&!o)return i&&fa(t,n,!1),uc(e,t,a);r=t.stateNode,Hs.current=t;var s=o&&typeof n.getDerivedStateFromError!=`function`?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Ya(t,e.child,null,a),t.child=Ya(t,null,s,a)):B(e,t,s,a),t.memoizedState=r.state,i&&fa(t,n,!0),t.child}function Qs(e){var t=e.stateNode;t.pendingContext?la(e,t.pendingContext,t.pendingContext!==t.context):t.context&&la(e,t.context,!1),To(e,t.containerInfo)}function $s(e,t,n,r,i){return Ha(),Ua(i),t.flags|=256,B(e,t,n,r),t.child}var ec={dehydrated:null,treeContext:null,retryLane:0};function tc(e){return{baseLanes:e,cachePool:null,transitions:null}}function nc(e,t,n){var r=t.pendingProps,i=F.current,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(i&2)!=0),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),A(F,i&1),e===null)return Ra(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data===`$!`?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,a?(r=t.mode,a=t.child,o={mode:`hidden`,children:o},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=o):a=Zl(o,r,0,null),e=Xl(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=tc(n),t.memoizedState=ec,e):rc(t,o));if(i=e.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return ac(e,t,o,r,s,i,n);if(a){a=r.fallback,o=t.mode,i=e.child,s=i.sibling;var c={mode:`hidden`,children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Jl(i,c),r.subtreeFlags=i.subtreeFlags&14680064),s===null?(a=Xl(a,o,n,null),a.flags|=2):a=Jl(s,a),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,o=e.child.memoizedState,o=o===null?tc(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},a.memoizedState=o,a.childLanes=e.childLanes&~n,t.memoizedState=ec,r}return a=e.child,e=a.sibling,r=Jl(a,{mode:`visible`,children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function rc(e,t){return t=Zl({mode:`visible`,children:t},e.mode,0,null),t.return=e,e.child=t}function ic(e,t,n,r){return r!==null&&Ua(r),Ya(t,e.child,null,n),e=rc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function ac(e,t,n,i,a,o,s){if(n)return t.flags&256?(t.flags&=-257,i=Ps(Error(r(422))),ic(e,t,s,i)):t.memoizedState===null?(o=i.fallback,a=t.mode,i=Zl({mode:`visible`,children:i.children},a,0,null),o=Xl(o,a,s,null),o.flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,t.mode&1&&Ya(t,e.child,null,s),t.child.memoizedState=tc(s),t.memoizedState=ec,o):(t.child=e.child,t.flags|=128,null);if(!(t.mode&1))return ic(e,t,s,null);if(a.data===`$!`){if(i=a.nextSibling&&a.nextSibling.dataset,i)var c=i.dgst;return i=c,o=Error(r(419)),i=Ps(o,i,void 0),ic(e,t,s,i)}if(c=(s&e.childLanes)!==0,Us||c){if(i=K,i!==null){switch(s&-s){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=(a&(i.suspendedLanes|s))===0?a:0,a!==0&&a!==o.retryLane&&(o.retryLane=a,lo(e,a),hl(i,e,a,-1))}return Ol(),i=Ps(Error(r(421))),ic(e,t,s,i)}return a.data===`$?`?(t.flags|=128,t.child=e.child,t=Bl.bind(null,e),a._reactRetry=t,null):(e=o.treeContext,Na=Ui(a.nextSibling),Ma=t,P=!0,Pa=null,e!==null&&(Ca[wa++]=Ea,Ca[wa++]=Da,Ca[wa++]=Ta,Ea=e.id,Da=e.overflow,Ta=t),t=rc(t,i.children),t.flags|=4096,t)}function oc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ro(e.return,t,n)}function sc(e,t,n,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=i)}function cc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(B(e,t,r.children,n),r=F.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&oc(e,n,t);else if(e.tag===19)oc(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}r&=1}if(A(F,r),!(t.mode&1))t.memoizedState=null;else switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&ko(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),sc(t,!1,i,n,a);break;case`backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&ko(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}sc(t,!0,n,null,a);break;case`together`:sc(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function lc(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function uc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Zc|=t.lanes,(n&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=Jl(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Jl(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function dc(e,t,n){switch(t.tag){case 3:Qs(t),Ha();break;case 5:Do(t);break;case 1:N(t.type)&&da(t);break;case 4:To(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;A(Za,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(A(F,F.current&1),e=uc(e,t,n),e===null?null:e.sibling):nc(e,t,n):(A(F,F.current&1),t.flags|=128,null);A(F,F.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return cc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),A(F,F.current),r)break;return null;case 22:case 23:return t.lanes=0,qs(e,t,n)}return uc(e,t,n)}var fc=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&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}},pc=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,wo(xo.current);var o=null;switch(n){case`input`:i=Ee(e,i),r=Ee(e,r),o=[];break;case`select`:i=w({},i,{value:void 0}),r=w({},r,{value:void 0}),o=[];break;case`textarea`:i=Pe(e,i),r=Pe(e,r),o=[];break;default:typeof i.onClick!=`function`&&typeof r.onClick==`function`&&(e.onclick=Ni)}Je(n,r);var s;for(u in n=null,i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u===`style`){var c=i[u];for(s in c)c.hasOwnProperty(s)&&(n||={},n[s]=``)}else u!==`dangerouslySetInnerHTML`&&u!==`children`&&u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&u!==`autoFocus`&&(a.hasOwnProperty(u)?o||=[]:(o||=[]).push(u,null));for(u in r){var l=r[u];if(c=i?.[u],r.hasOwnProperty(u)&&l!==c&&(l!=null||c!=null))if(u===`style`)if(c){for(s in c)!c.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||={},n[s]=``);for(s in l)l.hasOwnProperty(s)&&c[s]!==l[s]&&(n||={},n[s]=l[s])}else n||(o||=[],o.push(u,n)),n=l;else u===`dangerouslySetInnerHTML`?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(o||=[]).push(u,l)):u===`children`?typeof l!=`string`&&typeof l!=`number`||(o||=[]).push(u,``+l):u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&(a.hasOwnProperty(u)?(l!=null&&u===`onScroll`&&O(`scroll`,e),o||c===l||(o=[])):(o||=[]).push(u,l))}n&&(o||=[]).push(`style`,n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}},mc=function(e,t,n,r){n!==r&&(t.flags|=4)};function hc(e,t){if(!P)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var 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}}function V(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&14680064,r|=i.flags&14680064,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 gc(e,t,n){var i=t.pendingProps;switch(ja(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return V(t),null;case 1:return N(t.type)&&ca(),V(t),null;case 3:return i=t.stateNode,Eo(),k(M),k(j),jo(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(Ba(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Pa!==null&&(vl(Pa),Pa=null))),V(t),null;case 5:Oo(t);var o=wo(Co.current);if(n=t.type,e!==null&&t.stateNode!=null)pc(e,t,n,i,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!i){if(t.stateNode===null)throw Error(r(166));return V(t),null}if(e=wo(xo.current),Ba(t)){i=t.stateNode,n=t.type;var s=t.memoizedProps;switch(i[Ki]=t,i[qi]=s,e=(t.mode&1)!=0,n){case`dialog`:O(`cancel`,i),O(`close`,i);break;case`iframe`:case`object`:case`embed`:O(`load`,i);break;case`video`:case`audio`:for(o=0;o<\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[Ki]=t,e[qi]=i,fc(e,t,!1,!1),t.stateNode=e;a:{switch(c=Ye(n,i),n){case`dialog`:O(`cancel`,e),O(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:O(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;onl&&(t.flags|=128,i=!0,hc(s,!1),t.lanes=4194304)}else{if(!i)if(e=ko(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),hc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!P)return V(t),null}else 2*T()-s.renderingStartTime>nl&&n!==1073741824&&(t.flags|=128,i=!0,hc(s,!1),t.lanes=4194304);s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(V(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=T(),t.sibling=null,n=F.current,A(F,i?n&1|2:n&1),t);case 22:case 23:return wl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?Jc&1073741824&&(V(t),t.subtreeFlags&6&&(t.flags|=8192)):V(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function _c(e,t){switch(ja(t),t.tag){case 1:return N(t.type)&&ca(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Eo(),k(M),k(j),jo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Oo(t),null;case 13:if(k(F),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Ha()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return k(F),null;case 4:return Eo(),null;case 10:return no(t.type._context),null;case 22:case 23:return wl(),null;case 24:return null;default:return null}}var vc=!1,H=!1,yc=typeof WeakSet==`function`?WeakSet:Set,U=null;function bc(e,t){var n=e.ref;if(n!==null)if(typeof n==`function`)try{n(null)}catch(n){$(e,t,n)}else n.current=null}function xc(e,t,n){try{n()}catch(n){$(e,t,n)}}var Sc=!1;function Cc(e,t){if(Pi=En,e=qr(),Jr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Fi={focusedElem:e,selectionRange:n},En=!1,U=t;U!==null;)if(t=U,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,U=e;else for(;U!==null;){t=U;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:Es(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){$(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,U=e;break}U=t.return}return h=Sc,Sc=!1,h}function wc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&xc(t,n,a)}i=i.next}while(i!==r)}}function Tc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Ec(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function Dc(e){var t=e.alternate;t!==null&&(e.alternate=null,Dc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ki],delete t[qi],delete t[Yi],delete t[Xi],delete t[Zi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Oc(e){return e.tag===5||e.tag===3||e.tag===4}function kc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Oc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ac(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ni));else if(r!==4&&(e=e.child,e!==null))for(Ac(e,t,n),e=e.sibling;e!==null;)Ac(e,t,n),e=e.sibling}function jc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(jc(e,t,n),e=e.sibling;e!==null;)jc(e,t,n),e=e.sibling}var W=null,Mc=!1;function Nc(e,t,n){for(n=n.child;n!==null;)Pc(e,t,n),n=n.sibling}function Pc(e,t,n){if(It&&typeof It.onCommitFiberUnmount==`function`)try{It.onCommitFiberUnmount(Ft,n)}catch{}switch(n.tag){case 5:H||bc(n,t);case 6:var r=W,i=Mc;W=null,Nc(e,t,n),W=r,Mc=i,W!==null&&(Mc?(e=W,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):W.removeChild(n.stateNode));break;case 18:W!==null&&(Mc?(e=W,n=n.stateNode,e.nodeType===8?Hi(e.parentNode,n):e.nodeType===1&&Hi(e,n),wn(e)):Hi(W,n.stateNode));break;case 4:r=W,i=Mc,W=n.stateNode.containerInfo,Mc=!0,Nc(e,t,n),W=r,Mc=i;break;case 0:case 11:case 14:case 15:if(!H&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&xc(n,t,o),i=i.next}while(i!==r)}Nc(e,t,n);break;case 1:if(!H&&(bc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){$(n,t,e)}Nc(e,t,n);break;case 21:Nc(e,t,n);break;case 22:n.mode&1?(H=(r=H)||n.memoizedState!==null,Nc(e,t,n),H=r):Nc(e,t,n);break;default:Nc(e,t,n)}}function Fc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new yc),t.forEach(function(t){var r=Vl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function Ic(e,t){var n=t.deletions;if(n!==null)for(var i=0;ia&&(a=s),i&=~o}if(i=a,i=T()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*Wc(i/1960))-i,10e?16:e,cl===null)var i=!1;else{if(e=cl,cl=null,ll=0,G&6)throw Error(r(331));var a=G;for(G|=4,U=e.current;U!==null;){var o=U,s=o.child;if(U.flags&16){var c=o.deletions;if(c!==null){for(var l=0;lT()-tl?Tl(e,0):$c|=n),Q(e,t)}function zl(e,t){t===0&&(e.mode&1?(t=Ut,Ut<<=1,!(Ut&130023424)&&(Ut=4194304)):t=1);var n=Z();e=lo(e,t),e!==null&&(Zt(e,t,n),Q(e,n))}function Bl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),zl(e,n)}function Vl(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),zl(e,n)}var Hl=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||M.current)Us=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Us=!1,dc(e,t,n);Us=!!(e.flags&131072)}else Us=!1,P&&t.flags&1048576&&ka(t,Sa,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;lc(e,t),e=t.pendingProps;var a=sa(t,j.current);io(t,n),a=Bo(null,t,i,e,a,n);var o=Vo();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,N(i)?(o=!0,da(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,fo(t),a.updater=Os,t.stateNode=a,a._reactInternals=t,Ms(t,i,e,n),t=Zs(null,t,i,!0,o,n)):(t.tag=0,P&&o&&Aa(t),B(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(lc(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=ql(i),e=Es(i,e),a){case 0:t=Ys(null,t,i,e,n);break a;case 1:t=Xs(null,t,i,e,n);break a;case 11:t=Ws(null,t,i,e,n);break a;case 14:t=Gs(null,t,i,Es(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Es(i,a),Ys(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Es(i,a),Xs(e,t,i,a,n);case 3:a:{if(Qs(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,po(e,t),vo(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated)if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ns(Error(r(423)),t),t=$s(e,t,i,n,a);break a}else if(i!==a){a=Ns(Error(r(424)),t),t=$s(e,t,i,n,a);break a}else for(Na=Ui(t.stateNode.containerInfo.firstChild),Ma=t,P=!0,Pa=null,n=Xa(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ha(),i===a){t=uc(e,t,n);break a}B(e,t,i,n)}t=t.child}return t;case 5:return Do(t),e===null&&Ra(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,Ii(i,a)?s=null:o!==null&&Ii(i,o)&&(t.flags|=32),Js(e,t),B(e,t,s,n),t.child;case 6:return e===null&&Ra(t),null;case 13:return nc(e,t,n);case 4:return To(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Ya(t,null,i,n):B(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Es(i,a),Ws(e,t,i,a,n);case 7:return B(e,t,t.pendingProps,n),t.child;case 8:return B(e,t,t.pendingProps.children,n),t.child;case 12:return B(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,A(Za,i._currentValue),i._currentValue=s,o!==null)if(Hr(o.value,s)){if(o.children===a.children&&!M.current){t=uc(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=mo(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),ro(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),ro(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}B(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,io(t,n),a=ao(a),i=i(a),t.flags|=1,B(e,t,i,n),t.child;case 14:return i=t.type,a=Es(i,t.pendingProps),a=Es(i.type,a),Gs(e,t,i,a,n);case 15:return Ks(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Es(i,a),lc(e,t),t.tag=1,N(i)?(e=!0,da(t)):e=!1,io(t,n),As(t,i,a),Ms(t,i,a,n),Zs(null,t,i,!0,e,n);case 19:return cc(e,t,n);case 22:return qs(e,t,n)}throw Error(r(156,t.tag))};function Ul(e,t){return Tt(e,t)}function Wl(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.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 Gl(e,t,n,r){return new Wl(e,t,n,r)}function Kl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ql(e){if(typeof e==`function`)return+!!Kl(e);if(e!=null){if(e=e.$$typeof,e===oe)return 11;if(e===le)return 14}return 2}function Jl(e,t){var n=e.alternate;return n===null?(n=Gl(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Yl(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)Kl(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case te:return Xl(n.children,a,o,t);case ne:s=8,a|=8;break;case re:return e=Gl(12,n,t,a|2),e.elementType=re,e.lanes=o,e;case se:return e=Gl(13,n,t,a),e.elementType=se,e.lanes=o,e;case ce:return e=Gl(19,n,t,a),e.elementType=ce,e.lanes=o,e;case C:return Zl(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case ie:s=10;break a;case ae:s=9;break a;case oe:s=11;break a;case le:s=14;break a;case ue:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=Gl(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function Xl(e,t,n,r){return e=Gl(7,e,r,t),e.lanes=n,e}function Zl(e,t,n,r){return e=Gl(22,e,r,t),e.elementType=C,e.lanes=n,e.stateNode={isHidden:!1},e}function Ql(e,t,n){return e=Gl(6,e,null,t),e.lanes=n,e}function $l(e,t,n){return t=Gl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function eu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Xt(0),this.expirationTimes=Xt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function tu(e,t,n,r,i,a,o,s,c){return e=new eu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Gl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},fo(a),e}function nu(e,t,n){var r=3{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=require_react_dom_production_min()})),require_client=__commonJSMin((e=>{var t=require_react_dom();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),import_react=__toESM(require_react()),import_client=require_client(),TextAlign=function(e){return e[e.Left=0]=`Left`,e[e.Right=1]=`Right`,e[e.Center=2]=`Center`,e}({}),Border=class e{color;static from(t){let n=new e;return n.style=t.style,n.color=t.color,n}style=0;constructor(e=null){this.color=e}},Appearance=class e{get bold(){return!!(this.textStyle&&this.textStyle.indexOf(`bold`)!=-1)}set bold(e){this.ensureTextStyle(),this.bold!=e&&(e?this.textStyle=`${this.textStyle} bold`:this.textStyle=this.textStyle.replace(`bold`,``))}get italic(){return!!(this.textStyle&&this.textStyle.indexOf(`italic`)!=-1)}set italic(e){this.ensureTextStyle(),this.italic!=e&&(e?this.textStyle=`${this.textStyle} italic`:this.textStyle=this.textStyle.replace(`italic`,``))}get underline(){return!!(this.textStyle&&this.textStyle.indexOf(`underline`)!=-1)}set underline(e){this.ensureTextStyle(),!(this.italic==e||!this.textStyle)&&(e?this.textStyle=`${this.textStyle} underline`:this.textStyle=this.textStyle.replace(`underline`,``))}static from(t){let n=new e;return n.textAlign=t.textAlign,n.textStyle=t.textStyle,n.fontName=t.fontName,n.fontSize=t.fontSize,n.text=t.text,n.background=t.background,n.horizontalBorder=t.horizontalBorder&&Border.from(t.horizontalBorder),n.verticalBorder=t.verticalBorder&&Border.from(t.verticalBorder),n}textAlign=0;fontName=`Lato`;fontSize=12;textStyle;text;background;horizontalBorder;verticalBorder;alignTextTo(e){if(e.toLowerCase()==`right`)this.textAlign=1;else if(e.toLowerCase()==`center`)this.textAlign=2;else if(e.toLowerCase()==`left`)this.textAlign=0;else throw Error(`invalid text-align '${e}'`)}setHorizontal(e){this.horizontalBorder=new Border,this.horizontalBorder.style=0,this.horizontalBorder.color=e}setVertical(e){this.verticalBorder=new Border,this.verticalBorder.style=0,this.verticalBorder.color=e}ensureTextStyle(){this.textStyle||=``}};function saveDocument(e){if(!e)return;let t=document.createElement(`a`);t.download=`document.ows`,t.href=`data:application/octet-stream,`+encodeURIComponent(e.save()),t.target=`_blank`,t.click()}function loadDocument(e){if(!e)return;let t=document.createElement(`input`);t.accept=`.ows`,t.type=`file`,t.addEventListener(`change`,()=>readSelectedFile(t,e)),t.click()}function readSelectedFile(e,t){let n=e.files&&e.files[0];if(!n)return;let r=new FileReader;r.addEventListener(`load`,()=>t.load(r.result)),r.readAsText(n,`utf8`)}function FormulaBar(e){let[t,n]=import_react.useState(!1);return import_react.createElement(`div`,{className:t?`ows-formula-bar ows-formula-active`:`ows-formula-bar`},import_react.createElement(`input`,{className:`ows-cell-name`,readOnly:!0,value:e.label}),import_react.createElement(`div`,{className:`ows-formula-actions`},import_react.createElement(`button`,{onClick:e.onAbort,title:`Cancel`,type:`button`},`x`),import_react.createElement(`button`,{onClick:e.onCommit,title:`Apply`,type:`button`},`✓`),import_react.createElement(`strong`,null,`fx`)),import_react.createElement(`input`,{className:`ows-formula-input`,onBlur:()=>n(!1),onChange:t=>e.onValueChange(t.target.value),onFocus:()=>n(!0),value:e.value||``}))}function ControlGroup(e){return import_react.createElement(`section`,{className:e.wide?`ows-control-group ows-control-group-wide`:`ows-control-group`},import_react.createElement(`div`,{className:`ows-control-label`},e.label),import_react.createElement(`div`,{className:`ows-control-content`},e.children))}function AboutRibbon(){return import_react.createElement(`div`,{className:`ows-ribbon-panel`},import_react.createElement(ControlGroup,{label:`OSI`},import_react.createElement(`i`,{className:`fab fa-osi ows-large-icon`,title:`Open Source Initiative`})),import_react.createElement(ControlGroup,{label:`About Open Web Sheet Project`,wide:!0},import_react.createElement(`div`,{className:`ows-about`},import_react.createElement(`strong`,null,`Open Web Sheet Project`),import_react.createElement(`span`,null,`Designed and developed by Siamand`),import_react.createElement(`span`,null,`3rd Parties: FontAwesome Icons & Google noto web font`),import_react.createElement(`span`,null,`MIT Licence`),import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(`a`,{href:`https://siamand.cc`},`Developer Site`),import_react.createElement(`a`,{href:`https://github.com/code-by-sia/OpenWebSheet`},`Source Code`)))))}function Button(e){let t=e.active?`ows-button ows-button-active`:`ows-button`;return import_react.createElement(`button`,{className:t,onClick:e.onClick,title:e.title||e.label,type:`button`},e.icon&&import_react.createElement(`i`,{className:e.icon}),e.children)}function ImportExportGroup({label:e}){return import_react.createElement(ControlGroup,{label:e,wide:!0},import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(Button,{title:`${e} import`},`Import`),import_react.createElement(Button,{title:`${e} export`},`Export`)))}function DataRibbon(){return import_react.createElement(`div`,{className:`ows-ribbon-panel`},import_react.createElement(ControlGroup,{label:`File`},import_react.createElement(`i`,{className:`fa fa-file-excel ows-large-icon`,title:`Spreadsheet file`})),import_react.createElement(ImportExportGroup,{label:`Open Office`}),import_react.createElement(ImportExportGroup,{label:`MS Excel`}),import_react.createElement(ControlGroup,{label:`3rd Parties`,wide:!0},import_react.createElement(`span`,{className:`ows-muted`},`External data sources`)))}function FormulaFunctionGroup(e){return import_react.createElement(ControlGroup,{label:e.label,wide:!0},import_react.createElement(`div`,{className:`ows-formula-tools`},e.functions.map(t=>import_react.createElement(Button,{icon:t.icon,key:t.label,onClick:()=>e.onAction({actionName:`formula-template`,args:t.template}),title:`Insert ${t.label}`},t.label))))}var statistics=[{icon:`fa fa-plus`,label:`SUM`,template:`=SUM(`},{icon:`fa fa-arrow-down`,label:`MIN`,template:`=MIN(`},{icon:`fa fa-arrow-up`,label:`MAX`,template:`=MAX(`}],mathematical=[{icon:`fa fa-square-root-alt`,label:`SQRT`,template:`=SQRT(`},{icon:`fa fa-plus-circle`,label:`ABS`,template:`=ABS(`},{icon:`fa fa-chart-line`,label:`LOG`,template:`=LOG(`},{icon:`fa fa-superscript`,label:`EXP`,template:`=EXP(`}],trigonometry=[{icon:`fa fa-wave-square`,label:`SIN`,template:`=SIN(`},{icon:`fa fa-wave-square`,label:`COS`,template:`=COS(`},{icon:`fa fa-wave-square`,label:`TAN`,template:`=TAN(`}],constants=[{icon:`fa fa-circle-notch`,label:`PI`,template:`=PI`},{icon:`fa fa-italic`,label:`E`,template:`=E`}];function FormulaRibbon(e){return import_react.createElement(`div`,{className:`ows-ribbon-panel`},import_react.createElement(FormulaFunctionGroup,{functions:statistics,label:`Statistics`,onAction:e.onAction}),import_react.createElement(FormulaFunctionGroup,{functions:mathematical,label:`Mathematical`,onAction:e.onAction}),import_react.createElement(FormulaFunctionGroup,{functions:trigonometry,label:`Trigonometry`,onAction:e.onAction}),import_react.createElement(FormulaFunctionGroup,{functions:constants,label:`Constants`,onAction:e.onAction}),import_react.createElement(ControlGroup,{label:`User Defined Functions`,wide:!0},import_react.createElement(`span`,{className:`ows-muted`},`Custom functions are planned`)))}function CellControls(e){let t=(t,n)=>e.onAction({actionName:t,args:n});return import_react.createElement(ControlGroup,{label:`Cell`},import_react.createElement(Button,{active:e.state.isMerged,icon:`fa fa-th`,onClick:()=>t(e.state.isMerged?`unmerge`:`merge`)},e.state.isMerged?`Split`:`Merge`))}function DocumentControls(e){let t=t=>e.onAction({actionName:t});return e.fileMode===`local`?import_react.createElement(ControlGroup,{label:`Local Storage`},import_react.createElement(Button,{icon:`far fa-times-circle`,onClick:()=>e.onModeChanged(`file`)},`File mode`)):import_react.createElement(ControlGroup,{label:`Document`},import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(Button,{icon:`fas fa-save`,onClick:()=>t(`save-ows`),title:`Save`}),import_react.createElement(Button,{icon:`fas fa-folder`,onClick:()=>t(`load-ows`),title:`Load`}),import_react.createElement(Button,{icon:`fas fa-warehouse`,onClick:()=>e.onModeChanged(`local`),title:`Local storage`})))}function Field(e){return import_react.createElement(`label`,{className:`ows-field`},e.label&&import_react.createElement(`span`,null,e.label),e.children)}var fonts=[`Arial`,`Tahoma`,`Times New Roman`,`Courier New`],sizes=[8,9,10,11,12,14,16,18,24];function FontControls(e){let t=(t,n)=>e.onAction({actionName:t,args:n});return import_react.createElement(ControlGroup,{label:`Font`},import_react.createElement(`div`,{className:`ows-stack`},import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(Field,null,import_react.createElement(`select`,{onChange:e=>t(`font-name`,e.target.value),value:e.appearance.fontName},fonts.map(e=>import_react.createElement(`option`,{key:e},e)))),import_react.createElement(Field,null,import_react.createElement(`select`,{onChange:e=>t(`font-size`,Number(e.target.value)),value:e.appearance.fontSize},sizes.map(e=>import_react.createElement(`option`,{key:e},e))))),import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(Button,{active:e.appearance.bold,icon:`fa fa-bold`,onClick:()=>t(`bold`)}),import_react.createElement(Button,{active:e.appearance.italic,icon:`fa fa-italic`,onClick:()=>t(`italic`)}),import_react.createElement(Button,{active:e.appearance.underline,icon:`fa fa-underline`,onClick:()=>t(`underline`)}))))}var alignments=[{icon:`fa fa-align-left`,label:`Align left`,value:`left`,textAlign:TextAlign.Left},{icon:`fa fa-align-center`,label:`Align center`,value:`center`,textAlign:TextAlign.Center},{icon:`fa fa-align-right`,label:`Align right`,value:`right`,textAlign:TextAlign.Right}];function FormatControls(e){let t=(t,n)=>e.onAction({actionName:t,args:n});return import_react.createElement(ControlGroup,{label:`Format`},import_react.createElement(`div`,{className:`ows-stack`},import_react.createElement(`div`,{className:`ows-button-row`},import_react.createElement(Field,{label:`Text`},import_react.createElement(`input`,{onChange:e=>t(`fg-color`,e.target.value),type:`color`,value:e.appearance.text})),import_react.createElement(Field,{label:`Fill`},import_react.createElement(`input`,{onChange:e=>t(`bg-color`,e.target.value),type:`color`,value:e.appearance.background}))),import_react.createElement(`div`,{className:`ows-button-row`},alignments.map(n=>import_react.createElement(AlignButton,{action:t,alignment:n,appearance:e.appearance,key:n.value})))))}function AlignButton({action:e,alignment:t,appearance:n}){return import_react.createElement(Button,{active:n.textAlign===t.textAlign,icon:t.icon,onClick:()=>e(`align`,t.value),title:t.label})}var borders=[[`full-border`,`all`,`All borders`],[`cross-border`,`inside`,`Inside borders`],[`horizontal-border`,`horizontal`,`Horizontal borders`],[`vertical-border`,`vertical`,`Vertical borders`],[`outside-border`,`outside`,`Outside borders`],[`left-border`,`left`,`Left border`],[`top-border`,`top`,`Top border`],[`right-border`,`right`,`Right border`],[`bottom-border`,`bottom`,`Bottom border`],[`no-border`,`none`,`No border`]];function BorderControls(e){let[t,n]=import_react.useState(`#000000`),r=n=>e.onAction({actionName:n,args:t});return import_react.createElement(ControlGroup,{label:`Borders`},import_react.createElement(`div`,{className:`ows-stack`},import_react.createElement(Field,{label:`Color`},import_react.createElement(`input`,{onChange:e=>n(e.target.value),type:`color`,value:t})),import_react.createElement(`div`,{className:`ows-border-grid`},borders.map(([e,t,n])=>import_react.createElement(BorderButton,{key:e,label:n,onClick:()=>r(e),variant:t})))))}function BorderButton({label:e,onClick:t,variant:n}){return import_react.createElement(`button`,{className:`ows-border-tile ows-border-${n}`,onClick:t,title:e,type:`button`},import_react.createElement(`span`),import_react.createElement(`span`),import_react.createElement(`span`),import_react.createElement(`span`))}function HomeRibbon(e){return import_react.createElement(`div`,{className:`ows-ribbon-panel`},import_react.createElement(DocumentControls,{fileMode:e.fileMode,onAction:e.onAction,onModeChanged:e.onModeChanged}),import_react.createElement(FontControls,{appearance:e.appearance,onAction:e.onAction}),import_react.createElement(FormatControls,{appearance:e.appearance,onAction:e.onAction}),import_react.createElement(CellControls,{onAction:e.onAction,state:e.state}),import_react.createElement(BorderControls,{onAction:e.onAction}))}var layoutModes=[{id:`normal`,icon:`fa fa-table`,label:`Normal`},{id:`page-layout`,icon:`far fa-file-alt`,label:`Page layout`},{id:`page-break`,icon:`fa fa-columns`,label:`Page break`}],displayOptions=[{id:`gridlines`,icon:`fa fa-th`,label:`Gridlines`},{id:`headings`,icon:`fa fa-heading`,label:`Headings`},{id:`formula-bar`,icon:`fa fa-equals`,label:`Formula bar`}];function LayoutControls(){let[e,t]=import_react.useState(`normal`),[n,r]=import_react.useState(()=>new Set(displayOptions.map(e=>e.id))),i=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)};return import_react.createElement(ControlGroup,{label:`Layout`,wide:!0},import_react.createElement(`div`,{className:`ows-layout-controls`},import_react.createElement(`div`,{className:`ows-button-row`},layoutModes.map(n=>import_react.createElement(Button,{active:e===n.id,icon:n.icon,key:n.id,onClick:()=>t(n.id),title:n.label},n.label))),import_react.createElement(`div`,{className:`ows-button-row`},displayOptions.map(e=>import_react.createElement(Button,{active:n.has(e.id),icon:e.icon,key:e.id,onClick:()=>i(e.id),title:e.label},e.label)))))}function PrintControls(){return import_react.createElement(ControlGroup,{label:`Print`},import_react.createElement(Button,{icon:`fa fa-print`,onClick:()=>window.print(),title:`Print sheet`}))}function ViewRibbon(){return import_react.createElement(`div`,{className:`ows-ribbon-panel`},import_react.createElement(PrintControls),import_react.createElement(LayoutControls))}var canUseDOM=!!(typeof window<`u`&&window.document&&window.document.createElement);function composeEventHandlers(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var require_react_jsx_runtime_production_min=__commonJSMin((e=>{var t=require_react(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.jsx=s})),require_jsx_runtime=__commonJSMin(((e,t)=>{t.exports=require_react_jsx_runtime_production_min()})),import_jsx_runtime=require_jsx_runtime();function createContextScope(e,t=[]){let n=[];function r(t,r){let i=import_react.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=import_react.useMemo(()=>o,Object.values(o));return(0,import_jsx_runtime.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=import_react.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>import_react.createContext(e));return function(n){let r=n?.[e]||t;return import_react.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,composeContextScopes(i,...t)]}function composeContextScopes(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return import_react.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function setRef(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function composeRefs(...e){return t=>{let n=!1,r=e.map(e=>{let r=setRef(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t{let{children:r,...i}=e,a=import_react.Children.toArray(r),o=a.find(isSlottable);if(o){let e=o.props.children,r=a.map(t=>t===o?import_react.Children.count(e)>1?import_react.Children.only(null):import_react.isValidElement(e)?e.props.children:null:t);return(0,import_jsx_runtime.jsx)(t,{...i,ref:n,children:import_react.isValidElement(e)?import_react.cloneElement(e,void 0,r):null})}return(0,import_jsx_runtime.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function createSlotClone(e){let t=import_react.forwardRef((e,t)=>{let{children:n,...r}=e;if(import_react.isValidElement(n)){let e=getElementRef$1(n),i=mergeProps(r,n.props);return n.type!==import_react.Fragment&&(i.ref=t?composeRefs(t,e):e),import_react.cloneElement(n,i)}return import_react.Children.count(n)>1?import_react.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var SLOTTABLE_IDENTIFIER=Symbol(`radix.slottable`);function isSlottable(e){return import_react.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===SLOTTABLE_IDENTIFIER}function mergeProps(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function getElementRef$1(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function createCollection(e){let t=e+`CollectionProvider`,[n,r]=createContextScope(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=import_react.useRef(null),a=import_react.useRef(new Map).current;return(0,import_jsx_runtime.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=createSlot(s),l=import_react.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,import_jsx_runtime.jsx)(c,{ref:useComposedRefs(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=createSlot(u),p=import_react.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=import_react.useRef(null),s=useComposedRefs(t,o),c=a(u,n);return import_react.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,import_jsx_runtime.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return import_react.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var useLayoutEffect2=globalThis?.document?import_react.useLayoutEffect:()=>{},useReactId=import_react.useId||(()=>void 0),count=0;function useId(e){let[t,n]=import_react.useState(useReactId());return useLayoutEffect2(()=>{e||n(e=>e??String(count++))},[e]),e||(t?`radix-${t}`:``)}var import_react_dom=__toESM(require_react_dom(),1),Primitive=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=createSlot(`Primitive.${t}`),r=import_react.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,import_jsx_runtime.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function useCallbackRef(e){let t=import_react.useRef(e);return import_react.useEffect(()=>{t.current=e}),import_react.useMemo(()=>(...e)=>t.current?.(...e),[])}var useInsertionEffect=import_react.useInsertionEffect||useLayoutEffect2;function useControllableState({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=useUncontrolledState({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=import_react.useRef(e!==void 0);import_react.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,import_react.useCallback(t=>{if(s){let n=isFunction(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function useUncontrolledState({defaultProp:e,onChange:t}){let[n,r]=import_react.useState(e),i=import_react.useRef(n),a=import_react.useRef(t);return useInsertionEffect(()=>{a.current=t},[t]),import_react.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function isFunction(e){return typeof e==`function`}var DirectionContext=import_react.createContext(void 0);function useDirection(e){let t=import_react.useContext(DirectionContext);return e||t||`ltr`}var ENTRY_FOCUS=`rovingFocusGroup.onEntryFocus`,EVENT_OPTIONS={bubbles:!1,cancelable:!0},GROUP_NAME=`RovingFocusGroup`,[Collection,useCollection,createCollectionScope]=createCollection(GROUP_NAME),[createRovingFocusGroupContext,createRovingFocusGroupScope]=createContextScope(GROUP_NAME,[createCollectionScope]),[RovingFocusProvider,useRovingFocusContext]=createRovingFocusGroupContext(GROUP_NAME),RovingFocusGroup=import_react.forwardRef((e,t)=>(0,import_jsx_runtime.jsx)(Collection.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,import_jsx_runtime.jsx)(Collection.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,import_jsx_runtime.jsx)(RovingFocusGroupImpl,{...e,ref:t})})}));RovingFocusGroup.displayName=GROUP_NAME;var RovingFocusGroupImpl=import_react.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=import_react.useRef(null),p=useComposedRefs(t,f),m=useDirection(a),[h,g]=useControllableState({prop:o,defaultProp:s??null,onChange:c,caller:GROUP_NAME}),[_,v]=import_react.useState(!1),y=useCallbackRef(l),b=useCollection(n),x=import_react.useRef(!1),[ee,S]=import_react.useState(0);return import_react.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(ENTRY_FOCUS,y),()=>e.removeEventListener(ENTRY_FOCUS,y)},[y]),(0,import_jsx_runtime.jsx)(RovingFocusProvider,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:import_react.useCallback(e=>g(e),[g]),onItemShiftTab:import_react.useCallback(()=>v(!0),[]),onFocusableItemAdd:import_react.useCallback(()=>S(e=>e+1),[]),onFocusableItemRemove:import_react.useCallback(()=>S(e=>e-1),[]),children:(0,import_jsx_runtime.jsx)(Primitive.div,{tabIndex:_||ee===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:composeEventHandlers(e.onMouseDown,()=>{x.current=!0}),onFocus:composeEventHandlers(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(ENTRY_FOCUS,EVENT_OPTIONS);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);focusFirst([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:composeEventHandlers(e.onBlur,()=>v(!1))})})}),ITEM_NAME=`RovingFocusGroupItem`,RovingFocusGroupItem=import_react.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=useId(),l=a||c,u=useRovingFocusContext(ITEM_NAME,n),d=u.currentTabStopId===l,f=useCollection(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return import_react.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,import_jsx_runtime.jsx)(Collection.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,import_jsx_runtime.jsx)(Primitive.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:composeEventHandlers(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:composeEventHandlers(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:composeEventHandlers(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=getFocusIntent(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?wrapArray(n,r+1):n.slice(r+1)}setTimeout(()=>focusFirst(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});RovingFocusGroupItem.displayName=ITEM_NAME;var MAP_KEY_TO_FOCUS_INTENT={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function getDirectionAwareKey(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function getFocusIntent(e,t,n){let r=getDirectionAwareKey(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return MAP_KEY_TO_FOCUS_INTENT[r]}function focusFirst(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function wrapArray(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Root=RovingFocusGroup,Item=RovingFocusGroupItem;function useStateMachine(e,t){return import_react.useReducer((e,n)=>t[e][n]??e,e)}var Presence=e=>{let{present:t,children:n}=e,r=usePresence(t),i=typeof n==`function`?n({present:r.isPresent}):import_react.Children.only(n),a=useComposedRefs(r.ref,getElementRef(i));return typeof n==`function`||r.isPresent?import_react.cloneElement(i,{ref:a}):null};Presence.displayName=`Presence`;function usePresence(e){let[t,n]=import_react.useState(),r=import_react.useRef(null),i=import_react.useRef(e),a=import_react.useRef(`none`),[o,s]=useStateMachine(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return import_react.useEffect(()=>{let e=getAnimationName(r.current);a.current=o===`mounted`?e:`none`},[o]),useLayoutEffect2(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=getAnimationName(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),useLayoutEffect2(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=getAnimationName(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=getAnimationName(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:import_react.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function getAnimationName(e){return e?.animationName||`none`}function getElementRef(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var TABS_NAME=`Tabs`,[createTabsContext,createTabsScope]=createContextScope(TABS_NAME,[createRovingFocusGroupScope]),useRovingFocusGroupScope=createRovingFocusGroupScope(),[TabsProvider,useTabsContext]=createTabsContext(TABS_NAME),Tabs$1=import_react.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=useDirection(s),[d,f]=useControllableState({prop:r,onChange:i,defaultProp:a??``,caller:TABS_NAME});return(0,import_jsx_runtime.jsx)(TabsProvider,{scope:n,baseId:useId(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,import_jsx_runtime.jsx)(Primitive.div,{dir:u,"data-orientation":o,...l,ref:t})})});Tabs$1.displayName=TABS_NAME;var TAB_LIST_NAME=`TabsList`,TabsList$1=import_react.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=useTabsContext(TAB_LIST_NAME,n),o=useRovingFocusGroupScope(n);return(0,import_jsx_runtime.jsx)(Root,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,import_jsx_runtime.jsx)(Primitive.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});TabsList$1.displayName=TAB_LIST_NAME;var TRIGGER_NAME=`TabsTrigger`,TabsTrigger$1=import_react.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=useTabsContext(TRIGGER_NAME,n),s=useRovingFocusGroupScope(n),c=makeTriggerId(o.baseId,r),l=makeContentId(o.baseId,r),u=r===o.value;return(0,import_jsx_runtime.jsx)(Item,{asChild:!0,...s,focusable:!i,active:u,children:(0,import_jsx_runtime.jsx)(Primitive.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:composeEventHandlers(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:composeEventHandlers(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:composeEventHandlers(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});TabsTrigger$1.displayName=TRIGGER_NAME;var CONTENT_NAME=`TabsContent`,TabsContent$1=import_react.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=useTabsContext(CONTENT_NAME,n),c=makeTriggerId(s.baseId,r),l=makeContentId(s.baseId,r),u=r===s.value,d=import_react.useRef(u);return import_react.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,import_jsx_runtime.jsx)(Presence,{present:i||u,children:({present:n})=>(0,import_jsx_runtime.jsx)(Primitive.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});TabsContent$1.displayName=CONTENT_NAME;function makeTriggerId(e,t){return`${e}-trigger-${t}`}function makeContentId(e,t){return`${e}-content-${t}`}var Root2=Tabs$1,List=TabsList$1,Trigger=TabsTrigger$1,Content=TabsContent$1;function Tabs(e){return import_react.createElement(Root2,{className:`ows-tabs`,defaultValue:e.defaultValue},e.children)}function TabsList(e){return import_react.createElement(List,{className:`ows-tabs-list`},e.children)}function TabsTrigger(e){return import_react.createElement(Trigger,{className:`ows-tabs-trigger`,value:e.value},e.children)}function TabsContent(e){return import_react.createElement(Content,{className:`ows-tabs-content`,value:e.value},e.children)}var tabs=[{id:`home`,icon:`fa fa-home`,label:`Home`},{id:`formulas`,icon:`fa fa-square-root-alt`,label:`Formulas`},{id:`data`,icon:`fa fa-database`,label:`Data`},{id:`view`,icon:`fa fa-eye`,label:`View`},{id:`about`,icon:`fa fa-info-circle`,label:`About`}];function RibbonMenu(e){return import_react.createElement(`header`,{className:`ows-ribbon`},import_react.createElement(Tabs,{defaultValue:`home`},import_react.createElement(TabsList,null,tabs.map(e=>import_react.createElement(TabsTrigger,{key:e.id,value:e.id},import_react.createElement(`span`,{className:`ows-tab-label`},import_react.createElement(`i`,{className:e.icon}),e.label)))),import_react.createElement(TabsContent,{value:`home`},import_react.createElement(HomeRibbon,e)),import_react.createElement(TabsContent,{value:`formulas`},import_react.createElement(FormulaRibbon,{onAction:e.onAction})),import_react.createElement(TabsContent,{value:`data`},import_react.createElement(DataRibbon)),import_react.createElement(TabsContent,{value:`view`},import_react.createElement(ViewRibbon)),import_react.createElement(TabsContent,{value:`about`},import_react.createElement(AboutRibbon))))}var Cell=class e{get isMerged(){return this.reference!==null}get columnId(){return this._columnId}get rowId(){return this._rowId}get label(){return this.formattedValue}get value(){return this._value}set value(e){this.update(e,e)}get top(){return this.isMerged&&this.reference?this.reference.top:this.rowId}get left(){return this.isMerged&&this.reference?this.reference.left:this.columnId}get bottom(){return this.isMerged&&this.reference?this.reference.bottom:this.rowId+this.rowSpan}get right(){return this.isMerged&&this.reference?this.reference.right:this.columnId+this.colSpan}static from(t){let n=new e(t.columnId,t.rowId);return n.colSpan=t.colSpan,n.rowSpan=t.rowSpan,n.formattedValue=t.formattedValue,n.evaluatedValue=t.evaluatedValue,n._columnId=t._columnId,n._rowId=t._rowId,n._value=t._value,n.reference=t.reference&&this.from(t.reference),n}colSpan=1;rowSpan=1;reference=null;formattedValue;evaluatedValue;_columnId;_rowId;_value=null;constructor(e,t){this._columnId=e,this._rowId=t}update(e,t){this._value=e,this.evaluatedValue=t,this.format()}to(){return{colSpan:this.colSpan,rowSpan:this.rowSpan,formattedValue:this.formattedValue,evaluatedValue:this.evaluatedValue,_columnId:this._columnId,_rowId:this._rowId,_value:this._value,reference:this.reference&&this.reference.to()}}format(){this.formattedValue=this.evaluatedValue}},COLOR_LIGHT=`#fff`,COLOR_1=`#00897b`,COLOR_2=`#00796b`,COLOR_3=`#00454d`,Env=class{ranges;dataProvider;constructor(e,t){this.ranges=e,this.dataProvider=t}Eval(txt){const _M_E_=this,_R_A_N_G_E_=this.ranges,PI=Math.PI,E=Math.E;function SUM(e){return _M_E_.data(e).reduce((e,t)=>e*1+t*1,0)}function MIN(e){return _M_E_.data(e).reduce((e,t)=>Math.min(e*1,t*1),0)}function MAX(e){return _M_E_.data(e).reduce((e,t)=>Math.max(e*1,t*1),0)}function SIN(e){return Math.sin(e)}function COS(e){return Math.cos(e)}function TAN(e){return Math.tan(e)}function ASIN(e){return Math.asin(e)}function ACOS(e){return Math.acos(e)}function ATAN(e){return Math.atan(e)}function ASINH(e){return Math.asinh(e)}function ACOSH(e){return Math.acosh(e)}function ATANH(e){return Math.atanh(e)}function ABS(e){return Math.abs(e)}function SQRT(e){return Math.sqrt(e)}function CBRT(e){return Math.cbrt(e)}function LOG(e){return Math.log(e)}function EXP(e){return Math.exp(e)}function TRUNC(e){return Math.trunc(e)}function CEIL(e){return Math.ceil(e)}function FLOOR(e){return Math.floor(e)}return eval(txt)}data(e){return this.dataProvider.getEvaluatedValue(e)}},Evaluator=class{static Eval(e,t){if(t.length<1||t[0]!=`=`)return t;let n,r=this.valueRegex,i=t,a=[],o=0;for(;(n=r.exec(t))!==null;)n.index===r.lastIndex&&r.lastIndex++,n.forEach((t,n)=>{if(t&&t.indexOf(`:`)!=-1)a.push(t),i=i.replace(t+``,`_R_A_N_G_E_[${o++}]`);else if(n==0){let n=e.getEvaluatedValue(t);i=i.replace(t,n)}});try{return new Env(a,e).Eval(i.substr(1))}catch{return`#ERR`}}static valueRegex=/(([a-zA-Z]+[0-9])+\:?([a-zA-Z]+[0-9]+)?)/g},CellSelection=class{left=0;top=0;right=0;bottom=0;rowId=0;columnId=0;get single(){return this.right==this.left&&this.top==this.bottom}toString(){return`${this.top} ${this.left} - ${this.bottom} ${this.right}`}},Sheet=class e{title;get SelectionLabel(){return this.getCellName(this.selection.columnId,this.selection.rowId)}get SelectedValue(){return this.selectedCell&&this.selectedCell.value}get SelectedAppearance(){return this.getAppearance(this.selection.columnId,this.selection.rowId)}get selectedCell(){return this.getCell(this.selection.columnId,this.selection.rowId)}get invalidSelection(){return this.selectedCell&&this.selectedCell.isMerged}get scrollColumn(){return this.scrollX}get scrollRow(){return this.scrollY}static get_columnName(e){let t=`ABCDEFGHIJKLMNOPQRSTUVWXYZ`,n=``,r=e+1;for(;r>0;){let e=(r-1)%26;n=`ABCDEFGHIJKLMNOPQRSTUVWXYZ`[e]+n,r=(r-(e+1))/26}return n}static load(t){let n=new e(t.title);return n.fill(t.data),n.style(t.appearance),n.columnAppearance=t.columnAppearance,n.rowAppearance=t.rowAppearance,n.columnWidth=t.columnWidth,n.rowHeight=t.rowHeight,n.scrollX=t.scrollX,n.scrollY=t.scrollY,n.selection=t.selection,n}defaultAppearance=new Appearance;defaultRowHeight=30;defaultColumnWidth=100;selection;data=[];appearance=[];columnAppearance=[];rowAppearance=[];rowHeight=[];columnWidth=[];scrollX=0;scrollY=0;change_listeners=[];constructor(e){this.title=e,this.defaultAppearance.background=null,this.defaultAppearance.fontName=`Lato`,this.defaultAppearance.fontSize=12,this.defaultAppearance.horizontalBorder=null,this.defaultAppearance.verticalBorder=null,this.defaultAppearance.text=`#333333`,this.selection=new CellSelection,this.selection.top=0,this.selection.left=0,this.selection.right=0,this.selection.bottom=0,this.selection.rowId=0,this.selection.columnId=0}selectNextColumnCell(){if(this.selection.columnId++,this.selection.single){this.selection.right=this.selection.columnId,this.selection.left=this.selection.columnId,this.onChange();return}this.selection.columnId>this.selection.right&&(this.selection.columnId=this.selection.left,this.selection.rowId==this.selection.bottom?this.selection.rowId=this.selection.top:this.selectNextRowCell()),this.invalidSelection&&this.selectNextColumnCell(),this.onChange()}selectPreviousColumnCell(){if(this.selection.columnId!=0){if(this.selection.columnId--,this.selection.single){this.selection.right=this.selection.columnId,this.selection.left=this.selection.columnId,this.onChange();return}this.selection.columnIdthis.selection.bottom&&(this.selection.rowId=this.selection.top,this.selection.columnId==this.selection.right?this.selection.columnId=this.selection.left:this.selectNextColumnCell()),this.invalidSelection&&this.selectNextRowCell(),this.onChange()}selectPreviousRowCell(){if(this.selection.rowId!=0){if(this.selection.rowId--,this.selection.single){this.selection.top=this.selection.rowId,this.selection.bottom=this.selection.rowId,this.onChange();return}this.selection.rowIdthis.scrollColumn+100)return 0;let r=this.getColumnWidth(n);if(e>t&&e=0&&this.change_listeners.splice(t,1)}getWidth(e){return 110}save(){return{title:this.title,data:this.data,appearance:this.appearance,columnAppearance:this.columnAppearance,rowAppearance:this.rowAppearance,rowHeight:this.rowHeight,columnWidth:this.columnWidth,scrollX:this.scrollX,scrollY:this.scrollY,selection:this.selection}}getCellName(t,n){return`${e.get_columnName(t)}${n+1}`}getCellPos(e){let t=/([a-zA-z]+)([0-9]+)/g;if(!/([a-zA-z]+)([0-9]+)/g.test(e))throw Error(`invalid cell name `+e);let n=t.exec(e),r=this.getColumnIndex(n[1]);return{rowId:parseInt(n[2])-1,columnId:r}}getColumnIndex(e){let t=0,n=1,r=65;for(let i=e.length-1;i>=0;i--){let a=e.charCodeAt(i)-r;t+=a*n,n*=26,r=64}return t}getCellEvaluatedValue(e,t){let n=this.getCell(e,t);return n==null?null:Evaluator.Eval(this,n.value)}updateDependees(e,t){for(let e of this.data)if(e)for(let t of e)!t||!t.value||t.value.length&&t.value[0]==`=`&&this.setCellValue(t.columnId,t.rowId,t.value,!0)}onChange(){this.change_listeners.forEach(e=>e())}fill(e){this.data=[];for(let t of e)if(t)for(let e of t){if(!e)continue;let t=Cell.from(e);this.setCell(t.columnId,t.rowId,t,!0)}}style(e){if(this.appearance=[],e){for(let t of e)if(t)for(let n of t){if(!n)continue;let r=Appearance.from(n),i=e.indexOf(t),a=t.indexOf(n);this.setCellAppearance(i,a,r,!0)}}}};function clone(e){return JSON.parse(JSON.stringify(e))}var Commander=class{doc;get ActiveSheet(){return this.doc.ActiveSheet}get Selection(){return this.ActiveSheet.selection}get SelectedAppearance(){let e=this.Selection,t=this.doc.ActiveSheet,n=[];for(let r=e.top;r<=e.bottom;r++)for(let r=e.left;r<=e.right;r++){let r=t.getCellAppearance(e.columnId,e.rowId);r&&n.push(clone(r))}return n}get SelectionData(){let e=this.Selection,t=this.doc.ActiveSheet,n=[];for(let r=e.left;r<=e.right;r++)for(let i=e.top;i<=e.bottom;i++){let e=t.getCell(r,i);n.push(clone(e))}return n}history=[];commands={};constructor(e){this.doc=e,this.commands.bold=()=>this.appearance(e=>e.bold=!e.bold),this.commands.italic=()=>this.appearance(e=>e.italic=!e.italic),this.commands.underline=()=>this.appearance(e=>e.underline=!e.underline),this.commands[`font-size`]=e=>this.appearance(t=>t.fontSize=e),this.commands[`font-name`]=e=>this.appearance(t=>t.fontName=e),this.commands[`bg-color`]=e=>this.appearance(t=>t.background=e),this.commands[`fg-color`]=e=>this.appearance(t=>t.text=e),this.commands[`top-border`]=e=>this.topBorder(e),this.commands[`no-border`]=()=>this.noBorder(),this.commands[`left-border`]=e=>this.leftBorder(e),this.commands[`right-border`]=e=>this.rightBorder(e),this.commands[`bottom-border`]=e=>this.bottomBorder(e),this.commands[`outside-border`]=e=>this.outsideBorder(e),this.commands[`horizontal-border`]=e=>this.horizontalBorder(e),this.commands[`vertical-border`]=e=>this.verticalBorder(e),this.commands[`cross-border`]=e=>this.crossBorder(e),this.commands[`full-border`]=e=>{this.topBorder(e,!1),this.leftBorder(e,!1),this.bottomBorder(e,!1),this.rightBorder(e,!1),this.appearance(t=>{t.setVertical(e),t.setHorizontal(e)})},this.commands.merge=()=>this.merge(),this.commands.unmerge=()=>this.unmerge(),this.commands.align=e=>this.appearance(t=>t.alignTextTo(e)),this.commands[`change-value`]=(e,t,n)=>this.changeValue(e,t,n),this.commands[`alter-column`]=(e,t)=>this.alterColumn(e,t),this.commands[`alter-row`]=(e,t)=>this.alterRow(e,t)}do(e,...t){this.has(e)||console.warn(`command ${e} does not exsits!`),this.commands[e](...t)}undo(){throw Error(`undo has not been implemented`)}redo(){throw Error(`redo has not been implemented`)}has(e){return!!this.commands[e]}outsideBorder(e){this.logAppearanceOnlyCommand(),this.topBorder(e,!1),this.rightBorder(e,!1),this.bottomBorder(e,!1),this.leftBorder(e,!1)}horizontalBorder(e){this.crossBorder(e,!0,!1)}verticalBorder(e){this.crossBorder(e,!1,!0)}crossBorder(e,t=!0,n=!0){this.logAppearanceOnlyCommand();let r=this.Selection;this.doc.ActiveSheet;for(let i=r.left;i<=r.right;i++)for(let a=r.top;a<=r.bottom;a++){let o=this.ActiveSheet.getCellAppearance(i,a)||new Appearance;t&&a{e.setVertical(null),e.setHorizontal(null)})}topBorder(e,t=!0){t&&this.logAppearanceOnlyCommand();let n=this.Selection;this.doc.ActiveSheet;let r=n.top-1;for(let t=n.left;t<=n.right;t++){let n=this.ActiveSheet.getCellAppearance(t,r)||new Appearance;n.setHorizontal(e),this.ActiveSheet.setCellAppearance(t,r,n,!1)}}leftBorder(e,t=!0){t&&this.logAppearanceOnlyCommand();let n=this.Selection;this.doc.ActiveSheet;let r=n.left-1;for(let t=n.top;t<=n.bottom;t++){let n=this.ActiveSheet.getCellAppearance(r,t)||new Appearance;n.setVertical(e),this.ActiveSheet.setCellAppearance(r,t,n,!1)}}rightBorder(e,t=!0){t&&this.logAppearanceOnlyCommand();let n=this.Selection;this.doc.ActiveSheet;let r=n.right;for(let t=n.top;t<=n.bottom;t++){let n=this.ActiveSheet.getCellAppearance(r,t)||new Appearance;n.setVertical(e),this.ActiveSheet.setCellAppearance(r,t,n,!1)}}bottomBorder(e,t=!0){t&&this.logAppearanceOnlyCommand();let n=this.Selection,r=this.doc.ActiveSheet;for(let t=n.left;t<=n.right;t++){let i=r.getCellAppearance(t,n.bottom)||new Appearance;i.setHorizontal(e),r.setCellAppearance(t,n.bottom,i,!1)}}logAppearanceOnlyCommand(){let e={selection:this.Selection,appearance:this.SelectedAppearance};this.history.push(e)}logDataOnlyCommand(){let e={selection:this.Selection,data:this.SelectionData};this.history.push(e)}alterColumn(e,t){let n=this.doc.ActiveSheet.getColumnWidth(e);this.history.push({selection:e,data:n,meta:`COLUMN`}),this.doc.ActiveSheet.setColumnWidth(e,n+t)}alterRow(e,t){let n=this.doc.ActiveSheet.getRowHeight(e);this.history.push({selection:e,data:n,meta:`ROW`}),this.doc.ActiveSheet.setRowHeight(e,n+t)}changeValue(e,t,n){this.logDataOnlyCommand(),e??=this.Selection.columnId,t??=this.Selection.rowId,this.ActiveSheet.setCellValue(e,t,n)}merge(){this.logDataOnlyCommand();let e=this.Selection,t=Math.min(e.right,e.left),n=Math.min(e.top,e.bottom),r=Math.abs(e.right-e.left)+1,i=Math.abs(e.top-e.bottom)+1;this.ActiveSheet.merge(t,n,r,i)}unmerge(){this.logDataOnlyCommand();let e=this.Selection;this.ActiveSheet.unmerge(e.columnId,e.rowId)}appearance(e){this.logAppearanceOnlyCommand();let t=this.Selection;for(let n=t.top;n<=t.bottom;n++)for(let r=t.left;r<=t.right;r++){let t=this.ActiveSheet.getCellAppearance(r,n)||new Appearance;e(t),this.ActiveSheet.setCellAppearance(r,n,t)}}},OpenDocument=class{get ActiveSheet(){return this.sheets[this.activeSheetIndex]}get ActiveSheetIndex(){return this.activeSheetIndex}set ActiveSheetIndex(e){if(e<0||e>=this.sheets.length)throw Error(`invalid sheet index`);this.activeSheetIndex=e,this.onChange()}get Sheets(){return this.sheets}sheets=[];activeSheetIndex=0;commander;change_listeners=[];constructor(){this.init(),this.commander=new Commander(this)}addSheet(e){let t=new Sheet(e);t.addOnChange(()=>this.onChange()),this.sheets.push(t),this.onChange()}addOnChange(e){this.change_listeners.push(e)}removeOnChange(e){let t=this.change_listeners.indexOf(e);t>=0&&this.change_listeners.splice(t,1)}onChange(){this.change_listeners.forEach(e=>e())}execCommand(e,...t){this.commander.do(e,...t)}save(){return{sheets:this.sheets.map(e=>e.save()),activeSheetIndex:this.activeSheetIndex}}load(e){this.sheets=e.sheets.map(e=>Sheet.load(e)),this.activeSheetIndex=e.activeSheetIndex,this.onChange()}init(){this.addSheet(`Sheet1`),this.addSheet(`Sheet2`),this.addSheet(`Sheet3`)}},LayoutDirection=function(e){return e[e.LeftToRight=1]=`LeftToRight`,e[e.RightToLeft=2]=`RightToLeft`,e}({}),ContextMask=class e{x=0;y=0;width=0;height=0;constructor(e,t,n,r){this.x=e,this.y=t,this.width=n,this.height=r}get_left(){return this.x}set_left(e){this.x=e}get_top(){return this.y}get_right(){return this.x+this.width}get_bottom(){return this.y+this.height}set_top(e){this.y=e}get_width(){return this.width}set_width(e){this.width=e}get_height(){return this.height}set_height(e){this.height=e}set_value(e,t,n,r){this.x=e,this.y=t,this.width=n,this.height=r}get_combinedMask(t,n,r,i){let a=Math.min(t+r,this.get_right()),o=Math.min(n+i,this.get_bottom());return r=Math.min(a-t,this.get_width()),i=Math.min(o-n,this.get_height()),t=Math.max(t,this.get_left()),n=Math.max(n,this.get_top()),new e(t,n,r,i)}},Context=class{direction=LayoutDirection.LeftToRight;textAlign=TextAlign.Left;fillStyle=`#fff`;strokeStyle=`#000`;strokeSize=1;contentFillStyle=`#000`;fontStyle=``;fontSize=12;fontName=`Tahoma`;context2d;width;height;currentMask;maskStack=[];constructor(e,t,n){this.context2d=e,this.width=t,this.height=n}get_directed_x(e,t=0){return this.direction===LayoutDirection.LeftToRight?e:this.width-e-t}get_textWidth(e){return this.context2d.measureText(e).width}save(){if(this.context2d.save(),this.context2d.translate(-.5,-.5),this.currentMask){let e=this.currentMask;this.context2d.rect(e.get_left(),e.get_top(),e.get_width(),e.get_height()),this.context2d.clip()}}restore(){this.context2d.restore()}setMask(e,t,n,r,i=!1){e=this.get_directed_x(e,n),this.currentMask&&this.maskStack.push(this.currentMask),i&&this.currentMask?this.currentMask=this.currentMask.get_combinedMask(e,t,n,r):this.currentMask=new ContextMask(e,t,n,r)}unmask(){this.maskStack.length>0?this.currentMask=this.maskStack.pop():this.currentMask=null}clearRect(e,t,n,r){e=this.get_directed_x(e,n),this.save(),this.context2d.clearRect(e,t,n,r),this.restore()}fillRect(e,t,n,r){e=this.get_directed_x(e,n),this.save(),this.applyFill(),this.context2d.beginPath(),this.context2d.fillRect(e,t,n,r),this.context2d.fill(),this.restore()}strokeRect(e,t,n,r){e=this.get_directed_x(e,n),this.save(),this.applyStroke(),this.context2d.beginPath(),this.context2d.strokeRect(e,t,n,r),this.context2d.stroke(),this.restore()}line(e,t,n,r){e=this.get_directed_x(e),n=this.get_directed_x(n),this.save(),this.applyStroke(),this.context2d.beginPath(),this.context2d.moveTo(e,t),this.context2d.lineTo(n,r),this.context2d.stroke(),this.restore()}path(e,t,n,...r){this.save(),this.applyStroke(),this.applyFill(),this.context2d.beginPath();let i=r[0],a=this.get_directed_x(i.x);this.context2d.moveTo(a,i.y);for(let e=1;ethis.render())}initialize(){this.createElements(),this.resize(),this.render()}createElements(){this.canvas=document.createElement(`canvas`),this.container.appendChild(this.canvas)}resize(){let e=window.devicePixelRatio;this.width=this.container.clientWidth,this.height=this.container.clientHeight,e>1?(this.canvas.width=this.width*e,this.canvas.height=this.height*e,this.canvas.style.width=this.width+`px`,this.canvas.style.height=this.height+`px`):(this.canvas.width=this.width,this.canvas.height=this.height),this.render()}get_context2D(){let e=window.devicePixelRatio;this.canvas.width=this.canvas.width;let t=this.canvas.getContext(`2d`);return t.scale(e,e),t}render(){this.rendering||(this.rendering=!0,setTimeout(()=>{this.doRender(),this.rendering=!1},1e3/this.renderFrameRate))}doRender(){console.log(`%cRender`,`color:${COLOR_1}`);let e=this.get_context2D();this.context=new Context(e,this.width,this.height),this.renderSheetTitles(),this.renderSheet()}renderTopCorner(){this.context.fillStyle=`#ececec`,this.context.fontSize=12;let e=28;this.context.fillClosePath(new Point(2,28),new Point(28,28),new Point(28,1))}renderSheetTitles(){this.renderTopCorner(),this.context.strokeSize=1;let e=0,t=this.height-30-.5,n=35,r=this.height-30-.5;this.context.rect(0,t,this.width,35),this.context.fillStyle=this.context.createGradient(0,r,0,30/3,[0,`#f0f0f0`],[1,`#fff`]),this.context.fillRect(0,t,this.width,35),this.context.textAlign=TextAlign.Center;let i=30,a=this.document.ActiveSheet,o=5;for(let e of this.document.Sheets){let t=e.getWidth(e=>this.context.get_textWidth(e));this.context.strokeStyle=`#aaa`,this.context.fillStyle=`#fafafa`,this.context.fontStyle=`italic`,e===a&&(this.context.fillStyle=`#fff`,this.context.fontStyle=`bold`),this.context.rect(i,r,t,25),this.context.fillText(e.title,i,r+5,t),e===a&&(this.context.fillStyle=COLOR_3,this.context.fillRect(i,r+30-5,t,2),this.context.strokeStyle=COLOR_LIGHT),this.context.line(i,r,i+t,r),i+=t+5}this.context.fontStyle=``}renderSheet(){let e=this.width,t=this.height,n=30,r=t-30,i=this.context;i.setMask(0,0,e,t-31.5);let a=this.renderRows(),o=this.renderColumns();i.unmask(),i.setMask(30.5,30,e,r-30-.5),this.renderCells(o,a),i.unmask()}renderRows(){this.context;let e=this.height-30-30,t=30,n=this.document.ActiveSheet,r=n.scrollRow;for(;t0&&(!s||!s.isMerged)){let e=u.horizontalBorder,t=u.verticalBorder;a.strokeStyle=e&&e.color||`#eeeeee`,(u.background==null||e!=null)&&a.line(n+30,r+c,n+30+l,r+c),a.strokeStyle=t&&t.color||`#eeeeee`,(u.background==null||t!=null)&&a.line(n+30+l,r,n+30+l,r+c)}n+=e}r+=t}}paintCell(e,t,n,r){let i=this.context,a=this.document.ActiveSheet,o=a.getCell(e,t);if(o&&o.isMerged)return;let s=a.getAppearance(e,t),c=n+30;if(r<30)return;s.fontSize&&(i.fontSize=parseInt(s.fontSize+``)),s.fontName&&(i.fontName=s.fontName),i.fontStyle=s.textStyle?s.textStyle:``;let l=o?a.getCellWidth(o):a.getColumnWidth(e),u=o?a.getCellHeight(o):a.getRowHeight(t);i.setMask(c,r,l,u),s.background&&(i.fillStyle=s.background,i.fillRect(c,r,l,u)),o&&o.label&&(i.contentFillStyle=s.text,i.strokeStyle=s.text,i.textAlign=s.textAlign,i.fillText(o.label,n+30+5,r+7,l)),i.unmask()}},CellEditor=class{controler;get Value(){return this.editorElement.value==``?null:this.editorElement.value}set Value(e){this.editorElement&&(this.editorElement.value=e?e+``:``)}get IsDirty(){return this.getCurrentCell().value!=this.Value}get EditMode(){return this.editMode}set EditMode(e){this.editMode=e,e?this.editorElement.readOnly=!1:this.editorElement.readOnly=!0,this.editorElement.focus()}websheet;editorArea;selectionElement;editorElement;anchorElement;editMode=!1;constructor(e){this.controler=e,this.websheet=e.websheet,this.initialize(),this.select()}initialize(){this.editorArea=document.createElement(`div`),this.editorArea.style.position=`absolute`,this.editorArea.style.top=`30px`,this.editorArea.style.left=`30px`,this.editorArea.style.bottom=`30px`,this.editorArea.style.right=`0px`,this.editorArea.style.overflow=`visible`,this.controler.renderer.Element.appendChild(this.editorArea),this.selectionElement=document.createElement(`div`),this.selectionElement.style.position=`absolute`,this.selectionElement.style.border=`solid 2px ${COLOR_1}`,this.selectionElement.style.overflow=`hidden`,this.selectionElement.style.background=`rgba(0,0,0,.1)`,this.selectionElement.style.transitionDuration=`.1s`,this.editorArea.appendChild(this.selectionElement),this.editorElement=document.createElement(`input`),this.editorElement.type=`text`,this.editorElement.style.display=`block`,this.editorElement.style.zIndex=`10000`,this.editorElement.style.position=`absolute`,this.editorElement.style.background=`#fff`,this.editorElement.style.textIndent=`3px`,this.editorElement.style.border=`none`;let e=()=>{this.EditMode||=!0};this.editorElement.addEventListener(`click`,e),this.editorElement.addEventListener(`change`,e),this.editorElement.addEventListener(`touchstart`,e),this.selectionElement.appendChild(this.editorElement),this.anchorElement=document.createElement(`span`),this.anchorElement.style.position=`absolute`,this.anchorElement.style.right=`0`,this.anchorElement.style.bottom=`0`,this.anchorElement.style.width=`6px`,this.anchorElement.style.height=`6px`,this.anchorElement.style.borderRadius=`2px`,this.anchorElement.style.border=`solid 1px #fff`,this.anchorElement.style.background=COLOR_2,this.anchorElement.style.zIndex=`10000`,this.anchorElement.style.cursor=`cell`,this.editorArea.appendChild(this.anchorElement),this.websheet.addOnChange(()=>{let e=this.websheet.ActiveSheet.SelectedValue;e!=this.Value&&(this.Value=e),this.updateEditorAppearance(),this.select(!0)})}disableAnimation(){this.selectionElement.style.transitionDuration=``,this.anchorElement.style.transitionDuration=``}enableAnimation(){this.selectionElement.style.transitionDuration=`.1s`,this.anchorElement.style.transitionDuration=`.1s`}deselect(){let e=this.getCurrentCell();this.IsDirty&&this.controler.websheet.execCommand(`change-value`,e.columnId,e.rowId,this.Value)}updateEditorAppearance(){let e=this.getCurrentAppearance();this.editorElement.style.textAlign=this.getTextAlign(e.textAlign),this.editorElement.style.fontStyle=e.italic?`italic`:``,this.editorElement.style.fontWeight=e.bold?`bold`:``,this.editorElement.style.background=e.background,this.editorElement.style.fontFamily=e.fontName,this.editorElement.style.fontSize=`${e.fontSize}px`,this.editorElement.style.color=e.text,this.editorElement.style.textDecoration=e.underline?`underline`:``}select(e=!0){e?this.enableAnimation():this.disableAnimation(),this.updateEditorAppearance();let t=this.controler.websheet.ActiveSheet,n=t.selection,r=t.getColumnLeft(n.left),i=t.getRowTop(n.top),a=t.getColumnRight(n.right),o=t.getRowBottom(n.bottom),s=a-r,c=o-i;this.selectionElement.style.left=r-2+`px`,this.selectionElement.style.top=i-2+`px`,this.selectionElement.style.width=s-2+`px`,this.selectionElement.style.height=c-2+`px`;let l=this.getCurrentCell(),u=t.getRowTop(n.rowId),d=t.getColumnLeft(n.columnId);this.editorElement.style.left=d-r+`px`,this.editorElement.style.top=u-i+`px`,this.editorElement.style.width=t.getCellWidth(l)-3+`px`,this.editorElement.style.height=t.getCellHeight(l)-3+`px`,this.editorElement.focus(),this.anchorElement.style.left=`${a-5}px`,this.anchorElement.style.top=`${o-5}px`}getCurrentCell(){let e=this.controler.websheet.ActiveSheet,t=e.selection;return e.getCell(t.columnId,t.rowId)||new Cell(t.columnId,t.rowId)}getCurrentAppearance(){let e=this.controler.websheet.ActiveSheet,t=e.selection;return e.getAppearance(t.columnId,t.rowId)}getTextAlign(e){return e==TextAlign.Center?`center`:e==TextAlign.Left?`left`:e==TextAlign.Right?`right`:``}},UIHandler=class{controller;constructor(e){this.controller=e}click(){}dblClick(){}mouseDown(e,t){}mouseMove(e,t){}mouseUp(e,t){}mouseWheel(e,t){}keyDown(e){}keyPress(e){}keyUp(e){}get locked(){return this.controller.locked}lock(){this.controller.lock(this)}unlock(){this.controller.unlock()}},WebSheetUIHandler=class extends UIHandler{mouseUp(e,t){if(t120?(n.scrollRight(),this.wheelDeltaX=0):this.wheelDeltaX<-120&&(n.scrollLeft(),this.wheelDeltaX=0),this.wheelDeltaY>120?(n.scrollUp(),this.wheelDeltaY=0):this.wheelDeltaY<-120&&(n.scrollDown(),this.wheelDeltaY=0),this.controller.renderer.render(),this.controller.select()}mouseDown(e,t){this.oldX=e,this.oldY=t}mouseUp(e,t){this.selectCell(e,t)}keyPress(e){if(e.key==`Enter`){if(this.controller.EditMode)this.controller.commit(),this.controller.EditMode=!1;else{this.controller.EditMode=!0;return}e.shiftKey?this.sheet.selectPreviousRowCell():this.sheet.selectNextRowCell()}}keyDown(e){e.key==`Tab`&&(this.controller.deselect(),e.shiftKey?this.sheet.selectPreviousColumnCell():this.sheet.selectNextColumnCell(),e.preventDefault(),this.controller.select(!0)),!this.controller.EditMode&&(e.key==`ArrowRight`||e.key==`ArrowLeft`||e.key==`ArrowUp`||e.key==`ArrowDown`)&&(this.controller.deselect(),e.key==`ArrowRight`?this.sheet.selectNextColumnCell():e.key==`ArrowLeft`?this.sheet.selectPreviousColumnCell():e.key==`ArrowUp`?this.sheet.selectPreviousRowCell():e.key==`ArrowDown`&&this.sheet.selectNextRowCell(),e.preventDefault(),this.controller.select(!0))}dblClick(){this.controller.EditMode||(this.controller.EditMode=!0)}selectCell(e,t){if(t<30||e<30||t>this.controller.renderer.Element.clientHeight-30)return;let n=this.controller.websheet.ActiveSheet,r=this.oldX-30,i=this.oldY-30,a=e-30,o=t-30;this.controller.deselect(),n.selectByXY(r,i,a,o),this.controller.select(!0)}},delta=4,ResizeHandler=class extends UIHandler{col;row;oldX;oldY;engaged=!1;mouseMove(e,t){let n=this.hitColumn(e-30,t),r=this.hitRow(e,t-30);n===!1?r===!1?this.engaged||this.controller.resetCursor():this.controller.changeCursor(`row-resize`):this.controller.changeCursor(`col-resize`)}mouseDown(e,t){this.col=this.hitColumn(e-30,t),this.row=this.hitRow(e,t-30),this.oldX=e,this.oldY=t,this.col!==!1||this.row!==!1?(this.lock(),this.col===!1?this.row!==!1&&this.controller.changeCursor(`row-resize`):this.controller.changeCursor(`col-resize`),this.engaged=!0):this.engaged=!1}mouseUp(e,t){this.engaged&&(this.col!==!1&&(this.controller.alterColumn(this.col,e-this.oldX),this.controller.resetCursor()),this.row!==!1&&(this.controller.alterRow(this.row,t-this.oldY),this.controller.resetCursor()),this.unlock())}hitRow(e,t){if(e>30)return!1;let n=e=>this.controller.websheet.ActiveSheet.getRowHeight(e),r=0;for(let e=n(r++);ee-delta&&t30)return!1;let n=e=>this.controller.websheet.ActiveSheet.getColumnWidth(e),r=0;for(let t=n(r++);tt-delta&&ethis.cellEditor.updateEditorAppearance())}select(e=!0){this.cellEditor.select(e)}deselect(){this.cellEditor.deselect()}alterColumn(e,t){this.websheet.execCommand(`alter-column`,e,t)}alterRow(e,t){this.websheet.execCommand(`alter-row`,e,t)}lock(e){this.lockedOn=e}unlock(){this.lockedOn=null}resetCursor(){this.renderer.Element.style.cursor=``}changeCursor(e){this.renderer.Element.style.cursor=e}attachEvents(){let e=this.renderer.Element,t=document.createElement(`div`);t.style.position=`absolute`,t.style.top=`0`,t.style.left=`0`,t.style.right=`0`,t.style.bottom=`0`,t.style.zIndex=`9999`,e.appendChild(t);let n=this,r=function(t){return{x:t.offsetX||t.layerX||t.clientX-e.offsetLeft,y:t.offsetY||t.layerY||t.clientY-e.offsetTop}},i=function(t){let n=t.touches.length?t.touches[0]:t.changedTouches[0];return{x:n.clientX-e.offsetLeft,y:n.clientY-e.offsetTop}};t.addEventListener(`touchstart`,e=>{if(e.touches.length==1){let t=i(e);n.mouseDown(t.x,t.y),e.preventDefault()}}),t.addEventListener(`touchmove`,e=>{let t=i(e);n.mouseMove(t.x,t.y)}),t.addEventListener(`touchend`,e=>{let t=i(e);n.mouseUp(t.x,t.y)}),t.addEventListener(`touchcancel`,e=>{let t=i(e);n.mouseUp(t.x,t.y)}),t.addEventListener(`mousedown`,e=>{let t=r(e);n.mouseDown(t.x,t.y)}),t.addEventListener(`mousemove`,e=>{let t=r(e);n.mouseMove(t.x,t.y)}),t.addEventListener(`mouseup`,e=>{let t=r(e);n.mouseUp(t.x,t.y)}),t.addEventListener(`click`,e=>n.click()),t.addEventListener(`dblclick`,e=>n.dblClick()),t.addEventListener(`mousewheel`,e=>{let t=e.wheelDeltaX,r=e.wheelDeltaY;return n.mouseWheel(t,r),e.preventDefault(),e.stopPropagation(),!1}),window.addEventListener(`keydown`,e=>n.keyDown(e)),window.addEventListener(`keypress`,e=>n.keyPress(e)),window.addEventListener(`keyup`,e=>n.keyUp(e)),window.addEventListener(`resize`,()=>this.renderer.resize())}click(){if(this.lockedOn){this.lockedOn.click();return}for(let e=0;e1||e.rowSpan>1:!1}get selectedCell(){return this.document.ActiveSheet.selectedCell}get SelectedCellLabel(){return this.document.ActiveSheet.SelectionLabel}get SelectedValue(){return this.document.ActiveSheet.SelectedValue}get SelectedAppearance(){return this.document.ActiveSheet.SelectedAppearance}handlers=[];document=new OpenDocument;render=null;uiController;constructor(e){this.element=e,this.render=new CanvasRenderer(e,this.document),this.uiController=new UIHandlerController(this.document,this.render),this.document.addOnChange(()=>this.raiseOnChangeEventListener()),this.render.render(),e.openDocument=this.document}execCmd(e,...t){console.log(`the command _${e}_ executed.`),this.uiController.commit(),this.document.execCommand(e,...t)}addOnChangeEventListener(e){this.handlers.push(e)}removeOnChangeEventListener(e){let t=this.handlers.indexOf(e);t!=-1&&this.handlers.splice(t,1)}save(){return JSON.stringify(this.document.save())}load(e){let t=JSON.parse(e);this.document.load(t)}raiseOnChangeEventListener(){this.handlers.forEach(e=>e(this.document))}};function SpreadsheetSurface(e){let t=import_react.useRef(null);return import_react.useEffect(()=>{if(!t.current)return;let n=new UI(t.current),r=t=>e.onChange(t);return n.addOnChangeEventListener(r),e.onReady(n),e.registerLoad(e=>n.load(e)),()=>{n.removeOnChangeEventListener(r),e.registerLoad(null)}},[]),import_react.createElement(`div`,{className:`ows-sheet-surface`,ref:t})}var defaultState={isMerged:!1,label:`A1`,originalValue:``,value:``};function App(){let[e,t]=import_react.useState(new Appearance),[n,r]=import_react.useState(`file`),[i,a]=import_react.useState(defaultState),o=import_react.useRef(n),s=import_react.useRef(null),c=import_react.useRef(null);return import_react.createElement(`div`,{className:`ows-app`},import_react.createElement(RibbonMenu,{appearance:e,fileMode:n,onAction:e=>e.actionName===`save-ows`?saveDocument(c.current):e.actionName===`load-ows`?loadDocument(c.current):e.actionName===`formula-template`?a({...i,value:e.args}):c.current&&c.current.execCmd(e.actionName,e.args),onModeChanged:e=>{o.current===`file`&&e===`local`&&localStorage.getItem(`data`)&&s.current&&s.current(localStorage.getItem(`data`)),o.current=e,r(e)},state:i}),import_react.createElement(FormulaBar,{label:i.label,onAbort:()=>a({...i,value:i.originalValue}),onCommit:()=>commitFormula(c.current,i),onValueChange:e=>a({...i,value:e}),value:i.value}),import_react.createElement(SpreadsheetSurface,{onChange:e=>{t(e.ActiveSheet.SelectedAppearance),a({isMerged:c.current?c.current.isMerged:!1,label:e.ActiveSheet.SelectionLabel,originalValue:e.ActiveSheet.SelectedValue||``,value:e.ActiveSheet.SelectedValue||``}),o.current===`local`&&localStorage.setItem(`data`,JSON.stringify(e.save()))},onReady:e=>c.current=e,registerLoad:e=>s.current=e}),import_react.createElement(`footer`,{className:`ows-status-bar`},`Ready`))}function commitFormula(e,t){e&&t.value!==t.originalValue&&e.execCmd(`change-value`,null,null,t.value)}var isLocalhost=function(){return!!(window.location.hostname===`localhost`||window.location.hostname===`[::1]`||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/))},waitWindowLoad;typeof window<`u`&&(waitWindowLoad=typeof Promise<`u`?new Promise(function(e){return window.addEventListener(`load`,e)}):{then:function(e){return window.addEventListener(`load`,e)}});function register(e,t){t===void 0&&(t={});var n=t.registrationOptions;n===void 0&&(n={}),delete t.registrationOptions;var r=function(e){for(var n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];t&&t[e]&&t[e].apply(t,n)};`serviceWorker`in navigator&&waitWindowLoad.then(function(){isLocalhost()?(checkValidServiceWorker(e,r,n),navigator.serviceWorker.ready.then(function(e){r(`ready`,e)}).catch(function(e){return handleError(r,e)})):(registerValidSW(e,r,n),navigator.serviceWorker.ready.then(function(e){r(`ready`,e)}).catch(function(e){return handleError(r,e)}))})}function handleError(e,t){navigator.onLine||e(`offline`),e(`error`,t)}function registerValidSW(e,t,n){navigator.serviceWorker.register(e,n).then(function(e){if(t(`registered`,e),e.waiting){t(`updated`,e);return}e.onupdatefound=function(){t(`updatefound`,e);var n=e.installing;n.onstatechange=function(){n.state===`installed`&&(navigator.serviceWorker.controller?t(`updated`,e):t(`cached`,e))}}}).catch(function(e){return handleError(t,e)})}function checkValidServiceWorker(e,t,n){fetch(e).then(function(r){r.status===404?(t(`error`,Error(`Service worker not found at `+e)),unregister()):r.headers.get(`content-type`).indexOf(`javascript`)===-1?(t(`error`,Error(`Expected `+e+` to have javascript content-type, but received `+r.headers.get(`content-type`))),unregister()):registerValidSW(e,t,n)}).catch(function(e){return handleError(t,e)})}function unregister(){`serviceWorker`in navigator&&navigator.serviceWorker.ready.then(function(e){e.unregister()}).catch(function(e){return handleError(emit,e)})}register(`service-worker.js`,{ready(){console.log(`App is being served from cache by a service worker. For more details, visit https://goo.gl/AFskqB`)},registered(){console.log(`Service worker has been registered.`)},cached(){console.log(`Content has been cached for offline use.`)},updatefound(){console.log(`New content is downloading.`)},updated(){console.log(`New content is available; please refresh.`)},offline(){console.log(`No internet connection found. App is running in offline mode.`)},error(e){console.error(`Error during service worker registration:`,e)}});var app=document.getElementById(`app`);app&&(0,import_client.createRoot)(app).render(import_react.createElement(App)); \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 8d8fc3b..0b2c453 100644 --- a/docs/index.html +++ b/docs/index.html @@ -10,7 +10,7 @@ crossorigin="anonymous"> Open web sheet - + diff --git a/src/features/ribbon/FormatControls.tsx b/src/features/ribbon/FormatControls.tsx index 128cba4..ed42b87 100644 --- a/src/features/ribbon/FormatControls.tsx +++ b/src/features/ribbon/FormatControls.tsx @@ -10,6 +10,12 @@ interface FormatControlsProps { onAction: (action: AppAction) => void; } +const alignments = [ + {icon: 'fa fa-align-left', label: 'Align left', value: 'left', textAlign: TextAlign.Left}, + {icon: 'fa fa-align-center', label: 'Align center', value: 'center', textAlign: TextAlign.Center}, + {icon: 'fa fa-align-right', label: 'Align right', value: 'right', textAlign: TextAlign.Right}, +]; + export function FormatControls(props: FormatControlsProps) { const action = (actionName: string, args?: any) => props.onAction({actionName, args}); @@ -30,22 +36,22 @@ export function FormatControls(props: FormatControlsProps) { })), ), React.createElement('div', {className: 'ows-button-row'}, - React.createElement(AlignButton, {action, alignment: TextAlign.Left, appearance: props.appearance}), - React.createElement(AlignButton, {action, alignment: TextAlign.Center, appearance: props.appearance}), - React.createElement(AlignButton, {action, alignment: TextAlign.Right, appearance: props.appearance}), + alignments.map((alignment) => React.createElement(AlignButton, { + action, + alignment, + appearance: props.appearance, + key: alignment.value, + })), ), ), ); } function AlignButton({action, alignment, appearance}: any) { - const icon = alignment === TextAlign.Left - ? 'fa fa-align-left' - : alignment === TextAlign.Center ? 'fa fa-align-center' : 'fa fa-align-right'; - return React.createElement(Button, { - active: appearance.textAlign === alignment, - icon, - onClick: () => action('align', alignment), + active: appearance.textAlign === alignment.textAlign, + icon: alignment.icon, + onClick: () => action('align', alignment.value), + title: alignment.label, }); } diff --git a/src/features/ribbon/RibbonMenu.test.tsx b/src/features/ribbon/RibbonMenu.test.tsx index 7dec7dd..31c699f 100644 --- a/src/features/ribbon/RibbonMenu.test.tsx +++ b/src/features/ribbon/RibbonMenu.test.tsx @@ -54,6 +54,16 @@ describe('RibbonMenu', () => { expect(onAction).toHaveBeenCalledWith({actionName: 'outside-border', args: '#000000'}); }); + it('emits text alignment command values the core accepts', () => { + const onAction = renderRibbon(); + + fireEvent.click(screen.getByTitle('Align center')); + fireEvent.click(screen.getByTitle('Align right')); + + expect(onAction).toHaveBeenCalledWith({actionName: 'align', args: 'center'}); + expect(onAction).toHaveBeenCalledWith({actionName: 'align', args: 'right'}); + }); + it('toggles view layout section items', async () => { renderRibbon();