@vuu-ui/vuu-data-react 0.8.0 → 0.8.1-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +495 -1
- package/cjs/index.js.map +4 -4
- package/esm/index.js +476 -1
- package/esm/index.js.map +4 -4
- package/package.json +8 -9
- package/types/hooks/useVuuMenuActions.d.ts +1 -2
- package/LICENSE +0 -201
package/esm/index.js
CHANGED
|
@@ -1,2 +1,477 @@
|
|
|
1
|
-
var Be=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var D=(i,e,t)=>(Be(i,e,"read from private field"),t?t.call(i):e.get(i)),Ue=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},me=(i,e,t,s)=>(Be(i,e,"write to private field"),s?s.call(i,t):e.set(i,t),t);import{getFullRange as re,metadataKeys as ct,WindowRange as pt}from"@vuu-ui/vuu-utils";import{useCallback as be,useEffect as xe,useMemo as We,useRef as ie,useState as dt}from"react";var{SELECTED:ke}=ct;function fs({dataSource:i,renderBufferSize:e=10}){let[,t]=dt(null),s=ie(!0),r=ie(!1),o=ie(null),n=ie([]),h=ie({from:0,to:10}),l=We(()=>new we(re(h.current,e)),[e]),a=be(c=>{for(let p of c)l.add(p);n.current=l.data.slice(),r.current=!0},[l]),f=be(c=>{c.type==="viewport-update"&&(c.size!==void 0&&l.setRowCount(c.size),c.rows?(a(c.rows),t({})):c.size!==void 0&&(n.current=l.data.slice(),r.current=!0))},[l,a]);xe(()=>()=>{o.current&&(cancelAnimationFrame(o.current),o.current=null),s.current=!1},[]);let u=be(c=>{h.current=c;let p=re(h.current,e);i.range=p,l.setRange(p.from,p.to)},[i,l,e]);return We(()=>{let{from:c,to:p}=h.current,g=re({from:c,to:p},e);i.range=g,l.setRange(g.from,g.to)},[i,l,e]),xe(()=>{let{from:c,to:p}=re(h.current,e);i.subscribe({range:{from:c,to:p}},f)},[i,f,e]),xe(()=>()=>{i.unsubscribe()},[i]),[n.current,l.rowCount,re(h.current,e),u]}var we=class{constructor({from:e,to:t}){this.rowCount=0;this.setRowCount=e=>{e<this.data.length&&(this.data.length=e),this.rowCount=e};this.range=new pt(e,t),this.data=new Array(t-e)}add(e){let[t]=e;if(this.isWithinRange(t)){let s=t-this.range.from;this.data[s]=e,this.data[s-1]&&this.data[s-1][ke]===1&&e[ke]===0&&(e[ke]=2),t===this.rowCount-1&&(this.data.length=s+1)}}getAtIndex(e){return this.range.isWithin(e)&&this.data[e-this.range.from]!=null?this.data[e-this.range.from]:void 0}isWithinRange(e){return this.range.isWithin(e)}setRange(e,t){if(e!==this.range.from||t!==this.range.to){let[s,r]=this.range.overlap(e,t),o=new Array(t-e);for(let n=s;n<r;n++){let h=this.getAtIndex(n);if(h){let l=n-e;o[l]=h}}this.data=o,this.range.from=e,this.range.to=t}}};import{useCallback as gt,useEffect as mt,useState as bt}from"react";import{ConnectionManager as je}from"@vuu-ui/vuu-data";var ms=()=>{let[i,e]=bt("disconnected"),t=gt(({status:s})=>{e(s)},[]);return mt(()=>(je.on("connection-status",t),()=>{je.removeListener("connection-status",t)}),[t]),i};import{useCallback as xt,useEffect as kt,useState as wt}from"react";import{ConnectionManager as Ge}from"@vuu-ui/vuu-data";var ws=()=>{let[i,e]=wt(0),t=xt(({messages:s})=>{e(s.messagesLength)},[]);return kt(()=>(Ge.on("connection-metrics",t),()=>{Ge.removeListener("connection-metrics",t)}),[t]),i};import{useCallback as Ot}from"react";import{makeRpcCall as Pt}from"@vuu-ui/vuu-data";var $e={type:"RPC_CALL",service:"TypeAheadRpcHandler"},Ss=(i,e,t="",s=[])=>t!==""&&!s.includes(t.toLowerCase())?[i,e,t]:[i,e],ys=()=>Ot(async e=>{let t=e.length===2?{method:"getUniqueFieldValues",params:e,...$e}:{method:"getUniqueFieldValuesStartingWith",params:e,...$e};return await Pt(t)},[]);var Ct=0,ne=class{constructor(e,t){this.from=e,this.to=t}},k=class{constructor(e={}){this.id=Ct++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=M.match(e)),t=>{let s=e(t);return s===void 0?null:[this,s]}}};k.closedBy=new k({deserialize:i=>i.split(" ")});k.openedBy=new k({deserialize:i=>i.split(" ")});k.group=new k({deserialize:i=>i.split(" ")});k.contextHash=new k({perNode:!0});k.lookAhead=new k({perNode:!0});k.mounted=new k({perNode:!0});var St=Object.create(null),M=class{constructor(e,t,s,r=0){this.name=e,this.props=t,this.id=s,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):St,s=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new M(e.name||"",t,e.id,s);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(r)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[o[0].id]=o[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(k.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let s in e)for(let r of s.split(" "))t[r]=e[s];return s=>{for(let r=s.prop(k.group),o=-1;o<(r?r.length:0);o++){let n=t[o<0?s.name:r[o]];if(n)return n}}}};M.none=new M("",Object.create(null),0,8);var Z=class{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let s of this.types){let r=null;for(let o of e){let n=o(s);n&&(r||(r=Object.assign({},s.props)),r[n[0].id]=n[1])}t.push(r?new M(s.name,r,s.id,s.flags):s)}return new Z(t)}},ue=new WeakMap,Xe=new WeakMap,C;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays"})(C||(C={}));var y=class{constructor(e,t,s,r,o){if(this.type=e,this.children=t,this.positions=s,this.length=r,this.props=null,o&&o.length){this.props=Object.create(null);for(let[n,h]of o)this.props[typeof n=="number"?n:n.id]=h}}toString(){let e=this.prop(k.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let s of this.children){let r=s.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new J(this.topNode,e)}cursorAt(e,t=0,s=0){let r=ue.get(this)||this.topNode,o=new J(r);return o.moveTo(e,t),ue.set(this,o._tree),o}get topNode(){return new I(this,0,0,null)}resolve(e,t=0){let s=K(ue.get(this)||this.topNode,e,t,!1);return ue.set(this,s),s}resolveInner(e,t=0){let s=K(Xe.get(this)||this.topNode,e,t,!0);return Xe.set(this,s),s}iterate(e){let{enter:t,leave:s,from:r=0,to:o=this.length}=e,n=e.mode||0,h=(n&C.IncludeAnonymous)>0;for(let l=this.cursor(n|C.IncludeAnonymous);;){let a=!1;if(l.from<=o&&l.to>=r&&(!h&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;a=!0}for(;a&&s&&(h||!l.type.isAnonymous)&&s(l),!l.nextSibling();){if(!l.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Se(M.none,this.children,this.positions,0,this.children.length,0,this.length,(t,s,r)=>new y(this.type,t,s,r,this.propValues),e.makeTree||((t,s,r)=>new y(M.none,t,s,r)))}static build(e){return yt(e)}};y.empty=new y(M.none,[],[],0);var oe=class{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new oe(this.buffer,this.index)}},E=class{constructor(e,t,s){this.buffer=e,this.length=t,this.set=s}get type(){return M.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],s=this.buffer[e+3],r=this.set.types[t],o=r.name;if(/\W/.test(o)&&!r.isError&&(o=JSON.stringify(o)),e+=4,s==e)return o;let n=[];for(;e<s;)n.push(this.childString(e)),e=this.buffer[e+3];return o+"("+n.join(",")+")"}findChild(e,t,s,r,o){let{buffer:n}=this,h=-1;for(let l=e;l!=t&&!(qe(o,r,n[l+1],n[l+2])&&(h=l,s>0));l=n[l+3]);return h}slice(e,t,s){let r=this.buffer,o=new Uint16Array(t-e),n=0;for(let h=e,l=0;h<t;){o[l++]=r[h++],o[l++]=r[h++]-s;let a=o[l++]=r[h++]-s;o[l++]=r[h++]-e,n=Math.max(n,a)}return new E(o,n,this.set)}};function qe(i,e,t,s){switch(i){case-2:return t<e;case-1:return s>=e&&t<e;case 0:return t<e&&s>e;case 1:return t<=e&&s>e;case 2:return s>e;case 4:return!0}}function He(i,e){let t=i.childBefore(e);for(;t;){let s=t.lastChild;if(!s||s.to!=t.to)break;s.type.isError&&s.from==s.to?(i=t,t=s.prevSibling):t=s}return i}function K(i,e,t,s){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to<e);){let n=!s&&i instanceof I&&i.index<0?null:i.parent;if(!n)return i;i=n}let o=s?0:C.IgnoreOverlays;if(s)for(let n=i,h=n.parent;h;n=h,h=n.parent)n instanceof I&&n.index<0&&((r=h.enter(e,t,o))===null||r===void 0?void 0:r.from)!=n.from&&(i=h);for(;;){let n=i.enter(e,t,o);if(!n)return i;i=n}}var I=class{constructor(e,t,s,r){this._tree=e,this.from=t,this.index=s,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,s,r,o=0){for(let n=this;;){for(let{children:h,positions:l}=n._tree,a=t>0?h.length:-1;e!=a;e+=t){let f=h[e],u=l[e]+n.from;if(qe(r,s,u,u+f.length)){if(f instanceof E){if(o&C.ExcludeBuffers)continue;let c=f.findChild(0,f.buffer.length,t,s-u,r);if(c>-1)return new N(new Oe(n,f,e,u),null,c)}else if(o&C.IncludeAnonymous||!f.type.isAnonymous||Ce(f)){let c;if(!(o&C.IgnoreMounts)&&f.props&&(c=f.prop(k.mounted))&&!c.overlay)return new I(c.tree,u,e,n);let p=new I(f,u,e,n);return o&C.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?f.children.length-1:0,t,s,r)}}}if(o&C.IncludeAnonymous||!n.type.isAnonymous||(n.index>=0?e=n.index+t:e=t<0?-1:n._parent._tree.children.length,n=n._parent,!n))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,s=0){let r;if(!(s&C.IgnoreOverlays)&&(r=this._tree.prop(k.mounted))&&r.overlay){let o=e-this.from;for(let{from:n,to:h}of r.overlay)if((t>0?n<=o:n<o)&&(t<0?h>=o:h>o))return new I(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,s)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new J(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return K(this,e,t,!1)}resolveInner(e,t=0){return K(this,e,t,!0)}enterUnfinishedNodesBefore(e){return He(this,e)}getChild(e,t=null,s=null){let r=ce(this,e,t,s);return r.length?r[0]:null}getChildren(e,t=null,s=null){return ce(this,e,t,s)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return pe(this,e)}};function ce(i,e,t,s){let r=i.cursor(),o=[];if(!r.firstChild())return o;if(t!=null){for(;!r.type.is(t);)if(!r.nextSibling())return o}for(;;){if(s!=null&&r.type.is(s))return o;if(r.type.is(e)&&o.push(r.node),!r.nextSibling())return s==null?o:[]}}function pe(i,e,t=e.length-1){for(let s=i.parent;t>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(e[t]&&e[t]!=s.name)return!1;t--}}return!0}var Oe=class{constructor(e,t,s,r){this.parent=e,this.buffer=t,this.index=s,this.start=r}},N=class{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,s){this.context=e,this._parent=t,this.index=s,this.type=e.buffer.set.types[e.buffer.buffer[s]]}child(e,t,s){let{buffer:r}=this.context,o=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,s);return o<0?null:new N(this.context,this,o)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,s=0){if(s&C.ExcludeBuffers)return null;let{buffer:r}=this.context,o=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return o<0?null:new N(this.context,this,o)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new N(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new N(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new J(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:s}=this.context,r=this.index+4,o=s.buffer[this.index+3];if(o>r){let n=s.buffer[this.index+1];e.push(s.slice(r,o,n)),t.push(0)}return new y(this.type,e,t,this.to-this.from)}resolve(e,t=0){return K(this,e,t,!1)}resolveInner(e,t=0){return K(this,e,t,!0)}enterUnfinishedNodesBefore(e){return He(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,s=null){let r=ce(this,e,t,s);return r.length?r[0]:null}getChildren(e,t=null,s=null){return ce(this,e,t,s)}get node(){return this}matchContext(e){return pe(this,e)}},J=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof I)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let s=e._parent;s;s=s._parent)this.stack.unshift(s.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:s,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=s+r.buffer[e+1],this.to=s+r.buffer[e+2],!0}yield(e){return e?e instanceof I?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,s){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,s,this.mode));let{buffer:r}=this.buffer,o=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,s);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,s=this.mode){return this.buffer?s&C.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,s))}parent(){if(!this.buffer)return this.yieldNode(this.mode&C.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&C.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,s=this.stack.length-1;if(e<0){let r=s<0?0:this.stack[s]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(s<0?t.buffer.length:t.buffer[this.stack[s]+3]))return this.yieldBuf(r)}return s<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,s,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let o=0;o<this.index;o++)if(r.buffer.buffer[o+3]<this.index)return!1;({index:t,parent:s}=r)}else({index:t,_parent:s}=this._tree);for(;s;{index:t,_parent:s}=s)if(t>-1)for(let o=t+e,n=e<0?-1:s._tree.children.length;o!=n;o+=e){let h=s._tree.children[o];if(this.mode&C.IncludeAnonymous||h instanceof E||!h.type.isAnonymous||Ce(h))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,s=0;if(e&&e.context==this.buffer)e:for(let r=this.index,o=this.stack.length;o>=0;){for(let n=e;n;n=n._parent)if(n.index==r){if(r==this.index)return n;t=n,s=o+1;break e}r=this.stack[--o]}for(let r=s;r<this.stack.length;r++)t=new N(this.buffer,t,this.stack[r]);return this.bufferNode=new N(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let s=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){s++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!s)return;this.parent(),s--,r=!0}}}matchContext(e){if(!this.buffer)return pe(this.node,e);let{buffer:t}=this.buffer,{types:s}=t.set;for(let r=e.length-1,o=this.stack.length-1;r>=0;o--){if(o<0)return pe(this.node,e,r);let n=s[t.buffer[this.stack[o]]];if(!n.isAnonymous){if(e[r]&&e[r]!=n.name)return!1;r--}}return!0}};function Ce(i){return i.children.some(e=>e instanceof E||!e.type.isAnonymous||Ce(e))}function yt(i){var e;let{buffer:t,nodeSet:s,maxBufferLength:r=1024,reused:o=[],minRepeatType:n=s.types.length}=i,h=Array.isArray(t)?new oe(t,t.length):t,l=s.types,a=0,f=0;function u(w,O,d,b,S){let{id:x,start:m,end:P,size:R}=h,T=f;for(;R<0;)if(h.next(),R==-1){let U=o[x];d.push(U),b.push(m-w);return}else if(R==-3){a=x;return}else if(R==-4){f=x;return}else throw new RangeError(`Unrecognized record size: ${R}`);let q=l[x],B,Q,Le=m-w;if(P-m<=r&&(Q=z(h.pos-O,S))){let U=new Uint16Array(Q.size-Q.skip),V=h.pos-Q.size,_=U.length;for(;h.pos>V;)_=X(Q.start,U,_);B=new E(U,P-Q.start,s),Le=Q.start-w}else{let U=h.pos-R;h.next();let V=[],_=[],G=x>=n?x:-1,H=0,ae=P;for(;h.pos>U;)G>=0&&h.id==G&&h.size>=0?(h.end<=ae-r&&(p(V,_,m,H,h.end,ae,G,T),H=V.length,ae=h.end),h.next()):u(m,U,V,_,G);if(G>=0&&H>0&&H<V.length&&p(V,_,m,H,m,ae,G,T),V.reverse(),_.reverse(),G>-1&&H>0){let ze=c(q);B=Se(q,V,_,0,V.length,0,P-m,ze,ze)}else B=g(q,V,_,P-m,T-P)}d.push(B),b.push(Le)}function c(w){return(O,d,b)=>{let S=0,x=O.length-1,m,P;if(x>=0&&(m=O[x])instanceof y){if(!x&&m.type==w&&m.length==b)return m;(P=m.prop(k.lookAhead))&&(S=d[x]+m.length+P)}return g(w,O,d,b,S)}}function p(w,O,d,b,S,x,m,P){let R=[],T=[];for(;w.length>b;)R.push(w.pop()),T.push(O.pop()+d-S);w.push(g(s.types[m],R,T,x-S,P-x)),O.push(S-d)}function g(w,O,d,b,S=0,x){if(a){let m=[k.contextHash,a];x=x?[m].concat(x):[m]}if(S>25){let m=[k.lookAhead,S];x=x?[m].concat(x):[m]}return new y(w,O,d,b,x)}function z(w,O){let d=h.fork(),b=0,S=0,x=0,m=d.end-r,P={size:0,start:0,skip:0};e:for(let R=d.pos-w;d.pos>R;){let T=d.size;if(d.id==O&&T>=0){P.size=b,P.start=S,P.skip=x,x+=4,b+=4,d.next();continue}let q=d.pos-T;if(T<0||q<R||d.start<m)break;let B=d.id>=n?4:0,Q=d.start;for(d.next();d.pos>q;){if(d.size<0)if(d.size==-3)B+=4;else break e;else d.id>=n&&(B+=4);d.next()}S=Q,b+=T,x+=B}return(O<0||b==w)&&(P.size=b,P.start=S,P.skip=x),P.size>4?P:void 0}function X(w,O,d){let{id:b,start:S,end:x,size:m}=h;if(h.next(),m>=0&&b<n){let P=d;if(m>4){let R=h.pos-(m-4);for(;h.pos>R;)d=X(w,O,d)}O[--d]=P,O[--d]=x-w,O[--d]=S-w,O[--d]=b}else m==-3?a=b:m==-4&&(f=b);return d}let j=[],Y=[];for(;h.pos>0;)u(i.start||0,i.bufferStart||0,j,Y,-1);let v=(e=i.length)!==null&&e!==void 0?e:j.length?Y[0]+j[0].length:0;return new y(l[i.topID],j.reverse(),Y.reverse(),v)}var Ye=new WeakMap;function fe(i,e){if(!i.isAnonymous||e instanceof E||e.type!=i)return 1;let t=Ye.get(e);if(t==null){t=1;for(let s of e.children){if(s.type!=i||!(s instanceof y)){t=1;break}t+=fe(i,s)}Ye.set(e,t)}return t}function Se(i,e,t,s,r,o,n,h,l){let a=0;for(let g=s;g<r;g++)a+=fe(i,e[g]);let f=Math.ceil(a*1.5/8),u=[],c=[];function p(g,z,X,j,Y){for(let v=X;v<j;){let w=v,O=z[v],d=fe(i,g[v]);for(v++;v<j;v++){let b=fe(i,g[v]);if(d+b>=f)break;d+=b}if(v==w+1){if(d>f){let b=g[w];p(b.children,b.positions,0,b.children.length,z[w]+Y);continue}u.push(g[w])}else{let b=z[v-1]+g[v-1].length-O;u.push(Se(i,g,z,w,v,O,b,null,l))}c.push(O+Y-o)}}return p(e,t,s,r,0),(h||l)(u,c,n)}var de=class{startParse(e,t,s){return typeof e=="string"&&(e=new Pe(e)),s=s?s.length?s.map(r=>new ne(r.from,r.to)):[new ne(0,0)]:[new ne(0,e.length)],this.createParse(e,t||[],s)}parse(e,t,s){let r=this.startParse(e,t,s);for(;;){let o=r.advance();if(o)return o}}},Pe=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var Rs=new k({perNode:!0});var te=class{constructor(e,t,s,r,o,n,h,l,a,f=0,u){this.p=e,this.stack=t,this.state=s,this.reducePos=r,this.pos=o,this.score=n,this.buffer=h,this.bufferBase=l,this.curContext=a,this.lookAhead=f,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,s=0){let r=e.parser.context;return new te(e,[],t,s,s,0,[],0,r?new ge(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let s=e>>19,r=e&65535,{parser:o}=this.p,n=o.dynamicPrecedence(r);if(n&&(this.score+=n),s==0){this.pushState(o.getGoto(this.state,r,!0),this.reducePos),r<o.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,4,!0),this.reduceContext(r,this.reducePos);return}let h=this.stack.length-(s-1)*3-(e&262144?6:0),l=h?this.stack[h-2]:this.p.ranges[0].from,a=this.reducePos-l;a>=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=a):this.p.lastBigReductionSize<a&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=a));let f=h?this.stack[h-1]:0,u=this.bufferBase+this.buffer.length-f;if(r<o.minRepeatTerm||e&131072){let c=o.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,l,c,u+4,!0)}if(e&262144)this.state=this.stack[h];else{let c=this.stack[h-3];this.state=o.getGoto(c,r,!0)}for(;this.stack.length>h;)this.stack.pop();this.reduceContext(r,l)}storeNode(e,t,s,r=4,o=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let n=this,h=this.buffer.length;if(h==0&&n.parent&&(h=n.bufferBase-n.parent.bufferBase,n=n.parent),h>0&&n.buffer[h-4]==0&&n.buffer[h-1]>-1){if(t==s)return;if(n.buffer[h-2]>=t){n.buffer[h-2]=s;return}}}if(!o||this.pos==s)this.buffer.push(e,t,s,r);else{let n=this.buffer.length;if(n>0&&this.buffer[n-4]!=0)for(;n>0&&this.buffer[n-2]>s;)this.buffer[n]=this.buffer[n-4],this.buffer[n+1]=this.buffer[n-3],this.buffer[n+2]=this.buffer[n-2],this.buffer[n+3]=this.buffer[n-1],n-=4,r>4&&(r-=4);this.buffer[n]=e,this.buffer[n+1]=t,this.buffer[n+2]=s,this.buffer[n+3]=r}}shift(e,t,s){let r=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=s,this.shiftContext(t,r),t<=this.p.parser.maxNode&&this.buffer.push(t,r,s,4);else{let o=e,{parser:n}=this.p;(s>this.pos||t<=n.maxNode)&&(this.pos=s,n.stateFlag(o,1)||(this.reducePos=s)),this.pushState(o,r),this.shiftContext(t,r),t<=n.maxNode&&this.buffer.push(t,r,s,4)}}apply(e,t,s){e&65536?this.reduce(e):this.shift(e,t,s)}useNode(e,t){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=e)&&(this.p.reused.push(e),s++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(s,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let s=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new te(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let s=e<=this.p.parser.maxNode;s&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,s?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new ve(this);;){let s=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(s==0)return!1;if(!(s&65536))return!0;t.reduce(s)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>4<<1||this.stack.length>=120){let r=[];for(let o=0,n;o<t.length;o+=2)(n=t[o+1])!=this.state&&this.p.parser.hasAction(n,e)&&r.push(t[o],n);if(this.stack.length<120)for(let o=0;r.length<4<<1&&o<t.length;o+=2){let n=t[o+1];r.some((h,l)=>l&1&&h==n)||r.push(t[o],n)}t=r}let s=[];for(let r=0;r<t.length&&s.length<4;r+=2){let o=t[r+1];if(o==this.state)continue;let n=this.split();n.pushState(o,this.pos),n.storeNode(0,n.pos,n.pos,4,!0),n.shiftContext(t[r],this.pos),n.score-=200,s.push(n)}return s}forceReduce(){let e=this.p.parser.stateSlot(this.state,5);if(!(e&65536))return!1;let{parser:t}=this.p;if(!t.validAction(this.state,e)){let s=e>>19,r=e&65535,o=this.stack.length-s*3;if(o<0||t.getGoto(this.stack[o],r,!1)<0)return!1;this.storeNode(0,this.reducePos,this.reducePos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.reducePos,this.reducePos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.reducePos,this.reducePos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new ge(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},ge=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},Ze;(function(i){i[i.Insert=200]="Insert",i[i.Delete=190]="Delete",i[i.Reduce=100]="Reduce",i[i.MaxNext=4]="MaxNext",i[i.MaxInsertStackDepth=300]="MaxInsertStackDepth",i[i.DampenInsertStackDepth=120]="DampenInsertStackDepth",i[i.MinBigReduction=2e3]="MinBigReduction"})(Ze||(Ze={}));var ve=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,s=e>>19;s==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(s-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},se=class{constructor(e,t,s){this.stack=e,this.pos=t,this.index=s,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new se(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new se(this.stack,this.pos,this.index)}};function he(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let s=0,r=0;s<i.length;){let o=0;for(;;){let n=i.charCodeAt(s++),h=!1;if(n==126){o=65535;break}n>=92&&n--,n>=34&&n--;let l=n-32;if(l>=46&&(l-=46,h=!0),o+=l,h)break;o*=46}t?t[r++]=o:t=new e(o)}return t}var ee=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},Ke=new ee,Re=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Ke,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let s=this.range,r=this.rangeIndex,o=this.pos+e;for(;o<s.from;){if(!r)return null;let n=this.ranges[--r];o-=s.from-n.to,s=n}for(;t<0?o>s.to:o>=s.to;){if(r==this.ranges.length-1)return null;let n=this.ranges[++r];o+=n.from-s.to,s=n}return o}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,s,r;if(t>=0&&t<this.chunk.length)s=this.pos+e,r=this.chunk.charCodeAt(t);else{let o=this.resolveOffset(e,1);if(o==null)return-1;if(s=o,s>=this.chunk2Pos&&s<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(s-this.chunk2Pos);else{let n=this.rangeIndex,h=this.range;for(;h.to<=s;)h=this.ranges[++n];this.chunk2=this.input.chunk(this.chunk2Pos=s),s+this.chunk2.length>h.to&&(this.chunk2=this.chunk2.slice(0,h.to-s)),r=this.chunk2.charCodeAt(0)}}return s>=this.token.lookAhead&&(this.token.lookAhead=s+1),r}acceptToken(e,t=0){let s=t?this.resolveOffset(t,-1):this.pos;if(s==null||s<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=s}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=Ke,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let s="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(s+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return s}},W=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:s}=t.p;nt(this.data,e,t,this.id,s.data,s.tokenPrecTable)}};W.prototype.contextual=W.prototype.fallback=W.prototype.extend=!1;var Me=class{constructor(e,t,s){this.precTable=t,this.elseToken=s,this.data=typeof e=="string"?he(e):e}token(e,t){let s=e.pos,r=0;for(;nt(this.data,e,t,0,this.data,this.precTable),!(e.token.value>-1);){if(this.elseToken==null)return;if(e.next<0)break;e.advance(),e.reset(e.pos,e.token),r++}r&&(e.reset(s,e.token),e.acceptToken(this.elseToken,r))}};Me.prototype.contextual=W.prototype.fallback=W.prototype.extend=!1;function nt(i,e,t,s,r,o){let n=0,h=1<<s,{dialect:l}=t.p.parser;e:for(;h&i[n];){let a=i[n+1];for(let p=n+3;p<a;p+=2)if((i[p+1]&h)>0){let g=i[p];if(l.allows(g)&&(e.token.value==-1||e.token.value==g||Rt(g,e.token.value,r,o))){e.acceptToken(g);break}}let f=e.next,u=0,c=i[n+2];if(e.next<0&&c>u&&i[a+c*3-3]==65535&&i[a+c*3-3]==65535){n=i[a+c*3-1];continue e}for(;u<c;){let p=u+c>>1,g=a+p+(p<<1),z=i[g],X=i[g+1]||65536;if(f<z)c=p;else if(f>=X)u=p+1;else{n=i[g+2],e.advance();continue e}}break}}function Je(i,e,t){for(let s=e,r;(r=i[s])!=65535;s++)if(r==t)return s-e;return-1}function Rt(i,e,t,s){let r=Je(t,s,e);return r<0||Je(t,s,i)<r}var F=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),ye=null,et;(function(i){i[i.Margin=25]="Margin"})(et||(et={}));function tt(i,e,t){let s=i.cursor(C.IncludeAnonymous);for(s.moveTo(e);;)if(!(t<0?s.childBefore(e):s.childAfter(e)))for(;;){if((t<0?s.to<e:s.from>e)&&!s.type.isError)return t<0?Math.max(0,Math.min(s.to-1,e-25)):Math.min(i.length,Math.max(s.from+1,e+25));if(t<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return t<0?0:i.length}}var Ae=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?tt(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?tt(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let s=this.trees[t],r=this.index[t];if(r==s.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let o=s.children[r],n=this.start[t]+s.positions[r];if(n>e)return this.nextStart=n,null;if(o instanceof y){if(n==e){if(n<this.safeFrom)return null;let h=n+o.length;if(h<=this.safeTo){let l=o.prop(k.lookAhead);if(!l||h+l<this.fragment.to)return o}}this.index[t]++,n+o.length>=Math.max(this.safeFrom,e)&&(this.trees.push(o),this.start.push(n),this.index.push(0))}else this.index[t]++,this.nextStart=n+o.length}}},Te=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(s=>new ee)}getActions(e){let t=0,s=null,{parser:r}=e.p,{tokenizers:o}=r,n=r.stateSlot(e.state,3),h=e.curContext?e.curContext.hash:0,l=0;for(let a=0;a<o.length;a++){if(!(1<<a&n))continue;let f=o[a],u=this.tokens[a];if(!(s&&!f.fallback)&&((f.contextual||u.start!=e.pos||u.mask!=n||u.context!=h)&&(this.updateCachedToken(u,f,e),u.mask=n,u.context=h),u.lookAhead>u.end+25&&(l=Math.max(u.lookAhead,l)),u.value!=0)){let c=t;if(u.extended>-1&&(t=this.addActions(e,u.extended,u.end,t)),t=this.addActions(e,u.value,u.end,t),!f.extend&&(s=u,t>c))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!s&&e.pos==this.stream.end&&(s=new ee,s.value=e.p.parser.eofTerm,s.start=s.end=e.pos,t=this.addActions(e,s.value,s.end,t)),this.mainToken=s,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new ee,{pos:s,p:r}=e;return t.start=s,t.end=Math.min(s+1,r.stream.end),t.value=s==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,s){let r=this.stream.clipPos(s.pos);if(t.token(this.stream.reset(r,e),s),e.value>-1){let{parser:o}=s.p;for(let n=0;n<o.specialized.length;n++)if(o.specialized[n]==e.value){let h=o.specializers[n](this.stream.read(e.start,e.end),s);if(h>=0&&s.p.parser.dialect.allows(h>>1)){h&1?e.extended=h>>1:e.value=h>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,s,r){for(let o=0;o<r;o+=3)if(this.actions[o]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=s,r}addActions(e,t,s,r){let{state:o}=e,{parser:n}=e.p,{data:h}=n;for(let l=0;l<2;l++)for(let a=n.stateSlot(o,l?2:1);;a+=3){if(h[a]==65535)if(h[a+1]==1)a=L(h,a+2);else{r==0&&h[a+1]==2&&(r=this.putAction(L(h,a+2),t,s,r));break}h[a]==t&&(r=this.putAction(L(h,a+1),t,s,r))}return r}},st;(function(i){i[i.Distance=5]="Distance",i[i.MaxRemainingPerStep=3]="MaxRemainingPerStep",i[i.MinBufferLengthPrune=500]="MinBufferLengthPrune",i[i.ForceReduceLimit=10]="ForceReduceLimit",i[i.CutDepth=15e3]="CutDepth",i[i.CutTo=9e3]="CutTo",i[i.MaxLeftAssociativeReductionCount=300]="MaxLeftAssociativeReductionCount",i[i.MaxStackCount=12]="MaxStackCount"})(st||(st={}));var Ve=class{constructor(e,t,s,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Re(t,r),this.tokens=new Te(e,this.stream),this.topTerm=e.top[1];let{from:o}=r[0];this.stacks=[te.start(this,e.top[0],o)],this.fragments=s.length&&this.stream.end-o>e.bufferLength*4?new Ae(s,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,s=this.stacks=[],r,o;if(this.bigReductionCount>300&&e.length==1){let[n]=e;for(;n.forceReduce()&&n.stack.length&&n.stack[n.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let n=0;n<e.length;n++){let h=e[n];for(;;){if(this.tokens.mainToken=null,h.pos>t)s.push(h);else{if(this.advanceStack(h,s,e))continue;{r||(r=[],o=[]),r.push(h);let l=this.tokens.getMainToken(h);o.push(l.value,l.end)}}break}}if(!s.length){let n=r&&Mt(r);if(n)return this.stackToTree(n);if(this.parser.strict)throw F&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let n=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,o,s);if(n)return this.stackToTree(n.forceAll())}if(this.recovering){let n=this.recovering==1?1:this.recovering*3;if(s.length>n)for(s.sort((h,l)=>l.score-h.score);s.length>n;)s.pop();s.some(h=>h.reducePos>t)&&this.recovering--}else if(s.length>1){e:for(let n=0;n<s.length-1;n++){let h=s[n];for(let l=n+1;l<s.length;l++){let a=s[l];if(h.sameState(a)||h.buffer.length>500&&a.buffer.length>500)if((h.score-a.score||h.buffer.length-a.buffer.length)>0)s.splice(l--,1);else{s.splice(n--,1);continue e}}}s.length>12&&s.splice(12,s.length-12)}this.minStackPos=s[0].pos;for(let n=1;n<s.length;n++)s[n].pos<this.minStackPos&&(this.minStackPos=s[n].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,s){let r=e.pos,{parser:o}=this,n=F?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let a=e.curContext&&e.curContext.tracker.strict,f=a?e.curContext.hash:0;for(let u=this.fragments.nodeAt(r);u;){let c=this.parser.nodeSet.types[u.type.id]==u.type?o.getGoto(e.state,u.type.id):-1;if(c>-1&&u.length&&(!a||(u.prop(k.contextHash)||0)==f))return e.useNode(u,c),F&&console.log(n+this.stackID(e)+` (via reuse of ${o.getName(u.type.id)})`),!0;if(!(u instanceof y)||u.children.length==0||u.positions[0]>0)break;let p=u.children[0];if(p instanceof y&&u.positions[0]==0)u=p;else break}}let h=o.stateSlot(e.state,4);if(h>0)return e.reduce(h),F&&console.log(n+this.stackID(e)+` (via always-reduce ${o.getName(h&65535)})`),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let a=0;a<l.length;){let f=l[a++],u=l[a++],c=l[a++],p=a==l.length||!s,g=p?e:e.split();if(g.apply(f,u,c),F&&console.log(n+this.stackID(g)+` (via ${f&65536?`reduce of ${o.getName(f&65535)}`:"shift"} for ${o.getName(u)} @ ${r}${g==e?"":", split"})`),p)return!0;g.pos>r?t.push(g):s.push(g)}return!1}advanceFully(e,t){let s=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>s)return rt(e,t),!0}}runRecovery(e,t,s){let r=null,o=!1;for(let n=0;n<e.length;n++){let h=e[n],l=t[n<<1],a=t[(n<<1)+1],f=F?this.stackID(h)+" -> ":"";if(h.deadEnd&&(o||(o=!0,h.restart(),F&&console.log(f+this.stackID(h)+" (restarted)"),this.advanceFully(h,s))))continue;let u=h.split(),c=f;for(let p=0;u.forceReduce()&&p<10&&(F&&console.log(c+this.stackID(u)+" (via force-reduce)"),!this.advanceFully(u,s));p++)F&&(c=this.stackID(u)+" -> ");for(let p of h.recoverByInsert(l))F&&console.log(f+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,s);this.stream.end>h.pos?(a==h.pos&&(a++,l=0),h.recoverByDelete(l,a),F&&console.log(f+this.stackID(h)+` (via recover-delete ${this.parser.getName(l)})`),rt(h,s)):(!r||r.score<h.score)&&(r=h)}return r}stackToTree(e){return e.close(),y.build({buffer:se.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(ye||(ye=new WeakMap)).get(e);return t||ye.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function rt(i,e){for(let t=0;t<e.length;t++){let s=e[t];if(s.pos==i.pos&&s.sameState(i)){e[t].score<i.score&&(e[t]=i);return}}e.push(i)}var Ie=class{constructor(e,t,s){this.source=e,this.flags=t,this.disabled=s}allows(e){return!this.disabled||this.disabled[e]==0}};var $=class extends de{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let h=0;h<e.repeatNodeCount;h++)t.push("");let s=Object.keys(e.topRules).map(h=>e.topRules[h][1]),r=[];for(let h=0;h<t.length;h++)r.push([]);function o(h,l,a){r[h].push([l,l.deserialize(String(a))])}if(e.nodeProps)for(let h of e.nodeProps){let l=h[0];typeof l=="string"&&(l=k[l]);for(let a=1;a<h.length;){let f=h[a++];if(f>=0)o(f,l,h[a++]);else{let u=h[a+-f];for(let c=-f;c>0;c--)o(h[a++],l,u);a++}}}this.nodeSet=new Z(t.map((h,l)=>M.define({name:l>=this.minRepeatTerm?void 0:h,id:l,props:r[l],top:s.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let n=he(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let h=0;h<this.specializerSpecs.length;h++)this.specialized[h]=this.specializerSpecs[h].term;this.specializers=this.specializerSpecs.map(it),this.states=he(e.states,Uint32Array),this.data=he(e.stateData),this.goto=he(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(h=>typeof h=="number"?new W(n,h):h),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,s){let r=new Ve(this,e,t,s);for(let o of this.wrappers)r=o(r,e,t,s);return r}getGoto(e,t,s=!1){let r=this.goto;if(t>=r[0])return-1;for(let o=r[t+1];;){let n=r[o++],h=n&1,l=r[o++];if(h&&s)return l;for(let a=o+(n>>1);o<a;o++)if(r[o]==e)return l;if(h)return-1}}hasAction(e,t){let s=this.data;for(let r=0;r<2;r++)for(let o=this.stateSlot(e,r?2:1),n;;o+=3){if((n=s[o])==65535)if(s[o+1]==1)n=s[o=L(s,o+2)];else{if(s[o+1]==2)return L(s,o+2);break}if(n==t||n==0)return L(s,o+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){if(t==this.stateSlot(e,4))return!0;for(let s=this.stateSlot(e,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=L(this.data,s+2);else return!1;if(t==L(this.data,s+1))return!0}}nextStates(e){let t=[];for(let s=this.stateSlot(e,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=L(this.data,s+2);else break;if(!(this.data[s+2]&1)){let r=this.data[s+1];t.some((o,n)=>n&1&&o==r)||t.push(this.data[s],r)}}return t}configure(e){let t=Object.assign(Object.create($.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let s=this.topRules[e.top];if(!s)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=s}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(s=>{let r=e.tokenizers.find(o=>o.from==s);return r?r.to:s})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((s,r)=>{let o=e.specializers.find(h=>h.from==s.external);if(!o)return s;let n=Object.assign(Object.assign({},s),{external:o.to});return t.specializers[r]=it(n),n})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),s=t.map(()=>!1);if(e)for(let o of e.split(" ")){let n=t.indexOf(o);n>=0&&(s[n]=!0)}let r=null;for(let o=0;o<t.length;o++)if(!s[o])for(let n=this.dialects[t[o]],h;(h=this.data[n++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[h]=1;return new Ie(e,s,r)}static deserialize(e){return new $(e)}};function L(i,e){return i[e]|i[e+1]<<16}function Mt(i){let e=null;for(let t of i){let s=t.p.stoppedAt;(t.pos==t.p.stream.end||s!=null&&t.pos>s)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function it(i){if(i.external){let e=i.extend?1:0;return(t,s)=>i.external(t,s)<<1|e}return i.get}var Fe=$.deserialize({version:14,states:"%QOVQPOOOOQO'#C_'#C_O_QQO'#C^OOQO'#DO'#DOOvQQO'#C|OOQO'#DR'#DROVQPO'#CuOOQO'#C}'#C}QOQPOOOOQO'#C`'#C`O!UQQO,58xO!dQPO,59VOVQPO,59]OVQPO,59_O!iQPO,59hO!nQQO,59aOOQO'#DQ'#DQOOQO1G.d1G.dO!UQQO1G.qO!yQQO1G.wOOQO1G.y1G.yOOQO'#Cw'#CwOOQO1G/S1G/SOOQO1G.{1G.{O#[QPO'#CnO#dQPO7+$]O!UQQO'#CxO#iQPO,59YOOQO<<Gw<<GwOOQO,59d,59dOOQO-E6v-E6v",stateData:"#q~OoOS~OsPOvUO~OTXOUXOVXOWXOXXOYXO`ZO~Of[Oh]Oj^OmpX~OZ`O[`O]`O^`O~OabO~OseO~Of[Oh]OwgO~Oh]Ofeijeimeiwei~OcjOdbX~OdlO~OcjOdba~O",goto:"#YvPPw}!TPPPPPPPPPPwPP!WPP!ZP!ZP!aP!g!jPPP!p!s!aP#P!aXROU[]XQOU[]RYQRibXTOU[]XVOU[]Rf^QkhRnkRWOQSOQ_UQc[Rd]QaYQhbRmj",nodeNames:"\u26A0 Filter ColumnValueExpression Column Operator Eq NotEq Gt Lt Starts Ends Number String True False ColumnSetExpression In LBrack Values Comma RBrack AndExpression And OrExpression Or ParenthesizedExpression As FilterName",maxTerm:39,skippedNodes:[0],repeatNodeCount:1,tokenData:"6p~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$j|}$o!O!P$t!Q![%S!^!_%_!_!`%d!`!a%i!c!}%n!}#O&V#P#Q&[#R#S%n#T#U&a#U#X%n#X#Y(w#Y#Z+]#Z#]%n#]#^.]#^#c%n#c#d/e#d#g%n#g#h0m#h#i4[#i#o%n~#USo~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOU~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_O[~~$bP;=`<%l#m~$jOv~~$oOw~~$tOc~~$wP!Q![$z~%PPZ~!Q![$z~%XQZ~!O!P$t!Q![%S~%dOW~~%iOT~~%nOV~P%sUsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n~&[Oa~~&aOd~R&fYsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c'U#c#g%n#g#h(^#h#o%nR'ZWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X's#X#o%nR'zUfQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(eUjQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c)f#c#o%nR)kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X*T#X#o%nR*YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h*r#h#o%nR*yUYQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR+bVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U+w#U#o%nR+|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#`%n#`#a,f#a#o%nR,kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h-T#h#o%nR-YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y-r#Y#o%nR-yU^QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR.bWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c.z#c#o%nR/RU`QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR/jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g0S#g#o%nR0ZUhQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR0rWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i1[#i#o%nR1aVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U1v#U#o%nR1{WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g2e#g#o%nR2jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i3S#i#o%nR3XWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h3q#h#o%nR3xUXQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR4aWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g4y#g#o%nR5OWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#i%n#i#j5h#j#o%nR5mWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y6V#Y#o%nR6^U]QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n",tokenizers:[0,1],topRules:{Filter:[0,1]},tokenPrec:0});import{isMultiClauseFilter as le,isMultiValueFilter as At,isSingleValueFilter as Tt}from"@vuu-ui/vuu-utils";var A,De=class{constructor(){Ue(this,A,void 0)}setFilterCombinatorOp(e,t=D(this,A)){le(t)&&t.op===e||me(this,A,{op:e,filters:[D(this,A)]})}add(e){if(D(this,A)===void 0)me(this,A,e);else if(le(D(this,A)))D(this,A).filters.push(e);else throw Error("Invalid filter passed to FilterExpression")}setColumn(e,t=D(this,A)){if(le(t)){let s=t.filters.at(-1);s&&this.setColumn(e,s)}else t&&(t.column=e)}setOp(e,t=D(this,A)){if(le(t)){let s=t.filters.at(-1);s&&this.setOp(e,s)}else t&&(t.op=e)}setValue(e,t=D(this,A)){var s;if(le(t)){let r=t.filters.at(-1);r&&this.setValue(e,r)}else At(t)?((s=t.values)!=null||(t.values=[]),t.values.push(e)):Tt(t)&&(t.value=e)}toJSON(e=D(this,A)){return this.name?{...e,name:this.name}:e}};A=new WeakMap;var Ne=(i,e)=>{let t=new De,s=i.cursor();do{let{name:r,from:o,to:n}=s;switch(r){case"ColumnValueExpression":t.add({});break;case"ColumnSetExpression":t.add({op:"in"});break;case"Or":case"And":t.setFilterCombinatorOp(e.substring(o,n));break;case"Column":t.setColumn(e.substring(o,n));break;case"Operator":t.setOp(e.substring(o,n));break;case"String":t.setValue(e.substring(o+1,n-1));break;case"Number":t.setValue(parseFloat(e.substring(o,n)));break;case"True":t.setValue(!0);break;case"False":t.setValue(!1);break;case"FilterName":t.name=e.substring(o,n);break;default:}}while(s.next());return t.toJSON()};var Vt=Fe.configure({strict:!0}),Qe=i=>{let e=Vt.parse(i);return Ne(e,i)};var ot=new Map,It=()=>!1,_e=(i,e)=>{let t=ot.get(e);if(t)return t;try{let s=Qe(e);return t=Ee(i,s),ot.set(e,t),t}catch{return console.warn(`filter-evaluation-utils, failed to parse filter "${e}"`),It}};function Ee(i,e){switch(e.op){case"in":return Ft(i,e);case"=":return Dt(i,e);case">":return Nt(i,e);case">=":return Qt(i,e);case"<":return _t(i,e);case"<=":return Et(i,e);case"starts":return Lt(i,e);case"and":return zt(i,e);case"or":return Bt(i,e);default:return console.log(`unrecognized filter type ${e.op}`),()=>!0}}var Ft=(i,e)=>t=>e.values.indexOf(t[i[e.column]])!==-1,Dt=(i,e)=>t=>t[i[e.column]]===e.value,Nt=(i,e)=>t=>t[i[e.column]]>e.value,Qt=(i,e)=>t=>t[i[e.column]]>=e.value,_t=(i,e)=>t=>t[i[e.column]]<e.value,Et=(i,e)=>t=>t[i[e.column]]<=e.value,Lt=(i,e)=>{let t=e.value;if(typeof t!="string")throw Error("string filter applied to value of wrong type");return s=>{let r=s[i[e.column]];if(typeof r!="string")throw Error("string filter applied to value of wrong type");return r.toLowerCase().startsWith(t.toLowerCase())}},zt=(i,e)=>{let t=e.filters.map(s=>Ee(i,s));return s=>t.every(r=>r(s))};function Bt(i,e){let t=e.filters.map(s=>Ee(i,s));return s=>t.some(r=>r(s))}import{getRowRecord as Ut,isGroupMenuItemDescriptor as Wt,metadataKeys as jt}from"@vuu-ui/vuu-utils";import{useCallback as ht}from"react";var Hs="addRowsFromInstruments",{KEY:lt}=jt,Gt={},$t=i=>i.type==="vuu-links",Zs=i=>i.type==="vuu-link-created",Ks=i=>i.type==="vuu-link-removed",Xt=i=>i.type==="vuu-menu",Js=i=>Xt(i)||$t(i),er=i=>i.type==="vuu-link-created"||i.type==="vuu-link-removed",Yt=i=>"rpcName"in i,qt=i=>"menus"in i,Ht=i=>i.name==="ROOT",at=i=>i.context==="cell",Zt=i=>i.context==="row",Kt=i=>i.context==="selected-rows",Jt=(i,e,t=0)=>{switch(i){case"grid":return e==="selected-rows"?t>0:!0;case"header":return e==="grid";default:return!1}},es=(i,e,t,s,r)=>{if(i==="cell"||i==="row")return _e(r,s)(e);if(i==="selected-rows"){if(t.length===0)return!1;{let o=_e(r,s);return t.every(o)}}return!0},ts=i=>{let{rpcName:e}=i;return at(i)?{field:i.field,rowKey:i.rowKey,rpcName:e,value:i.value,type:"VIEW_PORT_MENU_CELL_RPC"}:Zt(i)?{rowKey:i.rowKey,row:i.row,rpcName:e,type:"VIEW_PORT_MENU_ROW_RPC"}:Kt(i)?{rpcName:e,type:"VIEW_PORT_MENUS_SELECT_RPC"}:{rpcName:e,type:"VIEW_PORT_MENU_TABLE_RPC"}},ss=({filter:i})=>typeof i=="string"&&i.length>0,rs=(i,e)=>{switch(i.context){case"cell":return{...i,field:e.columnName,rowKey:e.row[lt],value:e.row[e.columnMap[e.columnName]]};case"row":return{...i,row:Ut(e.row,e.columnMap),rowKey:e.row[lt]};default:return i}},ut=(i,e,t)=>{var s;return qt(i)?i.menus.some(r=>ut(r,e,t)):Jt(e,i.context,(s=t.selectedRows)==null?void 0:s.length)?e==="grid"&&ss(i)?es(i.context,t.row,t.selectedRows,i.filter,t.columnMap):at(i)&&i.field!=="*"?i.field===t.columnName:!0:!1},ft=(i,e,t)=>{if(ut(i,e,t)){if(Yt(i))return{label:i.name,action:"MENU_RPC_CALL",options:rs(i,t)};{let s=i.menus.map(r=>ft(r,e,t)).filter(r=>r!==void 0);if(s.length>0)return{label:i.name,children:s}}}},tr=({dataSource:i,menuActionConfig:e=Gt,onRpcResponse:t})=>{let s=ht((o,n)=>{let{visualLink:h,visualLinks:l,vuuMenu:a}=e,f=[];if(o==="grid"&&l&&!h&&l.forEach(u=>{let{link:c,label:p}=u,g=p||c.toTable;f.push({label:`Link to ${g}`,action:"link-table",options:u})}),a){let u=ft(a,o,n);Ht(a)&&Wt(u)?f.push(...u.children):u&&f.push(u)}return f},[e]),r=ht((o,n)=>{if(o==="MENU_RPC_CALL"){let h=ts(n);return i.menuRpcCall(h).then(l=>{t&&l&&t&&t(l)}),!0}else{if(o==="link-table")return i.visualLink=n,!0;console.log(`useViewServer handleMenuAction, can't handle action type ${o}`)}return!1},[i,t]);return{buildViewserverMenuOptions:s,handleMenuAction:r}};import{useCallback as is,useEffect as ns,useState as os}from"react";import{getServerAPI as hs}from"@vuu-ui/vuu-data";var or=()=>{let[i,e]=os(),t=is(s=>{let r=new Map;return s.forEach(o=>{r.set(o.table.table,o)}),r},[]);return ns(()=>{async function s(){let r=await hs(),{tables:o}=await r.getTableList(),n=t(await Promise.all(o.map(h=>r.getTableSchema(h))));e(n)}s()},[t]),i};export{we as MovingWindow,Hs as addRowsFromInstruments,Ss as getTypeaheadParams,Xt as isViewportMenusAction,Zs as isVisualLinkCreatedAction,Ks as isVisualLinkRemovedAction,$t as isVisualLinksAction,Js as isVuuFeatureAction,er as isVuuFeatureInvocation,fs as useDataSource,ws as useServerConnectionQuality,ms as useServerConnectionStatus,ys as useTypeaheadSuggestions,tr as useVuuMenuActions,or as useVuuTables};
|
|
1
|
+
// src/hooks/useDataSource.ts
|
|
2
|
+
import { getFullRange, metadataKeys, WindowRange } from "@vuu-ui/vuu-utils";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
var { SELECTED } = metadataKeys;
|
|
5
|
+
function useDataSource({
|
|
6
|
+
dataSource,
|
|
7
|
+
renderBufferSize = 10
|
|
8
|
+
}) {
|
|
9
|
+
const [, forceUpdate] = useState(null);
|
|
10
|
+
const isMounted = useRef(true);
|
|
11
|
+
const hasUpdated = useRef(false);
|
|
12
|
+
const rafHandle = useRef(null);
|
|
13
|
+
const data = useRef([]);
|
|
14
|
+
const rangeRef = useRef({ from: 0, to: 10 });
|
|
15
|
+
const dataWindow = useMemo(
|
|
16
|
+
() => new MovingWindow(getFullRange(rangeRef.current, renderBufferSize)),
|
|
17
|
+
[renderBufferSize]
|
|
18
|
+
);
|
|
19
|
+
const setData = useCallback(
|
|
20
|
+
(updates) => {
|
|
21
|
+
for (const row of updates) {
|
|
22
|
+
dataWindow.add(row);
|
|
23
|
+
}
|
|
24
|
+
data.current = dataWindow.data.slice();
|
|
25
|
+
hasUpdated.current = true;
|
|
26
|
+
},
|
|
27
|
+
[dataWindow]
|
|
28
|
+
);
|
|
29
|
+
const datasourceMessageHandler = useCallback(
|
|
30
|
+
(message) => {
|
|
31
|
+
if (message.type === "viewport-update") {
|
|
32
|
+
if (message.size !== void 0) {
|
|
33
|
+
dataWindow.setRowCount(message.size);
|
|
34
|
+
}
|
|
35
|
+
if (message.rows) {
|
|
36
|
+
setData(message.rows);
|
|
37
|
+
forceUpdate({});
|
|
38
|
+
} else if (message.size !== void 0) {
|
|
39
|
+
data.current = dataWindow.data.slice();
|
|
40
|
+
hasUpdated.current = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
[dataWindow, setData]
|
|
45
|
+
);
|
|
46
|
+
useEffect(
|
|
47
|
+
() => () => {
|
|
48
|
+
if (rafHandle.current) {
|
|
49
|
+
cancelAnimationFrame(rafHandle.current);
|
|
50
|
+
rafHandle.current = null;
|
|
51
|
+
}
|
|
52
|
+
isMounted.current = false;
|
|
53
|
+
},
|
|
54
|
+
[]
|
|
55
|
+
);
|
|
56
|
+
const setRange = useCallback(
|
|
57
|
+
(range) => {
|
|
58
|
+
rangeRef.current = range;
|
|
59
|
+
const fullRange = getFullRange(rangeRef.current, renderBufferSize);
|
|
60
|
+
dataSource.range = fullRange;
|
|
61
|
+
dataWindow.setRange(fullRange.from, fullRange.to);
|
|
62
|
+
},
|
|
63
|
+
[dataSource, dataWindow, renderBufferSize]
|
|
64
|
+
);
|
|
65
|
+
useMemo(() => {
|
|
66
|
+
const { from, to } = rangeRef.current;
|
|
67
|
+
const fullRange = getFullRange({ from, to }, renderBufferSize);
|
|
68
|
+
dataSource.range = fullRange;
|
|
69
|
+
dataWindow.setRange(fullRange.from, fullRange.to);
|
|
70
|
+
}, [dataSource, dataWindow, renderBufferSize]);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
const { from, to } = getFullRange(rangeRef.current, renderBufferSize);
|
|
73
|
+
dataSource.subscribe(
|
|
74
|
+
{
|
|
75
|
+
range: { from, to }
|
|
76
|
+
},
|
|
77
|
+
datasourceMessageHandler
|
|
78
|
+
);
|
|
79
|
+
}, [dataSource, datasourceMessageHandler, renderBufferSize]);
|
|
80
|
+
useEffect(
|
|
81
|
+
() => () => {
|
|
82
|
+
dataSource.unsubscribe();
|
|
83
|
+
},
|
|
84
|
+
[dataSource]
|
|
85
|
+
);
|
|
86
|
+
return [
|
|
87
|
+
data.current,
|
|
88
|
+
dataWindow.rowCount,
|
|
89
|
+
getFullRange(rangeRef.current, renderBufferSize),
|
|
90
|
+
setRange
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
var MovingWindow = class {
|
|
94
|
+
constructor({ from, to }) {
|
|
95
|
+
this.rowCount = 0;
|
|
96
|
+
this.setRowCount = (rowCount) => {
|
|
97
|
+
if (rowCount < this.data.length) {
|
|
98
|
+
this.data.length = rowCount;
|
|
99
|
+
}
|
|
100
|
+
this.rowCount = rowCount;
|
|
101
|
+
};
|
|
102
|
+
this.range = new WindowRange(from, to);
|
|
103
|
+
this.data = new Array(to - from);
|
|
104
|
+
}
|
|
105
|
+
add(data) {
|
|
106
|
+
const [index] = data;
|
|
107
|
+
if (this.isWithinRange(index)) {
|
|
108
|
+
const internalIndex = index - this.range.from;
|
|
109
|
+
this.data[internalIndex] = data;
|
|
110
|
+
if (this.data[internalIndex - 1]) {
|
|
111
|
+
if (this.data[internalIndex - 1][SELECTED] === 1 && data[SELECTED] === 0) {
|
|
112
|
+
data[SELECTED] = 2;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (index === this.rowCount - 1) {
|
|
116
|
+
this.data.length = internalIndex + 1;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
getAtIndex(index) {
|
|
121
|
+
return this.range.isWithin(index) && this.data[index - this.range.from] != null ? this.data[index - this.range.from] : void 0;
|
|
122
|
+
}
|
|
123
|
+
isWithinRange(index) {
|
|
124
|
+
return this.range.isWithin(index);
|
|
125
|
+
}
|
|
126
|
+
setRange(from, to) {
|
|
127
|
+
if (from !== this.range.from || to !== this.range.to) {
|
|
128
|
+
const [overlapFrom, overlapTo] = this.range.overlap(from, to);
|
|
129
|
+
const newData = new Array(to - from);
|
|
130
|
+
for (let i = overlapFrom; i < overlapTo; i++) {
|
|
131
|
+
const data = this.getAtIndex(i);
|
|
132
|
+
if (data) {
|
|
133
|
+
const index = i - from;
|
|
134
|
+
newData[index] = data;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
this.data = newData;
|
|
138
|
+
this.range.from = from;
|
|
139
|
+
this.range.to = to;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// src/hooks/useServerConnectionStatus.ts
|
|
145
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useState as useState2 } from "react";
|
|
146
|
+
import { ConnectionManager } from "@vuu-ui/vuu-data";
|
|
147
|
+
var useServerConnectionStatus = () => {
|
|
148
|
+
const [connectionStatus, setConnectionStatus] = useState2("disconnected");
|
|
149
|
+
const handleStatusChange = useCallback2(
|
|
150
|
+
({ status }) => {
|
|
151
|
+
setConnectionStatus(status);
|
|
152
|
+
},
|
|
153
|
+
[]
|
|
154
|
+
);
|
|
155
|
+
useEffect2(() => {
|
|
156
|
+
ConnectionManager.on("connection-status", handleStatusChange);
|
|
157
|
+
return () => {
|
|
158
|
+
ConnectionManager.removeListener("connection-status", handleStatusChange);
|
|
159
|
+
};
|
|
160
|
+
}, [handleStatusChange]);
|
|
161
|
+
return connectionStatus;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// src/hooks/useServerConnectionQuality.ts
|
|
165
|
+
import { useCallback as useCallback3, useEffect as useEffect3, useState as useState3 } from "react";
|
|
166
|
+
import { ConnectionManager as ConnectionManager2 } from "@vuu-ui/vuu-data";
|
|
167
|
+
var useServerConnectionQuality = () => {
|
|
168
|
+
const [messagesPerSecond, setMessagesPerSecond] = useState3(0);
|
|
169
|
+
const handleConnectivityMessage = useCallback3(({ messages }) => {
|
|
170
|
+
setMessagesPerSecond(messages.messagesLength);
|
|
171
|
+
}, []);
|
|
172
|
+
useEffect3(() => {
|
|
173
|
+
ConnectionManager2.on("connection-metrics", handleConnectivityMessage);
|
|
174
|
+
return () => {
|
|
175
|
+
ConnectionManager2.removeListener(
|
|
176
|
+
"connection-metrics",
|
|
177
|
+
handleConnectivityMessage
|
|
178
|
+
);
|
|
179
|
+
};
|
|
180
|
+
}, [handleConnectivityMessage]);
|
|
181
|
+
return messagesPerSecond;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// src/hooks/useTypeaheadSuggestions.ts
|
|
185
|
+
import { useCallback as useCallback4 } from "react";
|
|
186
|
+
import { makeRpcCall } from "@vuu-ui/vuu-data";
|
|
187
|
+
var TYPEAHEAD_MESSAGE_CONSTANTS = {
|
|
188
|
+
type: "RPC_CALL",
|
|
189
|
+
service: "TypeAheadRpcHandler"
|
|
190
|
+
};
|
|
191
|
+
var getTypeaheadParams = (table, column, text = "", selectedValues = []) => {
|
|
192
|
+
if (text !== "" && !selectedValues.includes(text.toLowerCase())) {
|
|
193
|
+
return [table, column, text];
|
|
194
|
+
}
|
|
195
|
+
return [table, column];
|
|
196
|
+
};
|
|
197
|
+
var useTypeaheadSuggestions = () => {
|
|
198
|
+
const getTypeaheadSuggestions = useCallback4(
|
|
199
|
+
async (params) => {
|
|
200
|
+
const rpcMessage = params.length === 2 ? {
|
|
201
|
+
method: "getUniqueFieldValues",
|
|
202
|
+
params,
|
|
203
|
+
...TYPEAHEAD_MESSAGE_CONSTANTS
|
|
204
|
+
} : {
|
|
205
|
+
method: "getUniqueFieldValuesStartingWith",
|
|
206
|
+
params,
|
|
207
|
+
...TYPEAHEAD_MESSAGE_CONSTANTS
|
|
208
|
+
};
|
|
209
|
+
const suggestions = await makeRpcCall(rpcMessage);
|
|
210
|
+
return suggestions;
|
|
211
|
+
},
|
|
212
|
+
[]
|
|
213
|
+
);
|
|
214
|
+
return getTypeaheadSuggestions;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// src/hooks/useVuuMenuActions.ts
|
|
218
|
+
import { getFilterPredicate } from "@vuu-ui/vuu-filter-parser";
|
|
219
|
+
import {
|
|
220
|
+
getRowRecord,
|
|
221
|
+
isGroupMenuItemDescriptor,
|
|
222
|
+
metadataKeys as metadataKeys2
|
|
223
|
+
} from "@vuu-ui/vuu-utils";
|
|
224
|
+
import { useCallback as useCallback5 } from "react";
|
|
225
|
+
var addRowsFromInstruments = "addRowsFromInstruments";
|
|
226
|
+
var { KEY } = metadataKeys2;
|
|
227
|
+
var NO_CONFIG = {};
|
|
228
|
+
var isVisualLinksAction = (action) => action.type === "vuu-links";
|
|
229
|
+
var isVisualLinkCreatedAction = (action) => action.type === "vuu-link-created";
|
|
230
|
+
var isVisualLinkRemovedAction = (action) => action.type === "vuu-link-removed";
|
|
231
|
+
var isViewportMenusAction = (action) => action.type === "vuu-menu";
|
|
232
|
+
var isVuuFeatureAction = (action) => isViewportMenusAction(action) || isVisualLinksAction(action);
|
|
233
|
+
var isVuuFeatureInvocation = (action) => action.type === "vuu-link-created" || action.type === "vuu-link-removed";
|
|
234
|
+
var isMenuItem = (menu) => "rpcName" in menu;
|
|
235
|
+
var isGroupMenuItem = (menu) => "menus" in menu;
|
|
236
|
+
var isRoot = (menu) => menu.name === "ROOT";
|
|
237
|
+
var isCellMenu = (options) => options.context === "cell";
|
|
238
|
+
var isRowMenu = (options) => options.context === "row";
|
|
239
|
+
var isSelectionMenu = (options) => options.context === "selected-rows";
|
|
240
|
+
var vuuContextCompatibleWithTableLocation = (uiLocation, vuuContext, selectedRowCount = 0) => {
|
|
241
|
+
switch (uiLocation) {
|
|
242
|
+
case "grid":
|
|
243
|
+
if (vuuContext === "selected-rows") {
|
|
244
|
+
return selectedRowCount > 0;
|
|
245
|
+
} else {
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
case "header":
|
|
249
|
+
return vuuContext === "grid";
|
|
250
|
+
default:
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
var gridRowMeetsFilterCriteria = (context, row, selectedRows, filter, columnMap) => {
|
|
255
|
+
if (context === "cell" || context === "row") {
|
|
256
|
+
const filterPredicate = getFilterPredicate(columnMap, filter);
|
|
257
|
+
return filterPredicate(row);
|
|
258
|
+
} else if (context === "selected-rows") {
|
|
259
|
+
if (selectedRows.length === 0) {
|
|
260
|
+
return false;
|
|
261
|
+
} else {
|
|
262
|
+
const filterPredicate = getFilterPredicate(columnMap, filter);
|
|
263
|
+
return selectedRows.every(filterPredicate);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return true;
|
|
267
|
+
};
|
|
268
|
+
var getMenuRpcRequest = (options) => {
|
|
269
|
+
const { rpcName } = options;
|
|
270
|
+
if (isCellMenu(options)) {
|
|
271
|
+
return {
|
|
272
|
+
field: options.field,
|
|
273
|
+
rowKey: options.rowKey,
|
|
274
|
+
rpcName,
|
|
275
|
+
value: options.value,
|
|
276
|
+
type: "VIEW_PORT_MENU_CELL_RPC"
|
|
277
|
+
};
|
|
278
|
+
} else if (isRowMenu(options)) {
|
|
279
|
+
return {
|
|
280
|
+
rowKey: options.rowKey,
|
|
281
|
+
row: options.row,
|
|
282
|
+
rpcName,
|
|
283
|
+
type: "VIEW_PORT_MENU_ROW_RPC"
|
|
284
|
+
};
|
|
285
|
+
} else if (isSelectionMenu(options)) {
|
|
286
|
+
return {
|
|
287
|
+
rpcName,
|
|
288
|
+
type: "VIEW_PORT_MENUS_SELECT_RPC"
|
|
289
|
+
};
|
|
290
|
+
} else {
|
|
291
|
+
return {
|
|
292
|
+
rpcName,
|
|
293
|
+
type: "VIEW_PORT_MENU_TABLE_RPC"
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
var hasFilter = ({ filter }) => typeof filter === "string" && filter.length > 0;
|
|
298
|
+
var getMenuItemOptions = (menu, options) => {
|
|
299
|
+
switch (menu.context) {
|
|
300
|
+
case "cell":
|
|
301
|
+
return {
|
|
302
|
+
...menu,
|
|
303
|
+
field: options.columnName,
|
|
304
|
+
rowKey: options.row[KEY],
|
|
305
|
+
value: options.row[options.columnMap[options.columnName]]
|
|
306
|
+
};
|
|
307
|
+
case "row":
|
|
308
|
+
return {
|
|
309
|
+
...menu,
|
|
310
|
+
row: getRowRecord(options.row, options.columnMap),
|
|
311
|
+
rowKey: options.row[KEY]
|
|
312
|
+
};
|
|
313
|
+
default:
|
|
314
|
+
return menu;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
var menuShouldBeRenderedInThisContext = (menuItem, tableLocation, options) => {
|
|
318
|
+
var _a;
|
|
319
|
+
if (isGroupMenuItem(menuItem)) {
|
|
320
|
+
return menuItem.menus.some(
|
|
321
|
+
(childMenu) => menuShouldBeRenderedInThisContext(childMenu, tableLocation, options)
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
if (!vuuContextCompatibleWithTableLocation(
|
|
325
|
+
tableLocation,
|
|
326
|
+
menuItem.context,
|
|
327
|
+
(_a = options.selectedRows) == null ? void 0 : _a.length
|
|
328
|
+
)) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
if (tableLocation === "grid" && hasFilter(menuItem)) {
|
|
332
|
+
return gridRowMeetsFilterCriteria(
|
|
333
|
+
menuItem.context,
|
|
334
|
+
options.row,
|
|
335
|
+
options.selectedRows,
|
|
336
|
+
menuItem.filter,
|
|
337
|
+
options.columnMap
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
if (isCellMenu(menuItem) && menuItem.field !== "*") {
|
|
341
|
+
return menuItem.field === options.columnName;
|
|
342
|
+
}
|
|
343
|
+
return true;
|
|
344
|
+
};
|
|
345
|
+
var buildMenuDescriptor = (menu, tableLocation, options) => {
|
|
346
|
+
if (menuShouldBeRenderedInThisContext(menu, tableLocation, options)) {
|
|
347
|
+
if (isMenuItem(menu)) {
|
|
348
|
+
return {
|
|
349
|
+
label: menu.name,
|
|
350
|
+
action: "MENU_RPC_CALL",
|
|
351
|
+
options: getMenuItemOptions(menu, options)
|
|
352
|
+
};
|
|
353
|
+
} else {
|
|
354
|
+
const children = menu.menus.map(
|
|
355
|
+
(childMenu) => buildMenuDescriptor(childMenu, tableLocation, options)
|
|
356
|
+
).filter(
|
|
357
|
+
(childMenu) => childMenu !== void 0
|
|
358
|
+
);
|
|
359
|
+
if (children.length > 0) {
|
|
360
|
+
return {
|
|
361
|
+
label: menu.name,
|
|
362
|
+
children
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
var useVuuMenuActions = ({
|
|
369
|
+
dataSource,
|
|
370
|
+
menuActionConfig = NO_CONFIG,
|
|
371
|
+
onRpcResponse
|
|
372
|
+
}) => {
|
|
373
|
+
const buildViewserverMenuOptions = useCallback5(
|
|
374
|
+
(tableLocation, options) => {
|
|
375
|
+
const { visualLink, visualLinks, vuuMenu } = menuActionConfig;
|
|
376
|
+
const descriptors = [];
|
|
377
|
+
if (tableLocation === "grid" && visualLinks && !visualLink) {
|
|
378
|
+
visualLinks.forEach((linkDescriptor) => {
|
|
379
|
+
const { link, label: linkLabel } = linkDescriptor;
|
|
380
|
+
const label = linkLabel ? linkLabel : link.toTable;
|
|
381
|
+
descriptors.push({
|
|
382
|
+
label: `Link to ${label}`,
|
|
383
|
+
action: "link-table",
|
|
384
|
+
options: linkDescriptor
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
if (vuuMenu) {
|
|
389
|
+
const menuDescriptor = buildMenuDescriptor(
|
|
390
|
+
vuuMenu,
|
|
391
|
+
tableLocation,
|
|
392
|
+
options
|
|
393
|
+
);
|
|
394
|
+
if (isRoot(vuuMenu) && isGroupMenuItemDescriptor(menuDescriptor)) {
|
|
395
|
+
descriptors.push(...menuDescriptor.children);
|
|
396
|
+
} else if (menuDescriptor) {
|
|
397
|
+
descriptors.push(menuDescriptor);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return descriptors;
|
|
401
|
+
},
|
|
402
|
+
[menuActionConfig]
|
|
403
|
+
);
|
|
404
|
+
const handleMenuAction = useCallback5(
|
|
405
|
+
(type, options) => {
|
|
406
|
+
if (type === "MENU_RPC_CALL") {
|
|
407
|
+
const rpcRequest = getMenuRpcRequest(options);
|
|
408
|
+
dataSource.menuRpcCall(rpcRequest).then((rpcResponse) => {
|
|
409
|
+
if (onRpcResponse && rpcResponse) {
|
|
410
|
+
onRpcResponse && onRpcResponse(rpcResponse);
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
return true;
|
|
414
|
+
} else if (type === "link-table") {
|
|
415
|
+
return dataSource.visualLink = options, true;
|
|
416
|
+
} else {
|
|
417
|
+
console.log(
|
|
418
|
+
`useViewServer handleMenuAction, can't handle action type ${type}`
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
return false;
|
|
422
|
+
},
|
|
423
|
+
[dataSource, onRpcResponse]
|
|
424
|
+
);
|
|
425
|
+
return {
|
|
426
|
+
buildViewserverMenuOptions,
|
|
427
|
+
handleMenuAction
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
// src/hooks/useVuuTables.ts
|
|
432
|
+
import { useCallback as useCallback6, useEffect as useEffect4, useState as useState4 } from "react";
|
|
433
|
+
import { getServerAPI } from "@vuu-ui/vuu-data";
|
|
434
|
+
var useVuuTables = () => {
|
|
435
|
+
const [tables, setTables] = useState4();
|
|
436
|
+
const buildTables = useCallback6((schemas) => {
|
|
437
|
+
const vuuTables = /* @__PURE__ */ new Map();
|
|
438
|
+
schemas.forEach((schema) => {
|
|
439
|
+
vuuTables.set(schema.table.table, schema);
|
|
440
|
+
});
|
|
441
|
+
return vuuTables;
|
|
442
|
+
}, []);
|
|
443
|
+
useEffect4(() => {
|
|
444
|
+
async function fetchTableMetadata() {
|
|
445
|
+
const server = await getServerAPI();
|
|
446
|
+
const { tables: tables2 } = await server.getTableList();
|
|
447
|
+
const tableSchemas = buildTables(
|
|
448
|
+
await Promise.all(
|
|
449
|
+
tables2.map(
|
|
450
|
+
(tableDescriptor) => server.getTableSchema(tableDescriptor)
|
|
451
|
+
)
|
|
452
|
+
)
|
|
453
|
+
);
|
|
454
|
+
setTables(tableSchemas);
|
|
455
|
+
}
|
|
456
|
+
fetchTableMetadata();
|
|
457
|
+
}, [buildTables]);
|
|
458
|
+
return tables;
|
|
459
|
+
};
|
|
460
|
+
export {
|
|
461
|
+
MovingWindow,
|
|
462
|
+
addRowsFromInstruments,
|
|
463
|
+
getTypeaheadParams,
|
|
464
|
+
isViewportMenusAction,
|
|
465
|
+
isVisualLinkCreatedAction,
|
|
466
|
+
isVisualLinkRemovedAction,
|
|
467
|
+
isVisualLinksAction,
|
|
468
|
+
isVuuFeatureAction,
|
|
469
|
+
isVuuFeatureInvocation,
|
|
470
|
+
useDataSource,
|
|
471
|
+
useServerConnectionQuality,
|
|
472
|
+
useServerConnectionStatus,
|
|
473
|
+
useTypeaheadSuggestions,
|
|
474
|
+
useVuuMenuActions,
|
|
475
|
+
useVuuTables
|
|
476
|
+
};
|
|
2
477
|
//# sourceMappingURL=index.js.map
|